From 4bcf738068c2325e913b0507e237bb2a6e227634 Mon Sep 17 00:00:00 2001 From: lang Date: Thu, 10 Mar 2016 14:14:26 +0800 Subject: [PATCH] Dump 3.1.3 --- dist/echarts.common.js | 71069 ++++++++++---------- dist/echarts.common.min.js | 37 +- dist/echarts.js | 104460 +++++++++++++++--------------- dist/echarts.min.js | 46 +- dist/echarts.simple.js | 51537 +++++++-------- dist/echarts.simple.min.js | 31 +- dist/extension/bmap.js | 341 +- dist/extension/bmap.min.js | 1 + dist/extension/dataTool.js | 435 +- dist/extension/dataTool.min.js | 1 + package.json | 8 +- src/echarts.js | 4 +- 12 files changed, 116636 insertions(+), 111334 deletions(-) create mode 100644 dist/extension/bmap.min.js create mode 100644 dist/extension/dataTool.min.js diff --git a/dist/echarts.common.js b/dist/echarts.common.js index ffe58d1432..6ecf85526c 100644 --- a/dist/echarts.common.js +++ b/dist/echarts.common.js @@ -1,35104 +1,36409 @@ -(function (root, factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define([], factory); - } else if (typeof module === 'object' && module.exports) { - // Node. Does not work with strict CommonJS, but - // only CommonJS-like environments that support module.exports, - // like Node. - module.exports = factory(); - } else { - // Browser globals (root is window) - root.echarts = factory(); - } -}(this, function () { -var require, define; -(function () { - var mods = {}; - - define = function (id, deps, factory) { - // In case like - // define('echarts/model/globalDefault', {...}); - if (arguments.length === 2) { - factory = deps; - deps = []; - if (typeof factory !== 'function') { - var configObj = factory; - factory = function () { return configObj; }; - } - } - mods[id] = { - id: id, - deps: deps, - factory: factory, - defined: 0, - exports: {}, - require: createRequire(id) - }; - }; - - require = createRequire(''); - - function normalize(id, baseId) { - if (!baseId) { - return id; - } - - if (id.indexOf('.') === 0) { - var basePath = baseId.split('/'); - var namePath = id.split('/'); - var baseLen = basePath.length - 1; - var nameLen = namePath.length; - var cutBaseTerms = 0; - var cutNameTerms = 0; - - pathLoop: for (var i = 0; i < nameLen; i++) { - switch (namePath[i]) { - case '..': - if (cutBaseTerms < baseLen) { - cutBaseTerms++; - cutNameTerms++; - } - else { - break pathLoop; - } - break; - case '.': - cutNameTerms++; - break; - default: - break pathLoop; - } - } - - basePath.length = baseLen - cutBaseTerms; - namePath = namePath.slice(cutNameTerms); - - return basePath.concat(namePath).join('/'); - } - - return id; - } - - function createRequire(baseId) { - var cacheMods = {}; - - function localRequire(id, callback) { - if (typeof id === 'string') { - var exports = cacheMods[id]; - if (!exports) { - exports = getModExports(normalize(id, baseId)); - cacheMods[id] = exports; - } - - return exports; - } - else if (id instanceof Array) { - callback = callback || function () {}; - callback.apply(this, getModsExports(id, callback, baseId)); - } - }; - - return localRequire; - } - - function getModsExports(ids, factory, baseId) { - var es = []; - var mod = mods[baseId]; - - for (var i = 0, l = Math.min(ids.length, factory.length); i < l; i++) { - var id = normalize(ids[i], baseId); - var arg; - switch (id) { - case 'require': - arg = (mod && mod.require) || require; - break; - case 'exports': - arg = mod.exports; - break; - case 'module': - arg = mod; - break; - default: - arg = getModExports(id); - } - es.push(arg); - } - - return es; - } - - function getModExports(id) { - var mod = mods[id]; - if (!mod) { - throw new Error('No ' + id); - } - - if (!mod.defined) { - var factory = mod.factory; - var factoryReturn = factory.apply( - this, - getModsExports(mod.deps || [], factory, id) - ); - if (typeof factoryReturn !== 'undefined') { - mod.exports = factoryReturn; - } - mod.defined = 1; - } - - return mod.exports; - } -}()); - - -define('zrender/graphic/Gradient',['require'],function (require) { - - /** - * @param {Array.} colorStops - */ - var Gradient = function (colorStops) { - - this.colorStops = colorStops || []; - }; - - Gradient.prototype = { - - constructor: Gradient, - - addColorStop: function (offset, color) { - this.colorStops.push({ - - offset: offset, - - color: color - }); - } - }; - - return Gradient; -}); -/** - */ -define('zrender/core/util',['require','../graphic/Gradient'],function(require) { - var Gradient = require('../graphic/Gradient'); - // 用于处理merge时无法遍历Date等对象的问题 - var BUILTIN_OBJECT = { - '[object Function]': 1, - '[object RegExp]': 1, - '[object Date]': 1, - '[object Error]': 1, - '[object CanvasGradient]': 1 - }; - - var objToString = Object.prototype.toString; - - var arrayProto = Array.prototype; - var nativeForEach = arrayProto.forEach; - var nativeFilter = arrayProto.filter; - var nativeSlice = arrayProto.slice; - var nativeMap = arrayProto.map; - var nativeReduce = arrayProto.reduce; - - /** - * @param {*} source - * @return {*} 拷贝后的新对象 - */ - function clone(source) { - if (typeof source == 'object' && source !== null) { - var result = source; - if (source instanceof Array) { - result = []; - for (var i = 0, len = source.length; i < len; i++) { - result[i] = clone(source[i]); - } - } - else if ( - !isBuildInObject(source) - // 是否为 dom 对象 - && !isDom(source) - ) { - result = {}; - for (var key in source) { - if (source.hasOwnProperty(key)) { - result[key] = clone(source[key]); - } - } - } - - return result; - } - - return source; - } - - /** - * @param {*} target - * @param {*} source - * @param {boolean} [overwrite=false] - */ - function merge(target, source, overwrite) { - // We should escapse that source is string - // and enter for ... in ... - if (!isObject(source) || !isObject(target)) { - return overwrite ? clone(source) : target; - } - - for (var key in source) { - if (source.hasOwnProperty(key)) { - var targetProp = target[key]; - var sourceProp = source[key]; - - if (isObject(sourceProp) - && isObject(targetProp) - && !isArray(sourceProp) - && !isArray(targetProp) - && !isDom(sourceProp) - && !isDom(targetProp) - && !isBuildInObject(sourceProp) - && !isBuildInObject(targetProp) - ) { - // 如果需要递归覆盖,就递归调用merge - merge(targetProp, sourceProp, overwrite); - } - else if (overwrite || !(key in target)) { - // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况 - // NOTE,在 target[key] 不存在的时候也是直接覆盖 - target[key] = clone(source[key], true); - } - } - } - - return target; - } - - /** - * @param {Array} targetAndSources The first item is target, and the rests are source. - * @param {boolean} [overwrite=false] - * @return {*} target - */ - function mergeAll(targetAndSources, overwrite) { - var result = targetAndSources[0]; - for (var i = 1, len = targetAndSources.length; i < len; i++) { - result = merge(result, targetAndSources[i], overwrite); - } - return result; - } - - /** - * @param {*} target - * @param {*} source - */ - function extend(target, source) { - for (var key in source) { - if (source.hasOwnProperty(key)) { - target[key] = source[key]; - } - } - return target; - } - - /** - * @param {*} target - * @param {*} source - * @param {boolen} [overlay=false] - */ - function defaults(target, source, overlay) { - for (var key in source) { - if (source.hasOwnProperty(key) - && (overlay ? source[key] != null : target[key] == null) - ) { - target[key] = source[key]; - } - } - return target; - } - - function createCanvas() { - return document.createElement('canvas'); - } - // FIXME - var _ctx; - function getContext() { - if (!_ctx) { - // Use util.createCanvas instead of createCanvas - // because createCanvas may be overwritten in different environment - _ctx = util.createCanvas().getContext('2d'); - } - return _ctx; - } - - /** - * 查询数组中元素的index - */ - function indexOf(array, value) { - if (array) { - if (array.indexOf) { - return array.indexOf(value); - } - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] === value) { - return i; - } - } - } - return -1; - } - - /** - * 构造类继承关系 - * - * @param {Function} clazz 源类 - * @param {Function} baseClazz 基类 - */ - function inherits(clazz, baseClazz) { - var clazzPrototype = clazz.prototype; - function F() {} - F.prototype = baseClazz.prototype; - clazz.prototype = new F(); - - for (var prop in clazzPrototype) { - clazz.prototype[prop] = clazzPrototype[prop]; - } - clazz.prototype.constructor = clazz; - clazz.superClass = baseClazz; - } - - /** - * @param {Object|Function} target - * @param {Object|Function} sorce - * @param {boolean} overlay - */ - function mixin(target, source, overlay) { - target = 'prototype' in target ? target.prototype : target; - source = 'prototype' in source ? source.prototype : source; - - defaults(target, source, overlay); - } - - /** - * @param {Array|TypedArray} data - */ - function isArrayLike(data) { - if (! data) { - return; - } - if (typeof data == 'string') { - return false; - } - return typeof data.length == 'number'; - } - - /** - * 数组或对象遍历 - * @memberOf module:zrender/tool/util - * @param {Object|Array} obj - * @param {Function} cb - * @param {*} [context] - */ - function each(obj, cb, context) { - if (!(obj && cb)) { - return; - } - if (obj.forEach && obj.forEach === nativeForEach) { - obj.forEach(cb, context); - } - else if (obj.length === +obj.length) { - for (var i = 0, len = obj.length; i < len; i++) { - cb.call(context, obj[i], i, obj); - } - } - else { - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - cb.call(context, obj[key], key, obj); - } - } - } - } - - /** - * 数组映射 - * @memberOf module:zrender/tool/util - * @param {Array} obj - * @param {Function} cb - * @param {*} [context] - * @return {Array} - */ - function map(obj, cb, context) { - if (!(obj && cb)) { - return; - } - if (obj.map && obj.map === nativeMap) { - return obj.map(cb, context); - } - else { - var result = []; - for (var i = 0, len = obj.length; i < len; i++) { - result.push(cb.call(context, obj[i], i, obj)); - } - return result; - } - } - - /** - * @memberOf module:zrender/tool/util - * @param {Array} obj - * @param {Function} cb - * @param {Object} [memo] - * @param {*} [context] - * @return {Array} - */ - function reduce(obj, cb, memo, context) { - if (!(obj && cb)) { - return; - } - if (obj.reduce && obj.reduce === nativeReduce) { - return obj.reduce(cb, memo, context); - } - else { - for (var i = 0, len = obj.length; i < len; i++) { - memo = cb.call(context, memo, obj[i], i, obj); - } - return memo; - } - } - - /** - * 数组过滤 - * @memberOf module:zrender/tool/util - * @param {Array} obj - * @param {Function} cb - * @param {*} [context] - * @return {Array} - */ - function filter(obj, cb, context) { - if (!(obj && cb)) { - return; - } - if (obj.filter && obj.filter === nativeFilter) { - return obj.filter(cb, context); - } - else { - var result = []; - for (var i = 0, len = obj.length; i < len; i++) { - if (cb.call(context, obj[i], i, obj)) { - result.push(obj[i]); - } - } - return result; - } - } - - /** - * 数组项查找 - * @memberOf module:zrender/tool/util - * @param {Array} obj - * @param {Function} cb - * @param {*} [context] - * @return {Array} - */ - function find(obj, cb, context) { - if (!(obj && cb)) { - return; - } - for (var i = 0, len = obj.length; i < len; i++) { - if (cb.call(context, obj[i], i, obj)) { - return obj[i]; - } - } - } - - /** - * @memberOf module:zrender/tool/util - * @param {Function} func - * @param {*} context - * @return {Function} - */ - function bind(func, context) { - var args = nativeSlice.call(arguments, 2); - return function () { - return func.apply(context, args.concat(nativeSlice.call(arguments))); - }; - } - - /** - * @memberOf module:zrender/tool/util - * @param {Function} func - * @param {...} - * @return {Function} - */ - function curry(func) { - var args = nativeSlice.call(arguments, 1); - return function () { - return func.apply(this, args.concat(nativeSlice.call(arguments))); - }; - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isArray(value) { - return objToString.call(value) === '[object Array]'; - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isFunction(value) { - return typeof value === 'function'; - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isString(value) { - return objToString.call(value) === '[object String]'; - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isObject(value) { - // Avoid a V8 JIT bug in Chrome 19-20. - // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. - var type = typeof value; - return type === 'function' || (!!value && type == 'object'); - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isBuildInObject(value) { - return !!BUILTIN_OBJECT[objToString.call(value)] - || (value instanceof Gradient); - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isDom(value) { - return value && value.nodeType === 1 - && typeof(value.nodeName) == 'string'; - } - - /** - * If value1 is not null, then return value1, otherwise judget rest of values. - * @param {*...} values - * @return {*} Final value - */ - function retrieve(values) { - for (var i = 0, len = arguments.length; i < len; i++) { - if (arguments[i] != null) { - return arguments[i]; - } - } - } - - /** - * @memberOf module:zrender/tool/util - * @param {Array} arr - * @param {number} startIndex - * @param {number} endIndex - * @return {Array} - */ - function slice() { - return Function.call.apply(nativeSlice, arguments); - } - - /** - * @param {boolean} condition - * @param {string} message - */ - function assert(condition, message) { - if (!condition) { - throw new Error(message); - } - } - - var util = { - inherits: inherits, - mixin: mixin, - clone: clone, - merge: merge, - mergeAll: mergeAll, - extend: extend, - defaults: defaults, - getContext: getContext, - createCanvas: createCanvas, - indexOf: indexOf, - slice: slice, - find: find, - isArrayLike: isArrayLike, - each: each, - map: map, - reduce: reduce, - filter: filter, - bind: bind, - curry: curry, - isArray: isArray, - isString: isString, - isObject: isObject, - isFunction: isFunction, - isBuildInObject: isBuildInObject, - isDom: isDom, - retrieve: retrieve, - assert: assert, - noop: function () {} - }; - return util; -}); +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["echarts"] = factory(); + else + root["echarts"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Export echarts as CommonJS module + */ + module.exports = __webpack_require__(1); + + __webpack_require__(91); + __webpack_require__(127); + __webpack_require__(132); + __webpack_require__(141); + __webpack_require__(268); + __webpack_require__(262); + + __webpack_require__(106); + __webpack_require__(285); + + __webpack_require__(315); + __webpack_require__(319); + __webpack_require__(286); + __webpack_require__(331); + + __webpack_require__(345); + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + /*! + * ECharts, a javascript interactive chart library. + * + * Copyright (c) 2015, Baidu Inc. + * All rights reserved. + * + * LICENSE + * https://github.com/ecomfe/echarts/blob/master/LICENSE.txt + */ + + /** + * @module echarts + */ + + + var GlobalModel = __webpack_require__(2); + var ExtensionAPI = __webpack_require__(24); + var CoordinateSystemManager = __webpack_require__(25); + var OptionManager = __webpack_require__(26); + + var ComponentModel = __webpack_require__(19); + var SeriesModel = __webpack_require__(27); + + var ComponentView = __webpack_require__(28); + var ChartView = __webpack_require__(41); + var graphic = __webpack_require__(42); + + var zrender = __webpack_require__(77); + var zrUtil = __webpack_require__(3); + var colorTool = __webpack_require__(38); + var env = __webpack_require__(78); + var Eventful = __webpack_require__(32); + + var each = zrUtil.each; + + var VISUAL_CODING_STAGES = ['echarts', 'chart', 'component']; + + // TODO Transform first or filter first + var PROCESSOR_STAGES = ['transform', 'filter', 'statistic']; + + function createRegisterEventWithLowercaseName(method) { + return function (eventName, handler, context) { + // Event name is all lowercase + eventName = eventName && eventName.toLowerCase(); + Eventful.prototype[method].call(this, eventName, handler, context); + }; + } + /** + * @module echarts~MessageCenter + */ + function MessageCenter() { + Eventful.call(this); + } + MessageCenter.prototype.on = createRegisterEventWithLowercaseName('on'); + MessageCenter.prototype.off = createRegisterEventWithLowercaseName('off'); + MessageCenter.prototype.one = createRegisterEventWithLowercaseName('one'); + zrUtil.mixin(MessageCenter, Eventful); + /** + * @module echarts~ECharts + */ + function ECharts (dom, theme, opts) { + opts = opts || {}; + + // Get theme by name + if (typeof theme === 'string') { + theme = themeStorage[theme]; + } + + if (theme) { + each(optionPreprocessorFuncs, function (preProcess) { + preProcess(theme); + }); + } + /** + * @type {string} + */ + this.id; + /** + * Group id + * @type {string} + */ + this.group; + /** + * @type {HTMLDomElement} + * @private + */ + this._dom = dom; + /** + * @type {module:zrender/ZRender} + * @private + */ + this._zr = zrender.init(dom, { + renderer: opts.renderer || 'canvas', + devicePixelRatio: opts.devicePixelRatio + }); + + /** + * @type {Object} + * @private + */ + this._theme = zrUtil.clone(theme); + + /** + * @type {Array.} + * @private + */ + this._chartsViews = []; + + /** + * @type {Object.} + * @private + */ + this._chartsMap = {}; + + /** + * @type {Array.} + * @private + */ + this._componentsViews = []; + + /** + * @type {Object.} + * @private + */ + this._componentsMap = {}; + + /** + * @type {module:echarts/ExtensionAPI} + * @private + */ + this._api = new ExtensionAPI(this); + + /** + * @type {module:echarts/CoordinateSystem} + * @private + */ + this._coordSysMgr = new CoordinateSystemManager(); + + Eventful.call(this); + + /** + * @type {module:echarts~MessageCenter} + * @private + */ + this._messageCenter = new MessageCenter(); + + // Init mouse events + this._initEvents(); + + // In case some people write `window.onresize = chart.resize` + this.resize = zrUtil.bind(this.resize, this); + } + + var echartsProto = ECharts.prototype; + + /** + * @return {HTMLDomElement} + */ + echartsProto.getDom = function () { + return this._dom; + }; + + /** + * @return {module:zrender~ZRender} + */ + echartsProto.getZr = function () { + return this._zr; + }; + + /** + * @param {Object} option + * @param {boolean} notMerge + * @param {boolean} [notRefreshImmediately=false] Useful when setOption frequently. + */ + echartsProto.setOption = function (option, notMerge, notRefreshImmediately) { + if (!this._model || notMerge) { + this._model = new GlobalModel( + null, null, this._theme, new OptionManager(this._api) + ); + } + + this._model.setOption(option, optionPreprocessorFuncs); + + updateMethods.prepareAndUpdate.call(this); + + !notRefreshImmediately && this._zr.refreshImmediately(); + }; + + /** + * @DEPRECATED + */ + echartsProto.setTheme = function () { + console.log('ECharts#setTheme() is DEPRECATED in ECharts 3.0'); + }; + + /** + * @return {module:echarts/model/Global} + */ + echartsProto.getModel = function () { + return this._model; + }; + + /** + * @return {Object} + */ + echartsProto.getOption = function () { + return this._model.getOption(); + }; + + /** + * @return {number} + */ + echartsProto.getWidth = function () { + return this._zr.getWidth(); + }; + + /** + * @return {number} + */ + echartsProto.getHeight = function () { + return this._zr.getHeight(); + }; + + /** + * Get canvas which has all thing rendered + * @param {Object} opts + * @param {string} [opts.backgroundColor] + */ + echartsProto.getRenderedCanvas = function (opts) { + if (!env.canvasSupported) { + return; + } + opts = opts || {}; + opts.pixelRatio = opts.pixelRatio || 1; + opts.backgroundColor = opts.backgroundColor + || this._model.get('backgroundColor'); + var zr = this._zr; + var list = zr.storage.getDisplayList(); + // Stop animations + zrUtil.each(list, function (el) { + el.stopAnimation(true); + }); + return zr.painter.getRenderedCanvas(opts); + }; + /** + * @return {string} + * @param {Object} opts + * @param {string} [opts.type='png'] + * @param {string} [opts.pixelRatio=1] + * @param {string} [opts.backgroundColor] + */ + echartsProto.getDataURL = function (opts) { + opts = opts || {}; + var excludeComponents = opts.excludeComponents; + var ecModel = this._model; + var excludesComponentViews = []; + var self = this; + + each(excludeComponents, function (componentType) { + ecModel.eachComponent({ + mainType: componentType + }, function (component) { + var view = self._componentsMap[component.__viewId]; + if (!view.group.ignore) { + excludesComponentViews.push(view); + view.group.ignore = true; + } + }); + }); + + var url = this.getRenderedCanvas(opts).toDataURL( + 'image/' + (opts && opts.type || 'png') + ); + + each(excludesComponentViews, function (view) { + view.group.ignore = false; + }); + return url; + }; + + + /** + * @return {string} + * @param {Object} opts + * @param {string} [opts.type='png'] + * @param {string} [opts.pixelRatio=1] + * @param {string} [opts.backgroundColor] + */ + echartsProto.getConnectedDataURL = function (opts) { + if (!env.canvasSupported) { + return; + } + var groupId = this.group; + var mathMin = Math.min; + var mathMax = Math.max; + var MAX_NUMBER = Infinity; + if (connectedGroups[groupId]) { + var left = MAX_NUMBER; + var top = MAX_NUMBER; + var right = -MAX_NUMBER; + var bottom = -MAX_NUMBER; + var canvasList = []; + var dpr = (opts && opts.pixelRatio) || 1; + for (var id in instances) { + var chart = instances[id]; + if (chart.group === groupId) { + var canvas = chart.getRenderedCanvas( + zrUtil.clone(opts) + ); + var boundingRect = chart.getDom().getBoundingClientRect(); + left = mathMin(boundingRect.left, left); + top = mathMin(boundingRect.top, top); + right = mathMax(boundingRect.right, right); + bottom = mathMax(boundingRect.bottom, bottom); + canvasList.push({ + dom: canvas, + left: boundingRect.left, + top: boundingRect.top + }); + } + } + + left *= dpr; + top *= dpr; + right *= dpr; + bottom *= dpr; + var width = right - left; + var height = bottom - top; + var targetCanvas = zrUtil.createCanvas(); + targetCanvas.width = width; + targetCanvas.height = height; + var zr = zrender.init(targetCanvas); + + each(canvasList, function (item) { + var img = new graphic.Image({ + style: { + x: item.left * dpr - left, + y: item.top * dpr - top, + image: item.dom + } + }); + zr.add(img); + }); + zr.refreshImmediately(); + + return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png')); + } + else { + return this.getDataURL(opts); + } + }; + + var updateMethods = { + + /** + * @param {Object} payload + * @private + */ + update: function (payload) { + // console.time && console.time('update'); + + var ecModel = this._model; + var api = this._api; + var coordSysMgr = this._coordSysMgr; + // update before setOption + if (!ecModel) { + return; + } + + ecModel.restoreData(); + + // TODO + // Save total ecModel here for undo/redo (after restoring data and before processing data). + // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call. + + // Create new coordinate system each update + // In LineView may save the old coordinate system and use it to get the orignal point + coordSysMgr.create(this._model, this._api); + + processData.call(this, ecModel, api); + + stackSeriesData.call(this, ecModel); + + coordSysMgr.update(ecModel, api); + + doLayout.call(this, ecModel, payload); + + doVisualCoding.call(this, ecModel, payload); + + doRender.call(this, ecModel, payload); + + // Set background + var backgroundColor = ecModel.get('backgroundColor') || 'transparent'; + + var painter = this._zr.painter; + // TODO all use clearColor ? + if (painter.isSingleCanvas && painter.isSingleCanvas()) { + this._zr.configLayer(0, { + clearColor: backgroundColor + }); + } + else { + // In IE8 + if (!env.canvasSupported) { + var colorArr = colorTool.parse(backgroundColor); + backgroundColor = colorTool.stringify(colorArr, 'rgb'); + if (colorArr[3] === 0) { + backgroundColor = 'transparent'; + } + } + backgroundColor = backgroundColor; + this._dom.style.backgroundColor = backgroundColor; + } + + // console.time && console.timeEnd('update'); + }, + + // PENDING + /** + * @param {Object} payload + * @private + */ + updateView: function (payload) { + var ecModel = this._model; + + // update before setOption + if (!ecModel) { + return; + } + + doLayout.call(this, ecModel, payload); + + doVisualCoding.call(this, ecModel, payload); + + invokeUpdateMethod.call(this, 'updateView', ecModel, payload); + }, + + /** + * @param {Object} payload + * @private + */ + updateVisual: function (payload) { + var ecModel = this._model; + + // update before setOption + if (!ecModel) { + return; + } + + doVisualCoding.call(this, ecModel, payload); + + invokeUpdateMethod.call(this, 'updateVisual', ecModel, payload); + }, + + /** + * @param {Object} payload + * @private + */ + updateLayout: function (payload) { + var ecModel = this._model; + + // update before setOption + if (!ecModel) { + return; + } + + doLayout.call(this, ecModel, payload); + + invokeUpdateMethod.call(this, 'updateLayout', ecModel, payload); + }, + + /** + * @param {Object} payload + * @private + */ + highlight: function (payload) { + toggleHighlight.call(this, 'highlight', payload); + }, + + /** + * @param {Object} payload + * @private + */ + downplay: function (payload) { + toggleHighlight.call(this, 'downplay', payload); + }, + + /** + * @param {Object} payload + * @private + */ + prepareAndUpdate: function (payload) { + var ecModel = this._model; + + prepareView.call(this, 'component', ecModel); + + prepareView.call(this, 'chart', ecModel); + + updateMethods.update.call(this, payload); + } + }; + + /** + * @param {Object} payload + * @private + */ + function toggleHighlight(method, payload) { + var ecModel = this._model; + + // dispatchAction before setOption + if (!ecModel) { + return; + } + + ecModel.eachComponent( + {mainType: 'series', query: payload}, + function (seriesModel, index) { + var chartView = this._chartsMap[seriesModel.__viewId]; + if (chartView && chartView.__alive) { + chartView[method]( + seriesModel, ecModel, this._api, payload + ); + } + }, + this + ); + } + + /** + * Resize the chart + */ + echartsProto.resize = function () { + this._zr.resize(); + + var optionChanged = this._model && this._model.resetOption('media'); + updateMethods[optionChanged ? 'prepareAndUpdate' : 'update'].call(this); + + // Resize loading effect + this._loadingFX && this._loadingFX.resize(); + }; + + var defaultLoadingEffect = __webpack_require__(87); + /** + * Show loading effect + * @param {string} [name='default'] + * @param {Object} [cfg] + */ + echartsProto.showLoading = function (name, cfg) { + if (zrUtil.isObject(name)) { + cfg = name; + name = 'default'; + } + var el = defaultLoadingEffect(this._api, cfg); + var zr = this._zr; + this._loadingFX = el; + + zr.add(el); + }; + + /** + * Hide loading effect + */ + echartsProto.hideLoading = function () { + this._loadingFX && this._zr.remove(this._loadingFX); + this._loadingFX = null; + }; + + /** + * @param {Object} eventObj + * @return {Object} + */ + echartsProto.makeActionFromEvent = function (eventObj) { + var payload = zrUtil.extend({}, eventObj); + payload.type = eventActionMap[eventObj.type]; + return payload; + }; + + /** + * @pubilc + * @param {Object} payload + * @param {string} [payload.type] Action type + * @param {boolean} [silent=false] Whether trigger event. + */ + echartsProto.dispatchAction = function (payload, silent) { + var actionWrap = actions[payload.type]; + if (actionWrap) { + var actionInfo = actionWrap.actionInfo; + var updateMethod = actionInfo.update || 'update'; + + var payloads = [payload]; + var batched = false; + // Batch action + if (payload.batch) { + batched = true; + payloads = zrUtil.map(payload.batch, function (item) { + item = zrUtil.defaults(zrUtil.extend({}, item), payload); + item.batch = null; + return item; + }); + } + + var eventObjBatch = []; + var eventObj; + var isHighlightOrDownplay = payload.type === 'highlight' || payload.type === 'downplay'; + for (var i = 0; i < payloads.length; i++) { + var batchItem = payloads[i]; + // Action can specify the event by return it. + eventObj = actionWrap.action(batchItem, this._model); + // Emit event outside + eventObj = eventObj || zrUtil.extend({}, batchItem); + // Convert type to eventType + eventObj.type = actionInfo.event || eventObj.type; + eventObjBatch.push(eventObj); + + // Highlight and downplay are special. + isHighlightOrDownplay && updateMethods[updateMethod].call(this, batchItem); + } + + (updateMethod !== 'none' && !isHighlightOrDownplay) + && updateMethods[updateMethod].call(this, payload); + if (!silent) { + // Follow the rule of action batch + if (batched) { + eventObj = { + type: eventObjBatch[0].type, + batch: eventObjBatch + }; + } + else { + eventObj = eventObjBatch[0]; + } + this._messageCenter.trigger(eventObj.type, eventObj); + } + } + }; + + /** + * Register event + * @method + */ + echartsProto.on = createRegisterEventWithLowercaseName('on'); + echartsProto.off = createRegisterEventWithLowercaseName('off'); + echartsProto.one = createRegisterEventWithLowercaseName('one'); + + /** + * @param {string} methodName + * @private + */ + function invokeUpdateMethod(methodName, ecModel, payload) { + var api = this._api; + + // Update all components + each(this._componentsViews, function (component) { + var componentModel = component.__model; + component[methodName](componentModel, ecModel, api, payload); + + updateZ(componentModel, component); + }, this); + + // Upate all charts + ecModel.eachSeries(function (seriesModel, idx) { + var chart = this._chartsMap[seriesModel.__viewId]; + chart[methodName](seriesModel, ecModel, api, payload); + + updateZ(seriesModel, chart); + }, this); + + } + + /** + * Prepare view instances of charts and components + * @param {module:echarts/model/Global} ecModel + * @private + */ + function prepareView(type, ecModel) { + var isComponent = type === 'component'; + var viewList = isComponent ? this._componentsViews : this._chartsViews; + var viewMap = isComponent ? this._componentsMap : this._chartsMap; + var zr = this._zr; + + for (var i = 0; i < viewList.length; i++) { + viewList[i].__alive = false; + } + + ecModel[isComponent ? 'eachComponent' : 'eachSeries'](function (componentType, model) { + if (isComponent) { + if (componentType === 'series') { + return; + } + } + else { + model = componentType; + } + + // Consider: id same and type changed. + var viewId = model.id + '_' + model.type; + var view = viewMap[viewId]; + if (!view) { + var classType = ComponentModel.parseClassType(model.type); + var Clazz = isComponent + ? ComponentView.getClass(classType.main, classType.sub) + : ChartView.getClass(classType.sub); + if (Clazz) { + view = new Clazz(); + view.init(ecModel, this._api); + viewMap[viewId] = view; + viewList.push(view); + zr.add(view.group); + } + else { + // Error + return; + } + } + + model.__viewId = viewId; + view.__alive = true; + view.__id = viewId; + view.__model = model; + }, this); + + for (var i = 0; i < viewList.length;) { + var view = viewList[i]; + if (!view.__alive) { + zr.remove(view.group); + view.dispose(ecModel, this._api); + viewList.splice(i, 1); + delete viewMap[view.__id]; + } + else { + i++; + } + } + } + + /** + * Processor data in each series + * + * @param {module:echarts/model/Global} ecModel + * @private + */ + function processData(ecModel, api) { + each(PROCESSOR_STAGES, function (stage) { + each(dataProcessorFuncs[stage] || [], function (process) { + process(ecModel, api); + }); + }); + } + + /** + * @private + */ + function stackSeriesData(ecModel) { + var stackedDataMap = {}; + ecModel.eachSeries(function (series) { + var stack = series.get('stack'); + var data = series.getData(); + if (stack && data.type === 'list') { + var previousStack = stackedDataMap[stack]; + if (previousStack) { + data.stackedOn = previousStack; + } + stackedDataMap[stack] = data; + } + }); + } + + /** + * Layout before each chart render there series, after visual coding and data processing + * + * @param {module:echarts/model/Global} ecModel + * @private + */ + function doLayout(ecModel, payload) { + var api = this._api; + each(layoutFuncs, function (layout) { + layout(ecModel, api, payload); + }); + } + + /** + * Code visual infomation from data after data processing + * + * @param {module:echarts/model/Global} ecModel + * @private + */ + function doVisualCoding(ecModel, payload) { + each(VISUAL_CODING_STAGES, function (stage) { + each(visualCodingFuncs[stage] || [], function (visualCoding) { + visualCoding(ecModel, payload); + }); + }); + } + + /** + * Render each chart and component + * @private + */ + function doRender(ecModel, payload) { + var api = this._api; + // Render all components + each(this._componentsViews, function (componentView) { + var componentModel = componentView.__model; + componentView.render(componentModel, ecModel, api, payload); + + updateZ(componentModel, componentView); + }, this); + + each(this._chartsViews, function (chart) { + chart.__alive = false; + }, this); + + // Render all charts + ecModel.eachSeries(function (seriesModel, idx) { + var chartView = this._chartsMap[seriesModel.__viewId]; + chartView.__alive = true; + chartView.render(seriesModel, ecModel, api, payload); + + updateZ(seriesModel, chartView); + }, this); + + // Remove groups of unrendered charts + each(this._chartsViews, function (chart) { + if (!chart.__alive) { + chart.remove(ecModel, api); + } + }, this); + } + + var MOUSE_EVENT_NAMES = [ + 'click', 'dblclick', 'mouseover', 'mouseout', 'globalout' + ]; + /** + * @private + */ + echartsProto._initEvents = function () { + var zr = this._zr; + each(MOUSE_EVENT_NAMES, function (eveName) { + zr.on(eveName, function (e) { + var ecModel = this.getModel(); + var el = e.target; + if (el && el.dataIndex != null) { + var hostModel = el.hostModel || ecModel.getSeriesByIndex(el.seriesIndex); + var params = hostModel && hostModel.getDataParams(el.dataIndex) || {}; + params.event = e; + params.type = eveName; + this.trigger(eveName, params); + } + }, this); + }, this); + + each(eventActionMap, function (actionType, eventType) { + this._messageCenter.on(eventType, function (event) { + this.trigger(eventType, event); + }, this); + }, this); + }; + + /** + * @return {boolean} + */ + echartsProto.isDisposed = function () { + return this._disposed; + }; + + /** + * Clear + */ + echartsProto.clear = function () { + this.setOption({}, true); + }; + /** + * Dispose instance + */ + echartsProto.dispose = function () { + this._disposed = true; + var api = this._api; + var ecModel = this._model; + + each(this._componentsViews, function (component) { + component.dispose(ecModel, api); + }); + each(this._chartsViews, function (chart) { + chart.dispose(ecModel, api); + }); + + this._zr.dispose(); + + instances[this.id] = null; + }; + + zrUtil.mixin(ECharts, Eventful); + + /** + * @param {module:echarts/model/Series|module:echarts/model/Component} model + * @param {module:echarts/view/Component|module:echarts/view/Chart} view + * @return {string} + */ + function updateZ(model, view) { + var z = model.get('z'); + var zlevel = model.get('zlevel'); + // Set z and zlevel + view.group.traverse(function (el) { + z != null && (el.z = z); + zlevel != null && (el.zlevel = zlevel); + }); + } + /** + * @type {Array.} + * @inner + */ + var actions = []; + + /** + * Map eventType to actionType + * @type {Object} + */ + var eventActionMap = {}; + + /** + * @type {Array.} + * @inner + */ + var layoutFuncs = []; + + /** + * Data processor functions of each stage + * @type {Array.>} + * @inner + */ + var dataProcessorFuncs = {}; + + /** + * @type {Array.} + * @inner + */ + var optionPreprocessorFuncs = []; + + /** + * Visual coding functions of each stage + * @type {Array.>} + * @inner + */ + var visualCodingFuncs = {}; + /** + * Theme storage + * @type {Object.} + */ + var themeStorage = {}; + + + var instances = {}; + var connectedGroups = {}; + + var idBase = new Date() - 0; + var groupIdBase = new Date() - 0; + var DOM_ATTRIBUTE_KEY = '_echarts_instance_'; + /** + * @alias module:echarts + */ + var echarts = { + /** + * @type {number} + */ + version: '3.1.3', + dependencies: { + zrender: '3.0.4' + } + }; + + function enableConnect(chart) { + + var STATUS_PENDING = 0; + var STATUS_UPDATING = 1; + var STATUS_UPDATED = 2; + var STATUS_KEY = '__connectUpdateStatus'; + function updateConnectedChartsStatus(charts, status) { + for (var i = 0; i < charts.length; i++) { + var otherChart = charts[i]; + otherChart[STATUS_KEY] = status; + } + } + zrUtil.each(eventActionMap, function (actionType, eventType) { + chart._messageCenter.on(eventType, function (event) { + if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) { + var action = chart.makeActionFromEvent(event); + var otherCharts = []; + for (var id in instances) { + var otherChart = instances[id]; + if (otherChart !== chart && otherChart.group === chart.group) { + otherCharts.push(otherChart); + } + } + updateConnectedChartsStatus(otherCharts, STATUS_PENDING); + each(otherCharts, function (otherChart) { + if (otherChart[STATUS_KEY] !== STATUS_UPDATING) { + otherChart.dispatchAction(action); + } + }); + updateConnectedChartsStatus(otherCharts, STATUS_UPDATED); + } + }); + }); + + } + /** + * @param {HTMLDomElement} dom + * @param {Object} [theme] + * @param {Object} opts + */ + echarts.init = function (dom, theme, opts) { + // Check version + if ((zrender.version.replace('.', '') - 0) < (echarts.dependencies.zrender.replace('.', '') - 0)) { + throw new Error( + 'ZRender ' + zrender.version + + ' is too old for ECharts ' + echarts.version + + '. Current version need ZRender ' + + echarts.dependencies.zrender + '+' + ); + } + if (!dom) { + throw new Error('Initialize failed: invalid dom.'); + } + + var chart = new ECharts(dom, theme, opts); + chart.id = 'ec_' + idBase++; + instances[chart.id] = chart; + + dom.setAttribute && + dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id); + + enableConnect(chart); + + return chart; + }; + + /** + * @return {string|Array.} groupId + */ + echarts.connect = function (groupId) { + // Is array of charts + if (zrUtil.isArray(groupId)) { + var charts = groupId; + groupId = null; + // If any chart has group + zrUtil.each(charts, function (chart) { + if (chart.group != null) { + groupId = chart.group; + } + }); + groupId = groupId || ('g_' + groupIdBase++); + zrUtil.each(charts, function (chart) { + chart.group = groupId; + }); + } + connectedGroups[groupId] = true; + return groupId; + }; + + /** + * @return {string} groupId + */ + echarts.disConnect = function (groupId) { + connectedGroups[groupId] = false; + }; + + /** + * Dispose a chart instance + * @param {module:echarts~ECharts|HTMLDomElement|string} chart + */ + echarts.dispose = function (chart) { + if (zrUtil.isDom(chart)) { + chart = echarts.getInstanceByDom(chart); + } + else if (typeof chart === 'string') { + chart = instances[chart]; + } + if ((chart instanceof ECharts) && !chart.isDisposed()) { + chart.dispose(); + } + }; + + /** + * @param {HTMLDomElement} dom + * @return {echarts~ECharts} + */ + echarts.getInstanceByDom = function (dom) { + var key = dom.getAttribute(DOM_ATTRIBUTE_KEY); + return instances[key]; + }; + /** + * @param {string} key + * @return {echarts~ECharts} + */ + echarts.getInstanceById = function (key) { + return instances[key]; + }; + + /** + * Register theme + */ + echarts.registerTheme = function (name, theme) { + themeStorage[name] = theme; + }; + + /** + * Register option preprocessor + * @param {Function} preprocessorFunc + */ + echarts.registerPreprocessor = function (preprocessorFunc) { + optionPreprocessorFuncs.push(preprocessorFunc); + }; + + /** + * @param {string} stage + * @param {Function} processorFunc + */ + echarts.registerProcessor = function (stage, processorFunc) { + if (zrUtil.indexOf(PROCESSOR_STAGES, stage) < 0) { + throw new Error('stage should be one of ' + PROCESSOR_STAGES); + } + var funcs = dataProcessorFuncs[stage] || (dataProcessorFuncs[stage] = []); + funcs.push(processorFunc); + }; + + /** + * Usage: + * registerAction('someAction', 'someEvent', function () { ... }); + * registerAction('someAction', function () { ... }); + * registerAction( + * {type: 'someAction', event: 'someEvent', update: 'updateView'}, + * function () { ... } + * ); + * + * @param {(string|Object)} actionInfo + * @param {string} actionInfo.type + * @param {string} [actionInfo.event] + * @param {string} [actionInfo.update] + * @param {string} [eventName] + * @param {Function} action + */ + echarts.registerAction = function (actionInfo, eventName, action) { + if (typeof eventName === 'function') { + action = eventName; + eventName = ''; + } + var actionType = zrUtil.isObject(actionInfo) + ? actionInfo.type + : ([actionInfo, actionInfo = { + event: eventName + }][0]); + + // Event name is all lowercase + actionInfo.event = (actionInfo.event || actionType).toLowerCase(); + eventName = actionInfo.event; + + if (!actions[actionType]) { + actions[actionType] = {action: action, actionInfo: actionInfo}; + } + eventActionMap[eventName] = actionType; + }; + + /** + * @param {string} type + * @param {*} CoordinateSystem + */ + echarts.registerCoordinateSystem = function (type, CoordinateSystem) { + CoordinateSystemManager.register(type, CoordinateSystem); + }; + + /** + * @param {*} layout + */ + echarts.registerLayout = function (layout) { + // PENDING All functions ? + if (zrUtil.indexOf(layoutFuncs, layout) < 0) { + layoutFuncs.push(layout); + } + }; + + /** + * @param {string} stage + * @param {Function} visualCodingFunc + */ + echarts.registerVisualCoding = function (stage, visualCodingFunc) { + if (zrUtil.indexOf(VISUAL_CODING_STAGES, stage) < 0) { + throw new Error('stage should be one of ' + VISUAL_CODING_STAGES); + } + var funcs = visualCodingFuncs[stage] || (visualCodingFuncs[stage] = []); + funcs.push(visualCodingFunc); + }; + + /** + * @param {Object} opts + */ + echarts.extendChartView = function (opts) { + return ChartView.extend(opts); + }; + + /** + * @param {Object} opts + */ + echarts.extendComponentModel = function (opts) { + return ComponentModel.extend(opts); + }; + + /** + * @param {Object} opts + */ + echarts.extendSeriesModel = function (opts) { + return SeriesModel.extend(opts); + }; + + /** + * @param {Object} opts + */ + echarts.extendComponentView = function (opts) { + return ComponentView.extend(opts); + }; + + /** + * ZRender need a canvas context to do measureText. + * But in node environment canvas may be created by node-canvas. + * So we need to specify how to create a canvas instead of using document.createElement('canvas') + * + * Be careful of using it in the browser. + * + * @param {Function} creator + * @example + * var Canvas = require('canvas'); + * var echarts = require('echarts'); + * echarts.setCanvasCreator(function () { + * // Small size is enough. + * return new Canvas(32, 32); + * }); + */ + echarts.setCanvasCreator = function (creator) { + zrUtil.createCanvas = creator; + }; + + echarts.registerVisualCoding('echarts', zrUtil.curry( + __webpack_require__(88), '', 'itemStyle' + )); + echarts.registerPreprocessor(__webpack_require__(89)); + + // Default action + echarts.registerAction({ + type: 'highlight', + event: 'highlight', + update: 'highlight' + }, zrUtil.noop); + echarts.registerAction({ + type: 'downplay', + event: 'downplay', + update: 'downplay' + }, zrUtil.noop); + + + // -------- + // Exports + // -------- + + echarts.graphic = __webpack_require__(42); + echarts.number = __webpack_require__(7); + echarts.format = __webpack_require__(6); + echarts.matrix = __webpack_require__(17); + echarts.vector = __webpack_require__(16); + + echarts.util = {}; + each([ + 'map', 'each', 'filter', 'indexOf', 'inherits', + 'reduce', 'filter', 'bind', 'curry', 'isArray', + 'isString', 'isObject', 'isFunction', 'extend' + ], + function (name) { + echarts.util[name] = zrUtil[name]; + } + ); + + module.exports = echarts; + + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * ECharts global model + * + * @module {echarts/model/Global} + * + */ + + + + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var Model = __webpack_require__(8); + var each = zrUtil.each; + var filter = zrUtil.filter; + var map = zrUtil.map; + var isArray = zrUtil.isArray; + var indexOf = zrUtil.indexOf; + var isObject = zrUtil.isObject; + + var ComponentModel = __webpack_require__(19); + + var globalDefault = __webpack_require__(23); + + var OPTION_INNER_KEY = '\0_ec_inner'; + + /** + * @alias module:echarts/model/Global + * + * @param {Object} option + * @param {module:echarts/model/Model} parentModel + * @param {Object} theme + */ + var GlobalModel = Model.extend({ + + constructor: GlobalModel, + + init: function (option, parentModel, theme, optionManager) { + theme = theme || {}; + + this.option = null; // Mark as not initialized. + + /** + * @type {module:echarts/model/Model} + * @private + */ + this._theme = new Model(theme); + + /** + * @type {module:echarts/model/OptionManager} + */ + this._optionManager = optionManager; + }, + + setOption: function (option, optionPreprocessorFuncs) { + zrUtil.assert( + !(OPTION_INNER_KEY in option), + 'please use chart.getOption()' + ); + + this._optionManager.setOption(option, optionPreprocessorFuncs); + + this.resetOption(); + }, + + /** + * @param {string} type null/undefined: reset all. + * 'recreate': force recreate all. + * 'timeline': only reset timeline option + * 'media': only reset media query option + * @return {boolean} Whether option changed. + */ + resetOption: function (type) { + var optionChanged = false; + var optionManager = this._optionManager; + + if (!type || type === 'recreate') { + var baseOption = optionManager.mountOption(type === 'recreate'); + + if (!this.option || type === 'recreate') { + initBase.call(this, baseOption); + } + else { + this.restoreData(); + this.mergeOption(baseOption); + } + optionChanged = true; + } + + if (type === 'timeline' || type === 'media') { + this.restoreData(); + } + + if (!type || type === 'recreate' || type === 'timeline') { + var timelineOption = optionManager.getTimelineOption(this); + timelineOption && (this.mergeOption(timelineOption), optionChanged = true); + } + + if (!type || type === 'recreate' || type === 'media') { + var mediaOptions = optionManager.getMediaOption(this, this._api); + if (mediaOptions.length) { + each(mediaOptions, function (mediaOption) { + this.mergeOption(mediaOption, optionChanged = true); + }, this); + } + } + + return optionChanged; + }, + + /** + * @protected + */ + mergeOption: function (newOption) { + var option = this.option; + var componentsMap = this._componentsMap; + var newCptTypes = []; + + // 如果不存在对应的 component model 则直接 merge + each(newOption, function (componentOption, mainType) { + if (componentOption == null) { + return; + } + + if (!ComponentModel.hasClass(mainType)) { + option[mainType] = option[mainType] == null + ? zrUtil.clone(componentOption) + : zrUtil.merge(option[mainType], componentOption, true); + } + else { + newCptTypes.push(mainType); + } + }); + + // FIXME OPTION 同步是否要改回原来的 + ComponentModel.topologicalTravel( + newCptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this + ); + + function visitComponent(mainType, dependencies) { + var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]); + + var mapResult = modelUtil.mappingToExists( + componentsMap[mainType], newCptOptionList + ); + + makeKeyInfo(mainType, mapResult); + + var dependentModels = getComponentsByTypes( + componentsMap, dependencies + ); + + option[mainType] = []; + componentsMap[mainType] = []; + + each(mapResult, function (resultItem, index) { + var componentModel = resultItem.exist; + var newCptOption = resultItem.option; + + zrUtil.assert( + isObject(newCptOption) || componentModel, + 'Empty component definition' + ); + + // Consider where is no new option and should be merged using {}, + // see removeEdgeAndAdd in topologicalTravel and + // ComponentModel.getAllClassMainTypes. + if (!newCptOption) { + componentModel.mergeOption({}, this); + componentModel.optionUpdated(this); + } + else { + var ComponentModelClass = ComponentModel.getClass( + mainType, resultItem.keyInfo.subType, true + ); + + if (componentModel && componentModel instanceof ComponentModelClass) { + componentModel.mergeOption(newCptOption, this); + componentModel.optionUpdated(this); + } + else { + // PENDING Global as parent ? + componentModel = new ComponentModelClass( + newCptOption, this, this, + zrUtil.extend( + { + dependentModels: dependentModels, + componentIndex: index + }, + resultItem.keyInfo + ) + ); + // Call optionUpdated after init + componentModel.optionUpdated(this); + } + } + + componentsMap[mainType][index] = componentModel; + option[mainType][index] = componentModel.option; + }, this); + + // Backup series for filtering. + if (mainType === 'series') { + this._seriesIndices = createSeriesIndices(componentsMap.series); + } + } + }, + + /** + * Get option for output (cloned option and inner info removed) + * @public + * @return {Object} + */ + getOption: function () { + var option = zrUtil.clone(this.option); + + each(option, function (opts, mainType) { + if (ComponentModel.hasClass(mainType)) { + var opts = modelUtil.normalizeToArray(opts); + for (var i = opts.length - 1; i >= 0; i--) { + // Remove options with inner id. + if (modelUtil.isIdInner(opts[i])) { + opts.splice(i, 1); + } + } + option[mainType] = opts; + } + }); + + delete option[OPTION_INNER_KEY]; + + return option; + }, + + /** + * @return {module:echarts/model/Model} + */ + getTheme: function () { + return this._theme; + }, + + /** + * @param {string} mainType + * @param {number} [idx=0] + * @return {module:echarts/model/Component} + */ + getComponent: function (mainType, idx) { + var list = this._componentsMap[mainType]; + if (list) { + return list[idx || 0]; + } + }, + + /** + * @param {Object} condition + * @param {string} condition.mainType + * @param {string} [condition.subType] If ignore, only query by mainType + * @param {number} [condition.index] Either input index or id or name. + * @param {string} [condition.id] Either input index or id or name. + * @param {string} [condition.name] Either input index or id or name. + * @return {Array.} + */ + queryComponents: function (condition) { + var mainType = condition.mainType; + if (!mainType) { + return []; + } + + var index = condition.index; + var id = condition.id; + var name = condition.name; + + var cpts = this._componentsMap[mainType]; + + if (!cpts || !cpts.length) { + return []; + } + + var result; + + if (index != null) { + if (!isArray(index)) { + index = [index]; + } + result = filter(map(index, function (idx) { + return cpts[idx]; + }), function (val) { + return !!val; + }); + } + else if (id != null) { + var isIdArray = isArray(id); + result = filter(cpts, function (cpt) { + return (isIdArray && indexOf(id, cpt.id) >= 0) + || (!isIdArray && cpt.id === id); + }); + } + else if (name != null) { + var isNameArray = isArray(name); + result = filter(cpts, function (cpt) { + return (isNameArray && indexOf(name, cpt.name) >= 0) + || (!isNameArray && cpt.name === name); + }); + } + + return filterBySubType(result, condition); + }, + + /** + * The interface is different from queryComponents, + * which is convenient for inner usage. + * + * @usage + * findComponents( + * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}, + * function (model, index) {...} + * ); + * + * findComponents( + * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}, + * function (model, index) {...} + * ); + * + * var result = findComponents( + * {mainType: 'series'}, + * function (model, index) {...} + * ); + * // result like [component0, componnet1, ...] + * + * @param {Object} condition + * @param {string} condition.mainType Mandatory. + * @param {string} [condition.subType] Optional. + * @param {Object} [condition.query] like {xxxIndex, xxxId, xxxName}, + * where xxx is mainType. + * If query attribute is null/undefined or has no index/id/name, + * do not filtering by query conditions, which is convenient for + * no-payload situations or when target of action is global. + * @param {Function} [condition.filter] parameter: component, return boolean. + * @return {Array.} + */ + findComponents: function (condition) { + var query = condition.query; + var mainType = condition.mainType; + + var queryCond = getQueryCond(query); + var result = queryCond + ? this.queryComponents(queryCond) + : this._componentsMap[mainType]; + + return doFilter(filterBySubType(result, condition)); + + function getQueryCond(q) { + var indexAttr = mainType + 'Index'; + var idAttr = mainType + 'Id'; + var nameAttr = mainType + 'Name'; + return q && ( + q.hasOwnProperty(indexAttr) + || q.hasOwnProperty(idAttr) + || q.hasOwnProperty(nameAttr) + ) + ? { + mainType: mainType, + // subType will be filtered finally. + index: q[indexAttr], + id: q[idAttr], + name: q[nameAttr] + } + : null; + } + + function doFilter(res) { + return condition.filter + ? filter(res, condition.filter) + : res; + } + }, + + /** + * @usage + * eachComponent('legend', function (legendModel, index) { + * ... + * }); + * eachComponent(function (componentType, model, index) { + * // componentType does not include subType + * // (componentType is 'xxx' but not 'xxx.aa') + * }); + * eachComponent( + * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}, + * function (model, index) {...} + * ); + * eachComponent( + * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}, + * function (model, index) {...} + * ); + * + * @param {string|Object=} mainType When mainType is object, the definition + * is the same as the method 'findComponents'. + * @param {Function} cb + * @param {*} context + */ + eachComponent: function (mainType, cb, context) { + var componentsMap = this._componentsMap; + + if (typeof mainType === 'function') { + context = cb; + cb = mainType; + each(componentsMap, function (components, componentType) { + each(components, function (component, index) { + cb.call(context, componentType, component, index); + }); + }); + } + else if (zrUtil.isString(mainType)) { + each(componentsMap[mainType], cb, context); + } + else if (isObject(mainType)) { + var queryResult = this.findComponents(mainType); + each(queryResult, cb, context); + } + }, + + /** + * @param {string} name + * @return {Array.} + */ + getSeriesByName: function (name) { + var series = this._componentsMap.series; + return filter(series, function (oneSeries) { + return oneSeries.name === name; + }); + }, + + /** + * @param {number} seriesIndex + * @return {module:echarts/model/Series} + */ + getSeriesByIndex: function (seriesIndex) { + return this._componentsMap.series[seriesIndex]; + }, + + /** + * @param {string} subType + * @return {Array.} + */ + getSeriesByType: function (subType) { + var series = this._componentsMap.series; + return filter(series, function (oneSeries) { + return oneSeries.subType === subType; + }); + }, + + /** + * @return {Array.} + */ + getSeries: function () { + return this._componentsMap.series.slice(); + }, + + /** + * After filtering, series may be different + * frome raw series. + * + * @param {Function} cb + * @param {*} context + */ + eachSeries: function (cb, context) { + assertSeriesInitialized(this); + each(this._seriesIndices, function (rawSeriesIndex) { + var series = this._componentsMap.series[rawSeriesIndex]; + cb.call(context, series, rawSeriesIndex); + }, this); + }, + + /** + * Iterate raw series before filtered. + * + * @param {Function} cb + * @param {*} context + */ + eachRawSeries: function (cb, context) { + each(this._componentsMap.series, cb, context); + }, + + /** + * After filtering, series may be different. + * frome raw series. + * + * @parma {string} subType + * @param {Function} cb + * @param {*} context + */ + eachSeriesByType: function (subType, cb, context) { + assertSeriesInitialized(this); + each(this._seriesIndices, function (rawSeriesIndex) { + var series = this._componentsMap.series[rawSeriesIndex]; + if (series.subType === subType) { + cb.call(context, series, rawSeriesIndex); + } + }, this); + }, + + /** + * Iterate raw series before filtered of given type. + * + * @parma {string} subType + * @param {Function} cb + * @param {*} context + */ + eachRawSeriesByType: function (subType, cb, context) { + return each(this.getSeriesByType(subType), cb, context); + }, + + /** + * @param {module:echarts/model/Series} seriesModel + */ + isSeriesFiltered: function (seriesModel) { + assertSeriesInitialized(this); + return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0; + }, + + /** + * @param {Function} cb + * @param {*} context + */ + filterSeries: function (cb, context) { + assertSeriesInitialized(this); + var filteredSeries = filter( + this._componentsMap.series, cb, context + ); + this._seriesIndices = createSeriesIndices(filteredSeries); + }, + + restoreData: function () { + var componentsMap = this._componentsMap; + + this._seriesIndices = createSeriesIndices(componentsMap.series); + + var componentTypes = []; + each(componentsMap, function (components, componentType) { + componentTypes.push(componentType); + }); + + ComponentModel.topologicalTravel( + componentTypes, + ComponentModel.getAllClassMainTypes(), + function (componentType, dependencies) { + each(componentsMap[componentType], function (component) { + component.restoreData(); + }); + } + ); + } + + }); + + /** + * @inner + */ + function mergeTheme(option, theme) { + for (var name in theme) { + // 如果有 component model 则把具体的 merge 逻辑交给该 model 处理 + if (!ComponentModel.hasClass(name)) { + if (typeof theme[name] === 'object') { + option[name] = !option[name] + ? zrUtil.clone(theme[name]) + : zrUtil.merge(option[name], theme[name], false); + } + else { + option[name] = theme[name]; + } + } + } + } + + function initBase(baseOption) { + baseOption = baseOption; + + // Using OPTION_INNER_KEY to mark that this option can not be used outside, + // i.e. `chart.setOption(chart.getModel().option);` is forbiden. + this.option = {}; + this.option[OPTION_INNER_KEY] = 1; + + /** + * @type {Object.>} + * @private + */ + this._componentsMap = {}; + + /** + * Mapping between filtered series list and raw series list. + * key: filtered series indices, value: raw series indices. + * @type {Array.} + * @private + */ + this._seriesIndices = null; + + mergeTheme(baseOption, this._theme.option); + + // TODO Needs clone when merging to the unexisted property + zrUtil.merge(baseOption, globalDefault, false); + + this.mergeOption(baseOption); + } + + /** + * @inner + * @param {Array.|string} types model types + * @return {Object} key: {string} type, value: {Array.} models + */ + function getComponentsByTypes(componentsMap, types) { + if (!zrUtil.isArray(types)) { + types = types ? [types] : []; + } + + var ret = {}; + each(types, function (type) { + ret[type] = (componentsMap[type] || []).slice(); + }); + + return ret; + } + + /** + * @inner + */ + function makeKeyInfo(mainType, mapResult) { + // We use this id to hash component models and view instances + // in echarts. id can be specified by user, or auto generated. + + // The id generation rule ensures new view instance are able + // to mapped to old instance when setOption are called in + // no-merge mode. So we generate model id by name and plus + // type in view id. + + // name can be duplicated among components, which is convenient + // to specify multi components (like series) by one name. + + // Ensure that each id is distinct. + var idMap = {}; + + each(mapResult, function (item, index) { + var existCpt = item.exist; + existCpt && (idMap[existCpt.id] = item); + }); + + each(mapResult, function (item, index) { + var opt = item.option; + + zrUtil.assert( + !opt || opt.id == null || !idMap[opt.id] || idMap[opt.id] === item, + 'id duplicates: ' + (opt && opt.id) + ); + + opt && opt.id != null && (idMap[opt.id] = item); + + // Complete subType + if (isObject(opt)) { + var subType = determineSubType(mainType, opt, item.exist); + item.keyInfo = {mainType: mainType, subType: subType}; + } + }); + + // Make name and id. + each(mapResult, function (item, index) { + var existCpt = item.exist; + var opt = item.option; + var keyInfo = item.keyInfo; + + if (!isObject(opt)) { + return; + } + + // name can be overwitten. Consider case: axis.name = '20km'. + // But id generated by name will not be changed, which affect + // only in that case: setOption with 'not merge mode' and view + // instance will be recreated, which can be accepted. + keyInfo.name = opt.name != null + ? opt.name + '' + : existCpt + ? existCpt.name + : '\0-'; + + if (existCpt) { + keyInfo.id = existCpt.id; + } + else if (opt.id != null) { + keyInfo.id = opt.id + ''; + } + else { + // Consider this situatoin: + // optionA: [{name: 'a'}, {name: 'a'}, {..}] + // optionB [{..}, {name: 'a'}, {name: 'a'}] + // Series with the same name between optionA and optionB + // should be mapped. + var idNum = 0; + do { + keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++; + } + while (idMap[keyInfo.id]); + } + + idMap[keyInfo.id] = item; + }); + } + + /** + * @inner + */ + function determineSubType(mainType, newCptOption, existComponent) { + var subType = newCptOption.type + ? newCptOption.type + : existComponent + ? existComponent.subType + // Use determineSubType only when there is no existComponent. + : ComponentModel.determineSubType(mainType, newCptOption); + + // tooltip, markline, markpoint may always has no subType + return subType; + } + + /** + * @inner + */ + function createSeriesIndices(seriesModels) { + return map(seriesModels, function (series) { + return series.componentIndex; + }) || []; + } + + /** + * @inner + */ + function filterBySubType(components, condition) { + // Using hasOwnProperty for restrict. Consider + // subType is undefined in user payload. + return condition.hasOwnProperty('subType') + ? filter(components, function (cpt) { + return cpt.subType === condition.subType; + }) + : components; + } + + /** + * @inner + */ + function assertSeriesInitialized(ecModel) { + // Components that use _seriesIndices should depends on series component, + // which make sure that their initialization is after series. + if (!ecModel._seriesIndices) { + // FIXME + // 验证和提示怎么写 + throw new Error('Series has not been initialized yet.'); + } + } + + module.exports = GlobalModel; + + +/***/ }, +/* 3 */ +/***/ function(module, exports, __webpack_require__) { + + /** + */ + + var Gradient = __webpack_require__(4); + // 用于处理merge时无法遍历Date等对象的问题 + var BUILTIN_OBJECT = { + '[object Function]': 1, + '[object RegExp]': 1, + '[object Date]': 1, + '[object Error]': 1, + '[object CanvasGradient]': 1 + }; + + var objToString = Object.prototype.toString; + + var arrayProto = Array.prototype; + var nativeForEach = arrayProto.forEach; + var nativeFilter = arrayProto.filter; + var nativeSlice = arrayProto.slice; + var nativeMap = arrayProto.map; + var nativeReduce = arrayProto.reduce; + + /** + * @param {*} source + * @return {*} 拷贝后的新对象 + */ + function clone(source) { + if (typeof source == 'object' && source !== null) { + var result = source; + if (source instanceof Array) { + result = []; + for (var i = 0, len = source.length; i < len; i++) { + result[i] = clone(source[i]); + } + } + else if ( + !isBuildInObject(source) + // 是否为 dom 对象 + && !isDom(source) + ) { + result = {}; + for (var key in source) { + if (source.hasOwnProperty(key)) { + result[key] = clone(source[key]); + } + } + } + + return result; + } + + return source; + } + + /** + * @param {*} target + * @param {*} source + * @param {boolean} [overwrite=false] + */ + function merge(target, source, overwrite) { + // We should escapse that source is string + // and enter for ... in ... + if (!isObject(source) || !isObject(target)) { + return overwrite ? clone(source) : target; + } + + for (var key in source) { + if (source.hasOwnProperty(key)) { + var targetProp = target[key]; + var sourceProp = source[key]; + + if (isObject(sourceProp) + && isObject(targetProp) + && !isArray(sourceProp) + && !isArray(targetProp) + && !isDom(sourceProp) + && !isDom(targetProp) + && !isBuildInObject(sourceProp) + && !isBuildInObject(targetProp) + ) { + // 如果需要递归覆盖,就递归调用merge + merge(targetProp, sourceProp, overwrite); + } + else if (overwrite || !(key in target)) { + // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况 + // NOTE,在 target[key] 不存在的时候也是直接覆盖 + target[key] = clone(source[key], true); + } + } + } + + return target; + } + + /** + * @param {Array} targetAndSources The first item is target, and the rests are source. + * @param {boolean} [overwrite=false] + * @return {*} target + */ + function mergeAll(targetAndSources, overwrite) { + var result = targetAndSources[0]; + for (var i = 1, len = targetAndSources.length; i < len; i++) { + result = merge(result, targetAndSources[i], overwrite); + } + return result; + } + + /** + * @param {*} target + * @param {*} source + */ + function extend(target, source) { + for (var key in source) { + if (source.hasOwnProperty(key)) { + target[key] = source[key]; + } + } + return target; + } + + /** + * @param {*} target + * @param {*} source + * @param {boolen} [overlay=false] + */ + function defaults(target, source, overlay) { + for (var key in source) { + if (source.hasOwnProperty(key) + && (overlay ? source[key] != null : target[key] == null) + ) { + target[key] = source[key]; + } + } + return target; + } + + function createCanvas() { + return document.createElement('canvas'); + } + // FIXME + var _ctx; + function getContext() { + if (!_ctx) { + // Use util.createCanvas instead of createCanvas + // because createCanvas may be overwritten in different environment + _ctx = util.createCanvas().getContext('2d'); + } + return _ctx; + } + + /** + * 查询数组中元素的index + */ + function indexOf(array, value) { + if (array) { + if (array.indexOf) { + return array.indexOf(value); + } + for (var i = 0, len = array.length; i < len; i++) { + if (array[i] === value) { + return i; + } + } + } + return -1; + } + + /** + * 构造类继承关系 + * + * @param {Function} clazz 源类 + * @param {Function} baseClazz 基类 + */ + function inherits(clazz, baseClazz) { + var clazzPrototype = clazz.prototype; + function F() {} + F.prototype = baseClazz.prototype; + clazz.prototype = new F(); + + for (var prop in clazzPrototype) { + clazz.prototype[prop] = clazzPrototype[prop]; + } + clazz.prototype.constructor = clazz; + clazz.superClass = baseClazz; + } + + /** + * @param {Object|Function} target + * @param {Object|Function} sorce + * @param {boolean} overlay + */ + function mixin(target, source, overlay) { + target = 'prototype' in target ? target.prototype : target; + source = 'prototype' in source ? source.prototype : source; + + defaults(target, source, overlay); + } + + /** + * @param {Array|TypedArray} data + */ + function isArrayLike(data) { + if (! data) { + return; + } + if (typeof data == 'string') { + return false; + } + return typeof data.length == 'number'; + } + + /** + * 数组或对象遍历 + * @memberOf module:zrender/tool/util + * @param {Object|Array} obj + * @param {Function} cb + * @param {*} [context] + */ + function each(obj, cb, context) { + if (!(obj && cb)) { + return; + } + if (obj.forEach && obj.forEach === nativeForEach) { + obj.forEach(cb, context); + } + else if (obj.length === +obj.length) { + for (var i = 0, len = obj.length; i < len; i++) { + cb.call(context, obj[i], i, obj); + } + } + else { + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + cb.call(context, obj[key], key, obj); + } + } + } + } + + /** + * 数组映射 + * @memberOf module:zrender/tool/util + * @param {Array} obj + * @param {Function} cb + * @param {*} [context] + * @return {Array} + */ + function map(obj, cb, context) { + if (!(obj && cb)) { + return; + } + if (obj.map && obj.map === nativeMap) { + return obj.map(cb, context); + } + else { + var result = []; + for (var i = 0, len = obj.length; i < len; i++) { + result.push(cb.call(context, obj[i], i, obj)); + } + return result; + } + } + + /** + * @memberOf module:zrender/tool/util + * @param {Array} obj + * @param {Function} cb + * @param {Object} [memo] + * @param {*} [context] + * @return {Array} + */ + function reduce(obj, cb, memo, context) { + if (!(obj && cb)) { + return; + } + if (obj.reduce && obj.reduce === nativeReduce) { + return obj.reduce(cb, memo, context); + } + else { + for (var i = 0, len = obj.length; i < len; i++) { + memo = cb.call(context, memo, obj[i], i, obj); + } + return memo; + } + } + + /** + * 数组过滤 + * @memberOf module:zrender/tool/util + * @param {Array} obj + * @param {Function} cb + * @param {*} [context] + * @return {Array} + */ + function filter(obj, cb, context) { + if (!(obj && cb)) { + return; + } + if (obj.filter && obj.filter === nativeFilter) { + return obj.filter(cb, context); + } + else { + var result = []; + for (var i = 0, len = obj.length; i < len; i++) { + if (cb.call(context, obj[i], i, obj)) { + result.push(obj[i]); + } + } + return result; + } + } + + /** + * 数组项查找 + * @memberOf module:zrender/tool/util + * @param {Array} obj + * @param {Function} cb + * @param {*} [context] + * @return {Array} + */ + function find(obj, cb, context) { + if (!(obj && cb)) { + return; + } + for (var i = 0, len = obj.length; i < len; i++) { + if (cb.call(context, obj[i], i, obj)) { + return obj[i]; + } + } + } + + /** + * @memberOf module:zrender/tool/util + * @param {Function} func + * @param {*} context + * @return {Function} + */ + function bind(func, context) { + var args = nativeSlice.call(arguments, 2); + return function () { + return func.apply(context, args.concat(nativeSlice.call(arguments))); + }; + } + + /** + * @memberOf module:zrender/tool/util + * @param {Function} func + * @param {...} + * @return {Function} + */ + function curry(func) { + var args = nativeSlice.call(arguments, 1); + return function () { + return func.apply(this, args.concat(nativeSlice.call(arguments))); + }; + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isArray(value) { + return objToString.call(value) === '[object Array]'; + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isFunction(value) { + return typeof value === 'function'; + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isString(value) { + return objToString.call(value) === '[object String]'; + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isObject(value) { + // Avoid a V8 JIT bug in Chrome 19-20. + // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. + var type = typeof value; + return type === 'function' || (!!value && type == 'object'); + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isBuildInObject(value) { + return !!BUILTIN_OBJECT[objToString.call(value)] + || (value instanceof Gradient); + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isDom(value) { + return value && value.nodeType === 1 + && typeof(value.nodeName) == 'string'; + } + + /** + * If value1 is not null, then return value1, otherwise judget rest of values. + * @param {*...} values + * @return {*} Final value + */ + function retrieve(values) { + for (var i = 0, len = arguments.length; i < len; i++) { + if (arguments[i] != null) { + return arguments[i]; + } + } + } + + /** + * @memberOf module:zrender/tool/util + * @param {Array} arr + * @param {number} startIndex + * @param {number} endIndex + * @return {Array} + */ + function slice() { + return Function.call.apply(nativeSlice, arguments); + } + + /** + * @param {boolean} condition + * @param {string} message + */ + function assert(condition, message) { + if (!condition) { + throw new Error(message); + } + } + + var util = { + inherits: inherits, + mixin: mixin, + clone: clone, + merge: merge, + mergeAll: mergeAll, + extend: extend, + defaults: defaults, + getContext: getContext, + createCanvas: createCanvas, + indexOf: indexOf, + slice: slice, + find: find, + isArrayLike: isArrayLike, + each: each, + map: map, + reduce: reduce, + filter: filter, + bind: bind, + curry: curry, + isArray: isArray, + isString: isString, + isObject: isObject, + isFunction: isFunction, + isBuildInObject: isBuildInObject, + isDom: isDom, + retrieve: retrieve, + assert: assert, + noop: function () {} + }; + module.exports = util; + + + +/***/ }, +/* 4 */ +/***/ function(module, exports) { + + + + /** + * @param {Array.} colorStops + */ + var Gradient = function (colorStops) { + + this.colorStops = colorStops || []; + }; + + Gradient.prototype = { + + constructor: Gradient, + + addColorStop: function (offset, color) { + this.colorStops.push({ + + offset: offset, + + color: color + }); + } + }; + + module.exports = Gradient; + + +/***/ }, +/* 5 */ +/***/ function(module, exports, __webpack_require__) { + + + + var formatUtil = __webpack_require__(6); + var nubmerUtil = __webpack_require__(7); + var zrUtil = __webpack_require__(3); + + var Model = __webpack_require__(8); + + var AXIS_DIMS = ['x', 'y', 'z', 'radius', 'angle']; + + var modelUtil = {}; + + /** + * Create "each" method to iterate names. + * + * @pubilc + * @param {Array.} names + * @param {Array.=} attrs + * @return {Function} + */ + modelUtil.createNameEach = function (names, attrs) { + names = names.slice(); + var capitalNames = zrUtil.map(names, modelUtil.capitalFirst); + attrs = (attrs || []).slice(); + var capitalAttrs = zrUtil.map(attrs, modelUtil.capitalFirst); + + return function (callback, context) { + zrUtil.each(names, function (name, index) { + var nameObj = {name: name, capital: capitalNames[index]}; + + for (var j = 0; j < attrs.length; j++) { + nameObj[attrs[j]] = name + capitalAttrs[j]; + } + + callback.call(context, nameObj); + }); + }; + }; + + /** + * @public + */ + modelUtil.capitalFirst = function (str) { + return str ? str.charAt(0).toUpperCase() + str.substr(1) : str; + }; + + /** + * Iterate each dimension name. + * + * @public + * @param {Function} callback The parameter is like: + * { + * name: 'angle', + * capital: 'Angle', + * axis: 'angleAxis', + * axisIndex: 'angleAixs', + * index: 'angleIndex' + * } + * @param {Object} context + */ + modelUtil.eachAxisDim = modelUtil.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index']); + + /** + * If value is not array, then translate it to array. + * @param {*} value + * @return {Array} [value] or value + */ + modelUtil.normalizeToArray = function (value) { + return zrUtil.isArray(value) + ? value + : value == null + ? [] + : [value]; + }; + + /** + * If tow dataZoomModels has the same axis controlled, we say that they are 'linked'. + * dataZoomModels and 'links' make up one or more graphics. + * This function finds the graphic where the source dataZoomModel is in. + * + * @public + * @param {Function} forEachNode Node iterator. + * @param {Function} forEachEdgeType edgeType iterator + * @param {Function} edgeIdGetter Giving node and edgeType, return an array of edge id. + * @return {Function} Input: sourceNode, Output: Like {nodes: [], dims: {}} + */ + modelUtil.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) { + + return function (sourceNode) { + var result = { + nodes: [], + records: {} // key: edgeType.name, value: Object (key: edge id, value: boolean). + }; + + forEachEdgeType(function (edgeType) { + result.records[edgeType.name] = {}; + }); + + if (!sourceNode) { + return result; + } + + absorb(sourceNode, result); + + var existsLink; + do { + existsLink = false; + forEachNode(processSingleNode); + } + while (existsLink); + + function processSingleNode(node) { + if (!isNodeAbsorded(node, result) && isLinked(node, result)) { + absorb(node, result); + existsLink = true; + } + } + + return result; + }; + + function isNodeAbsorded(node, result) { + return zrUtil.indexOf(result.nodes, node) >= 0; + } + + function isLinked(node, result) { + var hasLink = false; + forEachEdgeType(function (edgeType) { + zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) { + result.records[edgeType.name][edgeId] && (hasLink = true); + }); + }); + return hasLink; + } + + function absorb(node, result) { + result.nodes.push(node); + forEachEdgeType(function (edgeType) { + zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) { + result.records[edgeType.name][edgeId] = true; + }); + }); + } + }; + + /** + * Sync default option between normal and emphasis like `position` and `show` + * In case some one will write code like + * label: { + * normal: { + * show: false, + * position: 'outside', + * textStyle: { + * fontSize: 18 + * } + * }, + * emphasis: { + * show: true + * } + * } + * @param {Object} opt + * @param {Array.} subOpts + */ + modelUtil.defaultEmphasis = function (opt, subOpts) { + if (opt) { + var emphasisOpt = opt.emphasis = opt.emphasis || {}; + var normalOpt = opt.normal = opt.normal || {}; + + // Default emphasis option from normal + zrUtil.each(subOpts, function (subOptName) { + var val = zrUtil.retrieve(emphasisOpt[subOptName], normalOpt[subOptName]); + if (val != null) { + emphasisOpt[subOptName] = val; + } + }); + } + }; + + /** + * Create a model proxy to be used in tooltip for edge data, markLine data, markPoint data. + * @param {Object} opt + * @param {string} [opt.seriesIndex] + * @param {Object} [opt.name] + * @param {module:echarts/data/List} data + * @param {Array.} rawData + */ + modelUtil.createDataFormatModel = function (opt, data, rawData) { + var model = new Model(); + zrUtil.mixin(model, modelUtil.dataFormatMixin); + model.seriesIndex = opt.seriesIndex; + model.name = opt.name || ''; + + model.getData = function () { + return data; + }; + model.getRawDataArray = function () { + return rawData; + }; + return model; + }; + + /** + * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}] + * This helper method retieves value from data. + * @param {string|number|Date|Array|Object} dataItem + * @return {number|string|Date|Array.} + */ + modelUtil.getDataItemValue = function (dataItem) { + // Performance sensitive. + return dataItem && (dataItem.value == null ? dataItem : dataItem.value); + }; + + /** + * This helper method convert value in data. + * @param {string|number|Date} value + * @param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'. + */ + modelUtil.converDataValue = function (value, dimInfo) { + // Performance sensitive. + var dimType = dimInfo && dimInfo.type; + if (dimType === 'ordinal') { + return value; + } + + if (dimType === 'time' && !isFinite(value) && value != null && value !== '-') { + value = +nubmerUtil.parseDate(value); + } + + // dimType defaults 'number'. + // If dimType is not ordinal and value is null or undefined or NaN or '-', + // parse to NaN. + return (value == null || value === '') + ? NaN : +value; // If string (like '-'), using '+' parse to NaN + }; + + modelUtil.dataFormatMixin = { + /** + * Get params for formatter + * @param {number} dataIndex + * @return {Object} + */ + getDataParams: function (dataIndex) { + var data = this.getData(); + + var seriesIndex = this.seriesIndex; + var seriesName = this.name; + + var rawValue = this.getRawValue(dataIndex); + var rawDataIndex = data.getRawIndex(dataIndex); + var name = data.getName(dataIndex, true); + + // Data may not exists in the option given by user + var rawDataArray = this.getRawDataArray(); + var itemOpt = rawDataArray && rawDataArray[rawDataIndex]; + + return { + seriesIndex: seriesIndex, + seriesName: seriesName, + name: name, + dataIndex: rawDataIndex, + data: itemOpt, + value: rawValue, + + // Param name list for mapping `a`, `b`, `c`, `d`, `e` + $vars: ['seriesName', 'name', 'value'] + }; + }, + + /** + * Format label + * @param {number} dataIndex + * @param {string} [status='normal'] 'normal' or 'emphasis' + * @param {Function|string} [formatter] Default use the `itemStyle[status].label.formatter` + * @return {string} + */ + getFormattedLabel: function (dataIndex, status, formatter) { + status = status || 'normal'; + var data = this.getData(); + var itemModel = data.getItemModel(dataIndex); + + var params = this.getDataParams(dataIndex); + if (formatter == null) { + formatter = itemModel.get(['label', status, 'formatter']); + } + + if (typeof formatter === 'function') { + params.status = status; + return formatter(params); + } + else if (typeof formatter === 'string') { + return formatUtil.formatTpl(formatter, params); + } + }, + + /** + * Get raw value in option + * @param {number} idx + * @return {Object} + */ + getRawValue: function (idx) { + var itemModel = this.getData().getItemModel(idx); + if (itemModel && itemModel.option != null) { + var dataItem = itemModel.option; + return (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem)) + ? dataItem.value : dataItem; + } + } + }; + + /** + * Mapping to exists for merge. + * + * @public + * @param {Array.|Array.} exists + * @param {Object|Array.} newCptOptions + * @return {Array.} Result, like [{exist: ..., option: ...}, {}], + * which order is the same as exists. + */ + modelUtil.mappingToExists = function (exists, newCptOptions) { + // Mapping by the order by original option (but not order of + // new option) in merge mode. Because we should ensure + // some specified index (like xAxisIndex) is consistent with + // original option, which is easy to understand, espatially in + // media query. And in most case, merge option is used to + // update partial option but not be expected to change order. + newCptOptions = (newCptOptions || []).slice(); + + var result = zrUtil.map(exists || [], function (obj, index) { + return {exist: obj}; + }); + + // Mapping by id or name if specified. + zrUtil.each(newCptOptions, function (cptOption, index) { + if (!zrUtil.isObject(cptOption)) { + return; + } + + for (var i = 0; i < result.length; i++) { + var exist = result[i].exist; + if (!result[i].option // Consider name: two map to one. + && ( + // id has highest priority. + (cptOption.id != null && exist.id === cptOption.id + '') + || (cptOption.name != null + && !modelUtil.isIdInner(cptOption) + && !modelUtil.isIdInner(exist) + && exist.name === cptOption.name + '' + ) + ) + ) { + result[i].option = cptOption; + newCptOptions[index] = null; + break; + } + } + }); + + // Otherwise mapping by index. + zrUtil.each(newCptOptions, function (cptOption, index) { + if (!zrUtil.isObject(cptOption)) { + return; + } + + var i = 0; + for (; i < result.length; i++) { + var exist = result[i].exist; + if (!result[i].option + && !modelUtil.isIdInner(exist) + // Caution: + // Do not overwrite id. But name can be overwritten, + // because axis use name as 'show label text'. + // 'exist' always has id and name and we dont + // need to check it. + && cptOption.id == null + ) { + result[i].option = cptOption; + break; + } + } + + if (i >= result.length) { + result.push({option: cptOption}); + } + }); + + return result; + }; + + /** + * @public + * @param {Object} cptOption + * @return {boolean} + */ + modelUtil.isIdInner = function (cptOption) { + return zrUtil.isObject(cptOption) + && cptOption.id + && (cptOption.id + '').indexOf('\0_ec_\0') === 0; + }; + + module.exports = modelUtil; + + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + + /** + * 每三位默认加,格式化 + * @type {string|number} x + */ + function addCommas(x) { + if (isNaN(x)) { + return '-'; + } + x = (x + '').split('.'); + return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,'$1,') + + (x.length > 1 ? ('.' + x[1]) : ''); + } + + /** + * @param {string} str + * @return {string} str + */ + function toCamelCase(str) { + return str.toLowerCase().replace(/-(.)/g, function(match, group1) { + return group1.toUpperCase(); + }); + } + + /** + * Normalize css liked array configuration + * e.g. + * 3 => [3, 3, 3, 3] + * [4, 2] => [4, 2, 4, 2] + * [4, 3, 2] => [4, 3, 2, 3] + * @param {number|Array.} val + */ + function normalizeCssArray(val) { + var len = val.length; + if (typeof (val) === 'number') { + return [val, val, val, val]; + } + else if (len === 2) { + // vertical | horizontal + return [val[0], val[1], val[0], val[1]]; + } + else if (len === 3) { + // top | horizontal | bottom + return [val[0], val[1], val[2], val[1]]; + } + return val; + } + + function encodeHTML(source) { + return String(source) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + } + + var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g']; + + function wrapVar(varName, seriesIdx) { + return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}'; + } + /** + * Template formatter + * @param {string} tpl + * @param {Array.|Object} paramsList + * @return {string} + */ + function formatTpl(tpl, paramsList) { + if (!zrUtil.isArray(paramsList)) { + paramsList = [paramsList]; + } + var seriesLen = paramsList.length; + if (!seriesLen) { + return ''; + } + + var $vars = paramsList[0].$vars; + for (var i = 0; i < $vars.length; i++) { + var alias = TPL_VAR_ALIAS[i]; + tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0)); + } + for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) { + for (var k = 0; k < $vars.length; k++) { + tpl = tpl.replace( + wrapVar(TPL_VAR_ALIAS[k], seriesIdx), + paramsList[seriesIdx][$vars[k]] + ); + } + } + + return tpl; + } + + /** + * ISO Date format + * @param {string} tpl + * @param {number} value + * @inner + */ + function formatTime(tpl, value) { + if (tpl === 'week' + || tpl === 'month' + || tpl === 'quarter' + || tpl === 'half-year' + || tpl === 'year' + ) { + tpl = 'MM-dd\nyyyy'; + } + + var date = numberUtil.parseDate(value); + var y = date.getFullYear(); + var M = date.getMonth() + 1; + var d = date.getDate(); + var h = date.getHours(); + var m = date.getMinutes(); + var s = date.getSeconds(); + + tpl = tpl.replace('MM', s2d(M)) + .toLowerCase() + .replace('yyyy', y) + .replace('yy', y % 100) + .replace('dd', s2d(d)) + .replace('d', d) + .replace('hh', s2d(h)) + .replace('h', h) + .replace('mm', s2d(m)) + .replace('m', m) + .replace('ss', s2d(s)) + .replace('s', s); + + return tpl; + } + + /** + * @param {string} str + * @return {string} + * @inner + */ + function s2d(str) { + return str < 10 ? ('0' + str) : str; + } + + module.exports = { + + normalizeCssArray: normalizeCssArray, + + addCommas: addCommas, + + toCamelCase: toCamelCase, + + encodeHTML: encodeHTML, + + formatTpl: formatTpl, + + formatTime: formatTime + }; + + +/***/ }, +/* 7 */ +/***/ function(module, exports) { + + /** + * 数值处理模块 + * @module echarts/util/number + */ + + + + var number = {}; + + var RADIAN_EPSILON = 1e-4; + + function _trim(str) { + return str.replace(/^\s+/, '').replace(/\s+$/, ''); + } + + /** + * Linear mapping a value from domain to range + * @memberOf module:echarts/util/number + * @param {(number|Array.)} val + * @param {Array.} domain Domain extent domain[0] can be bigger than domain[1] + * @param {Array.} range Range extent range[0] can be bigger than range[1] + * @param {boolean} clamp + * @return {(number|Array.} + */ + number.linearMap = function (val, domain, range, clamp) { + + var sub = domain[1] - domain[0]; + + if (sub === 0) { + return (range[0] + range[1]) / 2; + } + var t = (val - domain[0]) / sub; + + if (clamp) { + t = Math.min(Math.max(t, 0), 1); + } + + return t * (range[1] - range[0]) + range[0]; + }; + + /** + * Convert a percent string to absolute number. + * Returns NaN if percent is not a valid string or number + * @memberOf module:echarts/util/number + * @param {string|number} percent + * @param {number} all + * @return {number} + */ + number.parsePercent = function(percent, all) { + switch (percent) { + case 'center': + case 'middle': + percent = '50%'; + break; + case 'left': + case 'top': + percent = '0%'; + break; + case 'right': + case 'bottom': + percent = '100%'; + break; + } + if (typeof percent === 'string') { + if (_trim(percent).match(/%$/)) { + return parseFloat(percent) / 100 * all; + } + + return parseFloat(percent); + } + + return percent == null ? NaN : +percent; + }; + + /** + * Fix rounding error of float numbers + * @param {number} x + * @return {number} + */ + number.round = function (x) { + // PENDING + return +(+x).toFixed(12); + }; + + number.asc = function (arr) { + arr.sort(function (a, b) { + return a - b; + }); + return arr; + }; + + /** + * Get precision + * @param {number} val + */ + number.getPrecision = function (val) { + if (isNaN(val)) { + return 0; + } + // It is much faster than methods converting number to string as follows + // var tmp = val.toString(); + // return tmp.length - 1 - tmp.indexOf('.'); + // especially when precision is low + var e = 1; + var count = 0; + while (Math.round(val * e) / e !== val) { + e *= 10; + count++; + } + return count; + }; + + /** + * @param {Array.} dataExtent + * @param {Array.} pixelExtent + * @return {number} precision + */ + number.getPixelPrecision = function (dataExtent, pixelExtent) { + var log = Math.log; + var LN10 = Math.LN10; + var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10); + var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10); + return Math.max( + -dataQuantity + sizeQuantity, + 0 + ); + }; + + // Number.MAX_SAFE_INTEGER, ie do not support. + number.MAX_SAFE_INTEGER = 9007199254740991; + + /** + * To 0 - 2 * PI, considering negative radian. + * @param {number} radian + * @return {number} + */ + number.remRadian = function (radian) { + var pi2 = Math.PI * 2; + return (radian % pi2 + pi2) % pi2; + }; + + /** + * @param {type} radian + * @return {boolean} + */ + number.isRadianAroundZero = function (val) { + return val > -RADIAN_EPSILON && val < RADIAN_EPSILON; + }; + + /** + * @param {string|Date|number} value + * @return {number} timestamp + */ + number.parseDate = function (value) { + return value instanceof Date + ? value + : new Date( + typeof value === 'string' + ? value.replace(/-/g, '/') + : Math.round(value) + ); + }; + + // "Nice Numbers for Graph Labels" of Graphic Gems + /** + * find a “nice” number approximately equal to x. Round the number if round = true, take ceiling if round = false + * The primary observation is that the “nicest” numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers. + * @param {number} val + * @param {boolean} round + * @return {number} + */ + number.nice = function (val, round) { + var exp = Math.floor(Math.log(val) / Math.LN10); + var exp10 = Math.pow(10, exp); + var f = val / exp10; // between 1 and 10 + var nf; + if (round) { + if (f < 1.5) { nf = 1; } + else if (f < 2.5) { nf = 2; } + else if (f < 4) { nf = 3; } + else if (f < 7) { nf = 5; } + else { nf = 10; } + } + else { + if (f < 1) { nf = 1; } + else if (f < 2) { nf = 2; } + else if (f < 3) { nf = 3; } + else if (f < 5) { nf = 5; } + else { nf = 10; } + } + return nf * exp10; + }; + + module.exports = number; + + +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/model/Model + */ + + + var zrUtil = __webpack_require__(3); + var clazzUtil = __webpack_require__(9); + + /** + * @alias module:echarts/model/Model + * @constructor + * @param {Object} option + * @param {module:echarts/model/Model} parentModel + * @param {module:echarts/model/Global} ecModel + * @param {Object} extraOpt + */ + function Model(option, parentModel, ecModel, extraOpt) { + /** + * @type {module:echarts/model/Model} + * @readOnly + */ + this.parentModel = parentModel; + + /** + * @type {module:echarts/model/Global} + * @readOnly + */ + this.ecModel = ecModel; + + /** + * @type {Object} + * @protected + */ + this.option = option; + + // Simple optimization + if (this.init) { + if (arguments.length <= 4) { + this.init(option, parentModel, ecModel, extraOpt); + } + else { + this.init.apply(this, arguments); + } + } + } + + Model.prototype = { + + constructor: Model, + + /** + * Model 的初始化函数 + * @param {Object} option + */ + init: null, + + /** + * 从新的 Option merge + */ + mergeOption: function (option) { + zrUtil.merge(this.option, option, true); + }, + + /** + * @param {string} path + * @param {boolean} [ignoreParent=false] + * @return {*} + */ + get: function (path, ignoreParent) { + if (!path) { + return this.option; + } + + if (typeof path === 'string') { + path = path.split('.'); + } + + var obj = this.option; + var parentModel = this.parentModel; + for (var i = 0; i < path.length; i++) { + // obj could be number/string/... (like 0) + obj = (obj && typeof obj === 'object') ? obj[path[i]] : null; + if (obj == null) { + break; + } + } + if (obj == null && parentModel && !ignoreParent) { + obj = parentModel.get(path); + } + return obj; + }, + + /** + * @param {string} key + * @param {boolean} [ignoreParent=false] + * @return {*} + */ + getShallow: function (key, ignoreParent) { + var option = this.option; + var val = option && option[key]; + var parentModel = this.parentModel; + if (val == null && parentModel && !ignoreParent) { + val = parentModel.getShallow(key); + } + return val; + }, + + /** + * @param {string} path + * @param {module:echarts/model/Model} [parentModel] + * @return {module:echarts/model/Model} + */ + getModel: function (path, parentModel) { + var obj = this.get(path, true); + var thisParentModel = this.parentModel; + var model = new Model( + obj, parentModel || (thisParentModel && thisParentModel.getModel(path)), + this.ecModel + ); + return model; + }, + + /** + * If model has option + */ + isEmpty: function () { + return this.option == null; + }, + + restoreData: function () {}, + + // Pending + clone: function () { + var Ctor = this.constructor; + return new Ctor(zrUtil.clone(this.option)); + }, + + setReadOnly: function (properties) { + clazzUtil.setReadOnly(this, properties); + } + }; + + // Enable Model.extend. + clazzUtil.enableClassExtend(Model); + + var mixin = zrUtil.mixin; + mixin(Model, __webpack_require__(10)); + mixin(Model, __webpack_require__(12)); + mixin(Model, __webpack_require__(13)); + mixin(Model, __webpack_require__(18)); + + module.exports = Model; + + +/***/ }, +/* 9 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + var clazz = {}; + + var TYPE_DELIMITER = '.'; + var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___'; + /** + * @public + */ + var parseClassType = clazz.parseClassType = function (componentType) { + var ret = {main: '', sub: ''}; + if (componentType) { + componentType = componentType.split(TYPE_DELIMITER); + ret.main = componentType[0] || ''; + ret.sub = componentType[1] || ''; + } + return ret; + }; + /** + * @public + */ + clazz.enableClassExtend = function (RootClass, preConstruct) { + RootClass.extend = function (proto) { + var ExtendedClass = function () { + preConstruct && preConstruct.apply(this, arguments); + RootClass.apply(this, arguments); + }; + + zrUtil.extend(ExtendedClass.prototype, proto); + + ExtendedClass.extend = this.extend; + ExtendedClass.superCall = superCall; + ExtendedClass.superApply = superApply; + zrUtil.inherits(ExtendedClass, this); + ExtendedClass.superClass = this; + + return ExtendedClass; + }; + }; + + // superCall should have class info, which can not be fetch from 'this'. + // Consider this case: + // class A has method f, + // class B inherits class A, overrides method f, f call superApply('f'), + // class C inherits class B, do not overrides method f, + // then when method of class C is called, dead loop occured. + function superCall(context, methodName) { + var args = zrUtil.slice(arguments, 2); + return this.superClass.prototype[methodName].apply(context, args); + } + + function superApply(context, methodName, args) { + return this.superClass.prototype[methodName].apply(context, args); + } + + /** + * @param {Object} entity + * @param {Object} options + * @param {boolean} [options.registerWhenExtend] + * @public + */ + clazz.enableClassManagement = function (entity, options) { + options = options || {}; + + /** + * Component model classes + * key: componentType, + * value: + * componentClass, when componentType is 'xxx' + * or Object., when componentType is 'xxx.yy' + * @type {Object} + */ + var storage = {}; + + entity.registerClass = function (Clazz, componentType) { + if (componentType) { + componentType = parseClassType(componentType); + + if (!componentType.sub) { + if (storage[componentType.main]) { + throw new Error(componentType.main + 'exists'); + } + storage[componentType.main] = Clazz; + } + else if (componentType.sub !== IS_CONTAINER) { + var container = makeContainer(componentType); + container[componentType.sub] = Clazz; + } + } + return Clazz; + }; + + entity.getClass = function (componentTypeMain, subType, throwWhenNotFound) { + var Clazz = storage[componentTypeMain]; + + if (Clazz && Clazz[IS_CONTAINER]) { + Clazz = subType ? Clazz[subType] : null; + } + + if (throwWhenNotFound && !Clazz) { + throw new Error( + 'Component ' + componentTypeMain + '.' + (subType || '') + ' not exists' + ); + } + + return Clazz; + }; + + entity.getClassesByMainType = function (componentType) { + componentType = parseClassType(componentType); + + var result = []; + var obj = storage[componentType.main]; + + if (obj && obj[IS_CONTAINER]) { + zrUtil.each(obj, function (o, type) { + type !== IS_CONTAINER && result.push(o); + }); + } + else { + result.push(obj); + } + + return result; + }; + + entity.hasClass = function (componentType) { + // Just consider componentType.main. + componentType = parseClassType(componentType); + return !!storage[componentType.main]; + }; + + /** + * @return {Array.} Like ['aa', 'bb'], but can not be ['aa.xx'] + */ + entity.getAllClassMainTypes = function () { + var types = []; + zrUtil.each(storage, function (obj, type) { + types.push(type); + }); + return types; + }; + + /** + * If a main type is container and has sub types + * @param {string} mainType + * @return {boolean} + */ + entity.hasSubTypes = function (componentType) { + componentType = parseClassType(componentType); + var obj = storage[componentType.main]; + return obj && obj[IS_CONTAINER]; + }; + + entity.parseClassType = parseClassType; + + function makeContainer(componentType) { + var container = storage[componentType.main]; + if (!container || !container[IS_CONTAINER]) { + container = storage[componentType.main] = {}; + container[IS_CONTAINER] = true; + } + return container; + } + + if (options.registerWhenExtend) { + var originalExtend = entity.extend; + if (originalExtend) { + entity.extend = function (proto) { + var ExtendedClass = originalExtend.call(this, proto); + return entity.registerClass(ExtendedClass, proto.type); + }; + } + } + + return entity; + }; + + /** + * @param {string|Array.} properties + */ + clazz.setReadOnly = function (obj, properties) { + // FIXME It seems broken in IE8 simulation of IE11 + // if (!zrUtil.isArray(properties)) { + // properties = properties != null ? [properties] : []; + // } + // zrUtil.each(properties, function (prop) { + // var value = obj[prop]; + + // Object.defineProperty + // && Object.defineProperty(obj, prop, { + // value: value, writable: false + // }); + // zrUtil.isArray(obj[prop]) + // && Object.freeze + // && Object.freeze(obj[prop]); + // }); + }; + + module.exports = clazz; + + +/***/ }, +/* 10 */ +/***/ function(module, exports, __webpack_require__) { + + + var getLineStyle = __webpack_require__(11)( + [ + ['lineWidth', 'width'], + ['stroke', 'color'], + ['opacity'], + ['shadowBlur'], + ['shadowOffsetX'], + ['shadowOffsetY'], + ['shadowColor'] + ] + ); + module.exports = { + getLineStyle: function (excludes) { + var style = getLineStyle.call(this, excludes); + var lineDash = this.getLineDash(); + lineDash && (style.lineDash = lineDash); + return style; + }, + + getLineDash: function () { + var lineType = this.get('type'); + return (lineType === 'solid' || lineType == null) ? null + : (lineType === 'dashed' ? [5, 5] : [1, 1]); + } + }; + + +/***/ }, +/* 11 */ +/***/ function(module, exports, __webpack_require__) { + + // TODO Parse shadow style + // TODO Only shallow path support + + var zrUtil = __webpack_require__(3); + + module.exports = function (properties) { + // Normalize + for (var i = 0; i < properties.length; i++) { + if (!properties[i][1]) { + properties[i][1] = properties[i][0]; + } + } + return function (excludes) { + var style = {}; + for (var i = 0; i < properties.length; i++) { + var propName = properties[i][1]; + if (excludes && zrUtil.indexOf(excludes, propName) >= 0) { + continue; + } + var val = this.getShallow(propName); + if (val != null) { + style[properties[i][0]] = val; + } + } + return style; + }; + }; + + +/***/ }, +/* 12 */ +/***/ function(module, exports, __webpack_require__) { + + + module.exports = { + getAreaStyle: __webpack_require__(11)( + [ + ['fill', 'color'], + ['shadowBlur'], + ['shadowOffsetX'], + ['shadowOffsetY'], + ['opacity'], + ['shadowColor'] + ] + ) + }; + + +/***/ }, +/* 13 */ +/***/ function(module, exports, __webpack_require__) { + + + + var textContain = __webpack_require__(14); + + function getShallow(model, path) { + return model && model.getShallow(path); + } + + module.exports = { + /** + * Get color property or get color from option.textStyle.color + * @return {string} + */ + getTextColor: function () { + var ecModel = this.ecModel; + return this.getShallow('color') + || (ecModel && ecModel.get('textStyle.color')); + }, + + /** + * Create font string from fontStyle, fontWeight, fontSize, fontFamily + * @return {string} + */ + getFont: function () { + var ecModel = this.ecModel; + var gTextStyleModel = ecModel && ecModel.getModel('textStyle'); + return [ + // FIXME in node-canvas fontWeight is before fontStyle + this.getShallow('fontStyle') || getShallow(gTextStyleModel, 'fontStyle'), + this.getShallow('fontWeight') || getShallow(gTextStyleModel, 'fontWeight'), + (this.getShallow('fontSize') || getShallow(gTextStyleModel, 'fontSize') || 12) + 'px', + this.getShallow('fontFamily') || getShallow(gTextStyleModel, 'fontFamily') || 'sans-serif' + ].join(' '); + }, + + getTextRect: function (text) { + var textStyle = this.get('textStyle') || {}; + return textContain.getBoundingRect( + text, + this.getFont(), + textStyle.align, + textStyle.baseline + ); + }, + + ellipsis: function (text, containerWidth, options) { + return textContain.ellipsis( + text, this.getFont(), containerWidth, options + ); + } + }; + + +/***/ }, +/* 14 */ +/***/ function(module, exports, __webpack_require__) { + + + + var textWidthCache = {}; + var textWidthCacheCounter = 0; + var TEXT_CACHE_MAX = 5000; + + var util = __webpack_require__(3); + var BoundingRect = __webpack_require__(15); + + function getTextWidth(text, textFont) { + var key = text + ':' + textFont; + if (textWidthCache[key]) { + return textWidthCache[key]; + } + + var textLines = (text + '').split('\n'); + var width = 0; + + for (var i = 0, l = textLines.length; i < l; i++) { + // measureText 可以被覆盖以兼容不支持 Canvas 的环境 + width = Math.max(textContain.measureText(textLines[i], textFont).width, width); + } + + if (textWidthCacheCounter > TEXT_CACHE_MAX) { + textWidthCacheCounter = 0; + textWidthCache = {}; + } + textWidthCacheCounter++; + textWidthCache[key] = width; + + return width; + } + + function getTextRect(text, textFont, textAlign, textBaseline) { + var textLineLen = ((text || '') + '').split('\n').length; + + var width = getTextWidth(text, textFont); + // FIXME 高度计算比较粗暴 + var lineHeight = getTextWidth('国', textFont); + var height = textLineLen * lineHeight; + + var rect = new BoundingRect(0, 0, width, height); + // Text has a special line height property + rect.lineHeight = lineHeight; + + switch (textBaseline) { + case 'bottom': + case 'alphabetic': + rect.y -= lineHeight; + break; + case 'middle': + rect.y -= lineHeight / 2; + break; + // case 'hanging': + // case 'top': + } + + // FIXME Right to left language + switch (textAlign) { + case 'end': + case 'right': + rect.x -= rect.width; + break; + case 'center': + rect.x -= rect.width / 2; + break; + // case 'start': + // case 'left': + } + + return rect; + } + + function adjustTextPositionOnRect(textPosition, rect, textRect, distance) { + + var x = rect.x; + var y = rect.y; + + var height = rect.height; + var width = rect.width; + + var textHeight = textRect.height; + + var halfHeight = height / 2 - textHeight / 2; + + var textAlign = 'left'; + + switch (textPosition) { + case 'left': + x -= distance; + y += halfHeight; + textAlign = 'right'; + break; + case 'right': + x += distance + width; + y += halfHeight; + textAlign = 'left'; + break; + case 'top': + x += width / 2; + y -= distance + textHeight; + textAlign = 'center'; + break; + case 'bottom': + x += width / 2; + y += height + distance; + textAlign = 'center'; + break; + case 'inside': + x += width / 2; + y += halfHeight; + textAlign = 'center'; + break; + case 'insideLeft': + x += distance; + y += halfHeight; + textAlign = 'left'; + break; + case 'insideRight': + x += width - distance; + y += halfHeight; + textAlign = 'right'; + break; + case 'insideTop': + x += width / 2; + y += distance; + textAlign = 'center'; + break; + case 'insideBottom': + x += width / 2; + y += height - textHeight - distance; + textAlign = 'center'; + break; + case 'insideTopLeft': + x += distance; + y += distance; + textAlign = 'left'; + break; + case 'insideTopRight': + x += width - distance; + y += distance; + textAlign = 'right'; + break; + case 'insideBottomLeft': + x += distance; + y += height - textHeight - distance; + break; + case 'insideBottomRight': + x += width - distance; + y += height - textHeight - distance; + textAlign = 'right'; + break; + } + + return { + x: x, + y: y, + textAlign: textAlign, + textBaseline: 'top' + }; + } + + /** + * Show ellipsis if overflow. + * + * @param {string} text + * @param {string} textFont + * @param {string} containerWidth + * @param {Object} [options] + * @param {number} [options.ellipsis='...'] + * @param {number} [options.maxIterations=3] + * @param {number} [options.minCharacters=3] + * @return {string} + */ + function textEllipsis(text, textFont, containerWidth, options) { + if (!containerWidth) { + return ''; + } + + options = util.defaults({ + ellipsis: '...', + minCharacters: 3, + maxIterations: 3, + cnCharWidth: getTextWidth('国', textFont), + // FIXME + // 未考虑非等宽字体 + ascCharWidth: getTextWidth('a', textFont) + }, options, true); + + containerWidth -= getTextWidth(options.ellipsis); + + var textLines = (text + '').split('\n'); + + for (var i = 0, len = textLines.length; i < len; i++) { + textLines[i] = textLineTruncate( + textLines[i], textFont, containerWidth, options + ); + } + + return textLines.join('\n'); + } + + function textLineTruncate(text, textFont, containerWidth, options) { + // FIXME + // 粗糙得写的,尚未考虑性能和各种语言、字体的效果。 + for (var i = 0;; i++) { + var lineWidth = getTextWidth(text, textFont); + + if (lineWidth < containerWidth || i >= options.maxIterations) { + text += options.ellipsis; + break; + } + + var subLength = i === 0 + ? estimateLength(text, containerWidth, options) + : Math.floor(text.length * containerWidth / lineWidth); + + if (subLength < options.minCharacters) { + text = ''; + break; + } + + text = text.substr(0, subLength); + } + + return text; + } + + function estimateLength(text, containerWidth, options) { + var width = 0; + var i = 0; + for (var len = text.length; i < len && width < containerWidth; i++) { + var charCode = text.charCodeAt(i); + width += (0 <= charCode && charCode <= 127) + ? options.ascCharWidth : options.cnCharWidth; + } + return i; + } + + var textContain = { + + getWidth: getTextWidth, + + getBoundingRect: getTextRect, + + adjustTextPositionOnRect: adjustTextPositionOnRect, + + ellipsis: textEllipsis, + + measureText: function (text, textFont) { + var ctx = util.getContext(); + ctx.font = textFont; + return ctx.measureText(text); + } + }; + + module.exports = textContain; + + +/***/ }, +/* 15 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * @module echarts/core/BoundingRect + */ + + + var vec2 = __webpack_require__(16); + var matrix = __webpack_require__(17); + + var v2ApplyTransform = vec2.applyTransform; + var mathMin = Math.min; + var mathAbs = Math.abs; + var mathMax = Math.max; + /** + * @alias module:echarts/core/BoundingRect + */ + function BoundingRect(x, y, width, height) { + /** + * @type {number} + */ + this.x = x; + /** + * @type {number} + */ + this.y = y; + /** + * @type {number} + */ + this.width = width; + /** + * @type {number} + */ + this.height = height; + } + + BoundingRect.prototype = { + + constructor: BoundingRect, + + /** + * @param {module:echarts/core/BoundingRect} other + */ + union: function (other) { + var x = mathMin(other.x, this.x); + var y = mathMin(other.y, this.y); + + this.width = mathMax( + other.x + other.width, + this.x + this.width + ) - x; + this.height = mathMax( + other.y + other.height, + this.y + this.height + ) - y; + this.x = x; + this.y = y; + }, + + /** + * @param {Array.} m + * @methods + */ + applyTransform: (function () { + var min = []; + var max = []; + return function (m) { + // In case usage like this + // el.getBoundingRect().applyTransform(el.transform) + // And element has no transform + if (!m) { + return; + } + min[0] = this.x; + min[1] = this.y; + max[0] = this.x + this.width; + max[1] = this.y + this.height; + + v2ApplyTransform(min, min, m); + v2ApplyTransform(max, max, m); + + this.x = mathMin(min[0], max[0]); + this.y = mathMin(min[1], max[1]); + this.width = mathAbs(max[0] - min[0]); + this.height = mathAbs(max[1] - min[1]); + }; + })(), + + /** + * Calculate matrix of transforming from self to target rect + * @param {module:zrender/core/BoundingRect} b + * @return {Array.} + */ + calculateTransform: function (b) { + var a = this; + var sx = b.width / a.width; + var sy = b.height / a.height; + + var m = matrix.create(); + + // 矩阵右乘 + matrix.translate(m, m, [-a.x, -a.y]); + matrix.scale(m, m, [sx, sy]); + matrix.translate(m, m, [b.x, b.y]); + + return m; + }, + + /** + * @param {(module:echarts/core/BoundingRect|Object)} b + * @return {boolean} + */ + intersect: function (b) { + var a = this; + var ax0 = a.x; + var ax1 = a.x + a.width; + var ay0 = a.y; + var ay1 = a.y + a.height; + + var bx0 = b.x; + var bx1 = b.x + b.width; + var by0 = b.y; + var by1 = b.y + b.height; + + return ! (ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0); + }, + + contain: function (x, y) { + var rect = this; + return x >= rect.x + && x <= (rect.x + rect.width) + && y >= rect.y + && y <= (rect.y + rect.height); + }, + + /** + * @return {module:echarts/core/BoundingRect} + */ + clone: function () { + return new BoundingRect(this.x, this.y, this.width, this.height); + }, + + /** + * Copy from another rect + */ + copy: function (other) { + this.x = other.x; + this.y = other.y; + this.width = other.width; + this.height = other.height; + } + }; + + module.exports = BoundingRect; + + +/***/ }, +/* 16 */ +/***/ function(module, exports) { + + + var ArrayCtor = typeof Float32Array === 'undefined' + ? Array + : Float32Array; + + /** + * @typedef {Float32Array|Array.} Vector2 + */ + /** + * 二维向量类 + * @exports zrender/tool/vector + */ + var vector = { + /** + * 创建一个向量 + * @param {number} [x=0] + * @param {number} [y=0] + * @return {Vector2} + */ + create: function (x, y) { + var out = new ArrayCtor(2); + out[0] = x || 0; + out[1] = y || 0; + return out; + }, + + /** + * 复制向量数据 + * @param {Vector2} out + * @param {Vector2} v + * @return {Vector2} + */ + copy: function (out, v) { + out[0] = v[0]; + out[1] = v[1]; + return out; + }, + + /** + * 克隆一个向量 + * @param {Vector2} v + * @return {Vector2} + */ + clone: function (v) { + var out = new ArrayCtor(2); + out[0] = v[0]; + out[1] = v[1]; + return out; + }, + + /** + * 设置向量的两个项 + * @param {Vector2} out + * @param {number} a + * @param {number} b + * @return {Vector2} 结果 + */ + set: function (out, a, b) { + out[0] = a; + out[1] = b; + return out; + }, + + /** + * 向量相加 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + add: function (out, v1, v2) { + out[0] = v1[0] + v2[0]; + out[1] = v1[1] + v2[1]; + return out; + }, + + /** + * 向量缩放后相加 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + * @param {number} a + */ + scaleAndAdd: function (out, v1, v2, a) { + out[0] = v1[0] + v2[0] * a; + out[1] = v1[1] + v2[1] * a; + return out; + }, + + /** + * 向量相减 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + sub: function (out, v1, v2) { + out[0] = v1[0] - v2[0]; + out[1] = v1[1] - v2[1]; + return out; + }, + + /** + * 向量长度 + * @param {Vector2} v + * @return {number} + */ + len: function (v) { + return Math.sqrt(this.lenSquare(v)); + }, + + /** + * 向量长度平方 + * @param {Vector2} v + * @return {number} + */ + lenSquare: function (v) { + return v[0] * v[0] + v[1] * v[1]; + }, + + /** + * 向量乘法 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + mul: function (out, v1, v2) { + out[0] = v1[0] * v2[0]; + out[1] = v1[1] * v2[1]; + return out; + }, + + /** + * 向量除法 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + div: function (out, v1, v2) { + out[0] = v1[0] / v2[0]; + out[1] = v1[1] / v2[1]; + return out; + }, + + /** + * 向量点乘 + * @param {Vector2} v1 + * @param {Vector2} v2 + * @return {number} + */ + dot: function (v1, v2) { + return v1[0] * v2[0] + v1[1] * v2[1]; + }, + + /** + * 向量缩放 + * @param {Vector2} out + * @param {Vector2} v + * @param {number} s + */ + scale: function (out, v, s) { + out[0] = v[0] * s; + out[1] = v[1] * s; + return out; + }, + + /** + * 向量归一化 + * @param {Vector2} out + * @param {Vector2} v + */ + normalize: function (out, v) { + var d = vector.len(v); + if (d === 0) { + out[0] = 0; + out[1] = 0; + } + else { + out[0] = v[0] / d; + out[1] = v[1] / d; + } + return out; + }, + + /** + * 计算向量间距离 + * @param {Vector2} v1 + * @param {Vector2} v2 + * @return {number} + */ + distance: function (v1, v2) { + return Math.sqrt( + (v1[0] - v2[0]) * (v1[0] - v2[0]) + + (v1[1] - v2[1]) * (v1[1] - v2[1]) + ); + }, + + /** + * 向量距离平方 + * @param {Vector2} v1 + * @param {Vector2} v2 + * @return {number} + */ + distanceSquare: function (v1, v2) { + return (v1[0] - v2[0]) * (v1[0] - v2[0]) + + (v1[1] - v2[1]) * (v1[1] - v2[1]); + }, + + /** + * 求负向量 + * @param {Vector2} out + * @param {Vector2} v + */ + negate: function (out, v) { + out[0] = -v[0]; + out[1] = -v[1]; + return out; + }, + + /** + * 插值两个点 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + * @param {number} t + */ + lerp: function (out, v1, v2, t) { + out[0] = v1[0] + t * (v2[0] - v1[0]); + out[1] = v1[1] + t * (v2[1] - v1[1]); + return out; + }, + + /** + * 矩阵左乘向量 + * @param {Vector2} out + * @param {Vector2} v + * @param {Vector2} m + */ + applyTransform: function (out, v, m) { + var x = v[0]; + var y = v[1]; + out[0] = m[0] * x + m[2] * y + m[4]; + out[1] = m[1] * x + m[3] * y + m[5]; + return out; + }, + /** + * 求两个向量最小值 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + min: function (out, v1, v2) { + out[0] = Math.min(v1[0], v2[0]); + out[1] = Math.min(v1[1], v2[1]); + return out; + }, + /** + * 求两个向量最大值 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + max: function (out, v1, v2) { + out[0] = Math.max(v1[0], v2[0]); + out[1] = Math.max(v1[1], v2[1]); + return out; + } + }; + + vector.length = vector.len; + vector.lengthSquare = vector.lenSquare; + vector.dist = vector.distance; + vector.distSquare = vector.distanceSquare; + + module.exports = vector; + + + +/***/ }, +/* 17 */ +/***/ function(module, exports) { + + + var ArrayCtor = typeof Float32Array === 'undefined' + ? Array + : Float32Array; + /** + * 3x2矩阵操作类 + * @exports zrender/tool/matrix + */ + var matrix = { + /** + * 创建一个单位矩阵 + * @return {Float32Array|Array.} + */ + create : function() { + var out = new ArrayCtor(6); + matrix.identity(out); + + return out; + }, + /** + * 设置矩阵为单位矩阵 + * @param {Float32Array|Array.} out + */ + identity : function(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = 0; + out[5] = 0; + return out; + }, + /** + * 复制矩阵 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} m + */ + copy: function(out, m) { + out[0] = m[0]; + out[1] = m[1]; + out[2] = m[2]; + out[3] = m[3]; + out[4] = m[4]; + out[5] = m[5]; + return out; + }, + /** + * 矩阵相乘 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} m1 + * @param {Float32Array|Array.} m2 + */ + mul : function (out, m1, m2) { + // Consider matrix.mul(m, m2, m); + // where out is the same as m2. + // So use temp variable to escape error. + var out0 = m1[0] * m2[0] + m1[2] * m2[1]; + var out1 = m1[1] * m2[0] + m1[3] * m2[1]; + var out2 = m1[0] * m2[2] + m1[2] * m2[3]; + var out3 = m1[1] * m2[2] + m1[3] * m2[3]; + var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4]; + var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5]; + out[0] = out0; + out[1] = out1; + out[2] = out2; + out[3] = out3; + out[4] = out4; + out[5] = out5; + return out; + }, + /** + * 平移变换 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + * @param {Float32Array|Array.} v + */ + translate : function(out, a, v) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4] + v[0]; + out[5] = a[5] + v[1]; + return out; + }, + /** + * 旋转变换 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + * @param {number} rad + */ + rotate : function(out, a, rad) { + var aa = a[0]; + var ac = a[2]; + var atx = a[4]; + var ab = a[1]; + var ad = a[3]; + var aty = a[5]; + var st = Math.sin(rad); + var ct = Math.cos(rad); + + out[0] = aa * ct + ab * st; + out[1] = -aa * st + ab * ct; + out[2] = ac * ct + ad * st; + out[3] = -ac * st + ct * ad; + out[4] = ct * atx + st * aty; + out[5] = ct * aty - st * atx; + return out; + }, + /** + * 缩放变换 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + * @param {Float32Array|Array.} v + */ + scale : function(out, a, v) { + var vx = v[0]; + var vy = v[1]; + out[0] = a[0] * vx; + out[1] = a[1] * vy; + out[2] = a[2] * vx; + out[3] = a[3] * vy; + out[4] = a[4] * vx; + out[5] = a[5] * vy; + return out; + }, + /** + * 求逆矩阵 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + */ + invert : function(out, a) { + + var aa = a[0]; + var ac = a[2]; + var atx = a[4]; + var ab = a[1]; + var ad = a[3]; + var aty = a[5]; + + var det = aa * ad - ab * ac; + if (!det) { + return null; + } + det = 1.0 / det; + + out[0] = ad * det; + out[1] = -ab * det; + out[2] = -ac * det; + out[3] = aa * det; + out[4] = (ac * aty - ad * atx) * det; + out[5] = (ab * atx - aa * aty) * det; + return out; + } + }; + + module.exports = matrix; + + + +/***/ }, +/* 18 */ +/***/ function(module, exports, __webpack_require__) { + + + module.exports = { + getItemStyle: __webpack_require__(11)( + [ + ['fill', 'color'], + ['stroke', 'borderColor'], + ['lineWidth', 'borderWidth'], + ['opacity'], + ['shadowBlur'], + ['shadowOffsetX'], + ['shadowOffsetY'], + ['shadowColor'] + ] + ) + }; + + +/***/ }, +/* 19 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Component model + * + * @module echarts/model/Component + */ + + + var Model = __webpack_require__(8); + var zrUtil = __webpack_require__(3); + var arrayPush = Array.prototype.push; + var componentUtil = __webpack_require__(20); + var clazzUtil = __webpack_require__(9); + var layout = __webpack_require__(21); + + /** + * @alias module:echarts/model/Component + * @constructor + * @param {Object} option + * @param {module:echarts/model/Model} parentModel + * @param {module:echarts/model/Model} ecModel + */ + var ComponentModel = Model.extend({ + + type: 'component', + + /** + * @readOnly + * @type {string} + */ + id: '', + + /** + * @readOnly + */ + name: '', + + /** + * @readOnly + * @type {string} + */ + mainType: '', + + /** + * @readOnly + * @type {string} + */ + subType: '', + + /** + * @readOnly + * @type {number} + */ + componentIndex: 0, + + /** + * @type {Object} + * @protected + */ + defaultOption: null, + + /** + * @type {module:echarts/model/Global} + * @readOnly + */ + ecModel: null, + + /** + * key: componentType + * value: Component model list, can not be null. + * @type {Object.>} + * @readOnly + */ + dependentModels: [], + + /** + * @type {string} + * @readOnly + */ + uid: null, + + /** + * Support merge layout params. + * Only support 'box' now (left/right/top/bottom/width/height). + * @type {string|Object} Object can be {ignoreSize: true} + * @readOnly + */ + layoutMode: null, + + + init: function (option, parentModel, ecModel, extraOpt) { + this.mergeDefaultAndTheme(this.option, this.ecModel); + }, + + mergeDefaultAndTheme: function (option, ecModel) { + var layoutMode = this.layoutMode; + var inputPositionParams = layoutMode + ? layout.getLayoutParams(option) : {}; + + var themeModel = ecModel.getTheme(); + zrUtil.merge(option, themeModel.get(this.mainType)); + zrUtil.merge(option, this.getDefaultOption()); + + if (layoutMode) { + layout.mergeLayoutParam(option, inputPositionParams, layoutMode); + } + }, + + mergeOption: function (option) { + zrUtil.merge(this.option, option, true); + + var layoutMode = this.layoutMode; + if (layoutMode) { + layout.mergeLayoutParam(this.option, option, layoutMode); + } + }, + + // Hooker after init or mergeOption + optionUpdated: function (ecModel) {}, + + getDefaultOption: function () { + if (!this.hasOwnProperty('__defaultOption')) { + var optList = []; + var Class = this.constructor; + while (Class) { + var opt = Class.prototype.defaultOption; + opt && optList.push(opt); + Class = Class.superClass; + } + + var defaultOption = {}; + for (var i = optList.length - 1; i >= 0; i--) { + defaultOption = zrUtil.merge(defaultOption, optList[i], true); + } + this.__defaultOption = defaultOption; + } + return this.__defaultOption; + } + + }); + + // Reset ComponentModel.extend, add preConstruct. + clazzUtil.enableClassExtend( + ComponentModel, + function (option, parentModel, ecModel, extraOpt) { + // Set dependentModels, componentIndex, name, id, mainType, subType. + zrUtil.extend(this, extraOpt); + + this.uid = componentUtil.getUID('componentModel'); + + this.setReadOnly([ + 'type', 'id', 'uid', 'name', 'mainType', 'subType', + 'dependentModels', 'componentIndex' + ]); + } + ); + + // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. + clazzUtil.enableClassManagement( + ComponentModel, {registerWhenExtend: true} + ); + componentUtil.enableSubTypeDefaulter(ComponentModel); + + // Add capability of ComponentModel.topologicalTravel. + componentUtil.enableTopologicalTravel(ComponentModel, getDependencies); + + function getDependencies(componentType) { + var deps = []; + zrUtil.each(ComponentModel.getClassesByMainType(componentType), function (Clazz) { + arrayPush.apply(deps, Clazz.prototype.dependencies || []); + }); + // Ensure main type + return zrUtil.map(deps, function (type) { + return clazzUtil.parseClassType(type).main; + }); + } + + zrUtil.mixin(ComponentModel, __webpack_require__(22)); + + module.exports = ComponentModel; + + +/***/ }, +/* 20 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var clazz = __webpack_require__(9); + + var parseClassType = clazz.parseClassType; + + var base = 0; + + var componentUtil = {}; + + var DELIMITER = '_'; + + /** + * @public + * @param {string} type + * @return {string} + */ + componentUtil.getUID = function (type) { + // Considering the case of crossing js context, + // use Math.random to make id as unique as possible. + return [(type || ''), base++, Math.random()].join(DELIMITER); + }; + + /** + * @inner + */ + componentUtil.enableSubTypeDefaulter = function (entity) { + + var subTypeDefaulters = {}; + + entity.registerSubTypeDefaulter = function (componentType, defaulter) { + componentType = parseClassType(componentType); + subTypeDefaulters[componentType.main] = defaulter; + }; + + entity.determineSubType = function (componentType, option) { + var type = option.type; + if (!type) { + var componentTypeMain = parseClassType(componentType).main; + if (entity.hasSubTypes(componentType) && subTypeDefaulters[componentTypeMain]) { + type = subTypeDefaulters[componentTypeMain](option); + } + } + return type; + }; + + return entity; + }; + + /** + * Topological travel on Activity Network (Activity On Vertices). + * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis']. + * + * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology. + * + * If there is circle dependencey, Error will be thrown. + * + */ + componentUtil.enableTopologicalTravel = function (entity, dependencyGetter) { + + /** + * @public + * @param {Array.} targetNameList Target Component type list. + * Can be ['aa', 'bb', 'aa.xx'] + * @param {Array.} fullNameList By which we can build dependency graph. + * @param {Function} callback Params: componentType, dependencies. + * @param {Object} context Scope of callback. + */ + entity.topologicalTravel = function (targetNameList, fullNameList, callback, context) { + if (!targetNameList.length) { + return; + } + + var result = makeDepndencyGraph(fullNameList); + var graph = result.graph; + var stack = result.noEntryList; + + var targetNameSet = {}; + zrUtil.each(targetNameList, function (name) { + targetNameSet[name] = true; + }); + + while (stack.length) { + var currComponentType = stack.pop(); + var currVertex = graph[currComponentType]; + var isInTargetNameSet = !!targetNameSet[currComponentType]; + if (isInTargetNameSet) { + callback.call(context, currComponentType, currVertex.originalDeps.slice()); + delete targetNameSet[currComponentType]; + } + zrUtil.each( + currVertex.successor, + isInTargetNameSet ? removeEdgeAndAdd : removeEdge + ); + } + + zrUtil.each(targetNameSet, function () { + throw new Error('Circle dependency may exists'); + }); + + function removeEdge(succComponentType) { + graph[succComponentType].entryCount--; + if (graph[succComponentType].entryCount === 0) { + stack.push(succComponentType); + } + } + + // Consider this case: legend depends on series, and we call + // chart.setOption({series: [...]}), where only series is in option. + // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will + // not be called, but only sereis.mergeOption is called. Thus legend + // have no chance to update its local record about series (like which + // name of series is available in legend). + function removeEdgeAndAdd(succComponentType) { + targetNameSet[succComponentType] = true; + removeEdge(succComponentType); + } + }; + + /** + * DepndencyGraph: {Object} + * key: conponentType, + * value: { + * successor: [conponentTypes...], + * originalDeps: [conponentTypes...], + * entryCount: {number} + * } + */ + function makeDepndencyGraph(fullNameList) { + var graph = {}; + var noEntryList = []; + + zrUtil.each(fullNameList, function (name) { + + var thisItem = createDependencyGraphItem(graph, name); + var originalDeps = thisItem.originalDeps = dependencyGetter(name); + + var availableDeps = getAvailableDependencies(originalDeps, fullNameList); + thisItem.entryCount = availableDeps.length; + if (thisItem.entryCount === 0) { + noEntryList.push(name); + } + + zrUtil.each(availableDeps, function (dependentName) { + if (zrUtil.indexOf(thisItem.predecessor, dependentName) < 0) { + thisItem.predecessor.push(dependentName); + } + var thatItem = createDependencyGraphItem(graph, dependentName); + if (zrUtil.indexOf(thatItem.successor, dependentName) < 0) { + thatItem.successor.push(name); + } + }); + }); + + return {graph: graph, noEntryList: noEntryList}; + } + + function createDependencyGraphItem(graph, name) { + if (!graph[name]) { + graph[name] = {predecessor: [], successor: []}; + } + return graph[name]; + } + + function getAvailableDependencies(originalDeps, fullNameList) { + var availableDeps = []; + zrUtil.each(originalDeps, function (dep) { + zrUtil.indexOf(fullNameList, dep) >= 0 && availableDeps.push(dep); + }); + return availableDeps; + } + }; + + module.exports = componentUtil; + + +/***/ }, +/* 21 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // Layout helpers for each component positioning + + + var zrUtil = __webpack_require__(3); + var BoundingRect = __webpack_require__(15); + var numberUtil = __webpack_require__(7); + var formatUtil = __webpack_require__(6); + var parsePercent = numberUtil.parsePercent; + var each = zrUtil.each; + + var layout = {}; + + var LOCATION_PARAMS = ['left', 'right', 'top', 'bottom', 'width', 'height']; + + function boxLayout(orient, group, gap, maxWidth, maxHeight) { + var x = 0; + var y = 0; + if (maxWidth == null) { + maxWidth = Infinity; + } + if (maxHeight == null) { + maxHeight = Infinity; + } + var currentLineMaxSize = 0; + group.eachChild(function (child, idx) { + var position = child.position; + var rect = child.getBoundingRect(); + var nextChild = group.childAt(idx + 1); + var nextChildRect = nextChild && nextChild.getBoundingRect(); + var nextX; + var nextY; + if (orient === 'horizontal') { + var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0); + nextX = x + moveX; + // Wrap when width exceeds maxWidth or meet a `newline` group + if (nextX > maxWidth || child.newline) { + x = 0; + nextX = moveX; + y += currentLineMaxSize + gap; + currentLineMaxSize = rect.height; + } + else { + currentLineMaxSize = Math.max(currentLineMaxSize, rect.height); + } + } + else { + var moveY = rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0); + nextY = y + moveY; + // Wrap when width exceeds maxHeight or meet a `newline` group + if (nextY > maxHeight || child.newline) { + x += currentLineMaxSize + gap; + y = 0; + nextY = moveY; + currentLineMaxSize = rect.width; + } + else { + currentLineMaxSize = Math.max(currentLineMaxSize, rect.width); + } + } + + if (child.newline) { + return; + } + + position[0] = x; + position[1] = y; + + orient === 'horizontal' + ? (x = nextX + gap) + : (y = nextY + gap); + }); + } + + /** + * VBox or HBox layouting + * @param {string} orient + * @param {module:zrender/container/Group} group + * @param {number} gap + * @param {number} [width=Infinity] + * @param {number} [height=Infinity] + */ + layout.box = boxLayout; + + /** + * VBox layouting + * @param {module:zrender/container/Group} group + * @param {number} gap + * @param {number} [width=Infinity] + * @param {number} [height=Infinity] + */ + layout.vbox = zrUtil.curry(boxLayout, 'vertical'); + + /** + * HBox layouting + * @param {module:zrender/container/Group} group + * @param {number} gap + * @param {number} [width=Infinity] + * @param {number} [height=Infinity] + */ + layout.hbox = zrUtil.curry(boxLayout, 'horizontal'); + + /** + * If x or x2 is not specified or 'center' 'left' 'right', + * the width would be as long as possible. + * If y or y2 is not specified or 'middle' 'top' 'bottom', + * the height would be as long as possible. + * + * @param {Object} positionInfo + * @param {number|string} [positionInfo.x] + * @param {number|string} [positionInfo.y] + * @param {number|string} [positionInfo.x2] + * @param {number|string} [positionInfo.y2] + * @param {Object} containerRect + * @param {string|number} margin + * @return {Object} {width, height} + */ + layout.getAvailableSize = function (positionInfo, containerRect, margin) { + var containerWidth = containerRect.width; + var containerHeight = containerRect.height; + + var x = parsePercent(positionInfo.x, containerWidth); + var y = parsePercent(positionInfo.y, containerHeight); + var x2 = parsePercent(positionInfo.x2, containerWidth); + var y2 = parsePercent(positionInfo.y2, containerHeight); + + (isNaN(x) || isNaN(parseFloat(positionInfo.x))) && (x = 0); + (isNaN(x2) || isNaN(parseFloat(positionInfo.x2))) && (x2 = containerWidth); + (isNaN(y) || isNaN(parseFloat(positionInfo.y))) && (y = 0); + (isNaN(y2) || isNaN(parseFloat(positionInfo.y2))) && (y2 = containerHeight); + + margin = formatUtil.normalizeCssArray(margin || 0); + + return { + width: Math.max(x2 - x - margin[1] - margin[3], 0), + height: Math.max(y2 - y - margin[0] - margin[2], 0) + }; + }; + + /** + * Parse position info. + * + * @param {Object} positionInfo + * @param {number|string} [positionInfo.left] + * @param {number|string} [positionInfo.top] + * @param {number|string} [positionInfo.right] + * @param {number|string} [positionInfo.bottom] + * @param {number|string} [positionInfo.width] + * @param {number|string} [positionInfo.height] + * @param {number|string} [positionInfo.aspect] Aspect is width / height + * @param {Object} containerRect + * @param {string|number} [margin] + * + * @return {module:zrender/core/BoundingRect} + */ + layout.getLayoutRect = function ( + positionInfo, containerRect, margin + ) { + margin = formatUtil.normalizeCssArray(margin || 0); + + var containerWidth = containerRect.width; + var containerHeight = containerRect.height; + + var left = parsePercent(positionInfo.left, containerWidth); + var top = parsePercent(positionInfo.top, containerHeight); + var right = parsePercent(positionInfo.right, containerWidth); + var bottom = parsePercent(positionInfo.bottom, containerHeight); + var width = parsePercent(positionInfo.width, containerWidth); + var height = parsePercent(positionInfo.height, containerHeight); + + var verticalMargin = margin[2] + margin[0]; + var horizontalMargin = margin[1] + margin[3]; + var aspect = positionInfo.aspect; + + // If width is not specified, calculate width from left and right + if (isNaN(width)) { + width = containerWidth - right - horizontalMargin - left; + } + if (isNaN(height)) { + height = containerHeight - bottom - verticalMargin - top; + } + + // If width and height are not given + // 1. Graph should not exceeds the container + // 2. Aspect must be keeped + // 3. Graph should take the space as more as possible + if (isNaN(width) && isNaN(height)) { + if (aspect > containerWidth / containerHeight) { + width = containerWidth * 0.8; + } + else { + height = containerHeight * 0.8; + } + } + + if (aspect != null) { + // Calculate width or height with given aspect + if (isNaN(width)) { + width = aspect * height; + } + if (isNaN(height)) { + height = width / aspect; + } + } + + // If left is not specified, calculate left from right and width + if (isNaN(left)) { + left = containerWidth - right - width - horizontalMargin; + } + if (isNaN(top)) { + top = containerHeight - bottom - height - verticalMargin; + } + + // Align left and top + switch (positionInfo.left || positionInfo.right) { + case 'center': + left = containerWidth / 2 - width / 2 - margin[3]; + break; + case 'right': + left = containerWidth - width - horizontalMargin; + break; + } + switch (positionInfo.top || positionInfo.bottom) { + case 'middle': + case 'center': + top = containerHeight / 2 - height / 2 - margin[0]; + break; + case 'bottom': + top = containerHeight - height - verticalMargin; + break; + } + // If something is wrong and left, top, width, height are calculated as NaN + left = left || 0; + top = top || 0; + if (isNaN(width)) { + // Width may be NaN if only one value is given except width + width = containerWidth - left - (right || 0); + } + if (isNaN(height)) { + // Height may be NaN if only one value is given except height + height = containerHeight - top - (bottom || 0); + } + + var rect = new BoundingRect(left + margin[3], top + margin[0], width, height); + rect.margin = margin; + return rect; + }; + + /** + * Position group of component in viewport + * Group position is specified by either + * {left, top}, {right, bottom} + * If all properties exists, right and bottom will be igonred. + * + * @param {module:zrender/container/Group} group + * @param {Object} positionInfo + * @param {number|string} [positionInfo.left] + * @param {number|string} [positionInfo.top] + * @param {number|string} [positionInfo.right] + * @param {number|string} [positionInfo.bottom] + * @param {Object} containerRect + * @param {string|number} margin + */ + layout.positionGroup = function ( + group, positionInfo, containerRect, margin + ) { + var groupRect = group.getBoundingRect(); + + positionInfo = zrUtil.extend(zrUtil.clone(positionInfo), { + width: groupRect.width, + height: groupRect.height + }); + + positionInfo = layout.getLayoutRect( + positionInfo, containerRect, margin + ); + + group.position = [ + positionInfo.x - groupRect.x, + positionInfo.y - groupRect.y + ]; + }; + + /** + * Consider Case: + * When defulat option has {left: 0, width: 100}, and we set {right: 0} + * through setOption or media query, using normal zrUtil.merge will cause + * {right: 0} does not take effect. + * + * @example + * ComponentModel.extend({ + * init: function () { + * ... + * var inputPositionParams = layout.getLayoutParams(option); + * this.mergeOption(inputPositionParams); + * }, + * mergeOption: function (newOption) { + * newOption && zrUtil.merge(thisOption, newOption, true); + * layout.mergeLayoutParam(thisOption, newOption); + * } + * }); + * + * @param {Object} targetOption + * @param {Object} newOption + * @param {Object|string} [opt] + * @param {boolean} [opt.ignoreSize=false] Some component must has width and height. + */ + layout.mergeLayoutParam = function (targetOption, newOption, opt) { + !zrUtil.isObject(opt) && (opt = {}); + var hNames = ['width', 'left', 'right']; // Order by priority. + var vNames = ['height', 'top', 'bottom']; // Order by priority. + var hResult = merge(hNames); + var vResult = merge(vNames); + + copy(hNames, targetOption, hResult); + copy(vNames, targetOption, vResult); + + function merge(names) { + var newParams = {}; + var newValueCount = 0; + var merged = {}; + var mergedValueCount = 0; + var enoughParamNumber = opt.ignoreSize ? 1 : 2; + + each(names, function (name) { + merged[name] = targetOption[name]; + }); + each(names, function (name) { + // Consider case: newOption.width is null, which is + // set by user for removing width setting. + hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]); + hasValue(newParams, name) && newValueCount++; + hasValue(merged, name) && mergedValueCount++; + }); + + // Case: newOption: {width: ..., right: ...}, + // or targetOption: {right: ...} and newOption: {width: ...}, + // There is no conflict when merged only has params count + // little than enoughParamNumber. + if (mergedValueCount === enoughParamNumber || !newValueCount) { + return merged; + } + // Case: newOption: {width: ..., right: ...}, + // Than we can make sure user only want those two, and ignore + // all origin params in targetOption. + else if (newValueCount >= enoughParamNumber) { + return newParams; + } + else { + // Chose another param from targetOption by priority. + // When 'ignoreSize', enoughParamNumber is 1 and those will not happen. + for (var i = 0; i < names.length; i++) { + var name = names[i]; + if (!hasProp(newParams, name) && hasProp(targetOption, name)) { + newParams[name] = targetOption[name]; + break; + } + } + return newParams; + } + } + + function hasProp(obj, name) { + return obj.hasOwnProperty(name); + } + + function hasValue(obj, name) { + return obj[name] != null && obj[name] !== 'auto'; + } + + function copy(names, target, source) { + each(names, function (name) { + target[name] = source[name]; + }); + } + }; + + /** + * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object. + * @param {Object} source + * @return {Object} Result contains those props. + */ + layout.getLayoutParams = function (source) { + return layout.copyLayoutParams({}, source); + }; + + /** + * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object. + * @param {Object} source + * @return {Object} Result contains those props. + */ + layout.copyLayoutParams = function (target, source) { + source && target && each(LOCATION_PARAMS, function (name) { + source.hasOwnProperty(name) && (target[name] = source[name]); + }); + return target; + }; + + module.exports = layout; + + +/***/ }, +/* 22 */ +/***/ function(module, exports) { + + + + module.exports = { + getBoxLayoutParams: function () { + return { + left: this.get('left'), + top: this.get('top'), + right: this.get('right'), + bottom: this.get('bottom'), + width: this.get('width'), + height: this.get('height') + }; + } + }; + + +/***/ }, +/* 23 */ +/***/ function(module, exports) { + + + var platform = ''; + // Navigator not exists in node + if (typeof navigator !== 'undefined') { + platform = navigator.platform || ''; + } + module.exports = { + // 全图默认背景 + // backgroundColor: 'rgba(0,0,0,0)', + + // https://dribbble.com/shots/1065960-Infographic-Pie-chart-visualization + // color: ['#5793f3', '#d14a61', '#fd9c35', '#675bba', '#fec42c', '#dd4444', '#d4df5a', '#cd4870'], + // 浅色 + // color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'], + // color: ['#cc5664', '#9bd6ec', '#ea946e', '#8acaaa', '#f1ec64', '#ee8686', '#a48dc1', '#5da6bc', '#b9dcae'], + // 深色 + color: ['#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83', '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'], + + // 默认需要 Grid 配置项 + grid: {}, + // 主题,主题 + textStyle: { + // color: '#000', + // decoration: 'none', + // PENDING + fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif', + // fontFamily: 'Arial, Verdana, sans-serif', + fontSize: 12, + fontStyle: 'normal', + fontWeight: 'normal' + }, + // 主题,默认标志图形类型列表 + // symbolList: [ + // 'circle', 'rectangle', 'triangle', 'diamond', + // 'emptyCircle', 'emptyRectangle', 'emptyTriangle', 'emptyDiamond' + // ], + animation: true, // 过渡动画是否开启 + animationThreshold: 2000, // 动画元素阀值,产生的图形原素超过2000不出动画 + animationDuration: 1000, // 过渡动画参数:进入 + animationDurationUpdate: 300, // 过渡动画参数:更新 + animationEasing: 'exponentialOut', //BounceOut + animationEasingUpdate: 'cubicOut' + }; + + +/***/ }, +/* 24 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + + var echartsAPIList = [ + 'getDom', 'getZr', 'getWidth', 'getHeight', 'dispatchAction', + 'on', 'off', 'getDataURL', 'getConnectedDataURL', 'getModel', 'getOption' + ]; + + function ExtensionAPI(chartInstance) { + zrUtil.each(echartsAPIList, function (name) { + this[name] = zrUtil.bind(chartInstance[name], chartInstance); + }, this); + } + + module.exports = ExtensionAPI; + + +/***/ }, +/* 25 */ +/***/ function(module, exports) { + + 'use strict'; + + + // var zrUtil = require('zrender/lib/core/util'); + var coordinateSystemCreators = {}; + + function CoordinateSystemManager() { + + this._coordinateSystems = []; + } + + CoordinateSystemManager.prototype = { + + constructor: CoordinateSystemManager, + + create: function (ecModel, api) { + var coordinateSystems = []; + for (var type in coordinateSystemCreators) { + var list = coordinateSystemCreators[type].create(ecModel, api); + list && (coordinateSystems = coordinateSystems.concat(list)); + } + + this._coordinateSystems = coordinateSystems; + }, + + update: function (ecModel, api) { + var coordinateSystems = this._coordinateSystems; + for (var i = 0; i < coordinateSystems.length; i++) { + // FIXME MUST have + coordinateSystems[i].update && coordinateSystems[i].update(ecModel, api); + } + } + }; + + CoordinateSystemManager.register = function (type, coordinateSystemCreator) { + coordinateSystemCreators[type] = coordinateSystemCreator; + }; + + CoordinateSystemManager.get = function (type) { + return coordinateSystemCreators[type]; + }; + + module.exports = CoordinateSystemManager; + + +/***/ }, +/* 26 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * ECharts option manager + * + * @module {echarts/model/OptionManager} + */ + + + + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var ComponentModel = __webpack_require__(19); + var each = zrUtil.each; + var clone = zrUtil.clone; + var map = zrUtil.map; + var merge = zrUtil.merge; + + var QUERY_REG = /^(min|max)?(.+)$/; + + /** + * TERM EXPLANATIONS: + * + * [option]: + * + * An object that contains definitions of components. For example: + * var option = { + * title: {...}, + * legend: {...}, + * visualMap: {...}, + * series: [ + * {data: [...]}, + * {data: [...]}, + * ... + * ] + * }; + * + * [rawOption]: + * + * An object input to echarts.setOption. 'rawOption' may be an + * 'option', or may be an object contains multi-options. For example: + * var option = { + * baseOption: { + * title: {...}, + * legend: {...}, + * series: [ + * {data: [...]}, + * {data: [...]}, + * ... + * ] + * }, + * timeline: {...}, + * options: [ + * {title: {...}, series: {data: [...]}}, + * {title: {...}, series: {data: [...]}}, + * ... + * ], + * media: [ + * { + * query: {maxWidth: 320}, + * option: {series: {x: 20}, visualMap: {show: false}} + * }, + * { + * query: {minWidth: 320, maxWidth: 720}, + * option: {series: {x: 500}, visualMap: {show: true}} + * }, + * { + * option: {series: {x: 1200}, visualMap: {show: true}} + * } + * ] + * }; + * + * @alias module:echarts/model/OptionManager + * @param {module:echarts/ExtensionAPI} api + */ + function OptionManager(api) { + + /** + * @private + * @type {module:echarts/ExtensionAPI} + */ + this._api = api; + + /** + * @private + * @type {Array.} + */ + this._timelineOptions = []; + + /** + * @private + * @type {Array.} + */ + this._mediaList = []; + + /** + * @private + * @type {Object} + */ + this._mediaDefault; + + /** + * -1, means default. + * empty means no media. + * @private + * @type {Array.} + */ + this._currentMediaIndices = []; + + /** + * @private + * @type {Object} + */ + this._optionBackup; + + /** + * @private + * @type {Object} + */ + this._newOptionBackup; + } + + // timeline.notMerge is not supported in ec3. Firstly there is rearly + // case that notMerge is needed. Secondly supporting 'notMerge' requires + // rawOption cloned and backuped when timeline changed, which does no + // good to performance. What's more, that both timeline and setOption + // method supply 'notMerge' brings complex and some problems. + // Consider this case: + // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false); + // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false); + + OptionManager.prototype = { + + constructor: OptionManager, + + /** + * @public + * @param {Object} rawOption Raw option. + * @param {module:echarts/model/Global} ecModel + * @param {Array.} optionPreprocessorFuncs + * @return {Object} Init option + */ + setOption: function (rawOption, optionPreprocessorFuncs) { + rawOption = clone(rawOption, true); + + // FIXME + // 如果 timeline options 或者 media 中设置了某个属性,而baseOption中没有设置,则进行警告。 + + var oldOptionBackup = this._optionBackup; + var newOptionBackup = this._newOptionBackup = parseRawOption.call( + this, rawOption, optionPreprocessorFuncs + ); + + // For setOption at second time (using merge mode); + if (oldOptionBackup) { + // Only baseOption can be merged. + mergeOption(oldOptionBackup.baseOption, newOptionBackup.baseOption); + + if (newOptionBackup.timelineOptions.length) { + oldOptionBackup.timelineOptions = newOptionBackup.timelineOptions; + } + if (newOptionBackup.mediaList.length) { + oldOptionBackup.mediaList = newOptionBackup.mediaList; + } + if (newOptionBackup.mediaDefault) { + oldOptionBackup.mediaDefault = newOptionBackup.mediaDefault; + } + } + else { + this._optionBackup = newOptionBackup; + } + }, + + /** + * @param {boolean} isRecreate + * @return {Object} + */ + mountOption: function (isRecreate) { + var optionBackup = isRecreate + // this._optionBackup can be only used when recreate. + // In other cases we use model.mergeOption to handle merge. + ? this._optionBackup : this._newOptionBackup; + + // FIXME + // 如果没有reset功能则不clone。 + + this._timelineOptions = map(optionBackup.timelineOptions, clone); + this._mediaList = map(optionBackup.mediaList, clone); + this._mediaDefault = clone(optionBackup.mediaDefault); + this._currentMediaIndices = []; + + return clone(optionBackup.baseOption); + }, + + /** + * @param {module:echarts/model/Global} ecModel + * @return {Object} + */ + getTimelineOption: function (ecModel) { + var option; + var timelineOptions = this._timelineOptions; + + if (timelineOptions.length) { + // getTimelineOption can only be called after ecModel inited, + // so we can get currentIndex from timelineModel. + var timelineModel = ecModel.getComponent('timeline'); + if (timelineModel) { + option = clone( + timelineOptions[timelineModel.getCurrentIndex()], + true + ); + } + } + + return option; + }, + + /** + * @param {module:echarts/model/Global} ecModel + * @return {Array.} + */ + getMediaOption: function (ecModel) { + var ecWidth = this._api.getWidth(); + var ecHeight = this._api.getHeight(); + var mediaList = this._mediaList; + var mediaDefault = this._mediaDefault; + var indices = []; + var result = []; + + // No media defined. + if (!mediaList.length && !mediaDefault) { + return result; + } + + // Multi media may be applied, the latter defined media has higher priority. + for (var i = 0, len = mediaList.length; i < len; i++) { + if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) { + indices.push(i); + } + } + + // FIXME + // 是否mediaDefault应该强制用户设置,否则可能修改不能回归。 + if (!indices.length && mediaDefault) { + indices = [-1]; + } + + if (indices.length && !indicesEquals(indices, this._currentMediaIndices)) { + result = map(indices, function (index) { + return clone( + index === -1 ? mediaDefault.option : mediaList[index].option + ); + }); + } + // Otherwise return nothing. + + this._currentMediaIndices = indices; + + return result; + } + }; + + function parseRawOption(rawOption, optionPreprocessorFuncs) { + var timelineOptions = []; + var mediaList = []; + var mediaDefault; + var baseOption; + + // Compatible with ec2. + var timelineOpt = rawOption.timeline; + + if (rawOption.baseOption) { + baseOption = rawOption.baseOption; + } + + // For timeline + if (timelineOpt || rawOption.options) { + baseOption = baseOption || {}; + timelineOptions = (rawOption.options || []).slice(); + } + // For media query + if (rawOption.media) { + baseOption = baseOption || {}; + var media = rawOption.media; + each(media, function (singleMedia) { + if (singleMedia && singleMedia.option) { + if (singleMedia.query) { + mediaList.push(singleMedia); + } + else if (!mediaDefault) { + // Use the first media default. + mediaDefault = singleMedia; + } + } + }); + } + + // For normal option + if (!baseOption) { + baseOption = rawOption; + } + + // Set timelineOpt to baseOption in ec3, + // which is convenient for merge option. + if (!baseOption.timeline) { + baseOption.timeline = timelineOpt; + } + + // Preprocess. + each([baseOption].concat(timelineOptions) + .concat(zrUtil.map(mediaList, function (media) { + return media.option; + })), + function (option) { + each(optionPreprocessorFuncs, function (preProcess) { + preProcess(option); + }); + } + ); + + return { + baseOption: baseOption, + timelineOptions: timelineOptions, + mediaDefault: mediaDefault, + mediaList: mediaList + }; + } + + /** + * @see + * Support: width, height, aspectRatio + * Can use max or min as prefix. + */ + function applyMediaQuery(query, ecWidth, ecHeight) { + var realMap = { + width: ecWidth, + height: ecHeight, + aspectratio: ecWidth / ecHeight // lowser case for convenientce. + }; + + var applicatable = true; + + zrUtil.each(query, function (value, attr) { + var matched = attr.match(QUERY_REG); + + if (!matched || !matched[1] || !matched[2]) { + return; + } + + var operator = matched[1]; + var realAttr = matched[2].toLowerCase(); + + if (!compare(realMap[realAttr], value, operator)) { + applicatable = false; + } + }); + + return applicatable; + } + + function compare(real, expect, operator) { + if (operator === 'min') { + return real >= expect; + } + else if (operator === 'max') { + return real <= expect; + } + else { // Equals + return real === expect; + } + } + + function indicesEquals(indices1, indices2) { + // indices is always order by asc and has only finite number. + return indices1.join(',') === indices2.join(','); + } + + /** + * Consider case: + * `chart.setOption(opt1);` + * Then user do some interaction like dataZoom, dataView changing. + * `chart.setOption(opt2);` + * Then user press 'reset button' in toolbox. + * + * After doing that all of the interaction effects should be reset, the + * chart should be the same as the result of invoke + * `chart.setOption(opt1); chart.setOption(opt2);`. + * + * Although it is not able ensure that + * `chart.setOption(opt1); chart.setOption(opt2);` is equivalents to + * `chart.setOption(merge(opt1, opt2));` exactly, + * this might be the only simple way to implement that feature. + * + * MEMO: We've considered some other approaches: + * 1. Each model handle its self restoration but not uniform treatment. + * (Too complex in logic and error-prone) + * 2. Use a shadow ecModel. (Performace expensive) + */ + function mergeOption(oldOption, newOption) { + newOption = newOption || {}; + + each(newOption, function (newCptOpt, mainType) { + if (newCptOpt == null) { + return; + } + + var oldCptOpt = oldOption[mainType]; + + if (!ComponentModel.hasClass(mainType)) { + oldOption[mainType] = merge(oldCptOpt, newCptOpt, true); + } + else { + newCptOpt = modelUtil.normalizeToArray(newCptOpt); + oldCptOpt = modelUtil.normalizeToArray(oldCptOpt); + + var mapResult = modelUtil.mappingToExists(oldCptOpt, newCptOpt); + + oldOption[mainType] = map(mapResult, function (item) { + return (item.option && item.exist) + ? merge(item.exist, item.option, true) + : (item.exist || item.option); + }); + } + }); + } + + module.exports = OptionManager; + + +/***/ }, +/* 27 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var formatUtil = __webpack_require__(6); + var modelUtil = __webpack_require__(5); + var ComponentModel = __webpack_require__(19); + + var encodeHTML = formatUtil.encodeHTML; + var addCommas = formatUtil.addCommas; + + var SeriesModel = ComponentModel.extend({ + + type: 'series', + + /** + * @readOnly + */ + seriesIndex: 0, + + // coodinateSystem will be injected in the echarts/CoordinateSystem + coordinateSystem: null, + + /** + * @type {Object} + * @protected + */ + defaultOption: null, + + /** + * Data provided for legend + * @type {Function} + */ + // PENDING + legendDataProvider: null, + + init: function (option, parentModel, ecModel, extraOpt) { + + /** + * @type {number} + * @readOnly + */ + this.seriesIndex = this.componentIndex; + + this.mergeDefaultAndTheme(option, ecModel); + + /** + * @type {module:echarts/data/List|module:echarts/data/Tree|module:echarts/data/Graph} + * @private + */ + this._dataBeforeProcessed = this.getInitialData(option, ecModel); + + // When using module:echarts/data/Tree or module:echarts/data/Graph, + // cloneShallow will cause this._data.graph.data pointing to new data list. + // Wo we make this._dataBeforeProcessed first, and then make this._data. + this._data = this._dataBeforeProcessed.cloneShallow(); + }, + + /** + * Util for merge default and theme to option + * @param {Object} option + * @param {module:echarts/model/Global} ecModel + */ + mergeDefaultAndTheme: function (option, ecModel) { + zrUtil.merge( + option, + ecModel.getTheme().get(this.subType) + ); + zrUtil.merge(option, this.getDefaultOption()); + + // Default label emphasis `position` and `show` + modelUtil.defaultEmphasis( + option.label, ['position', 'show', 'textStyle', 'distance', 'formatter'] + ); + + // Default data label emphasis `position` and `show` + // FIXME Tree structure data ? + var data = option.data || []; + for (var i = 0; i < data.length; i++) { + if (data[i] && data[i].label) { + modelUtil.defaultEmphasis( + data[i].label, ['position', 'show', 'textStyle', 'distance', 'formatter'] + ); + } + } + }, + + mergeOption: function (newSeriesOption, ecModel) { + newSeriesOption = zrUtil.merge(this.option, newSeriesOption, true); + + var data = this.getInitialData(newSeriesOption, ecModel); + // TODO Merge data? + if (data) { + this._data = data; + this._dataBeforeProcessed = data.cloneShallow(); + } + }, + + /** + * Init a data structure from data related option in series + * Must be overwritten + */ + getInitialData: function () {}, + + /** + * @return {module:echarts/data/List} + */ + getData: function () { + return this._data; + }, + + /** + * @param {module:echarts/data/List} data + */ + setData: function (data) { + this._data = data; + }, + + /** + * Get data before processed + * @return {module:echarts/data/List} + */ + getRawData: function () { + return this._dataBeforeProcessed; + }, + + /** + * Get raw data array given by user + * @return {Array.} + */ + getRawDataArray: function () { + return this.option.data; + }, + + /** + * Coord dimension to data dimension. + * + * By default the result is the same as dimensions of series data. + * But some series dimensions are different from coord dimensions (i.e. + * candlestick and boxplot). Override this method to handle those cases. + * + * Coord dimension to data dimension can be one-to-many + * + * @param {string} coordDim + * @return {Array.} dimensions on the axis. + */ + coordDimToDataDim: function (coordDim) { + return [coordDim]; + }, + + /** + * Convert data dimension to coord dimension. + * + * @param {string|number} dataDim + * @return {string} + */ + dataDimToCoordDim: function (dataDim) { + return dataDim; + }, + + /** + * Get base axis if has coordinate system and has axis. + * By default use coordSys.getBaseAxis(); + * Can be overrided for some chart. + * @return {type} description + */ + getBaseAxis: function () { + var coordSys = this.coordinateSystem; + return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis(); + }, + + // FIXME + /** + * Default tooltip formatter + * + * @param {number} dataIndex + * @param {boolean} [multipleSeries=false] + */ + formatTooltip: function (dataIndex, multipleSeries) { + var data = this._data; + var value = this.getRawValue(dataIndex); + var formattedValue = zrUtil.isArray(value) + ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); + var name = data.getName(dataIndex); + + return !multipleSeries + ? (encodeHTML(this.name) + '
' + + (name + ? encodeHTML(name) + ' : ' + formattedValue + : formattedValue) + ) + : (encodeHTML(this.name) + ' : ' + formattedValue); + }, + + restoreData: function () { + this._data = this._dataBeforeProcessed.cloneShallow(); + } + }); + + zrUtil.mixin(SeriesModel, modelUtil.dataFormatMixin); + + module.exports = SeriesModel; + + +/***/ }, +/* 28 */ +/***/ function(module, exports, __webpack_require__) { + + + + var Group = __webpack_require__(29); + var componentUtil = __webpack_require__(20); + var clazzUtil = __webpack_require__(9); + + var Component = function () { + /** + * @type {module:zrender/container/Group} + * @readOnly + */ + this.group = new Group(); + + /** + * @type {string} + * @readOnly + */ + this.uid = componentUtil.getUID('viewComponent'); + }; + + Component.prototype = { + + constructor: Component, + + init: function (ecModel, api) {}, + + render: function (componentModel, ecModel, api, payload) {}, + + dispose: function () {} + }; + + var componentProto = Component.prototype; + componentProto.updateView + = componentProto.updateLayout + = componentProto.updateVisual + = function (seriesModel, ecModel, api, payload) { + // Do nothing; + }; + // Enable Component.extend. + clazzUtil.enableClassExtend(Component); + + // Enable capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. + clazzUtil.enableClassManagement(Component, {registerWhenExtend: true}); + + module.exports = Component; + + +/***/ }, +/* 29 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上 + * @module zrender/graphic/Group + * @example + * var Group = require('zrender/lib/container/Group'); + * var Circle = require('zrender/lib/graphic/shape/Circle'); + * var g = new Group(); + * g.position[0] = 100; + * g.position[1] = 100; + * g.add(new Circle({ + * style: { + * x: 100, + * y: 100, + * r: 20, + * } + * })); + * zr.add(g); + */ + + + var zrUtil = __webpack_require__(3); + var Element = __webpack_require__(30); + var BoundingRect = __webpack_require__(15); + + /** + * @alias module:zrender/graphic/Group + * @constructor + * @extends module:zrender/mixin/Transformable + * @extends module:zrender/mixin/Eventful + */ + var Group = function (opts) { + + opts = opts || {}; + + Element.call(this, opts); + + for (var key in opts) { + this[key] = opts[key]; + } + + this._children = []; + + this.__storage = null; + + this.__dirty = true; + }; + + Group.prototype = { + + constructor: Group, + + /** + * @type {string} + */ + type: 'group', + + /** + * @return {Array.} + */ + children: function () { + return this._children.slice(); + }, + + /** + * 获取指定 index 的儿子节点 + * @param {number} idx + * @return {module:zrender/Element} + */ + childAt: function (idx) { + return this._children[idx]; + }, + + /** + * 获取指定名字的儿子节点 + * @param {string} name + * @return {module:zrender/Element} + */ + childOfName: function (name) { + var children = this._children; + for (var i = 0; i < children.length; i++) { + if (children[i].name === name) { + return children[i]; + } + } + }, + + /** + * @return {number} + */ + childCount: function () { + return this._children.length; + }, + + /** + * 添加子节点到最后 + * @param {module:zrender/Element} child + */ + add: function (child) { + if (child && child !== this && child.parent !== this) { + + this._children.push(child); + + this._doAdd(child); + } + + return this; + }, + + /** + * 添加子节点在 nextSibling 之前 + * @param {module:zrender/Element} child + * @param {module:zrender/Element} nextSibling + */ + addBefore: function (child, nextSibling) { + if (child && child !== this && child.parent !== this + && nextSibling && nextSibling.parent === this) { + + var children = this._children; + var idx = children.indexOf(nextSibling); + + if (idx >= 0) { + children.splice(idx, 0, child); + this._doAdd(child); + } + } + + return this; + }, + + _doAdd: function (child) { + if (child.parent) { + child.parent.remove(child); + } + + child.parent = this; + + var storage = this.__storage; + var zr = this.__zr; + if (storage && storage !== child.__storage) { + + storage.addToMap(child); + + if (child instanceof Group) { + child.addChildrenToStorage(storage); + } + } + + zr && zr.refresh(); + }, + + /** + * 移除子节点 + * @param {module:zrender/Element} child + */ + remove: function (child) { + var zr = this.__zr; + var storage = this.__storage; + var children = this._children; + + var idx = zrUtil.indexOf(children, child); + if (idx < 0) { + return this; + } + children.splice(idx, 1); + + child.parent = null; + + if (storage) { + + storage.delFromMap(child.id); + + if (child instanceof Group) { + child.delChildrenFromStorage(storage); + } + } + + zr && zr.refresh(); + + return this; + }, + + /** + * 移除所有子节点 + */ + removeAll: function () { + var children = this._children; + var storage = this.__storage; + var child; + var i; + for (i = 0; i < children.length; i++) { + child = children[i]; + if (storage) { + storage.delFromMap(child.id); + if (child instanceof Group) { + child.delChildrenFromStorage(storage); + } + } + child.parent = null; + } + children.length = 0; + + return this; + }, + + /** + * 遍历所有子节点 + * @param {Function} cb + * @param {} context + */ + eachChild: function (cb, context) { + var children = this._children; + for (var i = 0; i < children.length; i++) { + var child = children[i]; + cb.call(context, child, i); + } + return this; + }, + + /** + * 深度优先遍历所有子孙节点 + * @param {Function} cb + * @param {} context + */ + traverse: function (cb, context) { + for (var i = 0; i < this._children.length; i++) { + var child = this._children[i]; + cb.call(context, child); + + if (child.type === 'group') { + child.traverse(cb, context); + } + } + return this; + }, + + addChildrenToStorage: function (storage) { + for (var i = 0; i < this._children.length; i++) { + var child = this._children[i]; + storage.addToMap(child); + if (child instanceof Group) { + child.addChildrenToStorage(storage); + } + } + }, + + delChildrenFromStorage: function (storage) { + for (var i = 0; i < this._children.length; i++) { + var child = this._children[i]; + storage.delFromMap(child.id); + if (child instanceof Group) { + child.delChildrenFromStorage(storage); + } + } + }, + + dirty: function () { + this.__dirty = true; + this.__zr && this.__zr.refresh(); + return this; + }, + + /** + * @return {module:zrender/core/BoundingRect} + */ + getBoundingRect: function (includeChildren) { + // TODO Caching + // TODO Transform + var rect = null; + var tmpRect = new BoundingRect(0, 0, 0, 0); + var children = includeChildren || this._children; + var tmpMat = []; + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (child.ignore || child.invisible) { + continue; + } + + var childRect = child.getBoundingRect(); + var transform = child.getLocalTransform(tmpMat); + if (transform) { + tmpRect.copy(childRect); + tmpRect.applyTransform(transform); + rect = rect || tmpRect.clone(); + rect.union(tmpRect); + } + else { + rect = rect || childRect.clone(); + rect.union(childRect); + } + } + return rect || tmpRect; + } + }; + + zrUtil.inherits(Group, Element); + + module.exports = Group; + + +/***/ }, +/* 30 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * @module zrender/Element + */ + + + var guid = __webpack_require__(31); + var Eventful = __webpack_require__(32); + var Transformable = __webpack_require__(33); + var Animatable = __webpack_require__(34); + var zrUtil = __webpack_require__(3); + + /** + * @alias module:zrender/Element + * @constructor + * @extends {module:zrender/mixin/Animatable} + * @extends {module:zrender/mixin/Transformable} + * @extends {module:zrender/mixin/Eventful} + */ + var Element = function (opts) { + + Transformable.call(this, opts); + Eventful.call(this, opts); + Animatable.call(this, opts); + + /** + * 画布元素ID + * @type {string} + */ + this.id = opts.id || guid(); + }; + + Element.prototype = { + + /** + * 元素类型 + * Element type + * @type {string} + */ + type: 'element', + + /** + * 元素名字 + * Element name + * @type {string} + */ + name: '', + + /** + * ZRender 实例对象,会在 element 添加到 zrender 实例中后自动赋值 + * ZRender instance will be assigned when element is associated with zrender + * @name module:/zrender/Element#__zr + * @type {module:zrender/ZRender} + */ + __zr: null, + + /** + * 图形是否忽略,为true时忽略图形的绘制以及事件触发 + * If ignore drawing and events of the element object + * @name module:/zrender/Element#ignore + * @type {boolean} + * @default false + */ + ignore: false, + + /** + * 用于裁剪的路径(shape),所有 Group 内的路径在绘制时都会被这个路径裁剪 + * 该路径会继承被裁减对象的变换 + * @type {module:zrender/graphic/Path} + * @see http://www.w3.org/TR/2dcontext/#clipping-region + * @readOnly + */ + clipPath: null, + + /** + * Drift element + * @param {number} dx dx on the global space + * @param {number} dy dy on the global space + */ + drift: function (dx, dy) { + switch (this.draggable) { + case 'horizontal': + dy = 0; + break; + case 'vertical': + dx = 0; + break; + } + + var m = this.transform; + if (!m) { + m = this.transform = [1, 0, 0, 1, 0, 0]; + } + m[4] += dx; + m[5] += dy; + + this.decomposeTransform(); + this.dirty(); + }, + + /** + * Hook before update + */ + beforeUpdate: function () {}, + /** + * Hook after update + */ + afterUpdate: function () {}, + /** + * Update each frame + */ + update: function () { + this.updateTransform(); + }, + + /** + * @param {Function} cb + * @param {} context + */ + traverse: function (cb, context) {}, + + /** + * @protected + */ + attrKV: function (key, value) { + if (key === 'position' || key === 'scale' || key === 'origin') { + // Copy the array + if (value) { + var target = this[key]; + if (!target) { + target = this[key] = []; + } + target[0] = value[0]; + target[1] = value[1]; + } + } + else { + this[key] = value; + } + }, + + /** + * Hide the element + */ + hide: function () { + this.ignore = true; + this.__zr && this.__zr.refresh(); + }, + + /** + * Show the element + */ + show: function () { + this.ignore = false; + this.__zr && this.__zr.refresh(); + }, + + /** + * @param {string|Object} key + * @param {*} value + */ + attr: function (key, value) { + if (typeof key === 'string') { + this.attrKV(key, value); + } + else if (zrUtil.isObject(key)) { + for (var name in key) { + if (key.hasOwnProperty(name)) { + this.attrKV(name, key[name]); + } + } + } + this.dirty(); + + return this; + }, + + /** + * @param {module:zrender/graphic/Path} clipPath + */ + setClipPath: function (clipPath) { + var zr = this.__zr; + if (zr) { + clipPath.addSelfToZr(zr); + } + + // Remove previous clip path + if (this.clipPath && this.clipPath !== clipPath) { + this.removeClipPath(); + } + + this.clipPath = clipPath; + clipPath.__zr = zr; + clipPath.__clipTarget = this; + + this.dirty(); + }, + + /** + */ + removeClipPath: function () { + var clipPath = this.clipPath; + if (clipPath) { + if (clipPath.__zr) { + clipPath.removeSelfFromZr(clipPath.__zr); + } + + clipPath.__zr = null; + clipPath.__clipTarget = null; + this.clipPath = null; + + this.dirty(); + } + }, + + /** + * Add self from zrender instance. + * Not recursively because it will be invoked when element added to storage. + * @param {module:zrender/ZRender} zr + */ + addSelfToZr: function (zr) { + this.__zr = zr; + // 添加动画 + var animators = this.animators; + if (animators) { + for (var i = 0; i < animators.length; i++) { + zr.animation.addAnimator(animators[i]); + } + } + + if (this.clipPath) { + this.clipPath.addSelfToZr(zr); + } + }, + + /** + * Remove self from zrender instance. + * Not recursively because it will be invoked when element added to storage. + * @param {module:zrender/ZRender} zr + */ + removeSelfFromZr: function (zr) { + this.__zr = null; + // 移除动画 + var animators = this.animators; + if (animators) { + for (var i = 0; i < animators.length; i++) { + zr.animation.removeAnimator(animators[i]); + } + } + + if (this.clipPath) { + this.clipPath.removeSelfFromZr(zr); + } + } + }; + + zrUtil.mixin(Element, Animatable); + zrUtil.mixin(Element, Transformable); + zrUtil.mixin(Element, Eventful); + + module.exports = Element; + + +/***/ }, +/* 31 */ +/***/ function(module, exports) { + + /** + * zrender: 生成唯一id + * + * @author errorrik (errorrik@gmail.com) + */ + + + var idStart = 0x0907; + + module.exports = function () { + return 'zr_' + (idStart++); + }; + + + +/***/ }, +/* 32 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 事件扩展 + * @module zrender/mixin/Eventful + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + * pissang (https://www.github.com/pissang) + */ + + + var arrySlice = Array.prototype.slice; + var zrUtil = __webpack_require__(3); + var indexOf = zrUtil.indexOf; + + /** + * 事件分发器 + * @alias module:zrender/mixin/Eventful + * @constructor + */ + var Eventful = function () { + this._$handlers = {}; + }; + + Eventful.prototype = { + + constructor: Eventful, + + /** + * 单次触发绑定,trigger后销毁 + * + * @param {string} event 事件名 + * @param {Function} handler 响应函数 + * @param {Object} context + */ + one: function (event, handler, context) { + var _h = this._$handlers; + + if (!handler || !event) { + return this; + } + + if (!_h[event]) { + _h[event] = []; + } + + if (indexOf(_h[event], event) >= 0) { + return this; + } + + _h[event].push({ + h: handler, + one: true, + ctx: context || this + }); + + return this; + }, + + /** + * 绑定事件 + * @param {string} event 事件名 + * @param {Function} handler 事件处理函数 + * @param {Object} [context] + */ + on: function (event, handler, context) { + var _h = this._$handlers; + + if (!handler || !event) { + return this; + } + + if (!_h[event]) { + _h[event] = []; + } + + _h[event].push({ + h: handler, + one: false, + ctx: context || this + }); + + return this; + }, + + /** + * 是否绑定了事件 + * @param {string} event + * @return {boolean} + */ + isSilent: function (event) { + var _h = this._$handlers; + return _h[event] && _h[event].length; + }, + + /** + * 解绑事件 + * @param {string} event 事件名 + * @param {Function} [handler] 事件处理函数 + */ + off: function (event, handler) { + var _h = this._$handlers; + + if (!event) { + this._$handlers = {}; + return this; + } + + if (handler) { + if (_h[event]) { + var newList = []; + for (var i = 0, l = _h[event].length; i < l; i++) { + if (_h[event][i]['h'] != handler) { + newList.push(_h[event][i]); + } + } + _h[event] = newList; + } + + if (_h[event] && _h[event].length === 0) { + delete _h[event]; + } + } + else { + delete _h[event]; + } + + return this; + }, + + /** + * 事件分发 + * + * @param {string} type 事件类型 + */ + trigger: function (type) { + if (this._$handlers[type]) { + var args = arguments; + var argLen = args.length; + + if (argLen > 3) { + args = arrySlice.call(args, 1); + } + + var _h = this._$handlers[type]; + var len = _h.length; + for (var i = 0; i < len;) { + // Optimize advise from backbone + switch (argLen) { + case 1: + _h[i]['h'].call(_h[i]['ctx']); + break; + case 2: + _h[i]['h'].call(_h[i]['ctx'], args[1]); + break; + case 3: + _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]); + break; + default: + // have more than 2 given arguments + _h[i]['h'].apply(_h[i]['ctx'], args); + break; + } + + if (_h[i]['one']) { + _h.splice(i, 1); + len--; + } + else { + i++; + } + } + } + + return this; + }, + + /** + * 带有context的事件分发, 最后一个参数是事件回调的context + * @param {string} type 事件类型 + */ + triggerWithContext: function (type) { + if (this._$handlers[type]) { + var args = arguments; + var argLen = args.length; + + if (argLen > 4) { + args = arrySlice.call(args, 1, args.length - 1); + } + var ctx = args[args.length - 1]; + + var _h = this._$handlers[type]; + var len = _h.length; + for (var i = 0; i < len;) { + // Optimize advise from backbone + switch (argLen) { + case 1: + _h[i]['h'].call(ctx); + break; + case 2: + _h[i]['h'].call(ctx, args[1]); + break; + case 3: + _h[i]['h'].call(ctx, args[1], args[2]); + break; + default: + // have more than 2 given arguments + _h[i]['h'].apply(ctx, args); + break; + } + + if (_h[i]['one']) { + _h.splice(i, 1); + len--; + } + else { + i++; + } + } + } + + return this; + } + }; + + // 对象可以通过 onxxxx 绑定事件 + /** + * @event module:zrender/mixin/Eventful#onclick + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmouseover + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmouseout + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmousemove + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmousewheel + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmousedown + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmouseup + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragstart + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragend + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragenter + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragleave + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragover + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondrop + * @type {Function} + * @default null + */ + + module.exports = Eventful; + + + +/***/ }, +/* 33 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 提供变换扩展 + * @module zrender/mixin/Transformable + * @author pissang (https://www.github.com/pissang) + */ + + + var matrix = __webpack_require__(17); + var vector = __webpack_require__(16); + var mIdentity = matrix.identity; + + var EPSILON = 5e-5; + + function isNotAroundZero(val) { + return val > EPSILON || val < -EPSILON; + } + + /** + * @alias module:zrender/mixin/Transformable + * @constructor + */ + var Transformable = function (opts) { + opts = opts || {}; + // If there are no given position, rotation, scale + if (!opts.position) { + /** + * 平移 + * @type {Array.} + * @default [0, 0] + */ + this.position = [0, 0]; + } + if (opts.rotation == null) { + /** + * 旋转 + * @type {Array.} + * @default 0 + */ + this.rotation = 0; + } + if (!opts.scale) { + /** + * 缩放 + * @type {Array.} + * @default [1, 1] + */ + this.scale = [1, 1]; + } + /** + * 旋转和缩放的原点 + * @type {Array.} + * @default null + */ + this.origin = this.origin || null; + }; + + var transformableProto = Transformable.prototype; + transformableProto.transform = null; + + /** + * 判断是否需要有坐标变换 + * 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵 + */ + transformableProto.needLocalTransform = function () { + return isNotAroundZero(this.rotation) + || isNotAroundZero(this.position[0]) + || isNotAroundZero(this.position[1]) + || isNotAroundZero(this.scale[0] - 1) + || isNotAroundZero(this.scale[1] - 1); + }; + + transformableProto.updateTransform = function () { + var parent = this.parent; + var parentHasTransform = parent && parent.transform; + var needLocalTransform = this.needLocalTransform(); + + var m = this.transform; + if (!(needLocalTransform || parentHasTransform)) { + m && mIdentity(m); + return; + } + + m = m || matrix.create(); + + if (needLocalTransform) { + this.getLocalTransform(m); + } + else { + mIdentity(m); + } + + // 应用父节点变换 + if (parentHasTransform) { + if (needLocalTransform) { + matrix.mul(m, parent.transform, m); + } + else { + matrix.copy(m, parent.transform); + } + } + // 保存这个变换矩阵 + this.transform = m; + + this.invTransform = this.invTransform || matrix.create(); + matrix.invert(this.invTransform, m); + }; + + transformableProto.getLocalTransform = function (m) { + m = m || []; + mIdentity(m); + + var origin = this.origin; + + var scale = this.scale; + var rotation = this.rotation; + var position = this.position; + if (origin) { + // Translate to origin + m[4] -= origin[0]; + m[5] -= origin[1]; + } + matrix.scale(m, m, scale); + if (rotation) { + matrix.rotate(m, m, rotation); + } + if (origin) { + // Translate back from origin + m[4] += origin[0]; + m[5] += origin[1]; + } + + m[4] += position[0]; + m[5] += position[1]; + + return m; + }; + /** + * 将自己的transform应用到context上 + * @param {Context2D} ctx + */ + transformableProto.setTransform = function (ctx) { + var m = this.transform; + if (m) { + ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); + } + }; + + var tmpTransform = []; + + /** + * 分解`transform`矩阵到`position`, `rotation`, `scale` + */ + transformableProto.decomposeTransform = function () { + if (!this.transform) { + return; + } + var parent = this.parent; + var m = this.transform; + if (parent && parent.transform) { + // Get local transform and decompose them to position, scale, rotation + matrix.mul(tmpTransform, parent.invTransform, m); + m = tmpTransform; + } + var sx = m[0] * m[0] + m[1] * m[1]; + var sy = m[2] * m[2] + m[3] * m[3]; + var position = this.position; + var scale = this.scale; + if (isNotAroundZero(sx - 1)) { + sx = Math.sqrt(sx); + } + if (isNotAroundZero(sy - 1)) { + sy = Math.sqrt(sy); + } + if (m[0] < 0) { + sx = -sx; + } + if (m[3] < 0) { + sy = -sy; + } + position[0] = m[4]; + position[1] = m[5]; + scale[0] = sx; + scale[1] = sy; + this.rotation = Math.atan2(-m[1] / sy, m[0] / sx); + }; + + /** + * 变换坐标位置到 shape 的局部坐标空间 + * @method + * @param {number} x + * @param {number} y + * @return {Array.} + */ + transformableProto.transformCoordToLocal = function (x, y) { + var v2 = [x, y]; + var invTransform = this.invTransform; + if (invTransform) { + vector.applyTransform(v2, v2, invTransform); + } + return v2; + }; + + /** + * 变换局部坐标位置到全局坐标空间 + * @method + * @param {number} x + * @param {number} y + * @return {Array.} + */ + transformableProto.transformCoordToGlobal = function (x, y) { + var v2 = [x, y]; + var transform = this.transform; + if (transform) { + vector.applyTransform(v2, v2, transform); + } + return v2; + }; + + module.exports = Transformable; + + + +/***/ }, +/* 34 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * @module zrender/mixin/Animatable + */ + + + var Animator = __webpack_require__(35); + var util = __webpack_require__(3); + var isString = util.isString; + var isFunction = util.isFunction; + var isObject = util.isObject; + var log = __webpack_require__(39); + + /** + * @alias modue:zrender/mixin/Animatable + * @constructor + */ + var Animatable = function () { + + /** + * @type {Array.} + * @readOnly + */ + this.animators = []; + }; + + Animatable.prototype = { + + constructor: Animatable, + + /** + * 动画 + * + * @param {string} path 需要添加动画的属性获取路径,可以通过a.b.c来获取深层的属性 + * @param {boolean} [loop] 动画是否循环 + * @return {module:zrender/animation/Animator} + * @example: + * el.animate('style', false) + * .when(1000, {x: 10} ) + * .done(function(){ // Animation done }) + * .start() + */ + animate: function (path, loop) { + var target; + var animatingShape = false; + var el = this; + var zr = this.__zr; + if (path) { + var pathSplitted = path.split('.'); + var prop = el; + // If animating shape + animatingShape = pathSplitted[0] === 'shape'; + for (var i = 0, l = pathSplitted.length; i < l; i++) { + if (!prop) { + continue; + } + prop = prop[pathSplitted[i]]; + } + if (prop) { + target = prop; + } + } + else { + target = el; + } + + if (!target) { + log( + 'Property "' + + path + + '" is not existed in element ' + + el.id + ); + return; + } + + var animators = el.animators; + + var animator = new Animator(target, loop); + + animator.during(function (target) { + el.dirty(animatingShape); + }) + .done(function () { + // FIXME Animator will not be removed if use `Animator#stop` to stop animation + animators.splice(util.indexOf(animators, animator), 1); + }); + + animators.push(animator); + + // If animate after added to the zrender + if (zr) { + zr.animation.addAnimator(animator); + } + + return animator; + }, + + /** + * 停止动画 + * @param {boolean} forwardToLast If move to last frame before stop + */ + stopAnimation: function (forwardToLast) { + var animators = this.animators; + var len = animators.length; + for (var i = 0; i < len; i++) { + animators[i].stop(forwardToLast); + } + animators.length = 0; + + return this; + }, + + /** + * @param {Object} target + * @param {number} [time=500] Time in ms + * @param {string} [easing='linear'] + * @param {number} [delay=0] + * @param {Function} [callback] + * + * @example + * // Animate position + * el.animateTo({ + * position: [10, 10] + * }, function () { // done }) + * + * // Animate shape, style and position in 100ms, delayed 100ms, with cubicOut easing + * el.animateTo({ + * shape: { + * width: 500 + * }, + * style: { + * fill: 'red' + * } + * position: [10, 10] + * }, 100, 100, 'cubicOut', function () { // done }) + */ + // TODO Return animation key + animateTo: function (target, time, delay, easing, callback) { + // animateTo(target, time, easing, callback); + if (isString(delay)) { + callback = easing; + easing = delay; + delay = 0; + } + // animateTo(target, time, delay, callback); + else if (isFunction(easing)) { + callback = easing; + easing = 'linear'; + delay = 0; + } + // animateTo(target, time, callback); + else if (isFunction(delay)) { + callback = delay; + delay = 0; + } + // animateTo(target, callback) + else if (isFunction(time)) { + callback = time; + time = 500; + } + // animateTo(target) + else if (!time) { + time = 500; + } + // Stop all previous animations + this.stopAnimation(); + this._animateToShallow('', this, target, time, delay, easing, callback); + + // Animators may be removed immediately after start + // if there is nothing to animate + var animators = this.animators.slice(); + var count = animators.length; + function done() { + count--; + if (!count) { + callback && callback(); + } + } + + // No animators. This should be checked before animators[i].start(), + // because 'done' may be executed immediately if no need to animate. + if (!count) { + callback && callback(); + } + // Start after all animators created + // Incase any animator is done immediately when all animation properties are not changed + for (var i = 0; i < animators.length; i++) { + animators[i] + .done(done) + .start(easing); + } + }, + + /** + * @private + * @param {string} path='' + * @param {Object} source=this + * @param {Object} target + * @param {number} [time=500] + * @param {number} [delay=0] + * + * @example + * // Animate position + * el._animateToShallow({ + * position: [10, 10] + * }) + * + * // Animate shape, style and position in 100ms, delayed 100ms + * el._animateToShallow({ + * shape: { + * width: 500 + * }, + * style: { + * fill: 'red' + * } + * position: [10, 10] + * }, 100, 100) + */ + _animateToShallow: function (path, source, target, time, delay) { + var objShallow = {}; + var propertyCount = 0; + for (var name in target) { + if (source[name] != null) { + if (isObject(target[name]) && !util.isArrayLike(target[name])) { + this._animateToShallow( + path ? path + '.' + name : name, + source[name], + target[name], + time, + delay + ); + } + else { + objShallow[name] = target[name]; + propertyCount++; + } + } + else if (target[name] != null) { + // Attr directly if not has property + // FIXME, if some property not needed for element ? + if (!path) { + this.attr(name, target[name]); + } + else { // Shape or style + var props = {}; + props[path] = {}; + props[path][name] = target[name]; + this.attr(props); + } + } + } + + if (propertyCount > 0) { + this.animate(path, false) + .when(time == null ? 500 : time, objShallow) + .delay(delay || 0); + } + + return this; + } + }; + + module.exports = Animatable; + + +/***/ }, +/* 35 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/animation/Animator + */ + + + var Clip = __webpack_require__(36); + var color = __webpack_require__(38); + var util = __webpack_require__(3); + var isArrayLike = util.isArrayLike; + + var arraySlice = Array.prototype.slice; + + function defaultGetter(target, key) { + return target[key]; + } + + function defaultSetter(target, key, value) { + target[key] = value; + } + + /** + * @param {number} p0 + * @param {number} p1 + * @param {number} percent + * @return {number} + */ + function interpolateNumber(p0, p1, percent) { + return (p1 - p0) * percent + p0; + } + + /** + * @param {string} p0 + * @param {string} p1 + * @param {number} percent + * @return {string} + */ + function interpolateString(p0, p1, percent) { + return percent > 0.5 ? p1 : p0; + } + + /** + * @param {Array} p0 + * @param {Array} p1 + * @param {number} percent + * @param {Array} out + * @param {number} arrDim + */ + function interpolateArray(p0, p1, percent, out, arrDim) { + var len = p0.length; + if (arrDim == 1) { + for (var i = 0; i < len; i++) { + out[i] = interpolateNumber(p0[i], p1[i], percent); + } + } + else { + var len2 = p0[0].length; + for (var i = 0; i < len; i++) { + for (var j = 0; j < len2; j++) { + out[i][j] = interpolateNumber( + p0[i][j], p1[i][j], percent + ); + } + } + } + } + + function fillArr(arr0, arr1, arrDim) { + var arr0Len = arr0.length; + var arr1Len = arr1.length; + if (arr0Len === arr1Len) { + return; + } + // FIXME Not work for TypedArray + var isPreviousLarger = arr0Len > arr1Len; + if (isPreviousLarger) { + // Cut the previous + arr0.length = arr1Len; + } + else { + // Fill the previous + for (var i = arr0Len; i < arr1Len; i++) { + arr0.push( + arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i]) + ); + } + } + } + + /** + * @param {Array} arr0 + * @param {Array} arr1 + * @param {number} arrDim + * @return {boolean} + */ + function isArraySame(arr0, arr1, arrDim) { + if (arr0 === arr1) { + return true; + } + var len = arr0.length; + if (len !== arr1.length) { + return false; + } + if (arrDim === 1) { + for (var i = 0; i < len; i++) { + if (arr0[i] !== arr1[i]) { + return false; + } + } + } + else { + var len2 = arr0[0].length; + for (var i = 0; i < len; i++) { + for (var j = 0; j < len2; j++) { + if (arr0[i][j] !== arr1[i][j]) { + return false; + } + } + } + } + return true; + } + + /** + * Catmull Rom interpolate array + * @param {Array} p0 + * @param {Array} p1 + * @param {Array} p2 + * @param {Array} p3 + * @param {number} t + * @param {number} t2 + * @param {number} t3 + * @param {Array} out + * @param {number} arrDim + */ + function catmullRomInterpolateArray( + p0, p1, p2, p3, t, t2, t3, out, arrDim + ) { + var len = p0.length; + if (arrDim == 1) { + for (var i = 0; i < len; i++) { + out[i] = catmullRomInterpolate( + p0[i], p1[i], p2[i], p3[i], t, t2, t3 + ); + } + } + else { + var len2 = p0[0].length; + for (var i = 0; i < len; i++) { + for (var j = 0; j < len2; j++) { + out[i][j] = catmullRomInterpolate( + p0[i][j], p1[i][j], p2[i][j], p3[i][j], + t, t2, t3 + ); + } + } + } + } + + /** + * Catmull Rom interpolate number + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @param {number} t2 + * @param {number} t3 + * @return {number} + */ + function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) { + var v0 = (p2 - p0) * 0.5; + var v1 = (p3 - p1) * 0.5; + return (2 * (p1 - p2) + v0 + v1) * t3 + + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + + v0 * t + p1; + } + + function cloneValue(value) { + if (isArrayLike(value)) { + var len = value.length; + if (isArrayLike(value[0])) { + var ret = []; + for (var i = 0; i < len; i++) { + ret.push(arraySlice.call(value[i])); + } + return ret; + } + + return arraySlice.call(value); + } + + return value; + } + + function rgba2String(rgba) { + rgba[0] = Math.floor(rgba[0]); + rgba[1] = Math.floor(rgba[1]); + rgba[2] = Math.floor(rgba[2]); + + return 'rgba(' + rgba.join(',') + ')'; + } + + function createTrackClip (animator, easing, oneTrackDone, keyframes, propName) { + var getter = animator._getter; + var setter = animator._setter; + var useSpline = easing === 'spline'; + + var trackLen = keyframes.length; + if (!trackLen) { + return; + } + // Guess data type + var firstVal = keyframes[0].value; + var isValueArray = isArrayLike(firstVal); + var isValueColor = false; + var isValueString = false; + + // For vertices morphing + var arrDim = ( + isValueArray + && isArrayLike(firstVal[0]) + ) + ? 2 : 1; + var trackMaxTime; + // Sort keyframe as ascending + keyframes.sort(function(a, b) { + return a.time - b.time; + }); + + trackMaxTime = keyframes[trackLen - 1].time; + // Percents of each keyframe + var kfPercents = []; + // Value of each keyframe + var kfValues = []; + var prevValue = keyframes[0].value; + var isAllValueEqual = true; + for (var i = 0; i < trackLen; i++) { + kfPercents.push(keyframes[i].time / trackMaxTime); + // Assume value is a color when it is a string + var value = keyframes[i].value; + + // Check if value is equal, deep check if value is array + if (!((isValueArray && isArraySame(value, prevValue, arrDim)) + || (!isValueArray && value === prevValue))) { + isAllValueEqual = false; + } + prevValue = value; + + // Try converting a string to a color array + if (typeof value == 'string') { + var colorArray = color.parse(value); + if (colorArray) { + value = colorArray; + isValueColor = true; + } + else { + isValueString = true; + } + } + kfValues.push(value); + } + if (isAllValueEqual) { + return; + } + + if (isValueArray) { + var lastValue = kfValues[trackLen - 1]; + // Polyfill array + for (var i = 0; i < trackLen - 1; i++) { + fillArr(kfValues[i], lastValue, arrDim); + } + fillArr(getter(animator._target, propName), lastValue, arrDim); + } + + // Cache the key of last frame to speed up when + // animation playback is sequency + var lastFrame = 0; + var lastFramePercent = 0; + var start; + var w; + var p0; + var p1; + var p2; + var p3; + + if (isValueColor) { + var rgba = [0, 0, 0, 0]; + } + + var onframe = function (target, percent) { + // Find the range keyframes + // kf1-----kf2---------current--------kf3 + // find kf2 and kf3 and do interpolation + var frame; + if (percent < lastFramePercent) { + // Start from next key + start = Math.min(lastFrame + 1, trackLen - 1); + for (frame = start; frame >= 0; frame--) { + if (kfPercents[frame] <= percent) { + break; + } + } + frame = Math.min(frame, trackLen - 2); + } + else { + for (frame = lastFrame; frame < trackLen; frame++) { + if (kfPercents[frame] > percent) { + break; + } + } + frame = Math.min(frame - 1, trackLen - 2); + } + lastFrame = frame; + lastFramePercent = percent; + + var range = (kfPercents[frame + 1] - kfPercents[frame]); + if (range === 0) { + return; + } + else { + w = (percent - kfPercents[frame]) / range; + } + if (useSpline) { + p1 = kfValues[frame]; + p0 = kfValues[frame === 0 ? frame : frame - 1]; + p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1]; + p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2]; + if (isValueArray) { + catmullRomInterpolateArray( + p0, p1, p2, p3, w, w * w, w * w * w, + getter(target, propName), + arrDim + ); + } + else { + var value; + if (isValueColor) { + value = catmullRomInterpolateArray( + p0, p1, p2, p3, w, w * w, w * w * w, + rgba, 1 + ); + value = rgba2String(rgba); + } + else if (isValueString) { + // String is step(0.5) + return interpolateString(p1, p2, w); + } + else { + value = catmullRomInterpolate( + p0, p1, p2, p3, w, w * w, w * w * w + ); + } + setter( + target, + propName, + value + ); + } + } + else { + if (isValueArray) { + interpolateArray( + kfValues[frame], kfValues[frame + 1], w, + getter(target, propName), + arrDim + ); + } + else { + var value; + if (isValueColor) { + interpolateArray( + kfValues[frame], kfValues[frame + 1], w, + rgba, 1 + ); + value = rgba2String(rgba); + } + else if (isValueString) { + // String is step(0.5) + return interpolateString(kfValues[frame], kfValues[frame + 1], w); + } + else { + value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w); + } + setter( + target, + propName, + value + ); + } + } + }; + + var clip = new Clip({ + target: animator._target, + life: trackMaxTime, + loop: animator._loop, + delay: animator._delay, + onframe: onframe, + ondestroy: oneTrackDone + }); + + if (easing && easing !== 'spline') { + clip.easing = easing; + } + + return clip; + } + + /** + * @alias module:zrender/animation/Animator + * @constructor + * @param {Object} target + * @param {boolean} loop + * @param {Function} getter + * @param {Function} setter + */ + var Animator = function(target, loop, getter, setter) { + this._tracks = {}; + this._target = target; + + this._loop = loop || false; + + this._getter = getter || defaultGetter; + this._setter = setter || defaultSetter; + + this._clipCount = 0; + + this._delay = 0; + + this._doneList = []; + + this._onframeList = []; + + this._clipList = []; + }; + + Animator.prototype = { + /** + * 设置动画关键帧 + * @param {number} time 关键帧时间,单位是ms + * @param {Object} props 关键帧的属性值,key-value表示 + * @return {module:zrender/animation/Animator} + */ + when: function(time /* ms */, props) { + var tracks = this._tracks; + for (var propName in props) { + if (!tracks[propName]) { + tracks[propName] = []; + // Invalid value + var value = this._getter(this._target, propName); + if (value == null) { + // zrLog('Invalid property ' + propName); + continue; + } + // If time is 0 + // Then props is given initialize value + // Else + // Initialize value from current prop value + if (time !== 0) { + tracks[propName].push({ + time: 0, + value: cloneValue(value) + }); + } + } + tracks[propName].push({ + time: time, + value: props[propName] + }); + } + return this; + }, + /** + * 添加动画每一帧的回调函数 + * @param {Function} callback + * @return {module:zrender/animation/Animator} + */ + during: function (callback) { + this._onframeList.push(callback); + return this; + }, + + _doneCallback: function () { + // Clear all tracks + this._tracks = {}; + // Clear all clips + this._clipList.length = 0; + + var doneList = this._doneList; + var len = doneList.length; + for (var i = 0; i < len; i++) { + doneList[i].call(this); + } + }, + /** + * 开始执行动画 + * @param {string|Function} easing + * 动画缓动函数,详见{@link module:zrender/animation/easing} + * @return {module:zrender/animation/Animator} + */ + start: function (easing) { + + var self = this; + var clipCount = 0; + + var oneTrackDone = function() { + clipCount--; + if (!clipCount) { + self._doneCallback(); + } + }; + + var lastClip; + for (var propName in this._tracks) { + var clip = createTrackClip( + this, easing, oneTrackDone, + this._tracks[propName], propName + ); + if (clip) { + this._clipList.push(clip); + clipCount++; + + // If start after added to animation + if (this.animation) { + this.animation.addClip(clip); + } + + lastClip = clip; + } + } + + // Add during callback on the last clip + if (lastClip) { + var oldOnFrame = lastClip.onframe; + lastClip.onframe = function (target, percent) { + oldOnFrame(target, percent); + + for (var i = 0; i < self._onframeList.length; i++) { + self._onframeList[i](target, percent); + } + }; + } + + if (!clipCount) { + this._doneCallback(); + } + return this; + }, + /** + * 停止动画 + * @param {boolean} forwardToLast If move to last frame before stop + */ + stop: function (forwardToLast) { + var clipList = this._clipList; + var animation = this.animation; + for (var i = 0; i < clipList.length; i++) { + var clip = clipList[i]; + if (forwardToLast) { + // Move to last frame before stop + clip.onframe(this._target, 1); + } + animation && animation.removeClip(clip); + } + clipList.length = 0; + }, + /** + * 设置动画延迟开始的时间 + * @param {number} time 单位ms + * @return {module:zrender/animation/Animator} + */ + delay: function (time) { + this._delay = time; + return this; + }, + /** + * 添加动画结束的回调 + * @param {Function} cb + * @return {module:zrender/animation/Animator} + */ + done: function(cb) { + if (cb) { + this._doneList.push(cb); + } + return this; + }, + + /** + * @return {Array.} + */ + getClips: function () { + return this._clipList; + } + }; + + module.exports = Animator; + + +/***/ }, +/* 36 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 动画主控制器 + * @config target 动画对象,可以是数组,如果是数组的话会批量分发onframe等事件 + * @config life(1000) 动画时长 + * @config delay(0) 动画延迟时间 + * @config loop(true) + * @config gap(0) 循环的间隔时间 + * @config onframe + * @config easing(optional) + * @config ondestroy(optional) + * @config onrestart(optional) + * + * TODO pause + */ + + + var easingFuncs = __webpack_require__(37); + + function Clip(options) { + + this._target = options.target; + + // 生命周期 + this._life = options.life || 1000; + // 延时 + this._delay = options.delay || 0; + // 开始时间 + // this._startTime = new Date().getTime() + this._delay;// 单位毫秒 + this._initialized = false; + + // 是否循环 + this.loop = options.loop == null ? false : options.loop; + + this.gap = options.gap || 0; + + this.easing = options.easing || 'Linear'; + + this.onframe = options.onframe; + this.ondestroy = options.ondestroy; + this.onrestart = options.onrestart; + } + + Clip.prototype = { + + constructor: Clip, + + step: function (time) { + // Set startTime on first step, or _startTime may has milleseconds different between clips + // PENDING + if (!this._initialized) { + this._startTime = new Date().getTime() + this._delay; + this._initialized = true; + } + + var percent = (time - this._startTime) / this._life; + + // 还没开始 + if (percent < 0) { + return; + } + + percent = Math.min(percent, 1); + + var easing = this.easing; + var easingFunc = typeof easing == 'string' ? easingFuncs[easing] : easing; + var schedule = typeof easingFunc === 'function' + ? easingFunc(percent) + : percent; + + this.fire('frame', schedule); + + // 结束 + if (percent == 1) { + if (this.loop) { + this.restart(); + // 重新开始周期 + // 抛出而不是直接调用事件直到 stage.update 后再统一调用这些事件 + return 'restart'; + } + + // 动画完成将这个控制器标识为待删除 + // 在Animation.update中进行批量删除 + this._needsRemove = true; + return 'destroy'; + } + + return null; + }, + + restart: function() { + var time = new Date().getTime(); + var remainder = (time - this._startTime) % this._life; + this._startTime = new Date().getTime() - remainder + this.gap; + + this._needsRemove = false; + }, + + fire: function(eventType, arg) { + eventType = 'on' + eventType; + if (this[eventType]) { + this[eventType](this._target, arg); + } + } + }; + + module.exports = Clip; + + + +/***/ }, +/* 37 */ +/***/ function(module, exports) { + + /** + * 缓动代码来自 https://github.com/sole/tween.js/blob/master/src/Tween.js + * @see http://sole.github.io/tween.js/examples/03_graphs.html + * @exports zrender/animation/easing + */ + + var easing = { + /** + * @param {number} k + * @return {number} + */ + linear: function (k) { + return k; + }, + + /** + * @param {number} k + * @return {number} + */ + quadraticIn: function (k) { + return k * k; + }, + /** + * @param {number} k + * @return {number} + */ + quadraticOut: function (k) { + return k * (2 - k); + }, + /** + * @param {number} k + * @return {number} + */ + quadraticInOut: function (k) { + if ((k *= 2) < 1) { + return 0.5 * k * k; + } + return -0.5 * (--k * (k - 2) - 1); + }, + + // 三次方的缓动(t^3) + /** + * @param {number} k + * @return {number} + */ + cubicIn: function (k) { + return k * k * k; + }, + /** + * @param {number} k + * @return {number} + */ + cubicOut: function (k) { + return --k * k * k + 1; + }, + /** + * @param {number} k + * @return {number} + */ + cubicInOut: function (k) { + if ((k *= 2) < 1) { + return 0.5 * k * k * k; + } + return 0.5 * ((k -= 2) * k * k + 2); + }, + + // 四次方的缓动(t^4) + /** + * @param {number} k + * @return {number} + */ + quarticIn: function (k) { + return k * k * k * k; + }, + /** + * @param {number} k + * @return {number} + */ + quarticOut: function (k) { + return 1 - (--k * k * k * k); + }, + /** + * @param {number} k + * @return {number} + */ + quarticInOut: function (k) { + if ((k *= 2) < 1) { + return 0.5 * k * k * k * k; + } + return -0.5 * ((k -= 2) * k * k * k - 2); + }, + + // 五次方的缓动(t^5) + /** + * @param {number} k + * @return {number} + */ + quinticIn: function (k) { + return k * k * k * k * k; + }, + /** + * @param {number} k + * @return {number} + */ + quinticOut: function (k) { + return --k * k * k * k * k + 1; + }, + /** + * @param {number} k + * @return {number} + */ + quinticInOut: function (k) { + if ((k *= 2) < 1) { + return 0.5 * k * k * k * k * k; + } + return 0.5 * ((k -= 2) * k * k * k * k + 2); + }, + + // 正弦曲线的缓动(sin(t)) + /** + * @param {number} k + * @return {number} + */ + sinusoidalIn: function (k) { + return 1 - Math.cos(k * Math.PI / 2); + }, + /** + * @param {number} k + * @return {number} + */ + sinusoidalOut: function (k) { + return Math.sin(k * Math.PI / 2); + }, + /** + * @param {number} k + * @return {number} + */ + sinusoidalInOut: function (k) { + return 0.5 * (1 - Math.cos(Math.PI * k)); + }, + + // 指数曲线的缓动(2^t) + /** + * @param {number} k + * @return {number} + */ + exponentialIn: function (k) { + return k === 0 ? 0 : Math.pow(1024, k - 1); + }, + /** + * @param {number} k + * @return {number} + */ + exponentialOut: function (k) { + return k === 1 ? 1 : 1 - Math.pow(2, -10 * k); + }, + /** + * @param {number} k + * @return {number} + */ + exponentialInOut: function (k) { + if (k === 0) { + return 0; + } + if (k === 1) { + return 1; + } + if ((k *= 2) < 1) { + return 0.5 * Math.pow(1024, k - 1); + } + return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2); + }, + + // 圆形曲线的缓动(sqrt(1-t^2)) + /** + * @param {number} k + * @return {number} + */ + circularIn: function (k) { + return 1 - Math.sqrt(1 - k * k); + }, + /** + * @param {number} k + * @return {number} + */ + circularOut: function (k) { + return Math.sqrt(1 - (--k * k)); + }, + /** + * @param {number} k + * @return {number} + */ + circularInOut: function (k) { + if ((k *= 2) < 1) { + return -0.5 * (Math.sqrt(1 - k * k) - 1); + } + return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); + }, + + // 创建类似于弹簧在停止前来回振荡的动画 + /** + * @param {number} k + * @return {number} + */ + elasticIn: function (k) { + var s; + var a = 0.1; + var p = 0.4; + if (k === 0) { + return 0; + } + if (k === 1) { + return 1; + } + if (!a || a < 1) { + a = 1; s = p / 4; + } + else { + s = p * Math.asin(1 / a) / (2 * Math.PI); + } + return -(a * Math.pow(2, 10 * (k -= 1)) * + Math.sin((k - s) * (2 * Math.PI) / p)); + }, + /** + * @param {number} k + * @return {number} + */ + elasticOut: function (k) { + var s; + var a = 0.1; + var p = 0.4; + if (k === 0) { + return 0; + } + if (k === 1) { + return 1; + } + if (!a || a < 1) { + a = 1; s = p / 4; + } + else { + s = p * Math.asin(1 / a) / (2 * Math.PI); + } + return (a * Math.pow(2, -10 * k) * + Math.sin((k - s) * (2 * Math.PI) / p) + 1); + }, + /** + * @param {number} k + * @return {number} + */ + elasticInOut: function (k) { + var s; + var a = 0.1; + var p = 0.4; + if (k === 0) { + return 0; + } + if (k === 1) { + return 1; + } + if (!a || a < 1) { + a = 1; s = p / 4; + } + else { + s = p * Math.asin(1 / a) / (2 * Math.PI); + } + if ((k *= 2) < 1) { + return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) + * Math.sin((k - s) * (2 * Math.PI) / p)); + } + return a * Math.pow(2, -10 * (k -= 1)) + * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1; + + }, + + // 在某一动画开始沿指示的路径进行动画处理前稍稍收回该动画的移动 + /** + * @param {number} k + * @return {number} + */ + backIn: function (k) { + var s = 1.70158; + return k * k * ((s + 1) * k - s); + }, + /** + * @param {number} k + * @return {number} + */ + backOut: function (k) { + var s = 1.70158; + return --k * k * ((s + 1) * k + s) + 1; + }, + /** + * @param {number} k + * @return {number} + */ + backInOut: function (k) { + var s = 1.70158 * 1.525; + if ((k *= 2) < 1) { + return 0.5 * (k * k * ((s + 1) * k - s)); + } + return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); + }, + + // 创建弹跳效果 + /** + * @param {number} k + * @return {number} + */ + bounceIn: function (k) { + return 1 - easing.bounceOut(1 - k); + }, + /** + * @param {number} k + * @return {number} + */ + bounceOut: function (k) { + if (k < (1 / 2.75)) { + return 7.5625 * k * k; + } + else if (k < (2 / 2.75)) { + return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75; + } + else if (k < (2.5 / 2.75)) { + return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375; + } + else { + return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; + } + }, + /** + * @param {number} k + * @return {number} + */ + bounceInOut: function (k) { + if (k < 0.5) { + return easing.bounceIn(k * 2) * 0.5; + } + return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5; + } + }; + + module.exports = easing; + + + + +/***/ }, +/* 38 */ +/***/ function(module, exports) { + + /** + * @module zrender/tool/color + */ + + + var kCSSColorTable = { + 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1], + 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1], + 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1], + 'beige': [245,245,220,1], 'bisque': [255,228,196,1], + 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1], + 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1], + 'brown': [165,42,42,1], 'burlywood': [222,184,135,1], + 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1], + 'chocolate': [210,105,30,1], 'coral': [255,127,80,1], + 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1], + 'crimson': [220,20,60,1], 'cyan': [0,255,255,1], + 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1], + 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1], + 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1], + 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1], + 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1], + 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1], + 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1], + 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1], + 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1], + 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1], + 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1], + 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1], + 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1], + 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1], + 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1], + 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1], + 'gray': [128,128,128,1], 'green': [0,128,0,1], + 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1], + 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1], + 'indianred': [205,92,92,1], 'indigo': [75,0,130,1], + 'ivory': [255,255,240,1], 'khaki': [240,230,140,1], + 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1], + 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1], + 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1], + 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1], + 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1], + 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1], + 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1], + 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1], + 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1], + 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1], + 'limegreen': [50,205,50,1], 'linen': [250,240,230,1], + 'magenta': [255,0,255,1], 'maroon': [128,0,0,1], + 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1], + 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1], + 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1], + 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1], + 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1], + 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1], + 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1], + 'navy': [0,0,128,1], 'oldlace': [253,245,230,1], + 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1], + 'orange': [255,165,0,1], 'orangered': [255,69,0,1], + 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1], + 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1], + 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1], + 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1], + 'pink': [255,192,203,1], 'plum': [221,160,221,1], + 'powderblue': [176,224,230,1], 'purple': [128,0,128,1], + 'red': [255,0,0,1], 'rosybrown': [188,143,143,1], + 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1], + 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1], + 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1], + 'sienna': [160,82,45,1], 'silver': [192,192,192,1], + 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1], + 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1], + 'snow': [255,250,250,1], 'springgreen': [0,255,127,1], + 'steelblue': [70,130,180,1], 'tan': [210,180,140,1], + 'teal': [0,128,128,1], 'thistle': [216,191,216,1], + 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1], + 'violet': [238,130,238,1], 'wheat': [245,222,179,1], + 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1], + 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1] + }; + + function clampCssByte(i) { // Clamp to integer 0 .. 255. + i = Math.round(i); // Seems to be what Chrome does (vs truncation). + return i < 0 ? 0 : i > 255 ? 255 : i; + } + + function clampCssAngle(i) { // Clamp to integer 0 .. 360. + i = Math.round(i); // Seems to be what Chrome does (vs truncation). + return i < 0 ? 0 : i > 360 ? 360 : i; + } + + function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0. + return f < 0 ? 0 : f > 1 ? 1 : f; + } + + function parseCssInt(str) { // int or percentage. + if (str.length && str.charAt(str.length - 1) === '%') { + return clampCssByte(parseFloat(str) / 100 * 255); + } + return clampCssByte(parseInt(str, 10)); + } + + function parseCssFloat(str) { // float or percentage. + if (str.length && str.charAt(str.length - 1) === '%') { + return clampCssFloat(parseFloat(str) / 100); + } + return clampCssFloat(parseFloat(str)); + } + + function cssHueToRgb(m1, m2, h) { + if (h < 0) { + h += 1; + } + else if (h > 1) { + h -= 1; + } + + if (h * 6 < 1) { + return m1 + (m2 - m1) * h * 6; + } + if (h * 2 < 1) { + return m2; + } + if (h * 3 < 2) { + return m1 + (m2 - m1) * (2/3 - h) * 6; + } + return m1; + } + + function lerp(a, b, p) { + return a + (b - a) * p; + } + + /** + * @param {string} colorStr + * @return {Array.} + * @memberOf module:zrender/util/color + */ + function parse(colorStr) { + if (!colorStr) { + return; + } + // colorStr may be not string + colorStr = colorStr + ''; + // Remove all whitespace, not compliant, but should just be more accepting. + var str = colorStr.replace(/ /g, '').toLowerCase(); + + // Color keywords (and transparent) lookup. + if (str in kCSSColorTable) { + return kCSSColorTable[str].slice(); // dup. + } + + // #abc and #abc123 syntax. + if (str.charAt(0) === '#') { + if (str.length === 4) { + var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. + if (!(iv >= 0 && iv <= 0xfff)) { + return; // Covers NaN. + } + return [ + ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8), + (iv & 0xf0) | ((iv & 0xf0) >> 4), + (iv & 0xf) | ((iv & 0xf) << 4), + 1 + ]; + } + else if (str.length === 7) { + var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. + if (!(iv >= 0 && iv <= 0xffffff)) { + return; // Covers NaN. + } + return [ + (iv & 0xff0000) >> 16, + (iv & 0xff00) >> 8, + iv & 0xff, + 1 + ]; + } + + return; + } + var op = str.indexOf('('), ep = str.indexOf(')'); + if (op !== -1 && ep + 1 === str.length) { + var fname = str.substr(0, op); + var params = str.substr(op + 1, ep - (op + 1)).split(','); + var alpha = 1; // To allow case fallthrough. + switch (fname) { + case 'rgba': + if (params.length !== 4) { + return; + } + alpha = parseCssFloat(params.pop()); // jshint ignore:line + // Fall through. + case 'rgb': + if (params.length !== 3) { + return; + } + return [ + parseCssInt(params[0]), + parseCssInt(params[1]), + parseCssInt(params[2]), + alpha + ]; + case 'hsla': + if (params.length !== 4) { + return; + } + params[3] = parseCssFloat(params[3]); + return hsla2rgba(params); + case 'hsl': + if (params.length !== 3) { + return; + } + return hsla2rgba(params); + default: + return; + } + } + + return; + } + + /** + * @param {Array.} hsla + * @return {Array.} rgba + */ + function hsla2rgba(hsla) { + var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1 + // NOTE(deanm): According to the CSS spec s/l should only be + // percentages, but we don't bother and let float or percentage. + var s = parseCssFloat(hsla[1]); + var l = parseCssFloat(hsla[2]); + var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; + var m1 = l * 2 - m2; + + var rgba = [ + clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255), + clampCssByte(cssHueToRgb(m1, m2, h) * 255), + clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255) + ]; + + if (hsla.length === 4) { + rgba[3] = hsla[3]; + } + + return rgba; + } + + /** + * @param {Array.} rgba + * @return {Array.} hsla + */ + function rgba2hsla(rgba) { + if (!rgba) { + return; + } + + // RGB from 0 to 255 + var R = rgba[0] / 255; + var G = rgba[1] / 255; + var B = rgba[2] / 255; + + var vMin = Math.min(R, G, B); // Min. value of RGB + var vMax = Math.max(R, G, B); // Max. value of RGB + var delta = vMax - vMin; // Delta RGB value + + var L = (vMax + vMin) / 2; + var H; + var S; + // HSL results from 0 to 1 + if (delta === 0) { + H = 0; + S = 0; + } + else { + if (L < 0.5) { + S = delta / (vMax + vMin); + } + else { + S = delta / (2 - vMax - vMin); + } + + var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta; + var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta; + var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta; + + if (R === vMax) { + H = deltaB - deltaG; + } + else if (G === vMax) { + H = (1 / 3) + deltaR - deltaB; + } + else if (B === vMax) { + H = (2 / 3) + deltaG - deltaR; + } + + if (H < 0) { + H += 1; + } + + if (H > 1) { + H -= 1; + } + } + + var hsla = [H * 360, S, L]; + + if (rgba[3] != null) { + hsla.push(rgba[3]); + } + + return hsla; + } + + /** + * @param {string} color + * @param {number} level + * @return {string} + * @memberOf module:zrender/util/color + */ + function lift(color, level) { + var colorArr = parse(color); + if (colorArr) { + for (var i = 0; i < 3; i++) { + if (level < 0) { + colorArr[i] = colorArr[i] * (1 - level) | 0; + } + else { + colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0; + } + } + return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb'); + } + } + + /** + * @param {string} color + * @return {string} + * @memberOf module:zrender/util/color + */ + function toHex(color, level) { + var colorArr = parse(color); + if (colorArr) { + return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1); + } + } + + /** + * Map value to color. Faster than mapToColor methods because color is represented by rgba array + * @param {number} normalizedValue A float between 0 and 1. + * @param {Array.>} colors List of rgba color array + * @param {Array.} [out] Mapped gba color array + * @return {Array.} + */ + function fastMapToColor(normalizedValue, colors, out) { + if (!(colors && colors.length) + || !(normalizedValue >= 0 && normalizedValue <= 1) + ) { + return; + } + out = out || [0, 0, 0, 0]; + var value = normalizedValue * (colors.length - 1); + var leftIndex = Math.floor(value); + var rightIndex = Math.ceil(value); + var leftColor = colors[leftIndex]; + var rightColor = colors[rightIndex]; + var dv = value - leftIndex; + out[0] = clampCssByte(lerp(leftColor[0], rightColor[0], dv)); + out[1] = clampCssByte(lerp(leftColor[1], rightColor[1], dv)); + out[2] = clampCssByte(lerp(leftColor[2], rightColor[2], dv)); + out[3] = clampCssByte(lerp(leftColor[3], rightColor[3], dv)); + return out; + } + /** + * @param {number} normalizedValue A float between 0 and 1. + * @param {Array.} colors Color list. + * @param {boolean=} fullOutput Default false. + * @return {(string|Object)} Result color. If fullOutput, + * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...}, + * @memberOf module:zrender/util/color + */ + function mapToColor(normalizedValue, colors, fullOutput) { + if (!(colors && colors.length) + || !(normalizedValue >= 0 && normalizedValue <= 1) + ) { + return; + } + + var value = normalizedValue * (colors.length - 1); + var leftIndex = Math.floor(value); + var rightIndex = Math.ceil(value); + var leftColor = parse(colors[leftIndex]); + var rightColor = parse(colors[rightIndex]); + var dv = value - leftIndex; + + var color = stringify( + [ + clampCssByte(lerp(leftColor[0], rightColor[0], dv)), + clampCssByte(lerp(leftColor[1], rightColor[1], dv)), + clampCssByte(lerp(leftColor[2], rightColor[2], dv)), + clampCssFloat(lerp(leftColor[3], rightColor[3], dv)) + ], + 'rgba' + ); + + return fullOutput + ? { + color: color, + leftIndex: leftIndex, + rightIndex: rightIndex, + value: value + } + : color; + } + + /** + * @param {Array} interval Array length === 2, + * each item is normalized value ([0, 1]). + * @param {Array.} colors Color list. + * @return {Array.} colors corresponding to the interval, + * each item is {color: 'xxx', offset: ...} + * where offset is between 0 and 1. + * @memberOf module:zrender/util/color + */ + function mapIntervalToColor(interval, colors) { + if (interval.length !== 2 || interval[1] < interval[0]) { + return; + } + + var info0 = mapToColor(interval[0], colors, true); + var info1 = mapToColor(interval[1], colors, true); + + var result = [{color: info0.color, offset: 0}]; + + var during = info1.value - info0.value; + var start = Math.max(info0.value, info0.rightIndex); + var end = Math.min(info1.value, info1.leftIndex); + + for (var i = start; during > 0 && i <= end; i++) { + result.push({ + color: colors[i], + offset: (i - info0.value) / during + }); + } + result.push({color: info1.color, offset: 1}); + + return result; + } + + /** + * @param {string} color + * @param {number=} h 0 ~ 360, ignore when null. + * @param {number=} s 0 ~ 1, ignore when null. + * @param {number=} l 0 ~ 1, ignore when null. + * @return {string} Color string in rgba format. + * @memberOf module:zrender/util/color + */ + function modifyHSL(color, h, s, l) { + color = parse(color); + + if (color) { + color = rgba2hsla(color); + h != null && (color[0] = clampCssAngle(h)); + s != null && (color[1] = parseCssFloat(s)); + l != null && (color[2] = parseCssFloat(l)); + + return stringify(hsla2rgba(color), 'rgba'); + } + } + + /** + * @param {string} color + * @param {number=} alpha 0 ~ 1 + * @return {string} Color string in rgba format. + * @memberOf module:zrender/util/color + */ + function modifyAlpha(color, alpha) { + color = parse(color); + + if (color && alpha != null) { + color[3] = clampCssFloat(alpha); + return stringify(color, 'rgba'); + } + } + + /** + * @param {Array.} colors Color list. + * @param {string} type 'rgba', 'hsva', ... + * @return {string} Result color. + */ + function stringify(arrColor, type) { + if (type === 'rgb' || type === 'hsv' || type === 'hsl') { + arrColor = arrColor.slice(0, 3); + } + return type + '(' + arrColor.join(',') + ')'; + } + + module.exports = { + parse: parse, + lift: lift, + toHex: toHex, + fastMapToColor: fastMapToColor, + mapToColor: mapToColor, + mapIntervalToColor: mapIntervalToColor, + modifyHSL: modifyHSL, + modifyAlpha: modifyAlpha, + stringify: stringify + }; + + + + +/***/ }, +/* 39 */ +/***/ function(module, exports, __webpack_require__) { + + + var config = __webpack_require__(40); + + /** + * @exports zrender/tool/log + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + */ + module.exports = function() { + if (config.debugMode === 0) { + return; + } + else if (config.debugMode == 1) { + for (var k in arguments) { + throw new Error(arguments[k]); + } + } + else if (config.debugMode > 1) { + for (var k in arguments) { + console.log(arguments[k]); + } + } + }; + + /* for debug + return function(mes) { + document.getElementById('wrong-message').innerHTML = + mes + ' ' + (new Date() - 0) + + '
' + + document.getElementById('wrong-message').innerHTML; + }; + */ + + + +/***/ }, +/* 40 */ +/***/ function(module, exports) { + + + var dpr = 1; + // If in browser environment + if (typeof window !== 'undefined') { + dpr = Math.max(window.devicePixelRatio || 1, 1); + } + /** + * config默认配置项 + * @exports zrender/config + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + */ + var config = { + /** + * debug日志选项:catchBrushException为true下有效 + * 0 : 不生成debug数据,发布用 + * 1 : 异常抛出,调试用 + * 2 : 控制台输出,调试用 + */ + debugMode: 0, + + // retina 屏幕优化 + devicePixelRatio: dpr + }; + module.exports = config; + + + + +/***/ }, +/* 41 */ +/***/ function(module, exports, __webpack_require__) { + + + + var Group = __webpack_require__(29); + var componentUtil = __webpack_require__(20); + var clazzUtil = __webpack_require__(9); + + function Chart() { + + /** + * @type {module:zrender/container/Group} + * @readOnly + */ + this.group = new Group(); + + /** + * @type {string} + * @readOnly + */ + this.uid = componentUtil.getUID('viewChart'); + } + + Chart.prototype = { + + type: 'chart', + + /** + * Init the chart + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + */ + init: function (ecModel, api) {}, + + /** + * Render the chart + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + * @param {Object} payload + */ + render: function (seriesModel, ecModel, api, payload) {}, + + /** + * Highlight series or specified data item + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + * @param {Object} payload + */ + highlight: function (seriesModel, ecModel, api, payload) { + toggleHighlight(seriesModel.getData(), payload, 'emphasis'); + }, + + /** + * Downplay series or specified data item + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + * @param {Object} payload + */ + downplay: function (seriesModel, ecModel, api, payload) { + toggleHighlight(seriesModel.getData(), payload, 'normal'); + }, + + /** + * Remove self + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + */ + remove: function (ecModel, api) { + this.group.removeAll(); + }, + + /** + * Dispose self + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + */ + dispose: function () {} + }; + + var chartProto = Chart.prototype; + chartProto.updateView + = chartProto.updateLayout + = chartProto.updateVisual + = function (seriesModel, ecModel, api, payload) { + this.render(seriesModel, ecModel, api, payload); + }; + + /** + * Set state of single element + * @param {module:zrender/Element} el + * @param {string} state + */ + function elSetState(el, state) { + if (el) { + el.trigger(state); + if (el.type === 'group') { + for (var i = 0; i < el.childCount(); i++) { + elSetState(el.childAt(i), state); + } + } + } + } + /** + * @param {module:echarts/data/List} data + * @param {Object} payload + * @param {string} state 'normal'|'emphasis' + * @inner + */ + function toggleHighlight(data, payload, state) { + if (payload.dataIndex != null) { + var el = data.getItemGraphicEl(payload.dataIndex); + elSetState(el, state); + } + else if (payload.name) { + var dataIndex = data.indexOfName(payload.name); + var el = data.getItemGraphicEl(dataIndex); + elSetState(el, state); + } + else { + data.eachItemGraphicEl(function (el) { + elSetState(el, state); + }); + } + } + + // Enable Chart.extend. + clazzUtil.enableClassExtend(Chart); + + // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. + clazzUtil.enableClassManagement(Chart, {registerWhenExtend: true}); + + module.exports = Chart; + + +/***/ }, +/* 42 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + + var pathTool = __webpack_require__(43); + var round = Math.round; + var Path = __webpack_require__(44); + var colorTool = __webpack_require__(38); + var matrix = __webpack_require__(17); + var vector = __webpack_require__(16); + var Gradient = __webpack_require__(4); + + var graphic = {}; + + graphic.Group = __webpack_require__(29); + + graphic.Image = __webpack_require__(59); + + graphic.Text = __webpack_require__(62); + + graphic.Circle = __webpack_require__(63); + + graphic.Sector = __webpack_require__(64); + + graphic.Ring = __webpack_require__(65); + + graphic.Polygon = __webpack_require__(66); + + graphic.Polyline = __webpack_require__(70); + + graphic.Rect = __webpack_require__(71); + + graphic.Line = __webpack_require__(72); + + graphic.BezierCurve = __webpack_require__(73); + + graphic.Arc = __webpack_require__(74); + + graphic.LinearGradient = __webpack_require__(75); + + graphic.RadialGradient = __webpack_require__(76); + + graphic.BoundingRect = __webpack_require__(15); + + /** + * Extend shape with parameters + */ + graphic.extendShape = function (opts) { + return Path.extend(opts); + }; + + /** + * Extend path + */ + graphic.extendPath = function (pathData, opts) { + return pathTool.extendFromString(pathData, opts); + }; + + /** + * Create a path element from path data string + * @param {string} pathData + * @param {Object} opts + * @param {module:zrender/core/BoundingRect} rect + * @param {string} [layout=cover] 'center' or 'cover' + */ + graphic.makePath = function (pathData, opts, rect, layout) { + var path = pathTool.createFromString(pathData, opts); + var boundingRect = path.getBoundingRect(); + if (rect) { + var aspect = boundingRect.width / boundingRect.height; + + if (layout === 'center') { + // Set rect to center, keep width / height ratio. + var width = rect.height * aspect; + var height; + if (width <= rect.width) { + height = rect.height; + } + else { + width = rect.width; + height = width / aspect; + } + var cx = rect.x + rect.width / 2; + var cy = rect.y + rect.height / 2; + + rect.x = cx - width / 2; + rect.y = cy - height / 2; + rect.width = width; + rect.height = height; + } + + this.resizePath(path, rect); + } + return path; + }; + + graphic.mergePath = pathTool.mergePath, + + /** + * Resize a path to fit the rect + * @param {module:zrender/graphic/Path} path + * @param {Object} rect + */ + graphic.resizePath = function (path, rect) { + if (!path.applyTransform) { + return; + } + + var pathRect = path.getBoundingRect(); + + var m = pathRect.calculateTransform(rect); + + path.applyTransform(m); + }; + + /** + * Sub pixel optimize line for canvas + * + * @param {Object} param + * @param {Object} [param.shape] + * @param {number} [param.shape.x1] + * @param {number} [param.shape.y1] + * @param {number} [param.shape.x2] + * @param {number} [param.shape.y2] + * @param {Object} [param.style] + * @param {number} [param.style.lineWidth] + * @return {Object} Modified param + */ + graphic.subPixelOptimizeLine = function (param) { + var subPixelOptimize = graphic.subPixelOptimize; + var shape = param.shape; + var lineWidth = param.style.lineWidth; + + if (round(shape.x1 * 2) === round(shape.x2 * 2)) { + shape.x1 = shape.x2 = subPixelOptimize(shape.x1, lineWidth, true); + } + if (round(shape.y1 * 2) === round(shape.y2 * 2)) { + shape.y1 = shape.y2 = subPixelOptimize(shape.y1, lineWidth, true); + } + return param; + }; + + /** + * Sub pixel optimize rect for canvas + * + * @param {Object} param + * @param {Object} [param.shape] + * @param {number} [param.shape.x] + * @param {number} [param.shape.y] + * @param {number} [param.shape.width] + * @param {number} [param.shape.height] + * @param {Object} [param.style] + * @param {number} [param.style.lineWidth] + * @return {Object} Modified param + */ + graphic.subPixelOptimizeRect = function (param) { + var subPixelOptimize = graphic.subPixelOptimize; + var shape = param.shape; + var lineWidth = param.style.lineWidth; + var originX = shape.x; + var originY = shape.y; + var originWidth = shape.width; + var originHeight = shape.height; + shape.x = subPixelOptimize(shape.x, lineWidth, true); + shape.y = subPixelOptimize(shape.y, lineWidth, true); + shape.width = Math.max( + subPixelOptimize(originX + originWidth, lineWidth, false) - shape.x, + originWidth === 0 ? 0 : 1 + ); + shape.height = Math.max( + subPixelOptimize(originY + originHeight, lineWidth, false) - shape.y, + originHeight === 0 ? 0 : 1 + ); + return param; + }; + + /** + * Sub pixel optimize for canvas + * + * @param {number} position Coordinate, such as x, y + * @param {number} lineWidth Should be nonnegative integer. + * @param {boolean=} positiveOrNegative Default false (negative). + * @return {number} Optimized position. + */ + graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) { + // Assure that (position + lineWidth / 2) is near integer edge, + // otherwise line will be fuzzy in canvas. + var doubledPosition = round(position * 2); + return (doubledPosition + round(lineWidth)) % 2 === 0 + ? doubledPosition / 2 + : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2; + }; + + /** + * @private + */ + function doSingleEnterHover(el) { + if (el.__isHover) { + return; + } + if (el.__hoverStlDirty) { + var stroke = el.style.stroke; + var fill = el.style.fill; + + // Create hoverStyle on mouseover + var hoverStyle = el.__hoverStl; + hoverStyle.fill = hoverStyle.fill + || (fill instanceof Gradient ? fill : colorTool.lift(fill, -0.1)); + hoverStyle.stroke = hoverStyle.stroke + || (stroke instanceof Gradient ? stroke : colorTool.lift(stroke, -0.1)); + + var normalStyle = {}; + for (var name in hoverStyle) { + if (hoverStyle.hasOwnProperty(name)) { + normalStyle[name] = el.style[name]; + } + } + + el.__normalStl = normalStyle; + + el.__hoverStlDirty = false; + } + el.setStyle(el.__hoverStl); + el.z2 += 1; + + el.__isHover = true; + } + + /** + * @inner + */ + function doSingleLeaveHover(el) { + if (!el.__isHover) { + return; + } + + var normalStl = el.__normalStl; + normalStl && el.setStyle(normalStl); + el.z2 -= 1; + + el.__isHover = false; + } + + /** + * @inner + */ + function doEnterHover(el) { + el.type === 'group' + ? el.traverse(function (child) { + if (child.type !== 'group') { + doSingleEnterHover(child); + } + }) + : doSingleEnterHover(el); + } + + function doLeaveHover(el) { + el.type === 'group' + ? el.traverse(function (child) { + if (child.type !== 'group') { + doSingleLeaveHover(child); + } + }) + : doSingleLeaveHover(el); + } + + /** + * @inner + */ + function setElementHoverStl(el, hoverStl) { + // If element has sepcified hoverStyle, then use it instead of given hoverStyle + // Often used when item group has a label element and it's hoverStyle is different + el.__hoverStl = el.hoverStyle || hoverStl; + el.__hoverStlDirty = true; + } + + /** + * @inner + */ + function onElementMouseOver() { + // Only if element is not in emphasis status + !this.__isEmphasis && doEnterHover(this); + } + + /** + * @inner + */ + function onElementMouseOut() { + // Only if element is not in emphasis status + !this.__isEmphasis && doLeaveHover(this); + } + + /** + * @inner + */ + function enterEmphasis() { + this.__isEmphasis = true; + doEnterHover(this); + } + + /** + * @inner + */ + function leaveEmphasis() { + this.__isEmphasis = false; + doLeaveHover(this); + } + + /** + * Set hover style of element + * @param {module:zrender/Element} el + * @param {Object} [hoverStyle] + */ + graphic.setHoverStyle = function (el, hoverStyle) { + hoverStyle = hoverStyle || {}; + el.type === 'group' + ? el.traverse(function (child) { + if (child.type !== 'group') { + setElementHoverStl(child, hoverStyle); + } + }) + : setElementHoverStl(el, hoverStyle); + // Remove previous bound handlers + el.on('mouseover', onElementMouseOver) + .on('mouseout', onElementMouseOut); + + // Emphasis, normal can be triggered manually + el.on('emphasis', enterEmphasis) + .on('normal', leaveEmphasis); + }; + + /** + * Set text option in the style + * @param {Object} textStyle + * @param {module:echarts/model/Model} labelModel + * @param {string} color + */ + graphic.setText = function (textStyle, labelModel, color) { + var labelPosition = labelModel.getShallow('position') || 'inside'; + var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color; + var textStyleModel = labelModel.getModel('textStyle'); + zrUtil.extend(textStyle, { + textDistance: labelModel.getShallow('distance') || 5, + textFont: textStyleModel.getFont(), + textPosition: labelPosition, + textFill: textStyleModel.getTextColor() || labelColor + }); + }; + + function animateOrSetProps(isUpdate, el, props, animatableModel, cb) { + var postfix = isUpdate ? 'Update' : ''; + var duration = animatableModel + && animatableModel.getShallow('animationDuration' + postfix); + var animationEasing = animatableModel + && animatableModel.getShallow('animationEasing' + postfix); + + animatableModel && animatableModel.getShallow('animation') + ? el.animateTo(props, duration, animationEasing, cb) + : (el.attr(props), cb && cb()); + } + /** + * Update graphic element properties with or without animation according to the configuration in series + * @param {module:zrender/Element} el + * @param {Object} props + * @param {module:echarts/model/Model} [animatableModel] + * @param {Function} cb + */ + graphic.updateProps = zrUtil.curry(animateOrSetProps, true); + + /** + * Init graphic element properties with or without animation according to the configuration in series + * @param {module:zrender/Element} el + * @param {Object} props + * @param {module:echarts/model/Model} [animatableModel] + * @param {Function} cb + */ + graphic.initProps = zrUtil.curry(animateOrSetProps, false); + + /** + * Get transform matrix of target (param target), + * in coordinate of its ancestor (param ancestor) + * + * @param {module:zrender/mixin/Transformable} target + * @param {module:zrender/mixin/Transformable} ancestor + */ + graphic.getTransform = function (target, ancestor) { + var mat = matrix.identity([]); + + while (target && target !== ancestor) { + matrix.mul(mat, target.getLocalTransform(), mat); + target = target.parent; + } + + return mat; + }; + + /** + * Apply transform to an vertex. + * @param {Array.} vertex [x, y] + * @param {Array.} transform Transform matrix: like [1, 0, 0, 1, 0, 0] + * @param {boolean=} invert Whether use invert matrix. + * @return {Array.} [x, y] + */ + graphic.applyTransform = function (vertex, transform, invert) { + if (invert) { + transform = matrix.invert([], transform); + } + return vector.applyTransform([], vertex, transform); + }; + + /** + * @param {string} direction 'left' 'right' 'top' 'bottom' + * @param {Array.} transform Transform matrix: like [1, 0, 0, 1, 0, 0] + * @param {boolean=} invert Whether use invert matrix. + * @return {string} Transformed direction. 'left' 'right' 'top' 'bottom' + */ + graphic.transformDirection = function (direction, transform, invert) { + + // Pick a base, ensure that transform result will not be (0, 0). + var hBase = (transform[4] === 0 || transform[5] === 0 || transform[0] === 0) + ? 1 : Math.abs(2 * transform[4] / transform[0]); + var vBase = (transform[4] === 0 || transform[5] === 0 || transform[2] === 0) + ? 1 : Math.abs(2 * transform[4] / transform[2]); + + var vertex = [ + direction === 'left' ? -hBase : direction === 'right' ? hBase : 0, + direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0 + ]; + + vertex = graphic.applyTransform(vertex, transform, invert); + + return Math.abs(vertex[0]) > Math.abs(vertex[1]) + ? (vertex[0] > 0 ? 'right' : 'left') + : (vertex[1] > 0 ? 'bottom' : 'top'); + }; + + module.exports = graphic; + + +/***/ }, +/* 43 */ +/***/ function(module, exports, __webpack_require__) { + + + + var Path = __webpack_require__(44); + var PathProxy = __webpack_require__(48); + var transformPath = __webpack_require__(58); + var matrix = __webpack_require__(17); + + // command chars + var cc = [ + 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z', + 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A' + ]; + + var mathSqrt = Math.sqrt; + var mathSin = Math.sin; + var mathCos = Math.cos; + var PI = Math.PI; + + var vMag = function(v) { + return Math.sqrt(v[0] * v[0] + v[1] * v[1]); + }; + var vRatio = function(u, v) { + return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v)); + }; + var vAngle = function(u, v) { + return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) + * Math.acos(vRatio(u, v)); + }; + + function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) { + var psi = psiDeg * (PI / 180.0); + var xp = mathCos(psi) * (x1 - x2) / 2.0 + + mathSin(psi) * (y1 - y2) / 2.0; + var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0 + + mathCos(psi) * (y1 - y2) / 2.0; + + var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry); + + if (lambda > 1) { + rx *= mathSqrt(lambda); + ry *= mathSqrt(lambda); + } + + var f = (fa === fs ? -1 : 1) + * mathSqrt((((rx * rx) * (ry * ry)) + - ((rx * rx) * (yp * yp)) + - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp) + + (ry * ry) * (xp * xp)) + ) || 0; + + var cxp = f * rx * yp / ry; + var cyp = f * -ry * xp / rx; + + var cx = (x1 + x2) / 2.0 + + mathCos(psi) * cxp + - mathSin(psi) * cyp; + var cy = (y1 + y2) / 2.0 + + mathSin(psi) * cxp + + mathCos(psi) * cyp; + + var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]); + var u = [ (xp - cxp) / rx, (yp - cyp) / ry ]; + var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ]; + var dTheta = vAngle(u, v); + + if (vRatio(u, v) <= -1) { + dTheta = PI; + } + if (vRatio(u, v) >= 1) { + dTheta = 0; + } + if (fs === 0 && dTheta > 0) { + dTheta = dTheta - 2 * PI; + } + if (fs === 1 && dTheta < 0) { + dTheta = dTheta + 2 * PI; + } + + path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs); + } + + function createPathProxyFromString(data) { + if (!data) { + return []; + } + + // command string + var cs = data.replace(/-/g, ' -') + .replace(/ /g, ' ') + .replace(/ /g, ',') + .replace(/,,/g, ','); + + var n; + // create pipes so that we can split the data + for (n = 0; n < cc.length; n++) { + cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]); + } + + // create array + var arr = cs.split('|'); + // init context point + var cpx = 0; + var cpy = 0; + + var path = new PathProxy(); + var CMD = PathProxy.CMD; + + var prevCmd; + for (n = 1; n < arr.length; n++) { + var str = arr[n]; + var c = str.charAt(0); + var off = 0; + var p = str.slice(1).replace(/e,-/g, 'e-').split(','); + var cmd; + + if (p.length > 0 && p[0] === '') { + p.shift(); + } + + for (var i = 0; i < p.length; i++) { + p[i] = parseFloat(p[i]); + } + while (off < p.length && !isNaN(p[off])) { + if (isNaN(p[0])) { + break; + } + var ctlPtx; + var ctlPty; + + var rx; + var ry; + var psi; + var fa; + var fs; + + var x1 = cpx; + var y1 = cpy; + + // convert l, H, h, V, and v to L + switch (c) { + case 'l': + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'L': + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'm': + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.M; + path.addData(cmd, cpx, cpy); + c = 'l'; + break; + case 'M': + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.M; + path.addData(cmd, cpx, cpy); + c = 'L'; + break; + case 'h': + cpx += p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'H': + cpx = p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'v': + cpy += p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'V': + cpy = p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'C': + cmd = CMD.C; + path.addData( + cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++] + ); + cpx = p[off - 2]; + cpy = p[off - 1]; + break; + case 'c': + cmd = CMD.C; + path.addData( + cmd, + p[off++] + cpx, p[off++] + cpy, + p[off++] + cpx, p[off++] + cpy, + p[off++] + cpx, p[off++] + cpy + ); + cpx += p[off - 2]; + cpy += p[off - 1]; + break; + case 'S': + ctlPtx = cpx; + ctlPty = cpy; + var len = path.len(); + var pathData = path.data; + if (prevCmd === CMD.C) { + ctlPtx += cpx - pathData[len - 4]; + ctlPty += cpy - pathData[len - 3]; + } + cmd = CMD.C; + x1 = p[off++]; + y1 = p[off++]; + cpx = p[off++]; + cpy = p[off++]; + path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy); + break; + case 's': + ctlPtx = cpx; + ctlPty = cpy; + var len = path.len(); + var pathData = path.data; + if (prevCmd === CMD.C) { + ctlPtx += cpx - pathData[len - 4]; + ctlPty += cpy - pathData[len - 3]; + } + cmd = CMD.C; + x1 = cpx + p[off++]; + y1 = cpy + p[off++]; + cpx += p[off++]; + cpy += p[off++]; + path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy); + break; + case 'Q': + x1 = p[off++]; + y1 = p[off++]; + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.Q; + path.addData(cmd, x1, y1, cpx, cpy); + break; + case 'q': + x1 = p[off++] + cpx; + y1 = p[off++] + cpy; + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.Q; + path.addData(cmd, x1, y1, cpx, cpy); + break; + case 'T': + ctlPtx = cpx; + ctlPty = cpy; + var len = path.len(); + var pathData = path.data; + if (prevCmd === CMD.Q) { + ctlPtx += cpx - pathData[len - 4]; + ctlPty += cpy - pathData[len - 3]; + } + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.Q; + path.addData(cmd, ctlPtx, ctlPty, cpx, cpy); + break; + case 't': + ctlPtx = cpx; + ctlPty = cpy; + var len = path.len(); + var pathData = path.data; + if (prevCmd === CMD.Q) { + ctlPtx += cpx - pathData[len - 4]; + ctlPty += cpy - pathData[len - 3]; + } + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.Q; + path.addData(cmd, ctlPtx, ctlPty, cpx, cpy); + break; + case 'A': + rx = p[off++]; + ry = p[off++]; + psi = p[off++]; + fa = p[off++]; + fs = p[off++]; + + x1 = cpx, y1 = cpy; + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.A; + processArc( + x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path + ); + break; + case 'a': + rx = p[off++]; + ry = p[off++]; + psi = p[off++]; + fa = p[off++]; + fs = p[off++]; + + x1 = cpx, y1 = cpy; + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.A; + processArc( + x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path + ); + break; + } + } + + if (c === 'z' || c === 'Z') { + cmd = CMD.Z; + path.addData(cmd); + } + + prevCmd = cmd; + } + + path.toStatic(); + + return path; + } + + // TODO Optimize double memory cost problem + function createPathOptions(str, opts) { + var pathProxy = createPathProxyFromString(str); + var transform; + opts = opts || {}; + opts.buildPath = function (path) { + path.setData(pathProxy.data); + transform && transformPath(path, transform); + // Svg and vml renderer don't have context + var ctx = path.getContext(); + if (ctx) { + path.rebuildPath(ctx); + } + }; + + opts.applyTransform = function (m) { + if (!transform) { + transform = matrix.create(); + } + matrix.mul(transform, m, transform); + }; + + return opts; + } + + module.exports = { + /** + * Create a Path object from path string data + * http://www.w3.org/TR/SVG/paths.html#PathData + * @param {Object} opts Other options + */ + createFromString: function (str, opts) { + return new Path(createPathOptions(str, opts)); + }, + + /** + * Create a Path class from path string data + * @param {string} str + * @param {Object} opts Other options + */ + extendFromString: function (str, opts) { + return Path.extend(createPathOptions(str, opts)); + }, + + /** + * Merge multiple paths + */ + // TODO Apply transform + // TODO stroke dash + // TODO Optimize double memory cost problem + mergePath: function (pathEls, opts) { + var pathList = []; + var len = pathEls.length; + var pathEl; + var i; + for (i = 0; i < len; i++) { + pathEl = pathEls[i]; + if (pathEl.__dirty) { + pathEl.buildPath(pathEl.path, pathEl.shape); + } + pathList.push(pathEl.path); + } + + var pathBundle = new Path(opts); + pathBundle.buildPath = function (path) { + path.appendPath(pathList); + // Svg and vml renderer don't have context + var ctx = path.getContext(); + if (ctx) { + path.rebuildPath(ctx); + } + }; + + return pathBundle; + } + }; + + +/***/ }, +/* 44 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Path element + * @module zrender/graphic/Path + */ + + + + var Displayable = __webpack_require__(45); + var zrUtil = __webpack_require__(3); + var PathProxy = __webpack_require__(48); + var pathContain = __webpack_require__(51); + + var Gradient = __webpack_require__(4); + + function pathHasFill(style) { + var fill = style.fill; + return fill != null && fill !== 'none'; + } + + function pathHasStroke(style) { + var stroke = style.stroke; + return stroke != null && stroke !== 'none' && style.lineWidth > 0; + } + + var abs = Math.abs; + + /** + * @alias module:zrender/graphic/Path + * @extends module:zrender/graphic/Displayable + * @constructor + * @param {Object} opts + */ + function Path(opts) { + Displayable.call(this, opts); + + /** + * @type {module:zrender/core/PathProxy} + * @readOnly + */ + this.path = new PathProxy(); + } + + Path.prototype = { + + constructor: Path, + + type: 'path', + + __dirtyPath: true, + + strokeContainThreshold: 5, + + brush: function (ctx) { + ctx.save(); + + var style = this.style; + var path = this.path; + var hasStroke = pathHasStroke(style); + var hasFill = pathHasFill(style); + + if (this.__dirtyPath) { + // Update gradient because bounding rect may changed + if (hasFill && (style.fill instanceof Gradient)) { + style.fill.updateCanvasGradient(this, ctx); + } + if (hasStroke && (style.stroke instanceof Gradient)) { + style.stroke.updateCanvasGradient(this, ctx); + } + } + + style.bind(ctx, this); + this.setTransform(ctx); + + var lineDash = style.lineDash; + var lineDashOffset = style.lineDashOffset; + + var ctxLineDash = !!ctx.setLineDash; + + // Proxy context + // Rebuild path in following 2 cases + // 1. Path is dirty + // 2. Path needs javascript implemented lineDash stroking. + // In this case, lineDash information will not be saved in PathProxy + if (this.__dirtyPath || ( + lineDash && !ctxLineDash && hasStroke + )) { + path = this.path.beginPath(ctx); + + // Setting line dash before build path + if (lineDash && !ctxLineDash) { + path.setLineDash(lineDash); + path.setLineDashOffset(lineDashOffset); + } + + this.buildPath(path, this.shape); + + // Clear path dirty flag + this.__dirtyPath = false; + } + else { + // Replay path building + ctx.beginPath(); + this.path.rebuildPath(ctx); + } + + hasFill && path.fill(ctx); + + if (lineDash && ctxLineDash) { + ctx.setLineDash(lineDash); + ctx.lineDashOffset = lineDashOffset; + } + + hasStroke && path.stroke(ctx); + + // Draw rect text + if (style.text != null) { + // var rect = this.getBoundingRect(); + this.drawRectText(ctx, this.getBoundingRect()); + } + + ctx.restore(); + }, + + buildPath: function (ctx, shapeCfg) {}, + + getBoundingRect: function () { + var rect = this._rect; + var style = this.style; + if (!rect) { + var path = this.path; + if (this.__dirtyPath) { + path.beginPath(); + this.buildPath(path, this.shape); + } + rect = path.getBoundingRect(); + } + /** + * Needs update rect with stroke lineWidth when + * 1. Element changes scale or lineWidth + * 2. First create rect + */ + if (pathHasStroke(style) && (this.__dirty || !this._rect)) { + var rectWithStroke = this._rectWithStroke + || (this._rectWithStroke = rect.clone()); + rectWithStroke.copy(rect); + // FIXME Must after updateTransform + var w = style.lineWidth; + // PENDING, Min line width is needed when line is horizontal or vertical + var lineScale = style.strokeNoScale ? this.getLineScale() : 1; + + // Only add extra hover lineWidth when there are no fill + if (!pathHasFill(style)) { + w = Math.max(w, this.strokeContainThreshold); + } + // Consider line width + // Line scale can't be 0; + if (lineScale > 1e-10) { + rectWithStroke.width += w / lineScale; + rectWithStroke.height += w / lineScale; + rectWithStroke.x -= w / lineScale / 2; + rectWithStroke.y -= w / lineScale / 2; + } + return rectWithStroke; + } + this._rect = rect; + return rect; + }, + + contain: function (x, y) { + var localPos = this.transformCoordToLocal(x, y); + var rect = this.getBoundingRect(); + var style = this.style; + x = localPos[0]; + y = localPos[1]; + + if (rect.contain(x, y)) { + var pathData = this.path.data; + if (pathHasStroke(style)) { + var lineWidth = style.lineWidth; + var lineScale = style.strokeNoScale ? this.getLineScale() : 1; + // Line scale can't be 0; + if (lineScale > 1e-10) { + // Only add extra hover lineWidth when there are no fill + if (!pathHasFill(style)) { + lineWidth = Math.max(lineWidth, this.strokeContainThreshold); + } + if (pathContain.containStroke( + pathData, lineWidth / lineScale, x, y + )) { + return true; + } + } + } + if (pathHasFill(style)) { + return pathContain.contain(pathData, x, y); + } + } + return false; + }, + + /** + * @param {boolean} dirtyPath + */ + dirty: function (dirtyPath) { + if (arguments.length ===0) { + dirtyPath = true; + } + // Only mark dirty, not mark clean + if (dirtyPath) { + this.__dirtyPath = dirtyPath; + this._rect = null; + } + + this.__dirty = true; + + this.__zr && this.__zr.refresh(); + + // Used as a clipping path + if (this.__clipTarget) { + this.__clipTarget.dirty(); + } + }, + + /** + * Alias for animate('shape') + * @param {boolean} loop + */ + animateShape: function (loop) { + return this.animate('shape', loop); + }, + + // Overwrite attrKV + attrKV: function (key, value) { + // FIXME + if (key === 'shape') { + this.setShape(value); + } + else { + Displayable.prototype.attrKV.call(this, key, value); + } + }, + /** + * @param {Object|string} key + * @param {*} value + */ + setShape: function (key, value) { + var shape = this.shape; + // Path from string may not have shape + if (shape) { + if (zrUtil.isObject(key)) { + for (var name in key) { + shape[name] = key[name]; + } + } + else { + shape[key] = value; + } + this.dirty(true); + } + return this; + }, + + getLineScale: function () { + var m = this.transform; + // Get the line scale. + // Determinant of `m` means how much the area is enlarged by the + // transformation. So its square root can be used as a scale factor + // for width. + return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10 + ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1])) + : 1; + } + }; + + /** + * 扩展一个 Path element, 比如星形,圆等。 + * Extend a path element + * @param {Object} props + * @param {string} props.type Path type + * @param {Function} props.init Initialize + * @param {Function} props.buildPath Overwrite buildPath method + * @param {Object} [props.style] Extended default style config + * @param {Object} [props.shape] Extended default shape config + */ + Path.extend = function (defaults) { + var Sub = function (opts) { + Path.call(this, opts); + + if (defaults.style) { + // Extend default style + this.style.extendFrom(defaults.style, false); + } + + // Extend default shape + var defaultShape = defaults.shape; + if (defaultShape) { + this.shape = this.shape || {}; + var thisShape = this.shape; + for (var name in defaultShape) { + if ( + ! thisShape.hasOwnProperty(name) + && defaultShape.hasOwnProperty(name) + ) { + thisShape[name] = defaultShape[name]; + } + } + } + + defaults.init && defaults.init.call(this, opts); + }; + + zrUtil.inherits(Sub, Path); + + // FIXME 不能 extend position, rotation 等引用对象 + for (var name in defaults) { + // Extending prototype values and methods + if (name !== 'style' && name !== 'shape') { + Sub.prototype[name] = defaults[name]; + } + } + + return Sub; + }; + + zrUtil.inherits(Path, Displayable); + + module.exports = Path; + + +/***/ }, +/* 45 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 可绘制的图形基类 + * Base class of all displayable graphic objects + * @module zrender/graphic/Displayable + */ + + + + var zrUtil = __webpack_require__(3); + + var Style = __webpack_require__(46); + + var Element = __webpack_require__(30); + var RectText = __webpack_require__(47); + // var Stateful = require('./mixin/Stateful'); + + /** + * @alias module:zrender/graphic/Displayable + * @extends module:zrender/Element + * @extends module:zrender/graphic/mixin/RectText + */ + function Displayable(opts) { + + opts = opts || {}; + + Element.call(this, opts); + + // Extend properties + for (var name in opts) { + if ( + opts.hasOwnProperty(name) && + name !== 'style' + ) { + this[name] = opts[name]; + } + } + + /** + * @type {module:zrender/graphic/Style} + */ + this.style = new Style(opts.style); + + this._rect = null; + // Shapes for cascade clipping. + this.__clipPaths = []; + + // FIXME Stateful must be mixined after style is setted + // Stateful.call(this, opts); + } + + Displayable.prototype = { + + constructor: Displayable, + + type: 'displayable', + + /** + * Displayable 是否为脏,Painter 中会根据该标记判断是否需要是否需要重新绘制 + * Dirty flag. From which painter will determine if this displayable object needs brush + * @name module:zrender/graphic/Displayable#__dirty + * @type {boolean} + */ + __dirty: true, + + /** + * 图形是否可见,为true时不绘制图形,但是仍能触发鼠标事件 + * If ignore drawing of the displayable object. Mouse event will still be triggered + * @name module:/zrender/graphic/Displayable#invisible + * @type {boolean} + * @default false + */ + invisible: false, + + /** + * @name module:/zrender/graphic/Displayable#z + * @type {number} + * @default 0 + */ + z: 0, + + /** + * @name module:/zrender/graphic/Displayable#z + * @type {number} + * @default 0 + */ + z2: 0, + + /** + * z层level,决定绘画在哪层canvas中 + * @name module:/zrender/graphic/Displayable#zlevel + * @type {number} + * @default 0 + */ + zlevel: 0, + + /** + * 是否可拖拽 + * @name module:/zrender/graphic/Displayable#draggable + * @type {boolean} + * @default false + */ + draggable: false, + + /** + * 是否正在拖拽 + * @name module:/zrender/graphic/Displayable#draggable + * @type {boolean} + * @default false + */ + dragging: false, + + /** + * 是否相应鼠标事件 + * @name module:/zrender/graphic/Displayable#silent + * @type {boolean} + * @default false + */ + silent: false, + + /** + * If enable culling + * @type {boolean} + * @default false + */ + culling: false, + + /** + * Mouse cursor when hovered + * @name module:/zrender/graphic/Displayable#cursor + * @type {string} + */ + cursor: 'pointer', + + /** + * If hover area is bounding rect + * @name module:/zrender/graphic/Displayable#rectHover + * @type {string} + */ + rectHover: false, + + beforeBrush: function (ctx) {}, + + afterBrush: function (ctx) {}, + + /** + * 图形绘制方法 + * @param {Canvas2DRenderingContext} ctx + */ + // Interface + brush: function (ctx) {}, + + /** + * 获取最小包围盒 + * @return {module:zrender/core/BoundingRect} + */ + // Interface + getBoundingRect: function () {}, + + /** + * 判断坐标 x, y 是否在图形上 + * If displayable element contain coord x, y + * @param {number} x + * @param {number} y + * @return {boolean} + */ + contain: function (x, y) { + return this.rectContain(x, y); + }, + + /** + * @param {Function} cb + * @param {} context + */ + traverse: function (cb, context) { + cb.call(context, this); + }, + + /** + * 判断坐标 x, y 是否在图形的包围盒上 + * If bounding rect of element contain coord x, y + * @param {number} x + * @param {number} y + * @return {boolean} + */ + rectContain: function (x, y) { + var coord = this.transformCoordToLocal(x, y); + var rect = this.getBoundingRect(); + return rect.contain(coord[0], coord[1]); + }, + + /** + * 标记图形元素为脏,并且在下一帧重绘 + * Mark displayable element dirty and refresh next frame + */ + dirty: function () { + this.__dirty = true; + + this._rect = null; + + this.__zr && this.__zr.refresh(); + }, + + /** + * 图形是否会触发事件 + * If displayable object binded any event + * @return {boolean} + */ + // TODO, 通过 bind 绑定的事件 + // isSilent: function () { + // return !( + // this.hoverable || this.draggable + // || this.onmousemove || this.onmouseover || this.onmouseout + // || this.onmousedown || this.onmouseup || this.onclick + // || this.ondragenter || this.ondragover || this.ondragleave + // || this.ondrop + // ); + // }, + /** + * Alias for animate('style') + * @param {boolean} loop + */ + animateStyle: function (loop) { + return this.animate('style', loop); + }, + + attrKV: function (key, value) { + if (key !== 'style') { + Element.prototype.attrKV.call(this, key, value); + } + else { + this.style.set(value); + } + }, + + /** + * @param {Object|string} key + * @param {*} value + */ + setStyle: function (key, value) { + this.style.set(key, value); + this.dirty(); + return this; + } + }; + + zrUtil.inherits(Displayable, Element); + + zrUtil.mixin(Displayable, RectText); + // zrUtil.mixin(Displayable, Stateful); + + module.exports = Displayable; + + +/***/ }, +/* 46 */ +/***/ function(module, exports) { + + /** + * @module zrender/graphic/Style + */ + + + + var STYLE_LIST_COMMON = [ + 'lineCap', 'lineJoin', 'miterLimit', + 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'shadowColor' + ]; + + var Style = function (opts) { + this.extendFrom(opts); + }; + + Style.prototype = { + + constructor: Style, + + /** + * @type {string} + */ + fill: '#000000', + + /** + * @type {string} + */ + stroke: null, + + /** + * @type {number} + */ + opacity: 1, + + /** + * @type {Array.} + */ + lineDash: null, + + /** + * @type {number} + */ + lineDashOffset: 0, + + /** + * @type {number} + */ + shadowBlur: 0, + + /** + * @type {number} + */ + shadowOffsetX: 0, + + /** + * @type {number} + */ + shadowOffsetY: 0, + + /** + * @type {number} + */ + lineWidth: 1, + + /** + * If stroke ignore scale + * @type {Boolean} + */ + strokeNoScale: false, + + // Bounding rect text configuration + // Not affected by element transform + /** + * @type {string} + */ + text: null, + + /** + * @type {string} + */ + textFill: '#000', + + /** + * @type {string} + */ + textStroke: null, + + /** + * 'inside', 'left', 'right', 'top', 'bottom' + * [x, y] + * @type {string|Array.} + * @default 'inside' + */ + textPosition: 'inside', + + /** + * @type {string} + */ + textBaseline: null, + + /** + * @type {string} + */ + textAlign: null, + + /** + * @type {string} + */ + textVerticalAlign: null, + + /** + * @type {number} + */ + textDistance: 5, + + /** + * @type {number} + */ + textShadowBlur: 0, + + /** + * @type {number} + */ + textShadowOffsetX: 0, + + /** + * @type {number} + */ + textShadowOffsetY: 0, + + /** + * @param {CanvasRenderingContext2D} ctx + */ + bind: function (ctx, el) { + var fill = this.fill; + var stroke = this.stroke; + for (var i = 0; i < STYLE_LIST_COMMON.length; i++) { + var styleName = STYLE_LIST_COMMON[i]; + + if (this[styleName] != null) { + ctx[styleName] = this[styleName]; + } + } + if (stroke != null) { + var lineWidth = this.lineWidth; + ctx.lineWidth = lineWidth / ( + (this.strokeNoScale && el && el.getLineScale) ? el.getLineScale() : 1 + ); + } + if (fill != null) { + // Use canvas gradient if has + ctx.fillStyle = fill.canvasGradient ? fill.canvasGradient : fill; + } + if (stroke != null) { + // Use canvas gradient if has + ctx.strokeStyle = stroke.canvasGradient ? stroke.canvasGradient : stroke; + } + this.opacity != null && (ctx.globalAlpha = this.opacity); + }, + + /** + * Extend from other style + * @param {zrender/graphic/Style} otherStyle + * @param {boolean} overwrite + */ + extendFrom: function (otherStyle, overwrite) { + if (otherStyle) { + var target = this; + for (var name in otherStyle) { + if (otherStyle.hasOwnProperty(name) + && (overwrite || ! target.hasOwnProperty(name)) + ) { + target[name] = otherStyle[name]; + } + } + } + }, + + /** + * Batch setting style with a given object + * @param {Object|string} obj + * @param {*} [obj] + */ + set: function (obj, value) { + if (typeof obj === 'string') { + this[obj] = value; + } + else { + this.extendFrom(obj, true); + } + }, + + /** + * Clone + * @return {zrender/graphic/Style} [description] + */ + clone: function () { + var newStyle = new this.constructor(); + newStyle.extendFrom(this, true); + return newStyle; + } + }; + + var styleProto = Style.prototype; + var name; + var i; + for (i = 0; i < STYLE_LIST_COMMON.length; i++) { + name = STYLE_LIST_COMMON[i]; + if (!(name in styleProto)) { + styleProto[name] = null; + } + } + + module.exports = Style; + + +/***/ }, +/* 47 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Mixin for drawing text in a element bounding rect + * @module zrender/mixin/RectText + */ + + + + var textContain = __webpack_require__(14); + var BoundingRect = __webpack_require__(15); + + var tmpRect = new BoundingRect(); + + var RectText = function () {}; + + function parsePercent(value, maxValue) { + if (typeof value === 'string') { + if (value.lastIndexOf('%') >= 0) { + return parseFloat(value) / 100 * maxValue; + } + return parseFloat(value); + } + return value; + } + + function setTransform(ctx, m) { + ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); + } + + RectText.prototype = { + + constructor: RectText, + + /** + * Draw text in a rect with specified position. + * @param {CanvasRenderingContext} ctx + * @param {Object} rect Displayable rect + * @return {Object} textRect Alternative precalculated text bounding rect + */ + drawRectText: function (ctx, rect, textRect) { + var style = this.style; + var text = style.text; + // Convert to string + text != null && (text += ''); + if (!text) { + return; + } + var x; + var y; + var textPosition = style.textPosition; + var distance = style.textDistance; + var align = style.textAlign; + var font = style.textFont || style.font; + var baseline = style.textBaseline; + var verticalAlign = style.textVerticalAlign; + + textRect = textRect || textContain.getBoundingRect(text, font, align, baseline); + + // Transform rect to view space + var transform = this.transform; + var invTransform = this.invTransform; + if (transform) { + tmpRect.copy(rect); + tmpRect.applyTransform(transform); + rect = tmpRect; + // Transform back + setTransform(ctx, invTransform); + } + + // Text position represented by coord + if (textPosition instanceof Array) { + // Percent + x = rect.x + parsePercent(textPosition[0], rect.width); + y = rect.y + parsePercent(textPosition[1], rect.height); + align = align || 'left'; + baseline = baseline || 'top'; + } + else { + var res = textContain.adjustTextPositionOnRect( + textPosition, rect, textRect, distance + ); + x = res.x; + y = res.y; + // Default align and baseline when has textPosition + align = align || res.textAlign; + baseline = baseline || res.textBaseline; + } + + ctx.textAlign = align; + if (verticalAlign) { + switch (verticalAlign) { + case 'middle': + y -= textRect.height / 2; + break; + case 'bottom': + y -= textRect.height; + break; + // 'top' + } + // Ignore baseline + ctx.textBaseline = 'top'; + } + else { + ctx.textBaseline = baseline; + } + + var textFill = style.textFill; + var textStroke = style.textStroke; + textFill && (ctx.fillStyle = textFill); + textStroke && (ctx.strokeStyle = textStroke); + ctx.font = font; + + // Text shadow + ctx.shadowColor = style.textShadowColor; + ctx.shadowBlur = style.textShadowBlur; + ctx.shadowOffsetX = style.textShadowOffsetX; + ctx.shadowOffsetY = style.textShadowOffsetY; + + var textLines = text.split('\n'); + for (var i = 0; i < textLines.length; i++) { + textFill && ctx.fillText(textLines[i], x, y); + textStroke && ctx.strokeText(textLines[i], x, y); + y += textRect.lineHeight; + } + + // Transform again + transform && setTransform(ctx, transform); + } + }; + + module.exports = RectText; + + +/***/ }, +/* 48 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Path 代理,可以在`buildPath`中用于替代`ctx`, 会保存每个path操作的命令到pathCommands属性中 + * 可以用于 isInsidePath 判断以及获取boundingRect + * + * @module zrender/core/PathProxy + * @author Yi Shen (http://www.github.com/pissang) + */ + + // TODO getTotalLength, getPointAtLength + + + var curve = __webpack_require__(49); + var vec2 = __webpack_require__(16); + var bbox = __webpack_require__(50); + var BoundingRect = __webpack_require__(15); + + var CMD = { + M: 1, + L: 2, + C: 3, + Q: 4, + A: 5, + Z: 6, + // Rect + R: 7 + }; + + var min = []; + var max = []; + var min2 = []; + var max2 = []; + var mathMin = Math.min; + var mathMax = Math.max; + var mathCos = Math.cos; + var mathSin = Math.sin; + var mathSqrt = Math.sqrt; + + var hasTypedArray = typeof Float32Array != 'undefined'; + + /** + * @alias module:zrender/core/PathProxy + * @constructor + */ + var PathProxy = function () { + + /** + * Path data. Stored as flat array + * @type {Array.} + */ + this.data = []; + + this._len = 0; + + this._ctx = null; + + this._xi = 0; + this._yi = 0; + + this._x0 = 0; + this._y0 = 0; + }; + + /** + * 快速计算Path包围盒(并不是最小包围盒) + * @return {Object} + */ + PathProxy.prototype = { + + constructor: PathProxy, + + _lineDash: null, + + _dashOffset: 0, + + _dashIdx: 0, + + _dashSum: 0, + + getContext: function () { + return this._ctx; + }, + + /** + * @param {CanvasRenderingContext2D} ctx + * @return {module:zrender/core/PathProxy} + */ + beginPath: function (ctx) { + this._ctx = ctx; + + ctx && ctx.beginPath(); + + // Reset + this._len = 0; + + if (this._lineDash) { + this._lineDash = null; + + this._dashOffset = 0; + } + + return this; + }, + + /** + * @param {number} x + * @param {number} y + * @return {module:zrender/core/PathProxy} + */ + moveTo: function (x, y) { + this.addData(CMD.M, x, y); + this._ctx && this._ctx.moveTo(x, y); + + // x0, y0, xi, yi 是记录在 _dashedXXXXTo 方法中使用 + // xi, yi 记录当前点, x0, y0 在 closePath 的时候回到起始点。 + // 有可能在 beginPath 之后直接调用 lineTo,这时候 x0, y0 需要 + // 在 lineTo 方法中记录,这里先不考虑这种情况,dashed line 也只在 IE10- 中不支持 + this._x0 = x; + this._y0 = y; + + this._xi = x; + this._yi = y; + + return this; + }, + + /** + * @param {number} x + * @param {number} y + * @return {module:zrender/core/PathProxy} + */ + lineTo: function (x, y) { + this.addData(CMD.L, x, y); + if (this._ctx) { + this._needsDash() ? this._dashedLineTo(x, y) + : this._ctx.lineTo(x, y); + } + this._xi = x; + this._yi = y; + return this; + }, + + /** + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x3 + * @param {number} y3 + * @return {module:zrender/core/PathProxy} + */ + bezierCurveTo: function (x1, y1, x2, y2, x3, y3) { + this.addData(CMD.C, x1, y1, x2, y2, x3, y3); + if (this._ctx) { + this._needsDash() ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3) + : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3); + } + this._xi = x3; + this._yi = y3; + return this; + }, + + /** + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @return {module:zrender/core/PathProxy} + */ + quadraticCurveTo: function (x1, y1, x2, y2) { + this.addData(CMD.Q, x1, y1, x2, y2); + if (this._ctx) { + this._needsDash() ? this._dashedQuadraticTo(x1, y1, x2, y2) + : this._ctx.quadraticCurveTo(x1, y1, x2, y2); + } + this._xi = x2; + this._yi = y2; + return this; + }, + + /** + * @param {number} cx + * @param {number} cy + * @param {number} r + * @param {number} startAngle + * @param {number} endAngle + * @param {boolean} anticlockwise + * @return {module:zrender/core/PathProxy} + */ + arc: function (cx, cy, r, startAngle, endAngle, anticlockwise) { + this.addData( + CMD.A, cx, cy, r, r, startAngle, endAngle - startAngle, 0, anticlockwise ? 0 : 1 + ); + this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise); + + this._xi = mathCos(endAngle) * r + cx; + this._xi = mathSin(endAngle) * r + cx; + return this; + }, + + // TODO + arcTo: function (x1, y1, x2, y2, radius) { + if (this._ctx) { + this._ctx.arcTo(x1, y1, x2, y2, radius); + } + return this; + }, + + // TODO + rect: function (x, y, w, h) { + this._ctx && this._ctx.rect(x, y, w, h); + this.addData(CMD.R, x, y, w, h); + return this; + }, + + /** + * @return {module:zrender/core/PathProxy} + */ + closePath: function () { + this.addData(CMD.Z); + + var ctx = this._ctx; + var x0 = this._x0; + var y0 = this._y0; + if (ctx) { + this._needsDash() && this._dashedLineTo(x0, y0); + ctx.closePath(); + } + + this._xi = x0; + this._yi = y0; + return this; + }, + + /** + * Context 从外部传入,因为有可能是 rebuildPath 完之后再 fill。 + * stroke 同样 + * @param {CanvasRenderingContext2D} ctx + * @return {module:zrender/core/PathProxy} + */ + fill: function (ctx) { + ctx && ctx.fill(); + this.toStatic(); + }, + + /** + * @param {CanvasRenderingContext2D} ctx + * @return {module:zrender/core/PathProxy} + */ + stroke: function (ctx) { + ctx && ctx.stroke(); + this.toStatic(); + }, + + /** + * 必须在其它绘制命令前调用 + * Must be invoked before all other path drawing methods + * @return {module:zrender/core/PathProxy} + */ + setLineDash: function (lineDash) { + if (lineDash instanceof Array) { + this._lineDash = lineDash; + + this._dashIdx = 0; + + var lineDashSum = 0; + for (var i = 0; i < lineDash.length; i++) { + lineDashSum += lineDash[i]; + } + this._dashSum = lineDashSum; + } + return this; + }, + + /** + * 必须在其它绘制命令前调用 + * Must be invoked before all other path drawing methods + * @return {module:zrender/core/PathProxy} + */ + setLineDashOffset: function (offset) { + this._dashOffset = offset; + return this; + }, + + /** + * + * @return {boolean} + */ + len: function () { + return this._len; + }, + + /** + * 直接设置 Path 数据 + */ + setData: function (data) { + + var len = data.length; + + if (! (this.data && this.data.length == len) && hasTypedArray) { + this.data = new Float32Array(len); + } + + for (var i = 0; i < len; i++) { + this.data[i] = data[i]; + } + + this._len = len; + }, + + /** + * 添加子路径 + * @param {module:zrender/core/PathProxy|Array.} path + */ + appendPath: function (path) { + if (!(path instanceof Array)) { + path = [path]; + } + var len = path.length; + var appendSize = 0; + var offset = this._len; + for (var i = 0; i < len; i++) { + appendSize += path[i].len(); + } + if (hasTypedArray && (this.data instanceof Float32Array)) { + this.data = new Float32Array(offset + appendSize); + } + for (var i = 0; i < len; i++) { + var appendPathData = path[i].data; + for (var k = 0; k < appendPathData.length; k++) { + this.data[offset++] = appendPathData[k]; + } + } + this._len = offset; + }, + + /** + * 填充 Path 数据。 + * 尽量复用而不申明新的数组。大部分图形重绘的指令数据长度都是不变的。 + */ + addData: function (cmd) { + var data = this.data; + if (this._len + arguments.length > data.length) { + // 因为之前的数组已经转换成静态的 Float32Array + // 所以不够用时需要扩展一个新的动态数组 + this._expandData(); + data = this.data; + } + for (var i = 0; i < arguments.length; i++) { + data[this._len++] = arguments[i]; + } + + this._prevCmd = cmd; + }, + + _expandData: function () { + // Only if data is Float32Array + if (!(this.data instanceof Array)) { + var newData = []; + for (var i = 0; i < this._len; i++) { + newData[i] = this.data[i]; + } + this.data = newData; + } + }, + + /** + * If needs js implemented dashed line + * @return {boolean} + * @private + */ + _needsDash: function () { + return this._lineDash; + }, + + _dashedLineTo: function (x1, y1) { + var dashSum = this._dashSum; + var offset = this._dashOffset; + var lineDash = this._lineDash; + var ctx = this._ctx; + + var x0 = this._xi; + var y0 = this._yi; + var dx = x1 - x0; + var dy = y1 - y0; + var dist = mathSqrt(dx * dx + dy * dy); + var x = x0; + var y = y0; + var dash; + var nDash = lineDash.length; + var idx; + dx /= dist; + dy /= dist; + + if (offset < 0) { + // Convert to positive offset + offset = dashSum + offset; + } + offset %= dashSum; + x -= offset * dx; + y -= offset * dy; + + while ((dx >= 0 && x <= x1) || (dx < 0 && x > x1)) { + idx = this._dashIdx; + dash = lineDash[idx]; + x += dx * dash; + y += dy * dash; + this._dashIdx = (idx + 1) % nDash; + // Skip positive offset + if ((dx > 0 && x < x0) || (dx < 0 && x > x0)) { + continue; + } + ctx[idx % 2 ? 'moveTo' : 'lineTo']( + dx >= 0 ? mathMin(x, x1) : mathMax(x, x1), + dy >= 0 ? mathMin(y, y1) : mathMax(y, y1) + ); + } + // Offset for next lineTo + dx = x - x1; + dy = y - y1; + this._dashOffset = -mathSqrt(dx * dx + dy * dy); + }, + + // Not accurate dashed line to + _dashedBezierTo: function (x1, y1, x2, y2, x3, y3) { + var dashSum = this._dashSum; + var offset = this._dashOffset; + var lineDash = this._lineDash; + var ctx = this._ctx; + + var x0 = this._xi; + var y0 = this._yi; + var t; + var dx; + var dy; + var cubicAt = curve.cubicAt; + var bezierLen = 0; + var idx = this._dashIdx; + var nDash = lineDash.length; + + var x; + var y; + + var tmpLen = 0; + + if (offset < 0) { + // Convert to positive offset + offset = dashSum + offset; + } + offset %= dashSum; + // Bezier approx length + for (t = 0; t < 1; t += 0.1) { + dx = cubicAt(x0, x1, x2, x3, t + 0.1) + - cubicAt(x0, x1, x2, x3, t); + dy = cubicAt(y0, y1, y2, y3, t + 0.1) + - cubicAt(y0, y1, y2, y3, t); + bezierLen += mathSqrt(dx * dx + dy * dy); + } + + // Find idx after add offset + for (; idx < nDash; idx++) { + tmpLen += lineDash[idx]; + if (tmpLen > offset) { + break; + } + } + t = (tmpLen - offset) / bezierLen; + + while (t <= 1) { + + x = cubicAt(x0, x1, x2, x3, t); + y = cubicAt(y0, y1, y2, y3, t); + + // Use line to approximate dashed bezier + // Bad result if dash is long + idx % 2 ? ctx.moveTo(x, y) + : ctx.lineTo(x, y); + + t += lineDash[idx] / bezierLen; + + idx = (idx + 1) % nDash; + } + + // Finish the last segment and calculate the new offset + (idx % 2 !== 0) && ctx.lineTo(x3, y3); + dx = x3 - x; + dy = y3 - y; + this._dashOffset = -mathSqrt(dx * dx + dy * dy); + }, + + _dashedQuadraticTo: function (x1, y1, x2, y2) { + // Convert quadratic to cubic using degree elevation + var x3 = x2; + var y3 = y2; + x2 = (x2 + 2 * x1) / 3; + y2 = (y2 + 2 * y1) / 3; + x1 = (this._xi + 2 * x1) / 3; + y1 = (this._yi + 2 * y1) / 3; + + this._dashedBezierTo(x1, y1, x2, y2, x3, y3); + }, + + /** + * 转成静态的 Float32Array 减少堆内存占用 + * Convert dynamic array to static Float32Array + */ + toStatic: function () { + var data = this.data; + if (data instanceof Array) { + data.length = this._len; + if (hasTypedArray) { + this.data = new Float32Array(data); + } + } + }, + + /** + * @return {module:zrender/core/BoundingRect} + */ + getBoundingRect: function () { + min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE; + max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE; + + var data = this.data; + var xi = 0; + var yi = 0; + var x0 = 0; + var y0 = 0; + + for (var i = 0; i < data.length;) { + var cmd = data[i++]; + + if (i == 1) { + // 如果第一个命令是 L, C, Q + // 则 previous point 同绘制命令的第一个 point + // + // 第一个命令为 Arc 的情况下会在后面特殊处理 + xi = data[i]; + yi = data[i + 1]; + + x0 = xi; + y0 = yi; + } + + switch (cmd) { + case CMD.M: + // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点 + // 在 closePath 的时候使用 + x0 = data[i++]; + y0 = data[i++]; + xi = x0; + yi = y0; + min2[0] = x0; + min2[1] = y0; + max2[0] = x0; + max2[1] = y0; + break; + case CMD.L: + bbox.fromLine(xi, yi, data[i], data[i + 1], min2, max2); + xi = data[i++]; + yi = data[i++]; + break; + case CMD.C: + bbox.fromCubic( + xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], + min2, max2 + ); + xi = data[i++]; + yi = data[i++]; + break; + case CMD.Q: + bbox.fromQuadratic( + xi, yi, data[i++], data[i++], data[i], data[i + 1], + min2, max2 + ); + xi = data[i++]; + yi = data[i++]; + break; + case CMD.A: + // TODO Arc 判断的开销比较大 + var cx = data[i++]; + var cy = data[i++]; + var rx = data[i++]; + var ry = data[i++]; + var startAngle = data[i++]; + var endAngle = data[i++] + startAngle; + // TODO Arc 旋转 + var psi = data[i++]; + var anticlockwise = 1 - data[i++]; + + if (i == 1) { + // 直接使用 arc 命令 + // 第一个命令起点还未定义 + x0 = mathCos(startAngle) * rx + cx; + y0 = mathSin(startAngle) * ry + cy; + } + + bbox.fromArc( + cx, cy, rx, ry, startAngle, endAngle, + anticlockwise, min2, max2 + ); + + xi = mathCos(endAngle) * rx + cx; + yi = mathSin(endAngle) * ry + cy; + break; + case CMD.R: + x0 = xi = data[i++]; + y0 = yi = data[i++]; + var width = data[i++]; + var height = data[i++]; + // Use fromLine + bbox.fromLine(x0, y0, x0 + width, y0 + height, min2, max2); + break; + case CMD.Z: + xi = x0; + yi = y0; + break; + } + + // Union + vec2.min(min, min, min2); + vec2.max(max, max, max2); + } + + // No data + if (i === 0) { + min[0] = min[1] = max[0] = max[1] = 0; + } + + return new BoundingRect( + min[0], min[1], max[0] - min[0], max[1] - min[1] + ); + }, + + /** + * Rebuild path from current data + * Rebuild path will not consider javascript implemented line dash. + * @param {CanvasRenderingContext} ctx + */ + rebuildPath: function (ctx) { + var d = this.data; + for (var i = 0; i < this._len;) { + var cmd = d[i++]; + switch (cmd) { + case CMD.M: + ctx.moveTo(d[i++], d[i++]); + break; + case CMD.L: + ctx.lineTo(d[i++], d[i++]); + break; + case CMD.C: + ctx.bezierCurveTo( + d[i++], d[i++], d[i++], d[i++], d[i++], d[i++] + ); + break; + case CMD.Q: + ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]); + break; + case CMD.A: + var cx = d[i++]; + var cy = d[i++]; + var rx = d[i++]; + var ry = d[i++]; + var theta = d[i++]; + var dTheta = d[i++]; + var psi = d[i++]; + var fs = d[i++]; + var r = (rx > ry) ? rx : ry; + var scaleX = (rx > ry) ? 1 : rx / ry; + var scaleY = (rx > ry) ? ry / rx : 1; + var isEllipse = Math.abs(rx - ry) > 1e-3; + if (isEllipse) { + ctx.translate(cx, cy); + ctx.rotate(psi); + ctx.scale(scaleX, scaleY); + ctx.arc(0, 0, r, theta, theta + dTheta, 1 - fs); + ctx.scale(1 / scaleX, 1 / scaleY); + ctx.rotate(-psi); + ctx.translate(-cx, -cy); + } + else { + ctx.arc(cx, cy, r, theta, theta + dTheta, 1 - fs); + } + break; + case CMD.R: + ctx.rect(d[i++], d[i++], d[i++], d[i++]); + break; + case CMD.Z: + ctx.closePath(); + } + } + } + }; + + PathProxy.CMD = CMD; + + module.exports = PathProxy; + + +/***/ }, +/* 49 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 曲线辅助模块 + * @module zrender/core/curve + * @author pissang(https://www.github.com/pissang) + */ + + + var vec2 = __webpack_require__(16); + var v2Create = vec2.create; + var v2DistSquare = vec2.distSquare; + var mathPow = Math.pow; + var mathSqrt = Math.sqrt; + + var EPSILON = 1e-4; + + var THREE_SQRT = mathSqrt(3); + var ONE_THIRD = 1 / 3; + + // 临时变量 + var _v0 = v2Create(); + var _v1 = v2Create(); + var _v2 = v2Create(); + // var _v3 = vec2.create(); + + function isAroundZero(val) { + return val > -EPSILON && val < EPSILON; + } + function isNotAroundZero(val) { + return val > EPSILON || val < -EPSILON; + } + /** + * 计算三次贝塞尔值 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @return {number} + */ + function cubicAt(p0, p1, p2, p3, t) { + var onet = 1 - t; + return onet * onet * (onet * p0 + 3 * t * p1) + + t * t * (t * p3 + 3 * onet * p2); + } + + /** + * 计算三次贝塞尔导数值 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @return {number} + */ + function cubicDerivativeAt(p0, p1, p2, p3, t) { + var onet = 1 - t; + return 3 * ( + ((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet + + (p3 - p2) * t * t + ); + } + + /** + * 计算三次贝塞尔方程根,使用盛金公式 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} val + * @param {Array.} roots + * @return {number} 有效根数目 + */ + function cubicRootAt(p0, p1, p2, p3, val, roots) { + // Evaluate roots of cubic functions + var a = p3 + 3 * (p1 - p2) - p0; + var b = 3 * (p2 - p1 * 2 + p0); + var c = 3 * (p1 - p0); + var d = p0 - val; + + var A = b * b - 3 * a * c; + var B = b * c - 9 * a * d; + var C = c * c - 3 * b * d; + + var n = 0; + + if (isAroundZero(A) && isAroundZero(B)) { + if (isAroundZero(b)) { + roots[0] = 0; + } + else { + var t1 = -c / b; //t1, t2, t3, b is not zero + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + } + } + else { + var disc = B * B - 4 * A * C; + + if (isAroundZero(disc)) { + var K = B / A; + var t1 = -b / a + K; // t1, a is not zero + var t2 = -K / 2; // t2, t3 + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + if (t2 >= 0 && t2 <= 1) { + roots[n++] = t2; + } + } + else if (disc > 0) { + var discSqrt = mathSqrt(disc); + var Y1 = A * b + 1.5 * a * (-B + discSqrt); + var Y2 = A * b + 1.5 * a * (-B - discSqrt); + if (Y1 < 0) { + Y1 = -mathPow(-Y1, ONE_THIRD); + } + else { + Y1 = mathPow(Y1, ONE_THIRD); + } + if (Y2 < 0) { + Y2 = -mathPow(-Y2, ONE_THIRD); + } + else { + Y2 = mathPow(Y2, ONE_THIRD); + } + var t1 = (-b - (Y1 + Y2)) / (3 * a); + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + } + else { + var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt(A * A * A)); + var theta = Math.acos(T) / 3; + var ASqrt = mathSqrt(A); + var tmp = Math.cos(theta); + + var t1 = (-b - 2 * ASqrt * tmp) / (3 * a); + var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a); + var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a); + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + if (t2 >= 0 && t2 <= 1) { + roots[n++] = t2; + } + if (t3 >= 0 && t3 <= 1) { + roots[n++] = t3; + } + } + } + return n; + } + + /** + * 计算三次贝塞尔方程极限值的位置 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {Array.} extrema + * @return {number} 有效数目 + */ + function cubicExtrema(p0, p1, p2, p3, extrema) { + var b = 6 * p2 - 12 * p1 + 6 * p0; + var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2; + var c = 3 * p1 - 3 * p0; + + var n = 0; + if (isAroundZero(a)) { + if (isNotAroundZero(b)) { + var t1 = -c / b; + if (t1 >= 0 && t1 <=1) { + extrema[n++] = t1; + } + } + } + else { + var disc = b * b - 4 * a * c; + if (isAroundZero(disc)) { + extrema[0] = -b / (2 * a); + } + else if (disc > 0) { + var discSqrt = mathSqrt(disc); + var t1 = (-b + discSqrt) / (2 * a); + var t2 = (-b - discSqrt) / (2 * a); + if (t1 >= 0 && t1 <= 1) { + extrema[n++] = t1; + } + if (t2 >= 0 && t2 <= 1) { + extrema[n++] = t2; + } + } + } + return n; + } + + /** + * 细分三次贝塞尔曲线 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @param {Array.} out + */ + function cubicSubdivide(p0, p1, p2, p3, t, out) { + var p01 = (p1 - p0) * t + p0; + var p12 = (p2 - p1) * t + p1; + var p23 = (p3 - p2) * t + p2; + + var p012 = (p12 - p01) * t + p01; + var p123 = (p23 - p12) * t + p12; + + var p0123 = (p123 - p012) * t + p012; + // Seg0 + out[0] = p0; + out[1] = p01; + out[2] = p012; + out[3] = p0123; + // Seg1 + out[4] = p0123; + out[5] = p123; + out[6] = p23; + out[7] = p3; + } + + /** + * 投射点到三次贝塞尔曲线上,返回投射距离。 + * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x3 + * @param {number} y3 + * @param {number} x + * @param {number} y + * @param {Array.} [out] 投射点 + * @return {number} + */ + function cubicProjectPoint( + x0, y0, x1, y1, x2, y2, x3, y3, + x, y, out + ) { + // http://pomax.github.io/bezierinfo/#projections + var t; + var interval = 0.005; + var d = Infinity; + var prev; + var next; + var d1; + var d2; + + _v0[0] = x; + _v0[1] = y; + + // 先粗略估计一下可能的最小距离的 t 值 + // PENDING + for (var _t = 0; _t < 1; _t += 0.05) { + _v1[0] = cubicAt(x0, x1, x2, x3, _t); + _v1[1] = cubicAt(y0, y1, y2, y3, _t); + d1 = v2DistSquare(_v0, _v1); + if (d1 < d) { + t = _t; + d = d1; + } + } + d = Infinity; + + // At most 32 iteration + for (var i = 0; i < 32; i++) { + if (interval < EPSILON) { + break; + } + prev = t - interval; + next = t + interval; + // t - interval + _v1[0] = cubicAt(x0, x1, x2, x3, prev); + _v1[1] = cubicAt(y0, y1, y2, y3, prev); + + d1 = v2DistSquare(_v1, _v0); + + if (prev >= 0 && d1 < d) { + t = prev; + d = d1; + } + else { + // t + interval + _v2[0] = cubicAt(x0, x1, x2, x3, next); + _v2[1] = cubicAt(y0, y1, y2, y3, next); + d2 = v2DistSquare(_v2, _v0); + + if (next <= 1 && d2 < d) { + t = next; + d = d2; + } + else { + interval *= 0.5; + } + } + } + // t + if (out) { + out[0] = cubicAt(x0, x1, x2, x3, t); + out[1] = cubicAt(y0, y1, y2, y3, t); + } + // console.log(interval, i); + return mathSqrt(d); + } + + /** + * 计算二次方贝塞尔值 + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} t + * @return {number} + */ + function quadraticAt(p0, p1, p2, t) { + var onet = 1 - t; + return onet * (onet * p0 + 2 * t * p1) + t * t * p2; + } + + /** + * 计算二次方贝塞尔导数值 + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} t + * @return {number} + */ + function quadraticDerivativeAt(p0, p1, p2, t) { + return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1)); + } + + /** + * 计算二次方贝塞尔方程根 + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} t + * @param {Array.} roots + * @return {number} 有效根数目 + */ + function quadraticRootAt(p0, p1, p2, val, roots) { + var a = p0 - 2 * p1 + p2; + var b = 2 * (p1 - p0); + var c = p0 - val; + + var n = 0; + if (isAroundZero(a)) { + if (isNotAroundZero(b)) { + var t1 = -c / b; + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + } + } + else { + var disc = b * b - 4 * a * c; + if (isAroundZero(disc)) { + var t1 = -b / (2 * a); + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + } + else if (disc > 0) { + var discSqrt = mathSqrt(disc); + var t1 = (-b + discSqrt) / (2 * a); + var t2 = (-b - discSqrt) / (2 * a); + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + if (t2 >= 0 && t2 <= 1) { + roots[n++] = t2; + } + } + } + return n; + } + + /** + * 计算二次贝塞尔方程极限值 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @return {number} + */ + function quadraticExtremum(p0, p1, p2) { + var divider = p0 + p2 - 2 * p1; + if (divider === 0) { + // p1 is center of p0 and p2 + return 0.5; + } + else { + return (p0 - p1) / divider; + } + } + + /** + * 细分二次贝塞尔曲线 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} t + * @param {Array.} out + */ + function quadraticSubdivide(p0, p1, p2, t, out) { + var p01 = (p1 - p0) * t + p0; + var p12 = (p2 - p1) * t + p1; + var p012 = (p12 - p01) * t + p01; + + // Seg0 + out[0] = p0; + out[1] = p01; + out[2] = p012; + + // Seg1 + out[3] = p012; + out[4] = p12; + out[5] = p2; + } + + /** + * 投射点到二次贝塞尔曲线上,返回投射距离。 + * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x + * @param {number} y + * @param {Array.} out 投射点 + * @return {number} + */ + function quadraticProjectPoint( + x0, y0, x1, y1, x2, y2, + x, y, out + ) { + // http://pomax.github.io/bezierinfo/#projections + var t; + var interval = 0.005; + var d = Infinity; + + _v0[0] = x; + _v0[1] = y; + + // 先粗略估计一下可能的最小距离的 t 值 + // PENDING + for (var _t = 0; _t < 1; _t += 0.05) { + _v1[0] = quadraticAt(x0, x1, x2, _t); + _v1[1] = quadraticAt(y0, y1, y2, _t); + var d1 = v2DistSquare(_v0, _v1); + if (d1 < d) { + t = _t; + d = d1; + } + } + d = Infinity; + + // At most 32 iteration + for (var i = 0; i < 32; i++) { + if (interval < EPSILON) { + break; + } + var prev = t - interval; + var next = t + interval; + // t - interval + _v1[0] = quadraticAt(x0, x1, x2, prev); + _v1[1] = quadraticAt(y0, y1, y2, prev); + + var d1 = v2DistSquare(_v1, _v0); + + if (prev >= 0 && d1 < d) { + t = prev; + d = d1; + } + else { + // t + interval + _v2[0] = quadraticAt(x0, x1, x2, next); + _v2[1] = quadraticAt(y0, y1, y2, next); + var d2 = v2DistSquare(_v2, _v0); + if (next <= 1 && d2 < d) { + t = next; + d = d2; + } + else { + interval *= 0.5; + } + } + } + // t + if (out) { + out[0] = quadraticAt(x0, x1, x2, t); + out[1] = quadraticAt(y0, y1, y2, t); + } + // console.log(interval, i); + return mathSqrt(d); + } + + module.exports = { + + cubicAt: cubicAt, + + cubicDerivativeAt: cubicDerivativeAt, + + cubicRootAt: cubicRootAt, + + cubicExtrema: cubicExtrema, + + cubicSubdivide: cubicSubdivide, + + cubicProjectPoint: cubicProjectPoint, + + quadraticAt: quadraticAt, + + quadraticDerivativeAt: quadraticDerivativeAt, + + quadraticRootAt: quadraticRootAt, + + quadraticExtremum: quadraticExtremum, + + quadraticSubdivide: quadraticSubdivide, + + quadraticProjectPoint: quadraticProjectPoint + }; + + +/***/ }, +/* 50 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @author Yi Shen(https://github.com/pissang) + */ + + + var vec2 = __webpack_require__(16); + var curve = __webpack_require__(49); + + var bbox = {}; + var mathMin = Math.min; + var mathMax = Math.max; + var mathSin = Math.sin; + var mathCos = Math.cos; + + var start = vec2.create(); + var end = vec2.create(); + var extremity = vec2.create(); + + var PI2 = Math.PI * 2; + /** + * 从顶点数组中计算出最小包围盒,写入`min`和`max`中 + * @module zrender/core/bbox + * @param {Array} points 顶点数组 + * @param {number} min + * @param {number} max + */ + bbox.fromPoints = function(points, min, max) { + if (points.length === 0) { + return; + } + var p = points[0]; + var left = p[0]; + var right = p[0]; + var top = p[1]; + var bottom = p[1]; + var i; + + for (i = 1; i < points.length; i++) { + p = points[i]; + left = mathMin(left, p[0]); + right = mathMax(right, p[0]); + top = mathMin(top, p[1]); + bottom = mathMax(bottom, p[1]); + } + + min[0] = left; + min[1] = top; + max[0] = right; + max[1] = bottom; + }; + + /** + * @memberOf module:zrender/core/bbox + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {Array.} min + * @param {Array.} max + */ + bbox.fromLine = function (x0, y0, x1, y1, min, max) { + min[0] = mathMin(x0, x1); + min[1] = mathMin(y0, y1); + max[0] = mathMax(x0, x1); + max[1] = mathMax(y0, y1); + }; + + /** + * 从三阶贝塞尔曲线(p0, p1, p2, p3)中计算出最小包围盒,写入`min`和`max`中 + * @memberOf module:zrender/core/bbox + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x3 + * @param {number} y3 + * @param {Array.} min + * @param {Array.} max + */ + bbox.fromCubic = function( + x0, y0, x1, y1, x2, y2, x3, y3, min, max + ) { + var xDim = []; + var yDim = []; + var cubicExtrema = curve.cubicExtrema; + var cubicAt = curve.cubicAt; + var left, right, top, bottom; + var i; + var n = cubicExtrema(x0, x1, x2, x3, xDim); + + for (i = 0; i < n; i++) { + xDim[i] = cubicAt(x0, x1, x2, x3, xDim[i]); + } + n = cubicExtrema(y0, y1, y2, y3, yDim); + for (i = 0; i < n; i++) { + yDim[i] = cubicAt(y0, y1, y2, y3, yDim[i]); + } + + xDim.push(x0, x3); + yDim.push(y0, y3); + + left = mathMin.apply(null, xDim); + right = mathMax.apply(null, xDim); + top = mathMin.apply(null, yDim); + bottom = mathMax.apply(null, yDim); + + min[0] = left; + min[1] = top; + max[0] = right; + max[1] = bottom; + }; + + /** + * 从二阶贝塞尔曲线(p0, p1, p2)中计算出最小包围盒,写入`min`和`max`中 + * @memberOf module:zrender/core/bbox + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {Array.} min + * @param {Array.} max + */ + bbox.fromQuadratic = function(x0, y0, x1, y1, x2, y2, min, max) { + var quadraticExtremum = curve.quadraticExtremum; + var quadraticAt = curve.quadraticAt; + // Find extremities, where derivative in x dim or y dim is zero + var tx = + mathMax( + mathMin(quadraticExtremum(x0, x1, x2), 1), 0 + ); + var ty = + mathMax( + mathMin(quadraticExtremum(y0, y1, y2), 1), 0 + ); + + var x = quadraticAt(x0, x1, x2, tx); + var y = quadraticAt(y0, y1, y2, ty); + + min[0] = mathMin(x0, x2, x); + min[1] = mathMin(y0, y2, y); + max[0] = mathMax(x0, x2, x); + max[1] = mathMax(y0, y2, y); + }; + + /** + * 从圆弧中计算出最小包围盒,写入`min`和`max`中 + * @method + * @memberOf module:zrender/core/bbox + * @param {number} x + * @param {number} y + * @param {number} rx + * @param {number} ry + * @param {number} startAngle + * @param {number} endAngle + * @param {number} anticlockwise + * @param {Array.} min + * @param {Array.} max + */ + bbox.fromArc = function ( + x, y, rx, ry, startAngle, endAngle, anticlockwise, min, max + ) { + var vec2Min = vec2.min; + var vec2Max = vec2.max; + + var diff = Math.abs(startAngle - endAngle); + + + if (diff % PI2 < 1e-4 && diff > 1e-4) { + // Is a circle + min[0] = x - rx; + min[1] = y - ry; + max[0] = x + rx; + max[1] = y + ry; + return; + } + + start[0] = mathCos(startAngle) * rx + x; + start[1] = mathSin(startAngle) * ry + y; + + end[0] = mathCos(endAngle) * rx + x; + end[1] = mathSin(endAngle) * ry + y; + + vec2Min(min, start, end); + vec2Max(max, start, end); + + // Thresh to [0, Math.PI * 2] + startAngle = startAngle % (PI2); + if (startAngle < 0) { + startAngle = startAngle + PI2; + } + endAngle = endAngle % (PI2); + if (endAngle < 0) { + endAngle = endAngle + PI2; + } + + if (startAngle > endAngle && !anticlockwise) { + endAngle += PI2; + } + else if (startAngle < endAngle && anticlockwise) { + startAngle += PI2; + } + if (anticlockwise) { + var tmp = endAngle; + endAngle = startAngle; + startAngle = tmp; + } + + // var number = 0; + // var step = (anticlockwise ? -Math.PI : Math.PI) / 2; + for (var angle = 0; angle < endAngle; angle += Math.PI / 2) { + if (angle > startAngle) { + extremity[0] = mathCos(angle) * rx + x; + extremity[1] = mathSin(angle) * ry + y; + + vec2Min(min, extremity, min); + vec2Max(max, extremity, max); + } + } + }; + + module.exports = bbox; + + + +/***/ }, +/* 51 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var CMD = __webpack_require__(48).CMD; + var line = __webpack_require__(52); + var cubic = __webpack_require__(53); + var quadratic = __webpack_require__(54); + var arc = __webpack_require__(55); + var normalizeRadian = __webpack_require__(56).normalizeRadian; + var curve = __webpack_require__(49); + + var windingLine = __webpack_require__(57); + + var containStroke = line.containStroke; + + var PI2 = Math.PI * 2; + + var EPSILON = 1e-4; + + function isAroundEqual(a, b) { + return Math.abs(a - b) < EPSILON; + } + + // 临时数组 + var roots = [-1, -1, -1]; + var extrema = [-1, -1]; + + function swapExtrema() { + var tmp = extrema[0]; + extrema[0] = extrema[1]; + extrema[1] = tmp; + } + + function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) { + // Quick reject + if ( + (y > y0 && y > y1 && y > y2 && y > y3) + || (y < y0 && y < y1 && y < y2 && y < y3) + ) { + return 0; + } + var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots); + if (nRoots === 0) { + return 0; + } + else { + var w = 0; + var nExtrema = -1; + var y0_, y1_; + for (var i = 0; i < nRoots; i++) { + var t = roots[i]; + var x_ = curve.cubicAt(x0, x1, x2, x3, t); + if (x_ < x) { // Quick reject + continue; + } + if (nExtrema < 0) { + nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema); + if (extrema[1] < extrema[0] && nExtrema > 1) { + swapExtrema(); + } + y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]); + if (nExtrema > 1) { + y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]); + } + } + if (nExtrema == 2) { + // 分成三段单调函数 + if (t < extrema[0]) { + w += y0_ < y0 ? 1 : -1; + } + else if (t < extrema[1]) { + w += y1_ < y0_ ? 1 : -1; + } + else { + w += y3 < y1_ ? 1 : -1; + } + } + else { + // 分成两段单调函数 + if (t < extrema[0]) { + w += y0_ < y0 ? 1 : -1; + } + else { + w += y3 < y0_ ? 1 : -1; + } + } + } + return w; + } + } + + function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) { + // Quick reject + if ( + (y > y0 && y > y1 && y > y2) + || (y < y0 && y < y1 && y < y2) + ) { + return 0; + } + var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots); + if (nRoots === 0) { + return 0; + } + else { + var t = curve.quadraticExtremum(y0, y1, y2); + if (t >=0 && t <= 1) { + var w = 0; + var y_ = curve.quadraticAt(y0, y1, y2, t); + for (var i = 0; i < nRoots; i++) { + var x_ = curve.quadraticAt(x0, x1, x2, roots[i]); + if (x_ > x) { + continue; + } + if (roots[i] < t) { + w += y_ < y0 ? 1 : -1; + } + else { + w += y2 < y_ ? 1 : -1; + } + } + return w; + } + else { + var x_ = curve.quadraticAt(x0, x1, x2, roots[0]); + if (x_ > x) { + return 0; + } + return y2 < y0 ? 1 : -1; + } + } + } + + // TODO + // Arc 旋转 + function windingArc( + cx, cy, r, startAngle, endAngle, anticlockwise, x, y + ) { + y -= cy; + if (y > r || y < -r) { + return 0; + } + var tmp = Math.sqrt(r * r - y * y); + roots[0] = -tmp; + roots[1] = tmp; + + var diff = Math.abs(startAngle - endAngle); + if (diff < 1e-4) { + return 0; + } + if (diff % PI2 < 1e-4) { + // Is a circle + startAngle = 0; + endAngle = PI2; + var dir = anticlockwise ? 1 : -1; + if (x >= roots[0] + cx && x <= roots[1] + cx) { + return dir; + } else { + return 0; + } + } + + if (anticlockwise) { + var tmp = startAngle; + startAngle = normalizeRadian(endAngle); + endAngle = normalizeRadian(tmp); + } + else { + startAngle = normalizeRadian(startAngle); + endAngle = normalizeRadian(endAngle); + } + if (startAngle > endAngle) { + endAngle += PI2; + } + + var w = 0; + for (var i = 0; i < 2; i++) { + var x_ = roots[i]; + if (x_ + cx > x) { + var angle = Math.atan2(y, x_); + var dir = anticlockwise ? 1 : -1; + if (angle < 0) { + angle = PI2 + angle; + } + if ( + (angle >= startAngle && angle <= endAngle) + || (angle + PI2 >= startAngle && angle + PI2 <= endAngle) + ) { + if (angle > Math.PI / 2 && angle < Math.PI * 1.5) { + dir = -dir; + } + w += dir; + } + } + } + return w; + } + + function containPath(data, lineWidth, isStroke, x, y) { + var w = 0; + var xi = 0; + var yi = 0; + var x0 = 0; + var y0 = 0; + + for (var i = 0; i < data.length;) { + var cmd = data[i++]; + // Begin a new subpath + if (cmd === CMD.M && i > 1) { + // Close previous subpath + if (!isStroke) { + w += windingLine(xi, yi, x0, y0, x, y); + } + // 如果被任何一个 subpath 包含 + if (w !== 0) { + return true; + } + } + + if (i == 1) { + // 如果第一个命令是 L, C, Q + // 则 previous point 同绘制命令的第一个 point + // + // 第一个命令为 Arc 的情况下会在后面特殊处理 + xi = data[i]; + yi = data[i + 1]; + + x0 = xi; + y0 = yi; + } + + switch (cmd) { + case CMD.M: + // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点 + // 在 closePath 的时候使用 + x0 = data[i++]; + y0 = data[i++]; + xi = x0; + yi = y0; + break; + case CMD.L: + if (isStroke) { + if (containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) { + return true; + } + } + else { + // NOTE 在第一个命令为 L, C, Q 的时候会计算出 NaN + w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0; + } + xi = data[i++]; + yi = data[i++]; + break; + case CMD.C: + if (isStroke) { + if (cubic.containStroke(xi, yi, + data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], + lineWidth, x, y + )) { + return true; + } + } + else { + w += windingCubic( + xi, yi, + data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], + x, y + ) || 0; + } + xi = data[i++]; + yi = data[i++]; + break; + case CMD.Q: + if (isStroke) { + if (quadratic.containStroke(xi, yi, + data[i++], data[i++], data[i], data[i + 1], + lineWidth, x, y + )) { + return true; + } + } + else { + w += windingQuadratic( + xi, yi, + data[i++], data[i++], data[i], data[i + 1], + x, y + ) || 0; + } + xi = data[i++]; + yi = data[i++]; + break; + case CMD.A: + // TODO Arc 判断的开销比较大 + var cx = data[i++]; + var cy = data[i++]; + var rx = data[i++]; + var ry = data[i++]; + var theta = data[i++]; + var dTheta = data[i++]; + // TODO Arc 旋转 + var psi = data[i++]; + var anticlockwise = 1 - data[i++]; + var x1 = Math.cos(theta) * rx + cx; + var y1 = Math.sin(theta) * ry + cy; + // 不是直接使用 arc 命令 + if (i > 1) { + w += windingLine(xi, yi, x1, y1, x, y); + } + else { + // 第一个命令起点还未定义 + x0 = x1; + y0 = y1; + } + // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放 + var _x = (x - cx) * ry / rx + cx; + if (isStroke) { + if (arc.containStroke( + cx, cy, ry, theta, theta + dTheta, anticlockwise, + lineWidth, _x, y + )) { + return true; + } + } + else { + w += windingArc( + cx, cy, ry, theta, theta + dTheta, anticlockwise, + _x, y + ); + } + xi = Math.cos(theta + dTheta) * rx + cx; + yi = Math.sin(theta + dTheta) * ry + cy; + break; + case CMD.R: + x0 = xi = data[i++]; + y0 = yi = data[i++]; + var width = data[i++]; + var height = data[i++]; + var x1 = x0 + width; + var y1 = y0 + height; + if (isStroke) { + if (containStroke(x0, y0, x1, y0, lineWidth, x, y) + || containStroke(x1, y0, x1, y1, lineWidth, x, y) + || containStroke(x1, y1, x0, y1, lineWidth, x, y) + || containStroke(x0, y1, x1, y1, lineWidth, x, y) + ) { + return true; + } + } + else { + // FIXME Clockwise ? + w += windingLine(x1, y0, x1, y1, x, y); + w += windingLine(x0, y1, x0, y0, x, y); + } + break; + case CMD.Z: + if (isStroke) { + if (containStroke( + xi, yi, x0, y0, lineWidth, x, y + )) { + return true; + } + } + else { + // Close a subpath + w += windingLine(xi, yi, x0, y0, x, y); + // 如果被任何一个 subpath 包含 + if (w !== 0) { + return true; + } + } + xi = x0; + yi = y0; + break; + } + } + if (!isStroke && !isAroundEqual(yi, y0)) { + w += windingLine(xi, yi, x0, y0, x, y) || 0; + } + return w !== 0; + } + + module.exports = { + contain: function (pathData, x, y) { + return containPath(pathData, 0, false, x, y); + }, + + containStroke: function (pathData, lineWidth, x, y) { + return containPath(pathData, lineWidth, true, x, y); + } + }; + + +/***/ }, +/* 52 */ +/***/ function(module, exports) { + + + module.exports = { + /** + * 线段包含判断 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} lineWidth + * @param {number} x + * @param {number} y + * @return {boolean} + */ + containStroke: function (x0, y0, x1, y1, lineWidth, x, y) { + if (lineWidth === 0) { + return false; + } + var _l = lineWidth; + var _a = 0; + var _b = x0; + // Quick reject + 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) + ) { + return false; + } + + if (x0 !== x1) { + _a = (y0 - y1) / (x0 - x1); + _b = (x0 * y1 - x1 * y0) / (x0 - x1) ; + } + else { + return Math.abs(x - x0) <= _l / 2; + } + var tmp = _a * x - y + _b; + var _s = tmp * tmp / (_a * _a + 1); + return _s <= _l / 2 * _l / 2; + } + }; + + +/***/ }, +/* 53 */ +/***/ function(module, exports, __webpack_require__) { + + + + var curve = __webpack_require__(49); + + module.exports = { + /** + * 三次贝塞尔曲线描边包含判断 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x3 + * @param {number} y3 + * @param {number} lineWidth + * @param {number} x + * @param {number} y + * @return {boolean} + */ + containStroke: function(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) { + if (lineWidth === 0) { + return false; + } + var _l = lineWidth; + // Quick reject + 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) + ) { + return false; + } + var d = curve.cubicProjectPoint( + x0, y0, x1, y1, x2, y2, x3, y3, + x, y, null + ); + return d <= _l / 2; + } + }; + + +/***/ }, +/* 54 */ +/***/ function(module, exports, __webpack_require__) { + + + + var curve = __webpack_require__(49); + + module.exports = { + /** + * 二次贝塞尔曲线描边包含判断 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} lineWidth + * @param {number} x + * @param {number} y + * @return {boolean} + */ + containStroke: function (x0, y0, x1, y1, x2, y2, lineWidth, x, y) { + if (lineWidth === 0) { + return false; + } + var _l = lineWidth; + // Quick reject + 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) + ) { + return false; + } + var d = curve.quadraticProjectPoint( + x0, y0, x1, y1, x2, y2, + x, y, null + ); + return d <= _l / 2; + } + }; + + +/***/ }, +/* 55 */ +/***/ function(module, exports, __webpack_require__) { + + + + var normalizeRadian = __webpack_require__(56).normalizeRadian; + var PI2 = Math.PI * 2; + + module.exports = { + /** + * 圆弧描边包含判断 + * @param {number} cx + * @param {number} cy + * @param {number} r + * @param {number} startAngle + * @param {number} endAngle + * @param {boolean} anticlockwise + * @param {number} lineWidth + * @param {number} x + * @param {number} y + * @return {Boolean} + */ + containStroke: function ( + cx, cy, r, startAngle, endAngle, anticlockwise, + lineWidth, x, y + ) { + + if (lineWidth === 0) { + return false; + } + var _l = lineWidth; + + x -= cx; + y -= cy; + var d = Math.sqrt(x * x + y * y); + + if ((d - _l > r) || (d + _l < r)) { + return false; + } + if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) { + // Is a circle + return true; + } + if (anticlockwise) { + var tmp = startAngle; + startAngle = normalizeRadian(endAngle); + endAngle = normalizeRadian(tmp); + } else { + startAngle = normalizeRadian(startAngle); + endAngle = normalizeRadian(endAngle); + } + if (startAngle > endAngle) { + endAngle += PI2; + } + + var angle = Math.atan2(y, x); + if (angle < 0) { + angle += PI2; + } + return (angle >= startAngle && angle <= endAngle) + || (angle + PI2 >= startAngle && angle + PI2 <= endAngle); + } + }; + + +/***/ }, +/* 56 */ +/***/ function(module, exports) { + + + + var PI2 = Math.PI * 2; + module.exports = { + normalizeRadian: function(angle) { + angle %= PI2; + if (angle < 0) { + angle += PI2; + } + return angle; + } + }; + + +/***/ }, +/* 57 */ +/***/ function(module, exports) { + + + module.exports = function windingLine(x0, y0, x1, y1, x, y) { + if ((y > y0 && y > y1) || (y < y0 && y < y1)) { + return 0; + } + if (y1 === y0) { + return 0; + } + var dir = y1 < y0 ? 1 : -1; + var t = (y - y0) / (y1 - y0); + var x_ = t * (x1 - x0) + x0; + + return x_ > x ? dir : 0; + }; + + +/***/ }, +/* 58 */ +/***/ function(module, exports, __webpack_require__) { + + + + var CMD = __webpack_require__(48).CMD; + var vec2 = __webpack_require__(16); + var v2ApplyTransform = vec2.applyTransform; + + var points = [[], [], []]; + var mathSqrt = Math.sqrt; + var mathAtan2 = Math.atan2; + function transformPath(path, m) { + var data = path.data; + var cmd; + var nPoint; + var i; + var j; + var k; + var p; + + var M = CMD.M; + var C = CMD.C; + var L = CMD.L; + var R = CMD.R; + var A = CMD.A; + var Q = CMD.Q; + + for (i = 0, j = 0; i < data.length;) { + cmd = data[i++]; + j = i; + nPoint = 0; + + switch (cmd) { + case M: + nPoint = 1; + break; + case L: + nPoint = 1; + break; + case C: + nPoint = 3; + break; + case Q: + nPoint = 2; + break; + case A: + var x = m[4]; + var y = m[5]; + var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]); + var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]); + var angle = mathAtan2(-m[1] / sy, m[0] / sx); + // cx + data[i++] += x; + // cy + data[i++] += y; + // Scale rx and ry + // FIXME Assume psi is 0 here + data[i++] *= sx; + data[i++] *= sy; + + // Start angle + data[i++] += angle; + // end angle + data[i++] += angle; + // FIXME psi + i += 2; + j = i; + break; + case R: + // x0, y0 + p[0] = data[i++]; + p[1] = data[i++]; + v2ApplyTransform(p, p, m); + data[j++] = p[0]; + data[j++] = p[1]; + // x1, y1 + p[0] += data[i++]; + p[1] += data[i++]; + v2ApplyTransform(p, p, m); + data[j++] = p[0]; + data[j++] = p[1]; + } + + for (k = 0; k < nPoint; k++) { + var p = points[k]; + p[0] = data[i++]; + p[1] = data[i++]; + + v2ApplyTransform(p, p, m); + // Write back + data[j++] = p[0]; + data[j++] = p[1]; + } + } + } + + module.exports = transformPath; + + +/***/ }, +/* 59 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Image element + * @module zrender/graphic/Image + */ + + + + var Displayable = __webpack_require__(45); + var BoundingRect = __webpack_require__(15); + var zrUtil = __webpack_require__(3); + var roundRectHelper = __webpack_require__(60); + + var LRU = __webpack_require__(61); + var globalImageCache = new LRU(50); + /** + * @alias zrender/graphic/Image + * @extends module:zrender/graphic/Displayable + * @constructor + * @param {Object} opts + */ + var ZImage = function (opts) { + Displayable.call(this, opts); + }; + + ZImage.prototype = { + + constructor: ZImage, + + type: 'image', + + brush: function (ctx) { + var style = this.style; + var src = style.image; + var image; + // style.image is a url string + if (typeof src === 'string') { + image = this._image; + } + // style.image is an HTMLImageElement or HTMLCanvasElement or Canvas + else { + image = src; + } + // FIXME Case create many images with src + if (!image && src) { + // Try get from global image cache + var cachedImgObj = globalImageCache.get(src); + if (!cachedImgObj) { + // Create a new image + image = new Image(); + image.onload = function () { + image.onload = null; + for (var i = 0; i < cachedImgObj.pending.length; i++) { + cachedImgObj.pending[i].dirty(); + } + }; + cachedImgObj = { + image: image, + pending: [this] + }; + image.src = src; + globalImageCache.put(src, cachedImgObj); + this._image = image; + return; + } + else { + image = cachedImgObj.image; + this._image = image; + // Image is not complete finish, add to pending list + if (!image.width || !image.height) { + cachedImgObj.pending.push(this); + return; + } + } + } + + if (image) { + // 图片已经加载完成 + // if (image.nodeName.toUpperCase() == 'IMG') { + // if (!image.complete) { + // return; + // } + // } + // Else is canvas + + var width = style.width || image.width; + var height = style.height || image.height; + var x = style.x || 0; + var y = style.y || 0; + // 图片加载失败 + if (!image.width || !image.height) { + return; + } + + ctx.save(); + + style.bind(ctx); + + // 设置transform + this.setTransform(ctx); + + if (style.r) { + // Border radius clipping + // FIXME + ctx.beginPath(); + roundRectHelper.buildPath(ctx, style); + ctx.clip(); + } + + if (style.sWidth && style.sHeight) { + var sx = style.sx || 0; + var sy = style.sy || 0; + ctx.drawImage( + image, + sx, sy, style.sWidth, style.sHeight, + x, y, width, height + ); + } + else if (style.sx && style.sy) { + var sx = style.sx; + var sy = style.sy; + var sWidth = width - sx; + var sHeight = height - sy; + ctx.drawImage( + image, + sx, sy, sWidth, sHeight, + x, y, width, height + ); + } + else { + ctx.drawImage(image, x, y, width, height); + } + + // 如果没设置宽和高的话自动根据图片宽高设置 + if (style.width == null) { + style.width = width; + } + if (style.height == null) { + style.height = height; + } + + // Draw rect text + if (style.text != null) { + this.drawRectText(ctx, this.getBoundingRect()); + } + + ctx.restore(); + } + }, + + getBoundingRect: function () { + var style = this.style; + if (! this._rect) { + this._rect = new BoundingRect( + style.x || 0, style.y || 0, style.width || 0, style.height || 0 + ); + } + return this._rect; + } + }; + + zrUtil.inherits(ZImage, Displayable); + + module.exports = ZImage; + + +/***/ }, +/* 60 */ +/***/ function(module, exports) { + + + + module.exports = { + buildPath: function (ctx, shape) { + var x = shape.x; + var y = shape.y; + var width = shape.width; + var height = shape.height; + var r = shape.r; + var r1; + var r2; + var r3; + var r4; + + // Convert width and height to positive for better borderRadius + if (width < 0) { + x = x + width; + width = -width; + } + if (height < 0) { + y = y + height; + height = -height; + } + + if (typeof r === 'number') { + r1 = r2 = r3 = r4 = r; + } + else if (r instanceof Array) { + if (r.length === 1) { + r1 = r2 = r3 = r4 = r[0]; + } + else if (r.length === 2) { + r1 = r3 = r[0]; + r2 = r4 = r[1]; + } + else if (r.length === 3) { + r1 = r[0]; + r2 = r4 = r[1]; + r3 = r[2]; + } + else { + r1 = r[0]; + r2 = r[1]; + r3 = r[2]; + r4 = r[3]; + } + } + else { + r1 = r2 = r3 = r4 = 0; + } + + var total; + if (r1 + r2 > width) { + total = r1 + r2; + r1 *= width / total; + r2 *= width / total; + } + if (r3 + r4 > width) { + total = r3 + r4; + r3 *= width / total; + r4 *= width / total; + } + if (r2 + r3 > height) { + total = r2 + r3; + r2 *= height / total; + r3 *= height / total; + } + if (r1 + r4 > height) { + total = r1 + r4; + r1 *= height / total; + r4 *= height / total; + } + ctx.moveTo(x + r1, y); + ctx.lineTo(x + width - r2, y); + r2 !== 0 && ctx.quadraticCurveTo( + x + width, y, x + width, y + r2 + ); + ctx.lineTo(x + width, y + height - r3); + r3 !== 0 && ctx.quadraticCurveTo( + x + width, y + height, x + width - r3, y + height + ); + ctx.lineTo(x + r4, y + height); + r4 !== 0 && ctx.quadraticCurveTo( + x, y + height, x, y + height - r4 + ); + ctx.lineTo(x, y + r1); + r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y); + } + }; + + +/***/ }, +/* 61 */ +/***/ function(module, exports) { + + // Simple LRU cache use doubly linked list + // @module zrender/core/LRU + + + /** + * Simple double linked list. Compared with array, it has O(1) remove operation. + * @constructor + */ + var LinkedList = function() { + + /** + * @type {module:zrender/core/LRU~Entry} + */ + this.head = null; + + /** + * @type {module:zrender/core/LRU~Entry} + */ + this.tail = null; + + this._len = 0; + }; + + var linkedListProto = LinkedList.prototype; + /** + * Insert a new value at the tail + * @param {} val + * @return {module:zrender/core/LRU~Entry} + */ + linkedListProto.insert = function(val) { + var entry = new Entry(val); + this.insertEntry(entry); + return entry; + }; + + /** + * Insert an entry at the tail + * @param {module:zrender/core/LRU~Entry} entry + */ + linkedListProto.insertEntry = function(entry) { + if (!this.head) { + this.head = this.tail = entry; + } + else { + this.tail.next = entry; + entry.prev = this.tail; + this.tail = entry; + } + this._len++; + }; + + /** + * Remove entry. + * @param {module:zrender/core/LRU~Entry} entry + */ + linkedListProto.remove = function(entry) { + var prev = entry.prev; + var next = entry.next; + if (prev) { + prev.next = next; + } + else { + // Is head + this.head = next; + } + if (next) { + next.prev = prev; + } + else { + // Is tail + this.tail = prev; + } + entry.next = entry.prev = null; + this._len--; + }; + + /** + * @return {number} + */ + linkedListProto.len = function() { + return this._len; + }; + + /** + * @constructor + * @param {} val + */ + var Entry = function(val) { + /** + * @type {} + */ + this.value = val; + + /** + * @type {module:zrender/core/LRU~Entry} + */ + this.next; + + /** + * @type {module:zrender/core/LRU~Entry} + */ + this.prev; + }; + + /** + * LRU Cache + * @constructor + * @alias module:zrender/core/LRU + */ + var LRU = function(maxSize) { + + this._list = new LinkedList(); + + this._map = {}; + + this._maxSize = maxSize || 10; + }; + + var LRUProto = LRU.prototype; + + /** + * @param {string} key + * @param {} value + */ + LRUProto.put = function(key, value) { + var list = this._list; + var map = this._map; + if (map[key] == null) { + var len = list.len(); + if (len >= this._maxSize && len > 0) { + // Remove the least recently used + var leastUsedEntry = list.head; + list.remove(leastUsedEntry); + delete map[leastUsedEntry.key]; + } + + var entry = list.insert(value); + entry.key = key; + map[key] = entry; + } + }; + + /** + * @param {string} key + * @return {} + */ + LRUProto.get = function(key) { + var entry = this._map[key]; + var list = this._list; + if (entry != null) { + // Put the latest used entry in the tail + if (entry !== list.tail) { + list.remove(entry); + list.insertEntry(entry); + } + + return entry.value; + } + }; + + /** + * Clear the cache + */ + LRUProto.clear = function() { + this._list.clear(); + this._map = {}; + }; + + module.exports = LRU; + + +/***/ }, +/* 62 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Text element + * @module zrender/graphic/Text + * + * TODO Wrapping + */ + + + + var Displayable = __webpack_require__(45); + var zrUtil = __webpack_require__(3); + var textContain = __webpack_require__(14); + + /** + * @alias zrender/graphic/Text + * @extends module:zrender/graphic/Displayable + * @constructor + * @param {Object} opts + */ + var Text = function (opts) { + Displayable.call(this, opts); + }; + + Text.prototype = { + + constructor: Text, + + type: 'text', + + brush: function (ctx) { + var style = this.style; + var x = style.x || 0; + var y = style.y || 0; + // Convert to string + var text = style.text; + var textFill = style.fill; + var textStroke = style.stroke; + + // Convert to string + text != null && (text += ''); + + if (text) { + ctx.save(); + + this.style.bind(ctx); + this.setTransform(ctx); + + textFill && (ctx.fillStyle = textFill); + textStroke && (ctx.strokeStyle = textStroke); + + ctx.font = style.textFont || style.font; + ctx.textAlign = style.textAlign; + + if (style.textVerticalAlign) { + var rect = textContain.getBoundingRect( + text, ctx.font, style.textAlign, 'top' + ); + // Ignore textBaseline + ctx.textBaseline = 'top'; + switch (style.textVerticalAlign) { + case 'middle': + y -= rect.height / 2; + break; + case 'bottom': + y -= rect.height; + break; + // 'top' + } + } + else { + ctx.textBaseline = style.textBaseline; + } + var lineHeight = textContain.measureText('国', ctx.font).width; -/** - * 数值处理模块 - * @module echarts/util/number - */ - -define('echarts/util/number',['require'],function (require) { - - var number = {}; - - var RADIAN_EPSILON = 1e-4; - - function _trim(str) { - return str.replace(/^\s+/, '').replace(/\s+$/, ''); - } - - /** - * Linear mapping a value from domain to range - * @memberOf module:echarts/util/number - * @param {(number|Array.)} val - * @param {Array.} domain Domain extent domain[0] can be bigger than domain[1] - * @param {Array.} range Range extent range[0] can be bigger than range[1] - * @param {boolean} clamp - * @return {(number|Array.} - */ - number.linearMap = function (val, domain, range, clamp) { - - var sub = domain[1] - domain[0]; - - if (sub === 0) { - return (range[0] + range[1]) / 2; - } - var t = (val - domain[0]) / sub; - - if (clamp) { - t = Math.min(Math.max(t, 0), 1); - } - - return t * (range[1] - range[0]) + range[0]; - }; - - /** - * Convert a percent string to absolute number. - * Returns NaN if percent is not a valid string or number - * @memberOf module:echarts/util/number - * @param {string|number} percent - * @param {number} all - * @return {number} - */ - number.parsePercent = function(percent, all) { - switch (percent) { - case 'center': - case 'middle': - percent = '50%'; - break; - case 'left': - case 'top': - percent = '0%'; - break; - case 'right': - case 'bottom': - percent = '100%'; - break; - } - if (typeof percent === 'string') { - if (_trim(percent).match(/%$/)) { - return parseFloat(percent) / 100 * all; - } - - return parseFloat(percent); - } - - return percent == null ? NaN : +percent; - }; - - /** - * Fix rounding error of float numbers - * @param {number} x - * @return {number} - */ - number.round = function (x) { - // PENDING - return +(+x).toFixed(12); - }; - - number.asc = function (arr) { - arr.sort(function (a, b) { - return a - b; - }); - return arr; - }; - - /** - * Get precision - * @param {number} val - */ - number.getPrecision = function (val) { - // It is much faster than methods converting number to string as follows - // var tmp = val.toString(); - // return tmp.length - 1 - tmp.indexOf('.'); - // especially when precision is low - var e = 1; - var count = 0; - while (Math.round(val * e) / e !== val) { - e *= 10; - count++; - } - return count; - }; - - /** - * @param {Array.} dataExtent - * @param {Array.} pixelExtent - * @return {number} precision - */ - number.getPixelPrecision = function (dataExtent, pixelExtent) { - var log = Math.log; - var LN10 = Math.LN10; - var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10); - var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10); - return Math.max( - -dataQuantity + sizeQuantity, - 0 - ); - }; - - // Number.MAX_SAFE_INTEGER, ie do not support. - number.MAX_SAFE_INTEGER = 9007199254740991; - - /** - * To 0 - 2 * PI, considering negative radian. - * @param {number} radian - * @return {number} - */ - number.remRadian = function (radian) { - var pi2 = Math.PI * 2; - return (radian % pi2 + pi2) % pi2; - }; - - /** - * @param {type} radian - * @return {boolean} - */ - number.isRadianAroundZero = function (val) { - return val > -RADIAN_EPSILON && val < RADIAN_EPSILON; - }; - - /** - * @param {string|Date|number} value - * @return {number} timestamp - */ - number.parseDate = function (value) { - return value instanceof Date - ? value - : new Date( - typeof value === 'string' - ? value.replace(/-/g, '/') - : Math.round(value) - ); - }; - - return number; -}); -define('echarts/util/format',['require','zrender/core/util','./number'],function (require) { - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('./number'); - - /** - * 每三位默认加,格式化 - * @type {string|number} x - */ - function addCommas(x) { - if (isNaN(x)) { - return '-'; - } - x = (x + '').split('.'); - return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,'$1,') - + (x.length > 1 ? ('.' + x[1]) : ''); - } - - /** - * @param {string} str - * @return {string} str - */ - function toCamelCase(str) { - return str.toLowerCase().replace(/-(.)/g, function(match, group1) { - return group1.toUpperCase(); - }); - } - - /** - * Normalize css liked array configuration - * e.g. - * 3 => [3, 3, 3, 3] - * [4, 2] => [4, 2, 4, 2] - * [4, 3, 2] => [4, 3, 2, 3] - * @param {number|Array.} val - */ - function normalizeCssArray(val) { - var len = val.length; - if (typeof (val) === 'number') { - return [val, val, val, val]; - } - else if (len === 2) { - // vertical | horizontal - return [val[0], val[1], val[0], val[1]]; - } - else if (len === 3) { - // top | horizontal | bottom - return [val[0], val[1], val[2], val[1]]; - } - return val; - } - - function encodeHTML(source) { - return String(source) - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - } - - var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g']; - - function wrapVar(varName, seriesIdx) { - return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}'; - } - /** - * Template formatter - * @param {string} tpl - * @param {Array.|Object} paramsList - * @return {string} - */ - function formatTpl(tpl, paramsList) { - if (!zrUtil.isArray(paramsList)) { - paramsList = [paramsList]; - } - var seriesLen = paramsList.length; - if (!seriesLen) { - return ''; - } - - var $vars = paramsList[0].$vars; - for (var i = 0; i < $vars.length; i++) { - var alias = TPL_VAR_ALIAS[i]; - tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0)); - } - for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) { - for (var k = 0; k < $vars.length; k++) { - tpl = tpl.replace( - wrapVar(TPL_VAR_ALIAS[k], seriesIdx), - paramsList[seriesIdx][$vars[k]] - ); - } - } - - return tpl; - } - - /** - * ISO Date format - * @param {string} tpl - * @param {number} value - * @inner - */ - function formatTime(tpl, value) { - if (tpl === 'week' - || tpl === 'month' - || tpl === 'quarter' - || tpl === 'half-year' - || tpl === 'year' - ) { - tpl = 'MM-dd\nyyyy'; - } - - var date = numberUtil.parseDate(value); - var y = date.getFullYear(); - var M = date.getMonth() + 1; - var d = date.getDate(); - var h = date.getHours(); - var m = date.getMinutes(); - var s = date.getSeconds(); - - tpl = tpl.replace('MM', s2d(M)) - .toLowerCase() - .replace('yyyy', y) - .replace('yy', y % 100) - .replace('dd', s2d(d)) - .replace('d', d) - .replace('hh', s2d(h)) - .replace('h', h) - .replace('mm', s2d(m)) - .replace('m', m) - .replace('ss', s2d(s)) - .replace('s', s); - - return tpl; - } - - /** - * @param {string} str - * @return {string} - * @inner - */ - function s2d(str) { - return str < 10 ? ('0' + str) : str; - } - - return { - - normalizeCssArray: normalizeCssArray, - - addCommas: addCommas, - - toCamelCase: toCamelCase, - - encodeHTML: encodeHTML, - - formatTpl: formatTpl, - - formatTime: formatTime - }; -}); -define('echarts/util/clazz',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - var clazz = {}; - - var TYPE_DELIMITER = '.'; - var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___'; - /** - * @public - */ - var parseClassType = clazz.parseClassType = function (componentType) { - var ret = {main: '', sub: ''}; - if (componentType) { - componentType = componentType.split(TYPE_DELIMITER); - ret.main = componentType[0] || ''; - ret.sub = componentType[1] || ''; - } - return ret; - }; - /** - * @public - */ - clazz.enableClassExtend = function (RootClass, preConstruct) { - RootClass.extend = function (proto) { - var ExtendedClass = function () { - preConstruct && preConstruct.apply(this, arguments); - RootClass.apply(this, arguments); - }; - - zrUtil.extend(ExtendedClass.prototype, proto); - - ExtendedClass.extend = this.extend; - ExtendedClass.superCall = superCall; - ExtendedClass.superApply = superApply; - zrUtil.inherits(ExtendedClass, this); - ExtendedClass.superClass = this; - - return ExtendedClass; - }; - }; - - // superCall should have class info, which can not be fetch from 'this'. - // Consider this case: - // class A has method f, - // class B inherits class A, overrides method f, f call superApply('f'), - // class C inherits class B, do not overrides method f, - // then when method of class C is called, dead loop occured. - function superCall(context, methodName) { - var args = zrUtil.slice(arguments, 2); - return this.superClass.prototype[methodName].apply(context, args); - } - - function superApply(context, methodName, args) { - return this.superClass.prototype[methodName].apply(context, args); - } - - /** - * @param {Object} entity - * @param {Object} options - * @param {boolean} [options.registerWhenExtend] - * @public - */ - clazz.enableClassManagement = function (entity, options) { - options = options || {}; - - /** - * Component model classes - * key: componentType, - * value: - * componentClass, when componentType is 'xxx' - * or Object., when componentType is 'xxx.yy' - * @type {Object} - */ - var storage = {}; - - entity.registerClass = function (Clazz, componentType) { - if (componentType) { - componentType = parseClassType(componentType); - - if (!componentType.sub) { - if (storage[componentType.main]) { - throw new Error(componentType.main + 'exists'); - } - storage[componentType.main] = Clazz; - } - else if (componentType.sub !== IS_CONTAINER) { - var container = makeContainer(componentType); - container[componentType.sub] = Clazz; - } - } - return Clazz; - }; - - entity.getClass = function (componentTypeMain, subType, throwWhenNotFound) { - var Clazz = storage[componentTypeMain]; - - if (Clazz && Clazz[IS_CONTAINER]) { - Clazz = subType ? Clazz[subType] : null; - } - - if (throwWhenNotFound && !Clazz) { - throw new Error( - 'Component ' + componentTypeMain + '.' + (subType || '') + ' not exists' - ); - } - - return Clazz; - }; - - entity.getClassesByMainType = function (componentType) { - componentType = parseClassType(componentType); - - var result = []; - var obj = storage[componentType.main]; - - if (obj && obj[IS_CONTAINER]) { - zrUtil.each(obj, function (o, type) { - type !== IS_CONTAINER && result.push(o); - }); - } - else { - result.push(obj); - } - - return result; - }; - - entity.hasClass = function (componentType) { - // Just consider componentType.main. - componentType = parseClassType(componentType); - return !!storage[componentType.main]; - }; - - /** - * @return {Array.} Like ['aa', 'bb'], but can not be ['aa.xx'] - */ - entity.getAllClassMainTypes = function () { - var types = []; - zrUtil.each(storage, function (obj, type) { - types.push(type); - }); - return types; - }; - - /** - * If a main type is container and has sub types - * @param {string} mainType - * @return {boolean} - */ - entity.hasSubTypes = function (componentType) { - componentType = parseClassType(componentType); - var obj = storage[componentType.main]; - return obj && obj[IS_CONTAINER]; - }; - - entity.parseClassType = parseClassType; - - function makeContainer(componentType) { - var container = storage[componentType.main]; - if (!container || !container[IS_CONTAINER]) { - container = storage[componentType.main] = {}; - container[IS_CONTAINER] = true; - } - return container; - } - - if (options.registerWhenExtend) { - var originalExtend = entity.extend; - if (originalExtend) { - entity.extend = function (proto) { - var ExtendedClass = originalExtend.call(this, proto); - return entity.registerClass(ExtendedClass, proto.type); - }; - } - } - - return entity; - }; - - /** - * @param {string|Array.} properties - */ - clazz.setReadOnly = function (obj, properties) { - // FIXME It seems broken in IE8 simulation of IE11 - // if (!zrUtil.isArray(properties)) { - // properties = properties != null ? [properties] : []; - // } - // zrUtil.each(properties, function (prop) { - // var value = obj[prop]; - - // Object.defineProperty - // && Object.defineProperty(obj, prop, { - // value: value, writable: false - // }); - // zrUtil.isArray(obj[prop]) - // && Object.freeze - // && Object.freeze(obj[prop]); - // }); - }; - - return clazz; -}); -// TODO Parse shadow style -// TODO Only shallow path support -define('echarts/model/mixin/makeStyleMapper',['require','zrender/core/util'],function (require) { - var zrUtil = require('zrender/core/util'); - - return function (properties) { - // Normalize - for (var i = 0; i < properties.length; i++) { - if (!properties[i][1]) { - properties[i][1] = properties[i][0]; - } - } - return function (excludes) { - var style = {}; - for (var i = 0; i < properties.length; i++) { - var propName = properties[i][1]; - if (excludes && zrUtil.indexOf(excludes, propName) >= 0) { - continue; - } - var val = this.getShallow(propName); - if (val != null) { - style[properties[i][0]] = val; - } - } - return style; - }; - }; -}); -define('echarts/model/mixin/lineStyle',['require','./makeStyleMapper'],function (require) { - var getLineStyle = require('./makeStyleMapper')( - [ - ['lineWidth', 'width'], - ['stroke', 'color'], - ['opacity'], - ['shadowBlur'], - ['shadowOffsetX'], - ['shadowOffsetY'], - ['shadowColor'] - ] - ); - return { - getLineStyle: function (excludes) { - var style = getLineStyle.call(this, excludes); - var lineDash = this.getLineDash(); - lineDash && (style.lineDash = lineDash); - return style; - }, - - getLineDash: function () { - var lineType = this.get('type'); - return (lineType === 'solid' || lineType == null) ? null - : (lineType === 'dashed' ? [5, 5] : [1, 1]); - } - }; -}); -define('echarts/model/mixin/areaStyle',['require','./makeStyleMapper'],function (require) { - return { - getAreaStyle: require('./makeStyleMapper')( - [ - ['fill', 'color'], - ['shadowBlur'], - ['shadowOffsetX'], - ['shadowOffsetY'], - ['opacity'], - ['shadowColor'] - ] - ) - }; -}); -define('zrender/core/vector',[],function () { - var ArrayCtor = typeof Float32Array === 'undefined' - ? Array - : Float32Array; - - /** - * @typedef {Float32Array|Array.} Vector2 - */ - /** - * 二维向量类 - * @exports zrender/tool/vector - */ - var vector = { - /** - * 创建一个向量 - * @param {number} [x=0] - * @param {number} [y=0] - * @return {Vector2} - */ - create: function (x, y) { - var out = new ArrayCtor(2); - out[0] = x || 0; - out[1] = y || 0; - return out; - }, - - /** - * 复制向量数据 - * @param {Vector2} out - * @param {Vector2} v - * @return {Vector2} - */ - copy: function (out, v) { - out[0] = v[0]; - out[1] = v[1]; - return out; - }, - - /** - * 克隆一个向量 - * @param {Vector2} v - * @return {Vector2} - */ - clone: function (v) { - var out = new ArrayCtor(2); - out[0] = v[0]; - out[1] = v[1]; - return out; - }, - - /** - * 设置向量的两个项 - * @param {Vector2} out - * @param {number} a - * @param {number} b - * @return {Vector2} 结果 - */ - set: function (out, a, b) { - out[0] = a; - out[1] = b; - return out; - }, - - /** - * 向量相加 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - add: function (out, v1, v2) { - out[0] = v1[0] + v2[0]; - out[1] = v1[1] + v2[1]; - return out; - }, - - /** - * 向量缩放后相加 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - * @param {number} a - */ - scaleAndAdd: function (out, v1, v2, a) { - out[0] = v1[0] + v2[0] * a; - out[1] = v1[1] + v2[1] * a; - return out; - }, - - /** - * 向量相减 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - sub: function (out, v1, v2) { - out[0] = v1[0] - v2[0]; - out[1] = v1[1] - v2[1]; - return out; - }, - - /** - * 向量长度 - * @param {Vector2} v - * @return {number} - */ - len: function (v) { - return Math.sqrt(this.lenSquare(v)); - }, - - /** - * 向量长度平方 - * @param {Vector2} v - * @return {number} - */ - lenSquare: function (v) { - return v[0] * v[0] + v[1] * v[1]; - }, - - /** - * 向量乘法 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - mul: function (out, v1, v2) { - out[0] = v1[0] * v2[0]; - out[1] = v1[1] * v2[1]; - return out; - }, - - /** - * 向量除法 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - div: function (out, v1, v2) { - out[0] = v1[0] / v2[0]; - out[1] = v1[1] / v2[1]; - return out; - }, - - /** - * 向量点乘 - * @param {Vector2} v1 - * @param {Vector2} v2 - * @return {number} - */ - dot: function (v1, v2) { - return v1[0] * v2[0] + v1[1] * v2[1]; - }, - - /** - * 向量缩放 - * @param {Vector2} out - * @param {Vector2} v - * @param {number} s - */ - scale: function (out, v, s) { - out[0] = v[0] * s; - out[1] = v[1] * s; - return out; - }, - - /** - * 向量归一化 - * @param {Vector2} out - * @param {Vector2} v - */ - normalize: function (out, v) { - var d = vector.len(v); - if (d === 0) { - out[0] = 0; - out[1] = 0; - } - else { - out[0] = v[0] / d; - out[1] = v[1] / d; - } - return out; - }, - - /** - * 计算向量间距离 - * @param {Vector2} v1 - * @param {Vector2} v2 - * @return {number} - */ - distance: function (v1, v2) { - return Math.sqrt( - (v1[0] - v2[0]) * (v1[0] - v2[0]) - + (v1[1] - v2[1]) * (v1[1] - v2[1]) - ); - }, - - /** - * 向量距离平方 - * @param {Vector2} v1 - * @param {Vector2} v2 - * @return {number} - */ - distanceSquare: function (v1, v2) { - return (v1[0] - v2[0]) * (v1[0] - v2[0]) - + (v1[1] - v2[1]) * (v1[1] - v2[1]); - }, - - /** - * 求负向量 - * @param {Vector2} out - * @param {Vector2} v - */ - negate: function (out, v) { - out[0] = -v[0]; - out[1] = -v[1]; - return out; - }, - - /** - * 插值两个点 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - * @param {number} t - */ - lerp: function (out, v1, v2, t) { - out[0] = v1[0] + t * (v2[0] - v1[0]); - out[1] = v1[1] + t * (v2[1] - v1[1]); - return out; - }, - - /** - * 矩阵左乘向量 - * @param {Vector2} out - * @param {Vector2} v - * @param {Vector2} m - */ - applyTransform: function (out, v, m) { - var x = v[0]; - var y = v[1]; - out[0] = m[0] * x + m[2] * y + m[4]; - out[1] = m[1] * x + m[3] * y + m[5]; - return out; - }, - /** - * 求两个向量最小值 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - min: function (out, v1, v2) { - out[0] = Math.min(v1[0], v2[0]); - out[1] = Math.min(v1[1], v2[1]); - return out; - }, - /** - * 求两个向量最大值 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - max: function (out, v1, v2) { - out[0] = Math.max(v1[0], v2[0]); - out[1] = Math.max(v1[1], v2[1]); - return out; - } - }; - - vector.length = vector.len; - vector.lengthSquare = vector.lenSquare; - vector.dist = vector.distance; - vector.distSquare = vector.distanceSquare; - - return vector; -}); + var textLines = text.split('\n'); + for (var i = 0; i < textLines.length; i++) { + textFill && ctx.fillText(textLines[i], x, y); + textStroke && ctx.strokeText(textLines[i], x, y); + y += lineHeight; + } -define('zrender/core/matrix',[],function () { - var ArrayCtor = typeof Float32Array === 'undefined' - ? Array - : Float32Array; - /** - * 3x2矩阵操作类 - * @exports zrender/tool/matrix - */ - var matrix = { - /** - * 创建一个单位矩阵 - * @return {Float32Array|Array.} - */ - create : function() { - var out = new ArrayCtor(6); - matrix.identity(out); - - return out; - }, - /** - * 设置矩阵为单位矩阵 - * @param {Float32Array|Array.} out - */ - identity : function(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = 0; - out[5] = 0; - return out; - }, - /** - * 复制矩阵 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} m - */ - copy: function(out, m) { - out[0] = m[0]; - out[1] = m[1]; - out[2] = m[2]; - out[3] = m[3]; - out[4] = m[4]; - out[5] = m[5]; - return out; - }, - /** - * 矩阵相乘 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} m1 - * @param {Float32Array|Array.} m2 - */ - mul : function (out, m1, m2) { - // Consider matrix.mul(m, m2, m); - // where out is the same as m2. - // So use temp variable to escape error. - var out0 = m1[0] * m2[0] + m1[2] * m2[1]; - var out1 = m1[1] * m2[0] + m1[3] * m2[1]; - var out2 = m1[0] * m2[2] + m1[2] * m2[3]; - var out3 = m1[1] * m2[2] + m1[3] * m2[3]; - var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4]; - var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5]; - out[0] = out0; - out[1] = out1; - out[2] = out2; - out[3] = out3; - out[4] = out4; - out[5] = out5; - return out; - }, - /** - * 平移变换 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - * @param {Float32Array|Array.} v - */ - translate : function(out, a, v) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4] + v[0]; - out[5] = a[5] + v[1]; - return out; - }, - /** - * 旋转变换 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - * @param {number} rad - */ - rotate : function(out, a, rad) { - var aa = a[0]; - var ac = a[2]; - var atx = a[4]; - var ab = a[1]; - var ad = a[3]; - var aty = a[5]; - var st = Math.sin(rad); - var ct = Math.cos(rad); - - out[0] = aa * ct + ab * st; - out[1] = -aa * st + ab * ct; - out[2] = ac * ct + ad * st; - out[3] = -ac * st + ct * ad; - out[4] = ct * atx + st * aty; - out[5] = ct * aty - st * atx; - return out; - }, - /** - * 缩放变换 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - * @param {Float32Array|Array.} v - */ - scale : function(out, a, v) { - var vx = v[0]; - var vy = v[1]; - out[0] = a[0] * vx; - out[1] = a[1] * vy; - out[2] = a[2] * vx; - out[3] = a[3] * vy; - out[4] = a[4] * vx; - out[5] = a[5] * vy; - return out; - }, - /** - * 求逆矩阵 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - */ - invert : function(out, a) { - - var aa = a[0]; - var ac = a[2]; - var atx = a[4]; - var ab = a[1]; - var ad = a[3]; - var aty = a[5]; - - var det = aa * ad - ab * ac; - if (!det) { - return null; - } - det = 1.0 / det; - - out[0] = ad * det; - out[1] = -ab * det; - out[2] = -ac * det; - out[3] = aa * det; - out[4] = (ac * aty - ad * atx) * det; - out[5] = (ab * atx - aa * aty) * det; - return out; - } - }; - - return matrix; -}); + ctx.restore(); + } + }, -/** - * @module echarts/core/BoundingRect - */ -define('zrender/core/BoundingRect',['require','./vector','./matrix'],function(require) { - - - var vec2 = require('./vector'); - var matrix = require('./matrix'); - - var v2ApplyTransform = vec2.applyTransform; - var mathMin = Math.min; - var mathAbs = Math.abs; - var mathMax = Math.max; - /** - * @alias module:echarts/core/BoundingRect - */ - function BoundingRect(x, y, width, height) { - /** - * @type {number} - */ - this.x = x; - /** - * @type {number} - */ - this.y = y; - /** - * @type {number} - */ - this.width = width; - /** - * @type {number} - */ - this.height = height; - } - - BoundingRect.prototype = { - - constructor: BoundingRect, - - /** - * @param {module:echarts/core/BoundingRect} other - */ - union: function (other) { - var x = mathMin(other.x, this.x); - var y = mathMin(other.y, this.y); - - this.width = mathMax( - other.x + other.width, - this.x + this.width - ) - x; - this.height = mathMax( - other.y + other.height, - this.y + this.height - ) - y; - this.x = x; - this.y = y; - }, - - /** - * @param {Array.} m - * @methods - */ - applyTransform: (function () { - var min = []; - var max = []; - return function (m) { - // In case usage like this - // el.getBoundingRect().applyTransform(el.transform) - // And element has no transform - if (!m) { - return; - } - min[0] = this.x; - min[1] = this.y; - max[0] = this.x + this.width; - max[1] = this.y + this.height; - - v2ApplyTransform(min, min, m); - v2ApplyTransform(max, max, m); - - this.x = mathMin(min[0], max[0]); - this.y = mathMin(min[1], max[1]); - this.width = mathAbs(max[0] - min[0]); - this.height = mathAbs(max[1] - min[1]); - }; - })(), - - /** - * Calculate matrix of transforming from self to target rect - * @param {module:zrender/core/BoundingRect} b - * @return {Array.} - */ - calculateTransform: function (b) { - var a = this; - var sx = b.width / a.width; - var sy = b.height / a.height; - - var m = matrix.create(); - - // 矩阵右乘 - matrix.translate(m, m, [-a.x, -a.y]); - matrix.scale(m, m, [sx, sy]); - matrix.translate(m, m, [b.x, b.y]); - - return m; - }, - - /** - * @param {(module:echarts/core/BoundingRect|Object)} b - * @return {boolean} - */ - intersect: function (b) { - var a = this; - var ax0 = a.x; - var ax1 = a.x + a.width; - var ay0 = a.y; - var ay1 = a.y + a.height; - - var bx0 = b.x; - var bx1 = b.x + b.width; - var by0 = b.y; - var by1 = b.y + b.height; - - return ! (ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0); - }, - - contain: function (x, y) { - var rect = this; - return x >= rect.x - && x <= (rect.x + rect.width) - && y >= rect.y - && y <= (rect.y + rect.height); - }, - - /** - * @return {module:echarts/core/BoundingRect} - */ - clone: function () { - return new BoundingRect(this.x, this.y, this.width, this.height); - }, - - /** - * Copy from another rect - */ - copy: function (other) { - this.x = other.x; - this.y = other.y; - this.width = other.width; - this.height = other.height; - } - }; - - return BoundingRect; -}); -define('zrender/contain/text',['require','../core/util','../core/BoundingRect'],function (require) { - - var textWidthCache = {}; - var textWidthCacheCounter = 0; - var TEXT_CACHE_MAX = 5000; - - var util = require('../core/util'); - var BoundingRect = require('../core/BoundingRect'); - - function getTextWidth(text, textFont) { - var key = text + ':' + textFont; - if (textWidthCache[key]) { - return textWidthCache[key]; - } - - var textLines = (text + '').split('\n'); - var width = 0; - - for (var i = 0, l = textLines.length; i < l; i++) { - // measureText 可以被覆盖以兼容不支持 Canvas 的环境 - width = Math.max(textContain.measureText(textLines[i], textFont).width, width); - } - - if (textWidthCacheCounter > TEXT_CACHE_MAX) { - textWidthCacheCounter = 0; - textWidthCache = {}; - } - textWidthCacheCounter++; - textWidthCache[key] = width; - - return width; - } - - function getTextRect(text, textFont, textAlign, textBaseline) { - var textLineLen = ((text || '') + '').split('\n').length; - - var width = getTextWidth(text, textFont); - // FIXME 高度计算比较粗暴 - var lineHeight = getTextWidth('国', textFont); - var height = textLineLen * lineHeight; - - var rect = new BoundingRect(0, 0, width, height); - // Text has a special line height property - rect.lineHeight = lineHeight; - - switch (textBaseline) { - case 'bottom': - case 'alphabetic': - rect.y -= lineHeight; - break; - case 'middle': - rect.y -= lineHeight / 2; - break; - // case 'hanging': - // case 'top': - } - - // FIXME Right to left language - switch (textAlign) { - case 'end': - case 'right': - rect.x -= rect.width; - break; - case 'center': - rect.x -= rect.width / 2; - break; - // case 'start': - // case 'left': - } - - return rect; - } - - function adjustTextPositionOnRect(textPosition, rect, textRect, distance) { - - var x = rect.x; - var y = rect.y; - - var height = rect.height; - var width = rect.width; - - var textHeight = textRect.height; - - var halfHeight = height / 2 - textHeight / 2; - - var textAlign = 'left'; - - switch (textPosition) { - case 'left': - x -= distance; - y += halfHeight; - textAlign = 'right'; - break; - case 'right': - x += distance + width; - y += halfHeight; - textAlign = 'left'; - break; - case 'top': - x += width / 2; - y -= distance + textHeight; - textAlign = 'center'; - break; - case 'bottom': - x += width / 2; - y += height + distance; - textAlign = 'center'; - break; - case 'inside': - x += width / 2; - y += halfHeight; - textAlign = 'center'; - break; - case 'insideLeft': - x += distance; - y += halfHeight; - textAlign = 'left'; - break; - case 'insideRight': - x += width - distance; - y += halfHeight; - textAlign = 'right'; - break; - case 'insideTop': - x += width / 2; - y += distance; - textAlign = 'center'; - break; - case 'insideBottom': - x += width / 2; - y += height - textHeight - distance; - textAlign = 'center'; - break; - case 'insideTopLeft': - x += distance; - y += distance; - textAlign = 'left'; - break; - case 'insideTopRight': - x += width - distance; - y += distance; - textAlign = 'right'; - break; - case 'insideBottomLeft': - x += distance; - y += height - textHeight - distance; - break; - case 'insideBottomRight': - x += width - distance; - y += height - textHeight - distance; - textAlign = 'right'; - break; - } - - return { - x: x, - y: y, - textAlign: textAlign, - textBaseline: 'top' - }; - } - - /** - * Show ellipsis if overflow. - * - * @param {string} text - * @param {string} textFont - * @param {string} containerWidth - * @param {Object} [options] - * @param {number} [options.ellipsis='...'] - * @param {number} [options.maxIterations=3] - * @param {number} [options.minCharacters=3] - * @return {string} - */ - function textEllipsis(text, textFont, containerWidth, options) { - if (!containerWidth) { - return ''; - } - - options = util.defaults({ - ellipsis: '...', - minCharacters: 3, - maxIterations: 3, - cnCharWidth: getTextWidth('国', textFont), - // FIXME - // 未考虑非等宽字体 - ascCharWidth: getTextWidth('a', textFont) - }, options, true); - - containerWidth -= getTextWidth(options.ellipsis); - - var textLines = (text + '').split('\n'); - - for (var i = 0, len = textLines.length; i < len; i++) { - textLines[i] = textLineTruncate( - textLines[i], textFont, containerWidth, options - ); - } - - return textLines.join('\n'); - } - - function textLineTruncate(text, textFont, containerWidth, options) { - // FIXME - // 粗糙得写的,尚未考虑性能和各种语言、字体的效果。 - for (var i = 0;; i++) { - var lineWidth = getTextWidth(text, textFont); - - if (lineWidth < containerWidth || i >= options.maxIterations) { - text += options.ellipsis; - break; - } - - var subLength = i === 0 - ? estimateLength(text, containerWidth, options) - : Math.floor(text.length * containerWidth / lineWidth); - - if (subLength < options.minCharacters) { - text = ''; - break; - } - - text = text.substr(0, subLength); - } - - return text; - } - - function estimateLength(text, containerWidth, options) { - var width = 0; - var i = 0; - for (var len = text.length; i < len && width < containerWidth; i++) { - var charCode = text.charCodeAt(i); - width += (0 <= charCode && charCode <= 127) - ? options.ascCharWidth : options.cnCharWidth; - } - return i; - } - - var textContain = { - - getWidth: getTextWidth, - - getBoundingRect: getTextRect, - - adjustTextPositionOnRect: adjustTextPositionOnRect, - - ellipsis: textEllipsis, - - measureText: function (text, textFont) { - var ctx = util.getContext(); - ctx.font = textFont; - return ctx.measureText(text); - } - }; - - return textContain; -}); -define('echarts/model/mixin/textStyle',['require','zrender/contain/text'],function (require) { - - var textContain = require('zrender/contain/text'); - - function getShallow(model, path) { - return model && model.getShallow(path); - } - - return { - /** - * Get color property or get color from option.textStyle.color - * @return {string} - */ - getTextColor: function () { - var ecModel = this.ecModel; - return this.getShallow('color') - || (ecModel && ecModel.get('textStyle.color')); - }, - - /** - * Create font string from fontStyle, fontWeight, fontSize, fontFamily - * @return {string} - */ - getFont: function () { - var ecModel = this.ecModel; - var gTextStyleModel = ecModel && ecModel.getModel('textStyle'); - return [ - // FIXME in node-canvas fontWeight is before fontStyle - this.getShallow('fontStyle') || getShallow(gTextStyleModel, 'fontStyle'), - this.getShallow('fontWeight') || getShallow(gTextStyleModel, 'fontWeight'), - (this.getShallow('fontSize') || getShallow(gTextStyleModel, 'fontSize') || 12) + 'px', - this.getShallow('fontFamily') || getShallow(gTextStyleModel, 'fontFamily') || 'sans-serif' - ].join(' '); - }, - - getTextRect: function (text) { - var textStyle = this.get('textStyle') || {}; - return textContain.getBoundingRect( - text, - this.getFont(), - textStyle.align, - textStyle.baseline - ); - }, - - ellipsis: function (text, containerWidth, options) { - return textContain.ellipsis( - text, this.getFont(), containerWidth, options - ); - } - }; -}); -define('echarts/model/mixin/itemStyle',['require','./makeStyleMapper'],function (require) { - return { - getItemStyle: require('./makeStyleMapper')( - [ - ['fill', 'color'], - ['stroke', 'borderColor'], - ['lineWidth', 'borderWidth'], - ['opacity'], - ['shadowBlur'], - ['shadowOffsetX'], - ['shadowOffsetY'], - ['shadowColor'] - ] - ) - }; -}); -/** - * @module echarts/model/Model - */ -define('echarts/model/Model',['require','zrender/core/util','../util/clazz','./mixin/lineStyle','./mixin/areaStyle','./mixin/textStyle','./mixin/itemStyle'],function (require) { - - var zrUtil = require('zrender/core/util'); - var clazzUtil = require('../util/clazz'); - - /** - * @alias module:echarts/model/Model - * @constructor - * @param {Object} option - * @param {module:echarts/model/Model} parentModel - * @param {module:echarts/model/Global} ecModel - * @param {Object} extraOpt - */ - function Model(option, parentModel, ecModel, extraOpt) { - /** - * @type {module:echarts/model/Model} - * @readOnly - */ - this.parentModel = parentModel; - - /** - * @type {module:echarts/model/Global} - * @readOnly - */ - this.ecModel = ecModel; - - /** - * @type {Object} - * @protected - */ - this.option = option; - - // Simple optimization - if (this.init) { - if (arguments.length <= 4) { - this.init(option, parentModel, ecModel, extraOpt); - } - else { - this.init.apply(this, arguments); - } - } - } - - Model.prototype = { - - constructor: Model, - - /** - * Model 的初始化函数 - * @param {Object} option - */ - init: null, - - /** - * 从新的 Option merge - */ - mergeOption: function (option) { - zrUtil.merge(this.option, option, true); - }, - - /** - * @param {string} path - * @param {boolean} [ignoreParent=false] - * @return {*} - */ - get: function (path, ignoreParent) { - if (!path) { - return this.option; - } - - if (typeof path === 'string') { - path = path.split('.'); - } - - var obj = this.option; - var parentModel = this.parentModel; - for (var i = 0; i < path.length; i++) { - // obj could be number/string/... (like 0) - obj = (obj && typeof obj === 'object') ? obj[path[i]] : null; - if (obj == null) { - break; - } - } - if (obj == null && parentModel && !ignoreParent) { - obj = parentModel.get(path); - } - return obj; - }, - - /** - * @param {string} key - * @param {boolean} [ignoreParent=false] - * @return {*} - */ - getShallow: function (key, ignoreParent) { - var option = this.option; - var val = option && option[key]; - var parentModel = this.parentModel; - if (val == null && parentModel && !ignoreParent) { - val = parentModel.getShallow(key); - } - return val; - }, - - /** - * @param {string} path - * @param {module:echarts/model/Model} [parentModel] - * @return {module:echarts/model/Model} - */ - getModel: function (path, parentModel) { - var obj = this.get(path, true); - var thisParentModel = this.parentModel; - var model = new Model( - obj, parentModel || (thisParentModel && thisParentModel.getModel(path)), - this.ecModel - ); - return model; - }, - - /** - * If model has option - */ - isEmpty: function () { - return this.option == null; - }, - - restoreData: function () {}, - - // Pending - clone: function () { - var Ctor = this.constructor; - return new Ctor(zrUtil.clone(this.option)); - }, - - setReadOnly: function (properties) { - clazzUtil.setReadOnly(this, properties); - } - }; - - // Enable Model.extend. - clazzUtil.enableClassExtend(Model); - - var mixin = zrUtil.mixin; - mixin(Model, require('./mixin/lineStyle')); - mixin(Model, require('./mixin/areaStyle')); - mixin(Model, require('./mixin/textStyle')); - mixin(Model, require('./mixin/itemStyle')); - - return Model; -}); -define('echarts/util/model',['require','./format','./number','zrender/core/util','../model/Model'],function(require) { - - var formatUtil = require('./format'); - var nubmerUtil = require('./number'); - var zrUtil = require('zrender/core/util'); - - var Model = require('../model/Model'); - - var AXIS_DIMS = ['x', 'y', 'z', 'radius', 'angle']; - - var modelUtil = {}; - - /** - * Create "each" method to iterate names. - * - * @pubilc - * @param {Array.} names - * @param {Array.=} attrs - * @return {Function} - */ - modelUtil.createNameEach = function (names, attrs) { - names = names.slice(); - var capitalNames = zrUtil.map(names, modelUtil.capitalFirst); - attrs = (attrs || []).slice(); - var capitalAttrs = zrUtil.map(attrs, modelUtil.capitalFirst); - - return function (callback, context) { - zrUtil.each(names, function (name, index) { - var nameObj = {name: name, capital: capitalNames[index]}; - - for (var j = 0; j < attrs.length; j++) { - nameObj[attrs[j]] = name + capitalAttrs[j]; - } - - callback.call(context, nameObj); - }); - }; - }; - - /** - * @public - */ - modelUtil.capitalFirst = function (str) { - return str ? str.charAt(0).toUpperCase() + str.substr(1) : str; - }; - - /** - * Iterate each dimension name. - * - * @public - * @param {Function} callback The parameter is like: - * { - * name: 'angle', - * capital: 'Angle', - * axis: 'angleAxis', - * axisIndex: 'angleAixs', - * index: 'angleIndex' - * } - * @param {Object} context - */ - modelUtil.eachAxisDim = modelUtil.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index']); - - /** - * If value is not array, then translate it to array. - * @param {*} value - * @return {Array} [value] or value - */ - modelUtil.normalizeToArray = function (value) { - return zrUtil.isArray(value) - ? value - : value == null - ? [] - : [value]; - }; - - /** - * If tow dataZoomModels has the same axis controlled, we say that they are 'linked'. - * dataZoomModels and 'links' make up one or more graphics. - * This function finds the graphic where the source dataZoomModel is in. - * - * @public - * @param {Function} forEachNode Node iterator. - * @param {Function} forEachEdgeType edgeType iterator - * @param {Function} edgeIdGetter Giving node and edgeType, return an array of edge id. - * @return {Function} Input: sourceNode, Output: Like {nodes: [], dims: {}} - */ - modelUtil.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) { - - return function (sourceNode) { - var result = { - nodes: [], - records: {} // key: edgeType.name, value: Object (key: edge id, value: boolean). - }; - - forEachEdgeType(function (edgeType) { - result.records[edgeType.name] = {}; - }); - - if (!sourceNode) { - return result; - } - - absorb(sourceNode, result); - - var existsLink; - do { - existsLink = false; - forEachNode(processSingleNode); - } - while (existsLink); - - function processSingleNode(node) { - if (!isNodeAbsorded(node, result) && isLinked(node, result)) { - absorb(node, result); - existsLink = true; - } - } - - return result; - }; - - function isNodeAbsorded(node, result) { - return zrUtil.indexOf(result.nodes, node) >= 0; - } - - function isLinked(node, result) { - var hasLink = false; - forEachEdgeType(function (edgeType) { - zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) { - result.records[edgeType.name][edgeId] && (hasLink = true); - }); - }); - return hasLink; - } - - function absorb(node, result) { - result.nodes.push(node); - forEachEdgeType(function (edgeType) { - zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) { - result.records[edgeType.name][edgeId] = true; - }); - }); - } - }; - - /** - * Sync default option between normal and emphasis like `position` and `show` - * In case some one will write code like - * label: { - * normal: { - * show: false, - * position: 'outside', - * textStyle: { - * fontSize: 18 - * } - * }, - * emphasis: { - * show: true - * } - * } - * @param {Object} opt - * @param {Array.} subOpts - */ - modelUtil.defaultEmphasis = function (opt, subOpts) { - if (opt) { - var emphasisOpt = opt.emphasis = opt.emphasis || {}; - var normalOpt = opt.normal = opt.normal || {}; - - // Default emphasis option from normal - zrUtil.each(subOpts, function (subOptName) { - var val = zrUtil.retrieve(emphasisOpt[subOptName], normalOpt[subOptName]); - if (val != null) { - emphasisOpt[subOptName] = val; - } - }); - } - }; - - /** - * Create a model proxy to be used in tooltip for edge data, markLine data, markPoint data. - * @param {Object} opt - * @param {string} [opt.seriesIndex] - * @param {Object} [opt.name] - * @param {module:echarts/data/List} data - * @param {Array.} rawData - */ - modelUtil.createDataFormatModel = function (opt, data, rawData) { - var model = new Model(); - zrUtil.mixin(model, modelUtil.dataFormatMixin); - model.seriesIndex = opt.seriesIndex; - model.name = opt.name || ''; - - model.getData = function () { - return data; - }; - model.getRawDataArray = function () { - return rawData; - }; - return model; - }; - - /** - * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}] - * This helper method retieves value from data. - * @param {string|number|Date|Array|Object} dataItem - * @return {number|string|Date|Array.} - */ - modelUtil.getDataItemValue = function (dataItem) { - // Performance sensitive. - return dataItem && (dataItem.value == null ? dataItem : dataItem.value); - }; - - /** - * This helper method convert value in data. - * @param {string|number|Date} value - * @param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'. - */ - modelUtil.converDataValue = function (value, dimInfo) { - // Performance sensitive. - var dimType = dimInfo && dimInfo.type; - if (dimType === 'ordinal') { - return value; - } - - if (dimType === 'time' && !isFinite(value) && value != null && value !== '-') { - value = +nubmerUtil.parseDate(value); - } - - // dimType defaults 'number'. - // If dimType is not ordinal and value is null or undefined or NaN or '-', - // parse to NaN. - return (value == null || value === '') - ? NaN : +value; // If string (like '-'), using '+' parse to NaN - }; - - modelUtil.dataFormatMixin = { - /** - * Get params for formatter - * @param {number} dataIndex - * @return {Object} - */ - getDataParams: function (dataIndex) { - var data = this.getData(); - - var seriesIndex = this.seriesIndex; - var seriesName = this.name; - - var rawValue = this.getRawValue(dataIndex); - var rawDataIndex = data.getRawIndex(dataIndex); - var name = data.getName(dataIndex, true); - - // Data may not exists in the option given by user - var rawDataArray = this.getRawDataArray(); - var itemOpt = rawDataArray && rawDataArray[rawDataIndex]; - - return { - seriesIndex: seriesIndex, - seriesName: seriesName, - name: name, - dataIndex: rawDataIndex, - data: itemOpt, - value: rawValue, - - // Param name list for mapping `a`, `b`, `c`, `d`, `e` - $vars: ['seriesName', 'name', 'value'] - }; - }, - - /** - * Format label - * @param {number} dataIndex - * @param {string} [status='normal'] 'normal' or 'emphasis' - * @param {Function|string} [formatter] Default use the `itemStyle[status].label.formatter` - * @return {string} - */ - getFormattedLabel: function (dataIndex, status, formatter) { - status = status || 'normal'; - var data = this.getData(); - var itemModel = data.getItemModel(dataIndex); - - var params = this.getDataParams(dataIndex); - if (formatter == null) { - formatter = itemModel.get(['label', status, 'formatter']); - } - - if (typeof formatter === 'function') { - params.status = status; - return formatter(params); - } - else if (typeof formatter === 'string') { - return formatUtil.formatTpl(formatter, params); - } - }, - - /** - * Get raw value in option - * @param {number} idx - * @return {Object} - */ - getRawValue: function (idx) { - var itemModel = this.getData().getItemModel(idx); - if (itemModel && itemModel.option != null) { - var dataItem = itemModel.option; - return (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem)) - ? dataItem.value : dataItem; - } - } - }; - - /** - * Mapping to exists for merge. - * - * @public - * @param {Array.|Array.} exists - * @param {Object|Array.} newCptOptions - * @return {Array.} Result, like [{exist: ..., option: ...}, {}], - * which order is the same as exists. - */ - modelUtil.mappingToExists = function (exists, newCptOptions) { - // Mapping by the order by original option (but not order of - // new option) in merge mode. Because we should ensure - // some specified index (like xAxisIndex) is consistent with - // original option, which is easy to understand, espatially in - // media query. And in most case, merge option is used to - // update partial option but not be expected to change order. - newCptOptions = (newCptOptions || []).slice(); - - var result = zrUtil.map(exists || [], function (obj, index) { - return {exist: obj}; - }); - - // Mapping by id or name if specified. - zrUtil.each(newCptOptions, function (cptOption, index) { - if (!zrUtil.isObject(cptOption)) { - return; - } - - for (var i = 0; i < result.length; i++) { - var exist = result[i].exist; - if (!result[i].option // Consider name: two map to one. - && ( - // id has highest priority. - (cptOption.id != null && exist.id === cptOption.id + '') - || (cptOption.name != null - && !modelUtil.isIdInner(cptOption) - && !modelUtil.isIdInner(exist) - && exist.name === cptOption.name + '' - ) - ) - ) { - result[i].option = cptOption; - newCptOptions[index] = null; - break; - } - } - }); - - // Otherwise mapping by index. - zrUtil.each(newCptOptions, function (cptOption, index) { - if (!zrUtil.isObject(cptOption)) { - return; - } - - var i = 0; - for (; i < result.length; i++) { - var exist = result[i].exist; - if (!result[i].option - && !modelUtil.isIdInner(exist) - // Caution: - // Do not overwrite id. But name can be overwritten, - // because axis use name as 'show label text'. - // 'exist' always has id and name and we dont - // need to check it. - && cptOption.id == null - ) { - result[i].option = cptOption; - break; - } - } - - if (i >= result.length) { - result.push({option: cptOption}); - } - }); - - return result; - }; - - /** - * @public - * @param {Object} cptOption - * @return {boolean} - */ - modelUtil.isIdInner = function (cptOption) { - return zrUtil.isObject(cptOption) - && cptOption.id - && (cptOption.id + '').indexOf('\0_ec_\0') === 0; - }; - - return modelUtil; -}); -define('echarts/util/component',['require','zrender/core/util','./clazz'],function(require) { - - var zrUtil = require('zrender/core/util'); - var clazz = require('./clazz'); - - var parseClassType = clazz.parseClassType; - - var base = 0; - - var componentUtil = {}; - - var DELIMITER = '_'; - - /** - * @public - * @param {string} type - * @return {string} - */ - componentUtil.getUID = function (type) { - // Considering the case of crossing js context, - // use Math.random to make id as unique as possible. - return [(type || ''), base++, Math.random()].join(DELIMITER); - }; - - /** - * @inner - */ - componentUtil.enableSubTypeDefaulter = function (entity) { - - var subTypeDefaulters = {}; - - entity.registerSubTypeDefaulter = function (componentType, defaulter) { - componentType = parseClassType(componentType); - subTypeDefaulters[componentType.main] = defaulter; - }; - - entity.determineSubType = function (componentType, option) { - var type = option.type; - if (!type) { - var componentTypeMain = parseClassType(componentType).main; - if (entity.hasSubTypes(componentType) && subTypeDefaulters[componentTypeMain]) { - type = subTypeDefaulters[componentTypeMain](option); - } - } - return type; - }; - - return entity; - }; - - /** - * Topological travel on Activity Network (Activity On Vertices). - * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis']. - * - * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology. - * - * If there is circle dependencey, Error will be thrown. - * - */ - componentUtil.enableTopologicalTravel = function (entity, dependencyGetter) { - - /** - * @public - * @param {Array.} targetNameList Target Component type list. - * Can be ['aa', 'bb', 'aa.xx'] - * @param {Array.} fullNameList By which we can build dependency graph. - * @param {Function} callback Params: componentType, dependencies. - * @param {Object} context Scope of callback. - */ - entity.topologicalTravel = function (targetNameList, fullNameList, callback, context) { - if (!targetNameList.length) { - return; - } - - var result = makeDepndencyGraph(fullNameList); - var graph = result.graph; - var stack = result.noEntryList; - - var targetNameSet = {}; - zrUtil.each(targetNameList, function (name) { - targetNameSet[name] = true; - }); - - while (stack.length) { - var currComponentType = stack.pop(); - var currVertex = graph[currComponentType]; - var isInTargetNameSet = !!targetNameSet[currComponentType]; - if (isInTargetNameSet) { - callback.call(context, currComponentType, currVertex.originalDeps.slice()); - delete targetNameSet[currComponentType]; - } - zrUtil.each( - currVertex.successor, - isInTargetNameSet ? removeEdgeAndAdd : removeEdge - ); - } - - zrUtil.each(targetNameSet, function () { - throw new Error('Circle dependency may exists'); - }); - - function removeEdge(succComponentType) { - graph[succComponentType].entryCount--; - if (graph[succComponentType].entryCount === 0) { - stack.push(succComponentType); - } - } - - // Consider this case: legend depends on series, and we call - // chart.setOption({series: [...]}), where only series is in option. - // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will - // not be called, but only sereis.mergeOption is called. Thus legend - // have no chance to update its local record about series (like which - // name of series is available in legend). - function removeEdgeAndAdd(succComponentType) { - targetNameSet[succComponentType] = true; - removeEdge(succComponentType); - } - }; - - /** - * DepndencyGraph: {Object} - * key: conponentType, - * value: { - * successor: [conponentTypes...], - * originalDeps: [conponentTypes...], - * entryCount: {number} - * } - */ - function makeDepndencyGraph(fullNameList) { - var graph = {}; - var noEntryList = []; - - zrUtil.each(fullNameList, function (name) { - - var thisItem = createDependencyGraphItem(graph, name); - var originalDeps = thisItem.originalDeps = dependencyGetter(name); - - var availableDeps = getAvailableDependencies(originalDeps, fullNameList); - thisItem.entryCount = availableDeps.length; - if (thisItem.entryCount === 0) { - noEntryList.push(name); - } - - zrUtil.each(availableDeps, function (dependentName) { - if (zrUtil.indexOf(thisItem.predecessor, dependentName) < 0) { - thisItem.predecessor.push(dependentName); - } - var thatItem = createDependencyGraphItem(graph, dependentName); - if (zrUtil.indexOf(thatItem.successor, dependentName) < 0) { - thatItem.successor.push(name); - } - }); - }); - - return {graph: graph, noEntryList: noEntryList}; - } - - function createDependencyGraphItem(graph, name) { - if (!graph[name]) { - graph[name] = {predecessor: [], successor: []}; - } - return graph[name]; - } - - function getAvailableDependencies(originalDeps, fullNameList) { - var availableDeps = []; - zrUtil.each(originalDeps, function (dep) { - zrUtil.indexOf(fullNameList, dep) >= 0 && availableDeps.push(dep); - }); - return availableDeps; - } - }; - - return componentUtil; -}); -// Layout helpers for each component positioning -define('echarts/util/layout',['require','zrender/core/util','zrender/core/BoundingRect','./number','./format'],function(require) { - - - var zrUtil = require('zrender/core/util'); - var BoundingRect = require('zrender/core/BoundingRect'); - var numberUtil = require('./number'); - var formatUtil = require('./format'); - var parsePercent = numberUtil.parsePercent; - var each = zrUtil.each; - - var layout = {}; - - var LOCATION_PARAMS = ['left', 'right', 'top', 'bottom', 'width', 'height']; - - function boxLayout(orient, group, gap, maxWidth, maxHeight) { - var x = 0; - var y = 0; - if (maxWidth == null) { - maxWidth = Infinity; - } - if (maxHeight == null) { - maxHeight = Infinity; - } - var currentLineMaxSize = 0; - group.eachChild(function (child, idx) { - var position = child.position; - var rect = child.getBoundingRect(); - var nextChild = group.childAt(idx + 1); - var nextChildRect = nextChild && nextChild.getBoundingRect(); - var nextX; - var nextY; - if (orient === 'horizontal') { - var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0); - nextX = x + moveX; - // Wrap when width exceeds maxWidth or meet a `newline` group - if (nextX > maxWidth || child.newline) { - x = 0; - nextX = moveX; - y += currentLineMaxSize + gap; - currentLineMaxSize = rect.height; - } - else { - currentLineMaxSize = Math.max(currentLineMaxSize, rect.height); - } - } - else { - var moveY = rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0); - nextY = y + moveY; - // Wrap when width exceeds maxHeight or meet a `newline` group - if (nextY > maxHeight || child.newline) { - x += currentLineMaxSize + gap; - y = 0; - nextY = moveY; - currentLineMaxSize = rect.width; - } - else { - currentLineMaxSize = Math.max(currentLineMaxSize, rect.width); - } - } - - if (child.newline) { - return; - } - - position[0] = x; - position[1] = y; - - orient === 'horizontal' - ? (x = nextX + gap) - : (y = nextY + gap); - }); - } - - /** - * VBox or HBox layouting - * @param {string} orient - * @param {module:zrender/container/Group} group - * @param {number} gap - * @param {number} [width=Infinity] - * @param {number} [height=Infinity] - */ - layout.box = boxLayout; - - /** - * VBox layouting - * @param {module:zrender/container/Group} group - * @param {number} gap - * @param {number} [width=Infinity] - * @param {number} [height=Infinity] - */ - layout.vbox = zrUtil.curry(boxLayout, 'vertical'); - - /** - * HBox layouting - * @param {module:zrender/container/Group} group - * @param {number} gap - * @param {number} [width=Infinity] - * @param {number} [height=Infinity] - */ - layout.hbox = zrUtil.curry(boxLayout, 'horizontal'); - - /** - * If x or x2 is not specified or 'center' 'left' 'right', - * the width would be as long as possible. - * If y or y2 is not specified or 'middle' 'top' 'bottom', - * the height would be as long as possible. - * - * @param {Object} positionInfo - * @param {number|string} [positionInfo.x] - * @param {number|string} [positionInfo.y] - * @param {number|string} [positionInfo.x2] - * @param {number|string} [positionInfo.y2] - * @param {Object} containerRect - * @param {string|number} margin - * @return {Object} {width, height} - */ - layout.getAvailableSize = function (positionInfo, containerRect, margin) { - var containerWidth = containerRect.width; - var containerHeight = containerRect.height; - - var x = parsePercent(positionInfo.x, containerWidth); - var y = parsePercent(positionInfo.y, containerHeight); - var x2 = parsePercent(positionInfo.x2, containerWidth); - var y2 = parsePercent(positionInfo.y2, containerHeight); - - (isNaN(x) || isNaN(parseFloat(positionInfo.x))) && (x = 0); - (isNaN(x2) || isNaN(parseFloat(positionInfo.x2))) && (x2 = containerWidth); - (isNaN(y) || isNaN(parseFloat(positionInfo.y))) && (y = 0); - (isNaN(y2) || isNaN(parseFloat(positionInfo.y2))) && (y2 = containerHeight); - - margin = formatUtil.normalizeCssArray(margin || 0); - - return { - width: Math.max(x2 - x - margin[1] - margin[3], 0), - height: Math.max(y2 - y - margin[0] - margin[2], 0) - }; - }; - - /** - * Parse position info. - * - * @param {Object} positionInfo - * @param {number|string} [positionInfo.left] - * @param {number|string} [positionInfo.top] - * @param {number|string} [positionInfo.right] - * @param {number|string} [positionInfo.bottom] - * @param {number|string} [positionInfo.width] - * @param {number|string} [positionInfo.height] - * @param {number|string} [positionInfo.aspect] Aspect is width / height - * @param {Object} containerRect - * @param {string|number} [margin] - * - * @return {module:zrender/core/BoundingRect} - */ - layout.getLayoutRect = function ( - positionInfo, containerRect, margin - ) { - margin = formatUtil.normalizeCssArray(margin || 0); - - var containerWidth = containerRect.width; - var containerHeight = containerRect.height; - - var left = parsePercent(positionInfo.left, containerWidth); - var top = parsePercent(positionInfo.top, containerHeight); - var right = parsePercent(positionInfo.right, containerWidth); - var bottom = parsePercent(positionInfo.bottom, containerHeight); - var width = parsePercent(positionInfo.width, containerWidth); - var height = parsePercent(positionInfo.height, containerHeight); - - var verticalMargin = margin[2] + margin[0]; - var horizontalMargin = margin[1] + margin[3]; - var aspect = positionInfo.aspect; - - // If width is not specified, calculate width from left and right - if (isNaN(width)) { - width = containerWidth - right - horizontalMargin - left; - } - if (isNaN(height)) { - height = containerHeight - bottom - verticalMargin - top; - } - - // If width and height are not given - // 1. Graph should not exceeds the container - // 2. Aspect must be keeped - // 3. Graph should take the space as more as possible - if (isNaN(width) && isNaN(height)) { - if (aspect > containerWidth / containerHeight) { - width = containerWidth * 0.8; - } - else { - height = containerHeight * 0.8; - } - } - - if (aspect != null) { - // Calculate width or height with given aspect - if (isNaN(width)) { - width = aspect * height; - } - if (isNaN(height)) { - height = width / aspect; - } - } - - // If left is not specified, calculate left from right and width - if (isNaN(left)) { - left = containerWidth - right - width - horizontalMargin; - } - if (isNaN(top)) { - top = containerHeight - bottom - height - verticalMargin; - } - - // Align left and top - switch (positionInfo.left || positionInfo.right) { - case 'center': - left = containerWidth / 2 - width / 2 - margin[3]; - break; - case 'right': - left = containerWidth - width - horizontalMargin; - break; - } - switch (positionInfo.top || positionInfo.bottom) { - case 'middle': - case 'center': - top = containerHeight / 2 - height / 2 - margin[0]; - break; - case 'bottom': - top = containerHeight - height - verticalMargin; - break; - } - // If something is wrong and left, top, width, height are calculated as NaN - left = left || 0; - top = top || 0; - if (isNaN(width)) { - // Width may be NaN if only one value is given except width - width = containerWidth - left - (right || 0); - } - if (isNaN(height)) { - // Height may be NaN if only one value is given except height - height = containerHeight - top - (bottom || 0); - } - - var rect = new BoundingRect(left + margin[3], top + margin[0], width, height); - rect.margin = margin; - return rect; - }; - - /** - * Position group of component in viewport - * Group position is specified by either - * {left, top}, {right, bottom} - * If all properties exists, right and bottom will be igonred. - * - * @param {module:zrender/container/Group} group - * @param {Object} positionInfo - * @param {number|string} [positionInfo.left] - * @param {number|string} [positionInfo.top] - * @param {number|string} [positionInfo.right] - * @param {number|string} [positionInfo.bottom] - * @param {Object} containerRect - * @param {string|number} margin - */ - layout.positionGroup = function ( - group, positionInfo, containerRect, margin - ) { - var groupRect = group.getBoundingRect(); - - positionInfo = zrUtil.extend(zrUtil.clone(positionInfo), { - width: groupRect.width, - height: groupRect.height - }); - - positionInfo = layout.getLayoutRect( - positionInfo, containerRect, margin - ); - - group.position = [ - positionInfo.x - groupRect.x, - positionInfo.y - groupRect.y - ]; - }; - - /** - * Consider Case: - * When defulat option has {left: 0, width: 100}, and we set {right: 0} - * through setOption or media query, using normal zrUtil.merge will cause - * {right: 0} does not take effect. - * - * @example - * ComponentModel.extend({ - * init: function () { - * ... - * var inputPositionParams = layout.getLayoutParams(option); - * this.mergeOption(inputPositionParams); - * }, - * mergeOption: function (newOption) { - * newOption && zrUtil.merge(thisOption, newOption, true); - * layout.mergeLayoutParam(thisOption, newOption); - * } - * }); - * - * @param {Object} targetOption - * @param {Object} newOption - * @param {Object|string} [opt] - * @param {boolean} [opt.ignoreSize=false] Some component must has width and height. - */ - layout.mergeLayoutParam = function (targetOption, newOption, opt) { - !zrUtil.isObject(opt) && (opt = {}); - var hNames = ['width', 'left', 'right']; // Order by priority. - var vNames = ['height', 'top', 'bottom']; // Order by priority. - var hResult = merge(hNames); - var vResult = merge(vNames); - - copy(hNames, targetOption, hResult); - copy(vNames, targetOption, vResult); - - function merge(names) { - var newParams = {}; - var newValueCount = 0; - var merged = {}; - var mergedValueCount = 0; - var enoughParamNumber = opt.ignoreSize ? 1 : 2; - - each(names, function (name) { - merged[name] = targetOption[name]; - }); - each(names, function (name) { - // Consider case: newOption.width is null, which is - // set by user for removing width setting. - hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]); - hasValue(newParams, name) && newValueCount++; - hasValue(merged, name) && mergedValueCount++; - }); - - // Case: newOption: {width: ..., right: ...}, - // or targetOption: {right: ...} and newOption: {width: ...}, - // There is no conflict when merged only has params count - // little than enoughParamNumber. - if (mergedValueCount === enoughParamNumber || !newValueCount) { - return merged; - } - // Case: newOption: {width: ..., right: ...}, - // Than we can make sure user only want those two, and ignore - // all origin params in targetOption. - else if (newValueCount >= enoughParamNumber) { - return newParams; - } - else { - // Chose another param from targetOption by priority. - // When 'ignoreSize', enoughParamNumber is 1 and those will not happen. - for (var i = 0; i < names.length; i++) { - var name = names[i]; - if (!hasProp(newParams, name) && hasProp(targetOption, name)) { - newParams[name] = targetOption[name]; - break; - } - } - return newParams; - } - } - - function hasProp(obj, name) { - return obj.hasOwnProperty(name); - } - - function hasValue(obj, name) { - return obj[name] != null && obj[name] !== 'auto'; - } - - function copy(names, target, source) { - each(names, function (name) { - target[name] = source[name]; - }); - } - }; - - /** - * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object. - * @param {Object} source - * @return {Object} Result contains those props. - */ - layout.getLayoutParams = function (source) { - return layout.copyLayoutParams({}, source); - }; - - /** - * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object. - * @param {Object} source - * @return {Object} Result contains those props. - */ - layout.copyLayoutParams = function (target, source) { - source && target && each(LOCATION_PARAMS, function (name) { - source.hasOwnProperty(name) && (target[name] = source[name]); - }); - return target; - }; - - return layout; -}); -define('echarts/model/mixin/boxLayout',['require'],function (require) { - - return { - getBoxLayoutParams: function () { - return { - left: this.get('left'), - top: this.get('top'), - right: this.get('right'), - bottom: this.get('bottom'), - width: this.get('width'), - height: this.get('height') - }; - } - }; -}); -/** - * Component model - * - * @module echarts/model/Component - */ -define('echarts/model/Component',['require','./Model','zrender/core/util','../util/component','../util/clazz','../util/layout','./mixin/boxLayout'],function(require) { - - var Model = require('./Model'); - var zrUtil = require('zrender/core/util'); - var arrayPush = Array.prototype.push; - var componentUtil = require('../util/component'); - var clazzUtil = require('../util/clazz'); - var layout = require('../util/layout'); - - /** - * @alias module:echarts/model/Component - * @constructor - * @param {Object} option - * @param {module:echarts/model/Model} parentModel - * @param {module:echarts/model/Model} ecModel - */ - var ComponentModel = Model.extend({ - - type: 'component', - - /** - * @readOnly - * @type {string} - */ - id: '', - - /** - * @readOnly - */ - name: '', - - /** - * @readOnly - * @type {string} - */ - mainType: '', - - /** - * @readOnly - * @type {string} - */ - subType: '', - - /** - * @readOnly - * @type {number} - */ - componentIndex: 0, - - /** - * @type {Object} - * @protected - */ - defaultOption: null, - - /** - * @type {module:echarts/model/Global} - * @readOnly - */ - ecModel: null, - - /** - * key: componentType - * value: Component model list, can not be null. - * @type {Object.>} - * @readOnly - */ - dependentModels: [], - - /** - * @type {string} - * @readOnly - */ - uid: null, - - /** - * Support merge layout params. - * Only support 'box' now (left/right/top/bottom/width/height). - * @type {string|Object} Object can be {ignoreSize: true} - * @readOnly - */ - layoutMode: null, - - - init: function (option, parentModel, ecModel, extraOpt) { - this.mergeDefaultAndTheme(this.option, this.ecModel); - }, - - mergeDefaultAndTheme: function (option, ecModel) { - var layoutMode = this.layoutMode; - var inputPositionParams = layoutMode - ? layout.getLayoutParams(option) : {}; - - var themeModel = ecModel.getTheme(); - zrUtil.merge(option, themeModel.get(this.mainType)); - zrUtil.merge(option, this.getDefaultOption()); - - if (layoutMode) { - layout.mergeLayoutParam(option, inputPositionParams, layoutMode); - } - }, - - mergeOption: function (option) { - zrUtil.merge(this.option, option, true); - - var layoutMode = this.layoutMode; - if (layoutMode) { - layout.mergeLayoutParam(this.option, option, layoutMode); - } - }, - - getDefaultOption: function () { - if (!this.hasOwnProperty('__defaultOption')) { - var optList = []; - var Class = this.constructor; - while (Class) { - var opt = Class.prototype.defaultOption; - opt && optList.push(opt); - Class = Class.superClass; - } - - var defaultOption = {}; - for (var i = optList.length - 1; i >= 0; i--) { - defaultOption = zrUtil.merge(defaultOption, optList[i], true); - } - this.__defaultOption = defaultOption; - } - return this.__defaultOption; - } - - }); - - // Reset ComponentModel.extend, add preConstruct. - clazzUtil.enableClassExtend( - ComponentModel, - function (option, parentModel, ecModel, extraOpt) { - // Set dependentModels, componentIndex, name, id, mainType, subType. - zrUtil.extend(this, extraOpt); - - this.uid = componentUtil.getUID('componentModel'); - - this.setReadOnly([ - 'type', 'id', 'uid', 'name', 'mainType', 'subType', - 'dependentModels', 'componentIndex' - ]); - } - ); - - // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. - clazzUtil.enableClassManagement( - ComponentModel, {registerWhenExtend: true} - ); - componentUtil.enableSubTypeDefaulter(ComponentModel); - - // Add capability of ComponentModel.topologicalTravel. - componentUtil.enableTopologicalTravel(ComponentModel, getDependencies); - - function getDependencies(componentType) { - var deps = []; - zrUtil.each(ComponentModel.getClassesByMainType(componentType), function (Clazz) { - arrayPush.apply(deps, Clazz.prototype.dependencies || []); - }); - // Ensure main type - return zrUtil.map(deps, function (type) { - return clazzUtil.parseClassType(type).main; - }); - } - - zrUtil.mixin(ComponentModel, require('./mixin/boxLayout')); - - return ComponentModel; -}); -define('echarts/model/globalDefault',[],function () { - var platform = ''; - // Navigator not exists in node - if (typeof navigator !== 'undefined') { - platform = navigator.platform || ''; - } - return { - // 全图默认背景 - // backgroundColor: 'rgba(0,0,0,0)', - - // https://dribbble.com/shots/1065960-Infographic-Pie-chart-visualization - // color: ['#5793f3', '#d14a61', '#fd9c35', '#675bba', '#fec42c', '#dd4444', '#d4df5a', '#cd4870'], - // 浅色 - // color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'], - // color: ['#cc5664', '#9bd6ec', '#ea946e', '#8acaaa', '#f1ec64', '#ee8686', '#a48dc1', '#5da6bc', '#b9dcae'], - // 深色 - color: ['#c23531', '#314656', '#61a0a8', '#dd8668', '#91c7ae', '#6e7074', '#ca8622', '#bda29a', '#44525d', '#c4ccd3'], - - // 默认需要 Grid 配置项 - grid: {}, - // 主题,主题 - textStyle: { - // color: '#000', - // decoration: 'none', - // PENDING - fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif', - // fontFamily: 'Arial, Verdana, sans-serif', - fontSize: 12, - fontStyle: 'normal', - fontWeight: 'normal' - }, - // 主题,默认标志图形类型列表 - // symbolList: [ - // 'circle', 'rectangle', 'triangle', 'diamond', - // 'emptyCircle', 'emptyRectangle', 'emptyTriangle', 'emptyDiamond' - // ], - animation: true, // 过渡动画是否开启 - animationThreshold: 2000, // 动画元素阀值,产生的图形原素超过2000不出动画 - animationDuration: 1000, // 过渡动画参数:进入 - animationDurationUpdate: 300, // 过渡动画参数:更新 - animationEasing: 'exponentialOut', //BounceOut - animationEasingUpdate: 'cubicOut' - }; -}); -/** - * ECharts global model - * - * @module {echarts/model/Global} - * - */ - -define('echarts/model/Global',['require','zrender/core/util','../util/model','./Model','./Component','./globalDefault'],function (require) { - - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../util/model'); - var Model = require('./Model'); - var each = zrUtil.each; - var filter = zrUtil.filter; - var map = zrUtil.map; - var isArray = zrUtil.isArray; - var indexOf = zrUtil.indexOf; - var isObject = zrUtil.isObject; - - var ComponentModel = require('./Component'); - - var globalDefault = require('./globalDefault'); - - var OPTION_INNER_KEY = '\0_ec_inner'; - - /** - * @alias module:echarts/model/Global - * - * @param {Object} option - * @param {module:echarts/model/Model} parentModel - * @param {Object} theme - */ - var GlobalModel = Model.extend({ - - constructor: GlobalModel, - - init: function (option, parentModel, theme, optionManager) { - theme = theme || {}; - - this.option = null; // Mark as not initialized. - - /** - * @type {module:echarts/model/Model} - * @private - */ - this._theme = new Model(theme); - - /** - * @type {module:echarts/model/OptionManager} - */ - this._optionManager = optionManager; - }, - - setOption: function (option, optionPreprocessorFuncs) { - zrUtil.assert( - !(OPTION_INNER_KEY in option), - 'please use chart.getOption()' - ); - - this._optionManager.setOption(option, optionPreprocessorFuncs); - - this.resetOption(); - }, - - /** - * @param {string} type null/undefined: reset all. - * 'recreate': force recreate all. - * 'timeline': only reset timeline option - * 'media': only reset media query option - * @return {boolean} Whether option changed. - */ - resetOption: function (type) { - var optionChanged = false; - var optionManager = this._optionManager; - - if (!type || type === 'recreate') { - var baseOption = optionManager.mountOption(type === 'recreate'); - - if (!this.option || type === 'recreate') { - initBase.call(this, baseOption); - } - else { - this.restoreData(); - this.mergeOption(baseOption); - } - optionChanged = true; - } - - if (type === 'timeline' || type === 'media') { - this.restoreData(); - } - - if (!type || type === 'recreate' || type === 'timeline') { - var timelineOption = optionManager.getTimelineOption(this); - timelineOption && (this.mergeOption(timelineOption), optionChanged = true); - } - - if (!type || type === 'recreate' || type === 'media') { - var mediaOptions = optionManager.getMediaOption(this, this._api); - if (mediaOptions.length) { - each(mediaOptions, function (mediaOption) { - this.mergeOption(mediaOption, optionChanged = true); - }, this); - } - } - - return optionChanged; - }, - - /** - * @protected - */ - mergeOption: function (newOption) { - var option = this.option; - var componentsMap = this._componentsMap; - var newCptTypes = []; - - // 如果不存在对应的 component model 则直接 merge - each(newOption, function (componentOption, mainType) { - if (componentOption == null) { - return; - } - - if (!ComponentModel.hasClass(mainType)) { - option[mainType] = option[mainType] == null - ? zrUtil.clone(componentOption) - : zrUtil.merge(option[mainType], componentOption, true); - } - else { - newCptTypes.push(mainType); - } - }); - - // FIXME OPTION 同步是否要改回原来的 - ComponentModel.topologicalTravel( - newCptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this - ); - - function visitComponent(mainType, dependencies) { - var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]); - - var mapResult = modelUtil.mappingToExists( - componentsMap[mainType], newCptOptionList - ); - - makeKeyInfo(mainType, mapResult); - - var dependentModels = getComponentsByTypes( - componentsMap, dependencies - ); - - option[mainType] = []; - componentsMap[mainType] = []; - - each(mapResult, function (resultItem, index) { - var componentModel = resultItem.exist; - var newCptOption = resultItem.option; - - zrUtil.assert( - isObject(newCptOption) || componentModel, - 'Empty component definition' - ); - - // Consider where is no new option and should be merged using {}, - // see removeEdgeAndAdd in topologicalTravel and - // ComponentModel.getAllClassMainTypes. - if (!newCptOption) { - componentModel.mergeOption({}, this); - } - else { - var ComponentModelClass = ComponentModel.getClass( - mainType, resultItem.keyInfo.subType, true - ); - - if (componentModel && componentModel instanceof ComponentModelClass) { - componentModel.mergeOption(newCptOption, this); - } - else { - // PENDING Global as parent ? - componentModel = new ComponentModelClass( - newCptOption, this, this, - zrUtil.extend( - { - dependentModels: dependentModels, - componentIndex: index - }, - resultItem.keyInfo - ) - ); - } - } - - componentsMap[mainType][index] = componentModel; - option[mainType][index] = componentModel.option; - }, this); - - // Backup series for filtering. - if (mainType === 'series') { - this._seriesIndices = createSeriesIndices(componentsMap.series); - } - } - }, - - /** - * Get option for output (cloned option and inner info removed) - * @public - * @return {Object} - */ - getOption: function () { - var option = zrUtil.clone(this.option); - - each(option, function (opts, mainType) { - if (ComponentModel.hasClass(mainType)) { - var opts = modelUtil.normalizeToArray(opts); - for (var i = opts.length - 1; i >= 0; i--) { - // Remove options with inner id. - if (modelUtil.isIdInner(opts[i])) { - opts.splice(i, 1); - } - } - option[mainType] = opts; - } - }); - - delete option[OPTION_INNER_KEY]; - - return option; - }, - - /** - * @return {module:echarts/model/Model} - */ - getTheme: function () { - return this._theme; - }, - - /** - * @param {string} mainType - * @param {number} [idx=0] - * @return {module:echarts/model/Component} - */ - getComponent: function (mainType, idx) { - var list = this._componentsMap[mainType]; - if (list) { - return list[idx || 0]; - } - }, - - /** - * @param {Object} condition - * @param {string} condition.mainType - * @param {string} [condition.subType] If ignore, only query by mainType - * @param {number} [condition.index] Either input index or id or name. - * @param {string} [condition.id] Either input index or id or name. - * @param {string} [condition.name] Either input index or id or name. - * @return {Array.} - */ - queryComponents: function (condition) { - var mainType = condition.mainType; - if (!mainType) { - return []; - } - - var index = condition.index; - var id = condition.id; - var name = condition.name; - - var cpts = this._componentsMap[mainType]; - - if (!cpts || !cpts.length) { - return []; - } - - var result; - - if (index != null) { - if (!isArray(index)) { - index = [index]; - } - result = filter(map(index, function (idx) { - return cpts[idx]; - }), function (val) { - return !!val; - }); - } - else if (id != null) { - var isIdArray = isArray(id); - result = filter(cpts, function (cpt) { - return (isIdArray && indexOf(id, cpt.id) >= 0) - || (!isIdArray && cpt.id === id); - }); - } - else if (name != null) { - var isNameArray = isArray(name); - result = filter(cpts, function (cpt) { - return (isNameArray && indexOf(name, cpt.name) >= 0) - || (!isNameArray && cpt.name === name); - }); - } - - return filterBySubType(result, condition); - }, - - /** - * The interface is different from queryComponents, - * which is convenient for inner usage. - * - * @usage - * findComponents( - * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}, - * function (model, index) {...} - * ); - * - * findComponents( - * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}, - * function (model, index) {...} - * ); - * - * var result = findComponents( - * {mainType: 'series'}, - * function (model, index) {...} - * ); - * // result like [component0, componnet1, ...] - * - * @param {Object} condition - * @param {string} condition.mainType Mandatory. - * @param {string} [condition.subType] Optional. - * @param {Object} [condition.query] like {xxxIndex, xxxId, xxxName}, - * where xxx is mainType. - * If query attribute is null/undefined or has no index/id/name, - * do not filtering by query conditions, which is convenient for - * no-payload situations or when target of action is global. - * @param {Function} [condition.filter] parameter: component, return boolean. - * @return {Array.} - */ - findComponents: function (condition) { - var query = condition.query; - var mainType = condition.mainType; - - var queryCond = getQueryCond(query); - var result = queryCond - ? this.queryComponents(queryCond) - : this._componentsMap[mainType]; - - return doFilter(filterBySubType(result, condition)); - - function getQueryCond(q) { - var indexAttr = mainType + 'Index'; - var idAttr = mainType + 'Id'; - var nameAttr = mainType + 'Name'; - return q && ( - q.hasOwnProperty(indexAttr) - || q.hasOwnProperty(idAttr) - || q.hasOwnProperty(nameAttr) - ) - ? { - mainType: mainType, - // subType will be filtered finally. - index: q[indexAttr], - id: q[idAttr], - name: q[nameAttr] - } - : null; - } - - function doFilter(res) { - return condition.filter - ? filter(res, condition.filter) - : res; - } - }, - - /** - * @usage - * eachComponent('legend', function (legendModel, index) { - * ... - * }); - * eachComponent(function (componentType, model, index) { - * // componentType does not include subType - * // (componentType is 'xxx' but not 'xxx.aa') - * }); - * eachComponent( - * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}, - * function (model, index) {...} - * ); - * eachComponent( - * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}, - * function (model, index) {...} - * ); - * - * @param {string|Object=} mainType When mainType is object, the definition - * is the same as the method 'findComponents'. - * @param {Function} cb - * @param {*} context - */ - eachComponent: function (mainType, cb, context) { - var componentsMap = this._componentsMap; - - if (typeof mainType === 'function') { - context = cb; - cb = mainType; - each(componentsMap, function (components, componentType) { - each(components, function (component, index) { - cb.call(context, componentType, component, index); - }); - }); - } - else if (zrUtil.isString(mainType)) { - each(componentsMap[mainType], cb, context); - } - else if (isObject(mainType)) { - var queryResult = this.findComponents(mainType); - each(queryResult, cb, context); - } - }, - - /** - * @param {string} name - * @return {Array.} - */ - getSeriesByName: function (name) { - var series = this._componentsMap.series; - return filter(series, function (oneSeries) { - return oneSeries.name === name; - }); - }, - - /** - * @param {number} seriesIndex - * @return {module:echarts/model/Series} - */ - getSeriesByIndex: function (seriesIndex) { - return this._componentsMap.series[seriesIndex]; - }, - - /** - * @param {string} subType - * @return {Array.} - */ - getSeriesByType: function (subType) { - var series = this._componentsMap.series; - return filter(series, function (oneSeries) { - return oneSeries.subType === subType; - }); - }, - - /** - * @return {Array.} - */ - getSeries: function () { - return this._componentsMap.series.slice(); - }, - - /** - * After filtering, series may be different - * frome raw series. - * - * @param {Function} cb - * @param {*} context - */ - eachSeries: function (cb, context) { - assertSeriesInitialized(this); - each(this._seriesIndices, function (rawSeriesIndex) { - var series = this._componentsMap.series[rawSeriesIndex]; - cb.call(context, series, rawSeriesIndex); - }, this); - }, - - /** - * Iterate raw series before filtered. - * - * @param {Function} cb - * @param {*} context - */ - eachRawSeries: function (cb, context) { - each(this._componentsMap.series, cb, context); - }, - - /** - * After filtering, series may be different. - * frome raw series. - * - * @parma {string} subType - * @param {Function} cb - * @param {*} context - */ - eachSeriesByType: function (subType, cb, context) { - assertSeriesInitialized(this); - each(this._seriesIndices, function (rawSeriesIndex) { - var series = this._componentsMap.series[rawSeriesIndex]; - if (series.subType === subType) { - cb.call(context, series, rawSeriesIndex); - } - }, this); - }, - - /** - * Iterate raw series before filtered of given type. - * - * @parma {string} subType - * @param {Function} cb - * @param {*} context - */ - eachRawSeriesByType: function (subType, cb, context) { - return each(this.getSeriesByType(subType), cb, context); - }, - - /** - * @param {module:echarts/model/Series} seriesModel - */ - isSeriesFiltered: function (seriesModel) { - assertSeriesInitialized(this); - return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0; - }, - - /** - * @param {Function} cb - * @param {*} context - */ - filterSeries: function (cb, context) { - assertSeriesInitialized(this); - var filteredSeries = filter( - this._componentsMap.series, cb, context - ); - this._seriesIndices = createSeriesIndices(filteredSeries); - }, - - restoreData: function () { - var componentsMap = this._componentsMap; - - this._seriesIndices = createSeriesIndices(componentsMap.series); - - var componentTypes = []; - each(componentsMap, function (components, componentType) { - componentTypes.push(componentType); - }); - - ComponentModel.topologicalTravel( - componentTypes, - ComponentModel.getAllClassMainTypes(), - function (componentType, dependencies) { - each(componentsMap[componentType], function (component) { - component.restoreData(); - }); - } - ); - } - - }); - - /** - * @inner - */ - function mergeTheme(option, theme) { - for (var name in theme) { - // 如果有 component model 则把具体的 merge 逻辑交给该 model 处理 - if (!ComponentModel.hasClass(name)) { - if (typeof theme[name] === 'object') { - option[name] = !option[name] - ? zrUtil.clone(theme[name]) - : zrUtil.merge(option[name], theme[name], false); - } - else { - option[name] = theme[name]; - } - } - } - } - - function initBase(baseOption) { - baseOption = baseOption; - - // Using OPTION_INNER_KEY to mark that this option can not be used outside, - // i.e. `chart.setOption(chart.getModel().option);` is forbiden. - this.option = {}; - this.option[OPTION_INNER_KEY] = 1; - - /** - * @type {Object.>} - * @private - */ - this._componentsMap = {}; - - /** - * Mapping between filtered series list and raw series list. - * key: filtered series indices, value: raw series indices. - * @type {Array.} - * @private - */ - this._seriesIndices = null; - - mergeTheme(baseOption, this._theme.option); - - // TODO Needs clone when merging to the unexisted property - zrUtil.merge(baseOption, globalDefault, false); - - this.mergeOption(baseOption); - } - - /** - * @inner - * @param {Array.|string} types model types - * @return {Object} key: {string} type, value: {Array.} models - */ - function getComponentsByTypes(componentsMap, types) { - if (!zrUtil.isArray(types)) { - types = types ? [types] : []; - } - - var ret = {}; - each(types, function (type) { - ret[type] = (componentsMap[type] || []).slice(); - }); - - return ret; - } - - /** - * @inner - */ - function makeKeyInfo(mainType, mapResult) { - // We use this id to hash component models and view instances - // in echarts. id can be specified by user, or auto generated. - - // The id generation rule ensures new view instance are able - // to mapped to old instance when setOption are called in - // no-merge mode. So we generate model id by name and plus - // type in view id. - - // name can be duplicated among components, which is convenient - // to specify multi components (like series) by one name. - - // Ensure that each id is distinct. - var idMap = {}; - - each(mapResult, function (item, index) { - var existCpt = item.exist; - existCpt && (idMap[existCpt.id] = item); - }); - - each(mapResult, function (item, index) { - var opt = item.option; - - zrUtil.assert( - !opt || opt.id == null || !idMap[opt.id] || idMap[opt.id] === item, - 'id duplicates: ' + (opt && opt.id) - ); - - opt && opt.id != null && (idMap[opt.id] = item); - - // Complete subType - if (isObject(opt)) { - var subType = determineSubType(mainType, opt, item.exist); - item.keyInfo = {mainType: mainType, subType: subType}; - } - }); - - // Make name and id. - each(mapResult, function (item, index) { - var existCpt = item.exist; - var opt = item.option; - var keyInfo = item.keyInfo; - - if (!isObject(opt)) { - return; - } - - // name can be overwitten. Consider case: axis.name = '20km'. - // But id generated by name will not be changed, which affect - // only in that case: setOption with 'not merge mode' and view - // instance will be recreated, which can be accepted. - keyInfo.name = opt.name != null - ? opt.name + '' - : existCpt - ? existCpt.name - : '\0-'; - - if (existCpt) { - keyInfo.id = existCpt.id; - } - else if (opt.id != null) { - keyInfo.id = opt.id + ''; - } - else { - // Consider this situatoin: - // optionA: [{name: 'a'}, {name: 'a'}, {..}] - // optionB [{..}, {name: 'a'}, {name: 'a'}] - // Series with the same name between optionA and optionB - // should be mapped. - var idNum = 0; - do { - keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++; - } - while (idMap[keyInfo.id]); - } - - idMap[keyInfo.id] = item; - }); - } - - /** - * @inner - */ - function determineSubType(mainType, newCptOption, existComponent) { - var subType = newCptOption.type - ? newCptOption.type - : existComponent - ? existComponent.subType - // Use determineSubType only when there is no existComponent. - : ComponentModel.determineSubType(mainType, newCptOption); - - // tooltip, markline, markpoint may always has no subType - return subType; - } - - /** - * @inner - */ - function createSeriesIndices(seriesModels) { - return map(seriesModels, function (series) { - return series.componentIndex; - }) || []; - } - - /** - * @inner - */ - function filterBySubType(components, condition) { - // Using hasOwnProperty for restrict. Consider - // subType is undefined in user payload. - return condition.hasOwnProperty('subType') - ? filter(components, function (cpt) { - return cpt.subType === condition.subType; - }) - : components; - } - - /** - * @inner - */ - function assertSeriesInitialized(ecModel) { - // Components that use _seriesIndices should depends on series component, - // which make sure that their initialization is after series. - if (!ecModel._seriesIndices) { - // FIXME - // 验证和提示怎么写 - throw new Error('Series is not initialized. Please depends sereis.'); - } - } - - return GlobalModel; -}); -define('echarts/ExtensionAPI',['require','zrender/core/util'],function(require) { + getBoundingRect: function () { + if (!this._rect) { + var style = this.style; + var rect = textContain.getBoundingRect( + style.text + '', style.textFont || style.font, style.textAlign, style.textBaseline + ); + rect.x += style.x || 0; + rect.y += style.y || 0; + this._rect = rect; + } + return this._rect; + } + }; - + zrUtil.inherits(Text, Displayable); - var zrUtil = require('zrender/core/util'); + module.exports = Text; - var echartsAPIList = [ - 'getDom', 'getZr', 'getWidth', 'getHeight', 'dispatchAction', - 'on', 'off', 'getDataURL', 'getConnectedDataURL', 'getModel', 'getOption' - ]; - function ExtensionAPI(chartInstance) { - zrUtil.each(echartsAPIList, function (name) { - this[name] = zrUtil.bind(chartInstance[name], chartInstance); - }, this); - } +/***/ }, +/* 63 */ +/***/ function(module, exports, __webpack_require__) { - return ExtensionAPI; -}); -define('echarts/CoordinateSystem',['require'],function(require) { + 'use strict'; + /** + * 圆形 + * @module zrender/shape/Circle + */ - - // var zrUtil = require('zrender/core/util'); - var coordinateSystemCreators = {}; - function CoordinateSystemManager() { + module.exports = __webpack_require__(44).extend({ + + type: 'circle', - this._coordinateSystems = []; - } + shape: { + cx: 0, + cy: 0, + r: 0 + }, - CoordinateSystemManager.prototype = { + buildPath : function (ctx, shape) { + // Better stroking in ShapeBundle + ctx.moveTo(shape.cx + shape.r, shape.cy); + ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true); + return; + } + }); - constructor: CoordinateSystemManager, - create: function (ecModel, api) { - var coordinateSystems = []; - for (var type in coordinateSystemCreators) { - var list = coordinateSystemCreators[type].create(ecModel, api); - list && (coordinateSystems = coordinateSystems.concat(list)); - } - this._coordinateSystems = coordinateSystems; - }, +/***/ }, +/* 64 */ +/***/ function(module, exports, __webpack_require__) { - update: function (ecModel, api) { - var coordinateSystems = this._coordinateSystems; - for (var i = 0; i < coordinateSystems.length; i++) { - // FIXME MUST have - coordinateSystems[i].update && coordinateSystems[i].update(ecModel, api); - } - } - }; + /** + * 扇形 + * @module zrender/graphic/shape/Sector + */ - CoordinateSystemManager.register = function (type, coordinateSystemCreator) { - coordinateSystemCreators[type] = coordinateSystemCreator; - }; + // FIXME clockwise seems wrong - CoordinateSystemManager.get = function (type) { - return coordinateSystemCreators[type]; - }; - return CoordinateSystemManager; -}); -/** - * ECharts option manager - * - * @module {echarts/model/OptionManager} - */ - -define('echarts/model/OptionManager',['require','zrender/core/util','../util/model','./Component'],function (require) { - - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../util/model'); - var ComponentModel = require('./Component'); - var each = zrUtil.each; - var clone = zrUtil.clone; - var map = zrUtil.map; - var merge = zrUtil.merge; - - var QUERY_REG = /^(min|max)?(.+)$/; - - /** - * TERM EXPLANATIONS: - * - * [option]: - * - * An object that contains definitions of components. For example: - * var option = { - * title: {...}, - * legend: {...}, - * visualMap: {...}, - * series: [ - * {data: [...]}, - * {data: [...]}, - * ... - * ] - * }; - * - * [rawOption]: - * - * An object input to echarts.setOption. 'rawOption' may be an - * 'option', or may be an object contains multi-options. For example: - * var option = { - * baseOption: { - * title: {...}, - * legend: {...}, - * series: [ - * {data: [...]}, - * {data: [...]}, - * ... - * ] - * }, - * timeline: {...}, - * options: [ - * {title: {...}, series: {data: [...]}}, - * {title: {...}, series: {data: [...]}}, - * ... - * ], - * media: [ - * { - * query: {maxWidth: 320}, - * option: {series: {x: 20}, visualMap: {show: false}} - * }, - * { - * query: {minWidth: 320, maxWidth: 720}, - * option: {series: {x: 500}, visualMap: {show: true}} - * }, - * { - * option: {series: {x: 1200}, visualMap: {show: true}} - * } - * ] - * }; - * - * @alias module:echarts/model/OptionManager - * @param {module:echarts/ExtensionAPI} api - */ - function OptionManager(api) { - - /** - * @private - * @type {module:echarts/ExtensionAPI} - */ - this._api = api; - - /** - * @private - * @type {Array.} - */ - this._timelineOptions = []; - - /** - * @private - * @type {Array.} - */ - this._mediaList = []; - - /** - * @private - * @type {Object} - */ - this._mediaDefault; - - /** - * -1, means default. - * empty means no media. - * @private - * @type {Array.} - */ - this._currentMediaIndices = []; - - /** - * @private - * @type {Object} - */ - this._optionBackup; - - /** - * @private - * @type {Object} - */ - this._newOptionBackup; - } - - // timeline.notMerge is not supported in ec3. Firstly there is rearly - // case that notMerge is needed. Secondly supporting 'notMerge' requires - // rawOption cloned and backuped when timeline changed, which does no - // good to performance. What's more, that both timeline and setOption - // method supply 'notMerge' brings complex and some problems. - // Consider this case: - // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false); - // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false); - - OptionManager.prototype = { - - constructor: OptionManager, - - /** - * @public - * @param {Object} rawOption Raw option. - * @param {module:echarts/model/Global} ecModel - * @param {Array.} optionPreprocessorFuncs - * @return {Object} Init option - */ - setOption: function (rawOption, optionPreprocessorFuncs) { - rawOption = clone(rawOption, true); - - // FIXME - // 如果 timeline options 或者 media 中设置了某个属性,而baseOption中没有设置,则进行警告。 - - var oldOptionBackup = this._optionBackup; - var newOptionBackup = this._newOptionBackup = parseRawOption.call( - this, rawOption, optionPreprocessorFuncs - ); - - // For setOption at second time (using merge mode); - if (oldOptionBackup) { - // Only baseOption can be merged. - mergeOption(oldOptionBackup.baseOption, newOptionBackup.baseOption); - - if (newOptionBackup.timelineOptions.length) { - oldOptionBackup.timelineOptions = newOptionBackup.timelineOptions; - } - if (newOptionBackup.mediaList.length) { - oldOptionBackup.mediaList = newOptionBackup.mediaList; - } - if (newOptionBackup.mediaDefault) { - oldOptionBackup.mediaDefault = newOptionBackup.mediaDefault; - } - } - else { - this._optionBackup = newOptionBackup; - } - }, - - /** - * @param {boolean} isRecreate - * @return {Object} - */ - mountOption: function (isRecreate) { - var optionBackup = isRecreate - // this._optionBackup can be only used when recreate. - // In other cases we use model.mergeOption to handle merge. - ? this._optionBackup : this._newOptionBackup; - - // FIXME - // 如果没有reset功能则不clone。 - - this._timelineOptions = map(optionBackup.timelineOptions, clone); - this._mediaList = map(optionBackup.mediaList, clone); - this._mediaDefault = clone(optionBackup.mediaDefault); - this._currentMediaIndices = []; - - return clone(optionBackup.baseOption); - }, - - /** - * @param {module:echarts/model/Global} ecModel - * @return {Object} - */ - getTimelineOption: function (ecModel) { - var option; - var timelineOptions = this._timelineOptions; - - if (timelineOptions.length) { - // getTimelineOption can only be called after ecModel inited, - // so we can get currentIndex from timelineModel. - var timelineModel = ecModel.getComponent('timeline'); - if (timelineModel) { - option = clone( - timelineOptions[timelineModel.getCurrentIndex()], - true - ); - } - } - - return option; - }, - - /** - * @param {module:echarts/model/Global} ecModel - * @return {Array.} - */ - getMediaOption: function (ecModel) { - var ecWidth = this._api.getWidth(); - var ecHeight = this._api.getHeight(); - var mediaList = this._mediaList; - var mediaDefault = this._mediaDefault; - var indices = []; - var result = []; - - // No media defined. - if (!mediaList.length && !mediaDefault) { - return result; - } - - // Multi media may be applied, the latter defined media has higher priority. - for (var i = 0, len = mediaList.length; i < len; i++) { - if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) { - indices.push(i); - } - } - - // FIXME - // 是否mediaDefault应该强制用户设置,否则可能修改不能回归。 - if (!indices.length && mediaDefault) { - indices = [-1]; - } - - if (indices.length && !indicesEquals(indices, this._currentMediaIndices)) { - result = map(indices, function (index) { - return clone( - index === -1 ? mediaDefault.option : mediaList[index].option - ); - }); - } - // Otherwise return nothing. - - this._currentMediaIndices = indices; - - return result; - } - }; - - function parseRawOption(rawOption, optionPreprocessorFuncs) { - var timelineOptions = []; - var mediaList = []; - var mediaDefault; - var baseOption; - - // Compatible with ec2. - var timelineOpt = rawOption.timeline; - - if (rawOption.baseOption) { - baseOption = rawOption.baseOption; - } - - // For timeline - if (timelineOpt || rawOption.options) { - baseOption = baseOption || {}; - timelineOptions = (rawOption.options || []).slice(); - } - // For media query - if (rawOption.media) { - baseOption = baseOption || {}; - var media = rawOption.media; - each(media, function (singleMedia) { - if (singleMedia && singleMedia.option) { - if (singleMedia.query) { - mediaList.push(singleMedia); - } - else if (!mediaDefault) { - // Use the first media default. - mediaDefault = singleMedia; - } - } - }); - } - - // For normal option - if (!baseOption) { - baseOption = rawOption; - } - - // Set timelineOpt to baseOption in ec3, - // which is convenient for merge option. - if (!baseOption.timeline) { - baseOption.timeline = timelineOpt; - } - - // Preprocess. - each([baseOption].concat(timelineOptions) - .concat(zrUtil.map(mediaList, function (media) { - return media.option; - })), - function (option) { - each(optionPreprocessorFuncs, function (preProcess) { - preProcess(option); - }); - } - ); - - return { - baseOption: baseOption, - timelineOptions: timelineOptions, - mediaDefault: mediaDefault, - mediaList: mediaList - }; - } - - /** - * @see - * Support: width, height, aspectRatio - * Can use max or min as prefix. - */ - function applyMediaQuery(query, ecWidth, ecHeight) { - var realMap = { - width: ecWidth, - height: ecHeight, - aspectratio: ecWidth / ecHeight // lowser case for convenientce. - }; - - var applicatable = true; - - zrUtil.each(query, function (value, attr) { - var matched = attr.match(QUERY_REG); - - if (!matched || !matched[1] || !matched[2]) { - return; - } - - var operator = matched[1]; - var realAttr = matched[2].toLowerCase(); - - if (!compare(realMap[realAttr], value, operator)) { - applicatable = false; - } - }); - - return applicatable; - } - - function compare(real, expect, operator) { - if (operator === 'min') { - return real >= expect; - } - else if (operator === 'max') { - return real <= expect; - } - else { // Equals - return real === expect; - } - } - - function indicesEquals(indices1, indices2) { - // indices is always order by asc and has only finite number. - return indices1.join(',') === indices2.join(','); - } - - /** - * Consider case: - * `chart.setOption(opt1);` - * Then user do some interaction like dataZoom, dataView changing. - * `chart.setOption(opt2);` - * Then user press 'reset button' in toolbox. - * - * After doing that all of the interaction effects should be reset, the - * chart should be the same as the result of invoke - * `chart.setOption(opt1); chart.setOption(opt2);`. - * - * Although it is not able ensure that - * `chart.setOption(opt1); chart.setOption(opt2);` is equivalents to - * `chart.setOption(merge(opt1, opt2));` exactly, - * this might be the only simple way to implement that feature. - * - * MEMO: We've considered some other approaches: - * 1. Each model handle its self restoration but not uniform treatment. - * (Too complex in logic and error-prone) - * 2. Use a shadow ecModel. (Performace expensive) - */ - function mergeOption(oldOption, newOption) { - newOption = newOption || {}; - - each(newOption, function (newCptOpt, mainType) { - if (newCptOpt == null) { - return; - } - - var oldCptOpt = oldOption[mainType]; - - if (!ComponentModel.hasClass(mainType)) { - oldOption[mainType] = merge(oldCptOpt, newCptOpt, true); - } - else { - newCptOpt = modelUtil.normalizeToArray(newCptOpt); - oldCptOpt = modelUtil.normalizeToArray(oldCptOpt); - - var mapResult = modelUtil.mappingToExists(oldCptOpt, newCptOpt); - - oldOption[mainType] = map(mapResult, function (item) { - return (item.option && item.exist) - ? merge(item.exist, item.option, true) - : (item.exist || item.option); - }); - } - }); - } - - return OptionManager; -}); -define('echarts/model/Series',['require','zrender/core/util','../util/format','../util/model','./Component'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var formatUtil = require('../util/format'); - var modelUtil = require('../util/model'); - var ComponentModel = require('./Component'); - - var encodeHTML = formatUtil.encodeHTML; - var addCommas = formatUtil.addCommas; - - var SeriesModel = ComponentModel.extend({ - - type: 'series', - - /** - * @readOnly - */ - seriesIndex: 0, - - // coodinateSystem will be injected in the echarts/CoordinateSystem - coordinateSystem: null, - - /** - * @type {Object} - * @protected - */ - defaultOption: null, - - /** - * Data provided for legend - * @type {Function} - */ - // PENDING - legendDataProvider: null, - - init: function (option, parentModel, ecModel, extraOpt) { - - /** - * @type {number} - * @readOnly - */ - this.seriesIndex = this.componentIndex; - - this.mergeDefaultAndTheme(option, ecModel); - - /** - * @type {module:echarts/data/List|module:echarts/data/Tree|module:echarts/data/Graph} - * @private - */ - this._dataBeforeProcessed = this.getInitialData(option, ecModel); - - // When using module:echarts/data/Tree or module:echarts/data/Graph, - // cloneShallow will cause this._data.graph.data pointing to new data list. - // Wo we make this._dataBeforeProcessed first, and then make this._data. - this._data = this._dataBeforeProcessed.cloneShallow(); - }, - - /** - * Util for merge default and theme to option - * @param {Object} option - * @param {module:echarts/model/Global} ecModel - */ - mergeDefaultAndTheme: function (option, ecModel) { - zrUtil.merge( - option, - ecModel.getTheme().get(this.subType) - ); - zrUtil.merge(option, this.getDefaultOption()); - - // Default label emphasis `position` and `show` - modelUtil.defaultEmphasis( - option.label, ['position', 'show', 'textStyle', 'distance', 'formatter'] - ); - }, - - mergeOption: function (newSeriesOption, ecModel) { - newSeriesOption = zrUtil.merge(this.option, newSeriesOption, true); - - var data = this.getInitialData(newSeriesOption, ecModel); - // TODO Merge data? - if (data) { - this._data = data; - this._dataBeforeProcessed = data.cloneShallow(); - } - }, - - /** - * Init a data structure from data related option in series - * Must be overwritten - */ - getInitialData: function () {}, - - /** - * @return {module:echarts/data/List} - */ - getData: function () { - return this._data; - }, - - /** - * @param {module:echarts/data/List} data - */ - setData: function (data) { - this._data = data; - }, - - /** - * Get data before processed - * @return {module:echarts/data/List} - */ - getRawData: function () { - return this._dataBeforeProcessed; - }, - - /** - * Get raw data array given by user - * @return {Array.} - */ - getRawDataArray: function () { - return this.option.data; - }, - - /** - * Coord dimension to data dimension. - * - * By default the result is the same as dimensions of series data. - * But some series dimensions are different from coord dimensions (i.e. - * candlestick and boxplot). Override this method to handle those cases. - * - * Coord dimension to data dimension can be one-to-many - * - * @param {string} coordDim - * @return {Array.} dimensions on the axis. - */ - coordDimToDataDim: function (coordDim) { - return [coordDim]; - }, - - /** - * Convert data dimension to coord dimension. - * - * @param {string|number} dataDim - * @return {string} - */ - dataDimToCoordDim: function (dataDim) { - return dataDim; - }, - - /** - * Get base axis if has coordinate system and has axis. - * By default use coordSys.getBaseAxis(); - * Can be overrided for some chart. - * @return {type} description - */ - getBaseAxis: function () { - var coordSys = this.coordinateSystem; - return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis(); - }, - - // FIXME - /** - * Default tooltip formatter - * - * @param {number} dataIndex - * @param {boolean} [mutipleSeries=false] - */ - formatTooltip: function (dataIndex, mutipleSeries) { - var data = this._data; - var value = this.getRawValue(dataIndex); - var formattedValue = zrUtil.isArray(value) - ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); - var name = data.getName(dataIndex); - - return !mutipleSeries - ? (encodeHTML(this.name) + '
' - + (name - ? encodeHTML(name) + ' : ' + formattedValue - : formattedValue) - ) - : (encodeHTML(this.name) + ' : ' + formattedValue); - }, - - restoreData: function () { - this._data = this._dataBeforeProcessed.cloneShallow(); - } - }); - - zrUtil.mixin(SeriesModel, modelUtil.dataFormatMixin); - - return SeriesModel; -}); -/** - * zrender: 生成唯一id - * - * @author errorrik (errorrik@gmail.com) - */ - -define( - 'zrender/core/guid',[],function() { - var idStart = 0x0907; - - return function () { - return 'zr_' + (idStart++); - }; - } -); - -/** - * 事件扩展 - * @module zrender/mixin/Eventful - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - * pissang (https://www.github.com/pissang) - */ -define('zrender/mixin/Eventful',['require','../core/util'],function (require) { - - var arrySlice = Array.prototype.slice; - var zrUtil = require('../core/util'); - var indexOf = zrUtil.indexOf; - - /** - * 事件分发器 - * @alias module:zrender/mixin/Eventful - * @constructor - */ - var Eventful = function () { - this._$handlers = {}; - }; - - Eventful.prototype = { - - constructor: Eventful, - - /** - * 单次触发绑定,trigger后销毁 - * - * @param {string} event 事件名 - * @param {Function} handler 响应函数 - * @param {Object} context - */ - one: function (event, handler, context) { - var _h = this._$handlers; - - if (!handler || !event) { - return this; - } - - if (!_h[event]) { - _h[event] = []; - } - - if (indexOf(_h[event], event) >= 0) { - return this; - } - - _h[event].push({ - h: handler, - one: true, - ctx: context || this - }); - - return this; - }, - - /** - * 绑定事件 - * @param {string} event 事件名 - * @param {Function} handler 事件处理函数 - * @param {Object} [context] - */ - on: function (event, handler, context) { - var _h = this._$handlers; - - if (!handler || !event) { - return this; - } - - if (!_h[event]) { - _h[event] = []; - } - - _h[event].push({ - h: handler, - one: false, - ctx: context || this - }); - - return this; - }, - - /** - * 是否绑定了事件 - * @param {string} event - * @return {boolean} - */ - isSilent: function (event) { - var _h = this._$handlers; - return _h[event] && _h[event].length; - }, - - /** - * 解绑事件 - * @param {string} event 事件名 - * @param {Function} [handler] 事件处理函数 - */ - off: function (event, handler) { - var _h = this._$handlers; - - if (!event) { - this._$handlers = {}; - return this; - } - - if (handler) { - if (_h[event]) { - var newList = []; - for (var i = 0, l = _h[event].length; i < l; i++) { - if (_h[event][i]['h'] != handler) { - newList.push(_h[event][i]); - } - } - _h[event] = newList; - } - - if (_h[event] && _h[event].length === 0) { - delete _h[event]; - } - } - else { - delete _h[event]; - } - - return this; - }, - - /** - * 事件分发 - * - * @param {string} type 事件类型 - */ - trigger: function (type) { - if (this._$handlers[type]) { - var args = arguments; - var argLen = args.length; - - if (argLen > 3) { - args = arrySlice.call(args, 1); - } - - var _h = this._$handlers[type]; - var len = _h.length; - for (var i = 0; i < len;) { - // Optimize advise from backbone - switch (argLen) { - case 1: - _h[i]['h'].call(_h[i]['ctx']); - break; - case 2: - _h[i]['h'].call(_h[i]['ctx'], args[1]); - break; - case 3: - _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]); - break; - default: - // have more than 2 given arguments - _h[i]['h'].apply(_h[i]['ctx'], args); - break; - } - - if (_h[i]['one']) { - _h.splice(i, 1); - len--; - } - else { - i++; - } - } - } - - return this; - }, - - /** - * 带有context的事件分发, 最后一个参数是事件回调的context - * @param {string} type 事件类型 - */ - triggerWithContext: function (type) { - if (this._$handlers[type]) { - var args = arguments; - var argLen = args.length; - - if (argLen > 4) { - args = arrySlice.call(args, 1, args.length - 1); - } - var ctx = args[args.length - 1]; - - var _h = this._$handlers[type]; - var len = _h.length; - for (var i = 0; i < len;) { - // Optimize advise from backbone - switch (argLen) { - case 1: - _h[i]['h'].call(ctx); - break; - case 2: - _h[i]['h'].call(ctx, args[1]); - break; - case 3: - _h[i]['h'].call(ctx, args[1], args[2]); - break; - default: - // have more than 2 given arguments - _h[i]['h'].apply(ctx, args); - break; - } - - if (_h[i]['one']) { - _h.splice(i, 1); - len--; - } - else { - i++; - } - } - } - - return this; - } - }; - - // 对象可以通过 onxxxx 绑定事件 - /** - * @event module:zrender/mixin/Eventful#onclick - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmouseover - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmouseout - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmousemove - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmousewheel - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmousedown - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmouseup - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragstart - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragend - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragenter - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragleave - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragover - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondrop - * @type {Function} - * @default null - */ - - return Eventful; -}); + module.exports = __webpack_require__(44).extend({ -/** - * 提供变换扩展 - * @module zrender/mixin/Transformable - * @author pissang (https://www.github.com/pissang) - */ -define('zrender/mixin/Transformable',['require','../core/matrix','../core/vector'],function (require) { - - - - var matrix = require('../core/matrix'); - var vector = require('../core/vector'); - var mIdentity = matrix.identity; - - var EPSILON = 5e-5; - - function isNotAroundZero(val) { - return val > EPSILON || val < -EPSILON; - } - - /** - * @alias module:zrender/mixin/Transformable - * @constructor - */ - var Transformable = function (opts) { - opts = opts || {}; - // If there are no given position, rotation, scale - if (!opts.position) { - /** - * 平移 - * @type {Array.} - * @default [0, 0] - */ - this.position = [0, 0]; - } - if (opts.rotation == null) { - /** - * 旋转 - * @type {Array.} - * @default 0 - */ - this.rotation = 0; - } - if (!opts.scale) { - /** - * 缩放 - * @type {Array.} - * @default [1, 1] - */ - this.scale = [1, 1]; - } - /** - * 旋转和缩放的原点 - * @type {Array.} - * @default null - */ - this.origin = this.origin || null; - }; - - var transformableProto = Transformable.prototype; - transformableProto.transform = null; - - /** - * 判断是否需要有坐标变换 - * 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵 - */ - transformableProto.needLocalTransform = function () { - return isNotAroundZero(this.rotation) - || isNotAroundZero(this.position[0]) - || isNotAroundZero(this.position[1]) - || isNotAroundZero(this.scale[0] - 1) - || isNotAroundZero(this.scale[1] - 1); - }; - - transformableProto.updateTransform = function () { - var parent = this.parent; - var parentHasTransform = parent && parent.transform; - var needLocalTransform = this.needLocalTransform(); - - var m = this.transform; - if (!(needLocalTransform || parentHasTransform)) { - m && mIdentity(m); - return; - } - - m = m || matrix.create(); - - if (needLocalTransform) { - this.getLocalTransform(m); - } - else { - mIdentity(m); - } - - // 应用父节点变换 - if (parentHasTransform) { - if (needLocalTransform) { - matrix.mul(m, parent.transform, m); - } - else { - matrix.copy(m, parent.transform); - } - } - // 保存这个变换矩阵 - this.transform = m; - - this.invTransform = this.invTransform || matrix.create(); - matrix.invert(this.invTransform, m); - }; - - transformableProto.getLocalTransform = function (m) { - m = m || []; - mIdentity(m); - - var origin = this.origin; - - var scale = this.scale; - var rotation = this.rotation; - var position = this.position; - if (origin) { - // Translate to origin - m[4] -= origin[0]; - m[5] -= origin[1]; - } - matrix.scale(m, m, scale); - if (rotation) { - matrix.rotate(m, m, rotation); - } - if (origin) { - // Translate back from origin - m[4] += origin[0]; - m[5] += origin[1]; - } - - m[4] += position[0]; - m[5] += position[1]; - - return m; - }; - /** - * 将自己的transform应用到context上 - * @param {Context2D} ctx - */ - transformableProto.setTransform = function (ctx) { - var m = this.transform; - if (m) { - ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); - } - }; - - var tmpTransform = []; - - /** - * 分解`transform`矩阵到`position`, `rotation`, `scale` - */ - transformableProto.decomposeTransform = function () { - if (!this.transform) { - return; - } - var parent = this.parent; - var m = this.transform; - if (parent && parent.transform) { - // Get local transform and decompose them to position, scale, rotation - matrix.mul(tmpTransform, parent.invTransform, m); - m = tmpTransform; - } - var sx = m[0] * m[0] + m[1] * m[1]; - var sy = m[2] * m[2] + m[3] * m[3]; - var position = this.position; - var scale = this.scale; - if (isNotAroundZero(sx - 1)) { - sx = Math.sqrt(sx); - } - if (isNotAroundZero(sy - 1)) { - sy = Math.sqrt(sy); - } - if (m[0] < 0) { - sx = -sx; - } - if (m[3] < 0) { - sy = -sy; - } - position[0] = m[4]; - position[1] = m[5]; - scale[0] = sx; - scale[1] = sy; - this.rotation = Math.atan2(-m[1] / sy, m[0] / sx); - }; - - /** - * 变换坐标位置到 shape 的局部坐标空间 - * @method - * @param {number} x - * @param {number} y - * @return {Array.} - */ - transformableProto.transformCoordToLocal = function (x, y) { - var v2 = [x, y]; - var invTransform = this.invTransform; - if (invTransform) { - vector.applyTransform(v2, v2, invTransform); - } - return v2; - }; - - /** - * 变换局部坐标位置到全局坐标空间 - * @method - * @param {number} x - * @param {number} y - * @return {Array.} - */ - transformableProto.transformCoordToGlobal = function (x, y) { - var v2 = [x, y]; - var transform = this.transform; - if (transform) { - vector.applyTransform(v2, v2, transform); - } - return v2; - }; - - return Transformable; -}); + type: 'sector', -/** - * 缓动代码来自 https://github.com/sole/tween.js/blob/master/src/Tween.js - * @see http://sole.github.io/tween.js/examples/03_graphs.html - * @exports zrender/animation/easing - */ -define('zrender/animation/easing',[],function () { - var easing = { - /** - * @param {number} k - * @return {number} - */ - linear: function (k) { - return k; - }, - - /** - * @param {number} k - * @return {number} - */ - quadraticIn: function (k) { - return k * k; - }, - /** - * @param {number} k - * @return {number} - */ - quadraticOut: function (k) { - return k * (2 - k); - }, - /** - * @param {number} k - * @return {number} - */ - quadraticInOut: function (k) { - if ((k *= 2) < 1) { - return 0.5 * k * k; - } - return -0.5 * (--k * (k - 2) - 1); - }, - - // 三次方的缓动(t^3) - /** - * @param {number} k - * @return {number} - */ - cubicIn: function (k) { - return k * k * k; - }, - /** - * @param {number} k - * @return {number} - */ - cubicOut: function (k) { - return --k * k * k + 1; - }, - /** - * @param {number} k - * @return {number} - */ - cubicInOut: function (k) { - if ((k *= 2) < 1) { - return 0.5 * k * k * k; - } - return 0.5 * ((k -= 2) * k * k + 2); - }, - - // 四次方的缓动(t^4) - /** - * @param {number} k - * @return {number} - */ - quarticIn: function (k) { - return k * k * k * k; - }, - /** - * @param {number} k - * @return {number} - */ - quarticOut: function (k) { - return 1 - (--k * k * k * k); - }, - /** - * @param {number} k - * @return {number} - */ - quarticInOut: function (k) { - if ((k *= 2) < 1) { - return 0.5 * k * k * k * k; - } - return -0.5 * ((k -= 2) * k * k * k - 2); - }, - - // 五次方的缓动(t^5) - /** - * @param {number} k - * @return {number} - */ - quinticIn: function (k) { - return k * k * k * k * k; - }, - /** - * @param {number} k - * @return {number} - */ - quinticOut: function (k) { - return --k * k * k * k * k + 1; - }, - /** - * @param {number} k - * @return {number} - */ - quinticInOut: function (k) { - if ((k *= 2) < 1) { - return 0.5 * k * k * k * k * k; - } - return 0.5 * ((k -= 2) * k * k * k * k + 2); - }, - - // 正弦曲线的缓动(sin(t)) - /** - * @param {number} k - * @return {number} - */ - sinusoidalIn: function (k) { - return 1 - Math.cos(k * Math.PI / 2); - }, - /** - * @param {number} k - * @return {number} - */ - sinusoidalOut: function (k) { - return Math.sin(k * Math.PI / 2); - }, - /** - * @param {number} k - * @return {number} - */ - sinusoidalInOut: function (k) { - return 0.5 * (1 - Math.cos(Math.PI * k)); - }, - - // 指数曲线的缓动(2^t) - /** - * @param {number} k - * @return {number} - */ - exponentialIn: function (k) { - return k === 0 ? 0 : Math.pow(1024, k - 1); - }, - /** - * @param {number} k - * @return {number} - */ - exponentialOut: function (k) { - return k === 1 ? 1 : 1 - Math.pow(2, -10 * k); - }, - /** - * @param {number} k - * @return {number} - */ - exponentialInOut: function (k) { - if (k === 0) { - return 0; - } - if (k === 1) { - return 1; - } - if ((k *= 2) < 1) { - return 0.5 * Math.pow(1024, k - 1); - } - return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2); - }, - - // 圆形曲线的缓动(sqrt(1-t^2)) - /** - * @param {number} k - * @return {number} - */ - circularIn: function (k) { - return 1 - Math.sqrt(1 - k * k); - }, - /** - * @param {number} k - * @return {number} - */ - circularOut: function (k) { - return Math.sqrt(1 - (--k * k)); - }, - /** - * @param {number} k - * @return {number} - */ - circularInOut: function (k) { - if ((k *= 2) < 1) { - return -0.5 * (Math.sqrt(1 - k * k) - 1); - } - return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); - }, - - // 创建类似于弹簧在停止前来回振荡的动画 - /** - * @param {number} k - * @return {number} - */ - elasticIn: function (k) { - var s; - var a = 0.1; - var p = 0.4; - if (k === 0) { - return 0; - } - if (k === 1) { - return 1; - } - if (!a || a < 1) { - a = 1; s = p / 4; - } - else { - s = p * Math.asin(1 / a) / (2 * Math.PI); - } - return -(a * Math.pow(2, 10 * (k -= 1)) * - Math.sin((k - s) * (2 * Math.PI) / p)); - }, - /** - * @param {number} k - * @return {number} - */ - elasticOut: function (k) { - var s; - var a = 0.1; - var p = 0.4; - if (k === 0) { - return 0; - } - if (k === 1) { - return 1; - } - if (!a || a < 1) { - a = 1; s = p / 4; - } - else { - s = p * Math.asin(1 / a) / (2 * Math.PI); - } - return (a * Math.pow(2, -10 * k) * - Math.sin((k - s) * (2 * Math.PI) / p) + 1); - }, - /** - * @param {number} k - * @return {number} - */ - elasticInOut: function (k) { - var s; - var a = 0.1; - var p = 0.4; - if (k === 0) { - return 0; - } - if (k === 1) { - return 1; - } - if (!a || a < 1) { - a = 1; s = p / 4; - } - else { - s = p * Math.asin(1 / a) / (2 * Math.PI); - } - if ((k *= 2) < 1) { - return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) - * Math.sin((k - s) * (2 * Math.PI) / p)); - } - return a * Math.pow(2, -10 * (k -= 1)) - * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1; - - }, - - // 在某一动画开始沿指示的路径进行动画处理前稍稍收回该动画的移动 - /** - * @param {number} k - * @return {number} - */ - backIn: function (k) { - var s = 1.70158; - return k * k * ((s + 1) * k - s); - }, - /** - * @param {number} k - * @return {number} - */ - backOut: function (k) { - var s = 1.70158; - return --k * k * ((s + 1) * k + s) + 1; - }, - /** - * @param {number} k - * @return {number} - */ - backInOut: function (k) { - var s = 1.70158 * 1.525; - if ((k *= 2) < 1) { - return 0.5 * (k * k * ((s + 1) * k - s)); - } - return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); - }, - - // 创建弹跳效果 - /** - * @param {number} k - * @return {number} - */ - bounceIn: function (k) { - return 1 - easing.bounceOut(1 - k); - }, - /** - * @param {number} k - * @return {number} - */ - bounceOut: function (k) { - if (k < (1 / 2.75)) { - return 7.5625 * k * k; - } - else if (k < (2 / 2.75)) { - return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75; - } - else if (k < (2.5 / 2.75)) { - return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375; - } - else { - return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; - } - }, - /** - * @param {number} k - * @return {number} - */ - bounceInOut: function (k) { - if (k < 0.5) { - return easing.bounceIn(k * 2) * 0.5; - } - return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5; - } - }; - - return easing; -}); + shape: { + cx: 0, -/** - * 动画主控制器 - * @config target 动画对象,可以是数组,如果是数组的话会批量分发onframe等事件 - * @config life(1000) 动画时长 - * @config delay(0) 动画延迟时间 - * @config loop(true) - * @config gap(0) 循环的间隔时间 - * @config onframe - * @config easing(optional) - * @config ondestroy(optional) - * @config onrestart(optional) - * - * TODO pause - */ -define('zrender/animation/Clip',['require','./easing'],function(require) { - - var easingFuncs = require('./easing'); - - function Clip(options) { - - this._target = options.target; - - // 生命周期 - this._life = options.life || 1000; - // 延时 - this._delay = options.delay || 0; - // 开始时间 - // this._startTime = new Date().getTime() + this._delay;// 单位毫秒 - this._initialized = false; - - // 是否循环 - this.loop = options.loop == null ? false : options.loop; - - this.gap = options.gap || 0; - - this.easing = options.easing || 'Linear'; - - this.onframe = options.onframe; - this.ondestroy = options.ondestroy; - this.onrestart = options.onrestart; - } - - Clip.prototype = { - - constructor: Clip, - - step: function (time) { - // Set startTime on first step, or _startTime may has milleseconds different between clips - // PENDING - if (!this._initialized) { - this._startTime = new Date().getTime() + this._delay; - this._initialized = true; - } - - var percent = (time - this._startTime) / this._life; - - // 还没开始 - if (percent < 0) { - return; - } - - percent = Math.min(percent, 1); - - var easing = this.easing; - var easingFunc = typeof easing == 'string' ? easingFuncs[easing] : easing; - var schedule = typeof easingFunc === 'function' - ? easingFunc(percent) - : percent; - - this.fire('frame', schedule); - - // 结束 - if (percent == 1) { - if (this.loop) { - this.restart(); - // 重新开始周期 - // 抛出而不是直接调用事件直到 stage.update 后再统一调用这些事件 - return 'restart'; - } - - // 动画完成将这个控制器标识为待删除 - // 在Animation.update中进行批量删除 - this._needsRemove = true; - return 'destroy'; - } - - return null; - }, - - restart: function() { - var time = new Date().getTime(); - var remainder = (time - this._startTime) % this._life; - this._startTime = new Date().getTime() - remainder + this.gap; - - this._needsRemove = false; - }, - - fire: function(eventType, arg) { - eventType = 'on' + eventType; - if (this[eventType]) { - this[eventType](this._target, arg); - } - } - }; - - return Clip; -}); + cy: 0, -/** - * @module zrender/tool/color - */ -define('zrender/tool/color',['require'],function(require) { - - var kCSSColorTable = { - 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1], - 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1], - 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1], - 'beige': [245,245,220,1], 'bisque': [255,228,196,1], - 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1], - 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1], - 'brown': [165,42,42,1], 'burlywood': [222,184,135,1], - 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1], - 'chocolate': [210,105,30,1], 'coral': [255,127,80,1], - 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1], - 'crimson': [220,20,60,1], 'cyan': [0,255,255,1], - 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1], - 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1], - 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1], - 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1], - 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1], - 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1], - 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1], - 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1], - 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1], - 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1], - 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1], - 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1], - 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1], - 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1], - 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1], - 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1], - 'gray': [128,128,128,1], 'green': [0,128,0,1], - 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1], - 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1], - 'indianred': [205,92,92,1], 'indigo': [75,0,130,1], - 'ivory': [255,255,240,1], 'khaki': [240,230,140,1], - 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1], - 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1], - 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1], - 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1], - 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1], - 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1], - 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1], - 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1], - 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1], - 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1], - 'limegreen': [50,205,50,1], 'linen': [250,240,230,1], - 'magenta': [255,0,255,1], 'maroon': [128,0,0,1], - 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1], - 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1], - 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1], - 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1], - 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1], - 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1], - 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1], - 'navy': [0,0,128,1], 'oldlace': [253,245,230,1], - 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1], - 'orange': [255,165,0,1], 'orangered': [255,69,0,1], - 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1], - 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1], - 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1], - 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1], - 'pink': [255,192,203,1], 'plum': [221,160,221,1], - 'powderblue': [176,224,230,1], 'purple': [128,0,128,1], - 'red': [255,0,0,1], 'rosybrown': [188,143,143,1], - 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1], - 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1], - 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1], - 'sienna': [160,82,45,1], 'silver': [192,192,192,1], - 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1], - 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1], - 'snow': [255,250,250,1], 'springgreen': [0,255,127,1], - 'steelblue': [70,130,180,1], 'tan': [210,180,140,1], - 'teal': [0,128,128,1], 'thistle': [216,191,216,1], - 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1], - 'violet': [238,130,238,1], 'wheat': [245,222,179,1], - 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1], - 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1] - }; - - function clampCssByte(i) { // Clamp to integer 0 .. 255. - i = Math.round(i); // Seems to be what Chrome does (vs truncation). - return i < 0 ? 0 : i > 255 ? 255 : i; - } - - function clampCssAngle(i) { // Clamp to integer 0 .. 360. - i = Math.round(i); // Seems to be what Chrome does (vs truncation). - return i < 0 ? 0 : i > 360 ? 360 : i; - } - - function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0. - return f < 0 ? 0 : f > 1 ? 1 : f; - } - - function parseCssInt(str) { // int or percentage. - if (str.length && str.charAt(str.length - 1) === '%') { - return clampCssByte(parseFloat(str) / 100 * 255); - } - return clampCssByte(parseInt(str, 10)); - } - - function parseCssFloat(str) { // float or percentage. - if (str.length && str.charAt(str.length - 1) === '%') { - return clampCssFloat(parseFloat(str) / 100); - } - return clampCssFloat(parseFloat(str)); - } - - function cssHueToRgb(m1, m2, h) { - if (h < 0) { - h += 1; - } - else if (h > 1) { - h -= 1; - } - - if (h * 6 < 1) { - return m1 + (m2 - m1) * h * 6; - } - if (h * 2 < 1) { - return m2; - } - if (h * 3 < 2) { - return m1 + (m2 - m1) * (2/3 - h) * 6; - } - return m1; - } - - function lerp(a, b, p) { - return a + (b - a) * p; - } - - /** - * @param {string} colorStr - * @return {Array.} - * @memberOf module:zrender/util/color - */ - function parse(colorStr) { - if (!colorStr) { - return; - } - // colorStr may be not string - colorStr = colorStr + ''; - // Remove all whitespace, not compliant, but should just be more accepting. - var str = colorStr.replace(/ /g, '').toLowerCase(); - - // Color keywords (and transparent) lookup. - if (str in kCSSColorTable) { - return kCSSColorTable[str].slice(); // dup. - } - - // #abc and #abc123 syntax. - if (str.charAt(0) === '#') { - if (str.length === 4) { - var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. - if (!(iv >= 0 && iv <= 0xfff)) { - return; // Covers NaN. - } - return [ - ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8), - (iv & 0xf0) | ((iv & 0xf0) >> 4), - (iv & 0xf) | ((iv & 0xf) << 4), - 1 - ]; - } - else if (str.length === 7) { - var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. - if (!(iv >= 0 && iv <= 0xffffff)) { - return; // Covers NaN. - } - return [ - (iv & 0xff0000) >> 16, - (iv & 0xff00) >> 8, - iv & 0xff, - 1 - ]; - } - - return; - } - var op = str.indexOf('('), ep = str.indexOf(')'); - if (op !== -1 && ep + 1 === str.length) { - var fname = str.substr(0, op); - var params = str.substr(op + 1, ep - (op + 1)).split(','); - var alpha = 1; // To allow case fallthrough. - switch (fname) { - case 'rgba': - if (params.length !== 4) { - return; - } - alpha = parseCssFloat(params.pop()); // jshint ignore:line - // Fall through. - case 'rgb': - if (params.length !== 3) { - return; - } - return [ - parseCssInt(params[0]), - parseCssInt(params[1]), - parseCssInt(params[2]), - alpha - ]; - case 'hsla': - if (params.length !== 4) { - return; - } - params[3] = parseCssFloat(params[3]); - return hsla2rgba(params); - case 'hsl': - if (params.length !== 3) { - return; - } - return hsla2rgba(params); - default: - return; - } - } - - return; - } - - /** - * @param {Array.} hsla - * @return {Array.} rgba - */ - function hsla2rgba(hsla) { - var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1 - // NOTE(deanm): According to the CSS spec s/l should only be - // percentages, but we don't bother and let float or percentage. - var s = parseCssFloat(hsla[1]); - var l = parseCssFloat(hsla[2]); - var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; - var m1 = l * 2 - m2; - - var rgba = [ - clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255), - clampCssByte(cssHueToRgb(m1, m2, h) * 255), - clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255) - ]; - - if (hsla.length === 4) { - rgba[3] = hsla[3]; - } - - return rgba; - } - - /** - * @param {Array.} rgba - * @return {Array.} hsla - */ - function rgba2hsla(rgba) { - if (!rgba) { - return; - } - - // RGB from 0 to 255 - var R = rgba[0] / 255; - var G = rgba[1] / 255; - var B = rgba[2] / 255; - - var vMin = Math.min(R, G, B); // Min. value of RGB - var vMax = Math.max(R, G, B); // Max. value of RGB - var delta = vMax - vMin; // Delta RGB value - - var L = (vMax + vMin) / 2; - var H; - var S; - // HSL results from 0 to 1 - if (delta === 0) { - H = 0; - S = 0; - } - else { - if (L < 0.5) { - S = delta / (vMax + vMin); - } - else { - S = delta / (2 - vMax - vMin); - } - - var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta; - var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta; - var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta; - - if (R === vMax) { - H = deltaB - deltaG; - } - else if (G === vMax) { - H = (1 / 3) + deltaR - deltaB; - } - else if (B === vMax) { - H = (2 / 3) + deltaG - deltaR; - } - - if (H < 0) { - H += 1; - } - - if (H > 1) { - H -= 1; - } - } - - var hsla = [H * 360, S, L]; - - if (rgba[3] != null) { - hsla.push(rgba[3]); - } - - return hsla; - } - - /** - * @param {string} color - * @param {number} level - * @return {string} - * @memberOf module:zrender/util/color - */ - function lift(color, level) { - var colorArr = parse(color); - if (colorArr) { - for (var i = 0; i < 3; i++) { - if (level < 0) { - colorArr[i] = colorArr[i] * (1 - level) | 0; - } - else { - colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0; - } - } - return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb'); - } - } - - /** - * @param {string} color - * @return {string} - * @memberOf module:zrender/util/color - */ - function toHex(color, level) { - var colorArr = parse(color); - if (colorArr) { - return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1); - } - } - - /** - * Map value to color. Faster than mapToColor methods because color is represented by rgba array - * @param {number} normalizedValue A float between 0 and 1. - * @param {Array.>} colors List of rgba color array - * @param {Array.} [out] Mapped gba color array - * @return {Array.} - */ - function fastMapToColor(normalizedValue, colors, out) { - if (!(colors && colors.length) - || !(normalizedValue >= 0 && normalizedValue <= 1) - ) { - return; - } - out = out || [0, 0, 0, 0]; - var value = normalizedValue * (colors.length - 1); - var leftIndex = Math.floor(value); - var rightIndex = Math.ceil(value); - var leftColor = colors[leftIndex]; - var rightColor = colors[rightIndex]; - var dv = value - leftIndex; - out[0] = clampCssByte(lerp(leftColor[0], rightColor[0], dv)); - out[1] = clampCssByte(lerp(leftColor[1], rightColor[1], dv)); - out[2] = clampCssByte(lerp(leftColor[2], rightColor[2], dv)); - out[3] = clampCssByte(lerp(leftColor[3], rightColor[3], dv)); - return out; - } - /** - * @param {number} normalizedValue A float between 0 and 1. - * @param {Array.} colors Color list. - * @param {boolean=} fullOutput Default false. - * @return {(string|Object)} Result color. If fullOutput, - * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...}, - * @memberOf module:zrender/util/color - */ - function mapToColor(normalizedValue, colors, fullOutput) { - if (!(colors && colors.length) - || !(normalizedValue >= 0 && normalizedValue <= 1) - ) { - return; - } - - var value = normalizedValue * (colors.length - 1); - var leftIndex = Math.floor(value); - var rightIndex = Math.ceil(value); - var leftColor = parse(colors[leftIndex]); - var rightColor = parse(colors[rightIndex]); - var dv = value - leftIndex; - - var color = stringify( - [ - clampCssByte(lerp(leftColor[0], rightColor[0], dv)), - clampCssByte(lerp(leftColor[1], rightColor[1], dv)), - clampCssByte(lerp(leftColor[2], rightColor[2], dv)), - clampCssFloat(lerp(leftColor[3], rightColor[3], dv)) - ], - 'rgba' - ); - - return fullOutput - ? { - color: color, - leftIndex: leftIndex, - rightIndex: rightIndex, - value: value - } - : color; - } - - /** - * @param {Array} interval Array length === 2, - * each item is normalized value ([0, 1]). - * @param {Array.} colors Color list. - * @return {Array.} colors corresponding to the interval, - * each item is {color: 'xxx', offset: ...} - * where offset is between 0 and 1. - * @memberOf module:zrender/util/color - */ - function mapIntervalToColor(interval, colors) { - if (interval.length !== 2 || interval[1] < interval[0]) { - return; - } - - var info0 = mapToColor(interval[0], colors, true); - var info1 = mapToColor(interval[1], colors, true); - - var result = [{color: info0.color, offset: 0}]; - - var during = info1.value - info0.value; - var start = Math.max(info0.value, info0.rightIndex); - var end = Math.min(info1.value, info1.leftIndex); - - for (var i = start; during > 0 && i <= end; i++) { - result.push({ - color: colors[i], - offset: (i - info0.value) / during - }); - } - result.push({color: info1.color, offset: 1}); - - return result; - } - - /** - * @param {string} color - * @param {number=} h 0 ~ 360, ignore when null. - * @param {number=} s 0 ~ 1, ignore when null. - * @param {number=} l 0 ~ 1, ignore when null. - * @return {string} Color string in rgba format. - * @memberOf module:zrender/util/color - */ - function modifyHSL(color, h, s, l) { - color = parse(color); - - if (color) { - color = rgba2hsla(color); - h != null && (color[0] = clampCssAngle(h)); - s != null && (color[1] = parseCssFloat(s)); - l != null && (color[2] = parseCssFloat(l)); - - return stringify(hsla2rgba(color), 'rgba'); - } - } - - /** - * @param {string} color - * @param {number=} alpha 0 ~ 1 - * @return {string} Color string in rgba format. - * @memberOf module:zrender/util/color - */ - function modifyAlpha(color, alpha) { - color = parse(color); - - if (color && alpha != null) { - color[3] = clampCssFloat(alpha); - return stringify(color, 'rgba'); - } - } - - /** - * @param {Array.} colors Color list. - * @param {string} type 'rgba', 'hsva', ... - * @return {string} Result color. - */ - function stringify(arrColor, type) { - if (type === 'rgb' || type === 'hsv' || type === 'hsl') { - arrColor = arrColor.slice(0, 3); - } - return type + '(' + arrColor.join(',') + ')'; - } - - return { - parse: parse, - lift: lift, - toHex: toHex, - fastMapToColor: fastMapToColor, - mapToColor: mapToColor, - mapIntervalToColor: mapIntervalToColor, - modifyHSL: modifyHSL, - modifyAlpha: modifyAlpha, - stringify: stringify - }; -}); + r0: 0, + r: 0, -/** - * @module echarts/animation/Animator - */ -define('zrender/animation/Animator',['require','./Clip','../tool/color','../core/util'],function (require) { - - var Clip = require('./Clip'); - var color = require('../tool/color'); - var util = require('../core/util'); - var isArrayLike = util.isArrayLike; - - var arraySlice = Array.prototype.slice; - - function defaultGetter(target, key) { - return target[key]; - } - - function defaultSetter(target, key, value) { - target[key] = value; - } - - /** - * @param {number} p0 - * @param {number} p1 - * @param {number} percent - * @return {number} - */ - function interpolateNumber(p0, p1, percent) { - return (p1 - p0) * percent + p0; - } - - /** - * @param {string} p0 - * @param {string} p1 - * @param {number} percent - * @return {string} - */ - function interpolateString(p0, p1, percent) { - return percent > 0.5 ? p1 : p0; - } - - /** - * @param {Array} p0 - * @param {Array} p1 - * @param {number} percent - * @param {Array} out - * @param {number} arrDim - */ - function interpolateArray(p0, p1, percent, out, arrDim) { - var len = p0.length; - if (arrDim == 1) { - for (var i = 0; i < len; i++) { - out[i] = interpolateNumber(p0[i], p1[i], percent); - } - } - else { - var len2 = p0[0].length; - for (var i = 0; i < len; i++) { - for (var j = 0; j < len2; j++) { - out[i][j] = interpolateNumber( - p0[i][j], p1[i][j], percent - ); - } - } - } - } - - function fillArr(arr0, arr1, arrDim) { - var arr0Len = arr0.length; - var arr1Len = arr1.length; - if (arr0Len === arr1Len) { - return; - } - // FIXME Not work for TypedArray - var isPreviousLarger = arr0Len > arr1Len; - if (isPreviousLarger) { - // Cut the previous - arr0.length = arr1Len; - } - else { - // Fill the previous - for (var i = arr0Len; i < arr1Len; i++) { - arr0.push( - arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i]) - ); - } - } - } - - /** - * @param {Array} arr0 - * @param {Array} arr1 - * @param {number} arrDim - * @return {boolean} - */ - function isArraySame(arr0, arr1, arrDim) { - if (arr0 === arr1) { - return true; - } - var len = arr0.length; - if (len !== arr1.length) { - return false; - } - if (arrDim === 1) { - for (var i = 0; i < len; i++) { - if (arr0[i] !== arr1[i]) { - return false; - } - } - } - else { - var len2 = arr0[0].length; - for (var i = 0; i < len; i++) { - for (var j = 0; j < len2; j++) { - if (arr0[i][j] !== arr1[i][j]) { - return false; - } - } - } - } - return true; - } - - /** - * Catmull Rom interpolate array - * @param {Array} p0 - * @param {Array} p1 - * @param {Array} p2 - * @param {Array} p3 - * @param {number} t - * @param {number} t2 - * @param {number} t3 - * @param {Array} out - * @param {number} arrDim - */ - function catmullRomInterpolateArray( - p0, p1, p2, p3, t, t2, t3, out, arrDim - ) { - var len = p0.length; - if (arrDim == 1) { - for (var i = 0; i < len; i++) { - out[i] = catmullRomInterpolate( - p0[i], p1[i], p2[i], p3[i], t, t2, t3 - ); - } - } - else { - var len2 = p0[0].length; - for (var i = 0; i < len; i++) { - for (var j = 0; j < len2; j++) { - out[i][j] = catmullRomInterpolate( - p0[i][j], p1[i][j], p2[i][j], p3[i][j], - t, t2, t3 - ); - } - } - } - } - - /** - * Catmull Rom interpolate number - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} t - * @param {number} t2 - * @param {number} t3 - * @return {number} - */ - function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) { - var v0 = (p2 - p0) * 0.5; - var v1 = (p3 - p1) * 0.5; - return (2 * (p1 - p2) + v0 + v1) * t3 - + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 - + v0 * t + p1; - } - - function cloneValue(value) { - if (isArrayLike(value)) { - var len = value.length; - if (isArrayLike(value[0])) { - var ret = []; - for (var i = 0; i < len; i++) { - ret.push(arraySlice.call(value[i])); - } - return ret; - } - - return arraySlice.call(value); - } - - return value; - } - - function rgba2String(rgba) { - rgba[0] = Math.floor(rgba[0]); - rgba[1] = Math.floor(rgba[1]); - rgba[2] = Math.floor(rgba[2]); - - return 'rgba(' + rgba.join(',') + ')'; - } - - function createTrackClip (animator, easing, oneTrackDone, keyframes, propName) { - var getter = animator._getter; - var setter = animator._setter; - var useSpline = easing === 'spline'; - - var trackLen = keyframes.length; - if (!trackLen) { - return; - } - // Guess data type - var firstVal = keyframes[0].value; - var isValueArray = isArrayLike(firstVal); - var isValueColor = false; - var isValueString = false; - - // For vertices morphing - var arrDim = ( - isValueArray - && isArrayLike(firstVal[0]) - ) - ? 2 : 1; - var trackMaxTime; - // Sort keyframe as ascending - keyframes.sort(function(a, b) { - return a.time - b.time; - }); - - trackMaxTime = keyframes[trackLen - 1].time; - // Percents of each keyframe - var kfPercents = []; - // Value of each keyframe - var kfValues = []; - var prevValue = keyframes[0].value; - var isAllValueEqual = true; - for (var i = 0; i < trackLen; i++) { - kfPercents.push(keyframes[i].time / trackMaxTime); - // Assume value is a color when it is a string - var value = keyframes[i].value; - - // Check if value is equal, deep check if value is array - if (!((isValueArray && isArraySame(value, prevValue, arrDim)) - || (!isValueArray && value === prevValue))) { - isAllValueEqual = false; - } - prevValue = value; - - // Try converting a string to a color array - if (typeof value == 'string') { - var colorArray = color.parse(value); - if (colorArray) { - value = colorArray; - isValueColor = true; - } - else { - isValueString = true; - } - } - kfValues.push(value); - } - if (isAllValueEqual) { - return; - } - - if (isValueArray) { - var lastValue = kfValues[trackLen - 1]; - // Polyfill array - for (var i = 0; i < trackLen - 1; i++) { - fillArr(kfValues[i], lastValue, arrDim); - } - fillArr(getter(animator._target, propName), lastValue, arrDim); - } - - // Cache the key of last frame to speed up when - // animation playback is sequency - var lastFrame = 0; - var lastFramePercent = 0; - var start; - var w; - var p0; - var p1; - var p2; - var p3; - - if (isValueColor) { - var rgba = [0, 0, 0, 0]; - } - - var onframe = function (target, percent) { - // Find the range keyframes - // kf1-----kf2---------current--------kf3 - // find kf2 and kf3 and do interpolation - var frame; - if (percent < lastFramePercent) { - // Start from next key - start = Math.min(lastFrame + 1, trackLen - 1); - for (frame = start; frame >= 0; frame--) { - if (kfPercents[frame] <= percent) { - break; - } - } - frame = Math.min(frame, trackLen - 2); - } - else { - for (frame = lastFrame; frame < trackLen; frame++) { - if (kfPercents[frame] > percent) { - break; - } - } - frame = Math.min(frame - 1, trackLen - 2); - } - lastFrame = frame; - lastFramePercent = percent; - - var range = (kfPercents[frame + 1] - kfPercents[frame]); - if (range === 0) { - return; - } - else { - w = (percent - kfPercents[frame]) / range; - } - if (useSpline) { - p1 = kfValues[frame]; - p0 = kfValues[frame === 0 ? frame : frame - 1]; - p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1]; - p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2]; - if (isValueArray) { - catmullRomInterpolateArray( - p0, p1, p2, p3, w, w * w, w * w * w, - getter(target, propName), - arrDim - ); - } - else { - var value; - if (isValueColor) { - value = catmullRomInterpolateArray( - p0, p1, p2, p3, w, w * w, w * w * w, - rgba, 1 - ); - value = rgba2String(rgba); - } - else if (isValueString) { - // String is step(0.5) - return interpolateString(p1, p2, w); - } - else { - value = catmullRomInterpolate( - p0, p1, p2, p3, w, w * w, w * w * w - ); - } - setter( - target, - propName, - value - ); - } - } - else { - if (isValueArray) { - interpolateArray( - kfValues[frame], kfValues[frame + 1], w, - getter(target, propName), - arrDim - ); - } - else { - var value; - if (isValueColor) { - interpolateArray( - kfValues[frame], kfValues[frame + 1], w, - rgba, 1 - ); - value = rgba2String(rgba); - } - else if (isValueString) { - // String is step(0.5) - return interpolateString(kfValues[frame], kfValues[frame + 1], w); - } - else { - value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w); - } - setter( - target, - propName, - value - ); - } - } - }; - - var clip = new Clip({ - target: animator._target, - life: trackMaxTime, - loop: animator._loop, - delay: animator._delay, - onframe: onframe, - ondestroy: oneTrackDone - }); - - if (easing && easing !== 'spline') { - clip.easing = easing; - } - - return clip; - } - - /** - * @alias module:zrender/animation/Animator - * @constructor - * @param {Object} target - * @param {boolean} loop - * @param {Function} getter - * @param {Function} setter - */ - var Animator = function(target, loop, getter, setter) { - this._tracks = {}; - this._target = target; - - this._loop = loop || false; - - this._getter = getter || defaultGetter; - this._setter = setter || defaultSetter; - - this._clipCount = 0; - - this._delay = 0; - - this._doneList = []; - - this._onframeList = []; - - this._clipList = []; - }; - - Animator.prototype = { - /** - * 设置动画关键帧 - * @param {number} time 关键帧时间,单位是ms - * @param {Object} props 关键帧的属性值,key-value表示 - * @return {module:zrender/animation/Animator} - */ - when: function(time /* ms */, props) { - var tracks = this._tracks; - for (var propName in props) { - if (!tracks[propName]) { - tracks[propName] = []; - // Invalid value - var value = this._getter(this._target, propName); - if (value == null) { - // zrLog('Invalid property ' + propName); - continue; - } - // If time is 0 - // Then props is given initialize value - // Else - // Initialize value from current prop value - if (time !== 0) { - tracks[propName].push({ - time: 0, - value: cloneValue(value) - }); - } - } - tracks[propName].push({ - time: time, - value: props[propName] - }); - } - return this; - }, - /** - * 添加动画每一帧的回调函数 - * @param {Function} callback - * @return {module:zrender/animation/Animator} - */ - during: function (callback) { - this._onframeList.push(callback); - return this; - }, - - _doneCallback: function () { - // Clear all tracks - this._tracks = {}; - // Clear all clips - this._clipList.length = 0; - - var doneList = this._doneList; - var len = doneList.length; - for (var i = 0; i < len; i++) { - doneList[i].call(this); - } - }, - /** - * 开始执行动画 - * @param {string|Function} easing - * 动画缓动函数,详见{@link module:zrender/animation/easing} - * @return {module:zrender/animation/Animator} - */ - start: function (easing) { - - var self = this; - var clipCount = 0; - - var oneTrackDone = function() { - clipCount--; - if (!clipCount) { - self._doneCallback(); - } - }; - - var lastClip; - for (var propName in this._tracks) { - var clip = createTrackClip( - this, easing, oneTrackDone, - this._tracks[propName], propName - ); - if (clip) { - this._clipList.push(clip); - clipCount++; - - // If start after added to animation - if (this.animation) { - this.animation.addClip(clip); - } - - lastClip = clip; - } - } - - // Add during callback on the last clip - if (lastClip) { - var oldOnFrame = lastClip.onframe; - lastClip.onframe = function (target, percent) { - oldOnFrame(target, percent); - - for (var i = 0; i < self._onframeList.length; i++) { - self._onframeList[i](target, percent); - } - }; - } - - if (!clipCount) { - this._doneCallback(); - } - return this; - }, - /** - * 停止动画 - * @param {boolean} forwardToLast If move to last frame before stop - */ - stop: function (forwardToLast) { - var clipList = this._clipList; - var animation = this.animation; - for (var i = 0; i < clipList.length; i++) { - var clip = clipList[i]; - if (forwardToLast) { - // Move to last frame before stop - clip.onframe(this._target, 1); - } - animation && animation.removeClip(clip); - } - clipList.length = 0; - }, - /** - * 设置动画延迟开始的时间 - * @param {number} time 单位ms - * @return {module:zrender/animation/Animator} - */ - delay: function (time) { - this._delay = time; - return this; - }, - /** - * 添加动画结束的回调 - * @param {Function} cb - * @return {module:zrender/animation/Animator} - */ - done: function(cb) { - if (cb) { - this._doneList.push(cb); - } - return this; - }, - - /** - * @return {Array.} - */ - getClips: function () { - return this._clipList; - } - }; - - return Animator; -}); -define('zrender/config',[],function () { - var dpr = 1; - // If in browser environment - if (typeof window !== 'undefined') { - dpr = Math.max(window.devicePixelRatio || 1, 1); - } - /** - * config默认配置项 - * @exports zrender/config - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - */ - var config = { - /** - * debug日志选项:catchBrushException为true下有效 - * 0 : 不生成debug数据,发布用 - * 1 : 异常抛出,调试用 - * 2 : 控制台输出,调试用 - */ - debugMode: 0, - - // retina 屏幕优化 - devicePixelRatio: dpr - }; - return config; -}); + startAngle: 0, + endAngle: Math.PI * 2, -define( - 'zrender/core/log',['require','../config'],function (require) { - var config = require('../config'); - - /** - * @exports zrender/tool/log - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - */ - return function() { - if (config.debugMode === 0) { - return; - } - else if (config.debugMode == 1) { - for (var k in arguments) { - throw new Error(arguments[k]); - } - } - else if (config.debugMode > 1) { - for (var k in arguments) { - console.log(arguments[k]); - } - } - }; - - /* for debug - return function(mes) { - document.getElementById('wrong-message').innerHTML = - mes + ' ' + (new Date() - 0) - + '
' - + document.getElementById('wrong-message').innerHTML; - }; - */ - } -); - -/** - * @module zrender/mixin/Animatable - */ -define('zrender/mixin/Animatable',['require','../animation/Animator','../core/util','../core/log'],function(require) { - - - - var Animator = require('../animation/Animator'); - var util = require('../core/util'); - var isString = util.isString; - var isFunction = util.isFunction; - var isObject = util.isObject; - var log = require('../core/log'); - - /** - * @alias modue:zrender/mixin/Animatable - * @constructor - */ - var Animatable = function () { - - /** - * @type {Array.} - * @readOnly - */ - this.animators = []; - }; - - Animatable.prototype = { - - constructor: Animatable, - - /** - * 动画 - * - * @param {string} path 需要添加动画的属性获取路径,可以通过a.b.c来获取深层的属性 - * @param {boolean} [loop] 动画是否循环 - * @return {module:zrender/animation/Animator} - * @example: - * el.animate('style', false) - * .when(1000, {x: 10} ) - * .done(function(){ // Animation done }) - * .start() - */ - animate: function (path, loop) { - var target; - var animatingShape = false; - var el = this; - var zr = this.__zr; - if (path) { - var pathSplitted = path.split('.'); - var prop = el; - // If animating shape - animatingShape = pathSplitted[0] === 'shape'; - for (var i = 0, l = pathSplitted.length; i < l; i++) { - if (!prop) { - continue; - } - prop = prop[pathSplitted[i]]; - } - if (prop) { - target = prop; - } - } - else { - target = el; - } - - if (!target) { - log( - 'Property "' - + path - + '" is not existed in element ' - + el.id - ); - return; - } - - var animators = el.animators; - - var animator = new Animator(target, loop); - - animator.during(function (target) { - el.dirty(animatingShape); - }) - .done(function () { - // FIXME Animator will not be removed if use `Animator#stop` to stop animation - animators.splice(util.indexOf(animators, animator), 1); - }); - - animators.push(animator); - - // If animate after added to the zrender - if (zr) { - zr.animation.addAnimator(animator); - } - - return animator; - }, - - /** - * 停止动画 - * @param {boolean} forwardToLast If move to last frame before stop - */ - stopAnimation: function (forwardToLast) { - var animators = this.animators; - var len = animators.length; - for (var i = 0; i < len; i++) { - animators[i].stop(forwardToLast); - } - animators.length = 0; - - return this; - }, - - /** - * @param {Object} target - * @param {number} [time=500] Time in ms - * @param {string} [easing='linear'] - * @param {number} [delay=0] - * @param {Function} [callback] - * - * @example - * // Animate position - * el.animateTo({ - * position: [10, 10] - * }, function () { // done }) - * - * // Animate shape, style and position in 100ms, delayed 100ms, with cubicOut easing - * el.animateTo({ - * shape: { - * width: 500 - * }, - * style: { - * fill: 'red' - * } - * position: [10, 10] - * }, 100, 100, 'cubicOut', function () { // done }) - */ - // TODO Return animation key - animateTo: function (target, time, delay, easing, callback) { - // animateTo(target, time, easing, callback); - if (isString(delay)) { - callback = easing; - easing = delay; - delay = 0; - } - // animateTo(target, time, delay, callback); - else if (isFunction(easing)) { - callback = easing; - easing = 'linear'; - delay = 0; - } - // animateTo(target, time, callback); - else if (isFunction(delay)) { - callback = delay; - delay = 0; - } - // animateTo(target, callback) - else if (isFunction(time)) { - callback = time; - time = 500; - } - // animateTo(target) - else if (!time) { - time = 500; - } - // Stop all previous animations - this.stopAnimation(); - this._animateToShallow('', this, target, time, delay, easing, callback); - - // Animators may be removed immediately after start - // if there is nothing to animate - var animators = this.animators.slice(); - var count = animators.length; - function done() { - count--; - if (!count) { - callback && callback(); - } - } - - // No animators. This should be checked before animators[i].start(), - // because 'done' may be executed immediately if no need to animate. - if (!count) { - callback && callback(); - } - // Start after all animators created - // Incase any animator is done immediately when all animation properties are not changed - for (var i = 0; i < animators.length; i++) { - animators[i] - .done(done) - .start(easing); - } - }, - - /** - * @private - * @param {string} path='' - * @param {Object} source=this - * @param {Object} target - * @param {number} [time=500] - * @param {number} [delay=0] - * - * @example - * // Animate position - * el._animateToShallow({ - * position: [10, 10] - * }) - * - * // Animate shape, style and position in 100ms, delayed 100ms - * el._animateToShallow({ - * shape: { - * width: 500 - * }, - * style: { - * fill: 'red' - * } - * position: [10, 10] - * }, 100, 100) - */ - _animateToShallow: function (path, source, target, time, delay) { - var objShallow = {}; - var propertyCount = 0; - for (var name in target) { - if (source[name] != null) { - if (isObject(target[name]) && !util.isArrayLike(target[name])) { - this._animateToShallow( - path ? path + '.' + name : name, - source[name], - target[name], - time, - delay - ); - } - else { - objShallow[name] = target[name]; - propertyCount++; - } - } - else if (target[name] != null) { - // Attr directly if not has property - // FIXME, if some property not needed for element ? - if (!path) { - this.attr(name, target[name]); - } - else { // Shape or style - var props = {}; - props[path] = {}; - props[path][name] = target[name]; - this.attr(props); - } - } - } - - if (propertyCount > 0) { - this.animate(path, false) - .when(time == null ? 500 : time, objShallow) - .delay(delay || 0); - } - - return this; - } - }; - - return Animatable; -}); -/** - * @module zrender/Element - */ -define('zrender/Element',['require','./core/guid','./mixin/Eventful','./mixin/Transformable','./mixin/Animatable','./core/util'],function(require) { - - - var guid = require('./core/guid'); - var Eventful = require('./mixin/Eventful'); - var Transformable = require('./mixin/Transformable'); - var Animatable = require('./mixin/Animatable'); - var zrUtil = require('./core/util'); - - /** - * @alias module:zrender/Element - * @constructor - * @extends {module:zrender/mixin/Animatable} - * @extends {module:zrender/mixin/Transformable} - * @extends {module:zrender/mixin/Eventful} - */ - var Element = function (opts) { - - Transformable.call(this, opts); - Eventful.call(this, opts); - Animatable.call(this, opts); - - /** - * 画布元素ID - * @type {string} - */ - this.id = opts.id || guid(); - }; - - Element.prototype = { - - /** - * 元素类型 - * Element type - * @type {string} - */ - type: 'element', - - /** - * 元素名字 - * Element name - * @type {string} - */ - name: '', - - /** - * ZRender 实例对象,会在 element 添加到 zrender 实例中后自动赋值 - * ZRender instance will be assigned when element is associated with zrender - * @name module:/zrender/Element#__zr - * @type {module:zrender/ZRender} - */ - __zr: null, - - /** - * 图形是否忽略,为true时忽略图形的绘制以及事件触发 - * If ignore drawing and events of the element object - * @name module:/zrender/Element#ignore - * @type {boolean} - * @default false - */ - ignore: false, - - /** - * 用于裁剪的路径(shape),所有 Group 内的路径在绘制时都会被这个路径裁剪 - * 该路径会继承被裁减对象的变换 - * @type {module:zrender/graphic/Path} - * @see http://www.w3.org/TR/2dcontext/#clipping-region - * @readOnly - */ - clipPath: null, - - /** - * Drift element - * @param {number} dx dx on the global space - * @param {number} dy dy on the global space - */ - drift: function (dx, dy) { - switch (this.draggable) { - case 'horizontal': - dy = 0; - break; - case 'vertical': - dx = 0; - break; - } - - var m = this.transform; - if (!m) { - m = this.transform = [1, 0, 0, 1, 0, 0]; - } - m[4] += dx; - m[5] += dy; - - this.decomposeTransform(); - this.dirty(); - }, - - /** - * Hook before update - */ - beforeUpdate: function () {}, - /** - * Hook after update - */ - afterUpdate: function () {}, - /** - * Update each frame - */ - update: function () { - this.updateTransform(); - }, - - /** - * @param {Function} cb - * @param {} context - */ - traverse: function (cb, context) {}, - - /** - * @protected - */ - attrKV: function (key, value) { - if (key === 'position' || key === 'scale' || key === 'origin') { - // Copy the array - if (value) { - var target = this[key]; - if (!target) { - target = this[key] = []; - } - target[0] = value[0]; - target[1] = value[1]; - } - } - else { - this[key] = value; - } - }, - - /** - * Hide the element - */ - hide: function () { - this.ignore = true; - this.__zr && this.__zr.refresh(); - }, - - /** - * Show the element - */ - show: function () { - this.ignore = false; - this.__zr && this.__zr.refresh(); - }, - - /** - * @param {string|Object} key - * @param {*} value - */ - attr: function (key, value) { - if (typeof key === 'string') { - this.attrKV(key, value); - } - else if (zrUtil.isObject(key)) { - for (var name in key) { - if (key.hasOwnProperty(name)) { - this.attrKV(name, key[name]); - } - } - } - this.dirty(); - - return this; - }, - - /** - * @param {module:zrender/graphic/Path} clipPath - */ - setClipPath: function (clipPath) { - var zr = this.__zr; - if (zr) { - clipPath.addSelfToZr(zr); - } - - // Remove previous clip path - if (this.clipPath && this.clipPath !== clipPath) { - this.removeClipPath(); - } - - this.clipPath = clipPath; - clipPath.__zr = zr; - clipPath.__clipTarget = this; - - this.dirty(); - }, - - /** - */ - removeClipPath: function () { - var clipPath = this.clipPath; - if (clipPath) { - if (clipPath.__zr) { - clipPath.removeSelfFromZr(clipPath.__zr); - } - - clipPath.__zr = null; - clipPath.__clipTarget = null; - this.clipPath = null; - - this.dirty(); - } - }, - - /** - * Add self from zrender instance. - * Not recursively because it will be invoked when element added to storage. - * @param {module:zrender/ZRender} zr - */ - addSelfToZr: function (zr) { - this.__zr = zr; - // 添加动画 - var animators = this.animators; - if (animators) { - for (var i = 0; i < animators.length; i++) { - zr.animation.addAnimator(animators[i]); - } - } - - if (this.clipPath) { - this.clipPath.addSelfToZr(zr); - } - }, - - /** - * Remove self from zrender instance. - * Not recursively because it will be invoked when element added to storage. - * @param {module:zrender/ZRender} zr - */ - removeSelfFromZr: function (zr) { - this.__zr = null; - // 移除动画 - var animators = this.animators; - if (animators) { - for (var i = 0; i < animators.length; i++) { - zr.animation.removeAnimator(animators[i]); - } - } - - if (this.clipPath) { - this.clipPath.removeSelfFromZr(zr); - } - } - }; - - zrUtil.mixin(Element, Animatable); - zrUtil.mixin(Element, Transformable); - zrUtil.mixin(Element, Eventful); - - return Element; -}); -/** - * Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上 - * @module zrender/graphic/Group - * @example - * var Group = require('zrender/container/Group'); - * var Circle = require('zrender/graphic/shape/Circle'); - * var g = new Group(); - * g.position[0] = 100; - * g.position[1] = 100; - * g.add(new Circle({ - * style: { - * x: 100, - * y: 100, - * r: 20, - * } - * })); - * zr.add(g); - */ -define('zrender/container/Group',['require','../core/util','../Element','../core/BoundingRect'],function (require) { - - var zrUtil = require('../core/util'); - var Element = require('../Element'); - var BoundingRect = require('../core/BoundingRect'); - - /** - * @alias module:zrender/graphic/Group - * @constructor - * @extends module:zrender/mixin/Transformable - * @extends module:zrender/mixin/Eventful - */ - var Group = function (opts) { - - opts = opts || {}; - - Element.call(this, opts); - - for (var key in opts) { - this[key] = opts[key]; - } - - this._children = []; - - this.__storage = null; - - this.__dirty = true; - }; - - Group.prototype = { - - constructor: Group, - - /** - * @type {string} - */ - type: 'group', - - /** - * @return {Array.} - */ - children: function () { - return this._children.slice(); - }, - - /** - * 获取指定 index 的儿子节点 - * @param {number} idx - * @return {module:zrender/Element} - */ - childAt: function (idx) { - return this._children[idx]; - }, - - /** - * 获取指定名字的儿子节点 - * @param {string} name - * @return {module:zrender/Element} - */ - childOfName: function (name) { - var children = this._children; - for (var i = 0; i < children.length; i++) { - if (children[i].name === name) { - return children[i]; - } - } - }, - - /** - * @return {number} - */ - childCount: function () { - return this._children.length; - }, - - /** - * 添加子节点到最后 - * @param {module:zrender/Element} child - */ - add: function (child) { - if (child && child !== this && child.parent !== this) { - - this._children.push(child); - - this._doAdd(child); - } - - return this; - }, - - /** - * 添加子节点在 nextSibling 之前 - * @param {module:zrender/Element} child - * @param {module:zrender/Element} nextSibling - */ - addBefore: function (child, nextSibling) { - if (child && child !== this && child.parent !== this - && nextSibling && nextSibling.parent === this) { - - var children = this._children; - var idx = children.indexOf(nextSibling); - - if (idx >= 0) { - children.splice(idx, 0, child); - this._doAdd(child); - } - } - - return this; - }, - - _doAdd: function (child) { - if (child.parent) { - child.parent.remove(child); - } - - child.parent = this; - - var storage = this.__storage; - var zr = this.__zr; - if (storage && storage !== child.__storage) { - - storage.addToMap(child); - - if (child instanceof Group) { - child.addChildrenToStorage(storage); - } - } - - zr && zr.refresh(); - }, - - /** - * 移除子节点 - * @param {module:zrender/Element} child - */ - remove: function (child) { - var zr = this.__zr; - var storage = this.__storage; - var children = this._children; - - var idx = zrUtil.indexOf(children, child); - if (idx < 0) { - return this; - } - children.splice(idx, 1); - - child.parent = null; - - if (storage) { - - storage.delFromMap(child.id); - - if (child instanceof Group) { - child.delChildrenFromStorage(storage); - } - } - - zr && zr.refresh(); - - return this; - }, - - /** - * 移除所有子节点 - */ - removeAll: function () { - var children = this._children; - var storage = this.__storage; - var child; - var i; - for (i = 0; i < children.length; i++) { - child = children[i]; - if (storage) { - storage.delFromMap(child.id); - if (child instanceof Group) { - child.delChildrenFromStorage(storage); - } - } - child.parent = null; - } - children.length = 0; - - return this; - }, - - /** - * 遍历所有子节点 - * @param {Function} cb - * @param {} context - */ - eachChild: function (cb, context) { - var children = this._children; - for (var i = 0; i < children.length; i++) { - var child = children[i]; - cb.call(context, child, i); - } - return this; - }, - - /** - * 深度优先遍历所有子孙节点 - * @param {Function} cb - * @param {} context - */ - traverse: function (cb, context) { - for (var i = 0; i < this._children.length; i++) { - var child = this._children[i]; - cb.call(context, child); - - if (child.type === 'group') { - child.traverse(cb, context); - } - } - return this; - }, - - addChildrenToStorage: function (storage) { - for (var i = 0; i < this._children.length; i++) { - var child = this._children[i]; - storage.addToMap(child); - if (child instanceof Group) { - child.addChildrenToStorage(storage); - } - } - }, - - delChildrenFromStorage: function (storage) { - for (var i = 0; i < this._children.length; i++) { - var child = this._children[i]; - storage.delFromMap(child.id); - if (child instanceof Group) { - child.delChildrenFromStorage(storage); - } - } - }, - - dirty: function () { - this.__dirty = true; - this.__zr && this.__zr.refresh(); - return this; - }, - - /** - * @return {module:zrender/core/BoundingRect} - */ - getBoundingRect: function (includeChildren) { - // TODO Caching - // TODO Transform - var rect = null; - var tmpRect = new BoundingRect(0, 0, 0, 0); - var children = includeChildren || this._children; - var tmpMat = []; - - for (var i = 0; i < children.length; i++) { - var child = children[i]; - if (child.ignore || child.invisible) { - continue; - } - - var childRect = child.getBoundingRect(); - var transform = child.getLocalTransform(tmpMat); - if (transform) { - tmpRect.copy(childRect); - tmpRect.applyTransform(transform); - rect = rect || tmpRect.clone(); - rect.union(tmpRect); - } - else { - rect = rect || childRect.clone(); - rect.union(childRect); - } - } - return rect || tmpRect; - } - }; - - zrUtil.inherits(Group, Element); - - return Group; -}); -define('echarts/view/Component',['require','zrender/container/Group','../util/component','../util/clazz'],function (require) { + clockwise: true + }, - var Group = require('zrender/container/Group'); - var componentUtil = require('../util/component'); - var clazzUtil = require('../util/clazz'); + buildPath: function (ctx, shape) { - var Component = function () { - /** - * @type {module:zrender/container/Group} - * @readOnly - */ - this.group = new Group(); + var x = shape.cx; + var y = shape.cy; + var r0 = Math.max(shape.r0 || 0, 0); + var r = Math.max(shape.r, 0); + var startAngle = shape.startAngle; + var endAngle = shape.endAngle; + var clockwise = shape.clockwise; - /** - * @type {string} - * @readOnly - */ - this.uid = componentUtil.getUID('viewComponent'); - }; + var unitX = Math.cos(startAngle); + var unitY = Math.sin(startAngle); - Component.prototype = { + ctx.moveTo(unitX * r0 + x, unitY * r0 + y); - constructor: Component, + ctx.lineTo(unitX * r + x, unitY * r + y); - init: function (ecModel, api) {}, + ctx.arc(x, y, r, startAngle, endAngle, !clockwise); - render: function (componentModel, ecModel, api, payload) {}, + ctx.lineTo( + Math.cos(endAngle) * r0 + x, + Math.sin(endAngle) * r0 + y + ); - dispose: function () {} - }; + if (r0 !== 0) { + ctx.arc(x, y, r0, endAngle, startAngle, clockwise); + } - var componentProto = Component.prototype; - componentProto.updateView - = componentProto.updateLayout - = componentProto.updateVisual - = function (seriesModel, ecModel, api, payload) { - // Do nothing; - }; - // Enable Component.extend. - clazzUtil.enableClassExtend(Component); + ctx.closePath(); + } + }); - // Enable capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. - clazzUtil.enableClassManagement(Component, {registerWhenExtend: true}); - return Component; -}); -define('echarts/view/Chart',['require','zrender/container/Group','../util/component','../util/clazz'],function (require) { - - var Group = require('zrender/container/Group'); - var componentUtil = require('../util/component'); - var clazzUtil = require('../util/clazz'); - - function Chart() { - - /** - * @type {module:zrender/container/Group} - * @readOnly - */ - this.group = new Group(); - - /** - * @type {string} - * @readOnly - */ - this.uid = componentUtil.getUID('viewChart'); - } - - Chart.prototype = { - - type: 'chart', - - /** - * Init the chart - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - */ - init: function (ecModel, api) {}, - - /** - * Render the chart - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - * @param {Object} payload - */ - render: function (seriesModel, ecModel, api, payload) {}, - - /** - * Highlight series or specified data item - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - * @param {Object} payload - */ - highlight: function (seriesModel, ecModel, api, payload) { - toggleHighlight(seriesModel.getData(), payload, 'emphasis'); - }, - - /** - * Downplay series or specified data item - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - * @param {Object} payload - */ - downplay: function (seriesModel, ecModel, api, payload) { - toggleHighlight(seriesModel.getData(), payload, 'normal'); - }, - - /** - * Remove self - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - */ - remove: function (ecModel, api) { - this.group.removeAll(); - }, - - /** - * Dispose self - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - */ - dispose: function () {} - }; - - var chartProto = Chart.prototype; - chartProto.updateView - = chartProto.updateLayout - = chartProto.updateVisual - = function (seriesModel, ecModel, api, payload) { - this.render(seriesModel, ecModel, api, payload); - }; - - /** - * Set state of single element - * @param {module:zrender/Element} el - * @param {string} state - */ - function elSetState(el, state) { - if (el) { - el.trigger(state); - if (el.type === 'group') { - for (var i = 0; i < el.childCount(); i++) { - elSetState(el.childAt(i), state); - } - } - } - } - /** - * @param {module:echarts/data/List} data - * @param {Object} payload - * @param {string} state 'normal'|'emphasis' - * @inner - */ - function toggleHighlight(data, payload, state) { - if (payload.dataIndex != null) { - var el = data.getItemGraphicEl(payload.dataIndex); - elSetState(el, state); - } - else if (payload.name) { - var dataIndex = data.indexOfName(payload.name); - var el = data.getItemGraphicEl(dataIndex); - elSetState(el, state); - } - else { - data.eachItemGraphicEl(function (el) { - elSetState(el, state); - }); - } - } - - // Enable Chart.extend. - clazzUtil.enableClassExtend(Chart); - - // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. - clazzUtil.enableClassManagement(Chart, {registerWhenExtend: true}); - - return Chart; -}); -/** - * @module zrender/graphic/Style - */ - -define('zrender/graphic/Style',['require'],function (require) { - - var STYLE_LIST_COMMON = [ - 'lineCap', 'lineJoin', 'miterLimit', - 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'shadowColor' - ]; - - var Style = function (opts) { - this.extendFrom(opts); - }; - - Style.prototype = { - - constructor: Style, - - /** - * @type {string} - */ - fill: '#000000', - - /** - * @type {string} - */ - stroke: null, - - /** - * @type {number} - */ - opacity: 1, - - /** - * @type {Array.} - */ - lineDash: null, - - /** - * @type {number} - */ - lineDashOffset: 0, - - /** - * @type {number} - */ - shadowBlur: 0, - - /** - * @type {number} - */ - shadowOffsetX: 0, - - /** - * @type {number} - */ - shadowOffsetY: 0, - - /** - * @type {number} - */ - lineWidth: 1, - - /** - * If stroke ignore scale - * @type {Boolean} - */ - strokeNoScale: false, - - // Bounding rect text configuration - // Not affected by element transform - /** - * @type {string} - */ - text: null, - - /** - * @type {string} - */ - textFill: '#000', - - /** - * @type {string} - */ - textStroke: null, - - /** - * 'inside', 'left', 'right', 'top', 'bottom' - * [x, y] - * @type {string|Array.} - * @default 'inside' - */ - textPosition: 'inside', - - /** - * @type {string} - */ - textBaseline: null, - - /** - * @type {string} - */ - textAlign: null, - - /** - * @type {number} - */ - textDistance: 5, - - /** - * @type {number} - */ - textShadowBlur: 0, - - /** - * @type {number} - */ - textShadowOffsetX: 0, - - /** - * @type {number} - */ - textShadowOffsetY: 0, - - /** - * @param {CanvasRenderingContext2D} ctx - */ - bind: function (ctx, el) { - var fill = this.fill; - var stroke = this.stroke; - for (var i = 0; i < STYLE_LIST_COMMON.length; i++) { - var styleName = STYLE_LIST_COMMON[i]; - - if (this[styleName] != null) { - ctx[styleName] = this[styleName]; - } - } - if (stroke != null) { - var lineWidth = this.lineWidth; - ctx.lineWidth = lineWidth / ( - (this.strokeNoScale && el && el.getLineScale) ? el.getLineScale() : 1 - ); - } - if (fill != null) { - // Use canvas gradient if has - ctx.fillStyle = fill.canvasGradient ? fill.canvasGradient : fill; - } - if (stroke != null) { - // Use canvas gradient if has - ctx.strokeStyle = stroke.canvasGradient ? stroke.canvasGradient : stroke; - } - this.opacity != null && (ctx.globalAlpha = this.opacity); - }, - - /** - * Extend from other style - * @param {zrender/graphic/Style} otherStyle - * @param {boolean} overwrite - */ - extendFrom: function (otherStyle, overwrite) { - if (otherStyle) { - var target = this; - for (var name in otherStyle) { - if (otherStyle.hasOwnProperty(name) - && (overwrite || ! target.hasOwnProperty(name)) - ) { - target[name] = otherStyle[name]; - } - } - } - }, - - /** - * Batch setting style with a given object - * @param {Object|string} obj - * @param {*} [obj] - */ - set: function (obj, value) { - if (typeof obj === 'string') { - this[obj] = value; - } - else { - this.extendFrom(obj, true); - } - }, - - /** - * Clone - * @return {zrender/graphic/Style} [description] - */ - clone: function () { - var newStyle = new this.constructor(); - newStyle.extendFrom(this, true); - return newStyle; - } - }; - - var styleProto = Style.prototype; - var name; - var i; - for (i = 0; i < STYLE_LIST_COMMON.length; i++) { - name = STYLE_LIST_COMMON[i]; - if (!(name in styleProto)) { - styleProto[name] = null; - } - } - - return Style; -}); -/** - * Mixin for drawing text in a element bounding rect - * @module zrender/mixin/RectText - */ - -define('zrender/graphic/mixin/RectText',['require','../../contain/text','../../core/BoundingRect'],function (require) { - - var textContain = require('../../contain/text'); - var BoundingRect = require('../../core/BoundingRect'); - - var tmpRect = new BoundingRect(); - - var RectText = function () {}; - - function parsePercent(value, maxValue) { - if (typeof value === 'string') { - if (value.lastIndexOf('%') >= 0) { - return parseFloat(value) / 100 * maxValue; - } - return parseFloat(value); - } - return value; - } - - function setTransform(ctx, m) { - ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); - } - - RectText.prototype = { - - constructor: RectText, - - /** - * Draw text in a rect with specified position. - * @param {CanvasRenderingContext} ctx - * @param {Object} rect Displayable rect - * @return {Object} textRect Alternative precalculated text bounding rect - */ - drawRectText: function (ctx, rect, textRect) { - var style = this.style; - var text = style.text; - // Convert to string - text != null && (text += ''); - if (!text) { - return; - } - var x; - var y; - var textPosition = style.textPosition; - var distance = style.textDistance; - var align = style.textAlign; - var font = style.textFont || style.font; - var baseline = style.textBaseline; - - textRect = textRect || textContain.getBoundingRect(text, font, align, baseline); - - // Transform rect to view space - var transform = this.transform; - var invTransform = this.invTransform; - if (transform) { - tmpRect.copy(rect); - tmpRect.applyTransform(transform); - rect = tmpRect; - // Transform back - setTransform(ctx, invTransform); - } - - // Text position represented by coord - if (textPosition instanceof Array) { - // Percent - x = rect.x + parsePercent(textPosition[0], rect.width); - y = rect.y + parsePercent(textPosition[1], rect.height); - align = align || 'left'; - baseline = baseline || 'top'; - } - else { - var res = textContain.adjustTextPositionOnRect( - textPosition, rect, textRect, distance - ); - x = res.x; - y = res.y; - // Default align and baseline when has textPosition - align = align || res.textAlign; - baseline = baseline || res.textBaseline; - } - - ctx.textAlign = align; - ctx.textBaseline = baseline; - - var textFill = style.textFill; - var textStroke = style.textStroke; - textFill && (ctx.fillStyle = textFill); - textStroke && (ctx.strokeStyle = textStroke); - ctx.font = font; - - // Text shadow - ctx.shadowColor = style.textShadowColor; - ctx.shadowBlur = style.textShadowBlur; - ctx.shadowOffsetX = style.textShadowOffsetX; - ctx.shadowOffsetY = style.textShadowOffsetY; - - var textLines = text.split('\n'); - for (var i = 0; i < textLines.length; i++) { - textFill && ctx.fillText(textLines[i], x, y); - textStroke && ctx.strokeText(textLines[i], x, y); - y += textRect.lineHeight; - } - - // Transform again - transform && setTransform(ctx, transform); - } - }; - - return RectText; -}); -/** - * 可绘制的图形基类 - * Base class of all displayable graphic objects - * @module zrender/graphic/Displayable - */ - -define('zrender/graphic/Displayable',['require','../core/util','./Style','../Element','./mixin/RectText'],function (require) { - - var zrUtil = require('../core/util'); - - var Style = require('./Style'); - - var Element = require('../Element'); - var RectText = require('./mixin/RectText'); - // var Stateful = require('./mixin/Stateful'); - - /** - * @alias module:zrender/graphic/Displayable - * @extends module:zrender/Element - * @extends module:zrender/graphic/mixin/RectText - */ - function Displayable(opts) { - - opts = opts || {}; - - Element.call(this, opts); - - // Extend properties - for (var name in opts) { - if ( - opts.hasOwnProperty(name) && - name !== 'style' - ) { - this[name] = opts[name]; - } - } - - /** - * @type {module:zrender/graphic/Style} - */ - this.style = new Style(opts.style); - - this._rect = null; - // Shapes for cascade clipping. - this.__clipPaths = []; - - // FIXME Stateful must be mixined after style is setted - // Stateful.call(this, opts); - } - - Displayable.prototype = { - - constructor: Displayable, - - type: 'displayable', - - /** - * Displayable 是否为脏,Painter 中会根据该标记判断是否需要是否需要重新绘制 - * Dirty flag. From which painter will determine if this displayable object needs brush - * @name module:zrender/graphic/Displayable#__dirty - * @type {boolean} - */ - __dirty: true, - - /** - * 图形是否可见,为true时不绘制图形,但是仍能触发鼠标事件 - * If ignore drawing of the displayable object. Mouse event will still be triggered - * @name module:/zrender/graphic/Displayable#invisible - * @type {boolean} - * @default false - */ - invisible: false, - - /** - * @name module:/zrender/graphic/Displayable#z - * @type {number} - * @default 0 - */ - z: 0, - - /** - * @name module:/zrender/graphic/Displayable#z - * @type {number} - * @default 0 - */ - z2: 0, - - /** - * z层level,决定绘画在哪层canvas中 - * @name module:/zrender/graphic/Displayable#zlevel - * @type {number} - * @default 0 - */ - zlevel: 0, - - /** - * 是否可拖拽 - * @name module:/zrender/graphic/Displayable#draggable - * @type {boolean} - * @default false - */ - draggable: false, - - /** - * 是否正在拖拽 - * @name module:/zrender/graphic/Displayable#draggable - * @type {boolean} - * @default false - */ - dragging: false, - - /** - * 是否相应鼠标事件 - * @name module:/zrender/graphic/Displayable#silent - * @type {boolean} - * @default false - */ - silent: false, - - /** - * If enable culling - * @type {boolean} - * @default false - */ - culling: false, - - /** - * Mouse cursor when hovered - * @name module:/zrender/graphic/Displayable#cursor - * @type {string} - */ - cursor: 'pointer', - - /** - * If hover area is bounding rect - * @name module:/zrender/graphic/Displayable#rectHover - * @type {string} - */ - rectHover: false, - - beforeBrush: function (ctx) {}, - - afterBrush: function (ctx) {}, - - /** - * 图形绘制方法 - * @param {Canvas2DRenderingContext} ctx - */ - // Interface - brush: function (ctx) {}, - - /** - * 获取最小包围盒 - * @return {module:zrender/core/BoundingRect} - */ - // Interface - getBoundingRect: function () {}, - - /** - * 判断坐标 x, y 是否在图形上 - * If displayable element contain coord x, y - * @param {number} x - * @param {number} y - * @return {boolean} - */ - contain: function (x, y) { - return this.rectContain(x, y); - }, - - /** - * @param {Function} cb - * @param {} context - */ - traverse: function (cb, context) { - cb.call(context, this); - }, - - /** - * 判断坐标 x, y 是否在图形的包围盒上 - * If bounding rect of element contain coord x, y - * @param {number} x - * @param {number} y - * @return {boolean} - */ - rectContain: function (x, y) { - var coord = this.transformCoordToLocal(x, y); - var rect = this.getBoundingRect(); - return rect.contain(coord[0], coord[1]); - }, - - /** - * 标记图形元素为脏,并且在下一帧重绘 - * Mark displayable element dirty and refresh next frame - */ - dirty: function () { - this.__dirty = true; - - this._rect = null; - - this.__zr && this.__zr.refresh(); - }, - - /** - * 图形是否会触发事件 - * If displayable object binded any event - * @return {boolean} - */ - // TODO, 通过 bind 绑定的事件 - // isSilent: function () { - // return !( - // this.hoverable || this.draggable - // || this.onmousemove || this.onmouseover || this.onmouseout - // || this.onmousedown || this.onmouseup || this.onclick - // || this.ondragenter || this.ondragover || this.ondragleave - // || this.ondrop - // ); - // }, - /** - * Alias for animate('style') - * @param {boolean} loop - */ - animateStyle: function (loop) { - return this.animate('style', loop); - }, - - attrKV: function (key, value) { - if (key !== 'style') { - Element.prototype.attrKV.call(this, key, value); - } - else { - this.style.set(value); - } - }, - - /** - * @param {Object|string} key - * @param {*} value - */ - setStyle: function (key, value) { - this.style.set(key, value); - this.dirty(); - return this; - } - }; - - zrUtil.inherits(Displayable, Element); - - zrUtil.mixin(Displayable, RectText); - // zrUtil.mixin(Displayable, Stateful); - - return Displayable; -}); -/** - * 曲线辅助模块 - * @module zrender/core/curve - * @author pissang(https://www.github.com/pissang) - */ -define('zrender/core/curve',['require','./vector'],function(require) { - - - - var vec2 = require('./vector'); - var v2Create = vec2.create; - var v2DistSquare = vec2.distSquare; - var mathPow = Math.pow; - var mathSqrt = Math.sqrt; - - var EPSILON = 1e-4; - - var THREE_SQRT = mathSqrt(3); - var ONE_THIRD = 1 / 3; - - // 临时变量 - var _v0 = v2Create(); - var _v1 = v2Create(); - var _v2 = v2Create(); - // var _v3 = vec2.create(); - - function isAroundZero(val) { - return val > -EPSILON && val < EPSILON; - } - function isNotAroundZero(val) { - return val > EPSILON || val < -EPSILON; - } - /** - * 计算三次贝塞尔值 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} t - * @return {number} - */ - function cubicAt(p0, p1, p2, p3, t) { - var onet = 1 - t; - return onet * onet * (onet * p0 + 3 * t * p1) - + t * t * (t * p3 + 3 * onet * p2); - } - - /** - * 计算三次贝塞尔导数值 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} t - * @return {number} - */ - function cubicDerivativeAt(p0, p1, p2, p3, t) { - var onet = 1 - t; - return 3 * ( - ((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet - + (p3 - p2) * t * t - ); - } - - /** - * 计算三次贝塞尔方程根,使用盛金公式 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} val - * @param {Array.} roots - * @return {number} 有效根数目 - */ - function cubicRootAt(p0, p1, p2, p3, val, roots) { - // Evaluate roots of cubic functions - var a = p3 + 3 * (p1 - p2) - p0; - var b = 3 * (p2 - p1 * 2 + p0); - var c = 3 * (p1 - p0); - var d = p0 - val; - - var A = b * b - 3 * a * c; - var B = b * c - 9 * a * d; - var C = c * c - 3 * b * d; - - var n = 0; - - if (isAroundZero(A) && isAroundZero(B)) { - if (isAroundZero(b)) { - roots[0] = 0; - } - else { - var t1 = -c / b; //t1, t2, t3, b is not zero - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - } - } - else { - var disc = B * B - 4 * A * C; - - if (isAroundZero(disc)) { - var K = B / A; - var t1 = -b / a + K; // t1, a is not zero - var t2 = -K / 2; // t2, t3 - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - if (t2 >= 0 && t2 <= 1) { - roots[n++] = t2; - } - } - else if (disc > 0) { - var discSqrt = mathSqrt(disc); - var Y1 = A * b + 1.5 * a * (-B + discSqrt); - var Y2 = A * b + 1.5 * a * (-B - discSqrt); - if (Y1 < 0) { - Y1 = -mathPow(-Y1, ONE_THIRD); - } - else { - Y1 = mathPow(Y1, ONE_THIRD); - } - if (Y2 < 0) { - Y2 = -mathPow(-Y2, ONE_THIRD); - } - else { - Y2 = mathPow(Y2, ONE_THIRD); - } - var t1 = (-b - (Y1 + Y2)) / (3 * a); - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - } - else { - var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt(A * A * A)); - var theta = Math.acos(T) / 3; - var ASqrt = mathSqrt(A); - var tmp = Math.cos(theta); - - var t1 = (-b - 2 * ASqrt * tmp) / (3 * a); - var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a); - var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a); - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - if (t2 >= 0 && t2 <= 1) { - roots[n++] = t2; - } - if (t3 >= 0 && t3 <= 1) { - roots[n++] = t3; - } - } - } - return n; - } - - /** - * 计算三次贝塞尔方程极限值的位置 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {Array.} extrema - * @return {number} 有效数目 - */ - function cubicExtrema(p0, p1, p2, p3, extrema) { - var b = 6 * p2 - 12 * p1 + 6 * p0; - var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2; - var c = 3 * p1 - 3 * p0; - - var n = 0; - if (isAroundZero(a)) { - if (isNotAroundZero(b)) { - var t1 = -c / b; - if (t1 >= 0 && t1 <=1) { - extrema[n++] = t1; - } - } - } - else { - var disc = b * b - 4 * a * c; - if (isAroundZero(disc)) { - extrema[0] = -b / (2 * a); - } - else if (disc > 0) { - var discSqrt = mathSqrt(disc); - var t1 = (-b + discSqrt) / (2 * a); - var t2 = (-b - discSqrt) / (2 * a); - if (t1 >= 0 && t1 <= 1) { - extrema[n++] = t1; - } - if (t2 >= 0 && t2 <= 1) { - extrema[n++] = t2; - } - } - } - return n; - } - - /** - * 细分三次贝塞尔曲线 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} t - * @param {Array.} out - */ - function cubicSubdivide(p0, p1, p2, p3, t, out) { - var p01 = (p1 - p0) * t + p0; - var p12 = (p2 - p1) * t + p1; - var p23 = (p3 - p2) * t + p2; - - var p012 = (p12 - p01) * t + p01; - var p123 = (p23 - p12) * t + p12; - - var p0123 = (p123 - p012) * t + p012; - // Seg0 - out[0] = p0; - out[1] = p01; - out[2] = p012; - out[3] = p0123; - // Seg1 - out[4] = p0123; - out[5] = p123; - out[6] = p23; - out[7] = p3; - } - - /** - * 投射点到三次贝塞尔曲线上,返回投射距离。 - * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x3 - * @param {number} y3 - * @param {number} x - * @param {number} y - * @param {Array.} [out] 投射点 - * @return {number} - */ - function cubicProjectPoint( - x0, y0, x1, y1, x2, y2, x3, y3, - x, y, out - ) { - // http://pomax.github.io/bezierinfo/#projections - var t; - var interval = 0.005; - var d = Infinity; - var prev; - var next; - var d1; - var d2; - - _v0[0] = x; - _v0[1] = y; - - // 先粗略估计一下可能的最小距离的 t 值 - // PENDING - for (var _t = 0; _t < 1; _t += 0.05) { - _v1[0] = cubicAt(x0, x1, x2, x3, _t); - _v1[1] = cubicAt(y0, y1, y2, y3, _t); - d1 = v2DistSquare(_v0, _v1); - if (d1 < d) { - t = _t; - d = d1; - } - } - d = Infinity; - - // At most 32 iteration - for (var i = 0; i < 32; i++) { - if (interval < EPSILON) { - break; - } - prev = t - interval; - next = t + interval; - // t - interval - _v1[0] = cubicAt(x0, x1, x2, x3, prev); - _v1[1] = cubicAt(y0, y1, y2, y3, prev); - - d1 = v2DistSquare(_v1, _v0); - - if (prev >= 0 && d1 < d) { - t = prev; - d = d1; - } - else { - // t + interval - _v2[0] = cubicAt(x0, x1, x2, x3, next); - _v2[1] = cubicAt(y0, y1, y2, y3, next); - d2 = v2DistSquare(_v2, _v0); - - if (next <= 1 && d2 < d) { - t = next; - d = d2; - } - else { - interval *= 0.5; - } - } - } - // t - if (out) { - out[0] = cubicAt(x0, x1, x2, x3, t); - out[1] = cubicAt(y0, y1, y2, y3, t); - } - // console.log(interval, i); - return mathSqrt(d); - } - - /** - * 计算二次方贝塞尔值 - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} t - * @return {number} - */ - function quadraticAt(p0, p1, p2, t) { - var onet = 1 - t; - return onet * (onet * p0 + 2 * t * p1) + t * t * p2; - } - - /** - * 计算二次方贝塞尔导数值 - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} t - * @return {number} - */ - function quadraticDerivativeAt(p0, p1, p2, t) { - return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1)); - } - - /** - * 计算二次方贝塞尔方程根 - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} t - * @param {Array.} roots - * @return {number} 有效根数目 - */ - function quadraticRootAt(p0, p1, p2, val, roots) { - var a = p0 - 2 * p1 + p2; - var b = 2 * (p1 - p0); - var c = p0 - val; - - var n = 0; - if (isAroundZero(a)) { - if (isNotAroundZero(b)) { - var t1 = -c / b; - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - } - } - else { - var disc = b * b - 4 * a * c; - if (isAroundZero(disc)) { - var t1 = -b / (2 * a); - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - } - else if (disc > 0) { - var discSqrt = mathSqrt(disc); - var t1 = (-b + discSqrt) / (2 * a); - var t2 = (-b - discSqrt) / (2 * a); - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - if (t2 >= 0 && t2 <= 1) { - roots[n++] = t2; - } - } - } - return n; - } - - /** - * 计算二次贝塞尔方程极限值 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @return {number} - */ - function quadraticExtremum(p0, p1, p2) { - var divider = p0 + p2 - 2 * p1; - if (divider === 0) { - // p1 is center of p0 and p2 - return 0.5; - } - else { - return (p0 - p1) / divider; - } - } - - /** - * 细分二次贝塞尔曲线 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} t - * @param {Array.} out - */ - function quadraticSubdivide(p0, p1, p2, t, out) { - var p01 = (p1 - p0) * t + p0; - var p12 = (p2 - p1) * t + p1; - var p012 = (p12 - p01) * t + p01; - - // Seg0 - out[0] = p0; - out[1] = p01; - out[2] = p012; - - // Seg1 - out[3] = p012; - out[4] = p12; - out[5] = p2; - } - - /** - * 投射点到二次贝塞尔曲线上,返回投射距离。 - * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x - * @param {number} y - * @param {Array.} out 投射点 - * @return {number} - */ - function quadraticProjectPoint( - x0, y0, x1, y1, x2, y2, - x, y, out - ) { - // http://pomax.github.io/bezierinfo/#projections - var t; - var interval = 0.005; - var d = Infinity; - - _v0[0] = x; - _v0[1] = y; - - // 先粗略估计一下可能的最小距离的 t 值 - // PENDING - for (var _t = 0; _t < 1; _t += 0.05) { - _v1[0] = quadraticAt(x0, x1, x2, _t); - _v1[1] = quadraticAt(y0, y1, y2, _t); - var d1 = v2DistSquare(_v0, _v1); - if (d1 < d) { - t = _t; - d = d1; - } - } - d = Infinity; - - // At most 32 iteration - for (var i = 0; i < 32; i++) { - if (interval < EPSILON) { - break; - } - var prev = t - interval; - var next = t + interval; - // t - interval - _v1[0] = quadraticAt(x0, x1, x2, prev); - _v1[1] = quadraticAt(y0, y1, y2, prev); - - var d1 = v2DistSquare(_v1, _v0); - - if (prev >= 0 && d1 < d) { - t = prev; - d = d1; - } - else { - // t + interval - _v2[0] = quadraticAt(x0, x1, x2, next); - _v2[1] = quadraticAt(y0, y1, y2, next); - var d2 = v2DistSquare(_v2, _v0); - if (next <= 1 && d2 < d) { - t = next; - d = d2; - } - else { - interval *= 0.5; - } - } - } - // t - if (out) { - out[0] = quadraticAt(x0, x1, x2, t); - out[1] = quadraticAt(y0, y1, y2, t); - } - // console.log(interval, i); - return mathSqrt(d); - } - - return { - - cubicAt: cubicAt, - - cubicDerivativeAt: cubicDerivativeAt, - - cubicRootAt: cubicRootAt, - - cubicExtrema: cubicExtrema, - - cubicSubdivide: cubicSubdivide, - - cubicProjectPoint: cubicProjectPoint, - - quadraticAt: quadraticAt, - - quadraticDerivativeAt: quadraticDerivativeAt, - - quadraticRootAt: quadraticRootAt, - - quadraticExtremum: quadraticExtremum, - - quadraticSubdivide: quadraticSubdivide, - - quadraticProjectPoint: quadraticProjectPoint - }; -}); -/** - * @author Yi Shen(https://github.com/pissang) - */ -define('zrender/core/bbox',['require','./vector','./curve'],function (require) { - - var vec2 = require('./vector'); - var curve = require('./curve'); - - var bbox = {}; - var mathMin = Math.min; - var mathMax = Math.max; - var mathSin = Math.sin; - var mathCos = Math.cos; - - var start = vec2.create(); - var end = vec2.create(); - var extremity = vec2.create(); - - var PI2 = Math.PI * 2; - /** - * 从顶点数组中计算出最小包围盒,写入`min`和`max`中 - * @module zrender/core/bbox - * @param {Array} points 顶点数组 - * @param {number} min - * @param {number} max - */ - bbox.fromPoints = function(points, min, max) { - if (points.length === 0) { - return; - } - var p = points[0]; - var left = p[0]; - var right = p[0]; - var top = p[1]; - var bottom = p[1]; - var i; - - for (i = 1; i < points.length; i++) { - p = points[i]; - left = mathMin(left, p[0]); - right = mathMax(right, p[0]); - top = mathMin(top, p[1]); - bottom = mathMax(bottom, p[1]); - } - - min[0] = left; - min[1] = top; - max[0] = right; - max[1] = bottom; - }; - - /** - * @memberOf module:zrender/core/bbox - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {Array.} min - * @param {Array.} max - */ - bbox.fromLine = function (x0, y0, x1, y1, min, max) { - min[0] = mathMin(x0, x1); - min[1] = mathMin(y0, y1); - max[0] = mathMax(x0, x1); - max[1] = mathMax(y0, y1); - }; - - /** - * 从三阶贝塞尔曲线(p0, p1, p2, p3)中计算出最小包围盒,写入`min`和`max`中 - * @memberOf module:zrender/core/bbox - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x3 - * @param {number} y3 - * @param {Array.} min - * @param {Array.} max - */ - bbox.fromCubic = function( - x0, y0, x1, y1, x2, y2, x3, y3, min, max - ) { - var xDim = []; - var yDim = []; - var cubicExtrema = curve.cubicExtrema; - var cubicAt = curve.cubicAt; - var left, right, top, bottom; - var i; - var n = cubicExtrema(x0, x1, x2, x3, xDim); - - for (i = 0; i < n; i++) { - xDim[i] = cubicAt(x0, x1, x2, x3, xDim[i]); - } - n = cubicExtrema(y0, y1, y2, y3, yDim); - for (i = 0; i < n; i++) { - yDim[i] = cubicAt(y0, y1, y2, y3, yDim[i]); - } - - xDim.push(x0, x3); - yDim.push(y0, y3); - - left = mathMin.apply(null, xDim); - right = mathMax.apply(null, xDim); - top = mathMin.apply(null, yDim); - bottom = mathMax.apply(null, yDim); - - min[0] = left; - min[1] = top; - max[0] = right; - max[1] = bottom; - }; - - /** - * 从二阶贝塞尔曲线(p0, p1, p2)中计算出最小包围盒,写入`min`和`max`中 - * @memberOf module:zrender/core/bbox - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {Array.} min - * @param {Array.} max - */ - bbox.fromQuadratic = function(x0, y0, x1, y1, x2, y2, min, max) { - var quadraticExtremum = curve.quadraticExtremum; - var quadraticAt = curve.quadraticAt; - // Find extremities, where derivative in x dim or y dim is zero - var tx = - mathMax( - mathMin(quadraticExtremum(x0, x1, x2), 1), 0 - ); - var ty = - mathMax( - mathMin(quadraticExtremum(y0, y1, y2), 1), 0 - ); - - var x = quadraticAt(x0, x1, x2, tx); - var y = quadraticAt(y0, y1, y2, ty); - - min[0] = mathMin(x0, x2, x); - min[1] = mathMin(y0, y2, y); - max[0] = mathMax(x0, x2, x); - max[1] = mathMax(y0, y2, y); - }; - - /** - * 从圆弧中计算出最小包围盒,写入`min`和`max`中 - * @method - * @memberOf module:zrender/core/bbox - * @param {number} x - * @param {number} y - * @param {number} rx - * @param {number} ry - * @param {number} startAngle - * @param {number} endAngle - * @param {number} anticlockwise - * @param {Array.} min - * @param {Array.} max - */ - bbox.fromArc = function ( - x, y, rx, ry, startAngle, endAngle, anticlockwise, min, max - ) { - var vec2Min = vec2.min; - var vec2Max = vec2.max; - - var diff = Math.abs(startAngle - endAngle); - - - if (diff % PI2 < 1e-4 && diff > 1e-4) { - // Is a circle - min[0] = x - rx; - min[1] = y - ry; - max[0] = x + rx; - max[1] = y + ry; - return; - } - - start[0] = mathCos(startAngle) * rx + x; - start[1] = mathSin(startAngle) * ry + y; - - end[0] = mathCos(endAngle) * rx + x; - end[1] = mathSin(endAngle) * ry + y; - - vec2Min(min, start, end); - vec2Max(max, start, end); - - // Thresh to [0, Math.PI * 2] - startAngle = startAngle % (PI2); - if (startAngle < 0) { - startAngle = startAngle + PI2; - } - endAngle = endAngle % (PI2); - if (endAngle < 0) { - endAngle = endAngle + PI2; - } - - if (startAngle > endAngle && !anticlockwise) { - endAngle += PI2; - } - else if (startAngle < endAngle && anticlockwise) { - startAngle += PI2; - } - if (anticlockwise) { - var tmp = endAngle; - endAngle = startAngle; - startAngle = tmp; - } - - // var number = 0; - // var step = (anticlockwise ? -Math.PI : Math.PI) / 2; - for (var angle = 0; angle < endAngle; angle += Math.PI / 2) { - if (angle > startAngle) { - extremity[0] = mathCos(angle) * rx + x; - extremity[1] = mathSin(angle) * ry + y; - - vec2Min(min, extremity, min); - vec2Max(max, extremity, max); - } - } - }; - - return bbox; -}); -/** - * Path 代理,可以在`buildPath`中用于替代`ctx`, 会保存每个path操作的命令到pathCommands属性中 - * 可以用于 isInsidePath 判断以及获取boundingRect - * - * @module zrender/core/PathProxy - * @author Yi Shen (http://www.github.com/pissang) - */ - - // TODO getTotalLength, getPointAtLength -define('zrender/core/PathProxy',['require','./curve','./vector','./bbox','./BoundingRect'],function (require) { - - - var curve = require('./curve'); - var vec2 = require('./vector'); - var bbox = require('./bbox'); - var BoundingRect = require('./BoundingRect'); - - var CMD = { - M: 1, - L: 2, - C: 3, - Q: 4, - A: 5, - Z: 6, - // Rect - R: 7 - }; - - var min = []; - var max = []; - var min2 = []; - var max2 = []; - var mathMin = Math.min; - var mathMax = Math.max; - var mathCos = Math.cos; - var mathSin = Math.sin; - var mathSqrt = Math.sqrt; - - var hasTypedArray = typeof Float32Array != 'undefined'; - - /** - * @alias module:zrender/core/PathProxy - * @constructor - */ - var PathProxy = function () { - - /** - * Path data. Stored as flat array - * @type {Array.} - */ - this.data = []; - - this._len = 0; - - this._ctx = null; - - this._xi = 0; - this._yi = 0; - - this._x0 = 0; - this._y0 = 0; - }; - - /** - * 快速计算Path包围盒(并不是最小包围盒) - * @return {Object} - */ - PathProxy.prototype = { - - constructor: PathProxy, - - _lineDash: null, - - _dashOffset: 0, - - _dashIdx: 0, - - _dashSum: 0, - - getContext: function () { - return this._ctx; - }, - - /** - * @param {CanvasRenderingContext2D} ctx - * @return {module:zrender/core/PathProxy} - */ - beginPath: function (ctx) { - this._ctx = ctx; - - ctx && ctx.beginPath(); - - // Reset - this._len = 0; - - if (this._lineDash) { - this._lineDash = null; - - this._dashOffset = 0; - } - - return this; - }, - - /** - * @param {number} x - * @param {number} y - * @return {module:zrender/core/PathProxy} - */ - moveTo: function (x, y) { - this.addData(CMD.M, x, y); - this._ctx && this._ctx.moveTo(x, y); - - // x0, y0, xi, yi 是记录在 _dashedXXXXTo 方法中使用 - // xi, yi 记录当前点, x0, y0 在 closePath 的时候回到起始点。 - // 有可能在 beginPath 之后直接调用 lineTo,这时候 x0, y0 需要 - // 在 lineTo 方法中记录,这里先不考虑这种情况,dashed line 也只在 IE10- 中不支持 - this._x0 = x; - this._y0 = y; - - this._xi = x; - this._yi = y; - - return this; - }, - - /** - * @param {number} x - * @param {number} y - * @return {module:zrender/core/PathProxy} - */ - lineTo: function (x, y) { - this.addData(CMD.L, x, y); - if (this._ctx) { - this._needsDash() ? this._dashedLineTo(x, y) - : this._ctx.lineTo(x, y); - } - this._xi = x; - this._yi = y; - return this; - }, - - /** - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x3 - * @param {number} y3 - * @return {module:zrender/core/PathProxy} - */ - bezierCurveTo: function (x1, y1, x2, y2, x3, y3) { - this.addData(CMD.C, x1, y1, x2, y2, x3, y3); - if (this._ctx) { - this._needsDash() ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3) - : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3); - } - this._xi = x3; - this._yi = y3; - return this; - }, - - /** - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @return {module:zrender/core/PathProxy} - */ - quadraticCurveTo: function (x1, y1, x2, y2) { - this.addData(CMD.Q, x1, y1, x2, y2); - if (this._ctx) { - this._needsDash() ? this._dashedQuadraticTo(x1, y1, x2, y2) - : this._ctx.quadraticCurveTo(x1, y1, x2, y2); - } - this._xi = x2; - this._yi = y2; - return this; - }, - - /** - * @param {number} cx - * @param {number} cy - * @param {number} r - * @param {number} startAngle - * @param {number} endAngle - * @param {boolean} anticlockwise - * @return {module:zrender/core/PathProxy} - */ - arc: function (cx, cy, r, startAngle, endAngle, anticlockwise) { - this.addData( - CMD.A, cx, cy, r, r, startAngle, endAngle - startAngle, 0, anticlockwise ? 0 : 1 - ); - this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise); - - this._xi = mathCos(endAngle) * r + cx; - this._xi = mathSin(endAngle) * r + cx; - return this; - }, - - // TODO - arcTo: function (x1, y1, x2, y2, radius) { - if (this._ctx) { - this._ctx.arcTo(x1, y1, x2, y2, radius); - } - return this; - }, - - // TODO - rect: function (x, y, w, h) { - this._ctx && this._ctx.rect(x, y, w, h); - this.addData(CMD.R, x, y, w, h); - return this; - }, - - /** - * @return {module:zrender/core/PathProxy} - */ - closePath: function () { - this.addData(CMD.Z); - - var ctx = this._ctx; - var x0 = this._x0; - var y0 = this._y0; - if (ctx) { - this._needsDash() && this._dashedLineTo(x0, y0); - ctx.closePath(); - } - - this._xi = x0; - this._yi = y0; - return this; - }, - - /** - * Context 从外部传入,因为有可能是 rebuildPath 完之后再 fill。 - * stroke 同样 - * @param {CanvasRenderingContext2D} ctx - * @return {module:zrender/core/PathProxy} - */ - fill: function (ctx) { - ctx && ctx.fill(); - this.toStatic(); - }, - - /** - * @param {CanvasRenderingContext2D} ctx - * @return {module:zrender/core/PathProxy} - */ - stroke: function (ctx) { - ctx && ctx.stroke(); - this.toStatic(); - }, - - /** - * 必须在其它绘制命令前调用 - * Must be invoked before all other path drawing methods - * @return {module:zrender/core/PathProxy} - */ - setLineDash: function (lineDash) { - if (lineDash instanceof Array) { - this._lineDash = lineDash; - - this._dashIdx = 0; - - var lineDashSum = 0; - for (var i = 0; i < lineDash.length; i++) { - lineDashSum += lineDash[i]; - } - this._dashSum = lineDashSum; - } - return this; - }, - - /** - * 必须在其它绘制命令前调用 - * Must be invoked before all other path drawing methods - * @return {module:zrender/core/PathProxy} - */ - setLineDashOffset: function (offset) { - this._dashOffset = offset; - return this; - }, - - /** - * - * @return {boolean} - */ - len: function () { - return this._len; - }, - - /** - * 直接设置 Path 数据 - */ - setData: function (data) { - - var len = data.length; - - if (! (this.data && this.data.length == len) && hasTypedArray) { - this.data = new Float32Array(len); - } - - for (var i = 0; i < len; i++) { - this.data[i] = data[i]; - } - - this._len = len; - }, - - /** - * 添加子路径 - * @param {module:zrender/core/PathProxy|Array.} path - */ - appendPath: function (path) { - if (!(path instanceof Array)) { - path = [path]; - } - var len = path.length; - var appendSize = 0; - var offset = this._len; - for (var i = 0; i < len; i++) { - appendSize += path[i].len(); - } - if (hasTypedArray && (this.data instanceof Float32Array)) { - this.data = new Float32Array(offset + appendSize); - } - for (var i = 0; i < len; i++) { - var appendPathData = path[i].data; - for (var k = 0; k < appendPathData.length; k++) { - this.data[offset++] = appendPathData[k]; - } - } - this._len = offset; - }, - - /** - * 填充 Path 数据。 - * 尽量复用而不申明新的数组。大部分图形重绘的指令数据长度都是不变的。 - */ - addData: function (cmd) { - var data = this.data; - if (this._len + arguments.length > data.length) { - // 因为之前的数组已经转换成静态的 Float32Array - // 所以不够用时需要扩展一个新的动态数组 - this._expandData(); - data = this.data; - } - for (var i = 0; i < arguments.length; i++) { - data[this._len++] = arguments[i]; - } - - this._prevCmd = cmd; - }, - - _expandData: function () { - // Only if data is Float32Array - if (!(this.data instanceof Array)) { - var newData = []; - for (var i = 0; i < this._len; i++) { - newData[i] = this.data[i]; - } - this.data = newData; - } - }, - - /** - * If needs js implemented dashed line - * @return {boolean} - * @private - */ - _needsDash: function () { - return this._lineDash; - }, - - _dashedLineTo: function (x1, y1) { - var dashSum = this._dashSum; - var offset = this._dashOffset; - var lineDash = this._lineDash; - var ctx = this._ctx; - - var x0 = this._xi; - var y0 = this._yi; - var dx = x1 - x0; - var dy = y1 - y0; - var dist = mathSqrt(dx * dx + dy * dy); - var x = x0; - var y = y0; - var dash; - var nDash = lineDash.length; - var idx; - dx /= dist; - dy /= dist; - - if (offset < 0) { - // Convert to positive offset - offset = dashSum + offset; - } - offset %= dashSum; - x -= offset * dx; - y -= offset * dy; - - while ((dx >= 0 && x <= x1) || (dx < 0 && x > x1)) { - idx = this._dashIdx; - dash = lineDash[idx]; - x += dx * dash; - y += dy * dash; - this._dashIdx = (idx + 1) % nDash; - // Skip positive offset - if ((dx > 0 && x < x0) || (dx < 0 && x > x0)) { - continue; - } - ctx[idx % 2 ? 'moveTo' : 'lineTo']( - dx >= 0 ? mathMin(x, x1) : mathMax(x, x1), - dy >= 0 ? mathMin(y, y1) : mathMax(y, y1) - ); - } - // Offset for next lineTo - dx = x - x1; - dy = y - y1; - this._dashOffset = -mathSqrt(dx * dx + dy * dy); - }, - - // Not accurate dashed line to - _dashedBezierTo: function (x1, y1, x2, y2, x3, y3) { - var dashSum = this._dashSum; - var offset = this._dashOffset; - var lineDash = this._lineDash; - var ctx = this._ctx; - - var x0 = this._xi; - var y0 = this._yi; - var t; - var dx; - var dy; - var cubicAt = curve.cubicAt; - var bezierLen = 0; - var idx = this._dashIdx; - var nDash = lineDash.length; - - var x; - var y; - - var tmpLen = 0; - - if (offset < 0) { - // Convert to positive offset - offset = dashSum + offset; - } - offset %= dashSum; - // Bezier approx length - for (t = 0; t < 1; t += 0.1) { - dx = cubicAt(x0, x1, x2, x3, t + 0.1) - - cubicAt(x0, x1, x2, x3, t); - dy = cubicAt(y0, y1, y2, y3, t + 0.1) - - cubicAt(y0, y1, y2, y3, t); - bezierLen += mathSqrt(dx * dx + dy * dy); - } - - // Find idx after add offset - for (; idx < nDash; idx++) { - tmpLen += lineDash[idx]; - if (tmpLen > offset) { - break; - } - } - t = (tmpLen - offset) / bezierLen; - - while (t <= 1) { - - x = cubicAt(x0, x1, x2, x3, t); - y = cubicAt(y0, y1, y2, y3, t); - - // Use line to approximate dashed bezier - // Bad result if dash is long - idx % 2 ? ctx.moveTo(x, y) - : ctx.lineTo(x, y); - - t += lineDash[idx] / bezierLen; - - idx = (idx + 1) % nDash; - } - - // Finish the last segment and calculate the new offset - (idx % 2 !== 0) && ctx.lineTo(x3, y3); - dx = x3 - x; - dy = y3 - y; - this._dashOffset = -mathSqrt(dx * dx + dy * dy); - }, - - _dashedQuadraticTo: function (x1, y1, x2, y2) { - // Convert quadratic to cubic using degree elevation - var x3 = x2; - var y3 = y2; - x2 = (x2 + 2 * x1) / 3; - y2 = (y2 + 2 * y1) / 3; - x1 = (this._xi + 2 * x1) / 3; - y1 = (this._yi + 2 * y1) / 3; - - this._dashedBezierTo(x1, y1, x2, y2, x3, y3); - }, - - /** - * 转成静态的 Float32Array 减少堆内存占用 - * Convert dynamic array to static Float32Array - */ - toStatic: function () { - var data = this.data; - if (data instanceof Array) { - data.length = this._len; - if (hasTypedArray) { - this.data = new Float32Array(data); - } - } - }, - - /** - * @return {module:zrender/core/BoundingRect} - */ - getBoundingRect: function () { - min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE; - max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE; - - var data = this.data; - var xi = 0; - var yi = 0; - var x0 = 0; - var y0 = 0; - - for (var i = 0; i < data.length;) { - var cmd = data[i++]; - - if (i == 1) { - // 如果第一个命令是 L, C, Q - // 则 previous point 同绘制命令的第一个 point - // - // 第一个命令为 Arc 的情况下会在后面特殊处理 - xi = data[i]; - yi = data[i + 1]; - - x0 = xi; - y0 = yi; - } - - switch (cmd) { - case CMD.M: - // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点 - // 在 closePath 的时候使用 - x0 = data[i++]; - y0 = data[i++]; - xi = x0; - yi = y0; - min2[0] = x0; - min2[1] = y0; - max2[0] = x0; - max2[1] = y0; - break; - case CMD.L: - bbox.fromLine(xi, yi, data[i], data[i + 1], min2, max2); - xi = data[i++]; - yi = data[i++]; - break; - case CMD.C: - bbox.fromCubic( - xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], - min2, max2 - ); - xi = data[i++]; - yi = data[i++]; - break; - case CMD.Q: - bbox.fromQuadratic( - xi, yi, data[i++], data[i++], data[i], data[i + 1], - min2, max2 - ); - xi = data[i++]; - yi = data[i++]; - break; - case CMD.A: - // TODO Arc 判断的开销比较大 - var cx = data[i++]; - var cy = data[i++]; - var rx = data[i++]; - var ry = data[i++]; - var startAngle = data[i++]; - var endAngle = data[i++] + startAngle; - // TODO Arc 旋转 - var psi = data[i++]; - var anticlockwise = 1 - data[i++]; - - if (i == 1) { - // 直接使用 arc 命令 - // 第一个命令起点还未定义 - x0 = mathCos(startAngle) * rx + cx; - y0 = mathSin(startAngle) * ry + cy; - } - - bbox.fromArc( - cx, cy, rx, ry, startAngle, endAngle, - anticlockwise, min2, max2 - ); - - xi = mathCos(endAngle) * rx + cx; - yi = mathSin(endAngle) * ry + cy; - break; - case CMD.R: - x0 = xi = data[i++]; - y0 = yi = data[i++]; - var width = data[i++]; - var height = data[i++]; - // Use fromLine - bbox.fromLine(x0, y0, x0 + width, y0 + height, min2, max2); - break; - case CMD.Z: - xi = x0; - yi = y0; - break; - } - - // Union - vec2.min(min, min, min2); - vec2.max(max, max, max2); - } - - // No data - if (i === 0) { - min[0] = min[1] = max[0] = max[1] = 0; - } - - return new BoundingRect( - min[0], min[1], max[0] - min[0], max[1] - min[1] - ); - }, - - /** - * Rebuild path from current data - * Rebuild path will not consider javascript implemented line dash. - * @param {CanvasRenderingContext} ctx - */ - rebuildPath: function (ctx) { - var d = this.data; - for (var i = 0; i < this._len;) { - var cmd = d[i++]; - switch (cmd) { - case CMD.M: - ctx.moveTo(d[i++], d[i++]); - break; - case CMD.L: - ctx.lineTo(d[i++], d[i++]); - break; - case CMD.C: - ctx.bezierCurveTo( - d[i++], d[i++], d[i++], d[i++], d[i++], d[i++] - ); - break; - case CMD.Q: - ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]); - break; - case CMD.A: - var cx = d[i++]; - var cy = d[i++]; - var rx = d[i++]; - var ry = d[i++]; - var theta = d[i++]; - var dTheta = d[i++]; - var psi = d[i++]; - var fs = d[i++]; - var r = (rx > ry) ? rx : ry; - var scaleX = (rx > ry) ? 1 : rx / ry; - var scaleY = (rx > ry) ? ry / rx : 1; - var isEllipse = Math.abs(rx - ry) > 1e-3; - if (isEllipse) { - ctx.translate(cx, cy); - ctx.rotate(psi); - ctx.scale(scaleX, scaleY); - ctx.arc(0, 0, r, theta, theta + dTheta, 1 - fs); - ctx.scale(1 / scaleX, 1 / scaleY); - ctx.rotate(-psi); - ctx.translate(-cx, -cy); - } - else { - ctx.arc(cx, cy, r, theta, theta + dTheta, 1 - fs); - } - break; - case CMD.R: - ctx.rect(d[i++], d[i++], d[i++], d[i++]); - break; - case CMD.Z: - ctx.closePath(); - } - } - } - }; - - PathProxy.CMD = CMD; - - return PathProxy; -}); -define('zrender/contain/line',[],function () { - return { - /** - * 线段包含判断 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} lineWidth - * @param {number} x - * @param {number} y - * @return {boolean} - */ - containStroke: function (x0, y0, x1, y1, lineWidth, x, y) { - if (lineWidth === 0) { - return false; - } - var _l = lineWidth; - var _a = 0; - var _b = x0; - // Quick reject - 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) - ) { - return false; - } - - if (x0 !== x1) { - _a = (y0 - y1) / (x0 - x1); - _b = (x0 * y1 - x1 * y0) / (x0 - x1) ; - } - else { - return Math.abs(x - x0) <= _l / 2; - } - var tmp = _a * x - y + _b; - var _s = tmp * tmp / (_a * _a + 1); - return _s <= _l / 2 * _l / 2; - } - }; -}); -define('zrender/contain/cubic',['require','../core/curve'],function (require) { - - var curve = require('../core/curve'); - - return { - /** - * 三次贝塞尔曲线描边包含判断 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x3 - * @param {number} y3 - * @param {number} lineWidth - * @param {number} x - * @param {number} y - * @return {boolean} - */ - containStroke: function(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) { - if (lineWidth === 0) { - return false; - } - var _l = lineWidth; - // Quick reject - 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) - ) { - return false; - } - var d = curve.cubicProjectPoint( - x0, y0, x1, y1, x2, y2, x3, y3, - x, y, null - ); - return d <= _l / 2; - } - }; -}); -define('zrender/contain/quadratic',['require','../core/curve'],function (require) { - - var curve = require('../core/curve'); - - return { - /** - * 二次贝塞尔曲线描边包含判断 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} lineWidth - * @param {number} x - * @param {number} y - * @return {boolean} - */ - containStroke: function (x0, y0, x1, y1, x2, y2, lineWidth, x, y) { - if (lineWidth === 0) { - return false; - } - var _l = lineWidth; - // Quick reject - 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) - ) { - return false; - } - var d = curve.quadraticProjectPoint( - x0, y0, x1, y1, x2, y2, - x, y, null - ); - return d <= _l / 2; - } - }; -}); -define('zrender/contain/util',['require'],function (require) { - - var PI2 = Math.PI * 2; - return { - normalizeRadian: function(angle) { - angle %= PI2; - if (angle < 0) { - angle += PI2; - } - return angle; - } - }; -}); -define('zrender/contain/arc',['require','./util'],function (require) { - - var normalizeRadian = require('./util').normalizeRadian; - var PI2 = Math.PI * 2; - - return { - /** - * 圆弧描边包含判断 - * @param {number} cx - * @param {number} cy - * @param {number} r - * @param {number} startAngle - * @param {number} endAngle - * @param {boolean} anticlockwise - * @param {number} lineWidth - * @param {number} x - * @param {number} y - * @return {Boolean} - */ - containStroke: function ( - cx, cy, r, startAngle, endAngle, anticlockwise, - lineWidth, x, y - ) { - - if (lineWidth === 0) { - return false; - } - var _l = lineWidth; - - x -= cx; - y -= cy; - var d = Math.sqrt(x * x + y * y); - - if ((d - _l > r) || (d + _l < r)) { - return false; - } - if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) { - // Is a circle - return true; - } - if (anticlockwise) { - var tmp = startAngle; - startAngle = normalizeRadian(endAngle); - endAngle = normalizeRadian(tmp); - } else { - startAngle = normalizeRadian(startAngle); - endAngle = normalizeRadian(endAngle); - } - if (startAngle > endAngle) { - endAngle += PI2; - } - - var angle = Math.atan2(y, x); - if (angle < 0) { - angle += PI2; - } - return (angle >= startAngle && angle <= endAngle) - || (angle + PI2 >= startAngle && angle + PI2 <= endAngle); - } - }; -}); -define('zrender/contain/windingLine',[],function () { - return function windingLine(x0, y0, x1, y1, x, y) { - if ((y > y0 && y > y1) || (y < y0 && y < y1)) { - return 0; - } - if (y1 === y0) { - return 0; - } - var dir = y1 < y0 ? 1 : -1; - var t = (y - y0) / (y1 - y0); - var x_ = t * (x1 - x0) + x0; - - return x_ > x ? dir : 0; - }; -}); -define('zrender/contain/path',['require','../core/PathProxy','./line','./cubic','./quadratic','./arc','./util','../core/curve','./windingLine'],function (require) { - - - - var CMD = require('../core/PathProxy').CMD; - var line = require('./line'); - var cubic = require('./cubic'); - var quadratic = require('./quadratic'); - var arc = require('./arc'); - var normalizeRadian = require('./util').normalizeRadian; - var curve = require('../core/curve'); - - var windingLine = require('./windingLine'); - - var containStroke = line.containStroke; - - var PI2 = Math.PI * 2; - - var EPSILON = 1e-4; - - function isAroundEqual(a, b) { - return Math.abs(a - b) < EPSILON; - } - - // 临时数组 - var roots = [-1, -1, -1]; - var extrema = [-1, -1]; - - function swapExtrema() { - var tmp = extrema[0]; - extrema[0] = extrema[1]; - extrema[1] = tmp; - } - - function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) { - // Quick reject - if ( - (y > y0 && y > y1 && y > y2 && y > y3) - || (y < y0 && y < y1 && y < y2 && y < y3) - ) { - return 0; - } - var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots); - if (nRoots === 0) { - return 0; - } - else { - var w = 0; - var nExtrema = -1; - var y0_, y1_; - for (var i = 0; i < nRoots; i++) { - var t = roots[i]; - var x_ = curve.cubicAt(x0, x1, x2, x3, t); - if (x_ < x) { // Quick reject - continue; - } - if (nExtrema < 0) { - nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema); - if (extrema[1] < extrema[0] && nExtrema > 1) { - swapExtrema(); - } - y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]); - if (nExtrema > 1) { - y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]); - } - } - if (nExtrema == 2) { - // 分成三段单调函数 - if (t < extrema[0]) { - w += y0_ < y0 ? 1 : -1; - } - else if (t < extrema[1]) { - w += y1_ < y0_ ? 1 : -1; - } - else { - w += y3 < y1_ ? 1 : -1; - } - } - else { - // 分成两段单调函数 - if (t < extrema[0]) { - w += y0_ < y0 ? 1 : -1; - } - else { - w += y3 < y0_ ? 1 : -1; - } - } - } - return w; - } - } - - function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) { - // Quick reject - if ( - (y > y0 && y > y1 && y > y2) - || (y < y0 && y < y1 && y < y2) - ) { - return 0; - } - var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots); - if (nRoots === 0) { - return 0; - } - else { - var t = curve.quadraticExtremum(y0, y1, y2); - if (t >=0 && t <= 1) { - var w = 0; - var y_ = curve.quadraticAt(y0, y1, y2, t); - for (var i = 0; i < nRoots; i++) { - var x_ = curve.quadraticAt(x0, x1, x2, roots[i]); - if (x_ > x) { - continue; - } - if (roots[i] < t) { - w += y_ < y0 ? 1 : -1; - } - else { - w += y2 < y_ ? 1 : -1; - } - } - return w; - } - else { - var x_ = curve.quadraticAt(x0, x1, x2, roots[0]); - if (x_ > x) { - return 0; - } - return y2 < y0 ? 1 : -1; - } - } - } - - // TODO - // Arc 旋转 - function windingArc( - cx, cy, r, startAngle, endAngle, anticlockwise, x, y - ) { - y -= cy; - if (y > r || y < -r) { - return 0; - } - var tmp = Math.sqrt(r * r - y * y); - roots[0] = -tmp; - roots[1] = tmp; - - var diff = Math.abs(startAngle - endAngle); - if (diff < 1e-4) { - return 0; - } - if (diff % PI2 < 1e-4) { - // Is a circle - startAngle = 0; - endAngle = PI2; - var dir = anticlockwise ? 1 : -1; - if (x >= roots[0] + cx && x <= roots[1] + cx) { - return dir; - } else { - return 0; - } - } - - if (anticlockwise) { - var tmp = startAngle; - startAngle = normalizeRadian(endAngle); - endAngle = normalizeRadian(tmp); - } - else { - startAngle = normalizeRadian(startAngle); - endAngle = normalizeRadian(endAngle); - } - if (startAngle > endAngle) { - endAngle += PI2; - } - - var w = 0; - for (var i = 0; i < 2; i++) { - var x_ = roots[i]; - if (x_ + cx > x) { - var angle = Math.atan2(y, x_); - var dir = anticlockwise ? 1 : -1; - if (angle < 0) { - angle = PI2 + angle; - } - if ( - (angle >= startAngle && angle <= endAngle) - || (angle + PI2 >= startAngle && angle + PI2 <= endAngle) - ) { - if (angle > Math.PI / 2 && angle < Math.PI * 1.5) { - dir = -dir; - } - w += dir; - } - } - } - return w; - } - - function containPath(data, lineWidth, isStroke, x, y) { - var w = 0; - var xi = 0; - var yi = 0; - var x0 = 0; - var y0 = 0; - - for (var i = 0; i < data.length;) { - var cmd = data[i++]; - // Begin a new subpath - if (cmd === CMD.M && i > 1) { - // Close previous subpath - if (!isStroke) { - w += windingLine(xi, yi, x0, y0, x, y); - } - // 如果被任何一个 subpath 包含 - if (w !== 0) { - return true; - } - } - - if (i == 1) { - // 如果第一个命令是 L, C, Q - // 则 previous point 同绘制命令的第一个 point - // - // 第一个命令为 Arc 的情况下会在后面特殊处理 - xi = data[i]; - yi = data[i + 1]; - - x0 = xi; - y0 = yi; - } - - switch (cmd) { - case CMD.M: - // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点 - // 在 closePath 的时候使用 - x0 = data[i++]; - y0 = data[i++]; - xi = x0; - yi = y0; - break; - case CMD.L: - if (isStroke) { - if (containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) { - return true; - } - } - else { - // NOTE 在第一个命令为 L, C, Q 的时候会计算出 NaN - w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0; - } - xi = data[i++]; - yi = data[i++]; - break; - case CMD.C: - if (isStroke) { - if (cubic.containStroke(xi, yi, - data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], - lineWidth, x, y - )) { - return true; - } - } - else { - w += windingCubic( - xi, yi, - data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], - x, y - ) || 0; - } - xi = data[i++]; - yi = data[i++]; - break; - case CMD.Q: - if (isStroke) { - if (quadratic.containStroke(xi, yi, - data[i++], data[i++], data[i], data[i + 1], - lineWidth, x, y - )) { - return true; - } - } - else { - w += windingQuadratic( - xi, yi, - data[i++], data[i++], data[i], data[i + 1], - x, y - ) || 0; - } - xi = data[i++]; - yi = data[i++]; - break; - case CMD.A: - // TODO Arc 判断的开销比较大 - var cx = data[i++]; - var cy = data[i++]; - var rx = data[i++]; - var ry = data[i++]; - var theta = data[i++]; - var dTheta = data[i++]; - // TODO Arc 旋转 - var psi = data[i++]; - var anticlockwise = 1 - data[i++]; - var x1 = Math.cos(theta) * rx + cx; - var y1 = Math.sin(theta) * ry + cy; - // 不是直接使用 arc 命令 - if (i > 1) { - w += windingLine(xi, yi, x1, y1, x, y); - } - else { - // 第一个命令起点还未定义 - x0 = x1; - y0 = y1; - } - // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放 - var _x = (x - cx) * ry / rx + cx; - if (isStroke) { - if (arc.containStroke( - cx, cy, ry, theta, theta + dTheta, anticlockwise, - lineWidth, _x, y - )) { - return true; - } - } - else { - w += windingArc( - cx, cy, ry, theta, theta + dTheta, anticlockwise, - _x, y - ); - } - xi = Math.cos(theta + dTheta) * rx + cx; - yi = Math.sin(theta + dTheta) * ry + cy; - break; - case CMD.R: - x0 = xi = data[i++]; - y0 = yi = data[i++]; - var width = data[i++]; - var height = data[i++]; - var x1 = x0 + width; - var y1 = y0 + height; - if (isStroke) { - if (containStroke(x0, y0, x1, y0, lineWidth, x, y) - || containStroke(x1, y0, x1, y1, lineWidth, x, y) - || containStroke(x1, y1, x0, y1, lineWidth, x, y) - || containStroke(x0, y1, x1, y1, lineWidth, x, y) - ) { - return true; - } - } - else { - // FIXME Clockwise ? - w += windingLine(x1, y0, x1, y1, x, y); - w += windingLine(x0, y1, x0, y0, x, y); - } - break; - case CMD.Z: - if (isStroke) { - if (containStroke( - xi, yi, x0, y0, lineWidth, x, y - )) { - return true; - } - } - else { - // Close a subpath - w += windingLine(xi, yi, x0, y0, x, y); - // 如果被任何一个 subpath 包含 - if (w !== 0) { - return true; - } - } - xi = x0; - yi = y0; - break; - } - } - if (!isStroke && !isAroundEqual(yi, y0)) { - w += windingLine(xi, yi, x0, y0, x, y) || 0; - } - return w !== 0; - } - - return { - contain: function (pathData, x, y) { - return containPath(pathData, 0, false, x, y); - }, - - containStroke: function (pathData, lineWidth, x, y) { - return containPath(pathData, lineWidth, true, x, y); - } - }; -}); -/** - * Path element - * @module zrender/graphic/Path - */ - -define('zrender/graphic/Path',['require','./Displayable','../core/util','../core/PathProxy','../contain/path','./Gradient'],function (require) { - - var Displayable = require('./Displayable'); - var zrUtil = require('../core/util'); - var PathProxy = require('../core/PathProxy'); - var pathContain = require('../contain/path'); - - var Gradient = require('./Gradient'); - - function pathHasFill(style) { - var fill = style.fill; - return fill != null && fill !== 'none'; - } - - function pathHasStroke(style) { - var stroke = style.stroke; - return stroke != null && stroke !== 'none' && style.lineWidth > 0; - } - - var abs = Math.abs; - - /** - * @alias module:zrender/graphic/Path - * @extends module:zrender/graphic/Displayable - * @constructor - * @param {Object} opts - */ - function Path(opts) { - Displayable.call(this, opts); - - /** - * @type {module:zrender/core/PathProxy} - * @readOnly - */ - this.path = new PathProxy(); - } - - Path.prototype = { - - constructor: Path, - - type: 'path', - - __dirtyPath: true, - - strokeContainThreshold: 5, - - brush: function (ctx) { - ctx.save(); - - var style = this.style; - var path = this.path; - var hasStroke = pathHasStroke(style); - var hasFill = pathHasFill(style); - - if (this.__dirtyPath) { - // Update gradient because bounding rect may changed - if (hasFill && (style.fill instanceof Gradient)) { - style.fill.updateCanvasGradient(this, ctx); - } - if (hasStroke && (style.stroke instanceof Gradient)) { - style.stroke.updateCanvasGradient(this, ctx); - } - } - - style.bind(ctx, this); - this.setTransform(ctx); - - var lineDash = style.lineDash; - var lineDashOffset = style.lineDashOffset; - - var ctxLineDash = !!ctx.setLineDash; - - // Proxy context - // Rebuild path in following 2 cases - // 1. Path is dirty - // 2. Path needs javascript implemented lineDash stroking. - // In this case, lineDash information will not be saved in PathProxy - if (this.__dirtyPath || ( - lineDash && !ctxLineDash && hasStroke - )) { - path = this.path.beginPath(ctx); - - // Setting line dash before build path - if (lineDash && !ctxLineDash) { - path.setLineDash(lineDash); - path.setLineDashOffset(lineDashOffset); - } - - this.buildPath(path, this.shape); - - // Clear path dirty flag - this.__dirtyPath = false; - } - else { - // Replay path building - ctx.beginPath(); - this.path.rebuildPath(ctx); - } - - hasFill && path.fill(ctx); - - if (lineDash && ctxLineDash) { - ctx.setLineDash(lineDash); - ctx.lineDashOffset = lineDashOffset; - } - - hasStroke && path.stroke(ctx); - - // Draw rect text - if (style.text != null) { - // var rect = this.getBoundingRect(); - this.drawRectText(ctx, this.getBoundingRect()); - } - - ctx.restore(); - }, - - buildPath: function (ctx, shapeCfg) {}, - - getBoundingRect: function () { - var rect = this._rect; - var style = this.style; - if (!rect) { - var path = this.path; - if (this.__dirtyPath) { - path.beginPath(); - this.buildPath(path, this.shape); - } - rect = path.getBoundingRect(); - } - /** - * Needs update rect with stroke lineWidth when - * 1. Element changes scale or lineWidth - * 2. First create rect - */ - if (pathHasStroke(style) && (this.__dirty || !this._rect)) { - var rectWithStroke = this._rectWithStroke - || (this._rectWithStroke = rect.clone()); - rectWithStroke.copy(rect); - // FIXME Must after updateTransform - var w = style.lineWidth; - // PENDING, Min line width is needed when line is horizontal or vertical - var lineScale = style.strokeNoScale ? this.getLineScale() : 1; - - // Only add extra hover lineWidth when there are no fill - if (!pathHasFill(style)) { - w = Math.max(w, this.strokeContainThreshold); - } - // Consider line width - // Line scale can't be 0; - if (lineScale > 1e-10) { - rectWithStroke.width += w / lineScale; - rectWithStroke.height += w / lineScale; - rectWithStroke.x -= w / lineScale / 2; - rectWithStroke.y -= w / lineScale / 2; - } - return rectWithStroke; - } - this._rect = rect; - return rect; - }, - - contain: function (x, y) { - var localPos = this.transformCoordToLocal(x, y); - var rect = this.getBoundingRect(); - var style = this.style; - x = localPos[0]; - y = localPos[1]; - - if (rect.contain(x, y)) { - var pathData = this.path.data; - if (pathHasStroke(style)) { - var lineWidth = style.lineWidth; - var lineScale = style.strokeNoScale ? this.getLineScale() : 1; - // Line scale can't be 0; - if (lineScale > 1e-10) { - // Only add extra hover lineWidth when there are no fill - if (!pathHasFill(style)) { - lineWidth = Math.max(lineWidth, this.strokeContainThreshold); - } - if (pathContain.containStroke( - pathData, lineWidth / lineScale, x, y - )) { - return true; - } - } - } - if (pathHasFill(style)) { - return pathContain.contain(pathData, x, y); - } - } - return false; - }, - - /** - * @param {boolean} dirtyPath - */ - dirty: function (dirtyPath) { - if (arguments.length ===0) { - dirtyPath = true; - } - // Only mark dirty, not mark clean - if (dirtyPath) { - this.__dirtyPath = dirtyPath; - this._rect = null; - } - - this.__dirty = true; - - this.__zr && this.__zr.refresh(); - - // Used as a clipping path - if (this.__clipTarget) { - this.__clipTarget.dirty(); - } - }, - - /** - * Alias for animate('shape') - * @param {boolean} loop - */ - animateShape: function (loop) { - return this.animate('shape', loop); - }, - - // Overwrite attrKV - attrKV: function (key, value) { - // FIXME - if (key === 'shape') { - this.setShape(value); - } - else { - Displayable.prototype.attrKV.call(this, key, value); - } - }, - /** - * @param {Object|string} key - * @param {*} value - */ - setShape: function (key, value) { - var shape = this.shape; - // Path from string may not have shape - if (shape) { - if (zrUtil.isObject(key)) { - for (var name in key) { - shape[name] = key[name]; - } - } - else { - shape[key] = value; - } - this.dirty(true); - } - return this; - }, - - getLineScale: function () { - var m = this.transform; - // Get the line scale. - // Determinant of `m` means how much the area is enlarged by the - // transformation. So its square root can be used as a scale factor - // for width. - return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10 - ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1])) - : 1; - } - }; - - /** - * 扩展一个 Path element, 比如星形,圆等。 - * Extend a path element - * @param {Object} props - * @param {string} props.type Path type - * @param {Function} props.init Initialize - * @param {Function} props.buildPath Overwrite buildPath method - * @param {Object} [props.style] Extended default style config - * @param {Object} [props.shape] Extended default shape config - */ - Path.extend = function (defaults) { - var Sub = function (opts) { - Path.call(this, opts); - - if (defaults.style) { - // Extend default style - this.style.extendFrom(defaults.style, false); - } - - // Extend default shape - var defaultShape = defaults.shape; - if (defaultShape) { - this.shape = this.shape || {}; - var thisShape = this.shape; - for (var name in defaultShape) { - if ( - ! thisShape.hasOwnProperty(name) - && defaultShape.hasOwnProperty(name) - ) { - thisShape[name] = defaultShape[name]; - } - } - } - - defaults.init && defaults.init.call(this, opts); - }; - - zrUtil.inherits(Sub, Path); - - // FIXME 不能 extend position, rotation 等引用对象 - for (var name in defaults) { - // Extending prototype values and methods - if (name !== 'style' && name !== 'shape') { - Sub.prototype[name] = defaults[name]; - } - } - - return Sub; - }; - - zrUtil.inherits(Path, Displayable); - - return Path; -}); -define('zrender/tool/transformPath',['require','../core/PathProxy','../core/vector'],function (require) { - - var CMD = require('../core/PathProxy').CMD; - var vec2 = require('../core/vector'); - var v2ApplyTransform = vec2.applyTransform; - - var points = [[], [], []]; - var mathSqrt = Math.sqrt; - var mathAtan2 = Math.atan2; - function transformPath(path, m) { - var data = path.data; - var cmd; - var nPoint; - var i; - var j; - var k; - var p; - - var M = CMD.M; - var C = CMD.C; - var L = CMD.L; - var R = CMD.R; - var A = CMD.A; - var Q = CMD.Q; - - for (i = 0, j = 0; i < data.length;) { - cmd = data[i++]; - j = i; - nPoint = 0; - - switch (cmd) { - case M: - nPoint = 1; - break; - case L: - nPoint = 1; - break; - case C: - nPoint = 3; - break; - case Q: - nPoint = 2; - break; - case A: - var x = m[4]; - var y = m[5]; - var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]); - var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]); - var angle = mathAtan2(-m[1] / sy, m[0] / sx); - // cx - data[i++] += x; - // cy - data[i++] += y; - // Scale rx and ry - // FIXME Assume psi is 0 here - data[i++] *= sx; - data[i++] *= sy; - - // Start angle - data[i++] += angle; - // end angle - data[i++] += angle; - // FIXME psi - i += 2; - j = i; - break; - case R: - // x0, y0 - p[0] = data[i++]; - p[1] = data[i++]; - v2ApplyTransform(p, p, m); - data[j++] = p[0]; - data[j++] = p[1]; - // x1, y1 - p[0] += data[i++]; - p[1] += data[i++]; - v2ApplyTransform(p, p, m); - data[j++] = p[0]; - data[j++] = p[1]; - } - - for (k = 0; k < nPoint; k++) { - var p = points[k]; - p[0] = data[i++]; - p[1] = data[i++]; - - v2ApplyTransform(p, p, m); - // Write back - data[j++] = p[0]; - data[j++] = p[1]; - } - } - } - - return transformPath; -}); -define('zrender/tool/path',['require','../graphic/Path','../core/PathProxy','./transformPath','../core/matrix'],function (require) { - - var Path = require('../graphic/Path'); - var PathProxy = require('../core/PathProxy'); - var transformPath = require('./transformPath'); - var matrix = require('../core/matrix'); - - // command chars - var cc = [ - 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z', - 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A' - ]; - - var mathSqrt = Math.sqrt; - var mathSin = Math.sin; - var mathCos = Math.cos; - var PI = Math.PI; - - var vMag = function(v) { - return Math.sqrt(v[0] * v[0] + v[1] * v[1]); - }; - var vRatio = function(u, v) { - return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v)); - }; - var vAngle = function(u, v) { - return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) - * Math.acos(vRatio(u, v)); - }; - - function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) { - var psi = psiDeg * (PI / 180.0); - var xp = mathCos(psi) * (x1 - x2) / 2.0 - + mathSin(psi) * (y1 - y2) / 2.0; - var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0 - + mathCos(psi) * (y1 - y2) / 2.0; - - var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry); - - if (lambda > 1) { - rx *= mathSqrt(lambda); - ry *= mathSqrt(lambda); - } - - var f = (fa === fs ? -1 : 1) - * mathSqrt((((rx * rx) * (ry * ry)) - - ((rx * rx) * (yp * yp)) - - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp) - + (ry * ry) * (xp * xp)) - ) || 0; - - var cxp = f * rx * yp / ry; - var cyp = f * -ry * xp / rx; - - var cx = (x1 + x2) / 2.0 - + mathCos(psi) * cxp - - mathSin(psi) * cyp; - var cy = (y1 + y2) / 2.0 - + mathSin(psi) * cxp - + mathCos(psi) * cyp; - - var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]); - var u = [ (xp - cxp) / rx, (yp - cyp) / ry ]; - var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ]; - var dTheta = vAngle(u, v); - - if (vRatio(u, v) <= -1) { - dTheta = PI; - } - if (vRatio(u, v) >= 1) { - dTheta = 0; - } - if (fs === 0 && dTheta > 0) { - dTheta = dTheta - 2 * PI; - } - if (fs === 1 && dTheta < 0) { - dTheta = dTheta + 2 * PI; - } - - path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs); - } - - function createPathProxyFromString(data) { - if (!data) { - return []; - } - - // command string - var cs = data.replace(/-/g, ' -') - .replace(/ /g, ' ') - .replace(/ /g, ',') - .replace(/,,/g, ','); - - var n; - // create pipes so that we can split the data - for (n = 0; n < cc.length; n++) { - cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]); - } - - // create array - var arr = cs.split('|'); - // init context point - var cpx = 0; - var cpy = 0; - - var path = new PathProxy(); - var CMD = PathProxy.CMD; - - var prevCmd; - for (n = 1; n < arr.length; n++) { - var str = arr[n]; - var c = str.charAt(0); - var off = 0; - var p = str.slice(1).replace(/e,-/g, 'e-').split(','); - var cmd; - - if (p.length > 0 && p[0] === '') { - p.shift(); - } - - for (var i = 0; i < p.length; i++) { - p[i] = parseFloat(p[i]); - } - while (off < p.length && !isNaN(p[off])) { - if (isNaN(p[0])) { - break; - } - var ctlPtx; - var ctlPty; - - var rx; - var ry; - var psi; - var fa; - var fs; - - var x1 = cpx; - var y1 = cpy; - - // convert l, H, h, V, and v to L - switch (c) { - case 'l': - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'L': - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'm': - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.M; - path.addData(cmd, cpx, cpy); - c = 'l'; - break; - case 'M': - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.M; - path.addData(cmd, cpx, cpy); - c = 'L'; - break; - case 'h': - cpx += p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'H': - cpx = p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'v': - cpy += p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'V': - cpy = p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'C': - cmd = CMD.C; - path.addData( - cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++] - ); - cpx = p[off - 2]; - cpy = p[off - 1]; - break; - case 'c': - cmd = CMD.C; - path.addData( - cmd, - p[off++] + cpx, p[off++] + cpy, - p[off++] + cpx, p[off++] + cpy, - p[off++] + cpx, p[off++] + cpy - ); - cpx += p[off - 2]; - cpy += p[off - 1]; - break; - case 'S': - ctlPtx = cpx; - ctlPty = cpy; - var len = path.len(); - var pathData = path.data; - if (prevCmd === CMD.C) { - ctlPtx += cpx - pathData[len - 4]; - ctlPty += cpy - pathData[len - 3]; - } - cmd = CMD.C; - x1 = p[off++]; - y1 = p[off++]; - cpx = p[off++]; - cpy = p[off++]; - path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy); - break; - case 's': - ctlPtx = cpx; - ctlPty = cpy; - var len = path.len(); - var pathData = path.data; - if (prevCmd === CMD.C) { - ctlPtx += cpx - pathData[len - 4]; - ctlPty += cpy - pathData[len - 3]; - } - cmd = CMD.C; - x1 = cpx + p[off++]; - y1 = cpy + p[off++]; - cpx += p[off++]; - cpy += p[off++]; - path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy); - break; - case 'Q': - x1 = p[off++]; - y1 = p[off++]; - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.Q; - path.addData(cmd, x1, y1, cpx, cpy); - break; - case 'q': - x1 = p[off++] + cpx; - y1 = p[off++] + cpy; - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.Q; - path.addData(cmd, x1, y1, cpx, cpy); - break; - case 'T': - ctlPtx = cpx; - ctlPty = cpy; - var len = path.len(); - var pathData = path.data; - if (prevCmd === CMD.Q) { - ctlPtx += cpx - pathData[len - 4]; - ctlPty += cpy - pathData[len - 3]; - } - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.Q; - path.addData(cmd, ctlPtx, ctlPty, cpx, cpy); - break; - case 't': - ctlPtx = cpx; - ctlPty = cpy; - var len = path.len(); - var pathData = path.data; - if (prevCmd === CMD.Q) { - ctlPtx += cpx - pathData[len - 4]; - ctlPty += cpy - pathData[len - 3]; - } - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.Q; - path.addData(cmd, ctlPtx, ctlPty, cpx, cpy); - break; - case 'A': - rx = p[off++]; - ry = p[off++]; - psi = p[off++]; - fa = p[off++]; - fs = p[off++]; - - x1 = cpx, y1 = cpy; - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.A; - processArc( - x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path - ); - break; - case 'a': - rx = p[off++]; - ry = p[off++]; - psi = p[off++]; - fa = p[off++]; - fs = p[off++]; - - x1 = cpx, y1 = cpy; - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.A; - processArc( - x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path - ); - break; - } - } - - if (c === 'z' || c === 'Z') { - cmd = CMD.Z; - path.addData(cmd); - } - - prevCmd = cmd; - } - - path.toStatic(); - - return path; - } - - // TODO Optimize double memory cost problem - function createPathOptions(str, opts) { - var pathProxy = createPathProxyFromString(str); - var transform; - opts = opts || {}; - opts.buildPath = function (path) { - path.setData(pathProxy.data); - transform && transformPath(path, transform); - // Svg and vml renderer don't have context - var ctx = path.getContext(); - if (ctx) { - path.rebuildPath(ctx); - } - }; - - opts.applyTransform = function (m) { - if (!transform) { - transform = matrix.create(); - } - matrix.mul(transform, m, transform); - }; - - return opts; - } - - return { - /** - * Create a Path object from path string data - * http://www.w3.org/TR/SVG/paths.html#PathData - * @param {Object} opts Other options - */ - createFromString: function (str, opts) { - return new Path(createPathOptions(str, opts)); - }, - - /** - * Create a Path class from path string data - * @param {string} str - * @param {Object} opts Other options - */ - extendFromString: function (str, opts) { - return Path.extend(createPathOptions(str, opts)); - }, - - /** - * Merge multiple paths - */ - // TODO Apply transform - // TODO stroke dash - // TODO Optimize double memory cost problem - mergePath: function (pathEls, opts) { - var pathList = []; - var len = pathEls.length; - var pathEl; - var i; - for (i = 0; i < len; i++) { - pathEl = pathEls[i]; - if (pathEl.__dirty) { - pathEl.buildPath(pathEl.path, pathEl.shape); - } - pathList.push(pathEl.path); - } - - var pathBundle = new Path(opts); - pathBundle.buildPath = function (path) { - path.appendPath(pathList); - // Svg and vml renderer don't have context - var ctx = path.getContext(); - if (ctx) { - path.rebuildPath(ctx); - } - }; - - return pathBundle; - } - }; -}); -define('zrender/graphic/helper/roundRect',['require'],function (require) { - - return { - buildPath: function (ctx, shape) { - var x = shape.x; - var y = shape.y; - var width = shape.width; - var height = shape.height; - var r = shape.r; - var r1; - var r2; - var r3; - var r4; - - // Convert width and height to positive for better borderRadius - if (width < 0) { - x = x + width; - width = -width; - } - if (height < 0) { - y = y + height; - height = -height; - } - - if (typeof r === 'number') { - r1 = r2 = r3 = r4 = r; - } - else if (r instanceof Array) { - if (r.length === 1) { - r1 = r2 = r3 = r4 = r[0]; - } - else if (r.length === 2) { - r1 = r3 = r[0]; - r2 = r4 = r[1]; - } - else if (r.length === 3) { - r1 = r[0]; - r2 = r4 = r[1]; - r3 = r[2]; - } - else { - r1 = r[0]; - r2 = r[1]; - r3 = r[2]; - r4 = r[3]; - } - } - else { - r1 = r2 = r3 = r4 = 0; - } - - var total; - if (r1 + r2 > width) { - total = r1 + r2; - r1 *= width / total; - r2 *= width / total; - } - if (r3 + r4 > width) { - total = r3 + r4; - r3 *= width / total; - r4 *= width / total; - } - if (r2 + r3 > height) { - total = r2 + r3; - r2 *= height / total; - r3 *= height / total; - } - if (r1 + r4 > height) { - total = r1 + r4; - r1 *= height / total; - r4 *= height / total; - } - ctx.moveTo(x + r1, y); - ctx.lineTo(x + width - r2, y); - r2 !== 0 && ctx.quadraticCurveTo( - x + width, y, x + width, y + r2 - ); - ctx.lineTo(x + width, y + height - r3); - r3 !== 0 && ctx.quadraticCurveTo( - x + width, y + height, x + width - r3, y + height - ); - ctx.lineTo(x + r4, y + height); - r4 !== 0 && ctx.quadraticCurveTo( - x, y + height, x, y + height - r4 - ); - ctx.lineTo(x, y + r1); - r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y); - } - }; -}); -// Simple LRU cache use doubly linked list -// @module zrender/core/LRU -define('zrender/core/LRU',['require'],function(require) { - - /** - * Simple double linked list. Compared with array, it has O(1) remove operation. - * @constructor - */ - var LinkedList = function() { - - /** - * @type {module:zrender/core/LRU~Entry} - */ - this.head = null; - - /** - * @type {module:zrender/core/LRU~Entry} - */ - this.tail = null; - - this._len = 0; - }; - - var linkedListProto = LinkedList.prototype; - /** - * Insert a new value at the tail - * @param {} val - * @return {module:zrender/core/LRU~Entry} - */ - linkedListProto.insert = function(val) { - var entry = new Entry(val); - this.insertEntry(entry); - return entry; - }; - - /** - * Insert an entry at the tail - * @param {module:zrender/core/LRU~Entry} entry - */ - linkedListProto.insertEntry = function(entry) { - if (!this.head) { - this.head = this.tail = entry; - } - else { - this.tail.next = entry; - entry.prev = this.tail; - this.tail = entry; - } - this._len++; - }; - - /** - * Remove entry. - * @param {module:zrender/core/LRU~Entry} entry - */ - linkedListProto.remove = function(entry) { - var prev = entry.prev; - var next = entry.next; - if (prev) { - prev.next = next; - } - else { - // Is head - this.head = next; - } - if (next) { - next.prev = prev; - } - else { - // Is tail - this.tail = prev; - } - entry.next = entry.prev = null; - this._len--; - }; - - /** - * @return {number} - */ - linkedListProto.len = function() { - return this._len; - }; - - /** - * @constructor - * @param {} val - */ - var Entry = function(val) { - /** - * @type {} - */ - this.value = val; - - /** - * @type {module:zrender/core/LRU~Entry} - */ - this.next; - - /** - * @type {module:zrender/core/LRU~Entry} - */ - this.prev; - }; - - /** - * LRU Cache - * @constructor - * @alias module:zrender/core/LRU - */ - var LRU = function(maxSize) { - - this._list = new LinkedList(); - - this._map = {}; - - this._maxSize = maxSize || 10; - }; - - var LRUProto = LRU.prototype; - - /** - * @param {string} key - * @param {} value - */ - LRUProto.put = function(key, value) { - var list = this._list; - var map = this._map; - if (map[key] == null) { - var len = list.len(); - if (len >= this._maxSize && len > 0) { - // Remove the least recently used - var leastUsedEntry = list.head; - list.remove(leastUsedEntry); - delete map[leastUsedEntry.key]; - } - - var entry = list.insert(value); - entry.key = key; - map[key] = entry; - } - }; - - /** - * @param {string} key - * @return {} - */ - LRUProto.get = function(key) { - var entry = this._map[key]; - var list = this._list; - if (entry != null) { - // Put the latest used entry in the tail - if (entry !== list.tail) { - list.remove(entry); - list.insertEntry(entry); - } - - return entry.value; - } - }; - - /** - * Clear the cache - */ - LRUProto.clear = function() { - this._list.clear(); - this._map = {}; - }; - - return LRU; -}); -/** - * Image element - * @module zrender/graphic/Image - */ - -define('zrender/graphic/Image',['require','./Displayable','../core/BoundingRect','../core/util','./helper/roundRect','../core/LRU'],function (require) { - - var Displayable = require('./Displayable'); - var BoundingRect = require('../core/BoundingRect'); - var zrUtil = require('../core/util'); - var roundRectHelper = require('./helper/roundRect'); - - var LRU = require('../core/LRU'); - var globalImageCache = new LRU(50); - /** - * @alias zrender/graphic/Image - * @extends module:zrender/graphic/Displayable - * @constructor - * @param {Object} opts - */ - var ZImage = function (opts) { - Displayable.call(this, opts); - }; - - ZImage.prototype = { - - constructor: ZImage, - - type: 'image', - - brush: function (ctx) { - var style = this.style; - var src = style.image; - var image; - // style.image is a url string - if (typeof src === 'string') { - image = this._image; - } - // style.image is an HTMLImageElement or HTMLCanvasElement or Canvas - else { - image = src; - } - // FIXME Case create many images with src - if (!image && src) { - // Try get from global image cache - var cachedImgObj = globalImageCache.get(src); - if (!cachedImgObj) { - // Create a new image - image = new Image(); - image.onload = function () { - image.onload = null; - for (var i = 0; i < cachedImgObj.pending.length; i++) { - cachedImgObj.pending[i].dirty(); - } - }; - cachedImgObj = { - image: image, - pending: [this] - }; - image.src = src; - globalImageCache.put(src, cachedImgObj); - this._image = image; - return; - } - else { - image = cachedImgObj.image; - this._image = image; - // Image is not complete finish, add to pending list - if (!image.width || !image.height) { - cachedImgObj.pending.push(this); - return; - } - } - } - - if (image) { - // 图片已经加载完成 - // if (image.nodeName.toUpperCase() == 'IMG') { - // if (!image.complete) { - // return; - // } - // } - // Else is canvas - - var width = style.width || image.width; - var height = style.height || image.height; - var x = style.x || 0; - var y = style.y || 0; - // 图片加载失败 - if (!image.width || !image.height) { - return; - } - - ctx.save(); - - style.bind(ctx); - - // 设置transform - this.setTransform(ctx); - - if (style.r) { - // Border radius clipping - // FIXME - ctx.beginPath(); - roundRectHelper.buildPath(ctx, style); - ctx.clip(); - } - - if (style.sWidth && style.sHeight) { - var sx = style.sx || 0; - var sy = style.sy || 0; - ctx.drawImage( - image, - sx, sy, style.sWidth, style.sHeight, - x, y, width, height - ); - } - else if (style.sx && style.sy) { - var sx = style.sx; - var sy = style.sy; - var sWidth = width - sx; - var sHeight = height - sy; - ctx.drawImage( - image, - sx, sy, sWidth, sHeight, - x, y, width, height - ); - } - else { - ctx.drawImage(image, x, y, width, height); - } - - // 如果没设置宽和高的话自动根据图片宽高设置 - if (style.width == null) { - style.width = width; - } - if (style.height == null) { - style.height = height; - } - - // Draw rect text - if (style.text != null) { - this.drawRectText(ctx, this.getBoundingRect()); - } - - ctx.restore(); - } - }, - - getBoundingRect: function () { - var style = this.style; - if (! this._rect) { - this._rect = new BoundingRect( - style.x || 0, style.y || 0, style.width || 0, style.height || 0 - ); - } - return this._rect; - } - }; - - zrUtil.inherits(ZImage, Displayable); - - return ZImage; -}); -/** - * Text element - * @module zrender/graphic/Text - * - * TODO Wrapping - */ - -define('zrender/graphic/Text',['require','./Displayable','../core/util','../contain/text'],function (require) { - - var Displayable = require('./Displayable'); - var zrUtil = require('../core/util'); - var textContain = require('../contain/text'); - - /** - * @alias zrender/graphic/Text - * @extends module:zrender/graphic/Displayable - * @constructor - * @param {Object} opts - */ - var Text = function (opts) { - Displayable.call(this, opts); - }; - - Text.prototype = { - - constructor: Text, - - type: 'text', - - brush: function (ctx) { - var style = this.style; - var x = style.x || 0; - var y = style.y || 0; - // Convert to string - var text = style.text; - var textFill = style.fill; - var textStroke = style.stroke; - - // Convert to string - text != null && (text += ''); - - if (text) { - ctx.save(); - - this.style.bind(ctx); - this.setTransform(ctx); - - textFill && (ctx.fillStyle = textFill); - textStroke && (ctx.strokeStyle = textStroke); - - ctx.font = style.textFont || style.font; - ctx.textAlign = style.textAlign; - ctx.textBaseline = style.textBaseline; - - var lineHeight = textContain.measureText('国', ctx.font).width; - - var textLines = text.split('\n'); - for (var i = 0; i < textLines.length; i++) { - textFill && ctx.fillText(textLines[i], x, y); - textStroke && ctx.strokeText(textLines[i], x, y); - y += lineHeight; - } - - ctx.restore(); - } - }, - - getBoundingRect: function () { - if (!this._rect) { - var style = this.style; - var rect = textContain.getBoundingRect( - style.text + '', style.textFont, style.textAlign, style.textBaseline - ); - rect.x += style.x || 0; - rect.y += style.y || 0; - this._rect = rect; - } - return this._rect; - } - }; - - zrUtil.inherits(Text, Displayable); - - return Text; -}); -/** - * 圆形 - * @module zrender/shape/Circle - */ - -define('zrender/graphic/shape/Circle',['require','../Path'],function (require) { - - - return require('../Path').extend({ - - type: 'circle', - - shape: { - cx: 0, - cy: 0, - r: 0 - }, - - buildPath : function (ctx, shape) { - // Better stroking in ShapeBundle - ctx.moveTo(shape.cx + shape.r, shape.cy); - ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true); - return; - } - }); -}); +/***/ }, +/* 65 */ +/***/ function(module, exports, __webpack_require__) { -/** - * 扇形 - * @module zrender/graphic/shape/Sector - */ + /** + * 圆环 + * @module zrender/graphic/shape/Ring + */ -// FIXME clockwise seems wrong -define('zrender/graphic/shape/Sector',['require','../Path'],function (require) { - return require('../Path').extend({ + module.exports = __webpack_require__(44).extend({ - type: 'sector', + type: 'ring', - shape: { + shape: { + cx: 0, + cy: 0, + r: 0, + r0: 0 + }, - cx: 0, + buildPath: function (ctx, shape) { + var x = shape.cx; + var y = shape.cy; + var PI2 = Math.PI * 2; + ctx.moveTo(x + shape.r, y); + ctx.arc(x, y, shape.r, 0, PI2, false); + ctx.moveTo(x + shape.r0, y); + ctx.arc(x, y, shape.r0, 0, PI2, true); + } + }); - cy: 0, - r0: 0, - r: 0, +/***/ }, +/* 66 */ +/***/ function(module, exports, __webpack_require__) { - startAngle: 0, + /** + * 多边形 + * @module zrender/shape/Polygon + */ - endAngle: Math.PI * 2, - clockwise: true - }, + var polyHelper = __webpack_require__(67); - buildPath: function (ctx, shape) { + module.exports = __webpack_require__(44).extend({ + + type: 'polygon', - var x = shape.cx; - var y = shape.cy; - var r0 = Math.max(shape.r0 || 0, 0); - var r = Math.max(shape.r, 0); - var startAngle = shape.startAngle; - var endAngle = shape.endAngle; - var clockwise = shape.clockwise; + shape: { + points: null, - var unitX = Math.cos(startAngle); - var unitY = Math.sin(startAngle); + smooth: false, - ctx.moveTo(unitX * r0 + x, unitY * r0 + y); + smoothConstraint: null + }, + + buildPath: function (ctx, shape) { + polyHelper.buildPath(ctx, shape, true); + } + }); + + +/***/ }, +/* 67 */ +/***/ function(module, exports, __webpack_require__) { + + + + var smoothSpline = __webpack_require__(68); + var smoothBezier = __webpack_require__(69); + + module.exports = { + buildPath: function (ctx, shape, closePath) { + var points = shape.points; + var smooth = shape.smooth; + if (points && points.length >= 2) { + if (smooth && smooth !== 'spline') { + var controlPoints = smoothBezier( + points, smooth, closePath, shape.smoothConstraint + ); + + ctx.moveTo(points[0][0], points[0][1]); + var len = points.length; + for (var i = 0; i < (closePath ? len : len - 1); i++) { + var cp1 = controlPoints[i * 2]; + var cp2 = controlPoints[i * 2 + 1]; + var p = points[(i + 1) % len]; + ctx.bezierCurveTo( + cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1] + ); + } + } + else { + if (smooth === 'spline') { + points = smoothSpline(points, closePath); + } + + ctx.moveTo(points[0][0], points[0][1]); + for (var i = 1, l = points.length; i < l; i++) { + ctx.lineTo(points[i][0], points[i][1]); + } + } + + closePath && ctx.closePath(); + } + } + }; + + +/***/ }, +/* 68 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Catmull-Rom spline 插值折线 + * @module zrender/shape/util/smoothSpline + * @author pissang (https://www.github.com/pissang) + * Kener (@Kener-林峰, kener.linfeng@gmail.com) + * errorrik (errorrik@gmail.com) + */ + + var vec2 = __webpack_require__(16); + + /** + * @inner + */ + function interpolate(p0, p1, p2, p3, t, t2, t3) { + var v0 = (p2 - p0) * 0.5; + var v1 = (p3 - p1) * 0.5; + return (2 * (p1 - p2) + v0 + v1) * t3 + + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + + v0 * t + p1; + } + + /** + * @alias module:zrender/shape/util/smoothSpline + * @param {Array} points 线段顶点数组 + * @param {boolean} isLoop + * @return {Array} + */ + module.exports = function (points, isLoop) { + var len = points.length; + var ret = []; + + var distance = 0; + for (var i = 1; i < len; i++) { + distance += vec2.distance(points[i - 1], points[i]); + } + + var segs = distance / 2; + segs = segs < len ? len : segs; + for (var i = 0; i < segs; i++) { + var pos = i / (segs - 1) * (isLoop ? len : len - 1); + var idx = Math.floor(pos); + + var w = pos - idx; + + var p0; + var p1 = points[idx % len]; + var p2; + var p3; + if (!isLoop) { + p0 = points[idx === 0 ? idx : idx - 1]; + p2 = points[idx > len - 2 ? len - 1 : idx + 1]; + p3 = points[idx > len - 3 ? len - 1 : idx + 2]; + } + else { + p0 = points[(idx - 1 + len) % len]; + p2 = points[(idx + 1) % len]; + p3 = points[(idx + 2) % len]; + } + + var w2 = w * w; + var w3 = w * w2; + + ret.push([ + interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3), + interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3) + ]); + } + return ret; + }; + + + +/***/ }, +/* 69 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 贝塞尔平滑曲线 + * @module zrender/shape/util/smoothBezier + * @author pissang (https://www.github.com/pissang) + * Kener (@Kener-林峰, kener.linfeng@gmail.com) + * errorrik (errorrik@gmail.com) + */ + + + var vec2 = __webpack_require__(16); + var v2Min = vec2.min; + var v2Max = vec2.max; + var v2Scale = vec2.scale; + var v2Distance = vec2.distance; + var v2Add = vec2.add; + + /** + * 贝塞尔平滑曲线 + * @alias module:zrender/shape/util/smoothBezier + * @param {Array} points 线段顶点数组 + * @param {number} smooth 平滑等级, 0-1 + * @param {boolean} isLoop + * @param {Array} constraint 将计算出来的控制点约束在一个包围盒内 + * 比如 [[0, 0], [100, 100]], 这个包围盒会与 + * 整个折线的包围盒做一个并集用来约束控制点。 + * @param {Array} 计算出来的控制点数组 + */ + module.exports = function (points, smooth, isLoop, constraint) { + var cps = []; + + var v = []; + var v1 = []; + var v2 = []; + var prevPoint; + var nextPoint; + + var min, max; + if (constraint) { + min = [Infinity, Infinity]; + max = [-Infinity, -Infinity]; + for (var i = 0, len = points.length; i < len; i++) { + v2Min(min, min, points[i]); + v2Max(max, max, points[i]); + } + // 与指定的包围盒做并集 + v2Min(min, min, constraint[0]); + v2Max(max, max, constraint[1]); + } + + for (var i = 0, len = points.length; i < len; i++) { + var point = points[i]; + + if (isLoop) { + prevPoint = points[i ? i - 1 : len - 1]; + nextPoint = points[(i + 1) % len]; + } + else { + if (i === 0 || i === len - 1) { + cps.push(vec2.clone(points[i])); + continue; + } + else { + prevPoint = points[i - 1]; + nextPoint = points[i + 1]; + } + } + + vec2.sub(v, nextPoint, prevPoint); + + // use degree to scale the handle length + v2Scale(v, v, smooth); + + var d0 = v2Distance(point, prevPoint); + var d1 = v2Distance(point, nextPoint); + var sum = d0 + d1; + if (sum !== 0) { + d0 /= sum; + d1 /= sum; + } + + v2Scale(v1, v, -d0); + v2Scale(v2, v, d1); + var cp0 = v2Add([], point, v1); + var cp1 = v2Add([], point, v2); + if (constraint) { + v2Max(cp0, cp0, min); + v2Min(cp0, cp0, max); + v2Max(cp1, cp1, min); + v2Min(cp1, cp1, max); + } + cps.push(cp0); + cps.push(cp1); + } + + if (isLoop) { + cps.push(cps.shift()); + } + + return cps; + }; + + + +/***/ }, +/* 70 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module zrender/graphic/shape/Polyline + */ + + + var polyHelper = __webpack_require__(67); + + module.exports = __webpack_require__(44).extend({ + + type: 'polyline', + + shape: { + points: null, + + smooth: false, + + smoothConstraint: null + }, + + style: { + stroke: '#000', + + fill: null + }, + + buildPath: function (ctx, shape) { + polyHelper.buildPath(ctx, shape, false); + } + }); + + +/***/ }, +/* 71 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 矩形 + * @module zrender/graphic/shape/Rect + */ + + + var roundRectHelper = __webpack_require__(60); + + module.exports = __webpack_require__(44).extend({ + + type: 'rect', + + shape: { + // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4 + // r缩写为1 相当于 [1, 1, 1, 1] + // r缩写为[1] 相当于 [1, 1, 1, 1] + // r缩写为[1, 2] 相当于 [1, 2, 1, 2] + // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2] + r: 0, + + x: 0, + y: 0, + width: 0, + height: 0 + }, + + buildPath: function (ctx, shape) { + var x = shape.x; + var y = shape.y; + var width = shape.width; + var height = shape.height; + if (!shape.r) { + ctx.rect(x, y, width, height); + } + else { + roundRectHelper.buildPath(ctx, shape); + } + ctx.closePath(); + return; + } + }); + + + +/***/ }, +/* 72 */ +/***/ function(module, exports, __webpack_require__) { - ctx.lineTo(unitX * r + x, unitY * r + y); + /** + * 直线 + * @module zrender/graphic/shape/Line + */ - ctx.arc(x, y, r, startAngle, endAngle, !clockwise); + module.exports = __webpack_require__(44).extend({ - ctx.lineTo( - Math.cos(endAngle) * r0 + x, - Math.sin(endAngle) * r0 + y - ); + type: 'line', + + shape: { + // Start point + x1: 0, + y1: 0, + // End point + x2: 0, + y2: 0, + + percent: 1 + }, + + style: { + stroke: '#000', + fill: null + }, + + buildPath: function (ctx, shape) { + var x1 = shape.x1; + var y1 = shape.y1; + var x2 = shape.x2; + var y2 = shape.y2; + var percent = shape.percent; + + if (percent === 0) { + return; + } + + ctx.moveTo(x1, y1); + + if (percent < 1) { + x2 = x1 * (1 - percent) + x2 * percent; + y2 = y1 * (1 - percent) + y2 * percent; + } + ctx.lineTo(x2, y2); + }, + + /** + * Get point at percent + * @param {number} percent + * @return {Array.} + */ + pointAt: function (p) { + var shape = this.shape; + return [ + shape.x1 * (1 - p) + shape.x2 * p, + shape.y1 * (1 - p) + shape.y2 * p + ]; + } + }); + + + +/***/ }, +/* 73 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 贝塞尔曲线 + * @module zrender/shape/BezierCurve + */ + + + var curveTool = __webpack_require__(49); + var quadraticSubdivide = curveTool.quadraticSubdivide; + var cubicSubdivide = curveTool.cubicSubdivide; + var quadraticAt = curveTool.quadraticAt; + var cubicAt = curveTool.cubicAt; + + var out = []; + module.exports = __webpack_require__(44).extend({ + + type: 'bezier-curve', + + shape: { + x1: 0, + y1: 0, + x2: 0, + y2: 0, + cpx1: 0, + cpy1: 0, + // cpx2: 0, + // cpy2: 0 + + // Curve show percent, for animating + percent: 1 + }, + + style: { + stroke: '#000', + fill: null + }, + + buildPath: function (ctx, shape) { + var x1 = shape.x1; + var y1 = shape.y1; + var x2 = shape.x2; + var y2 = shape.y2; + var cpx1 = shape.cpx1; + var cpy1 = shape.cpy1; + var cpx2 = shape.cpx2; + var cpy2 = shape.cpy2; + var percent = shape.percent; + if (percent === 0) { + return; + } + + ctx.moveTo(x1, y1); + + if (cpx2 == null || cpy2 == null) { + if (percent < 1) { + quadraticSubdivide( + x1, cpx1, x2, percent, out + ); + cpx1 = out[1]; + x2 = out[2]; + quadraticSubdivide( + y1, cpy1, y2, percent, out + ); + cpy1 = out[1]; + y2 = out[2]; + } + + ctx.quadraticCurveTo( + cpx1, cpy1, + x2, y2 + ); + } + else { + if (percent < 1) { + cubicSubdivide( + x1, cpx1, cpx2, x2, percent, out + ); + cpx1 = out[1]; + cpx2 = out[2]; + x2 = out[3]; + cubicSubdivide( + y1, cpy1, cpy2, y2, percent, out + ); + cpy1 = out[1]; + cpy2 = out[2]; + y2 = out[3]; + } + ctx.bezierCurveTo( + cpx1, cpy1, + cpx2, cpy2, + x2, y2 + ); + } + }, + + /** + * Get point at percent + * @param {number} percent + * @return {Array.} + */ + pointAt: function (p) { + var shape = this.shape; + var cpx2 = shape.cpx2; + var cpy2 = shape.cpy2; + if (cpx2 === null || cpy2 === null) { + return [ + quadraticAt(shape.x1, shape.cpx1, shape.x2, p), + quadraticAt(shape.y1, shape.cpy1, shape.y2, p) + ]; + } + else { + return [ + cubicAt(shape.x1, shape.cpx1, shape.cpx1, shape.x2, p), + cubicAt(shape.y1, shape.cpy1, shape.cpy1, shape.y2, p) + ]; + } + } + }); + + + +/***/ }, +/* 74 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 圆弧 + * @module zrender/graphic/shape/Arc + */ + + + module.exports = __webpack_require__(44).extend({ + + type: 'arc', + + shape: { + + cx: 0, + + cy: 0, + + r: 0, + + startAngle: 0, + + endAngle: Math.PI * 2, - if (r0 !== 0) { - ctx.arc(x, y, r0, endAngle, startAngle, clockwise); - } + clockwise: true + }, - ctx.closePath(); - } - }); -}); + style: { -/** - * Catmull-Rom spline 插值折线 - * @module zrender/shape/util/smoothSpline - * @author pissang (https://www.github.com/pissang) - * Kener (@Kener-林峰, kener.linfeng@gmail.com) - * errorrik (errorrik@gmail.com) - */ -define('zrender/graphic/helper/smoothSpline',['require','../../core/vector'],function (require) { - var vec2 = require('../../core/vector'); - - /** - * @inner - */ - function interpolate(p0, p1, p2, p3, t, t2, t3) { - var v0 = (p2 - p0) * 0.5; - var v1 = (p3 - p1) * 0.5; - return (2 * (p1 - p2) + v0 + v1) * t3 - + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 - + v0 * t + p1; - } - - /** - * @alias module:zrender/shape/util/smoothSpline - * @param {Array} points 线段顶点数组 - * @param {boolean} isLoop - * @return {Array} - */ - return function (points, isLoop) { - var len = points.length; - var ret = []; - - var distance = 0; - for (var i = 1; i < len; i++) { - distance += vec2.distance(points[i - 1], points[i]); - } - - var segs = distance / 2; - segs = segs < len ? len : segs; - for (var i = 0; i < segs; i++) { - var pos = i / (segs - 1) * (isLoop ? len : len - 1); - var idx = Math.floor(pos); - - var w = pos - idx; - - var p0; - var p1 = points[idx % len]; - var p2; - var p3; - if (!isLoop) { - p0 = points[idx === 0 ? idx : idx - 1]; - p2 = points[idx > len - 2 ? len - 1 : idx + 1]; - p3 = points[idx > len - 3 ? len - 1 : idx + 2]; - } - else { - p0 = points[(idx - 1 + len) % len]; - p2 = points[(idx + 1) % len]; - p3 = points[(idx + 2) % len]; - } - - var w2 = w * w; - var w3 = w * w2; - - ret.push([ - interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3), - interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3) - ]); - } - return ret; - }; -}); + stroke: '#000', -/** - * 贝塞尔平滑曲线 - * @module zrender/shape/util/smoothBezier - * @author pissang (https://www.github.com/pissang) - * Kener (@Kener-林峰, kener.linfeng@gmail.com) - * errorrik (errorrik@gmail.com) - */ -define('zrender/graphic/helper/smoothBezier',['require','../../core/vector'],function (require) { - - var vec2 = require('../../core/vector'); - var v2Min = vec2.min; - var v2Max = vec2.max; - var v2Scale = vec2.scale; - var v2Distance = vec2.distance; - var v2Add = vec2.add; - - /** - * 贝塞尔平滑曲线 - * @alias module:zrender/shape/util/smoothBezier - * @param {Array} points 线段顶点数组 - * @param {number} smooth 平滑等级, 0-1 - * @param {boolean} isLoop - * @param {Array} constraint 将计算出来的控制点约束在一个包围盒内 - * 比如 [[0, 0], [100, 100]], 这个包围盒会与 - * 整个折线的包围盒做一个并集用来约束控制点。 - * @param {Array} 计算出来的控制点数组 - */ - return function (points, smooth, isLoop, constraint) { - var cps = []; - - var v = []; - var v1 = []; - var v2 = []; - var prevPoint; - var nextPoint; - - var min, max; - if (constraint) { - min = [Infinity, Infinity]; - max = [-Infinity, -Infinity]; - for (var i = 0, len = points.length; i < len; i++) { - v2Min(min, min, points[i]); - v2Max(max, max, points[i]); - } - // 与指定的包围盒做并集 - v2Min(min, min, constraint[0]); - v2Max(max, max, constraint[1]); - } - - for (var i = 0, len = points.length; i < len; i++) { - var point = points[i]; - - if (isLoop) { - prevPoint = points[i ? i - 1 : len - 1]; - nextPoint = points[(i + 1) % len]; - } - else { - if (i === 0 || i === len - 1) { - cps.push(vec2.clone(points[i])); - continue; - } - else { - prevPoint = points[i - 1]; - nextPoint = points[i + 1]; - } - } - - vec2.sub(v, nextPoint, prevPoint); - - // use degree to scale the handle length - v2Scale(v, v, smooth); - - var d0 = v2Distance(point, prevPoint); - var d1 = v2Distance(point, nextPoint); - var sum = d0 + d1; - if (sum !== 0) { - d0 /= sum; - d1 /= sum; - } - - v2Scale(v1, v, -d0); - v2Scale(v2, v, d1); - var cp0 = v2Add([], point, v1); - var cp1 = v2Add([], point, v2); - if (constraint) { - v2Max(cp0, cp0, min); - v2Min(cp0, cp0, max); - v2Max(cp1, cp1, min); - v2Min(cp1, cp1, max); - } - cps.push(cp0); - cps.push(cp1); - } - - if (isLoop) { - cps.push(cps.shift()); - } - - return cps; - }; -}); + fill: null + }, -define('zrender/graphic/helper/poly',['require','./smoothSpline','./smoothBezier'],function (require) { - - var smoothSpline = require('./smoothSpline'); - var smoothBezier = require('./smoothBezier'); - - return { - buildPath: function (ctx, shape, closePath) { - var points = shape.points; - var smooth = shape.smooth; - if (points && points.length >= 2) { - if (smooth && smooth !== 'spline') { - var controlPoints = smoothBezier( - points, smooth, closePath, shape.smoothConstraint - ); - - ctx.moveTo(points[0][0], points[0][1]); - var len = points.length; - for (var i = 0; i < (closePath ? len : len - 1); i++) { - var cp1 = controlPoints[i * 2]; - var cp2 = controlPoints[i * 2 + 1]; - var p = points[(i + 1) % len]; - ctx.bezierCurveTo( - cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1] - ); - } - } - else { - if (smooth === 'spline') { - points = smoothSpline(points, closePath); - } - - ctx.moveTo(points[0][0], points[0][1]); - for (var i = 1, l = points.length; i < l; i++) { - ctx.lineTo(points[i][0], points[i][1]); - } - } - - closePath && ctx.closePath(); - } - } - }; -}); -/** - * 多边形 - * @module zrender/shape/Polygon - */ -define('zrender/graphic/shape/Polygon',['require','../helper/poly','../Path'],function (require) { + buildPath: function (ctx, shape) { - var polyHelper = require('../helper/poly'); + var x = shape.cx; + var y = shape.cy; + var r = Math.max(shape.r, 0); + var startAngle = shape.startAngle; + var endAngle = shape.endAngle; + var clockwise = shape.clockwise; - return require('../Path').extend({ - - type: 'polygon', + var unitX = Math.cos(startAngle); + var unitY = Math.sin(startAngle); - shape: { - points: null, + ctx.moveTo(unitX * r + x, unitY * r + y); + ctx.arc(x, y, r, startAngle, endAngle, !clockwise); + } + }); - smooth: false, - smoothConstraint: null - }, +/***/ }, +/* 75 */ +/***/ function(module, exports, __webpack_require__) { - buildPath: function (ctx, shape) { - polyHelper.buildPath(ctx, shape, true); - } - }); -}); -/** - * @module zrender/graphic/shape/Polyline - */ -define('zrender/graphic/shape/Polyline',['require','../helper/poly','../Path'],function (require) { + 'use strict'; - var polyHelper = require('../helper/poly'); - return require('../Path').extend({ - - type: 'polyline', + var zrUtil = __webpack_require__(3); - shape: { - points: null, + var Gradient = __webpack_require__(4); - smooth: false, + /** + * x, y, x2, y2 are all percent from 0 to 1 + * @param {number} [x=0] + * @param {number} [y=0] + * @param {number} [x2=1] + * @param {number} [y2=0] + * @param {Array.} colorStops + */ + var LinearGradient = function (x, y, x2, y2, colorStops) { + this.x = x == null ? 0 : x; - smoothConstraint: null - }, + this.y = y == null ? 0 : y; - style: { - stroke: '#000', + this.x2 = x2 == null ? 1 : x2; - fill: null - }, + this.y2 = y2 == null ? 0 : y2; - buildPath: function (ctx, shape) { - polyHelper.buildPath(ctx, shape, false); - } - }); -}); -/** - * 矩形 - * @module zrender/graphic/shape/Rect - */ - -define('zrender/graphic/shape/Rect',['require','../helper/roundRect','../Path'],function (require) { - var roundRectHelper = require('../helper/roundRect'); - - return require('../Path').extend({ - - type: 'rect', - - shape: { - // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4 - // r缩写为1 相当于 [1, 1, 1, 1] - // r缩写为[1] 相当于 [1, 1, 1, 1] - // r缩写为[1, 2] 相当于 [1, 2, 1, 2] - // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2] - r: 0, - - x: 0, - y: 0, - width: 0, - height: 0 - }, - - buildPath: function (ctx, shape) { - var x = shape.x; - var y = shape.y; - var width = shape.width; - var height = shape.height; - if (!shape.r) { - ctx.rect(x, y, width, height); - } - else { - roundRectHelper.buildPath(ctx, shape); - } - ctx.closePath(); - return; - } - }); -}); + Gradient.call(this, colorStops); + }; -/** - * 直线 - * @module zrender/graphic/shape/Line - */ -define('zrender/graphic/shape/Line',['require','../Path'],function (require) { - return require('../Path').extend({ - - type: 'line', - - shape: { - // Start point - x1: 0, - y1: 0, - // End point - x2: 0, - y2: 0, - - percent: 1 - }, - - style: { - stroke: '#000', - fill: null - }, - - buildPath: function (ctx, shape) { - var x1 = shape.x1; - var y1 = shape.y1; - var x2 = shape.x2; - var y2 = shape.y2; - var percent = shape.percent; - - if (percent === 0) { - return; - } - - ctx.moveTo(x1, y1); - - if (percent < 1) { - x2 = x1 * (1 - percent) + x2 * percent; - y2 = y1 * (1 - percent) + y2 * percent; - } - ctx.lineTo(x2, y2); - }, - - /** - * Get point at percent - * @param {number} percent - * @return {Array.} - */ - pointAt: function (p) { - var shape = this.shape; - return [ - shape.x1 * (1 - p) + shape.x2 * p, - shape.y1 * (1 - p) + shape.y2 * p - ]; - } - }); -}); + LinearGradient.prototype = { -/** - * 贝塞尔曲线 - * @module zrender/shape/BezierCurve - */ -define('zrender/graphic/shape/BezierCurve',['require','../../core/curve','../Path'],function (require) { - - - var curveTool = require('../../core/curve'); - var quadraticSubdivide = curveTool.quadraticSubdivide; - var cubicSubdivide = curveTool.cubicSubdivide; - var quadraticAt = curveTool.quadraticAt; - var cubicAt = curveTool.cubicAt; - - var out = []; - return require('../Path').extend({ - - type: 'bezier-curve', - - shape: { - x1: 0, - y1: 0, - x2: 0, - y2: 0, - cpx1: 0, - cpy1: 0, - // cpx2: 0, - // cpy2: 0 - - // Curve show percent, for animating - percent: 1 - }, - - style: { - stroke: '#000', - fill: null - }, - - buildPath: function (ctx, shape) { - var x1 = shape.x1; - var y1 = shape.y1; - var x2 = shape.x2; - var y2 = shape.y2; - var cpx1 = shape.cpx1; - var cpy1 = shape.cpy1; - var cpx2 = shape.cpx2; - var cpy2 = shape.cpy2; - var percent = shape.percent; - if (percent === 0) { - return; - } - - ctx.moveTo(x1, y1); - - if (cpx2 == null || cpy2 == null) { - if (percent < 1) { - quadraticSubdivide( - x1, cpx1, x2, percent, out - ); - cpx1 = out[1]; - x2 = out[2]; - quadraticSubdivide( - y1, cpy1, y2, percent, out - ); - cpy1 = out[1]; - y2 = out[2]; - } - - ctx.quadraticCurveTo( - cpx1, cpy1, - x2, y2 - ); - } - else { - if (percent < 1) { - cubicSubdivide( - x1, cpx1, cpx2, x2, percent, out - ); - cpx1 = out[1]; - cpx2 = out[2]; - x2 = out[3]; - cubicSubdivide( - y1, cpy1, cpy2, y2, percent, out - ); - cpy1 = out[1]; - cpy2 = out[2]; - y2 = out[3]; - } - ctx.bezierCurveTo( - cpx1, cpy1, - cpx2, cpy2, - x2, y2 - ); - } - }, - - /** - * Get point at percent - * @param {number} percent - * @return {Array.} - */ - pointAt: function (p) { - var shape = this.shape; - var cpx2 = shape.cpx2; - var cpy2 = shape.cpy2; - if (cpx2 === null || cpy2 === null) { - return [ - quadraticAt(shape.x1, shape.cpx1, shape.x2, p), - quadraticAt(shape.y1, shape.cpy1, shape.y2, p) - ]; - } - else { - return [ - cubicAt(shape.x1, shape.cpx1, shape.cpx1, shape.x2, p), - cubicAt(shape.y1, shape.cpy1, shape.cpy1, shape.y2, p) - ]; - } - } - }); -}); + constructor: LinearGradient, -/** - * 圆弧 - * @module zrender/graphic/shape/Arc - */ - define('zrender/graphic/shape/Arc',['require','../Path'],function (require) { + type: 'linear', - return require('../Path').extend({ + updateCanvasGradient: function (shape, ctx) { + var rect = shape.getBoundingRect(); + // var size = + var x = this.x * rect.width + rect.x; + var x2 = this.x2 * rect.width + rect.x; + var y = this.y * rect.height + rect.y; + var y2 = this.y2 * rect.height + rect.y; - type: 'arc', + var canvasGradient = ctx.createLinearGradient(x, y, x2, y2); - shape: { + var colorStops = this.colorStops; + for (var i = 0; i < colorStops.length; i++) { + canvasGradient.addColorStop( + colorStops[i].offset, colorStops[i].color + ); + } - cx: 0, + this.canvasGradient = canvasGradient; + } - cy: 0, + }; - r: 0, + zrUtil.inherits(LinearGradient, Gradient); - startAngle: 0, + module.exports = LinearGradient; - endAngle: Math.PI * 2, - clockwise: true - }, +/***/ }, +/* 76 */ +/***/ function(module, exports, __webpack_require__) { - style: { + 'use strict'; - stroke: '#000', - fill: null - }, + var zrUtil = __webpack_require__(3); - buildPath: function (ctx, shape) { + var Gradient = __webpack_require__(4); - var x = shape.cx; - var y = shape.cy; - var r = Math.max(shape.r, 0); - var startAngle = shape.startAngle; - var endAngle = shape.endAngle; - var clockwise = shape.clockwise; + /** + * x, y, r are all percent from 0 to 1 + * @param {number} [x=0.5] + * @param {number} [y=0.5] + * @param {number} [r=0.5] + * @param {Array.} [colorStops] + */ + var RadialGradient = function (x, y, r, colorStops) { + this.x = x == null ? 0.5 : x; - var unitX = Math.cos(startAngle); - var unitY = Math.sin(startAngle); + this.y = y == null ? 0.5 : y; - ctx.moveTo(unitX * r + x, unitY * r + y); - ctx.arc(x, y, r, startAngle, endAngle, !clockwise); - } - }); -}); -define('zrender/graphic/LinearGradient',['require','../core/util','./Gradient'],function(require) { - + this.r = r == null ? 0.5 : r; - var zrUtil = require('../core/util'); + Gradient.call(this, colorStops); + }; - var Gradient = require('./Gradient'); + RadialGradient.prototype = { - /** - * x, y, x2, y2 are all percent from 0 to 1 - * @param {number} [x=0] - * @param {number} [y=0] - * @param {number} [x2=1] - * @param {number} [y2=0] - * @param {Array.} colorStops - */ - var LinearGradient = function (x, y, x2, y2, colorStops) { - this.x = x == null ? 0 : x; + constructor: RadialGradient, - this.y = y == null ? 0 : y; + type: 'radial', - this.x2 = x2 == null ? 1 : x2; + updateCanvasGradient: function (shape, ctx) { + var rect = shape.getBoundingRect(); - this.y2 = y2 == null ? 0 : y2; + var width = rect.width; + var height = rect.height; + var min = Math.min(width, height); + // var max = Math.max(width, height); - Gradient.call(this, colorStops); - }; + var x = this.x * width + rect.x; + var y = this.y * height + rect.y; + var r = this.r * min; - LinearGradient.prototype = { + var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r); - constructor: LinearGradient, + var colorStops = this.colorStops; + for (var i = 0; i < colorStops.length; i++) { + canvasGradient.addColorStop( + colorStops[i].offset, colorStops[i].color + ); + } - type: 'linear', + this.canvasGradient = canvasGradient; + } + }; + + zrUtil.inherits(RadialGradient, Gradient); + + module.exports = RadialGradient; - updateCanvasGradient: function (shape, ctx) { - var rect = shape.getBoundingRect(); - // var size = - var x = this.x * rect.width + rect.x; - var x2 = this.x2 * rect.width + rect.x; - var y = this.y * rect.height + rect.y; - var y2 = this.y2 * rect.height + rect.y; - var canvasGradient = ctx.createLinearGradient(x, y, x2, y2); +/***/ }, +/* 77 */ +/***/ function(module, exports, __webpack_require__) { + + /*! + * ZRender, a high performance 2d drawing library. + * + * Copyright (c) 2013, Baidu Inc. + * All rights reserved. + * + * LICENSE + * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt + */ + // Global defines + + var guid = __webpack_require__(31); + var env = __webpack_require__(78); + + var Handler = __webpack_require__(79); + var Storage = __webpack_require__(83); + var Animation = __webpack_require__(84); + + var useVML = !env.canvasSupported; + + var painterCtors = { + canvas: __webpack_require__(85) + }; + + var instances = {}; // ZRender实例map索引 + + var zrender = {}; + /** + * @type {string} + */ + zrender.version = '3.0.4'; + + /** + * @param {HTMLElement} dom + * @param {Object} opts + * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg' + * @param {number} [opts.devicePixelRatio] + * @return {module:zrender/ZRender} + */ + zrender.init = function(dom, opts) { + var zr = new ZRender(guid(), dom, opts); + instances[zr.id] = zr; + return zr; + }; + + /** + * Dispose zrender instance + * @param {module:zrender/ZRender} zr + */ + zrender.dispose = function (zr) { + if (zr) { + zr.dispose(); + } + else { + for (var key in instances) { + instances[key].dispose(); + } + instances = {}; + } + + return zrender; + }; + + /** + * 获取zrender实例 + * @param {string} id ZRender对象索引 + * @return {module:zrender/ZRender} + */ + zrender.getInstance = function (id) { + return instances[id]; + }; + + zrender.registerPainter = function (name, Ctor) { + painterCtors[name] = Ctor; + }; + + function delInstance(id) { + delete instances[id]; + } + + /** + * @module zrender/ZRender + */ + /** + * @constructor + * @alias module:zrender/ZRender + * @param {string} id + * @param {HTMLDomElement} dom + * @param {Object} opts + * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg' + * @param {number} [opts.devicePixelRatio] + */ + var ZRender = function(id, dom, opts) { + + opts = opts || {}; + + /** + * @type {HTMLDomElement} + */ + this.dom = dom; + + /** + * @type {string} + */ + this.id = id; + + var self = this; + var storage = new Storage(); + + var rendererType = opts.renderer; + if (useVML) { + if (!painterCtors.vml) { + throw new Error('You need to require \'zrender/vml/vml\' to support IE8'); + } + rendererType = 'vml'; + } + else if (!rendererType || !painterCtors[rendererType]) { + rendererType = 'canvas'; + } + var painter = new painterCtors[rendererType](dom, storage, opts); + + this.storage = storage; + this.painter = painter; + if (!env.node) { + this.handler = new Handler(painter.getViewportRoot(), storage, painter); + } + + /** + * @type {module:zrender/animation/Animation} + */ + this.animation = new Animation({ + stage: { + update: function () { + if (self._needsRefresh) { + self.refreshImmediately(); + } + } + } + }); + this.animation.start(); + + /** + * @type {boolean} + * @private + */ + this._needsRefresh; + + // 修改 storage.delFromMap, 每次删除元素之前删除动画 + // FIXME 有点ugly + var oldDelFromMap = storage.delFromMap; + var oldAddToMap = storage.addToMap; + + storage.delFromMap = function (elId) { + var el = storage.get(elId); + + oldDelFromMap.call(storage, elId); + + el && el.removeSelfFromZr(self); + }; + + storage.addToMap = function (el) { + oldAddToMap.call(storage, el); + + el.addSelfToZr(self); + }; + }; + + ZRender.prototype = { + + constructor: ZRender, + /** + * 获取实例唯一标识 + * @return {string} + */ + getId: function () { + return this.id; + }, + + /** + * 添加元素 + * @param {string|module:zrender/Element} el + */ + add: function (el) { + this.storage.addRoot(el); + this._needsRefresh = true; + }, + + /** + * 删除元素 + * @param {string|module:zrender/Element} el + */ + remove: function (el) { + this.storage.delRoot(el); + this._needsRefresh = true; + }, + + /** + * 修改指定zlevel的绘制配置项 + * + * @param {string} zLevel + * @param {Object} config 配置对象 + * @param {string} [config.clearColor=0] 每次清空画布的颜色 + * @param {string} [config.motionBlur=false] 是否开启动态模糊 + * @param {number} [config.lastFrameAlpha=0.7] + * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 + */ + configLayer: function (zLevel, config) { + this.painter.configLayer(zLevel, config); + this._needsRefresh = true; + }, + + /** + * 视图更新 + */ + refreshImmediately: function () { + // Clear needsRefresh ahead to avoid something wrong happens in refresh + // Or it will cause zrender refreshes again and again. + this._needsRefresh = false; + this.painter.refresh(); + /** + * Avoid trigger zr.refresh in Element#beforeUpdate hook + */ + this._needsRefresh = false; + }, + + /** + * 标记视图在浏览器下一帧需要绘制 + */ + refresh: function() { + this._needsRefresh = true; + }, + + /** + * 调整视图大小 + */ + resize: function() { + this.painter.resize(); + this.handler && this.handler.resize(); + }, + + /** + * 停止所有动画 + */ + clearAnimation: function () { + this.animation.clear(); + }, + + /** + * 获取视图宽度 + */ + getWidth: function() { + return this.painter.getWidth(); + }, + + /** + * 获取视图高度 + */ + getHeight: function() { + return this.painter.getHeight(); + }, + + /** + * 图像导出 + * @param {string} type + * @param {string} [backgroundColor='#fff'] 背景色 + * @return {string} 图片的Base64 url + */ + toDataURL: function(type, backgroundColor, args) { + return this.painter.toDataURL(type, backgroundColor, args); + }, + + /** + * 将常规shape转成image shape + * @param {module:zrender/graphic/Path} e + * @param {number} width + * @param {number} height + */ + pathToImage: function(e, width, height) { + var id = guid(); + return this.painter.pathToImage(id, e, width, height); + }, + + /** + * 设置默认的cursor style + * @param {string} cursorStyle 例如 crosshair + */ + setDefaultCursorStyle: function (cursorStyle) { + this.handler.setDefaultCursorStyle(cursorStyle); + }, + + /** + * 事件绑定 + * + * @param {string} eventName 事件名称 + * @param {Function} eventHandler 响应函数 + * @param {Object} [context] 响应函数 + */ + on: function(eventName, eventHandler, context) { + this.handler && this.handler.on(eventName, eventHandler, context); + }, + + /** + * 事件解绑定,参数为空则解绑所有自定义事件 + * + * @param {string} eventName 事件名称 + * @param {Function} eventHandler 响应函数 + */ + off: function(eventName, eventHandler) { + this.handler && this.handler.off(eventName, eventHandler); + }, + + /** + * 事件触发 + * + * @param {string} eventName 事件名称,resize,hover,drag,etc + * @param {event=} event event dom事件对象 + */ + trigger: function (eventName, event) { + this.handler && this.handler.trigger(eventName, event); + }, + + + /** + * 清除当前ZRender下所有类图的数据和显示,clear后MVC和已绑定事件均还存在在,ZRender可用 + */ + clear: function () { + this.storage.delRoot(); + this.painter.clear(); + }, + + /** + * 释放当前ZR实例(删除包括dom,数据、显示和事件绑定),dispose后ZR不可用 + */ + dispose: function () { + this.animation.stop(); + + this.clear(); + this.storage.dispose(); + this.painter.dispose(); + this.handler && this.handler.dispose(); + + this.animation = + this.storage = + this.painter = + this.handler = null; + + delInstance(this.id); + } + }; + + module.exports = zrender; + + + +/***/ }, +/* 78 */ +/***/ function(module, exports) { + + /** + * echarts设备环境识别 + * + * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。 + * @author firede[firede@firede.us] + * @desc thanks zepto. + */ + + var env = {}; + if (typeof navigator === 'undefined') { + // In node + env = { + browser: {}, + os: {}, + node: true, + // Assume canvas is supported + canvasSupported: true + }; + } + else { + env = detect(navigator.userAgent); + } + + module.exports = env; + + // Zepto.js + // (c) 2010-2013 Thomas Fuchs + // Zepto.js may be freely distributed under the MIT license. + + function detect(ua) { + var os = {}; + var browser = {}; + var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/); + var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); + var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); + var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); + var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/); + var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/); + var touchpad = webos && ua.match(/TouchPad/); + var kindle = ua.match(/Kindle\/([\d.]+)/); + var silk = ua.match(/Silk\/([\d._]+)/); + var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/); + var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/); + var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/); + var playbook = ua.match(/PlayBook/); + var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/); + var firefox = ua.match(/Firefox\/([\d.]+)/); + var safari = webkit && ua.match(/Mobile\//) && !chrome; + var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome; + var ie = ua.match(/MSIE\s([\d.]+)/) + // IE 11 Trident/7.0; rv:11.0 + || ua.match(/Trident\/.+?rv:(([\d.]+))/); + var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+ + + // Todo: clean this up with a better OS/browser seperation: + // - discern (more) between multiple browsers on android + // - decide if kindle fire in silk mode is android or not + // - Firefox on Android doesn't specify the Android version + // - possibly devide in os, device and browser hashes + + if (browser.webkit = !!webkit) browser.version = webkit[1]; + + if (android) os.android = true, os.version = android[2]; + if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.'); + if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.'); + if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null; + if (webos) os.webos = true, os.version = webos[2]; + if (touchpad) os.touchpad = true; + if (blackberry) os.blackberry = true, os.version = blackberry[2]; + if (bb10) os.bb10 = true, os.version = bb10[2]; + if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2]; + if (playbook) browser.playbook = true; + if (kindle) os.kindle = true, os.version = kindle[1]; + if (silk) browser.silk = true, browser.version = silk[1]; + if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true; + if (chrome) browser.chrome = true, browser.version = chrome[1]; + if (firefox) browser.firefox = true, browser.version = firefox[1]; + if (ie) browser.ie = true, browser.version = ie[1]; + if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true; + if (webview) browser.webview = true; + if (ie) browser.ie = true, browser.version = ie[1]; + if (edge) browser.edge = true, browser.version = edge[1]; + + os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) || + (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/))); + 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/)))); + + return { + browser: browser, + os: os, + node: false, + // 原生canvas支持,改极端点了 + // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9) + canvasSupported : document.createElement('canvas').getContext ? true : false, + // @see + // works on most browsers + // IE10/11 does not support touch event, and MS Edge supports them but not by + // default, so we dont check navigator.maxTouchPoints for them here. + touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge, + // . + pointerEventsSupported: 'onpointerdown' in window + // Firefox supports pointer but not by default, + // only MS browsers are reliable on pointer events currently. + && (browser.edge || (browser.ie && browser.version >= 10)) + }; + } + + +/***/ }, +/* 79 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Handler控制模块 + * @module zrender/Handler + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + * errorrik (errorrik@gmail.com) + * pissang (shenyi.914@gmail.com) + */ + + + var env = __webpack_require__(78); + var eventTool = __webpack_require__(80); + var util = __webpack_require__(3); + var Draggable = __webpack_require__(81); + var GestureMgr = __webpack_require__(82); + + var Eventful = __webpack_require__(32); + + var mouseHandlerNames = [ + 'click', 'dblclick', 'mousewheel', 'mouseout' + ]; + !usePointerEvent() && mouseHandlerNames.push( + 'mouseup', 'mousedown', 'mousemove' + ); + + var touchHandlerNames = [ + 'touchstart', 'touchend', 'touchmove' + ]; + + var pointerHandlerNames = [ + 'pointerdown', 'pointerup', 'pointermove' + ]; + + var TOUCH_CLICK_DELAY = 300; + + // touch指尖错觉的尝试偏移量配置 + // var MOBILE_TOUCH_OFFSETS = [ + // { x: 10 }, + // { x: -20 }, + // { x: 10, y: 10 }, + // { y: -20 } + // ]; + + var addEventListener = eventTool.addEventListener; + var removeEventListener = eventTool.removeEventListener; + var normalizeEvent = eventTool.normalizeEvent; + + function makeEventPacket(eveType, target, event) { + return { + type: eveType, + event: event, + target: target, + cancelBubble: false, + offsetX: event.zrX, + offsetY: event.zrY, + gestureEvent: event.gestureEvent, + pinchX: event.pinchX, + pinchY: event.pinchY, + pinchScale: event.pinchScale, + wheelDelta: event.zrDelta + }; + } + + var domHandlers = { + /** + * Mouse move handler + * @inner + * @param {Event} event + */ + mousemove: function (event) { + event = normalizeEvent(this.root, event); + + var x = event.zrX; + var y = event.zrY; + + var hovered = this.findHover(x, y, null); + var lastHovered = this._hovered; + + this._hovered = hovered; + + this.root.style.cursor = hovered ? hovered.cursor : this._defaultCursorStyle; + // Mouse out on previous hovered element + if (lastHovered && hovered !== lastHovered && lastHovered.__zr) { + this._dispatchProxy(lastHovered, 'mouseout', event); + } + + // Mouse moving on one element + this._dispatchProxy(hovered, 'mousemove', event); + + // Mouse over on a new element + if (hovered && hovered !== lastHovered) { + this._dispatchProxy(hovered, 'mouseover', event); + } + }, + + /** + * Mouse out handler + * @inner + * @param {Event} event + */ + mouseout: function (event) { + event = normalizeEvent(this.root, event); + + var element = event.toElement || event.relatedTarget; + if (element != this.root) { + while (element && element.nodeType != 9) { + // 忽略包含在root中的dom引起的mouseOut + if (element === this.root) { + return; + } + + element = element.parentNode; + } + } + + this._dispatchProxy(this._hovered, 'mouseout', event); + + this.trigger('globalout', { + event: event + }); + }, + + /** + * Touch开始响应函数 + * @inner + * @param {Event} event + */ + touchstart: function (event) { + // FIXME + // 移动端可能需要default行为,例如静态图表时。 + // eventTool.stop(event);// 阻止浏览器默认事件,重要 + event = normalizeEvent(this.root, event); + + this._lastTouchMoment = new Date(); + + processGesture(this, event, 'start'); + + // 平板补充一次findHover + // this._mobileFindFixed(event); + // Trigger mousemove and mousedown + domHandlers.mousemove.call(this, event); + + domHandlers.mousedown.call(this, event); + + setTouchTimer(this); + }, + + /** + * Touch移动响应函数 + * @inner + * @param {Event} event + */ + touchmove: function (event) { + // eventTool.stop(event);// 阻止浏览器默认事件,重要 + event = normalizeEvent(this.root, event); + + processGesture(this, event, 'change'); + + // Mouse move should always be triggered no matter whether + // there is gestrue event, because mouse move and pinch may + // be used at the same time. + domHandlers.mousemove.call(this, event); + + setTouchTimer(this); + }, + + /** + * Touch结束响应函数 + * @inner + * @param {Event} event + */ + touchend: function (event) { + // eventTool.stop(event);// 阻止浏览器默认事件,重要 + event = normalizeEvent(this.root, event); + + processGesture(this, event, 'end'); + + domHandlers.mouseup.call(this, event); + + // click event should always be triggered no matter whether + // there is gestrue event. System click can not be prevented. + if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) { + // this._mobileFindFixed(event); + domHandlers.click.call(this, event); + } + + setTouchTimer(this); + } + }; + + // Common handlers + util.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick'], function (name) { + domHandlers[name] = function (event) { + event = normalizeEvent(this.root, event); + // Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover + var hovered = this.findHover(event.zrX, event.zrY, null); + this._dispatchProxy(hovered, name, event); + }; + }); + + // Pointer event handlers + // util.each(['pointerdown', 'pointermove', 'pointerup'], function (name) { + // domHandlers[name] = function (event) { + // var mouseName = name.replace('pointer', 'mouse'); + // domHandlers[mouseName].call(this, event); + // }; + // }); + + function processGesture(zrHandler, event, stage) { + var gestureMgr = zrHandler._gestureMgr; + + stage === 'start' && gestureMgr.clear(); + + var gestureInfo = gestureMgr.recognize( + event, + zrHandler.findHover(event.zrX, event.zrY, null) + ); + + stage === 'end' && gestureMgr.clear(); + + if (gestureInfo) { + // eventTool.stop(event); + var type = gestureInfo.type; + event.gestureEvent = type; + + zrHandler._dispatchProxy(gestureInfo.target, type, gestureInfo.event); + } + } + + /** + * 为控制类实例初始化dom 事件处理函数 + * + * @inner + * @param {module:zrender/Handler} instance 控制类实例 + */ + function initDomHandler(instance) { + var handlerNames = touchHandlerNames.concat(pointerHandlerNames); + for (var i = 0; i < handlerNames.length; i++) { + var name = handlerNames[i]; + instance._handlers[name] = util.bind(domHandlers[name], instance); + } + + for (var i = 0; i < mouseHandlerNames.length; i++) { + var name = mouseHandlerNames[i]; + instance._handlers[name] = makeMouseHandler(domHandlers[name], instance); + } + + function makeMouseHandler(fn, instance) { + return function () { + if (instance._touching) { + return; + } + return fn.apply(instance, arguments); + }; + } + } + + /** + * @alias module:zrender/Handler + * @constructor + * @extends module:zrender/mixin/Eventful + * @param {HTMLElement} root Main HTML element for painting. + * @param {module:zrender/Storage} storage Storage instance. + * @param {module:zrender/Painter} painter Painter instance. + */ + var Handler = function(root, storage, painter) { + Eventful.call(this); + + this.root = root; + this.storage = storage; + this.painter = painter; + + /** + * @private + * @type {boolean} + */ + this._hovered; + + /** + * @private + * @type {Date} + */ + this._lastTouchMoment; + + /** + * @private + * @type {number} + */ + this._lastX; + + /** + * @private + * @type {number} + */ + this._lastY; + + /** + * @private + * @type {string} + */ + this._defaultCursorStyle = 'default'; + + /** + * @private + * @type {module:zrender/core/GestureMgr} + */ + this._gestureMgr = new GestureMgr(); + + /** + * @private + * @type {Array.} + */ + this._handlers = []; + + /** + * @private + * @type {boolean} + */ + this._touching = false; + + /** + * @private + * @type {number} + */ + this._touchTimer; + + initDomHandler(this); + + if (usePointerEvent()) { + mountHandlers(pointerHandlerNames, this); + } + else if (useTouchEvent()) { + mountHandlers(touchHandlerNames, this); + + // Handler of 'mouseout' event is needed in touch mode, which will be mounted below. + // addEventListener(root, 'mouseout', this._mouseoutHandler); + } + + // Considering some devices that both enable touch and mouse event (like MS Surface + // and lenovo X240, @see #2350), we make mouse event be always listened, otherwise + // mouse event can not be handle in those devices. + mountHandlers(mouseHandlerNames, this); + + Draggable.call(this); + + function mountHandlers(handlerNames, instance) { + util.each(handlerNames, function (name) { + addEventListener(root, eventNameFix(name), instance._handlers[name]); + }, instance); + } + }; + + Handler.prototype = { + + constructor: Handler, + + /** + * Resize + */ + resize: function (event) { + this._hovered = null; + }, + + /** + * Dispatch event + * @param {string} eventName + * @param {event=} eventArgs + */ + dispatch: function (eventName, eventArgs) { + var handler = this._handlers[eventName]; + handler && handler.call(this, eventArgs); + }, + + /** + * Dispose + */ + dispose: function () { + var root = this.root; + + var handlerNames = mouseHandlerNames.concat(touchHandlerNames); + + for (var i = 0; i < handlerNames.length; i++) { + var name = handlerNames[i]; + removeEventListener(root, eventNameFix(name), this._handlers[name]); + } + + this.root = + this.storage = + this.painter = null; + }, + + /** + * 设置默认的cursor style + * @param {string} cursorStyle 例如 crosshair + */ + setDefaultCursorStyle: function (cursorStyle) { + this._defaultCursorStyle = cursorStyle; + }, + + /** + * 事件分发代理 + * + * @private + * @param {Object} targetEl 目标图形元素 + * @param {string} eventName 事件名称 + * @param {Object} event 事件对象 + */ + _dispatchProxy: function (targetEl, eventName, event) { + var eventHandler = 'on' + eventName; + var eventPacket = makeEventPacket(eventName, targetEl, event); + + var el = targetEl; + + while (el) { + el[eventHandler] + && (eventPacket.cancelBubble = el[eventHandler].call(el, eventPacket)); + + el.trigger(eventName, eventPacket); + + el = el.parent; + + if (eventPacket.cancelBubble) { + break; + } + } + + if (!eventPacket.cancelBubble) { + // 冒泡到顶级 zrender 对象 + this.trigger(eventName, eventPacket); + // 分发事件到用户自定义层 + // 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在 + this.painter && this.painter.eachOtherLayer(function (layer) { + if (typeof(layer[eventHandler]) == 'function') { + layer[eventHandler].call(layer, eventPacket); + } + if (layer.trigger) { + layer.trigger(eventName, eventPacket); + } + }); + } + }, + + /** + * @private + * @param {number} x + * @param {number} y + * @param {module:zrender/graphic/Displayable} exclude + * @method + */ + findHover: function(x, y, exclude) { + var list = this.storage.getDisplayList(); + for (var i = list.length - 1; i >= 0 ; i--) { + if (!list[i].silent + && list[i] !== exclude + // getDisplayList may include ignored item in VML mode + && !list[i].ignore + && isHover(list[i], x, y)) { + return list[i]; + } + } + } + }; + + function isHover(displayable, x, y) { + if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) { + var p = displayable.parent; + while (p) { + if (p.clipPath && !p.clipPath.contain(x, y)) { + // Clipped by parents + return false; + } + p = p.parent; + } + return true; + } + + return false; + } + + /** + * Prevent mouse event from being dispatched after Touch Events action + * @see + * 1. Mobile browsers dispatch mouse events 300ms after touchend. + * 2. Chrome for Android dispatch mousedown for long-touch about 650ms + * Result: Blocking Mouse Events for 700ms. + */ + function setTouchTimer(instance) { + instance._touching = true; + clearTimeout(instance._touchTimer); + instance._touchTimer = setTimeout(function () { + instance._touching = false; + }, 700); + } + + /** + * Althought MS Surface support screen touch, IE10/11 do not support + * touch event and MS Edge supported them but not by default (but chrome + * and firefox do). Thus we use Pointer event on MS browsers to handle touch. + */ + function usePointerEvent() { + // TODO + // pointermove event dont trigger when using finger. + // We may figger it out latter. + return false; + // return env.pointerEventsSupported + // In no-touch device we dont use pointer evnets but just + // use mouse event for avoiding problems. + // && window.navigator.maxTouchPoints; + } + + function useTouchEvent() { + return env.touchEventsSupported; + } + + function eventNameFix(name) { + return (name === 'mousewheel' && env.browser.firefox) ? 'DOMMouseScroll' : name; + } + + util.mixin(Handler, Eventful); + util.mixin(Handler, Draggable); + + module.exports = Handler; + + +/***/ }, +/* 80 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 事件辅助类 + * @module zrender/core/event + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + */ + + + var Eventful = __webpack_require__(32); + + var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener; + + function getBoundingClientRect(el) { + // BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect + return el.getBoundingClientRect ? el.getBoundingClientRect() : { left: 0, top: 0}; + } + /** + * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标 + */ + function normalizeEvent(el, e) { + + e = e || window.event; + + if (e.zrX != null) { + return e; + } + + var eventType = e.type; + var isTouch = eventType && eventType.indexOf('touch') >= 0; + + if (!isTouch) { + var box = getBoundingClientRect(el); + e.zrX = e.clientX - box.left; + e.zrY = e.clientY - box.top; + e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3; + } + else { + var touch = eventType != 'touchend' + ? e.targetTouches[0] + : e.changedTouches[0]; + if (touch) { + var rBounding = getBoundingClientRect(el); + // touch事件坐标是全屏的~ + e.zrX = touch.clientX - rBounding.left; + e.zrY = touch.clientY - rBounding.top; + } + } + + return e; + } + + function addEventListener(el, name, handler) { + if (isDomLevel2) { + el.addEventListener(name, handler); + } + else { + el.attachEvent('on' + name, handler); + } + } + + function removeEventListener(el, name, handler) { + if (isDomLevel2) { + el.removeEventListener(name, handler); + } + else { + el.detachEvent('on' + name, handler); + } + } + + /** + * 停止冒泡和阻止默认行为 + * @memberOf module:zrender/core/event + * @method + * @param {Event} e : event对象 + */ + var stop = isDomLevel2 + ? function (e) { + e.preventDefault(); + e.stopPropagation(); + e.cancelBubble = true; + } + : function (e) { + e.returnValue = false; + e.cancelBubble = true; + }; + + module.exports = { + normalizeEvent: normalizeEvent, + addEventListener: addEventListener, + removeEventListener: removeEventListener, + + stop: stop, + // 做向上兼容 + Dispatcher: Eventful + }; + + + +/***/ }, +/* 81 */ +/***/ function(module, exports) { + + // TODO Draggable for group + // FIXME Draggable on element which has parent rotation or scale + + function Draggable() { + + this.on('mousedown', this._dragStart, this); + this.on('mousemove', this._drag, this); + this.on('mouseup', this._dragEnd, this); + this.on('globalout', this._dragEnd, this); + // this._dropTarget = null; + // this._draggingTarget = null; + + // this._x = 0; + // this._y = 0; + } + + Draggable.prototype = { + + constructor: Draggable, + + _dragStart: function (e) { + var draggingTarget = e.target; + if (draggingTarget && draggingTarget.draggable) { + this._draggingTarget = draggingTarget; + draggingTarget.dragging = true; + this._x = e.offsetX; + this._y = e.offsetY; + + this._dispatchProxy(draggingTarget, 'dragstart', e.event); + } + }, + + _drag: function (e) { + var draggingTarget = this._draggingTarget; + if (draggingTarget) { + + var x = e.offsetX; + var y = e.offsetY; + + var dx = x - this._x; + var dy = y - this._y; + this._x = x; + this._y = y; + + draggingTarget.drift(dx, dy, e); + this._dispatchProxy(draggingTarget, 'drag', e.event); + + var dropTarget = this.findHover(x, y, draggingTarget); + var lastDropTarget = this._dropTarget; + this._dropTarget = dropTarget; + + if (draggingTarget !== dropTarget) { + if (lastDropTarget && dropTarget !== lastDropTarget) { + this._dispatchProxy(lastDropTarget, 'dragleave', e.event); + } + if (dropTarget && dropTarget !== lastDropTarget) { + this._dispatchProxy(dropTarget, 'dragenter', e.event); + } + } + } + }, + + _dragEnd: function (e) { + var draggingTarget = this._draggingTarget; + + if (draggingTarget) { + draggingTarget.dragging = false; + } + + this._dispatchProxy(draggingTarget, 'dragend', e.event); + + if (this._dropTarget) { + this._dispatchProxy(this._dropTarget, 'drop', e.event); + } + + this._draggingTarget = null; + this._dropTarget = null; + } - var colorStops = this.colorStops; - for (var i = 0; i < colorStops.length; i++) { - canvasGradient.addColorStop( - colorStops[i].offset, colorStops[i].color - ); - } + }; - this.canvasGradient = canvasGradient; - } + module.exports = Draggable; - }; - zrUtil.inherits(LinearGradient, Gradient); +/***/ }, +/* 82 */ +/***/ function(module, exports) { - return LinearGradient; -}); -define('zrender/graphic/RadialGradient',['require','../core/util','./Gradient'],function(require) { - + 'use strict'; + /** + * Only implements needed gestures for mobile. + */ - var zrUtil = require('../core/util'); - var Gradient = require('./Gradient'); + var GestureMgr = function () { + + /** + * @private + * @type {Array.} + */ + this._track = []; + }; + + GestureMgr.prototype = { + + constructor: GestureMgr, - /** - * x, y, r are all percent from 0 to 1 - * @param {number} [x=0.5] - * @param {number} [y=0.5] - * @param {number} [r=0.5] - * @param {Array.} [colorStops] - */ - var RadialGradient = function (x, y, r, colorStops) { - this.x = x == null ? 0.5 : x; + recognize: function (event, target) { + this._doTrack(event, target); + return this._recognize(event); + }, - this.y = y == null ? 0.5 : y; + clear: function () { + this._track.length = 0; + return this; + }, + + _doTrack: function (event, target) { + var touches = event.touches; + + if (!touches) { + return; + } - this.r = r == null ? 0.5 : r; + var trackItem = { + points: [], + touches: [], + target: target, + event: event + }; - Gradient.call(this, colorStops); - }; + for (var i = 0, len = touches.length; i < len; i++) { + var touch = touches[i]; + trackItem.points.push([touch.clientX, touch.clientY]); + trackItem.touches.push(touch); + } + + this._track.push(trackItem); + }, + + _recognize: function (event) { + for (var eventName in recognizers) { + if (recognizers.hasOwnProperty(eventName)) { + var gestureInfo = recognizers[eventName](this._track, event); + if (gestureInfo) { + return gestureInfo; + } + } + } + } + }; + + function dist(pointPair) { + var dx = pointPair[1][0] - pointPair[0][0]; + var dy = pointPair[1][1] - pointPair[0][1]; + + return Math.sqrt(dx * dx + dy * dy); + } - RadialGradient.prototype = { + function center(pointPair) { + return [ + (pointPair[0][0] + pointPair[1][0]) / 2, + (pointPair[0][1] + pointPair[1][1]) / 2 + ]; + } + + var recognizers = { + + pinch: function (track, event) { + var trackLen = track.length; + + if (!trackLen) { + return; + } + + var pinchEnd = (track[trackLen - 1] || {}).points; + var pinchPre = (track[trackLen - 2] || {}).points || pinchEnd; + + if (pinchPre + && pinchPre.length > 1 + && pinchEnd + && pinchEnd.length > 1 + ) { + var pinchScale = dist(pinchEnd) / dist(pinchPre); + !isFinite(pinchScale) && (pinchScale = 1); + + event.pinchScale = pinchScale; + + var pinchCenter = center(pinchEnd); + event.pinchX = pinchCenter[0]; + event.pinchY = pinchCenter[1]; + + return { + type: 'pinch', + target: track[0].target, + event: event + }; + } + } + + // Only pinch currently. + }; + + module.exports = GestureMgr; + + + +/***/ }, +/* 83 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Storage内容仓库模块 + * @module zrender/Storage + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + * @author errorrik (errorrik@gmail.com) + * @author pissang (https://github.com/pissang/) + */ + + + var util = __webpack_require__(3); + + var Group = __webpack_require__(29); + + function shapeCompareFunc(a, b) { + if (a.zlevel === b.zlevel) { + if (a.z === b.z) { + if (a.z2 === b.z2) { + return a.__renderidx - b.__renderidx; + } + return a.z2 - b.z2; + } + return a.z - b.z; + } + return a.zlevel - b.zlevel; + } + /** + * 内容仓库 (M) + * @alias module:zrender/Storage + * @constructor + */ + var Storage = function () { + // 所有常规形状,id索引的map + this._elements = {}; + + this._roots = []; + + this._displayList = []; + + this._displayListLen = 0; + }; + + Storage.prototype = { + + constructor: Storage, + + /** + * 返回所有图形的绘制队列 + * @param {boolean} [update=false] 是否在返回前更新该数组 + * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组, 在 update 为 true 的时候有效 + * + * 详见{@link module:zrender/graphic/Displayable.prototype.updateDisplayList} + * @return {Array.} + */ + getDisplayList: function (update, includeIgnore) { + includeIgnore = includeIgnore || false; + if (update) { + this.updateDisplayList(includeIgnore); + } + return this._displayList; + }, + + /** + * 更新图形的绘制队列。 + * 每次绘制前都会调用,该方法会先深度优先遍历整个树,更新所有Group和Shape的变换并且把所有可见的Shape保存到数组中, + * 最后根据绘制的优先级(zlevel > z > 插入顺序)排序得到绘制队列 + * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组 + */ + updateDisplayList: function (includeIgnore) { + this._displayListLen = 0; + var roots = this._roots; + var displayList = this._displayList; + for (var i = 0, len = roots.length; i < len; i++) { + this._updateAndAddDisplayable(roots[i], null, includeIgnore); + } + displayList.length = this._displayListLen; + + for (var i = 0, len = displayList.length; i < len; i++) { + displayList[i].__renderidx = i; + } + + displayList.sort(shapeCompareFunc); + }, + + _updateAndAddDisplayable: function (el, clipPaths, includeIgnore) { + + if (el.ignore && !includeIgnore) { + return; + } + + el.beforeUpdate(); + + el.update(); + + el.afterUpdate(); + + var clipPath = el.clipPath; + if (clipPath) { + // clipPath 的变换是基于 group 的变换 + clipPath.parent = el; + clipPath.updateTransform(); + + // FIXME 效率影响 + if (clipPaths) { + clipPaths = clipPaths.slice(); + clipPaths.push(clipPath); + } + else { + clipPaths = [clipPath]; + } + } + + if (el.type == 'group') { + var children = el._children; + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + + // Force to mark as dirty if group is dirty + // FIXME __dirtyPath ? + child.__dirty = el.__dirty || child.__dirty; + + this._updateAndAddDisplayable(child, clipPaths, includeIgnore); + } + + // Mark group clean here + el.__dirty = false; + + } + else { + el.__clipPaths = clipPaths; + + this._displayList[this._displayListLen++] = el; + } + }, + + /** + * 添加图形(Shape)或者组(Group)到根节点 + * @param {module:zrender/Element} el + */ + addRoot: function (el) { + // Element has been added + if (this._elements[el.id]) { + return; + } + + if (el instanceof Group) { + el.addChildrenToStorage(this); + } + + this.addToMap(el); + this._roots.push(el); + }, + + /** + * 删除指定的图形(Shape)或者组(Group) + * @param {string|Array.} [elId] 如果为空清空整个Storage + */ + delRoot: function (elId) { + if (elId == null) { + // 不指定elId清空 + for (var i = 0; i < this._roots.length; i++) { + var root = this._roots[i]; + if (root instanceof Group) { + root.delChildrenFromStorage(this); + } + } + + this._elements = {}; + this._roots = []; + this._displayList = []; + this._displayListLen = 0; + + return; + } + + if (elId instanceof Array) { + for (var i = 0, l = elId.length; i < l; i++) { + this.delRoot(elId[i]); + } + return; + } + + var el; + if (typeof(elId) == 'string') { + el = this._elements[elId]; + } + else { + el = elId; + } + + var idx = util.indexOf(this._roots, el); + if (idx >= 0) { + this.delFromMap(el.id); + this._roots.splice(idx, 1); + if (el instanceof Group) { + el.delChildrenFromStorage(this); + } + } + }, + + addToMap: function (el) { + if (el instanceof Group) { + el.__storage = this; + } + el.dirty(); + + this._elements[el.id] = el; + + return this; + }, + + get: function (elId) { + return this._elements[elId]; + }, + + delFromMap: function (elId) { + var elements = this._elements; + var el = elements[elId]; + if (el) { + delete elements[elId]; + if (el instanceof Group) { + el.__storage = null; + } + } + + return this; + }, + + /** + * 清空并且释放Storage + */ + dispose: function () { + this._elements = + this._renderList = + this._roots = null; + } + }; + + module.exports = Storage; + + + +/***/ }, +/* 84 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 动画主类, 调度和管理所有动画控制器 + * + * @module zrender/animation/Animation + * @author pissang(https://github.com/pissang) + */ + // TODO Additive animation + // http://iosoteric.com/additive-animations-animatewithduration-in-ios-8/ + // https://developer.apple.com/videos/wwdc2014/#236 + + + var util = __webpack_require__(3); + var Dispatcher = __webpack_require__(80).Dispatcher; + + var requestAnimationFrame = (typeof window !== 'undefined' && + (window.requestAnimationFrame + || window.msRequestAnimationFrame + || window.mozRequestAnimationFrame + || window.webkitRequestAnimationFrame)) + || function (func) { + setTimeout(func, 16); + }; + + var Animator = __webpack_require__(35); + /** + * @typedef {Object} IZRenderStage + * @property {Function} update + */ + + /** + * @alias module:zrender/animation/Animation + * @constructor + * @param {Object} [options] + * @param {Function} [options.onframe] + * @param {IZRenderStage} [options.stage] + * @example + * var animation = new Animation(); + * var obj = { + * x: 100, + * y: 100 + * }; + * animation.animate(node.position) + * .when(1000, { + * x: 500, + * y: 500 + * }) + * .when(2000, { + * x: 100, + * y: 100 + * }) + * .start('spline'); + */ + var Animation = function (options) { + + options = options || {}; + + this.stage = options.stage || {}; + + this.onframe = options.onframe || function() {}; + + // private properties + this._clips = []; + + this._running = false; + + this._time = 0; + + Dispatcher.call(this); + }; + + Animation.prototype = { + + constructor: Animation, + /** + * 添加 clip + * @param {module:zrender/animation/Clip} clip + */ + addClip: function (clip) { + this._clips.push(clip); + }, + /** + * 添加 animator + * @param {module:zrender/animation/Animator} animator + */ + addAnimator: function (animator) { + animator.animation = this; + var clips = animator.getClips(); + for (var i = 0; i < clips.length; i++) { + this.addClip(clips[i]); + } + }, + /** + * 删除动画片段 + * @param {module:zrender/animation/Clip} clip + */ + removeClip: function(clip) { + var idx = util.indexOf(this._clips, clip); + if (idx >= 0) { + this._clips.splice(idx, 1); + } + }, + + /** + * 删除动画片段 + * @param {module:zrender/animation/Animator} animator + */ + removeAnimator: function (animator) { + var clips = animator.getClips(); + for (var i = 0; i < clips.length; i++) { + this.removeClip(clips[i]); + } + animator.animation = null; + }, + + _update: function() { + + var time = new Date().getTime(); + var delta = time - this._time; + var clips = this._clips; + var len = clips.length; + + var deferredEvents = []; + var deferredClips = []; + for (var i = 0; i < len; i++) { + var clip = clips[i]; + var e = clip.step(time); + // Throw out the events need to be called after + // stage.update, like destroy + if (e) { + deferredEvents.push(e); + deferredClips.push(clip); + } + } + + // Remove the finished clip + for (var i = 0; i < len;) { + if (clips[i]._needsRemove) { + clips[i] = clips[len - 1]; + clips.pop(); + len--; + } + else { + i++; + } + } + + len = deferredEvents.length; + for (var i = 0; i < len; i++) { + deferredClips[i].fire(deferredEvents[i]); + } + + this._time = time; + + this.onframe(delta); + + this.trigger('frame', delta); + + if (this.stage.update) { + this.stage.update(); + } + }, + /** + * 开始运行动画 + */ + start: function () { + var self = this; + + this._running = true; + + function step() { + if (self._running) { + + requestAnimationFrame(step); + + self._update(); + } + } + + this._time = new Date().getTime(); + requestAnimationFrame(step); + }, + /** + * 停止运行动画 + */ + stop: function () { + this._running = false; + }, + /** + * 清除所有动画片段 + */ + clear: function () { + this._clips = []; + }, + /** + * 对一个目标创建一个animator对象,可以指定目标中的属性使用动画 + * @param {Object} target + * @param {Object} options + * @param {boolean} [options.loop=false] 是否循环播放动画 + * @param {Function} [options.getter=null] + * 如果指定getter函数,会通过getter函数取属性值 + * @param {Function} [options.setter=null] + * 如果指定setter函数,会通过setter函数设置属性值 + * @return {module:zrender/animation/Animation~Animator} + */ + animate: function (target, options) { + options = options || {}; + var animator = new Animator( + target, + options.loop, + options.getter, + options.setter + ); + + return animator; + } + }; + + util.mixin(Animation, Dispatcher); + + module.exports = Animation; + + + +/***/ }, +/* 85 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Default canvas painter + * @module zrender/Painter + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + * errorrik (errorrik@gmail.com) + * pissang (https://www.github.com/pissang) + */ + + + var config = __webpack_require__(40); + var util = __webpack_require__(3); + var log = __webpack_require__(39); + var BoundingRect = __webpack_require__(15); + + var Layer = __webpack_require__(86); + + function parseInt10(val) { + return parseInt(val, 10); + } + + function isLayerValid(layer) { + if (!layer) { + return false; + } + + if (layer.isBuildin) { + return true; + } + + if (typeof(layer.resize) !== 'function' + || typeof(layer.refresh) !== 'function' + ) { + return false; + } + + return true; + } + + function preProcessLayer(layer) { + layer.__unusedCount++; + } + + function postProcessLayer(layer) { + layer.__dirty = false; + if (layer.__unusedCount == 1) { + layer.clear(); + } + } + + var tmpRect = new BoundingRect(0, 0, 0, 0); + var viewRect = new BoundingRect(0, 0, 0, 0); + function isDisplayableCulled(el, width, height) { + tmpRect.copy(el.getBoundingRect()); + if (el.transform) { + tmpRect.applyTransform(el.transform); + } + viewRect.width = width; + viewRect.height = height; + return !tmpRect.intersect(viewRect); + } + + function isClipPathChanged(clipPaths, prevClipPaths) { + if (!clipPaths || !prevClipPaths || (clipPaths.length !== prevClipPaths.length)) { + return true; + } + for (var i = 0; i < clipPaths.length; i++) { + if (clipPaths[i] !== prevClipPaths[i]) { + return true; + } + } + } + + function doClip(clipPaths, ctx) { + for (var i = 0; i < clipPaths.length; i++) { + var clipPath = clipPaths[i]; + var m; + if (clipPath.transform) { + m = clipPath.transform; + ctx.transform( + m[0], m[1], + m[2], m[3], + m[4], m[5] + ); + } + var path = clipPath.path; + path.beginPath(ctx); + clipPath.buildPath(path, clipPath.shape); + ctx.clip(); + // Transform back + if (clipPath.transform) { + m = clipPath.invTransform; + ctx.transform( + m[0], m[1], + m[2], m[3], + m[4], m[5] + ); + } + } + } + + /** + * @alias module:zrender/Painter + * @constructor + * @param {HTMLElement} root 绘图容器 + * @param {module:zrender/Storage} storage + * @param {Ojbect} opts + */ + var Painter = function (root, storage, opts) { + var singleCanvas = !root.nodeName // In node ? + || root.nodeName.toUpperCase() === 'CANVAS'; + + opts = opts || {}; + + /** + * @type {number} + */ + this.dpr = opts.devicePixelRatio || config.devicePixelRatio; + /** + * @type {boolean} + * @private + */ + this._singleCanvas = singleCanvas; + /** + * 绘图容器 + * @type {HTMLElement} + */ + this.root = root; + + var rootStyle = root.style; + + // In node environment using node-canvas + if (rootStyle) { + rootStyle['-webkit-tap-highlight-color'] = 'transparent'; + rootStyle['-webkit-user-select'] = 'none'; + rootStyle['user-select'] = 'none'; + rootStyle['-webkit-touch-callout'] = 'none'; + + root.innerHTML = ''; + } + + /** + * @type {module:zrender/Storage} + */ + this.storage = storage; + + if (!singleCanvas) { + var width = this._getWidth(); + var height = this._getHeight(); + this._width = width; + this._height = height; + + var domRoot = document.createElement('div'); + this._domRoot = domRoot; + var domRootStyle = domRoot.style; + + // domRoot.onselectstart = returnFalse; // 避免页面选中的尴尬 + domRootStyle.position = 'relative'; + domRootStyle.overflow = 'hidden'; + domRootStyle.width = this._width + 'px'; + domRootStyle.height = this._height + 'px'; + root.appendChild(domRoot); + + /** + * @type {Object.} + * @private + */ + this._layers = {}; + /** + * @type {Array.} + * @private + */ + this._zlevelList = []; + } + else { + // Use canvas width and height directly + var width = root.width; + var height = root.height; + this._width = width; + this._height = height; + + // Create layer if only one given canvas + // Device pixel ratio is fixed to 1 because given canvas has its specified width and height + var mainLayer = new Layer(root, this, 1); + mainLayer.initContext(); + // FIXME Use canvas width and height + // mainLayer.resize(width, height); + this._layers = { + 0: mainLayer + }; + this._zlevelList = [0]; + } + + this._layerConfig = {}; + + this.pathToImage = this._createPathToImage(); + }; + + Painter.prototype = { + + constructor: Painter, + + /** + * If painter use a single canvas + * @return {boolean} + */ + isSingleCanvas: function () { + return this._singleCanvas; + }, + /** + * @return {HTMLDivElement} + */ + getViewportRoot: function () { + return this._singleCanvas ? this._layers[0].dom : this._domRoot; + }, + + /** + * 刷新 + * @param {boolean} [paintAll=false] 强制绘制所有displayable + */ + refresh: function (paintAll) { + var list = this.storage.getDisplayList(true); + var zlevelList = this._zlevelList; + + this._paintList(list, paintAll); + + // Paint custum layers + for (var i = 0; i < zlevelList.length; i++) { + var z = zlevelList[i]; + var layer = this._layers[z]; + if (!layer.isBuildin && layer.refresh) { + layer.refresh(); + } + } + + return this; + }, + + _paintList: function (list, paintAll) { + + if (paintAll == null) { + paintAll = false; + } + + this._updateLayerStatus(list); + + var currentLayer; + var currentZLevel; + var ctx; + + var viewWidth = this._width; + var viewHeight = this._height; + + this.eachBuildinLayer(preProcessLayer); + + // var invTransform = []; + var prevElClipPaths = null; + + for (var i = 0, l = list.length; i < l; i++) { + var el = list[i]; + var elZLevel = this._singleCanvas ? 0 : el.zlevel; + // Change draw layer + if (currentZLevel !== elZLevel) { + // Only 0 zlevel if only has one canvas + currentZLevel = elZLevel; + currentLayer = this.getLayer(currentZLevel); + + if (!currentLayer.isBuildin) { + log( + 'ZLevel ' + currentZLevel + + ' has been used by unkown layer ' + currentLayer.id + ); + } + + ctx = currentLayer.ctx; + + // Reset the count + currentLayer.__unusedCount = 0; + + if (currentLayer.__dirty || paintAll) { + currentLayer.clear(); + } + } + + if ( + (currentLayer.__dirty || paintAll) + // Ignore invisible element + && !el.invisible + // Ignore transparent element + && el.style.opacity !== 0 + // Ignore scale 0 element, in some environment like node-canvas + // Draw a scale 0 element can cause all following draw wrong + && el.scale[0] && el.scale[1] + // Ignore culled element + && !(el.culling && isDisplayableCulled(el, viewWidth, viewHeight)) + ) { + var clipPaths = el.__clipPaths; + + // Optimize when clipping on group with several elements + if (isClipPathChanged(clipPaths, prevElClipPaths)) { + // If has previous clipping state, restore from it + if (prevElClipPaths) { + ctx.restore(); + } + // New clipping state + if (clipPaths) { + ctx.save(); + doClip(clipPaths, ctx); + } + prevElClipPaths = clipPaths; + } + // TODO Use events ? + el.beforeBrush && el.beforeBrush(ctx); + el.brush(ctx, false); + el.afterBrush && el.afterBrush(ctx); + } + + el.__dirty = false; + } + + // If still has clipping state + if (prevElClipPaths) { + ctx.restore(); + } + + this.eachBuildinLayer(postProcessLayer); + }, + + /** + * 获取 zlevel 所在层,如果不存在则会创建一个新的层 + * @param {number} zlevel + * @return {module:zrender/Layer} + */ + getLayer: function (zlevel) { + if (this._singleCanvas) { + return this._layers[0]; + } + + var layer = this._layers[zlevel]; + if (!layer) { + // Create a new layer + layer = new Layer('zr_' + zlevel, this, this.dpr); + layer.isBuildin = true; + + if (this._layerConfig[zlevel]) { + util.merge(layer, this._layerConfig[zlevel], true); + } + + this.insertLayer(zlevel, layer); + + // Context is created after dom inserted to document + // Or excanvas will get 0px clientWidth and clientHeight + layer.initContext(); + } + + return layer; + }, + + insertLayer: function (zlevel, layer) { + + var layersMap = this._layers; + var zlevelList = this._zlevelList; + var len = zlevelList.length; + var prevLayer = null; + var i = -1; + var domRoot = this._domRoot; + + if (layersMap[zlevel]) { + log('ZLevel ' + zlevel + ' has been used already'); + return; + } + // Check if is a valid layer + if (!isLayerValid(layer)) { + log('Layer of zlevel ' + zlevel + ' is not valid'); + return; + } + + if (len > 0 && zlevel > zlevelList[0]) { + for (i = 0; i < len - 1; i++) { + if ( + zlevelList[i] < zlevel + && zlevelList[i + 1] > zlevel + ) { + break; + } + } + prevLayer = layersMap[zlevelList[i]]; + } + zlevelList.splice(i + 1, 0, zlevel); + + if (prevLayer) { + var prevDom = prevLayer.dom; + if (prevDom.nextSibling) { + domRoot.insertBefore( + layer.dom, + prevDom.nextSibling + ); + } + else { + domRoot.appendChild(layer.dom); + } + } + else { + if (domRoot.firstChild) { + domRoot.insertBefore(layer.dom, domRoot.firstChild); + } + else { + domRoot.appendChild(layer.dom); + } + } + + layersMap[zlevel] = layer; + }, + + // Iterate each layer + eachLayer: function (cb, context) { + var zlevelList = this._zlevelList; + var z; + var i; + for (i = 0; i < zlevelList.length; i++) { + z = zlevelList[i]; + cb.call(context, this._layers[z], z); + } + }, + + // Iterate each buildin layer + eachBuildinLayer: function (cb, context) { + var zlevelList = this._zlevelList; + var layer; + var z; + var i; + for (i = 0; i < zlevelList.length; i++) { + z = zlevelList[i]; + layer = this._layers[z]; + if (layer.isBuildin) { + cb.call(context, layer, z); + } + } + }, + + // Iterate each other layer except buildin layer + eachOtherLayer: function (cb, context) { + var zlevelList = this._zlevelList; + var layer; + var z; + var i; + for (i = 0; i < zlevelList.length; i++) { + z = zlevelList[i]; + layer = this._layers[z]; + if (! layer.isBuildin) { + cb.call(context, layer, z); + } + } + }, + + /** + * 获取所有已创建的层 + * @param {Array.} [prevLayer] + */ + getLayers: function () { + return this._layers; + }, + + _updateLayerStatus: function (list) { + + var layers = this._layers; + + var elCounts = {}; + + this.eachBuildinLayer(function (layer, z) { + elCounts[z] = layer.elCount; + layer.elCount = 0; + }); + + for (var i = 0, l = list.length; i < l; i++) { + var el = list[i]; + var zlevel = this._singleCanvas ? 0 : el.zlevel; + var layer = layers[zlevel]; + if (layer) { + layer.elCount++; + // 已经被标记为需要刷新 + if (layer.__dirty) { + continue; + } + layer.__dirty = el.__dirty; + } + } + + // 层中的元素数量有发生变化 + this.eachBuildinLayer(function (layer, z) { + if (elCounts[z] !== layer.elCount) { + layer.__dirty = true; + } + }); + }, + + /** + * 清除hover层外所有内容 + */ + clear: function () { + this.eachBuildinLayer(this._clearLayer); + return this; + }, + + _clearLayer: function (layer) { + layer.clear(); + }, + + /** + * 修改指定zlevel的绘制参数 + * + * @param {string} zlevel + * @param {Object} config 配置对象 + * @param {string} [config.clearColor=0] 每次清空画布的颜色 + * @param {string} [config.motionBlur=false] 是否开启动态模糊 + * @param {number} [config.lastFrameAlpha=0.7] + * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 + */ + configLayer: function (zlevel, config) { + if (config) { + var layerConfig = this._layerConfig; + if (!layerConfig[zlevel]) { + layerConfig[zlevel] = config; + } + else { + util.merge(layerConfig[zlevel], config, true); + } + + var layer = this._layers[zlevel]; + + if (layer) { + util.merge(layer, layerConfig[zlevel], true); + } + } + }, + + /** + * 删除指定层 + * @param {number} zlevel 层所在的zlevel + */ + delLayer: function (zlevel) { + var layers = this._layers; + var zlevelList = this._zlevelList; + var layer = layers[zlevel]; + if (!layer) { + return; + } + layer.dom.parentNode.removeChild(layer.dom); + delete layers[zlevel]; + + zlevelList.splice(util.indexOf(zlevelList, zlevel), 1); + }, + + /** + * 区域大小变化后重绘 + */ + resize: function (width, height) { + var domRoot = this._domRoot; + // FIXME Why ? + domRoot.style.display = 'none'; + + width = width || this._getWidth(); + height = height || this._getHeight(); + + domRoot.style.display = ''; + + // 优化没有实际改变的resize + if (this._width != width || height != this._height) { + domRoot.style.width = width + 'px'; + domRoot.style.height = height + 'px'; + + for (var id in this._layers) { + this._layers[id].resize(width, height); + } + + this.refresh(true); + } + + this._width = width; + this._height = height; + + return this; + }, + + /** + * 清除单独的一个层 + * @param {number} zlevel + */ + clearLayer: function (zlevel) { + var layer = this._layers[zlevel]; + if (layer) { + layer.clear(); + } + }, + + /** + * 释放 + */ + dispose: function () { + this.root.innerHTML = ''; + + this.root = + this.storage = + + this._domRoot = + this._layers = null; + }, + + /** + * Get canvas which has all thing rendered + * @param {Object} opts + * @param {string} [opts.backgroundColor] + */ + getRenderedCanvas: function (opts) { + opts = opts || {}; + if (this._singleCanvas) { + return this._layers[0].dom; + } + + var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr); + imageLayer.initContext(); + + var ctx = imageLayer.ctx; + imageLayer.clearColor = opts.backgroundColor; + imageLayer.clear(); + + var displayList = this.storage.getDisplayList(true); + + for (var i = 0; i < displayList.length; i++) { + var el = displayList[i]; + if (!el.invisible) { + el.beforeBrush && el.beforeBrush(ctx); + // TODO Check image cross origin + el.brush(ctx, false); + el.afterBrush && el.afterBrush(ctx); + } + } + + return imageLayer.dom; + }, + /** + * 获取绘图区域宽度 + */ + getWidth: function () { + return this._width; + }, + + /** + * 获取绘图区域高度 + */ + getHeight: function () { + return this._height; + }, + + _getWidth: function () { + var root = this.root; + var stl = document.defaultView.getComputedStyle(root); + + // FIXME Better way to get the width and height when element has not been append to the document + return ((root.clientWidth || parseInt10(stl.width) || parseInt10(root.style.width)) + - (parseInt10(stl.paddingLeft) || 0) + - (parseInt10(stl.paddingRight) || 0)) | 0; + }, + + _getHeight: function () { + var root = this.root; + var stl = document.defaultView.getComputedStyle(root); + + return ((root.clientHeight || parseInt10(stl.height) || parseInt10(root.style.height)) + - (parseInt10(stl.paddingTop) || 0) + - (parseInt10(stl.paddingBottom) || 0)) | 0; + }, + + _pathToImage: function (id, path, width, height, dpr) { + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + + canvas.width = width * dpr; + canvas.height = height * dpr; + + ctx.clearRect(0, 0, width * dpr, height * dpr); + + var pathTransform = { + position: path.position, + rotation: path.rotation, + scale: path.scale + }; + path.position = [0, 0, 0]; + path.rotation = 0; + path.scale = [1, 1]; + if (path) { + path.brush(ctx); + } + + var ImageShape = __webpack_require__(59); + var imgShape = new ImageShape({ + id: id, + style: { + x: 0, + y: 0, + image: canvas + } + }); + + if (pathTransform.position != null) { + imgShape.position = path.position = pathTransform.position; + } + + if (pathTransform.rotation != null) { + imgShape.rotation = path.rotation = pathTransform.rotation; + } + + if (pathTransform.scale != null) { + imgShape.scale = path.scale = pathTransform.scale; + } + + return imgShape; + }, + + _createPathToImage: function () { + var me = this; + + return function (id, e, width, height) { + return me._pathToImage( + id, e, width, height, me.dpr + ); + }; + } + }; + + module.exports = Painter; + + + +/***/ }, +/* 86 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module zrender/Layer + * @author pissang(https://www.github.com/pissang) + */ + + + var util = __webpack_require__(3); + var config = __webpack_require__(40); + + function returnFalse() { + return false; + } + + /** + * 创建dom + * + * @inner + * @param {string} id dom id 待用 + * @param {string} type dom type,such as canvas, div etc. + * @param {Painter} painter painter instance + * @param {number} number + */ + function createDom(id, type, painter, dpr) { + var newDom = document.createElement(type); + var width = painter.getWidth(); + var height = painter.getHeight(); + + var newDomStyle = newDom.style; + // 没append呢,请原谅我这样写,清晰~ + newDomStyle.position = 'absolute'; + newDomStyle.left = 0; + newDomStyle.top = 0; + newDomStyle.width = width + 'px'; + newDomStyle.height = height + 'px'; + newDom.width = width * dpr; + newDom.height = height * dpr; + + // id不作为索引用,避免可能造成的重名,定义为私有属性 + newDom.setAttribute('data-zr-dom-id', id); + return newDom; + } + + /** + * @alias module:zrender/Layer + * @constructor + * @extends module:zrender/mixin/Transformable + * @param {string} id + * @param {module:zrender/Painter} painter + * @param {number} [dpr] + */ + var Layer = function(id, painter, dpr) { + var dom; + dpr = dpr || config.devicePixelRatio; + if (typeof id === 'string') { + dom = createDom(id, 'canvas', painter, dpr); + } + // Not using isDom because in node it will return false + else if (util.isObject(id)) { + dom = id; + id = dom.id; + } + this.id = id; + this.dom = dom; + + var domStyle = dom.style; + if (domStyle) { // Not in node + dom.onselectstart = returnFalse; // 避免页面选中的尴尬 + domStyle['-webkit-user-select'] = 'none'; + domStyle['user-select'] = 'none'; + domStyle['-webkit-touch-callout'] = 'none'; + domStyle['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)'; + } + + this.domBack = null; + this.ctxBack = null; + + this.painter = painter; + + this.config = null; + + // Configs + /** + * 每次清空画布的颜色 + * @type {string} + * @default 0 + */ + this.clearColor = 0; + /** + * 是否开启动态模糊 + * @type {boolean} + * @default false + */ + this.motionBlur = false; + /** + * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 + * @type {number} + * @default 0.7 + */ + this.lastFrameAlpha = 0.7; + + /** + * Layer dpr + * @type {number} + */ + this.dpr = dpr; + }; + + Layer.prototype = { + + constructor: Layer, + + elCount: 0, + + __dirty: true, + + initContext: function () { + this.ctx = this.dom.getContext('2d'); + + var dpr = this.dpr; + if (dpr != 1) { + this.ctx.scale(dpr, dpr); + } + }, + + createBackBuffer: function () { + var dpr = this.dpr; + + this.domBack = createDom('back-' + this.id, 'canvas', this.painter, dpr); + this.ctxBack = this.domBack.getContext('2d'); + + if (dpr != 1) { + this.ctxBack.scale(dpr, dpr); + } + }, + + /** + * @param {number} width + * @param {number} height + */ + resize: function (width, height) { + var dpr = this.dpr; + + var dom = this.dom; + var domStyle = dom.style; + var domBack = this.domBack; + + domStyle.width = width + 'px'; + domStyle.height = height + 'px'; + + dom.width = width * dpr; + dom.height = height * dpr; + + if (dpr != 1) { + this.ctx.scale(dpr, dpr); + } + + if (domBack) { + domBack.width = width * dpr; + domBack.height = height * dpr; + + if (dpr != 1) { + this.ctxBack.scale(dpr, dpr); + } + } + }, + + /** + * 清空该层画布 + * @param {boolean} clearAll Clear all with out motion blur + */ + clear: function (clearAll) { + var dom = this.dom; + var ctx = this.ctx; + var width = dom.width; + var height = dom.height; + + var haveClearColor = this.clearColor; + var haveMotionBLur = this.motionBlur && !clearAll; + var lastFrameAlpha = this.lastFrameAlpha; + + var dpr = this.dpr; + + if (haveMotionBLur) { + if (!this.domBack) { + this.createBackBuffer(); + } + + this.ctxBack.globalCompositeOperation = 'copy'; + this.ctxBack.drawImage( + dom, 0, 0, + width / dpr, + height / dpr + ); + } + + ctx.clearRect(0, 0, width / dpr, height / dpr); + if (haveClearColor) { + ctx.save(); + ctx.fillStyle = this.clearColor; + ctx.fillRect(0, 0, width / dpr, height / dpr); + ctx.restore(); + } + + if (haveMotionBLur) { + var domBack = this.domBack; + ctx.save(); + ctx.globalAlpha = lastFrameAlpha; + ctx.drawImage(domBack, 0, 0, width / dpr, height / dpr); + ctx.restore(); + } + } + }; + + module.exports = Layer; + + +/***/ }, +/* 87 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + var PI = Math.PI; + /** + * @param {module:echarts/ExtensionAPI} api + * @param {Object} [opts] + * @param {string} [opts.text] + * @param {string} [opts.color] + * @param {string} [opts.textColor] + * @return {module:zrender/Element} + */ + module.exports = function (api, opts) { + opts = opts || {}; + zrUtil.defaults(opts, { + text: 'loading', + color: '#c23531', + textColor: '#000', + maskColor: 'rgba(255, 255, 255, 0.8)', + zlevel: 0 + }); + var mask = new graphic.Rect({ + style: { + fill: opts.maskColor + }, + zlevel: opts.zlevel, + z: 10000 + }); + var arc = new graphic.Arc({ + shape: { + startAngle: -PI / 2, + endAngle: -PI / 2 + 0.1, + r: 10 + }, + style: { + stroke: opts.color, + lineCap: 'round', + lineWidth: 5 + }, + zlevel: opts.zlevel, + z: 10001 + }); + var labelRect = new graphic.Rect({ + style: { + fill: 'none', + text: opts.text, + textPosition: 'right', + textDistance: 10, + textFill: opts.textColor + }, + zlevel: opts.zlevel, + z: 10001 + }); + + arc.animateShape(true) + .when(1000, { + endAngle: PI * 3 / 2 + }) + .start('circularInOut'); + arc.animateShape(true) + .when(1000, { + startAngle: PI * 3 / 2 + }) + .delay(300) + .start('circularInOut'); + + var group = new graphic.Group(); + group.add(arc); + group.add(labelRect); + group.add(mask); + // Inject resize + group.resize = function () { + var cx = api.getWidth() / 2; + var cy = api.getHeight() / 2; + arc.setShape({ + cx: cx, + cy: cy + }); + var r = arc.shape.r; + labelRect.setShape({ + x: cx - r, + y: cy - r, + width: r * 2, + height: r * 2 + }); + + mask.setShape({ + x: 0, + y: 0, + width: api.getWidth(), + height: api.getHeight() + }); + }; + group.resize(); + return group; + }; + + +/***/ }, +/* 88 */ +/***/ function(module, exports, __webpack_require__) { + + + var Gradient = __webpack_require__(4); + module.exports = function (seriesType, styleType, ecModel) { + function encodeColor(seriesModel) { + var colorAccessPath = [styleType, 'normal', 'color']; + var colorList = ecModel.get('color'); + var data = seriesModel.getData(); + var color = seriesModel.get(colorAccessPath) // Set in itemStyle + || colorList[seriesModel.seriesIndex % colorList.length]; // Default color + + // FIXME Set color function or use the platte color + data.setVisual('color', color); + + // Only visible series has each data be visual encoded + if (!ecModel.isSeriesFiltered(seriesModel)) { + if (typeof color === 'function' && !(color instanceof Gradient)) { + data.each(function (idx) { + data.setItemVisual( + idx, 'color', color(seriesModel.getDataParams(idx)) + ); + }); + } + + data.each(function (idx) { + var itemModel = data.getItemModel(idx); + var color = itemModel.get(colorAccessPath, true); + if (color != null) { + data.setItemVisual(idx, 'color', color); + } + }); + } + } + seriesType ? ecModel.eachSeriesByType(seriesType, encodeColor) + : ecModel.eachSeries(encodeColor); + }; + + +/***/ }, +/* 89 */ +/***/ function(module, exports, __webpack_require__) { + + // Compatitable with 2.0 + + + var zrUtil = __webpack_require__(3); + var compatStyle = __webpack_require__(90); + + function get(opt, path) { + path = path.split(','); + var obj = opt; + for (var i = 0; i < path.length; i++) { + obj = obj && obj[path[i]]; + if (obj == null) { + break; + } + } + return obj; + } + + function set(opt, path, val, overwrite) { + path = path.split(','); + var obj = opt; + var key; + for (var i = 0; i < path.length - 1; i++) { + key = path[i]; + if (obj[key] == null) { + obj[key] = {}; + } + obj = obj[key]; + } + if (overwrite || obj[path[i]] == null) { + obj[path[i]] = val; + } + } + + function compatLayoutProperties(option) { + each(LAYOUT_PROPERTIES, function (prop) { + if (prop[0] in option && !(prop[1] in option)) { + option[prop[1]] = option[prop[0]]; + } + }); + } + + var LAYOUT_PROPERTIES = [ + ['x', 'left'], ['y', 'top'], ['x2', 'right'], ['y2', 'bottom'] + ]; + + var COMPATITABLE_COMPONENTS = [ + 'grid', 'geo', 'parallel', 'legend', 'toolbox', 'title', 'visualMap', 'dataZoom', 'timeline' + ]; + + var COMPATITABLE_SERIES = [ + 'bar', 'boxplot', 'candlestick', 'chord', 'effectScatter', + 'funnel', 'gauge', 'lines', 'graph', 'heatmap', 'line', 'map', 'parallel', + 'pie', 'radar', 'sankey', 'scatter', 'treemap' + ]; + + var each = zrUtil.each; + + module.exports = function (option) { + each(option.series, function (seriesOpt) { + if (!zrUtil.isObject(seriesOpt)) { + return; + } + + var seriesType = seriesOpt.type; + + compatStyle(seriesOpt); + + if (seriesType === 'pie' || seriesType === 'gauge') { + if (seriesOpt.clockWise != null) { + seriesOpt.clockwise = seriesOpt.clockWise; + } + } + if (seriesType === 'gauge') { + var pointerColor = get(seriesOpt, 'pointer.color'); + pointerColor != null + && set(seriesOpt, 'itemStyle.normal.color', pointerColor); + } + + for (var i = 0; i < COMPATITABLE_SERIES.length; i++) { + if (COMPATITABLE_SERIES[i] === seriesOpt.type) { + compatLayoutProperties(seriesOpt); + break; + } + } + }); + + // dataRange has changed to visualMap + if (option.dataRange) { + option.visualMap = option.dataRange; + } + + each(COMPATITABLE_COMPONENTS, function (componentName) { + var options = option[componentName]; + if (options) { + if (!zrUtil.isArray(options)) { + options = [options]; + } + each(options, function (option) { + compatLayoutProperties(option); + }); + } + }); + }; + + +/***/ }, +/* 90 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + var POSSIBLE_STYLES = [ + 'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle', + 'chordStyle', 'label', 'labelLine' + ]; + + function compatItemStyle(opt) { + var itemStyleOpt = opt && opt.itemStyle; + if (itemStyleOpt) { + zrUtil.each(POSSIBLE_STYLES, function (styleName) { + var normalItemStyleOpt = itemStyleOpt.normal; + var emphasisItemStyleOpt = itemStyleOpt.emphasis; + if (normalItemStyleOpt && normalItemStyleOpt[styleName]) { + opt[styleName] = opt[styleName] || {}; + if (!opt[styleName].normal) { + opt[styleName].normal = normalItemStyleOpt[styleName]; + } + else { + zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]); + } + normalItemStyleOpt[styleName] = null; + } + if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) { + opt[styleName] = opt[styleName] || {}; + if (!opt[styleName].emphasis) { + opt[styleName].emphasis = emphasisItemStyleOpt[styleName]; + } + else { + zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]); + } + emphasisItemStyleOpt[styleName] = null; + } + }); + } + } + + module.exports = function (seriesOpt) { + if (!seriesOpt) { + return; + } + compatItemStyle(seriesOpt); + compatItemStyle(seriesOpt.markPoint); + compatItemStyle(seriesOpt.markLine); + var data = seriesOpt.data; + if (data) { + for (var i = 0; i < data.length; i++) { + compatItemStyle(data[i]); + } + // mark point data + var markPoint = seriesOpt.markPoint; + if (markPoint && markPoint.data) { + var mpData = markPoint.data; + for (var i = 0; i < mpData.length; i++) { + compatItemStyle(mpData[i]); + } + } + // mark line data + var markLine = seriesOpt.markLine; + if (markLine && markLine.data) { + var mlData = markLine.data; + for (var i = 0; i < mlData.length; i++) { + if (zrUtil.isArray(mlData[i])) { + compatItemStyle(mlData[i][0]); + compatItemStyle(mlData[i][1]); + } + else { + compatItemStyle(mlData[i]); + } + } + } + } + }; + + +/***/ }, +/* 91 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var echarts = __webpack_require__(1); + + __webpack_require__(92); + __webpack_require__(97); + + echarts.registerVisualCoding('chart', zrUtil.curry( + __webpack_require__(103), 'line', 'circle', 'line' + )); + echarts.registerLayout(zrUtil.curry( + __webpack_require__(104), 'line' + )); + + // Down sample after filter + echarts.registerProcessor('statistic', zrUtil.curry( + __webpack_require__(105), 'line' + )); + + // In case developer forget to include grid component + __webpack_require__(106); + + +/***/ }, +/* 92 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var createListFromArray = __webpack_require__(93); + var SeriesModel = __webpack_require__(27); + + module.exports = SeriesModel.extend({ + + type: 'series.line', + + dependencies: ['grid', 'polar'], + + getInitialData: function (option, ecModel) { + return createListFromArray(option.data, this, ecModel); + }, + + defaultOption: { + zlevel: 0, // 一级层叠 + z: 2, // 二级层叠 + coordinateSystem: 'cartesian2d', + legendHoverLink: true, + + hoverAnimation: true, + // stack: null + xAxisIndex: 0, + yAxisIndex: 0, + + polarIndex: 0, + + // If clip the overflow value + clipOverflow: true, + + label: { + normal: { + // show: false, + position: 'top' + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 + // 'inside'|'left'|'right'|'top'|'bottom' + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + } + // emphasis: { + // show: false, + // position: 'top' + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 + // 'inside'|'left'|'right'|'top'|'bottom' + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + // } + }, + // itemStyle: { + // normal: { + // // color: 各异 + // }, + // emphasis: { + // // color: 各异, + // } + // }, + lineStyle: { + normal: { + width: 2, + type: 'solid' + } + }, + // areaStyle: { + // }, + // smooth: false, + // smoothMonotone: null, + // 拐点图形类型 + symbol: 'emptyCircle', + // 拐点图形大小 + symbolSize: 4, + // 拐点图形旋转控制 + // symbolRotate: null, + + // 是否显示 symbol, 只有在 tooltip hover 的时候显示 + showSymbol: true, + // 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略) + // showAllSymbol: false + // + // 大数据过滤,'average', 'max', 'min', 'sum' + // sampling: 'none' + + animationEasing: 'linear' + } + }); + + +/***/ }, +/* 93 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var List = __webpack_require__(94); + var completeDimensions = __webpack_require__(96); + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var CoordinateSystem = __webpack_require__(25); + var getDataItemValue = modelUtil.getDataItemValue; + var converDataValue = modelUtil.converDataValue; + + function firstDataNotNull(data) { + var i = 0; + while (i < data.length && data[i] == null) { + i++; + } + return data[i]; + } + function ifNeedCompleteOrdinalData(data) { + var sampleItem = firstDataNotNull(data); + return sampleItem != null + && !zrUtil.isArray(getDataItemValue(sampleItem)); + } + + /** + * Helper function to create a list from option data + */ + function createListFromArray(data, seriesModel, ecModel) { + // If data is undefined + data = data || []; + + var coordSysName = seriesModel.get('coordinateSystem'); + var creator = creators[coordSysName]; + var registeredCoordSys = CoordinateSystem.get(coordSysName); + // FIXME + var result = creator && creator(data, seriesModel, ecModel); + var dimensions = result && result.dimensions; + if (!dimensions) { + // Get dimensions from registered coordinate system + dimensions = (registeredCoordSys && registeredCoordSys.dimensions) || ['x', 'y']; + dimensions = completeDimensions(dimensions, data, dimensions.concat(['value'])); + } + var categoryAxisModel = result && result.categoryAxisModel; + + var categoryDimIndex = dimensions[0].type === 'ordinal' + ? 0 : (dimensions[1].type === 'ordinal' ? 1 : -1); + + var list = new List(dimensions, seriesModel); + + var nameList = createNameList(result, data); + + var dimValueGetter = (categoryAxisModel && ifNeedCompleteOrdinalData(data)) + ? function (itemOpt, dimName, dataIndex, dimIndex) { + // Use dataIndex as ordinal value in categoryAxis + return dimIndex === categoryDimIndex + ? dataIndex + : converDataValue(getDataItemValue(itemOpt), dimensions[dimIndex]); + } + : function (itemOpt, dimName, dataIndex, dimIndex) { + var val = getDataItemValue(itemOpt); + return converDataValue(val && val[dimIndex], dimensions[dimIndex]); + }; + + list.initData(data, nameList, dimValueGetter); + + return list; + } + + function isStackable(axisType) { + return axisType !== 'category' && axisType !== 'time'; + } + + function getDimTypeByAxis(axisType) { + return axisType === 'category' + ? 'ordinal' + : axisType === 'time' + ? 'time' + : 'float'; + } + + /** + * Creaters for each coord system. + * @return {Object} {dimensions, categoryAxisModel}; + */ + var creators = { + + cartesian2d: function (data, seriesModel, ecModel) { + var xAxisModel = ecModel.getComponent('xAxis', seriesModel.get('xAxisIndex')); + var yAxisModel = ecModel.getComponent('yAxis', seriesModel.get('yAxisIndex')); + var xAxisType = xAxisModel.get('type'); + var yAxisType = yAxisModel.get('type'); + + var dimensions = [ + { + name: 'x', + type: getDimTypeByAxis(xAxisType), + stackable: isStackable(xAxisType) + }, + { + name: 'y', + // If two category axes + type: getDimTypeByAxis(yAxisType), + stackable: isStackable(yAxisType) + } + ]; + + completeDimensions(dimensions, data, ['x', 'y', 'z']); + + return { + dimensions: dimensions, + categoryAxisModel: xAxisType === 'category' + ? xAxisModel + : (yAxisType === 'category' ? yAxisModel : null) + }; + }, + + polar: function (data, seriesModel, ecModel) { + var polarIndex = seriesModel.get('polarIndex') || 0; + + var axisFinder = function (axisModel) { + return axisModel.get('polarIndex') === polarIndex; + }; + + var angleAxisModel = ecModel.findComponents({ + mainType: 'angleAxis', filter: axisFinder + })[0]; + var radiusAxisModel = ecModel.findComponents({ + mainType: 'radiusAxis', filter: axisFinder + })[0]; + + var radiusAxisType = radiusAxisModel.get('type'); + var angleAxisType = angleAxisModel.get('type'); + + var dimensions = [ + { + name: 'radius', + type: getDimTypeByAxis(radiusAxisType), + stackable: isStackable(radiusAxisType) + }, + { + name: 'angle', + type: getDimTypeByAxis(angleAxisType), + stackable: isStackable(angleAxisType) + } + ]; + + completeDimensions(dimensions, data, ['radius', 'angle', 'value']); + + return { + dimensions: dimensions, + categoryAxisModel: angleAxisType === 'category' + ? angleAxisModel + : (radiusAxisType === 'category' ? radiusAxisModel : null) + }; + }, + + geo: function (data, seriesModel, ecModel) { + // TODO Region + // 多个散点图系列在同一个地区的时候 + return { + dimensions: completeDimensions([ + {name: 'lng'}, + {name: 'lat'} + ], data, ['lng', 'lat', 'value']) + }; + } + }; + + function createNameList(result, data) { + var nameList = []; + + if (result && result.categoryAxisModel) { + // FIXME Two category axis + var categories = result.categoryAxisModel.getCategories(); + if (categories) { + var dataLen = data.length; + // Ordered data is given explicitly like + // [[3, 0.2], [1, 0.3], [2, 0.15]] + // or given scatter data, + // pick the category + if (zrUtil.isArray(data[0]) && data[0].length > 1) { + nameList = []; + for (var i = 0; i < dataLen; i++) { + nameList[i] = categories[data[i][0]]; + } + } + else { + nameList = categories.slice(0); + } + } + } + + return nameList; + } + + module.exports = createListFromArray; + + + +/***/ }, +/* 94 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global) {/** + * List for data storage + * @module echarts/data/List + */ + + + var UNDEFINED = 'undefined'; + var globalObj = typeof window === 'undefined' ? global : window; + var Float64Array = typeof globalObj.Float64Array === UNDEFINED + ? Array : globalObj.Float64Array; + var Int32Array = typeof globalObj.Int32Array === UNDEFINED + ? Array : globalObj.Int32Array; + + var dataCtors = { + 'float': Float64Array, + 'int': Int32Array, + // Ordinal data type can be string or int + 'ordinal': Array, + 'number': Array, + 'time': Array + }; + + var Model = __webpack_require__(8); + var DataDiffer = __webpack_require__(95); + + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var isObject = zrUtil.isObject; + + var IMMUTABLE_PROPERTIES = [ + 'stackedOn', '_nameList', '_idList', '_rawData' + ]; + + var transferImmuProperties = function (a, b, wrappedMethod) { + zrUtil.each(IMMUTABLE_PROPERTIES.concat(wrappedMethod || []), function (propName) { + if (b.hasOwnProperty(propName)) { + a[propName] = b[propName]; + } + }); + }; + + /** + * @constructor + * @alias module:echarts/data/List + * + * @param {Array.} dimensions + * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius + * @param {module:echarts/model/Model} hostModel + */ + var List = function (dimensions, hostModel) { + + dimensions = dimensions || ['x', 'y']; + + var dimensionInfos = {}; + var dimensionNames = []; + for (var i = 0; i < dimensions.length; i++) { + var dimensionName; + var dimensionInfo = {}; + if (typeof dimensions[i] === 'string') { + dimensionName = dimensions[i]; + dimensionInfo = { + name: dimensionName, + stackable: false, + // Type can be 'float', 'int', 'number' + // Default is number, Precision of float may not enough + type: 'number' + }; + } + else { + dimensionInfo = dimensions[i]; + dimensionName = dimensionInfo.name; + dimensionInfo.type = dimensionInfo.type || 'number'; + } + dimensionNames.push(dimensionName); + dimensionInfos[dimensionName] = dimensionInfo; + } + /** + * @readOnly + * @type {Array.} + */ + this.dimensions = dimensionNames; + + /** + * Infomation of each data dimension, like data type. + * @type {Object} + */ + this._dimensionInfos = dimensionInfos; + + /** + * @type {module:echarts/model/Model} + */ + this.hostModel = hostModel; + + /** + * Indices stores the indices of data subset after filtered. + * This data subset will be used in chart. + * @type {Array.} + * @readOnly + */ + this.indices = []; + + /** + * Data storage + * @type {Object.} + * @private + */ + this._storage = {}; + + /** + * @type {Array.} + */ + this._nameList = []; + /** + * @type {Array.} + */ + this._idList = []; + /** + * Models of data option is stored sparse for optimizing memory cost + * @type {Array.} + * @private + */ + this._optionModels = []; + + /** + * @param {module:echarts/data/List} + */ + this.stackedOn = null; + + /** + * Global visual properties after visual coding + * @type {Object} + * @private + */ + this._visual = {}; + + /** + * Globel layout properties. + * @type {Object} + * @private + */ + this._layout = {}; + + /** + * Item visual properties after visual coding + * @type {Array.} + * @private + */ + this._itemVisuals = []; + + /** + * Item layout properties after layout + * @type {Array.} + * @private + */ + this._itemLayouts = []; + + /** + * Graphic elemnents + * @type {Array.} + * @private + */ + this._graphicEls = []; + + /** + * @type {Array.} + * @private + */ + this._rawData; + + /** + * @type {Object} + * @private + */ + this._extent; + }; + + var listProto = List.prototype; + + listProto.type = 'list'; + + /** + * Get dimension name + * @param {string|number} dim + * Dimension can be concrete names like x, y, z, lng, lat, angle, radius + * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius' + */ + listProto.getDimension = function (dim) { + if (!isNaN(dim)) { + dim = this.dimensions[dim] || dim; + } + return dim; + }; + /** + * Get type and stackable info of particular dimension + * @param {string|number} dim + * Dimension can be concrete names like x, y, z, lng, lat, angle, radius + * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius' + */ + listProto.getDimensionInfo = function (dim) { + return zrUtil.clone(this._dimensionInfos[this.getDimension(dim)]); + }; + + /** + * Initialize from data + * @param {Array.} data + * @param {Array.} [nameList] + * @param {Function} [dimValueGetter] (dataItem, dimName, dataIndex, dimIndex) => number + */ + listProto.initData = function (data, nameList, dimValueGetter) { + data = data || []; + + this._rawData = data; + + // Clear + var storage = this._storage = {}; + var indices = this.indices = []; + + var dimensions = this.dimensions; + var size = data.length; + var dimensionInfoMap = this._dimensionInfos; + + var idList = []; + var nameRepeatCount = {}; + + nameList = nameList || []; + + // Init storage + for (var i = 0; i < dimensions.length; i++) { + var dimInfo = dimensionInfoMap[dimensions[i]]; + var DataCtor = dataCtors[dimInfo.type]; + storage[dimensions[i]] = new DataCtor(size); + } + + // Default dim value getter + dimValueGetter = dimValueGetter || function (dataItem, dimName, dataIndex, dimIndex) { + var value = modelUtil.getDataItemValue(dataItem); + return modelUtil.converDataValue( + zrUtil.isArray(value) + ? value[dimIndex] + // If value is a single number or something else not array. + : value, + dimensionInfoMap[dimName] + ); + }; + + for (var idx = 0; idx < data.length; idx++) { + var dataItem = data[idx]; + // Each data item is value + // [1, 2] + // 2 + // Bar chart, line chart which uses category axis + // only gives the 'y' value. 'x' value is the indices of cateogry + // Use a tempValue to normalize the value to be a (x, y) value + + // Store the data by dimensions + for (var k = 0; k < dimensions.length; k++) { + var dim = dimensions[k]; + var dimStorage = storage[dim]; + // PENDING NULL is empty or zero + dimStorage[idx] = dimValueGetter(dataItem, dim, idx, k); + } + + indices.push(idx); + } + + // Use the name in option and create id + for (var i = 0; i < data.length; i++) { + var id = ''; + if (!nameList[i]) { + nameList[i] = data[i].name; + // Try using the id in option + id = data[i].id; + } + var name = nameList[i] || ''; + if (!id && name) { + // Use name as id and add counter to avoid same name + nameRepeatCount[name] = nameRepeatCount[name] || 0; + id = name; + if (nameRepeatCount[name] > 0) { + id += '__ec__' + nameRepeatCount[name]; + } + nameRepeatCount[name]++; + } + id && (idList[i] = id); + } + + this._nameList = nameList; + this._idList = idList; + }; + + /** + * @return {number} + */ + listProto.count = function () { + return this.indices.length; + }; + + /** + * Get value. Return NaN if idx is out of range. + * @param {string} dim Dim must be concrete name. + * @param {number} idx + * @param {boolean} stack + * @return {number} + */ + listProto.get = function (dim, idx, stack) { + var storage = this._storage; + var dataIndex = this.indices[idx]; + + // If value not exists + if (dataIndex == null) { + return NaN; + } + + var value = storage[dim] && storage[dim][dataIndex]; + // FIXME ordinal data type is not stackable + if (stack) { + var dimensionInfo = this._dimensionInfos[dim]; + if (dimensionInfo && dimensionInfo.stackable) { + var stackedOn = this.stackedOn; + while (stackedOn) { + // Get no stacked data of stacked on + var stackedValue = stackedOn.get(dim, idx); + // Considering positive stack, negative stack and empty data + if ((value >= 0 && stackedValue > 0) // Positive stack + || (value <= 0 && stackedValue < 0) // Negative stack + ) { + value += stackedValue; + } + stackedOn = stackedOn.stackedOn; + } + } + } + return value; + }; + + /** + * Get value for multi dimensions. + * @param {Array.} [dimensions] If ignored, using all dimensions. + * @param {number} idx + * @param {boolean} stack + * @return {number} + */ + listProto.getValues = function (dimensions, idx, stack) { + var values = []; + + if (!zrUtil.isArray(dimensions)) { + stack = idx; + idx = dimensions; + dimensions = this.dimensions; + } + + for (var i = 0, len = dimensions.length; i < len; i++) { + values.push(this.get(dimensions[i], idx, stack)); + } + + return values; + }; + + /** + * If value is NaN. Inlcuding '-' + * @param {string} dim + * @param {number} idx + * @return {number} + */ + listProto.hasValue = function (idx) { + var dimensions = this.dimensions; + var dimensionInfos = this._dimensionInfos; + for (var i = 0, len = dimensions.length; i < len; i++) { + if ( + // Ordinal type can be string or number + dimensionInfos[dimensions[i]].type !== 'ordinal' + && isNaN(this.get(dimensions[i], idx)) + ) { + return false; + } + } + return true; + }; + + /** + * Get extent of data in one dimension + * @param {string} dim + * @param {boolean} stack + */ + listProto.getDataExtent = function (dim, stack) { + var dimData = this._storage[dim]; + var dimInfo = this.getDimensionInfo(dim); + stack = (dimInfo && dimInfo.stackable) && stack; + var dimExtent = (this._extent || (this._extent = {}))[dim + (!!stack)]; + var value; + if (dimExtent) { + return dimExtent; + } + // var dimInfo = this._dimensionInfos[dim]; + if (dimData) { + var min = Infinity; + var max = -Infinity; + // var isOrdinal = dimInfo.type === 'ordinal'; + for (var i = 0, len = this.count(); i < len; i++) { + value = this.get(dim, i, stack); + // FIXME + // if (isOrdinal && typeof value === 'string') { + // value = zrUtil.indexOf(dimData, value); + // console.log(value); + // } + value < min && (min = value); + value > max && (max = value); + } + return (this._extent[dim + stack] = [min, max]); + } + else { + return [Infinity, -Infinity]; + } + }; + + /** + * Get sum of data in one dimension + * @param {string} dim + * @param {boolean} stack + */ + listProto.getSum = function (dim, stack) { + var dimData = this._storage[dim]; + var sum = 0; + if (dimData) { + for (var i = 0, len = this.count(); i < len; i++) { + var value = this.get(dim, i, stack); + if (!isNaN(value)) { + sum += value; + } + } + } + return sum; + }; + + /** + * Retreive the index with given value + * @param {number} idx + * @param {number} value + * @return {number} + */ + // FIXME Precision of float value + listProto.indexOf = function (dim, value) { + var storage = this._storage; + var dimData = storage[dim]; + var indices = this.indices; + + if (dimData) { + for (var i = 0, len = indices.length; i < len; i++) { + var rawIndex = indices[i]; + if (dimData[rawIndex] === value) { + return i; + } + } + } + return -1; + }; + + /** + * Retreive the index with given name + * @param {number} idx + * @param {number} name + * @return {number} + */ + listProto.indexOfName = function (name) { + var indices = this.indices; + var nameList = this._nameList; + + for (var i = 0, len = indices.length; i < len; i++) { + var rawIndex = indices[i]; + if (nameList[rawIndex] === name) { + return i; + } + } + + return -1; + }; + + /** + * Retreive the index of nearest value + * @param {string>} dim + * @param {number} value + * @param {boolean} stack If given value is after stacked + * @return {number} + */ + listProto.indexOfNearest = function (dim, value, stack) { + var storage = this._storage; + var dimData = storage[dim]; + + if (dimData) { + var minDist = Number.MAX_VALUE; + var nearestIdx = -1; + for (var i = 0, len = this.count(); i < len; i++) { + var dist = Math.abs(this.get(dim, i, stack) - value); + if (dist <= minDist) { + minDist = dist; + nearestIdx = i; + } + } + return nearestIdx; + } + return -1; + }; + + /** + * Get raw data index + * @param {number} idx + * @return {number} + */ + listProto.getRawIndex = function (idx) { + var rawIdx = this.indices[idx]; + return rawIdx == null ? -1 : rawIdx; + }; + + /** + * @param {number} idx + * @param {boolean} [notDefaultIdx=false] + * @return {string} + */ + listProto.getName = function (idx) { + return this._nameList[this.indices[idx]] || ''; + }; + + /** + * @param {number} idx + * @param {boolean} [notDefaultIdx=false] + * @return {string} + */ + listProto.getId = function (idx) { + return this._idList[this.indices[idx]] || (this.getRawIndex(idx) + ''); + }; + + + function normalizeDimensions(dimensions) { + if (!zrUtil.isArray(dimensions)) { + dimensions = [dimensions]; + } + return dimensions; + } + + /** + * Data iteration + * @param {string|Array.} + * @param {Function} cb + * @param {boolean} [stack=false] + * @param {*} [context=this] + * + * @example + * list.each('x', function (x, idx) {}); + * list.each(['x', 'y'], function (x, y, idx) {}); + * list.each(function (idx) {}) + */ + listProto.each = function (dimensions, cb, stack, context) { + if (typeof dimensions === 'function') { + context = stack; + stack = cb; + cb = dimensions; + dimensions = []; + } + + dimensions = zrUtil.map( + normalizeDimensions(dimensions), this.getDimension, this + ); + + var value = []; + var dimSize = dimensions.length; + var indices = this.indices; + + context = context || this; + + for (var i = 0; i < indices.length; i++) { + if (dimSize === 0) { + cb.call(context, i); + } + // Simple optimization + else if (dimSize === 1) { + cb.call(context, this.get(dimensions[0], i, stack), i); + } + else { + for (var k = 0; k < dimSize; k++) { + value[k] = this.get(dimensions[k], i, stack); + } + // Index + value[k] = i; + cb.apply(context, value); + } + } + }; + + /** + * Data filter + * @param {string|Array.} + * @param {Function} cb + * @param {boolean} [stack=false] + * @param {*} [context=this] + */ + listProto.filterSelf = function (dimensions, cb, stack, context) { + if (typeof dimensions === 'function') { + context = stack; + stack = cb; + cb = dimensions; + dimensions = []; + } + + dimensions = zrUtil.map( + normalizeDimensions(dimensions), this.getDimension, this + ); + + var newIndices = []; + var value = []; + var dimSize = dimensions.length; + var indices = this.indices; + + context = context || this; + + for (var i = 0; i < indices.length; i++) { + var keep; + // Simple optimization + if (dimSize === 1) { + keep = cb.call( + context, this.get(dimensions[0], i, stack), i + ); + } + else { + for (var k = 0; k < dimSize; k++) { + value[k] = this.get(dimensions[k], i, stack); + } + value[k] = i; + keep = cb.apply(context, value); + } + if (keep) { + newIndices.push(indices[i]); + } + } + + this.indices = newIndices; + + // Reset data extent + this._extent = {}; + + return this; + }; + + /** + * Data mapping to a plain array + * @param {string|Array.} [dimensions] + * @param {Function} cb + * @param {boolean} [stack=false] + * @param {*} [context=this] + * @return {Array} + */ + listProto.mapArray = function (dimensions, cb, stack, context) { + if (typeof dimensions === 'function') { + context = stack; + stack = cb; + cb = dimensions; + dimensions = []; + } + + var result = []; + this.each(dimensions, function () { + result.push(cb && cb.apply(this, arguments)); + }, stack, context); + return result; + }; + + function cloneListForMapAndSample(original, excludeDimensions) { + var allDimensions = original.dimensions; + var list = new List( + zrUtil.map(allDimensions, original.getDimensionInfo, original), + original.hostModel + ); + // FIXME If needs stackedOn, value may already been stacked + transferImmuProperties(list, original, original._wrappedMethods); + + var storage = list._storage = {}; + var originalStorage = original._storage; + // Init storage + for (var i = 0; i < allDimensions.length; i++) { + var dim = allDimensions[i]; + var dimStore = originalStorage[dim]; + if (zrUtil.indexOf(excludeDimensions, dim) >= 0) { + storage[dim] = new dimStore.constructor( + originalStorage[dim].length + ); + } + else { + // Direct reference for other dimensions + storage[dim] = originalStorage[dim]; + } + } + return list; + } + + /** + * Data mapping to a new List with given dimensions + * @param {string|Array.} dimensions + * @param {Function} cb + * @param {boolean} [stack=false] + * @param {*} [context=this] + * @return {Array} + */ + listProto.map = function (dimensions, cb, stack, context) { + dimensions = zrUtil.map( + normalizeDimensions(dimensions), this.getDimension, this + ); + + var list = cloneListForMapAndSample(this, dimensions); + // Following properties are all immutable. + // So we can reference to the same value + var indices = list.indices = this.indices; + + var storage = list._storage; + + var tmpRetValue = []; + this.each(dimensions, function () { + var idx = arguments[arguments.length - 1]; + var retValue = cb && cb.apply(this, arguments); + if (retValue != null) { + // a number + if (typeof retValue === 'number') { + tmpRetValue[0] = retValue; + retValue = tmpRetValue; + } + for (var i = 0; i < retValue.length; i++) { + var dim = dimensions[i]; + var dimStore = storage[dim]; + var rawIdx = indices[idx]; + if (dimStore) { + dimStore[rawIdx] = retValue[i]; + } + } + } + }, stack, context); + + return list; + }; + + /** + * Large data down sampling on given dimension + * @param {string} dimension + * @param {number} rate + * @param {Function} sampleValue + * @param {Function} sampleIndex Sample index for name and id + */ + listProto.downSample = function (dimension, rate, sampleValue, sampleIndex) { + var list = cloneListForMapAndSample(this, [dimension]); + var storage = this._storage; + var targetStorage = list._storage; + + var originalIndices = this.indices; + var indices = list.indices = []; + + var frameValues = []; + var frameIndices = []; + var frameSize = Math.floor(1 / rate); + + var dimStore = targetStorage[dimension]; + var len = this.count(); + // Copy data from original data + for (var i = 0; i < storage[dimension].length; i++) { + targetStorage[dimension][i] = storage[dimension][i]; + } + for (var i = 0; i < len; i += frameSize) { + // Last frame + if (frameSize > len - i) { + frameSize = len - i; + frameValues.length = frameSize; + } + for (var k = 0; k < frameSize; k++) { + var idx = originalIndices[i + k]; + frameValues[k] = dimStore[idx]; + frameIndices[k] = idx; + } + var value = sampleValue(frameValues); + var idx = frameIndices[sampleIndex(frameValues, value) || 0]; + // Only write value on the filtered data + dimStore[idx] = value; + indices.push(idx); + } + return list; + }; + + /** + * Get model of one data item. + * + * @param {number} idx + */ + // FIXME Model proxy ? + listProto.getItemModel = function (idx) { + var hostModel = this.hostModel; + idx = this.indices[idx]; + return new Model(this._rawData[idx], hostModel, hostModel.ecModel); + }; + + /** + * Create a data differ + * @param {module:echarts/data/List} otherList + * @return {module:echarts/data/DataDiffer} + */ + listProto.diff = function (otherList) { + var idList = this._idList; + var otherIdList = otherList && otherList._idList; + return new DataDiffer( + otherList ? otherList.indices : [], this.indices, function (idx) { + return otherIdList[idx] || (idx + ''); + }, function (idx) { + return idList[idx] || (idx + ''); + } + ); + }; + /** + * Get visual property. + * @param {string} key + */ + listProto.getVisual = function (key) { + var visual = this._visual; + return visual && visual[key]; + }; + + /** + * Set visual property + * @param {string|Object} key + * @param {*} [value] + * + * @example + * setVisual('color', color); + * setVisual({ + * 'color': color + * }); + */ + listProto.setVisual = function (key, val) { + if (isObject(key)) { + for (var name in key) { + if (key.hasOwnProperty(name)) { + this.setVisual(name, key[name]); + } + } + return; + } + this._visual = this._visual || {}; + this._visual[key] = val; + }; + + /** + * Set layout property. + * @param {string} key + * @param {*} [val] + */ + listProto.setLayout = function (key, val) { + if (isObject(key)) { + for (var name in key) { + if (key.hasOwnProperty(name)) { + this.setLayout(name, key[name]); + } + } + return; + } + this._layout[key] = val; + }; + + /** + * Get layout property. + * @param {string} key. + * @return {*} + */ + listProto.getLayout = function (key) { + return this._layout[key]; + }; + + /** + * Get layout of single data item + * @param {number} idx + */ + listProto.getItemLayout = function (idx) { + return this._itemLayouts[idx]; + }, + + /** + * Set layout of single data item + * @param {number} idx + * @param {Object} layout + * @param {boolean=} [merge=false] + */ + listProto.setItemLayout = function (idx, layout, merge) { + this._itemLayouts[idx] = merge + ? zrUtil.extend(this._itemLayouts[idx] || {}, layout) + : layout; + }, + + /** + * Get visual property of single data item + * @param {number} idx + * @param {string} key + * @param {boolean} ignoreParent + */ + listProto.getItemVisual = function (idx, key, ignoreParent) { + var itemVisual = this._itemVisuals[idx]; + var val = itemVisual && itemVisual[key]; + if (val == null && !ignoreParent) { + // Use global visual property + return this.getVisual(key); + } + return val; + }, + + /** + * Set visual property of single data item + * + * @param {number} idx + * @param {string|Object} key + * @param {*} [value] + * + * @example + * setItemVisual(0, 'color', color); + * setItemVisual(0, { + * 'color': color + * }); + */ + listProto.setItemVisual = function (idx, key, value) { + var itemVisual = this._itemVisuals[idx] || {}; + this._itemVisuals[idx] = itemVisual; + + if (isObject(key)) { + for (var name in key) { + if (key.hasOwnProperty(name)) { + itemVisual[name] = key[name]; + } + } + return; + } + itemVisual[key] = value; + }; + + var setItemDataAndSeriesIndex = function (child) { + child.seriesIndex = this.seriesIndex; + child.dataIndex = this.dataIndex; + }; + /** + * Set graphic element relative to data. It can be set as null + * @param {number} idx + * @param {module:zrender/Element} [el] + */ + listProto.setItemGraphicEl = function (idx, el) { + var hostModel = this.hostModel; + + if (el) { + // Add data index and series index for indexing the data by element + // Useful in tooltip + el.dataIndex = idx; + el.seriesIndex = hostModel && hostModel.seriesIndex; + if (el.type === 'group') { + el.traverse(setItemDataAndSeriesIndex, el); + } + } + + this._graphicEls[idx] = el; + }; + + /** + * @param {number} idx + * @return {module:zrender/Element} + */ + listProto.getItemGraphicEl = function (idx) { + return this._graphicEls[idx]; + }; + + /** + * @param {Function} cb + * @param {*} context + */ + listProto.eachItemGraphicEl = function (cb, context) { + zrUtil.each(this._graphicEls, function (el, idx) { + if (el) { + cb && cb.call(context, el, idx); + } + }); + }; + + /** + * Shallow clone a new list except visual and layout properties, and graph elements. + * New list only change the indices. + */ + listProto.cloneShallow = function () { + var dimensionInfoList = zrUtil.map(this.dimensions, this.getDimensionInfo, this); + var list = new List(dimensionInfoList, this.hostModel); + + // FIXME + list._storage = this._storage; + + transferImmuProperties(list, this, this._wrappedMethods); + + list.indices = this.indices.slice(); + + return list; + }; + + /** + * Wrap some method to add more feature + * @param {string} methodName + * @param {Function} injectFunction + */ + listProto.wrapMethod = function (methodName, injectFunction) { + var originalMethod = this[methodName]; + if (typeof originalMethod !== 'function') { + return; + } + this._wrappedMethods = this._wrappedMethods || []; + this._wrappedMethods.push(methodName); + this[methodName] = function () { + var res = originalMethod.apply(this, arguments); + return injectFunction.call(this, res); + }; + }; + + module.exports = List; + + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }, +/* 95 */ +/***/ function(module, exports) { + + 'use strict'; + + + function defaultKeyGetter(item) { + return item; + } + + function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter) { + this._old = oldArr; + this._new = newArr; + + this._oldKeyGetter = oldKeyGetter || defaultKeyGetter; + this._newKeyGetter = newKeyGetter || defaultKeyGetter; + } + + DataDiffer.prototype = { + + constructor: DataDiffer, + + /** + * Callback function when add a data + */ + add: function (func) { + this._add = func; + return this; + }, + + /** + * Callback function when update a data + */ + update: function (func) { + this._update = func; + return this; + }, + + /** + * Callback function when remove a data + */ + remove: function (func) { + this._remove = func; + return this; + }, + + execute: function () { + var oldArr = this._old; + var newArr = this._new; + var oldKeyGetter = this._oldKeyGetter; + var newKeyGetter = this._newKeyGetter; + + var oldDataIndexMap = {}; + var newDataIndexMap = {}; + var i; + + initIndexMap(oldArr, oldDataIndexMap, oldKeyGetter); + initIndexMap(newArr, newDataIndexMap, newKeyGetter); + + // Travel by inverted order to make sure order consistency + // when duplicate keys exists (consider newDataIndex.pop() below). + // For performance consideration, these code below do not look neat. + for (i = 0; i < oldArr.length; i++) { + var key = oldKeyGetter(oldArr[i]); + var idx = newDataIndexMap[key]; + + // idx can never be empty array here. see 'set null' logic below. + if (idx != null) { + // Consider there is duplicate key (for example, use dataItem.name as key). + // We should make sure every item in newArr and oldArr can be visited. + var len = idx.length; + if (len) { + len === 1 && (newDataIndexMap[key] = null); + idx = idx.unshift(); + } + else { + newDataIndexMap[key] = null; + } + this._update && this._update(idx, i); + } + else { + this._remove && this._remove(i); + } + } + + for (var key in newDataIndexMap) { + if (newDataIndexMap.hasOwnProperty(key)) { + var idx = newDataIndexMap[key]; + if (idx == null) { + continue; + } + // idx can never be empty array here. see 'set null' logic above. + if (!idx.length) { + this._add && this._add(idx); + } + else { + for (var i = 0, len = idx.length; i < len; i++) { + this._add && this._add(idx[i]); + } + } + } + } + } + }; + + function initIndexMap(arr, map, keyGetter) { + for (var i = 0; i < arr.length; i++) { + var key = keyGetter(arr[i]); + var existence = map[key]; + if (existence == null) { + map[key] = i; + } + else { + if (!existence.length) { + map[key] = existence = [existence]; + } + existence.push(i); + } + } + } + + module.exports = DataDiffer; + + +/***/ }, +/* 96 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Complete dimensions by data (guess dimension). + */ + + + var zrUtil = __webpack_require__(3); + + /** + * Complete the dimensions array guessed from the data structure. + * @param {Array.} dimensions Necessary dimensions, like ['x', 'y'] + * @param {Array} data Data list. [[1, 2, 3], [2, 3, 4]] + * @param {Array.} defaultNames Default names to fill not necessary dimensions, like ['value'] + * @param {string} extraPrefix Prefix of name when filling the left dimensions. + * @return {Array.} + */ + function completeDimensions(dimensions, data, defaultNames, extraPrefix) { + if (!data) { + return dimensions; + } + + var value0 = retrieveValue(data[0]); + var dimSize = zrUtil.isArray(value0) && value0.length || 1; + + defaultNames = defaultNames || []; + extraPrefix = extraPrefix || 'extra'; + for (var i = 0; i < dimSize; i++) { + if (!dimensions[i]) { + var name = defaultNames[i] || (extraPrefix + (i - defaultNames.length)); + dimensions[i] = guessOrdinal(data, i) + ? {type: 'ordinal', name: name} + : name; + } + } + + return dimensions; + } + + // The rule should not be complex, otherwise user might not + // be able to known where the data is wrong. + function guessOrdinal(data, dimIndex) { + for (var i = 0, len = data.length; i < len; i++) { + var value = retrieveValue(data[i]); + + if (!zrUtil.isArray(value)) { + return false; + } + + var value = value[dimIndex]; + if (value != null && isFinite(value)) { + return false; + } + else if (zrUtil.isString(value) && value !== '-') { + return true; + } + } + return false; + } + + function retrieveValue(o) { + return zrUtil.isArray(o) ? o : zrUtil.isObject(o) ? o.value: o; + } + + module.exports = completeDimensions; + + + +/***/ }, +/* 97 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var SymbolDraw = __webpack_require__(98); + var Symbol = __webpack_require__(99); + var lineAnimationDiff = __webpack_require__(101); + var graphic = __webpack_require__(42); + + var polyHelper = __webpack_require__(102); + + var ChartView = __webpack_require__(41); + + function isPointsSame(points1, points2) { + if (points1.length !== points2.length) { + return; + } + for (var i = 0; i < points1.length; i++) { + var p1 = points1[i]; + var p2 = points2[i]; + if (p1[0] !== p2[0] || p1[1] !== p2[1]) { + return; + } + } + return true; + } + + function getSmooth(smooth) { + return typeof (smooth) === 'number' ? smooth : (smooth ? 0.3 : 0); + } + + function getAxisExtentWithGap(axis) { + var extent = axis.getGlobalExtent(); + if (axis.onBand) { + // Remove extra 1px to avoid line miter in clipped edge + var halfBandWidth = axis.getBandWidth() / 2 - 1; + var dir = extent[1] > extent[0] ? 1 : -1; + extent[0] += dir * halfBandWidth; + extent[1] -= dir * halfBandWidth; + } + return extent; + } + + function sign(val) { + return val >= 0 ? 1 : -1; + } + /** + * @param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys + * @param {module:echarts/data/List} data + * @param {Array.>} points + * @private + */ + function getStackedOnPoints(coordSys, data) { + var baseAxis = coordSys.getBaseAxis(); + var valueAxis = coordSys.getOtherAxis(baseAxis); + var valueStart = baseAxis.onZero + ? 0 : valueAxis.scale.getExtent()[0]; + + var valueDim = valueAxis.dim; + + var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0; + + return data.mapArray([valueDim], function (val, idx) { + var stackedOnSameSign; + var stackedOn = data.stackedOn; + // Find first stacked value with same sign + while (stackedOn && + sign(stackedOn.get(valueDim, idx)) === sign(val) + ) { + stackedOnSameSign = stackedOn; + break; + } + var stackedData = []; + stackedData[baseDataOffset] = data.get(baseAxis.dim, idx); + stackedData[1 - baseDataOffset] = stackedOnSameSign + ? stackedOnSameSign.get(valueDim, idx, true) : valueStart; + + return coordSys.dataToPoint(stackedData); + }, true); + } + + function queryDataIndex(data, payload) { + if (payload.dataIndex != null) { + return payload.dataIndex; + } + else if (payload.name != null) { + return data.indexOfName(payload.name); + } + } + + function createGridClipShape(cartesian, hasAnimation, seriesModel) { + var xExtent = getAxisExtentWithGap(cartesian.getAxis('x')); + var yExtent = getAxisExtentWithGap(cartesian.getAxis('y')); + var isHorizontal = cartesian.getBaseAxis().isHorizontal(); + + var x = xExtent[0]; + var y = yExtent[0]; + var width = xExtent[1] - x; + var height = yExtent[1] - y; + // Expand clip shape to avoid line value exceeds axis + if (!seriesModel.get('clipOverflow')) { + if (isHorizontal) { + y -= height; + height *= 3; + } + else { + x -= width; + width *= 3; + } + } + var clipPath = new graphic.Rect({ + shape: { + x: x, + y: y, + width: width, + height: height + } + }); + + if (hasAnimation) { + clipPath.shape[isHorizontal ? 'width' : 'height'] = 0; + graphic.initProps(clipPath, { + shape: { + width: width, + height: height + } + }, seriesModel); + } + + return clipPath; + } + + function createPolarClipShape(polar, hasAnimation, seriesModel) { + var angleAxis = polar.getAngleAxis(); + var radiusAxis = polar.getRadiusAxis(); + + var radiusExtent = radiusAxis.getExtent(); + var angleExtent = angleAxis.getExtent(); + + var RADIAN = Math.PI / 180; + + var clipPath = new graphic.Sector({ + shape: { + cx: polar.cx, + cy: polar.cy, + r0: radiusExtent[0], + r: radiusExtent[1], + startAngle: -angleExtent[0] * RADIAN, + endAngle: -angleExtent[1] * RADIAN, + clockwise: angleAxis.inverse + } + }); + + if (hasAnimation) { + clipPath.shape.endAngle = -angleExtent[0] * RADIAN; + graphic.initProps(clipPath, { + shape: { + endAngle: -angleExtent[1] * RADIAN + } + }, seriesModel); + } + + return clipPath; + } + + function createClipShape(coordSys, hasAnimation, seriesModel) { + return coordSys.type === 'polar' + ? createPolarClipShape(coordSys, hasAnimation, seriesModel) + : createGridClipShape(coordSys, hasAnimation, seriesModel); + } + + module.exports = ChartView.extend({ + + type: 'line', + + init: function () { + var lineGroup = new graphic.Group(); + + var symbolDraw = new SymbolDraw(); + this.group.add(symbolDraw.group); + + this._symbolDraw = symbolDraw; + this._lineGroup = lineGroup; + }, + + render: function (seriesModel, ecModel, api) { + var coordSys = seriesModel.coordinateSystem; + var group = this.group; + var data = seriesModel.getData(); + var lineStyleModel = seriesModel.getModel('lineStyle.normal'); + var areaStyleModel = seriesModel.getModel('areaStyle.normal'); + + var points = data.mapArray(data.getItemLayout, true); + + var isCoordSysPolar = coordSys.type === 'polar'; + var prevCoordSys = this._coordSys; + + var symbolDraw = this._symbolDraw; + var polyline = this._polyline; + var polygon = this._polygon; + + var lineGroup = this._lineGroup; + + var hasAnimation = seriesModel.get('animation'); + + var isAreaChart = !areaStyleModel.isEmpty(); + var stackedOnPoints = getStackedOnPoints(coordSys, data); + + var showSymbol = seriesModel.get('showSymbol'); + + var isSymbolIgnore = showSymbol && !isCoordSysPolar && !seriesModel.get('showAllSymbol') + && this._getSymbolIgnoreFunc(data, coordSys); + + // Remove temporary symbols + var oldData = this._data; + oldData && oldData.eachItemGraphicEl(function (el, idx) { + if (el.__temp) { + group.remove(el); + oldData.setItemGraphicEl(idx, null); + } + }); + + // Remove previous created symbols if showSymbol changed to false + if (!showSymbol) { + symbolDraw.remove(); + } + + group.add(lineGroup); + + // Initialization animation or coordinate system changed + if ( + !(polyline && prevCoordSys.type === coordSys.type) + ) { + showSymbol && symbolDraw.updateData(data, isSymbolIgnore); + + polyline = this._newPolyline(points, coordSys, hasAnimation); + if (isAreaChart) { + polygon = this._newPolygon( + points, stackedOnPoints, + coordSys, hasAnimation + ); + } + lineGroup.setClipPath(createClipShape(coordSys, true, seriesModel)); + } + else { + if (isAreaChart && !polygon) { + // If areaStyle is added + polygon = this._newPolygon( + points, stackedOnPoints, + coordSys, hasAnimation + ); + } + else if (polygon && !isAreaChart) { + // If areaStyle is removed + lineGroup.remove(polygon); + polygon = this._polygon = null; + } + + // Update clipPath + lineGroup.setClipPath(createClipShape(coordSys, false, seriesModel)); + + // Always update, or it is wrong in the case turning on legend + // because points are not changed + showSymbol && symbolDraw.updateData(data, isSymbolIgnore); + + // Stop symbol animation and sync with line points + // FIXME performance? + data.eachItemGraphicEl(function (el) { + el.stopAnimation(true); + }); + + // In the case data zoom triggerred refreshing frequently + // Data may not change if line has a category axis. So it should animate nothing + if (!isPointsSame(this._stackedOnPoints, stackedOnPoints) + || !isPointsSame(this._points, points) + ) { + if (hasAnimation) { + this._updateAnimation( + data, stackedOnPoints, coordSys, api + ); + } + else { + polyline.setShape({ + points: points + }); + polygon && polygon.setShape({ + points: points, + stackedOnPoints: stackedOnPoints + }); + } + } + } + + polyline.setStyle(zrUtil.defaults( + // Use color in lineStyle first + lineStyleModel.getLineStyle(), + { + stroke: data.getVisual('color'), + lineJoin: 'bevel' + } + )); + + var smooth = seriesModel.get('smooth'); + smooth = getSmooth(seriesModel.get('smooth')); + polyline.setShape({ + smooth: smooth, + smoothMonotone: seriesModel.get('smoothMonotone') + }); + + if (polygon) { + var stackedOn = data.stackedOn; + var stackedOnSmooth = 0; + + polygon.style.opacity = 0.7; + polygon.setStyle(zrUtil.defaults( + areaStyleModel.getAreaStyle(), + { + fill: data.getVisual('color'), + lineJoin: 'bevel' + } + )); + + if (stackedOn) { + var stackedOnSeries = stackedOn.hostModel; + stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth')); + } + + polygon.setShape({ + smooth: smooth, + stackedOnSmooth: stackedOnSmooth, + smoothMonotone: seriesModel.get('smoothMonotone') + }); + } + + this._data = data; + // Save the coordinate system for transition animation when data changed + this._coordSys = coordSys; + this._stackedOnPoints = stackedOnPoints; + this._points = points; + }, + + highlight: function (seriesModel, ecModel, api, payload) { + var data = seriesModel.getData(); + var dataIndex = queryDataIndex(data, payload); + + if (dataIndex != null && dataIndex >= 0) { + var symbol = data.getItemGraphicEl(dataIndex); + if (!symbol) { + // Create a temporary symbol if it is not exists + var pt = data.getItemLayout(dataIndex); + symbol = new Symbol(data, dataIndex, api); + symbol.position = pt; + symbol.setZ( + seriesModel.get('zlevel'), + seriesModel.get('z') + ); + symbol.ignore = isNaN(pt[0]) || isNaN(pt[1]); + symbol.__temp = true; + data.setItemGraphicEl(dataIndex, symbol); + + // Stop scale animation + symbol.stopSymbolAnimation(true); + + this.group.add(symbol); + } + symbol.highlight(); + } + else { + // Highlight whole series + ChartView.prototype.highlight.call( + this, seriesModel, ecModel, api, payload + ); + } + }, + + downplay: function (seriesModel, ecModel, api, payload) { + var data = seriesModel.getData(); + var dataIndex = queryDataIndex(data, payload); + if (dataIndex != null && dataIndex >= 0) { + var symbol = data.getItemGraphicEl(dataIndex); + if (symbol) { + if (symbol.__temp) { + data.setItemGraphicEl(dataIndex, null); + this.group.remove(symbol); + } + else { + symbol.downplay(); + } + } + } + else { + // Downplay whole series + ChartView.prototype.downplay.call( + this, seriesModel, ecModel, api, payload + ); + } + }, + + /** + * @param {module:zrender/container/Group} group + * @param {Array.>} points + * @private + */ + _newPolyline: function (points) { + var polyline = this._polyline; + // Remove previous created polyline + if (polyline) { + this._lineGroup.remove(polyline); + } + + polyline = new polyHelper.Polyline({ + shape: { + points: points + }, + silent: true, + z2: 10 + }); + + this._lineGroup.add(polyline); + + this._polyline = polyline; + + return polyline; + }, + + /** + * @param {module:zrender/container/Group} group + * @param {Array.>} stackedOnPoints + * @param {Array.>} points + * @private + */ + _newPolygon: function (points, stackedOnPoints) { + var polygon = this._polygon; + // Remove previous created polygon + if (polygon) { + this._lineGroup.remove(polygon); + } + + polygon = new polyHelper.Polygon({ + shape: { + points: points, + stackedOnPoints: stackedOnPoints + }, + silent: true + }); + + this._lineGroup.add(polygon); + + this._polygon = polygon; + return polygon; + }, + /** + * @private + */ + _getSymbolIgnoreFunc: function (data, coordSys) { + var categoryAxis = coordSys.getAxesByScale('ordinal')[0]; + // `getLabelInterval` is provided by echarts/component/axis + if (categoryAxis && categoryAxis.isLabelIgnored) { + return zrUtil.bind(categoryAxis.isLabelIgnored, categoryAxis); + } + }, + + /** + * @private + */ + // FIXME Two value axis + _updateAnimation: function (data, stackedOnPoints, coordSys, api) { + var polyline = this._polyline; + var polygon = this._polygon; + var seriesModel = data.hostModel; + + var diff = lineAnimationDiff( + this._data, data, + this._stackedOnPoints, stackedOnPoints, + this._coordSys, coordSys + ); + polyline.shape.points = diff.current; + + graphic.updateProps(polyline, { + shape: { + points: diff.next + } + }, seriesModel); + + if (polygon) { + polygon.setShape({ + points: diff.current, + stackedOnPoints: diff.stackedOnCurrent + }); + graphic.updateProps(polygon, { + shape: { + points: diff.next, + stackedOnPoints: diff.stackedOnNext + } + }, seriesModel); + } + + var updatedDataInfo = []; + var diffStatus = diff.status; + + for (var i = 0; i < diffStatus.length; i++) { + var cmd = diffStatus[i].cmd; + if (cmd === '=') { + var el = data.getItemGraphicEl(diffStatus[i].idx1); + if (el) { + updatedDataInfo.push({ + el: el, + ptIdx: i // Index of points + }); + } + } + } + + if (polyline.animators && polyline.animators.length) { + polyline.animators[0].during(function () { + for (var i = 0; i < updatedDataInfo.length; i++) { + var el = updatedDataInfo[i].el; + el.attr('position', polyline.shape.points[updatedDataInfo[i].ptIdx]); + } + }); + } + }, + + remove: function (ecModel) { + var group = this.group; + var oldData = this._data; + this._lineGroup.removeAll(); + this._symbolDraw.remove(true); + // Remove temporary created elements when highlighting + oldData && oldData.eachItemGraphicEl(function (el, idx) { + if (el.__temp) { + group.remove(el); + oldData.setItemGraphicEl(idx, null); + } + }); + + this._polyline = + this._polygon = + this._coordSys = + this._points = + this._stackedOnPoints = + this._data = null; + } + }); + + +/***/ }, +/* 98 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/chart/helper/SymbolDraw + */ + + + var graphic = __webpack_require__(42); + var Symbol = __webpack_require__(99); + + /** + * @constructor + * @alias module:echarts/chart/helper/SymbolDraw + * @param {module:zrender/graphic/Group} [symbolCtor] + */ + function SymbolDraw(symbolCtor) { + this.group = new graphic.Group(); + + this._symbolCtor = symbolCtor || Symbol; + } + + var symbolDrawProto = SymbolDraw.prototype; + + function symbolNeedsDraw(data, idx, isIgnore) { + var point = data.getItemLayout(idx); + return point && !isNaN(point[0]) && !isNaN(point[1]) && !(isIgnore && isIgnore(idx)) + && data.getItemVisual(idx, 'symbol') !== 'none'; + } + /** + * Update symbols draw by new data + * @param {module:echarts/data/List} data + * @param {Array.} [isIgnore] + */ + symbolDrawProto.updateData = function (data, isIgnore) { + var group = this.group; + var seriesModel = data.hostModel; + var oldData = this._data; + + var SymbolCtor = this._symbolCtor; + + data.diff(oldData) + .add(function (newIdx) { + var point = data.getItemLayout(newIdx); + if (symbolNeedsDraw(data, newIdx, isIgnore)) { + var symbolEl = new SymbolCtor(data, newIdx); + symbolEl.attr('position', point); + data.setItemGraphicEl(newIdx, symbolEl); + group.add(symbolEl); + } + }) + .update(function (newIdx, oldIdx) { + var symbolEl = oldData.getItemGraphicEl(oldIdx); + var point = data.getItemLayout(newIdx); + if (!symbolNeedsDraw(data, newIdx, isIgnore)) { + group.remove(symbolEl); + return; + } + if (!symbolEl) { + symbolEl = new SymbolCtor(data, newIdx); + symbolEl.attr('position', point); + } + else { + symbolEl.updateData(data, newIdx); + graphic.updateProps(symbolEl, { + position: point + }, seriesModel); + } + + // Add back + group.add(symbolEl); + + data.setItemGraphicEl(newIdx, symbolEl); + }) + .remove(function (oldIdx) { + var el = oldData.getItemGraphicEl(oldIdx); + el && el.fadeOut(function () { + group.remove(el); + }); + }) + .execute(); + + this._data = data; + }; + + symbolDrawProto.updateLayout = function () { + var data = this._data; + if (data) { + // Not use animation + data.eachItemGraphicEl(function (el, idx) { + el.attr('position', data.getItemLayout(idx)); + }); + } + }; + + symbolDrawProto.remove = function (enableAnimation) { + var group = this.group; + var data = this._data; + if (data) { + if (enableAnimation) { + data.eachItemGraphicEl(function (el) { + el.fadeOut(function () { + group.remove(el); + }); + }); + } + else { + group.removeAll(); + } + } + }; + + module.exports = SymbolDraw; + + +/***/ }, +/* 99 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/chart/helper/Symbol + */ + + + var zrUtil = __webpack_require__(3); + var symbolUtil = __webpack_require__(100); + var graphic = __webpack_require__(42); + var numberUtil = __webpack_require__(7); + + function normalizeSymbolSize(symbolSize) { + if (!zrUtil.isArray(symbolSize)) { + symbolSize = [+symbolSize, +symbolSize]; + } + return symbolSize; + } + + /** + * @constructor + * @alias {module:echarts/chart/helper/Symbol} + * @param {module:echarts/data/List} data + * @param {number} idx + * @extends {module:zrender/graphic/Group} + */ + function Symbol(data, idx) { + graphic.Group.call(this); + + this.updateData(data, idx); + } + + var symbolProto = Symbol.prototype; + + function driftSymbol(dx, dy) { + this.parent.drift(dx, dy); + } + + symbolProto._createSymbol = function (symbolType, data, idx) { + // Remove paths created before + this.removeAll(); + + var seriesModel = data.hostModel; + var color = data.getItemVisual(idx, 'color'); + + var symbolPath = symbolUtil.createSymbol( + symbolType, -0.5, -0.5, 1, 1, color + ); + + symbolPath.attr({ + style: { + strokeNoScale: true + }, + z2: 100, + culling: true, + scale: [0, 0] + }); + // Rewrite drift method + symbolPath.drift = driftSymbol; + + var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); + + graphic.initProps(symbolPath, { + scale: size + }, seriesModel); + + this._symbolType = symbolType; + + this.add(symbolPath); + }; + + /** + * Stop animation + * @param {boolean} toLastFrame + */ + symbolProto.stopSymbolAnimation = function (toLastFrame) { + this.childAt(0).stopAnimation(toLastFrame); + }; + + /** + * Get scale(aka, current symbol size). + * Including the change caused by animation + * @param {Array.} toLastFrame + */ + symbolProto.getScale = function () { + return this.childAt(0).scale; + }; + + /** + * Highlight symbol + */ + symbolProto.highlight = function () { + this.childAt(0).trigger('emphasis'); + }; + + /** + * Downplay symbol + */ + symbolProto.downplay = function () { + this.childAt(0).trigger('normal'); + }; + + /** + * @param {number} zlevel + * @param {number} z + */ + symbolProto.setZ = function (zlevel, z) { + var symbolPath = this.childAt(0); + symbolPath.zlevel = zlevel; + symbolPath.z = z; + }; + + symbolProto.setDraggable = function (draggable) { + var symbolPath = this.childAt(0); + symbolPath.draggable = draggable; + symbolPath.cursor = draggable ? 'move' : 'pointer'; + }; + /** + * Update symbol properties + * @param {module:echarts/data/List} data + * @param {number} idx + */ + symbolProto.updateData = function (data, idx) { + var symbolType = data.getItemVisual(idx, 'symbol') || 'circle'; + var seriesModel = data.hostModel; + var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); + if (symbolType !== this._symbolType) { + this._createSymbol(symbolType, data, idx); + } + else { + var symbolPath = this.childAt(0); + graphic.updateProps(symbolPath, { + scale: symbolSize + }, seriesModel); + } + this._updateCommon(data, idx, symbolSize); + + this._seriesModel = seriesModel; + }; + + // Update common properties + var normalStyleAccessPath = ['itemStyle', 'normal']; + var emphasisStyleAccessPath = ['itemStyle', 'emphasis']; + var normalLabelAccessPath = ['label', 'normal']; + var emphasisLabelAccessPath = ['label', 'emphasis']; + + symbolProto._updateCommon = function (data, idx, symbolSize) { + var symbolPath = this.childAt(0); + var seriesModel = data.hostModel; + var itemModel = data.getItemModel(idx); + var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath); + var color = data.getItemVisual(idx, 'color'); + + var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle(); + + symbolPath.rotation = itemModel.getShallow('symbolRotate') * Math.PI / 180 || 0; + + var symbolOffset = itemModel.getShallow('symbolOffset'); + if (symbolOffset) { + var pos = symbolPath.position; + pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]); + pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]); + } + + symbolPath.setColor(color); + + zrUtil.extend( + symbolPath.style, + // Color must be excluded. + // Because symbol provide setColor individually to set fill and stroke + normalItemStyleModel.getItemStyle(['color']) + ); + + var labelModel = itemModel.getModel(normalLabelAccessPath); + var hoverLabelModel = itemModel.getModel(emphasisLabelAccessPath); + + var elStyle = symbolPath.style; + + // Get last value dim + var dimensions = data.dimensions.slice(); + var valueDim = dimensions.pop(); + var dataType; + while ( + ((dataType = data.getDimensionInfo(valueDim).type) === 'ordinal') + || (dataType === 'time') + ) { + valueDim = dimensions.pop(); + } + + if (labelModel.get('show')) { + graphic.setText(elStyle, labelModel, color); + elStyle.text = zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'normal'), + data.get(valueDim, idx) + ); + } + else { + elStyle.text = ''; + } + + if (hoverLabelModel.getShallow('show')) { + graphic.setText(hoverStyle, hoverLabelModel, color); + hoverStyle.text = zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'emphasis'), + data.get(valueDim, idx) + ); + } + else { + hoverStyle.text = ''; + } + + var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); + + symbolPath.off('mouseover') + .off('mouseout') + .off('emphasis') + .off('normal'); + + graphic.setHoverStyle(symbolPath, hoverStyle); + + if (itemModel.getShallow('hoverAnimation')) { + var onEmphasis = function() { + var ratio = size[1] / size[0]; + this.animateTo({ + scale: [ + Math.max(size[0] * 1.1, size[0] + 3), + Math.max(size[1] * 1.1, size[1] + 3 * ratio) + ] + }, 400, 'elasticOut'); + }; + var onNormal = function() { + this.animateTo({ + scale: size + }, 400, 'elasticOut'); + }; + symbolPath.on('mouseover', onEmphasis) + .on('mouseout', onNormal) + .on('emphasis', onEmphasis) + .on('normal', onNormal); + } + }; + + symbolProto.fadeOut = function (cb) { + var symbolPath = this.childAt(0); + // Not show text when animating + symbolPath.style.text = ''; + graphic.updateProps(symbolPath, { + scale: [0, 0] + }, this._seriesModel, cb); + }; + + zrUtil.inherits(Symbol, graphic.Group); + + module.exports = Symbol; + + +/***/ }, +/* 100 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // Symbol factory + + + var graphic = __webpack_require__(42); + var BoundingRect = __webpack_require__(15); + + /** + * Triangle shape + * @inner + */ + var Triangle = graphic.extendShape({ + type: 'triangle', + shape: { + cx: 0, + cy: 0, + width: 0, + height: 0 + }, + buildPath: function (path, shape) { + var cx = shape.cx; + var cy = shape.cy; + var width = shape.width / 2; + var height = shape.height / 2; + path.moveTo(cx, cy - height); + path.lineTo(cx + width, cy + height); + path.lineTo(cx - width, cy + height); + path.closePath(); + } + }); + /** + * Diamond shape + * @inner + */ + var Diamond = graphic.extendShape({ + type: 'diamond', + shape: { + cx: 0, + cy: 0, + width: 0, + height: 0 + }, + buildPath: function (path, shape) { + var cx = shape.cx; + var cy = shape.cy; + var width = shape.width / 2; + var height = shape.height / 2; + path.moveTo(cx, cy - height); + path.lineTo(cx + width, cy); + path.lineTo(cx, cy + height); + path.lineTo(cx - width, cy); + path.closePath(); + } + }); + + /** + * Pin shape + * @inner + */ + var Pin = graphic.extendShape({ + type: 'pin', + shape: { + // x, y on the cusp + x: 0, + y: 0, + width: 0, + height: 0 + }, + + buildPath: function (path, shape) { + var x = shape.x; + var y = shape.y; + var w = shape.width / 5 * 3; + // Height must be larger than width + var h = Math.max(w, shape.height); + var r = w / 2; + + // Dist on y with tangent point and circle center + var dy = r * r / (h - r); + var cy = y - h + r + dy; + var angle = Math.asin(dy / r); + // Dist on x with tangent point and circle center + var dx = Math.cos(angle) * r; + + var tanX = Math.sin(angle); + var tanY = Math.cos(angle); + + path.arc( + x, cy, r, + Math.PI - angle, + Math.PI * 2 + angle + ); + + var cpLen = r * 0.6; + var cpLen2 = r * 0.7; + path.bezierCurveTo( + x + dx - tanX * cpLen, cy + dy + tanY * cpLen, + x, y - cpLen2, + x, y + ); + path.bezierCurveTo( + x, y - cpLen2, + x - dx + tanX * cpLen, cy + dy + tanY * cpLen, + x - dx, cy + dy + ); + path.closePath(); + } + }); + + /** + * Arrow shape + * @inner + */ + var Arrow = graphic.extendShape({ + + type: 'arrow', + + shape: { + x: 0, + y: 0, + width: 0, + height: 0 + }, + + buildPath: function (ctx, shape) { + var height = shape.height; + var width = shape.width; + var x = shape.x; + var y = shape.y; + var dx = width / 3 * 2; + ctx.moveTo(x, y); + ctx.lineTo(x + dx, y + height); + ctx.lineTo(x, y + height / 4 * 3); + ctx.lineTo(x - dx, y + height); + ctx.lineTo(x, y); + ctx.closePath(); + } + }); + + /** + * Map of path contructors + * @type {Object.} + */ + var symbolCtors = { + line: graphic.Line, + + rect: graphic.Rect, + + roundRect: graphic.Rect, + + square: graphic.Rect, + + circle: graphic.Circle, + + diamond: Diamond, + + pin: Pin, + + arrow: Arrow, + + triangle: Triangle + }; + + var symbolShapeMakers = { + + line: function (x, y, w, h, shape) { + // FIXME + shape.x1 = x; + shape.y1 = y + h / 2; + shape.x2 = x + w; + shape.y2 = y + h / 2; + }, + + rect: function (x, y, w, h, shape) { + shape.x = x; + shape.y = y; + shape.width = w; + shape.height = h; + }, + + roundRect: function (x, y, w, h, shape) { + shape.x = x; + shape.y = y; + shape.width = w; + shape.height = h; + shape.r = Math.min(w, h) / 4; + }, + + square: function (x, y, w, h, shape) { + var size = Math.min(w, h); + shape.x = x; + shape.y = y; + shape.width = size; + shape.height = size; + }, + + circle: function (x, y, w, h, shape) { + // Put circle in the center of square + shape.cx = x + w / 2; + shape.cy = y + h / 2; + shape.r = Math.min(w, h) / 2; + }, + + diamond: function (x, y, w, h, shape) { + shape.cx = x + w / 2; + shape.cy = y + h / 2; + shape.width = w; + shape.height = h; + }, + + pin: function (x, y, w, h, shape) { + shape.x = x + w / 2; + shape.y = y + h / 2; + shape.width = w; + shape.height = h; + }, + + arrow: function (x, y, w, h, shape) { + shape.x = x + w / 2; + shape.y = y + h / 2; + shape.width = w; + shape.height = h; + }, + + triangle: function (x, y, w, h, shape) { + shape.cx = x + w / 2; + shape.cy = y + h / 2; + shape.width = w; + shape.height = h; + } + }; + + var symbolBuildProxies = {}; + for (var name in symbolCtors) { + symbolBuildProxies[name] = new symbolCtors[name](); + } + + var Symbol = graphic.extendShape({ + + type: 'symbol', + + shape: { + symbolType: '', + x: 0, + y: 0, + width: 0, + height: 0 + }, + + beforeBrush: function () { + var style = this.style; + var shape = this.shape; + // FIXME + if (shape.symbolType === 'pin' && style.textPosition === 'inside') { + style.textPosition = ['50%', '40%']; + style.textAlign = 'center'; + style.textVerticalAlign = 'middle'; + } + }, + + buildPath: function (ctx, shape) { + var symbolType = shape.symbolType; + var proxySymbol = symbolBuildProxies[symbolType]; + if (shape.symbolType !== 'none') { + if (!proxySymbol) { + // Default rect + symbolType = 'rect'; + proxySymbol = symbolBuildProxies[symbolType]; + } + symbolShapeMakers[symbolType]( + shape.x, shape.y, shape.width, shape.height, proxySymbol.shape + ); + proxySymbol.buildPath(ctx, proxySymbol.shape); + } + } + }); + + // Provide setColor helper method to avoid determine if set the fill or stroke outside + var symbolPathSetColor = function (color) { + if (this.type !== 'image') { + var symbolStyle = this.style; + var symbolShape = this.shape; + if (symbolShape && symbolShape.symbolType === 'line') { + symbolStyle.stroke = color; + } + else if (this.__isEmptyBrush) { + symbolStyle.stroke = color; + symbolStyle.fill = '#fff'; + } + else { + // FIXME 判断图形默认是填充还是描边,使用 onlyStroke ? + symbolStyle.fill && (symbolStyle.fill = color); + symbolStyle.stroke && (symbolStyle.stroke = color); + } + this.dirty(); + } + }; + + var symbolUtil = { + /** + * Create a symbol element with given symbol configuration: shape, x, y, width, height, color + * @param {string} symbolType + * @param {number} x + * @param {number} y + * @param {number} w + * @param {number} h + * @param {string} color + */ + createSymbol: function (symbolType, x, y, w, h, color) { + var isEmpty = symbolType.indexOf('empty') === 0; + if (isEmpty) { + symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6); + } + var symbolPath; + + if (symbolType.indexOf('image://') === 0) { + symbolPath = new graphic.Image({ + style: { + image: symbolType.slice(8), + x: x, + y: y, + width: w, + height: h + } + }); + } + else if (symbolType.indexOf('path://') === 0) { + symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h)); + } + else { + symbolPath = new Symbol({ + shape: { + symbolType: symbolType, + x: x, + y: y, + width: w, + height: h + } + }); + } + + symbolPath.__isEmptyBrush = isEmpty; + + symbolPath.setColor = symbolPathSetColor; + + symbolPath.setColor(color); + + return symbolPath; + } + }; + + module.exports = symbolUtil; + + +/***/ }, +/* 101 */ +/***/ function(module, exports) { + + + + // var arrayDiff = require('zrender/lib/core/arrayDiff'); + // 'zrender/core/arrayDiff' has been used before, but it did + // not do well in performance when roam with fixed dataZoom window. + + function sign(val) { + return val >= 0 ? 1 : -1; + } + + function getStackedOnPoint(coordSys, data, idx) { + var baseAxis = coordSys.getBaseAxis(); + var valueAxis = coordSys.getOtherAxis(baseAxis); + var valueStart = baseAxis.onZero + ? 0 : valueAxis.scale.getExtent()[0]; + + var valueDim = valueAxis.dim; + var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0; + + var stackedOnSameSign; + var stackedOn = data.stackedOn; + var val = data.get(valueDim, idx); + // Find first stacked value with same sign + while (stackedOn && + sign(stackedOn.get(valueDim, idx)) === sign(val) + ) { + stackedOnSameSign = stackedOn; + break; + } + var stackedData = []; + stackedData[baseDataOffset] = data.get(baseAxis.dim, idx); + stackedData[1 - baseDataOffset] = stackedOnSameSign + ? stackedOnSameSign.get(valueDim, idx, true) : valueStart; + + return coordSys.dataToPoint(stackedData); + } + + // function convertToIntId(newIdList, oldIdList) { + // // Generate int id instead of string id. + // // Compare string maybe slow in score function of arrDiff + + // // Assume id in idList are all unique + // var idIndicesMap = {}; + // var idx = 0; + // for (var i = 0; i < newIdList.length; i++) { + // idIndicesMap[newIdList[i]] = idx; + // newIdList[i] = idx++; + // } + // for (var i = 0; i < oldIdList.length; i++) { + // var oldId = oldIdList[i]; + // // Same with newIdList + // if (idIndicesMap[oldId]) { + // oldIdList[i] = idIndicesMap[oldId]; + // } + // else { + // oldIdList[i] = idx++; + // } + // } + // } + + function diffData(oldData, newData) { + var diffResult = []; + + newData.diff(oldData) + .add(function (idx) { + diffResult.push({cmd: '+', idx: idx}); + }) + .update(function (newIdx, oldIdx) { + diffResult.push({cmd: '=', idx: oldIdx, idx1: newIdx}); + }) + .remove(function (idx) { + diffResult.push({cmd: '-', idx: idx}); + }) + .execute(); + + return diffResult; + } + + module.exports = function ( + oldData, newData, + oldStackedOnPoints, newStackedOnPoints, + oldCoordSys, newCoordSys + ) { + var diff = diffData(oldData, newData); + + // var newIdList = newData.mapArray(newData.getId); + // var oldIdList = oldData.mapArray(oldData.getId); + + // convertToIntId(newIdList, oldIdList); + + // // FIXME One data ? + // diff = arrayDiff(oldIdList, newIdList); + + var currPoints = []; + var nextPoints = []; + // Points for stacking base line + var currStackedPoints = []; + var nextStackedPoints = []; + + var status = []; + var sortedIndices = []; + var rawIndices = []; + var dims = newCoordSys.dimensions; + for (var i = 0; i < diff.length; i++) { + var diffItem = diff[i]; + var pointAdded = true; + + // FIXME, animation is not so perfect when dataZoom window moves fast + // Which is in case remvoing or add more than one data in the tail or head + switch (diffItem.cmd) { + case '=': + var currentPt = oldData.getItemLayout(diffItem.idx); + var nextPt = newData.getItemLayout(diffItem.idx1); + // If previous data is NaN, use next point directly + if (isNaN(currentPt[0]) || isNaN(currentPt[1])) { + currentPt = nextPt.slice(); + } + currPoints.push(currentPt); + nextPoints.push(nextPt); + + currStackedPoints.push(oldStackedOnPoints[diffItem.idx]); + nextStackedPoints.push(newStackedOnPoints[diffItem.idx1]); + + rawIndices.push(newData.getRawIndex(diffItem.idx1)); + break; + case '+': + var idx = diffItem.idx; + currPoints.push( + oldCoordSys.dataToPoint([ + newData.get(dims[0], idx, true), newData.get(dims[1], idx, true) + ]) + ); + + nextPoints.push(newData.getItemLayout(idx).slice()); + + currStackedPoints.push( + getStackedOnPoint(oldCoordSys, newData, idx) + ); + nextStackedPoints.push(newStackedOnPoints[idx]); + + rawIndices.push(newData.getRawIndex(idx)); + break; + case '-': + var idx = diffItem.idx; + var rawIndex = oldData.getRawIndex(idx); + // Data is replaced. In the case of dynamic data queue + // FIXME FIXME FIXME + if (rawIndex !== idx) { + currPoints.push(oldData.getItemLayout(idx)); + nextPoints.push(newCoordSys.dataToPoint([ + oldData.get(dims[0], idx, true), oldData.get(dims[1], idx, true) + ])); + + currStackedPoints.push(oldStackedOnPoints[idx]); + nextStackedPoints.push( + getStackedOnPoint( + newCoordSys, oldData, idx + ) + ); + + rawIndices.push(rawIndex); + } + else { + pointAdded = false; + } + } + + // Original indices + if (pointAdded) { + status.push(diffItem); + sortedIndices.push(sortedIndices.length); + } + } + + // Diff result may be crossed if all items are changed + // Sort by data index + sortedIndices.sort(function (a, b) { + return rawIndices[a] - rawIndices[b]; + }); + + var sortedCurrPoints = []; + var sortedNextPoints = []; + + var sortedCurrStackedPoints = []; + var sortedNextStackedPoints = []; + + var sortedStatus = []; + for (var i = 0; i < sortedIndices.length; i++) { + var idx = sortedIndices[i]; + sortedCurrPoints[i] = currPoints[idx]; + sortedNextPoints[i] = nextPoints[idx]; + + sortedCurrStackedPoints[i] = currStackedPoints[idx]; + sortedNextStackedPoints[i] = nextStackedPoints[idx]; + + sortedStatus[i] = status[idx]; + } + + return { + current: sortedCurrPoints, + next: sortedNextPoints, + + stackedOnCurrent: sortedCurrStackedPoints, + stackedOnNext: sortedNextStackedPoints, + + status: sortedStatus + }; + }; + + +/***/ }, +/* 102 */ +/***/ function(module, exports, __webpack_require__) { + + // Poly path support NaN point + + + var Path = __webpack_require__(44); + var vec2 = __webpack_require__(16); + + var vec2Min = vec2.min; + var vec2Max = vec2.max; + + var scaleAndAdd = vec2.scaleAndAdd; + var v2Copy = vec2.copy; + + // Temporary variable + var v = []; + var cp0 = []; + var cp1 = []; + + function drawSegment( + ctx, points, start, stop, len, + dir, smoothMin, smoothMax, smooth, smoothMonotone + ) { + var idx = start; + for (var k = 0; k < len; k++) { + var p = points[idx]; + if (idx >= stop || idx < 0 || isNaN(p[0]) || isNaN(p[1])) { + break; + } + + if (idx === start) { + ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]); + v2Copy(cp0, p); + } + else { + if (smooth > 0) { + var prevIdx = idx - dir; + var nextIdx = idx + dir; + + var ratioNextSeg = 0.5; + var prevP = points[prevIdx]; + var nextP = points[nextIdx]; + // Last point + if ((dir > 0 && (idx === len - 1 || isNaN(nextP[0]) || isNaN(nextP[1]))) + || (dir <= 0 && (idx === 0 || isNaN(nextP[0]) || isNaN(nextP[1]))) + ) { + v2Copy(cp1, p); + } + else { + // If next data is null + if (isNaN(nextP[0]) || isNaN(nextP[1])) { + nextP = p; + } + + vec2.sub(v, nextP, prevP); + + var lenPrevSeg; + var lenNextSeg; + if (smoothMonotone === 'x' || smoothMonotone === 'y') { + var dim = smoothMonotone === 'x' ? 0 : 1; + lenPrevSeg = Math.abs(p[dim] - prevP[dim]); + lenNextSeg = Math.abs(p[dim] - nextP[dim]); + } + else { + lenPrevSeg = vec2.dist(p, prevP); + lenNextSeg = vec2.dist(p, nextP); + } + + // Use ratio of seg length + ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg); + + scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg)); + } + // Smooth constraint + vec2Min(cp0, cp0, smoothMax); + vec2Max(cp0, cp0, smoothMin); + vec2Min(cp1, cp1, smoothMax); + vec2Max(cp1, cp1, smoothMin); + + ctx.bezierCurveTo( + cp0[0], cp0[1], + cp1[0], cp1[1], + p[0], p[1] + ); + // cp0 of next segment + scaleAndAdd(cp0, p, v, smooth * ratioNextSeg); + } + else { + ctx.lineTo(p[0], p[1]); + } + } + + idx += dir; + } + + return k; + } + + function getBoundingBox(points, smoothConstraint) { + var ptMin = [Infinity, Infinity]; + var ptMax = [-Infinity, -Infinity]; + if (smoothConstraint) { + for (var i = 0; i < points.length; i++) { + var pt = points[i]; + if (pt[0] < ptMin[0]) { ptMin[0] = pt[0]; } + if (pt[1] < ptMin[1]) { ptMin[1] = pt[1]; } + if (pt[0] > ptMax[0]) { ptMax[0] = pt[0]; } + if (pt[1] > ptMax[1]) { ptMax[1] = pt[1]; } + } + } + return { + min: smoothConstraint ? ptMin : ptMax, + max: smoothConstraint ? ptMax : ptMin + }; + } + + module.exports = { + + Polyline: Path.extend({ + + type: 'ec-polyline', + + shape: { + points: [], + + smooth: 0, + + smoothConstraint: true, + + smoothMonotone: null + }, + + style: { + fill: null, + + stroke: '#000' + }, + + buildPath: function (ctx, shape) { + var points = shape.points; + + var i = 0; + var len = points.length; + + var result = getBoundingBox(points, shape.smoothConstraint); + + while (i < len) { + i += drawSegment( + ctx, points, i, len, len, + 1, result.min, result.max, shape.smooth, + shape.smoothMonotone + ) + 1; + } + } + }), + + Polygon: Path.extend({ + + type: 'ec-polygon', + + shape: { + points: [], + + // Offset between stacked base points and points + stackedOnPoints: [], + + smooth: 0, + + stackedOnSmooth: 0, + + smoothConstraint: true, + + smoothMonotone: null + }, + + buildPath: function (ctx, shape) { + var points = shape.points; + var stackedOnPoints = shape.stackedOnPoints; + + var i = 0; + var len = points.length; + var smoothMonotone = shape.smoothMonotone; + var bbox = getBoundingBox(points, shape.smoothConstraint); + var stackedOnBBox = getBoundingBox(stackedOnPoints, shape.smoothConstraint); + while (i < len) { + var k = drawSegment( + ctx, points, i, len, len, + 1, bbox.min, bbox.max, shape.smooth, + smoothMonotone + ); + drawSegment( + ctx, stackedOnPoints, i + k - 1, len, k, + -1, stackedOnBBox.min, stackedOnBBox.max, shape.stackedOnSmooth, + smoothMonotone + ); + i += k + 1; + + ctx.closePath(); + } + } + }) + }; + + +/***/ }, +/* 103 */ +/***/ function(module, exports) { + + + + module.exports = function (seriesType, defaultSymbolType, legendSymbol, ecModel, api) { + + // Encoding visual for all series include which is filtered for legend drawing + ecModel.eachRawSeriesByType(seriesType, function (seriesModel) { + var data = seriesModel.getData(); + + var symbolType = seriesModel.get('symbol') || defaultSymbolType; + var symbolSize = seriesModel.get('symbolSize'); + + data.setVisual({ + legendSymbol: legendSymbol || symbolType, + symbol: symbolType, + symbolSize: symbolSize + }); + + // Only visible series has each data be visual encoded + if (!ecModel.isSeriesFiltered(seriesModel)) { + if (typeof symbolSize === 'function') { + data.each(function (idx) { + var rawValue = seriesModel.getRawValue(idx); + // FIXME + var params = seriesModel.getDataParams(idx); + data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params)); + }); + } + data.each(function (idx) { + var itemModel = data.getItemModel(idx); + var itemSymbolType = itemModel.get('symbol', true); + var itemSymbolSize = itemModel.get('symbolSize', true); + // If has item symbol + if (itemSymbolType != null) { + data.setItemVisual(idx, 'symbol', itemSymbolType); + } + if (itemSymbolSize != null) { + // PENDING Transform symbolSize ? + data.setItemVisual(idx, 'symbolSize', itemSymbolSize); + } + }); + } + }); + }; + + +/***/ }, +/* 104 */ +/***/ function(module, exports) { + + + + module.exports = function (seriesType, ecModel, api) { + ecModel.eachSeriesByType(seriesType, function (seriesModel) { + var data = seriesModel.getData(); + var coordSys = seriesModel.coordinateSystem; + + var dims = coordSys.dimensions; + data.each(dims, function (x, y, idx) { + var point; + if (!isNaN(x) && !isNaN(y)) { + point = coordSys.dataToPoint([x, y]); + } + else { + // Also {Array.}, not undefined to avoid if...else... statement + point = [NaN, NaN]; + } + + data.setItemLayout(idx, point); + }, true); + }); + }; + + +/***/ }, +/* 105 */ +/***/ function(module, exports) { + + + var samplers = { + average: function (frame) { + var sum = 0; + var count = 0; + for (var i = 0; i < frame.length; i++) { + if (!isNaN(frame[i])) { + sum += frame[i]; + count++; + } + } + // Return NaN if count is 0 + return count === 0 ? NaN : sum / count; + }, + sum: function (frame) { + var sum = 0; + for (var i = 0; i < frame.length; i++) { + // Ignore NaN + sum += frame[i] || 0; + } + return sum; + }, + max: function (frame) { + var max = -Infinity; + for (var i = 0; i < frame.length; i++) { + frame[i] > max && (max = frame[i]); + } + return max; + }, + min: function (frame) { + var min = Infinity; + for (var i = 0; i < frame.length; i++) { + frame[i] < min && (min = frame[i]); + } + return min; + } + }; + + var indexSampler = function (frame, value) { + return Math.round(frame.length / 2); + }; + module.exports = function (seriesType, ecModel, api) { + ecModel.eachSeriesByType(seriesType, function (seriesModel) { + var data = seriesModel.getData(); + var sampling = seriesModel.get('sampling'); + var coordSys = seriesModel.coordinateSystem; + // Only cartesian2d support down sampling + if (coordSys.type === 'cartesian2d' && sampling) { + var baseAxis = coordSys.getBaseAxis(); + var valueAxis = coordSys.getOtherAxis(baseAxis); + var extent = baseAxis.getExtent(); + // Coordinste system has been resized + var size = extent[1] - extent[0]; + var rate = Math.round(data.count() / size); + if (rate > 1) { + var sampler; + if (typeof sampling === 'string') { + sampler = samplers[sampling]; + } + else if (typeof sampling === 'function') { + sampler = sampling; + } + if (sampler) { + data = data.downSample( + valueAxis.dim, 1 / rate, sampler, indexSampler + ); + seriesModel.setData(data); + } + } + } + }, this); + }; + + +/***/ }, +/* 106 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + + __webpack_require__(107); + + __webpack_require__(124); + + // Grid view + __webpack_require__(1).extendComponentView({ + + type: 'grid', + + render: function (gridModel, ecModel) { + this.group.removeAll(); + if (gridModel.get('show')) { + this.group.add(new graphic.Rect({ + shape:gridModel.coordinateSystem.getRect(), + style: zrUtil.defaults({ + fill: gridModel.get('backgroundColor') + }, gridModel.getItemStyle()), + silent: true + })); + } + } + }); + + +/***/ }, +/* 107 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Grid is a region which contains at most 4 cartesian systems + * + * TODO Default cartesian + */ + var factory = exports; + + var layout = __webpack_require__(21); + var axisHelper = __webpack_require__(108); + + var zrUtil = __webpack_require__(3); + var Cartesian2D = __webpack_require__(114); + var Axis2D = __webpack_require__(116); + + var each = zrUtil.each; + + var ifAxisCrossZero = axisHelper.ifAxisCrossZero; + var niceScaleExtent = axisHelper.niceScaleExtent; + + // 依赖 GridModel, AxisModel 做预处理 + __webpack_require__(119); + + /** + * Check if the axis is used in the specified grid + * @inner + */ + function isAxisUsedInTheGrid(axisModel, gridModel, ecModel) { + return ecModel.getComponent('grid', axisModel.get('gridIndex')) === gridModel; + } + + function getLabelUnionRect(axis) { + var axisModel = axis.model; + var labels = axisModel.getFormattedLabels(); + var rect; + var step = 1; + var labelCount = labels.length; + if (labelCount > 40) { + // Simple optimization for large amount of labels + step = Math.ceil(labelCount / 40); + } + for (var i = 0; i < labelCount; i += step) { + if (!axis.isLabelIgnored(i)) { + var singleRect = axisModel.getTextRect(labels[i]); + // FIXME consider label rotate + rect ? rect.union(singleRect) : (rect = singleRect); + } + } + return rect; + } + + function Grid(gridModel, ecModel, api) { + /** + * @type {Object.} + * @private + */ + this._coordsMap = {}; + + /** + * @type {Array.} + * @private + */ + this._coordsList = []; + + /** + * @type {Object.} + * @private + */ + this._axesMap = {}; + + /** + * @type {Array.} + * @private + */ + this._axesList = []; + + this._initCartesian(gridModel, ecModel, api); + + this._model = gridModel; + } + + var gridProto = Grid.prototype; + + gridProto.type = 'grid'; + + gridProto.getRect = function () { + return this._rect; + }; + + gridProto.update = function (ecModel, api) { + + var axesMap = this._axesMap; + + this._updateScale(ecModel, this._model); + + function ifAxisCanNotOnZero(otherAxisDim) { + var axes = axesMap[otherAxisDim]; + for (var idx in axes) { + var axis = axes[idx]; + if (axis && (axis.type === 'category' || !ifAxisCrossZero(axis))) { + return true; + } + } + return false; + } + + each(axesMap.x, function (xAxis) { + niceScaleExtent(xAxis, xAxis.model); + }); + each(axesMap.y, function (yAxis) { + niceScaleExtent(yAxis, yAxis.model); + }); + // Fix configuration + each(axesMap.x, function (xAxis) { + // onZero can not be enabled in these two situations + // 1. When any other axis is a category axis + // 2. When any other axis not across 0 point + if (ifAxisCanNotOnZero('y')) { + xAxis.onZero = false; + } + }); + each(axesMap.y, function (yAxis) { + if (ifAxisCanNotOnZero('x')) { + yAxis.onZero = false; + } + }); + + // Resize again if containLabel is enabled + // FIXME It may cause getting wrong grid size in data processing stage + this.resize(this._model, api); + }; + + /** + * Resize the grid + * @param {module:echarts/coord/cartesian/GridModel} gridModel + * @param {module:echarts/ExtensionAPI} api + */ + gridProto.resize = function (gridModel, api) { + + var gridRect = layout.getLayoutRect( + gridModel.getBoxLayoutParams(), { + width: api.getWidth(), + height: api.getHeight() + }); + + this._rect = gridRect; + + var axesList = this._axesList; + + adjustAxes(); + + // Minus label size + if (gridModel.get('containLabel')) { + each(axesList, function (axis) { + if (!axis.model.get('axisLabel.inside')) { + var labelUnionRect = getLabelUnionRect(axis); + if (labelUnionRect) { + var dim = axis.isHorizontal() ? 'height' : 'width'; + var margin = axis.model.get('axisLabel.margin'); + gridRect[dim] -= labelUnionRect[dim] + margin; + if (axis.position === 'top') { + gridRect.y += labelUnionRect.height + margin; + } + else if (axis.position === 'left') { + gridRect.x += labelUnionRect.width + margin; + } + } + } + }); + + adjustAxes(); + } + + function adjustAxes() { + each(axesList, function (axis) { + var isHorizontal = axis.isHorizontal(); + var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height]; + var idx = axis.inverse ? 1 : 0; + axis.setExtent(extent[idx], extent[1 - idx]); + updateAxisTransfrom(axis, isHorizontal ? gridRect.x : gridRect.y); + }); + } + }; + + /** + * @param {string} axisType + * @param {ndumber} [axisIndex] + */ + gridProto.getAxis = function (axisType, axisIndex) { + var axesMapOnDim = this._axesMap[axisType]; + if (axesMapOnDim != null) { + if (axisIndex == null) { + // Find first axis + for (var name in axesMapOnDim) { + return axesMapOnDim[name]; + } + } + return axesMapOnDim[axisIndex]; + } + }; + + gridProto.getCartesian = function (xAxisIndex, yAxisIndex) { + var key = 'x' + xAxisIndex + 'y' + yAxisIndex; + return this._coordsMap[key]; + }; + + /** + * Initialize cartesian coordinate systems + * @private + */ + gridProto._initCartesian = function (gridModel, ecModel, api) { + var axisPositionUsed = { + left: false, + right: false, + top: false, + bottom: false + }; + + var axesMap = { + x: {}, + y: {} + }; + var axesCount = { + x: 0, + y: 0 + }; + + /// Create axis + ecModel.eachComponent('xAxis', createAxisCreator('x'), this); + ecModel.eachComponent('yAxis', createAxisCreator('y'), this); + + if (!axesCount.x || !axesCount.y) { + // Roll back when there no either x or y axis + this._axesMap = {}; + this._axesList = []; + return; + } + + this._axesMap = axesMap; + + /// Create cartesian2d + each(axesMap.x, function (xAxis, xAxisIndex) { + each(axesMap.y, function (yAxis, yAxisIndex) { + var key = 'x' + xAxisIndex + 'y' + yAxisIndex; + var cartesian = new Cartesian2D(key); + + cartesian.grid = this; + + this._coordsMap[key] = cartesian; + this._coordsList.push(cartesian); + + cartesian.addAxis(xAxis); + cartesian.addAxis(yAxis); + }, this); + }, this); + + function createAxisCreator(axisType) { + return function (axisModel, idx) { + if (!isAxisUsedInTheGrid(axisModel, gridModel, ecModel)) { + return; + } + + var axisPosition = axisModel.get('position'); + if (axisType === 'x') { + // Fix position + if (axisPosition !== 'top' && axisPosition !== 'bottom') { + // Default bottom of X + axisPosition = 'bottom'; + } + if (axisPositionUsed[axisPosition]) { + axisPosition = axisPosition === 'top' ? 'bottom' : 'top'; + } + } + else { + // Fix position + if (axisPosition !== 'left' && axisPosition !== 'right') { + // Default left of Y + axisPosition = 'left'; + } + if (axisPositionUsed[axisPosition]) { + axisPosition = axisPosition === 'left' ? 'right' : 'left'; + } + } + axisPositionUsed[axisPosition] = true; + + var axis = new Axis2D( + axisType, axisHelper.createScaleByModel(axisModel), + [0, 0], + axisModel.get('type'), + axisPosition + ); + + var isCategory = axis.type === 'category'; + axis.onBand = isCategory && axisModel.get('boundaryGap'); + axis.inverse = axisModel.get('inverse'); + + axis.onZero = axisModel.get('axisLine.onZero'); + + // Inject axis into axisModel + axisModel.axis = axis; + + // Inject axisModel into axis + axis.model = axisModel; + + // Index of axis, can be used as key + axis.index = idx; + + this._axesList.push(axis); + + axesMap[axisType][idx] = axis; + axesCount[axisType]++; + }; + } + }; + + /** + * Update cartesian properties from series + * @param {module:echarts/model/Option} option + * @private + */ + gridProto._updateScale = function (ecModel, gridModel) { + // Reset scale + zrUtil.each(this._axesList, function (axis) { + axis.scale.setExtent(Infinity, -Infinity); + }); + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.get('coordinateSystem') === 'cartesian2d') { + var xAxisIndex = seriesModel.get('xAxisIndex'); + var yAxisIndex = seriesModel.get('yAxisIndex'); + + var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex); + var yAxisModel = ecModel.getComponent('yAxis', yAxisIndex); + + if (!isAxisUsedInTheGrid(xAxisModel, gridModel, ecModel) + || !isAxisUsedInTheGrid(yAxisModel, gridModel, ecModel) + ) { + return; + } + + var cartesian = this.getCartesian(xAxisIndex, yAxisIndex); + var data = seriesModel.getData(); + var xAxis = cartesian.getAxis('x'); + var yAxis = cartesian.getAxis('y'); + + if (data.type === 'list') { + unionExtent(data, xAxis, seriesModel); + unionExtent(data, yAxis, seriesModel); + } + } + }, this); + + function unionExtent(data, axis, seriesModel) { + each(seriesModel.coordDimToDataDim(axis.dim), function (dim) { + axis.scale.unionExtent(data.getDataExtent( + dim, axis.scale.type !== 'ordinal' + )); + }); + } + }; + + /** + * @inner + */ + function updateAxisTransfrom(axis, coordBase) { + var axisExtent = axis.getExtent(); + var axisExtentSum = axisExtent[0] + axisExtent[1]; + + // Fast transform + axis.toGlobalCoord = axis.dim === 'x' + ? function (coord) { + return coord + coordBase; + } + : function (coord) { + return axisExtentSum - coord + coordBase; + }; + axis.toLocalCoord = axis.dim === 'x' + ? function (coord) { + return coord - coordBase; + } + : function (coord) { + return axisExtentSum - coord + coordBase; + }; + } + + Grid.create = function (ecModel, api) { + var grids = []; + ecModel.eachComponent('grid', function (gridModel, idx) { + var grid = new Grid(gridModel, ecModel, api); + grid.name = 'grid_' + idx; + grid.resize(gridModel, api); + + gridModel.coordinateSystem = grid; + + grids.push(grid); + }); + + // Inject the coordinateSystems into seriesModel + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.get('coordinateSystem') !== 'cartesian2d') { + return; + } + var xAxisIndex = seriesModel.get('xAxisIndex'); + // TODO Validate + var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex); + var grid = grids[xAxisModel.get('gridIndex')]; + seriesModel.coordinateSystem = grid.getCartesian( + xAxisIndex, seriesModel.get('yAxisIndex') + ); + }); + + return grids; + }; + + // For deciding which dimensions to use when creating list data + Grid.dimensions = Cartesian2D.prototype.dimensions; + + __webpack_require__(25).register('cartesian2d', Grid); + + module.exports = Grid; + + +/***/ }, +/* 108 */ +/***/ function(module, exports, __webpack_require__) { + + + + var OrdinalScale = __webpack_require__(109); + var IntervalScale = __webpack_require__(111); + __webpack_require__(112); + __webpack_require__(113); + var Scale = __webpack_require__(110); + + var numberUtil = __webpack_require__(7); + var zrUtil = __webpack_require__(3); + var textContain = __webpack_require__(14); + var axisHelper = {}; + + /** + * Get axis scale extent before niced. + */ + axisHelper.getScaleExtent = function (axis, model) { + var scale = axis.scale; + var originalExtent = scale.getExtent(); + var span = originalExtent[1] - originalExtent[0]; + if (scale.type === 'ordinal') { + // If series has no data, scale extent may be wrong + if (!isFinite(span)) { + return [0, 0]; + } + else { + return originalExtent; + } + } + var min = model.getMin ? model.getMin() : model.get('min'); + var max = model.getMax ? model.getMax() : model.get('max'); + var crossZero = model.getNeedCrossZero + ? model.getNeedCrossZero() : !model.get('scale'); + var boundaryGap = model.get('boundaryGap'); + if (!zrUtil.isArray(boundaryGap)) { + boundaryGap = [boundaryGap || 0, boundaryGap || 0]; + } + boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], 1); + boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], 1); + var fixMin = true; + var fixMax = true; + // Add boundary gap + if (min == null) { + min = originalExtent[0] - boundaryGap[0] * span; + fixMin = false; + } + if (max == null) { + max = originalExtent[1] + boundaryGap[1] * span; + fixMax = false; + } + // TODO Only one data + if (min === 'dataMin') { + min = originalExtent[0]; + } + if (max === 'dataMax') { + max = originalExtent[1]; + } + // Evaluate if axis needs cross zero + if (crossZero) { + // Axis is over zero and min is not set + if (min > 0 && max > 0 && !fixMin) { + min = 0; + } + // Axis is under zero and max is not set + if (min < 0 && max < 0 && !fixMax) { + max = 0; + } + } + return [min, max]; + }; + + axisHelper.niceScaleExtent = function (axis, model) { + var scale = axis.scale; + var extent = axisHelper.getScaleExtent(axis, model); + var fixMin = model.get('min') != null; + var fixMax = model.get('max') != null; + scale.setExtent(extent[0], extent[1]); + scale.niceExtent(model.get('splitNumber'), fixMin, fixMax); + + // If some one specified the min, max. And the default calculated interval + // is not good enough. He can specify the interval. It is often appeared + // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard + // to be 60. + // FIXME + var interval = model.get('interval'); + if (interval != null) { + scale.setInterval && scale.setInterval(interval); + } + }; + + /** + * @param {module:echarts/model/Model} model + * @param {string} [axisType] Default retrieve from model.type + * @return {module:echarts/scale/*} + */ + axisHelper.createScaleByModel = function(model, axisType) { + axisType = axisType || model.get('type'); + if (axisType) { + switch (axisType) { + // Buildin scale + case 'category': + return new OrdinalScale( + model.getCategories(), [Infinity, -Infinity] + ); + case 'value': + return new IntervalScale(); + // Extended scale, like time and log + default: + return (Scale.getClass(axisType) || IntervalScale).create(model); + } + } + }; + + /** + * Check if the axis corss 0 + */ + axisHelper.ifAxisCrossZero = function (axis) { + var dataExtent = axis.scale.getExtent(); + var min = dataExtent[0]; + var max = dataExtent[1]; + return !((min > 0 && max > 0) || (min < 0 && max < 0)); + }; + + /** + * @param {Array.} tickCoords In axis self coordinate. + * @param {Array.} labels + * @param {string} font + * @param {boolean} isAxisHorizontal + * @return {number} + */ + axisHelper.getAxisLabelInterval = function (tickCoords, labels, font, isAxisHorizontal) { + // FIXME + // 不同角的axis和label,不只是horizontal和vertical. + + var textSpaceTakenRect; + var autoLabelInterval = 0; + var accumulatedLabelInterval = 0; + + var step = 1; + if (labels.length > 40) { + // Simple optimization for large amount of labels + step = Math.round(labels.length / 40); + } + for (var i = 0; i < tickCoords.length; i += step) { + var tickCoord = tickCoords[i]; + var rect = textContain.getBoundingRect( + labels[i], font, 'center', 'top' + ); + rect[isAxisHorizontal ? 'x' : 'y'] += tickCoord; + rect[isAxisHorizontal ? 'width' : 'height'] *= 1.5; + if (!textSpaceTakenRect) { + textSpaceTakenRect = rect.clone(); + } + // There is no space for current label; + else if (textSpaceTakenRect.intersect(rect)) { + accumulatedLabelInterval++; + autoLabelInterval = Math.max(autoLabelInterval, accumulatedLabelInterval); + } + else { + textSpaceTakenRect.union(rect); + // Reset + accumulatedLabelInterval = 0; + } + } + if (autoLabelInterval === 0 && step > 1) { + return step; + } + return autoLabelInterval * step; + }; + + /** + * @param {Object} axis + * @param {Function} labelFormatter + * @return {Array.} + */ + axisHelper.getFormattedLabels = function (axis, labelFormatter) { + var scale = axis.scale; + var labels = scale.getTicksLabels(); + var ticks = scale.getTicks(); + if (typeof labelFormatter === 'string') { + labelFormatter = (function (tpl) { + return function (val) { + return tpl.replace('{value}', val); + }; + })(labelFormatter); + return zrUtil.map(labels, labelFormatter); + } + else if (typeof labelFormatter === 'function') { + return zrUtil.map(ticks, function (tick, idx) { + return labelFormatter( + axis.type === 'category' ? scale.getLabel(tick) : tick, + idx + ); + }, this); + } + else { + return labels; + } + }; + + module.exports = axisHelper; + + +/***/ }, +/* 109 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Linear continuous scale + * @module echarts/coord/scale/Ordinal + * + * http://en.wikipedia.org/wiki/Level_of_measurement + */ + + // FIXME only one data + + + var zrUtil = __webpack_require__(3); + var Scale = __webpack_require__(110); + + var scaleProto = Scale.prototype; + + var OrdinalScale = Scale.extend({ + + type: 'ordinal', + + init: function (data, extent) { + this._data = data; + this._extent = extent || [0, data.length - 1]; + }, + + parse: function (val) { + return typeof val === 'string' + ? zrUtil.indexOf(this._data, val) + // val might be float. + : Math.round(val); + }, + + contain: function (rank) { + rank = this.parse(rank); + return scaleProto.contain.call(this, rank) + && this._data[rank] != null; + }, + + /** + * Normalize given rank or name to linear [0, 1] + * @param {number|string} [val] + * @return {number} + */ + normalize: function (val) { + return scaleProto.normalize.call(this, this.parse(val)); + }, + + scale: function (val) { + return Math.round(scaleProto.scale.call(this, val)); + }, + + /** + * @return {Array} + */ + getTicks: function () { + var ticks = []; + var extent = this._extent; + var rank = extent[0]; + + while (rank <= extent[1]) { + ticks.push(rank); + rank++; + } + + return ticks; + }, + + /** + * Get item on rank n + * @param {number} n + * @return {string} + */ + getLabel: function (n) { + return this._data[n]; + }, + + /** + * @return {number} + */ + count: function () { + return this._extent[1] - this._extent[0] + 1; + }, + + niceTicks: zrUtil.noop, + niceExtent: zrUtil.noop + }); + + /** + * @return {module:echarts/scale/Time} + */ + OrdinalScale.create = function () { + return new OrdinalScale(); + }; + + module.exports = OrdinalScale; + + +/***/ }, +/* 110 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * // Scale class management + * @module echarts/scale/Scale + */ + + + var clazzUtil = __webpack_require__(9); + + function Scale() { + /** + * Extent + * @type {Array.} + * @protected + */ + this._extent = [Infinity, -Infinity]; + + /** + * Step is calculated in adjustExtent + * @type {Array.} + * @protected + */ + this._interval = 0; + + this.init && this.init.apply(this, arguments); + } + + var scaleProto = Scale.prototype; + + /** + * Parse input val to valid inner number. + * @param {*} val + * @return {number} + */ + scaleProto.parse = function (val) { + // Notice: This would be a trap here, If the implementation + // of this method depends on extent, and this method is used + // before extent set (like in dataZoom), it would be wrong. + // Nevertheless, parse does not depend on extent generally. + return val; + }; + + scaleProto.contain = function (val) { + var extent = this._extent; + return val >= extent[0] && val <= extent[1]; + }; + + /** + * Normalize value to linear [0, 1], return 0.5 if extent span is 0 + * @param {number} val + * @return {number} + */ + scaleProto.normalize = function (val) { + var extent = this._extent; + if (extent[1] === extent[0]) { + return 0.5; + } + return (val - extent[0]) / (extent[1] - extent[0]); + }; + + /** + * Scale normalized value + * @param {number} val + * @return {number} + */ + scaleProto.scale = function (val) { + var extent = this._extent; + return val * (extent[1] - extent[0]) + extent[0]; + }; + + /** + * Set extent from data + * @param {Array.} other + */ + scaleProto.unionExtent = function (other) { + var extent = this._extent; + other[0] < extent[0] && (extent[0] = other[0]); + other[1] > extent[1] && (extent[1] = other[1]); + // not setExtent because in log axis it may transformed to power + // this.setExtent(extent[0], extent[1]); + }; + + /** + * Get extent + * @return {Array.} + */ + scaleProto.getExtent = function () { + return this._extent.slice(); + }; + + /** + * Set extent + * @param {number} start + * @param {number} end + */ + scaleProto.setExtent = function (start, end) { + var thisExtent = this._extent; + if (!isNaN(start)) { + thisExtent[0] = start; + } + if (!isNaN(end)) { + thisExtent[1] = end; + } + }; + + /** + * @return {Array.} + */ + scaleProto.getTicksLabels = function () { + var labels = []; + var ticks = this.getTicks(); + for (var i = 0; i < ticks.length; i++) { + labels.push(this.getLabel(ticks[i])); + } + return labels; + }; + + clazzUtil.enableClassExtend(Scale); + clazzUtil.enableClassManagement(Scale, { + registerWhenExtend: true + }); + + module.exports = Scale; + + +/***/ }, +/* 111 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Interval scale + * @module echarts/scale/Interval + */ + + + + var numberUtil = __webpack_require__(7); + var formatUtil = __webpack_require__(6); + var Scale = __webpack_require__(110); + + var mathFloor = Math.floor; + var mathCeil = Math.ceil; + /** + * @alias module:echarts/coord/scale/Interval + * @constructor + */ + var IntervalScale = Scale.extend({ + + type: 'interval', + + _interval: 0, + + setExtent: function (start, end) { + var thisExtent = this._extent; + //start,end may be a Number like '25',so... + if (!isNaN(start)) { + thisExtent[0] = parseFloat(start); + } + if (!isNaN(end)) { + thisExtent[1] = parseFloat(end); + } + }, + + unionExtent: function (other) { + var extent = this._extent; + other[0] < extent[0] && (extent[0] = other[0]); + other[1] > extent[1] && (extent[1] = other[1]); + + // unionExtent may called by it's sub classes + IntervalScale.prototype.setExtent.call(this, extent[0], extent[1]); + }, + /** + * Get interval + */ + getInterval: function () { + if (!this._interval) { + this.niceTicks(); + } + return this._interval; + }, + + /** + * Set interval + */ + setInterval: function (interval) { + this._interval = interval; + // Dropped auto calculated niceExtent and use user setted extent + // We assume user wan't to set both interval, min, max to get a better result + this._niceExtent = this._extent.slice(); + }, + + /** + * @return {Array.} + */ + getTicks: function () { + if (!this._interval) { + this.niceTicks(); + } + var interval = this._interval; + var extent = this._extent; + var ticks = []; + + // Consider this case: using dataZoom toolbox, zoom and zoom. + var safeLimit = 10000; + + if (interval) { + var niceExtent = this._niceExtent; + if (extent[0] < niceExtent[0]) { + ticks.push(extent[0]); + } + var tick = niceExtent[0]; + while (tick <= niceExtent[1]) { + ticks.push(tick); + // Avoid rounding error + tick = numberUtil.round(tick + interval); + if (ticks.length > safeLimit) { + return []; + } + } + if (extent[1] > niceExtent[1]) { + ticks.push(extent[1]); + } + } + + return ticks; + }, + + /** + * @return {Array.} + */ + getTicksLabels: function () { + var labels = []; + var ticks = this.getTicks(); + for (var i = 0; i < ticks.length; i++) { + labels.push(this.getLabel(ticks[i])); + } + return labels; + }, + + /** + * @param {number} n + * @return {number} + */ + getLabel: function (data) { + return formatUtil.addCommas(data); + }, + + /** + * Update interval and extent of intervals for nice ticks + * + * @param {number} [splitNumber = 5] Desired number of ticks + */ + niceTicks: function (splitNumber) { + splitNumber = splitNumber || 5; + var extent = this._extent; + var span = extent[1] - extent[0]; + if (!isFinite(span)) { + return; + } + // User may set axis min 0 and data are all negative + // FIXME If it needs to reverse ? + if (span < 0) { + span = -span; + extent.reverse(); + } + + // From "Nice Numbers for Graph Labels" of Graphic Gems + // var niceSpan = numberUtil.nice(span, false); + var step = numberUtil.nice(span / splitNumber, true); + + // Niced extent inside original extent + var niceExtent = [ + numberUtil.round(mathCeil(extent[0] / step) * step), + numberUtil.round(mathFloor(extent[1] / step) * step) + ]; + + this._interval = step; + this._niceExtent = niceExtent; + }, + + /** + * Nice extent. + * @param {number} [splitNumber = 5] Given approx tick number + * @param {boolean} [fixMin=false] + * @param {boolean} [fixMax=false] + */ + niceExtent: function (splitNumber, fixMin, fixMax) { + var extent = this._extent; + // If extent start and end are same, expand them + if (extent[0] === extent[1]) { + if (extent[0] !== 0) { + // Expand extent + var expandSize = extent[0] / 2; + extent[0] -= expandSize; + extent[1] += expandSize; + } + else { + extent[1] = 1; + } + } + var span = extent[1] - extent[0]; + // If there are no data and extent are [Infinity, -Infinity] + if (!isFinite(span)) { + extent[0] = 0; + extent[1] = 1; + } + + this.niceTicks(splitNumber); + + // var extent = this._extent; + var interval = this._interval; + + if (!fixMin) { + extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval); + } + if (!fixMax) { + extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval); + } + } + }); + + /** + * @return {module:echarts/scale/Time} + */ + IntervalScale.create = function () { + return new IntervalScale(); + }; + + module.exports = IntervalScale; + + + +/***/ }, +/* 112 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Interval scale + * @module echarts/coord/scale/Time + */ + + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var formatUtil = __webpack_require__(6); + + var IntervalScale = __webpack_require__(111); + + var intervalScaleProto = IntervalScale.prototype; + + var mathCeil = Math.ceil; + var mathFloor = Math.floor; + var ONE_DAY = 3600000 * 24; + + // FIXME 公用? + var bisect = function (a, x, lo, hi) { + while (lo < hi) { + var mid = lo + hi >>> 1; + if (a[mid][2] < x) { + lo = mid + 1; + } + else { + hi = mid; + } + } + return lo; + }; + + /** + * @alias module:echarts/coord/scale/Time + * @constructor + */ + var TimeScale = IntervalScale.extend({ + type: 'time', + + // Overwrite + getLabel: function (val) { + var stepLvl = this._stepLvl; + + var date = new Date(val); + + return formatUtil.formatTime(stepLvl[0], date); + }, + + // Overwrite + niceExtent: function (approxTickNum, fixMin, fixMax) { + var extent = this._extent; + // If extent start and end are same, expand them + if (extent[0] === extent[1]) { + // Expand extent + extent[0] -= ONE_DAY; + extent[1] += ONE_DAY; + } + // If there are no data and extent are [Infinity, -Infinity] + if (extent[1] === -Infinity && extent[0] === Infinity) { + var d = new Date(); + extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate()); + extent[0] = extent[1] - ONE_DAY; + } + + this.niceTicks(approxTickNum, fixMin, fixMax); + + // var extent = this._extent; + var interval = this._interval; + + if (!fixMin) { + extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval); + } + if (!fixMax) { + extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval); + } + }, + + // Overwrite + niceTicks: function (approxTickNum) { + approxTickNum = approxTickNum || 10; + + var extent = this._extent; + var span = extent[1] - extent[0]; + var approxInterval = span / approxTickNum; + var scaleLevelsLen = scaleLevels.length; + var idx = bisect(scaleLevels, approxInterval, 0, scaleLevelsLen); + + var level = scaleLevels[Math.min(idx, scaleLevelsLen - 1)]; + var interval = level[2]; + // Same with interval scale if span is much larger than 1 year + if (level[0] === 'year') { + var yearSpan = span / interval; + + // From "Nice Numbers for Graph Labels" of Graphic Gems + // var niceYearSpan = numberUtil.nice(yearSpan, false); + var yearStep = numberUtil.nice(yearSpan / approxTickNum, true); + + interval *= yearStep; + } + + var niceExtent = [ + mathCeil(extent[0] / interval) * interval, + mathFloor(extent[1] / interval) * interval + ]; + + this._stepLvl = level; + // Interval will be used in getTicks + this._interval = interval; + this._niceExtent = niceExtent; + }, + + parse: function (val) { + // val might be float. + return +numberUtil.parseDate(val); + } + }); + + zrUtil.each(['contain', 'normalize'], function (methodName) { + TimeScale.prototype[methodName] = function (val) { + return intervalScaleProto[methodName].call(this, this.parse(val)); + }; + }); + + // Steps from d3 + var scaleLevels = [ + // Format step interval + ['hh:mm:ss', 1, 1000], // 1s + ['hh:mm:ss', 5, 1000 * 5], // 5s + ['hh:mm:ss', 10, 1000 * 10], // 10s + ['hh:mm:ss', 15, 1000 * 15], // 15s + ['hh:mm:ss', 30, 1000 * 30], // 30s + ['hh:mm\nMM-dd',1, 60000], // 1m + ['hh:mm\nMM-dd',5, 60000 * 5], // 5m + ['hh:mm\nMM-dd',10, 60000 * 10], // 10m + ['hh:mm\nMM-dd',15, 60000 * 15], // 15m + ['hh:mm\nMM-dd',30, 60000 * 30], // 30m + ['hh:mm\nMM-dd',1, 3600000], // 1h + ['hh:mm\nMM-dd',2, 3600000 * 2], // 2h + ['hh:mm\nMM-dd',6, 3600000 * 6], // 6h + ['hh:mm\nMM-dd',12, 3600000 * 12], // 12h + ['MM-dd\nyyyy', 1, ONE_DAY], // 1d + ['week', 7, ONE_DAY * 7], // 7d + ['month', 1, ONE_DAY * 31], // 1M + ['quarter', 3, ONE_DAY * 380 / 4], // 3M + ['half-year', 6, ONE_DAY * 380 / 2], // 6M + ['year', 1, ONE_DAY * 380] // 1Y + ]; + + /** + * @return {module:echarts/scale/Time} + */ + TimeScale.create = function () { + return new TimeScale(); + }; + + module.exports = TimeScale; + + +/***/ }, +/* 113 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Log scale + * @module echarts/scale/Log + */ + + + var zrUtil = __webpack_require__(3); + var Scale = __webpack_require__(110); + var numberUtil = __webpack_require__(7); + + // Use some method of IntervalScale + var IntervalScale = __webpack_require__(111); + + var scaleProto = Scale.prototype; + var intervalScaleProto = IntervalScale.prototype; + + var mathFloor = Math.floor; + var mathCeil = Math.ceil; + var mathPow = Math.pow; + + var LOG_BASE = 10; + var mathLog = Math.log; + + var LogScale = Scale.extend({ + + type: 'log', + + /** + * @return {Array.} + */ + getTicks: function () { + return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) { + return numberUtil.round(mathPow(LOG_BASE, val)); + }); + }, + + /** + * @param {number} val + * @return {string} + */ + getLabel: intervalScaleProto.getLabel, + + /** + * @param {number} val + * @return {number} + */ + scale: function (val) { + val = scaleProto.scale.call(this, val); + return mathPow(LOG_BASE, val); + }, + + /** + * @param {number} start + * @param {number} end + */ + setExtent: function (start, end) { + start = mathLog(start) / mathLog(LOG_BASE); + end = mathLog(end) / mathLog(LOG_BASE); + intervalScaleProto.setExtent.call(this, start, end); + }, + + /** + * @return {number} end + */ + getExtent: function () { + var extent = scaleProto.getExtent.call(this); + extent[0] = mathPow(LOG_BASE, extent[0]); + extent[1] = mathPow(LOG_BASE, extent[1]); + return extent; + }, + + /** + * @param {Array.} extent + */ + unionExtent: function (extent) { + extent[0] = mathLog(extent[0]) / mathLog(LOG_BASE); + extent[1] = mathLog(extent[1]) / mathLog(LOG_BASE); + scaleProto.unionExtent.call(this, extent); + }, + + /** + * Update interval and extent of intervals for nice ticks + * @param {number} [approxTickNum = 10] Given approx tick number + */ + niceTicks: function (approxTickNum) { + approxTickNum = approxTickNum || 10; + var extent = this._extent; + var span = extent[1] - extent[0]; + if (span === Infinity || span <= 0) { + return; + } + + var interval = mathPow(10, mathFloor(mathLog(span / approxTickNum) / Math.LN10)); + var err = approxTickNum / span * interval; + + // Filter ticks to get closer to the desired count. + if (err <= 0.5) { + interval *= 10; + } + var niceExtent = [ + numberUtil.round(mathCeil(extent[0] / interval) * interval), + numberUtil.round(mathFloor(extent[1] / interval) * interval) + ]; + + this._interval = interval; + this._niceExtent = niceExtent; + }, + + /** + * Nice extent. + * @param {number} [approxTickNum = 10] Given approx tick number + * @param {boolean} [fixMin=false] + * @param {boolean} [fixMax=false] + */ + niceExtent: intervalScaleProto.niceExtent + }); + + zrUtil.each(['contain', 'normalize'], function (methodName) { + LogScale.prototype[methodName] = function (val) { + val = mathLog(val) / mathLog(LOG_BASE); + return scaleProto[methodName].call(this, val); + }; + }); + + LogScale.create = function () { + return new LogScale(); + }; + + module.exports = LogScale; + + +/***/ }, +/* 114 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var Cartesian = __webpack_require__(115); + + function Cartesian2D(name) { + + Cartesian.call(this, name); + } + + Cartesian2D.prototype = { + + constructor: Cartesian2D, + + type: 'cartesian2d', + + /** + * @type {Array.} + * @readOnly + */ + dimensions: ['x', 'y'], + + /** + * Base axis will be used on stacking. + * + * @return {module:echarts/coord/cartesian/Axis2D} + */ + getBaseAxis: function () { + return this.getAxesByScale('ordinal')[0] + || this.getAxesByScale('time')[0] + || this.getAxis('x'); + }, + + /** + * If contain point + * @param {Array.} point + * @return {boolean} + */ + containPoint: function (point) { + var axisX = this.getAxis('x'); + var axisY = this.getAxis('y'); + return axisX.contain(axisX.toLocalCoord(point[0])) + && axisY.contain(axisY.toLocalCoord(point[1])); + }, + + /** + * If contain data + * @param {Array.} data + * @return {boolean} + */ + containData: function (data) { + return this.getAxis('x').containData(data[0]) + && this.getAxis('y').containData(data[1]); + }, + + /** + * Convert series data to an array of points + * @param {module:echarts/data/List} data + * @param {boolean} stack + * @return {Array} + * Return array of points. For example: + * `[[10, 10], [20, 20], [30, 30]]` + */ + dataToPoints: function (data, stack) { + return data.mapArray(['x', 'y'], function (x, y) { + return this.dataToPoint([x, y]); + }, stack, this); + }, + + /** + * @param {Array.} data + * @param {boolean} [clamp=false] + * @return {Array.} + */ + dataToPoint: function (data, clamp) { + var xAxis = this.getAxis('x'); + var yAxis = this.getAxis('y'); + return [ + xAxis.toGlobalCoord(xAxis.dataToCoord(data[0], clamp)), + yAxis.toGlobalCoord(yAxis.dataToCoord(data[1], clamp)) + ]; + }, + + /** + * @param {Array.} point + * @param {boolean} [clamp=false] + * @return {Array.} + */ + pointToData: function (point, clamp) { + var xAxis = this.getAxis('x'); + var yAxis = this.getAxis('y'); + return [ + xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp), + yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp) + ]; + }, + + /** + * Get other axis + * @param {module:echarts/coord/cartesian/Axis2D} axis + */ + getOtherAxis: function (axis) { + return this.getAxis(axis.dim === 'x' ? 'y' : 'x'); + } + }; + + zrUtil.inherits(Cartesian2D, Cartesian); + + module.exports = Cartesian2D; + + +/***/ }, +/* 115 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Cartesian coordinate system + * @module echarts/coord/Cartesian + * + */ + + + var zrUtil = __webpack_require__(3); + + function dimAxisMapper(dim) { + return this._axes[dim]; + } + + /** + * @alias module:echarts/coord/Cartesian + * @constructor + */ + var Cartesian = function (name) { + this._axes = {}; + + this._dimList = []; + + /** + * @type {string} + */ + this.name = name || ''; + }; + + Cartesian.prototype = { + + constructor: Cartesian, + + type: 'cartesian', + + /** + * Get axis + * @param {number|string} dim + * @return {module:echarts/coord/Cartesian~Axis} + */ + getAxis: function (dim) { + return this._axes[dim]; + }, + + /** + * Get axes list + * @return {Array.} + */ + getAxes: function () { + return zrUtil.map(this._dimList, dimAxisMapper, this); + }, + + /** + * Get axes list by given scale type + */ + getAxesByScale: function (scaleType) { + scaleType = scaleType.toLowerCase(); + return zrUtil.filter( + this.getAxes(), + function (axis) { + return axis.scale.type === scaleType; + } + ); + }, + + /** + * Add axis + * @param {module:echarts/coord/Cartesian.Axis} + */ + addAxis: function (axis) { + var dim = axis.dim; + + this._axes[dim] = axis; + + this._dimList.push(dim); + }, + + /** + * Convert data to coord in nd space + * @param {Array.|Object.} val + * @return {Array.|Object.} + */ + dataToCoord: function (val) { + return this._dataCoordConvert(val, 'dataToCoord'); + }, + + /** + * Convert coord in nd space to data + * @param {Array.|Object.} val + * @return {Array.|Object.} + */ + coordToData: function (val) { + return this._dataCoordConvert(val, 'coordToData'); + }, + + _dataCoordConvert: function (input, method) { + var dimList = this._dimList; + + var output = input instanceof Array ? [] : {}; + + for (var i = 0; i < dimList.length; i++) { + var dim = dimList[i]; + var axis = this._axes[dim]; + + output[dim] = axis[method](input[dim]); + } + + return output; + } + }; + + module.exports = Cartesian; + + +/***/ }, +/* 116 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var Axis = __webpack_require__(117); + var axisLabelInterval = __webpack_require__(118); + + /** + * Extend axis 2d + * @constructor module:echarts/coord/cartesian/Axis2D + * @extends {module:echarts/coord/cartesian/Axis} + * @param {string} dim + * @param {*} scale + * @param {Array.} coordExtent + * @param {string} axisType + * @param {string} position + */ + var Axis2D = function (dim, scale, coordExtent, axisType, position) { + Axis.call(this, dim, scale, coordExtent); + /** + * Axis type + * - 'category' + * - 'value' + * - 'time' + * - 'log' + * @type {string} + */ + this.type = axisType || 'value'; + + /** + * Axis position + * - 'top' + * - 'bottom' + * - 'left' + * - 'right' + */ + this.position = position || 'bottom'; + }; + + Axis2D.prototype = { + + constructor: Axis2D, + + /** + * Index of axis, can be used as key + */ + index: 0, + /** + * If axis is on the zero position of the other axis + * @type {boolean} + */ + onZero: false, + + /** + * Axis model + * @param {module:echarts/coord/cartesian/AxisModel} + */ + model: null, + + isHorizontal: function () { + var position = this.position; + return position === 'top' || position === 'bottom'; + }, + + getGlobalExtent: function () { + var ret = this.getExtent(); + ret[0] = this.toGlobalCoord(ret[0]); + ret[1] = this.toGlobalCoord(ret[1]); + return ret; + }, + + /** + * @return {number} + */ + getLabelInterval: function () { + var labelInterval = this._labelInterval; + if (!labelInterval) { + labelInterval = this._labelInterval = axisLabelInterval(this); + } + return labelInterval; + }, + + /** + * If label is ignored. + * Automatically used when axis is category and label can not be all shown + * @param {number} idx + * @return {boolean} + */ + isLabelIgnored: function (idx) { + if (this.type === 'category') { + var labelInterval = this.getLabelInterval(); + return ((typeof labelInterval === 'function') + && !labelInterval(idx, this.scale.getLabel(idx))) + || idx % (labelInterval + 1); + } + }, + + /** + * Transform global coord to local coord, + * i.e. var localCoord = axis.toLocalCoord(80); + * designate by module:echarts/coord/cartesian/Grid. + * @type {Function} + */ + toLocalCoord: null, + + /** + * Transform global coord to local coord, + * i.e. var globalCoord = axis.toLocalCoord(40); + * designate by module:echarts/coord/cartesian/Grid. + * @type {Function} + */ + toGlobalCoord: null + + }; + zrUtil.inherits(Axis2D, Axis); + + module.exports = Axis2D; + + +/***/ }, +/* 117 */ +/***/ function(module, exports, __webpack_require__) { + + + + var numberUtil = __webpack_require__(7); + var linearMap = numberUtil.linearMap; + var zrUtil = __webpack_require__(3); + + function fixExtentWithBands(extent, nTick) { + var size = extent[1] - extent[0]; + var len = nTick; + var margin = size / len / 2; + extent[0] += margin; + extent[1] -= margin; + } + + var normalizedExtent = [0, 1]; + /** + * @name module:echarts/coord/CartesianAxis + * @constructor + */ + var Axis = function (dim, scale, extent) { + + /** + * Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius' + * @type {string} + */ + this.dim = dim; + + /** + * Axis scale + * @type {module:echarts/coord/scale/*} + */ + this.scale = scale; + + /** + * @type {Array.} + * @private + */ + this._extent = extent || [0, 0]; + + /** + * @type {boolean} + */ + this.inverse = false; + + /** + * Usually true when axis has a ordinal scale + * @type {boolean} + */ + this.onBand = false; + }; + + Axis.prototype = { + + constructor: Axis, + + /** + * If axis extent contain given coord + * @param {number} coord + * @return {boolean} + */ + contain: function (coord) { + var extent = this._extent; + var min = Math.min(extent[0], extent[1]); + var max = Math.max(extent[0], extent[1]); + return coord >= min && coord <= max; + }, + + /** + * If axis extent contain given data + * @param {number} data + * @return {boolean} + */ + containData: function (data) { + return this.contain(this.dataToCoord(data)); + }, + + /** + * Get coord extent. + * @return {Array.} + */ + getExtent: function () { + var ret = this._extent.slice(); + return ret; + }, + + /** + * Get precision used for formatting + * @param {Array.} [dataExtent] + * @return {number} + */ + getPixelPrecision: function (dataExtent) { + return numberUtil.getPixelPrecision( + dataExtent || this.scale.getExtent(), + this._extent + ); + }, + + /** + * Set coord extent + * @param {number} start + * @param {number} end + */ + setExtent: function (start, end) { + var extent = this._extent; + extent[0] = start; + extent[1] = end; + }, + + /** + * Convert data to coord. Data is the rank if it has a ordinal scale + * @param {number} data + * @param {boolean} clamp + * @return {number} + */ + dataToCoord: function (data, clamp) { + var extent = this._extent; + var scale = this.scale; + data = scale.normalize(data); + + if (this.onBand && scale.type === 'ordinal') { + extent = extent.slice(); + fixExtentWithBands(extent, scale.count()); + } + + return linearMap(data, normalizedExtent, extent, clamp); + }, + + /** + * Convert coord to data. Data is the rank if it has a ordinal scale + * @param {number} coord + * @param {boolean} clamp + * @return {number} + */ + coordToData: function (coord, clamp) { + var extent = this._extent; + var scale = this.scale; + + if (this.onBand && scale.type === 'ordinal') { + extent = extent.slice(); + fixExtentWithBands(extent, scale.count()); + } + + var t = linearMap(coord, extent, normalizedExtent, clamp); + + return this.scale.scale(t); + }, + /** + * @return {Array.} + */ + getTicksCoords: function () { + if (this.onBand) { + var bands = this.getBands(); + var coords = []; + for (var i = 0; i < bands.length; i++) { + coords.push(bands[i][0]); + } + if (bands[i - 1]) { + coords.push(bands[i - 1][1]); + } + return coords; + } + else { + return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this); + } + }, + + /** + * Coords of labels are on the ticks or on the middle of bands + * @return {Array.} + */ + getLabelsCoords: function () { + if (this.onBand) { + var bands = this.getBands(); + var coords = []; + var band; + for (var i = 0; i < bands.length; i++) { + band = bands[i]; + coords.push((band[0] + band[1]) / 2); + } + return coords; + } + else { + return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this); + } + }, + + /** + * Get bands. + * + * If axis has labels [1, 2, 3, 4]. Bands on the axis are + * |---1---|---2---|---3---|---4---|. + * + * @return {Array} + */ + // FIXME Situation when labels is on ticks + getBands: function () { + var extent = this.getExtent(); + var bands = []; + var len = this.scale.count(); + var start = extent[0]; + var end = extent[1]; + var span = end - start; + + for (var i = 0; i < len; i++) { + bands.push([ + span * i / len + start, + span * (i + 1) / len + start + ]); + } + return bands; + }, + + /** + * Get width of band + * @return {number} + */ + getBandWidth: function () { + var axisExtent = this._extent; + var dataExtent = this.scale.getExtent(); + + var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0); + + var size = Math.abs(axisExtent[1] - axisExtent[0]); + + return Math.abs(size) / len; + } + }; + + module.exports = Axis; + + +/***/ }, +/* 118 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Helper function for axisLabelInterval calculation + */ + + + + var zrUtil = __webpack_require__(3); + var axisHelper = __webpack_require__(108); + + module.exports = function (axis) { + var axisModel = axis.model; + var labelModel = axisModel.getModel('axisLabel'); + var labelInterval = labelModel.get('interval'); + if (!(axis.type === 'category' && labelInterval === 'auto')) { + return labelInterval === 'auto' ? 0 : labelInterval; + } + + return axisHelper.getAxisLabelInterval( + zrUtil.map(axis.scale.getTicks(), axis.dataToCoord, axis), + axisModel.getFormattedLabels(), + labelModel.getModel('textStyle').getFont(), + axis.isHorizontal() + ); + }; + + +/***/ }, +/* 119 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // Grid 是在有直角坐标系的时候必须要存在的 + // 所以这里也要被 Cartesian2D 依赖 + + + __webpack_require__(120); + var ComponentModel = __webpack_require__(19); + + module.exports = ComponentModel.extend({ + + type: 'grid', + + dependencies: ['xAxis', 'yAxis'], + + layoutMode: 'box', + + /** + * @type {module:echarts/coord/cartesian/Grid} + */ + coordinateSystem: null, + + defaultOption: { + show: false, + zlevel: 0, + z: 0, + left: '10%', + top: 60, + right: '10%', + bottom: 60, + // If grid size contain label + containLabel: false, + // width: {totalWidth} - left - right, + // height: {totalHeight} - top - bottom, + backgroundColor: 'rgba(0,0,0,0)', + borderWidth: 1, + borderColor: '#ccc' + } + }); + + +/***/ }, +/* 120 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var ComponentModel = __webpack_require__(19); + var zrUtil = __webpack_require__(3); + var axisModelCreator = __webpack_require__(121); + + var AxisModel = ComponentModel.extend({ + + type: 'cartesian2dAxis', + + /** + * @type {module:echarts/coord/cartesian/Axis2D} + */ + axis: null, + + /** + * @override + */ + init: function () { + AxisModel.superApply(this, 'init', arguments); + this._resetRange(); + }, + + /** + * @override + */ + mergeOption: function () { + AxisModel.superApply(this, 'mergeOption', arguments); + this._resetRange(); + }, + + /** + * @override + */ + restoreData: function () { + AxisModel.superApply(this, 'restoreData', arguments); + this._resetRange(); + }, + + /** + * @public + * @param {number} rangeStart + * @param {number} rangeEnd + */ + setRange: function (rangeStart, rangeEnd) { + this.option.rangeStart = rangeStart; + this.option.rangeEnd = rangeEnd; + }, + + /** + * @public + * @return {Array.} + */ + getMin: function () { + var option = this.option; + return option.rangeStart != null ? option.rangeStart : option.min; + }, + + /** + * @public + * @return {Array.} + */ + getMax: function () { + var option = this.option; + return option.rangeEnd != null ? option.rangeEnd : option.max; + }, + + /** + * @public + * @return {boolean} + */ + getNeedCrossZero: function () { + var option = this.option; + return (option.rangeStart != null || option.rangeEnd != null) + ? false : !option.scale; + }, + + /** + * @private + */ + _resetRange: function () { + // rangeStart and rangeEnd is readonly. + this.option.rangeStart = this.option.rangeEnd = null; + } + + }); + + function getAxisType(axisDim, option) { + // Default axis with data is category axis + return option.type || (option.data ? 'category' : 'value'); + } + + zrUtil.merge(AxisModel.prototype, __webpack_require__(123)); + + var extraOption = { + gridIndex: 0 + }; + + axisModelCreator('x', AxisModel, getAxisType, extraOption); + axisModelCreator('y', AxisModel, getAxisType, extraOption); + + module.exports = AxisModel; + + +/***/ }, +/* 121 */ +/***/ function(module, exports, __webpack_require__) { + + + + var axisDefault = __webpack_require__(122); + var zrUtil = __webpack_require__(3); + var ComponentModel = __webpack_require__(19); + var layout = __webpack_require__(21); + + // FIXME axisType is fixed ? + var AXIS_TYPES = ['value', 'category', 'time', 'log']; + + /** + * Generate sub axis model class + * @param {string} axisName 'x' 'y' 'radius' 'angle' 'parallel' + * @param {module:echarts/model/Component} BaseAxisModelClass + * @param {Function} axisTypeDefaulter + * @param {Object} [extraDefaultOption] + */ + module.exports = function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) { + + zrUtil.each(AXIS_TYPES, function (axisType) { + + BaseAxisModelClass.extend({ + + type: axisName + 'Axis.' + axisType, + + mergeDefaultAndTheme: function (option, ecModel) { + var layoutMode = this.layoutMode; + var inputPositionParams = layoutMode + ? layout.getLayoutParams(option) : {}; + + var themeModel = ecModel.getTheme(); + zrUtil.merge(option, themeModel.get(axisType + 'Axis')); + zrUtil.merge(option, this.getDefaultOption()); + + option.type = axisTypeDefaulter(axisName, option); + + if (layoutMode) { + layout.mergeLayoutParam(option, inputPositionParams, layoutMode); + } + }, + + defaultOption: zrUtil.mergeAll( + [ + {}, + axisDefault[axisType + 'Axis'], + extraDefaultOption + ], + true + ) + }); + }); + + ComponentModel.registerSubTypeDefaulter( + axisName + 'Axis', + zrUtil.curry(axisTypeDefaulter, axisName) + ); + }; + + +/***/ }, +/* 122 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + var defaultOption = { + show: true, + zlevel: 0, // 一级层叠 + z: 0, // 二级层叠 + // 反向坐标轴 + inverse: false, + // 坐标轴名字,默认为空 + name: '', + // 坐标轴名字位置,支持'start' | 'middle' | 'end' + nameLocation: 'end', + // 坐标轴文字样式,默认取全局样式 + nameTextStyle: {}, + // 文字与轴线距离 + nameGap: 15, + // 坐标轴线 + axisLine: { + // 默认显示,属性show控制显示与否 + show: true, + onZero: true, + // 属性lineStyle控制线条样式 + lineStyle: { + color: '#333', + width: 1, + type: 'solid' + } + }, + // 坐标轴小标记 + axisTick: { + // 属性show控制显示与否,默认显示 + show: true, + // 控制小标记是否在grid里 + inside: false, + // 属性length控制线长 + length: 5, + // 属性lineStyle控制线条样式 + lineStyle: { + color: '#333', + width: 1 + } + }, + // 坐标轴文本标签,详见axis.axisLabel + axisLabel: { + show: true, + // 控制文本标签是否在grid里 + inside: false, + rotate: 0, + margin: 8, + // formatter: null, + // 其余属性默认使用全局文本样式,详见TEXTSTYLE + textStyle: { + color: '#333', + fontSize: 12 + } + }, + // 分隔线 + splitLine: { + // 默认显示,属性show控制显示与否 + show: true, + // 属性lineStyle(详见lineStyle)控制线条样式 + lineStyle: { + color: ['#ccc'], + width: 1, + type: 'solid' + } + }, + // 分隔区域 + splitArea: { + // 默认不显示,属性show控制显示与否 + show: false, + // 属性areaStyle(详见areaStyle)控制区域样式 + areaStyle: { + color: ['rgba(250,250,250,0.3)','rgba(200,200,200,0.3)'] + } + } + }; + + var categoryAxis = zrUtil.merge({ + // 类目起始和结束两端空白策略 + boundaryGap: true, + // 坐标轴小标记 + axisTick: { + interval: 'auto' + }, + // 坐标轴文本标签,详见axis.axisLabel + axisLabel: { + interval: 'auto' + } + }, defaultOption); + + var valueAxis = zrUtil.defaults({ + // 数值起始和结束两端空白策略 + boundaryGap: [0, 0], + // 最小值, 设置成 'dataMin' 则从数据中计算最小值 + // min: null, + // 最大值,设置成 'dataMax' 则从数据中计算最大值 + // max: null, + // Readonly prop, specifies start value of the range when using data zoom. + // rangeStart: null + // Readonly prop, specifies end value of the range when using data zoom. + // rangeEnd: null + // 脱离0值比例,放大聚焦到最终_min,_max区间 + // scale: false, + // 分割段数,默认为5 + splitNumber: 5 + }, defaultOption); + + // FIXME + var timeAxis = zrUtil.defaults({ + scale: true, + min: 'dataMin', + max: 'dataMax' + }, valueAxis); + var logAxis = zrUtil.defaults({}, valueAxis); + logAxis.scale = true; + + module.exports = { + categoryAxis: categoryAxis, + valueAxis: valueAxis, + timeAxis: timeAxis, + logAxis: logAxis + }; + + +/***/ }, +/* 123 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var axisHelper = __webpack_require__(108); + + function getName(obj) { + if (zrUtil.isObject(obj) && obj.value != null) { + return obj.value; + } + else { + return obj; + } + } + /** + * Get categories + */ + function getCategories() { + return this.get('type') === 'category' + && zrUtil.map(this.get('data'), getName); + } + + /** + * Format labels + * @return {Array.} + */ + function getFormattedLabels() { + return axisHelper.getFormattedLabels( + this.axis, + this.get('axisLabel.formatter') + ); + } + + module.exports = { + + getFormattedLabels: getFormattedLabels, + + getCategories: getCategories + }; + + +/***/ }, +/* 124 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // TODO boundaryGap + + + __webpack_require__(120); + + __webpack_require__(125); + + +/***/ }, +/* 125 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var AxisBuilder = __webpack_require__(126); + var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick; + var getInterval = AxisBuilder.getInterval; + + var axisBuilderAttrs = [ + 'axisLine', 'axisLabel', 'axisTick', 'axisName' + ]; + var selfBuilderAttrs = [ + 'splitLine', 'splitArea' + ]; + + var AxisView = __webpack_require__(1).extendComponentView({ + + type: 'axis', + + render: function (axisModel, ecModel) { + + this.group.removeAll(); + + if (!axisModel.get('show')) { + return; + } + + var gridModel = ecModel.getComponent('grid', axisModel.get('gridIndex')); + + var layout = layoutAxis(gridModel, axisModel); + + var axisBuilder = new AxisBuilder(axisModel, layout); + + zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder); + + this.group.add(axisBuilder.getGroup()); + + zrUtil.each(selfBuilderAttrs, function (name) { + if (axisModel.get(name +'.show')) { + this['_' + name](axisModel, gridModel, layout.labelInterval); + } + }, this); + }, + + /** + * @param {module:echarts/coord/cartesian/AxisModel} axisModel + * @param {module:echarts/coord/cartesian/GridModel} gridModel + * @param {number|Function} labelInterval + * @private + */ + _splitLine: function (axisModel, gridModel, labelInterval) { + var axis = axisModel.axis; + + var splitLineModel = axisModel.getModel('splitLine'); + var lineStyleModel = splitLineModel.getModel('lineStyle'); + var lineWidth = lineStyleModel.get('width'); + var lineColors = lineStyleModel.get('color'); + + var lineInterval = getInterval(splitLineModel, labelInterval); + + lineColors = zrUtil.isArray(lineColors) ? lineColors : [lineColors]; + + var gridRect = gridModel.coordinateSystem.getRect(); + var isHorizontal = axis.isHorizontal(); + + var splitLines = []; + var lineCount = 0; + + var ticksCoords = axis.getTicksCoords(); + + var p1 = []; + var p2 = []; + for (var i = 0; i < ticksCoords.length; i++) { + if (ifIgnoreOnTick(axis, i, lineInterval)) { + continue; + } + + var tickCoord = axis.toGlobalCoord(ticksCoords[i]); + + if (isHorizontal) { + p1[0] = tickCoord; + p1[1] = gridRect.y; + p2[0] = tickCoord; + p2[1] = gridRect.y + gridRect.height; + } + else { + p1[0] = gridRect.x; + p1[1] = tickCoord; + p2[0] = gridRect.x + gridRect.width; + p2[1] = tickCoord; + } + + var colorIndex = (lineCount++) % lineColors.length; + splitLines[colorIndex] = splitLines[colorIndex] || []; + splitLines[colorIndex].push(new graphic.Line(graphic.subPixelOptimizeLine({ + shape: { + x1: p1[0], + y1: p1[1], + x2: p2[0], + y2: p2[1] + }, + style: { + lineWidth: lineWidth + }, + silent: true + }))); + } + + // Simple optimization + // Batching the lines if color are the same + var lineStyle = lineStyleModel.getLineStyle(); + for (var i = 0; i < splitLines.length; i++) { + this.group.add(graphic.mergePath(splitLines[i], { + style: zrUtil.defaults({ + stroke: lineColors[i % lineColors.length] + }, lineStyle), + silent: true + })); + } + }, + + /** + * @param {module:echarts/coord/cartesian/AxisModel} axisModel + * @param {module:echarts/coord/cartesian/GridModel} gridModel + * @param {number|Function} labelInterval + * @private + */ + _splitArea: function (axisModel, gridModel, labelInterval) { + var axis = axisModel.axis; + + var splitAreaModel = axisModel.getModel('splitArea'); + var areaStyleModel = splitAreaModel.getModel('areaStyle'); + var areaColors = areaStyleModel.get('color'); + + var gridRect = gridModel.coordinateSystem.getRect(); + var ticksCoords = axis.getTicksCoords(); + + var prevX = axis.toGlobalCoord(ticksCoords[0]); + var prevY = axis.toGlobalCoord(ticksCoords[0]); + + var splitAreaRects = []; + var count = 0; + + var areaInterval = getInterval(splitAreaModel, labelInterval); + + areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors]; + + for (var i = 1; i < ticksCoords.length; i++) { + if (ifIgnoreOnTick(axis, i, areaInterval)) { + continue; + } + + var tickCoord = axis.toGlobalCoord(ticksCoords[i]); + + var x; + var y; + var width; + var height; + if (axis.isHorizontal()) { + x = prevX; + y = gridRect.y; + width = tickCoord - x; + height = gridRect.height; + } + else { + x = gridRect.x; + y = prevY; + width = gridRect.width; + height = tickCoord - y; + } + + var colorIndex = (count++) % areaColors.length; + splitAreaRects[colorIndex] = splitAreaRects[colorIndex] || []; + splitAreaRects[colorIndex].push(new graphic.Rect({ + shape: { + x: x, + y: y, + width: width, + height: height + }, + silent: true + })); + + prevX = x + width; + prevY = y + height; + } + + // Simple optimization + // Batching the rects if color are the same + var areaStyle = areaStyleModel.getAreaStyle(); + for (var i = 0; i < splitAreaRects.length; i++) { + this.group.add(graphic.mergePath(splitAreaRects[i], { + style: zrUtil.defaults({ + fill: areaColors[i % areaColors.length] + }, areaStyle), + silent: true + })); + } + } + }); + + AxisView.extend({ + type: 'xAxis' + }); + AxisView.extend({ + type: 'yAxis' + }); + + /** + * @inner + */ + function layoutAxis(gridModel, axisModel) { + var grid = gridModel.coordinateSystem; + var axis = axisModel.axis; + var layout = {}; + + var rawAxisPosition = axis.position; + var axisPosition = axis.onZero ? 'onZero' : rawAxisPosition; + var axisDim = axis.dim; + + // [left, right, top, bottom] + var rect = grid.getRect(); + var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height]; + + var posMap = { + x: {top: rectBound[2], bottom: rectBound[3]}, + y: {left: rectBound[0], right: rectBound[1]} + }; + posMap.x.onZero = Math.max(Math.min(getZero('y'), posMap.x.bottom), posMap.x.top); + posMap.y.onZero = Math.max(Math.min(getZero('x'), posMap.y.right), posMap.y.left); + + function getZero(dim, val) { + var theAxis = grid.getAxis(dim); + return theAxis.toGlobalCoord(theAxis.dataToCoord(0)); + } + + // Axis position + layout.position = [ + axisDim === 'y' ? posMap.y[axisPosition] : rectBound[0], + axisDim === 'x' ? posMap.x[axisPosition] : rectBound[3] + ]; + + // Axis rotation + var r = {x: 0, y: 1}; + layout.rotation = Math.PI / 2 * r[axisDim]; + + // Tick and label direction, x y is axisDim + var dirMap = {top: -1, bottom: 1, left: -1, right: 1}; + + layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition]; + if (axis.onZero) { + layout.labelOffset = posMap[axisDim][rawAxisPosition] - posMap[axisDim].onZero; + } + + if (axisModel.getModel('axisTick').get('inside')) { + layout.tickDirection = -layout.tickDirection; + } + if (axisModel.getModel('axisLabel').get('inside')) { + layout.labelDirection = -layout.labelDirection; + } + + // Special label rotation + var labelRotation = axisModel.getModel('axisLabel').get('rotate'); + layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation; + + // label interval when auto mode. + layout.labelInterval = axis.getLabelInterval(); + + // Over splitLine and splitArea + layout.z2 = 1; + + return layout; + } + + +/***/ }, +/* 126 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var Model = __webpack_require__(8); + var numberUtil = __webpack_require__(7); + var remRadian = numberUtil.remRadian; + var isRadianAroundZero = numberUtil.isRadianAroundZero; + + var PI = Math.PI; + + /** + * A final axis is translated and rotated from a "standard axis". + * So opt.position and opt.rotation is required. + * + * A standard axis is and axis from [0, 0] to [0, axisExtent[1]], + * for example: (0, 0) ------------> (0, 50) + * + * nameDirection or tickDirection or labelDirection is 1 means tick + * or label is below the standard axis, whereas is -1 means above + * the standard axis. labelOffset means offset between label and axis, + * which is useful when 'onZero', where axisLabel is in the grid and + * label in outside grid. + * + * Tips: like always, + * positive rotation represents anticlockwise, and negative rotation + * represents clockwise. + * The direction of position coordinate is the same as the direction + * of screen coordinate. + * + * Do not need to consider axis 'inverse', which is auto processed by + * axis extent. + * + * @param {module:zrender/container/Group} group + * @param {Object} axisModel + * @param {Object} opt Standard axis parameters. + * @param {Array.} opt.position [x, y] + * @param {number} opt.rotation by radian + * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'. + * @param {number} [opt.tickDirection=1] 1 or -1 + * @param {number} [opt.labelDirection=1] 1 or -1 + * @param {number} [opt.labelOffset=0] Usefull when onZero. + * @param {string} [opt.axisName] default get from axisModel. + * @param {number} [opt.labelRotation] by degree, default get from axisModel. + * @param {number} [opt.labelInterval] Default label interval when label + * interval from model is null or 'auto'. + * @param {number} [opt.strokeContainThreshold] Default label interval when label + * @param {number} [opt.silent=true] + */ + var AxisBuilder = function (axisModel, opt) { + + /** + * @readOnly + */ + this.opt = opt; + + /** + * @readOnly + */ + this.axisModel = axisModel; + + // Default value + zrUtil.defaults( + opt, + { + labelOffset: 0, + nameDirection: 1, + tickDirection: 1, + labelDirection: 1, + silent: true + } + ); + + /** + * @readOnly + */ + this.group = new graphic.Group({ + position: opt.position.slice(), + rotation: opt.rotation + }); + }; + + AxisBuilder.prototype = { + + constructor: AxisBuilder, + + hasBuilder: function (name) { + return !!builders[name]; + }, + + add: function (name) { + builders[name].call(this); + }, + + getGroup: function () { + return this.group; + } + + }; + + var builders = { + + /** + * @private + */ + axisLine: function () { + var opt = this.opt; + var axisModel = this.axisModel; + + if (!axisModel.get('axisLine.show')) { + return; + } + + var extent = this.axisModel.axis.getExtent(); + + this.group.add(new graphic.Line({ + shape: { + x1: extent[0], + y1: 0, + x2: extent[1], + y2: 0 + }, + style: zrUtil.extend( + {lineCap: 'round'}, + axisModel.getModel('axisLine.lineStyle').getLineStyle() + ), + strokeContainThreshold: opt.strokeContainThreshold, + silent: !!opt.silent, + z2: 1 + })); + }, + + /** + * @private + */ + axisTick: function () { + var axisModel = this.axisModel; + + if (!axisModel.get('axisTick.show')) { + return; + } + + var axis = axisModel.axis; + var tickModel = axisModel.getModel('axisTick'); + var opt = this.opt; + + var lineStyleModel = tickModel.getModel('lineStyle'); + var tickLen = tickModel.get('length'); + var tickInterval = getInterval(tickModel, opt.labelInterval); + var ticksCoords = axis.getTicksCoords(); + var tickLines = []; + + for (var i = 0; i < ticksCoords.length; i++) { + // Only ordinal scale support tick interval + if (ifIgnoreOnTick(axis, i, tickInterval)) { + continue; + } + + var tickCoord = ticksCoords[i]; + + // Tick line + tickLines.push(new graphic.Line(graphic.subPixelOptimizeLine({ + shape: { + x1: tickCoord, + y1: 0, + x2: tickCoord, + y2: opt.tickDirection * tickLen + }, + style: { + lineWidth: lineStyleModel.get('width') + }, + silent: true + }))); + } + + this.group.add(graphic.mergePath(tickLines, { + style: lineStyleModel.getLineStyle(), + z2: 2, + silent: true + })); + }, + + /** + * @param {module:echarts/coord/cartesian/AxisModel} axisModel + * @param {module:echarts/coord/cartesian/GridModel} gridModel + * @private + */ + axisLabel: function () { + var axisModel = this.axisModel; + + if (!axisModel.get('axisLabel.show')) { + return; + } + + var opt = this.opt; + var axis = axisModel.axis; + var labelModel = axisModel.getModel('axisLabel'); + var textStyleModel = labelModel.getModel('textStyle'); + var labelMargin = labelModel.get('margin'); + var ticks = axis.scale.getTicks(); + var labels = axisModel.getFormattedLabels(); + + // Special label rotate. + var labelRotation = opt.labelRotation; + if (labelRotation == null) { + labelRotation = labelModel.get('rotate') || 0; + } + // To radian. + labelRotation = labelRotation * PI / 180; + + var labelLayout = innerTextLayout(opt, labelRotation, opt.labelDirection); + var categoryData = axisModel.get('data'); + + var textEls = []; + for (var i = 0; i < ticks.length; i++) { + if (ifIgnoreOnTick(axis, i, opt.labelInterval)) { + continue; + } + + var itemTextStyleModel = textStyleModel; + if (categoryData && categoryData[i] && categoryData[i].textStyle) { + itemTextStyleModel = new Model( + categoryData[i].textStyle, textStyleModel, axisModel.ecModel + ); + } + + var tickCoord = axis.dataToCoord(ticks[i]); + var pos = [ + tickCoord, + opt.labelOffset + opt.labelDirection * labelMargin + ]; + + var textEl = new graphic.Text({ + style: { + text: labels[i], + textAlign: itemTextStyleModel.get('align', true) || labelLayout.textAlign, + textVerticalAlign: itemTextStyleModel.get('baseline', true) || labelLayout.verticalAlign, + textFont: itemTextStyleModel.getFont(), + fill: itemTextStyleModel.getTextColor() + }, + position: pos, + rotation: labelLayout.rotation, + silent: true, + z2: 10 + }); + textEls.push(textEl); + this.group.add(textEl); + } + + function isTwoLabelOverlapped(current, next) { + var firstRect = current && current.getBoundingRect().clone(); + var nextRect = next && next.getBoundingRect().clone(); + if (firstRect && nextRect) { + firstRect.applyTransform(current.getLocalTransform()); + nextRect.applyTransform(next.getLocalTransform()); + return firstRect.intersect(nextRect); + } + } + if (axis.type !== 'category') { + // If min or max are user set, we need to check + // If the tick on min(max) are overlap on their neighbour tick + // If they are overlapped, we need to hide the min(max) tick label + if (axisModel.getMin ? axisModel.getMin() : axisModel.get('min')) { + var firstLabel = textEls[0]; + var nextLabel = textEls[1]; + if (isTwoLabelOverlapped(firstLabel, nextLabel)) { + firstLabel.ignore = true; + } + } + if (axisModel.getMax ? axisModel.getMax() : axisModel.get('max')) { + var lastLabel = textEls[textEls.length - 1]; + var prevLabel = textEls[textEls.length - 2]; + if (isTwoLabelOverlapped(prevLabel, lastLabel)) { + lastLabel.ignore = true; + } + } + } + }, + + /** + * @private + */ + axisName: function () { + var opt = this.opt; + var axisModel = this.axisModel; + + var name = this.opt.axisName; + // If name is '', do not get name from axisMode. + if (name == null) { + name = axisModel.get('name'); + } + + if (!name) { + return; + } + + var nameLocation = axisModel.get('nameLocation'); + var nameDirection = opt.nameDirection; + var textStyleModel = axisModel.getModel('nameTextStyle'); + var gap = axisModel.get('nameGap') || 0; + + var extent = this.axisModel.axis.getExtent(); + var gapSignal = extent[0] > extent[1] ? -1 : 1; + var pos = [ + nameLocation === 'start' + ? extent[0] - gapSignal * gap + : nameLocation === 'end' + ? extent[1] + gapSignal * gap + : (extent[0] + extent[1]) / 2, // 'middle' + // Reuse labelOffset. + nameLocation === 'middle' ? opt.labelOffset + nameDirection * gap : 0 + ]; + + var labelLayout; + + if (nameLocation === 'middle') { + labelLayout = innerTextLayout(opt, opt.rotation, nameDirection); + } + else { + labelLayout = endTextLayout(opt, nameLocation, extent); + } + + this.group.add(new graphic.Text({ + style: { + text: name, + textFont: textStyleModel.getFont(), + fill: textStyleModel.getTextColor() + || axisModel.get('axisLine.lineStyle.color'), + textAlign: labelLayout.textAlign, + textVerticalAlign: labelLayout.verticalAlign + }, + position: pos, + rotation: labelLayout.rotation, + silent: true, + z2: 1 + })); + } + + }; + + /** + * @inner + */ + function innerTextLayout(opt, textRotation, direction) { + var rotationDiff = remRadian(textRotation - opt.rotation); + var textAlign; + var verticalAlign; + + if (isRadianAroundZero(rotationDiff)) { // Label is parallel with axis line. + verticalAlign = direction > 0 ? 'top' : 'bottom'; + textAlign = 'center'; + } + else if (isRadianAroundZero(rotationDiff - PI)) { // Label is inverse parallel with axis line. + verticalAlign = direction > 0 ? 'bottom' : 'top'; + textAlign = 'center'; + } + else { + verticalAlign = 'middle'; + + if (rotationDiff > 0 && rotationDiff < PI) { + textAlign = direction > 0 ? 'right' : 'left'; + } + else { + textAlign = direction > 0 ? 'left' : 'right'; + } + } + + return { + rotation: rotationDiff, + textAlign: textAlign, + verticalAlign: verticalAlign + }; + } + + /** + * @inner + */ + function endTextLayout(opt, textPosition, extent) { + var rotationDiff = remRadian(-opt.rotation); + var textAlign; + var verticalAlign; + var inverse = extent[0] > extent[1]; + var onLeft = (textPosition === 'start' && !inverse) + || (textPosition !== 'start' && inverse); + + if (isRadianAroundZero(rotationDiff - PI / 2)) { + verticalAlign = onLeft ? 'bottom' : 'top'; + textAlign = 'center'; + } + else if (isRadianAroundZero(rotationDiff - PI * 1.5)) { + verticalAlign = onLeft ? 'top' : 'bottom'; + textAlign = 'center'; + } + else { + verticalAlign = 'middle'; + if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) { + textAlign = onLeft ? 'left' : 'right'; + } + else { + textAlign = onLeft ? 'right' : 'left'; + } + } + + return { + rotation: rotationDiff, + textAlign: textAlign, + verticalAlign: verticalAlign + }; + } + + /** + * @static + */ + var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (axis, i, interval) { + var rawTick; + var scale = axis.scale; + return scale.type === 'ordinal' + && ( + typeof interval === 'function' + ? ( + rawTick = scale.getTicks()[i], + !interval(rawTick, scale.getLabel(rawTick)) + ) + : i % (interval + 1) + ); + }; + + /** + * @static + */ + var getInterval = AxisBuilder.getInterval = function (model, labelInterval) { + var interval = model.get('interval'); + if (interval == null || interval == 'auto') { + interval = labelInterval; + } + return interval; + }; + + module.exports = AxisBuilder; + + + +/***/ }, +/* 127 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + __webpack_require__(107); + + __webpack_require__(128); + __webpack_require__(129); + + var barLayoutGrid = __webpack_require__(131); + var echarts = __webpack_require__(1); + + echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar')); + // Visual coding for legend + echarts.registerVisualCoding('chart', function (ecModel) { + ecModel.eachSeriesByType('bar', function (seriesModel) { + var data = seriesModel.getData(); + data.setVisual('legendSymbol', 'roundRect'); + }); + }); + + // In case developer forget to include grid component + __webpack_require__(106); + + +/***/ }, +/* 128 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var SeriesModel = __webpack_require__(27); + var createListFromArray = __webpack_require__(93); + + module.exports = SeriesModel.extend({ + + type: 'series.bar', + + dependencies: ['grid', 'polar'], + + getInitialData: function (option, ecModel) { + return createListFromArray(option.data, this, ecModel); + }, + + getMarkerPosition: function (value) { + var coordSys = this.coordinateSystem; + if (coordSys) { + var pt = coordSys.dataToPoint(value); + var data = this.getData(); + var offset = data.getLayout('offset'); + var size = data.getLayout('size'); + var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1; + pt[offsetIndex] += offset + size / 2; + return pt; + } + return [NaN, NaN]; + }, + + defaultOption: { + zlevel: 0, // 一级层叠 + z: 2, // 二级层叠 + coordinateSystem: 'cartesian2d', + legendHoverLink: true, + // stack: null + + // Cartesian coordinate system + xAxisIndex: 0, + yAxisIndex: 0, + + // 最小高度改为0 + barMinHeight: 0, + + // barMaxWidth: null, + // 默认自适应 + // barWidth: null, + // 柱间距离,默认为柱形宽度的30%,可设固定值 + // barGap: '30%', + // 类目间柱形距离,默认为类目间距的20%,可设固定值 + // barCategoryGap: '20%', + // label: { + // normal: { + // show: false + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + + // // 默认自适应,水平布局为'top',垂直布局为'right',可选为 + // // 'inside' | 'insideleft' | 'insideTop' | 'insideRight' | 'insideBottom' | + // // 'outside' |'left' | 'right'|'top'|'bottom' + // position: + + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + // } + // }, + itemStyle: { + normal: { + // color: '各异', + // 柱条边线 + barBorderColor: '#fff', + // 柱条边线线宽,单位px,默认为1 + barBorderWidth: 0 + }, + emphasis: { + // color: '各异', + // 柱条边线 + barBorderColor: '#fff', + // 柱条边线线宽,单位px,默认为1 + barBorderWidth: 0 + } + } + } + }); + + +/***/ }, +/* 129 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + + zrUtil.extend(__webpack_require__(8).prototype, __webpack_require__(130)); + + function fixLayoutWithLineWidth(layout, lineWidth) { + var signX = layout.width > 0 ? 1 : -1; + var signY = layout.height > 0 ? 1 : -1; + // In case width or height are too small. + lineWidth = Math.min(lineWidth, Math.abs(layout.width), Math.abs(layout.height)); + layout.x += signX * lineWidth / 2; + layout.y += signY * lineWidth / 2; + layout.width -= signX * lineWidth; + layout.height -= signY * lineWidth; + } + + module.exports = __webpack_require__(1).extendChartView({ + + type: 'bar', + + render: function (seriesModel, ecModel, api) { + var coordinateSystemType = seriesModel.get('coordinateSystem'); + + if (coordinateSystemType === 'cartesian2d') { + this._renderOnCartesian(seriesModel, ecModel, api); + } + + return this.group; + }, + + _renderOnCartesian: function (seriesModel, ecModel, api) { + var group = this.group; + var data = seriesModel.getData(); + var oldData = this._data; + + var cartesian = seriesModel.coordinateSystem; + var baseAxis = cartesian.getBaseAxis(); + var isHorizontal = baseAxis.isHorizontal(); + + var enableAnimation = seriesModel.get('animation'); + + var barBorderWidthQuery = ['itemStyle', 'normal', 'barBorderWidth']; + + function createRect(dataIndex, isUpdate) { + var layout = data.getItemLayout(dataIndex); + var lineWidth = data.getItemModel(dataIndex).get(barBorderWidthQuery) || 0; + fixLayoutWithLineWidth(layout, lineWidth); + + var rect = new graphic.Rect({ + shape: zrUtil.extend({}, layout) + }); + // Animation + if (enableAnimation) { + var rectShape = rect.shape; + var animateProperty = isHorizontal ? 'height' : 'width'; + var animateTarget = {}; + rectShape[animateProperty] = 0; + animateTarget[animateProperty] = layout[animateProperty]; + graphic[isUpdate? 'updateProps' : 'initProps'](rect, { + shape: animateTarget + }, seriesModel); + } + return rect; + } + data.diff(oldData) + .add(function (dataIndex) { + // 空数据 + if (!data.hasValue(dataIndex)) { + return; + } + + var rect = createRect(dataIndex); + + data.setItemGraphicEl(dataIndex, rect); + + group.add(rect); + + }) + .update(function (newIndex, oldIndex) { + var rect = oldData.getItemGraphicEl(oldIndex); + // 空数据 + if (!data.hasValue(newIndex)) { + group.remove(rect); + return; + } + if (!rect) { + rect = createRect(newIndex, true); + } + + var layout = data.getItemLayout(newIndex); + var lineWidth = data.getItemModel(newIndex).get(barBorderWidthQuery) || 0; + fixLayoutWithLineWidth(layout, lineWidth); + + graphic.updateProps(rect, { + shape: layout + }, seriesModel); + + data.setItemGraphicEl(newIndex, rect); + + // Add back + group.add(rect); + }) + .remove(function (idx) { + var rect = oldData.getItemGraphicEl(idx); + if (rect) { + // Not show text when animating + rect.style.text = ''; + graphic.updateProps(rect, { + shape: { + width: 0 + } + }, seriesModel, function () { + group.remove(rect); + }); + } + }) + .execute(); + + this._updateStyle(seriesModel, data, isHorizontal); + + this._data = data; + }, + + _updateStyle: function (seriesModel, data, isHorizontal) { + function setLabel(style, model, color, labelText, labelPositionOutside) { + graphic.setText(style, model, color); + style.text = labelText; + if (style.textPosition === 'outside') { + style.textPosition = labelPositionOutside; + } + } + + data.eachItemGraphicEl(function (rect, idx) { + var itemModel = data.getItemModel(idx); + var color = data.getItemVisual(idx, 'color'); + var layout = data.getItemLayout(idx); + var itemStyleModel = itemModel.getModel('itemStyle.normal'); + + var hoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle(); + + rect.setShape('r', itemStyleModel.get('barBorderRadius') || 0); + + rect.setStyle(zrUtil.defaults( + { + fill: color + }, + itemStyleModel.getBarItemStyle() + )); + + var labelPositionOutside = isHorizontal + ? (layout.height > 0 ? 'bottom' : 'top') + : (layout.width > 0 ? 'left' : 'right'); + + var labelModel = itemModel.getModel('label.normal'); + var hoverLabelModel = itemModel.getModel('label.emphasis'); + var rectStyle = rect.style; + if (labelModel.get('show')) { + setLabel( + rectStyle, labelModel, color, + zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'normal'), + seriesModel.getRawValue(idx) + ), + labelPositionOutside + ); + } + else { + rectStyle.text = ''; + } + if (hoverLabelModel.get('show')) { + setLabel( + hoverStyle, hoverLabelModel, color, + zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'emphasis'), + seriesModel.getRawValue(idx) + ), + labelPositionOutside + ); + } + else { + hoverStyle.text = ''; + } + graphic.setHoverStyle(rect, hoverStyle); + }); + }, + + remove: function (ecModel, api) { + var group = this.group; + if (ecModel.get('animation')) { + if (this._data) { + this._data.eachItemGraphicEl(function (el) { + // Not show text when animating + el.style.text = ''; + graphic.updateProps(el, { + shape: { + width: 0 + } + }, ecModel, function () { + group.remove(el); + }); + }); + } + } + else { + group.removeAll(); + } + } + }); + + +/***/ }, +/* 130 */ +/***/ function(module, exports, __webpack_require__) { + + + module.exports = { + getBarItemStyle: __webpack_require__(11)( + [ + ['fill', 'color'], + ['stroke', 'barBorderColor'], + ['lineWidth', 'barBorderWidth'], + ['opacity'], + ['shadowBlur'], + ['shadowOffsetX'], + ['shadowOffsetY'], + ['shadowColor'] + ] + ) + }; + + +/***/ }, +/* 131 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var parsePercent = numberUtil.parsePercent; + + function getSeriesStackId(seriesModel) { + return seriesModel.get('stack') || '__ec_stack_' + seriesModel.seriesIndex; + } + + function calBarWidthAndOffset(barSeries, api) { + // Columns info on each category axis. Key is cartesian name + var columnsMap = {}; + + zrUtil.each(barSeries, function (seriesModel, idx) { + var cartesian = seriesModel.coordinateSystem; + + var baseAxis = cartesian.getBaseAxis(); + + var columnsOnAxis = columnsMap[baseAxis.index] || { + remainedWidth: baseAxis.getBandWidth(), + autoWidthCount: 0, + categoryGap: '20%', + gap: '30%', + axis: baseAxis, + stacks: {} + }; + var stacks = columnsOnAxis.stacks; + columnsMap[baseAxis.index] = columnsOnAxis; + + var stackId = getSeriesStackId(seriesModel); + + if (!stacks[stackId]) { + columnsOnAxis.autoWidthCount++; + } + stacks[stackId] = stacks[stackId] || { + width: 0, + maxWidth: 0 + }; + + var barWidth = seriesModel.get('barWidth'); + var barMaxWidth = seriesModel.get('barMaxWidth'); + var barGap = seriesModel.get('barGap'); + var barCategoryGap = seriesModel.get('barCategoryGap'); + // TODO + if (barWidth && ! stacks[stackId].width) { + barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth); + stacks[stackId].width = barWidth; + columnsOnAxis.remainedWidth -= barWidth; + } + + barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth); + (barGap != null) && (columnsOnAxis.gap = barGap); + (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap); + }); + + var result = {}; + + zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) { + + result[coordSysName] = {}; + + var stacks = columnsOnAxis.stacks; + var baseAxis = columnsOnAxis.axis; + var bandWidth = baseAxis.getBandWidth(); + var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth); + var barGapPercent = parsePercent(columnsOnAxis.gap, 1); + + var remainedWidth = columnsOnAxis.remainedWidth; + var autoWidthCount = columnsOnAxis.autoWidthCount; + var autoWidth = (remainedWidth - categoryGap) + / (autoWidthCount + (autoWidthCount - 1) * barGapPercent); + autoWidth = Math.max(autoWidth, 0); + + // Find if any auto calculated bar exceeded maxBarWidth + zrUtil.each(stacks, function (column, stack) { + var maxWidth = column.maxWidth; + if (!column.width && maxWidth && maxWidth < autoWidth) { + maxWidth = Math.min(maxWidth, remainedWidth); + remainedWidth -= maxWidth; + column.width = maxWidth; + autoWidthCount--; + } + }); + + // Recalculate width again + autoWidth = (remainedWidth - categoryGap) + / (autoWidthCount + (autoWidthCount - 1) * barGapPercent); + autoWidth = Math.max(autoWidth, 0); + + var widthSum = 0; + var lastColumn; + zrUtil.each(stacks, function (column, idx) { + if (!column.width) { + column.width = autoWidth; + } + lastColumn = column; + widthSum += column.width * (1 + barGapPercent); + }); + if (lastColumn) { + widthSum -= lastColumn.width * barGapPercent; + } + + var offset = -widthSum / 2; + zrUtil.each(stacks, function (column, stackId) { + result[coordSysName][stackId] = result[coordSysName][stackId] || { + offset: offset, + width: column.width + }; + + offset += column.width * (1 + barGapPercent); + }); + }); + + return result; + } + + /** + * @param {string} seriesType + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + */ + function barLayoutGrid(seriesType, ecModel, api) { + + var barWidthAndOffset = calBarWidthAndOffset( + zrUtil.filter( + ecModel.getSeriesByType(seriesType), + function (seriesModel) { + return !ecModel.isSeriesFiltered(seriesModel) + && seriesModel.coordinateSystem + && seriesModel.coordinateSystem.type === 'cartesian2d'; + } + ) + ); + + var lastStackCoords = {}; + + ecModel.eachSeriesByType(seriesType, function (seriesModel) { + + var data = seriesModel.getData(); + var cartesian = seriesModel.coordinateSystem; + var baseAxis = cartesian.getBaseAxis(); + + var stackId = getSeriesStackId(seriesModel); + var columnLayoutInfo = barWidthAndOffset[baseAxis.index][stackId]; + var columnOffset = columnLayoutInfo.offset; + var columnWidth = columnLayoutInfo.width; + var valueAxis = cartesian.getOtherAxis(baseAxis); + + var barMinHeight = seriesModel.get('barMinHeight') || 0; + + var valueAxisStart = baseAxis.onZero + ? valueAxis.toGlobalCoord(valueAxis.dataToCoord(0)) + : valueAxis.getGlobalExtent()[0]; + + var coords = cartesian.dataToPoints(data, true); + lastStackCoords[stackId] = lastStackCoords[stackId] || []; + + data.setLayout({ + offset: columnOffset, + size: columnWidth + }); + data.each(valueAxis.dim, function (value, idx) { + // 空数据 + if (isNaN(value)) { + return; + } + if (!lastStackCoords[stackId][idx]) { + lastStackCoords[stackId][idx] = { + // Positive stack + p: valueAxisStart, + // Negative stack + n: valueAxisStart + }; + } + var sign = value >= 0 ? 'p' : 'n'; + var coord = coords[idx]; + var lastCoord = lastStackCoords[stackId][idx][sign]; + var x, y, width, height; + if (valueAxis.isHorizontal()) { + x = lastCoord; + y = coord[1] + columnOffset; + width = coord[0] - lastCoord; + height = columnWidth; + + if (Math.abs(width) < barMinHeight) { + width = (width < 0 ? -1 : 1) * barMinHeight; + } + lastStackCoords[stackId][idx][sign] += width; + } + else { + x = coord[0] + columnOffset; + y = lastCoord; + width = columnWidth; + height = coord[1] - lastCoord; + if (Math.abs(height) < barMinHeight) { + // Include zero to has a positive bar + height = (height <= 0 ? -1 : 1) * barMinHeight; + } + lastStackCoords[stackId][idx][sign] += height; + } + + data.setItemLayout(idx, { + x: x, + y: y, + width: width, + height: height + }); + }, true); + + }, this); + } + + module.exports = barLayoutGrid; + + +/***/ }, +/* 132 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var echarts = __webpack_require__(1); + + __webpack_require__(133); + __webpack_require__(135); + + __webpack_require__(136)('pie', [{ + type: 'pieToggleSelect', + event: 'pieselectchanged', + method: 'toggleSelected' + }, { + type: 'pieSelect', + event: 'pieselected', + method: 'select' + }, { + type: 'pieUnSelect', + event: 'pieunselected', + method: 'unSelect' + }]); + + echarts.registerVisualCoding( + 'chart', zrUtil.curry(__webpack_require__(137), 'pie') + ); + + echarts.registerLayout(zrUtil.curry( + __webpack_require__(138), 'pie' + )); + + echarts.registerProcessor( + 'filter', zrUtil.curry(__webpack_require__(140), 'pie') + ); + + +/***/ }, +/* 133 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var List = __webpack_require__(94); + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var completeDimensions = __webpack_require__(96); + + var dataSelectableMixin = __webpack_require__(134); + + var PieSeries = __webpack_require__(1).extendSeriesModel({ + + type: 'series.pie', + + // Overwrite + init: function (option) { + PieSeries.superApply(this, 'init', arguments); + + // Enable legend selection for each data item + // Use a function instead of direct access because data reference may changed + this.legendDataProvider = function () { + return this._dataBeforeProcessed; + }; + + this.updateSelectedMap(); + + this._defaultLabelLine(option); + }, + + // Overwrite + mergeOption: function (newOption) { + PieSeries.superCall(this, 'mergeOption', newOption); + this.updateSelectedMap(); + }, + + getInitialData: function (option, ecModel) { + var dimensions = completeDimensions(['value'], option.data); + var list = new List(dimensions, this); + list.initData(option.data); + return list; + }, + + // Overwrite + getDataParams: function (dataIndex) { + var data = this._data; + var params = PieSeries.superCall(this, 'getDataParams', dataIndex); + var sum = data.getSum('value'); + // FIXME toFixed? + // + // Percent is 0 if sum is 0 + params.percent = !sum ? 0 : +(data.get('value', dataIndex) / sum * 100).toFixed(2); + + params.$vars.push('percent'); + return params; + }, + + _defaultLabelLine: function (option) { + // Extend labelLine emphasis + modelUtil.defaultEmphasis(option.labelLine, ['show']); + + var labelLineNormalOpt = option.labelLine.normal; + var labelLineEmphasisOpt = option.labelLine.emphasis; + // Not show label line if `label.normal.show = false` + labelLineNormalOpt.show = labelLineNormalOpt.show + && option.label.normal.show; + labelLineEmphasisOpt.show = labelLineEmphasisOpt.show + && option.label.emphasis.show; + }, + + defaultOption: { + zlevel: 0, + z: 2, + legendHoverLink: true, + + hoverAnimation: true, + // 默认全局居中 + center: ['50%', '50%'], + radius: [0, '75%'], + // 默认顺时针 + clockwise: true, + startAngle: 90, + // 最小角度改为0 + minAngle: 0, + // 选中是扇区偏移量 + selectedOffset: 10, + + // If use strategy to avoid label overlapping + avoidLabelOverlap: true, + // 选择模式,默认关闭,可选single,multiple + // selectedMode: false, + // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积) + // roseType: null, + + label: { + normal: { + // If rotate around circle + rotate: false, + show: true, + // 'outer', 'inside', 'center' + position: 'outer' + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数 + }, + emphasis: {} + }, + // Enabled when label.normal.position is 'outer' + labelLine: { + normal: { + show: true, + // 引导线两段中的第一段长度 + length: 20, + // 引导线两段中的第二段长度 + length2: 5, + smooth: false, + lineStyle: { + // color: 各异, + width: 1, + type: 'solid' + } + } + }, + itemStyle: { + normal: { + // color: 各异, + borderColor: 'rgba(0,0,0,0)', + borderWidth: 1 + }, + emphasis: { + // color: 各异, + borderColor: 'rgba(0,0,0,0)', + borderWidth: 1 + } + }, + + animationEasing: 'cubicOut', + + data: [] + } + }); + + zrUtil.mixin(PieSeries, dataSelectableMixin); + + module.exports = PieSeries; + + +/***/ }, +/* 134 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Data selectable mixin for chart series. + * To eanble data select, option of series must have `selectedMode`. + * And each data item will use `selected` to toggle itself selected status + * + * @module echarts/chart/helper/DataSelectable + */ + + + var zrUtil = __webpack_require__(3); + + module.exports = { + + updateSelectedMap: function () { + var option = this.option; + this._dataOptMap = zrUtil.reduce(option.data, function (dataOptMap, dataOpt) { + dataOptMap[dataOpt.name] = dataOpt; + return dataOptMap; + }, {}); + }, + /** + * @param {string} name + */ + // PENGING If selectedMode is null ? + select: function (name) { + var dataOptMap = this._dataOptMap; + var dataOpt = dataOptMap[name]; + var selectedMode = this.get('selectedMode'); + if (selectedMode === 'single') { + zrUtil.each(dataOptMap, function (dataOpt) { + dataOpt.selected = false; + }); + } + dataOpt && (dataOpt.selected = true); + }, + + /** + * @param {string} name + */ + unSelect: function (name) { + var dataOpt = this._dataOptMap[name]; + // var selectedMode = this.get('selectedMode'); + // selectedMode !== 'single' && dataOpt && (dataOpt.selected = false); + dataOpt && (dataOpt.selected = false); + }, + + /** + * @param {string} name + */ + toggleSelected: function (name) { + var dataOpt = this._dataOptMap[name]; + if (dataOpt != null) { + this[dataOpt.selected ? 'unSelect' : 'select'](name); + return dataOpt.selected; + } + }, + + /** + * @param {string} name + */ + isSelected: function (name) { + var dataOpt = this._dataOptMap[name]; + return dataOpt && dataOpt.selected; + } + }; + + +/***/ }, +/* 135 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + + /** + * @param {module:echarts/model/Series} seriesModel + * @param {boolean} hasAnimation + * @inner + */ + function updateDataSelected(uid, seriesModel, hasAnimation, api) { + var data = seriesModel.getData(); + var dataIndex = this.dataIndex; + var name = data.getName(dataIndex); + var selectedOffset = seriesModel.get('selectedOffset'); + + api.dispatchAction({ + type: 'pieToggleSelect', + from: uid, + name: name, + seriesId: seriesModel.id + }); + + data.each(function (idx) { + toggleItemSelected( + data.getItemGraphicEl(idx), + data.getItemLayout(idx), + seriesModel.isSelected(data.getName(idx)), + selectedOffset, + hasAnimation + ); + }); + } + + /** + * @param {module:zrender/graphic/Sector} el + * @param {Object} layout + * @param {boolean} isSelected + * @param {number} selectedOffset + * @param {boolean} hasAnimation + * @inner + */ + function toggleItemSelected(el, layout, isSelected, selectedOffset, hasAnimation) { + var midAngle = (layout.startAngle + layout.endAngle) / 2; + + var dx = Math.cos(midAngle); + var dy = Math.sin(midAngle); + + var offset = isSelected ? selectedOffset : 0; + var position = [dx * offset, dy * offset]; + + hasAnimation + // animateTo will stop revious animation like update transition + ? el.animate() + .when(200, { + position: position + }) + .start('bounceOut') + : el.attr('position', position); + } + + /** + * Piece of pie including Sector, Label, LabelLine + * @constructor + * @extends {module:zrender/graphic/Group} + */ + function PiePiece(data, idx) { + + graphic.Group.call(this); + + var sector = new graphic.Sector({ + z2: 2 + }); + var polyline = new graphic.Polyline(); + var text = new graphic.Text(); + this.add(sector); + this.add(polyline); + this.add(text); + + this.updateData(data, idx, true); + + // Hover to change label and labelLine + function onEmphasis() { + polyline.ignore = polyline.hoverIgnore; + text.ignore = text.hoverIgnore; + } + function onNormal() { + polyline.ignore = polyline.normalIgnore; + text.ignore = text.normalIgnore; + } + this.on('emphasis', onEmphasis) + .on('normal', onNormal) + .on('mouseover', onEmphasis) + .on('mouseout', onNormal); + } + + var piePieceProto = PiePiece.prototype; + + function getLabelStyle(data, idx, state, labelModel, labelPosition) { + var textStyleModel = labelModel.getModel('textStyle'); + var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner'; + return { + fill: textStyleModel.getTextColor() + || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')), + textFont: textStyleModel.getFont(), + text: zrUtil.retrieve( + data.hostModel.getFormattedLabel(idx, state), data.getName(idx) + ) + }; + } + + piePieceProto.updateData = function (data, idx, firstCreate) { + + var sector = this.childAt(0); + + var seriesModel = data.hostModel; + var itemModel = data.getItemModel(idx); + var layout = data.getItemLayout(idx); + var sectorShape = zrUtil.extend({}, layout); + sectorShape.label = null; + if (firstCreate) { + sector.setShape(sectorShape); + sector.shape.endAngle = layout.startAngle; + graphic.updateProps(sector, { + shape: { + endAngle: layout.endAngle + } + }, seriesModel); + } + else { + graphic.updateProps(sector, { + shape: sectorShape + }, seriesModel); + } + + // Update common style + var itemStyleModel = itemModel.getModel('itemStyle'); + var visualColor = data.getItemVisual(idx, 'color'); + + sector.setStyle( + zrUtil.defaults( + { + fill: visualColor + }, + itemStyleModel.getModel('normal').getItemStyle() + ) + ); + sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle(); + + // Toggle selected + toggleItemSelected( + this, + data.getItemLayout(idx), + itemModel.get('selected'), + seriesModel.get('selectedOffset'), + seriesModel.get('animation') + ); + + function onEmphasis() { + // Sector may has animation of updating data. Force to move to the last frame + // Or it may stopped on the wrong shape + sector.stopAnimation(true); + sector.animateTo({ + shape: { + r: layout.r + 10 + } + }, 300, 'elasticOut'); + } + function onNormal() { + sector.stopAnimation(true); + sector.animateTo({ + shape: { + r: layout.r + } + }, 300, 'elasticOut'); + } + sector.off('mouseover').off('mouseout').off('emphasis').off('normal'); + if (itemModel.get('hoverAnimation')) { + sector + .on('mouseover', onEmphasis) + .on('mouseout', onNormal) + .on('emphasis', onEmphasis) + .on('normal', onNormal); + } + + this._updateLabel(data, idx); + + graphic.setHoverStyle(this); + }; + + piePieceProto._updateLabel = function (data, idx) { + + var labelLine = this.childAt(1); + var labelText = this.childAt(2); + + var seriesModel = data.hostModel; + var itemModel = data.getItemModel(idx); + var layout = data.getItemLayout(idx); + var labelLayout = layout.label; + var visualColor = data.getItemVisual(idx, 'color'); + + graphic.updateProps(labelLine, { + shape: { + points: labelLayout.linePoints || [ + [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y] + ] + } + }, seriesModel); + + graphic.updateProps(labelText, { + style: { + x: labelLayout.x, + y: labelLayout.y + } + }, seriesModel); + labelText.attr({ + style: { + textVerticalAlign: labelLayout.verticalAlign, + textAlign: labelLayout.textAlign, + textFont: labelLayout.font + }, + rotation: labelLayout.rotation, + origin: [labelLayout.x, labelLayout.y], + z2: 10 + }); + + var labelModel = itemModel.getModel('label.normal'); + var labelHoverModel = itemModel.getModel('label.emphasis'); + var labelLineModel = itemModel.getModel('labelLine.normal'); + var labelLineHoverModel = itemModel.getModel('labelLine.emphasis'); + var labelPosition = labelModel.get('position') || labelHoverModel.get('position'); + + labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel, labelPosition)); + + labelText.ignore = labelText.normalIgnore = !labelModel.get('show'); + labelText.hoverIgnore = !labelHoverModel.get('show'); + + labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show'); + labelLine.hoverIgnore = !labelLineHoverModel.get('show'); + + // Default use item visual color + labelLine.setStyle({ + stroke: visualColor + }); + labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle()); + + labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel, labelPosition); + labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle(); + + var smooth = labelLineModel.get('smooth'); + if (smooth && smooth === true) { + smooth = 0.4; + } + labelLine.setShape({ + smooth: smooth + }); + }; + + zrUtil.inherits(PiePiece, graphic.Group); + + + // Pie view + var Pie = __webpack_require__(41).extend({ + + type: 'pie', + + init: function () { + var sectorGroup = new graphic.Group(); + this._sectorGroup = sectorGroup; + }, + + render: function (seriesModel, ecModel, api, payload) { + if (payload && (payload.from === this.uid)) { + return; + } + + var data = seriesModel.getData(); + var oldData = this._data; + var group = this.group; + + var hasAnimation = ecModel.get('animation'); + var isFirstRender = !oldData; + + var onSectorClick = zrUtil.curry( + updateDataSelected, this.uid, seriesModel, hasAnimation, api + ); + + var selectedMode = seriesModel.get('selectedMode'); + + data.diff(oldData) + .add(function (idx) { + var piePiece = new PiePiece(data, idx); + if (isFirstRender) { + piePiece.eachChild(function (child) { + child.stopAnimation(true); + }); + } + + selectedMode && piePiece.on('click', onSectorClick); + + data.setItemGraphicEl(idx, piePiece); + + group.add(piePiece); + }) + .update(function (newIdx, oldIdx) { + var piePiece = oldData.getItemGraphicEl(oldIdx); + + piePiece.updateData(data, newIdx); + + piePiece.off('click'); + selectedMode && piePiece.on('click', onSectorClick); + group.add(piePiece); + data.setItemGraphicEl(newIdx, piePiece); + }) + .remove(function (idx) { + var piePiece = oldData.getItemGraphicEl(idx); + group.remove(piePiece); + }) + .execute(); + + if (hasAnimation && isFirstRender && data.count() > 0) { + var shape = data.getItemLayout(0); + var r = Math.max(api.getWidth(), api.getHeight()) / 2; + + var removeClipPath = zrUtil.bind(group.removeClipPath, group); + group.setClipPath(this._createClipPath( + shape.cx, shape.cy, r, shape.startAngle, shape.clockwise, removeClipPath, seriesModel + )); + } + + this._data = data; + }, + + _createClipPath: function ( + cx, cy, r, startAngle, clockwise, cb, seriesModel + ) { + var clipPath = new graphic.Sector({ + shape: { + cx: cx, + cy: cy, + r0: 0, + r: r, + startAngle: startAngle, + endAngle: startAngle, + clockwise: clockwise + } + }); + + graphic.initProps(clipPath, { + shape: { + endAngle: startAngle + (clockwise ? 1 : -1) * Math.PI * 2 + } + }, seriesModel, cb); + + return clipPath; + } + }); + + module.exports = Pie; + + +/***/ }, +/* 136 */ +/***/ function(module, exports, __webpack_require__) { + + + var echarts = __webpack_require__(1); + var zrUtil = __webpack_require__(3); + module.exports = function (seriesType, actionInfos) { + zrUtil.each(actionInfos, function (actionInfo) { + actionInfo.update = 'updateView'; + /** + * @payload + * @property {string} seriesName + * @property {string} name + */ + echarts.registerAction(actionInfo, function (payload, ecModel) { + var selected = {}; + ecModel.eachComponent( + {mainType: 'series', subType: seriesType, query: payload}, + function (seriesModel) { + if (seriesModel[actionInfo.method]) { + seriesModel[actionInfo.method](payload.name); + } + var data = seriesModel.getData(); + // Create selected map + data.each(function (idx) { + var name = data.getName(idx); + selected[name] = seriesModel.isSelected(name) || false; + }); + } + ); + return { + name: payload.name, + selected: selected + }; + }); + }); + }; + + +/***/ }, +/* 137 */ +/***/ function(module, exports) { + + // Pick color from palette for each data item + + + module.exports = function (seriesType, ecModel) { + var globalColorList = ecModel.get('color'); + var offset = 0; + ecModel.eachRawSeriesByType(seriesType, function (seriesModel) { + var colorList = seriesModel.get('color', true); + var dataAll = seriesModel.getRawData(); + if (!ecModel.isSeriesFiltered(seriesModel)) { + var data = seriesModel.getData(); + data.each(function (idx) { + var itemModel = data.getItemModel(idx); + var rawIdx = data.getRawIndex(idx); + // If series.itemStyle.normal.color is a function. itemVisual may be encoded + var singleDataColor = data.getItemVisual(idx, 'color', true); + if (!singleDataColor) { + var paletteColor = colorList ? colorList[rawIdx % colorList.length] + : globalColorList[(rawIdx + offset) % globalColorList.length]; + var color = itemModel.get('itemStyle.normal.color') || paletteColor; + // Legend may use the visual info in data before processed + dataAll.setItemVisual(rawIdx, 'color', color); + data.setItemVisual(idx, 'color', color); + } + else { + // Set data all color for legend + dataAll.setItemVisual(rawIdx, 'color', singleDataColor); + } + }); + } + offset += dataAll.count(); + }); + }; + + +/***/ }, +/* 138 */ +/***/ function(module, exports, __webpack_require__) { + + // TODO minAngle + + + + var numberUtil = __webpack_require__(7); + var parsePercent = numberUtil.parsePercent; + var labelLayout = __webpack_require__(139); + var zrUtil = __webpack_require__(3); + + var PI2 = Math.PI * 2; + var RADIAN = Math.PI / 180; + + module.exports = function (seriesType, ecModel, api) { + ecModel.eachSeriesByType(seriesType, function (seriesModel) { + var center = seriesModel.get('center'); + var radius = seriesModel.get('radius'); + + if (!zrUtil.isArray(radius)) { + radius = [0, radius]; + } + if (!zrUtil.isArray(center)) { + center = [center, center]; + } + + var width = api.getWidth(); + var height = api.getHeight(); + var size = Math.min(width, height); + var cx = parsePercent(center[0], width); + var cy = parsePercent(center[1], height); + var r0 = parsePercent(radius[0], size / 2); + var r = parsePercent(radius[1], size / 2); + + var data = seriesModel.getData(); + + var startAngle = -seriesModel.get('startAngle') * RADIAN; + + var minAngle = seriesModel.get('minAngle') * RADIAN; + + var sum = data.getSum('value'); + // Sum may be 0 + var unitRadian = Math.PI / (sum || data.count()) * 2; + + var clockwise = seriesModel.get('clockwise'); + + var roseType = seriesModel.get('roseType'); + + // [0...max] + var extent = data.getDataExtent('value'); + extent[0] = 0; + + // In the case some sector angle is smaller than minAngle + var restAngle = PI2; + var valueSumLargerThanMinAngle = 0; + + var currentAngle = startAngle; + + var dir = clockwise ? 1 : -1; + data.each('value', function (value, idx) { + var angle; + // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样? + if (roseType !== 'area') { + angle = sum === 0 ? unitRadian : (value * unitRadian); + } + else { + angle = PI2 / (data.count() || 1); + } + + if (angle < minAngle) { + angle = minAngle; + restAngle -= minAngle; + } + else { + valueSumLargerThanMinAngle += value; + } + + var endAngle = currentAngle + dir * angle; + data.setItemLayout(idx, { + angle: angle, + startAngle: currentAngle, + endAngle: endAngle, + clockwise: clockwise, + cx: cx, + cy: cy, + r0: r0, + r: roseType + ? numberUtil.linearMap(value, extent, [r0, r]) + : r + }); + + currentAngle = endAngle; + }, true); + + // Some sector is constrained by minAngle + // Rest sectors needs recalculate angle + if (restAngle < PI2) { + // Average the angle if rest angle is not enough after all angles is + // Constrained by minAngle + if (restAngle <= 1e-3) { + var angle = PI2 / data.count(); + data.each(function (idx) { + var layout = data.getItemLayout(idx); + layout.startAngle = startAngle + dir * idx * angle; + layout.endAngle = startAngle + dir * (idx + 1) * angle; + }); + } + else { + unitRadian = restAngle / valueSumLargerThanMinAngle; + currentAngle = startAngle; + data.each('value', function (value, idx) { + var layout = data.getItemLayout(idx); + var angle = layout.angle === minAngle + ? minAngle : value * unitRadian; + layout.startAngle = currentAngle; + layout.endAngle = currentAngle + dir * angle; + currentAngle += angle; + }); + } + } + + labelLayout(seriesModel, r, width, height); + }); + }; + + +/***/ }, +/* 139 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // FIXME emphasis label position is not same with normal label position + + + var textContain = __webpack_require__(14); + + function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) { + list.sort(function (a, b) { + return a.y - b.y; + }); + + // 压 + function shiftDown(start, end, delta, dir) { + for (var j = start; j < end; j++) { + list[j].y += delta; + if (j > start + && j + 1 < end + && list[j + 1].y > list[j].y + list[j].height + ) { + shiftUp(j, delta / 2); + return; + } + } + + shiftUp(end - 1, delta / 2); + } + + // 弹 + function shiftUp(end, delta) { + for (var j = end; j >= 0; j--) { + list[j].y -= delta; + if (j > 0 + && list[j].y > list[j - 1].y + list[j - 1].height + ) { + break; + } + } + } + + // function changeX(list, isDownList, cx, cy, r, dir) { + // var deltaX; + // var deltaY; + // var length; + // var lastDeltaX = dir > 0 + // ? isDownList // 右侧 + // ? Number.MAX_VALUE // 下 + // : 0 // 上 + // : isDownList // 左侧 + // ? Number.MAX_VALUE // 下 + // : 0; // 上 + + // for (var i = 0, l = list.length; i < l; i++) { + // deltaY = Math.abs(list[i].y - cy); + // length = list[i].length; + // deltaX = (deltaY < r + length) + // ? Math.sqrt( + // (r + length + 20) * (r + length + 20) + // - Math.pow(list[i].y - cy, 2) + // ) + // : Math.abs( + // list[i].x - cx + // ); + // if (isDownList && deltaX >= lastDeltaX) { + // // 右下,左下 + // deltaX = lastDeltaX - 10; + // } + // if (!isDownList && deltaX <= lastDeltaX) { + // // 右上,左上 + // deltaX = lastDeltaX + 10; + // } + + // list[i].x = cx + deltaX * dir; + // lastDeltaX = deltaX; + // } + // } + + var lastY = 0; + var delta; + var len = list.length; + var upList = []; + var downList = []; + for (var i = 0; i < len; i++) { + delta = list[i].y - lastY; + if (delta < 0) { + shiftDown(i, len, -delta, dir); + } + lastY = list[i].y + list[i].height; + } + if (viewHeight - lastY < 0) { + shiftUp(len - 1, lastY - viewHeight); + } + for (var i = 0; i < len; i++) { + if (list[i].y >= cy) { + downList.push(list[i]); + } + else { + upList.push(list[i]); + } + } + // changeX(downList, true, cx, cy, r, dir); + // changeX(upList, false, cx, cy, r, dir); + } + + function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) { + var leftList = []; + var rightList = []; + for (var i = 0; i < labelLayoutList.length; i++) { + if (labelLayoutList[i].x < cx) { + leftList.push(labelLayoutList[i]); + } + else { + rightList.push(labelLayoutList[i]); + } + } + + adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight); + adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight); + + for (var i = 0; i < labelLayoutList.length; i++) { + var linePoints = labelLayoutList[i].linePoints; + if (linePoints) { + if (labelLayoutList[i].x < cx) { + linePoints[2][0] = labelLayoutList[i].x + 3; + } + else { + linePoints[2][0] = labelLayoutList[i].x - 3; + } + linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y; + } + } + } + + module.exports = function (seriesModel, r, viewWidth, viewHeight) { + var data = seriesModel.getData(); + var labelLayoutList = []; + var cx; + var cy; + var hasLabelRotate = false; + + data.each(function (idx) { + var layout = data.getItemLayout(idx); + + var itemModel = data.getItemModel(idx); + var labelModel = itemModel.getModel('label.normal'); + // Use position in normal or emphasis + var labelPosition = labelModel.get('position') || itemModel.get('label.emphasis.position'); + + var labelLineModel = itemModel.getModel('labelLine.normal'); + var labelLineLen = labelLineModel.get('length'); + var labelLineLen2 = labelLineModel.get('length2'); + + var midAngle = (layout.startAngle + layout.endAngle) / 2; + var dx = Math.cos(midAngle); + var dy = Math.sin(midAngle); + + var textX; + var textY; + var linePoints; + var textAlign; + + cx = layout.cx; + cy = layout.cy; + + if (labelPosition === 'center') { + textX = layout.cx; + textY = layout.cy; + textAlign = 'center'; + } + else { + var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner'; + var x1 = (isLabelInside ? layout.r / 2 * dx : layout.r * dx) + cx; + var y1 = (isLabelInside ? layout.r / 2 * dy : layout.r * dy) + cy; + + // For roseType + labelLineLen += r - layout.r; + + textX = x1 + dx * 3; + textY = y1 + dy * 3; + + if (!isLabelInside) { + var x2 = x1 + dx * labelLineLen; + var y2 = y1 + dy * labelLineLen; + var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2); + var y3 = y2; + + textX = x3 + (dx < 0 ? -5 : 5); + textY = y3; + linePoints = [[x1, y1], [x2, y2], [x3, y3]]; + } + + textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right'); + } + var font = labelModel.getModel('textStyle').getFont(); + + var labelRotate = labelModel.get('rotate') + ? (dx < 0 ? -midAngle + Math.PI : -midAngle) : 0; + var text = seriesModel.getFormattedLabel(idx, 'normal') + || data.getName(idx); + var textRect = textContain.getBoundingRect( + text, font, textAlign, 'top' + ); + hasLabelRotate = !!labelRotate; + layout.label = { + x: textX, + y: textY, + height: textRect.height, + length: labelLineLen, + length2: labelLineLen2, + linePoints: linePoints, + textAlign: textAlign, + verticalAlign: 'middle', + font: font, + rotation: labelRotate + }; + + labelLayoutList.push(layout.label); + }); + if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) { + avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight); + } + }; + + +/***/ }, +/* 140 */ +/***/ function(module, exports) { + + + module.exports = function (seriesType, ecModel) { + var legendModels = ecModel.findComponents({ + mainType: 'legend' + }); + if (!legendModels || !legendModels.length) { + return; + } + ecModel.eachSeriesByType(seriesType, function (series) { + var data = series.getData(); + data.filterSelf(function (idx) { + var name = data.getName(idx); + // If in any legend component the status is not selected. + for (var i = 0; i < legendModels.length; i++) { + if (!legendModels[i].isSelected(name)) { + return false; + } + } + return true; + }, this); + }, this); + }; + + +/***/ }, +/* 141 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var echarts = __webpack_require__(1); + + __webpack_require__(142); + __webpack_require__(143); + + echarts.registerVisualCoding('chart', zrUtil.curry( + __webpack_require__(103), 'scatter', 'circle', null + )); + echarts.registerLayout(zrUtil.curry( + __webpack_require__(104), 'scatter' + )); + + // In case developer forget to include grid component + __webpack_require__(106); + + +/***/ }, +/* 142 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var createListFromArray = __webpack_require__(93); + var SeriesModel = __webpack_require__(27); + + module.exports = SeriesModel.extend({ + + type: 'series.scatter', + + dependencies: ['grid', 'polar'], + + getInitialData: function (option, ecModel) { + var list = createListFromArray(option.data, this, ecModel); + return list; + }, + + defaultOption: { + coordinateSystem: 'cartesian2d', + zlevel: 0, + z: 2, + legendHoverLink: true, + + hoverAnimation: true, + // Cartesian coordinate system + xAxisIndex: 0, + yAxisIndex: 0, + + // Polar coordinate system + polarIndex: 0, + + // Geo coordinate system + geoIndex: 0, + + // symbol: null, // 图形类型 + symbolSize: 10, // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2 + // symbolRotate: null, // 图形旋转控制 + + large: false, + // Available when large is true + largeThreshold: 2000, + + // label: { + // normal: { + // show: false + // distance: 5, + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 + // 'inside'|'left'|'right'|'top'|'bottom' + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + // } + // }, + itemStyle: { + normal: { + opacity: 0.8 + // color: 各异 + } + } + } + }); + + +/***/ }, +/* 143 */ +/***/ function(module, exports, __webpack_require__) { + + + + var SymbolDraw = __webpack_require__(98); + var LargeSymbolDraw = __webpack_require__(144); + + __webpack_require__(1).extendChartView({ + + type: 'scatter', + + init: function () { + this._normalSymbolDraw = new SymbolDraw(); + this._largeSymbolDraw = new LargeSymbolDraw(); + }, + + render: function (seriesModel, ecModel, api) { + var data = seriesModel.getData(); + var largeSymbolDraw = this._largeSymbolDraw; + var normalSymbolDraw = this._normalSymbolDraw; + var group = this.group; + + var symbolDraw = seriesModel.get('large') && data.count() > seriesModel.get('largeThreshold') + ? largeSymbolDraw : normalSymbolDraw; + + this._symbolDraw = symbolDraw; + symbolDraw.updateData(data); + group.add(symbolDraw.group); + + group.remove( + symbolDraw === largeSymbolDraw + ? normalSymbolDraw.group : largeSymbolDraw.group + ); + }, + + updateLayout: function (seriesModel) { + this._symbolDraw.updateLayout(seriesModel); + }, + + remove: function (ecModel, api) { + this._symbolDraw && this._symbolDraw.remove(api, true); + } + }); + + +/***/ }, +/* 144 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var symbolUtil = __webpack_require__(100); + var zrUtil = __webpack_require__(3); + + var LargeSymbolPath = graphic.extendShape({ + shape: { + points: null, + sizes: null + }, + + symbolProxy: null, + + buildPath: function (path, shape) { + var points = shape.points; + var sizes = shape.sizes; + + var symbolProxy = this.symbolProxy; + var symbolProxyShape = symbolProxy.shape; + for (var i = 0; i < points.length; i++) { + var pt = points[i]; + var size = sizes[i]; + if (size[0] < 4) { + // Optimize for small symbol + path.rect( + pt[0] - size[0] / 2, pt[1] - size[1] / 2, + size[0], size[1] + ); + } + else { + symbolProxyShape.x = pt[0] - size[0] / 2; + symbolProxyShape.y = pt[1] - size[1] / 2; + symbolProxyShape.width = size[0]; + symbolProxyShape.height = size[1]; + + symbolProxy.buildPath(path, symbolProxyShape); + } + } + } + }); + + function LargeSymbolDraw() { + this.group = new graphic.Group(); + + this._symbolEl = new LargeSymbolPath({ + silent: true + }); + } + + var largeSymbolProto = LargeSymbolDraw.prototype; + + /** + * Update symbols draw by new data + * @param {module:echarts/data/List} data + */ + largeSymbolProto.updateData = function (data) { + this.group.removeAll(); + + var symbolEl = this._symbolEl; + + var seriesModel = data.hostModel; + + symbolEl.setShape({ + points: data.mapArray(data.getItemLayout), + sizes: data.mapArray( + function (idx) { + var size = data.getItemVisual(idx, 'symbolSize'); + if (!zrUtil.isArray(size)) { + size = [size, size]; + } + return size; + } + ) + }); + + // Create symbolProxy to build path for each data + symbolEl.symbolProxy = symbolUtil.createSymbol( + data.getVisual('symbol'), 0, 0, 0, 0 + ); + // Use symbolProxy setColor method + symbolEl.setColor = symbolEl.symbolProxy.setColor; + + symbolEl.setStyle( + seriesModel.getModel('itemStyle.normal').getItemStyle(['color']) + ); + + var visualColor = data.getVisual('color'); + if (visualColor) { + symbolEl.setColor(visualColor); + } + + // Add back + this.group.add(this._symbolEl); + }; + + largeSymbolProto.updateLayout = function (seriesModel) { + var data = seriesModel.getData(); + this._symbolEl.setShape({ + points: data.mapArray(data.getItemLayout) + }); + }; + + largeSymbolProto.remove = function () { + this.group.removeAll(); + }; + + module.exports = LargeSymbolDraw; + + +/***/ }, +/* 145 */, +/* 146 */, +/* 147 */, +/* 148 */, +/* 149 */, +/* 150 */, +/* 151 */, +/* 152 */, +/* 153 */, +/* 154 */, +/* 155 */, +/* 156 */, +/* 157 */, +/* 158 */, +/* 159 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/component/helper/RoamController + */ + + + + var Eventful = __webpack_require__(32); + var zrUtil = __webpack_require__(3); + var eventTool = __webpack_require__(80); + var interactionMutex = __webpack_require__(160); + + function mousedown(e) { + if (e.target && e.target.draggable) { + return; + } + + var x = e.offsetX; + var y = e.offsetY; + var rect = this.rect; + if (rect && rect.contain(x, y)) { + this._x = x; + this._y = y; + this._dragging = true; + } + } + + function mousemove(e) { + if (!this._dragging) { + return; + } + + eventTool.stop(e.event); + + if (e.gestureEvent !== 'pinch') { + + if (interactionMutex.isTaken('globalPan', this._zr)) { + return; + } + + var x = e.offsetX; + var y = e.offsetY; + + var dx = x - this._x; + var dy = y - this._y; + + this._x = x; + this._y = y; + + var target = this.target; + + if (target) { + var pos = target.position; + pos[0] += dx; + pos[1] += dy; + target.dirty(); + } + + eventTool.stop(e.event); + this.trigger('pan', dx, dy); + } + } + + function mouseup(e) { + this._dragging = false; + } + + function mousewheel(e) { + eventTool.stop(e.event); + // Convenience: + // Mac and VM Windows on Mac: scroll up: zoom out. + // Windows: scroll up: zoom in. + var zoomDelta = e.wheelDelta > 0 ? 1.1 : 1 / 1.1; + zoom.call(this, e, zoomDelta, e.offsetX, e.offsetY); + } + + function pinch(e) { + if (interactionMutex.isTaken('globalPan', this._zr)) { + return; + } + + eventTool.stop(e.event); + var zoomDelta = e.pinchScale > 1 ? 1.1 : 1 / 1.1; + zoom.call(this, e, zoomDelta, e.pinchX, e.pinchY); + } + + function zoom(e, zoomDelta, zoomX, zoomY) { + var rect = this.rect; + + if (rect && rect.contain(zoomX, zoomY)) { + + var target = this.target; + + if (target) { + var pos = target.position; + var scale = target.scale; + + var newZoom = this._zoom = this._zoom || 1; + newZoom *= zoomDelta; + // newZoom = Math.max( + // Math.min(target.maxZoom, newZoom), + // target.minZoom + // ); + var zoomScale = newZoom / this._zoom; + this._zoom = newZoom; + // Keep the mouse center when scaling + pos[0] -= (zoomX - pos[0]) * (zoomScale - 1); + pos[1] -= (zoomY - pos[1]) * (zoomScale - 1); + scale[0] *= zoomScale; + scale[1] *= zoomScale; + + target.dirty(); + } + + this.trigger('zoom', zoomDelta, zoomX, zoomY); + } + } + + /** + * @alias module:echarts/component/helper/RoamController + * @constructor + * @mixin {module:zrender/mixin/Eventful} + * + * @param {module:zrender/zrender~ZRender} zr + * @param {module:zrender/Element} target + * @param {module:zrender/core/BoundingRect} rect + */ + function RoamController(zr, target, rect) { + + /** + * @type {module:zrender/Element} + */ + this.target = target; + + /** + * @type {module:zrender/core/BoundingRect} + */ + this.rect = rect; + + /** + * @type {module:zrender} + */ + this._zr = zr; + + // Avoid two roamController bind the same handler + var bind = zrUtil.bind; + var mousedownHandler = bind(mousedown, this); + var mousemoveHandler = bind(mousemove, this); + var mouseupHandler = bind(mouseup, this); + var mousewheelHandler = bind(mousewheel, this); + var pinchHandler = bind(pinch, this); + + Eventful.call(this); + + /** + * Notice: only enable needed types. For example, if 'zoom' + * is not needed, 'zoom' should not be enabled, otherwise + * default mousewheel behaviour (scroll page) will be disabled. + * + * @param {boolean|string} [controlType=true] Specify the control type, + * which can be null/undefined or true/false + * or 'pan/move' or 'zoom'/'scale' + */ + this.enable = function (controlType) { + // Disable previous first + this.disable(); + + if (controlType == null) { + controlType = true; + } + + if (controlType === true || (controlType === 'move' || controlType === 'pan')) { + zr.on('mousedown', mousedownHandler); + zr.on('mousemove', mousemoveHandler); + zr.on('mouseup', mouseupHandler); + } + if (controlType === true || (controlType === 'scale' || controlType === 'zoom')) { + zr.on('mousewheel', mousewheelHandler); + zr.on('pinch', pinchHandler); + } + }; + + this.disable = function () { + zr.off('mousedown', mousedownHandler); + zr.off('mousemove', mousemoveHandler); + zr.off('mouseup', mouseupHandler); + zr.off('mousewheel', mousewheelHandler); + zr.off('pinch', pinchHandler); + }; + + this.dispose = this.disable; + + this.isDragging = function () { + return this._dragging; + }; + + this.isPinching = function () { + return this._pinching; + }; + } + + zrUtil.mixin(RoamController, Eventful); + + module.exports = RoamController; + + +/***/ }, +/* 160 */ +/***/ function(module, exports) { + + + + var ATTR = '\0_ec_interaction_mutex'; + + var interactionMutex = { + + take: function (key, zr) { + getStore(zr)[key] = true; + }, + + release: function (key, zr) { + getStore(zr)[key] = false; + }, + + isTaken: function (key, zr) { + return !!getStore(zr)[key]; + } + }; + + function getStore(zr) { + return zr[ATTR] || (zr[ATTR] = {}); + } + + module.exports = interactionMutex; + + +/***/ }, +/* 161 */, +/* 162 */, +/* 163 */, +/* 164 */, +/* 165 */, +/* 166 */, +/* 167 */, +/* 168 */, +/* 169 */, +/* 170 */, +/* 171 */, +/* 172 */, +/* 173 */, +/* 174 */, +/* 175 */, +/* 176 */, +/* 177 */, +/* 178 */, +/* 179 */, +/* 180 */, +/* 181 */, +/* 182 */, +/* 183 */, +/* 184 */, +/* 185 */, +/* 186 */, +/* 187 */, +/* 188 */, +/* 189 */, +/* 190 */, +/* 191 */, +/* 192 */, +/* 193 */, +/* 194 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/chart/helper/LineDraw + */ + + + var graphic = __webpack_require__(42); + var LineGroup = __webpack_require__(195); + + /** + * @alias module:echarts/component/marker/LineDraw + * @constructor + */ + function LineDraw(ctor) { + this._ctor = ctor || LineGroup; + this.group = new graphic.Group(); + } + + var lineDrawProto = LineDraw.prototype; + + /** + * @param {module:echarts/data/List} lineData + * @param {module:echarts/data/List} [fromData] + * @param {module:echarts/data/List} [toData] + */ + lineDrawProto.updateData = function (lineData, fromData, toData) { + + var oldLineData = this._lineData; + var group = this.group; + var LineCtor = this._ctor; + + lineData.diff(oldLineData) + .add(function (idx) { + var lineGroup = new LineCtor(lineData, fromData, toData, idx); + + lineData.setItemGraphicEl(idx, lineGroup); + + group.add(lineGroup); + }) + .update(function (newIdx, oldIdx) { + var lineGroup = oldLineData.getItemGraphicEl(oldIdx); + lineGroup.updateData(lineData, fromData, toData, newIdx); + + lineData.setItemGraphicEl(newIdx, lineGroup); + + group.add(lineGroup); + }) + .remove(function (idx) { + group.remove(oldLineData.getItemGraphicEl(idx)); + }) + .execute(); + + this._lineData = lineData; + this._fromData = fromData; + this._toData = toData; + }; + + lineDrawProto.updateLayout = function () { + var lineData = this._lineData; + lineData.eachItemGraphicEl(function (el, idx) { + el.updateLayout(lineData, this._fromData, this._toData, idx); + }, this); + }; + + lineDrawProto.remove = function () { + this.group.removeAll(); + }; + + module.exports = LineDraw; + + +/***/ }, +/* 195 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/chart/helper/Line + */ + + + var symbolUtil = __webpack_require__(100); + var vector = __webpack_require__(16); + var LinePath = __webpack_require__(196); + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + + /** + * @inner + */ + function createSymbol(name, data, idx) { + var color = data.getItemVisual(idx, 'color'); + var symbolType = data.getItemVisual(idx, 'symbol'); + var symbolSize = data.getItemVisual(idx, 'symbolSize'); + + if (symbolType === 'none') { + return; + } + + if (!zrUtil.isArray(symbolSize)) { + symbolSize = [symbolSize, symbolSize]; + } + var symbolPath = symbolUtil.createSymbol( + symbolType, -symbolSize[0] / 2, -symbolSize[1] / 2, + symbolSize[0], symbolSize[1], color + ); + symbolPath.name = name; + + return symbolPath; + } + + function createLine(points) { + var line = new LinePath({ + name: 'line', + style: { + strokeNoScale: true + } + }); + setLinePoints(line.shape, points); + return line; + } + + function setLinePoints(targetShape, points) { + var p1 = points[0]; + var p2 = points[1]; + var cp1 = points[2]; + targetShape.x1 = p1[0]; + targetShape.y1 = p1[1]; + targetShape.x2 = p2[0]; + targetShape.y2 = p2[1]; + targetShape.percent = 1; + + if (cp1) { + targetShape.cpx1 = cp1[0]; + targetShape.cpy1 = cp1[1]; + } + } + + function isSymbolArrow(symbol) { + return symbol.type === 'symbol' && symbol.shape.symbolType === 'arrow'; + } + + function updateSymbolBeforeLineUpdate () { + var lineGroup = this; + var line = lineGroup.childOfName('line'); + // If line not changed + if (!this.__dirty && !line.__dirty) { + return; + } + var symbolFrom = lineGroup.childOfName('fromSymbol'); + var symbolTo = lineGroup.childOfName('toSymbol'); + var label = lineGroup.childOfName('label'); + var fromPos = line.pointAt(0); + var toPos = line.pointAt(line.shape.percent); + + var d = vector.sub([], toPos, fromPos); + vector.normalize(d, d); + + if (symbolFrom) { + symbolFrom.attr('position', fromPos); + // Rotate the arrow + // FIXME Hard coded ? + if (isSymbolArrow(symbolFrom)) { + symbolFrom.attr('rotation', tangentRotation(toPos, fromPos)); + } + } + if (symbolTo) { + symbolTo.attr('position', toPos); + if (isSymbolArrow(symbolTo)) { + symbolTo.attr('rotation', tangentRotation(fromPos, toPos)); + } + } + + label.attr('position', toPos); + + var textPosition; + var textAlign; + var textVerticalAlign; + // End + if (label.__position === 'end') { + textPosition = [d[0] * 5 + toPos[0], d[1] * 5 + toPos[1]]; + textAlign = d[0] > 0.8 ? 'left' : (d[0] < -0.8 ? 'right' : 'center'); + textVerticalAlign = d[1] > 0.8 ? 'top' : (d[1] < -0.8 ? 'bottom' : 'middle'); + } + // Start + else { + textPosition = [-d[0] * 5 + fromPos[0], -d[1] * 5 + fromPos[1]]; + textAlign = d[0] > 0.8 ? 'right' : (d[0] < -0.8 ? 'left' : 'center'); + textVerticalAlign = d[1] > 0.8 ? 'bottom' : (d[1] < -0.8 ? 'top' : 'middle'); + } + label.attr({ + style: { + // Use the user specified text align and baseline first + textVerticalAlign: label.__verticalAlign || textVerticalAlign, + textAlign: label.__textAlign || textAlign + }, + position: textPosition + }); + } + + function tangentRotation(p1, p2) { + return -Math.PI / 2 - Math.atan2( + p2[1] - p1[1], p2[0] - p1[0] + ); + } + + /** + * @constructor + * @extends {module:zrender/graphic/Group} + * @alias {module:echarts/chart/helper/Line} + */ + function Line(lineData, fromData, toData, idx) { + graphic.Group.call(this); + + this._createLine(lineData, fromData, toData, idx); + } + + var lineProto = Line.prototype; + + // Update symbol position and rotation + lineProto.beforeUpdate = updateSymbolBeforeLineUpdate; + + lineProto._createLine = function (lineData, fromData, toData, idx) { + var seriesModel = lineData.hostModel; + var linePoints = lineData.getItemLayout(idx); + + var line = createLine(linePoints); + line.shape.percent = 0; + graphic.initProps(line, { + shape: { + percent: 1 + } + }, seriesModel); + + this.add(line); + + var label = new graphic.Text({ + name: 'label' + }); + this.add(label); + + if (fromData) { + var symbolFrom = createSymbol('fromSymbol', fromData, idx); + // symbols must added after line to make sure + // it will be updated after line#update. + // Or symbol position and rotation update in line#beforeUpdate will be one frame slow + this.add(symbolFrom); + + this._fromSymbolType = fromData.getItemVisual(idx, 'symbol'); + } + if (toData) { + var symbolTo = createSymbol('toSymbol', toData, idx); + this.add(symbolTo); + + this._toSymbolType = toData.getItemVisual(idx, 'symbol'); + } + + this._updateCommonStl(lineData, fromData, toData, idx); + }; + + lineProto.updateData = function (lineData, fromData, toData, idx) { + var seriesModel = lineData.hostModel; + + var line = this.childOfName('line'); + var linePoints = lineData.getItemLayout(idx); + var target = { + shape: {} + }; + setLinePoints(target.shape, linePoints); + graphic.updateProps(line, target, seriesModel); + + // Symbol changed + if (fromData) { + var fromSymbolType = fromData.getItemVisual(idx, 'symbol'); + if (this._fromSymbolType !== fromSymbolType) { + var symbolFrom = createSymbol('fromSymbol', fromData, idx); + this.remove(this.childOfName('fromSymbol')); + this.add(symbolFrom); + } + this._fromSymbolType = fromSymbolType; + } + if (toData) { + var toSymbolType = toData.getItemVisual(idx, 'symbol'); + // Symbol changed + if (toSymbolType !== this._toSymbolType) { + var symbolTo = createSymbol('toSymbol', toData, idx); + this.remove(this.childOfName('toSymbol')); + this.add(symbolTo); + } + this._toSymbolType = toSymbolType; + } + + this._updateCommonStl(lineData, fromData, toData, idx); + }; + + lineProto._updateCommonStl = function (lineData, fromData, toData, idx) { + var seriesModel = lineData.hostModel; + + var line = this.childOfName('line'); + var itemModel = lineData.getItemModel(idx); + + var labelModel = itemModel.getModel('label.normal'); + var textStyleModel = labelModel.getModel('textStyle'); + var labelHoverModel = itemModel.getModel('label.emphasis'); + var textStyleHoverModel = labelHoverModel.getModel('textStyle'); + + var defaultText = numberUtil.round(seriesModel.getRawValue(idx)); + if (isNaN(defaultText)) { + // Use name + defaultText = lineData.getName(idx); + } + line.setStyle(zrUtil.extend( + { + stroke: lineData.getItemVisual(idx, 'color') + }, + itemModel.getModel('lineStyle.normal').getLineStyle() + )); + + var label = this.childOfName('label'); + label.setStyle({ + text: labelModel.get('show') + ? zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'normal'), + defaultText + ) + : '', + textFont: textStyleModel.getFont(), + fill: textStyleModel.getTextColor() || lineData.getItemVisual(idx, 'color') + }); + label.hoverStyle = { + text: labelHoverModel.get('show') + ? zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'emphasis'), + defaultText + ) + : '', + textFont: textStyleModel.getFont(), + fill: textStyleHoverModel.getTextColor() + }; + label.__textAlign = textStyleModel.get('align'); + label.__verticalAlign = textStyleModel.get('baseline'); + label.__position = labelModel.get('position'); + + graphic.setHoverStyle( + this, itemModel.getModel('lineStyle.emphasis').getLineStyle() + ); + }; + + lineProto.updateLayout = function (lineData, fromData, toData, idx) { + var points = lineData.getItemLayout(idx); + var linePath = this.childOfName('line'); + setLinePoints(linePath.shape, points); + linePath.dirty(true); + fromData && fromData.getItemGraphicEl(idx).attr('position', points[0]); + toData && toData.getItemGraphicEl(idx).attr('position', points[1]); + }; + + zrUtil.inherits(Line, graphic.Group); + + module.exports = Line; + + +/***/ }, +/* 196 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Line path for bezier and straight line draw + */ + + var graphic = __webpack_require__(42); + + var straightLineProto = graphic.Line.prototype; + var bezierCurveProto = graphic.BezierCurve.prototype; + + module.exports = graphic.extendShape({ + + type: 'ec-line', + + style: { + stroke: '#000', + fill: null + }, + + shape: { + x1: 0, + y1: 0, + x2: 0, + y2: 0, + percent: 1, + cpx1: null, + cpy1: null + }, + + buildPath: function (ctx, shape) { + (shape.cpx1 == null || shape.cpy1 == null + ? straightLineProto : bezierCurveProto).buildPath(ctx, shape); + }, + + pointAt: function (t) { + var shape = this.shape; + return shape.cpx1 == null || shape.cpy1 == null + ? straightLineProto.pointAt.call(this, t) + : bezierCurveProto.pointAt.call(this, t); + } + }); + + +/***/ }, +/* 197 */, +/* 198 */, +/* 199 */, +/* 200 */, +/* 201 */, +/* 202 */, +/* 203 */, +/* 204 */, +/* 205 */, +/* 206 */, +/* 207 */, +/* 208 */, +/* 209 */, +/* 210 */, +/* 211 */, +/* 212 */, +/* 213 */, +/* 214 */, +/* 215 */, +/* 216 */, +/* 217 */, +/* 218 */, +/* 219 */, +/* 220 */, +/* 221 */, +/* 222 */, +/* 223 */, +/* 224 */, +/* 225 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Box selection tool. + * + * @module echarts/component/helper/SelectController + */ + + + + var Eventful = __webpack_require__(32); + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var bind = zrUtil.bind; + var each = zrUtil.each; + var mathMin = Math.min; + var mathMax = Math.max; + var mathPow = Math.pow; + + var COVER_Z = 10000; + var UNSELECT_THRESHOLD = 2; + var EVENTS = ['mousedown', 'mousemove', 'mouseup']; + + /** + * @alias module:echarts/component/helper/SelectController + * @constructor + * @mixin {module:zrender/mixin/Eventful} + * + * @param {string} type 'line', 'rect' + * @param {module:zrender/zrender~ZRender} zr + * @param {Object} [opt] + * @param {number} [opt.width] + * @param {number} [opt.lineWidth] + * @param {string} [opt.stroke] + * @param {string} [opt.fill] + */ + function SelectController(type, zr, opt) { + + Eventful.call(this); + + /** + * @type {string} + * @readOnly + */ + this.type = type; + + /** + * @type {module:zrender/zrender~ZRender} + */ + this.zr = zr; + + /** + * @type {Object} + * @readOnly + */ + this.opt = zrUtil.clone(opt); + + /** + * @type {module:zrender/container/Group} + * @readOnly + */ + this.group = new graphic.Group(); + + /** + * @type {module:zrender/core/BoundingRect} + */ + this._containerRect = null; + + /** + * @type {Array.} + * @private + */ + this._track = []; + + /** + * @type {boolean} + */ + this._dragging; + + /** + * @type {module:zrender/Element} + * @private + */ + this._cover; + + /** + * @type {boolean} + * @private + */ + this._disabled = true; + + /** + * @type {Object} + * @private + */ + this._handlers = { + mousedown: bind(mousedown, this), + mousemove: bind(mousemove, this), + mouseup: bind(mouseup, this) + }; + + each(EVENTS, function (eventName) { + this.zr.on(eventName, this._handlers[eventName]); + }, this); + } + + SelectController.prototype = { + + constructor: SelectController, + + /** + * @param {module:zrender/mixin/Transformable} container + * @param {module:zrender/core/BoundingRect|boolean} [rect] If not specified, + * use container.getBoundingRect(). + * If false, do not use containerRect. + */ + enable: function (container, rect) { + + this._disabled = false; + + // Remove from old container. + removeGroup.call(this); + + // boundingRect will change when dragging, so we have + // to keep initial boundingRect. + this._containerRect = rect !== false + ? (rect || container.getBoundingRect()) : null; + + // Add to new container. + container.add(this.group); + }, + + /** + * Update cover location. + * @param {Array.|Object} ranges If null/undefined, remove cover. + */ + update: function (ranges) { + // TODO + // Only support one interval yet. + renderCover.call(this, ranges && zrUtil.clone(ranges)); + }, + + disable: function () { + this._disabled = true; + + removeGroup.call(this); + }, + + dispose: function () { + this.disable(); + + each(EVENTS, function (eventName) { + this.zr.off(eventName, this._handlers[eventName]); + }, this); + } + }; + + + zrUtil.mixin(SelectController, Eventful); + + function updateZ(group) { + group.traverse(function (el) { + el.z = COVER_Z; + }); + } + + function isInContainer(x, y) { + var localPos = this.group.transformCoordToLocal(x, y); + return !this._containerRect + || this._containerRect.contain(localPos[0], localPos[1]); + } + + function preventDefault(e) { + var rawE = e.event; + rawE.preventDefault && rawE.preventDefault(); + } + + function mousedown(e) { + if (this._disabled || (e.target && e.target.draggable)) { + return; + } + + preventDefault(e); + + var x = e.offsetX; + var y = e.offsetY; + + if (isInContainer.call(this, x, y)) { + this._dragging = true; + this._track = [[x, y]]; + } + } + + function mousemove(e) { + if (!this._dragging || this._disabled) { + return; + } + + preventDefault(e); + + updateViewByCursor.call(this, e); + } + + function mouseup(e) { + if (!this._dragging || this._disabled) { + return; + } + + preventDefault(e); + + updateViewByCursor.call(this, e, true); + + this._dragging = false; + this._track = []; + } + + function updateViewByCursor(e, isEnd) { + var x = e.offsetX; + var y = e.offsetY; + + if (isInContainer.call(this, x, y)) { + this._track.push([x, y]); + + // Create or update cover. + var ranges = shouldShowCover.call(this) + ? coverRenderers[this.type].getRanges.call(this) + // Remove cover. + : []; + + renderCover.call(this, ranges); + + this.trigger('selected', zrUtil.clone(ranges)); + + if (isEnd) { + this.trigger('selectEnd', zrUtil.clone(ranges)); + } + } + } + + function shouldShowCover() { + var track = this._track; + + if (!track.length) { + return false; + } + + var p2 = track[track.length - 1]; + var p1 = track[0]; + var dx = p2[0] - p1[0]; + var dy = p2[1] - p1[1]; + var dist = mathPow(dx * dx + dy * dy, 0.5); + + return dist > UNSELECT_THRESHOLD; + } + + function renderCover(ranges) { + var coverRenderer = coverRenderers[this.type]; + + if (ranges && ranges.length) { + if (!this._cover) { + this._cover = coverRenderer.create.call(this); + this.group.add(this._cover); + } + coverRenderer.update.call(this, ranges); + } + else { + this.group.remove(this._cover); + this._cover = null; + } + + updateZ(this.group); + } + + function removeGroup() { + // container may 'removeAll' outside. + var group = this.group; + var container = group.parent; + if (container) { + container.remove(group); + } + } + + function createRectCover() { + var opt = this.opt; + return new graphic.Rect({ + // FIXME + // customize style. + style: { + stroke: opt.stroke, + fill: opt.fill, + lineWidth: opt.lineWidth, + opacity: opt.opacity + } + }); + } + + function getLocalTrack() { + return zrUtil.map(this._track, function (point) { + return this.group.transformCoordToLocal(point[0], point[1]); + }, this); + } + + function getLocalTrackEnds() { + var localTrack = getLocalTrack.call(this); + var tail = localTrack.length - 1; + tail < 0 && (tail = 0); + return [localTrack[0], localTrack[tail]]; + } + + /** + * key: this.type + * @type {Object} + */ + var coverRenderers = { + + line: { + + create: createRectCover, + + getRanges: function () { + var ends = getLocalTrackEnds.call(this); + var min = mathMin(ends[0][0], ends[1][0]); + var max = mathMax(ends[0][0], ends[1][0]); + + return [[min, max]]; + }, + + update: function (ranges) { + var range = ranges[0]; + var width = this.opt.width; + this._cover.setShape({ + x: range[0], + y: -width / 2, + width: range[1] - range[0], + height: width + }); + } + }, + + rect: { + + create: createRectCover, + + getRanges: function () { + var ends = getLocalTrackEnds.call(this); + + var min = [ + mathMin(ends[1][0], ends[0][0]), + mathMin(ends[1][1], ends[0][1]) + ]; + var max = [ + mathMax(ends[1][0], ends[0][0]), + mathMax(ends[1][1], ends[0][1]) + ]; + + return [[ + [min[0], max[0]], // x range + [min[1], max[1]] // y range + ]]; + }, + + update: function (ranges) { + var range = ranges[0]; + this._cover.setShape({ + x: range[0][0], + y: range[1][0], + width: range[0][1] - range[0][0], + height: range[1][1] - range[1][0] + }); + } + } + }; + + module.exports = SelectController; + + +/***/ }, +/* 226 */, +/* 227 */, +/* 228 */, +/* 229 */, +/* 230 */, +/* 231 */, +/* 232 */, +/* 233 */, +/* 234 */, +/* 235 */, +/* 236 */, +/* 237 */, +/* 238 */, +/* 239 */, +/* 240 */, +/* 241 */, +/* 242 */, +/* 243 */, +/* 244 */, +/* 245 */, +/* 246 */, +/* 247 */, +/* 248 */, +/* 249 */, +/* 250 */, +/* 251 */, +/* 252 */, +/* 253 */, +/* 254 */, +/* 255 */, +/* 256 */, +/* 257 */, +/* 258 */, +/* 259 */, +/* 260 */, +/* 261 */, +/* 262 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Legend component entry file8 + */ + + + __webpack_require__(263); + __webpack_require__(264); + __webpack_require__(265); + + var echarts = __webpack_require__(1); + // Series Filter + echarts.registerProcessor('filter', __webpack_require__(267)); + + +/***/ }, +/* 263 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var Model = __webpack_require__(8); + + var LegendModel = __webpack_require__(1).extendComponentModel({ + + type: 'legend', + + dependencies: ['series'], + + layoutMode: { + type: 'box', + ignoreSize: true + }, + + init: function (option, parentModel, ecModel) { + this.mergeDefaultAndTheme(option, ecModel); + + option.selected = option.selected || {}; + + this._updateData(ecModel); + + var legendData = this._data; + // If has any selected in option.selected + var selectedMap = this.option.selected; + // If selectedMode is single, try to select one + if (legendData[0] && this.get('selectedMode') === 'single') { + var hasSelected = false; + for (var name in selectedMap) { + if (selectedMap[name]) { + this.select(name); + hasSelected = true; + } + } + // Try select the first if selectedMode is single + !hasSelected && this.select(legendData[0].get('name')); + } + }, + + mergeOption: function (option) { + LegendModel.superCall(this, 'mergeOption', option); + + this._updateData(this.ecModel); + }, + + _updateData: function (ecModel) { + var legendData = zrUtil.map(this.get('data') || [], function (dataItem) { + if (typeof dataItem === 'string') { + dataItem = { + name: dataItem + }; + } + return new Model(dataItem, this, this.ecModel); + }, this); + this._data = legendData; + + var availableNames = zrUtil.map(ecModel.getSeries(), function (series) { + return series.name; + }); + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.legendDataProvider) { + var data = seriesModel.legendDataProvider(); + availableNames = availableNames.concat(data.mapArray(data.getName)); + } + }); + /** + * @type {Array.} + * @private + */ + this._availableNames = availableNames; + }, + + /** + * @return {Array.} + */ + getData: function () { + return this._data; + }, + + /** + * @param {string} name + */ + select: function (name) { + var selected = this.option.selected; + var selectedMode = this.get('selectedMode'); + if (selectedMode === 'single') { + var data = this._data; + zrUtil.each(data, function (dataItem) { + selected[dataItem.get('name')] = false; + }); + } + selected[name] = true; + }, + + /** + * @param {string} name + */ + unSelect: function (name) { + if (this.get('selectedMode') !== 'single') { + this.option.selected[name] = false; + } + }, + + /** + * @param {string} name + */ + toggleSelected: function (name) { + var selected = this.option.selected; + // Default is true + if (!(name in selected)) { + selected[name] = true; + } + this[selected[name] ? 'unSelect' : 'select'](name); + }, + + /** + * @param {string} name + */ + isSelected: function (name) { + var selected = this.option.selected; + return !((name in selected) && !selected[name]) + && zrUtil.indexOf(this._availableNames, name) >= 0; + }, + + defaultOption: { + // 一级层叠 + zlevel: 0, + // 二级层叠 + z: 4, + show: true, + + // 布局方式,默认为水平布局,可选为: + // 'horizontal' | 'vertical' + orient: 'horizontal', + + left: 'center', + // right: 'center', + + top: 'top', + // bottom: 'top', + + // 水平对齐 + // 'auto' | 'left' | 'right' + // 默认为 'auto', 根据 x 的位置判断是左对齐还是右对齐 + align: 'auto', + + backgroundColor: 'rgba(0,0,0,0)', + // 图例边框颜色 + borderColor: '#ccc', + // 图例边框线宽,单位px,默认为0(无边框) + borderWidth: 0, + // 图例内边距,单位px,默认各方向内边距为5, + // 接受数组分别设定上右下左边距,同css + padding: 5, + // 各个item之间的间隔,单位px,默认为10, + // 横向布局时为水平间隔,纵向布局时为纵向间隔 + itemGap: 10, + // 图例图形宽度 + itemWidth: 25, + // 图例图形高度 + itemHeight: 14, + textStyle: { + // 图例文字颜色 + color: '#333' + }, + // formatter: '', + // 选择模式,默认开启图例开关 + selectedMode: true + // 配置默认选中状态,可配合LEGEND.SELECTED事件做动态数据载入 + // selected: null, + // 图例内容(详见legend.data,数组中每一项代表一个item + // data: [], + } + }); + + module.exports = LegendModel; + + +/***/ }, +/* 264 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Legend action + */ + + + var echarts = __webpack_require__(1); + var zrUtil = __webpack_require__(3); + + function legendSelectActionHandler(methodName, payload, ecModel) { + var selectedMap = {}; + var isToggleSelect = methodName === 'toggleSelected'; + var isSelected; + // Update all legend components + ecModel.eachComponent('legend', function (legendModel) { + if (isToggleSelect && isSelected != null) { + // Force other legend has same selected status + // Or the first is toggled to true and other are toggled to false + // In the case one legend has some item unSelected in option. And if other legend + // doesn't has the item, they will assume it is selected. + legendModel[isSelected ? 'select' : 'unSelect'](payload.name); + } + else { + legendModel[methodName](payload.name); + isSelected = legendModel.isSelected(payload.name); + } + var legendData = legendModel.getData(); + zrUtil.each(legendData, function (model) { + var name = model.get('name'); + // Wrap element + if (name === '\n' || name === '') { + return; + } + var isItemSelected = legendModel.isSelected(name); + if (name in selectedMap) { + // Unselected if any legend is unselected + selectedMap[name] = selectedMap[name] && isItemSelected; + } + else { + selectedMap[name] = isItemSelected; + } + }); + }); + // Return the event explicitly + return { + name: payload.name, + selected: selectedMap + }; + } + /** + * @event legendToggleSelect + * @type {Object} + * @property {string} type 'legendToggleSelect' + * @property {string} [from] + * @property {string} name Series name or data item name + */ + echarts.registerAction( + 'legendToggleSelect', 'legendselectchanged', + zrUtil.curry(legendSelectActionHandler, 'toggleSelected') + ); + + /** + * @event legendSelect + * @type {Object} + * @property {string} type 'legendSelect' + * @property {string} name Series name or data item name + */ + echarts.registerAction( + 'legendSelect', 'legendselected', + zrUtil.curry(legendSelectActionHandler, 'select') + ); + + /** + * @event legendUnSelect + * @type {Object} + * @property {string} type 'legendUnSelect' + * @property {string} name Series name or data item name + */ + echarts.registerAction( + 'legendUnSelect', 'legendunselected', + zrUtil.curry(legendSelectActionHandler, 'unSelect') + ); + + +/***/ }, +/* 265 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var symbolCreator = __webpack_require__(100); + var graphic = __webpack_require__(42); + var listComponentHelper = __webpack_require__(266); + + var curry = zrUtil.curry; + + var LEGEND_DISABLE_COLOR = '#ccc'; + + function dispatchSelectAction(name, api) { + api.dispatchAction({ + type: 'legendToggleSelect', + name: name + }); + } + + function dispatchHighlightAction(seriesModel, dataName, api) { + seriesModel.get('legendHoverLink') && api.dispatchAction({ + type: 'highlight', + seriesName: seriesModel.name, + name: dataName + }); + } + + function dispatchDownplayAction(seriesModel, dataName, api) { + seriesModel.get('legendHoverLink') &&api.dispatchAction({ + type: 'downplay', + seriesName: seriesModel.name, + name: dataName + }); + } + + module.exports = __webpack_require__(1).extendComponentView({ + + type: 'legend', + + init: function () { + this._symbolTypeStore = {}; + }, + + render: function (legendModel, ecModel, api) { + var group = this.group; + group.removeAll(); + + if (!legendModel.get('show')) { + return; + } + + var selectMode = legendModel.get('selectedMode'); + var itemAlign = legendModel.get('align'); + + if (itemAlign === 'auto') { + itemAlign = (legendModel.get('left') === 'right' + && legendModel.get('orient') === 'vertical') + ? 'right' : 'left'; + } + + var legendItemMap = {}; + var legendDrawedMap = {}; + zrUtil.each(legendModel.getData(), function (itemModel) { + var seriesName = itemModel.get('name'); + // Use empty string or \n as a newline string + if (seriesName === '' || seriesName === '\n') { + group.add(new graphic.Group({ + newline: true + })); + } + + var seriesModel = ecModel.getSeriesByName(seriesName)[0]; + + legendItemMap[seriesName] = itemModel; + + if (!seriesModel || legendDrawedMap[seriesName]) { + // Series not exists + return; + } + + var data = seriesModel.getData(); + var color = data.getVisual('color'); + + // If color is a callback function + if (typeof color === 'function') { + // Use the first data + color = color(seriesModel.getDataParams(0)); + } + + // Using rect symbol defaultly + var legendSymbolType = data.getVisual('legendSymbol') || 'roundRect'; + var symbolType = data.getVisual('symbol'); + + var itemGroup = this._createItem( + seriesName, itemModel, legendModel, + legendSymbolType, symbolType, + itemAlign, color, + selectMode + ); + + itemGroup.on('click', curry(dispatchSelectAction, seriesName, api)) + .on('mouseover', curry(dispatchHighlightAction, seriesModel, '', api)) + .on('mouseout', curry(dispatchDownplayAction, seriesModel, '', api)); + + legendDrawedMap[seriesName] = true; + }, this); + + ecModel.eachRawSeries(function (seriesModel) { + if (seriesModel.legendDataProvider) { + var data = seriesModel.legendDataProvider(); + data.each(function (idx) { + var name = data.getName(idx); + + // Avoid mutiple series use the same data name + if (!legendItemMap[name] || legendDrawedMap[name]) { + return; + } + + var color = data.getItemVisual(idx, 'color'); + + var legendSymbolType = 'roundRect'; + + var itemGroup = this._createItem( + name, legendItemMap[name], legendModel, + legendSymbolType, null, + itemAlign, color, + selectMode + ); + + itemGroup.on('click', curry(dispatchSelectAction, name, api)) + // FIXME Should not specify the series name + .on('mouseover', curry(dispatchHighlightAction, seriesModel, name, api)) + .on('mouseout', curry(dispatchDownplayAction, seriesModel, name, api)); + + legendDrawedMap[name] = true; + }, false, this); + } + }, this); + + listComponentHelper.layout(group, legendModel, api); + // Render background after group is layout + // FIXME + listComponentHelper.addBackground(group, legendModel); + }, + + _createItem: function ( + name, itemModel, legendModel, + legendSymbolType, symbolType, + itemAlign, color, selectMode + ) { + var itemWidth = legendModel.get('itemWidth'); + var itemHeight = legendModel.get('itemHeight'); + + var isSelected = legendModel.isSelected(name); + var itemGroup = new graphic.Group(); + + var textStyleModel = itemModel.getModel('textStyle'); + + var itemIcon = itemModel.get('icon'); + + // Use user given icon first + legendSymbolType = itemIcon || legendSymbolType; + itemGroup.add(symbolCreator.createSymbol( + legendSymbolType, 0, 0, itemWidth, itemHeight, isSelected ? color : LEGEND_DISABLE_COLOR + )); + + // Compose symbols + // PENDING + if (!itemIcon && symbolType + // At least show one symbol, can't be all none + && ((symbolType !== legendSymbolType) || symbolType == 'none') + ) { + var size = itemHeight * 0.8; + if (symbolType === 'none') { + symbolType = 'circle'; + } + // Put symbol in the center + itemGroup.add(symbolCreator.createSymbol( + symbolType, (itemWidth - size) / 2, (itemHeight - size) / 2, size, size, + isSelected ? color : LEGEND_DISABLE_COLOR + )); + } + + // Text + var textX = itemAlign === 'left' ? itemWidth + 5 : -5; + var textAlign = itemAlign; + + var formatter = legendModel.get('formatter'); + if (typeof formatter === 'string' && formatter) { + name = formatter.replace('{name}', name); + } + else if (typeof formatter === 'function') { + name = formatter(name); + } + + var text = new graphic.Text({ + style: { + text: name, + x: textX, + y: itemHeight / 2, + fill: isSelected ? textStyleModel.getTextColor() : LEGEND_DISABLE_COLOR, + textFont: textStyleModel.getFont(), + textAlign: textAlign, + textVerticalAlign: 'middle' + } + }); + itemGroup.add(text); + + // Add a invisible rect to increase the area of mouse hover + itemGroup.add(new graphic.Rect({ + shape: itemGroup.getBoundingRect(), + invisible: true + })); + + itemGroup.eachChild(function (child) { + child.silent = !selectMode; + }); + + this.group.add(itemGroup); + + return itemGroup; + } + }); + + +/***/ }, +/* 266 */ +/***/ function(module, exports, __webpack_require__) { + + + // List layout + var layout = __webpack_require__(21); + var formatUtil = __webpack_require__(6); + var graphic = __webpack_require__(42); + + function positionGroup(group, model, api) { + layout.positionGroup( + group, model.getBoxLayoutParams(), + { + width: api.getWidth(), + height: api.getHeight() + }, + model.get('padding') + ); + } + + module.exports = { + /** + * Layout list like component. + * It will box layout each items in group of component and then position the whole group in the viewport + * @param {module:zrender/group/Group} group + * @param {module:echarts/model/Component} componentModel + * @param {module:echarts/ExtensionAPI} + */ + layout: function (group, componentModel, api) { + var rect = layout.getLayoutRect(componentModel.getBoxLayoutParams(), { + width: api.getWidth(), + height: api.getHeight() + }, componentModel.get('padding')); + layout.box( + componentModel.get('orient'), + group, + componentModel.get('itemGap'), + rect.width, + rect.height + ); + + positionGroup(group, componentModel, api); + }, + + addBackground: function (group, componentModel) { + var padding = formatUtil.normalizeCssArray( + componentModel.get('padding') + ); + var boundingRect = group.getBoundingRect(); + var style = componentModel.getItemStyle(['color', 'opacity']); + style.fill = componentModel.get('backgroundColor'); + var rect = new graphic.Rect({ + shape: { + x: boundingRect.x - padding[3], + y: boundingRect.y - padding[0], + width: boundingRect.width + padding[1] + padding[3], + height: boundingRect.height + padding[0] + padding[2] + }, + style: style, + silent: true, + z2: -1 + }); + graphic.subPixelOptimizeRect(rect); + + group.add(rect); + } + }; + + +/***/ }, +/* 267 */ +/***/ function(module, exports) { + + + module.exports = function (ecModel) { + var legendModels = ecModel.findComponents({ + mainType: 'legend' + }); + if (legendModels && legendModels.length) { + ecModel.filterSeries(function (series) { + // If in any legend component the status is not selected. + // Because in legend series + for (var i = 0; i < legendModels.length; i++) { + if (!legendModels[i].isSelected(series.name)) { + return false; + } + } + return true; + }); + } + }; + + +/***/ }, +/* 268 */ +/***/ function(module, exports, __webpack_require__) { + + // FIXME Better way to pack data in graphic element + + + __webpack_require__(269); + + __webpack_require__(270); + + // Show tip action + /** + * @action + * @property {string} type + * @property {number} seriesIndex + * @property {number} dataIndex + * @property {number} [x] + * @property {number} [y] + */ + __webpack_require__(1).registerAction( + { + type: 'showTip', + event: 'showTip', + update: 'none' + }, + // noop + function () {} + ); + // Hide tip action + __webpack_require__(1).registerAction( + { + type: 'hideTip', + event: 'hideTip', + update: 'none' + }, + // noop + function () {} + ); + + +/***/ }, +/* 269 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(1).extendComponentModel({ + + type: 'tooltip', + + defaultOption: { + zlevel: 0, + + z: 8, + + show: true, + + // tooltip主体内容 + showContent: true, + + // 触发类型,默认数据触发,见下图,可选为:'item' ¦ 'axis' + trigger: 'item', + + // 触发条件,支持 'click' | 'mousemove' + triggerOn: 'mousemove', + + // 是否永远显示 content + alwaysShowContent: false, + + // 位置 {Array} | {Function} + // position: null + + // 内容格式器:{string}(Template) ¦ {Function} + // formatter: null + + // 隐藏延迟,单位ms + hideDelay: 100, + + // 动画变换时间,单位s + transitionDuration: 0.4, + + enterable: false, + + // 提示背景颜色,默认为透明度为0.7的黑色 + backgroundColor: 'rgba(50,50,50,0.7)', + + // 提示边框颜色 + borderColor: '#333', + + // 提示边框圆角,单位px,默认为4 + borderRadius: 4, + + // 提示边框线宽,单位px,默认为0(无边框) + borderWidth: 0, + + // 提示内边距,单位px,默认各方向内边距为5, + // 接受数组分别设定上右下左边距,同css + padding: 5, + + // 坐标轴指示器,坐标轴触发有效 + axisPointer: { + // 默认为直线 + // 可选为:'line' | 'shadow' | 'cross' + type: 'line', + + // type 为 line 的时候有效,指定 tooltip line 所在的轴,可选 + // 可选 'x' | 'y' | 'angle' | 'radius' | 'auto' + // 默认 'auto',会选择类型为 cateogry 的轴,对于双数值轴,笛卡尔坐标系会默认选择 x 轴 + // 极坐标系会默认选择 angle 轴 + axis: 'auto', + + animation: true, + animationDurationUpdate: 200, + animationEasingUpdate: 'exponentialOut', + + // 直线指示器样式设置 + lineStyle: { + color: '#555', + width: 1, + type: 'solid' + }, + + crossStyle: { + color: '#555', + width: 1, + type: 'dashed', + + // TODO formatter + textStyle: {} + }, + + // 阴影指示器样式设置 + shadowStyle: { + color: 'rgba(150,150,150,0.3)' + } + }, + textStyle: { + color: '#fff', + fontSize: 14 + } + } + }); + + +/***/ }, +/* 270 */ +/***/ function(module, exports, __webpack_require__) { + + + + var TooltipContent = __webpack_require__(271); + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + var formatUtil = __webpack_require__(6); + var numberUtil = __webpack_require__(7); + var parsePercent = numberUtil.parsePercent; + var env = __webpack_require__(78); + + function dataEqual(a, b) { + if (!a || !b) { + return false; + } + var round = numberUtil.round; + return round(a[0]) === round(b[0]) + && round(a[1]) === round(b[1]); + } + /** + * @inner + */ + function makeLineShape(x1, y1, x2, y2) { + return { + x1: x1, + y1: y1, + x2: x2, + y2: y2 + }; + } + + /** + * @inner + */ + function makeRectShape(x, y, width, height) { + return { + x: x, + y: y, + width: width, + height: height + }; + } + + /** + * @inner + */ + function makeSectorShape(cx, cy, r0, r, startAngle, endAngle) { + return { + cx: cx, + cy: cy, + r0: r0, + r: r, + startAngle: startAngle, + endAngle: endAngle, + clockwise: true + }; + } + + function refixTooltipPosition(x, y, el, viewWidth, viewHeight) { + var width = el.clientWidth; + var height = el.clientHeight; + var gap = 20; + + if (x + width + gap > viewWidth) { + x -= width + gap; + } + else { + x += gap; + } + if (y + height + gap > viewHeight) { + y -= height + gap; + } + else { + y += gap; + } + return [x, y]; + } + + function calcTooltipPosition(position, rect, dom) { + var domWidth = dom.clientWidth; + var domHeight = dom.clientHeight; + var gap = 5; + var x = 0; + var y = 0; + var rectWidth = rect.width; + var rectHeight = rect.height; + switch (position) { + case 'inside': + x = rect.x + rectWidth / 2 - domWidth / 2; + y = rect.y + rectHeight / 2 - domHeight / 2; + break; + case 'top': + x = rect.x + rectWidth / 2 - domWidth / 2; + y = rect.y - domHeight - gap; + break; + case 'bottom': + x = rect.x + rectWidth / 2 - domWidth / 2; + y = rect.y + rectHeight + gap; + break; + case 'left': + x = rect.x - domWidth - gap; + y = rect.y + rectHeight / 2 - domHeight / 2; + break; + case 'right': + x = rect.x + rectWidth + gap; + y = rect.y + rectHeight / 2 - domHeight / 2; + } + return [x, y]; + } + + /** + * @param {string|Function|Array.} positionExpr + * @param {number} x Mouse x + * @param {number} y Mouse y + * @param {module:echarts/component/tooltip/TooltipContent} content + * @param {Object|} params + * @param {module:zrender/Element} el target element + * @param {module:echarts/ExtensionAPI} api + * @return {Array.} + */ + function updatePosition(positionExpr, x, y, content, params, el, api) { + var viewWidth = api.getWidth(); + var viewHeight = api.getHeight(); + + var rect = el && el.getBoundingRect().clone(); + el && rect.applyTransform(el.transform); + if (typeof positionExpr === 'function') { + // Callback of position can be an array or a string specify the positiont + positionExpr = positionExpr([x, y], params, rect); + } + + if (zrUtil.isArray(positionExpr)) { + x = parsePercent(positionExpr[0], viewWidth); + y = parsePercent(positionExpr[1], viewHeight); + } + // Specify tooltip position by string 'top' 'bottom' 'left' 'right' around graphic element + else if (typeof positionExpr === 'string' && el) { + var pos = calcTooltipPosition( + positionExpr, rect, content.el + ); + x = pos[0]; + y = pos[1]; + } + else { + var pos = refixTooltipPosition( + x, y, content.el, viewWidth, viewHeight + ); + x = pos[0]; + y = pos[1]; + } + + content.moveTo(x, y); + } + + function ifSeriesSupportAxisTrigger(seriesModel) { + var coordSys = seriesModel.coordinateSystem; + var trigger = seriesModel.get('tooltip.trigger', true); + // Ignore series use item tooltip trigger and series coordinate system is not cartesian or + return !(!coordSys + || (coordSys.type !== 'cartesian2d' && coordSys.type !== 'polar' && coordSys.type !== 'single') + || trigger === 'item'); + } + + __webpack_require__(1).extendComponentView({ + + type: 'tooltip', + + _axisPointers: {}, + + init: function (ecModel, api) { + if (env.node) { + return; + } + var tooltipContent = new TooltipContent(api.getDom(), api); + this._tooltipContent = tooltipContent; + + api.on('showTip', this._manuallyShowTip, this); + api.on('hideTip', this._manuallyHideTip, this); + }, + + render: function (tooltipModel, ecModel, api) { + if (env.node) { + return; + } + + // Reset + this.group.removeAll(); + + /** + * @type {Object} + * @private + */ + this._axisPointers = {}; + + /** + * @private + * @type {module:echarts/component/tooltip/TooltipModel} + */ + this._tooltipModel = tooltipModel; + + /** + * @private + * @type {module:echarts/model/Global} + */ + this._ecModel = ecModel; + + /** + * @private + * @type {module:echarts/ExtensionAPI} + */ + this._api = api; + + /** + * @type {Object} + * @private + */ + this._lastHover = { + // data + // payloadBatch + }; + + var tooltipContent = this._tooltipContent; + tooltipContent.update(); + tooltipContent.enterable = tooltipModel.get('enterable'); + this._alwaysShowContent = tooltipModel.get('alwaysShowContent'); + + /** + * @type {Object.} + */ + this._seriesGroupByAxis = this._prepareAxisTriggerData( + tooltipModel, ecModel + ); + + var crossText = this._crossText; + if (crossText) { + this.group.add(crossText); + } + + // Try to keep the tooltip show when refreshing + if (this._lastX != null && this._lastY != null) { + var self = this; + clearTimeout(this._refreshUpdateTimeout); + this._refreshUpdateTimeout = setTimeout(function () { + // Show tip next tick after other charts are rendered + // In case highlight action has wrong result + // FIXME + self._manuallyShowTip({ + x: self._lastX, + y: self._lastY + }); + }); + } + + var zr = this._api.getZr(); + var tryShow = this._tryShow; + zr.off('click', tryShow); + zr.off('mousemove', tryShow); + zr.off('mouseout', this._hide); + if (tooltipModel.get('triggerOn') === 'click') { + zr.on('click', tryShow, this); + } + else { + zr.on('mousemove', tryShow, this); + zr.on('mouseout', this._hide, this); + } + + }, + + /** + * Show tip manually by + * dispatchAction({ + * type: 'showTip', + * x: 10, + * y: 10 + * }); + * Or + * dispatchAction({ + * type: 'showTip', + * seriesIndex: 0, + * dataIndex: 1 + * }); + * + * TODO Batch + */ + _manuallyShowTip: function (event) { + // From self + if (event.from === this.uid) { + return; + } + + var ecModel = this._ecModel; + var seriesIndex = event.seriesIndex; + var dataIndex = event.dataIndex; + var seriesModel = ecModel.getSeriesByIndex(seriesIndex); + var api = this._api; + + if (event.x == null || event.y == null) { + if (!seriesModel) { + // Find the first series can use axis trigger + ecModel.eachSeries(function (_series) { + if (ifSeriesSupportAxisTrigger(_series) && !seriesModel) { + seriesModel = _series; + } + }); + } + if (seriesModel) { + var data = seriesModel.getData(); + if (dataIndex == null) { + dataIndex = data.indexOfName(event.name); + } + var el = data.getItemGraphicEl(dataIndex); + var cx, cy; + // Try to get the point in coordinate system + var coordSys = seriesModel.coordinateSystem; + if (coordSys && coordSys.dataToPoint) { + var point = coordSys.dataToPoint( + data.getValues(coordSys.dimensions, dataIndex, true) + ); + cx = point && point[0]; + cy = point && point[1]; + } + else if (el) { + // Use graphic bounding rect + var rect = el.getBoundingRect().clone(); + rect.applyTransform(el.transform); + cx = rect.x + rect.width / 2; + cy = rect.y + rect.height / 2; + } + if (cx != null && cy != null) { + this._tryShow({ + offsetX: cx, + offsetY: cy, + target: el, + event: {} + }); + } + } + } + else { + var el = api.getZr().handler.findHover(event.x, event.y); + this._tryShow({ + offsetX: event.x, + offsetY: event.y, + target: el, + event: {} + }); + } + }, + + _manuallyHideTip: function (e) { + if (e.from === this.uid) { + return; + } + + this._hide(); + }, + + _prepareAxisTriggerData: function (tooltipModel, ecModel) { + // Prepare data for axis trigger + var seriesGroupByAxis = {}; + ecModel.eachSeries(function (seriesModel) { + if (ifSeriesSupportAxisTrigger(seriesModel)) { + var coordSys = seriesModel.coordinateSystem; + var baseAxis; + var key; + + // Only cartesian2d, polar and single support axis trigger + if (coordSys.type === 'cartesian2d') { + // FIXME `axisPointer.axis` is not baseAxis + baseAxis = coordSys.getBaseAxis(); + key = baseAxis.dim + baseAxis.index; + } + else if (coordSys.type === 'single') { + baseAxis = coordSys.getAxis(); + key = baseAxis.dim + baseAxis.type; + } + else { + baseAxis = coordSys.getBaseAxis(); + key = baseAxis.dim + coordSys.name; + } + + seriesGroupByAxis[key] = seriesGroupByAxis[key] || { + coordSys: [], + series: [] + }; + seriesGroupByAxis[key].coordSys.push(coordSys); + seriesGroupByAxis[key].series.push(seriesModel); + } + }, this); + + return seriesGroupByAxis; + }, + + /** + * mousemove handler + * @param {Object} e + * @private + */ + _tryShow: function (e) { + var el = e.target; + var tooltipModel = this._tooltipModel; + var globalTrigger = tooltipModel.get('trigger'); + var ecModel = this._ecModel; + var api = this._api; + + if (!tooltipModel) { + return; + } + + // Save mouse x, mouse y. So we can try to keep showing the tip if chart is refreshed + this._lastX = e.offsetX; + this._lastY = e.offsetY; + + // Always show item tooltip if mouse is on the element with dataIndex + if (el && el.dataIndex != null) { + // Use hostModel in element if possible + // Used when mouseover on a element like markPoint or edge + // In which case, the data is not main data in series. + var hostModel = el.hostModel || ecModel.getSeriesByIndex(el.seriesIndex); + var dataIndex = el.dataIndex; + var itemModel = hostModel.getData().getItemModel(dataIndex); + // Series or single data may use item trigger when global is axis trigger + if ((itemModel.get('tooltip.trigger') || globalTrigger) === 'axis') { + this._showAxisTooltip(tooltipModel, ecModel, e); + } + else { + // Reset ticket + this._ticket = ''; + // If either single data or series use item trigger + this._hideAxisPointer(); + // Reset last hover and dispatch downplay action + this._resetLastHover(); + + this._showItemTooltipContent(hostModel, dataIndex, e); + } + + api.dispatchAction({ + type: 'showTip', + from: this.uid, + dataIndex: el.dataIndex, + seriesIndex: el.seriesIndex + }); + } + else { + if (globalTrigger === 'item') { + this._hide(); + } + else { + // Try show axis tooltip + this._showAxisTooltip(tooltipModel, ecModel, e); + } + + // Action of cross pointer + // other pointer types will trigger action in _dispatchAndShowSeriesTooltipContent method + if (tooltipModel.get('axisPointer.type') === 'cross') { + api.dispatchAction({ + type: 'showTip', + from: this.uid, + x: e.offsetX, + y: e.offsetY + }); + } + } + }, + + /** + * Show tooltip on axis + * @param {module:echarts/component/tooltip/TooltipModel} tooltipModel + * @param {module:echarts/model/Global} ecModel + * @param {Object} e + * @private + */ + _showAxisTooltip: function (tooltipModel, ecModel, e) { + var axisPointerModel = tooltipModel.getModel('axisPointer'); + var axisPointerType = axisPointerModel.get('type'); + + if (axisPointerType === 'cross') { + var el = e.target; + if (el && el.dataIndex != null) { + var seriesModel = ecModel.getSeriesByIndex(el.seriesIndex); + var dataIndex = el.dataIndex; + this._showItemTooltipContent(seriesModel, dataIndex, e); + } + } + + this._showAxisPointer(); + var allNotShow = true; + zrUtil.each(this._seriesGroupByAxis, function (seriesCoordSysSameAxis) { + // Try show the axis pointer + var allCoordSys = seriesCoordSysSameAxis.coordSys; + var coordSys = allCoordSys[0]; + + // If mouse position is not in the grid or polar + var point = [e.offsetX, e.offsetY]; + + if (!coordSys.containPoint(point)) { + // Hide axis pointer + this._hideAxisPointer(coordSys.name); + return; + } + + allNotShow = false; + // Make sure point is discrete on cateogry axis + var dimensions = coordSys.dimensions; + var value = coordSys.pointToData(point, true); + point = coordSys.dataToPoint(value); + var baseAxis = coordSys.getBaseAxis(); + var axisType = axisPointerModel.get('axis'); + if (axisType === 'auto') { + axisType = baseAxis.dim; + } + + var contentNotChange = false; + var lastHover = this._lastHover; + if (axisPointerType === 'cross') { + // If hover data not changed + // Possible when two axes are all category + if (dataEqual(lastHover.data, value)) { + contentNotChange = true; + } + lastHover.data = value; + } + else { + var valIndex = zrUtil.indexOf(dimensions, axisType); + + // If hover data not changed on the axis dimension + if (lastHover.data === value[valIndex]) { + contentNotChange = true; + } + lastHover.data = value[valIndex]; + } + + if (coordSys.type === 'cartesian2d' && !contentNotChange) { + this._showCartesianPointer( + axisPointerModel, coordSys, axisType, point + ); + } + else if (coordSys.type === 'polar' && !contentNotChange) { + this._showPolarPointer( + axisPointerModel, coordSys, axisType, point + ); + } + else if (coordSys.type === 'single' && !contentNotChange) { + this._showSinglePointer( + axisPointerModel, coordSys, axisType, point + ); + } + + if (axisPointerType !== 'cross') { + this._dispatchAndShowSeriesTooltipContent( + coordSys, seriesCoordSysSameAxis.series, point, value, contentNotChange + ); + } + }, this); + + if (allNotShow) { + this._hide(); + } + }, + + /** + * Show tooltip on axis of cartesian coordinate + * @param {module:echarts/model/Model} axisPointerModel + * @param {module:echarts/coord/cartesian/Cartesian2D} cartesians + * @param {string} axisType + * @param {Array.} point + * @private + */ + _showCartesianPointer: function (axisPointerModel, cartesian, axisType, point) { + var self = this; + + var axisPointerType = axisPointerModel.get('type'); + var moveAnimation = axisPointerType !== 'cross'; + + if (axisPointerType === 'cross') { + moveGridLine('x', point, cartesian.getAxis('y').getGlobalExtent()); + moveGridLine('y', point, cartesian.getAxis('x').getGlobalExtent()); + + this._updateCrossText(cartesian, point, axisPointerModel); + } + else { + var otherAxis = cartesian.getAxis(axisType === 'x' ? 'y' : 'x'); + var otherExtent = otherAxis.getGlobalExtent(); + + if (cartesian.type === 'cartesian2d') { + (axisPointerType === 'line' ? moveGridLine : moveGridShadow)( + axisType, point, otherExtent + ); + } + } + + /** + * @inner + */ + function moveGridLine(axisType, point, otherExtent) { + var targetShape = axisType === 'x' + ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1]) + : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]); + + var pointerEl = self._getPointerElement( + cartesian, axisPointerModel, axisType, targetShape + ); + moveAnimation + ? graphic.updateProps(pointerEl, { + shape: targetShape + }, axisPointerModel) + : pointerEl.attr({ + shape: targetShape + }); + } + + /** + * @inner + */ + function moveGridShadow(axisType, point, otherExtent) { + var axis = cartesian.getAxis(axisType); + var bandWidth = axis.getBandWidth(); + var span = otherExtent[1] - otherExtent[0]; + var targetShape = axisType === 'x' + ? makeRectShape(point[0] - bandWidth / 2, otherExtent[0], bandWidth, span) + : makeRectShape(otherExtent[0], point[1] - bandWidth / 2, span, bandWidth); + + var pointerEl = self._getPointerElement( + cartesian, axisPointerModel, axisType, targetShape + ); + moveAnimation + ? graphic.updateProps(pointerEl, { + shape: targetShape + }, axisPointerModel) + : pointerEl.attr({ + shape: targetShape + }); + } + }, + + _showSinglePointer: function (axisPointerModel, single, axisType, point) { + var self = this; + var axisPointerType = axisPointerModel.get('type'); + var moveAnimation = axisPointerType !== 'cross'; + var rect = single.getRect(); + var otherExtent = [rect.y, rect.y + rect.height]; + + moveSingleLine(axisType, point, otherExtent); + + /** + * @inner + */ + function moveSingleLine(axisType, point, otherExtent) { + var axis = single.getAxis(); + var orient = axis.orient; + + var targetShape = orient === 'horizontal' + ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1]) + : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]); + + var pointerEl = self._getPointerElement( + single, axisPointerModel, axisType, targetShape + ); + moveAnimation + ? graphic.updateProps(pointerEl, { + shape: targetShape + }, axisPointerModel) + : pointerEl.attr({ + shape: targetShape + }); + } + + }, + + /** + * Show tooltip on axis of polar coordinate + * @param {module:echarts/model/Model} axisPointerModel + * @param {Array.} polar + * @param {string} axisType + * @param {Array.} point + */ + _showPolarPointer: function (axisPointerModel, polar, axisType, point) { + var self = this; + + var axisPointerType = axisPointerModel.get('type'); + + var angleAxis = polar.getAngleAxis(); + var radiusAxis = polar.getRadiusAxis(); + + var moveAnimation = axisPointerType !== 'cross'; + + if (axisPointerType === 'cross') { + movePolarLine('angle', point, radiusAxis.getExtent()); + movePolarLine('radius', point, angleAxis.getExtent()); + + this._updateCrossText(polar, point, axisPointerModel); + } + else { + var otherAxis = polar.getAxis(axisType === 'radius' ? 'angle' : 'radius'); + var otherExtent = otherAxis.getExtent(); + + (axisPointerType === 'line' ? movePolarLine : movePolarShadow)( + axisType, point, otherExtent + ); + } + /** + * @inner + */ + function movePolarLine(axisType, point, otherExtent) { + var mouseCoord = polar.pointToCoord(point); + + var targetShape; + + if (axisType === 'angle') { + var p1 = polar.coordToPoint([otherExtent[0], mouseCoord[1]]); + var p2 = polar.coordToPoint([otherExtent[1], mouseCoord[1]]); + targetShape = makeLineShape(p1[0], p1[1], p2[0], p2[1]); + } + else { + targetShape = { + cx: polar.cx, + cy: polar.cy, + r: mouseCoord[0] + }; + } + + var pointerEl = self._getPointerElement( + polar, axisPointerModel, axisType, targetShape + ); + + moveAnimation + ? graphic.updateProps(pointerEl, { + shape: targetShape + }, axisPointerModel) + : pointerEl.attr({ + shape: targetShape + }); + } + + /** + * @inner + */ + function movePolarShadow(axisType, point, otherExtent) { + var axis = polar.getAxis(axisType); + var bandWidth = axis.getBandWidth(); + + var mouseCoord = polar.pointToCoord(point); + + var targetShape; + + var radian = Math.PI / 180; + + if (axisType === 'angle') { + targetShape = makeSectorShape( + polar.cx, polar.cy, + otherExtent[0], otherExtent[1], + // In ECharts y is negative if angle is positive + (-mouseCoord[1] - bandWidth / 2) * radian, + (-mouseCoord[1] + bandWidth / 2) * radian + ); + } + else { + targetShape = makeSectorShape( + polar.cx, polar.cy, + mouseCoord[0] - bandWidth / 2, + mouseCoord[0] + bandWidth / 2, + 0, Math.PI * 2 + ); + } + + var pointerEl = self._getPointerElement( + polar, axisPointerModel, axisType, targetShape + ); + moveAnimation + ? graphic.updateProps(pointerEl, { + shape: targetShape + }, axisPointerModel) + : pointerEl.attr({ + shape: targetShape + }); + } + }, + + _updateCrossText: function (coordSys, point, axisPointerModel) { + var crossStyleModel = axisPointerModel.getModel('crossStyle'); + var textStyleModel = crossStyleModel.getModel('textStyle'); + + var tooltipModel = this._tooltipModel; + + var text = this._crossText; + if (!text) { + text = this._crossText = new graphic.Text({ + style: { + textAlign: 'left', + textVerticalAlign: 'bottom' + } + }); + this.group.add(text); + } + + var value = coordSys.pointToData(point); + + var dims = coordSys.dimensions; + value = zrUtil.map(value, function (val, idx) { + var axis = coordSys.getAxis(dims[idx]); + if (axis.type === 'category' || axis.type === 'time') { + val = axis.scale.getLabel(val); + } + else { + val = formatUtil.addCommas( + val.toFixed(axis.getPixelPrecision()) + ); + } + return val; + }); + + text.setStyle({ + fill: textStyleModel.getTextColor() || crossStyleModel.get('color'), + textFont: textStyleModel.getFont(), + text: value.join(', '), + x: point[0] + 5, + y: point[1] - 5 + }); + text.z = tooltipModel.get('z'); + text.zlevel = tooltipModel.get('zlevel'); + }, + + _getPointerElement: function (coordSys, pointerModel, axisType, initShape) { + var tooltipModel = this._tooltipModel; + var z = tooltipModel.get('z'); + var zlevel = tooltipModel.get('zlevel'); + var axisPointers = this._axisPointers; + var coordSysName = coordSys.name; + axisPointers[coordSysName] = axisPointers[coordSysName] || {}; + if (axisPointers[coordSysName][axisType]) { + return axisPointers[coordSysName][axisType]; + } + + // Create if not exists + var pointerType = pointerModel.get('type'); + var styleModel = pointerModel.getModel(pointerType + 'Style'); + var isShadow = pointerType === 'shadow'; + var style = styleModel[isShadow ? 'getAreaStyle' : 'getLineStyle'](); + + var elementType = coordSys.type === 'polar' + ? (isShadow ? 'Sector' : (axisType === 'radius' ? 'Circle' : 'Line')) + : (isShadow ? 'Rect' : 'Line'); + + isShadow ? (style.stroke = null) : (style.fill = null); + + var el = axisPointers[coordSysName][axisType] = new graphic[elementType]({ + style: style, + z: z, + zlevel: zlevel, + silent: true, + shape: initShape + }); + + this.group.add(el); + return el; + }, + + /** + * Dispatch actions and show tooltip on series + * @param {Array.} seriesList + * @param {Array.} point + * @param {Array.} value + * @param {boolean} contentNotChange + * @param {Object} e + */ + _dispatchAndShowSeriesTooltipContent: function ( + coordSys, seriesList, point, value, contentNotChange + ) { + + var rootTooltipModel = this._tooltipModel; + var tooltipContent = this._tooltipContent; + + var baseAxis = coordSys.getBaseAxis(); + + var payloadBatch = zrUtil.map(seriesList, function (series) { + return { + seriesIndex: series.seriesIndex, + dataIndex: series.getAxisTooltipDataIndex + ? series.getAxisTooltipDataIndex(series.coordDimToDataDim(baseAxis.dim), value, baseAxis) + : series.getData().indexOfNearest( + series.coordDimToDataDim(baseAxis.dim)[0], + value[baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1] + ) + }; + }); + + var lastHover = this._lastHover; + var api = this._api; + // Dispatch downplay action + if (lastHover.payloadBatch && !contentNotChange) { + api.dispatchAction({ + type: 'downplay', + batch: lastHover.payloadBatch + }); + } + // Dispatch highlight action + if (!contentNotChange) { + api.dispatchAction({ + type: 'highlight', + batch: payloadBatch + }); + lastHover.payloadBatch = payloadBatch; + } + // Dispatch showTip action + api.dispatchAction({ + type: 'showTip', + dataIndex: payloadBatch[0].dataIndex, + seriesIndex: payloadBatch[0].seriesIndex, + from: this.uid + }); + + if (baseAxis && rootTooltipModel.get('showContent')) { + + var formatter = rootTooltipModel.get('formatter'); + var positionExpr = rootTooltipModel.get('position'); + var html; + + var paramsList = zrUtil.map(seriesList, function (series, index) { + return series.getDataParams(payloadBatch[index].dataIndex); + }); + // If only one series + // FIXME + // if (paramsList.length === 1) { + // paramsList = paramsList[0]; + // } + + tooltipContent.show(rootTooltipModel); + + // Update html content + var firstDataIndex = payloadBatch[0].dataIndex; + if (!contentNotChange) { + // Reset ticket + this._ticket = ''; + if (!formatter) { + // Default tooltip content + // FIXME + // (1) shold be the first data which has name? + // (2) themeRiver, firstDataIndex is array, and first line is unnecessary. + var firstLine = seriesList[0].getData().getName(firstDataIndex); + html = (firstLine ? firstLine + '
' : '') + + zrUtil.map(seriesList, function (series, index) { + return series.formatTooltip(payloadBatch[index].dataIndex, true); + }).join('
'); + } + else { + if (typeof formatter === 'string') { + html = formatUtil.formatTpl(formatter, paramsList); + } + else if (typeof formatter === 'function') { + var self = this; + var ticket = 'axis_' + coordSys.name + '_' + firstDataIndex; + var callback = function (cbTicket, html) { + if (cbTicket === self._ticket) { + tooltipContent.setContent(html); + + updatePosition( + positionExpr, point[0], point[1], + tooltipContent, paramsList, null, api + ); + } + }; + self._ticket = ticket; + html = formatter(paramsList, ticket, callback); + } + } + + tooltipContent.setContent(html); + } + + updatePosition( + positionExpr, point[0], point[1], + tooltipContent, paramsList, null, api + ); + } + }, + + /** + * Show tooltip on item + * @param {module:echarts/model/Series} seriesModel + * @param {number} dataIndex + * @param {Object} e + */ + _showItemTooltipContent: function (seriesModel, dataIndex, e) { + // FIXME Graph data + var api = this._api; + var data = seriesModel.getData(); + var itemModel = data.getItemModel(dataIndex); + + var rootTooltipModel = this._tooltipModel; + + var tooltipContent = this._tooltipContent; + + var tooltipModel = itemModel.getModel('tooltip'); + + // If series model + if (tooltipModel.parentModel) { + tooltipModel.parentModel.parentModel = rootTooltipModel; + } + else { + tooltipModel.parentModel = this._tooltipModel; + } + + if (tooltipModel.get('showContent')) { + var formatter = tooltipModel.get('formatter'); + var positionExpr = tooltipModel.get('position'); + var params = seriesModel.getDataParams(dataIndex); + var html; + if (!formatter) { + html = seriesModel.formatTooltip(dataIndex); + } + else { + if (typeof formatter === 'string') { + html = formatUtil.formatTpl(formatter, params); + } + else if (typeof formatter === 'function') { + var self = this; + var ticket = 'item_' + seriesModel.name + '_' + dataIndex; + var callback = function (cbTicket, html) { + if (cbTicket === self._ticket) { + tooltipContent.setContent(html); + + updatePosition( + positionExpr, e.offsetX, e.offsetY, + tooltipContent, params, e.target, api + ); + } + }; + self._ticket = ticket; + html = formatter(params, ticket, callback); + } + } + + tooltipContent.show(tooltipModel); + tooltipContent.setContent(html); + + updatePosition( + positionExpr, e.offsetX, e.offsetY, + tooltipContent, params, e.target, api + ); + } + }, + + /** + * Show axis pointer + * @param {string} [coordSysName] + */ + _showAxisPointer: function (coordSysName) { + if (coordSysName) { + var axisPointers = this._axisPointers[coordSysName]; + axisPointers && zrUtil.each(axisPointers, function (el) { + el.show(); + }); + } + else { + this.group.eachChild(function (child) { + child.show(); + }); + this.group.show(); + } + }, + + _resetLastHover: function () { + var lastHover = this._lastHover; + if (lastHover.payloadBatch) { + this._api.dispatchAction({ + type: 'downplay', + batch: lastHover.payloadBatch + }); + } + // Reset lastHover + this._lastHover = {}; + }, + /** + * Hide axis pointer + * @param {string} [coordSysName] + */ + _hideAxisPointer: function (coordSysName) { + if (coordSysName) { + var axisPointers = this._axisPointers[coordSysName]; + axisPointers && zrUtil.each(axisPointers, function (el) { + el.hide(); + }); + } + else { + this.group.hide(); + } + }, + + _hide: function () { + this._hideAxisPointer(); + this._resetLastHover(); + if (!this._alwaysShowContent) { + this._tooltipContent.hideLater(this._tooltipModel.get('hideDelay')); + } + + this._api.dispatchAction({ + type: 'hideTip', + from: this.uid + }); + }, + + dispose: function (ecModel, api) { + if (env.node) { + return; + } + var zr = api.getZr(); + this._tooltipContent.hide(); + + zr.off('click', this._tryShow); + zr.off('mousemove', this._tryShow); + zr.off('mouseout', this._hide); + + api.off('showTip', this._manuallyShowTip); + api.off('hideTip', this._manuallyHideTip); + } + }); + + +/***/ }, +/* 271 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/component/tooltip/TooltipContent + */ + + + var zrUtil = __webpack_require__(3); + var zrColor = __webpack_require__(38); + var eventUtil = __webpack_require__(80); + var formatUtil = __webpack_require__(6); + var each = zrUtil.each; + var toCamelCase = formatUtil.toCamelCase; + + var vendors = ['', '-webkit-', '-moz-', '-o-']; + + var gCssText = 'position:absolute;display:block;border-style:solid;white-space:nowrap;'; + + /** + * @param {number} duration + * @return {string} + * @inner + */ + function assembleTransition(duration) { + var transitionCurve = 'cubic-bezier(0.23, 1, 0.32, 1)'; + var transitionText = 'left ' + duration + 's ' + transitionCurve + ',' + + 'top ' + duration + 's ' + transitionCurve; + return zrUtil.map(vendors, function (vendorPrefix) { + return vendorPrefix + 'transition:' + transitionText; + }).join(';'); + } + + /** + * @param {Object} textStyle + * @return {string} + * @inner + */ + function assembleFont(textStyleModel) { + var cssText = []; + + var fontSize = textStyleModel.get('fontSize'); + var color = textStyleModel.getTextColor(); + + color && cssText.push('color:' + color); + + cssText.push('font:' + textStyleModel.getFont()); + + fontSize && + cssText.push('line-height:' + Math.round(fontSize * 3 / 2) + 'px'); + + each(['decoration', 'align'], function (name) { + var val = textStyleModel.get(name); + val && cssText.push('text-' + name + ':' + val); + }); + + return cssText.join(';'); + } + + /** + * @param {Object} tooltipModel + * @return {string} + * @inner + */ + function assembleCssText(tooltipModel) { + + tooltipModel = tooltipModel; + + var cssText = []; + + var transitionDuration = tooltipModel.get('transitionDuration'); + var backgroundColor = tooltipModel.get('backgroundColor'); + var textStyleModel = tooltipModel.getModel('textStyle'); + var padding = tooltipModel.get('padding'); + + // Animation transition + transitionDuration && + cssText.push(assembleTransition(transitionDuration)); + + if (backgroundColor) { + // for ie + cssText.push( + 'background-Color:' + zrColor.toHex(backgroundColor) + ); + cssText.push('filter:alpha(opacity=70)'); + cssText.push('background-Color:' + backgroundColor); + } + + // Border style + each(['width', 'color', 'radius'], function (name) { + var borderName = 'border-' + name; + var camelCase = toCamelCase(borderName); + var val = tooltipModel.get(camelCase); + val != null && + cssText.push(borderName + ':' + val + (name === 'color' ? '' : 'px')); + }); + + // Text style + cssText.push(assembleFont(textStyleModel)); + + // Padding + if (padding != null) { + cssText.push('padding:' + formatUtil.normalizeCssArray(padding).join('px ') + 'px'); + } + + return cssText.join(';') + ';'; + } + + /** + * @alias module:echarts/component/tooltip/TooltipContent + * @constructor + */ + function TooltipContent(container, api) { + var el = document.createElement('div'); + var zr = api.getZr(); + + this.el = el; + + this._x = api.getWidth() / 2; + this._y = api.getHeight() / 2; + + container.appendChild(el); + + this._container = container; + + this._show = false; + + /** + * @private + */ + this._hideTimeout; + + var self = this; + el.onmouseenter = function () { + // clear the timeout in hideLater and keep showing tooltip + if (self.enterable) { + clearTimeout(self._hideTimeout); + self._show = true; + } + self._inContent = true; + }; + el.onmousemove = function (e) { + if (!self.enterable) { + // Try trigger zrender event to avoid mouse + // in and out shape too frequently + var handler = zr.handler; + eventUtil.normalizeEvent(container, e); + handler.dispatch('mousemove', e); + } + }; + el.onmouseleave = function () { + if (self.enterable) { + if (self._show) { + self.hideLater(self._hideDelay); + } + } + self._inContent = false; + }; + + compromiseMobile(el, container); + } + + function compromiseMobile(tooltipContentEl, container) { + // Prevent default behavior on mobile. For example, + // defuault pinch gesture will cause browser zoom. + // We do not preventing event on tooltip contnet el, + // because user may need customization in tooltip el. + eventUtil.addEventListener(container, 'touchstart', preventDefault); + eventUtil.addEventListener(container, 'touchmove', preventDefault); + eventUtil.addEventListener(container, 'touchend', preventDefault); + + function preventDefault(e) { + if (contains(e.target)) { + e.preventDefault(); + } + } + + function contains(targetEl) { + while (targetEl && targetEl !== container) { + if (targetEl === tooltipContentEl) { + return true; + } + targetEl = targetEl.parentNode; + } + } + } + + TooltipContent.prototype = { + + constructor: TooltipContent, + + enterable: true, + + /** + * Update when tooltip is rendered + */ + update: function () { + var container = this._container; + var stl = container.currentStyle + || document.defaultView.getComputedStyle(container); + var domStyle = container.style; + if (domStyle.position !== 'absolute' && stl.position !== 'absolute') { + domStyle.position = 'relative'; + } + // Hide the tooltip + // PENDING + // this.hide(); + }, + + show: function (tooltipModel) { + clearTimeout(this._hideTimeout); + + this.el.style.cssText = gCssText + assembleCssText(tooltipModel) + // http://stackoverflow.com/questions/21125587/css3-transition-not-working-in-chrome-anymore + + ';left:' + this._x + 'px;top:' + this._y + 'px;'; + + this._show = true; + }, + + setContent: function (content) { + var el = this.el; + el.innerHTML = content; + el.style.display = content ? 'block' : 'none'; + }, + + moveTo: function (x, y) { + var style = this.el.style; + style.left = x + 'px'; + style.top = y + 'px'; + + this._x = x; + this._y = y; + }, + + hide: function () { + this.el.style.display = 'none'; + this._show = false; + }, + + // showLater: function () + + hideLater: function (time) { + if (this._show && !(this._inContent && this.enterable)) { + if (time) { + this._hideDelay = time; + // Set show false to avoid invoke hideLater mutiple times + this._show = false; + this._hideTimeout = setTimeout(zrUtil.bind(this.hide, this), time); + } + else { + this.hide(); + } + } + }, + + isShow: function () { + return this._show; + } + }; + + module.exports = TooltipContent; + + +/***/ }, +/* 272 */, +/* 273 */, +/* 274 */, +/* 275 */, +/* 276 */, +/* 277 */, +/* 278 */, +/* 279 */, +/* 280 */, +/* 281 */, +/* 282 */, +/* 283 */, +/* 284 */, +/* 285 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var echarts = __webpack_require__(1); + var graphic = __webpack_require__(42); + var layout = __webpack_require__(21); + + // Model + echarts.extendComponentModel({ + + type: 'title', + + layoutMode: {type: 'box', ignoreSize: true}, + + defaultOption: { + // 一级层叠 + zlevel: 0, + // 二级层叠 + z: 6, + show: true, + + text: '', + // 超链接跳转 + // link: null, + // 仅支持self | blank + target: 'blank', + subtext: '', + + // 超链接跳转 + // sublink: null, + // 仅支持self | blank + subtarget: 'blank', + + // 'center' ¦ 'left' ¦ 'right' + // ¦ {number}(x坐标,单位px) + left: 0, + // 'top' ¦ 'bottom' ¦ 'center' + // ¦ {number}(y坐标,单位px) + top: 0, + + // 水平对齐 + // 'auto' | 'left' | 'right' + // 默认根据 x 的位置判断是左对齐还是右对齐 + //textAlign: null + + backgroundColor: 'rgba(0,0,0,0)', + + // 标题边框颜色 + borderColor: '#ccc', + + // 标题边框线宽,单位px,默认为0(无边框) + borderWidth: 0, + + // 标题内边距,单位px,默认各方向内边距为5, + // 接受数组分别设定上右下左边距,同css + padding: 5, + + // 主副标题纵向间隔,单位px,默认为10, + itemGap: 10, + textStyle: { + fontSize: 18, + fontWeight: 'bolder', + // 主标题文字颜色 + color: '#333' + }, + subtextStyle: { + // 副标题文字颜色 + color: '#aaa' + } + } + }); + + // View + echarts.extendComponentView({ + + type: 'title', + + render: function (titleModel, ecModel, api) { + this.group.removeAll(); + + if (!titleModel.get('show')) { + return; + } + + var group = this.group; + + var textStyleModel = titleModel.getModel('textStyle'); + var subtextStyleModel = titleModel.getModel('subtextStyle'); + + var textAlign = titleModel.get('textAlign'); + + var textEl = new graphic.Text({ + style: { + text: titleModel.get('text'), + textFont: textStyleModel.getFont(), + fill: textStyleModel.getTextColor(), + textBaseline: 'top' + }, + z2: 10 + }); + + var textRect = textEl.getBoundingRect(); + + var subText = titleModel.get('subtext'); + var subTextEl = new graphic.Text({ + style: { + text: subText, + textFont: subtextStyleModel.getFont(), + fill: subtextStyleModel.getTextColor(), + y: textRect.height + titleModel.get('itemGap'), + textBaseline: 'top' + }, + z2: 10 + }); + + var link = titleModel.get('link'); + var sublink = titleModel.get('sublink'); + + textEl.silent = !link; + subTextEl.silent = !sublink; + + if (link) { + textEl.on('click', function () { + window.open(link, titleModel.get('target')); + }); + } + if (sublink) { + subTextEl.on('click', function () { + window.open(sublink, titleModel.get('subtarget')); + }); + } + + group.add(textEl); + subText && group.add(subTextEl); + // If no subText, but add subTextEl, there will be an empty line. + + var groupRect = group.getBoundingRect(); + var layoutOption = titleModel.getBoxLayoutParams(); + layoutOption.width = groupRect.width; + layoutOption.height = groupRect.height; + var layoutRect = layout.getLayoutRect( + layoutOption, { + width: api.getWidth(), + height: api.getHeight() + }, titleModel.get('padding') + ); + // Adjust text align based on position + if (!textAlign) { + // Align left if title is on the left. center and right is same + textAlign = titleModel.get('left') || titleModel.get('right'); + if (textAlign === 'middle') { + textAlign = 'center'; + } + // Adjust layout by text align + if (textAlign === 'right') { + layoutRect.x += layoutRect.width; + } + else if (textAlign === 'center') { + layoutRect.x += layoutRect.width / 2; + } + } + group.position = [layoutRect.x, layoutRect.y]; + textEl.setStyle('textAlign', textAlign); + subTextEl.setStyle('textAlign', textAlign); + + // Render background + // Get groupRect again because textAlign has been changed + groupRect = group.getBoundingRect(); + var padding = layoutRect.margin; + var style = titleModel.getItemStyle(['color', 'opacity']); + style.fill = titleModel.get('backgroundColor'); + var rect = new graphic.Rect({ + shape: { + x: groupRect.x - padding[3], + y: groupRect.y - padding[0], + width: groupRect.width + padding[1] + padding[3], + height: groupRect.height + padding[0] + padding[2] + }, + style: style, + silent: true + }); + graphic.subPixelOptimizeRect(rect); + + group.add(rect); + } + }); + + +/***/ }, +/* 286 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * DataZoom component entry + */ + + + __webpack_require__(287); + + __webpack_require__(288); + __webpack_require__(290); + + __webpack_require__(291); + __webpack_require__(292); + + __webpack_require__(295); + __webpack_require__(296); + + __webpack_require__(298); + __webpack_require__(299); + + + +/***/ }, +/* 287 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(19).registerSubTypeDefaulter('dataZoom', function (option) { + // Default 'slider' when no type specified. + return 'slider'; + }); + + + +/***/ }, +/* 288 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Data zoom model + */ + + + var zrUtil = __webpack_require__(3); + var env = __webpack_require__(78); + var echarts = __webpack_require__(1); + var modelUtil = __webpack_require__(5); + var AxisProxy = __webpack_require__(289); + var each = zrUtil.each; + var eachAxisDim = modelUtil.eachAxisDim; + + var DataZoomModel = echarts.extendComponentModel({ + + type: 'dataZoom', + + dependencies: [ + 'xAxis', 'yAxis', 'zAxis', 'radiusAxis', 'angleAxis', 'series' + ], + + /** + * @protected + */ + defaultOption: { + zlevel: 0, + z: 4, // Higher than normal component (z: 2). + orient: null, // Default auto by axisIndex. Possible value: 'horizontal', 'vertical'. + xAxisIndex: null, // Default all horizontal category axis. + yAxisIndex: null, // Default all vertical category axis. + angleAxisIndex: null, + radiusAxisIndex: null, + filterMode: 'filter', // Possible values: 'filter' or 'empty'. + // 'filter': data items which are out of window will be removed. + // This option is applicable when filtering outliers. + // 'empty': data items which are out of window will be set to empty. + // This option is applicable when user should not neglect + // that there are some data items out of window. + // Taking line chart as an example, line will be broken in + // the filtered points when filterModel is set to 'empty', but + // be connected when set to 'filter'. + + throttle: 100, // Dispatch action by the fixed rate, avoid frequency. + // default 100. Do not throttle when use null/undefined. + start: 0, // Start percent. 0 ~ 100 + end: 100, // End percent. 0 ~ 100 + startValue: null, // Start value. If startValue specified, start is ignored. + endValue: null // End value. If endValue specified, end is ignored. + }, - constructor: RadialGradient, + /** + * @override + */ + init: function (option, parentModel, ecModel) { + + /** + * key like x_0, y_1 + * @private + * @type {Object} + */ + this._dataIntervalByAxis = {}; + + /** + * @private + */ + this._dataInfo = {}; + + /** + * key like x_0, y_1 + * @private + */ + this._axisProxies = {}; + + /** + * @readOnly + */ + this.textStyleModel; + + var rawOption = retrieveRaw(option); + + this.mergeDefaultAndTheme(option, ecModel); + + this.doInit(rawOption); + }, + + /** + * @override + */ + mergeOption: function (newOption) { + var rawOption = retrieveRaw(newOption); + + //FIX #2591 + zrUtil.merge(this.option, newOption, true); + + this.doInit(rawOption); + }, + + /** + * @protected + */ + doInit: function (rawOption) { + var thisOption = this.option; + + // Disable realtime view update if canvas is not supported. + if (!env.canvasSupported) { + thisOption.realtime = false; + } + + processRangeProp('start', 'startValue', rawOption, thisOption); + processRangeProp('end', 'endValue', rawOption, thisOption); + + this.textStyleModel = this.getModel('textStyle'); + + this._resetTarget(); + + this._giveAxisProxies(); + }, + + /** + * @private + */ + _giveAxisProxies: function () { + var axisProxies = this._axisProxies; + + this.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel, ecModel) { + var axisModel = this.dependentModels[dimNames.axis][axisIndex]; + + // If exists, share axisProxy with other dataZoomModels. + var axisProxy = axisModel.__dzAxisProxy || ( + // Use the first dataZoomModel as the main model of axisProxy. + axisModel.__dzAxisProxy = new AxisProxy( + dimNames.name, axisIndex, this, ecModel + ) + ); + // FIXME + // dispose __dzAxisProxy + + axisProxies[dimNames.name + '_' + axisIndex] = axisProxy; + }, this); + }, + + /** + * @private + */ + _resetTarget: function () { + var thisOption = this.option; + + var autoMode = this._judgeAutoMode(); + + eachAxisDim(function (dimNames) { + var axisIndexName = dimNames.axisIndex; + thisOption[axisIndexName] = modelUtil.normalizeToArray( + thisOption[axisIndexName] + ); + }, this); + + if (autoMode === 'axisIndex') { + this._autoSetAxisIndex(); + } + else if (autoMode === 'orient') { + this._autoSetOrient(); + } + }, + + /** + * @private + */ + _judgeAutoMode: function () { + // Auto set only works for setOption at the first time. + // The following is user's reponsibility. So using merged + // option is OK. + var thisOption = this.option; + + var hasIndexSpecified = false; + eachAxisDim(function (dimNames) { + // When user set axisIndex as a empty array, we think that user specify axisIndex + // but do not want use auto mode. Because empty array may be encountered when + // some error occured. + if (thisOption[dimNames.axisIndex] != null) { + hasIndexSpecified = true; + } + }, this); + + var orient = thisOption.orient; + + if (orient == null && hasIndexSpecified) { + return 'orient'; + } + else if (!hasIndexSpecified) { + if (orient == null) { + thisOption.orient = 'horizontal'; + } + return 'axisIndex'; + } + }, + + /** + * @private + */ + _autoSetAxisIndex: function () { + var autoAxisIndex = true; + var orient = this.get('orient', true); + var thisOption = this.option; + + if (autoAxisIndex) { + // Find axis that parallel to dataZoom as default. + var dimNames = orient === 'vertical' + ? {dim: 'y', axisIndex: 'yAxisIndex', axis: 'yAxis'} + : {dim: 'x', axisIndex: 'xAxisIndex', axis: 'xAxis'}; + + if (this.dependentModels[dimNames.axis].length) { + thisOption[dimNames.axisIndex] = [0]; + autoAxisIndex = false; + } + } + + if (autoAxisIndex) { + // Find the first category axis as default. (consider polar) + eachAxisDim(function (dimNames) { + if (!autoAxisIndex) { + return; + } + var axisIndices = []; + var axisModels = this.dependentModels[dimNames.axis]; + if (axisModels.length && !axisIndices.length) { + for (var i = 0, len = axisModels.length; i < len; i++) { + if (axisModels[i].get('type') === 'category') { + axisIndices.push(i); + } + } + } + thisOption[dimNames.axisIndex] = axisIndices; + if (axisIndices.length) { + autoAxisIndex = false; + } + }, this); + } + + if (autoAxisIndex) { + // FIXME + // 这里是兼容ec2的写法(没指定xAxisIndex和yAxisIndex时把scatter和双数值轴折柱纳入dataZoom控制), + // 但是实际是否需要Grid.js#getScaleByOption来判断(考虑time,log等axis type)? + + // If both dataZoom.xAxisIndex and dataZoom.yAxisIndex is not specified, + // dataZoom component auto adopts series that reference to + // both xAxis and yAxis which type is 'value'. + this.ecModel.eachSeries(function (seriesModel) { + if (this._isSeriesHasAllAxesTypeOf(seriesModel, 'value')) { + eachAxisDim(function (dimNames) { + var axisIndices = thisOption[dimNames.axisIndex]; + var axisIndex = seriesModel.get(dimNames.axisIndex); + if (zrUtil.indexOf(axisIndices, axisIndex) < 0) { + axisIndices.push(axisIndex); + } + }); + } + }, this); + } + }, + + /** + * @private + */ + _autoSetOrient: function () { + var dim; + + // Find the first axis + this.eachTargetAxis(function (dimNames) { + !dim && (dim = dimNames.name); + }, this); + + this.option.orient = dim === 'y' ? 'vertical' : 'horizontal'; + }, + + /** + * @private + */ + _isSeriesHasAllAxesTypeOf: function (seriesModel, axisType) { + // FIXME + // 需要series的xAxisIndex和yAxisIndex都首先自动设置上。 + // 例如series.type === scatter时。 + + var is = true; + eachAxisDim(function (dimNames) { + var seriesAxisIndex = seriesModel.get(dimNames.axisIndex); + var axisModel = this.dependentModels[dimNames.axis][seriesAxisIndex]; + + if (!axisModel || axisModel.get('type') !== axisType) { + is = false; + } + }, this); + return is; + }, + + /** + * @public + */ + getFirstTargetAxisModel: function () { + var firstAxisModel; + eachAxisDim(function (dimNames) { + if (firstAxisModel == null) { + var indices = this.get(dimNames.axisIndex); + if (indices.length) { + firstAxisModel = this.dependentModels[dimNames.axis][indices[0]]; + } + } + }, this); + + return firstAxisModel; + }, + + /** + * @public + * @param {Function} callback param: axisModel, dimNames, axisIndex, dataZoomModel, ecModel + */ + eachTargetAxis: function (callback, context) { + var ecModel = this.ecModel; + eachAxisDim(function (dimNames) { + each( + this.get(dimNames.axisIndex), + function (axisIndex) { + callback.call(context, dimNames, axisIndex, this, ecModel); + }, + this + ); + }, this); + }, + + getAxisProxy: function (dimName, axisIndex) { + return this._axisProxies[dimName + '_' + axisIndex]; + }, + + /** + * If not specified, set to undefined. + * + * @public + * @param {Object} opt + * @param {number} [opt.start] + * @param {number} [opt.end] + * @param {number} [opt.startValue] + * @param {number} [opt.endValue] + */ + setRawRange: function (opt) { + each(['start', 'end', 'startValue', 'endValue'], function (name) { + // If any of those prop is null/undefined, we should alos set + // them, because only one pair between start/end and + // startValue/endValue can work. + this.option[name] = opt[name]; + }, this); + }, + + /** + * @public + * @return {Array.} [startPercent, endPercent] + */ + getPercentRange: function () { + var axisProxy = this.findRepresentativeAxisProxy(); + if (axisProxy) { + return axisProxy.getDataPercentWindow(); + } + }, + + /** + * @public + * For example, chart.getModel().getComponent('dataZoom').getValueRange('y', 0); + * + * @param {string} [axisDimName] + * @param {number} [axisIndex] + * @return {Array.} [startValue, endValue] + */ + getValueRange: function (axisDimName, axisIndex) { + if (axisDimName == null && axisIndex == null) { + var axisProxy = this.findRepresentativeAxisProxy(); + if (axisProxy) { + return axisProxy.getDataValueWindow(); + } + } + else { + return this.getAxisProxy(axisDimName, axisIndex).getDataValueWindow(); + } + }, + + /** + * @public + * @return {module:echarts/component/dataZoom/AxisProxy} + */ + findRepresentativeAxisProxy: function () { + // Find the first hosted axisProxy + var axisProxies = this._axisProxies; + for (var key in axisProxies) { + if (axisProxies.hasOwnProperty(key) && axisProxies[key].hostedBy(this)) { + return axisProxies[key]; + } + } + + // If no hosted axis find not hosted axisProxy. + // Consider this case: dataZoomModel1 and dataZoomModel2 control the same axis, + // and the option.start or option.end settings are different. The percentRange + // should follow axisProxy. + // (We encounter this problem in toolbox data zoom.) + for (var key in axisProxies) { + if (axisProxies.hasOwnProperty(key) && !axisProxies[key].hostedBy(this)) { + return axisProxies[key]; + } + } + } + + }); + + function retrieveRaw(option) { + var ret = {}; + each( + ['start', 'end', 'startValue', 'endValue'], + function (name) { + ret[name] = option[name]; + } + ); + return ret; + } + + function processRangeProp(percentProp, valueProp, rawOption, thisOption) { + // start/end has higher priority over startValue/endValue, + // but we should make chart.setOption({endValue: 1000}) effective, + // rather than chart.setOption({endValue: 1000, end: null}). + if (rawOption[valueProp] != null && rawOption[percentProp] == null) { + thisOption[percentProp] = null; + } + // Otherwise do nothing and use the merge result. + } + + module.exports = DataZoomModel; + + + +/***/ }, +/* 289 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Axis operator + */ + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var each = zrUtil.each; + var asc = numberUtil.asc; + + /** + * Operate single axis. + * One axis can only operated by one axis operator. + * Different dataZoomModels may be defined to operate the same axis. + * (i.e. 'inside' data zoom and 'slider' data zoom components) + * So dataZoomModels share one axisProxy in that case. + * + * @class + */ + var AxisProxy = function (dimName, axisIndex, dataZoomModel, ecModel) { + + /** + * @private + * @type {string} + */ + this._dimName = dimName; + + /** + * @private + */ + this._axisIndex = axisIndex; + + /** + * @private + * @type {Array.} + */ + this._valueWindow; + + /** + * @private + * @type {Array.} + */ + this._percentWindow; + + /** + * @private + * @type {Array.} + */ + this._dataExtent; + + /** + * @readOnly + * @type {module: echarts/model/Global} + */ + this.ecModel = ecModel; + + /** + * @private + * @type {module: echarts/component/dataZoom/DataZoomModel} + */ + this._dataZoomModel = dataZoomModel; + }; + + AxisProxy.prototype = { + + constructor: AxisProxy, + + /** + * Whether the axisProxy is hosted by dataZoomModel. + * + * @public + * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel + * @return {boolean} + */ + hostedBy: function (dataZoomModel) { + return this._dataZoomModel === dataZoomModel; + }, + + /** + * @return {Array.} + */ + getDataExtent: function () { + return this._dataExtent.slice(); + }, + + /** + * @return {Array.} + */ + getDataValueWindow: function () { + return this._valueWindow.slice(); + }, + + /** + * @return {Array.} + */ + getDataPercentWindow: function () { + return this._percentWindow.slice(); + }, + + /** + * @public + * @param {number} axisIndex + * @return {Array} seriesModels + */ + getTargetSeriesModels: function () { + var seriesModels = []; + + this.ecModel.eachSeries(function (seriesModel) { + if (this._axisIndex === seriesModel.get(this._dimName + 'AxisIndex')) { + seriesModels.push(seriesModel); + } + }, this); + + return seriesModels; + }, + + getAxisModel: function () { + return this.ecModel.getComponent(this._dimName + 'Axis', this._axisIndex); + }, + + getOtherAxisModel: function () { + var axisDim = this._dimName; + var ecModel = this.ecModel; + var axisModel = this.getAxisModel(); + var isCartesian = axisDim === 'x' || axisDim === 'y'; + var otherAxisDim; + var coordSysIndexName; + if (isCartesian) { + coordSysIndexName = 'gridIndex'; + otherAxisDim = axisDim === 'x' ? 'y' : 'x'; + } + else { + coordSysIndexName = 'polarIndex'; + otherAxisDim = axisDim === 'angle' ? 'radius' : 'angle'; + } + var foundOtherAxisModel; + ecModel.eachComponent(otherAxisDim + 'Axis', function (otherAxisModel) { + if ((otherAxisModel.get(coordSysIndexName) || 0) + === (axisModel.get(coordSysIndexName) || 0)) { + foundOtherAxisModel = otherAxisModel; + } + }); + return foundOtherAxisModel; + }, + + /** + * Notice: reset should not be called before series.restoreData() called, + * so it is recommanded to be called in "process stage" but not "model init + * stage". + * + * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel + */ + reset: function (dataZoomModel) { + if (dataZoomModel !== this._dataZoomModel) { + return; + } + + // Culculate data window and data extent, and record them. + var dataExtent = this._dataExtent = calculateDataExtent( + this._dimName, this.getTargetSeriesModels() + ); + var dataWindow = calculateDataWindow( + dataZoomModel.option, dataExtent, this + ); + this._valueWindow = dataWindow.valueWindow; + this._percentWindow = dataWindow.percentWindow; + + // Update axis setting then. + setAxisModel(this); + }, + + /** + * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel + */ + restore: function (dataZoomModel) { + if (dataZoomModel !== this._dataZoomModel) { + return; + } + + this._valueWindow = this._percentWindow = null; + setAxisModel(this, true); + }, + + /** + * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel + */ + filterData: function (dataZoomModel) { + if (dataZoomModel !== this._dataZoomModel) { + return; + } + + var axisDim = this._dimName; + var seriesModels = this.getTargetSeriesModels(); + var filterMode = dataZoomModel.get('filterMode'); + var valueWindow = this._valueWindow; + + // FIXME + // Toolbox may has dataZoom injected. And if there are stacked bar chart + // with NaN data. NaN will be filtered and stack will be wrong. + // So we need to force the mode to be set empty + var otherAxisModel = this.getOtherAxisModel(); + if (dataZoomModel.get('$fromToolbox') + && otherAxisModel && otherAxisModel.get('type') === 'category') { + filterMode = 'empty'; + } + // Process series data + each(seriesModels, function (seriesModel) { + var seriesData = seriesModel.getData(); + if (!seriesData) { + return; + } + + each(seriesModel.coordDimToDataDim(axisDim), function (dim) { + if (filterMode === 'empty') { + seriesModel.setData( + seriesData.map(dim, function (value) { + return !isInWindow(value) ? NaN : value; + }) + ); + } + else { + seriesData.filterSelf(dim, isInWindow); + } + }); + }); + + function isInWindow(value) { + return value >= valueWindow[0] && value <= valueWindow[1]; + } + } + }; + + function calculateDataExtent(axisDim, seriesModels) { + var dataExtent = [Infinity, -Infinity]; + + each(seriesModels, function (seriesModel) { + var seriesData = seriesModel.getData(); + if (seriesData) { + each(seriesModel.coordDimToDataDim(axisDim), function (dim) { + var seriesExtent = seriesData.getDataExtent(dim); + seriesExtent[0] < dataExtent[0] && (dataExtent[0] = seriesExtent[0]); + seriesExtent[1] > dataExtent[1] && (dataExtent[1] = seriesExtent[1]); + }); + } + }, this); + + return dataExtent; + } + + function calculateDataWindow(opt, dataExtent, axisProxy) { + var axisModel = axisProxy.getAxisModel(); + var scale = axisModel.axis.scale; + var percentExtent = [0, 100]; + var percentWindow = [ + opt.start, + opt.end + ]; + var valueWindow = []; + + // In percent range is used and axis min/max/scale is set, + // window should be based on min/max/0, but should not be + // based on the extent of filtered data. + dataExtent = dataExtent.slice(); + fixExtendByAxis(dataExtent, axisModel, scale); + + each(['startValue', 'endValue'], function (prop) { + valueWindow.push( + opt[prop] != null + ? scale.parse(opt[prop]) + : null + ); + }); + + // Normalize bound. + each([0, 1], function (idx) { + var boundValue = valueWindow[idx]; + var boundPercent = percentWindow[idx]; + + // start/end has higher priority over startValue/endValue, + // because start/end can be consistent among different type + // of axis but startValue/endValue not. + + if (boundPercent != null || boundValue == null) { + if (boundPercent == null) { + boundPercent = percentExtent[idx]; + } + // Use scale.parse to math round for category or time axis. + boundValue = scale.parse(numberUtil.linearMap( + boundPercent, percentExtent, dataExtent, true + )); + } + else { // boundPercent == null && boundValue != null + boundPercent = numberUtil.linearMap( + boundValue, dataExtent, percentExtent, true + ); + } + // Avoid rounding error + valueWindow[idx] = numberUtil.round(boundValue); + percentWindow[idx] = numberUtil.round(boundPercent); + }); + + return { + valueWindow: asc(valueWindow), + percentWindow: asc(percentWindow) + }; + } + + function fixExtendByAxis(dataExtent, axisModel, scale) { + each(['min', 'max'], function (minMax, index) { + var axisMax = axisModel.get(minMax, true); + // Consider 'dataMin', 'dataMax' + if (axisMax != null && (axisMax + '').toLowerCase() !== 'data' + minMax) { + dataExtent[index] = scale.parse(axisMax); + } + }); + + if (!axisModel.get('scale', true)) { + dataExtent[0] > 0 && (dataExtent[0] = 0); + dataExtent[1] < 0 && (dataExtent[1] = 0); + } + + return dataExtent; + } + + function setAxisModel(axisProxy, isRestore) { + var axisModel = axisProxy.getAxisModel(); + + var percentWindow = axisProxy._percentWindow; + var valueWindow = axisProxy._valueWindow; + + if (!percentWindow) { + return; + } + + var isFull = isRestore || (percentWindow[0] === 0 && percentWindow[1] === 100); + // [0, 500]: arbitrary value, guess axis extent. + var precision = !isRestore && numberUtil.getPixelPrecision(valueWindow, [0, 500]); + // toFixed() digits argument must be between 0 and 20 + var invalidPrecision = !isRestore && !(precision < 20 && precision >= 0); + + var useOrigin = isRestore || isFull || invalidPrecision; + + axisModel.setRange && axisModel.setRange( + useOrigin ? null : +valueWindow[0].toFixed(precision), + useOrigin ? null : +valueWindow[1].toFixed(precision) + ); + } + + module.exports = AxisProxy; + + + +/***/ }, +/* 290 */ +/***/ function(module, exports, __webpack_require__) { + + + + var ComponentView = __webpack_require__(28); + + module.exports = ComponentView.extend({ + + type: 'dataZoom', + + render: function (dataZoomModel, ecModel, api, payload) { + this.dataZoomModel = dataZoomModel; + this.ecModel = ecModel; + this.api = api; + }, + + /** + * Find the first target coordinate system. + * + * @protected + * @return {Object} { + * cartesians: [ + * {model: coord0, axisModels: [axis1, axis3], coordIndex: 1}, + * {model: coord1, axisModels: [axis0, axis2], coordIndex: 0}, + * ... + * ], // cartesians must not be null/undefined. + * polars: [ + * {model: coord0, axisModels: [axis4], coordIndex: 0}, + * ... + * ], // polars must not be null/undefined. + * axisModels: [axis0, axis1, axis2, axis3, axis4] + * // axisModels must not be null/undefined. + * } + */ + getTargetInfo: function () { + var dataZoomModel = this.dataZoomModel; + var ecModel = this.ecModel; + var cartesians = []; + var polars = []; + var axisModels = []; + + dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) { + var axisModel = ecModel.getComponent(dimNames.axis, axisIndex); + if (axisModel) { + axisModels.push(axisModel); + + var gridIndex = axisModel.get('gridIndex'); + var polarIndex = axisModel.get('polarIndex'); + + if (gridIndex != null) { + var coordModel = ecModel.getComponent('grid', gridIndex); + save(coordModel, axisModel, cartesians, gridIndex); + } + else if (polarIndex != null) { + var coordModel = ecModel.getComponent('polar', polarIndex); + save(coordModel, axisModel, polars, polarIndex); + } + } + }, this); + + function save(coordModel, axisModel, store, coordIndex) { + var item; + for (var i = 0; i < store.length; i++) { + if (store[i].model === coordModel) { + item = store[i]; + break; + } + } + if (!item) { + store.push(item = { + model: coordModel, axisModels: [], coordIndex: coordIndex + }); + } + item.axisModels.push(axisModel); + } + + return { + cartesians: cartesians, + polars: polars, + axisModels: axisModels + }; + } + + }); + + + +/***/ }, +/* 291 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Data zoom model + */ + + + var DataZoomModel = __webpack_require__(288); + var layout = __webpack_require__(21); + var zrUtil = __webpack_require__(3); + + var SliderZoomModel = DataZoomModel.extend({ + + type: 'dataZoom.slider', + + layoutMode: 'box', + + /** + * @protected + */ + defaultOption: { + show: true, + + // ph => placeholder. Using placehoder here because + // deault value can only be drived in view stage. + right: 'ph', // Default align to grid rect. + top: 'ph', // Default align to grid rect. + width: 'ph', // Default align to grid rect. + height: 'ph', // Default align to grid rect. + left: null, // Default align to grid rect. + bottom: null, // Default align to grid rect. + + backgroundColor: 'rgba(47,69,84,0)', // Background of slider zoom component. + dataBackgroundColor: '#ddd', // Background of data shadow. + fillerColor: 'rgba(47,69,84,0.25)', // Color of selected area. + handleColor: 'rgba(47,69,84,0.65)', // Color of handle. + handleSize: 10, + + labelPrecision: null, + labelFormatter: null, + showDetail: true, + showDataShadow: 'auto', // Default auto decision. + realtime: true, + zoomLock: false, // Whether disable zoom. + textStyle: { + color: '#333' + } + }, + + /** + * @public + */ + setDefaultLayoutParams: function (params) { + var option = this.option; + zrUtil.each(['right', 'top', 'width', 'height'], function (name) { + if (option[name] === 'ph') { + option[name] = params[name]; + }; + }); + }, + + /** + * @override + */ + mergeOption: function (option) { + SliderZoomModel.superApply(this, 'mergeOption', arguments); + } + + }); + + module.exports = SliderZoomModel; + + + +/***/ }, +/* 292 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var throttle = __webpack_require__(293); + var DataZoomView = __webpack_require__(290); + var Rect = graphic.Rect; + var numberUtil = __webpack_require__(7); + var linearMap = numberUtil.linearMap; + var layout = __webpack_require__(21); + var sliderMove = __webpack_require__(294); + var asc = numberUtil.asc; + var bind = zrUtil.bind; + var mathRound = Math.round; + var mathMax = Math.max; + var each = zrUtil.each; + + // Constants + var DEFAULT_LOCATION_EDGE_GAP = 7; + var DEFAULT_FRAME_BORDER_WIDTH = 1; + var DEFAULT_FILLER_SIZE = 30; + var HORIZONTAL = 'horizontal'; + var VERTICAL = 'vertical'; + var LABEL_GAP = 5; + var SHOW_DATA_SHADOW_SERIES_TYPE = ['line', 'bar', 'candlestick', 'scatter']; + + var SliderZoomView = DataZoomView.extend({ + + type: 'dataZoom.slider', + + init: function (ecModel, api) { + + /** + * @private + * @type {Object} + */ + this._displayables = {}; + + /** + * @private + * @type {string} + */ + this._orient; + + /** + * [0, 100] + * @private + */ + this._range; + + /** + * [coord of the first handle, coord of the second handle] + * @private + */ + this._handleEnds; + + /** + * [length, thick] + * @private + * @type {Array.} + */ + this._size; + + /** + * @private + * @type {number} + */ + this._halfHandleSize; + + /** + * @private + */ + this._location; + + /** + * @private + */ + this._dragging; + + /** + * @private + */ + this._dataShadowInfo; + + this.api = api; + }, + + /** + * @override + */ + render: function (dataZoomModel, ecModel, api, payload) { + SliderZoomView.superApply(this, 'render', arguments); + + throttle.createOrUpdate( + this, + '_dispatchZoomAction', + this.dataZoomModel.get('throttle'), + 'fixRate' + ); + + this._orient = dataZoomModel.get('orient'); + this._halfHandleSize = mathRound(dataZoomModel.get('handleSize') / 2); + + if (this.dataZoomModel.get('show') === false) { + this.group.removeAll(); + return; + } + + // Notice: this._resetInterval() should not be executed when payload.type + // is 'dataZoom', origin this._range should be maintained, otherwise 'pan' + // or 'zoom' info will be missed because of 'throttle' of this.dispatchAction, + if (!payload || payload.type !== 'dataZoom' || payload.from !== this.uid) { + this._buildView(); + } + + this._updateView(); + }, + + /** + * @override + */ + remove: function () { + SliderZoomView.superApply(this, 'remove', arguments); + throttle.clear(this, '_dispatchZoomAction'); + }, + + /** + * @override + */ + dispose: function () { + SliderZoomView.superApply(this, 'dispose', arguments); + throttle.clear(this, '_dispatchZoomAction'); + }, + + _buildView: function () { + var thisGroup = this.group; + + thisGroup.removeAll(); + + this._resetLocation(); + this._resetInterval(); + + var barGroup = this._displayables.barGroup = new graphic.Group(); + + this._renderBackground(); + this._renderDataShadow(); + this._renderHandle(); + + thisGroup.add(barGroup); + + this._positionGroup(); + }, + + /** + * @private + */ + _resetLocation: function () { + var dataZoomModel = this.dataZoomModel; + var api = this.api; + + // If some of x/y/width/height are not specified, + // auto-adapt according to target grid. + var coordRect = this._findCoordRect(); + var ecSize = {width: api.getWidth(), height: api.getHeight()}; + + // Default align by coordinate system rect. + var positionInfo = this._orient === HORIZONTAL + ? { + // Why using 'right', because right should be used in vertical, + // and it is better to be consistent for dealing with position param merge. + right: ecSize.width - coordRect.x - coordRect.width, + top: (ecSize.height - DEFAULT_FILLER_SIZE - DEFAULT_LOCATION_EDGE_GAP), + width: coordRect.width, + height: DEFAULT_FILLER_SIZE + } + : { // vertical + right: DEFAULT_LOCATION_EDGE_GAP, + top: coordRect.y, + width: DEFAULT_FILLER_SIZE, + height: coordRect.height + }; + + // Write back to option for chart.getOption(). (and may then + // chart.setOption() again, where current location value is needed); + // dataZoomModel.setLayoutParams(positionInfo); + dataZoomModel.setDefaultLayoutParams(positionInfo); + + var layoutRect = layout.getLayoutRect( + dataZoomModel.option, + ecSize, + dataZoomModel.padding + ); + + this._location = {x: layoutRect.x, y: layoutRect.y}; + this._size = [layoutRect.width, layoutRect.height]; + this._orient === VERTICAL && this._size.reverse(); + }, + + /** + * @private + */ + _positionGroup: function () { + var thisGroup = this.group; + var location = this._location; + var orient = this._orient; + + // Just use the first axis to determine mapping. + var targetAxisModel = this.dataZoomModel.getFirstTargetAxisModel(); + var inverse = targetAxisModel && targetAxisModel.get('inverse'); + + var barGroup = this._displayables.barGroup; + var otherAxisInverse = (this._dataShadowInfo || {}).otherAxisInverse; + + // Transform barGroup. + barGroup.attr( + (orient === HORIZONTAL && !inverse) + ? {scale: otherAxisInverse ? [1, 1] : [1, -1]} + : (orient === HORIZONTAL && inverse) + ? {scale: otherAxisInverse ? [-1, 1] : [-1, -1]} + : (orient === VERTICAL && !inverse) + ? {scale: otherAxisInverse ? [1, -1] : [1, 1], rotation: Math.PI / 2} + // Dont use Math.PI, considering shadow direction. + : {scale: otherAxisInverse ? [-1, -1] : [-1, 1], rotation: Math.PI / 2} + ); + + // Position barGroup + var rect = thisGroup.getBoundingRect([barGroup]); + thisGroup.position[0] = location.x - rect.x; + thisGroup.position[1] = location.y - rect.y; + }, + + /** + * @private + */ + _getViewExtent: function () { + // View total length. + var halfHandleSize = this._halfHandleSize; + var totalLength = mathMax(this._size[0], halfHandleSize * 4); + var extent = [halfHandleSize, totalLength - halfHandleSize]; + + return extent; + }, + + _renderBackground : function () { + var dataZoomModel = this.dataZoomModel; + var size = this._size; + + this._displayables.barGroup.add(new Rect({ + silent: true, + shape: { + x: 0, y: 0, width: size[0], height: size[1] + }, + style: { + fill: dataZoomModel.get('backgroundColor') + } + })); + }, + + _renderDataShadow: function () { + var info = this._dataShadowInfo = this._prepareDataShadowInfo(); + + if (!info) { + return; + } + + var size = this._size; + var seriesModel = info.series; + var data = seriesModel.getRawData(); + var otherDim = seriesModel.getShadowDim + ? seriesModel.getShadowDim() // @see candlestick + : info.otherDim; + + var otherDataExtent = data.getDataExtent(otherDim); + // Nice extent. + var otherOffset = (otherDataExtent[1] - otherDataExtent[0]) * 0.3; + otherDataExtent = [ + otherDataExtent[0] - otherOffset, + otherDataExtent[1] + otherOffset + ]; + var otherShadowExtent = [0, size[1]]; + + var thisShadowExtent = [0, size[0]]; + + var points = [[size[0], 0], [0, 0]]; + var step = thisShadowExtent[1] / (data.count() - 1); + var thisCoord = 0; + + // Optimize for large data shadow + var stride = Math.round(data.count() / size[0]); + data.each([otherDim], function (value, index) { + if (stride > 0 && (index % stride)) { + thisCoord += step; + return; + } + // FIXME + // 应该使用统计的空判断?还是在list里进行空判断? + var otherCoord = (value == null || isNaN(value) || value === '') + ? null + : linearMap(value, otherDataExtent, otherShadowExtent, true); + otherCoord != null && points.push([thisCoord, otherCoord]); + + thisCoord += step; + }); + + this._displayables.barGroup.add(new graphic.Polyline({ + shape: {points: points}, + style: {fill: this.dataZoomModel.get('dataBackgroundColor'), lineWidth: 0}, + silent: true, + z2: -20 + })); + }, + + _prepareDataShadowInfo: function () { + var dataZoomModel = this.dataZoomModel; + var showDataShadow = dataZoomModel.get('showDataShadow'); + + if (showDataShadow === false) { + return; + } + + // Find a representative series. + var result; + var ecModel = this.ecModel; + + dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) { + var seriesModels = dataZoomModel + .getAxisProxy(dimNames.name, axisIndex) + .getTargetSeriesModels(); + + zrUtil.each(seriesModels, function (seriesModel) { + if (result) { + return; + } + + if (showDataShadow !== true && zrUtil.indexOf( + SHOW_DATA_SHADOW_SERIES_TYPE, seriesModel.get('type') + ) < 0 + ) { + return; + } + + var otherDim = getOtherDim(dimNames.name); + + var thisAxis = ecModel.getComponent(dimNames.axis, axisIndex).axis; + + result = { + thisAxis: thisAxis, + series: seriesModel, + thisDim: dimNames.name, + otherDim: otherDim, + otherAxisInverse: seriesModel + .coordinateSystem.getOtherAxis(thisAxis).inverse + }; + + }, this); + + }, this); + + return result; + }, + + _renderHandle: function () { + var displaybles = this._displayables; + var handles = displaybles.handles = []; + var handleLabels = displaybles.handleLabels = []; + var barGroup = this._displayables.barGroup; + var size = this._size; + + barGroup.add(displaybles.filler = new Rect({ + draggable: true, + cursor: 'move', + drift: bind(this._onDragMove, this, 'all'), + ondragend: bind(this._onDragEnd, this), + onmouseover: bind(this._showDataInfo, this, true), + onmouseout: bind(this._showDataInfo, this, false), + style: { + fill: this.dataZoomModel.get('fillerColor'), + // text: ':::', + textPosition : 'inside' + } + })); + + // Frame border. + barGroup.add(new Rect(graphic.subPixelOptimizeRect({ + silent: true, + shape: { + x: 0, + y: 0, + width: size[0], + height: size[1] + }, + style: { + stroke: this.dataZoomModel.get('dataBackgroundColor'), + lineWidth: DEFAULT_FRAME_BORDER_WIDTH, + fill: 'rgba(0,0,0,0)' + } + }))); + + each([0, 1], function (handleIndex) { + + barGroup.add(handles[handleIndex] = new Rect({ + style: { + fill: this.dataZoomModel.get('handleColor') + }, + cursor: 'move', + draggable: true, + drift: bind(this._onDragMove, this, handleIndex), + ondragend: bind(this._onDragEnd, this), + onmouseover: bind(this._showDataInfo, this, true), + onmouseout: bind(this._showDataInfo, this, false) + })); + + var textStyleModel = this.dataZoomModel.textStyleModel; + + this.group.add( + handleLabels[handleIndex] = new graphic.Text({ + silent: true, + invisible: true, + style: { + x: 0, y: 0, text: '', + textVerticalAlign: 'middle', + textAlign: 'center', + fill: textStyleModel.getTextColor(), + textFont: textStyleModel.getFont() + } + })); + + }, this); + }, + + /** + * @private + */ + _resetInterval: function () { + var range = this._range = this.dataZoomModel.getPercentRange(); + var viewExtent = this._getViewExtent(); + + this._handleEnds = [ + linearMap(range[0], [0, 100], viewExtent, true), + linearMap(range[1], [0, 100], viewExtent, true) + ]; + }, + + /** + * @private + * @param {(number|string)} handleIndex 0 or 1 or 'all' + * @param {number} dx + * @param {number} dy + */ + _updateInterval: function (handleIndex, delta) { + var handleEnds = this._handleEnds; + var viewExtend = this._getViewExtent(); + + sliderMove( + delta, + handleEnds, + viewExtend, + (handleIndex === 'all' || this.dataZoomModel.get('zoomLock')) + ? 'rigid' : 'cross', + handleIndex + ); + + this._range = asc([ + linearMap(handleEnds[0], viewExtend, [0, 100], true), + linearMap(handleEnds[1], viewExtend, [0, 100], true) + ]); + }, + + /** + * @private + */ + _updateView: function () { + var displaybles = this._displayables; + var handleEnds = this._handleEnds; + var handleInterval = asc(handleEnds.slice()); + var size = this._size; + var halfHandleSize = this._halfHandleSize; + + each([0, 1], function (handleIndex) { + + // Handles + var handle = displaybles.handles[handleIndex]; + handle.setShape({ + x: handleEnds[handleIndex] - halfHandleSize, + y: -1, + width: halfHandleSize * 2, + height: size[1] + 2, + r: 1 + }); + + }, this); + + // Filler + displaybles.filler.setShape({ + x: handleInterval[0], + y: 0, + width: handleInterval[1] - handleInterval[0], + height: this._size[1] + }); + + this._updateDataInfo(); + }, + + /** + * @private + */ + _updateDataInfo: function () { + var dataZoomModel = this.dataZoomModel; + var displaybles = this._displayables; + var handleLabels = displaybles.handleLabels; + var orient = this._orient; + var labelTexts = ['', '']; + + // FIXME + // date型,支持formatter,autoformatter(ec2 date.getAutoFormatter) + if (dataZoomModel.get('showDetail')) { + var dataInterval; + var axis; + dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) { + // Using dataInterval of the first axis. + if (!dataInterval) { + dataInterval = dataZoomModel + .getAxisProxy(dimNames.name, axisIndex) + .getDataValueWindow(); + axis = this.ecModel.getComponent(dimNames.axis, axisIndex).axis; + } + }, this); + + if (dataInterval) { + labelTexts = [ + this._formatLabel(dataInterval[0], axis), + this._formatLabel(dataInterval[1], axis) + ]; + } + } + + var orderedHandleEnds = asc(this._handleEnds.slice()); + + setLabel.call(this, 0); + setLabel.call(this, 1); + + function setLabel(handleIndex) { + // Label + // Text should not transform by barGroup. + var barTransform = graphic.getTransform( + displaybles.handles[handleIndex], this.group + ); + var direction = graphic.transformDirection( + handleIndex === 0 ? 'right' : 'left', barTransform + ); + var offset = this._halfHandleSize + LABEL_GAP; + var textPoint = graphic.applyTransform( + [ + orderedHandleEnds[handleIndex] + (handleIndex === 0 ? -offset : offset), + this._size[1] / 2 + ], + barTransform + ); + handleLabels[handleIndex].setStyle({ + x: textPoint[0], + y: textPoint[1], + textVerticalAlign: orient === HORIZONTAL ? 'middle' : direction, + textAlign: orient === HORIZONTAL ? direction : 'center', + text: labelTexts[handleIndex] + }); + } + }, + + /** + * @private + */ + _formatLabel: function (value, axis) { + var dataZoomModel = this.dataZoomModel; + var labelFormatter = dataZoomModel.get('labelFormatter'); + if (zrUtil.isFunction(labelFormatter)) { + return labelFormatter(value); + } + + var labelPrecision = dataZoomModel.get('labelPrecision'); + if (labelPrecision == null || labelPrecision === 'auto') { + labelPrecision = axis.getPixelPrecision(); + } + + value = (value == null && isNaN(value)) + ? '' + // FIXME Glue code + : (axis.type === 'category' || axis.type === 'time') + ? axis.scale.getLabel(Math.round(value)) + // param of toFixed should less then 20. + : value.toFixed(Math.min(labelPrecision, 20)); + + if (zrUtil.isString(labelFormatter)) { + value = labelFormatter.replace('{value}', value); + } + + return value; + }, + + /** + * @private + * @param {boolean} showOrHide true: show, false: hide + */ + _showDataInfo: function (showOrHide) { + // Always show when drgging. + showOrHide = this._dragging || showOrHide; + + var handleLabels = this._displayables.handleLabels; + handleLabels[0].attr('invisible', !showOrHide); + handleLabels[1].attr('invisible', !showOrHide); + }, + + _onDragMove: function (handleIndex, dx, dy) { + this._dragging = true; + + // Transform dx, dy to bar coordination. + var vertex = this._applyBarTransform([dx, dy], true); + + this._updateInterval(handleIndex, vertex[0]); + this._updateView(); + + if (this.dataZoomModel.get('realtime')) { + this._dispatchZoomAction(); + } + }, + + _onDragEnd: function () { + this._dragging = false; + this._showDataInfo(false); + this._dispatchZoomAction(); + }, + + /** + * This action will be throttled. + * @private + */ + _dispatchZoomAction: function () { + var range = this._range; + + this.api.dispatchAction({ + type: 'dataZoom', + from: this.uid, + dataZoomId: this.dataZoomModel.id, + start: range[0], + end: range[1] + }); + }, + + /** + * @private + */ + _applyBarTransform: function (vertex, inverse) { + var barTransform = this._displayables.barGroup.getLocalTransform(); + return graphic.applyTransform(vertex, barTransform, inverse); + }, + + /** + * @private + */ + _findCoordRect: function () { + // Find the grid coresponding to the first axis referred by dataZoom. + var targetInfo = this.getTargetInfo(); + + // FIXME + // 判断是catesian还是polar + var rect; + if (targetInfo.cartesians.length) { + rect = targetInfo.cartesians[0].model.coordinateSystem.getRect(); + } + else { // Polar + // FIXME + // 暂时随便写的 + var width = this.api.getWidth(); + var height = this.api.getHeight(); + rect = { + x: width * 0.2, + y: height * 0.2, + width: width * 0.6, + height: height * 0.6 + }; + } + + return rect; + } + + }); + + function getOtherDim(thisDim) { + // FIXME + // 这个逻辑和getOtherAxis里一致,但是写在这里是否不好 + return thisDim === 'x' ? 'y' : 'x'; + } + + module.exports = SliderZoomView; + + + +/***/ }, +/* 293 */ +/***/ function(module, exports) { + + + + var lib = {}; + + var ORIGIN_METHOD = '\0__throttleOriginMethod'; + var RATE = '\0__throttleRate'; + + /** + * 频率控制 返回函数连续调用时,fn 执行频率限定为每多少时间执行一次 + * 例如常见效果: + * notifyWhenChangesStop + * 频繁调用时,只保证最后一次执行 + * 配成:trailing:true;debounce:true 即可 + * notifyAtFixRate + * 频繁调用时,按规律心跳执行 + * 配成:trailing:true;debounce:false 即可 + * 注意: + * 根据model更新view的时候,可以使用throttle, + * 但是根据view更新model的时候,避免使用这种延迟更新的方式。 + * 因为这可能导致model和server同步出现问题。 + * + * @public + * @param {(Function|Array.)} fn 需要调用的函数 + * 如果fn为array,则表示可以对多个函数进行throttle。 + * 他们共享同一个timer。 + * @param {number} delay 延迟时间,单位毫秒 + * @param {bool} trailing 是否保证最后一次触发的执行 + * true:表示保证最后一次调用会触发执行。 + * 但任何调用后不可能立即执行,总会delay。 + * false:表示不保证最后一次调用会触发执行。 + * 但只要间隔大于delay,调用就会立即执行。 + * @param {bool} debounce 节流 + * true:表示:频繁调用(间隔小于delay)时,根本不执行 + * false:表示:频繁调用(间隔小于delay)时,按规律心跳执行 + * @return {(Function|Array.)} 实际调用函数。 + * 当输入的fn为array时,返回值也为array。 + * 每项是Function。 + */ + lib.throttle = function (fn, delay, trailing, debounce) { + + var currCall = (new Date()).getTime(); + var lastCall = 0; + var lastExec = 0; + var timer = null; + var diff; + var scope; + var args; + var isSingle = typeof fn === 'function'; + delay = delay || 0; + + if (isSingle) { + return createCallback(); + } + else { + var ret = []; + for (var i = 0; i < fn.length; i++) { + ret[i] = createCallback(i); + } + return ret; + } + + function createCallback(index) { + + function exec() { + lastExec = (new Date()).getTime(); + timer = null; + (isSingle ? fn : fn[index]).apply(scope, args || []); + } + + var cb = function () { + currCall = (new Date()).getTime(); + scope = this; + args = arguments; + diff = currCall - (debounce ? lastCall : lastExec) - delay; + + clearTimeout(timer); + + if (debounce) { + if (trailing) { + timer = setTimeout(exec, delay); + } + else if (diff >= 0) { + exec(); + } + } + else { + if (diff >= 0) { + exec(); + } + else if (trailing) { + timer = setTimeout(exec, -diff); + } + } + + lastCall = currCall; + }; + + /** + * Clear throttle. + * @public + */ + cb.clear = function () { + if (timer) { + clearTimeout(timer); + timer = null; + } + }; + + return cb; + } + }; + + /** + * 按一定频率执行,最后一次调用总归会执行 + * + * @public + */ + lib.fixRate = function (fn, delay) { + return delay != null + ? lib.throttle(fn, delay, true, false) + : fn; + }; + + /** + * 直到不频繁调用了才会执行,最后一次调用总归会执行 + * + * @public + */ + lib.debounce = function (fn, delay) { + return delay != null + ? lib.throttle(fn, delay, true, true) + : fn; + }; + + + /** + * Create throttle method or update throttle rate. + * + * @example + * ComponentView.prototype.render = function () { + * ... + * throttle.createOrUpdate( + * this, + * '_dispatchAction', + * this.model.get('throttle'), + * 'fixRate' + * ); + * }; + * ComponentView.prototype.remove = function () { + * throttle.clear(this, '_dispatchAction'); + * }; + * ComponentView.prototype.dispose = function () { + * throttle.clear(this, '_dispatchAction'); + * }; + * + * @public + * @param {Object} obj + * @param {string} fnAttr + * @param {number} rate + * @param {string} throttleType 'fixRate' or 'debounce' + */ + lib.createOrUpdate = function (obj, fnAttr, rate, throttleType) { + var fn = obj[fnAttr]; + + if (!fn || rate == null || !throttleType) { + return; + } + + var originFn = fn[ORIGIN_METHOD] || fn; + var lastRate = fn[RATE]; + + if (lastRate !== rate) { + fn = obj[fnAttr] = lib[throttleType](originFn, rate); + fn[ORIGIN_METHOD] = originFn; + fn[RATE] = rate; + } + }; + + /** + * Clear throttle. Example see throttle.createOrUpdate. + * + * @public + * @param {Object} obj + * @param {string} fnAttr + */ + lib.clear = function (obj, fnAttr) { + var fn = obj[fnAttr]; + if (fn && fn[ORIGIN_METHOD]) { + obj[fnAttr] = fn[ORIGIN_METHOD]; + } + }; + + module.exports = lib; + + + +/***/ }, +/* 294 */ +/***/ function(module, exports) { + + + + /** + * Calculate slider move result. + * + * @param {number} delta Move length. + * @param {Array.} handleEnds handleEnds[0] and be bigger then handleEnds[1]. + * handleEnds will be modified in this method. + * @param {Array.} extent handleEnds is restricted by extent. + * extent[0] should less or equals than extent[1]. + * @param {string} mode 'rigid': Math.abs(handleEnds[0] - handleEnds[1]) remain unchanged, + * 'cross' handleEnds[0] can be bigger then handleEnds[1], + * 'push' handleEnds[0] can not be bigger then handleEnds[1], + * when they touch, one push other. + * @param {number} handleIndex If mode is 'rigid', handleIndex is not required. + * @param {Array.} The input handleEnds. + */ + module.exports = function (delta, handleEnds, extent, mode, handleIndex) { + if (!delta) { + return handleEnds; + } + + if (mode === 'rigid') { + delta = getRealDelta(delta, handleEnds, extent); + handleEnds[0] += delta; + handleEnds[1] += delta; + } + else { + delta = getRealDelta(delta, handleEnds[handleIndex], extent); + handleEnds[handleIndex] += delta; + + if (mode === 'push' && handleEnds[0] > handleEnds[1]) { + handleEnds[1 - handleIndex] = handleEnds[handleIndex]; + } + } + + return handleEnds; + + function getRealDelta(delta, handleEnds, extent) { + var handleMinMax = !handleEnds.length + ? [handleEnds, handleEnds] + : handleEnds.slice(); + handleEnds[0] > handleEnds[1] && handleMinMax.reverse(); + + if (delta < 0 && handleMinMax[0] + delta < extent[0]) { + delta = extent[0] - handleMinMax[0]; + } + if (delta > 0 && handleMinMax[1] + delta > extent[1]) { + delta = extent[1] - handleMinMax[1]; + } + return delta; + } + }; + + +/***/ }, +/* 295 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Data zoom model + */ + + + module.exports = __webpack_require__(288).extend({ + + type: 'dataZoom.inside', + + /** + * @protected + */ + defaultOption: { + zoomLock: false // Whether disable zoom but only pan. + } + }); + + +/***/ }, +/* 296 */ +/***/ function(module, exports, __webpack_require__) { + + + + var DataZoomView = __webpack_require__(290); + var zrUtil = __webpack_require__(3); + var sliderMove = __webpack_require__(294); + var roams = __webpack_require__(297); + var bind = zrUtil.bind; + + var InsideZoomView = DataZoomView.extend({ + + type: 'dataZoom.inside', + + /** + * @override + */ + init: function (ecModel, api) { + /** + * 'throttle' is used in this.dispatchAction, so we save range + * to avoid missing some 'pan' info. + * @private + * @type {Array.} + */ + this._range; + }, + + /** + * @override + */ + render: function (dataZoomModel, ecModel, api, payload) { + InsideZoomView.superApply(this, 'render', arguments); + + // Notice: origin this._range should be maintained, and should not be re-fetched + // from dataZoomModel when payload.type is 'dataZoom', otherwise 'pan' or 'zoom' + // info will be missed because of 'throttle' of this.dispatchAction. + if (roams.shouldRecordRange(payload, dataZoomModel.id)) { + this._range = dataZoomModel.getPercentRange(); + } + + // Reset controllers. + zrUtil.each(this.getTargetInfo().cartesians, function (coordInfo) { + var coordModel = coordInfo.model; + roams.register( + api, + { + coordId: coordModel.id, + coordType: coordModel.type, + coordinateSystem: coordModel.coordinateSystem, + dataZoomId: dataZoomModel.id, + throttleRage: dataZoomModel.get('throttle', true), + panGetRange: bind(this._onPan, this, coordInfo), + zoomGetRange: bind(this._onZoom, this, coordInfo) + } + ); + }, this); + + // TODO + // polar支持 + }, + + /** + * @override + */ + remove: function () { + roams.unregister(this.api, this.dataZoomModel.id); + InsideZoomView.superApply(this, 'remove', arguments); + this._range = null; + }, + + /** + * @override + */ + dispose: function () { + roams.unregister(this.api, this.dataZoomModel.id); + InsideZoomView.superApply(this, 'dispose', arguments); + this._range = null; + }, + + /** + * @private + */ + _onPan: function (coordInfo, controller, dx, dy) { + return ( + this._range = panCartesian( + [dx, dy], this._range, controller, coordInfo + ) + ); + }, + + /** + * @private + */ + _onZoom: function (coordInfo, controller, scale, mouseX, mouseY) { + var dataZoomModel = this.dataZoomModel; + + if (dataZoomModel.option.zoomLock) { + return; + } + + return ( + this._range = scaleCartesian( + 1 / scale, [mouseX, mouseY], this._range, + controller, coordInfo, dataZoomModel + ) + ); + } + + }); + + function panCartesian(pixelDeltas, range, controller, coordInfo) { + range = range.slice(); + + // Calculate transform by the first axis. + var axisModel = coordInfo.axisModels[0]; + if (!axisModel) { + return; + } + + var directionInfo = getDirectionInfo(pixelDeltas, axisModel, controller); + + var percentDelta = directionInfo.signal + * (range[1] - range[0]) + * directionInfo.pixel / directionInfo.pixelLength; + + sliderMove( + percentDelta, + range, + [0, 100], + 'rigid' + ); + + return range; + } + + function scaleCartesian(scale, mousePoint, range, controller, coordInfo, dataZoomModel) { + range = range.slice(); + + // Calculate transform by the first axis. + var axisModel = coordInfo.axisModels[0]; + if (!axisModel) { + return; + } + + var directionInfo = getDirectionInfo(mousePoint, axisModel, controller); + + var mouse = directionInfo.pixel - directionInfo.pixelStart; + var percentPoint = mouse / directionInfo.pixelLength * (range[1] - range[0]) + range[0]; + + scale = Math.max(scale, 0); + range[0] = (range[0] - percentPoint) * scale + percentPoint; + range[1] = (range[1] - percentPoint) * scale + percentPoint; + + return fixRange(range); + } + + function getDirectionInfo(xy, axisModel, controller) { + var axis = axisModel.axis; + var rect = controller.rect; + var ret = {}; + + if (axis.dim === 'x') { + ret.pixel = xy[0]; + ret.pixelLength = rect.width; + ret.pixelStart = rect.x; + ret.signal = axis.inverse ? 1 : -1; + } + else { // axis.dim === 'y' + ret.pixel = xy[1]; + ret.pixelLength = rect.height; + ret.pixelStart = rect.y; + ret.signal = axis.inverse ? -1 : 1; + } + + return ret; + } + + function fixRange(range) { + // Clamp, using !(<= or >=) to handle NaN. + // jshint ignore:start + var bound = [0, 100]; + !(range[0] <= bound[1]) && (range[0] = bound[1]); + !(range[1] <= bound[1]) && (range[1] = bound[1]); + !(range[0] >= bound[0]) && (range[0] = bound[0]); + !(range[1] >= bound[0]) && (range[1] = bound[0]); + // jshint ignore:end + + return range; + } + + module.exports = InsideZoomView; + + +/***/ }, +/* 297 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Roam controller manager. + */ + + + // Only create one roam controller for each coordinate system. + // one roam controller might be refered by two inside data zoom + // components (for example, one for x and one for y). When user + // pan or zoom, only dispatch one action for those data zoom + // components. + + var zrUtil = __webpack_require__(3); + var RoamController = __webpack_require__(159); + var throttle = __webpack_require__(293); + var curry = zrUtil.curry; + + var ATTR = '\0_ec_dataZoom_roams'; + + var roams = { + + /** + * @public + * @param {module:echarts/ExtensionAPI} api + * @param {Object} dataZoomInfo + * @param {string} dataZoomInfo.coordType + * @param {string} dataZoomInfo.coordId + * @param {Object} dataZoomInfo.coordinateSystem + * @param {string} dataZoomInfo.dataZoomId + * @param {number} dataZoomInfo.throttleRate + * @param {Function} dataZoomInfo.panGetRange + * @param {Function} dataZoomInfo.zoomGetRange + */ + register: function (api, dataZoomInfo) { + var store = giveStore(api); + var theDataZoomId = dataZoomInfo.dataZoomId; + var theCoordId = dataZoomInfo.coordType + '\0_' + dataZoomInfo.coordId; + + // Do clean when a dataZoom changes its target coordnate system. + zrUtil.each(store, function (record, coordId) { + var dataZoomInfos = record.dataZoomInfos; + if (dataZoomInfos[theDataZoomId] && coordId !== theCoordId) { + delete dataZoomInfos[theDataZoomId]; + record.count--; + } + }); + + cleanStore(store); + + var record = store[theCoordId]; + + // Create if needed. + if (!record) { + record = store[theCoordId] = { + coordId: theCoordId, + dataZoomInfos: {}, + count: 0 + }; + record.controller = createController(api, dataZoomInfo, record); + record.dispatchAction = zrUtil.curry(dispatchAction, api); + } + + // Update. + if (record) { + throttle.createOrUpdate( + record, + 'dispatchAction', + dataZoomInfo.throttleRate, + 'fixRate' + ); + + !record.dataZoomInfos[theDataZoomId] && record.count++; + record.dataZoomInfos[theDataZoomId] = dataZoomInfo; + } + }, + + /** + * @public + * @param {module:echarts/ExtensionAPI} api + * @param {string} dataZoomId + */ + unregister: function (api, dataZoomId) { + var store = giveStore(api); + + zrUtil.each(store, function (record, coordId) { + var dataZoomInfos = record.dataZoomInfos; + if (dataZoomInfos[dataZoomId]) { + delete dataZoomInfos[dataZoomId]; + record.count--; + } + }); + + cleanStore(store); + }, + + /** + * @public + */ + shouldRecordRange: function (payload, dataZoomId) { + if (payload && payload.type === 'dataZoom' && payload.batch) { + for (var i = 0, len = payload.batch.length; i < len; i++) { + if (payload.batch[i].dataZoomId === dataZoomId) { + return false; + } + } + } + return true; + } + + }; + + /** + * Key: coordId, value: {dataZoomInfos: [], count, controller} + * @type {Array.} + */ + function giveStore(api) { + // Mount store on zrender instance, so that we do not + // need to worry about dispose. + var zr = api.getZr(); + return zr[ATTR] || (zr[ATTR] = {}); + } + + function createController(api, dataZoomInfo, newRecord) { + var controller = new RoamController(api.getZr()); + controller.enable(); + controller.on('pan', curry(onPan, newRecord)); + controller.on('zoom', curry(onZoom, newRecord)); + controller.rect = dataZoomInfo.coordinateSystem.getRect().clone(); + + return controller; + } + + function cleanStore(store) { + zrUtil.each(store, function (record, coordId) { + if (!record.count) { + record.controller.off('pan').off('zoom'); + delete store[coordId]; + } + }); + } + + function onPan(record, dx, dy) { + wrapAndDispatch(record, function (info) { + return info.panGetRange(record.controller, dx, dy); + }); + } + + function onZoom(record, scale, mouseX, mouseY) { + wrapAndDispatch(record, function (info) { + return info.zoomGetRange(record.controller, scale, mouseX, mouseY); + }); + } + + function wrapAndDispatch(record, getRange) { + var batch = []; + + zrUtil.each(record.dataZoomInfos, function (info) { + var range = getRange(info); + range && batch.push({ + dataZoomId: info.dataZoomId, + start: range[0], + end: range[1] + }); + }); + + record.dispatchAction(batch); + } + + /** + * This action will be throttled. + */ + function dispatchAction(api, batch) { + api.dispatchAction({ + type: 'dataZoom', + batch: batch + }); + } + + module.exports = roams; + + + +/***/ }, +/* 298 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Data zoom processor + */ + + + var echarts = __webpack_require__(1); + + echarts.registerProcessor('filter', function (ecModel, api) { + + ecModel.eachComponent('dataZoom', function (dataZoomModel) { + // We calculate window and reset axis here but not in model + // init stage and not after action dispatch handler, because + // reset should be called after seriesData.restoreData. + dataZoomModel.eachTargetAxis(resetSingleAxis); + + // Caution: data zoom filtering is order sensitive when using + // percent range and no min/max/scale set on axis. + // For example, we have dataZoom definition: + // [ + // {xAxisIndex: 0, start: 30, end: 70}, + // {yAxisIndex: 0, start: 20, end: 80} + // ] + // In this case, [20, 80] of y-dataZoom should be based on data + // that have filtered by x-dataZoom using range of [30, 70], + // but should not be based on full raw data. Thus sliding + // x-dataZoom will change both ranges of xAxis and yAxis, + // while sliding y-dataZoom will only change the range of yAxis. + // So we should filter x-axis after reset x-axis immediately, + // and then reset y-axis and filter y-axis. + dataZoomModel.eachTargetAxis(filterSingleAxis); + }); + + ecModel.eachComponent('dataZoom', function (dataZoomModel) { + // Fullfill all of the range props so that user + // is able to get them from chart.getOption(). + var axisProxy = dataZoomModel.findRepresentativeAxisProxy(); + var percentRange = axisProxy.getDataPercentWindow(); + var valueRange = axisProxy.getDataValueWindow(); + dataZoomModel.setRawRange({ + start: percentRange[0], + end: percentRange[1], + startValue: valueRange[0], + endValue: valueRange[1] + }); + }); + }); + + function resetSingleAxis(dimNames, axisIndex, dataZoomModel) { + dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel); + } + + function filterSingleAxis(dimNames, axisIndex, dataZoomModel) { + dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel); + } + + + + +/***/ }, +/* 299 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Data zoom action + */ + + + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var echarts = __webpack_require__(1); + + + echarts.registerAction('dataZoom', function (payload, ecModel) { + + var linkedNodesFinder = modelUtil.createLinkedNodesFinder( + zrUtil.bind(ecModel.eachComponent, ecModel, 'dataZoom'), + modelUtil.eachAxisDim, + function (model, dimNames) { + return model.get(dimNames.axisIndex); + } + ); + + var effectedModels = []; + + ecModel.eachComponent( + {mainType: 'dataZoom', query: payload}, + function (model, index) { + effectedModels.push.apply( + effectedModels, linkedNodesFinder(model).nodes + ); + } + ); + + zrUtil.each(effectedModels, function (dataZoomModel, index) { + dataZoomModel.setRawRange({ + start: payload.start, + end: payload.end, + startValue: payload.startValue, + endValue: payload.endValue + }); + }); + + }); + + + +/***/ }, +/* 300 */, +/* 301 */, +/* 302 */, +/* 303 */, +/* 304 */, +/* 305 */, +/* 306 */, +/* 307 */, +/* 308 */, +/* 309 */, +/* 310 */, +/* 311 */, +/* 312 */, +/* 313 */, +/* 314 */, +/* 315 */ +/***/ function(module, exports, __webpack_require__) { + + // HINT Markpoint can't be used too much + + + __webpack_require__(316); + __webpack_require__(317); + + __webpack_require__(1).registerPreprocessor(function (opt) { + // Make sure markPoint component is enabled + opt.markPoint = opt.markPoint || {}; + }); + + +/***/ }, +/* 316 */ +/***/ function(module, exports, __webpack_require__) { + + + // Default enable markPoint + // var globalDefault = require('../../model/globalDefault'); + var modelUtil = __webpack_require__(5); + // // Force to load markPoint component + // globalDefault.markPoint = {}; + + var MarkPointModel = __webpack_require__(1).extendComponentModel({ + + type: 'markPoint', + + dependencies: ['series', 'grid', 'polar'], + /** + * @overrite + */ + init: function (option, parentModel, ecModel, extraOpt) { + this.mergeDefaultAndTheme(option, ecModel); + this.mergeOption(option, ecModel, extraOpt.createdBySelf, true); + }, + + mergeOption: function (newOpt, ecModel, createdBySelf, isInit) { + if (!createdBySelf) { + ecModel.eachSeries(function (seriesModel) { + var markPointOpt = seriesModel.get('markPoint'); + var mpModel = seriesModel.markPointModel; + if (!markPointOpt || !markPointOpt.data) { + seriesModel.markPointModel = null; + return; + } + if (!mpModel) { + if (isInit) { + // Default label emphasis `position` and `show` + modelUtil.defaultEmphasis( + markPointOpt.label, + ['position', 'show', 'textStyle', 'distance', 'formatter'] + ); + } + var opt = { + // Use the same series index and name + seriesIndex: seriesModel.seriesIndex, + name: seriesModel.name, + createdBySelf: true + }; + mpModel = new MarkPointModel( + markPointOpt, this, ecModel, opt + ); + } + else { + mpModel.mergeOption(markPointOpt, ecModel, true); + } + seriesModel.markPointModel = mpModel; + }, this); + } + }, + + defaultOption: { + zlevel: 0, + z: 5, + symbol: 'pin', // 标注类型 + symbolSize: 50, // 标注大小 + // symbolRotate: null, // 标注旋转控制 + tooltip: { + trigger: 'item' + }, + label: { + normal: { + show: true, + // 标签文本格式器,同Tooltip.formatter,不支持回调 + // formatter: null, + // 可选为'left'|'right'|'top'|'bottom' + position: 'inside' + // 默认使用全局文本样式,详见TEXTSTYLE + // textStyle: null + }, + emphasis: { + show: true + // 标签文本格式器,同Tooltip.formatter,不支持回调 + // formatter: null, + // position: 'inside' // 'left'|'right'|'top'|'bottom' + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + } + }, + itemStyle: { + normal: { + // color: 各异, + // 标注边线颜色,优先于color + // borderColor: 各异, + // 标注边线线宽,单位px,默认为1 + borderWidth: 2 + }, + emphasis: { + // color: 各异 + } + } + } + }); + + module.exports = MarkPointModel; + + +/***/ }, +/* 317 */ +/***/ function(module, exports, __webpack_require__) { + + + + var SymbolDraw = __webpack_require__(98); + var zrUtil = __webpack_require__(3); + var formatUtil = __webpack_require__(6); + var modelUtil = __webpack_require__(5); + var numberUtil = __webpack_require__(7); + + var addCommas = formatUtil.addCommas; + var encodeHTML = formatUtil.encodeHTML; + + var List = __webpack_require__(94); + + var markerHelper = __webpack_require__(318); + + // FIXME + var markPointFormatMixin = { + getRawDataArray: function () { + return this.option.data; + }, + + formatTooltip: function (dataIndex) { + var data = this.getData(); + var value = this.getRawValue(dataIndex); + var formattedValue = zrUtil.isArray(value) + ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); + var name = data.getName(dataIndex); + return this.name + '
' + + ((name ? encodeHTML(name) + ' : ' : '') + formattedValue); + }, + + getData: function () { + return this._data; + }, + + setData: function (data) { + this._data = data; + } + }; + + zrUtil.defaults(markPointFormatMixin, modelUtil.dataFormatMixin); + + __webpack_require__(1).extendComponentView({ + + type: 'markPoint', + + init: function () { + this._symbolDrawMap = {}; + }, + + render: function (markPointModel, ecModel, api) { + var symbolDrawMap = this._symbolDrawMap; + for (var name in symbolDrawMap) { + symbolDrawMap[name].__keep = false; + } + + ecModel.eachSeries(function (seriesModel) { + var mpModel = seriesModel.markPointModel; + mpModel && this._renderSeriesMP(seriesModel, mpModel, api); + }, this); + + for (var name in symbolDrawMap) { + if (!symbolDrawMap[name].__keep) { + symbolDrawMap[name].remove(); + this.group.remove(symbolDrawMap[name].group); + } + } + }, + + _renderSeriesMP: function (seriesModel, mpModel, api) { + var coordSys = seriesModel.coordinateSystem; + var seriesName = seriesModel.name; + var seriesData = seriesModel.getData(); + + var symbolDrawMap = this._symbolDrawMap; + var symbolDraw = symbolDrawMap[seriesName]; + if (!symbolDraw) { + symbolDraw = symbolDrawMap[seriesName] = new SymbolDraw(); + } + + var mpData = createList(coordSys, seriesModel, mpModel); + var dims = coordSys && coordSys.dimensions; + + // FIXME + zrUtil.mixin(mpModel, markPointFormatMixin); + mpModel.setData(mpData); + + mpData.each(function (idx) { + var itemModel = mpData.getItemModel(idx); + var point; + var xPx = itemModel.getShallow('x'); + var yPx = itemModel.getShallow('y'); + if (xPx != null && yPx != null) { + point = [ + numberUtil.parsePercent(xPx, api.getWidth()), + numberUtil.parsePercent(yPx, api.getHeight()) + ]; + } + // Chart like bar may have there own marker positioning logic + else if (seriesModel.getMarkerPosition) { + // Use the getMarkerPoisition + point = seriesModel.getMarkerPosition( + mpData.getValues(mpData.dimensions, idx) + ); + } + else if (coordSys) { + var x = mpData.get(dims[0], idx); + var y = mpData.get(dims[1], idx); + point = coordSys.dataToPoint([x, y]); + } + + mpData.setItemLayout(idx, point); + + var symbolSize = itemModel.getShallow('symbolSize'); + if (typeof symbolSize === 'function') { + // FIXME 这里不兼容 ECharts 2.x,2.x 貌似参数是整个数据? + symbolSize = symbolSize( + mpModel.getRawValue(idx), mpModel.getDataParams(idx) + ); + } + mpData.setItemVisual(idx, { + symbolSize: symbolSize, + color: itemModel.get('itemStyle.normal.color') + || seriesData.getVisual('color'), + symbol: itemModel.getShallow('symbol') + }); + }); + + // TODO Text are wrong + symbolDraw.updateData(mpData); + this.group.add(symbolDraw.group); + + // Set host model for tooltip + // FIXME + mpData.eachItemGraphicEl(function (el) { + el.traverse(function (child) { + child.hostModel = mpModel; + }); + }); + + symbolDraw.__keep = true; + } + }); + + /** + * @inner + * @param {module:echarts/coord/*} [coordSys] + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/model/Model} mpModel + */ + function createList(coordSys, seriesModel, mpModel) { + var coordDimsInfos = zrUtil.map(coordSys.dimensions, function (coordDim) { + var info = seriesModel.getData().getDimensionInfo( + seriesModel.coordDimToDataDim(coordDim)[0] + ); + info.name = coordDim; + return info; + }); + + var mpData = new List(coordDimsInfos, mpModel); + + if (coordSys) { + mpData.initData( + zrUtil.filter( + zrUtil.map(mpModel.get('data'), zrUtil.curry( + markerHelper.dataTransform, seriesModel + )), + zrUtil.curry(markerHelper.dataFilter, coordSys) + ), + null, + markerHelper.dimValueGetter + ); + } + + return mpData; + } + + + +/***/ }, +/* 318 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var indexOf = zrUtil.indexOf; + + function getPrecision(data, valueAxisDim, dataIndex) { + var precision = -1; + do { + precision = Math.max( + numberUtil.getPrecision(data.get( + valueAxisDim, dataIndex + )), + precision + ); + data = data.stackedOn; + } while (data); + + return precision; + } + + function markerTypeCalculatorWithExtent( + mlType, data, baseDataDim, valueDataDim, baseCoordIndex, valueCoordIndex + ) { + var coordArr = []; + var value = numCalculate(data, valueDataDim, mlType); + + var dataIndex = data.indexOfNearest(valueDataDim, value, true); + coordArr[baseCoordIndex] = data.get(baseDataDim, dataIndex, true); + coordArr[valueCoordIndex] = data.get(valueDataDim, dataIndex, true); + + var precision = getPrecision(data, valueDataDim, dataIndex); + if (precision >= 0) { + coordArr[valueCoordIndex] = +coordArr[valueCoordIndex].toFixed(precision); + } + + return coordArr; + } + + var curry = zrUtil.curry; + // TODO Specified percent + var markerTypeCalculator = { + /** + * @method + * @param {module:echarts/data/List} data + * @param {string} baseAxisDim + * @param {string} valueAxisDim + */ + min: curry(markerTypeCalculatorWithExtent, 'min'), + /** + * @method + * @param {module:echarts/data/List} data + * @param {string} baseAxisDim + * @param {string} valueAxisDim + */ + max: curry(markerTypeCalculatorWithExtent, 'max'), + /** + * @method + * @param {module:echarts/data/List} data + * @param {string} baseAxisDim + * @param {string} valueAxisDim + */ + average: curry(markerTypeCalculatorWithExtent, 'average') + }; + + /** + * Transform markPoint data item to format used in List by do the following + * 1. Calculate statistic like `max`, `min`, `average` + * 2. Convert `item.xAxis`, `item.yAxis` to `item.coord` array + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/coord/*} [coordSys] + * @param {Object} item + * @return {Object} + */ + var dataTransform = function (seriesModel, item) { + var data = seriesModel.getData(); + var coordSys = seriesModel.coordinateSystem; + + // 1. If not specify the position with pixel directly + // 2. If `coord` is not a data array. Which uses `xAxis`, + // `yAxis` to specify the coord on each dimension + if ((isNaN(item.x) || isNaN(item.y)) + && !zrUtil.isArray(item.coord) + && coordSys + ) { + var axisInfo = getAxisInfo(item, data, coordSys, seriesModel); + + // Clone the option + // Transform the properties xAxis, yAxis, radiusAxis, angleAxis, geoCoord to value + item = zrUtil.clone(item); + + if (item.type + && markerTypeCalculator[item.type] + && axisInfo.baseAxis && axisInfo.valueAxis + ) { + var dims = coordSys.dimensions; + var baseCoordIndex = indexOf(dims, axisInfo.baseAxis.dim); + var valueCoordIndex = indexOf(dims, axisInfo.valueAxis.dim); + + item.coord = markerTypeCalculator[item.type]( + data, axisInfo.baseDataDim, axisInfo.valueDataDim, + baseCoordIndex, valueCoordIndex + ); + // Force to use the value of calculated value. + item.value = item.coord[valueCoordIndex]; + } + else { + // FIXME Only has one of xAxis and yAxis. + item.coord = [ + item.xAxis != null ? item.xAxis : item.radiusAxis, + item.yAxis != null ? item.yAxis : item.angleAxis + ]; + } + } + return item; + }; + + var getAxisInfo = function (item, data, coordSys, seriesModel) { + var ret = {}; + + if (item.valueIndex != null || item.valueDim != null) { + ret.valueDataDim = item.valueIndex != null + ? data.getDimension(item.valueIndex) : item.valueDim; + ret.valueAxis = coordSys.getAxis(seriesModel.dataDimToCoordDim(ret.valueDataDim)); + ret.baseAxis = coordSys.getOtherAxis(ret.valueAxis); + ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0]; + } + else { + ret.baseAxis = seriesModel.getBaseAxis(); + ret.valueAxis = coordSys.getOtherAxis(ret.baseAxis); + ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0]; + ret.valueDataDim = seriesModel.coordDimToDataDim(ret.valueAxis.dim)[0]; + } + + return ret; + }; + + /** + * Filter data which is out of coordinateSystem range + * [dataFilter description] + * @param {module:echarts/coord/*} [coordSys] + * @param {Object} item + * @return {boolean} + */ + var dataFilter = function (coordSys, item) { + // Alwalys return true if there is no coordSys + return (coordSys && item.coord && (item.x == null || item.y == null)) + ? coordSys.containData(item.coord) : true; + }; + + var dimValueGetter = function (item, dimName, dataIndex, dimIndex) { + // x, y, radius, angle + if (dimIndex < 2) { + return item.coord && item.coord[dimIndex]; + } + else { + item.value; + } + }; + + var numCalculate = function (data, valueDataDim, mlType) { + return mlType === 'average' + ? data.getSum(valueDataDim, true) / data.count() + : data.getDataExtent(valueDataDim, true)[mlType === 'max' ? 1 : 0]; + }; + + module.exports = { + dataTransform: dataTransform, + dataFilter: dataFilter, + dimValueGetter: dimValueGetter, + getAxisInfo: getAxisInfo, + numCalculate: numCalculate + }; + + +/***/ }, +/* 319 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(320); + __webpack_require__(321); + + __webpack_require__(1).registerPreprocessor(function (opt) { + // Make sure markLine component is enabled + opt.markLine = opt.markLine || {}; + }); + + +/***/ }, +/* 320 */ +/***/ function(module, exports, __webpack_require__) { + + + + // Default enable markLine + // var globalDefault = require('../../model/globalDefault'); + var modelUtil = __webpack_require__(5); + + // // Force to load markLine component + // globalDefault.markLine = {}; + + var MarkLineModel = __webpack_require__(1).extendComponentModel({ + + type: 'markLine', + + dependencies: ['series', 'grid', 'polar'], + /** + * @overrite + */ + init: function (option, parentModel, ecModel, extraOpt) { + this.mergeDefaultAndTheme(option, ecModel); + this.mergeOption(option, ecModel, extraOpt.createdBySelf, true); + }, + + mergeOption: function (newOpt, ecModel, createdBySelf, isInit) { + if (!createdBySelf) { + ecModel.eachSeries(function (seriesModel) { + var markLineOpt = seriesModel.get('markLine'); + var mlModel = seriesModel.markLineModel; + if (!markLineOpt || !markLineOpt.data) { + seriesModel.markLineModel = null; + return; + } + if (!mlModel) { + if (isInit) { + // Default label emphasis `position` and `show` + modelUtil.defaultEmphasis( + markLineOpt.label, + ['position', 'show', 'textStyle', 'distance', 'formatter'] + ); + } + var opt = { + // Use the same series index and name + seriesIndex: seriesModel.seriesIndex, + name: seriesModel.name, + createdBySelf: true + }; + mlModel = new MarkLineModel( + markLineOpt, this, ecModel, opt + ); + } + else { + mlModel.mergeOption(markLineOpt, ecModel, true); + } + seriesModel.markLineModel = mlModel; + }, this); + } + }, + + defaultOption: { + zlevel: 0, + z: 5, + // 标线起始和结束的symbol介绍类型,如果都一样,可以直接传string + symbol: ['circle', 'arrow'], + // 标线起始和结束的symbol大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2 + symbolSize: [8, 16], + // 标线起始和结束的symbol旋转控制 + //symbolRotate: null, + //smooth: false, + precision: 2, + tooltip: { + trigger: 'item' + }, + label: { + normal: { + show: true, + // 标签文本格式器,同Tooltip.formatter,不支持回调 + // formatter: null, + // 可选为 'start'|'end'|'left'|'right'|'top'|'bottom' + position: 'end' + // 默认使用全局文本样式,详见TEXTSTYLE + // textStyle: null + }, + emphasis: { + show: true + } + }, + lineStyle: { + normal: { + // color + // width + type: 'dashed' + // shadowColor: 'rgba(0,0,0,0)', + // shadowBlur: 0, + // shadowOffsetX: 0, + // shadowOffsetY: 0 + }, + emphasis: { + width: 3 + } + }, + animationEasing: 'linear' + } + }); + + module.exports = MarkLineModel; + + +/***/ }, +/* 321 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var List = __webpack_require__(94); + var formatUtil = __webpack_require__(6); + var modelUtil = __webpack_require__(5); + var numberUtil = __webpack_require__(7); + + var addCommas = formatUtil.addCommas; + var encodeHTML = formatUtil.encodeHTML; + + var markerHelper = __webpack_require__(318); + + var LineDraw = __webpack_require__(194); + + var markLineTransform = function (seriesModel, coordSys, mlModel, item) { + var data = seriesModel.getData(); + // Special type markLine like 'min', 'max', 'average' + var mlType = item.type; + + if (!zrUtil.isArray(item) + && (mlType === 'min' || mlType === 'max' || mlType === 'average') + ) { + var axisInfo = markerHelper.getAxisInfo(item, data, coordSys, seriesModel); + + var baseAxisKey = axisInfo.baseAxis.dim + 'Axis'; + var valueAxisKey = axisInfo.valueAxis.dim + 'Axis'; + var baseScaleExtent = axisInfo.baseAxis.scale.getExtent(); + + var mlFrom = zrUtil.clone(item); + var mlTo = {}; + + mlFrom.type = null; + + // FIXME Polar should use circle + mlFrom[baseAxisKey] = baseScaleExtent[0]; + mlTo[baseAxisKey] = baseScaleExtent[1]; + + var value = markerHelper.numCalculate(data, axisInfo.valueDataDim, mlType); + + // Round if axis is cateogry + value = axisInfo.valueAxis.coordToData(axisInfo.valueAxis.dataToCoord(value)); + + var precision = mlModel.get('precision'); + if (precision >= 0) { + value = +value.toFixed(precision); + } + + mlFrom[valueAxisKey] = mlTo[valueAxisKey] = value; + + item = [mlFrom, mlTo, { // Extra option for tooltip and label + type: mlType, + valueIndex: item.valueIndex, + // Force to use the value of calculated value. + value: value + }]; + } + + item = [ + markerHelper.dataTransform(seriesModel, item[0]), + markerHelper.dataTransform(seriesModel, item[1]), + zrUtil.extend({}, item[2]) + ]; + + // Avoid line data type is extended by from(to) data type + item[2].type = item[2].type || ''; + + // Merge from option and to option into line option + zrUtil.merge(item[2], item[0]); + zrUtil.merge(item[2], item[1]); + + return item; + }; + + function markLineFilter(coordSys, item) { + return markerHelper.dataFilter(coordSys, item[0]) + && markerHelper.dataFilter(coordSys, item[1]); + } + + var markLineFormatMixin = { + formatTooltip: function (dataIndex) { + var data = this._data; + var value = this.getRawValue(dataIndex); + var formattedValue = zrUtil.isArray(value) + ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); + var name = data.getName(dataIndex); + return this.name + '
' + + ((name ? encodeHTML(name) + ' : ' : '') + formattedValue); + }, + + getRawDataArray: function () { + return this.option.data; + }, + + getData: function () { + return this._data; + }, + + setData: function (data) { + this._data = data; + } + }; + + zrUtil.defaults(markLineFormatMixin, modelUtil.dataFormatMixin); + + __webpack_require__(1).extendComponentView({ + + type: 'markLine', + + init: function () { + /** + * Markline grouped by series + * @private + * @type {Object} + */ + this._markLineMap = {}; + }, + + render: function (markLineModel, ecModel, api) { + var lineDrawMap = this._markLineMap; + for (var name in lineDrawMap) { + lineDrawMap[name].__keep = false; + } + + ecModel.eachSeries(function (seriesModel) { + var mlModel = seriesModel.markLineModel; + mlModel && this._renderSeriesML(seriesModel, mlModel, ecModel, api); + }, this); + + for (var name in lineDrawMap) { + if (!lineDrawMap[name].__keep) { + this.group.remove(lineDrawMap[name].group); + } + } + }, + + _renderSeriesML: function (seriesModel, mlModel, ecModel, api) { + var coordSys = seriesModel.coordinateSystem; + var seriesName = seriesModel.name; + var seriesData = seriesModel.getData(); + + var lineDrawMap = this._markLineMap; + var lineDraw = lineDrawMap[seriesName]; + if (!lineDraw) { + lineDraw = lineDrawMap[seriesName] = new LineDraw(); + } + this.group.add(lineDraw.group); + + var mlData = createList(coordSys, seriesModel, mlModel); + var dims = coordSys.dimensions; + + var fromData = mlData.from; + var toData = mlData.to; + var lineData = mlData.line; + + // Line data for tooltip and formatter + zrUtil.extend(mlModel, markLineFormatMixin); + mlModel.setData(lineData); + + var symbolType = mlModel.get('symbol'); + var symbolSize = mlModel.get('symbolSize'); + if (!zrUtil.isArray(symbolType)) { + symbolType = [symbolType, symbolType]; + } + if (typeof symbolSize === 'number') { + symbolSize = [symbolSize, symbolSize]; + } + + // Update visual and layout of from symbol and to symbol + mlData.from.each(function (idx) { + var lineModel = lineData.getItemModel(idx); + var mlType = lineModel.get('type'); + var valueIndex = lineModel.get('valueIndex'); + updateDataVisualAndLayout(fromData, idx, true, mlType, valueIndex); + updateDataVisualAndLayout(toData, idx, false, mlType, valueIndex); + }); + + // Update visual and layout of line + lineData.each(function (idx) { + var lineColor = lineData.getItemModel(idx).get('lineStyle.normal.color'); + lineData.setItemVisual(idx, { + color: lineColor || fromData.getItemVisual(idx, 'color') + }); + lineData.setItemLayout(idx, [ + fromData.getItemLayout(idx), + toData.getItemLayout(idx) + ]); + }); + + lineDraw.updateData(lineData, fromData, toData); + + // Set host model for tooltip + // FIXME + mlData.line.eachItemGraphicEl(function (el, idx) { + el.traverse(function (child) { + child.hostModel = mlModel; + }); + }); + + function updateDataVisualAndLayout(data, idx, isFrom, mlType, valueIndex) { + var itemModel = data.getItemModel(idx); + + var point; + var xPx = itemModel.get('x'); + var yPx = itemModel.get('y'); + if (xPx != null && yPx != null) { + point = [ + numberUtil.parsePercent(xPx, api.getWidth()), + numberUtil.parsePercent(yPx, api.getHeight()) + ]; + } + else { + // Chart like bar may have there own marker positioning logic + if (seriesModel.getMarkerPosition) { + // Use the getMarkerPoisition + point = seriesModel.getMarkerPosition( + data.getValues(data.dimensions, idx) + ); + } + else { + var x = data.get(dims[0], idx); + var y = data.get(dims[1], idx); + point = coordSys.dataToPoint([x, y]); + } + // Expand min, max, average line to the edge of grid + // FIXME Glue code + if (mlType && coordSys.type === 'cartesian2d') { + var mlOnAxis = valueIndex != null + ? coordSys.getAxis(valueIndex === 1 ? 'x' : 'y') + : coordSys.getAxesByScale('ordinal')[0]; + if (mlOnAxis && mlOnAxis.onBand) { + point[mlOnAxis.dim === 'x' ? 0 : 1] = + mlOnAxis.toGlobalCoord(mlOnAxis.getExtent()[isFrom ? 0 : 1]); + } + } + } + + data.setItemLayout(idx, point); + + data.setItemVisual(idx, { + symbolSize: itemModel.get('symbolSize') + || symbolSize[isFrom ? 0 : 1], + symbol: itemModel.get('symbol', true) + || symbolType[isFrom ? 0 : 1], + color: itemModel.get('itemStyle.normal.color') + || seriesData.getVisual('color') + }); + } + + lineDraw.__keep = true; + } + }); + + /** + * @inner + * @param {module:echarts/coord/*} coordSys + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/model/Model} mpModel + */ + function createList(coordSys, seriesModel, mlModel) { + + var coordDimsInfos = zrUtil.map(coordSys.dimensions, function (coordDim) { + var info = seriesModel.getData().getDimensionInfo( + seriesModel.coordDimToDataDim(coordDim)[0] + ); + info.name = coordDim; + return info; + }); + var fromData = new List(coordDimsInfos, mlModel); + var toData = new List(coordDimsInfos, mlModel); + // No dimensions + var lineData = new List([], mlModel); + + if (coordSys) { + var optData = zrUtil.filter( + zrUtil.map(mlModel.get('data'), zrUtil.curry( + markLineTransform, seriesModel, coordSys, mlModel + )), + zrUtil.curry(markLineFilter, coordSys) + ); + fromData.initData( + zrUtil.map(optData, function (item) { return item[0]; }), + null, + markerHelper.dimValueGetter + ); + toData.initData( + zrUtil.map(optData, function (item) { return item[1]; }), + null, + markerHelper.dimValueGetter + ); + lineData.initData( + zrUtil.map(optData, function (item) { return item[2]; }) + ); + + } + return { + from: fromData, + to: toData, + line: lineData + }; + } + + +/***/ }, +/* 322 */, +/* 323 */, +/* 324 */, +/* 325 */, +/* 326 */, +/* 327 */, +/* 328 */, +/* 329 */, +/* 330 */, +/* 331 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(332); + __webpack_require__(334); + + __webpack_require__(336); + __webpack_require__(337); + __webpack_require__(338); + __webpack_require__(339); + __webpack_require__(344); + + +/***/ }, +/* 332 */ +/***/ function(module, exports, __webpack_require__) { - type: 'radial', + - updateCanvasGradient: function (shape, ctx) { - var rect = shape.getBoundingRect(); + var featureManager = __webpack_require__(333); + var zrUtil = __webpack_require__(3); - var width = rect.width; - var height = rect.height; - var min = Math.min(width, height); - // var max = Math.max(width, height); + var ToolboxModel = __webpack_require__(1).extendComponentModel({ - var x = this.x * width + rect.x; - var y = this.y * height + rect.y; - var r = this.r * min; + type: 'toolbox', - var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r); + layoutMode: { + type: 'box', + ignoreSize: true + }, - var colorStops = this.colorStops; - for (var i = 0; i < colorStops.length; i++) { - canvasGradient.addColorStop( - colorStops[i].offset, colorStops[i].color - ); - } + mergeDefaultAndTheme: function (option) { + ToolboxModel.superApply(this, 'mergeDefaultAndTheme', arguments); - this.canvasGradient = canvasGradient; - } - }; + zrUtil.each(this.option.feature, function (featureOpt, featureName) { + var Feature = featureManager.get(featureName); + Feature && zrUtil.merge(featureOpt, Feature.defaultOption); + }); + }, - zrUtil.inherits(RadialGradient, Gradient); + defaultOption: { - return RadialGradient; -}); -define('echarts/util/graphic',['require','zrender/core/util','zrender/tool/path','zrender/graphic/Path','zrender/tool/color','zrender/core/matrix','zrender/core/vector','zrender/graphic/Gradient','zrender/container/Group','zrender/graphic/Image','zrender/graphic/Text','zrender/graphic/shape/Circle','zrender/graphic/shape/Sector','zrender/graphic/shape/Polygon','zrender/graphic/shape/Polyline','zrender/graphic/shape/Rect','zrender/graphic/shape/Line','zrender/graphic/shape/BezierCurve','zrender/graphic/shape/Arc','zrender/graphic/LinearGradient','zrender/graphic/RadialGradient','zrender/core/BoundingRect'],function(require) { + show: true, - + z: 6, - var zrUtil = require('zrender/core/util'); + zlevel: 0, - var pathTool = require('zrender/tool/path'); - var round = Math.round; - var Path = require('zrender/graphic/Path'); - var colorTool = require('zrender/tool/color'); - var matrix = require('zrender/core/matrix'); - var vector = require('zrender/core/vector'); - var Gradient = require('zrender/graphic/Gradient'); + orient: 'horizontal', - var graphic = {}; + left: 'right', - graphic.Group = require('zrender/container/Group'); + top: 'top', - graphic.Image = require('zrender/graphic/Image'); + // right + // bottom - graphic.Text = require('zrender/graphic/Text'); + backgroundColor: 'transparent', - graphic.Circle = require('zrender/graphic/shape/Circle'); - - graphic.Sector = require('zrender/graphic/shape/Sector'); - - graphic.Polygon = require('zrender/graphic/shape/Polygon'); - - graphic.Polyline = require('zrender/graphic/shape/Polyline'); - - graphic.Rect = require('zrender/graphic/shape/Rect'); - - graphic.Line = require('zrender/graphic/shape/Line'); - - graphic.BezierCurve = require('zrender/graphic/shape/BezierCurve'); - - graphic.Arc = require('zrender/graphic/shape/Arc'); - - graphic.LinearGradient = require('zrender/graphic/LinearGradient'); - - graphic.RadialGradient = require('zrender/graphic/RadialGradient'); - - graphic.BoundingRect = require('zrender/core/BoundingRect'); - - /** - * Extend shape with parameters - */ - graphic.extendShape = function (opts) { - return Path.extend(opts); - }; - - /** - * Extend path - */ - graphic.extendPath = function (pathData, opts) { - return pathTool.extendFromString(pathData, opts); - }; - - /** - * Create a path element from path data string - * @param {string} pathData - * @param {Object} opts - * @param {module:zrender/core/BoundingRect} rect - * @param {string} [layout=cover] 'center' or 'cover' - */ - graphic.makePath = function (pathData, opts, rect, layout) { - var path = pathTool.createFromString(pathData, opts); - var boundingRect = path.getBoundingRect(); - if (rect) { - var aspect = boundingRect.width / boundingRect.height; - - if (layout === 'center') { - // Set rect to center, keep width / height ratio. - var width = rect.height * aspect; - var height; - if (width <= rect.width) { - height = rect.height; - } - else { - width = rect.width; - height = width / aspect; - } - var cx = rect.x + rect.width / 2; - var cy = rect.y + rect.height / 2; - - rect.x = cx - width / 2; - rect.y = cy - height / 2; - rect.width = width; - rect.height = height; - } - - this.resizePath(path, rect); - } - return path; - }; - - graphic.mergePath = pathTool.mergePath, - - /** - * Resize a path to fit the rect - * @param {module:zrender/graphic/Path} path - * @param {Object} rect - */ - graphic.resizePath = function (path, rect) { - if (!path.applyTransform) { - return; - } - - var pathRect = path.getBoundingRect(); - - var m = pathRect.calculateTransform(rect); - - path.applyTransform(m); - }; - - /** - * Sub pixel optimize line for canvas - * - * @param {Object} param - * @param {Object} [param.shape] - * @param {number} [param.shape.x1] - * @param {number} [param.shape.y1] - * @param {number} [param.shape.x2] - * @param {number} [param.shape.y2] - * @param {Object} [param.style] - * @param {number} [param.style.lineWidth] - * @return {Object} Modified param - */ - graphic.subPixelOptimizeLine = function (param) { - var subPixelOptimize = graphic.subPixelOptimize; - var shape = param.shape; - var lineWidth = param.style.lineWidth; - - if (round(shape.x1 * 2) === round(shape.x2 * 2)) { - shape.x1 = shape.x2 = subPixelOptimize(shape.x1, lineWidth, true); - } - if (round(shape.y1 * 2) === round(shape.y2 * 2)) { - shape.y1 = shape.y2 = subPixelOptimize(shape.y1, lineWidth, true); - } - return param; - }; - - /** - * Sub pixel optimize rect for canvas - * - * @param {Object} param - * @param {Object} [param.shape] - * @param {number} [param.shape.x] - * @param {number} [param.shape.y] - * @param {number} [param.shape.width] - * @param {number} [param.shape.height] - * @param {Object} [param.style] - * @param {number} [param.style.lineWidth] - * @return {Object} Modified param - */ - graphic.subPixelOptimizeRect = function (param) { - var subPixelOptimize = graphic.subPixelOptimize; - var shape = param.shape; - var lineWidth = param.style.lineWidth; - var originX = shape.x; - var originY = shape.y; - var originWidth = shape.width; - var originHeight = shape.height; - shape.x = subPixelOptimize(shape.x, lineWidth, true); - shape.y = subPixelOptimize(shape.y, lineWidth, true); - shape.width = Math.max( - subPixelOptimize(originX + originWidth, lineWidth, false) - shape.x, - originWidth === 0 ? 0 : 1 - ); - shape.height = Math.max( - subPixelOptimize(originY + originHeight, lineWidth, false) - shape.y, - originHeight === 0 ? 0 : 1 - ); - return param; - }; - - /** - * Sub pixel optimize for canvas - * - * @param {number} position Coordinate, such as x, y - * @param {number} lineWidth Should be nonnegative integer. - * @param {boolean=} positiveOrNegative Default false (negative). - * @return {number} Optimized position. - */ - graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) { - // Assure that (position + lineWidth / 2) is near integer edge, - // otherwise line will be fuzzy in canvas. - var doubledPosition = round(position * 2); - return (doubledPosition + round(lineWidth)) % 2 === 0 - ? doubledPosition / 2 - : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2; - }; - - /** - * @private - */ - function doSingleEnterHover(el) { - if (el.__isHover) { - return; - } - if (el.__hoverStlDirty) { - var stroke = el.style.stroke; - var fill = el.style.fill; - - // Create hoverStyle on mouseover - var hoverStyle = el.__hoverStl; - hoverStyle.fill = hoverStyle.fill - || (fill instanceof Gradient ? fill : colorTool.lift(fill, -0.1)); - hoverStyle.stroke = hoverStyle.stroke - || (stroke instanceof Gradient ? stroke : colorTool.lift(stroke, -0.1)); - - var normalStyle = {}; - for (var name in hoverStyle) { - if (hoverStyle.hasOwnProperty(name)) { - normalStyle[name] = el.style[name]; - } - } - - el.__normalStl = normalStyle; - - el.__hoverStlDirty = false; - } - el.setStyle(el.__hoverStl); - el.z2 += 1; - - el.__isHover = true; - } - - /** - * @inner - */ - function doSingleLeaveHover(el) { - if (!el.__isHover) { - return; - } - - var normalStl = el.__normalStl; - normalStl && el.setStyle(normalStl); - el.z2 -= 1; - - el.__isHover = false; - } - - /** - * @inner - */ - function doEnterHover(el) { - el.type === 'group' - ? el.traverse(function (child) { - if (child.type !== 'group') { - doSingleEnterHover(child); - } - }) - : doSingleEnterHover(el); - } - - function doLeaveHover(el) { - el.type === 'group' - ? el.traverse(function (child) { - if (child.type !== 'group') { - doSingleLeaveHover(child); - } - }) - : doSingleLeaveHover(el); - } - - /** - * @inner - */ - function setElementHoverStl(el, hoverStl) { - // If element has sepcified hoverStyle, then use it instead of given hoverStyle - // Often used when item group has a label element and it's hoverStyle is different - el.__hoverStl = el.hoverStyle || hoverStl; - el.__hoverStlDirty = true; - } - - /** - * @inner - */ - function onElementMouseOver() { - // Only if element is not in emphasis status - !this.__isEmphasis && doEnterHover(this); - } - - /** - * @inner - */ - function onElementMouseOut() { - // Only if element is not in emphasis status - !this.__isEmphasis && doLeaveHover(this); - } - - /** - * @inner - */ - function enterEmphasis() { - this.__isEmphasis = true; - doEnterHover(this); - } - - /** - * @inner - */ - function leaveEmphasis() { - this.__isEmphasis = false; - doLeaveHover(this); - } - - /** - * Set hover style of element - * @param {module:zrender/Element} el - * @param {Object} [hoverStyle] - */ - graphic.setHoverStyle = function (el, hoverStyle) { - hoverStyle = hoverStyle || {}; - el.type === 'group' - ? el.traverse(function (child) { - if (child.type !== 'group') { - setElementHoverStl(child, hoverStyle); - } - }) - : setElementHoverStl(el, hoverStyle); - // Remove previous bound handlers - el.on('mouseover', onElementMouseOver) - .on('mouseout', onElementMouseOut); - - // Emphasis, normal can be triggered manually - el.on('emphasis', enterEmphasis) - .on('normal', leaveEmphasis); - }; - - /** - * Set text option in the style - * @param {Object} textStyle - * @param {module:echarts/model/Model} labelModel - * @param {string} color - */ - graphic.setText = function (textStyle, labelModel, color) { - var labelPosition = labelModel.getShallow('position') || 'inside'; - var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color; - var textStyleModel = labelModel.getModel('textStyle'); - zrUtil.extend(textStyle, { - textDistance: labelModel.getShallow('distance') || 5, - textFont: textStyleModel.getFont(), - textPosition: labelPosition, - textFill: textStyleModel.getTextColor() || labelColor - }); - }; - - function animateOrSetProps(isUpdate, el, props, animatableModel, cb) { - var postfix = isUpdate ? 'Update' : ''; - var duration = animatableModel - && animatableModel.getShallow('animationDuration' + postfix); - var animationEasing = animatableModel - && animatableModel.getShallow('animationEasing' + postfix); - - animatableModel && animatableModel.getShallow('animation') - ? el.animateTo(props, duration, animationEasing, cb) - : (el.attr(props), cb && cb()); - } - /** - * Update graphic element properties with or without animation according to the configuration in series - * @param {module:zrender/Element} el - * @param {Object} props - * @param {module:echarts/model/Model} [animatableModel] - * @param {Function} cb - */ - graphic.updateProps = zrUtil.curry(animateOrSetProps, true); - - /** - * Init graphic element properties with or without animation according to the configuration in series - * @param {module:zrender/Element} el - * @param {Object} props - * @param {module:echarts/model/Model} [animatableModel] - * @param {Function} cb - */ - graphic.initProps = zrUtil.curry(animateOrSetProps, false); - - /** - * Get transform matrix of target (param target), - * in coordinate of its ancestor (param ancestor) - * - * @param {module:zrender/mixin/Transformable} target - * @param {module:zrender/mixin/Transformable} ancestor - */ - graphic.getTransform = function (target, ancestor) { - var mat = matrix.identity([]); - - while (target && target !== ancestor) { - matrix.mul(mat, target.getLocalTransform(), mat); - target = target.parent; - } - - return mat; - }; - - /** - * Apply transform to an vertex. - * @param {Array.} vertex [x, y] - * @param {Array.} transform Transform matrix: like [1, 0, 0, 1, 0, 0] - * @param {boolean=} invert Whether use invert matrix. - * @return {Array.} [x, y] - */ - graphic.applyTransform = function (vertex, transform, invert) { - if (invert) { - transform = matrix.invert([], transform); - } - return vector.applyTransform([], vertex, transform); - }; - - /** - * @param {string} direction 'left' 'right' 'top' 'bottom' - * @param {Array.} transform Transform matrix: like [1, 0, 0, 1, 0, 0] - * @param {boolean=} invert Whether use invert matrix. - * @return {string} Transformed direction. 'left' 'right' 'top' 'bottom' - */ - graphic.transformDirection = function (direction, transform, invert) { - - // Pick a base, ensure that transform result will not be (0, 0). - var hBase = (transform[4] === 0 || transform[5] === 0 || transform[0] === 0) - ? 1 : Math.abs(2 * transform[4] / transform[0]); - var vBase = (transform[4] === 0 || transform[5] === 0 || transform[2] === 0) - ? 1 : Math.abs(2 * transform[4] / transform[2]); - - var vertex = [ - direction === 'left' ? -hBase : direction === 'right' ? hBase : 0, - direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0 - ]; - - vertex = graphic.applyTransform(vertex, transform, invert); - - return Math.abs(vertex[0]) > Math.abs(vertex[1]) - ? (vertex[0] > 0 ? 'right' : 'left') - : (vertex[1] > 0 ? 'bottom' : 'top'); - }; - - return graphic; -}); -/** - * echarts设备环境识别 - * - * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。 - * @author firede[firede@firede.us] - * @desc thanks zepto. - */ -define('zrender/core/env',[],function () { - var env = {}; - if (typeof navigator === 'undefined') { - // In node - env = { - browser: {}, - os: {}, - node: true, - // Assume canvas is supported - canvasSupported: true - }; - } - else { - env = detect(navigator.userAgent); - } - - return env; - - // Zepto.js - // (c) 2010-2013 Thomas Fuchs - // Zepto.js may be freely distributed under the MIT license. - - function detect(ua) { - var os = {}; - var browser = {}; - var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/); - var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); - var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); - var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); - var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/); - var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/); - var touchpad = webos && ua.match(/TouchPad/); - var kindle = ua.match(/Kindle\/([\d.]+)/); - var silk = ua.match(/Silk\/([\d._]+)/); - var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/); - var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/); - var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/); - var playbook = ua.match(/PlayBook/); - var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/); - var firefox = ua.match(/Firefox\/([\d.]+)/); - var safari = webkit && ua.match(/Mobile\//) && !chrome; - var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome; - var ie = ua.match(/MSIE\s([\d.]+)/) - // IE 11 Trident/7.0; rv:11.0 - || ua.match(/Trident\/.+?rv:(([\d.]+))/); - var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+ - - // Todo: clean this up with a better OS/browser seperation: - // - discern (more) between multiple browsers on android - // - decide if kindle fire in silk mode is android or not - // - Firefox on Android doesn't specify the Android version - // - possibly devide in os, device and browser hashes - - if (browser.webkit = !!webkit) browser.version = webkit[1]; - - if (android) os.android = true, os.version = android[2]; - if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.'); - if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.'); - if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null; - if (webos) os.webos = true, os.version = webos[2]; - if (touchpad) os.touchpad = true; - if (blackberry) os.blackberry = true, os.version = blackberry[2]; - if (bb10) os.bb10 = true, os.version = bb10[2]; - if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2]; - if (playbook) browser.playbook = true; - if (kindle) os.kindle = true, os.version = kindle[1]; - if (silk) browser.silk = true, browser.version = silk[1]; - if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true; - if (chrome) browser.chrome = true, browser.version = chrome[1]; - if (firefox) browser.firefox = true, browser.version = firefox[1]; - if (ie) browser.ie = true, browser.version = ie[1]; - if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true; - if (webview) browser.webview = true; - if (ie) browser.ie = true, browser.version = ie[1]; - if (edge) browser.edge = true, browser.version = edge[1]; - - os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) || - (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/))); - 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/)))); - - return { - browser: browser, - os: os, - node: false, - // 原生canvas支持,改极端点了 - // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9) - canvasSupported : document.createElement('canvas').getContext ? true : false, - // @see - // works on most browsers - // IE10/11 does not support touch event, and MS Edge supports them but not by - // default, so we dont check navigator.maxTouchPoints for them here. - touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge, - // . - pointerEventsSupported: 'onpointerdown' in window - // Firefox supports pointer but not by default, - // only MS browsers are reliable on pointer events currently. - && (browser.edge || (browser.ie && browser.version >= 10)) - }; - } -}); -/** - * 事件辅助类 - * @module zrender/core/event - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - */ -define('zrender/core/event',['require','../mixin/Eventful'],function(require) { - - - - var Eventful = require('../mixin/Eventful'); - - var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener; - - function getBoundingClientRect(el) { - // BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect - return el.getBoundingClientRect ? el.getBoundingClientRect() : { left: 0, top: 0}; - } - /** - * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标 - */ - function normalizeEvent(el, e) { - - e = e || window.event; - - if (e.zrX != null) { - return e; - } - - var eventType = e.type; - var isTouch = eventType && eventType.indexOf('touch') >= 0; - - if (!isTouch) { - var box = getBoundingClientRect(el); - e.zrX = e.clientX - box.left; - e.zrY = e.clientY - box.top; - e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3; - } - else { - var touch = eventType != 'touchend' - ? e.targetTouches[0] - : e.changedTouches[0]; - if (touch) { - var rBounding = getBoundingClientRect(el); - // touch事件坐标是全屏的~ - e.zrX = touch.clientX - rBounding.left; - e.zrY = touch.clientY - rBounding.top; - } - } - - return e; - } - - function addEventListener(el, name, handler) { - if (isDomLevel2) { - el.addEventListener(name, handler); - } - else { - el.attachEvent('on' + name, handler); - } - } - - function removeEventListener(el, name, handler) { - if (isDomLevel2) { - el.removeEventListener(name, handler); - } - else { - el.detachEvent('on' + name, handler); - } - } - - /** - * 停止冒泡和阻止默认行为 - * @memberOf module:zrender/core/event - * @method - * @param {Event} e : event对象 - */ - var stop = isDomLevel2 - ? function (e) { - e.preventDefault(); - e.stopPropagation(); - e.cancelBubble = true; - } - : function (e) { - e.returnValue = false; - e.cancelBubble = true; - }; - - return { - normalizeEvent: normalizeEvent, - addEventListener: addEventListener, - removeEventListener: removeEventListener, - - stop: stop, - // 做向上兼容 - Dispatcher: Eventful - }; -}); + borderColor: '#ccc', -// TODO Draggable for group -// FIXME Draggable on element which has parent rotation or scale -define('zrender/mixin/Draggable',['require'],function (require) { - function Draggable() { + borderWidth: 0, - this.on('mousedown', this._dragStart, this); - this.on('mousemove', this._drag, this); - this.on('mouseup', this._dragEnd, this); - this.on('globalout', this._dragEnd, this); - // this._dropTarget = null; - // this._draggingTarget = null; + padding: 5, - // this._x = 0; - // this._y = 0; - } + itemSize: 15, - Draggable.prototype = { + itemGap: 8, - constructor: Draggable, + showTitle: true, - _dragStart: function (e) { - var draggingTarget = e.target; - if (draggingTarget && draggingTarget.draggable) { - this._draggingTarget = draggingTarget; - draggingTarget.dragging = true; - this._x = e.offsetX; - this._y = e.offsetY; + iconStyle: { + normal: { + borderColor: '#666', + color: 'none' + }, + emphasis: { + borderColor: '#3E98C5' + } + } + // textStyle: {}, - this._dispatchProxy(draggingTarget, 'dragstart', e.event); - } - }, + // feature + } + }); - _drag: function (e) { - var draggingTarget = this._draggingTarget; - if (draggingTarget) { + module.exports = ToolboxModel; - var x = e.offsetX; - var y = e.offsetY; - var dx = x - this._x; - var dy = y - this._y; - this._x = x; - this._y = y; +/***/ }, +/* 333 */ +/***/ function(module, exports) { - draggingTarget.drift(dx, dy, e); - this._dispatchProxy(draggingTarget, 'drag', e.event); + 'use strict'; - var dropTarget = this.findHover(x, y, draggingTarget); - var lastDropTarget = this._dropTarget; - this._dropTarget = dropTarget; - if (draggingTarget !== dropTarget) { - if (lastDropTarget && dropTarget !== lastDropTarget) { - this._dispatchProxy(lastDropTarget, 'dragleave', e.event); - } - if (dropTarget && dropTarget !== lastDropTarget) { - this._dispatchProxy(dropTarget, 'dragenter', e.event); - } - } - } - }, + var features = {}; - _dragEnd: function (e) { - var draggingTarget = this._draggingTarget; + module.exports = { + register: function (name, ctor) { + features[name] = ctor; + }, - if (draggingTarget) { - draggingTarget.dragging = false; - } + get: function (name) { + return features[name]; + } + }; - this._dispatchProxy(draggingTarget, 'dragend', e.event); - if (this._dropTarget) { - this._dispatchProxy(this._dropTarget, 'drop', e.event); - } +/***/ }, +/* 334 */ +/***/ function(module, exports, __webpack_require__) { - this._draggingTarget = null; - this._dropTarget = null; - } + /* WEBPACK VAR INJECTION */(function(process) { - }; + var featureManager = __webpack_require__(333); + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var Model = __webpack_require__(8); + var DataDiffer = __webpack_require__(95); + var listComponentHelper = __webpack_require__(266); + var textContain = __webpack_require__(14); - return Draggable; -}); -/** - * Only implements needed gestures for mobile. - */ -define('zrender/core/GestureMgr',['require'],function(require) { - - - - var GestureMgr = function () { - - /** - * @private - * @type {Array.} - */ - this._track = []; - }; - - GestureMgr.prototype = { - - constructor: GestureMgr, - - recognize: function (event, target) { - this._doTrack(event, target); - return this._recognize(event); - }, - - clear: function () { - this._track.length = 0; - return this; - }, - - _doTrack: function (event, target) { - var touches = event.touches; - - if (!touches) { - return; - } - - var trackItem = { - points: [], - touches: [], - target: target, - event: event - }; - - for (var i = 0, len = touches.length; i < len; i++) { - var touch = touches[i]; - trackItem.points.push([touch.clientX, touch.clientY]); - trackItem.touches.push(touch); - } - - this._track.push(trackItem); - }, - - _recognize: function (event) { - for (var eventName in recognizers) { - if (recognizers.hasOwnProperty(eventName)) { - var gestureInfo = recognizers[eventName](this._track, event); - if (gestureInfo) { - return gestureInfo; - } - } - } - } - }; - - function dist(pointPair) { - var dx = pointPair[1][0] - pointPair[0][0]; - var dy = pointPair[1][1] - pointPair[0][1]; - - return Math.sqrt(dx * dx + dy * dy); - } - - function center(pointPair) { - return [ - (pointPair[0][0] + pointPair[1][0]) / 2, - (pointPair[0][1] + pointPair[1][1]) / 2 - ]; - } - - var recognizers = { - - pinch: function (track, event) { - var trackLen = track.length; - - if (!trackLen) { - return; - } - - var pinchEnd = (track[trackLen - 1] || {}).points; - var pinchPre = (track[trackLen - 2] || {}).points || pinchEnd; - - if (pinchPre - && pinchPre.length > 1 - && pinchEnd - && pinchEnd.length > 1 - ) { - var pinchScale = dist(pinchEnd) / dist(pinchPre); - !isFinite(pinchScale) && (pinchScale = 1); - - event.pinchScale = pinchScale; - - var pinchCenter = center(pinchEnd); - event.pinchX = pinchCenter[0]; - event.pinchY = pinchCenter[1]; - - return { - type: 'pinch', - target: track[0].target, - event: event - }; - } - } - - // Only pinch currently. - }; - - return GestureMgr; -}); + module.exports = __webpack_require__(1).extendComponentView({ + + type: 'toolbox', + + render: function (toolboxModel, ecModel, api) { + var group = this.group; + group.removeAll(); + + if (!toolboxModel.get('show')) { + return; + } + + var itemSize = +toolboxModel.get('itemSize'); + var featureOpts = toolboxModel.get('feature') || {}; + var features = this._features || (this._features = {}); + + var featureNames = []; + zrUtil.each(featureOpts, function (opt, name) { + featureNames.push(name); + }); + + (new DataDiffer(this._featureNames || [], featureNames)) + .add(process) + .update(process) + .remove(zrUtil.curry(process, null)) + .execute(); + + // Keep for diff. + this._featureNames = featureNames; + + function process(newIndex, oldIndex) { + var featureName = featureNames[newIndex]; + var oldName = featureNames[oldIndex]; + var featureOpt = featureOpts[featureName]; + var featureModel = new Model(featureOpt, toolboxModel, toolboxModel.ecModel); + var feature; + + if (featureName && !oldName) { // Create + if (isUserFeatureName(featureName)) { + feature = { + model: featureModel, + onclick: featureModel.option.onclick, + featureName: featureName + }; + } + else { + var Feature = featureManager.get(featureName); + if (!Feature) { + return; + } + feature = new Feature(featureModel); + } + features[featureName] = feature; + } + else { + feature = features[oldName]; + // If feature does not exsit. + if (!feature) { + return; + } + feature.model = featureModel; + } + + if (!featureName && oldName) { + feature.dispose && feature.dispose(ecModel, api); + return; + } + + if (!featureModel.get('show') || feature.unusable) { + feature.remove && feature.remove(ecModel, api); + return; + } + + createIconPaths(featureModel, feature, featureName); + + featureModel.setIconStatus = function (iconName, status) { + var option = this.option; + var iconPaths = this.iconPaths; + option.iconStatus = option.iconStatus || {}; + option.iconStatus[iconName] = status; + // FIXME + iconPaths[iconName] && iconPaths[iconName].trigger(status); + }; + + if (feature.render) { + feature.render(featureModel, ecModel, api); + } + } + + function createIconPaths(featureModel, feature, featureName) { + var iconStyleModel = featureModel.getModel('iconStyle'); + + // If one feature has mutiple icon. they are orginaized as + // { + // icon: { + // foo: '', + // bar: '' + // }, + // title: { + // foo: '', + // bar: '' + // } + // } + var icons = feature.getIcons ? feature.getIcons() : featureModel.get('icon'); + var titles = featureModel.get('title') || {}; + if (typeof icons === 'string') { + var icon = icons; + var title = titles; + icons = {}; + titles = {}; + icons[featureName] = icon; + titles[featureName] = title; + } + var iconPaths = featureModel.iconPaths = {}; + zrUtil.each(icons, function (icon, iconName) { + var normalStyle = iconStyleModel.getModel('normal').getItemStyle(); + var hoverStyle = iconStyleModel.getModel('emphasis').getItemStyle(); + + var style = { + x: -itemSize / 2, + y: -itemSize / 2, + width: itemSize, + height: itemSize + }; + var path = icon.indexOf('image://') === 0 + ? ( + style.image = icon.slice(8), + new graphic.Image({style: style}) + ) + : graphic.makePath( + icon.replace('path://', ''), + { + style: normalStyle, + hoverStyle: hoverStyle, + rectHover: true + }, + style, + 'center' + ); + + graphic.setHoverStyle(path); + + if (toolboxModel.get('showTitle')) { + path.__title = titles[iconName]; + path.on('mouseover', function () { + path.setStyle({ + text: titles[iconName], + textPosition: hoverStyle.textPosition || 'bottom', + textFill: hoverStyle.fill || hoverStyle.stroke || '#000', + textAlign: hoverStyle.textAlign || 'center' + }); + }) + .on('mouseout', function () { + path.setStyle({ + textFill: null + }); + }); + } + path.trigger(featureModel.get('iconStatus.' + iconName) || 'normal'); + + group.add(path); + path.on('click', zrUtil.bind( + feature.onclick, feature, ecModel, api, iconName + )); + + iconPaths[iconName] = path; + }); + } + + listComponentHelper.layout(group, toolboxModel, api); + // Render background after group is layout + // FIXME + listComponentHelper.addBackground(group, toolboxModel); + + // Adjust icon title positions to avoid them out of screen + group.eachChild(function (icon) { + var titleText = icon.__title; + var hoverStyle = icon.hoverStyle; + // May be background element + if (hoverStyle && titleText) { + var rect = textContain.getBoundingRect( + titleText, hoverStyle.font + ); + var offsetX = icon.position[0] + group.position[0]; + var offsetY = icon.position[1] + group.position[1] + itemSize; + + var needPutOnTop = false; + if (offsetY + rect.height > api.getHeight()) { + hoverStyle.textPosition = 'top'; + needPutOnTop = true; + } + var topOffset = needPutOnTop ? (-5 - rect.height) : (itemSize + 8); + if (offsetX + rect.width / 2 > api.getWidth()) { + hoverStyle.textPosition = ['100%', topOffset]; + hoverStyle.textAlign = 'right'; + } + else if (offsetX - rect.width / 2 < 0) { + hoverStyle.textPosition = [0, topOffset]; + hoverStyle.textAlign = 'left'; + } + } + }); + }, + + remove: function (ecModel, api) { + zrUtil.each(this._features, function (feature) { + feature.remove && feature.remove(ecModel, api); + }); + this.group.removeAll(); + }, + + dispose: function (ecModel, api) { + zrUtil.each(this._features, function (feature) { + feature.dispose && feature.dispose(ecModel, api); + }); + } + }); + + function isUserFeatureName(featureName) { + return featureName.indexOf('my') === 0; + } + + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(335))) + +/***/ }, +/* 335 */ +/***/ function(module, exports) { + + // shim for using process in browser + + var process = module.exports = {}; + var queue = []; + var draining = false; + var currentQueue; + var queueIndex = -1; + + function cleanUpNextTick() { + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } + } + + function drainQueue() { + if (draining) { + return; + } + var timeout = setTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + clearTimeout(timeout); + } + + process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + setTimeout(drainQueue, 0); + } + }; + + // v8 likes predictible objects + function Item(fun, array) { + this.fun = fun; + this.array = array; + } + Item.prototype.run = function () { + this.fun.apply(null, this.array); + }; + process.title = 'browser'; + process.browser = true; + process.env = {}; + process.argv = []; + process.version = ''; // empty string to avoid regexp issues + process.versions = {}; + + function noop() {} + + process.on = noop; + process.addListener = noop; + process.once = noop; + process.off = noop; + process.removeListener = noop; + process.removeAllListeners = noop; + process.emit = noop; + + process.binding = function (name) { + throw new Error('process.binding is not supported'); + }; + + process.cwd = function () { return '/' }; + process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); + }; + process.umask = function() { return 0; }; + + +/***/ }, +/* 336 */ +/***/ function(module, exports, __webpack_require__) { + + + + var env = __webpack_require__(78); + + function SaveAsImage (model) { + this.model = model; + } + + SaveAsImage.defaultOption = { + show: true, + icon: 'M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0', + title: '保存为图片', + type: 'png', + // Default use option.backgroundColor + // backgroundColor: '#fff', + name: '', + excludeComponents: ['toolbox'], + pixelRatio: 1, + lang: ['右键另存为图片'] + }; + + SaveAsImage.prototype.unusable = !env.canvasSupported; + + var proto = SaveAsImage.prototype; + + proto.onclick = function (ecModel, api) { + var model = this.model; + var title = model.get('name') || ecModel.get('title.0.text') || 'echarts'; + var $a = document.createElement('a'); + var type = model.get('type', true) || 'png'; + $a.download = title + '.' + type; + $a.target = '_blank'; + var url = api.getConnectedDataURL({ + type: type, + backgroundColor: model.get('backgroundColor', true) + || ecModel.get('backgroundColor') || '#fff', + excludeComponents: model.get('excludeComponents'), + pixelRatio: model.get('pixelRatio') + }); + $a.href = url; + // Chrome and Firefox + if (typeof MouseEvent === 'function') { + var evt = new MouseEvent('click', { + view: window, + bubbles: true, + cancelable: false + }); + $a.dispatchEvent(evt); + } + // IE + else { + var lang = model.get('lang'); + var html = '' + + '' + + '' + + ''; + var tab = window.open(); + tab.document.write(html); + } + }; + + __webpack_require__(333).register( + 'saveAsImage', SaveAsImage + ); + + module.exports = SaveAsImage; + + +/***/ }, +/* 337 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + + function MagicType(model) { + this.model = model; + } + + MagicType.defaultOption = { + show: true, + type: [], + // Icon group + icon: { + line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4', + bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7', + stack: 'M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z', // jshint ignore:line + tiled: 'M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z' + }, + title: { + line: '切换为折线图', + bar: '切换为柱状图', + stack: '切换为堆叠', + tiled: '切换为平铺' + }, + option: {}, + seriesIndex: {} + }; + + var proto = MagicType.prototype; + + proto.getIcons = function () { + var model = this.model; + var availableIcons = model.get('icon'); + var icons = {}; + zrUtil.each(model.get('type'), function (type) { + if (availableIcons[type]) { + icons[type] = availableIcons[type]; + } + }); + return icons; + }; + + var seriesOptGenreator = { + 'line': function (seriesType, seriesId, seriesModel, model) { + if (seriesType === 'bar') { + return zrUtil.merge({ + id: seriesId, + type: 'line', + // Preserve data related option + data: seriesModel.get('data'), + stack: seriesModel.get('stack'), + markPoint: seriesModel.get('markPoint'), + markLine: seriesModel.get('markLine') + }, model.get('option.line')); + } + }, + 'bar': function (seriesType, seriesId, seriesModel, model) { + if (seriesType === 'line') { + return zrUtil.merge({ + id: seriesId, + type: 'bar', + // Preserve data related option + data: seriesModel.get('data'), + stack: seriesModel.get('stack'), + markPoint: seriesModel.get('markPoint'), + markLine: seriesModel.get('markLine') + }, model.get('option.bar')); + } + }, + 'stack': function (seriesType, seriesId, seriesModel, model) { + if (seriesType === 'line' || seriesType === 'bar') { + return { + id: seriesId, + stack: '__ec_magicType_stack__' + }; + } + }, + 'tiled': function (seriesType, seriesId, seriesModel, model) { + if (seriesType === 'line' || seriesType === 'bar') { + return { + id: seriesId, + stack: '' + }; + } + } + }; + + var radioTypes = [ + ['line', 'bar'], + ['stack', 'tiled'] + ]; + + proto.onclick = function (ecModel, api, type) { + var model = this.model; + var seriesIndex = model.get('seriesIndex.' + type); + // Not supported magicType + if (!seriesOptGenreator[type]) { + return; + } + var newOption = { + series: [] + }; + var generateNewSeriesTypes = function (seriesModel) { + var seriesType = seriesModel.subType; + var seriesId = seriesModel.id; + var newSeriesOpt = seriesOptGenreator[type]( + seriesType, seriesId, seriesModel, model + ); + if (newSeriesOpt) { + // PENDING If merge original option? + zrUtil.defaults(newSeriesOpt, seriesModel.option); + newOption.series.push(newSeriesOpt); + } + }; + + zrUtil.each(radioTypes, function (radio) { + if (zrUtil.indexOf(radio, type) >= 0) { + zrUtil.each(radio, function (item) { + model.setIconStatus(item, 'normal'); + }); + } + }); + + model.setIconStatus(type, 'emphasis'); + + ecModel.eachComponent( + { + mainType: 'series', + seriesIndex: seriesIndex + }, generateNewSeriesTypes + ); + api.dispatchAction({ + type: 'changeMagicType', + currentType: type, + newOption: newOption + }); + }; + + var echarts = __webpack_require__(1); + echarts.registerAction({ + type: 'changeMagicType', + event: 'magicTypeChanged', + update: 'prepareAndUpdate' + }, function (payload, ecModel) { + ecModel.mergeOption(payload.newOption); + }); + + __webpack_require__(333).register('magicType', MagicType); + + module.exports = MagicType; + + +/***/ }, +/* 338 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/component/toolbox/feature/DataView + */ + + + + var zrUtil = __webpack_require__(3); + var eventTool = __webpack_require__(80); + + + var BLOCK_SPLITER = new Array(60).join('-'); + var ITEM_SPLITER = '\t'; + /** + * Group series into two types + * 1. on category axis, like line, bar + * 2. others, like scatter, pie + * @param {module:echarts/model/Global} ecModel + * @return {Object} + * @inner + */ + function groupSeries(ecModel) { + var seriesGroupByCategoryAxis = {}; + var otherSeries = []; + var meta = []; + ecModel.eachRawSeries(function (seriesModel) { + var coordSys = seriesModel.coordinateSystem; + + if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) { + var baseAxis = coordSys.getBaseAxis(); + if (baseAxis.type === 'category') { + var key = baseAxis.dim + '_' + baseAxis.index; + if (!seriesGroupByCategoryAxis[key]) { + seriesGroupByCategoryAxis[key] = { + categoryAxis: baseAxis, + valueAxis: coordSys.getOtherAxis(baseAxis), + series: [] + }; + meta.push({ + axisDim: baseAxis.dim, + axisIndex: baseAxis.index + }); + } + seriesGroupByCategoryAxis[key].series.push(seriesModel); + } + else { + otherSeries.push(seriesModel); + } + } + else { + otherSeries.push(seriesModel); + } + }); + + return { + seriesGroupByCategoryAxis: seriesGroupByCategoryAxis, + other: otherSeries, + meta: meta + }; + } + + /** + * Assemble content of series on cateogory axis + * @param {Array.} series + * @return {string} + * @inner + */ + function assembleSeriesWithCategoryAxis(series) { + var tables = []; + zrUtil.each(series, function (group, key) { + var categoryAxis = group.categoryAxis; + var valueAxis = group.valueAxis; + var valueAxisDim = valueAxis.dim; + + var headers = [' '].concat(zrUtil.map(group.series, function (series) { + return series.name; + })); + var columns = [categoryAxis.model.getCategories()]; + zrUtil.each(group.series, function (series) { + columns.push(series.getRawData().mapArray(valueAxisDim, function (val) { + return val; + })); + }); + // Assemble table content + var lines = [headers.join(ITEM_SPLITER)]; + for (var i = 0; i < columns[0].length; i++) { + var items = []; + for (var j = 0; j < columns.length; j++) { + items.push(columns[j][i]); + } + lines.push(items.join(ITEM_SPLITER)); + } + tables.push(lines.join('\n')); + }); + return tables.join('\n\n' + BLOCK_SPLITER + '\n\n'); + } + + /** + * Assemble content of other series + * @param {Array.} series + * @return {string} + * @inner + */ + function assembleOtherSeries(series) { + return zrUtil.map(series, function (series) { + var data = series.getRawData(); + var lines = [series.name]; + var vals = []; + data.each(data.dimensions, function () { + var argLen = arguments.length; + var dataIndex = arguments[argLen - 1]; + var name = data.getName(dataIndex); + for (var i = 0; i < argLen - 1; i++) { + vals[i] = arguments[i]; + } + lines.push((name ? (name + ITEM_SPLITER) : '') + vals.join(ITEM_SPLITER)); + }); + return lines.join('\n'); + }).join('\n\n' + BLOCK_SPLITER + '\n\n'); + } + + /** + * @param {module:echarts/model/Global} + * @return {string} + * @inner + */ + function getContentFromModel(ecModel) { + + var result = groupSeries(ecModel); + + return { + value: zrUtil.filter([ + assembleSeriesWithCategoryAxis(result.seriesGroupByCategoryAxis), + assembleOtherSeries(result.other) + ], function (str) { + return str.replace(/[\n\t\s]/g, ''); + }).join('\n\n' + BLOCK_SPLITER + '\n\n'), + + meta: result.meta + }; + } + + + function trim(str) { + return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); + } + /** + * If a block is tsv format + */ + function isTSVFormat(block) { + // Simple method to find out if a block is tsv format + var firstLine = block.slice(0, block.indexOf('\n')); + if (firstLine.indexOf(ITEM_SPLITER) >= 0) { + return true; + } + } + + var itemSplitRegex = new RegExp('[' + ITEM_SPLITER + ']+', 'g'); + /** + * @param {string} tsv + * @return {Array.} + */ + function parseTSVContents(tsv) { + var tsvLines = tsv.split(/\n+/g); + var headers = trim(tsvLines.shift()).split(itemSplitRegex); + + var categories = []; + var series = zrUtil.map(headers, function (header) { + return { + name: header, + data: [] + }; + }); + for (var i = 0; i < tsvLines.length; i++) { + var items = trim(tsvLines[i]).split(itemSplitRegex); + categories.push(items.shift()); + for (var j = 0; j < items.length; j++) { + series[j] && (series[j].data[i] = items[j]); + } + } + return { + series: series, + categories: categories + }; + } + + /** + * @param {string} str + * @return {Array.} + * @inner + */ + function parseListContents(str) { + var lines = str.split(/\n+/g); + var seriesName = trim(lines.shift()); + + var data = []; + for (var i = 0; i < lines.length; i++) { + var items = trim(lines[i]).split(itemSplitRegex); + var name = ''; + var value; + var hasName = false; + if (isNaN(items[0])) { // First item is name + hasName = true; + name = items[0]; + items = items.slice(1); + data[i] = { + name: name, + value: [] + }; + value = data[i].value; + } + else { + value = data[i] = []; + } + for (var j = 0; j < items.length; j++) { + value.push(+items[j]); + } + if (value.length === 1) { + hasName ? (data[i].value = value[0]) : (data[i] = value[0]); + } + } + + return { + name: seriesName, + data: data + }; + } + + /** + * @param {string} str + * @param {Array.} blockMetaList + * @return {Object} + * @inner + */ + function parseContents(str, blockMetaList) { + var blocks = str.split(new RegExp('\n*' + BLOCK_SPLITER + '\n*', 'g')); + var newOption = { + series: [] + }; + zrUtil.each(blocks, function (block, idx) { + if (isTSVFormat(block)) { + var result = parseTSVContents(block); + var blockMeta = blockMetaList[idx]; + var axisKey = blockMeta.axisDim + 'Axis'; + + if (blockMeta) { + newOption[axisKey] = newOption[axisKey] || []; + newOption[axisKey][blockMeta.axisIndex] = { + data: result.categories + }; + newOption.series = newOption.series.concat(result.series); + } + } + else { + var result = parseListContents(block); + newOption.series.push(result); + } + }); + return newOption; + } + + /** + * @alias {module:echarts/component/toolbox/feature/DataView} + * @constructor + * @param {module:echarts/model/Model} model + */ + function DataView(model) { + + this._dom = null; + + this.model = model; + } + + DataView.defaultOption = { + show: true, + readOnly: false, + icon: 'M17.5,17.3H33 M17.5,17.3H33 M45.4,29.5h-28 M11.5,2v56H51V14.8L38.4,2H11.5z M38.4,2.2v12.7H51 M45.4,41.7h-28', + title: '数据视图', + lang: ['数据视图', '关闭', '刷新'], + backgroundColor: '#fff', + textColor: '#000', + textareaColor: '#fff', + textareaBorderColor: '#333', + buttonColor: '#c23531', + buttonTextColor: '#fff' + }; + + DataView.prototype.onclick = function (ecModel, api) { + var container = api.getDom(); + var model = this.model; + if (this._dom) { + container.removeChild(this._dom); + } + var root = document.createElement('div'); + root.style.cssText = 'position:absolute;left:5px;top:5px;bottom:5px;right:5px;'; + root.style.backgroundColor = model.get('backgroundColor') || '#fff'; + + // Create elements + var header = document.createElement('h4'); + var lang = model.get('lang') || []; + header.innerHTML = lang[0] || model.get('title'); + header.style.cssText = 'margin: 10px 20px;'; + header.style.color = model.get('textColor'); + + var textarea = document.createElement('textarea'); + // Textarea style + textarea.style.cssText = 'display:block;width:100%;font-size:14px;line-height:1.6rem;font-family:Monaco,Consolas,Courier new,monospace'; + textarea.readOnly = model.get('readOnly'); + textarea.style.color = model.get('textColor'); + textarea.style.borderColor = model.get('textareaBorderColor'); + textarea.style.backgroundColor = model.get('textareaColor'); + + var result = getContentFromModel(ecModel); + textarea.value = result.value; + var blockMetaList = result.meta; + + var buttonContainer = document.createElement('div'); + buttonContainer.style.cssText = 'position:absolute;bottom:0;left:0;right:0;'; + + var buttonStyle = 'float:right;margin-right:20px;border:none;' + + 'cursor:pointer;padding:2px 5px;font-size:12px;border-radius:3px'; + var closeButton = document.createElement('div'); + var refreshButton = document.createElement('div'); + + buttonStyle += ';background-color:' + model.get('buttonColor'); + buttonStyle += ';color:' + model.get('buttonTextColor'); + + var self = this; + + function close() { + container.removeChild(root); + self._dom = null; + } + eventTool.addEventListener(closeButton, 'click', close); + + eventTool.addEventListener(refreshButton, 'click', function () { + var newOption; + try { + newOption = parseContents(textarea.value, blockMetaList); + } + catch (e) { + close(); + throw new Error('Data view format error ' + e); + } + api.dispatchAction({ + type: 'changeDataView', + newOption: newOption + }); + + close(); + }); + + closeButton.innerHTML = lang[1]; + refreshButton.innerHTML = lang[2]; + refreshButton.style.cssText = buttonStyle; + closeButton.style.cssText = buttonStyle; + + buttonContainer.appendChild(refreshButton); + buttonContainer.appendChild(closeButton); + + // http://stackoverflow.com/questions/6637341/use-tab-to-indent-in-textarea + eventTool.addEventListener(textarea, 'keydown', function (e) { + if ((e.keyCode || e.which) === 9) { + // get caret position/selection + var val = this.value; + var start = this.selectionStart; + var end = this.selectionEnd; + + // set textarea value to: text before caret + tab + text after caret + this.value = val.substring(0, start) + ITEM_SPLITER + val.substring(end); + + // put caret at right position again + this.selectionStart = this.selectionEnd = start + 1; + + // prevent the focus lose + eventTool.stop(e); + } + }); + + root.appendChild(header); + root.appendChild(textarea); + root.appendChild(buttonContainer); + + textarea.style.height = (container.clientHeight - 80) + 'px'; + + container.appendChild(root); + this._dom = root; + }; + + DataView.prototype.remove = function (ecModel, api) { + this._dom && api.getDom().removeChild(this._dom); + }; + + DataView.prototype.dispose = function (ecModel, api) { + this.remove(ecModel, api); + }; + + /** + * @inner + */ + function tryMergeDataOption(newData, originalData) { + return zrUtil.map(newData, function (newVal, idx) { + var original = originalData && originalData[idx]; + if (zrUtil.isObject(original) && !zrUtil.isArray(original)) { + if (zrUtil.isObject(newVal) && !zrUtil.isArray(newVal)) { + newVal = newVal.value; + } + // Original data has option + return zrUtil.defaults({ + value: newVal + }, original); + } + else { + return newVal; + } + }); + } + + __webpack_require__(333).register('dataView', DataView); + + __webpack_require__(1).registerAction({ + type: 'changeDataView', + event: 'dataViewChanged', + update: 'prepareAndUpdate' + }, function (payload, ecModel) { + var newSeriesOptList = []; + zrUtil.each(payload.newOption.series, function (seriesOpt) { + var seriesModel = ecModel.getSeriesByName(seriesOpt.name)[0]; + if (!seriesModel) { + // New created series + // Geuss the series type + newSeriesOptList.push(zrUtil.extend({ + // Default is scatter + type: 'scatter' + }, seriesOpt)); + } + else { + var originalData = seriesModel.get('data'); + newSeriesOptList.push({ + name: seriesOpt.name, + data: tryMergeDataOption(seriesOpt.data, originalData) + }); + } + }); + + ecModel.mergeOption(zrUtil.defaults({ + series: newSeriesOptList + }, payload.newOption)); + }); + + module.exports = DataView; + + +/***/ }, +/* 339 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var SelectController = __webpack_require__(225); + var BoundingRect = __webpack_require__(15); + var Group = __webpack_require__(29); + var history = __webpack_require__(340); + var interactionMutex = __webpack_require__(160); + + var each = zrUtil.each; + var asc = numberUtil.asc; + + // Use dataZoomSelect + __webpack_require__(341); + + // Spectial component id start with \0ec\0, see echarts/model/Global.js~hasInnerId + var DATA_ZOOM_ID_BASE = '\0_ec_\0toolbox-dataZoom_'; + + function DataZoom(model) { + this.model = model; + + /** + * @private + * @type {module:zrender/container/Group} + */ + this._controllerGroup; + + /** + * @private + * @type {module:echarts/component/helper/SelectController} + */ + this._controller; + + /** + * Is zoom active. + * @private + * @type {Object} + */ + this._isZoomActive; + } + + DataZoom.defaultOption = { + show: true, + // Icon group + icon: { + zoom: 'M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1', + back: 'M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26' + }, + title: { + zoom: '区域缩放', + back: '区域缩放还原' + } + }; + + var proto = DataZoom.prototype; + + proto.render = function (featureModel, ecModel, api) { + updateBackBtnStatus(featureModel, ecModel); + }; + + proto.onclick = function (ecModel, api, type) { + var controllerGroup = this._controllerGroup; + if (!this._controllerGroup) { + controllerGroup = this._controllerGroup = new Group(); + api.getZr().add(controllerGroup); + } + + handlers[type].call(this, controllerGroup, this.model, ecModel, api); + }; + + proto.remove = function (ecModel, api) { + this._disposeController(); + interactionMutex.release('globalPan', api.getZr()); + }; + + proto.dispose = function (ecModel, api) { + var zr = api.getZr(); + interactionMutex.release('globalPan', zr); + this._disposeController(); + this._controllerGroup && zr.remove(this._controllerGroup); + }; + + /** + * @private + */ + var handlers = { + + zoom: function (controllerGroup, featureModel, ecModel, api) { + var isZoomActive = this._isZoomActive = !this._isZoomActive; + var zr = api.getZr(); + + interactionMutex[isZoomActive ? 'take' : 'release']('globalPan', zr); + + featureModel.setIconStatus('zoom', isZoomActive ? 'emphasis' : 'normal'); + + if (isZoomActive) { + zr.setDefaultCursorStyle('crosshair'); + + this._createController( + controllerGroup, featureModel, ecModel, api + ); + } + else { + zr.setDefaultCursorStyle('default'); + this._disposeController(); + } + }, + + back: function (controllerGroup, featureModel, ecModel, api) { + this._dispatchAction(history.pop(ecModel), api); + } + }; + + /** + * @private + */ + proto._createController = function ( + controllerGroup, featureModel, ecModel, api + ) { + var controller = this._controller = new SelectController( + 'rect', + api.getZr(), + { + // FIXME + lineWidth: 3, + stroke: '#333', + fill: 'rgba(0,0,0,0.2)' + } + ); + controller.on( + 'selectEnd', + zrUtil.bind( + this._onSelected, this, controller, + featureModel, ecModel, api + ) + ); + controller.enable(controllerGroup, false); + }; + + proto._disposeController = function () { + var controller = this._controller; + if (controller) { + controller.off('selected'); + controller.dispose(); + } + }; + + function prepareCoordInfo(grid, ecModel) { + // Default use the first axis. + // FIXME + var coordInfo = [ + {axisModel: grid.getAxis('x').model, axisIndex: 0}, // x + {axisModel: grid.getAxis('y').model, axisIndex: 0} // y + ]; + coordInfo.grid = grid; + + ecModel.eachComponent( + {mainType: 'dataZoom', subType: 'select'}, + function (dzModel, dataZoomIndex) { + if (isTheAxis('xAxis', coordInfo[0].axisModel, dzModel, ecModel)) { + coordInfo[0].dataZoomModel = dzModel; + } + if (isTheAxis('yAxis', coordInfo[1].axisModel, dzModel, ecModel)) { + coordInfo[1].dataZoomModel = dzModel; + } + } + ); + + return coordInfo; + } + + function isTheAxis(axisName, axisModel, dataZoomModel, ecModel) { + var axisIndex = dataZoomModel.get(axisName + 'Index'); + return axisIndex != null + && ecModel.getComponent(axisName, axisIndex) === axisModel; + } + + /** + * @private + */ + proto._onSelected = function (controller, featureModel, ecModel, api, selRanges) { + if (!selRanges.length) { + return; + } + var selRange = selRanges[0]; + + controller.update(); // remove cover + + var snapshot = {}; + + // FIXME + // polar + + ecModel.eachComponent('grid', function (gridModel, gridIndex) { + var grid = gridModel.coordinateSystem; + var coordInfo = prepareCoordInfo(grid, ecModel); + var selDataRange = pointToDataInCartesian(selRange, coordInfo); + + if (selDataRange) { + var xBatchItem = scaleCartesianAxis(selDataRange, coordInfo, 0, 'x'); + var yBatchItem = scaleCartesianAxis(selDataRange, coordInfo, 1, 'y'); + + xBatchItem && (snapshot[xBatchItem.dataZoomId] = xBatchItem); + yBatchItem && (snapshot[yBatchItem.dataZoomId] = yBatchItem); + } + }, this); + + history.push(ecModel, snapshot); + + this._dispatchAction(snapshot, api); + }; + + function pointToDataInCartesian(selRange, coordInfo) { + var grid = coordInfo.grid; + + var selRect = new BoundingRect( + selRange[0][0], + selRange[1][0], + selRange[0][1] - selRange[0][0], + selRange[1][1] - selRange[1][0] + ); + if (!selRect.intersect(grid.getRect())) { + return; + } + var cartesian = grid.getCartesian(coordInfo[0].axisIndex, coordInfo[1].axisIndex); + var dataLeftTop = cartesian.pointToData([selRange[0][0], selRange[1][0]], true); + var dataRightBottom = cartesian.pointToData([selRange[0][1], selRange[1][1]], true); + + return [ + asc([dataLeftTop[0], dataRightBottom[0]]), // x, using asc to handle inverse + asc([dataLeftTop[1], dataRightBottom[1]]) // y, using asc to handle inverse + ]; + } + + function scaleCartesianAxis(selDataRange, coordInfo, dimIdx, dimName) { + var dimCoordInfo = coordInfo[dimIdx]; + var dataZoomModel = dimCoordInfo.dataZoomModel; + + if (dataZoomModel) { + return { + dataZoomId: dataZoomModel.id, + startValue: selDataRange[dimIdx][0], + endValue: selDataRange[dimIdx][1] + }; + } + } + + /** + * @private + */ + proto._dispatchAction = function (snapshot, api) { + var batch = []; + + each(snapshot, function (batchItem) { + batch.push(batchItem); + }); + + batch.length && api.dispatchAction({ + type: 'dataZoom', + from: this.uid, + batch: zrUtil.clone(batch, true) + }); + }; + + function updateBackBtnStatus(featureModel, ecModel) { + featureModel.setIconStatus( + 'back', + history.count(ecModel) > 1 ? 'emphasis' : 'normal' + ); + } + + + __webpack_require__(333).register('dataZoom', DataZoom); + + + // Create special dataZoom option for select + __webpack_require__(1).registerPreprocessor(function (option) { + if (!option) { + return; + } + + var dataZoomOpts = option.dataZoom || (option.dataZoom = []); + if (!zrUtil.isArray(dataZoomOpts)) { + dataZoomOpts = [dataZoomOpts]; + } + + var toolboxOpt = option.toolbox; + if (toolboxOpt) { + // Assume there is only one toolbox + if (zrUtil.isArray(toolboxOpt)) { + toolboxOpt = toolboxOpt[0]; + } + + if (toolboxOpt && toolboxOpt.feature) { + var dataZoomOpt = toolboxOpt.feature.dataZoom; + addForAxis('xAxis', dataZoomOpt); + addForAxis('yAxis', dataZoomOpt); + } + } + + function addForAxis(axisName, dataZoomOpt) { + if (!dataZoomOpt) { + return; + } + + var axisIndicesName = axisName + 'Index'; + var givenAxisIndices = dataZoomOpt[axisIndicesName]; + if (givenAxisIndices != null && !zrUtil.isArray(givenAxisIndices)) { + givenAxisIndices = givenAxisIndices === false ? [] : [givenAxisIndices]; + } + + forEachComponent(axisName, function (axisOpt, axisIndex) { + if (givenAxisIndices != null + && zrUtil.indexOf(givenAxisIndices, axisIndex) === -1 + ) { + return; + } + var newOpt = { + type: 'select', + $fromToolbox: true, + // Id for merge mapping. + id: DATA_ZOOM_ID_BASE + axisName + axisIndex + }; + // FIXME + // Only support one axis now. + newOpt[axisIndicesName] = axisIndex; + dataZoomOpts.push(newOpt); + }); + } + + function forEachComponent(mainType, cb) { + var opts = option[mainType]; + if (!zrUtil.isArray(opts)) { + opts = opts ? [opts] : []; + } + each(opts, cb); + } + }); + + module.exports = DataZoom; + + +/***/ }, +/* 340 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file History manager. + */ + + + var zrUtil = __webpack_require__(3); + var each = zrUtil.each; + + var ATTR = '\0_ec_hist_store'; + + var history = { + + /** + * @public + * @param {module:echarts/model/Global} ecModel + * @param {Object} newSnapshot {dataZoomId, batch: [payloadInfo, ...]} + */ + push: function (ecModel, newSnapshot) { + var store = giveStore(ecModel); + + // If previous dataZoom can not be found, + // complete an range with current range. + each(newSnapshot, function (batchItem, dataZoomId) { + var i = store.length - 1; + for (; i >= 0; i--) { + var snapshot = store[i]; + if (snapshot[dataZoomId]) { + break; + } + } + if (i < 0) { + // No origin range set, create one by current range. + var dataZoomModel = ecModel.queryComponents( + {mainType: 'dataZoom', subType: 'select', id: dataZoomId} + )[0]; + if (dataZoomModel) { + var percentRange = dataZoomModel.getPercentRange(); + store[0][dataZoomId] = { + dataZoomId: dataZoomId, + start: percentRange[0], + end: percentRange[1] + }; + } + } + }); + + store.push(newSnapshot); + }, + + /** + * @public + * @param {module:echarts/model/Global} ecModel + * @return {Object} snapshot + */ + pop: function (ecModel) { + var store = giveStore(ecModel); + var head = store[store.length - 1]; + store.length > 1 && store.pop(); + + // Find top for all dataZoom. + var snapshot = {}; + each(head, function (batchItem, dataZoomId) { + for (var i = store.length - 1; i >= 0; i--) { + var batchItem = store[i][dataZoomId]; + if (batchItem) { + snapshot[dataZoomId] = batchItem; + break; + } + } + }); -/** - * Handler控制模块 - * @module zrender/Handler - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - * errorrik (errorrik@gmail.com) - * pissang (shenyi.914@gmail.com) - */ -define('zrender/Handler',['require','./core/env','./core/event','./core/util','./mixin/Draggable','./core/GestureMgr','./mixin/Eventful'],function (require) { - - - - var env = require('./core/env'); - var eventTool = require('./core/event'); - var util = require('./core/util'); - var Draggable = require('./mixin/Draggable'); - var GestureMgr = require('./core/GestureMgr'); - - var Eventful = require('./mixin/Eventful'); - - var mouseHandlerNames = [ - 'click', 'dblclick', 'mousewheel', 'mouseout' - ]; - !usePointerEvent() && mouseHandlerNames.push( - 'mouseup', 'mousedown', 'mousemove' - ); - - var touchHandlerNames = [ - 'touchstart', 'touchend', 'touchmove' - ]; - - var pointerHandlerNames = [ - 'pointerdown', 'pointerup', 'pointermove' - ]; - - var TOUCH_CLICK_DELAY = 300; - - // touch指尖错觉的尝试偏移量配置 - // var MOBILE_TOUCH_OFFSETS = [ - // { x: 10 }, - // { x: -20 }, - // { x: 10, y: 10 }, - // { y: -20 } - // ]; - - var addEventListener = eventTool.addEventListener; - var removeEventListener = eventTool.removeEventListener; - var normalizeEvent = eventTool.normalizeEvent; - - function makeEventPacket(eveType, target, event) { - return { - type: eveType, - event: event, - target: target, - cancelBubble: false, - offsetX: event.zrX, - offsetY: event.zrY, - gestureEvent: event.gestureEvent, - pinchX: event.pinchX, - pinchY: event.pinchY, - pinchScale: event.pinchScale, - wheelDelta: event.zrDelta - }; - } - - var domHandlers = { - /** - * Mouse move handler - * @inner - * @param {Event} event - */ - mousemove: function (event) { - event = normalizeEvent(this.root, event); - - var x = event.zrX; - var y = event.zrY; - - var hovered = this.findHover(x, y, null); - var lastHovered = this._hovered; - - this._hovered = hovered; - - this.root.style.cursor = hovered ? hovered.cursor : this._defaultCursorStyle; - // Mouse out on previous hovered element - if (lastHovered && hovered !== lastHovered && lastHovered.__zr) { - this._dispatchProxy(lastHovered, 'mouseout', event); - } - - // Mouse moving on one element - this._dispatchProxy(hovered, 'mousemove', event); - - // Mouse over on a new element - if (hovered && hovered !== lastHovered) { - this._dispatchProxy(hovered, 'mouseover', event); - } - }, - - /** - * Mouse out handler - * @inner - * @param {Event} event - */ - mouseout: function (event) { - event = normalizeEvent(this.root, event); - - var element = event.toElement || event.relatedTarget; - if (element != this.root) { - while (element && element.nodeType != 9) { - // 忽略包含在root中的dom引起的mouseOut - if (element === this.root) { - return; - } - - element = element.parentNode; - } - } - - this._dispatchProxy(this._hovered, 'mouseout', event); - - this.trigger('globalout', { - event: event - }); - }, - - /** - * Touch开始响应函数 - * @inner - * @param {Event} event - */ - touchstart: function (event) { - // FIXME - // 移动端可能需要default行为,例如静态图表时。 - // eventTool.stop(event);// 阻止浏览器默认事件,重要 - event = normalizeEvent(this.root, event); - - this._lastTouchMoment = new Date(); - - processGesture(this, event, 'start'); - - // 平板补充一次findHover - // this._mobileFindFixed(event); - // Trigger mousemove and mousedown - domHandlers.mousemove.call(this, event); - - domHandlers.mousedown.call(this, event); - - setTouchTimer(this); - }, - - /** - * Touch移动响应函数 - * @inner - * @param {Event} event - */ - touchmove: function (event) { - // eventTool.stop(event);// 阻止浏览器默认事件,重要 - event = normalizeEvent(this.root, event); - - processGesture(this, event, 'change'); - - // Mouse move should always be triggered no matter whether - // there is gestrue event, because mouse move and pinch may - // be used at the same time. - domHandlers.mousemove.call(this, event); - - setTouchTimer(this); - }, - - /** - * Touch结束响应函数 - * @inner - * @param {Event} event - */ - touchend: function (event) { - // eventTool.stop(event);// 阻止浏览器默认事件,重要 - event = normalizeEvent(this.root, event); - - processGesture(this, event, 'end'); - - domHandlers.mouseup.call(this, event); - - // click event should always be triggered no matter whether - // there is gestrue event. System click can not be prevented. - if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) { - // this._mobileFindFixed(event); - domHandlers.click.call(this, event); - } - - setTouchTimer(this); - } - }; - - // Common handlers - util.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick'], function (name) { - domHandlers[name] = function (event) { - event = normalizeEvent(this.root, event); - // Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover - var hovered = this.findHover(event.zrX, event.zrY, null); - this._dispatchProxy(hovered, name, event); - }; - }); - - // Pointer event handlers - // util.each(['pointerdown', 'pointermove', 'pointerup'], function (name) { - // domHandlers[name] = function (event) { - // var mouseName = name.replace('pointer', 'mouse'); - // domHandlers[mouseName].call(this, event); - // }; - // }); - - function processGesture(zrHandler, event, stage) { - var gestureMgr = zrHandler._gestureMgr; - - stage === 'start' && gestureMgr.clear(); - - var gestureInfo = gestureMgr.recognize( - event, - zrHandler.findHover(event.zrX, event.zrY, null) - ); - - stage === 'end' && gestureMgr.clear(); - - if (gestureInfo) { - // eventTool.stop(event); - var type = gestureInfo.type; - event.gestureEvent = type; - - zrHandler._dispatchProxy(gestureInfo.target, type, gestureInfo.event); - } - } - - /** - * 为控制类实例初始化dom 事件处理函数 - * - * @inner - * @param {module:zrender/Handler} instance 控制类实例 - */ - function initDomHandler(instance) { - var handlerNames = touchHandlerNames.concat(pointerHandlerNames); - for (var i = 0; i < handlerNames.length; i++) { - var name = handlerNames[i]; - instance._handlers[name] = util.bind(domHandlers[name], instance); - } - - for (var i = 0; i < mouseHandlerNames.length; i++) { - var name = mouseHandlerNames[i]; - instance._handlers[name] = makeMouseHandler(domHandlers[name], instance); - } - - function makeMouseHandler(fn, instance) { - return function () { - if (instance._touching) { - return; - } - return fn.apply(instance, arguments); - }; - } - } - - /** - * @alias module:zrender/Handler - * @constructor - * @extends module:zrender/mixin/Eventful - * @param {HTMLElement} root Main HTML element for painting. - * @param {module:zrender/Storage} storage Storage instance. - * @param {module:zrender/Painter} painter Painter instance. - */ - var Handler = function(root, storage, painter) { - Eventful.call(this); - - this.root = root; - this.storage = storage; - this.painter = painter; - - /** - * @private - * @type {boolean} - */ - this._hovered; - - /** - * @private - * @type {Date} - */ - this._lastTouchMoment; - - /** - * @private - * @type {number} - */ - this._lastX; - - /** - * @private - * @type {number} - */ - this._lastY; - - /** - * @private - * @type {string} - */ - this._defaultCursorStyle = 'default'; - - /** - * @private - * @type {module:zrender/core/GestureMgr} - */ - this._gestureMgr = new GestureMgr(); - - /** - * @private - * @type {Array.} - */ - this._handlers = []; - - /** - * @private - * @type {boolean} - */ - this._touching = false; - - /** - * @private - * @type {number} - */ - this._touchTimer; - - initDomHandler(this); - - if (usePointerEvent()) { - mountHandlers(pointerHandlerNames, this); - } - else if (useTouchEvent()) { - mountHandlers(touchHandlerNames, this); - - // Handler of 'mouseout' event is needed in touch mode, which will be mounted below. - // addEventListener(root, 'mouseout', this._mouseoutHandler); - } - - // Considering some devices that both enable touch and mouse event (like MS Surface - // and lenovo X240, @see #2350), we make mouse event be always listened, otherwise - // mouse event can not be handle in those devices. - mountHandlers(mouseHandlerNames, this); - - Draggable.call(this); - - function mountHandlers(handlerNames, instance) { - util.each(handlerNames, function (name) { - addEventListener(root, eventNameFix(name), instance._handlers[name]); - }, instance); - } - }; - - Handler.prototype = { - - constructor: Handler, - - /** - * Resize - */ - resize: function (event) { - this._hovered = null; - }, - - /** - * Dispatch event - * @param {string} eventName - * @param {event=} eventArgs - */ - dispatch: function (eventName, eventArgs) { - var handler = this._handlers[eventName]; - handler && handler.call(this, eventArgs); - }, - - /** - * Dispose - */ - dispose: function () { - var root = this.root; - - var handlerNames = mouseHandlerNames.concat(touchHandlerNames); - - for (var i = 0; i < handlerNames.length; i++) { - var name = handlerNames[i]; - removeEventListener(root, eventNameFix(name), this._handlers[name]); - } - - this.root = - this.storage = - this.painter = null; - }, - - /** - * 设置默认的cursor style - * @param {string} cursorStyle 例如 crosshair - */ - setDefaultCursorStyle: function (cursorStyle) { - this._defaultCursorStyle = cursorStyle; - }, - - /** - * 事件分发代理 - * - * @private - * @param {Object} targetEl 目标图形元素 - * @param {string} eventName 事件名称 - * @param {Object} event 事件对象 - */ - _dispatchProxy: function (targetEl, eventName, event) { - var eventHandler = 'on' + eventName; - var eventPacket = makeEventPacket(eventName, targetEl, event); - - var el = targetEl; - - while (el) { - el[eventHandler] - && (eventPacket.cancelBubble = el[eventHandler].call(el, eventPacket)); - - el.trigger(eventName, eventPacket); - - el = el.parent; - - if (eventPacket.cancelBubble) { - break; - } - } - - if (!eventPacket.cancelBubble) { - // 冒泡到顶级 zrender 对象 - this.trigger(eventName, eventPacket); - // 分发事件到用户自定义层 - // 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在 - this.painter && this.painter.eachOtherLayer(function (layer) { - if (typeof(layer[eventHandler]) == 'function') { - layer[eventHandler].call(layer, eventPacket); - } - if (layer.trigger) { - layer.trigger(eventName, eventPacket); - } - }); - } - }, - - /** - * @private - * @param {number} x - * @param {number} y - * @param {module:zrender/graphic/Displayable} exclude - * @method - */ - findHover: function(x, y, exclude) { - var list = this.storage.getDisplayList(); - for (var i = list.length - 1; i >= 0 ; i--) { - if (!list[i].silent - && list[i] !== exclude - && isHover(list[i], x, y)) { - return list[i]; - } - } - } - }; - - function isHover(displayable, x, y) { - if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) { - var p = displayable.parent; - while (p) { - if (p.clipPath && !p.clipPath.contain(x, y)) { - // Clipped by parents - return false; - } - p = p.parent; - } - return true; - } - - return false; - } - - /** - * Prevent mouse event from being dispatched after Touch Events action - * @see - * 1. Mobile browsers dispatch mouse events 300ms after touchend. - * 2. Chrome for Android dispatch mousedown for long-touch about 650ms - * Result: Blocking Mouse Events for 700ms. - */ - function setTouchTimer(instance) { - instance._touching = true; - clearTimeout(instance._touchTimer); - instance._touchTimer = setTimeout(function () { - instance._touching = false; - }, 700); - } - - /** - * Althought MS Surface support screen touch, IE10/11 do not support - * touch event and MS Edge supported them but not by default (but chrome - * and firefox do). Thus we use Pointer event on MS browsers to handle touch. - */ - function usePointerEvent() { - // TODO - // pointermove event dont trigger when using finger. - // We may figger it out latter. - return false; - // return env.pointerEventsSupported - // In no-touch device we dont use pointer evnets but just - // use mouse event for avoiding problems. - // && window.navigator.maxTouchPoints; - } - - function useTouchEvent() { - return env.touchEventsSupported; - } - - function eventNameFix(name) { - return (name === 'mousewheel' && env.firefox) ? 'DOMMouseScroll' : name; - } - - util.mixin(Handler, Eventful); - util.mixin(Handler, Draggable); - - return Handler; -}); -/** - * Storage内容仓库模块 - * @module zrender/Storage - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - * @author errorrik (errorrik@gmail.com) - * @author pissang (https://github.com/pissang/) - */ -define('zrender/Storage',['require','./core/util','./container/Group'],function (require) { - - - - var util = require('./core/util'); - - var Group = require('./container/Group'); - - function shapeCompareFunc(a, b) { - if (a.zlevel === b.zlevel) { - if (a.z === b.z) { - if (a.z2 === b.z2) { - return a.__renderidx - b.__renderidx; - } - return a.z2 - b.z2; - } - return a.z - b.z; - } - return a.zlevel - b.zlevel; - } - /** - * 内容仓库 (M) - * @alias module:zrender/Storage - * @constructor - */ - var Storage = function () { - // 所有常规形状,id索引的map - this._elements = {}; - - this._roots = []; - - this._displayList = []; - - this._displayListLen = 0; - }; - - Storage.prototype = { - - constructor: Storage, - - /** - * 返回所有图形的绘制队列 - * @param {boolean} [update=false] 是否在返回前更新该数组 - * 详见{@link module:zrender/graphic/Displayable.prototype.updateDisplayList} - * @return {Array.} - */ - getDisplayList: function (update) { - if (update) { - this.updateDisplayList(); - } - return this._displayList; - }, - - /** - * 更新图形的绘制队列。 - * 每次绘制前都会调用,该方法会先深度优先遍历整个树,更新所有Group和Shape的变换并且把所有可见的Shape保存到数组中, - * 最后根据绘制的优先级(zlevel > z > 插入顺序)排序得到绘制队列 - */ - updateDisplayList: function () { - this._displayListLen = 0; - var roots = this._roots; - var displayList = this._displayList; - for (var i = 0, len = roots.length; i < len; i++) { - var root = roots[i]; - this._updateAndAddDisplayable(root); - } - displayList.length = this._displayListLen; - - for (var i = 0, len = displayList.length; i < len; i++) { - displayList[i].__renderidx = i; - } - - displayList.sort(shapeCompareFunc); - }, - - _updateAndAddDisplayable: function (el, clipPaths) { - - if (el.ignore) { - return; - } - - el.beforeUpdate(); - - el.update(); - - el.afterUpdate(); - - var clipPath = el.clipPath; - if (clipPath) { - // clipPath 的变换是基于 group 的变换 - clipPath.parent = el; - clipPath.updateTransform(); - - // FIXME 效率影响 - if (clipPaths) { - clipPaths = clipPaths.slice(); - clipPaths.push(clipPath); - } - else { - clipPaths = [clipPath]; - } - } - - if (el.type == 'group') { - var children = el._children; - - for (var i = 0; i < children.length; i++) { - var child = children[i]; - - // Force to mark as dirty if group is dirty - // FIXME __dirtyPath ? - child.__dirty = el.__dirty || child.__dirty; - - this._updateAndAddDisplayable(child, clipPaths); - } - - // Mark group clean here - el.__dirty = false; - - } - else { - el.__clipPaths = clipPaths; - - this._displayList[this._displayListLen++] = el; - } - }, - - /** - * 添加图形(Shape)或者组(Group)到根节点 - * @param {module:zrender/Element} el - */ - addRoot: function (el) { - // Element has been added - if (this._elements[el.id]) { - return; - } - - if (el instanceof Group) { - el.addChildrenToStorage(this); - } - - this.addToMap(el); - this._roots.push(el); - }, - - /** - * 删除指定的图形(Shape)或者组(Group) - * @param {string|Array.} [elId] 如果为空清空整个Storage - */ - delRoot: function (elId) { - if (elId == null) { - // 不指定elId清空 - for (var i = 0; i < this._roots.length; i++) { - var root = this._roots[i]; - if (root instanceof Group) { - root.delChildrenFromStorage(this); - } - } - - this._elements = {}; - this._roots = []; - this._displayList = []; - this._displayListLen = 0; - - return; - } - - if (elId instanceof Array) { - for (var i = 0, l = elId.length; i < l; i++) { - this.delRoot(elId[i]); - } - return; - } - - var el; - if (typeof(elId) == 'string') { - el = this._elements[elId]; - } - else { - el = elId; - } - - var idx = util.indexOf(this._roots, el); - if (idx >= 0) { - this.delFromMap(el.id); - this._roots.splice(idx, 1); - if (el instanceof Group) { - el.delChildrenFromStorage(this); - } - } - }, - - addToMap: function (el) { - if (el instanceof Group) { - el.__storage = this; - } - el.dirty(); - - this._elements[el.id] = el; - - return this; - }, - - get: function (elId) { - return this._elements[elId]; - }, - - delFromMap: function (elId) { - var elements = this._elements; - var el = elements[elId]; - if (el) { - delete elements[elId]; - if (el instanceof Group) { - el.__storage = null; - } - } - - return this; - }, - - /** - * 清空并且释放Storage - */ - dispose: function () { - this._elements = - this._renderList = - this._roots = null; - } - }; - - return Storage; -}); + return snapshot; + }, -/** - * 动画主类, 调度和管理所有动画控制器 - * - * @module zrender/animation/Animation - * @author pissang(https://github.com/pissang) - */ -// TODO Additive animation -// http://iosoteric.com/additive-animations-animatewithduration-in-ios-8/ -// https://developer.apple.com/videos/wwdc2014/#236 -define('zrender/animation/Animation',['require','../core/util','../core/event','./Animator'],function(require) { - - - - var util = require('../core/util'); - var Dispatcher = require('../core/event').Dispatcher; - - var requestAnimationFrame = (typeof window !== 'undefined' && - (window.requestAnimationFrame - || window.msRequestAnimationFrame - || window.mozRequestAnimationFrame - || window.webkitRequestAnimationFrame)) - || function (func) { - setTimeout(func, 16); - }; - - var Animator = require('./Animator'); - /** - * @typedef {Object} IZRenderStage - * @property {Function} update - */ - - /** - * @alias module:zrender/animation/Animation - * @constructor - * @param {Object} [options] - * @param {Function} [options.onframe] - * @param {IZRenderStage} [options.stage] - * @example - * var animation = new Animation(); - * var obj = { - * x: 100, - * y: 100 - * }; - * animation.animate(node.position) - * .when(1000, { - * x: 500, - * y: 500 - * }) - * .when(2000, { - * x: 100, - * y: 100 - * }) - * .start('spline'); - */ - var Animation = function (options) { - - options = options || {}; - - this.stage = options.stage || {}; - - this.onframe = options.onframe || function() {}; - - // private properties - this._clips = []; - - this._running = false; - - this._time = 0; - - Dispatcher.call(this); - }; - - Animation.prototype = { - - constructor: Animation, - /** - * 添加 clip - * @param {module:zrender/animation/Clip} clip - */ - addClip: function (clip) { - this._clips.push(clip); - }, - /** - * 添加 animator - * @param {module:zrender/animation/Animator} animator - */ - addAnimator: function (animator) { - animator.animation = this; - var clips = animator.getClips(); - for (var i = 0; i < clips.length; i++) { - this.addClip(clips[i]); - } - }, - /** - * 删除动画片段 - * @param {module:zrender/animation/Clip} clip - */ - removeClip: function(clip) { - var idx = util.indexOf(this._clips, clip); - if (idx >= 0) { - this._clips.splice(idx, 1); - } - }, - - /** - * 删除动画片段 - * @param {module:zrender/animation/Animator} animator - */ - removeAnimator: function (animator) { - var clips = animator.getClips(); - for (var i = 0; i < clips.length; i++) { - this.removeClip(clips[i]); - } - animator.animation = null; - }, - - _update: function() { - - var time = new Date().getTime(); - var delta = time - this._time; - var clips = this._clips; - var len = clips.length; - - var deferredEvents = []; - var deferredClips = []; - for (var i = 0; i < len; i++) { - var clip = clips[i]; - var e = clip.step(time); - // Throw out the events need to be called after - // stage.update, like destroy - if (e) { - deferredEvents.push(e); - deferredClips.push(clip); - } - } - - // Remove the finished clip - for (var i = 0; i < len;) { - if (clips[i]._needsRemove) { - clips[i] = clips[len - 1]; - clips.pop(); - len--; - } - else { - i++; - } - } - - len = deferredEvents.length; - for (var i = 0; i < len; i++) { - deferredClips[i].fire(deferredEvents[i]); - } - - this._time = time; - - this.onframe(delta); - - this.trigger('frame', delta); - - if (this.stage.update) { - this.stage.update(); - } - }, - /** - * 开始运行动画 - */ - start: function () { - var self = this; - - this._running = true; - - function step() { - if (self._running) { - - requestAnimationFrame(step); - - self._update(); - } - } - - this._time = new Date().getTime(); - requestAnimationFrame(step); - }, - /** - * 停止运行动画 - */ - stop: function () { - this._running = false; - }, - /** - * 清除所有动画片段 - */ - clear: function () { - this._clips = []; - }, - /** - * 对一个目标创建一个animator对象,可以指定目标中的属性使用动画 - * @param {Object} target - * @param {Object} options - * @param {boolean} [options.loop=false] 是否循环播放动画 - * @param {Function} [options.getter=null] - * 如果指定getter函数,会通过getter函数取属性值 - * @param {Function} [options.setter=null] - * 如果指定setter函数,会通过setter函数设置属性值 - * @return {module:zrender/animation/Animation~Animator} - */ - animate: function (target, options) { - options = options || {}; - var animator = new Animator( - target, - options.loop, - options.getter, - options.setter - ); - - return animator; - } - }; - - util.mixin(Animation, Dispatcher); - - return Animation; -}); + /** + * @public + */ + clear: function (ecModel) { + ecModel[ATTR] = null; + }, -/** - * @module zrender/Layer - * @author pissang(https://www.github.com/pissang) - */ -define('zrender/Layer',['require','./core/util','./config'],function (require) { - - var util = require('./core/util'); - var config = require('./config'); - - function returnFalse() { - return false; - } - - /** - * 创建dom - * - * @inner - * @param {string} id dom id 待用 - * @param {string} type dom type,such as canvas, div etc. - * @param {Painter} painter painter instance - * @param {number} number - */ - function createDom(id, type, painter, dpr) { - var newDom = document.createElement(type); - var width = painter.getWidth(); - var height = painter.getHeight(); - - var newDomStyle = newDom.style; - // 没append呢,请原谅我这样写,清晰~ - newDomStyle.position = 'absolute'; - newDomStyle.left = 0; - newDomStyle.top = 0; - newDomStyle.width = width + 'px'; - newDomStyle.height = height + 'px'; - newDom.width = width * dpr; - newDom.height = height * dpr; - - // id不作为索引用,避免可能造成的重名,定义为私有属性 - newDom.setAttribute('data-zr-dom-id', id); - return newDom; - } - - /** - * @alias module:zrender/Layer - * @constructor - * @extends module:zrender/mixin/Transformable - * @param {string} id - * @param {module:zrender/Painter} painter - * @param {number} [dpr] - */ - var Layer = function(id, painter, dpr) { - var dom; - dpr = dpr || config.devicePixelRatio; - if (typeof id === 'string') { - dom = createDom(id, 'canvas', painter, dpr); - } - // Not using isDom because in node it will return false - else if (util.isObject(id)) { - dom = id; - id = dom.id; - } - this.id = id; - this.dom = dom; - - var domStyle = dom.style; - if (domStyle) { // Not in node - dom.onselectstart = returnFalse; // 避免页面选中的尴尬 - domStyle['-webkit-user-select'] = 'none'; - domStyle['user-select'] = 'none'; - domStyle['-webkit-touch-callout'] = 'none'; - domStyle['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)'; - } - - this.domBack = null; - this.ctxBack = null; - - this.painter = painter; - - this.config = null; - - // Configs - /** - * 每次清空画布的颜色 - * @type {string} - * @default 0 - */ - this.clearColor = 0; - /** - * 是否开启动态模糊 - * @type {boolean} - * @default false - */ - this.motionBlur = false; - /** - * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 - * @type {number} - * @default 0.7 - */ - this.lastFrameAlpha = 0.7; - - /** - * Layer dpr - * @type {number} - */ - this.dpr = dpr; - }; - - Layer.prototype = { - - constructor: Layer, - - elCount: 0, - - __dirty: true, - - initContext: function () { - this.ctx = this.dom.getContext('2d'); - - var dpr = this.dpr; - if (dpr != 1) { - this.ctx.scale(dpr, dpr); - } - }, - - createBackBuffer: function () { - var dpr = this.dpr; - - this.domBack = createDom('back-' + this.id, 'canvas', this.painter, dpr); - this.ctxBack = this.domBack.getContext('2d'); - - if (dpr != 1) { - this.ctxBack.scale(dpr, dpr); - } - }, - - /** - * @param {number} width - * @param {number} height - */ - resize: function (width, height) { - var dpr = this.dpr; - - var dom = this.dom; - var domStyle = dom.style; - var domBack = this.domBack; - - domStyle.width = width + 'px'; - domStyle.height = height + 'px'; - - dom.width = width * dpr; - dom.height = height * dpr; - - if (dpr != 1) { - this.ctx.scale(dpr, dpr); - } - - if (domBack) { - domBack.width = width * dpr; - domBack.height = height * dpr; - - if (dpr != 1) { - this.ctxBack.scale(dpr, dpr); - } - } - }, - - /** - * 清空该层画布 - * @param {boolean} clearAll Clear all with out motion blur - */ - clear: function (clearAll) { - var dom = this.dom; - var ctx = this.ctx; - var width = dom.width; - var height = dom.height; - - var haveClearColor = this.clearColor; - var haveMotionBLur = this.motionBlur && !clearAll; - var lastFrameAlpha = this.lastFrameAlpha; - - var dpr = this.dpr; - - if (haveMotionBLur) { - if (!this.domBack) { - this.createBackBuffer(); - } - - this.ctxBack.globalCompositeOperation = 'copy'; - this.ctxBack.drawImage( - dom, 0, 0, - width / dpr, - height / dpr - ); - } - - ctx.clearRect(0, 0, width / dpr, height / dpr); - if (haveClearColor) { - ctx.save(); - ctx.fillStyle = this.clearColor; - ctx.fillRect(0, 0, width / dpr, height / dpr); - ctx.restore(); - } - - if (haveMotionBLur) { - var domBack = this.domBack; - ctx.save(); - ctx.globalAlpha = lastFrameAlpha; - ctx.drawImage(domBack, 0, 0, width / dpr, height / dpr); - ctx.restore(); - } - } - }; - - return Layer; -}); -/** - * Default canvas painter - * @module zrender/Painter - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - * errorrik (errorrik@gmail.com) - * pissang (https://www.github.com/pissang) - */ - define('zrender/Painter',['require','./config','./core/util','./core/log','./core/BoundingRect','./Layer','./graphic/Image'],function (require) { - - - var config = require('./config'); - var util = require('./core/util'); - var log = require('./core/log'); - var BoundingRect = require('./core/BoundingRect'); - - var Layer = require('./Layer'); - - function parseInt10(val) { - return parseInt(val, 10); - } - - function isLayerValid(layer) { - if (!layer) { - return false; - } - - if (layer.isBuildin) { - return true; - } - - if (typeof(layer.resize) !== 'function' - || typeof(layer.refresh) !== 'function' - ) { - return false; - } - - return true; - } - - function preProcessLayer(layer) { - layer.__unusedCount++; - } - - function postProcessLayer(layer) { - layer.__dirty = false; - if (layer.__unusedCount == 1) { - layer.clear(); - } - } - - var tmpRect = new BoundingRect(0, 0, 0, 0); - var viewRect = new BoundingRect(0, 0, 0, 0); - function isDisplayableCulled(el, width, height) { - tmpRect.copy(el.getBoundingRect()); - if (el.transform) { - tmpRect.applyTransform(el.transform); - } - viewRect.width = width; - viewRect.height = height; - return !tmpRect.intersect(viewRect); - } - - function isClipPathChanged(clipPaths, prevClipPaths) { - if (!clipPaths || !prevClipPaths || (clipPaths.length !== prevClipPaths.length)) { - return true; - } - for (var i = 0; i < clipPaths.length; i++) { - if (clipPaths[i] !== prevClipPaths[i]) { - return true; - } - } - } - - function doClip(clipPaths, ctx) { - for (var i = 0; i < clipPaths.length; i++) { - var clipPath = clipPaths[i]; - var m; - if (clipPath.transform) { - m = clipPath.transform; - ctx.transform( - m[0], m[1], - m[2], m[3], - m[4], m[5] - ); - } - var path = clipPath.path; - path.beginPath(ctx); - clipPath.buildPath(path, clipPath.shape); - ctx.clip(); - // Transform back - if (clipPath.transform) { - m = clipPath.invTransform; - ctx.transform( - m[0], m[1], - m[2], m[3], - m[4], m[5] - ); - } - } - } - - /** - * @alias module:zrender/Painter - * @constructor - * @param {HTMLElement} root 绘图容器 - * @param {module:zrender/Storage} storage - * @param {Ojbect} opts - */ - var Painter = function (root, storage, opts) { - var singleCanvas = !root.nodeName // In node ? - || root.nodeName.toUpperCase() === 'CANVAS'; - - opts = opts || {}; - - /** - * @type {number} - */ - this.dpr = opts.devicePixelRatio || config.devicePixelRatio; - /** - * @type {boolean} - * @private - */ - this._singleCanvas = singleCanvas; - /** - * 绘图容器 - * @type {HTMLElement} - */ - this.root = root; - - var rootStyle = root.style; - - // In node environment using node-canvas - if (rootStyle) { - rootStyle['-webkit-tap-highlight-color'] = 'transparent'; - rootStyle['-webkit-user-select'] = 'none'; - rootStyle['user-select'] = 'none'; - rootStyle['-webkit-touch-callout'] = 'none'; - - root.innerHTML = ''; - } - - /** - * @type {module:zrender/Storage} - */ - this.storage = storage; - - if (!singleCanvas) { - var width = this._getWidth(); - var height = this._getHeight(); - this._width = width; - this._height = height; - - var domRoot = document.createElement('div'); - this._domRoot = domRoot; - var domRootStyle = domRoot.style; - - // domRoot.onselectstart = returnFalse; // 避免页面选中的尴尬 - domRootStyle.position = 'relative'; - domRootStyle.overflow = 'hidden'; - domRootStyle.width = this._width + 'px'; - domRootStyle.height = this._height + 'px'; - root.appendChild(domRoot); - - /** - * @type {Object.} - * @private - */ - this._layers = {}; - /** - * @type {Array.} - * @private - */ - this._zlevelList = []; - } - else { - // Use canvas width and height directly - var width = root.width; - var height = root.height; - this._width = width; - this._height = height; - - // Create layer if only one given canvas - // Device pixel ratio is fixed to 1 because given canvas has its specified width and height - var mainLayer = new Layer(root, this, 1); - mainLayer.initContext(); - // FIXME Use canvas width and height - // mainLayer.resize(width, height); - this._layers = { - 0: mainLayer - }; - this._zlevelList = [0]; - } - - this._layerConfig = {}; - - this.pathToImage = this._createPathToImage(); - }; - - Painter.prototype = { - - constructor: Painter, - - /** - * If painter use a single canvas - * @return {boolean} - */ - isSingleCanvas: function () { - return this._singleCanvas; - }, - /** - * @return {HTMLDivElement} - */ - getViewportRoot: function () { - return this._singleCanvas ? this._layers[0].dom : this._domRoot; - }, - - /** - * 刷新 - * @param {boolean} [paintAll=false] 强制绘制所有displayable - */ - refresh: function (paintAll) { - var list = this.storage.getDisplayList(true); - var zlevelList = this._zlevelList; - - this._paintList(list, paintAll); - - // Paint custum layers - for (var i = 0; i < zlevelList.length; i++) { - var z = zlevelList[i]; - var layer = this._layers[z]; - if (!layer.isBuildin && layer.refresh) { - layer.refresh(); - } - } - - return this; - }, - - _paintList: function (list, paintAll) { - - if (paintAll == null) { - paintAll = false; - } - - this._updateLayerStatus(list); - - var currentLayer; - var currentZLevel; - var ctx; - - var viewWidth = this._width; - var viewHeight = this._height; - - this.eachBuildinLayer(preProcessLayer); - - // var invTransform = []; - var prevElClipPaths = null; - - for (var i = 0, l = list.length; i < l; i++) { - var el = list[i]; - var elZLevel = this._singleCanvas ? 0 : el.zlevel; - // Change draw layer - if (currentZLevel !== elZLevel) { - // Only 0 zlevel if only has one canvas - currentZLevel = elZLevel; - currentLayer = this.getLayer(currentZLevel); - - if (!currentLayer.isBuildin) { - log( - 'ZLevel ' + currentZLevel - + ' has been used by unkown layer ' + currentLayer.id - ); - } - - ctx = currentLayer.ctx; - - // Reset the count - currentLayer.__unusedCount = 0; - - if (currentLayer.__dirty || paintAll) { - currentLayer.clear(); - } - } - - if ( - (currentLayer.__dirty || paintAll) - // Ignore invisible element - && !el.invisible - // Ignore transparent element - && el.style.opacity !== 0 - // Ignore scale 0 element, in some environment like node-canvas - // Draw a scale 0 element can cause all following draw wrong - && el.scale[0] && el.scale[1] - // Ignore culled element - && !(el.culling && isDisplayableCulled(el, viewWidth, viewHeight)) - ) { - var clipPaths = el.__clipPaths; - - // Optimize when clipping on group with several elements - if (isClipPathChanged(clipPaths, prevElClipPaths)) { - // If has previous clipping state, restore from it - if (prevElClipPaths) { - ctx.restore(); - } - // New clipping state - if (clipPaths) { - ctx.save(); - doClip(clipPaths, ctx); - } - prevElClipPaths = clipPaths; - } - // TODO Use events ? - el.beforeBrush && el.beforeBrush(ctx); - el.brush(ctx, false); - el.afterBrush && el.afterBrush(ctx); - } - - el.__dirty = false; - } - - // If still has clipping state - if (prevElClipPaths) { - ctx.restore(); - } - - this.eachBuildinLayer(postProcessLayer); - }, - - /** - * 获取 zlevel 所在层,如果不存在则会创建一个新的层 - * @param {number} zlevel - * @return {module:zrender/Layer} - */ - getLayer: function (zlevel) { - if (this._singleCanvas) { - return this._layers[0]; - } - - var layer = this._layers[zlevel]; - if (!layer) { - // Create a new layer - layer = new Layer('zr_' + zlevel, this, this.dpr); - layer.isBuildin = true; - - if (this._layerConfig[zlevel]) { - util.merge(layer, this._layerConfig[zlevel], true); - } - - this.insertLayer(zlevel, layer); - - // Context is created after dom inserted to document - // Or excanvas will get 0px clientWidth and clientHeight - layer.initContext(); - } - - return layer; - }, - - insertLayer: function (zlevel, layer) { - - var layersMap = this._layers; - var zlevelList = this._zlevelList; - var len = zlevelList.length; - var prevLayer = null; - var i = -1; - var domRoot = this._domRoot; - - if (layersMap[zlevel]) { - log('ZLevel ' + zlevel + ' has been used already'); - return; - } - // Check if is a valid layer - if (!isLayerValid(layer)) { - log('Layer of zlevel ' + zlevel + ' is not valid'); - return; - } - - if (len > 0 && zlevel > zlevelList[0]) { - for (i = 0; i < len - 1; i++) { - if ( - zlevelList[i] < zlevel - && zlevelList[i + 1] > zlevel - ) { - break; - } - } - prevLayer = layersMap[zlevelList[i]]; - } - zlevelList.splice(i + 1, 0, zlevel); - - if (prevLayer) { - var prevDom = prevLayer.dom; - if (prevDom.nextSibling) { - domRoot.insertBefore( - layer.dom, - prevDom.nextSibling - ); - } - else { - domRoot.appendChild(layer.dom); - } - } - else { - if (domRoot.firstChild) { - domRoot.insertBefore(layer.dom, domRoot.firstChild); - } - else { - domRoot.appendChild(layer.dom); - } - } - - layersMap[zlevel] = layer; - }, - - // Iterate each layer - eachLayer: function (cb, context) { - var zlevelList = this._zlevelList; - var z; - var i; - for (i = 0; i < zlevelList.length; i++) { - z = zlevelList[i]; - cb.call(context, this._layers[z], z); - } - }, - - // Iterate each buildin layer - eachBuildinLayer: function (cb, context) { - var zlevelList = this._zlevelList; - var layer; - var z; - var i; - for (i = 0; i < zlevelList.length; i++) { - z = zlevelList[i]; - layer = this._layers[z]; - if (layer.isBuildin) { - cb.call(context, layer, z); - } - } - }, - - // Iterate each other layer except buildin layer - eachOtherLayer: function (cb, context) { - var zlevelList = this._zlevelList; - var layer; - var z; - var i; - for (i = 0; i < zlevelList.length; i++) { - z = zlevelList[i]; - layer = this._layers[z]; - if (! layer.isBuildin) { - cb.call(context, layer, z); - } - } - }, - - /** - * 获取所有已创建的层 - * @param {Array.} [prevLayer] - */ - getLayers: function () { - return this._layers; - }, - - _updateLayerStatus: function (list) { - - var layers = this._layers; - - var elCounts = {}; - - this.eachBuildinLayer(function (layer, z) { - elCounts[z] = layer.elCount; - layer.elCount = 0; - }); - - for (var i = 0, l = list.length; i < l; i++) { - var el = list[i]; - var zlevel = this._singleCanvas ? 0 : el.zlevel; - var layer = layers[zlevel]; - if (layer) { - layer.elCount++; - // 已经被标记为需要刷新 - if (layer.__dirty) { - continue; - } - layer.__dirty = el.__dirty; - } - } - - // 层中的元素数量有发生变化 - this.eachBuildinLayer(function (layer, z) { - if (elCounts[z] !== layer.elCount) { - layer.__dirty = true; - } - }); - }, - - /** - * 清除hover层外所有内容 - */ - clear: function () { - this.eachBuildinLayer(this._clearLayer); - return this; - }, - - _clearLayer: function (layer) { - layer.clear(); - }, - - /** - * 修改指定zlevel的绘制参数 - * - * @param {string} zlevel - * @param {Object} config 配置对象 - * @param {string} [config.clearColor=0] 每次清空画布的颜色 - * @param {string} [config.motionBlur=false] 是否开启动态模糊 - * @param {number} [config.lastFrameAlpha=0.7] - * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 - */ - configLayer: function (zlevel, config) { - if (config) { - var layerConfig = this._layerConfig; - if (!layerConfig[zlevel]) { - layerConfig[zlevel] = config; - } - else { - util.merge(layerConfig[zlevel], config, true); - } - - var layer = this._layers[zlevel]; - - if (layer) { - util.merge(layer, layerConfig[zlevel], true); - } - } - }, - - /** - * 删除指定层 - * @param {number} zlevel 层所在的zlevel - */ - delLayer: function (zlevel) { - var layers = this._layers; - var zlevelList = this._zlevelList; - var layer = layers[zlevel]; - if (!layer) { - return; - } - layer.dom.parentNode.removeChild(layer.dom); - delete layers[zlevel]; - - zlevelList.splice(util.indexOf(zlevelList, zlevel), 1); - }, - - /** - * 区域大小变化后重绘 - */ - resize: function (width, height) { - var domRoot = this._domRoot; - // FIXME Why ? - domRoot.style.display = 'none'; - - width = width || this._getWidth(); - height = height || this._getHeight(); - - domRoot.style.display = ''; - - // 优化没有实际改变的resize - if (this._width != width || height != this._height) { - domRoot.style.width = width + 'px'; - domRoot.style.height = height + 'px'; - - for (var id in this._layers) { - this._layers[id].resize(width, height); - } - - this.refresh(true); - } - - this._width = width; - this._height = height; - - return this; - }, - - /** - * 清除单独的一个层 - * @param {number} zlevel - */ - clearLayer: function (zlevel) { - var layer = this._layers[zlevel]; - if (layer) { - layer.clear(); - } - }, - - /** - * 释放 - */ - dispose: function () { - this.root.innerHTML = ''; - - this.root = - this.storage = - - this._domRoot = - this._layers = null; - }, - - /** - * Get canvas which has all thing rendered - * @param {Object} opts - * @param {string} [opts.backgroundColor] - */ - getRenderedCanvas: function (opts) { - opts = opts || {}; - if (this._singleCanvas) { - return this._layers[0].dom; - } - - var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr); - imageLayer.initContext(); - - var ctx = imageLayer.ctx; - imageLayer.clearColor = opts.backgroundColor; - imageLayer.clear(); - - var displayList = this.storage.getDisplayList(true); - - for (var i = 0; i < displayList.length; i++) { - var el = displayList[i]; - if (!el.invisible) { - el.beforeBrush && el.beforeBrush(ctx); - // TODO Check image cross origin - el.brush(ctx, false); - el.afterBrush && el.afterBrush(ctx); - } - } - - return imageLayer.dom; - }, - /** - * 获取绘图区域宽度 - */ - getWidth: function () { - return this._width; - }, - - /** - * 获取绘图区域高度 - */ - getHeight: function () { - return this._height; - }, - - _getWidth: function () { - var root = this.root; - var stl = document.defaultView.getComputedStyle(root); - - // FIXME Better way to get the width and height when element has not been append to the document - return ((root.clientWidth || parseInt10(stl.width) || parseInt10(root.style.width)) - - (parseInt10(stl.paddingLeft) || 0) - - (parseInt10(stl.paddingRight) || 0)) | 0; - }, - - _getHeight: function () { - var root = this.root; - var stl = document.defaultView.getComputedStyle(root); - - return ((root.clientHeight || parseInt10(stl.height) || parseInt10(root.style.height)) - - (parseInt10(stl.paddingTop) || 0) - - (parseInt10(stl.paddingBottom) || 0)) | 0; - }, - - _pathToImage: function (id, path, width, height, dpr) { - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - - canvas.width = width * dpr; - canvas.height = height * dpr; - - ctx.clearRect(0, 0, width * dpr, height * dpr); - - var pathTransform = { - position: path.position, - rotation: path.rotation, - scale: path.scale - }; - path.position = [0, 0, 0]; - path.rotation = 0; - path.scale = [1, 1]; - if (path) { - path.brush(ctx); - } - - var ImageShape = require('./graphic/Image'); - var imgShape = new ImageShape({ - id: id, - style: { - x: 0, - y: 0, - image: canvas - } - }); - - if (pathTransform.position != null) { - imgShape.position = path.position = pathTransform.position; - } - - if (pathTransform.rotation != null) { - imgShape.rotation = path.rotation = pathTransform.rotation; - } - - if (pathTransform.scale != null) { - imgShape.scale = path.scale = pathTransform.scale; - } - - return imgShape; - }, - - _createPathToImage: function () { - var me = this; - - return function (id, e, width, height) { - return me._pathToImage( - id, e, width, height, me.dpr - ); - }; - } - }; - - return Painter; -}); + /** + * @public + * @param {module:echarts/model/Global} ecModel + * @return {number} records. always >= 1. + */ + count: function (ecModel) { + return giveStore(ecModel).length; + } -/*! - * ZRender, a high performance 2d drawing library. - * - * Copyright (c) 2013, Baidu Inc. - * All rights reserved. - * - * LICENSE - * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt - */ -// Global defines -define('zrender/zrender',['require','./core/guid','./core/env','./Handler','./Storage','./animation/Animation','./Painter'],function(require) { - var guid = require('./core/guid'); - var env = require('./core/env'); - - var Handler = require('./Handler'); - var Storage = require('./Storage'); - var Animation = require('./animation/Animation'); - - var useVML = !env.canvasSupported; - - var painterCtors = { - canvas: require('./Painter') - }; - - var instances = {}; // ZRender实例map索引 - - var zrender = {}; - /** - * @type {string} - */ - zrender.version = '3.0.3'; - - /** - * @param {HTMLElement} dom - * @param {Object} opts - * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg' - * @param {number} [opts.devicePixelRatio] - * @return {module:zrender/ZRender} - */ - zrender.init = function(dom, opts) { - var zr = new ZRender(guid(), dom, opts); - instances[zr.id] = zr; - return zr; - }; - - /** - * Dispose zrender instance - * @param {module:zrender/ZRender} zr - */ - zrender.dispose = function (zr) { - if (zr) { - zr.dispose(); - } - else { - for (var key in instances) { - instances[key].dispose(); - } - instances = {}; - } - - return zrender; - }; - - /** - * 获取zrender实例 - * @param {string} id ZRender对象索引 - * @return {module:zrender/ZRender} - */ - zrender.getInstance = function (id) { - return instances[id]; - }; - - zrender.registerPainter = function (name, Ctor) { - painterCtors[name] = Ctor; - }; - - function delInstance(id) { - delete instances[id]; - } - - /** - * @module zrender/ZRender - */ - /** - * @constructor - * @alias module:zrender/ZRender - * @param {string} id - * @param {HTMLDomElement} dom - * @param {Object} opts - * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg' - * @param {number} [opts.devicePixelRatio] - */ - var ZRender = function(id, dom, opts) { - - opts = opts || {}; - - /** - * @type {HTMLDomElement} - */ - this.dom = dom; - - /** - * @type {string} - */ - this.id = id; - - var self = this; - var storage = new Storage(); - - var rendererType = opts.renderer; - if (useVML) { - if (!painterCtors.vml) { - throw new Error('You need to require \'zrender/vml/vml\' to support IE8'); - } - rendererType = 'vml'; - } - else if (!rendererType || !painterCtors[rendererType]) { - rendererType = 'canvas'; - } - var painter = new painterCtors[rendererType](dom, storage, opts); - - this.storage = storage; - this.painter = painter; - if (!env.node) { - this.handler = new Handler(painter.getViewportRoot(), storage, painter); - } - - /** - * @type {module:zrender/animation/Animation} - */ - this.animation = new Animation({ - stage: { - update: function () { - if (self._needsRefresh) { - self.refreshImmediately(); - } - } - } - }); - this.animation.start(); - - /** - * @type {boolean} - * @private - */ - this._needsRefresh; - - // 修改 storage.delFromMap, 每次删除元素之前删除动画 - // FIXME 有点ugly - var oldDelFromMap = storage.delFromMap; - var oldAddToMap = storage.addToMap; - - storage.delFromMap = function (elId) { - var el = storage.get(elId); - - oldDelFromMap.call(storage, elId); - - el && el.removeSelfFromZr(self); - }; - - storage.addToMap = function (el) { - oldAddToMap.call(storage, el); - - el.addSelfToZr(self); - }; - }; - - ZRender.prototype = { - - constructor: ZRender, - /** - * 获取实例唯一标识 - * @return {string} - */ - getId: function () { - return this.id; - }, - - /** - * 添加元素 - * @param {string|module:zrender/Element} el - */ - add: function (el) { - this.storage.addRoot(el); - this._needsRefresh = true; - }, - - /** - * 删除元素 - * @param {string|module:zrender/Element} el - */ - remove: function (el) { - this.storage.delRoot(el); - this._needsRefresh = true; - }, - - /** - * 修改指定zlevel的绘制配置项 - * - * @param {string} zLevel - * @param {Object} config 配置对象 - * @param {string} [config.clearColor=0] 每次清空画布的颜色 - * @param {string} [config.motionBlur=false] 是否开启动态模糊 - * @param {number} [config.lastFrameAlpha=0.7] - * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 - */ - configLayer: function (zLevel, config) { - this.painter.configLayer(zLevel, config); - this._needsRefresh = true; - }, - - /** - * 视图更新 - */ - refreshImmediately: function () { - // Clear needsRefresh ahead to avoid something wrong happens in refresh - // Or it will cause zrender refreshes again and again. - this._needsRefresh = false; - this.painter.refresh(); - /** - * Avoid trigger zr.refresh in Element#beforeUpdate hook - */ - this._needsRefresh = false; - }, - - /** - * 标记视图在浏览器下一帧需要绘制 - */ - refresh: function() { - this._needsRefresh = true; - }, - - /** - * 调整视图大小 - */ - resize: function() { - this.painter.resize(); - this.handler && this.handler.resize(); - }, - - /** - * 停止所有动画 - */ - clearAnimation: function () { - this.animation.clear(); - }, - - /** - * 获取视图宽度 - */ - getWidth: function() { - return this.painter.getWidth(); - }, - - /** - * 获取视图高度 - */ - getHeight: function() { - return this.painter.getHeight(); - }, - - /** - * 图像导出 - * @param {string} type - * @param {string} [backgroundColor='#fff'] 背景色 - * @return {string} 图片的Base64 url - */ - toDataURL: function(type, backgroundColor, args) { - return this.painter.toDataURL(type, backgroundColor, args); - }, - - /** - * 将常规shape转成image shape - * @param {module:zrender/graphic/Path} e - * @param {number} width - * @param {number} height - */ - pathToImage: function(e, width, height) { - var id = guid(); - return this.painter.pathToImage(id, e, width, height); - }, - - /** - * 设置默认的cursor style - * @param {string} cursorStyle 例如 crosshair - */ - setDefaultCursorStyle: function (cursorStyle) { - this.handler.setDefaultCursorStyle(cursorStyle); - }, - - /** - * 事件绑定 - * - * @param {string} eventName 事件名称 - * @param {Function} eventHandler 响应函数 - * @param {Object} [context] 响应函数 - */ - on: function(eventName, eventHandler, context) { - this.handler && this.handler.on(eventName, eventHandler, context); - }, - - /** - * 事件解绑定,参数为空则解绑所有自定义事件 - * - * @param {string} eventName 事件名称 - * @param {Function} eventHandler 响应函数 - */ - off: function(eventName, eventHandler) { - this.handler && this.handler.off(eventName, eventHandler); - }, - - /** - * 事件触发 - * - * @param {string} eventName 事件名称,resize,hover,drag,etc - * @param {event=} event event dom事件对象 - */ - trigger: function (eventName, event) { - this.handler && this.handler.trigger(eventName, event); - }, - - - /** - * 清除当前ZRender下所有类图的数据和显示,clear后MVC和已绑定事件均还存在在,ZRender可用 - */ - clear: function () { - this.storage.delRoot(); - this.painter.clear(); - }, - - /** - * 释放当前ZR实例(删除包括dom,数据、显示和事件绑定),dispose后ZR不可用 - */ - dispose: function () { - this.animation.stop(); - - this.clear(); - this.storage.dispose(); - this.painter.dispose(); - this.handler && this.handler.dispose(); - - this.animation = - this.storage = - this.painter = - this.handler = null; - - delInstance(this.id); - } - }; - - return zrender; -}); + }; -define('zrender', ['zrender/zrender'], function (main) { return main; }); - -define('echarts/loading/default',['require','../util/graphic','zrender/core/util'],function (require) { - - var graphic = require('../util/graphic'); - var zrUtil = require('zrender/core/util'); - var PI = Math.PI; - /** - * @param {module:echarts/ExtensionAPI} api - * @param {Object} [opts] - * @param {string} [opts.text] - * @param {string} [opts.color] - * @param {string} [opts.textColor] - * @return {module:zrender/Element} - */ - return function (api, opts) { - opts = opts || {}; - zrUtil.defaults(opts, { - text: 'loading', - color: '#c23531', - textColor: '#000', - maskColor: 'rgba(255, 255, 255, 0.8)', - zlevel: 0 - }); - var mask = new graphic.Rect({ - style: { - fill: opts.maskColor - }, - zlevel: opts.zlevel, - z: 10000 - }); - var arc = new graphic.Arc({ - shape: { - startAngle: -PI / 2, - endAngle: -PI / 2 + 0.1, - r: 10 - }, - style: { - stroke: opts.color, - lineCap: 'round', - lineWidth: 5 - }, - zlevel: opts.zlevel, - z: 10001 - }); - var labelRect = new graphic.Rect({ - style: { - fill: 'none', - text: opts.text, - textPosition: 'right', - textDistance: 10, - textFill: opts.textColor - }, - zlevel: opts.zlevel, - z: 10001 - }); - - arc.animateShape(true) - .when(1000, { - endAngle: PI * 3 / 2 - }) - .start('circularInOut'); - arc.animateShape(true) - .when(1000, { - startAngle: PI * 3 / 2 - }) - .delay(300) - .start('circularInOut'); - - var group = new graphic.Group(); - group.add(arc); - group.add(labelRect); - group.add(mask); - // Inject resize - group.resize = function () { - var cx = api.getWidth() / 2; - var cy = api.getHeight() / 2; - arc.setShape({ - cx: cx, - cy: cy - }); - var r = arc.shape.r; - labelRect.setShape({ - x: cx - r, - y: cy - r, - width: r * 2, - height: r * 2 - }); - - mask.setShape({ - x: 0, - y: 0, - width: api.getWidth(), - height: api.getHeight() - }); - }; - group.resize(); - return group; - }; -}); -define('echarts/visual/seriesColor',['require','zrender/graphic/Gradient'],function (require) { - var Gradient = require('zrender/graphic/Gradient'); - return function (seriesType, styleType, ecModel) { - function encodeColor(seriesModel) { - var colorAccessPath = [styleType, 'normal', 'color']; - var colorList = ecModel.get('color'); - var data = seriesModel.getData(); - var color = seriesModel.get(colorAccessPath) // Set in itemStyle - || colorList[seriesModel.seriesIndex % colorList.length]; // Default color - - // FIXME Set color function or use the platte color - data.setVisual('color', color); - - // Only visible series has each data be visual encoded - if (!ecModel.isSeriesFiltered(seriesModel)) { - if (typeof color === 'function' && !(color instanceof Gradient)) { - data.each(function (idx) { - data.setItemVisual( - idx, 'color', color(seriesModel.getDataParams(idx)) - ); - }); - } - - data.each(function (idx) { - var itemModel = data.getItemModel(idx); - var color = itemModel.get(colorAccessPath, true); - if (color != null) { - data.setItemVisual(idx, 'color', color); - } - }); - } - } - seriesType ? ecModel.eachSeriesByType(seriesType, encodeColor) - : ecModel.eachSeries(encodeColor); - }; -}); -define('echarts/preprocessor/helper/compatStyle',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - var POSSIBLE_STYLES = [ - 'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle', - 'chordStyle', 'label', 'labelLine' - ]; - - function compatItemStyle(opt) { - var itemStyleOpt = opt && opt.itemStyle; - if (itemStyleOpt) { - zrUtil.each(POSSIBLE_STYLES, function (styleName) { - var normalItemStyleOpt = itemStyleOpt.normal; - var emphasisItemStyleOpt = itemStyleOpt.emphasis; - if (normalItemStyleOpt && normalItemStyleOpt[styleName]) { - opt[styleName] = opt[styleName] || {}; - if (!opt[styleName].normal) { - opt[styleName].normal = normalItemStyleOpt[styleName]; - } - else { - zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]); - } - normalItemStyleOpt[styleName] = null; - } - if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) { - opt[styleName] = opt[styleName] || {}; - if (!opt[styleName].emphasis) { - opt[styleName].emphasis = emphasisItemStyleOpt[styleName]; - } - else { - zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]); - } - emphasisItemStyleOpt[styleName] = null; - } - }); - } - } - - return function (seriesOpt) { - compatItemStyle(seriesOpt); - var data = seriesOpt.data; - if (data) { - for (var i = 0; i < data.length; i++) { - compatItemStyle(data[i]); - } - // mark point data - var markPoint = seriesOpt.markPoint; - if (markPoint && markPoint.data) { - var mpData = markPoint.data; - for (var i = 0; i < mpData.length; i++) { - compatItemStyle(mpData[i]); - } - } - // mark line data - var markLine = seriesOpt.markLine; - if (markLine && markLine.data) { - var mlData = markLine.data; - for (var i = 0; i < mlData.length; i++) { - if (zrUtil.isArray(mlData[i])) { - compatItemStyle(mlData[i][0]); - compatItemStyle(mlData[i][1]); - } - else { - compatItemStyle(mlData[i]); - } - } - } - } - }; -}); -// Compatitable with 2.0 -define('echarts/preprocessor/backwardCompat',['require','zrender/core/util','./helper/compatStyle'],function (require) { - - var zrUtil = require('zrender/core/util'); - var compatStyle = require('./helper/compatStyle'); - - function get(opt, path) { - path = path.split(','); - var obj = opt; - for (var i = 0; i < path.length; i++) { - obj = obj && obj[path[i]]; - if (obj == null) { - break; - } - } - return obj; - } - - function set(opt, path, val, overwrite) { - path = path.split(','); - var obj = opt; - var key; - for (var i = 0; i < path.length - 1; i++) { - key = path[i]; - if (obj[key] == null) { - obj[key] = {}; - } - obj = obj[key]; - } - if (overwrite || obj[path[i]] == null) { - obj[path[i]] = val; - } - } - - function compatLayoutProperties(option) { - each(LAYOUT_PROPERTIES, function (prop) { - if (prop[0] in option && !(prop[1] in option)) { - option[prop[1]] = option[prop[0]]; - } - }); - } - - var LAYOUT_PROPERTIES = [ - ['x', 'left'], ['y', 'top'], ['x2', 'right'], ['y2', 'bottom'] - ]; - - var COMPATITABLE_COMPONENTS = [ - 'grid', 'geo', 'parallel', 'legend', 'toolbox', 'title', 'visualMap', 'dataZoom', 'timeline' - ]; - - var COMPATITABLE_SERIES = [ - 'bar', 'boxplot', 'candlestick', 'chord', 'effectScatter', - 'funnel', 'gauge', 'lines', 'graph', 'heatmap', 'line', 'map', 'parallel', - 'pie', 'radar', 'sankey', 'scatter', 'treemap' - ]; - - var each = zrUtil.each; - - return function (option) { - each(option.series, function (seriesOpt) { - if (!zrUtil.isObject(seriesOpt)) { - return; - } - - var seriesType = seriesOpt.type; - - compatStyle(seriesOpt); - - if (seriesType === 'pie' || seriesType === 'gauge') { - if (seriesOpt.clockWise != null) { - seriesOpt.clockwise = seriesOpt.clockWise; - } - } - if (seriesType === 'gauge') { - var pointerColor = get(seriesOpt, 'pointer.color'); - pointerColor != null - && set(seriesOpt, 'itemStyle.normal.color', pointerColor); - } - - for (var i = 0; i < COMPATITABLE_SERIES.length; i++) { - if (COMPATITABLE_SERIES[i] === seriesOpt.type) { - compatLayoutProperties(seriesOpt); - break; - } - } - }); - - // dataRange has changed to visualMap - if (option.dataRange) { - option.visualMap = option.dataRange; - } - - each(COMPATITABLE_COMPONENTS, function (componentName) { - var options = option[componentName]; - if (options) { - if (!zrUtil.isArray(options)) { - options = [options]; - } - each(options, function (option) { - compatLayoutProperties(option); - }); - } - }); - }; -}); -/*! - * ECharts, a javascript interactive chart library. - * - * Copyright (c) 2015, Baidu Inc. - * All rights reserved. - * - * LICENSE - * https://github.com/ecomfe/echarts/blob/master/LICENSE.txt - */ - -/** - * @module echarts - */ -define('echarts/echarts',['require','./model/Global','./ExtensionAPI','./CoordinateSystem','./model/OptionManager','./model/Component','./model/Series','./view/Component','./view/Chart','./util/graphic','zrender','zrender/core/util','zrender/tool/color','zrender/core/env','zrender/mixin/Eventful','./loading/default','./visual/seriesColor','./preprocessor/backwardCompat','./util/graphic','./util/number','./util/format','zrender/core/matrix','zrender/core/vector'],function (require) { - - var GlobalModel = require('./model/Global'); - var ExtensionAPI = require('./ExtensionAPI'); - var CoordinateSystemManager = require('./CoordinateSystem'); - var OptionManager = require('./model/OptionManager'); - - var ComponentModel = require('./model/Component'); - var SeriesModel = require('./model/Series'); - - var ComponentView = require('./view/Component'); - var ChartView = require('./view/Chart'); - var graphic = require('./util/graphic'); - - var zrender = require('zrender'); - var zrUtil = require('zrender/core/util'); - var colorTool = require('zrender/tool/color'); - var env = require('zrender/core/env'); - var Eventful = require('zrender/mixin/Eventful'); - - var each = zrUtil.each; - - var VISUAL_CODING_STAGES = ['echarts', 'chart', 'component']; - - // TODO Transform first or filter first - var PROCESSOR_STAGES = ['transform', 'filter', 'statistic']; - - function createRegisterEventWithLowercaseName(method) { - return function (eventName, handler, context) { - // Event name is all lowercase - eventName = eventName && eventName.toLowerCase(); - Eventful.prototype[method].call(this, eventName, handler, context); - }; - } - /** - * @module echarts~MessageCenter - */ - function MessageCenter() { - Eventful.call(this); - } - MessageCenter.prototype.on = createRegisterEventWithLowercaseName('on'); - MessageCenter.prototype.off = createRegisterEventWithLowercaseName('off'); - MessageCenter.prototype.one = createRegisterEventWithLowercaseName('one'); - zrUtil.mixin(MessageCenter, Eventful); - /** - * @module echarts~ECharts - */ - function ECharts (dom, theme, opts) { - opts = opts || {}; - - // Get theme by name - if (typeof theme === 'string') { - theme = themeStorage[theme]; - } - - if (theme) { - each(optionPreprocessorFuncs, function (preProcess) { - preProcess(theme); - }); - } - /** - * @type {string} - */ - this.id; - /** - * Group id - * @type {string} - */ - this.group; - /** - * @type {HTMLDomElement} - * @private - */ - this._dom = dom; - /** - * @type {module:zrender/ZRender} - * @private - */ - this._zr = zrender.init(dom, { - renderer: opts.renderer || 'canvas', - devicePixelRatio: opts.devicePixelRatio - }); - - /** - * @type {Object} - * @private - */ - this._theme = zrUtil.clone(theme); - - /** - * @type {Array.} - * @private - */ - this._chartsViews = []; - - /** - * @type {Object.} - * @private - */ - this._chartsMap = {}; - - /** - * @type {Array.} - * @private - */ - this._componentsViews = []; - - /** - * @type {Object.} - * @private - */ - this._componentsMap = {}; - - /** - * @type {module:echarts/ExtensionAPI} - * @private - */ - this._api = new ExtensionAPI(this); - - /** - * @type {module:echarts/CoordinateSystem} - * @private - */ - this._coordSysMgr = new CoordinateSystemManager(); - - Eventful.call(this); - - /** - * @type {module:echarts~MessageCenter} - * @private - */ - this._messageCenter = new MessageCenter(); - - // Init mouse events - this._initEvents(); - - // In case some people write `window.onresize = chart.resize` - this.resize = zrUtil.bind(this.resize, this); - } - - var echartsProto = ECharts.prototype; - - /** - * @return {HTMLDomElement} - */ - echartsProto.getDom = function () { - return this._dom; - }; - - /** - * @return {module:zrender~ZRender} - */ - echartsProto.getZr = function () { - return this._zr; - }; - - /** - * @param {Object} option - * @param {boolean} notMerge - * @param {boolean} [notRefreshImmediately=false] Useful when setOption frequently. - */ - echartsProto.setOption = function (option, notMerge, notRefreshImmediately) { - if (!this._model || notMerge) { - this._model = new GlobalModel( - null, null, this._theme, new OptionManager(this._api) - ); - } - - this._model.setOption(option, optionPreprocessorFuncs); - - updateMethods.prepareAndUpdate.call(this); - - !notRefreshImmediately && this._zr.refreshImmediately(); - }; - - /** - * @DEPRECATED - */ - echartsProto.setTheme = function () { - console.log('ECharts#setTheme() is DEPRECATED in ECharts 3.0'); - }; - - /** - * @return {module:echarts/model/Global} - */ - echartsProto.getModel = function () { - return this._model; - }; - - /** - * @return {Object} - */ - echartsProto.getOption = function () { - return this._model.getOption(); - }; - - /** - * @return {number} - */ - echartsProto.getWidth = function () { - return this._zr.getWidth(); - }; - - /** - * @return {number} - */ - echartsProto.getHeight = function () { - return this._zr.getHeight(); - }; - - /** - * Get canvas which has all thing rendered - * @param {Object} opts - * @param {string} [opts.backgroundColor] - */ - echartsProto.getRenderedCanvas = function (opts) { - if (!env.canvasSupported) { - return; - } - opts = opts || {}; - opts.pixelRatio = opts.pixelRatio || 1; - opts.backgroundColor = opts.backgroundColor - || this._model.get('backgroundColor'); - var zr = this._zr; - var list = zr.storage.getDisplayList(); - // Stop animations - zrUtil.each(list, function (el) { - el.stopAnimation(true); - }); - return zr.painter.getRenderedCanvas(opts); - }; - /** - * @return {string} - * @param {Object} opts - * @param {string} [opts.type='png'] - * @param {string} [opts.pixelRatio=1] - * @param {string} [opts.backgroundColor] - */ - echartsProto.getDataURL = function (opts) { - opts = opts || {}; - var excludeComponents = opts.excludeComponents; - var ecModel = this._model; - var excludesComponentViews = []; - var self = this; - - each(excludeComponents, function (componentType) { - ecModel.eachComponent({ - mainType: componentType - }, function (component) { - var view = self._componentsMap[component.__viewId]; - if (!view.group.ignore) { - excludesComponentViews.push(view); - view.group.ignore = true; - } - }); - }); - - var url = this.getRenderedCanvas(opts).toDataURL( - 'image/' + (opts && opts.type || 'png') - ); - - each(excludesComponentViews, function (view) { - view.group.ignore = false; - }); - return url; - }; - - - /** - * @return {string} - * @param {Object} opts - * @param {string} [opts.type='png'] - * @param {string} [opts.pixelRatio=1] - * @param {string} [opts.backgroundColor] - */ - echartsProto.getConnectedDataURL = function (opts) { - if (!env.canvasSupported) { - return; - } - var groupId = this.group; - var mathMin = Math.min; - var mathMax = Math.max; - var MAX_NUMBER = Infinity; - if (connectedGroups[groupId]) { - var left = MAX_NUMBER; - var top = MAX_NUMBER; - var right = -MAX_NUMBER; - var bottom = -MAX_NUMBER; - var canvasList = []; - var dpr = (opts && opts.pixelRatio) || 1; - for (var id in instances) { - var chart = instances[id]; - if (chart.group === groupId) { - var canvas = chart.getRenderedCanvas( - zrUtil.clone(opts) - ); - var boundingRect = chart.getDom().getBoundingClientRect(); - left = mathMin(boundingRect.left, left); - top = mathMin(boundingRect.top, top); - right = mathMax(boundingRect.right, right); - bottom = mathMax(boundingRect.bottom, bottom); - canvasList.push({ - dom: canvas, - left: boundingRect.left, - top: boundingRect.top - }); - } - } - - left *= dpr; - top *= dpr; - right *= dpr; - bottom *= dpr; - var width = right - left; - var height = bottom - top; - var targetCanvas = zrUtil.createCanvas(); - targetCanvas.width = width; - targetCanvas.height = height; - var zr = zrender.init(targetCanvas); - - each(canvasList, function (item) { - var img = new graphic.Image({ - style: { - x: item.left * dpr - left, - y: item.top * dpr - top, - image: item.dom - } - }); - zr.add(img); - }); - zr.refreshImmediately(); - - return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png')); - } - else { - return this.getDataURL(opts); - } - }; - - var updateMethods = { - - /** - * @param {Object} payload - * @private - */ - update: function (payload) { - // console.time && console.time('update'); - - var ecModel = this._model; - var api = this._api; - var coordSysMgr = this._coordSysMgr; - // update before setOption - if (!ecModel) { - return; - } - - ecModel.restoreData(); - - // TODO - // Save total ecModel here for undo/redo (after restoring data and before processing data). - // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call. - - // Create new coordinate system each update - // In LineView may save the old coordinate system and use it to get the orignal point - coordSysMgr.create(this._model, this._api); - - processData.call(this, ecModel, api); - - stackSeriesData.call(this, ecModel); - - coordSysMgr.update(ecModel, api); - - doLayout.call(this, ecModel, payload); - - doVisualCoding.call(this, ecModel, payload); - - doRender.call(this, ecModel, payload); - - // Set background - var backgroundColor = ecModel.get('backgroundColor') || 'transparent'; - - var painter = this._zr.painter; - // TODO all use clearColor ? - if (painter.isSingleCanvas && painter.isSingleCanvas()) { - this._zr.configLayer(0, { - clearColor: backgroundColor - }); - } - else { - // In IE8 - if (!env.canvasSupported) { - var colorArr = colorTool.parse(backgroundColor); - backgroundColor = colorTool.stringify(colorArr, 'rgb'); - if (colorArr[3] === 0) { - backgroundColor = 'transparent'; - } - } - backgroundColor = backgroundColor; - this._dom.style.backgroundColor = backgroundColor; - } - - // console.time && console.timeEnd('update'); - }, - - // PENDING - /** - * @param {Object} payload - * @private - */ - updateView: function (payload) { - var ecModel = this._model; - - // update before setOption - if (!ecModel) { - return; - } - - doLayout.call(this, ecModel, payload); - - doVisualCoding.call(this, ecModel, payload); - - invokeUpdateMethod.call(this, 'updateView', ecModel, payload); - }, - - /** - * @param {Object} payload - * @private - */ - updateVisual: function (payload) { - var ecModel = this._model; - - // update before setOption - if (!ecModel) { - return; - } - - doVisualCoding.call(this, ecModel, payload); - - invokeUpdateMethod.call(this, 'updateVisual', ecModel, payload); - }, - - /** - * @param {Object} payload - * @private - */ - updateLayout: function (payload) { - var ecModel = this._model; - - // update before setOption - if (!ecModel) { - return; - } - - doLayout.call(this, ecModel, payload); - - invokeUpdateMethod.call(this, 'updateLayout', ecModel, payload); - }, - - /** - * @param {Object} payload - * @private - */ - highlight: function (payload) { - toggleHighlight.call(this, 'highlight', payload); - }, - - /** - * @param {Object} payload - * @private - */ - downplay: function (payload) { - toggleHighlight.call(this, 'downplay', payload); - }, - - /** - * @param {Object} payload - * @private - */ - prepareAndUpdate: function (payload) { - var ecModel = this._model; - - prepareView.call(this, 'component', ecModel); - - prepareView.call(this, 'chart', ecModel); - - updateMethods.update.call(this, payload); - } - }; - - /** - * @param {Object} payload - * @private - */ - function toggleHighlight(method, payload) { - var ecModel = this._model; - - // dispatchAction before setOption - if (!ecModel) { - return; - } - - ecModel.eachComponent( - {mainType: 'series', query: payload}, - function (seriesModel, index) { - var chartView = this._chartsMap[seriesModel.__viewId]; - if (chartView && chartView.__alive) { - chartView[method]( - seriesModel, ecModel, this._api, payload - ); - } - }, - this - ); - } - - /** - * Resize the chart - */ - echartsProto.resize = function () { - this._zr.resize(); - - var optionChanged = this._model && this._model.resetOption('media'); - updateMethods[optionChanged ? 'prepareAndUpdate' : 'update'].call(this); - - // Resize loading effect - this._loadingFX && this._loadingFX.resize(); - }; - - var defaultLoadingEffect = require('./loading/default'); - /** - * Show loading effect - * @param {string} [name='default'] - * @param {Object} [cfg] - */ - echartsProto.showLoading = function (name, cfg) { - if (zrUtil.isObject(name)) { - cfg = name; - name = 'default'; - } - var el = defaultLoadingEffect(this._api, cfg); - var zr = this._zr; - this._loadingFX = el; - - zr.add(el); - }; - - /** - * Hide loading effect - */ - echartsProto.hideLoading = function () { - this._loadingFX && this._zr.remove(this._loadingFX); - this._loadingFX = null; - }; - - /** - * @param {Object} eventObj - * @return {Object} - */ - echartsProto.makeActionFromEvent = function (eventObj) { - var payload = zrUtil.extend({}, eventObj); - payload.type = eventActionMap[eventObj.type]; - return payload; - }; - - /** - * @pubilc - * @param {Object} payload - * @param {string} [payload.type] Action type - * @param {boolean} [silent=false] Whether trigger event. - */ - echartsProto.dispatchAction = function (payload, silent) { - var actionWrap = actions[payload.type]; - if (actionWrap) { - var actionInfo = actionWrap.actionInfo; - var updateMethod = actionInfo.update || 'update'; - - var payloads = [payload]; - var batched = false; - // Batch action - if (payload.batch) { - batched = true; - payloads = zrUtil.map(payload.batch, function (item) { - item = zrUtil.defaults(zrUtil.extend({}, item), payload); - item.batch = null; - return item; - }); - } - - var eventObjBatch = []; - var eventObj; - var isHighlightOrDownplay = payload.type === 'highlight' || payload.type === 'downplay'; - for (var i = 0; i < payloads.length; i++) { - var batchItem = payloads[i]; - // Action can specify the event by return it. - eventObj = actionWrap.action(batchItem, this._model); - // Emit event outside - eventObj = eventObj || zrUtil.extend({}, batchItem); - // Convert type to eventType - eventObj.type = actionInfo.event || eventObj.type; - eventObjBatch.push(eventObj); - - // Highlight and downplay are special. - isHighlightOrDownplay && updateMethods[updateMethod].call(this, batchItem); - } - - (updateMethod !== 'none' && !isHighlightOrDownplay) - && updateMethods[updateMethod].call(this, payload); - if (!silent) { - // Follow the rule of action batch - if (batched) { - eventObj = { - type: eventObjBatch[0].type, - batch: eventObjBatch - }; - } - else { - eventObj = eventObjBatch[0]; - } - this._messageCenter.trigger(eventObj.type, eventObj); - } - } - }; - - /** - * Register event - * @method - */ - echartsProto.on = createRegisterEventWithLowercaseName('on'); - echartsProto.off = createRegisterEventWithLowercaseName('off'); - echartsProto.one = createRegisterEventWithLowercaseName('one'); - - /** - * @param {string} methodName - * @private - */ - function invokeUpdateMethod(methodName, ecModel, payload) { - var api = this._api; - - // Update all components - each(this._componentsViews, function (component) { - var componentModel = component.__model; - component[methodName](componentModel, ecModel, api, payload); - - updateZ(componentModel, component); - }, this); - - // Upate all charts - ecModel.eachSeries(function (seriesModel, idx) { - var chart = this._chartsMap[seriesModel.__viewId]; - chart[methodName](seriesModel, ecModel, api, payload); - - updateZ(seriesModel, chart); - }, this); - - } - - /** - * Prepare view instances of charts and components - * @param {module:echarts/model/Global} ecModel - * @private - */ - function prepareView(type, ecModel) { - var isComponent = type === 'component'; - var viewList = isComponent ? this._componentsViews : this._chartsViews; - var viewMap = isComponent ? this._componentsMap : this._chartsMap; - var zr = this._zr; - - for (var i = 0; i < viewList.length; i++) { - viewList[i].__alive = false; - } - - ecModel[isComponent ? 'eachComponent' : 'eachSeries'](function (componentType, model) { - if (isComponent) { - if (componentType === 'series') { - return; - } - } - else { - model = componentType; - } - - // Consider: id same and type changed. - var viewId = model.id + '_' + model.type; - var view = viewMap[viewId]; - if (!view) { - var classType = ComponentModel.parseClassType(model.type); - var Clazz = isComponent - ? ComponentView.getClass(classType.main, classType.sub) - : ChartView.getClass(classType.sub); - if (Clazz) { - view = new Clazz(); - view.init(ecModel, this._api); - viewMap[viewId] = view; - viewList.push(view); - zr.add(view.group); - } - else { - // Error - return; - } - } - - model.__viewId = viewId; - view.__alive = true; - view.__id = viewId; - view.__model = model; - }, this); - - for (var i = 0; i < viewList.length;) { - var view = viewList[i]; - if (!view.__alive) { - zr.remove(view.group); - view.dispose(ecModel, this._api); - viewList.splice(i, 1); - delete viewMap[view.__id]; - } - else { - i++; - } - } - } - - /** - * Processor data in each series - * - * @param {module:echarts/model/Global} ecModel - * @private - */ - function processData(ecModel, api) { - each(PROCESSOR_STAGES, function (stage) { - each(dataProcessorFuncs[stage] || [], function (process) { - process(ecModel, api); - }); - }); - } - - /** - * @private - */ - function stackSeriesData(ecModel) { - var stackedDataMap = {}; - ecModel.eachSeries(function (series) { - var stack = series.get('stack'); - var data = series.getData(); - if (stack && data.type === 'list') { - var previousStack = stackedDataMap[stack]; - if (previousStack) { - data.stackedOn = previousStack; - } - stackedDataMap[stack] = data; - } - }); - } - - /** - * Layout before each chart render there series, after visual coding and data processing - * - * @param {module:echarts/model/Global} ecModel - * @private - */ - function doLayout(ecModel, payload) { - var api = this._api; - each(layoutFuncs, function (layout) { - layout(ecModel, api, payload); - }); - } - - /** - * Code visual infomation from data after data processing - * - * @param {module:echarts/model/Global} ecModel - * @private - */ - function doVisualCoding(ecModel, payload) { - each(VISUAL_CODING_STAGES, function (stage) { - each(visualCodingFuncs[stage] || [], function (visualCoding) { - visualCoding(ecModel, payload); - }); - }); - } - - /** - * Render each chart and component - * @private - */ - function doRender(ecModel, payload) { - var api = this._api; - // Render all components - each(this._componentsViews, function (componentView) { - var componentModel = componentView.__model; - componentView.render(componentModel, ecModel, api, payload); - - updateZ(componentModel, componentView); - }, this); - - each(this._chartsViews, function (chart) { - chart.__alive = false; - }, this); - - // Render all charts - ecModel.eachSeries(function (seriesModel, idx) { - var chartView = this._chartsMap[seriesModel.__viewId]; - chartView.__alive = true; - chartView.render(seriesModel, ecModel, api, payload); - - updateZ(seriesModel, chartView); - }, this); - - // Remove groups of unrendered charts - each(this._chartsViews, function (chart) { - if (!chart.__alive) { - chart.remove(ecModel, api); - } - }, this); - } - - var MOUSE_EVENT_NAMES = [ - 'click', 'dblclick', 'mouseover', 'mouseout', 'globalout' - ]; - /** - * @private - */ - echartsProto._initEvents = function () { - var zr = this._zr; - each(MOUSE_EVENT_NAMES, function (eveName) { - zr.on(eveName, function (e) { - var ecModel = this.getModel(); - var el = e.target; - if (el && el.dataIndex != null) { - var hostModel = el.hostModel || ecModel.getSeriesByIndex(el.seriesIndex); - var params = hostModel && hostModel.getDataParams(el.dataIndex) || {}; - params.event = e; - params.type = eveName; - this.trigger(eveName, params); - } - }, this); - }, this); - - each(eventActionMap, function (actionType, eventType) { - this._messageCenter.on(eventType, function (event) { - this.trigger(eventType, event); - }, this); - }, this); - }; - - /** - * @return {boolean} - */ - echartsProto.isDisposed = function () { - return this._disposed; - }; - - /** - * Clear - */ - echartsProto.clear = function () { - this.setOption({}, true); - }; - /** - * Dispose instance - */ - echartsProto.dispose = function () { - this._disposed = true; - var api = this._api; - var ecModel = this._model; - - each(this._componentsViews, function (component) { - component.dispose(ecModel, api); - }); - each(this._chartsViews, function (chart) { - chart.dispose(ecModel, api); - }); - - this._zr.dispose(); - - instances[this.id] = null; - }; - - zrUtil.mixin(ECharts, Eventful); - - /** - * @param {module:echarts/model/Series|module:echarts/model/Component} model - * @param {module:echarts/view/Component|module:echarts/view/Chart} view - * @return {string} - */ - function updateZ(model, view) { - var z = model.get('z'); - var zlevel = model.get('zlevel'); - // Set z and zlevel - view.group.traverse(function (el) { - z != null && (el.z = z); - zlevel != null && (el.zlevel = zlevel); - }); - } - /** - * @type {Array.} - * @inner - */ - var actions = []; - - /** - * Map eventType to actionType - * @type {Object} - */ - var eventActionMap = {}; - - /** - * @type {Array.} - * @inner - */ - var layoutFuncs = []; - - /** - * Data processor functions of each stage - * @type {Array.>} - * @inner - */ - var dataProcessorFuncs = {}; - - /** - * @type {Array.} - * @inner - */ - var optionPreprocessorFuncs = []; - - /** - * Visual coding functions of each stage - * @type {Array.>} - * @inner - */ - var visualCodingFuncs = {}; - /** - * Theme storage - * @type {Object.} - */ - var themeStorage = {}; - - - var instances = {}; - var connectedGroups = {}; - - var idBase = new Date() - 0; - var groupIdBase = new Date() - 0; - var DOM_ATTRIBUTE_KEY = '_echarts_instance_'; - /** - * @alias module:echarts - */ - var echarts = { - /** - * @type {number} - */ - version: '3.1.2', - dependencies: { - zrender: '3.0.3' - } - }; - - function enableConnect(chart) { - - var STATUS_PENDING = 0; - var STATUS_UPDATING = 1; - var STATUS_UPDATED = 2; - var STATUS_KEY = '__connectUpdateStatus'; - function updateConnectedChartsStatus(charts, status) { - for (var i = 0; i < charts.length; i++) { - var otherChart = charts[i]; - otherChart[STATUS_KEY] = status; - } - } - zrUtil.each(eventActionMap, function (actionType, eventType) { - chart._messageCenter.on(eventType, function (event) { - if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) { - var action = chart.makeActionFromEvent(event); - var otherCharts = []; - for (var id in instances) { - var otherChart = instances[id]; - if (otherChart !== chart && otherChart.group === chart.group) { - otherCharts.push(otherChart); - } - } - updateConnectedChartsStatus(otherCharts, STATUS_PENDING); - each(otherCharts, function (otherChart) { - if (otherChart[STATUS_KEY] !== STATUS_UPDATING) { - otherChart.dispatchAction(action); - } - }); - updateConnectedChartsStatus(otherCharts, STATUS_UPDATED); - } - }); - }); - - } - /** - * @param {HTMLDomElement} dom - * @param {Object} [theme] - * @param {Object} opts - */ - echarts.init = function (dom, theme, opts) { - // Check version - if ((zrender.version.replace('.', '') - 0) < (echarts.dependencies.zrender.replace('.', '') - 0)) { - throw new Error( - 'ZRender ' + zrender.version - + ' is too old for ECharts ' + echarts.version - + '. Current version need ZRender ' - + echarts.dependencies.zrender + '+' - ); - } - if (!dom) { - throw new Error('Initialize failed: invalid dom.'); - } - - var chart = new ECharts(dom, theme, opts); - chart.id = 'ec_' + idBase++; - instances[chart.id] = chart; - - dom.setAttribute && - dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id); - - enableConnect(chart); - - return chart; - }; - - /** - * @return {string|Array.} groupId - */ - echarts.connect = function (groupId) { - // Is array of charts - if (zrUtil.isArray(groupId)) { - var charts = groupId; - groupId = null; - // If any chart has group - zrUtil.each(charts, function (chart) { - if (chart.group != null) { - groupId = chart.group; - } - }); - groupId = groupId || ('g_' + groupIdBase++); - zrUtil.each(charts, function (chart) { - chart.group = groupId; - }); - } - connectedGroups[groupId] = true; - return groupId; - }; - - /** - * @return {string} groupId - */ - echarts.disConnect = function (groupId) { - connectedGroups[groupId] = false; - }; - - /** - * Dispose a chart instance - * @param {module:echarts~ECharts|HTMLDomElement|string} chart - */ - echarts.dispose = function (chart) { - if (zrUtil.isDom(chart)) { - chart = echarts.getInstanceByDom(chart); - } - else if (typeof chart === 'string') { - chart = instances[chart]; - } - if ((chart instanceof ECharts) && !chart.isDisposed()) { - chart.dispose(); - } - }; - - /** - * @param {HTMLDomElement} dom - * @return {echarts~ECharts} - */ - echarts.getInstanceByDom = function (dom) { - var key = dom.getAttribute(DOM_ATTRIBUTE_KEY); - return instances[key]; - }; - /** - * @param {string} key - * @return {echarts~ECharts} - */ - echarts.getInstanceById = function (key) { - return instances[key]; - }; - - /** - * Register theme - */ - echarts.registerTheme = function (name, theme) { - themeStorage[name] = theme; - }; - - /** - * Register option preprocessor - * @param {Function} preprocessorFunc - */ - echarts.registerPreprocessor = function (preprocessorFunc) { - optionPreprocessorFuncs.push(preprocessorFunc); - }; - - /** - * @param {string} stage - * @param {Function} processorFunc - */ - echarts.registerProcessor = function (stage, processorFunc) { - if (zrUtil.indexOf(PROCESSOR_STAGES, stage) < 0) { - throw new Error('stage should be one of ' + PROCESSOR_STAGES); - } - var funcs = dataProcessorFuncs[stage] || (dataProcessorFuncs[stage] = []); - funcs.push(processorFunc); - }; - - /** - * Usage: - * registerAction('someAction', 'someEvent', function () { ... }); - * registerAction('someAction', function () { ... }); - * registerAction( - * {type: 'someAction', event: 'someEvent', update: 'updateView'}, - * function () { ... } - * ); - * - * @param {(string|Object)} actionInfo - * @param {string} actionInfo.type - * @param {string} [actionInfo.event] - * @param {string} [actionInfo.update] - * @param {string} [eventName] - * @param {Function} action - */ - echarts.registerAction = function (actionInfo, eventName, action) { - if (typeof eventName === 'function') { - action = eventName; - eventName = ''; - } - var actionType = zrUtil.isObject(actionInfo) - ? actionInfo.type - : ([actionInfo, actionInfo = { - event: eventName - }][0]); - - // Event name is all lowercase - actionInfo.event = (actionInfo.event || actionType).toLowerCase(); - eventName = actionInfo.event; - - if (!actions[actionType]) { - actions[actionType] = {action: action, actionInfo: actionInfo}; - } - eventActionMap[eventName] = actionType; - }; - - /** - * @param {string} type - * @param {*} CoordinateSystem - */ - echarts.registerCoordinateSystem = function (type, CoordinateSystem) { - CoordinateSystemManager.register(type, CoordinateSystem); - }; - - /** - * @param {*} layout - */ - echarts.registerLayout = function (layout) { - // PENDING All functions ? - if (zrUtil.indexOf(layoutFuncs, layout) < 0) { - layoutFuncs.push(layout); - } - }; - - /** - * @param {string} stage - * @param {Function} visualCodingFunc - */ - echarts.registerVisualCoding = function (stage, visualCodingFunc) { - if (zrUtil.indexOf(VISUAL_CODING_STAGES, stage) < 0) { - throw new Error('stage should be one of ' + VISUAL_CODING_STAGES); - } - var funcs = visualCodingFuncs[stage] || (visualCodingFuncs[stage] = []); - funcs.push(visualCodingFunc); - }; - - /** - * @param {Object} opts - */ - echarts.extendChartView = function (opts) { - return ChartView.extend(opts); - }; - - /** - * @param {Object} opts - */ - echarts.extendComponentModel = function (opts) { - return ComponentModel.extend(opts); - }; - - /** - * @param {Object} opts - */ - echarts.extendSeriesModel = function (opts) { - return SeriesModel.extend(opts); - }; - - /** - * @param {Object} opts - */ - echarts.extendComponentView = function (opts) { - return ComponentView.extend(opts); - }; - - /** - * ZRender need a canvas context to do measureText. - * But in node environment canvas may be created by node-canvas. - * So we need to specify how to create a canvas instead of using document.createElement('canvas') - * - * Be careful of using it in the browser. - * - * @param {Function} creator - * @example - * var Canvas = require('canvas'); - * var echarts = require('echarts'); - * echarts.setCanvasCreator(function () { - * // Small size is enough. - * return new Canvas(32, 32); - * }); - */ - echarts.setCanvasCreator = function (creator) { - zrUtil.createCanvas = creator; - }; - - echarts.registerVisualCoding('echarts', zrUtil.curry( - require('./visual/seriesColor'), '', 'itemStyle' - )); - echarts.registerPreprocessor(require('./preprocessor/backwardCompat')); - - // Default action - echarts.registerAction({ - type: 'highlight', - event: 'highlight', - update: 'highlight' - }, zrUtil.noop); - echarts.registerAction({ - type: 'downplay', - event: 'downplay', - update: 'downplay' - }, zrUtil.noop); - - - // -------- - // Exports - // -------- - - echarts.graphic = require('./util/graphic'); - echarts.number = require('./util/number'); - echarts.format = require('./util/format'); - echarts.matrix = require('zrender/core/matrix'); - echarts.vector = require('zrender/core/vector'); - - echarts.util = {}; - each([ - 'map', 'each', 'filter', 'indexOf', 'inherits', - 'reduce', 'filter', 'bind', 'curry', 'isArray', - 'isString', 'isObject', 'isFunction', 'extend' - ], - function (name) { - echarts.util[name] = zrUtil[name]; - } - ); - - return echarts; -}); -define('echarts', ['echarts/echarts'], function (main) { return main; }); - -define('echarts/data/DataDiffer',['require'],function(require) { - - - function defaultKeyGetter(item) { - return item; - } - - function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter) { - this._old = oldArr; - this._new = newArr; - - this._oldKeyGetter = oldKeyGetter || defaultKeyGetter; - this._newKeyGetter = newKeyGetter || defaultKeyGetter; - } - - DataDiffer.prototype = { - - constructor: DataDiffer, - - /** - * Callback function when add a data - */ - add: function (func) { - this._add = func; - return this; - }, - - /** - * Callback function when update a data - */ - update: function (func) { - this._update = func; - return this; - }, - - /** - * Callback function when remove a data - */ - remove: function (func) { - this._remove = func; - return this; - }, - - execute: function () { - var oldArr = this._old; - var newArr = this._new; - var oldKeyGetter = this._oldKeyGetter; - var newKeyGetter = this._newKeyGetter; - - var oldDataIndexMap = {}; - var newDataIndexMap = {}; - var i; - - initIndexMap(oldArr, oldDataIndexMap, oldKeyGetter); - initIndexMap(newArr, newDataIndexMap, newKeyGetter); - - // Travel by inverted order to make sure order consistency - // when duplicate keys exists (consider newDataIndex.pop() below). - // For performance consideration, these code below do not look neat. - for (i = 0; i < oldArr.length; i++) { - var key = oldKeyGetter(oldArr[i]); - var idx = newDataIndexMap[key]; - - // idx can never be empty array here. see 'set null' logic below. - if (idx != null) { - // Consider there is duplicate key (for example, use dataItem.name as key). - // We should make sure every item in newArr and oldArr can be visited. - var len = idx.length; - if (len) { - len === 1 && (newDataIndexMap[key] = null); - idx = idx.unshift(); - } - else { - newDataIndexMap[key] = null; - } - this._update && this._update(idx, i); - } - else { - this._remove && this._remove(i); - } - } - - for (var key in newDataIndexMap) { - if (newDataIndexMap.hasOwnProperty(key)) { - var idx = newDataIndexMap[key]; - if (idx == null) { - continue; - } - // idx can never be empty array here. see 'set null' logic above. - if (!idx.length) { - this._add && this._add(idx); - } - else { - for (var i = 0, len = idx.length; i < len; i++) { - this._add && this._add(idx[i]); - } - } - } - } - } - }; - - function initIndexMap(arr, map, keyGetter) { - for (var i = 0; i < arr.length; i++) { - var key = keyGetter(arr[i]); - var existence = map[key]; - if (existence == null) { - map[key] = i; - } - else { - if (!existence.length) { - map[key] = existence = [existence]; - } - existence.push(i); - } - } - } - - return DataDiffer; -}); -/** - * List for data storage - * @module echarts/data/List - */ -define('echarts/data/List',['require','../model/Model','./DataDiffer','zrender/core/util','../util/model'],function (require) { - - var UNDEFINED = 'undefined'; - var globalObj = typeof window === 'undefined' ? global : window; - var Float64Array = typeof globalObj.Float64Array === UNDEFINED - ? Array : globalObj.Float64Array; - var Int32Array = typeof globalObj.Int32Array === UNDEFINED - ? Array : globalObj.Int32Array; - - var dataCtors = { - 'float': Float64Array, - 'int': Int32Array, - // Ordinal data type can be string or int - 'ordinal': Array, - 'number': Array, - 'time': Array - }; - - var Model = require('../model/Model'); - var DataDiffer = require('./DataDiffer'); - - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../util/model'); - var isObject = zrUtil.isObject; - - var IMMUTABLE_PROPERTIES = [ - 'stackedOn', '_nameList', '_idList', '_rawData' - ]; - - var transferImmuProperties = function (a, b, wrappedMethod) { - zrUtil.each(IMMUTABLE_PROPERTIES.concat(wrappedMethod || []), function (propName) { - if (b.hasOwnProperty(propName)) { - a[propName] = b[propName]; - } - }); - }; - - /** - * @constructor - * @alias module:echarts/data/List - * - * @param {Array.} dimensions - * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius - * @param {module:echarts/model/Model} hostModel - */ - var List = function (dimensions, hostModel) { - - dimensions = dimensions || ['x', 'y']; - - var dimensionInfos = {}; - var dimensionNames = []; - for (var i = 0; i < dimensions.length; i++) { - var dimensionName; - var dimensionInfo = {}; - if (typeof dimensions[i] === 'string') { - dimensionName = dimensions[i]; - dimensionInfo = { - name: dimensionName, - stackable: false, - // Type can be 'float', 'int', 'number' - // Default is number, Precision of float may not enough - type: 'number' - }; - } - else { - dimensionInfo = dimensions[i]; - dimensionName = dimensionInfo.name; - dimensionInfo.type = dimensionInfo.type || 'number'; - } - dimensionNames.push(dimensionName); - dimensionInfos[dimensionName] = dimensionInfo; - } - /** - * @readOnly - * @type {Array.} - */ - this.dimensions = dimensionNames; - - /** - * Infomation of each data dimension, like data type. - * @type {Object} - */ - this._dimensionInfos = dimensionInfos; - - /** - * @type {module:echarts/model/Model} - */ - this.hostModel = hostModel; - - /** - * Indices stores the indices of data subset after filtered. - * This data subset will be used in chart. - * @type {Array.} - * @readOnly - */ - this.indices = []; - - /** - * Data storage - * @type {Object.} - * @private - */ - this._storage = {}; - - /** - * @type {Array.} - */ - this._nameList = []; - /** - * @type {Array.} - */ - this._idList = []; - /** - * Models of data option is stored sparse for optimizing memory cost - * @type {Array.} - * @private - */ - this._optionModels = []; - - /** - * @param {module:echarts/data/List} - */ - this.stackedOn = null; - - /** - * Global visual properties after visual coding - * @type {Object} - * @private - */ - this._visual = {}; - - /** - * Globel layout properties. - * @type {Object} - * @private - */ - this._layout = {}; - - /** - * Item visual properties after visual coding - * @type {Array.} - * @private - */ - this._itemVisuals = []; - - /** - * Item layout properties after layout - * @type {Array.} - * @private - */ - this._itemLayouts = []; - - /** - * Graphic elemnents - * @type {Array.} - * @private - */ - this._graphicEls = []; - - /** - * @type {Array.} - * @private - */ - this._rawData; - - /** - * @type {Object} - * @private - */ - this._extent; - }; - - var listProto = List.prototype; - - listProto.type = 'list'; - - /** - * Get dimension name - * @param {string|number} dim - * Dimension can be concrete names like x, y, z, lng, lat, angle, radius - * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius' - */ - listProto.getDimension = function (dim) { - if (!isNaN(dim)) { - dim = this.dimensions[dim] || dim; - } - return dim; - }; - /** - * Get type and stackable info of particular dimension - * @param {string|number} dim - * Dimension can be concrete names like x, y, z, lng, lat, angle, radius - * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius' - */ - listProto.getDimensionInfo = function (dim) { - return zrUtil.clone(this._dimensionInfos[this.getDimension(dim)]); - }; - - /** - * Initialize from data - * @param {Array.} data - * @param {Array.} [nameList] - * @param {Function} [dimValueGetter] (dataItem, dimName, dataIndex, dimIndex) => number - */ - listProto.initData = function (data, nameList, dimValueGetter) { - data = data || []; - - this._rawData = data; - - // Clear - var storage = this._storage = {}; - var indices = this.indices = []; - - var dimensions = this.dimensions; - var size = data.length; - var dimensionInfoMap = this._dimensionInfos; - - var idList = []; - var nameRepeatCount = {}; - - nameList = nameList || []; - - // Init storage - for (var i = 0; i < dimensions.length; i++) { - var dimInfo = dimensionInfoMap[dimensions[i]]; - var DataCtor = dataCtors[dimInfo.type]; - storage[dimensions[i]] = new DataCtor(size); - } - - // Default dim value getter - dimValueGetter = dimValueGetter || function (dataItem, dimName, dataIndex, dimIndex) { - var value = modelUtil.getDataItemValue(dataItem); - return modelUtil.converDataValue( - zrUtil.isArray(value) - ? value[dimIndex] - // If value is a single number or something else not array. - : value, - dimensionInfoMap[dimName] - ); - }; - - for (var idx = 0; idx < data.length; idx++) { - var dataItem = data[idx]; - // Each data item is value - // [1, 2] - // 2 - // Bar chart, line chart which uses category axis - // only gives the 'y' value. 'x' value is the indices of cateogry - // Use a tempValue to normalize the value to be a (x, y) value - - // Store the data by dimensions - for (var k = 0; k < dimensions.length; k++) { - var dim = dimensions[k]; - var dimStorage = storage[dim]; - // PENDING NULL is empty or zero - dimStorage[idx] = dimValueGetter(dataItem, dim, idx, k); - } - - indices.push(idx); - } - - // Use the name in option and create id - for (var i = 0; i < data.length; i++) { - var id = ''; - if (!nameList[i]) { - nameList[i] = data[i].name; - // Try using the id in option - id = data[i].id; - } - var name = nameList[i] || ''; - if (!id && name) { - // Use name as id and add counter to avoid same name - nameRepeatCount[name] = nameRepeatCount[name] || 0; - id = name; - if (nameRepeatCount[name] > 0) { - id += '__ec__' + nameRepeatCount[name]; - } - nameRepeatCount[name]++; - } - id && (idList[i] = id); - } - - this._nameList = nameList; - this._idList = idList; - }; - - /** - * @return {number} - */ - listProto.count = function () { - return this.indices.length; - }; - - /** - * Get value - * @param {string} dim Dim must be concrete name. - * @param {number} idx - * @param {boolean} stack - * @return {number} - */ - listProto.get = function (dim, idx, stack) { - var storage = this._storage; - var dataIndex = this.indices[idx]; - - var value = storage[dim] && storage[dim][dataIndex]; - // FIXME ordinal data type is not stackable - if (stack) { - var dimensionInfo = this._dimensionInfos[dim]; - if (dimensionInfo && dimensionInfo.stackable) { - var stackedOn = this.stackedOn; - while (stackedOn) { - // Get no stacked data of stacked on - var stackedValue = stackedOn.get(dim, idx); - // Considering positive stack, negative stack and empty data - if ((value >= 0 && stackedValue > 0) // Positive stack - || (value <= 0 && stackedValue < 0) // Negative stack - ) { - value += stackedValue; - } - stackedOn = stackedOn.stackedOn; - } - } - } - return value; - }; - - /** - * Get value for multi dimensions. - * @param {Array.} [dimensions] If ignored, using all dimensions. - * @param {number} idx - * @param {boolean} stack - * @return {number} - */ - listProto.getValues = function (dimensions, idx, stack) { - var values = []; - - if (!zrUtil.isArray(dimensions)) { - stack = idx; - idx = dimensions; - dimensions = this.dimensions; - } - - for (var i = 0, len = dimensions.length; i < len; i++) { - values.push(this.get(dimensions[i], idx, stack)); - } - - return values; - }; - - /** - * If value is NaN. Inlcuding '-' - * @param {string} dim - * @param {number} idx - * @return {number} - */ - listProto.hasValue = function (idx) { - var dimensions = this.dimensions; - var dimensionInfos = this._dimensionInfos; - for (var i = 0, len = dimensions.length; i < len; i++) { - if ( - // Ordinal type can be string or number - dimensionInfos[dimensions[i]].type !== 'ordinal' - && isNaN(this.get(dimensions[i], idx)) - ) { - return false; - } - } - return true; - }; - - /** - * Get extent of data in one dimension - * @param {string} dim - * @param {boolean} stack - */ - listProto.getDataExtent = function (dim, stack) { - var dimData = this._storage[dim]; - var dimInfo = this.getDimensionInfo(dim); - stack = (dimInfo && dimInfo.stackable) && stack; - var dimExtent = (this._extent || (this._extent = {}))[dim + (!!stack)]; - var value; - if (dimExtent) { - return dimExtent; - } - // var dimInfo = this._dimensionInfos[dim]; - if (dimData) { - var min = Infinity; - var max = -Infinity; - // var isOrdinal = dimInfo.type === 'ordinal'; - for (var i = 0, len = this.count(); i < len; i++) { - value = this.get(dim, i, stack); - // FIXME - // if (isOrdinal && typeof value === 'string') { - // value = zrUtil.indexOf(dimData, value); - // console.log(value); - // } - value < min && (min = value); - value > max && (max = value); - } - return (this._extent[dim + stack] = [min, max]); - } - else { - return [Infinity, -Infinity]; - } - }; - - /** - * Get sum of data in one dimension - * @param {string} dim - * @param {boolean} stack - */ - listProto.getSum = function (dim, stack) { - var dimData = this._storage[dim]; - var sum = 0; - if (dimData) { - for (var i = 0, len = this.count(); i < len; i++) { - var value = this.get(dim, i, stack); - if (!isNaN(value)) { - sum += value; - } - } - } - return sum; - }; - - /** - * Retreive the index with given value - * @param {number} idx - * @param {number} value - * @return {number} - */ - // FIXME Precision of float value - listProto.indexOf = function (dim, value) { - var storage = this._storage; - var dimData = storage[dim]; - var indices = this.indices; - - if (dimData) { - for (var i = 0, len = indices.length; i < len; i++) { - var rawIndex = indices[i]; - if (dimData[rawIndex] === value) { - return i; - } - } - } - return -1; - }; - - /** - * Retreive the index with given name - * @param {number} idx - * @param {number} name - * @return {number} - */ - listProto.indexOfName = function (name) { - var indices = this.indices; - var nameList = this._nameList; - - for (var i = 0, len = indices.length; i < len; i++) { - var rawIndex = indices[i]; - if (nameList[rawIndex] === name) { - return i; - } - } - - return -1; - }; - - /** - * Retreive the index of nearest value - * @param {string>} dim - * @param {number} value - * @param {boolean} stack If given value is after stacked - * @return {number} - */ - listProto.indexOfNearest = function (dim, value, stack) { - var storage = this._storage; - var dimData = storage[dim]; - - if (dimData) { - var minDist = Number.MAX_VALUE; - var nearestIdx = -1; - for (var i = 0, len = this.count(); i < len; i++) { - var dist = Math.abs(this.get(dim, i, stack) - value); - if (dist <= minDist) { - minDist = dist; - nearestIdx = i; - } - } - return nearestIdx; - } - return -1; - }; - - /** - * Get raw data index - * @param {number} idx - * @return {number} - */ - listProto.getRawIndex = function (idx) { - var rawIdx = this.indices[idx]; - return rawIdx == null ? -1 : rawIdx; - }; - - /** - * @param {number} idx - * @param {boolean} [notDefaultIdx=false] - * @return {string} - */ - listProto.getName = function (idx) { - return this._nameList[this.indices[idx]] || ''; - }; - - /** - * @param {number} idx - * @param {boolean} [notDefaultIdx=false] - * @return {string} - */ - listProto.getId = function (idx) { - return this._idList[this.indices[idx]] || (this.getRawIndex(idx) + ''); - }; - - - function normalizeDimensions(dimensions) { - if (!zrUtil.isArray(dimensions)) { - dimensions = [dimensions]; - } - return dimensions; - } - - /** - * Data iteration - * @param {string|Array.} - * @param {Function} cb - * @param {boolean} [stack=false] - * @param {*} [context=this] - * - * @example - * list.each('x', function (x, idx) {}); - * list.each(['x', 'y'], function (x, y, idx) {}); - * list.each(function (idx) {}) - */ - listProto.each = function (dimensions, cb, stack, context) { - if (typeof dimensions === 'function') { - context = stack; - stack = cb; - cb = dimensions; - dimensions = []; - } - - dimensions = zrUtil.map( - normalizeDimensions(dimensions), this.getDimension, this - ); - - var value = []; - var dimSize = dimensions.length; - var indices = this.indices; - - context = context || this; - - for (var i = 0; i < indices.length; i++) { - if (dimSize === 0) { - cb.call(context, i); - } - // Simple optimization - else if (dimSize === 1) { - cb.call(context, this.get(dimensions[0], i, stack), i); - } - else { - for (var k = 0; k < dimSize; k++) { - value[k] = this.get(dimensions[k], i, stack); - } - // Index - value[k] = i; - cb.apply(context, value); - } - } - }; - - /** - * Data filter - * @param {string|Array.} - * @param {Function} cb - * @param {boolean} [stack=false] - * @param {*} [context=this] - */ - listProto.filterSelf = function (dimensions, cb, stack, context) { - if (typeof dimensions === 'function') { - context = stack; - stack = cb; - cb = dimensions; - dimensions = []; - } - - dimensions = zrUtil.map( - normalizeDimensions(dimensions), this.getDimension, this - ); - - var newIndices = []; - var value = []; - var dimSize = dimensions.length; - var indices = this.indices; - - context = context || this; - - for (var i = 0; i < indices.length; i++) { - var keep; - // Simple optimization - if (dimSize === 1) { - keep = cb.call( - context, this.get(dimensions[0], i, stack), i - ); - } - else { - for (var k = 0; k < dimSize; k++) { - value[k] = this.get(dimensions[k], i, stack); - } - value[k] = i; - keep = cb.apply(context, value); - } - if (keep) { - newIndices.push(indices[i]); - } - } - - this.indices = newIndices; - - // Reset data extent - this._extent = {}; - - return this; - }; - - /** - * Data mapping to a plain array - * @param {string|Array.} [dimensions] - * @param {Function} cb - * @param {boolean} [stack=false] - * @param {*} [context=this] - * @return {Array} - */ - listProto.mapArray = function (dimensions, cb, stack, context) { - if (typeof dimensions === 'function') { - context = stack; - stack = cb; - cb = dimensions; - dimensions = []; - } - - var result = []; - this.each(dimensions, function () { - result.push(cb && cb.apply(this, arguments)); - }, stack, context); - return result; - }; - - function cloneListForMapAndSample(original, excludeDimensions) { - var allDimensions = original.dimensions; - var list = new List( - zrUtil.map(allDimensions, original.getDimensionInfo, original), - original.hostModel - ); - // FIXME If needs stackedOn, value may already been stacked - transferImmuProperties(list, original, original._wrappedMethods); - - var storage = list._storage = {}; - var originalStorage = original._storage; - // Init storage - for (var i = 0; i < allDimensions.length; i++) { - var dim = allDimensions[i]; - var dimStore = originalStorage[dim]; - if (zrUtil.indexOf(excludeDimensions, dim) >= 0) { - storage[dim] = new dimStore.constructor( - originalStorage[dim].length - ); - } - else { - // Direct reference for other dimensions - storage[dim] = originalStorage[dim]; - } - } - return list; - } - - /** - * Data mapping to a new List with given dimensions - * @param {string|Array.} dimensions - * @param {Function} cb - * @param {boolean} [stack=false] - * @param {*} [context=this] - * @return {Array} - */ - listProto.map = function (dimensions, cb, stack, context) { - dimensions = zrUtil.map( - normalizeDimensions(dimensions), this.getDimension, this - ); - - var list = cloneListForMapAndSample(this, dimensions); - // Following properties are all immutable. - // So we can reference to the same value - var indices = list.indices = this.indices; - - var storage = list._storage; - - var tmpRetValue = []; - this.each(dimensions, function () { - var idx = arguments[arguments.length - 1]; - var retValue = cb && cb.apply(this, arguments); - if (retValue != null) { - // a number - if (typeof retValue === 'number') { - tmpRetValue[0] = retValue; - retValue = tmpRetValue; - } - for (var i = 0; i < retValue.length; i++) { - var dim = dimensions[i]; - var dimStore = storage[dim]; - var rawIdx = indices[idx]; - if (dimStore) { - dimStore[rawIdx] = retValue[i]; - } - } - } - }, stack, context); - - return list; - }; - - /** - * Large data down sampling on given dimension - * @param {string} dimension - * @param {number} rate - * @param {Function} sampleValue - * @param {Function} sampleIndex Sample index for name and id - */ - listProto.downSample = function (dimension, rate, sampleValue, sampleIndex) { - var list = cloneListForMapAndSample(this, [dimension]); - var storage = this._storage; - var targetStorage = list._storage; - - var originalIndices = this.indices; - var indices = list.indices = []; - - var frameValues = []; - var frameIndices = []; - var frameSize = Math.floor(1 / rate); - - var dimStore = targetStorage[dimension]; - var len = this.count(); - // Copy data from original data - for (var i = 0; i < storage[dimension].length; i++) { - targetStorage[dimension][i] = storage[dimension][i]; - } - for (var i = 0; i < len; i += frameSize) { - // Last frame - if (frameSize > len - i) { - frameSize = len - i; - frameValues.length = frameSize; - } - for (var k = 0; k < frameSize; k++) { - var idx = originalIndices[i + k]; - frameValues[k] = dimStore[idx]; - frameIndices[k] = idx; - } - var value = sampleValue(frameValues); - var idx = frameIndices[sampleIndex(frameValues, value) || 0]; - // Only write value on the filtered data - dimStore[idx] = value; - indices.push(idx); - } - return list; - }; - - /** - * Get model of one data item. - * - * @param {number} idx - */ - // FIXME Model proxy ? - listProto.getItemModel = function (idx) { - var hostModel = this.hostModel; - idx = this.indices[idx]; - return new Model(this._rawData[idx], hostModel, hostModel.ecModel); - }; - - /** - * Create a data differ - * @param {module:echarts/data/List} otherList - * @return {module:echarts/data/DataDiffer} - */ - listProto.diff = function (otherList) { - var idList = this._idList; - var otherIdList = otherList && otherList._idList; - return new DataDiffer( - otherList ? otherList.indices : [], this.indices, function (idx) { - return otherIdList[idx] || (idx + ''); - }, function (idx) { - return idList[idx] || (idx + ''); - } - ); - }; - /** - * Get visual property. - * @param {string} key - */ - listProto.getVisual = function (key) { - var visual = this._visual; - return visual && visual[key]; - }; - - /** - * Set visual property - * @param {string|Object} key - * @param {*} [value] - * - * @example - * setVisual('color', color); - * setVisual({ - * 'color': color - * }); - */ - listProto.setVisual = function (key, val) { - if (isObject(key)) { - for (var name in key) { - if (key.hasOwnProperty(name)) { - this.setVisual(name, key[name]); - } - } - return; - } - this._visual = this._visual || {}; - this._visual[key] = val; - }; - - /** - * Set layout property. - * @param {string} key - * @param {*} [val] - */ - listProto.setLayout = function (key, val) { - if (isObject(key)) { - for (var name in key) { - if (key.hasOwnProperty(name)) { - this.setLayout(name, key[name]); - } - } - return; - } - this._layout[key] = val; - }; - - /** - * Get layout property. - * @param {string} key. - * @return {*} - */ - listProto.getLayout = function (key) { - return this._layout[key]; - }; - - /** - * Get layout of single data item - * @param {number} idx - */ - listProto.getItemLayout = function (idx) { - return this._itemLayouts[idx]; - }, - - /** - * Set layout of single data item - * @param {number} idx - * @param {Object} layout - * @param {boolean=} [merge=false] - */ - listProto.setItemLayout = function (idx, layout, merge) { - this._itemLayouts[idx] = merge - ? zrUtil.extend(this._itemLayouts[idx] || {}, layout) - : layout; - }, - - /** - * Get visual property of single data item - * @param {number} idx - * @param {string} key - * @param {boolean} ignoreParent - */ - listProto.getItemVisual = function (idx, key, ignoreParent) { - var itemVisual = this._itemVisuals[idx]; - var val = itemVisual && itemVisual[key]; - if (val == null && !ignoreParent) { - // Use global visual property - return this.getVisual(key); - } - return val; - }, - - /** - * Set visual property of single data item - * - * @param {number} idx - * @param {string|Object} key - * @param {*} [value] - * - * @example - * setItemVisual(0, 'color', color); - * setItemVisual(0, { - * 'color': color - * }); - */ - listProto.setItemVisual = function (idx, key, value) { - var itemVisual = this._itemVisuals[idx] || {}; - this._itemVisuals[idx] = itemVisual; - - if (isObject(key)) { - for (var name in key) { - if (key.hasOwnProperty(name)) { - itemVisual[name] = key[name]; - } - } - return; - } - itemVisual[key] = value; - }; - - var setItemDataAndSeriesIndex = function (child) { - child.seriesIndex = this.seriesIndex; - child.dataIndex = this.dataIndex; - }; - /** - * Set graphic element relative to data. It can be set as null - * @param {number} idx - * @param {module:zrender/Element} [el] - */ - listProto.setItemGraphicEl = function (idx, el) { - var hostModel = this.hostModel; - - if (el) { - // Add data index and series index for indexing the data by element - // Useful in tooltip - el.dataIndex = idx; - el.seriesIndex = hostModel && hostModel.seriesIndex; - if (el.type === 'group') { - el.traverse(setItemDataAndSeriesIndex, el); - } - } - - this._graphicEls[idx] = el; - }; - - /** - * @param {number} idx - * @return {module:zrender/Element} - */ - listProto.getItemGraphicEl = function (idx) { - return this._graphicEls[idx]; - }; - - /** - * @param {Function} cb - * @param {*} context - */ - listProto.eachItemGraphicEl = function (cb, context) { - zrUtil.each(this._graphicEls, function (el, idx) { - if (el) { - cb && cb.call(context, el, idx); - } - }); - }; - - /** - * Shallow clone a new list except visual and layout properties, and graph elements. - * New list only change the indices. - */ - listProto.cloneShallow = function () { - var dimensionInfoList = zrUtil.map(this.dimensions, this.getDimensionInfo, this); - var list = new List(dimensionInfoList, this.hostModel); - - // FIXME - list._storage = this._storage; - - transferImmuProperties(list, this, this._wrappedMethods); - - list.indices = this.indices.slice(); - - return list; - }; - - /** - * Wrap some method to add more feature - * @param {string} methodName - * @param {Function} injectFunction - */ - listProto.wrapMethod = function (methodName, injectFunction) { - var originalMethod = this[methodName]; - if (typeof originalMethod !== 'function') { - return; - } - this._wrappedMethods = this._wrappedMethods || []; - this._wrappedMethods.push(methodName); - this[methodName] = function () { - var res = originalMethod.apply(this, arguments); - return injectFunction.call(this, res); - }; - }; - - return List; -}); -/** - * Complete dimensions by data (guess dimension). - */ -define('echarts/data/helper/completeDimensions',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - function completeDimensions(dimensions, data, defaultNames) { - if (!data) { - return dimensions; - } - - var value0 = retrieveValue(data[0]); - var dimSize = zrUtil.isArray(value0) && value0.length || 1; - - defaultNames = defaultNames || []; - for (var i = 0; i < dimSize; i++) { - if (!dimensions[i]) { - var name = defaultNames[i] || ('extra' + (i - defaultNames.length)); - dimensions[i] = guessOrdinal(data, i) - ? {type: 'ordinal', name: name} - : name; - } - } - - return dimensions; - } - - // The rule should not be complex, otherwise user might not - // be able to known where the data is wrong. - function guessOrdinal(data, dimIndex) { - for (var i = 0, len = data.length; i < len; i++) { - var value = retrieveValue(data[i]); - - if (!zrUtil.isArray(value)) { - return false; - } - - var value = value[dimIndex]; - if (value != null && isFinite(value)) { - return false; - } - else if (zrUtil.isString(value) && value !== '-') { - return true; - } - } - return false; - } - - function retrieveValue(o) { - return zrUtil.isArray(o) ? o : zrUtil.isObject(o) ? o.value: o; - } - - return completeDimensions; + /** + * [{key: dataZoomId, value: {dataZoomId, range}}, ...] + * History length of each dataZoom may be different. + * this._history[0] is used to store origin range. + * @type {Array.} + */ + function giveStore(ecModel) { + var store = ecModel[ATTR]; + if (!store) { + store = ecModel[ATTR] = [{}]; + } + return store; + } -}); -define('echarts/chart/helper/createListFromArray',['require','../../data/List','../../data/helper/completeDimensions','zrender/core/util','../../util/model','../../CoordinateSystem'],function(require) { - - - var List = require('../../data/List'); - var completeDimensions = require('../../data/helper/completeDimensions'); - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../../util/model'); - var CoordinateSystem = require('../../CoordinateSystem'); - var getDataItemValue = modelUtil.getDataItemValue; - var converDataValue = modelUtil.converDataValue; - - function firstDataNotNull(data) { - var i = 0; - while (i < data.length && data[i] == null) { - i++; - } - return data[i]; - } - function ifNeedCompleteOrdinalData(data) { - var sampleItem = firstDataNotNull(data); - return sampleItem != null - && !zrUtil.isArray(getDataItemValue(sampleItem)); - } - - /** - * Helper function to create a list from option data - */ - function createListFromArray(data, seriesModel, ecModel) { - // If data is undefined - data = data || []; - - var coordSysName = seriesModel.get('coordinateSystem'); - var creator = creators[coordSysName]; - var registeredCoordSys = CoordinateSystem.get(coordSysName); - // FIXME - var result = creator && creator(data, seriesModel, ecModel); - var dimensions = result && result.dimensions; - if (!dimensions) { - // Get dimensions from registered coordinate system - dimensions = (registeredCoordSys && registeredCoordSys.dimensions) || ['x', 'y']; - dimensions = completeDimensions(dimensions, data, dimensions.concat(['value'])); - } - var categoryAxisModel = result && result.categoryAxisModel; - - var categoryDimIndex = dimensions[0].type === 'ordinal' - ? 0 : (dimensions[1].type === 'ordinal' ? 1 : -1); - - var list = new List(dimensions, seriesModel); - - var nameList = createNameList(result, data); - - var dimValueGetter = (categoryAxisModel && ifNeedCompleteOrdinalData(data)) - ? function (itemOpt, dimName, dataIndex, dimIndex) { - // Use dataIndex as ordinal value in categoryAxis - return dimIndex === categoryDimIndex - ? dataIndex - : converDataValue(getDataItemValue(itemOpt), dimensions[dimIndex]); - } - : function (itemOpt, dimName, dataIndex, dimIndex) { - var val = getDataItemValue(itemOpt); - return converDataValue(val && val[dimIndex], dimensions[dimIndex]); - }; - - list.initData(data, nameList, dimValueGetter); - - return list; - } - - function isStackable(axisType) { - return axisType !== 'category' && axisType !== 'time'; - } - - function getDimTypeByAxis(axisType) { - return axisType === 'category' - ? 'ordinal' - : axisType === 'time' - ? 'time' - : 'float'; - } - - /** - * Creaters for each coord system. - * @return {Object} {dimensions, categoryAxisModel}; - */ - var creators = { - - cartesian2d: function (data, seriesModel, ecModel) { - var xAxisModel = ecModel.getComponent('xAxis', seriesModel.get('xAxisIndex')); - var yAxisModel = ecModel.getComponent('yAxis', seriesModel.get('yAxisIndex')); - var xAxisType = xAxisModel.get('type'); - var yAxisType = yAxisModel.get('type'); - - var dimensions = [ - { - name: 'x', - type: getDimTypeByAxis(xAxisType), - stackable: isStackable(xAxisType) - }, - { - name: 'y', - // If two category axes - type: getDimTypeByAxis(yAxisType), - stackable: isStackable(yAxisType) - } - ]; - - completeDimensions(dimensions, data, ['x', 'y', 'z']); - - return { - dimensions: dimensions, - categoryAxisModel: xAxisType === 'category' - ? xAxisModel - : (yAxisType === 'category' ? yAxisModel : null) - }; - }, - - polar: function (data, seriesModel, ecModel) { - var polarIndex = seriesModel.get('polarIndex') || 0; - - var axisFinder = function (axisModel) { - return axisModel.get('polarIndex') === polarIndex; - }; - - var angleAxisModel = ecModel.findComponents({ - mainType: 'angleAxis', filter: axisFinder - })[0]; - var radiusAxisModel = ecModel.findComponents({ - mainType: 'radiusAxis', filter: axisFinder - })[0]; - - var radiusAxisType = radiusAxisModel.get('type'); - var angleAxisType = angleAxisModel.get('type'); - - var dimensions = [ - { - name: 'radius', - type: getDimTypeByAxis(radiusAxisType), - stackable: isStackable(radiusAxisType) - }, - { - name: 'angle', - type: getDimTypeByAxis(angleAxisType), - stackable: isStackable(angleAxisType) - } - ]; - - completeDimensions(dimensions, data, ['radius', 'angle', 'value']); - - return { - dimensions: dimensions, - categoryAxisModel: angleAxisType === 'category' - ? angleAxisModel - : (radiusAxisType === 'category' ? radiusAxisModel : null) - }; - }, - - geo: function (data, seriesModel, ecModel) { - // TODO Region - // 多个散点图系列在同一个地区的时候 - return { - dimensions: completeDimensions([ - {name: 'lng'}, - {name: 'lat'} - ], data, ['lng', 'lat', 'value']) - }; - } - }; - - function createNameList(result, data) { - var nameList = []; - - if (result && result.categoryAxisModel) { - // FIXME Two category axis - var categories = result.categoryAxisModel.getCategories(); - if (categories) { - var dataLen = data.length; - // Ordered data is given explicitly like - // [[3, 0.2], [1, 0.3], [2, 0.15]] - // or given scatter data, - // pick the category - if (zrUtil.isArray(data[0]) && data[0].length > 1) { - nameList = []; - for (var i = 0; i < dataLen; i++) { - nameList[i] = categories[data[i][0]]; - } - } - else { - nameList = categories.slice(0); - } - } - } - - return nameList; - } - - return createListFromArray; + module.exports = history; -}); -define('echarts/chart/line/LineSeries',['require','../helper/createListFromArray','../../model/Series'],function(require) { - - - - var createListFromArray = require('../helper/createListFromArray'); - var SeriesModel = require('../../model/Series'); - - return SeriesModel.extend({ - - type: 'series.line', - - dependencies: ['grid', 'polar'], - - getInitialData: function (option, ecModel) { - return createListFromArray(option.data, this, ecModel); - }, - - defaultOption: { - zlevel: 0, // 一级层叠 - z: 2, // 二级层叠 - coordinateSystem: 'cartesian2d', - legendHoverLink: true, - - hoverAnimation: true, - // stack: null - xAxisIndex: 0, - yAxisIndex: 0, - - polarIndex: 0, - - // If clip the overflow value - clipOverflow: true, - - label: { - normal: { - // show: false, - position: 'top' - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 - // 'inside'|'left'|'right'|'top'|'bottom' - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - }, - emphasis: { - // show: false, - position: 'top' - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 - // 'inside'|'left'|'right'|'top'|'bottom' - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - } - }, - // itemStyle: { - // normal: { - // // color: 各异 - // }, - // emphasis: { - // // color: 各异, - // } - // }, - lineStyle: { - normal: { - width: 2, - type: 'solid' - } - }, - // areaStyle: { - // }, - // smooth: false, - // smoothMonotone: null, - // 拐点图形类型 - symbol: 'emptyCircle', - // 拐点图形大小 - symbolSize: 4, - // 拐点图形旋转控制 - // symbolRotate: null, - - // 是否显示 symbol, 只有在 tooltip hover 的时候显示 - showSymbol: true, - // 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略) - // showAllSymbol: false - // - // 大数据过滤,'average', 'max', 'min', 'sum' - // sampling: 'none' - - animationEasing: 'linear' - } - }); -}); -// Symbol factory -define('echarts/util/symbol',['require','./graphic','zrender/core/BoundingRect'],function(require) { - - - - var graphic = require('./graphic'); - var BoundingRect = require('zrender/core/BoundingRect'); - - /** - * Triangle shape - * @inner - */ - var Triangle = graphic.extendShape({ - type: 'triangle', - shape: { - cx: 0, - cy: 0, - width: 0, - height: 0 - }, - buildPath: function (path, shape) { - var cx = shape.cx; - var cy = shape.cy; - var width = shape.width / 2; - var height = shape.height / 2; - path.moveTo(cx, cy - height); - path.lineTo(cx + width, cy + height); - path.lineTo(cx - width, cy + height); - path.closePath(); - } - }); - /** - * Diamond shape - * @inner - */ - var Diamond = graphic.extendShape({ - type: 'diamond', - shape: { - cx: 0, - cy: 0, - width: 0, - height: 0 - }, - buildPath: function (path, shape) { - var cx = shape.cx; - var cy = shape.cy; - var width = shape.width / 2; - var height = shape.height / 2; - path.moveTo(cx, cy - height); - path.lineTo(cx + width, cy); - path.lineTo(cx, cy + height); - path.lineTo(cx - width, cy); - path.closePath(); - } - }); - - /** - * Pin shape - * @inner - */ - var Pin = graphic.extendShape({ - type: 'pin', - shape: { - // x, y on the cusp - x: 0, - y: 0, - width: 0, - height: 0 - }, - - buildPath: function (path, shape) { - var x = shape.x; - var y = shape.y; - var w = shape.width / 5 * 3; - // Height must be larger than width - var h = Math.max(w, shape.height); - var r = w / 2; - - // Dist on y with tangent point and circle center - var dy = r * r / (h - r); - var cy = y - h + r + dy; - var angle = Math.asin(dy / r); - // Dist on x with tangent point and circle center - var dx = Math.cos(angle) * r; - - var tanX = Math.sin(angle); - var tanY = Math.cos(angle); - - path.arc( - x, cy, r, - Math.PI - angle, - Math.PI * 2 + angle - ); - - var cpLen = r * 0.6; - var cpLen2 = r * 0.7; - path.bezierCurveTo( - x + dx - tanX * cpLen, cy + dy + tanY * cpLen, - x, y - cpLen2, - x, y - ); - path.bezierCurveTo( - x, y - cpLen2, - x - dx + tanX * cpLen, cy + dy + tanY * cpLen, - x - dx, cy + dy - ); - path.closePath(); - } - }); - - /** - * Arrow shape - * @inner - */ - var Arrow = graphic.extendShape({ - - type: 'arrow', - - shape: { - x: 0, - y: 0, - width: 0, - height: 0 - }, - - buildPath: function (ctx, shape) { - var height = shape.height; - var width = shape.width; - var x = shape.x; - var y = shape.y; - var dx = width / 3 * 2; - ctx.moveTo(x, y); - ctx.lineTo(x + dx, y + height); - ctx.lineTo(x, y + height / 4 * 3); - ctx.lineTo(x - dx, y + height); - ctx.lineTo(x, y); - ctx.closePath(); - } - }); - - /** - * Map of path contructors - * @type {Object.} - */ - var symbolCtors = { - line: graphic.Line, - - rect: graphic.Rect, - - roundRect: graphic.Rect, - - square: graphic.Rect, - - circle: graphic.Circle, - - diamond: Diamond, - - pin: Pin, - - arrow: Arrow, - - triangle: Triangle - }; - - var symbolShapeMakers = { - - line: function (x, y, w, h, shape) { - // FIXME - shape.x1 = x; - shape.y1 = y + h / 2; - shape.x2 = x + w; - shape.y2 = y + h / 2; - }, - - rect: function (x, y, w, h, shape) { - shape.x = x; - shape.y = y; - shape.width = w; - shape.height = h; - }, - - roundRect: function (x, y, w, h, shape) { - shape.x = x; - shape.y = y; - shape.width = w; - shape.height = h; - shape.r = Math.min(w, h) / 4; - }, - - square: function (x, y, w, h, shape) { - var size = Math.min(w, h); - shape.x = x; - shape.y = y; - shape.width = size; - shape.height = size; - }, - - circle: function (x, y, w, h, shape) { - // Put circle in the center of square - shape.cx = x + w / 2; - shape.cy = y + h / 2; - shape.r = Math.min(w, h) / 2; - }, - - diamond: function (x, y, w, h, shape) { - shape.cx = x + w / 2; - shape.cy = y + h / 2; - shape.width = w; - shape.height = h; - }, - - pin: function (x, y, w, h, shape) { - shape.x = x + w / 2; - shape.y = y + h / 2; - shape.width = w; - shape.height = h; - }, - - arrow: function (x, y, w, h, shape) { - shape.x = x + w / 2; - shape.y = y + h / 2; - shape.width = w; - shape.height = h; - }, - - triangle: function (x, y, w, h, shape) { - shape.cx = x + w / 2; - shape.cy = y + h / 2; - shape.width = w; - shape.height = h; - } - }; - - var symbolBuildProxies = {}; - for (var name in symbolCtors) { - symbolBuildProxies[name] = new symbolCtors[name](); - } - - var Symbol = graphic.extendShape({ - - type: 'symbol', - - shape: { - symbolType: '', - x: 0, - y: 0, - width: 0, - height: 0 - }, - - beforeBrush: function () { - var style = this.style; - var shape = this.shape; - // FIXME - if (shape.symbolType === 'pin' && style.textPosition === 'inside') { - style.textPosition = ['50%', '40%']; - style.textAlign = 'center'; - style.textBaseline = 'middle'; - } - }, - - buildPath: function (ctx, shape) { - var symbolType = shape.symbolType; - var proxySymbol = symbolBuildProxies[symbolType]; - if (shape.symbolType !== 'none') { - if (!proxySymbol) { - // Default rect - symbolType = 'rect'; - proxySymbol = symbolBuildProxies[symbolType]; - } - symbolShapeMakers[symbolType]( - shape.x, shape.y, shape.width, shape.height, proxySymbol.shape - ); - proxySymbol.buildPath(ctx, proxySymbol.shape); - } - } - }); - - // Provide setColor helper method to avoid determine if set the fill or stroke outside - var symbolPathSetColor = function (color) { - if (this.type !== 'image') { - var symbolStyle = this.style; - var symbolShape = this.shape; - if (symbolShape && symbolShape.symbolType === 'line') { - symbolStyle.stroke = color; - } - else if (this.__isEmptyBrush) { - symbolStyle.stroke = color; - symbolStyle.fill = '#fff'; - } - else { - // FIXME 判断图形默认是填充还是描边,使用 onlyStroke ? - symbolStyle.fill && (symbolStyle.fill = color); - symbolStyle.stroke && (symbolStyle.stroke = color); - } - this.dirty(); - } - }; - - var symbolUtil = { - /** - * Create a symbol element with given symbol configuration: shape, x, y, width, height, color - * @param {string} symbolType - * @param {number} x - * @param {number} y - * @param {number} w - * @param {number} h - * @param {string} color - */ - createSymbol: function (symbolType, x, y, w, h, color) { - var isEmpty = symbolType.indexOf('empty') === 0; - if (isEmpty) { - symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6); - } - var symbolPath; - - if (symbolType.indexOf('image://') === 0) { - symbolPath = new graphic.Image({ - style: { - image: symbolType.slice(8), - x: x, - y: y, - width: w, - height: h - } - }); - } - else if (symbolType.indexOf('path://') === 0) { - symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h)); - } - else { - symbolPath = new Symbol({ - shape: { - symbolType: symbolType, - x: x, - y: y, - width: w, - height: h - } - }); - } - - symbolPath.__isEmptyBrush = isEmpty; - - symbolPath.setColor = symbolPathSetColor; - - symbolPath.setColor(color); - - return symbolPath; - } - }; - - return symbolUtil; -}); -/** - * @module echarts/chart/helper/Symbol - */ -define('echarts/chart/helper/Symbol',['require','zrender/core/util','../../util/symbol','../../util/graphic','../../util/number'],function (require) { - - var zrUtil = require('zrender/core/util'); - var symbolUtil = require('../../util/symbol'); - var graphic = require('../../util/graphic'); - var numberUtil = require('../../util/number'); - - function normalizeSymbolSize(symbolSize) { - if (!zrUtil.isArray(symbolSize)) { - symbolSize = [+symbolSize, +symbolSize]; - } - return symbolSize; - } - - /** - * @constructor - * @alias {module:echarts/chart/helper/Symbol} - * @param {module:echarts/data/List} data - * @param {number} idx - * @extends {module:zrender/graphic/Group} - */ - function Symbol(data, idx) { - graphic.Group.call(this); - - this.updateData(data, idx); - } - - var symbolProto = Symbol.prototype; - - function driftSymbol(dx, dy) { - this.parent.drift(dx, dy); - } - - symbolProto._createSymbol = function (symbolType, data, idx) { - // Remove paths created before - this.removeAll(); - - var seriesModel = data.hostModel; - var color = data.getItemVisual(idx, 'color'); - - var symbolPath = symbolUtil.createSymbol( - symbolType, -0.5, -0.5, 1, 1, color - ); - - symbolPath.attr({ - style: { - strokeNoScale: true - }, - z2: 100, - culling: true, - scale: [0, 0] - }); - // Rewrite drift method - symbolPath.drift = driftSymbol; - - var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); - - graphic.initProps(symbolPath, { - scale: size - }, seriesModel); - - this._symbolType = symbolType; - - this.add(symbolPath); - }; - - /** - * Stop animation - * @param {boolean} toLastFrame - */ - symbolProto.stopSymbolAnimation = function (toLastFrame) { - this.childAt(0).stopAnimation(toLastFrame); - }; - - /** - * Get scale(aka, current symbol size). - * Including the change caused by animation - * @param {Array.} toLastFrame - */ - symbolProto.getScale = function () { - return this.childAt(0).scale; - }; - - /** - * Highlight symbol - */ - symbolProto.highlight = function () { - this.childAt(0).trigger('emphasis'); - }; - - /** - * Downplay symbol - */ - symbolProto.downplay = function () { - this.childAt(0).trigger('normal'); - }; - - /** - * @param {number} zlevel - * @param {number} z - */ - symbolProto.setZ = function (zlevel, z) { - var symbolPath = this.childAt(0); - symbolPath.zlevel = zlevel; - symbolPath.z = z; - }; - - symbolProto.setDraggable = function (draggable) { - var symbolPath = this.childAt(0); - symbolPath.draggable = draggable; - symbolPath.cursor = draggable ? 'move' : 'pointer'; - }; - /** - * Update symbol properties - * @param {module:echarts/data/List} data - * @param {number} idx - */ - symbolProto.updateData = function (data, idx) { - var symbolType = data.getItemVisual(idx, 'symbol') || 'circle'; - var seriesModel = data.hostModel; - var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); - if (symbolType !== this._symbolType) { - this._createSymbol(symbolType, data, idx); - } - else { - var symbolPath = this.childAt(0); - graphic.updateProps(symbolPath, { - scale: symbolSize - }, seriesModel); - } - this._updateCommon(data, idx, symbolSize); - - this._seriesModel = seriesModel; - }; - - // Update common properties - var normalStyleAccessPath = ['itemStyle', 'normal']; - var emphasisStyleAccessPath = ['itemStyle', 'emphasis']; - var normalLabelAccessPath = ['label', 'normal']; - var emphasisLabelAccessPath = ['label', 'emphasis']; - - symbolProto._updateCommon = function (data, idx, symbolSize) { - var symbolPath = this.childAt(0); - var seriesModel = data.hostModel; - var itemModel = data.getItemModel(idx); - var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath); - var color = data.getItemVisual(idx, 'color'); - - var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle(); - - symbolPath.rotation = itemModel.getShallow('symbolRotate') * Math.PI / 180 || 0; - - var symbolOffset = itemModel.getShallow('symbolOffset'); - if (symbolOffset) { - var pos = symbolPath.position; - pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]); - pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]); - } - - symbolPath.setColor(color); - - zrUtil.extend( - symbolPath.style, - // Color must be excluded. - // Because symbol provide setColor individually to set fill and stroke - normalItemStyleModel.getItemStyle(['color']) - ); - - var labelModel = itemModel.getModel(normalLabelAccessPath); - var hoverLabelModel = itemModel.getModel(emphasisLabelAccessPath); - - var elStyle = symbolPath.style; - - // Get last value dim - var dimensions = data.dimensions.slice(); - var valueDim = dimensions.pop(); - var dataType; - while ( - ((dataType = data.getDimensionInfo(valueDim).type) === 'ordinal') - || (dataType === 'time') - ) { - valueDim = dimensions.pop(); - } - - if (labelModel.get('show')) { - graphic.setText(elStyle, labelModel, color); - elStyle.text = zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'normal'), - data.get(valueDim, idx) - ); - } - else { - elStyle.text = ''; - } - - if (hoverLabelModel.getShallow('show')) { - graphic.setText(hoverStyle, hoverLabelModel, color); - hoverStyle.text = zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'emphasis'), - data.get(valueDim, idx) - ); - } - else { - hoverStyle.text = ''; - } - - var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); - - symbolPath.off('mouseover') - .off('mouseout') - .off('emphasis') - .off('normal'); - - graphic.setHoverStyle(symbolPath, hoverStyle); - - if (itemModel.getShallow('hoverAnimation')) { - var onEmphasis = function() { - var ratio = size[1] / size[0]; - this.animateTo({ - scale: [ - Math.max(size[0] * 1.1, size[0] + 3), - Math.max(size[1] * 1.1, size[1] + 3 * ratio) - ] - }, 400, 'elasticOut'); - }; - var onNormal = function() { - this.animateTo({ - scale: size - }, 400, 'elasticOut'); - }; - symbolPath.on('mouseover', onEmphasis) - .on('mouseout', onNormal) - .on('emphasis', onEmphasis) - .on('normal', onNormal); - } - }; - - symbolProto.fadeOut = function (cb) { - var symbolPath = this.childAt(0); - // Not show text when animating - symbolPath.style.text = ''; - graphic.updateProps(symbolPath, { - scale: [0, 0] - }, this._seriesModel, cb); - }; - - zrUtil.inherits(Symbol, graphic.Group); - - return Symbol; -}); -/** - * @module echarts/chart/helper/SymbolDraw - */ -define('echarts/chart/helper/SymbolDraw',['require','../../util/graphic','./Symbol'],function (require) { - - var graphic = require('../../util/graphic'); - var Symbol = require('./Symbol'); - - /** - * @constructor - * @alias module:echarts/chart/helper/SymbolDraw - * @param {module:zrender/graphic/Group} [symbolCtor] - */ - function SymbolDraw(symbolCtor) { - this.group = new graphic.Group(); - - this._symbolCtor = symbolCtor || Symbol; - } - - var symbolDrawProto = SymbolDraw.prototype; - - function symbolNeedsDraw(data, idx, isIgnore) { - var point = data.getItemLayout(idx); - return point && !isNaN(point[0]) && !isNaN(point[1]) && !(isIgnore && isIgnore(idx)) - && data.getItemVisual(idx, 'symbol') !== 'none'; - } - /** - * Update symbols draw by new data - * @param {module:echarts/data/List} data - * @param {Array.} [isIgnore] - */ - symbolDrawProto.updateData = function (data, isIgnore) { - var group = this.group; - var seriesModel = data.hostModel; - var oldData = this._data; - - var SymbolCtor = this._symbolCtor; - - data.diff(oldData) - .add(function (newIdx) { - var point = data.getItemLayout(newIdx); - if (symbolNeedsDraw(data, newIdx, isIgnore)) { - var symbolEl = new SymbolCtor(data, newIdx); - symbolEl.attr('position', point); - data.setItemGraphicEl(newIdx, symbolEl); - group.add(symbolEl); - } - }) - .update(function (newIdx, oldIdx) { - var symbolEl = oldData.getItemGraphicEl(oldIdx); - var point = data.getItemLayout(newIdx); - if (!symbolNeedsDraw(data, newIdx, isIgnore)) { - group.remove(symbolEl); - return; - } - if (!symbolEl) { - symbolEl = new SymbolCtor(data, newIdx); - symbolEl.attr('position', point); - } - else { - symbolEl.updateData(data, newIdx); - graphic.updateProps(symbolEl, { - position: point - }, seriesModel); - } - - // Add back - group.add(symbolEl); - - data.setItemGraphicEl(newIdx, symbolEl); - }) - .remove(function (oldIdx) { - var el = oldData.getItemGraphicEl(oldIdx); - el && el.fadeOut(function () { - group.remove(el); - }); - }) - .execute(); - - this._data = data; - }; - - symbolDrawProto.updateLayout = function () { - var data = this._data; - if (data) { - // Not use animation - data.eachItemGraphicEl(function (el, idx) { - el.attr('position', data.getItemLayout(idx)); - }); - } - }; - - symbolDrawProto.remove = function (enableAnimation) { - var group = this.group; - var data = this._data; - if (data) { - if (enableAnimation) { - data.eachItemGraphicEl(function (el) { - el.fadeOut(function () { - group.remove(el); - }); - }); - } - else { - group.removeAll(); - } - } - }; - - return SymbolDraw; -}); -define('echarts/chart/line/lineAnimationDiff',['require'],function (require) { - - // var arrayDiff = require('zrender/core/arrayDiff'); - // 'zrender/core/arrayDiff' has been used before, but it did - // not do well in performance when roam with fixed dataZoom window. - - function sign(val) { - return val >= 0 ? 1 : -1; - } - - function getStackedOnPoint(coordSys, data, idx) { - var baseAxis = coordSys.getBaseAxis(); - var valueAxis = coordSys.getOtherAxis(baseAxis); - var valueStart = baseAxis.onZero - ? 0 : valueAxis.scale.getExtent()[0]; - - var valueDim = valueAxis.dim; - var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0; - - var stackedOnSameSign; - var stackedOn = data.stackedOn; - var val = data.get(valueDim, idx); - // Find first stacked value with same sign - while (stackedOn && - sign(stackedOn.get(valueDim, idx)) === sign(val) - ) { - stackedOnSameSign = stackedOn; - break; - } - var stackedData = []; - stackedData[baseDataOffset] = data.get(baseAxis.dim, idx); - stackedData[1 - baseDataOffset] = stackedOnSameSign - ? stackedOnSameSign.get(valueDim, idx, true) : valueStart; - - return coordSys.dataToPoint(stackedData); - } - - // function convertToIntId(newIdList, oldIdList) { - // // Generate int id instead of string id. - // // Compare string maybe slow in score function of arrDiff - - // // Assume id in idList are all unique - // var idIndicesMap = {}; - // var idx = 0; - // for (var i = 0; i < newIdList.length; i++) { - // idIndicesMap[newIdList[i]] = idx; - // newIdList[i] = idx++; - // } - // for (var i = 0; i < oldIdList.length; i++) { - // var oldId = oldIdList[i]; - // // Same with newIdList - // if (idIndicesMap[oldId]) { - // oldIdList[i] = idIndicesMap[oldId]; - // } - // else { - // oldIdList[i] = idx++; - // } - // } - // } - - function diffData(oldData, newData) { - var diffResult = []; - - newData.diff(oldData) - .add(function (idx) { - diffResult.push({cmd: '+', idx: idx}); - }) - .update(function (newIdx, oldIdx) { - diffResult.push({cmd: '=', idx: oldIdx, idx1: newIdx}); - }) - .remove(function (idx) { - diffResult.push({cmd: '-', idx: idx}); - }) - .execute(); - - return diffResult; - } - - return function ( - oldData, newData, - oldStackedOnPoints, newStackedOnPoints, - oldCoordSys, newCoordSys - ) { - var diff = diffData(oldData, newData); - - // var newIdList = newData.mapArray(newData.getId); - // var oldIdList = oldData.mapArray(oldData.getId); - - // convertToIntId(newIdList, oldIdList); - - // // FIXME One data ? - // diff = arrayDiff(oldIdList, newIdList); - - var currPoints = []; - var nextPoints = []; - // Points for stacking base line - var currStackedPoints = []; - var nextStackedPoints = []; - - var status = []; - var sortedIndices = []; - var rawIndices = []; - var dims = newCoordSys.dimensions; - for (var i = 0; i < diff.length; i++) { - var diffItem = diff[i]; - var pointAdded = true; - - // FIXME, animation is not so perfect when dataZoom window moves fast - // Which is in case remvoing or add more than one data in the tail or head - switch (diffItem.cmd) { - case '=': - var currentPt = oldData.getItemLayout(diffItem.idx); - var nextPt = newData.getItemLayout(diffItem.idx1); - // If previous data is NaN, use next point directly - if (isNaN(currentPt[0]) || isNaN(currentPt[1])) { - currentPt = nextPt.slice(); - } - currPoints.push(currentPt); - nextPoints.push(nextPt); - - currStackedPoints.push(oldStackedOnPoints[diffItem.idx]); - nextStackedPoints.push(newStackedOnPoints[diffItem.idx1]); - - rawIndices.push(newData.getRawIndex(diffItem.idx1)); - break; - case '+': - var idx = diffItem.idx; - currPoints.push( - oldCoordSys.dataToPoint([ - newData.get(dims[0], idx, true), newData.get(dims[1], idx, true) - ]) - ); - - nextPoints.push(newData.getItemLayout(idx).slice()); - - currStackedPoints.push( - getStackedOnPoint(oldCoordSys, newData, idx) - ); - nextStackedPoints.push(newStackedOnPoints[idx]); - - rawIndices.push(newData.getRawIndex(idx)); - break; - case '-': - var idx = diffItem.idx; - var rawIndex = oldData.getRawIndex(idx); - // Data is replaced. In the case of dynamic data queue - // FIXME FIXME FIXME - if (rawIndex !== idx) { - currPoints.push(oldData.getItemLayout(idx)); - nextPoints.push(newCoordSys.dataToPoint([ - oldData.get(dims[0], idx, true), oldData.get(dims[1], idx, true) - ])); - - currStackedPoints.push(oldStackedOnPoints[idx]); - nextStackedPoints.push( - getStackedOnPoint( - newCoordSys, oldData, idx - ) - ); - - rawIndices.push(rawIndex); - } - else { - pointAdded = false; - } - } - - // Original indices - if (pointAdded) { - status.push(diffItem); - sortedIndices.push(sortedIndices.length); - } - } - - // Diff result may be crossed if all items are changed - // Sort by data index - sortedIndices.sort(function (a, b) { - return rawIndices[a] - rawIndices[b]; - }); - - var sortedCurrPoints = []; - var sortedNextPoints = []; - - var sortedCurrStackedPoints = []; - var sortedNextStackedPoints = []; - - var sortedStatus = []; - for (var i = 0; i < sortedIndices.length; i++) { - var idx = sortedIndices[i]; - sortedCurrPoints[i] = currPoints[idx]; - sortedNextPoints[i] = nextPoints[idx]; - - sortedCurrStackedPoints[i] = currStackedPoints[idx]; - sortedNextStackedPoints[i] = nextStackedPoints[idx]; - - sortedStatus[i] = status[idx]; - } - - return { - current: sortedCurrPoints, - next: sortedNextPoints, - - stackedOnCurrent: sortedCurrStackedPoints, - stackedOnNext: sortedNextStackedPoints, - - status: sortedStatus - }; - }; -}); -// Poly path support NaN point -define('echarts/chart/line/poly',['require','zrender/graphic/Path','zrender/core/vector'],function (require) { - - var Path = require('zrender/graphic/Path'); - var vec2 = require('zrender/core/vector'); - - var vec2Min = vec2.min; - var vec2Max = vec2.max; - - var scaleAndAdd = vec2.scaleAndAdd; - var v2Copy = vec2.copy; - - // Temporary variable - var v = []; - var cp0 = []; - var cp1 = []; - - function drawSegment( - ctx, points, start, stop, len, - dir, smoothMin, smoothMax, smooth, smoothMonotone - ) { - var idx = start; - for (var k = 0; k < len; k++) { - var p = points[idx]; - if (idx >= stop || idx < 0 || isNaN(p[0]) || isNaN(p[1])) { - break; - } - - if (idx === start) { - ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]); - v2Copy(cp0, p); - } - else { - if (smooth > 0) { - var prevIdx = idx - dir; - var nextIdx = idx + dir; - - var ratioNextSeg = 0.5; - var prevP = points[prevIdx]; - var nextP = points[nextIdx]; - // Last point - if ((dir > 0 && (idx === len - 1 || isNaN(nextP[0]) || isNaN(nextP[1]))) - || (dir <= 0 && (idx === 0 || isNaN(nextP[0]) || isNaN(nextP[1]))) - ) { - v2Copy(cp1, p); - } - else { - // If next data is null - if (isNaN(nextP[0]) || isNaN(nextP[1])) { - nextP = p; - } - - vec2.sub(v, nextP, prevP); - - var lenPrevSeg; - var lenNextSeg; - if (smoothMonotone === 'x' || smoothMonotone === 'y') { - var dim = smoothMonotone === 'x' ? 0 : 1; - lenPrevSeg = Math.abs(p[dim] - prevP[dim]); - lenNextSeg = Math.abs(p[dim] - nextP[dim]); - } - else { - lenPrevSeg = vec2.dist(p, prevP); - lenNextSeg = vec2.dist(p, nextP); - } - - // Use ratio of seg length - ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg); - - scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg)); - } - // Smooth constraint - vec2Min(cp0, cp0, smoothMax); - vec2Max(cp0, cp0, smoothMin); - vec2Min(cp1, cp1, smoothMax); - vec2Max(cp1, cp1, smoothMin); - - ctx.bezierCurveTo( - cp0[0], cp0[1], - cp1[0], cp1[1], - p[0], p[1] - ); - // cp0 of next segment - scaleAndAdd(cp0, p, v, smooth * ratioNextSeg); - } - else { - ctx.lineTo(p[0], p[1]); - } - } - - idx += dir; - } - - return k; - } - - function getBoundingBox(points, smoothConstraint) { - var ptMin = [Infinity, Infinity]; - var ptMax = [-Infinity, -Infinity]; - if (smoothConstraint) { - for (var i = 0; i < points.length; i++) { - var pt = points[i]; - if (pt[0] < ptMin[0]) { ptMin[0] = pt[0]; } - if (pt[1] < ptMin[1]) { ptMin[1] = pt[1]; } - if (pt[0] > ptMax[0]) { ptMax[0] = pt[0]; } - if (pt[1] > ptMax[1]) { ptMax[1] = pt[1]; } - } - } - return { - min: smoothConstraint ? ptMin : ptMax, - max: smoothConstraint ? ptMax : ptMin - }; - } - - return { - - Polyline: Path.extend({ - - type: 'ec-polyline', - - shape: { - points: [], - - smooth: 0, - - smoothConstraint: true, - - smoothMonotone: null - }, - - style: { - fill: null, - - stroke: '#000' - }, - - buildPath: function (ctx, shape) { - var points = shape.points; - - var i = 0; - var len = points.length; - - var result = getBoundingBox(points, shape.smoothConstraint); - - while (i < len) { - i += drawSegment( - ctx, points, i, len, len, - 1, result.min, result.max, shape.smooth, - shape.smoothMonotone - ) + 1; - } - } - }), - - Polygon: Path.extend({ - - type: 'ec-polygon', - - shape: { - points: [], - - // Offset between stacked base points and points - stackedOnPoints: [], - - smooth: 0, - - stackedOnSmooth: 0, - - smoothConstraint: true, - - smoothMonotone: null - }, - - buildPath: function (ctx, shape) { - var points = shape.points; - var stackedOnPoints = shape.stackedOnPoints; - - var i = 0; - var len = points.length; - var smoothMonotone = shape.smoothMonotone; - var bbox = getBoundingBox(points, shape.smoothConstraint); - var stackedOnBBox = getBoundingBox(stackedOnPoints, shape.smoothConstraint); - while (i < len) { - var k = drawSegment( - ctx, points, i, len, len, - 1, bbox.min, bbox.max, shape.smooth, - smoothMonotone - ); - drawSegment( - ctx, stackedOnPoints, i + k - 1, len, k, - -1, stackedOnBBox.min, stackedOnBBox.max, shape.stackedOnSmooth, - smoothMonotone - ); - i += k + 1; - - ctx.closePath(); - } - } - }) - }; -}); -define('echarts/chart/line/LineView',['require','zrender/core/util','../helper/SymbolDraw','../helper/Symbol','./lineAnimationDiff','../../util/graphic','./poly','../../view/Chart'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var SymbolDraw = require('../helper/SymbolDraw'); - var Symbol = require('../helper/Symbol'); - var lineAnimationDiff = require('./lineAnimationDiff'); - var graphic = require('../../util/graphic'); - - var polyHelper = require('./poly'); - - var ChartView = require('../../view/Chart'); - - function isPointsSame(points1, points2) { - if (points1.length !== points2.length) { - return; - } - for (var i = 0; i < points1.length; i++) { - var p1 = points1[i]; - var p2 = points2[i]; - if (p1[0] !== p2[0] || p1[1] !== p2[1]) { - return; - } - } - return true; - } - - function getSmooth(smooth) { - return typeof (smooth) === 'number' ? smooth : (smooth ? 0.3 : 0); - } - - function getAxisExtentWithGap(axis) { - var extent = axis.getGlobalExtent(); - if (axis.onBand) { - // Remove extra 1px to avoid line miter in clipped edge - var halfBandWidth = axis.getBandWidth() / 2 - 1; - var dir = extent[1] > extent[0] ? 1 : -1; - extent[0] += dir * halfBandWidth; - extent[1] -= dir * halfBandWidth; - } - return extent; - } - - function sign(val) { - return val >= 0 ? 1 : -1; - } - /** - * @param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys - * @param {module:echarts/data/List} data - * @param {Array.>} points - * @private - */ - function getStackedOnPoints(coordSys, data) { - var baseAxis = coordSys.getBaseAxis(); - var valueAxis = coordSys.getOtherAxis(baseAxis); - var valueStart = baseAxis.onZero - ? 0 : valueAxis.scale.getExtent()[0]; - - var valueDim = valueAxis.dim; - - var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0; - - return data.mapArray([valueDim], function (val, idx) { - var stackedOnSameSign; - var stackedOn = data.stackedOn; - // Find first stacked value with same sign - while (stackedOn && - sign(stackedOn.get(valueDim, idx)) === sign(val) - ) { - stackedOnSameSign = stackedOn; - break; - } - var stackedData = []; - stackedData[baseDataOffset] = data.get(baseAxis.dim, idx); - stackedData[1 - baseDataOffset] = stackedOnSameSign - ? stackedOnSameSign.get(valueDim, idx, true) : valueStart; - - return coordSys.dataToPoint(stackedData); - }, true); - } - - function queryDataIndex(data, payload) { - if (payload.dataIndex != null) { - return payload.dataIndex; - } - else if (payload.name != null) { - return data.indexOfName(payload.name); - } - } - - function createGridClipShape(cartesian, hasAnimation, seriesModel) { - var xExtent = getAxisExtentWithGap(cartesian.getAxis('x')); - var yExtent = getAxisExtentWithGap(cartesian.getAxis('y')); - var isHorizontal = cartesian.getBaseAxis().isHorizontal(); - - var x = xExtent[0]; - var y = yExtent[0]; - var width = xExtent[1] - x; - var height = yExtent[1] - y; - // Expand clip shape to avoid line value exceeds axis - if (!seriesModel.get('clipOverflow')) { - if (isHorizontal) { - y -= height; - height *= 3; - } - else { - x -= width; - width *= 3; - } - } - var clipPath = new graphic.Rect({ - shape: { - x: x, - y: y, - width: width, - height: height - } - }); - - if (hasAnimation) { - clipPath.shape[isHorizontal ? 'width' : 'height'] = 0; - graphic.initProps(clipPath, { - shape: { - width: width, - height: height - } - }, seriesModel); - } - - return clipPath; - } - - function createPolarClipShape(polar, hasAnimation, seriesModel) { - var angleAxis = polar.getAngleAxis(); - var radiusAxis = polar.getRadiusAxis(); - - var radiusExtent = radiusAxis.getExtent(); - var angleExtent = angleAxis.getExtent(); - - var RADIAN = Math.PI / 180; - - var clipPath = new graphic.Sector({ - shape: { - cx: polar.cx, - cy: polar.cy, - r0: radiusExtent[0], - r: radiusExtent[1], - startAngle: -angleExtent[0] * RADIAN, - endAngle: -angleExtent[1] * RADIAN, - clockwise: angleAxis.inverse - } - }); - - if (hasAnimation) { - clipPath.shape.endAngle = -angleExtent[0] * RADIAN; - graphic.initProps(clipPath, { - shape: { - endAngle: -angleExtent[1] * RADIAN - } - }, seriesModel); - } - - return clipPath; - } - - function createClipShape(coordSys, hasAnimation, seriesModel) { - return coordSys.type === 'polar' - ? createPolarClipShape(coordSys, hasAnimation, seriesModel) - : createGridClipShape(coordSys, hasAnimation, seriesModel); - } - - return ChartView.extend({ - - type: 'line', - - init: function () { - var lineGroup = new graphic.Group(); - - var symbolDraw = new SymbolDraw(); - this.group.add(symbolDraw.group); - - this._symbolDraw = symbolDraw; - this._lineGroup = lineGroup; - }, - - render: function (seriesModel, ecModel, api) { - var coordSys = seriesModel.coordinateSystem; - var group = this.group; - var data = seriesModel.getData(); - var lineStyleModel = seriesModel.getModel('lineStyle.normal'); - var areaStyleModel = seriesModel.getModel('areaStyle.normal'); - - var points = data.mapArray(data.getItemLayout, true); - - var isCoordSysPolar = coordSys.type === 'polar'; - var prevCoordSys = this._coordSys; - - var symbolDraw = this._symbolDraw; - var polyline = this._polyline; - var polygon = this._polygon; - - var lineGroup = this._lineGroup; - - var hasAnimation = seriesModel.get('animation'); - - var isAreaChart = !areaStyleModel.isEmpty(); - var stackedOnPoints = getStackedOnPoints(coordSys, data); - - var showSymbol = seriesModel.get('showSymbol'); - - var isSymbolIgnore = showSymbol && !isCoordSysPolar && !seriesModel.get('showAllSymbol') - && this._getSymbolIgnoreFunc(data, coordSys); - - // Remove temporary symbols - var oldData = this._data; - oldData && oldData.eachItemGraphicEl(function (el, idx) { - if (el.__temp) { - group.remove(el); - oldData.setItemGraphicEl(idx, null); - } - }); - - // Remove previous created symbols if showSymbol changed to false - if (!showSymbol) { - symbolDraw.remove(); - } - - group.add(lineGroup); - - // Initialization animation or coordinate system changed - if ( - !(polyline && prevCoordSys.type === coordSys.type) - ) { - showSymbol && symbolDraw.updateData(data, isSymbolIgnore); - - polyline = this._newPolyline(points, coordSys, hasAnimation); - if (isAreaChart) { - polygon = this._newPolygon( - points, stackedOnPoints, - coordSys, hasAnimation - ); - } - lineGroup.setClipPath(createClipShape(coordSys, true, seriesModel)); - } - else { - if (isAreaChart && !polygon) { - // If areaStyle is added - polygon = this._newPolygon( - points, stackedOnPoints, - coordSys, hasAnimation - ); - } - else if (polygon && !isAreaChart) { - // If areaStyle is removed - lineGroup.remove(polygon); - polygon = this._polygon = null; - } - - // Update clipPath - lineGroup.setClipPath(createClipShape(coordSys, false, seriesModel)); - - // Always update, or it is wrong in the case turning on legend - // because points are not changed - showSymbol && symbolDraw.updateData(data, isSymbolIgnore); - - // Stop symbol animation and sync with line points - // FIXME performance? - data.eachItemGraphicEl(function (el) { - el.stopAnimation(true); - }); - - // In the case data zoom triggerred refreshing frequently - // Data may not change if line has a category axis. So it should animate nothing - if (!isPointsSame(this._stackedOnPoints, stackedOnPoints) - || !isPointsSame(this._points, points) - ) { - if (hasAnimation) { - this._updateAnimation( - data, stackedOnPoints, coordSys, api - ); - } - else { - polyline.setShape({ - points: points - }); - polygon && polygon.setShape({ - points: points, - stackedOnPoints: stackedOnPoints - }); - } - } - } - - polyline.setStyle(zrUtil.defaults( - // Use color in lineStyle first - lineStyleModel.getLineStyle(), - { - stroke: data.getVisual('color'), - lineJoin: 'bevel' - } - )); - - var smooth = seriesModel.get('smooth'); - smooth = getSmooth(seriesModel.get('smooth')); - polyline.setShape({ - smooth: smooth, - smoothMonotone: seriesModel.get('smoothMonotone') - }); - - if (polygon) { - var stackedOn = data.stackedOn; - var stackedOnSmooth = 0; - - polygon.style.opacity = 0.7; - polygon.setStyle(zrUtil.defaults( - areaStyleModel.getAreaStyle(), - { - fill: data.getVisual('color'), - lineJoin: 'bevel' - } - )); - - if (stackedOn) { - var stackedOnSeries = stackedOn.hostModel; - stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth')); - } - - polygon.setShape({ - smooth: smooth, - stackedOnSmooth: stackedOnSmooth, - smoothMonotone: seriesModel.get('smoothMonotone') - }); - } - - this._data = data; - // Save the coordinate system for transition animation when data changed - this._coordSys = coordSys; - this._stackedOnPoints = stackedOnPoints; - this._points = points; - }, - - highlight: function (seriesModel, ecModel, api, payload) { - var data = seriesModel.getData(); - var dataIndex = queryDataIndex(data, payload); - - if (dataIndex != null && dataIndex >= 0) { - var symbol = data.getItemGraphicEl(dataIndex); - if (!symbol) { - // Create a temporary symbol if it is not exists - var pt = data.getItemLayout(dataIndex); - symbol = new Symbol(data, dataIndex, api); - symbol.position = pt; - symbol.setZ( - seriesModel.get('zlevel'), - seriesModel.get('z') - ); - symbol.ignore = isNaN(pt[0]) || isNaN(pt[1]); - symbol.__temp = true; - data.setItemGraphicEl(dataIndex, symbol); - - // Stop scale animation - symbol.stopSymbolAnimation(true); - - this.group.add(symbol); - } - symbol.highlight(); - } - else { - // Highlight whole series - ChartView.prototype.highlight.call( - this, seriesModel, ecModel, api, payload - ); - } - }, - - downplay: function (seriesModel, ecModel, api, payload) { - var data = seriesModel.getData(); - var dataIndex = queryDataIndex(data, payload); - if (dataIndex != null && dataIndex >= 0) { - var symbol = data.getItemGraphicEl(dataIndex); - if (symbol) { - if (symbol.__temp) { - data.setItemGraphicEl(dataIndex, null); - this.group.remove(symbol); - } - else { - symbol.downplay(); - } - } - } - else { - // Downplay whole series - ChartView.prototype.downplay.call( - this, seriesModel, ecModel, api, payload - ); - } - }, - - /** - * @param {module:zrender/container/Group} group - * @param {Array.>} points - * @private - */ - _newPolyline: function (points) { - var polyline = this._polyline; - // Remove previous created polyline - if (polyline) { - this._lineGroup.remove(polyline); - } - - polyline = new polyHelper.Polyline({ - shape: { - points: points - }, - silent: true, - z2: 10 - }); - - this._lineGroup.add(polyline); - - this._polyline = polyline; - - return polyline; - }, - - /** - * @param {module:zrender/container/Group} group - * @param {Array.>} stackedOnPoints - * @param {Array.>} points - * @private - */ - _newPolygon: function (points, stackedOnPoints) { - var polygon = this._polygon; - // Remove previous created polygon - if (polygon) { - this._lineGroup.remove(polygon); - } - - polygon = new polyHelper.Polygon({ - shape: { - points: points, - stackedOnPoints: stackedOnPoints - }, - silent: true - }); - - this._lineGroup.add(polygon); - - this._polygon = polygon; - return polygon; - }, - /** - * @private - */ - _getSymbolIgnoreFunc: function (data, coordSys) { - var categoryAxis = coordSys.getAxesByScale('ordinal')[0]; - // `getLabelInterval` is provided by echarts/component/axis - if (categoryAxis && categoryAxis.isLabelIgnored) { - return zrUtil.bind(categoryAxis.isLabelIgnored, categoryAxis); - } - }, - - /** - * @private - */ - // FIXME Two value axis - _updateAnimation: function (data, stackedOnPoints, coordSys, api) { - var polyline = this._polyline; - var polygon = this._polygon; - var seriesModel = data.hostModel; - - var diff = lineAnimationDiff( - this._data, data, - this._stackedOnPoints, stackedOnPoints, - this._coordSys, coordSys - ); - polyline.shape.points = diff.current; - - graphic.updateProps(polyline, { - shape: { - points: diff.next - } - }, seriesModel); - - if (polygon) { - polygon.setShape({ - points: diff.current, - stackedOnPoints: diff.stackedOnCurrent - }); - graphic.updateProps(polygon, { - shape: { - points: diff.next, - stackedOnPoints: diff.stackedOnNext - } - }, seriesModel); - } - - var updatedDataInfo = []; - var diffStatus = diff.status; - - for (var i = 0; i < diffStatus.length; i++) { - var cmd = diffStatus[i].cmd; - if (cmd === '=') { - var el = data.getItemGraphicEl(diffStatus[i].idx1); - if (el) { - updatedDataInfo.push({ - el: el, - ptIdx: i // Index of points - }); - } - } - } - - if (polyline.animators && polyline.animators.length) { - polyline.animators[0].during(function () { - for (var i = 0; i < updatedDataInfo.length; i++) { - var el = updatedDataInfo[i].el; - el.attr('position', polyline.shape.points[updatedDataInfo[i].ptIdx]); - } - }); - } - }, - - remove: function (ecModel) { - this._lineGroup.removeAll(); - this._symbolDraw.remove(true); - - this._polyline = - this._polygon = - this._coordSys = - this._points = - this._stackedOnPoints = - this._data = null; - } - }); -}); -define('echarts/visual/symbol',['require'],function (require) { - - return function (seriesType, defaultSymbolType, legendSymbol, ecModel, api) { - - // Encoding visual for all series include which is filtered for legend drawing - ecModel.eachRawSeriesByType(seriesType, function (seriesModel) { - var data = seriesModel.getData(); - - var symbolType = seriesModel.get('symbol') || defaultSymbolType; - var symbolSize = seriesModel.get('symbolSize'); - - data.setVisual({ - legendSymbol: legendSymbol || symbolType, - symbol: symbolType, - symbolSize: symbolSize - }); - - // Only visible series has each data be visual encoded - if (!ecModel.isSeriesFiltered(seriesModel)) { - if (typeof symbolSize === 'function') { - data.each(function (idx) { - var rawValue = seriesModel.getRawValue(idx); - // FIXME - var params = seriesModel.getDataParams(idx); - data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params)); - }); - } - data.each(function (idx) { - var itemModel = data.getItemModel(idx); - var itemSymbolType = itemModel.get('symbol', true); - var itemSymbolSize = itemModel.get('symbolSize', true); - // If has item symbol - if (itemSymbolType != null) { - data.setItemVisual(idx, 'symbol', itemSymbolType); - } - if (itemSymbolSize != null) { - // PENDING Transform symbolSize ? - data.setItemVisual(idx, 'symbolSize', itemSymbolSize); - } - }); - } - }); - }; -}); -define('echarts/layout/points',['require'],function (require) { - - return function (seriesType, ecModel, api) { - ecModel.eachSeriesByType(seriesType, function (seriesModel) { - var data = seriesModel.getData(); - var coordSys = seriesModel.coordinateSystem; - - var dims = coordSys.dimensions; - data.each(dims, function (x, y, idx) { - var point; - if (!isNaN(x) && !isNaN(y)) { - point = coordSys.dataToPoint([x, y]); - } - else { - // Also {Array.}, not undefined to avoid if...else... statement - point = [NaN, NaN]; - } - - data.setItemLayout(idx, point); - }, true); - }); - }; -}); -define('echarts/processor/dataSample',[],function () { - var samplers = { - average: function (frame) { - var sum = 0; - var count = 0; - for (var i = 0; i < frame.length; i++) { - if (!isNaN(frame[i])) { - sum += frame[i]; - count++; - } - } - // Return NaN if count is 0 - return count === 0 ? NaN : sum / count; - }, - sum: function (frame) { - var sum = 0; - for (var i = 0; i < frame.length; i++) { - // Ignore NaN - sum += frame[i] || 0; - } - return sum; - }, - max: function (frame) { - var max = -Infinity; - for (var i = 0; i < frame.length; i++) { - frame[i] > max && (max = frame[i]); - } - return max; - }, - min: function (frame) { - var min = Infinity; - for (var i = 0; i < frame.length; i++) { - frame[i] < min && (min = frame[i]); - } - return min; - } - }; - - var indexSampler = function (frame, value) { - return Math.round(frame.length / 2); - }; - return function (seriesType, ecModel, api) { - ecModel.eachSeriesByType(seriesType, function (seriesModel) { - var data = seriesModel.getData(); - var sampling = seriesModel.get('sampling'); - var coordSys = seriesModel.coordinateSystem; - // Only cartesian2d support down sampling - if (coordSys.type === 'cartesian2d' && sampling) { - var baseAxis = coordSys.getBaseAxis(); - var valueAxis = coordSys.getOtherAxis(baseAxis); - var extent = baseAxis.getExtent(); - // Coordinste system has been resized - var size = extent[1] - extent[0]; - var rate = Math.round(data.count() / size); - if (rate > 1) { - var sampler; - if (typeof sampling === 'string') { - sampler = samplers[sampling]; - } - else if (typeof sampling === 'function') { - sampler = sampling; - } - if (sampler) { - data = data.downSample( - valueAxis.dim, 1 / rate, sampler, indexSampler - ); - seriesModel.setData(data); - } - } - } - }, this); - }; -}); -define('echarts/chart/line',['require','zrender/core/util','../echarts','./line/LineSeries','./line/LineView','../visual/symbol','../layout/points','../processor/dataSample'],function (require) { - var zrUtil = require('zrender/core/util'); - var echarts = require('../echarts'); - require('./line/LineSeries'); - require('./line/LineView'); +/***/ }, +/* 341 */ +/***/ function(module, exports, __webpack_require__) { - echarts.registerVisualCoding('chart', zrUtil.curry( - require('../visual/symbol'), 'line', 'circle', 'line' - )); - echarts.registerLayout(zrUtil.curry( - require('../layout/points'), 'line' - )); + /** + * DataZoom component entry + */ - // Down sample after filter - echarts.registerProcessor('statistic', zrUtil.curry( - require('../processor/dataSample'), 'line' - )); -}); -/** - * // Scale class management - * @module echarts/scale/Scale - */ -define('echarts/scale/Scale',['require','../util/clazz'],function (require) { - - var clazzUtil = require('../util/clazz'); - - function Scale() { - /** - * Extent - * @type {Array.} - * @protected - */ - this._extent = [Infinity, -Infinity]; - - /** - * Step is calculated in adjustExtent - * @type {Array.} - * @protected - */ - this._interval = 0; - - this.init && this.init.apply(this, arguments); - } - - var scaleProto = Scale.prototype; - - /** - * Parse input val to valid inner number. - * @param {*} val - * @return {number} - */ - scaleProto.parse = function (val) { - // Notice: This would be a trap here, If the implementation - // of this method depends on extent, and this method is used - // before extent set (like in dataZoom), it would be wrong. - // Nevertheless, parse does not depend on extent generally. - return val; - }; - - scaleProto.contain = function (val) { - var extent = this._extent; - return val >= extent[0] && val <= extent[1]; - }; - - /** - * Normalize value to linear [0, 1], return 0.5 if extent span is 0 - * @param {number} val - * @return {number} - */ - scaleProto.normalize = function (val) { - var extent = this._extent; - if (extent[1] === extent[0]) { - return 0.5; - } - return (val - extent[0]) / (extent[1] - extent[0]); - }; - - /** - * Scale normalized value - * @param {number} val - * @return {number} - */ - scaleProto.scale = function (val) { - var extent = this._extent; - return val * (extent[1] - extent[0]) + extent[0]; - }; - - /** - * Set extent from data - * @param {Array.} other - */ - scaleProto.unionExtent = function (other) { - var extent = this._extent; - other[0] < extent[0] && (extent[0] = other[0]); - other[1] > extent[1] && (extent[1] = other[1]); - // not setExtent because in log axis it may transformed to power - // this.setExtent(extent[0], extent[1]); - }; - - /** - * Get extent - * @return {Array.} - */ - scaleProto.getExtent = function () { - return this._extent.slice(); - }; - - /** - * Set extent - * @param {number} start - * @param {number} end - */ - scaleProto.setExtent = function (start, end) { - var thisExtent = this._extent; - if (!isNaN(start)) { - thisExtent[0] = start; - } - if (!isNaN(end)) { - thisExtent[1] = end; - } - }; - - /** - * @return {Array.} - */ - scaleProto.getTicksLabels = function () { - var labels = []; - var ticks = this.getTicks(); - for (var i = 0; i < ticks.length; i++) { - labels.push(this.getLabel(ticks[i])); - } - return labels; - }; - - clazzUtil.enableClassExtend(Scale); - clazzUtil.enableClassManagement(Scale, { - registerWhenExtend: true - }); - - return Scale; -}); -/** - * Linear continuous scale - * @module echarts/coord/scale/Ordinal - * - * http://en.wikipedia.org/wiki/Level_of_measurement - */ - -// FIXME only one data -define('echarts/scale/Ordinal',['require','zrender/core/util','./Scale'],function (require) { - - var zrUtil = require('zrender/core/util'); - var Scale = require('./Scale'); - - var scaleProto = Scale.prototype; - - var OrdinalScale = Scale.extend({ - - type: 'ordinal', - - init: function (data, extent) { - this._data = data; - this._extent = extent || [0, data.length - 1]; - }, - - parse: function (val) { - return typeof val === 'string' - ? zrUtil.indexOf(this._data, val) - // val might be float. - : Math.round(val); - }, - - contain: function (rank) { - rank = this.parse(rank); - return scaleProto.contain.call(this, rank) - && this._data[rank] != null; - }, - - /** - * Normalize given rank or name to linear [0, 1] - * @param {number|string} [val] - * @return {number} - */ - normalize: function (val) { - return scaleProto.normalize.call(this, this.parse(val)); - }, - - scale: function (val) { - return Math.round(scaleProto.scale.call(this, val)); - }, - - /** - * @return {Array} - */ - getTicks: function () { - var ticks = []; - var extent = this._extent; - var rank = extent[0]; - - while (rank <= extent[1]) { - ticks.push(rank); - rank++; - } - - return ticks; - }, - - /** - * Get item on rank n - * @param {number} n - * @return {string} - */ - getLabel: function (n) { - return this._data[n]; - }, - - /** - * @return {number} - */ - count: function () { - return this._extent[1] - this._extent[0] + 1; - }, - - niceTicks: zrUtil.noop, - niceExtent: zrUtil.noop - }); - - /** - * @return {module:echarts/scale/Time} - */ - OrdinalScale.create = function () { - return new OrdinalScale(); - }; - - return OrdinalScale; -}); -/** - * Interval scale - * @module echarts/scale/Interval - */ - -define('echarts/scale/Interval',['require','../util/number','../util/format','./Scale'],function (require) { - - var numberUtil = require('../util/number'); - var formatUtil = require('../util/format'); - var Scale = require('./Scale'); - - var mathFloor = Math.floor; - var mathCeil = Math.ceil; - /** - * @alias module:echarts/coord/scale/Interval - * @constructor - */ - var IntervalScale = Scale.extend({ - - type: 'interval', - - _interval: 0, - - setExtent: function (start, end) { - var thisExtent = this._extent; - //start,end may be a Number like '25',so... - if (!isNaN(start)) { - thisExtent[0] = parseFloat(start); - } - if (!isNaN(end)) { - thisExtent[1] = parseFloat(end); - } - }, - - unionExtent: function (other) { - var extent = this._extent; - other[0] < extent[0] && (extent[0] = other[0]); - other[1] > extent[1] && (extent[1] = other[1]); - - // unionExtent may called by it's sub classes - IntervalScale.prototype.setExtent.call(this, extent[0], extent[1]); - }, - /** - * Get interval - */ - getInterval: function () { - if (!this._interval) { - this.niceTicks(); - } - return this._interval; - }, - - /** - * Set interval - */ - setInterval: function (interval) { - this._interval = interval; - // Dropped auto calculated niceExtent and use user setted extent - // We assume user wan't to set both interval, min, max to get a better result - this._niceExtent = this._extent.slice(); - }, - - /** - * @return {Array.} - */ - getTicks: function () { - if (!this._interval) { - this.niceTicks(); - } - var interval = this._interval; - var extent = this._extent; - var ticks = []; - - // Consider this case: using dataZoom toolbox, zoom and zoom. - var safeLimit = 10000; - - if (interval) { - var niceExtent = this._niceExtent; - if (extent[0] < niceExtent[0]) { - ticks.push(extent[0]); - } - var tick = niceExtent[0]; - while (tick <= niceExtent[1]) { - ticks.push(tick); - // Avoid rounding error - tick = numberUtil.round(tick + interval); - if (ticks.length > safeLimit) { - return []; - } - } - if (extent[1] > niceExtent[1]) { - ticks.push(extent[1]); - } - } - - return ticks; - }, - - /** - * @return {Array.} - */ - getTicksLabels: function () { - var labels = []; - var ticks = this.getTicks(); - for (var i = 0; i < ticks.length; i++) { - labels.push(this.getLabel(ticks[i])); - } - return labels; - }, - - /** - * @param {number} n - * @return {number} - */ - getLabel: function (data) { - return formatUtil.addCommas(data); - }, - - /** - * Update interval and extent of intervals for nice ticks - * Algorithm from d3.js - * @param {number} [approxTickNum = 10] Given approx tick number - */ - niceTicks: function (approxTickNum) { - approxTickNum = approxTickNum || 10; - var extent = this._extent; - var span = extent[1] - extent[0]; - if (span === Infinity || span <= 0) { - return; - } - - // Figure out step quantity, for example 0.1, 1, 10, 100 - var interval = Math.pow(10, Math.floor(Math.log(span / approxTickNum) / Math.LN10)); - var err = approxTickNum / span * interval; - - // Filter ticks to get closer to the desired count. - if (err <= 0.15) { - interval *= 10; - } - else if (err <= 0.3) { - interval *= 5; - } - else if (err <= 0.45) { - interval *= 3; - } - else if (err <= 0.75) { - interval *= 2; - } - - var niceExtent = [ - numberUtil.round(mathCeil(extent[0] / interval) * interval), - numberUtil.round(mathFloor(extent[1] / interval) * interval) - ]; - - this._interval = interval; - this._niceExtent = niceExtent; - }, - - /** - * Nice extent. - * @param {number} [approxTickNum = 10] Given approx tick number - * @param {boolean} [fixMin=false] - * @param {boolean} [fixMax=false] - */ - niceExtent: function (approxTickNum, fixMin, fixMax) { - var extent = this._extent; - // If extent start and end are same, expand them - if (extent[0] === extent[1]) { - if (extent[0] !== 0) { - // Expand extent - var expandSize = extent[0] / 2; - extent[0] -= expandSize; - extent[1] += expandSize; - } - else { - extent[1] = 1; - } - } - // If there are no data and extent are [Infinity, -Infinity] - if (extent[1] === -Infinity && extent[0] === Infinity) { - extent[0] = 0; - extent[1] = 1; - } - - this.niceTicks(approxTickNum, fixMin, fixMax); - - // var extent = this._extent; - var interval = this._interval; - - if (!fixMin) { - extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval); - } - if (!fixMax) { - extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval); - } - } - }); - - /** - * @return {module:echarts/scale/Time} - */ - IntervalScale.create = function () { - return new IntervalScale(); - }; - - return IntervalScale; -}); -/** - * Interval scale - * @module echarts/coord/scale/Time - */ - -define('echarts/scale/Time',['require','zrender/core/util','../util/number','../util/format','./Interval'],function (require) { - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../util/number'); - var formatUtil = require('../util/format'); - - var IntervalScale = require('./Interval'); - - var intervalScaleProto = IntervalScale.prototype; - - var mathCeil = Math.ceil; - var mathFloor = Math.floor; - var ONE_DAY = 3600000 * 24; - - // FIXME 公用? - var bisect = function (a, x, lo, hi) { - while (lo < hi) { - var mid = lo + hi >>> 1; - if (a[mid][2] < x) { - lo = mid + 1; - } - else { - hi = mid; - } - } - return lo; - }; - - /** - * @alias module:echarts/coord/scale/Time - * @constructor - */ - var TimeScale = IntervalScale.extend({ - type: 'time', - - // Overwrite - getLabel: function (val) { - var stepLvl = this._stepLvl; - - var date = new Date(val); - - return formatUtil.formatTime(stepLvl[0], date); - }, - - // Overwrite - niceExtent: function (approxTickNum, fixMin, fixMax) { - var extent = this._extent; - // If extent start and end are same, expand them - if (extent[0] === extent[1]) { - // Expand extent - extent[0] -= ONE_DAY; - extent[1] += ONE_DAY; - } - // If there are no data and extent are [Infinity, -Infinity] - if (extent[1] === -Infinity && extent[0] === Infinity) { - var d = new Date(); - extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate()); - extent[0] = extent[1] - ONE_DAY; - } - - this.niceTicks(approxTickNum, fixMin, fixMax); - - // var extent = this._extent; - var interval = this._interval; - - if (!fixMin) { - extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval); - } - if (!fixMax) { - extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval); - } - }, - - // Overwrite - niceTicks: function (approxTickNum) { - approxTickNum = approxTickNum || 10; - - var extent = this._extent; - var span = extent[1] - extent[0]; - var approxInterval = span / approxTickNum; - var scaleLevelsLen = scaleLevels.length; - var idx = bisect(scaleLevels, approxInterval, 0, scaleLevelsLen); - - var level = scaleLevels[Math.min(idx, scaleLevelsLen - 1)]; - var interval = level[2]; - // Same with interval scale if span is much larger than 1 year - if (level[0] === 'year') { - var year = span / interval; - var yearInterval = Math.pow(10, Math.floor(Math.log(year / approxTickNum) / Math.LN10)); - var err = approxTickNum / year * yearInterval; - // Filter ticks to get closer to the desired count. - if (err <= 0.15) { - yearInterval *= 10; - } - else if (err <= 0.3) { - yearInterval *= 5; - } - else if (err <= 0.75) { - yearInterval *= 2; - } - interval *= yearInterval; - } - - var niceExtent = [ - mathCeil(extent[0] / interval) * interval, - mathFloor(extent[1] / interval) * interval - ]; - - this._stepLvl = level; - // Interval will be used in getTicks - this._interval = interval; - this._niceExtent = niceExtent; - }, - - parse: function (val) { - // val might be float. - return +numberUtil.parseDate(val); - } - }); - - zrUtil.each(['contain', 'normalize'], function (methodName) { - TimeScale.prototype[methodName] = function (val) { - return intervalScaleProto[methodName].call(this, this.parse(val)); - }; - }); - - // Steps from d3 - var scaleLevels = [ - // Format step interval - ['hh:mm:ss', 1, 1000], // 1s - ['hh:mm:ss', 5, 1000 * 5], // 5s - ['hh:mm:ss', 10, 1000 * 10], // 10s - ['hh:mm:ss', 15, 1000 * 15], // 15s - ['hh:mm:ss', 30, 1000 * 30], // 30s - ['hh:mm\nMM-dd',1, 60000], // 1m - ['hh:mm\nMM-dd',5, 60000 * 5], // 5m - ['hh:mm\nMM-dd',10, 60000 * 10], // 10m - ['hh:mm\nMM-dd',15, 60000 * 15], // 15m - ['hh:mm\nMM-dd',30, 60000 * 30], // 30m - ['hh:mm\nMM-dd',1, 3600000], // 1h - ['hh:mm\nMM-dd',2, 3600000 * 2], // 2h - ['hh:mm\nMM-dd',6, 3600000 * 6], // 6h - ['hh:mm\nMM-dd',12, 3600000 * 12], // 12h - ['MM-dd\nyyyy', 1, ONE_DAY], // 1d - ['week', 7, ONE_DAY * 7], // 7d - ['month', 1, ONE_DAY * 31], // 1M - ['quarter', 3, ONE_DAY * 380 / 4], // 3M - ['half-year', 6, ONE_DAY * 380 / 2], // 6M - ['year', 1, ONE_DAY * 380] // 1Y - ]; - - /** - * @return {module:echarts/scale/Time} - */ - TimeScale.create = function () { - return new TimeScale(); - }; - - return TimeScale; -}); -/** - * Log scale - * @module echarts/scale/Log - */ -define('echarts/scale/Log',['require','zrender/core/util','./Scale','../util/number','./Interval'],function (require) { - - var zrUtil = require('zrender/core/util'); - var Scale = require('./Scale'); - var numberUtil = require('../util/number'); - - // Use some method of IntervalScale - var IntervalScale = require('./Interval'); - - var scaleProto = Scale.prototype; - var intervalScaleProto = IntervalScale.prototype; - - var mathFloor = Math.floor; - var mathCeil = Math.ceil; - var mathPow = Math.pow; - - var LOG_BASE = 10; - var mathLog = Math.log; - - var LogScale = Scale.extend({ - - type: 'log', - - /** - * @return {Array.} - */ - getTicks: function () { - return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) { - return numberUtil.round(mathPow(LOG_BASE, val)); - }); - }, - - /** - * @param {number} val - * @return {string} - */ - getLabel: intervalScaleProto.getLabel, - - /** - * @param {number} val - * @return {number} - */ - scale: function (val) { - val = scaleProto.scale.call(this, val); - return mathPow(LOG_BASE, val); - }, - - /** - * @param {number} start - * @param {number} end - */ - setExtent: function (start, end) { - start = mathLog(start) / mathLog(LOG_BASE); - end = mathLog(end) / mathLog(LOG_BASE); - intervalScaleProto.setExtent.call(this, start, end); - }, - - /** - * @return {number} end - */ - getExtent: function () { - var extent = scaleProto.getExtent.call(this); - extent[0] = mathPow(LOG_BASE, extent[0]); - extent[1] = mathPow(LOG_BASE, extent[1]); - return extent; - }, - - /** - * @param {Array.} extent - */ - unionExtent: function (extent) { - extent[0] = mathLog(extent[0]) / mathLog(LOG_BASE); - extent[1] = mathLog(extent[1]) / mathLog(LOG_BASE); - scaleProto.unionExtent.call(this, extent); - }, - - /** - * Update interval and extent of intervals for nice ticks - * @param {number} [approxTickNum = 10] Given approx tick number - */ - niceTicks: function (approxTickNum) { - approxTickNum = approxTickNum || 10; - var extent = this._extent; - var span = extent[1] - extent[0]; - if (span === Infinity || span <= 0) { - return; - } - - var interval = mathPow(10, mathFloor(mathLog(span / approxTickNum) / Math.LN10)); - var err = approxTickNum / span * interval; - - // Filter ticks to get closer to the desired count. - if (err <= 0.5) { - interval *= 10; - } - var niceExtent = [ - numberUtil.round(mathCeil(extent[0] / interval) * interval), - numberUtil.round(mathFloor(extent[1] / interval) * interval) - ]; - - this._interval = interval; - this._niceExtent = niceExtent; - }, - - /** - * Nice extent. - * @param {number} [approxTickNum = 10] Given approx tick number - * @param {boolean} [fixMin=false] - * @param {boolean} [fixMax=false] - */ - niceExtent: intervalScaleProto.niceExtent - }); - - zrUtil.each(['contain', 'normalize'], function (methodName) { - LogScale.prototype[methodName] = function (val) { - val = mathLog(val) / mathLog(LOG_BASE); - return scaleProto[methodName].call(this, val); - }; - }); - - LogScale.create = function () { - return new LogScale(); - }; - - return LogScale; -}); -define('echarts/coord/axisHelper',['require','../scale/Ordinal','../scale/Interval','../scale/Time','../scale/Log','../scale/Scale','../util/number','zrender/core/util','zrender/contain/text'],function (require) { - - var OrdinalScale = require('../scale/Ordinal'); - var IntervalScale = require('../scale/Interval'); - require('../scale/Time'); - require('../scale/Log'); - var Scale = require('../scale/Scale'); - - var numberUtil = require('../util/number'); - var zrUtil = require('zrender/core/util'); - var textContain = require('zrender/contain/text'); - var axisHelper = {}; - - axisHelper.niceScaleExtent = function (axis, model) { - var scale = axis.scale; - var originalExtent = scale.getExtent(); - var span = originalExtent[1] - originalExtent[0]; - if (scale.type === 'ordinal') { - // If series has no data, scale extent may be wrong - if (!isFinite(span)) { - scale.setExtent(0, 0); - } - return; - } - var min = model.get('min'); - var max = model.get('max'); - var crossZero = !model.get('scale'); - var boundaryGap = model.get('boundaryGap'); - if (!zrUtil.isArray(boundaryGap)) { - boundaryGap = [boundaryGap || 0, boundaryGap || 0]; - } - boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], 1); - boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], 1); - var fixMin = true; - var fixMax = true; - // Add boundary gap - if (min == null) { - min = originalExtent[0] - boundaryGap[0] * span; - fixMin = false; - } - if (max == null) { - max = originalExtent[1] + boundaryGap[1] * span; - fixMax = false; - } - // TODO Only one data - if (min === 'dataMin') { - min = originalExtent[0]; - } - if (max === 'dataMax') { - max = originalExtent[1]; - } - // Evaluate if axis needs cross zero - if (crossZero) { - // Axis is over zero and min is not set - if (min > 0 && max > 0 && !fixMin) { - min = 0; - } - // Axis is under zero and max is not set - if (min < 0 && max < 0 && !fixMax) { - max = 0; - } - } - scale.setExtent(min, max); - scale.niceExtent(model.get('splitNumber'), fixMin, fixMax); - - // If some one specified the min, max. And the default calculated interval - // is not good enough. He can specify the interval. It is often appeared - // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard - // to be 60. - // FIXME - var interval = model.get('interval'); - if (interval != null) { - scale.setInterval && scale.setInterval(interval); - } - }; - - /** - * @param {module:echarts/model/Model} model - * @param {string} [axisType] Default retrieve from model.type - * @return {module:echarts/scale/*} - */ - axisHelper.createScaleByModel = function(model, axisType) { - axisType = axisType || model.get('type'); - if (axisType) { - switch (axisType) { - // Buildin scale - case 'category': - return new OrdinalScale( - model.getCategories(), [Infinity, -Infinity] - ); - case 'value': - return new IntervalScale(); - // Extended scale, like time and log - default: - return (Scale.getClass(axisType) || IntervalScale).create(model); - } - } - }; - - /** - * Check if the axis corss 0 - */ - axisHelper.ifAxisCrossZero = function (axis) { - var dataExtent = axis.scale.getExtent(); - var min = dataExtent[0]; - var max = dataExtent[1]; - return !((min > 0 && max > 0) || (min < 0 && max < 0)); - }; - - /** - * @param {Array.} tickCoords In axis self coordinate. - * @param {Array.} labels - * @param {string} font - * @param {boolean} isAxisHorizontal - * @return {number} - */ - axisHelper.getAxisLabelInterval = function (tickCoords, labels, font, isAxisHorizontal) { - // FIXME - // 不同角的axis和label,不只是horizontal和vertical. - - var textSpaceTakenRect; - var autoLabelInterval = 0; - var accumulatedLabelInterval = 0; - - var step = 1; - if (labels.length > 40) { - // Simple optimization for large amount of labels - step = Math.round(labels.length / 40); - } - for (var i = 0; i < tickCoords.length; i += step) { - var tickCoord = tickCoords[i]; - var rect = textContain.getBoundingRect( - labels[i], font, 'center', 'top' - ); - rect[isAxisHorizontal ? 'x' : 'y'] += tickCoord; - rect[isAxisHorizontal ? 'width' : 'height'] *= 1.5; - if (!textSpaceTakenRect) { - textSpaceTakenRect = rect.clone(); - } - // There is no space for current label; - else if (textSpaceTakenRect.intersect(rect)) { - accumulatedLabelInterval++; - autoLabelInterval = Math.max(autoLabelInterval, accumulatedLabelInterval); - } - else { - textSpaceTakenRect.union(rect); - // Reset - accumulatedLabelInterval = 0; - } - } - if (autoLabelInterval === 0 && step > 1) { - return step; - } - return autoLabelInterval * step; - }; - - /** - * @param {Object} axis - * @param {Function} labelFormatter - * @return {Array.} - */ - axisHelper.getFormattedLabels = function (axis, labelFormatter) { - var scale = axis.scale; - var labels = scale.getTicksLabels(); - var ticks = scale.getTicks(); - if (typeof labelFormatter === 'string') { - labelFormatter = (function (tpl) { - return function (val) { - return tpl.replace('{value}', val); - }; - })(labelFormatter); - return zrUtil.map(labels, labelFormatter); - } - else if (typeof labelFormatter === 'function') { - return zrUtil.map(ticks, function (tick, idx) { - return labelFormatter( - axis.type === 'category' ? scale.getLabel(tick) : tick, - idx - ); - }, this); - } - else { - return labels; - } - }; - - return axisHelper; -}); -/** - * Cartesian coordinate system - * @module echarts/coord/Cartesian - * - */ -define('echarts/coord/cartesian/Cartesian',['require','zrender/core/util'],function (require) { - - - - var zrUtil = require('zrender/core/util'); - - function dimAxisMapper(dim) { - return this._axes[dim]; - } - - /** - * @alias module:echarts/coord/Cartesian - * @constructor - */ - var Cartesian = function (name) { - this._axes = {}; - - this._dimList = []; - - /** - * @type {string} - */ - this.name = name || ''; - }; - - Cartesian.prototype = { - - constructor: Cartesian, - - type: 'cartesian', - - /** - * Get axis - * @param {number|string} dim - * @return {module:echarts/coord/Cartesian~Axis} - */ - getAxis: function (dim) { - return this._axes[dim]; - }, - - /** - * Get axes list - * @return {Array.} - */ - getAxes: function () { - return zrUtil.map(this._dimList, dimAxisMapper, this); - }, - - /** - * Get axes list by given scale type - */ - getAxesByScale: function (scaleType) { - scaleType = scaleType.toLowerCase(); - return zrUtil.filter( - this.getAxes(), - function (axis) { - return axis.scale.type === scaleType; - } - ); - }, - - /** - * Add axis - * @param {module:echarts/coord/Cartesian.Axis} - */ - addAxis: function (axis) { - var dim = axis.dim; - - this._axes[dim] = axis; - - this._dimList.push(dim); - }, - - /** - * Convert data to coord in nd space - * @param {Array.|Object.} val - * @return {Array.|Object.} - */ - dataToCoord: function (val) { - return this._dataCoordConvert(val, 'dataToCoord'); - }, - - /** - * Convert coord in nd space to data - * @param {Array.|Object.} val - * @return {Array.|Object.} - */ - coordToData: function (val) { - return this._dataCoordConvert(val, 'coordToData'); - }, - - _dataCoordConvert: function (input, method) { - var dimList = this._dimList; - - var output = input instanceof Array ? [] : {}; - - for (var i = 0; i < dimList.length; i++) { - var dim = dimList[i]; - var axis = this._axes[dim]; - - output[dim] = axis[method](input[dim]); - } - - return output; - } - }; - - return Cartesian; -}); -define('echarts/coord/cartesian/Cartesian2D',['require','zrender/core/util','./Cartesian'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var Cartesian = require('./Cartesian'); - - function Cartesian2D(name) { - - Cartesian.call(this, name); - } - - Cartesian2D.prototype = { - - constructor: Cartesian2D, - - type: 'cartesian2d', - - /** - * @type {Array.} - * @readOnly - */ - dimensions: ['x', 'y'], - - /** - * Base axis will be used on stacking. - * - * @return {module:echarts/coord/cartesian/Axis2D} - */ - getBaseAxis: function () { - return this.getAxesByScale('ordinal')[0] - || this.getAxesByScale('time')[0] - || this.getAxis('x'); - }, - - /** - * If contain point - * @param {Array.} point - * @return {boolean} - */ - containPoint: function (point) { - var axisX = this.getAxis('x'); - var axisY = this.getAxis('y'); - return axisX.contain(axisX.toLocalCoord(point[0])) - && axisY.contain(axisY.toLocalCoord(point[1])); - }, - - /** - * If contain data - * @param {Array.} data - * @return {boolean} - */ - containData: function (data) { - return this.getAxis('x').containData(data[0]) - && this.getAxis('y').containData(data[1]); - }, - - /** - * Convert series data to an array of points - * @param {module:echarts/data/List} data - * @param {boolean} stack - * @return {Array} - * Return array of points. For example: - * `[[10, 10], [20, 20], [30, 30]]` - */ - dataToPoints: function (data, stack) { - return data.mapArray(['x', 'y'], function (x, y) { - return this.dataToPoint([x, y]); - }, stack, this); - }, - - /** - * @param {Array.} data - * @param {boolean} [clamp=false] - * @return {Array.} - */ - dataToPoint: function (data, clamp) { - var xAxis = this.getAxis('x'); - var yAxis = this.getAxis('y'); - return [ - xAxis.toGlobalCoord(xAxis.dataToCoord(data[0], clamp)), - yAxis.toGlobalCoord(yAxis.dataToCoord(data[1], clamp)) - ]; - }, - - /** - * @param {Array.} point - * @param {boolean} [clamp=false] - * @return {Array.} - */ - pointToData: function (point, clamp) { - var xAxis = this.getAxis('x'); - var yAxis = this.getAxis('y'); - return [ - xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp), - yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp) - ]; - }, - - /** - * Get other axis - * @param {module:echarts/coord/cartesian/Axis2D} axis - */ - getOtherAxis: function (axis) { - return this.getAxis(axis.dim === 'x' ? 'y' : 'x'); - } - }; - - zrUtil.inherits(Cartesian2D, Cartesian); - - return Cartesian2D; -}); -define('echarts/coord/Axis',['require','../util/number','zrender/core/util'],function (require) { - - var numberUtil = require('../util/number'); - var linearMap = numberUtil.linearMap; - var zrUtil = require('zrender/core/util'); - - function fixExtentWithBands(extent, nTick) { - var size = extent[1] - extent[0]; - var len = nTick; - var margin = size / len / 2; - extent[0] += margin; - extent[1] -= margin; - } - - var normalizedExtent = [0, 1]; - /** - * @name module:echarts/coord/CartesianAxis - * @constructor - */ - var Axis = function (dim, scale, extent) { - - /** - * Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius' - * @type {string} - */ - this.dim = dim; - - /** - * Axis scale - * @type {module:echarts/coord/scale/*} - */ - this.scale = scale; - - /** - * @type {Array.} - * @private - */ - this._extent = extent || [0, 0]; - - /** - * @type {boolean} - */ - this.inverse = false; - - /** - * Usually true when axis has a ordinal scale - * @type {boolean} - */ - this.onBand = false; - }; - - Axis.prototype = { - - constructor: Axis, - - /** - * If axis extent contain given coord - * @param {number} coord - * @return {boolean} - */ - contain: function (coord) { - var extent = this._extent; - var min = Math.min(extent[0], extent[1]); - var max = Math.max(extent[0], extent[1]); - return coord >= min && coord <= max; - }, - - /** - * If axis extent contain given data - * @param {number} data - * @return {boolean} - */ - containData: function (data) { - return this.contain(this.dataToCoord(data)); - }, - - /** - * Get coord extent. - * @return {Array.} - */ - getExtent: function () { - var ret = this._extent.slice(); - return ret; - }, - - /** - * Get precision used for formatting - * @param {Array.} [dataExtent] - * @return {number} - */ - getPixelPrecision: function (dataExtent) { - return numberUtil.getPixelPrecision( - dataExtent || this.scale.getExtent(), - this._extent - ); - }, - - /** - * Set coord extent - * @param {number} start - * @param {number} end - */ - setExtent: function (start, end) { - var extent = this._extent; - extent[0] = start; - extent[1] = end; - }, - - /** - * Convert data to coord. Data is the rank if it has a ordinal scale - * @param {number} data - * @param {boolean} clamp - * @return {number} - */ - dataToCoord: function (data, clamp) { - var extent = this._extent; - var scale = this.scale; - data = scale.normalize(data); - - if (this.onBand && scale.type === 'ordinal') { - extent = extent.slice(); - fixExtentWithBands(extent, scale.count()); - } - - return linearMap(data, normalizedExtent, extent, clamp); - }, - - /** - * Convert coord to data. Data is the rank if it has a ordinal scale - * @param {number} coord - * @param {boolean} clamp - * @return {number} - */ - coordToData: function (coord, clamp) { - var extent = this._extent; - var scale = this.scale; - - if (this.onBand && scale.type === 'ordinal') { - extent = extent.slice(); - fixExtentWithBands(extent, scale.count()); - } - - var t = linearMap(coord, extent, normalizedExtent, clamp); - - return this.scale.scale(t); - }, - /** - * @return {Array.} - */ - getTicksCoords: function () { - if (this.onBand) { - var bands = this.getBands(); - var coords = []; - for (var i = 0; i < bands.length; i++) { - coords.push(bands[i][0]); - } - if (bands[i - 1]) { - coords.push(bands[i - 1][1]); - } - return coords; - } - else { - return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this); - } - }, - - /** - * Coords of labels are on the ticks or on the middle of bands - * @return {Array.} - */ - getLabelsCoords: function () { - if (this.onBand) { - var bands = this.getBands(); - var coords = []; - var band; - for (var i = 0; i < bands.length; i++) { - band = bands[i]; - coords.push((band[0] + band[1]) / 2); - } - return coords; - } - else { - return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this); - } - }, - - /** - * Get bands. - * - * If axis has labels [1, 2, 3, 4]. Bands on the axis are - * |---1---|---2---|---3---|---4---|. - * - * @return {Array} - */ - // FIXME Situation when labels is on ticks - getBands: function () { - var extent = this.getExtent(); - var bands = []; - var len = this.scale.count(); - var start = extent[0]; - var end = extent[1]; - var span = end - start; - - for (var i = 0; i < len; i++) { - bands.push([ - span * i / len + start, - span * (i + 1) / len + start - ]); - } - return bands; - }, - - /** - * Get width of band - * @return {number} - */ - getBandWidth: function () { - var axisExtent = this._extent; - var dataExtent = this.scale.getExtent(); - - var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0); - - var size = Math.abs(axisExtent[1] - axisExtent[0]); - - return Math.abs(size) / len; - } - }; - - return Axis; -}); -/** - * Helper function for axisLabelInterval calculation - */ - -define('echarts/coord/cartesian/axisLabelInterval',['require','zrender/core/util','../axisHelper'],function(require) { - - - var zrUtil = require('zrender/core/util'); - var axisHelper = require('../axisHelper'); - - return function (axis) { - var axisModel = axis.model; - var labelModel = axisModel.getModel('axisLabel'); - var labelInterval = labelModel.get('interval'); - if (!(axis.type === 'category' && labelInterval === 'auto')) { - return labelInterval === 'auto' ? 0 : labelInterval; - } - - return axisHelper.getAxisLabelInterval( - zrUtil.map(axis.scale.getTicks(), axis.dataToCoord, axis), - axisModel.getFormattedLabels(), - labelModel.getModel('textStyle').getFont(), - axis.isHorizontal() - ); - }; -}); -define('echarts/coord/cartesian/Axis2D',['require','zrender/core/util','../Axis','./axisLabelInterval'],function (require) { - - var zrUtil = require('zrender/core/util'); - var Axis = require('../Axis'); - var axisLabelInterval = require('./axisLabelInterval'); - - /** - * Extend axis 2d - * @constructor module:echarts/coord/cartesian/Axis2D - * @extends {module:echarts/coord/cartesian/Axis} - * @param {string} dim - * @param {*} scale - * @param {Array.} coordExtent - * @param {string} axisType - * @param {string} position - */ - var Axis2D = function (dim, scale, coordExtent, axisType, position) { - Axis.call(this, dim, scale, coordExtent); - /** - * Axis type - * - 'category' - * - 'value' - * - 'time' - * - 'log' - * @type {string} - */ - this.type = axisType || 'value'; - - /** - * Axis position - * - 'top' - * - 'bottom' - * - 'left' - * - 'right' - */ - this.position = position || 'bottom'; - }; - - Axis2D.prototype = { - - constructor: Axis2D, - - /** - * Index of axis, can be used as key - */ - index: 0, - /** - * If axis is on the zero position of the other axis - * @type {boolean} - */ - onZero: false, - - /** - * Axis model - * @param {module:echarts/coord/cartesian/AxisModel} - */ - model: null, - - isHorizontal: function () { - var position = this.position; - return position === 'top' || position === 'bottom'; - }, - - getGlobalExtent: function () { - var ret = this.getExtent(); - ret[0] = this.toGlobalCoord(ret[0]); - ret[1] = this.toGlobalCoord(ret[1]); - return ret; - }, - - /** - * @return {number} - */ - getLabelInterval: function () { - var labelInterval = this._labelInterval; - if (!labelInterval) { - labelInterval = this._labelInterval = axisLabelInterval(this); - } - return labelInterval; - }, - - /** - * If label is ignored. - * Automatically used when axis is category and label can not be all shown - * @param {number} idx - * @return {boolean} - */ - isLabelIgnored: function (idx) { - if (this.type === 'category') { - var labelInterval = this.getLabelInterval(); - return ((typeof labelInterval === 'function') - && !labelInterval(idx, this.scale.getLabel(idx))) - || idx % (labelInterval + 1); - } - }, - - /** - * Transform global coord to local coord, - * i.e. var localCoord = axis.toLocalCoord(80); - * designate by module:echarts/coord/cartesian/Grid. - * @type {Function} - */ - toLocalCoord: null, - - /** - * Transform global coord to local coord, - * i.e. var globalCoord = axis.toLocalCoord(40); - * designate by module:echarts/coord/cartesian/Grid. - * @type {Function} - */ - toGlobalCoord: null - - }; - zrUtil.inherits(Axis2D, Axis); - - return Axis2D; -}); -define('echarts/coord/axisDefault',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - var defaultOption = { - show: true, - zlevel: 0, // 一级层叠 - z: 0, // 二级层叠 - // 反向坐标轴 - inverse: false, - // 坐标轴名字,默认为空 - name: '', - // 坐标轴名字位置,支持'start' | 'middle' | 'end' - nameLocation: 'end', - // 坐标轴文字样式,默认取全局样式 - nameTextStyle: {}, - // 文字与轴线距离 - nameGap: 15, - // 坐标轴线 - axisLine: { - // 默认显示,属性show控制显示与否 - show: true, - onZero: true, - // 属性lineStyle控制线条样式 - lineStyle: { - color: '#333', - width: 1, - type: 'solid' - } - }, - // 坐标轴小标记 - axisTick: { - // 属性show控制显示与否,默认显示 - show: true, - // 控制小标记是否在grid里 - inside: false, - // 属性length控制线长 - length: 5, - // 属性lineStyle控制线条样式 - lineStyle: { - color: '#333', - width: 1 - } - }, - // 坐标轴文本标签,详见axis.axisLabel - axisLabel: { - show: true, - // 控制文本标签是否在grid里 - inside: false, - rotate: 0, - margin: 8, - // formatter: null, - // 其余属性默认使用全局文本样式,详见TEXTSTYLE - textStyle: { - color: '#333', - fontSize: 12 - } - }, - // 分隔线 - splitLine: { - // 默认显示,属性show控制显示与否 - show: true, - // 属性lineStyle(详见lineStyle)控制线条样式 - lineStyle: { - color: ['#ccc'], - width: 1, - type: 'solid' - } - }, - // 分隔区域 - splitArea: { - // 默认不显示,属性show控制显示与否 - show: false, - // 属性areaStyle(详见areaStyle)控制区域样式 - areaStyle: { - color: ['rgba(250,250,250,0.3)','rgba(200,200,200,0.3)'] - } - } - }; - - var categoryAxis = zrUtil.merge({ - // 类目起始和结束两端空白策略 - boundaryGap: true, - // 坐标轴小标记 - axisTick: { - interval: 'auto' - }, - // 坐标轴文本标签,详见axis.axisLabel - axisLabel: { - interval: 'auto' - } - }, defaultOption); - - var valueAxis = zrUtil.defaults({ - // 数值起始和结束两端空白策略 - boundaryGap: [0, 0], - // 最小值, 设置成 'dataMin' 则从数据中计算最小值 - // min: null, - // 最大值,设置成 'dataMax' 则从数据中计算最大值 - // max: null, - // 脱离0值比例,放大聚焦到最终_min,_max区间 - // scale: false, - // 分割段数,默认为5 - splitNumber: 5 - }, defaultOption); - - // FIXME - var timeAxis = zrUtil.defaults({ - scale: true, - min: 'dataMin', - max: 'dataMax' - }, valueAxis); - var logAxis = zrUtil.defaults({}, valueAxis); - logAxis.scale = true; - - return { - categoryAxis: categoryAxis, - valueAxis: valueAxis, - timeAxis: timeAxis, - logAxis: logAxis - }; -}); -define('echarts/coord/axisModelCreator',['require','./axisDefault','zrender/core/util','../model/Component','../util/layout'],function (require) { - - var axisDefault = require('./axisDefault'); - var zrUtil = require('zrender/core/util'); - var ComponentModel = require('../model/Component'); - var layout = require('../util/layout'); - - // FIXME axisType is fixed ? - var AXIS_TYPES = ['value', 'category', 'time', 'log']; - - /** - * Generate sub axis model class - * @param {string} axisName 'x' 'y' 'radius' 'angle' 'parallel' - * @param {module:echarts/model/Component} BaseAxisModelClass - * @param {Function} axisTypeDefaulter - * @param {Object} [extraDefaultOption] - */ - return function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) { - - zrUtil.each(AXIS_TYPES, function (axisType) { - - BaseAxisModelClass.extend({ - - type: axisName + 'Axis.' + axisType, - - mergeDefaultAndTheme: function (option, ecModel) { - var layoutMode = this.layoutMode; - var inputPositionParams = layoutMode - ? layout.getLayoutParams(option) : {}; - - var themeModel = ecModel.getTheme(); - zrUtil.merge(option, themeModel.get(axisType + 'Axis')); - zrUtil.merge(option, this.getDefaultOption()); - - option.type = axisTypeDefaulter(axisName, option); - - if (layoutMode) { - layout.mergeLayoutParam(option, inputPositionParams, layoutMode); - } - }, - - defaultOption: zrUtil.mergeAll( - [ - {}, - axisDefault[axisType + 'Axis'], - extraDefaultOption - ], - true - ) - }); - }); - - ComponentModel.registerSubTypeDefaulter( - axisName + 'Axis', - zrUtil.curry(axisTypeDefaulter, axisName) - ); - }; -}); -define('echarts/coord/axisModelCommonMixin',['require','zrender/core/util','./axisHelper'],function (require) { - - var zrUtil = require('zrender/core/util'); - var axisHelper = require('./axisHelper'); - - function getName(obj) { - if (zrUtil.isObject(obj) && obj.value != null) { - return obj.value; - } - else { - return obj; - } - } - /** - * Get categories - */ - function getCategories() { - return this.get('type') === 'category' - && zrUtil.map(this.get('data'), getName); - } - - /** - * Format labels - * @return {Array.} - */ - function getFormattedLabels() { - return axisHelper.getFormattedLabels( - this.axis, - this.get('axisLabel.formatter') - ); - } - - return { - - getFormattedLabels: getFormattedLabels, - - getCategories: getCategories - }; -}); -define('echarts/coord/cartesian/AxisModel',['require','../../model/Component','zrender/core/util','../axisModelCreator','../axisModelCommonMixin'],function(require) { - - - - var ComponentModel = require('../../model/Component'); - var zrUtil = require('zrender/core/util'); - var axisModelCreator = require('../axisModelCreator'); - - var AxisModel = ComponentModel.extend({ - - type: 'cartesian2dAxis', - - /** - * @type {module:echarts/coord/cartesian/Axis2D} - */ - axis: null, - - /** - * @public - * @param {boolean} needs Whether axis needs cross zero. - */ - setNeedsCrossZero: function (needs) { - this.option.scale = !needs; - }, - - /** - * @public - * @param {number} min - */ - setMin: function (min) { - this.option.min = min; - }, - - /** - * @public - * @param {number} max - */ - setMax: function (max) { - this.option.max = max; - } - }); - - function getAxisType(axisDim, option) { - // Default axis with data is category axis - return option.type || (option.data ? 'category' : 'value'); - } - - zrUtil.merge(AxisModel.prototype, require('../axisModelCommonMixin')); - - var extraOption = { - gridIndex: 0 - }; - - axisModelCreator('x', AxisModel, getAxisType, extraOption); - axisModelCreator('y', AxisModel, getAxisType, extraOption); - - return AxisModel; -}); -// Grid 是在有直角坐标系的时候必须要存在的 -// 所以这里也要被 Cartesian2D 依赖 -define('echarts/coord/cartesian/GridModel',['require','./AxisModel','../../model/Component'],function(require) { - - - - require('./AxisModel'); - var ComponentModel = require('../../model/Component'); - - return ComponentModel.extend({ - - type: 'grid', - - dependencies: ['xAxis', 'yAxis'], - - layoutMode: 'box', - - /** - * @type {module:echarts/coord/cartesian/Grid} - */ - coordinateSystem: null, - - defaultOption: { - show: false, - zlevel: 0, - z: 0, - left: '10%', - top: 60, - right: '10%', - bottom: 60, - // If grid size contain label - containLabel: false, - // width: {totalWidth} - left - right, - // height: {totalHeight} - top - bottom, - backgroundColor: 'rgba(0,0,0,0)', - borderWidth: 1, - borderColor: '#ccc' - } - }); -}); -/** - * Grid is a region which contains at most 4 cartesian systems - * - * TODO Default cartesian - */ -define('echarts/coord/cartesian/Grid',['require','exports','module','../../util/layout','../../coord/axisHelper','zrender/core/util','./Cartesian2D','./Axis2D','./GridModel','../../CoordinateSystem'],function(require, factory) { - - var layout = require('../../util/layout'); - var axisHelper = require('../../coord/axisHelper'); - - var zrUtil = require('zrender/core/util'); - var Cartesian2D = require('./Cartesian2D'); - var Axis2D = require('./Axis2D'); - - var each = zrUtil.each; - - var ifAxisCrossZero = axisHelper.ifAxisCrossZero; - var niceScaleExtent = axisHelper.niceScaleExtent; - - // 依赖 GridModel, AxisModel 做预处理 - require('./GridModel'); - - /** - * Check if the axis is used in the specified grid - * @inner - */ - function isAxisUsedInTheGrid(axisModel, gridModel, ecModel) { - return ecModel.getComponent('grid', axisModel.get('gridIndex')) === gridModel; - } - - function getLabelUnionRect(axis) { - var axisModel = axis.model; - var labels = axisModel.getFormattedLabels(); - var rect; - var step = 1; - var labelCount = labels.length; - if (labelCount > 40) { - // Simple optimization for large amount of labels - step = Math.ceil(labelCount / 40); - } - for (var i = 0; i < labelCount; i += step) { - if (!axis.isLabelIgnored(i)) { - var singleRect = axisModel.getTextRect(labels[i]); - // FIXME consider label rotate - rect ? rect.union(singleRect) : (rect = singleRect); - } - } - return rect; - } - - function Grid(gridModel, ecModel, api) { - /** - * @type {Object.} - * @private - */ - this._coordsMap = {}; - - /** - * @type {Array.} - * @private - */ - this._coordsList = []; - - /** - * @type {Object.} - * @private - */ - this._axesMap = {}; - - /** - * @type {Array.} - * @private - */ - this._axesList = []; - - this._initCartesian(gridModel, ecModel, api); - - this._model = gridModel; - } - - var gridProto = Grid.prototype; - - gridProto.type = 'grid'; - - gridProto.getRect = function () { - return this._rect; - }; - - gridProto.update = function (ecModel, api) { - - var axesMap = this._axesMap; - - this._updateScale(ecModel, this._model); - - function ifAxisCanNotOnZero(otherAxisDim) { - var axes = axesMap[otherAxisDim]; - for (var idx in axes) { - var axis = axes[idx]; - if (axis && (axis.type === 'category' || !ifAxisCrossZero(axis))) { - return true; - } - } - return false; - } - - each(axesMap.x, function (xAxis) { - niceScaleExtent(xAxis, xAxis.model); - }); - each(axesMap.y, function (yAxis) { - niceScaleExtent(yAxis, yAxis.model); - }); - // Fix configuration - each(axesMap.x, function (xAxis) { - // onZero can not be enabled in these two situations - // 1. When any other axis is a category axis - // 2. When any other axis not across 0 point - if (ifAxisCanNotOnZero('y')) { - xAxis.onZero = false; - } - }); - each(axesMap.y, function (yAxis) { - if (ifAxisCanNotOnZero('x')) { - yAxis.onZero = false; - } - }); - - // Resize again if containLabel is enabled - // FIXME It may cause getting wrong grid size in data processing stage - this.resize(this._model, api); - }; - - /** - * Resize the grid - * @param {module:echarts/coord/cartesian/GridModel} gridModel - * @param {module:echarts/ExtensionAPI} api - */ - gridProto.resize = function (gridModel, api) { - - var gridRect = layout.getLayoutRect( - gridModel.getBoxLayoutParams(), { - width: api.getWidth(), - height: api.getHeight() - }); - - this._rect = gridRect; - - var axesList = this._axesList; - - adjustAxes(); - - // Minus label size - if (gridModel.get('containLabel')) { - each(axesList, function (axis) { - if (!axis.model.get('axisLabel.inside')) { - var labelUnionRect = getLabelUnionRect(axis); - if (labelUnionRect) { - var dim = axis.isHorizontal() ? 'height' : 'width'; - var margin = axis.model.get('axisLabel.margin'); - gridRect[dim] -= labelUnionRect[dim] + margin; - if (axis.position === 'top') { - gridRect.y += labelUnionRect.height + margin; - } - else if (axis.position === 'left') { - gridRect.x += labelUnionRect.width + margin; - } - } - } - }); - - adjustAxes(); - } - - function adjustAxes() { - each(axesList, function (axis) { - var isHorizontal = axis.isHorizontal(); - var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height]; - var idx = axis.inverse ? 1 : 0; - axis.setExtent(extent[idx], extent[1 - idx]); - updateAxisTransfrom(axis, isHorizontal ? gridRect.x : gridRect.y); - }); - } - }; - - /** - * @param {string} axisType - * @param {ndumber} [axisIndex] - */ - gridProto.getAxis = function (axisType, axisIndex) { - var axesMapOnDim = this._axesMap[axisType]; - if (axesMapOnDim != null) { - if (axisIndex == null) { - // Find first axis - for (var name in axesMapOnDim) { - return axesMapOnDim[name]; - } - } - return axesMapOnDim[axisIndex]; - } - }; - - gridProto.getCartesian = function (xAxisIndex, yAxisIndex) { - var key = 'x' + xAxisIndex + 'y' + yAxisIndex; - return this._coordsMap[key]; - }; - - /** - * Initialize cartesian coordinate systems - * @private - */ - gridProto._initCartesian = function (gridModel, ecModel, api) { - var axisPositionUsed = { - left: false, - right: false, - top: false, - bottom: false - }; - - var axesMap = { - x: {}, - y: {} - }; - var axesCount = { - x: 0, - y: 0 - }; - - /// Create axis - ecModel.eachComponent('xAxis', createAxisCreator('x'), this); - ecModel.eachComponent('yAxis', createAxisCreator('y'), this); - - if (!axesCount.x || !axesCount.y) { - // Roll back when there no either x or y axis - this._axesMap = {}; - this._axesList = []; - return; - } - - this._axesMap = axesMap; - - /// Create cartesian2d - each(axesMap.x, function (xAxis, xAxisIndex) { - each(axesMap.y, function (yAxis, yAxisIndex) { - var key = 'x' + xAxisIndex + 'y' + yAxisIndex; - var cartesian = new Cartesian2D(key); - - cartesian.grid = this; - - this._coordsMap[key] = cartesian; - this._coordsList.push(cartesian); - - cartesian.addAxis(xAxis); - cartesian.addAxis(yAxis); - }, this); - }, this); - - function createAxisCreator(axisType) { - return function (axisModel, idx) { - if (!isAxisUsedInTheGrid(axisModel, gridModel, ecModel)) { - return; - } - - var axisPosition = axisModel.get('position'); - if (axisType === 'x') { - // Fix position - if (axisPosition !== 'top' && axisPosition !== 'bottom') { - // Default bottom of X - axisPosition = 'bottom'; - } - if (axisPositionUsed[axisPosition]) { - axisPosition = axisPosition === 'top' ? 'bottom' : 'top'; - } - } - else { - // Fix position - if (axisPosition !== 'left' && axisPosition !== 'right') { - // Default left of Y - axisPosition = 'left'; - } - if (axisPositionUsed[axisPosition]) { - axisPosition = axisPosition === 'left' ? 'right' : 'left'; - } - } - axisPositionUsed[axisPosition] = true; - - var axis = new Axis2D( - axisType, axisHelper.createScaleByModel(axisModel), - [0, 0], - axisModel.get('type'), - axisPosition - ); - - var isCategory = axis.type === 'category'; - axis.onBand = isCategory && axisModel.get('boundaryGap'); - axis.inverse = axisModel.get('inverse'); - - axis.onZero = axisModel.get('axisLine.onZero'); - - // Inject axis into axisModel - axisModel.axis = axis; - - // Inject axisModel into axis - axis.model = axisModel; - - // Index of axis, can be used as key - axis.index = idx; - - this._axesList.push(axis); - - axesMap[axisType][idx] = axis; - axesCount[axisType]++; - }; - } - }; - - /** - * Update cartesian properties from series - * @param {module:echarts/model/Option} option - * @private - */ - gridProto._updateScale = function (ecModel, gridModel) { - // Reset scale - zrUtil.each(this._axesList, function (axis) { - axis.scale.setExtent(Infinity, -Infinity); - }); - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.get('coordinateSystem') === 'cartesian2d') { - var xAxisIndex = seriesModel.get('xAxisIndex'); - var yAxisIndex = seriesModel.get('yAxisIndex'); - - var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex); - var yAxisModel = ecModel.getComponent('yAxis', yAxisIndex); - - if (!isAxisUsedInTheGrid(xAxisModel, gridModel, ecModel) - || !isAxisUsedInTheGrid(yAxisModel, gridModel, ecModel) - ) { - return; - } - - var cartesian = this.getCartesian(xAxisIndex, yAxisIndex); - var data = seriesModel.getData(); - var xAxis = cartesian.getAxis('x'); - var yAxis = cartesian.getAxis('y'); - - if (data.type === 'list') { - unionExtent(data, xAxis, seriesModel); - unionExtent(data, yAxis, seriesModel); - } - } - }, this); - - function unionExtent(data, axis, seriesModel) { - each(seriesModel.coordDimToDataDim(axis.dim), function (dim) { - axis.scale.unionExtent(data.getDataExtent( - dim, axis.scale.type !== 'ordinal' - )); - }); - } - }; - - /** - * @inner - */ - function updateAxisTransfrom(axis, coordBase) { - var axisExtent = axis.getExtent(); - var axisExtentSum = axisExtent[0] + axisExtent[1]; - - // Fast transform - axis.toGlobalCoord = axis.dim === 'x' - ? function (coord) { - return coord + coordBase; - } - : function (coord) { - return axisExtentSum - coord + coordBase; - }; - axis.toLocalCoord = axis.dim === 'x' - ? function (coord) { - return coord - coordBase; - } - : function (coord) { - return axisExtentSum - coord + coordBase; - }; - } - - Grid.create = function (ecModel, api) { - var grids = []; - ecModel.eachComponent('grid', function (gridModel, idx) { - var grid = new Grid(gridModel, ecModel, api); - grid.name = 'grid_' + idx; - grid.resize(gridModel, api); - - gridModel.coordinateSystem = grid; - - grids.push(grid); - }); - - // Inject the coordinateSystems into seriesModel - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.get('coordinateSystem') !== 'cartesian2d') { - return; - } - var xAxisIndex = seriesModel.get('xAxisIndex'); - // TODO Validate - var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex); - var grid = grids[xAxisModel.get('gridIndex')]; - seriesModel.coordinateSystem = grid.getCartesian( - xAxisIndex, seriesModel.get('yAxisIndex') - ); - }); - - return grids; - }; - - // For deciding which dimensions to use when creating list data - Grid.dimensions = Cartesian2D.prototype.dimensions; - - require('../../CoordinateSystem').register('cartesian2d', Grid); - - return Grid; -}); -define('echarts/chart/bar/BarSeries',['require','../../model/Series','../helper/createListFromArray'],function(require) { - - - - var SeriesModel = require('../../model/Series'); - var createListFromArray = require('../helper/createListFromArray'); - - return SeriesModel.extend({ - - type: 'series.bar', - - dependencies: ['grid', 'polar'], - - getInitialData: function (option, ecModel) { - return createListFromArray(option.data, this, ecModel); - }, - - getMarkerPosition: function (value) { - var coordSys = this.coordinateSystem; - if (coordSys) { - var pt = coordSys.dataToPoint(value); - var data = this.getData(); - var offset = data.getLayout('offset'); - var size = data.getLayout('size'); - var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1; - pt[offsetIndex] += offset + size / 2; - return pt; - } - return [NaN, NaN]; - }, - - defaultOption: { - zlevel: 0, // 一级层叠 - z: 2, // 二级层叠 - coordinateSystem: 'cartesian2d', - legendHoverLink: true, - // stack: null - - // Cartesian coordinate system - xAxisIndex: 0, - yAxisIndex: 0, - - // 最小高度改为0 - barMinHeight: 0, - - // barMaxWidth: null, - // 默认自适应 - // barWidth: null, - // 柱间距离,默认为柱形宽度的30%,可设固定值 - // barGap: '30%', - // 类目间柱形距离,默认为类目间距的20%,可设固定值 - // barCategoryGap: '20%', - // label: { - // normal: { - // show: false - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - - // // 默认自适应,水平布局为'top',垂直布局为'right',可选为 - // // 'inside' | 'insideleft' | 'insideTop' | 'insideRight' | 'insideBottom' | - // // 'outside' |'left' | 'right'|'top'|'bottom' - // position: - - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - // } - // }, - itemStyle: { - normal: { - // color: '各异', - // 柱条边线 - barBorderColor: '#fff', - // 柱条边线线宽,单位px,默认为1 - barBorderWidth: 0 - }, - emphasis: { - // color: '各异', - // 柱条边线 - barBorderColor: '#fff', - // 柱条边线线宽,单位px,默认为1 - barBorderWidth: 0 - } - } - } - }); -}); -define('echarts/chart/bar/barItemStyle',['require','../../model/mixin/makeStyleMapper'],function (require) { - return { - getBarItemStyle: require('../../model/mixin/makeStyleMapper')( - [ - ['fill', 'color'], - ['stroke', 'barBorderColor'], - ['lineWidth', 'barBorderWidth'], - ['opacity'], - ['shadowBlur'], - ['shadowOffsetX'], - ['shadowOffsetY'], - ['shadowColor'] - ] - ) - }; -}); -define('echarts/chart/bar/BarView',['require','zrender/core/util','../../util/graphic','../../model/Model','./barItemStyle','../../echarts'],function (require) { - - - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - - zrUtil.extend(require('../../model/Model').prototype, require('./barItemStyle')); - - function fixLayoutWithLineWidth(layout, lineWidth) { - var signX = layout.width > 0 ? 1 : -1; - var signY = layout.height > 0 ? 1 : -1; - // In case width or height are too small. - lineWidth = Math.min(lineWidth, Math.abs(layout.width), Math.abs(layout.height)); - layout.x += signX * lineWidth / 2; - layout.y += signY * lineWidth / 2; - layout.width -= signX * lineWidth; - layout.height -= signY * lineWidth; - } - - return require('../../echarts').extendChartView({ - - type: 'bar', - - render: function (seriesModel, ecModel, api) { - var coordinateSystemType = seriesModel.get('coordinateSystem'); - - if (coordinateSystemType === 'cartesian2d') { - this._renderOnCartesian(seriesModel, ecModel, api); - } - - return this.group; - }, - - _renderOnCartesian: function (seriesModel, ecModel, api) { - var group = this.group; - var data = seriesModel.getData(); - var oldData = this._data; - - var cartesian = seriesModel.coordinateSystem; - var baseAxis = cartesian.getBaseAxis(); - var isHorizontal = baseAxis.isHorizontal(); - - var enableAnimation = seriesModel.get('animation'); - - var barBorderWidthQuery = ['itemStyle', 'normal', 'barBorderWidth']; - - function createRect(dataIndex, isUpdate) { - var layout = data.getItemLayout(dataIndex); - var lineWidth = data.getItemModel(dataIndex).get(barBorderWidthQuery) || 0; - fixLayoutWithLineWidth(layout, lineWidth); - - var rect = new graphic.Rect({ - shape: zrUtil.extend({}, layout) - }); - // Animation - if (enableAnimation) { - var rectShape = rect.shape; - var animateProperty = isHorizontal ? 'height' : 'width'; - var animateTarget = {}; - rectShape[animateProperty] = 0; - animateTarget[animateProperty] = layout[animateProperty]; - graphic[isUpdate? 'updateProps' : 'initProps'](rect, { - shape: animateTarget - }, seriesModel); - } - return rect; - } - data.diff(oldData) - .add(function (dataIndex) { - // 空数据 - if (!data.hasValue(dataIndex)) { - return; - } - - var rect = createRect(dataIndex); - - data.setItemGraphicEl(dataIndex, rect); - - group.add(rect); - - }) - .update(function (newIndex, oldIndex) { - var rect = oldData.getItemGraphicEl(oldIndex); - // 空数据 - if (!data.hasValue(newIndex)) { - group.remove(rect); - return; - } - if (!rect) { - rect = createRect(newIndex, true); - } - - var layout = data.getItemLayout(newIndex); - var lineWidth = data.getItemModel(newIndex).get(barBorderWidthQuery) || 0; - fixLayoutWithLineWidth(layout, lineWidth); - - graphic.updateProps(rect, { - shape: layout - }, seriesModel); - - data.setItemGraphicEl(newIndex, rect); - - // Add back - group.add(rect); - }) - .remove(function (idx) { - var rect = oldData.getItemGraphicEl(idx); - if (rect) { - // Not show text when animating - rect.style.text = ''; - graphic.updateProps(rect, { - shape: { - width: 0 - } - }, seriesModel, function () { - group.remove(rect); - }); - } - }) - .execute(); - - this._updateStyle(seriesModel, data, isHorizontal); - - this._data = data; - }, - - _updateStyle: function (seriesModel, data, isHorizontal) { - function setLabel(style, model, color, labelText, labelPositionOutside) { - graphic.setText(style, model, color); - style.text = labelText; - if (style.textPosition === 'outside') { - style.textPosition = labelPositionOutside; - } - } - - data.eachItemGraphicEl(function (rect, idx) { - var itemModel = data.getItemModel(idx); - var color = data.getItemVisual(idx, 'color'); - var layout = data.getItemLayout(idx); - var itemStyleModel = itemModel.getModel('itemStyle.normal'); - - var hoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle(); - - rect.setShape('r', itemStyleModel.get('barBorderRadius') || 0); - - rect.setStyle(zrUtil.defaults( - { - fill: color - }, - itemStyleModel.getBarItemStyle() - )); - - var labelPositionOutside = isHorizontal - ? (layout.height > 0 ? 'bottom' : 'top') - : (layout.width > 0 ? 'left' : 'right'); - - var labelModel = itemModel.getModel('label.normal'); - var hoverLabelModel = itemModel.getModel('label.emphasis'); - var rectStyle = rect.style; - if (labelModel.get('show')) { - setLabel( - rectStyle, labelModel, color, - zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'normal'), - seriesModel.getRawValue(idx) - ), - labelPositionOutside - ); - } - else { - rectStyle.text = ''; - } - if (hoverLabelModel.get('show')) { - setLabel( - hoverStyle, hoverLabelModel, color, - zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'emphasis'), - seriesModel.getRawValue(idx) - ), - labelPositionOutside - ); - } - else { - hoverStyle.text = ''; - } - graphic.setHoverStyle(rect, hoverStyle); - }); - }, - - remove: function (ecModel, api) { - var group = this.group; - if (ecModel.get('animation')) { - if (this._data) { - this._data.eachItemGraphicEl(function (el) { - // Not show text when animating - el.style.text = ''; - graphic.updateProps(el, { - shape: { - width: 0 - } - }, ecModel, function () { - group.remove(el); - }); - }); - } - } - else { - group.removeAll(); - } - } - }); -}); -define('echarts/layout/barGrid',['require','zrender/core/util','../util/number'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../util/number'); - var parsePercent = numberUtil.parsePercent; - - function getSeriesStackId(seriesModel) { - return seriesModel.get('stack') || '__ec_stack_' + seriesModel.seriesIndex; - } - - function calBarWidthAndOffset(barSeries, api) { - // Columns info on each category axis. Key is cartesian name - var columnsMap = {}; - - zrUtil.each(barSeries, function (seriesModel, idx) { - var cartesian = seriesModel.coordinateSystem; - - var baseAxis = cartesian.getBaseAxis(); - - var columnsOnAxis = columnsMap[baseAxis.index] || { - remainedWidth: baseAxis.getBandWidth(), - autoWidthCount: 0, - categoryGap: '20%', - gap: '30%', - axis: baseAxis, - stacks: {} - }; - var stacks = columnsOnAxis.stacks; - columnsMap[baseAxis.index] = columnsOnAxis; - - var stackId = getSeriesStackId(seriesModel); - - if (!stacks[stackId]) { - columnsOnAxis.autoWidthCount++; - } - stacks[stackId] = stacks[stackId] || { - width: 0, - maxWidth: 0 - }; - - var barWidth = seriesModel.get('barWidth'); - var barMaxWidth = seriesModel.get('barMaxWidth'); - var barGap = seriesModel.get('barGap'); - var barCategoryGap = seriesModel.get('barCategoryGap'); - // TODO - if (barWidth && ! stacks[stackId].width) { - barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth); - stacks[stackId].width = barWidth; - columnsOnAxis.remainedWidth -= barWidth; - } - - barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth); - (barGap != null) && (columnsOnAxis.gap = barGap); - (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap); - }); - - var result = {}; - - zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) { - - result[coordSysName] = {}; - - var stacks = columnsOnAxis.stacks; - var baseAxis = columnsOnAxis.axis; - var bandWidth = baseAxis.getBandWidth(); - var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth); - var barGapPercent = parsePercent(columnsOnAxis.gap, 1); - - var remainedWidth = columnsOnAxis.remainedWidth; - var autoWidthCount = columnsOnAxis.autoWidthCount; - var autoWidth = (remainedWidth - categoryGap) - / (autoWidthCount + (autoWidthCount - 1) * barGapPercent); - autoWidth = Math.max(autoWidth, 0); - - // Find if any auto calculated bar exceeded maxBarWidth - zrUtil.each(stacks, function (column, stack) { - var maxWidth = column.maxWidth; - if (!column.width && maxWidth && maxWidth < autoWidth) { - maxWidth = Math.min(maxWidth, remainedWidth); - remainedWidth -= maxWidth; - column.width = maxWidth; - autoWidthCount--; - } - }); - - // Recalculate width again - autoWidth = (remainedWidth - categoryGap) - / (autoWidthCount + (autoWidthCount - 1) * barGapPercent); - autoWidth = Math.max(autoWidth, 0); - - var widthSum = 0; - var lastColumn; - zrUtil.each(stacks, function (column, idx) { - if (!column.width) { - column.width = autoWidth; - } - lastColumn = column; - widthSum += column.width * (1 + barGapPercent); - }); - if (lastColumn) { - widthSum -= lastColumn.width * barGapPercent; - } - - var offset = -widthSum / 2; - zrUtil.each(stacks, function (column, stackId) { - result[coordSysName][stackId] = result[coordSysName][stackId] || { - offset: offset, - width: column.width - }; - - offset += column.width * (1 + barGapPercent); - }); - }); - - return result; - } - - /** - * @param {string} seriesType - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - */ - function barLayoutGrid(seriesType, ecModel, api) { - - var barWidthAndOffset = calBarWidthAndOffset( - zrUtil.filter( - ecModel.getSeriesByType(seriesType), - function (seriesModel) { - return !ecModel.isSeriesFiltered(seriesModel) - && seriesModel.coordinateSystem - && seriesModel.coordinateSystem.type === 'cartesian2d'; - } - ) - ); - - var lastStackCoords = {}; - - ecModel.eachSeriesByType(seriesType, function (seriesModel) { - - var data = seriesModel.getData(); - var cartesian = seriesModel.coordinateSystem; - var baseAxis = cartesian.getBaseAxis(); - - var stackId = getSeriesStackId(seriesModel); - var columnLayoutInfo = barWidthAndOffset[baseAxis.index][stackId]; - var columnOffset = columnLayoutInfo.offset; - var columnWidth = columnLayoutInfo.width; - var valueAxis = cartesian.getOtherAxis(baseAxis); - - var barMinHeight = seriesModel.get('barMinHeight') || 0; - - var valueAxisStart = baseAxis.onZero - ? valueAxis.toGlobalCoord(valueAxis.dataToCoord(0)) - : valueAxis.getGlobalExtent()[0]; - - var coords = cartesian.dataToPoints(data, true); - lastStackCoords[stackId] = lastStackCoords[stackId] || []; - - data.setLayout({ - offset: columnOffset, - size: columnWidth - }); - data.each(valueAxis.dim, function (value, idx) { - // 空数据 - if (isNaN(value)) { - return; - } - if (!lastStackCoords[stackId][idx]) { - lastStackCoords[stackId][idx] = { - // Positive stack - p: valueAxisStart, - // Negative stack - n: valueAxisStart - }; - } - var sign = value >= 0 ? 'p' : 'n'; - var coord = coords[idx]; - var lastCoord = lastStackCoords[stackId][idx][sign]; - var x, y, width, height; - if (valueAxis.isHorizontal()) { - x = lastCoord; - y = coord[1] + columnOffset; - width = coord[0] - lastCoord; - height = columnWidth; - - if (Math.abs(width) < barMinHeight) { - width = (width < 0 ? -1 : 1) * barMinHeight; - } - lastStackCoords[stackId][idx][sign] += width; - } - else { - x = coord[0] + columnOffset; - y = lastCoord; - width = columnWidth; - height = coord[1] - lastCoord; - if (Math.abs(height) < barMinHeight) { - // Include zero to has a positive bar - height = (height <= 0 ? -1 : 1) * barMinHeight; - } - lastStackCoords[stackId][idx][sign] += height; - } - - data.setItemLayout(idx, { - x: x, - y: y, - width: width, - height: height - }); - }, true); - - }, this); - } - - return barLayoutGrid; -}); -define('echarts/chart/bar',['require','zrender/core/util','../coord/cartesian/Grid','./bar/BarSeries','./bar/BarView','../layout/barGrid','../echarts'],function (require) { + __webpack_require__(287); - var zrUtil = require('zrender/core/util'); + __webpack_require__(288); + __webpack_require__(290); - require('../coord/cartesian/Grid'); + __webpack_require__(342); + __webpack_require__(343); - require('./bar/BarSeries'); - require('./bar/BarView'); + __webpack_require__(298); + __webpack_require__(299); - var barLayoutGrid = require('../layout/barGrid'); - var echarts = require('../echarts'); - echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar')); - // Visual coding for legend - echarts.registerVisualCoding('chart', function (ecModel) { - ecModel.eachSeriesByType('bar', function (seriesModel) { - var data = seriesModel.getData(); - data.setVisual('legendSymbol', 'roundRect'); - }); - }); -}); -/** - * Data selectable mixin for chart series. - * To eanble data select, option of series must have `selectedMode`. - * And each data item will use `selected` to toggle itself selected status - * - * @module echarts/chart/helper/DataSelectable - */ -define('echarts/chart/helper/dataSelectableMixin',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - return { - - updateSelectedMap: function () { - var option = this.option; - this._dataOptMap = zrUtil.reduce(option.data, function (dataOptMap, dataOpt) { - dataOptMap[dataOpt.name] = dataOpt; - return dataOptMap; - }, {}); - }, - /** - * @param {string} name - */ - // PENGING If selectedMode is null ? - select: function (name) { - var dataOptMap = this._dataOptMap; - var dataOpt = dataOptMap[name]; - var selectedMode = this.get('selectedMode'); - if (selectedMode === 'single') { - zrUtil.each(dataOptMap, function (dataOpt) { - dataOpt.selected = false; - }); - } - dataOpt && (dataOpt.selected = true); - }, - - /** - * @param {string} name - */ - unSelect: function (name) { - var dataOpt = this._dataOptMap[name]; - // var selectedMode = this.get('selectedMode'); - // selectedMode !== 'single' && dataOpt && (dataOpt.selected = false); - dataOpt && (dataOpt.selected = false); - }, - - /** - * @param {string} name - */ - toggleSelected: function (name) { - var dataOpt = this._dataOptMap[name]; - if (dataOpt != null) { - this[dataOpt.selected ? 'unSelect' : 'select'](name); - return dataOpt.selected; - } - }, - - /** - * @param {string} name - */ - isSelected: function (name) { - var dataOpt = this._dataOptMap[name]; - return dataOpt && dataOpt.selected; - } - }; -}); -define('echarts/chart/pie/PieSeries',['require','../../data/List','zrender/core/util','../../util/model','../../data/helper/completeDimensions','../helper/dataSelectableMixin','../../echarts'],function(require) { - - - - var List = require('../../data/List'); - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../../util/model'); - var completeDimensions = require('../../data/helper/completeDimensions'); - - var dataSelectableMixin = require('../helper/dataSelectableMixin'); - - var PieSeries = require('../../echarts').extendSeriesModel({ - - type: 'series.pie', - - // Overwrite - init: function (option) { - PieSeries.superApply(this, 'init', arguments); - - // Enable legend selection for each data item - // Use a function instead of direct access because data reference may changed - this.legendDataProvider = function () { - return this._dataBeforeProcessed; - }; - - this.updateSelectedMap(); - - this._defaultLabelLine(option); - }, - - // Overwrite - mergeOption: function (newOption) { - PieSeries.superCall(this, 'mergeOption', newOption); - this.updateSelectedMap(); - }, - - getInitialData: function (option, ecModel) { - var dimensions = completeDimensions(['value'], option.data); - var list = new List(dimensions, this); - list.initData(option.data); - return list; - }, - - // Overwrite - getDataParams: function (dataIndex) { - var data = this._data; - var params = PieSeries.superCall(this, 'getDataParams', dataIndex); - var sum = data.getSum('value'); - // FIXME toFixed? - // - // Percent is 0 if sum is 0 - params.percent = !sum ? 0 : +(data.get('value', dataIndex) / sum * 100).toFixed(2); - - params.$vars.push('percent'); - return params; - }, - - _defaultLabelLine: function (option) { - // Extend labelLine emphasis - modelUtil.defaultEmphasis(option.labelLine, ['show']); - - var labelLineNormalOpt = option.labelLine.normal; - var labelLineEmphasisOpt = option.labelLine.emphasis; - // Not show label line if `label.normal.show = false` - labelLineNormalOpt.show = labelLineNormalOpt.show - && option.label.normal.show; - labelLineEmphasisOpt.show = labelLineEmphasisOpt.show - && option.label.emphasis.show; - }, - - defaultOption: { - zlevel: 0, - z: 2, - legendHoverLink: true, - - hoverAnimation: true, - // 默认全局居中 - center: ['50%', '50%'], - radius: [0, '75%'], - // 默认顺时针 - clockwise: true, - startAngle: 90, - // 最小角度改为0 - minAngle: 0, - // 选中是扇区偏移量 - selectedOffset: 10, - - // If use strategy to avoid label overlapping - avoidLabelOverlap: true, - // 选择模式,默认关闭,可选single,multiple - // selectedMode: false, - // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积) - // roseType: null, - - label: { - normal: { - // If rotate around circle - rotate: false, - show: true, - // 'outer', 'inside', 'center' - position: 'outer' - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数 - }, - emphasis: {} - }, - // Enabled when label.normal.position is 'outer' - labelLine: { - normal: { - show: true, - // 引导线两段中的第一段长度 - length: 20, - // 引导线两段中的第二段长度 - length2: 5, - smooth: false, - lineStyle: { - // color: 各异, - width: 1, - type: 'solid' - } - } - }, - itemStyle: { - normal: { - // color: 各异, - borderColor: 'rgba(0,0,0,0)', - borderWidth: 1 - }, - emphasis: { - // color: 各异, - borderColor: 'rgba(0,0,0,0)', - borderWidth: 1 - } - }, - - animationEasing: 'cubicOut', - - data: [] - } - }); - - zrUtil.mixin(PieSeries, dataSelectableMixin); - - return PieSeries; -}); -define('echarts/chart/pie/PieView',['require','../../util/graphic','zrender/core/util','../../view/Chart'],function (require) { - - var graphic = require('../../util/graphic'); - var zrUtil = require('zrender/core/util'); - - /** - * @param {module:echarts/model/Series} seriesModel - * @param {boolean} hasAnimation - * @inner - */ - function updateDataSelected(uid, seriesModel, hasAnimation, api) { - var data = seriesModel.getData(); - var dataIndex = this.dataIndex; - var name = data.getName(dataIndex); - var selectedOffset = seriesModel.get('selectedOffset'); - - api.dispatchAction({ - type: 'pieToggleSelect', - from: uid, - name: name, - seriesId: seriesModel.id - }); - - data.each(function (idx) { - toggleItemSelected( - data.getItemGraphicEl(idx), - data.getItemLayout(idx), - seriesModel.isSelected(data.getName(idx)), - selectedOffset, - hasAnimation - ); - }); - } - - /** - * @param {module:zrender/graphic/Sector} el - * @param {Object} layout - * @param {boolean} isSelected - * @param {number} selectedOffset - * @param {boolean} hasAnimation - * @inner - */ - function toggleItemSelected(el, layout, isSelected, selectedOffset, hasAnimation) { - var midAngle = (layout.startAngle + layout.endAngle) / 2; - - var dx = Math.cos(midAngle); - var dy = Math.sin(midAngle); - - var offset = isSelected ? selectedOffset : 0; - var position = [dx * offset, dy * offset]; - - hasAnimation - // animateTo will stop revious animation like update transition - ? el.animate() - .when(200, { - position: position - }) - .start('bounceOut') - : el.attr('position', position); - } - - /** - * Piece of pie including Sector, Label, LabelLine - * @constructor - * @extends {module:zrender/graphic/Group} - */ - function PiePiece(data, idx) { - - graphic.Group.call(this); - - var sector = new graphic.Sector({ - z2: 2 - }); - var polyline = new graphic.Polyline(); - var text = new graphic.Text(); - this.add(sector); - this.add(polyline); - this.add(text); - - this.updateData(data, idx, true); - - // Hover to change label and labelLine - function onEmphasis() { - polyline.ignore = polyline.hoverIgnore; - text.ignore = text.hoverIgnore; - } - function onNormal() { - polyline.ignore = polyline.normalIgnore; - text.ignore = text.normalIgnore; - } - this.on('emphasis', onEmphasis) - .on('normal', onNormal) - .on('mouseover', onEmphasis) - .on('mouseout', onNormal); - } - - var piePieceProto = PiePiece.prototype; - - function getLabelStyle(data, idx, state, labelModel) { - var textStyleModel = labelModel.getModel('textStyle'); - var position = labelModel.get('position'); - var isLabelInside = position === 'inside' || position === 'inner'; - return { - fill: textStyleModel.getTextColor() - || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')), - textFont: textStyleModel.getFont(), - text: zrUtil.retrieve( - data.hostModel.getFormattedLabel(idx, state), data.getName(idx) - ) - }; - } - - piePieceProto.updateData = function (data, idx, firstCreate) { - - var sector = this.childAt(0); - - var seriesModel = data.hostModel; - var itemModel = data.getItemModel(idx); - var layout = data.getItemLayout(idx); - var sectorShape = zrUtil.extend({}, layout); - sectorShape.label = null; - if (firstCreate) { - sector.setShape(sectorShape); - sector.shape.endAngle = layout.startAngle; - graphic.updateProps(sector, { - shape: { - endAngle: layout.endAngle - } - }, seriesModel); - } - else { - graphic.updateProps(sector, { - shape: sectorShape - }, seriesModel); - } - - // Update common style - var itemStyleModel = itemModel.getModel('itemStyle'); - var visualColor = data.getItemVisual(idx, 'color'); - - sector.setStyle( - zrUtil.defaults( - { - fill: visualColor - }, - itemStyleModel.getModel('normal').getItemStyle() - ) - ); - sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle(); - - // Toggle selected - toggleItemSelected( - this, - data.getItemLayout(idx), - itemModel.get('selected'), - seriesModel.get('selectedOffset'), - seriesModel.get('animation') - ); - - function onEmphasis() { - // Sector may has animation of updating data. Force to move to the last frame - // Or it may stopped on the wrong shape - sector.stopAnimation(true); - sector.animateTo({ - shape: { - r: layout.r + 10 - } - }, 300, 'elasticOut'); - } - function onNormal() { - sector.stopAnimation(true); - sector.animateTo({ - shape: { - r: layout.r - } - }, 300, 'elasticOut'); - } - sector.off('mouseover').off('mouseout').off('emphasis').off('normal'); - if (itemModel.get('hoverAnimation')) { - sector - .on('mouseover', onEmphasis) - .on('mouseout', onNormal) - .on('emphasis', onEmphasis) - .on('normal', onNormal); - } - - this._updateLabel(data, idx); - - graphic.setHoverStyle(this); - }; - - piePieceProto._updateLabel = function (data, idx) { - - var labelLine = this.childAt(1); - var labelText = this.childAt(2); - - var seriesModel = data.hostModel; - var itemModel = data.getItemModel(idx); - var layout = data.getItemLayout(idx); - var labelLayout = layout.label; - var visualColor = data.getItemVisual(idx, 'color'); - - graphic.updateProps(labelLine, { - shape: { - points: labelLayout.linePoints || [ - [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y] - ] - } - }, seriesModel); - - graphic.updateProps(labelText, { - style: { - x: labelLayout.x, - y: labelLayout.y - } - }, seriesModel); - labelText.attr({ - style: { - textAlign: labelLayout.textAlign, - textBaseline: labelLayout.textBaseline, - textFont: labelLayout.font - }, - rotation: labelLayout.rotation, - origin: [labelLayout.x, labelLayout.y], - z2: 10 - }); - - var labelModel = itemModel.getModel('label.normal'); - var labelHoverModel = itemModel.getModel('label.emphasis'); - var labelLineModel = itemModel.getModel('labelLine.normal'); - var labelLineHoverModel = itemModel.getModel('labelLine.emphasis'); - - labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel)); - - labelText.ignore = labelText.normalIgnore = !labelModel.get('show'); - labelText.hoverIgnore = !labelHoverModel.get('show'); - - labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show'); - labelLine.hoverIgnore = !labelLineHoverModel.get('show'); - - // Default use item visual color - labelLine.setStyle({ - stroke: visualColor - }); - labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle()); - - labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel); - labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle(); - - var smooth = labelLineModel.get('smooth'); - if (smooth && smooth === true) { - smooth = 0.4; - } - labelLine.setShape({ - smooth: smooth - }); - }; - - zrUtil.inherits(PiePiece, graphic.Group); - - - // Pie view - var Pie = require('../../view/Chart').extend({ - - type: 'pie', - - init: function () { - var sectorGroup = new graphic.Group(); - this._sectorGroup = sectorGroup; - }, - - render: function (seriesModel, ecModel, api, payload) { - if (payload && (payload.from === this.uid)) { - return; - } - - var data = seriesModel.getData(); - var oldData = this._data; - var group = this.group; - - var hasAnimation = ecModel.get('animation'); - var isFirstRender = !oldData; - - var onSectorClick = zrUtil.curry( - updateDataSelected, this.uid, seriesModel, hasAnimation, api - ); - - var selectedMode = seriesModel.get('selectedMode'); - - data.diff(oldData) - .add(function (idx) { - var piePiece = new PiePiece(data, idx); - if (isFirstRender) { - piePiece.eachChild(function (child) { - child.stopAnimation(true); - }); - } - - selectedMode && piePiece.on('click', onSectorClick); - - data.setItemGraphicEl(idx, piePiece); - - group.add(piePiece); - }) - .update(function (newIdx, oldIdx) { - var piePiece = oldData.getItemGraphicEl(oldIdx); - - piePiece.updateData(data, newIdx); - - piePiece.off('click'); - selectedMode && piePiece.on('click', onSectorClick); - group.add(piePiece); - data.setItemGraphicEl(newIdx, piePiece); - }) - .remove(function (idx) { - var piePiece = oldData.getItemGraphicEl(idx); - group.remove(piePiece); - }) - .execute(); - - if (hasAnimation && isFirstRender && data.count() > 0) { - var shape = data.getItemLayout(0); - var r = Math.max(api.getWidth(), api.getHeight()) / 2; - - var removeClipPath = zrUtil.bind(group.removeClipPath, group); - group.setClipPath(this._createClipPath( - shape.cx, shape.cy, r, shape.startAngle, shape.clockwise, removeClipPath, seriesModel - )); - } - - this._data = data; - }, - - _createClipPath: function ( - cx, cy, r, startAngle, clockwise, cb, seriesModel - ) { - var clipPath = new graphic.Sector({ - shape: { - cx: cx, - cy: cy, - r0: 0, - r: r, - startAngle: startAngle, - endAngle: startAngle, - clockwise: clockwise - } - }); - - graphic.initProps(clipPath, { - shape: { - endAngle: startAngle + (clockwise ? 1 : -1) * Math.PI * 2 - } - }, seriesModel, cb); - - return clipPath; - } - }); - - return Pie; -}); -define('echarts/action/createDataSelectAction',['require','../echarts','zrender/core/util'],function (require) { - var echarts = require('../echarts'); - var zrUtil = require('zrender/core/util'); - return function (seriesType, actionInfos) { - zrUtil.each(actionInfos, function (actionInfo) { - actionInfo.update = 'updateView'; - /** - * @payload - * @property {string} seriesName - * @property {string} name - */ - echarts.registerAction(actionInfo, function (payload, ecModel) { - var selected = {}; - ecModel.eachComponent( - {mainType: 'series', subType: seriesType, query: payload}, - function (seriesModel) { - if (seriesModel[actionInfo.method]) { - seriesModel[actionInfo.method](payload.name); - } - var data = seriesModel.getData(); - // Create selected map - data.each(function (idx) { - var name = data.getName(idx); - selected[name] = seriesModel.isSelected(name) || false; - }); - } - ); - return { - name: payload.name, - selected: selected - }; - }); - }); - }; -}); -// Pick color from palette for each data item -define('echarts/visual/dataColor',['require'],function (require) { - - return function (seriesType, ecModel) { - var globalColorList = ecModel.get('color'); - var offset = 0; - ecModel.eachRawSeriesByType(seriesType, function (seriesModel) { - var colorList = seriesModel.get('color', true); - var dataAll = seriesModel.getRawData(); - if (!ecModel.isSeriesFiltered(seriesModel)) { - var data = seriesModel.getData(); - data.each(function (idx) { - var itemModel = data.getItemModel(idx); - var rawIdx = data.getRawIndex(idx); - // If series.itemStyle.normal.color is a function. itemVisual may be encoded - var singleDataColor = data.getItemVisual(idx, 'color', true); - if (!singleDataColor) { - var paletteColor = colorList ? colorList[rawIdx % colorList.length] - : globalColorList[(rawIdx + offset) % globalColorList.length]; - var color = itemModel.get('itemStyle.normal.color') || paletteColor; - // Legend may use the visual info in data before processed - dataAll.setItemVisual(rawIdx, 'color', color); - data.setItemVisual(idx, 'color', color); - } - else { - // Set data all color for legend - dataAll.setItemVisual(rawIdx, 'color', singleDataColor); - } - }); - } - offset += dataAll.count(); - }); - }; -}); -// FIXME emphasis label position is not same with normal label position -define('echarts/chart/pie/labelLayout',['require','zrender/contain/text'],function (require) { - - - - var textContain = require('zrender/contain/text'); - - function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) { - list.sort(function (a, b) { - return a.y - b.y; - }); - - // 压 - function shiftDown(start, end, delta, dir) { - for (var j = start; j < end; j++) { - list[j].y += delta; - if (j > start - && j + 1 < end - && list[j + 1].y > list[j].y + list[j].height - ) { - shiftUp(j, delta / 2); - return; - } - } - - shiftUp(end - 1, delta / 2); - } - - // 弹 - function shiftUp(end, delta) { - for (var j = end; j >= 0; j--) { - list[j].y -= delta; - if (j > 0 - && list[j].y > list[j - 1].y + list[j - 1].height - ) { - break; - } - } - } - - // function changeX(list, isDownList, cx, cy, r, dir) { - // var deltaX; - // var deltaY; - // var length; - // var lastDeltaX = dir > 0 - // ? isDownList // 右侧 - // ? Number.MAX_VALUE // 下 - // : 0 // 上 - // : isDownList // 左侧 - // ? Number.MAX_VALUE // 下 - // : 0; // 上 - - // for (var i = 0, l = list.length; i < l; i++) { - // deltaY = Math.abs(list[i].y - cy); - // length = list[i].length; - // deltaX = (deltaY < r + length) - // ? Math.sqrt( - // (r + length + 20) * (r + length + 20) - // - Math.pow(list[i].y - cy, 2) - // ) - // : Math.abs( - // list[i].x - cx - // ); - // if (isDownList && deltaX >= lastDeltaX) { - // // 右下,左下 - // deltaX = lastDeltaX - 10; - // } - // if (!isDownList && deltaX <= lastDeltaX) { - // // 右上,左上 - // deltaX = lastDeltaX + 10; - // } - - // list[i].x = cx + deltaX * dir; - // lastDeltaX = deltaX; - // } - // } - - var lastY = 0; - var delta; - var len = list.length; - var upList = []; - var downList = []; - for (var i = 0; i < len; i++) { - delta = list[i].y - lastY; - if (delta < 0) { - shiftDown(i, len, -delta, dir); - } - lastY = list[i].y + list[i].height; - } - if (viewHeight - lastY < 0) { - shiftUp(len - 1, lastY - viewHeight); - } - for (var i = 0; i < len; i++) { - if (list[i].y >= cy) { - downList.push(list[i]); - } - else { - upList.push(list[i]); - } - } - // changeX(downList, true, cx, cy, r, dir); - // changeX(upList, false, cx, cy, r, dir); - } - - function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) { - var leftList = []; - var rightList = []; - for (var i = 0; i < labelLayoutList.length; i++) { - if (labelLayoutList[i].x < cx) { - leftList.push(labelLayoutList[i]); - } - else { - rightList.push(labelLayoutList[i]); - } - } - - adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight); - adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight); - - for (var i = 0; i < labelLayoutList.length; i++) { - var linePoints = labelLayoutList[i].linePoints; - if (linePoints) { - if (labelLayoutList[i].x < cx) { - linePoints[2][0] = labelLayoutList[i].x + 3; - } - else { - linePoints[2][0] = labelLayoutList[i].x - 3; - } - linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y; - } - } - } - - return function (seriesModel, r, viewWidth, viewHeight) { - var data = seriesModel.getData(); - var labelLayoutList = []; - var cx; - var cy; - var hasLabelRotate = false; - - data.each(function (idx) { - var layout = data.getItemLayout(idx); - - var itemModel = data.getItemModel(idx); - var labelModel = itemModel.getModel('label.normal'); - var labelPosition = labelModel.get('position'); - - var labelLineModel = itemModel.getModel('labelLine.normal'); - var labelLineLen = labelLineModel.get('length'); - var labelLineLen2 = labelLineModel.get('length2'); - - var midAngle = (layout.startAngle + layout.endAngle) / 2; - var dx = Math.cos(midAngle); - var dy = Math.sin(midAngle); - - var textX; - var textY; - var linePoints; - var textAlign; - - cx = layout.cx; - cy = layout.cy; - - if (labelPosition === 'center') { - textX = layout.cx; - textY = layout.cy; - textAlign = 'center'; - } - else { - var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner'; - var x1 = (isLabelInside ? layout.r / 2 * dx : layout.r * dx) + cx; - var y1 = (isLabelInside ? layout.r / 2 * dy : layout.r * dy) + cy; - - // For roseType - labelLineLen += r - layout.r; - - textX = x1 + dx * 3; - textY = y1 + dy * 3; - - if (!isLabelInside) { - var x2 = x1 + dx * labelLineLen; - var y2 = y1 + dy * labelLineLen; - var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2); - var y3 = y2; - - textX = x3 + (dx < 0 ? -5 : 5); - textY = y3; - linePoints = [[x1, y1], [x2, y2], [x3, y3]]; - } - - textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right'); - } - var textBaseline = 'middle'; - var font = labelModel.getModel('textStyle').getFont(); - - var labelRotate = labelModel.get('rotate') - ? (dx < 0 ? -midAngle + Math.PI : -midAngle) : 0; - var text = seriesModel.getFormattedLabel(idx, 'normal') - || data.getName(idx); - var textRect = textContain.getBoundingRect( - text, font, textAlign, textBaseline - ); - hasLabelRotate = !!labelRotate; - layout.label = { - x: textX, - y: textY, - height: textRect.height, - length: labelLineLen, - length2: labelLineLen2, - linePoints: linePoints, - textAlign: textAlign, - textBaseline: textBaseline, - font: font, - rotation: labelRotate - }; - - labelLayoutList.push(layout.label); - }); - if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) { - avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight); - } - }; -}); -// TODO minAngle - -define('echarts/chart/pie/pieLayout',['require','../../util/number','./labelLayout','zrender/core/util'],function (require) { - - var numberUtil = require('../../util/number'); - var parsePercent = numberUtil.parsePercent; - var labelLayout = require('./labelLayout'); - var zrUtil = require('zrender/core/util'); - - var PI2 = Math.PI * 2; - var RADIAN = Math.PI / 180; - - return function (seriesType, ecModel, api) { - ecModel.eachSeriesByType(seriesType, function (seriesModel) { - var center = seriesModel.get('center'); - var radius = seriesModel.get('radius'); - - if (!zrUtil.isArray(radius)) { - radius = [0, radius]; - } - if (!zrUtil.isArray(center)) { - center = [center, center]; - } - - var width = api.getWidth(); - var height = api.getHeight(); - var size = Math.min(width, height); - var cx = parsePercent(center[0], width); - var cy = parsePercent(center[1], height); - var r0 = parsePercent(radius[0], size / 2); - var r = parsePercent(radius[1], size / 2); - - var data = seriesModel.getData(); - - var startAngle = -seriesModel.get('startAngle') * RADIAN; - - var minAngle = seriesModel.get('minAngle') * RADIAN; - - var sum = data.getSum('value'); - // Sum may be 0 - var unitRadian = Math.PI / (sum || data.count()) * 2; - - var clockwise = seriesModel.get('clockwise'); - - var roseType = seriesModel.get('roseType'); - - // [0...max] - var extent = data.getDataExtent('value'); - extent[0] = 0; - - // In the case some sector angle is smaller than minAngle - var restAngle = PI2; - var valueSumLargerThanMinAngle = 0; - - var currentAngle = startAngle; - - var dir = clockwise ? 1 : -1; - data.each('value', function (value, idx) { - var angle; - // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样? - if (roseType !== 'area') { - angle = sum === 0 ? unitRadian : (value * unitRadian); - } - else { - angle = PI2 / (data.count() || 1); - } - - if (angle < minAngle) { - angle = minAngle; - restAngle -= minAngle; - } - else { - valueSumLargerThanMinAngle += value; - } - - var endAngle = currentAngle + dir * angle; - data.setItemLayout(idx, { - angle: angle, - startAngle: currentAngle, - endAngle: endAngle, - clockwise: clockwise, - cx: cx, - cy: cy, - r0: r0, - r: roseType - ? numberUtil.linearMap(value, extent, [r0, r]) - : r - }); - - currentAngle = endAngle; - }, true); - - // Some sector is constrained by minAngle - // Rest sectors needs recalculate angle - if (restAngle < PI2) { - // Average the angle if rest angle is not enough after all angles is - // Constrained by minAngle - if (restAngle <= 1e-3) { - var angle = PI2 / data.count(); - data.each(function (idx) { - var layout = data.getItemLayout(idx); - layout.startAngle = startAngle + dir * idx * angle; - layout.endAngle = startAngle + dir * (idx + 1) * angle; - }); - } - else { - unitRadian = restAngle / valueSumLargerThanMinAngle; - currentAngle = startAngle; - data.each('value', function (value, idx) { - var layout = data.getItemLayout(idx); - var angle = layout.angle === minAngle - ? minAngle : value * unitRadian; - layout.startAngle = currentAngle; - layout.endAngle = currentAngle + dir * angle; - currentAngle += angle; - }); - } - } - - labelLayout(seriesModel, r, width, height); - }); - }; -}); -define('echarts/processor/dataFilter',[],function () { - return function (seriesType, ecModel) { - var legendModels = ecModel.findComponents({ - mainType: 'legend' - }); - if (!legendModels || !legendModels.length) { - return; - } - ecModel.eachSeriesByType(seriesType, function (series) { - var data = series.getData(); - data.filterSelf(function (idx) { - var name = data.getName(idx); - // If in any legend component the status is not selected. - for (var i = 0; i < legendModels.length; i++) { - if (!legendModels[i].isSelected(name)) { - return false; - } - } - return true; - }, this); - }, this); - }; -}); -define('echarts/chart/pie',['require','zrender/core/util','../echarts','./pie/PieSeries','./pie/PieView','../action/createDataSelectAction','../visual/dataColor','./pie/pieLayout','../processor/dataFilter'],function (require) { - - var zrUtil = require('zrender/core/util'); - var echarts = require('../echarts'); - - require('./pie/PieSeries'); - require('./pie/PieView'); - - require('../action/createDataSelectAction')('pie', [{ - type: 'pieToggleSelect', - event: 'pieselectchanged', - method: 'toggleSelected' - }, { - type: 'pieSelect', - event: 'pieselected', - method: 'select' - }, { - type: 'pieUnSelect', - event: 'pieunselected', - method: 'unSelect' - }]); - - echarts.registerVisualCoding( - 'chart', zrUtil.curry(require('../visual/dataColor'), 'pie') - ); - - echarts.registerLayout(zrUtil.curry( - require('./pie/pieLayout'), 'pie' - )); - - echarts.registerProcessor( - 'filter', zrUtil.curry(require('../processor/dataFilter'), 'pie') - ); -}); -define('echarts/chart/scatter/ScatterSeries',['require','../helper/createListFromArray','../../model/Series'],function (require) { - - - - var createListFromArray = require('../helper/createListFromArray'); - var SeriesModel = require('../../model/Series'); - - return SeriesModel.extend({ - - type: 'series.scatter', - - dependencies: ['grid', 'polar'], - - getInitialData: function (option, ecModel) { - var list = createListFromArray(option.data, this, ecModel); - return list; - }, - - defaultOption: { - coordinateSystem: 'cartesian2d', - zlevel: 0, - z: 2, - legendHoverLink: true, - - hoverAnimation: true, - // Cartesian coordinate system - xAxisIndex: 0, - yAxisIndex: 0, - - // Polar coordinate system - polarIndex: 0, - - // Geo coordinate system - geoIndex: 0, - - // symbol: null, // 图形类型 - symbolSize: 10, // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2 - // symbolRotate: null, // 图形旋转控制 - - large: false, - // Available when large is true - largeThreshold: 2000, - - // label: { - // normal: { - // show: false - // distance: 5, - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 - // 'inside'|'left'|'right'|'top'|'bottom' - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - // } - // }, - itemStyle: { - normal: { - opacity: 0.8 - // color: 各异 - } - } - } - }); -}); -define('echarts/chart/helper/LargeSymbolDraw',['require','../../util/graphic','../../util/symbol','zrender/core/util'],function (require) { - - var graphic = require('../../util/graphic'); - var symbolUtil = require('../../util/symbol'); - var zrUtil = require('zrender/core/util'); - - var LargeSymbolPath = graphic.extendShape({ - shape: { - points: null, - sizes: null - }, - - symbolProxy: null, - - buildPath: function (path, shape) { - var points = shape.points; - var sizes = shape.sizes; - - var symbolProxy = this.symbolProxy; - var symbolProxyShape = symbolProxy.shape; - for (var i = 0; i < points.length; i++) { - var pt = points[i]; - var size = sizes[i]; - if (size[0] < 4) { - // Optimize for small symbol - path.rect( - pt[0] - size[0] / 2, pt[1] - size[1] / 2, - size[0], size[1] - ); - } - else { - symbolProxyShape.x = pt[0] - size[0] / 2; - symbolProxyShape.y = pt[1] - size[1] / 2; - symbolProxyShape.width = size[0]; - symbolProxyShape.height = size[1]; - - symbolProxy.buildPath(path, symbolProxyShape); - } - } - } - }); - - function LargeSymbolDraw() { - this.group = new graphic.Group(); - - this._symbolEl = new LargeSymbolPath({ - silent: true - }); - } - - var largeSymbolProto = LargeSymbolDraw.prototype; - - /** - * Update symbols draw by new data - * @param {module:echarts/data/List} data - */ - largeSymbolProto.updateData = function (data) { - this.group.removeAll(); - - var symbolEl = this._symbolEl; - - var seriesModel = data.hostModel; - - symbolEl.setShape({ - points: data.mapArray(data.getItemLayout), - sizes: data.mapArray( - function (idx) { - var size = data.getItemVisual(idx, 'symbolSize'); - if (!zrUtil.isArray(size)) { - size = [size, size]; - } - return size; - } - ) - }); - - // Create symbolProxy to build path for each data - symbolEl.symbolProxy = symbolUtil.createSymbol( - data.getVisual('symbol'), 0, 0, 0, 0 - ); - // Use symbolProxy setColor method - symbolEl.setColor = symbolEl.symbolProxy.setColor; - - symbolEl.setStyle( - seriesModel.getModel('itemStyle.normal').getItemStyle(['color']) - ); - - var visualColor = data.getVisual('color'); - if (visualColor) { - symbolEl.setColor(visualColor); - } - - // Add back - this.group.add(this._symbolEl); - }; - - largeSymbolProto.updateLayout = function (seriesModel) { - var data = seriesModel.getData(); - this._symbolEl.setShape({ - points: data.mapArray(data.getItemLayout) - }); - }; - - largeSymbolProto.remove = function () { - this.group.removeAll(); - }; - - return LargeSymbolDraw; -}); -define('echarts/chart/scatter/ScatterView',['require','../helper/SymbolDraw','../helper/LargeSymbolDraw','../../echarts'],function (require) { - var SymbolDraw = require('../helper/SymbolDraw'); - var LargeSymbolDraw = require('../helper/LargeSymbolDraw'); +/***/ }, +/* 342 */ +/***/ function(module, exports, __webpack_require__) { - require('../../echarts').extendChartView({ + /** + * @file Data zoom model + */ - type: 'scatter', - init: function () { - this._normalSymbolDraw = new SymbolDraw(); - this._largeSymbolDraw = new LargeSymbolDraw(); - }, + var DataZoomModel = __webpack_require__(288); - render: function (seriesModel, ecModel, api) { - var data = seriesModel.getData(); - var largeSymbolDraw = this._largeSymbolDraw; - var normalSymbolDraw = this._normalSymbolDraw; - var group = this.group; + module.exports = DataZoomModel.extend({ - var symbolDraw = seriesModel.get('large') && data.count() > seriesModel.get('largeThreshold') - ? largeSymbolDraw : normalSymbolDraw; + type: 'dataZoom.select' - this._symbolDraw = symbolDraw; - symbolDraw.updateData(data); - group.add(symbolDraw.group); + }); - group.remove( - symbolDraw === largeSymbolDraw - ? normalSymbolDraw.group : largeSymbolDraw.group - ); - }, - updateLayout: function (seriesModel) { - this._symbolDraw.updateLayout(seriesModel); - }, - remove: function (ecModel, api) { - this._symbolDraw && this._symbolDraw.remove(api, true); - } - }); -}); -define('echarts/chart/scatter',['require','zrender/core/util','../echarts','./scatter/ScatterSeries','./scatter/ScatterView','../visual/symbol','../layout/points'],function (require) { - - var zrUtil = require('zrender/core/util'); - var echarts = require('../echarts'); - - require('./scatter/ScatterSeries'); - require('./scatter/ScatterView'); - - echarts.registerVisualCoding('chart', zrUtil.curry( - require('../visual/symbol'), 'scatter', 'circle', null - )); - echarts.registerLayout(zrUtil.curry( - require('../layout/points'), 'scatter' - )); -}); -define('echarts/component/tooltip/TooltipModel',['require','../../echarts'],function (require) { +/***/ }, +/* 343 */ +/***/ function(module, exports, __webpack_require__) { - require('../../echarts').extendComponentModel({ + - type: 'tooltip', + module.exports = __webpack_require__(290).extend({ - defaultOption: { - zlevel: 0, + type: 'dataZoom.select' - z: 8, + }); - show: true, - // tooltip主体内容 - showContent: true, - // 触发类型,默认数据触发,见下图,可选为:'item' ¦ 'axis' - trigger: 'item', +/***/ }, +/* 344 */ +/***/ function(module, exports, __webpack_require__) { - // 触发条件,支持 'click' | 'mousemove' - triggerOn: 'mousemove', + 'use strict'; - // 是否永远显示 content - alwaysShowContent: false, - // 位置 {Array} | {Function} - // position: null + var history = __webpack_require__(340); - // 内容格式器:{string}(Template) ¦ {Function} - // formatter: null + function Restore(model) { + this.model = model; + } - // 隐藏延迟,单位ms - hideDelay: 100, + Restore.defaultOption = { + show: true, + icon: 'M3.8,33.4 M47,18.9h9.8V8.7 M56.3,20.1 C52.1,9,40.5,0.6,26.8,2.1C12.6,3.7,1.6,16.2,2.1,30.6 M13,41.1H3.1v10.2 M3.7,39.9c4.2,11.1,15.8,19.5,29.5,18 c14.2-1.6,25.2-14.1,24.7-28.5', + title: '还原' + }; - // 动画变换时间,单位s - transitionDuration: 0.4, + var proto = Restore.prototype; - enterable: false, + proto.onclick = function (ecModel, api, type) { + history.clear(ecModel); - // 提示背景颜色,默认为透明度为0.7的黑色 - backgroundColor: 'rgba(50,50,50,0.7)', + api.dispatchAction({ + type: 'restore', + from: this.uid + }); + }; - // 提示边框颜色 - borderColor: '#333', - // 提示边框圆角,单位px,默认为4 - borderRadius: 4, + __webpack_require__(333).register('restore', Restore); - // 提示边框线宽,单位px,默认为0(无边框) - borderWidth: 0, - // 提示内边距,单位px,默认各方向内边距为5, - // 接受数组分别设定上右下左边距,同css - padding: 5, + __webpack_require__(1).registerAction( + {type: 'restore', event: 'restore', update: 'prepareAndUpdate'}, + function (payload, ecModel) { + ecModel.resetOption('recreate'); + } + ); - // 坐标轴指示器,坐标轴触发有效 - axisPointer: { - // 默认为直线 - // 可选为:'line' | 'shadow' | 'cross' - type: 'line', - - // type 为 line 的时候有效,指定 tooltip line 所在的轴,可选 - // 可选 'x' | 'y' | 'angle' | 'radius' | 'auto' - // 默认 'auto',会选择类型为 cateogry 的轴,对于双数值轴,笛卡尔坐标系会默认选择 x 轴 - // 极坐标系会默认选择 angle 轴 - axis: 'auto', - - animation: true, - animationDurationUpdate: 200, - animationEasingUpdate: 'exponentialOut', - - // 直线指示器样式设置 - lineStyle: { - color: '#555', - width: 1, - type: 'solid' - }, - - crossStyle: { - color: '#555', - width: 1, - type: 'dashed', - - // TODO formatter - textStyle: {} - }, - - // 阴影指示器样式设置 - shadowStyle: { - color: 'rgba(150,150,150,0.3)' - } - }, - textStyle: { - color: '#fff', - fontSize: 14 - } - } - }); -}); -/** - * @module echarts/component/tooltip/TooltipContent - */ -define('echarts/component/tooltip/TooltipContent',['require','zrender/core/util','zrender/tool/color','zrender/core/event','../../util/format'],function (require) { - - var zrUtil = require('zrender/core/util'); - var zrColor = require('zrender/tool/color'); - var eventUtil = require('zrender/core/event'); - var formatUtil = require('../../util/format'); - var each = zrUtil.each; - var toCamelCase = formatUtil.toCamelCase; - - var vendors = ['', '-webkit-', '-moz-', '-o-']; - - var gCssText = 'position:absolute;display:block;border-style:solid;white-space:nowrap;'; - - /** - * @param {number} duration - * @return {string} - * @inner - */ - function assembleTransition(duration) { - var transitionCurve = 'cubic-bezier(0.23, 1, 0.32, 1)'; - var transitionText = 'left ' + duration + 's ' + transitionCurve + ',' - + 'top ' + duration + 's ' + transitionCurve; - return zrUtil.map(vendors, function (vendorPrefix) { - return vendorPrefix + 'transition:' + transitionText; - }).join(';'); - } - - /** - * @param {Object} textStyle - * @return {string} - * @inner - */ - function assembleFont(textStyleModel) { - var cssText = []; - - var fontSize = textStyleModel.get('fontSize'); - var color = textStyleModel.getTextColor(); - - color && cssText.push('color:' + color); - - cssText.push('font:' + textStyleModel.getFont()); - - fontSize && - cssText.push('line-height:' + Math.round(fontSize * 3 / 2) + 'px'); - - each(['decoration', 'align'], function (name) { - var val = textStyleModel.get(name); - val && cssText.push('text-' + name + ':' + val); - }); - - return cssText.join(';'); - } - - /** - * @param {Object} tooltipModel - * @return {string} - * @inner - */ - function assembleCssText(tooltipModel) { - - tooltipModel = tooltipModel; - - var cssText = []; - - var transitionDuration = tooltipModel.get('transitionDuration'); - var backgroundColor = tooltipModel.get('backgroundColor'); - var textStyleModel = tooltipModel.getModel('textStyle'); - var padding = tooltipModel.get('padding'); - - // Animation transition - transitionDuration && - cssText.push(assembleTransition(transitionDuration)); - - if (backgroundColor) { - // for ie - cssText.push( - 'background-Color:' + zrColor.toHex(backgroundColor) - ); - cssText.push('filter:alpha(opacity=70)'); - cssText.push('background-Color:' + backgroundColor); - } - - // Border style - each(['width', 'color', 'radius'], function (name) { - var borderName = 'border-' + name; - var camelCase = toCamelCase(borderName); - var val = tooltipModel.get(camelCase); - val != null && - cssText.push(borderName + ':' + val + (name === 'color' ? '' : 'px')); - }); - - // Text style - cssText.push(assembleFont(textStyleModel)); - - // Padding - if (padding != null) { - cssText.push('padding:' + formatUtil.normalizeCssArray(padding).join('px ') + 'px'); - } - - return cssText.join(';') + ';'; - } - - /** - * @alias module:echarts/component/tooltip/TooltipContent - * @constructor - */ - function TooltipContent(container, api) { - var el = document.createElement('div'); - var zr = api.getZr(); - - this.el = el; - - this._x = api.getWidth() / 2; - this._y = api.getHeight() / 2; - - container.appendChild(el); - - this._container = container; - - this._show = false; - - /** - * @private - */ - this._hideTimeout; - - var self = this; - el.onmouseenter = function () { - // clear the timeout in hideLater and keep showing tooltip - if (self.enterable) { - clearTimeout(self._hideTimeout); - self._show = true; - } - self._inContent = true; - }; - el.onmousemove = function (e) { - if (!self.enterable) { - // Try trigger zrender event to avoid mouse - // in and out shape too frequently - var handler = zr.handler; - eventUtil.normalizeEvent(container, e); - handler.dispatch('mousemove', e); - } - }; - el.onmouseleave = function () { - if (self.enterable) { - if (self._show) { - self.hideLater(self._hideDelay); - } - } - self._inContent = false; - }; - - compromiseMobile(el, container); - } - - function compromiseMobile(tooltipContentEl, container) { - // Prevent default behavior on mobile. For example, - // defuault pinch gesture will cause browser zoom. - // We do not preventing event on tooltip contnet el, - // because user may need customization in tooltip el. - eventUtil.addEventListener(container, 'touchstart', preventDefault); - eventUtil.addEventListener(container, 'touchmove', preventDefault); - eventUtil.addEventListener(container, 'touchend', preventDefault); - - function preventDefault(e) { - if (contains(e.target)) { - e.preventDefault(); - } - } - - function contains(targetEl) { - while (targetEl && targetEl !== container) { - if (targetEl === tooltipContentEl) { - return true; - } - targetEl = targetEl.parentNode; - } - } - } - - TooltipContent.prototype = { - - constructor: TooltipContent, - - enterable: true, - - /** - * Update when tooltip is rendered - */ - update: function () { - var container = this._container; - var stl = container.currentStyle - || document.defaultView.getComputedStyle(container); - var domStyle = container.style; - if (domStyle.position !== 'absolute' && stl.position !== 'absolute') { - domStyle.position = 'relative'; - } - // Hide the tooltip - // PENDING - // this.hide(); - }, - - show: function (tooltipModel) { - clearTimeout(this._hideTimeout); - - this.el.style.cssText = gCssText + assembleCssText(tooltipModel) - // http://stackoverflow.com/questions/21125587/css3-transition-not-working-in-chrome-anymore - + ';left:' + this._x + 'px;top:' + this._y + 'px;'; - - this._show = true; - }, - - setContent: function (content) { - var el = this.el; - el.innerHTML = content; - el.style.display = content ? 'block' : 'none'; - }, - - moveTo: function (x, y) { - var style = this.el.style; - style.left = x + 'px'; - style.top = y + 'px'; - - this._x = x; - this._y = y; - }, - - hide: function () { - this.el.style.display = 'none'; - this._show = false; - }, - - // showLater: function () - - hideLater: function (time) { - if (this._show && !(this._inContent && this.enterable)) { - if (time) { - this._hideDelay = time; - // Set show false to avoid invoke hideLater mutiple times - this._show = false; - this._hideTimeout = setTimeout(zrUtil.bind(this.hide, this), time); - } - else { - this.hide(); - } - } - }, - - isShow: function () { - return this._show; - } - }; - - return TooltipContent; -}); -define('echarts/component/tooltip/TooltipView',['require','./TooltipContent','../../util/graphic','zrender/core/util','../../util/format','../../util/number','zrender/core/env','../../echarts'],function (require) { - - var TooltipContent = require('./TooltipContent'); - var graphic = require('../../util/graphic'); - var zrUtil = require('zrender/core/util'); - var formatUtil = require('../../util/format'); - var numberUtil = require('../../util/number'); - var parsePercent = numberUtil.parsePercent; - var env = require('zrender/core/env'); - - function dataEqual(a, b) { - if (!a || !b) { - return false; - } - var round = numberUtil.round; - return round(a[0]) === round(b[0]) - && round(a[1]) === round(b[1]); - } - /** - * @inner - */ - function makeLineShape(x1, y1, x2, y2) { - return { - x1: x1, - y1: y1, - x2: x2, - y2: y2 - }; - } - - /** - * @inner - */ - function makeRectShape(x, y, width, height) { - return { - x: x, - y: y, - width: width, - height: height - }; - } - - /** - * @inner - */ - function makeSectorShape(cx, cy, r0, r, startAngle, endAngle) { - return { - cx: cx, - cy: cy, - r0: r0, - r: r, - startAngle: startAngle, - endAngle: endAngle, - clockwise: true - }; - } - - function refixTooltipPosition(x, y, el, viewWidth, viewHeight) { - var width = el.clientWidth; - var height = el.clientHeight; - var gap = 20; - - if (x + width + gap > viewWidth) { - x -= width + gap; - } - else { - x += gap; - } - if (y + height + gap > viewHeight) { - y -= height + gap; - } - else { - y += gap; - } - return [x, y]; - } - - function calcTooltipPosition(position, rect, dom) { - var domWidth = dom.clientWidth; - var domHeight = dom.clientHeight; - var gap = 5; - var x = 0; - var y = 0; - var rectWidth = rect.width; - var rectHeight = rect.height; - switch (position) { - case 'inside': - x = rect.x + rectWidth / 2 - domWidth / 2; - y = rect.y + rectHeight / 2 - domHeight / 2; - break; - case 'top': - x = rect.x + rectWidth / 2 - domWidth / 2; - y = rect.y - domHeight - gap; - break; - case 'bottom': - x = rect.x + rectWidth / 2 - domWidth / 2; - y = rect.y + rectHeight + gap; - break; - case 'left': - x = rect.x - domWidth - gap; - y = rect.y + rectHeight / 2 - domHeight / 2; - break; - case 'right': - x = rect.x + rectWidth + gap; - y = rect.y + rectHeight / 2 - domHeight / 2; - } - return [x, y]; - } - - /** - * @param {string|Function|Array.} positionExpr - * @param {number} x Mouse x - * @param {number} y Mouse y - * @param {module:echarts/component/tooltip/TooltipContent} content - * @param {Object|} params - * @param {module:zrender/Element} el target element - * @param {module:echarts/ExtensionAPI} api - * @return {Array.} - */ - function updatePosition(positionExpr, x, y, content, params, el, api) { - var viewWidth = api.getWidth(); - var viewHeight = api.getHeight(); - - var rect = el && el.getBoundingRect().clone(); - el && rect.applyTransform(el.transform); - if (typeof positionExpr === 'function') { - // Callback of position can be an array or a string specify the positiont - positionExpr = positionExpr([x, y], params, rect); - } - - if (zrUtil.isArray(positionExpr)) { - x = parsePercent(positionExpr[0], viewWidth); - y = parsePercent(positionExpr[1], viewHeight); - } - // Specify tooltip position by string 'top' 'bottom' 'left' 'right' around graphic element - else if (typeof positionExpr === 'string' && el) { - var pos = calcTooltipPosition( - positionExpr, rect, content.el - ); - x = pos[0]; - y = pos[1]; - } - else { - var pos = refixTooltipPosition( - x, y, content.el, viewWidth, viewHeight - ); - x = pos[0]; - y = pos[1]; - } - - content.moveTo(x, y); - } - - function ifSeriesSupportAxisTrigger(seriesModel) { - var coordSys = seriesModel.coordinateSystem; - var trigger = seriesModel.get('tooltip.trigger', true); - // Ignore series use item tooltip trigger and series coordinate system is not cartesian or - return !(!coordSys - || (coordSys.type !== 'cartesian2d' && coordSys.type !== 'polar' && coordSys.type !== 'single') - || trigger === 'item'); - } - - require('../../echarts').extendComponentView({ - - type: 'tooltip', - - _axisPointers: {}, - - init: function (ecModel, api) { - if (env.node) { - return; - } - var tooltipContent = new TooltipContent(api.getDom(), api); - this._tooltipContent = tooltipContent; - - api.on('showTip', this._manuallyShowTip, this); - api.on('hideTip', this._manuallyHideTip, this); - }, - - render: function (tooltipModel, ecModel, api) { - if (env.node) { - return; - } - - // Reset - this.group.removeAll(); - - /** - * @type {Object} - * @private - */ - this._axisPointers = {}; - - /** - * @private - * @type {module:echarts/component/tooltip/TooltipModel} - */ - this._tooltipModel = tooltipModel; - - /** - * @private - * @type {module:echarts/model/Global} - */ - this._ecModel = ecModel; - - /** - * @private - * @type {module:echarts/ExtensionAPI} - */ - this._api = api; - - /** - * @type {Object} - * @private - */ - this._lastHover = { - // data - // payloadBatch - }; - - var tooltipContent = this._tooltipContent; - tooltipContent.update(); - tooltipContent.enterable = tooltipModel.get('enterable'); - this._alwaysShowContent = tooltipModel.get('alwaysShowContent'); - - /** - * @type {Object.} - */ - this._seriesGroupByAxis = this._prepareAxisTriggerData( - tooltipModel, ecModel - ); - - var crossText = this._crossText; - if (crossText) { - this.group.add(crossText); - } - - // Try to keep the tooltip show when refreshing - if (this._lastX != null && this._lastY != null) { - var self = this; - clearTimeout(this._refreshUpdateTimeout); - this._refreshUpdateTimeout = setTimeout(function () { - // Show tip next tick after other charts are rendered - // In case highlight action has wrong result - // FIXME - self._manuallyShowTip({ - x: self._lastX, - y: self._lastY - }); - }); - } - - var zr = this._api.getZr(); - var tryShow = this._tryShow; - zr.off('click', tryShow); - zr.off('mousemove', tryShow); - zr.off('mouseout', this._hide); - if (tooltipModel.get('triggerOn') === 'click') { - zr.on('click', tryShow, this); - } - else { - zr.on('mousemove', tryShow, this); - zr.on('mouseout', this._hide, this); - } - - }, - - /** - * Show tip manually by - * dispatchAction({ - * type: 'showTip', - * x: 10, - * y: 10 - * }); - * Or - * dispatchAction({ - * type: 'showTip', - * seriesIndex: 0, - * dataIndex: 1 - * }); - * - * TODO Batch - */ - _manuallyShowTip: function (event) { - // From self - if (event.from === this.uid) { - return; - } - - var ecModel = this._ecModel; - var seriesIndex = event.seriesIndex; - var dataIndex = event.dataIndex; - var seriesModel = ecModel.getSeriesByIndex(seriesIndex); - var api = this._api; - - if (event.x == null || event.y == null) { - if (!seriesModel) { - // Find the first series can use axis trigger - ecModel.eachSeries(function (_series) { - if (ifSeriesSupportAxisTrigger(_series) && !seriesModel) { - seriesModel = _series; - } - }); - } - if (seriesModel) { - var data = seriesModel.getData(); - if (dataIndex == null) { - dataIndex = data.indexOfName(event.name); - } - var el = data.getItemGraphicEl(dataIndex); - var cx, cy; - // Try to get the point in coordinate system - var coordSys = seriesModel.coordinateSystem; - if (coordSys && coordSys.dataToPoint) { - var point = coordSys.dataToPoint( - data.getValues(coordSys.dimensions, dataIndex, true) - ); - cx = point && point[0]; - cy = point && point[1]; - } - else if (el) { - // Use graphic bounding rect - var rect = el.getBoundingRect().clone(); - rect.applyTransform(el.transform); - cx = rect.x + rect.width / 2; - cy = rect.y + rect.height / 2; - } - if (cx != null && cy != null) { - this._tryShow({ - offsetX: cx, - offsetY: cy, - target: el, - event: {} - }); - } - } - } - else { - var el = api.getZr().handler.findHover(event.x, event.y); - this._tryShow({ - offsetX: event.x, - offsetY: event.y, - target: el, - event: {} - }); - } - }, - - _manuallyHideTip: function (e) { - if (e.from === this.uid) { - return; - } - - this._hide(); - }, - - _prepareAxisTriggerData: function (tooltipModel, ecModel) { - // Prepare data for axis trigger - var seriesGroupByAxis = {}; - ecModel.eachSeries(function (seriesModel) { - if (ifSeriesSupportAxisTrigger(seriesModel)) { - var coordSys = seriesModel.coordinateSystem; - var baseAxis; - var key; - - // Only cartesian2d and polar support axis trigger - if (coordSys.type === 'cartesian2d') { - // FIXME `axisPointer.axis` is not baseAxis - baseAxis = coordSys.getBaseAxis(); - key = baseAxis.dim + baseAxis.index; - } - else if (coordSys.type === 'single') { - baseAxis = coordSys.getAxis(); - key = baseAxis.dim + baseAxis.type; - } - else { - baseAxis = coordSys.getBaseAxis(); - key = baseAxis.dim + coordSys.name; - } - - seriesGroupByAxis[key] = seriesGroupByAxis[key] || { - coordSys: [], - series: [] - }; - seriesGroupByAxis[key].coordSys.push(coordSys); - seriesGroupByAxis[key].series.push(seriesModel); - } - }, this); - - return seriesGroupByAxis; - }, - - /** - * mousemove handler - * @param {Object} e - * @private - */ - _tryShow: function (e) { - var el = e.target; - var tooltipModel = this._tooltipModel; - var globalTrigger = tooltipModel.get('trigger'); - var ecModel = this._ecModel; - var api = this._api; - - if (!tooltipModel) { - return; - } - - // Save mouse x, mouse y. So we can try to keep showing the tip if chart is refreshed - this._lastX = e.offsetX; - this._lastY = e.offsetY; - - // Always show item tooltip if mouse is on the element with dataIndex - if (el && el.dataIndex != null) { - // Use hostModel in element if possible - // Used when mouseover on a element like markPoint or edge - // In which case, the data is not main data in series. - var hostModel = el.hostModel || ecModel.getSeriesByIndex(el.seriesIndex); - var dataIndex = el.dataIndex; - var itemModel = hostModel.getData().getItemModel(dataIndex); - // Series or single data may use item trigger when global is axis trigger - if ((itemModel.get('tooltip.trigger') || globalTrigger) === 'axis') { - this._showAxisTooltip(tooltipModel, ecModel, e); - } - else { - // Reset ticket - this._ticket = ''; - // If either single data or series use item trigger - this._hideAxisPointer(); - // Reset last hover and dispatch downplay action - this._resetLastHover(); - - this._showItemTooltipContent(hostModel, dataIndex, e); - } - - api.dispatchAction({ - type: 'showTip', - from: this.uid, - dataIndex: el.dataIndex, - seriesIndex: el.seriesIndex - }); - } - else { - if (globalTrigger === 'item') { - this._hide(); - } - else { - // Try show axis tooltip - this._showAxisTooltip(tooltipModel, ecModel, e); - } - - // Action of cross pointer - // other pointer types will trigger action in _dispatchAndShowSeriesTooltipContent method - if (tooltipModel.get('axisPointer.type') === 'cross') { - api.dispatchAction({ - type: 'showTip', - from: this.uid, - x: e.offsetX, - y: e.offsetY - }); - } - } - }, - - /** - * Show tooltip on axis - * @param {module:echarts/component/tooltip/TooltipModel} tooltipModel - * @param {module:echarts/model/Global} ecModel - * @param {Object} e - * @private - */ - _showAxisTooltip: function (tooltipModel, ecModel, e) { - var axisPointerModel = tooltipModel.getModel('axisPointer'); - var axisPointerType = axisPointerModel.get('type'); - - if (axisPointerType === 'cross') { - var el = e.target; - if (el && el.dataIndex != null) { - var seriesModel = ecModel.getSeriesByIndex(el.seriesIndex); - var dataIndex = el.dataIndex; - this._showItemTooltipContent(seriesModel, dataIndex, e); - } - } - - this._showAxisPointer(); - var allNotShow = true; - zrUtil.each(this._seriesGroupByAxis, function (seriesCoordSysSameAxis) { - // Try show the axis pointer - var allCoordSys = seriesCoordSysSameAxis.coordSys; - var coordSys = allCoordSys[0]; - - // If mouse position is not in the grid or polar - var point = [e.offsetX, e.offsetY]; - - if (!coordSys.containPoint(point)) { - // Hide axis pointer - this._hideAxisPointer(coordSys.name); - return; - } - - allNotShow = false; - // Make sure point is discrete on cateogry axis - var dimensions = coordSys.dimensions; - var value = coordSys.pointToData(point, true); - point = coordSys.dataToPoint(value); - var baseAxis = coordSys.getBaseAxis(); - var axisType = axisPointerModel.get('axis'); - if (axisType === 'auto') { - axisType = baseAxis.dim; - } - - var contentNotChange = false; - var lastHover = this._lastHover; - if (axisPointerType === 'cross') { - // If hover data not changed - // Possible when two axes are all category - if (dataEqual(lastHover.data, value)) { - contentNotChange = true; - } - lastHover.data = value; - } - else { - var valIndex = zrUtil.indexOf(dimensions, axisType); - - // If hover data not changed on the axis dimension - if (lastHover.data === value[valIndex]) { - contentNotChange = true; - } - lastHover.data = value[valIndex]; - } - - if (coordSys.type === 'cartesian2d' && !contentNotChange) { - this._showCartesianPointer( - axisPointerModel, coordSys, axisType, point - ); - } - else if (coordSys.type === 'polar' && !contentNotChange) { - this._showPolarPointer( - axisPointerModel, coordSys, axisType, point - ); - } - else if (coordSys.type === 'single' && !contentNotChange) { - this._showSinglePointer( - axisPointerModel, coordSys, axisType, point - ); - } - - if (axisPointerType !== 'cross') { - this._dispatchAndShowSeriesTooltipContent( - coordSys, seriesCoordSysSameAxis.series, point, value, contentNotChange - ); - } - }, this); - - if (allNotShow) { - this._hide(); - } - }, - - /** - * Show tooltip on axis of cartesian coordinate - * @param {module:echarts/model/Model} axisPointerModel - * @param {module:echarts/coord/cartesian/Cartesian2D} cartesians - * @param {string} axisType - * @param {Array.} point - * @private - */ - _showCartesianPointer: function (axisPointerModel, cartesian, axisType, point) { - var self = this; - - var axisPointerType = axisPointerModel.get('type'); - var moveAnimation = axisPointerType !== 'cross'; - - if (axisPointerType === 'cross') { - moveGridLine('x', point, cartesian.getAxis('y').getGlobalExtent()); - moveGridLine('y', point, cartesian.getAxis('x').getGlobalExtent()); - - this._updateCrossText(cartesian, point, axisPointerModel); - } - else { - var otherAxis = cartesian.getAxis(axisType === 'x' ? 'y' : 'x'); - var otherExtent = otherAxis.getGlobalExtent(); - - if (cartesian.type === 'cartesian2d') { - (axisPointerType === 'line' ? moveGridLine : moveGridShadow)( - axisType, point, otherExtent - ); - } - } - - /** - * @inner - */ - function moveGridLine(axisType, point, otherExtent) { - var targetShape = axisType === 'x' - ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1]) - : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]); - - var pointerEl = self._getPointerElement( - cartesian, axisPointerModel, axisType, targetShape - ); - moveAnimation - ? graphic.updateProps(pointerEl, { - shape: targetShape - }, axisPointerModel) - : pointerEl.attr({ - shape: targetShape - }); - } - - /** - * @inner - */ - function moveGridShadow(axisType, point, otherExtent) { - var axis = cartesian.getAxis(axisType); - var bandWidth = axis.getBandWidth(); - var span = otherExtent[1] - otherExtent[0]; - var targetShape = axisType === 'x' - ? makeRectShape(point[0] - bandWidth / 2, otherExtent[0], bandWidth, span) - : makeRectShape(otherExtent[0], point[1] - bandWidth / 2, span, bandWidth); - - var pointerEl = self._getPointerElement( - cartesian, axisPointerModel, axisType, targetShape - ); - moveAnimation - ? graphic.updateProps(pointerEl, { - shape: targetShape - }, axisPointerModel) - : pointerEl.attr({ - shape: targetShape - }); - } - }, - - _showSinglePointer: function (axisPointerModel, single, axisType, point) { - var self = this; - var axisPointerType = axisPointerModel.get('type'); - var moveAnimation = axisPointerType !== 'cross'; - var rect = single.getRect(); - var otherExtent = [rect.y, rect.y + rect.height]; - - moveSingleLine(axisType, point, otherExtent); - - /** - * @inner - */ - function moveSingleLine(axisType, point, otherExtent) { - var axis = single.getAxis(); - var orient = axis.orient; - - var targetShape = orient === 'horizontal' - ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1]) - : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]); - - var pointerEl = self._getPointerElement( - single, axisPointerModel, axisType, targetShape - ); - moveAnimation - ? graphic.updateProps(pointerEl, { - shape: targetShape - }, axisPointerModel) - : pointerEl.attr({ - shape: targetShape - }); - } - - }, - - /** - * Show tooltip on axis of polar coordinate - * @param {module:echarts/model/Model} axisPointerModel - * @param {Array.} polar - * @param {string} axisType - * @param {Array.} point - */ - _showPolarPointer: function (axisPointerModel, polar, axisType, point) { - var self = this; - - var axisPointerType = axisPointerModel.get('type'); - - var angleAxis = polar.getAngleAxis(); - var radiusAxis = polar.getRadiusAxis(); - - var moveAnimation = axisPointerType !== 'cross'; - - if (axisPointerType === 'cross') { - movePolarLine('angle', point, radiusAxis.getExtent()); - movePolarLine('radius', point, angleAxis.getExtent()); - - this._updateCrossText(polar, point, axisPointerModel); - } - else { - var otherAxis = polar.getAxis(axisType === 'radius' ? 'angle' : 'radius'); - var otherExtent = otherAxis.getExtent(); - - (axisPointerType === 'line' ? movePolarLine : movePolarShadow)( - axisType, point, otherExtent - ); - } - /** - * @inner - */ - function movePolarLine(axisType, point, otherExtent) { - var mouseCoord = polar.pointToCoord(point); - - var targetShape; - - if (axisType === 'angle') { - var p1 = polar.coordToPoint([otherExtent[0], mouseCoord[1]]); - var p2 = polar.coordToPoint([otherExtent[1], mouseCoord[1]]); - targetShape = makeLineShape(p1[0], p1[1], p2[0], p2[1]); - } - else { - targetShape = { - cx: polar.cx, - cy: polar.cy, - r: mouseCoord[0] - }; - } - - var pointerEl = self._getPointerElement( - polar, axisPointerModel, axisType, targetShape - ); - - moveAnimation - ? graphic.updateProps(pointerEl, { - shape: targetShape - }, axisPointerModel) - : pointerEl.attr({ - shape: targetShape - }); - } - - /** - * @inner - */ - function movePolarShadow(axisType, point, otherExtent) { - var axis = polar.getAxis(axisType); - var bandWidth = axis.getBandWidth(); - - var mouseCoord = polar.pointToCoord(point); - - var targetShape; - - var radian = Math.PI / 180; - - if (axisType === 'angle') { - targetShape = makeSectorShape( - polar.cx, polar.cy, - otherExtent[0], otherExtent[1], - // In ECharts y is negative if angle is positive - (-mouseCoord[1] - bandWidth / 2) * radian, - (-mouseCoord[1] + bandWidth / 2) * radian - ); - } - else { - targetShape = makeSectorShape( - polar.cx, polar.cy, - mouseCoord[0] - bandWidth / 2, - mouseCoord[0] + bandWidth / 2, - 0, Math.PI * 2 - ); - } - - var pointerEl = self._getPointerElement( - polar, axisPointerModel, axisType, targetShape - ); - moveAnimation - ? graphic.updateProps(pointerEl, { - shape: targetShape - }, axisPointerModel) - : pointerEl.attr({ - shape: targetShape - }); - } - }, - - _updateCrossText: function (coordSys, point, axisPointerModel) { - var crossStyleModel = axisPointerModel.getModel('crossStyle'); - var textStyleModel = crossStyleModel.getModel('textStyle'); - - var tooltipModel = this._tooltipModel; - - var text = this._crossText; - if (!text) { - text = this._crossText = new graphic.Text({ - style: { - textAlign: 'left', - textBaseline: 'bottom' - } - }); - this.group.add(text); - } - - var value = coordSys.pointToData(point); - - var dims = coordSys.dimensions; - value = zrUtil.map(value, function (val, idx) { - var axis = coordSys.getAxis(dims[idx]); - if (axis.type === 'category' || axis.type === 'time') { - val = axis.scale.getLabel(val); - } - else { - val = formatUtil.addCommas( - val.toFixed(axis.getPixelPrecision()) - ); - } - return val; - }); - - text.setStyle({ - fill: textStyleModel.getTextColor() || crossStyleModel.get('color'), - textFont: textStyleModel.getFont(), - text: value.join(', '), - x: point[0] + 5, - y: point[1] - 5 - }); - text.z = tooltipModel.get('z'); - text.zlevel = tooltipModel.get('zlevel'); - }, - - _getPointerElement: function (coordSys, pointerModel, axisType, initShape) { - var tooltipModel = this._tooltipModel; - var z = tooltipModel.get('z'); - var zlevel = tooltipModel.get('zlevel'); - var axisPointers = this._axisPointers; - var coordSysName = coordSys.name; - axisPointers[coordSysName] = axisPointers[coordSysName] || {}; - if (axisPointers[coordSysName][axisType]) { - return axisPointers[coordSysName][axisType]; - } - - // Create if not exists - var pointerType = pointerModel.get('type'); - var styleModel = pointerModel.getModel(pointerType + 'Style'); - var isShadow = pointerType === 'shadow'; - var style = styleModel[isShadow ? 'getAreaStyle' : 'getLineStyle'](); - - var elementType = coordSys.type === 'polar' - ? (isShadow ? 'Sector' : (axisType === 'radius' ? 'Circle' : 'Line')) - : (isShadow ? 'Rect' : 'Line'); - - isShadow ? (style.stroke = null) : (style.fill = null); - - var el = axisPointers[coordSysName][axisType] = new graphic[elementType]({ - style: style, - z: z, - zlevel: zlevel, - silent: true, - shape: initShape - }); - - this.group.add(el); - return el; - }, - - /** - * Dispatch actions and show tooltip on series - * @param {Array.} seriesList - * @param {Array.} point - * @param {Array.} value - * @param {boolean} contentNotChange - * @param {Object} e - */ - _dispatchAndShowSeriesTooltipContent: function ( - coordSys, seriesList, point, value, contentNotChange - ) { - - var rootTooltipModel = this._tooltipModel; - var tooltipContent = this._tooltipContent; - - var baseAxis = coordSys.getBaseAxis(); - - var payloadBatch = zrUtil.map(seriesList, function (series) { - return { - seriesIndex: series.seriesIndex, - dataIndex: series.getAxisTooltipDataIndex - ? series.getAxisTooltipDataIndex(series.coordDimToDataDim(baseAxis.dim), value, baseAxis) - : series.getData().indexOfNearest( - series.coordDimToDataDim(baseAxis.dim)[0], - value[baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1] - ) - }; - }); - - var lastHover = this._lastHover; - var api = this._api; - // Dispatch downplay action - if (lastHover.payloadBatch && !contentNotChange) { - api.dispatchAction({ - type: 'downplay', - batch: lastHover.payloadBatch - }); - } - // Dispatch highlight action - if (!contentNotChange) { - api.dispatchAction({ - type: 'highlight', - batch: payloadBatch - }); - lastHover.payloadBatch = payloadBatch; - } - // Dispatch showTip action - api.dispatchAction({ - type: 'showTip', - dataIndex: payloadBatch[0].dataIndex, - seriesIndex: payloadBatch[0].seriesIndex, - from: this.uid - }); - - if (baseAxis && rootTooltipModel.get('showContent')) { - - var formatter = rootTooltipModel.get('formatter'); - var positionExpr = rootTooltipModel.get('position'); - var html; - - var paramsList = zrUtil.map(seriesList, function (series, index) { - return series.getDataParams(payloadBatch[index].dataIndex); - }); - // If only one series - // FIXME - // if (paramsList.length === 1) { - // paramsList = paramsList[0]; - // } - - tooltipContent.show(rootTooltipModel); - - // Update html content - var firstDataIndex = payloadBatch[0].dataIndex; - if (!contentNotChange) { - // Reset ticket - this._ticket = ''; - if (!formatter) { - // Default tooltip content - // FIXME - // (1) shold be the first data which has name? - // (2) themeRiver, firstDataIndex is array, and first line is unnecessary. - var firstLine = seriesList[0].getData().getName(firstDataIndex); - html = (firstLine ? firstLine + '
' : '') - + zrUtil.map(seriesList, function (series, index) { - return series.formatTooltip(payloadBatch[index].dataIndex, true); - }).join('
'); - } - else { - if (typeof formatter === 'string') { - html = formatUtil.formatTpl(formatter, paramsList); - } - else if (typeof formatter === 'function') { - var self = this; - var ticket = 'axis_' + coordSys.name + '_' + firstDataIndex; - var callback = function (cbTicket, html) { - if (cbTicket === self._ticket) { - tooltipContent.setContent(html); - - updatePosition( - positionExpr, point[0], point[1], - tooltipContent, paramsList, null, api - ); - } - }; - self._ticket = ticket; - html = formatter(paramsList, ticket, callback); - } - } - - tooltipContent.setContent(html); - } - - updatePosition( - positionExpr, point[0], point[1], - tooltipContent, paramsList, null, api - ); - } - }, - - /** - * Show tooltip on item - * @param {module:echarts/model/Series} seriesModel - * @param {number} dataIndex - * @param {Object} e - */ - _showItemTooltipContent: function (seriesModel, dataIndex, e) { - // FIXME Graph data - var api = this._api; - var data = seriesModel.getData(); - var itemModel = data.getItemModel(dataIndex); - - var rootTooltipModel = this._tooltipModel; - - var tooltipContent = this._tooltipContent; - - var tooltipModel = itemModel.getModel('tooltip'); - - // If series model - if (tooltipModel.parentModel) { - tooltipModel.parentModel.parentModel = rootTooltipModel; - } - else { - tooltipModel.parentModel = this._tooltipModel; - } - - if (tooltipModel.get('showContent')) { - var formatter = tooltipModel.get('formatter'); - var positionExpr = tooltipModel.get('position'); - var params = seriesModel.getDataParams(dataIndex); - var html; - if (!formatter) { - html = seriesModel.formatTooltip(dataIndex); - } - else { - if (typeof formatter === 'string') { - html = formatUtil.formatTpl(formatter, params); - } - else if (typeof formatter === 'function') { - var self = this; - var ticket = 'item_' + seriesModel.name + '_' + dataIndex; - var callback = function (cbTicket, html) { - if (cbTicket === self._ticket) { - tooltipContent.setContent(html); - - updatePosition( - positionExpr, e.offsetX, e.offsetY, - tooltipContent, params, e.target, api - ); - } - }; - self._ticket = ticket; - html = formatter(params, ticket, callback); - } - } - - tooltipContent.show(tooltipModel); - tooltipContent.setContent(html); - - updatePosition( - positionExpr, e.offsetX, e.offsetY, - tooltipContent, params, e.target, api - ); - } - }, - - /** - * Show axis pointer - * @param {string} [coordSysName] - */ - _showAxisPointer: function (coordSysName) { - if (coordSysName) { - var axisPointers = this._axisPointers[coordSysName]; - axisPointers && zrUtil.each(axisPointers, function (el) { - el.show(); - }); - } - else { - this.group.eachChild(function (child) { - child.show(); - }); - this.group.show(); - } - }, - - _resetLastHover: function () { - var lastHover = this._lastHover; - if (lastHover.payloadBatch) { - this._api.dispatchAction({ - type: 'downplay', - batch: lastHover.payloadBatch - }); - } - // Reset lastHover - this._lastHover = {}; - }, - /** - * Hide axis pointer - * @param {string} [coordSysName] - */ - _hideAxisPointer: function (coordSysName) { - if (coordSysName) { - var axisPointers = this._axisPointers[coordSysName]; - axisPointers && zrUtil.each(axisPointers, function (el) { - el.hide(); - }); - } - else { - this.group.hide(); - } - }, - - _hide: function () { - this._hideAxisPointer(); - this._resetLastHover(); - if (!this._alwaysShowContent) { - this._tooltipContent.hideLater(this._tooltipModel.get('hideDelay')); - } - - this._api.dispatchAction({ - type: 'hideTip', - from: this.uid - }); - }, - - dispose: function (ecModel, api) { - if (env.node) { - return; - } - var zr = api.getZr(); - this._tooltipContent.hide(); - - zr.off('click', this._tryShow); - zr.off('mousemove', this._tryShow); - zr.off('mouseout', this._hide); - - api.off('showTip', this._manuallyShowTip); - api.off('hideTip', this._manuallyHideTip); - } - }); -}); -// FIXME Better way to pack data in graphic element -define('echarts/component/tooltip',['require','./tooltip/TooltipModel','./tooltip/TooltipView','../echarts','../echarts'],function (require) { - - require('./tooltip/TooltipModel'); - - require('./tooltip/TooltipView'); - - // Show tip action - /** - * @action - * @property {string} type - * @property {number} seriesIndex - * @property {number} dataIndex - * @property {number} [x] - * @property {number} [y] - */ - require('../echarts').registerAction( - { - type: 'showTip', - event: 'showTip', - update: 'none' - }, - // noop - function () {} - ); - // Hide tip action - require('../echarts').registerAction( - { - type: 'hideTip', - event: 'hideTip', - update: 'none' - }, - // noop - function () {} - ); -}); -define('echarts/component/legend/LegendModel',['require','zrender/core/util','../../model/Model','../../echarts'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var Model = require('../../model/Model'); - - var LegendModel = require('../../echarts').extendComponentModel({ - - type: 'legend', - - dependencies: ['series'], - - layoutMode: { - type: 'box', - ignoreSize: true - }, - - init: function (option, parentModel, ecModel) { - this.mergeDefaultAndTheme(option, ecModel); - - option.selected = option.selected || {}; - - this._updateData(ecModel); - - var legendData = this._data; - // If has any selected in option.selected - var selectedMap = this.option.selected; - // If selectedMode is single, try to select one - if (legendData[0] && this.get('selectedMode') === 'single') { - var hasSelected = false; - for (var name in selectedMap) { - if (selectedMap[name]) { - this.select(name); - hasSelected = true; - } - } - // Try select the first if selectedMode is single - !hasSelected && this.select(legendData[0].get('name')); - } - }, - - mergeOption: function (option) { - LegendModel.superCall(this, 'mergeOption', option); - - this._updateData(this.ecModel); - }, - - _updateData: function (ecModel) { - var legendData = zrUtil.map(this.get('data') || [], function (dataItem) { - if (typeof dataItem === 'string') { - dataItem = { - name: dataItem - }; - } - return new Model(dataItem, this, this.ecModel); - }, this); - this._data = legendData; - - var availableNames = zrUtil.map(ecModel.getSeries(), function (series) { - return series.name; - }); - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.legendDataProvider) { - var data = seriesModel.legendDataProvider(); - availableNames = availableNames.concat(data.mapArray(data.getName)); - } - }); - /** - * @type {Array.} - * @private - */ - this._availableNames = availableNames; - }, - - /** - * @return {Array.} - */ - getData: function () { - return this._data; - }, - - /** - * @param {string} name - */ - select: function (name) { - var selected = this.option.selected; - var selectedMode = this.get('selectedMode'); - if (selectedMode === 'single') { - var data = this._data; - zrUtil.each(data, function (dataItem) { - selected[dataItem.get('name')] = false; - }); - } - selected[name] = true; - }, - - /** - * @param {string} name - */ - unSelect: function (name) { - if (this.get('selectedMode') !== 'single') { - this.option.selected[name] = false; - } - }, - - /** - * @param {string} name - */ - toggleSelected: function (name) { - var selected = this.option.selected; - // Default is true - if (!(name in selected)) { - selected[name] = true; - } - this[selected[name] ? 'unSelect' : 'select'](name); - }, - - /** - * @param {string} name - */ - isSelected: function (name) { - var selected = this.option.selected; - return !((name in selected) && !selected[name]) - && zrUtil.indexOf(this._availableNames, name) >= 0; - }, - - defaultOption: { - // 一级层叠 - zlevel: 0, - // 二级层叠 - z: 4, - show: true, - - // 布局方式,默认为水平布局,可选为: - // 'horizontal' | 'vertical' - orient: 'horizontal', - - left: 'center', - // right: 'center', - - top: 'top', - // bottom: 'top', - - // 水平对齐 - // 'auto' | 'left' | 'right' - // 默认为 'auto', 根据 x 的位置判断是左对齐还是右对齐 - align: 'auto', - - backgroundColor: 'rgba(0,0,0,0)', - // 图例边框颜色 - borderColor: '#ccc', - // 图例边框线宽,单位px,默认为0(无边框) - borderWidth: 0, - // 图例内边距,单位px,默认各方向内边距为5, - // 接受数组分别设定上右下左边距,同css - padding: 5, - // 各个item之间的间隔,单位px,默认为10, - // 横向布局时为水平间隔,纵向布局时为纵向间隔 - itemGap: 10, - // 图例图形宽度 - itemWidth: 25, - // 图例图形高度 - itemHeight: 14, - textStyle: { - // 图例文字颜色 - color: '#333' - }, - // formatter: '', - // 选择模式,默认开启图例开关 - selectedMode: true - // 配置默认选中状态,可配合LEGEND.SELECTED事件做动态数据载入 - // selected: null, - // 图例内容(详见legend.data,数组中每一项代表一个item - // data: [], - } - }); - - return LegendModel; -}); -/** - * @file Legend action - */ -define('echarts/component/legend/legendAction',['require','../../echarts','zrender/core/util'],function(require) { - - var echarts = require('../../echarts'); - var zrUtil = require('zrender/core/util'); - - function legendSelectActionHandler(methodName, payload, ecModel) { - var selectedMap = {}; - var isToggleSelect = methodName === 'toggleSelected'; - var isSelected; - // Update all legend components - ecModel.eachComponent('legend', function (legendModel) { - if (isToggleSelect && isSelected != null) { - // Force other legend has same selected status - // Or the first is toggled to true and other are toggled to false - // In the case one legend has some item unSelected in option. And if other legend - // doesn't has the item, they will assume it is selected. - legendModel[isSelected ? 'select' : 'unSelect'](payload.name); - } - else { - legendModel[methodName](payload.name); - isSelected = legendModel.isSelected(payload.name); - } - var legendData = legendModel.getData(); - zrUtil.each(legendData, function (model) { - var name = model.get('name'); - // Wrap element - if (name === '\n' || name === '') { - return; - } - var isItemSelected = legendModel.isSelected(name); - if (name in selectedMap) { - // Unselected if any legend is unselected - selectedMap[name] = selectedMap[name] && isItemSelected; - } - else { - selectedMap[name] = isItemSelected; - } - }); - }); - // Return the event explicitly - return { - name: payload.name, - selected: selectedMap - }; - } - /** - * @event legendToggleSelect - * @type {Object} - * @property {string} type 'legendToggleSelect' - * @property {string} [from] - * @property {string} name Series name or data item name - */ - echarts.registerAction( - 'legendToggleSelect', 'legendselectchanged', - zrUtil.curry(legendSelectActionHandler, 'toggleSelected') - ); - - /** - * @event legendSelect - * @type {Object} - * @property {string} type 'legendSelect' - * @property {string} name Series name or data item name - */ - echarts.registerAction( - 'legendSelect', 'legendselected', - zrUtil.curry(legendSelectActionHandler, 'select') - ); - - /** - * @event legendUnSelect - * @type {Object} - * @property {string} type 'legendUnSelect' - * @property {string} name Series name or data item name - */ - echarts.registerAction( - 'legendUnSelect', 'legendunselected', - zrUtil.curry(legendSelectActionHandler, 'unSelect') - ); -}); -define('echarts/component/helper/listComponent',['require','../../util/layout','../../util/format','../../util/graphic'],function (require) { - // List layout - var layout = require('../../util/layout'); - var formatUtil = require('../../util/format'); - var graphic = require('../../util/graphic'); - - function positionGroup(group, model, api) { - layout.positionGroup( - group, model.getBoxLayoutParams(), - { - width: api.getWidth(), - height: api.getHeight() - }, - model.get('padding') - ); - } - - return { - /** - * Layout list like component. - * It will box layout each items in group of component and then position the whole group in the viewport - * @param {module:zrender/group/Group} group - * @param {module:echarts/model/Component} componentModel - * @param {module:echarts/ExtensionAPI} - */ - layout: function (group, componentModel, api) { - var rect = layout.getLayoutRect(componentModel.getBoxLayoutParams(), { - width: api.getWidth(), - height: api.getHeight() - }, componentModel.get('padding')); - layout.box( - componentModel.get('orient'), - group, - componentModel.get('itemGap'), - rect.width, - rect.height - ); - - positionGroup(group, componentModel, api); - }, - - addBackground: function (group, componentModel) { - var padding = formatUtil.normalizeCssArray( - componentModel.get('padding') - ); - var boundingRect = group.getBoundingRect(); - var style = componentModel.getItemStyle(['color', 'opacity']); - style.fill = componentModel.get('backgroundColor'); - var rect = new graphic.Rect({ - shape: { - x: boundingRect.x - padding[3], - y: boundingRect.y - padding[0], - width: boundingRect.width + padding[1] + padding[3], - height: boundingRect.height + padding[0] + padding[2] - }, - style: style, - silent: true, - z2: -1 - }); - graphic.subPixelOptimizeRect(rect); - - group.add(rect); - } - }; -}); -define('echarts/component/legend/LegendView',['require','zrender/core/util','../../util/symbol','../../util/graphic','../helper/listComponent','../../echarts'],function (require) { - - var zrUtil = require('zrender/core/util'); - var symbolCreator = require('../../util/symbol'); - var graphic = require('../../util/graphic'); - var listComponentHelper = require('../helper/listComponent'); - - var curry = zrUtil.curry; - - var LEGEND_DISABLE_COLOR = '#ccc'; - - function dispatchSelectAction(name, api) { - api.dispatchAction({ - type: 'legendToggleSelect', - name: name - }); - } - - function dispatchHighlightAction(seriesModel, dataName, api) { - seriesModel.get('legendHoverLink') && api.dispatchAction({ - type: 'highlight', - seriesName: seriesModel.name, - name: dataName - }); - } - - function dispatchDownplayAction(seriesModel, dataName, api) { - seriesModel.get('legendHoverLink') &&api.dispatchAction({ - type: 'downplay', - seriesName: seriesModel.name, - name: dataName - }); - } - - return require('../../echarts').extendComponentView({ - - type: 'legend', - - init: function () { - this._symbolTypeStore = {}; - }, - - render: function (legendModel, ecModel, api) { - var group = this.group; - group.removeAll(); - - if (!legendModel.get('show')) { - return; - } - - var selectMode = legendModel.get('selectedMode'); - var itemWidth = legendModel.get('itemWidth'); - var itemHeight = legendModel.get('itemHeight'); - var itemAlign = legendModel.get('align'); - - if (itemAlign === 'auto') { - itemAlign = (legendModel.get('left') === 'right' - && legendModel.get('orient') === 'vertical') - ? 'right' : 'left'; - } - - var legendItemMap = {}; - var legendDrawedMap = {}; - zrUtil.each(legendModel.getData(), function (itemModel) { - var seriesName = itemModel.get('name'); - // Use empty string or \n as a newline string - if (seriesName === '' || seriesName === '\n') { - group.add(new graphic.Group({ - newline: true - })); - } - - var seriesModel = ecModel.getSeriesByName(seriesName)[0]; - - legendItemMap[seriesName] = itemModel; - - if (!seriesModel || legendDrawedMap[seriesName]) { - // Series not exists - return; - } - - var data = seriesModel.getData(); - var color = data.getVisual('color'); - - if (!legendModel.isSelected(seriesName)) { - color = LEGEND_DISABLE_COLOR; - } - - // If color is a callback function - if (typeof color === 'function') { - // Use the first data - color = color(seriesModel.getDataParams(0)); - } - - // Using rect symbol defaultly - var legendSymbolType = data.getVisual('legendSymbol') || 'roundRect'; - var symbolType = data.getVisual('symbol'); - - var itemGroup = this._createItem( - seriesName, itemModel, legendModel, - legendSymbolType, symbolType, - itemWidth, itemHeight, itemAlign, color, - selectMode - ); - - itemGroup.on('click', curry(dispatchSelectAction, seriesName, api)) - .on('mouseover', curry(dispatchHighlightAction, seriesModel, '', api)) - .on('mouseout', curry(dispatchDownplayAction, seriesModel, '', api)); - - legendDrawedMap[seriesName] = true; - }, this); - - ecModel.eachRawSeries(function (seriesModel) { - if (seriesModel.legendDataProvider) { - var data = seriesModel.legendDataProvider(); - data.each(function (idx) { - var name = data.getName(idx); - - // Avoid mutiple series use the same data name - if (!legendItemMap[name] || legendDrawedMap[name]) { - return; - } - - var color = data.getItemVisual(idx, 'color'); - - if (!legendModel.isSelected(name)) { - color = LEGEND_DISABLE_COLOR; - } - - var legendSymbolType = 'roundRect'; - - var itemGroup = this._createItem( - name, legendItemMap[name], legendModel, - legendSymbolType, null, - itemWidth, itemHeight, itemAlign, color, - selectMode - ); - - itemGroup.on('click', curry(dispatchSelectAction, name, api)) - // FIXME Should not specify the series name - .on('mouseover', curry(dispatchHighlightAction, seriesModel, name, api)) - .on('mouseout', curry(dispatchDownplayAction, seriesModel, name, api)); - - legendDrawedMap[name] = true; - }, false, this); - } - }, this); - - listComponentHelper.layout(group, legendModel, api); - // Render background after group is layout - // FIXME - listComponentHelper.addBackground(group, legendModel); - }, - - _createItem: function ( - name, itemModel, legendModel, - legendSymbolType, symbolType, - itemWidth, itemHeight, itemAlign, color, - selectMode - ) { - var itemGroup = new graphic.Group(); - - var textStyleModel = itemModel.getModel('textStyle'); - - var itemIcon = itemModel.get('icon'); - // Use user given icon first - legendSymbolType = itemIcon || legendSymbolType; - itemGroup.add(symbolCreator.createSymbol( - legendSymbolType, 0, 0, itemWidth, itemHeight, color - )); - - // Compose symbols - // PENDING - if (!itemIcon && symbolType - && symbolType !== legendSymbolType - && symbolType != 'none' - ) { - var size = itemHeight * 0.8; - // Put symbol in the center - itemGroup.add(symbolCreator.createSymbol( - symbolType, (itemWidth - size) / 2, (itemHeight - size) / 2, size, size, color - )); - } - - // Text - var textX = itemAlign === 'left' ? itemWidth + 5 : -5; - var textAlign = itemAlign; - - var formatter = legendModel.get('formatter'); - if (typeof formatter === 'string' && formatter) { - name = formatter.replace('{name}', name); - } - else if (typeof formatter === 'function') { - name = formatter(name); - } - - var text = new graphic.Text({ - style: { - text: name, - x: textX, - y: itemHeight / 2, - fill: textStyleModel.getTextColor(), - textFont: textStyleModel.getFont(), - textAlign: textAlign, - textBaseline: 'middle' - } - }); - itemGroup.add(text); - - // Add a invisible rect to increase the area of mouse hover - itemGroup.add(new graphic.Rect({ - shape: itemGroup.getBoundingRect(), - invisible: true - })); - - itemGroup.eachChild(function (child) { - child.silent = !selectMode; - }); - - this.group.add(itemGroup); - - return itemGroup; - } - }); -}); -define('echarts/component/legend/legendFilter',[],function () { - return function (ecModel) { - var legendModels = ecModel.findComponents({ - mainType: 'legend' - }); - if (legendModels && legendModels.length) { - ecModel.filterSeries(function (series) { - // If in any legend component the status is not selected. - // Because in legend series - for (var i = 0; i < legendModels.length; i++) { - if (!legendModels[i].isSelected(series.name)) { - return false; - } - } - return true; - }); - } - }; -}); -/** - * Legend component entry file8 - */ -define('echarts/component/legend',['require','./legend/LegendModel','./legend/legendAction','./legend/LegendView','../echarts','./legend/legendFilter'],function (require) { - - require('./legend/LegendModel'); - require('./legend/legendAction'); - require('./legend/LegendView'); - - var echarts = require('../echarts'); - // Series Filter - echarts.registerProcessor('filter', require('./legend/legendFilter')); -}); -define('echarts/component/axis/AxisBuilder',['require','zrender/core/util','../../util/graphic','../../model/Model','../../util/number'],function (require) { - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var Model = require('../../model/Model'); - var numberUtil = require('../../util/number'); - var remRadian = numberUtil.remRadian; - var isRadianAroundZero = numberUtil.isRadianAroundZero; - - var PI = Math.PI; - - /** - * A final axis is translated and rotated from a "standard axis". - * So opt.position and opt.rotation is required. - * - * A standard axis is and axis from [0, 0] to [0, axisExtent[1]], - * for example: (0, 0) ------------> (0, 50) - * - * nameDirection or tickDirection or labelDirection is 1 means tick - * or label is below the standard axis, whereas is -1 means above - * the standard axis. labelOffset means offset between label and axis, - * which is useful when 'onZero', where axisLabel is in the grid and - * label in outside grid. - * - * Tips: like always, - * positive rotation represents anticlockwise, and negative rotation - * represents clockwise. - * The direction of position coordinate is the same as the direction - * of screen coordinate. - * - * Do not need to consider axis 'inverse', which is auto processed by - * axis extent. - * - * @param {module:zrender/container/Group} group - * @param {Object} axisModel - * @param {Object} opt Standard axis parameters. - * @param {Array.} opt.position [x, y] - * @param {number} opt.rotation by radian - * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'. - * @param {number} [opt.tickDirection=1] 1 or -1 - * @param {number} [opt.labelDirection=1] 1 or -1 - * @param {number} [opt.labelOffset=0] Usefull when onZero. - * @param {string} [opt.axisName] default get from axisModel. - * @param {number} [opt.labelRotation] by degree, default get from axisModel. - * @param {number} [opt.labelInterval] Default label interval when label - * interval from model is null or 'auto'. - * @param {number} [opt.strokeContainThreshold] Default label interval when label - * @param {number} [opt.silent=true] - */ - var AxisBuilder = function (axisModel, opt) { - - /** - * @readOnly - */ - this.opt = opt; - - /** - * @readOnly - */ - this.axisModel = axisModel; - - // Default value - zrUtil.defaults( - opt, - { - labelOffset: 0, - nameDirection: 1, - tickDirection: 1, - labelDirection: 1, - silent: true - } - ); - - /** - * @readOnly - */ - this.group = new graphic.Group({ - position: opt.position.slice(), - rotation: opt.rotation - }); - }; - - AxisBuilder.prototype = { - - constructor: AxisBuilder, - - hasBuilder: function (name) { - return !!builders[name]; - }, - - add: function (name) { - builders[name].call(this); - }, - - getGroup: function () { - return this.group; - } - - }; - - var builders = { - - /** - * @private - */ - axisLine: function () { - var opt = this.opt; - var axisModel = this.axisModel; - - if (!axisModel.get('axisLine.show')) { - return; - } - - var extent = this.axisModel.axis.getExtent(); - - this.group.add(new graphic.Line({ - shape: { - x1: extent[0], - y1: 0, - x2: extent[1], - y2: 0 - }, - style: zrUtil.extend( - {lineCap: 'round'}, - axisModel.getModel('axisLine.lineStyle').getLineStyle() - ), - strokeContainThreshold: opt.strokeContainThreshold, - silent: !!opt.silent, - z2: 1 - })); - }, - - /** - * @private - */ - axisTick: function () { - var axisModel = this.axisModel; - - if (!axisModel.get('axisTick.show')) { - return; - } - - var axis = axisModel.axis; - var tickModel = axisModel.getModel('axisTick'); - var opt = this.opt; - - var lineStyleModel = tickModel.getModel('lineStyle'); - var tickLen = tickModel.get('length'); - var tickInterval = getInterval(tickModel, opt.labelInterval); - var ticksCoords = axis.getTicksCoords(); - var tickLines = []; - - for (var i = 0; i < ticksCoords.length; i++) { - // Only ordinal scale support tick interval - if (ifIgnoreOnTick(axis, i, tickInterval)) { - continue; - } - - var tickCoord = ticksCoords[i]; - - // Tick line - tickLines.push(new graphic.Line(graphic.subPixelOptimizeLine({ - shape: { - x1: tickCoord, - y1: 0, - x2: tickCoord, - y2: opt.tickDirection * tickLen - }, - style: { - lineWidth: lineStyleModel.get('width') - }, - silent: true - }))); - } - - this.group.add(graphic.mergePath(tickLines, { - style: lineStyleModel.getLineStyle(), - silent: true - })); - }, - - /** - * @param {module:echarts/coord/cartesian/AxisModel} axisModel - * @param {module:echarts/coord/cartesian/GridModel} gridModel - * @private - */ - axisLabel: function () { - var axisModel = this.axisModel; - - if (!axisModel.get('axisLabel.show')) { - return; - } - - var opt = this.opt; - var axis = axisModel.axis; - var labelModel = axisModel.getModel('axisLabel'); - var textStyleModel = labelModel.getModel('textStyle'); - var labelMargin = labelModel.get('margin'); - var ticks = axis.scale.getTicks(); - var labels = axisModel.getFormattedLabels(); - - // Special label rotate. - var labelRotation = opt.labelRotation; - if (labelRotation == null) { - labelRotation = labelModel.get('rotate') || 0; - } - // To radian. - labelRotation = labelRotation * PI / 180; - - var labelLayout = innerTextLayout(opt, labelRotation, opt.labelDirection); - var categoryData = axisModel.get('data'); - - var textEls = []; - for (var i = 0; i < ticks.length; i++) { - if (ifIgnoreOnTick(axis, i, opt.labelInterval)) { - continue; - } - - var itemTextStyleModel = textStyleModel; - if (categoryData && categoryData[i] && categoryData[i].textStyle) { - itemTextStyleModel = new Model( - categoryData[i].textStyle, textStyleModel, axisModel.ecModel - ); - } - - var tickCoord = axis.dataToCoord(ticks[i]); - var pos = [ - tickCoord, - opt.labelOffset + opt.labelDirection * labelMargin - ]; - - var textEl = new graphic.Text({ - style: { - text: labels[i], - textAlign: itemTextStyleModel.get('align', true) || labelLayout.textAlign, - textBaseline: itemTextStyleModel.get('baseline', true) || labelLayout.textBaseline, - textFont: itemTextStyleModel.getFont(), - fill: itemTextStyleModel.getTextColor() - }, - position: pos, - rotation: labelLayout.rotation, - silent: true, - z2: 10 - }); - textEls.push(textEl); - this.group.add(textEl); - } - - function isTwoLabelOverlapped(current, next) { - var firstRect = current && current.getBoundingRect().clone(); - var nextRect = next && next.getBoundingRect().clone(); - if (firstRect && nextRect) { - firstRect.applyTransform(current.getLocalTransform()); - nextRect.applyTransform(next.getLocalTransform()); - return firstRect.intersect(nextRect); - } - } - if (axis.type !== 'category') { - // If min or max are user set, we need to check - // If the tick on min(max) are overlap on their neighbour tick - // If they are overlapped, we need to hide the min(max) tick label - if (axisModel.get('min')) { - var firstLabel = textEls[0]; - var nextLabel = textEls[1]; - if (isTwoLabelOverlapped(firstLabel, nextLabel)) { - firstLabel.ignore = true; - } - } - if (axisModel.get('max')) { - var lastLabel = textEls[textEls.length - 1]; - var prevLabel = textEls[textEls.length - 2]; - if (isTwoLabelOverlapped(prevLabel, lastLabel)) { - lastLabel.ignore = true; - } - } - } - }, - - /** - * @private - */ - axisName: function () { - var opt = this.opt; - var axisModel = this.axisModel; - - var name = this.opt.axisName; - // If name is '', do not get name from axisMode. - if (name == null) { - name = axisModel.get('name'); - } - - if (!name) { - return; - } - - var nameLocation = axisModel.get('nameLocation'); - var nameDirection = opt.nameDirection; - var textStyleModel = axisModel.getModel('nameTextStyle'); - var gap = axisModel.get('nameGap') || 0; - - var extent = this.axisModel.axis.getExtent(); - var gapSignal = extent[0] > extent[1] ? -1 : 1; - var pos = [ - nameLocation === 'start' - ? extent[0] - gapSignal * gap - : nameLocation === 'end' - ? extent[1] + gapSignal * gap - : (extent[0] + extent[1]) / 2, // 'middle' - // Reuse labelOffset. - nameLocation === 'middle' ? opt.labelOffset + nameDirection * gap : 0 - ]; - - var labelLayout; - - if (nameLocation === 'middle') { - labelLayout = innerTextLayout(opt, opt.rotation, nameDirection); - } - else { - labelLayout = endTextLayout(opt, nameLocation, extent); - } - - this.group.add(new graphic.Text({ - style: { - text: name, - textFont: textStyleModel.getFont(), - fill: textStyleModel.getTextColor() - || axisModel.get('axisLine.lineStyle.color'), - textAlign: labelLayout.textAlign, - textBaseline: labelLayout.textBaseline - }, - position: pos, - rotation: labelLayout.rotation, - silent: true, - z2: 1 - })); - } - - }; - - /** - * @inner - */ - function innerTextLayout(opt, textRotation, direction) { - var rotationDiff = remRadian(textRotation - opt.rotation); - var textAlign; - var textBaseline; - - if (isRadianAroundZero(rotationDiff)) { // Label is parallel with axis line. - textBaseline = direction > 0 ? 'top' : 'bottom'; - textAlign = 'center'; - } - else if (isRadianAroundZero(rotationDiff - PI)) { // Label is inverse parallel with axis line. - textBaseline = direction > 0 ? 'bottom' : 'top'; - textAlign = 'center'; - } - else { - textBaseline = 'middle'; - - if (rotationDiff > 0 && rotationDiff < PI) { - textAlign = direction > 0 ? 'right' : 'left'; - } - else { - textAlign = direction > 0 ? 'left' : 'right'; - } - } - - return { - rotation: rotationDiff, - textAlign: textAlign, - textBaseline: textBaseline - }; - } - - /** - * @inner - */ - function endTextLayout(opt, textPosition, extent) { - var rotationDiff = remRadian(-opt.rotation); - var textAlign; - var textBaseline; - var inverse = extent[0] > extent[1]; - var onLeft = (textPosition === 'start' && !inverse) - || (textPosition !== 'start' && inverse); - - if (isRadianAroundZero(rotationDiff - PI / 2)) { - textBaseline = onLeft ? 'bottom' : 'top'; - textAlign = 'center'; - } - else if (isRadianAroundZero(rotationDiff - PI * 1.5)) { - textBaseline = onLeft ? 'top' : 'bottom'; - textAlign = 'center'; - } - else { - textBaseline = 'middle'; - if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) { - textAlign = onLeft ? 'left' : 'right'; - } - else { - textAlign = onLeft ? 'right' : 'left'; - } - } - - return { - rotation: rotationDiff, - textAlign: textAlign, - textBaseline: textBaseline - }; - } - - /** - * @static - */ - var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (axis, i, interval) { - var rawTick; - var scale = axis.scale; - return scale.type === 'ordinal' - && ( - typeof interval === 'function' - ? ( - rawTick = scale.getTicks()[i], - !interval(rawTick, scale.getLabel(rawTick)) - ) - : i % (interval + 1) - ); - }; - - /** - * @static - */ - var getInterval = AxisBuilder.getInterval = function (model, labelInterval) { - var interval = model.get('interval'); - if (interval == null || interval == 'auto') { - interval = labelInterval; - } - return interval; - }; - - return AxisBuilder; + module.exports = Restore; -}); -define('echarts/component/axis/AxisView',['require','zrender/core/util','../../util/graphic','./AxisBuilder','../../echarts'],function (require) { - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var AxisBuilder = require('./AxisBuilder'); - var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick; - var getInterval = AxisBuilder.getInterval; - - var axisBuilderAttrs = [ - 'axisLine', 'axisLabel', 'axisTick', 'axisName' - ]; - var selfBuilderAttrs = [ - 'splitLine', 'splitArea' - ]; - - var AxisView = require('../../echarts').extendComponentView({ - - type: 'axis', - - render: function (axisModel, ecModel) { - - this.group.removeAll(); - - if (!axisModel.get('show')) { - return; - } - - var gridModel = ecModel.getComponent('grid', axisModel.get('gridIndex')); - - var layout = layoutAxis(gridModel, axisModel); - - var axisBuilder = new AxisBuilder(axisModel, layout); - - zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder); - - this.group.add(axisBuilder.getGroup()); - - zrUtil.each(selfBuilderAttrs, function (name) { - if (axisModel.get(name +'.show')) { - this['_' + name](axisModel, gridModel, layout.labelInterval); - } - }, this); - }, - - /** - * @param {module:echarts/coord/cartesian/AxisModel} axisModel - * @param {module:echarts/coord/cartesian/GridModel} gridModel - * @param {number|Function} labelInterval - * @private - */ - _splitLine: function (axisModel, gridModel, labelInterval) { - var axis = axisModel.axis; - - var splitLineModel = axisModel.getModel('splitLine'); - var lineStyleModel = splitLineModel.getModel('lineStyle'); - var lineWidth = lineStyleModel.get('width'); - var lineColors = lineStyleModel.get('color'); - - var lineInterval = getInterval(splitLineModel, labelInterval); - - lineColors = lineColors instanceof Array ? lineColors : [lineColors]; - - var gridRect = gridModel.coordinateSystem.getRect(); - var isHorizontal = axis.isHorizontal(); - - var splitLines = []; - var lineCount = 0; - - var ticksCoords = axis.getTicksCoords(); - - var p1 = []; - var p2 = []; - for (var i = 0; i < ticksCoords.length; i++) { - if (ifIgnoreOnTick(axis, i, lineInterval)) { - continue; - } - - var tickCoord = axis.toGlobalCoord(ticksCoords[i]); - - if (isHorizontal) { - p1[0] = tickCoord; - p1[1] = gridRect.y; - p2[0] = tickCoord; - p2[1] = gridRect.y + gridRect.height; - } - else { - p1[0] = gridRect.x; - p1[1] = tickCoord; - p2[0] = gridRect.x + gridRect.width; - p2[1] = tickCoord; - } - - var colorIndex = (lineCount++) % lineColors.length; - splitLines[colorIndex] = splitLines[colorIndex] || []; - splitLines[colorIndex].push(new graphic.Line(graphic.subPixelOptimizeLine({ - shape: { - x1: p1[0], - y1: p1[1], - x2: p2[0], - y2: p2[1] - }, - style: { - lineWidth: lineWidth - }, - silent: true - }))); - } - - // Simple optimization - // Batching the lines if color are the same - for (var i = 0; i < splitLines.length; i++) { - this.group.add(graphic.mergePath(splitLines[i], { - style: { - stroke: lineColors[i % lineColors.length], - lineDash: lineStyleModel.getLineDash(), - lineWidth: lineWidth - }, - silent: true - })); - } - }, - - /** - * @param {module:echarts/coord/cartesian/AxisModel} axisModel - * @param {module:echarts/coord/cartesian/GridModel} gridModel - * @param {number|Function} labelInterval - * @private - */ - _splitArea: function (axisModel, gridModel, labelInterval) { - var axis = axisModel.axis; - - var splitAreaModel = axisModel.getModel('splitArea'); - var areaColors = splitAreaModel.get('areaStyle.color'); - - var gridRect = gridModel.coordinateSystem.getRect(); - var ticksCoords = axis.getTicksCoords(); - - var prevX = axis.toGlobalCoord(ticksCoords[0]); - var prevY = axis.toGlobalCoord(ticksCoords[0]); - - var splitAreaRects = []; - var count = 0; - - var areaInterval = getInterval(splitAreaModel, labelInterval); - - areaColors = areaColors instanceof Array ? areaColors : [areaColors]; - - for (var i = 1; i < ticksCoords.length; i++) { - if (ifIgnoreOnTick(axis, i, areaInterval)) { - continue; - } - - var tickCoord = axis.toGlobalCoord(ticksCoords[i]); - - var x; - var y; - var width; - var height; - if (axis.isHorizontal()) { - x = prevX; - y = gridRect.y; - width = tickCoord - x; - height = gridRect.height; - } - else { - x = gridRect.x; - y = prevY; - width = gridRect.width; - height = tickCoord - y; - } - - var colorIndex = (count++) % areaColors.length; - splitAreaRects[colorIndex] = splitAreaRects[colorIndex] || []; - splitAreaRects[colorIndex].push(new graphic.Rect({ - shape: { - x: x, - y: y, - width: width, - height: height - }, - silent: true - })); - - prevX = x + width; - prevY = y + height; - } - - // Simple optimization - // Batching the rects if color are the same - for (var i = 0; i < splitAreaRects.length; i++) { - this.group.add(graphic.mergePath(splitAreaRects[i], { - style: { - fill: areaColors[i % areaColors.length] - }, - silent: true - })); - } - } - }); - - AxisView.extend({ - type: 'xAxis' - }); - AxisView.extend({ - type: 'yAxis' - }); - - /** - * @inner - */ - function layoutAxis(gridModel, axisModel) { - var grid = gridModel.coordinateSystem; - var axis = axisModel.axis; - var layout = {}; - - var rawAxisPosition = axis.position; - var axisPosition = axis.onZero ? 'onZero' : rawAxisPosition; - var axisDim = axis.dim; - - // [left, right, top, bottom] - var rect = grid.getRect(); - var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height]; - - var posMap = { - x: {top: rectBound[2], bottom: rectBound[3]}, - y: {left: rectBound[0], right: rectBound[1]} - }; - posMap.x.onZero = Math.max(Math.min(getZero('y'), posMap.x.bottom), posMap.x.top); - posMap.y.onZero = Math.max(Math.min(getZero('x'), posMap.y.right), posMap.y.left); - - function getZero(dim, val) { - var theAxis = grid.getAxis(dim); - return theAxis.toGlobalCoord(theAxis.dataToCoord(0)); - } - - // Axis position - layout.position = [ - axisDim === 'y' ? posMap.y[axisPosition] : rectBound[0], - axisDim === 'x' ? posMap.x[axisPosition] : rectBound[3] - ]; - - // Axis rotation - var r = {x: 0, y: 1}; - layout.rotation = Math.PI / 2 * r[axisDim]; - - // Tick and label direction, x y is axisDim - var dirMap = {top: -1, bottom: 1, left: -1, right: 1}; - - layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition]; - if (axis.onZero) { - layout.labelOffset = posMap[axisDim][rawAxisPosition] - posMap[axisDim].onZero; - } - - if (axisModel.getModel('axisTick').get('inside')) { - layout.tickDirection = -layout.tickDirection; - } - if (axisModel.getModel('axisLabel').get('inside')) { - layout.labelDirection = -layout.labelDirection; - } - - // Special label rotation - var labelRotation = axisModel.getModel('axisLabel').get('rotate'); - layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation; - - // label interval when auto mode. - layout.labelInterval = axis.getLabelInterval(); - - // Over splitLine and splitArea - layout.z2 = 1; - - return layout; - } -}); -// TODO boundaryGap -define('echarts/component/axis',['require','../coord/cartesian/AxisModel','./axis/AxisView'],function(require) { - - require('../coord/cartesian/AxisModel'); +/***/ }, +/* 345 */ +/***/ function(module, exports, __webpack_require__) { - require('./axis/AxisView'); -}); -define('echarts/component/grid',['require','../util/graphic','zrender/core/util','../coord/cartesian/Grid','./axis','../echarts'],function(require) { - - - var graphic = require('../util/graphic'); - var zrUtil = require('zrender/core/util'); - - require('../coord/cartesian/Grid'); - - require('./axis'); - - // Grid view - require('../echarts').extendComponentView({ - - type: 'grid', - - render: function (gridModel, ecModel) { - this.group.removeAll(); - if (gridModel.get('show')) { - this.group.add(new graphic.Rect({ - shape:gridModel.coordinateSystem.getRect(), - style: zrUtil.defaults({ - fill: gridModel.get('backgroundColor') - }, gridModel.getItemStyle()), - silent: true - })); - } - } - }); -}); -define('echarts/component/title',['require','../echarts','../util/graphic','../util/layout'],function(require) { - - - - var echarts = require('../echarts'); - var graphic = require('../util/graphic'); - var layout = require('../util/layout'); - - // Model - echarts.extendComponentModel({ - - type: 'title', - - layoutMode: {type: 'box', ignoreSize: true}, - - defaultOption: { - // 一级层叠 - zlevel: 0, - // 二级层叠 - z: 6, - show: true, - - text: '', - // 超链接跳转 - // link: null, - // 仅支持self | blank - target: 'blank', - subtext: '', - - // 超链接跳转 - // sublink: null, - // 仅支持self | blank - subtarget: 'blank', - - // 'center' ¦ 'left' ¦ 'right' - // ¦ {number}(x坐标,单位px) - left: 0, - // 'top' ¦ 'bottom' ¦ 'center' - // ¦ {number}(y坐标,单位px) - top: 0, - - // 水平对齐 - // 'auto' | 'left' | 'right' - // 默认根据 x 的位置判断是左对齐还是右对齐 - //textAlign: null - - backgroundColor: 'rgba(0,0,0,0)', - - // 标题边框颜色 - borderColor: '#ccc', - - // 标题边框线宽,单位px,默认为0(无边框) - borderWidth: 0, - - // 标题内边距,单位px,默认各方向内边距为5, - // 接受数组分别设定上右下左边距,同css - padding: 5, - - // 主副标题纵向间隔,单位px,默认为10, - itemGap: 10, - textStyle: { - fontSize: 18, - fontWeight: 'bolder', - // 主标题文字颜色 - color: '#333' - }, - subtextStyle: { - // 副标题文字颜色 - color: '#aaa' - } - } - }); - - // View - echarts.extendComponentView({ - - type: 'title', - - render: function (titleModel, ecModel, api) { - this.group.removeAll(); - - if (!titleModel.get('show')) { - return; - } - - var group = this.group; - - var textStyleModel = titleModel.getModel('textStyle'); - var subtextStyleModel = titleModel.getModel('subtextStyle'); - - var textAlign = titleModel.get('textAlign'); - - var textEl = new graphic.Text({ - style: { - text: titleModel.get('text'), - textFont: textStyleModel.getFont(), - fill: textStyleModel.getTextColor(), - textBaseline: 'top' - }, - z2: 10 - }); - - var textRect = textEl.getBoundingRect(); - - var subText = titleModel.get('subtext'); - var subTextEl = new graphic.Text({ - style: { - text: subText, - textFont: subtextStyleModel.getFont(), - fill: subtextStyleModel.getTextColor(), - y: textRect.height + titleModel.get('itemGap'), - textBaseline: 'top' - }, - z2: 10 - }); - - var link = titleModel.get('link'); - var sublink = titleModel.get('sublink'); - - textEl.silent = !link; - subTextEl.silent = !sublink; - - if (link) { - textEl.on('click', function () { - window.open(link, titleModel.get('target')); - }); - } - if (sublink) { - subTextEl.on('click', function () { - window.open(sublink, titleModel.get('subtarget')); - }); - } - - group.add(textEl); - subText && group.add(subTextEl); - // If no subText, but add subTextEl, there will be an empty line. - - var groupRect = group.getBoundingRect(); - var layoutOption = titleModel.getBoxLayoutParams(); - layoutOption.width = groupRect.width; - layoutOption.height = groupRect.height; - var layoutRect = layout.getLayoutRect( - layoutOption, { - width: api.getWidth(), - height: api.getHeight() - }, titleModel.get('padding') - ); - // Adjust text align based on position - if (!textAlign) { - // Align left if title is on the left. center and right is same - textAlign = titleModel.get('left') || titleModel.get('right'); - if (textAlign === 'middle') { - textAlign = 'center'; - } - // Adjust layout by text align - if (textAlign === 'right') { - layoutRect.x += layoutRect.width; - } - else if (textAlign === 'center') { - layoutRect.x += layoutRect.width / 2; - } - } - group.position = [layoutRect.x, layoutRect.y]; - textEl.setStyle('textAlign', textAlign); - subTextEl.setStyle('textAlign', textAlign); - - // Render background - // Get groupRect again because textAlign has been changed - groupRect = group.getBoundingRect(); - var padding = layoutRect.margin; - var style = titleModel.getItemStyle(['color', 'opacity']); - style.fill = titleModel.get('backgroundColor'); - var rect = new graphic.Rect({ - shape: { - x: groupRect.x - padding[3], - y: groupRect.y - padding[0], - width: groupRect.width + padding[1] + padding[3], - height: groupRect.height + padding[0] + padding[2] - }, - style: style, - silent: true - }); - graphic.subPixelOptimizeRect(rect); - - group.add(rect); - } - }); -}); -define('echarts/component/marker/MarkPointModel',['require','../../util/model','../../echarts'],function (require) { - // Default enable markPoint - // var globalDefault = require('../../model/globalDefault'); - var modelUtil = require('../../util/model'); - // // Force to load markPoint component - // globalDefault.markPoint = {}; - - var MarkPointModel = require('../../echarts').extendComponentModel({ - - type: 'markPoint', - - dependencies: ['series', 'grid', 'polar'], - /** - * @overrite - */ - init: function (option, parentModel, ecModel, extraOpt) { - this.mergeDefaultAndTheme(option, ecModel); - this.mergeOption(option, ecModel, extraOpt.createdBySelf, true); - }, - - mergeOption: function (newOpt, ecModel, createdBySelf, isInit) { - if (!createdBySelf) { - ecModel.eachSeries(function (seriesModel) { - var markPointOpt = seriesModel.get('markPoint'); - var mpModel = seriesModel.markPointModel; - if (!markPointOpt || !markPointOpt.data) { - seriesModel.markPointModel = null; - return; - } - if (!mpModel) { - if (isInit) { - // Default label emphasis `position` and `show` - modelUtil.defaultEmphasis( - markPointOpt.label, - ['position', 'show', 'textStyle', 'distance', 'formatter'] - ); - } - var opt = { - // Use the same series index and name - seriesIndex: seriesModel.seriesIndex, - name: seriesModel.name, - createdBySelf: true - }; - mpModel = new MarkPointModel( - markPointOpt, this, ecModel, opt - ); - } - else { - mpModel.mergeOption(markPointOpt, ecModel, true); - } - seriesModel.markPointModel = mpModel; - }, this); - } - }, - - defaultOption: { - zlevel: 0, - z: 5, - symbol: 'pin', // 标注类型 - symbolSize: 50, // 标注大小 - // symbolRotate: null, // 标注旋转控制 - tooltip: { - trigger: 'item' - }, - label: { - normal: { - show: true, - // 标签文本格式器,同Tooltip.formatter,不支持回调 - // formatter: null, - // 可选为'left'|'right'|'top'|'bottom' - position: 'inside' - // 默认使用全局文本样式,详见TEXTSTYLE - // textStyle: null - }, - emphasis: { - show: true - // 标签文本格式器,同Tooltip.formatter,不支持回调 - // formatter: null, - // position: 'inside' // 'left'|'right'|'top'|'bottom' - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - } - }, - itemStyle: { - normal: { - // color: 各异, - // 标注边线颜色,优先于color - // borderColor: 各异, - // 标注边线线宽,单位px,默认为1 - borderWidth: 2 - }, - emphasis: { - // color: 各异 - } - } - } - }); - - return MarkPointModel; -}); -define('echarts/component/marker/markerHelper',['require','zrender/core/util','../../util/number'],function (require) { - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../../util/number'); - var indexOf = zrUtil.indexOf; - - function getPrecision(data, valueAxisDim, dataIndex) { - var precision = -1; - do { - precision = Math.max( - numberUtil.getPrecision(data.get( - valueAxisDim, dataIndex - )), - precision - ); - data = data.stackedOn; - } while (data); - - return precision; - } - - function markerTypeCalculatorWithExtent( - mlType, data, baseDataDim, valueDataDim, baseCoordIndex, valueCoordIndex - ) { - var coordArr = []; - var value = numCalculate(data, valueDataDim, mlType); - - var dataIndex = data.indexOfNearest(valueDataDim, value, true); - coordArr[baseCoordIndex] = data.get(baseDataDim, dataIndex, true); - coordArr[valueCoordIndex] = data.get(valueDataDim, dataIndex, true); - - var precision = getPrecision(data, valueDataDim, dataIndex); - if (precision >= 0) { - coordArr[valueCoordIndex] = +coordArr[valueCoordIndex].toFixed(precision); - } - - return coordArr; - } - - var curry = zrUtil.curry; - // TODO Specified percent - var markerTypeCalculator = { - /** - * @method - * @param {module:echarts/data/List} data - * @param {string} baseAxisDim - * @param {string} valueAxisDim - */ - min: curry(markerTypeCalculatorWithExtent, 'min'), - /** - * @method - * @param {module:echarts/data/List} data - * @param {string} baseAxisDim - * @param {string} valueAxisDim - */ - max: curry(markerTypeCalculatorWithExtent, 'max'), - /** - * @method - * @param {module:echarts/data/List} data - * @param {string} baseAxisDim - * @param {string} valueAxisDim - */ - average: curry(markerTypeCalculatorWithExtent, 'average') - }; - - /** - * Transform markPoint data item to format used in List by do the following - * 1. Calculate statistic like `max`, `min`, `average` - * 2. Convert `item.xAxis`, `item.yAxis` to `item.coord` array - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/coord/*} [coordSys] - * @param {Object} item - * @return {Object} - */ - var dataTransform = function (seriesModel, item) { - var data = seriesModel.getData(); - var coordSys = seriesModel.coordinateSystem; - - // 1. If not specify the position with pixel directly - // 2. If `coord` is not a data array. Which uses `xAxis`, - // `yAxis` to specify the coord on each dimension - if ((isNaN(item.x) || isNaN(item.y)) - && !zrUtil.isArray(item.coord) - && coordSys - ) { - var axisInfo = getAxisInfo(item, data, coordSys, seriesModel); - - // Clone the option - // Transform the properties xAxis, yAxis, radiusAxis, angleAxis, geoCoord to value - item = zrUtil.clone(item); - - if (item.type - && markerTypeCalculator[item.type] - && axisInfo.baseAxis && axisInfo.valueAxis - ) { - var dims = coordSys.dimensions; - var baseCoordIndex = indexOf(dims, axisInfo.baseAxis.dim); - var valueCoordIndex = indexOf(dims, axisInfo.valueAxis.dim); - - item.coord = markerTypeCalculator[item.type]( - data, axisInfo.baseDataDim, axisInfo.valueDataDim, - baseCoordIndex, valueCoordIndex - ); - // Force to use the value of calculated value. - item.value = item.coord[valueCoordIndex]; - } - else { - // FIXME Only has one of xAxis and yAxis. - item.coord = [ - item.xAxis != null ? item.xAxis : item.radiusAxis, - item.yAxis != null ? item.yAxis : item.angleAxis - ]; - } - } - return item; - }; - - var getAxisInfo = function (item, data, coordSys, seriesModel) { - var ret = {}; - - if (item.valueIndex != null || item.valueDim != null) { - ret.valueDataDim = item.valueIndex != null - ? data.getDimension(item.valueIndex) : item.valueDim; - ret.valueAxis = coordSys.getAxis(seriesModel.dataDimToCoordDim(ret.valueDataDim)); - ret.baseAxis = coordSys.getOtherAxis(ret.valueAxis); - ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0]; - } - else { - ret.baseAxis = seriesModel.getBaseAxis(); - ret.valueAxis = coordSys.getOtherAxis(ret.baseAxis); - ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0]; - ret.valueDataDim = seriesModel.coordDimToDataDim(ret.valueAxis.dim)[0]; - } - - return ret; - }; - - /** - * Filter data which is out of coordinateSystem range - * [dataFilter description] - * @param {module:echarts/coord/*} [coordSys] - * @param {Object} item - * @return {boolean} - */ - var dataFilter = function (coordSys, item) { - // Alwalys return true if there is no coordSys - return (coordSys && item.coord && (item.x == null || item.y == null)) - ? coordSys.containData(item.coord) : true; - }; - - var dimValueGetter = function (item, dimName, dataIndex, dimIndex) { - // x, y, radius, angle - if (dimIndex < 2) { - return item.coord && item.coord[dimIndex]; - } - else { - item.value; - } - }; - - var numCalculate = function (data, valueDataDim, mlType) { - return mlType === 'average' - ? data.getSum(valueDataDim, true) / data.count() - : data.getDataExtent(valueDataDim, true)[mlType === 'max' ? 1 : 0]; - }; - - return { - dataTransform: dataTransform, - dataFilter: dataFilter, - dimValueGetter: dimValueGetter, - getAxisInfo: getAxisInfo, - numCalculate: numCalculate - }; -}); -define('echarts/component/marker/MarkPointView',['require','../../chart/helper/SymbolDraw','zrender/core/util','../../util/format','../../util/model','../../util/number','../../data/List','./markerHelper','../../echarts'],function (require) { - - var SymbolDraw = require('../../chart/helper/SymbolDraw'); - var zrUtil = require('zrender/core/util'); - var formatUtil = require('../../util/format'); - var modelUtil = require('../../util/model'); - var numberUtil = require('../../util/number'); - - var addCommas = formatUtil.addCommas; - var encodeHTML = formatUtil.encodeHTML; - - var List = require('../../data/List'); - - var markerHelper = require('./markerHelper'); - - // FIXME - var markPointFormatMixin = { - getRawDataArray: function () { - return this.option.data; - }, - - formatTooltip: function (dataIndex) { - var data = this.getData(); - var value = this.getRawValue(dataIndex); - var formattedValue = zrUtil.isArray(value) - ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); - var name = data.getName(dataIndex); - return this.name + '
' - + ((name ? encodeHTML(name) + ' : ' : '') + formattedValue); - }, - - getData: function () { - return this._data; - }, - - setData: function (data) { - this._data = data; - } - }; - - zrUtil.defaults(markPointFormatMixin, modelUtil.dataFormatMixin); - - require('../../echarts').extendComponentView({ - - type: 'markPoint', - - init: function () { - this._symbolDrawMap = {}; - }, - - render: function (markPointModel, ecModel, api) { - var symbolDrawMap = this._symbolDrawMap; - for (var name in symbolDrawMap) { - symbolDrawMap[name].__keep = false; - } - - ecModel.eachSeries(function (seriesModel) { - var mpModel = seriesModel.markPointModel; - mpModel && this._renderSeriesMP(seriesModel, mpModel, api); - }, this); - - for (var name in symbolDrawMap) { - if (!symbolDrawMap[name].__keep) { - symbolDrawMap[name].remove(); - this.group.remove(symbolDrawMap[name].group); - } - } - }, - - _renderSeriesMP: function (seriesModel, mpModel, api) { - var coordSys = seriesModel.coordinateSystem; - var seriesName = seriesModel.name; - var seriesData = seriesModel.getData(); - - var symbolDrawMap = this._symbolDrawMap; - var symbolDraw = symbolDrawMap[seriesName]; - if (!symbolDraw) { - symbolDraw = symbolDrawMap[seriesName] = new SymbolDraw(); - } - - var mpData = createList(coordSys, seriesModel, mpModel); - var dims = coordSys && coordSys.dimensions; - - // FIXME - zrUtil.mixin(mpModel, markPointFormatMixin); - mpModel.setData(mpData); - - mpData.each(function (idx) { - var itemModel = mpData.getItemModel(idx); - var point; - var xPx = itemModel.getShallow('x'); - var yPx = itemModel.getShallow('y'); - if (xPx != null && yPx != null) { - point = [ - numberUtil.parsePercent(xPx, api.getWidth()), - numberUtil.parsePercent(yPx, api.getHeight()) - ]; - } - // Chart like bar may have there own marker positioning logic - else if (seriesModel.getMarkerPosition) { - // Use the getMarkerPoisition - point = seriesModel.getMarkerPosition( - mpData.getValues(mpData.dimensions, idx) - ); - } - else if (coordSys) { - var x = mpData.get(dims[0], idx); - var y = mpData.get(dims[1], idx); - point = coordSys.dataToPoint([x, y]); - } - - mpData.setItemLayout(idx, point); - - var symbolSize = itemModel.getShallow('symbolSize'); - if (typeof symbolSize === 'function') { - // FIXME 这里不兼容 ECharts 2.x,2.x 貌似参数是整个数据? - symbolSize = symbolSize( - mpModel.getRawValue(idx), mpModel.getDataParams(idx) - ); - } - mpData.setItemVisual(idx, { - symbolSize: symbolSize, - color: itemModel.get('itemStyle.normal.color') - || seriesData.getVisual('color'), - symbol: itemModel.getShallow('symbol') - }); - }); - - // TODO Text are wrong - symbolDraw.updateData(mpData); - this.group.add(symbolDraw.group); - - // Set host model for tooltip - // FIXME - mpData.eachItemGraphicEl(function (el) { - el.traverse(function (child) { - child.hostModel = mpModel; - }); - }); - - symbolDraw.__keep = true; - } - }); - - /** - * @inner - * @param {module:echarts/coord/*} [coordSys] - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/model/Model} mpModel - */ - function createList(coordSys, seriesModel, mpModel) { - var coordDimsInfos = zrUtil.map(coordSys.dimensions, function (coordDim) { - var info = seriesModel.getData().getDimensionInfo( - seriesModel.coordDimToDataDim(coordDim)[0] - ); - info.name = coordDim; - return info; - }); - - var mpData = new List(coordDimsInfos, mpModel); - - if (coordSys) { - mpData.initData( - zrUtil.filter( - zrUtil.map(mpModel.get('data'), zrUtil.curry( - markerHelper.dataTransform, seriesModel - )), - zrUtil.curry(markerHelper.dataFilter, coordSys) - ), - null, - markerHelper.dimValueGetter - ); - } - - return mpData; - } + + __webpack_require__(346); + __webpack_require__(77).registerPainter('vml', __webpack_require__(348)); -}); -// HINT Markpoint can't be used too much -define('echarts/component/markPoint',['require','./marker/MarkPointModel','./marker/MarkPointView','../echarts'],function (require) { - require('./marker/MarkPointModel'); - require('./marker/MarkPointView'); +/***/ }, +/* 346 */ +/***/ function(module, exports, __webpack_require__) { - require('../echarts').registerPreprocessor(function (opt) { - // Make sure markPoint component is enabled - opt.markPoint = opt.markPoint || {}; - }); -}); -define('echarts/component/marker/MarkLineModel',['require','../../util/model','../../echarts'],function (require) { - - // Default enable markLine - // var globalDefault = require('../../model/globalDefault'); - var modelUtil = require('../../util/model'); - - // // Force to load markLine component - // globalDefault.markLine = {}; - - var MarkLineModel = require('../../echarts').extendComponentModel({ - - type: 'markLine', - - dependencies: ['series', 'grid', 'polar'], - /** - * @overrite - */ - init: function (option, parentModel, ecModel, extraOpt) { - this.mergeDefaultAndTheme(option, ecModel); - this.mergeOption(option, ecModel, extraOpt.createdBySelf, true); - }, - - mergeOption: function (newOpt, ecModel, createdBySelf, isInit) { - if (!createdBySelf) { - ecModel.eachSeries(function (seriesModel) { - var markLineOpt = seriesModel.get('markLine'); - var mlModel = seriesModel.markLineModel; - if (!markLineOpt || !markLineOpt.data) { - seriesModel.markLineModel = null; - return; - } - if (!mlModel) { - if (isInit) { - // Default label emphasis `position` and `show` - modelUtil.defaultEmphasis( - markLineOpt.label, - ['position', 'show', 'textStyle', 'distance', 'formatter'] - ); - } - var opt = { - // Use the same series index and name - seriesIndex: seriesModel.seriesIndex, - name: seriesModel.name, - createdBySelf: true - }; - mlModel = new MarkLineModel( - markLineOpt, this, ecModel, opt - ); - } - else { - mlModel.mergeOption(markLineOpt, ecModel, true); - } - seriesModel.markLineModel = mlModel; - }, this); - } - }, - - defaultOption: { - zlevel: 0, - z: 5, - // 标线起始和结束的symbol介绍类型,如果都一样,可以直接传string - symbol: ['circle', 'arrow'], - // 标线起始和结束的symbol大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2 - symbolSize: [8, 16], - // 标线起始和结束的symbol旋转控制 - //symbolRotate: null, - //smooth: false, - precision: 2, - tooltip: { - trigger: 'item' - }, - label: { - normal: { - show: true, - // 标签文本格式器,同Tooltip.formatter,不支持回调 - // formatter: null, - // 可选为 'start'|'end'|'left'|'right'|'top'|'bottom' - position: 'end' - // 默认使用全局文本样式,详见TEXTSTYLE - // textStyle: null - }, - emphasis: { - show: true - } - }, - lineStyle: { - normal: { - // color - // width - type: 'dashed' - // shadowColor: 'rgba(0,0,0,0)', - // shadowBlur: 0, - // shadowOffsetX: 0, - // shadowOffsetY: 0 - }, - emphasis: { - width: 3 - } - }, - animationEasing: 'linear' - } - }); - - return MarkLineModel; -}); -/** - * Line path for bezier and straight line draw - */ -define('echarts/chart/helper/LinePath',['require','../../util/graphic'],function (require) { - var graphic = require('../../util/graphic'); - - var straightLineProto = graphic.Line.prototype; - var bezierCurveProto = graphic.BezierCurve.prototype; - - return graphic.extendShape({ - - type: 'ec-line', - - style: { - stroke: '#000', - fill: null - }, - - shape: { - x1: 0, - y1: 0, - x2: 0, - y2: 0, - percent: 1, - cpx1: null, - cpy1: null - }, - - buildPath: function (ctx, shape) { - (shape.cpx1 == null || shape.cpy1 == null - ? straightLineProto : bezierCurveProto).buildPath(ctx, shape); - }, - - pointAt: function (t) { - var shape = this.shape; - return shape.cpx1 == null || shape.cpy1 == null - ? straightLineProto.pointAt.call(this, t) - : bezierCurveProto.pointAt.call(this, t); - } - }); -}); -/** - * @module echarts/chart/helper/Line - */ -define('echarts/chart/helper/Line',['require','../../util/symbol','zrender/core/vector','./LinePath','../../util/graphic','zrender/core/util','../../util/number'],function (require) { - - var symbolUtil = require('../../util/symbol'); - var vector = require('zrender/core/vector'); - var LinePath = require('./LinePath'); - var graphic = require('../../util/graphic'); - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../../util/number'); - - /** - * @inner - */ - function createSymbol(name, data, idx) { - var color = data.getItemVisual(idx, 'color'); - var symbolType = data.getItemVisual(idx, 'symbol'); - var symbolSize = data.getItemVisual(idx, 'symbolSize'); - - if (symbolType === 'none') { - return; - } - - if (!zrUtil.isArray(symbolSize)) { - symbolSize = [symbolSize, symbolSize]; - } - var symbolPath = symbolUtil.createSymbol( - symbolType, -symbolSize[0] / 2, -symbolSize[1] / 2, - symbolSize[0], symbolSize[1], color - ); - symbolPath.name = name; - - return symbolPath; - } - - function createLine(points) { - var line = new LinePath({ - name: 'line', - style: { - strokeNoScale: true - } - }); - setLinePoints(line.shape, points); - return line; - } - - function setLinePoints(targetShape, points) { - var p1 = points[0]; - var p2 = points[1]; - var cp1 = points[2]; - targetShape.x1 = p1[0]; - targetShape.y1 = p1[1]; - targetShape.x2 = p2[0]; - targetShape.y2 = p2[1]; - targetShape.percent = 1; - - if (cp1) { - targetShape.cpx1 = cp1[0]; - targetShape.cpy1 = cp1[1]; - } - } - - function isSymbolArrow(symbol) { - return symbol.type === 'symbol' && symbol.shape.symbolType === 'arrow'; - } - - function updateSymbolBeforeLineUpdate () { - var lineGroup = this; - var line = lineGroup.childOfName('line'); - // If line not changed - if (!this.__dirty && !line.__dirty) { - return; - } - var symbolFrom = lineGroup.childOfName('fromSymbol'); - var symbolTo = lineGroup.childOfName('toSymbol'); - var label = lineGroup.childOfName('label'); - var fromPos = line.pointAt(0); - var toPos = line.pointAt(line.shape.percent); - - var d = vector.sub([], toPos, fromPos); - vector.normalize(d, d); - - if (symbolFrom) { - symbolFrom.attr('position', fromPos); - // Rotate the arrow - // FIXME Hard coded ? - if (isSymbolArrow(symbolTo)) { - symbolTo.attr('rotation', tangentRotation(fromPos, toPos)); - } - } - if (symbolTo) { - symbolTo.attr('position', toPos); - if (isSymbolArrow(symbolFrom)) { - symbolFrom.attr('rotation', tangentRotation(toPos, fromPos)); - } - } - - label.attr('position', toPos); - - var textPosition; - var textAlign; - var textBaseline; - // End - if (label.__position === 'end') { - textPosition = [d[0] * 5 + toPos[0], d[1] * 5 + toPos[1]]; - textAlign = d[0] > 0.8 ? 'left' : (d[0] < -0.8 ? 'right' : 'center'); - textBaseline = d[1] > 0.8 ? 'top' : (d[1] < -0.8 ? 'bottom' : 'middle'); - } - // Start - else { - textPosition = [-d[0] * 5 + fromPos[0], -d[1] * 5 + fromPos[1]]; - textAlign = d[0] > 0.8 ? 'right' : (d[0] < -0.8 ? 'left' : 'center'); - textBaseline = d[1] > 0.8 ? 'bottom' : (d[1] < -0.8 ? 'top' : 'middle'); - } - label.attr({ - style: { - // Use the user specified text align and baseline first - textBaseline: label.__textBaseline || textBaseline, - textAlign: label.__textAlign || textAlign - }, - position: textPosition - }); - } - - function tangentRotation(p1, p2) { - return -Math.PI / 2 - Math.atan2( - p2[1] - p1[1], p2[0] - p1[0] - ); - } - - /** - * @constructor - * @extends {module:zrender/graphic/Group} - * @alias {module:echarts/chart/helper/Line} - */ - function Line(lineData, fromData, toData, idx) { - graphic.Group.call(this); - - this._createLine(lineData, fromData, toData, idx); - } - - var lineProto = Line.prototype; - - // Update symbol position and rotation - lineProto.beforeUpdate = updateSymbolBeforeLineUpdate; - - lineProto._createLine = function (lineData, fromData, toData, idx) { - var seriesModel = lineData.hostModel; - var linePoints = lineData.getItemLayout(idx); - - var line = createLine(linePoints); - line.shape.percent = 0; - graphic.initProps(line, { - shape: { - percent: 1 - } - }, seriesModel); - - this.add(line); - - var label = new graphic.Text({ - name: 'label' - }); - this.add(label); - - if (fromData) { - var symbolFrom = createSymbol('fromSymbol', fromData, idx); - // symbols must added after line to make sure - // it will be updated after line#update. - // Or symbol position and rotation update in line#beforeUpdate will be one frame slow - this.add(symbolFrom); - - this._fromSymbolType = fromData.getItemVisual(idx, 'symbol'); - } - if (toData) { - var symbolTo = createSymbol('toSymbol', toData, idx); - this.add(symbolTo); - - this._toSymbolType = toData.getItemVisual(idx, 'symbol'); - } - - this._updateCommonStl(lineData, fromData, toData, idx); - }; - - lineProto.updateData = function (lineData, fromData, toData, idx) { - var seriesModel = lineData.hostModel; - - var line = this.childOfName('line'); - var linePoints = lineData.getItemLayout(idx); - var target = { - shape: {} - }; - setLinePoints(target.shape, linePoints); - graphic.updateProps(line, target, seriesModel); - - // Symbol changed - if (fromData) { - var fromSymbolType = fromData.getItemVisual(idx, 'symbol'); - if (this._fromSymbolType !== fromSymbolType) { - var symbolFrom = createSymbol('fromSymbol', fromData, idx); - this.remove(line.childOfName('fromSymbol')); - this.add(symbolFrom); - } - this._fromSymbolType = fromSymbolType; - } - if (toData) { - var toSymbolType = toData.getItemVisual(idx, 'symbol'); - // Symbol changed - if (toSymbolType !== this._toSymbolType) { - var symbolTo = createSymbol('toSymbol', toData, idx); - this.remove(line.childOfName('toSymbol')); - this.add(symbolTo); - } - this._toSymbolType = toSymbolType; - } - - this._updateCommonStl(lineData, fromData, toData, idx); - }; - - lineProto._updateCommonStl = function (lineData, fromData, toData, idx) { - var seriesModel = lineData.hostModel; - - var line = this.childOfName('line'); - var itemModel = lineData.getItemModel(idx); - - var labelModel = itemModel.getModel('label.normal'); - var textStyleModel = labelModel.getModel('textStyle'); - var labelHoverModel = itemModel.getModel('label.emphasis'); - var textStyleHoverModel = labelHoverModel.getModel('textStyle'); - - var defaultText = numberUtil.round(seriesModel.getRawValue(idx)); - if (isNaN(defaultText)) { - // Use name - defaultText = lineData.getName(idx); - } - line.setStyle(zrUtil.extend( - { - stroke: lineData.getItemVisual(idx, 'color') - }, - itemModel.getModel('lineStyle.normal').getLineStyle() - )); - - var label = this.childOfName('label'); - label.setStyle({ - text: labelModel.get('show') - ? zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'normal'), - defaultText - ) - : '', - textFont: textStyleModel.getFont(), - fill: textStyleModel.getTextColor() || lineData.getItemVisual(idx, 'color') - }); - label.hoverStyle = { - text: labelHoverModel.get('show') - ? zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'emphasis'), - defaultText - ) - : '', - textFont: textStyleModel.getFont(), - fill: textStyleHoverModel.getTextColor() - }; - label.__textAlign = textStyleModel.get('align'); - label.__textBaseline = textStyleModel.get('baseline'); - label.__position = labelModel.get('position'); - - graphic.setHoverStyle( - this, itemModel.getModel('lineStyle.emphasis').getLineStyle() - ); - }; - - lineProto.updateLayout = function (lineData, fromData, toData, idx) { - var points = lineData.getItemLayout(idx); - var linePath = this.childOfName('line'); - setLinePoints(linePath.shape, points); - linePath.dirty(true); - fromData && fromData.getItemGraphicEl(idx).attr('position', points[0]); - toData && toData.getItemGraphicEl(idx).attr('position', points[1]); - }; - - zrUtil.inherits(Line, graphic.Group); - - return Line; -}); -/** - * @module echarts/chart/helper/LineDraw - */ -define('echarts/chart/helper/LineDraw',['require','../../util/graphic','./Line'],function (require) { - - var graphic = require('../../util/graphic'); - var LineGroup = require('./Line'); - - /** - * @alias module:echarts/component/marker/LineDraw - * @constructor - */ - function LineDraw(ctor) { - this._ctor = ctor || LineGroup; - this.group = new graphic.Group(); - } - - var lineDrawProto = LineDraw.prototype; - - /** - * @param {module:echarts/data/List} lineData - * @param {module:echarts/data/List} [fromData] - * @param {module:echarts/data/List} [toData] - */ - lineDrawProto.updateData = function (lineData, fromData, toData) { - - var oldLineData = this._lineData; - var group = this.group; - var LineCtor = this._ctor; - - lineData.diff(oldLineData) - .add(function (idx) { - var lineGroup = new LineCtor(lineData, fromData, toData, idx); - - lineData.setItemGraphicEl(idx, lineGroup); - - group.add(lineGroup); - }) - .update(function (newIdx, oldIdx) { - var lineGroup = oldLineData.getItemGraphicEl(oldIdx); - lineGroup.updateData(lineData, fromData, toData, newIdx); - - lineData.setItemGraphicEl(newIdx, lineGroup); - - group.add(lineGroup); - }) - .remove(function (idx) { - group.remove(oldLineData.getItemGraphicEl(idx)); - }) - .execute(); - - this._lineData = lineData; - this._fromData = fromData; - this._toData = toData; - }; - - lineDrawProto.updateLayout = function () { - var lineData = this._lineData; - lineData.eachItemGraphicEl(function (el, idx) { - el.updateLayout(lineData, this._fromData, this._toData, idx); - }, this); - }; - - lineDrawProto.remove = function () { - this.group.removeAll(); - }; - - return LineDraw; -}); -define('echarts/component/marker/MarkLineView',['require','zrender/core/util','../../data/List','../../util/format','../../util/model','../../util/number','./markerHelper','../../chart/helper/LineDraw','../../echarts'],function (require) { + // http://www.w3.org/TR/NOTE-VML + // TODO Use proxy like svg instead of overwrite brush methods - var zrUtil = require('zrender/core/util'); - var List = require('../../data/List'); - var formatUtil = require('../../util/format'); - var modelUtil = require('../../util/model'); - var numberUtil = require('../../util/number'); - var addCommas = formatUtil.addCommas; - var encodeHTML = formatUtil.encodeHTML; + if (!__webpack_require__(78).canvasSupported) { + var vec2 = __webpack_require__(16); + var BoundingRect = __webpack_require__(15); + var CMD = __webpack_require__(48).CMD; + var colorTool = __webpack_require__(38); + var textContain = __webpack_require__(14); + var RectText = __webpack_require__(47); + var Displayable = __webpack_require__(45); + var ZImage = __webpack_require__(59); + var Text = __webpack_require__(62); + var Path = __webpack_require__(44); - var markerHelper = require('./markerHelper'); - - var LineDraw = require('../../chart/helper/LineDraw'); + var Gradient = __webpack_require__(4); - var markLineTransform = function (seriesModel, coordSys, mlModel, item) { - var data = seriesModel.getData(); - // Special type markLine like 'min', 'max', 'average' - var mlType = item.type; - - if (!zrUtil.isArray(item) - && (mlType === 'min' || mlType === 'max' || mlType === 'average') - ) { - var axisInfo = markerHelper.getAxisInfo(item, data, coordSys, seriesModel); - - var baseAxisKey = axisInfo.baseAxis.dim + 'Axis'; - var valueAxisKey = axisInfo.valueAxis.dim + 'Axis'; - var baseScaleExtent = axisInfo.baseAxis.scale.getExtent(); - - var mlFrom = zrUtil.clone(item); - var mlTo = {}; - - mlFrom.type = null; - - // FIXME Polar should use circle - mlFrom[baseAxisKey] = baseScaleExtent[0]; - mlTo[baseAxisKey] = baseScaleExtent[1]; - - var value = markerHelper.numCalculate(data, axisInfo.valueDataDim, mlType); - - // Round if axis is cateogry - value = axisInfo.valueAxis.coordToData(axisInfo.valueAxis.dataToCoord(value)); - - var precision = mlModel.get('precision'); - if (precision >= 0) { - value = +value.toFixed(precision); - } - - mlFrom[valueAxisKey] = mlTo[valueAxisKey] = value; - - item = [mlFrom, mlTo, { // Extra option for tooltip and label - type: mlType, - // Force to use the value of calculated value. - value: value - }]; - } - - item = [ - markerHelper.dataTransform(seriesModel, item[0]), - markerHelper.dataTransform(seriesModel, item[1]), - zrUtil.extend({}, item[2]) - ]; - - // Merge from option and to option into line option - zrUtil.merge(item[2], item[0]); - zrUtil.merge(item[2], item[1]); - - return item; - }; - - function markLineFilter(coordSys, item) { - return markerHelper.dataFilter(coordSys, item[0]) - && markerHelper.dataFilter(coordSys, item[1]); - } - - var markLineFormatMixin = { - formatTooltip: function (dataIndex) { - var data = this._data; - var value = this.getRawValue(dataIndex); - var formattedValue = zrUtil.isArray(value) - ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); - var name = data.getName(dataIndex); - return this.name + '
' - + ((name ? encodeHTML(name) + ' : ' : '') + formattedValue); - }, - - getRawDataArray: function () { - return this.option.data; - }, - - getData: function () { - return this._data; - }, - - setData: function (data) { - this._data = data; - } - }; - - zrUtil.defaults(markLineFormatMixin, modelUtil.dataFormatMixin); - - require('../../echarts').extendComponentView({ - - type: 'markLine', - - init: function () { - /** - * Markline grouped by series - * @private - * @type {Object} - */ - this._markLineMap = {}; - }, - - render: function (markLineModel, ecModel, api) { - var lineDrawMap = this._markLineMap; - for (var name in lineDrawMap) { - lineDrawMap[name].__keep = false; - } - - ecModel.eachSeries(function (seriesModel) { - var mlModel = seriesModel.markLineModel; - mlModel && this._renderSeriesML(seriesModel, mlModel, ecModel, api); - }, this); - - for (var name in lineDrawMap) { - if (!lineDrawMap[name].__keep) { - this.group.remove(lineDrawMap[name].group); - } - } - }, - - _renderSeriesML: function (seriesModel, mlModel, ecModel, api) { - var coordSys = seriesModel.coordinateSystem; - var seriesName = seriesModel.name; - var seriesData = seriesModel.getData(); - - var lineDrawMap = this._markLineMap; - var lineDraw = lineDrawMap[seriesName]; - if (!lineDraw) { - lineDraw = lineDrawMap[seriesName] = new LineDraw(); - } - this.group.add(lineDraw.group); - - var mlData = createList(coordSys, seriesModel, mlModel); - var dims = coordSys.dimensions; - - var fromData = mlData.from; - var toData = mlData.to; - var lineData = mlData.line; - - // Line data for tooltip and formatter - zrUtil.extend(mlModel, markLineFormatMixin); - mlModel.setData(lineData); - - var symbolType = mlModel.get('symbol'); - var symbolSize = mlModel.get('symbolSize'); - if (!zrUtil.isArray(symbolType)) { - symbolType = [symbolType, symbolType]; - } - if (typeof symbolSize === 'number') { - symbolSize = [symbolSize, symbolSize]; - } - - // Update visual and layout of from symbol and to symbol - mlData.from.each(function (idx) { - updateDataVisualAndLayout(fromData, idx, true); - updateDataVisualAndLayout(toData, idx); - }); - - // Update visual and layout of line - lineData.each(function (idx) { - var lineColor = lineData.getItemModel(idx).get('lineStyle.normal.color'); - lineData.setItemVisual(idx, { - color: lineColor || fromData.getItemVisual(idx, 'color') - }); - lineData.setItemLayout(idx, [ - fromData.getItemLayout(idx), - toData.getItemLayout(idx) - ]); - }); - - lineDraw.updateData(lineData, fromData, toData); - - // Set host model for tooltip - // FIXME - mlData.line.eachItemGraphicEl(function (el, idx) { - el.traverse(function (child) { - child.hostModel = mlModel; - }); - }); - - function updateDataVisualAndLayout(data, idx, isFrom) { - var itemModel = data.getItemModel(idx); - - var point; - var xPx = itemModel.get('x'); - var yPx = itemModel.get('y'); - if (xPx != null && yPx != null) { - point = [ - numberUtil.parsePercent(xPx, api.getWidth()), - numberUtil.parsePercent(yPx, api.getHeight()) - ]; - } - // Chart like bar may have there own marker positioning logic - else if (seriesModel.getMarkerPosition) { - // Use the getMarkerPoisition - point = seriesModel.getMarkerPosition( - data.getValues(data.dimensions, idx) - ); - } - else { - var x = data.get(dims[0], idx); - var y = data.get(dims[1], idx); - point = coordSys.dataToPoint([x, y]); - } - - data.setItemLayout(idx, point); - - data.setItemVisual(idx, { - symbolSize: itemModel.get('symbolSize') - || symbolSize[isFrom ? 0 : 1], - symbol: itemModel.get('symbol', true) - || symbolType[isFrom ? 0 : 1], - color: itemModel.get('itemStyle.normal.color') - || seriesData.getVisual('color') - }); - } - - lineDraw.__keep = true; - } - }); - - /** - * @inner - * @param {module:echarts/coord/*} coordSys - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/model/Model} mpModel - */ - function createList(coordSys, seriesModel, mlModel) { - - var coordDimsInfos = zrUtil.map(coordSys.dimensions, function (coordDim) { - var info = seriesModel.getData().getDimensionInfo( - seriesModel.coordDimToDataDim(coordDim)[0] - ); - info.name = coordDim; - return info; - }); - var fromData = new List(coordDimsInfos, mlModel); - var toData = new List(coordDimsInfos, mlModel); - // No dimensions - var lineData = new List([], mlModel); - - if (coordSys) { - var optData = zrUtil.filter( - zrUtil.map(mlModel.get('data'), zrUtil.curry( - markLineTransform, seriesModel, coordSys, mlModel - )), - zrUtil.curry(markLineFilter, coordSys) - ); - fromData.initData( - zrUtil.map(optData, function (item) { return item[0]; }), - null, - markerHelper.dimValueGetter - ); - toData.initData( - zrUtil.map(optData, function (item) { return item[1]; }), - null, - markerHelper.dimValueGetter - ); - lineData.initData( - zrUtil.map(optData, function (item) { return item[2]; }) - ); - - } - return { - from: fromData, - to: toData, - line: lineData - }; - } -}); -define('echarts/component/markLine',['require','./marker/MarkLineModel','./marker/MarkLineView','../echarts'],function (require) { + var vmlCore = __webpack_require__(347); - require('./marker/MarkLineModel'); - require('./marker/MarkLineView'); + var round = Math.round; + var sqrt = Math.sqrt; + var abs = Math.abs; + var cos = Math.cos; + var sin = Math.sin; + var mathMax = Math.max; + + var applyTransform = vec2.applyTransform; + + var comma = ','; + var imageTransformPrefix = 'progid:DXImageTransform.Microsoft'; + + var Z = 21600; + var Z2 = Z / 2; + + var ZLEVEL_BASE = 100000; + var Z_BASE = 1000; + + var initRootElStyle = function (el) { + el.style.cssText = 'position:absolute;left:0;top:0;width:1px;height:1px;'; + el.coordsize = Z + ',' + Z; + el.coordorigin = '0,0'; + }; + + var encodeHtmlAttribute = function (s) { + return String(s).replace(/&/g, '&').replace(/"/g, '"'); + }; + + var rgb2Str = function (r, g, b) { + return 'rgb(' + [r, g, b].join(',') + ')'; + }; + + var append = function (parent, child) { + if (child && parent && child.parentNode !== parent) { + parent.appendChild(child); + } + }; + + var remove = function (parent, child) { + if (child && parent && child.parentNode === parent) { + parent.removeChild(child); + } + }; + + var getZIndex = function (zlevel, z, z2) { + // z 的取值范围为 [0, 1000] + return (parseFloat(zlevel) || 0) * ZLEVEL_BASE + (parseFloat(z) || 0) * Z_BASE + z2; + }; + + var parsePercent = function (value, maxValue) { + if (typeof value === 'string') { + if (value.lastIndexOf('%') >= 0) { + return parseFloat(value) / 100 * maxValue; + } + return parseFloat(value); + } + return value; + }; + + /*************************************************** + * PATH + **************************************************/ + + var setColorAndOpacity = function (el, color, opacity) { + var colorArr = colorTool.parse(color); + opacity = +opacity; + if (isNaN(opacity)) { + opacity = 1; + } + if (colorArr) { + el.color = rgb2Str(colorArr[0], colorArr[1], colorArr[2]); + el.opacity = opacity * colorArr[3]; + } + }; + + var getColorAndAlpha = function (color) { + var colorArr = colorTool.parse(color); + return [ + rgb2Str(colorArr[0], colorArr[1], colorArr[2]), + colorArr[3] + ]; + }; + + var updateFillNode = function (el, style, zrEl) { + // TODO pattern + var fill = style.fill; + if (fill != null) { + // Modified from excanvas + if (fill instanceof Gradient) { + var gradientType; + var angle = 0; + var focus = [0, 0]; + // additional offset + var shift = 0; + // scale factor for offset + var expansion = 1; + var rect = zrEl.getBoundingRect(); + var rectWidth = rect.width; + var rectHeight = rect.height; + if (fill.type === 'linear') { + gradientType = 'gradient'; + var transform = zrEl.transform; + var p0 = [fill.x * rectWidth, fill.y * rectHeight]; + var p1 = [fill.x2 * rectWidth, fill.y2 * rectHeight]; + if (transform) { + applyTransform(p0, p0, transform); + applyTransform(p1, p1, transform); + } + var dx = p1[0] - p0[0]; + var dy = p1[1] - p0[1]; + angle = Math.atan2(dx, dy) * 180 / Math.PI; + // The angle should be a non-negative number. + if (angle < 0) { + angle += 360; + } + + // Very small angles produce an unexpected result because they are + // converted to a scientific notation string. + if (angle < 1e-6) { + angle = 0; + } + } + else { + gradientType = 'gradientradial'; + var p0 = [fill.x * rectWidth, fill.y * rectHeight]; + var transform = zrEl.transform; + var scale = zrEl.scale; + var width = rectWidth; + var height = rectHeight; + focus = [ + // Percent in bounding rect + (p0[0] - rect.x) / width, + (p0[1] - rect.y) / height + ]; + if (transform) { + applyTransform(p0, p0, transform); + } + + width /= scale[0] * Z; + height /= scale[1] * Z; + var dimension = mathMax(width, height); + shift = 2 * 0 / dimension; + expansion = 2 * fill.r / dimension - shift; + } + + // We need to sort the color stops in ascending order by offset, + // otherwise IE won't interpret it correctly. + var stops = fill.colorStops.slice(); + stops.sort(function(cs1, cs2) { + return cs1.offset - cs2.offset; + }); + + var length = stops.length; + // Color and alpha list of first and last stop + var colorAndAlphaList = []; + var colors = []; + for (var i = 0; i < length; i++) { + var stop = stops[i]; + var colorAndAlpha = getColorAndAlpha(stop.color); + colors.push(stop.offset * expansion + shift + ' ' + colorAndAlpha[0]); + if (i === 0 || i === length - 1) { + colorAndAlphaList.push(colorAndAlpha); + } + } + + if (length >= 2) { + var color1 = colorAndAlphaList[0][0]; + var color2 = colorAndAlphaList[1][0]; + var opacity1 = colorAndAlphaList[0][1] * style.opacity; + var opacity2 = colorAndAlphaList[1][1] * style.opacity; + + el.type = gradientType; + el.method = 'none'; + el.focus = '100%'; + el.angle = angle; + el.color = color1; + el.color2 = color2; + el.colors = colors.join(','); + // When colors attribute is used, the meanings of opacity and o:opacity2 + // are reversed. + el.opacity = opacity2; + // FIXME g_o_:opacity ? + el.opacity2 = opacity1; + } + if (gradientType === 'radial') { + el.focusposition = focus.join(','); + } + } + else { + // FIXME Change from Gradient fill to color fill + setColorAndOpacity(el, fill, style.opacity); + } + } + }; + + var updateStrokeNode = function (el, style) { + if (style.lineJoin != null) { + el.joinstyle = style.lineJoin; + } + if (style.miterLimit != null) { + el.miterlimit = style.miterLimit * Z; + } + if (style.lineCap != null) { + el.endcap = style.lineCap; + } + if (style.lineDash != null) { + el.dashstyle = style.lineDash.join(' '); + } + if (style.stroke != null && !(style.stroke instanceof Gradient)) { + setColorAndOpacity(el, style.stroke, style.opacity); + } + }; + + var updateFillAndStroke = function (vmlEl, type, style, zrEl) { + var isFill = type == 'fill'; + var el = vmlEl.getElementsByTagName(type)[0]; + // Stroke must have lineWidth + if (style[type] != null && style[type] !== 'none' && (isFill || (!isFill && style.lineWidth))) { + vmlEl[isFill ? 'filled' : 'stroked'] = 'true'; + // FIXME Remove before updating, or set `colors` will throw error + if (style[type] instanceof Gradient) { + remove(vmlEl, el); + } + if (!el) { + el = vmlCore.createNode(type); + } + + isFill ? updateFillNode(el, style, zrEl) : updateStrokeNode(el, style); + append(vmlEl, el); + } + else { + vmlEl[isFill ? 'filled' : 'stroked'] = 'false'; + remove(vmlEl, el); + } + }; + + var points = [[], [], []]; + var pathDataToString = function (data, m) { + var M = CMD.M; + var C = CMD.C; + var L = CMD.L; + var A = CMD.A; + var Q = CMD.Q; + + var str = []; + var nPoint; + var cmdStr; + var cmd; + var i; + var xi; + var yi; + for (i = 0; i < data.length;) { + cmd = data[i++]; + cmdStr = ''; + nPoint = 0; + switch (cmd) { + case M: + cmdStr = ' m '; + nPoint = 1; + xi = data[i++]; + yi = data[i++]; + points[0][0] = xi; + points[0][1] = yi; + break; + case L: + cmdStr = ' l '; + nPoint = 1; + xi = data[i++]; + yi = data[i++]; + points[0][0] = xi; + points[0][1] = yi; + break; + case Q: + case C: + cmdStr = ' c '; + nPoint = 3; + var x1 = data[i++]; + var y1 = data[i++]; + var x2 = data[i++]; + var y2 = data[i++]; + var x3; + var y3; + if (cmd === Q) { + // Convert quadratic to cubic using degree elevation + x3 = x2; + y3 = y2; + x2 = (x2 + 2 * x1) / 3; + y2 = (y2 + 2 * y1) / 3; + x1 = (xi + 2 * x1) / 3; + y1 = (yi + 2 * y1) / 3; + } + else { + x3 = data[i++]; + y3 = data[i++]; + } + points[0][0] = x1; + points[0][1] = y1; + points[1][0] = x2; + points[1][1] = y2; + points[2][0] = x3; + points[2][1] = y3; + + xi = x3; + yi = y3; + break; + case A: + var x = 0; + var y = 0; + var sx = 1; + var sy = 1; + var angle = 0; + if (m) { + // Extract SRT from matrix + x = m[4]; + y = m[5]; + sx = sqrt(m[0] * m[0] + m[1] * m[1]); + sy = sqrt(m[2] * m[2] + m[3] * m[3]); + angle = Math.atan2(-m[1] / sy, m[0] / sx); + } + + var cx = data[i++]; + var cy = data[i++]; + var rx = data[i++]; + var ry = data[i++]; + var startAngle = data[i++] + angle; + var endAngle = data[i++] + startAngle + angle; + // FIXME + // var psi = data[i++]; + i++; + var clockwise = data[i++]; + + var x0 = cx + cos(startAngle) * rx; + var y0 = cy + sin(startAngle) * ry; + + var x1 = cx + cos(endAngle) * rx; + var y1 = cy + sin(endAngle) * ry; + + var type = clockwise ? ' wa ' : ' at '; + + str.push( + type, + round(((cx - rx) * sx + x) * Z - Z2), comma, + round(((cy - ry) * sy + y) * Z - Z2), comma, + round(((cx + rx) * sx + x) * Z - Z2), comma, + round(((cy + ry) * sy + y) * Z - Z2), comma, + round((x0 * sx + x) * Z - Z2), comma, + round((y0 * sy + y) * Z - Z2), comma, + round((x1 * sx + x) * Z - Z2), comma, + round((y1 * sy + y) * Z - Z2) + ); + + xi = x1; + yi = y1; + break; + case CMD.R: + var p0 = points[0]; + var p1 = points[1]; + // x0, y0 + p0[0] = data[i++]; + p0[1] = data[i++]; + // x1, y1 + p1[0] = p0[0] + data[i++]; + p1[1] = p0[1] + data[i++]; + + if (m) { + applyTransform(p0, p0, m); + applyTransform(p1, p1, m); + } + + p0[0] = round(p0[0] * Z - Z2); + p1[0] = round(p1[0] * Z - Z2); + p0[1] = round(p0[1] * Z - Z2); + p1[1] = round(p1[1] * Z - Z2); + str.push( + // x0, y0 + ' m ', p0[0], comma, p0[1], + // x1, y0 + ' l ', p1[0], comma, p0[1], + // x1, y1 + ' l ', p1[0], comma, p1[1], + // x0, y1 + ' l ', p0[0], comma, p1[1] + ); + break; + case CMD.Z: + // FIXME Update xi, yi + str.push(' x '); + } + + if (nPoint > 0) { + str.push(cmdStr); + for (var k = 0; k < nPoint; k++) { + var p = points[k]; + + m && applyTransform(p, p, m); + // 不 round 会非常慢 + str.push( + round(p[0] * Z - Z2), comma, round(p[1] * Z - Z2), + k < nPoint - 1 ? comma : '' + ); + } + } + } + return str.join(''); + }; + + // Rewrite the original path method + Path.prototype.brush = function (vmlRoot) { + var style = this.style; + + var vmlEl = this._vmlEl; + if (!vmlEl) { + vmlEl = vmlCore.createNode('shape'); + initRootElStyle(vmlEl); + + this._vmlEl = vmlEl; + } + + updateFillAndStroke(vmlEl, 'fill', style, this); + updateFillAndStroke(vmlEl, 'stroke', style, this); + + var m = this.transform; + var needTransform = m != null; + var strokeEl = vmlEl.getElementsByTagName('stroke')[0]; + if (strokeEl) { + var lineWidth = style.lineWidth; + // Get the line scale. + // Determinant of this.m_ means how much the area is enlarged by the + // transformation. So its square root can be used as a scale factor + // for width. + if (needTransform && !style.strokeNoScale) { + var det = m[0] * m[3] - m[1] * m[2]; + lineWidth *= sqrt(abs(det)); + } + strokeEl.weight = lineWidth + 'px'; + } + + var path = this.path; + if (this.__dirtyPath) { + path.beginPath(); + this.buildPath(path, this.shape); + this.__dirtyPath = false; + } + + vmlEl.path = pathDataToString(path.data, this.transform); + + vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2); + + // Append to root + append(vmlRoot, vmlEl); + + // Text + if (style.text) { + this.drawRectText(vmlRoot, this.getBoundingRect()); + } + }; + + Path.prototype.onRemoveFromStorage = function (vmlRoot) { + remove(vmlRoot, this._vmlEl); + this.removeRectText(vmlRoot); + }; + + Path.prototype.onAddToStorage = function (vmlRoot) { + append(vmlRoot, this._vmlEl); + this.appendRectText(vmlRoot); + }; + + /*************************************************** + * IMAGE + **************************************************/ + var isImage = function (img) { + // FIXME img instanceof Image 如果 img 是一个字符串的时候,IE8 下会报错 + return (typeof img === 'object') && img.tagName && img.tagName.toUpperCase() === 'IMG'; + // return img instanceof Image; + }; + + // Rewrite the original path method + ZImage.prototype.brush = function (vmlRoot) { + var style = this.style; + var image = style.image; + + // Image original width, height + var ow; + var oh; + + if (isImage(image)) { + var src = image.src; + if (src === this._imageSrc) { + ow = this._imageWidth; + oh = this._imageHeight; + } + else { + var imageRuntimeStyle = image.runtimeStyle; + var oldRuntimeWidth = imageRuntimeStyle.width; + var oldRuntimeHeight = imageRuntimeStyle.height; + imageRuntimeStyle.width = 'auto'; + imageRuntimeStyle.height = 'auto'; + + // get the original size + ow = image.width; + oh = image.height; + + // and remove overides + imageRuntimeStyle.width = oldRuntimeWidth; + imageRuntimeStyle.height = oldRuntimeHeight; + + // Caching image original width, height and src + this._imageSrc = src; + this._imageWidth = ow; + this._imageHeight = oh; + } + image = src; + } + else { + if (image === this._imageSrc) { + ow = this._imageWidth; + oh = this._imageHeight; + } + } + if (!image) { + return; + } + + var x = style.x || 0; + var y = style.y || 0; + + var dw = style.width; + var dh = style.height; + + var sw = style.sWidth; + var sh = style.sHeight; + var sx = style.sx || 0; + var sy = style.sy || 0; + + var hasCrop = sw && sh; + + var vmlEl = this._vmlEl; + if (!vmlEl) { + // FIXME 使用 group 在 left, top 都不是 0 的时候就无法显示了。 + // vmlEl = vmlCore.createNode('group'); + vmlEl = vmlCore.doc.createElement('div'); + initRootElStyle(vmlEl); + + this._vmlEl = vmlEl; + } + + var vmlElStyle = vmlEl.style; + var hasRotation = false; + var m; + var scaleX = 1; + var scaleY = 1; + if (this.transform) { + m = this.transform; + scaleX = sqrt(m[0] * m[0] + m[1] * m[1]); + scaleY = sqrt(m[2] * m[2] + m[3] * m[3]); + + hasRotation = m[1] || m[2]; + } + if (hasRotation) { + // If filters are necessary (rotation exists), create them + // filters are bog-slow, so only create them if abbsolutely necessary + // The following check doesn't account for skews (which don't exist + // in the canvas spec (yet) anyway. + // From excanvas + var p0 = [x, y]; + var p1 = [x + dw, y]; + var p2 = [x, y + dh]; + var p3 = [x + dw, y + dh]; + applyTransform(p0, p0, m); + applyTransform(p1, p1, m); + applyTransform(p2, p2, m); + applyTransform(p3, p3, m); + + var maxX = mathMax(p0[0], p1[0], p2[0], p3[0]); + var maxY = mathMax(p0[1], p1[1], p2[1], p3[1]); + + var transformFilter = []; + transformFilter.push('M11=', m[0] / scaleX, comma, + 'M12=', m[2] / scaleY, comma, + 'M21=', m[1] / scaleX, comma, + 'M22=', m[3] / scaleY, comma, + 'Dx=', round(x * scaleX + m[4]), comma, + 'Dy=', round(y * scaleY + m[5])); + + vmlElStyle.padding = '0 ' + round(maxX) + 'px ' + round(maxY) + 'px 0'; + // FIXME DXImageTransform 在 IE11 的兼容模式下不起作用 + vmlElStyle.filter = imageTransformPrefix + '.Matrix(' + + transformFilter.join('') + ', SizingMethod=clip)'; + + } + else { + if (m) { + x = x * scaleX + m[4]; + y = y * scaleY + m[5]; + } + vmlElStyle.filter = ''; + vmlElStyle.left = round(x) + 'px'; + vmlElStyle.top = round(y) + 'px'; + } + + var imageEl = this._imageEl; + var cropEl = this._cropEl; + + if (! imageEl) { + imageEl = vmlCore.doc.createElement('div'); + this._imageEl = imageEl; + } + var imageELStyle = imageEl.style; + if (hasCrop) { + // Needs know image original width and height + if (! (ow && oh)) { + var tmpImage = new Image(); + var self = this; + tmpImage.onload = function () { + tmpImage.onload = null; + ow = tmpImage.width; + oh = tmpImage.height; + // Adjust image width and height to fit the ratio destinationSize / sourceSize + imageELStyle.width = round(scaleX * ow * dw / sw) + 'px'; + imageELStyle.height = round(scaleY * oh * dh / sh) + 'px'; + + // Caching image original width, height and src + self._imageWidth = ow; + self._imageHeight = oh; + self._imageSrc = image; + }; + tmpImage.src = image; + } + else { + imageELStyle.width = round(scaleX * ow * dw / sw) + 'px'; + imageELStyle.height = round(scaleY * oh * dh / sh) + 'px'; + } + + if (! cropEl) { + cropEl = vmlCore.doc.createElement('div'); + cropEl.style.overflow = 'hidden'; + this._cropEl = cropEl; + } + var cropElStyle = cropEl.style; + cropElStyle.width = round((dw + sx * dw / sw) * scaleX); + cropElStyle.height = round((dh + sy * dh / sh) * scaleY); + cropElStyle.filter = imageTransformPrefix + '.Matrix(Dx=' + + (-sx * dw / sw * scaleX) + ',Dy=' + (-sy * dh / sh * scaleY) + ')'; + + if (! cropEl.parentNode) { + vmlEl.appendChild(cropEl); + } + if (imageEl.parentNode != cropEl) { + cropEl.appendChild(imageEl); + } + } + else { + imageELStyle.width = round(scaleX * dw) + 'px'; + imageELStyle.height = round(scaleY * dh) + 'px'; + + vmlEl.appendChild(imageEl); + + if (cropEl && cropEl.parentNode) { + vmlEl.removeChild(cropEl); + this._cropEl = null; + } + } + + var filterStr = ''; + var alpha = style.opacity; + if (alpha < 1) { + filterStr += '.Alpha(opacity=' + round(alpha * 100) + ') '; + } + filterStr += imageTransformPrefix + '.AlphaImageLoader(src=' + image + ', SizingMethod=scale)'; + + imageELStyle.filter = filterStr; + + vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2); + + // Append to root + append(vmlRoot, vmlEl); + + // Text + if (style.text) { + this.drawRectText(vmlRoot, this.getBoundingRect()); + } + }; + + ZImage.prototype.onRemoveFromStorage = function (vmlRoot) { + remove(vmlRoot, this._vmlEl); + + this._vmlEl = null; + this._cropEl = null; + this._imageEl = null; + + this.removeRectText(vmlRoot); + }; + + ZImage.prototype.onAddToStorage = function (vmlRoot) { + append(vmlRoot, this._vmlEl); + this.appendRectText(vmlRoot); + }; + + + /*************************************************** + * TEXT + **************************************************/ + + var DEFAULT_STYLE_NORMAL = 'normal'; + + var fontStyleCache = {}; + var fontStyleCacheCount = 0; + var MAX_FONT_CACHE_SIZE = 100; + var fontEl = document.createElement('div'); + + var getFontStyle = function (fontString) { + var fontStyle = fontStyleCache[fontString]; + if (!fontStyle) { + // Clear cache + if (fontStyleCacheCount > MAX_FONT_CACHE_SIZE) { + fontStyleCacheCount = 0; + fontStyleCache = {}; + } + + var style = fontEl.style; + var fontFamily; + try { + style.font = fontString; + fontFamily = style.fontFamily.split(',')[0]; + } + catch (e) { + } + + fontStyle = { + style: style.fontStyle || DEFAULT_STYLE_NORMAL, + variant: style.fontVariant || DEFAULT_STYLE_NORMAL, + weight: style.fontWeight || DEFAULT_STYLE_NORMAL, + size: parseFloat(style.fontSize || 12) | 0, + family: fontFamily || 'Microsoft YaHei' + }; + + fontStyleCache[fontString] = fontStyle; + fontStyleCacheCount++; + } + return fontStyle; + }; + + var textMeasureEl; + // Overwrite measure text method + textContain.measureText = function (text, textFont) { + var doc = vmlCore.doc; + if (!textMeasureEl) { + textMeasureEl = doc.createElement('div'); + textMeasureEl.style.cssText = 'position:absolute;top:-20000px;left:0;' + + 'padding:0;margin:0;border:none;white-space:pre;'; + vmlCore.doc.body.appendChild(textMeasureEl); + } + + try { + textMeasureEl.style.font = textFont; + } catch (ex) { + // Ignore failures to set to invalid font. + } + textMeasureEl.innerHTML = ''; + // Don't use innerHTML or innerText because they allow markup/whitespace. + textMeasureEl.appendChild(doc.createTextNode(text)); + return { + width: textMeasureEl.offsetWidth + }; + }; + + var tmpRect = new BoundingRect(); + + var drawRectText = function (vmlRoot, rect, textRect, fromTextEl) { + + var style = this.style; + var text = style.text; + if (!text) { + return; + } + + var x; + var y; + var align = style.textAlign; + var fontStyle = getFontStyle(style.textFont); + // FIXME encodeHtmlAttribute ? + var font = fontStyle.style + ' ' + fontStyle.variant + ' ' + fontStyle.weight + ' ' + + fontStyle.size + 'px "' + fontStyle.family + '"'; + var baseline = style.textBaseline; + var verticalAlign = style.textVerticalAlign; + + textRect = textRect || textContain.getBoundingRect(text, font, align, baseline); + + // Transform rect to view space + var m = this.transform; + // Ignore transform for text in other element + if (m && !fromTextEl) { + tmpRect.copy(rect); + tmpRect.applyTransform(m); + rect = tmpRect; + } + + if (!fromTextEl) { + var textPosition = style.textPosition; + var distance = style.textDistance; + // Text position represented by coord + if (textPosition instanceof Array) { + x = rect.x + parsePercent(textPosition[0], rect.width); + y = rect.y + parsePercent(textPosition[1], rect.height); + + align = align || 'left'; + baseline = baseline || 'top'; + } + else { + var res = textContain.adjustTextPositionOnRect( + textPosition, rect, textRect, distance + ); + x = res.x; + y = res.y; + + // Default align and baseline when has textPosition + align = align || res.textAlign; + baseline = baseline || res.textBaseline; + } + } + else { + x = rect.x; + y = rect.y; + } + if (verticalAlign) { + switch (verticalAlign) { + case 'middle': + y -= textRect.height / 2; + break; + case 'bottom': + y -= textRect.height; + break; + // 'top' + } + // Ignore baseline + baseline = 'top'; + } + + var fontSize = fontStyle.size; + // 1.75 is an arbitrary number, as there is no info about the text baseline + switch (baseline) { + case 'hanging': + case 'top': + y += fontSize / 1.75; + break; + case 'middle': + break; + default: + // case null: + // case 'alphabetic': + // case 'ideographic': + // case 'bottom': + y -= fontSize / 2.25; + break; + } + switch (align) { + case 'left': + break; + case 'center': + x -= textRect.width / 2; + break; + case 'right': + x -= textRect.width; + break; + // case 'end': + // align = elementStyle.direction == 'ltr' ? 'right' : 'left'; + // break; + // case 'start': + // align = elementStyle.direction == 'rtl' ? 'right' : 'left'; + // break; + // default: + // align = 'left'; + } + + var createNode = vmlCore.createNode; + + var textVmlEl = this._textVmlEl; + var pathEl; + var textPathEl; + var skewEl; + if (!textVmlEl) { + textVmlEl = createNode('line'); + pathEl = createNode('path'); + textPathEl = createNode('textpath'); + skewEl = createNode('skew'); + + // FIXME Why here is not cammel case + // Align 'center' seems wrong + textPathEl.style['v-text-align'] = 'left'; + + initRootElStyle(textVmlEl); + + pathEl.textpathok = true; + textPathEl.on = true; + + textVmlEl.from = '0 0'; + textVmlEl.to = '1000 0.05'; + + append(textVmlEl, skewEl); + append(textVmlEl, pathEl); + append(textVmlEl, textPathEl); + + this._textVmlEl = textVmlEl; + } + else { + // 这里是在前面 appendChild 保证顺序的前提下 + skewEl = textVmlEl.firstChild; + pathEl = skewEl.nextSibling; + textPathEl = pathEl.nextSibling; + } + + var coords = [x, y]; + var textVmlElStyle = textVmlEl.style; + // Ignore transform for text in other element + if (m && fromTextEl) { + applyTransform(coords, coords, m); + + skewEl.on = true; + + skewEl.matrix = m[0].toFixed(3) + comma + m[2].toFixed(3) + comma + + m[1].toFixed(3) + comma + m[3].toFixed(3) + ',0,0'; + + // Text position + skewEl.offset = (round(coords[0]) || 0) + ',' + (round(coords[1]) || 0); + // Left top point as origin + skewEl.origin = '0 0'; + + textVmlElStyle.left = '0px'; + textVmlElStyle.top = '0px'; + } + else { + skewEl.on = false; + textVmlElStyle.left = round(x) + 'px'; + textVmlElStyle.top = round(y) + 'px'; + } + + textPathEl.string = encodeHtmlAttribute(text); + // TODO + try { + textPathEl.style.font = font; + } + // Error font format + catch (e) {} + + updateFillAndStroke(textVmlEl, 'fill', { + fill: fromTextEl ? style.fill : style.textFill, + opacity: style.opacity + }, this); + updateFillAndStroke(textVmlEl, 'stroke', { + stroke: fromTextEl ? style.stroke : style.textStroke, + opacity: style.opacity, + lineDash: style.lineDash + }, this); + + textVmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2); + + // Attached to root + append(vmlRoot, textVmlEl); + }; + + var removeRectText = function (vmlRoot) { + remove(vmlRoot, this._textVmlEl); + this._textVmlEl = null; + }; + + var appendRectText = function (vmlRoot) { + append(vmlRoot, this._textVmlEl); + }; + + var list = [RectText, Displayable, ZImage, Path, Text]; + + // In case Displayable has been mixed in RectText + for (var i = 0; i < list.length; i++) { + var proto = list[i].prototype; + proto.drawRectText = drawRectText; + proto.removeRectText = removeRectText; + proto.appendRectText = appendRectText; + } + + Text.prototype.brush = function (root) { + var style = this.style; + if (style.text) { + this.drawRectText(root, { + x: style.x || 0, y: style.y || 0, + width: 0, height: 0 + }, this.getBoundingRect(), true); + } + }; + + Text.prototype.onRemoveFromStorage = function (vmlRoot) { + this.removeRectText(vmlRoot); + }; + + Text.prototype.onAddToStorage = function (vmlRoot) { + this.appendRectText(vmlRoot); + }; + } + + +/***/ }, +/* 347 */ +/***/ function(module, exports, __webpack_require__) { + + + + if (!__webpack_require__(78).canvasSupported) { + var urn = 'urn:schemas-microsoft-com:vml'; + + var createNode; + var win = window; + var doc = win.document; + + var vmlInited = false; + + try { + !doc.namespaces.zrvml && doc.namespaces.add('zrvml', urn); + createNode = function (tagName) { + return doc.createElement(''); + }; + } + catch (e) { + createNode = function (tagName) { + return doc.createElement('<' + tagName + ' xmlns="' + urn + '" class="zrvml">'); + }; + } + + // From raphael + var initVML = function () { + if (vmlInited) { + return; + } + vmlInited = true; + + var styleSheets = doc.styleSheets; + if (styleSheets.length < 31) { + doc.createStyleSheet().addRule('.zrvml', 'behavior:url(#default#VML)'); + } + else { + // http://msdn.microsoft.com/en-us/library/ms531194%28VS.85%29.aspx + styleSheets[0].addRule('.zrvml', 'behavior:url(#default#VML)'); + } + }; - require('../echarts').registerPreprocessor(function (opt) { - // Make sure markLine component is enabled - opt.markLine = opt.markLine || {}; - }); -}); -define('echarts/component/dataZoom/typeDefaulter',['require','../../model/Component'],function (require) { + // Not useing return to avoid error when converting to CommonJS module + module.exports = { + doc: doc, + initVML: initVML, + createNode: createNode + }; + } - require('../../model/Component').registerSubTypeDefaulter('dataZoom', function (option) { - // Default 'slider' when no type specified. - return 'slider'; - }); +/***/ }, +/* 348 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * VML Painter. + * + * @module zrender/vml/Painter + */ + + + + var zrLog = __webpack_require__(39); + var vmlCore = __webpack_require__(347); + + function parseInt10(val) { + return parseInt(val, 10); + } + + /** + * @alias module:zrender/vml/Painter + */ + function VMLPainter(root, storage) { + + vmlCore.initVML(); + + this.root = root; + + this.storage = storage; + + var vmlViewport = document.createElement('div'); + + var vmlRoot = document.createElement('div'); + + vmlViewport.style.cssText = 'display:inline-block;overflow:hidden;position:relative;width:300px;height:150px;'; + + vmlRoot.style.cssText = 'position:absolute;left:0;top:0;'; + + root.appendChild(vmlViewport); + + this._vmlRoot = vmlRoot; + this._vmlViewport = vmlViewport; + + this.resize(); + + // Modify storage + var oldDelFromMap = storage.delFromMap; + var oldAddToMap = storage.addToMap; + storage.delFromMap = function (elId) { + var el = storage.get(elId); + + oldDelFromMap.call(storage, elId); + + if (el) { + el.onRemoveFromStorage && el.onRemoveFromStorage(vmlRoot); + } + }; + + storage.addToMap = function (el) { + // Displayable already has a vml node + el.onAddToStorage && el.onAddToStorage(vmlRoot); + + oldAddToMap.call(storage, el); + }; + + this._firstPaint = true; + } + + VMLPainter.prototype = { + + constructor: VMLPainter, + + /** + * @return {HTMLDivElement} + */ + getViewportRoot: function () { + return this._vmlViewport; + }, + + /** + * 刷新 + */ + refresh: function () { + + var list = this.storage.getDisplayList(true, true); + + this._paintList(list); + }, + + _paintList: function (list) { + var vmlRoot = this._vmlRoot; + for (var i = 0; i < list.length; i++) { + var el = list[i]; + if (el.invisible || el.ignore) { + if (!el.__alreadyNotVisible) { + el.onRemoveFromStorage(vmlRoot); + } + // Set as already invisible + el.__alreadyNotVisible = true; + } + else { + if (el.__alreadyNotVisible) { + el.onAddToStorage(vmlRoot); + } + el.__alreadyNotVisible = false; + if (el.__dirty) { + el.beforeBrush && el.beforeBrush(); + el.brush(vmlRoot); + el.afterBrush && el.afterBrush(); + } + } + el.__dirty = false; + } + + if (this._firstPaint) { + // Detached from document at first time + // to avoid page refreshing too many times + + // FIXME 如果每次都先 removeChild 可能会导致一些填充和描边的效果改变 + this._vmlViewport.appendChild(vmlRoot); + this._firstPaint = false; + } + }, + + resize: function () { + var width = this._getWidth(); + var height = this._getHeight(); + + if (this._width != width && this._height != height) { + this._width = width; + this._height = height; + + var vmlViewportStyle = this._vmlViewport.style; + vmlViewportStyle.width = width + 'px'; + vmlViewportStyle.height = height + 'px'; + } + }, + + dispose: function () { + this.root.innerHTML = ''; + + this._vmlRoot = + this._vmlViewport = + this.storage = null; + }, + + getWidth: function () { + return this._width; + }, + + getHeight: function () { + return this._height; + }, + + _getWidth: function () { + var root = this.root; + var stl = root.currentStyle; + + return ((root.clientWidth || parseInt10(stl.width)) + - parseInt10(stl.paddingLeft) + - parseInt10(stl.paddingRight)) | 0; + }, + + _getHeight: function () { + var root = this.root; + var stl = root.currentStyle; + + return ((root.clientHeight || parseInt10(stl.height)) + - parseInt10(stl.paddingTop) + - parseInt10(stl.paddingBottom)) | 0; + } + }; + + // Not supported methods + function createMethodNotSupport(method) { + return function () { + zrLog('In IE8.0 VML mode painter not support method "' + method + '"'); + }; + } + + var notSupportedMethods = [ + 'getLayer', 'insertLayer', 'eachLayer', 'eachBuildinLayer', 'eachOtherLayer', 'getLayers', + 'modLayer', 'delLayer', 'clearLayer', 'toDataURL', 'pathToImage' + ]; + + for (var i = 0; i < notSupportedMethods.length; i++) { + var name = notSupportedMethods[i]; + VMLPainter.prototype[name] = createMethodNotSupport(name); + } + + module.exports = VMLPainter; + + +/***/ } +/******/ ]) }); -/** - * @file Axis operator - */ -define('echarts/component/dataZoom/AxisProxy',['require','zrender/core/util','../../util/number'],function(require) { - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../../util/number'); - var each = zrUtil.each; - var asc = numberUtil.asc; - - /** - * Operate single axis. - * One axis can only operated by one axis operator. - * Different dataZoomModels may be defined to operate the same axis. - * (i.e. 'inside' data zoom and 'slider' data zoom components) - * So dataZoomModels share one axisProxy in that case. - * - * @class - */ - var AxisProxy = function (dimName, axisIndex, dataZoomModel, ecModel) { - - /** - * @private - * @type {string} - */ - this._dimName = dimName; - - /** - * @private - */ - this._axisIndex = axisIndex; - - /** - * {scale, min, max} - * @private - * @type {Object} - */ - this._backup; - - /** - * @private - * @type {Array.} - */ - this._valueWindow; - - /** - * @private - * @type {Array.} - */ - this._percentWindow; - - /** - * @private - * @type {Array.} - */ - this._dataExtent; - - /** - * @readOnly - * @type {module: echarts/model/Global} - */ - this.ecModel = ecModel; - - /** - * @private - * @type {module: echarts/component/dataZoom/DataZoomModel} - */ - this._dataZoomModel = dataZoomModel; - }; - - AxisProxy.prototype = { - - constructor: AxisProxy, - - /** - * Whether the axisProxy is hosted by dataZoomModel. - * - * @public - * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel - * @return {boolean} - */ - hostedBy: function (dataZoomModel) { - return this._dataZoomModel === dataZoomModel; - }, - - /** - * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel - * @param {Object} option - */ - backup: function (dataZoomModel, option) { - if (dataZoomModel === this._dataZoomModel) { - var axisModel = this.getAxisModel(); - this._backup = { - scale: axisModel.get('scale', true), - min: axisModel.get('min', true), - max: axisModel.get('max', true) - }; - } - }, - - /** - * @return {Array.} - */ - getDataExtent: function () { - return this._dataExtent.slice(); - }, - - /** - * @return {Array.} - */ - getDataValueWindow: function () { - return this._valueWindow.slice(); - }, - - /** - * @return {Array.} - */ - getDataPercentWindow: function () { - return this._percentWindow.slice(); - }, - - /** - * @public - * @param {number} axisIndex - * @return {Array} seriesModels - */ - getTargetSeriesModels: function () { - var seriesModels = []; - - this.ecModel.eachSeries(function (seriesModel) { - if (this._axisIndex === seriesModel.get(this._dimName + 'AxisIndex')) { - seriesModels.push(seriesModel); - } - }, this); - - return seriesModels; - }, - - getAxisModel: function () { - return this.ecModel.getComponent(this._dimName + 'Axis', this._axisIndex); - }, - - getOtherAxisModel: function () { - var axisDim = this._dimName; - var ecModel = this.ecModel; - var axisModel = this.getAxisModel(); - var isCartesian = axisDim === 'x' || axisDim === 'y'; - var otherAxisDim; - var coordSysIndexName; - if (isCartesian) { - coordSysIndexName = 'gridIndex'; - otherAxisDim = axisDim === 'x' ? 'y' : 'x'; - } - else { - coordSysIndexName = 'polarIndex'; - otherAxisDim = axisDim === 'angle' ? 'radius' : 'angle'; - } - var foundOtherAxisModel; - ecModel.eachComponent(otherAxisDim + 'Axis', function (otherAxisModel) { - if ((otherAxisModel.get(coordSysIndexName) || 0) - === (axisModel.get(coordSysIndexName) || 0)) { - foundOtherAxisModel = otherAxisModel; - } - }); - return foundOtherAxisModel; - }, - - /** - * Notice: reset should not be called before series.restoreData() called, - * so it is recommanded to be called in "process stage" but not "model init - * stage". - * - * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel - */ - reset: function (dataZoomModel) { - if (dataZoomModel !== this._dataZoomModel) { - return; - } - - // Culculate data window and data extent, and record them. - var dataExtent = this._dataExtent = calculateDataExtent( - this._dimName, this.getTargetSeriesModels() - ); - var dataWindow = calculateDataWindow( - dataZoomModel.option, dataExtent, this - ); - this._valueWindow = dataWindow.valueWindow; - this._percentWindow = dataWindow.percentWindow; - - // Update axis setting then. - setAxisModel(this); - }, - - /** - * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel - */ - restore: function (dataZoomModel) { - if (dataZoomModel !== this._dataZoomModel) { - return; - } - - this._valueWindow = this._percentWindow = null; - setAxisModel(this, true); - }, - - /** - * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel - */ - filterData: function (dataZoomModel) { - if (dataZoomModel !== this._dataZoomModel) { - return; - } - - var axisDim = this._dimName; - var seriesModels = this.getTargetSeriesModels(); - var filterMode = dataZoomModel.get('filterMode'); - var valueWindow = this._valueWindow; - - // FIXME - // Toolbox may has dataZoom injected. And if there are stacked bar chart - // with NaN data. NaN will be filtered and stack will be wrong. - // So we need to force the mode to be set empty - var otherAxisModel = this.getOtherAxisModel(); - if (dataZoomModel.get('$fromToolbox') - && otherAxisModel && otherAxisModel.get('type') === 'category') { - filterMode = 'empty'; - } - // Process series data - each(seriesModels, function (seriesModel) { - var seriesData = seriesModel.getData(); - if (!seriesData) { - return; - } - - each(seriesModel.coordDimToDataDim(axisDim), function (dim) { - if (filterMode === 'empty') { - seriesModel.setData( - seriesData.map(dim, function (value) { - return !isInWindow(value) ? NaN : value; - }) - ); - } - else { - seriesData.filterSelf(dim, isInWindow); - } - }); - }); - - function isInWindow(value) { - return value >= valueWindow[0] && value <= valueWindow[1]; - } - } - }; - - function calculateDataExtent(axisDim, seriesModels) { - var dataExtent = [Infinity, -Infinity]; - - each(seriesModels, function (seriesModel) { - var seriesData = seriesModel.getData(); - if (seriesData) { - each(seriesModel.coordDimToDataDim(axisDim), function (dim) { - var seriesExtent = seriesData.getDataExtent(dim); - seriesExtent[0] < dataExtent[0] && (dataExtent[0] = seriesExtent[0]); - seriesExtent[1] > dataExtent[1] && (dataExtent[1] = seriesExtent[1]); - }); - } - }, this); - - return dataExtent; - } - - function calculateDataWindow(opt, dataExtent, axisProxy) { - var axisModel = axisProxy.getAxisModel(); - var scale = axisModel.axis.scale; - var percentExtent = [0, 100]; - var percentWindow = [ - opt.start, - opt.end - ]; - var valueWindow = []; - - // In percent range is used and axis min/max/scale is set, - // window should be based on min/max/0, but should not be - // based on the extent of filtered data. - var backup = axisProxy._backup; - dataExtent = dataExtent.slice(); - fixExtendByAxis(dataExtent, backup, scale); - - each(['startValue', 'endValue'], function (prop) { - valueWindow.push( - opt[prop] != null - ? scale.parse(opt[prop]) - : null - ); - }); - - // Normalize bound. - each([0, 1], function (idx) { - var boundValue = valueWindow[idx]; - var boundPercent = percentWindow[idx]; - - // start/end has higher priority over startValue/endValue, - // because start/end can be consistent among different type - // of axis but startValue/endValue not. - - if (boundPercent != null || boundValue == null) { - if (boundPercent == null) { - boundPercent = percentExtent[idx]; - } - // Use scale.parse to math round for category or time axis. - boundValue = scale.parse(numberUtil.linearMap( - boundPercent, percentExtent, dataExtent, true - )); - } - else { // boundPercent == null && boundValue != null - boundPercent = numberUtil.linearMap( - boundValue, dataExtent, percentExtent, true - ); - } - valueWindow[idx] = boundValue; - percentWindow[idx] = boundPercent; - }); - - return { - valueWindow: asc(valueWindow), - percentWindow: asc(percentWindow) - }; - } - - function fixExtendByAxis(dataExtent, backup, scale) { - each(['min', 'max'], function (minMax, index) { - var axisMax = backup[minMax]; - // Consider 'dataMin', 'dataMax' - if (axisMax != null && (axisMax + '').toLowerCase() !== 'data' + minMax) { - dataExtent[index] = scale.parse(axisMax); - } - }); - - if (!backup.scale) { - dataExtent[0] > 0 && (dataExtent[0] = 0); - dataExtent[1] < 0 && (dataExtent[1] = 0); - } - - return dataExtent; - } - - function setAxisModel(axisProxy, isRestore) { - var axisModel = axisProxy.getAxisModel(); - - var backup = axisProxy._backup; - var percentWindow = axisProxy._percentWindow; - var valueWindow = axisProxy._valueWindow; - - if (!backup) { - return; - } - - var isFull = isRestore || (percentWindow[0] === 0 && percentWindow[1] === 100); - // [0, 500]: arbitrary value, guess axis extent. - var precision = !isRestore && numberUtil.getPixelPrecision(valueWindow, [0, 500]); - // toFixed() digits argument must be between 0 and 20 - var invalidPrecision = !isRestore && !(precision < 20 && precision >= 0); - - axisModel.setNeedsCrossZero && axisModel.setNeedsCrossZero( - (isRestore || isFull) ? !backup.scale : false - ); - axisModel.setMin && axisModel.setMin( - (isRestore || isFull || invalidPrecision) - ? backup.min - : +valueWindow[0].toFixed(precision) - ); - axisModel.setMax && axisModel.setMax( - (isRestore || isFull || invalidPrecision) - ? backup.max - : +valueWindow[1].toFixed(precision) - ); - } - - return AxisProxy; - -}); -/** - * @file Data zoom model - */ -define('echarts/component/dataZoom/DataZoomModel',['require','zrender/core/util','zrender/core/env','../../echarts','../../util/model','./AxisProxy','../../util/layout'],function(require) { - - var zrUtil = require('zrender/core/util'); - var env = require('zrender/core/env'); - var echarts = require('../../echarts'); - var modelUtil = require('../../util/model'); - var AxisProxy = require('./AxisProxy'); - var layout = require('../../util/layout'); - var each = zrUtil.each; - var eachAxisDim = modelUtil.eachAxisDim; - - var DataZoomModel = echarts.extendComponentModel({ - - type: 'dataZoom', - - dependencies: [ - 'xAxis', 'yAxis', 'zAxis', 'radiusAxis', 'angleAxis', 'series' - ], - - /** - * @protected - */ - defaultOption: { - zlevel: 0, - z: 4, // Higher than normal component (z: 2). - orient: null, // Default auto by axisIndex. Possible value: 'horizontal', 'vertical'. - xAxisIndex: null, // Default all horizontal category axis. - yAxisIndex: null, // Default all vertical category axis. - angleAxisIndex: null, - radiusAxisIndex: null, - filterMode: 'filter', // Possible values: 'filter' or 'empty'. - // 'filter': data items which are out of window will be removed. - // This option is applicable when filtering outliers. - // 'empty': data items which are out of window will be set to empty. - // This option is applicable when user should not neglect - // that there are some data items out of window. - // Taking line chart as an example, line will be broken in - // the filtered points when filterModel is set to 'empty', but - // be connected when set to 'filter'. - - throttle: 100, // Dispatch action by the fixed rate, avoid frequency. - // default 100. Do not throttle when use null/undefined. - start: 0, // Start percent. 0 ~ 100 - end: 100, // End percent. 0 ~ 100 - startValue: null, // Start value. If startValue specified, start is ignored. - endValue: null // End value. If endValue specified, end is ignored. - }, - - /** - * @override - */ - init: function (option, parentModel, ecModel) { - - /** - * key like x_0, y_1 - * @private - * @type {Object} - */ - this._dataIntervalByAxis = {}; - - /** - * @private - */ - this._dataInfo = {}; - - /** - * key like x_0, y_1 - * @private - */ - this._axisProxies = {}; - - /** - * @readOnly - */ - this.textStyleModel; - - var rawOption = retrieveRaw(option); - - this.mergeDefaultAndTheme(option, ecModel); - - this.doInit(rawOption); - }, - - /** - * @override - */ - mergeOption: function (newOption) { - var rawOption = retrieveRaw(newOption); - - //FIX #2591 - zrUtil.merge(this.option, newOption, true); - - this.doInit(rawOption); - }, - - /** - * @protected - */ - doInit: function (rawOption) { - var thisOption = this.option; - - // Disable realtime view update if canvas is not supported. - if (!env.canvasSupported) { - thisOption.realtime = false; - } - - processRangeProp('start', 'startValue', rawOption, thisOption); - processRangeProp('end', 'endValue', rawOption, thisOption); - - this.textStyleModel = this.getModel('textStyle'); - - this._resetTarget(); - - this._giveAxisProxies(); - - this._backup(); - }, - - /** - * @protected - */ - restoreData: function () { - DataZoomModel.superApply(this, 'restoreData', arguments); - - // If use dataZoom while dynamic setOption, axis setting should - // be restored before new option setting, otherwise axis status - // that is set by dataZoom will be recorded in _backup calling. - this.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) { - dataZoomModel.getAxisProxy(dimNames.name, axisIndex).restore(dataZoomModel); - }); - }, - - /** - * @private - */ - _giveAxisProxies: function () { - var axisProxies = this._axisProxies; - - this.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel, ecModel) { - var axisModel = this.dependentModels[dimNames.axis][axisIndex]; - - // If exists, share axisProxy with other dataZoomModels. - var axisProxy = axisModel.__dzAxisProxy || ( - // Use the first dataZoomModel as the main model of axisProxy. - axisModel.__dzAxisProxy = new AxisProxy( - dimNames.name, axisIndex, this, ecModel - ) - ); - // FIXME - // dispose __dzAxisProxy - - axisProxies[dimNames.name + '_' + axisIndex] = axisProxy; - }, this); - }, - - /** - * @private - */ - _resetTarget: function () { - var thisOption = this.option; - - var autoMode = this._judgeAutoMode(); - - eachAxisDim(function (dimNames) { - var axisIndexName = dimNames.axisIndex; - thisOption[axisIndexName] = modelUtil.normalizeToArray( - thisOption[axisIndexName] - ); - }, this); - - if (autoMode === 'axisIndex') { - this._autoSetAxisIndex(); - } - else if (autoMode === 'orient') { - this._autoSetOrient(); - } - }, - - /** - * @private - */ - _judgeAutoMode: function () { - // Auto set only works for setOption at the first time. - // The following is user's reponsibility. So using merged - // option is OK. - var thisOption = this.option; - - var hasIndexSpecified = false; - eachAxisDim(function (dimNames) { - // When user set axisIndex as a empty array, we think that user specify axisIndex - // but do not want use auto mode. Because empty array may be encountered when - // some error occured. - if (thisOption[dimNames.axisIndex] != null) { - hasIndexSpecified = true; - } - }, this); - - var orient = thisOption.orient; - - if (orient == null && hasIndexSpecified) { - return 'orient'; - } - else if (!hasIndexSpecified) { - if (orient == null) { - thisOption.orient = 'horizontal'; - } - return 'axisIndex'; - } - }, - - /** - * @private - */ - _autoSetAxisIndex: function () { - var autoAxisIndex = true; - var orient = this.get('orient', true); - var thisOption = this.option; - - if (autoAxisIndex) { - // Find axis that parallel to dataZoom as default. - var dimNames = orient === 'vertical' - ? {dim: 'y', axisIndex: 'yAxisIndex', axis: 'yAxis'} - : {dim: 'x', axisIndex: 'xAxisIndex', axis: 'xAxis'}; - - if (this.dependentModels[dimNames.axis].length) { - thisOption[dimNames.axisIndex] = [0]; - autoAxisIndex = false; - } - } - - if (autoAxisIndex) { - // Find the first category axis as default. (consider polar) - eachAxisDim(function (dimNames) { - if (!autoAxisIndex) { - return; - } - var axisIndices = []; - var axisModels = this.dependentModels[dimNames.axis]; - if (axisModels.length && !axisIndices.length) { - for (var i = 0, len = axisModels.length; i < len; i++) { - if (axisModels[i].get('type') === 'category') { - axisIndices.push(i); - } - } - } - thisOption[dimNames.axisIndex] = axisIndices; - if (axisIndices.length) { - autoAxisIndex = false; - } - }, this); - } - - if (autoAxisIndex) { - // FIXME - // 这里是兼容ec2的写法(没指定xAxisIndex和yAxisIndex时把scatter和双数值轴折柱纳入dataZoom控制), - // 但是实际是否需要Grid.js#getScaleByOption来判断(考虑time,log等axis type)? - - // If both dataZoom.xAxisIndex and dataZoom.yAxisIndex is not specified, - // dataZoom component auto adopts series that reference to - // both xAxis and yAxis which type is 'value'. - this.ecModel.eachSeries(function (seriesModel) { - if (this._isSeriesHasAllAxesTypeOf(seriesModel, 'value')) { - eachAxisDim(function (dimNames) { - var axisIndices = thisOption[dimNames.axisIndex]; - var axisIndex = seriesModel.get(dimNames.axisIndex); - if (zrUtil.indexOf(axisIndices, axisIndex) < 0) { - axisIndices.push(axisIndex); - } - }); - } - }, this); - } - }, - - /** - * @private - */ - _autoSetOrient: function () { - var dim; - - // Find the first axis - this.eachTargetAxis(function (dimNames) { - !dim && (dim = dimNames.name); - }, this); - - this.option.orient = dim === 'y' ? 'vertical' : 'horizontal'; - }, - - /** - * @private - */ - _isSeriesHasAllAxesTypeOf: function (seriesModel, axisType) { - // FIXME - // 需要series的xAxisIndex和yAxisIndex都首先自动设置上。 - // 例如series.type === scatter时。 - - var is = true; - eachAxisDim(function (dimNames) { - var seriesAxisIndex = seriesModel.get(dimNames.axisIndex); - var axisModel = this.dependentModels[dimNames.axis][seriesAxisIndex]; - - if (!axisModel || axisModel.get('type') !== axisType) { - is = false; - } - }, this); - return is; - }, - - /** - * @private - */ - _backup: function () { - this.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel, ecModel) { - this.getAxisProxy(dimNames.name, axisIndex).backup(dataZoomModel); - }, this); - }, - - /** - * @public - */ - getFirstTargetAxisModel: function () { - var firstAxisModel; - eachAxisDim(function (dimNames) { - if (firstAxisModel == null) { - var indices = this.get(dimNames.axisIndex); - if (indices.length) { - firstAxisModel = this.dependentModels[dimNames.axis][indices[0]]; - } - } - }, this); - - return firstAxisModel; - }, - - /** - * @public - * @param {Function} callback param: axisModel, dimNames, axisIndex, dataZoomModel, ecModel - */ - eachTargetAxis: function (callback, context) { - var ecModel = this.ecModel; - eachAxisDim(function (dimNames) { - each( - this.get(dimNames.axisIndex), - function (axisIndex) { - callback.call(context, dimNames, axisIndex, this, ecModel); - }, - this - ); - }, this); - }, - - getAxisProxy: function (dimName, axisIndex) { - return this._axisProxies[dimName + '_' + axisIndex]; - }, - - /** - * If not specified, set to undefined. - * - * @public - * @param {Object} opt - * @param {number} [opt.start] - * @param {number} [opt.end] - * @param {number} [opt.startValue] - * @param {number} [opt.endValue] - */ - setRawRange: function (opt) { - each(['start', 'end', 'startValue', 'endValue'], function (name) { - // If any of those prop is null/undefined, we should alos set - // them, because only one pair between start/end and - // startValue/endValue can work. - this.option[name] = opt[name]; - }, this); - }, - - /** - * @public - */ - setLayoutParams: function (params) { - layout.copyLayoutParams(this.option, params); - }, - - /** - * @public - * @return {Array.} [startPercent, endPercent] - */ - getPercentRange: function () { - var axisProxy = this.findRepresentativeAxisProxy(); - if (axisProxy) { - return axisProxy.getDataPercentWindow(); - } - }, - - /** - * @public - * For example, chart.getModel().getComponent('dataZoom').getValueRange('y', 0); - * - * @param {string} [axisDimName] - * @param {number} [axisIndex] - * @return {Array.} [startValue, endValue] - */ - getValueRange: function (axisDimName, axisIndex) { - if (axisDimName == null && axisIndex == null) { - var axisProxy = this.findRepresentativeAxisProxy(); - if (axisProxy) { - return axisProxy.getDataValueWindow(); - } - } - else { - return this.getAxisProxy(axisDimName, axisIndex).getDataValueWindow(); - } - }, - - /** - * @public - * @return {module:echarts/component/dataZoom/AxisProxy} - */ - findRepresentativeAxisProxy: function () { - // Find the first hosted axisProxy - var axisProxies = this._axisProxies; - for (var key in axisProxies) { - if (axisProxies.hasOwnProperty(key) && axisProxies[key].hostedBy(this)) { - return axisProxies[key]; - } - } - - // If no hosted axis find not hosted axisProxy. - // Consider this case: dataZoomModel1 and dataZoomModel2 control the same axis, - // and the option.start or option.end settings are different. The percentRange - // should follow axisProxy. - // (We encounter this problem in toolbox data zoom.) - for (var key in axisProxies) { - if (axisProxies.hasOwnProperty(key) && !axisProxies[key].hostedBy(this)) { - return axisProxies[key]; - } - } - } - - }); - - function retrieveRaw(option) { - var ret = {}; - each( - ['start', 'end', 'startValue', 'endValue'], - function (name) { - ret[name] = option[name]; - } - ); - return ret; - } - - function processRangeProp(percentProp, valueProp, rawOption, thisOption) { - // start/end has higher priority over startValue/endValue, - // but we should make chart.setOption({endValue: 1000}) effective, - // rather than chart.setOption({endValue: 1000, end: null}). - if (rawOption[valueProp] != null && rawOption[percentProp] == null) { - thisOption[percentProp] = null; - } - // Otherwise do nothing and use the merge result. - } - - return DataZoomModel; -}); - -define('echarts/component/dataZoom/DataZoomView',['require','../../view/Component'],function (require) { - - var ComponentView = require('../../view/Component'); - - return ComponentView.extend({ - - type: 'dataZoom', - - render: function (dataZoomModel, ecModel, api, payload) { - this.dataZoomModel = dataZoomModel; - this.ecModel = ecModel; - this.api = api; - }, - - /** - * Find the first target coordinate system. - * - * @protected - * @return {Object} { - * cartesians: [ - * {model: coord0, axisModels: [axis1, axis3], coordIndex: 1}, - * {model: coord1, axisModels: [axis0, axis2], coordIndex: 0}, - * ... - * ], // cartesians must not be null/undefined. - * polars: [ - * {model: coord0, axisModels: [axis4], coordIndex: 0}, - * ... - * ], // polars must not be null/undefined. - * axisModels: [axis0, axis1, axis2, axis3, axis4] - * // axisModels must not be null/undefined. - * } - */ - getTargetInfo: function () { - var dataZoomModel = this.dataZoomModel; - var ecModel = this.ecModel; - var cartesians = []; - var polars = []; - var axisModels = []; - - dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) { - var axisModel = ecModel.getComponent(dimNames.axis, axisIndex); - if (axisModel) { - axisModels.push(axisModel); - - var gridIndex = axisModel.get('gridIndex'); - var polarIndex = axisModel.get('polarIndex'); - - if (gridIndex != null) { - var coordModel = ecModel.getComponent('grid', gridIndex); - save(coordModel, axisModel, cartesians, gridIndex); - } - else if (polarIndex != null) { - var coordModel = ecModel.getComponent('polar', polarIndex); - save(coordModel, axisModel, polars, polarIndex); - } - } - }, this); - - function save(coordModel, axisModel, store, coordIndex) { - var item; - for (var i = 0; i < store.length; i++) { - if (store[i].model === coordModel) { - item = store[i]; - break; - } - } - if (!item) { - store.push(item = { - model: coordModel, axisModels: [], coordIndex: coordIndex - }); - } - item.axisModels.push(axisModel); - } - - return { - cartesians: cartesians, - polars: polars, - axisModels: axisModels - }; - } - - }); - -}); -/** - * @file Data zoom model - */ -define('echarts/component/dataZoom/SliderZoomModel',['require','./DataZoomModel','../../util/layout'],function(require) { - - var DataZoomModel = require('./DataZoomModel'); - var layout = require('../../util/layout'); - - var SliderZoomModel = DataZoomModel.extend({ - - type: 'dataZoom.slider', - - /** - * @readOnly - */ - inputPositionParams: null, - - /** - * @protected - */ - defaultOption: { - show: true, - - left: null, // Default align to grid rect. - right: null, // Default align to grid rect. - top: null, // Default align to grid rect. - bottom: null, // Default align to grid rect. - width: null, // Default align to grid rect. - height: null, // Default align to grid rect. - - backgroundColor: 'rgba(47,69,84,0)', // Background of slider zoom component. - dataBackgroundColor: '#ddd', // Background of data shadow. - fillerColor: 'rgba(47,69,84,0.25)', // Color of selected area. - handleColor: 'rgba(47,69,84,0.65)', // Color of handle. - handleSize: 10, - - labelPrecision: null, - labelFormatter: null, - showDetail: true, - showDataShadow: 'auto', // Default auto decision. - realtime: true, - zoomLock: false, // Whether disable zoom. - textStyle: { - color: '#333' - } - }, - - /** - * @override - */ - init: function (option) { - this.inputPositionParams = layout.getLayoutParams(option); - SliderZoomModel.superApply(this, 'init', arguments); - }, - - /** - * @override - */ - mergeOption: function (option) { - this.inputPositionParams = layout.getLayoutParams(option); - SliderZoomModel.superApply(this, 'mergeOption', arguments); - } - - }); - - return SliderZoomModel; - -}); -define('echarts/util/throttle',[],function () { - - var lib = {}; - - var ORIGIN_METHOD = '\0__throttleOriginMethod'; - var RATE = '\0__throttleRate'; - - /** - * 频率控制 返回函数连续调用时,fn 执行频率限定为每多少时间执行一次 - * 例如常见效果: - * notifyWhenChangesStop - * 频繁调用时,只保证最后一次执行 - * 配成:trailing:true;debounce:true 即可 - * notifyAtFixRate - * 频繁调用时,按规律心跳执行 - * 配成:trailing:true;debounce:false 即可 - * 注意: - * 根据model更新view的时候,可以使用throttle, - * 但是根据view更新model的时候,避免使用这种延迟更新的方式。 - * 因为这可能导致model和server同步出现问题。 - * - * @public - * @param {(Function|Array.)} fn 需要调用的函数 - * 如果fn为array,则表示可以对多个函数进行throttle。 - * 他们共享同一个timer。 - * @param {number} delay 延迟时间,单位毫秒 - * @param {bool} trailing 是否保证最后一次触发的执行 - * true:表示保证最后一次调用会触发执行。 - * 但任何调用后不可能立即执行,总会delay。 - * false:表示不保证最后一次调用会触发执行。 - * 但只要间隔大于delay,调用就会立即执行。 - * @param {bool} debounce 节流 - * true:表示:频繁调用(间隔小于delay)时,根本不执行 - * false:表示:频繁调用(间隔小于delay)时,按规律心跳执行 - * @return {(Function|Array.)} 实际调用函数。 - * 当输入的fn为array时,返回值也为array。 - * 每项是Function。 - */ - lib.throttle = function (fn, delay, trailing, debounce) { - - var currCall = (new Date()).getTime(); - var lastCall = 0; - var lastExec = 0; - var timer = null; - var diff; - var scope; - var args; - var isSingle = typeof fn === 'function'; - delay = delay || 0; - - if (isSingle) { - return createCallback(); - } - else { - var ret = []; - for (var i = 0; i < fn.length; i++) { - ret[i] = createCallback(i); - } - return ret; - } - - function createCallback(index) { - - function exec() { - lastExec = (new Date()).getTime(); - timer = null; - (isSingle ? fn : fn[index]).apply(scope, args || []); - } - - var cb = function () { - currCall = (new Date()).getTime(); - scope = this; - args = arguments; - diff = currCall - (debounce ? lastCall : lastExec) - delay; - - clearTimeout(timer); - - if (debounce) { - if (trailing) { - timer = setTimeout(exec, delay); - } - else if (diff >= 0) { - exec(); - } - } - else { - if (diff >= 0) { - exec(); - } - else if (trailing) { - timer = setTimeout(exec, -diff); - } - } - - lastCall = currCall; - }; - - /** - * Clear throttle. - * @public - */ - cb.clear = function () { - if (timer) { - clearTimeout(timer); - timer = null; - } - }; - - return cb; - } - }; - - /** - * 按一定频率执行,最后一次调用总归会执行 - * - * @public - */ - lib.fixRate = function (fn, delay) { - return delay != null - ? lib.throttle(fn, delay, true, false) - : fn; - }; - - /** - * 直到不频繁调用了才会执行,最后一次调用总归会执行 - * - * @public - */ - lib.debounce = function (fn, delay) { - return delay != null - ? lib.throttle(fn, delay, true, true) - : fn; - }; - - - /** - * Create throttle method or update throttle rate. - * - * @example - * ComponentView.prototype.render = function () { - * ... - * throttle.createOrUpdate( - * this, - * '_dispatchAction', - * this.model.get('throttle'), - * 'fixRate' - * ); - * }; - * ComponentView.prototype.remove = function () { - * throttle.clear(this, '_dispatchAction'); - * }; - * ComponentView.prototype.dispose = function () { - * throttle.clear(this, '_dispatchAction'); - * }; - * - * @public - * @param {Object} obj - * @param {string} fnAttr - * @param {number} rate - * @param {string} throttleType 'fixRate' or 'debounce' - */ - lib.createOrUpdate = function (obj, fnAttr, rate, throttleType) { - var fn = obj[fnAttr]; - - if (!fn || rate == null || !throttleType) { - return; - } - - var originFn = fn[ORIGIN_METHOD] || fn; - var lastRate = fn[RATE]; - - if (lastRate !== rate) { - fn = obj[fnAttr] = lib[throttleType](originFn, rate); - fn[ORIGIN_METHOD] = originFn; - fn[RATE] = rate; - } - }; - - /** - * Clear throttle. Example see throttle.createOrUpdate. - * - * @public - * @param {Object} obj - * @param {string} fnAttr - */ - lib.clear = function (obj, fnAttr) { - var fn = obj[fnAttr]; - if (fn && fn[ORIGIN_METHOD]) { - obj[fnAttr] = fn[ORIGIN_METHOD]; - } - }; - - return lib; -}); - -define('echarts/component/helper/sliderMove',['require'],function (require) { - - /** - * Calculate slider move result. - * - * @param {number} delta Move length. - * @param {Array.} handleEnds handleEnds[0] and be bigger then handleEnds[1]. - * handleEnds will be modified in this method. - * @param {Array.} extent handleEnds is restricted by extent. - * extent[0] should less or equals than extent[1]. - * @param {string} mode 'rigid': Math.abs(handleEnds[0] - handleEnds[1]) remain unchanged, - * 'cross' handleEnds[0] can be bigger then handleEnds[1], - * 'push' handleEnds[0] can not be bigger then handleEnds[1], - * when they touch, one push other. - * @param {number} handleIndex If mode is 'rigid', handleIndex is not required. - * @param {Array.} The input handleEnds. - */ - return function (delta, handleEnds, extent, mode, handleIndex) { - if (!delta) { - return handleEnds; - } - - if (mode === 'rigid') { - delta = getRealDelta(delta, handleEnds, extent); - handleEnds[0] += delta; - handleEnds[1] += delta; - } - else { - delta = getRealDelta(delta, handleEnds[handleIndex], extent); - handleEnds[handleIndex] += delta; - - if (mode === 'push' && handleEnds[0] > handleEnds[1]) { - handleEnds[1 - handleIndex] = handleEnds[handleIndex]; - } - } - - return handleEnds; - - function getRealDelta(delta, handleEnds, extent) { - var handleMinMax = !handleEnds.length - ? [handleEnds, handleEnds] - : handleEnds.slice(); - handleEnds[0] > handleEnds[1] && handleMinMax.reverse(); - - if (delta < 0 && handleMinMax[0] + delta < extent[0]) { - delta = extent[0] - handleMinMax[0]; - } - if (delta > 0 && handleMinMax[1] + delta > extent[1]) { - delta = extent[1] - handleMinMax[1]; - } - return delta; - } - }; -}); -define('echarts/component/dataZoom/SliderZoomView',['require','zrender/core/util','../../util/graphic','../../util/throttle','./DataZoomView','../../util/number','../../util/layout','../helper/sliderMove'],function (require) { - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var throttle = require('../../util/throttle'); - var DataZoomView = require('./DataZoomView'); - var Rect = graphic.Rect; - var numberUtil = require('../../util/number'); - var linearMap = numberUtil.linearMap; - var layout = require('../../util/layout'); - var sliderMove = require('../helper/sliderMove'); - var asc = numberUtil.asc; - var bind = zrUtil.bind; - var mathRound = Math.round; - var mathMax = Math.max; - var each = zrUtil.each; - - // Constants - var DEFAULT_LOCATION_EDGE_GAP = 7; - var DEFAULT_FRAME_BORDER_WIDTH = 1; - var DEFAULT_FILLER_SIZE = 30; - var HORIZONTAL = 'horizontal'; - var VERTICAL = 'vertical'; - var LABEL_GAP = 5; - var SHOW_DATA_SHADOW_SERIES_TYPE = ['line', 'bar', 'candlestick', 'scatter']; - - var SliderZoomView = DataZoomView.extend({ - - type: 'dataZoom.slider', - - init: function (ecModel, api) { - - /** - * @private - * @type {Object} - */ - this._displayables = {}; - - /** - * @private - * @type {string} - */ - this._orient; - - /** - * [0, 100] - * @private - */ - this._range; - - /** - * [coord of the first handle, coord of the second handle] - * @private - */ - this._handleEnds; - - /** - * [length, thick] - * @private - * @type {Array.} - */ - this._size; - - /** - * @private - * @type {number} - */ - this._halfHandleSize; - - /** - * @private - */ - this._location; - - /** - * @private - */ - this._dragging; - - /** - * @private - */ - this._dataShadowInfo; - - this.api = api; - }, - - /** - * @override - */ - render: function (dataZoomModel, ecModel, api, payload) { - SliderZoomView.superApply(this, 'render', arguments); - - throttle.createOrUpdate( - this, - '_dispatchZoomAction', - this.dataZoomModel.get('throttle'), - 'fixRate' - ); - - this._orient = dataZoomModel.get('orient'); - this._halfHandleSize = mathRound(dataZoomModel.get('handleSize') / 2); - - if (this.dataZoomModel.get('show') === false) { - this.group.removeAll(); - return; - } - - // Notice: this._resetInterval() should not be executed when payload.type - // is 'dataZoom', origin this._range should be maintained, otherwise 'pan' - // or 'zoom' info will be missed because of 'throttle' of this.dispatchAction, - if (!payload || payload.type !== 'dataZoom' || payload.from !== this.uid) { - this._buildView(); - } - - this._updateView(); - }, - - /** - * @override - */ - remove: function () { - SliderZoomView.superApply(this, 'remove', arguments); - throttle.clear(this, '_dispatchZoomAction'); - }, - - /** - * @override - */ - dispose: function () { - SliderZoomView.superApply(this, 'dispose', arguments); - throttle.clear(this, '_dispatchZoomAction'); - }, - - _buildView: function () { - var thisGroup = this.group; - - thisGroup.removeAll(); - - this._resetLocation(); - this._resetInterval(); - - var barGroup = this._displayables.barGroup = new graphic.Group(); - - this._renderBackground(); - this._renderDataShadow(); - this._renderHandle(); - - thisGroup.add(barGroup); - - this._positionGroup(); - }, - - /** - * @private - */ - _resetLocation: function () { - var dataZoomModel = this.dataZoomModel; - var api = this.api; - - // If some of x/y/width/height are not specified, - // auto-adapt according to target grid. - var coordRect = this._findCoordRect(); - var ecSize = {width: api.getWidth(), height: api.getHeight()}; - - // Default align by coordinate system rect. - var positionInfo = this._orient === HORIZONTAL - ? { - left: coordRect.x, - top: (ecSize.height - DEFAULT_FILLER_SIZE - DEFAULT_LOCATION_EDGE_GAP), - width: coordRect.width, - height: DEFAULT_FILLER_SIZE - } - : { // vertical - right: DEFAULT_LOCATION_EDGE_GAP, - top: coordRect.y, - width: DEFAULT_FILLER_SIZE, - height: coordRect.height - }; - - layout.mergeLayoutParam(positionInfo, dataZoomModel.inputPositionParams); - - // Write back to option for chart.getOption(). (and may then - // chart.setOption() again, where current location value is needed); - dataZoomModel.setLayoutParams(positionInfo); - - var layoutRect = layout.getLayoutRect( - positionInfo, - ecSize, - dataZoomModel.padding - ); - - this._location = {x: layoutRect.x, y: layoutRect.y}; - this._size = [layoutRect.width, layoutRect.height]; - this._orient === VERTICAL && this._size.reverse(); - }, - - /** - * @private - */ - _positionGroup: function () { - var thisGroup = this.group; - var location = this._location; - var orient = this._orient; - - // Just use the first axis to determine mapping. - var targetAxisModel = this.dataZoomModel.getFirstTargetAxisModel(); - var inverse = targetAxisModel && targetAxisModel.get('inverse'); - - var barGroup = this._displayables.barGroup; - var otherAxisInverse = (this._dataShadowInfo || {}).otherAxisInverse; - - // Transform barGroup. - barGroup.attr( - (orient === HORIZONTAL && !inverse) - ? {scale: otherAxisInverse ? [1, 1] : [1, -1]} - : (orient === HORIZONTAL && inverse) - ? {scale: otherAxisInverse ? [-1, 1] : [-1, -1]} - : (orient === VERTICAL && !inverse) - ? {scale: otherAxisInverse ? [1, -1] : [1, 1], rotation: Math.PI / 2} - // Dont use Math.PI, considering shadow direction. - : {scale: otherAxisInverse ? [-1, -1] : [-1, 1], rotation: Math.PI / 2} - ); - - // Position barGroup - var rect = thisGroup.getBoundingRect([barGroup]); - thisGroup.position[0] = location.x - rect.x; - thisGroup.position[1] = location.y - rect.y; - }, - - /** - * @private - */ - _getViewExtent: function () { - // View total length. - var halfHandleSize = this._halfHandleSize; - var totalLength = mathMax(this._size[0], halfHandleSize * 4); - var extent = [halfHandleSize, totalLength - halfHandleSize]; - - return extent; - }, - - _renderBackground : function () { - var dataZoomModel = this.dataZoomModel; - var size = this._size; - - this._displayables.barGroup.add(new Rect({ - silent: true, - shape: { - x: 0, y: 0, width: size[0], height: size[1] - }, - style: { - fill: dataZoomModel.get('backgroundColor') - } - })); - }, - - _renderDataShadow: function () { - var info = this._dataShadowInfo = this._prepareDataShadowInfo(); - - if (!info) { - return; - } - - var size = this._size; - var seriesModel = info.series; - var data = seriesModel.getRawData(); - var otherDim = seriesModel.getShadowDim - ? seriesModel.getShadowDim() // @see candlestick - : info.otherDim; - - var otherDataExtent = data.getDataExtent(otherDim); - // Nice extent. - var otherOffset = (otherDataExtent[1] - otherDataExtent[0]) * 0.3; - otherDataExtent = [ - otherDataExtent[0] - otherOffset, - otherDataExtent[1] + otherOffset - ]; - var otherShadowExtent = [0, size[1]]; - - var thisShadowExtent = [0, size[0]]; - - var points = [[size[0], 0], [0, 0]]; - var step = thisShadowExtent[1] / (data.count() - 1); - var thisCoord = 0; - - // Optimize for large data shadow - var stride = Math.round(data.count() / size[0]); - data.each([otherDim], function (value, index) { - if (stride > 0 && (index % stride)) { - thisCoord += step; - return; - } - // FIXME - // 应该使用统计的空判断?还是在list里进行空判断? - var otherCoord = (value == null || isNaN(value) || value === '') - ? null - : linearMap(value, otherDataExtent, otherShadowExtent, true); - otherCoord != null && points.push([thisCoord, otherCoord]); - - thisCoord += step; - }); - - this._displayables.barGroup.add(new graphic.Polyline({ - shape: {points: points}, - style: {fill: this.dataZoomModel.get('dataBackgroundColor'), lineWidth: 0}, - silent: true, - z2: -20 - })); - }, - - _prepareDataShadowInfo: function () { - var dataZoomModel = this.dataZoomModel; - var showDataShadow = dataZoomModel.get('showDataShadow'); - - if (showDataShadow === false) { - return; - } - - // Find a representative series. - var result; - var ecModel = this.ecModel; - - dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) { - var seriesModels = dataZoomModel - .getAxisProxy(dimNames.name, axisIndex) - .getTargetSeriesModels(); - - zrUtil.each(seriesModels, function (seriesModel) { - if (result) { - return; - } - - if (showDataShadow !== true && zrUtil.indexOf( - SHOW_DATA_SHADOW_SERIES_TYPE, seriesModel.get('type') - ) < 0 - ) { - return; - } - - var otherDim = getOtherDim(dimNames.name); - - var thisAxis = ecModel.getComponent(dimNames.axis, axisIndex).axis; - - result = { - thisAxis: thisAxis, - series: seriesModel, - thisDim: dimNames.name, - otherDim: otherDim, - otherAxisInverse: seriesModel - .coordinateSystem.getOtherAxis(thisAxis).inverse - }; - - }, this); - - }, this); - - return result; - }, - - _renderHandle: function () { - var displaybles = this._displayables; - var handles = displaybles.handles = []; - var handleLabels = displaybles.handleLabels = []; - var barGroup = this._displayables.barGroup; - var size = this._size; - - barGroup.add(displaybles.filler = new Rect({ - draggable: true, - cursor: 'move', - drift: bind(this._onDragMove, this, 'all'), - ondragend: bind(this._onDragEnd, this), - onmouseover: bind(this._showDataInfo, this, true), - onmouseout: bind(this._showDataInfo, this, false), - style: { - fill: this.dataZoomModel.get('fillerColor'), - // text: ':::', - textPosition : 'inside' - } - })); - - // Frame border. - barGroup.add(new Rect(graphic.subPixelOptimizeRect({ - silent: true, - shape: { - x: 0, - y: 0, - width: size[0], - height: size[1] - }, - style: { - stroke: this.dataZoomModel.get('dataBackgroundColor'), - lineWidth: DEFAULT_FRAME_BORDER_WIDTH, - fill: 'rgba(0,0,0,0)' - } - }))); - - each([0, 1], function (handleIndex) { - - barGroup.add(handles[handleIndex] = new Rect({ - style: { - fill: this.dataZoomModel.get('handleColor') - }, - cursor: 'move', - draggable: true, - drift: bind(this._onDragMove, this, handleIndex), - ondragend: bind(this._onDragEnd, this), - onmouseover: bind(this._showDataInfo, this, true), - onmouseout: bind(this._showDataInfo, this, false) - })); - - var textStyleModel = this.dataZoomModel.textStyleModel; - - this.group.add( - handleLabels[handleIndex] = new graphic.Text({ - silent: true, - invisible: true, - style: { - x: 0, y: 0, text: '', - textBaseline: 'middle', - textAlign: 'center', - fill: textStyleModel.getTextColor(), - textFont: textStyleModel.getFont() - } - })); - - }, this); - }, - - /** - * @private - */ - _resetInterval: function () { - var range = this._range = this.dataZoomModel.getPercentRange(); - var viewExtent = this._getViewExtent(); - - this._handleEnds = [ - linearMap(range[0], [0, 100], viewExtent, true), - linearMap(range[1], [0, 100], viewExtent, true) - ]; - }, - - /** - * @private - * @param {(number|string)} handleIndex 0 or 1 or 'all' - * @param {number} dx - * @param {number} dy - */ - _updateInterval: function (handleIndex, delta) { - var handleEnds = this._handleEnds; - var viewExtend = this._getViewExtent(); - - sliderMove( - delta, - handleEnds, - viewExtend, - (handleIndex === 'all' || this.dataZoomModel.get('zoomLock')) - ? 'rigid' : 'cross', - handleIndex - ); - - this._range = asc([ - linearMap(handleEnds[0], viewExtend, [0, 100], true), - linearMap(handleEnds[1], viewExtend, [0, 100], true) - ]); - }, - - /** - * @private - */ - _updateView: function () { - var displaybles = this._displayables; - var handleEnds = this._handleEnds; - var handleInterval = asc(handleEnds.slice()); - var size = this._size; - var halfHandleSize = this._halfHandleSize; - - each([0, 1], function (handleIndex) { - - // Handles - var handle = displaybles.handles[handleIndex]; - handle.setShape({ - x: handleEnds[handleIndex] - halfHandleSize, - y: -1, - width: halfHandleSize * 2, - height: size[1] + 2, - r: 1 - }); - - }, this); - - // Filler - displaybles.filler.setShape({ - x: handleInterval[0], - y: 0, - width: handleInterval[1] - handleInterval[0], - height: this._size[1] - }); - - this._updateDataInfo(); - }, - - /** - * @private - */ - _updateDataInfo: function () { - var dataZoomModel = this.dataZoomModel; - var displaybles = this._displayables; - var handleLabels = displaybles.handleLabels; - var orient = this._orient; - var labelTexts = ['', '']; - - // FIXME - // date型,支持formatter,autoformatter(ec2 date.getAutoFormatter) - if (dataZoomModel.get('showDetail')) { - var dataInterval; - var axis; - dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) { - // Using dataInterval of the first axis. - if (!dataInterval) { - dataInterval = dataZoomModel - .getAxisProxy(dimNames.name, axisIndex) - .getDataValueWindow(); - axis = this.ecModel.getComponent(dimNames.axis, axisIndex).axis; - } - }, this); - - if (dataInterval) { - labelTexts = [ - this._formatLabel(dataInterval[0], axis), - this._formatLabel(dataInterval[1], axis) - ]; - } - } - - var orderedHandleEnds = asc(this._handleEnds.slice()); - - setLabel.call(this, 0); - setLabel.call(this, 1); - - function setLabel(handleIndex) { - // Label - // Text should not transform by barGroup. - var barTransform = graphic.getTransform( - displaybles.handles[handleIndex], this.group - ); - var direction = graphic.transformDirection( - handleIndex === 0 ? 'right' : 'left', barTransform - ); - var offset = this._halfHandleSize + LABEL_GAP; - var textPoint = graphic.applyTransform( - [ - orderedHandleEnds[handleIndex] + (handleIndex === 0 ? -offset : offset), - this._size[1] / 2 - ], - barTransform - ); - handleLabels[handleIndex].setStyle({ - x: textPoint[0], - y: textPoint[1], - textBaseline: orient === HORIZONTAL ? 'middle' : direction, - textAlign: orient === HORIZONTAL ? direction : 'center', - text: labelTexts[handleIndex] - }); - } - }, - - /** - * @private - */ - _formatLabel: function (value, axis) { - var dataZoomModel = this.dataZoomModel; - var labelFormatter = dataZoomModel.get('labelFormatter'); - if (zrUtil.isFunction(labelFormatter)) { - return labelFormatter(value); - } - - var labelPrecision = dataZoomModel.get('labelPrecision'); - if (labelPrecision == null || labelPrecision === 'auto') { - labelPrecision = axis.getPixelPrecision(); - } - - value = (value == null && isNaN(value)) - ? '' - // FIXME Glue code - : (axis.type === 'category' || axis.type === 'time') - ? axis.scale.getLabel(Math.round(value)) - // param of toFixed should less then 20. - : value.toFixed(Math.min(labelPrecision, 20)); - - if (zrUtil.isString(labelFormatter)) { - value = labelFormatter.replace('{value}', value); - } - - return value; - }, - - /** - * @private - * @param {boolean} showOrHide true: show, false: hide - */ - _showDataInfo: function (showOrHide) { - // Always show when drgging. - showOrHide = this._dragging || showOrHide; - - var handleLabels = this._displayables.handleLabels; - handleLabels[0].attr('invisible', !showOrHide); - handleLabels[1].attr('invisible', !showOrHide); - }, - - _onDragMove: function (handleIndex, dx, dy) { - this._dragging = true; - - // Transform dx, dy to bar coordination. - var vertex = this._applyBarTransform([dx, dy], true); - - this._updateInterval(handleIndex, vertex[0]); - this._updateView(); - - if (this.dataZoomModel.get('realtime')) { - this._dispatchZoomAction(); - } - }, - - _onDragEnd: function () { - this._dragging = false; - this._showDataInfo(false); - this._dispatchZoomAction(); - }, - - /** - * This action will be throttled. - * @private - */ - _dispatchZoomAction: function () { - var range = this._range; - - this.api.dispatchAction({ - type: 'dataZoom', - from: this.uid, - dataZoomId: this.dataZoomModel.id, - start: range[0], - end: range[1] - }); - }, - - /** - * @private - */ - _applyBarTransform: function (vertex, inverse) { - var barTransform = this._displayables.barGroup.getLocalTransform(); - return graphic.applyTransform(vertex, barTransform, inverse); - }, - - /** - * @private - */ - _findCoordRect: function () { - // Find the grid coresponding to the first axis referred by dataZoom. - var targetInfo = this.getTargetInfo(); - - // FIXME - // 判断是catesian还是polar - var rect; - if (targetInfo.cartesians.length) { - rect = targetInfo.cartesians[0].model.coordinateSystem.getRect(); - } - else { // Polar - // FIXME - // 暂时随便写的 - var width = this.api.getWidth(); - var height = this.api.getHeight(); - rect = { - x: width * 0.2, - y: height * 0.2, - width: width * 0.6, - height: height * 0.6 - }; - } - - return rect; - } - - }); - - function getOtherDim(thisDim) { - // FIXME - // 这个逻辑和getOtherAxis里一致,但是写在这里是否不好 - return thisDim === 'x' ? 'y' : 'x'; - } - - return SliderZoomView; - -}); -/** - * @file Data zoom model - */ -define('echarts/component/dataZoom/InsideZoomModel',['require','./DataZoomModel'],function(require) { - - return require('./DataZoomModel').extend({ - - type: 'dataZoom.inside', - - /** - * @protected - */ - defaultOption: { - zoomLock: false // Whether disable zoom but only pan. - } - }); -}); -define('echarts/component/helper/interactionMutex',['require'],function (require) { - - var ATTR = '\0_ec_interaction_mutex'; - - var interactionMutex = { - - take: function (key, zr) { - getStore(zr)[key] = true; - }, - - release: function (key, zr) { - getStore(zr)[key] = false; - }, - - isTaken: function (key, zr) { - return !!getStore(zr)[key]; - } - }; - - function getStore(zr) { - return zr[ATTR] || (zr[ATTR] = {}); - } - - return interactionMutex; -}); -/** - * @module echarts/component/helper/RoamController - */ - -define('echarts/component/helper/RoamController',['require','zrender/mixin/Eventful','zrender/core/util','zrender/core/event','./interactionMutex'],function (require) { - - var Eventful = require('zrender/mixin/Eventful'); - var zrUtil = require('zrender/core/util'); - var eventTool = require('zrender/core/event'); - var interactionMutex = require('./interactionMutex'); - - function mousedown(e) { - if (e.target && e.target.draggable) { - return; - } - - var x = e.offsetX; - var y = e.offsetY; - var rect = this.rect; - if (rect && rect.contain(x, y)) { - this._x = x; - this._y = y; - this._dragging = true; - } - } - - function mousemove(e) { - if (!this._dragging) { - return; - } - - eventTool.stop(e.event); - - if (e.gestureEvent !== 'pinch') { - - if (interactionMutex.isTaken('globalPan', this._zr)) { - return; - } - - var x = e.offsetX; - var y = e.offsetY; - - var dx = x - this._x; - var dy = y - this._y; - - this._x = x; - this._y = y; - - var target = this.target; - - if (target) { - var pos = target.position; - pos[0] += dx; - pos[1] += dy; - target.dirty(); - } - - eventTool.stop(e.event); - this.trigger('pan', dx, dy); - } - } - - function mouseup(e) { - this._dragging = false; - } - - function mousewheel(e) { - eventTool.stop(e.event); - // Convenience: - // Mac and VM Windows on Mac: scroll up: zoom out. - // Windows: scroll up: zoom in. - var zoomDelta = e.wheelDelta > 0 ? 1.1 : 1 / 1.1; - zoom.call(this, e, zoomDelta, e.offsetX, e.offsetY); - } - - function pinch(e) { - if (interactionMutex.isTaken('globalPan', this._zr)) { - return; - } - - eventTool.stop(e.event); - var zoomDelta = e.pinchScale > 1 ? 1.1 : 1 / 1.1; - zoom.call(this, e, zoomDelta, e.pinchX, e.pinchY); - } - - function zoom(e, zoomDelta, zoomX, zoomY) { - var rect = this.rect; - - if (rect && rect.contain(zoomX, zoomY)) { - - var target = this.target; - - if (target) { - var pos = target.position; - var scale = target.scale; - - var newZoom = this._zoom = this._zoom || 1; - newZoom *= zoomDelta; - // newZoom = Math.max( - // Math.min(target.maxZoom, newZoom), - // target.minZoom - // ); - var zoomScale = newZoom / this._zoom; - this._zoom = newZoom; - // Keep the mouse center when scaling - pos[0] -= (zoomX - pos[0]) * (zoomScale - 1); - pos[1] -= (zoomY - pos[1]) * (zoomScale - 1); - scale[0] *= zoomScale; - scale[1] *= zoomScale; - - target.dirty(); - } - - this.trigger('zoom', zoomDelta, zoomX, zoomY); - } - } - - /** - * @alias module:echarts/component/helper/RoamController - * @constructor - * @mixin {module:zrender/mixin/Eventful} - * - * @param {module:zrender/zrender~ZRender} zr - * @param {module:zrender/Element} target - * @param {module:zrender/core/BoundingRect} rect - */ - function RoamController(zr, target, rect) { - - /** - * @type {module:zrender/Element} - */ - this.target = target; - - /** - * @type {module:zrender/core/BoundingRect} - */ - this.rect = rect; - - /** - * @type {module:zrender} - */ - this._zr = zr; - - // Avoid two roamController bind the same handler - var bind = zrUtil.bind; - var mousedownHandler = bind(mousedown, this); - var mousemoveHandler = bind(mousemove, this); - var mouseupHandler = bind(mouseup, this); - var mousewheelHandler = bind(mousewheel, this); - var pinchHandler = bind(pinch, this); - - Eventful.call(this); - - /** - * Notice: only enable needed types. For example, if 'zoom' - * is not needed, 'zoom' should not be enabled, otherwise - * default mousewheel behaviour (scroll page) will be disabled. - * - * @param {boolean|string} [controlType=true] Specify the control type, - * which can be null/undefined or true/false - * or 'pan/move' or 'zoom'/'scale' - */ - this.enable = function (controlType) { - // Disable previous first - this.disable(); - - if (controlType == null) { - controlType = true; - } - - if (controlType === true || (controlType === 'move' || controlType === 'pan')) { - zr.on('mousedown', mousedownHandler); - zr.on('mousemove', mousemoveHandler); - zr.on('mouseup', mouseupHandler); - } - if (controlType === true || (controlType === 'scale' || controlType === 'zoom')) { - zr.on('mousewheel', mousewheelHandler); - zr.on('pinch', pinchHandler); - } - }; - - this.disable = function () { - zr.off('mousedown', mousedownHandler); - zr.off('mousemove', mousemoveHandler); - zr.off('mouseup', mouseupHandler); - zr.off('mousewheel', mousewheelHandler); - zr.off('pinch', pinchHandler); - }; - - this.dispose = this.disable; - - this.isDragging = function () { - return this._dragging; - }; - - this.isPinching = function () { - return this._pinching; - }; - } - - zrUtil.mixin(RoamController, Eventful); - - return RoamController; -}); -/** - * @file Roam controller manager. - */ -define('echarts/component/dataZoom/roams',['require','zrender/core/util','../../component/helper/RoamController','../../util/throttle'],function(require) { - - // Only create one roam controller for each coordinate system. - // one roam controller might be refered by two inside data zoom - // components (for example, one for x and one for y). When user - // pan or zoom, only dispatch one action for those data zoom - // components. - - var zrUtil = require('zrender/core/util'); - var RoamController = require('../../component/helper/RoamController'); - var throttle = require('../../util/throttle'); - var curry = zrUtil.curry; - - var ATTR = '\0_ec_dataZoom_roams'; - - var roams = { - - /** - * @public - * @param {module:echarts/ExtensionAPI} api - * @param {Object} dataZoomInfo - * @param {string} dataZoomInfo.coordType - * @param {string} dataZoomInfo.coordId - * @param {Object} dataZoomInfo.coordinateSystem - * @param {string} dataZoomInfo.dataZoomId - * @param {number} dataZoomInfo.throttleRate - * @param {Function} dataZoomInfo.panGetRange - * @param {Function} dataZoomInfo.zoomGetRange - */ - register: function (api, dataZoomInfo) { - var store = giveStore(api); - var theDataZoomId = dataZoomInfo.dataZoomId; - var theCoordId = dataZoomInfo.coordType + '\0_' + dataZoomInfo.coordId; - - // Do clean when a dataZoom changes its target coordnate system. - zrUtil.each(store, function (record, coordId) { - var dataZoomInfos = record.dataZoomInfos; - if (dataZoomInfos[theDataZoomId] && coordId !== theCoordId) { - delete dataZoomInfos[theDataZoomId]; - record.count--; - } - }); - - cleanStore(store); - - var record = store[theCoordId]; - - // Create if needed. - if (!record) { - record = store[theCoordId] = { - coordId: theCoordId, - dataZoomInfos: {}, - count: 0 - }; - record.controller = createController(api, dataZoomInfo, record); - record.dispatchAction = zrUtil.curry(dispatchAction, api); - } - - // Update. - if (record) { - throttle.createOrUpdate( - record, - 'dispatchAction', - dataZoomInfo.throttleRate, - 'fixRate' - ); - - !record.dataZoomInfos[theDataZoomId] && record.count++; - record.dataZoomInfos[theDataZoomId] = dataZoomInfo; - } - }, - - /** - * @public - * @param {module:echarts/ExtensionAPI} api - * @param {string} dataZoomId - */ - unregister: function (api, dataZoomId) { - var store = giveStore(api); - - zrUtil.each(store, function (record, coordId) { - var dataZoomInfos = record.dataZoomInfos; - if (dataZoomInfos[dataZoomId]) { - delete dataZoomInfos[dataZoomId]; - record.count--; - } - }); - - cleanStore(store); - }, - - /** - * @public - */ - shouldRecordRange: function (payload, dataZoomId) { - if (payload && payload.type === 'dataZoom' && payload.batch) { - for (var i = 0, len = payload.batch.length; i < len; i++) { - if (payload.batch[i].dataZoomId === dataZoomId) { - return false; - } - } - } - return true; - } - - }; - - /** - * Key: coordId, value: {dataZoomInfos: [], count, controller} - * @type {Array.} - */ - function giveStore(api) { - // Mount store on zrender instance, so that we do not - // need to worry about dispose. - var zr = api.getZr(); - return zr[ATTR] || (zr[ATTR] = {}); - } - - function createController(api, dataZoomInfo, newRecord) { - var controller = new RoamController(api.getZr()); - controller.enable(); - controller.on('pan', curry(onPan, newRecord)); - controller.on('zoom', curry(onZoom, newRecord)); - controller.rect = dataZoomInfo.coordinateSystem.getRect().clone(); - - return controller; - } - - function cleanStore(store) { - zrUtil.each(store, function (record, coordId) { - if (!record.count) { - record.controller.off('pan').off('zoom'); - delete store[coordId]; - } - }); - } - - function onPan(record, dx, dy) { - wrapAndDispatch(record, function (info) { - return info.panGetRange(record.controller, dx, dy); - }); - } - - function onZoom(record, scale, mouseX, mouseY) { - wrapAndDispatch(record, function (info) { - return info.zoomGetRange(record.controller, scale, mouseX, mouseY); - }); - } - - function wrapAndDispatch(record, getRange) { - var batch = []; - - zrUtil.each(record.dataZoomInfos, function (info) { - var range = getRange(info); - range && batch.push({ - dataZoomId: info.dataZoomId, - start: range[0], - end: range[1] - }); - }); - - record.dispatchAction(batch); - } - - /** - * This action will be throttled. - */ - function dispatchAction(api, batch) { - api.dispatchAction({ - type: 'dataZoom', - batch: batch - }); - } - - return roams; - -}); -define('echarts/component/dataZoom/InsideZoomView',['require','./DataZoomView','zrender/core/util','../helper/sliderMove','./roams'],function (require) { - - var DataZoomView = require('./DataZoomView'); - var zrUtil = require('zrender/core/util'); - var sliderMove = require('../helper/sliderMove'); - var roams = require('./roams'); - var bind = zrUtil.bind; - - var InsideZoomView = DataZoomView.extend({ - - type: 'dataZoom.inside', - - /** - * @override - */ - init: function (ecModel, api) { - /** - * 'throttle' is used in this.dispatchAction, so we save range - * to avoid missing some 'pan' info. - * @private - * @type {Array.} - */ - this._range; - }, - - /** - * @override - */ - render: function (dataZoomModel, ecModel, api, payload) { - InsideZoomView.superApply(this, 'render', arguments); - - // Notice: origin this._range should be maintained, and should not be re-fetched - // from dataZoomModel when payload.type is 'dataZoom', otherwise 'pan' or 'zoom' - // info will be missed because of 'throttle' of this.dispatchAction. - if (roams.shouldRecordRange(payload, dataZoomModel.id)) { - this._range = dataZoomModel.getPercentRange(); - } - - // Reset controllers. - zrUtil.each(this.getTargetInfo().cartesians, function (coordInfo) { - var coordModel = coordInfo.model; - roams.register( - api, - { - coordId: coordModel.id, - coordType: coordModel.type, - coordinateSystem: coordModel.coordinateSystem, - dataZoomId: dataZoomModel.id, - throttleRage: dataZoomModel.get('throttle', true), - panGetRange: bind(this._onPan, this, coordInfo), - zoomGetRange: bind(this._onZoom, this, coordInfo) - } - ); - }, this); - - // TODO - // polar支持 - }, - - /** - * @override - */ - remove: function () { - roams.unregister(this.api, this.dataZoomModel.id); - InsideZoomView.superApply(this, 'remove', arguments); - this._range = null; - }, - - /** - * @override - */ - dispose: function () { - roams.unregister(this.api, this.dataZoomModel.id); - InsideZoomView.superApply(this, 'dispose', arguments); - this._range = null; - }, - - /** - * @private - */ - _onPan: function (coordInfo, controller, dx, dy) { - return ( - this._range = panCartesian( - [dx, dy], this._range, controller, coordInfo - ) - ); - }, - - /** - * @private - */ - _onZoom: function (coordInfo, controller, scale, mouseX, mouseY) { - var dataZoomModel = this.dataZoomModel; - - if (dataZoomModel.option.zoomLock) { - return; - } - - return ( - this._range = scaleCartesian( - 1 / scale, [mouseX, mouseY], this._range, - controller, coordInfo, dataZoomModel - ) - ); - } - - }); - - function panCartesian(pixelDeltas, range, controller, coordInfo) { - range = range.slice(); - - // Calculate transform by the first axis. - var axisModel = coordInfo.axisModels[0]; - if (!axisModel) { - return; - } - - var directionInfo = getDirectionInfo(pixelDeltas, axisModel, controller); - - var percentDelta = directionInfo.signal - * (range[1] - range[0]) - * directionInfo.pixel / directionInfo.pixelLength; - - sliderMove( - percentDelta, - range, - [0, 100], - 'rigid' - ); - - return range; - } - - function scaleCartesian(scale, mousePoint, range, controller, coordInfo, dataZoomModel) { - range = range.slice(); - - // Calculate transform by the first axis. - var axisModel = coordInfo.axisModels[0]; - if (!axisModel) { - return; - } - - var directionInfo = getDirectionInfo(mousePoint, axisModel, controller); - - var mouse = directionInfo.pixel - directionInfo.pixelStart; - var percentPoint = mouse / directionInfo.pixelLength * (range[1] - range[0]) + range[0]; - - scale = Math.max(scale, 0); - range[0] = (range[0] - percentPoint) * scale + percentPoint; - range[1] = (range[1] - percentPoint) * scale + percentPoint; - - return fixRange(range); - } - - function getDirectionInfo(xy, axisModel, controller) { - var axis = axisModel.axis; - var rect = controller.rect; - var ret = {}; - - if (axis.dim === 'x') { - ret.pixel = xy[0]; - ret.pixelLength = rect.width; - ret.pixelStart = rect.x; - ret.signal = axis.inverse ? 1 : -1; - } - else { // axis.dim === 'y' - ret.pixel = xy[1]; - ret.pixelLength = rect.height; - ret.pixelStart = rect.y; - ret.signal = axis.inverse ? -1 : 1; - } - - return ret; - } - - function fixRange(range) { - // Clamp, using !(<= or >=) to handle NaN. - // jshint ignore:start - var bound = [0, 100]; - !(range[0] <= bound[1]) && (range[0] = bound[1]); - !(range[1] <= bound[1]) && (range[1] = bound[1]); - !(range[0] >= bound[0]) && (range[0] = bound[0]); - !(range[1] >= bound[0]) && (range[1] = bound[0]); - // jshint ignore:end - - return range; - } - - return InsideZoomView; -}); -/** - * @file Data zoom processor - */ -define('echarts/component/dataZoom/dataZoomProcessor',['require','../../echarts'],function (require) { - - var echarts = require('../../echarts'); - - echarts.registerProcessor('filter', function (ecModel, api) { - - ecModel.eachComponent('dataZoom', function (dataZoomModel) { - // We calculate window and reset axis here but not in model - // init stage and not after action dispatch handler, because - // reset should be called after seriesData.restoreData. - dataZoomModel.eachTargetAxis(resetSingleAxis); - - // Caution: data zoom filtering is order sensitive when using - // percent range and no min/max/scale set on axis. - // For example, we have dataZoom definition: - // [ - // {xAxisIndex: 0, start: 30, end: 70}, - // {yAxisIndex: 0, start: 20, end: 80} - // ] - // In this case, [20, 80] of y-dataZoom should be based on data - // that have filtered by x-dataZoom using range of [30, 70], - // but should not be based on full raw data. Thus sliding - // x-dataZoom will change both ranges of xAxis and yAxis, - // while sliding y-dataZoom will only change the range of yAxis. - // So we should filter x-axis after reset x-axis immediately, - // and then reset y-axis and filter y-axis. - dataZoomModel.eachTargetAxis(filterSingleAxis); - }); - - ecModel.eachComponent('dataZoom', function (dataZoomModel) { - // Fullfill all of the range props so that user - // is able to get them from chart.getOption(). - var axisProxy = dataZoomModel.findRepresentativeAxisProxy(); - var percentRange = axisProxy.getDataPercentWindow(); - var valueRange = axisProxy.getDataValueWindow(); - dataZoomModel.setRawRange({ - start: percentRange[0], - end: percentRange[1], - startValue: valueRange[0], - endValue: valueRange[1] - }); - }); - }); - - function resetSingleAxis(dimNames, axisIndex, dataZoomModel) { - dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel); - } - - function filterSingleAxis(dimNames, axisIndex, dataZoomModel) { - dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel); - } - -}); - -/** - * @file Data zoom action - */ -define('echarts/component/dataZoom/dataZoomAction',['require','zrender/core/util','../../util/model','../../echarts'],function(require) { - - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../../util/model'); - var echarts = require('../../echarts'); - - - echarts.registerAction('dataZoom', function (payload, ecModel) { - - var linkedNodesFinder = modelUtil.createLinkedNodesFinder( - zrUtil.bind(ecModel.eachComponent, ecModel, 'dataZoom'), - modelUtil.eachAxisDim, - function (model, dimNames) { - return model.get(dimNames.axisIndex); - } - ); - - var effectedModels = []; - - ecModel.eachComponent( - {mainType: 'dataZoom', query: payload}, - function (model, index) { - effectedModels.push.apply( - effectedModels, linkedNodesFinder(model).nodes - ); - } - ); - - zrUtil.each(effectedModels, function (dataZoomModel, index) { - dataZoomModel.setRawRange({ - start: payload.start, - end: payload.end, - startValue: payload.startValue, - endValue: payload.endValue - }); - }); - - }); - -}); -/** - * DataZoom component entry - */ -define('echarts/component/dataZoom',['require','./dataZoom/typeDefaulter','./dataZoom/DataZoomModel','./dataZoom/DataZoomView','./dataZoom/SliderZoomModel','./dataZoom/SliderZoomView','./dataZoom/InsideZoomModel','./dataZoom/InsideZoomView','./dataZoom/dataZoomProcessor','./dataZoom/dataZoomAction'],function (require) { - - require('./dataZoom/typeDefaulter'); - - require('./dataZoom/DataZoomModel'); - require('./dataZoom/DataZoomView'); - - require('./dataZoom/SliderZoomModel'); - require('./dataZoom/SliderZoomView'); - - require('./dataZoom/InsideZoomModel'); - require('./dataZoom/InsideZoomView'); - - require('./dataZoom/dataZoomProcessor'); - require('./dataZoom/dataZoomAction'); - -}); -define('echarts/component/toolbox/featureManager',['require'],function(require) { - - - var features = {}; - - return { - register: function (name, ctor) { - features[name] = ctor; - }, - - get: function (name) { - return features[name]; - } - }; -}); -define('echarts/component/toolbox/ToolboxModel',['require','./featureManager','zrender/core/util','../../echarts'],function (require) { - - var featureManager = require('./featureManager'); - var zrUtil = require('zrender/core/util'); - - var ToolboxModel = require('../../echarts').extendComponentModel({ - - type: 'toolbox', - - layoutMode: { - type: 'box', - ignoreSize: true - }, - - mergeDefaultAndTheme: function (option) { - ToolboxModel.superApply(this, 'mergeDefaultAndTheme', arguments); - - zrUtil.each(this.option.feature, function (featureOpt, featureName) { - var Feature = featureManager.get(featureName); - Feature && zrUtil.merge(featureOpt, Feature.defaultOption); - }); - }, - - defaultOption: { - - show: true, - - z: 6, - - zlevel: 0, - - orient: 'horizontal', - - left: 'right', - - top: 'top', - - // right - // bottom - - backgroundColor: 'transparent', - - borderColor: '#ccc', - - borderWidth: 0, - - padding: 5, - - itemSize: 15, - - itemGap: 8, - - showTitle: true, - - iconStyle: { - normal: { - borderColor: '#666', - color: 'none' - }, - emphasis: { - borderColor: '#3E98C5' - } - } - // textStyle: {}, - - // feature - } - }); - - return ToolboxModel; -}); -define('echarts/component/toolbox/ToolboxView',['require','./featureManager','zrender/core/util','../../util/graphic','../../model/Model','../../data/DataDiffer','../helper/listComponent','zrender/contain/text','../../echarts'],function (require) { - - var featureManager = require('./featureManager'); - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var Model = require('../../model/Model'); - var DataDiffer = require('../../data/DataDiffer'); - var listComponentHelper = require('../helper/listComponent'); - var textContain = require('zrender/contain/text'); - - return require('../../echarts').extendComponentView({ - - type: 'toolbox', - - render: function (toolboxModel, ecModel, api) { - var group = this.group; - group.removeAll(); - - if (!toolboxModel.get('show')) { - return; - } - - var itemSize = +toolboxModel.get('itemSize'); - var featureOpts = toolboxModel.get('feature') || {}; - var features = this._features || (this._features = {}); - - var featureNames = []; - zrUtil.each(featureOpts, function (opt, name) { - featureNames.push(name); - }); - - (new DataDiffer(this._featureNames || [], featureNames)) - .add(process) - .update(process) - .remove(zrUtil.curry(process, null)) - .execute(); - - // Keep for diff. - this._featureNames = featureNames; - - function process(newIndex, oldIndex) { - var featureName = featureNames[newIndex]; - var oldName = featureNames[oldIndex]; - var featureOpt = featureOpts[featureName]; - var featureModel = new Model(featureOpt, toolboxModel, toolboxModel.ecModel); - var feature; - - if (featureName && !oldName) { // Create - if (isUserFeatureName(featureName)) { - feature = { - model: featureModel, - onclick: featureModel.option.onclick, - featureName: featureName - }; - } - else { - var Feature = featureManager.get(featureName); - if (!Feature) { - return; - } - feature = new Feature(featureModel); - } - features[featureName] = feature; - } - else { - feature = features[oldName]; - // If feature does not exsit. - if (!feature) { - return; - } - feature.model = featureModel; - } - - if (!featureName && oldName) { - feature.dispose && feature.dispose(ecModel, api); - return; - } - - if (!featureModel.get('show') || feature.unusable) { - feature.remove && feature.remove(ecModel, api); - return; - } - - createIconPaths(featureModel, feature, featureName); - - featureModel.setIconStatus = function (iconName, status) { - var option = this.option; - var iconPaths = this.iconPaths; - option.iconStatus = option.iconStatus || {}; - option.iconStatus[iconName] = status; - // FIXME - iconPaths[iconName] && iconPaths[iconName].trigger(status); - }; - - if (feature.render) { - feature.render(featureModel, ecModel, api); - } - } - - function createIconPaths(featureModel, feature, featureName) { - var iconStyleModel = featureModel.getModel('iconStyle'); - - // If one feature has mutiple icon. they are orginaized as - // { - // icon: { - // foo: '', - // bar: '' - // }, - // title: { - // foo: '', - // bar: '' - // } - // } - var icons = feature.getIcons ? feature.getIcons() : featureModel.get('icon'); - var titles = featureModel.get('title') || {}; - if (typeof icons === 'string') { - var icon = icons; - var title = titles; - icons = {}; - titles = {}; - icons[featureName] = icon; - titles[featureName] = title; - } - var iconPaths = featureModel.iconPaths = {}; - zrUtil.each(icons, function (icon, iconName) { - var normalStyle = iconStyleModel.getModel('normal').getItemStyle(); - var hoverStyle = iconStyleModel.getModel('emphasis').getItemStyle(); - - var style = { - x: -itemSize / 2, - y: -itemSize / 2, - width: itemSize, - height: itemSize - }; - var path = icon.indexOf('image://') === 0 - ? ( - style.image = icon.slice(8), - new graphic.Image({style: style}) - ) - : graphic.makePath( - icon.replace('path://', ''), - { - style: normalStyle, - hoverStyle: hoverStyle, - rectHover: true - }, - style, - 'center' - ); - - graphic.setHoverStyle(path); - - if (toolboxModel.get('showTitle')) { - path.__title = titles[iconName]; - path.on('mouseover', function () { - path.setStyle({ - text: titles[iconName], - textPosition: hoverStyle.textPosition || 'bottom', - textFill: hoverStyle.fill || hoverStyle.stroke || '#000', - textAlign: hoverStyle.textAlign || 'center' - }); - }) - .on('mouseout', function () { - path.setStyle({ - textFill: null - }); - }); - } - path.trigger(featureModel.get('iconStatus.' + iconName) || 'normal'); - - group.add(path); - path.on('click', zrUtil.bind( - feature.onclick, feature, ecModel, api, iconName - )); - - iconPaths[iconName] = path; - }); - } - - listComponentHelper.layout(group, toolboxModel, api); - // Render background after group is layout - // FIXME - listComponentHelper.addBackground(group, toolboxModel); - - // Adjust icon title positions to avoid them out of screen - group.eachChild(function (icon) { - var titleText = icon.__title; - var hoverStyle = icon.hoverStyle; - // May be background element - if (hoverStyle && titleText) { - var rect = textContain.getBoundingRect( - titleText, hoverStyle.font - ); - var offsetX = icon.position[0] + group.position[0]; - var offsetY = icon.position[1] + group.position[1] + itemSize; - - var needPutOnTop = false; - if (offsetY + rect.height > api.getHeight()) { - hoverStyle.textPosition = 'top'; - needPutOnTop = true; - } - var topOffset = needPutOnTop ? (-5 - rect.height) : (itemSize + 8); - if (offsetX + rect.width / 2 > api.getWidth()) { - hoverStyle.textPosition = ['100%', topOffset]; - hoverStyle.textAlign = 'right'; - } - else if (offsetX - rect.width / 2 < 0) { - hoverStyle.textPosition = [0, topOffset]; - hoverStyle.textAlign = 'left'; - } - } - }); - }, - - remove: function (ecModel, api) { - zrUtil.each(this._features, function (feature) { - feature.remove && feature.remove(ecModel, api); - }); - this.group.removeAll(); - }, - - dispose: function (ecModel, api) { - zrUtil.each(this._features, function (feature) { - feature.dispose && feature.dispose(ecModel, api); - }); - } - }); - - function isUserFeatureName(featureName) { - return featureName.indexOf('my') === 0; - } - -}); -define('echarts/component/toolbox/feature/SaveAsImage',['require','zrender/core/env','../featureManager'],function (require) { - - var env = require('zrender/core/env'); - - function SaveAsImage (model) { - this.model = model; - } - - SaveAsImage.defaultOption = { - show: true, - icon: 'M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0', - title: '保存为图片', - type: 'png', - // Default use option.backgroundColor - // backgroundColor: '#fff', - name: '', - excludeComponents: ['toolbox'], - pixelRatio: 1, - lang: ['右键另存为图片'] - }; - - SaveAsImage.prototype.unusable = !env.canvasSupported; - - var proto = SaveAsImage.prototype; - - proto.onclick = function (ecModel, api) { - var model = this.model; - var title = model.get('name') || ecModel.get('title.0.text') || 'echarts'; - var $a = document.createElement('a'); - var type = model.get('type', true) || 'png'; - $a.download = title + '.' + type; - $a.target = '_blank'; - var url = api.getConnectedDataURL({ - type: type, - backgroundColor: model.get('backgroundColor', true) - || ecModel.get('backgroundColor') || '#fff', - excludeComponents: model.get('excludeComponents'), - pixelRatio: model.get('pixelRatio') - }); - $a.href = url; - // Chrome and Firefox - if (typeof MouseEvent === 'function') { - var evt = new MouseEvent('click', { - view: window, - bubbles: true, - cancelable: false - }); - $a.dispatchEvent(evt); - } - // IE - else { - var lang = model.get('lang'); - var html = '' - + '' - + '' - + ''; - var tab = window.open(); - tab.document.write(html); - } - }; - - require('../featureManager').register( - 'saveAsImage', SaveAsImage - ); - - return SaveAsImage; -}); -define('echarts/component/toolbox/feature/MagicType',['require','zrender/core/util','../../../echarts','../featureManager'],function(require) { - - - var zrUtil = require('zrender/core/util'); - - function MagicType(model) { - this.model = model; - } - - MagicType.defaultOption = { - show: true, - type: [], - // Icon group - icon: { - line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4', - bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7', - stack: 'M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z', // jshint ignore:line - tiled: 'M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z' - }, - title: { - line: '切换为折线图', - bar: '切换为柱状图', - stack: '切换为堆叠', - tiled: '切换为平铺' - }, - option: {}, - seriesIndex: {} - }; - - var proto = MagicType.prototype; - - proto.getIcons = function () { - var model = this.model; - var availableIcons = model.get('icon'); - var icons = {}; - zrUtil.each(model.get('type'), function (type) { - if (availableIcons[type]) { - icons[type] = availableIcons[type]; - } - }); - return icons; - }; - - var seriesOptGenreator = { - 'line': function (seriesType, seriesId, seriesModel, model) { - if (seriesType === 'bar') { - return zrUtil.merge({ - id: seriesId, - type: 'line', - // Preserve data related option - data: seriesModel.get('data'), - stack: seriesModel.get('stack'), - markPoint: seriesModel.get('markPoint'), - markLine: seriesModel.get('markLine') - }, model.get('option.line')); - } - }, - 'bar': function (seriesType, seriesId, seriesModel, model) { - if (seriesType === 'line') { - return zrUtil.merge({ - id: seriesId, - type: 'bar', - // Preserve data related option - data: seriesModel.get('data'), - stack: seriesModel.get('stack'), - markPoint: seriesModel.get('markPoint'), - markLine: seriesModel.get('markLine') - }, model.get('option.bar')); - } - }, - 'stack': function (seriesType, seriesId, seriesModel, model) { - if (seriesType === 'line' || seriesType === 'bar') { - return { - id: seriesId, - stack: '__ec_magicType_stack__' - }; - } - }, - 'tiled': function (seriesType, seriesId, seriesModel, model) { - if (seriesType === 'line' || seriesType === 'bar') { - return { - id: seriesId, - stack: '' - }; - } - } - }; - - var radioTypes = [ - ['line', 'bar'], - ['stack', 'tiled'] - ]; - - proto.onclick = function (ecModel, api, type) { - var model = this.model; - var seriesIndex = model.get('seriesIndex.' + type); - // Not supported magicType - if (!seriesOptGenreator[type]) { - return; - } - var newOption = { - series: [] - }; - var generateNewSeriesTypes = function (seriesModel) { - var seriesType = seriesModel.subType; - var seriesId = seriesModel.id; - var newSeriesOpt = seriesOptGenreator[type]( - seriesType, seriesId, seriesModel, model - ); - if (newSeriesOpt) { - // PENDING If merge original option? - zrUtil.defaults(newSeriesOpt, seriesModel.option); - newOption.series.push(newSeriesOpt); - } - }; - - zrUtil.each(radioTypes, function (radio) { - if (zrUtil.indexOf(radio, type) >= 0) { - zrUtil.each(radio, function (item) { - model.setIconStatus(item, 'normal'); - }); - } - }); - - model.setIconStatus(type, 'emphasis'); - - ecModel.eachComponent( - { - mainType: 'series', - seriesIndex: seriesIndex - }, generateNewSeriesTypes - ); - api.dispatchAction({ - type: 'changeMagicType', - currentType: type, - newOption: newOption - }); - }; - - var echarts = require('../../../echarts'); - echarts.registerAction({ - type: 'changeMagicType', - event: 'magicTypeChanged', - update: 'prepareAndUpdate' - }, function (payload, ecModel) { - ecModel.mergeOption(payload.newOption); - }); - - require('../featureManager').register('magicType', MagicType); - - return MagicType; -}); -/** - * @module echarts/component/toolbox/feature/DataView - */ - -define('echarts/component/toolbox/feature/DataView',['require','zrender/core/util','zrender/core/event','../featureManager','../../../echarts'],function (require) { - - var zrUtil = require('zrender/core/util'); - var eventTool = require('zrender/core/event'); - - - var BLOCK_SPLITER = new Array(60).join('-'); - var ITEM_SPLITER = '\t'; - /** - * Group series into two types - * 1. on category axis, like line, bar - * 2. others, like scatter, pie - * @param {module:echarts/model/Global} ecModel - * @return {Object} - * @inner - */ - function groupSeries(ecModel) { - var seriesGroupByCategoryAxis = {}; - var otherSeries = []; - var meta = []; - ecModel.eachRawSeries(function (seriesModel) { - var coordSys = seriesModel.coordinateSystem; - - if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) { - var baseAxis = coordSys.getBaseAxis(); - if (baseAxis.type === 'category') { - var key = baseAxis.dim + '_' + baseAxis.index; - if (!seriesGroupByCategoryAxis[key]) { - seriesGroupByCategoryAxis[key] = { - categoryAxis: baseAxis, - valueAxis: coordSys.getOtherAxis(baseAxis), - series: [] - }; - meta.push({ - axisDim: baseAxis.dim, - axisIndex: baseAxis.index - }); - } - seriesGroupByCategoryAxis[key].series.push(seriesModel); - } - else { - otherSeries.push(seriesModel); - } - } - else { - otherSeries.push(seriesModel); - } - }); - - return { - seriesGroupByCategoryAxis: seriesGroupByCategoryAxis, - other: otherSeries, - meta: meta - }; - } - - /** - * Assemble content of series on cateogory axis - * @param {Array.} series - * @return {string} - * @inner - */ - function assembleSeriesWithCategoryAxis(series) { - var tables = []; - zrUtil.each(series, function (group, key) { - var categoryAxis = group.categoryAxis; - var valueAxis = group.valueAxis; - var valueAxisDim = valueAxis.dim; - - var headers = [' '].concat(zrUtil.map(group.series, function (series) { - return series.name; - })); - var columns = [categoryAxis.model.getCategories()]; - zrUtil.each(group.series, function (series) { - columns.push(series.getRawData().mapArray(valueAxisDim, function (val) { - return val; - })); - }); - // Assemble table content - var lines = [headers.join(ITEM_SPLITER)]; - for (var i = 0; i < columns[0].length; i++) { - var items = []; - for (var j = 0; j < columns.length; j++) { - items.push(columns[j][i]); - } - lines.push(items.join(ITEM_SPLITER)); - } - tables.push(lines.join('\n')); - }); - return tables.join('\n\n' + BLOCK_SPLITER + '\n\n'); - } - - /** - * Assemble content of other series - * @param {Array.} series - * @return {string} - * @inner - */ - function assembleOtherSeries(series) { - return zrUtil.map(series, function (series) { - var data = series.getRawData(); - var lines = [series.name]; - var vals = []; - data.each(data.dimensions, function () { - var argLen = arguments.length; - var dataIndex = arguments[argLen - 1]; - var name = data.getName(dataIndex); - for (var i = 0; i < argLen - 1; i++) { - vals[i] = arguments[i]; - } - lines.push((name ? (name + ITEM_SPLITER) : '') + vals.join(ITEM_SPLITER)); - }); - return lines.join('\n'); - }).join('\n\n' + BLOCK_SPLITER + '\n\n'); - } - - /** - * @param {module:echarts/model/Global} - * @return {string} - * @inner - */ - function getContentFromModel(ecModel) { - - var result = groupSeries(ecModel); - - return { - value: zrUtil.filter([ - assembleSeriesWithCategoryAxis(result.seriesGroupByCategoryAxis), - assembleOtherSeries(result.other) - ], function (str) { - return str.replace(/[\n\t\s]/g, ''); - }).join('\n\n' + BLOCK_SPLITER + '\n\n'), - - meta: result.meta - }; - } - - - function trim(str) { - return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); - } - /** - * If a block is tsv format - */ - function isTSVFormat(block) { - // Simple method to find out if a block is tsv format - var firstLine = block.slice(0, block.indexOf('\n')); - if (firstLine.indexOf(ITEM_SPLITER) >= 0) { - return true; - } - } - - var itemSplitRegex = new RegExp('[' + ITEM_SPLITER + ']+', 'g'); - /** - * @param {string} tsv - * @return {Array.} - */ - function parseTSVContents(tsv) { - var tsvLines = tsv.split(/\n+/g); - var headers = trim(tsvLines.shift()).split(itemSplitRegex); - - var categories = []; - var series = zrUtil.map(headers, function (header) { - return { - name: header, - data: [] - }; - }); - for (var i = 0; i < tsvLines.length; i++) { - var items = trim(tsvLines[i]).split(itemSplitRegex); - categories.push(items.shift()); - for (var j = 0; j < items.length; j++) { - series[j] && (series[j].data[i] = items[j]); - } - } - return { - series: series, - categories: categories - }; - } - - /** - * @param {string} str - * @return {Array.} - * @inner - */ - function parseListContents(str) { - var lines = str.split(/\n+/g); - var seriesName = trim(lines.shift()); - - var data = []; - for (var i = 0; i < lines.length; i++) { - var items = trim(lines[i]).split(itemSplitRegex); - var name = ''; - var value; - var hasName = false; - if (isNaN(items[0])) { // First item is name - hasName = true; - name = items[0]; - items = items.slice(1); - data[i] = { - name: name, - value: [] - }; - value = data[i].value; - } - else { - value = data[i] = []; - } - for (var j = 0; j < items.length; j++) { - value.push(+items[j]); - } - if (value.length === 1) { - hasName ? (data[i].value = value[0]) : (data[i] = value[0]); - } - } - - return { - name: seriesName, - data: data - }; - } - - /** - * @param {string} str - * @param {Array.} blockMetaList - * @return {Object} - * @inner - */ - function parseContents(str, blockMetaList) { - var blocks = str.split(new RegExp('\n*' + BLOCK_SPLITER + '\n*', 'g')); - var newOption = { - series: [] - }; - zrUtil.each(blocks, function (block, idx) { - if (isTSVFormat(block)) { - var result = parseTSVContents(block); - var blockMeta = blockMetaList[idx]; - var axisKey = blockMeta.axisDim + 'Axis'; - - if (blockMeta) { - newOption[axisKey] = newOption[axisKey] || []; - newOption[axisKey][blockMeta.axisIndex] = { - data: result.categories - }; - newOption.series = newOption.series.concat(result.series); - } - } - else { - var result = parseListContents(block); - newOption.series.push(result); - } - }); - return newOption; - } - - /** - * @alias {module:echarts/component/toolbox/feature/DataView} - * @constructor - * @param {module:echarts/model/Model} model - */ - function DataView(model) { - - this._dom = null; - - this.model = model; - } - - DataView.defaultOption = { - show: true, - readOnly: false, - icon: 'M17.5,17.3H33 M17.5,17.3H33 M45.4,29.5h-28 M11.5,2v56H51V14.8L38.4,2H11.5z M38.4,2.2v12.7H51 M45.4,41.7h-28', - title: '数据视图', - lang: ['数据视图', '关闭', '刷新'], - backgroundColor: '#fff', - textColor: '#000', - textareaColor: '#fff', - textareaBorderColor: '#333', - buttonColor: '#c23531', - buttonTextColor: '#fff' - }; - - DataView.prototype.onclick = function (ecModel, api) { - var container = api.getDom(); - var model = this.model; - if (this._dom) { - container.removeChild(this._dom); - } - var root = document.createElement('div'); - root.style.cssText = 'position:absolute;left:5px;top:5px;bottom:5px;right:5px;'; - root.style.backgroundColor = model.get('backgroundColor') || '#fff'; - - // Create elements - var header = document.createElement('h4'); - var lang = model.get('lang') || []; - header.innerHTML = lang[0] || model.get('title'); - header.style.cssText = 'margin: 10px 20px;'; - header.style.color = model.get('textColor'); - - var textarea = document.createElement('textarea'); - // Textarea style - textarea.style.cssText = 'display:block;width:100%;font-size:14px;line-height:1.6rem;font-family:Monaco,Consolas,Courier new,monospace'; - textarea.readOnly = model.get('readOnly'); - textarea.style.color = model.get('textColor'); - textarea.style.borderColor = model.get('textareaBorderColor'); - textarea.style.backgroundColor = model.get('textareaColor'); - - var result = getContentFromModel(ecModel); - textarea.value = result.value; - var blockMetaList = result.meta; - - var buttonContainer = document.createElement('div'); - buttonContainer.style.cssText = 'position:absolute;bottom:0;left:0;right:0;'; - - var buttonStyle = 'float:right;margin-right:20px;border:none;' - + 'cursor:pointer;padding:2px 5px;font-size:12px;border-radius:3px'; - var closeButton = document.createElement('div'); - var refreshButton = document.createElement('div'); - - buttonStyle += ';background-color:' + model.get('buttonColor'); - buttonStyle += ';color:' + model.get('buttonTextColor'); - - var self = this; - - function close() { - container.removeChild(root); - self._dom = null; - } - eventTool.addEventListener(closeButton, 'click', close); - - eventTool.addEventListener(refreshButton, 'click', function () { - var newOption; - try { - newOption = parseContents(textarea.value, blockMetaList); - } - catch (e) { - close(); - throw new Error('Data view format error ' + e); - } - api.dispatchAction({ - type: 'changeDataView', - newOption: newOption - }); - - close(); - }); - - closeButton.innerHTML = lang[1]; - refreshButton.innerHTML = lang[2]; - refreshButton.style.cssText = buttonStyle; - closeButton.style.cssText = buttonStyle; - - buttonContainer.appendChild(refreshButton); - buttonContainer.appendChild(closeButton); - - // http://stackoverflow.com/questions/6637341/use-tab-to-indent-in-textarea - eventTool.addEventListener(textarea, 'keydown', function (e) { - if ((e.keyCode || e.which) === 9) { - // get caret position/selection - var val = this.value; - var start = this.selectionStart; - var end = this.selectionEnd; - - // set textarea value to: text before caret + tab + text after caret - this.value = val.substring(0, start) + ITEM_SPLITER + val.substring(end); - - // put caret at right position again - this.selectionStart = this.selectionEnd = start + 1; - - // prevent the focus lose - eventTool.stop(e); - } - }); - - root.appendChild(header); - root.appendChild(textarea); - root.appendChild(buttonContainer); - - textarea.style.height = (container.clientHeight - 80) + 'px'; - - container.appendChild(root); - this._dom = root; - }; - - DataView.prototype.remove = function (ecModel, api) { - this._dom && api.getDom().removeChild(this._dom); - }; - - DataView.prototype.dispose = function (ecModel, api) { - this.remove(ecModel, api); - }; - - /** - * @inner - */ - function tryMergeDataOption(newData, originalData) { - return zrUtil.map(newData, function (newVal, idx) { - var original = originalData && originalData[idx]; - if (zrUtil.isObject(original) && !zrUtil.isArray(original)) { - if (zrUtil.isObject(newVal) && !zrUtil.isArray(newVal)) { - newVal = newVal.value; - } - // Original data has option - return zrUtil.defaults({ - value: newVal - }, original); - } - else { - return newVal; - } - }); - } - - require('../featureManager').register('dataView', DataView); - - require('../../../echarts').registerAction({ - type: 'changeDataView', - event: 'dataViewChanged', - update: 'prepareAndUpdate' - }, function (payload, ecModel) { - var newSeriesOptList = []; - zrUtil.each(payload.newOption.series, function (seriesOpt) { - var seriesModel = ecModel.getSeriesByName(seriesOpt.name)[0]; - if (!seriesModel) { - // New created series - // Geuss the series type - newSeriesOptList.push(zrUtil.extend({ - // Default is scatter - type: 'scatter' - }, seriesOpt)); - } - else { - var originalData = seriesModel.get('data'); - newSeriesOptList.push({ - name: seriesOpt.name, - data: tryMergeDataOption(seriesOpt.data, originalData) - }); - } - }); - - ecModel.mergeOption(zrUtil.defaults({ - series: newSeriesOptList - }, payload.newOption)); - }); - - return DataView; -}); -/** - * Box selection tool. - * - * @module echarts/component/helper/SelectController - */ - -define('echarts/component/helper/SelectController',['require','zrender/mixin/Eventful','zrender/core/util','../../util/graphic'],function (require) { - - var Eventful = require('zrender/mixin/Eventful'); - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var bind = zrUtil.bind; - var each = zrUtil.each; - var mathMin = Math.min; - var mathMax = Math.max; - var mathPow = Math.pow; - - var COVER_Z = 10000; - var UNSELECT_THRESHOLD = 2; - var EVENTS = ['mousedown', 'mousemove', 'mouseup']; - - /** - * @alias module:echarts/component/helper/SelectController - * @constructor - * @mixin {module:zrender/mixin/Eventful} - * - * @param {string} type 'line', 'rect' - * @param {module:zrender/zrender~ZRender} zr - * @param {Object} [opt] - * @param {number} [opt.width] - * @param {number} [opt.lineWidth] - * @param {string} [opt.stroke] - * @param {string} [opt.fill] - */ - function SelectController(type, zr, opt) { - - Eventful.call(this); - - /** - * @type {string} - * @readOnly - */ - this.type = type; - - /** - * @type {module:zrender/zrender~ZRender} - */ - this.zr = zr; - - /** - * @type {Object} - * @readOnly - */ - this.opt = zrUtil.clone(opt); - - /** - * @type {module:zrender/container/Group} - * @readOnly - */ - this.group = new graphic.Group(); - - /** - * @type {module:zrender/core/BoundingRect} - */ - this._containerRect = null; - - /** - * @type {Array.} - * @private - */ - this._track = []; - - /** - * @type {boolean} - */ - this._dragging; - - /** - * @type {module:zrender/Element} - * @private - */ - this._cover; - - /** - * @type {boolean} - * @private - */ - this._disabled = true; - - /** - * @type {Object} - * @private - */ - this._handlers = { - mousedown: bind(mousedown, this), - mousemove: bind(mousemove, this), - mouseup: bind(mouseup, this) - }; - - each(EVENTS, function (eventName) { - this.zr.on(eventName, this._handlers[eventName]); - }, this); - } - - SelectController.prototype = { - - constructor: SelectController, - - /** - * @param {module:zrender/mixin/Transformable} container - * @param {module:zrender/core/BoundingRect|boolean} [rect] If not specified, - * use container.getBoundingRect(). - * If false, do not use containerRect. - */ - enable: function (container, rect) { - - this._disabled = false; - - // Remove from old container. - removeGroup.call(this); - - // boundingRect will change when dragging, so we have - // to keep initial boundingRect. - this._containerRect = rect !== false - ? (rect || container.getBoundingRect()) : null; - - // Add to new container. - container.add(this.group); - }, - - /** - * Update cover location. - * @param {Array.|Object} ranges If null/undefined, remove cover. - */ - update: function (ranges) { - // TODO - // Only support one interval yet. - renderCover.call(this, ranges && zrUtil.clone(ranges)); - }, - - disable: function () { - this._disabled = true; - - removeGroup.call(this); - }, - - dispose: function () { - this.disable(); - - each(EVENTS, function (eventName) { - this.zr.off(eventName, this._handlers[eventName]); - }, this); - } - }; - - - zrUtil.mixin(SelectController, Eventful); - - function updateZ(group) { - group.traverse(function (el) { - el.z = COVER_Z; - }); - } - - function isInContainer(x, y) { - var localPos = this.group.transformCoordToLocal(x, y); - return !this._containerRect - || this._containerRect.contain(localPos[0], localPos[1]); - } - - function preventDefault(e) { - var rawE = e.event; - rawE.preventDefault && rawE.preventDefault(); - } - - function mousedown(e) { - if (this._disabled || (e.target && e.target.draggable)) { - return; - } - - preventDefault(e); - - var x = e.offsetX; - var y = e.offsetY; - - if (isInContainer.call(this, x, y)) { - this._dragging = true; - this._track = [[x, y]]; - } - } - - function mousemove(e) { - if (!this._dragging || this._disabled) { - return; - } - - preventDefault(e); - - updateViewByCursor.call(this, e); - } - - function mouseup(e) { - if (!this._dragging || this._disabled) { - return; - } - - preventDefault(e); - - updateViewByCursor.call(this, e, true); - - this._dragging = false; - this._track = []; - } - - function updateViewByCursor(e, isEnd) { - var x = e.offsetX; - var y = e.offsetY; - - if (isInContainer.call(this, x, y)) { - this._track.push([x, y]); - - // Create or update cover. - var ranges = shouldShowCover.call(this) - ? coverRenderers[this.type].getRanges.call(this) - // Remove cover. - : []; - - renderCover.call(this, ranges); - - this.trigger('selected', zrUtil.clone(ranges)); - - if (isEnd) { - this.trigger('selectEnd', zrUtil.clone(ranges)); - } - } - } - - function shouldShowCover() { - var track = this._track; - - if (!track.length) { - return false; - } - - var p2 = track[track.length - 1]; - var p1 = track[0]; - var dx = p2[0] - p1[0]; - var dy = p2[1] - p1[1]; - var dist = mathPow(dx * dx + dy * dy, 0.5); - - return dist > UNSELECT_THRESHOLD; - } - - function renderCover(ranges) { - var coverRenderer = coverRenderers[this.type]; - - if (ranges && ranges.length) { - if (!this._cover) { - this._cover = coverRenderer.create.call(this); - this.group.add(this._cover); - } - coverRenderer.update.call(this, ranges); - } - else { - this.group.remove(this._cover); - this._cover = null; - } - - updateZ(this.group); - } - - function removeGroup() { - // container may 'removeAll' outside. - var group = this.group; - var container = group.parent; - if (container) { - container.remove(group); - } - } - - function createRectCover() { - var opt = this.opt; - return new graphic.Rect({ - // FIXME - // customize style. - style: { - stroke: opt.stroke, - fill: opt.fill, - lineWidth: opt.lineWidth, - opacity: opt.opacity - } - }); - } - - function getLocalTrack() { - return zrUtil.map(this._track, function (point) { - return this.group.transformCoordToLocal(point[0], point[1]); - }, this); - } - - function getLocalTrackEnds() { - var localTrack = getLocalTrack.call(this); - var tail = localTrack.length - 1; - tail < 0 && (tail = 0); - return [localTrack[0], localTrack[tail]]; - } - - /** - * key: this.type - * @type {Object} - */ - var coverRenderers = { - - line: { - - create: createRectCover, - - getRanges: function () { - var ends = getLocalTrackEnds.call(this); - var min = mathMin(ends[0][0], ends[1][0]); - var max = mathMax(ends[0][0], ends[1][0]); - - return [[min, max]]; - }, - - update: function (ranges) { - var range = ranges[0]; - var width = this.opt.width; - this._cover.setShape({ - x: range[0], - y: -width / 2, - width: range[1] - range[0], - height: width - }); - } - }, - - rect: { - - create: createRectCover, - - getRanges: function () { - var ends = getLocalTrackEnds.call(this); - - var min = [ - mathMin(ends[1][0], ends[0][0]), - mathMin(ends[1][1], ends[0][1]) - ]; - var max = [ - mathMax(ends[1][0], ends[0][0]), - mathMax(ends[1][1], ends[0][1]) - ]; - - return [[ - [min[0], max[0]], // x range - [min[1], max[1]] // y range - ]]; - }, - - update: function (ranges) { - var range = ranges[0]; - this._cover.setShape({ - x: range[0][0], - y: range[1][0], - width: range[0][1] - range[0][0], - height: range[1][1] - range[1][0] - }); - } - } - }; - - return SelectController; -}); -/** - * @file History manager. - */ -define('echarts/component/dataZoom/history',['require','zrender/core/util'],function(require) { - - var zrUtil = require('zrender/core/util'); - var each = zrUtil.each; - - var ATTR = '\0_ec_hist_store'; - - var history = { - - /** - * @public - * @param {module:echarts/model/Global} ecModel - * @param {Object} newSnapshot {dataZoomId, batch: [payloadInfo, ...]} - */ - push: function (ecModel, newSnapshot) { - var store = giveStore(ecModel); - - // If previous dataZoom can not be found, - // complete an range with current range. - each(newSnapshot, function (batchItem, dataZoomId) { - var i = store.length - 1; - for (; i >= 0; i--) { - var snapshot = store[i]; - if (snapshot[dataZoomId]) { - break; - } - } - if (i < 0) { - // No origin range set, create one by current range. - var dataZoomModel = ecModel.queryComponents( - {mainType: 'dataZoom', subType: 'select', id: dataZoomId} - )[0]; - if (dataZoomModel) { - var percentRange = dataZoomModel.getPercentRange(); - store[0][dataZoomId] = { - dataZoomId: dataZoomId, - start: percentRange[0], - end: percentRange[1] - }; - } - } - }); - - store.push(newSnapshot); - }, - - /** - * @public - * @param {module:echarts/model/Global} ecModel - * @return {Object} snapshot - */ - pop: function (ecModel) { - var store = giveStore(ecModel); - var head = store[store.length - 1]; - store.length > 1 && store.pop(); - - // Find top for all dataZoom. - var snapshot = {}; - each(head, function (batchItem, dataZoomId) { - for (var i = store.length - 1; i >= 0; i--) { - var batchItem = store[i][dataZoomId]; - if (batchItem) { - snapshot[dataZoomId] = batchItem; - break; - } - } - }); - - return snapshot; - }, - - /** - * @public - */ - clear: function (ecModel) { - ecModel[ATTR] = null; - }, - - /** - * @public - * @param {module:echarts/model/Global} ecModel - * @return {number} records. always >= 1. - */ - count: function (ecModel) { - return giveStore(ecModel).length; - } - - }; - - /** - * [{key: dataZoomId, value: {dataZoomId, range}}, ...] - * History length of each dataZoom may be different. - * this._history[0] is used to store origin range. - * @type {Array.} - */ - function giveStore(ecModel) { - var store = ecModel[ATTR]; - if (!store) { - store = ecModel[ATTR] = [{}]; - } - return store; - } - - return history; - -}); -/** - * @file Data zoom model - */ -define('echarts/component/dataZoom/SelectZoomModel',['require','./DataZoomModel'],function(require) { - - var DataZoomModel = require('./DataZoomModel'); - - return DataZoomModel.extend({ - - type: 'dataZoom.select' - - }); - -}); -define('echarts/component/dataZoom/SelectZoomView',['require','./DataZoomView'],function (require) { - - return require('./DataZoomView').extend({ - - type: 'dataZoom.select' - - }); - -}); -/** - * DataZoom component entry - */ -define('echarts/component/dataZoomSelect',['require','./dataZoom/typeDefaulter','./dataZoom/DataZoomModel','./dataZoom/DataZoomView','./dataZoom/SelectZoomModel','./dataZoom/SelectZoomView','./dataZoom/dataZoomProcessor','./dataZoom/dataZoomAction'],function (require) { - - require('./dataZoom/typeDefaulter'); - - require('./dataZoom/DataZoomModel'); - require('./dataZoom/DataZoomView'); - - require('./dataZoom/SelectZoomModel'); - require('./dataZoom/SelectZoomView'); - - require('./dataZoom/dataZoomProcessor'); - require('./dataZoom/dataZoomAction'); - -}); -define('echarts/component/toolbox/feature/DataZoom',['require','zrender/core/util','../../../util/number','../../helper/SelectController','zrender/core/BoundingRect','zrender/container/Group','../../dataZoom/history','../../helper/interactionMutex','../../dataZoomSelect','../featureManager','../../../echarts'],function(require) { - - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../../../util/number'); - var SelectController = require('../../helper/SelectController'); - var BoundingRect = require('zrender/core/BoundingRect'); - var Group = require('zrender/container/Group'); - var history = require('../../dataZoom/history'); - var interactionMutex = require('../../helper/interactionMutex'); - - var each = zrUtil.each; - var asc = numberUtil.asc; - - // Use dataZoomSelect - require('../../dataZoomSelect'); - - // Spectial component id start with \0ec\0, see echarts/model/Global.js~hasInnerId - var DATA_ZOOM_ID_BASE = '\0_ec_\0toolbox-dataZoom_'; - - function DataZoom(model) { - this.model = model; - - /** - * @private - * @type {module:zrender/container/Group} - */ - this._controllerGroup; - - /** - * @private - * @type {module:echarts/component/helper/SelectController} - */ - this._controller; - - /** - * Is zoom active. - * @private - * @type {Object} - */ - this._isZoomActive; - } - - DataZoom.defaultOption = { - show: true, - // Icon group - icon: { - zoom: 'M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1', - back: 'M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26' - }, - title: { - zoom: '区域缩放', - back: '区域缩放还原' - } - }; - - var proto = DataZoom.prototype; - - proto.render = function (featureModel, ecModel, api) { - updateBackBtnStatus(featureModel, ecModel); - }; - - proto.onclick = function (ecModel, api, type) { - var controllerGroup = this._controllerGroup; - if (!this._controllerGroup) { - controllerGroup = this._controllerGroup = new Group(); - api.getZr().add(controllerGroup); - } - - handlers[type].call(this, controllerGroup, this.model, ecModel, api); - }; - - proto.remove = function (ecModel, api) { - this._disposeController(); - interactionMutex.release('globalPan', api.getZr()); - }; - - proto.dispose = function (ecModel, api) { - var zr = api.getZr(); - interactionMutex.release('globalPan', zr); - this._disposeController(); - this._controllerGroup && zr.remove(this._controllerGroup); - }; - - /** - * @private - */ - var handlers = { - - zoom: function (controllerGroup, featureModel, ecModel, api) { - var isZoomActive = this._isZoomActive = !this._isZoomActive; - var zr = api.getZr(); - - interactionMutex[isZoomActive ? 'take' : 'release']('globalPan', zr); - - featureModel.setIconStatus('zoom', isZoomActive ? 'emphasis' : 'normal'); - - if (isZoomActive) { - zr.setDefaultCursorStyle('crosshair'); - - this._createController( - controllerGroup, featureModel, ecModel, api - ); - } - else { - zr.setDefaultCursorStyle('default'); - this._disposeController(); - } - }, - - back: function (controllerGroup, featureModel, ecModel, api) { - this._dispatchAction(history.pop(ecModel), api); - } - }; - - /** - * @private - */ - proto._createController = function ( - controllerGroup, featureModel, ecModel, api - ) { - var controller = this._controller = new SelectController( - 'rect', - api.getZr(), - { - // FIXME - lineWidth: 3, - stroke: '#333', - fill: 'rgba(0,0,0,0.2)' - } - ); - controller.on( - 'selectEnd', - zrUtil.bind( - this._onSelected, this, controller, - featureModel, ecModel, api - ) - ); - controller.enable(controllerGroup, false); - }; - - proto._disposeController = function () { - var controller = this._controller; - if (controller) { - controller.off('selected'); - controller.dispose(); - } - }; - - function prepareCoordInfo(grid, ecModel) { - // Default use the first axis. - // FIXME - var coordInfo = [ - {axisModel: grid.getAxis('x').model, axisIndex: 0}, // x - {axisModel: grid.getAxis('y').model, axisIndex: 0} // y - ]; - coordInfo.grid = grid; - - ecModel.eachComponent( - {mainType: 'dataZoom', subType: 'select'}, - function (dzModel, dataZoomIndex) { - if (isTheAxis('xAxis', coordInfo[0].axisModel, dzModel, ecModel)) { - coordInfo[0].dataZoomModel = dzModel; - } - if (isTheAxis('yAxis', coordInfo[1].axisModel, dzModel, ecModel)) { - coordInfo[1].dataZoomModel = dzModel; - } - } - ); - - return coordInfo; - } - - function isTheAxis(axisName, axisModel, dataZoomModel, ecModel) { - var axisIndex = dataZoomModel.get(axisName + 'Index'); - return axisIndex != null - && ecModel.getComponent(axisName, axisIndex) === axisModel; - } - - /** - * @private - */ - proto._onSelected = function (controller, featureModel, ecModel, api, selRanges) { - if (!selRanges.length) { - return; - } - var selRange = selRanges[0]; - - controller.update(); // remove cover - - var snapshot = {}; - - // FIXME - // polar - - ecModel.eachComponent('grid', function (gridModel, gridIndex) { - var grid = gridModel.coordinateSystem; - var coordInfo = prepareCoordInfo(grid, ecModel); - var selDataRange = pointToDataInCartesian(selRange, coordInfo); - - if (selDataRange) { - var xBatchItem = scaleCartesianAxis(selDataRange, coordInfo, 0, 'x'); - var yBatchItem = scaleCartesianAxis(selDataRange, coordInfo, 1, 'y'); - - xBatchItem && (snapshot[xBatchItem.dataZoomId] = xBatchItem); - yBatchItem && (snapshot[yBatchItem.dataZoomId] = yBatchItem); - } - }, this); - - history.push(ecModel, snapshot); - - this._dispatchAction(snapshot, api); - }; - - function pointToDataInCartesian(selRange, coordInfo) { - var grid = coordInfo.grid; - - var selRect = new BoundingRect( - selRange[0][0], - selRange[1][0], - selRange[0][1] - selRange[0][0], - selRange[1][1] - selRange[1][0] - ); - if (!selRect.intersect(grid.getRect())) { - return; - } - var cartesian = grid.getCartesian(coordInfo[0].axisIndex, coordInfo[1].axisIndex); - var dataLeftTop = cartesian.pointToData([selRange[0][0], selRange[1][0]], true); - var dataRightBottom = cartesian.pointToData([selRange[0][1], selRange[1][1]], true); - - return [ - asc([dataLeftTop[0], dataRightBottom[0]]), // x, using asc to handle inverse - asc([dataLeftTop[1], dataRightBottom[1]]) // y, using asc to handle inverse - ]; - } - - function scaleCartesianAxis(selDataRange, coordInfo, dimIdx, dimName) { - var dimCoordInfo = coordInfo[dimIdx]; - var dataZoomModel = dimCoordInfo.dataZoomModel; - - if (dataZoomModel) { - return { - dataZoomId: dataZoomModel.id, - startValue: selDataRange[dimIdx][0], - endValue: selDataRange[dimIdx][1] - }; - } - } - - /** - * @private - */ - proto._dispatchAction = function (snapshot, api) { - var batch = []; - - each(snapshot, function (batchItem) { - batch.push(batchItem); - }); - - batch.length && api.dispatchAction({ - type: 'dataZoom', - from: this.uid, - batch: zrUtil.clone(batch, true) - }); - }; - - function updateBackBtnStatus(featureModel, ecModel) { - featureModel.setIconStatus( - 'back', - history.count(ecModel) > 1 ? 'emphasis' : 'normal' - ); - } - - - require('../featureManager').register('dataZoom', DataZoom); - - - // Create special dataZoom option for select - require('../../../echarts').registerPreprocessor(function (option) { - if (!option) { - return; - } - - var dataZoomOpts = option.dataZoom || (option.dataZoom = []); - if (!zrUtil.isArray(dataZoomOpts)) { - dataZoomOpts = [dataZoomOpts]; - } - - var toolboxOpt = option.toolbox; - if (toolboxOpt) { - // Assume there is only one toolbox - if (zrUtil.isArray(toolboxOpt)) { - toolboxOpt = toolboxOpt[0]; - } - - if (toolboxOpt && toolboxOpt.feature) { - var dataZoomOpt = toolboxOpt.feature.dataZoom; - addForAxis('xAxis', dataZoomOpt); - addForAxis('yAxis', dataZoomOpt); - } - } - - function addForAxis(axisName, dataZoomOpt) { - if (!dataZoomOpt) { - return; - } - - var axisIndicesName = axisName + 'Index'; - var givenAxisIndices = dataZoomOpt[axisIndicesName]; - if (givenAxisIndices != null && !zrUtil.isArray(givenAxisIndices)) { - givenAxisIndices = givenAxisIndices === false ? [] : [givenAxisIndices]; - } - - forEachComponent(axisName, function (axisOpt, axisIndex) { - if (givenAxisIndices != null - && zrUtil.indexOf(givenAxisIndices, axisIndex) === -1 - ) { - return; - } - var newOpt = { - type: 'select', - $fromToolbox: true, - // Id for merge mapping. - id: DATA_ZOOM_ID_BASE + axisName + axisIndex - }; - // FIXME - // Only support one axis now. - newOpt[axisIndicesName] = axisIndex; - dataZoomOpts.push(newOpt); - }); - } - - function forEachComponent(mainType, cb) { - var opts = option[mainType]; - if (!zrUtil.isArray(opts)) { - opts = opts ? [opts] : []; - } - each(opts, cb); - } - }); - - return DataZoom; -}); -define('echarts/component/toolbox/feature/Restore',['require','../../dataZoom/history','../featureManager','../../../echarts'],function(require) { - - - var history = require('../../dataZoom/history'); - - function Restore(model) { - this.model = model; - } - - Restore.defaultOption = { - show: true, - icon: 'M3.8,33.4 M47,18.9h9.8V8.7 M56.3,20.1 C52.1,9,40.5,0.6,26.8,2.1C12.6,3.7,1.6,16.2,2.1,30.6 M13,41.1H3.1v10.2 M3.7,39.9c4.2,11.1,15.8,19.5,29.5,18 c14.2-1.6,25.2-14.1,24.7-28.5', - title: '还原' - }; - - var proto = Restore.prototype; - - proto.onclick = function (ecModel, api, type) { - history.clear(ecModel); - - api.dispatchAction({ - type: 'restore', - from: this.uid - }); - }; - - - require('../featureManager').register('restore', Restore); - - - require('../../../echarts').registerAction( - {type: 'restore', event: 'restore', update: 'prepareAndUpdate'}, - function (payload, ecModel) { - ecModel.resetOption('recreate'); - } - ); - - return Restore; -}); -define('echarts/component/toolbox',['require','./toolbox/ToolboxModel','./toolbox/ToolboxView','./toolbox/feature/SaveAsImage','./toolbox/feature/MagicType','./toolbox/feature/DataView','./toolbox/feature/DataZoom','./toolbox/feature/Restore'],function (require) { - - require('./toolbox/ToolboxModel'); - require('./toolbox/ToolboxView'); - - require('./toolbox/feature/SaveAsImage'); - require('./toolbox/feature/MagicType'); - require('./toolbox/feature/DataView'); - require('./toolbox/feature/DataZoom'); - require('./toolbox/feature/Restore'); -}); -define('zrender/vml/core',['require','exports','module','../core/env'],function (require, exports, module) { - -if (!require('../core/env').canvasSupported) { - var urn = 'urn:schemas-microsoft-com:vml'; - - var createNode; - var win = window; - var doc = win.document; - - var vmlInited = false; - - try { - !doc.namespaces.zrvml && doc.namespaces.add('zrvml', urn); - createNode = function (tagName) { - return doc.createElement(''); - }; - } - catch (e) { - createNode = function (tagName) { - return doc.createElement('<' + tagName + ' xmlns="' + urn + '" class="zrvml">'); - }; - } - - // From raphael - var initVML = function () { - if (vmlInited) { - return; - } - vmlInited = true; - - var styleSheets = doc.styleSheets; - if (styleSheets.length < 31) { - doc.createStyleSheet().addRule('.zrvml', 'behavior:url(#default#VML)'); - } - else { - // http://msdn.microsoft.com/en-us/library/ms531194%28VS.85%29.aspx - styleSheets[0].addRule('.zrvml', 'behavior:url(#default#VML)'); - } - }; - - // Not useing return to avoid error when converting to CommonJS module - module.exports = { - doc: doc, - initVML: initVML, - createNode: createNode - }; -} -}); -// http://www.w3.org/TR/NOTE-VML -// TODO Use proxy like svg instead of overwrite brush methods -define('zrender/vml/graphic',['require','../core/env','../core/vector','../core/BoundingRect','../core/PathProxy','../tool/color','../contain/text','../graphic/mixin/RectText','../graphic/Displayable','../graphic/Image','../graphic/Text','../graphic/Path','../graphic/Gradient','./core'],function (require) { - -if (!require('../core/env').canvasSupported) { - var vec2 = require('../core/vector'); - var BoundingRect = require('../core/BoundingRect'); - var CMD = require('../core/PathProxy').CMD; - var colorTool = require('../tool/color'); - var textContain = require('../contain/text'); - var RectText = require('../graphic/mixin/RectText'); - var Displayable = require('../graphic/Displayable'); - var ZImage = require('../graphic/Image'); - var Text = require('../graphic/Text'); - var Path = require('../graphic/Path'); - - var Gradient = require('../graphic/Gradient'); - - var vmlCore = require('./core'); - - var round = Math.round; - var sqrt = Math.sqrt; - var abs = Math.abs; - var cos = Math.cos; - var sin = Math.sin; - var mathMax = Math.max; - - var applyTransform = vec2.applyTransform; - - var comma = ','; - var imageTransformPrefix = 'progid:DXImageTransform.Microsoft'; - - var Z = 21600; - var Z2 = Z / 2; - - var ZLEVEL_BASE = 100000; - var Z_BASE = 1000; - - var initRootElStyle = function (el) { - el.style.cssText = 'position:absolute;left:0;top:0;width:1px;height:1px;'; - el.coordsize = Z + ',' + Z; - el.coordorigin = '0,0'; - }; - - var encodeHtmlAttribute = function (s) { - return String(s).replace(/&/g, '&').replace(/"/g, '"'); - }; - - var rgb2Str = function (r, g, b) { - return 'rgb(' + [r, g, b].join(',') + ')'; - }; - - var append = function (parent, child) { - if (child && parent && child.parentNode !== parent) { - parent.appendChild(child); - } - }; - - var remove = function (parent, child) { - if (child && parent && child.parentNode === parent) { - parent.removeChild(child); - } - }; - - var getZIndex = function (zlevel, z, z2) { - // z 的取值范围为 [0, 1000] - return (parseFloat(zlevel) || 0) * ZLEVEL_BASE + (parseFloat(z) || 0) * Z_BASE + z2; - }; - - var parsePercent = function (value, maxValue) { - if (typeof value === 'string') { - if (value.lastIndexOf('%') >= 0) { - return parseFloat(value) / 100 * maxValue; - } - return parseFloat(value); - } - return value; - }; - - /*************************************************** - * PATH - **************************************************/ - - var setColorAndOpacity = function (el, color, opacity) { - var colorArr = colorTool.parse(color); - opacity = +opacity; - if (isNaN(opacity)) { - opacity = 1; - } - if (colorArr) { - el.color = rgb2Str(colorArr[0], colorArr[1], colorArr[2]); - el.opacity = opacity * colorArr[3]; - } - }; - - var getColorAndAlpha = function (color) { - var colorArr = colorTool.parse(color); - return [ - rgb2Str(colorArr[0], colorArr[1], colorArr[2]), - colorArr[3] - ]; - }; - - var updateFillNode = function (el, style, zrEl) { - // TODO pattern - var fill = style.fill; - if (fill != null) { - // Modified from excanvas - if (fill instanceof Gradient) { - var gradientType; - var angle = 0; - var focus = [0, 0]; - // additional offset - var shift = 0; - // scale factor for offset - var expansion = 1; - var rect = zrEl.getBoundingRect(); - var rectWidth = rect.width; - var rectHeight = rect.height; - if (fill.type === 'linear') { - gradientType = 'gradient'; - var transform = zrEl.transform; - var p0 = [fill.x * rectWidth, fill.y * rectHeight]; - var p1 = [fill.x2 * rectWidth, fill.y2 * rectHeight]; - if (transform) { - applyTransform(p0, p0, transform); - applyTransform(p1, p1, transform); - } - var dx = p1[0] - p0[0]; - var dy = p1[1] - p0[1]; - angle = Math.atan2(dx, dy) * 180 / Math.PI; - // The angle should be a non-negative number. - if (angle < 0) { - angle += 360; - } - - // Very small angles produce an unexpected result because they are - // converted to a scientific notation string. - if (angle < 1e-6) { - angle = 0; - } - } - else { - gradientType = 'gradientradial'; - var p0 = [fill.x * rectWidth, fill.y * rectHeight]; - var transform = zrEl.transform; - var scale = zrEl.scale; - var width = rectWidth; - var height = rectHeight; - focus = [ - // Percent in bounding rect - (p0[0] - rect.x) / width, - (p0[1] - rect.y) / height - ]; - if (transform) { - applyTransform(p0, p0, transform); - } - - width /= scale[0] * Z; - height /= scale[1] * Z; - var dimension = mathMax(width, height); - shift = 2 * 0 / dimension; - expansion = 2 * fill.r / dimension - shift; - } - - // We need to sort the color stops in ascending order by offset, - // otherwise IE won't interpret it correctly. - var stops = fill.colorStops.slice(); - stops.sort(function(cs1, cs2) { - return cs1.offset - cs2.offset; - }); - - var length = stops.length; - // Color and alpha list of first and last stop - var colorAndAlphaList = []; - var colors = []; - for (var i = 0; i < length; i++) { - var stop = stops[i]; - var colorAndAlpha = getColorAndAlpha(stop.color); - colors.push(stop.offset * expansion + shift + ' ' + colorAndAlpha[0]); - if (i === 0 || i === length - 1) { - colorAndAlphaList.push(colorAndAlpha); - } - } - - if (length >= 2) { - var color1 = colorAndAlphaList[0][0]; - var color2 = colorAndAlphaList[1][0]; - var opacity1 = colorAndAlphaList[0][1] * style.opacity; - var opacity2 = colorAndAlphaList[1][1] * style.opacity; - - el.type = gradientType; - el.method = 'none'; - el.focus = '100%'; - el.angle = angle; - el.color = color1; - el.color2 = color2; - el.colors = colors.join(','); - // When colors attribute is used, the meanings of opacity and o:opacity2 - // are reversed. - el.opacity = opacity2; - // FIXME g_o_:opacity ? - el.opacity2 = opacity1; - } - if (gradientType === 'radial') { - el.focusposition = focus.join(','); - } - } - else { - // FIXME Change from Gradient fill to color fill - setColorAndOpacity(el, fill, style.opacity); - } - } - }; - - var updateStrokeNode = function (el, style) { - if (style.lineJoin != null) { - el.joinstyle = style.lineJoin; - } - if (style.miterLimit != null) { - el.miterlimit = style.miterLimit * Z; - } - if (style.lineCap != null) { - el.endcap = style.lineCap; - } - if (style.lineDash != null) { - el.dashstyle = style.lineDash.join(' '); - } - if (style.stroke != null && !(style.stroke instanceof Gradient)) { - setColorAndOpacity(el, style.stroke, style.opacity); - } - }; - - var updateFillAndStroke = function (vmlEl, type, style, zrEl) { - var isFill = type == 'fill'; - var el = vmlEl.getElementsByTagName(type)[0]; - // Stroke must have lineWidth - if (style[type] != null && style[type] !== 'none' && (isFill || (!isFill && style.lineWidth))) { - vmlEl[isFill ? 'filled' : 'stroked'] = 'true'; - // FIXME Remove before updating, or set `colors` will throw error - if (style[type] instanceof Gradient) { - remove(vmlEl, el); - } - if (!el) { - el = vmlCore.createNode(type); - } - - isFill ? updateFillNode(el, style, zrEl) : updateStrokeNode(el, style); - append(vmlEl, el); - } - else { - vmlEl[isFill ? 'filled' : 'stroked'] = 'false'; - remove(vmlEl, el); - } - }; - - var points = [[], [], []]; - var pathDataToString = function (data, m) { - var M = CMD.M; - var C = CMD.C; - var L = CMD.L; - var A = CMD.A; - var Q = CMD.Q; - - var str = []; - var nPoint; - var cmdStr; - var cmd; - var i; - var xi; - var yi; - for (i = 0; i < data.length;) { - cmd = data[i++]; - cmdStr = ''; - nPoint = 0; - switch (cmd) { - case M: - cmdStr = ' m '; - nPoint = 1; - xi = data[i++]; - yi = data[i++]; - points[0][0] = xi; - points[0][1] = yi; - break; - case L: - cmdStr = ' l '; - nPoint = 1; - xi = data[i++]; - yi = data[i++]; - points[0][0] = xi; - points[0][1] = yi; - break; - case Q: - case C: - cmdStr = ' c '; - nPoint = 3; - var x1 = data[i++]; - var y1 = data[i++]; - var x2 = data[i++]; - var y2 = data[i++]; - var x3; - var y3; - if (cmd === Q) { - // Convert quadratic to cubic using degree elevation - x3 = x2; - y3 = y2; - x2 = (x2 + 2 * x1) / 3; - y2 = (y2 + 2 * y1) / 3; - x1 = (xi + 2 * x1) / 3; - y1 = (yi + 2 * y1) / 3; - } - else { - x3 = data[i++]; - y3 = data[i++]; - } - points[0][0] = x1; - points[0][1] = y1; - points[1][0] = x2; - points[1][1] = y2; - points[2][0] = x3; - points[2][1] = y3; - - xi = x3; - yi = y3; - break; - case A: - var x = 0; - var y = 0; - var sx = 1; - var sy = 1; - var angle = 0; - if (m) { - // Extract SRT from matrix - x = m[4]; - y = m[5]; - sx = sqrt(m[0] * m[0] + m[1] * m[1]); - sy = sqrt(m[2] * m[2] + m[3] * m[3]); - angle = Math.atan2(-m[1] / sy, m[0] / sx); - } - - var cx = data[i++]; - var cy = data[i++]; - var rx = data[i++]; - var ry = data[i++]; - var startAngle = data[i++] + angle; - var endAngle = data[i++] + startAngle + angle; - // FIXME - // var psi = data[i++]; - i++; - var clockwise = data[i++]; - - var x0 = cx + cos(startAngle) * rx; - var y0 = cy + sin(startAngle) * ry; - - var x1 = cx + cos(endAngle) * rx; - var y1 = cy + sin(endAngle) * ry; - - var type = clockwise ? ' wa ' : ' at '; - - str.push( - type, - round(((cx - rx) * sx + x) * Z - Z2), comma, - round(((cy - ry) * sy + y) * Z - Z2), comma, - round(((cx + rx) * sx + x) * Z - Z2), comma, - round(((cy + ry) * sy + y) * Z - Z2), comma, - round((x0 * sx + x) * Z - Z2), comma, - round((y0 * sy + y) * Z - Z2), comma, - round((x1 * sx + x) * Z - Z2), comma, - round((y1 * sy + y) * Z - Z2) - ); - - xi = x1; - yi = y1; - break; - case CMD.R: - var p0 = points[0]; - var p1 = points[1]; - // x0, y0 - p0[0] = data[i++]; - p0[1] = data[i++]; - // x1, y1 - p1[0] = p0[0] + data[i++]; - p1[1] = p0[1] + data[i++]; - - if (m) { - applyTransform(p0, p0, m); - applyTransform(p1, p1, m); - } - - p0[0] = round(p0[0] * Z - Z2); - p1[0] = round(p1[0] * Z - Z2); - p0[1] = round(p0[1] * Z - Z2); - p1[1] = round(p1[1] * Z - Z2); - str.push( - // x0, y0 - ' m ', p0[0], comma, p0[1], - // x1, y0 - ' l ', p1[0], comma, p0[1], - // x1, y1 - ' l ', p1[0], comma, p1[1], - // x0, y1 - ' l ', p0[0], comma, p1[1] - ); - break; - case CMD.Z: - // FIXME Update xi, yi - str.push(' x '); - } - - if (nPoint > 0) { - str.push(cmdStr); - for (var k = 0; k < nPoint; k++) { - var p = points[k]; - - m && applyTransform(p, p, m); - // 不 round 会非常慢 - str.push( - round(p[0] * Z - Z2), comma, round(p[1] * Z - Z2), - k < nPoint - 1 ? comma : '' - ); - } - } - } - return str.join(''); - }; - - // Rewrite the original path method - Path.prototype.brush = function (vmlRoot) { - var style = this.style; - - var vmlEl = this._vmlEl; - if (!vmlEl) { - vmlEl = vmlCore.createNode('shape'); - initRootElStyle(vmlEl); - - this._vmlEl = vmlEl; - } - - updateFillAndStroke(vmlEl, 'fill', style, this); - updateFillAndStroke(vmlEl, 'stroke', style, this); - - var m = this.transform; - var needTransform = m != null; - var strokeEl = vmlEl.getElementsByTagName('stroke')[0]; - if (strokeEl) { - var lineWidth = style.lineWidth; - // Get the line scale. - // Determinant of this.m_ means how much the area is enlarged by the - // transformation. So its square root can be used as a scale factor - // for width. - if (needTransform && !style.strokeNoScale) { - var det = m[0] * m[3] - m[1] * m[2]; - lineWidth *= sqrt(abs(det)); - } - strokeEl.weight = lineWidth + 'px'; - } - - var path = this.path; - if (this.__dirtyPath) { - path.beginPath(); - this.buildPath(path, this.shape); - this.__dirtyPath = false; - } - - vmlEl.path = pathDataToString(path.data, this.transform); - - vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2); - - // Append to root - append(vmlRoot, vmlEl); - - // Text - if (style.text) { - this.drawRectText(vmlRoot, this.getBoundingRect()); - } - }; - - Path.prototype.onRemoveFromStorage = function (vmlRoot) { - remove(vmlRoot, this._vmlEl); - this.removeRectText(vmlRoot); - }; - - Path.prototype.onAddToStorage = function (vmlRoot) { - append(vmlRoot, this._vmlEl); - this.appendRectText(vmlRoot); - }; - - /*************************************************** - * IMAGE - **************************************************/ - var isImage = function (img) { - // FIXME img instanceof Image 如果 img 是一个字符串的时候,IE8 下会报错 - return (typeof img === 'object') && img.tagName && img.tagName.toUpperCase() === 'IMG'; - // return img instanceof Image; - }; - - // Rewrite the original path method - ZImage.prototype.brush = function (vmlRoot) { - var style = this.style; - var image = style.image; - - // Image original width, height - var ow; - var oh; - - if (isImage(image)) { - var src = image.src; - if (src === this._imageSrc) { - ow = this._imageWidth; - oh = this._imageHeight; - } - else { - var imageRuntimeStyle = image.runtimeStyle; - var oldRuntimeWidth = imageRuntimeStyle.width; - var oldRuntimeHeight = imageRuntimeStyle.height; - imageRuntimeStyle.width = 'auto'; - imageRuntimeStyle.height = 'auto'; - - // get the original size - ow = image.width; - oh = image.height; - - // and remove overides - imageRuntimeStyle.width = oldRuntimeWidth; - imageRuntimeStyle.height = oldRuntimeHeight; - - // Caching image original width, height and src - this._imageSrc = src; - this._imageWidth = ow; - this._imageHeight = oh; - } - image = src; - } - else { - if (image === this._imageSrc) { - ow = this._imageWidth; - oh = this._imageHeight; - } - } - if (!image) { - return; - } - - var x = style.x || 0; - var y = style.y || 0; - - var dw = style.width; - var dh = style.height; - - var sw = style.sWidth; - var sh = style.sHeight; - var sx = style.sx || 0; - var sy = style.sy || 0; - - var hasCrop = sw && sh; - - var vmlEl = this._vmlEl; - if (!vmlEl) { - // FIXME 使用 group 在 left, top 都不是 0 的时候就无法显示了。 - // vmlEl = vmlCore.createNode('group'); - vmlEl = vmlCore.doc.createElement('div'); - initRootElStyle(vmlEl); - - this._vmlEl = vmlEl; - } - - var vmlElStyle = vmlEl.style; - var hasRotation = false; - var m; - var scaleX = 1; - var scaleY = 1; - if (this.transform) { - m = this.transform; - scaleX = sqrt(m[0] * m[0] + m[1] * m[1]); - scaleY = sqrt(m[2] * m[2] + m[3] * m[3]); - - hasRotation = m[1] || m[2]; - } - if (hasRotation) { - // If filters are necessary (rotation exists), create them - // filters are bog-slow, so only create them if abbsolutely necessary - // The following check doesn't account for skews (which don't exist - // in the canvas spec (yet) anyway. - // From excanvas - var p0 = [x, y]; - var p1 = [x + dw, y]; - var p2 = [x, y + dh]; - var p3 = [x + dw, y + dh]; - applyTransform(p0, p0, m); - applyTransform(p1, p1, m); - applyTransform(p2, p2, m); - applyTransform(p3, p3, m); - - var maxX = mathMax(p0[0], p1[0], p2[0], p3[0]); - var maxY = mathMax(p0[1], p1[1], p2[1], p3[1]); - - var transformFilter = []; - transformFilter.push('M11=', m[0] / scaleX, comma, - 'M12=', m[2] / scaleY, comma, - 'M21=', m[1] / scaleX, comma, - 'M22=', m[3] / scaleY, comma, - 'Dx=', round(x * scaleX + m[4]), comma, - 'Dy=', round(y * scaleY + m[5])); - - vmlElStyle.padding = '0 ' + round(maxX) + 'px ' + round(maxY) + 'px 0'; - // FIXME DXImageTransform 在 IE11 的兼容模式下不起作用 - vmlElStyle.filter = imageTransformPrefix + '.Matrix(' - + transformFilter.join('') + ', SizingMethod=clip)'; - - } - else { - if (m) { - x = x * scaleX + m[4]; - y = y * scaleY + m[5]; - } - vmlElStyle.filter = ''; - vmlElStyle.left = round(x) + 'px'; - vmlElStyle.top = round(y) + 'px'; - } - - var imageEl = this._imageEl; - var cropEl = this._cropEl; - - if (! imageEl) { - imageEl = vmlCore.doc.createElement('div'); - this._imageEl = imageEl; - } - var imageELStyle = imageEl.style; - if (hasCrop) { - // Needs know image original width and height - if (! (ow && oh)) { - var tmpImage = new Image(); - var self = this; - tmpImage.onload = function () { - tmpImage.onload = null; - ow = tmpImage.width; - oh = tmpImage.height; - // Adjust image width and height to fit the ratio destinationSize / sourceSize - imageELStyle.width = round(scaleX * ow * dw / sw) + 'px'; - imageELStyle.height = round(scaleY * oh * dh / sh) + 'px'; - - // Caching image original width, height and src - self._imageWidth = ow; - self._imageHeight = oh; - self._imageSrc = image; - }; - tmpImage.src = image; - } - else { - imageELStyle.width = round(scaleX * ow * dw / sw) + 'px'; - imageELStyle.height = round(scaleY * oh * dh / sh) + 'px'; - } - - if (! cropEl) { - cropEl = vmlCore.doc.createElement('div'); - cropEl.style.overflow = 'hidden'; - this._cropEl = cropEl; - } - var cropElStyle = cropEl.style; - cropElStyle.width = round((dw + sx * dw / sw) * scaleX); - cropElStyle.height = round((dh + sy * dh / sh) * scaleY); - cropElStyle.filter = imageTransformPrefix + '.Matrix(Dx=' - + (-sx * dw / sw * scaleX) + ',Dy=' + (-sy * dh / sh * scaleY) + ')'; - - if (! cropEl.parentNode) { - vmlEl.appendChild(cropEl); - } - if (imageEl.parentNode != cropEl) { - cropEl.appendChild(imageEl); - } - } - else { - imageELStyle.width = round(scaleX * dw) + 'px'; - imageELStyle.height = round(scaleY * dh) + 'px'; - - vmlEl.appendChild(imageEl); - - if (cropEl && cropEl.parentNode) { - vmlEl.removeChild(cropEl); - this._cropEl = null; - } - } - - var filterStr = ''; - var alpha = style.opacity; - if (alpha < 1) { - filterStr += '.Alpha(opacity=' + round(alpha * 100) + ') '; - } - filterStr += imageTransformPrefix + '.AlphaImageLoader(src=' + image + ', SizingMethod=scale)'; - - imageELStyle.filter = filterStr; - - vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2); - - // Append to root - append(vmlRoot, vmlEl); - - // Text - if (style.text) { - this.drawRectText(vmlRoot, this.getBoundingRect()); - } - }; - - ZImage.prototype.onRemoveFromStorage = function (vmlRoot) { - remove(vmlRoot, this._vmlEl); - - this._vmlEl = null; - this._cropEl = null; - this._imageEl = null; - - this.removeRectText(vmlRoot); - }; - - ZImage.prototype.onAddToStorage = function (vmlRoot) { - append(vmlRoot, this._vmlEl); - this.appendRectText(vmlRoot); - }; - - - /*************************************************** - * TEXT - **************************************************/ - - var DEFAULT_STYLE_NORMAL = 'normal'; - - var fontStyleCache = {}; - var fontStyleCacheCount = 0; - var MAX_FONT_CACHE_SIZE = 100; - var fontEl = document.createElement('div'); - - var getFontStyle = function (fontString) { - var fontStyle = fontStyleCache[fontString]; - if (!fontStyle) { - // Clear cache - if (fontStyleCacheCount > MAX_FONT_CACHE_SIZE) { - fontStyleCacheCount = 0; - fontStyleCache = {}; - } - - var style = fontEl.style; - var fontFamily; - try { - style.font = fontString; - fontFamily = style.fontFamily.split(',')[0]; - } - catch (e) { - } - - fontStyle = { - style: style.fontStyle || DEFAULT_STYLE_NORMAL, - variant: style.fontVariant || DEFAULT_STYLE_NORMAL, - weight: style.fontWeight || DEFAULT_STYLE_NORMAL, - size: parseFloat(style.fontSize || 12) | 0, - family: fontFamily || 'Microsoft YaHei' - }; - - fontStyleCache[fontString] = fontStyle; - fontStyleCacheCount++; - } - return fontStyle; - }; - - var textMeasureEl; - // Overwrite measure text method - textContain.measureText = function (text, textFont) { - var doc = vmlCore.doc; - if (!textMeasureEl) { - textMeasureEl = doc.createElement('div'); - textMeasureEl.style.cssText = 'position:absolute;top:-20000px;left:0;' - + 'padding:0;margin:0;border:none;white-space:pre;'; - vmlCore.doc.body.appendChild(textMeasureEl); - } - - try { - textMeasureEl.style.font = textFont; - } catch (ex) { - // Ignore failures to set to invalid font. - } - textMeasureEl.innerHTML = ''; - // Don't use innerHTML or innerText because they allow markup/whitespace. - textMeasureEl.appendChild(doc.createTextNode(text)); - return { - width: textMeasureEl.offsetWidth - }; - }; - - var tmpRect = new BoundingRect(); - - var drawRectText = function (vmlRoot, rect, textRect, fromTextEl) { - - var style = this.style; - var text = style.text; - if (!text) { - return; - } - - var x; - var y; - var align = style.textAlign; - var fontStyle = getFontStyle(style.textFont); - // FIXME encodeHtmlAttribute ? - var font = fontStyle.style + ' ' + fontStyle.variant + ' ' + fontStyle.weight + ' ' - + fontStyle.size + 'px "' + fontStyle.family + '"'; - var baseline = style.textBaseline; - - textRect = textRect || textContain.getBoundingRect(text, font, align, baseline); - - // Transform rect to view space - var m = this.transform; - // Ignore transform for text in other element - if (m && !fromTextEl) { - tmpRect.copy(rect); - tmpRect.applyTransform(m); - rect = tmpRect; - } - - if (!fromTextEl) { - var textPosition = style.textPosition; - var distance = style.textDistance; - // Text position represented by coord - if (textPosition instanceof Array) { - x = rect.x + parsePercent(textPosition[0], rect.width); - y = rect.y + parsePercent(textPosition[1], rect.height); - - align = align || 'left'; - baseline = baseline || 'top'; - } - else { - var res = textContain.adjustTextPositionOnRect( - textPosition, rect, textRect, distance - ); - x = res.x; - y = res.y; - - // Default align and baseline when has textPosition - align = align || res.textAlign; - baseline = baseline || res.textBaseline; - } - } - else { - x = rect.x; - y = rect.y; - } - - var fontSize = fontStyle.size; - // 1.75 is an arbitrary number, as there is no info about the text baseline - var lineCount = (text + '').split('\n').length; // not precise. - switch (baseline) { - case 'hanging': - case 'top': - y += (fontSize / 1.75) * lineCount; - break; - case 'middle': - break; - default: - // case null: - // case 'alphabetic': - // case 'ideographic': - // case 'bottom': - y -= fontSize / 2.25; - break; - } - switch (align) { - case 'left': - break; - case 'center': - x -= textRect.width / 2; - break; - case 'right': - x -= textRect.width; - break; - // case 'end': - // align = elementStyle.direction == 'ltr' ? 'right' : 'left'; - // break; - // case 'start': - // align = elementStyle.direction == 'rtl' ? 'right' : 'left'; - // break; - // default: - // align = 'left'; - } - - var createNode = vmlCore.createNode; - - var textVmlEl = this._textVmlEl; - var pathEl; - var textPathEl; - var skewEl; - if (!textVmlEl) { - textVmlEl = createNode('line'); - pathEl = createNode('path'); - textPathEl = createNode('textpath'); - skewEl = createNode('skew'); - - // FIXME Why here is not cammel case - // Align 'center' seems wrong - textPathEl.style['v-text-align'] = 'left'; - - initRootElStyle(textVmlEl); - - pathEl.textpathok = true; - textPathEl.on = true; - - textVmlEl.from = '0 0'; - textVmlEl.to = '1000 0.05'; - - append(textVmlEl, skewEl); - append(textVmlEl, pathEl); - append(textVmlEl, textPathEl); - - this._textVmlEl = textVmlEl; - } - else { - // 这里是在前面 appendChild 保证顺序的前提下 - skewEl = textVmlEl.firstChild; - pathEl = skewEl.nextSibling; - textPathEl = pathEl.nextSibling; - } - - var coords = [x, y]; - var textVmlElStyle = textVmlEl.style; - // Ignore transform for text in other element - if (m && fromTextEl) { - applyTransform(coords, coords, m); - - skewEl.on = true; - - skewEl.matrix = m[0].toFixed(3) + comma + m[2].toFixed(3) + comma + - m[1].toFixed(3) + comma + m[3].toFixed(3) + ',0,0'; - - // Text position - skewEl.offset = (round(coords[0]) || 0) + ',' + (round(coords[1]) || 0); - // Left top point as origin - skewEl.origin = '0 0'; - - textVmlElStyle.left = '0px'; - textVmlElStyle.top = '0px'; - } - else { - skewEl.on = false; - textVmlElStyle.left = round(x) + 'px'; - textVmlElStyle.top = round(y) + 'px'; - } - - textPathEl.string = encodeHtmlAttribute(text); - // TODO - try { - textPathEl.style.font = font; - } - // Error font format - catch (e) {} - - updateFillAndStroke(textVmlEl, 'fill', { - fill: fromTextEl ? style.fill : style.textFill, - opacity: style.opacity - }, this); - updateFillAndStroke(textVmlEl, 'stroke', { - stroke: fromTextEl ? style.stroke : style.textStroke, - opacity: style.opacity, - lineDash: style.lineDash - }, this); - - textVmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2); - - // Attached to root - append(vmlRoot, textVmlEl); - }; - - var removeRectText = function (vmlRoot) { - remove(vmlRoot, this._textVmlEl); - this._textVmlEl = null; - }; - - var appendRectText = function (vmlRoot) { - append(vmlRoot, this._textVmlEl); - }; - - var list = [RectText, Displayable, ZImage, Path, Text]; - - // In case Displayable has been mixed in RectText - for (var i = 0; i < list.length; i++) { - var proto = list[i].prototype; - proto.drawRectText = drawRectText; - proto.removeRectText = removeRectText; - proto.appendRectText = appendRectText; - } - - Text.prototype.brush = function (root) { - var style = this.style; - if (style.text) { - this.drawRectText(root, { - x: style.x || 0, y: style.y || 0, - width: 0, height: 0 - }, this.getBoundingRect(), true); - } - }; - - Text.prototype.onRemoveFromStorage = function (vmlRoot) { - this.removeRectText(vmlRoot); - }; - - Text.prototype.onAddToStorage = function (vmlRoot) { - this.appendRectText(vmlRoot); - }; -} -}); -/** - * VML Painter. - * - * @module zrender/vml/Painter - */ - -define('zrender/vml/Painter',['require','../core/log','./core'],function (require) { - - var zrLog = require('../core/log'); - var vmlCore = require('./core'); - - function parseInt10(val) { - return parseInt(val, 10); - } - - /** - * @alias module:zrender/vml/Painter - */ - function VMLPainter(root, storage) { - - vmlCore.initVML(); - - this.root = root; - - this.storage = storage; - - var vmlViewport = document.createElement('div'); - - var vmlRoot = document.createElement('div'); - - vmlViewport.style.cssText = 'display:inline-block;overflow:hidden;position:relative;width:300px;height:150px;'; - - vmlRoot.style.cssText = 'position:absolute;left:0;top:0;'; - - root.appendChild(vmlViewport); - - this._vmlRoot = vmlRoot; - this._vmlViewport = vmlViewport; - - this.resize(); - - // Modify storage - var oldDelFromMap = storage.delFromMap; - var oldAddToMap = storage.addToMap; - storage.delFromMap = function (elId) { - var el = storage.get(elId); - - oldDelFromMap.call(storage, elId); - - if (el) { - el.onRemoveFromStorage && el.onRemoveFromStorage(vmlRoot); - } - }; - - storage.addToMap = function (el) { - // Displayable already has a vml node - el.onAddToStorage && el.onAddToStorage(vmlRoot); - - oldAddToMap.call(storage, el); - }; - - this._firstPaint = true; - } - - VMLPainter.prototype = { - - constructor: VMLPainter, - - /** - * @return {HTMLDivElement} - */ - getViewportRoot: function () { - return this._vmlViewport; - }, - - /** - * 刷新 - */ - refresh: function () { - - var list = this.storage.getDisplayList(true); - - this._paintList(list); - }, - - _paintList: function (list) { - var vmlRoot = this._vmlRoot; - for (var i = 0; i < list.length; i++) { - var el = list[i]; - if (el.__dirty && !el.invisible) { - el.beforeBrush && el.beforeBrush(); - el.brush(vmlRoot); - el.afterBrush && el.afterBrush(); - } - el.__dirty = false; - } - - if (this._firstPaint) { - // Detached from document at first time - // to avoid page refreshing too many times - - // FIXME 如果每次都先 removeChild 可能会导致一些填充和描边的效果改变 - this._vmlViewport.appendChild(vmlRoot); - this._firstPaint = false; - } - }, - - resize: function () { - var width = this._getWidth(); - var height = this._getHeight(); - - if (this._width != width && this._height != height) { - this._width = width; - this._height = height; - - var vmlViewportStyle = this._vmlViewport.style; - vmlViewportStyle.width = width + 'px'; - vmlViewportStyle.height = height + 'px'; - } - }, - - dispose: function () { - this.root.innerHTML = ''; - - this._vmlRoot = - this._vmlViewport = - this.storage = null; - }, - - getWidth: function () { - return this._width; - }, - - getHeight: function () { - return this._height; - }, - - _getWidth: function () { - var root = this.root; - var stl = root.currentStyle; - - return ((root.clientWidth || parseInt10(stl.width)) - - parseInt10(stl.paddingLeft) - - parseInt10(stl.paddingRight)) | 0; - }, - - _getHeight: function () { - var root = this.root; - var stl = root.currentStyle; - - return ((root.clientHeight || parseInt10(stl.height)) - - parseInt10(stl.paddingTop) - - parseInt10(stl.paddingBottom)) | 0; - } - }; - - // Not supported methods - function createMethodNotSupport(method) { - return function () { - zrLog('In IE8.0 VML mode painter not support method "' + method + '"'); - }; - } - - var notSupportedMethods = [ - 'getLayer', 'insertLayer', 'eachLayer', 'eachBuildinLayer', 'eachOtherLayer', 'getLayers', - 'modLayer', 'delLayer', 'clearLayer', 'toDataURL', 'pathToImage' - ]; - - for (var i = 0; i < notSupportedMethods.length; i++) { - var name = notSupportedMethods[i]; - VMLPainter.prototype[name] = createMethodNotSupport(name); - } - - return VMLPainter; -}); -define('zrender/vml/vml',['require','./graphic','../zrender','./Painter'],function (require) { - require('./graphic'); - require('../zrender').registerPainter('vml', require('./Painter')); -}); -var echarts = require('echarts'); - - -require("echarts/chart/line"); - -require("echarts/chart/bar"); - -require("echarts/chart/pie"); - -require("echarts/chart/scatter"); - -require("echarts/component/tooltip"); - -require("echarts/component/legend"); - -require("echarts/component/grid"); - -require("echarts/component/title"); - -require("echarts/component/markPoint"); - -require("echarts/component/markLine"); - -require("echarts/component/dataZoom"); - -require("echarts/component/toolbox"); - -require("zrender/vml/vml"); - - -return echarts; -})); +; \ No newline at end of file diff --git a/dist/echarts.common.min.js b/dist/echarts.common.min.js index ea04b4b877..470ca695c3 100644 --- a/dist/echarts.common.min.js +++ b/dist/echarts.common.min.js @@ -1,10 +1,27 @@ -!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():t.echarts=e()}(this,function(){var t,e;!function(){function i(t,e){if(!e)return t;if(0===t.indexOf(".")){var i=e.split("/"),n=t.split("/"),r=i.length-1,a=n.length,o=0,s=0;t:for(var l=0;a>l;l++)switch(n[l]){case"..":if(!(r>o))break t;o++,s++;break;case".":s++;break;default:break t}return i.length=r-o,n=n.slice(s),i.concat(n).join("/")}return t}function n(t){function e(e,o){if("string"==typeof e){var s=n[e];return s||(s=a(i(e,t)),n[e]=s),s}e instanceof Array&&(o=o||function(){},o.apply(this,r(e,o,t)))}var n={};return e}function r(e,n,r){for(var s=[],l=o[r],u=0,c=Math.min(e.length,n.length);c>u;u++){var h,d=i(e[u],r);switch(d){case"require":h=l&&l.require||t;break;case"exports":h=l.exports;break;case"module":h=l;break;default:h=a(d)}s.push(h)}return s}function a(t){var e=o[t];if(!e)throw new Error("No "+t);if(!e.defined){var i=e.factory,n=i.apply(this,r(e.deps||[],i,t));"undefined"!=typeof n&&(e.exports=n),e.defined=1}return e.exports}var o={};e=function(t,e,i){if(2===arguments.length&&(i=e,e=[],"function"!=typeof i)){var r=i;i=function(){return r}}o[t]={id:t,deps:e,factory:i,defined:0,exports:{},require:n(t)}},t=n("")}();var i="padding",n="../../echarts",r="coordDimToDataDim",a="getRect",o="dataToCoord",s="getLabel",l="../echarts",u="cartesian2d",c="getLineStyle",h="inverse",d="isHorizontal",f="getAxis",p="dataToPoint",m="getExtent",v="getOtherAxis",g="execute",y="getFormattedLabel",x="getItemStyle",_="circle",b="symbol",w="symbolSize",M="createSymbol",S="updateData",k="../../util/number",T="../../util/graphic",C="../../util/symbol",A="category",D="../../util/model",L="setItemGraphicEl",P="getItemVisual",z="setItemLayout",I="getItemLayout",O="getVisual",R="mapArray",B="getDataExtent",Z="dimensions",E="extendComponentView",N="extendComponentModel",V="registerVisualCoding",G="registerLayout",F="registerAction",W="registerProcessor",H="hostModel",q="eachComponent",j="dataZoom",U="itemStyle",X="eachSeries",Y="eachSeriesByType",$="setItemVisual",Q="setVisual",K="dispose",J="canvasSupported",tt="clientHeight",et="backgroundColor",it="appendChild",nt="innerHTML",rt="intersect",at="resize",ot="zlevel",st="getDisplayList",lt="storage",ut="parentNode",ct="offsetY",ht="offsetX",dt="mousemove",ft="zrender/core/event",pt="zrender/core/env",mt="initProps",vt="updateProps",gt="getTextColor",yt="mouseout",xt="mouseover",_t="setHoverStyle",bt="hoverStyle",wt="setStyle",Mt="subPixelOptimizeRect",St="extendShape",kt="Polyline",Tt="Sector",Ct="points",At="setData",Dt="setShape",Lt="restore",Pt="buildPath",zt="closePath",It="moveTo",Ot="beginPath",Rt="contain",Bt="textBaseline",Zt="textAlign",Et="textPosition",Nt="eachItemGraphicEl",Vt="indexOfName",Gt="getItemGraphicEl",Ft="dataIndex",Wt="trigger",Ht="render",qt="removeAll",jt="updateLayout",Ut="invisible",Xt="traverse",Yt="delFromMap",$t="addToMap",Qt="remove",Kt="__dirty",Jt="refresh",te="ignore",ee="draggable",ie="animate",ne="stopAnimation",re="animation",ae="zrender/tool/color",oe="target",se="transformCoordToLocal",le="rotate",ue="getLocalTransform",ce="parent",he="transform",de="rotation",fe="zrender/mixin/Eventful",pe="getBaseAxis",me="coordinateSystem",ve="addCommas",ge="getComponent",ye="register",xe="update",_e="dispatchAction",be="getHeight",we="getWidth",Me="getDom",Se="findComponents",ke="isString",Te="splice",Ce="series",Ae="mergeOption",De="mergeDefaultAndTheme",Le="getLayoutRect",Pe="vertical",ze="horizontal",Ie="childAt",Oe="position",Re="eachChild",Be="isObject",Ze="formatter",Ee="getDataParams",Ne="getItemModel",Ve="getName",Ge="getRawIndex",Fe="getRawValue",We="ordinal",He="getData",qe="seriesIndex",je="retrieve",Ue="normal",Xe="emphasis",Ye="defaultEmphasis",$e="normalizeToArray",Qe="axisIndex",Ke="radius",Je="option",ti="../util/clazz",ei="getFont",ii="getBoundingRect",ni="textStyle",ri="getModel",ai="ecModel",oi="defaults",si="inside",li="../core/BoundingRect",ui="../core/util",ci="zrender/contain/text",hi="create",di="height",fi="applyTransform",pi="zrender/core/BoundingRect",mi="zrender/core/matrix",vi="distance",gi="undefined",yi="zrender/core/vector",xi="opacity",_i="stroke",bi="lineWidth",wi="getShallow",Mi="getClass",Si="enableClassManagement",ki="inherits",Ti="superApply",Ci="extend",Ai="enableClassExtend",Di="isArray",Li="toUpperCase",Pi="toLowerCase",zi="getPixelPrecision",Ii="toFixed",Oi="bottom",Ri="middle",Bi="center",Zi="parsePercent",Ei="linearMap",Ni="replace",Vi="function",Gi="concat",Fi="number",Wi="string",Hi="indexOf",qi="getContext",ji="canvas",Ui="createElement",Xi="length",Yi="object",$i="filter",Qi="zrender/core/util",Ki="prototype",Ji="require";e("zrender/graphic/Gradient",[Ji],function(t){var e=function(t){this.colorStops=t||[]};return e[Ki]={constructor:e,addColorStop:function(t,e){this.colorStops.push({offset:t,color:e})}},e}),e(Qi,[Ji,"../graphic/Gradient"],function(t){function e(t){if(typeof t==Yi&&null!==t){var i=t;if(t instanceof Array){i=[];for(var n=0,r=t[Xi];r>n;n++)i[n]=e(t[n])}else if(!M(t)&&!S(t)){i={};for(var a in t)t.hasOwnProperty(a)&&(i[a]=e(t[a]))}return i}return t}function i(t,n,r){if(!w(n)||!w(t))return r?e(n):t;for(var a in n)if(n.hasOwnProperty(a)){var o=t[a],s=n[a];!w(s)||!w(o)||x(s)||x(o)||S(s)||S(o)||M(s)||M(o)?!r&&a in t||(t[a]=e(n[a],!0)):i(o,s,r)}return t}function n(t,e){for(var n=t[0],r=1,a=t[Xi];a>r;r++)n=i(n,t[r],e);return n}function r(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}function a(t,e,i){for(var n in e)e.hasOwnProperty(n)&&(i?null!=e[n]:null==t[n])&&(t[n]=e[n]);return t}function o(){return document[Ui](ji)}function s(){return A||(A=E.createCanvas()[qi]("2d")),A}function l(t,e){if(t){if(t[Hi])return t[Hi](e);for(var i=0,n=t[Xi];n>i;i++)if(t[i]===e)return i}return-1}function u(t,e){function i(){}var n=t[Ki];i[Ki]=e[Ki],t[Ki]=new i;for(var r in n)t[Ki][r]=n[r];t[Ki].constructor=t,t.superClass=e}function c(t,e,i){t=Ki in t?t[Ki]:t,e=Ki in e?e[Ki]:e,a(t,e,i)}function h(t){return t?typeof t==Wi?!1:typeof t[Xi]==Fi:void 0}function d(t,e,i){if(t&&e)if(t.forEach&&t.forEach===I)t.forEach(e,i);else if(t[Xi]===+t[Xi])for(var n=0,r=t[Xi];r>n;n++)e.call(i,t[n],n,t);else for(var a in t)t.hasOwnProperty(a)&&e.call(i,t[a],a,t)}function f(t,e,i){if(t&&e){if(t.map&&t.map===B)return t.map(e,i);for(var n=[],r=0,a=t[Xi];a>r;r++)n.push(e.call(i,t[r],r,t));return n}}function p(t,e,i,n){if(t&&e){if(t.reduce&&t.reduce===Z)return t.reduce(e,i,n);for(var r=0,a=t[Xi];a>r;r++)i=e.call(n,i,t[r],r,t);return i}}function m(t,e,i){if(t&&e){if(t[$i]&&t[$i]===O)return t[$i](e,i);for(var n=[],r=0,a=t[Xi];a>r;r++)e.call(i,t[r],r,t)&&n.push(t[r]);return n}}function v(t,e,i){if(t&&e)for(var n=0,r=t[Xi];r>n;n++)if(e.call(i,t[n],n,t))return t[n]}function g(t,e){var i=R.call(arguments,2);return function(){return t.apply(e,i[Gi](R.call(arguments)))}}function y(t){var e=R.call(arguments,1);return function(){return t.apply(this,e[Gi](R.call(arguments)))}}function x(t){return"[object Array]"===P.call(t)}function _(t){return typeof t===Vi}function b(t){return"[object String]"===P.call(t)}function w(t){var e=typeof t;return e===Vi||!!t&&e==Yi}function M(t){return!!L[P.call(t)]||t instanceof D}function S(t){return t&&1===t.nodeType&&typeof t.nodeName==Wi}function k(t){for(var e=0,i=arguments[Xi];i>e;e++)if(null!=arguments[e])return arguments[e]}function T(){return Function.call.apply(R,arguments)}function C(t,e){if(!t)throw new Error(e)}var A,D=t("../graphic/Gradient"),L={"[object Function]":1,"[object RegExp]":1,"[object Date]":1,"[object Error]":1,"[object CanvasGradient]":1},P=Object[Ki].toString,z=Array[Ki],I=z.forEach,O=z[$i],R=z.slice,B=z.map,Z=z.reduce,E={inherits:u,mixin:c,clone:e,merge:i,mergeAll:n,extend:r,defaults:a,getContext:s,createCanvas:o,indexOf:l,slice:T,find:v,isArrayLike:h,each:d,map:f,reduce:p,filter:m,bind:g,curry:y,isArray:x,isString:b,isObject:w,isFunction:_,isBuildInObject:M,isDom:S,retrieve:k,assert:C,noop:function(){}};return E}),e("echarts/util/number",[Ji],function(t){function e(t){return t[Ni](/^\s+/,"")[Ni](/\s+$/,"")}var i={},n=1e-4;return i[Ei]=function(t,e,i,n){var r=e[1]-e[0];if(0===r)return(i[0]+i[1])/2;var a=(t-e[0])/r;return n&&(a=Math.min(Math.max(a,0),1)),a*(i[1]-i[0])+i[0]},i[Zi]=function(t,i){switch(t){case Bi:case Ri:t="50%";break;case"left":case"top":t="0%";break;case"right":case Oi:t="100%"}return typeof t===Wi?e(t).match(/%$/)?parseFloat(t)/100*i:parseFloat(t):null==t?NaN:+t},i.round=function(t){return+(+t)[Ii](12)},i.asc=function(t){return t.sort(function(t,e){return t-e}),t},i.getPrecision=function(t){for(var e=1,i=0;Math.round(t*e)/e!==t;)e*=10,i++;return i},i[zi]=function(t,e){var i=Math.log,n=Math.LN10,r=Math.floor(i(t[1]-t[0])/n),a=Math.round(i(Math.abs(e[1]-e[0]))/n);return Math.max(-r+a,0)},i.MAX_SAFE_INTEGER=9007199254740991,i.remRadian=function(t){var e=2*Math.PI;return(t%e+e)%e},i.isRadianAroundZero=function(t){return t>-n&&n>t},i.parseDate=function(t){return t instanceof Date?t:new Date(typeof t===Wi?t[Ni](/-/g,"/"):Math.round(t))},i}),e("echarts/util/format",[Ji,Qi,"./number"],function(t){function e(t){return isNaN(t)?"-":(t=(t+"").split("."),t[0][Ni](/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,"$1,")+(t[Xi]>1?"."+t[1]:""))}function i(t){return t[Pi]()[Ni](/-(.)/g,function(t,e){return e[Li]()})}function n(t){var e=t[Xi];return typeof t===Fi?[t,t,t,t]:2===e?[t[0],t[1],t[0],t[1]]:3===e?[t[0],t[1],t[2],t[1]]:t}function r(t){return String(t)[Ni](/&/g,"&")[Ni](//g,">")[Ni](/"/g,""")[Ni](/'/g,"'")}function a(t,e){return"{"+t+(null==e?"":e)+"}"}function o(t,e){u[Di](e)||(e=[e]);var i=e[Xi];if(!i)return"";for(var n=e[0].$vars,r=0;rs;s++)for(var l=0;lt?"0"+t:t}var u=t(Qi),c=t("./number"),h=["a","b","c","d","e","f","g"];return{normalizeCssArray:n,addCommas:e,toCamelCase:i,encodeHTML:r,formatTpl:o,formatTime:s}}),e("echarts/util/clazz",[Ji,Qi],function(t){function e(t,e){var i=n.slice(arguments,2);return this.superClass[Ki][e].apply(t,i)}function i(t,e,i){return this.superClass[Ki][e].apply(t,i)}var n=t(Qi),r={},a=".",o="___EC__COMPONENT__CONTAINER___",s=r.parseClassType=function(t){var e={main:"",sub:""};return t&&(t=t.split(a),e.main=t[0]||"",e.sub=t[1]||""),e};return r[Ai]=function(t,r){t[Ci]=function(a){var o=function(){r&&r.apply(this,arguments),t.apply(this,arguments)};return n[Ci](o[Ki],a),o[Ci]=this[Ci],o.superCall=e,o[Ti]=i,n[ki](o,this),o.superClass=this,o}},r[Si]=function(t,e){function i(t){var e=r[t.main];return e&&e[o]||(e=r[t.main]={},e[o]=!0),e}e=e||{};var r={};if(t.registerClass=function(t,e){if(e)if(e=s(e),e.sub){if(e.sub!==o){var n=i(e);n[e.sub]=t}}else{if(r[e.main])throw new Error(e.main+"exists");r[e.main]=t}return t},t[Mi]=function(t,e,i){var n=r[t];if(n&&n[o]&&(n=e?n[e]:null),i&&!n)throw new Error("Component "+t+"."+(e||"")+" not exists");return n},t.getClassesByMainType=function(t){t=s(t);var e=[],i=r[t.main];return i&&i[o]?n.each(i,function(t,i){i!==o&&e.push(t)}):e.push(i),e},t.hasClass=function(t){return t=s(t),!!r[t.main]},t.getAllClassMainTypes=function(){var t=[];return n.each(r,function(e,i){t.push(i)}),t},t.hasSubTypes=function(t){t=s(t);var e=r[t.main];return e&&e[o]},t.parseClassType=s,e.registerWhenExtend){var a=t[Ci];a&&(t[Ci]=function(e){var i=a.call(this,e);return t.registerClass(i,e.type)})}return t},r.setReadOnly=function(t,e){},r}),e("echarts/model/mixin/makeStyleMapper",[Ji,Qi],function(t){var e=t(Qi);return function(t){for(var i=0;i=0)){var o=this[wi](a);null!=o&&(n[t[r][0]]=o)}}return n}}}),e("echarts/model/mixin/lineStyle",[Ji,"./makeStyleMapper"],function(t){var e=t("./makeStyleMapper")([[bi,"width"],[_i,"color"],[xi],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]]);return{getLineStyle:function(t){var i=e.call(this,t),n=this.getLineDash();return n&&(i.lineDash=n),i},getLineDash:function(){var t=this.get("type");return"solid"===t||null==t?null:"dashed"===t?[5,5]:[1,1]}}}),e("echarts/model/mixin/areaStyle",[Ji,"./makeStyleMapper"],function(t){return{getAreaStyle:t("./makeStyleMapper")([["fill","color"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],[xi],["shadowColor"]])}}),e(yi,[],function(){var t=typeof Float32Array===gi?Array:Float32Array,e={create:function(e,i){var n=new t(2);return n[0]=e||0,n[1]=i||0,n},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t},clone:function(e){var i=new t(2);return i[0]=e[0],i[1]=e[1],i},set:function(t,e,i){return t[0]=e,t[1]=i,t},add:function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t},scaleAndAdd:function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t},sub:function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t},len:function(t){return Math.sqrt(this.lenSquare(t))},lenSquare:function(t){return t[0]*t[0]+t[1]*t[1]},mul:function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t},div:function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},scale:function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},normalize:function(t,i){var n=e.len(i);return 0===n?(t[0]=0,t[1]=0):(t[0]=i[0]/n,t[1]=i[1]/n),t},distance:function(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))},distanceSquare:function(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])},negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},lerp:function(t,e,i,n){return t[0]=e[0]+n*(i[0]-e[0]),t[1]=e[1]+n*(i[1]-e[1]),t},applyTransform:function(t,e,i){var n=e[0],r=e[1];return t[0]=i[0]*n+i[2]*r+i[4],t[1]=i[1]*n+i[3]*r+i[5],t},min:function(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t},max:function(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t}};return e[Xi]=e.len,e.lengthSquare=e.lenSquare,e.dist=e[vi],e.distSquare=e.distanceSquare,e}),e(mi,[],function(){var t=typeof Float32Array===gi?Array:Float32Array,e={create:function(){var i=new t(6);return e.identity(i),i},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},mul:function(t,e,i){var n=e[0]*i[0]+e[2]*i[1],r=e[1]*i[0]+e[3]*i[1],a=e[0]*i[2]+e[2]*i[3],o=e[1]*i[2]+e[3]*i[3],s=e[0]*i[4]+e[2]*i[5]+e[4],l=e[1]*i[4]+e[3]*i[5]+e[5];return t[0]=n,t[1]=r,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t},translate:function(t,e,i){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4]+i[0],t[5]=e[5]+i[1],t},rotate:function(t,e,i){var n=e[0],r=e[2],a=e[4],o=e[1],s=e[3],l=e[5],u=Math.sin(i),c=Math.cos(i);return t[0]=n*c+o*u,t[1]=-n*u+o*c,t[2]=r*c+s*u,t[3]=-r*u+c*s,t[4]=c*a+u*l,t[5]=c*l-u*a,t},scale:function(t,e,i){var n=i[0],r=i[1];return t[0]=e[0]*n,t[1]=e[1]*r,t[2]=e[2]*n,t[3]=e[3]*r,t[4]=e[4]*n,t[5]=e[5]*r,t},invert:function(t,e){var i=e[0],n=e[2],r=e[4],a=e[1],o=e[3],s=e[5],l=i*o-a*n;return l?(l=1/l,t[0]=o*l,t[1]=-a*l,t[2]=-n*l,t[3]=i*l,t[4]=(n*s-o*r)*l,t[5]=(a*r-i*s)*l,t):null}};return e}),e(pi,[Ji,"./vector","./matrix"],function(t){function e(t,e,i,n){this.x=t,this.y=e,this.width=i,this[di]=n}var i=t("./vector"),n=t("./matrix"),r=i[fi],a=Math.min,o=Math.abs,s=Math.max;return e[Ki]={constructor:e,union:function(t){var e=a(t.x,this.x),i=a(t.y,this.y);this.width=s(t.x+t.width,this.x+this.width)-e,this[di]=s(t.y+t[di],this.y+this[di])-i,this.x=e,this.y=i},applyTransform:function(){var t=[],e=[];return function(i){i&&(t[0]=this.x,t[1]=this.y,e[0]=this.x+this.width,e[1]=this.y+this[di],r(t,t,i),r(e,e,i),this.x=a(t[0],e[0]),this.y=a(t[1],e[1]),this.width=o(e[0]-t[0]),this[di]=o(e[1]-t[1]))}}(),calculateTransform:function(t){var e=this,i=t.width/e.width,r=t[di]/e[di],a=n[hi]();return n.translate(a,a,[-e.x,-e.y]),n.scale(a,a,[i,r]),n.translate(a,a,[t.x,t.y]),a},intersect:function(t){var e=this,i=e.x,n=e.x+e.width,r=e.y,a=e.y+e[di],o=t.x,s=t.x+t.width,l=t.y,u=t.y+t[di];return!(o>n||i>s||l>a||r>u)},contain:function(t,e){var i=this;return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i[di]},clone:function(){return new e(this.x,this.y,this.width,this[di])},copy:function(t){this.x=t.x,this.y=t.y,this.width=t.width,this[di]=t[di]}},e}),e(ci,[Ji,ui,li],function(t){function e(t,e){var i=t+":"+e;if(s[i])return s[i];for(var n=(t+"").split("\n"),r=0,a=0,o=n[Xi];o>a;a++)r=Math.max(d.measureText(n[a],e).width,r);return l>u&&(l=0,s={}),l++,s[i]=r,r}function i(t,i,n,r){var a=((t||"")+"").split("\n")[Xi],o=e(t,i),s=e("国",i),l=a*s,u=new h(0,0,o,l);switch(u.lineHeight=s,r){case Oi:case"alphabetic":u.y-=s;break;case Ri:u.y-=s/2}switch(n){case"end":case"right":u.x-=u.width;break;case Bi:u.x-=u.width/2}return u}function n(t,e,i,n){var r=e.x,a=e.y,o=e[di],s=e.width,l=i[di],u=o/2-l/2,c="left";switch(t){case"left":r-=n,a+=u,c="right";break;case"right":r+=n+s,a+=u,c="left";break;case"top":r+=s/2,a-=n+l,c=Bi;break;case Oi:r+=s/2,a+=o+n,c=Bi;break;case si:r+=s/2,a+=u,c=Bi;break;case"insideLeft":r+=n,a+=u,c="left";break;case"insideRight":r+=s-n,a+=u,c="right";break;case"insideTop":r+=s/2,a+=n,c=Bi;break;case"insideBottom":r+=s/2,a+=o-l-n,c=Bi;break;case"insideTopLeft":r+=n,a+=n,c="left";break;case"insideTopRight":r+=s-n,a+=n,c="right";break;case"insideBottomLeft":r+=n,a+=o-l-n;break;case"insideBottomRight":r+=s-n,a+=o-l-n,c="right"}return{x:r,y:a,textAlign:c,textBaseline:"top"}}function r(t,i,n,r){if(!n)return"";r=c[oi]({ellipsis:"...",minCharacters:3,maxIterations:3,cnCharWidth:e("国",i),ascCharWidth:e("a",i)},r,!0),n-=e(r.ellipsis);for(var o=(t+"").split("\n"),s=0,l=o[Xi];l>s;s++)o[s]=a(o[s],i,n,r);return o.join("\n")}function a(t,i,n,r){for(var a=0;;a++){var s=e(t,i);if(n>s||a>=r.maxIterations){t+=r.ellipsis;break}var l=0===a?o(t,n,r):Math.floor(t[Xi]*n/s);if(lr&&e>n;r++){var o=t.charCodeAt(r);n+=o>=0&&127>=o?i.ascCharWidth:i.cnCharWidth}return r}var s={},l=0,u=5e3,c=t(ui),h=t(li),d={getWidth:e,getBoundingRect:i,adjustTextPositionOnRect:n,ellipsis:r,measureText:function(t,e){var i=c[qi]();return i.font=e,i.measureText(t)}};return d}),e("echarts/model/mixin/textStyle",[Ji,ci],function(t){function e(t,e){return t&&t[wi](e)}var i=t(ci);return{getTextColor:function(){var t=this[ai];return this[wi]("color")||t&&t.get("textStyle.color")},getFont:function(){var t=this[ai],i=t&&t[ri](ni);return[this[wi]("fontStyle")||e(i,"fontStyle"),this[wi]("fontWeight")||e(i,"fontWeight"),(this[wi]("fontSize")||e(i,"fontSize")||12)+"px",this[wi]("fontFamily")||e(i,"fontFamily")||"sans-serif"].join(" ")},getTextRect:function(t){var e=this.get(ni)||{};return i[ii](t,this[ei](),e.align,e.baseline)},ellipsis:function(t,e,n){return i.ellipsis(t,this[ei](),e,n)}}}),e("echarts/model/mixin/itemStyle",[Ji,"./makeStyleMapper"],function(t){return{getItemStyle:t("./makeStyleMapper")([["fill","color"],[_i,"borderColor"],[bi,"borderWidth"],[xi],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]])}}),e("echarts/model/Model",[Ji,Qi,ti,"./mixin/lineStyle","./mixin/areaStyle","./mixin/textStyle","./mixin/itemStyle"],function(t){function e(t,e,i,n){this.parentModel=e,this[ai]=i,this[Je]=t,this.init&&(arguments[Xi]<=4?this.init(t,e,i,n):this.init.apply(this,arguments))}var i=t(Qi),n=t(ti);e[Ki]={constructor:e,init:null,mergeOption:function(t){i.merge(this[Je],t,!0)},get:function(t,e){if(!t)return this[Je];typeof t===Wi&&(t=t.split("."));for(var i=this[Je],n=this.parentModel,r=0;r=0}function a(t,r){var a=!1;return e(function(e){n.each(i(t,e)||[],function(t){r.records[e.name][t]&&(a=!0)})}),a}function o(t,r){r.nodes.push(t),e(function(e){n.each(i(t,e)||[],function(t){r.records[e.name][t]=!0})})}return function(i){function n(t){!r(t,s)&&a(t,s)&&(o(t,s),l=!0)}var s={nodes:[],records:{}};if(e(function(t){s.records[t.name]={}}),!i)return s;o(i,s);var l;do l=!1,t(n);while(l);return s}},o[Ye]=function(t,e){if(t){var i=t[Xe]=t[Xe]||{},r=t[Ue]=t[Ue]||{};n.each(e,function(t){var e=n[je](i[t],r[t]);null!=e&&(i[t]=e)})}},o.createDataFormatModel=function(t,e,i){var a=new r;return n.mixin(a,o.dataFormatMixin),a[qe]=t[qe],a.name=t.name||"",a[He]=function(){return e},a.getRawDataArray=function(){return i},a},o.getDataItemValue=function(t){return t&&(null==t.value?t:t.value)},o.converDataValue=function(t,e){var n=e&&e.type;return n===We?t:("time"!==n||isFinite(t)||null==t||"-"===t||(t=+i.parseDate(t)),null==t||""===t?NaN:+t)},o.dataFormatMixin={getDataParams:function(t){var e=this[He](),i=this[qe],n=this.name,r=this[Fe](t),a=e[Ge](t),o=e[Ve](t,!0),s=this.getRawDataArray(),l=s&&s[a];return{seriesIndex:i,seriesName:n,name:o,dataIndex:a,data:l,value:r,$vars:["seriesName","name","value"]}},getFormattedLabel:function(t,i,n){i=i||Ue;var r=this[He](),a=r[Ne](t),o=this[Ee](t);return null==n&&(n=a.get(["label",i,Ze])),typeof n===Vi?(o.status=i,n(o)):typeof n===Wi?e.formatTpl(n,o):void 0},getRawValue:function(t){var e=this[He]()[Ne](t);if(e&&null!=e[Je]){var i=e[Je];return n[Be](i)&&!n[Di](i)?i.value:i}}},o.mappingToExists=function(t,e){e=(e||[]).slice();var i=n.map(t||[],function(t,e){return{exist:t}});return n.each(e,function(t,r){if(n[Be](t))for(var a=0;a=i[Xi]&&i.push({option:t})}}),i},o.isIdInner=function(t){return n[Be](t)&&t.id&&0===(t.id+"")[Hi]("\x00_ec_\x00")},o}),e("echarts/util/component",[Ji,Qi,"./clazz"],function(t){var e=t(Qi),i=t("./clazz"),n=i.parseClassType,r=0,a={},o="_";return a.getUID=function(t){return[t||"",r++,Math.random()].join(o)},a.enableSubTypeDefaulter=function(t){var e={};return t.registerSubTypeDefaulter=function(t,i){t=n(t),e[t.main]=i},t.determineSubType=function(i,r){var a=r.type;if(!a){var o=n(i).main;t.hasSubTypes(i)&&e[o]&&(a=e[o](r))}return a},t},a.enableTopologicalTravel=function(t,i){function n(t){var n={},o=[];return e.each(t,function(s){var l=r(n,s),u=l.originalDeps=i(s),c=a(u,t);l.entryCount=c[Xi],0===l.entryCount&&o.push(s),e.each(c,function(t){e[Hi](l.predecessor,t)<0&&l.predecessor.push(t);var i=r(n,t);e[Hi](i.successor,t)<0&&i.successor.push(s)})}),{graph:n,noEntryList:o}}function r(t,e){return t[e]||(t[e]={predecessor:[],successor:[]}),t[e]}function a(t,i){var n=[];return e.each(t,function(t){e[Hi](i,t)>=0&&n.push(t)}),n}t.topologicalTravel=function(t,i,r,a){function o(t){u[t].entryCount--,0===u[t].entryCount&&c.push(t)}function s(t){h[t]=!0,o(t)}if(t[Xi]){var l=n(i),u=l.graph,c=l.noEntryList,h={};for(e.each(t,function(t){h[t]=!0});c[Xi];){var d=c.pop(),f=u[d],p=!!h[d];p&&(r.call(a,d,f.originalDeps.slice()),delete h[d]),e.each(f.successor,p?s:o)}e.each(h,function(){throw new Error("Circle dependency may exists")})}}},a}),e("echarts/util/layout",[Ji,Qi,pi,"./number","./format"],function(t){function e(t,e,i,n,r){var a=0,o=0;null==n&&(n=1/0),null==r&&(r=1/0);var s=0;e[Re](function(l,u){var c,h,d=l[Oe],f=l[ii](),p=e[Ie](u+1),m=p&&p[ii]();if(t===ze){var v=f.width+(m?-m.x+f.x:0);c=a+v,c>n||l.newline?(a=0,c=v,o+=s+i,s=f[di]):s=Math.max(s,f[di])}else{var g=f[di]+(m?-m.y+f.y:0);h=o+g,h>r||l.newline?(a+=s+i,o=0,h=g,s=f.width):s=Math.max(s,f.width)}l.newline||(d[0]=a,d[1]=o,t===ze?a=c+i:o=h+i)})}var i=t(Qi),n=t(pi),r=t("./number"),a=t("./format"),o=r[Zi],s=i.each,l={},u=["left","right","top",Oi,"width",di];return l.box=e,l.vbox=i.curry(e,Pe),l.hbox=i.curry(e,ze),l.getAvailableSize=function(t,e,i){var n=e.width,r=e[di],s=o(t.x,n),l=o(t.y,r),u=o(t.x2,n),c=o(t.y2,r);return(isNaN(s)||isNaN(parseFloat(t.x)))&&(s=0),(isNaN(u)||isNaN(parseFloat(t.x2)))&&(u=n),(isNaN(l)||isNaN(parseFloat(t.y)))&&(l=0),(isNaN(c)||isNaN(parseFloat(t.y2)))&&(c=r),i=a.normalizeCssArray(i||0),{width:Math.max(u-s-i[1]-i[3],0),height:Math.max(c-l-i[0]-i[2],0)}},l[Le]=function(t,e,i){i=a.normalizeCssArray(i||0);var r=e.width,s=e[di],l=o(t.left,r),u=o(t.top,s),c=o(t.right,r),h=o(t[Oi],s),d=o(t.width,r),f=o(t[di],s),p=i[2]+i[0],m=i[1]+i[3],v=t.aspect;switch(isNaN(d)&&(d=r-c-m-l),isNaN(f)&&(f=s-h-p-u),isNaN(d)&&isNaN(f)&&(v>r/s?d=.8*r:f=.8*s),null!=v&&(isNaN(d)&&(d=v*f),isNaN(f)&&(f=d/v)),isNaN(l)&&(l=r-c-d-m),isNaN(u)&&(u=s-h-f-p),t.left||t.right){case Bi:l=r/2-d/2-i[3];break;case"right":l=r-d-m}switch(t.top||t[Oi]){case Ri:case Bi:u=s/2-f/2-i[0];break;case Oi:u=s-f-p}l=l||0,u=u||0,isNaN(d)&&(d=r-l-(c||0)),isNaN(f)&&(f=s-u-(h||0));var g=new n(l+i[3],u+i[0],d,f);return g.margin=i,g},l.positionGroup=function(t,e,n,r){var a=t[ii]();e=i[Ci](i.clone(e),{width:a.width,height:a[di]}),e=l[Le](e,n,r),t[Oe]=[e.x-a.x,e.y-a.y]},l.mergeLayoutParam=function(t,e,n){function r(i){var r={},l=0,u={},c=0,h=n.ignoreSize?1:2;if(s(i,function(e){u[e]=t[e]}),s(i,function(t){a(e,t)&&(r[t]=u[t]=e[t]),o(r,t)&&l++,o(u,t)&&c++}),c!==h&&l){if(l>=h)return r;for(var d=0;d=0;a--)r=n.merge(r,t[a],!0);this.__defaultOption=r}return this.__defaultOption}});return o[Ai](l,function(t,e,i,r){n[Ci](this,r),this.uid=a.getUID("componentModel"),this.setReadOnly(["type","id","uid","name","mainType","subType","dependentModels","componentIndex"])}),o[Si](l,{registerWhenExtend:!0}),a.enableSubTypeDefaulter(l),a.enableTopologicalTravel(l,e),n.mixin(l,t("./mixin/boxLayout")),l}),e("echarts/model/globalDefault",[],function(){var t="";return typeof navigator!==gi&&(t=navigator.platform||""),{color:["#c23531","#314656","#61a0a8","#dd8668","#91c7ae","#6e7074","#ca8622","#bda29a","#44525d","#c4ccd3"],grid:{},textStyle:{fontFamily:t.match(/^Win/)?"Microsoft YaHei":"sans-serif",fontSize:12,fontStyle:"normal",fontWeight:"normal"},animation:!0,animationThreshold:2e3,animationDuration:1e3,animationDurationUpdate:300,animationEasing:"exponentialOut",animationEasingUpdate:"cubicOut"}}),e("echarts/model/Global",[Ji,Qi,"../util/model","./Model","./Component","./globalDefault"],function(t){function e(t,e){for(var i in e)y.hasClass(i)||(typeof e[i]===Yi?t[i]=t[i]?u.merge(t[i],e[i],!1):u.clone(e[i]):t[i]=e[i])}function i(t){t=t,this[Je]={},this[Je][_]=1,this._componentsMap={},this._seriesIndices=null,e(t,this._theme[Je]),u.merge(t,x,!1),this[Ae](t)}function n(t,e){u[Di](e)||(e=e?[e]:[]);var i={};return d(e,function(e){i[e]=(t[e]||[]).slice()}),i}function r(t,e){var i={};d(e,function(t,e){var n=t.exist;n&&(i[n.id]=t)}),d(e,function(e,n){var r=e[Je];if(u.assert(!r||null==r.id||!i[r.id]||i[r.id]===e,"id duplicates: "+(r&&r.id)),r&&null!=r.id&&(i[r.id]=e),g(r)){var o=a(t,r,e.exist);e.keyInfo={mainType:t,subType:o}}}),d(e,function(t,e){var n=t.exist,r=t[Je],a=t.keyInfo;if(g(r)){if(a.name=null!=r.name?r.name+"":n?n.name:"\x00-",n)a.id=n.id;else if(null!=r.id)a.id=r.id+"";else{var o=0;do a.id="\x00"+a.name+"\x00"+o++;while(i[a.id])}i[a.id]=t}})}function a(t,e,i){var n=e.type?e.type:i?i.subType:y.determineSubType(t,e);return n}function o(t){return p(t,function(t){return t.componentIndex})||[]}function s(t,e){return e.hasOwnProperty("subType")?f(t,function(t){return t.subType===e.subType}):t}function l(t){if(!t._seriesIndices)throw new Error("Series is not initialized. Please depends sereis.")}var u=t(Qi),c=t("../util/model"),h=t("./Model"),d=u.each,f=u[$i],p=u.map,m=u[Di],v=u[Hi],g=u[Be],y=t("./Component"),x=t("./globalDefault"),_="\x00_ec_inner",b=h[Ci]({constructor:b,init:function(t,e,i,n){i=i||{},this[Je]=null,this._theme=new h(i),this._optionManager=n},setOption:function(t,e){u.assert(!(_ in t),"please use chart.getOption()"),this._optionManager.setOption(t,e),this.resetOption()},resetOption:function(t){var e=!1,n=this._optionManager;if(!t||"recreate"===t){var r=n.mountOption("recreate"===t);this[Je]&&"recreate"!==t?(this.restoreData(),this[Ae](r)):i.call(this,r),e=!0}if(("timeline"===t||"media"===t)&&this.restoreData(),!t||"recreate"===t||"timeline"===t){var a=n.getTimelineOption(this);a&&(this[Ae](a),e=!0)}if(!t||"recreate"===t||"media"===t){var o=n.getMediaOption(this,this._api);o[Xi]&&d(o,function(t){this[Ae](t,e=!0)},this)}return e},mergeOption:function(t){function e(e,s){var l=c[$e](t[e]),h=c.mappingToExists(a[e],l);r(e,h);var f=n(a,s);i[e]=[],a[e]=[],d(h,function(t,n){var r=t.exist,o=t[Je];if(u.assert(g(o)||r,"Empty component definition"),o){var s=y[Mi](e,t.keyInfo.subType,!0);r&&r instanceof s?r[Ae](o,this):r=new s(o,this,this,u[Ci]({dependentModels:f,componentIndex:n},t.keyInfo))}else r[Ae]({},this);a[e][n]=r,i[e][n]=r[Je]},this),e===Ce&&(this._seriesIndices=o(a[Ce]))}var i=this[Je],a=this._componentsMap,s=[]; -d(t,function(t,e){null!=t&&(y.hasClass(e)?s.push(e):i[e]=null==i[e]?u.clone(t):u.merge(i[e],t,!0))}),y.topologicalTravel(s,y.getAllClassMainTypes(),e,this)},getOption:function(){var t=u.clone(this[Je]);return d(t,function(e,i){if(y.hasClass(i)){for(var e=c[$e](e),n=e[Xi]-1;n>=0;n--)c.isIdInner(e[n])&&e[Te](n,1);t[i]=e}}),delete t[_],t},getTheme:function(){return this._theme},getComponent:function(t,e){var i=this._componentsMap[t];return i?i[e||0]:void 0},queryComponents:function(t){var e=t.mainType;if(!e)return[];var i=t.index,n=t.id,r=t.name,a=this._componentsMap[e];if(!a||!a[Xi])return[];var o;if(null!=i)m(i)||(i=[i]),o=f(p(i,function(t){return a[t]}),function(t){return!!t});else if(null!=n){var l=m(n);o=f(a,function(t){return l&&v(n,t.id)>=0||!l&&t.id===n})}else if(null!=r){var u=m(r);o=f(a,function(t){return u&&v(r,t.name)>=0||!u&&t.name===r})}return s(o,t)},findComponents:function(t){function e(t){var e=r+"Index",i=r+"Id",n=r+"Name";return t&&(t.hasOwnProperty(e)||t.hasOwnProperty(i)||t.hasOwnProperty(n))?{mainType:r,index:t[e],id:t[i],name:t[n]}:null}function i(e){return t[$i]?f(e,t[$i]):e}var n=t.query,r=t.mainType,a=e(n),o=a?this.queryComponents(a):this._componentsMap[r];return i(s(o,t))},eachComponent:function(t,e,i){var n=this._componentsMap;if(typeof t===Vi)i=e,e=t,d(n,function(t,n){d(t,function(t,r){e.call(i,n,t,r)})});else if(u[ke](t))d(n[t],e,i);else if(g(t)){var r=this[Se](t);d(r,e,i)}},getSeriesByName:function(t){var e=this._componentsMap[Ce];return f(e,function(e){return e.name===t})},getSeriesByIndex:function(t){return this._componentsMap[Ce][t]},getSeriesByType:function(t){var e=this._componentsMap[Ce];return f(e,function(e){return e.subType===t})},getSeries:function(){return this._componentsMap[Ce].slice()},eachSeries:function(t,e){l(this),d(this._seriesIndices,function(i){var n=this._componentsMap[Ce][i];t.call(e,n,i)},this)},eachRawSeries:function(t,e){d(this._componentsMap[Ce],t,e)},eachSeriesByType:function(t,e,i){l(this),d(this._seriesIndices,function(n){var r=this._componentsMap[Ce][n];r.subType===t&&e.call(i,r,n)},this)},eachRawSeriesByType:function(t,e,i){return d(this.getSeriesByType(t),e,i)},isSeriesFiltered:function(t){return l(this),u[Hi](this._seriesIndices,t.componentIndex)<0},filterSeries:function(t,e){l(this);var i=f(this._componentsMap[Ce],t,e);this._seriesIndices=o(i)},restoreData:function(){var t=this._componentsMap;this._seriesIndices=o(t[Ce]);var e=[];d(t,function(t,i){e.push(i)}),y.topologicalTravel(e,y.getAllClassMainTypes(),function(e,i){d(t[e],function(t){t.restoreData()})})}});return b}),e("echarts/ExtensionAPI",[Ji,Qi],function(t){function e(t){i.each(n,function(e){this[e]=i.bind(t[e],t)},this)}var i=t(Qi),n=[Me,"getZr",we,be,_e,"on","off","getDataURL","getConnectedDataURL",ri,"getOption"];return e}),e("echarts/CoordinateSystem",[Ji],function(t){function e(){this._coordinateSystems=[]}var i={};return e[Ki]={constructor:e,create:function(t,e){var n=[];for(var r in i){var a=i[r][hi](t,e);a&&(n=n[Gi](a))}this._coordinateSystems=n},update:function(t,e){for(var i=this._coordinateSystems,n=0;n=e:"max"===i?e>=t:t===e}function a(t,e){return t.join(",")===e.join(",")}function o(t,e){e=e||{},c(e,function(e,i){if(null!=e){var n=t[i];if(u.hasClass(i)){e=l[$e](e),n=l[$e](n);var r=l.mappingToExists(n,e);t[i]=d(r,function(t){return t[Je]&&t.exist?f(t.exist,t[Je],!0):t.exist||t[Je]})}else t[i]=f(n,e,!0)}})}var s=t(Qi),l=t("../util/model"),u=t("./Component"),c=s.each,h=s.clone,d=s.map,f=s.merge,p=/^(min|max)?(.+)$/;return e[Ki]={constructor:e,setOption:function(t,e){t=h(t,!0);var n=this._optionBackup,r=this._newOptionBackup=i.call(this,t,e);n?(o(n.baseOption,r.baseOption),r.timelineOptions[Xi]&&(n.timelineOptions=r.timelineOptions),r.mediaList[Xi]&&(n.mediaList=r.mediaList),r.mediaDefault&&(n.mediaDefault=r.mediaDefault)):this._optionBackup=r},mountOption:function(t){var e=t?this._optionBackup:this._newOptionBackup;return this._timelineOptions=d(e.timelineOptions,h),this._mediaList=d(e.mediaList,h),this._mediaDefault=h(e.mediaDefault),this._currentMediaIndices=[],h(e.baseOption)},getTimelineOption:function(t){var e,i=this._timelineOptions;if(i[Xi]){var n=t[ge]("timeline");n&&(e=h(i[n.getCurrentIndex()],!0))}return e},getMediaOption:function(t){var e=this._api[we](),i=this._api[be](),r=this._mediaList,o=this._mediaDefault,s=[],l=[];if(!r[Xi]&&!o)return l;for(var u=0,c=r[Xi];c>u;u++)n(r[u].query,e,i)&&s.push(u);return!s[Xi]&&o&&(s=[-1]),s[Xi]&&!a(s,this._currentMediaIndices)&&(l=d(s,function(t){return h(-1===t?o[Je]:r[t][Je])})),this._currentMediaIndices=s,l}},e}),e("echarts/model/Series",[Ji,Qi,"../util/format","../util/model","./Component"],function(t){var e=t(Qi),i=t("../util/format"),n=t("../util/model"),r=t("./Component"),a=i.encodeHTML,o=i[ve],s=r[Ci]({type:"series",seriesIndex:0,coordinateSystem:null,defaultOption:null,legendDataProvider:null,init:function(t,e,i,n){this[qe]=this.componentIndex,this[De](t,i),this._dataBeforeProcessed=this.getInitialData(t,i),this._data=this._dataBeforeProcessed.cloneShallow()},mergeDefaultAndTheme:function(t,i){e.merge(t,i.getTheme().get(this.subType)),e.merge(t,this.getDefaultOption()),n[Ye](t.label,[Oe,"show",ni,vi,Ze])},mergeOption:function(t,i){t=e.merge(this[Je],t,!0);var n=this.getInitialData(t,i);n&&(this._data=n,this._dataBeforeProcessed=n.cloneShallow())},getInitialData:function(){},getData:function(){return this._data},setData:function(t){this._data=t},getRawData:function(){return this._dataBeforeProcessed},getRawDataArray:function(){return this[Je].data},coordDimToDataDim:function(t){return[t]},dataDimToCoordDim:function(t){return t},getBaseAxis:function(){var t=this[me];return t&&t[pe]&&t[pe]()},formatTooltip:function(t,i){var n=this._data,r=this[Fe](t),s=e[Di](r)?e.map(r,o).join(", "):o(r),l=n[Ve](t);return i?a(this.name)+" : "+s:a(this.name)+"
"+(l?a(l)+" : "+s:s)},restoreData:function(){this._data=this._dataBeforeProcessed.cloneShallow()}});return e.mixin(s,n.dataFormatMixin),s}),e("zrender/core/guid",[],function(){var t=2311;return function(){return"zr_"+t++}}),e(fe,[Ji,ui],function(t){var e=Array[Ki].slice,i=t(ui),n=i[Hi],r=function(){this._$handlers={}};return r[Ki]={constructor:r,one:function(t,e,i){var r=this._$handlers;return e&&t?(r[t]||(r[t]=[]),n(r[t],t)>=0?this:(r[t].push({h:e,one:!0,ctx:i||this}),this)):this},on:function(t,e,i){var n=this._$handlers;return e&&t?(n[t]||(n[t]=[]),n[t].push({h:e,one:!1,ctx:i||this}),this):this},isSilent:function(t){var e=this._$handlers;return e[t]&&e[t][Xi]},off:function(t,e){var i=this._$handlers;if(!t)return this._$handlers={},this;if(e){if(i[t]){for(var n=[],r=0,a=i[t][Xi];a>r;r++)i[t][r].h!=e&&n.push(i[t][r]);i[t]=n}i[t]&&0===i[t][Xi]&&delete i[t]}else delete i[t];return this},trigger:function(t){if(this._$handlers[t]){var i=arguments,n=i[Xi];n>3&&(i=e.call(i,1));for(var r=this._$handlers[t],a=r[Xi],o=0;a>o;){switch(n){case 1:r[o].h.call(r[o].ctx);break;case 2:r[o].h.call(r[o].ctx,i[1]);break;case 3:r[o].h.call(r[o].ctx,i[1],i[2]);break;default:r[o].h.apply(r[o].ctx,i)}r[o].one?(r[Te](o,1),a--):o++}}return this},triggerWithContext:function(t){if(this._$handlers[t]){var i=arguments,n=i[Xi];n>4&&(i=e.call(i,1,i[Xi]-1));for(var r=i[i[Xi]-1],a=this._$handlers[t],o=a[Xi],s=0;o>s;){switch(n){case 1:a[s].h.call(r);break;case 2:a[s].h.call(r,i[1]);break;case 3:a[s].h.call(r,i[1],i[2]);break;default:a[s].h.apply(r,i)}a[s].one?(a[Te](s,1),o--):s++}}return this}},r}),e("zrender/mixin/Transformable",[Ji,"../core/matrix","../core/vector"],function(t){function e(t){return t>a||-a>t}var i=t("../core/matrix"),n=t("../core/vector"),r=i.identity,a=5e-5,o=function(t){t=t||{},t[Oe]||(this[Oe]=[0,0]),null==t[de]&&(this[de]=0),t.scale||(this.scale=[1,1]),this.origin=this.origin||null},s=o[Ki];s[he]=null,s.needLocalTransform=function(){return e(this[de])||e(this[Oe][0])||e(this[Oe][1])||e(this.scale[0]-1)||e(this.scale[1]-1)},s.updateTransform=function(){var t=this[ce],e=t&&t[he],n=this.needLocalTransform(),a=this[he];return n||e?(a=a||i[hi](),n?this[ue](a):r(a),e&&(n?i.mul(a,t[he],a):i.copy(a,t[he])),this[he]=a,this.invTransform=this.invTransform||i[hi](),void i.invert(this.invTransform,a)):void(a&&r(a))},s[ue]=function(t){t=t||[],r(t);var e=this.origin,n=this.scale,a=this[de],o=this[Oe];return e&&(t[4]-=e[0],t[5]-=e[1]),i.scale(t,t,n),a&&i[le](t,t,a),e&&(t[4]+=e[0],t[5]+=e[1]),t[4]+=o[0],t[5]+=o[1],t},s.setTransform=function(t){var e=this[he];e&&t[he](e[0],e[1],e[2],e[3],e[4],e[5])};var l=[];return s.decomposeTransform=function(){if(this[he]){var t=this[ce],n=this[he];t&&t[he]&&(i.mul(l,t.invTransform,n),n=l);var r=n[0]*n[0]+n[1]*n[1],a=n[2]*n[2]+n[3]*n[3],o=this[Oe],s=this.scale;e(r-1)&&(r=Math.sqrt(r)),e(a-1)&&(a=Math.sqrt(a)),n[0]<0&&(r=-r),n[3]<0&&(a=-a),o[0]=n[4],o[1]=n[5],s[0]=r,s[1]=a,this[de]=Math.atan2(-n[1]/a,n[0]/r)}},s[se]=function(t,e){var i=[t,e],r=this.invTransform;return r&&n[fi](i,i,r),i},s.transformCoordToGlobal=function(t,e){var i=[t,e],r=this[he];return r&&n[fi](i,i,r),i},o}),e("zrender/animation/easing",[],function(){var t={linear:function(t){return t},quadraticIn:function(t){return t*t},quadraticOut:function(t){return t*(2-t)},quadraticInOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},cubicIn:function(t){return t*t*t},cubicOut:function(t){return--t*t*t+1},cubicInOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},quarticIn:function(t){return t*t*t*t},quarticOut:function(t){return 1- --t*t*t*t},quarticInOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},quinticIn:function(t){return t*t*t*t*t},quinticOut:function(t){return--t*t*t*t*t+1},quinticInOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},sinusoidalIn:function(t){return 1-Math.cos(t*Math.PI/2)},sinusoidalOut:function(t){return Math.sin(t*Math.PI/2)},sinusoidalInOut:function(t){return.5*(1-Math.cos(Math.PI*t))},exponentialIn:function(t){return 0===t?0:Math.pow(1024,t-1)},exponentialOut:function(t){return 1===t?1:1-Math.pow(2,-10*t)},exponentialInOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(2,-10*(t-1))+2)},circularIn:function(t){return 1-Math.sqrt(1-t*t)},circularOut:function(t){return Math.sqrt(1- --t*t)},circularInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},elasticIn:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),-(i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)))},elasticOut:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/n)+1)},elasticInOut:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),(t*=2)<1?-.5*(i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)):i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)*.5+1)},backIn:function(t){var e=1.70158;return t*t*((e+1)*t-e)},backOut:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},backInOut:function(t){var e=2.5949095;return(t*=2)<1?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+2)},bounceIn:function(e){return 1-t.bounceOut(1-e)},bounceOut:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},bounceInOut:function(e){return.5>e?.5*t.bounceIn(2*e):.5*t.bounceOut(2*e-1)+.5}};return t}),e("zrender/animation/Clip",[Ji,"./easing"],function(t){function e(t){this._target=t[oe],this._life=t.life||1e3,this._delay=t.delay||0,this._initialized=!1,this.loop=null==t.loop?!1:t.loop,this.gap=t.gap||0,this.easing=t.easing||"Linear",this.onframe=t.onframe,this.ondestroy=t.ondestroy,this.onrestart=t.onrestart}var i=t("./easing");return e[Ki]={constructor:e,step:function(t){this._initialized||(this._startTime=(new Date).getTime()+this._delay,this._initialized=!0);var e=(t-this._startTime)/this._life;if(!(0>e)){e=Math.min(e,1);var n=this.easing,r=typeof n==Wi?i[n]:n,a=typeof r===Vi?r(e):e;return this.fire("frame",a),1==e?this.loop?(this.restart(),"restart"):(this._needsRemove=!0,"destroy"):null}},restart:function(){var t=(new Date).getTime(),e=(t-this._startTime)%this._life;this._startTime=(new Date).getTime()-e+this.gap,this._needsRemove=!1},fire:function(t,e){t="on"+t,this[t]&&this[t](this._target,e)}},e}),e(ae,[Ji],function(t){function e(t){return t=Math.round(t),0>t?0:t>255?255:t}function i(t){return t=Math.round(t),0>t?0:t>360?360:t}function n(t){return 0>t?0:t>1?1:t}function r(t){return e(t[Xi]&&"%"===t.charAt(t[Xi]-1)?parseFloat(t)/100*255:parseInt(t,10))}function a(t){return n(t[Xi]&&"%"===t.charAt(t[Xi]-1)?parseFloat(t)/100:parseFloat(t))}function o(t,e,i){return 0>i?i+=1:i>1&&(i-=1),1>6*i?t+(e-t)*i*6:1>2*i?e:2>3*i?t+(e-t)*(2/3-i)*6:t}function s(t,e,i){return t+(e-t)*i}function l(t){if(t){t+="";var e=t[Ni](/ /g,"")[Pi]();if(e in x)return x[e].slice();if("#"!==e.charAt(0)){var i=e[Hi]("("),n=e[Hi](")");if(-1!==i&&n+1===e[Xi]){var o=e.substr(0,i),s=e.substr(i+1,n-(i+1)).split(","),l=1;switch(o){case"rgba":if(4!==s[Xi])return;l=a(s.pop());case"rgb":if(3!==s[Xi])return;return[r(s[0]),r(s[1]),r(s[2]),l];case"hsla":if(4!==s[Xi])return;return s[3]=a(s[3]),u(s);case"hsl":if(3!==s[Xi])return;return u(s);default:return}}}else{if(4===e[Xi]){var c=parseInt(e.substr(1),16);if(!(c>=0&&4095>=c))return;return[(3840&c)>>4|(3840&c)>>8,240&c|(240&c)>>4,15&c|(15&c)<<4,1]}if(7===e[Xi]){var c=parseInt(e.substr(1),16);if(!(c>=0&&16777215>=c))return;return[(16711680&c)>>16,(65280&c)>>8,255&c,1]}}}}function u(t){var i=(parseFloat(t[0])%360+360)%360/360,n=a(t[1]),r=a(t[2]),s=.5>=r?r*(n+1):r+n-r*n,l=2*r-s,u=[e(255*o(l,s,i+1/3)),e(255*o(l,s,i)),e(255*o(l,s,i-1/3))];return 4===t[Xi]&&(u[3]=t[3]),u}function c(t){if(t){var e,i,n=t[0]/255,r=t[1]/255,a=t[2]/255,o=Math.min(n,r,a),s=Math.max(n,r,a),l=s-o,u=(s+o)/2;if(0===l)e=0,i=0;else{i=.5>u?l/(s+o):l/(2-s-o);var c=((s-n)/6+l/2)/l,h=((s-r)/6+l/2)/l,d=((s-a)/6+l/2)/l;n===s?e=d-h:r===s?e=1/3+c-d:a===s&&(e=2/3+h-c),0>e&&(e+=1),e>1&&(e-=1)}var f=[360*e,i,u];return null!=t[3]&&f.push(t[3]),f}}function h(t,e){var i=l(t);if(i){for(var n=0;3>n;n++)0>e?i[n]=i[n]*(1-e)|0:i[n]=(255-i[n])*e+i[n]|0;return y(i,4===i[Xi]?"rgba":"rgb")}}function d(t,e){var i=l(t);return i?((1<<24)+(i[0]<<16)+(i[1]<<8)+ +i[2]).toString(16).slice(1):void 0}function f(t,i,n){if(i&&i[Xi]&&t>=0&&1>=t){n=n||[0,0,0,0];var r=t*(i[Xi]-1),a=Math.floor(r),o=Math.ceil(r),l=i[a],u=i[o],c=r-a;return n[0]=e(s(l[0],u[0],c)),n[1]=e(s(l[1],u[1],c)),n[2]=e(s(l[2],u[2],c)),n[3]=e(s(l[3],u[3],c)),n}}function p(t,i,r){if(i&&i[Xi]&&t>=0&&1>=t){var a=t*(i[Xi]-1),o=Math.floor(a),u=Math.ceil(a),c=l(i[o]),h=l(i[u]),d=a-o,f=y([e(s(c[0],h[0],d)),e(s(c[1],h[1],d)),e(s(c[2],h[2],d)),n(s(c[3],h[3],d))],"rgba");return r?{color:f,leftIndex:o,rightIndex:u,value:a}:f}}function m(t,e){if(!(2!==t[Xi]||t[1]0&&s>=l;l++)r.push({color:e[l],offset:(l-i.value)/a});return r.push({color:n.color,offset:1}),r}}function v(t,e,n,r){return t=l(t),t?(t=c(t),null!=e&&(t[0]=i(e)),null!=n&&(t[1]=a(n)),null!=r&&(t[2]=a(r)),y(u(t),"rgba")):void 0}function g(t,e){return t=l(t),t&&null!=e?(t[3]=n(e),y(t,"rgba")):void 0}function y(t,e){return("rgb"===e||"hsv"===e||"hsl"===e)&&(t=t.slice(0,3)),e+"("+t.join(",")+")"}var x={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};return{parse:l,lift:h,toHex:d,fastMapToColor:f,mapToColor:p,mapIntervalToColor:m,modifyHSL:v,modifyAlpha:g,stringify:y}}),e("zrender/animation/Animator",[Ji,"./Clip","../tool/color",ui],function(t){function e(t,e){return t[e]}function i(t,e,i){t[e]=i}function n(t,e,i){return(e-t)*i+t}function r(t,e,i){return i>.5?e:t}function a(t,e,i,r,a){var o=t[Xi];if(1==a)for(var s=0;o>s;s++)r[s]=n(t[s],e[s],i);else for(var l=t[0][Xi],s=0;o>s;s++)for(var u=0;l>u;u++)r[s][u]=n(t[s][u],e[s][u],i)}function o(t,e,i){var n=t[Xi],r=e[Xi];if(n!==r){var a=n>r;if(a)t[Xi]=r;else for(var o=n;r>o;o++)t.push(1===i?e[o]:g.call(e[o]))}}function s(t,e,i){if(t===e)return!0;var n=t[Xi];if(n!==e[Xi])return!1;if(1===i){for(var r=0;n>r;r++)if(t[r]!==e[r])return!1}else for(var a=t[0][Xi],r=0;n>r;r++)for(var o=0;a>o;o++)if(t[r][o]!==e[r][o])return!1;return!0}function l(t,e,i,n,r,a,o,s,l){var c=t[Xi];if(1==l)for(var h=0;c>h;h++)s[h]=u(t[h],e[h],i[h],n[h],r,a,o);else for(var d=t[0][Xi],h=0;c>h;h++)for(var f=0;d>f;f++)s[h][f]=u(t[h][f],e[h][f],i[h][f],n[h][f],r,a,o)}function u(t,e,i,n,r,a,o){var s=.5*(i-t),l=.5*(n-e);return(2*(e-i)+s+l)*o+(-3*(e-i)-2*s-l)*a+s*r+e}function c(t){if(v(t)){var e=t[Xi];if(v(t[0])){for(var i=[],n=0;e>n;n++)i.push(g.call(t[n]));return i}return g.call(t)}return t}function h(t){return t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.floor(t[2]),"rgba("+t.join(",")+")"}function d(t,e,i,c,d){var m=t._getter,g=t._setter,y="spline"===e,x=c[Xi];if(x){var _,b=c[0].value,w=v(b),M=!1,S=!1,k=w&&v(b[0])?2:1;c.sort(function(t,e){return t.time-e.time}),_=c[x-1].time;for(var T=[],C=[],A=c[0].value,D=!0,L=0;x>L;L++){T.push(c[L].time/_);var P=c[L].value;if(w&&s(P,A,k)||!w&&P===A||(D=!1),A=P,typeof P==Wi){var z=p.parse(P);z?(P=z,M=!0):S=!0}C.push(P)}if(!D){if(w){for(var I=C[x-1],L=0;x-1>L;L++)o(C[L],I,k);o(m(t._target,d),I,k)}var O,R,B,Z,E,N,V=0,G=0;if(M)var F=[0,0,0,0];var W=function(t,e){var i;if(G>e){for(O=Math.min(V+1,x-1),i=O;i>=0&&!(T[i]<=e);i--);i=Math.min(i,x-2)}else{for(i=V;x>i&&!(T[i]>e);i++);i=Math.min(i-1,x-2)}V=i,G=e;var o=T[i+1]-T[i];if(0!==o)if(R=(e-T[i])/o,y)if(Z=C[i],B=C[0===i?i:i-1],E=C[i>x-2?x-1:i+1],N=C[i>x-3?x-1:i+2],w)l(B,Z,E,N,R,R*R,R*R*R,m(t,d),k);else{var s;if(M)s=l(B,Z,E,N,R,R*R,R*R*R,F,1),s=h(F);else{if(S)return r(Z,E,R);s=u(B,Z,E,N,R,R*R,R*R*R)}g(t,d,s)}else if(w)a(C[i],C[i+1],R,m(t,d),k);else{var s;if(M)a(C[i],C[i+1],R,F,1),s=h(F);else{if(S)return r(C[i],C[i+1],R);s=n(C[i],C[i+1],R)}g(t,d,s)}},H=new f({target:t._target,life:_,loop:t._loop,delay:t._delay,onframe:W,ondestroy:i});return e&&"spline"!==e&&(H.easing=e),H}}}var f=t("./Clip"),p=t("../tool/color"),m=t(ui),v=m.isArrayLike,g=Array[Ki].slice,y=function(t,n,r,a){this._tracks={},this._target=t,this._loop=n||!1,this._getter=r||e,this._setter=a||i,this._clipCount=0,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]};return y[Ki]={when:function(t,e){var i=this._tracks;for(var n in e){if(!i[n]){i[n]=[];var r=this._getter(this._target,n);if(null==r)continue;0!==t&&i[n].push({time:0,value:c(r)})}i[n].push({time:t,value:e[n]})}return this},during:function(t){return this._onframeList.push(t),this},_doneCallback:function(){this._tracks={},this._clipList[Xi]=0;for(var t=this._doneList,e=t[Xi],i=0;e>i;i++)t[i].call(this)},start:function(t){var e,i=this,n=0,r=function(){n--,n||i._doneCallback()};for(var a in this._tracks){var o=d(this,t,r,this._tracks[a],a);o&&(this._clipList.push(o),n++,this[re]&&this[re].addClip(o),e=o)}if(e){var s=e.onframe;e.onframe=function(t,e){s(t,e);for(var n=0;n1)for(var t in arguments)console.log(arguments[t])}}),e("zrender/mixin/Animatable",[Ji,"../animation/Animator",ui,"../core/log"],function(t){var e=t("../animation/Animator"),i=t(ui),n=i[ke],r=i.isFunction,a=i[Be],o=t("../core/log"),s=function(){this.animators=[]};return s[Ki]={constructor:s,animate:function(t,n){var r,a=!1,s=this,l=this.__zr;if(t){var u=t.split("."),c=s;a="shape"===u[0];for(var h=0,d=u[Xi];d>h;h++)c&&(c=c[u[h]]);c&&(r=c)}else r=s;if(!r)return void o('Property "'+t+'" is not existed in element '+s.id);var f=s.animators,p=new e(r,n);return p.during(function(t){s.dirty(a)}).done(function(){f[Te](i[Hi](f,p),1)}),f.push(p),l&&l[re].addAnimator(p),p},stopAnimation:function(t){for(var e=this.animators,i=e[Xi],n=0;i>n;n++)e[n].stop(t);return e[Xi]=0,this},animateTo:function(t,e,i,a,o){function s(){u--,u||o&&o()}n(i)?(o=a,a=i,i=0):r(a)?(o=a,a="linear",i=0):r(i)?(o=i,i=0):r(e)?(o=e,e=500):e||(e=500),this[ne](),this._animateToShallow("",this,t,e,i,a,o);var l=this.animators.slice(),u=l[Xi];u||o&&o();for(var c=0;c0&&this[ie](t,!1).when(null==r?500:r,s).delay(o||0),this}},s}),e("zrender/Element",[Ji,"./core/guid","./mixin/Eventful","./mixin/Transformable","./mixin/Animatable","./core/util"],function(t){var e=t("./core/guid"),i=t("./mixin/Eventful"),n=t("./mixin/Transformable"),r=t("./mixin/Animatable"),a=t("./core/util"),o=function(t){n.call(this,t),i.call(this,t),r.call(this,t),this.id=t.id||e()};return o[Ki]={type:"element",name:"",__zr:null,ignore:!1,clipPath:null,drift:function(t,e){switch(this[ee]){case ze:e=0;break;case Pe:t=0}var i=this[he];i||(i=this[he]=[1,0,0,1,0,0]),i[4]+=t,i[5]+=e,this.decomposeTransform(),this.dirty()},beforeUpdate:function(){},afterUpdate:function(){},update:function(){this.updateTransform()},traverse:function(t,e){},attrKV:function(t,e){if(t===Oe||"scale"===t||"origin"===t){if(e){var i=this[t];i||(i=this[t]=[]),i[0]=e[0],i[1]=e[1]}}else this[t]=e},hide:function(){this[te]=!0,this.__zr&&this.__zr[Jt]()},show:function(){this[te]=!1,this.__zr&&this.__zr[Jt]()},attr:function(t,e){if(typeof t===Wi)this.attrKV(t,e);else if(a[Be](t))for(var i in t)t.hasOwnProperty(i)&&this.attrKV(i,t[i]);return this.dirty(),this},setClipPath:function(t){var e=this.__zr;e&&t.addSelfToZr(e),this.clipPath&&this.clipPath!==t&&this.removeClipPath(),this.clipPath=t,t.__zr=e,t.__clipTarget=this,this.dirty()},removeClipPath:function(){var t=this.clipPath;t&&(t.__zr&&t.removeSelfFromZr(t.__zr),t.__zr=null,t.__clipTarget=null,this.clipPath=null,this.dirty())},addSelfToZr:function(t){this.__zr=t;var e=this.animators;if(e)for(var i=0;i=0&&(i[Te](n,0,t),this._doAdd(t))}return this},_doAdd:function(t){t[ce]&&t[ce][Qt](t),t[ce]=this;var e=this.__storage,i=this.__zr;e&&e!==t.__storage&&(e[$t](t),t instanceof r&&t.addChildrenToStorage(e)),i&&i[Jt]()},remove:function(t){var i=this.__zr,n=this.__storage,a=this._children,o=e[Hi](a,t);return 0>o?this:(a[Te](o,1),t[ce]=null,n&&(n[Yt](t.id),t instanceof r&&t.delChildrenFromStorage(n)),i&&i[Jt](),this)},removeAll:function(){var t,e,i=this._children,n=this.__storage;for(e=0;e=0?parseFloat(t)/100*e:parseFloat(t):t}function i(t,e){t[he](e[0],e[1],e[2],e[3],e[4],e[5])}var n=t("../../contain/text"),r=t("../../core/BoundingRect"),a=new r,o=function(){};return o[Ki]={constructor:o,drawRectText:function(t,r,o){var s=this.style,l=s.text;if(null!=l&&(l+=""),l){var u,c,h=s[Et],d=s.textDistance,f=s[Zt],p=s.textFont||s.font,m=s[Bt];o=o||n[ii](l,p,f,m);var v=this[he],g=this.invTransform;if(v&&(a.copy(r),a[fi](v),r=a,i(t,g)),h instanceof Array)u=r.x+e(h[0],r.width),c=r.y+e(h[1],r[di]),f=f||"left",m=m||"top";else{var y=n.adjustTextPositionOnRect(h,r,o,d);u=y.x,c=y.y,f=f||y[Zt],m=m||y[Bt]}t[Zt]=f,t[Bt]=m;var x=s.textFill,_=s.textStroke;x&&(t.fillStyle=x),_&&(t.strokeStyle=_),t.font=p,t.shadowColor=s.textShadowColor,t.shadowBlur=s.textShadowBlur,t.shadowOffsetX=s.textShadowOffsetX,t.shadowOffsetY=s.textShadowOffsetY;for(var b=l.split("\n"),w=0;w-_&&_>t}function i(t){return t>_||-_>t}function n(t,e,i,n,r){var a=1-r;return a*a*(a*t+3*r*e)+r*r*(r*n+3*a*i)}function r(t,e,i,n,r){var a=1-r;return 3*(((e-t)*a+2*(i-e)*r)*a+(n-i)*r*r)}function a(t,i,n,r,a,o){var s=r+3*(i-n)-t,l=3*(n-2*i+t),u=3*(i-t),c=t-a,h=l*l-3*s*u,d=l*u-9*s*c,f=u*u-3*l*c,p=0;if(e(h)&&e(d))if(e(l))o[0]=0;else{var m=-u/l;m>=0&&1>=m&&(o[p++]=m)}else{var v=d*d-4*h*f;if(e(v)){var g=d/h,m=-l/s+g,_=-g/2;m>=0&&1>=m&&(o[p++]=m),_>=0&&1>=_&&(o[p++]=_)}else if(v>0){var M=x(v),S=h*l+1.5*s*(-d+M),k=h*l+1.5*s*(-d-M);S=0>S?-y(-S,w):y(S,w),k=0>k?-y(-k,w):y(k,w);var m=(-l-(S+k))/(3*s);m>=0&&1>=m&&(o[p++]=m)}else{var T=(2*h*l-3*s*d)/(2*x(h*h*h)),C=Math.acos(T)/3,A=x(h),D=Math.cos(C),m=(-l-2*A*D)/(3*s),_=(-l+A*(D+b*Math.sin(C)))/(3*s),L=(-l+A*(D-b*Math.sin(C)))/(3*s);m>=0&&1>=m&&(o[p++]=m),_>=0&&1>=_&&(o[p++]=_),L>=0&&1>=L&&(o[p++]=L)}}return p}function o(t,n,r,a,o){var s=6*r-12*n+6*t,l=9*n+3*a-3*t-9*r,u=3*n-3*t,c=0;if(e(l)){if(i(s)){var h=-u/s;h>=0&&1>=h&&(o[c++]=h)}}else{var d=s*s-4*l*u;if(e(d))o[0]=-s/(2*l);else if(d>0){var f=x(d),h=(-s+f)/(2*l),p=(-s-f)/(2*l);h>=0&&1>=h&&(o[c++]=h),p>=0&&1>=p&&(o[c++]=p)}}return c}function s(t,e,i,n,r,a){var o=(e-t)*r+t,s=(i-e)*r+e,l=(n-i)*r+i,u=(s-o)*r+o,c=(l-s)*r+s,h=(c-u)*r+u;a[0]=t,a[1]=o,a[2]=u,a[3]=h,a[4]=h,a[5]=c,a[6]=l,a[7]=n}function l(t,e,i,r,a,o,s,l,u,c,h){var d,f,p,m,v,y=.005,b=1/0;M[0]=u,M[1]=c;for(var w=0;1>w;w+=.05)S[0]=n(t,i,a,s,w),S[1]=n(e,r,o,l,w),m=g(M,S),b>m&&(d=w,b=m);b=1/0;for(var T=0;32>T&&!(_>y);T++)f=d-y,p=d+y,S[0]=n(t,i,a,s,f),S[1]=n(e,r,o,l,f),m=g(S,M),f>=0&&b>m?(d=f,b=m):(k[0]=n(t,i,a,s,p),k[1]=n(e,r,o,l,p),v=g(k,M),1>=p&&b>v?(d=p,b=v):y*=.5);return h&&(h[0]=n(t,i,a,s,d),h[1]=n(e,r,o,l,d)),x(b)}function u(t,e,i,n){var r=1-n;return r*(r*t+2*n*e)+n*n*i}function c(t,e,i,n){return 2*((1-n)*(e-t)+n*(i-e))}function h(t,n,r,a,o){var s=t-2*n+r,l=2*(n-t),u=t-a,c=0;if(e(s)){if(i(l)){var h=-u/l;h>=0&&1>=h&&(o[c++]=h)}}else{var d=l*l-4*s*u;if(e(d)){var h=-l/(2*s);h>=0&&1>=h&&(o[c++]=h)}else if(d>0){var f=x(d),h=(-l+f)/(2*s),p=(-l-f)/(2*s);h>=0&&1>=h&&(o[c++]=h),p>=0&&1>=p&&(o[c++]=p)}}return c}function d(t,e,i){var n=t+i-2*e;return 0===n?.5:(t-e)/n}function f(t,e,i,n,r){var a=(e-t)*n+t,o=(i-e)*n+e,s=(o-a)*n+a;r[0]=t,r[1]=a,r[2]=s,r[3]=s,r[4]=o,r[5]=i}function p(t,e,i,n,r,a,o,s,l){var c,h=.005,d=1/0;M[0]=o,M[1]=s;for(var f=0;1>f;f+=.05){S[0]=u(t,i,r,f),S[1]=u(e,n,a,f);var p=g(M,S);d>p&&(c=f,d=p)}d=1/0;for(var m=0;32>m&&!(_>h);m++){var v=c-h,y=c+h;S[0]=u(t,i,r,v),S[1]=u(e,n,a,v);var p=g(S,M);if(v>=0&&d>p)c=v,d=p;else{k[0]=u(t,i,r,y),k[1]=u(e,n,a,y);var b=g(k,M);1>=y&&d>b?(c=y,d=b):h*=.5}}return l&&(l[0]=u(t,i,r,c),l[1]=u(e,n,a,c)),x(d)}var m=t("./vector"),v=m[hi],g=m.distSquare,y=Math.pow,x=Math.sqrt,_=1e-4,b=x(3),w=1/3,M=v(),S=v(),k=v();return{cubicAt:n,cubicDerivativeAt:r,cubicRootAt:a,cubicExtrema:o,cubicSubdivide:s,cubicProjectPoint:l,quadraticAt:u,quadraticDerivativeAt:c,quadraticRootAt:h,quadraticExtremum:d,quadraticSubdivide:f,quadraticProjectPoint:p}}),e("zrender/core/bbox",[Ji,"./vector","./curve"],function(t){var e=t("./vector"),i=t("./curve"),n={},r=Math.min,a=Math.max,o=Math.sin,s=Math.cos,l=e[hi](),u=e[hi](),c=e[hi](),h=2*Math.PI;return n.fromPoints=function(t,e,i){if(0!==t[Xi]){var n,o=t[0],s=o[0],l=o[0],u=o[1],c=o[1];for(n=1;ng;g++)y[g]=b(t,n,s,u,y[g]);for(w=_(e,o,l,c,x),g=0;w>g;g++)x[g]=b(e,o,l,c,x[g]);y.push(t,u),x.push(e,c),f=r.apply(null,y),p=a.apply(null,y),m=r.apply(null,x),v=a.apply(null,x),h[0]=f,h[1]=m,d[0]=p,d[1]=v},n.fromQuadratic=function(t,e,n,o,s,l,u,c){var h=i.quadraticExtremum,d=i.quadraticAt,f=a(r(h(t,n,s),1),0),p=a(r(h(e,o,l),1),0),m=d(t,n,s,f),v=d(e,o,l,p);u[0]=r(t,s,m),u[1]=r(e,l,v),c[0]=a(t,s,m),c[1]=a(e,l,v)},n.fromArc=function(t,i,n,r,a,d,f,p,m){var v=e.min,g=e.max,y=Math.abs(a-d);if(1e-4>y%h&&y>1e-4)return p[0]=t-n,p[1]=i-r,m[0]=t+n,void(m[1]=i+r);if(l[0]=s(a)*n+t,l[1]=o(a)*r+i,u[0]=s(d)*n+t,u[1]=o(d)*r+i,v(p,l,u),g(m,l,u),a%=h,0>a&&(a+=h),d%=h,0>d&&(d+=h),a>d&&!f?d+=h:d>a&&f&&(a+=h),f){var x=d;d=a,a=x}for(var _=0;d>_;_+=Math.PI/2)_>a&&(c[0]=s(_)*n+t,c[1]=o(_)*r+i,v(p,c,p),g(m,c,m))},n}),e("zrender/core/PathProxy",[Ji,"./curve","./vector","./bbox","./BoundingRect"],function(t){var e=t("./curve"),i=t("./vector"),n=t("./bbox"),r=t("./BoundingRect"),a={M:1,L:2,C:3,Q:4,A:5,Z:6,R:7},o=[],s=[],l=[],u=[],c=Math.min,h=Math.max,d=Math.cos,f=Math.sin,p=Math.sqrt,m=typeof Float32Array!=gi,v=function(){this.data=[],this._len=0,this._ctx=null,this._xi=0,this._yi=0,this._x0=0,this._y0=0};return v[Ki]={constructor:v,_lineDash:null,_dashOffset:0,_dashIdx:0,_dashSum:0,getContext:function(){return this._ctx},beginPath:function(t){return this._ctx=t,t&&t[Ot](),this._len=0,this._lineDash&&(this._lineDash=null,this._dashOffset=0),this},moveTo:function(t,e){return this.addData(a.M,t,e),this._ctx&&this._ctx[It](t,e),this._x0=t,this._y0=e,this._xi=t,this._yi=e,this},lineTo:function(t,e){return this.addData(a.L,t,e),this._ctx&&(this._needsDash()?this._dashedLineTo(t,e):this._ctx.lineTo(t,e)),this._xi=t,this._yi=e,this},bezierCurveTo:function(t,e,i,n,r,o){return this.addData(a.C,t,e,i,n,r,o),this._ctx&&(this._needsDash()?this._dashedBezierTo(t,e,i,n,r,o):this._ctx.bezierCurveTo(t,e,i,n,r,o)),this._xi=r,this._yi=o,this},quadraticCurveTo:function(t,e,i,n){return this.addData(a.Q,t,e,i,n),this._ctx&&(this._needsDash()?this._dashedQuadraticTo(t,e,i,n):this._ctx.quadraticCurveTo(t,e,i,n)),this._xi=i,this._yi=n,this},arc:function(t,e,i,n,r,o){return this.addData(a.A,t,e,i,i,n,r-n,0,o?0:1),this._ctx&&this._ctx.arc(t,e,i,n,r,o),this._xi=d(r)*i+t,this._xi=f(r)*i+t,this},arcTo:function(t,e,i,n,r){return this._ctx&&this._ctx.arcTo(t,e,i,n,r),this},rect:function(t,e,i,n){return this._ctx&&this._ctx.rect(t,e,i,n),this.addData(a.R,t,e,i,n),this},closePath:function(){this.addData(a.Z);var t=this._ctx,e=this._x0,i=this._y0;return t&&(this._needsDash()&&this._dashedLineTo(e,i),t[zt]()),this._xi=e,this._yi=i,this},fill:function(t){t&&t.fill(),this.toStatic()},stroke:function(t){t&&t[_i](),this.toStatic()},setLineDash:function(t){if(t instanceof Array){this._lineDash=t,this._dashIdx=0;for(var e=0,i=0;ii;i++)this.data[i]=t[i];this._len=e},appendPath:function(t){t instanceof Array||(t=[t]);for(var e=t[Xi],i=0,n=this._len,r=0;e>r;r++)i+=t[r].len();m&&this.data instanceof Float32Array&&(this.data=new Float32Array(n+i));for(var r=0;e>r;r++)for(var a=t[r].data,o=0;oe[Xi]&&(this._expandData(),e=this.data);for(var i=0;ia&&(a=r+a),a%=r,v-=a*d,g-=a*f;d>=0&&t>=v||0>d&&v>t;)n=this._dashIdx,i=o[n],v+=d*i,g+=f*i,this._dashIdx=(n+1)%y,d>0&&l>v||0>d&&v>l||s[n%2?It:"lineTo"](d>=0?c(v,t):h(v,t),f>=0?c(g,e):h(g,e));d=v-t,f=g-e,this._dashOffset=-p(d*d+f*f)},_dashedBezierTo:function(t,i,n,r,a,o){var s,l,u,c,h,d=this._dashSum,f=this._dashOffset,m=this._lineDash,v=this._ctx,g=this._xi,y=this._yi,x=e.cubicAt,_=0,b=this._dashIdx,w=m[Xi],M=0;for(0>f&&(f=d+f),f%=d,s=0;1>s;s+=.1)l=x(g,t,n,a,s+.1)-x(g,t,n,a,s),u=x(y,i,r,o,s+.1)-x(y,i,r,o,s),_+=p(l*l+u*u);for(;w>b&&(M+=m[b],!(M>f));b++);for(s=(M-f)/_;1>=s;)c=x(g,t,n,a,s),h=x(y,i,r,o,s),b%2?v[It](c,h):v.lineTo(c,h),s+=m[b]/_,b=(b+1)%w;b%2!==0&&v.lineTo(a,o),l=a-c,u=o-h,this._dashOffset=-p(l*l+u*u)},_dashedQuadraticTo:function(t,e,i,n){var r=i,a=n;i=(i+2*t)/3,n=(n+2*e)/3,t=(this._xi+2*t)/3,e=(this._yi+2*e)/3,this._dashedBezierTo(t,e,i,n,r,a)},toStatic:function(){var t=this.data;t instanceof Array&&(t[Xi]=this._len,m&&(this.data=new Float32Array(t)))},getBoundingRect:function(){o[0]=o[1]=l[0]=l[1]=Number.MAX_VALUE,s[0]=s[1]=u[0]=u[1]=-Number.MAX_VALUE;for(var t=this.data,e=0,c=0,h=0,p=0,m=0;ml?s:l,p=s>l?1:s/l,m=s>l?l/s:1,v=Math.abs(s-l)>.001;v?(t.translate(r,o),t[le](h),t.scale(p,m),t.arc(0,0,f,u,u+c,1-d),t.scale(1/p,1/m),t[le](-h),t.translate(-r,-o)):t.arc(r,o,f,u,u+c,1-d);break;case a.R:t.rect(e[i++],e[i++],e[i++],e[i++]);break;case a.Z:t[zt]()}}}},v.CMD=a,v}),e("zrender/contain/line",[],function(){return{containStroke:function(t,e,i,n,r,a,o){if(0===r)return!1;var s=r,l=0,u=t;if(o>e+s&&o>n+s||e-s>o&&n-s>o||a>t+s&&a>i+s||t-s>a&&i-s>a)return!1;if(t===i)return Math.abs(a-t)<=s/2;l=(e-n)/(t-i),u=(t*n-i*e)/(t-i);var c=l*a-o+u,h=c*c/(l*l+1);return s/2*s/2>=h}}}),e("zrender/contain/cubic",[Ji,"../core/curve"],function(t){var e=t("../core/curve");return{containStroke:function(t,i,n,r,a,o,s,l,u,c,h){if(0===u)return!1;var d=u;if(h>i+d&&h>r+d&&h>o+d&&h>l+d||i-d>h&&r-d>h&&o-d>h&&l-d>h||c>t+d&&c>n+d&&c>a+d&&c>s+d||t-d>c&&n-d>c&&a-d>c&&s-d>c)return!1;var f=e.cubicProjectPoint(t,i,n,r,a,o,s,l,c,h,null);return d/2>=f}}}),e("zrender/contain/quadratic",[Ji,"../core/curve"],function(t){var e=t("../core/curve");return{containStroke:function(t,i,n,r,a,o,s,l,u){if(0===s)return!1;var c=s;if(u>i+c&&u>r+c&&u>o+c||i-c>u&&r-c>u&&o-c>u||l>t+c&&l>n+c&&l>a+c||t-c>l&&n-c>l&&a-c>l)return!1;var h=e.quadraticProjectPoint(t,i,n,r,a,o,l,u,null);return c/2>=h}}}),e("zrender/contain/util",[Ji],function(t){var e=2*Math.PI;return{normalizeRadian:function(t){return t%=e,0>t&&(t+=e),t}}}),e("zrender/contain/arc",[Ji,"./util"],function(t){var e=t("./util").normalizeRadian,i=2*Math.PI;return{containStroke:function(t,n,r,a,o,s,l,u,c){if(0===l)return!1;var h=l;u-=t,c-=n;var d=Math.sqrt(u*u+c*c);if(d-h>r||r>d+h)return!1;if(Math.abs(a-o)%i<1e-4)return!0;if(s){var f=a;a=e(o),o=e(f)}else a=e(a),o=e(o);a>o&&(o+=i);var p=Math.atan2(c,u);return 0>p&&(p+=i),p>=a&&o>=p||p+i>=a&&o>=p+i}}}),e("zrender/contain/windingLine",[],function(){return function(t,e,i,n,r,a){if(a>e&&a>n||e>a&&n>a)return 0;if(n===e)return 0;var o=e>n?1:-1,s=(a-e)/(n-e),l=s*(i-t)+t;return l>r?o:0}}),e("zrender/contain/path",[Ji,"../core/PathProxy","./line","./cubic","./quadratic","./arc","./util","../core/curve","./windingLine"],function(t){function e(t,e){return Math.abs(t-e)e&&c>r&&c>o&&c>l||e>c&&r>c&&o>c&&l>c)return 0;var h=f.cubicRootAt(e,r,o,l,c,y);if(0===h)return 0;for(var d,p,m=0,v=-1,g=0;h>g;g++){var _=y[g],b=f.cubicAt(t,n,a,s,_);u>b||(0>v&&(v=f.cubicExtrema(e,r,o,l,x),x[1]1&&i(),d=f.cubicAt(e,r,o,l,x[0]),v>1&&(p=f.cubicAt(e,r,o,l,x[1]))),m+=2==v?_d?1:-1:_p?1:-1:p>l?1:-1:_d?1:-1:d>l?1:-1)}return m}function r(t,e,i,n,r,a,o,s){if(s>e&&s>n&&s>a||e>s&&n>s&&a>s)return 0;var l=f.quadraticRootAt(e,n,a,s,y);if(0===l)return 0;var u=f.quadraticExtremum(e,n,a);if(u>=0&&1>=u){for(var c=0,h=f.quadraticAt(e,n,a,u),d=0;l>d;d++){var p=f.quadraticAt(t,i,r,y[d]);p>o||(c+=y[d]h?1:-1:h>a?1:-1)}return c}var p=f.quadraticAt(t,i,r,y[0]);return p>o?0:e>a?1:-1}function a(t,e,i,n,r,a,o,s){if(s-=e,s>i||-i>s)return 0;var l=Math.sqrt(i*i-s*s);y[0]=-l,y[1]=l;var u=Math.abs(n-r);if(1e-4>u)return 0;if(1e-4>u%v){n=0,r=v;var c=a?1:-1;return o>=y[0]+t&&o<=y[1]+t?c:0}if(a){var l=n;n=d(r),r=d(l)}else n=d(n),r=d(r);n>r&&(r+=v);for(var h=0,f=0;2>f;f++){var p=y[f];if(p+t>o){var m=Math.atan2(s,p),c=a?1:-1;0>m&&(m=v+m),(m>=n&&r>=m||m+v>=n&&r>=m+v)&&(m>Math.PI/2&&m<1.5*Math.PI&&(c=-c),h+=c)}}return h}function o(t,i,o,l,d){for(var f=0,v=0,g=0,y=0,x=0,_=0;_1&&(o||(f+=p(v,g,y,x,l,d)),0!==f))return!0;switch(1==_&&(v=t[_],g=t[_+1],y=v,x=g),b){case s.M:y=t[_++],x=t[_++],v=y,g=x;break;case s.L:if(o){if(m(v,g,t[_],t[_+1],i,l,d))return!0}else f+=p(v,g,t[_],t[_+1],l,d)||0;v=t[_++],g=t[_++];break;case s.C:if(o){if(u.containStroke(v,g,t[_++],t[_++],t[_++],t[_++],t[_],t[_+1],i,l,d))return!0}else f+=n(v,g,t[_++],t[_++],t[_++],t[_++],t[_],t[_+1],l,d)||0;v=t[_++],g=t[_++];break;case s.Q:if(o){if(c.containStroke(v,g,t[_++],t[_++],t[_],t[_+1],i,l,d))return!0}else f+=r(v,g,t[_++],t[_++],t[_],t[_+1],l,d)||0;v=t[_++],g=t[_++];break;case s.A:var w=t[_++],M=t[_++],S=t[_++],k=t[_++],T=t[_++],C=t[_++],A=(t[_++],1-t[_++]),D=Math.cos(T)*S+w,L=Math.sin(T)*k+M;_>1?f+=p(v,g,D,L,l,d):(y=D,x=L);var P=(l-w)*k/S+w;if(o){if(h.containStroke(w,M,k,T,T+C,A,i,P,d))return!0}else f+=a(w,M,k,T,T+C,A,P,d);v=Math.cos(T+C)*S+w,g=Math.sin(T+C)*k+M;break;case s.R:y=v=t[_++],x=g=t[_++];var z=t[_++],I=t[_++],D=y+z,L=x+I;if(o){if(m(y,x,D,x,i,l,d)||m(D,x,D,L,i,l,d)||m(D,L,y,L,i,l,d)||m(y,L,D,L,i,l,d))return!0}else f+=p(D,x,D,L,l,d),f+=p(y,L,y,x,l,d);break;case s.Z:if(o){if(m(v,g,y,x,i,l,d))return!0}else if(f+=p(v,g,y,x,l,d),0!==f)return!0;v=y,g=x}}return o||e(g,x)||(f+=p(v,g,y,x,l,d)||0),0!==f}var s=t("../core/PathProxy").CMD,l=t("./line"),u=t("./cubic"),c=t("./quadratic"),h=t("./arc"),d=t("./util").normalizeRadian,f=t("../core/curve"),p=t("./windingLine"),m=l.containStroke,v=2*Math.PI,g=1e-4,y=[-1,-1,-1],x=[-1,-1];return{contain:function(t,e,i){return o(t,0,!1,e,i)},containStroke:function(t,e,i,n){return o(t,e,!0,i,n)}}}),e("zrender/graphic/Path",[Ji,"./Displayable",ui,"../core/PathProxy","../contain/path","./Gradient"],function(t){function e(t){var e=t.fill;return null!=e&&"none"!==e}function i(t){var e=t[_i];return null!=e&&"none"!==e&&t[bi]>0}function n(t){r.call(this,t),this.path=new o}var r=t("./Displayable"),a=t(ui),o=t("../core/PathProxy"),s=t("../contain/path"),l=t("./Gradient"),u=Math.abs;return n[Ki]={constructor:n,type:"path",__dirtyPath:!0,strokeContainThreshold:5,brush:function(t){t.save();var n=this.style,r=this.path,a=i(n),o=e(n);this.__dirtyPath&&(o&&n.fill instanceof l&&n.fill.updateCanvasGradient(this,t),a&&n[_i]instanceof l&&n[_i].updateCanvasGradient(this,t)),n.bind(t,this),this.setTransform(t);var s=n.lineDash,u=n.lineDashOffset,c=!!t.setLineDash;this.__dirtyPath||s&&!c&&a?(r=this.path[Ot](t),s&&!c&&(r.setLineDash(s),r.setLineDashOffset(u)),this[Pt](r,this.shape),this.__dirtyPath=!1):(t[Ot](),this.path.rebuildPath(t)),o&&r.fill(t),s&&c&&(t.setLineDash(s),t.lineDashOffset=u),a&&r[_i](t),null!=n.text&&this.drawRectText(t,this[ii]()),t[Lt]()},buildPath:function(t,e){},getBoundingRect:function(){var t=this._rect,n=this.style;if(!t){var r=this.path;this.__dirtyPath&&(r[Ot](),this[Pt](r,this.shape)),t=r[ii]()}if(i(n)&&(this[Kt]||!this._rect)){var a=this._rectWithStroke||(this._rectWithStroke=t.clone());a.copy(t);var o=n[bi],s=n.strokeNoScale?this.getLineScale():1;return e(n)||(o=Math.max(o,this.strokeContainThreshold)),s>1e-10&&(a.width+=o/s,a[di]+=o/s,a.x-=o/s/2,a.y-=o/s/2),a}return this._rect=t,t},contain:function(t,n){var r=this[se](t,n),a=this[ii](),o=this.style;if(t=r[0],n=r[1],a[Rt](t,n)){var l=this.path.data;if(i(o)){var u=o[bi],c=o.strokeNoScale?this.getLineScale():1;if(c>1e-10&&(e(o)||(u=Math.max(u,this.strokeContainThreshold)),s.containStroke(l,u/c,t,n)))return!0}if(e(o))return s[Rt](l,t,n)}return!1},dirty:function(t){0===arguments[Xi]&&(t=!0),t&&(this.__dirtyPath=t,this._rect=null),this[Kt]=!0,this.__zr&&this.__zr[Jt](),this.__clipTarget&&this.__clipTarget.dirty()},animateShape:function(t){return this[ie]("shape",t)},attrKV:function(t,e){"shape"===t?this[Dt](e):r[Ki].attrKV.call(this,t,e)},setShape:function(t,e){var i=this.shape;if(i){if(a[Be](t))for(var n in t)i[n]=t[n];else i[t]=e;this.dirty(!0)}return this},getLineScale:function(){var t=this[he];return t&&u(t[0]-1)>1e-10&&u(t[3]-1)>1e-10?Math.sqrt(u(t[0]*t[3]-t[2]*t[1])):1}},n[Ci]=function(t){var e=function(e){n.call(this,e),t.style&&this.style.extendFrom(t.style,!1);var i=t.shape;if(i){this.shape=this.shape||{};var r=this.shape;for(var a in i)!r.hasOwnProperty(a)&&i.hasOwnProperty(a)&&(r[a]=i[a])}t.init&&t.init.call(this,e)};a[ki](e,n);for(var i in t)"style"!==i&&"shape"!==i&&(e[Ki][i]=t[i]);return e},a[ki](n,r),n}),e("zrender/tool/transformPath",[Ji,"../core/PathProxy","../core/vector"],function(t){function e(t,e){var n,l,u,c,h,d,f=t.data,p=i.M,m=i.C,v=i.L,g=i.R,y=i.A,x=i.Q;for(u=0,c=0;uh;h++){var d=a[h];d[0]=f[u++],d[1]=f[u++],r(d,d,e),f[c++]=d[0],f[c++]=d[1]}}}var i=t("../core/PathProxy").CMD,n=t("../core/vector"),r=n[fi],a=[[],[],[]],o=Math.sqrt,s=Math.atan2;return e}),e("zrender/tool/path",[Ji,"../graphic/Path","../core/PathProxy","./transformPath","../core/matrix"],function(t){function e(t,e,i,n,r,a,o,s,l,f,v){var g=l*(d/180),y=h(g)*(t-i)/2+c(g)*(e-n)/2,x=-1*c(g)*(t-i)/2+h(g)*(e-n)/2,_=y*y/(o*o)+x*x/(s*s);_>1&&(o*=u(_),s*=u(_));var b=(r===a?-1:1)*u((o*o*(s*s)-o*o*(x*x)-s*s*(y*y))/(o*o*(x*x)+s*s*(y*y)))||0,w=b*o*x/s,M=b*-s*y/o,S=(t+i)/2+h(g)*w-c(g)*M,k=(e+n)/2+c(g)*w+h(g)*M,T=m([1,0],[(y-w)/o,(x-M)/s]),C=[(y-w)/o,(x-M)/s],A=[(-1*y-w)/o,(-1*x-M)/s],D=m(C,A);p(C,A)<=-1&&(D=d),p(C,A)>=1&&(D=0),0===a&&D>0&&(D-=2*d),1===a&&0>D&&(D+=2*d),v.addData(f,S,k,o,s,T,D,g,a)}function i(t){if(!t)return[];var i,n=t[Ni](/-/g," -")[Ni](/ /g," ")[Ni](/ /g,",")[Ni](/,,/g,",");for(i=0;i0&&""===v[0]&&v.shift();for(var g=0;gn;n++)i=t[n],i[Kt]&&i[Pt](i.path,i.shape),a.push(i.path);var s=new r(e);return s[Pt]=function(t){t.appendPath(a);var e=t[qi]();e&&t.rebuildPath(e)},s}}}),e("zrender/graphic/helper/roundRect",[Ji],function(t){return{buildPath:function(t,e){var i,n,r,a,o=e.x,s=e.y,l=e.width,u=e[di],c=e.r;0>l&&(o+=l,l=-l),0>u&&(s+=u,u=-u),typeof c===Fi?i=n=r=a=c:c instanceof Array?1===c[Xi]?i=n=r=a=c[0]:2===c[Xi]?(i=r=c[0],n=a=c[1]):3===c[Xi]?(i=c[0],n=a=c[1],r=c[2]):(i=c[0],n=c[1],r=c[2],a=c[3]):i=n=r=a=0;var h;i+n>l&&(h=i+n,i*=l/h,n*=l/h),r+a>l&&(h=r+a,r*=l/h,a*=l/h),n+r>u&&(h=n+r,n*=u/h,r*=u/h),i+a>u&&(h=i+a,i*=u/h,a*=u/h),t[It](o+i,s),t.lineTo(o+l-n,s),0!==n&&t.quadraticCurveTo(o+l,s,o+l,s+n),t.lineTo(o+l,s+u-r),0!==r&&t.quadraticCurveTo(o+l,s+u,o+l-r,s+u),t.lineTo(o+a,s+u),0!==a&&t.quadraticCurveTo(o,s+u,o,s+u-a),t.lineTo(o,s+i),0!==i&&t.quadraticCurveTo(o,s,o+i,s)}}}),e("zrender/core/LRU",[Ji],function(t){var e=function(){this.head=null,this.tail=null,this._len=0},i=e[Ki];i.insert=function(t){var e=new n(t);return this.insertEntry(e),e},i.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,this.tail=t):this.head=this.tail=t,this._len++},i[Qt]=function(t){var e=t.prev,i=t.next;e?e.next=i:this.head=i,i?i.prev=e:this.tail=e,t.next=t.prev=null,this._len--},i.len=function(){return this._len};var n=function(t){this.value=t,this.next,this.prev},r=function(t){this._list=new e,this._map={},this._maxSize=t||10},a=r[Ki];return a.put=function(t,e){var i=this._list,n=this._map;if(null==n[t]){var r=i.len();if(r>=this._maxSize&&r>0){var a=i.head;i[Qt](a),delete n[a.key]}var o=i.insert(e);o.key=t,n[t]=o}},a.get=function(t){var e=this._map[t],i=this._list;return null!=e?(e!==i.tail&&(i[Qt](e),i.insertEntry(e)),e.value):void 0},a.clear=function(){this._list.clear(),this._map={}},r}),e("zrender/graphic/Image",[Ji,"./Displayable",li,ui,"./helper/roundRect","../core/LRU"],function(t){var e=t("./Displayable"),i=t(li),n=t(ui),r=t("./helper/roundRect"),a=t("../core/LRU"),o=new a(50),s=function(t){e.call(this,t)};return s[Ki]={constructor:s,type:"image",brush:function(t){var e,i=this.style,n=i.image;if(e=typeof n===Wi?this._image:n,!e&&n){var a=o.get(n);if(!a)return e=new Image,e.onload=function(){e.onload=null;for(var t=0;ts;s++)o+=i[vi](t[s-1],t[s]);var l=o/2;l=r>l?r:l;for(var s=0;l>s;s++){var u,c,h,d=s/(l-1)*(n?r:r-1),f=Math.floor(d),p=d-f,m=t[f%r];n?(u=t[(f-1+r)%r],c=t[(f+1)%r],h=t[(f+2)%r]):(u=t[0===f?f:f-1],c=t[f>r-2?r-1:f+1],h=t[f>r-3?r-1:f+2]);var v=p*p,g=p*v;a.push([e(u[0],m[0],c[0],h[0],p,v,g),e(u[1],m[1],c[1],h[1],p,v,g)])}return a}}),e("zrender/graphic/helper/smoothBezier",[Ji,"../../core/vector"],function(t){var e=t("../../core/vector"),i=e.min,n=e.max,r=e.scale,a=e[vi],o=e.add;return function(t,s,l,u){var c,h,d,f,p=[],m=[],v=[],g=[];if(u){d=[1/0,1/0],f=[-(1/0),-(1/0)];for(var y=0,x=t[Xi];x>y;y++)i(d,d,t[y]),n(f,f,t[y]);i(d,d,u[0]),n(f,f,u[1])}for(var y=0,x=t[Xi];x>y;y++){var _=t[y];if(l)c=t[y?y-1:x-1],h=t[(y+1)%x];else{if(0===y||y===x-1){p.push(e.clone(t[y]));continue}c=t[y-1],h=t[y+1]}e.sub(m,h,c),r(m,m,s);var b=a(_,c),w=a(_,h),M=b+w;0!==M&&(b/=M,w/=M),r(v,m,-b),r(g,m,w);var S=o([],_,v),k=o([],_,g);u&&(n(S,S,d),i(S,S,f),n(k,k,d),i(k,k,f)),p.push(S),p.push(k)}return l&&p.push(p.shift()),p}}),e("zrender/graphic/helper/poly",[Ji,"./smoothSpline","./smoothBezier"],function(t){var e=t("./smoothSpline"),i=t("./smoothBezier");return{buildPath:function(t,n,r){var a=n[Ct],o=n.smooth;if(a&&a[Xi]>=2){if(o&&"spline"!==o){var s=i(a,o,r,n.smoothConstraint);t[It](a[0][0],a[0][1]);for(var l=a[Xi],u=0;(r?l:l-1)>u;u++){var c=s[2*u],h=s[2*u+1],d=a[(u+1)%l];t.bezierCurveTo(c[0],c[1],h[0],h[1],d[0],d[1])}}else{"spline"===o&&(a=e(a,r)),t[It](a[0][0],a[0][1]);for(var u=1,f=a[Xi];f>u;u++)t.lineTo(a[u][0],a[u][1])}r&&t[zt]()}}}}),e("zrender/graphic/shape/Polygon",[Ji,"../helper/poly","../Path"],function(t){var e=t("../helper/poly");return t("../Path")[Ci]({type:"polygon",shape:{points:null,smooth:!1,smoothConstraint:null},buildPath:function(t,i){e[Pt](t,i,!0)}})}),e("zrender/graphic/shape/Polyline",[Ji,"../helper/poly","../Path"],function(t){var e=t("../helper/poly");return t("../Path")[Ci]({type:"polyline",shape:{points:null,smooth:!1,smoothConstraint:null},style:{stroke:"#000",fill:null},buildPath:function(t,i){e[Pt](t,i,!1)}})}),e("zrender/graphic/shape/Rect",[Ji,"../helper/roundRect","../Path"],function(t){var e=t("../helper/roundRect");return t("../Path")[Ci]({type:"rect",shape:{r:0,x:0,y:0,width:0,height:0},buildPath:function(t,i){var n=i.x,r=i.y,a=i.width,o=i[di];i.r?e[Pt](t,i):t.rect(n,r,a,o),t[zt]()}})}),e("zrender/graphic/shape/Line",[Ji,"../Path"],function(t){return t("../Path")[Ci]({type:"line",shape:{x1:0,y1:0,x2:0,y2:0,percent:1},style:{stroke:"#000",fill:null},buildPath:function(t,e){var i=e.x1,n=e.y1,r=e.x2,a=e.y2,o=e.percent;0!==o&&(t[It](i,n),1>o&&(r=i*(1-o)+r*o,a=n*(1-o)+a*o),t.lineTo(r,a))},pointAt:function(t){var e=this.shape;return[e.x1*(1-t)+e.x2*t,e.y1*(1-t)+e.y2*t]}})}),e("zrender/graphic/shape/BezierCurve",[Ji,"../../core/curve","../Path"],function(t){var e=t("../../core/curve"),i=e.quadraticSubdivide,n=e.cubicSubdivide,r=e.quadraticAt,a=e.cubicAt,o=[];return t("../Path")[Ci]({type:"bezier-curve",shape:{x1:0,y1:0,x2:0,y2:0,cpx1:0,cpy1:0,percent:1},style:{stroke:"#000",fill:null},buildPath:function(t,e){var r=e.x1,a=e.y1,s=e.x2,l=e.y2,u=e.cpx1,c=e.cpy1,h=e.cpx2,d=e.cpy2,f=e.percent;0!==f&&(t[It](r,a),null==h||null==d?(1>f&&(i(r,u,s,f,o),u=o[1],s=o[2],i(a,c,l,f,o),c=o[1],l=o[2]),t.quadraticCurveTo(u,c,s,l)):(1>f&&(n(r,u,h,s,f,o), -u=o[1],h=o[2],s=o[3],n(a,c,d,l,f,o),c=o[1],d=o[2],l=o[3]),t.bezierCurveTo(u,c,h,d,s,l)))},pointAt:function(t){var e=this.shape,i=e.cpx2,n=e.cpy2;return null===i||null===n?[r(e.x1,e.cpx1,e.x2,t),r(e.y1,e.cpy1,e.y2,t)]:[a(e.x1,e.cpx1,e.cpx1,e.x2,t),a(e.y1,e.cpy1,e.cpy1,e.y2,t)]}})}),e("zrender/graphic/shape/Arc",[Ji,"../Path"],function(t){return t("../Path")[Ci]({type:"arc",shape:{cx:0,cy:0,r:0,startAngle:0,endAngle:2*Math.PI,clockwise:!0},style:{stroke:"#000",fill:null},buildPath:function(t,e){var i=e.cx,n=e.cy,r=Math.max(e.r,0),a=e.startAngle,o=e.endAngle,s=e.clockwise,l=Math.cos(a),u=Math.sin(a);t[It](l*r+i,u*r+n),t.arc(i,n,r,a,o,!s)}})}),e("zrender/graphic/LinearGradient",[Ji,ui,"./Gradient"],function(t){var e=t(ui),i=t("./Gradient"),n=function(t,e,n,r,a){this.x=null==t?0:t,this.y=null==e?0:e,this.x2=null==n?1:n,this.y2=null==r?0:r,i.call(this,a)};return n[Ki]={constructor:n,type:"linear",updateCanvasGradient:function(t,e){for(var i=t[ii](),n=this.x*i.width+i.x,r=this.x2*i.width+i.x,a=this.y*i[di]+i.y,o=this.y2*i[di]+i.y,s=e.createLinearGradient(n,a,r,o),l=this.colorStops,u=0;u=0?"white":i,a=e[ri](ni);h[Ci](t,{textDistance:e[wi](vi)||5,textFont:a[ei](),textPosition:n,textFill:a[gt]()||r})},x[vt]=h.curry(c,!0),x[mt]=h.curry(c,!1),x.getTransform=function(t,e){for(var i=v.identity([]);t&&t!==e;)v.mul(i,t[ue](),i),t=t[ce];return i},x[fi]=function(t,e,i){return i&&(e=v.invert([],e)),g[fi]([],t,e)},x.transformDirection=function(t,e,i){var n=0===e[4]||0===e[5]||0===e[0]?1:Math.abs(2*e[4]/e[0]),r=0===e[4]||0===e[5]||0===e[2]?1:Math.abs(2*e[4]/e[2]),a=["left"===t?-n:"right"===t?n:0,"top"===t?-r:t===Oi?r:0];return a=x[fi](a,e,i),Math.abs(a[0])>Math.abs(a[1])?a[0]>0?"right":"left":a[1]>0?Oi:"top"},x}),e(pt,[],function(){function t(t){var e={},i={},n=t.match(/Web[kK]it[\/]{0,1}([\d.]+)/),r=t.match(/(Android);?[\s\/]+([\d.]+)?/),a=t.match(/(iPad).*OS\s([\d_]+)/),o=t.match(/(iPod)(.*OS\s([\d_]+))?/),s=!a&&t.match(/(iPhone\sOS)\s([\d_]+)/),l=t.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),u=l&&t.match(/TouchPad/),c=t.match(/Kindle\/([\d.]+)/),h=t.match(/Silk\/([\d._]+)/),d=t.match(/(BlackBerry).*Version\/([\d.]+)/),f=t.match(/(BB10).*Version\/([\d.]+)/),p=t.match(/(RIM\sTablet\sOS)\s([\d.]+)/),m=t.match(/PlayBook/),v=t.match(/Chrome\/([\d.]+)/)||t.match(/CriOS\/([\d.]+)/),g=t.match(/Firefox\/([\d.]+)/),y=n&&t.match(/Mobile\//)&&!v,x=t.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/)&&!v,_=t.match(/MSIE\s([\d.]+)/)||t.match(/Trident\/.+?rv:(([\d.]+))/),b=t.match(/Edge\/([\d.]+)/);return(i.webkit=!!n)&&(i.version=n[1]),r&&(e.android=!0,e.version=r[2]),s&&!o&&(e.ios=e.iphone=!0,e.version=s[2][Ni](/_/g,".")),a&&(e.ios=e.ipad=!0,e.version=a[2][Ni](/_/g,".")),o&&(e.ios=e.ipod=!0,e.version=o[3]?o[3][Ni](/_/g,"."):null),l&&(e.webos=!0,e.version=l[2]),u&&(e.touchpad=!0),d&&(e.blackberry=!0,e.version=d[2]),f&&(e.bb10=!0,e.version=f[2]),p&&(e.rimtabletos=!0,e.version=p[2]),m&&(i.playbook=!0),c&&(e.kindle=!0,e.version=c[1]),h&&(i.silk=!0,i.version=h[1]),!h&&e.android&&t.match(/Kindle Fire/)&&(i.silk=!0),v&&(i.chrome=!0,i.version=v[1]),g&&(i.firefox=!0,i.version=g[1]),_&&(i.ie=!0,i.version=_[1]),y&&(t.match(/Safari/)||e.ios)&&(i.safari=!0),x&&(i.webview=!0),_&&(i.ie=!0,i.version=_[1]),b&&(i.edge=!0,i.version=b[1]),e.tablet=!!(a||m||r&&!t.match(/Mobile/)||g&&t.match(/Tablet/)||_&&!t.match(/Phone/)&&t.match(/Touch/)),e.phone=!(e.tablet||e.ipod||!(r||s||l||d||f||v&&t.match(/Android/)||v&&t.match(/CriOS\/([\d.]+)/)||g&&t.match(/Mobile/)||_&&t.match(/Touch/))),{browser:i,os:e,node:!1,canvasSupported:document[Ui](ji)[qi]?!0:!1,touchEventsSupported:"ontouchstart"in window&&!i.ie&&!i.edge,pointerEventsSupported:"onpointerdown"in window&&(i.edge||i.ie&&i.version>=10)}}var e={};return e=typeof navigator===gi?{browser:{},os:{},node:!0,canvasSupported:!0}:t(navigator.userAgent)}),e(ft,[Ji,"../mixin/Eventful"],function(t){function e(t){return t.getBoundingClientRect?t.getBoundingClientRect():{left:0,top:0}}function i(t,i){if(i=i||window.event,null!=i.zrX)return i;var n=i.type,r=n&&n[Hi]("touch")>=0;if(r){var a="touchend"!=n?i.targetTouches[0]:i.changedTouches[0];if(a){var o=e(t);i.zrX=a.clientX-o.left,i.zrY=a.clientY-o.top}}else{var s=e(t);i.zrX=i.clientX-s.left,i.zrY=i.clientY-s.top,i.zrDelta=i.wheelDelta?i.wheelDelta/120:-(i.detail||0)/3}return i}function n(t,e,i){o?t.addEventListener(e,i):t.attachEvent("on"+e,i)}function r(t,e,i){o?t.removeEventListener(e,i):t.detachEvent("on"+e,i)}var a=t("../mixin/Eventful"),o=typeof window!==gi&&!!window.addEventListener,s=o?function(t){t.preventDefault(),t.stopPropagation(),t.cancelBubble=!0}:function(t){t.returnValue=!1,t.cancelBubble=!0};return{normalizeEvent:i,addEventListener:n,removeEventListener:r,stop:s,Dispatcher:a}}),e("zrender/mixin/Draggable",[Ji],function(t){function e(){this.on("mousedown",this._dragStart,this),this.on(dt,this._drag,this),this.on("mouseup",this._dragEnd,this),this.on("globalout",this._dragEnd,this)}return e[Ki]={constructor:e,_dragStart:function(t){var e=t[oe];e&&e[ee]&&(this._draggingTarget=e,e.dragging=!0,this._x=t[ht],this._y=t[ct],this._dispatchProxy(e,"dragstart",t.event))},_drag:function(t){var e=this._draggingTarget;if(e){var i=t[ht],n=t[ct],r=i-this._x,a=n-this._y;this._x=i,this._y=n,e.drift(r,a,t),this._dispatchProxy(e,"drag",t.event);var o=this.findHover(i,n,e),s=this._dropTarget;this._dropTarget=o,e!==o&&(s&&o!==s&&this._dispatchProxy(s,"dragleave",t.event),o&&o!==s&&this._dispatchProxy(o,"dragenter",t.event))}},_dragEnd:function(t){var e=this._draggingTarget;e&&(e.dragging=!1),this._dispatchProxy(e,"dragend",t.event),this._dropTarget&&this._dispatchProxy(this._dropTarget,"drop",t.event),this._draggingTarget=null,this._dropTarget=null}},e}),e("zrender/core/GestureMgr",[Ji],function(t){function e(t){var e=t[1][0]-t[0][0],i=t[1][1]-t[0][1];return Math.sqrt(e*e+i*i)}function i(t){return[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2]}var n=function(){this._track=[]};n[Ki]={constructor:n,recognize:function(t,e){return this._doTrack(t,e),this._recognize(t)},clear:function(){return this._track[Xi]=0,this},_doTrack:function(t,e){var i=t.touches;if(i){for(var n={points:[],touches:[],target:e,event:t},r=0,a=i[Xi];a>r;r++){var o=i[r];n[Ct].push([o.clientX,o.clientY]),n.touches.push(o)}this._track.push(n)}},_recognize:function(t){for(var e in r)if(r.hasOwnProperty(e)){var i=r[e](this._track,t);if(i)return i}}};var r={pinch:function(t,n){var r=t[Xi];if(r){var a=(t[r-1]||{})[Ct],o=(t[r-2]||{})[Ct]||a;if(o&&o[Xi]>1&&a&&a[Xi]>1){var s=e(a)/e(o);!isFinite(s)&&(s=1),n.pinchScale=s;var l=i(a);return n.pinchX=l[0],n.pinchY=l[1],{type:"pinch",target:t[0][oe],event:n}}}}};return n}),e("zrender/Handler",[Ji,"./core/env","./core/event","./core/util","./mixin/Draggable","./core/GestureMgr","./mixin/Eventful"],function(t){function e(t,e,i){return{type:t,event:i,target:e,cancelBubble:!1,offsetX:i.zrX,offsetY:i.zrY,gestureEvent:i.gestureEvent,pinchX:i.pinchX,pinchY:i.pinchY,pinchScale:i.pinchScale,wheelDelta:i.zrDelta}}function i(t,e,i){var n=t._gestureMgr;"start"===i&&n.clear();var r=n.recognize(e,t.findHover(e.zrX,e.zrY,null));if("end"===i&&n.clear(),r){var a=r.type;e.gestureEvent=a,t._dispatchProxy(r[oe],a,r.event)}}function n(t){function e(t,e){return function(){return e._touching?void 0:t.apply(e,arguments)}}for(var i=v[Gi](g),n=0;n=0;a--)if(!n[a].silent&&n[a]!==i&&r(n[a],t,e))return n[a]}},h.mixin(M,p),h.mixin(M,d),M}),e("zrender/Storage",[Ji,"./core/util","./container/Group"],function(t){function e(t,e){return t[ot]===e[ot]?t.z===e.z?t.z2===e.z2?t.__renderidx-e.__renderidx:t.z2-e.z2:t.z-e.z:t[ot]-e[ot]}var i=t("./core/util"),n=t("./container/Group"),r=function(){this._elements={},this._roots=[],this._displayList=[],this._displayListLen=0};return r[Ki]={constructor:r,getDisplayList:function(t){return t&&this.updateDisplayList(),this._displayList},updateDisplayList:function(){this._displayListLen=0;for(var t=this._roots,i=this._displayList,n=0,r=t[Xi];r>n;n++){var a=t[n];this._updateAndAddDisplayable(a)}i[Xi]=this._displayListLen;for(var n=0,r=i[Xi];r>n;n++)i[n].__renderidx=n;i.sort(e)},_updateAndAddDisplayable:function(t,e){if(!t[te]){t.beforeUpdate(),t[xe](),t.afterUpdate();var i=t.clipPath;if(i&&(i[ce]=t,i.updateTransform(),e?(e=e.slice(),e.push(i)):e=[i]),"group"==t.type){for(var n=t._children,r=0;re;e++)this.delRoot(t[e]);else{var o;o=typeof t==Wi?this._elements[t]:t;var s=i[Hi](this._roots,o);s>=0&&(this[Yt](o.id),this._roots[Te](s,1),o instanceof n&&o.delChildrenFromStorage(this))}},addToMap:function(t){return t instanceof n&&(t.__storage=this),t.dirty(),this._elements[t.id]=t,this},get:function(t){return this._elements[t]},delFromMap:function(t){var e=this._elements,i=e[t];return i&&(delete e[t],i instanceof n&&(i.__storage=null)),this},dispose:function(){this._elements=this._renderList=this._roots=null}},r}),e("zrender/animation/Animation",[Ji,ui,"../core/event","./Animator"],function(t){var e=t(ui),i=t("../core/event").Dispatcher,n=typeof window!==gi&&(window.requestAnimationFrame||window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(t){setTimeout(t,16)},r=t("./Animator"),a=function(t){t=t||{},this.stage=t.stage||{},this.onframe=t.onframe||function(){},this._clips=[],this._running=!1,this._time=0,i.call(this)};return a[Ki]={constructor:a,addClip:function(t){this._clips.push(t)},addAnimator:function(t){t[re]=this;for(var e=t.getClips(),i=0;i=0&&this._clips[Te](i,1)},removeAnimator:function(t){for(var e=t.getClips(),i=0;io;o++){var s=i[o],l=s.step(t);l&&(r.push(l),a.push(s))}for(var o=0;n>o;)i[o]._needsRemove?(i[o]=i[n-1],i.pop(),n--):o++;n=r[Xi];for(var o=0;n>o;o++)a[o].fire(r[o]);this._time=t,this.onframe(e),this[Wt]("frame",e),this.stage[xe]&&this.stage[xe]()},start:function(){function t(){e._running&&(n(t),e._update())}var e=this;this._running=!0,this._time=(new Date).getTime(),n(t)},stop:function(){this._running=!1},clear:function(){this._clips=[]},animate:function(t,e){e=e||{};var i=new r(t,e.loop,e.getter,e.setter);return i}},e.mixin(a,i),a}),e("zrender/Layer",[Ji,"./core/util","./config"],function(t){function e(){return!1}function i(t,e,i,n){var r=document[Ui](e),a=i[we](),o=i[be](),s=r.style;return s[Oe]="absolute",s.left=0,s.top=0,s.width=a+"px",s[di]=o+"px",r.width=a*n,r[di]=o*n,r.setAttribute("data-zr-dom-id",t),r}var n=t("./core/util"),r=t("./config"),a=function(t,a,o){var s;o=o||r.devicePixelRatio,typeof t===Wi?s=i(t,ji,a,o):n[Be](t)&&(s=t,t=s.id),this.id=t,this.dom=s;var l=s.style;l&&(s.onselectstart=e,l["-webkit-user-select"]="none",l["user-select"]="none",l["-webkit-touch-callout"]="none",l["-webkit-tap-highlight-color"]="rgba(0,0,0,0)"),this.domBack=null,this.ctxBack=null,this.painter=a,this.config=null,this.clearColor=0,this.motionBlur=!1,this.lastFrameAlpha=.7,this.dpr=o};return a[Ki]={constructor:a,elCount:0,__dirty:!0,initContext:function(){this.ctx=this.dom[qi]("2d");var t=this.dpr;1!=t&&this.ctx.scale(t,t)},createBackBuffer:function(){var t=this.dpr;this.domBack=i("back-"+this.id,ji,this.painter,t),this.ctxBack=this.domBack[qi]("2d"),1!=t&&this.ctxBack.scale(t,t)},resize:function(t,e){var i=this.dpr,n=this.dom,r=n.style,a=this.domBack;r.width=t+"px",r[di]=e+"px",n.width=t*i,n[di]=e*i,1!=i&&this.ctx.scale(i,i),a&&(a.width=t*i,a[di]=e*i,1!=i&&this.ctxBack.scale(i,i))},clear:function(t){var e=this.dom,i=this.ctx,n=e.width,r=e[di],a=this.clearColor,o=this.motionBlur&&!t,s=this.lastFrameAlpha,l=this.dpr;if(o&&(this.domBack||this.createBackBuffer(),this.ctxBack.globalCompositeOperation="copy",this.ctxBack.drawImage(e,0,0,n/l,r/l)),i.clearRect(0,0,n/l,r/l),a&&(i.save(),i.fillStyle=this.clearColor,i.fillRect(0,0,n/l,r/l),i[Lt]()),o){var u=this.domBack;i.save(),i.globalAlpha=s,i.drawImage(u,0,0,n/l,r/l),i[Lt]()}}},a}),e("zrender/Painter",[Ji,"./config","./core/util","./core/log","./core/BoundingRect","./Layer","./graphic/Image"],function(t){function e(t){return parseInt(t,10)}function i(t){return t?t.isBuildin?!0:typeof t[at]!==Vi||typeof t[Jt]!==Vi?!1:!0:!1}function n(t){t.__unusedCount++}function r(t){t[Kt]=!1,1==t.__unusedCount&&t.clear()}function a(t,e,i){return f.copy(t[ii]()),t[he]&&f[fi](t[he]),p.width=e,p[di]=i,!f[rt](p)}function o(t,e){if(!t||!e||t[Xi]!==e[Xi])return!0;for(var i=0;ip;p++){var v=t[p],g=this._singleCanvas?0:v[ot];if(l!==g&&(l=g,i=this.getLayer(l),i.isBuildin||c("ZLevel "+l+" has been used by unkown layer "+i.id),u=i.ctx,i.__unusedCount=0,(i[Kt]||e)&&i.clear()),(i[Kt]||e)&&!v[Ut]&&0!==v.style[xi]&&v.scale[0]&&v.scale[1]&&(!v.culling||!a(v,h,d))){var y=v.__clipPaths;o(y,f)&&(f&&u[Lt](),y&&(u.save(),s(y,u)),f=y),v.beforeBrush&&v.beforeBrush(u),v.brush(u,!1),v.afterBrush&&v.afterBrush(u)}v[Kt]=!1}f&&u[Lt](),this.eachBuildinLayer(r)},getLayer:function(t){if(this._singleCanvas)return this._layers[0];var e=this._layers[t];return e||(e=new d("zr_"+t,this,this.dpr),e.isBuildin=!0,this._layerConfig[t]&&u.merge(e,this._layerConfig[t],!0),this.insertLayer(t,e),e.initContext()),e},insertLayer:function(t,e){var n=this._layers,r=this._zlevelList,a=r[Xi],o=null,s=-1,l=this._domRoot;if(n[t])return void c("ZLevel "+t+" has been used already");if(!i(e))return void c("Layer of zlevel "+t+" is not valid");if(a>0&&t>r[0]){for(s=0;a-1>s&&!(r[s]t);s++);o=n[r[s]]}if(r[Te](s+1,0,t),o){var u=o.dom;u.nextSibling?l.insertBefore(e.dom,u.nextSibling):l[it](e.dom)}else l.firstChild?l.insertBefore(e.dom,l.firstChild):l[it](e.dom);n[t]=e},eachLayer:function(t,e){var i,n,r=this._zlevelList;for(n=0;nn;n++){var a=t[n],o=this._singleCanvas?0:a[ot],s=e[o];if(s){if(s.elCount++,s[Kt])continue;s[Kt]=a[Kt]}}this.eachBuildinLayer(function(t,e){i[e]!==t.elCount&&(t[Kt]=!0)})},clear:function(){return this.eachBuildinLayer(this._clearLayer),this},_clearLayer:function(t){t.clear()},configLayer:function(t,e){if(e){var i=this._layerConfig;i[t]?u.merge(i[t],e,!0):i[t]=e;var n=this._layers[t];n&&u.merge(n,i[t],!0)}},delLayer:function(t){var e=this._layers,i=this._zlevelList,n=e[t];n&&(n.dom[ut].removeChild(n.dom),delete e[t],i[Te](u[Hi](i,t),1))},resize:function(t,e){var i=this._domRoot;if(i.style.display="none",t=t||this._getWidth(),e=e||this._getHeight(),i.style.display="",this._width!=t||e!=this._height){i.style.width=t+"px",i.style[di]=e+"px";for(var n in this._layers)this._layers[n][at](t,e);this[Jt](!0)}return this._width=t,this._height=e,this},clearLayer:function(t){var e=this._layers[t];e&&e.clear()},dispose:function(){this.root[nt]="",this.root=this[lt]=this._domRoot=this._layers=null},getRenderedCanvas:function(t){if(t=t||{},this._singleCanvas)return this._layers[0].dom;var e=new d("image",this,t.pixelRatio||this.dpr);e.initContext();var i=e.ctx;e.clearColor=t[et],e.clear();for(var n=this[lt][st](!0),r=0;rt;t++)this._add&&this._add(u[t]);else this._add&&this._add(u)}}},i}),e("echarts/data/List",[Ji,"../model/Model","./DataDiffer",Qi,"../util/model"],function(t){function e(t){return c[Di](t)||(t=[t]),t}function i(t,e){var i=t[Z],n=new m(c.map(i,t.getDimensionInfo,t),t[H]);p(n,t,t._wrappedMethods);for(var r=n._storage={},a=t._storage,o=0;o=0?r[s]=new l.constructor(a[s][Xi]):r[s]=a[s]}return n}var n=gi,r=typeof window===gi?global:window,a=typeof r.Float64Array===n?Array:r.Float64Array,o=typeof r.Int32Array===n?Array:r.Int32Array,s={"float":a,"int":o,ordinal:Array,number:Array,time:Array},l=t("../model/Model"),u=t("./DataDiffer"),c=t(Qi),h=t("../util/model"),d=c[Be],f=["stackedOn","_nameList","_idList","_rawData"],p=function(t,e,i){c.each(f[Gi](i||[]),function(i){e.hasOwnProperty(i)&&(t[i]=e[i])})},m=function(t,e){t=t||["x","y"];for(var i={},n=[],r=0;r0&&(b+="__ec__"+d[w]),d[w]++),b&&(u[f]=b)}this._nameList=e,this._idList=u},v.count=function(){return this.indices[Xi]},v.get=function(t,e,i){var n=this._storage,r=this.indices[e],a=n[t]&&n[t][r];if(i){var o=this._dimensionInfos[t];if(o&&o.stackable)for(var s=this.stackedOn;s;){var l=s.get(t,e);(a>=0&&l>0||0>=a&&0>l)&&(a+=l),s=s.stackedOn}}return a},v.getValues=function(t,e,i){var n=[];c[Di](t)||(i=e,e=t,t=this[Z]);for(var r=0,a=t[Xi];a>r;r++)n.push(this.get(t[r],e,i));return n},v.hasValue=function(t){for(var e=this[Z],i=this._dimensionInfos,n=0,r=e[Xi];r>n;n++)if(i[e[n]].type!==We&&isNaN(this.get(e[n],t)))return!1;return!0},v[B]=function(t,e){var i=this._storage[t],n=this.getDimensionInfo(t);e=n&&n.stackable&&e;var r,a=(this._extent||(this._extent={}))[t+!!e];if(a)return a;if(i){for(var o=1/0,s=-(1/0),l=0,u=this.count();u>l;l++)r=this.get(t,l,e),o>r&&(o=r),r>s&&(s=r);return this._extent[t+e]=[o,s]}return[1/0,-(1/0)]},v.getSum=function(t,e){var i=this._storage[t],n=0;if(i)for(var r=0,a=this.count();a>r;r++){var o=this.get(t,r,e);isNaN(o)||(n+=o)}return n},v[Hi]=function(t,e){var i=this._storage,n=i[t],r=this.indices;if(n)for(var a=0,o=r[Xi];o>a;a++){var s=r[a];if(n[s]===e)return a}return-1},v[Vt]=function(t){for(var e=this.indices,i=this._nameList,n=0,r=e[Xi];r>n;n++){var a=e[n];if(i[a]===t)return n}return-1},v.indexOfNearest=function(t,e,i){var n=this._storage,r=n[t];if(r){for(var a=Number.MAX_VALUE,o=-1,s=0,l=this.count();l>s;s++){var u=Math.abs(this.get(t,s,i)-e);a>=u&&(a=u,o=s)}return o}return-1},v[Ge]=function(t){var e=this.indices[t];return null==e?-1:e},v[Ve]=function(t){return this._nameList[this.indices[t]]||""},v.getId=function(t){return this._idList[this.indices[t]]||this[Ge](t)+""},v.each=function(t,i,n,r){typeof t===Vi&&(r=n,n=i,i=t,t=[]),t=c.map(e(t),this.getDimension,this);var a=[],o=t[Xi],s=this.indices;r=r||this;for(var l=0;lu;u++)a[u]=this.get(t[u],l,n);a[u]=l,i.apply(r,a)}},v.filterSelf=function(t,i,n,r){typeof t===Vi&&(r=n,n=i,i=t,t=[]),t=c.map(e(t),this.getDimension,this);var a=[],o=[],s=t[Xi],l=this.indices;r=r||this;for(var u=0;ud;d++)o[d]=this.get(t[d],u,n);o[d]=u,h=i.apply(r,o)}h&&a.push(l[u])}return this.indices=a,this._extent={},this},v[R]=function(t,e,i,n){typeof t===Vi&&(n=i,i=e,e=t,t=[]);var r=[];return this.each(t,function(){r.push(e&&e.apply(this,arguments))},i,n),r},v.map=function(t,n,r,a){t=c.map(e(t),this.getDimension,this);var o=i(this,t),s=o.indices=this.indices,l=o._storage,u=[];return this.each(t,function(){var e=arguments[arguments[Xi]-1],i=n&&n.apply(this,arguments);if(null!=i){typeof i===Fi&&(u[0]=i,i=u);for(var r=0;rm;m+=d){d>p-m&&(d=p-m,c[Xi]=d);for(var v=0;d>v;v++){var g=l[m+v];c[v]=f[g],h[v]=g}var y=n(c),g=h[r(c,y)||0];f[g]=y,u.push(g)}return a},v[Ne]=function(t){var e=this[H];return t=this.indices[t],new l(this._rawData[t],e,e[ai])},v.diff=function(t){var e=this._idList,i=t&&t._idList;return new u(t?t.indices:[],this.indices,function(t){return i[t]||t+""},function(t){return e[t]||t+""})},v[O]=function(t){var e=this._visual;return e&&e[t]},v[Q]=function(t,e){if(d(t))for(var i in t)t.hasOwnProperty(i)&&this[Q](i,t[i]);else this._visual=this._visual||{},this._visual[t]=e},v.setLayout=function(t,e){if(d(t))for(var i in t)t.hasOwnProperty(i)&&this.setLayout(i,t[i]);else this._layout[t]=e},v.getLayout=function(t){return this._layout[t]},v[I]=function(t){return this._itemLayouts[t]},v[z]=function(t,e,i){this._itemLayouts[t]=i?c[Ci](this._itemLayouts[t]||{},e):e},v[P]=function(t,e,i){var n=this._itemVisuals[t],r=n&&n[e];return null!=r||i?r:this[O](e)},v[$]=function(t,e,i){var n=this._itemVisuals[t]||{};if(this._itemVisuals[t]=n,d(e))for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);else n[e]=i};var g=function(t){t[qe]=this[qe],t[Ft]=this[Ft]};return v[L]=function(t,e){var i=this[H];e&&(e[Ft]=t,e[qe]=i&&i[qe],"group"===e.type&&e[Xt](g,e)),this._graphicEls[t]=e},v[Gt]=function(t){return this._graphicEls[t]},v[Nt]=function(t,e){c.each(this._graphicEls,function(i,n){i&&t&&t.call(e,i,n)})},v.cloneShallow=function(){var t=c.map(this[Z],this.getDimensionInfo,this),e=new m(t,this[H]);return e._storage=this._storage,p(e,this,this._wrappedMethods),e.indices=this.indices.slice(),e},v.wrapMethod=function(t,e){var i=this[t];typeof i===Vi&&(this._wrappedMethods=this._wrappedMethods||[],this._wrappedMethods.push(t),this[t]=function(){var t=i.apply(this,arguments);return e.call(this,t)})},m}),e("echarts/data/helper/completeDimensions",[Ji,Qi],function(t){function e(t,e,a){if(!e)return t;var o=n(e[0]),s=r[Di](o)&&o[Xi]||1;a=a||[];for(var l=0;s>l;l++)if(!t[l]){var u=a[l]||"extra"+(l-a[Xi]);t[l]=i(e,l)?{type:"ordinal",name:u}:u}return t}function i(t,e){for(var i=0,a=t[Xi];a>i;i++){var o=n(t[i]);if(!r[Di](o))return!1;var o=o[e];if(null!=o&&isFinite(o))return!1;if(r[ke](o)&&"-"!==o)return!0}return!1}function n(t){return r[Di](t)?t:r[Be](t)?t.value:t}var r=t(Qi);return e}),e("echarts/chart/helper/createListFromArray",[Ji,"../../data/List","../../data/helper/completeDimensions",Qi,D,"../../CoordinateSystem"],function(t){function e(t){for(var e=0;e1){i=[];for(var a=0;r>a;a++)i[a]=n[e[a][0]]}else i=n.slice(0)}}return i}var s=t("../../data/List"),l=t("../../data/helper/completeDimensions"),u=t(Qi),c=t(D),h=t("../../CoordinateSystem"),d=c.getDataItemValue,f=c.converDataValue,p={cartesian2d:function(t,e,i){var n=i[ge]("xAxis",e.get("xAxisIndex")),o=i[ge]("yAxis",e.get("yAxisIndex")),s=n.get("type"),u=o.get("type"),c=[{name:"x",type:a(s),stackable:r(s)},{name:"y",type:a(u),stackable:r(u)}];return l(c,t,["x","y","z"]),{dimensions:c,categoryAxisModel:s===A?n:u===A?o:null}},polar:function(t,e,i){var n=e.get("polarIndex")||0,o=function(t){return t.get("polarIndex")===n},s=i[Se]({mainType:"angleAxis",filter:o})[0],u=i[Se]({mainType:"radiusAxis",filter:o})[0],c=u.get("type"),h=s.get("type"),d=[{name:"radius",type:a(c),stackable:r(c)},{name:"angle",type:a(h),stackable:r(h)}];return l(d,t,[Ke,"angle","value"]),{dimensions:d,categoryAxisModel:h===A?s:c===A?u:null}},geo:function(t,e,i){return{dimensions:l([{name:"lng"},{name:"lat"}],t,["lng","lat","value"])}}};return n}),e("echarts/chart/line/LineSeries",[Ji,"../helper/createListFromArray","../../model/Series"],function(t){var e=t("../helper/createListFromArray"),i=t("../../model/Series");return i[Ci]({type:"series.line",dependencies:["grid","polar"],getInitialData:function(t,i){return e(t.data,this,i)},defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,hoverAnimation:!0,xAxisIndex:0,yAxisIndex:0,polarIndex:0,clipOverflow:!0,label:{normal:{position:"top"},emphasis:{position:"top"}},lineStyle:{normal:{width:2,type:"solid"}},symbol:"emptyCircle",symbolSize:4,showSymbol:!0,animationEasing:"linear"}})}),e("echarts/util/symbol",[Ji,"./graphic",pi],function(t){var e=t("./graphic"),i=t(pi),n=e[St]({type:"triangle",shape:{cx:0,cy:0,width:0,height:0},buildPath:function(t,e){var i=e.cx,n=e.cy,r=e.width/2,a=e[di]/2;t[It](i,n-a),t.lineTo(i+r,n+a),t.lineTo(i-r,n+a),t[zt]()}}),r=e[St]({type:"diamond",shape:{cx:0,cy:0,width:0,height:0},buildPath:function(t,e){var i=e.cx,n=e.cy,r=e.width/2,a=e[di]/2;t[It](i,n-a),t.lineTo(i+r,n),t.lineTo(i,n+a),t.lineTo(i-r,n),t[zt]()}}),a=e[St]({type:"pin",shape:{x:0,y:0,width:0,height:0},buildPath:function(t,e){var i=e.x,n=e.y,r=e.width/5*3,a=Math.max(r,e[di]),o=r/2,s=o*o/(a-o),l=n-a+o+s,u=Math.asin(s/o),c=Math.cos(u)*o,h=Math.sin(u),d=Math.cos(u);t.arc(i,l,o,Math.PI-u,2*Math.PI+u);var f=.6*o,p=.7*o;t.bezierCurveTo(i+c-h*f,l+s+d*f,i,n-p,i,n),t.bezierCurveTo(i,n-p,i-c+h*f,l+s+d*f,i-c,l+s),t[zt]()}}),o=e[St]({type:"arrow",shape:{x:0,y:0,width:0,height:0},buildPath:function(t,e){var i=e[di],n=e.width,r=e.x,a=e.y,o=n/3*2;t[It](r,a),t.lineTo(r+o,a+i),t.lineTo(r,a+i/4*3),t.lineTo(r-o,a+i),t.lineTo(r,a),t[zt]()}}),s={line:e.Line,rect:e.Rect,roundRect:e.Rect,square:e.Rect,circle:e.Circle,diamond:r,pin:a,arrow:o,triangle:n},l={line:function(t,e,i,n,r){r.x1=t,r.y1=e+n/2,r.x2=t+i,r.y2=e+n/2},rect:function(t,e,i,n,r){r.x=t,r.y=e,r.width=i,r[di]=n},roundRect:function(t,e,i,n,r){r.x=t,r.y=e,r.width=i,r[di]=n,r.r=Math.min(i,n)/4},square:function(t,e,i,n,r){var a=Math.min(i,n);r.x=t,r.y=e,r.width=a,r[di]=a},circle:function(t,e,i,n,r){r.cx=t+i/2,r.cy=e+n/2,r.r=Math.min(i,n)/2},diamond:function(t,e,i,n,r){r.cx=t+i/2,r.cy=e+n/2,r.width=i,r[di]=n},pin:function(t,e,i,n,r){r.x=t+i/2,r.y=e+n/2,r.width=i,r[di]=n},arrow:function(t,e,i,n,r){r.x=t+i/2,r.y=e+n/2,r.width=i,r[di]=n},triangle:function(t,e,i,n,r){r.cx=t+i/2,r.cy=e+n/2,r.width=i,r[di]=n}},u={};for(var c in s)u[c]=new s[c];var h=e[St]({type:"symbol",shape:{symbolType:"",x:0,y:0,width:0,height:0},beforeBrush:function(){var t=this.style,e=this.shape;"pin"===e.symbolType&&t[Et]===si&&(t[Et]=["50%","40%"],t[Zt]=Bi,t[Bt]=Ri)},buildPath:function(t,e){var i=e.symbolType,n=u[i];"none"!==e.symbolType&&(n||(i="rect",n=u[i]),l[i](e.x,e.y,e.width,e[di],n.shape),n[Pt](t,n.shape))}}),d=function(t){if("image"!==this.type){var e=this.style,i=this.shape;i&&"line"===i.symbolType?e[_i]=t:this.__isEmptyBrush?(e[_i]=t,e.fill="#fff"):(e.fill&&(e.fill=t),e[_i]&&(e[_i]=t)),this.dirty()}},f={createSymbol:function(t,n,r,a,o,s){var l=0===t[Hi]("empty");l&&(t=t.substr(5,1)[Pi]()+t.substr(6));var u;return u=0===t[Hi]("image://")?new e.Image({style:{image:t.slice(8),x:n,y:r,width:a,height:o}}):0===t[Hi]("path://")?e.makePath(t.slice(7),{},new i(n,r,a,o)):new h({shape:{symbolType:t,x:n,y:r,width:a,height:o}}),u.__isEmptyBrush=l,u.setColor=d,u.setColor(s),u}};return f}),e("echarts/chart/helper/Symbol",[Ji,Qi,C,T,k],function(t){function e(t){return r[Di](t)||(t=[+t,+t]),t}function i(t,e){o.Group.call(this),this[S](t,e)}function n(t,e){this[ce].drift(t,e)}var r=t(Qi),a=t(C),o=t(T),s=t(k),l=i[Ki];l._createSymbol=function(t,i,r){this[qt]();var s=i[H],l=i[P](r,"color"),u=a[M](t,-.5,-.5,1,1,l);u.attr({style:{strokeNoScale:!0},z2:100,culling:!0,scale:[0,0]}),u.drift=n;var c=e(i[P](r,w));o[mt](u,{scale:c},s),this._symbolType=t,this.add(u)},l.stopSymbolAnimation=function(t){this[Ie](0)[ne](t)},l.getScale=function(){return this[Ie](0).scale},l.highlight=function(){this[Ie](0)[Wt](Xe)},l.downplay=function(){this[Ie](0)[Wt](Ue)},l.setZ=function(t,e){var i=this[Ie](0);i[ot]=t,i.z=e},l.setDraggable=function(t){var e=this[Ie](0);e[ee]=t,e.cursor=t?"move":"pointer"},l[S]=function(t,i){var n=t[P](i,b)||_,r=t[H],a=e(t[P](i,w));if(n!==this._symbolType)this._createSymbol(n,t,i);else{var s=this[Ie](0);o[vt](s,{scale:a},r)}this._updateCommon(t,i,a),this._seriesModel=r};var u=[U,Ue],c=[U,Xe],h=["label",Ue],d=["label",Xe];return l._updateCommon=function(t,i,n){var a=this[Ie](0),l=t[H],f=t[Ne](i),p=f[ri](u),m=t[P](i,"color"),v=f[ri](c)[x]();a[de]=f[wi]("symbolRotate")*Math.PI/180||0;var g=f[wi]("symbolOffset");if(g){var _=a[Oe];_[0]=s[Zi](g[0],n[0]),_[1]=s[Zi](g[1],n[1])}a.setColor(m),r[Ci](a.style,p[x](["color"]));for(var b,M=f[ri](h),S=f[ri](d),k=a.style,T=t[Z].slice(),C=T.pop();(b=t.getDimensionInfo(C).type)===We||"time"===b;)C=T.pop();M.get("show")?(o.setText(k,M,m),k.text=r[je](l[y](i,Ue),t.get(C,i))):k.text="",S[wi]("show")?(o.setText(v,S,m),v.text=r[je](l[y](i,Xe),t.get(C,i))):v.text="";var A=e(t[P](i,w));if(a.off(xt).off(yt).off(Xe).off(Ue),o[_t](a,v),f[wi]("hoverAnimation")){var D=function(){var t=A[1]/A[0];this.animateTo({scale:[Math.max(1.1*A[0],A[0]+3),Math.max(1.1*A[1],A[1]+3*t)]},400,"elasticOut")},L=function(){this.animateTo({scale:A},400,"elasticOut")};a.on(xt,D).on(yt,L).on(Xe,D).on(Ue,L)}},l.fadeOut=function(t){var e=this[Ie](0);e.style.text="",o[vt](e,{scale:[0,0]},this._seriesModel,t)},r[ki](i,o.Group),i}),e("echarts/chart/helper/SymbolDraw",[Ji,T,"./Symbol"],function(t){function e(t){this.group=new n.Group,this._symbolCtor=t||r}function i(t,e,i){var n=t[I](e);return n&&!isNaN(n[0])&&!isNaN(n[1])&&!(i&&i(e))&&"none"!==t[P](e,b)}var n=t(T),r=t("./Symbol"),a=e[Ki];return a[S]=function(t,e){var r=this.group,a=t[H],o=this._data,s=this._symbolCtor;t.diff(o).add(function(n){var a=t[I](n);if(i(t,n,e)){var o=new s(t,n);o.attr(Oe,a),t[L](n,o),r.add(o)}})[xe](function(l,u){var c=o[Gt](u),h=t[I](l);return i(t,l,e)?(c?(c[S](t,l),n[vt](c,{position:h},a)):(c=new s(t,l),c.attr(Oe,h)),r.add(c),void t[L](l,c)):void r[Qt](c)})[Qt](function(t){var e=o[Gt](t);e&&e.fadeOut(function(){r[Qt](e)})})[g](),this._data=t},a[jt]=function(){var t=this._data;t&&t[Nt](function(e,i){e.attr(Oe,t[I](i))})},a[Qt]=function(t){var e=this.group,i=this._data;i&&(t?i[Nt](function(t){t.fadeOut(function(){e[Qt](t)})}):e[qt]())},e}),e("echarts/chart/line/lineAnimationDiff",[Ji],function(t){function e(t){return t>=0?1:-1}function i(t,i,n){for(var r,a=t[pe](),o=t[v](a),s=a.onZero?0:o.scale[m]()[0],l=o.dim,u="x"===l||l===Ke?1:0,c=i.stackedOn,h=i.get(l,n);c&&e(c.get(l,n))===e(h);){r=c;break}var d=[];return d[u]=i.get(a.dim,n),d[1-u]=r?r.get(l,n,!0):s,t[p](d)}function n(t,e){var i=[];return e.diff(t).add(function(t){i.push({cmd:"+",idx:t})})[xe](function(t,e){i.push({cmd:"=",idx:e,idx1:t})})[Qt](function(t){i.push({cmd:"-",idx:t})})[g](),i}return function(t,e,r,a,o,s){for(var l=n(t,e),u=[],c=[],h=[],d=[],f=[],m=[],v=[],g=s[Z],y=0;yx;x++){var _=e[y];if(y>=n||0>y||isNaN(_[0])||isNaN(_[1]))break;if(y===i)t[f>0?It:"lineTo"](_[0],_[1]),l(c,_);else if(v>0){var b=y-f,w=y+f,M=.5,S=e[b],k=e[w];if(f>0&&(y===d-1||isNaN(k[0])||isNaN(k[1]))||0>=f&&(0===y||isNaN(k[0])||isNaN(k[1])))l(h,_);else{(isNaN(k[0])||isNaN(k[1]))&&(k=_),r.sub(u,k,S);var T,C;if("x"===g||"y"===g){var A="x"===g?0:1;T=Math.abs(_[A]-S[A]),C=Math.abs(_[A]-k[A])}else T=r.dist(_,S),C=r.dist(_,k);M=C/(C+T),s(h,_,u,-v*(1-M))}a(c,c,m),o(c,c,p),a(h,h,m),o(h,h,p),t.bezierCurveTo(c[0],c[1],h[0],h[1],_[0],_[1]),s(c,_,u,v*M)}else t.lineTo(_[0],_[1]);y+=f}return x}function i(t,e){var i=[1/0,1/0],n=[-(1/0),-(1/0)];if(e)for(var r=0;rn[0]&&(n[0]=a[0]),a[1]>n[1]&&(n[1]=a[1])}return{min:e?i:n,max:e?n:i}}var n=t("zrender/graphic/Path"),r=t(yi),a=r.min,o=r.max,s=r.scaleAndAdd,l=r.copy,u=[],c=[],h=[];return{Polyline:n[Ci]({type:"ec-polyline",shape:{points:[],smooth:0,smoothConstraint:!0,smoothMonotone:null},style:{fill:null,stroke:"#000"},buildPath:function(t,n){for(var r=n[Ct],a=0,o=r[Xi],s=i(r,n.smoothConstraint);o>a;)a+=e(t,r,a,o,o,1,s.min,s.max,n.smooth,n.smoothMonotone)+1}}),Polygon:n[Ci]({type:"ec-polygon",shape:{points:[],stackedOnPoints:[],smooth:0,stackedOnSmooth:0,smoothConstraint:!0,smoothMonotone:null},buildPath:function(t,n){for(var r=n[Ct],a=n.stackedOnPoints,o=0,s=r[Xi],l=n.smoothMonotone,u=i(r,n.smoothConstraint),c=i(a,n.smoothConstraint);s>o;){var h=e(t,r,o,s,s,1,u.min,u.max,n.smooth,l);e(t,a,o+h-1,s,h,-1,c.min,c.max,n.stackedOnSmooth,l),o+=h+1,t[zt]()}}})}}),e("echarts/chart/line/LineView",[Ji,Qi,"../helper/SymbolDraw","../helper/Symbol","./lineAnimationDiff",T,"./poly","../../view/Chart"],function(t){function e(t,e){if(t[Xi]===e[Xi]){for(var i=0;ie[0]?1:-1;e[0]+=n*i,e[1]-=n*i}return e}function r(t){return t>=0?1:-1}function a(t,e){var i=t[pe](),n=t[v](i),a=i.onZero?0:n.scale[m]()[0],o=n.dim,s="x"===o||o===Ke?1:0;return e[R]([o],function(n,l){for(var u,c=e.stackedOn;c&&r(c.get(o,l))===r(n);){u=c;break}var h=[];return h[s]=e.get(i.dim,l),h[1-s]=u?u.get(o,l,!0):a,t[p](h)},!0)}function o(t,e){return null!=e[Ft]?e[Ft]:null!=e.name?t[Vt](e.name):void 0}function s(t,e,i){var r=n(t[f]("x")),a=n(t[f]("y")),o=t[pe]()[d](),s=r[0],l=a[0],u=r[1]-s,c=a[1]-l;i.get("clipOverflow")||(o?(l-=c,c*=3):(s-=u,u*=3));var h=new b.Rect({shape:{x:s,y:l,width:u,height:c}});return e&&(h.shape[o?"width":di]=0,b[mt](h,{shape:{width:u,height:c}},i)),h}function l(t,e,i){var n=t.getAngleAxis(),r=t.getRadiusAxis(),a=r[m](),o=n[m](),s=Math.PI/180,l=new b[Tt]({shape:{cx:t.cx,cy:t.cy,r0:a[0],r:a[1],startAngle:-o[0]*s,endAngle:-o[1]*s,clockwise:n[h]}});return e&&(l.shape.endAngle=-o[0]*s,b[mt](l,{shape:{endAngle:-o[1]*s}},i)),l}function u(t,e,i){return"polar"===t.type?l(t,e,i):s(t,e,i)}var g=t(Qi),y=t("../helper/SymbolDraw"),x=t("../helper/Symbol"),_=t("./lineAnimationDiff"),b=t(T),w=t("./poly"),M=t("../../view/Chart");return M[Ci]({type:"line",init:function(){var t=new b.Group,e=new y;this.group.add(e.group),this._symbolDraw=e,this._lineGroup=t},render:function(t,n,r){var o=t[me],s=this.group,l=t[He](),h=t[ri]("lineStyle.normal"),d=t[ri]("areaStyle.normal"),f=l[R](l[I],!0),p="polar"===o.type,m=this._coordSys,v=this._symbolDraw,y=this._polyline,x=this._polygon,_=this._lineGroup,b=t.get(re),w=!d.isEmpty(),M=a(o,l),k=t.get("showSymbol"),T=k&&!p&&!t.get("showAllSymbol")&&this._getSymbolIgnoreFunc(l,o),C=this._data;C&&C[Nt](function(t,e){t.__temp&&(s[Qt](t),C[L](e,null))}),k||v[Qt](),s.add(_),y&&m.type===o.type?(w&&!x?x=this._newPolygon(f,M,o,b):x&&!w&&(_[Qt](x),x=this._polygon=null),_.setClipPath(u(o,!1,t)),k&&v[S](l,T),l[Nt](function(t){t[ne](!0)}),e(this._stackedOnPoints,M)&&e(this._points,f)||(b?this._updateAnimation(l,M,o,r):(y[Dt]({points:f}),x&&x[Dt]({points:f,stackedOnPoints:M})))):(k&&v[S](l,T),y=this._newPolyline(f,o,b),w&&(x=this._newPolygon(f,M,o,b)),_.setClipPath(u(o,!0,t))),y[wt](g[oi](h[c](),{stroke:l[O]("color"),lineJoin:"bevel"}));var A=t.get("smooth");if(A=i(t.get("smooth")),y[Dt]({smooth:A,smoothMonotone:t.get("smoothMonotone")}),x){var D=l.stackedOn,P=0;if(x.style[xi]=.7,x[wt](g[oi](d.getAreaStyle(),{fill:l[O]("color"),lineJoin:"bevel"})),D){var z=D[H];P=i(z.get("smooth"))}x[Dt]({smooth:A,stackedOnSmooth:P,smoothMonotone:t.get("smoothMonotone")})}this._data=l,this._coordSys=o,this._stackedOnPoints=M,this._points=f},highlight:function(t,e,i,n){var r=t[He](),a=o(r,n);if(null!=a&&a>=0){var s=r[Gt](a);if(!s){var l=r[I](a);s=new x(r,a,i),s[Oe]=l,s.setZ(t.get(ot),t.get("z")),s[te]=isNaN(l[0])||isNaN(l[1]),s.__temp=!0,r[L](a,s),s.stopSymbolAnimation(!0),this.group.add(s)}s.highlight()}else M[Ki].highlight.call(this,t,e,i,n)},downplay:function(t,e,i,n){ -var r=t[He](),a=o(r,n);if(null!=a&&a>=0){var s=r[Gt](a);s&&(s.__temp?(r[L](a,null),this.group[Qt](s)):s.downplay())}else M[Ki].downplay.call(this,t,e,i,n)},_newPolyline:function(t){var e=this._polyline;return e&&this._lineGroup[Qt](e),e=new w[kt]({shape:{points:t},silent:!0,z2:10}),this._lineGroup.add(e),this._polyline=e,e},_newPolygon:function(t,e){var i=this._polygon;return i&&this._lineGroup[Qt](i),i=new w.Polygon({shape:{points:t,stackedOnPoints:e},silent:!0}),this._lineGroup.add(i),this._polygon=i,i},_getSymbolIgnoreFunc:function(t,e){var i=e.getAxesByScale(We)[0];return i&&i.isLabelIgnored?g.bind(i.isLabelIgnored,i):void 0},_updateAnimation:function(t,e,i,n){var r=this._polyline,a=this._polygon,o=t[H],s=_(this._data,t,this._stackedOnPoints,e,this._coordSys,i);r.shape[Ct]=s.current,b[vt](r,{shape:{points:s.next}},o),a&&(a[Dt]({points:s.current,stackedOnPoints:s.stackedOnCurrent}),b[vt](a,{shape:{points:s.next,stackedOnPoints:s.stackedOnNext}},o));for(var l=[],u=s.status,c=0;ce&&(e=t[i]);return e},min:function(t){for(var e=1/0,i=0;i1){var d;typeof r===Wi?d=t[r]:typeof r===Vi&&(d=r),d&&(n=n.downSample(s.dim,1/h,d,e),i[At](n))}}},this)}}),e("echarts/chart/line",[Ji,Qi,l,"./line/LineSeries","./line/LineView","../visual/symbol","../layout/points","../processor/dataSample"],function(t){var e=t(Qi),i=t(l);t("./line/LineSeries"),t("./line/LineView"),i[V]("chart",e.curry(t("../visual/symbol"),"line",_,"line")),i[G](e.curry(t("../layout/points"),"line")),i[W]("statistic",e.curry(t("../processor/dataSample"),"line"))}),e("echarts/scale/Scale",[Ji,ti],function(t){function e(){this._extent=[1/0,-(1/0)],this._interval=0,this.init&&this.init.apply(this,arguments)}var i=t(ti),n=e[Ki];return n.parse=function(t){return t},n[Rt]=function(t){var e=this._extent;return t>=e[0]&&t<=e[1]},n.normalize=function(t){var e=this._extent;return e[1]===e[0]?.5:(t-e[0])/(e[1]-e[0])},n.scale=function(t){var e=this._extent;return t*(e[1]-e[0])+e[0]},n.unionExtent=function(t){var e=this._extent;t[0]e[1]&&(e[1]=t[1])},n[m]=function(){return this._extent.slice()},n.setExtent=function(t,e){var i=this._extent;isNaN(t)||(i[0]=t),isNaN(e)||(i[1]=e)},n.getTicksLabels=function(){for(var t=[],e=this.getTicks(),i=0;ie[1]&&(e[1]=t[1]),o[Ki].setExtent.call(this,e[0],e[1])},getInterval:function(){return this._interval||this.niceTicks(),this._interval},setInterval:function(t){this._interval=t,this._niceExtent=this._extent.slice()},getTicks:function(){this._interval||this.niceTicks();var t=this._interval,i=this._extent,n=[],r=1e4;if(t){var a=this._niceExtent;i[0]r)return[];i[1]>a[1]&&n.push(i[1])}return n},getTicksLabels:function(){for(var t=[],e=this.getTicks(),i=0;i=n)){var o=Math.pow(10,Math.floor(Math.log(n/t)/Math.LN10)),s=t/n*o;.15>=s?o*=10:.3>=s?o*=5:.45>=s?o*=3:.75>=s&&(o*=2);var l=[e.round(a(i[0]/o)*o),e.round(r(i[1]/o)*o)];this._interval=o,this._niceExtent=l}},niceExtent:function(t,i,n){var o=this._extent;if(o[0]===o[1])if(0!==o[0]){var s=o[0]/2;o[0]-=s,o[1]+=s}else o[1]=1;o[1]===-(1/0)&&o[0]===1/0&&(o[0]=0,o[1]=1),this.niceTicks(t,i,n);var l=this._interval;i||(o[0]=e.round(r(o[0]/l)*l)),n||(o[1]=e.round(a(o[1]/l)*l))}});return o[hi]=function(){return new o},o}),e("echarts/scale/Time",[Ji,Qi,"../util/number","../util/format","./Interval"],function(t){var e=t(Qi),i=t("../util/number"),n=t("../util/format"),r=t("./Interval"),a=r[Ki],o=Math.ceil,s=Math.floor,l=864e5,u=function(t,e,i,n){for(;n>i;){var r=i+n>>>1;t[r][2]=p?f*=10:.3>=p?f*=5:.75>=p&&(f*=2),c*=f}var m=[o(e[0]/c)*c,s(e[1]/c)*c];this._stepLvl=l,this._interval=c,this._niceExtent=m},parse:function(t){return+i.parseDate(t)}});e.each([Rt,"normalize"],function(t){c[Ki][t]=function(e){return a[t].call(this,this.parse(e))}});var h=[["hh:mm:ss",1,1e3],["hh:mm:ss",5,5e3],["hh:mm:ss",10,1e4],["hh:mm:ss",15,15e3],["hh:mm:ss",30,3e4],["hh:mm\nMM-dd",1,6e4],["hh:mm\nMM-dd",5,3e5],["hh:mm\nMM-dd",10,6e5],["hh:mm\nMM-dd",15,9e5],["hh:mm\nMM-dd",30,18e5],["hh:mm\nMM-dd",1,36e5],["hh:mm\nMM-dd",2,72e5],["hh:mm\nMM-dd",6,216e5],["hh:mm\nMM-dd",12,432e5],["MM-dd\nyyyy",1,l],["week",7,7*l],["month",1,31*l],["quarter",3,380*l/4],["half-year",6,380*l/2],["year",1,380*l]];return c[hi]=function(){return new c},c}),e("echarts/scale/Log",[Ji,Qi,"./Scale","../util/number","./Interval"],function(t){var e=t(Qi),i=t("./Scale"),n=t("../util/number"),r=t("./Interval"),a=i[Ki],o=r[Ki],l=Math.floor,u=Math.ceil,c=Math.pow,h=10,d=Math.log,f=i[Ci]({type:"log",getTicks:function(){return e.map(o.getTicks.call(this),function(t){return n.round(c(h,t))})},getLabel:o[s],scale:function(t){return t=a.scale.call(this,t),c(h,t)},setExtent:function(t,e){t=d(t)/d(h),e=d(e)/d(h),o.setExtent.call(this,t,e)},getExtent:function(){var t=a[m].call(this);return t[0]=c(h,t[0]),t[1]=c(h,t[1]),t},unionExtent:function(t){t[0]=d(t[0])/d(h),t[1]=d(t[1])/d(h),a.unionExtent.call(this,t)},niceTicks:function(t){t=t||10;var e=this._extent,i=e[1]-e[0];if(!(i===1/0||0>=i)){var r=c(10,l(d(i/t)/Math.LN10)),a=t/i*r;.5>=a&&(r*=10);var o=[n.round(u(e[0]/r)*r),n.round(l(e[1]/r)*r)];this._interval=r,this._niceExtent=o}},niceExtent:o.niceExtent});return e.each([Rt,"normalize"],function(t){f[Ki][t]=function(e){return e=d(e)/d(h),a[t].call(this,e)}}),f[hi]=function(){return new f},f}),e("echarts/coord/axisHelper",[Ji,"../scale/Ordinal","../scale/Interval","../scale/Time","../scale/Log","../scale/Scale","../util/number",Qi,ci],function(t){var e=t("../scale/Ordinal"),i=t("../scale/Interval");t("../scale/Time"),t("../scale/Log");var n=t("../scale/Scale"),r=t("../util/number"),a=t(Qi),o=t(ci),l={};return l.niceScaleExtent=function(t,e){var i=t.scale,n=i[m](),o=n[1]-n[0];if(i.type===We)return void(isFinite(o)||i.setExtent(0,0));var s=e.get("min"),l=e.get("max"),u=!e.get("scale"),c=e.get("boundaryGap");a[Di](c)||(c=[c||0,c||0]),c[0]=r[Zi](c[0],1),c[1]=r[Zi](c[1],1);var h=!0,d=!0;null==s&&(s=n[0]-c[0]*o,h=!1),null==l&&(l=n[1]+c[1]*o,d=!1),"dataMin"===s&&(s=n[0]),"dataMax"===l&&(l=n[1]),u&&(s>0&&l>0&&!h&&(s=0),0>s&&0>l&&!d&&(l=0)),i.setExtent(s,l),i.niceExtent(e.get("splitNumber"),h,d);var f=e.get("interval");null!=f&&i.setInterval&&i.setInterval(f)},l.createScaleByModel=function(t,r){if(r=r||t.get("type"))switch(r){case A:return new e(t.getCategories(),[1/0,-(1/0)]);case"value":return new i;default:return(n[Mi](r)||i)[hi](t)}},l.ifAxisCrossZero=function(t){var e=t.scale[m](),i=e[0],n=e[1];return!(i>0&&n>0||0>i&&0>n)},l.getAxisLabelInterval=function(t,e,i,n){var r,a=0,s=0,l=1;e[Xi]>40&&(l=Math.round(e[Xi]/40));for(var u=0;u1?l:a*l},l.getFormattedLabels=function(t,e){var i=t.scale,n=i.getTicksLabels(),r=i.getTicks();return typeof e===Wi?(e=function(t){return function(e){return t[Ni]("{value}",e)}}(e),a.map(n,e)):typeof e===Vi?a.map(r,function(n,r){return e(t.type===A?i[s](n):n,r)},this):n},l}),e("echarts/coord/cartesian/Cartesian",[Ji,Qi],function(t){function e(t){return this._axes[t]}var i=t(Qi),n=function(t){this._axes={},this._dimList=[],this.name=t||""};return n[Ki]={constructor:n,type:"cartesian",getAxis:function(t){return this._axes[t]},getAxes:function(){return i.map(this._dimList,e,this)},getAxesByScale:function(t){return t=t[Pi](),i[$i](this.getAxes(),function(e){return e.scale.type===t})},addAxis:function(t){var e=t.dim;this._axes[e]=t,this._dimList.push(e)},dataToCoord:function(t){return this._dataCoordConvert(t,o)},coordToData:function(t){return this._dataCoordConvert(t,"coordToData")},_dataCoordConvert:function(t,e){for(var i=this._dimList,n=t instanceof Array?[]:{},r=0;r=i&&n>=t},containData:function(t){return this[Rt](this[o](t))},getExtent:function(){var t=this._extent.slice();return t},getPixelPrecision:function(t){return i[zi](t||this.scale[m](),this._extent)},setExtent:function(t,e){var i=this._extent;i[0]=t,i[1]=e},dataToCoord:function(t,i){var r=this._extent,o=this.scale;return t=o.normalize(t),this.onBand&&o.type===We&&(r=r.slice(),e(r,o.count())),n(t,a,r,i)},coordToData:function(t,i){var r=this._extent,o=this.scale;this.onBand&&o.type===We&&(r=r.slice(),e(r,o.count()));var s=n(t,r,a,i);return this.scale.scale(s)},getTicksCoords:function(){if(this.onBand){for(var t=this.getBands(),e=[],i=0;io;o++)e.push([a*o/i+n,a*(o+1)/i+n]);return e},getBandWidth:function(){var t=this._extent,e=this.scale[m](),i=e[1]-e[0]+(this.onBand?1:0),n=Math.abs(t[1]-t[0]);return Math.abs(n)/i}},s}),e("echarts/coord/cartesian/axisLabelInterval",[Ji,Qi,"../axisHelper"],function(t){var e=t(Qi),i=t("../axisHelper");return function(t){var n=t.model,r=n[ri]("axisLabel"),a=r.get("interval");return t.type!==A||"auto"!==a?"auto"===a?0:a:i.getAxisLabelInterval(e.map(t.scale.getTicks(),t[o],t),n.getFormattedLabels(),r[ri](ni)[ei](),t[d]())}}),e("echarts/coord/cartesian/Axis2D",[Ji,Qi,"../Axis","./axisLabelInterval"],function(t){var e=t(Qi),i=t("../Axis"),n=t("./axisLabelInterval"),r=function(t,e,n,r,a){i.call(this,t,e,n),this.type=r||"value",this[Oe]=a||Oi};return r[Ki]={constructor:r,index:0,onZero:!1,model:null,isHorizontal:function(){var t=this[Oe];return"top"===t||t===Oi},getGlobalExtent:function(){var t=this[m]();return t[0]=this.toGlobalCoord(t[0]),t[1]=this.toGlobalCoord(t[1]),t},getLabelInterval:function(){var t=this._labelInterval;return t||(t=this._labelInterval=n(this)),t},isLabelIgnored:function(t){if(this.type===A){var e=this.getLabelInterval();return typeof e===Vi&&!e(t,this.scale[s](t))||t%(e+1)}},toLocalCoord:null,toGlobalCoord:null},e[ki](r,i),r}),e("echarts/coord/axisDefault",[Ji,Qi],function(t){var e=t(Qi),i={show:!0,zlevel:0,z:0,inverse:!1,name:"",nameLocation:"end",nameTextStyle:{},nameGap:15,axisLine:{show:!0,onZero:!0,lineStyle:{color:"#333",width:1,type:"solid"}},axisTick:{show:!0,inside:!1,length:5,lineStyle:{color:"#333",width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{color:"#333",fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}}},n=e.merge({boundaryGap:!0,axisTick:{interval:"auto"},axisLabel:{interval:"auto"}},i),r=e[oi]({boundaryGap:[0,0],splitNumber:5},i),a=e[oi]({scale:!0,min:"dataMin",max:"dataMax"},r),o=e[oi]({},r);return o.scale=!0,{categoryAxis:n,valueAxis:r,timeAxis:a,logAxis:o}}),e("echarts/coord/axisModelCreator",[Ji,"./axisDefault",Qi,"../model/Component","../util/layout"],function(t){var e=t("./axisDefault"),i=t(Qi),n=t("../model/Component"),r=t("../util/layout"),a=["value",A,"time","log"];return function(t,o,s,l){i.each(a,function(n){o[Ci]({type:t+"Axis."+n,mergeDefaultAndTheme:function(e,a){var o=this.layoutMode,l=o?r.getLayoutParams(e):{},u=a.getTheme();i.merge(e,u.get(n+"Axis")),i.merge(e,this.getDefaultOption()),e.type=s(t,e),o&&r.mergeLayoutParam(e,l,o)},defaultOption:i.mergeAll([{},e[n+"Axis"],l],!0)})}),n.registerSubTypeDefaulter(t+"Axis",i.curry(s,t))}}),e("echarts/coord/axisModelCommonMixin",[Ji,Qi,"./axisHelper"],function(t){function e(t){return r[Be](t)&&null!=t.value?t.value:t}function i(){return this.get("type")===A&&r.map(this.get("data"),e)}function n(){return a.getFormattedLabels(this.axis,this.get("axisLabel.formatter"))}var r=t(Qi),a=t("./axisHelper");return{getFormattedLabels:n,getCategories:i}}),e("echarts/coord/cartesian/AxisModel",[Ji,"../../model/Component",Qi,"../axisModelCreator","../axisModelCommonMixin"],function(t){function e(t,e){return e.type||(e.data?A:"value")}var i=t("../../model/Component"),n=t(Qi),r=t("../axisModelCreator"),a=i[Ci]({type:"cartesian2dAxis",axis:null,setNeedsCrossZero:function(t){this[Je].scale=!t},setMin:function(t){this[Je].min=t},setMax:function(t){this[Je].max=t}});n.merge(a[Ki],t("../axisModelCommonMixin"));var o={gridIndex:0};return r("x",a,e,o),r("y",a,e,o),a}),e("echarts/coord/cartesian/GridModel",[Ji,"./AxisModel","../../model/Component"],function(t){t("./AxisModel");var e=t("../../model/Component");return e[Ci]({type:"grid",dependencies:["xAxis","yAxis"],layoutMode:"box",coordinateSystem:null,defaultOption:{show:!1,zlevel:0,z:0,left:"10%",top:60,right:"10%",bottom:60,containLabel:!1,backgroundColor:"rgba(0,0,0,0)",borderWidth:1,borderColor:"#ccc"}})}),e("echarts/coord/cartesian/Grid",[Ji,"exports","module","../../util/layout","../../coord/axisHelper",Qi,"./Cartesian2D","./Axis2D","./GridModel","../../CoordinateSystem"],function(t,e){function i(t,e,i){return i[ge]("grid",t.get("gridIndex"))===e}function n(t){var e,i=t.model,n=i.getFormattedLabels(),r=1,a=n[Xi];a>40&&(r=Math.ceil(a/40));for(var o=0;a>o;o+=r)if(!t.isLabelIgnored(o)){var s=i.getTextRect(n[o]);e?e.union(s):e=s}return e}function o(t,e,i){this._coordsMap={},this._coordsList=[],this._axesMap={},this._axesList=[],this._initCartesian(t,e,i),this._model=t}function s(t,e){var i=t[m](),n=i[0]+i[1];t.toGlobalCoord="x"===t.dim?function(t){return t+e}:function(t){return n-t+e},t.toLocalCoord="x"===t.dim?function(t){return t-e}:function(t){return n-t+e}}var l=t("../../util/layout"),c=t("../../coord/axisHelper"),p=t(Qi),v=t("./Cartesian2D"),g=t("./Axis2D"),y=p.each,x=c.ifAxisCrossZero,_=c.niceScaleExtent;t("./GridModel");var b=o[Ki];return b.type="grid",b[a]=function(){return this._rect},b[xe]=function(t,e){function i(t){var e=n[t];for(var i in e){var r=e[i];if(r&&(r.type===A||!x(r)))return!0}return!1}var n=this._axesMap;this._updateScale(t,this._model),y(n.x,function(t){_(t,t.model)}),y(n.y,function(t){_(t,t.model)}),y(n.x,function(t){i("y")&&(t.onZero=!1)}),y(n.y,function(t){i("x")&&(t.onZero=!1)}),this[at](this._model,e)},b[at]=function(t,e){function i(){y(a,function(t){var e=t[d](),i=e?[0,r.width]:[0,r[di]],n=t[h]?1:0;t.setExtent(i[n],i[1-n]),s(t,e?r.x:r.y)})}var r=l[Le](t.getBoxLayoutParams(),{width:e[we](),height:e[be]()});this._rect=r;var a=this._axesList;i(),t.get("containLabel")&&(y(a,function(t){if(!t.model.get("axisLabel.inside")){var e=n(t);if(e){var i=t[d]()?di:"width",a=t.model.get("axisLabel.margin");r[i]-=e[i]+a,"top"===t[Oe]?r.y+=e[di]+a:"left"===t[Oe]&&(r.x+=e.width+a)}}}),i())},b[f]=function(t,e){var i=this._axesMap[t];if(null!=i){if(null==e)for(var n in i)return i[n];return i[e]}},b.getCartesian=function(t,e){var i="x"+t+"y"+e;return this._coordsMap[i]},b._initCartesian=function(t,e,n){function r(n){return function(r,l){if(i(r,t,e)){var u=r.get(Oe);"x"===n?("top"!==u&&u!==Oi&&(u=Oi),a[u]&&(u="top"===u?Oi:"top")):("left"!==u&&"right"!==u&&(u="left"),a[u]&&(u="left"===u?"right":"left")),a[u]=!0;var d=new g(n,c.createScaleByModel(r),[0,0],r.get("type"),u),f=d.type===A;d.onBand=f&&r.get("boundaryGap"),d[h]=r.get(h),d.onZero=r.get("axisLine.onZero"),r.axis=d,d.model=r,d.index=l,this._axesList.push(d),o[n][l]=d,s[n]++}}}var a={left:!1,right:!1,top:!1,bottom:!1},o={x:{},y:{}},s={x:0,y:0};return e[q]("xAxis",r("x"),this),e[q]("yAxis",r("y"),this),s.x&&s.y?(this._axesMap=o,void y(o.x,function(t,e){y(o.y,function(i,n){var r="x"+e+"y"+n,a=new v(r);a.grid=this,this._coordsMap[r]=a,this._coordsList.push(a),a.addAxis(t),a.addAxis(i)},this)},this)):(this._axesMap={},void(this._axesList=[]))},b._updateScale=function(t,e){function n(t,e,i){y(i[r](e.dim),function(i){e.scale.unionExtent(t[B](i,e.scale.type!==We))})}p.each(this._axesList,function(t){t.scale.setExtent(1/0,-(1/0))}),t[X](function(r){if(r.get(me)===u){var a=r.get("xAxisIndex"),o=r.get("yAxisIndex"),s=t[ge]("xAxis",a),l=t[ge]("yAxis",o);if(!i(s,e,t)||!i(l,e,t))return;var c=this.getCartesian(a,o),h=r[He](),d=c[f]("x"),p=c[f]("y");"list"===h.type&&(n(h,d,r),n(h,p,r))}},this)},o[hi]=function(t,e){var i=[];return t[q]("grid",function(n,r){var a=new o(n,t,e);a.name="grid_"+r,a[at](n,e),n[me]=a,i.push(a)}),t[X](function(e){if(e.get(me)===u){var n=e.get("xAxisIndex"),r=t[ge]("xAxis",n),a=i[r.get("gridIndex")];e[me]=a.getCartesian(n,e.get("yAxisIndex"))}}),i},o[Z]=v[Ki][Z],t("../../CoordinateSystem")[ye](u,o),o}),e("echarts/chart/bar/BarSeries",[Ji,"../../model/Series","../helper/createListFromArray"],function(t){var e=t("../../model/Series"),i=t("../helper/createListFromArray");return e[Ci]({type:"series.bar",dependencies:["grid","polar"],getInitialData:function(t,e){return i(t.data,this,e)},getMarkerPosition:function(t){var e=this[me];if(e){var i=e[p](t),n=this[He](),r=n.getLayout("offset"),a=n.getLayout("size"),o=e[pe]()[d]()?0:1;return i[o]+=r+a/2,i}return[NaN,NaN]},defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,xAxisIndex:0,yAxisIndex:0,barMinHeight:0,itemStyle:{normal:{barBorderColor:"#fff",barBorderWidth:0},emphasis:{barBorderColor:"#fff",barBorderWidth:0}}}})}),e("echarts/chart/bar/barItemStyle",[Ji,"../../model/mixin/makeStyleMapper"],function(t){return{getBarItemStyle:t("../../model/mixin/makeStyleMapper")([["fill","color"],[_i,"barBorderColor"],[bi,"barBorderWidth"],[xi],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]])}}),e("echarts/chart/bar/BarView",[Ji,Qi,T,"../../model/Model","./barItemStyle",n],function(t){function e(t,e){var i=t.width>0?1:-1,n=t[di]>0?1:-1;e=Math.min(e,Math.abs(t.width),Math.abs(t[di])),t.x+=i*e/2,t.y+=n*e/2,t.width-=i*e,t[di]-=n*e}var i=t(Qi),r=t(T);return i[Ci](t("../../model/Model")[Ki],t("./barItemStyle")),t(n).extendChartView({type:"bar",render:function(t,e,i){var n=t.get(me);return n===u&&this._renderOnCartesian(t,e,i),this.group},_renderOnCartesian:function(t,n,a){function o(n,a){var o=l[I](n),s=l[Ne](n).get(m)||0;e(o,s);var u=new r.Rect({shape:i[Ci]({},o)});if(p){var c=u.shape,h=f?di:"width",d={};c[h]=0,d[h]=o[h],r[a?vt:mt](u,{shape:d},t)}return u}var s=this.group,l=t[He](),u=this._data,c=t[me],h=c[pe](),f=h[d](),p=t.get(re),m=[U,Ue,"barBorderWidth"];l.diff(u).add(function(t){if(l.hasValue(t)){var e=o(t);l[L](t,e),s.add(e)}})[xe](function(i,n){var a=u[Gt](n);if(!l.hasValue(i))return void s[Qt](a);a||(a=o(i,!0));var c=l[I](i),h=l[Ne](i).get(m)||0;e(c,h),r[vt](a,{shape:c},t),l[L](i,a),s.add(a)})[Qt](function(e){var i=u[Gt](e);i&&(i.style.text="",r[vt](i,{shape:{width:0}},t,function(){s[Qt](i)}))})[g](),this._updateStyle(t,l,f),this._data=l},_updateStyle:function(t,e,n){function a(t,e,i,n,a){r.setText(t,e,i),t.text=n,"outside"===t[Et]&&(t[Et]=a)}e[Nt](function(o,s){var l=e[Ne](s),u=e[P](s,"color"),c=e[I](s),h=l[ri]("itemStyle.normal"),d=l[ri]("itemStyle.emphasis")[x]();o[Dt]("r",h.get("barBorderRadius")||0),o[wt](i[oi]({fill:u},h.getBarItemStyle()));var f=n?c[di]>0?Oi:"top":c.width>0?"left":"right",p=l[ri]("label.normal"),m=l[ri]("label.emphasis"),v=o.style;p.get("show")?a(v,p,u,i[je](t[y](s,Ue),t[Fe](s)),f):v.text="",m.get("show")?a(d,m,u,i[je](t[y](s,Xe),t[Fe](s)),f):d.text="",r[_t](o,d)})},remove:function(t,e){var i=this.group;t.get(re)?this._data&&this._data[Nt](function(e){e.style.text="",r[vt](e,{shape:{width:0}},t,function(){i[Qt](e)})}):i[qt]()}})}),e("echarts/layout/barGrid",[Ji,Qi,"../util/number"],function(t){function e(t){return t.get("stack")||"__ec_stack_"+t[qe]}function i(t,i){var n={};r.each(t,function(t,i){var r=t[me],a=r[pe](),o=n[a.index]||{remainedWidth:a.getBandWidth(),autoWidthCount:0,categoryGap:"20%",gap:"30%",axis:a,stacks:{}},s=o.stacks;n[a.index]=o;var l=e(t);s[l]||o.autoWidthCount++,s[l]=s[l]||{width:0,maxWidth:0};var u=t.get("barWidth"),c=t.get("barMaxWidth"),h=t.get("barGap"),d=t.get("barCategoryGap");u&&!s[l].width&&(u=Math.min(o.remainedWidth,u),s[l].width=u,o.remainedWidth-=u),c&&(s[l].maxWidth=c),null!=h&&(o.gap=h),null!=d&&(o.categoryGap=d)});var a={};return r.each(n,function(t,e){a[e]={};var i=t.stacks,n=t.axis,o=n.getBandWidth(),l=s(t.categoryGap,o),u=s(t.gap,1),c=t.remainedWidth,h=t.autoWidthCount,d=(c-l)/(h+(h-1)*u);d=Math.max(d,0),r.each(i,function(t,e){var i=t.maxWidth;!t.width&&i&&d>i&&(i=Math.min(i,c),c-=i,t.width=i,h--)}),d=(c-l)/(h+(h-1)*u),d=Math.max(d,0);var f,p=0;r.each(i,function(t,e){t.width||(t.width=d),f=t,p+=t.width*(1+u)}),f&&(p-=f.width*u);var m=-p/2;r.each(i,function(t,i){a[e][i]=a[e][i]||{offset:m,width:t.width},m+=t.width*(1+u)})}),a}function n(t,n,a){var s=i(r[$i](n.getSeriesByType(t),function(t){return!n.isSeriesFiltered(t)&&t[me]&&t[me].type===u})),l={};n[Y](t,function(t){var i=t[He](),n=t[me],r=n[pe](),a=e(t),u=s[r.index][a],c=u.offset,h=u.width,f=n[v](r),p=t.get("barMinHeight")||0,m=r.onZero?f.toGlobalCoord(f[o](0)):f.getGlobalExtent()[0],g=n.dataToPoints(i,!0);l[a]=l[a]||[],i.setLayout({offset:c,size:h}),i.each(f.dim,function(t,e){if(!isNaN(t)){l[a][e]||(l[a][e]={p:m,n:m});var n,r,o,s,u=t>=0?"p":"n",v=g[e],y=l[a][e][u];f[d]()?(n=y,r=v[1]+c,o=v[0]-y,s=h,Math.abs(o)o?-1:1)*p),l[a][e][u]+=o):(n=v[0]+c,r=y,o=h,s=v[1]-y,Math.abs(s)=s?-1:1)*p),l[a][e][u]+=s),i[z](e,{x:n,y:r,width:o,height:s})}},!0)},this)}var r=t(Qi),a=t("../util/number"),s=a[Zi];return n}),e("echarts/chart/bar",[Ji,Qi,"../coord/cartesian/Grid","./bar/BarSeries","./bar/BarView","../layout/barGrid",l],function(t){var e=t(Qi);t("../coord/cartesian/Grid"),t("./bar/BarSeries"),t("./bar/BarView");var i=t("../layout/barGrid"),n=t(l);n[G](e.curry(i,"bar")),n[V]("chart",function(t){t[Y]("bar",function(t){var e=t[He]();e[Q]("legendSymbol","roundRect")})})}),e("echarts/chart/helper/dataSelectableMixin",[Ji,Qi],function(t){var e=t(Qi);return{updateSelectedMap:function(){var t=this[Je];this._dataOptMap=e.reduce(t.data,function(t,e){return t[e.name]=e,t},{})},select:function(t){var i=this._dataOptMap,n=i[t],r=this.get("selectedMode");"single"===r&&e.each(i,function(t){t.selected=!1}),n&&(n.selected=!0)},unSelect:function(t){var e=this._dataOptMap[t];e&&(e.selected=!1)},toggleSelected:function(t){var e=this._dataOptMap[t];return null!=e?(this[e.selected?"unSelect":"select"](t),e.selected):void 0},isSelected:function(t){var e=this._dataOptMap[t];return e&&e.selected}}}),e("echarts/chart/pie/PieSeries",[Ji,"../../data/List",Qi,D,"../../data/helper/completeDimensions","../helper/dataSelectableMixin",n],function(t){var e=t("../../data/List"),i=t(Qi),r=t(D),a=t("../../data/helper/completeDimensions"),o=t("../helper/dataSelectableMixin"),s=t(n).extendSeriesModel({type:"series.pie",init:function(t){s[Ti](this,"init",arguments),this.legendDataProvider=function(){return this._dataBeforeProcessed},this.updateSelectedMap(),this._defaultLabelLine(t)},mergeOption:function(t){s.superCall(this,Ae,t),this.updateSelectedMap()},getInitialData:function(t,i){var n=a(["value"],t.data),r=new e(n,this);return r.initData(t.data),r},getDataParams:function(t){var e=this._data,i=s.superCall(this,Ee,t),n=e.getSum("value");return i.percent=n?+(e.get("value",t)/n*100)[Ii](2):0,i.$vars.push("percent"),i},_defaultLabelLine:function(t){r[Ye](t.labelLine,["show"]);var e=t.labelLine[Ue],i=t.labelLine[Xe];e.show=e.show&&t.label[Ue].show,i.show=i.show&&t.label[Xe].show},defaultOption:{zlevel:0,z:2,legendHoverLink:!0,hoverAnimation:!0,center:["50%","50%"],radius:[0,"75%"],clockwise:!0,startAngle:90,minAngle:0,selectedOffset:10,avoidLabelOverlap:!0,label:{normal:{rotate:!1,show:!0,position:"outer"},emphasis:{}},labelLine:{normal:{show:!0,length:20,length2:5,smooth:!1,lineStyle:{width:1,type:"solid"}}},itemStyle:{normal:{borderColor:"rgba(0,0,0,0)",borderWidth:1},emphasis:{borderColor:"rgba(0,0,0,0)",borderWidth:1}},animationEasing:"cubicOut",data:[]}});return i.mixin(s,o),s}),e("echarts/chart/pie/PieView",[Ji,T,Qi,"../../view/Chart"],function(t){function e(t,e,n,r){var a=e[He](),o=this[Ft],s=a[Ve](o),l=e.get("selectedOffset");r[_e]({type:"pieToggleSelect",from:t,name:s,seriesId:e.id}),a.each(function(t){i(a[Gt](t),a[I](t),e.isSelected(a[Ve](t)),l,n)})}function i(t,e,i,n,r){var a=(e.startAngle+e.endAngle)/2,o=Math.cos(a),s=Math.sin(a),l=i?n:0,u=[o*l,s*l];r?t[ie]().when(200,{position:u}).start("bounceOut"):t.attr(Oe,u)}function n(t,e){function i(){o[te]=o.hoverIgnore,s[te]=s.hoverIgnore}function n(){o[te]=o.normalIgnore,s[te]=s.normalIgnore}a.Group.call(this);var r=new a[Tt]({z2:2}),o=new a[kt],s=new a.Text;this.add(r),this.add(o),this.add(s),this[S](t,e,!0),this.on(Xe,i).on(Ue,n).on(xt,i).on(yt,n)}function r(t,e,i,n){var r=n[ri](ni),a=n.get(Oe),s=a===si||"inner"===a;return{fill:r[gt]()||(s?"#fff":t[P](e,"color")),textFont:r[ei](),text:o[je](t[H][y](e,i),t[Ve](e))}}var a=t(T),o=t(Qi),s=n[Ki];s[S]=function(t,e,n){function r(){l[ne](!0),l.animateTo({shape:{r:h.r+10}},300,"elasticOut")}function s(){l[ne](!0),l.animateTo({shape:{r:h.r}},300,"elasticOut")}var l=this[Ie](0),u=t[H],c=t[Ne](e),h=t[I](e),d=o[Ci]({},h);d.label=null,n?(l[Dt](d),l.shape.endAngle=h.startAngle,a[vt](l,{shape:{endAngle:h.endAngle}},u)):a[vt](l,{shape:d},u);var f=c[ri](U),p=t[P](e,"color");l[wt](o[oi]({fill:p},f[ri](Ue)[x]())),l[bt]=f[ri](Xe)[x](),i(this,t[I](e),c.get("selected"),u.get("selectedOffset"),u.get(re)),l.off(xt).off(yt).off(Xe).off(Ue),c.get("hoverAnimation")&&l.on(xt,r).on(yt,s).on(Xe,r).on(Ue,s),this._updateLabel(t,e),a[_t](this)},s._updateLabel=function(t,e){var i=this[Ie](1),n=this[Ie](2),o=t[H],s=t[Ne](e),l=t[I](e),u=l.label,h=t[P](e,"color");a[vt](i,{shape:{points:u.linePoints||[[u.x,u.y],[u.x,u.y],[u.x,u.y]]}},o),a[vt](n,{style:{x:u.x,y:u.y}},o),n.attr({style:{textAlign:u[Zt],textBaseline:u[Bt],textFont:u.font},rotation:u[de],origin:[u.x,u.y],z2:10});var d=s[ri]("label.normal"),f=s[ri]("label.emphasis"),p=s[ri]("labelLine.normal"),m=s[ri]("labelLine.emphasis");n[wt](r(t,e,Ue,d)),n[te]=n.normalIgnore=!d.get("show"),n.hoverIgnore=!f.get("show"),i[te]=i.normalIgnore=!p.get("show"),i.hoverIgnore=!m.get("show"),i[wt]({stroke:h}),i[wt](p[ri]("lineStyle")[c]()),n[bt]=r(t,e,Xe,f),i[bt]=m[ri]("lineStyle")[c]();var v=p.get("smooth");v&&v===!0&&(v=.4),i[Dt]({smooth:v})},o[ki](n,a.Group);var l=t("../../view/Chart")[Ci]({type:"pie",init:function(){var t=new a.Group;this._sectorGroup=t},render:function(t,i,r,a){if(!a||a.from!==this.uid){var s=t[He](),l=this._data,u=this.group,c=i.get(re),h=!l,d=o.curry(e,this.uid,t,c,r),f=t.get("selectedMode");if(s.diff(l).add(function(t){var e=new n(s,t);h&&e[Re](function(t){t[ne](!0)}),f&&e.on("click",d),s[L](t,e),u.add(e)})[xe](function(t,e){var i=l[Gt](e);i[S](s,t),i.off("click"),f&&i.on("click",d),u.add(i),s[L](t,i)})[Qt](function(t){var e=l[Gt](t);u[Qt](e)})[g](),c&&h&&s.count()>0){var p=s[I](0),m=Math.max(r[we](),r[be]())/2,v=o.bind(u.removeClipPath,u);u.setClipPath(this._createClipPath(p.cx,p.cy,m,p.startAngle,p.clockwise,v,t))}this._data=s}},_createClipPath:function(t,e,i,n,r,o,s){var l=new a[Tt]({shape:{cx:t,cy:e,r0:0,r:i,startAngle:n,endAngle:n,clockwise:r}});return a[mt](l,{shape:{endAngle:n+(r?1:-1)*Math.PI*2}},s,o),l}});return l}),e("echarts/action/createDataSelectAction",[Ji,l,Qi],function(t){var e=t(l),i=t(Qi);return function(t,n){i.each(n,function(i){i[xe]="updateView",e[F](i,function(e,n){var r={};return n[q]({mainType:"series", -subType:t,query:e},function(t){t[i.method]&&t[i.method](e.name);var n=t[He]();n.each(function(e){var i=n[Ve](e);r[i]=t.isSelected(i)||!1})}),{name:e.name,selected:r}})})}}),e("echarts/visual/dataColor",[Ji],function(t){return function(t,e){var i=e.get("color"),n=0;e.eachRawSeriesByType(t,function(t){var r=t.get("color",!0),a=t.getRawData();if(!e.isSeriesFiltered(t)){var o=t[He]();o.each(function(t){var e=o[Ne](t),s=o[Ge](t),l=o[P](t,"color",!0);if(l)a[$](s,"color",l);else{var u=r?r[s%r[Xi]]:i[(s+n)%i[Xi]],c=e.get("itemStyle.normal.color")||u;a[$](s,"color",c),o[$](t,"color",c)}})}n+=a.count()})}}),e("echarts/chart/pie/labelLayout",[Ji,ci],function(t){function e(t,e,i,n,r,a,o){function s(e,i,n,r){for(var a=e;i>a;a++)if(t[a].y+=n,a>e&&i>a+1&&t[a+1].y>t[a].y+t[a][di])return void l(a,n/2);l(i-1,n/2)}function l(e,i){for(var n=e;n>=0&&(t[n].y-=i,!(n>0&&t[n].y>t[n-1].y+t[n-1][di]));n--);}t.sort(function(t,e){return t.y-e.y});for(var u,c=0,h=t[Xi],d=[],f=[],p=0;h>p;p++)u=t[p].y-c,0>u&&s(p,h,-u,r),c=t[p].y+t[p][di];0>o-c&&l(h-1,c-o);for(var p=0;h>p;p++)t[p].y>=i?f.push(t[p]):d.push(t[p])}function i(t,i,n,r,a,o){for(var s=[],l=[],u=0;uw?-1:1)*_,L=A;r=D+(0>w?-5:5),a=L,h=[[k,T],[C,A],[D,L]]}d=S?Bi:w>0?"left":"right"}var P=Ri,z=m[ri](ni)[ei](),O=m.get(le)?0>w?-b+Math.PI:-b:0,R=t[y](i,Ue)||l[Ve](i),B=n[ii](R,z,d,P);c=!!O,f.label={x:r,y:a,height:B[di],length:x,length2:_,linePoints:h,textAlign:d,textBaseline:P,font:z,rotation:O},u.push(f.label)}),!c&&t.get("avoidLabelOverlap")&&i(u,o,s,e,r,a)}}),e("echarts/chart/pie/pieLayout",[Ji,k,"./labelLayout",Qi],function(t){var e=t(k),i=e[Zi],n=t("./labelLayout"),r=t(Qi),a=2*Math.PI,o=Math.PI/180;return function(t,s,l){s[Y](t,function(t){var s=t.get(Bi),u=t.get(Ke);r[Di](u)||(u=[0,u]),r[Di](s)||(s=[s,s]);var c=l[we](),h=l[be](),d=Math.min(c,h),f=i(s[0],c),p=i(s[1],h),m=i(u[0],d/2),v=i(u[1],d/2),g=t[He](),y=-t.get("startAngle")*o,x=t.get("minAngle")*o,_=g.getSum("value"),b=Math.PI/(_||g.count())*2,w=t.get("clockwise"),M=t.get("roseType"),S=g[B]("value");S[0]=0;var k=a,T=0,C=y,A=w?1:-1;if(g.each("value",function(t,i){var n;n="area"!==M?0===_?b:t*b:a/(g.count()||1),x>n?(n=x,k-=x):T+=t;var r=C+A*n;g[z](i,{angle:n,startAngle:C,endAngle:r,clockwise:w,cx:f,cy:p,r0:m,r:M?e[Ei](t,S,[m,v]):v}),C=r},!0),a>k)if(.001>=k){var D=a/g.count();g.each(function(t){var e=g[I](t);e.startAngle=y+A*t*D,e.endAngle=y+A*(t+1)*D})}else b=k/T,C=y,g.each("value",function(t,e){var i=g[I](e),n=i.angle===x?x:t*b;i.startAngle=C,i.endAngle=C+A*n,C+=n});n(t,v,c,h)})}}),e("echarts/processor/dataFilter",[],function(){return function(t,e){var i=e[Se]({mainType:"legend"});i&&i[Xi]&&e[Y](t,function(t){var e=t[He]();e.filterSelf(function(t){for(var n=e[Ve](t),r=0;rt.get("largeThreshold")?r:a;this._symbolDraw=s,s[S](n),o.add(s.group),o[Qt](s===r?a.group:r.group)},updateLayout:function(t){this._symbolDraw[jt](t)},remove:function(t,e){this._symbolDraw&&this._symbolDraw[Qt](e,!0)}})}),e("echarts/chart/scatter",[Ji,Qi,l,"./scatter/ScatterSeries","./scatter/ScatterView","../visual/symbol","../layout/points"],function(t){var e=t(Qi),i=t(l);t("./scatter/ScatterSeries"),t("./scatter/ScatterView"),i[V]("chart",e.curry(t("../visual/symbol"),"scatter",_,null)),i[G](e.curry(t("../layout/points"),"scatter"))}),e("echarts/component/tooltip/TooltipModel",[Ji,n],function(t){t(n)[N]({type:"tooltip",defaultOption:{zlevel:0,z:8,show:!0,showContent:!0,trigger:"item",triggerOn:"mousemove",alwaysShowContent:!1,hideDelay:100,transitionDuration:.4,enterable:!1,backgroundColor:"rgba(50,50,50,0.7)",borderColor:"#333",borderRadius:4,borderWidth:0,padding:5,axisPointer:{type:"line",axis:"auto",animation:!0,animationDurationUpdate:200,animationEasingUpdate:"exponentialOut",lineStyle:{color:"#555",width:1,type:"solid"},crossStyle:{color:"#555",width:1,type:"dashed",textStyle:{}},shadowStyle:{color:"rgba(150,150,150,0.3)"}},textStyle:{color:"#fff",fontSize:14}}})}),e("echarts/component/tooltip/TooltipContent",[Ji,Qi,ae,ft,"../../util/format"],function(t){function e(t){var e="cubic-bezier(0.23, 1, 0.32, 1)",i="left "+t+"s "+e+",top "+t+"s "+e;return s.map(f,function(t){return t+"transition:"+i}).join(";")}function n(t){var e=[],i=t.get("fontSize"),n=t[gt]();return n&&e.push("color:"+n),e.push("font:"+t[ei]()),i&&e.push("line-height:"+Math.round(3*i/2)+"px"),h(["decoration","align"],function(i){var n=t.get(i);n&&e.push("text-"+i+":"+n)}),e.join(";")}function r(t){t=t;var r=[],a=t.get("transitionDuration"),o=t.get(et),s=t[ri](ni),u=t.get(i);return a&&r.push(e(a)),o&&(r.push("background-Color:"+l.toHex(o)),r.push("filter:alpha(opacity=70)"),r.push("background-Color:"+o)),h(["width","color",Ke],function(e){var i="border-"+e,n=d(i),a=t.get(n);null!=a&&r.push(i+":"+a+("color"===e?"":"px"))}),r.push(n(s)),null!=u&&r.push("padding:"+c.normalizeCssArray(u).join("px ")+"px"),r.join(";")+";"}function a(t,e){var i=document[Ui]("div"),n=e.getZr();this.el=i,this._x=e[we]()/2,this._y=e[be]()/2,t[it](i),this._container=t,this._show=!1,this._hideTimeout;var r=this;i.onmouseenter=function(){r.enterable&&(clearTimeout(r._hideTimeout),r._show=!0),r._inContent=!0},i.onmousemove=function(e){if(!r.enterable){var i=n.handler;u.normalizeEvent(t,e),i.dispatch(dt,e)}},i.onmouseleave=function(){r.enterable&&r._show&&r.hideLater(r._hideDelay),r._inContent=!1},o(i,t)}function o(t,e){function i(t){n(t[oe])&&t.preventDefault()}function n(i){for(;i&&i!==e;){if(i===t)return!0;i=i[ut]}}u.addEventListener(e,"touchstart",i),u.addEventListener(e,"touchmove",i),u.addEventListener(e,"touchend",i)}var s=t(Qi),l=t(ae),u=t(ft),c=t("../../util/format"),h=s.each,d=c.toCamelCase,f=["","-webkit-","-moz-","-o-"],p="position:absolute;display:block;border-style:solid;white-space:nowrap;";return a[Ki]={constructor:a,enterable:!0,update:function(){var t=this._container,e=t.currentStyle||document.defaultView.getComputedStyle(t),i=t.style;"absolute"!==i[Oe]&&"absolute"!==e[Oe]&&(i[Oe]="relative")},show:function(t){clearTimeout(this._hideTimeout),this.el.style.cssText=p+r(t)+";left:"+this._x+"px;top:"+this._y+"px;",this._show=!0},setContent:function(t){var e=this.el;e[nt]=t,e.style.display=t?"block":"none"},moveTo:function(t,e){var i=this.el.style;i.left=t+"px",i.top=e+"px",this._x=t,this._y=e},hide:function(){this.el.style.display="none",this._show=!1},hideLater:function(t){!this._show||this._inContent&&this.enterable||(t?(this._hideDelay=t,this._show=!1,this._hideTimeout=setTimeout(s.bind(this.hide,this),t)):this.hide())},isShow:function(){return this._show}},a}),e("echarts/component/tooltip/TooltipView",[Ji,"./TooltipContent",T,Qi,"../../util/format",k,pt,n],function(t){function e(t,e){if(!t||!e)return!1;var i=w.round;return i(t[0])===i(e[0])&&i(t[1])===i(e[1])}function i(t,e,i,n){return{x1:t,y1:e,x2:i,y2:n}}function o(t,e,i,n){return{x:t,y:e,width:i,height:n}}function l(t,e,i,n,r,a){return{cx:t,cy:e,r0:i,r:n,startAngle:r,endAngle:a,clockwise:!0}}function h(t,e,i,n,r){var a=i.clientWidth,o=i[tt],s=20;return t+a+s>n?t-=a+s:t+=s,e+o+s>r?e-=o+s:e+=s,[t,e]}function d(t,e,i){var n=i.clientWidth,r=i[tt],a=5,o=0,s=0,l=e.width,u=e[di];switch(t){case si:o=e.x+l/2-n/2,s=e.y+u/2-r/2;break;case"top":o=e.x+l/2-n/2,s=e.y-r-a;break;case Oi:o=e.x+l/2-n/2,s=e.y+u+a;break;case"left":o=e.x-n-a,s=e.y+u/2-r/2;break;case"right":o=e.x+l+a,s=e.y+u/2-r/2}return[o,s]}function v(t,e,i,n,r,a,o){var s=o[we](),l=o[be](),u=a&&a[ii]().clone();if(a&&u[fi](a[he]),typeof t===Vi&&(t=t([e,i],r,u)),_[Di](t))e=M(t[0],s),i=M(t[1],l);else if(typeof t===Wi&&a){var c=d(t,u,n.el);e=c[0],i=c[1]}else{var c=h(e,i,n.el,s,l);e=c[0],i=c[1]}n[It](e,i)}function g(t){var e=t[me],i=t.get("tooltip.trigger",!0);return!(!e||e.type!==u&&"polar"!==e.type&&"single"!==e.type||"item"===i)}var y=t("./TooltipContent"),x=t(T),_=t(Qi),b=t("../../util/format"),w=t(k),M=w[Zi],S=t(pt);t(n)[E]({type:"tooltip",_axisPointers:{},init:function(t,e){if(!S.node){var i=new y(e[Me](),e);this._tooltipContent=i,e.on("showTip",this._manuallyShowTip,this),e.on("hideTip",this._manuallyHideTip,this)}},render:function(t,e,i){if(!S.node){this.group[qt](),this._axisPointers={},this._tooltipModel=t,this._ecModel=e,this._api=i,this._lastHover={};var n=this._tooltipContent;n[xe](),n.enterable=t.get("enterable"),this._alwaysShowContent=t.get("alwaysShowContent"),this._seriesGroupByAxis=this._prepareAxisTriggerData(t,e);var r=this._crossText;if(r&&this.group.add(r),null!=this._lastX&&null!=this._lastY){var a=this;clearTimeout(this._refreshUpdateTimeout),this._refreshUpdateTimeout=setTimeout(function(){a._manuallyShowTip({x:a._lastX,y:a._lastY})})}var o=this._api.getZr(),s=this._tryShow;o.off("click",s),o.off(dt,s),o.off(yt,this._hide),"click"===t.get("triggerOn")?o.on("click",s,this):(o.on(dt,s,this),o.on(yt,this._hide,this))}},_manuallyShowTip:function(t){if(t.from!==this.uid){var e=this._ecModel,i=t[qe],n=t[Ft],r=e.getSeriesByIndex(i),a=this._api;if(null==t.x||null==t.y){if(r||e[X](function(t){g(t)&&!r&&(r=t)}),r){var o=r[He]();null==n&&(n=o[Vt](t.name));var s,l,u=o[Gt](n),c=r[me];if(c&&c[p]){var h=c[p](o.getValues(c[Z],n,!0));s=h&&h[0],l=h&&h[1]}else if(u){var d=u[ii]().clone();d[fi](u[he]),s=d.x+d.width/2,l=d.y+d[di]/2}null!=s&&null!=l&&this._tryShow({offsetX:s,offsetY:l,target:u,event:{}})}}else{var u=a.getZr().handler.findHover(t.x,t.y);this._tryShow({offsetX:t.x,offsetY:t.y,target:u,event:{}})}}},_manuallyHideTip:function(t){t.from!==this.uid&&this._hide()},_prepareAxisTriggerData:function(t,e){var i={};return e[X](function(t){if(g(t)){var e,n,r=t[me];r.type===u?(e=r[pe](),n=e.dim+e.index):"single"===r.type?(e=r[f](),n=e.dim+e.type):(e=r[pe](),n=e.dim+r.name),i[n]=i[n]||{coordSys:[],series:[]},i[n].coordSys.push(r),i[n][Ce].push(t)}},this),i},_tryShow:function(t){var e=t[oe],i=this._tooltipModel,n=i.get(Wt),r=this._ecModel,a=this._api;if(i)if(this._lastX=t[ht],this._lastY=t[ct],e&&null!=e[Ft]){var o=e[H]||r.getSeriesByIndex(e[qe]),s=e[Ft],l=o[He]()[Ne](s);"axis"===(l.get("tooltip.trigger")||n)?this._showAxisTooltip(i,r,t):(this._ticket="",this._hideAxisPointer(),this._resetLastHover(),this._showItemTooltipContent(o,s,t)),a[_e]({type:"showTip",from:this.uid,dataIndex:e[Ft],seriesIndex:e[qe]})}else"item"===n?this._hide():this._showAxisTooltip(i,r,t),"cross"===i.get("axisPointer.type")&&a[_e]({type:"showTip",from:this.uid,x:t[ht],y:t[ct]})},_showAxisTooltip:function(t,i,n){var r=t[ri]("axisPointer"),a=r.get("type");if("cross"===a){var o=n[oe];if(o&&null!=o[Ft]){var s=i.getSeriesByIndex(o[qe]),l=o[Ft];this._showItemTooltipContent(s,l,n)}}this._showAxisPointer();var c=!0;_.each(this._seriesGroupByAxis,function(t){var i=t.coordSys,o=i[0],s=[n[ht],n[ct]];if(!o.containPoint(s))return void this._hideAxisPointer(o.name);c=!1;var l=o[Z],h=o.pointToData(s,!0);s=o[p](h);var d=o[pe](),f=r.get("axis");"auto"===f&&(f=d.dim);var m=!1,v=this._lastHover;if("cross"===a)e(v.data,h)&&(m=!0),v.data=h;else{var g=_[Hi](l,f);v.data===h[g]&&(m=!0),v.data=h[g]}o.type!==u||m?"polar"!==o.type||m?"single"!==o.type||m||this._showSinglePointer(r,o,f,s):this._showPolarPointer(r,o,f,s):this._showCartesianPointer(r,o,f,s),"cross"!==a&&this._dispatchAndShowSeriesTooltipContent(o,t[Ce],s,h,m)},this),c&&this._hide()},_showCartesianPointer:function(t,e,n,r){function a(n,r,a){var o="x"===n?i(r[0],a[0],r[0],a[1]):i(a[0],r[1],a[1],r[1]),s=l._getPointerElement(e,t,n,o);h?x[vt](s,{shape:o},t):s.attr({shape:o})}function s(i,n,r){var a=e[f](i),s=a.getBandWidth(),u=r[1]-r[0],c="x"===i?o(n[0]-s/2,r[0],s,u):o(r[0],n[1]-s/2,u,s),d=l._getPointerElement(e,t,i,c);h?x[vt](d,{shape:c},t):d.attr({shape:c})}var l=this,c=t.get("type"),h="cross"!==c;if("cross"===c)a("x",r,e[f]("y").getGlobalExtent()),a("y",r,e[f]("x").getGlobalExtent()),this._updateCrossText(e,r,t);else{var d=e[f]("x"===n?"y":"x"),p=d.getGlobalExtent();e.type===u&&("line"===c?a:s)(n,r,p)}},_showSinglePointer:function(t,e,n,r){function o(n,r,a){var o=e[f](),l=o.orient,c=l===ze?i(r[0],a[0],r[0],a[1]):i(a[0],r[1],a[1],r[1]),h=s._getPointerElement(e,t,n,c);u?x[vt](h,{shape:c},t):h.attr({shape:c})}var s=this,l=t.get("type"),u="cross"!==l,c=e[a](),h=[c.y,c.y+c[di]];o(n,r,h)},_showPolarPointer:function(t,e,n,r){function a(n,r,a){var o,l=e.pointToCoord(r);if("angle"===n){var u=e.coordToPoint([a[0],l[1]]),c=e.coordToPoint([a[1],l[1]]);o=i(u[0],u[1],c[0],c[1])}else o={cx:e.cx,cy:e.cy,r:l[0]};var h=s._getPointerElement(e,t,n,o);d?x[vt](h,{shape:o},t):h.attr({shape:o})}function o(i,n,r){var a,o=e[f](i),u=o.getBandWidth(),c=e.pointToCoord(n),h=Math.PI/180;a="angle"===i?l(e.cx,e.cy,r[0],r[1],(-c[1]-u/2)*h,(-c[1]+u/2)*h):l(e.cx,e.cy,c[0]-u/2,c[0]+u/2,0,2*Math.PI);var p=s._getPointerElement(e,t,i,a);d?x[vt](p,{shape:a},t):p.attr({shape:a})}var s=this,u=t.get("type"),c=e.getAngleAxis(),h=e.getRadiusAxis(),d="cross"!==u;if("cross"===u)a("angle",r,h[m]()),a(Ke,r,c[m]()),this._updateCrossText(e,r,t);else{var p=e[f](n===Ke?"angle":Ke),v=p[m]();("line"===u?a:o)(n,r,v)}},_updateCrossText:function(t,e,i){var n=i[ri]("crossStyle"),r=n[ri](ni),a=this._tooltipModel,o=this._crossText;o||(o=this._crossText=new x.Text({style:{textAlign:"left",textBaseline:"bottom"}}),this.group.add(o));var l=t.pointToData(e),u=t[Z];l=_.map(l,function(e,i){var n=t[f](u[i]);return e=n.type===A||"time"===n.type?n.scale[s](e):b[ve](e[Ii](n[zi]()))}),o[wt]({fill:r[gt]()||n.get("color"),textFont:r[ei](),text:l.join(", "),x:e[0]+5,y:e[1]-5}),o.z=a.get("z"),o[ot]=a.get(ot)},_getPointerElement:function(t,e,i,n){var r=this._tooltipModel,a=r.get("z"),o=r.get(ot),s=this._axisPointers,l=t.name;if(s[l]=s[l]||{},s[l][i])return s[l][i];var u=e.get("type"),h=e[ri](u+"Style"),d="shadow"===u,f=h[d?"getAreaStyle":c](),p="polar"===t.type?d?Tt:i===Ke?"Circle":"Line":d?"Rect":"Line";d?f[_i]=null:f.fill=null;var m=s[l][i]=new x[p]({style:f,z:a,zlevel:o,silent:!0,shape:n});return this.group.add(m),m},_dispatchAndShowSeriesTooltipContent:function(t,e,i,n,a){var o=this._tooltipModel,s=this._tooltipContent,l=t[pe](),u=_.map(e,function(t){return{seriesIndex:t[qe],dataIndex:t.getAxisTooltipDataIndex?t.getAxisTooltipDataIndex(t[r](l.dim),n,l):t[He]().indexOfNearest(t[r](l.dim)[0],n["x"===l.dim||l.dim===Ke?0:1])}}),c=this._lastHover,h=this._api;if(c.payloadBatch&&!a&&h[_e]({type:"downplay",batch:c.payloadBatch}),a||(h[_e]({type:"highlight",batch:u}),c.payloadBatch=u),h[_e]({type:"showTip",dataIndex:u[0][Ft],seriesIndex:u[0][qe],from:this.uid}),l&&o.get("showContent")){var d,f=o.get(Ze),p=o.get(Oe),m=_.map(e,function(t,e){return t[Ee](u[e][Ft])});s.show(o);var g=u[0][Ft];if(!a){if(this._ticket="",f){if(typeof f===Wi)d=b.formatTpl(f,m);else if(typeof f===Vi){var y=this,x="axis_"+t.name+"_"+g,w=function(t,e){t===y._ticket&&(s.setContent(e),v(p,i[0],i[1],s,m,null,h))};y._ticket=x,d=f(m,x,w)}}else{var M=e[0][He]()[Ve](g);d=(M?M+"
":"")+_.map(e,function(t,e){return t.formatTooltip(u[e][Ft],!0)}).join("
")}s.setContent(d)}v(p,i[0],i[1],s,m,null,h)}},_showItemTooltipContent:function(t,e,i){var n=this._api,r=t[He](),a=r[Ne](e),o=this._tooltipModel,s=this._tooltipContent,l=a[ri]("tooltip");if(l.parentModel?l.parentModel.parentModel=o:l.parentModel=this._tooltipModel,l.get("showContent")){var u,c=l.get(Ze),h=l.get(Oe),d=t[Ee](e);if(c){if(typeof c===Wi)u=b.formatTpl(c,d);else if(typeof c===Vi){var f=this,p="item_"+t.name+"_"+e,m=function(t,e){t===f._ticket&&(s.setContent(e),v(h,i[ht],i[ct],s,d,i[oe],n))};f._ticket=p,u=c(d,p,m)}}else u=t.formatTooltip(e);s.show(l),s.setContent(u),v(h,i[ht],i[ct],s,d,i[oe],n)}},_showAxisPointer:function(t){if(t){var e=this._axisPointers[t];e&&_.each(e,function(t){t.show()})}else this.group[Re](function(t){t.show()}),this.group.show()},_resetLastHover:function(){var t=this._lastHover;t.payloadBatch&&this._api[_e]({type:"downplay",batch:t.payloadBatch}),this._lastHover={}},_hideAxisPointer:function(t){if(t){var e=this._axisPointers[t];e&&_.each(e,function(t){t.hide()})}else this.group.hide()},_hide:function(){this._hideAxisPointer(),this._resetLastHover(),this._alwaysShowContent||this._tooltipContent.hideLater(this._tooltipModel.get("hideDelay")),this._api[_e]({type:"hideTip",from:this.uid})},dispose:function(t,e){if(!S.node){var i=e.getZr();this._tooltipContent.hide(),i.off("click",this._tryShow),i.off(dt,this._tryShow),i.off(yt,this._hide),e.off("showTip",this._manuallyShowTip),e.off("hideTip",this._manuallyHideTip)}}})}),e("echarts/component/tooltip",[Ji,"./tooltip/TooltipModel","./tooltip/TooltipView",l,l],function(t){t("./tooltip/TooltipModel"),t("./tooltip/TooltipView"),t(l)[F]({type:"showTip",event:"showTip",update:"none"},function(){}),t(l)[F]({type:"hideTip",event:"hideTip",update:"none"},function(){})}),e("echarts/component/legend/LegendModel",[Ji,Qi,"../../model/Model",n],function(t){var e=t(Qi),i=t("../../model/Model"),r=t(n)[N]({type:"legend",dependencies:[Ce],layoutMode:{type:"box",ignoreSize:!0},init:function(t,e,i){this[De](t,i),t.selected=t.selected||{},this._updateData(i);var n=this._data,r=this[Je].selected;if(n[0]&&"single"===this.get("selectedMode")){var a=!1;for(var o in r)r[o]&&(this.select(o),a=!0);!a&&this.select(n[0].get("name"))}},mergeOption:function(t){r.superCall(this,Ae,t),this._updateData(this[ai])},_updateData:function(t){var n=e.map(this.get("data")||[],function(t){return typeof t===Wi&&(t={name:t}),new i(t,this,this[ai])},this);this._data=n;var r=e.map(t.getSeries(),function(t){return t.name});t[X](function(t){if(t.legendDataProvider){var e=t.legendDataProvider();r=r[Gi](e[R](e[Ve]))}}),this._availableNames=r},getData:function(){return this._data},select:function(t){var i=this[Je].selected,n=this.get("selectedMode");if("single"===n){var r=this._data;e.each(r,function(t){i[t.get("name")]=!1})}i[t]=!0},unSelect:function(t){"single"!==this.get("selectedMode")&&(this[Je].selected[t]=!1)},toggleSelected:function(t){var e=this[Je].selected;t in e||(e[t]=!0),this[e[t]?"unSelect":"select"](t)},isSelected:function(t){var i=this[Je].selected;return!(t in i&&!i[t])&&e[Hi](this._availableNames,t)>=0},defaultOption:{zlevel:0,z:4,show:!0,orient:"horizontal",left:"center",top:"top",align:"auto",backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",borderWidth:0,padding:5,itemGap:10,itemWidth:25,itemHeight:14,textStyle:{color:"#333"},selectedMode:!0}});return r}),e("echarts/component/legend/legendAction",[Ji,n,Qi],function(t){function e(t,e,i){var n,a={},o="toggleSelected"===t;return i[q]("legend",function(i){o&&null!=n?i[n?"select":"unSelect"](e.name):(i[t](e.name),n=i.isSelected(e.name));var s=i[He]();r.each(s,function(t){var e=t.get("name");if("\n"!==e&&""!==e){var n=i.isSelected(e);e in a?a[e]=a[e]&&n:a[e]=n}})}),{name:e.name,selected:a}}var i=t(n),r=t(Qi);i[F]("legendToggleSelect","legendselectchanged",r.curry(e,"toggleSelected")),i[F]("legendSelect","legendselected",r.curry(e,"select")),i[F]("legendUnSelect","legendunselected",r.curry(e,"unSelect"))}),e("echarts/component/helper/listComponent",[Ji,"../../util/layout","../../util/format",T],function(t){function e(t,e,r){n.positionGroup(t,e.getBoxLayoutParams(),{width:r[we](),height:r[be]()},e.get(i))}var n=t("../../util/layout"),r=t("../../util/format"),a=t(T);return{layout:function(t,r,a){var o=n[Le](r.getBoxLayoutParams(),{width:a[we](),height:a[be]()},r.get(i));n.box(r.get("orient"),t,r.get("itemGap"),o.width,o[di]),e(t,r,a)},addBackground:function(t,e){var n=r.normalizeCssArray(e.get(i)),o=t[ii](),s=e[x](["color",xi]);s.fill=e.get(et);var l=new a.Rect({shape:{x:o.x-n[3],y:o.y-n[0],width:o.width+n[1]+n[3],height:o[di]+n[0]+n[2]},style:s,silent:!0,z2:-1});a[Mt](l),t.add(l)}}}),e("echarts/component/legend/LegendView",[Ji,Qi,C,T,"../helper/listComponent",n],function(t){function e(t,e){e[_e]({type:"legendToggleSelect",name:t})}function i(t,e,i){t.get("legendHoverLink")&&i[_e]({type:"highlight",seriesName:t.name,name:e})}function r(t,e,i){t.get("legendHoverLink")&&i[_e]({type:"downplay",seriesName:t.name,name:e})}var a=t(Qi),o=t(C),s=t(T),l=t("../helper/listComponent"),u=a.curry,c="#ccc";return t(n)[E]({type:"legend",init:function(){this._symbolTypeStore={}},render:function(t,n,o){var h=this.group;if(h[qt](),t.get("show")){var d=t.get("selectedMode"),f=t.get("itemWidth"),p=t.get("itemHeight"),m=t.get("align");"auto"===m&&(m="right"===t.get("left")&&t.get("orient")===Pe?"right":"left");var v={},g={};a.each(t[He](),function(a){var l=a.get("name");(""===l||"\n"===l)&&h.add(new s.Group({newline:!0}));var y=n.getSeriesByName(l)[0];if(v[l]=a,y&&!g[l]){var x=y[He](),_=x[O]("color");t.isSelected(l)||(_=c),typeof _===Vi&&(_=_(y[Ee](0)));var w=x[O]("legendSymbol")||"roundRect",M=x[O](b),S=this._createItem(l,a,t,w,M,f,p,m,_,d);S.on("click",u(e,l,o)).on(xt,u(i,y,"",o)).on(yt,u(r,y,"",o)),g[l]=!0}},this),n.eachRawSeries(function(n){if(n.legendDataProvider){var a=n.legendDataProvider();a.each(function(s){var l=a[Ve](s);if(v[l]&&!g[l]){var h=a[P](s,"color");t.isSelected(l)||(h=c);var y="roundRect",x=this._createItem(l,v[l],t,y,null,f,p,m,h,d);x.on("click",u(e,l,o)).on(xt,u(i,n,l,o)).on(yt,u(r,n,l,o)),g[l]=!0}},!1,this)}},this),l.layout(h,t,o),l.addBackground(h,t)}},_createItem:function(t,e,i,n,r,a,l,u,c,h){var d=new s.Group,f=e[ri](ni),p=e.get("icon");if(n=p||n,d.add(o[M](n,0,0,a,l,c)),!p&&r&&r!==n&&"none"!=r){var m=.8*l;d.add(o[M](r,(a-m)/2,(l-m)/2,m,m,c))}var v="left"===u?a+5:-5,g=u,y=i.get(Ze);typeof y===Wi&&y?t=y[Ni]("{name}",t):typeof y===Vi&&(t=y(t));var x=new s.Text({style:{text:t,x:v,y:l/2,fill:f[gt](),textFont:f[ei](),textAlign:g,textBaseline:"middle"}});return d.add(x),d.add(new s.Rect({shape:d[ii](),invisible:!0})),d[Re](function(t){t.silent=!h}),this.group.add(d),d}})}),e("echarts/component/legend/legendFilter",[],function(){return function(t){var e=t[Se]({mainType:"legend"});e&&e[Xi]&&t.filterSeries(function(t){for(var i=0;i0?"top":Oi,n=Bi):h(a-d)?(r=i>0?Oi:"top",n=Bi):(r=Ri,n=a>0&&d>a?i>0?"right":"left":i>0?"left":"right"),{rotation:a,textAlign:n,textBaseline:r}}function i(t,e,i){var n,r,a=u(-t[de]),o=i[0]>i[1],s="start"===e&&!o||"start"!==e&&o;return h(a-d/2)?(r=s?Oi:"top",n=Bi):h(a-1.5*d)?(r=s?"top":Oi,n=Bi):(r=Ri,n=1.5*d>a&&a>d/2?s?"left":"right":s?"right":"left"),{rotation:a,textAlign:n,textBaseline:r}}var n=t(Qi),r=t(T),a=t("../../model/Model"),l=t(k),u=l.remRadian,h=l.isRadianAroundZero,d=Math.PI,f=function(t,e){this.opt=e,this.axisModel=t,n[oi](e,{labelOffset:0,nameDirection:1,tickDirection:1,labelDirection:1,silent:!0}),this.group=new r.Group({position:e[Oe].slice(),rotation:e[de]})};f[Ki]={constructor:f,hasBuilder:function(t){return!!p[t]},add:function(t){p[t].call(this)},getGroup:function(){return this.group}};var p={axisLine:function(){var t=this.opt,e=this.axisModel;if(e.get("axisLine.show")){var i=this.axisModel.axis[m]();this.group.add(new r.Line({shape:{x1:i[0],y1:0,x2:i[1],y2:0},style:n[Ci]({lineCap:"round"},e[ri]("axisLine.lineStyle")[c]()),strokeContainThreshold:t.strokeContainThreshold,silent:!!t.silent,z2:1}))}},axisTick:function(){var t=this.axisModel;if(t.get("axisTick.show")){for(var e=t.axis,i=t[ri]("axisTick"),n=this.opt,a=i[ri]("lineStyle"),o=i.get(Xi),s=g(i,n.labelInterval),l=e.getTicksCoords(),u=[],h=0;hh[1]?-1:1,f=["start"===s?h[0]-d*c:"end"===s?h[1]+d*c:(h[0]+h[1])/2,s===Ri?t.labelOffset+l*c:0];o=s===Ri?e(t,t[de],l):i(t,s,h),this.group.add(new r.Text({style:{text:a,textFont:u[ei](),fill:u[gt]()||n.get("axisLine.lineStyle.color"),textAlign:o[Zt],textBaseline:o[Bt]},position:f,rotation:o[de],silent:!0,z2:1}))}}},v=f.ifIgnoreOnTick=function(t,e,i){var n,r=t.scale;return r.type===We&&(typeof i===Vi?(n=r.getTicks()[e],!i(n,r[s](n))):e%(i+1))},g=f.getInterval=function(t,e){var i=t.get("interval");return(null==i||"auto"==i)&&(i=e),i};return f}),e("echarts/component/axis/AxisView",[Ji,Qi,T,"./AxisBuilder",n],function(t){function e(t,e){function i(t,e){var i=n[f](t);return i.toGlobalCoord(i[o](0))}var n=t[me],r=e.axis,s={},l=r[Oe],u=r.onZero?"onZero":l,c=r.dim,h=n[a](),d=[h.x,h.x+h.width,h.y,h.y+h[di]],p={x:{top:d[2],bottom:d[3]},y:{left:d[0],right:d[1]}};p.x.onZero=Math.max(Math.min(i("y"),p.x[Oi]),p.x.top),p.y.onZero=Math.max(Math.min(i("x"),p.y.right),p.y.left),s[Oe]=["y"===c?p.y[u]:d[0],"x"===c?p.x[u]:d[3]];var m={x:0,y:1};s[de]=Math.PI/2*m[c];var v={top:-1,bottom:1,left:-1,right:1};s.labelDirection=s.tickDirection=s.nameDirection=v[l],r.onZero&&(s.labelOffset=p[c][l]-p[c].onZero),e[ri]("axisTick").get(si)&&(s.tickDirection=-s.tickDirection),e[ri]("axisLabel").get(si)&&(s.labelDirection=-s.labelDirection);var g=e[ri]("axisLabel").get(le);return s.labelRotation="top"===u?-g:g,s.labelInterval=r.getLabelInterval(),s.z2=1,s}var i=t(Qi),r=t(T),s=t("./AxisBuilder"),l=s.ifIgnoreOnTick,u=s.getInterval,c=["axisLine","axisLabel","axisTick","axisName"],h=["splitLine","splitArea"],p=t(n)[E]({type:"axis",render:function(t,n){if(this.group[qt](),t.get("show")){var r=n[ge]("grid",t.get("gridIndex")),a=e(r,t),o=new s(t,a);i.each(c,o.add,o),this.group.add(o.getGroup()),i.each(h,function(e){t.get(e+".show")&&this["_"+e](t,r,a.labelInterval)},this)}},_splitLine:function(t,e,i){var n=t.axis,o=t[ri]("splitLine"),s=o[ri]("lineStyle"),c=s.get("width"),h=s.get("color"),f=u(o,i);h=h instanceof Array?h:[h];for(var p=e[me][a](),m=n[d](),v=[],g=0,y=n.getTicksCoords(),x=[],_=[],b=0;b=0&&(s[o]=+s[o][Ii](c)),s}var n=t(Qi),a=t(k),o=n[Hi],s=n.curry,l={min:s(i,"min"),max:s(i,"max"),average:s(i,"average")},u=function(t,e){var i=t[He](),r=t[me];if((isNaN(e.x)||isNaN(e.y))&&!n[Di](e.coord)&&r){var a=c(e,i,r,t);if(e=n.clone(e),e.type&&l[e.type]&&a.baseAxis&&a.valueAxis){var s=r[Z],u=o(s,a.baseAxis.dim),h=o(s,a.valueAxis.dim);e.coord=l[e.type](i,a.baseDataDim,a.valueDataDim,u,h),e.value=e.coord[h]}else e.coord=[null!=e.xAxis?e.xAxis:e.radiusAxis,null!=e.yAxis?e.yAxis:e.angleAxis]}return e},c=function(t,e,i,n){var a={};return null!=t.valueIndex||null!=t.valueDim?(a.valueDataDim=null!=t.valueIndex?e.getDimension(t.valueIndex):t.valueDim,a.valueAxis=i[f](n.dataDimToCoordDim(a.valueDataDim)),a.baseAxis=i[v](a.valueAxis),a.baseDataDim=n[r](a.baseAxis.dim)[0]):(a.baseAxis=n[pe](),a.valueAxis=i[v](a.baseAxis),a.baseDataDim=n[r](a.baseAxis.dim)[0],a.valueDataDim=n[r](a.valueAxis.dim)[0]),a},h=function(t,e){return t&&e.coord&&(null==e.x||null==e.y)?t.containData(e.coord):!0},d=function(t,e,i,n){return 2>n?t.coord&&t.coord[n]:void t.value},p=function(t,e,i){return"average"===i?t.getSum(e,!0)/t.count():t[B](e,!0)["max"===i?1:0]};return{dataTransform:u,dataFilter:h,dimValueGetter:d,getAxisInfo:c,numCalculate:p}}),e("echarts/component/marker/MarkPointView",[Ji,"../../chart/helper/SymbolDraw",Qi,"../../util/format",D,k,"../../data/List","./markerHelper",n],function(t){function e(t,e,i){var n=a.map(t[Z],function(t){var i=e[He]().getDimensionInfo(e[r](t)[0]);return i.name=t,i}),o=new h(n,i);return t&&o.initData(a[$i](a.map(i.get("data"),a.curry(d.dataTransform,e)),a.curry(d.dataFilter,t)),null,d.dimValueGetter),o}var i=t("../../chart/helper/SymbolDraw"),a=t(Qi),o=t("../../util/format"),s=t(D),l=t(k),u=o[ve],c=o.encodeHTML,h=t("../../data/List"),d=t("./markerHelper"),f={getRawDataArray:function(){return this[Je].data},formatTooltip:function(t){var e=this[He](),i=this[Fe](t),n=a[Di](i)?a.map(i,u).join(", "):u(i),r=e[Ve](t);return this.name+"
"+((r?c(r)+" : ":"")+n)},getData:function(){return this._data},setData:function(t){this._data=t}};a[oi](f,s.dataFormatMixin),t(n)[E]({type:"markPoint",init:function(){this._symbolDrawMap={}},render:function(t,e,i){var n=this._symbolDrawMap;for(var r in n)n[r].__keep=!1;e[X](function(t){var e=t.markPointModel;e&&this._renderSeriesMP(t,e,i)},this);for(var r in n)n[r].__keep||(n[r][Qt](),this.group[Qt](n[r].group))},_renderSeriesMP:function(t,n,r){var o=t[me],s=t.name,u=t[He](),c=this._symbolDrawMap,h=c[s];h||(h=c[s]=new i);var d=e(o,t,n),m=o&&o[Z];a.mixin(n,f),n[At](d),d.each(function(e){var i,a=d[Ne](e),s=a[wi]("x"),c=a[wi]("y");if(null!=s&&null!=c)i=[l[Zi](s,r[we]()),l[Zi](c,r[be]())];else if(t.getMarkerPosition)i=t.getMarkerPosition(d.getValues(d[Z],e));else if(o){var h=d.get(m[0],e),f=d.get(m[1],e);i=o[p]([h,f])}d[z](e,i);var v=a[wi](w);typeof v===Vi&&(v=v(n[Fe](e),n[Ee](e))),d[$](e,{symbolSize:v,color:a.get("itemStyle.normal.color")||u[O]("color"),symbol:a[wi](b)})}),h[S](d),this.group.add(h.group),d[Nt](function(t){t[Xt](function(t){t[H]=n})}),h.__keep=!0}})}),e("echarts/component/markPoint",[Ji,"./marker/MarkPointModel","./marker/MarkPointView",l],function(t){t("./marker/MarkPointModel"),t("./marker/MarkPointView"),t(l).registerPreprocessor(function(t){t.markPoint=t.markPoint||{}})}),e("echarts/component/marker/MarkLineModel",[Ji,D,n],function(t){var e=t(D),i=t(n)[N]({type:"markLine",dependencies:[Ce,"grid","polar"],init:function(t,e,i,n){this[De](t,i),this[Ae](t,i,n.createdBySelf,!0)},mergeOption:function(t,n,r,a){r||n[X](function(t){var r=t.get("markLine"),o=t.markLineModel;if(!r||!r.data)return void(t.markLineModel=null);if(o)o[Ae](r,n,!0);else{a&&e[Ye](r.label,[Oe,"show",ni,vi,Ze]);var s={seriesIndex:t[qe],name:t.name,createdBySelf:!0};o=new i(r,this,n,s)}t.markLineModel=o},this)},defaultOption:{zlevel:0,z:5,symbol:[_,"arrow"],symbolSize:[8,16],precision:2,tooltip:{trigger:"item"},label:{normal:{show:!0,position:"end"},emphasis:{show:!0}},lineStyle:{normal:{type:"dashed"},emphasis:{width:3}},animationEasing:"linear"}});return i}),e("echarts/chart/helper/LinePath",[Ji,T],function(t){var e=t(T),i=e.Line[Ki],n=e.BezierCurve[Ki];return e[St]({type:"ec-line",style:{stroke:"#000",fill:null},shape:{x1:0,y1:0,x2:0,y2:0,percent:1,cpx1:null,cpy1:null},buildPath:function(t,e){(null==e.cpx1||null==e.cpy1?i:n)[Pt](t,e)},pointAt:function(t){var e=this.shape;return null==e.cpx1||null==e.cpy1?i.pointAt.call(this,t):n.pointAt.call(this,t)}})}),e("echarts/chart/helper/Line",[Ji,C,yi,"./LinePath",T,Qi,k],function(t){function e(t,e,i){var n=e[P](i,"color"),r=e[P](i,b),a=e[P](i,w);if("none"!==r){f[Di](a)||(a=[a,a]);var o=l[M](r,-a[0]/2,-a[1]/2,a[0],a[1],n);return o.name=t,o}}function i(t){var e=new h({name:"line",style:{strokeNoScale:!0}});return n(e.shape,t),e}function n(t,e){var i=e[0],n=e[1],r=e[2];t.x1=i[0],t.y1=i[1],t.x2=n[0],t.y2=n[1],t.percent=1,r&&(t.cpx1=r[0],t.cpy1=r[1])}function r(t){return t.type===b&&"arrow"===t.shape.symbolType}function a(){var t=this,e=t.childOfName("line");if(this[Kt]||e[Kt]){var i=t.childOfName("fromSymbol"),n=t.childOfName("toSymbol"),a=t.childOfName("label"),s=e.pointAt(0),l=e.pointAt(e.shape.percent),c=u.sub([],l,s);u.normalize(c,c),i&&(i.attr(Oe,s),r(n)&&n.attr(de,o(s,l))),n&&(n.attr(Oe,l),r(i)&&i.attr(de,o(l,s))),a.attr(Oe,l);var h,d,f;"end"===a.__position?(h=[5*c[0]+l[0],5*c[1]+l[1]],d=c[0]>.8?"left":c[0]<-.8?"right":Bi,f=c[1]>.8?"top":c[1]<-.8?Oi:Ri):(h=[5*-c[0]+s[0],5*-c[1]+s[1]],d=c[0]>.8?"right":c[0]<-.8?"left":Bi,f=c[1]>.8?Oi:c[1]<-.8?"top":Ri),a.attr({style:{textBaseline:a.__textBaseline||f,textAlign:a.__textAlign||d},position:h})}}function o(t,e){return-Math.PI/2-Math.atan2(e[1]-t[1],e[0]-t[0])}function s(t,e,i,n){d.Group.call(this),this._createLine(t,e,i,n)}var l=t(C),u=t(yi),h=t("./LinePath"),d=t(T),f=t(Qi),p=t(k),m=s[Ki];return m.beforeUpdate=a,m._createLine=function(t,n,r,a){var o=t[H],s=t[I](a),l=i(s);l.shape.percent=0,d[mt](l,{shape:{percent:1}},o),this.add(l);var u=new d.Text({name:"label"});if(this.add(u),n){var c=e("fromSymbol",n,a);this.add(c),this._fromSymbolType=n[P](a,b)}if(r){var h=e("toSymbol",r,a);this.add(h),this._toSymbolType=r[P](a,b)}this._updateCommonStl(t,n,r,a)},m[S]=function(t,i,r,a){var o=t[H],s=this.childOfName("line"),l=t[I](a),u={shape:{}};if(n(u.shape,l),d[vt](s,u,o),i){var c=i[P](a,b);if(this._fromSymbolType!==c){var h=e("fromSymbol",i,a);this[Qt](s.childOfName("fromSymbol")),this.add(h)}this._fromSymbolType=c}if(r){var f=r[P](a,b);if(f!==this._toSymbolType){var p=e("toSymbol",r,a);this[Qt](s.childOfName("toSymbol")),this.add(p)}this._toSymbolType=f}this._updateCommonStl(t,i,r,a)},m._updateCommonStl=function(t,e,i,n){var r=t[H],a=this.childOfName("line"),o=t[Ne](n),s=o[ri]("label.normal"),l=s[ri](ni),u=o[ri]("label.emphasis"),h=u[ri](ni),m=p.round(r[Fe](n));isNaN(m)&&(m=t[Ve](n)),a[wt](f[Ci]({stroke:t[P](n,"color")},o[ri]("lineStyle.normal")[c]()));var v=this.childOfName("label");v[wt]({text:s.get("show")?f[je](r[y](n,Ue),m):"",textFont:l[ei](),fill:l[gt]()||t[P](n,"color")}),v[bt]={text:u.get("show")?f[je](r[y](n,Xe),m):"",textFont:l[ei](),fill:h[gt]()},v.__textAlign=l.get("align"),v.__textBaseline=l.get("baseline"),v.__position=s.get(Oe),d[_t](this,o[ri]("lineStyle.emphasis")[c]())},m[jt]=function(t,e,i,r){var a=t[I](r),o=this.childOfName("line");n(o.shape,a),o.dirty(!0),e&&e[Gt](r).attr(Oe,a[0]),i&&i[Gt](r).attr(Oe,a[1])},f[ki](s,d.Group),s}),e("echarts/chart/helper/LineDraw",[Ji,T,"./Line"],function(t){function e(t){this._ctor=t||n,this.group=new i.Group}var i=t(T),n=t("./Line"),r=e[Ki];return r[S]=function(t,e,i){var n=this._lineData,r=this.group,a=this._ctor;t.diff(n).add(function(n){var o=new a(t,e,i,n);t[L](n,o),r.add(o)})[xe](function(a,o){var s=n[Gt](o);s[S](t,e,i,a),t[L](a,s),r.add(s)})[Qt](function(t){r[Qt](n[Gt](t))})[g](),this._lineData=t,this._fromData=e,this._toData=i},r[jt]=function(){var t=this._lineData;t[Nt](function(e,i){e[jt](t,this._fromData,this._toData,i)},this)},r[Qt]=function(){this.group[qt]()},e}),e("echarts/component/marker/MarkLineView",[Ji,Qi,"../../data/List","../../util/format",D,k,"./markerHelper","../../chart/helper/LineDraw",n],function(t){function e(t,e){return f.dataFilter(t,e[0])&&f.dataFilter(t,e[1])}function i(t,i,n){var o=a.map(t[Z],function(t){var e=i[He]().getDimensionInfo(i[r](t)[0]);return e.name=t,e}),l=new s(o,n),u=new s(o,n),c=new s([],n);if(t){var h=a[$i](a.map(n.get("data"),a.curry(g,i,t,n)),a.curry(e,t));l.initData(a.map(h,function(t){return t[0]}),null,f.dimValueGetter),u.initData(a.map(h,function(t){return t[1]}),null,f.dimValueGetter),c.initData(a.map(h,function(t){return t[2]}))}return{from:l,to:u,line:c}}var a=t(Qi),s=t("../../data/List"),l=t("../../util/format"),u=t(D),c=t(k),h=l[ve],d=l.encodeHTML,f=t("./markerHelper"),v=t("../../chart/helper/LineDraw"),g=function(t,e,i,n){var r=t[He](),s=n.type;if(!a[Di](n)&&("min"===s||"max"===s||"average"===s)){var l=f.getAxisInfo(n,r,e,t),u=l.baseAxis.dim+"Axis",c=l.valueAxis.dim+"Axis",h=l.baseAxis.scale[m](),d=a.clone(n),p={};d.type=null,d[u]=h[0],p[u]=h[1];var v=f.numCalculate(r,l.valueDataDim,s);v=l.valueAxis.coordToData(l.valueAxis[o](v));var g=i.get("precision");g>=0&&(v=+v[Ii](g)),d[c]=p[c]=v,n=[d,p,{type:s,value:v}]}return n=[f.dataTransform(t,n[0]),f.dataTransform(t,n[1]),a[Ci]({},n[2])],a.merge(n[2],n[0]),a.merge(n[2],n[1]),n},y={formatTooltip:function(t){var e=this._data,i=this[Fe](t),n=a[Di](i)?a.map(i,h).join(", "):h(i),r=e[Ve](t);return this.name+"
"+((r?d(r)+" : ":"")+n)},getRawDataArray:function(){return this[Je].data},getData:function(){return this._data},setData:function(t){this._data=t}};a[oi](y,u.dataFormatMixin),t(n)[E]({type:"markLine",init:function(){this._markLineMap={}},render:function(t,e,i){var n=this._markLineMap;for(var r in n)n[r].__keep=!1;e[X](function(t){var n=t.markLineModel;n&&this._renderSeriesML(t,n,e,i)},this);for(var r in n)n[r].__keep||this.group[Qt](n[r].group)},_renderSeriesML:function(t,e,n,r){function o(e,i,n){var a,o=e[Ne](i),l=o.get("x"),h=o.get("y");if(null!=l&&null!=h)a=[c[Zi](l,r[we]()),c[Zi](h,r[be]())];else if(t.getMarkerPosition)a=t.getMarkerPosition(e.getValues(e[Z],i));else{var d=e.get(m[0],i),f=e.get(m[1],i);a=s[p]([d,f])}e[z](i,a),e[$](i,{symbolSize:o.get(w)||k[n?0:1],symbol:o.get(b,!0)||M[n?0:1],color:o.get("itemStyle.normal.color")||u[O]("color")})}var s=t[me],l=t.name,u=t[He](),h=this._markLineMap,d=h[l];d||(d=h[l]=new v),this.group.add(d.group);var f=i(s,t,e),m=s[Z],g=f.from,x=f.to,_=f.line;a[Ci](e,y),e[At](_);var M=e.get(b),k=e.get(w);a[Di](M)||(M=[M,M]),typeof k===Fi&&(k=[k,k]),f.from.each(function(t){o(g,t,!0),o(x,t)}),_.each(function(t){var e=_[Ne](t).get("lineStyle.normal.color");_[$](t,{color:e||g[P](t,"color")}),_[z](t,[g[I](t),x[I](t)])}),d[S](_,g,x),f.line[Nt](function(t,i){t[Xt](function(t){t[H]=e})}),d.__keep=!0}})}),e("echarts/component/markLine",[Ji,"./marker/MarkLineModel","./marker/MarkLineView",l],function(t){t("./marker/MarkLineModel"),t("./marker/MarkLineView"),t(l).registerPreprocessor(function(t){t.markLine=t.markLine||{}})}),e("echarts/component/dataZoom/typeDefaulter",[Ji,"../../model/Component"],function(t){t("../../model/Component").registerSubTypeDefaulter(j,function(t){return"slider"})}),e("echarts/component/dataZoom/AxisProxy",[Ji,Qi,k],function(t){function e(t,e){var i=[1/0,-(1/0)];return l(e,function(e){var n=e[He]();n&&l(e[r](t),function(t){var e=n[B](t);e[0]i[1]&&(i[1]=e[1])})},this),i}function i(t,e,i){var r=i.getAxisModel(),a=r.axis.scale,o=[0,100],c=[t.start,t.end],h=[],d=i._backup;return e=e.slice(),n(e,d,a),l(["startValue","endValue"],function(e){h.push(null!=t[e]?a.parse(t[e]):null)}),l([0,1],function(t){var i=h[t],n=c[t];null!=n||null==i?(null==n&&(n=o[t]),i=a.parse(s[Ei](n,o,e,!0))):n=s[Ei](i,e,o,!0),h[t]=i,c[t]=n}),{valueWindow:u(h),percentWindow:u(c)}}function n(t,e,i){return l(["min","max"],function(n,r){var a=e[n];null!=a&&(a+"")[Pi]()!=="data"+n&&(t[r]=i.parse(a))}),e.scale||(t[0]>0&&(t[0]=0),t[1]<0&&(t[1]=0)),t}function a(t,e){var i=t.getAxisModel(),n=t._backup,r=t._percentWindow,a=t._valueWindow;if(n){var o=e||0===r[0]&&100===r[1],l=!e&&s[zi](a,[0,500]),u=!(e||20>l&&l>=0);i.setNeedsCrossZero&&i.setNeedsCrossZero(e||o?!n.scale:!1),i.setMin&&i.setMin(e||o||u?n.min:+a[0][Ii](l)),i.setMax&&i.setMax(e||o||u?n.max:+a[1][Ii](l))}}var o=t(Qi),s=t(k),l=o.each,u=s.asc,c=function(t,e,i,n){this._dimName=t,this._axisIndex=e,this._backup,this._valueWindow,this._percentWindow,this._dataExtent,this[ai]=n,this._dataZoomModel=i};return c[Ki]={constructor:c,hostedBy:function(t){return this._dataZoomModel===t},backup:function(t,e){if(t===this._dataZoomModel){var i=this.getAxisModel();this._backup={scale:i.get("scale",!0),min:i.get("min",!0),max:i.get("max",!0)}}},getDataExtent:function(){return this._dataExtent.slice()},getDataValueWindow:function(){return this._valueWindow.slice()},getDataPercentWindow:function(){return this._percentWindow.slice()},getTargetSeriesModels:function(){var t=[];return this[ai][X](function(e){this._axisIndex===e.get(this._dimName+"AxisIndex")&&t.push(e)},this),t},getAxisModel:function(){return this[ai][ge](this._dimName+"Axis",this._axisIndex)},getOtherAxisModel:function(){var t,e,i=this._dimName,n=this[ai],r=this.getAxisModel(),a="x"===i||"y"===i;a?(e="gridIndex",t="x"===i?"y":"x"):(e="polarIndex",t="angle"===i?Ke:"angle");var o;return n[q](t+"Axis",function(t){(t.get(e)||0)===(r.get(e)||0)&&(o=t)}),o},reset:function(t){if(t===this._dataZoomModel){var n=this._dataExtent=e(this._dimName,this.getTargetSeriesModels()),r=i(t[Je],n,this);this._valueWindow=r.valueWindow,this._percentWindow=r.percentWindow,a(this)}},restore:function(t){t===this._dataZoomModel&&(this._valueWindow=this._percentWindow=null,a(this,!0))},filterData:function(t){function e(t){return t>=o[0]&&t<=o[1]}if(t===this._dataZoomModel){var i=this._dimName,n=this.getTargetSeriesModels(),a=t.get("filterMode"),o=this._valueWindow,s=this.getOtherAxisModel();t.get("$fromToolbox")&&s&&s.get("type")===A&&(a="empty"),l(n,function(t){var n=t[He]();n&&l(t[r](i),function(i){"empty"===a?t[At](n.map(i,function(t){return e(t)?t:NaN})):n.filterSelf(i,e)})})}}},c}),e("echarts/component/dataZoom/DataZoomModel",[Ji,Qi,pt,n,D,"./AxisProxy","../../util/layout"],function(t){function e(t){var e={};return c(["start","end","startValue","endValue"],function(i){e[i]=t[i]}),e}function i(t,e,i,n){null!=i[e]&&null==i[t]&&(n[t]=null)}var r=t(Qi),a=t(pt),o=t(n),s=t(D),l=t("./AxisProxy"),u=t("../../util/layout"),c=r.each,h=s.eachAxisDim,d=o[N]({type:"dataZoom",dependencies:["xAxis","yAxis","zAxis","radiusAxis","angleAxis",Ce],defaultOption:{zlevel:0,z:4,orient:null,xAxisIndex:null,yAxisIndex:null,angleAxisIndex:null,radiusAxisIndex:null,filterMode:"filter",throttle:100,start:0,end:100,startValue:null,endValue:null},init:function(t,i,n){this._dataIntervalByAxis={},this._dataInfo={},this._axisProxies={},this.textStyleModel;var r=e(t);this[De](t,n),this.doInit(r)},mergeOption:function(t){var i=e(t);r.merge(this[Je],t,!0),this.doInit(i)},doInit:function(t){var e=this[Je];a[J]||(e.realtime=!1),i("start","startValue",t,e),i("end","endValue",t,e),this.textStyleModel=this[ri](ni),this._resetTarget(),this._giveAxisProxies(),this._backup()},restoreData:function(){d[Ti](this,"restoreData",arguments),this.eachTargetAxis(function(t,e,i){i.getAxisProxy(t.name,e)[Lt](i)})},_giveAxisProxies:function(){var t=this._axisProxies;this.eachTargetAxis(function(e,i,n,r){var a=this.dependentModels[e.axis][i],o=a.__dzAxisProxy||(a.__dzAxisProxy=new l(e.name,i,this,r));t[e.name+"_"+i]=o},this)},_resetTarget:function(){var t=this[Je],e=this._judgeAutoMode();h(function(e){var i=e[Qe];t[i]=s[$e](t[i])},this),e===Qe?this._autoSetAxisIndex():"orient"===e&&this._autoSetOrient()},_judgeAutoMode:function(){var t=this[Je],e=!1;h(function(i){null!=t[i[Qe]]&&(e=!0)},this);var i=t.orient;return null==i&&e?"orient":e?void 0:(null==i&&(t.orient=ze),Qe)},_autoSetAxisIndex:function(){var t=!0,e=this.get("orient",!0),i=this[Je];if(t){var n=e===Pe?{dim:"y",axisIndex:"yAxisIndex",axis:"yAxis"}:{dim:"x",axisIndex:"xAxisIndex",axis:"xAxis"};this.dependentModels[n.axis][Xi]&&(i[n[Qe]]=[0],t=!1)}t&&h(function(e){if(t){var n=[],r=this.dependentModels[e.axis];if(r[Xi]&&!n[Xi])for(var a=0,o=r[Xi];o>a;a++)r[a].get("type")===A&&n.push(a);i[e[Qe]]=n,n[Xi]&&(t=!1)}},this),t&&this[ai][X](function(t){this._isSeriesHasAllAxesTypeOf(t,"value")&&h(function(e){var n=i[e[Qe]],a=t.get(e[Qe]);r[Hi](n,a)<0&&n.push(a)})},this)},_autoSetOrient:function(){var t;this.eachTargetAxis(function(e){!t&&(t=e.name)},this),this[Je].orient="y"===t?Pe:ze},_isSeriesHasAllAxesTypeOf:function(t,e){var i=!0;return h(function(n){var r=t.get(n[Qe]),a=this.dependentModels[n.axis][r];a&&a.get("type")===e||(i=!1)},this),i},_backup:function(){this.eachTargetAxis(function(t,e,i,n){this.getAxisProxy(t.name,e).backup(i)},this)},getFirstTargetAxisModel:function(){var t;return h(function(e){if(null==t){var i=this.get(e[Qe]);i[Xi]&&(t=this.dependentModels[e.axis][i[0]])}},this),t},eachTargetAxis:function(t,e){var i=this[ai];h(function(n){c(this.get(n[Qe]),function(r){t.call(e,n,r,this,i)},this)},this)},getAxisProxy:function(t,e){return this._axisProxies[t+"_"+e]},setRawRange:function(t){c(["start","end","startValue","endValue"],function(e){this[Je][e]=t[e]},this)},setLayoutParams:function(t){u.copyLayoutParams(this[Je],t)},getPercentRange:function(){var t=this.findRepresentativeAxisProxy();return t?t.getDataPercentWindow():void 0},getValueRange:function(t,e){if(null!=t||null!=e)return this.getAxisProxy(t,e).getDataValueWindow();var i=this.findRepresentativeAxisProxy();return i?i.getDataValueWindow():void 0},findRepresentativeAxisProxy:function(){var t=this._axisProxies;for(var e in t)if(t.hasOwnProperty(e)&&t[e].hostedBy(this))return t[e];for(var e in t)if(t.hasOwnProperty(e)&&!t[e].hostedBy(this))return t[e]}});return d}),e("echarts/component/dataZoom/DataZoomView",[Ji,"../../view/Component"],function(t){var e=t("../../view/Component");return e[Ci]({type:"dataZoom",render:function(t,e,i,n){this.dataZoomModel=t,this[ai]=e,this.api=i},getTargetInfo:function(){function t(t,e,i,n){for(var r,a=0;a=0&&f():a>=0?f():i&&(h=setTimeout(f,-a)),u=l};return p.clear=function(){h&&(clearTimeout(h),h=null)},p}var a,o,s,l=(new Date).getTime(),u=0,c=0,h=null,d=typeof t===Vi;if(e=e||0,d)return r();for(var f=[],p=0;pe[1]&&n.reverse(),0>t&&n[0]+t0&&n[1]+t>i[1]&&(t=i[1]-n[1]),t}return t?("rigid"===n?(t=a(t,e,i),e[0]+=t,e[1]+=t):(t=a(t,e[r],i),e[r]+=t,"push"===n&&e[0]>e[1]&&(e[1-r]=e[r])),e):e}}),e("echarts/component/dataZoom/SliderZoomView",[Ji,Qi,T,"../../util/throttle","./DataZoomView",k,"../../util/layout","../helper/sliderMove"],function(t){function e(t){return"x"===t?"y":"x"}var n=t(Qi),r=t(T),o=t("../../util/throttle"),l=t("./DataZoomView"),u=r.Rect,c=t(k),d=c[Ei],f=t("../../util/layout"),p=t("../helper/sliderMove"),m=c.asc,g=n.bind,y=Math.round,x=Math.max,_=n.each,b=7,w=1,M=30,S=ze,C=Pe,D=5,L=["line","bar","candlestick","scatter"],P=l[Ci]({type:"dataZoom.slider",init:function(t,e){this._displayables={},this._orient,this._range,this._handleEnds,this._size,this._halfHandleSize,this._location,this._dragging,this._dataShadowInfo,this.api=e},render:function(t,e,i,n){return P[Ti](this,Ht,arguments),o.createOrUpdate(this,"_dispatchZoomAction",this.dataZoomModel.get("throttle"),"fixRate"),this._orient=t.get("orient"),this._halfHandleSize=y(t.get("handleSize")/2),this.dataZoomModel.get("show")===!1?void this.group[qt]():(n&&n.type===j&&n.from===this.uid||this._buildView(),void this._updateView())},remove:function(){P[Ti](this,Qt,arguments),o.clear(this,"_dispatchZoomAction")},dispose:function(){P[Ti](this,K,arguments),o.clear(this,"_dispatchZoomAction")},_buildView:function(){var t=this.group;t[qt](),this._resetLocation(),this._resetInterval();var e=this._displayables.barGroup=new r.Group;this._renderBackground(),this._renderDataShadow(),this._renderHandle(),t.add(e),this._positionGroup()},_resetLocation:function(){var t=this.dataZoomModel,e=this.api,n=this._findCoordRect(),r={width:e[we](),height:e[be]()},a=this._orient===S?{left:n.x,top:r[di]-M-b,width:n.width,height:M}:{right:b,top:n.y,width:M,height:n[di]};f.mergeLayoutParam(a,t.inputPositionParams),t.setLayoutParams(a);var o=f[Le](a,r,t[i]);this._location={x:o.x,y:o.y},this._size=[o.width,o[di]],this._orient===C&&this._size.reverse()},_positionGroup:function(){var t=this.group,e=this._location,i=this._orient,n=this.dataZoomModel.getFirstTargetAxisModel(),r=n&&n.get(h),a=this._displayables.barGroup,o=(this._dataShadowInfo||{}).otherAxisInverse;a.attr(i!==S||r?i===S&&r?{scale:o?[-1,1]:[-1,-1]}:i!==C||r?{scale:o?[-1,-1]:[-1,1],rotation:Math.PI/2}:{scale:o?[1,-1]:[1,1],rotation:Math.PI/2}:{scale:o?[1,1]:[1,-1]});var s=t[ii]([a]);t[Oe][0]=e.x-s.x,t[Oe][1]=e.y-s.y},_getViewExtent:function(){var t=this._halfHandleSize,e=x(this._size[0],4*t),i=[t,e-t];return i},_renderBackground:function(){var t=this.dataZoomModel,e=this._size;this._displayables.barGroup.add(new u({silent:!0,shape:{x:0,y:0,width:e[0],height:e[1]},style:{fill:t.get(et)}}))},_renderDataShadow:function(){var t=this._dataShadowInfo=this._prepareDataShadowInfo();if(t){var e=this._size,i=t[Ce],n=i.getRawData(),a=i.getShadowDim?i.getShadowDim():t.otherDim,o=n[B](a),s=.3*(o[1]-o[0]);o=[o[0]-s,o[1]+s];var l=[0,e[1]],u=[0,e[0]],c=[[e[0],0],[0,0]],h=u[1]/(n.count()-1),f=0,p=Math.round(n.count()/e[0]);n.each([a],function(t,e){if(p>0&&e%p)return void(f+=h);var i=null==t||isNaN(t)||""===t?null:d(t,o,l,!0);null!=i&&c.push([f,i]),f+=h}),this._displayables.barGroup.add(new r[kt]({shape:{points:c},style:{fill:this.dataZoomModel.get("dataBackgroundColor"),lineWidth:0},silent:!0,z2:-20}))}},_prepareDataShadowInfo:function(){var t=this.dataZoomModel,i=t.get("showDataShadow");if(i!==!1){var r,a=this[ai];return t.eachTargetAxis(function(o,s){var l=t.getAxisProxy(o.name,s).getTargetSeriesModels();n.each(l,function(t){if(!(r||i!==!0&&n[Hi](L,t.get("type"))<0)){var l=e(o.name),u=a[ge](o.axis,s).axis;r={thisAxis:u,series:t,thisDim:o.name,otherDim:l,otherAxisInverse:t[me][v](u)[h]}}},this)},this),r}},_renderHandle:function(){var t=this._displayables,e=t.handles=[],i=t.handleLabels=[],n=this._displayables.barGroup,a=this._size;n.add(t.filler=new u({draggable:!0,cursor:"move",drift:g(this._onDragMove,this,"all"),ondragend:g(this._onDragEnd,this),onmouseover:g(this._showDataInfo,this,!0),onmouseout:g(this._showDataInfo,this,!1),style:{fill:this.dataZoomModel.get("fillerColor"),textPosition:"inside"}})),n.add(new u(r[Mt]({silent:!0,shape:{x:0,y:0,width:a[0],height:a[1]},style:{stroke:this.dataZoomModel.get("dataBackgroundColor"),lineWidth:w,fill:"rgba(0,0,0,0)"}}))),_([0,1],function(t){n.add(e[t]=new u({style:{fill:this.dataZoomModel.get("handleColor")},cursor:"move",draggable:!0,drift:g(this._onDragMove,this,t),ondragend:g(this._onDragEnd,this),onmouseover:g(this._showDataInfo,this,!0),onmouseout:g(this._showDataInfo,this,!1)}));var a=this.dataZoomModel.textStyleModel;this.group.add(i[t]=new r.Text({silent:!0,invisible:!0,style:{x:0,y:0,text:"",textBaseline:"middle",textAlign:"center",fill:a[gt](),textFont:a[ei]()}}))},this)},_resetInterval:function(){var t=this._range=this.dataZoomModel.getPercentRange(),e=this._getViewExtent();this._handleEnds=[d(t[0],[0,100],e,!0),d(t[1],[0,100],e,!0)]},_updateInterval:function(t,e){var i=this._handleEnds,n=this._getViewExtent();p(e,i,n,"all"===t||this.dataZoomModel.get("zoomLock")?"rigid":"cross",t),this._range=m([d(i[0],n,[0,100],!0),d(i[1],n,[0,100],!0)])},_updateView:function(){var t=this._displayables,e=this._handleEnds,i=m(e.slice()),n=this._size,r=this._halfHandleSize;_([0,1],function(i){var a=t.handles[i];a[Dt]({x:e[i]-r,y:-1,width:2*r,height:n[1]+2,r:1})},this),t.filler[Dt]({x:i[0],y:0,width:i[1]-i[0],height:this._size[1]}),this._updateDataInfo()},_updateDataInfo:function(){function t(t){var e=r.getTransform(i.handles[t],this.group),s=r.transformDirection(0===t?"right":"left",e),l=this._halfHandleSize+D,c=r[fi]([u[t]+(0===t?-l:l),this._size[1]/2],e);n[t][wt]({x:c[0],y:c[1],textBaseline:a===S?Ri:s,textAlign:a===S?s:Bi,text:o[t]})}var e=this.dataZoomModel,i=this._displayables,n=i.handleLabels,a=this._orient,o=["",""];if(e.get("showDetail")){var s,l;e.eachTargetAxis(function(t,i){s||(s=e.getAxisProxy(t.name,i).getDataValueWindow(),l=this[ai][ge](t.axis,i).axis)},this),s&&(o=[this._formatLabel(s[0],l),this._formatLabel(s[1],l)])}var u=m(this._handleEnds.slice());t.call(this,0),t.call(this,1)},_formatLabel:function(t,e){var i=this.dataZoomModel,r=i.get("labelFormatter");if(n.isFunction(r))return r(t);var a=i.get("labelPrecision");return(null==a||"auto"===a)&&(a=e[zi]()),t=null==t&&isNaN(t)?"":e.type===A||"time"===e.type?e.scale[s](Math.round(t)):t[Ii](Math.min(a,20)),n[ke](r)&&(t=r[Ni]("{value}",t)),t},_showDataInfo:function(t){t=this._dragging||t;var e=this._displayables.handleLabels;e[0].attr(Ut,!t),e[1].attr(Ut,!t)},_onDragMove:function(t,e,i){this._dragging=!0;var n=this._applyBarTransform([e,i],!0);this._updateInterval(t,n[0]),this._updateView(),this.dataZoomModel.get("realtime")&&this._dispatchZoomAction()},_onDragEnd:function(){this._dragging=!1,this._showDataInfo(!1),this._dispatchZoomAction()},_dispatchZoomAction:function(){var t=this._range;this.api[_e]({type:"dataZoom",from:this.uid,dataZoomId:this.dataZoomModel.id,start:t[0],end:t[1]})},_applyBarTransform:function(t,e){var i=this._displayables.barGroup[ue]();return r[fi](t,i,e)},_findCoordRect:function(){var t,e=this.getTargetInfo();if(e.cartesians[Xi])t=e.cartesians[0].model[me][a]();else{var i=this.api[we](),n=this.api[be]();t={x:.2*i,y:.2*n,width:.6*i,height:.6*n}}return t}});return P}),e("echarts/component/dataZoom/InsideZoomModel",[Ji,"./DataZoomModel"],function(t){return t("./DataZoomModel")[Ci]({type:"dataZoom.inside",defaultOption:{zoomLock:!1}})}),e("echarts/component/helper/interactionMutex",[Ji],function(t){function e(t){return t[i]||(t[i]={})}var i="\x00_ec_interaction_mutex",n={take:function(t,i){e(i)[t]=!0},release:function(t,i){e(i)[t]=!1},isTaken:function(t,i){return!!e(i)[t]}};return n}),e("echarts/component/helper/RoamController",[Ji,fe,Qi,ft,"./interactionMutex"],function(t){function e(t){if(!t[oe]||!t[oe][ee]){var e=t[ht],i=t[ct],n=this.rect;n&&n[Rt](e,i)&&(this._x=e,this._y=i,this._dragging=!0)}}function i(t){if(this._dragging&&(c.stop(t.event),"pinch"!==t.gestureEvent)){if(h.isTaken("globalPan",this._zr))return;var e=t[ht],i=t[ct],n=e-this._x,r=i-this._y;this._x=e,this._y=i;var a=this[oe];if(a){var o=a[Oe];o[0]+=n,o[1]+=r,a.dirty()}c.stop(t.event),this[Wt]("pan",n,r)}}function n(t){this._dragging=!1}function r(t){c.stop(t.event);var e=t.wheelDelta>0?1.1:1/1.1;o.call(this,t,e,t[ht],t[ct])}function a(t){if(!h.isTaken("globalPan",this._zr)){c.stop(t.event);var e=t.pinchScale>1?1.1:1/1.1;o.call(this,t,e,t.pinchX,t.pinchY)}}function o(t,e,i,n){var r=this.rect;if(r&&r[Rt](i,n)){var a=this[oe];if(a){var o=a[Oe],s=a.scale,l=this._zoom=this._zoom||1;l*=e;var u=l/this._zoom;this._zoom=l,o[0]-=(i-o[0])*(u-1),o[1]-=(n-o[1])*(u-1),s[0]*=u,s[1]*=u,a.dirty()}this[Wt]("zoom",e,i,n)}}function s(t,o,s){this[oe]=o,this.rect=s,this._zr=t;var c=u.bind,h=c(e,this),d=c(i,this),f=c(n,this),p=c(r,this),m=c(a,this);l.call(this),this.enable=function(e){this.disable(),null==e&&(e=!0),(e===!0||"move"===e||"pan"===e)&&(t.on("mousedown",h),t.on(dt,d),t.on("mouseup",f)),(e===!0||"scale"===e||"zoom"===e)&&(t.on("mousewheel",p),t.on("pinch",m))},this.disable=function(){t.off("mousedown",h),t.off(dt,d),t.off("mouseup",f),t.off("mousewheel",p),t.off("pinch",m)},this[K]=this.disable,this.isDragging=function(){return this._dragging},this.isPinching=function(){return this._pinching}}var l=t(fe),u=t(Qi),c=t(ft),h=t("./interactionMutex");return u.mixin(s,l),s}),e("echarts/component/dataZoom/roams",[Ji,Qi,"../../component/helper/RoamController","../../util/throttle"],function(t){ -function e(t){var e=t.getZr();return e[f]||(e[f]={})}function i(t,e,i){var n=new c(t.getZr());return n.enable(),n.on("pan",d(r,i)),n.on("zoom",d(o,i)),n.rect=e[me][a]().clone(),n}function n(t){u.each(t,function(e,i){e.count||(e.controller.off("pan").off("zoom"),delete t[i])})}function r(t,e,i){s(t,function(n){return n.panGetRange(t.controller,e,i)})}function o(t,e,i,n){s(t,function(r){return r.zoomGetRange(t.controller,e,i,n)})}function s(t,e){var i=[];u.each(t.dataZoomInfos,function(t){var n=e(t);n&&i.push({dataZoomId:t.dataZoomId,start:n[0],end:n[1]})}),t[_e](i)}function l(t,e){t[_e]({type:"dataZoom",batch:e})}var u=t(Qi),c=t("../../component/helper/RoamController"),h=t("../../util/throttle"),d=u.curry,f="\x00_ec_dataZoom_roams",p={register:function(t,r){var a=e(t),o=r.dataZoomId,s=r.coordType+"\x00_"+r.coordId;u.each(a,function(t,e){var i=t.dataZoomInfos;i[o]&&e!==s&&(delete i[o],t.count--)}),n(a);var c=a[s];c||(c=a[s]={coordId:s,dataZoomInfos:{},count:0},c.controller=i(t,r,c),c[_e]=u.curry(l,t)),c&&(h.createOrUpdate(c,_e,r.throttleRate,"fixRate"),!c.dataZoomInfos[o]&&c.count++,c.dataZoomInfos[o]=r)},unregister:function(t,i){var r=e(t);u.each(r,function(t,e){var n=t.dataZoomInfos;n[i]&&(delete n[i],t.count--)}),n(r)},shouldRecordRange:function(t,e){if(t&&t.type===j&&t.batch)for(var i=0,n=t.batch[Xi];n>i;i++)if(t.batch[i].dataZoomId===e)return!1;return!0}};return p}),e("echarts/component/dataZoom/InsideZoomView",[Ji,"./DataZoomView",Qi,"../helper/sliderMove","./roams"],function(t){function e(t,e,i,r){e=e.slice();var a=r.axisModels[0];if(a){var o=n(t,a,i),l=o.signal*(e[1]-e[0])*o.pixel/o.pixelLength;return s(l,e,[0,100],"rigid"),e}}function i(t,e,i,a,o,s){i=i.slice();var l=o.axisModels[0];if(l){var u=n(e,l,a),c=u.pixel-u.pixelStart,h=c/u.pixelLength*(i[1]-i[0])+i[0];return t=Math.max(t,0),i[0]=(i[0]-h)*t+h,i[1]=(i[1]-h)*t+h,r(i)}}function n(t,e,i){var n=e.axis,r=i.rect,a={};return"x"===n.dim?(a.pixel=t[0],a.pixelLength=r.width,a.pixelStart=r.x,a.signal=n[h]?1:-1):(a.pixel=t[1],a.pixelLength=r[di],a.pixelStart=r.y,a.signal=n[h]?-1:1),a}function r(t){var e=[0,100];return!(t[0]<=e[1])&&(t[0]=e[1]),!(t[1]<=e[1])&&(t[1]=e[1]),!(t[0]>=e[0])&&(t[0]=e[0]),!(t[1]>=e[0])&&(t[1]=e[0]),t}var a=t("./DataZoomView"),o=t(Qi),s=t("../helper/sliderMove"),l=t("./roams"),u=o.bind,c=a[Ci]({type:"dataZoom.inside",init:function(t,e){this._range},render:function(t,e,i,n){c[Ti](this,Ht,arguments),l.shouldRecordRange(n,t.id)&&(this._range=t.getPercentRange()),o.each(this.getTargetInfo().cartesians,function(e){var n=e.model;l[ye](i,{coordId:n.id,coordType:n.type,coordinateSystem:n[me],dataZoomId:t.id,throttleRage:t.get("throttle",!0),panGetRange:u(this._onPan,this,e),zoomGetRange:u(this._onZoom,this,e)})},this)},remove:function(){l.unregister(this.api,this.dataZoomModel.id),c[Ti](this,Qt,arguments),this._range=null},dispose:function(){l.unregister(this.api,this.dataZoomModel.id),c[Ti](this,K,arguments),this._range=null},_onPan:function(t,i,n,r){return this._range=e([n,r],this._range,i,t)},_onZoom:function(t,e,n,r,a){var o=this.dataZoomModel;if(!o[Je].zoomLock)return this._range=i(1/n,[r,a],this._range,e,t,o)}});return c}),e("echarts/component/dataZoom/dataZoomProcessor",[Ji,n],function(t){function e(t,e,i){i.getAxisProxy(t.name,e).reset(i)}function i(t,e,i){i.getAxisProxy(t.name,e).filterData(i)}var r=t(n);r[W]($i,function(t,n){t[q](j,function(t){t.eachTargetAxis(e),t.eachTargetAxis(i)}),t[q](j,function(t){var e=t.findRepresentativeAxisProxy(),i=e.getDataPercentWindow(),n=e.getDataValueWindow();t.setRawRange({start:i[0],end:i[1],startValue:n[0],endValue:n[1]})})})}),e("echarts/component/dataZoom/dataZoomAction",[Ji,Qi,D,n],function(t){var e=t(Qi),i=t(D),r=t(n);r[F](j,function(t,n){var r=i.createLinkedNodesFinder(e.bind(n[q],n,j),i.eachAxisDim,function(t,e){return t.get(e[Qe])}),a=[];n[q]({mainType:"dataZoom",query:t},function(t,e){a.push.apply(a,r(t).nodes)}),e.each(a,function(e,i){e.setRawRange({start:t.start,end:t.end,startValue:t.startValue,endValue:t.endValue})})})}),e("echarts/component/dataZoom",[Ji,"./dataZoom/typeDefaulter","./dataZoom/DataZoomModel","./dataZoom/DataZoomView","./dataZoom/SliderZoomModel","./dataZoom/SliderZoomView","./dataZoom/InsideZoomModel","./dataZoom/InsideZoomView","./dataZoom/dataZoomProcessor","./dataZoom/dataZoomAction"],function(t){t("./dataZoom/typeDefaulter"),t("./dataZoom/DataZoomModel"),t("./dataZoom/DataZoomView"),t("./dataZoom/SliderZoomModel"),t("./dataZoom/SliderZoomView"),t("./dataZoom/InsideZoomModel"),t("./dataZoom/InsideZoomView"),t("./dataZoom/dataZoomProcessor"),t("./dataZoom/dataZoomAction")}),e("echarts/component/toolbox/featureManager",[Ji],function(t){var e={};return{register:function(t,i){e[t]=i},get:function(t){return e[t]}}}),e("echarts/component/toolbox/ToolboxModel",[Ji,"./featureManager",Qi,n],function(t){var e=t("./featureManager"),i=t(Qi),r=t(n)[N]({type:"toolbox",layoutMode:{type:"box",ignoreSize:!0},mergeDefaultAndTheme:function(t){r[Ti](this,De,arguments),i.each(this[Je].feature,function(t,n){var r=e.get(n);r&&i.merge(t,r.defaultOption)})},defaultOption:{show:!0,z:6,zlevel:0,orient:"horizontal",left:"right",top:"top",backgroundColor:"transparent",borderColor:"#ccc",borderWidth:0,padding:5,itemSize:15,itemGap:8,showTitle:!0,iconStyle:{normal:{borderColor:"#666",color:"none"},emphasis:{borderColor:"#3E98C5"}}}});return r}),e("echarts/component/toolbox/ToolboxView",[Ji,"./featureManager",Qi,T,"../../model/Model","../../data/DataDiffer","../helper/listComponent",ci,n],function(t){function e(t){return 0===t[Hi]("my")}var i=t("./featureManager"),r=t(Qi),a=t(T),o=t("../../model/Model"),s=t("../../data/DataDiffer"),l=t("../helper/listComponent"),u=t(ci);return t(n)[E]({type:"toolbox",render:function(t,n,c){function h(r,a){var s,l=y[r],u=y[a],h=m[l],f=new o(h,t,t[ai]);if(l&&!u){if(e(l))s={model:f,onclick:f[Je].onclick,featureName:l};else{var p=i.get(l);if(!p)return;s=new p(f)}v[l]=s}else{if(s=v[u],!s)return;s.model=f}return!l&&u?void(s[K]&&s[K](n,c)):!f.get("show")||s.unusable?void(s[Qt]&&s[Qt](n,c)):(d(f,s,l),f.setIconStatus=function(t,e){var i=this[Je],n=this.iconPaths;i.iconStatus=i.iconStatus||{},i.iconStatus[t]=e,n[t]&&n[t][Wt](e)},void(s[Ht]&&s[Ht](f,n,c)))}function d(e,i,o){var s=e[ri]("iconStyle"),l=i.getIcons?i.getIcons():e.get("icon"),u=e.get("title")||{};if(typeof l===Wi){var h=l,d=u;l={},u={},l[o]=h,u[o]=d}var m=e.iconPaths={};r.each(l,function(o,l){var h=s[ri](Ue)[x](),d=s[ri](Xe)[x](),v={x:-p/2,y:-p/2,width:p,height:p},g=0===o[Hi]("image://")?(v.image=o.slice(8),new a.Image({style:v})):a.makePath(o[Ni]("path://",""),{style:h,hoverStyle:d,rectHover:!0},v,Bi);a[_t](g),t.get("showTitle")&&(g.__title=u[l],g.on(xt,function(){g[wt]({text:u[l],textPosition:d[Et]||Oi,textFill:d.fill||d[_i]||"#000",textAlign:d[Zt]||Bi})}).on(yt,function(){g[wt]({textFill:null})})),g[Wt](e.get("iconStatus."+l)||Ue),f.add(g),g.on("click",r.bind(i.onclick,i,n,c,l)),m[l]=g})}var f=this.group;if(f[qt](),t.get("show")){var p=+t.get("itemSize"),m=t.get("feature")||{},v=this._features||(this._features={}),y=[];r.each(m,function(t,e){y.push(e)}),new s(this._featureNames||[],y).add(h)[xe](h)[Qt](r.curry(h,null))[g](),this._featureNames=y,l.layout(f,t,c),l.addBackground(f,t),f[Re](function(t){var e=t.__title,i=t[bt];if(i&&e){var n=u[ii](e,i.font),r=t[Oe][0]+f[Oe][0],a=t[Oe][1]+f[Oe][1]+p,o=!1;a+n[di]>c[be]()&&(i[Et]="top",o=!0);var s=o?-5-n[di]:p+8;r+n.width/2>c[we]()?(i[Et]=["100%",s],i[Zt]="right"):r-n.width/2<0&&(i[Et]=[0,s],i[Zt]="left")}})}},remove:function(t,e){r.each(this._features,function(i){i[Qt]&&i[Qt](t,e)}),this.group[qt]()},dispose:function(t,e){r.each(this._features,function(i){i[K]&&i[K](t,e)})}})}),e("echarts/component/toolbox/feature/SaveAsImage",[Ji,pt,"../featureManager"],function(t){function e(t){this.model=t}var i=t(pt);e.defaultOption={show:!0,icon:"M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0",title:"保存为图片",type:"png",name:"",excludeComponents:["toolbox"],pixelRatio:1,lang:["右键另存为图片"]},e[Ki].unusable=!i[J];var n=e[Ki];return n.onclick=function(t,e){var i=this.model,n=i.get("name")||t.get("title.0.text")||"echarts",r=document[Ui]("a"),a=i.get("type",!0)||"png";r.download=n+"."+a,r[oe]="_blank";var o=e.getConnectedDataURL({type:a,backgroundColor:i.get(et,!0)||t.get(et)||"#fff",excludeComponents:i.get("excludeComponents"),pixelRatio:i.get("pixelRatio")});if(r.href=o,typeof MouseEvent===Vi){var s=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});r.dispatchEvent(s)}else{var l=i.get("lang"),u='',c=window.open();c.document.write(u)}},t("../featureManager")[ye]("saveAsImage",e),e}),e("echarts/component/toolbox/feature/MagicType",[Ji,Qi,"../../../echarts","../featureManager"],function(t){function e(t){this.model=t}var i=t(Qi);e.defaultOption={show:!0,type:[],icon:{line:"M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4",bar:"M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7",stack:"M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z",tiled:"M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z"},title:{line:"切换为折线图",bar:"切换为柱状图",stack:"切换为堆叠",tiled:"切换为平铺"},option:{},seriesIndex:{}};var n=e[Ki];n.getIcons=function(){var t=this.model,e=t.get("icon"),n={};return i.each(t.get("type"),function(t){e[t]&&(n[t]=e[t])}),n};var r={line:function(t,e,n,r){return"bar"===t?i.merge({id:e,type:"line",data:n.get("data"),stack:n.get("stack"),markPoint:n.get("markPoint"),markLine:n.get("markLine")},r.get("option.line")):void 0},bar:function(t,e,n,r){return"line"===t?i.merge({id:e,type:"bar",data:n.get("data"),stack:n.get("stack"),markPoint:n.get("markPoint"),markLine:n.get("markLine")},r.get("option.bar")):void 0},stack:function(t,e,i,n){return"line"===t||"bar"===t?{id:e,stack:"__ec_magicType_stack__"}:void 0},tiled:function(t,e,i,n){return"line"===t||"bar"===t?{id:e,stack:""}:void 0}},a=[["line","bar"],["stack","tiled"]];n.onclick=function(t,e,n){var o=this.model,s=o.get("seriesIndex."+n);if(r[n]){var l={series:[]},u=function(t){var e=t.subType,a=t.id,s=r[n](e,a,t,o);s&&(i[oi](s,t[Je]),l[Ce].push(s))};i.each(a,function(t){i[Hi](t,n)>=0&&i.each(t,function(t){o.setIconStatus(t,Ue)})}),o.setIconStatus(n,Xe),t[q]({mainType:"series",seriesIndex:s},u),e[_e]({type:"changeMagicType",currentType:n,newOption:l})}};var o=t("../../../echarts");return o[F]({type:"changeMagicType",event:"magicTypeChanged",update:"prepareAndUpdate"},function(t,e){e[Ae](t.newOption)}),t("../featureManager")[ye]("magicType",e),e}),e("echarts/component/toolbox/feature/DataView",[Ji,Qi,ft,"../featureManager","../../../echarts"],function(t){function e(t){var e={},i=[],n=[];return t.eachRawSeries(function(t){var r=t[me];if(!r||r.type!==u&&"polar"!==r.type)i.push(t);else{var a=r[pe]();if(a.type===A){var o=a.dim+"_"+a.index;e[o]||(e[o]={categoryAxis:a,valueAxis:r[v](a),series:[]},n.push({axisDim:a.dim,axisIndex:a.index})),e[o][Ce].push(t)}else i.push(t)}}),{seriesGroupByCategoryAxis:e,other:i,meta:n}}function i(t){var e=[];return f.each(t,function(t,i){var n=t.categoryAxis,r=t.valueAxis,a=r.dim,o=[" "][Gi](f.map(t[Ce],function(t){return t.name})),s=[n.model.getCategories()];f.each(t[Ce],function(t){s.push(t.getRawData()[R](a,function(t){return t}))});for(var l=[o.join(g)],u=0;uo;o++)n[o]=arguments[o];i.push((a?a+g:"")+n.join(g))}),i.join("\n")}).join("\n\n"+m+"\n\n")}function r(t){var r=e(t);return{value:f[$i]([i(r.seriesGroupByCategoryAxis),n(r.other)],function(t){return t[Ni](/[\n\t\s]/g,"")}).join("\n\n"+m+"\n\n"),meta:r.meta}}function a(t){return t[Ni](/^\s\s*/,"")[Ni](/\s\s*$/,"")}function o(t){var e=t.slice(0,t[Hi]("\n"));return e[Hi](g)>=0?!0:void 0}function s(t){for(var e=t.split(/\n+/g),i=a(e.shift()).split(y),n=[],r=f.map(i,function(t){return{name:t,data:[]}}),o=0;oS}function c(t){var e=C[this.type];t&&t[Xi]?(this._cover||(this._cover=e[hi].call(this),this.group.add(this._cover)),e[xe].call(this,t)):(this.group[Qt](this._cover),this._cover=null),i(this.group)}function h(){var t=this.group,e=t[ce];e&&e[Qt](t)}function d(){var t=this.opt;return new g.Rect({style:{stroke:t[_i],fill:t.fill,lineWidth:t[bi],opacity:t[xi]}})}function f(){return v.map(this._track,function(t){return this.group[se](t[0],t[1])},this)}function p(){var t=f.call(this),e=t[Xi]-1;return 0>e&&(e=0),[t[0],t[e]]}var m=t(fe),v=t(Qi),g=t(T),y=v.bind,x=v.each,_=Math.min,b=Math.max,w=Math.pow,M=1e4,S=2,k=["mousedown",dt,"mouseup"];e[Ki]={constructor:e,enable:function(t,e){this._disabled=!1,h.call(this),this._containerRect=e!==!1?e||t[ii]():null,t.add(this.group)},update:function(t){c.call(this,t&&v.clone(t))},disable:function(){this._disabled=!0,h.call(this)},dispose:function(){this.disable(),x(k,function(t){this.zr.off(t,this._handlers[t])},this)}},v.mixin(e,m);var C={line:{create:d,getRanges:function(){var t=p.call(this),e=_(t[0][0],t[1][0]),i=b(t[0][0],t[1][0]);return[[e,i]]},update:function(t){var e=t[0],i=this.opt.width;this._cover[Dt]({x:e[0],y:-i/2,width:e[1]-e[0],height:i})}},rect:{create:d,getRanges:function(){var t=p.call(this),e=[_(t[1][0],t[0][0]),_(t[1][1],t[0][1])],i=[b(t[1][0],t[0][0]),b(t[1][1],t[0][1])];return[[[e[0],i[0]],[e[1],i[1]]]]},update:function(t){var e=t[0];this._cover[Dt]({x:e[0][0],y:e[1][0],width:e[0][1]-e[0][0],height:e[1][1]-e[1][0]})}}};return e}),e("echarts/component/dataZoom/history",[Ji,Qi],function(t){function e(t){var e=t[r];return e||(e=t[r]=[{}]),e}var i=t(Qi),n=i.each,r="\x00_ec_hist_store",a={push:function(t,i){var r=e(t);n(i,function(e,i){for(var n=r[Xi]-1;n>=0;n--){var a=r[n];if(a[i])break}if(0>n){var o=t.queryComponents({mainType:"dataZoom",subType:"select",id:i})[0];if(o){var s=o.getPercentRange();r[0][i]={dataZoomId:i,start:s[0],end:s[1]}}}}),r.push(i)},pop:function(t){var i=e(t),r=i[i[Xi]-1];i[Xi]>1&&i.pop();var a={};return n(r,function(t,e){for(var n=i[Xi]-1;n>=0;n--){var t=i[n][e];if(t){a[e]=t;break}}}),a},clear:function(t){t[r]=null},count:function(t){return e(t)[Xi]}};return a}),e("echarts/component/dataZoom/SelectZoomModel",[Ji,"./DataZoomModel"],function(t){var e=t("./DataZoomModel");return e[Ci]({type:"dataZoom.select"})}),e("echarts/component/dataZoom/SelectZoomView",[Ji,"./DataZoomView"],function(t){return t("./DataZoomView")[Ci]({type:"dataZoom.select"})}),e("echarts/component/dataZoomSelect",[Ji,"./dataZoom/typeDefaulter","./dataZoom/DataZoomModel","./dataZoom/DataZoomView","./dataZoom/SelectZoomModel","./dataZoom/SelectZoomView","./dataZoom/dataZoomProcessor","./dataZoom/dataZoomAction"],function(t){t("./dataZoom/typeDefaulter"),t("./dataZoom/DataZoomModel"),t("./dataZoom/DataZoomView"),t("./dataZoom/SelectZoomModel"),t("./dataZoom/SelectZoomView"),t("./dataZoom/dataZoomProcessor"),t("./dataZoom/dataZoomAction")}),e("echarts/component/toolbox/feature/DataZoom",[Ji,Qi,"../../../util/number","../../helper/SelectController",pi,"zrender/container/Group","../../dataZoom/history","../../helper/interactionMutex","../../dataZoomSelect","../featureManager","../../../echarts"],function(t){function e(t){this.model=t,this._controllerGroup,this._controller,this._isZoomActive}function i(t,e){var i=[{axisModel:t[f]("x").model,axisIndex:0},{axisModel:t[f]("y").model,axisIndex:0}];return i.grid=t,e[q]({mainType:"dataZoom",subType:"select"},function(t,r){n("xAxis",i[0].axisModel,t,e)&&(i[0].dataZoomModel=t),n("yAxis",i[1].axisModel,t,e)&&(i[1].dataZoomModel=t)}),i}function n(t,e,i,n){var r=i.get(t+"Index");return null!=r&&n[ge](t,r)===e}function r(t,e){var i=e.grid,n=new h(t[0][0],t[1][0],t[0][1]-t[0][0],t[1][1]-t[1][0]);if(n[rt](i[a]())){var r=i.getCartesian(e[0][Qe],e[1][Qe]),o=r.pointToData([t[0][0],t[1][0]],!0),s=r.pointToData([t[0][1],t[1][1]],!0);return[g([o[0],s[0]]),g([o[1],s[1]])]}}function o(t,e,i,n){var r=e[i],a=r.dataZoomModel;return a?{dataZoomId:a.id,startValue:t[i][0],endValue:t[i][1]}:void 0}function s(t,e){t.setIconStatus("back",p.count(e)>1?Xe:Ue)}var l=t(Qi),u=t("../../../util/number"),c=t("../../helper/SelectController"),h=t(pi),d=t("zrender/container/Group"),p=t("../../dataZoom/history"),m=t("../../helper/interactionMutex"),v=l.each,g=u.asc;t("../../dataZoomSelect");var y="\x00_ec_\x00toolbox-dataZoom_";e.defaultOption={show:!0,icon:{zoom:"M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1",back:"M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26"},title:{zoom:"区域缩放",back:"区域缩放还原"}};var x=e[Ki];x[Ht]=function(t,e,i){s(t,e)},x.onclick=function(t,e,i){var n=this._controllerGroup;this._controllerGroup||(n=this._controllerGroup=new d,e.getZr().add(n)),_[i].call(this,n,this.model,t,e)},x[Qt]=function(t,e){this._disposeController(),m.release("globalPan",e.getZr())},x[K]=function(t,e){var i=e.getZr();m.release("globalPan",i),this._disposeController(),this._controllerGroup&&i[Qt](this._controllerGroup)};var _={zoom:function(t,e,i,n){var r=this._isZoomActive=!this._isZoomActive,a=n.getZr();m[r?"take":"release"]("globalPan",a),e.setIconStatus("zoom",r?Xe:Ue),r?(a.setDefaultCursorStyle("crosshair"),this._createController(t,e,i,n)):(a.setDefaultCursorStyle("default"),this._disposeController())},back:function(t,e,i,n){this._dispatchAction(p.pop(i),n)}};return x._createController=function(t,e,i,n){var r=this._controller=new c("rect",n.getZr(),{lineWidth:3,stroke:"#333",fill:"rgba(0,0,0,0.2)"});r.on("selectEnd",l.bind(this._onSelected,this,r,e,i,n)),r.enable(t,!1)},x._disposeController=function(){var t=this._controller;t&&(t.off("selected"),t[K]())},x._onSelected=function(t,e,n,a,s){if(s[Xi]){var l=s[0];t[xe]();var u={};n[q]("grid",function(t,e){var a=t[me],s=i(a,n),c=r(l,s);if(c){var h=o(c,s,0,"x"),d=o(c,s,1,"y");h&&(u[h.dataZoomId]=h),d&&(u[d.dataZoomId]=d)}},this),p.push(n,u),this._dispatchAction(u,a)}},x._dispatchAction=function(t,e){var i=[];v(t,function(t){i.push(t)}),i[Xi]&&e[_e]({type:"dataZoom",from:this.uid,batch:l.clone(i,!0)})},t("../featureManager")[ye](j,e),t("../../../echarts").registerPreprocessor(function(t){function e(t,e){if(e){var r=t+"Index",a=e[r];null==a||l[Di](a)||(a=a===!1?[]:[a]),i(t,function(e,i){if(null==a||-1!==l[Hi](a,i)){var o={type:"select",$fromToolbox:!0,id:y+t+i};o[r]=i,n.push(o)}})}}function i(e,i){var n=t[e];l[Di](n)||(n=n?[n]:[]),v(n,i)}if(t){var n=t[j]||(t[j]=[]);l[Di](n)||(n=[n]);var r=t.toolbox;if(r&&(l[Di](r)&&(r=r[0]),r&&r.feature)){var a=r.feature[j];e("xAxis",a),e("yAxis",a)}}}),e}),e("echarts/component/toolbox/feature/Restore",[Ji,"../../dataZoom/history","../featureManager","../../../echarts"],function(t){function e(t){this.model=t}var i=t("../../dataZoom/history");e.defaultOption={show:!0,icon:"M3.8,33.4 M47,18.9h9.8V8.7 M56.3,20.1 C52.1,9,40.5,0.6,26.8,2.1C12.6,3.7,1.6,16.2,2.1,30.6 M13,41.1H3.1v10.2 M3.7,39.9c4.2,11.1,15.8,19.5,29.5,18 c14.2-1.6,25.2-14.1,24.7-28.5",title:"还原"};var n=e[Ki];return n.onclick=function(t,e,n){i.clear(t),e[_e]({type:"restore",from:this.uid})},t("../featureManager")[ye](Lt,e),t("../../../echarts")[F]({type:"restore",event:"restore",update:"prepareAndUpdate"},function(t,e){e.resetOption("recreate")}),e}),e("echarts/component/toolbox",[Ji,"./toolbox/ToolboxModel","./toolbox/ToolboxView","./toolbox/feature/SaveAsImage","./toolbox/feature/MagicType","./toolbox/feature/DataView","./toolbox/feature/DataZoom","./toolbox/feature/Restore"],function(t){t("./toolbox/ToolboxModel"),t("./toolbox/ToolboxView"),t("./toolbox/feature/SaveAsImage"),t("./toolbox/feature/MagicType"),t("./toolbox/feature/DataView"),t("./toolbox/feature/DataZoom"),t("./toolbox/feature/Restore")}),e("zrender/vml/core",[Ji,"exports","module","../core/env"],function(t,e,i){if(!t("../core/env")[J]){var n,r="urn:schemas-microsoft-com:vml",a=window,o=a.document,s=!1;try{!o.namespaces.zrvml&&o.namespaces.add("zrvml",r),n=function(t){return o[Ui]("')}}catch(l){n=function(t){return o[Ui]("<"+t+' xmlns="'+r+'" class="zrvml">')}}var u=function(){if(!s){s=!0;var t=o.styleSheets;t[Xi]<31?o.createStyleSheet().addRule(".zrvml","behavior:url(#default#VML)"):t[0].addRule(".zrvml","behavior:url(#default#VML)")}};i.exports={doc:o,initVML:u,createNode:n}}}),e("zrender/vml/graphic",[Ji,"../core/env","../core/vector",li,"../core/PathProxy","../tool/color","../contain/text","../graphic/mixin/RectText","../graphic/Displayable","../graphic/Image","../graphic/Text","../graphic/Path","../graphic/Gradient","./core"],function(t){if(!t("../core/env")[J]){var e=t("../core/vector"),n=t(li),r=t("../core/PathProxy").CMD,a=t("../tool/color"),o=t("../contain/text"),s=t("../graphic/mixin/RectText"),l=t("../graphic/Displayable"),u=t("../graphic/Image"),c=t("../graphic/Text"),h=t("../graphic/Path"),d=t("../graphic/Gradient"),f=t("./core"),p=Math.round,m=Math.sqrt,v=Math.abs,g=Math.cos,y=Math.sin,x=Math.max,_=e[fi],b=",",w="progid:DXImageTransform.Microsoft",M=21600,S=M/2,k=1e5,T=1e3,C=function(t){t.style.cssText="position:absolute;left:0;top:0;width:1px;height:1px;",t.coordsize=M+","+M,t.coordorigin="0,0"},A=function(t){return String(t)[Ni](/&/g,"&")[Ni](/"/g,""")},D=function(t,e,i){return"rgb("+[t,e,i].join(",")+")"},L=function(t,e){e&&t&&e[ut]!==t&&t[it](e)},P=function(t,e){e&&t&&e[ut]===t&&t.removeChild(e)},z=function(t,e,i){return(parseFloat(t)||0)*k+(parseFloat(e)||0)*T+i},I=function(t,e){return typeof t===Wi?t.lastIndexOf("%")>=0?parseFloat(t)/100*e:parseFloat(t):t},O=function(t,e,i){var n=a.parse(e);i=+i,isNaN(i)&&(i=1),n&&(t.color=D(n[0],n[1],n[2]),t[xi]=i*n[3])},R=function(t){var e=a.parse(t);return[D(e[0],e[1],e[2]),e[3]]},B=function(t,e,i){var n=e.fill;if(null!=n)if(n instanceof d){var r,a=0,o=[0,0],s=0,l=1,u=i[ii](),c=u.width,h=u[di];if("linear"===n.type){r="gradient";var f=i[he],p=[n.x*c,n.y*h],m=[n.x2*c,n.y2*h];f&&(_(p,p,f),_(m,m,f));var v=m[0]-p[0],g=m[1]-p[1];a=180*Math.atan2(v,g)/Math.PI,0>a&&(a+=360),1e-6>a&&(a=0)}else{r="gradientradial";var p=[n.x*c,n.y*h],f=i[he],y=i.scale,b=c,w=h;o=[(p[0]-u.x)/b,(p[1]-u.y)/w],f&&_(p,p,f),b/=y[0]*M,w/=y[1]*M;var S=x(b,w);s=0/S,l=2*n.r/S-s}var k=n.colorStops.slice();k.sort(function(t,e){return t.offset-e.offset});for(var T=k[Xi],C=[],A=[],D=0;T>D;D++){var L=k[D],P=R(L.color);A.push(L.offset*l+s+" "+P[0]),(0===D||D===T-1)&&C.push(P)}if(T>=2){var z=C[0][0],I=C[1][0],B=C[0][1]*e[xi],Z=C[1][1]*e[xi];t.type=r,t.method="none",t.focus="100%",t.angle=a,t.color=z,t.color2=I,t.colors=A.join(","),t[xi]=Z,t.opacity2=B}"radial"===r&&(t.focusposition=o.join(","))}else O(t,n,e[xi])},Z=function(t,e){null!=e.lineJoin&&(t.joinstyle=e.lineJoin),null!=e.miterLimit&&(t.miterlimit=e.miterLimit*M),null!=e.lineCap&&(t.endcap=e.lineCap),null!=e.lineDash&&(t.dashstyle=e.lineDash.join(" ")),null==e[_i]||e[_i]instanceof d||O(t,e[_i],e[xi])},E=function(t,e,i,n){var r="fill"==e,a=t.getElementsByTagName(e)[0];null!=i[e]&&"none"!==i[e]&&(r||!r&&i[bi])?(t[r?"filled":"stroked"]="true",i[e]instanceof d&&P(t,a),a||(a=f.createNode(e)),r?B(a,i,n):Z(a,i),L(t,a)):(t[r?"filled":"stroked"]="false",P(t,a))},N=[[],[],[]],V=function(t,e){var i,n,a,o,s,l,u=r.M,c=r.C,h=r.L,d=r.A,f=r.Q,v=[];for(o=0;o0){v.push(n);for(var U=0;i>U;U++){var X=N[U];e&&_(X,X,e),v.push(p(X[0]*M-S),b,p(X[1]*M-S),i-1>U?b:"")}}}return v.join("")};h[Ki].brush=function(t){var e=this.style,i=this._vmlEl;i||(i=f.createNode("shape"),C(i),this._vmlEl=i),E(i,"fill",e,this),E(i,_i,e,this);var n=this[he],r=null!=n,a=i.getElementsByTagName(_i)[0];if(a){var o=e[bi];if(r&&!e.strokeNoScale){var s=n[0]*n[3]-n[1]*n[2];o*=m(v(s))}a.weight=o+"px"}var l=this.path;this.__dirtyPath&&(l[Ot](),this[Pt](l,this.shape),this.__dirtyPath=!1),i.path=V(l.data,this[he]),i.style.zIndex=z(this[ot],this.z,this.z2),L(t,i),e.text&&this.drawRectText(t,this[ii]())},h[Ki].onRemoveFromStorage=function(t){P(t,this._vmlEl),this.removeRectText(t)},h[Ki].onAddToStorage=function(t){L(t,this._vmlEl),this.appendRectText(t)};var G=function(t){return typeof t===Yi&&t.tagName&&"IMG"===t.tagName[Li]()};u[Ki].brush=function(t){var e,n,r=this.style,a=r.image;if(G(a)){var o=a.src;if(o===this._imageSrc)e=this._imageWidth,n=this._imageHeight;else{var s=a.runtimeStyle,l=s.width,u=s[di];s.width="auto",s[di]="auto",e=a.width,n=a[di],s.width=l,s[di]=u,this._imageSrc=o,this._imageWidth=e,this._imageHeight=n}a=o}else a===this._imageSrc&&(e=this._imageWidth,n=this._imageHeight);if(a){var c=r.x||0,h=r.y||0,d=r.width,v=r[di],g=r.sWidth,y=r.sHeight,M=r.sx||0,S=r.sy||0,k=g&&y,T=this._vmlEl;T||(T=f.doc[Ui]("div"),C(T),this._vmlEl=T);var A,D=T.style,P=!1,I=1,O=1;if(this[he]&&(A=this[he],I=m(A[0]*A[0]+A[1]*A[1]),O=m(A[2]*A[2]+A[3]*A[3]),P=A[1]||A[2]),P){var R=[c,h],B=[c+d,h],Z=[c,h+v],E=[c+d,h+v];_(R,R,A),_(B,B,A),_(Z,Z,A),_(E,E,A);var N=x(R[0],B[0],Z[0],E[0]),V=x(R[1],B[1],Z[1],E[1]),F=[];F.push("M11=",A[0]/I,b,"M12=",A[2]/O,b,"M21=",A[1]/I,b,"M22=",A[3]/O,b,"Dx=",p(c*I+A[4]),b,"Dy=",p(h*O+A[5])),D[i]="0 "+p(N)+"px "+p(V)+"px 0",D[$i]=w+".Matrix("+F.join("")+", SizingMethod=clip)"}else A&&(c=c*I+A[4],h=h*O+A[5]),D[$i]="",D.left=p(c)+"px",D.top=p(h)+"px";var W=this._imageEl,H=this._cropEl;W||(W=f.doc[Ui]("div"),this._imageEl=W);var q=W.style;if(k){if(e&&n)q.width=p(I*e*d/g)+"px",q[di]=p(O*n*v/y)+"px";else{var j=new Image,U=this;j.onload=function(){j.onload=null,e=j.width,n=j[di],q.width=p(I*e*d/g)+"px",q[di]=p(O*n*v/y)+"px",U._imageWidth=e,U._imageHeight=n,U._imageSrc=a},j.src=a}H||(H=f.doc[Ui]("div"),H.style.overflow="hidden",this._cropEl=H);var X=H.style;X.width=p((d+M*d/g)*I),X[di]=p((v+S*v/y)*O),X[$i]=w+".Matrix(Dx="+-M*d/g*I+",Dy="+-S*v/y*O+")",H[ut]||T[it](H),W[ut]!=H&&H[it](W)}else q.width=p(I*d)+"px",q[di]=p(O*v)+"px",T[it](W),H&&H[ut]&&(T.removeChild(H),this._cropEl=null);var Y="",$=r[xi]; -1>$&&(Y+=".Alpha(opacity="+p(100*$)+") "),Y+=w+".AlphaImageLoader(src="+a+", SizingMethod=scale)",q[$i]=Y,T.style.zIndex=z(this[ot],this.z,this.z2),L(t,T),r.text&&this.drawRectText(t,this[ii]())}},u[Ki].onRemoveFromStorage=function(t){P(t,this._vmlEl),this._vmlEl=null,this._cropEl=null,this._imageEl=null,this.removeRectText(t)},u[Ki].onAddToStorage=function(t){L(t,this._vmlEl),this.appendRectText(t)};var F,W=Ue,H={},q=0,j=100,U=document[Ui]("div"),X=function(t){var e=H[t];if(!e){q>j&&(q=0,H={});var i,n=U.style;try{n.font=t,i=n.fontFamily.split(",")[0]}catch(r){}e={style:n.fontStyle||W,variant:n.fontVariant||W,weight:n.fontWeight||W,size:0|parseFloat(n.fontSize||12),family:i||"Microsoft YaHei"},H[t]=e,q++}return e};o.measureText=function(t,e){var i=f.doc;F||(F=i[Ui]("div"),F.style.cssText="position:absolute;top:-20000px;left:0;padding:0;margin:0;border:none;white-space:pre;",f.doc.body[it](F));try{F.style.font=e}catch(n){}return F[nt]="",F[it](i.createTextNode(t)),{width:F.offsetWidth}};for(var Y=new n,$=function(t,e,i,n){var r=this.style,a=r.text;if(a){var s,l,u=r[Zt],c=X(r.textFont),h=c.style+" "+c.variant+" "+c.weight+" "+c.size+'px "'+c.family+'"',d=r[Bt];i=i||o[ii](a,h,u,d);var m=this[he];if(m&&!n&&(Y.copy(e),Y[fi](m),e=Y),n)s=e.x,l=e.y;else{var v=r[Et],g=r.textDistance;if(v instanceof Array)s=e.x+I(v[0],e.width),l=e.y+I(v[1],e[di]),u=u||"left",d=d||"top";else{var y=o.adjustTextPositionOnRect(v,e,i,g);s=y.x,l=y.y,u=u||y[Zt],d=d||y[Bt]}}var x=c.size,w=(a+"").split("\n")[Xi];switch(d){case"hanging":case"top":l+=x/1.75*w;break;case Ri:break;default:l-=x/2.25}switch(u){case"left":break;case Bi:s-=i.width/2;break;case"right":s-=i.width}var M,S,k,T=f.createNode,D=this._textVmlEl;D?(k=D.firstChild,M=k.nextSibling,S=M.nextSibling):(D=T("line"),M=T("path"),S=T("textpath"),k=T("skew"),S.style["v-text-align"]="left",C(D),M.textpathok=!0,S.on=!0,D.from="0 0",D.to="1000 0.05",L(D,k),L(D,M),L(D,S),this._textVmlEl=D);var P=[s,l],O=D.style;m&&n?(_(P,P,m),k.on=!0,k.matrix=m[0][Ii](3)+b+m[2][Ii](3)+b+m[1][Ii](3)+b+m[3][Ii](3)+",0,0",k.offset=(p(P[0])||0)+","+(p(P[1])||0),k.origin="0 0",O.left="0px",O.top="0px"):(k.on=!1,O.left=p(s)+"px",O.top=p(l)+"px"),S[Wi]=A(a);try{S.style.font=h}catch(R){}E(D,"fill",{fill:n?r.fill:r.textFill,opacity:r[xi]},this),E(D,_i,{stroke:n?r[_i]:r.textStroke,opacity:r[xi],lineDash:r.lineDash},this),D.style.zIndex=z(this[ot],this.z,this.z2),L(t,D)}},Q=function(t){P(t,this._textVmlEl),this._textVmlEl=null},K=function(t){L(t,this._textVmlEl)},tt=[s,l,u,h,c],et=0;eti;i++)e[i]=n(t[i])}else if(!A(t)&&!T(t)){e={};for(var o in t)t.hasOwnProperty(o)&&(e[o]=n(t[o]))}return e}return t}function r(t,e,i){if(!S(e)||!S(t))return i?n(e):t;for(var o in e)if(e.hasOwnProperty(o)){var a=t[o],s=e[o];!S(s)||!S(a)||b(s)||b(a)||T(s)||T(a)||A(s)||A(a)?!i&&o in t||(t[o]=n(e[o],!0)):r(a,s,i)}return t}function o(t,e){for(var i=t[0],n=1,o=t.length;o>n;n++)i=r(i,t[n],e);return i}function a(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}function s(t,e,i){for(var n in e)e.hasOwnProperty(n)&&(i?null!=e[n]:null==t[n])&&(t[n]=e[n]);return t}function l(){return document.createElement("canvas")}function h(){return D||(D=F.createCanvas().getContext("2d")),D}function c(t,e){if(t){if(t.indexOf)return t.indexOf(e);for(var i=0,n=t.length;n>i;i++)if(t[i]===e)return i}return-1}function u(t,e){function i(){}var n=t.prototype;i.prototype=e.prototype,t.prototype=new i;for(var r in n)t.prototype[r]=n[r];t.prototype.constructor=t,t.superClass=e}function d(t,e,i){t="prototype"in t?t.prototype:t,e="prototype"in e?e.prototype:e,s(t,e,i)}function f(t){return t?"string"==typeof t?!1:"number"==typeof t.length:void 0}function p(t,e,i){if(t&&e)if(t.forEach&&t.forEach===E)t.forEach(e,i);else if(t.length===+t.length)for(var n=0,r=t.length;r>n;n++)e.call(i,t[n],n,t);else for(var o in t)t.hasOwnProperty(o)&&e.call(i,t[o],o,t)}function g(t,e,i){if(t&&e){if(t.map&&t.map===N)return t.map(e,i);for(var n=[],r=0,o=t.length;o>r;r++)n.push(e.call(i,t[r],r,t));return n}}function m(t,e,i,n){if(t&&e){if(t.reduce&&t.reduce===V)return t.reduce(e,i,n);for(var r=0,o=t.length;o>r;r++)i=e.call(n,i,t[r],r,t);return i}}function v(t,e,i){if(t&&e){if(t.filter&&t.filter===R)return t.filter(e,i);for(var n=[],r=0,o=t.length;o>r;r++)e.call(i,t[r],r,t)&&n.push(t[r]);return n}}function y(t,e,i){if(t&&e)for(var n=0,r=t.length;r>n;n++)if(e.call(i,t[n],n,t))return t[n]}function x(t,e){var i=B.call(arguments,2);return function(){return t.apply(e,i.concat(B.call(arguments)))}}function _(t){var e=B.call(arguments,1);return function(){return t.apply(this,e.concat(B.call(arguments)))}}function b(t){return"[object Array]"===z.call(t)}function w(t){return"function"==typeof t}function M(t){return"[object String]"===z.call(t)}function S(t){var e=typeof t;return"function"===e||!!t&&"object"==e}function A(t){return!!P[z.call(t)]||t instanceof L}function T(t){return t&&1===t.nodeType&&"string"==typeof t.nodeName}function C(t){for(var e=0,i=arguments.length;i>e;e++)if(null!=arguments[e])return arguments[e]}function I(){return Function.call.apply(B,arguments)}function k(t,e){if(!t)throw new Error(e)}var D,L=i(16),P={"[object Function]":1,"[object RegExp]":1,"[object Date]":1,"[object Error]":1,"[object CanvasGradient]":1},z=Object.prototype.toString,O=Array.prototype,E=O.forEach,R=O.filter,B=O.slice,N=O.map,V=O.reduce,F={inherits:u,mixin:d,clone:n,merge:r,mergeAll:o,extend:a,defaults:s,getContext:h,createCanvas:l,indexOf:c,slice:I,find:y,isArrayLike:f,each:p,map:g,reduce:m,filter:v,bind:x,curry:_,isArray:b,isString:M,isObject:S,isFunction:w,isBuildInObject:A,isDom:T,retrieve:C,assert:k,noop:function(){}};t.exports=F},function(t,e,i){function n(t){return function(e,i,n){e=e&&e.toLowerCase(),k.prototype[t].call(this,e,i,n)}}function r(){k.call(this)}function o(t,e,i){i=i||{},"string"==typeof e&&(e=W[e]),e&&D(G,function(t){t(e)}),this.id,this.group,this._dom=t,this._zr=A.init(t,{renderer:i.renderer||"canvas",devicePixelRatio:i.devicePixelRatio}),this._theme=T.clone(e),this._chartsViews=[],this._chartsMap={},this._componentsViews=[],this._componentsMap={},this._api=new v(this),this._coordSysMgr=new y,k.call(this),this._messageCenter=new r,this._initEvents(),this.resize=T.bind(this.resize,this)}function a(t,e){var i=this._model;i&&i.eachComponent({mainType:"series",query:e},function(n,r){var o=this._chartsMap[n.__viewId];o&&o.__alive&&o[t](n,i,this._api,e)},this)}function s(t,e,i){var n=this._api;D(this._componentsViews,function(r){var o=r.__model;r[t](o,e,n,i),p(o,r)},this),e.eachSeries(function(r,o){var a=this._chartsMap[r.__viewId];a[t](r,e,n,i),p(r,a)},this)}function l(t,e){for(var i="component"===t,n=i?this._componentsViews:this._chartsViews,r=i?this._componentsMap:this._chartsMap,o=this._zr,a=0;a=0?"white":i,o=e.getModel("textStyle");f.extend(t,{textDistance:e.getShallow("distance")||5,textFont:o.getFont(),textPosition:n,textFill:o.getTextColor()||r})},b.updateProps=f.curry(d,!0),b.initProps=f.curry(d,!1),b.getTransform=function(t,e){for(var i=y.identity([]);t&&t!==e;)y.mul(i,t.getLocalTransform(),i),t=t.parent;return i},b.applyTransform=function(t,e,i){return i&&(e=y.invert([],e)),x.applyTransform([],t,e)},b.transformDirection=function(t,e,i){var n=0===e[4]||0===e[5]||0===e[0]?1:Math.abs(2*e[4]/e[0]),r=0===e[4]||0===e[5]||0===e[2]?1:Math.abs(2*e[4]/e[2]),o=["left"===t?-n:"right"===t?n:0,"top"===t?-r:"bottom"===t?r:0];return o=b.applyTransform(o,e,i),Math.abs(o[0])>Math.abs(o[1])?o[0]>0?"right":"left":o[1]>0?"bottom":"top"},t.exports=b},function(t,e){function i(t){return t.replace(/^\s+/,"").replace(/\s+$/,"")}var n={},r=1e-4;n.linearMap=function(t,e,i,n){var r=e[1]-e[0];if(0===r)return(i[0]+i[1])/2;var o=(t-e[0])/r;return n&&(o=Math.min(Math.max(o,0),1)),o*(i[1]-i[0])+i[0]},n.parsePercent=function(t,e){switch(t){case"center":case"middle":t="50%";break;case"left":case"top":t="0%";break;case"right":case"bottom":t="100%"}return"string"==typeof t?i(t).match(/%$/)?parseFloat(t)/100*e:parseFloat(t):null==t?NaN:+t},n.round=function(t){return+(+t).toFixed(12)},n.asc=function(t){return t.sort(function(t,e){return t-e}),t},n.getPrecision=function(t){if(isNaN(t))return 0;for(var e=1,i=0;Math.round(t*e)/e!==t;)e*=10,i++;return i},n.getPixelPrecision=function(t,e){var i=Math.log,n=Math.LN10,r=Math.floor(i(t[1]-t[0])/n),o=Math.round(i(Math.abs(e[1]-e[0]))/n);return Math.max(-r+o,0)},n.MAX_SAFE_INTEGER=9007199254740991,n.remRadian=function(t){var e=2*Math.PI;return(t%e+e)%e},n.isRadianAroundZero=function(t){return t>-r&&r>t},n.parseDate=function(t){return t instanceof Date?t:new Date("string"==typeof t?t.replace(/-/g,"/"):Math.round(t))},n.nice=function(t,e){var i,n=Math.floor(Math.log(t)/Math.LN10),r=Math.pow(10,n),o=t/r;return i=e?1.5>o?1:2.5>o?2:4>o?3:7>o?5:10:1>o?1:2>o?2:3>o?3:5>o?5:10,i*r},t.exports=n},function(t,e){var i="undefined"==typeof Float32Array?Array:Float32Array,n={create:function(t,e){var n=new i(2);return n[0]=t||0,n[1]=e||0,n},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t},clone:function(t){var e=new i(2);return e[0]=t[0],e[1]=t[1],e},set:function(t,e,i){return t[0]=e,t[1]=i,t},add:function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t},scaleAndAdd:function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t},sub:function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t},len:function(t){return Math.sqrt(this.lenSquare(t))},lenSquare:function(t){return t[0]*t[0]+t[1]*t[1]},mul:function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t},div:function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},scale:function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},normalize:function(t,e){var i=n.len(e);return 0===i?(t[0]=0,t[1]=0):(t[0]=e[0]/i,t[1]=e[1]/i),t},distance:function(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))},distanceSquare:function(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])},negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},lerp:function(t,e,i,n){return t[0]=e[0]+n*(i[0]-e[0]),t[1]=e[1]+n*(i[1]-e[1]),t},applyTransform:function(t,e,i){var n=e[0],r=e[1];return t[0]=i[0]*n+i[2]*r+i[4],t[1]=i[1]*n+i[3]*r+i[5],t},min:function(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t},max:function(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t}};n.length=n.len,n.lengthSquare=n.lenSquare,n.dist=n.distance,n.distSquare=n.distanceSquare,t.exports=n},function(t,e,i){function n(t){var e=t.fill;return null!=e&&"none"!==e}function r(t){var e=t.stroke;return null!=e&&"none"!==e&&t.lineWidth>0}function o(t){a.call(this,t),this.path=new l}var a=i(35),s=i(1),l=i(27),h=i(136),c=i(16),u=Math.abs;o.prototype={constructor:o,type:"path",__dirtyPath:!0,strokeContainThreshold:5,brush:function(t){t.save();var e=this.style,i=this.path,o=r(e),a=n(e);this.__dirtyPath&&(a&&e.fill instanceof c&&e.fill.updateCanvasGradient(this,t),o&&e.stroke instanceof c&&e.stroke.updateCanvasGradient(this,t)),e.bind(t,this),this.setTransform(t);var s=e.lineDash,l=e.lineDashOffset,h=!!t.setLineDash;this.__dirtyPath||s&&!h&&o?(i=this.path.beginPath(t),s&&!h&&(i.setLineDash(s),i.setLineDashOffset(l)),this.buildPath(i,this.shape),this.__dirtyPath=!1):(t.beginPath(),this.path.rebuildPath(t)),a&&i.fill(t),s&&h&&(t.setLineDash(s),t.lineDashOffset=l),o&&i.stroke(t),null!=e.text&&this.drawRectText(t,this.getBoundingRect()),t.restore()},buildPath:function(t,e){},getBoundingRect:function(){var t=this._rect,e=this.style;if(!t){var i=this.path;this.__dirtyPath&&(i.beginPath(),this.buildPath(i,this.shape)),t=i.getBoundingRect()}if(r(e)&&(this.__dirty||!this._rect)){var o=this._rectWithStroke||(this._rectWithStroke=t.clone());o.copy(t);var a=e.lineWidth,s=e.strokeNoScale?this.getLineScale():1;return n(e)||(a=Math.max(a,this.strokeContainThreshold)),s>1e-10&&(o.width+=a/s,o.height+=a/s,o.x-=a/s/2,o.y-=a/s/2),o}return this._rect=t,t},contain:function(t,e){var i=this.transformCoordToLocal(t,e),o=this.getBoundingRect(),a=this.style;if(t=i[0],e=i[1],o.contain(t,e)){var s=this.path.data;if(r(a)){var l=a.lineWidth,c=a.strokeNoScale?this.getLineScale():1;if(c>1e-10&&(n(a)||(l=Math.max(l,this.strokeContainThreshold)),h.containStroke(s,l/c,t,e)))return!0}if(n(a))return h.contain(s,t,e)}return!1},dirty:function(t){0===arguments.length&&(t=!0),t&&(this.__dirtyPath=t,this._rect=null),this.__dirty=!0,this.__zr&&this.__zr.refresh(),this.__clipTarget&&this.__clipTarget.dirty()},animateShape:function(t){return this.animate("shape",t)},attrKV:function(t,e){"shape"===t?this.setShape(e):a.prototype.attrKV.call(this,t,e)},setShape:function(t,e){var i=this.shape;if(i){if(s.isObject(t))for(var n in t)i[n]=t[n];else i[t]=e;this.dirty(!0)}return this},getLineScale:function(){var t=this.transform;return t&&u(t[0]-1)>1e-10&&u(t[3]-1)>1e-10?Math.sqrt(u(t[0]*t[3]-t[2]*t[1])):1}},o.extend=function(t){var e=function(e){o.call(this,e),t.style&&this.style.extendFrom(t.style,!1);var i=t.shape;if(i){this.shape=this.shape||{};var n=this.shape;for(var r in i)!n.hasOwnProperty(r)&&i.hasOwnProperty(r)&&(n[r]=i[r])}t.init&&t.init.call(this,e)};s.inherits(e,o);for(var i in t)"style"!==i&&"shape"!==i&&(e.prototype[i]=t[i]);return e},s.inherits(o,a),t.exports=o},function(t,e,i){var n=i(9),r=i(4),o=i(1),a=i(12),s=["x","y","z","radius","angle"],l={};l.createNameEach=function(t,e){t=t.slice();var i=o.map(t,l.capitalFirst);e=(e||[]).slice();var n=o.map(e,l.capitalFirst);return function(r,a){o.each(t,function(t,o){for(var s={name:t,capital:i[o]},l=0;l=0}function r(t,n){var r=!1;return e(function(e){o.each(i(t,e)||[],function(t){n.records[e.name][t]&&(r=!0)})}),r}function a(t,n){n.nodes.push(t),e(function(e){o.each(i(t,e)||[],function(t){n.records[e.name][t]=!0})})}return function(i){function o(t){!n(t,s)&&r(t,s)&&(a(t,s),l=!0)}var s={nodes:[],records:{}};if(e(function(t){s.records[t.name]={}}),!i)return s;a(i,s);var l;do l=!1,t(o);while(l);return s}},l.defaultEmphasis=function(t,e){if(t){var i=t.emphasis=t.emphasis||{},n=t.normal=t.normal||{};o.each(e,function(t){var e=o.retrieve(i[t],n[t]);null!=e&&(i[t]=e)})}},l.createDataFormatModel=function(t,e,i){var n=new a;return o.mixin(n,l.dataFormatMixin),n.seriesIndex=t.seriesIndex,n.name=t.name||"",n.getData=function(){return e},n.getRawDataArray=function(){return i},n},l.getDataItemValue=function(t){return t&&(null==t.value?t:t.value)},l.converDataValue=function(t,e){var i=e&&e.type;return"ordinal"===i?t:("time"!==i||isFinite(t)||null==t||"-"===t||(t=+r.parseDate(t)),null==t||""===t?NaN:+t)},l.dataFormatMixin={getDataParams:function(t){var e=this.getData(),i=this.seriesIndex,n=this.name,r=this.getRawValue(t),o=e.getRawIndex(t),a=e.getName(t,!0),s=this.getRawDataArray(),l=s&&s[o];return{seriesIndex:i,seriesName:n,name:a,dataIndex:o,data:l,value:r,$vars:["seriesName","name","value"]}},getFormattedLabel:function(t,e,i){e=e||"normal";var r=this.getData(),o=r.getItemModel(t),a=this.getDataParams(t);return null==i&&(i=o.get(["label",e,"formatter"])),"function"==typeof i?(a.status=e,i(a)):"string"==typeof i?n.formatTpl(i,a):void 0},getRawValue:function(t){var e=this.getData().getItemModel(t);if(e&&null!=e.option){var i=e.option;return o.isObject(i)&&!o.isArray(i)?i.value:i}}},l.mappingToExists=function(t,e){e=(e||[]).slice();var i=o.map(t||[],function(t,e){return{exist:t}});return o.each(e,function(t,n){if(o.isObject(t))for(var r=0;r=i.length&&i.push({option:t})}}),i},l.isIdInner=function(t){return o.isObject(t)&&t.id&&0===(t.id+"").indexOf("\x00_ec_\x00")},t.exports=l},function(t,e,i){"use strict";function n(t,e,i,n){this.x=t,this.y=e,this.width=i,this.height=n}var r=i(5),o=i(19),a=r.applyTransform,s=Math.min,l=Math.abs,h=Math.max;n.prototype={constructor:n,union:function(t){var e=s(t.x,this.x),i=s(t.y,this.y);this.width=h(t.x+t.width,this.x+this.width)-e,this.height=h(t.y+t.height,this.y+this.height)-i,this.x=e,this.y=i},applyTransform:function(){var t=[],e=[];return function(i){i&&(t[0]=this.x,t[1]=this.y,e[0]=this.x+this.width,e[1]=this.y+this.height,a(t,t,i),a(e,e,i),this.x=s(t[0],e[0]),this.y=s(t[1],e[1]),this.width=l(e[0]-t[0]),this.height=l(e[1]-t[1]))}}(),calculateTransform:function(t){var e=this,i=t.width/e.width,n=t.height/e.height,r=o.create();return o.translate(r,r,[-e.x,-e.y]),o.scale(r,r,[i,n]),o.translate(r,r,[t.x,t.y]),r},intersect:function(t){var e=this,i=e.x,n=e.x+e.width,r=e.y,o=e.y+e.height,a=t.x,s=t.x+t.width,l=t.y,h=t.y+t.height;return!(a>n||i>s||l>o||r>h)},contain:function(t,e){var i=this;return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i.height},clone:function(){return new n(this.x,this.y,this.width,this.height)},copy:function(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}},t.exports=n},function(t,e,i){function n(t){return isNaN(t)?"-":(t=(t+"").split("."),t[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,"$1,")+(t.length>1?"."+t[1]:""))}function r(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function o(t){var e=t.length;return"number"==typeof t?[t,t,t,t]:2===e?[t[0],t[1],t[0],t[1]]:3===e?[t[0],t[1],t[2],t[1]]:t}function a(t){return String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function s(t,e){return"{"+t+(null==e?"":e)+"}"}function l(t,e){u.isArray(e)||(e=[e]);var i=e.length;if(!i)return"";for(var n=e[0].$vars,r=0;ra;a++)for(var l=0;lt?"0"+t:t}var u=i(1),d=i(4),f=["a","b","c","d","e","f","g"];t.exports={normalizeCssArray:o,addCommas:n,toCamelCase:r,encodeHTML:a,formatTpl:l,formatTime:h}},function(t,e,i){function n(t){var e=[];return o.each(c.getClassesByMainType(t),function(t){a.apply(e,t.prototype.dependencies||[])}),o.map(e,function(t){return l.parseClassType(t).main})}var r=i(12),o=i(1),a=Array.prototype.push,s=i(41),l=i(20),h=i(11),c=r.extend({type:"component",id:"",name:"",mainType:"",subType:"",componentIndex:0,defaultOption:null,ecModel:null,dependentModels:[],uid:null,layoutMode:null,init:function(t,e,i,n){this.mergeDefaultAndTheme(this.option,this.ecModel)},mergeDefaultAndTheme:function(t,e){var i=this.layoutMode,n=i?h.getLayoutParams(t):{},r=e.getTheme();o.merge(t,r.get(this.mainType)),o.merge(t,this.getDefaultOption()),i&&h.mergeLayoutParam(t,n,i)},mergeOption:function(t){o.merge(this.option,t,!0);var e=this.layoutMode;e&&h.mergeLayoutParam(this.option,t,e)},optionUpdated:function(t){},getDefaultOption:function(){if(!this.hasOwnProperty("__defaultOption")){for(var t=[],e=this.constructor;e;){var i=e.prototype.defaultOption;i&&t.push(i),e=e.superClass}for(var n={},r=t.length-1;r>=0;r--)n=o.merge(n,t[r],!0);this.__defaultOption=n}return this.__defaultOption}});l.enableClassExtend(c,function(t,e,i,n){o.extend(this,n),this.uid=s.getUID("componentModel"),this.setReadOnly(["type","id","uid","name","mainType","subType","dependentModels","componentIndex"])}),l.enableClassManagement(c,{registerWhenExtend:!0}),s.enableSubTypeDefaulter(c),s.enableTopologicalTravel(c,n),o.mixin(c,i(115)),t.exports=c},function(t,e,i){"use strict";function n(t,e,i,n,r){var o=0,a=0;null==n&&(n=1/0),null==r&&(r=1/0);var s=0;e.eachChild(function(l,h){var c,u,d=l.position,f=l.getBoundingRect(),p=e.childAt(h+1),g=p&&p.getBoundingRect();if("horizontal"===t){var m=f.width+(g?-g.x+f.x:0);c=o+m,c>n||l.newline?(o=0,c=m,a+=s+i,s=f.height):s=Math.max(s,f.height)}else{var v=f.height+(g?-g.y+f.y:0);u=a+v,u>r||l.newline?(o+=s+i,a=0,u=v,s=f.width):s=Math.max(s,f.width)}l.newline||(d[0]=o,d[1]=a,"horizontal"===t?o=c+i:a=u+i)})}var r=i(1),o=i(8),a=i(4),s=i(9),l=a.parsePercent,h=r.each,c={},u=["left","right","top","bottom","width","height"];c.box=n,c.vbox=r.curry(n,"vertical"),c.hbox=r.curry(n,"horizontal"),c.getAvailableSize=function(t,e,i){var n=e.width,r=e.height,o=l(t.x,n),a=l(t.y,r),h=l(t.x2,n),c=l(t.y2,r);return(isNaN(o)||isNaN(parseFloat(t.x)))&&(o=0),(isNaN(h)||isNaN(parseFloat(t.x2)))&&(h=n),(isNaN(a)||isNaN(parseFloat(t.y)))&&(a=0),(isNaN(c)||isNaN(parseFloat(t.y2)))&&(c=r),i=s.normalizeCssArray(i||0),{width:Math.max(h-o-i[1]-i[3],0),height:Math.max(c-a-i[0]-i[2],0)}},c.getLayoutRect=function(t,e,i){i=s.normalizeCssArray(i||0);var n=e.width,r=e.height,a=l(t.left,n),h=l(t.top,r),c=l(t.right,n),u=l(t.bottom,r),d=l(t.width,n),f=l(t.height,r),p=i[2]+i[0],g=i[1]+i[3],m=t.aspect;switch(isNaN(d)&&(d=n-c-g-a),isNaN(f)&&(f=r-u-p-h),isNaN(d)&&isNaN(f)&&(m>n/r?d=.8*n:f=.8*r),null!=m&&(isNaN(d)&&(d=m*f),isNaN(f)&&(f=d/m)),isNaN(a)&&(a=n-c-d-g),isNaN(h)&&(h=r-u-f-p),t.left||t.right){case"center":a=n/2-d/2-i[3];break;case"right":a=n-d-g}switch(t.top||t.bottom){case"middle":case"center":h=r/2-f/2-i[0];break;case"bottom":h=r-f-p}a=a||0,h=h||0,isNaN(d)&&(d=n-a-(c||0)),isNaN(f)&&(f=r-h-(u||0));var v=new o(a+i[3],h+i[0],d,f);return v.margin=i,v},c.positionGroup=function(t,e,i,n){var o=t.getBoundingRect();e=r.extend(r.clone(e),{width:o.width,height:o.height}),e=c.getLayoutRect(e,i,n),t.position=[e.x-o.x,e.y-o.y]},c.mergeLayoutParam=function(t,e,i){function n(n){var r={},s=0,l={},c=0,u=i.ignoreSize?1:2;if(h(n,function(e){l[e]=t[e]}),h(n,function(t){o(e,t)&&(r[t]=l[t]=e[t]),a(r,t)&&s++,a(l,t)&&c++}),c!==u&&s){if(s>=u)return r;for(var d=0;d"+(a?s(a)+" : "+o:o)},restoreData:function(){this._data=this._dataBeforeProcessed.cloneShallow()}});n.mixin(h,o.dataFormatMixin),t.exports=h},function(t,e,i){(function(e){function n(t){return d.isArray(t)||(t=[t]),t}function r(t,e){var i=t.dimensions,n=new v(d.map(i,t.getDimensionInfo,t),t.hostModel);m(n,t,t._wrappedMethods);for(var r=n._storage={},o=t._storage,a=0;a=0?r[s]=new l.constructor(o[s].length):r[s]=o[s]}return n}var o="undefined",a="undefined"==typeof window?e:window,s=typeof a.Float64Array===o?Array:a.Float64Array,l=typeof a.Int32Array===o?Array:a.Int32Array,h={"float":s,"int":l,ordinal:Array,number:Array,time:Array},c=i(12),u=i(52),d=i(1),f=i(7),p=d.isObject,g=["stackedOn","_nameList","_idList","_rawData"],m=function(t,e,i){d.each(g.concat(i||[]),function(i){e.hasOwnProperty(i)&&(t[i]=e[i])})},v=function(t,e){t=t||["x","y"];for(var i={},n=[],r=0;r0&&(b+="__ec__"+c[w]),c[w]++),b&&(l[u]=b)}this._nameList=e,this._idList=l},y.count=function(){return this.indices.length},y.get=function(t,e,i){var n=this._storage,r=this.indices[e];if(null==r)return NaN;var o=n[t]&&n[t][r];if(i){var a=this._dimensionInfos[t];if(a&&a.stackable)for(var s=this.stackedOn;s;){var l=s.get(t,e);(o>=0&&l>0||0>=o&&0>l)&&(o+=l),s=s.stackedOn}}return o},y.getValues=function(t,e,i){var n=[];d.isArray(t)||(i=e,e=t,t=this.dimensions);for(var r=0,o=t.length;o>r;r++)n.push(this.get(t[r],e,i));return n},y.hasValue=function(t){for(var e=this.dimensions,i=this._dimensionInfos,n=0,r=e.length;r>n;n++)if("ordinal"!==i[e[n]].type&&isNaN(this.get(e[n],t)))return!1;return!0},y.getDataExtent=function(t,e){var i=this._storage[t],n=this.getDimensionInfo(t);e=n&&n.stackable&&e;var r,o=(this._extent||(this._extent={}))[t+!!e];if(o)return o;if(i){for(var a=1/0,s=-(1/0),l=0,h=this.count();h>l;l++)r=this.get(t,l,e),a>r&&(a=r),r>s&&(s=r);return this._extent[t+e]=[a,s]}return[1/0,-(1/0)]},y.getSum=function(t,e){var i=this._storage[t],n=0;if(i)for(var r=0,o=this.count();o>r;r++){var a=this.get(t,r,e);isNaN(a)||(n+=a)}return n},y.indexOf=function(t,e){var i=this._storage,n=i[t],r=this.indices;if(n)for(var o=0,a=r.length;a>o;o++){var s=r[o];if(n[s]===e)return o; +}return-1},y.indexOfName=function(t){for(var e=this.indices,i=this._nameList,n=0,r=e.length;r>n;n++){var o=e[n];if(i[o]===t)return n}return-1},y.indexOfNearest=function(t,e,i){var n=this._storage,r=n[t];if(r){for(var o=Number.MAX_VALUE,a=-1,s=0,l=this.count();l>s;s++){var h=Math.abs(this.get(t,s,i)-e);o>=h&&(o=h,a=s)}return a}return-1},y.getRawIndex=function(t){var e=this.indices[t];return null==e?-1:e},y.getName=function(t){return this._nameList[this.indices[t]]||""},y.getId=function(t){return this._idList[this.indices[t]]||this.getRawIndex(t)+""},y.each=function(t,e,i,r){"function"==typeof t&&(r=i,i=e,e=t,t=[]),t=d.map(n(t),this.getDimension,this);var o=[],a=t.length,s=this.indices;r=r||this;for(var l=0;lh;h++)o[h]=this.get(t[h],l,i);o[h]=l,e.apply(r,o)}},y.filterSelf=function(t,e,i,r){"function"==typeof t&&(r=i,i=e,e=t,t=[]),t=d.map(n(t),this.getDimension,this);var o=[],a=[],s=t.length,l=this.indices;r=r||this;for(var h=0;hu;u++)a[u]=this.get(t[u],h,i);a[u]=h,c=e.apply(r,a)}c&&o.push(l[h])}return this.indices=o,this._extent={},this},y.mapArray=function(t,e,i,n){"function"==typeof t&&(n=i,i=e,e=t,t=[]);var r=[];return this.each(t,function(){r.push(e&&e.apply(this,arguments))},i,n),r},y.map=function(t,e,i,o){t=d.map(n(t),this.getDimension,this);var a=r(this,t),s=a.indices=this.indices,l=a._storage,h=[];return this.each(t,function(){var i=arguments[arguments.length-1],n=e&&e.apply(this,arguments);if(null!=n){"number"==typeof n&&(h[0]=n,n=h);for(var r=0;rg;g+=d){d>p-g&&(d=p-g,c.length=d);for(var m=0;d>m;m++){var v=l[g+m];c[m]=f[v],u[m]=v}var y=i(c),v=u[n(c,y)||0];f[v]=y,h.push(v)}return o},y.getItemModel=function(t){var e=this.hostModel;return t=this.indices[t],new c(this._rawData[t],e,e.ecModel)},y.diff=function(t){var e=this._idList,i=t&&t._idList;return new u(t?t.indices:[],this.indices,function(t){return i[t]||t+""},function(t){return e[t]||t+""})},y.getVisual=function(t){var e=this._visual;return e&&e[t]},y.setVisual=function(t,e){if(p(t))for(var i in t)t.hasOwnProperty(i)&&this.setVisual(i,t[i]);else this._visual=this._visual||{},this._visual[t]=e},y.setLayout=function(t,e){if(p(t))for(var i in t)t.hasOwnProperty(i)&&this.setLayout(i,t[i]);else this._layout[t]=e},y.getLayout=function(t){return this._layout[t]},y.getItemLayout=function(t){return this._itemLayouts[t]},y.setItemLayout=function(t,e,i){this._itemLayouts[t]=i?d.extend(this._itemLayouts[t]||{},e):e},y.getItemVisual=function(t,e,i){var n=this._itemVisuals[t],r=n&&n[e];return null!=r||i?r:this.getVisual(e)},y.setItemVisual=function(t,e,i){var n=this._itemVisuals[t]||{};if(this._itemVisuals[t]=n,p(e))for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);else n[e]=i};var x=function(t){t.seriesIndex=this.seriesIndex,t.dataIndex=this.dataIndex};y.setItemGraphicEl=function(t,e){var i=this.hostModel;e&&(e.dataIndex=t,e.seriesIndex=i&&i.seriesIndex,"group"===e.type&&e.traverse(x,e)),this._graphicEls[t]=e},y.getItemGraphicEl=function(t){return this._graphicEls[t]},y.eachItemGraphicEl=function(t,e){d.each(this._graphicEls,function(i,n){i&&t&&t.call(e,i,n)})},y.cloneShallow=function(){var t=d.map(this.dimensions,this.getDimensionInfo,this),e=new v(t,this.hostModel);return e._storage=this._storage,m(e,this,this._wrappedMethods),e.indices=this.indices.slice(),e},y.wrapMethod=function(t,e){var i=this[t];"function"==typeof i&&(this._wrappedMethods=this._wrappedMethods||[],this._wrappedMethods.push(t),this[t]=function(){var t=i.apply(this,arguments);return e.call(this,t)})},t.exports=v}).call(e,function(){return this}())},function(t,e){function i(t){var e={},i={},n=t.match(/Web[kK]it[\/]{0,1}([\d.]+)/),r=t.match(/(Android);?[\s\/]+([\d.]+)?/),o=t.match(/(iPad).*OS\s([\d_]+)/),a=t.match(/(iPod)(.*OS\s([\d_]+))?/),s=!o&&t.match(/(iPhone\sOS)\s([\d_]+)/),l=t.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),h=l&&t.match(/TouchPad/),c=t.match(/Kindle\/([\d.]+)/),u=t.match(/Silk\/([\d._]+)/),d=t.match(/(BlackBerry).*Version\/([\d.]+)/),f=t.match(/(BB10).*Version\/([\d.]+)/),p=t.match(/(RIM\sTablet\sOS)\s([\d.]+)/),g=t.match(/PlayBook/),m=t.match(/Chrome\/([\d.]+)/)||t.match(/CriOS\/([\d.]+)/),v=t.match(/Firefox\/([\d.]+)/),y=n&&t.match(/Mobile\//)&&!m,x=t.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/)&&!m,_=t.match(/MSIE\s([\d.]+)/)||t.match(/Trident\/.+?rv:(([\d.]+))/),b=t.match(/Edge\/([\d.]+)/);return(i.webkit=!!n)&&(i.version=n[1]),r&&(e.android=!0,e.version=r[2]),s&&!a&&(e.ios=e.iphone=!0,e.version=s[2].replace(/_/g,".")),o&&(e.ios=e.ipad=!0,e.version=o[2].replace(/_/g,".")),a&&(e.ios=e.ipod=!0,e.version=a[3]?a[3].replace(/_/g,"."):null),l&&(e.webos=!0,e.version=l[2]),h&&(e.touchpad=!0),d&&(e.blackberry=!0,e.version=d[2]),f&&(e.bb10=!0,e.version=f[2]),p&&(e.rimtabletos=!0,e.version=p[2]),g&&(i.playbook=!0),c&&(e.kindle=!0,e.version=c[1]),u&&(i.silk=!0,i.version=u[1]),!u&&e.android&&t.match(/Kindle Fire/)&&(i.silk=!0),m&&(i.chrome=!0,i.version=m[1]),v&&(i.firefox=!0,i.version=v[1]),_&&(i.ie=!0,i.version=_[1]),y&&(t.match(/Safari/)||e.ios)&&(i.safari=!0),x&&(i.webview=!0),_&&(i.ie=!0,i.version=_[1]),b&&(i.edge=!0,i.version=b[1]),e.tablet=!!(o||g||r&&!t.match(/Mobile/)||v&&t.match(/Tablet/)||_&&!t.match(/Phone/)&&t.match(/Touch/)),e.phone=!(e.tablet||e.ipod||!(r||s||l||d||f||m&&t.match(/Android/)||m&&t.match(/CriOS\/([\d.]+)/)||v&&t.match(/Mobile/)||_&&t.match(/Touch/))),{browser:i,os:e,node:!1,canvasSupported:!!document.createElement("canvas").getContext,touchEventsSupported:"ontouchstart"in window&&!i.ie&&!i.edge,pointerEventsSupported:"onpointerdown"in window&&(i.edge||i.ie&&i.version>=10)}}var n={};n="undefined"==typeof navigator?{browser:{},os:{},node:!0,canvasSupported:!0}:i(navigator.userAgent),t.exports=n},function(t,e){var i=function(t){this.colorStops=t||[]};i.prototype={constructor:i,addColorStop:function(t,e){this.colorStops.push({offset:t,color:e})}},t.exports=i},function(t,e,i){function n(t,e){var i=t+":"+e;if(h[i])return h[i];for(var n=(t+"").split("\n"),r=0,o=0,a=n.length;a>o;o++)r=Math.max(p.measureText(n[o],e).width,r);return c>u&&(c=0,h={}),c++,h[i]=r,r}function r(t,e,i,r){var o=((t||"")+"").split("\n").length,a=n(t,e),s=n("国",e),l=o*s,h=new f(0,0,a,l);switch(h.lineHeight=s,r){case"bottom":case"alphabetic":h.y-=s;break;case"middle":h.y-=s/2}switch(i){case"end":case"right":h.x-=h.width;break;case"center":h.x-=h.width/2}return h}function o(t,e,i,n){var r=e.x,o=e.y,a=e.height,s=e.width,l=i.height,h=a/2-l/2,c="left";switch(t){case"left":r-=n,o+=h,c="right";break;case"right":r+=n+s,o+=h,c="left";break;case"top":r+=s/2,o-=n+l,c="center";break;case"bottom":r+=s/2,o+=a+n,c="center";break;case"inside":r+=s/2,o+=h,c="center";break;case"insideLeft":r+=n,o+=h,c="left";break;case"insideRight":r+=s-n,o+=h,c="right";break;case"insideTop":r+=s/2,o+=n,c="center";break;case"insideBottom":r+=s/2,o+=a-l-n,c="center";break;case"insideTopLeft":r+=n,o+=n,c="left";break;case"insideTopRight":r+=s-n,o+=n,c="right";break;case"insideBottomLeft":r+=n,o+=a-l-n;break;case"insideBottomRight":r+=s-n,o+=a-l-n,c="right"}return{x:r,y:o,textAlign:c,textBaseline:"top"}}function a(t,e,i,r){if(!i)return"";r=d.defaults({ellipsis:"...",minCharacters:3,maxIterations:3,cnCharWidth:n("国",e),ascCharWidth:n("a",e)},r,!0),i-=n(r.ellipsis);for(var o=(t+"").split("\n"),a=0,l=o.length;l>a;a++)o[a]=s(o[a],e,i,r);return o.join("\n")}function s(t,e,i,r){for(var o=0;;o++){var a=n(t,e);if(i>a||o>=r.maxIterations){t+=r.ellipsis;break}var s=0===o?l(t,i,r):Math.floor(t.length*i/a);if(sr&&e>n;r++){var a=t.charCodeAt(r);n+=a>=0&&127>=a?i.ascCharWidth:i.cnCharWidth}return r}var h={},c=0,u=5e3,d=i(1),f=i(8),p={getWidth:n,getBoundingRect:r,adjustTextPositionOnRect:o,ellipsis:a,measureText:function(t,e){var i=d.getContext();return i.font=e,i.measureText(t)}};t.exports=p},function(t,e,i){"use strict";function n(t){return t>-w&&w>t}function r(t){return t>w||-w>t}function o(t,e,i,n,r){var o=1-r;return o*o*(o*t+3*r*e)+r*r*(r*n+3*o*i)}function a(t,e,i,n,r){var o=1-r;return 3*(((e-t)*o+2*(i-e)*r)*o+(n-i)*r*r)}function s(t,e,i,r,o,a){var s=r+3*(e-i)-t,l=3*(i-2*e+t),h=3*(e-t),c=t-o,u=l*l-3*s*h,d=l*h-9*s*c,f=h*h-3*l*c,p=0;if(n(u)&&n(d))if(n(l))a[0]=0;else{var g=-h/l;g>=0&&1>=g&&(a[p++]=g)}else{var m=d*d-4*u*f;if(n(m)){var v=d/u,g=-l/s+v,y=-v/2;g>=0&&1>=g&&(a[p++]=g),y>=0&&1>=y&&(a[p++]=y)}else if(m>0){var x=b(m),w=u*l+1.5*s*(-d+x),A=u*l+1.5*s*(-d-x);w=0>w?-_(-w,S):_(w,S),A=0>A?-_(-A,S):_(A,S);var g=(-l-(w+A))/(3*s);g>=0&&1>=g&&(a[p++]=g)}else{var T=(2*u*l-3*s*d)/(2*b(u*u*u)),C=Math.acos(T)/3,I=b(u),k=Math.cos(C),g=(-l-2*I*k)/(3*s),y=(-l+I*(k+M*Math.sin(C)))/(3*s),D=(-l+I*(k-M*Math.sin(C)))/(3*s);g>=0&&1>=g&&(a[p++]=g),y>=0&&1>=y&&(a[p++]=y),D>=0&&1>=D&&(a[p++]=D)}}return p}function l(t,e,i,o,a){var s=6*i-12*e+6*t,l=9*e+3*o-3*t-9*i,h=3*e-3*t,c=0;if(n(l)){if(r(s)){var u=-h/s;u>=0&&1>=u&&(a[c++]=u)}}else{var d=s*s-4*l*h;if(n(d))a[0]=-s/(2*l);else if(d>0){var f=b(d),u=(-s+f)/(2*l),p=(-s-f)/(2*l);u>=0&&1>=u&&(a[c++]=u),p>=0&&1>=p&&(a[c++]=p)}}return c}function h(t,e,i,n,r,o){var a=(e-t)*r+t,s=(i-e)*r+e,l=(n-i)*r+i,h=(s-a)*r+a,c=(l-s)*r+s,u=(c-h)*r+h;o[0]=t,o[1]=a,o[2]=h,o[3]=u,o[4]=u,o[5]=c,o[6]=l,o[7]=n}function c(t,e,i,n,r,a,s,l,h,c,u){var d,f,p,g,m,v=.005,y=1/0;A[0]=h,A[1]=c;for(var _=0;1>_;_+=.05)T[0]=o(t,i,r,s,_),T[1]=o(e,n,a,l,_),g=x(A,T),y>g&&(d=_,y=g);y=1/0;for(var M=0;32>M&&!(w>v);M++)f=d-v,p=d+v,T[0]=o(t,i,r,s,f),T[1]=o(e,n,a,l,f),g=x(T,A),f>=0&&y>g?(d=f,y=g):(C[0]=o(t,i,r,s,p),C[1]=o(e,n,a,l,p),m=x(C,A),1>=p&&y>m?(d=p,y=m):v*=.5);return u&&(u[0]=o(t,i,r,s,d),u[1]=o(e,n,a,l,d)),b(y)}function u(t,e,i,n){var r=1-n;return r*(r*t+2*n*e)+n*n*i}function d(t,e,i,n){return 2*((1-n)*(e-t)+n*(i-e))}function f(t,e,i,o,a){var s=t-2*e+i,l=2*(e-t),h=t-o,c=0;if(n(s)){if(r(l)){var u=-h/l;u>=0&&1>=u&&(a[c++]=u)}}else{var d=l*l-4*s*h;if(n(d)){var u=-l/(2*s);u>=0&&1>=u&&(a[c++]=u)}else if(d>0){var f=b(d),u=(-l+f)/(2*s),p=(-l-f)/(2*s);u>=0&&1>=u&&(a[c++]=u),p>=0&&1>=p&&(a[c++]=p)}}return c}function p(t,e,i){var n=t+i-2*e;return 0===n?.5:(t-e)/n}function g(t,e,i,n,r){var o=(e-t)*n+t,a=(i-e)*n+e,s=(a-o)*n+o;r[0]=t,r[1]=o,r[2]=s,r[3]=s,r[4]=a,r[5]=i}function m(t,e,i,n,r,o,a,s,l){var h,c=.005,d=1/0;A[0]=a,A[1]=s;for(var f=0;1>f;f+=.05){T[0]=u(t,i,r,f),T[1]=u(e,n,o,f);var p=x(A,T);d>p&&(h=f,d=p)}d=1/0;for(var g=0;32>g&&!(w>c);g++){var m=h-c,v=h+c;T[0]=u(t,i,r,m),T[1]=u(e,n,o,m);var p=x(T,A);if(m>=0&&d>p)h=m,d=p;else{C[0]=u(t,i,r,v),C[1]=u(e,n,o,v);var y=x(C,A);1>=v&&d>y?(h=v,d=y):c*=.5}}return l&&(l[0]=u(t,i,r,h),l[1]=u(e,n,o,h)),b(d)}var v=i(5),y=v.create,x=v.distSquare,_=Math.pow,b=Math.sqrt,w=1e-4,M=b(3),S=1/3,A=y(),T=y(),C=y();t.exports={cubicAt:o,cubicDerivativeAt:a,cubicRootAt:s,cubicExtrema:l,cubicSubdivide:h,cubicProjectPoint:c,quadraticAt:u,quadraticDerivativeAt:d,quadraticRootAt:f,quadraticExtremum:p,quadraticSubdivide:g,quadraticProjectPoint:m}},function(t,e){var i="undefined"==typeof Float32Array?Array:Float32Array,n={create:function(){var t=new i(6);return n.identity(t),t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},mul:function(t,e,i){var n=e[0]*i[0]+e[2]*i[1],r=e[1]*i[0]+e[3]*i[1],o=e[0]*i[2]+e[2]*i[3],a=e[1]*i[2]+e[3]*i[3],s=e[0]*i[4]+e[2]*i[5]+e[4],l=e[1]*i[4]+e[3]*i[5]+e[5];return t[0]=n,t[1]=r,t[2]=o,t[3]=a,t[4]=s,t[5]=l,t},translate:function(t,e,i){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4]+i[0],t[5]=e[5]+i[1],t},rotate:function(t,e,i){var n=e[0],r=e[2],o=e[4],a=e[1],s=e[3],l=e[5],h=Math.sin(i),c=Math.cos(i);return t[0]=n*c+a*h,t[1]=-n*h+a*c,t[2]=r*c+s*h,t[3]=-r*h+c*s,t[4]=c*o+h*l,t[5]=c*l-h*o,t},scale:function(t,e,i){var n=i[0],r=i[1];return t[0]=e[0]*n,t[1]=e[1]*r,t[2]=e[2]*n,t[3]=e[3]*r,t[4]=e[4]*n,t[5]=e[5]*r,t},invert:function(t,e){var i=e[0],n=e[2],r=e[4],o=e[1],a=e[3],s=e[5],l=i*a-o*n;return l?(l=1/l,t[0]=a*l,t[1]=-o*l,t[2]=-n*l,t[3]=i*l,t[4]=(n*s-a*r)*l,t[5]=(o*r-i*s)*l,t):null}};t.exports=n},function(t,e,i){function n(t,e){var i=o.slice(arguments,2);return this.superClass.prototype[e].apply(t,i)}function r(t,e,i){return this.superClass.prototype[e].apply(t,i)}var o=i(1),a={},s=".",l="___EC__COMPONENT__CONTAINER___",h=a.parseClassType=function(t){var e={main:"",sub:""};return t&&(t=t.split(s),e.main=t[0]||"",e.sub=t[1]||""),e};a.enableClassExtend=function(t,e){t.extend=function(i){var a=function(){e&&e.apply(this,arguments),t.apply(this,arguments)};return o.extend(a.prototype,i),a.extend=this.extend,a.superCall=n,a.superApply=r,o.inherits(a,this),a.superClass=this,a}},a.enableClassManagement=function(t,e){function i(t){var e=n[t.main];return e&&e[l]||(e=n[t.main]={},e[l]=!0),e}e=e||{};var n={};if(t.registerClass=function(t,e){if(e)if(e=h(e),e.sub){if(e.sub!==l){var r=i(e);r[e.sub]=t}}else{if(n[e.main])throw new Error(e.main+"exists");n[e.main]=t}return t},t.getClass=function(t,e,i){var r=n[t];if(r&&r[l]&&(r=e?r[e]:null),i&&!r)throw new Error("Component "+t+"."+(e||"")+" not exists");return r},t.getClassesByMainType=function(t){t=h(t);var e=[],i=n[t.main];return i&&i[l]?o.each(i,function(t,i){i!==l&&e.push(t)}):e.push(i),e},t.hasClass=function(t){return t=h(t),!!n[t.main]},t.getAllClassMainTypes=function(){var t=[];return o.each(n,function(e,i){t.push(i)}),t},t.hasSubTypes=function(t){t=h(t);var e=n[t.main];return e&&e[l]},t.parseClassType=h,e.registerWhenExtend){var r=t.extend;r&&(t.extend=function(e){var i=r.call(this,e);return t.registerClass(i,e.type)})}return t},a.setReadOnly=function(t,e){},t.exports=a},function(t,e,i){var n=Array.prototype.slice,r=i(1),o=r.indexOf,a=function(){this._$handlers={}};a.prototype={constructor:a,one:function(t,e,i){var n=this._$handlers;return e&&t?(n[t]||(n[t]=[]),o(n[t],t)>=0?this:(n[t].push({h:e,one:!0,ctx:i||this}),this)):this},on:function(t,e,i){var n=this._$handlers;return e&&t?(n[t]||(n[t]=[]),n[t].push({h:e,one:!1,ctx:i||this}),this):this},isSilent:function(t){var e=this._$handlers;return e[t]&&e[t].length},off:function(t,e){var i=this._$handlers;if(!t)return this._$handlers={},this;if(e){if(i[t]){for(var n=[],r=0,o=i[t].length;o>r;r++)i[t][r].h!=e&&n.push(i[t][r]);i[t]=n}i[t]&&0===i[t].length&&delete i[t]}else delete i[t];return this},trigger:function(t){if(this._$handlers[t]){var e=arguments,i=e.length;i>3&&(e=n.call(e,1));for(var r=this._$handlers[t],o=r.length,a=0;o>a;){switch(i){case 1:r[a].h.call(r[a].ctx);break;case 2:r[a].h.call(r[a].ctx,e[1]);break;case 3:r[a].h.call(r[a].ctx,e[1],e[2]);break;default:r[a].h.apply(r[a].ctx,e)}r[a].one?(r.splice(a,1),o--):a++}}return this},triggerWithContext:function(t){if(this._$handlers[t]){var e=arguments,i=e.length;i>4&&(e=n.call(e,1,e.length-1));for(var r=e[e.length-1],o=this._$handlers[t],a=o.length,s=0;a>s;){switch(i){case 1:o[s].h.call(r);break;case 2:o[s].h.call(r,e[1]);break;case 3:o[s].h.call(r,e[1],e[2]);break;default:o[s].h.apply(r,e)}o[s].one?(o.splice(s,1),a--):s++}}return this}},t.exports=a},function(t,e){function i(t){return t=Math.round(t),0>t?0:t>255?255:t}function n(t){return t=Math.round(t),0>t?0:t>360?360:t}function r(t){return 0>t?0:t>1?1:t}function o(t){return i(t.length&&"%"===t.charAt(t.length-1)?parseFloat(t)/100*255:parseInt(t,10))}function a(t){return r(t.length&&"%"===t.charAt(t.length-1)?parseFloat(t)/100:parseFloat(t))}function s(t,e,i){return 0>i?i+=1:i>1&&(i-=1),1>6*i?t+(e-t)*i*6:1>2*i?e:2>3*i?t+(e-t)*(2/3-i)*6:t}function l(t,e,i){return t+(e-t)*i}function h(t){if(t){t+="";var e=t.replace(/ /g,"").toLowerCase();if(e in _)return _[e].slice();if("#"!==e.charAt(0)){var i=e.indexOf("("),n=e.indexOf(")");if(-1!==i&&n+1===e.length){var r=e.substr(0,i),s=e.substr(i+1,n-(i+1)).split(","),l=1;switch(r){case"rgba":if(4!==s.length)return;l=a(s.pop());case"rgb":if(3!==s.length)return;return[o(s[0]),o(s[1]),o(s[2]),l];case"hsla":if(4!==s.length)return;return s[3]=a(s[3]),c(s);case"hsl":if(3!==s.length)return;return c(s);default:return}}}else{if(4===e.length){var h=parseInt(e.substr(1),16);if(!(h>=0&&4095>=h))return;return[(3840&h)>>4|(3840&h)>>8,240&h|(240&h)>>4,15&h|(15&h)<<4,1]}if(7===e.length){var h=parseInt(e.substr(1),16);if(!(h>=0&&16777215>=h))return;return[(16711680&h)>>16,(65280&h)>>8,255&h,1]}}}}function c(t){var e=(parseFloat(t[0])%360+360)%360/360,n=a(t[1]),r=a(t[2]),o=.5>=r?r*(n+1):r+n-r*n,l=2*r-o,h=[i(255*s(l,o,e+1/3)),i(255*s(l,o,e)),i(255*s(l,o,e-1/3))];return 4===t.length&&(h[3]=t[3]),h}function u(t){if(t){var e,i,n=t[0]/255,r=t[1]/255,o=t[2]/255,a=Math.min(n,r,o),s=Math.max(n,r,o),l=s-a,h=(s+a)/2;if(0===l)e=0,i=0;else{i=.5>h?l/(s+a):l/(2-s-a);var c=((s-n)/6+l/2)/l,u=((s-r)/6+l/2)/l,d=((s-o)/6+l/2)/l;n===s?e=d-u:r===s?e=1/3+c-d:o===s&&(e=2/3+u-c),0>e&&(e+=1),e>1&&(e-=1)}var f=[360*e,i,h];return null!=t[3]&&f.push(t[3]),f}}function d(t,e){var i=h(t);if(i){for(var n=0;3>n;n++)0>e?i[n]=i[n]*(1-e)|0:i[n]=(255-i[n])*e+i[n]|0;return x(i,4===i.length?"rgba":"rgb")}}function f(t,e){var i=h(t);return i?((1<<24)+(i[0]<<16)+(i[1]<<8)+ +i[2]).toString(16).slice(1):void 0}function p(t,e,n){if(e&&e.length&&t>=0&&1>=t){n=n||[0,0,0,0];var r=t*(e.length-1),o=Math.floor(r),a=Math.ceil(r),s=e[o],h=e[a],c=r-o;return n[0]=i(l(s[0],h[0],c)),n[1]=i(l(s[1],h[1],c)),n[2]=i(l(s[2],h[2],c)),n[3]=i(l(s[3],h[3],c)),n}}function g(t,e,n){if(e&&e.length&&t>=0&&1>=t){var o=t*(e.length-1),a=Math.floor(o),s=Math.ceil(o),c=h(e[a]),u=h(e[s]),d=o-a,f=x([i(l(c[0],u[0],d)),i(l(c[1],u[1],d)),i(l(c[2],u[2],d)),r(l(c[3],u[3],d))],"rgba");return n?{color:f,leftIndex:a,rightIndex:s,value:o}:f}}function m(t,e){if(!(2!==t.length||t[1]0&&s>=l;l++)r.push({color:e[l],offset:(l-i.value)/o});return r.push({color:n.color,offset:1}),r}}function v(t,e,i,r){return t=h(t),t?(t=u(t),null!=e&&(t[0]=n(e)),null!=i&&(t[1]=a(i)),null!=r&&(t[2]=a(r)),x(c(t),"rgba")):void 0}function y(t,e){return t=h(t),t&&null!=e?(t[3]=r(e),x(t,"rgba")):void 0}function x(t,e){return"rgb"!==e&&"hsv"!==e&&"hsl"!==e||(t=t.slice(0,3)),e+"("+t.join(",")+")"}var _={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};t.exports={parse:h,lift:d,toHex:f,fastMapToColor:p,mapToColor:g,mapIntervalToColor:m,modifyHSL:v,modifyAlpha:y,stringify:x}},function(t,e,i){var n=i(123),r=i(37);i(124),i(122);var o=i(32),a=i(4),s=i(1),l=i(17),h={};h.getScaleExtent=function(t,e){var i=t.scale,n=i.getExtent(),r=n[1]-n[0];if("ordinal"===i.type)return isFinite(r)?n:[0,0];var o=e.getMin?e.getMin():e.get("min"),l=e.getMax?e.getMax():e.get("max"),h=e.getNeedCrossZero?e.getNeedCrossZero():!e.get("scale"),c=e.get("boundaryGap");s.isArray(c)||(c=[c||0,c||0]),c[0]=a.parsePercent(c[0],1),c[1]=a.parsePercent(c[1],1);var u=!0,d=!0;return null==o&&(o=n[0]-c[0]*r,u=!1),null==l&&(l=n[1]+c[1]*r,d=!1),"dataMin"===o&&(o=n[0]),"dataMax"===l&&(l=n[1]),h&&(o>0&&l>0&&!u&&(o=0),0>o&&0>l&&!d&&(l=0)),[o,l]},h.niceScaleExtent=function(t,e){var i=t.scale,n=h.getScaleExtent(t,e),r=null!=e.get("min"),o=null!=e.get("max");i.setExtent(n[0],n[1]),i.niceExtent(e.get("splitNumber"),r,o);var a=e.get("interval");null!=a&&i.setInterval&&i.setInterval(a)},h.createScaleByModel=function(t,e){if(e=e||t.get("type"))switch(e){case"category":return new n(t.getCategories(),[1/0,-(1/0)]);case"value":return new r;default:return(o.getClass(e)||r).create(t)}},h.ifAxisCrossZero=function(t){var e=t.scale.getExtent(),i=e[0],n=e[1];return!(i>0&&n>0||0>i&&0>n)},h.getAxisLabelInterval=function(t,e,i,n){var r,o=0,a=0,s=1;e.length>40&&(s=Math.round(e.length/40));for(var h=0;h1?s:o*s},h.getFormattedLabels=function(t,e){var i=t.scale,n=i.getTicksLabels(),r=i.getTicks();return"string"==typeof e?(e=function(t){return function(e){return t.replace("{value}",e)}}(e),s.map(n,e)):"function"==typeof e?s.map(r,function(n,r){return e("category"===t.type?i.getLabel(n):n,r)},this):n},t.exports=h},function(t,e,i){"use strict";var n=i(3),r=i(8),o=n.extendShape({type:"triangle",shape:{cx:0,cy:0,width:0,height:0},buildPath:function(t,e){var i=e.cx,n=e.cy,r=e.width/2,o=e.height/2;t.moveTo(i,n-o),t.lineTo(i+r,n+o),t.lineTo(i-r,n+o),t.closePath()}}),a=n.extendShape({type:"diamond",shape:{cx:0,cy:0,width:0,height:0},buildPath:function(t,e){var i=e.cx,n=e.cy,r=e.width/2,o=e.height/2;t.moveTo(i,n-o),t.lineTo(i+r,n),t.lineTo(i,n+o),t.lineTo(i-r,n),t.closePath()}}),s=n.extendShape({type:"pin",shape:{x:0,y:0,width:0,height:0},buildPath:function(t,e){var i=e.x,n=e.y,r=e.width/5*3,o=Math.max(r,e.height),a=r/2,s=a*a/(o-a),l=n-o+a+s,h=Math.asin(s/a),c=Math.cos(h)*a,u=Math.sin(h),d=Math.cos(h);t.arc(i,l,a,Math.PI-h,2*Math.PI+h);var f=.6*a,p=.7*a;t.bezierCurveTo(i+c-u*f,l+s+d*f,i,n-p,i,n),t.bezierCurveTo(i,n-p,i-c+u*f,l+s+d*f,i-c,l+s),t.closePath()}}),l=n.extendShape({type:"arrow",shape:{x:0,y:0,width:0,height:0},buildPath:function(t,e){var i=e.height,n=e.width,r=e.x,o=e.y,a=n/3*2;t.moveTo(r,o),t.lineTo(r+a,o+i),t.lineTo(r,o+i/4*3),t.lineTo(r-a,o+i),t.lineTo(r,o),t.closePath()}}),h={line:n.Line,rect:n.Rect,roundRect:n.Rect,square:n.Rect,circle:n.Circle,diamond:a,pin:s,arrow:l,triangle:o},c={line:function(t,e,i,n,r){r.x1=t,r.y1=e+n/2,r.x2=t+i,r.y2=e+n/2},rect:function(t,e,i,n,r){r.x=t,r.y=e,r.width=i,r.height=n},roundRect:function(t,e,i,n,r){r.x=t,r.y=e,r.width=i,r.height=n,r.r=Math.min(i,n)/4},square:function(t,e,i,n,r){var o=Math.min(i,n);r.x=t,r.y=e,r.width=o,r.height=o},circle:function(t,e,i,n,r){r.cx=t+i/2,r.cy=e+n/2,r.r=Math.min(i,n)/2},diamond:function(t,e,i,n,r){r.cx=t+i/2,r.cy=e+n/2,r.width=i,r.height=n},pin:function(t,e,i,n,r){r.x=t+i/2,r.y=e+n/2,r.width=i,r.height=n},arrow:function(t,e,i,n,r){r.x=t+i/2,r.y=e+n/2,r.width=i,r.height=n},triangle:function(t,e,i,n,r){r.cx=t+i/2,r.cy=e+n/2,r.width=i,r.height=n}},u={};for(var d in h)u[d]=new h[d];var f=n.extendShape({type:"symbol",shape:{symbolType:"",x:0,y:0,width:0,height:0},beforeBrush:function(){var t=this.style,e=this.shape;"pin"===e.symbolType&&"inside"===t.textPosition&&(t.textPosition=["50%","40%"],t.textAlign="center",t.textVerticalAlign="middle")},buildPath:function(t,e){var i=e.symbolType,n=u[i];"none"!==e.symbolType&&(n||(i="rect",n=u[i]),c[i](e.x,e.y,e.width,e.height,n.shape),n.buildPath(t,n.shape))}}),p=function(t){if("image"!==this.type){var e=this.style,i=this.shape;i&&"line"===i.symbolType?e.stroke=t:this.__isEmptyBrush?(e.stroke=t,e.fill="#fff"):(e.fill&&(e.fill=t),e.stroke&&(e.stroke=t)),this.dirty()}},g={createSymbol:function(t,e,i,o,a,s){var l=0===t.indexOf("empty");l&&(t=t.substr(5,1).toLowerCase()+t.substr(6));var h;return h=0===t.indexOf("image://")?new n.Image({style:{image:t.slice(8),x:e,y:i,width:o,height:a}}):0===t.indexOf("path://")?n.makePath(t.slice(7),{},new r(e,i,o,a)):new f({shape:{symbolType:t,x:e,y:i,width:o,height:a}}),h.__isEmptyBrush=l,h.setColor=p,h.setColor(s),h}};t.exports=g},function(t,e,i){function n(){this.group=new a,this.uid=s.getUID("viewChart")}function r(t,e){if(t&&(t.trigger(e),"group"===t.type))for(var i=0;i=0&&(i.splice(n,0,t),this._doAdd(t))}return this},_doAdd:function(t){t.parent&&t.parent.remove(t),t.parent=this;var e=this.__storage,i=this.__zr;e&&e!==t.__storage&&(e.addToMap(t),t instanceof a&&t.addChildrenToStorage(e)),i&&i.refresh()},remove:function(t){var e=this.__zr,i=this.__storage,r=this._children,o=n.indexOf(r,t);return 0>o?this:(r.splice(o,1),t.parent=null,i&&(i.delFromMap(t.id),t instanceof a&&t.delChildrenFromStorage(i)),e&&e.refresh(),this)},removeAll:function(){var t,e,i=this._children,n=this.__storage;for(e=0;ei;i++)this.data[i]=t[i];this._len=e},appendPath:function(t){t instanceof Array||(t=[t]);for(var e=t.length,i=0,n=this._len,r=0;e>r;r++)i+=t[r].len();v&&this.data instanceof Float32Array&&(this.data=new Float32Array(n+i));for(var r=0;e>r;r++)for(var o=t[r].data,a=0;ae.length&&(this._expandData(),e=this.data);for(var i=0;io&&(o=r+o),o%=r,g-=o*c,v-=o*u;c>=0&&t>=g||0>c&&g>t;)n=this._dashIdx,i=a[n],g+=c*i,v+=u*i,this._dashIdx=(n+1)%y,c>0&&l>g||0>c&&g>l||s[n%2?"moveTo":"lineTo"](c>=0?d(g,t):f(g,t),u>=0?d(v,e):f(v,e));c=g-t,u=v-e,this._dashOffset=-m(c*c+u*u)},_dashedBezierTo:function(t,e,i,r,o,a){var s,l,h,c,u,d=this._dashSum,f=this._dashOffset,p=this._lineDash,g=this._ctx,v=this._xi,y=this._yi,x=n.cubicAt,_=0,b=this._dashIdx,w=p.length,M=0;for(0>f&&(f=d+f),f%=d,s=0;1>s;s+=.1)l=x(v,t,i,o,s+.1)-x(v,t,i,o,s),h=x(y,e,r,a,s+.1)-x(y,e,r,a,s),_+=m(l*l+h*h);for(;w>b&&(M+=p[b],!(M>f));b++);for(s=(M-f)/_;1>=s;)c=x(v,t,i,o,s),u=x(y,e,r,a,s),b%2?g.moveTo(c,u):g.lineTo(c,u),s+=p[b]/_,b=(b+1)%w;b%2!==0&&g.lineTo(o,a),l=o-c,h=a-u,this._dashOffset=-m(l*l+h*h)},_dashedQuadraticTo:function(t,e,i,n){var r=i,o=n;i=(i+2*t)/3,n=(n+2*e)/3,t=(this._xi+2*t)/3,e=(this._yi+2*e)/3,this._dashedBezierTo(t,e,i,n,r,o)},toStatic:function(){var t=this.data;t instanceof Array&&(t.length=this._len,v&&(this.data=new Float32Array(t)))},getBoundingRect:function(){l[0]=l[1]=c[0]=c[1]=Number.MAX_VALUE,h[0]=h[1]=u[0]=u[1]=-Number.MAX_VALUE;for(var t=this.data,e=0,i=0,n=0,d=0,f=0;fl?a:l,p=a>l?1:a/l,g=a>l?l/a:1,m=Math.abs(a-l)>.001;m?(t.translate(r,o),t.rotate(u),t.scale(p,g),t.arc(0,0,f,h,h+c,1-d),t.scale(1/p,1/g),t.rotate(-u),t.translate(-r,-o)):t.arc(r,o,f,h,h+c,1-d);break;case s.R:t.rect(e[i++],e[i++],e[i++],e[i++]);break;case s.Z:t.closePath()}}}},y.CMD=s,t.exports=y},function(t,e){"use strict";function i(){this._coordinateSystems=[]}var n={};i.prototype={constructor:i,create:function(t,e){var i=[];for(var r in n){var o=n[r].create(t,e);o&&(i=i.concat(o))}this._coordinateSystems=i},update:function(t,e){for(var i=this._coordinateSystems,n=0;n=0)){var a=this.getShallow(o);null!=a&&(i[t[r][0]]=a)}}return i}}},function(t,e,i){function n(t,e,i,n){if(!e)return t;var s=o(e[0]),l=a.isArray(s)&&s.length||1;i=i||[],n=n||"extra";for(var h=0;l>h;h++)if(!t[h]){var c=i[h]||n+(h-i.length);t[h]=r(e,h)?{type:"ordinal",name:c}:c}return t}function r(t,e){for(var i=0,n=t.length;n>i;i++){var r=o(t[i]);if(!a.isArray(r))return!1;var r=r[e];if(null!=r&&isFinite(r))return!1;if(a.isString(r)&&"-"!==r)return!0}return!1}function o(t){return a.isArray(t)?t:a.isObject(t)?t.value:t}var a=i(1);t.exports=n},function(t,e,i){function n(){this._extent=[1/0,-(1/0)],this._interval=0,this.init&&this.init.apply(this,arguments)}var r=i(20),o=n.prototype;o.parse=function(t){return t},o.contain=function(t){var e=this._extent;return t>=e[0]&&t<=e[1]},o.normalize=function(t){var e=this._extent;return e[1]===e[0]?.5:(t-e[0])/(e[1]-e[0])},o.scale=function(t){var e=this._extent;return t*(e[1]-e[0])+e[0]},o.unionExtent=function(t){var e=this._extent;t[0]e[1]&&(e[1]=t[1])},o.getExtent=function(){return this._extent.slice()},o.setExtent=function(t,e){var i=this._extent;isNaN(t)||(i[0]=t),isNaN(e)||(i[1]=e)},o.getTicksLabels=function(){for(var t=[],e=this.getTicks(),i=0;i=0;if(r){var o="touchend"!=i?e.targetTouches[0]:e.changedTouches[0];if(o){var a=n(t);e.zrX=o.clientX-a.left,e.zrY=o.clientY-a.top}}else{var s=n(t);e.zrX=e.clientX-s.left,e.zrY=e.clientY-s.top,e.zrDelta=e.wheelDelta?e.wheelDelta/120:-(e.detail||0)/3}return e}function o(t,e,i){l?t.addEventListener(e,i):t.attachEvent("on"+e,i)}function a(t,e,i){l?t.removeEventListener(e,i):t.detachEvent("on"+e,i)}var s=i(21),l="undefined"!=typeof window&&!!window.addEventListener,h=l?function(t){t.preventDefault(),t.stopPropagation(),t.cancelBubble=!0}:function(t){t.returnValue=!1,t.cancelBubble=!0};t.exports={normalizeEvent:r,addEventListener:o,removeEventListener:a,stop:h,Dispatcher:s}},function(t,e,i){"use strict";var n=i(3),r=i(1);i(51),i(95),i(2).extendComponentView({type:"grid",render:function(t,e){this.group.removeAll(),t.get("show")&&this.group.add(new n.Rect({shape:t.coordinateSystem.getRect(),style:r.defaults({fill:t.get("backgroundColor")},t.getItemStyle()),silent:!0}))}})},function(t,e,i){function n(t){t=t||{},a.call(this,t);for(var e in t)t.hasOwnProperty(e)&&"style"!==e&&(this[e]=t[e]);this.style=new o(t.style),this._rect=null,this.__clipPaths=[]}var r=i(1),o=i(141),a=i(55),s=i(66);n.prototype={constructor:n,type:"displayable",__dirty:!0,invisible:!1,z:0,z2:0,zlevel:0,draggable:!1,dragging:!1,silent:!1,culling:!1,cursor:"pointer",rectHover:!1,beforeBrush:function(t){},afterBrush:function(t){},brush:function(t){},getBoundingRect:function(){},contain:function(t,e){return this.rectContain(t,e)},traverse:function(t,e){t.call(e,this)},rectContain:function(t,e){var i=this.transformCoordToLocal(t,e),n=this.getBoundingRect();return n.contain(i[0],i[1])},dirty:function(){this.__dirty=!0,this._rect=null,this.__zr&&this.__zr.refresh()},animateStyle:function(t){return this.animate("style",t)},attrKV:function(t,e){"style"!==t?a.prototype.attrKV.call(this,t,e):this.style.set(e)},setStyle:function(t,e){return this.style.set(t,e),this.dirty(),this}},r.inherits(n,a),r.mixin(n,s),t.exports=n},function(t,e,i){"use strict";function n(t){for(var e=0;e1){i=[];for(var o=0;r>o;o++)i[o]=n[e[o][0]]}else i=n.slice(0)}}return i}var h=i(14),c=i(31),u=i(1),d=i(7),f=i(28),p=d.getDataItemValue,g=d.converDataValue,m={cartesian2d:function(t,e,i){var n=i.getComponent("xAxis",e.get("xAxisIndex")),r=i.getComponent("yAxis",e.get("yAxisIndex")),o=n.get("type"),l=r.get("type"),h=[{name:"x",type:s(o),stackable:a(o)},{name:"y",type:s(l),stackable:a(l)}];return c(h,t,["x","y","z"]),{dimensions:h,categoryAxisModel:"category"===o?n:"category"===l?r:null}},polar:function(t,e,i){var n=e.get("polarIndex")||0,r=function(t){return t.get("polarIndex")===n},o=i.findComponents({mainType:"angleAxis",filter:r})[0],l=i.findComponents({mainType:"radiusAxis",filter:r})[0],h=l.get("type"),u=o.get("type"),d=[{name:"radius",type:s(h),stackable:a(h)},{name:"angle",type:s(u),stackable:a(u)}];return c(d,t,["radius","angle","value"]),{dimensions:d,categoryAxisModel:"category"===u?o:"category"===h?l:null}},geo:function(t,e,i){return{dimensions:c([{name:"lng"},{name:"lat"}],t,["lng","lat","value"])}}};t.exports=o},function(t,e,i){var n=i(4),r=i(9),o=i(32),a=Math.floor,s=Math.ceil,l=o.extend({type:"interval",_interval:0,setExtent:function(t,e){var i=this._extent;isNaN(t)||(i[0]=parseFloat(t)),isNaN(e)||(i[1]=parseFloat(e))},unionExtent:function(t){var e=this._extent;t[0]e[1]&&(e[1]=t[1]),l.prototype.setExtent.call(this,e[0],e[1])},getInterval:function(){return this._interval||this.niceTicks(),this._interval},setInterval:function(t){this._interval=t,this._niceExtent=this._extent.slice()},getTicks:function(){this._interval||this.niceTicks();var t=this._interval,e=this._extent,i=[],r=1e4;if(t){var o=this._niceExtent;e[0]r)return[];e[1]>o[1]&&i.push(e[1])}return i},getTicksLabels:function(){for(var t=[],e=this.getTicks(),i=0;ii&&(i=-i,e.reverse());var r=n.nice(i/t,!0),o=[n.round(s(e[0]/r)*r),n.round(a(e[1]/r)*r)];this._interval=r,this._niceExtent=o}},niceExtent:function(t,e,i){var r=this._extent;if(r[0]===r[1])if(0!==r[0]){var o=r[0]/2;r[0]-=o,r[1]+=o}else r[1]=1;var l=r[1]-r[0];isFinite(l)||(r[0]=0,r[1]=1),this.niceTicks(t);var h=this._interval;e||(r[0]=n.round(a(r[0]/h)*h)),i||(r[1]=n.round(s(r[1]/h)*h))}});l.create=function(){return new l},t.exports=l},function(t,e,i){function n(t){this.group=new o.Group,this._symbolCtor=t||a}function r(t,e,i){var n=t.getItemLayout(e);return n&&!isNaN(n[0])&&!isNaN(n[1])&&!(i&&i(e))&&"none"!==t.getItemVisual(e,"symbol")}var o=i(3),a=i(47),s=n.prototype;s.updateData=function(t,e){var i=this.group,n=t.hostModel,a=this._data,s=this._symbolCtor;t.diff(a).add(function(n){var o=t.getItemLayout(n);if(r(t,n,e)){var a=new s(t,n);a.attr("position",o),t.setItemGraphicEl(n,a),i.add(a)}}).update(function(l,h){var c=a.getItemGraphicEl(h),u=t.getItemLayout(l);return r(t,l,e)?(c?(c.updateData(t,l),o.updateProps(c,{position:u},n)):(c=new s(t,l),c.attr("position",u)),i.add(c),void t.setItemGraphicEl(l,c)):void i.remove(c)}).remove(function(t){var e=a.getItemGraphicEl(t);e&&e.fadeOut(function(){i.remove(e)})}).execute(),this._data=t},s.updateLayout=function(){var t=this._data;t&&t.eachItemGraphicEl(function(e,i){e.attr("position",t.getItemLayout(i))})},s.remove=function(t){var e=this.group,i=this._data;i&&(t?i.eachItemGraphicEl(function(t){t.fadeOut(function(){e.remove(t)})}):e.removeAll())},t.exports=n},function(t,e,i){function n(t){var e={};return c(["start","end","startValue","endValue"],function(i){e[i]=t[i]}),e}function r(t,e,i,n){null!=i[e]&&null==i[t]&&(n[t]=null)}var o=i(1),a=i(15),s=i(2),l=i(7),h=i(166),c=o.each,u=l.eachAxisDim,d=s.extendComponentModel({type:"dataZoom",dependencies:["xAxis","yAxis","zAxis","radiusAxis","angleAxis","series"],defaultOption:{zlevel:0,z:4,orient:null,xAxisIndex:null,yAxisIndex:null,angleAxisIndex:null,radiusAxisIndex:null,filterMode:"filter",throttle:100,start:0,end:100,startValue:null,endValue:null},init:function(t,e,i){this._dataIntervalByAxis={},this._dataInfo={},this._axisProxies={},this.textStyleModel;var r=n(t);this.mergeDefaultAndTheme(t,i),this.doInit(r)},mergeOption:function(t){var e=n(t);o.merge(this.option,t,!0),this.doInit(e)},doInit:function(t){var e=this.option;a.canvasSupported||(e.realtime=!1),r("start","startValue",t,e),r("end","endValue",t,e),this.textStyleModel=this.getModel("textStyle"),this._resetTarget(),this._giveAxisProxies()},_giveAxisProxies:function(){var t=this._axisProxies;this.eachTargetAxis(function(e,i,n,r){var o=this.dependentModels[e.axis][i],a=o.__dzAxisProxy||(o.__dzAxisProxy=new h(e.name,i,this,r));t[e.name+"_"+i]=a},this)},_resetTarget:function(){var t=this.option,e=this._judgeAutoMode();u(function(e){var i=e.axisIndex;t[i]=l.normalizeToArray(t[i])},this),"axisIndex"===e?this._autoSetAxisIndex():"orient"===e&&this._autoSetOrient()},_judgeAutoMode:function(){var t=this.option,e=!1;u(function(i){null!=t[i.axisIndex]&&(e=!0)},this);var i=t.orient;return null==i&&e?"orient":e?void 0:(null==i&&(t.orient="horizontal"),"axisIndex")},_autoSetAxisIndex:function(){var t=!0,e=this.get("orient",!0),i=this.option;if(t){var n="vertical"===e?{dim:"y",axisIndex:"yAxisIndex",axis:"yAxis"}:{dim:"x",axisIndex:"xAxisIndex",axis:"xAxis"};this.dependentModels[n.axis].length&&(i[n.axisIndex]=[0],t=!1)}t&&u(function(e){if(t){var n=[],r=this.dependentModels[e.axis];if(r.length&&!n.length)for(var o=0,a=r.length;a>o;o++)"category"===r[o].get("type")&&n.push(o);i[e.axisIndex]=n,n.length&&(t=!1)}},this),t&&this.ecModel.eachSeries(function(t){this._isSeriesHasAllAxesTypeOf(t,"value")&&u(function(e){var n=i[e.axisIndex],r=t.get(e.axisIndex);o.indexOf(n,r)<0&&n.push(r)})},this)},_autoSetOrient:function(){var t;this.eachTargetAxis(function(e){!t&&(t=e.name)},this),this.option.orient="y"===t?"vertical":"horizontal"},_isSeriesHasAllAxesTypeOf:function(t,e){var i=!0;return u(function(n){var r=t.get(n.axisIndex),o=this.dependentModels[n.axis][r];o&&o.get("type")===e||(i=!1)},this),i},getFirstTargetAxisModel:function(){var t;return u(function(e){if(null==t){var i=this.get(e.axisIndex);i.length&&(t=this.dependentModels[e.axis][i[0]])}},this),t},eachTargetAxis:function(t,e){var i=this.ecModel;u(function(n){c(this.get(n.axisIndex),function(r){t.call(e,n,r,this,i)},this)},this)},getAxisProxy:function(t,e){return this._axisProxies[t+"_"+e]},setRawRange:function(t){c(["start","end","startValue","endValue"],function(e){this.option[e]=t[e]},this)},getPercentRange:function(){var t=this.findRepresentativeAxisProxy();return t?t.getDataPercentWindow():void 0},getValueRange:function(t,e){if(null!=t||null!=e)return this.getAxisProxy(t,e).getDataValueWindow();var i=this.findRepresentativeAxisProxy();return i?i.getDataValueWindow():void 0},findRepresentativeAxisProxy:function(){var t=this._axisProxies;for(var e in t)if(t.hasOwnProperty(e)&&t[e].hostedBy(this))return t[e];for(var e in t)if(t.hasOwnProperty(e)&&!t[e].hostedBy(this))return t[e]}});t.exports=d},function(t,e,i){var n=i(54);t.exports=n.extend({type:"dataZoom",render:function(t,e,i,n){this.dataZoomModel=t,this.ecModel=e,this.api=i},getTargetInfo:function(){function t(t,e,i,n){for(var r,o=0;o=0&&i.push(t)}),i}t.topologicalTravel=function(t,e,r,o){function a(t){h[t].entryCount--,0===h[t].entryCount&&c.push(t)}function s(t){u[t]=!0,a(t)}if(t.length){var l=i(e),h=l.graph,c=l.noEntryList,u={};for(n.each(t,function(t){u[t]=!0});c.length;){var d=c.pop(),f=h[d],p=!!u[d];p&&(r.call(o,d,f.originalDeps.slice()),delete u[d]),n.each(f.successor,p?s:a)}n.each(u,function(){throw new Error("Circle dependency may exists")})}}},t.exports=s},function(t,e){var i=1;"undefined"!=typeof window&&(i=Math.max(window.devicePixelRatio||1,1));var n={debugMode:0,devicePixelRatio:i};t.exports=n},function(t,e,i){function n(t,e){var i=t[1]-t[0],n=e,r=i/n/2;t[0]+=r,t[1]-=r}var r=i(4),o=r.linearMap,a=i(1),s=[0,1],l=function(t,e,i){this.dim=t,this.scale=e,this._extent=i||[0,0],this.inverse=!1,this.onBand=!1};l.prototype={constructor:l,contain:function(t){var e=this._extent,i=Math.min(e[0],e[1]),n=Math.max(e[0],e[1]);return t>=i&&n>=t},containData:function(t){return this.contain(this.dataToCoord(t))},getExtent:function(){var t=this._extent.slice();return t},getPixelPrecision:function(t){return r.getPixelPrecision(t||this.scale.getExtent(),this._extent)},setExtent:function(t,e){var i=this._extent;i[0]=t,i[1]=e},dataToCoord:function(t,e){var i=this._extent,r=this.scale;return t=r.normalize(t),this.onBand&&"ordinal"===r.type&&(i=i.slice(),n(i,r.count())),o(t,s,i,e)},coordToData:function(t,e){var i=this._extent,r=this.scale;this.onBand&&"ordinal"===r.type&&(i=i.slice(),n(i,r.count()));var a=o(t,i,s,e);return this.scale.scale(a)},getTicksCoords:function(){if(this.onBand){for(var t=this.getBands(),e=[],i=0;ia;a++)e.push([o*a/i+n,o*(a+1)/i+n]);return e},getBandWidth:function(){var t=this._extent,e=this.scale.getExtent(),i=e[1]-e[0]+(this.onBand?1:0),n=Math.abs(t[1]-t[0]);return Math.abs(n)/i}},t.exports=l},function(t,e){t.exports=function(t,e,i,n,r){n.eachRawSeriesByType(t,function(t){var r=t.getData(),o=t.get("symbol")||e,a=t.get("symbolSize");r.setVisual({legendSymbol:i||o,symbol:o,symbolSize:a}),n.isSeriesFiltered(t)||("function"==typeof a&&r.each(function(e){var i=t.getRawValue(e),n=t.getDataParams(e);r.setItemVisual(e,"symbolSize",a(i,n))}),r.each(function(t){var e=r.getItemModel(t),i=e.get("symbol",!0),n=e.get("symbolSize",!0);null!=i&&r.setItemVisual(t,"symbol",i),null!=n&&r.setItemVisual(t,"symbolSize",n)}))})}},function(t,e,i){var n=i(42);t.exports=function(){if(0!==n.debugMode)if(1==n.debugMode)for(var t in arguments)throw new Error(arguments[t]);else if(n.debugMode>1)for(var t in arguments)console.log(arguments[t])}},function(t,e,i){var n=i(35),r=i(8),o=i(1),a=i(60),s=i(139),l=new s(50),h=function(t){n.call(this,t)};h.prototype={constructor:h,type:"image",brush:function(t){var e,i=this.style,n=i.image;if(e="string"==typeof n?this._image:n,!e&&n){var r=l.get(n);if(!r)return e=new Image,e.onload=function(){e.onload=null;for(var t=0;t0?"top":"bottom",n="center"):c(o-u)?(r=i>0?"bottom":"top",n="center"):(r="middle",n=o>0&&u>o?i>0?"right":"left":i>0?"left":"right"),{rotation:o,textAlign:n,verticalAlign:r}}function r(t,e,i){var n,r,o=h(-t.rotation),a=i[0]>i[1],s="start"===e&&!a||"start"!==e&&a;return c(o-u/2)?(r=s?"bottom":"top",n="center"):c(o-1.5*u)?(r=s?"top":"bottom",n="center"):(r="middle",n=1.5*u>o&&o>u/2?s?"left":"right":s?"right":"left"),{rotation:o,textAlign:n,verticalAlign:r}}var o=i(1),a=i(3),s=i(12),l=i(4),h=l.remRadian,c=l.isRadianAroundZero,u=Math.PI,d=function(t,e){this.opt=e,this.axisModel=t,o.defaults(e,{labelOffset:0,nameDirection:1,tickDirection:1,labelDirection:1,silent:!0}),this.group=new a.Group({position:e.position.slice(),rotation:e.rotation})};d.prototype={constructor:d,hasBuilder:function(t){return!!f[t]},add:function(t){f[t].call(this)},getGroup:function(){return this.group}};var f={axisLine:function(){var t=this.opt,e=this.axisModel;if(e.get("axisLine.show")){var i=this.axisModel.axis.getExtent();this.group.add(new a.Line({shape:{x1:i[0],y1:0,x2:i[1],y2:0},style:o.extend({lineCap:"round"},e.getModel("axisLine.lineStyle").getLineStyle()),strokeContainThreshold:t.strokeContainThreshold,silent:!!t.silent,z2:1}))}},axisTick:function(){var t=this.axisModel;if(t.get("axisTick.show")){for(var e=t.axis,i=t.getModel("axisTick"),n=this.opt,r=i.getModel("lineStyle"),o=i.get("length"),s=g(i,n.labelInterval),l=e.getTicksCoords(),h=[],c=0;cu[1]?-1:1,f=["start"===s?u[0]-d*c:"end"===s?u[1]+d*c:(u[0]+u[1])/2,"middle"===s?t.labelOffset+l*c:0];o="middle"===s?n(t,t.rotation,l):r(t,s,u),this.group.add(new a.Text({style:{text:i,textFont:h.getFont(),fill:h.getTextColor()||e.get("axisLine.lineStyle.color"),textAlign:o.textAlign,textVerticalAlign:o.verticalAlign},position:f,rotation:o.rotation,silent:!0,z2:1}))}}},p=d.ifIgnoreOnTick=function(t,e,i){var n,r=t.scale;return"ordinal"===r.type&&("function"==typeof i?(n=r.getTicks()[e],!i(n,r.getLabel(n))):e%(i+1))},g=d.getInterval=function(t,e){var i=t.get("interval");return null!=i&&"auto"!=i||(i=e),i};t.exports=d},function(t,e,i){function n(t){return a.isObject(t)&&null!=t.value?t.value:t}function r(){return"category"===this.get("type")&&a.map(this.get("data"),n)}function o(){return s.getFormattedLabels(this.axis,this.get("axisLabel.formatter"))}var a=i(1),s=i(23);t.exports={getFormattedLabels:o,getCategories:r}},function(t,e,i){"use strict";function n(t,e){return e.type||(e.data?"category":"value")}var r=i(10),o=i(1),a=i(61),s=r.extend({type:"cartesian2dAxis",axis:null,init:function(){s.superApply(this,"init",arguments),this._resetRange()},mergeOption:function(){s.superApply(this,"mergeOption",arguments),this._resetRange()},restoreData:function(){s.superApply(this,"restoreData",arguments),this._resetRange()},setRange:function(t,e){this.option.rangeStart=t,this.option.rangeEnd=e},getMin:function(){var t=this.option;return null!=t.rangeStart?t.rangeStart:t.min},getMax:function(){var t=this.option;return null!=t.rangeEnd?t.rangeEnd:t.max},getNeedCrossZero:function(){var t=this.option;return null!=t.rangeStart||null!=t.rangeEnd?!1:!t.scale},_resetRange:function(){this.option.rangeStart=this.option.rangeEnd=null}});o.merge(s.prototype,i(49));var l={gridIndex:0};a("x",s,n,l),a("y",s,n,l),t.exports=s},function(t,e,i){function n(t,e,i){return i.getComponent("grid",t.get("gridIndex"))===e}function r(t){var e,i=t.model,n=i.getFormattedLabels(),r=1,o=n.length;o>40&&(r=Math.ceil(o/40));for(var a=0;o>a;a+=r)if(!t.isLabelIgnored(a)){var s=i.getTextRect(n[a]);e?e.union(s):e=s}return e}function o(t,e,i){this._coordsMap={},this._coordsList=[],this._axesMap={},this._axesList=[],this._initCartesian(t,e,i),this._model=t}function a(t,e){var i=t.getExtent(),n=i[0]+i[1];t.toGlobalCoord="x"===t.dim?function(t){return t+e}:function(t){return n-t+e},t.toLocalCoord="x"===t.dim?function(t){return t-e}:function(t){return n-t+e}}var s=i(11),l=i(23),h=i(1),c=i(106),u=i(104),d=h.each,f=l.ifAxisCrossZero,p=l.niceScaleExtent;i(107);var g=o.prototype;g.type="grid",g.getRect=function(){return this._rect},g.update=function(t,e){function i(t){var e=n[t];for(var i in e){var r=e[i];if(r&&("category"===r.type||!f(r)))return!0}return!1}var n=this._axesMap;this._updateScale(t,this._model),d(n.x,function(t){p(t,t.model)}),d(n.y,function(t){p(t,t.model)}),d(n.x,function(t){i("y")&&(t.onZero=!1)}),d(n.y,function(t){i("x")&&(t.onZero=!1)}),this.resize(this._model,e)},g.resize=function(t,e){function i(){d(o,function(t){var e=t.isHorizontal(),i=e?[0,n.width]:[0,n.height],r=t.inverse?1:0;t.setExtent(i[r],i[1-r]),a(t,e?n.x:n.y)})}var n=s.getLayoutRect(t.getBoxLayoutParams(),{width:e.getWidth(),height:e.getHeight()});this._rect=n;var o=this._axesList;i(),t.get("containLabel")&&(d(o,function(t){if(!t.model.get("axisLabel.inside")){var e=r(t);if(e){var i=t.isHorizontal()?"height":"width",o=t.model.get("axisLabel.margin");n[i]-=e[i]+o,"top"===t.position?n.y+=e.height+o:"left"===t.position&&(n.x+=e.width+o)}}}),i())},g.getAxis=function(t,e){var i=this._axesMap[t];if(null!=i){if(null==e)for(var n in i)return i[n];return i[e]}},g.getCartesian=function(t,e){var i="x"+t+"y"+e;return this._coordsMap[i]},g._initCartesian=function(t,e,i){function r(i){return function(r,h){if(n(r,t,e)){var c=r.get("position");"x"===i?("top"!==c&&"bottom"!==c&&(c="bottom"),o[c]&&(c="top"===c?"bottom":"top")):("left"!==c&&"right"!==c&&(c="left"),o[c]&&(c="left"===c?"right":"left")),o[c]=!0;var d=new u(i,l.createScaleByModel(r),[0,0],r.get("type"),c),f="category"===d.type;d.onBand=f&&r.get("boundaryGap"),d.inverse=r.get("inverse"),d.onZero=r.get("axisLine.onZero"),r.axis=d,d.model=r,d.index=h,this._axesList.push(d),a[i][h]=d,s[i]++}}}var o={left:!1,right:!1,top:!1,bottom:!1},a={x:{},y:{}},s={x:0,y:0};return e.eachComponent("xAxis",r("x"),this),e.eachComponent("yAxis",r("y"),this),s.x&&s.y?(this._axesMap=a,void d(a.x,function(t,e){d(a.y,function(i,n){var r="x"+e+"y"+n,o=new c(r);o.grid=this,this._coordsMap[r]=o,this._coordsList.push(o),o.addAxis(t),o.addAxis(i); +},this)},this)):(this._axesMap={},void(this._axesList=[]))},g._updateScale=function(t,e){function i(t,e,i){d(i.coordDimToDataDim(e.dim),function(i){e.scale.unionExtent(t.getDataExtent(i,"ordinal"!==e.scale.type))})}h.each(this._axesList,function(t){t.scale.setExtent(1/0,-(1/0))}),t.eachSeries(function(r){if("cartesian2d"===r.get("coordinateSystem")){var o=r.get("xAxisIndex"),a=r.get("yAxisIndex"),s=t.getComponent("xAxis",o),l=t.getComponent("yAxis",a);if(!n(s,e,t)||!n(l,e,t))return;var h=this.getCartesian(o,a),c=r.getData(),u=h.getAxis("x"),d=h.getAxis("y");"list"===c.type&&(i(c,u,r),i(c,d,r))}},this)},o.create=function(t,e){var i=[];return t.eachComponent("grid",function(n,r){var a=new o(n,t,e);a.name="grid_"+r,a.resize(n,e),n.coordinateSystem=a,i.push(a)}),t.eachSeries(function(e){if("cartesian2d"===e.get("coordinateSystem")){var n=e.get("xAxisIndex"),r=t.getComponent("xAxis",n),o=i[r.get("gridIndex")];e.coordinateSystem=o.getCartesian(n,e.get("yAxisIndex"))}}),i},o.dimensions=c.prototype.dimensions,i(28).register("cartesian2d",o),t.exports=o},function(t,e){"use strict";function i(t){return t}function n(t,e,n,r){this._old=t,this._new=e,this._oldKeyGetter=n||i,this._newKeyGetter=r||i}function r(t,e,i){for(var n=0;nt;t++)this._add&&this._add(h[t]);else this._add&&this._add(h)}}},t.exports=n},function(t,e){t.exports=function(t,e,i){e.eachSeriesByType(t,function(t){var e=t.getData(),i=t.coordinateSystem,n=i.dimensions;e.each(n,function(t,n,r){var o;o=isNaN(t)||isNaN(n)?[NaN,NaN]:i.dataToPoint([t,n]),e.setItemLayout(r,o)},!0)})}},function(t,e,i){var n=i(26),r=i(41),o=i(20),a=function(){this.group=new n,this.uid=r.getUID("viewComponent")};a.prototype={constructor:a,init:function(t,e){},render:function(t,e,i,n){},dispose:function(){}};var s=a.prototype;s.updateView=s.updateLayout=s.updateVisual=function(t,e,i,n){},o.enableClassExtend(a),o.enableClassManagement(a,{registerWhenExtend:!0}),t.exports=a},function(t,e,i){"use strict";var n=i(58),r=i(21),o=i(77),a=i(153),s=i(1),l=function(t){o.call(this,t),r.call(this,t),a.call(this,t),this.id=t.id||n()};l.prototype={type:"element",name:"",__zr:null,ignore:!1,clipPath:null,drift:function(t,e){switch(this.draggable){case"horizontal":e=0;break;case"vertical":t=0}var i=this.transform;i||(i=this.transform=[1,0,0,1,0,0]),i[4]+=t,i[5]+=e,this.decomposeTransform(),this.dirty()},beforeUpdate:function(){},afterUpdate:function(){},update:function(){this.updateTransform()},traverse:function(t,e){},attrKV:function(t,e){if("position"===t||"scale"===t||"origin"===t){if(e){var i=this[t];i||(i=this[t]=[]),i[0]=e[0],i[1]=e[1]}}else this[t]=e},hide:function(){this.ignore=!0,this.__zr&&this.__zr.refresh()},show:function(){this.ignore=!1,this.__zr&&this.__zr.refresh()},attr:function(t,e){if("string"==typeof t)this.attrKV(t,e);else if(s.isObject(t))for(var i in t)t.hasOwnProperty(i)&&this.attrKV(i,t[i]);return this.dirty(),this},setClipPath:function(t){var e=this.__zr;e&&t.addSelfToZr(e),this.clipPath&&this.clipPath!==t&&this.removeClipPath(),this.clipPath=t,t.__zr=e,t.__clipTarget=this,this.dirty()},removeClipPath:function(){var t=this.clipPath;t&&(t.__zr&&t.removeSelfFromZr(t.__zr),t.__zr=null,t.__clipTarget=null,this.clipPath=null,this.dirty())},addSelfToZr:function(t){this.__zr=t;var e=this.animators;if(e)for(var i=0;i.5?e:t}function s(t,e,i,n,r){var a=t.length;if(1==r)for(var s=0;a>s;s++)n[s]=o(t[s],e[s],i);else for(var l=t[0].length,s=0;a>s;s++)for(var h=0;l>h;h++)n[s][h]=o(t[s][h],e[s][h],i)}function l(t,e,i){var n=t.length,r=e.length;if(n!==r){var o=n>r;if(o)t.length=r;else for(var a=n;r>a;a++)t.push(1===i?e[a]:x.call(e[a]))}}function h(t,e,i){if(t===e)return!0;var n=t.length;if(n!==e.length)return!1;if(1===i){for(var r=0;n>r;r++)if(t[r]!==e[r])return!1}else for(var o=t[0].length,r=0;n>r;r++)for(var a=0;o>a;a++)if(t[r][a]!==e[r][a])return!1;return!0}function c(t,e,i,n,r,o,a,s,l){var h=t.length;if(1==l)for(var c=0;h>c;c++)s[c]=u(t[c],e[c],i[c],n[c],r,o,a);else for(var d=t[0].length,c=0;h>c;c++)for(var f=0;d>f;f++)s[c][f]=u(t[c][f],e[c][f],i[c][f],n[c][f],r,o,a)}function u(t,e,i,n,r,o,a){var s=.5*(i-t),l=.5*(n-e);return(2*(e-i)+s+l)*a+(-3*(e-i)-2*s-l)*o+s*r+e}function d(t){if(y(t)){var e=t.length;if(y(t[0])){for(var i=[],n=0;e>n;n++)i.push(x.call(t[n]));return i}return x.call(t)}return t}function f(t){return t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.floor(t[2]),"rgba("+t.join(",")+")"}function p(t,e,i,n,r){var d=t._getter,p=t._setter,v="spline"===e,x=n.length;if(x){var _,b=n[0].value,w=y(b),M=!1,S=!1,A=w&&y(b[0])?2:1;n.sort(function(t,e){return t.time-e.time}),_=n[x-1].time;for(var T=[],C=[],I=n[0].value,k=!0,D=0;x>D;D++){T.push(n[D].time/_);var L=n[D].value;if(w&&h(L,I,A)||!w&&L===I||(k=!1),I=L,"string"==typeof L){var P=m.parse(L);P?(L=P,M=!0):S=!0}C.push(L)}if(!k){if(w){for(var z=C[x-1],D=0;x-1>D;D++)l(C[D],z,A);l(d(t._target,r),z,A)}var O,E,R,B,N,V,F=0,G=0;if(M)var Z=[0,0,0,0];var W=function(t,e){var i;if(G>e){for(O=Math.min(F+1,x-1),i=O;i>=0&&!(T[i]<=e);i--);i=Math.min(i,x-2)}else{for(i=F;x>i&&!(T[i]>e);i++);i=Math.min(i-1,x-2)}F=i,G=e;var n=T[i+1]-T[i];if(0!==n)if(E=(e-T[i])/n,v)if(B=C[i],R=C[0===i?i:i-1],N=C[i>x-2?x-1:i+1],V=C[i>x-3?x-1:i+2],w)c(R,B,N,V,E,E*E,E*E*E,d(t,r),A);else{var l;if(M)l=c(R,B,N,V,E,E*E,E*E*E,Z,1),l=f(Z);else{if(S)return a(B,N,E);l=u(R,B,N,V,E,E*E,E*E*E)}p(t,r,l)}else if(w)s(C[i],C[i+1],E,d(t,r),A);else{var l;if(M)s(C[i],C[i+1],E,Z,1),l=f(Z);else{if(S)return a(C[i],C[i+1],E);l=o(C[i],C[i+1],E)}p(t,r,l)}},H=new g({target:t._target,life:_,loop:t._loop,delay:t._delay,onframe:W,ondestroy:i});return e&&"spline"!==e&&(H.easing=e),H}}}var g=i(131),m=i(22),v=i(1),y=v.isArrayLike,x=Array.prototype.slice,_=function(t,e,i,o){this._tracks={},this._target=t,this._loop=e||!1,this._getter=i||n,this._setter=o||r,this._clipCount=0,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]};_.prototype={when:function(t,e){var i=this._tracks;for(var n in e){if(!i[n]){i[n]=[];var r=this._getter(this._target,n);if(null==r)continue;0!==t&&i[n].push({time:0,value:d(r)})}i[n].push({time:t,value:e[n]})}return this},during:function(t){return this._onframeList.push(t),this},_doneCallback:function(){this._tracks={},this._clipList.length=0;for(var t=this._doneList,e=t.length,i=0;e>i;i++)t[i].call(this)},start:function(t){var e,i=this,n=0,r=function(){n--,n||i._doneCallback()};for(var o in this._tracks){var a=p(this,t,r,this._tracks[o],o);a&&(this._clipList.push(a),n++,this.animation&&this.animation.addClip(a),e=a)}if(e){var s=e.onframe;e.onframe=function(t,e){s(t,e);for(var n=0;nt&&(t+=i),t}}},function(t,e){var i=2311;t.exports=function(){return"zr_"+i++}},function(t,e,i){var n=i(143),r=i(142);t.exports={buildPath:function(t,e,i){var o=e.points,a=e.smooth;if(o&&o.length>=2){if(a&&"spline"!==a){var s=r(o,a,i,e.smoothConstraint);t.moveTo(o[0][0],o[0][1]);for(var l=o.length,h=0;(i?l:l-1)>h;h++){var c=s[2*h],u=s[2*h+1],d=o[(h+1)%l];t.bezierCurveTo(c[0],c[1],u[0],u[1],d[0],d[1])}}else{"spline"===a&&(o=n(o,i)),t.moveTo(o[0][0],o[0][1]);for(var h=1,f=o.length;f>h;h++)t.lineTo(o[h][0],o[h][1])}i&&t.closePath()}}}},function(t,e){t.exports={buildPath:function(t,e){var i,n,r,o,a=e.x,s=e.y,l=e.width,h=e.height,c=e.r;0>l&&(a+=l,l=-l),0>h&&(s+=h,h=-h),"number"==typeof c?i=n=r=o=c:c instanceof Array?1===c.length?i=n=r=o=c[0]:2===c.length?(i=r=c[0],n=o=c[1]):3===c.length?(i=c[0],n=o=c[1],r=c[2]):(i=c[0],n=c[1],r=c[2],o=c[3]):i=n=r=o=0;var u;i+n>l&&(u=i+n,i*=l/u,n*=l/u),r+o>l&&(u=r+o,r*=l/u,o*=l/u),n+r>h&&(u=n+r,n*=h/u,r*=h/u),i+o>h&&(u=i+o,i*=h/u,o*=h/u),t.moveTo(a+i,s),t.lineTo(a+l-n,s),0!==n&&t.quadraticCurveTo(a+l,s,a+l,s+n),t.lineTo(a+l,s+h-r),0!==r&&t.quadraticCurveTo(a+l,s+h,a+l-r,s+h),t.lineTo(a+o,s+h),0!==o&&t.quadraticCurveTo(a,s+h,a,s+h-o),t.lineTo(a,s+i),0!==i&&t.quadraticCurveTo(a,s,a+i,s)}}},function(t,e,i){var n=i(72),r=i(1),o=i(10),a=i(11),s=["value","category","time","log"];t.exports=function(t,e,i,l){r.each(s,function(o){e.extend({type:t+"Axis."+o,mergeDefaultAndTheme:function(e,n){var s=this.layoutMode,l=s?a.getLayoutParams(e):{},h=n.getTheme();r.merge(e,h.get(o+"Axis")),r.merge(e,this.getDefaultOption()),e.type=i(t,e),s&&a.mergeLayoutParam(e,l,s)},defaultOption:r.mergeAll([{},n[o+"Axis"],l],!0)})}),o.registerSubTypeDefaulter(t+"Axis",r.curry(i,t))}},function(t,e){t.exports=function(t,e){var i=e.findComponents({mainType:"legend"});i&&i.length&&e.eachSeriesByType(t,function(t){var e=t.getData();e.filterSelf(function(t){for(var n=e.getName(t),r=0;rv;v++)y[v]=b(t,i,o,h,y[v]);for(w=_(e,n,l,c,x),v=0;w>v;v++)x[v]=b(e,n,l,c,x[v]);y.push(t,h),x.push(e,c),f=a.apply(null,y),p=s.apply(null,y),g=a.apply(null,x),m=s.apply(null,x),u[0]=f,u[1]=g,d[0]=p,d[1]=m},o.fromQuadratic=function(t,e,i,n,o,l,h,c){var u=r.quadraticExtremum,d=r.quadraticAt,f=s(a(u(t,i,o),1),0),p=s(a(u(e,n,l),1),0),g=d(t,i,o,f),m=d(e,n,l,p);h[0]=a(t,o,g),h[1]=a(e,l,m),c[0]=s(t,o,g),c[1]=s(e,l,m)},o.fromArc=function(t,e,i,r,o,a,s,p,g){var m=n.min,v=n.max,y=Math.abs(o-a);if(1e-4>y%f&&y>1e-4)return p[0]=t-i,p[1]=e-r,g[0]=t+i,void(g[1]=e+r);if(c[0]=h(o)*i+t,c[1]=l(o)*r+e,u[0]=h(a)*i+t,u[1]=l(a)*r+e,m(p,c,u),v(g,c,u),o%=f,0>o&&(o+=f),a%=f,0>a&&(a+=f),o>a&&!s?a+=f:a>o&&s&&(o+=f),s){var x=a;a=o,o=x}for(var _=0;a>_;_+=Math.PI/2)_>o&&(d[0]=h(_)*i+t,d[1]=l(_)*r+e,m(p,d,p),v(g,d,g))},t.exports=o},function(t,e,i){var n=i(35),r=i(1),o=i(17),a=function(t){n.call(this,t)};a.prototype={constructor:a,type:"text",brush:function(t){var e=this.style,i=e.x||0,n=e.y||0,r=e.text,a=e.fill,s=e.stroke;if(null!=r&&(r+=""),r){if(t.save(),this.style.bind(t),this.setTransform(t),a&&(t.fillStyle=a),s&&(t.strokeStyle=s),t.font=e.textFont||e.font,t.textAlign=e.textAlign,e.textVerticalAlign){var l=o.getBoundingRect(r,t.font,e.textAlign,"top");switch(t.textBaseline="top",e.textVerticalAlign){case"middle":n-=l.height/2;break;case"bottom":n-=l.height}}else t.textBaseline=e.textBaseline;for(var h=o.measureText("国",t.font).width,c=r.split("\n"),u=0;u=0?parseFloat(t)/100*e:parseFloat(t):t}function r(t,e){t.transform(e[0],e[1],e[2],e[3],e[4],e[5])}var o=i(17),a=i(8),s=new a,l=function(){};l.prototype={constructor:l,drawRectText:function(t,e,i){var a=this.style,l=a.text;if(null!=l&&(l+=""),l){var h,c,u=a.textPosition,d=a.textDistance,f=a.textAlign,p=a.textFont||a.font,g=a.textBaseline,m=a.textVerticalAlign;i=i||o.getBoundingRect(l,p,f,g);var v=this.transform,y=this.invTransform;if(v&&(s.copy(e),s.applyTransform(v),e=s,r(t,y)),u instanceof Array)h=e.x+n(u[0],e.width),c=e.y+n(u[1],e.height),f=f||"left",g=g||"top";else{var x=o.adjustTextPositionOnRect(u,e,i,d);h=x.x,c=x.y,f=f||x.textAlign,g=g||x.textBaseline}if(t.textAlign=f,m){switch(m){case"middle":c-=i.height/2;break;case"bottom":c-=i.height}t.textBaseline="top"}else t.textBaseline=g;var _=a.textFill,b=a.textStroke;_&&(t.fillStyle=_),b&&(t.strokeStyle=b),t.font=p,t.shadowColor=a.textShadowColor,t.shadowBlur=a.textShadowBlur,t.shadowOffsetX=a.textShadowOffsetX,t.shadowOffsetY=a.textShadowOffsetY;for(var w=l.split("\n"),M=0;M0?1.1:1/1.1;l.call(this,t,e,t.offsetX,t.offsetY)}function s(t){if(!f.isTaken("globalPan",this._zr)){d.stop(t.event);var e=t.pinchScale>1?1.1:1/1.1;l.call(this,t,e,t.pinchX,t.pinchY)}}function l(t,e,i,n){var r=this.rect;if(r&&r.contain(i,n)){var o=this.target;if(o){var a=o.position,s=o.scale,l=this._zoom=this._zoom||1;l*=e;var h=l/this._zoom;this._zoom=l,a[0]-=(i-a[0])*(h-1),a[1]-=(n-a[1])*(h-1),s[0]*=h,s[1]*=h,o.dirty()}this.trigger("zoom",e,i,n)}}function h(t,e,i){this.target=e,this.rect=i,this._zr=t;var l=u.bind,h=l(n,this),d=l(r,this),f=l(o,this),p=l(a,this),g=l(s,this);c.call(this),this.enable=function(e){this.disable(),null==e&&(e=!0),e!==!0&&"move"!==e&&"pan"!==e||(t.on("mousedown",h),t.on("mousemove",d),t.on("mouseup",f)),e!==!0&&"scale"!==e&&"zoom"!==e||(t.on("mousewheel",p),t.on("pinch",g))},this.disable=function(){t.off("mousedown",h),t.off("mousemove",d),t.off("mouseup",f),t.off("mousewheel",p),t.off("pinch",g)},this.dispose=this.disable,this.isDragging=function(){return this._dragging},this.isPinching=function(){return this._pinching}}var c=i(21),u=i(1),d=i(33),f=i(101);u.mixin(h,c),t.exports=h},function(t,e){t.exports=function(t,e,i,n,r){function o(t,e,i){var n=e.length?e.slice():[e,e];return e[0]>e[1]&&n.reverse(),0>t&&n[0]+t0&&n[1]+t>i[1]&&(t=i[1]-n[1]),t}return t?("rigid"===n?(t=o(t,e,i),e[0]+=t,e[1]+=t):(t=o(t,e[r],i),e[r]+=t,"push"===n&&e[0]>e[1]&&(e[1-r]=e[r])),e):e}},function(t,e,i){var n=i(1),r={show:!0,zlevel:0,z:0,inverse:!1,name:"",nameLocation:"end",nameTextStyle:{},nameGap:15,axisLine:{show:!0,onZero:!0,lineStyle:{color:"#333",width:1,type:"solid"}},axisTick:{show:!0,inside:!1,length:5,lineStyle:{color:"#333",width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{color:"#333",fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}}},o=n.merge({boundaryGap:!0,axisTick:{interval:"auto"},axisLabel:{interval:"auto"}},r),a=n.defaults({boundaryGap:[0,0],splitNumber:5},r),s=n.defaults({scale:!0,min:"dataMin",max:"dataMax"},a),l=n.defaults({},a);l.scale=!0,t.exports={categoryAxis:o,valueAxis:a,timeAxis:s,logAxis:l}},,function(t,e,i){var n=i(16);t.exports=function(t,e,i){function r(t){var r=[e,"normal","color"],o=i.get("color"),a=t.getData(),s=t.get(r)||o[t.seriesIndex%o.length];a.setVisual("color",s),i.isSeriesFiltered(t)||("function"!=typeof s||s instanceof n||a.each(function(e){a.setItemVisual(e,"color",s(t.getDataParams(e)))}),a.each(function(t){var e=a.getItemModel(t),i=e.get(r,!0);null!=i&&a.setItemVisual(t,"color",i)}))}t?i.eachSeriesByType(t,r):i.eachSeries(r)}},function(t,e){t.exports=function(t,e,i,n,r,o){if(o>e&&o>n||e>o&&n>o)return 0;if(n===e)return 0;var a=e>n?1:-1,s=(o-e)/(n-e),l=s*(i-t)+t;return l>r?a:0}},function(t,e,i){"use strict";var n=i(1),r=i(16),o=function(t,e,i,n,o){this.x=null==t?0:t,this.y=null==e?0:e,this.x2=null==i?1:i,this.y2=null==n?0:n,r.call(this,o)};o.prototype={constructor:o,type:"linear",updateCanvasGradient:function(t,e){for(var i=t.getBoundingRect(),n=this.x*i.width+i.x,r=this.x2*i.width+i.x,o=this.y*i.height+i.y,a=this.y2*i.height+i.y,s=e.createLinearGradient(n,o,r,a),l=this.colorStops,h=0;hs||-s>t}var r=i(19),o=i(5),a=r.identity,s=5e-5,l=function(t){t=t||{},t.position||(this.position=[0,0]),null==t.rotation&&(this.rotation=0),t.scale||(this.scale=[1,1]),this.origin=this.origin||null},h=l.prototype;h.transform=null,h.needLocalTransform=function(){return n(this.rotation)||n(this.position[0])||n(this.position[1])||n(this.scale[0]-1)||n(this.scale[1]-1)},h.updateTransform=function(){var t=this.parent,e=t&&t.transform,i=this.needLocalTransform(),n=this.transform;return i||e?(n=n||r.create(),i?this.getLocalTransform(n):a(n),e&&(i?r.mul(n,t.transform,n):r.copy(n,t.transform)),this.transform=n,this.invTransform=this.invTransform||r.create(),void r.invert(this.invTransform,n)):void(n&&a(n))},h.getLocalTransform=function(t){t=t||[],a(t);var e=this.origin,i=this.scale,n=this.rotation,o=this.position;return e&&(t[4]-=e[0],t[5]-=e[1]),r.scale(t,t,i),n&&r.rotate(t,t,n),e&&(t[4]+=e[0],t[5]+=e[1]),t[4]+=o[0],t[5]+=o[1],t},h.setTransform=function(t){var e=this.transform;e&&t.transform(e[0],e[1],e[2],e[3],e[4],e[5])};var c=[];h.decomposeTransform=function(){if(this.transform){var t=this.parent,e=this.transform;t&&t.transform&&(r.mul(c,t.invTransform,e),e=c);var i=e[0]*e[0]+e[1]*e[1],o=e[2]*e[2]+e[3]*e[3],a=this.position,s=this.scale;n(i-1)&&(i=Math.sqrt(i)),n(o-1)&&(o=Math.sqrt(o)),e[0]<0&&(i=-i),e[3]<0&&(o=-o),a[0]=e[4],a[1]=e[5],s[0]=i,s[1]=o,this.rotation=Math.atan2(-e[1]/o,e[0]/i)}},h.transformCoordToLocal=function(t,e){var i=[t,e],n=this.invTransform;return n&&o.applyTransform(i,i,n),i},h.transformCoordToGlobal=function(t,e){var i=[t,e],n=this.transform;return n&&o.applyTransform(i,i,n),i},t.exports=l},function(t,e,i){"use strict";function n(t){r.each(o,function(e){this[e]=r.bind(t[e],t)},this)}var r=i(1),o=["getDom","getZr","getWidth","getHeight","dispatchAction","on","off","getDataURL","getConnectedDataURL","getModel","getOption"];t.exports=n},function(t,e,i){var n=i(1);i(51),i(80),i(81);var r=i(109),o=i(2);o.registerLayout(n.curry(r,"bar")),o.registerVisualCoding("chart",function(t){t.eachSeriesByType("bar",function(t){var e=t.getData();e.setVisual("legendSymbol","roundRect")})}),i(34)},function(t,e,i){"use strict";var n=i(13),r=i(36);t.exports=n.extend({type:"series.bar",dependencies:["grid","polar"],getInitialData:function(t,e){return r(t.data,this,e)},getMarkerPosition:function(t){var e=this.coordinateSystem;if(e){var i=e.dataToPoint(t),n=this.getData(),r=n.getLayout("offset"),o=n.getLayout("size"),a=e.getBaseAxis().isHorizontal()?0:1;return i[a]+=r+o/2,i}return[NaN,NaN]},defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,xAxisIndex:0,yAxisIndex:0,barMinHeight:0,itemStyle:{normal:{barBorderColor:"#fff",barBorderWidth:0},emphasis:{barBorderColor:"#fff",barBorderWidth:0}}}})},function(t,e,i){"use strict";function n(t,e){var i=t.width>0?1:-1,n=t.height>0?1:-1;e=Math.min(e,Math.abs(t.width),Math.abs(t.height)),t.x+=i*e/2,t.y+=n*e/2,t.width-=i*e,t.height-=n*e}var r=i(1),o=i(3);r.extend(i(12).prototype,i(82)),t.exports=i(2).extendChartView({type:"bar",render:function(t,e,i){var n=t.get("coordinateSystem");return"cartesian2d"===n&&this._renderOnCartesian(t,e,i),this.group},_renderOnCartesian:function(t,e,i){function a(e,i){var a=l.getItemLayout(e),s=l.getItemModel(e).get(p)||0;n(a,s);var h=new o.Rect({shape:r.extend({},a)});if(f){var c=h.shape,u=d?"height":"width",g={};c[u]=0,g[u]=a[u],o[i?"updateProps":"initProps"](h,{shape:g},t)}return h}var s=this.group,l=t.getData(),h=this._data,c=t.coordinateSystem,u=c.getBaseAxis(),d=u.isHorizontal(),f=t.get("animation"),p=["itemStyle","normal","barBorderWidth"];l.diff(h).add(function(t){if(l.hasValue(t)){var e=a(t);l.setItemGraphicEl(t,e),s.add(e)}}).update(function(e,i){var r=h.getItemGraphicEl(i);if(!l.hasValue(e))return void s.remove(r);r||(r=a(e,!0));var c=l.getItemLayout(e),u=l.getItemModel(e).get(p)||0;n(c,u),o.updateProps(r,{shape:c},t),l.setItemGraphicEl(e,r),s.add(r)}).remove(function(e){var i=h.getItemGraphicEl(e);i&&(i.style.text="",o.updateProps(i,{shape:{width:0}},t,function(){s.remove(i)}))}).execute(),this._updateStyle(t,l,d),this._data=l},_updateStyle:function(t,e,i){function n(t,e,i,n,r){o.setText(t,e,i),t.text=n,"outside"===t.textPosition&&(t.textPosition=r)}e.eachItemGraphicEl(function(a,s){var l=e.getItemModel(s),h=e.getItemVisual(s,"color"),c=e.getItemLayout(s),u=l.getModel("itemStyle.normal"),d=l.getModel("itemStyle.emphasis").getItemStyle();a.setShape("r",u.get("barBorderRadius")||0),a.setStyle(r.defaults({fill:h},u.getBarItemStyle()));var f=i?c.height>0?"bottom":"top":c.width>0?"left":"right",p=l.getModel("label.normal"),g=l.getModel("label.emphasis"),m=a.style;p.get("show")?n(m,p,h,r.retrieve(t.getFormattedLabel(s,"normal"),t.getRawValue(s)),f):m.text="",g.get("show")?n(d,g,h,r.retrieve(t.getFormattedLabel(s,"emphasis"),t.getRawValue(s)),f):d.text="",o.setHoverStyle(a,d)})},remove:function(t,e){var i=this.group;t.get("animation")?this._data&&this._data.eachItemGraphicEl(function(e){e.style.text="",o.updateProps(e,{shape:{width:0}},t,function(){i.remove(e)})}):i.removeAll()}})},function(t,e,i){t.exports={getBarItemStyle:i(30)([["fill","color"],["stroke","barBorderColor"],["lineWidth","barBorderWidth"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]])}},function(t,e,i){function n(t,e,i){var n=e.getItemVisual(i,"color"),r=e.getItemVisual(i,"symbol"),o=e.getItemVisual(i,"symbolSize");if("none"!==r){p.isArray(o)||(o=[o,o]);var a=c.createSymbol(r,-o[0]/2,-o[1]/2,o[0],o[1],n);return a.name=t,a}}function r(t){var e=new d({name:"line",style:{strokeNoScale:!0}});return o(e.shape,t),e}function o(t,e){var i=e[0],n=e[1],r=e[2];t.x1=i[0],t.y1=i[1],t.x2=n[0],t.y2=n[1],t.percent=1,r&&(t.cpx1=r[0],t.cpy1=r[1])}function a(t){return"symbol"===t.type&&"arrow"===t.shape.symbolType}function s(){var t=this,e=t.childOfName("line");if(this.__dirty||e.__dirty){var i=t.childOfName("fromSymbol"),n=t.childOfName("toSymbol"),r=t.childOfName("label"),o=e.pointAt(0),s=e.pointAt(e.shape.percent),h=u.sub([],s,o);u.normalize(h,h),i&&(i.attr("position",o),a(i)&&i.attr("rotation",l(s,o))),n&&(n.attr("position",s),a(n)&&n.attr("rotation",l(o,s))),r.attr("position",s);var c,d,f;"end"===r.__position?(c=[5*h[0]+s[0],5*h[1]+s[1]],d=h[0]>.8?"left":h[0]<-.8?"right":"center",f=h[1]>.8?"top":h[1]<-.8?"bottom":"middle"):(c=[5*-h[0]+o[0],5*-h[1]+o[1]],d=h[0]>.8?"right":h[0]<-.8?"left":"center",f=h[1]>.8?"bottom":h[1]<-.8?"top":"middle"),r.attr({style:{textVerticalAlign:r.__verticalAlign||f,textAlign:r.__textAlign||d},position:c})}}function l(t,e){return-Math.PI/2-Math.atan2(e[1]-t[1],e[0]-t[0])}function h(t,e,i,n){f.Group.call(this),this._createLine(t,e,i,n)}var c=i(24),u=i(5),d=i(161),f=i(3),p=i(1),g=i(4),m=h.prototype;m.beforeUpdate=s,m._createLine=function(t,e,i,o){var a=t.hostModel,s=t.getItemLayout(o),l=r(s);l.shape.percent=0,f.initProps(l,{shape:{percent:1}},a),this.add(l);var h=new f.Text({name:"label"});if(this.add(h),e){var c=n("fromSymbol",e,o);this.add(c),this._fromSymbolType=e.getItemVisual(o,"symbol")}if(i){var u=n("toSymbol",i,o);this.add(u),this._toSymbolType=i.getItemVisual(o,"symbol")}this._updateCommonStl(t,e,i,o)},m.updateData=function(t,e,i,r){var a=t.hostModel,s=this.childOfName("line"),l=t.getItemLayout(r),h={shape:{}};if(o(h.shape,l),f.updateProps(s,h,a),e){var c=e.getItemVisual(r,"symbol");if(this._fromSymbolType!==c){var u=n("fromSymbol",e,r);this.remove(this.childOfName("fromSymbol")),this.add(u)}this._fromSymbolType=c}if(i){var d=i.getItemVisual(r,"symbol");if(d!==this._toSymbolType){var p=n("toSymbol",i,r);this.remove(this.childOfName("toSymbol")),this.add(p)}this._toSymbolType=d}this._updateCommonStl(t,e,i,r)},m._updateCommonStl=function(t,e,i,n){var r=t.hostModel,o=this.childOfName("line"),a=t.getItemModel(n),s=a.getModel("label.normal"),l=s.getModel("textStyle"),h=a.getModel("label.emphasis"),c=h.getModel("textStyle"),u=g.round(r.getRawValue(n));isNaN(u)&&(u=t.getName(n)),o.setStyle(p.extend({stroke:t.getItemVisual(n,"color")},a.getModel("lineStyle.normal").getLineStyle()));var d=this.childOfName("label");d.setStyle({text:s.get("show")?p.retrieve(r.getFormattedLabel(n,"normal"),u):"",textFont:l.getFont(),fill:l.getTextColor()||t.getItemVisual(n,"color")}),d.hoverStyle={text:h.get("show")?p.retrieve(r.getFormattedLabel(n,"emphasis"),u):"",textFont:l.getFont(),fill:c.getTextColor()},d.__textAlign=l.get("align"),d.__verticalAlign=l.get("baseline"),d.__position=s.get("position"),f.setHoverStyle(this,a.getModel("lineStyle.emphasis").getLineStyle())},m.updateLayout=function(t,e,i,n){var r=t.getItemLayout(n),a=this.childOfName("line");o(a.shape,r),a.dirty(!0),e&&e.getItemGraphicEl(n).attr("position",r[0]),i&&i.getItemGraphicEl(n).attr("position",r[1])},p.inherits(h,f.Group),t.exports=h},function(t,e,i){function n(t){this._ctor=t||o,this.group=new r.Group}var r=i(3),o=i(83),a=n.prototype;a.updateData=function(t,e,i){var n=this._lineData,r=this.group,o=this._ctor;t.diff(n).add(function(n){var a=new o(t,e,i,n);t.setItemGraphicEl(n,a),r.add(a)}).update(function(o,a){var s=n.getItemGraphicEl(a);s.updateData(t,e,i,o),t.setItemGraphicEl(o,s),r.add(s)}).remove(function(t){r.remove(n.getItemGraphicEl(t))}).execute(),this._lineData=t,this._fromData=e,this._toData=i},a.updateLayout=function(){var t=this._lineData;t.eachItemGraphicEl(function(e,i){e.updateLayout(t,this._fromData,this._toData,i)},this)},a.remove=function(){this.group.removeAll()},t.exports=n},function(t,e,i){var n=i(1),r=i(2);i(86),i(87),r.registerVisualCoding("chart",n.curry(i(44),"line","circle","line")),r.registerLayout(n.curry(i(53),"line")),r.registerProcessor("statistic",n.curry(i(121),"line")),i(34)},function(t,e,i){"use strict";var n=i(36),r=i(13);t.exports=r.extend({type:"series.line",dependencies:["grid","polar"],getInitialData:function(t,e){return n(t.data,this,e)},defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,hoverAnimation:!0,xAxisIndex:0,yAxisIndex:0,polarIndex:0,clipOverflow:!0,label:{normal:{position:"top"}},lineStyle:{normal:{width:2,type:"solid"}},symbol:"emptyCircle",symbolSize:4,showSymbol:!0,animationEasing:"linear"}})},function(t,e,i){"use strict";function n(t,e){if(t.length===e.length){for(var i=0;ie[0]?1:-1;e[0]+=n*i,e[1]-=n*i}return e}function a(t){return t>=0?1:-1}function s(t,e){var i=t.getBaseAxis(),n=t.getOtherAxis(i),r=i.onZero?0:n.scale.getExtent()[0],o=n.dim,s="x"===o||"radius"===o?1:0;return e.mapArray([o],function(n,l){for(var h,c=e.stackedOn;c&&a(c.get(o,l))===a(n);){h=c;break}var u=[];return u[s]=e.get(i.dim,l),u[1-s]=h?h.get(o,l,!0):r,t.dataToPoint(u)},!0)}function l(t,e){return null!=e.dataIndex?e.dataIndex:null!=e.name?t.indexOfName(e.name):void 0}function h(t,e,i){var n=o(t.getAxis("x")),r=o(t.getAxis("y")),a=t.getBaseAxis().isHorizontal(),s=n[0],l=r[0],h=n[1]-s,c=r[1]-l;i.get("clipOverflow")||(a?(l-=c,c*=3):(s-=h,h*=3));var u=new m.Rect({shape:{x:s,y:l,width:h,height:c}});return e&&(u.shape[a?"width":"height"]=0,m.initProps(u,{shape:{width:h,height:c}},i)),u}function c(t,e,i){var n=t.getAngleAxis(),r=t.getRadiusAxis(),o=r.getExtent(),a=n.getExtent(),s=Math.PI/180,l=new m.Sector({shape:{cx:t.cx,cy:t.cy,r0:o[0],r:o[1],startAngle:-a[0]*s,endAngle:-a[1]*s,clockwise:n.inverse}});return e&&(l.shape.endAngle=-a[0]*s,m.initProps(l,{shape:{endAngle:-a[1]*s}},i)),l}function u(t,e,i){return"polar"===t.type?c(t,e,i):h(t,e,i)}var d=i(1),f=i(38),p=i(47),g=i(88),m=i(3),v=i(89),y=i(25);t.exports=y.extend({type:"line",init:function(){var t=new m.Group,e=new f;this.group.add(e.group),this._symbolDraw=e,this._lineGroup=t},render:function(t,e,i){var o=t.coordinateSystem,a=this.group,l=t.getData(),h=t.getModel("lineStyle.normal"),c=t.getModel("areaStyle.normal"),f=l.mapArray(l.getItemLayout,!0),p="polar"===o.type,g=this._coordSys,m=this._symbolDraw,v=this._polyline,y=this._polygon,x=this._lineGroup,_=t.get("animation"),b=!c.isEmpty(),w=s(o,l),M=t.get("showSymbol"),S=M&&!p&&!t.get("showAllSymbol")&&this._getSymbolIgnoreFunc(l,o),A=this._data;A&&A.eachItemGraphicEl(function(t,e){t.__temp&&(a.remove(t),A.setItemGraphicEl(e,null))}),M||m.remove(),a.add(x),v&&g.type===o.type?(b&&!y?y=this._newPolygon(f,w,o,_):y&&!b&&(x.remove(y),y=this._polygon=null),x.setClipPath(u(o,!1,t)),M&&m.updateData(l,S),l.eachItemGraphicEl(function(t){t.stopAnimation(!0)}),n(this._stackedOnPoints,w)&&n(this._points,f)||(_?this._updateAnimation(l,w,o,i):(v.setShape({points:f}),y&&y.setShape({points:f,stackedOnPoints:w})))):(M&&m.updateData(l,S),v=this._newPolyline(f,o,_),b&&(y=this._newPolygon(f,w,o,_)),x.setClipPath(u(o,!0,t))),v.setStyle(d.defaults(h.getLineStyle(),{stroke:l.getVisual("color"),lineJoin:"bevel"}));var T=t.get("smooth");if(T=r(t.get("smooth")),v.setShape({smooth:T,smoothMonotone:t.get("smoothMonotone")}),y){var C=l.stackedOn,I=0;if(y.style.opacity=.7,y.setStyle(d.defaults(c.getAreaStyle(),{fill:l.getVisual("color"),lineJoin:"bevel"})),C){var k=C.hostModel;I=r(k.get("smooth"))}y.setShape({smooth:T,stackedOnSmooth:I,smoothMonotone:t.get("smoothMonotone")})}this._data=l,this._coordSys=o,this._stackedOnPoints=w,this._points=f},highlight:function(t,e,i,n){var r=t.getData(),o=l(r,n);if(null!=o&&o>=0){var a=r.getItemGraphicEl(o);if(!a){var s=r.getItemLayout(o);a=new p(r,o,i),a.position=s,a.setZ(t.get("zlevel"),t.get("z")),a.ignore=isNaN(s[0])||isNaN(s[1]),a.__temp=!0,r.setItemGraphicEl(o,a),a.stopSymbolAnimation(!0),this.group.add(a)}a.highlight()}else y.prototype.highlight.call(this,t,e,i,n)},downplay:function(t,e,i,n){var r=t.getData(),o=l(r,n);if(null!=o&&o>=0){var a=r.getItemGraphicEl(o);a&&(a.__temp?(r.setItemGraphicEl(o,null),this.group.remove(a)):a.downplay())}else y.prototype.downplay.call(this,t,e,i,n)},_newPolyline:function(t){var e=this._polyline;return e&&this._lineGroup.remove(e),e=new v.Polyline({shape:{points:t},silent:!0,z2:10}),this._lineGroup.add(e),this._polyline=e,e},_newPolygon:function(t,e){var i=this._polygon;return i&&this._lineGroup.remove(i),i=new v.Polygon({shape:{points:t,stackedOnPoints:e},silent:!0}),this._lineGroup.add(i),this._polygon=i,i},_getSymbolIgnoreFunc:function(t,e){var i=e.getAxesByScale("ordinal")[0];return i&&i.isLabelIgnored?d.bind(i.isLabelIgnored,i):void 0},_updateAnimation:function(t,e,i,n){var r=this._polyline,o=this._polygon,a=t.hostModel,s=g(this._data,t,this._stackedOnPoints,e,this._coordSys,i);r.shape.points=s.current,m.updateProps(r,{shape:{points:s.next}},a),o&&(o.setShape({points:s.current,stackedOnPoints:s.stackedOnCurrent}),m.updateProps(o,{shape:{points:s.next,stackedOnPoints:s.stackedOnNext}},a));for(var l=[],h=s.status,c=0;c=0?1:-1}function n(t,e,n){for(var r,o=t.getBaseAxis(),a=t.getOtherAxis(o),s=o.onZero?0:a.scale.getExtent()[0],l=a.dim,h="x"===l||"radius"===l?1:0,c=e.stackedOn,u=e.get(l,n);c&&i(c.get(l,n))===i(u);){r=c;break}var d=[];return d[h]=e.get(o.dim,n),d[1-h]=r?r.get(l,n,!0):s,t.dataToPoint(d)}function r(t,e){var i=[];return e.diff(t).add(function(t){i.push({cmd:"+",idx:t})}).update(function(t,e){i.push({cmd:"=",idx:e,idx1:t})}).remove(function(t){i.push({cmd:"-",idx:t})}).execute(),i}t.exports=function(t,e,i,o,a,s){for(var l=r(t,e),h=[],c=[],u=[],d=[],f=[],p=[],g=[],m=s.dimensions,v=0;vx;x++){var _=e[y];if(y>=n||0>y||isNaN(_[0])||isNaN(_[1]))break;if(y===i)t[o>0?"moveTo":"lineTo"](_[0],_[1]),c(d,_);else if(m>0){var b=y-o,w=y+o,M=.5,S=e[b],A=e[w];if(o>0&&(y===r-1||isNaN(A[0])||isNaN(A[1]))||0>=o&&(0===y||isNaN(A[0])||isNaN(A[1])))c(f,_);else{(isNaN(A[0])||isNaN(A[1]))&&(A=_),a.sub(u,A,S);var T,C;if("x"===v||"y"===v){var I="x"===v?0:1;T=Math.abs(_[I]-S[I]),C=Math.abs(_[I]-A[I])}else T=a.dist(_,S),C=a.dist(_,A);M=C/(C+T),h(f,_,u,-m*(1-M))}s(d,d,g),l(d,d,p),s(f,f,g),l(f,f,p),t.bezierCurveTo(d[0],d[1],f[0],f[1],_[0],_[1]),h(d,_,u,m*M)}else t.lineTo(_[0],_[1]);y+=o}return x}function r(t,e){var i=[1/0,1/0],n=[-(1/0),-(1/0)];if(e)for(var r=0;rn[0]&&(n[0]=o[0]),o[1]>n[1]&&(n[1]=o[1])}return{min:e?i:n,max:e?n:i}}var o=i(6),a=i(5),s=a.min,l=a.max,h=a.scaleAndAdd,c=a.copy,u=[],d=[],f=[];t.exports={Polyline:o.extend({type:"ec-polyline",shape:{points:[],smooth:0,smoothConstraint:!0,smoothMonotone:null},style:{fill:null,stroke:"#000"},buildPath:function(t,e){for(var i=e.points,o=0,a=i.length,s=r(i,e.smoothConstraint);a>o;)o+=n(t,i,o,a,a,1,s.min,s.max,e.smooth,e.smoothMonotone)+1}}),Polygon:o.extend({type:"ec-polygon",shape:{points:[],stackedOnPoints:[],smooth:0,stackedOnSmooth:0,smoothConstraint:!0,smoothMonotone:null},buildPath:function(t,e){for(var i=e.points,o=e.stackedOnPoints,a=0,s=i.length,l=e.smoothMonotone,h=r(i,e.smoothConstraint),c=r(o,e.smoothConstraint);s>a;){var u=n(t,i,a,s,s,1,h.min,h.max,e.smooth,l);n(t,o,a+u-1,s,u,-1,c.min,c.max,e.stackedOnSmooth,l),a+=u+1,t.closePath()}}})}},function(t,e,i){var n=i(1),r=i(2);i(91),i(92),i(68)("pie",[{type:"pieToggleSelect",event:"pieselectchanged",method:"toggleSelected"},{type:"pieSelect",event:"pieselected",method:"select"},{type:"pieUnSelect",event:"pieunselected",method:"unSelect"}]),r.registerVisualCoding("chart",n.curry(i(63),"pie")),r.registerLayout(n.curry(i(94),"pie")),r.registerProcessor("filter",n.curry(i(62),"pie"))},function(t,e,i){"use strict";var n=i(14),r=i(1),o=i(7),a=i(31),s=i(69),l=i(2).extendSeriesModel({type:"series.pie",init:function(t){l.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._dataBeforeProcessed},this.updateSelectedMap(),this._defaultLabelLine(t)},mergeOption:function(t){l.superCall(this,"mergeOption",t),this.updateSelectedMap()},getInitialData:function(t,e){var i=a(["value"],t.data),r=new n(i,this);return r.initData(t.data),r},getDataParams:function(t){var e=this._data,i=l.superCall(this,"getDataParams",t),n=e.getSum("value");return i.percent=n?+(e.get("value",t)/n*100).toFixed(2):0,i.$vars.push("percent"),i},_defaultLabelLine:function(t){o.defaultEmphasis(t.labelLine,["show"]);var e=t.labelLine.normal,i=t.labelLine.emphasis;e.show=e.show&&t.label.normal.show,i.show=i.show&&t.label.emphasis.show},defaultOption:{zlevel:0,z:2,legendHoverLink:!0,hoverAnimation:!0,center:["50%","50%"],radius:[0,"75%"],clockwise:!0,startAngle:90,minAngle:0,selectedOffset:10,avoidLabelOverlap:!0,label:{normal:{rotate:!1,show:!0,position:"outer"},emphasis:{}},labelLine:{normal:{show:!0,length:20,length2:5,smooth:!1,lineStyle:{width:1,type:"solid"}}},itemStyle:{normal:{borderColor:"rgba(0,0,0,0)",borderWidth:1},emphasis:{borderColor:"rgba(0,0,0,0)",borderWidth:1}},animationEasing:"cubicOut",data:[]}});r.mixin(l,s),t.exports=l},function(t,e,i){function n(t,e,i,n){var o=e.getData(),a=this.dataIndex,s=o.getName(a),l=e.get("selectedOffset");n.dispatchAction({type:"pieToggleSelect",from:t,name:s,seriesId:e.id}),o.each(function(t){r(o.getItemGraphicEl(t),o.getItemLayout(t),e.isSelected(o.getName(t)),l,i)})}function r(t,e,i,n,r){var o=(e.startAngle+e.endAngle)/2,a=Math.cos(o),s=Math.sin(o),l=i?n:0,h=[a*l,s*l];r?t.animate().when(200,{position:h}).start("bounceOut"):t.attr("position",h)}function o(t,e){function i(){o.ignore=o.hoverIgnore,a.ignore=a.hoverIgnore}function n(){o.ignore=o.normalIgnore,a.ignore=a.normalIgnore}s.Group.call(this);var r=new s.Sector({z2:2}),o=new s.Polyline,a=new s.Text;this.add(r),this.add(o),this.add(a),this.updateData(t,e,!0),this.on("emphasis",i).on("normal",n).on("mouseover",i).on("mouseout",n)}function a(t,e,i,n,r){var o=n.getModel("textStyle"),a="inside"===r||"inner"===r;return{fill:o.getTextColor()||(a?"#fff":t.getItemVisual(e,"color")),textFont:o.getFont(),text:l.retrieve(t.hostModel.getFormattedLabel(e,i),t.getName(e))}}var s=i(3),l=i(1),h=o.prototype;h.updateData=function(t,e,i){function n(){a.stopAnimation(!0),a.animateTo({shape:{r:u.r+10}},300,"elasticOut")}function o(){a.stopAnimation(!0),a.animateTo({shape:{r:u.r}},300,"elasticOut")}var a=this.childAt(0),h=t.hostModel,c=t.getItemModel(e),u=t.getItemLayout(e),d=l.extend({},u);d.label=null,i?(a.setShape(d),a.shape.endAngle=u.startAngle,s.updateProps(a,{shape:{endAngle:u.endAngle}},h)):s.updateProps(a,{shape:d},h);var f=c.getModel("itemStyle"),p=t.getItemVisual(e,"color");a.setStyle(l.defaults({fill:p},f.getModel("normal").getItemStyle())),a.hoverStyle=f.getModel("emphasis").getItemStyle(),r(this,t.getItemLayout(e),c.get("selected"),h.get("selectedOffset"),h.get("animation")),a.off("mouseover").off("mouseout").off("emphasis").off("normal"),c.get("hoverAnimation")&&a.on("mouseover",n).on("mouseout",o).on("emphasis",n).on("normal",o),this._updateLabel(t,e),s.setHoverStyle(this)},h._updateLabel=function(t,e){var i=this.childAt(1),n=this.childAt(2),r=t.hostModel,o=t.getItemModel(e),l=t.getItemLayout(e),h=l.label,c=t.getItemVisual(e,"color");s.updateProps(i,{shape:{points:h.linePoints||[[h.x,h.y],[h.x,h.y],[h.x,h.y]]}},r),s.updateProps(n,{style:{x:h.x,y:h.y}},r),n.attr({style:{textVerticalAlign:h.verticalAlign,textAlign:h.textAlign,textFont:h.font},rotation:h.rotation,origin:[h.x,h.y],z2:10});var u=o.getModel("label.normal"),d=o.getModel("label.emphasis"),f=o.getModel("labelLine.normal"),p=o.getModel("labelLine.emphasis"),g=u.get("position")||d.get("position");n.setStyle(a(t,e,"normal",u,g)),n.ignore=n.normalIgnore=!u.get("show"),n.hoverIgnore=!d.get("show"),i.ignore=i.normalIgnore=!f.get("show"),i.hoverIgnore=!p.get("show"),i.setStyle({stroke:c}),i.setStyle(f.getModel("lineStyle").getLineStyle()),n.hoverStyle=a(t,e,"emphasis",d,g),i.hoverStyle=p.getModel("lineStyle").getLineStyle();var m=f.get("smooth");m&&m===!0&&(m=.4),i.setShape({smooth:m})},l.inherits(o,s.Group);var c=i(25).extend({type:"pie",init:function(){var t=new s.Group;this._sectorGroup=t},render:function(t,e,i,r){if(!r||r.from!==this.uid){var a=t.getData(),s=this._data,h=this.group,c=e.get("animation"),u=!s,d=l.curry(n,this.uid,t,c,i),f=t.get("selectedMode");if(a.diff(s).add(function(t){var e=new o(a,t);u&&e.eachChild(function(t){t.stopAnimation(!0)}),f&&e.on("click",d),a.setItemGraphicEl(t,e),h.add(e)}).update(function(t,e){var i=s.getItemGraphicEl(e);i.updateData(a,t),i.off("click"),f&&i.on("click",d),h.add(i),a.setItemGraphicEl(t,i)}).remove(function(t){var e=s.getItemGraphicEl(t);h.remove(e)}).execute(),c&&u&&a.count()>0){var p=a.getItemLayout(0),g=Math.max(i.getWidth(),i.getHeight())/2,m=l.bind(h.removeClipPath,h);h.setClipPath(this._createClipPath(p.cx,p.cy,g,p.startAngle,p.clockwise,m,t))}this._data=a}},_createClipPath:function(t,e,i,n,r,o,a){var l=new s.Sector({shape:{cx:t,cy:e,r0:0,r:i,startAngle:n,endAngle:n,clockwise:r}});return s.initProps(l,{shape:{endAngle:n+(r?1:-1)*Math.PI*2}},a,o),l}});t.exports=c},function(t,e,i){"use strict";function n(t,e,i,n,r,o,a){function s(e,i,n,r){for(var o=e;i>o;o++)if(t[o].y+=n,o>e&&i>o+1&&t[o+1].y>t[o].y+t[o].height)return void l(o,n/2);l(i-1,n/2)}function l(e,i){for(var n=e;n>=0&&(t[n].y-=i,!(n>0&&t[n].y>t[n-1].y+t[n-1].height));n--);}t.sort(function(t,e){return t.y-e.y});for(var h,c=0,u=t.length,d=[],f=[],p=0;u>p;p++)h=t[p].y-c,0>h&&s(p,u,-h,r),c=t[p].y+t[p].height;0>a-c&&l(u-1,c-a);for(var p=0;u>p;p++)t[p].y>=i?f.push(t[p]):d.push(t[p])}function r(t,e,i,r,o,a){for(var s=[],l=[],h=0;hb?-1:1)*x,k=C;n=I+(0>b?-5:5),r=k,u=[[S,A],[T,C],[I,k]]}d=M?"center":b>0?"left":"right"}var D=g.getModel("textStyle").getFont(),L=g.get("rotate")?0>b?-_+Math.PI:-_:0,P=t.getFormattedLabel(i,"normal")||l.getName(i),z=o.getBoundingRect(P,D,d,"top");c=!!L,f.label={x:n,y:r,height:z.height,length:y,length2:x,linePoints:u,textAlign:d,verticalAlign:"middle",font:D,rotation:L},h.push(f.label)}),!c&&t.get("avoidLabelOverlap")&&r(h,a,s,e,i,n)}},function(t,e,i){var n=i(4),r=n.parsePercent,o=i(93),a=i(1),s=2*Math.PI,l=Math.PI/180;t.exports=function(t,e,i){e.eachSeriesByType(t,function(t){var e=t.get("center"),h=t.get("radius");a.isArray(h)||(h=[0,h]),a.isArray(e)||(e=[e,e]);var c=i.getWidth(),u=i.getHeight(),d=Math.min(c,u),f=r(e[0],c),p=r(e[1],u),g=r(h[0],d/2),m=r(h[1],d/2),v=t.getData(),y=-t.get("startAngle")*l,x=t.get("minAngle")*l,_=v.getSum("value"),b=Math.PI/(_||v.count())*2,w=t.get("clockwise"),M=t.get("roseType"),S=v.getDataExtent("value");S[0]=0;var A=s,T=0,C=y,I=w?1:-1;if(v.each("value",function(t,e){var i;i="area"!==M?0===_?b:t*b:s/(v.count()||1),x>i?(i=x,A-=x):T+=t;var r=C+I*i;v.setItemLayout(e,{angle:i,startAngle:C,endAngle:r,clockwise:w,cx:f,cy:p,r0:g,r:M?n.linearMap(t,S,[g,m]):m}),C=r},!0),s>A)if(.001>=A){var k=s/v.count();v.each(function(t){var e=v.getItemLayout(t);e.startAngle=y+I*t*k,e.endAngle=y+I*(t+1)*k})}else b=A/T,C=y,v.each("value",function(t,e){var i=v.getItemLayout(e),n=i.angle===x?x:t*b;i.startAngle=C,i.endAngle=C+I*n,C+=n});o(t,m,c,u)})}},function(t,e,i){"use strict";i(50),i(96)},function(t,e,i){function n(t,e){function i(t,e){var i=n.getAxis(t);return i.toGlobalCoord(i.dataToCoord(0))}var n=t.coordinateSystem,r=e.axis,o={},a=r.position,s=r.onZero?"onZero":a,l=r.dim,h=n.getRect(),c=[h.x,h.x+h.width,h.y,h.y+h.height],u={x:{top:c[2],bottom:c[3]},y:{left:c[0],right:c[1]}};u.x.onZero=Math.max(Math.min(i("y"),u.x.bottom),u.x.top),u.y.onZero=Math.max(Math.min(i("x"),u.y.right),u.y.left),o.position=["y"===l?u.y[s]:c[0],"x"===l?u.x[s]:c[3]];var d={x:0,y:1};o.rotation=Math.PI/2*d[l];var f={top:-1,bottom:1,left:-1,right:1};o.labelDirection=o.tickDirection=o.nameDirection=f[a],r.onZero&&(o.labelOffset=u[l][a]-u[l].onZero),e.getModel("axisTick").get("inside")&&(o.tickDirection=-o.tickDirection),e.getModel("axisLabel").get("inside")&&(o.labelDirection=-o.labelDirection);var p=e.getModel("axisLabel").get("rotate");return o.labelRotation="top"===s?-p:p,o.labelInterval=r.getLabelInterval(),o.z2=1,o}var r=i(1),o=i(3),a=i(48),s=a.ifIgnoreOnTick,l=a.getInterval,h=["axisLine","axisLabel","axisTick","axisName"],c=["splitLine","splitArea"],u=i(2).extendComponentView({type:"axis",render:function(t,e){if(this.group.removeAll(),t.get("show")){var i=e.getComponent("grid",t.get("gridIndex")),o=n(i,t),s=new a(t,o);r.each(h,s.add,s),this.group.add(s.getGroup()),r.each(c,function(e){t.get(e+".show")&&this["_"+e](t,i,o.labelInterval)},this)}},_splitLine:function(t,e,i){var n=t.axis,a=t.getModel("splitLine"),h=a.getModel("lineStyle"),c=h.get("width"),u=h.get("color"),d=l(a,i);u=r.isArray(u)?u:[u];for(var f=e.coordinateSystem.getRect(),p=n.isHorizontal(),g=[],m=0,v=n.getTicksCoords(),y=[],x=[],_=0;_=0;r--){var o=i[r];if(o[n])break}if(0>r){var a=t.queryComponents({mainType:"dataZoom",subType:"select",id:n})[0];if(a){var s=a.getPercentRange();i[0][n]={dataZoomId:n,start:s[0],end:s[1]}}}}),i.push(e)},pop:function(t){var e=n(t),i=e[e.length-1];e.length>1&&e.pop();var r={};return o(i,function(t,i){for(var n=e.length-1;n>=0;n--){var t=e[n][i];if(t){r[i]=t;break}}}),r},clear:function(t){t[a]=null},count:function(t){return n(t).length}};t.exports=s},function(t,e,i){i(10).registerSubTypeDefaulter("dataZoom",function(t){return"slider"})},function(t,e){function i(t){return t[n]||(t[n]={})}var n="\x00_ec_interaction_mutex",r={take:function(t,e){i(e)[t]=!0},release:function(t,e){i(e)[t]=!1},isTaken:function(t,e){return!!i(e)[t]}};t.exports=r},function(t,e,i){function n(t,e,i){r.positionGroup(t,e.getBoxLayoutParams(),{width:i.getWidth(),height:i.getHeight()},e.get("padding"))}var r=i(11),o=i(9),a=i(3);t.exports={layout:function(t,e,i){var o=r.getLayoutRect(e.getBoxLayoutParams(),{width:i.getWidth(),height:i.getHeight()},e.get("padding"));r.box(e.get("orient"),t,e.get("itemGap"),o.width,o.height),n(t,e,i)},addBackground:function(t,e){var i=o.normalizeCssArray(e.get("padding")),n=t.getBoundingRect(),r=e.getItemStyle(["color","opacity"]);r.fill=e.get("backgroundColor");var s=new a.Rect({shape:{x:n.x-i[3],y:n.y-i[0],width:n.width+i[1]+i[3],height:n.height+i[0]+i[2]},style:r,silent:!0,z2:-1});a.subPixelOptimizeRect(s),t.add(s)}}},function(t,e,i){function n(t,e,i){var n=-1;do n=Math.max(a.getPrecision(t.get(e,i)),n),t=t.stackedOn;while(t);return n}function r(t,e,i,r,o,a){var s=[],l=p(e,r,t),h=e.indexOfNearest(r,l,!0);s[o]=e.get(i,h,!0),s[a]=e.get(r,h,!0);var c=n(e,r,h);return c>=0&&(s[a]=+s[a].toFixed(c)),s}var o=i(1),a=i(4),s=o.indexOf,l=o.curry,h={min:l(r,"min"),max:l(r,"max"),average:l(r,"average")},c=function(t,e){var i=t.getData(),n=t.coordinateSystem;if((isNaN(e.x)||isNaN(e.y))&&!o.isArray(e.coord)&&n){var r=u(e,i,n,t);if(e=o.clone(e),e.type&&h[e.type]&&r.baseAxis&&r.valueAxis){var a=n.dimensions,l=s(a,r.baseAxis.dim),c=s(a,r.valueAxis.dim);e.coord=h[e.type](i,r.baseDataDim,r.valueDataDim,l,c),e.value=e.coord[c]}else e.coord=[null!=e.xAxis?e.xAxis:e.radiusAxis,null!=e.yAxis?e.yAxis:e.angleAxis]}return e},u=function(t,e,i,n){var r={};return null!=t.valueIndex||null!=t.valueDim?(r.valueDataDim=null!=t.valueIndex?e.getDimension(t.valueIndex):t.valueDim,r.valueAxis=i.getAxis(n.dataDimToCoordDim(r.valueDataDim)),r.baseAxis=i.getOtherAxis(r.valueAxis),r.baseDataDim=n.coordDimToDataDim(r.baseAxis.dim)[0]):(r.baseAxis=n.getBaseAxis(),r.valueAxis=i.getOtherAxis(r.baseAxis),r.baseDataDim=n.coordDimToDataDim(r.baseAxis.dim)[0],r.valueDataDim=n.coordDimToDataDim(r.valueAxis.dim)[0]),r},d=function(t,e){return t&&e.coord&&(null==e.x||null==e.y)?t.containData(e.coord):!0},f=function(t,e,i,n){return 2>n?t.coord&&t.coord[n]:void t.value},p=function(t,e,i){return"average"===i?t.getSum(e,!0)/t.count():t.getDataExtent(e,!0)["max"===i?1:0]};t.exports={dataTransform:c,dataFilter:d,dimValueGetter:f,getAxisInfo:u,numCalculate:p}},function(t,e,i){var n=i(1),r=i(43),o=i(108),a=function(t,e,i,n,o){r.call(this,t,e,i),this.type=n||"value",this.position=o||"bottom"};a.prototype={constructor:a,index:0,onZero:!1,model:null,isHorizontal:function(){var t=this.position;return"top"===t||"bottom"===t},getGlobalExtent:function(){var t=this.getExtent();return t[0]=this.toGlobalCoord(t[0]),t[1]=this.toGlobalCoord(t[1]),t},getLabelInterval:function(){var t=this._labelInterval;return t||(t=this._labelInterval=o(this)),t},isLabelIgnored:function(t){if("category"===this.type){var e=this.getLabelInterval();return"function"==typeof e&&!e(t,this.scale.getLabel(t))||t%(e+1)}},toLocalCoord:null,toGlobalCoord:null},n.inherits(a,r),t.exports=a},function(t,e,i){"use strict";function n(t){return this._axes[t]}var r=i(1),o=function(t){this._axes={},this._dimList=[],this.name=t||""};o.prototype={constructor:o,type:"cartesian",getAxis:function(t){return this._axes[t]},getAxes:function(){return r.map(this._dimList,n,this)},getAxesByScale:function(t){return t=t.toLowerCase(),r.filter(this.getAxes(),function(e){return e.scale.type===t})},addAxis:function(t){var e=t.dim;this._axes[e]=t,this._dimList.push(e)},dataToCoord:function(t){return this._dataCoordConvert(t,"dataToCoord")},coordToData:function(t){return this._dataCoordConvert(t,"coordToData")},_dataCoordConvert:function(t,e){for(var i=this._dimList,n=t instanceof Array?[]:{},r=0;ri&&(i=Math.min(i,c),c-=i,t.width=i,u--)}),d=(c-s)/(u+(u-1)*h),d=Math.max(d,0);var f,p=0;a.each(i,function(t,e){t.width||(t.width=d),f=t,p+=t.width*(1+h)}),f&&(p-=f.width*h);var g=-p/2;a.each(i,function(t,i){r[e][i]=r[e][i]||{offset:g,width:t.width},g+=t.width*(1+h)})}),r}function o(t,e,i){var o=r(a.filter(e.getSeriesByType(t),function(t){return!e.isSeriesFiltered(t)&&t.coordinateSystem&&"cartesian2d"===t.coordinateSystem.type})),s={};e.eachSeriesByType(t,function(t){var e=t.getData(),i=t.coordinateSystem,r=i.getBaseAxis(),a=n(t),l=o[r.index][a],h=l.offset,c=l.width,u=i.getOtherAxis(r),d=t.get("barMinHeight")||0,f=r.onZero?u.toGlobalCoord(u.dataToCoord(0)):u.getGlobalExtent()[0],p=i.dataToPoints(e,!0);s[a]=s[a]||[],e.setLayout({offset:h,size:c}),e.each(u.dim,function(t,i){if(!isNaN(t)){s[a][i]||(s[a][i]={p:f,n:f});var n,r,o,l,g=t>=0?"p":"n",m=p[i],v=s[a][i][g];u.isHorizontal()?(n=v,r=m[1]+h,o=m[0]-v,l=c,Math.abs(o)o?-1:1)*d),s[a][i][g]+=o):(n=m[0]+h,r=v,o=c,l=m[1]-v,Math.abs(l)=l?-1:1)*d),s[a][i][g]+=l),e.setItemLayout(i,{x:n,y:r,width:o,height:l})}},!0)},this)}var a=i(1),s=i(4),l=s.parsePercent;t.exports=o},function(t,e,i){var n=i(3),r=i(1),o=Math.PI;t.exports=function(t,e){e=e||{},r.defaults(e,{text:"loading",color:"#c23531",textColor:"#000",maskColor:"rgba(255, 255, 255, 0.8)",zlevel:0});var i=new n.Rect({style:{fill:e.maskColor},zlevel:e.zlevel,z:1e4}),a=new n.Arc({shape:{startAngle:-o/2,endAngle:-o/2+.1,r:10},style:{stroke:e.color,lineCap:"round",lineWidth:5},zlevel:e.zlevel,z:10001}),s=new n.Rect({style:{fill:"none",text:e.text,textPosition:"right",textDistance:10,textFill:e.textColor},zlevel:e.zlevel,z:10001});a.animateShape(!0).when(1e3,{endAngle:3*o/2}).start("circularInOut"),a.animateShape(!0).when(1e3,{startAngle:3*o/2}).delay(300).start("circularInOut");var l=new n.Group;return l.add(a),l.add(s),l.add(i),l.resize=function(){var e=t.getWidth()/2,n=t.getHeight()/2;a.setShape({cx:e,cy:n});var r=a.shape.r;s.setShape({x:e-r,y:n-r,width:2*r,height:2*r}),i.setShape({x:0,y:0,width:t.getWidth(),height:t.getHeight()})},l.resize(),l}},function(t,e,i){function n(t,e){for(var i in e)_.hasClass(i)||("object"==typeof e[i]?t[i]=t[i]?u.merge(t[i],e[i],!1):u.clone(e[i]):t[i]=e[i])}function r(t){t=t,this.option={},this.option[w]=1,this._componentsMap={},this._seriesIndices=null,n(t,this._theme.option),u.merge(t,b,!1),this.mergeOption(t)}function o(t,e){u.isArray(e)||(e=e?[e]:[]);var i={};return p(e,function(e){i[e]=(t[e]||[]).slice()}),i}function a(t,e){var i={};p(e,function(t,e){var n=t.exist;n&&(i[n.id]=t)}),p(e,function(e,n){var r=e.option;if(u.assert(!r||null==r.id||!i[r.id]||i[r.id]===e,"id duplicates: "+(r&&r.id)),r&&null!=r.id&&(i[r.id]=e),x(r)){var o=s(t,r,e.exist);e.keyInfo={mainType:t,subType:o}}}),p(e,function(t,e){var n=t.exist,r=t.option,o=t.keyInfo;if(x(r)){if(o.name=null!=r.name?r.name+"":n?n.name:"\x00-",n)o.id=n.id;else if(null!=r.id)o.id=r.id+"";else{var a=0;do o.id="\x00"+o.name+"\x00"+a++;while(i[o.id])}i[o.id]=t}})}function s(t,e,i){var n=e.type?e.type:i?i.subType:_.determineSubType(t,e);return n}function l(t){return m(t,function(t){return t.componentIndex})||[]}function h(t,e){return e.hasOwnProperty("subType")?g(t,function(t){return t.subType===e.subType}):t}function c(t){if(!t._seriesIndices)throw new Error("Series has not been initialized yet.")}var u=i(1),d=i(7),f=i(12),p=u.each,g=u.filter,m=u.map,v=u.isArray,y=u.indexOf,x=u.isObject,_=i(10),b=i(113),w="\x00_ec_inner",M=f.extend({constructor:M,init:function(t,e,i,n){i=i||{},this.option=null,this._theme=new f(i),this._optionManager=n},setOption:function(t,e){u.assert(!(w in t),"please use chart.getOption()"),this._optionManager.setOption(t,e),this.resetOption()},resetOption:function(t){var e=!1,i=this._optionManager;if(!t||"recreate"===t){var n=i.mountOption("recreate"===t);this.option&&"recreate"!==t?(this.restoreData(),this.mergeOption(n)):r.call(this,n),e=!0}if("timeline"!==t&&"media"!==t||this.restoreData(),!t||"recreate"===t||"timeline"===t){var o=i.getTimelineOption(this);o&&(this.mergeOption(o),e=!0)}if(!t||"recreate"===t||"media"===t){var a=i.getMediaOption(this,this._api);a.length&&p(a,function(t){this.mergeOption(t,e=!0)},this)}return e},mergeOption:function(t){function e(e,r){var s=d.normalizeToArray(t[e]),h=d.mappingToExists(n[e],s);a(e,h);var c=o(n,r);i[e]=[],n[e]=[],p(h,function(t,r){var o=t.exist,a=t.option;if(u.assert(x(a)||o,"Empty component definition"),a){var s=_.getClass(e,t.keyInfo.subType,!0);o&&o instanceof s?(o.mergeOption(a,this),o.optionUpdated(this)):(o=new s(a,this,this,u.extend({dependentModels:c,componentIndex:r},t.keyInfo)),o.optionUpdated(this))}else o.mergeOption({},this),o.optionUpdated(this);n[e][r]=o,i[e][r]=o.option},this),"series"===e&&(this._seriesIndices=l(n.series))}var i=this.option,n=this._componentsMap,r=[];p(t,function(t,e){null!=t&&(_.hasClass(e)?r.push(e):i[e]=null==i[e]?u.clone(t):u.merge(i[e],t,!0))}),_.topologicalTravel(r,_.getAllClassMainTypes(),e,this)},getOption:function(){var t=u.clone(this.option);return p(t,function(e,i){if(_.hasClass(i)){for(var e=d.normalizeToArray(e),n=e.length-1;n>=0;n--)d.isIdInner(e[n])&&e.splice(n,1);t[i]=e}}),delete t[w],t},getTheme:function(){return this._theme},getComponent:function(t,e){var i=this._componentsMap[t];return i?i[e||0]:void 0},queryComponents:function(t){var e=t.mainType;if(!e)return[];var i=t.index,n=t.id,r=t.name,o=this._componentsMap[e];if(!o||!o.length)return[];var a;if(null!=i)v(i)||(i=[i]),a=g(m(i,function(t){return o[t]}),function(t){return!!t});else if(null!=n){var s=v(n);a=g(o,function(t){return s&&y(n,t.id)>=0||!s&&t.id===n})}else if(null!=r){var l=v(r);a=g(o,function(t){return l&&y(r,t.name)>=0||!l&&t.name===r})}return h(a,t)},findComponents:function(t){function e(t){var e=r+"Index",i=r+"Id",n=r+"Name";return t&&(t.hasOwnProperty(e)||t.hasOwnProperty(i)||t.hasOwnProperty(n))?{mainType:r,index:t[e],id:t[i],name:t[n]}:null}function i(e){return t.filter?g(e,t.filter):e}var n=t.query,r=t.mainType,o=e(n),a=o?this.queryComponents(o):this._componentsMap[r];return i(h(a,t))},eachComponent:function(t,e,i){var n=this._componentsMap;if("function"==typeof t)i=e,e=t,p(n,function(t,n){p(t,function(t,r){e.call(i,n,t,r)})});else if(u.isString(t))p(n[t],e,i);else if(x(t)){var r=this.findComponents(t);p(r,e,i)}},getSeriesByName:function(t){var e=this._componentsMap.series;return g(e,function(e){return e.name===t})},getSeriesByIndex:function(t){return this._componentsMap.series[t]},getSeriesByType:function(t){var e=this._componentsMap.series;return g(e,function(e){return e.subType===t})},getSeries:function(){return this._componentsMap.series.slice()},eachSeries:function(t,e){c(this),p(this._seriesIndices,function(i){var n=this._componentsMap.series[i];t.call(e,n,i)},this)},eachRawSeries:function(t,e){p(this._componentsMap.series,t,e)},eachSeriesByType:function(t,e,i){c(this),p(this._seriesIndices,function(n){var r=this._componentsMap.series[n];r.subType===t&&e.call(i,r,n)},this)},eachRawSeriesByType:function(t,e,i){return p(this.getSeriesByType(t),e,i)},isSeriesFiltered:function(t){return c(this),u.indexOf(this._seriesIndices,t.componentIndex)<0},filterSeries:function(t,e){c(this);var i=g(this._componentsMap.series,t,e);this._seriesIndices=l(i)},restoreData:function(){var t=this._componentsMap;this._seriesIndices=l(t.series);var e=[];p(t,function(t,i){e.push(i)}),_.topologicalTravel(e,_.getAllClassMainTypes(),function(e,i){p(t[e],function(t){t.restoreData()})})}});t.exports=M},function(t,e,i){function n(t){this._api=t,this._timelineOptions=[],this._mediaList=[],this._mediaDefault,this._currentMediaIndices=[],this._optionBackup,this._newOptionBackup}function r(t,e){var i,n,r=[],o=[],a=t.timeline;if(t.baseOption&&(n=t.baseOption),(a||t.options)&&(n=n||{},r=(t.options||[]).slice()),t.media){n=n||{};var s=t.media;d(s,function(t){t&&t.option&&(t.query?o.push(t):i||(i=t))})}return n||(n=t),n.timeline||(n.timeline=a),d([n].concat(r).concat(h.map(o,function(t){return t.option})),function(t){d(e,function(e){e(t)})}),{baseOption:n,timelineOptions:r,mediaDefault:i,mediaList:o}}function o(t,e,i){var n={width:e,height:i,aspectratio:e/i},r=!0;return h.each(t,function(t,e){var i=e.match(m);if(i&&i[1]&&i[2]){var o=i[1],s=i[2].toLowerCase();a(n[s],t,o)||(r=!1)}}),r}function a(t,e,i){return"min"===i?t>=e:"max"===i?e>=t:t===e}function s(t,e){return t.join(",")===e.join(",")}function l(t,e){e=e||{},d(e,function(e,i){if(null!=e){var n=t[i];if(u.hasClass(i)){e=c.normalizeToArray(e),n=c.normalizeToArray(n);var r=c.mappingToExists(n,e);t[i]=p(r,function(t){return t.option&&t.exist?g(t.exist,t.option,!0):t.exist||t.option})}else t[i]=g(n,e,!0)}})}var h=i(1),c=i(7),u=i(10),d=h.each,f=h.clone,p=h.map,g=h.merge,m=/^(min|max)?(.+)$/;n.prototype={constructor:n,setOption:function(t,e){t=f(t,!0);var i=this._optionBackup,n=this._newOptionBackup=r.call(this,t,e);i?(l(i.baseOption,n.baseOption),n.timelineOptions.length&&(i.timelineOptions=n.timelineOptions),n.mediaList.length&&(i.mediaList=n.mediaList),n.mediaDefault&&(i.mediaDefault=n.mediaDefault)):this._optionBackup=n},mountOption:function(t){var e=t?this._optionBackup:this._newOptionBackup;return this._timelineOptions=p(e.timelineOptions,f),this._mediaList=p(e.mediaList,f),this._mediaDefault=f(e.mediaDefault),this._currentMediaIndices=[],f(e.baseOption)},getTimelineOption:function(t){var e,i=this._timelineOptions;if(i.length){var n=t.getComponent("timeline");n&&(e=f(i[n.getCurrentIndex()],!0))}return e},getMediaOption:function(t){var e=this._api.getWidth(),i=this._api.getHeight(),n=this._mediaList,r=this._mediaDefault,a=[],l=[];if(!n.length&&!r)return l;for(var h=0,c=n.length;c>h;h++)o(n[h].query,e,i)&&a.push(h);return!a.length&&r&&(a=[-1]),a.length&&!s(a,this._currentMediaIndices)&&(l=p(a,function(t){return f(-1===t?r.option:n[t].option)})),this._currentMediaIndices=a,l}},t.exports=n},function(t,e){var i="";"undefined"!=typeof navigator&&(i=navigator.platform||""),t.exports={color:["#c23531","#2f4554","#61a0a8","#d48265","#91c7ae","#749f83","#ca8622","#bda29a","#6e7074","#546570","#c4ccd3"],grid:{},textStyle:{fontFamily:i.match(/^Win/)?"Microsoft YaHei":"sans-serif",fontSize:12,fontStyle:"normal",fontWeight:"normal"},animation:!0,animationThreshold:2e3,animationDuration:1e3,animationDurationUpdate:300,animationEasing:"exponentialOut",animationEasingUpdate:"cubicOut"}},function(t,e,i){t.exports={getAreaStyle:i(30)([["fill","color"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["opacity"],["shadowColor"]])}},function(t,e){t.exports={getBoxLayoutParams:function(){return{left:this.get("left"),top:this.get("top"),right:this.get("right"),bottom:this.get("bottom"),width:this.get("width"),height:this.get("height")}}}},function(t,e,i){t.exports={getItemStyle:i(30)([["fill","color"],["stroke","borderColor"],["lineWidth","borderWidth"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]])}},function(t,e,i){var n=i(30)([["lineWidth","width"],["stroke","color"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]]);t.exports={getLineStyle:function(t){var e=n.call(this,t),i=this.getLineDash();return i&&(e.lineDash=i),e},getLineDash:function(){var t=this.get("type");return"solid"===t||null==t?null:"dashed"===t?[5,5]:[1,1]}}},function(t,e,i){function n(t,e){return t&&t.getShallow(e)}var r=i(17);t.exports={getTextColor:function(){var t=this.ecModel;return this.getShallow("color")||t&&t.get("textStyle.color")},getFont:function(){var t=this.ecModel,e=t&&t.getModel("textStyle");return[this.getShallow("fontStyle")||n(e,"fontStyle"),this.getShallow("fontWeight")||n(e,"fontWeight"),(this.getShallow("fontSize")||n(e,"fontSize")||12)+"px",this.getShallow("fontFamily")||n(e,"fontFamily")||"sans-serif"].join(" ")},getTextRect:function(t){var e=this.get("textStyle")||{};return r.getBoundingRect(t,this.getFont(),e.align,e.baseline)},ellipsis:function(t,e,i){return r.ellipsis(t,this.getFont(),e,i)}}},function(t,e,i){function n(t,e){e=e.split(",");for(var i=t,n=0;ne&&(e=t[i]);return e},min:function(t){for(var e=1/0,i=0;i1){var u;"string"==typeof r?u=i[r]:"function"==typeof r&&(u=r),u&&(e=e.downSample(s.dim,1/c,u,n),t.setData(e))}}},this)}},function(t,e,i){var n=i(1),r=i(32),o=i(4),a=i(37),s=r.prototype,l=a.prototype,h=Math.floor,c=Math.ceil,u=Math.pow,d=10,f=Math.log,p=r.extend({type:"log",getTicks:function(){return n.map(l.getTicks.call(this),function(t){return o.round(u(d,t))})},getLabel:l.getLabel,scale:function(t){return t=s.scale.call(this,t),u(d,t)},setExtent:function(t,e){t=f(t)/f(d),e=f(e)/f(d),l.setExtent.call(this,t,e)},getExtent:function(){var t=s.getExtent.call(this);return t[0]=u(d,t[0]),t[1]=u(d,t[1]),t},unionExtent:function(t){t[0]=f(t[0])/f(d),t[1]=f(t[1])/f(d),s.unionExtent.call(this,t)},niceTicks:function(t){t=t||10;var e=this._extent,i=e[1]-e[0];if(!(i===1/0||0>=i)){var n=u(10,h(f(i/t)/Math.LN10)),r=t/i*n;.5>=r&&(n*=10);var a=[o.round(c(e[0]/n)*n),o.round(h(e[1]/n)*n)];this._interval=n,this._niceExtent=a}},niceExtent:l.niceExtent});n.each(["contain","normalize"],function(t){p.prototype[t]=function(e){return e=f(e)/f(d),s[t].call(this,e)}}),p.create=function(){return new p},t.exports=p},function(t,e,i){var n=i(1),r=i(32),o=r.prototype,a=r.extend({type:"ordinal",init:function(t,e){this._data=t,this._extent=e||[0,t.length-1]},parse:function(t){return"string"==typeof t?n.indexOf(this._data,t):Math.round(t)},contain:function(t){return t=this.parse(t),o.contain.call(this,t)&&null!=this._data[t]},normalize:function(t){return o.normalize.call(this,this.parse(t))},scale:function(t){return Math.round(o.scale.call(this,t))},getTicks:function(){for(var t=[],e=this._extent,i=e[0];i<=e[1];)t.push(i),i++;return t},getLabel:function(t){return this._data[t]},count:function(){return this._extent[1]-this._extent[0]+1},niceTicks:n.noop,niceExtent:n.noop});a.create=function(){return new a},t.exports=a},function(t,e,i){var n=i(1),r=i(4),o=i(9),a=i(37),s=a.prototype,l=Math.ceil,h=Math.floor,c=864e5,u=function(t,e,i,n){for(;n>i;){var r=i+n>>>1;t[r][2]=0&&f():o>=0?f():i&&(u=setTimeout(f,-o)),h=l};return p.clear=function(){u&&(clearTimeout(u),u=null)},p}var o,a,s,l=(new Date).getTime(),h=0,c=0,u=null,d="function"==typeof t;if(e=e||0,d)return r();for(var f=[],p=0;p=0;r--)if(!n[r].silent&&n[r]!==i&&!n[r].ignore&&a(n[r],t,e))return n[r]}},f.mixin(A,m),f.mixin(A,p),t.exports=A},function(t,e,i){function n(){return!1}function r(t,e,i,n){var r=document.createElement(e),o=i.getWidth(),a=i.getHeight(),s=r.style;return s.position="absolute",s.left=0,s.top=0,s.width=o+"px",s.height=a+"px",r.width=o*n,r.height=a*n,r.setAttribute("data-zr-dom-id",t),r}var o=i(1),a=i(42),s=function(t,e,i){var s;i=i||a.devicePixelRatio,"string"==typeof t?s=r(t,"canvas",e,i):o.isObject(t)&&(s=t,t=s.id),this.id=t,this.dom=s;var l=s.style;l&&(s.onselectstart=n,l["-webkit-user-select"]="none",l["user-select"]="none",l["-webkit-touch-callout"]="none",l["-webkit-tap-highlight-color"]="rgba(0,0,0,0)"),this.domBack=null,this.ctxBack=null,this.painter=e,this.config=null,this.clearColor=0,this.motionBlur=!1,this.lastFrameAlpha=.7,this.dpr=i};s.prototype={constructor:s,elCount:0,__dirty:!0,initContext:function(){this.ctx=this.dom.getContext("2d");var t=this.dpr;1!=t&&this.ctx.scale(t,t)},createBackBuffer:function(){var t=this.dpr;this.domBack=r("back-"+this.id,"canvas",this.painter,t),this.ctxBack=this.domBack.getContext("2d"),1!=t&&this.ctxBack.scale(t,t)},resize:function(t,e){var i=this.dpr,n=this.dom,r=n.style,o=this.domBack;r.width=t+"px",r.height=e+"px",n.width=t*i,n.height=e*i,1!=i&&this.ctx.scale(i,i),o&&(o.width=t*i,o.height=e*i,1!=i&&this.ctxBack.scale(i,i))},clear:function(t){var e=this.dom,i=this.ctx,n=e.width,r=e.height,o=this.clearColor,a=this.motionBlur&&!t,s=this.lastFrameAlpha,l=this.dpr;if(a&&(this.domBack||this.createBackBuffer(),this.ctxBack.globalCompositeOperation="copy",this.ctxBack.drawImage(e,0,0,n/l,r/l)),i.clearRect(0,0,n/l,r/l),o&&(i.save(),i.fillStyle=this.clearColor,i.fillRect(0,0,n/l,r/l),i.restore()),a){var h=this.domBack;i.save(),i.globalAlpha=s,i.drawImage(h,0,0,n/l,r/l),i.restore()}}},t.exports=s},function(t,e,i){"use strict";function n(t){return parseInt(t,10)}function r(t){return t?t.isBuildin?!0:"function"==typeof t.resize&&"function"==typeof t.refresh:!1}function o(t){t.__unusedCount++}function a(t){t.__dirty=!1,1==t.__unusedCount&&t.clear()}function s(t,e,i){return g.copy(t.getBoundingRect()),t.transform&&g.applyTransform(t.transform),m.width=e,m.height=i,!g.intersect(m)}function l(t,e){if(!t||!e||t.length!==e.length)return!0;for(var i=0;ip;p++){var m=t[p],v=this._singleCanvas?0:m.zlevel;if(n!==v&&(n=v,i=this.getLayer(n),i.isBuildin||d("ZLevel "+n+" has been used by unkown layer "+i.id),r=i.ctx,i.__unusedCount=0,(i.__dirty||e)&&i.clear()),(i.__dirty||e)&&!m.invisible&&0!==m.style.opacity&&m.scale[0]&&m.scale[1]&&(!m.culling||!s(m,c,u))){var y=m.__clipPaths;l(y,f)&&(f&&r.restore(),y&&(r.save(),h(y,r)),f=y),m.beforeBrush&&m.beforeBrush(r),m.brush(r,!1),m.afterBrush&&m.afterBrush(r)}m.__dirty=!1}f&&r.restore(),this.eachBuildinLayer(a)},getLayer:function(t){if(this._singleCanvas)return this._layers[0];var e=this._layers[t];return e||(e=new p("zr_"+t,this,this.dpr),e.isBuildin=!0,this._layerConfig[t]&&u.merge(e,this._layerConfig[t],!0),this.insertLayer(t,e),e.initContext()),e},insertLayer:function(t,e){var i=this._layers,n=this._zlevelList,o=n.length,a=null,s=-1,l=this._domRoot;if(i[t])return void d("ZLevel "+t+" has been used already");if(!r(e))return void d("Layer of zlevel "+t+" is not valid");if(o>0&&t>n[0]){for(s=0;o-1>s&&!(n[s]t);s++);a=i[n[s]]}if(n.splice(s+1,0,t),a){var h=a.dom;h.nextSibling?l.insertBefore(e.dom,h.nextSibling):l.appendChild(e.dom)}else l.firstChild?l.insertBefore(e.dom,l.firstChild):l.appendChild(e.dom);i[t]=e},eachLayer:function(t,e){var i,n,r=this._zlevelList;for(n=0;nn;n++){var o=t[n],a=this._singleCanvas?0:o.zlevel,s=e[a];if(s){if(s.elCount++,s.__dirty)continue;s.__dirty=o.__dirty}}this.eachBuildinLayer(function(t,e){i[e]!==t.elCount&&(t.__dirty=!0)})},clear:function(){return this.eachBuildinLayer(this._clearLayer),this},_clearLayer:function(t){t.clear()},configLayer:function(t,e){if(e){var i=this._layerConfig;i[t]?u.merge(i[t],e,!0):i[t]=e;var n=this._layers[t];n&&u.merge(n,i[t],!0)}},delLayer:function(t){var e=this._layers,i=this._zlevelList,n=e[t];n&&(n.dom.parentNode.removeChild(n.dom),delete e[t],i.splice(u.indexOf(i,t),1))},resize:function(t,e){var i=this._domRoot;if(i.style.display="none",t=t||this._getWidth(),e=e||this._getHeight(),i.style.display="",this._width!=t||e!=this._height){i.style.width=t+"px",i.style.height=e+"px";for(var n in this._layers)this._layers[n].resize(t,e);this.refresh(!0)}return this._width=t,this._height=e,this},clearLayer:function(t){var e=this._layers[t];e&&e.clear()},dispose:function(){this.root.innerHTML="",this.root=this.storage=this._domRoot=this._layers=null},getRenderedCanvas:function(t){if(t=t||{},this._singleCanvas)return this._layers[0].dom;var e=new p("image",this,t.pixelRatio||this.dpr);e.initContext();var i=e.ctx;e.clearColor=t.backgroundColor,e.clear();for(var n=this.storage.getDisplayList(!0),r=0;rr;r++)this._updateAndAddDisplayable(e[r],null,t);i.length=this._displayListLen;for(var r=0,o=i.length;o>r;r++)i[r].__renderidx=r;i.sort(n)},_updateAndAddDisplayable:function(t,e,i){if(!t.ignore||i){t.beforeUpdate(),t.update(),t.afterUpdate();var n=t.clipPath;if(n&&(n.parent=t,n.updateTransform(),e?(e=e.slice(),e.push(n)):e=[n]),"group"==t.type){for(var r=t._children,o=0;oe;e++)this.delRoot(t[e]);else{var a;a="string"==typeof t?this._elements[t]:t;var s=r.indexOf(this._roots,a);s>=0&&(this.delFromMap(a.id),this._roots.splice(s,1),a instanceof o&&a.delChildrenFromStorage(this))}},addToMap:function(t){return t instanceof o&&(t.__storage=this),t.dirty(),this._elements[t.id]=t,this},get:function(t){return this._elements[t]},delFromMap:function(t){var e=this._elements,i=e[t];return i&&(delete e[t],i instanceof o&&(i.__storage=null)),this},dispose:function(){this._elements=this._renderList=this._roots=null}},t.exports=a},function(t,e,i){"use strict";var n=i(1),r=i(33).Dispatcher,o="undefined"!=typeof window&&(window.requestAnimationFrame||window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(t){setTimeout(t,16)},a=i(56),s=function(t){t=t||{},this.stage=t.stage||{},this.onframe=t.onframe||function(){},this._clips=[],this._running=!1,this._time=0,r.call(this)};s.prototype={constructor:s,addClip:function(t){this._clips.push(t)},addAnimator:function(t){t.animation=this;for(var e=t.getClips(),i=0;i=0&&this._clips.splice(e,1)},removeAnimator:function(t){for(var e=t.getClips(),i=0;ia;a++){var s=i[a],l=s.step(t);l&&(r.push(l),o.push(s))}for(var a=0;n>a;)i[a]._needsRemove?(i[a]=i[n-1],i.pop(),n--):a++;n=r.length;for(var a=0;n>a;a++)o[a].fire(r[a]);this._time=t,this.onframe(e),this.trigger("frame",e),this.stage.update&&this.stage.update()},start:function(){function t(){e._running&&(o(t),e._update())}var e=this;this._running=!0,this._time=(new Date).getTime(),o(t)},stop:function(){this._running=!1},clear:function(){this._clips=[]},animate:function(t,e){e=e||{};var i=new a(t,e.loop,e.getter,e.setter);return i}},n.mixin(s,r),t.exports=s},function(t,e,i){function n(t){this._target=t.target,this._life=t.life||1e3,this._delay=t.delay||0,this._initialized=!1,this.loop=null==t.loop?!1:t.loop,this.gap=t.gap||0,this.easing=t.easing||"Linear",this.onframe=t.onframe,this.ondestroy=t.ondestroy,this.onrestart=t.onrestart}var r=i(132);n.prototype={constructor:n,step:function(t){this._initialized||(this._startTime=(new Date).getTime()+this._delay,this._initialized=!0);var e=(t-this._startTime)/this._life;if(!(0>e)){e=Math.min(e,1);var i=this.easing,n="string"==typeof i?r[i]:i,o="function"==typeof n?n(e):e;return this.fire("frame",o),1==e?this.loop?(this.restart(),"restart"):(this._needsRemove=!0,"destroy"):null}},restart:function(){var t=(new Date).getTime(),e=(t-this._startTime)%this._life;this._startTime=(new Date).getTime()-e+this.gap,this._needsRemove=!1},fire:function(t,e){t="on"+t,this[t]&&this[t](this._target,e)}},t.exports=n},function(t,e){var i={linear:function(t){return t},quadraticIn:function(t){return t*t},quadraticOut:function(t){return t*(2-t)},quadraticInOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},cubicIn:function(t){return t*t*t},cubicOut:function(t){return--t*t*t+1},cubicInOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},quarticIn:function(t){return t*t*t*t},quarticOut:function(t){return 1- --t*t*t*t},quarticInOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},quinticIn:function(t){return t*t*t*t*t},quinticOut:function(t){return--t*t*t*t*t+1},quinticInOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},sinusoidalIn:function(t){return 1-Math.cos(t*Math.PI/2)},sinusoidalOut:function(t){return Math.sin(t*Math.PI/2)},sinusoidalInOut:function(t){return.5*(1-Math.cos(Math.PI*t))},exponentialIn:function(t){return 0===t?0:Math.pow(1024,t-1)},exponentialOut:function(t){return 1===t?1:1-Math.pow(2,-10*t)},exponentialInOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(2,-10*(t-1))+2)},circularIn:function(t){return 1-Math.sqrt(1-t*t)},circularOut:function(t){return Math.sqrt(1- --t*t)},circularInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},elasticIn:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),-(i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)))},elasticOut:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/n)+1)},elasticInOut:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),(t*=2)<1?-.5*(i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)):i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)*.5+1)},backIn:function(t){var e=1.70158;return t*t*((e+1)*t-e)},backOut:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},backInOut:function(t){var e=2.5949095;return(t*=2)<1?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+2)},bounceIn:function(t){return 1-i.bounceOut(1-t)},bounceOut:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},bounceInOut:function(t){return.5>t?.5*i.bounceIn(2*t):.5*i.bounceOut(2*t-1)+.5}};t.exports=i},function(t,e,i){var n=i(57).normalizeRadian,r=2*Math.PI;t.exports={containStroke:function(t,e,i,o,a,s,l,h,c){if(0===l)return!1;var u=l;h-=t,c-=e;var d=Math.sqrt(h*h+c*c);if(d-u>i||i>d+u)return!1;if(Math.abs(o-a)%r<1e-4)return!0;if(s){var f=o;o=n(a),a=n(f)}else o=n(o),a=n(a);o>a&&(a+=r);var p=Math.atan2(c,h);return 0>p&&(p+=r),p>=o&&a>=p||p+r>=o&&a>=p+r}}},function(t,e,i){var n=i(18);t.exports={containStroke:function(t,e,i,r,o,a,s,l,h,c,u){if(0===h)return!1;var d=h;if(u>e+d&&u>r+d&&u>a+d&&u>l+d||e-d>u&&r-d>u&&a-d>u&&l-d>u||c>t+d&&c>i+d&&c>o+d&&c>s+d||t-d>c&&i-d>c&&o-d>c&&s-d>c)return!1;var f=n.cubicProjectPoint(t,e,i,r,o,a,s,l,c,u,null);return d/2>=f}}},function(t,e){t.exports={containStroke:function(t,e,i,n,r,o,a){if(0===r)return!1;var s=r,l=0,h=t;if(a>e+s&&a>n+s||e-s>a&&n-s>a||o>t+s&&o>i+s||t-s>o&&i-s>o)return!1;if(t===i)return Math.abs(o-t)<=s/2;l=(e-n)/(t-i),h=(t*n-i*e)/(t-i);var c=l*o-a+h,u=c*c/(l*l+1);return s/2*s/2>=u}}},function(t,e,i){"use strict";function n(t,e){return Math.abs(t-e)e&&c>n&&c>a&&c>l||e>c&&n>c&&a>c&&l>c)return 0;var u=g.cubicRootAt(e,n,a,l,c,_);if(0===u)return 0;for(var d,f,p=0,m=-1,v=0;u>v;v++){var y=_[v],x=g.cubicAt(t,i,o,s,y);h>x||(0>m&&(m=g.cubicExtrema(e,n,a,l,b),b[1]1&&r(),d=g.cubicAt(e,n,a,l,b[0]),m>1&&(f=g.cubicAt(e,n,a,l,b[1]))),p+=2==m?yd?1:-1:yf?1:-1:f>l?1:-1:yd?1:-1:d>l?1:-1)}return p}function a(t,e,i,n,r,o,a,s){if(s>e&&s>n&&s>o||e>s&&n>s&&o>s)return 0;var l=g.quadraticRootAt(e,n,o,s,_);if(0===l)return 0;var h=g.quadraticExtremum(e,n,o);if(h>=0&&1>=h){for(var c=0,u=g.quadraticAt(e,n,o,h),d=0;l>d;d++){var f=g.quadraticAt(t,i,r,_[d]);f>a||(c+=_[d]u?1:-1:u>o?1:-1)}return c}var f=g.quadraticAt(t,i,r,_[0]);return f>a?0:e>o?1:-1}function s(t,e,i,n,r,o,a,s){if(s-=e,s>i||-i>s)return 0;var l=Math.sqrt(i*i-s*s);_[0]=-l,_[1]=l;var h=Math.abs(n-r);if(1e-4>h)return 0;if(1e-4>h%y){n=0,r=y;var c=o?1:-1;return a>=_[0]+t&&a<=_[1]+t?c:0}if(o){var l=n;n=p(r),r=p(l)}else n=p(n),r=p(r);n>r&&(r+=y);for(var u=0,d=0;2>d;d++){var f=_[d];if(f+t>a){var g=Math.atan2(s,f),c=o?1:-1;0>g&&(g=y+g),(g>=n&&r>=g||g+y>=n&&r>=g+y)&&(g>Math.PI/2&&g<1.5*Math.PI&&(c=-c),u+=c)}}return u}function l(t,e,i,r,l){for(var c=0,p=0,g=0,y=0,x=0,_=0;_1&&(i||(c+=m(p,g,y,x,r,l)),0!==c))return!0;switch(1==_&&(p=t[_],g=t[_+1],y=p,x=g),b){case h.M:y=t[_++],x=t[_++],p=y,g=x;break;case h.L:if(i){if(v(p,g,t[_],t[_+1],e,r,l))return!0}else c+=m(p,g,t[_],t[_+1],r,l)||0;p=t[_++],g=t[_++];break;case h.C:if(i){if(u.containStroke(p,g,t[_++],t[_++],t[_++],t[_++],t[_],t[_+1],e,r,l))return!0}else c+=o(p,g,t[_++],t[_++],t[_++],t[_++],t[_],t[_+1],r,l)||0;p=t[_++],g=t[_++];break;case h.Q:if(i){if(d.containStroke(p,g,t[_++],t[_++],t[_],t[_+1],e,r,l))return!0}else c+=a(p,g,t[_++],t[_++],t[_],t[_+1],r,l)||0;p=t[_++],g=t[_++];break;case h.A:var w=t[_++],M=t[_++],S=t[_++],A=t[_++],T=t[_++],C=t[_++],I=(t[_++],1-t[_++]),k=Math.cos(T)*S+w,D=Math.sin(T)*A+M;_>1?c+=m(p,g,k,D,r,l):(y=k,x=D);var L=(r-w)*A/S+w;if(i){if(f.containStroke(w,M,A,T,T+C,I,e,L,l))return!0}else c+=s(w,M,A,T,T+C,I,L,l);p=Math.cos(T+C)*S+w,g=Math.sin(T+C)*A+M;break;case h.R:y=p=t[_++],x=g=t[_++];var P=t[_++],z=t[_++],k=y+P,D=x+z;if(i){if(v(y,x,k,x,e,r,l)||v(k,x,k,D,e,r,l)||v(k,D,y,D,e,r,l)||v(y,D,k,D,e,r,l))return!0}else c+=m(k,x,k,D,r,l),c+=m(y,D,y,x,r,l);break;case h.Z:if(i){if(v(p,g,y,x,e,r,l))return!0}else if(c+=m(p,g,y,x,r,l),0!==c)return!0;p=y,g=x}}return i||n(g,x)||(c+=m(p,g,y,x,r,l)||0),0!==c}var h=i(27).CMD,c=i(135),u=i(134),d=i(137),f=i(133),p=i(57).normalizeRadian,g=i(18),m=i(75),v=c.containStroke,y=2*Math.PI,x=1e-4,_=[-1,-1,-1],b=[-1,-1];t.exports={contain:function(t,e,i){return l(t,0,!1,e,i)},containStroke:function(t,e,i,n){return l(t,e,!0,i,n)}}},function(t,e,i){var n=i(18);t.exports={containStroke:function(t,e,i,r,o,a,s,l,h){if(0===s)return!1;var c=s;if(h>e+c&&h>r+c&&h>a+c||e-c>h&&r-c>h&&a-c>h||l>t+c&&l>i+c&&l>o+c||t-c>l&&i-c>l&&o-c>l)return!1;var u=n.quadraticProjectPoint(t,e,i,r,o,a,l,h,null);return c/2>=u}}},function(t,e){"use strict";function i(t){var e=t[1][0]-t[0][0],i=t[1][1]-t[0][1];return Math.sqrt(e*e+i*i)}function n(t){return[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2]}var r=function(){this._track=[]};r.prototype={constructor:r,recognize:function(t,e){return this._doTrack(t,e),this._recognize(t)},clear:function(){return this._track.length=0,this},_doTrack:function(t,e){var i=t.touches;if(i){for(var n={points:[],touches:[],target:e,event:t},r=0,o=i.length;o>r;r++){var a=i[r];n.points.push([a.clientX,a.clientY]),n.touches.push(a)}this._track.push(n)}},_recognize:function(t){for(var e in o)if(o.hasOwnProperty(e)){var i=o[e](this._track,t);if(i)return i}}};var o={pinch:function(t,e){var r=t.length;if(r){var o=(t[r-1]||{}).points,a=(t[r-2]||{}).points||o;if(a&&a.length>1&&o&&o.length>1){var s=i(o)/i(a);!isFinite(s)&&(s=1),e.pinchScale=s;var l=n(o);return e.pinchX=l[0],e.pinchY=l[1],{type:"pinch",target:t[0].target,event:e}}}}};t.exports=r},function(t,e){var i=function(){this.head=null,this.tail=null,this._len=0},n=i.prototype;n.insert=function(t){var e=new r(t);return this.insertEntry(e),e},n.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,this.tail=t):this.head=this.tail=t,this._len++},n.remove=function(t){var e=t.prev,i=t.next;e?e.next=i:this.head=i,i?i.prev=e:this.tail=e,t.next=t.prev=null,this._len--},n.len=function(){return this._len};var r=function(t){this.value=t,this.next,this.prev},o=function(t){this._list=new i,this._map={},this._maxSize=t||10},a=o.prototype;a.put=function(t,e){var i=this._list,n=this._map;if(null==n[t]){var r=i.len();if(r>=this._maxSize&&r>0){var o=i.head;i.remove(o),delete n[o.key]}var a=i.insert(e);a.key=t,n[t]=a}},a.get=function(t){var e=this._map[t],i=this._list;return null!=e?(e!==i.tail&&(i.remove(e),i.insertEntry(e)),e.value):void 0},a.clear=function(){this._list.clear(),this._map={}},t.exports=o},function(t,e,i){"use strict";var n=i(1),r=i(16),o=function(t,e,i,n){this.x=null==t?.5:t,this.y=null==e?.5:e,this.r=null==i?.5:i,r.call(this,n)};o.prototype={constructor:o,type:"radial",updateCanvasGradient:function(t,e){for(var i=t.getBoundingRect(),n=i.width,r=i.height,o=Math.min(n,r),a=this.x*n+i.x,s=this.y*r+i.y,l=this.r*o,h=e.createRadialGradient(a,s,0,a,s,l),c=this.colorStops,u=0;uy;y++)r(d,d,t[y]),o(f,f,t[y]);r(d,d,h[0]),o(f,f,h[1])}for(var y=0,x=t.length;x>y;y++){var _=t[y];if(i)c=t[y?y-1:x-1],u=t[(y+1)%x];else{if(0===y||y===x-1){p.push(n.clone(t[y]));continue}c=t[y-1],u=t[y+1]}n.sub(g,u,c),a(g,g,e);var b=s(_,c),w=s(_,u),M=b+w;0!==M&&(b/=M,w/=M),a(m,g,-b),a(v,g,w);var S=l([],_,m),A=l([],_,v);h&&(o(S,S,d),r(S,S,f),o(A,A,d),r(A,A,f)),p.push(S),p.push(A)}return i&&p.push(p.shift()),p}},function(t,e,i){function n(t,e,i,n,r,o,a){var s=.5*(i-t),l=.5*(n-e);return(2*(e-i)+s+l)*a+(-3*(e-i)-2*s-l)*o+s*r+e}var r=i(5);t.exports=function(t,e){for(var i=t.length,o=[],a=0,s=1;i>s;s++)a+=r.distance(t[s-1],t[s]);var l=a/2;l=i>l?i:l;for(var s=0;l>s;s++){var h,c,u,d=s/(l-1)*(e?i:i-1),f=Math.floor(d),p=d-f,g=t[f%i];e?(h=t[(f-1+i)%i],c=t[(f+1)%i],u=t[(f+2)%i]):(h=t[0===f?f:f-1],c=t[f>i-2?i-1:f+1],u=t[f>i-3?i-1:f+2]);var m=p*p,v=p*m;o.push([n(h[0],g[0],c[0],u[0],p,m,v),n(h[1],g[1],c[1],u[1],p,m,v)])}return o}},function(t,e,i){t.exports=i(6).extend({type:"arc",shape:{cx:0,cy:0,r:0,startAngle:0,endAngle:2*Math.PI,clockwise:!0},style:{stroke:"#000",fill:null},buildPath:function(t,e){var i=e.cx,n=e.cy,r=Math.max(e.r,0),o=e.startAngle,a=e.endAngle,s=e.clockwise,l=Math.cos(o),h=Math.sin(o);t.moveTo(l*r+i,h*r+n),t.arc(i,n,r,o,a,!s)}})},function(t,e,i){"use strict";var n=i(18),r=n.quadraticSubdivide,o=n.cubicSubdivide,a=n.quadraticAt,s=n.cubicAt,l=[];t.exports=i(6).extend({type:"bezier-curve",shape:{x1:0,y1:0,x2:0,y2:0,cpx1:0,cpy1:0,percent:1},style:{stroke:"#000",fill:null},buildPath:function(t,e){var i=e.x1,n=e.y1,a=e.x2,s=e.y2,h=e.cpx1,c=e.cpy1,u=e.cpx2,d=e.cpy2,f=e.percent;0!==f&&(t.moveTo(i,n),null==u||null==d?(1>f&&(r(i,h,a,f,l),h=l[1],a=l[2],r(n,c,s,f,l),c=l[1],s=l[2]),t.quadraticCurveTo(h,c,a,s)):(1>f&&(o(i,h,u,a,f,l),h=l[1],u=l[2],a=l[3],o(n,c,d,s,f,l),c=l[1],d=l[2],s=l[3]),t.bezierCurveTo(h,c,u,d,a,s)))},pointAt:function(t){var e=this.shape,i=e.cpx2,n=e.cpy2;return null===i||null===n?[a(e.x1,e.cpx1,e.x2,t),a(e.y1,e.cpy1,e.y2,t)]:[s(e.x1,e.cpx1,e.cpx1,e.x2,t),s(e.y1,e.cpy1,e.cpy1,e.y2,t)]}})},function(t,e,i){"use strict";t.exports=i(6).extend({type:"circle",shape:{cx:0,cy:0,r:0},buildPath:function(t,e){t.moveTo(e.cx+e.r,e.cy),t.arc(e.cx,e.cy,e.r,0,2*Math.PI,!0)}})},function(t,e,i){t.exports=i(6).extend({type:"line",shape:{x1:0,y1:0,x2:0,y2:0,percent:1},style:{stroke:"#000",fill:null},buildPath:function(t,e){var i=e.x1,n=e.y1,r=e.x2,o=e.y2,a=e.percent;0!==a&&(t.moveTo(i,n),1>a&&(r=i*(1-a)+r*a,o=n*(1-a)+o*a),t.lineTo(r,o))},pointAt:function(t){var e=this.shape;return[e.x1*(1-t)+e.x2*t,e.y1*(1-t)+e.y2*t]}})},function(t,e,i){var n=i(59);t.exports=i(6).extend({type:"polygon",shape:{points:null,smooth:!1,smoothConstraint:null},buildPath:function(t,e){n.buildPath(t,e,!0)}})},function(t,e,i){var n=i(59);t.exports=i(6).extend({type:"polyline",shape:{points:null,smooth:!1,smoothConstraint:null},style:{stroke:"#000",fill:null},buildPath:function(t,e){n.buildPath(t,e,!1)}})},function(t,e,i){var n=i(60);t.exports=i(6).extend({type:"rect",shape:{r:0,x:0,y:0,width:0,height:0},buildPath:function(t,e){var i=e.x,r=e.y,o=e.width,a=e.height;e.r?n.buildPath(t,e):t.rect(i,r,o,a),t.closePath()}})},function(t,e,i){t.exports=i(6).extend({type:"ring",shape:{cx:0,cy:0,r:0,r0:0},buildPath:function(t,e){var i=e.cx,n=e.cy,r=2*Math.PI;t.moveTo(i+e.r,n),t.arc(i,n,e.r,0,r,!1),t.moveTo(i+e.r0,n),t.arc(i,n,e.r0,0,r,!0)}})},function(t,e,i){t.exports=i(6).extend({type:"sector",shape:{cx:0,cy:0,r0:0,r:0,startAngle:0,endAngle:2*Math.PI,clockwise:!0},buildPath:function(t,e){var i=e.cx,n=e.cy,r=Math.max(e.r0||0,0),o=Math.max(e.r,0),a=e.startAngle,s=e.endAngle,l=e.clockwise,h=Math.cos(a),c=Math.sin(a);t.moveTo(h*r+i,c*r+n),t.lineTo(h*o+i,c*o+n),t.arc(i,n,o,a,s,!l),t.lineTo(Math.cos(s)*r+i,Math.sin(s)*r+n),0!==r&&t.arc(i,n,r,s,a,l),t.closePath()}})},function(t,e,i){"use strict";var n=i(56),r=i(1),o=r.isString,a=r.isFunction,s=r.isObject,l=i(45),h=function(){this.animators=[]};h.prototype={constructor:h,animate:function(t,e){var i,o=!1,a=this,s=this.__zr;if(t){var h=t.split("."),c=a;o="shape"===h[0];for(var u=0,d=h.length;d>u;u++)c&&(c=c[h[u]]);c&&(i=c)}else i=a;if(!i)return void l('Property "'+t+'" is not existed in element '+a.id);var f=a.animators,p=new n(i,e);return p.during(function(t){a.dirty(o)}).done(function(){f.splice(r.indexOf(f,p),1)}),f.push(p),s&&s.animation.addAnimator(p),p},stopAnimation:function(t){for(var e=this.animators,i=e.length,n=0;i>n;n++)e[n].stop(t);return e.length=0,this},animateTo:function(t,e,i,n,r){function s(){h--,h||r&&r()}o(i)?(r=n,n=i,i=0):a(n)?(r=n,n="linear",i=0):a(i)?(r=i,i=0):a(e)?(r=e,e=500):e||(e=500),this.stopAnimation(),this._animateToShallow("",this,t,e,i,n,r);var l=this.animators.slice(),h=l.length;h||r&&r();for(var c=0;c0&&this.animate(t,!1).when(null==n?500:n,a).delay(o||0),this}},t.exports=h},function(t,e){function i(){this.on("mousedown",this._dragStart,this),this.on("mousemove",this._drag,this),this.on("mouseup",this._dragEnd,this),this.on("globalout",this._dragEnd,this)}i.prototype={constructor:i,_dragStart:function(t){var e=t.target;e&&e.draggable&&(this._draggingTarget=e,e.dragging=!0,this._x=t.offsetX,this._y=t.offsetY,this._dispatchProxy(e,"dragstart",t.event))},_drag:function(t){var e=this._draggingTarget;if(e){var i=t.offsetX,n=t.offsetY,r=i-this._x,o=n-this._y;this._x=i,this._y=n,e.drift(r,o,t),this._dispatchProxy(e,"drag",t.event);var a=this.findHover(i,n,e),s=this._dropTarget;this._dropTarget=a,e!==a&&(s&&a!==s&&this._dispatchProxy(s,"dragleave",t.event),a&&a!==s&&this._dispatchProxy(a,"dragenter",t.event))}},_dragEnd:function(t){ +var e=this._draggingTarget;e&&(e.dragging=!1),this._dispatchProxy(e,"dragend",t.event),this._dropTarget&&this._dispatchProxy(this._dropTarget,"drop",t.event),this._draggingTarget=null,this._dropTarget=null}},t.exports=i},function(t,e,i){function n(t,e,i,n,r,o,a,s,l,h,c){var g=l*(p/180),y=f(g)*(t-i)/2+d(g)*(e-n)/2,x=-1*d(g)*(t-i)/2+f(g)*(e-n)/2,_=y*y/(a*a)+x*x/(s*s);_>1&&(a*=u(_),s*=u(_));var b=(r===o?-1:1)*u((a*a*(s*s)-a*a*(x*x)-s*s*(y*y))/(a*a*(x*x)+s*s*(y*y)))||0,w=b*a*x/s,M=b*-s*y/a,S=(t+i)/2+f(g)*w-d(g)*M,A=(e+n)/2+d(g)*w+f(g)*M,T=v([1,0],[(y-w)/a,(x-M)/s]),C=[(y-w)/a,(x-M)/s],I=[(-1*y-w)/a,(-1*x-M)/s],k=v(C,I);m(C,I)<=-1&&(k=p),m(C,I)>=1&&(k=0),0===o&&k>0&&(k-=2*p),1===o&&0>k&&(k+=2*p),c.addData(h,S,A,a,s,T,k,g,o)}function r(t){if(!t)return[];var e,i=t.replace(/-/g," -").replace(/ /g," ").replace(/ /g,",").replace(/,,/g,",");for(e=0;e0&&""===m[0]&&m.shift();for(var v=0;vn;n++)i=t[n],i.__dirty&&i.buildPath(i.path,i.shape),r.push(i.path);var s=new a(e);return s.buildPath=function(t){t.appendPath(r);var e=t.getContext();e&&t.rebuildPath(e)},s}}},function(t,e,i){function n(t,e){var i,n,o,c,u,d,f=t.data,p=r.M,g=r.C,m=r.L,v=r.R,y=r.A,x=r.Q;for(o=0,c=0;ou;u++){var d=s[u];d[0]=f[o++],d[1]=f[o++],a(d,d,e),f[c++]=d[0],f[c++]=d[1]}}}var r=i(27).CMD,o=i(5),a=o.applyTransform,s=[[],[],[]],l=Math.sqrt,h=Math.atan2;t.exports=n},function(t,e,i){if(!i(15).canvasSupported){var n,r="urn:schemas-microsoft-com:vml",o=window,a=o.document,s=!1;try{!a.namespaces.zrvml&&a.namespaces.add("zrvml",r),n=function(t){return a.createElement("')}}catch(l){n=function(t){return a.createElement("<"+t+' xmlns="'+r+'" class="zrvml">')}}var h=function(){if(!s){s=!0;var t=a.styleSheets;t.length<31?a.createStyleSheet().addRule(".zrvml","behavior:url(#default#VML)"):t[0].addRule(".zrvml","behavior:url(#default#VML)")}};t.exports={doc:a,initVML:h,createNode:n}}},,function(t,e,i){function n(t,e,i){v.call(this),this.type=t,this.zr=e,this.opt=y.clone(i),this.group=new x.Group,this._containerRect=null,this._track=[],this._dragging,this._cover,this._disabled=!0,this._handlers={mousedown:_(s,this),mousemove:_(l,this),mouseup:_(h,this)},b(C,function(t){this.zr.on(t,this._handlers[t])},this)}function r(t){t.traverse(function(t){t.z=A})}function o(t,e){var i=this.group.transformCoordToLocal(t,e);return!this._containerRect||this._containerRect.contain(i[0],i[1])}function a(t){var e=t.event;e.preventDefault&&e.preventDefault()}function s(t){if(!(this._disabled||t.target&&t.target.draggable)){a(t);var e=t.offsetX,i=t.offsetY;o.call(this,e,i)&&(this._dragging=!0,this._track=[[e,i]])}}function l(t){this._dragging&&!this._disabled&&(a(t),c.call(this,t))}function h(t){this._dragging&&!this._disabled&&(a(t),c.call(this,t,!0),this._dragging=!1,this._track=[])}function c(t,e){var i=t.offsetX,n=t.offsetY;if(o.call(this,i,n)){this._track.push([i,n]);var r=u.call(this)?I[this.type].getRanges.call(this):[];d.call(this,r),this.trigger("selected",y.clone(r)),e&&this.trigger("selectEnd",y.clone(r))}}function u(){var t=this._track;if(!t.length)return!1;var e=t[t.length-1],i=t[0],n=e[0]-i[0],r=e[1]-i[1],o=S(n*n+r*r,.5);return o>T}function d(t){var e=I[this.type];t&&t.length?(this._cover||(this._cover=e.create.call(this),this.group.add(this._cover)),e.update.call(this,t)):(this.group.remove(this._cover),this._cover=null),r(this.group)}function f(){var t=this.group,e=t.parent;e&&e.remove(t)}function p(){var t=this.opt;return new x.Rect({style:{stroke:t.stroke,fill:t.fill,lineWidth:t.lineWidth,opacity:t.opacity}})}function g(){return y.map(this._track,function(t){return this.group.transformCoordToLocal(t[0],t[1])},this)}function m(){var t=g.call(this),e=t.length-1;return 0>e&&(e=0),[t[0],t[e]]}var v=i(21),y=i(1),x=i(3),_=y.bind,b=y.each,w=Math.min,M=Math.max,S=Math.pow,A=1e4,T=2,C=["mousedown","mousemove","mouseup"];n.prototype={constructor:n,enable:function(t,e){this._disabled=!1,f.call(this),this._containerRect=e!==!1?e||t.getBoundingRect():null,t.add(this.group)},update:function(t){d.call(this,t&&y.clone(t))},disable:function(){this._disabled=!0,f.call(this)},dispose:function(){this.disable(),b(C,function(t){this.zr.off(t,this._handlers[t])},this)}},y.mixin(n,v);var I={line:{create:p,getRanges:function(){var t=m.call(this),e=w(t[0][0],t[1][0]),i=M(t[0][0],t[1][0]);return[[e,i]]},update:function(t){var e=t[0],i=this.opt.width;this._cover.setShape({x:e[0],y:-i/2,width:e[1]-e[0],height:i})}},rect:{create:p,getRanges:function(){var t=m.call(this),e=[w(t[1][0],t[0][0]),w(t[1][1],t[0][1])],i=[M(t[1][0],t[0][0]),M(t[1][1],t[0][1])];return[[[e[0],i[0]],[e[1],i[1]]]]},update:function(t){var e=t[0];this._cover.setShape({x:e[0][0],y:e[1][0],width:e[0][1]-e[0][0],height:e[1][1]-e[1][0]})}}};t.exports=n},function(t,e,i){function n(){this.group=new r.Group,this._symbolEl=new s({silent:!0})}var r=i(3),o=i(24),a=i(1),s=r.extendShape({shape:{points:null,sizes:null},symbolProxy:null,buildPath:function(t,e){for(var i=e.points,n=e.sizes,r=this.symbolProxy,o=r.shape,a=0;at.get("largeThreshold")?r:o;this._symbolDraw=s,s.updateData(n),a.add(s.group),a.remove(s===r?o.group:r.group)},updateLayout:function(t){this._symbolDraw.updateLayout(t)},remove:function(t,e){this._symbolDraw&&this._symbolDraw.remove(e,!0)}})},function(t,e,i){i(100),i(39),i(40),i(171),i(172),i(167),i(168),i(98),i(97)},function(t,e,i){function n(t,e){var i=[1/0,-(1/0)];return h(e,function(e){var n=e.getData();n&&h(e.coordDimToDataDim(t),function(t){var e=n.getDataExtent(t);e[0]i[1]&&(i[1]=e[1])})},this),i}function r(t,e,i){var n=i.getAxisModel(),r=n.axis.scale,a=[0,100],s=[t.start,t.end],u=[];return e=e.slice(),o(e,n,r),h(["startValue","endValue"],function(e){u.push(null!=t[e]?r.parse(t[e]):null)}),h([0,1],function(t){var i=u[t],n=s[t];null!=n||null==i?(null==n&&(n=a[t]),i=r.parse(l.linearMap(n,a,e,!0))):n=l.linearMap(i,e,a,!0),u[t]=l.round(i),s[t]=l.round(n)}),{valueWindow:c(u),percentWindow:c(s)}}function o(t,e,i){return h(["min","max"],function(n,r){var o=e.get(n,!0);null!=o&&(o+"").toLowerCase()!=="data"+n&&(t[r]=i.parse(o))}),e.get("scale",!0)||(t[0]>0&&(t[0]=0),t[1]<0&&(t[1]=0)),t}function a(t,e){var i=t.getAxisModel(),n=t._percentWindow,r=t._valueWindow;if(n){var o=e||0===n[0]&&100===n[1],a=!e&&l.getPixelPrecision(r,[0,500]),s=!(e||20>a&&a>=0),h=e||o||s;i.setRange&&i.setRange(h?null:+r[0].toFixed(a),h?null:+r[1].toFixed(a))}}var s=i(1),l=i(4),h=s.each,c=l.asc,u=function(t,e,i,n){this._dimName=t,this._axisIndex=e,this._valueWindow,this._percentWindow,this._dataExtent,this.ecModel=n,this._dataZoomModel=i};u.prototype={constructor:u,hostedBy:function(t){return this._dataZoomModel===t},getDataExtent:function(){return this._dataExtent.slice()},getDataValueWindow:function(){return this._valueWindow.slice()},getDataPercentWindow:function(){return this._percentWindow.slice()},getTargetSeriesModels:function(){var t=[];return this.ecModel.eachSeries(function(e){this._axisIndex===e.get(this._dimName+"AxisIndex")&&t.push(e)},this),t},getAxisModel:function(){return this.ecModel.getComponent(this._dimName+"Axis",this._axisIndex)},getOtherAxisModel:function(){var t,e,i=this._dimName,n=this.ecModel,r=this.getAxisModel(),o="x"===i||"y"===i;o?(e="gridIndex",t="x"===i?"y":"x"):(e="polarIndex",t="angle"===i?"radius":"angle");var a;return n.eachComponent(t+"Axis",function(t){(t.get(e)||0)===(r.get(e)||0)&&(a=t)}),a},reset:function(t){if(t===this._dataZoomModel){var e=this._dataExtent=n(this._dimName,this.getTargetSeriesModels()),i=r(t.option,e,this);this._valueWindow=i.valueWindow,this._percentWindow=i.percentWindow,a(this)}},restore:function(t){t===this._dataZoomModel&&(this._valueWindow=this._percentWindow=null,a(this,!0))},filterData:function(t){function e(t){return t>=o[0]&&t<=o[1]}if(t===this._dataZoomModel){var i=this._dimName,n=this.getTargetSeriesModels(),r=t.get("filterMode"),o=this._valueWindow,a=this.getOtherAxisModel();t.get("$fromToolbox")&&a&&"category"===a.get("type")&&(r="empty"),h(n,function(t){var n=t.getData();n&&h(t.coordDimToDataDim(i),function(i){"empty"===r?t.setData(n.map(i,function(t){return e(t)?t:NaN})):n.filterSelf(i,e)})})}}},t.exports=u},function(t,e,i){t.exports=i(39).extend({type:"dataZoom.inside",defaultOption:{zoomLock:!1}})},function(t,e,i){function n(t,e,i,n){e=e.slice();var r=n.axisModels[0];if(r){var a=o(t,r,i),s=a.signal*(e[1]-e[0])*a.pixel/a.pixelLength;return h(s,e,[0,100],"rigid"),e}}function r(t,e,i,n,r,s){i=i.slice();var l=r.axisModels[0];if(l){var h=o(e,l,n),c=h.pixel-h.pixelStart,u=c/h.pixelLength*(i[1]-i[0])+i[0];return t=Math.max(t,0),i[0]=(i[0]-u)*t+u,i[1]=(i[1]-u)*t+u,a(i)}}function o(t,e,i){var n=e.axis,r=i.rect,o={};return"x"===n.dim?(o.pixel=t[0],o.pixelLength=r.width,o.pixelStart=r.x,o.signal=n.inverse?1:-1):(o.pixel=t[1],o.pixelLength=r.height,o.pixelStart=r.y,o.signal=n.inverse?-1:1),o}function a(t){var e=[0,100];return!(t[0]<=e[1])&&(t[0]=e[1]),!(t[1]<=e[1])&&(t[1]=e[1]),!(t[0]>=e[0])&&(t[0]=e[0]),!(t[1]>=e[0])&&(t[1]=e[0]),t}var s=i(40),l=i(1),h=i(71),c=i(173),u=l.bind,d=s.extend({type:"dataZoom.inside",init:function(t,e){this._range},render:function(t,e,i,n){d.superApply(this,"render",arguments),c.shouldRecordRange(n,t.id)&&(this._range=t.getPercentRange()),l.each(this.getTargetInfo().cartesians,function(e){var n=e.model;c.register(i,{coordId:n.id,coordType:n.type,coordinateSystem:n.coordinateSystem,dataZoomId:t.id,throttleRage:t.get("throttle",!0),panGetRange:u(this._onPan,this,e),zoomGetRange:u(this._onZoom,this,e)})},this)},remove:function(){c.unregister(this.api,this.dataZoomModel.id),d.superApply(this,"remove",arguments),this._range=null},dispose:function(){c.unregister(this.api,this.dataZoomModel.id),d.superApply(this,"dispose",arguments),this._range=null},_onPan:function(t,e,i,r){return this._range=n([i,r],this._range,e,t)},_onZoom:function(t,e,i,n,o){var a=this.dataZoomModel;if(!a.option.zoomLock)return this._range=r(1/i,[n,o],this._range,e,t,a)}});t.exports=d},function(t,e,i){var n=i(39);t.exports=n.extend({type:"dataZoom.select"})},function(t,e,i){t.exports=i(40).extend({type:"dataZoom.select"})},function(t,e,i){var n=i(39),r=(i(11),i(1)),o=n.extend({type:"dataZoom.slider",layoutMode:"box",defaultOption:{show:!0,right:"ph",top:"ph",width:"ph",height:"ph",left:null,bottom:null,backgroundColor:"rgba(47,69,84,0)",dataBackgroundColor:"#ddd",fillerColor:"rgba(47,69,84,0.25)",handleColor:"rgba(47,69,84,0.65)",handleSize:10,labelPrecision:null,labelFormatter:null,showDetail:!0,showDataShadow:"auto",realtime:!0,zoomLock:!1,textStyle:{color:"#333"}},setDefaultLayoutParams:function(t){var e=this.option;r.each(["right","top","width","height"],function(i){"ph"===e[i]&&(e[i]=t[i])})},mergeOption:function(t){o.superApply(this,"mergeOption",arguments)}});t.exports=o},function(t,e,i){function n(t){return"x"===t?"y":"x"}var r=i(1),o=i(3),a=i(125),s=i(40),l=o.Rect,h=i(4),c=h.linearMap,u=i(11),d=i(71),f=h.asc,p=r.bind,g=Math.round,m=Math.max,v=r.each,y=7,x=1,_=30,b="horizontal",w="vertical",M=5,S=["line","bar","candlestick","scatter"],A=s.extend({type:"dataZoom.slider",init:function(t,e){this._displayables={},this._orient,this._range,this._handleEnds,this._size,this._halfHandleSize,this._location,this._dragging,this._dataShadowInfo,this.api=e},render:function(t,e,i,n){return A.superApply(this,"render",arguments),a.createOrUpdate(this,"_dispatchZoomAction",this.dataZoomModel.get("throttle"),"fixRate"),this._orient=t.get("orient"),this._halfHandleSize=g(t.get("handleSize")/2),this.dataZoomModel.get("show")===!1?void this.group.removeAll():(n&&"dataZoom"===n.type&&n.from===this.uid||this._buildView(),void this._updateView())},remove:function(){A.superApply(this,"remove",arguments),a.clear(this,"_dispatchZoomAction")},dispose:function(){A.superApply(this,"dispose",arguments),a.clear(this,"_dispatchZoomAction")},_buildView:function(){var t=this.group;t.removeAll(),this._resetLocation(),this._resetInterval();var e=this._displayables.barGroup=new o.Group;this._renderBackground(),this._renderDataShadow(),this._renderHandle(),t.add(e),this._positionGroup()},_resetLocation:function(){var t=this.dataZoomModel,e=this.api,i=this._findCoordRect(),n={width:e.getWidth(),height:e.getHeight()},r=this._orient===b?{right:n.width-i.x-i.width,top:n.height-_-y,width:i.width,height:_}:{right:y,top:i.y,width:_,height:i.height};t.setDefaultLayoutParams(r);var o=u.getLayoutRect(t.option,n,t.padding);this._location={x:o.x,y:o.y},this._size=[o.width,o.height],this._orient===w&&this._size.reverse()},_positionGroup:function(){var t=this.group,e=this._location,i=this._orient,n=this.dataZoomModel.getFirstTargetAxisModel(),r=n&&n.get("inverse"),o=this._displayables.barGroup,a=(this._dataShadowInfo||{}).otherAxisInverse;o.attr(i!==b||r?i===b&&r?{scale:a?[-1,1]:[-1,-1]}:i!==w||r?{scale:a?[-1,-1]:[-1,1],rotation:Math.PI/2}:{scale:a?[1,-1]:[1,1],rotation:Math.PI/2}:{scale:a?[1,1]:[1,-1]});var s=t.getBoundingRect([o]);t.position[0]=e.x-s.x,t.position[1]=e.y-s.y},_getViewExtent:function(){var t=this._halfHandleSize,e=m(this._size[0],4*t),i=[t,e-t];return i},_renderBackground:function(){var t=this.dataZoomModel,e=this._size;this._displayables.barGroup.add(new l({silent:!0,shape:{x:0,y:0,width:e[0],height:e[1]},style:{fill:t.get("backgroundColor")}}))},_renderDataShadow:function(){var t=this._dataShadowInfo=this._prepareDataShadowInfo();if(t){var e=this._size,i=t.series,n=i.getRawData(),r=i.getShadowDim?i.getShadowDim():t.otherDim,a=n.getDataExtent(r),s=.3*(a[1]-a[0]);a=[a[0]-s,a[1]+s];var l=[0,e[1]],h=[0,e[0]],u=[[e[0],0],[0,0]],d=h[1]/(n.count()-1),f=0,p=Math.round(n.count()/e[0]);n.each([r],function(t,e){if(p>0&&e%p)return void(f+=d);var i=null==t||isNaN(t)||""===t?null:c(t,a,l,!0);null!=i&&u.push([f,i]),f+=d}),this._displayables.barGroup.add(new o.Polyline({shape:{points:u},style:{fill:this.dataZoomModel.get("dataBackgroundColor"),lineWidth:0},silent:!0,z2:-20}))}},_prepareDataShadowInfo:function(){var t=this.dataZoomModel,e=t.get("showDataShadow");if(e!==!1){var i,o=this.ecModel;return t.eachTargetAxis(function(a,s){var l=t.getAxisProxy(a.name,s).getTargetSeriesModels();r.each(l,function(t){if(!(i||e!==!0&&r.indexOf(S,t.get("type"))<0)){var l=n(a.name),h=o.getComponent(a.axis,s).axis;i={thisAxis:h,series:t,thisDim:a.name,otherDim:l,otherAxisInverse:t.coordinateSystem.getOtherAxis(h).inverse}}},this)},this),i}},_renderHandle:function(){var t=this._displayables,e=t.handles=[],i=t.handleLabels=[],n=this._displayables.barGroup,r=this._size;n.add(t.filler=new l({draggable:!0,cursor:"move",drift:p(this._onDragMove,this,"all"),ondragend:p(this._onDragEnd,this),onmouseover:p(this._showDataInfo,this,!0),onmouseout:p(this._showDataInfo,this,!1),style:{fill:this.dataZoomModel.get("fillerColor"),textPosition:"inside"}})),n.add(new l(o.subPixelOptimizeRect({silent:!0,shape:{x:0,y:0,width:r[0],height:r[1]},style:{stroke:this.dataZoomModel.get("dataBackgroundColor"),lineWidth:x,fill:"rgba(0,0,0,0)"}}))),v([0,1],function(t){n.add(e[t]=new l({style:{fill:this.dataZoomModel.get("handleColor")},cursor:"move",draggable:!0,drift:p(this._onDragMove,this,t),ondragend:p(this._onDragEnd,this),onmouseover:p(this._showDataInfo,this,!0),onmouseout:p(this._showDataInfo,this,!1)}));var r=this.dataZoomModel.textStyleModel;this.group.add(i[t]=new o.Text({silent:!0,invisible:!0,style:{x:0,y:0,text:"",textVerticalAlign:"middle",textAlign:"center",fill:r.getTextColor(),textFont:r.getFont()}}))},this)},_resetInterval:function(){var t=this._range=this.dataZoomModel.getPercentRange(),e=this._getViewExtent();this._handleEnds=[c(t[0],[0,100],e,!0),c(t[1],[0,100],e,!0)]},_updateInterval:function(t,e){var i=this._handleEnds,n=this._getViewExtent();d(e,i,n,"all"===t||this.dataZoomModel.get("zoomLock")?"rigid":"cross",t),this._range=f([c(i[0],n,[0,100],!0),c(i[1],n,[0,100],!0)])},_updateView:function(){var t=this._displayables,e=this._handleEnds,i=f(e.slice()),n=this._size,r=this._halfHandleSize;v([0,1],function(i){var o=t.handles[i];o.setShape({x:e[i]-r,y:-1,width:2*r,height:n[1]+2,r:1})},this),t.filler.setShape({x:i[0],y:0,width:i[1]-i[0],height:this._size[1]}),this._updateDataInfo()},_updateDataInfo:function(){function t(t){var e=o.getTransform(i.handles[t],this.group),s=o.transformDirection(0===t?"right":"left",e),l=this._halfHandleSize+M,c=o.applyTransform([h[t]+(0===t?-l:l),this._size[1]/2],e);n[t].setStyle({x:c[0],y:c[1],textVerticalAlign:r===b?"middle":s,textAlign:r===b?s:"center",text:a[t]})}var e=this.dataZoomModel,i=this._displayables,n=i.handleLabels,r=this._orient,a=["",""];if(e.get("showDetail")){var s,l;e.eachTargetAxis(function(t,i){s||(s=e.getAxisProxy(t.name,i).getDataValueWindow(),l=this.ecModel.getComponent(t.axis,i).axis)},this),s&&(a=[this._formatLabel(s[0],l),this._formatLabel(s[1],l)])}var h=f(this._handleEnds.slice());t.call(this,0),t.call(this,1)},_formatLabel:function(t,e){var i=this.dataZoomModel,n=i.get("labelFormatter");if(r.isFunction(n))return n(t);var o=i.get("labelPrecision");return null!=o&&"auto"!==o||(o=e.getPixelPrecision()),t=null==t&&isNaN(t)?"":"category"===e.type||"time"===e.type?e.scale.getLabel(Math.round(t)):t.toFixed(Math.min(o,20)),r.isString(n)&&(t=n.replace("{value}",t)),t},_showDataInfo:function(t){t=this._dragging||t;var e=this._displayables.handleLabels;e[0].attr("invisible",!t),e[1].attr("invisible",!t)},_onDragMove:function(t,e,i){this._dragging=!0;var n=this._applyBarTransform([e,i],!0);this._updateInterval(t,n[0]),this._updateView(),this.dataZoomModel.get("realtime")&&this._dispatchZoomAction()},_onDragEnd:function(){this._dragging=!1,this._showDataInfo(!1),this._dispatchZoomAction()},_dispatchZoomAction:function(){var t=this._range;this.api.dispatchAction({type:"dataZoom",from:this.uid,dataZoomId:this.dataZoomModel.id,start:t[0],end:t[1]})},_applyBarTransform:function(t,e){var i=this._displayables.barGroup.getLocalTransform();return o.applyTransform(t,i,e)},_findCoordRect:function(){var t,e=this.getTargetInfo();if(e.cartesians.length)t=e.cartesians[0].model.coordinateSystem.getRect();else{var i=this.api.getWidth(),n=this.api.getHeight();t={x:.2*i,y:.2*n,width:.6*i,height:.6*n}}return t}});t.exports=A},function(t,e,i){function n(t){var e=t.getZr();return e[p]||(e[p]={})}function r(t,e,i){var n=new u(t.getZr());return n.enable(),n.on("pan",f(a,i)),n.on("zoom",f(s,i)),n.rect=e.coordinateSystem.getRect().clone(),n}function o(t){c.each(t,function(e,i){e.count||(e.controller.off("pan").off("zoom"),delete t[i])})}function a(t,e,i){l(t,function(n){return n.panGetRange(t.controller,e,i)})}function s(t,e,i,n){l(t,function(r){return r.zoomGetRange(t.controller,e,i,n)})}function l(t,e){var i=[];c.each(t.dataZoomInfos,function(t){var n=e(t);n&&i.push({dataZoomId:t.dataZoomId,start:n[0],end:n[1]})}),t.dispatchAction(i)}function h(t,e){t.dispatchAction({type:"dataZoom",batch:e})}var c=i(1),u=i(70),d=i(125),f=c.curry,p="\x00_ec_dataZoom_roams",g={register:function(t,e){var i=n(t),a=e.dataZoomId,s=e.coordType+"\x00_"+e.coordId;c.each(i,function(t,e){var i=t.dataZoomInfos;i[a]&&e!==s&&(delete i[a],t.count--)}),o(i);var l=i[s];l||(l=i[s]={coordId:s,dataZoomInfos:{},count:0},l.controller=r(t,e,l),l.dispatchAction=c.curry(h,t)),l&&(d.createOrUpdate(l,"dispatchAction",e.throttleRate,"fixRate"),!l.dataZoomInfos[a]&&l.count++,l.dataZoomInfos[a]=e)},unregister:function(t,e){var i=n(t);c.each(i,function(t,i){var n=t.dataZoomInfos;n[e]&&(delete n[e],t.count--)}),o(i)},shouldRecordRange:function(t,e){if(t&&"dataZoom"===t.type&&t.batch)for(var i=0,n=t.batch.length;n>i;i++)if(t.batch[i].dataZoomId===e)return!1;return!0}};t.exports=g},function(t,e,i){i(100),i(39),i(40),i(169),i(170),i(98),i(97)},function(t,e,i){i(176),i(178),i(177);var n=i(2);n.registerProcessor("filter",i(179))},function(t,e,i){"use strict";var n=i(1),r=i(12),o=i(2).extendComponentModel({type:"legend",dependencies:["series"],layoutMode:{type:"box",ignoreSize:!0},init:function(t,e,i){this.mergeDefaultAndTheme(t,i),t.selected=t.selected||{},this._updateData(i);var n=this._data,r=this.option.selected;if(n[0]&&"single"===this.get("selectedMode")){var o=!1;for(var a in r)r[a]&&(this.select(a),o=!0);!o&&this.select(n[0].get("name"))}},mergeOption:function(t){o.superCall(this,"mergeOption",t),this._updateData(this.ecModel)},_updateData:function(t){var e=n.map(this.get("data")||[],function(t){return"string"==typeof t&&(t={name:t}),new r(t,this,this.ecModel)},this);this._data=e;var i=n.map(t.getSeries(),function(t){return t.name});t.eachSeries(function(t){if(t.legendDataProvider){var e=t.legendDataProvider();i=i.concat(e.mapArray(e.getName))}}),this._availableNames=i},getData:function(){return this._data},select:function(t){var e=this.option.selected,i=this.get("selectedMode");if("single"===i){var r=this._data;n.each(r,function(t){e[t.get("name")]=!1})}e[t]=!0},unSelect:function(t){"single"!==this.get("selectedMode")&&(this.option.selected[t]=!1)},toggleSelected:function(t){var e=this.option.selected;t in e||(e[t]=!0),this[e[t]?"unSelect":"select"](t)},isSelected:function(t){var e=this.option.selected;return!(t in e&&!e[t])&&n.indexOf(this._availableNames,t)>=0},defaultOption:{zlevel:0,z:4,show:!0,orient:"horizontal",left:"center",top:"top",align:"auto",backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",borderWidth:0,padding:5,itemGap:10,itemWidth:25,itemHeight:14,textStyle:{color:"#333"},selectedMode:!0}});t.exports=o},function(t,e,i){function n(t,e){e.dispatchAction({type:"legendToggleSelect",name:t})}function r(t,e,i){t.get("legendHoverLink")&&i.dispatchAction({type:"highlight",seriesName:t.name,name:e})}function o(t,e,i){t.get("legendHoverLink")&&i.dispatchAction({type:"downplay",seriesName:t.name,name:e})}var a=i(1),s=i(24),l=i(3),h=i(102),c=a.curry,u="#ccc";t.exports=i(2).extendComponentView({type:"legend",init:function(){this._symbolTypeStore={}},render:function(t,e,i){var s=this.group;if(s.removeAll(),t.get("show")){var u=t.get("selectedMode"),d=t.get("align");"auto"===d&&(d="right"===t.get("left")&&"vertical"===t.get("orient")?"right":"left");var f={},p={};a.each(t.getData(),function(a){var h=a.get("name");""!==h&&"\n"!==h||s.add(new l.Group({newline:!0}));var g=e.getSeriesByName(h)[0];if(f[h]=a,g&&!p[h]){var m=g.getData(),v=m.getVisual("color");"function"==typeof v&&(v=v(g.getDataParams(0)));var y=m.getVisual("legendSymbol")||"roundRect",x=m.getVisual("symbol"),_=this._createItem(h,a,t,y,x,d,v,u);_.on("click",c(n,h,i)).on("mouseover",c(r,g,"",i)).on("mouseout",c(o,g,"",i)),p[h]=!0}},this),e.eachRawSeries(function(e){if(e.legendDataProvider){var a=e.legendDataProvider();a.each(function(s){var l=a.getName(s);if(f[l]&&!p[l]){var h=a.getItemVisual(s,"color"),g="roundRect",m=this._createItem(l,f[l],t,g,null,d,h,u);m.on("click",c(n,l,i)).on("mouseover",c(r,e,l,i)).on("mouseout",c(o,e,l,i)),p[l]=!0}},!1,this)}},this),h.layout(s,t,i),h.addBackground(s,t)}},_createItem:function(t,e,i,n,r,o,a,h){var c=i.get("itemWidth"),d=i.get("itemHeight"),f=i.isSelected(t),p=new l.Group,g=e.getModel("textStyle"),m=e.get("icon");if(n=m||n,p.add(s.createSymbol(n,0,0,c,d,f?a:u)),!m&&r&&(r!==n||"none"==r)){var v=.8*d;"none"===r&&(r="circle"),p.add(s.createSymbol(r,(c-v)/2,(d-v)/2,v,v,f?a:u))}var y="left"===o?c+5:-5,x=o,_=i.get("formatter");"string"==typeof _&&_?t=_.replace("{name}",t):"function"==typeof _&&(t=_(t));var b=new l.Text({style:{text:t,x:y,y:d/2,fill:f?g.getTextColor():u,textFont:g.getFont(),textAlign:x,textVerticalAlign:"middle"}});return p.add(b),p.add(new l.Rect({shape:p.getBoundingRect(),invisible:!0})),p.eachChild(function(t){t.silent=!h}),this.group.add(p),p}})},function(t,e,i){function n(t,e,i){var n,r={},a="toggleSelected"===t;return i.eachComponent("legend",function(i){a&&null!=n?i[n?"select":"unSelect"](e.name):(i[t](e.name),n=i.isSelected(e.name));var s=i.getData();o.each(s,function(t){var e=t.get("name");if("\n"!==e&&""!==e){var n=i.isSelected(e);e in r?r[e]=r[e]&&n:r[e]=n}})}),{name:e.name,selected:r}}var r=i(2),o=i(1);r.registerAction("legendToggleSelect","legendselectchanged",o.curry(n,"toggleSelected")),r.registerAction("legendSelect","legendselected",o.curry(n,"select")),r.registerAction("legendUnSelect","legendunselected",o.curry(n,"unSelect"))},function(t,e){t.exports=function(t){var e=t.findComponents({mainType:"legend"});e&&e.length&&t.filterSeries(function(t){for(var i=0;i=0&&(p=+p.toFixed(g)),u[h]=f[h]=p,n=[u,f,{type:a,valueIndex:n.valueIndex,value:p}]}return n=[d.dataTransform(t,n[0]),d.dataTransform(t,n[1]),o.extend({},n[2])],n[2].type=n[2].type||"",o.merge(n[2],n[0]),o.merge(n[2],n[1]),n},g={formatTooltip:function(t){var e=this._data,i=this.getRawValue(t),n=o.isArray(i)?o.map(i,c).join(", "):c(i),r=e.getName(t);return this.name+"
"+((r?u(r)+" : ":"")+n)},getRawDataArray:function(){return this.option.data},getData:function(){return this._data},setData:function(t){ +this._data=t}};o.defaults(g,l.dataFormatMixin),i(2).extendComponentView({type:"markLine",init:function(){this._markLineMap={}},render:function(t,e,i){var n=this._markLineMap;for(var r in n)n[r].__keep=!1;e.eachSeries(function(t){var n=t.markLineModel;n&&this._renderSeriesML(t,n,e,i)},this);for(var r in n)n[r].__keep||this.group.remove(n[r].group)},_renderSeriesML:function(t,e,i,n){function a(e,i,r,o,a){var l,u=e.getItemModel(i),d=u.get("x"),f=u.get("y");if(null!=d&&null!=f)l=[h.parsePercent(d,n.getWidth()),h.parsePercent(f,n.getHeight())];else{if(t.getMarkerPosition)l=t.getMarkerPosition(e.getValues(e.dimensions,i));else{var p=e.get(m[0],i),g=e.get(m[1],i);l=s.dataToPoint([p,g])}if(o&&"cartesian2d"===s.type){var v=null!=a?s.getAxis(1===a?"x":"y"):s.getAxesByScale("ordinal")[0];v&&v.onBand&&(l["x"===v.dim?0:1]=v.toGlobalCoord(v.getExtent()[r?0:1]))}}e.setItemLayout(i,l),e.setItemVisual(i,{symbolSize:u.get("symbolSize")||b[r?0:1],symbol:u.get("symbol",!0)||_[r?0:1],color:u.get("itemStyle.normal.color")||c.getVisual("color")})}var s=t.coordinateSystem,l=t.name,c=t.getData(),u=this._markLineMap,d=u[l];d||(d=u[l]=new f),this.group.add(d.group);var p=r(s,t,e),m=s.dimensions,v=p.from,y=p.to,x=p.line;o.extend(e,g),e.setData(x);var _=e.get("symbol"),b=e.get("symbolSize");o.isArray(_)||(_=[_,_]),"number"==typeof b&&(b=[b,b]),p.from.each(function(t){var e=x.getItemModel(t),i=e.get("type"),n=e.get("valueIndex");a(v,t,!0,i,n),a(y,t,!1,i,n)}),x.each(function(t){var e=x.getItemModel(t).get("lineStyle.normal.color");x.setItemVisual(t,{color:e||v.getItemVisual(t,"color")}),x.setItemLayout(t,[v.getItemLayout(t),y.getItemLayout(t)])}),d.updateData(x,v,y),p.line.eachItemGraphicEl(function(t,i){t.traverse(function(t){t.hostModel=e})}),d.__keep=!0}})},function(t,e,i){var n=i(7),r=i(2).extendComponentModel({type:"markPoint",dependencies:["series","grid","polar"],init:function(t,e,i,n){this.mergeDefaultAndTheme(t,i),this.mergeOption(t,i,n.createdBySelf,!0)},mergeOption:function(t,e,i,o){i||e.eachSeries(function(t){var i=t.get("markPoint"),a=t.markPointModel;if(!i||!i.data)return void(t.markPointModel=null);if(a)a.mergeOption(i,e,!0);else{o&&n.defaultEmphasis(i.label,["position","show","textStyle","distance","formatter"]);var s={seriesIndex:t.seriesIndex,name:t.name,createdBySelf:!0};a=new r(i,this,e,s)}t.markPointModel=a},this)},defaultOption:{zlevel:0,z:5,symbol:"pin",symbolSize:50,tooltip:{trigger:"item"},label:{normal:{show:!0,position:"inside"},emphasis:{show:!0}},itemStyle:{normal:{borderWidth:2},emphasis:{}}}});t.exports=r},function(t,e,i){function n(t,e,i){var n=o.map(t.dimensions,function(t){var i=e.getData().getDimensionInfo(e.coordDimToDataDim(t)[0]);return i.name=t,i}),r=new u(n,i);return t&&r.initData(o.filter(o.map(i.get("data"),o.curry(d.dataTransform,e)),o.curry(d.dataFilter,t)),null,d.dimValueGetter),r}var r=i(38),o=i(1),a=i(9),s=i(7),l=i(4),h=a.addCommas,c=a.encodeHTML,u=i(14),d=i(103),f={getRawDataArray:function(){return this.option.data},formatTooltip:function(t){var e=this.getData(),i=this.getRawValue(t),n=o.isArray(i)?o.map(i,h).join(", "):h(i),r=e.getName(t);return this.name+"
"+((r?c(r)+" : ":"")+n)},getData:function(){return this._data},setData:function(t){this._data=t}};o.defaults(f,s.dataFormatMixin),i(2).extendComponentView({type:"markPoint",init:function(){this._symbolDrawMap={}},render:function(t,e,i){var n=this._symbolDrawMap;for(var r in n)n[r].__keep=!1;e.eachSeries(function(t){var e=t.markPointModel;e&&this._renderSeriesMP(t,e,i)},this);for(var r in n)n[r].__keep||(n[r].remove(),this.group.remove(n[r].group))},_renderSeriesMP:function(t,e,i){var a=t.coordinateSystem,s=t.name,h=t.getData(),c=this._symbolDrawMap,u=c[s];u||(u=c[s]=new r);var d=n(a,t,e),p=a&&a.dimensions;o.mixin(e,f),e.setData(d),d.each(function(n){var r,o=d.getItemModel(n),s=o.getShallow("x"),c=o.getShallow("y");if(null!=s&&null!=c)r=[l.parsePercent(s,i.getWidth()),l.parsePercent(c,i.getHeight())];else if(t.getMarkerPosition)r=t.getMarkerPosition(d.getValues(d.dimensions,n));else if(a){var u=d.get(p[0],n),f=d.get(p[1],n);r=a.dataToPoint([u,f])}d.setItemLayout(n,r);var g=o.getShallow("symbolSize");"function"==typeof g&&(g=g(e.getRawValue(n),e.getDataParams(n))),d.setItemVisual(n,{symbolSize:g,color:o.get("itemStyle.normal.color")||h.getVisual("color"),symbol:o.getShallow("symbol")})}),u.updateData(d),this.group.add(u.group),d.eachItemGraphicEl(function(t){t.traverse(function(t){t.hostModel=e})}),u.__keep=!0}})},function(t,e,i){"use strict";var n=i(2),r=i(3),o=i(11);n.extendComponentModel({type:"title",layoutMode:{type:"box",ignoreSize:!0},defaultOption:{zlevel:0,z:6,show:!0,text:"",target:"blank",subtext:"",subtarget:"blank",left:0,top:0,backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",borderWidth:0,padding:5,itemGap:10,textStyle:{fontSize:18,fontWeight:"bolder",color:"#333"},subtextStyle:{color:"#aaa"}}}),n.extendComponentView({type:"title",render:function(t,e,i){if(this.group.removeAll(),t.get("show")){var n=this.group,a=t.getModel("textStyle"),s=t.getModel("subtextStyle"),l=t.get("textAlign"),h=new r.Text({style:{text:t.get("text"),textFont:a.getFont(),fill:a.getTextColor(),textBaseline:"top"},z2:10}),c=h.getBoundingRect(),u=t.get("subtext"),d=new r.Text({style:{text:u,textFont:s.getFont(),fill:s.getTextColor(),y:c.height+t.get("itemGap"),textBaseline:"top"},z2:10}),f=t.get("link"),p=t.get("sublink");h.silent=!f,d.silent=!p,f&&h.on("click",function(){window.open(f,t.get("target"))}),p&&d.on("click",function(){window.open(p,t.get("subtarget"))}),n.add(h),u&&n.add(d);var g=n.getBoundingRect(),m=t.getBoxLayoutParams();m.width=g.width,m.height=g.height;var v=o.getLayoutRect(m,{width:i.getWidth(),height:i.getHeight()},t.get("padding"));l||(l=t.get("left")||t.get("right"),"middle"===l&&(l="center"),"right"===l?v.x+=v.width:"center"===l&&(v.x+=v.width/2)),n.position=[v.x,v.y],h.setStyle("textAlign",l),d.setStyle("textAlign",l),g=n.getBoundingRect();var y=v.margin,x=t.getItemStyle(["color","opacity"]);x.fill=t.get("backgroundColor");var _=new r.Rect({shape:{x:g.x-y[3],y:g.y-y[0],width:g.width+y[1]+y[3],height:g.height+y[0]+y[2]},style:x,silent:!0});r.subPixelOptimizeRect(_),n.add(_)}}})},function(t,e,i){i(188),i(189),i(194),i(192),i(190),i(191),i(193)},function(t,e,i){var n=i(29),r=i(1),o=i(2).extendComponentModel({type:"toolbox",layoutMode:{type:"box",ignoreSize:!0},mergeDefaultAndTheme:function(t){o.superApply(this,"mergeDefaultAndTheme",arguments),r.each(this.option.feature,function(t,e){var i=n.get(e);i&&r.merge(t,i.defaultOption)})},defaultOption:{show:!0,z:6,zlevel:0,orient:"horizontal",left:"right",top:"top",backgroundColor:"transparent",borderColor:"#ccc",borderWidth:0,padding:5,itemSize:15,itemGap:8,showTitle:!0,iconStyle:{normal:{borderColor:"#666",color:"none"},emphasis:{borderColor:"#3E98C5"}}}});t.exports=o},function(t,e,i){(function(e){function n(t){return 0===t.indexOf("my")}var r=i(29),o=i(1),a=i(3),s=i(12),l=i(52),h=i(102),c=i(17);t.exports=i(2).extendComponentView({type:"toolbox",render:function(t,e,i){function u(o,a){var l,h=v[o],c=v[a],u=g[h],f=new s(u,t,t.ecModel);if(h&&!c){if(n(h))l={model:f,onclick:f.option.onclick,featureName:h};else{var p=r.get(h);if(!p)return;l=new p(f)}m[h]=l}else{if(l=m[c],!l)return;l.model=f}return!h&&c?void(l.dispose&&l.dispose(e,i)):!f.get("show")||l.unusable?void(l.remove&&l.remove(e,i)):(d(f,l,h),f.setIconStatus=function(t,e){var i=this.option,n=this.iconPaths;i.iconStatus=i.iconStatus||{},i.iconStatus[t]=e,n[t]&&n[t].trigger(e)},void(l.render&&l.render(f,e,i)))}function d(n,r,s){var l=n.getModel("iconStyle"),h=r.getIcons?r.getIcons():n.get("icon"),c=n.get("title")||{};if("string"==typeof h){var u=h,d=c;h={},c={},h[s]=u,c[s]=d}var g=n.iconPaths={};o.each(h,function(s,h){var u=l.getModel("normal").getItemStyle(),d=l.getModel("emphasis").getItemStyle(),m={x:-p/2,y:-p/2,width:p,height:p},v=0===s.indexOf("image://")?(m.image=s.slice(8),new a.Image({style:m})):a.makePath(s.replace("path://",""),{style:u,hoverStyle:d,rectHover:!0},m,"center");a.setHoverStyle(v),t.get("showTitle")&&(v.__title=c[h],v.on("mouseover",function(){v.setStyle({text:c[h],textPosition:d.textPosition||"bottom",textFill:d.fill||d.stroke||"#000",textAlign:d.textAlign||"center"})}).on("mouseout",function(){v.setStyle({textFill:null})})),v.trigger(n.get("iconStatus."+h)||"normal"),f.add(v),v.on("click",o.bind(r.onclick,r,e,i,h)),g[h]=v})}var f=this.group;if(f.removeAll(),t.get("show")){var p=+t.get("itemSize"),g=t.get("feature")||{},m=this._features||(this._features={}),v=[];o.each(g,function(t,e){v.push(e)}),new l(this._featureNames||[],v).add(u).update(u).remove(o.curry(u,null)).execute(),this._featureNames=v,h.layout(f,t,i),h.addBackground(f,t),f.eachChild(function(t){var e=t.__title,n=t.hoverStyle;if(n&&e){var r=c.getBoundingRect(e,n.font),o=t.position[0]+f.position[0],a=t.position[1]+f.position[1]+p,s=!1;a+r.height>i.getHeight()&&(n.textPosition="top",s=!0);var l=s?-5-r.height:p+8;o+r.width/2>i.getWidth()?(n.textPosition=["100%",l],n.textAlign="right"):o-r.width/2<0&&(n.textPosition=[0,l],n.textAlign="left")}})}},remove:function(t,e){o.each(this._features,function(i){i.remove&&i.remove(t,e)}),this.group.removeAll()},dispose:function(t,e){o.each(this._features,function(i){i.dispose&&i.dispose(t,e)})}})}).call(e,i(200))},function(t,e,i){function n(t){var e={},i=[],n=[];return t.eachRawSeries(function(t){var r=t.coordinateSystem;if(!r||"cartesian2d"!==r.type&&"polar"!==r.type)i.push(t);else{var o=r.getBaseAxis();if("category"===o.type){var a=o.dim+"_"+o.index;e[a]||(e[a]={categoryAxis:o,valueAxis:r.getOtherAxis(o),series:[]},n.push({axisDim:o.dim,axisIndex:o.index})),e[a].series.push(t)}else i.push(t)}}),{seriesGroupByCategoryAxis:e,other:i,meta:n}}function r(t){var e=[];return p.each(t,function(t,i){var n=t.categoryAxis,r=t.valueAxis,o=r.dim,a=[" "].concat(p.map(t.series,function(t){return t.name})),s=[n.model.getCategories()];p.each(t.series,function(t){s.push(t.getRawData().mapArray(o,function(t){return t}))});for(var l=[a.join(v)],h=0;ha;a++)n[a]=arguments[a];i.push((o?o+v:"")+n.join(v))}),i.join("\n")}).join("\n\n"+m+"\n\n")}function a(t){var e=n(t);return{value:p.filter([r(e.seriesGroupByCategoryAxis),o(e.other)],function(t){return t.replace(/[\n\t\s]/g,"")}).join("\n\n"+m+"\n\n"),meta:e.meta}}function s(t){return t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function l(t){var e=t.slice(0,t.indexOf("\n"));return e.indexOf(v)>=0?!0:void 0}function h(t){for(var e=t.split(/\n+/g),i=s(e.shift()).split(y),n=[],r=p.map(i,function(t){return{name:t,data:[]}}),o=0;o1?"emphasis":"normal")}var h=i(1),c=i(4),u=i(159),d=i(8),f=i(26),p=i(99),g=i(101),m=h.each,v=c.asc;i(174);var y="\x00_ec_\x00toolbox-dataZoom_";n.defaultOption={show:!0,icon:{zoom:"M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1",back:"M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26"},title:{zoom:"区域缩放",back:"区域缩放还原"}};var x=n.prototype;x.render=function(t,e,i){l(t,e)},x.onclick=function(t,e,i){var n=this._controllerGroup;this._controllerGroup||(n=this._controllerGroup=new f,e.getZr().add(n)),_[i].call(this,n,this.model,t,e)},x.remove=function(t,e){this._disposeController(),g.release("globalPan",e.getZr())},x.dispose=function(t,e){var i=e.getZr();g.release("globalPan",i),this._disposeController(),this._controllerGroup&&i.remove(this._controllerGroup)};var _={zoom:function(t,e,i,n){var r=this._isZoomActive=!this._isZoomActive,o=n.getZr();g[r?"take":"release"]("globalPan",o),e.setIconStatus("zoom",r?"emphasis":"normal"),r?(o.setDefaultCursorStyle("crosshair"),this._createController(t,e,i,n)):(o.setDefaultCursorStyle("default"),this._disposeController())},back:function(t,e,i,n){this._dispatchAction(p.pop(i),n)}};x._createController=function(t,e,i,n){var r=this._controller=new u("rect",n.getZr(),{lineWidth:3,stroke:"#333",fill:"rgba(0,0,0,0.2)"});r.on("selectEnd",h.bind(this._onSelected,this,r,e,i,n)),r.enable(t,!1)},x._disposeController=function(){var t=this._controller;t&&(t.off("selected"),t.dispose())},x._onSelected=function(t,e,i,n,o){if(o.length){var l=o[0];t.update();var h={};i.eachComponent("grid",function(t,e){var n=t.coordinateSystem,o=r(n,i),c=a(l,o);if(c){var u=s(c,o,0,"x"),d=s(c,o,1,"y");u&&(h[u.dataZoomId]=u),d&&(h[d.dataZoomId]=d)}},this),p.push(i,h),this._dispatchAction(h,n)}},x._dispatchAction=function(t,e){var i=[];m(t,function(t){i.push(t)}),i.length&&e.dispatchAction({type:"dataZoom",from:this.uid,batch:h.clone(i,!0)})},i(29).register("dataZoom",n),i(2).registerPreprocessor(function(t){function e(t,e){if(e){var r=t+"Index",o=e[r];null==o||h.isArray(o)||(o=o===!1?[]:[o]),i(t,function(e,i){if(null==o||-1!==h.indexOf(o,i)){var a={type:"select",$fromToolbox:!0,id:y+t+i};a[r]=i,n.push(a)}})}}function i(e,i){var n=t[e];h.isArray(n)||(n=n?[n]:[]),m(n,i)}if(t){var n=t.dataZoom||(t.dataZoom=[]);h.isArray(n)||(n=[n]);var r=t.toolbox;if(r&&(h.isArray(r)&&(r=r[0]),r&&r.feature)){var o=r.feature.dataZoom;e("xAxis",o),e("yAxis",o)}}}),t.exports=n},function(t,e,i){"use strict";function n(t){this.model=t}var r=i(1);n.defaultOption={show:!0,type:[],icon:{line:"M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4",bar:"M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7",stack:"M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z",tiled:"M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z"},title:{line:"切换为折线图",bar:"切换为柱状图",stack:"切换为堆叠",tiled:"切换为平铺"},option:{},seriesIndex:{}};var o=n.prototype;o.getIcons=function(){var t=this.model,e=t.get("icon"),i={};return r.each(t.get("type"),function(t){e[t]&&(i[t]=e[t])}),i};var a={line:function(t,e,i,n){return"bar"===t?r.merge({id:e,type:"line",data:i.get("data"),stack:i.get("stack"),markPoint:i.get("markPoint"),markLine:i.get("markLine")},n.get("option.line")):void 0},bar:function(t,e,i,n){return"line"===t?r.merge({id:e,type:"bar",data:i.get("data"),stack:i.get("stack"),markPoint:i.get("markPoint"),markLine:i.get("markLine")},n.get("option.bar")):void 0},stack:function(t,e,i,n){return"line"===t||"bar"===t?{id:e,stack:"__ec_magicType_stack__"}:void 0},tiled:function(t,e,i,n){return"line"===t||"bar"===t?{id:e,stack:""}:void 0}},s=[["line","bar"],["stack","tiled"]];o.onclick=function(t,e,i){var n=this.model,o=n.get("seriesIndex."+i);if(a[i]){var l={series:[]},h=function(t){var e=t.subType,o=t.id,s=a[i](e,o,t,n);s&&(r.defaults(s,t.option),l.series.push(s))};r.each(s,function(t){r.indexOf(t,i)>=0&&r.each(t,function(t){n.setIconStatus(t,"normal")})}),n.setIconStatus(i,"emphasis"),t.eachComponent({mainType:"series",seriesIndex:o},h),e.dispatchAction({type:"changeMagicType",currentType:i,newOption:l})}};var l=i(2);l.registerAction({type:"changeMagicType",event:"magicTypeChanged",update:"prepareAndUpdate"},function(t,e){e.mergeOption(t.newOption)}),i(29).register("magicType",n),t.exports=n},function(t,e,i){"use strict";function n(t){this.model=t}var r=i(99);n.defaultOption={show:!0,icon:"M3.8,33.4 M47,18.9h9.8V8.7 M56.3,20.1 C52.1,9,40.5,0.6,26.8,2.1C12.6,3.7,1.6,16.2,2.1,30.6 M13,41.1H3.1v10.2 M3.7,39.9c4.2,11.1,15.8,19.5,29.5,18 c14.2-1.6,25.2-14.1,24.7-28.5",title:"还原"};var o=n.prototype;o.onclick=function(t,e,i){r.clear(t),e.dispatchAction({type:"restore",from:this.uid})},i(29).register("restore",n),i(2).registerAction({type:"restore",event:"restore",update:"prepareAndUpdate"},function(t,e){e.resetOption("recreate")}),t.exports=n},function(t,e,i){function n(t){this.model=t}var r=i(15);n.defaultOption={show:!0,icon:"M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0",title:"保存为图片",type:"png",name:"",excludeComponents:["toolbox"],pixelRatio:1,lang:["右键另存为图片"]},n.prototype.unusable=!r.canvasSupported;var o=n.prototype;o.onclick=function(t,e){var i=this.model,n=i.get("name")||t.get("title.0.text")||"echarts",r=document.createElement("a"),o=i.get("type",!0)||"png";r.download=n+"."+o,r.target="_blank";var a=e.getConnectedDataURL({type:o,backgroundColor:i.get("backgroundColor",!0)||t.get("backgroundColor")||"#fff",excludeComponents:i.get("excludeComponents"),pixelRatio:i.get("pixelRatio")});if(r.href=a,"function"==typeof MouseEvent){var s=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});r.dispatchEvent(s)}else{var l=i.get("lang"),h='',c=window.open();c.document.write(h)}},i(29).register("saveAsImage",n),t.exports=n},function(t,e,i){i(197),i(198),i(2).registerAction({type:"showTip",event:"showTip",update:"none"},function(){}),i(2).registerAction({type:"hideTip",event:"hideTip",update:"none"},function(){})},function(t,e,i){function n(t){var e="cubic-bezier(0.23, 1, 0.32, 1)",i="left "+t+"s "+e+",top "+t+"s "+e;return l.map(p,function(t){return t+"transition:"+i}).join(";")}function r(t){var e=[],i=t.get("fontSize"),n=t.getTextColor();return n&&e.push("color:"+n),e.push("font:"+t.getFont()),i&&e.push("line-height:"+Math.round(3*i/2)+"px"),d(["decoration","align"],function(i){var n=t.get(i);n&&e.push("text-"+i+":"+n)}),e.join(";")}function o(t){t=t;var e=[],i=t.get("transitionDuration"),o=t.get("backgroundColor"),a=t.getModel("textStyle"),s=t.get("padding");return i&&e.push(n(i)),o&&(e.push("background-Color:"+h.toHex(o)),e.push("filter:alpha(opacity=70)"),e.push("background-Color:"+o)),d(["width","color","radius"],function(i){var n="border-"+i,r=f(n),o=t.get(r);null!=o&&e.push(n+":"+o+("color"===i?"":"px"))}),e.push(r(a)),null!=s&&e.push("padding:"+u.normalizeCssArray(s).join("px ")+"px"),e.join(";")+";"}function a(t,e){var i=document.createElement("div"),n=e.getZr();this.el=i,this._x=e.getWidth()/2,this._y=e.getHeight()/2,t.appendChild(i),this._container=t,this._show=!1,this._hideTimeout;var r=this;i.onmouseenter=function(){r.enterable&&(clearTimeout(r._hideTimeout),r._show=!0),r._inContent=!0},i.onmousemove=function(e){if(!r.enterable){var i=n.handler;c.normalizeEvent(t,e),i.dispatch("mousemove",e)}},i.onmouseleave=function(){r.enterable&&r._show&&r.hideLater(r._hideDelay),r._inContent=!1},s(i,t)}function s(t,e){function i(t){n(t.target)&&t.preventDefault()}function n(i){for(;i&&i!==e;){if(i===t)return!0;i=i.parentNode}}c.addEventListener(e,"touchstart",i),c.addEventListener(e,"touchmove",i),c.addEventListener(e,"touchend",i)}var l=i(1),h=i(22),c=i(33),u=i(9),d=l.each,f=u.toCamelCase,p=["","-webkit-","-moz-","-o-"],g="position:absolute;display:block;border-style:solid;white-space:nowrap;";a.prototype={constructor:a,enterable:!0,update:function(){var t=this._container,e=t.currentStyle||document.defaultView.getComputedStyle(t),i=t.style;"absolute"!==i.position&&"absolute"!==e.position&&(i.position="relative")},show:function(t){clearTimeout(this._hideTimeout),this.el.style.cssText=g+o(t)+";left:"+this._x+"px;top:"+this._y+"px;",this._show=!0},setContent:function(t){var e=this.el;e.innerHTML=t,e.style.display=t?"block":"none"},moveTo:function(t,e){var i=this.el.style;i.left=t+"px",i.top=e+"px",this._x=t,this._y=e},hide:function(){this.el.style.display="none",this._show=!1},hideLater:function(t){!this._show||this._inContent&&this.enterable||(t?(this._hideDelay=t,this._show=!1,this._hideTimeout=setTimeout(l.bind(this.hide,this),t)):this.hide())},isShow:function(){return this._show}},t.exports=a},function(t,e,i){i(2).extendComponentModel({type:"tooltip",defaultOption:{zlevel:0,z:8,show:!0,showContent:!0,trigger:"item",triggerOn:"mousemove",alwaysShowContent:!1,hideDelay:100,transitionDuration:.4,enterable:!1,backgroundColor:"rgba(50,50,50,0.7)",borderColor:"#333",borderRadius:4,borderWidth:0,padding:5,axisPointer:{type:"line",axis:"auto",animation:!0,animationDurationUpdate:200,animationEasingUpdate:"exponentialOut",lineStyle:{color:"#555",width:1,type:"solid"},crossStyle:{color:"#555",width:1,type:"dashed",textStyle:{}},shadowStyle:{color:"rgba(150,150,150,0.3)"}},textStyle:{color:"#fff",fontSize:14}}})},function(t,e,i){function n(t,e){if(!t||!e)return!1;var i=g.round;return i(t[0])===i(e[0])&&i(t[1])===i(e[1])}function r(t,e,i,n){return{x1:t,y1:e,x2:i,y2:n}}function o(t,e,i,n){return{x:t,y:e,width:i,height:n}}function a(t,e,i,n,r,o){return{cx:t,cy:e,r0:i,r:n,startAngle:r,endAngle:o,clockwise:!0}}function s(t,e,i,n,r){var o=i.clientWidth,a=i.clientHeight,s=20;return t+o+s>n?t-=o+s:t+=s,e+a+s>r?e-=a+s:e+=s,[t,e]}function l(t,e,i){var n=i.clientWidth,r=i.clientHeight,o=5,a=0,s=0,l=e.width,h=e.height;switch(t){case"inside":a=e.x+l/2-n/2,s=e.y+h/2-r/2;break;case"top":a=e.x+l/2-n/2,s=e.y-r-o;break;case"bottom":a=e.x+l/2-n/2,s=e.y+h+o;break;case"left":a=e.x-n-o,s=e.y+h/2-r/2;break;case"right":a=e.x+l+o,s=e.y+h/2-r/2}return[a,s]}function h(t,e,i,n,r,o,a){var h=a.getWidth(),c=a.getHeight(),u=o&&o.getBoundingRect().clone();if(o&&u.applyTransform(o.transform),"function"==typeof t&&(t=t([e,i],r,u)),f.isArray(t))e=m(t[0],h),i=m(t[1],c);else if("string"==typeof t&&o){var d=l(t,u,n.el);e=d[0],i=d[1]}else{var d=s(e,i,n.el,h,c);e=d[0],i=d[1]}n.moveTo(e,i)}function c(t){var e=t.coordinateSystem,i=t.get("tooltip.trigger",!0);return!(!e||"cartesian2d"!==e.type&&"polar"!==e.type&&"single"!==e.type||"item"===i)}var u=i(196),d=i(3),f=i(1),p=i(9),g=i(4),m=g.parsePercent,v=i(15);i(2).extendComponentView({type:"tooltip",_axisPointers:{},init:function(t,e){if(!v.node){var i=new u(e.getDom(),e);this._tooltipContent=i,e.on("showTip",this._manuallyShowTip,this),e.on("hideTip",this._manuallyHideTip,this)}},render:function(t,e,i){if(!v.node){this.group.removeAll(),this._axisPointers={},this._tooltipModel=t,this._ecModel=e,this._api=i,this._lastHover={};var n=this._tooltipContent;n.update(),n.enterable=t.get("enterable"),this._alwaysShowContent=t.get("alwaysShowContent"),this._seriesGroupByAxis=this._prepareAxisTriggerData(t,e);var r=this._crossText;if(r&&this.group.add(r),null!=this._lastX&&null!=this._lastY){var o=this;clearTimeout(this._refreshUpdateTimeout),this._refreshUpdateTimeout=setTimeout(function(){o._manuallyShowTip({x:o._lastX,y:o._lastY})})}var a=this._api.getZr(),s=this._tryShow;a.off("click",s),a.off("mousemove",s),a.off("mouseout",this._hide),"click"===t.get("triggerOn")?a.on("click",s,this):(a.on("mousemove",s,this),a.on("mouseout",this._hide,this))}},_manuallyShowTip:function(t){if(t.from!==this.uid){var e=this._ecModel,i=t.seriesIndex,n=t.dataIndex,r=e.getSeriesByIndex(i),o=this._api;if(null==t.x||null==t.y){if(r||e.eachSeries(function(t){c(t)&&!r&&(r=t)}),r){var a=r.getData();null==n&&(n=a.indexOfName(t.name));var s,l,h=a.getItemGraphicEl(n),u=r.coordinateSystem;if(u&&u.dataToPoint){var d=u.dataToPoint(a.getValues(u.dimensions,n,!0));s=d&&d[0],l=d&&d[1]}else if(h){var f=h.getBoundingRect().clone();f.applyTransform(h.transform),s=f.x+f.width/2,l=f.y+f.height/2}null!=s&&null!=l&&this._tryShow({offsetX:s,offsetY:l,target:h,event:{}})}}else{var h=o.getZr().handler.findHover(t.x,t.y);this._tryShow({offsetX:t.x,offsetY:t.y,target:h,event:{}})}}},_manuallyHideTip:function(t){t.from!==this.uid&&this._hide()},_prepareAxisTriggerData:function(t,e){var i={};return e.eachSeries(function(t){if(c(t)){var e,n,r=t.coordinateSystem;"cartesian2d"===r.type?(e=r.getBaseAxis(),n=e.dim+e.index):"single"===r.type?(e=r.getAxis(),n=e.dim+e.type):(e=r.getBaseAxis(),n=e.dim+r.name),i[n]=i[n]||{coordSys:[],series:[]},i[n].coordSys.push(r),i[n].series.push(t)}},this),i},_tryShow:function(t){var e=t.target,i=this._tooltipModel,n=i.get("trigger"),r=this._ecModel,o=this._api;if(i)if(this._lastX=t.offsetX,this._lastY=t.offsetY,e&&null!=e.dataIndex){var a=e.hostModel||r.getSeriesByIndex(e.seriesIndex),s=e.dataIndex,l=a.getData().getItemModel(s);"axis"===(l.get("tooltip.trigger")||n)?this._showAxisTooltip(i,r,t):(this._ticket="",this._hideAxisPointer(),this._resetLastHover(),this._showItemTooltipContent(a,s,t)),o.dispatchAction({type:"showTip",from:this.uid,dataIndex:e.dataIndex,seriesIndex:e.seriesIndex})}else"item"===n?this._hide():this._showAxisTooltip(i,r,t),"cross"===i.get("axisPointer.type")&&o.dispatchAction({type:"showTip",from:this.uid,x:t.offsetX,y:t.offsetY})},_showAxisTooltip:function(t,e,i){var r=t.getModel("axisPointer"),o=r.get("type");if("cross"===o){var a=i.target;if(a&&null!=a.dataIndex){var s=e.getSeriesByIndex(a.seriesIndex),l=a.dataIndex;this._showItemTooltipContent(s,l,i)}}this._showAxisPointer();var h=!0;f.each(this._seriesGroupByAxis,function(t){var e=t.coordSys,a=e[0],s=[i.offsetX,i.offsetY];if(!a.containPoint(s))return void this._hideAxisPointer(a.name);h=!1;var l=a.dimensions,c=a.pointToData(s,!0);s=a.dataToPoint(c);var u=a.getBaseAxis(),d=r.get("axis");"auto"===d&&(d=u.dim);var p=!1,g=this._lastHover;if("cross"===o)n(g.data,c)&&(p=!0),g.data=c;else{var m=f.indexOf(l,d);g.data===c[m]&&(p=!0),g.data=c[m]}"cartesian2d"!==a.type||p?"polar"!==a.type||p?"single"!==a.type||p||this._showSinglePointer(r,a,d,s):this._showPolarPointer(r,a,d,s):this._showCartesianPointer(r,a,d,s),"cross"!==o&&this._dispatchAndShowSeriesTooltipContent(a,t.series,s,c,p)},this),h&&this._hide()},_showCartesianPointer:function(t,e,i,n){function a(i,n,o){var a="x"===i?r(n[0],o[0],n[0],o[1]):r(o[0],n[1],o[1],n[1]),s=l._getPointerElement(e,t,i,a);c?d.updateProps(s,{shape:a},t):s.attr({shape:a})}function s(i,n,r){var a=e.getAxis(i),s=a.getBandWidth(),h=r[1]-r[0],u="x"===i?o(n[0]-s/2,r[0],s,h):o(r[0],n[1]-s/2,h,s),f=l._getPointerElement(e,t,i,u);c?d.updateProps(f,{shape:u},t):f.attr({shape:u})}var l=this,h=t.get("type"),c="cross"!==h;if("cross"===h)a("x",n,e.getAxis("y").getGlobalExtent()),a("y",n,e.getAxis("x").getGlobalExtent()),this._updateCrossText(e,n,t);else{var u=e.getAxis("x"===i?"y":"x"),f=u.getGlobalExtent();"cartesian2d"===e.type&&("line"===h?a:s)(i,n,f)}},_showSinglePointer:function(t,e,i,n){function o(i,n,o){var s=e.getAxis(),h=s.orient,c="horizontal"===h?r(n[0],o[0],n[0],o[1]):r(o[0],n[1],o[1],n[1]),u=a._getPointerElement(e,t,i,c);l?d.updateProps(u,{shape:c},t):u.attr({shape:c})}var a=this,s=t.get("type"),l="cross"!==s,h=e.getRect(),c=[h.y,h.y+h.height];o(i,n,c)},_showPolarPointer:function(t,e,i,n){function o(i,n,o){var a,s=e.pointToCoord(n);if("angle"===i){var h=e.coordToPoint([o[0],s[1]]),c=e.coordToPoint([o[1],s[1]]);a=r(h[0],h[1],c[0],c[1])}else a={cx:e.cx,cy:e.cy,r:s[0]};var u=l._getPointerElement(e,t,i,a);f?d.updateProps(u,{shape:a},t):u.attr({shape:a})}function s(i,n,r){var o,s=e.getAxis(i),h=s.getBandWidth(),c=e.pointToCoord(n),u=Math.PI/180;o="angle"===i?a(e.cx,e.cy,r[0],r[1],(-c[1]-h/2)*u,(-c[1]+h/2)*u):a(e.cx,e.cy,c[0]-h/2,c[0]+h/2,0,2*Math.PI);var p=l._getPointerElement(e,t,i,o);f?d.updateProps(p,{shape:o},t):p.attr({shape:o})}var l=this,h=t.get("type"),c=e.getAngleAxis(),u=e.getRadiusAxis(),f="cross"!==h;if("cross"===h)o("angle",n,u.getExtent()),o("radius",n,c.getExtent()), +this._updateCrossText(e,n,t);else{var p=e.getAxis("radius"===i?"angle":"radius"),g=p.getExtent();("line"===h?o:s)(i,n,g)}},_updateCrossText:function(t,e,i){var n=i.getModel("crossStyle"),r=n.getModel("textStyle"),o=this._tooltipModel,a=this._crossText;a||(a=this._crossText=new d.Text({style:{textAlign:"left",textVerticalAlign:"bottom"}}),this.group.add(a));var s=t.pointToData(e),l=t.dimensions;s=f.map(s,function(e,i){var n=t.getAxis(l[i]);return e="category"===n.type||"time"===n.type?n.scale.getLabel(e):p.addCommas(e.toFixed(n.getPixelPrecision()))}),a.setStyle({fill:r.getTextColor()||n.get("color"),textFont:r.getFont(),text:s.join(", "),x:e[0]+5,y:e[1]-5}),a.z=o.get("z"),a.zlevel=o.get("zlevel")},_getPointerElement:function(t,e,i,n){var r=this._tooltipModel,o=r.get("z"),a=r.get("zlevel"),s=this._axisPointers,l=t.name;if(s[l]=s[l]||{},s[l][i])return s[l][i];var h=e.get("type"),c=e.getModel(h+"Style"),u="shadow"===h,f=c[u?"getAreaStyle":"getLineStyle"](),p="polar"===t.type?u?"Sector":"radius"===i?"Circle":"Line":u?"Rect":"Line";u?f.stroke=null:f.fill=null;var g=s[l][i]=new d[p]({style:f,z:o,zlevel:a,silent:!0,shape:n});return this.group.add(g),g},_dispatchAndShowSeriesTooltipContent:function(t,e,i,n,r){var o=this._tooltipModel,a=this._tooltipContent,s=t.getBaseAxis(),l=f.map(e,function(t){return{seriesIndex:t.seriesIndex,dataIndex:t.getAxisTooltipDataIndex?t.getAxisTooltipDataIndex(t.coordDimToDataDim(s.dim),n,s):t.getData().indexOfNearest(t.coordDimToDataDim(s.dim)[0],n["x"===s.dim||"radius"===s.dim?0:1])}}),c=this._lastHover,u=this._api;if(c.payloadBatch&&!r&&u.dispatchAction({type:"downplay",batch:c.payloadBatch}),r||(u.dispatchAction({type:"highlight",batch:l}),c.payloadBatch=l),u.dispatchAction({type:"showTip",dataIndex:l[0].dataIndex,seriesIndex:l[0].seriesIndex,from:this.uid}),s&&o.get("showContent")){var d,g=o.get("formatter"),m=o.get("position"),v=f.map(e,function(t,e){return t.getDataParams(l[e].dataIndex)});a.show(o);var y=l[0].dataIndex;if(!r){if(this._ticket="",g){if("string"==typeof g)d=p.formatTpl(g,v);else if("function"==typeof g){var x=this,_="axis_"+t.name+"_"+y,b=function(t,e){t===x._ticket&&(a.setContent(e),h(m,i[0],i[1],a,v,null,u))};x._ticket=_,d=g(v,_,b)}}else{var w=e[0].getData().getName(y);d=(w?w+"
":"")+f.map(e,function(t,e){return t.formatTooltip(l[e].dataIndex,!0)}).join("
")}a.setContent(d)}h(m,i[0],i[1],a,v,null,u)}},_showItemTooltipContent:function(t,e,i){var n=this._api,r=t.getData(),o=r.getItemModel(e),a=this._tooltipModel,s=this._tooltipContent,l=o.getModel("tooltip");if(l.parentModel?l.parentModel.parentModel=a:l.parentModel=this._tooltipModel,l.get("showContent")){var c,u=l.get("formatter"),d=l.get("position"),f=t.getDataParams(e);if(u){if("string"==typeof u)c=p.formatTpl(u,f);else if("function"==typeof u){var g=this,m="item_"+t.name+"_"+e,v=function(t,e){t===g._ticket&&(s.setContent(e),h(d,i.offsetX,i.offsetY,s,f,i.target,n))};g._ticket=m,c=u(f,m,v)}}else c=t.formatTooltip(e);s.show(l),s.setContent(c),h(d,i.offsetX,i.offsetY,s,f,i.target,n)}},_showAxisPointer:function(t){if(t){var e=this._axisPointers[t];e&&f.each(e,function(t){t.show()})}else this.group.eachChild(function(t){t.show()}),this.group.show()},_resetLastHover:function(){var t=this._lastHover;t.payloadBatch&&this._api.dispatchAction({type:"downplay",batch:t.payloadBatch}),this._lastHover={}},_hideAxisPointer:function(t){if(t){var e=this._axisPointers[t];e&&f.each(e,function(t){t.hide()})}else this.group.hide()},_hide:function(){this._hideAxisPointer(),this._resetLastHover(),this._alwaysShowContent||this._tooltipContent.hideLater(this._tooltipModel.get("hideDelay")),this._api.dispatchAction({type:"hideTip",from:this.uid})},dispose:function(t,e){if(!v.node){var i=e.getZr();this._tooltipContent.hide(),i.off("click",this._tryShow),i.off("mousemove",this._tryShow),i.off("mouseout",this._hide),e.off("showTip",this._manuallyShowTip),e.off("hideTip",this._manuallyHideTip)}}})},,function(t,e){function i(){h=!1,a.length?l=a.concat(l):c=-1,l.length&&n()}function n(){if(!h){var t=setTimeout(i);h=!0;for(var e=l.length;e;){for(a=l,l=[];++c1)for(var i=1;i=0?parseFloat(t)/100*e:parseFloat(t):t},E=function(t,e,i){var n=a.parse(e);i=+i,isNaN(i)&&(i=1),n&&(t.color=D(n[0],n[1],n[2]),t.opacity=i*n[3])},R=function(t){var e=a.parse(t);return[D(e[0],e[1],e[2]),e[3]]},B=function(t,e,i){var n=e.fill;if(null!=n)if(n instanceof f){var r,o=0,a=[0,0],s=0,l=1,h=i.getBoundingRect(),c=h.width,u=h.height;if("linear"===n.type){r="gradient";var d=i.transform,p=[n.x*c,n.y*u],g=[n.x2*c,n.y2*u];d&&(b(p,p,d),b(g,g,d));var m=g[0]-p[0],v=g[1]-p[1];o=180*Math.atan2(m,v)/Math.PI,0>o&&(o+=360),1e-6>o&&(o=0)}else{r="gradientradial";var p=[n.x*c,n.y*u],d=i.transform,y=i.scale,x=c,w=u;a=[(p[0]-h.x)/x,(p[1]-h.y)/w],d&&b(p,p,d),x/=y[0]*S,w/=y[1]*S;var M=_(x,w);s=0/M,l=2*n.r/M-s}var A=n.colorStops.slice();A.sort(function(t,e){return t.offset-e.offset});for(var T=A.length,C=[],I=[],k=0;T>k;k++){var D=A[k],L=R(D.color);I.push(D.offset*l+s+" "+L[0]),0!==k&&k!==T-1||C.push(L)}if(T>=2){var P=C[0][0],z=C[1][0],O=C[0][1]*e.opacity,B=C[1][1]*e.opacity;t.type=r,t.method="none",t.focus="100%",t.angle=o,t.color=P,t.color2=z,t.colors=I.join(","),t.opacity=B,t.opacity2=O}"radial"===r&&(t.focusposition=a.join(","))}else E(t,n,e.opacity)},N=function(t,e){null!=e.lineJoin&&(t.joinstyle=e.lineJoin),null!=e.miterLimit&&(t.miterlimit=e.miterLimit*S),null!=e.lineCap&&(t.endcap=e.lineCap),null!=e.lineDash&&(t.dashstyle=e.lineDash.join(" ")),null==e.stroke||e.stroke instanceof f||E(t,e.stroke,e.opacity)},V=function(t,e,i,n){var r="fill"==e,o=t.getElementsByTagName(e)[0];null!=i[e]&&"none"!==i[e]&&(r||!r&&i.lineWidth)?(t[r?"filled":"stroked"]="true",i[e]instanceof f&&P(t,o),o||(o=p.createNode(e)),r?B(o,i,n):N(o,i),L(t,o)):(t[r?"filled":"stroked"]="false",P(t,o))},F=[[],[],[]],G=function(t,e){var i,n,r,a,s,l,h=o.M,c=o.C,u=o.L,d=o.A,f=o.Q,p=[];for(a=0;a0){p.push(n);for(var X=0;i>X;X++){var U=F[X];e&&b(U,U,e),p.push(g(U[0]*S-A),w,g(U[1]*S-A),i-1>X?w:"")}}}return p.join("")};d.prototype.brush=function(t){var e=this.style,i=this._vmlEl;i||(i=p.createNode("shape"),I(i),this._vmlEl=i),V(i,"fill",e,this),V(i,"stroke",e,this);var n=this.transform,r=null!=n,o=i.getElementsByTagName("stroke")[0];if(o){var a=e.lineWidth;if(r&&!e.strokeNoScale){var s=n[0]*n[3]-n[1]*n[2];a*=m(v(s))}o.weight=a+"px"}var l=this.path;this.__dirtyPath&&(l.beginPath(),this.buildPath(l,this.shape),this.__dirtyPath=!1),i.path=G(l.data,this.transform),i.style.zIndex=z(this.zlevel,this.z,this.z2),L(t,i),e.text&&this.drawRectText(t,this.getBoundingRect())},d.prototype.onRemoveFromStorage=function(t){P(t,this._vmlEl),this.removeRectText(t)},d.prototype.onAddToStorage=function(t){L(t,this._vmlEl),this.appendRectText(t)};var Z=function(t){return"object"==typeof t&&t.tagName&&"IMG"===t.tagName.toUpperCase()};c.prototype.brush=function(t){var e,i,n=this.style,r=n.image;if(Z(r)){var o=r.src;if(o===this._imageSrc)e=this._imageWidth,i=this._imageHeight;else{var a=r.runtimeStyle,s=a.width,l=a.height;a.width="auto",a.height="auto",e=r.width,i=r.height,a.width=s,a.height=l,this._imageSrc=o,this._imageWidth=e,this._imageHeight=i}r=o}else r===this._imageSrc&&(e=this._imageWidth,i=this._imageHeight);if(r){var h=n.x||0,c=n.y||0,u=n.width,d=n.height,f=n.sWidth,v=n.sHeight,y=n.sx||0,x=n.sy||0,S=f&&v,A=this._vmlEl;A||(A=p.doc.createElement("div"),I(A),this._vmlEl=A);var T,C=A.style,k=!1,D=1,P=1;if(this.transform&&(T=this.transform,D=m(T[0]*T[0]+T[1]*T[1]),P=m(T[2]*T[2]+T[3]*T[3]),k=T[1]||T[2]),k){var O=[h,c],E=[h+u,c],R=[h,c+d],B=[h+u,c+d];b(O,O,T),b(E,E,T),b(R,R,T),b(B,B,T);var N=_(O[0],E[0],R[0],B[0]),V=_(O[1],E[1],R[1],B[1]),F=[];F.push("M11=",T[0]/D,w,"M12=",T[2]/P,w,"M21=",T[1]/D,w,"M22=",T[3]/P,w,"Dx=",g(h*D+T[4]),w,"Dy=",g(c*P+T[5])),C.padding="0 "+g(N)+"px "+g(V)+"px 0",C.filter=M+".Matrix("+F.join("")+", SizingMethod=clip)"}else T&&(h=h*D+T[4],c=c*P+T[5]),C.filter="",C.left=g(h)+"px",C.top=g(c)+"px";var G=this._imageEl,W=this._cropEl;G||(G=p.doc.createElement("div"),this._imageEl=G);var H=G.style;if(S){if(e&&i)H.width=g(D*e*u/f)+"px",H.height=g(P*i*d/v)+"px";else{var q=new Image,j=this;q.onload=function(){q.onload=null,e=q.width,i=q.height,H.width=g(D*e*u/f)+"px",H.height=g(P*i*d/v)+"px",j._imageWidth=e,j._imageHeight=i,j._imageSrc=r},q.src=r}W||(W=p.doc.createElement("div"),W.style.overflow="hidden",this._cropEl=W);var X=W.style;X.width=g((u+y*u/f)*D),X.height=g((d+x*d/v)*P),X.filter=M+".Matrix(Dx="+-y*u/f*D+",Dy="+-x*d/v*P+")",W.parentNode||A.appendChild(W),G.parentNode!=W&&W.appendChild(G)}else H.width=g(D*u)+"px",H.height=g(P*d)+"px",A.appendChild(G),W&&W.parentNode&&(A.removeChild(W),this._cropEl=null);var U="",Y=n.opacity;1>Y&&(U+=".Alpha(opacity="+g(100*Y)+") "),U+=M+".AlphaImageLoader(src="+r+", SizingMethod=scale)",H.filter=U,A.style.zIndex=z(this.zlevel,this.z,this.z2),L(t,A),n.text&&this.drawRectText(t,this.getBoundingRect())}},c.prototype.onRemoveFromStorage=function(t){P(t,this._vmlEl),this._vmlEl=null,this._cropEl=null,this._imageEl=null,this.removeRectText(t)},c.prototype.onAddToStorage=function(t){L(t,this._vmlEl),this.appendRectText(t)};var W,H="normal",q={},j=0,X=100,U=document.createElement("div"),Y=function(t){var e=q[t];if(!e){j>X&&(j=0,q={});var i,n=U.style;try{n.font=t,i=n.fontFamily.split(",")[0]}catch(r){}e={style:n.fontStyle||H,variant:n.fontVariant||H,weight:n.fontWeight||H,size:0|parseFloat(n.fontSize||12),family:i||"Microsoft YaHei"},q[t]=e,j++}return e};s.measureText=function(t,e){var i=p.doc;W||(W=i.createElement("div"),W.style.cssText="position:absolute;top:-20000px;left:0;padding:0;margin:0;border:none;white-space:pre;",p.doc.body.appendChild(W));try{W.style.font=e}catch(n){}return W.innerHTML="",W.appendChild(i.createTextNode(t)),{width:W.offsetWidth}};for(var $=new r,Q=function(t,e,i,n){var r=this.style,o=r.text;if(o){var a,l,h=r.textAlign,c=Y(r.textFont),u=c.style+" "+c.variant+" "+c.weight+" "+c.size+'px "'+c.family+'"',d=r.textBaseline,f=r.textVerticalAlign;i=i||s.getBoundingRect(o,u,h,d);var m=this.transform;if(m&&!n&&($.copy(e),$.applyTransform(m),e=$),n)a=e.x,l=e.y;else{var v=r.textPosition,y=r.textDistance;if(v instanceof Array)a=e.x+O(v[0],e.width),l=e.y+O(v[1],e.height),h=h||"left",d=d||"top";else{var x=s.adjustTextPositionOnRect(v,e,i,y);a=x.x,l=x.y,h=h||x.textAlign,d=d||x.textBaseline}}if(f){switch(f){case"middle":l-=i.height/2;break;case"bottom":l-=i.height}d="top"}var _=c.size;switch(d){case"hanging":case"top":l+=_/1.75;break;case"middle":break;default:l-=_/2.25}switch(h){case"left":break;case"center":a-=i.width/2;break;case"right":a-=i.width}var M,S,A,T=p.createNode,C=this._textVmlEl;C?(A=C.firstChild,M=A.nextSibling,S=M.nextSibling):(C=T("line"),M=T("path"),S=T("textpath"),A=T("skew"),S.style["v-text-align"]="left",I(C),M.textpathok=!0,S.on=!0,C.from="0 0",C.to="1000 0.05",L(C,A),L(C,M),L(C,S),this._textVmlEl=C);var D=[a,l],P=C.style;m&&n?(b(D,D,m),A.on=!0,A.matrix=m[0].toFixed(3)+w+m[2].toFixed(3)+w+m[1].toFixed(3)+w+m[3].toFixed(3)+",0,0",A.offset=(g(D[0])||0)+","+(g(D[1])||0),A.origin="0 0",P.left="0px",P.top="0px"):(A.on=!1,P.left=g(a)+"px",P.top=g(l)+"px"),S.string=k(o);try{S.style.font=u}catch(E){}V(C,"fill",{fill:n?r.fill:r.textFill,opacity:r.opacity},this),V(C,"stroke",{stroke:n?r.stroke:r.textStroke,opacity:r.opacity,lineDash:r.lineDash},this),C.style.zIndex=z(this.zlevel,this.z,this.z2),L(t,C)}},K=function(t){P(t,this._textVmlEl),this._textVmlEl=null},J=function(t){L(t,this._textVmlEl)},tt=[l,h,c,d,u],et=0;et} colorStops - */ - var Gradient = function (colorStops) { - - this.colorStops = colorStops || []; - }; - - Gradient.prototype = { - - constructor: Gradient, - - addColorStop: function (offset, color) { - this.colorStops.push({ - - offset: offset, - - color: color - }); - } - }; - - return Gradient; -}); -/** - */ -define('zrender/core/util',['require','../graphic/Gradient'],function(require) { - var Gradient = require('../graphic/Gradient'); - // 用于处理merge时无法遍历Date等对象的问题 - var BUILTIN_OBJECT = { - '[object Function]': 1, - '[object RegExp]': 1, - '[object Date]': 1, - '[object Error]': 1, - '[object CanvasGradient]': 1 - }; - - var objToString = Object.prototype.toString; - - var arrayProto = Array.prototype; - var nativeForEach = arrayProto.forEach; - var nativeFilter = arrayProto.filter; - var nativeSlice = arrayProto.slice; - var nativeMap = arrayProto.map; - var nativeReduce = arrayProto.reduce; - - /** - * @param {*} source - * @return {*} 拷贝后的新对象 - */ - function clone(source) { - if (typeof source == 'object' && source !== null) { - var result = source; - if (source instanceof Array) { - result = []; - for (var i = 0, len = source.length; i < len; i++) { - result[i] = clone(source[i]); - } - } - else if ( - !isBuildInObject(source) - // 是否为 dom 对象 - && !isDom(source) - ) { - result = {}; - for (var key in source) { - if (source.hasOwnProperty(key)) { - result[key] = clone(source[key]); - } - } - } - - return result; - } - - return source; - } - - /** - * @param {*} target - * @param {*} source - * @param {boolean} [overwrite=false] - */ - function merge(target, source, overwrite) { - // We should escapse that source is string - // and enter for ... in ... - if (!isObject(source) || !isObject(target)) { - return overwrite ? clone(source) : target; - } - - for (var key in source) { - if (source.hasOwnProperty(key)) { - var targetProp = target[key]; - var sourceProp = source[key]; - - if (isObject(sourceProp) - && isObject(targetProp) - && !isArray(sourceProp) - && !isArray(targetProp) - && !isDom(sourceProp) - && !isDom(targetProp) - && !isBuildInObject(sourceProp) - && !isBuildInObject(targetProp) - ) { - // 如果需要递归覆盖,就递归调用merge - merge(targetProp, sourceProp, overwrite); - } - else if (overwrite || !(key in target)) { - // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况 - // NOTE,在 target[key] 不存在的时候也是直接覆盖 - target[key] = clone(source[key], true); - } - } - } - - return target; - } - - /** - * @param {Array} targetAndSources The first item is target, and the rests are source. - * @param {boolean} [overwrite=false] - * @return {*} target - */ - function mergeAll(targetAndSources, overwrite) { - var result = targetAndSources[0]; - for (var i = 1, len = targetAndSources.length; i < len; i++) { - result = merge(result, targetAndSources[i], overwrite); - } - return result; - } - - /** - * @param {*} target - * @param {*} source - */ - function extend(target, source) { - for (var key in source) { - if (source.hasOwnProperty(key)) { - target[key] = source[key]; - } - } - return target; - } - - /** - * @param {*} target - * @param {*} source - * @param {boolen} [overlay=false] - */ - function defaults(target, source, overlay) { - for (var key in source) { - if (source.hasOwnProperty(key) - && (overlay ? source[key] != null : target[key] == null) - ) { - target[key] = source[key]; - } - } - return target; - } - - function createCanvas() { - return document.createElement('canvas'); - } - // FIXME - var _ctx; - function getContext() { - if (!_ctx) { - // Use util.createCanvas instead of createCanvas - // because createCanvas may be overwritten in different environment - _ctx = util.createCanvas().getContext('2d'); - } - return _ctx; - } - - /** - * 查询数组中元素的index - */ - function indexOf(array, value) { - if (array) { - if (array.indexOf) { - return array.indexOf(value); - } - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] === value) { - return i; - } - } - } - return -1; - } - - /** - * 构造类继承关系 - * - * @param {Function} clazz 源类 - * @param {Function} baseClazz 基类 - */ - function inherits(clazz, baseClazz) { - var clazzPrototype = clazz.prototype; - function F() {} - F.prototype = baseClazz.prototype; - clazz.prototype = new F(); - - for (var prop in clazzPrototype) { - clazz.prototype[prop] = clazzPrototype[prop]; - } - clazz.prototype.constructor = clazz; - clazz.superClass = baseClazz; - } - - /** - * @param {Object|Function} target - * @param {Object|Function} sorce - * @param {boolean} overlay - */ - function mixin(target, source, overlay) { - target = 'prototype' in target ? target.prototype : target; - source = 'prototype' in source ? source.prototype : source; - - defaults(target, source, overlay); - } - - /** - * @param {Array|TypedArray} data - */ - function isArrayLike(data) { - if (! data) { - return; - } - if (typeof data == 'string') { - return false; - } - return typeof data.length == 'number'; - } - - /** - * 数组或对象遍历 - * @memberOf module:zrender/tool/util - * @param {Object|Array} obj - * @param {Function} cb - * @param {*} [context] - */ - function each(obj, cb, context) { - if (!(obj && cb)) { - return; - } - if (obj.forEach && obj.forEach === nativeForEach) { - obj.forEach(cb, context); - } - else if (obj.length === +obj.length) { - for (var i = 0, len = obj.length; i < len; i++) { - cb.call(context, obj[i], i, obj); - } - } - else { - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - cb.call(context, obj[key], key, obj); - } - } - } - } - - /** - * 数组映射 - * @memberOf module:zrender/tool/util - * @param {Array} obj - * @param {Function} cb - * @param {*} [context] - * @return {Array} - */ - function map(obj, cb, context) { - if (!(obj && cb)) { - return; - } - if (obj.map && obj.map === nativeMap) { - return obj.map(cb, context); - } - else { - var result = []; - for (var i = 0, len = obj.length; i < len; i++) { - result.push(cb.call(context, obj[i], i, obj)); - } - return result; - } - } - - /** - * @memberOf module:zrender/tool/util - * @param {Array} obj - * @param {Function} cb - * @param {Object} [memo] - * @param {*} [context] - * @return {Array} - */ - function reduce(obj, cb, memo, context) { - if (!(obj && cb)) { - return; - } - if (obj.reduce && obj.reduce === nativeReduce) { - return obj.reduce(cb, memo, context); - } - else { - for (var i = 0, len = obj.length; i < len; i++) { - memo = cb.call(context, memo, obj[i], i, obj); - } - return memo; - } - } - - /** - * 数组过滤 - * @memberOf module:zrender/tool/util - * @param {Array} obj - * @param {Function} cb - * @param {*} [context] - * @return {Array} - */ - function filter(obj, cb, context) { - if (!(obj && cb)) { - return; - } - if (obj.filter && obj.filter === nativeFilter) { - return obj.filter(cb, context); - } - else { - var result = []; - for (var i = 0, len = obj.length; i < len; i++) { - if (cb.call(context, obj[i], i, obj)) { - result.push(obj[i]); - } - } - return result; - } - } - - /** - * 数组项查找 - * @memberOf module:zrender/tool/util - * @param {Array} obj - * @param {Function} cb - * @param {*} [context] - * @return {Array} - */ - function find(obj, cb, context) { - if (!(obj && cb)) { - return; - } - for (var i = 0, len = obj.length; i < len; i++) { - if (cb.call(context, obj[i], i, obj)) { - return obj[i]; - } - } - } - - /** - * @memberOf module:zrender/tool/util - * @param {Function} func - * @param {*} context - * @return {Function} - */ - function bind(func, context) { - var args = nativeSlice.call(arguments, 2); - return function () { - return func.apply(context, args.concat(nativeSlice.call(arguments))); - }; - } - - /** - * @memberOf module:zrender/tool/util - * @param {Function} func - * @param {...} - * @return {Function} - */ - function curry(func) { - var args = nativeSlice.call(arguments, 1); - return function () { - return func.apply(this, args.concat(nativeSlice.call(arguments))); - }; - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isArray(value) { - return objToString.call(value) === '[object Array]'; - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isFunction(value) { - return typeof value === 'function'; - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isString(value) { - return objToString.call(value) === '[object String]'; - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isObject(value) { - // Avoid a V8 JIT bug in Chrome 19-20. - // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. - var type = typeof value; - return type === 'function' || (!!value && type == 'object'); - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isBuildInObject(value) { - return !!BUILTIN_OBJECT[objToString.call(value)] - || (value instanceof Gradient); - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isDom(value) { - return value && value.nodeType === 1 - && typeof(value.nodeName) == 'string'; - } - - /** - * If value1 is not null, then return value1, otherwise judget rest of values. - * @param {*...} values - * @return {*} Final value - */ - function retrieve(values) { - for (var i = 0, len = arguments.length; i < len; i++) { - if (arguments[i] != null) { - return arguments[i]; - } - } - } - - /** - * @memberOf module:zrender/tool/util - * @param {Array} arr - * @param {number} startIndex - * @param {number} endIndex - * @return {Array} - */ - function slice() { - return Function.call.apply(nativeSlice, arguments); - } - - /** - * @param {boolean} condition - * @param {string} message - */ - function assert(condition, message) { - if (!condition) { - throw new Error(message); - } - } - - var util = { - inherits: inherits, - mixin: mixin, - clone: clone, - merge: merge, - mergeAll: mergeAll, - extend: extend, - defaults: defaults, - getContext: getContext, - createCanvas: createCanvas, - indexOf: indexOf, - slice: slice, - find: find, - isArrayLike: isArrayLike, - each: each, - map: map, - reduce: reduce, - filter: filter, - bind: bind, - curry: curry, - isArray: isArray, - isString: isString, - isObject: isObject, - isFunction: isFunction, - isBuildInObject: isBuildInObject, - isDom: isDom, - retrieve: retrieve, - assert: assert, - noop: function () {} - }; - return util; -}); +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["echarts"] = factory(); + else + root["echarts"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Export echarts as CommonJS module + */ + module.exports = __webpack_require__(1); + + // Import all charts and components + __webpack_require__(91); + __webpack_require__(127); + __webpack_require__(132); + __webpack_require__(141); + __webpack_require__(145); + + __webpack_require__(155); + __webpack_require__(177); + __webpack_require__(189); + __webpack_require__(207); + __webpack_require__(211); + __webpack_require__(215); + __webpack_require__(230); + __webpack_require__(236); + __webpack_require__(243); + __webpack_require__(249); + __webpack_require__(253); + __webpack_require__(258); + + __webpack_require__(106); + __webpack_require__(262); + __webpack_require__(268); + __webpack_require__(272); + __webpack_require__(283); + __webpack_require__(216); + + __webpack_require__(285); + + __webpack_require__(286); + __webpack_require__(300); + + __webpack_require__(315); + __webpack_require__(319); + + __webpack_require__(322); + __webpack_require__(331); + + __webpack_require__(345); + + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + /*! + * ECharts, a javascript interactive chart library. + * + * Copyright (c) 2015, Baidu Inc. + * All rights reserved. + * + * LICENSE + * https://github.com/ecomfe/echarts/blob/master/LICENSE.txt + */ + + /** + * @module echarts + */ + + + var GlobalModel = __webpack_require__(2); + var ExtensionAPI = __webpack_require__(24); + var CoordinateSystemManager = __webpack_require__(25); + var OptionManager = __webpack_require__(26); + + var ComponentModel = __webpack_require__(19); + var SeriesModel = __webpack_require__(27); + + var ComponentView = __webpack_require__(28); + var ChartView = __webpack_require__(41); + var graphic = __webpack_require__(42); + + var zrender = __webpack_require__(77); + var zrUtil = __webpack_require__(3); + var colorTool = __webpack_require__(38); + var env = __webpack_require__(78); + var Eventful = __webpack_require__(32); + + var each = zrUtil.each; + + var VISUAL_CODING_STAGES = ['echarts', 'chart', 'component']; + + // TODO Transform first or filter first + var PROCESSOR_STAGES = ['transform', 'filter', 'statistic']; + + function createRegisterEventWithLowercaseName(method) { + return function (eventName, handler, context) { + // Event name is all lowercase + eventName = eventName && eventName.toLowerCase(); + Eventful.prototype[method].call(this, eventName, handler, context); + }; + } + /** + * @module echarts~MessageCenter + */ + function MessageCenter() { + Eventful.call(this); + } + MessageCenter.prototype.on = createRegisterEventWithLowercaseName('on'); + MessageCenter.prototype.off = createRegisterEventWithLowercaseName('off'); + MessageCenter.prototype.one = createRegisterEventWithLowercaseName('one'); + zrUtil.mixin(MessageCenter, Eventful); + /** + * @module echarts~ECharts + */ + function ECharts (dom, theme, opts) { + opts = opts || {}; + + // Get theme by name + if (typeof theme === 'string') { + theme = themeStorage[theme]; + } + + if (theme) { + each(optionPreprocessorFuncs, function (preProcess) { + preProcess(theme); + }); + } + /** + * @type {string} + */ + this.id; + /** + * Group id + * @type {string} + */ + this.group; + /** + * @type {HTMLDomElement} + * @private + */ + this._dom = dom; + /** + * @type {module:zrender/ZRender} + * @private + */ + this._zr = zrender.init(dom, { + renderer: opts.renderer || 'canvas', + devicePixelRatio: opts.devicePixelRatio + }); + + /** + * @type {Object} + * @private + */ + this._theme = zrUtil.clone(theme); + + /** + * @type {Array.} + * @private + */ + this._chartsViews = []; + + /** + * @type {Object.} + * @private + */ + this._chartsMap = {}; + + /** + * @type {Array.} + * @private + */ + this._componentsViews = []; + + /** + * @type {Object.} + * @private + */ + this._componentsMap = {}; + + /** + * @type {module:echarts/ExtensionAPI} + * @private + */ + this._api = new ExtensionAPI(this); + + /** + * @type {module:echarts/CoordinateSystem} + * @private + */ + this._coordSysMgr = new CoordinateSystemManager(); + + Eventful.call(this); + + /** + * @type {module:echarts~MessageCenter} + * @private + */ + this._messageCenter = new MessageCenter(); + + // Init mouse events + this._initEvents(); + + // In case some people write `window.onresize = chart.resize` + this.resize = zrUtil.bind(this.resize, this); + } + + var echartsProto = ECharts.prototype; + + /** + * @return {HTMLDomElement} + */ + echartsProto.getDom = function () { + return this._dom; + }; + + /** + * @return {module:zrender~ZRender} + */ + echartsProto.getZr = function () { + return this._zr; + }; + + /** + * @param {Object} option + * @param {boolean} notMerge + * @param {boolean} [notRefreshImmediately=false] Useful when setOption frequently. + */ + echartsProto.setOption = function (option, notMerge, notRefreshImmediately) { + if (!this._model || notMerge) { + this._model = new GlobalModel( + null, null, this._theme, new OptionManager(this._api) + ); + } + + this._model.setOption(option, optionPreprocessorFuncs); + + updateMethods.prepareAndUpdate.call(this); + + !notRefreshImmediately && this._zr.refreshImmediately(); + }; + + /** + * @DEPRECATED + */ + echartsProto.setTheme = function () { + console.log('ECharts#setTheme() is DEPRECATED in ECharts 3.0'); + }; + + /** + * @return {module:echarts/model/Global} + */ + echartsProto.getModel = function () { + return this._model; + }; + + /** + * @return {Object} + */ + echartsProto.getOption = function () { + return this._model.getOption(); + }; + + /** + * @return {number} + */ + echartsProto.getWidth = function () { + return this._zr.getWidth(); + }; + + /** + * @return {number} + */ + echartsProto.getHeight = function () { + return this._zr.getHeight(); + }; + + /** + * Get canvas which has all thing rendered + * @param {Object} opts + * @param {string} [opts.backgroundColor] + */ + echartsProto.getRenderedCanvas = function (opts) { + if (!env.canvasSupported) { + return; + } + opts = opts || {}; + opts.pixelRatio = opts.pixelRatio || 1; + opts.backgroundColor = opts.backgroundColor + || this._model.get('backgroundColor'); + var zr = this._zr; + var list = zr.storage.getDisplayList(); + // Stop animations + zrUtil.each(list, function (el) { + el.stopAnimation(true); + }); + return zr.painter.getRenderedCanvas(opts); + }; + /** + * @return {string} + * @param {Object} opts + * @param {string} [opts.type='png'] + * @param {string} [opts.pixelRatio=1] + * @param {string} [opts.backgroundColor] + */ + echartsProto.getDataURL = function (opts) { + opts = opts || {}; + var excludeComponents = opts.excludeComponents; + var ecModel = this._model; + var excludesComponentViews = []; + var self = this; + + each(excludeComponents, function (componentType) { + ecModel.eachComponent({ + mainType: componentType + }, function (component) { + var view = self._componentsMap[component.__viewId]; + if (!view.group.ignore) { + excludesComponentViews.push(view); + view.group.ignore = true; + } + }); + }); + + var url = this.getRenderedCanvas(opts).toDataURL( + 'image/' + (opts && opts.type || 'png') + ); + + each(excludesComponentViews, function (view) { + view.group.ignore = false; + }); + return url; + }; + + + /** + * @return {string} + * @param {Object} opts + * @param {string} [opts.type='png'] + * @param {string} [opts.pixelRatio=1] + * @param {string} [opts.backgroundColor] + */ + echartsProto.getConnectedDataURL = function (opts) { + if (!env.canvasSupported) { + return; + } + var groupId = this.group; + var mathMin = Math.min; + var mathMax = Math.max; + var MAX_NUMBER = Infinity; + if (connectedGroups[groupId]) { + var left = MAX_NUMBER; + var top = MAX_NUMBER; + var right = -MAX_NUMBER; + var bottom = -MAX_NUMBER; + var canvasList = []; + var dpr = (opts && opts.pixelRatio) || 1; + for (var id in instances) { + var chart = instances[id]; + if (chart.group === groupId) { + var canvas = chart.getRenderedCanvas( + zrUtil.clone(opts) + ); + var boundingRect = chart.getDom().getBoundingClientRect(); + left = mathMin(boundingRect.left, left); + top = mathMin(boundingRect.top, top); + right = mathMax(boundingRect.right, right); + bottom = mathMax(boundingRect.bottom, bottom); + canvasList.push({ + dom: canvas, + left: boundingRect.left, + top: boundingRect.top + }); + } + } + + left *= dpr; + top *= dpr; + right *= dpr; + bottom *= dpr; + var width = right - left; + var height = bottom - top; + var targetCanvas = zrUtil.createCanvas(); + targetCanvas.width = width; + targetCanvas.height = height; + var zr = zrender.init(targetCanvas); + + each(canvasList, function (item) { + var img = new graphic.Image({ + style: { + x: item.left * dpr - left, + y: item.top * dpr - top, + image: item.dom + } + }); + zr.add(img); + }); + zr.refreshImmediately(); + + return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png')); + } + else { + return this.getDataURL(opts); + } + }; + + var updateMethods = { + + /** + * @param {Object} payload + * @private + */ + update: function (payload) { + // console.time && console.time('update'); + + var ecModel = this._model; + var api = this._api; + var coordSysMgr = this._coordSysMgr; + // update before setOption + if (!ecModel) { + return; + } + + ecModel.restoreData(); + + // TODO + // Save total ecModel here for undo/redo (after restoring data and before processing data). + // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call. + + // Create new coordinate system each update + // In LineView may save the old coordinate system and use it to get the orignal point + coordSysMgr.create(this._model, this._api); + + processData.call(this, ecModel, api); + + stackSeriesData.call(this, ecModel); + + coordSysMgr.update(ecModel, api); + + doLayout.call(this, ecModel, payload); + + doVisualCoding.call(this, ecModel, payload); + + doRender.call(this, ecModel, payload); + + // Set background + var backgroundColor = ecModel.get('backgroundColor') || 'transparent'; + + var painter = this._zr.painter; + // TODO all use clearColor ? + if (painter.isSingleCanvas && painter.isSingleCanvas()) { + this._zr.configLayer(0, { + clearColor: backgroundColor + }); + } + else { + // In IE8 + if (!env.canvasSupported) { + var colorArr = colorTool.parse(backgroundColor); + backgroundColor = colorTool.stringify(colorArr, 'rgb'); + if (colorArr[3] === 0) { + backgroundColor = 'transparent'; + } + } + backgroundColor = backgroundColor; + this._dom.style.backgroundColor = backgroundColor; + } + + // console.time && console.timeEnd('update'); + }, + + // PENDING + /** + * @param {Object} payload + * @private + */ + updateView: function (payload) { + var ecModel = this._model; + + // update before setOption + if (!ecModel) { + return; + } + + doLayout.call(this, ecModel, payload); + + doVisualCoding.call(this, ecModel, payload); + + invokeUpdateMethod.call(this, 'updateView', ecModel, payload); + }, + + /** + * @param {Object} payload + * @private + */ + updateVisual: function (payload) { + var ecModel = this._model; + + // update before setOption + if (!ecModel) { + return; + } + + doVisualCoding.call(this, ecModel, payload); + + invokeUpdateMethod.call(this, 'updateVisual', ecModel, payload); + }, + + /** + * @param {Object} payload + * @private + */ + updateLayout: function (payload) { + var ecModel = this._model; + + // update before setOption + if (!ecModel) { + return; + } + + doLayout.call(this, ecModel, payload); + + invokeUpdateMethod.call(this, 'updateLayout', ecModel, payload); + }, + + /** + * @param {Object} payload + * @private + */ + highlight: function (payload) { + toggleHighlight.call(this, 'highlight', payload); + }, + + /** + * @param {Object} payload + * @private + */ + downplay: function (payload) { + toggleHighlight.call(this, 'downplay', payload); + }, + + /** + * @param {Object} payload + * @private + */ + prepareAndUpdate: function (payload) { + var ecModel = this._model; + + prepareView.call(this, 'component', ecModel); + + prepareView.call(this, 'chart', ecModel); + + updateMethods.update.call(this, payload); + } + }; + + /** + * @param {Object} payload + * @private + */ + function toggleHighlight(method, payload) { + var ecModel = this._model; + + // dispatchAction before setOption + if (!ecModel) { + return; + } + + ecModel.eachComponent( + {mainType: 'series', query: payload}, + function (seriesModel, index) { + var chartView = this._chartsMap[seriesModel.__viewId]; + if (chartView && chartView.__alive) { + chartView[method]( + seriesModel, ecModel, this._api, payload + ); + } + }, + this + ); + } + + /** + * Resize the chart + */ + echartsProto.resize = function () { + this._zr.resize(); + + var optionChanged = this._model && this._model.resetOption('media'); + updateMethods[optionChanged ? 'prepareAndUpdate' : 'update'].call(this); + + // Resize loading effect + this._loadingFX && this._loadingFX.resize(); + }; + + var defaultLoadingEffect = __webpack_require__(87); + /** + * Show loading effect + * @param {string} [name='default'] + * @param {Object} [cfg] + */ + echartsProto.showLoading = function (name, cfg) { + if (zrUtil.isObject(name)) { + cfg = name; + name = 'default'; + } + var el = defaultLoadingEffect(this._api, cfg); + var zr = this._zr; + this._loadingFX = el; + + zr.add(el); + }; + + /** + * Hide loading effect + */ + echartsProto.hideLoading = function () { + this._loadingFX && this._zr.remove(this._loadingFX); + this._loadingFX = null; + }; + + /** + * @param {Object} eventObj + * @return {Object} + */ + echartsProto.makeActionFromEvent = function (eventObj) { + var payload = zrUtil.extend({}, eventObj); + payload.type = eventActionMap[eventObj.type]; + return payload; + }; + + /** + * @pubilc + * @param {Object} payload + * @param {string} [payload.type] Action type + * @param {boolean} [silent=false] Whether trigger event. + */ + echartsProto.dispatchAction = function (payload, silent) { + var actionWrap = actions[payload.type]; + if (actionWrap) { + var actionInfo = actionWrap.actionInfo; + var updateMethod = actionInfo.update || 'update'; + + var payloads = [payload]; + var batched = false; + // Batch action + if (payload.batch) { + batched = true; + payloads = zrUtil.map(payload.batch, function (item) { + item = zrUtil.defaults(zrUtil.extend({}, item), payload); + item.batch = null; + return item; + }); + } + + var eventObjBatch = []; + var eventObj; + var isHighlightOrDownplay = payload.type === 'highlight' || payload.type === 'downplay'; + for (var i = 0; i < payloads.length; i++) { + var batchItem = payloads[i]; + // Action can specify the event by return it. + eventObj = actionWrap.action(batchItem, this._model); + // Emit event outside + eventObj = eventObj || zrUtil.extend({}, batchItem); + // Convert type to eventType + eventObj.type = actionInfo.event || eventObj.type; + eventObjBatch.push(eventObj); + + // Highlight and downplay are special. + isHighlightOrDownplay && updateMethods[updateMethod].call(this, batchItem); + } + + (updateMethod !== 'none' && !isHighlightOrDownplay) + && updateMethods[updateMethod].call(this, payload); + if (!silent) { + // Follow the rule of action batch + if (batched) { + eventObj = { + type: eventObjBatch[0].type, + batch: eventObjBatch + }; + } + else { + eventObj = eventObjBatch[0]; + } + this._messageCenter.trigger(eventObj.type, eventObj); + } + } + }; + + /** + * Register event + * @method + */ + echartsProto.on = createRegisterEventWithLowercaseName('on'); + echartsProto.off = createRegisterEventWithLowercaseName('off'); + echartsProto.one = createRegisterEventWithLowercaseName('one'); + + /** + * @param {string} methodName + * @private + */ + function invokeUpdateMethod(methodName, ecModel, payload) { + var api = this._api; + + // Update all components + each(this._componentsViews, function (component) { + var componentModel = component.__model; + component[methodName](componentModel, ecModel, api, payload); + + updateZ(componentModel, component); + }, this); + + // Upate all charts + ecModel.eachSeries(function (seriesModel, idx) { + var chart = this._chartsMap[seriesModel.__viewId]; + chart[methodName](seriesModel, ecModel, api, payload); + + updateZ(seriesModel, chart); + }, this); + + } + + /** + * Prepare view instances of charts and components + * @param {module:echarts/model/Global} ecModel + * @private + */ + function prepareView(type, ecModel) { + var isComponent = type === 'component'; + var viewList = isComponent ? this._componentsViews : this._chartsViews; + var viewMap = isComponent ? this._componentsMap : this._chartsMap; + var zr = this._zr; + + for (var i = 0; i < viewList.length; i++) { + viewList[i].__alive = false; + } + + ecModel[isComponent ? 'eachComponent' : 'eachSeries'](function (componentType, model) { + if (isComponent) { + if (componentType === 'series') { + return; + } + } + else { + model = componentType; + } + + // Consider: id same and type changed. + var viewId = model.id + '_' + model.type; + var view = viewMap[viewId]; + if (!view) { + var classType = ComponentModel.parseClassType(model.type); + var Clazz = isComponent + ? ComponentView.getClass(classType.main, classType.sub) + : ChartView.getClass(classType.sub); + if (Clazz) { + view = new Clazz(); + view.init(ecModel, this._api); + viewMap[viewId] = view; + viewList.push(view); + zr.add(view.group); + } + else { + // Error + return; + } + } + + model.__viewId = viewId; + view.__alive = true; + view.__id = viewId; + view.__model = model; + }, this); + + for (var i = 0; i < viewList.length;) { + var view = viewList[i]; + if (!view.__alive) { + zr.remove(view.group); + view.dispose(ecModel, this._api); + viewList.splice(i, 1); + delete viewMap[view.__id]; + } + else { + i++; + } + } + } + + /** + * Processor data in each series + * + * @param {module:echarts/model/Global} ecModel + * @private + */ + function processData(ecModel, api) { + each(PROCESSOR_STAGES, function (stage) { + each(dataProcessorFuncs[stage] || [], function (process) { + process(ecModel, api); + }); + }); + } + + /** + * @private + */ + function stackSeriesData(ecModel) { + var stackedDataMap = {}; + ecModel.eachSeries(function (series) { + var stack = series.get('stack'); + var data = series.getData(); + if (stack && data.type === 'list') { + var previousStack = stackedDataMap[stack]; + if (previousStack) { + data.stackedOn = previousStack; + } + stackedDataMap[stack] = data; + } + }); + } + + /** + * Layout before each chart render there series, after visual coding and data processing + * + * @param {module:echarts/model/Global} ecModel + * @private + */ + function doLayout(ecModel, payload) { + var api = this._api; + each(layoutFuncs, function (layout) { + layout(ecModel, api, payload); + }); + } + + /** + * Code visual infomation from data after data processing + * + * @param {module:echarts/model/Global} ecModel + * @private + */ + function doVisualCoding(ecModel, payload) { + each(VISUAL_CODING_STAGES, function (stage) { + each(visualCodingFuncs[stage] || [], function (visualCoding) { + visualCoding(ecModel, payload); + }); + }); + } + + /** + * Render each chart and component + * @private + */ + function doRender(ecModel, payload) { + var api = this._api; + // Render all components + each(this._componentsViews, function (componentView) { + var componentModel = componentView.__model; + componentView.render(componentModel, ecModel, api, payload); + + updateZ(componentModel, componentView); + }, this); + + each(this._chartsViews, function (chart) { + chart.__alive = false; + }, this); + + // Render all charts + ecModel.eachSeries(function (seriesModel, idx) { + var chartView = this._chartsMap[seriesModel.__viewId]; + chartView.__alive = true; + chartView.render(seriesModel, ecModel, api, payload); + + updateZ(seriesModel, chartView); + }, this); + + // Remove groups of unrendered charts + each(this._chartsViews, function (chart) { + if (!chart.__alive) { + chart.remove(ecModel, api); + } + }, this); + } + + var MOUSE_EVENT_NAMES = [ + 'click', 'dblclick', 'mouseover', 'mouseout', 'globalout' + ]; + /** + * @private + */ + echartsProto._initEvents = function () { + var zr = this._zr; + each(MOUSE_EVENT_NAMES, function (eveName) { + zr.on(eveName, function (e) { + var ecModel = this.getModel(); + var el = e.target; + if (el && el.dataIndex != null) { + var hostModel = el.hostModel || ecModel.getSeriesByIndex(el.seriesIndex); + var params = hostModel && hostModel.getDataParams(el.dataIndex) || {}; + params.event = e; + params.type = eveName; + this.trigger(eveName, params); + } + }, this); + }, this); + + each(eventActionMap, function (actionType, eventType) { + this._messageCenter.on(eventType, function (event) { + this.trigger(eventType, event); + }, this); + }, this); + }; + + /** + * @return {boolean} + */ + echartsProto.isDisposed = function () { + return this._disposed; + }; + + /** + * Clear + */ + echartsProto.clear = function () { + this.setOption({}, true); + }; + /** + * Dispose instance + */ + echartsProto.dispose = function () { + this._disposed = true; + var api = this._api; + var ecModel = this._model; + + each(this._componentsViews, function (component) { + component.dispose(ecModel, api); + }); + each(this._chartsViews, function (chart) { + chart.dispose(ecModel, api); + }); + + this._zr.dispose(); + + instances[this.id] = null; + }; + + zrUtil.mixin(ECharts, Eventful); + + /** + * @param {module:echarts/model/Series|module:echarts/model/Component} model + * @param {module:echarts/view/Component|module:echarts/view/Chart} view + * @return {string} + */ + function updateZ(model, view) { + var z = model.get('z'); + var zlevel = model.get('zlevel'); + // Set z and zlevel + view.group.traverse(function (el) { + z != null && (el.z = z); + zlevel != null && (el.zlevel = zlevel); + }); + } + /** + * @type {Array.} + * @inner + */ + var actions = []; + + /** + * Map eventType to actionType + * @type {Object} + */ + var eventActionMap = {}; + + /** + * @type {Array.} + * @inner + */ + var layoutFuncs = []; + + /** + * Data processor functions of each stage + * @type {Array.>} + * @inner + */ + var dataProcessorFuncs = {}; + + /** + * @type {Array.} + * @inner + */ + var optionPreprocessorFuncs = []; + + /** + * Visual coding functions of each stage + * @type {Array.>} + * @inner + */ + var visualCodingFuncs = {}; + /** + * Theme storage + * @type {Object.} + */ + var themeStorage = {}; + + + var instances = {}; + var connectedGroups = {}; + + var idBase = new Date() - 0; + var groupIdBase = new Date() - 0; + var DOM_ATTRIBUTE_KEY = '_echarts_instance_'; + /** + * @alias module:echarts + */ + var echarts = { + /** + * @type {number} + */ + version: '3.1.3', + dependencies: { + zrender: '3.0.4' + } + }; + + function enableConnect(chart) { + + var STATUS_PENDING = 0; + var STATUS_UPDATING = 1; + var STATUS_UPDATED = 2; + var STATUS_KEY = '__connectUpdateStatus'; + function updateConnectedChartsStatus(charts, status) { + for (var i = 0; i < charts.length; i++) { + var otherChart = charts[i]; + otherChart[STATUS_KEY] = status; + } + } + zrUtil.each(eventActionMap, function (actionType, eventType) { + chart._messageCenter.on(eventType, function (event) { + if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) { + var action = chart.makeActionFromEvent(event); + var otherCharts = []; + for (var id in instances) { + var otherChart = instances[id]; + if (otherChart !== chart && otherChart.group === chart.group) { + otherCharts.push(otherChart); + } + } + updateConnectedChartsStatus(otherCharts, STATUS_PENDING); + each(otherCharts, function (otherChart) { + if (otherChart[STATUS_KEY] !== STATUS_UPDATING) { + otherChart.dispatchAction(action); + } + }); + updateConnectedChartsStatus(otherCharts, STATUS_UPDATED); + } + }); + }); + + } + /** + * @param {HTMLDomElement} dom + * @param {Object} [theme] + * @param {Object} opts + */ + echarts.init = function (dom, theme, opts) { + // Check version + if ((zrender.version.replace('.', '') - 0) < (echarts.dependencies.zrender.replace('.', '') - 0)) { + throw new Error( + 'ZRender ' + zrender.version + + ' is too old for ECharts ' + echarts.version + + '. Current version need ZRender ' + + echarts.dependencies.zrender + '+' + ); + } + if (!dom) { + throw new Error('Initialize failed: invalid dom.'); + } + + var chart = new ECharts(dom, theme, opts); + chart.id = 'ec_' + idBase++; + instances[chart.id] = chart; + + dom.setAttribute && + dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id); + + enableConnect(chart); + + return chart; + }; + + /** + * @return {string|Array.} groupId + */ + echarts.connect = function (groupId) { + // Is array of charts + if (zrUtil.isArray(groupId)) { + var charts = groupId; + groupId = null; + // If any chart has group + zrUtil.each(charts, function (chart) { + if (chart.group != null) { + groupId = chart.group; + } + }); + groupId = groupId || ('g_' + groupIdBase++); + zrUtil.each(charts, function (chart) { + chart.group = groupId; + }); + } + connectedGroups[groupId] = true; + return groupId; + }; + + /** + * @return {string} groupId + */ + echarts.disConnect = function (groupId) { + connectedGroups[groupId] = false; + }; + + /** + * Dispose a chart instance + * @param {module:echarts~ECharts|HTMLDomElement|string} chart + */ + echarts.dispose = function (chart) { + if (zrUtil.isDom(chart)) { + chart = echarts.getInstanceByDom(chart); + } + else if (typeof chart === 'string') { + chart = instances[chart]; + } + if ((chart instanceof ECharts) && !chart.isDisposed()) { + chart.dispose(); + } + }; + + /** + * @param {HTMLDomElement} dom + * @return {echarts~ECharts} + */ + echarts.getInstanceByDom = function (dom) { + var key = dom.getAttribute(DOM_ATTRIBUTE_KEY); + return instances[key]; + }; + /** + * @param {string} key + * @return {echarts~ECharts} + */ + echarts.getInstanceById = function (key) { + return instances[key]; + }; + + /** + * Register theme + */ + echarts.registerTheme = function (name, theme) { + themeStorage[name] = theme; + }; + + /** + * Register option preprocessor + * @param {Function} preprocessorFunc + */ + echarts.registerPreprocessor = function (preprocessorFunc) { + optionPreprocessorFuncs.push(preprocessorFunc); + }; + + /** + * @param {string} stage + * @param {Function} processorFunc + */ + echarts.registerProcessor = function (stage, processorFunc) { + if (zrUtil.indexOf(PROCESSOR_STAGES, stage) < 0) { + throw new Error('stage should be one of ' + PROCESSOR_STAGES); + } + var funcs = dataProcessorFuncs[stage] || (dataProcessorFuncs[stage] = []); + funcs.push(processorFunc); + }; + + /** + * Usage: + * registerAction('someAction', 'someEvent', function () { ... }); + * registerAction('someAction', function () { ... }); + * registerAction( + * {type: 'someAction', event: 'someEvent', update: 'updateView'}, + * function () { ... } + * ); + * + * @param {(string|Object)} actionInfo + * @param {string} actionInfo.type + * @param {string} [actionInfo.event] + * @param {string} [actionInfo.update] + * @param {string} [eventName] + * @param {Function} action + */ + echarts.registerAction = function (actionInfo, eventName, action) { + if (typeof eventName === 'function') { + action = eventName; + eventName = ''; + } + var actionType = zrUtil.isObject(actionInfo) + ? actionInfo.type + : ([actionInfo, actionInfo = { + event: eventName + }][0]); + + // Event name is all lowercase + actionInfo.event = (actionInfo.event || actionType).toLowerCase(); + eventName = actionInfo.event; + + if (!actions[actionType]) { + actions[actionType] = {action: action, actionInfo: actionInfo}; + } + eventActionMap[eventName] = actionType; + }; + + /** + * @param {string} type + * @param {*} CoordinateSystem + */ + echarts.registerCoordinateSystem = function (type, CoordinateSystem) { + CoordinateSystemManager.register(type, CoordinateSystem); + }; + + /** + * @param {*} layout + */ + echarts.registerLayout = function (layout) { + // PENDING All functions ? + if (zrUtil.indexOf(layoutFuncs, layout) < 0) { + layoutFuncs.push(layout); + } + }; + + /** + * @param {string} stage + * @param {Function} visualCodingFunc + */ + echarts.registerVisualCoding = function (stage, visualCodingFunc) { + if (zrUtil.indexOf(VISUAL_CODING_STAGES, stage) < 0) { + throw new Error('stage should be one of ' + VISUAL_CODING_STAGES); + } + var funcs = visualCodingFuncs[stage] || (visualCodingFuncs[stage] = []); + funcs.push(visualCodingFunc); + }; + + /** + * @param {Object} opts + */ + echarts.extendChartView = function (opts) { + return ChartView.extend(opts); + }; + + /** + * @param {Object} opts + */ + echarts.extendComponentModel = function (opts) { + return ComponentModel.extend(opts); + }; + + /** + * @param {Object} opts + */ + echarts.extendSeriesModel = function (opts) { + return SeriesModel.extend(opts); + }; + + /** + * @param {Object} opts + */ + echarts.extendComponentView = function (opts) { + return ComponentView.extend(opts); + }; + + /** + * ZRender need a canvas context to do measureText. + * But in node environment canvas may be created by node-canvas. + * So we need to specify how to create a canvas instead of using document.createElement('canvas') + * + * Be careful of using it in the browser. + * + * @param {Function} creator + * @example + * var Canvas = require('canvas'); + * var echarts = require('echarts'); + * echarts.setCanvasCreator(function () { + * // Small size is enough. + * return new Canvas(32, 32); + * }); + */ + echarts.setCanvasCreator = function (creator) { + zrUtil.createCanvas = creator; + }; + + echarts.registerVisualCoding('echarts', zrUtil.curry( + __webpack_require__(88), '', 'itemStyle' + )); + echarts.registerPreprocessor(__webpack_require__(89)); + + // Default action + echarts.registerAction({ + type: 'highlight', + event: 'highlight', + update: 'highlight' + }, zrUtil.noop); + echarts.registerAction({ + type: 'downplay', + event: 'downplay', + update: 'downplay' + }, zrUtil.noop); + + + // -------- + // Exports + // -------- + + echarts.graphic = __webpack_require__(42); + echarts.number = __webpack_require__(7); + echarts.format = __webpack_require__(6); + echarts.matrix = __webpack_require__(17); + echarts.vector = __webpack_require__(16); + + echarts.util = {}; + each([ + 'map', 'each', 'filter', 'indexOf', 'inherits', + 'reduce', 'filter', 'bind', 'curry', 'isArray', + 'isString', 'isObject', 'isFunction', 'extend' + ], + function (name) { + echarts.util[name] = zrUtil[name]; + } + ); + + module.exports = echarts; + + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * ECharts global model + * + * @module {echarts/model/Global} + * + */ + + + + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var Model = __webpack_require__(8); + var each = zrUtil.each; + var filter = zrUtil.filter; + var map = zrUtil.map; + var isArray = zrUtil.isArray; + var indexOf = zrUtil.indexOf; + var isObject = zrUtil.isObject; + + var ComponentModel = __webpack_require__(19); + + var globalDefault = __webpack_require__(23); + + var OPTION_INNER_KEY = '\0_ec_inner'; + + /** + * @alias module:echarts/model/Global + * + * @param {Object} option + * @param {module:echarts/model/Model} parentModel + * @param {Object} theme + */ + var GlobalModel = Model.extend({ + + constructor: GlobalModel, + + init: function (option, parentModel, theme, optionManager) { + theme = theme || {}; + + this.option = null; // Mark as not initialized. + + /** + * @type {module:echarts/model/Model} + * @private + */ + this._theme = new Model(theme); + + /** + * @type {module:echarts/model/OptionManager} + */ + this._optionManager = optionManager; + }, + + setOption: function (option, optionPreprocessorFuncs) { + zrUtil.assert( + !(OPTION_INNER_KEY in option), + 'please use chart.getOption()' + ); + + this._optionManager.setOption(option, optionPreprocessorFuncs); + + this.resetOption(); + }, + + /** + * @param {string} type null/undefined: reset all. + * 'recreate': force recreate all. + * 'timeline': only reset timeline option + * 'media': only reset media query option + * @return {boolean} Whether option changed. + */ + resetOption: function (type) { + var optionChanged = false; + var optionManager = this._optionManager; + + if (!type || type === 'recreate') { + var baseOption = optionManager.mountOption(type === 'recreate'); + + if (!this.option || type === 'recreate') { + initBase.call(this, baseOption); + } + else { + this.restoreData(); + this.mergeOption(baseOption); + } + optionChanged = true; + } + + if (type === 'timeline' || type === 'media') { + this.restoreData(); + } + + if (!type || type === 'recreate' || type === 'timeline') { + var timelineOption = optionManager.getTimelineOption(this); + timelineOption && (this.mergeOption(timelineOption), optionChanged = true); + } + + if (!type || type === 'recreate' || type === 'media') { + var mediaOptions = optionManager.getMediaOption(this, this._api); + if (mediaOptions.length) { + each(mediaOptions, function (mediaOption) { + this.mergeOption(mediaOption, optionChanged = true); + }, this); + } + } + + return optionChanged; + }, + + /** + * @protected + */ + mergeOption: function (newOption) { + var option = this.option; + var componentsMap = this._componentsMap; + var newCptTypes = []; + + // 如果不存在对应的 component model 则直接 merge + each(newOption, function (componentOption, mainType) { + if (componentOption == null) { + return; + } + + if (!ComponentModel.hasClass(mainType)) { + option[mainType] = option[mainType] == null + ? zrUtil.clone(componentOption) + : zrUtil.merge(option[mainType], componentOption, true); + } + else { + newCptTypes.push(mainType); + } + }); + + // FIXME OPTION 同步是否要改回原来的 + ComponentModel.topologicalTravel( + newCptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this + ); + + function visitComponent(mainType, dependencies) { + var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]); + + var mapResult = modelUtil.mappingToExists( + componentsMap[mainType], newCptOptionList + ); + + makeKeyInfo(mainType, mapResult); + + var dependentModels = getComponentsByTypes( + componentsMap, dependencies + ); + + option[mainType] = []; + componentsMap[mainType] = []; + + each(mapResult, function (resultItem, index) { + var componentModel = resultItem.exist; + var newCptOption = resultItem.option; + + zrUtil.assert( + isObject(newCptOption) || componentModel, + 'Empty component definition' + ); + + // Consider where is no new option and should be merged using {}, + // see removeEdgeAndAdd in topologicalTravel and + // ComponentModel.getAllClassMainTypes. + if (!newCptOption) { + componentModel.mergeOption({}, this); + componentModel.optionUpdated(this); + } + else { + var ComponentModelClass = ComponentModel.getClass( + mainType, resultItem.keyInfo.subType, true + ); + + if (componentModel && componentModel instanceof ComponentModelClass) { + componentModel.mergeOption(newCptOption, this); + componentModel.optionUpdated(this); + } + else { + // PENDING Global as parent ? + componentModel = new ComponentModelClass( + newCptOption, this, this, + zrUtil.extend( + { + dependentModels: dependentModels, + componentIndex: index + }, + resultItem.keyInfo + ) + ); + // Call optionUpdated after init + componentModel.optionUpdated(this); + } + } + + componentsMap[mainType][index] = componentModel; + option[mainType][index] = componentModel.option; + }, this); + + // Backup series for filtering. + if (mainType === 'series') { + this._seriesIndices = createSeriesIndices(componentsMap.series); + } + } + }, + + /** + * Get option for output (cloned option and inner info removed) + * @public + * @return {Object} + */ + getOption: function () { + var option = zrUtil.clone(this.option); + + each(option, function (opts, mainType) { + if (ComponentModel.hasClass(mainType)) { + var opts = modelUtil.normalizeToArray(opts); + for (var i = opts.length - 1; i >= 0; i--) { + // Remove options with inner id. + if (modelUtil.isIdInner(opts[i])) { + opts.splice(i, 1); + } + } + option[mainType] = opts; + } + }); + + delete option[OPTION_INNER_KEY]; + + return option; + }, + + /** + * @return {module:echarts/model/Model} + */ + getTheme: function () { + return this._theme; + }, + + /** + * @param {string} mainType + * @param {number} [idx=0] + * @return {module:echarts/model/Component} + */ + getComponent: function (mainType, idx) { + var list = this._componentsMap[mainType]; + if (list) { + return list[idx || 0]; + } + }, + + /** + * @param {Object} condition + * @param {string} condition.mainType + * @param {string} [condition.subType] If ignore, only query by mainType + * @param {number} [condition.index] Either input index or id or name. + * @param {string} [condition.id] Either input index or id or name. + * @param {string} [condition.name] Either input index or id or name. + * @return {Array.} + */ + queryComponents: function (condition) { + var mainType = condition.mainType; + if (!mainType) { + return []; + } + + var index = condition.index; + var id = condition.id; + var name = condition.name; + + var cpts = this._componentsMap[mainType]; + + if (!cpts || !cpts.length) { + return []; + } + + var result; + + if (index != null) { + if (!isArray(index)) { + index = [index]; + } + result = filter(map(index, function (idx) { + return cpts[idx]; + }), function (val) { + return !!val; + }); + } + else if (id != null) { + var isIdArray = isArray(id); + result = filter(cpts, function (cpt) { + return (isIdArray && indexOf(id, cpt.id) >= 0) + || (!isIdArray && cpt.id === id); + }); + } + else if (name != null) { + var isNameArray = isArray(name); + result = filter(cpts, function (cpt) { + return (isNameArray && indexOf(name, cpt.name) >= 0) + || (!isNameArray && cpt.name === name); + }); + } + + return filterBySubType(result, condition); + }, + + /** + * The interface is different from queryComponents, + * which is convenient for inner usage. + * + * @usage + * findComponents( + * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}, + * function (model, index) {...} + * ); + * + * findComponents( + * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}, + * function (model, index) {...} + * ); + * + * var result = findComponents( + * {mainType: 'series'}, + * function (model, index) {...} + * ); + * // result like [component0, componnet1, ...] + * + * @param {Object} condition + * @param {string} condition.mainType Mandatory. + * @param {string} [condition.subType] Optional. + * @param {Object} [condition.query] like {xxxIndex, xxxId, xxxName}, + * where xxx is mainType. + * If query attribute is null/undefined or has no index/id/name, + * do not filtering by query conditions, which is convenient for + * no-payload situations or when target of action is global. + * @param {Function} [condition.filter] parameter: component, return boolean. + * @return {Array.} + */ + findComponents: function (condition) { + var query = condition.query; + var mainType = condition.mainType; + + var queryCond = getQueryCond(query); + var result = queryCond + ? this.queryComponents(queryCond) + : this._componentsMap[mainType]; + + return doFilter(filterBySubType(result, condition)); + + function getQueryCond(q) { + var indexAttr = mainType + 'Index'; + var idAttr = mainType + 'Id'; + var nameAttr = mainType + 'Name'; + return q && ( + q.hasOwnProperty(indexAttr) + || q.hasOwnProperty(idAttr) + || q.hasOwnProperty(nameAttr) + ) + ? { + mainType: mainType, + // subType will be filtered finally. + index: q[indexAttr], + id: q[idAttr], + name: q[nameAttr] + } + : null; + } + + function doFilter(res) { + return condition.filter + ? filter(res, condition.filter) + : res; + } + }, + + /** + * @usage + * eachComponent('legend', function (legendModel, index) { + * ... + * }); + * eachComponent(function (componentType, model, index) { + * // componentType does not include subType + * // (componentType is 'xxx' but not 'xxx.aa') + * }); + * eachComponent( + * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}, + * function (model, index) {...} + * ); + * eachComponent( + * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}, + * function (model, index) {...} + * ); + * + * @param {string|Object=} mainType When mainType is object, the definition + * is the same as the method 'findComponents'. + * @param {Function} cb + * @param {*} context + */ + eachComponent: function (mainType, cb, context) { + var componentsMap = this._componentsMap; + + if (typeof mainType === 'function') { + context = cb; + cb = mainType; + each(componentsMap, function (components, componentType) { + each(components, function (component, index) { + cb.call(context, componentType, component, index); + }); + }); + } + else if (zrUtil.isString(mainType)) { + each(componentsMap[mainType], cb, context); + } + else if (isObject(mainType)) { + var queryResult = this.findComponents(mainType); + each(queryResult, cb, context); + } + }, + + /** + * @param {string} name + * @return {Array.} + */ + getSeriesByName: function (name) { + var series = this._componentsMap.series; + return filter(series, function (oneSeries) { + return oneSeries.name === name; + }); + }, + + /** + * @param {number} seriesIndex + * @return {module:echarts/model/Series} + */ + getSeriesByIndex: function (seriesIndex) { + return this._componentsMap.series[seriesIndex]; + }, + + /** + * @param {string} subType + * @return {Array.} + */ + getSeriesByType: function (subType) { + var series = this._componentsMap.series; + return filter(series, function (oneSeries) { + return oneSeries.subType === subType; + }); + }, + + /** + * @return {Array.} + */ + getSeries: function () { + return this._componentsMap.series.slice(); + }, + + /** + * After filtering, series may be different + * frome raw series. + * + * @param {Function} cb + * @param {*} context + */ + eachSeries: function (cb, context) { + assertSeriesInitialized(this); + each(this._seriesIndices, function (rawSeriesIndex) { + var series = this._componentsMap.series[rawSeriesIndex]; + cb.call(context, series, rawSeriesIndex); + }, this); + }, + + /** + * Iterate raw series before filtered. + * + * @param {Function} cb + * @param {*} context + */ + eachRawSeries: function (cb, context) { + each(this._componentsMap.series, cb, context); + }, + + /** + * After filtering, series may be different. + * frome raw series. + * + * @parma {string} subType + * @param {Function} cb + * @param {*} context + */ + eachSeriesByType: function (subType, cb, context) { + assertSeriesInitialized(this); + each(this._seriesIndices, function (rawSeriesIndex) { + var series = this._componentsMap.series[rawSeriesIndex]; + if (series.subType === subType) { + cb.call(context, series, rawSeriesIndex); + } + }, this); + }, + + /** + * Iterate raw series before filtered of given type. + * + * @parma {string} subType + * @param {Function} cb + * @param {*} context + */ + eachRawSeriesByType: function (subType, cb, context) { + return each(this.getSeriesByType(subType), cb, context); + }, + + /** + * @param {module:echarts/model/Series} seriesModel + */ + isSeriesFiltered: function (seriesModel) { + assertSeriesInitialized(this); + return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0; + }, + + /** + * @param {Function} cb + * @param {*} context + */ + filterSeries: function (cb, context) { + assertSeriesInitialized(this); + var filteredSeries = filter( + this._componentsMap.series, cb, context + ); + this._seriesIndices = createSeriesIndices(filteredSeries); + }, + + restoreData: function () { + var componentsMap = this._componentsMap; + + this._seriesIndices = createSeriesIndices(componentsMap.series); + + var componentTypes = []; + each(componentsMap, function (components, componentType) { + componentTypes.push(componentType); + }); + + ComponentModel.topologicalTravel( + componentTypes, + ComponentModel.getAllClassMainTypes(), + function (componentType, dependencies) { + each(componentsMap[componentType], function (component) { + component.restoreData(); + }); + } + ); + } + + }); + + /** + * @inner + */ + function mergeTheme(option, theme) { + for (var name in theme) { + // 如果有 component model 则把具体的 merge 逻辑交给该 model 处理 + if (!ComponentModel.hasClass(name)) { + if (typeof theme[name] === 'object') { + option[name] = !option[name] + ? zrUtil.clone(theme[name]) + : zrUtil.merge(option[name], theme[name], false); + } + else { + option[name] = theme[name]; + } + } + } + } + + function initBase(baseOption) { + baseOption = baseOption; + + // Using OPTION_INNER_KEY to mark that this option can not be used outside, + // i.e. `chart.setOption(chart.getModel().option);` is forbiden. + this.option = {}; + this.option[OPTION_INNER_KEY] = 1; + + /** + * @type {Object.>} + * @private + */ + this._componentsMap = {}; + + /** + * Mapping between filtered series list and raw series list. + * key: filtered series indices, value: raw series indices. + * @type {Array.} + * @private + */ + this._seriesIndices = null; + + mergeTheme(baseOption, this._theme.option); + + // TODO Needs clone when merging to the unexisted property + zrUtil.merge(baseOption, globalDefault, false); + + this.mergeOption(baseOption); + } + + /** + * @inner + * @param {Array.|string} types model types + * @return {Object} key: {string} type, value: {Array.} models + */ + function getComponentsByTypes(componentsMap, types) { + if (!zrUtil.isArray(types)) { + types = types ? [types] : []; + } + + var ret = {}; + each(types, function (type) { + ret[type] = (componentsMap[type] || []).slice(); + }); + + return ret; + } + + /** + * @inner + */ + function makeKeyInfo(mainType, mapResult) { + // We use this id to hash component models and view instances + // in echarts. id can be specified by user, or auto generated. + + // The id generation rule ensures new view instance are able + // to mapped to old instance when setOption are called in + // no-merge mode. So we generate model id by name and plus + // type in view id. + + // name can be duplicated among components, which is convenient + // to specify multi components (like series) by one name. + + // Ensure that each id is distinct. + var idMap = {}; + + each(mapResult, function (item, index) { + var existCpt = item.exist; + existCpt && (idMap[existCpt.id] = item); + }); + + each(mapResult, function (item, index) { + var opt = item.option; + + zrUtil.assert( + !opt || opt.id == null || !idMap[opt.id] || idMap[opt.id] === item, + 'id duplicates: ' + (opt && opt.id) + ); + + opt && opt.id != null && (idMap[opt.id] = item); + + // Complete subType + if (isObject(opt)) { + var subType = determineSubType(mainType, opt, item.exist); + item.keyInfo = {mainType: mainType, subType: subType}; + } + }); + + // Make name and id. + each(mapResult, function (item, index) { + var existCpt = item.exist; + var opt = item.option; + var keyInfo = item.keyInfo; + + if (!isObject(opt)) { + return; + } + + // name can be overwitten. Consider case: axis.name = '20km'. + // But id generated by name will not be changed, which affect + // only in that case: setOption with 'not merge mode' and view + // instance will be recreated, which can be accepted. + keyInfo.name = opt.name != null + ? opt.name + '' + : existCpt + ? existCpt.name + : '\0-'; + + if (existCpt) { + keyInfo.id = existCpt.id; + } + else if (opt.id != null) { + keyInfo.id = opt.id + ''; + } + else { + // Consider this situatoin: + // optionA: [{name: 'a'}, {name: 'a'}, {..}] + // optionB [{..}, {name: 'a'}, {name: 'a'}] + // Series with the same name between optionA and optionB + // should be mapped. + var idNum = 0; + do { + keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++; + } + while (idMap[keyInfo.id]); + } + + idMap[keyInfo.id] = item; + }); + } + + /** + * @inner + */ + function determineSubType(mainType, newCptOption, existComponent) { + var subType = newCptOption.type + ? newCptOption.type + : existComponent + ? existComponent.subType + // Use determineSubType only when there is no existComponent. + : ComponentModel.determineSubType(mainType, newCptOption); + + // tooltip, markline, markpoint may always has no subType + return subType; + } + + /** + * @inner + */ + function createSeriesIndices(seriesModels) { + return map(seriesModels, function (series) { + return series.componentIndex; + }) || []; + } + + /** + * @inner + */ + function filterBySubType(components, condition) { + // Using hasOwnProperty for restrict. Consider + // subType is undefined in user payload. + return condition.hasOwnProperty('subType') + ? filter(components, function (cpt) { + return cpt.subType === condition.subType; + }) + : components; + } + + /** + * @inner + */ + function assertSeriesInitialized(ecModel) { + // Components that use _seriesIndices should depends on series component, + // which make sure that their initialization is after series. + if (!ecModel._seriesIndices) { + // FIXME + // 验证和提示怎么写 + throw new Error('Series has not been initialized yet.'); + } + } + + module.exports = GlobalModel; + + +/***/ }, +/* 3 */ +/***/ function(module, exports, __webpack_require__) { + + /** + */ + + var Gradient = __webpack_require__(4); + // 用于处理merge时无法遍历Date等对象的问题 + var BUILTIN_OBJECT = { + '[object Function]': 1, + '[object RegExp]': 1, + '[object Date]': 1, + '[object Error]': 1, + '[object CanvasGradient]': 1 + }; + + var objToString = Object.prototype.toString; + + var arrayProto = Array.prototype; + var nativeForEach = arrayProto.forEach; + var nativeFilter = arrayProto.filter; + var nativeSlice = arrayProto.slice; + var nativeMap = arrayProto.map; + var nativeReduce = arrayProto.reduce; + + /** + * @param {*} source + * @return {*} 拷贝后的新对象 + */ + function clone(source) { + if (typeof source == 'object' && source !== null) { + var result = source; + if (source instanceof Array) { + result = []; + for (var i = 0, len = source.length; i < len; i++) { + result[i] = clone(source[i]); + } + } + else if ( + !isBuildInObject(source) + // 是否为 dom 对象 + && !isDom(source) + ) { + result = {}; + for (var key in source) { + if (source.hasOwnProperty(key)) { + result[key] = clone(source[key]); + } + } + } + + return result; + } + + return source; + } + + /** + * @param {*} target + * @param {*} source + * @param {boolean} [overwrite=false] + */ + function merge(target, source, overwrite) { + // We should escapse that source is string + // and enter for ... in ... + if (!isObject(source) || !isObject(target)) { + return overwrite ? clone(source) : target; + } + + for (var key in source) { + if (source.hasOwnProperty(key)) { + var targetProp = target[key]; + var sourceProp = source[key]; + + if (isObject(sourceProp) + && isObject(targetProp) + && !isArray(sourceProp) + && !isArray(targetProp) + && !isDom(sourceProp) + && !isDom(targetProp) + && !isBuildInObject(sourceProp) + && !isBuildInObject(targetProp) + ) { + // 如果需要递归覆盖,就递归调用merge + merge(targetProp, sourceProp, overwrite); + } + else if (overwrite || !(key in target)) { + // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况 + // NOTE,在 target[key] 不存在的时候也是直接覆盖 + target[key] = clone(source[key], true); + } + } + } + + return target; + } + + /** + * @param {Array} targetAndSources The first item is target, and the rests are source. + * @param {boolean} [overwrite=false] + * @return {*} target + */ + function mergeAll(targetAndSources, overwrite) { + var result = targetAndSources[0]; + for (var i = 1, len = targetAndSources.length; i < len; i++) { + result = merge(result, targetAndSources[i], overwrite); + } + return result; + } + + /** + * @param {*} target + * @param {*} source + */ + function extend(target, source) { + for (var key in source) { + if (source.hasOwnProperty(key)) { + target[key] = source[key]; + } + } + return target; + } + + /** + * @param {*} target + * @param {*} source + * @param {boolen} [overlay=false] + */ + function defaults(target, source, overlay) { + for (var key in source) { + if (source.hasOwnProperty(key) + && (overlay ? source[key] != null : target[key] == null) + ) { + target[key] = source[key]; + } + } + return target; + } + + function createCanvas() { + return document.createElement('canvas'); + } + // FIXME + var _ctx; + function getContext() { + if (!_ctx) { + // Use util.createCanvas instead of createCanvas + // because createCanvas may be overwritten in different environment + _ctx = util.createCanvas().getContext('2d'); + } + return _ctx; + } + + /** + * 查询数组中元素的index + */ + function indexOf(array, value) { + if (array) { + if (array.indexOf) { + return array.indexOf(value); + } + for (var i = 0, len = array.length; i < len; i++) { + if (array[i] === value) { + return i; + } + } + } + return -1; + } + + /** + * 构造类继承关系 + * + * @param {Function} clazz 源类 + * @param {Function} baseClazz 基类 + */ + function inherits(clazz, baseClazz) { + var clazzPrototype = clazz.prototype; + function F() {} + F.prototype = baseClazz.prototype; + clazz.prototype = new F(); + + for (var prop in clazzPrototype) { + clazz.prototype[prop] = clazzPrototype[prop]; + } + clazz.prototype.constructor = clazz; + clazz.superClass = baseClazz; + } + + /** + * @param {Object|Function} target + * @param {Object|Function} sorce + * @param {boolean} overlay + */ + function mixin(target, source, overlay) { + target = 'prototype' in target ? target.prototype : target; + source = 'prototype' in source ? source.prototype : source; + + defaults(target, source, overlay); + } + + /** + * @param {Array|TypedArray} data + */ + function isArrayLike(data) { + if (! data) { + return; + } + if (typeof data == 'string') { + return false; + } + return typeof data.length == 'number'; + } + + /** + * 数组或对象遍历 + * @memberOf module:zrender/tool/util + * @param {Object|Array} obj + * @param {Function} cb + * @param {*} [context] + */ + function each(obj, cb, context) { + if (!(obj && cb)) { + return; + } + if (obj.forEach && obj.forEach === nativeForEach) { + obj.forEach(cb, context); + } + else if (obj.length === +obj.length) { + for (var i = 0, len = obj.length; i < len; i++) { + cb.call(context, obj[i], i, obj); + } + } + else { + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + cb.call(context, obj[key], key, obj); + } + } + } + } + + /** + * 数组映射 + * @memberOf module:zrender/tool/util + * @param {Array} obj + * @param {Function} cb + * @param {*} [context] + * @return {Array} + */ + function map(obj, cb, context) { + if (!(obj && cb)) { + return; + } + if (obj.map && obj.map === nativeMap) { + return obj.map(cb, context); + } + else { + var result = []; + for (var i = 0, len = obj.length; i < len; i++) { + result.push(cb.call(context, obj[i], i, obj)); + } + return result; + } + } + + /** + * @memberOf module:zrender/tool/util + * @param {Array} obj + * @param {Function} cb + * @param {Object} [memo] + * @param {*} [context] + * @return {Array} + */ + function reduce(obj, cb, memo, context) { + if (!(obj && cb)) { + return; + } + if (obj.reduce && obj.reduce === nativeReduce) { + return obj.reduce(cb, memo, context); + } + else { + for (var i = 0, len = obj.length; i < len; i++) { + memo = cb.call(context, memo, obj[i], i, obj); + } + return memo; + } + } + + /** + * 数组过滤 + * @memberOf module:zrender/tool/util + * @param {Array} obj + * @param {Function} cb + * @param {*} [context] + * @return {Array} + */ + function filter(obj, cb, context) { + if (!(obj && cb)) { + return; + } + if (obj.filter && obj.filter === nativeFilter) { + return obj.filter(cb, context); + } + else { + var result = []; + for (var i = 0, len = obj.length; i < len; i++) { + if (cb.call(context, obj[i], i, obj)) { + result.push(obj[i]); + } + } + return result; + } + } + + /** + * 数组项查找 + * @memberOf module:zrender/tool/util + * @param {Array} obj + * @param {Function} cb + * @param {*} [context] + * @return {Array} + */ + function find(obj, cb, context) { + if (!(obj && cb)) { + return; + } + for (var i = 0, len = obj.length; i < len; i++) { + if (cb.call(context, obj[i], i, obj)) { + return obj[i]; + } + } + } + + /** + * @memberOf module:zrender/tool/util + * @param {Function} func + * @param {*} context + * @return {Function} + */ + function bind(func, context) { + var args = nativeSlice.call(arguments, 2); + return function () { + return func.apply(context, args.concat(nativeSlice.call(arguments))); + }; + } + + /** + * @memberOf module:zrender/tool/util + * @param {Function} func + * @param {...} + * @return {Function} + */ + function curry(func) { + var args = nativeSlice.call(arguments, 1); + return function () { + return func.apply(this, args.concat(nativeSlice.call(arguments))); + }; + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isArray(value) { + return objToString.call(value) === '[object Array]'; + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isFunction(value) { + return typeof value === 'function'; + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isString(value) { + return objToString.call(value) === '[object String]'; + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isObject(value) { + // Avoid a V8 JIT bug in Chrome 19-20. + // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. + var type = typeof value; + return type === 'function' || (!!value && type == 'object'); + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isBuildInObject(value) { + return !!BUILTIN_OBJECT[objToString.call(value)] + || (value instanceof Gradient); + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isDom(value) { + return value && value.nodeType === 1 + && typeof(value.nodeName) == 'string'; + } + + /** + * If value1 is not null, then return value1, otherwise judget rest of values. + * @param {*...} values + * @return {*} Final value + */ + function retrieve(values) { + for (var i = 0, len = arguments.length; i < len; i++) { + if (arguments[i] != null) { + return arguments[i]; + } + } + } + + /** + * @memberOf module:zrender/tool/util + * @param {Array} arr + * @param {number} startIndex + * @param {number} endIndex + * @return {Array} + */ + function slice() { + return Function.call.apply(nativeSlice, arguments); + } + + /** + * @param {boolean} condition + * @param {string} message + */ + function assert(condition, message) { + if (!condition) { + throw new Error(message); + } + } + + var util = { + inherits: inherits, + mixin: mixin, + clone: clone, + merge: merge, + mergeAll: mergeAll, + extend: extend, + defaults: defaults, + getContext: getContext, + createCanvas: createCanvas, + indexOf: indexOf, + slice: slice, + find: find, + isArrayLike: isArrayLike, + each: each, + map: map, + reduce: reduce, + filter: filter, + bind: bind, + curry: curry, + isArray: isArray, + isString: isString, + isObject: isObject, + isFunction: isFunction, + isBuildInObject: isBuildInObject, + isDom: isDom, + retrieve: retrieve, + assert: assert, + noop: function () {} + }; + module.exports = util; + + + +/***/ }, +/* 4 */ +/***/ function(module, exports) { + + + + /** + * @param {Array.} colorStops + */ + var Gradient = function (colorStops) { + + this.colorStops = colorStops || []; + }; + + Gradient.prototype = { + + constructor: Gradient, + + addColorStop: function (offset, color) { + this.colorStops.push({ + + offset: offset, + + color: color + }); + } + }; + + module.exports = Gradient; + + +/***/ }, +/* 5 */ +/***/ function(module, exports, __webpack_require__) { + + + + var formatUtil = __webpack_require__(6); + var nubmerUtil = __webpack_require__(7); + var zrUtil = __webpack_require__(3); + + var Model = __webpack_require__(8); + + var AXIS_DIMS = ['x', 'y', 'z', 'radius', 'angle']; + + var modelUtil = {}; + + /** + * Create "each" method to iterate names. + * + * @pubilc + * @param {Array.} names + * @param {Array.=} attrs + * @return {Function} + */ + modelUtil.createNameEach = function (names, attrs) { + names = names.slice(); + var capitalNames = zrUtil.map(names, modelUtil.capitalFirst); + attrs = (attrs || []).slice(); + var capitalAttrs = zrUtil.map(attrs, modelUtil.capitalFirst); + + return function (callback, context) { + zrUtil.each(names, function (name, index) { + var nameObj = {name: name, capital: capitalNames[index]}; + + for (var j = 0; j < attrs.length; j++) { + nameObj[attrs[j]] = name + capitalAttrs[j]; + } + + callback.call(context, nameObj); + }); + }; + }; + + /** + * @public + */ + modelUtil.capitalFirst = function (str) { + return str ? str.charAt(0).toUpperCase() + str.substr(1) : str; + }; + + /** + * Iterate each dimension name. + * + * @public + * @param {Function} callback The parameter is like: + * { + * name: 'angle', + * capital: 'Angle', + * axis: 'angleAxis', + * axisIndex: 'angleAixs', + * index: 'angleIndex' + * } + * @param {Object} context + */ + modelUtil.eachAxisDim = modelUtil.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index']); + + /** + * If value is not array, then translate it to array. + * @param {*} value + * @return {Array} [value] or value + */ + modelUtil.normalizeToArray = function (value) { + return zrUtil.isArray(value) + ? value + : value == null + ? [] + : [value]; + }; + + /** + * If tow dataZoomModels has the same axis controlled, we say that they are 'linked'. + * dataZoomModels and 'links' make up one or more graphics. + * This function finds the graphic where the source dataZoomModel is in. + * + * @public + * @param {Function} forEachNode Node iterator. + * @param {Function} forEachEdgeType edgeType iterator + * @param {Function} edgeIdGetter Giving node and edgeType, return an array of edge id. + * @return {Function} Input: sourceNode, Output: Like {nodes: [], dims: {}} + */ + modelUtil.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) { + + return function (sourceNode) { + var result = { + nodes: [], + records: {} // key: edgeType.name, value: Object (key: edge id, value: boolean). + }; + + forEachEdgeType(function (edgeType) { + result.records[edgeType.name] = {}; + }); + + if (!sourceNode) { + return result; + } + + absorb(sourceNode, result); + + var existsLink; + do { + existsLink = false; + forEachNode(processSingleNode); + } + while (existsLink); + + function processSingleNode(node) { + if (!isNodeAbsorded(node, result) && isLinked(node, result)) { + absorb(node, result); + existsLink = true; + } + } + + return result; + }; + + function isNodeAbsorded(node, result) { + return zrUtil.indexOf(result.nodes, node) >= 0; + } + + function isLinked(node, result) { + var hasLink = false; + forEachEdgeType(function (edgeType) { + zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) { + result.records[edgeType.name][edgeId] && (hasLink = true); + }); + }); + return hasLink; + } + + function absorb(node, result) { + result.nodes.push(node); + forEachEdgeType(function (edgeType) { + zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) { + result.records[edgeType.name][edgeId] = true; + }); + }); + } + }; + + /** + * Sync default option between normal and emphasis like `position` and `show` + * In case some one will write code like + * label: { + * normal: { + * show: false, + * position: 'outside', + * textStyle: { + * fontSize: 18 + * } + * }, + * emphasis: { + * show: true + * } + * } + * @param {Object} opt + * @param {Array.} subOpts + */ + modelUtil.defaultEmphasis = function (opt, subOpts) { + if (opt) { + var emphasisOpt = opt.emphasis = opt.emphasis || {}; + var normalOpt = opt.normal = opt.normal || {}; + + // Default emphasis option from normal + zrUtil.each(subOpts, function (subOptName) { + var val = zrUtil.retrieve(emphasisOpt[subOptName], normalOpt[subOptName]); + if (val != null) { + emphasisOpt[subOptName] = val; + } + }); + } + }; + + /** + * Create a model proxy to be used in tooltip for edge data, markLine data, markPoint data. + * @param {Object} opt + * @param {string} [opt.seriesIndex] + * @param {Object} [opt.name] + * @param {module:echarts/data/List} data + * @param {Array.} rawData + */ + modelUtil.createDataFormatModel = function (opt, data, rawData) { + var model = new Model(); + zrUtil.mixin(model, modelUtil.dataFormatMixin); + model.seriesIndex = opt.seriesIndex; + model.name = opt.name || ''; + + model.getData = function () { + return data; + }; + model.getRawDataArray = function () { + return rawData; + }; + return model; + }; + + /** + * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}] + * This helper method retieves value from data. + * @param {string|number|Date|Array|Object} dataItem + * @return {number|string|Date|Array.} + */ + modelUtil.getDataItemValue = function (dataItem) { + // Performance sensitive. + return dataItem && (dataItem.value == null ? dataItem : dataItem.value); + }; + + /** + * This helper method convert value in data. + * @param {string|number|Date} value + * @param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'. + */ + modelUtil.converDataValue = function (value, dimInfo) { + // Performance sensitive. + var dimType = dimInfo && dimInfo.type; + if (dimType === 'ordinal') { + return value; + } + + if (dimType === 'time' && !isFinite(value) && value != null && value !== '-') { + value = +nubmerUtil.parseDate(value); + } + + // dimType defaults 'number'. + // If dimType is not ordinal and value is null or undefined or NaN or '-', + // parse to NaN. + return (value == null || value === '') + ? NaN : +value; // If string (like '-'), using '+' parse to NaN + }; + + modelUtil.dataFormatMixin = { + /** + * Get params for formatter + * @param {number} dataIndex + * @return {Object} + */ + getDataParams: function (dataIndex) { + var data = this.getData(); + + var seriesIndex = this.seriesIndex; + var seriesName = this.name; + + var rawValue = this.getRawValue(dataIndex); + var rawDataIndex = data.getRawIndex(dataIndex); + var name = data.getName(dataIndex, true); + + // Data may not exists in the option given by user + var rawDataArray = this.getRawDataArray(); + var itemOpt = rawDataArray && rawDataArray[rawDataIndex]; + + return { + seriesIndex: seriesIndex, + seriesName: seriesName, + name: name, + dataIndex: rawDataIndex, + data: itemOpt, + value: rawValue, + + // Param name list for mapping `a`, `b`, `c`, `d`, `e` + $vars: ['seriesName', 'name', 'value'] + }; + }, + + /** + * Format label + * @param {number} dataIndex + * @param {string} [status='normal'] 'normal' or 'emphasis' + * @param {Function|string} [formatter] Default use the `itemStyle[status].label.formatter` + * @return {string} + */ + getFormattedLabel: function (dataIndex, status, formatter) { + status = status || 'normal'; + var data = this.getData(); + var itemModel = data.getItemModel(dataIndex); + + var params = this.getDataParams(dataIndex); + if (formatter == null) { + formatter = itemModel.get(['label', status, 'formatter']); + } + + if (typeof formatter === 'function') { + params.status = status; + return formatter(params); + } + else if (typeof formatter === 'string') { + return formatUtil.formatTpl(formatter, params); + } + }, + + /** + * Get raw value in option + * @param {number} idx + * @return {Object} + */ + getRawValue: function (idx) { + var itemModel = this.getData().getItemModel(idx); + if (itemModel && itemModel.option != null) { + var dataItem = itemModel.option; + return (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem)) + ? dataItem.value : dataItem; + } + } + }; + + /** + * Mapping to exists for merge. + * + * @public + * @param {Array.|Array.} exists + * @param {Object|Array.} newCptOptions + * @return {Array.} Result, like [{exist: ..., option: ...}, {}], + * which order is the same as exists. + */ + modelUtil.mappingToExists = function (exists, newCptOptions) { + // Mapping by the order by original option (but not order of + // new option) in merge mode. Because we should ensure + // some specified index (like xAxisIndex) is consistent with + // original option, which is easy to understand, espatially in + // media query. And in most case, merge option is used to + // update partial option but not be expected to change order. + newCptOptions = (newCptOptions || []).slice(); + + var result = zrUtil.map(exists || [], function (obj, index) { + return {exist: obj}; + }); + + // Mapping by id or name if specified. + zrUtil.each(newCptOptions, function (cptOption, index) { + if (!zrUtil.isObject(cptOption)) { + return; + } + + for (var i = 0; i < result.length; i++) { + var exist = result[i].exist; + if (!result[i].option // Consider name: two map to one. + && ( + // id has highest priority. + (cptOption.id != null && exist.id === cptOption.id + '') + || (cptOption.name != null + && !modelUtil.isIdInner(cptOption) + && !modelUtil.isIdInner(exist) + && exist.name === cptOption.name + '' + ) + ) + ) { + result[i].option = cptOption; + newCptOptions[index] = null; + break; + } + } + }); + + // Otherwise mapping by index. + zrUtil.each(newCptOptions, function (cptOption, index) { + if (!zrUtil.isObject(cptOption)) { + return; + } + + var i = 0; + for (; i < result.length; i++) { + var exist = result[i].exist; + if (!result[i].option + && !modelUtil.isIdInner(exist) + // Caution: + // Do not overwrite id. But name can be overwritten, + // because axis use name as 'show label text'. + // 'exist' always has id and name and we dont + // need to check it. + && cptOption.id == null + ) { + result[i].option = cptOption; + break; + } + } + + if (i >= result.length) { + result.push({option: cptOption}); + } + }); + + return result; + }; + + /** + * @public + * @param {Object} cptOption + * @return {boolean} + */ + modelUtil.isIdInner = function (cptOption) { + return zrUtil.isObject(cptOption) + && cptOption.id + && (cptOption.id + '').indexOf('\0_ec_\0') === 0; + }; + + module.exports = modelUtil; + + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + + /** + * 每三位默认加,格式化 + * @type {string|number} x + */ + function addCommas(x) { + if (isNaN(x)) { + return '-'; + } + x = (x + '').split('.'); + return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,'$1,') + + (x.length > 1 ? ('.' + x[1]) : ''); + } + + /** + * @param {string} str + * @return {string} str + */ + function toCamelCase(str) { + return str.toLowerCase().replace(/-(.)/g, function(match, group1) { + return group1.toUpperCase(); + }); + } + + /** + * Normalize css liked array configuration + * e.g. + * 3 => [3, 3, 3, 3] + * [4, 2] => [4, 2, 4, 2] + * [4, 3, 2] => [4, 3, 2, 3] + * @param {number|Array.} val + */ + function normalizeCssArray(val) { + var len = val.length; + if (typeof (val) === 'number') { + return [val, val, val, val]; + } + else if (len === 2) { + // vertical | horizontal + return [val[0], val[1], val[0], val[1]]; + } + else if (len === 3) { + // top | horizontal | bottom + return [val[0], val[1], val[2], val[1]]; + } + return val; + } + + function encodeHTML(source) { + return String(source) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + } + + var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g']; + + function wrapVar(varName, seriesIdx) { + return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}'; + } + /** + * Template formatter + * @param {string} tpl + * @param {Array.|Object} paramsList + * @return {string} + */ + function formatTpl(tpl, paramsList) { + if (!zrUtil.isArray(paramsList)) { + paramsList = [paramsList]; + } + var seriesLen = paramsList.length; + if (!seriesLen) { + return ''; + } + + var $vars = paramsList[0].$vars; + for (var i = 0; i < $vars.length; i++) { + var alias = TPL_VAR_ALIAS[i]; + tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0)); + } + for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) { + for (var k = 0; k < $vars.length; k++) { + tpl = tpl.replace( + wrapVar(TPL_VAR_ALIAS[k], seriesIdx), + paramsList[seriesIdx][$vars[k]] + ); + } + } + + return tpl; + } + + /** + * ISO Date format + * @param {string} tpl + * @param {number} value + * @inner + */ + function formatTime(tpl, value) { + if (tpl === 'week' + || tpl === 'month' + || tpl === 'quarter' + || tpl === 'half-year' + || tpl === 'year' + ) { + tpl = 'MM-dd\nyyyy'; + } + + var date = numberUtil.parseDate(value); + var y = date.getFullYear(); + var M = date.getMonth() + 1; + var d = date.getDate(); + var h = date.getHours(); + var m = date.getMinutes(); + var s = date.getSeconds(); + + tpl = tpl.replace('MM', s2d(M)) + .toLowerCase() + .replace('yyyy', y) + .replace('yy', y % 100) + .replace('dd', s2d(d)) + .replace('d', d) + .replace('hh', s2d(h)) + .replace('h', h) + .replace('mm', s2d(m)) + .replace('m', m) + .replace('ss', s2d(s)) + .replace('s', s); + + return tpl; + } + + /** + * @param {string} str + * @return {string} + * @inner + */ + function s2d(str) { + return str < 10 ? ('0' + str) : str; + } + + module.exports = { + + normalizeCssArray: normalizeCssArray, + + addCommas: addCommas, + + toCamelCase: toCamelCase, + + encodeHTML: encodeHTML, + + formatTpl: formatTpl, + + formatTime: formatTime + }; + + +/***/ }, +/* 7 */ +/***/ function(module, exports) { + + /** + * 数值处理模块 + * @module echarts/util/number + */ + + + + var number = {}; + + var RADIAN_EPSILON = 1e-4; + + function _trim(str) { + return str.replace(/^\s+/, '').replace(/\s+$/, ''); + } + + /** + * Linear mapping a value from domain to range + * @memberOf module:echarts/util/number + * @param {(number|Array.)} val + * @param {Array.} domain Domain extent domain[0] can be bigger than domain[1] + * @param {Array.} range Range extent range[0] can be bigger than range[1] + * @param {boolean} clamp + * @return {(number|Array.} + */ + number.linearMap = function (val, domain, range, clamp) { + + var sub = domain[1] - domain[0]; + + if (sub === 0) { + return (range[0] + range[1]) / 2; + } + var t = (val - domain[0]) / sub; + + if (clamp) { + t = Math.min(Math.max(t, 0), 1); + } + + return t * (range[1] - range[0]) + range[0]; + }; + + /** + * Convert a percent string to absolute number. + * Returns NaN if percent is not a valid string or number + * @memberOf module:echarts/util/number + * @param {string|number} percent + * @param {number} all + * @return {number} + */ + number.parsePercent = function(percent, all) { + switch (percent) { + case 'center': + case 'middle': + percent = '50%'; + break; + case 'left': + case 'top': + percent = '0%'; + break; + case 'right': + case 'bottom': + percent = '100%'; + break; + } + if (typeof percent === 'string') { + if (_trim(percent).match(/%$/)) { + return parseFloat(percent) / 100 * all; + } + + return parseFloat(percent); + } + + return percent == null ? NaN : +percent; + }; + + /** + * Fix rounding error of float numbers + * @param {number} x + * @return {number} + */ + number.round = function (x) { + // PENDING + return +(+x).toFixed(12); + }; + + number.asc = function (arr) { + arr.sort(function (a, b) { + return a - b; + }); + return arr; + }; + + /** + * Get precision + * @param {number} val + */ + number.getPrecision = function (val) { + if (isNaN(val)) { + return 0; + } + // It is much faster than methods converting number to string as follows + // var tmp = val.toString(); + // return tmp.length - 1 - tmp.indexOf('.'); + // especially when precision is low + var e = 1; + var count = 0; + while (Math.round(val * e) / e !== val) { + e *= 10; + count++; + } + return count; + }; + + /** + * @param {Array.} dataExtent + * @param {Array.} pixelExtent + * @return {number} precision + */ + number.getPixelPrecision = function (dataExtent, pixelExtent) { + var log = Math.log; + var LN10 = Math.LN10; + var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10); + var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10); + return Math.max( + -dataQuantity + sizeQuantity, + 0 + ); + }; + + // Number.MAX_SAFE_INTEGER, ie do not support. + number.MAX_SAFE_INTEGER = 9007199254740991; + + /** + * To 0 - 2 * PI, considering negative radian. + * @param {number} radian + * @return {number} + */ + number.remRadian = function (radian) { + var pi2 = Math.PI * 2; + return (radian % pi2 + pi2) % pi2; + }; + + /** + * @param {type} radian + * @return {boolean} + */ + number.isRadianAroundZero = function (val) { + return val > -RADIAN_EPSILON && val < RADIAN_EPSILON; + }; + + /** + * @param {string|Date|number} value + * @return {number} timestamp + */ + number.parseDate = function (value) { + return value instanceof Date + ? value + : new Date( + typeof value === 'string' + ? value.replace(/-/g, '/') + : Math.round(value) + ); + }; + + // "Nice Numbers for Graph Labels" of Graphic Gems + /** + * find a “nice” number approximately equal to x. Round the number if round = true, take ceiling if round = false + * The primary observation is that the “nicest” numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers. + * @param {number} val + * @param {boolean} round + * @return {number} + */ + number.nice = function (val, round) { + var exp = Math.floor(Math.log(val) / Math.LN10); + var exp10 = Math.pow(10, exp); + var f = val / exp10; // between 1 and 10 + var nf; + if (round) { + if (f < 1.5) { nf = 1; } + else if (f < 2.5) { nf = 2; } + else if (f < 4) { nf = 3; } + else if (f < 7) { nf = 5; } + else { nf = 10; } + } + else { + if (f < 1) { nf = 1; } + else if (f < 2) { nf = 2; } + else if (f < 3) { nf = 3; } + else if (f < 5) { nf = 5; } + else { nf = 10; } + } + return nf * exp10; + }; + + module.exports = number; + + +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/model/Model + */ + + + var zrUtil = __webpack_require__(3); + var clazzUtil = __webpack_require__(9); + + /** + * @alias module:echarts/model/Model + * @constructor + * @param {Object} option + * @param {module:echarts/model/Model} parentModel + * @param {module:echarts/model/Global} ecModel + * @param {Object} extraOpt + */ + function Model(option, parentModel, ecModel, extraOpt) { + /** + * @type {module:echarts/model/Model} + * @readOnly + */ + this.parentModel = parentModel; + + /** + * @type {module:echarts/model/Global} + * @readOnly + */ + this.ecModel = ecModel; + + /** + * @type {Object} + * @protected + */ + this.option = option; + + // Simple optimization + if (this.init) { + if (arguments.length <= 4) { + this.init(option, parentModel, ecModel, extraOpt); + } + else { + this.init.apply(this, arguments); + } + } + } + + Model.prototype = { + + constructor: Model, + + /** + * Model 的初始化函数 + * @param {Object} option + */ + init: null, + + /** + * 从新的 Option merge + */ + mergeOption: function (option) { + zrUtil.merge(this.option, option, true); + }, + + /** + * @param {string} path + * @param {boolean} [ignoreParent=false] + * @return {*} + */ + get: function (path, ignoreParent) { + if (!path) { + return this.option; + } + + if (typeof path === 'string') { + path = path.split('.'); + } + + var obj = this.option; + var parentModel = this.parentModel; + for (var i = 0; i < path.length; i++) { + // obj could be number/string/... (like 0) + obj = (obj && typeof obj === 'object') ? obj[path[i]] : null; + if (obj == null) { + break; + } + } + if (obj == null && parentModel && !ignoreParent) { + obj = parentModel.get(path); + } + return obj; + }, + + /** + * @param {string} key + * @param {boolean} [ignoreParent=false] + * @return {*} + */ + getShallow: function (key, ignoreParent) { + var option = this.option; + var val = option && option[key]; + var parentModel = this.parentModel; + if (val == null && parentModel && !ignoreParent) { + val = parentModel.getShallow(key); + } + return val; + }, + + /** + * @param {string} path + * @param {module:echarts/model/Model} [parentModel] + * @return {module:echarts/model/Model} + */ + getModel: function (path, parentModel) { + var obj = this.get(path, true); + var thisParentModel = this.parentModel; + var model = new Model( + obj, parentModel || (thisParentModel && thisParentModel.getModel(path)), + this.ecModel + ); + return model; + }, + + /** + * If model has option + */ + isEmpty: function () { + return this.option == null; + }, + + restoreData: function () {}, + + // Pending + clone: function () { + var Ctor = this.constructor; + return new Ctor(zrUtil.clone(this.option)); + }, + + setReadOnly: function (properties) { + clazzUtil.setReadOnly(this, properties); + } + }; + + // Enable Model.extend. + clazzUtil.enableClassExtend(Model); + + var mixin = zrUtil.mixin; + mixin(Model, __webpack_require__(10)); + mixin(Model, __webpack_require__(12)); + mixin(Model, __webpack_require__(13)); + mixin(Model, __webpack_require__(18)); + + module.exports = Model; + + +/***/ }, +/* 9 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + var clazz = {}; + + var TYPE_DELIMITER = '.'; + var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___'; + /** + * @public + */ + var parseClassType = clazz.parseClassType = function (componentType) { + var ret = {main: '', sub: ''}; + if (componentType) { + componentType = componentType.split(TYPE_DELIMITER); + ret.main = componentType[0] || ''; + ret.sub = componentType[1] || ''; + } + return ret; + }; + /** + * @public + */ + clazz.enableClassExtend = function (RootClass, preConstruct) { + RootClass.extend = function (proto) { + var ExtendedClass = function () { + preConstruct && preConstruct.apply(this, arguments); + RootClass.apply(this, arguments); + }; + + zrUtil.extend(ExtendedClass.prototype, proto); + + ExtendedClass.extend = this.extend; + ExtendedClass.superCall = superCall; + ExtendedClass.superApply = superApply; + zrUtil.inherits(ExtendedClass, this); + ExtendedClass.superClass = this; + + return ExtendedClass; + }; + }; + + // superCall should have class info, which can not be fetch from 'this'. + // Consider this case: + // class A has method f, + // class B inherits class A, overrides method f, f call superApply('f'), + // class C inherits class B, do not overrides method f, + // then when method of class C is called, dead loop occured. + function superCall(context, methodName) { + var args = zrUtil.slice(arguments, 2); + return this.superClass.prototype[methodName].apply(context, args); + } + + function superApply(context, methodName, args) { + return this.superClass.prototype[methodName].apply(context, args); + } + + /** + * @param {Object} entity + * @param {Object} options + * @param {boolean} [options.registerWhenExtend] + * @public + */ + clazz.enableClassManagement = function (entity, options) { + options = options || {}; + + /** + * Component model classes + * key: componentType, + * value: + * componentClass, when componentType is 'xxx' + * or Object., when componentType is 'xxx.yy' + * @type {Object} + */ + var storage = {}; + + entity.registerClass = function (Clazz, componentType) { + if (componentType) { + componentType = parseClassType(componentType); + + if (!componentType.sub) { + if (storage[componentType.main]) { + throw new Error(componentType.main + 'exists'); + } + storage[componentType.main] = Clazz; + } + else if (componentType.sub !== IS_CONTAINER) { + var container = makeContainer(componentType); + container[componentType.sub] = Clazz; + } + } + return Clazz; + }; + + entity.getClass = function (componentTypeMain, subType, throwWhenNotFound) { + var Clazz = storage[componentTypeMain]; + + if (Clazz && Clazz[IS_CONTAINER]) { + Clazz = subType ? Clazz[subType] : null; + } + + if (throwWhenNotFound && !Clazz) { + throw new Error( + 'Component ' + componentTypeMain + '.' + (subType || '') + ' not exists' + ); + } + + return Clazz; + }; + + entity.getClassesByMainType = function (componentType) { + componentType = parseClassType(componentType); + + var result = []; + var obj = storage[componentType.main]; + + if (obj && obj[IS_CONTAINER]) { + zrUtil.each(obj, function (o, type) { + type !== IS_CONTAINER && result.push(o); + }); + } + else { + result.push(obj); + } + + return result; + }; + + entity.hasClass = function (componentType) { + // Just consider componentType.main. + componentType = parseClassType(componentType); + return !!storage[componentType.main]; + }; + + /** + * @return {Array.} Like ['aa', 'bb'], but can not be ['aa.xx'] + */ + entity.getAllClassMainTypes = function () { + var types = []; + zrUtil.each(storage, function (obj, type) { + types.push(type); + }); + return types; + }; + + /** + * If a main type is container and has sub types + * @param {string} mainType + * @return {boolean} + */ + entity.hasSubTypes = function (componentType) { + componentType = parseClassType(componentType); + var obj = storage[componentType.main]; + return obj && obj[IS_CONTAINER]; + }; + + entity.parseClassType = parseClassType; + + function makeContainer(componentType) { + var container = storage[componentType.main]; + if (!container || !container[IS_CONTAINER]) { + container = storage[componentType.main] = {}; + container[IS_CONTAINER] = true; + } + return container; + } + + if (options.registerWhenExtend) { + var originalExtend = entity.extend; + if (originalExtend) { + entity.extend = function (proto) { + var ExtendedClass = originalExtend.call(this, proto); + return entity.registerClass(ExtendedClass, proto.type); + }; + } + } + + return entity; + }; + + /** + * @param {string|Array.} properties + */ + clazz.setReadOnly = function (obj, properties) { + // FIXME It seems broken in IE8 simulation of IE11 + // if (!zrUtil.isArray(properties)) { + // properties = properties != null ? [properties] : []; + // } + // zrUtil.each(properties, function (prop) { + // var value = obj[prop]; + + // Object.defineProperty + // && Object.defineProperty(obj, prop, { + // value: value, writable: false + // }); + // zrUtil.isArray(obj[prop]) + // && Object.freeze + // && Object.freeze(obj[prop]); + // }); + }; + + module.exports = clazz; + + +/***/ }, +/* 10 */ +/***/ function(module, exports, __webpack_require__) { + + + var getLineStyle = __webpack_require__(11)( + [ + ['lineWidth', 'width'], + ['stroke', 'color'], + ['opacity'], + ['shadowBlur'], + ['shadowOffsetX'], + ['shadowOffsetY'], + ['shadowColor'] + ] + ); + module.exports = { + getLineStyle: function (excludes) { + var style = getLineStyle.call(this, excludes); + var lineDash = this.getLineDash(); + lineDash && (style.lineDash = lineDash); + return style; + }, + + getLineDash: function () { + var lineType = this.get('type'); + return (lineType === 'solid' || lineType == null) ? null + : (lineType === 'dashed' ? [5, 5] : [1, 1]); + } + }; + + +/***/ }, +/* 11 */ +/***/ function(module, exports, __webpack_require__) { + + // TODO Parse shadow style + // TODO Only shallow path support + + var zrUtil = __webpack_require__(3); + + module.exports = function (properties) { + // Normalize + for (var i = 0; i < properties.length; i++) { + if (!properties[i][1]) { + properties[i][1] = properties[i][0]; + } + } + return function (excludes) { + var style = {}; + for (var i = 0; i < properties.length; i++) { + var propName = properties[i][1]; + if (excludes && zrUtil.indexOf(excludes, propName) >= 0) { + continue; + } + var val = this.getShallow(propName); + if (val != null) { + style[properties[i][0]] = val; + } + } + return style; + }; + }; + + +/***/ }, +/* 12 */ +/***/ function(module, exports, __webpack_require__) { + + + module.exports = { + getAreaStyle: __webpack_require__(11)( + [ + ['fill', 'color'], + ['shadowBlur'], + ['shadowOffsetX'], + ['shadowOffsetY'], + ['opacity'], + ['shadowColor'] + ] + ) + }; + + +/***/ }, +/* 13 */ +/***/ function(module, exports, __webpack_require__) { + + + + var textContain = __webpack_require__(14); + + function getShallow(model, path) { + return model && model.getShallow(path); + } + + module.exports = { + /** + * Get color property or get color from option.textStyle.color + * @return {string} + */ + getTextColor: function () { + var ecModel = this.ecModel; + return this.getShallow('color') + || (ecModel && ecModel.get('textStyle.color')); + }, + + /** + * Create font string from fontStyle, fontWeight, fontSize, fontFamily + * @return {string} + */ + getFont: function () { + var ecModel = this.ecModel; + var gTextStyleModel = ecModel && ecModel.getModel('textStyle'); + return [ + // FIXME in node-canvas fontWeight is before fontStyle + this.getShallow('fontStyle') || getShallow(gTextStyleModel, 'fontStyle'), + this.getShallow('fontWeight') || getShallow(gTextStyleModel, 'fontWeight'), + (this.getShallow('fontSize') || getShallow(gTextStyleModel, 'fontSize') || 12) + 'px', + this.getShallow('fontFamily') || getShallow(gTextStyleModel, 'fontFamily') || 'sans-serif' + ].join(' '); + }, + + getTextRect: function (text) { + var textStyle = this.get('textStyle') || {}; + return textContain.getBoundingRect( + text, + this.getFont(), + textStyle.align, + textStyle.baseline + ); + }, + + ellipsis: function (text, containerWidth, options) { + return textContain.ellipsis( + text, this.getFont(), containerWidth, options + ); + } + }; + + +/***/ }, +/* 14 */ +/***/ function(module, exports, __webpack_require__) { + + + + var textWidthCache = {}; + var textWidthCacheCounter = 0; + var TEXT_CACHE_MAX = 5000; + + var util = __webpack_require__(3); + var BoundingRect = __webpack_require__(15); + + function getTextWidth(text, textFont) { + var key = text + ':' + textFont; + if (textWidthCache[key]) { + return textWidthCache[key]; + } + + var textLines = (text + '').split('\n'); + var width = 0; + + for (var i = 0, l = textLines.length; i < l; i++) { + // measureText 可以被覆盖以兼容不支持 Canvas 的环境 + width = Math.max(textContain.measureText(textLines[i], textFont).width, width); + } + + if (textWidthCacheCounter > TEXT_CACHE_MAX) { + textWidthCacheCounter = 0; + textWidthCache = {}; + } + textWidthCacheCounter++; + textWidthCache[key] = width; + + return width; + } + + function getTextRect(text, textFont, textAlign, textBaseline) { + var textLineLen = ((text || '') + '').split('\n').length; + + var width = getTextWidth(text, textFont); + // FIXME 高度计算比较粗暴 + var lineHeight = getTextWidth('国', textFont); + var height = textLineLen * lineHeight; + + var rect = new BoundingRect(0, 0, width, height); + // Text has a special line height property + rect.lineHeight = lineHeight; + + switch (textBaseline) { + case 'bottom': + case 'alphabetic': + rect.y -= lineHeight; + break; + case 'middle': + rect.y -= lineHeight / 2; + break; + // case 'hanging': + // case 'top': + } + + // FIXME Right to left language + switch (textAlign) { + case 'end': + case 'right': + rect.x -= rect.width; + break; + case 'center': + rect.x -= rect.width / 2; + break; + // case 'start': + // case 'left': + } + + return rect; + } + + function adjustTextPositionOnRect(textPosition, rect, textRect, distance) { + + var x = rect.x; + var y = rect.y; + + var height = rect.height; + var width = rect.width; + + var textHeight = textRect.height; + + var halfHeight = height / 2 - textHeight / 2; + + var textAlign = 'left'; + + switch (textPosition) { + case 'left': + x -= distance; + y += halfHeight; + textAlign = 'right'; + break; + case 'right': + x += distance + width; + y += halfHeight; + textAlign = 'left'; + break; + case 'top': + x += width / 2; + y -= distance + textHeight; + textAlign = 'center'; + break; + case 'bottom': + x += width / 2; + y += height + distance; + textAlign = 'center'; + break; + case 'inside': + x += width / 2; + y += halfHeight; + textAlign = 'center'; + break; + case 'insideLeft': + x += distance; + y += halfHeight; + textAlign = 'left'; + break; + case 'insideRight': + x += width - distance; + y += halfHeight; + textAlign = 'right'; + break; + case 'insideTop': + x += width / 2; + y += distance; + textAlign = 'center'; + break; + case 'insideBottom': + x += width / 2; + y += height - textHeight - distance; + textAlign = 'center'; + break; + case 'insideTopLeft': + x += distance; + y += distance; + textAlign = 'left'; + break; + case 'insideTopRight': + x += width - distance; + y += distance; + textAlign = 'right'; + break; + case 'insideBottomLeft': + x += distance; + y += height - textHeight - distance; + break; + case 'insideBottomRight': + x += width - distance; + y += height - textHeight - distance; + textAlign = 'right'; + break; + } + + return { + x: x, + y: y, + textAlign: textAlign, + textBaseline: 'top' + }; + } + + /** + * Show ellipsis if overflow. + * + * @param {string} text + * @param {string} textFont + * @param {string} containerWidth + * @param {Object} [options] + * @param {number} [options.ellipsis='...'] + * @param {number} [options.maxIterations=3] + * @param {number} [options.minCharacters=3] + * @return {string} + */ + function textEllipsis(text, textFont, containerWidth, options) { + if (!containerWidth) { + return ''; + } + + options = util.defaults({ + ellipsis: '...', + minCharacters: 3, + maxIterations: 3, + cnCharWidth: getTextWidth('国', textFont), + // FIXME + // 未考虑非等宽字体 + ascCharWidth: getTextWidth('a', textFont) + }, options, true); + + containerWidth -= getTextWidth(options.ellipsis); + + var textLines = (text + '').split('\n'); + + for (var i = 0, len = textLines.length; i < len; i++) { + textLines[i] = textLineTruncate( + textLines[i], textFont, containerWidth, options + ); + } + + return textLines.join('\n'); + } + + function textLineTruncate(text, textFont, containerWidth, options) { + // FIXME + // 粗糙得写的,尚未考虑性能和各种语言、字体的效果。 + for (var i = 0;; i++) { + var lineWidth = getTextWidth(text, textFont); + + if (lineWidth < containerWidth || i >= options.maxIterations) { + text += options.ellipsis; + break; + } + + var subLength = i === 0 + ? estimateLength(text, containerWidth, options) + : Math.floor(text.length * containerWidth / lineWidth); + + if (subLength < options.minCharacters) { + text = ''; + break; + } + + text = text.substr(0, subLength); + } + + return text; + } + + function estimateLength(text, containerWidth, options) { + var width = 0; + var i = 0; + for (var len = text.length; i < len && width < containerWidth; i++) { + var charCode = text.charCodeAt(i); + width += (0 <= charCode && charCode <= 127) + ? options.ascCharWidth : options.cnCharWidth; + } + return i; + } + + var textContain = { + + getWidth: getTextWidth, + + getBoundingRect: getTextRect, + + adjustTextPositionOnRect: adjustTextPositionOnRect, + + ellipsis: textEllipsis, + + measureText: function (text, textFont) { + var ctx = util.getContext(); + ctx.font = textFont; + return ctx.measureText(text); + } + }; + + module.exports = textContain; + + +/***/ }, +/* 15 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * @module echarts/core/BoundingRect + */ + + + var vec2 = __webpack_require__(16); + var matrix = __webpack_require__(17); + + var v2ApplyTransform = vec2.applyTransform; + var mathMin = Math.min; + var mathAbs = Math.abs; + var mathMax = Math.max; + /** + * @alias module:echarts/core/BoundingRect + */ + function BoundingRect(x, y, width, height) { + /** + * @type {number} + */ + this.x = x; + /** + * @type {number} + */ + this.y = y; + /** + * @type {number} + */ + this.width = width; + /** + * @type {number} + */ + this.height = height; + } + + BoundingRect.prototype = { + + constructor: BoundingRect, + + /** + * @param {module:echarts/core/BoundingRect} other + */ + union: function (other) { + var x = mathMin(other.x, this.x); + var y = mathMin(other.y, this.y); + + this.width = mathMax( + other.x + other.width, + this.x + this.width + ) - x; + this.height = mathMax( + other.y + other.height, + this.y + this.height + ) - y; + this.x = x; + this.y = y; + }, + + /** + * @param {Array.} m + * @methods + */ + applyTransform: (function () { + var min = []; + var max = []; + return function (m) { + // In case usage like this + // el.getBoundingRect().applyTransform(el.transform) + // And element has no transform + if (!m) { + return; + } + min[0] = this.x; + min[1] = this.y; + max[0] = this.x + this.width; + max[1] = this.y + this.height; + + v2ApplyTransform(min, min, m); + v2ApplyTransform(max, max, m); + + this.x = mathMin(min[0], max[0]); + this.y = mathMin(min[1], max[1]); + this.width = mathAbs(max[0] - min[0]); + this.height = mathAbs(max[1] - min[1]); + }; + })(), + + /** + * Calculate matrix of transforming from self to target rect + * @param {module:zrender/core/BoundingRect} b + * @return {Array.} + */ + calculateTransform: function (b) { + var a = this; + var sx = b.width / a.width; + var sy = b.height / a.height; + + var m = matrix.create(); + + // 矩阵右乘 + matrix.translate(m, m, [-a.x, -a.y]); + matrix.scale(m, m, [sx, sy]); + matrix.translate(m, m, [b.x, b.y]); + + return m; + }, + + /** + * @param {(module:echarts/core/BoundingRect|Object)} b + * @return {boolean} + */ + intersect: function (b) { + var a = this; + var ax0 = a.x; + var ax1 = a.x + a.width; + var ay0 = a.y; + var ay1 = a.y + a.height; + + var bx0 = b.x; + var bx1 = b.x + b.width; + var by0 = b.y; + var by1 = b.y + b.height; + + return ! (ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0); + }, + + contain: function (x, y) { + var rect = this; + return x >= rect.x + && x <= (rect.x + rect.width) + && y >= rect.y + && y <= (rect.y + rect.height); + }, + + /** + * @return {module:echarts/core/BoundingRect} + */ + clone: function () { + return new BoundingRect(this.x, this.y, this.width, this.height); + }, + + /** + * Copy from another rect + */ + copy: function (other) { + this.x = other.x; + this.y = other.y; + this.width = other.width; + this.height = other.height; + } + }; + + module.exports = BoundingRect; + + +/***/ }, +/* 16 */ +/***/ function(module, exports) { + + + var ArrayCtor = typeof Float32Array === 'undefined' + ? Array + : Float32Array; + + /** + * @typedef {Float32Array|Array.} Vector2 + */ + /** + * 二维向量类 + * @exports zrender/tool/vector + */ + var vector = { + /** + * 创建一个向量 + * @param {number} [x=0] + * @param {number} [y=0] + * @return {Vector2} + */ + create: function (x, y) { + var out = new ArrayCtor(2); + out[0] = x || 0; + out[1] = y || 0; + return out; + }, + + /** + * 复制向量数据 + * @param {Vector2} out + * @param {Vector2} v + * @return {Vector2} + */ + copy: function (out, v) { + out[0] = v[0]; + out[1] = v[1]; + return out; + }, + + /** + * 克隆一个向量 + * @param {Vector2} v + * @return {Vector2} + */ + clone: function (v) { + var out = new ArrayCtor(2); + out[0] = v[0]; + out[1] = v[1]; + return out; + }, + + /** + * 设置向量的两个项 + * @param {Vector2} out + * @param {number} a + * @param {number} b + * @return {Vector2} 结果 + */ + set: function (out, a, b) { + out[0] = a; + out[1] = b; + return out; + }, + + /** + * 向量相加 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + add: function (out, v1, v2) { + out[0] = v1[0] + v2[0]; + out[1] = v1[1] + v2[1]; + return out; + }, + + /** + * 向量缩放后相加 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + * @param {number} a + */ + scaleAndAdd: function (out, v1, v2, a) { + out[0] = v1[0] + v2[0] * a; + out[1] = v1[1] + v2[1] * a; + return out; + }, + + /** + * 向量相减 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + sub: function (out, v1, v2) { + out[0] = v1[0] - v2[0]; + out[1] = v1[1] - v2[1]; + return out; + }, + + /** + * 向量长度 + * @param {Vector2} v + * @return {number} + */ + len: function (v) { + return Math.sqrt(this.lenSquare(v)); + }, + + /** + * 向量长度平方 + * @param {Vector2} v + * @return {number} + */ + lenSquare: function (v) { + return v[0] * v[0] + v[1] * v[1]; + }, + + /** + * 向量乘法 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + mul: function (out, v1, v2) { + out[0] = v1[0] * v2[0]; + out[1] = v1[1] * v2[1]; + return out; + }, + + /** + * 向量除法 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + div: function (out, v1, v2) { + out[0] = v1[0] / v2[0]; + out[1] = v1[1] / v2[1]; + return out; + }, + + /** + * 向量点乘 + * @param {Vector2} v1 + * @param {Vector2} v2 + * @return {number} + */ + dot: function (v1, v2) { + return v1[0] * v2[0] + v1[1] * v2[1]; + }, + + /** + * 向量缩放 + * @param {Vector2} out + * @param {Vector2} v + * @param {number} s + */ + scale: function (out, v, s) { + out[0] = v[0] * s; + out[1] = v[1] * s; + return out; + }, + + /** + * 向量归一化 + * @param {Vector2} out + * @param {Vector2} v + */ + normalize: function (out, v) { + var d = vector.len(v); + if (d === 0) { + out[0] = 0; + out[1] = 0; + } + else { + out[0] = v[0] / d; + out[1] = v[1] / d; + } + return out; + }, + + /** + * 计算向量间距离 + * @param {Vector2} v1 + * @param {Vector2} v2 + * @return {number} + */ + distance: function (v1, v2) { + return Math.sqrt( + (v1[0] - v2[0]) * (v1[0] - v2[0]) + + (v1[1] - v2[1]) * (v1[1] - v2[1]) + ); + }, + + /** + * 向量距离平方 + * @param {Vector2} v1 + * @param {Vector2} v2 + * @return {number} + */ + distanceSquare: function (v1, v2) { + return (v1[0] - v2[0]) * (v1[0] - v2[0]) + + (v1[1] - v2[1]) * (v1[1] - v2[1]); + }, + + /** + * 求负向量 + * @param {Vector2} out + * @param {Vector2} v + */ + negate: function (out, v) { + out[0] = -v[0]; + out[1] = -v[1]; + return out; + }, + + /** + * 插值两个点 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + * @param {number} t + */ + lerp: function (out, v1, v2, t) { + out[0] = v1[0] + t * (v2[0] - v1[0]); + out[1] = v1[1] + t * (v2[1] - v1[1]); + return out; + }, + + /** + * 矩阵左乘向量 + * @param {Vector2} out + * @param {Vector2} v + * @param {Vector2} m + */ + applyTransform: function (out, v, m) { + var x = v[0]; + var y = v[1]; + out[0] = m[0] * x + m[2] * y + m[4]; + out[1] = m[1] * x + m[3] * y + m[5]; + return out; + }, + /** + * 求两个向量最小值 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + min: function (out, v1, v2) { + out[0] = Math.min(v1[0], v2[0]); + out[1] = Math.min(v1[1], v2[1]); + return out; + }, + /** + * 求两个向量最大值 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + max: function (out, v1, v2) { + out[0] = Math.max(v1[0], v2[0]); + out[1] = Math.max(v1[1], v2[1]); + return out; + } + }; + + vector.length = vector.len; + vector.lengthSquare = vector.lenSquare; + vector.dist = vector.distance; + vector.distSquare = vector.distanceSquare; + + module.exports = vector; + + + +/***/ }, +/* 17 */ +/***/ function(module, exports) { + + + var ArrayCtor = typeof Float32Array === 'undefined' + ? Array + : Float32Array; + /** + * 3x2矩阵操作类 + * @exports zrender/tool/matrix + */ + var matrix = { + /** + * 创建一个单位矩阵 + * @return {Float32Array|Array.} + */ + create : function() { + var out = new ArrayCtor(6); + matrix.identity(out); + + return out; + }, + /** + * 设置矩阵为单位矩阵 + * @param {Float32Array|Array.} out + */ + identity : function(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = 0; + out[5] = 0; + return out; + }, + /** + * 复制矩阵 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} m + */ + copy: function(out, m) { + out[0] = m[0]; + out[1] = m[1]; + out[2] = m[2]; + out[3] = m[3]; + out[4] = m[4]; + out[5] = m[5]; + return out; + }, + /** + * 矩阵相乘 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} m1 + * @param {Float32Array|Array.} m2 + */ + mul : function (out, m1, m2) { + // Consider matrix.mul(m, m2, m); + // where out is the same as m2. + // So use temp variable to escape error. + var out0 = m1[0] * m2[0] + m1[2] * m2[1]; + var out1 = m1[1] * m2[0] + m1[3] * m2[1]; + var out2 = m1[0] * m2[2] + m1[2] * m2[3]; + var out3 = m1[1] * m2[2] + m1[3] * m2[3]; + var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4]; + var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5]; + out[0] = out0; + out[1] = out1; + out[2] = out2; + out[3] = out3; + out[4] = out4; + out[5] = out5; + return out; + }, + /** + * 平移变换 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + * @param {Float32Array|Array.} v + */ + translate : function(out, a, v) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4] + v[0]; + out[5] = a[5] + v[1]; + return out; + }, + /** + * 旋转变换 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + * @param {number} rad + */ + rotate : function(out, a, rad) { + var aa = a[0]; + var ac = a[2]; + var atx = a[4]; + var ab = a[1]; + var ad = a[3]; + var aty = a[5]; + var st = Math.sin(rad); + var ct = Math.cos(rad); + + out[0] = aa * ct + ab * st; + out[1] = -aa * st + ab * ct; + out[2] = ac * ct + ad * st; + out[3] = -ac * st + ct * ad; + out[4] = ct * atx + st * aty; + out[5] = ct * aty - st * atx; + return out; + }, + /** + * 缩放变换 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + * @param {Float32Array|Array.} v + */ + scale : function(out, a, v) { + var vx = v[0]; + var vy = v[1]; + out[0] = a[0] * vx; + out[1] = a[1] * vy; + out[2] = a[2] * vx; + out[3] = a[3] * vy; + out[4] = a[4] * vx; + out[5] = a[5] * vy; + return out; + }, + /** + * 求逆矩阵 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + */ + invert : function(out, a) { + + var aa = a[0]; + var ac = a[2]; + var atx = a[4]; + var ab = a[1]; + var ad = a[3]; + var aty = a[5]; + + var det = aa * ad - ab * ac; + if (!det) { + return null; + } + det = 1.0 / det; + + out[0] = ad * det; + out[1] = -ab * det; + out[2] = -ac * det; + out[3] = aa * det; + out[4] = (ac * aty - ad * atx) * det; + out[5] = (ab * atx - aa * aty) * det; + return out; + } + }; + + module.exports = matrix; + + + +/***/ }, +/* 18 */ +/***/ function(module, exports, __webpack_require__) { + + + module.exports = { + getItemStyle: __webpack_require__(11)( + [ + ['fill', 'color'], + ['stroke', 'borderColor'], + ['lineWidth', 'borderWidth'], + ['opacity'], + ['shadowBlur'], + ['shadowOffsetX'], + ['shadowOffsetY'], + ['shadowColor'] + ] + ) + }; + + +/***/ }, +/* 19 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Component model + * + * @module echarts/model/Component + */ + + + var Model = __webpack_require__(8); + var zrUtil = __webpack_require__(3); + var arrayPush = Array.prototype.push; + var componentUtil = __webpack_require__(20); + var clazzUtil = __webpack_require__(9); + var layout = __webpack_require__(21); + + /** + * @alias module:echarts/model/Component + * @constructor + * @param {Object} option + * @param {module:echarts/model/Model} parentModel + * @param {module:echarts/model/Model} ecModel + */ + var ComponentModel = Model.extend({ + + type: 'component', + + /** + * @readOnly + * @type {string} + */ + id: '', + + /** + * @readOnly + */ + name: '', + + /** + * @readOnly + * @type {string} + */ + mainType: '', + + /** + * @readOnly + * @type {string} + */ + subType: '', + + /** + * @readOnly + * @type {number} + */ + componentIndex: 0, + + /** + * @type {Object} + * @protected + */ + defaultOption: null, + + /** + * @type {module:echarts/model/Global} + * @readOnly + */ + ecModel: null, + + /** + * key: componentType + * value: Component model list, can not be null. + * @type {Object.>} + * @readOnly + */ + dependentModels: [], + + /** + * @type {string} + * @readOnly + */ + uid: null, + + /** + * Support merge layout params. + * Only support 'box' now (left/right/top/bottom/width/height). + * @type {string|Object} Object can be {ignoreSize: true} + * @readOnly + */ + layoutMode: null, + + + init: function (option, parentModel, ecModel, extraOpt) { + this.mergeDefaultAndTheme(this.option, this.ecModel); + }, + + mergeDefaultAndTheme: function (option, ecModel) { + var layoutMode = this.layoutMode; + var inputPositionParams = layoutMode + ? layout.getLayoutParams(option) : {}; + + var themeModel = ecModel.getTheme(); + zrUtil.merge(option, themeModel.get(this.mainType)); + zrUtil.merge(option, this.getDefaultOption()); + + if (layoutMode) { + layout.mergeLayoutParam(option, inputPositionParams, layoutMode); + } + }, + + mergeOption: function (option) { + zrUtil.merge(this.option, option, true); + + var layoutMode = this.layoutMode; + if (layoutMode) { + layout.mergeLayoutParam(this.option, option, layoutMode); + } + }, + + // Hooker after init or mergeOption + optionUpdated: function (ecModel) {}, + + getDefaultOption: function () { + if (!this.hasOwnProperty('__defaultOption')) { + var optList = []; + var Class = this.constructor; + while (Class) { + var opt = Class.prototype.defaultOption; + opt && optList.push(opt); + Class = Class.superClass; + } + + var defaultOption = {}; + for (var i = optList.length - 1; i >= 0; i--) { + defaultOption = zrUtil.merge(defaultOption, optList[i], true); + } + this.__defaultOption = defaultOption; + } + return this.__defaultOption; + } + + }); + + // Reset ComponentModel.extend, add preConstruct. + clazzUtil.enableClassExtend( + ComponentModel, + function (option, parentModel, ecModel, extraOpt) { + // Set dependentModels, componentIndex, name, id, mainType, subType. + zrUtil.extend(this, extraOpt); + + this.uid = componentUtil.getUID('componentModel'); + + this.setReadOnly([ + 'type', 'id', 'uid', 'name', 'mainType', 'subType', + 'dependentModels', 'componentIndex' + ]); + } + ); + + // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. + clazzUtil.enableClassManagement( + ComponentModel, {registerWhenExtend: true} + ); + componentUtil.enableSubTypeDefaulter(ComponentModel); + + // Add capability of ComponentModel.topologicalTravel. + componentUtil.enableTopologicalTravel(ComponentModel, getDependencies); + + function getDependencies(componentType) { + var deps = []; + zrUtil.each(ComponentModel.getClassesByMainType(componentType), function (Clazz) { + arrayPush.apply(deps, Clazz.prototype.dependencies || []); + }); + // Ensure main type + return zrUtil.map(deps, function (type) { + return clazzUtil.parseClassType(type).main; + }); + } + + zrUtil.mixin(ComponentModel, __webpack_require__(22)); + + module.exports = ComponentModel; + + +/***/ }, +/* 20 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var clazz = __webpack_require__(9); + + var parseClassType = clazz.parseClassType; + + var base = 0; + + var componentUtil = {}; + + var DELIMITER = '_'; + + /** + * @public + * @param {string} type + * @return {string} + */ + componentUtil.getUID = function (type) { + // Considering the case of crossing js context, + // use Math.random to make id as unique as possible. + return [(type || ''), base++, Math.random()].join(DELIMITER); + }; + + /** + * @inner + */ + componentUtil.enableSubTypeDefaulter = function (entity) { + + var subTypeDefaulters = {}; + + entity.registerSubTypeDefaulter = function (componentType, defaulter) { + componentType = parseClassType(componentType); + subTypeDefaulters[componentType.main] = defaulter; + }; + + entity.determineSubType = function (componentType, option) { + var type = option.type; + if (!type) { + var componentTypeMain = parseClassType(componentType).main; + if (entity.hasSubTypes(componentType) && subTypeDefaulters[componentTypeMain]) { + type = subTypeDefaulters[componentTypeMain](option); + } + } + return type; + }; + + return entity; + }; + + /** + * Topological travel on Activity Network (Activity On Vertices). + * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis']. + * + * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology. + * + * If there is circle dependencey, Error will be thrown. + * + */ + componentUtil.enableTopologicalTravel = function (entity, dependencyGetter) { + + /** + * @public + * @param {Array.} targetNameList Target Component type list. + * Can be ['aa', 'bb', 'aa.xx'] + * @param {Array.} fullNameList By which we can build dependency graph. + * @param {Function} callback Params: componentType, dependencies. + * @param {Object} context Scope of callback. + */ + entity.topologicalTravel = function (targetNameList, fullNameList, callback, context) { + if (!targetNameList.length) { + return; + } + + var result = makeDepndencyGraph(fullNameList); + var graph = result.graph; + var stack = result.noEntryList; + + var targetNameSet = {}; + zrUtil.each(targetNameList, function (name) { + targetNameSet[name] = true; + }); + + while (stack.length) { + var currComponentType = stack.pop(); + var currVertex = graph[currComponentType]; + var isInTargetNameSet = !!targetNameSet[currComponentType]; + if (isInTargetNameSet) { + callback.call(context, currComponentType, currVertex.originalDeps.slice()); + delete targetNameSet[currComponentType]; + } + zrUtil.each( + currVertex.successor, + isInTargetNameSet ? removeEdgeAndAdd : removeEdge + ); + } + + zrUtil.each(targetNameSet, function () { + throw new Error('Circle dependency may exists'); + }); + + function removeEdge(succComponentType) { + graph[succComponentType].entryCount--; + if (graph[succComponentType].entryCount === 0) { + stack.push(succComponentType); + } + } + + // Consider this case: legend depends on series, and we call + // chart.setOption({series: [...]}), where only series is in option. + // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will + // not be called, but only sereis.mergeOption is called. Thus legend + // have no chance to update its local record about series (like which + // name of series is available in legend). + function removeEdgeAndAdd(succComponentType) { + targetNameSet[succComponentType] = true; + removeEdge(succComponentType); + } + }; + + /** + * DepndencyGraph: {Object} + * key: conponentType, + * value: { + * successor: [conponentTypes...], + * originalDeps: [conponentTypes...], + * entryCount: {number} + * } + */ + function makeDepndencyGraph(fullNameList) { + var graph = {}; + var noEntryList = []; + + zrUtil.each(fullNameList, function (name) { + + var thisItem = createDependencyGraphItem(graph, name); + var originalDeps = thisItem.originalDeps = dependencyGetter(name); + + var availableDeps = getAvailableDependencies(originalDeps, fullNameList); + thisItem.entryCount = availableDeps.length; + if (thisItem.entryCount === 0) { + noEntryList.push(name); + } + + zrUtil.each(availableDeps, function (dependentName) { + if (zrUtil.indexOf(thisItem.predecessor, dependentName) < 0) { + thisItem.predecessor.push(dependentName); + } + var thatItem = createDependencyGraphItem(graph, dependentName); + if (zrUtil.indexOf(thatItem.successor, dependentName) < 0) { + thatItem.successor.push(name); + } + }); + }); + + return {graph: graph, noEntryList: noEntryList}; + } + + function createDependencyGraphItem(graph, name) { + if (!graph[name]) { + graph[name] = {predecessor: [], successor: []}; + } + return graph[name]; + } + + function getAvailableDependencies(originalDeps, fullNameList) { + var availableDeps = []; + zrUtil.each(originalDeps, function (dep) { + zrUtil.indexOf(fullNameList, dep) >= 0 && availableDeps.push(dep); + }); + return availableDeps; + } + }; + + module.exports = componentUtil; + + +/***/ }, +/* 21 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // Layout helpers for each component positioning + + + var zrUtil = __webpack_require__(3); + var BoundingRect = __webpack_require__(15); + var numberUtil = __webpack_require__(7); + var formatUtil = __webpack_require__(6); + var parsePercent = numberUtil.parsePercent; + var each = zrUtil.each; + + var layout = {}; + + var LOCATION_PARAMS = ['left', 'right', 'top', 'bottom', 'width', 'height']; + + function boxLayout(orient, group, gap, maxWidth, maxHeight) { + var x = 0; + var y = 0; + if (maxWidth == null) { + maxWidth = Infinity; + } + if (maxHeight == null) { + maxHeight = Infinity; + } + var currentLineMaxSize = 0; + group.eachChild(function (child, idx) { + var position = child.position; + var rect = child.getBoundingRect(); + var nextChild = group.childAt(idx + 1); + var nextChildRect = nextChild && nextChild.getBoundingRect(); + var nextX; + var nextY; + if (orient === 'horizontal') { + var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0); + nextX = x + moveX; + // Wrap when width exceeds maxWidth or meet a `newline` group + if (nextX > maxWidth || child.newline) { + x = 0; + nextX = moveX; + y += currentLineMaxSize + gap; + currentLineMaxSize = rect.height; + } + else { + currentLineMaxSize = Math.max(currentLineMaxSize, rect.height); + } + } + else { + var moveY = rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0); + nextY = y + moveY; + // Wrap when width exceeds maxHeight or meet a `newline` group + if (nextY > maxHeight || child.newline) { + x += currentLineMaxSize + gap; + y = 0; + nextY = moveY; + currentLineMaxSize = rect.width; + } + else { + currentLineMaxSize = Math.max(currentLineMaxSize, rect.width); + } + } + + if (child.newline) { + return; + } + + position[0] = x; + position[1] = y; + + orient === 'horizontal' + ? (x = nextX + gap) + : (y = nextY + gap); + }); + } + + /** + * VBox or HBox layouting + * @param {string} orient + * @param {module:zrender/container/Group} group + * @param {number} gap + * @param {number} [width=Infinity] + * @param {number} [height=Infinity] + */ + layout.box = boxLayout; + + /** + * VBox layouting + * @param {module:zrender/container/Group} group + * @param {number} gap + * @param {number} [width=Infinity] + * @param {number} [height=Infinity] + */ + layout.vbox = zrUtil.curry(boxLayout, 'vertical'); + + /** + * HBox layouting + * @param {module:zrender/container/Group} group + * @param {number} gap + * @param {number} [width=Infinity] + * @param {number} [height=Infinity] + */ + layout.hbox = zrUtil.curry(boxLayout, 'horizontal'); + + /** + * If x or x2 is not specified or 'center' 'left' 'right', + * the width would be as long as possible. + * If y or y2 is not specified or 'middle' 'top' 'bottom', + * the height would be as long as possible. + * + * @param {Object} positionInfo + * @param {number|string} [positionInfo.x] + * @param {number|string} [positionInfo.y] + * @param {number|string} [positionInfo.x2] + * @param {number|string} [positionInfo.y2] + * @param {Object} containerRect + * @param {string|number} margin + * @return {Object} {width, height} + */ + layout.getAvailableSize = function (positionInfo, containerRect, margin) { + var containerWidth = containerRect.width; + var containerHeight = containerRect.height; + + var x = parsePercent(positionInfo.x, containerWidth); + var y = parsePercent(positionInfo.y, containerHeight); + var x2 = parsePercent(positionInfo.x2, containerWidth); + var y2 = parsePercent(positionInfo.y2, containerHeight); + + (isNaN(x) || isNaN(parseFloat(positionInfo.x))) && (x = 0); + (isNaN(x2) || isNaN(parseFloat(positionInfo.x2))) && (x2 = containerWidth); + (isNaN(y) || isNaN(parseFloat(positionInfo.y))) && (y = 0); + (isNaN(y2) || isNaN(parseFloat(positionInfo.y2))) && (y2 = containerHeight); + + margin = formatUtil.normalizeCssArray(margin || 0); + + return { + width: Math.max(x2 - x - margin[1] - margin[3], 0), + height: Math.max(y2 - y - margin[0] - margin[2], 0) + }; + }; + + /** + * Parse position info. + * + * @param {Object} positionInfo + * @param {number|string} [positionInfo.left] + * @param {number|string} [positionInfo.top] + * @param {number|string} [positionInfo.right] + * @param {number|string} [positionInfo.bottom] + * @param {number|string} [positionInfo.width] + * @param {number|string} [positionInfo.height] + * @param {number|string} [positionInfo.aspect] Aspect is width / height + * @param {Object} containerRect + * @param {string|number} [margin] + * + * @return {module:zrender/core/BoundingRect} + */ + layout.getLayoutRect = function ( + positionInfo, containerRect, margin + ) { + margin = formatUtil.normalizeCssArray(margin || 0); + + var containerWidth = containerRect.width; + var containerHeight = containerRect.height; + + var left = parsePercent(positionInfo.left, containerWidth); + var top = parsePercent(positionInfo.top, containerHeight); + var right = parsePercent(positionInfo.right, containerWidth); + var bottom = parsePercent(positionInfo.bottom, containerHeight); + var width = parsePercent(positionInfo.width, containerWidth); + var height = parsePercent(positionInfo.height, containerHeight); + + var verticalMargin = margin[2] + margin[0]; + var horizontalMargin = margin[1] + margin[3]; + var aspect = positionInfo.aspect; + + // If width is not specified, calculate width from left and right + if (isNaN(width)) { + width = containerWidth - right - horizontalMargin - left; + } + if (isNaN(height)) { + height = containerHeight - bottom - verticalMargin - top; + } + + // If width and height are not given + // 1. Graph should not exceeds the container + // 2. Aspect must be keeped + // 3. Graph should take the space as more as possible + if (isNaN(width) && isNaN(height)) { + if (aspect > containerWidth / containerHeight) { + width = containerWidth * 0.8; + } + else { + height = containerHeight * 0.8; + } + } + + if (aspect != null) { + // Calculate width or height with given aspect + if (isNaN(width)) { + width = aspect * height; + } + if (isNaN(height)) { + height = width / aspect; + } + } + + // If left is not specified, calculate left from right and width + if (isNaN(left)) { + left = containerWidth - right - width - horizontalMargin; + } + if (isNaN(top)) { + top = containerHeight - bottom - height - verticalMargin; + } + + // Align left and top + switch (positionInfo.left || positionInfo.right) { + case 'center': + left = containerWidth / 2 - width / 2 - margin[3]; + break; + case 'right': + left = containerWidth - width - horizontalMargin; + break; + } + switch (positionInfo.top || positionInfo.bottom) { + case 'middle': + case 'center': + top = containerHeight / 2 - height / 2 - margin[0]; + break; + case 'bottom': + top = containerHeight - height - verticalMargin; + break; + } + // If something is wrong and left, top, width, height are calculated as NaN + left = left || 0; + top = top || 0; + if (isNaN(width)) { + // Width may be NaN if only one value is given except width + width = containerWidth - left - (right || 0); + } + if (isNaN(height)) { + // Height may be NaN if only one value is given except height + height = containerHeight - top - (bottom || 0); + } + + var rect = new BoundingRect(left + margin[3], top + margin[0], width, height); + rect.margin = margin; + return rect; + }; + + /** + * Position group of component in viewport + * Group position is specified by either + * {left, top}, {right, bottom} + * If all properties exists, right and bottom will be igonred. + * + * @param {module:zrender/container/Group} group + * @param {Object} positionInfo + * @param {number|string} [positionInfo.left] + * @param {number|string} [positionInfo.top] + * @param {number|string} [positionInfo.right] + * @param {number|string} [positionInfo.bottom] + * @param {Object} containerRect + * @param {string|number} margin + */ + layout.positionGroup = function ( + group, positionInfo, containerRect, margin + ) { + var groupRect = group.getBoundingRect(); + + positionInfo = zrUtil.extend(zrUtil.clone(positionInfo), { + width: groupRect.width, + height: groupRect.height + }); + + positionInfo = layout.getLayoutRect( + positionInfo, containerRect, margin + ); + + group.position = [ + positionInfo.x - groupRect.x, + positionInfo.y - groupRect.y + ]; + }; + + /** + * Consider Case: + * When defulat option has {left: 0, width: 100}, and we set {right: 0} + * through setOption or media query, using normal zrUtil.merge will cause + * {right: 0} does not take effect. + * + * @example + * ComponentModel.extend({ + * init: function () { + * ... + * var inputPositionParams = layout.getLayoutParams(option); + * this.mergeOption(inputPositionParams); + * }, + * mergeOption: function (newOption) { + * newOption && zrUtil.merge(thisOption, newOption, true); + * layout.mergeLayoutParam(thisOption, newOption); + * } + * }); + * + * @param {Object} targetOption + * @param {Object} newOption + * @param {Object|string} [opt] + * @param {boolean} [opt.ignoreSize=false] Some component must has width and height. + */ + layout.mergeLayoutParam = function (targetOption, newOption, opt) { + !zrUtil.isObject(opt) && (opt = {}); + var hNames = ['width', 'left', 'right']; // Order by priority. + var vNames = ['height', 'top', 'bottom']; // Order by priority. + var hResult = merge(hNames); + var vResult = merge(vNames); + + copy(hNames, targetOption, hResult); + copy(vNames, targetOption, vResult); + + function merge(names) { + var newParams = {}; + var newValueCount = 0; + var merged = {}; + var mergedValueCount = 0; + var enoughParamNumber = opt.ignoreSize ? 1 : 2; + + each(names, function (name) { + merged[name] = targetOption[name]; + }); + each(names, function (name) { + // Consider case: newOption.width is null, which is + // set by user for removing width setting. + hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]); + hasValue(newParams, name) && newValueCount++; + hasValue(merged, name) && mergedValueCount++; + }); + + // Case: newOption: {width: ..., right: ...}, + // or targetOption: {right: ...} and newOption: {width: ...}, + // There is no conflict when merged only has params count + // little than enoughParamNumber. + if (mergedValueCount === enoughParamNumber || !newValueCount) { + return merged; + } + // Case: newOption: {width: ..., right: ...}, + // Than we can make sure user only want those two, and ignore + // all origin params in targetOption. + else if (newValueCount >= enoughParamNumber) { + return newParams; + } + else { + // Chose another param from targetOption by priority. + // When 'ignoreSize', enoughParamNumber is 1 and those will not happen. + for (var i = 0; i < names.length; i++) { + var name = names[i]; + if (!hasProp(newParams, name) && hasProp(targetOption, name)) { + newParams[name] = targetOption[name]; + break; + } + } + return newParams; + } + } + + function hasProp(obj, name) { + return obj.hasOwnProperty(name); + } + + function hasValue(obj, name) { + return obj[name] != null && obj[name] !== 'auto'; + } + + function copy(names, target, source) { + each(names, function (name) { + target[name] = source[name]; + }); + } + }; + + /** + * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object. + * @param {Object} source + * @return {Object} Result contains those props. + */ + layout.getLayoutParams = function (source) { + return layout.copyLayoutParams({}, source); + }; + + /** + * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object. + * @param {Object} source + * @return {Object} Result contains those props. + */ + layout.copyLayoutParams = function (target, source) { + source && target && each(LOCATION_PARAMS, function (name) { + source.hasOwnProperty(name) && (target[name] = source[name]); + }); + return target; + }; + + module.exports = layout; + + +/***/ }, +/* 22 */ +/***/ function(module, exports) { + + + + module.exports = { + getBoxLayoutParams: function () { + return { + left: this.get('left'), + top: this.get('top'), + right: this.get('right'), + bottom: this.get('bottom'), + width: this.get('width'), + height: this.get('height') + }; + } + }; + + +/***/ }, +/* 23 */ +/***/ function(module, exports) { + + + var platform = ''; + // Navigator not exists in node + if (typeof navigator !== 'undefined') { + platform = navigator.platform || ''; + } + module.exports = { + // 全图默认背景 + // backgroundColor: 'rgba(0,0,0,0)', + + // https://dribbble.com/shots/1065960-Infographic-Pie-chart-visualization + // color: ['#5793f3', '#d14a61', '#fd9c35', '#675bba', '#fec42c', '#dd4444', '#d4df5a', '#cd4870'], + // 浅色 + // color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'], + // color: ['#cc5664', '#9bd6ec', '#ea946e', '#8acaaa', '#f1ec64', '#ee8686', '#a48dc1', '#5da6bc', '#b9dcae'], + // 深色 + color: ['#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83', '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'], + + // 默认需要 Grid 配置项 + grid: {}, + // 主题,主题 + textStyle: { + // color: '#000', + // decoration: 'none', + // PENDING + fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif', + // fontFamily: 'Arial, Verdana, sans-serif', + fontSize: 12, + fontStyle: 'normal', + fontWeight: 'normal' + }, + // 主题,默认标志图形类型列表 + // symbolList: [ + // 'circle', 'rectangle', 'triangle', 'diamond', + // 'emptyCircle', 'emptyRectangle', 'emptyTriangle', 'emptyDiamond' + // ], + animation: true, // 过渡动画是否开启 + animationThreshold: 2000, // 动画元素阀值,产生的图形原素超过2000不出动画 + animationDuration: 1000, // 过渡动画参数:进入 + animationDurationUpdate: 300, // 过渡动画参数:更新 + animationEasing: 'exponentialOut', //BounceOut + animationEasingUpdate: 'cubicOut' + }; + + +/***/ }, +/* 24 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + + var echartsAPIList = [ + 'getDom', 'getZr', 'getWidth', 'getHeight', 'dispatchAction', + 'on', 'off', 'getDataURL', 'getConnectedDataURL', 'getModel', 'getOption' + ]; + + function ExtensionAPI(chartInstance) { + zrUtil.each(echartsAPIList, function (name) { + this[name] = zrUtil.bind(chartInstance[name], chartInstance); + }, this); + } + + module.exports = ExtensionAPI; + + +/***/ }, +/* 25 */ +/***/ function(module, exports) { + + 'use strict'; + + + // var zrUtil = require('zrender/lib/core/util'); + var coordinateSystemCreators = {}; + + function CoordinateSystemManager() { + + this._coordinateSystems = []; + } + + CoordinateSystemManager.prototype = { + + constructor: CoordinateSystemManager, + + create: function (ecModel, api) { + var coordinateSystems = []; + for (var type in coordinateSystemCreators) { + var list = coordinateSystemCreators[type].create(ecModel, api); + list && (coordinateSystems = coordinateSystems.concat(list)); + } + + this._coordinateSystems = coordinateSystems; + }, + + update: function (ecModel, api) { + var coordinateSystems = this._coordinateSystems; + for (var i = 0; i < coordinateSystems.length; i++) { + // FIXME MUST have + coordinateSystems[i].update && coordinateSystems[i].update(ecModel, api); + } + } + }; + + CoordinateSystemManager.register = function (type, coordinateSystemCreator) { + coordinateSystemCreators[type] = coordinateSystemCreator; + }; + + CoordinateSystemManager.get = function (type) { + return coordinateSystemCreators[type]; + }; + + module.exports = CoordinateSystemManager; + + +/***/ }, +/* 26 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * ECharts option manager + * + * @module {echarts/model/OptionManager} + */ + + + + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var ComponentModel = __webpack_require__(19); + var each = zrUtil.each; + var clone = zrUtil.clone; + var map = zrUtil.map; + var merge = zrUtil.merge; + + var QUERY_REG = /^(min|max)?(.+)$/; + + /** + * TERM EXPLANATIONS: + * + * [option]: + * + * An object that contains definitions of components. For example: + * var option = { + * title: {...}, + * legend: {...}, + * visualMap: {...}, + * series: [ + * {data: [...]}, + * {data: [...]}, + * ... + * ] + * }; + * + * [rawOption]: + * + * An object input to echarts.setOption. 'rawOption' may be an + * 'option', or may be an object contains multi-options. For example: + * var option = { + * baseOption: { + * title: {...}, + * legend: {...}, + * series: [ + * {data: [...]}, + * {data: [...]}, + * ... + * ] + * }, + * timeline: {...}, + * options: [ + * {title: {...}, series: {data: [...]}}, + * {title: {...}, series: {data: [...]}}, + * ... + * ], + * media: [ + * { + * query: {maxWidth: 320}, + * option: {series: {x: 20}, visualMap: {show: false}} + * }, + * { + * query: {minWidth: 320, maxWidth: 720}, + * option: {series: {x: 500}, visualMap: {show: true}} + * }, + * { + * option: {series: {x: 1200}, visualMap: {show: true}} + * } + * ] + * }; + * + * @alias module:echarts/model/OptionManager + * @param {module:echarts/ExtensionAPI} api + */ + function OptionManager(api) { + + /** + * @private + * @type {module:echarts/ExtensionAPI} + */ + this._api = api; + + /** + * @private + * @type {Array.} + */ + this._timelineOptions = []; + + /** + * @private + * @type {Array.} + */ + this._mediaList = []; + + /** + * @private + * @type {Object} + */ + this._mediaDefault; + + /** + * -1, means default. + * empty means no media. + * @private + * @type {Array.} + */ + this._currentMediaIndices = []; + + /** + * @private + * @type {Object} + */ + this._optionBackup; + + /** + * @private + * @type {Object} + */ + this._newOptionBackup; + } + + // timeline.notMerge is not supported in ec3. Firstly there is rearly + // case that notMerge is needed. Secondly supporting 'notMerge' requires + // rawOption cloned and backuped when timeline changed, which does no + // good to performance. What's more, that both timeline and setOption + // method supply 'notMerge' brings complex and some problems. + // Consider this case: + // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false); + // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false); + + OptionManager.prototype = { + + constructor: OptionManager, + + /** + * @public + * @param {Object} rawOption Raw option. + * @param {module:echarts/model/Global} ecModel + * @param {Array.} optionPreprocessorFuncs + * @return {Object} Init option + */ + setOption: function (rawOption, optionPreprocessorFuncs) { + rawOption = clone(rawOption, true); + + // FIXME + // 如果 timeline options 或者 media 中设置了某个属性,而baseOption中没有设置,则进行警告。 + + var oldOptionBackup = this._optionBackup; + var newOptionBackup = this._newOptionBackup = parseRawOption.call( + this, rawOption, optionPreprocessorFuncs + ); + + // For setOption at second time (using merge mode); + if (oldOptionBackup) { + // Only baseOption can be merged. + mergeOption(oldOptionBackup.baseOption, newOptionBackup.baseOption); + + if (newOptionBackup.timelineOptions.length) { + oldOptionBackup.timelineOptions = newOptionBackup.timelineOptions; + } + if (newOptionBackup.mediaList.length) { + oldOptionBackup.mediaList = newOptionBackup.mediaList; + } + if (newOptionBackup.mediaDefault) { + oldOptionBackup.mediaDefault = newOptionBackup.mediaDefault; + } + } + else { + this._optionBackup = newOptionBackup; + } + }, + + /** + * @param {boolean} isRecreate + * @return {Object} + */ + mountOption: function (isRecreate) { + var optionBackup = isRecreate + // this._optionBackup can be only used when recreate. + // In other cases we use model.mergeOption to handle merge. + ? this._optionBackup : this._newOptionBackup; + + // FIXME + // 如果没有reset功能则不clone。 + + this._timelineOptions = map(optionBackup.timelineOptions, clone); + this._mediaList = map(optionBackup.mediaList, clone); + this._mediaDefault = clone(optionBackup.mediaDefault); + this._currentMediaIndices = []; + + return clone(optionBackup.baseOption); + }, + + /** + * @param {module:echarts/model/Global} ecModel + * @return {Object} + */ + getTimelineOption: function (ecModel) { + var option; + var timelineOptions = this._timelineOptions; + + if (timelineOptions.length) { + // getTimelineOption can only be called after ecModel inited, + // so we can get currentIndex from timelineModel. + var timelineModel = ecModel.getComponent('timeline'); + if (timelineModel) { + option = clone( + timelineOptions[timelineModel.getCurrentIndex()], + true + ); + } + } + + return option; + }, + + /** + * @param {module:echarts/model/Global} ecModel + * @return {Array.} + */ + getMediaOption: function (ecModel) { + var ecWidth = this._api.getWidth(); + var ecHeight = this._api.getHeight(); + var mediaList = this._mediaList; + var mediaDefault = this._mediaDefault; + var indices = []; + var result = []; + + // No media defined. + if (!mediaList.length && !mediaDefault) { + return result; + } + + // Multi media may be applied, the latter defined media has higher priority. + for (var i = 0, len = mediaList.length; i < len; i++) { + if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) { + indices.push(i); + } + } + + // FIXME + // 是否mediaDefault应该强制用户设置,否则可能修改不能回归。 + if (!indices.length && mediaDefault) { + indices = [-1]; + } + + if (indices.length && !indicesEquals(indices, this._currentMediaIndices)) { + result = map(indices, function (index) { + return clone( + index === -1 ? mediaDefault.option : mediaList[index].option + ); + }); + } + // Otherwise return nothing. + + this._currentMediaIndices = indices; + + return result; + } + }; + + function parseRawOption(rawOption, optionPreprocessorFuncs) { + var timelineOptions = []; + var mediaList = []; + var mediaDefault; + var baseOption; + + // Compatible with ec2. + var timelineOpt = rawOption.timeline; + + if (rawOption.baseOption) { + baseOption = rawOption.baseOption; + } + + // For timeline + if (timelineOpt || rawOption.options) { + baseOption = baseOption || {}; + timelineOptions = (rawOption.options || []).slice(); + } + // For media query + if (rawOption.media) { + baseOption = baseOption || {}; + var media = rawOption.media; + each(media, function (singleMedia) { + if (singleMedia && singleMedia.option) { + if (singleMedia.query) { + mediaList.push(singleMedia); + } + else if (!mediaDefault) { + // Use the first media default. + mediaDefault = singleMedia; + } + } + }); + } + + // For normal option + if (!baseOption) { + baseOption = rawOption; + } + + // Set timelineOpt to baseOption in ec3, + // which is convenient for merge option. + if (!baseOption.timeline) { + baseOption.timeline = timelineOpt; + } + + // Preprocess. + each([baseOption].concat(timelineOptions) + .concat(zrUtil.map(mediaList, function (media) { + return media.option; + })), + function (option) { + each(optionPreprocessorFuncs, function (preProcess) { + preProcess(option); + }); + } + ); + + return { + baseOption: baseOption, + timelineOptions: timelineOptions, + mediaDefault: mediaDefault, + mediaList: mediaList + }; + } + + /** + * @see + * Support: width, height, aspectRatio + * Can use max or min as prefix. + */ + function applyMediaQuery(query, ecWidth, ecHeight) { + var realMap = { + width: ecWidth, + height: ecHeight, + aspectratio: ecWidth / ecHeight // lowser case for convenientce. + }; + + var applicatable = true; + + zrUtil.each(query, function (value, attr) { + var matched = attr.match(QUERY_REG); + + if (!matched || !matched[1] || !matched[2]) { + return; + } + + var operator = matched[1]; + var realAttr = matched[2].toLowerCase(); + + if (!compare(realMap[realAttr], value, operator)) { + applicatable = false; + } + }); + + return applicatable; + } + + function compare(real, expect, operator) { + if (operator === 'min') { + return real >= expect; + } + else if (operator === 'max') { + return real <= expect; + } + else { // Equals + return real === expect; + } + } + + function indicesEquals(indices1, indices2) { + // indices is always order by asc and has only finite number. + return indices1.join(',') === indices2.join(','); + } + + /** + * Consider case: + * `chart.setOption(opt1);` + * Then user do some interaction like dataZoom, dataView changing. + * `chart.setOption(opt2);` + * Then user press 'reset button' in toolbox. + * + * After doing that all of the interaction effects should be reset, the + * chart should be the same as the result of invoke + * `chart.setOption(opt1); chart.setOption(opt2);`. + * + * Although it is not able ensure that + * `chart.setOption(opt1); chart.setOption(opt2);` is equivalents to + * `chart.setOption(merge(opt1, opt2));` exactly, + * this might be the only simple way to implement that feature. + * + * MEMO: We've considered some other approaches: + * 1. Each model handle its self restoration but not uniform treatment. + * (Too complex in logic and error-prone) + * 2. Use a shadow ecModel. (Performace expensive) + */ + function mergeOption(oldOption, newOption) { + newOption = newOption || {}; + + each(newOption, function (newCptOpt, mainType) { + if (newCptOpt == null) { + return; + } + + var oldCptOpt = oldOption[mainType]; + + if (!ComponentModel.hasClass(mainType)) { + oldOption[mainType] = merge(oldCptOpt, newCptOpt, true); + } + else { + newCptOpt = modelUtil.normalizeToArray(newCptOpt); + oldCptOpt = modelUtil.normalizeToArray(oldCptOpt); + + var mapResult = modelUtil.mappingToExists(oldCptOpt, newCptOpt); + + oldOption[mainType] = map(mapResult, function (item) { + return (item.option && item.exist) + ? merge(item.exist, item.option, true) + : (item.exist || item.option); + }); + } + }); + } + + module.exports = OptionManager; + + +/***/ }, +/* 27 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var formatUtil = __webpack_require__(6); + var modelUtil = __webpack_require__(5); + var ComponentModel = __webpack_require__(19); + + var encodeHTML = formatUtil.encodeHTML; + var addCommas = formatUtil.addCommas; + + var SeriesModel = ComponentModel.extend({ + + type: 'series', + + /** + * @readOnly + */ + seriesIndex: 0, + + // coodinateSystem will be injected in the echarts/CoordinateSystem + coordinateSystem: null, + + /** + * @type {Object} + * @protected + */ + defaultOption: null, + + /** + * Data provided for legend + * @type {Function} + */ + // PENDING + legendDataProvider: null, + + init: function (option, parentModel, ecModel, extraOpt) { + + /** + * @type {number} + * @readOnly + */ + this.seriesIndex = this.componentIndex; + + this.mergeDefaultAndTheme(option, ecModel); + + /** + * @type {module:echarts/data/List|module:echarts/data/Tree|module:echarts/data/Graph} + * @private + */ + this._dataBeforeProcessed = this.getInitialData(option, ecModel); + + // When using module:echarts/data/Tree or module:echarts/data/Graph, + // cloneShallow will cause this._data.graph.data pointing to new data list. + // Wo we make this._dataBeforeProcessed first, and then make this._data. + this._data = this._dataBeforeProcessed.cloneShallow(); + }, + + /** + * Util for merge default and theme to option + * @param {Object} option + * @param {module:echarts/model/Global} ecModel + */ + mergeDefaultAndTheme: function (option, ecModel) { + zrUtil.merge( + option, + ecModel.getTheme().get(this.subType) + ); + zrUtil.merge(option, this.getDefaultOption()); + + // Default label emphasis `position` and `show` + modelUtil.defaultEmphasis( + option.label, ['position', 'show', 'textStyle', 'distance', 'formatter'] + ); + + // Default data label emphasis `position` and `show` + // FIXME Tree structure data ? + var data = option.data || []; + for (var i = 0; i < data.length; i++) { + if (data[i] && data[i].label) { + modelUtil.defaultEmphasis( + data[i].label, ['position', 'show', 'textStyle', 'distance', 'formatter'] + ); + } + } + }, + + mergeOption: function (newSeriesOption, ecModel) { + newSeriesOption = zrUtil.merge(this.option, newSeriesOption, true); + + var data = this.getInitialData(newSeriesOption, ecModel); + // TODO Merge data? + if (data) { + this._data = data; + this._dataBeforeProcessed = data.cloneShallow(); + } + }, + + /** + * Init a data structure from data related option in series + * Must be overwritten + */ + getInitialData: function () {}, + + /** + * @return {module:echarts/data/List} + */ + getData: function () { + return this._data; + }, + + /** + * @param {module:echarts/data/List} data + */ + setData: function (data) { + this._data = data; + }, + + /** + * Get data before processed + * @return {module:echarts/data/List} + */ + getRawData: function () { + return this._dataBeforeProcessed; + }, + + /** + * Get raw data array given by user + * @return {Array.} + */ + getRawDataArray: function () { + return this.option.data; + }, + + /** + * Coord dimension to data dimension. + * + * By default the result is the same as dimensions of series data. + * But some series dimensions are different from coord dimensions (i.e. + * candlestick and boxplot). Override this method to handle those cases. + * + * Coord dimension to data dimension can be one-to-many + * + * @param {string} coordDim + * @return {Array.} dimensions on the axis. + */ + coordDimToDataDim: function (coordDim) { + return [coordDim]; + }, + + /** + * Convert data dimension to coord dimension. + * + * @param {string|number} dataDim + * @return {string} + */ + dataDimToCoordDim: function (dataDim) { + return dataDim; + }, + + /** + * Get base axis if has coordinate system and has axis. + * By default use coordSys.getBaseAxis(); + * Can be overrided for some chart. + * @return {type} description + */ + getBaseAxis: function () { + var coordSys = this.coordinateSystem; + return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis(); + }, + + // FIXME + /** + * Default tooltip formatter + * + * @param {number} dataIndex + * @param {boolean} [multipleSeries=false] + */ + formatTooltip: function (dataIndex, multipleSeries) { + var data = this._data; + var value = this.getRawValue(dataIndex); + var formattedValue = zrUtil.isArray(value) + ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); + var name = data.getName(dataIndex); + + return !multipleSeries + ? (encodeHTML(this.name) + '
' + + (name + ? encodeHTML(name) + ' : ' + formattedValue + : formattedValue) + ) + : (encodeHTML(this.name) + ' : ' + formattedValue); + }, + + restoreData: function () { + this._data = this._dataBeforeProcessed.cloneShallow(); + } + }); + + zrUtil.mixin(SeriesModel, modelUtil.dataFormatMixin); + + module.exports = SeriesModel; + + +/***/ }, +/* 28 */ +/***/ function(module, exports, __webpack_require__) { + + + + var Group = __webpack_require__(29); + var componentUtil = __webpack_require__(20); + var clazzUtil = __webpack_require__(9); + + var Component = function () { + /** + * @type {module:zrender/container/Group} + * @readOnly + */ + this.group = new Group(); + + /** + * @type {string} + * @readOnly + */ + this.uid = componentUtil.getUID('viewComponent'); + }; + + Component.prototype = { + + constructor: Component, + + init: function (ecModel, api) {}, + + render: function (componentModel, ecModel, api, payload) {}, + + dispose: function () {} + }; + + var componentProto = Component.prototype; + componentProto.updateView + = componentProto.updateLayout + = componentProto.updateVisual + = function (seriesModel, ecModel, api, payload) { + // Do nothing; + }; + // Enable Component.extend. + clazzUtil.enableClassExtend(Component); + + // Enable capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. + clazzUtil.enableClassManagement(Component, {registerWhenExtend: true}); + + module.exports = Component; + + +/***/ }, +/* 29 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上 + * @module zrender/graphic/Group + * @example + * var Group = require('zrender/lib/container/Group'); + * var Circle = require('zrender/lib/graphic/shape/Circle'); + * var g = new Group(); + * g.position[0] = 100; + * g.position[1] = 100; + * g.add(new Circle({ + * style: { + * x: 100, + * y: 100, + * r: 20, + * } + * })); + * zr.add(g); + */ + + + var zrUtil = __webpack_require__(3); + var Element = __webpack_require__(30); + var BoundingRect = __webpack_require__(15); + + /** + * @alias module:zrender/graphic/Group + * @constructor + * @extends module:zrender/mixin/Transformable + * @extends module:zrender/mixin/Eventful + */ + var Group = function (opts) { + + opts = opts || {}; + + Element.call(this, opts); + + for (var key in opts) { + this[key] = opts[key]; + } + + this._children = []; + + this.__storage = null; + + this.__dirty = true; + }; + + Group.prototype = { + + constructor: Group, + + /** + * @type {string} + */ + type: 'group', + + /** + * @return {Array.} + */ + children: function () { + return this._children.slice(); + }, + + /** + * 获取指定 index 的儿子节点 + * @param {number} idx + * @return {module:zrender/Element} + */ + childAt: function (idx) { + return this._children[idx]; + }, + + /** + * 获取指定名字的儿子节点 + * @param {string} name + * @return {module:zrender/Element} + */ + childOfName: function (name) { + var children = this._children; + for (var i = 0; i < children.length; i++) { + if (children[i].name === name) { + return children[i]; + } + } + }, + + /** + * @return {number} + */ + childCount: function () { + return this._children.length; + }, + + /** + * 添加子节点到最后 + * @param {module:zrender/Element} child + */ + add: function (child) { + if (child && child !== this && child.parent !== this) { + + this._children.push(child); + + this._doAdd(child); + } + + return this; + }, + + /** + * 添加子节点在 nextSibling 之前 + * @param {module:zrender/Element} child + * @param {module:zrender/Element} nextSibling + */ + addBefore: function (child, nextSibling) { + if (child && child !== this && child.parent !== this + && nextSibling && nextSibling.parent === this) { + + var children = this._children; + var idx = children.indexOf(nextSibling); + + if (idx >= 0) { + children.splice(idx, 0, child); + this._doAdd(child); + } + } + + return this; + }, + + _doAdd: function (child) { + if (child.parent) { + child.parent.remove(child); + } + + child.parent = this; + + var storage = this.__storage; + var zr = this.__zr; + if (storage && storage !== child.__storage) { + + storage.addToMap(child); + + if (child instanceof Group) { + child.addChildrenToStorage(storage); + } + } + + zr && zr.refresh(); + }, + + /** + * 移除子节点 + * @param {module:zrender/Element} child + */ + remove: function (child) { + var zr = this.__zr; + var storage = this.__storage; + var children = this._children; + + var idx = zrUtil.indexOf(children, child); + if (idx < 0) { + return this; + } + children.splice(idx, 1); + + child.parent = null; + + if (storage) { + + storage.delFromMap(child.id); + + if (child instanceof Group) { + child.delChildrenFromStorage(storage); + } + } + + zr && zr.refresh(); + + return this; + }, + + /** + * 移除所有子节点 + */ + removeAll: function () { + var children = this._children; + var storage = this.__storage; + var child; + var i; + for (i = 0; i < children.length; i++) { + child = children[i]; + if (storage) { + storage.delFromMap(child.id); + if (child instanceof Group) { + child.delChildrenFromStorage(storage); + } + } + child.parent = null; + } + children.length = 0; + + return this; + }, + + /** + * 遍历所有子节点 + * @param {Function} cb + * @param {} context + */ + eachChild: function (cb, context) { + var children = this._children; + for (var i = 0; i < children.length; i++) { + var child = children[i]; + cb.call(context, child, i); + } + return this; + }, + + /** + * 深度优先遍历所有子孙节点 + * @param {Function} cb + * @param {} context + */ + traverse: function (cb, context) { + for (var i = 0; i < this._children.length; i++) { + var child = this._children[i]; + cb.call(context, child); + + if (child.type === 'group') { + child.traverse(cb, context); + } + } + return this; + }, + + addChildrenToStorage: function (storage) { + for (var i = 0; i < this._children.length; i++) { + var child = this._children[i]; + storage.addToMap(child); + if (child instanceof Group) { + child.addChildrenToStorage(storage); + } + } + }, + + delChildrenFromStorage: function (storage) { + for (var i = 0; i < this._children.length; i++) { + var child = this._children[i]; + storage.delFromMap(child.id); + if (child instanceof Group) { + child.delChildrenFromStorage(storage); + } + } + }, + + dirty: function () { + this.__dirty = true; + this.__zr && this.__zr.refresh(); + return this; + }, + + /** + * @return {module:zrender/core/BoundingRect} + */ + getBoundingRect: function (includeChildren) { + // TODO Caching + // TODO Transform + var rect = null; + var tmpRect = new BoundingRect(0, 0, 0, 0); + var children = includeChildren || this._children; + var tmpMat = []; + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (child.ignore || child.invisible) { + continue; + } + + var childRect = child.getBoundingRect(); + var transform = child.getLocalTransform(tmpMat); + if (transform) { + tmpRect.copy(childRect); + tmpRect.applyTransform(transform); + rect = rect || tmpRect.clone(); + rect.union(tmpRect); + } + else { + rect = rect || childRect.clone(); + rect.union(childRect); + } + } + return rect || tmpRect; + } + }; + + zrUtil.inherits(Group, Element); + + module.exports = Group; + + +/***/ }, +/* 30 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * @module zrender/Element + */ + + + var guid = __webpack_require__(31); + var Eventful = __webpack_require__(32); + var Transformable = __webpack_require__(33); + var Animatable = __webpack_require__(34); + var zrUtil = __webpack_require__(3); + + /** + * @alias module:zrender/Element + * @constructor + * @extends {module:zrender/mixin/Animatable} + * @extends {module:zrender/mixin/Transformable} + * @extends {module:zrender/mixin/Eventful} + */ + var Element = function (opts) { + + Transformable.call(this, opts); + Eventful.call(this, opts); + Animatable.call(this, opts); + + /** + * 画布元素ID + * @type {string} + */ + this.id = opts.id || guid(); + }; + + Element.prototype = { + + /** + * 元素类型 + * Element type + * @type {string} + */ + type: 'element', + + /** + * 元素名字 + * Element name + * @type {string} + */ + name: '', + + /** + * ZRender 实例对象,会在 element 添加到 zrender 实例中后自动赋值 + * ZRender instance will be assigned when element is associated with zrender + * @name module:/zrender/Element#__zr + * @type {module:zrender/ZRender} + */ + __zr: null, + + /** + * 图形是否忽略,为true时忽略图形的绘制以及事件触发 + * If ignore drawing and events of the element object + * @name module:/zrender/Element#ignore + * @type {boolean} + * @default false + */ + ignore: false, + + /** + * 用于裁剪的路径(shape),所有 Group 内的路径在绘制时都会被这个路径裁剪 + * 该路径会继承被裁减对象的变换 + * @type {module:zrender/graphic/Path} + * @see http://www.w3.org/TR/2dcontext/#clipping-region + * @readOnly + */ + clipPath: null, + + /** + * Drift element + * @param {number} dx dx on the global space + * @param {number} dy dy on the global space + */ + drift: function (dx, dy) { + switch (this.draggable) { + case 'horizontal': + dy = 0; + break; + case 'vertical': + dx = 0; + break; + } + + var m = this.transform; + if (!m) { + m = this.transform = [1, 0, 0, 1, 0, 0]; + } + m[4] += dx; + m[5] += dy; + + this.decomposeTransform(); + this.dirty(); + }, + + /** + * Hook before update + */ + beforeUpdate: function () {}, + /** + * Hook after update + */ + afterUpdate: function () {}, + /** + * Update each frame + */ + update: function () { + this.updateTransform(); + }, + + /** + * @param {Function} cb + * @param {} context + */ + traverse: function (cb, context) {}, + + /** + * @protected + */ + attrKV: function (key, value) { + if (key === 'position' || key === 'scale' || key === 'origin') { + // Copy the array + if (value) { + var target = this[key]; + if (!target) { + target = this[key] = []; + } + target[0] = value[0]; + target[1] = value[1]; + } + } + else { + this[key] = value; + } + }, + + /** + * Hide the element + */ + hide: function () { + this.ignore = true; + this.__zr && this.__zr.refresh(); + }, + + /** + * Show the element + */ + show: function () { + this.ignore = false; + this.__zr && this.__zr.refresh(); + }, + + /** + * @param {string|Object} key + * @param {*} value + */ + attr: function (key, value) { + if (typeof key === 'string') { + this.attrKV(key, value); + } + else if (zrUtil.isObject(key)) { + for (var name in key) { + if (key.hasOwnProperty(name)) { + this.attrKV(name, key[name]); + } + } + } + this.dirty(); + + return this; + }, + + /** + * @param {module:zrender/graphic/Path} clipPath + */ + setClipPath: function (clipPath) { + var zr = this.__zr; + if (zr) { + clipPath.addSelfToZr(zr); + } + + // Remove previous clip path + if (this.clipPath && this.clipPath !== clipPath) { + this.removeClipPath(); + } + + this.clipPath = clipPath; + clipPath.__zr = zr; + clipPath.__clipTarget = this; + + this.dirty(); + }, + + /** + */ + removeClipPath: function () { + var clipPath = this.clipPath; + if (clipPath) { + if (clipPath.__zr) { + clipPath.removeSelfFromZr(clipPath.__zr); + } + + clipPath.__zr = null; + clipPath.__clipTarget = null; + this.clipPath = null; + + this.dirty(); + } + }, + + /** + * Add self from zrender instance. + * Not recursively because it will be invoked when element added to storage. + * @param {module:zrender/ZRender} zr + */ + addSelfToZr: function (zr) { + this.__zr = zr; + // 添加动画 + var animators = this.animators; + if (animators) { + for (var i = 0; i < animators.length; i++) { + zr.animation.addAnimator(animators[i]); + } + } + + if (this.clipPath) { + this.clipPath.addSelfToZr(zr); + } + }, + + /** + * Remove self from zrender instance. + * Not recursively because it will be invoked when element added to storage. + * @param {module:zrender/ZRender} zr + */ + removeSelfFromZr: function (zr) { + this.__zr = null; + // 移除动画 + var animators = this.animators; + if (animators) { + for (var i = 0; i < animators.length; i++) { + zr.animation.removeAnimator(animators[i]); + } + } + + if (this.clipPath) { + this.clipPath.removeSelfFromZr(zr); + } + } + }; + + zrUtil.mixin(Element, Animatable); + zrUtil.mixin(Element, Transformable); + zrUtil.mixin(Element, Eventful); + + module.exports = Element; + + +/***/ }, +/* 31 */ +/***/ function(module, exports) { + + /** + * zrender: 生成唯一id + * + * @author errorrik (errorrik@gmail.com) + */ + + + var idStart = 0x0907; + + module.exports = function () { + return 'zr_' + (idStart++); + }; + + + +/***/ }, +/* 32 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 事件扩展 + * @module zrender/mixin/Eventful + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + * pissang (https://www.github.com/pissang) + */ + + + var arrySlice = Array.prototype.slice; + var zrUtil = __webpack_require__(3); + var indexOf = zrUtil.indexOf; + + /** + * 事件分发器 + * @alias module:zrender/mixin/Eventful + * @constructor + */ + var Eventful = function () { + this._$handlers = {}; + }; + + Eventful.prototype = { + + constructor: Eventful, + + /** + * 单次触发绑定,trigger后销毁 + * + * @param {string} event 事件名 + * @param {Function} handler 响应函数 + * @param {Object} context + */ + one: function (event, handler, context) { + var _h = this._$handlers; + + if (!handler || !event) { + return this; + } + + if (!_h[event]) { + _h[event] = []; + } + + if (indexOf(_h[event], event) >= 0) { + return this; + } + + _h[event].push({ + h: handler, + one: true, + ctx: context || this + }); + + return this; + }, + + /** + * 绑定事件 + * @param {string} event 事件名 + * @param {Function} handler 事件处理函数 + * @param {Object} [context] + */ + on: function (event, handler, context) { + var _h = this._$handlers; + + if (!handler || !event) { + return this; + } + + if (!_h[event]) { + _h[event] = []; + } + + _h[event].push({ + h: handler, + one: false, + ctx: context || this + }); + + return this; + }, + + /** + * 是否绑定了事件 + * @param {string} event + * @return {boolean} + */ + isSilent: function (event) { + var _h = this._$handlers; + return _h[event] && _h[event].length; + }, + + /** + * 解绑事件 + * @param {string} event 事件名 + * @param {Function} [handler] 事件处理函数 + */ + off: function (event, handler) { + var _h = this._$handlers; + + if (!event) { + this._$handlers = {}; + return this; + } + + if (handler) { + if (_h[event]) { + var newList = []; + for (var i = 0, l = _h[event].length; i < l; i++) { + if (_h[event][i]['h'] != handler) { + newList.push(_h[event][i]); + } + } + _h[event] = newList; + } + + if (_h[event] && _h[event].length === 0) { + delete _h[event]; + } + } + else { + delete _h[event]; + } + + return this; + }, + + /** + * 事件分发 + * + * @param {string} type 事件类型 + */ + trigger: function (type) { + if (this._$handlers[type]) { + var args = arguments; + var argLen = args.length; + + if (argLen > 3) { + args = arrySlice.call(args, 1); + } + + var _h = this._$handlers[type]; + var len = _h.length; + for (var i = 0; i < len;) { + // Optimize advise from backbone + switch (argLen) { + case 1: + _h[i]['h'].call(_h[i]['ctx']); + break; + case 2: + _h[i]['h'].call(_h[i]['ctx'], args[1]); + break; + case 3: + _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]); + break; + default: + // have more than 2 given arguments + _h[i]['h'].apply(_h[i]['ctx'], args); + break; + } + + if (_h[i]['one']) { + _h.splice(i, 1); + len--; + } + else { + i++; + } + } + } + + return this; + }, + + /** + * 带有context的事件分发, 最后一个参数是事件回调的context + * @param {string} type 事件类型 + */ + triggerWithContext: function (type) { + if (this._$handlers[type]) { + var args = arguments; + var argLen = args.length; + + if (argLen > 4) { + args = arrySlice.call(args, 1, args.length - 1); + } + var ctx = args[args.length - 1]; + + var _h = this._$handlers[type]; + var len = _h.length; + for (var i = 0; i < len;) { + // Optimize advise from backbone + switch (argLen) { + case 1: + _h[i]['h'].call(ctx); + break; + case 2: + _h[i]['h'].call(ctx, args[1]); + break; + case 3: + _h[i]['h'].call(ctx, args[1], args[2]); + break; + default: + // have more than 2 given arguments + _h[i]['h'].apply(ctx, args); + break; + } + + if (_h[i]['one']) { + _h.splice(i, 1); + len--; + } + else { + i++; + } + } + } + + return this; + } + }; + + // 对象可以通过 onxxxx 绑定事件 + /** + * @event module:zrender/mixin/Eventful#onclick + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmouseover + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmouseout + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmousemove + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmousewheel + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmousedown + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmouseup + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragstart + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragend + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragenter + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragleave + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragover + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondrop + * @type {Function} + * @default null + */ + + module.exports = Eventful; + + + +/***/ }, +/* 33 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 提供变换扩展 + * @module zrender/mixin/Transformable + * @author pissang (https://www.github.com/pissang) + */ + + + var matrix = __webpack_require__(17); + var vector = __webpack_require__(16); + var mIdentity = matrix.identity; + + var EPSILON = 5e-5; + + function isNotAroundZero(val) { + return val > EPSILON || val < -EPSILON; + } + + /** + * @alias module:zrender/mixin/Transformable + * @constructor + */ + var Transformable = function (opts) { + opts = opts || {}; + // If there are no given position, rotation, scale + if (!opts.position) { + /** + * 平移 + * @type {Array.} + * @default [0, 0] + */ + this.position = [0, 0]; + } + if (opts.rotation == null) { + /** + * 旋转 + * @type {Array.} + * @default 0 + */ + this.rotation = 0; + } + if (!opts.scale) { + /** + * 缩放 + * @type {Array.} + * @default [1, 1] + */ + this.scale = [1, 1]; + } + /** + * 旋转和缩放的原点 + * @type {Array.} + * @default null + */ + this.origin = this.origin || null; + }; + + var transformableProto = Transformable.prototype; + transformableProto.transform = null; + + /** + * 判断是否需要有坐标变换 + * 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵 + */ + transformableProto.needLocalTransform = function () { + return isNotAroundZero(this.rotation) + || isNotAroundZero(this.position[0]) + || isNotAroundZero(this.position[1]) + || isNotAroundZero(this.scale[0] - 1) + || isNotAroundZero(this.scale[1] - 1); + }; + + transformableProto.updateTransform = function () { + var parent = this.parent; + var parentHasTransform = parent && parent.transform; + var needLocalTransform = this.needLocalTransform(); + + var m = this.transform; + if (!(needLocalTransform || parentHasTransform)) { + m && mIdentity(m); + return; + } + + m = m || matrix.create(); + + if (needLocalTransform) { + this.getLocalTransform(m); + } + else { + mIdentity(m); + } + + // 应用父节点变换 + if (parentHasTransform) { + if (needLocalTransform) { + matrix.mul(m, parent.transform, m); + } + else { + matrix.copy(m, parent.transform); + } + } + // 保存这个变换矩阵 + this.transform = m; + + this.invTransform = this.invTransform || matrix.create(); + matrix.invert(this.invTransform, m); + }; + + transformableProto.getLocalTransform = function (m) { + m = m || []; + mIdentity(m); + + var origin = this.origin; + + var scale = this.scale; + var rotation = this.rotation; + var position = this.position; + if (origin) { + // Translate to origin + m[4] -= origin[0]; + m[5] -= origin[1]; + } + matrix.scale(m, m, scale); + if (rotation) { + matrix.rotate(m, m, rotation); + } + if (origin) { + // Translate back from origin + m[4] += origin[0]; + m[5] += origin[1]; + } + + m[4] += position[0]; + m[5] += position[1]; + + return m; + }; + /** + * 将自己的transform应用到context上 + * @param {Context2D} ctx + */ + transformableProto.setTransform = function (ctx) { + var m = this.transform; + if (m) { + ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); + } + }; + + var tmpTransform = []; + + /** + * 分解`transform`矩阵到`position`, `rotation`, `scale` + */ + transformableProto.decomposeTransform = function () { + if (!this.transform) { + return; + } + var parent = this.parent; + var m = this.transform; + if (parent && parent.transform) { + // Get local transform and decompose them to position, scale, rotation + matrix.mul(tmpTransform, parent.invTransform, m); + m = tmpTransform; + } + var sx = m[0] * m[0] + m[1] * m[1]; + var sy = m[2] * m[2] + m[3] * m[3]; + var position = this.position; + var scale = this.scale; + if (isNotAroundZero(sx - 1)) { + sx = Math.sqrt(sx); + } + if (isNotAroundZero(sy - 1)) { + sy = Math.sqrt(sy); + } + if (m[0] < 0) { + sx = -sx; + } + if (m[3] < 0) { + sy = -sy; + } + position[0] = m[4]; + position[1] = m[5]; + scale[0] = sx; + scale[1] = sy; + this.rotation = Math.atan2(-m[1] / sy, m[0] / sx); + }; + + /** + * 变换坐标位置到 shape 的局部坐标空间 + * @method + * @param {number} x + * @param {number} y + * @return {Array.} + */ + transformableProto.transformCoordToLocal = function (x, y) { + var v2 = [x, y]; + var invTransform = this.invTransform; + if (invTransform) { + vector.applyTransform(v2, v2, invTransform); + } + return v2; + }; + + /** + * 变换局部坐标位置到全局坐标空间 + * @method + * @param {number} x + * @param {number} y + * @return {Array.} + */ + transformableProto.transformCoordToGlobal = function (x, y) { + var v2 = [x, y]; + var transform = this.transform; + if (transform) { + vector.applyTransform(v2, v2, transform); + } + return v2; + }; + + module.exports = Transformable; + + + +/***/ }, +/* 34 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * @module zrender/mixin/Animatable + */ + + + var Animator = __webpack_require__(35); + var util = __webpack_require__(3); + var isString = util.isString; + var isFunction = util.isFunction; + var isObject = util.isObject; + var log = __webpack_require__(39); + + /** + * @alias modue:zrender/mixin/Animatable + * @constructor + */ + var Animatable = function () { + + /** + * @type {Array.} + * @readOnly + */ + this.animators = []; + }; + + Animatable.prototype = { + + constructor: Animatable, + + /** + * 动画 + * + * @param {string} path 需要添加动画的属性获取路径,可以通过a.b.c来获取深层的属性 + * @param {boolean} [loop] 动画是否循环 + * @return {module:zrender/animation/Animator} + * @example: + * el.animate('style', false) + * .when(1000, {x: 10} ) + * .done(function(){ // Animation done }) + * .start() + */ + animate: function (path, loop) { + var target; + var animatingShape = false; + var el = this; + var zr = this.__zr; + if (path) { + var pathSplitted = path.split('.'); + var prop = el; + // If animating shape + animatingShape = pathSplitted[0] === 'shape'; + for (var i = 0, l = pathSplitted.length; i < l; i++) { + if (!prop) { + continue; + } + prop = prop[pathSplitted[i]]; + } + if (prop) { + target = prop; + } + } + else { + target = el; + } + + if (!target) { + log( + 'Property "' + + path + + '" is not existed in element ' + + el.id + ); + return; + } + + var animators = el.animators; + + var animator = new Animator(target, loop); + + animator.during(function (target) { + el.dirty(animatingShape); + }) + .done(function () { + // FIXME Animator will not be removed if use `Animator#stop` to stop animation + animators.splice(util.indexOf(animators, animator), 1); + }); + + animators.push(animator); + + // If animate after added to the zrender + if (zr) { + zr.animation.addAnimator(animator); + } + + return animator; + }, + + /** + * 停止动画 + * @param {boolean} forwardToLast If move to last frame before stop + */ + stopAnimation: function (forwardToLast) { + var animators = this.animators; + var len = animators.length; + for (var i = 0; i < len; i++) { + animators[i].stop(forwardToLast); + } + animators.length = 0; + + return this; + }, + + /** + * @param {Object} target + * @param {number} [time=500] Time in ms + * @param {string} [easing='linear'] + * @param {number} [delay=0] + * @param {Function} [callback] + * + * @example + * // Animate position + * el.animateTo({ + * position: [10, 10] + * }, function () { // done }) + * + * // Animate shape, style and position in 100ms, delayed 100ms, with cubicOut easing + * el.animateTo({ + * shape: { + * width: 500 + * }, + * style: { + * fill: 'red' + * } + * position: [10, 10] + * }, 100, 100, 'cubicOut', function () { // done }) + */ + // TODO Return animation key + animateTo: function (target, time, delay, easing, callback) { + // animateTo(target, time, easing, callback); + if (isString(delay)) { + callback = easing; + easing = delay; + delay = 0; + } + // animateTo(target, time, delay, callback); + else if (isFunction(easing)) { + callback = easing; + easing = 'linear'; + delay = 0; + } + // animateTo(target, time, callback); + else if (isFunction(delay)) { + callback = delay; + delay = 0; + } + // animateTo(target, callback) + else if (isFunction(time)) { + callback = time; + time = 500; + } + // animateTo(target) + else if (!time) { + time = 500; + } + // Stop all previous animations + this.stopAnimation(); + this._animateToShallow('', this, target, time, delay, easing, callback); + + // Animators may be removed immediately after start + // if there is nothing to animate + var animators = this.animators.slice(); + var count = animators.length; + function done() { + count--; + if (!count) { + callback && callback(); + } + } + + // No animators. This should be checked before animators[i].start(), + // because 'done' may be executed immediately if no need to animate. + if (!count) { + callback && callback(); + } + // Start after all animators created + // Incase any animator is done immediately when all animation properties are not changed + for (var i = 0; i < animators.length; i++) { + animators[i] + .done(done) + .start(easing); + } + }, + + /** + * @private + * @param {string} path='' + * @param {Object} source=this + * @param {Object} target + * @param {number} [time=500] + * @param {number} [delay=0] + * + * @example + * // Animate position + * el._animateToShallow({ + * position: [10, 10] + * }) + * + * // Animate shape, style and position in 100ms, delayed 100ms + * el._animateToShallow({ + * shape: { + * width: 500 + * }, + * style: { + * fill: 'red' + * } + * position: [10, 10] + * }, 100, 100) + */ + _animateToShallow: function (path, source, target, time, delay) { + var objShallow = {}; + var propertyCount = 0; + for (var name in target) { + if (source[name] != null) { + if (isObject(target[name]) && !util.isArrayLike(target[name])) { + this._animateToShallow( + path ? path + '.' + name : name, + source[name], + target[name], + time, + delay + ); + } + else { + objShallow[name] = target[name]; + propertyCount++; + } + } + else if (target[name] != null) { + // Attr directly if not has property + // FIXME, if some property not needed for element ? + if (!path) { + this.attr(name, target[name]); + } + else { // Shape or style + var props = {}; + props[path] = {}; + props[path][name] = target[name]; + this.attr(props); + } + } + } + + if (propertyCount > 0) { + this.animate(path, false) + .when(time == null ? 500 : time, objShallow) + .delay(delay || 0); + } + + return this; + } + }; + + module.exports = Animatable; + + +/***/ }, +/* 35 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/animation/Animator + */ + + + var Clip = __webpack_require__(36); + var color = __webpack_require__(38); + var util = __webpack_require__(3); + var isArrayLike = util.isArrayLike; + + var arraySlice = Array.prototype.slice; + + function defaultGetter(target, key) { + return target[key]; + } + + function defaultSetter(target, key, value) { + target[key] = value; + } + + /** + * @param {number} p0 + * @param {number} p1 + * @param {number} percent + * @return {number} + */ + function interpolateNumber(p0, p1, percent) { + return (p1 - p0) * percent + p0; + } + + /** + * @param {string} p0 + * @param {string} p1 + * @param {number} percent + * @return {string} + */ + function interpolateString(p0, p1, percent) { + return percent > 0.5 ? p1 : p0; + } + + /** + * @param {Array} p0 + * @param {Array} p1 + * @param {number} percent + * @param {Array} out + * @param {number} arrDim + */ + function interpolateArray(p0, p1, percent, out, arrDim) { + var len = p0.length; + if (arrDim == 1) { + for (var i = 0; i < len; i++) { + out[i] = interpolateNumber(p0[i], p1[i], percent); + } + } + else { + var len2 = p0[0].length; + for (var i = 0; i < len; i++) { + for (var j = 0; j < len2; j++) { + out[i][j] = interpolateNumber( + p0[i][j], p1[i][j], percent + ); + } + } + } + } + + function fillArr(arr0, arr1, arrDim) { + var arr0Len = arr0.length; + var arr1Len = arr1.length; + if (arr0Len === arr1Len) { + return; + } + // FIXME Not work for TypedArray + var isPreviousLarger = arr0Len > arr1Len; + if (isPreviousLarger) { + // Cut the previous + arr0.length = arr1Len; + } + else { + // Fill the previous + for (var i = arr0Len; i < arr1Len; i++) { + arr0.push( + arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i]) + ); + } + } + } + + /** + * @param {Array} arr0 + * @param {Array} arr1 + * @param {number} arrDim + * @return {boolean} + */ + function isArraySame(arr0, arr1, arrDim) { + if (arr0 === arr1) { + return true; + } + var len = arr0.length; + if (len !== arr1.length) { + return false; + } + if (arrDim === 1) { + for (var i = 0; i < len; i++) { + if (arr0[i] !== arr1[i]) { + return false; + } + } + } + else { + var len2 = arr0[0].length; + for (var i = 0; i < len; i++) { + for (var j = 0; j < len2; j++) { + if (arr0[i][j] !== arr1[i][j]) { + return false; + } + } + } + } + return true; + } + + /** + * Catmull Rom interpolate array + * @param {Array} p0 + * @param {Array} p1 + * @param {Array} p2 + * @param {Array} p3 + * @param {number} t + * @param {number} t2 + * @param {number} t3 + * @param {Array} out + * @param {number} arrDim + */ + function catmullRomInterpolateArray( + p0, p1, p2, p3, t, t2, t3, out, arrDim + ) { + var len = p0.length; + if (arrDim == 1) { + for (var i = 0; i < len; i++) { + out[i] = catmullRomInterpolate( + p0[i], p1[i], p2[i], p3[i], t, t2, t3 + ); + } + } + else { + var len2 = p0[0].length; + for (var i = 0; i < len; i++) { + for (var j = 0; j < len2; j++) { + out[i][j] = catmullRomInterpolate( + p0[i][j], p1[i][j], p2[i][j], p3[i][j], + t, t2, t3 + ); + } + } + } + } + + /** + * Catmull Rom interpolate number + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @param {number} t2 + * @param {number} t3 + * @return {number} + */ + function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) { + var v0 = (p2 - p0) * 0.5; + var v1 = (p3 - p1) * 0.5; + return (2 * (p1 - p2) + v0 + v1) * t3 + + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + + v0 * t + p1; + } + + function cloneValue(value) { + if (isArrayLike(value)) { + var len = value.length; + if (isArrayLike(value[0])) { + var ret = []; + for (var i = 0; i < len; i++) { + ret.push(arraySlice.call(value[i])); + } + return ret; + } + + return arraySlice.call(value); + } + + return value; + } + + function rgba2String(rgba) { + rgba[0] = Math.floor(rgba[0]); + rgba[1] = Math.floor(rgba[1]); + rgba[2] = Math.floor(rgba[2]); + + return 'rgba(' + rgba.join(',') + ')'; + } + + function createTrackClip (animator, easing, oneTrackDone, keyframes, propName) { + var getter = animator._getter; + var setter = animator._setter; + var useSpline = easing === 'spline'; + + var trackLen = keyframes.length; + if (!trackLen) { + return; + } + // Guess data type + var firstVal = keyframes[0].value; + var isValueArray = isArrayLike(firstVal); + var isValueColor = false; + var isValueString = false; + + // For vertices morphing + var arrDim = ( + isValueArray + && isArrayLike(firstVal[0]) + ) + ? 2 : 1; + var trackMaxTime; + // Sort keyframe as ascending + keyframes.sort(function(a, b) { + return a.time - b.time; + }); + + trackMaxTime = keyframes[trackLen - 1].time; + // Percents of each keyframe + var kfPercents = []; + // Value of each keyframe + var kfValues = []; + var prevValue = keyframes[0].value; + var isAllValueEqual = true; + for (var i = 0; i < trackLen; i++) { + kfPercents.push(keyframes[i].time / trackMaxTime); + // Assume value is a color when it is a string + var value = keyframes[i].value; + + // Check if value is equal, deep check if value is array + if (!((isValueArray && isArraySame(value, prevValue, arrDim)) + || (!isValueArray && value === prevValue))) { + isAllValueEqual = false; + } + prevValue = value; + + // Try converting a string to a color array + if (typeof value == 'string') { + var colorArray = color.parse(value); + if (colorArray) { + value = colorArray; + isValueColor = true; + } + else { + isValueString = true; + } + } + kfValues.push(value); + } + if (isAllValueEqual) { + return; + } + + if (isValueArray) { + var lastValue = kfValues[trackLen - 1]; + // Polyfill array + for (var i = 0; i < trackLen - 1; i++) { + fillArr(kfValues[i], lastValue, arrDim); + } + fillArr(getter(animator._target, propName), lastValue, arrDim); + } + + // Cache the key of last frame to speed up when + // animation playback is sequency + var lastFrame = 0; + var lastFramePercent = 0; + var start; + var w; + var p0; + var p1; + var p2; + var p3; + + if (isValueColor) { + var rgba = [0, 0, 0, 0]; + } + + var onframe = function (target, percent) { + // Find the range keyframes + // kf1-----kf2---------current--------kf3 + // find kf2 and kf3 and do interpolation + var frame; + if (percent < lastFramePercent) { + // Start from next key + start = Math.min(lastFrame + 1, trackLen - 1); + for (frame = start; frame >= 0; frame--) { + if (kfPercents[frame] <= percent) { + break; + } + } + frame = Math.min(frame, trackLen - 2); + } + else { + for (frame = lastFrame; frame < trackLen; frame++) { + if (kfPercents[frame] > percent) { + break; + } + } + frame = Math.min(frame - 1, trackLen - 2); + } + lastFrame = frame; + lastFramePercent = percent; + + var range = (kfPercents[frame + 1] - kfPercents[frame]); + if (range === 0) { + return; + } + else { + w = (percent - kfPercents[frame]) / range; + } + if (useSpline) { + p1 = kfValues[frame]; + p0 = kfValues[frame === 0 ? frame : frame - 1]; + p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1]; + p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2]; + if (isValueArray) { + catmullRomInterpolateArray( + p0, p1, p2, p3, w, w * w, w * w * w, + getter(target, propName), + arrDim + ); + } + else { + var value; + if (isValueColor) { + value = catmullRomInterpolateArray( + p0, p1, p2, p3, w, w * w, w * w * w, + rgba, 1 + ); + value = rgba2String(rgba); + } + else if (isValueString) { + // String is step(0.5) + return interpolateString(p1, p2, w); + } + else { + value = catmullRomInterpolate( + p0, p1, p2, p3, w, w * w, w * w * w + ); + } + setter( + target, + propName, + value + ); + } + } + else { + if (isValueArray) { + interpolateArray( + kfValues[frame], kfValues[frame + 1], w, + getter(target, propName), + arrDim + ); + } + else { + var value; + if (isValueColor) { + interpolateArray( + kfValues[frame], kfValues[frame + 1], w, + rgba, 1 + ); + value = rgba2String(rgba); + } + else if (isValueString) { + // String is step(0.5) + return interpolateString(kfValues[frame], kfValues[frame + 1], w); + } + else { + value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w); + } + setter( + target, + propName, + value + ); + } + } + }; + + var clip = new Clip({ + target: animator._target, + life: trackMaxTime, + loop: animator._loop, + delay: animator._delay, + onframe: onframe, + ondestroy: oneTrackDone + }); + + if (easing && easing !== 'spline') { + clip.easing = easing; + } + + return clip; + } + + /** + * @alias module:zrender/animation/Animator + * @constructor + * @param {Object} target + * @param {boolean} loop + * @param {Function} getter + * @param {Function} setter + */ + var Animator = function(target, loop, getter, setter) { + this._tracks = {}; + this._target = target; + + this._loop = loop || false; + + this._getter = getter || defaultGetter; + this._setter = setter || defaultSetter; + + this._clipCount = 0; + + this._delay = 0; + + this._doneList = []; + + this._onframeList = []; + + this._clipList = []; + }; + + Animator.prototype = { + /** + * 设置动画关键帧 + * @param {number} time 关键帧时间,单位是ms + * @param {Object} props 关键帧的属性值,key-value表示 + * @return {module:zrender/animation/Animator} + */ + when: function(time /* ms */, props) { + var tracks = this._tracks; + for (var propName in props) { + if (!tracks[propName]) { + tracks[propName] = []; + // Invalid value + var value = this._getter(this._target, propName); + if (value == null) { + // zrLog('Invalid property ' + propName); + continue; + } + // If time is 0 + // Then props is given initialize value + // Else + // Initialize value from current prop value + if (time !== 0) { + tracks[propName].push({ + time: 0, + value: cloneValue(value) + }); + } + } + tracks[propName].push({ + time: time, + value: props[propName] + }); + } + return this; + }, + /** + * 添加动画每一帧的回调函数 + * @param {Function} callback + * @return {module:zrender/animation/Animator} + */ + during: function (callback) { + this._onframeList.push(callback); + return this; + }, + + _doneCallback: function () { + // Clear all tracks + this._tracks = {}; + // Clear all clips + this._clipList.length = 0; + + var doneList = this._doneList; + var len = doneList.length; + for (var i = 0; i < len; i++) { + doneList[i].call(this); + } + }, + /** + * 开始执行动画 + * @param {string|Function} easing + * 动画缓动函数,详见{@link module:zrender/animation/easing} + * @return {module:zrender/animation/Animator} + */ + start: function (easing) { + + var self = this; + var clipCount = 0; + + var oneTrackDone = function() { + clipCount--; + if (!clipCount) { + self._doneCallback(); + } + }; + + var lastClip; + for (var propName in this._tracks) { + var clip = createTrackClip( + this, easing, oneTrackDone, + this._tracks[propName], propName + ); + if (clip) { + this._clipList.push(clip); + clipCount++; + + // If start after added to animation + if (this.animation) { + this.animation.addClip(clip); + } + + lastClip = clip; + } + } + + // Add during callback on the last clip + if (lastClip) { + var oldOnFrame = lastClip.onframe; + lastClip.onframe = function (target, percent) { + oldOnFrame(target, percent); + + for (var i = 0; i < self._onframeList.length; i++) { + self._onframeList[i](target, percent); + } + }; + } + + if (!clipCount) { + this._doneCallback(); + } + return this; + }, + /** + * 停止动画 + * @param {boolean} forwardToLast If move to last frame before stop + */ + stop: function (forwardToLast) { + var clipList = this._clipList; + var animation = this.animation; + for (var i = 0; i < clipList.length; i++) { + var clip = clipList[i]; + if (forwardToLast) { + // Move to last frame before stop + clip.onframe(this._target, 1); + } + animation && animation.removeClip(clip); + } + clipList.length = 0; + }, + /** + * 设置动画延迟开始的时间 + * @param {number} time 单位ms + * @return {module:zrender/animation/Animator} + */ + delay: function (time) { + this._delay = time; + return this; + }, + /** + * 添加动画结束的回调 + * @param {Function} cb + * @return {module:zrender/animation/Animator} + */ + done: function(cb) { + if (cb) { + this._doneList.push(cb); + } + return this; + }, + + /** + * @return {Array.} + */ + getClips: function () { + return this._clipList; + } + }; + + module.exports = Animator; + + +/***/ }, +/* 36 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 动画主控制器 + * @config target 动画对象,可以是数组,如果是数组的话会批量分发onframe等事件 + * @config life(1000) 动画时长 + * @config delay(0) 动画延迟时间 + * @config loop(true) + * @config gap(0) 循环的间隔时间 + * @config onframe + * @config easing(optional) + * @config ondestroy(optional) + * @config onrestart(optional) + * + * TODO pause + */ + + + var easingFuncs = __webpack_require__(37); + + function Clip(options) { + + this._target = options.target; + + // 生命周期 + this._life = options.life || 1000; + // 延时 + this._delay = options.delay || 0; + // 开始时间 + // this._startTime = new Date().getTime() + this._delay;// 单位毫秒 + this._initialized = false; + + // 是否循环 + this.loop = options.loop == null ? false : options.loop; + + this.gap = options.gap || 0; + + this.easing = options.easing || 'Linear'; + + this.onframe = options.onframe; + this.ondestroy = options.ondestroy; + this.onrestart = options.onrestart; + } + + Clip.prototype = { + + constructor: Clip, + + step: function (time) { + // Set startTime on first step, or _startTime may has milleseconds different between clips + // PENDING + if (!this._initialized) { + this._startTime = new Date().getTime() + this._delay; + this._initialized = true; + } + + var percent = (time - this._startTime) / this._life; + + // 还没开始 + if (percent < 0) { + return; + } + + percent = Math.min(percent, 1); + + var easing = this.easing; + var easingFunc = typeof easing == 'string' ? easingFuncs[easing] : easing; + var schedule = typeof easingFunc === 'function' + ? easingFunc(percent) + : percent; + + this.fire('frame', schedule); + + // 结束 + if (percent == 1) { + if (this.loop) { + this.restart(); + // 重新开始周期 + // 抛出而不是直接调用事件直到 stage.update 后再统一调用这些事件 + return 'restart'; + } + + // 动画完成将这个控制器标识为待删除 + // 在Animation.update中进行批量删除 + this._needsRemove = true; + return 'destroy'; + } + + return null; + }, + + restart: function() { + var time = new Date().getTime(); + var remainder = (time - this._startTime) % this._life; + this._startTime = new Date().getTime() - remainder + this.gap; + + this._needsRemove = false; + }, + + fire: function(eventType, arg) { + eventType = 'on' + eventType; + if (this[eventType]) { + this[eventType](this._target, arg); + } + } + }; + + module.exports = Clip; + + + +/***/ }, +/* 37 */ +/***/ function(module, exports) { + + /** + * 缓动代码来自 https://github.com/sole/tween.js/blob/master/src/Tween.js + * @see http://sole.github.io/tween.js/examples/03_graphs.html + * @exports zrender/animation/easing + */ + + var easing = { + /** + * @param {number} k + * @return {number} + */ + linear: function (k) { + return k; + }, + + /** + * @param {number} k + * @return {number} + */ + quadraticIn: function (k) { + return k * k; + }, + /** + * @param {number} k + * @return {number} + */ + quadraticOut: function (k) { + return k * (2 - k); + }, + /** + * @param {number} k + * @return {number} + */ + quadraticInOut: function (k) { + if ((k *= 2) < 1) { + return 0.5 * k * k; + } + return -0.5 * (--k * (k - 2) - 1); + }, + + // 三次方的缓动(t^3) + /** + * @param {number} k + * @return {number} + */ + cubicIn: function (k) { + return k * k * k; + }, + /** + * @param {number} k + * @return {number} + */ + cubicOut: function (k) { + return --k * k * k + 1; + }, + /** + * @param {number} k + * @return {number} + */ + cubicInOut: function (k) { + if ((k *= 2) < 1) { + return 0.5 * k * k * k; + } + return 0.5 * ((k -= 2) * k * k + 2); + }, + + // 四次方的缓动(t^4) + /** + * @param {number} k + * @return {number} + */ + quarticIn: function (k) { + return k * k * k * k; + }, + /** + * @param {number} k + * @return {number} + */ + quarticOut: function (k) { + return 1 - (--k * k * k * k); + }, + /** + * @param {number} k + * @return {number} + */ + quarticInOut: function (k) { + if ((k *= 2) < 1) { + return 0.5 * k * k * k * k; + } + return -0.5 * ((k -= 2) * k * k * k - 2); + }, + + // 五次方的缓动(t^5) + /** + * @param {number} k + * @return {number} + */ + quinticIn: function (k) { + return k * k * k * k * k; + }, + /** + * @param {number} k + * @return {number} + */ + quinticOut: function (k) { + return --k * k * k * k * k + 1; + }, + /** + * @param {number} k + * @return {number} + */ + quinticInOut: function (k) { + if ((k *= 2) < 1) { + return 0.5 * k * k * k * k * k; + } + return 0.5 * ((k -= 2) * k * k * k * k + 2); + }, + + // 正弦曲线的缓动(sin(t)) + /** + * @param {number} k + * @return {number} + */ + sinusoidalIn: function (k) { + return 1 - Math.cos(k * Math.PI / 2); + }, + /** + * @param {number} k + * @return {number} + */ + sinusoidalOut: function (k) { + return Math.sin(k * Math.PI / 2); + }, + /** + * @param {number} k + * @return {number} + */ + sinusoidalInOut: function (k) { + return 0.5 * (1 - Math.cos(Math.PI * k)); + }, + + // 指数曲线的缓动(2^t) + /** + * @param {number} k + * @return {number} + */ + exponentialIn: function (k) { + return k === 0 ? 0 : Math.pow(1024, k - 1); + }, + /** + * @param {number} k + * @return {number} + */ + exponentialOut: function (k) { + return k === 1 ? 1 : 1 - Math.pow(2, -10 * k); + }, + /** + * @param {number} k + * @return {number} + */ + exponentialInOut: function (k) { + if (k === 0) { + return 0; + } + if (k === 1) { + return 1; + } + if ((k *= 2) < 1) { + return 0.5 * Math.pow(1024, k - 1); + } + return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2); + }, + + // 圆形曲线的缓动(sqrt(1-t^2)) + /** + * @param {number} k + * @return {number} + */ + circularIn: function (k) { + return 1 - Math.sqrt(1 - k * k); + }, + /** + * @param {number} k + * @return {number} + */ + circularOut: function (k) { + return Math.sqrt(1 - (--k * k)); + }, + /** + * @param {number} k + * @return {number} + */ + circularInOut: function (k) { + if ((k *= 2) < 1) { + return -0.5 * (Math.sqrt(1 - k * k) - 1); + } + return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); + }, + + // 创建类似于弹簧在停止前来回振荡的动画 + /** + * @param {number} k + * @return {number} + */ + elasticIn: function (k) { + var s; + var a = 0.1; + var p = 0.4; + if (k === 0) { + return 0; + } + if (k === 1) { + return 1; + } + if (!a || a < 1) { + a = 1; s = p / 4; + } + else { + s = p * Math.asin(1 / a) / (2 * Math.PI); + } + return -(a * Math.pow(2, 10 * (k -= 1)) * + Math.sin((k - s) * (2 * Math.PI) / p)); + }, + /** + * @param {number} k + * @return {number} + */ + elasticOut: function (k) { + var s; + var a = 0.1; + var p = 0.4; + if (k === 0) { + return 0; + } + if (k === 1) { + return 1; + } + if (!a || a < 1) { + a = 1; s = p / 4; + } + else { + s = p * Math.asin(1 / a) / (2 * Math.PI); + } + return (a * Math.pow(2, -10 * k) * + Math.sin((k - s) * (2 * Math.PI) / p) + 1); + }, + /** + * @param {number} k + * @return {number} + */ + elasticInOut: function (k) { + var s; + var a = 0.1; + var p = 0.4; + if (k === 0) { + return 0; + } + if (k === 1) { + return 1; + } + if (!a || a < 1) { + a = 1; s = p / 4; + } + else { + s = p * Math.asin(1 / a) / (2 * Math.PI); + } + if ((k *= 2) < 1) { + return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) + * Math.sin((k - s) * (2 * Math.PI) / p)); + } + return a * Math.pow(2, -10 * (k -= 1)) + * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1; + + }, + + // 在某一动画开始沿指示的路径进行动画处理前稍稍收回该动画的移动 + /** + * @param {number} k + * @return {number} + */ + backIn: function (k) { + var s = 1.70158; + return k * k * ((s + 1) * k - s); + }, + /** + * @param {number} k + * @return {number} + */ + backOut: function (k) { + var s = 1.70158; + return --k * k * ((s + 1) * k + s) + 1; + }, + /** + * @param {number} k + * @return {number} + */ + backInOut: function (k) { + var s = 1.70158 * 1.525; + if ((k *= 2) < 1) { + return 0.5 * (k * k * ((s + 1) * k - s)); + } + return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); + }, + + // 创建弹跳效果 + /** + * @param {number} k + * @return {number} + */ + bounceIn: function (k) { + return 1 - easing.bounceOut(1 - k); + }, + /** + * @param {number} k + * @return {number} + */ + bounceOut: function (k) { + if (k < (1 / 2.75)) { + return 7.5625 * k * k; + } + else if (k < (2 / 2.75)) { + return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75; + } + else if (k < (2.5 / 2.75)) { + return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375; + } + else { + return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; + } + }, + /** + * @param {number} k + * @return {number} + */ + bounceInOut: function (k) { + if (k < 0.5) { + return easing.bounceIn(k * 2) * 0.5; + } + return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5; + } + }; + + module.exports = easing; + + + + +/***/ }, +/* 38 */ +/***/ function(module, exports) { + + /** + * @module zrender/tool/color + */ + + + var kCSSColorTable = { + 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1], + 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1], + 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1], + 'beige': [245,245,220,1], 'bisque': [255,228,196,1], + 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1], + 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1], + 'brown': [165,42,42,1], 'burlywood': [222,184,135,1], + 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1], + 'chocolate': [210,105,30,1], 'coral': [255,127,80,1], + 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1], + 'crimson': [220,20,60,1], 'cyan': [0,255,255,1], + 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1], + 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1], + 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1], + 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1], + 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1], + 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1], + 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1], + 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1], + 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1], + 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1], + 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1], + 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1], + 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1], + 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1], + 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1], + 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1], + 'gray': [128,128,128,1], 'green': [0,128,0,1], + 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1], + 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1], + 'indianred': [205,92,92,1], 'indigo': [75,0,130,1], + 'ivory': [255,255,240,1], 'khaki': [240,230,140,1], + 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1], + 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1], + 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1], + 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1], + 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1], + 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1], + 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1], + 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1], + 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1], + 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1], + 'limegreen': [50,205,50,1], 'linen': [250,240,230,1], + 'magenta': [255,0,255,1], 'maroon': [128,0,0,1], + 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1], + 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1], + 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1], + 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1], + 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1], + 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1], + 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1], + 'navy': [0,0,128,1], 'oldlace': [253,245,230,1], + 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1], + 'orange': [255,165,0,1], 'orangered': [255,69,0,1], + 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1], + 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1], + 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1], + 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1], + 'pink': [255,192,203,1], 'plum': [221,160,221,1], + 'powderblue': [176,224,230,1], 'purple': [128,0,128,1], + 'red': [255,0,0,1], 'rosybrown': [188,143,143,1], + 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1], + 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1], + 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1], + 'sienna': [160,82,45,1], 'silver': [192,192,192,1], + 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1], + 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1], + 'snow': [255,250,250,1], 'springgreen': [0,255,127,1], + 'steelblue': [70,130,180,1], 'tan': [210,180,140,1], + 'teal': [0,128,128,1], 'thistle': [216,191,216,1], + 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1], + 'violet': [238,130,238,1], 'wheat': [245,222,179,1], + 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1], + 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1] + }; + + function clampCssByte(i) { // Clamp to integer 0 .. 255. + i = Math.round(i); // Seems to be what Chrome does (vs truncation). + return i < 0 ? 0 : i > 255 ? 255 : i; + } + + function clampCssAngle(i) { // Clamp to integer 0 .. 360. + i = Math.round(i); // Seems to be what Chrome does (vs truncation). + return i < 0 ? 0 : i > 360 ? 360 : i; + } + + function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0. + return f < 0 ? 0 : f > 1 ? 1 : f; + } + + function parseCssInt(str) { // int or percentage. + if (str.length && str.charAt(str.length - 1) === '%') { + return clampCssByte(parseFloat(str) / 100 * 255); + } + return clampCssByte(parseInt(str, 10)); + } + + function parseCssFloat(str) { // float or percentage. + if (str.length && str.charAt(str.length - 1) === '%') { + return clampCssFloat(parseFloat(str) / 100); + } + return clampCssFloat(parseFloat(str)); + } + + function cssHueToRgb(m1, m2, h) { + if (h < 0) { + h += 1; + } + else if (h > 1) { + h -= 1; + } + + if (h * 6 < 1) { + return m1 + (m2 - m1) * h * 6; + } + if (h * 2 < 1) { + return m2; + } + if (h * 3 < 2) { + return m1 + (m2 - m1) * (2/3 - h) * 6; + } + return m1; + } + + function lerp(a, b, p) { + return a + (b - a) * p; + } + + /** + * @param {string} colorStr + * @return {Array.} + * @memberOf module:zrender/util/color + */ + function parse(colorStr) { + if (!colorStr) { + return; + } + // colorStr may be not string + colorStr = colorStr + ''; + // Remove all whitespace, not compliant, but should just be more accepting. + var str = colorStr.replace(/ /g, '').toLowerCase(); + + // Color keywords (and transparent) lookup. + if (str in kCSSColorTable) { + return kCSSColorTable[str].slice(); // dup. + } + + // #abc and #abc123 syntax. + if (str.charAt(0) === '#') { + if (str.length === 4) { + var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. + if (!(iv >= 0 && iv <= 0xfff)) { + return; // Covers NaN. + } + return [ + ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8), + (iv & 0xf0) | ((iv & 0xf0) >> 4), + (iv & 0xf) | ((iv & 0xf) << 4), + 1 + ]; + } + else if (str.length === 7) { + var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. + if (!(iv >= 0 && iv <= 0xffffff)) { + return; // Covers NaN. + } + return [ + (iv & 0xff0000) >> 16, + (iv & 0xff00) >> 8, + iv & 0xff, + 1 + ]; + } + + return; + } + var op = str.indexOf('('), ep = str.indexOf(')'); + if (op !== -1 && ep + 1 === str.length) { + var fname = str.substr(0, op); + var params = str.substr(op + 1, ep - (op + 1)).split(','); + var alpha = 1; // To allow case fallthrough. + switch (fname) { + case 'rgba': + if (params.length !== 4) { + return; + } + alpha = parseCssFloat(params.pop()); // jshint ignore:line + // Fall through. + case 'rgb': + if (params.length !== 3) { + return; + } + return [ + parseCssInt(params[0]), + parseCssInt(params[1]), + parseCssInt(params[2]), + alpha + ]; + case 'hsla': + if (params.length !== 4) { + return; + } + params[3] = parseCssFloat(params[3]); + return hsla2rgba(params); + case 'hsl': + if (params.length !== 3) { + return; + } + return hsla2rgba(params); + default: + return; + } + } + + return; + } + + /** + * @param {Array.} hsla + * @return {Array.} rgba + */ + function hsla2rgba(hsla) { + var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1 + // NOTE(deanm): According to the CSS spec s/l should only be + // percentages, but we don't bother and let float or percentage. + var s = parseCssFloat(hsla[1]); + var l = parseCssFloat(hsla[2]); + var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; + var m1 = l * 2 - m2; + + var rgba = [ + clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255), + clampCssByte(cssHueToRgb(m1, m2, h) * 255), + clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255) + ]; + + if (hsla.length === 4) { + rgba[3] = hsla[3]; + } + + return rgba; + } + + /** + * @param {Array.} rgba + * @return {Array.} hsla + */ + function rgba2hsla(rgba) { + if (!rgba) { + return; + } + + // RGB from 0 to 255 + var R = rgba[0] / 255; + var G = rgba[1] / 255; + var B = rgba[2] / 255; + + var vMin = Math.min(R, G, B); // Min. value of RGB + var vMax = Math.max(R, G, B); // Max. value of RGB + var delta = vMax - vMin; // Delta RGB value + + var L = (vMax + vMin) / 2; + var H; + var S; + // HSL results from 0 to 1 + if (delta === 0) { + H = 0; + S = 0; + } + else { + if (L < 0.5) { + S = delta / (vMax + vMin); + } + else { + S = delta / (2 - vMax - vMin); + } + + var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta; + var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta; + var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta; + + if (R === vMax) { + H = deltaB - deltaG; + } + else if (G === vMax) { + H = (1 / 3) + deltaR - deltaB; + } + else if (B === vMax) { + H = (2 / 3) + deltaG - deltaR; + } + + if (H < 0) { + H += 1; + } + + if (H > 1) { + H -= 1; + } + } + + var hsla = [H * 360, S, L]; + + if (rgba[3] != null) { + hsla.push(rgba[3]); + } + + return hsla; + } + + /** + * @param {string} color + * @param {number} level + * @return {string} + * @memberOf module:zrender/util/color + */ + function lift(color, level) { + var colorArr = parse(color); + if (colorArr) { + for (var i = 0; i < 3; i++) { + if (level < 0) { + colorArr[i] = colorArr[i] * (1 - level) | 0; + } + else { + colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0; + } + } + return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb'); + } + } + + /** + * @param {string} color + * @return {string} + * @memberOf module:zrender/util/color + */ + function toHex(color, level) { + var colorArr = parse(color); + if (colorArr) { + return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1); + } + } + + /** + * Map value to color. Faster than mapToColor methods because color is represented by rgba array + * @param {number} normalizedValue A float between 0 and 1. + * @param {Array.>} colors List of rgba color array + * @param {Array.} [out] Mapped gba color array + * @return {Array.} + */ + function fastMapToColor(normalizedValue, colors, out) { + if (!(colors && colors.length) + || !(normalizedValue >= 0 && normalizedValue <= 1) + ) { + return; + } + out = out || [0, 0, 0, 0]; + var value = normalizedValue * (colors.length - 1); + var leftIndex = Math.floor(value); + var rightIndex = Math.ceil(value); + var leftColor = colors[leftIndex]; + var rightColor = colors[rightIndex]; + var dv = value - leftIndex; + out[0] = clampCssByte(lerp(leftColor[0], rightColor[0], dv)); + out[1] = clampCssByte(lerp(leftColor[1], rightColor[1], dv)); + out[2] = clampCssByte(lerp(leftColor[2], rightColor[2], dv)); + out[3] = clampCssByte(lerp(leftColor[3], rightColor[3], dv)); + return out; + } + /** + * @param {number} normalizedValue A float between 0 and 1. + * @param {Array.} colors Color list. + * @param {boolean=} fullOutput Default false. + * @return {(string|Object)} Result color. If fullOutput, + * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...}, + * @memberOf module:zrender/util/color + */ + function mapToColor(normalizedValue, colors, fullOutput) { + if (!(colors && colors.length) + || !(normalizedValue >= 0 && normalizedValue <= 1) + ) { + return; + } + + var value = normalizedValue * (colors.length - 1); + var leftIndex = Math.floor(value); + var rightIndex = Math.ceil(value); + var leftColor = parse(colors[leftIndex]); + var rightColor = parse(colors[rightIndex]); + var dv = value - leftIndex; + + var color = stringify( + [ + clampCssByte(lerp(leftColor[0], rightColor[0], dv)), + clampCssByte(lerp(leftColor[1], rightColor[1], dv)), + clampCssByte(lerp(leftColor[2], rightColor[2], dv)), + clampCssFloat(lerp(leftColor[3], rightColor[3], dv)) + ], + 'rgba' + ); + + return fullOutput + ? { + color: color, + leftIndex: leftIndex, + rightIndex: rightIndex, + value: value + } + : color; + } + + /** + * @param {Array} interval Array length === 2, + * each item is normalized value ([0, 1]). + * @param {Array.} colors Color list. + * @return {Array.} colors corresponding to the interval, + * each item is {color: 'xxx', offset: ...} + * where offset is between 0 and 1. + * @memberOf module:zrender/util/color + */ + function mapIntervalToColor(interval, colors) { + if (interval.length !== 2 || interval[1] < interval[0]) { + return; + } + + var info0 = mapToColor(interval[0], colors, true); + var info1 = mapToColor(interval[1], colors, true); + + var result = [{color: info0.color, offset: 0}]; + + var during = info1.value - info0.value; + var start = Math.max(info0.value, info0.rightIndex); + var end = Math.min(info1.value, info1.leftIndex); + + for (var i = start; during > 0 && i <= end; i++) { + result.push({ + color: colors[i], + offset: (i - info0.value) / during + }); + } + result.push({color: info1.color, offset: 1}); + + return result; + } + + /** + * @param {string} color + * @param {number=} h 0 ~ 360, ignore when null. + * @param {number=} s 0 ~ 1, ignore when null. + * @param {number=} l 0 ~ 1, ignore when null. + * @return {string} Color string in rgba format. + * @memberOf module:zrender/util/color + */ + function modifyHSL(color, h, s, l) { + color = parse(color); + + if (color) { + color = rgba2hsla(color); + h != null && (color[0] = clampCssAngle(h)); + s != null && (color[1] = parseCssFloat(s)); + l != null && (color[2] = parseCssFloat(l)); + + return stringify(hsla2rgba(color), 'rgba'); + } + } + + /** + * @param {string} color + * @param {number=} alpha 0 ~ 1 + * @return {string} Color string in rgba format. + * @memberOf module:zrender/util/color + */ + function modifyAlpha(color, alpha) { + color = parse(color); + + if (color && alpha != null) { + color[3] = clampCssFloat(alpha); + return stringify(color, 'rgba'); + } + } + + /** + * @param {Array.} colors Color list. + * @param {string} type 'rgba', 'hsva', ... + * @return {string} Result color. + */ + function stringify(arrColor, type) { + if (type === 'rgb' || type === 'hsv' || type === 'hsl') { + arrColor = arrColor.slice(0, 3); + } + return type + '(' + arrColor.join(',') + ')'; + } + + module.exports = { + parse: parse, + lift: lift, + toHex: toHex, + fastMapToColor: fastMapToColor, + mapToColor: mapToColor, + mapIntervalToColor: mapIntervalToColor, + modifyHSL: modifyHSL, + modifyAlpha: modifyAlpha, + stringify: stringify + }; + + + + +/***/ }, +/* 39 */ +/***/ function(module, exports, __webpack_require__) { + + + var config = __webpack_require__(40); + + /** + * @exports zrender/tool/log + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + */ + module.exports = function() { + if (config.debugMode === 0) { + return; + } + else if (config.debugMode == 1) { + for (var k in arguments) { + throw new Error(arguments[k]); + } + } + else if (config.debugMode > 1) { + for (var k in arguments) { + console.log(arguments[k]); + } + } + }; + + /* for debug + return function(mes) { + document.getElementById('wrong-message').innerHTML = + mes + ' ' + (new Date() - 0) + + '
' + + document.getElementById('wrong-message').innerHTML; + }; + */ + + + +/***/ }, +/* 40 */ +/***/ function(module, exports) { + + + var dpr = 1; + // If in browser environment + if (typeof window !== 'undefined') { + dpr = Math.max(window.devicePixelRatio || 1, 1); + } + /** + * config默认配置项 + * @exports zrender/config + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + */ + var config = { + /** + * debug日志选项:catchBrushException为true下有效 + * 0 : 不生成debug数据,发布用 + * 1 : 异常抛出,调试用 + * 2 : 控制台输出,调试用 + */ + debugMode: 0, + + // retina 屏幕优化 + devicePixelRatio: dpr + }; + module.exports = config; + + + + +/***/ }, +/* 41 */ +/***/ function(module, exports, __webpack_require__) { + + + + var Group = __webpack_require__(29); + var componentUtil = __webpack_require__(20); + var clazzUtil = __webpack_require__(9); + + function Chart() { + + /** + * @type {module:zrender/container/Group} + * @readOnly + */ + this.group = new Group(); + + /** + * @type {string} + * @readOnly + */ + this.uid = componentUtil.getUID('viewChart'); + } + + Chart.prototype = { + + type: 'chart', + + /** + * Init the chart + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + */ + init: function (ecModel, api) {}, + + /** + * Render the chart + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + * @param {Object} payload + */ + render: function (seriesModel, ecModel, api, payload) {}, + + /** + * Highlight series or specified data item + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + * @param {Object} payload + */ + highlight: function (seriesModel, ecModel, api, payload) { + toggleHighlight(seriesModel.getData(), payload, 'emphasis'); + }, + + /** + * Downplay series or specified data item + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + * @param {Object} payload + */ + downplay: function (seriesModel, ecModel, api, payload) { + toggleHighlight(seriesModel.getData(), payload, 'normal'); + }, + + /** + * Remove self + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + */ + remove: function (ecModel, api) { + this.group.removeAll(); + }, + + /** + * Dispose self + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + */ + dispose: function () {} + }; + + var chartProto = Chart.prototype; + chartProto.updateView + = chartProto.updateLayout + = chartProto.updateVisual + = function (seriesModel, ecModel, api, payload) { + this.render(seriesModel, ecModel, api, payload); + }; + + /** + * Set state of single element + * @param {module:zrender/Element} el + * @param {string} state + */ + function elSetState(el, state) { + if (el) { + el.trigger(state); + if (el.type === 'group') { + for (var i = 0; i < el.childCount(); i++) { + elSetState(el.childAt(i), state); + } + } + } + } + /** + * @param {module:echarts/data/List} data + * @param {Object} payload + * @param {string} state 'normal'|'emphasis' + * @inner + */ + function toggleHighlight(data, payload, state) { + if (payload.dataIndex != null) { + var el = data.getItemGraphicEl(payload.dataIndex); + elSetState(el, state); + } + else if (payload.name) { + var dataIndex = data.indexOfName(payload.name); + var el = data.getItemGraphicEl(dataIndex); + elSetState(el, state); + } + else { + data.eachItemGraphicEl(function (el) { + elSetState(el, state); + }); + } + } + + // Enable Chart.extend. + clazzUtil.enableClassExtend(Chart); + + // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. + clazzUtil.enableClassManagement(Chart, {registerWhenExtend: true}); + + module.exports = Chart; + + +/***/ }, +/* 42 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + + var pathTool = __webpack_require__(43); + var round = Math.round; + var Path = __webpack_require__(44); + var colorTool = __webpack_require__(38); + var matrix = __webpack_require__(17); + var vector = __webpack_require__(16); + var Gradient = __webpack_require__(4); + + var graphic = {}; + + graphic.Group = __webpack_require__(29); + + graphic.Image = __webpack_require__(59); + + graphic.Text = __webpack_require__(62); + + graphic.Circle = __webpack_require__(63); + + graphic.Sector = __webpack_require__(64); + + graphic.Ring = __webpack_require__(65); + + graphic.Polygon = __webpack_require__(66); + + graphic.Polyline = __webpack_require__(70); + + graphic.Rect = __webpack_require__(71); + + graphic.Line = __webpack_require__(72); + + graphic.BezierCurve = __webpack_require__(73); + + graphic.Arc = __webpack_require__(74); + + graphic.LinearGradient = __webpack_require__(75); + + graphic.RadialGradient = __webpack_require__(76); + + graphic.BoundingRect = __webpack_require__(15); + + /** + * Extend shape with parameters + */ + graphic.extendShape = function (opts) { + return Path.extend(opts); + }; + + /** + * Extend path + */ + graphic.extendPath = function (pathData, opts) { + return pathTool.extendFromString(pathData, opts); + }; + + /** + * Create a path element from path data string + * @param {string} pathData + * @param {Object} opts + * @param {module:zrender/core/BoundingRect} rect + * @param {string} [layout=cover] 'center' or 'cover' + */ + graphic.makePath = function (pathData, opts, rect, layout) { + var path = pathTool.createFromString(pathData, opts); + var boundingRect = path.getBoundingRect(); + if (rect) { + var aspect = boundingRect.width / boundingRect.height; + + if (layout === 'center') { + // Set rect to center, keep width / height ratio. + var width = rect.height * aspect; + var height; + if (width <= rect.width) { + height = rect.height; + } + else { + width = rect.width; + height = width / aspect; + } + var cx = rect.x + rect.width / 2; + var cy = rect.y + rect.height / 2; + + rect.x = cx - width / 2; + rect.y = cy - height / 2; + rect.width = width; + rect.height = height; + } + + this.resizePath(path, rect); + } + return path; + }; + + graphic.mergePath = pathTool.mergePath, + + /** + * Resize a path to fit the rect + * @param {module:zrender/graphic/Path} path + * @param {Object} rect + */ + graphic.resizePath = function (path, rect) { + if (!path.applyTransform) { + return; + } + + var pathRect = path.getBoundingRect(); + + var m = pathRect.calculateTransform(rect); + + path.applyTransform(m); + }; + + /** + * Sub pixel optimize line for canvas + * + * @param {Object} param + * @param {Object} [param.shape] + * @param {number} [param.shape.x1] + * @param {number} [param.shape.y1] + * @param {number} [param.shape.x2] + * @param {number} [param.shape.y2] + * @param {Object} [param.style] + * @param {number} [param.style.lineWidth] + * @return {Object} Modified param + */ + graphic.subPixelOptimizeLine = function (param) { + var subPixelOptimize = graphic.subPixelOptimize; + var shape = param.shape; + var lineWidth = param.style.lineWidth; + + if (round(shape.x1 * 2) === round(shape.x2 * 2)) { + shape.x1 = shape.x2 = subPixelOptimize(shape.x1, lineWidth, true); + } + if (round(shape.y1 * 2) === round(shape.y2 * 2)) { + shape.y1 = shape.y2 = subPixelOptimize(shape.y1, lineWidth, true); + } + return param; + }; + + /** + * Sub pixel optimize rect for canvas + * + * @param {Object} param + * @param {Object} [param.shape] + * @param {number} [param.shape.x] + * @param {number} [param.shape.y] + * @param {number} [param.shape.width] + * @param {number} [param.shape.height] + * @param {Object} [param.style] + * @param {number} [param.style.lineWidth] + * @return {Object} Modified param + */ + graphic.subPixelOptimizeRect = function (param) { + var subPixelOptimize = graphic.subPixelOptimize; + var shape = param.shape; + var lineWidth = param.style.lineWidth; + var originX = shape.x; + var originY = shape.y; + var originWidth = shape.width; + var originHeight = shape.height; + shape.x = subPixelOptimize(shape.x, lineWidth, true); + shape.y = subPixelOptimize(shape.y, lineWidth, true); + shape.width = Math.max( + subPixelOptimize(originX + originWidth, lineWidth, false) - shape.x, + originWidth === 0 ? 0 : 1 + ); + shape.height = Math.max( + subPixelOptimize(originY + originHeight, lineWidth, false) - shape.y, + originHeight === 0 ? 0 : 1 + ); + return param; + }; + + /** + * Sub pixel optimize for canvas + * + * @param {number} position Coordinate, such as x, y + * @param {number} lineWidth Should be nonnegative integer. + * @param {boolean=} positiveOrNegative Default false (negative). + * @return {number} Optimized position. + */ + graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) { + // Assure that (position + lineWidth / 2) is near integer edge, + // otherwise line will be fuzzy in canvas. + var doubledPosition = round(position * 2); + return (doubledPosition + round(lineWidth)) % 2 === 0 + ? doubledPosition / 2 + : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2; + }; + + /** + * @private + */ + function doSingleEnterHover(el) { + if (el.__isHover) { + return; + } + if (el.__hoverStlDirty) { + var stroke = el.style.stroke; + var fill = el.style.fill; + + // Create hoverStyle on mouseover + var hoverStyle = el.__hoverStl; + hoverStyle.fill = hoverStyle.fill + || (fill instanceof Gradient ? fill : colorTool.lift(fill, -0.1)); + hoverStyle.stroke = hoverStyle.stroke + || (stroke instanceof Gradient ? stroke : colorTool.lift(stroke, -0.1)); + + var normalStyle = {}; + for (var name in hoverStyle) { + if (hoverStyle.hasOwnProperty(name)) { + normalStyle[name] = el.style[name]; + } + } + + el.__normalStl = normalStyle; + + el.__hoverStlDirty = false; + } + el.setStyle(el.__hoverStl); + el.z2 += 1; + + el.__isHover = true; + } + + /** + * @inner + */ + function doSingleLeaveHover(el) { + if (!el.__isHover) { + return; + } + + var normalStl = el.__normalStl; + normalStl && el.setStyle(normalStl); + el.z2 -= 1; + + el.__isHover = false; + } + + /** + * @inner + */ + function doEnterHover(el) { + el.type === 'group' + ? el.traverse(function (child) { + if (child.type !== 'group') { + doSingleEnterHover(child); + } + }) + : doSingleEnterHover(el); + } + + function doLeaveHover(el) { + el.type === 'group' + ? el.traverse(function (child) { + if (child.type !== 'group') { + doSingleLeaveHover(child); + } + }) + : doSingleLeaveHover(el); + } + + /** + * @inner + */ + function setElementHoverStl(el, hoverStl) { + // If element has sepcified hoverStyle, then use it instead of given hoverStyle + // Often used when item group has a label element and it's hoverStyle is different + el.__hoverStl = el.hoverStyle || hoverStl; + el.__hoverStlDirty = true; + } + + /** + * @inner + */ + function onElementMouseOver() { + // Only if element is not in emphasis status + !this.__isEmphasis && doEnterHover(this); + } + + /** + * @inner + */ + function onElementMouseOut() { + // Only if element is not in emphasis status + !this.__isEmphasis && doLeaveHover(this); + } + + /** + * @inner + */ + function enterEmphasis() { + this.__isEmphasis = true; + doEnterHover(this); + } + + /** + * @inner + */ + function leaveEmphasis() { + this.__isEmphasis = false; + doLeaveHover(this); + } + + /** + * Set hover style of element + * @param {module:zrender/Element} el + * @param {Object} [hoverStyle] + */ + graphic.setHoverStyle = function (el, hoverStyle) { + hoverStyle = hoverStyle || {}; + el.type === 'group' + ? el.traverse(function (child) { + if (child.type !== 'group') { + setElementHoverStl(child, hoverStyle); + } + }) + : setElementHoverStl(el, hoverStyle); + // Remove previous bound handlers + el.on('mouseover', onElementMouseOver) + .on('mouseout', onElementMouseOut); + + // Emphasis, normal can be triggered manually + el.on('emphasis', enterEmphasis) + .on('normal', leaveEmphasis); + }; + + /** + * Set text option in the style + * @param {Object} textStyle + * @param {module:echarts/model/Model} labelModel + * @param {string} color + */ + graphic.setText = function (textStyle, labelModel, color) { + var labelPosition = labelModel.getShallow('position') || 'inside'; + var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color; + var textStyleModel = labelModel.getModel('textStyle'); + zrUtil.extend(textStyle, { + textDistance: labelModel.getShallow('distance') || 5, + textFont: textStyleModel.getFont(), + textPosition: labelPosition, + textFill: textStyleModel.getTextColor() || labelColor + }); + }; + + function animateOrSetProps(isUpdate, el, props, animatableModel, cb) { + var postfix = isUpdate ? 'Update' : ''; + var duration = animatableModel + && animatableModel.getShallow('animationDuration' + postfix); + var animationEasing = animatableModel + && animatableModel.getShallow('animationEasing' + postfix); + + animatableModel && animatableModel.getShallow('animation') + ? el.animateTo(props, duration, animationEasing, cb) + : (el.attr(props), cb && cb()); + } + /** + * Update graphic element properties with or without animation according to the configuration in series + * @param {module:zrender/Element} el + * @param {Object} props + * @param {module:echarts/model/Model} [animatableModel] + * @param {Function} cb + */ + graphic.updateProps = zrUtil.curry(animateOrSetProps, true); + + /** + * Init graphic element properties with or without animation according to the configuration in series + * @param {module:zrender/Element} el + * @param {Object} props + * @param {module:echarts/model/Model} [animatableModel] + * @param {Function} cb + */ + graphic.initProps = zrUtil.curry(animateOrSetProps, false); + + /** + * Get transform matrix of target (param target), + * in coordinate of its ancestor (param ancestor) + * + * @param {module:zrender/mixin/Transformable} target + * @param {module:zrender/mixin/Transformable} ancestor + */ + graphic.getTransform = function (target, ancestor) { + var mat = matrix.identity([]); + + while (target && target !== ancestor) { + matrix.mul(mat, target.getLocalTransform(), mat); + target = target.parent; + } + + return mat; + }; + + /** + * Apply transform to an vertex. + * @param {Array.} vertex [x, y] + * @param {Array.} transform Transform matrix: like [1, 0, 0, 1, 0, 0] + * @param {boolean=} invert Whether use invert matrix. + * @return {Array.} [x, y] + */ + graphic.applyTransform = function (vertex, transform, invert) { + if (invert) { + transform = matrix.invert([], transform); + } + return vector.applyTransform([], vertex, transform); + }; + + /** + * @param {string} direction 'left' 'right' 'top' 'bottom' + * @param {Array.} transform Transform matrix: like [1, 0, 0, 1, 0, 0] + * @param {boolean=} invert Whether use invert matrix. + * @return {string} Transformed direction. 'left' 'right' 'top' 'bottom' + */ + graphic.transformDirection = function (direction, transform, invert) { + + // Pick a base, ensure that transform result will not be (0, 0). + var hBase = (transform[4] === 0 || transform[5] === 0 || transform[0] === 0) + ? 1 : Math.abs(2 * transform[4] / transform[0]); + var vBase = (transform[4] === 0 || transform[5] === 0 || transform[2] === 0) + ? 1 : Math.abs(2 * transform[4] / transform[2]); + + var vertex = [ + direction === 'left' ? -hBase : direction === 'right' ? hBase : 0, + direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0 + ]; + + vertex = graphic.applyTransform(vertex, transform, invert); + + return Math.abs(vertex[0]) > Math.abs(vertex[1]) + ? (vertex[0] > 0 ? 'right' : 'left') + : (vertex[1] > 0 ? 'bottom' : 'top'); + }; + + module.exports = graphic; + + +/***/ }, +/* 43 */ +/***/ function(module, exports, __webpack_require__) { + + + + var Path = __webpack_require__(44); + var PathProxy = __webpack_require__(48); + var transformPath = __webpack_require__(58); + var matrix = __webpack_require__(17); + + // command chars + var cc = [ + 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z', + 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A' + ]; + + var mathSqrt = Math.sqrt; + var mathSin = Math.sin; + var mathCos = Math.cos; + var PI = Math.PI; + + var vMag = function(v) { + return Math.sqrt(v[0] * v[0] + v[1] * v[1]); + }; + var vRatio = function(u, v) { + return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v)); + }; + var vAngle = function(u, v) { + return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) + * Math.acos(vRatio(u, v)); + }; + + function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) { + var psi = psiDeg * (PI / 180.0); + var xp = mathCos(psi) * (x1 - x2) / 2.0 + + mathSin(psi) * (y1 - y2) / 2.0; + var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0 + + mathCos(psi) * (y1 - y2) / 2.0; + + var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry); + + if (lambda > 1) { + rx *= mathSqrt(lambda); + ry *= mathSqrt(lambda); + } + + var f = (fa === fs ? -1 : 1) + * mathSqrt((((rx * rx) * (ry * ry)) + - ((rx * rx) * (yp * yp)) + - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp) + + (ry * ry) * (xp * xp)) + ) || 0; + + var cxp = f * rx * yp / ry; + var cyp = f * -ry * xp / rx; + + var cx = (x1 + x2) / 2.0 + + mathCos(psi) * cxp + - mathSin(psi) * cyp; + var cy = (y1 + y2) / 2.0 + + mathSin(psi) * cxp + + mathCos(psi) * cyp; + + var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]); + var u = [ (xp - cxp) / rx, (yp - cyp) / ry ]; + var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ]; + var dTheta = vAngle(u, v); + + if (vRatio(u, v) <= -1) { + dTheta = PI; + } + if (vRatio(u, v) >= 1) { + dTheta = 0; + } + if (fs === 0 && dTheta > 0) { + dTheta = dTheta - 2 * PI; + } + if (fs === 1 && dTheta < 0) { + dTheta = dTheta + 2 * PI; + } + + path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs); + } + + function createPathProxyFromString(data) { + if (!data) { + return []; + } + + // command string + var cs = data.replace(/-/g, ' -') + .replace(/ /g, ' ') + .replace(/ /g, ',') + .replace(/,,/g, ','); + + var n; + // create pipes so that we can split the data + for (n = 0; n < cc.length; n++) { + cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]); + } + + // create array + var arr = cs.split('|'); + // init context point + var cpx = 0; + var cpy = 0; + + var path = new PathProxy(); + var CMD = PathProxy.CMD; + + var prevCmd; + for (n = 1; n < arr.length; n++) { + var str = arr[n]; + var c = str.charAt(0); + var off = 0; + var p = str.slice(1).replace(/e,-/g, 'e-').split(','); + var cmd; + + if (p.length > 0 && p[0] === '') { + p.shift(); + } + + for (var i = 0; i < p.length; i++) { + p[i] = parseFloat(p[i]); + } + while (off < p.length && !isNaN(p[off])) { + if (isNaN(p[0])) { + break; + } + var ctlPtx; + var ctlPty; + + var rx; + var ry; + var psi; + var fa; + var fs; + + var x1 = cpx; + var y1 = cpy; + + // convert l, H, h, V, and v to L + switch (c) { + case 'l': + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'L': + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'm': + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.M; + path.addData(cmd, cpx, cpy); + c = 'l'; + break; + case 'M': + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.M; + path.addData(cmd, cpx, cpy); + c = 'L'; + break; + case 'h': + cpx += p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'H': + cpx = p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'v': + cpy += p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'V': + cpy = p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'C': + cmd = CMD.C; + path.addData( + cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++] + ); + cpx = p[off - 2]; + cpy = p[off - 1]; + break; + case 'c': + cmd = CMD.C; + path.addData( + cmd, + p[off++] + cpx, p[off++] + cpy, + p[off++] + cpx, p[off++] + cpy, + p[off++] + cpx, p[off++] + cpy + ); + cpx += p[off - 2]; + cpy += p[off - 1]; + break; + case 'S': + ctlPtx = cpx; + ctlPty = cpy; + var len = path.len(); + var pathData = path.data; + if (prevCmd === CMD.C) { + ctlPtx += cpx - pathData[len - 4]; + ctlPty += cpy - pathData[len - 3]; + } + cmd = CMD.C; + x1 = p[off++]; + y1 = p[off++]; + cpx = p[off++]; + cpy = p[off++]; + path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy); + break; + case 's': + ctlPtx = cpx; + ctlPty = cpy; + var len = path.len(); + var pathData = path.data; + if (prevCmd === CMD.C) { + ctlPtx += cpx - pathData[len - 4]; + ctlPty += cpy - pathData[len - 3]; + } + cmd = CMD.C; + x1 = cpx + p[off++]; + y1 = cpy + p[off++]; + cpx += p[off++]; + cpy += p[off++]; + path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy); + break; + case 'Q': + x1 = p[off++]; + y1 = p[off++]; + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.Q; + path.addData(cmd, x1, y1, cpx, cpy); + break; + case 'q': + x1 = p[off++] + cpx; + y1 = p[off++] + cpy; + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.Q; + path.addData(cmd, x1, y1, cpx, cpy); + break; + case 'T': + ctlPtx = cpx; + ctlPty = cpy; + var len = path.len(); + var pathData = path.data; + if (prevCmd === CMD.Q) { + ctlPtx += cpx - pathData[len - 4]; + ctlPty += cpy - pathData[len - 3]; + } + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.Q; + path.addData(cmd, ctlPtx, ctlPty, cpx, cpy); + break; + case 't': + ctlPtx = cpx; + ctlPty = cpy; + var len = path.len(); + var pathData = path.data; + if (prevCmd === CMD.Q) { + ctlPtx += cpx - pathData[len - 4]; + ctlPty += cpy - pathData[len - 3]; + } + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.Q; + path.addData(cmd, ctlPtx, ctlPty, cpx, cpy); + break; + case 'A': + rx = p[off++]; + ry = p[off++]; + psi = p[off++]; + fa = p[off++]; + fs = p[off++]; + + x1 = cpx, y1 = cpy; + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.A; + processArc( + x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path + ); + break; + case 'a': + rx = p[off++]; + ry = p[off++]; + psi = p[off++]; + fa = p[off++]; + fs = p[off++]; + + x1 = cpx, y1 = cpy; + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.A; + processArc( + x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path + ); + break; + } + } + + if (c === 'z' || c === 'Z') { + cmd = CMD.Z; + path.addData(cmd); + } + + prevCmd = cmd; + } + + path.toStatic(); + + return path; + } + + // TODO Optimize double memory cost problem + function createPathOptions(str, opts) { + var pathProxy = createPathProxyFromString(str); + var transform; + opts = opts || {}; + opts.buildPath = function (path) { + path.setData(pathProxy.data); + transform && transformPath(path, transform); + // Svg and vml renderer don't have context + var ctx = path.getContext(); + if (ctx) { + path.rebuildPath(ctx); + } + }; + + opts.applyTransform = function (m) { + if (!transform) { + transform = matrix.create(); + } + matrix.mul(transform, m, transform); + }; + + return opts; + } + + module.exports = { + /** + * Create a Path object from path string data + * http://www.w3.org/TR/SVG/paths.html#PathData + * @param {Object} opts Other options + */ + createFromString: function (str, opts) { + return new Path(createPathOptions(str, opts)); + }, + + /** + * Create a Path class from path string data + * @param {string} str + * @param {Object} opts Other options + */ + extendFromString: function (str, opts) { + return Path.extend(createPathOptions(str, opts)); + }, + + /** + * Merge multiple paths + */ + // TODO Apply transform + // TODO stroke dash + // TODO Optimize double memory cost problem + mergePath: function (pathEls, opts) { + var pathList = []; + var len = pathEls.length; + var pathEl; + var i; + for (i = 0; i < len; i++) { + pathEl = pathEls[i]; + if (pathEl.__dirty) { + pathEl.buildPath(pathEl.path, pathEl.shape); + } + pathList.push(pathEl.path); + } + + var pathBundle = new Path(opts); + pathBundle.buildPath = function (path) { + path.appendPath(pathList); + // Svg and vml renderer don't have context + var ctx = path.getContext(); + if (ctx) { + path.rebuildPath(ctx); + } + }; + + return pathBundle; + } + }; + + +/***/ }, +/* 44 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Path element + * @module zrender/graphic/Path + */ + + + + var Displayable = __webpack_require__(45); + var zrUtil = __webpack_require__(3); + var PathProxy = __webpack_require__(48); + var pathContain = __webpack_require__(51); + + var Gradient = __webpack_require__(4); + + function pathHasFill(style) { + var fill = style.fill; + return fill != null && fill !== 'none'; + } + + function pathHasStroke(style) { + var stroke = style.stroke; + return stroke != null && stroke !== 'none' && style.lineWidth > 0; + } + + var abs = Math.abs; + + /** + * @alias module:zrender/graphic/Path + * @extends module:zrender/graphic/Displayable + * @constructor + * @param {Object} opts + */ + function Path(opts) { + Displayable.call(this, opts); + + /** + * @type {module:zrender/core/PathProxy} + * @readOnly + */ + this.path = new PathProxy(); + } + + Path.prototype = { + + constructor: Path, + + type: 'path', + + __dirtyPath: true, + + strokeContainThreshold: 5, + + brush: function (ctx) { + ctx.save(); + + var style = this.style; + var path = this.path; + var hasStroke = pathHasStroke(style); + var hasFill = pathHasFill(style); + + if (this.__dirtyPath) { + // Update gradient because bounding rect may changed + if (hasFill && (style.fill instanceof Gradient)) { + style.fill.updateCanvasGradient(this, ctx); + } + if (hasStroke && (style.stroke instanceof Gradient)) { + style.stroke.updateCanvasGradient(this, ctx); + } + } + + style.bind(ctx, this); + this.setTransform(ctx); + + var lineDash = style.lineDash; + var lineDashOffset = style.lineDashOffset; + + var ctxLineDash = !!ctx.setLineDash; + + // Proxy context + // Rebuild path in following 2 cases + // 1. Path is dirty + // 2. Path needs javascript implemented lineDash stroking. + // In this case, lineDash information will not be saved in PathProxy + if (this.__dirtyPath || ( + lineDash && !ctxLineDash && hasStroke + )) { + path = this.path.beginPath(ctx); + + // Setting line dash before build path + if (lineDash && !ctxLineDash) { + path.setLineDash(lineDash); + path.setLineDashOffset(lineDashOffset); + } + + this.buildPath(path, this.shape); + + // Clear path dirty flag + this.__dirtyPath = false; + } + else { + // Replay path building + ctx.beginPath(); + this.path.rebuildPath(ctx); + } + + hasFill && path.fill(ctx); + + if (lineDash && ctxLineDash) { + ctx.setLineDash(lineDash); + ctx.lineDashOffset = lineDashOffset; + } + + hasStroke && path.stroke(ctx); + + // Draw rect text + if (style.text != null) { + // var rect = this.getBoundingRect(); + this.drawRectText(ctx, this.getBoundingRect()); + } + + ctx.restore(); + }, + + buildPath: function (ctx, shapeCfg) {}, + + getBoundingRect: function () { + var rect = this._rect; + var style = this.style; + if (!rect) { + var path = this.path; + if (this.__dirtyPath) { + path.beginPath(); + this.buildPath(path, this.shape); + } + rect = path.getBoundingRect(); + } + /** + * Needs update rect with stroke lineWidth when + * 1. Element changes scale or lineWidth + * 2. First create rect + */ + if (pathHasStroke(style) && (this.__dirty || !this._rect)) { + var rectWithStroke = this._rectWithStroke + || (this._rectWithStroke = rect.clone()); + rectWithStroke.copy(rect); + // FIXME Must after updateTransform + var w = style.lineWidth; + // PENDING, Min line width is needed when line is horizontal or vertical + var lineScale = style.strokeNoScale ? this.getLineScale() : 1; + + // Only add extra hover lineWidth when there are no fill + if (!pathHasFill(style)) { + w = Math.max(w, this.strokeContainThreshold); + } + // Consider line width + // Line scale can't be 0; + if (lineScale > 1e-10) { + rectWithStroke.width += w / lineScale; + rectWithStroke.height += w / lineScale; + rectWithStroke.x -= w / lineScale / 2; + rectWithStroke.y -= w / lineScale / 2; + } + return rectWithStroke; + } + this._rect = rect; + return rect; + }, + + contain: function (x, y) { + var localPos = this.transformCoordToLocal(x, y); + var rect = this.getBoundingRect(); + var style = this.style; + x = localPos[0]; + y = localPos[1]; + + if (rect.contain(x, y)) { + var pathData = this.path.data; + if (pathHasStroke(style)) { + var lineWidth = style.lineWidth; + var lineScale = style.strokeNoScale ? this.getLineScale() : 1; + // Line scale can't be 0; + if (lineScale > 1e-10) { + // Only add extra hover lineWidth when there are no fill + if (!pathHasFill(style)) { + lineWidth = Math.max(lineWidth, this.strokeContainThreshold); + } + if (pathContain.containStroke( + pathData, lineWidth / lineScale, x, y + )) { + return true; + } + } + } + if (pathHasFill(style)) { + return pathContain.contain(pathData, x, y); + } + } + return false; + }, + + /** + * @param {boolean} dirtyPath + */ + dirty: function (dirtyPath) { + if (arguments.length ===0) { + dirtyPath = true; + } + // Only mark dirty, not mark clean + if (dirtyPath) { + this.__dirtyPath = dirtyPath; + this._rect = null; + } + + this.__dirty = true; + + this.__zr && this.__zr.refresh(); + + // Used as a clipping path + if (this.__clipTarget) { + this.__clipTarget.dirty(); + } + }, + + /** + * Alias for animate('shape') + * @param {boolean} loop + */ + animateShape: function (loop) { + return this.animate('shape', loop); + }, + + // Overwrite attrKV + attrKV: function (key, value) { + // FIXME + if (key === 'shape') { + this.setShape(value); + } + else { + Displayable.prototype.attrKV.call(this, key, value); + } + }, + /** + * @param {Object|string} key + * @param {*} value + */ + setShape: function (key, value) { + var shape = this.shape; + // Path from string may not have shape + if (shape) { + if (zrUtil.isObject(key)) { + for (var name in key) { + shape[name] = key[name]; + } + } + else { + shape[key] = value; + } + this.dirty(true); + } + return this; + }, + + getLineScale: function () { + var m = this.transform; + // Get the line scale. + // Determinant of `m` means how much the area is enlarged by the + // transformation. So its square root can be used as a scale factor + // for width. + return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10 + ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1])) + : 1; + } + }; + + /** + * 扩展一个 Path element, 比如星形,圆等。 + * Extend a path element + * @param {Object} props + * @param {string} props.type Path type + * @param {Function} props.init Initialize + * @param {Function} props.buildPath Overwrite buildPath method + * @param {Object} [props.style] Extended default style config + * @param {Object} [props.shape] Extended default shape config + */ + Path.extend = function (defaults) { + var Sub = function (opts) { + Path.call(this, opts); + + if (defaults.style) { + // Extend default style + this.style.extendFrom(defaults.style, false); + } + + // Extend default shape + var defaultShape = defaults.shape; + if (defaultShape) { + this.shape = this.shape || {}; + var thisShape = this.shape; + for (var name in defaultShape) { + if ( + ! thisShape.hasOwnProperty(name) + && defaultShape.hasOwnProperty(name) + ) { + thisShape[name] = defaultShape[name]; + } + } + } + + defaults.init && defaults.init.call(this, opts); + }; + + zrUtil.inherits(Sub, Path); + + // FIXME 不能 extend position, rotation 等引用对象 + for (var name in defaults) { + // Extending prototype values and methods + if (name !== 'style' && name !== 'shape') { + Sub.prototype[name] = defaults[name]; + } + } + + return Sub; + }; + + zrUtil.inherits(Path, Displayable); + + module.exports = Path; + + +/***/ }, +/* 45 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 可绘制的图形基类 + * Base class of all displayable graphic objects + * @module zrender/graphic/Displayable + */ + + + + var zrUtil = __webpack_require__(3); + + var Style = __webpack_require__(46); + + var Element = __webpack_require__(30); + var RectText = __webpack_require__(47); + // var Stateful = require('./mixin/Stateful'); + + /** + * @alias module:zrender/graphic/Displayable + * @extends module:zrender/Element + * @extends module:zrender/graphic/mixin/RectText + */ + function Displayable(opts) { + + opts = opts || {}; + + Element.call(this, opts); + + // Extend properties + for (var name in opts) { + if ( + opts.hasOwnProperty(name) && + name !== 'style' + ) { + this[name] = opts[name]; + } + } + + /** + * @type {module:zrender/graphic/Style} + */ + this.style = new Style(opts.style); + + this._rect = null; + // Shapes for cascade clipping. + this.__clipPaths = []; + + // FIXME Stateful must be mixined after style is setted + // Stateful.call(this, opts); + } + + Displayable.prototype = { + + constructor: Displayable, + + type: 'displayable', + + /** + * Displayable 是否为脏,Painter 中会根据该标记判断是否需要是否需要重新绘制 + * Dirty flag. From which painter will determine if this displayable object needs brush + * @name module:zrender/graphic/Displayable#__dirty + * @type {boolean} + */ + __dirty: true, + + /** + * 图形是否可见,为true时不绘制图形,但是仍能触发鼠标事件 + * If ignore drawing of the displayable object. Mouse event will still be triggered + * @name module:/zrender/graphic/Displayable#invisible + * @type {boolean} + * @default false + */ + invisible: false, + + /** + * @name module:/zrender/graphic/Displayable#z + * @type {number} + * @default 0 + */ + z: 0, + + /** + * @name module:/zrender/graphic/Displayable#z + * @type {number} + * @default 0 + */ + z2: 0, + + /** + * z层level,决定绘画在哪层canvas中 + * @name module:/zrender/graphic/Displayable#zlevel + * @type {number} + * @default 0 + */ + zlevel: 0, + + /** + * 是否可拖拽 + * @name module:/zrender/graphic/Displayable#draggable + * @type {boolean} + * @default false + */ + draggable: false, + + /** + * 是否正在拖拽 + * @name module:/zrender/graphic/Displayable#draggable + * @type {boolean} + * @default false + */ + dragging: false, + + /** + * 是否相应鼠标事件 + * @name module:/zrender/graphic/Displayable#silent + * @type {boolean} + * @default false + */ + silent: false, + + /** + * If enable culling + * @type {boolean} + * @default false + */ + culling: false, + + /** + * Mouse cursor when hovered + * @name module:/zrender/graphic/Displayable#cursor + * @type {string} + */ + cursor: 'pointer', + + /** + * If hover area is bounding rect + * @name module:/zrender/graphic/Displayable#rectHover + * @type {string} + */ + rectHover: false, + + beforeBrush: function (ctx) {}, + + afterBrush: function (ctx) {}, + + /** + * 图形绘制方法 + * @param {Canvas2DRenderingContext} ctx + */ + // Interface + brush: function (ctx) {}, + + /** + * 获取最小包围盒 + * @return {module:zrender/core/BoundingRect} + */ + // Interface + getBoundingRect: function () {}, + + /** + * 判断坐标 x, y 是否在图形上 + * If displayable element contain coord x, y + * @param {number} x + * @param {number} y + * @return {boolean} + */ + contain: function (x, y) { + return this.rectContain(x, y); + }, + + /** + * @param {Function} cb + * @param {} context + */ + traverse: function (cb, context) { + cb.call(context, this); + }, + + /** + * 判断坐标 x, y 是否在图形的包围盒上 + * If bounding rect of element contain coord x, y + * @param {number} x + * @param {number} y + * @return {boolean} + */ + rectContain: function (x, y) { + var coord = this.transformCoordToLocal(x, y); + var rect = this.getBoundingRect(); + return rect.contain(coord[0], coord[1]); + }, + + /** + * 标记图形元素为脏,并且在下一帧重绘 + * Mark displayable element dirty and refresh next frame + */ + dirty: function () { + this.__dirty = true; + + this._rect = null; + + this.__zr && this.__zr.refresh(); + }, + + /** + * 图形是否会触发事件 + * If displayable object binded any event + * @return {boolean} + */ + // TODO, 通过 bind 绑定的事件 + // isSilent: function () { + // return !( + // this.hoverable || this.draggable + // || this.onmousemove || this.onmouseover || this.onmouseout + // || this.onmousedown || this.onmouseup || this.onclick + // || this.ondragenter || this.ondragover || this.ondragleave + // || this.ondrop + // ); + // }, + /** + * Alias for animate('style') + * @param {boolean} loop + */ + animateStyle: function (loop) { + return this.animate('style', loop); + }, + + attrKV: function (key, value) { + if (key !== 'style') { + Element.prototype.attrKV.call(this, key, value); + } + else { + this.style.set(value); + } + }, + + /** + * @param {Object|string} key + * @param {*} value + */ + setStyle: function (key, value) { + this.style.set(key, value); + this.dirty(); + return this; + } + }; + + zrUtil.inherits(Displayable, Element); + + zrUtil.mixin(Displayable, RectText); + // zrUtil.mixin(Displayable, Stateful); + + module.exports = Displayable; + + +/***/ }, +/* 46 */ +/***/ function(module, exports) { + + /** + * @module zrender/graphic/Style + */ + + + + var STYLE_LIST_COMMON = [ + 'lineCap', 'lineJoin', 'miterLimit', + 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'shadowColor' + ]; + + var Style = function (opts) { + this.extendFrom(opts); + }; + + Style.prototype = { + + constructor: Style, + + /** + * @type {string} + */ + fill: '#000000', + + /** + * @type {string} + */ + stroke: null, + + /** + * @type {number} + */ + opacity: 1, + + /** + * @type {Array.} + */ + lineDash: null, + + /** + * @type {number} + */ + lineDashOffset: 0, + + /** + * @type {number} + */ + shadowBlur: 0, + + /** + * @type {number} + */ + shadowOffsetX: 0, + + /** + * @type {number} + */ + shadowOffsetY: 0, + + /** + * @type {number} + */ + lineWidth: 1, + + /** + * If stroke ignore scale + * @type {Boolean} + */ + strokeNoScale: false, + + // Bounding rect text configuration + // Not affected by element transform + /** + * @type {string} + */ + text: null, + + /** + * @type {string} + */ + textFill: '#000', + + /** + * @type {string} + */ + textStroke: null, + + /** + * 'inside', 'left', 'right', 'top', 'bottom' + * [x, y] + * @type {string|Array.} + * @default 'inside' + */ + textPosition: 'inside', + + /** + * @type {string} + */ + textBaseline: null, + + /** + * @type {string} + */ + textAlign: null, + + /** + * @type {string} + */ + textVerticalAlign: null, + + /** + * @type {number} + */ + textDistance: 5, + + /** + * @type {number} + */ + textShadowBlur: 0, + + /** + * @type {number} + */ + textShadowOffsetX: 0, + + /** + * @type {number} + */ + textShadowOffsetY: 0, + + /** + * @param {CanvasRenderingContext2D} ctx + */ + bind: function (ctx, el) { + var fill = this.fill; + var stroke = this.stroke; + for (var i = 0; i < STYLE_LIST_COMMON.length; i++) { + var styleName = STYLE_LIST_COMMON[i]; + + if (this[styleName] != null) { + ctx[styleName] = this[styleName]; + } + } + if (stroke != null) { + var lineWidth = this.lineWidth; + ctx.lineWidth = lineWidth / ( + (this.strokeNoScale && el && el.getLineScale) ? el.getLineScale() : 1 + ); + } + if (fill != null) { + // Use canvas gradient if has + ctx.fillStyle = fill.canvasGradient ? fill.canvasGradient : fill; + } + if (stroke != null) { + // Use canvas gradient if has + ctx.strokeStyle = stroke.canvasGradient ? stroke.canvasGradient : stroke; + } + this.opacity != null && (ctx.globalAlpha = this.opacity); + }, + + /** + * Extend from other style + * @param {zrender/graphic/Style} otherStyle + * @param {boolean} overwrite + */ + extendFrom: function (otherStyle, overwrite) { + if (otherStyle) { + var target = this; + for (var name in otherStyle) { + if (otherStyle.hasOwnProperty(name) + && (overwrite || ! target.hasOwnProperty(name)) + ) { + target[name] = otherStyle[name]; + } + } + } + }, + + /** + * Batch setting style with a given object + * @param {Object|string} obj + * @param {*} [obj] + */ + set: function (obj, value) { + if (typeof obj === 'string') { + this[obj] = value; + } + else { + this.extendFrom(obj, true); + } + }, + + /** + * Clone + * @return {zrender/graphic/Style} [description] + */ + clone: function () { + var newStyle = new this.constructor(); + newStyle.extendFrom(this, true); + return newStyle; + } + }; + + var styleProto = Style.prototype; + var name; + var i; + for (i = 0; i < STYLE_LIST_COMMON.length; i++) { + name = STYLE_LIST_COMMON[i]; + if (!(name in styleProto)) { + styleProto[name] = null; + } + } + + module.exports = Style; + + +/***/ }, +/* 47 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Mixin for drawing text in a element bounding rect + * @module zrender/mixin/RectText + */ + + + + var textContain = __webpack_require__(14); + var BoundingRect = __webpack_require__(15); + + var tmpRect = new BoundingRect(); + + var RectText = function () {}; + + function parsePercent(value, maxValue) { + if (typeof value === 'string') { + if (value.lastIndexOf('%') >= 0) { + return parseFloat(value) / 100 * maxValue; + } + return parseFloat(value); + } + return value; + } + + function setTransform(ctx, m) { + ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); + } + + RectText.prototype = { + + constructor: RectText, + + /** + * Draw text in a rect with specified position. + * @param {CanvasRenderingContext} ctx + * @param {Object} rect Displayable rect + * @return {Object} textRect Alternative precalculated text bounding rect + */ + drawRectText: function (ctx, rect, textRect) { + var style = this.style; + var text = style.text; + // Convert to string + text != null && (text += ''); + if (!text) { + return; + } + var x; + var y; + var textPosition = style.textPosition; + var distance = style.textDistance; + var align = style.textAlign; + var font = style.textFont || style.font; + var baseline = style.textBaseline; + var verticalAlign = style.textVerticalAlign; + + textRect = textRect || textContain.getBoundingRect(text, font, align, baseline); + + // Transform rect to view space + var transform = this.transform; + var invTransform = this.invTransform; + if (transform) { + tmpRect.copy(rect); + tmpRect.applyTransform(transform); + rect = tmpRect; + // Transform back + setTransform(ctx, invTransform); + } + + // Text position represented by coord + if (textPosition instanceof Array) { + // Percent + x = rect.x + parsePercent(textPosition[0], rect.width); + y = rect.y + parsePercent(textPosition[1], rect.height); + align = align || 'left'; + baseline = baseline || 'top'; + } + else { + var res = textContain.adjustTextPositionOnRect( + textPosition, rect, textRect, distance + ); + x = res.x; + y = res.y; + // Default align and baseline when has textPosition + align = align || res.textAlign; + baseline = baseline || res.textBaseline; + } + + ctx.textAlign = align; + if (verticalAlign) { + switch (verticalAlign) { + case 'middle': + y -= textRect.height / 2; + break; + case 'bottom': + y -= textRect.height; + break; + // 'top' + } + // Ignore baseline + ctx.textBaseline = 'top'; + } + else { + ctx.textBaseline = baseline; + } + + var textFill = style.textFill; + var textStroke = style.textStroke; + textFill && (ctx.fillStyle = textFill); + textStroke && (ctx.strokeStyle = textStroke); + ctx.font = font; + + // Text shadow + ctx.shadowColor = style.textShadowColor; + ctx.shadowBlur = style.textShadowBlur; + ctx.shadowOffsetX = style.textShadowOffsetX; + ctx.shadowOffsetY = style.textShadowOffsetY; + + var textLines = text.split('\n'); + for (var i = 0; i < textLines.length; i++) { + textFill && ctx.fillText(textLines[i], x, y); + textStroke && ctx.strokeText(textLines[i], x, y); + y += textRect.lineHeight; + } + + // Transform again + transform && setTransform(ctx, transform); + } + }; + + module.exports = RectText; + + +/***/ }, +/* 48 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Path 代理,可以在`buildPath`中用于替代`ctx`, 会保存每个path操作的命令到pathCommands属性中 + * 可以用于 isInsidePath 判断以及获取boundingRect + * + * @module zrender/core/PathProxy + * @author Yi Shen (http://www.github.com/pissang) + */ + + // TODO getTotalLength, getPointAtLength + + + var curve = __webpack_require__(49); + var vec2 = __webpack_require__(16); + var bbox = __webpack_require__(50); + var BoundingRect = __webpack_require__(15); + + var CMD = { + M: 1, + L: 2, + C: 3, + Q: 4, + A: 5, + Z: 6, + // Rect + R: 7 + }; + + var min = []; + var max = []; + var min2 = []; + var max2 = []; + var mathMin = Math.min; + var mathMax = Math.max; + var mathCos = Math.cos; + var mathSin = Math.sin; + var mathSqrt = Math.sqrt; + + var hasTypedArray = typeof Float32Array != 'undefined'; + + /** + * @alias module:zrender/core/PathProxy + * @constructor + */ + var PathProxy = function () { + + /** + * Path data. Stored as flat array + * @type {Array.} + */ + this.data = []; + + this._len = 0; + + this._ctx = null; + + this._xi = 0; + this._yi = 0; + + this._x0 = 0; + this._y0 = 0; + }; + + /** + * 快速计算Path包围盒(并不是最小包围盒) + * @return {Object} + */ + PathProxy.prototype = { + + constructor: PathProxy, + + _lineDash: null, + + _dashOffset: 0, + + _dashIdx: 0, + + _dashSum: 0, + + getContext: function () { + return this._ctx; + }, + + /** + * @param {CanvasRenderingContext2D} ctx + * @return {module:zrender/core/PathProxy} + */ + beginPath: function (ctx) { + this._ctx = ctx; + + ctx && ctx.beginPath(); + + // Reset + this._len = 0; + + if (this._lineDash) { + this._lineDash = null; + + this._dashOffset = 0; + } + + return this; + }, + + /** + * @param {number} x + * @param {number} y + * @return {module:zrender/core/PathProxy} + */ + moveTo: function (x, y) { + this.addData(CMD.M, x, y); + this._ctx && this._ctx.moveTo(x, y); + + // x0, y0, xi, yi 是记录在 _dashedXXXXTo 方法中使用 + // xi, yi 记录当前点, x0, y0 在 closePath 的时候回到起始点。 + // 有可能在 beginPath 之后直接调用 lineTo,这时候 x0, y0 需要 + // 在 lineTo 方法中记录,这里先不考虑这种情况,dashed line 也只在 IE10- 中不支持 + this._x0 = x; + this._y0 = y; + + this._xi = x; + this._yi = y; + + return this; + }, + + /** + * @param {number} x + * @param {number} y + * @return {module:zrender/core/PathProxy} + */ + lineTo: function (x, y) { + this.addData(CMD.L, x, y); + if (this._ctx) { + this._needsDash() ? this._dashedLineTo(x, y) + : this._ctx.lineTo(x, y); + } + this._xi = x; + this._yi = y; + return this; + }, + + /** + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x3 + * @param {number} y3 + * @return {module:zrender/core/PathProxy} + */ + bezierCurveTo: function (x1, y1, x2, y2, x3, y3) { + this.addData(CMD.C, x1, y1, x2, y2, x3, y3); + if (this._ctx) { + this._needsDash() ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3) + : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3); + } + this._xi = x3; + this._yi = y3; + return this; + }, + + /** + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @return {module:zrender/core/PathProxy} + */ + quadraticCurveTo: function (x1, y1, x2, y2) { + this.addData(CMD.Q, x1, y1, x2, y2); + if (this._ctx) { + this._needsDash() ? this._dashedQuadraticTo(x1, y1, x2, y2) + : this._ctx.quadraticCurveTo(x1, y1, x2, y2); + } + this._xi = x2; + this._yi = y2; + return this; + }, + + /** + * @param {number} cx + * @param {number} cy + * @param {number} r + * @param {number} startAngle + * @param {number} endAngle + * @param {boolean} anticlockwise + * @return {module:zrender/core/PathProxy} + */ + arc: function (cx, cy, r, startAngle, endAngle, anticlockwise) { + this.addData( + CMD.A, cx, cy, r, r, startAngle, endAngle - startAngle, 0, anticlockwise ? 0 : 1 + ); + this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise); + + this._xi = mathCos(endAngle) * r + cx; + this._xi = mathSin(endAngle) * r + cx; + return this; + }, + + // TODO + arcTo: function (x1, y1, x2, y2, radius) { + if (this._ctx) { + this._ctx.arcTo(x1, y1, x2, y2, radius); + } + return this; + }, + + // TODO + rect: function (x, y, w, h) { + this._ctx && this._ctx.rect(x, y, w, h); + this.addData(CMD.R, x, y, w, h); + return this; + }, + + /** + * @return {module:zrender/core/PathProxy} + */ + closePath: function () { + this.addData(CMD.Z); + + var ctx = this._ctx; + var x0 = this._x0; + var y0 = this._y0; + if (ctx) { + this._needsDash() && this._dashedLineTo(x0, y0); + ctx.closePath(); + } + + this._xi = x0; + this._yi = y0; + return this; + }, + + /** + * Context 从外部传入,因为有可能是 rebuildPath 完之后再 fill。 + * stroke 同样 + * @param {CanvasRenderingContext2D} ctx + * @return {module:zrender/core/PathProxy} + */ + fill: function (ctx) { + ctx && ctx.fill(); + this.toStatic(); + }, + + /** + * @param {CanvasRenderingContext2D} ctx + * @return {module:zrender/core/PathProxy} + */ + stroke: function (ctx) { + ctx && ctx.stroke(); + this.toStatic(); + }, + + /** + * 必须在其它绘制命令前调用 + * Must be invoked before all other path drawing methods + * @return {module:zrender/core/PathProxy} + */ + setLineDash: function (lineDash) { + if (lineDash instanceof Array) { + this._lineDash = lineDash; + + this._dashIdx = 0; + + var lineDashSum = 0; + for (var i = 0; i < lineDash.length; i++) { + lineDashSum += lineDash[i]; + } + this._dashSum = lineDashSum; + } + return this; + }, + + /** + * 必须在其它绘制命令前调用 + * Must be invoked before all other path drawing methods + * @return {module:zrender/core/PathProxy} + */ + setLineDashOffset: function (offset) { + this._dashOffset = offset; + return this; + }, + + /** + * + * @return {boolean} + */ + len: function () { + return this._len; + }, + + /** + * 直接设置 Path 数据 + */ + setData: function (data) { + + var len = data.length; + + if (! (this.data && this.data.length == len) && hasTypedArray) { + this.data = new Float32Array(len); + } + + for (var i = 0; i < len; i++) { + this.data[i] = data[i]; + } + + this._len = len; + }, + + /** + * 添加子路径 + * @param {module:zrender/core/PathProxy|Array.} path + */ + appendPath: function (path) { + if (!(path instanceof Array)) { + path = [path]; + } + var len = path.length; + var appendSize = 0; + var offset = this._len; + for (var i = 0; i < len; i++) { + appendSize += path[i].len(); + } + if (hasTypedArray && (this.data instanceof Float32Array)) { + this.data = new Float32Array(offset + appendSize); + } + for (var i = 0; i < len; i++) { + var appendPathData = path[i].data; + for (var k = 0; k < appendPathData.length; k++) { + this.data[offset++] = appendPathData[k]; + } + } + this._len = offset; + }, + + /** + * 填充 Path 数据。 + * 尽量复用而不申明新的数组。大部分图形重绘的指令数据长度都是不变的。 + */ + addData: function (cmd) { + var data = this.data; + if (this._len + arguments.length > data.length) { + // 因为之前的数组已经转换成静态的 Float32Array + // 所以不够用时需要扩展一个新的动态数组 + this._expandData(); + data = this.data; + } + for (var i = 0; i < arguments.length; i++) { + data[this._len++] = arguments[i]; + } + + this._prevCmd = cmd; + }, + + _expandData: function () { + // Only if data is Float32Array + if (!(this.data instanceof Array)) { + var newData = []; + for (var i = 0; i < this._len; i++) { + newData[i] = this.data[i]; + } + this.data = newData; + } + }, + + /** + * If needs js implemented dashed line + * @return {boolean} + * @private + */ + _needsDash: function () { + return this._lineDash; + }, + + _dashedLineTo: function (x1, y1) { + var dashSum = this._dashSum; + var offset = this._dashOffset; + var lineDash = this._lineDash; + var ctx = this._ctx; + + var x0 = this._xi; + var y0 = this._yi; + var dx = x1 - x0; + var dy = y1 - y0; + var dist = mathSqrt(dx * dx + dy * dy); + var x = x0; + var y = y0; + var dash; + var nDash = lineDash.length; + var idx; + dx /= dist; + dy /= dist; + + if (offset < 0) { + // Convert to positive offset + offset = dashSum + offset; + } + offset %= dashSum; + x -= offset * dx; + y -= offset * dy; + + while ((dx >= 0 && x <= x1) || (dx < 0 && x > x1)) { + idx = this._dashIdx; + dash = lineDash[idx]; + x += dx * dash; + y += dy * dash; + this._dashIdx = (idx + 1) % nDash; + // Skip positive offset + if ((dx > 0 && x < x0) || (dx < 0 && x > x0)) { + continue; + } + ctx[idx % 2 ? 'moveTo' : 'lineTo']( + dx >= 0 ? mathMin(x, x1) : mathMax(x, x1), + dy >= 0 ? mathMin(y, y1) : mathMax(y, y1) + ); + } + // Offset for next lineTo + dx = x - x1; + dy = y - y1; + this._dashOffset = -mathSqrt(dx * dx + dy * dy); + }, + + // Not accurate dashed line to + _dashedBezierTo: function (x1, y1, x2, y2, x3, y3) { + var dashSum = this._dashSum; + var offset = this._dashOffset; + var lineDash = this._lineDash; + var ctx = this._ctx; + + var x0 = this._xi; + var y0 = this._yi; + var t; + var dx; + var dy; + var cubicAt = curve.cubicAt; + var bezierLen = 0; + var idx = this._dashIdx; + var nDash = lineDash.length; + + var x; + var y; + + var tmpLen = 0; + + if (offset < 0) { + // Convert to positive offset + offset = dashSum + offset; + } + offset %= dashSum; + // Bezier approx length + for (t = 0; t < 1; t += 0.1) { + dx = cubicAt(x0, x1, x2, x3, t + 0.1) + - cubicAt(x0, x1, x2, x3, t); + dy = cubicAt(y0, y1, y2, y3, t + 0.1) + - cubicAt(y0, y1, y2, y3, t); + bezierLen += mathSqrt(dx * dx + dy * dy); + } + + // Find idx after add offset + for (; idx < nDash; idx++) { + tmpLen += lineDash[idx]; + if (tmpLen > offset) { + break; + } + } + t = (tmpLen - offset) / bezierLen; + + while (t <= 1) { + + x = cubicAt(x0, x1, x2, x3, t); + y = cubicAt(y0, y1, y2, y3, t); + + // Use line to approximate dashed bezier + // Bad result if dash is long + idx % 2 ? ctx.moveTo(x, y) + : ctx.lineTo(x, y); + + t += lineDash[idx] / bezierLen; + + idx = (idx + 1) % nDash; + } + + // Finish the last segment and calculate the new offset + (idx % 2 !== 0) && ctx.lineTo(x3, y3); + dx = x3 - x; + dy = y3 - y; + this._dashOffset = -mathSqrt(dx * dx + dy * dy); + }, + + _dashedQuadraticTo: function (x1, y1, x2, y2) { + // Convert quadratic to cubic using degree elevation + var x3 = x2; + var y3 = y2; + x2 = (x2 + 2 * x1) / 3; + y2 = (y2 + 2 * y1) / 3; + x1 = (this._xi + 2 * x1) / 3; + y1 = (this._yi + 2 * y1) / 3; + + this._dashedBezierTo(x1, y1, x2, y2, x3, y3); + }, + + /** + * 转成静态的 Float32Array 减少堆内存占用 + * Convert dynamic array to static Float32Array + */ + toStatic: function () { + var data = this.data; + if (data instanceof Array) { + data.length = this._len; + if (hasTypedArray) { + this.data = new Float32Array(data); + } + } + }, + + /** + * @return {module:zrender/core/BoundingRect} + */ + getBoundingRect: function () { + min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE; + max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE; + + var data = this.data; + var xi = 0; + var yi = 0; + var x0 = 0; + var y0 = 0; + + for (var i = 0; i < data.length;) { + var cmd = data[i++]; + + if (i == 1) { + // 如果第一个命令是 L, C, Q + // 则 previous point 同绘制命令的第一个 point + // + // 第一个命令为 Arc 的情况下会在后面特殊处理 + xi = data[i]; + yi = data[i + 1]; + + x0 = xi; + y0 = yi; + } + + switch (cmd) { + case CMD.M: + // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点 + // 在 closePath 的时候使用 + x0 = data[i++]; + y0 = data[i++]; + xi = x0; + yi = y0; + min2[0] = x0; + min2[1] = y0; + max2[0] = x0; + max2[1] = y0; + break; + case CMD.L: + bbox.fromLine(xi, yi, data[i], data[i + 1], min2, max2); + xi = data[i++]; + yi = data[i++]; + break; + case CMD.C: + bbox.fromCubic( + xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], + min2, max2 + ); + xi = data[i++]; + yi = data[i++]; + break; + case CMD.Q: + bbox.fromQuadratic( + xi, yi, data[i++], data[i++], data[i], data[i + 1], + min2, max2 + ); + xi = data[i++]; + yi = data[i++]; + break; + case CMD.A: + // TODO Arc 判断的开销比较大 + var cx = data[i++]; + var cy = data[i++]; + var rx = data[i++]; + var ry = data[i++]; + var startAngle = data[i++]; + var endAngle = data[i++] + startAngle; + // TODO Arc 旋转 + var psi = data[i++]; + var anticlockwise = 1 - data[i++]; + + if (i == 1) { + // 直接使用 arc 命令 + // 第一个命令起点还未定义 + x0 = mathCos(startAngle) * rx + cx; + y0 = mathSin(startAngle) * ry + cy; + } + + bbox.fromArc( + cx, cy, rx, ry, startAngle, endAngle, + anticlockwise, min2, max2 + ); + + xi = mathCos(endAngle) * rx + cx; + yi = mathSin(endAngle) * ry + cy; + break; + case CMD.R: + x0 = xi = data[i++]; + y0 = yi = data[i++]; + var width = data[i++]; + var height = data[i++]; + // Use fromLine + bbox.fromLine(x0, y0, x0 + width, y0 + height, min2, max2); + break; + case CMD.Z: + xi = x0; + yi = y0; + break; + } + + // Union + vec2.min(min, min, min2); + vec2.max(max, max, max2); + } + + // No data + if (i === 0) { + min[0] = min[1] = max[0] = max[1] = 0; + } + + return new BoundingRect( + min[0], min[1], max[0] - min[0], max[1] - min[1] + ); + }, + + /** + * Rebuild path from current data + * Rebuild path will not consider javascript implemented line dash. + * @param {CanvasRenderingContext} ctx + */ + rebuildPath: function (ctx) { + var d = this.data; + for (var i = 0; i < this._len;) { + var cmd = d[i++]; + switch (cmd) { + case CMD.M: + ctx.moveTo(d[i++], d[i++]); + break; + case CMD.L: + ctx.lineTo(d[i++], d[i++]); + break; + case CMD.C: + ctx.bezierCurveTo( + d[i++], d[i++], d[i++], d[i++], d[i++], d[i++] + ); + break; + case CMD.Q: + ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]); + break; + case CMD.A: + var cx = d[i++]; + var cy = d[i++]; + var rx = d[i++]; + var ry = d[i++]; + var theta = d[i++]; + var dTheta = d[i++]; + var psi = d[i++]; + var fs = d[i++]; + var r = (rx > ry) ? rx : ry; + var scaleX = (rx > ry) ? 1 : rx / ry; + var scaleY = (rx > ry) ? ry / rx : 1; + var isEllipse = Math.abs(rx - ry) > 1e-3; + if (isEllipse) { + ctx.translate(cx, cy); + ctx.rotate(psi); + ctx.scale(scaleX, scaleY); + ctx.arc(0, 0, r, theta, theta + dTheta, 1 - fs); + ctx.scale(1 / scaleX, 1 / scaleY); + ctx.rotate(-psi); + ctx.translate(-cx, -cy); + } + else { + ctx.arc(cx, cy, r, theta, theta + dTheta, 1 - fs); + } + break; + case CMD.R: + ctx.rect(d[i++], d[i++], d[i++], d[i++]); + break; + case CMD.Z: + ctx.closePath(); + } + } + } + }; + + PathProxy.CMD = CMD; + + module.exports = PathProxy; + + +/***/ }, +/* 49 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 曲线辅助模块 + * @module zrender/core/curve + * @author pissang(https://www.github.com/pissang) + */ + + + var vec2 = __webpack_require__(16); + var v2Create = vec2.create; + var v2DistSquare = vec2.distSquare; + var mathPow = Math.pow; + var mathSqrt = Math.sqrt; + + var EPSILON = 1e-4; + + var THREE_SQRT = mathSqrt(3); + var ONE_THIRD = 1 / 3; + + // 临时变量 + var _v0 = v2Create(); + var _v1 = v2Create(); + var _v2 = v2Create(); + // var _v3 = vec2.create(); + + function isAroundZero(val) { + return val > -EPSILON && val < EPSILON; + } + function isNotAroundZero(val) { + return val > EPSILON || val < -EPSILON; + } + /** + * 计算三次贝塞尔值 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @return {number} + */ + function cubicAt(p0, p1, p2, p3, t) { + var onet = 1 - t; + return onet * onet * (onet * p0 + 3 * t * p1) + + t * t * (t * p3 + 3 * onet * p2); + } + + /** + * 计算三次贝塞尔导数值 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @return {number} + */ + function cubicDerivativeAt(p0, p1, p2, p3, t) { + var onet = 1 - t; + return 3 * ( + ((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet + + (p3 - p2) * t * t + ); + } + + /** + * 计算三次贝塞尔方程根,使用盛金公式 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} val + * @param {Array.} roots + * @return {number} 有效根数目 + */ + function cubicRootAt(p0, p1, p2, p3, val, roots) { + // Evaluate roots of cubic functions + var a = p3 + 3 * (p1 - p2) - p0; + var b = 3 * (p2 - p1 * 2 + p0); + var c = 3 * (p1 - p0); + var d = p0 - val; + + var A = b * b - 3 * a * c; + var B = b * c - 9 * a * d; + var C = c * c - 3 * b * d; + + var n = 0; + + if (isAroundZero(A) && isAroundZero(B)) { + if (isAroundZero(b)) { + roots[0] = 0; + } + else { + var t1 = -c / b; //t1, t2, t3, b is not zero + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + } + } + else { + var disc = B * B - 4 * A * C; + + if (isAroundZero(disc)) { + var K = B / A; + var t1 = -b / a + K; // t1, a is not zero + var t2 = -K / 2; // t2, t3 + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + if (t2 >= 0 && t2 <= 1) { + roots[n++] = t2; + } + } + else if (disc > 0) { + var discSqrt = mathSqrt(disc); + var Y1 = A * b + 1.5 * a * (-B + discSqrt); + var Y2 = A * b + 1.5 * a * (-B - discSqrt); + if (Y1 < 0) { + Y1 = -mathPow(-Y1, ONE_THIRD); + } + else { + Y1 = mathPow(Y1, ONE_THIRD); + } + if (Y2 < 0) { + Y2 = -mathPow(-Y2, ONE_THIRD); + } + else { + Y2 = mathPow(Y2, ONE_THIRD); + } + var t1 = (-b - (Y1 + Y2)) / (3 * a); + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + } + else { + var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt(A * A * A)); + var theta = Math.acos(T) / 3; + var ASqrt = mathSqrt(A); + var tmp = Math.cos(theta); + + var t1 = (-b - 2 * ASqrt * tmp) / (3 * a); + var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a); + var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a); + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + if (t2 >= 0 && t2 <= 1) { + roots[n++] = t2; + } + if (t3 >= 0 && t3 <= 1) { + roots[n++] = t3; + } + } + } + return n; + } + + /** + * 计算三次贝塞尔方程极限值的位置 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {Array.} extrema + * @return {number} 有效数目 + */ + function cubicExtrema(p0, p1, p2, p3, extrema) { + var b = 6 * p2 - 12 * p1 + 6 * p0; + var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2; + var c = 3 * p1 - 3 * p0; + + var n = 0; + if (isAroundZero(a)) { + if (isNotAroundZero(b)) { + var t1 = -c / b; + if (t1 >= 0 && t1 <=1) { + extrema[n++] = t1; + } + } + } + else { + var disc = b * b - 4 * a * c; + if (isAroundZero(disc)) { + extrema[0] = -b / (2 * a); + } + else if (disc > 0) { + var discSqrt = mathSqrt(disc); + var t1 = (-b + discSqrt) / (2 * a); + var t2 = (-b - discSqrt) / (2 * a); + if (t1 >= 0 && t1 <= 1) { + extrema[n++] = t1; + } + if (t2 >= 0 && t2 <= 1) { + extrema[n++] = t2; + } + } + } + return n; + } + + /** + * 细分三次贝塞尔曲线 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @param {Array.} out + */ + function cubicSubdivide(p0, p1, p2, p3, t, out) { + var p01 = (p1 - p0) * t + p0; + var p12 = (p2 - p1) * t + p1; + var p23 = (p3 - p2) * t + p2; + + var p012 = (p12 - p01) * t + p01; + var p123 = (p23 - p12) * t + p12; + + var p0123 = (p123 - p012) * t + p012; + // Seg0 + out[0] = p0; + out[1] = p01; + out[2] = p012; + out[3] = p0123; + // Seg1 + out[4] = p0123; + out[5] = p123; + out[6] = p23; + out[7] = p3; + } + + /** + * 投射点到三次贝塞尔曲线上,返回投射距离。 + * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x3 + * @param {number} y3 + * @param {number} x + * @param {number} y + * @param {Array.} [out] 投射点 + * @return {number} + */ + function cubicProjectPoint( + x0, y0, x1, y1, x2, y2, x3, y3, + x, y, out + ) { + // http://pomax.github.io/bezierinfo/#projections + var t; + var interval = 0.005; + var d = Infinity; + var prev; + var next; + var d1; + var d2; + + _v0[0] = x; + _v0[1] = y; + + // 先粗略估计一下可能的最小距离的 t 值 + // PENDING + for (var _t = 0; _t < 1; _t += 0.05) { + _v1[0] = cubicAt(x0, x1, x2, x3, _t); + _v1[1] = cubicAt(y0, y1, y2, y3, _t); + d1 = v2DistSquare(_v0, _v1); + if (d1 < d) { + t = _t; + d = d1; + } + } + d = Infinity; + + // At most 32 iteration + for (var i = 0; i < 32; i++) { + if (interval < EPSILON) { + break; + } + prev = t - interval; + next = t + interval; + // t - interval + _v1[0] = cubicAt(x0, x1, x2, x3, prev); + _v1[1] = cubicAt(y0, y1, y2, y3, prev); + + d1 = v2DistSquare(_v1, _v0); + + if (prev >= 0 && d1 < d) { + t = prev; + d = d1; + } + else { + // t + interval + _v2[0] = cubicAt(x0, x1, x2, x3, next); + _v2[1] = cubicAt(y0, y1, y2, y3, next); + d2 = v2DistSquare(_v2, _v0); + + if (next <= 1 && d2 < d) { + t = next; + d = d2; + } + else { + interval *= 0.5; + } + } + } + // t + if (out) { + out[0] = cubicAt(x0, x1, x2, x3, t); + out[1] = cubicAt(y0, y1, y2, y3, t); + } + // console.log(interval, i); + return mathSqrt(d); + } + + /** + * 计算二次方贝塞尔值 + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} t + * @return {number} + */ + function quadraticAt(p0, p1, p2, t) { + var onet = 1 - t; + return onet * (onet * p0 + 2 * t * p1) + t * t * p2; + } + + /** + * 计算二次方贝塞尔导数值 + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} t + * @return {number} + */ + function quadraticDerivativeAt(p0, p1, p2, t) { + return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1)); + } + + /** + * 计算二次方贝塞尔方程根 + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} t + * @param {Array.} roots + * @return {number} 有效根数目 + */ + function quadraticRootAt(p0, p1, p2, val, roots) { + var a = p0 - 2 * p1 + p2; + var b = 2 * (p1 - p0); + var c = p0 - val; + + var n = 0; + if (isAroundZero(a)) { + if (isNotAroundZero(b)) { + var t1 = -c / b; + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + } + } + else { + var disc = b * b - 4 * a * c; + if (isAroundZero(disc)) { + var t1 = -b / (2 * a); + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + } + else if (disc > 0) { + var discSqrt = mathSqrt(disc); + var t1 = (-b + discSqrt) / (2 * a); + var t2 = (-b - discSqrt) / (2 * a); + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + if (t2 >= 0 && t2 <= 1) { + roots[n++] = t2; + } + } + } + return n; + } + + /** + * 计算二次贝塞尔方程极限值 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @return {number} + */ + function quadraticExtremum(p0, p1, p2) { + var divider = p0 + p2 - 2 * p1; + if (divider === 0) { + // p1 is center of p0 and p2 + return 0.5; + } + else { + return (p0 - p1) / divider; + } + } + + /** + * 细分二次贝塞尔曲线 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} t + * @param {Array.} out + */ + function quadraticSubdivide(p0, p1, p2, t, out) { + var p01 = (p1 - p0) * t + p0; + var p12 = (p2 - p1) * t + p1; + var p012 = (p12 - p01) * t + p01; + + // Seg0 + out[0] = p0; + out[1] = p01; + out[2] = p012; + + // Seg1 + out[3] = p012; + out[4] = p12; + out[5] = p2; + } + + /** + * 投射点到二次贝塞尔曲线上,返回投射距离。 + * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x + * @param {number} y + * @param {Array.} out 投射点 + * @return {number} + */ + function quadraticProjectPoint( + x0, y0, x1, y1, x2, y2, + x, y, out + ) { + // http://pomax.github.io/bezierinfo/#projections + var t; + var interval = 0.005; + var d = Infinity; + + _v0[0] = x; + _v0[1] = y; + + // 先粗略估计一下可能的最小距离的 t 值 + // PENDING + for (var _t = 0; _t < 1; _t += 0.05) { + _v1[0] = quadraticAt(x0, x1, x2, _t); + _v1[1] = quadraticAt(y0, y1, y2, _t); + var d1 = v2DistSquare(_v0, _v1); + if (d1 < d) { + t = _t; + d = d1; + } + } + d = Infinity; + + // At most 32 iteration + for (var i = 0; i < 32; i++) { + if (interval < EPSILON) { + break; + } + var prev = t - interval; + var next = t + interval; + // t - interval + _v1[0] = quadraticAt(x0, x1, x2, prev); + _v1[1] = quadraticAt(y0, y1, y2, prev); + + var d1 = v2DistSquare(_v1, _v0); + + if (prev >= 0 && d1 < d) { + t = prev; + d = d1; + } + else { + // t + interval + _v2[0] = quadraticAt(x0, x1, x2, next); + _v2[1] = quadraticAt(y0, y1, y2, next); + var d2 = v2DistSquare(_v2, _v0); + if (next <= 1 && d2 < d) { + t = next; + d = d2; + } + else { + interval *= 0.5; + } + } + } + // t + if (out) { + out[0] = quadraticAt(x0, x1, x2, t); + out[1] = quadraticAt(y0, y1, y2, t); + } + // console.log(interval, i); + return mathSqrt(d); + } + + module.exports = { + + cubicAt: cubicAt, + + cubicDerivativeAt: cubicDerivativeAt, + + cubicRootAt: cubicRootAt, + + cubicExtrema: cubicExtrema, + + cubicSubdivide: cubicSubdivide, + + cubicProjectPoint: cubicProjectPoint, + + quadraticAt: quadraticAt, + + quadraticDerivativeAt: quadraticDerivativeAt, + + quadraticRootAt: quadraticRootAt, + + quadraticExtremum: quadraticExtremum, + + quadraticSubdivide: quadraticSubdivide, + + quadraticProjectPoint: quadraticProjectPoint + }; + + +/***/ }, +/* 50 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @author Yi Shen(https://github.com/pissang) + */ + + + var vec2 = __webpack_require__(16); + var curve = __webpack_require__(49); + + var bbox = {}; + var mathMin = Math.min; + var mathMax = Math.max; + var mathSin = Math.sin; + var mathCos = Math.cos; + + var start = vec2.create(); + var end = vec2.create(); + var extremity = vec2.create(); + + var PI2 = Math.PI * 2; + /** + * 从顶点数组中计算出最小包围盒,写入`min`和`max`中 + * @module zrender/core/bbox + * @param {Array} points 顶点数组 + * @param {number} min + * @param {number} max + */ + bbox.fromPoints = function(points, min, max) { + if (points.length === 0) { + return; + } + var p = points[0]; + var left = p[0]; + var right = p[0]; + var top = p[1]; + var bottom = p[1]; + var i; + + for (i = 1; i < points.length; i++) { + p = points[i]; + left = mathMin(left, p[0]); + right = mathMax(right, p[0]); + top = mathMin(top, p[1]); + bottom = mathMax(bottom, p[1]); + } + + min[0] = left; + min[1] = top; + max[0] = right; + max[1] = bottom; + }; + + /** + * @memberOf module:zrender/core/bbox + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {Array.} min + * @param {Array.} max + */ + bbox.fromLine = function (x0, y0, x1, y1, min, max) { + min[0] = mathMin(x0, x1); + min[1] = mathMin(y0, y1); + max[0] = mathMax(x0, x1); + max[1] = mathMax(y0, y1); + }; + + /** + * 从三阶贝塞尔曲线(p0, p1, p2, p3)中计算出最小包围盒,写入`min`和`max`中 + * @memberOf module:zrender/core/bbox + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x3 + * @param {number} y3 + * @param {Array.} min + * @param {Array.} max + */ + bbox.fromCubic = function( + x0, y0, x1, y1, x2, y2, x3, y3, min, max + ) { + var xDim = []; + var yDim = []; + var cubicExtrema = curve.cubicExtrema; + var cubicAt = curve.cubicAt; + var left, right, top, bottom; + var i; + var n = cubicExtrema(x0, x1, x2, x3, xDim); + + for (i = 0; i < n; i++) { + xDim[i] = cubicAt(x0, x1, x2, x3, xDim[i]); + } + n = cubicExtrema(y0, y1, y2, y3, yDim); + for (i = 0; i < n; i++) { + yDim[i] = cubicAt(y0, y1, y2, y3, yDim[i]); + } + + xDim.push(x0, x3); + yDim.push(y0, y3); + + left = mathMin.apply(null, xDim); + right = mathMax.apply(null, xDim); + top = mathMin.apply(null, yDim); + bottom = mathMax.apply(null, yDim); + + min[0] = left; + min[1] = top; + max[0] = right; + max[1] = bottom; + }; + + /** + * 从二阶贝塞尔曲线(p0, p1, p2)中计算出最小包围盒,写入`min`和`max`中 + * @memberOf module:zrender/core/bbox + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {Array.} min + * @param {Array.} max + */ + bbox.fromQuadratic = function(x0, y0, x1, y1, x2, y2, min, max) { + var quadraticExtremum = curve.quadraticExtremum; + var quadraticAt = curve.quadraticAt; + // Find extremities, where derivative in x dim or y dim is zero + var tx = + mathMax( + mathMin(quadraticExtremum(x0, x1, x2), 1), 0 + ); + var ty = + mathMax( + mathMin(quadraticExtremum(y0, y1, y2), 1), 0 + ); + + var x = quadraticAt(x0, x1, x2, tx); + var y = quadraticAt(y0, y1, y2, ty); + + min[0] = mathMin(x0, x2, x); + min[1] = mathMin(y0, y2, y); + max[0] = mathMax(x0, x2, x); + max[1] = mathMax(y0, y2, y); + }; + + /** + * 从圆弧中计算出最小包围盒,写入`min`和`max`中 + * @method + * @memberOf module:zrender/core/bbox + * @param {number} x + * @param {number} y + * @param {number} rx + * @param {number} ry + * @param {number} startAngle + * @param {number} endAngle + * @param {number} anticlockwise + * @param {Array.} min + * @param {Array.} max + */ + bbox.fromArc = function ( + x, y, rx, ry, startAngle, endAngle, anticlockwise, min, max + ) { + var vec2Min = vec2.min; + var vec2Max = vec2.max; + + var diff = Math.abs(startAngle - endAngle); + + + if (diff % PI2 < 1e-4 && diff > 1e-4) { + // Is a circle + min[0] = x - rx; + min[1] = y - ry; + max[0] = x + rx; + max[1] = y + ry; + return; + } + + start[0] = mathCos(startAngle) * rx + x; + start[1] = mathSin(startAngle) * ry + y; + + end[0] = mathCos(endAngle) * rx + x; + end[1] = mathSin(endAngle) * ry + y; + + vec2Min(min, start, end); + vec2Max(max, start, end); + + // Thresh to [0, Math.PI * 2] + startAngle = startAngle % (PI2); + if (startAngle < 0) { + startAngle = startAngle + PI2; + } + endAngle = endAngle % (PI2); + if (endAngle < 0) { + endAngle = endAngle + PI2; + } + + if (startAngle > endAngle && !anticlockwise) { + endAngle += PI2; + } + else if (startAngle < endAngle && anticlockwise) { + startAngle += PI2; + } + if (anticlockwise) { + var tmp = endAngle; + endAngle = startAngle; + startAngle = tmp; + } + + // var number = 0; + // var step = (anticlockwise ? -Math.PI : Math.PI) / 2; + for (var angle = 0; angle < endAngle; angle += Math.PI / 2) { + if (angle > startAngle) { + extremity[0] = mathCos(angle) * rx + x; + extremity[1] = mathSin(angle) * ry + y; + + vec2Min(min, extremity, min); + vec2Max(max, extremity, max); + } + } + }; + + module.exports = bbox; + + + +/***/ }, +/* 51 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var CMD = __webpack_require__(48).CMD; + var line = __webpack_require__(52); + var cubic = __webpack_require__(53); + var quadratic = __webpack_require__(54); + var arc = __webpack_require__(55); + var normalizeRadian = __webpack_require__(56).normalizeRadian; + var curve = __webpack_require__(49); + + var windingLine = __webpack_require__(57); + + var containStroke = line.containStroke; + + var PI2 = Math.PI * 2; + + var EPSILON = 1e-4; + + function isAroundEqual(a, b) { + return Math.abs(a - b) < EPSILON; + } + + // 临时数组 + var roots = [-1, -1, -1]; + var extrema = [-1, -1]; + + function swapExtrema() { + var tmp = extrema[0]; + extrema[0] = extrema[1]; + extrema[1] = tmp; + } + + function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) { + // Quick reject + if ( + (y > y0 && y > y1 && y > y2 && y > y3) + || (y < y0 && y < y1 && y < y2 && y < y3) + ) { + return 0; + } + var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots); + if (nRoots === 0) { + return 0; + } + else { + var w = 0; + var nExtrema = -1; + var y0_, y1_; + for (var i = 0; i < nRoots; i++) { + var t = roots[i]; + var x_ = curve.cubicAt(x0, x1, x2, x3, t); + if (x_ < x) { // Quick reject + continue; + } + if (nExtrema < 0) { + nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema); + if (extrema[1] < extrema[0] && nExtrema > 1) { + swapExtrema(); + } + y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]); + if (nExtrema > 1) { + y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]); + } + } + if (nExtrema == 2) { + // 分成三段单调函数 + if (t < extrema[0]) { + w += y0_ < y0 ? 1 : -1; + } + else if (t < extrema[1]) { + w += y1_ < y0_ ? 1 : -1; + } + else { + w += y3 < y1_ ? 1 : -1; + } + } + else { + // 分成两段单调函数 + if (t < extrema[0]) { + w += y0_ < y0 ? 1 : -1; + } + else { + w += y3 < y0_ ? 1 : -1; + } + } + } + return w; + } + } + + function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) { + // Quick reject + if ( + (y > y0 && y > y1 && y > y2) + || (y < y0 && y < y1 && y < y2) + ) { + return 0; + } + var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots); + if (nRoots === 0) { + return 0; + } + else { + var t = curve.quadraticExtremum(y0, y1, y2); + if (t >=0 && t <= 1) { + var w = 0; + var y_ = curve.quadraticAt(y0, y1, y2, t); + for (var i = 0; i < nRoots; i++) { + var x_ = curve.quadraticAt(x0, x1, x2, roots[i]); + if (x_ > x) { + continue; + } + if (roots[i] < t) { + w += y_ < y0 ? 1 : -1; + } + else { + w += y2 < y_ ? 1 : -1; + } + } + return w; + } + else { + var x_ = curve.quadraticAt(x0, x1, x2, roots[0]); + if (x_ > x) { + return 0; + } + return y2 < y0 ? 1 : -1; + } + } + } + + // TODO + // Arc 旋转 + function windingArc( + cx, cy, r, startAngle, endAngle, anticlockwise, x, y + ) { + y -= cy; + if (y > r || y < -r) { + return 0; + } + var tmp = Math.sqrt(r * r - y * y); + roots[0] = -tmp; + roots[1] = tmp; + + var diff = Math.abs(startAngle - endAngle); + if (diff < 1e-4) { + return 0; + } + if (diff % PI2 < 1e-4) { + // Is a circle + startAngle = 0; + endAngle = PI2; + var dir = anticlockwise ? 1 : -1; + if (x >= roots[0] + cx && x <= roots[1] + cx) { + return dir; + } else { + return 0; + } + } + + if (anticlockwise) { + var tmp = startAngle; + startAngle = normalizeRadian(endAngle); + endAngle = normalizeRadian(tmp); + } + else { + startAngle = normalizeRadian(startAngle); + endAngle = normalizeRadian(endAngle); + } + if (startAngle > endAngle) { + endAngle += PI2; + } + + var w = 0; + for (var i = 0; i < 2; i++) { + var x_ = roots[i]; + if (x_ + cx > x) { + var angle = Math.atan2(y, x_); + var dir = anticlockwise ? 1 : -1; + if (angle < 0) { + angle = PI2 + angle; + } + if ( + (angle >= startAngle && angle <= endAngle) + || (angle + PI2 >= startAngle && angle + PI2 <= endAngle) + ) { + if (angle > Math.PI / 2 && angle < Math.PI * 1.5) { + dir = -dir; + } + w += dir; + } + } + } + return w; + } + + function containPath(data, lineWidth, isStroke, x, y) { + var w = 0; + var xi = 0; + var yi = 0; + var x0 = 0; + var y0 = 0; + + for (var i = 0; i < data.length;) { + var cmd = data[i++]; + // Begin a new subpath + if (cmd === CMD.M && i > 1) { + // Close previous subpath + if (!isStroke) { + w += windingLine(xi, yi, x0, y0, x, y); + } + // 如果被任何一个 subpath 包含 + if (w !== 0) { + return true; + } + } + + if (i == 1) { + // 如果第一个命令是 L, C, Q + // 则 previous point 同绘制命令的第一个 point + // + // 第一个命令为 Arc 的情况下会在后面特殊处理 + xi = data[i]; + yi = data[i + 1]; + + x0 = xi; + y0 = yi; + } + + switch (cmd) { + case CMD.M: + // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点 + // 在 closePath 的时候使用 + x0 = data[i++]; + y0 = data[i++]; + xi = x0; + yi = y0; + break; + case CMD.L: + if (isStroke) { + if (containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) { + return true; + } + } + else { + // NOTE 在第一个命令为 L, C, Q 的时候会计算出 NaN + w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0; + } + xi = data[i++]; + yi = data[i++]; + break; + case CMD.C: + if (isStroke) { + if (cubic.containStroke(xi, yi, + data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], + lineWidth, x, y + )) { + return true; + } + } + else { + w += windingCubic( + xi, yi, + data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], + x, y + ) || 0; + } + xi = data[i++]; + yi = data[i++]; + break; + case CMD.Q: + if (isStroke) { + if (quadratic.containStroke(xi, yi, + data[i++], data[i++], data[i], data[i + 1], + lineWidth, x, y + )) { + return true; + } + } + else { + w += windingQuadratic( + xi, yi, + data[i++], data[i++], data[i], data[i + 1], + x, y + ) || 0; + } + xi = data[i++]; + yi = data[i++]; + break; + case CMD.A: + // TODO Arc 判断的开销比较大 + var cx = data[i++]; + var cy = data[i++]; + var rx = data[i++]; + var ry = data[i++]; + var theta = data[i++]; + var dTheta = data[i++]; + // TODO Arc 旋转 + var psi = data[i++]; + var anticlockwise = 1 - data[i++]; + var x1 = Math.cos(theta) * rx + cx; + var y1 = Math.sin(theta) * ry + cy; + // 不是直接使用 arc 命令 + if (i > 1) { + w += windingLine(xi, yi, x1, y1, x, y); + } + else { + // 第一个命令起点还未定义 + x0 = x1; + y0 = y1; + } + // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放 + var _x = (x - cx) * ry / rx + cx; + if (isStroke) { + if (arc.containStroke( + cx, cy, ry, theta, theta + dTheta, anticlockwise, + lineWidth, _x, y + )) { + return true; + } + } + else { + w += windingArc( + cx, cy, ry, theta, theta + dTheta, anticlockwise, + _x, y + ); + } + xi = Math.cos(theta + dTheta) * rx + cx; + yi = Math.sin(theta + dTheta) * ry + cy; + break; + case CMD.R: + x0 = xi = data[i++]; + y0 = yi = data[i++]; + var width = data[i++]; + var height = data[i++]; + var x1 = x0 + width; + var y1 = y0 + height; + if (isStroke) { + if (containStroke(x0, y0, x1, y0, lineWidth, x, y) + || containStroke(x1, y0, x1, y1, lineWidth, x, y) + || containStroke(x1, y1, x0, y1, lineWidth, x, y) + || containStroke(x0, y1, x1, y1, lineWidth, x, y) + ) { + return true; + } + } + else { + // FIXME Clockwise ? + w += windingLine(x1, y0, x1, y1, x, y); + w += windingLine(x0, y1, x0, y0, x, y); + } + break; + case CMD.Z: + if (isStroke) { + if (containStroke( + xi, yi, x0, y0, lineWidth, x, y + )) { + return true; + } + } + else { + // Close a subpath + w += windingLine(xi, yi, x0, y0, x, y); + // 如果被任何一个 subpath 包含 + if (w !== 0) { + return true; + } + } + xi = x0; + yi = y0; + break; + } + } + if (!isStroke && !isAroundEqual(yi, y0)) { + w += windingLine(xi, yi, x0, y0, x, y) || 0; + } + return w !== 0; + } + + module.exports = { + contain: function (pathData, x, y) { + return containPath(pathData, 0, false, x, y); + }, + + containStroke: function (pathData, lineWidth, x, y) { + return containPath(pathData, lineWidth, true, x, y); + } + }; + + +/***/ }, +/* 52 */ +/***/ function(module, exports) { + + + module.exports = { + /** + * 线段包含判断 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} lineWidth + * @param {number} x + * @param {number} y + * @return {boolean} + */ + containStroke: function (x0, y0, x1, y1, lineWidth, x, y) { + if (lineWidth === 0) { + return false; + } + var _l = lineWidth; + var _a = 0; + var _b = x0; + // Quick reject + 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) + ) { + return false; + } + + if (x0 !== x1) { + _a = (y0 - y1) / (x0 - x1); + _b = (x0 * y1 - x1 * y0) / (x0 - x1) ; + } + else { + return Math.abs(x - x0) <= _l / 2; + } + var tmp = _a * x - y + _b; + var _s = tmp * tmp / (_a * _a + 1); + return _s <= _l / 2 * _l / 2; + } + }; + + +/***/ }, +/* 53 */ +/***/ function(module, exports, __webpack_require__) { + + + + var curve = __webpack_require__(49); + + module.exports = { + /** + * 三次贝塞尔曲线描边包含判断 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x3 + * @param {number} y3 + * @param {number} lineWidth + * @param {number} x + * @param {number} y + * @return {boolean} + */ + containStroke: function(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) { + if (lineWidth === 0) { + return false; + } + var _l = lineWidth; + // Quick reject + 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) + ) { + return false; + } + var d = curve.cubicProjectPoint( + x0, y0, x1, y1, x2, y2, x3, y3, + x, y, null + ); + return d <= _l / 2; + } + }; + + +/***/ }, +/* 54 */ +/***/ function(module, exports, __webpack_require__) { + + + + var curve = __webpack_require__(49); + + module.exports = { + /** + * 二次贝塞尔曲线描边包含判断 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} lineWidth + * @param {number} x + * @param {number} y + * @return {boolean} + */ + containStroke: function (x0, y0, x1, y1, x2, y2, lineWidth, x, y) { + if (lineWidth === 0) { + return false; + } + var _l = lineWidth; + // Quick reject + 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) + ) { + return false; + } + var d = curve.quadraticProjectPoint( + x0, y0, x1, y1, x2, y2, + x, y, null + ); + return d <= _l / 2; + } + }; + + +/***/ }, +/* 55 */ +/***/ function(module, exports, __webpack_require__) { + + + + var normalizeRadian = __webpack_require__(56).normalizeRadian; + var PI2 = Math.PI * 2; + + module.exports = { + /** + * 圆弧描边包含判断 + * @param {number} cx + * @param {number} cy + * @param {number} r + * @param {number} startAngle + * @param {number} endAngle + * @param {boolean} anticlockwise + * @param {number} lineWidth + * @param {number} x + * @param {number} y + * @return {Boolean} + */ + containStroke: function ( + cx, cy, r, startAngle, endAngle, anticlockwise, + lineWidth, x, y + ) { + + if (lineWidth === 0) { + return false; + } + var _l = lineWidth; + + x -= cx; + y -= cy; + var d = Math.sqrt(x * x + y * y); + + if ((d - _l > r) || (d + _l < r)) { + return false; + } + if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) { + // Is a circle + return true; + } + if (anticlockwise) { + var tmp = startAngle; + startAngle = normalizeRadian(endAngle); + endAngle = normalizeRadian(tmp); + } else { + startAngle = normalizeRadian(startAngle); + endAngle = normalizeRadian(endAngle); + } + if (startAngle > endAngle) { + endAngle += PI2; + } + + var angle = Math.atan2(y, x); + if (angle < 0) { + angle += PI2; + } + return (angle >= startAngle && angle <= endAngle) + || (angle + PI2 >= startAngle && angle + PI2 <= endAngle); + } + }; + + +/***/ }, +/* 56 */ +/***/ function(module, exports) { + + + + var PI2 = Math.PI * 2; + module.exports = { + normalizeRadian: function(angle) { + angle %= PI2; + if (angle < 0) { + angle += PI2; + } + return angle; + } + }; + + +/***/ }, +/* 57 */ +/***/ function(module, exports) { + + + module.exports = function windingLine(x0, y0, x1, y1, x, y) { + if ((y > y0 && y > y1) || (y < y0 && y < y1)) { + return 0; + } + if (y1 === y0) { + return 0; + } + var dir = y1 < y0 ? 1 : -1; + var t = (y - y0) / (y1 - y0); + var x_ = t * (x1 - x0) + x0; + + return x_ > x ? dir : 0; + }; + + +/***/ }, +/* 58 */ +/***/ function(module, exports, __webpack_require__) { + + + + var CMD = __webpack_require__(48).CMD; + var vec2 = __webpack_require__(16); + var v2ApplyTransform = vec2.applyTransform; + + var points = [[], [], []]; + var mathSqrt = Math.sqrt; + var mathAtan2 = Math.atan2; + function transformPath(path, m) { + var data = path.data; + var cmd; + var nPoint; + var i; + var j; + var k; + var p; + + var M = CMD.M; + var C = CMD.C; + var L = CMD.L; + var R = CMD.R; + var A = CMD.A; + var Q = CMD.Q; + + for (i = 0, j = 0; i < data.length;) { + cmd = data[i++]; + j = i; + nPoint = 0; + + switch (cmd) { + case M: + nPoint = 1; + break; + case L: + nPoint = 1; + break; + case C: + nPoint = 3; + break; + case Q: + nPoint = 2; + break; + case A: + var x = m[4]; + var y = m[5]; + var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]); + var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]); + var angle = mathAtan2(-m[1] / sy, m[0] / sx); + // cx + data[i++] += x; + // cy + data[i++] += y; + // Scale rx and ry + // FIXME Assume psi is 0 here + data[i++] *= sx; + data[i++] *= sy; + + // Start angle + data[i++] += angle; + // end angle + data[i++] += angle; + // FIXME psi + i += 2; + j = i; + break; + case R: + // x0, y0 + p[0] = data[i++]; + p[1] = data[i++]; + v2ApplyTransform(p, p, m); + data[j++] = p[0]; + data[j++] = p[1]; + // x1, y1 + p[0] += data[i++]; + p[1] += data[i++]; + v2ApplyTransform(p, p, m); + data[j++] = p[0]; + data[j++] = p[1]; + } + + for (k = 0; k < nPoint; k++) { + var p = points[k]; + p[0] = data[i++]; + p[1] = data[i++]; + + v2ApplyTransform(p, p, m); + // Write back + data[j++] = p[0]; + data[j++] = p[1]; + } + } + } + + module.exports = transformPath; + + +/***/ }, +/* 59 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Image element + * @module zrender/graphic/Image + */ + + + + var Displayable = __webpack_require__(45); + var BoundingRect = __webpack_require__(15); + var zrUtil = __webpack_require__(3); + var roundRectHelper = __webpack_require__(60); + + var LRU = __webpack_require__(61); + var globalImageCache = new LRU(50); + /** + * @alias zrender/graphic/Image + * @extends module:zrender/graphic/Displayable + * @constructor + * @param {Object} opts + */ + var ZImage = function (opts) { + Displayable.call(this, opts); + }; + + ZImage.prototype = { + + constructor: ZImage, + + type: 'image', + + brush: function (ctx) { + var style = this.style; + var src = style.image; + var image; + // style.image is a url string + if (typeof src === 'string') { + image = this._image; + } + // style.image is an HTMLImageElement or HTMLCanvasElement or Canvas + else { + image = src; + } + // FIXME Case create many images with src + if (!image && src) { + // Try get from global image cache + var cachedImgObj = globalImageCache.get(src); + if (!cachedImgObj) { + // Create a new image + image = new Image(); + image.onload = function () { + image.onload = null; + for (var i = 0; i < cachedImgObj.pending.length; i++) { + cachedImgObj.pending[i].dirty(); + } + }; + cachedImgObj = { + image: image, + pending: [this] + }; + image.src = src; + globalImageCache.put(src, cachedImgObj); + this._image = image; + return; + } + else { + image = cachedImgObj.image; + this._image = image; + // Image is not complete finish, add to pending list + if (!image.width || !image.height) { + cachedImgObj.pending.push(this); + return; + } + } + } + + if (image) { + // 图片已经加载完成 + // if (image.nodeName.toUpperCase() == 'IMG') { + // if (!image.complete) { + // return; + // } + // } + // Else is canvas + + var width = style.width || image.width; + var height = style.height || image.height; + var x = style.x || 0; + var y = style.y || 0; + // 图片加载失败 + if (!image.width || !image.height) { + return; + } + + ctx.save(); + + style.bind(ctx); + + // 设置transform + this.setTransform(ctx); + + if (style.r) { + // Border radius clipping + // FIXME + ctx.beginPath(); + roundRectHelper.buildPath(ctx, style); + ctx.clip(); + } + + if (style.sWidth && style.sHeight) { + var sx = style.sx || 0; + var sy = style.sy || 0; + ctx.drawImage( + image, + sx, sy, style.sWidth, style.sHeight, + x, y, width, height + ); + } + else if (style.sx && style.sy) { + var sx = style.sx; + var sy = style.sy; + var sWidth = width - sx; + var sHeight = height - sy; + ctx.drawImage( + image, + sx, sy, sWidth, sHeight, + x, y, width, height + ); + } + else { + ctx.drawImage(image, x, y, width, height); + } + + // 如果没设置宽和高的话自动根据图片宽高设置 + if (style.width == null) { + style.width = width; + } + if (style.height == null) { + style.height = height; + } + + // Draw rect text + if (style.text != null) { + this.drawRectText(ctx, this.getBoundingRect()); + } + + ctx.restore(); + } + }, + + getBoundingRect: function () { + var style = this.style; + if (! this._rect) { + this._rect = new BoundingRect( + style.x || 0, style.y || 0, style.width || 0, style.height || 0 + ); + } + return this._rect; + } + }; + + zrUtil.inherits(ZImage, Displayable); + + module.exports = ZImage; + + +/***/ }, +/* 60 */ +/***/ function(module, exports) { + + + + module.exports = { + buildPath: function (ctx, shape) { + var x = shape.x; + var y = shape.y; + var width = shape.width; + var height = shape.height; + var r = shape.r; + var r1; + var r2; + var r3; + var r4; + + // Convert width and height to positive for better borderRadius + if (width < 0) { + x = x + width; + width = -width; + } + if (height < 0) { + y = y + height; + height = -height; + } + + if (typeof r === 'number') { + r1 = r2 = r3 = r4 = r; + } + else if (r instanceof Array) { + if (r.length === 1) { + r1 = r2 = r3 = r4 = r[0]; + } + else if (r.length === 2) { + r1 = r3 = r[0]; + r2 = r4 = r[1]; + } + else if (r.length === 3) { + r1 = r[0]; + r2 = r4 = r[1]; + r3 = r[2]; + } + else { + r1 = r[0]; + r2 = r[1]; + r3 = r[2]; + r4 = r[3]; + } + } + else { + r1 = r2 = r3 = r4 = 0; + } + + var total; + if (r1 + r2 > width) { + total = r1 + r2; + r1 *= width / total; + r2 *= width / total; + } + if (r3 + r4 > width) { + total = r3 + r4; + r3 *= width / total; + r4 *= width / total; + } + if (r2 + r3 > height) { + total = r2 + r3; + r2 *= height / total; + r3 *= height / total; + } + if (r1 + r4 > height) { + total = r1 + r4; + r1 *= height / total; + r4 *= height / total; + } + ctx.moveTo(x + r1, y); + ctx.lineTo(x + width - r2, y); + r2 !== 0 && ctx.quadraticCurveTo( + x + width, y, x + width, y + r2 + ); + ctx.lineTo(x + width, y + height - r3); + r3 !== 0 && ctx.quadraticCurveTo( + x + width, y + height, x + width - r3, y + height + ); + ctx.lineTo(x + r4, y + height); + r4 !== 0 && ctx.quadraticCurveTo( + x, y + height, x, y + height - r4 + ); + ctx.lineTo(x, y + r1); + r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y); + } + }; + + +/***/ }, +/* 61 */ +/***/ function(module, exports) { + + // Simple LRU cache use doubly linked list + // @module zrender/core/LRU + + + /** + * Simple double linked list. Compared with array, it has O(1) remove operation. + * @constructor + */ + var LinkedList = function() { + + /** + * @type {module:zrender/core/LRU~Entry} + */ + this.head = null; + + /** + * @type {module:zrender/core/LRU~Entry} + */ + this.tail = null; + + this._len = 0; + }; + + var linkedListProto = LinkedList.prototype; + /** + * Insert a new value at the tail + * @param {} val + * @return {module:zrender/core/LRU~Entry} + */ + linkedListProto.insert = function(val) { + var entry = new Entry(val); + this.insertEntry(entry); + return entry; + }; + + /** + * Insert an entry at the tail + * @param {module:zrender/core/LRU~Entry} entry + */ + linkedListProto.insertEntry = function(entry) { + if (!this.head) { + this.head = this.tail = entry; + } + else { + this.tail.next = entry; + entry.prev = this.tail; + this.tail = entry; + } + this._len++; + }; + + /** + * Remove entry. + * @param {module:zrender/core/LRU~Entry} entry + */ + linkedListProto.remove = function(entry) { + var prev = entry.prev; + var next = entry.next; + if (prev) { + prev.next = next; + } + else { + // Is head + this.head = next; + } + if (next) { + next.prev = prev; + } + else { + // Is tail + this.tail = prev; + } + entry.next = entry.prev = null; + this._len--; + }; + + /** + * @return {number} + */ + linkedListProto.len = function() { + return this._len; + }; + + /** + * @constructor + * @param {} val + */ + var Entry = function(val) { + /** + * @type {} + */ + this.value = val; + + /** + * @type {module:zrender/core/LRU~Entry} + */ + this.next; + + /** + * @type {module:zrender/core/LRU~Entry} + */ + this.prev; + }; + + /** + * LRU Cache + * @constructor + * @alias module:zrender/core/LRU + */ + var LRU = function(maxSize) { + + this._list = new LinkedList(); + + this._map = {}; + + this._maxSize = maxSize || 10; + }; + + var LRUProto = LRU.prototype; + + /** + * @param {string} key + * @param {} value + */ + LRUProto.put = function(key, value) { + var list = this._list; + var map = this._map; + if (map[key] == null) { + var len = list.len(); + if (len >= this._maxSize && len > 0) { + // Remove the least recently used + var leastUsedEntry = list.head; + list.remove(leastUsedEntry); + delete map[leastUsedEntry.key]; + } + + var entry = list.insert(value); + entry.key = key; + map[key] = entry; + } + }; + + /** + * @param {string} key + * @return {} + */ + LRUProto.get = function(key) { + var entry = this._map[key]; + var list = this._list; + if (entry != null) { + // Put the latest used entry in the tail + if (entry !== list.tail) { + list.remove(entry); + list.insertEntry(entry); + } + + return entry.value; + } + }; + + /** + * Clear the cache + */ + LRUProto.clear = function() { + this._list.clear(); + this._map = {}; + }; + + module.exports = LRU; + + +/***/ }, +/* 62 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Text element + * @module zrender/graphic/Text + * + * TODO Wrapping + */ + + + + var Displayable = __webpack_require__(45); + var zrUtil = __webpack_require__(3); + var textContain = __webpack_require__(14); + + /** + * @alias zrender/graphic/Text + * @extends module:zrender/graphic/Displayable + * @constructor + * @param {Object} opts + */ + var Text = function (opts) { + Displayable.call(this, opts); + }; + + Text.prototype = { + + constructor: Text, + + type: 'text', + + brush: function (ctx) { + var style = this.style; + var x = style.x || 0; + var y = style.y || 0; + // Convert to string + var text = style.text; + var textFill = style.fill; + var textStroke = style.stroke; + + // Convert to string + text != null && (text += ''); + + if (text) { + ctx.save(); + + this.style.bind(ctx); + this.setTransform(ctx); + + textFill && (ctx.fillStyle = textFill); + textStroke && (ctx.strokeStyle = textStroke); + + ctx.font = style.textFont || style.font; + ctx.textAlign = style.textAlign; + + if (style.textVerticalAlign) { + var rect = textContain.getBoundingRect( + text, ctx.font, style.textAlign, 'top' + ); + // Ignore textBaseline + ctx.textBaseline = 'top'; + switch (style.textVerticalAlign) { + case 'middle': + y -= rect.height / 2; + break; + case 'bottom': + y -= rect.height; + break; + // 'top' + } + } + else { + ctx.textBaseline = style.textBaseline; + } + var lineHeight = textContain.measureText('国', ctx.font).width; -/** - * 数值处理模块 - * @module echarts/util/number - */ - -define('echarts/util/number',['require'],function (require) { - - var number = {}; - - var RADIAN_EPSILON = 1e-4; - - function _trim(str) { - return str.replace(/^\s+/, '').replace(/\s+$/, ''); - } - - /** - * Linear mapping a value from domain to range - * @memberOf module:echarts/util/number - * @param {(number|Array.)} val - * @param {Array.} domain Domain extent domain[0] can be bigger than domain[1] - * @param {Array.} range Range extent range[0] can be bigger than range[1] - * @param {boolean} clamp - * @return {(number|Array.} - */ - number.linearMap = function (val, domain, range, clamp) { - - var sub = domain[1] - domain[0]; - - if (sub === 0) { - return (range[0] + range[1]) / 2; - } - var t = (val - domain[0]) / sub; - - if (clamp) { - t = Math.min(Math.max(t, 0), 1); - } - - return t * (range[1] - range[0]) + range[0]; - }; - - /** - * Convert a percent string to absolute number. - * Returns NaN if percent is not a valid string or number - * @memberOf module:echarts/util/number - * @param {string|number} percent - * @param {number} all - * @return {number} - */ - number.parsePercent = function(percent, all) { - switch (percent) { - case 'center': - case 'middle': - percent = '50%'; - break; - case 'left': - case 'top': - percent = '0%'; - break; - case 'right': - case 'bottom': - percent = '100%'; - break; - } - if (typeof percent === 'string') { - if (_trim(percent).match(/%$/)) { - return parseFloat(percent) / 100 * all; - } - - return parseFloat(percent); - } - - return percent == null ? NaN : +percent; - }; - - /** - * Fix rounding error of float numbers - * @param {number} x - * @return {number} - */ - number.round = function (x) { - // PENDING - return +(+x).toFixed(12); - }; - - number.asc = function (arr) { - arr.sort(function (a, b) { - return a - b; - }); - return arr; - }; - - /** - * Get precision - * @param {number} val - */ - number.getPrecision = function (val) { - // It is much faster than methods converting number to string as follows - // var tmp = val.toString(); - // return tmp.length - 1 - tmp.indexOf('.'); - // especially when precision is low - var e = 1; - var count = 0; - while (Math.round(val * e) / e !== val) { - e *= 10; - count++; - } - return count; - }; - - /** - * @param {Array.} dataExtent - * @param {Array.} pixelExtent - * @return {number} precision - */ - number.getPixelPrecision = function (dataExtent, pixelExtent) { - var log = Math.log; - var LN10 = Math.LN10; - var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10); - var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10); - return Math.max( - -dataQuantity + sizeQuantity, - 0 - ); - }; - - // Number.MAX_SAFE_INTEGER, ie do not support. - number.MAX_SAFE_INTEGER = 9007199254740991; - - /** - * To 0 - 2 * PI, considering negative radian. - * @param {number} radian - * @return {number} - */ - number.remRadian = function (radian) { - var pi2 = Math.PI * 2; - return (radian % pi2 + pi2) % pi2; - }; - - /** - * @param {type} radian - * @return {boolean} - */ - number.isRadianAroundZero = function (val) { - return val > -RADIAN_EPSILON && val < RADIAN_EPSILON; - }; - - /** - * @param {string|Date|number} value - * @return {number} timestamp - */ - number.parseDate = function (value) { - return value instanceof Date - ? value - : new Date( - typeof value === 'string' - ? value.replace(/-/g, '/') - : Math.round(value) - ); - }; - - return number; -}); -define('echarts/util/format',['require','zrender/core/util','./number'],function (require) { - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('./number'); - - /** - * 每三位默认加,格式化 - * @type {string|number} x - */ - function addCommas(x) { - if (isNaN(x)) { - return '-'; - } - x = (x + '').split('.'); - return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,'$1,') - + (x.length > 1 ? ('.' + x[1]) : ''); - } - - /** - * @param {string} str - * @return {string} str - */ - function toCamelCase(str) { - return str.toLowerCase().replace(/-(.)/g, function(match, group1) { - return group1.toUpperCase(); - }); - } - - /** - * Normalize css liked array configuration - * e.g. - * 3 => [3, 3, 3, 3] - * [4, 2] => [4, 2, 4, 2] - * [4, 3, 2] => [4, 3, 2, 3] - * @param {number|Array.} val - */ - function normalizeCssArray(val) { - var len = val.length; - if (typeof (val) === 'number') { - return [val, val, val, val]; - } - else if (len === 2) { - // vertical | horizontal - return [val[0], val[1], val[0], val[1]]; - } - else if (len === 3) { - // top | horizontal | bottom - return [val[0], val[1], val[2], val[1]]; - } - return val; - } - - function encodeHTML(source) { - return String(source) - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - } - - var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g']; - - function wrapVar(varName, seriesIdx) { - return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}'; - } - /** - * Template formatter - * @param {string} tpl - * @param {Array.|Object} paramsList - * @return {string} - */ - function formatTpl(tpl, paramsList) { - if (!zrUtil.isArray(paramsList)) { - paramsList = [paramsList]; - } - var seriesLen = paramsList.length; - if (!seriesLen) { - return ''; - } - - var $vars = paramsList[0].$vars; - for (var i = 0; i < $vars.length; i++) { - var alias = TPL_VAR_ALIAS[i]; - tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0)); - } - for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) { - for (var k = 0; k < $vars.length; k++) { - tpl = tpl.replace( - wrapVar(TPL_VAR_ALIAS[k], seriesIdx), - paramsList[seriesIdx][$vars[k]] - ); - } - } - - return tpl; - } - - /** - * ISO Date format - * @param {string} tpl - * @param {number} value - * @inner - */ - function formatTime(tpl, value) { - if (tpl === 'week' - || tpl === 'month' - || tpl === 'quarter' - || tpl === 'half-year' - || tpl === 'year' - ) { - tpl = 'MM-dd\nyyyy'; - } - - var date = numberUtil.parseDate(value); - var y = date.getFullYear(); - var M = date.getMonth() + 1; - var d = date.getDate(); - var h = date.getHours(); - var m = date.getMinutes(); - var s = date.getSeconds(); - - tpl = tpl.replace('MM', s2d(M)) - .toLowerCase() - .replace('yyyy', y) - .replace('yy', y % 100) - .replace('dd', s2d(d)) - .replace('d', d) - .replace('hh', s2d(h)) - .replace('h', h) - .replace('mm', s2d(m)) - .replace('m', m) - .replace('ss', s2d(s)) - .replace('s', s); - - return tpl; - } - - /** - * @param {string} str - * @return {string} - * @inner - */ - function s2d(str) { - return str < 10 ? ('0' + str) : str; - } - - return { - - normalizeCssArray: normalizeCssArray, - - addCommas: addCommas, - - toCamelCase: toCamelCase, - - encodeHTML: encodeHTML, - - formatTpl: formatTpl, - - formatTime: formatTime - }; -}); -define('echarts/util/clazz',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - var clazz = {}; - - var TYPE_DELIMITER = '.'; - var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___'; - /** - * @public - */ - var parseClassType = clazz.parseClassType = function (componentType) { - var ret = {main: '', sub: ''}; - if (componentType) { - componentType = componentType.split(TYPE_DELIMITER); - ret.main = componentType[0] || ''; - ret.sub = componentType[1] || ''; - } - return ret; - }; - /** - * @public - */ - clazz.enableClassExtend = function (RootClass, preConstruct) { - RootClass.extend = function (proto) { - var ExtendedClass = function () { - preConstruct && preConstruct.apply(this, arguments); - RootClass.apply(this, arguments); - }; - - zrUtil.extend(ExtendedClass.prototype, proto); - - ExtendedClass.extend = this.extend; - ExtendedClass.superCall = superCall; - ExtendedClass.superApply = superApply; - zrUtil.inherits(ExtendedClass, this); - ExtendedClass.superClass = this; - - return ExtendedClass; - }; - }; - - // superCall should have class info, which can not be fetch from 'this'. - // Consider this case: - // class A has method f, - // class B inherits class A, overrides method f, f call superApply('f'), - // class C inherits class B, do not overrides method f, - // then when method of class C is called, dead loop occured. - function superCall(context, methodName) { - var args = zrUtil.slice(arguments, 2); - return this.superClass.prototype[methodName].apply(context, args); - } - - function superApply(context, methodName, args) { - return this.superClass.prototype[methodName].apply(context, args); - } - - /** - * @param {Object} entity - * @param {Object} options - * @param {boolean} [options.registerWhenExtend] - * @public - */ - clazz.enableClassManagement = function (entity, options) { - options = options || {}; - - /** - * Component model classes - * key: componentType, - * value: - * componentClass, when componentType is 'xxx' - * or Object., when componentType is 'xxx.yy' - * @type {Object} - */ - var storage = {}; - - entity.registerClass = function (Clazz, componentType) { - if (componentType) { - componentType = parseClassType(componentType); - - if (!componentType.sub) { - if (storage[componentType.main]) { - throw new Error(componentType.main + 'exists'); - } - storage[componentType.main] = Clazz; - } - else if (componentType.sub !== IS_CONTAINER) { - var container = makeContainer(componentType); - container[componentType.sub] = Clazz; - } - } - return Clazz; - }; - - entity.getClass = function (componentTypeMain, subType, throwWhenNotFound) { - var Clazz = storage[componentTypeMain]; - - if (Clazz && Clazz[IS_CONTAINER]) { - Clazz = subType ? Clazz[subType] : null; - } - - if (throwWhenNotFound && !Clazz) { - throw new Error( - 'Component ' + componentTypeMain + '.' + (subType || '') + ' not exists' - ); - } - - return Clazz; - }; - - entity.getClassesByMainType = function (componentType) { - componentType = parseClassType(componentType); - - var result = []; - var obj = storage[componentType.main]; - - if (obj && obj[IS_CONTAINER]) { - zrUtil.each(obj, function (o, type) { - type !== IS_CONTAINER && result.push(o); - }); - } - else { - result.push(obj); - } - - return result; - }; - - entity.hasClass = function (componentType) { - // Just consider componentType.main. - componentType = parseClassType(componentType); - return !!storage[componentType.main]; - }; - - /** - * @return {Array.} Like ['aa', 'bb'], but can not be ['aa.xx'] - */ - entity.getAllClassMainTypes = function () { - var types = []; - zrUtil.each(storage, function (obj, type) { - types.push(type); - }); - return types; - }; - - /** - * If a main type is container and has sub types - * @param {string} mainType - * @return {boolean} - */ - entity.hasSubTypes = function (componentType) { - componentType = parseClassType(componentType); - var obj = storage[componentType.main]; - return obj && obj[IS_CONTAINER]; - }; - - entity.parseClassType = parseClassType; - - function makeContainer(componentType) { - var container = storage[componentType.main]; - if (!container || !container[IS_CONTAINER]) { - container = storage[componentType.main] = {}; - container[IS_CONTAINER] = true; - } - return container; - } - - if (options.registerWhenExtend) { - var originalExtend = entity.extend; - if (originalExtend) { - entity.extend = function (proto) { - var ExtendedClass = originalExtend.call(this, proto); - return entity.registerClass(ExtendedClass, proto.type); - }; - } - } - - return entity; - }; - - /** - * @param {string|Array.} properties - */ - clazz.setReadOnly = function (obj, properties) { - // FIXME It seems broken in IE8 simulation of IE11 - // if (!zrUtil.isArray(properties)) { - // properties = properties != null ? [properties] : []; - // } - // zrUtil.each(properties, function (prop) { - // var value = obj[prop]; - - // Object.defineProperty - // && Object.defineProperty(obj, prop, { - // value: value, writable: false - // }); - // zrUtil.isArray(obj[prop]) - // && Object.freeze - // && Object.freeze(obj[prop]); - // }); - }; - - return clazz; -}); -// TODO Parse shadow style -// TODO Only shallow path support -define('echarts/model/mixin/makeStyleMapper',['require','zrender/core/util'],function (require) { - var zrUtil = require('zrender/core/util'); - - return function (properties) { - // Normalize - for (var i = 0; i < properties.length; i++) { - if (!properties[i][1]) { - properties[i][1] = properties[i][0]; - } - } - return function (excludes) { - var style = {}; - for (var i = 0; i < properties.length; i++) { - var propName = properties[i][1]; - if (excludes && zrUtil.indexOf(excludes, propName) >= 0) { - continue; - } - var val = this.getShallow(propName); - if (val != null) { - style[properties[i][0]] = val; - } - } - return style; - }; - }; -}); -define('echarts/model/mixin/lineStyle',['require','./makeStyleMapper'],function (require) { - var getLineStyle = require('./makeStyleMapper')( - [ - ['lineWidth', 'width'], - ['stroke', 'color'], - ['opacity'], - ['shadowBlur'], - ['shadowOffsetX'], - ['shadowOffsetY'], - ['shadowColor'] - ] - ); - return { - getLineStyle: function (excludes) { - var style = getLineStyle.call(this, excludes); - var lineDash = this.getLineDash(); - lineDash && (style.lineDash = lineDash); - return style; - }, - - getLineDash: function () { - var lineType = this.get('type'); - return (lineType === 'solid' || lineType == null) ? null - : (lineType === 'dashed' ? [5, 5] : [1, 1]); - } - }; -}); -define('echarts/model/mixin/areaStyle',['require','./makeStyleMapper'],function (require) { - return { - getAreaStyle: require('./makeStyleMapper')( - [ - ['fill', 'color'], - ['shadowBlur'], - ['shadowOffsetX'], - ['shadowOffsetY'], - ['opacity'], - ['shadowColor'] - ] - ) - }; -}); -define('zrender/core/vector',[],function () { - var ArrayCtor = typeof Float32Array === 'undefined' - ? Array - : Float32Array; - - /** - * @typedef {Float32Array|Array.} Vector2 - */ - /** - * 二维向量类 - * @exports zrender/tool/vector - */ - var vector = { - /** - * 创建一个向量 - * @param {number} [x=0] - * @param {number} [y=0] - * @return {Vector2} - */ - create: function (x, y) { - var out = new ArrayCtor(2); - out[0] = x || 0; - out[1] = y || 0; - return out; - }, - - /** - * 复制向量数据 - * @param {Vector2} out - * @param {Vector2} v - * @return {Vector2} - */ - copy: function (out, v) { - out[0] = v[0]; - out[1] = v[1]; - return out; - }, - - /** - * 克隆一个向量 - * @param {Vector2} v - * @return {Vector2} - */ - clone: function (v) { - var out = new ArrayCtor(2); - out[0] = v[0]; - out[1] = v[1]; - return out; - }, - - /** - * 设置向量的两个项 - * @param {Vector2} out - * @param {number} a - * @param {number} b - * @return {Vector2} 结果 - */ - set: function (out, a, b) { - out[0] = a; - out[1] = b; - return out; - }, - - /** - * 向量相加 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - add: function (out, v1, v2) { - out[0] = v1[0] + v2[0]; - out[1] = v1[1] + v2[1]; - return out; - }, - - /** - * 向量缩放后相加 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - * @param {number} a - */ - scaleAndAdd: function (out, v1, v2, a) { - out[0] = v1[0] + v2[0] * a; - out[1] = v1[1] + v2[1] * a; - return out; - }, - - /** - * 向量相减 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - sub: function (out, v1, v2) { - out[0] = v1[0] - v2[0]; - out[1] = v1[1] - v2[1]; - return out; - }, - - /** - * 向量长度 - * @param {Vector2} v - * @return {number} - */ - len: function (v) { - return Math.sqrt(this.lenSquare(v)); - }, - - /** - * 向量长度平方 - * @param {Vector2} v - * @return {number} - */ - lenSquare: function (v) { - return v[0] * v[0] + v[1] * v[1]; - }, - - /** - * 向量乘法 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - mul: function (out, v1, v2) { - out[0] = v1[0] * v2[0]; - out[1] = v1[1] * v2[1]; - return out; - }, - - /** - * 向量除法 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - div: function (out, v1, v2) { - out[0] = v1[0] / v2[0]; - out[1] = v1[1] / v2[1]; - return out; - }, - - /** - * 向量点乘 - * @param {Vector2} v1 - * @param {Vector2} v2 - * @return {number} - */ - dot: function (v1, v2) { - return v1[0] * v2[0] + v1[1] * v2[1]; - }, - - /** - * 向量缩放 - * @param {Vector2} out - * @param {Vector2} v - * @param {number} s - */ - scale: function (out, v, s) { - out[0] = v[0] * s; - out[1] = v[1] * s; - return out; - }, - - /** - * 向量归一化 - * @param {Vector2} out - * @param {Vector2} v - */ - normalize: function (out, v) { - var d = vector.len(v); - if (d === 0) { - out[0] = 0; - out[1] = 0; - } - else { - out[0] = v[0] / d; - out[1] = v[1] / d; - } - return out; - }, - - /** - * 计算向量间距离 - * @param {Vector2} v1 - * @param {Vector2} v2 - * @return {number} - */ - distance: function (v1, v2) { - return Math.sqrt( - (v1[0] - v2[0]) * (v1[0] - v2[0]) - + (v1[1] - v2[1]) * (v1[1] - v2[1]) - ); - }, - - /** - * 向量距离平方 - * @param {Vector2} v1 - * @param {Vector2} v2 - * @return {number} - */ - distanceSquare: function (v1, v2) { - return (v1[0] - v2[0]) * (v1[0] - v2[0]) - + (v1[1] - v2[1]) * (v1[1] - v2[1]); - }, - - /** - * 求负向量 - * @param {Vector2} out - * @param {Vector2} v - */ - negate: function (out, v) { - out[0] = -v[0]; - out[1] = -v[1]; - return out; - }, - - /** - * 插值两个点 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - * @param {number} t - */ - lerp: function (out, v1, v2, t) { - out[0] = v1[0] + t * (v2[0] - v1[0]); - out[1] = v1[1] + t * (v2[1] - v1[1]); - return out; - }, - - /** - * 矩阵左乘向量 - * @param {Vector2} out - * @param {Vector2} v - * @param {Vector2} m - */ - applyTransform: function (out, v, m) { - var x = v[0]; - var y = v[1]; - out[0] = m[0] * x + m[2] * y + m[4]; - out[1] = m[1] * x + m[3] * y + m[5]; - return out; - }, - /** - * 求两个向量最小值 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - min: function (out, v1, v2) { - out[0] = Math.min(v1[0], v2[0]); - out[1] = Math.min(v1[1], v2[1]); - return out; - }, - /** - * 求两个向量最大值 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - max: function (out, v1, v2) { - out[0] = Math.max(v1[0], v2[0]); - out[1] = Math.max(v1[1], v2[1]); - return out; - } - }; - - vector.length = vector.len; - vector.lengthSquare = vector.lenSquare; - vector.dist = vector.distance; - vector.distSquare = vector.distanceSquare; - - return vector; -}); + var textLines = text.split('\n'); + for (var i = 0; i < textLines.length; i++) { + textFill && ctx.fillText(textLines[i], x, y); + textStroke && ctx.strokeText(textLines[i], x, y); + y += lineHeight; + } -define('zrender/core/matrix',[],function () { - var ArrayCtor = typeof Float32Array === 'undefined' - ? Array - : Float32Array; - /** - * 3x2矩阵操作类 - * @exports zrender/tool/matrix - */ - var matrix = { - /** - * 创建一个单位矩阵 - * @return {Float32Array|Array.} - */ - create : function() { - var out = new ArrayCtor(6); - matrix.identity(out); - - return out; - }, - /** - * 设置矩阵为单位矩阵 - * @param {Float32Array|Array.} out - */ - identity : function(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = 0; - out[5] = 0; - return out; - }, - /** - * 复制矩阵 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} m - */ - copy: function(out, m) { - out[0] = m[0]; - out[1] = m[1]; - out[2] = m[2]; - out[3] = m[3]; - out[4] = m[4]; - out[5] = m[5]; - return out; - }, - /** - * 矩阵相乘 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} m1 - * @param {Float32Array|Array.} m2 - */ - mul : function (out, m1, m2) { - // Consider matrix.mul(m, m2, m); - // where out is the same as m2. - // So use temp variable to escape error. - var out0 = m1[0] * m2[0] + m1[2] * m2[1]; - var out1 = m1[1] * m2[0] + m1[3] * m2[1]; - var out2 = m1[0] * m2[2] + m1[2] * m2[3]; - var out3 = m1[1] * m2[2] + m1[3] * m2[3]; - var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4]; - var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5]; - out[0] = out0; - out[1] = out1; - out[2] = out2; - out[3] = out3; - out[4] = out4; - out[5] = out5; - return out; - }, - /** - * 平移变换 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - * @param {Float32Array|Array.} v - */ - translate : function(out, a, v) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4] + v[0]; - out[5] = a[5] + v[1]; - return out; - }, - /** - * 旋转变换 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - * @param {number} rad - */ - rotate : function(out, a, rad) { - var aa = a[0]; - var ac = a[2]; - var atx = a[4]; - var ab = a[1]; - var ad = a[3]; - var aty = a[5]; - var st = Math.sin(rad); - var ct = Math.cos(rad); - - out[0] = aa * ct + ab * st; - out[1] = -aa * st + ab * ct; - out[2] = ac * ct + ad * st; - out[3] = -ac * st + ct * ad; - out[4] = ct * atx + st * aty; - out[5] = ct * aty - st * atx; - return out; - }, - /** - * 缩放变换 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - * @param {Float32Array|Array.} v - */ - scale : function(out, a, v) { - var vx = v[0]; - var vy = v[1]; - out[0] = a[0] * vx; - out[1] = a[1] * vy; - out[2] = a[2] * vx; - out[3] = a[3] * vy; - out[4] = a[4] * vx; - out[5] = a[5] * vy; - return out; - }, - /** - * 求逆矩阵 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - */ - invert : function(out, a) { - - var aa = a[0]; - var ac = a[2]; - var atx = a[4]; - var ab = a[1]; - var ad = a[3]; - var aty = a[5]; - - var det = aa * ad - ab * ac; - if (!det) { - return null; - } - det = 1.0 / det; - - out[0] = ad * det; - out[1] = -ab * det; - out[2] = -ac * det; - out[3] = aa * det; - out[4] = (ac * aty - ad * atx) * det; - out[5] = (ab * atx - aa * aty) * det; - return out; - } - }; - - return matrix; -}); + ctx.restore(); + } + }, -/** - * @module echarts/core/BoundingRect - */ -define('zrender/core/BoundingRect',['require','./vector','./matrix'],function(require) { - - - var vec2 = require('./vector'); - var matrix = require('./matrix'); - - var v2ApplyTransform = vec2.applyTransform; - var mathMin = Math.min; - var mathAbs = Math.abs; - var mathMax = Math.max; - /** - * @alias module:echarts/core/BoundingRect - */ - function BoundingRect(x, y, width, height) { - /** - * @type {number} - */ - this.x = x; - /** - * @type {number} - */ - this.y = y; - /** - * @type {number} - */ - this.width = width; - /** - * @type {number} - */ - this.height = height; - } - - BoundingRect.prototype = { - - constructor: BoundingRect, - - /** - * @param {module:echarts/core/BoundingRect} other - */ - union: function (other) { - var x = mathMin(other.x, this.x); - var y = mathMin(other.y, this.y); - - this.width = mathMax( - other.x + other.width, - this.x + this.width - ) - x; - this.height = mathMax( - other.y + other.height, - this.y + this.height - ) - y; - this.x = x; - this.y = y; - }, - - /** - * @param {Array.} m - * @methods - */ - applyTransform: (function () { - var min = []; - var max = []; - return function (m) { - // In case usage like this - // el.getBoundingRect().applyTransform(el.transform) - // And element has no transform - if (!m) { - return; - } - min[0] = this.x; - min[1] = this.y; - max[0] = this.x + this.width; - max[1] = this.y + this.height; - - v2ApplyTransform(min, min, m); - v2ApplyTransform(max, max, m); - - this.x = mathMin(min[0], max[0]); - this.y = mathMin(min[1], max[1]); - this.width = mathAbs(max[0] - min[0]); - this.height = mathAbs(max[1] - min[1]); - }; - })(), - - /** - * Calculate matrix of transforming from self to target rect - * @param {module:zrender/core/BoundingRect} b - * @return {Array.} - */ - calculateTransform: function (b) { - var a = this; - var sx = b.width / a.width; - var sy = b.height / a.height; - - var m = matrix.create(); - - // 矩阵右乘 - matrix.translate(m, m, [-a.x, -a.y]); - matrix.scale(m, m, [sx, sy]); - matrix.translate(m, m, [b.x, b.y]); - - return m; - }, - - /** - * @param {(module:echarts/core/BoundingRect|Object)} b - * @return {boolean} - */ - intersect: function (b) { - var a = this; - var ax0 = a.x; - var ax1 = a.x + a.width; - var ay0 = a.y; - var ay1 = a.y + a.height; - - var bx0 = b.x; - var bx1 = b.x + b.width; - var by0 = b.y; - var by1 = b.y + b.height; - - return ! (ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0); - }, - - contain: function (x, y) { - var rect = this; - return x >= rect.x - && x <= (rect.x + rect.width) - && y >= rect.y - && y <= (rect.y + rect.height); - }, - - /** - * @return {module:echarts/core/BoundingRect} - */ - clone: function () { - return new BoundingRect(this.x, this.y, this.width, this.height); - }, - - /** - * Copy from another rect - */ - copy: function (other) { - this.x = other.x; - this.y = other.y; - this.width = other.width; - this.height = other.height; - } - }; - - return BoundingRect; -}); -define('zrender/contain/text',['require','../core/util','../core/BoundingRect'],function (require) { - - var textWidthCache = {}; - var textWidthCacheCounter = 0; - var TEXT_CACHE_MAX = 5000; - - var util = require('../core/util'); - var BoundingRect = require('../core/BoundingRect'); - - function getTextWidth(text, textFont) { - var key = text + ':' + textFont; - if (textWidthCache[key]) { - return textWidthCache[key]; - } - - var textLines = (text + '').split('\n'); - var width = 0; - - for (var i = 0, l = textLines.length; i < l; i++) { - // measureText 可以被覆盖以兼容不支持 Canvas 的环境 - width = Math.max(textContain.measureText(textLines[i], textFont).width, width); - } - - if (textWidthCacheCounter > TEXT_CACHE_MAX) { - textWidthCacheCounter = 0; - textWidthCache = {}; - } - textWidthCacheCounter++; - textWidthCache[key] = width; - - return width; - } - - function getTextRect(text, textFont, textAlign, textBaseline) { - var textLineLen = ((text || '') + '').split('\n').length; - - var width = getTextWidth(text, textFont); - // FIXME 高度计算比较粗暴 - var lineHeight = getTextWidth('国', textFont); - var height = textLineLen * lineHeight; - - var rect = new BoundingRect(0, 0, width, height); - // Text has a special line height property - rect.lineHeight = lineHeight; - - switch (textBaseline) { - case 'bottom': - case 'alphabetic': - rect.y -= lineHeight; - break; - case 'middle': - rect.y -= lineHeight / 2; - break; - // case 'hanging': - // case 'top': - } - - // FIXME Right to left language - switch (textAlign) { - case 'end': - case 'right': - rect.x -= rect.width; - break; - case 'center': - rect.x -= rect.width / 2; - break; - // case 'start': - // case 'left': - } - - return rect; - } - - function adjustTextPositionOnRect(textPosition, rect, textRect, distance) { - - var x = rect.x; - var y = rect.y; - - var height = rect.height; - var width = rect.width; - - var textHeight = textRect.height; - - var halfHeight = height / 2 - textHeight / 2; - - var textAlign = 'left'; - - switch (textPosition) { - case 'left': - x -= distance; - y += halfHeight; - textAlign = 'right'; - break; - case 'right': - x += distance + width; - y += halfHeight; - textAlign = 'left'; - break; - case 'top': - x += width / 2; - y -= distance + textHeight; - textAlign = 'center'; - break; - case 'bottom': - x += width / 2; - y += height + distance; - textAlign = 'center'; - break; - case 'inside': - x += width / 2; - y += halfHeight; - textAlign = 'center'; - break; - case 'insideLeft': - x += distance; - y += halfHeight; - textAlign = 'left'; - break; - case 'insideRight': - x += width - distance; - y += halfHeight; - textAlign = 'right'; - break; - case 'insideTop': - x += width / 2; - y += distance; - textAlign = 'center'; - break; - case 'insideBottom': - x += width / 2; - y += height - textHeight - distance; - textAlign = 'center'; - break; - case 'insideTopLeft': - x += distance; - y += distance; - textAlign = 'left'; - break; - case 'insideTopRight': - x += width - distance; - y += distance; - textAlign = 'right'; - break; - case 'insideBottomLeft': - x += distance; - y += height - textHeight - distance; - break; - case 'insideBottomRight': - x += width - distance; - y += height - textHeight - distance; - textAlign = 'right'; - break; - } - - return { - x: x, - y: y, - textAlign: textAlign, - textBaseline: 'top' - }; - } - - /** - * Show ellipsis if overflow. - * - * @param {string} text - * @param {string} textFont - * @param {string} containerWidth - * @param {Object} [options] - * @param {number} [options.ellipsis='...'] - * @param {number} [options.maxIterations=3] - * @param {number} [options.minCharacters=3] - * @return {string} - */ - function textEllipsis(text, textFont, containerWidth, options) { - if (!containerWidth) { - return ''; - } - - options = util.defaults({ - ellipsis: '...', - minCharacters: 3, - maxIterations: 3, - cnCharWidth: getTextWidth('国', textFont), - // FIXME - // 未考虑非等宽字体 - ascCharWidth: getTextWidth('a', textFont) - }, options, true); - - containerWidth -= getTextWidth(options.ellipsis); - - var textLines = (text + '').split('\n'); - - for (var i = 0, len = textLines.length; i < len; i++) { - textLines[i] = textLineTruncate( - textLines[i], textFont, containerWidth, options - ); - } - - return textLines.join('\n'); - } - - function textLineTruncate(text, textFont, containerWidth, options) { - // FIXME - // 粗糙得写的,尚未考虑性能和各种语言、字体的效果。 - for (var i = 0;; i++) { - var lineWidth = getTextWidth(text, textFont); - - if (lineWidth < containerWidth || i >= options.maxIterations) { - text += options.ellipsis; - break; - } - - var subLength = i === 0 - ? estimateLength(text, containerWidth, options) - : Math.floor(text.length * containerWidth / lineWidth); - - if (subLength < options.minCharacters) { - text = ''; - break; - } - - text = text.substr(0, subLength); - } - - return text; - } - - function estimateLength(text, containerWidth, options) { - var width = 0; - var i = 0; - for (var len = text.length; i < len && width < containerWidth; i++) { - var charCode = text.charCodeAt(i); - width += (0 <= charCode && charCode <= 127) - ? options.ascCharWidth : options.cnCharWidth; - } - return i; - } - - var textContain = { - - getWidth: getTextWidth, - - getBoundingRect: getTextRect, - - adjustTextPositionOnRect: adjustTextPositionOnRect, - - ellipsis: textEllipsis, - - measureText: function (text, textFont) { - var ctx = util.getContext(); - ctx.font = textFont; - return ctx.measureText(text); - } - }; - - return textContain; -}); -define('echarts/model/mixin/textStyle',['require','zrender/contain/text'],function (require) { - - var textContain = require('zrender/contain/text'); - - function getShallow(model, path) { - return model && model.getShallow(path); - } - - return { - /** - * Get color property or get color from option.textStyle.color - * @return {string} - */ - getTextColor: function () { - var ecModel = this.ecModel; - return this.getShallow('color') - || (ecModel && ecModel.get('textStyle.color')); - }, - - /** - * Create font string from fontStyle, fontWeight, fontSize, fontFamily - * @return {string} - */ - getFont: function () { - var ecModel = this.ecModel; - var gTextStyleModel = ecModel && ecModel.getModel('textStyle'); - return [ - // FIXME in node-canvas fontWeight is before fontStyle - this.getShallow('fontStyle') || getShallow(gTextStyleModel, 'fontStyle'), - this.getShallow('fontWeight') || getShallow(gTextStyleModel, 'fontWeight'), - (this.getShallow('fontSize') || getShallow(gTextStyleModel, 'fontSize') || 12) + 'px', - this.getShallow('fontFamily') || getShallow(gTextStyleModel, 'fontFamily') || 'sans-serif' - ].join(' '); - }, - - getTextRect: function (text) { - var textStyle = this.get('textStyle') || {}; - return textContain.getBoundingRect( - text, - this.getFont(), - textStyle.align, - textStyle.baseline - ); - }, - - ellipsis: function (text, containerWidth, options) { - return textContain.ellipsis( - text, this.getFont(), containerWidth, options - ); - } - }; -}); -define('echarts/model/mixin/itemStyle',['require','./makeStyleMapper'],function (require) { - return { - getItemStyle: require('./makeStyleMapper')( - [ - ['fill', 'color'], - ['stroke', 'borderColor'], - ['lineWidth', 'borderWidth'], - ['opacity'], - ['shadowBlur'], - ['shadowOffsetX'], - ['shadowOffsetY'], - ['shadowColor'] - ] - ) - }; -}); -/** - * @module echarts/model/Model - */ -define('echarts/model/Model',['require','zrender/core/util','../util/clazz','./mixin/lineStyle','./mixin/areaStyle','./mixin/textStyle','./mixin/itemStyle'],function (require) { - - var zrUtil = require('zrender/core/util'); - var clazzUtil = require('../util/clazz'); - - /** - * @alias module:echarts/model/Model - * @constructor - * @param {Object} option - * @param {module:echarts/model/Model} parentModel - * @param {module:echarts/model/Global} ecModel - * @param {Object} extraOpt - */ - function Model(option, parentModel, ecModel, extraOpt) { - /** - * @type {module:echarts/model/Model} - * @readOnly - */ - this.parentModel = parentModel; - - /** - * @type {module:echarts/model/Global} - * @readOnly - */ - this.ecModel = ecModel; - - /** - * @type {Object} - * @protected - */ - this.option = option; - - // Simple optimization - if (this.init) { - if (arguments.length <= 4) { - this.init(option, parentModel, ecModel, extraOpt); - } - else { - this.init.apply(this, arguments); - } - } - } - - Model.prototype = { - - constructor: Model, - - /** - * Model 的初始化函数 - * @param {Object} option - */ - init: null, - - /** - * 从新的 Option merge - */ - mergeOption: function (option) { - zrUtil.merge(this.option, option, true); - }, - - /** - * @param {string} path - * @param {boolean} [ignoreParent=false] - * @return {*} - */ - get: function (path, ignoreParent) { - if (!path) { - return this.option; - } - - if (typeof path === 'string') { - path = path.split('.'); - } - - var obj = this.option; - var parentModel = this.parentModel; - for (var i = 0; i < path.length; i++) { - // obj could be number/string/... (like 0) - obj = (obj && typeof obj === 'object') ? obj[path[i]] : null; - if (obj == null) { - break; - } - } - if (obj == null && parentModel && !ignoreParent) { - obj = parentModel.get(path); - } - return obj; - }, - - /** - * @param {string} key - * @param {boolean} [ignoreParent=false] - * @return {*} - */ - getShallow: function (key, ignoreParent) { - var option = this.option; - var val = option && option[key]; - var parentModel = this.parentModel; - if (val == null && parentModel && !ignoreParent) { - val = parentModel.getShallow(key); - } - return val; - }, - - /** - * @param {string} path - * @param {module:echarts/model/Model} [parentModel] - * @return {module:echarts/model/Model} - */ - getModel: function (path, parentModel) { - var obj = this.get(path, true); - var thisParentModel = this.parentModel; - var model = new Model( - obj, parentModel || (thisParentModel && thisParentModel.getModel(path)), - this.ecModel - ); - return model; - }, - - /** - * If model has option - */ - isEmpty: function () { - return this.option == null; - }, - - restoreData: function () {}, - - // Pending - clone: function () { - var Ctor = this.constructor; - return new Ctor(zrUtil.clone(this.option)); - }, - - setReadOnly: function (properties) { - clazzUtil.setReadOnly(this, properties); - } - }; - - // Enable Model.extend. - clazzUtil.enableClassExtend(Model); - - var mixin = zrUtil.mixin; - mixin(Model, require('./mixin/lineStyle')); - mixin(Model, require('./mixin/areaStyle')); - mixin(Model, require('./mixin/textStyle')); - mixin(Model, require('./mixin/itemStyle')); - - return Model; -}); -define('echarts/util/model',['require','./format','./number','zrender/core/util','../model/Model'],function(require) { - - var formatUtil = require('./format'); - var nubmerUtil = require('./number'); - var zrUtil = require('zrender/core/util'); - - var Model = require('../model/Model'); - - var AXIS_DIMS = ['x', 'y', 'z', 'radius', 'angle']; - - var modelUtil = {}; - - /** - * Create "each" method to iterate names. - * - * @pubilc - * @param {Array.} names - * @param {Array.=} attrs - * @return {Function} - */ - modelUtil.createNameEach = function (names, attrs) { - names = names.slice(); - var capitalNames = zrUtil.map(names, modelUtil.capitalFirst); - attrs = (attrs || []).slice(); - var capitalAttrs = zrUtil.map(attrs, modelUtil.capitalFirst); - - return function (callback, context) { - zrUtil.each(names, function (name, index) { - var nameObj = {name: name, capital: capitalNames[index]}; - - for (var j = 0; j < attrs.length; j++) { - nameObj[attrs[j]] = name + capitalAttrs[j]; - } - - callback.call(context, nameObj); - }); - }; - }; - - /** - * @public - */ - modelUtil.capitalFirst = function (str) { - return str ? str.charAt(0).toUpperCase() + str.substr(1) : str; - }; - - /** - * Iterate each dimension name. - * - * @public - * @param {Function} callback The parameter is like: - * { - * name: 'angle', - * capital: 'Angle', - * axis: 'angleAxis', - * axisIndex: 'angleAixs', - * index: 'angleIndex' - * } - * @param {Object} context - */ - modelUtil.eachAxisDim = modelUtil.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index']); - - /** - * If value is not array, then translate it to array. - * @param {*} value - * @return {Array} [value] or value - */ - modelUtil.normalizeToArray = function (value) { - return zrUtil.isArray(value) - ? value - : value == null - ? [] - : [value]; - }; - - /** - * If tow dataZoomModels has the same axis controlled, we say that they are 'linked'. - * dataZoomModels and 'links' make up one or more graphics. - * This function finds the graphic where the source dataZoomModel is in. - * - * @public - * @param {Function} forEachNode Node iterator. - * @param {Function} forEachEdgeType edgeType iterator - * @param {Function} edgeIdGetter Giving node and edgeType, return an array of edge id. - * @return {Function} Input: sourceNode, Output: Like {nodes: [], dims: {}} - */ - modelUtil.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) { - - return function (sourceNode) { - var result = { - nodes: [], - records: {} // key: edgeType.name, value: Object (key: edge id, value: boolean). - }; - - forEachEdgeType(function (edgeType) { - result.records[edgeType.name] = {}; - }); - - if (!sourceNode) { - return result; - } - - absorb(sourceNode, result); - - var existsLink; - do { - existsLink = false; - forEachNode(processSingleNode); - } - while (existsLink); - - function processSingleNode(node) { - if (!isNodeAbsorded(node, result) && isLinked(node, result)) { - absorb(node, result); - existsLink = true; - } - } - - return result; - }; - - function isNodeAbsorded(node, result) { - return zrUtil.indexOf(result.nodes, node) >= 0; - } - - function isLinked(node, result) { - var hasLink = false; - forEachEdgeType(function (edgeType) { - zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) { - result.records[edgeType.name][edgeId] && (hasLink = true); - }); - }); - return hasLink; - } - - function absorb(node, result) { - result.nodes.push(node); - forEachEdgeType(function (edgeType) { - zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) { - result.records[edgeType.name][edgeId] = true; - }); - }); - } - }; - - /** - * Sync default option between normal and emphasis like `position` and `show` - * In case some one will write code like - * label: { - * normal: { - * show: false, - * position: 'outside', - * textStyle: { - * fontSize: 18 - * } - * }, - * emphasis: { - * show: true - * } - * } - * @param {Object} opt - * @param {Array.} subOpts - */ - modelUtil.defaultEmphasis = function (opt, subOpts) { - if (opt) { - var emphasisOpt = opt.emphasis = opt.emphasis || {}; - var normalOpt = opt.normal = opt.normal || {}; - - // Default emphasis option from normal - zrUtil.each(subOpts, function (subOptName) { - var val = zrUtil.retrieve(emphasisOpt[subOptName], normalOpt[subOptName]); - if (val != null) { - emphasisOpt[subOptName] = val; - } - }); - } - }; - - /** - * Create a model proxy to be used in tooltip for edge data, markLine data, markPoint data. - * @param {Object} opt - * @param {string} [opt.seriesIndex] - * @param {Object} [opt.name] - * @param {module:echarts/data/List} data - * @param {Array.} rawData - */ - modelUtil.createDataFormatModel = function (opt, data, rawData) { - var model = new Model(); - zrUtil.mixin(model, modelUtil.dataFormatMixin); - model.seriesIndex = opt.seriesIndex; - model.name = opt.name || ''; - - model.getData = function () { - return data; - }; - model.getRawDataArray = function () { - return rawData; - }; - return model; - }; - - /** - * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}] - * This helper method retieves value from data. - * @param {string|number|Date|Array|Object} dataItem - * @return {number|string|Date|Array.} - */ - modelUtil.getDataItemValue = function (dataItem) { - // Performance sensitive. - return dataItem && (dataItem.value == null ? dataItem : dataItem.value); - }; - - /** - * This helper method convert value in data. - * @param {string|number|Date} value - * @param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'. - */ - modelUtil.converDataValue = function (value, dimInfo) { - // Performance sensitive. - var dimType = dimInfo && dimInfo.type; - if (dimType === 'ordinal') { - return value; - } - - if (dimType === 'time' && !isFinite(value) && value != null && value !== '-') { - value = +nubmerUtil.parseDate(value); - } - - // dimType defaults 'number'. - // If dimType is not ordinal and value is null or undefined or NaN or '-', - // parse to NaN. - return (value == null || value === '') - ? NaN : +value; // If string (like '-'), using '+' parse to NaN - }; - - modelUtil.dataFormatMixin = { - /** - * Get params for formatter - * @param {number} dataIndex - * @return {Object} - */ - getDataParams: function (dataIndex) { - var data = this.getData(); - - var seriesIndex = this.seriesIndex; - var seriesName = this.name; - - var rawValue = this.getRawValue(dataIndex); - var rawDataIndex = data.getRawIndex(dataIndex); - var name = data.getName(dataIndex, true); - - // Data may not exists in the option given by user - var rawDataArray = this.getRawDataArray(); - var itemOpt = rawDataArray && rawDataArray[rawDataIndex]; - - return { - seriesIndex: seriesIndex, - seriesName: seriesName, - name: name, - dataIndex: rawDataIndex, - data: itemOpt, - value: rawValue, - - // Param name list for mapping `a`, `b`, `c`, `d`, `e` - $vars: ['seriesName', 'name', 'value'] - }; - }, - - /** - * Format label - * @param {number} dataIndex - * @param {string} [status='normal'] 'normal' or 'emphasis' - * @param {Function|string} [formatter] Default use the `itemStyle[status].label.formatter` - * @return {string} - */ - getFormattedLabel: function (dataIndex, status, formatter) { - status = status || 'normal'; - var data = this.getData(); - var itemModel = data.getItemModel(dataIndex); - - var params = this.getDataParams(dataIndex); - if (formatter == null) { - formatter = itemModel.get(['label', status, 'formatter']); - } - - if (typeof formatter === 'function') { - params.status = status; - return formatter(params); - } - else if (typeof formatter === 'string') { - return formatUtil.formatTpl(formatter, params); - } - }, - - /** - * Get raw value in option - * @param {number} idx - * @return {Object} - */ - getRawValue: function (idx) { - var itemModel = this.getData().getItemModel(idx); - if (itemModel && itemModel.option != null) { - var dataItem = itemModel.option; - return (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem)) - ? dataItem.value : dataItem; - } - } - }; - - /** - * Mapping to exists for merge. - * - * @public - * @param {Array.|Array.} exists - * @param {Object|Array.} newCptOptions - * @return {Array.} Result, like [{exist: ..., option: ...}, {}], - * which order is the same as exists. - */ - modelUtil.mappingToExists = function (exists, newCptOptions) { - // Mapping by the order by original option (but not order of - // new option) in merge mode. Because we should ensure - // some specified index (like xAxisIndex) is consistent with - // original option, which is easy to understand, espatially in - // media query. And in most case, merge option is used to - // update partial option but not be expected to change order. - newCptOptions = (newCptOptions || []).slice(); - - var result = zrUtil.map(exists || [], function (obj, index) { - return {exist: obj}; - }); - - // Mapping by id or name if specified. - zrUtil.each(newCptOptions, function (cptOption, index) { - if (!zrUtil.isObject(cptOption)) { - return; - } - - for (var i = 0; i < result.length; i++) { - var exist = result[i].exist; - if (!result[i].option // Consider name: two map to one. - && ( - // id has highest priority. - (cptOption.id != null && exist.id === cptOption.id + '') - || (cptOption.name != null - && !modelUtil.isIdInner(cptOption) - && !modelUtil.isIdInner(exist) - && exist.name === cptOption.name + '' - ) - ) - ) { - result[i].option = cptOption; - newCptOptions[index] = null; - break; - } - } - }); - - // Otherwise mapping by index. - zrUtil.each(newCptOptions, function (cptOption, index) { - if (!zrUtil.isObject(cptOption)) { - return; - } - - var i = 0; - for (; i < result.length; i++) { - var exist = result[i].exist; - if (!result[i].option - && !modelUtil.isIdInner(exist) - // Caution: - // Do not overwrite id. But name can be overwritten, - // because axis use name as 'show label text'. - // 'exist' always has id and name and we dont - // need to check it. - && cptOption.id == null - ) { - result[i].option = cptOption; - break; - } - } - - if (i >= result.length) { - result.push({option: cptOption}); - } - }); - - return result; - }; - - /** - * @public - * @param {Object} cptOption - * @return {boolean} - */ - modelUtil.isIdInner = function (cptOption) { - return zrUtil.isObject(cptOption) - && cptOption.id - && (cptOption.id + '').indexOf('\0_ec_\0') === 0; - }; - - return modelUtil; -}); -define('echarts/util/component',['require','zrender/core/util','./clazz'],function(require) { - - var zrUtil = require('zrender/core/util'); - var clazz = require('./clazz'); - - var parseClassType = clazz.parseClassType; - - var base = 0; - - var componentUtil = {}; - - var DELIMITER = '_'; - - /** - * @public - * @param {string} type - * @return {string} - */ - componentUtil.getUID = function (type) { - // Considering the case of crossing js context, - // use Math.random to make id as unique as possible. - return [(type || ''), base++, Math.random()].join(DELIMITER); - }; - - /** - * @inner - */ - componentUtil.enableSubTypeDefaulter = function (entity) { - - var subTypeDefaulters = {}; - - entity.registerSubTypeDefaulter = function (componentType, defaulter) { - componentType = parseClassType(componentType); - subTypeDefaulters[componentType.main] = defaulter; - }; - - entity.determineSubType = function (componentType, option) { - var type = option.type; - if (!type) { - var componentTypeMain = parseClassType(componentType).main; - if (entity.hasSubTypes(componentType) && subTypeDefaulters[componentTypeMain]) { - type = subTypeDefaulters[componentTypeMain](option); - } - } - return type; - }; - - return entity; - }; - - /** - * Topological travel on Activity Network (Activity On Vertices). - * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis']. - * - * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology. - * - * If there is circle dependencey, Error will be thrown. - * - */ - componentUtil.enableTopologicalTravel = function (entity, dependencyGetter) { - - /** - * @public - * @param {Array.} targetNameList Target Component type list. - * Can be ['aa', 'bb', 'aa.xx'] - * @param {Array.} fullNameList By which we can build dependency graph. - * @param {Function} callback Params: componentType, dependencies. - * @param {Object} context Scope of callback. - */ - entity.topologicalTravel = function (targetNameList, fullNameList, callback, context) { - if (!targetNameList.length) { - return; - } - - var result = makeDepndencyGraph(fullNameList); - var graph = result.graph; - var stack = result.noEntryList; - - var targetNameSet = {}; - zrUtil.each(targetNameList, function (name) { - targetNameSet[name] = true; - }); - - while (stack.length) { - var currComponentType = stack.pop(); - var currVertex = graph[currComponentType]; - var isInTargetNameSet = !!targetNameSet[currComponentType]; - if (isInTargetNameSet) { - callback.call(context, currComponentType, currVertex.originalDeps.slice()); - delete targetNameSet[currComponentType]; - } - zrUtil.each( - currVertex.successor, - isInTargetNameSet ? removeEdgeAndAdd : removeEdge - ); - } - - zrUtil.each(targetNameSet, function () { - throw new Error('Circle dependency may exists'); - }); - - function removeEdge(succComponentType) { - graph[succComponentType].entryCount--; - if (graph[succComponentType].entryCount === 0) { - stack.push(succComponentType); - } - } - - // Consider this case: legend depends on series, and we call - // chart.setOption({series: [...]}), where only series is in option. - // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will - // not be called, but only sereis.mergeOption is called. Thus legend - // have no chance to update its local record about series (like which - // name of series is available in legend). - function removeEdgeAndAdd(succComponentType) { - targetNameSet[succComponentType] = true; - removeEdge(succComponentType); - } - }; - - /** - * DepndencyGraph: {Object} - * key: conponentType, - * value: { - * successor: [conponentTypes...], - * originalDeps: [conponentTypes...], - * entryCount: {number} - * } - */ - function makeDepndencyGraph(fullNameList) { - var graph = {}; - var noEntryList = []; - - zrUtil.each(fullNameList, function (name) { - - var thisItem = createDependencyGraphItem(graph, name); - var originalDeps = thisItem.originalDeps = dependencyGetter(name); - - var availableDeps = getAvailableDependencies(originalDeps, fullNameList); - thisItem.entryCount = availableDeps.length; - if (thisItem.entryCount === 0) { - noEntryList.push(name); - } - - zrUtil.each(availableDeps, function (dependentName) { - if (zrUtil.indexOf(thisItem.predecessor, dependentName) < 0) { - thisItem.predecessor.push(dependentName); - } - var thatItem = createDependencyGraphItem(graph, dependentName); - if (zrUtil.indexOf(thatItem.successor, dependentName) < 0) { - thatItem.successor.push(name); - } - }); - }); - - return {graph: graph, noEntryList: noEntryList}; - } - - function createDependencyGraphItem(graph, name) { - if (!graph[name]) { - graph[name] = {predecessor: [], successor: []}; - } - return graph[name]; - } - - function getAvailableDependencies(originalDeps, fullNameList) { - var availableDeps = []; - zrUtil.each(originalDeps, function (dep) { - zrUtil.indexOf(fullNameList, dep) >= 0 && availableDeps.push(dep); - }); - return availableDeps; - } - }; - - return componentUtil; -}); -// Layout helpers for each component positioning -define('echarts/util/layout',['require','zrender/core/util','zrender/core/BoundingRect','./number','./format'],function(require) { - - - var zrUtil = require('zrender/core/util'); - var BoundingRect = require('zrender/core/BoundingRect'); - var numberUtil = require('./number'); - var formatUtil = require('./format'); - var parsePercent = numberUtil.parsePercent; - var each = zrUtil.each; - - var layout = {}; - - var LOCATION_PARAMS = ['left', 'right', 'top', 'bottom', 'width', 'height']; - - function boxLayout(orient, group, gap, maxWidth, maxHeight) { - var x = 0; - var y = 0; - if (maxWidth == null) { - maxWidth = Infinity; - } - if (maxHeight == null) { - maxHeight = Infinity; - } - var currentLineMaxSize = 0; - group.eachChild(function (child, idx) { - var position = child.position; - var rect = child.getBoundingRect(); - var nextChild = group.childAt(idx + 1); - var nextChildRect = nextChild && nextChild.getBoundingRect(); - var nextX; - var nextY; - if (orient === 'horizontal') { - var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0); - nextX = x + moveX; - // Wrap when width exceeds maxWidth or meet a `newline` group - if (nextX > maxWidth || child.newline) { - x = 0; - nextX = moveX; - y += currentLineMaxSize + gap; - currentLineMaxSize = rect.height; - } - else { - currentLineMaxSize = Math.max(currentLineMaxSize, rect.height); - } - } - else { - var moveY = rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0); - nextY = y + moveY; - // Wrap when width exceeds maxHeight or meet a `newline` group - if (nextY > maxHeight || child.newline) { - x += currentLineMaxSize + gap; - y = 0; - nextY = moveY; - currentLineMaxSize = rect.width; - } - else { - currentLineMaxSize = Math.max(currentLineMaxSize, rect.width); - } - } - - if (child.newline) { - return; - } - - position[0] = x; - position[1] = y; - - orient === 'horizontal' - ? (x = nextX + gap) - : (y = nextY + gap); - }); - } - - /** - * VBox or HBox layouting - * @param {string} orient - * @param {module:zrender/container/Group} group - * @param {number} gap - * @param {number} [width=Infinity] - * @param {number} [height=Infinity] - */ - layout.box = boxLayout; - - /** - * VBox layouting - * @param {module:zrender/container/Group} group - * @param {number} gap - * @param {number} [width=Infinity] - * @param {number} [height=Infinity] - */ - layout.vbox = zrUtil.curry(boxLayout, 'vertical'); - - /** - * HBox layouting - * @param {module:zrender/container/Group} group - * @param {number} gap - * @param {number} [width=Infinity] - * @param {number} [height=Infinity] - */ - layout.hbox = zrUtil.curry(boxLayout, 'horizontal'); - - /** - * If x or x2 is not specified or 'center' 'left' 'right', - * the width would be as long as possible. - * If y or y2 is not specified or 'middle' 'top' 'bottom', - * the height would be as long as possible. - * - * @param {Object} positionInfo - * @param {number|string} [positionInfo.x] - * @param {number|string} [positionInfo.y] - * @param {number|string} [positionInfo.x2] - * @param {number|string} [positionInfo.y2] - * @param {Object} containerRect - * @param {string|number} margin - * @return {Object} {width, height} - */ - layout.getAvailableSize = function (positionInfo, containerRect, margin) { - var containerWidth = containerRect.width; - var containerHeight = containerRect.height; - - var x = parsePercent(positionInfo.x, containerWidth); - var y = parsePercent(positionInfo.y, containerHeight); - var x2 = parsePercent(positionInfo.x2, containerWidth); - var y2 = parsePercent(positionInfo.y2, containerHeight); - - (isNaN(x) || isNaN(parseFloat(positionInfo.x))) && (x = 0); - (isNaN(x2) || isNaN(parseFloat(positionInfo.x2))) && (x2 = containerWidth); - (isNaN(y) || isNaN(parseFloat(positionInfo.y))) && (y = 0); - (isNaN(y2) || isNaN(parseFloat(positionInfo.y2))) && (y2 = containerHeight); - - margin = formatUtil.normalizeCssArray(margin || 0); - - return { - width: Math.max(x2 - x - margin[1] - margin[3], 0), - height: Math.max(y2 - y - margin[0] - margin[2], 0) - }; - }; - - /** - * Parse position info. - * - * @param {Object} positionInfo - * @param {number|string} [positionInfo.left] - * @param {number|string} [positionInfo.top] - * @param {number|string} [positionInfo.right] - * @param {number|string} [positionInfo.bottom] - * @param {number|string} [positionInfo.width] - * @param {number|string} [positionInfo.height] - * @param {number|string} [positionInfo.aspect] Aspect is width / height - * @param {Object} containerRect - * @param {string|number} [margin] - * - * @return {module:zrender/core/BoundingRect} - */ - layout.getLayoutRect = function ( - positionInfo, containerRect, margin - ) { - margin = formatUtil.normalizeCssArray(margin || 0); - - var containerWidth = containerRect.width; - var containerHeight = containerRect.height; - - var left = parsePercent(positionInfo.left, containerWidth); - var top = parsePercent(positionInfo.top, containerHeight); - var right = parsePercent(positionInfo.right, containerWidth); - var bottom = parsePercent(positionInfo.bottom, containerHeight); - var width = parsePercent(positionInfo.width, containerWidth); - var height = parsePercent(positionInfo.height, containerHeight); - - var verticalMargin = margin[2] + margin[0]; - var horizontalMargin = margin[1] + margin[3]; - var aspect = positionInfo.aspect; - - // If width is not specified, calculate width from left and right - if (isNaN(width)) { - width = containerWidth - right - horizontalMargin - left; - } - if (isNaN(height)) { - height = containerHeight - bottom - verticalMargin - top; - } - - // If width and height are not given - // 1. Graph should not exceeds the container - // 2. Aspect must be keeped - // 3. Graph should take the space as more as possible - if (isNaN(width) && isNaN(height)) { - if (aspect > containerWidth / containerHeight) { - width = containerWidth * 0.8; - } - else { - height = containerHeight * 0.8; - } - } - - if (aspect != null) { - // Calculate width or height with given aspect - if (isNaN(width)) { - width = aspect * height; - } - if (isNaN(height)) { - height = width / aspect; - } - } - - // If left is not specified, calculate left from right and width - if (isNaN(left)) { - left = containerWidth - right - width - horizontalMargin; - } - if (isNaN(top)) { - top = containerHeight - bottom - height - verticalMargin; - } - - // Align left and top - switch (positionInfo.left || positionInfo.right) { - case 'center': - left = containerWidth / 2 - width / 2 - margin[3]; - break; - case 'right': - left = containerWidth - width - horizontalMargin; - break; - } - switch (positionInfo.top || positionInfo.bottom) { - case 'middle': - case 'center': - top = containerHeight / 2 - height / 2 - margin[0]; - break; - case 'bottom': - top = containerHeight - height - verticalMargin; - break; - } - // If something is wrong and left, top, width, height are calculated as NaN - left = left || 0; - top = top || 0; - if (isNaN(width)) { - // Width may be NaN if only one value is given except width - width = containerWidth - left - (right || 0); - } - if (isNaN(height)) { - // Height may be NaN if only one value is given except height - height = containerHeight - top - (bottom || 0); - } - - var rect = new BoundingRect(left + margin[3], top + margin[0], width, height); - rect.margin = margin; - return rect; - }; - - /** - * Position group of component in viewport - * Group position is specified by either - * {left, top}, {right, bottom} - * If all properties exists, right and bottom will be igonred. - * - * @param {module:zrender/container/Group} group - * @param {Object} positionInfo - * @param {number|string} [positionInfo.left] - * @param {number|string} [positionInfo.top] - * @param {number|string} [positionInfo.right] - * @param {number|string} [positionInfo.bottom] - * @param {Object} containerRect - * @param {string|number} margin - */ - layout.positionGroup = function ( - group, positionInfo, containerRect, margin - ) { - var groupRect = group.getBoundingRect(); - - positionInfo = zrUtil.extend(zrUtil.clone(positionInfo), { - width: groupRect.width, - height: groupRect.height - }); - - positionInfo = layout.getLayoutRect( - positionInfo, containerRect, margin - ); - - group.position = [ - positionInfo.x - groupRect.x, - positionInfo.y - groupRect.y - ]; - }; - - /** - * Consider Case: - * When defulat option has {left: 0, width: 100}, and we set {right: 0} - * through setOption or media query, using normal zrUtil.merge will cause - * {right: 0} does not take effect. - * - * @example - * ComponentModel.extend({ - * init: function () { - * ... - * var inputPositionParams = layout.getLayoutParams(option); - * this.mergeOption(inputPositionParams); - * }, - * mergeOption: function (newOption) { - * newOption && zrUtil.merge(thisOption, newOption, true); - * layout.mergeLayoutParam(thisOption, newOption); - * } - * }); - * - * @param {Object} targetOption - * @param {Object} newOption - * @param {Object|string} [opt] - * @param {boolean} [opt.ignoreSize=false] Some component must has width and height. - */ - layout.mergeLayoutParam = function (targetOption, newOption, opt) { - !zrUtil.isObject(opt) && (opt = {}); - var hNames = ['width', 'left', 'right']; // Order by priority. - var vNames = ['height', 'top', 'bottom']; // Order by priority. - var hResult = merge(hNames); - var vResult = merge(vNames); - - copy(hNames, targetOption, hResult); - copy(vNames, targetOption, vResult); - - function merge(names) { - var newParams = {}; - var newValueCount = 0; - var merged = {}; - var mergedValueCount = 0; - var enoughParamNumber = opt.ignoreSize ? 1 : 2; - - each(names, function (name) { - merged[name] = targetOption[name]; - }); - each(names, function (name) { - // Consider case: newOption.width is null, which is - // set by user for removing width setting. - hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]); - hasValue(newParams, name) && newValueCount++; - hasValue(merged, name) && mergedValueCount++; - }); - - // Case: newOption: {width: ..., right: ...}, - // or targetOption: {right: ...} and newOption: {width: ...}, - // There is no conflict when merged only has params count - // little than enoughParamNumber. - if (mergedValueCount === enoughParamNumber || !newValueCount) { - return merged; - } - // Case: newOption: {width: ..., right: ...}, - // Than we can make sure user only want those two, and ignore - // all origin params in targetOption. - else if (newValueCount >= enoughParamNumber) { - return newParams; - } - else { - // Chose another param from targetOption by priority. - // When 'ignoreSize', enoughParamNumber is 1 and those will not happen. - for (var i = 0; i < names.length; i++) { - var name = names[i]; - if (!hasProp(newParams, name) && hasProp(targetOption, name)) { - newParams[name] = targetOption[name]; - break; - } - } - return newParams; - } - } - - function hasProp(obj, name) { - return obj.hasOwnProperty(name); - } - - function hasValue(obj, name) { - return obj[name] != null && obj[name] !== 'auto'; - } - - function copy(names, target, source) { - each(names, function (name) { - target[name] = source[name]; - }); - } - }; - - /** - * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object. - * @param {Object} source - * @return {Object} Result contains those props. - */ - layout.getLayoutParams = function (source) { - return layout.copyLayoutParams({}, source); - }; - - /** - * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object. - * @param {Object} source - * @return {Object} Result contains those props. - */ - layout.copyLayoutParams = function (target, source) { - source && target && each(LOCATION_PARAMS, function (name) { - source.hasOwnProperty(name) && (target[name] = source[name]); - }); - return target; - }; - - return layout; -}); -define('echarts/model/mixin/boxLayout',['require'],function (require) { - - return { - getBoxLayoutParams: function () { - return { - left: this.get('left'), - top: this.get('top'), - right: this.get('right'), - bottom: this.get('bottom'), - width: this.get('width'), - height: this.get('height') - }; - } - }; -}); -/** - * Component model - * - * @module echarts/model/Component - */ -define('echarts/model/Component',['require','./Model','zrender/core/util','../util/component','../util/clazz','../util/layout','./mixin/boxLayout'],function(require) { - - var Model = require('./Model'); - var zrUtil = require('zrender/core/util'); - var arrayPush = Array.prototype.push; - var componentUtil = require('../util/component'); - var clazzUtil = require('../util/clazz'); - var layout = require('../util/layout'); - - /** - * @alias module:echarts/model/Component - * @constructor - * @param {Object} option - * @param {module:echarts/model/Model} parentModel - * @param {module:echarts/model/Model} ecModel - */ - var ComponentModel = Model.extend({ - - type: 'component', - - /** - * @readOnly - * @type {string} - */ - id: '', - - /** - * @readOnly - */ - name: '', - - /** - * @readOnly - * @type {string} - */ - mainType: '', - - /** - * @readOnly - * @type {string} - */ - subType: '', - - /** - * @readOnly - * @type {number} - */ - componentIndex: 0, - - /** - * @type {Object} - * @protected - */ - defaultOption: null, - - /** - * @type {module:echarts/model/Global} - * @readOnly - */ - ecModel: null, - - /** - * key: componentType - * value: Component model list, can not be null. - * @type {Object.>} - * @readOnly - */ - dependentModels: [], - - /** - * @type {string} - * @readOnly - */ - uid: null, - - /** - * Support merge layout params. - * Only support 'box' now (left/right/top/bottom/width/height). - * @type {string|Object} Object can be {ignoreSize: true} - * @readOnly - */ - layoutMode: null, - - - init: function (option, parentModel, ecModel, extraOpt) { - this.mergeDefaultAndTheme(this.option, this.ecModel); - }, - - mergeDefaultAndTheme: function (option, ecModel) { - var layoutMode = this.layoutMode; - var inputPositionParams = layoutMode - ? layout.getLayoutParams(option) : {}; - - var themeModel = ecModel.getTheme(); - zrUtil.merge(option, themeModel.get(this.mainType)); - zrUtil.merge(option, this.getDefaultOption()); - - if (layoutMode) { - layout.mergeLayoutParam(option, inputPositionParams, layoutMode); - } - }, - - mergeOption: function (option) { - zrUtil.merge(this.option, option, true); - - var layoutMode = this.layoutMode; - if (layoutMode) { - layout.mergeLayoutParam(this.option, option, layoutMode); - } - }, - - getDefaultOption: function () { - if (!this.hasOwnProperty('__defaultOption')) { - var optList = []; - var Class = this.constructor; - while (Class) { - var opt = Class.prototype.defaultOption; - opt && optList.push(opt); - Class = Class.superClass; - } - - var defaultOption = {}; - for (var i = optList.length - 1; i >= 0; i--) { - defaultOption = zrUtil.merge(defaultOption, optList[i], true); - } - this.__defaultOption = defaultOption; - } - return this.__defaultOption; - } - - }); - - // Reset ComponentModel.extend, add preConstruct. - clazzUtil.enableClassExtend( - ComponentModel, - function (option, parentModel, ecModel, extraOpt) { - // Set dependentModels, componentIndex, name, id, mainType, subType. - zrUtil.extend(this, extraOpt); - - this.uid = componentUtil.getUID('componentModel'); - - this.setReadOnly([ - 'type', 'id', 'uid', 'name', 'mainType', 'subType', - 'dependentModels', 'componentIndex' - ]); - } - ); - - // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. - clazzUtil.enableClassManagement( - ComponentModel, {registerWhenExtend: true} - ); - componentUtil.enableSubTypeDefaulter(ComponentModel); - - // Add capability of ComponentModel.topologicalTravel. - componentUtil.enableTopologicalTravel(ComponentModel, getDependencies); - - function getDependencies(componentType) { - var deps = []; - zrUtil.each(ComponentModel.getClassesByMainType(componentType), function (Clazz) { - arrayPush.apply(deps, Clazz.prototype.dependencies || []); - }); - // Ensure main type - return zrUtil.map(deps, function (type) { - return clazzUtil.parseClassType(type).main; - }); - } - - zrUtil.mixin(ComponentModel, require('./mixin/boxLayout')); - - return ComponentModel; -}); -define('echarts/model/globalDefault',[],function () { - var platform = ''; - // Navigator not exists in node - if (typeof navigator !== 'undefined') { - platform = navigator.platform || ''; - } - return { - // 全图默认背景 - // backgroundColor: 'rgba(0,0,0,0)', - - // https://dribbble.com/shots/1065960-Infographic-Pie-chart-visualization - // color: ['#5793f3', '#d14a61', '#fd9c35', '#675bba', '#fec42c', '#dd4444', '#d4df5a', '#cd4870'], - // 浅色 - // color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'], - // color: ['#cc5664', '#9bd6ec', '#ea946e', '#8acaaa', '#f1ec64', '#ee8686', '#a48dc1', '#5da6bc', '#b9dcae'], - // 深色 - color: ['#c23531', '#314656', '#61a0a8', '#dd8668', '#91c7ae', '#6e7074', '#ca8622', '#bda29a', '#44525d', '#c4ccd3'], - - // 默认需要 Grid 配置项 - grid: {}, - // 主题,主题 - textStyle: { - // color: '#000', - // decoration: 'none', - // PENDING - fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif', - // fontFamily: 'Arial, Verdana, sans-serif', - fontSize: 12, - fontStyle: 'normal', - fontWeight: 'normal' - }, - // 主题,默认标志图形类型列表 - // symbolList: [ - // 'circle', 'rectangle', 'triangle', 'diamond', - // 'emptyCircle', 'emptyRectangle', 'emptyTriangle', 'emptyDiamond' - // ], - animation: true, // 过渡动画是否开启 - animationThreshold: 2000, // 动画元素阀值,产生的图形原素超过2000不出动画 - animationDuration: 1000, // 过渡动画参数:进入 - animationDurationUpdate: 300, // 过渡动画参数:更新 - animationEasing: 'exponentialOut', //BounceOut - animationEasingUpdate: 'cubicOut' - }; -}); -/** - * ECharts global model - * - * @module {echarts/model/Global} - * - */ - -define('echarts/model/Global',['require','zrender/core/util','../util/model','./Model','./Component','./globalDefault'],function (require) { - - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../util/model'); - var Model = require('./Model'); - var each = zrUtil.each; - var filter = zrUtil.filter; - var map = zrUtil.map; - var isArray = zrUtil.isArray; - var indexOf = zrUtil.indexOf; - var isObject = zrUtil.isObject; - - var ComponentModel = require('./Component'); - - var globalDefault = require('./globalDefault'); - - var OPTION_INNER_KEY = '\0_ec_inner'; - - /** - * @alias module:echarts/model/Global - * - * @param {Object} option - * @param {module:echarts/model/Model} parentModel - * @param {Object} theme - */ - var GlobalModel = Model.extend({ - - constructor: GlobalModel, - - init: function (option, parentModel, theme, optionManager) { - theme = theme || {}; - - this.option = null; // Mark as not initialized. - - /** - * @type {module:echarts/model/Model} - * @private - */ - this._theme = new Model(theme); - - /** - * @type {module:echarts/model/OptionManager} - */ - this._optionManager = optionManager; - }, - - setOption: function (option, optionPreprocessorFuncs) { - zrUtil.assert( - !(OPTION_INNER_KEY in option), - 'please use chart.getOption()' - ); - - this._optionManager.setOption(option, optionPreprocessorFuncs); - - this.resetOption(); - }, - - /** - * @param {string} type null/undefined: reset all. - * 'recreate': force recreate all. - * 'timeline': only reset timeline option - * 'media': only reset media query option - * @return {boolean} Whether option changed. - */ - resetOption: function (type) { - var optionChanged = false; - var optionManager = this._optionManager; - - if (!type || type === 'recreate') { - var baseOption = optionManager.mountOption(type === 'recreate'); - - if (!this.option || type === 'recreate') { - initBase.call(this, baseOption); - } - else { - this.restoreData(); - this.mergeOption(baseOption); - } - optionChanged = true; - } - - if (type === 'timeline' || type === 'media') { - this.restoreData(); - } - - if (!type || type === 'recreate' || type === 'timeline') { - var timelineOption = optionManager.getTimelineOption(this); - timelineOption && (this.mergeOption(timelineOption), optionChanged = true); - } - - if (!type || type === 'recreate' || type === 'media') { - var mediaOptions = optionManager.getMediaOption(this, this._api); - if (mediaOptions.length) { - each(mediaOptions, function (mediaOption) { - this.mergeOption(mediaOption, optionChanged = true); - }, this); - } - } - - return optionChanged; - }, - - /** - * @protected - */ - mergeOption: function (newOption) { - var option = this.option; - var componentsMap = this._componentsMap; - var newCptTypes = []; - - // 如果不存在对应的 component model 则直接 merge - each(newOption, function (componentOption, mainType) { - if (componentOption == null) { - return; - } - - if (!ComponentModel.hasClass(mainType)) { - option[mainType] = option[mainType] == null - ? zrUtil.clone(componentOption) - : zrUtil.merge(option[mainType], componentOption, true); - } - else { - newCptTypes.push(mainType); - } - }); - - // FIXME OPTION 同步是否要改回原来的 - ComponentModel.topologicalTravel( - newCptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this - ); - - function visitComponent(mainType, dependencies) { - var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]); - - var mapResult = modelUtil.mappingToExists( - componentsMap[mainType], newCptOptionList - ); - - makeKeyInfo(mainType, mapResult); - - var dependentModels = getComponentsByTypes( - componentsMap, dependencies - ); - - option[mainType] = []; - componentsMap[mainType] = []; - - each(mapResult, function (resultItem, index) { - var componentModel = resultItem.exist; - var newCptOption = resultItem.option; - - zrUtil.assert( - isObject(newCptOption) || componentModel, - 'Empty component definition' - ); - - // Consider where is no new option and should be merged using {}, - // see removeEdgeAndAdd in topologicalTravel and - // ComponentModel.getAllClassMainTypes. - if (!newCptOption) { - componentModel.mergeOption({}, this); - } - else { - var ComponentModelClass = ComponentModel.getClass( - mainType, resultItem.keyInfo.subType, true - ); - - if (componentModel && componentModel instanceof ComponentModelClass) { - componentModel.mergeOption(newCptOption, this); - } - else { - // PENDING Global as parent ? - componentModel = new ComponentModelClass( - newCptOption, this, this, - zrUtil.extend( - { - dependentModels: dependentModels, - componentIndex: index - }, - resultItem.keyInfo - ) - ); - } - } - - componentsMap[mainType][index] = componentModel; - option[mainType][index] = componentModel.option; - }, this); - - // Backup series for filtering. - if (mainType === 'series') { - this._seriesIndices = createSeriesIndices(componentsMap.series); - } - } - }, - - /** - * Get option for output (cloned option and inner info removed) - * @public - * @return {Object} - */ - getOption: function () { - var option = zrUtil.clone(this.option); - - each(option, function (opts, mainType) { - if (ComponentModel.hasClass(mainType)) { - var opts = modelUtil.normalizeToArray(opts); - for (var i = opts.length - 1; i >= 0; i--) { - // Remove options with inner id. - if (modelUtil.isIdInner(opts[i])) { - opts.splice(i, 1); - } - } - option[mainType] = opts; - } - }); - - delete option[OPTION_INNER_KEY]; - - return option; - }, - - /** - * @return {module:echarts/model/Model} - */ - getTheme: function () { - return this._theme; - }, - - /** - * @param {string} mainType - * @param {number} [idx=0] - * @return {module:echarts/model/Component} - */ - getComponent: function (mainType, idx) { - var list = this._componentsMap[mainType]; - if (list) { - return list[idx || 0]; - } - }, - - /** - * @param {Object} condition - * @param {string} condition.mainType - * @param {string} [condition.subType] If ignore, only query by mainType - * @param {number} [condition.index] Either input index or id or name. - * @param {string} [condition.id] Either input index or id or name. - * @param {string} [condition.name] Either input index or id or name. - * @return {Array.} - */ - queryComponents: function (condition) { - var mainType = condition.mainType; - if (!mainType) { - return []; - } - - var index = condition.index; - var id = condition.id; - var name = condition.name; - - var cpts = this._componentsMap[mainType]; - - if (!cpts || !cpts.length) { - return []; - } - - var result; - - if (index != null) { - if (!isArray(index)) { - index = [index]; - } - result = filter(map(index, function (idx) { - return cpts[idx]; - }), function (val) { - return !!val; - }); - } - else if (id != null) { - var isIdArray = isArray(id); - result = filter(cpts, function (cpt) { - return (isIdArray && indexOf(id, cpt.id) >= 0) - || (!isIdArray && cpt.id === id); - }); - } - else if (name != null) { - var isNameArray = isArray(name); - result = filter(cpts, function (cpt) { - return (isNameArray && indexOf(name, cpt.name) >= 0) - || (!isNameArray && cpt.name === name); - }); - } - - return filterBySubType(result, condition); - }, - - /** - * The interface is different from queryComponents, - * which is convenient for inner usage. - * - * @usage - * findComponents( - * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}, - * function (model, index) {...} - * ); - * - * findComponents( - * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}, - * function (model, index) {...} - * ); - * - * var result = findComponents( - * {mainType: 'series'}, - * function (model, index) {...} - * ); - * // result like [component0, componnet1, ...] - * - * @param {Object} condition - * @param {string} condition.mainType Mandatory. - * @param {string} [condition.subType] Optional. - * @param {Object} [condition.query] like {xxxIndex, xxxId, xxxName}, - * where xxx is mainType. - * If query attribute is null/undefined or has no index/id/name, - * do not filtering by query conditions, which is convenient for - * no-payload situations or when target of action is global. - * @param {Function} [condition.filter] parameter: component, return boolean. - * @return {Array.} - */ - findComponents: function (condition) { - var query = condition.query; - var mainType = condition.mainType; - - var queryCond = getQueryCond(query); - var result = queryCond - ? this.queryComponents(queryCond) - : this._componentsMap[mainType]; - - return doFilter(filterBySubType(result, condition)); - - function getQueryCond(q) { - var indexAttr = mainType + 'Index'; - var idAttr = mainType + 'Id'; - var nameAttr = mainType + 'Name'; - return q && ( - q.hasOwnProperty(indexAttr) - || q.hasOwnProperty(idAttr) - || q.hasOwnProperty(nameAttr) - ) - ? { - mainType: mainType, - // subType will be filtered finally. - index: q[indexAttr], - id: q[idAttr], - name: q[nameAttr] - } - : null; - } - - function doFilter(res) { - return condition.filter - ? filter(res, condition.filter) - : res; - } - }, - - /** - * @usage - * eachComponent('legend', function (legendModel, index) { - * ... - * }); - * eachComponent(function (componentType, model, index) { - * // componentType does not include subType - * // (componentType is 'xxx' but not 'xxx.aa') - * }); - * eachComponent( - * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}, - * function (model, index) {...} - * ); - * eachComponent( - * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}, - * function (model, index) {...} - * ); - * - * @param {string|Object=} mainType When mainType is object, the definition - * is the same as the method 'findComponents'. - * @param {Function} cb - * @param {*} context - */ - eachComponent: function (mainType, cb, context) { - var componentsMap = this._componentsMap; - - if (typeof mainType === 'function') { - context = cb; - cb = mainType; - each(componentsMap, function (components, componentType) { - each(components, function (component, index) { - cb.call(context, componentType, component, index); - }); - }); - } - else if (zrUtil.isString(mainType)) { - each(componentsMap[mainType], cb, context); - } - else if (isObject(mainType)) { - var queryResult = this.findComponents(mainType); - each(queryResult, cb, context); - } - }, - - /** - * @param {string} name - * @return {Array.} - */ - getSeriesByName: function (name) { - var series = this._componentsMap.series; - return filter(series, function (oneSeries) { - return oneSeries.name === name; - }); - }, - - /** - * @param {number} seriesIndex - * @return {module:echarts/model/Series} - */ - getSeriesByIndex: function (seriesIndex) { - return this._componentsMap.series[seriesIndex]; - }, - - /** - * @param {string} subType - * @return {Array.} - */ - getSeriesByType: function (subType) { - var series = this._componentsMap.series; - return filter(series, function (oneSeries) { - return oneSeries.subType === subType; - }); - }, - - /** - * @return {Array.} - */ - getSeries: function () { - return this._componentsMap.series.slice(); - }, - - /** - * After filtering, series may be different - * frome raw series. - * - * @param {Function} cb - * @param {*} context - */ - eachSeries: function (cb, context) { - assertSeriesInitialized(this); - each(this._seriesIndices, function (rawSeriesIndex) { - var series = this._componentsMap.series[rawSeriesIndex]; - cb.call(context, series, rawSeriesIndex); - }, this); - }, - - /** - * Iterate raw series before filtered. - * - * @param {Function} cb - * @param {*} context - */ - eachRawSeries: function (cb, context) { - each(this._componentsMap.series, cb, context); - }, - - /** - * After filtering, series may be different. - * frome raw series. - * - * @parma {string} subType - * @param {Function} cb - * @param {*} context - */ - eachSeriesByType: function (subType, cb, context) { - assertSeriesInitialized(this); - each(this._seriesIndices, function (rawSeriesIndex) { - var series = this._componentsMap.series[rawSeriesIndex]; - if (series.subType === subType) { - cb.call(context, series, rawSeriesIndex); - } - }, this); - }, - - /** - * Iterate raw series before filtered of given type. - * - * @parma {string} subType - * @param {Function} cb - * @param {*} context - */ - eachRawSeriesByType: function (subType, cb, context) { - return each(this.getSeriesByType(subType), cb, context); - }, - - /** - * @param {module:echarts/model/Series} seriesModel - */ - isSeriesFiltered: function (seriesModel) { - assertSeriesInitialized(this); - return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0; - }, - - /** - * @param {Function} cb - * @param {*} context - */ - filterSeries: function (cb, context) { - assertSeriesInitialized(this); - var filteredSeries = filter( - this._componentsMap.series, cb, context - ); - this._seriesIndices = createSeriesIndices(filteredSeries); - }, - - restoreData: function () { - var componentsMap = this._componentsMap; - - this._seriesIndices = createSeriesIndices(componentsMap.series); - - var componentTypes = []; - each(componentsMap, function (components, componentType) { - componentTypes.push(componentType); - }); - - ComponentModel.topologicalTravel( - componentTypes, - ComponentModel.getAllClassMainTypes(), - function (componentType, dependencies) { - each(componentsMap[componentType], function (component) { - component.restoreData(); - }); - } - ); - } - - }); - - /** - * @inner - */ - function mergeTheme(option, theme) { - for (var name in theme) { - // 如果有 component model 则把具体的 merge 逻辑交给该 model 处理 - if (!ComponentModel.hasClass(name)) { - if (typeof theme[name] === 'object') { - option[name] = !option[name] - ? zrUtil.clone(theme[name]) - : zrUtil.merge(option[name], theme[name], false); - } - else { - option[name] = theme[name]; - } - } - } - } - - function initBase(baseOption) { - baseOption = baseOption; - - // Using OPTION_INNER_KEY to mark that this option can not be used outside, - // i.e. `chart.setOption(chart.getModel().option);` is forbiden. - this.option = {}; - this.option[OPTION_INNER_KEY] = 1; - - /** - * @type {Object.>} - * @private - */ - this._componentsMap = {}; - - /** - * Mapping between filtered series list and raw series list. - * key: filtered series indices, value: raw series indices. - * @type {Array.} - * @private - */ - this._seriesIndices = null; - - mergeTheme(baseOption, this._theme.option); - - // TODO Needs clone when merging to the unexisted property - zrUtil.merge(baseOption, globalDefault, false); - - this.mergeOption(baseOption); - } - - /** - * @inner - * @param {Array.|string} types model types - * @return {Object} key: {string} type, value: {Array.} models - */ - function getComponentsByTypes(componentsMap, types) { - if (!zrUtil.isArray(types)) { - types = types ? [types] : []; - } - - var ret = {}; - each(types, function (type) { - ret[type] = (componentsMap[type] || []).slice(); - }); - - return ret; - } - - /** - * @inner - */ - function makeKeyInfo(mainType, mapResult) { - // We use this id to hash component models and view instances - // in echarts. id can be specified by user, or auto generated. - - // The id generation rule ensures new view instance are able - // to mapped to old instance when setOption are called in - // no-merge mode. So we generate model id by name and plus - // type in view id. - - // name can be duplicated among components, which is convenient - // to specify multi components (like series) by one name. - - // Ensure that each id is distinct. - var idMap = {}; - - each(mapResult, function (item, index) { - var existCpt = item.exist; - existCpt && (idMap[existCpt.id] = item); - }); - - each(mapResult, function (item, index) { - var opt = item.option; - - zrUtil.assert( - !opt || opt.id == null || !idMap[opt.id] || idMap[opt.id] === item, - 'id duplicates: ' + (opt && opt.id) - ); - - opt && opt.id != null && (idMap[opt.id] = item); - - // Complete subType - if (isObject(opt)) { - var subType = determineSubType(mainType, opt, item.exist); - item.keyInfo = {mainType: mainType, subType: subType}; - } - }); - - // Make name and id. - each(mapResult, function (item, index) { - var existCpt = item.exist; - var opt = item.option; - var keyInfo = item.keyInfo; - - if (!isObject(opt)) { - return; - } - - // name can be overwitten. Consider case: axis.name = '20km'. - // But id generated by name will not be changed, which affect - // only in that case: setOption with 'not merge mode' and view - // instance will be recreated, which can be accepted. - keyInfo.name = opt.name != null - ? opt.name + '' - : existCpt - ? existCpt.name - : '\0-'; - - if (existCpt) { - keyInfo.id = existCpt.id; - } - else if (opt.id != null) { - keyInfo.id = opt.id + ''; - } - else { - // Consider this situatoin: - // optionA: [{name: 'a'}, {name: 'a'}, {..}] - // optionB [{..}, {name: 'a'}, {name: 'a'}] - // Series with the same name between optionA and optionB - // should be mapped. - var idNum = 0; - do { - keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++; - } - while (idMap[keyInfo.id]); - } - - idMap[keyInfo.id] = item; - }); - } - - /** - * @inner - */ - function determineSubType(mainType, newCptOption, existComponent) { - var subType = newCptOption.type - ? newCptOption.type - : existComponent - ? existComponent.subType - // Use determineSubType only when there is no existComponent. - : ComponentModel.determineSubType(mainType, newCptOption); - - // tooltip, markline, markpoint may always has no subType - return subType; - } - - /** - * @inner - */ - function createSeriesIndices(seriesModels) { - return map(seriesModels, function (series) { - return series.componentIndex; - }) || []; - } - - /** - * @inner - */ - function filterBySubType(components, condition) { - // Using hasOwnProperty for restrict. Consider - // subType is undefined in user payload. - return condition.hasOwnProperty('subType') - ? filter(components, function (cpt) { - return cpt.subType === condition.subType; - }) - : components; - } - - /** - * @inner - */ - function assertSeriesInitialized(ecModel) { - // Components that use _seriesIndices should depends on series component, - // which make sure that their initialization is after series. - if (!ecModel._seriesIndices) { - // FIXME - // 验证和提示怎么写 - throw new Error('Series is not initialized. Please depends sereis.'); - } - } - - return GlobalModel; -}); -define('echarts/ExtensionAPI',['require','zrender/core/util'],function(require) { + getBoundingRect: function () { + if (!this._rect) { + var style = this.style; + var rect = textContain.getBoundingRect( + style.text + '', style.textFont || style.font, style.textAlign, style.textBaseline + ); + rect.x += style.x || 0; + rect.y += style.y || 0; + this._rect = rect; + } + return this._rect; + } + }; - + zrUtil.inherits(Text, Displayable); - var zrUtil = require('zrender/core/util'); + module.exports = Text; - var echartsAPIList = [ - 'getDom', 'getZr', 'getWidth', 'getHeight', 'dispatchAction', - 'on', 'off', 'getDataURL', 'getConnectedDataURL', 'getModel', 'getOption' - ]; - function ExtensionAPI(chartInstance) { - zrUtil.each(echartsAPIList, function (name) { - this[name] = zrUtil.bind(chartInstance[name], chartInstance); - }, this); - } +/***/ }, +/* 63 */ +/***/ function(module, exports, __webpack_require__) { - return ExtensionAPI; -}); -define('echarts/CoordinateSystem',['require'],function(require) { + 'use strict'; + /** + * 圆形 + * @module zrender/shape/Circle + */ - - // var zrUtil = require('zrender/core/util'); - var coordinateSystemCreators = {}; - function CoordinateSystemManager() { + module.exports = __webpack_require__(44).extend({ + + type: 'circle', - this._coordinateSystems = []; - } + shape: { + cx: 0, + cy: 0, + r: 0 + }, - CoordinateSystemManager.prototype = { + buildPath : function (ctx, shape) { + // Better stroking in ShapeBundle + ctx.moveTo(shape.cx + shape.r, shape.cy); + ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true); + return; + } + }); - constructor: CoordinateSystemManager, - create: function (ecModel, api) { - var coordinateSystems = []; - for (var type in coordinateSystemCreators) { - var list = coordinateSystemCreators[type].create(ecModel, api); - list && (coordinateSystems = coordinateSystems.concat(list)); - } - this._coordinateSystems = coordinateSystems; - }, +/***/ }, +/* 64 */ +/***/ function(module, exports, __webpack_require__) { - update: function (ecModel, api) { - var coordinateSystems = this._coordinateSystems; - for (var i = 0; i < coordinateSystems.length; i++) { - // FIXME MUST have - coordinateSystems[i].update && coordinateSystems[i].update(ecModel, api); - } - } - }; + /** + * 扇形 + * @module zrender/graphic/shape/Sector + */ - CoordinateSystemManager.register = function (type, coordinateSystemCreator) { - coordinateSystemCreators[type] = coordinateSystemCreator; - }; + // FIXME clockwise seems wrong - CoordinateSystemManager.get = function (type) { - return coordinateSystemCreators[type]; - }; - return CoordinateSystemManager; -}); -/** - * ECharts option manager - * - * @module {echarts/model/OptionManager} - */ - -define('echarts/model/OptionManager',['require','zrender/core/util','../util/model','./Component'],function (require) { - - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../util/model'); - var ComponentModel = require('./Component'); - var each = zrUtil.each; - var clone = zrUtil.clone; - var map = zrUtil.map; - var merge = zrUtil.merge; - - var QUERY_REG = /^(min|max)?(.+)$/; - - /** - * TERM EXPLANATIONS: - * - * [option]: - * - * An object that contains definitions of components. For example: - * var option = { - * title: {...}, - * legend: {...}, - * visualMap: {...}, - * series: [ - * {data: [...]}, - * {data: [...]}, - * ... - * ] - * }; - * - * [rawOption]: - * - * An object input to echarts.setOption. 'rawOption' may be an - * 'option', or may be an object contains multi-options. For example: - * var option = { - * baseOption: { - * title: {...}, - * legend: {...}, - * series: [ - * {data: [...]}, - * {data: [...]}, - * ... - * ] - * }, - * timeline: {...}, - * options: [ - * {title: {...}, series: {data: [...]}}, - * {title: {...}, series: {data: [...]}}, - * ... - * ], - * media: [ - * { - * query: {maxWidth: 320}, - * option: {series: {x: 20}, visualMap: {show: false}} - * }, - * { - * query: {minWidth: 320, maxWidth: 720}, - * option: {series: {x: 500}, visualMap: {show: true}} - * }, - * { - * option: {series: {x: 1200}, visualMap: {show: true}} - * } - * ] - * }; - * - * @alias module:echarts/model/OptionManager - * @param {module:echarts/ExtensionAPI} api - */ - function OptionManager(api) { - - /** - * @private - * @type {module:echarts/ExtensionAPI} - */ - this._api = api; - - /** - * @private - * @type {Array.} - */ - this._timelineOptions = []; - - /** - * @private - * @type {Array.} - */ - this._mediaList = []; - - /** - * @private - * @type {Object} - */ - this._mediaDefault; - - /** - * -1, means default. - * empty means no media. - * @private - * @type {Array.} - */ - this._currentMediaIndices = []; - - /** - * @private - * @type {Object} - */ - this._optionBackup; - - /** - * @private - * @type {Object} - */ - this._newOptionBackup; - } - - // timeline.notMerge is not supported in ec3. Firstly there is rearly - // case that notMerge is needed. Secondly supporting 'notMerge' requires - // rawOption cloned and backuped when timeline changed, which does no - // good to performance. What's more, that both timeline and setOption - // method supply 'notMerge' brings complex and some problems. - // Consider this case: - // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false); - // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false); - - OptionManager.prototype = { - - constructor: OptionManager, - - /** - * @public - * @param {Object} rawOption Raw option. - * @param {module:echarts/model/Global} ecModel - * @param {Array.} optionPreprocessorFuncs - * @return {Object} Init option - */ - setOption: function (rawOption, optionPreprocessorFuncs) { - rawOption = clone(rawOption, true); - - // FIXME - // 如果 timeline options 或者 media 中设置了某个属性,而baseOption中没有设置,则进行警告。 - - var oldOptionBackup = this._optionBackup; - var newOptionBackup = this._newOptionBackup = parseRawOption.call( - this, rawOption, optionPreprocessorFuncs - ); - - // For setOption at second time (using merge mode); - if (oldOptionBackup) { - // Only baseOption can be merged. - mergeOption(oldOptionBackup.baseOption, newOptionBackup.baseOption); - - if (newOptionBackup.timelineOptions.length) { - oldOptionBackup.timelineOptions = newOptionBackup.timelineOptions; - } - if (newOptionBackup.mediaList.length) { - oldOptionBackup.mediaList = newOptionBackup.mediaList; - } - if (newOptionBackup.mediaDefault) { - oldOptionBackup.mediaDefault = newOptionBackup.mediaDefault; - } - } - else { - this._optionBackup = newOptionBackup; - } - }, - - /** - * @param {boolean} isRecreate - * @return {Object} - */ - mountOption: function (isRecreate) { - var optionBackup = isRecreate - // this._optionBackup can be only used when recreate. - // In other cases we use model.mergeOption to handle merge. - ? this._optionBackup : this._newOptionBackup; - - // FIXME - // 如果没有reset功能则不clone。 - - this._timelineOptions = map(optionBackup.timelineOptions, clone); - this._mediaList = map(optionBackup.mediaList, clone); - this._mediaDefault = clone(optionBackup.mediaDefault); - this._currentMediaIndices = []; - - return clone(optionBackup.baseOption); - }, - - /** - * @param {module:echarts/model/Global} ecModel - * @return {Object} - */ - getTimelineOption: function (ecModel) { - var option; - var timelineOptions = this._timelineOptions; - - if (timelineOptions.length) { - // getTimelineOption can only be called after ecModel inited, - // so we can get currentIndex from timelineModel. - var timelineModel = ecModel.getComponent('timeline'); - if (timelineModel) { - option = clone( - timelineOptions[timelineModel.getCurrentIndex()], - true - ); - } - } - - return option; - }, - - /** - * @param {module:echarts/model/Global} ecModel - * @return {Array.} - */ - getMediaOption: function (ecModel) { - var ecWidth = this._api.getWidth(); - var ecHeight = this._api.getHeight(); - var mediaList = this._mediaList; - var mediaDefault = this._mediaDefault; - var indices = []; - var result = []; - - // No media defined. - if (!mediaList.length && !mediaDefault) { - return result; - } - - // Multi media may be applied, the latter defined media has higher priority. - for (var i = 0, len = mediaList.length; i < len; i++) { - if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) { - indices.push(i); - } - } - - // FIXME - // 是否mediaDefault应该强制用户设置,否则可能修改不能回归。 - if (!indices.length && mediaDefault) { - indices = [-1]; - } - - if (indices.length && !indicesEquals(indices, this._currentMediaIndices)) { - result = map(indices, function (index) { - return clone( - index === -1 ? mediaDefault.option : mediaList[index].option - ); - }); - } - // Otherwise return nothing. - - this._currentMediaIndices = indices; - - return result; - } - }; - - function parseRawOption(rawOption, optionPreprocessorFuncs) { - var timelineOptions = []; - var mediaList = []; - var mediaDefault; - var baseOption; - - // Compatible with ec2. - var timelineOpt = rawOption.timeline; - - if (rawOption.baseOption) { - baseOption = rawOption.baseOption; - } - - // For timeline - if (timelineOpt || rawOption.options) { - baseOption = baseOption || {}; - timelineOptions = (rawOption.options || []).slice(); - } - // For media query - if (rawOption.media) { - baseOption = baseOption || {}; - var media = rawOption.media; - each(media, function (singleMedia) { - if (singleMedia && singleMedia.option) { - if (singleMedia.query) { - mediaList.push(singleMedia); - } - else if (!mediaDefault) { - // Use the first media default. - mediaDefault = singleMedia; - } - } - }); - } - - // For normal option - if (!baseOption) { - baseOption = rawOption; - } - - // Set timelineOpt to baseOption in ec3, - // which is convenient for merge option. - if (!baseOption.timeline) { - baseOption.timeline = timelineOpt; - } - - // Preprocess. - each([baseOption].concat(timelineOptions) - .concat(zrUtil.map(mediaList, function (media) { - return media.option; - })), - function (option) { - each(optionPreprocessorFuncs, function (preProcess) { - preProcess(option); - }); - } - ); - - return { - baseOption: baseOption, - timelineOptions: timelineOptions, - mediaDefault: mediaDefault, - mediaList: mediaList - }; - } - - /** - * @see - * Support: width, height, aspectRatio - * Can use max or min as prefix. - */ - function applyMediaQuery(query, ecWidth, ecHeight) { - var realMap = { - width: ecWidth, - height: ecHeight, - aspectratio: ecWidth / ecHeight // lowser case for convenientce. - }; - - var applicatable = true; - - zrUtil.each(query, function (value, attr) { - var matched = attr.match(QUERY_REG); - - if (!matched || !matched[1] || !matched[2]) { - return; - } - - var operator = matched[1]; - var realAttr = matched[2].toLowerCase(); - - if (!compare(realMap[realAttr], value, operator)) { - applicatable = false; - } - }); - - return applicatable; - } - - function compare(real, expect, operator) { - if (operator === 'min') { - return real >= expect; - } - else if (operator === 'max') { - return real <= expect; - } - else { // Equals - return real === expect; - } - } - - function indicesEquals(indices1, indices2) { - // indices is always order by asc and has only finite number. - return indices1.join(',') === indices2.join(','); - } - - /** - * Consider case: - * `chart.setOption(opt1);` - * Then user do some interaction like dataZoom, dataView changing. - * `chart.setOption(opt2);` - * Then user press 'reset button' in toolbox. - * - * After doing that all of the interaction effects should be reset, the - * chart should be the same as the result of invoke - * `chart.setOption(opt1); chart.setOption(opt2);`. - * - * Although it is not able ensure that - * `chart.setOption(opt1); chart.setOption(opt2);` is equivalents to - * `chart.setOption(merge(opt1, opt2));` exactly, - * this might be the only simple way to implement that feature. - * - * MEMO: We've considered some other approaches: - * 1. Each model handle its self restoration but not uniform treatment. - * (Too complex in logic and error-prone) - * 2. Use a shadow ecModel. (Performace expensive) - */ - function mergeOption(oldOption, newOption) { - newOption = newOption || {}; - - each(newOption, function (newCptOpt, mainType) { - if (newCptOpt == null) { - return; - } - - var oldCptOpt = oldOption[mainType]; - - if (!ComponentModel.hasClass(mainType)) { - oldOption[mainType] = merge(oldCptOpt, newCptOpt, true); - } - else { - newCptOpt = modelUtil.normalizeToArray(newCptOpt); - oldCptOpt = modelUtil.normalizeToArray(oldCptOpt); - - var mapResult = modelUtil.mappingToExists(oldCptOpt, newCptOpt); - - oldOption[mainType] = map(mapResult, function (item) { - return (item.option && item.exist) - ? merge(item.exist, item.option, true) - : (item.exist || item.option); - }); - } - }); - } - - return OptionManager; -}); -define('echarts/model/Series',['require','zrender/core/util','../util/format','../util/model','./Component'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var formatUtil = require('../util/format'); - var modelUtil = require('../util/model'); - var ComponentModel = require('./Component'); - - var encodeHTML = formatUtil.encodeHTML; - var addCommas = formatUtil.addCommas; - - var SeriesModel = ComponentModel.extend({ - - type: 'series', - - /** - * @readOnly - */ - seriesIndex: 0, - - // coodinateSystem will be injected in the echarts/CoordinateSystem - coordinateSystem: null, - - /** - * @type {Object} - * @protected - */ - defaultOption: null, - - /** - * Data provided for legend - * @type {Function} - */ - // PENDING - legendDataProvider: null, - - init: function (option, parentModel, ecModel, extraOpt) { - - /** - * @type {number} - * @readOnly - */ - this.seriesIndex = this.componentIndex; - - this.mergeDefaultAndTheme(option, ecModel); - - /** - * @type {module:echarts/data/List|module:echarts/data/Tree|module:echarts/data/Graph} - * @private - */ - this._dataBeforeProcessed = this.getInitialData(option, ecModel); - - // When using module:echarts/data/Tree or module:echarts/data/Graph, - // cloneShallow will cause this._data.graph.data pointing to new data list. - // Wo we make this._dataBeforeProcessed first, and then make this._data. - this._data = this._dataBeforeProcessed.cloneShallow(); - }, - - /** - * Util for merge default and theme to option - * @param {Object} option - * @param {module:echarts/model/Global} ecModel - */ - mergeDefaultAndTheme: function (option, ecModel) { - zrUtil.merge( - option, - ecModel.getTheme().get(this.subType) - ); - zrUtil.merge(option, this.getDefaultOption()); - - // Default label emphasis `position` and `show` - modelUtil.defaultEmphasis( - option.label, ['position', 'show', 'textStyle', 'distance', 'formatter'] - ); - }, - - mergeOption: function (newSeriesOption, ecModel) { - newSeriesOption = zrUtil.merge(this.option, newSeriesOption, true); - - var data = this.getInitialData(newSeriesOption, ecModel); - // TODO Merge data? - if (data) { - this._data = data; - this._dataBeforeProcessed = data.cloneShallow(); - } - }, - - /** - * Init a data structure from data related option in series - * Must be overwritten - */ - getInitialData: function () {}, - - /** - * @return {module:echarts/data/List} - */ - getData: function () { - return this._data; - }, - - /** - * @param {module:echarts/data/List} data - */ - setData: function (data) { - this._data = data; - }, - - /** - * Get data before processed - * @return {module:echarts/data/List} - */ - getRawData: function () { - return this._dataBeforeProcessed; - }, - - /** - * Get raw data array given by user - * @return {Array.} - */ - getRawDataArray: function () { - return this.option.data; - }, - - /** - * Coord dimension to data dimension. - * - * By default the result is the same as dimensions of series data. - * But some series dimensions are different from coord dimensions (i.e. - * candlestick and boxplot). Override this method to handle those cases. - * - * Coord dimension to data dimension can be one-to-many - * - * @param {string} coordDim - * @return {Array.} dimensions on the axis. - */ - coordDimToDataDim: function (coordDim) { - return [coordDim]; - }, - - /** - * Convert data dimension to coord dimension. - * - * @param {string|number} dataDim - * @return {string} - */ - dataDimToCoordDim: function (dataDim) { - return dataDim; - }, - - /** - * Get base axis if has coordinate system and has axis. - * By default use coordSys.getBaseAxis(); - * Can be overrided for some chart. - * @return {type} description - */ - getBaseAxis: function () { - var coordSys = this.coordinateSystem; - return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis(); - }, - - // FIXME - /** - * Default tooltip formatter - * - * @param {number} dataIndex - * @param {boolean} [mutipleSeries=false] - */ - formatTooltip: function (dataIndex, mutipleSeries) { - var data = this._data; - var value = this.getRawValue(dataIndex); - var formattedValue = zrUtil.isArray(value) - ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); - var name = data.getName(dataIndex); - - return !mutipleSeries - ? (encodeHTML(this.name) + '
' - + (name - ? encodeHTML(name) + ' : ' + formattedValue - : formattedValue) - ) - : (encodeHTML(this.name) + ' : ' + formattedValue); - }, - - restoreData: function () { - this._data = this._dataBeforeProcessed.cloneShallow(); - } - }); - - zrUtil.mixin(SeriesModel, modelUtil.dataFormatMixin); - - return SeriesModel; -}); -/** - * zrender: 生成唯一id - * - * @author errorrik (errorrik@gmail.com) - */ - -define( - 'zrender/core/guid',[],function() { - var idStart = 0x0907; - - return function () { - return 'zr_' + (idStart++); - }; - } -); - -/** - * 事件扩展 - * @module zrender/mixin/Eventful - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - * pissang (https://www.github.com/pissang) - */ -define('zrender/mixin/Eventful',['require','../core/util'],function (require) { - - var arrySlice = Array.prototype.slice; - var zrUtil = require('../core/util'); - var indexOf = zrUtil.indexOf; - - /** - * 事件分发器 - * @alias module:zrender/mixin/Eventful - * @constructor - */ - var Eventful = function () { - this._$handlers = {}; - }; - - Eventful.prototype = { - - constructor: Eventful, - - /** - * 单次触发绑定,trigger后销毁 - * - * @param {string} event 事件名 - * @param {Function} handler 响应函数 - * @param {Object} context - */ - one: function (event, handler, context) { - var _h = this._$handlers; - - if (!handler || !event) { - return this; - } - - if (!_h[event]) { - _h[event] = []; - } - - if (indexOf(_h[event], event) >= 0) { - return this; - } - - _h[event].push({ - h: handler, - one: true, - ctx: context || this - }); - - return this; - }, - - /** - * 绑定事件 - * @param {string} event 事件名 - * @param {Function} handler 事件处理函数 - * @param {Object} [context] - */ - on: function (event, handler, context) { - var _h = this._$handlers; - - if (!handler || !event) { - return this; - } - - if (!_h[event]) { - _h[event] = []; - } - - _h[event].push({ - h: handler, - one: false, - ctx: context || this - }); - - return this; - }, - - /** - * 是否绑定了事件 - * @param {string} event - * @return {boolean} - */ - isSilent: function (event) { - var _h = this._$handlers; - return _h[event] && _h[event].length; - }, - - /** - * 解绑事件 - * @param {string} event 事件名 - * @param {Function} [handler] 事件处理函数 - */ - off: function (event, handler) { - var _h = this._$handlers; - - if (!event) { - this._$handlers = {}; - return this; - } - - if (handler) { - if (_h[event]) { - var newList = []; - for (var i = 0, l = _h[event].length; i < l; i++) { - if (_h[event][i]['h'] != handler) { - newList.push(_h[event][i]); - } - } - _h[event] = newList; - } - - if (_h[event] && _h[event].length === 0) { - delete _h[event]; - } - } - else { - delete _h[event]; - } - - return this; - }, - - /** - * 事件分发 - * - * @param {string} type 事件类型 - */ - trigger: function (type) { - if (this._$handlers[type]) { - var args = arguments; - var argLen = args.length; - - if (argLen > 3) { - args = arrySlice.call(args, 1); - } - - var _h = this._$handlers[type]; - var len = _h.length; - for (var i = 0; i < len;) { - // Optimize advise from backbone - switch (argLen) { - case 1: - _h[i]['h'].call(_h[i]['ctx']); - break; - case 2: - _h[i]['h'].call(_h[i]['ctx'], args[1]); - break; - case 3: - _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]); - break; - default: - // have more than 2 given arguments - _h[i]['h'].apply(_h[i]['ctx'], args); - break; - } - - if (_h[i]['one']) { - _h.splice(i, 1); - len--; - } - else { - i++; - } - } - } - - return this; - }, - - /** - * 带有context的事件分发, 最后一个参数是事件回调的context - * @param {string} type 事件类型 - */ - triggerWithContext: function (type) { - if (this._$handlers[type]) { - var args = arguments; - var argLen = args.length; - - if (argLen > 4) { - args = arrySlice.call(args, 1, args.length - 1); - } - var ctx = args[args.length - 1]; - - var _h = this._$handlers[type]; - var len = _h.length; - for (var i = 0; i < len;) { - // Optimize advise from backbone - switch (argLen) { - case 1: - _h[i]['h'].call(ctx); - break; - case 2: - _h[i]['h'].call(ctx, args[1]); - break; - case 3: - _h[i]['h'].call(ctx, args[1], args[2]); - break; - default: - // have more than 2 given arguments - _h[i]['h'].apply(ctx, args); - break; - } - - if (_h[i]['one']) { - _h.splice(i, 1); - len--; - } - else { - i++; - } - } - } - - return this; - } - }; - - // 对象可以通过 onxxxx 绑定事件 - /** - * @event module:zrender/mixin/Eventful#onclick - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmouseover - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmouseout - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmousemove - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmousewheel - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmousedown - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmouseup - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragstart - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragend - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragenter - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragleave - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragover - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondrop - * @type {Function} - * @default null - */ - - return Eventful; -}); + module.exports = __webpack_require__(44).extend({ -/** - * 提供变换扩展 - * @module zrender/mixin/Transformable - * @author pissang (https://www.github.com/pissang) - */ -define('zrender/mixin/Transformable',['require','../core/matrix','../core/vector'],function (require) { - - - - var matrix = require('../core/matrix'); - var vector = require('../core/vector'); - var mIdentity = matrix.identity; - - var EPSILON = 5e-5; - - function isNotAroundZero(val) { - return val > EPSILON || val < -EPSILON; - } - - /** - * @alias module:zrender/mixin/Transformable - * @constructor - */ - var Transformable = function (opts) { - opts = opts || {}; - // If there are no given position, rotation, scale - if (!opts.position) { - /** - * 平移 - * @type {Array.} - * @default [0, 0] - */ - this.position = [0, 0]; - } - if (opts.rotation == null) { - /** - * 旋转 - * @type {Array.} - * @default 0 - */ - this.rotation = 0; - } - if (!opts.scale) { - /** - * 缩放 - * @type {Array.} - * @default [1, 1] - */ - this.scale = [1, 1]; - } - /** - * 旋转和缩放的原点 - * @type {Array.} - * @default null - */ - this.origin = this.origin || null; - }; - - var transformableProto = Transformable.prototype; - transformableProto.transform = null; - - /** - * 判断是否需要有坐标变换 - * 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵 - */ - transformableProto.needLocalTransform = function () { - return isNotAroundZero(this.rotation) - || isNotAroundZero(this.position[0]) - || isNotAroundZero(this.position[1]) - || isNotAroundZero(this.scale[0] - 1) - || isNotAroundZero(this.scale[1] - 1); - }; - - transformableProto.updateTransform = function () { - var parent = this.parent; - var parentHasTransform = parent && parent.transform; - var needLocalTransform = this.needLocalTransform(); - - var m = this.transform; - if (!(needLocalTransform || parentHasTransform)) { - m && mIdentity(m); - return; - } - - m = m || matrix.create(); - - if (needLocalTransform) { - this.getLocalTransform(m); - } - else { - mIdentity(m); - } - - // 应用父节点变换 - if (parentHasTransform) { - if (needLocalTransform) { - matrix.mul(m, parent.transform, m); - } - else { - matrix.copy(m, parent.transform); - } - } - // 保存这个变换矩阵 - this.transform = m; - - this.invTransform = this.invTransform || matrix.create(); - matrix.invert(this.invTransform, m); - }; - - transformableProto.getLocalTransform = function (m) { - m = m || []; - mIdentity(m); - - var origin = this.origin; - - var scale = this.scale; - var rotation = this.rotation; - var position = this.position; - if (origin) { - // Translate to origin - m[4] -= origin[0]; - m[5] -= origin[1]; - } - matrix.scale(m, m, scale); - if (rotation) { - matrix.rotate(m, m, rotation); - } - if (origin) { - // Translate back from origin - m[4] += origin[0]; - m[5] += origin[1]; - } - - m[4] += position[0]; - m[5] += position[1]; - - return m; - }; - /** - * 将自己的transform应用到context上 - * @param {Context2D} ctx - */ - transformableProto.setTransform = function (ctx) { - var m = this.transform; - if (m) { - ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); - } - }; - - var tmpTransform = []; - - /** - * 分解`transform`矩阵到`position`, `rotation`, `scale` - */ - transformableProto.decomposeTransform = function () { - if (!this.transform) { - return; - } - var parent = this.parent; - var m = this.transform; - if (parent && parent.transform) { - // Get local transform and decompose them to position, scale, rotation - matrix.mul(tmpTransform, parent.invTransform, m); - m = tmpTransform; - } - var sx = m[0] * m[0] + m[1] * m[1]; - var sy = m[2] * m[2] + m[3] * m[3]; - var position = this.position; - var scale = this.scale; - if (isNotAroundZero(sx - 1)) { - sx = Math.sqrt(sx); - } - if (isNotAroundZero(sy - 1)) { - sy = Math.sqrt(sy); - } - if (m[0] < 0) { - sx = -sx; - } - if (m[3] < 0) { - sy = -sy; - } - position[0] = m[4]; - position[1] = m[5]; - scale[0] = sx; - scale[1] = sy; - this.rotation = Math.atan2(-m[1] / sy, m[0] / sx); - }; - - /** - * 变换坐标位置到 shape 的局部坐标空间 - * @method - * @param {number} x - * @param {number} y - * @return {Array.} - */ - transformableProto.transformCoordToLocal = function (x, y) { - var v2 = [x, y]; - var invTransform = this.invTransform; - if (invTransform) { - vector.applyTransform(v2, v2, invTransform); - } - return v2; - }; - - /** - * 变换局部坐标位置到全局坐标空间 - * @method - * @param {number} x - * @param {number} y - * @return {Array.} - */ - transformableProto.transformCoordToGlobal = function (x, y) { - var v2 = [x, y]; - var transform = this.transform; - if (transform) { - vector.applyTransform(v2, v2, transform); - } - return v2; - }; - - return Transformable; -}); + type: 'sector', -/** - * 缓动代码来自 https://github.com/sole/tween.js/blob/master/src/Tween.js - * @see http://sole.github.io/tween.js/examples/03_graphs.html - * @exports zrender/animation/easing - */ -define('zrender/animation/easing',[],function () { - var easing = { - /** - * @param {number} k - * @return {number} - */ - linear: function (k) { - return k; - }, - - /** - * @param {number} k - * @return {number} - */ - quadraticIn: function (k) { - return k * k; - }, - /** - * @param {number} k - * @return {number} - */ - quadraticOut: function (k) { - return k * (2 - k); - }, - /** - * @param {number} k - * @return {number} - */ - quadraticInOut: function (k) { - if ((k *= 2) < 1) { - return 0.5 * k * k; - } - return -0.5 * (--k * (k - 2) - 1); - }, - - // 三次方的缓动(t^3) - /** - * @param {number} k - * @return {number} - */ - cubicIn: function (k) { - return k * k * k; - }, - /** - * @param {number} k - * @return {number} - */ - cubicOut: function (k) { - return --k * k * k + 1; - }, - /** - * @param {number} k - * @return {number} - */ - cubicInOut: function (k) { - if ((k *= 2) < 1) { - return 0.5 * k * k * k; - } - return 0.5 * ((k -= 2) * k * k + 2); - }, - - // 四次方的缓动(t^4) - /** - * @param {number} k - * @return {number} - */ - quarticIn: function (k) { - return k * k * k * k; - }, - /** - * @param {number} k - * @return {number} - */ - quarticOut: function (k) { - return 1 - (--k * k * k * k); - }, - /** - * @param {number} k - * @return {number} - */ - quarticInOut: function (k) { - if ((k *= 2) < 1) { - return 0.5 * k * k * k * k; - } - return -0.5 * ((k -= 2) * k * k * k - 2); - }, - - // 五次方的缓动(t^5) - /** - * @param {number} k - * @return {number} - */ - quinticIn: function (k) { - return k * k * k * k * k; - }, - /** - * @param {number} k - * @return {number} - */ - quinticOut: function (k) { - return --k * k * k * k * k + 1; - }, - /** - * @param {number} k - * @return {number} - */ - quinticInOut: function (k) { - if ((k *= 2) < 1) { - return 0.5 * k * k * k * k * k; - } - return 0.5 * ((k -= 2) * k * k * k * k + 2); - }, - - // 正弦曲线的缓动(sin(t)) - /** - * @param {number} k - * @return {number} - */ - sinusoidalIn: function (k) { - return 1 - Math.cos(k * Math.PI / 2); - }, - /** - * @param {number} k - * @return {number} - */ - sinusoidalOut: function (k) { - return Math.sin(k * Math.PI / 2); - }, - /** - * @param {number} k - * @return {number} - */ - sinusoidalInOut: function (k) { - return 0.5 * (1 - Math.cos(Math.PI * k)); - }, - - // 指数曲线的缓动(2^t) - /** - * @param {number} k - * @return {number} - */ - exponentialIn: function (k) { - return k === 0 ? 0 : Math.pow(1024, k - 1); - }, - /** - * @param {number} k - * @return {number} - */ - exponentialOut: function (k) { - return k === 1 ? 1 : 1 - Math.pow(2, -10 * k); - }, - /** - * @param {number} k - * @return {number} - */ - exponentialInOut: function (k) { - if (k === 0) { - return 0; - } - if (k === 1) { - return 1; - } - if ((k *= 2) < 1) { - return 0.5 * Math.pow(1024, k - 1); - } - return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2); - }, - - // 圆形曲线的缓动(sqrt(1-t^2)) - /** - * @param {number} k - * @return {number} - */ - circularIn: function (k) { - return 1 - Math.sqrt(1 - k * k); - }, - /** - * @param {number} k - * @return {number} - */ - circularOut: function (k) { - return Math.sqrt(1 - (--k * k)); - }, - /** - * @param {number} k - * @return {number} - */ - circularInOut: function (k) { - if ((k *= 2) < 1) { - return -0.5 * (Math.sqrt(1 - k * k) - 1); - } - return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); - }, - - // 创建类似于弹簧在停止前来回振荡的动画 - /** - * @param {number} k - * @return {number} - */ - elasticIn: function (k) { - var s; - var a = 0.1; - var p = 0.4; - if (k === 0) { - return 0; - } - if (k === 1) { - return 1; - } - if (!a || a < 1) { - a = 1; s = p / 4; - } - else { - s = p * Math.asin(1 / a) / (2 * Math.PI); - } - return -(a * Math.pow(2, 10 * (k -= 1)) * - Math.sin((k - s) * (2 * Math.PI) / p)); - }, - /** - * @param {number} k - * @return {number} - */ - elasticOut: function (k) { - var s; - var a = 0.1; - var p = 0.4; - if (k === 0) { - return 0; - } - if (k === 1) { - return 1; - } - if (!a || a < 1) { - a = 1; s = p / 4; - } - else { - s = p * Math.asin(1 / a) / (2 * Math.PI); - } - return (a * Math.pow(2, -10 * k) * - Math.sin((k - s) * (2 * Math.PI) / p) + 1); - }, - /** - * @param {number} k - * @return {number} - */ - elasticInOut: function (k) { - var s; - var a = 0.1; - var p = 0.4; - if (k === 0) { - return 0; - } - if (k === 1) { - return 1; - } - if (!a || a < 1) { - a = 1; s = p / 4; - } - else { - s = p * Math.asin(1 / a) / (2 * Math.PI); - } - if ((k *= 2) < 1) { - return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) - * Math.sin((k - s) * (2 * Math.PI) / p)); - } - return a * Math.pow(2, -10 * (k -= 1)) - * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1; - - }, - - // 在某一动画开始沿指示的路径进行动画处理前稍稍收回该动画的移动 - /** - * @param {number} k - * @return {number} - */ - backIn: function (k) { - var s = 1.70158; - return k * k * ((s + 1) * k - s); - }, - /** - * @param {number} k - * @return {number} - */ - backOut: function (k) { - var s = 1.70158; - return --k * k * ((s + 1) * k + s) + 1; - }, - /** - * @param {number} k - * @return {number} - */ - backInOut: function (k) { - var s = 1.70158 * 1.525; - if ((k *= 2) < 1) { - return 0.5 * (k * k * ((s + 1) * k - s)); - } - return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); - }, - - // 创建弹跳效果 - /** - * @param {number} k - * @return {number} - */ - bounceIn: function (k) { - return 1 - easing.bounceOut(1 - k); - }, - /** - * @param {number} k - * @return {number} - */ - bounceOut: function (k) { - if (k < (1 / 2.75)) { - return 7.5625 * k * k; - } - else if (k < (2 / 2.75)) { - return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75; - } - else if (k < (2.5 / 2.75)) { - return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375; - } - else { - return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; - } - }, - /** - * @param {number} k - * @return {number} - */ - bounceInOut: function (k) { - if (k < 0.5) { - return easing.bounceIn(k * 2) * 0.5; - } - return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5; - } - }; - - return easing; -}); + shape: { + cx: 0, -/** - * 动画主控制器 - * @config target 动画对象,可以是数组,如果是数组的话会批量分发onframe等事件 - * @config life(1000) 动画时长 - * @config delay(0) 动画延迟时间 - * @config loop(true) - * @config gap(0) 循环的间隔时间 - * @config onframe - * @config easing(optional) - * @config ondestroy(optional) - * @config onrestart(optional) - * - * TODO pause - */ -define('zrender/animation/Clip',['require','./easing'],function(require) { - - var easingFuncs = require('./easing'); - - function Clip(options) { - - this._target = options.target; - - // 生命周期 - this._life = options.life || 1000; - // 延时 - this._delay = options.delay || 0; - // 开始时间 - // this._startTime = new Date().getTime() + this._delay;// 单位毫秒 - this._initialized = false; - - // 是否循环 - this.loop = options.loop == null ? false : options.loop; - - this.gap = options.gap || 0; - - this.easing = options.easing || 'Linear'; - - this.onframe = options.onframe; - this.ondestroy = options.ondestroy; - this.onrestart = options.onrestart; - } - - Clip.prototype = { - - constructor: Clip, - - step: function (time) { - // Set startTime on first step, or _startTime may has milleseconds different between clips - // PENDING - if (!this._initialized) { - this._startTime = new Date().getTime() + this._delay; - this._initialized = true; - } - - var percent = (time - this._startTime) / this._life; - - // 还没开始 - if (percent < 0) { - return; - } - - percent = Math.min(percent, 1); - - var easing = this.easing; - var easingFunc = typeof easing == 'string' ? easingFuncs[easing] : easing; - var schedule = typeof easingFunc === 'function' - ? easingFunc(percent) - : percent; - - this.fire('frame', schedule); - - // 结束 - if (percent == 1) { - if (this.loop) { - this.restart(); - // 重新开始周期 - // 抛出而不是直接调用事件直到 stage.update 后再统一调用这些事件 - return 'restart'; - } - - // 动画完成将这个控制器标识为待删除 - // 在Animation.update中进行批量删除 - this._needsRemove = true; - return 'destroy'; - } - - return null; - }, - - restart: function() { - var time = new Date().getTime(); - var remainder = (time - this._startTime) % this._life; - this._startTime = new Date().getTime() - remainder + this.gap; - - this._needsRemove = false; - }, - - fire: function(eventType, arg) { - eventType = 'on' + eventType; - if (this[eventType]) { - this[eventType](this._target, arg); - } - } - }; - - return Clip; -}); + cy: 0, -/** - * @module zrender/tool/color - */ -define('zrender/tool/color',['require'],function(require) { - - var kCSSColorTable = { - 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1], - 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1], - 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1], - 'beige': [245,245,220,1], 'bisque': [255,228,196,1], - 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1], - 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1], - 'brown': [165,42,42,1], 'burlywood': [222,184,135,1], - 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1], - 'chocolate': [210,105,30,1], 'coral': [255,127,80,1], - 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1], - 'crimson': [220,20,60,1], 'cyan': [0,255,255,1], - 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1], - 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1], - 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1], - 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1], - 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1], - 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1], - 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1], - 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1], - 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1], - 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1], - 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1], - 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1], - 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1], - 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1], - 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1], - 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1], - 'gray': [128,128,128,1], 'green': [0,128,0,1], - 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1], - 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1], - 'indianred': [205,92,92,1], 'indigo': [75,0,130,1], - 'ivory': [255,255,240,1], 'khaki': [240,230,140,1], - 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1], - 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1], - 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1], - 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1], - 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1], - 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1], - 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1], - 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1], - 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1], - 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1], - 'limegreen': [50,205,50,1], 'linen': [250,240,230,1], - 'magenta': [255,0,255,1], 'maroon': [128,0,0,1], - 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1], - 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1], - 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1], - 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1], - 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1], - 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1], - 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1], - 'navy': [0,0,128,1], 'oldlace': [253,245,230,1], - 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1], - 'orange': [255,165,0,1], 'orangered': [255,69,0,1], - 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1], - 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1], - 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1], - 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1], - 'pink': [255,192,203,1], 'plum': [221,160,221,1], - 'powderblue': [176,224,230,1], 'purple': [128,0,128,1], - 'red': [255,0,0,1], 'rosybrown': [188,143,143,1], - 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1], - 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1], - 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1], - 'sienna': [160,82,45,1], 'silver': [192,192,192,1], - 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1], - 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1], - 'snow': [255,250,250,1], 'springgreen': [0,255,127,1], - 'steelblue': [70,130,180,1], 'tan': [210,180,140,1], - 'teal': [0,128,128,1], 'thistle': [216,191,216,1], - 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1], - 'violet': [238,130,238,1], 'wheat': [245,222,179,1], - 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1], - 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1] - }; - - function clampCssByte(i) { // Clamp to integer 0 .. 255. - i = Math.round(i); // Seems to be what Chrome does (vs truncation). - return i < 0 ? 0 : i > 255 ? 255 : i; - } - - function clampCssAngle(i) { // Clamp to integer 0 .. 360. - i = Math.round(i); // Seems to be what Chrome does (vs truncation). - return i < 0 ? 0 : i > 360 ? 360 : i; - } - - function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0. - return f < 0 ? 0 : f > 1 ? 1 : f; - } - - function parseCssInt(str) { // int or percentage. - if (str.length && str.charAt(str.length - 1) === '%') { - return clampCssByte(parseFloat(str) / 100 * 255); - } - return clampCssByte(parseInt(str, 10)); - } - - function parseCssFloat(str) { // float or percentage. - if (str.length && str.charAt(str.length - 1) === '%') { - return clampCssFloat(parseFloat(str) / 100); - } - return clampCssFloat(parseFloat(str)); - } - - function cssHueToRgb(m1, m2, h) { - if (h < 0) { - h += 1; - } - else if (h > 1) { - h -= 1; - } - - if (h * 6 < 1) { - return m1 + (m2 - m1) * h * 6; - } - if (h * 2 < 1) { - return m2; - } - if (h * 3 < 2) { - return m1 + (m2 - m1) * (2/3 - h) * 6; - } - return m1; - } - - function lerp(a, b, p) { - return a + (b - a) * p; - } - - /** - * @param {string} colorStr - * @return {Array.} - * @memberOf module:zrender/util/color - */ - function parse(colorStr) { - if (!colorStr) { - return; - } - // colorStr may be not string - colorStr = colorStr + ''; - // Remove all whitespace, not compliant, but should just be more accepting. - var str = colorStr.replace(/ /g, '').toLowerCase(); - - // Color keywords (and transparent) lookup. - if (str in kCSSColorTable) { - return kCSSColorTable[str].slice(); // dup. - } - - // #abc and #abc123 syntax. - if (str.charAt(0) === '#') { - if (str.length === 4) { - var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. - if (!(iv >= 0 && iv <= 0xfff)) { - return; // Covers NaN. - } - return [ - ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8), - (iv & 0xf0) | ((iv & 0xf0) >> 4), - (iv & 0xf) | ((iv & 0xf) << 4), - 1 - ]; - } - else if (str.length === 7) { - var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. - if (!(iv >= 0 && iv <= 0xffffff)) { - return; // Covers NaN. - } - return [ - (iv & 0xff0000) >> 16, - (iv & 0xff00) >> 8, - iv & 0xff, - 1 - ]; - } - - return; - } - var op = str.indexOf('('), ep = str.indexOf(')'); - if (op !== -1 && ep + 1 === str.length) { - var fname = str.substr(0, op); - var params = str.substr(op + 1, ep - (op + 1)).split(','); - var alpha = 1; // To allow case fallthrough. - switch (fname) { - case 'rgba': - if (params.length !== 4) { - return; - } - alpha = parseCssFloat(params.pop()); // jshint ignore:line - // Fall through. - case 'rgb': - if (params.length !== 3) { - return; - } - return [ - parseCssInt(params[0]), - parseCssInt(params[1]), - parseCssInt(params[2]), - alpha - ]; - case 'hsla': - if (params.length !== 4) { - return; - } - params[3] = parseCssFloat(params[3]); - return hsla2rgba(params); - case 'hsl': - if (params.length !== 3) { - return; - } - return hsla2rgba(params); - default: - return; - } - } - - return; - } - - /** - * @param {Array.} hsla - * @return {Array.} rgba - */ - function hsla2rgba(hsla) { - var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1 - // NOTE(deanm): According to the CSS spec s/l should only be - // percentages, but we don't bother and let float or percentage. - var s = parseCssFloat(hsla[1]); - var l = parseCssFloat(hsla[2]); - var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; - var m1 = l * 2 - m2; - - var rgba = [ - clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255), - clampCssByte(cssHueToRgb(m1, m2, h) * 255), - clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255) - ]; - - if (hsla.length === 4) { - rgba[3] = hsla[3]; - } - - return rgba; - } - - /** - * @param {Array.} rgba - * @return {Array.} hsla - */ - function rgba2hsla(rgba) { - if (!rgba) { - return; - } - - // RGB from 0 to 255 - var R = rgba[0] / 255; - var G = rgba[1] / 255; - var B = rgba[2] / 255; - - var vMin = Math.min(R, G, B); // Min. value of RGB - var vMax = Math.max(R, G, B); // Max. value of RGB - var delta = vMax - vMin; // Delta RGB value - - var L = (vMax + vMin) / 2; - var H; - var S; - // HSL results from 0 to 1 - if (delta === 0) { - H = 0; - S = 0; - } - else { - if (L < 0.5) { - S = delta / (vMax + vMin); - } - else { - S = delta / (2 - vMax - vMin); - } - - var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta; - var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta; - var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta; - - if (R === vMax) { - H = deltaB - deltaG; - } - else if (G === vMax) { - H = (1 / 3) + deltaR - deltaB; - } - else if (B === vMax) { - H = (2 / 3) + deltaG - deltaR; - } - - if (H < 0) { - H += 1; - } - - if (H > 1) { - H -= 1; - } - } - - var hsla = [H * 360, S, L]; - - if (rgba[3] != null) { - hsla.push(rgba[3]); - } - - return hsla; - } - - /** - * @param {string} color - * @param {number} level - * @return {string} - * @memberOf module:zrender/util/color - */ - function lift(color, level) { - var colorArr = parse(color); - if (colorArr) { - for (var i = 0; i < 3; i++) { - if (level < 0) { - colorArr[i] = colorArr[i] * (1 - level) | 0; - } - else { - colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0; - } - } - return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb'); - } - } - - /** - * @param {string} color - * @return {string} - * @memberOf module:zrender/util/color - */ - function toHex(color, level) { - var colorArr = parse(color); - if (colorArr) { - return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1); - } - } - - /** - * Map value to color. Faster than mapToColor methods because color is represented by rgba array - * @param {number} normalizedValue A float between 0 and 1. - * @param {Array.>} colors List of rgba color array - * @param {Array.} [out] Mapped gba color array - * @return {Array.} - */ - function fastMapToColor(normalizedValue, colors, out) { - if (!(colors && colors.length) - || !(normalizedValue >= 0 && normalizedValue <= 1) - ) { - return; - } - out = out || [0, 0, 0, 0]; - var value = normalizedValue * (colors.length - 1); - var leftIndex = Math.floor(value); - var rightIndex = Math.ceil(value); - var leftColor = colors[leftIndex]; - var rightColor = colors[rightIndex]; - var dv = value - leftIndex; - out[0] = clampCssByte(lerp(leftColor[0], rightColor[0], dv)); - out[1] = clampCssByte(lerp(leftColor[1], rightColor[1], dv)); - out[2] = clampCssByte(lerp(leftColor[2], rightColor[2], dv)); - out[3] = clampCssByte(lerp(leftColor[3], rightColor[3], dv)); - return out; - } - /** - * @param {number} normalizedValue A float between 0 and 1. - * @param {Array.} colors Color list. - * @param {boolean=} fullOutput Default false. - * @return {(string|Object)} Result color. If fullOutput, - * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...}, - * @memberOf module:zrender/util/color - */ - function mapToColor(normalizedValue, colors, fullOutput) { - if (!(colors && colors.length) - || !(normalizedValue >= 0 && normalizedValue <= 1) - ) { - return; - } - - var value = normalizedValue * (colors.length - 1); - var leftIndex = Math.floor(value); - var rightIndex = Math.ceil(value); - var leftColor = parse(colors[leftIndex]); - var rightColor = parse(colors[rightIndex]); - var dv = value - leftIndex; - - var color = stringify( - [ - clampCssByte(lerp(leftColor[0], rightColor[0], dv)), - clampCssByte(lerp(leftColor[1], rightColor[1], dv)), - clampCssByte(lerp(leftColor[2], rightColor[2], dv)), - clampCssFloat(lerp(leftColor[3], rightColor[3], dv)) - ], - 'rgba' - ); - - return fullOutput - ? { - color: color, - leftIndex: leftIndex, - rightIndex: rightIndex, - value: value - } - : color; - } - - /** - * @param {Array} interval Array length === 2, - * each item is normalized value ([0, 1]). - * @param {Array.} colors Color list. - * @return {Array.} colors corresponding to the interval, - * each item is {color: 'xxx', offset: ...} - * where offset is between 0 and 1. - * @memberOf module:zrender/util/color - */ - function mapIntervalToColor(interval, colors) { - if (interval.length !== 2 || interval[1] < interval[0]) { - return; - } - - var info0 = mapToColor(interval[0], colors, true); - var info1 = mapToColor(interval[1], colors, true); - - var result = [{color: info0.color, offset: 0}]; - - var during = info1.value - info0.value; - var start = Math.max(info0.value, info0.rightIndex); - var end = Math.min(info1.value, info1.leftIndex); - - for (var i = start; during > 0 && i <= end; i++) { - result.push({ - color: colors[i], - offset: (i - info0.value) / during - }); - } - result.push({color: info1.color, offset: 1}); - - return result; - } - - /** - * @param {string} color - * @param {number=} h 0 ~ 360, ignore when null. - * @param {number=} s 0 ~ 1, ignore when null. - * @param {number=} l 0 ~ 1, ignore when null. - * @return {string} Color string in rgba format. - * @memberOf module:zrender/util/color - */ - function modifyHSL(color, h, s, l) { - color = parse(color); - - if (color) { - color = rgba2hsla(color); - h != null && (color[0] = clampCssAngle(h)); - s != null && (color[1] = parseCssFloat(s)); - l != null && (color[2] = parseCssFloat(l)); - - return stringify(hsla2rgba(color), 'rgba'); - } - } - - /** - * @param {string} color - * @param {number=} alpha 0 ~ 1 - * @return {string} Color string in rgba format. - * @memberOf module:zrender/util/color - */ - function modifyAlpha(color, alpha) { - color = parse(color); - - if (color && alpha != null) { - color[3] = clampCssFloat(alpha); - return stringify(color, 'rgba'); - } - } - - /** - * @param {Array.} colors Color list. - * @param {string} type 'rgba', 'hsva', ... - * @return {string} Result color. - */ - function stringify(arrColor, type) { - if (type === 'rgb' || type === 'hsv' || type === 'hsl') { - arrColor = arrColor.slice(0, 3); - } - return type + '(' + arrColor.join(',') + ')'; - } - - return { - parse: parse, - lift: lift, - toHex: toHex, - fastMapToColor: fastMapToColor, - mapToColor: mapToColor, - mapIntervalToColor: mapIntervalToColor, - modifyHSL: modifyHSL, - modifyAlpha: modifyAlpha, - stringify: stringify - }; -}); + r0: 0, + r: 0, -/** - * @module echarts/animation/Animator - */ -define('zrender/animation/Animator',['require','./Clip','../tool/color','../core/util'],function (require) { - - var Clip = require('./Clip'); - var color = require('../tool/color'); - var util = require('../core/util'); - var isArrayLike = util.isArrayLike; - - var arraySlice = Array.prototype.slice; - - function defaultGetter(target, key) { - return target[key]; - } - - function defaultSetter(target, key, value) { - target[key] = value; - } - - /** - * @param {number} p0 - * @param {number} p1 - * @param {number} percent - * @return {number} - */ - function interpolateNumber(p0, p1, percent) { - return (p1 - p0) * percent + p0; - } - - /** - * @param {string} p0 - * @param {string} p1 - * @param {number} percent - * @return {string} - */ - function interpolateString(p0, p1, percent) { - return percent > 0.5 ? p1 : p0; - } - - /** - * @param {Array} p0 - * @param {Array} p1 - * @param {number} percent - * @param {Array} out - * @param {number} arrDim - */ - function interpolateArray(p0, p1, percent, out, arrDim) { - var len = p0.length; - if (arrDim == 1) { - for (var i = 0; i < len; i++) { - out[i] = interpolateNumber(p0[i], p1[i], percent); - } - } - else { - var len2 = p0[0].length; - for (var i = 0; i < len; i++) { - for (var j = 0; j < len2; j++) { - out[i][j] = interpolateNumber( - p0[i][j], p1[i][j], percent - ); - } - } - } - } - - function fillArr(arr0, arr1, arrDim) { - var arr0Len = arr0.length; - var arr1Len = arr1.length; - if (arr0Len === arr1Len) { - return; - } - // FIXME Not work for TypedArray - var isPreviousLarger = arr0Len > arr1Len; - if (isPreviousLarger) { - // Cut the previous - arr0.length = arr1Len; - } - else { - // Fill the previous - for (var i = arr0Len; i < arr1Len; i++) { - arr0.push( - arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i]) - ); - } - } - } - - /** - * @param {Array} arr0 - * @param {Array} arr1 - * @param {number} arrDim - * @return {boolean} - */ - function isArraySame(arr0, arr1, arrDim) { - if (arr0 === arr1) { - return true; - } - var len = arr0.length; - if (len !== arr1.length) { - return false; - } - if (arrDim === 1) { - for (var i = 0; i < len; i++) { - if (arr0[i] !== arr1[i]) { - return false; - } - } - } - else { - var len2 = arr0[0].length; - for (var i = 0; i < len; i++) { - for (var j = 0; j < len2; j++) { - if (arr0[i][j] !== arr1[i][j]) { - return false; - } - } - } - } - return true; - } - - /** - * Catmull Rom interpolate array - * @param {Array} p0 - * @param {Array} p1 - * @param {Array} p2 - * @param {Array} p3 - * @param {number} t - * @param {number} t2 - * @param {number} t3 - * @param {Array} out - * @param {number} arrDim - */ - function catmullRomInterpolateArray( - p0, p1, p2, p3, t, t2, t3, out, arrDim - ) { - var len = p0.length; - if (arrDim == 1) { - for (var i = 0; i < len; i++) { - out[i] = catmullRomInterpolate( - p0[i], p1[i], p2[i], p3[i], t, t2, t3 - ); - } - } - else { - var len2 = p0[0].length; - for (var i = 0; i < len; i++) { - for (var j = 0; j < len2; j++) { - out[i][j] = catmullRomInterpolate( - p0[i][j], p1[i][j], p2[i][j], p3[i][j], - t, t2, t3 - ); - } - } - } - } - - /** - * Catmull Rom interpolate number - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} t - * @param {number} t2 - * @param {number} t3 - * @return {number} - */ - function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) { - var v0 = (p2 - p0) * 0.5; - var v1 = (p3 - p1) * 0.5; - return (2 * (p1 - p2) + v0 + v1) * t3 - + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 - + v0 * t + p1; - } - - function cloneValue(value) { - if (isArrayLike(value)) { - var len = value.length; - if (isArrayLike(value[0])) { - var ret = []; - for (var i = 0; i < len; i++) { - ret.push(arraySlice.call(value[i])); - } - return ret; - } - - return arraySlice.call(value); - } - - return value; - } - - function rgba2String(rgba) { - rgba[0] = Math.floor(rgba[0]); - rgba[1] = Math.floor(rgba[1]); - rgba[2] = Math.floor(rgba[2]); - - return 'rgba(' + rgba.join(',') + ')'; - } - - function createTrackClip (animator, easing, oneTrackDone, keyframes, propName) { - var getter = animator._getter; - var setter = animator._setter; - var useSpline = easing === 'spline'; - - var trackLen = keyframes.length; - if (!trackLen) { - return; - } - // Guess data type - var firstVal = keyframes[0].value; - var isValueArray = isArrayLike(firstVal); - var isValueColor = false; - var isValueString = false; - - // For vertices morphing - var arrDim = ( - isValueArray - && isArrayLike(firstVal[0]) - ) - ? 2 : 1; - var trackMaxTime; - // Sort keyframe as ascending - keyframes.sort(function(a, b) { - return a.time - b.time; - }); - - trackMaxTime = keyframes[trackLen - 1].time; - // Percents of each keyframe - var kfPercents = []; - // Value of each keyframe - var kfValues = []; - var prevValue = keyframes[0].value; - var isAllValueEqual = true; - for (var i = 0; i < trackLen; i++) { - kfPercents.push(keyframes[i].time / trackMaxTime); - // Assume value is a color when it is a string - var value = keyframes[i].value; - - // Check if value is equal, deep check if value is array - if (!((isValueArray && isArraySame(value, prevValue, arrDim)) - || (!isValueArray && value === prevValue))) { - isAllValueEqual = false; - } - prevValue = value; - - // Try converting a string to a color array - if (typeof value == 'string') { - var colorArray = color.parse(value); - if (colorArray) { - value = colorArray; - isValueColor = true; - } - else { - isValueString = true; - } - } - kfValues.push(value); - } - if (isAllValueEqual) { - return; - } - - if (isValueArray) { - var lastValue = kfValues[trackLen - 1]; - // Polyfill array - for (var i = 0; i < trackLen - 1; i++) { - fillArr(kfValues[i], lastValue, arrDim); - } - fillArr(getter(animator._target, propName), lastValue, arrDim); - } - - // Cache the key of last frame to speed up when - // animation playback is sequency - var lastFrame = 0; - var lastFramePercent = 0; - var start; - var w; - var p0; - var p1; - var p2; - var p3; - - if (isValueColor) { - var rgba = [0, 0, 0, 0]; - } - - var onframe = function (target, percent) { - // Find the range keyframes - // kf1-----kf2---------current--------kf3 - // find kf2 and kf3 and do interpolation - var frame; - if (percent < lastFramePercent) { - // Start from next key - start = Math.min(lastFrame + 1, trackLen - 1); - for (frame = start; frame >= 0; frame--) { - if (kfPercents[frame] <= percent) { - break; - } - } - frame = Math.min(frame, trackLen - 2); - } - else { - for (frame = lastFrame; frame < trackLen; frame++) { - if (kfPercents[frame] > percent) { - break; - } - } - frame = Math.min(frame - 1, trackLen - 2); - } - lastFrame = frame; - lastFramePercent = percent; - - var range = (kfPercents[frame + 1] - kfPercents[frame]); - if (range === 0) { - return; - } - else { - w = (percent - kfPercents[frame]) / range; - } - if (useSpline) { - p1 = kfValues[frame]; - p0 = kfValues[frame === 0 ? frame : frame - 1]; - p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1]; - p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2]; - if (isValueArray) { - catmullRomInterpolateArray( - p0, p1, p2, p3, w, w * w, w * w * w, - getter(target, propName), - arrDim - ); - } - else { - var value; - if (isValueColor) { - value = catmullRomInterpolateArray( - p0, p1, p2, p3, w, w * w, w * w * w, - rgba, 1 - ); - value = rgba2String(rgba); - } - else if (isValueString) { - // String is step(0.5) - return interpolateString(p1, p2, w); - } - else { - value = catmullRomInterpolate( - p0, p1, p2, p3, w, w * w, w * w * w - ); - } - setter( - target, - propName, - value - ); - } - } - else { - if (isValueArray) { - interpolateArray( - kfValues[frame], kfValues[frame + 1], w, - getter(target, propName), - arrDim - ); - } - else { - var value; - if (isValueColor) { - interpolateArray( - kfValues[frame], kfValues[frame + 1], w, - rgba, 1 - ); - value = rgba2String(rgba); - } - else if (isValueString) { - // String is step(0.5) - return interpolateString(kfValues[frame], kfValues[frame + 1], w); - } - else { - value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w); - } - setter( - target, - propName, - value - ); - } - } - }; - - var clip = new Clip({ - target: animator._target, - life: trackMaxTime, - loop: animator._loop, - delay: animator._delay, - onframe: onframe, - ondestroy: oneTrackDone - }); - - if (easing && easing !== 'spline') { - clip.easing = easing; - } - - return clip; - } - - /** - * @alias module:zrender/animation/Animator - * @constructor - * @param {Object} target - * @param {boolean} loop - * @param {Function} getter - * @param {Function} setter - */ - var Animator = function(target, loop, getter, setter) { - this._tracks = {}; - this._target = target; - - this._loop = loop || false; - - this._getter = getter || defaultGetter; - this._setter = setter || defaultSetter; - - this._clipCount = 0; - - this._delay = 0; - - this._doneList = []; - - this._onframeList = []; - - this._clipList = []; - }; - - Animator.prototype = { - /** - * 设置动画关键帧 - * @param {number} time 关键帧时间,单位是ms - * @param {Object} props 关键帧的属性值,key-value表示 - * @return {module:zrender/animation/Animator} - */ - when: function(time /* ms */, props) { - var tracks = this._tracks; - for (var propName in props) { - if (!tracks[propName]) { - tracks[propName] = []; - // Invalid value - var value = this._getter(this._target, propName); - if (value == null) { - // zrLog('Invalid property ' + propName); - continue; - } - // If time is 0 - // Then props is given initialize value - // Else - // Initialize value from current prop value - if (time !== 0) { - tracks[propName].push({ - time: 0, - value: cloneValue(value) - }); - } - } - tracks[propName].push({ - time: time, - value: props[propName] - }); - } - return this; - }, - /** - * 添加动画每一帧的回调函数 - * @param {Function} callback - * @return {module:zrender/animation/Animator} - */ - during: function (callback) { - this._onframeList.push(callback); - return this; - }, - - _doneCallback: function () { - // Clear all tracks - this._tracks = {}; - // Clear all clips - this._clipList.length = 0; - - var doneList = this._doneList; - var len = doneList.length; - for (var i = 0; i < len; i++) { - doneList[i].call(this); - } - }, - /** - * 开始执行动画 - * @param {string|Function} easing - * 动画缓动函数,详见{@link module:zrender/animation/easing} - * @return {module:zrender/animation/Animator} - */ - start: function (easing) { - - var self = this; - var clipCount = 0; - - var oneTrackDone = function() { - clipCount--; - if (!clipCount) { - self._doneCallback(); - } - }; - - var lastClip; - for (var propName in this._tracks) { - var clip = createTrackClip( - this, easing, oneTrackDone, - this._tracks[propName], propName - ); - if (clip) { - this._clipList.push(clip); - clipCount++; - - // If start after added to animation - if (this.animation) { - this.animation.addClip(clip); - } - - lastClip = clip; - } - } - - // Add during callback on the last clip - if (lastClip) { - var oldOnFrame = lastClip.onframe; - lastClip.onframe = function (target, percent) { - oldOnFrame(target, percent); - - for (var i = 0; i < self._onframeList.length; i++) { - self._onframeList[i](target, percent); - } - }; - } - - if (!clipCount) { - this._doneCallback(); - } - return this; - }, - /** - * 停止动画 - * @param {boolean} forwardToLast If move to last frame before stop - */ - stop: function (forwardToLast) { - var clipList = this._clipList; - var animation = this.animation; - for (var i = 0; i < clipList.length; i++) { - var clip = clipList[i]; - if (forwardToLast) { - // Move to last frame before stop - clip.onframe(this._target, 1); - } - animation && animation.removeClip(clip); - } - clipList.length = 0; - }, - /** - * 设置动画延迟开始的时间 - * @param {number} time 单位ms - * @return {module:zrender/animation/Animator} - */ - delay: function (time) { - this._delay = time; - return this; - }, - /** - * 添加动画结束的回调 - * @param {Function} cb - * @return {module:zrender/animation/Animator} - */ - done: function(cb) { - if (cb) { - this._doneList.push(cb); - } - return this; - }, - - /** - * @return {Array.} - */ - getClips: function () { - return this._clipList; - } - }; - - return Animator; -}); -define('zrender/config',[],function () { - var dpr = 1; - // If in browser environment - if (typeof window !== 'undefined') { - dpr = Math.max(window.devicePixelRatio || 1, 1); - } - /** - * config默认配置项 - * @exports zrender/config - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - */ - var config = { - /** - * debug日志选项:catchBrushException为true下有效 - * 0 : 不生成debug数据,发布用 - * 1 : 异常抛出,调试用 - * 2 : 控制台输出,调试用 - */ - debugMode: 0, - - // retina 屏幕优化 - devicePixelRatio: dpr - }; - return config; -}); + startAngle: 0, + endAngle: Math.PI * 2, -define( - 'zrender/core/log',['require','../config'],function (require) { - var config = require('../config'); - - /** - * @exports zrender/tool/log - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - */ - return function() { - if (config.debugMode === 0) { - return; - } - else if (config.debugMode == 1) { - for (var k in arguments) { - throw new Error(arguments[k]); - } - } - else if (config.debugMode > 1) { - for (var k in arguments) { - console.log(arguments[k]); - } - } - }; - - /* for debug - return function(mes) { - document.getElementById('wrong-message').innerHTML = - mes + ' ' + (new Date() - 0) - + '
' - + document.getElementById('wrong-message').innerHTML; - }; - */ - } -); - -/** - * @module zrender/mixin/Animatable - */ -define('zrender/mixin/Animatable',['require','../animation/Animator','../core/util','../core/log'],function(require) { - - - - var Animator = require('../animation/Animator'); - var util = require('../core/util'); - var isString = util.isString; - var isFunction = util.isFunction; - var isObject = util.isObject; - var log = require('../core/log'); - - /** - * @alias modue:zrender/mixin/Animatable - * @constructor - */ - var Animatable = function () { - - /** - * @type {Array.} - * @readOnly - */ - this.animators = []; - }; - - Animatable.prototype = { - - constructor: Animatable, - - /** - * 动画 - * - * @param {string} path 需要添加动画的属性获取路径,可以通过a.b.c来获取深层的属性 - * @param {boolean} [loop] 动画是否循环 - * @return {module:zrender/animation/Animator} - * @example: - * el.animate('style', false) - * .when(1000, {x: 10} ) - * .done(function(){ // Animation done }) - * .start() - */ - animate: function (path, loop) { - var target; - var animatingShape = false; - var el = this; - var zr = this.__zr; - if (path) { - var pathSplitted = path.split('.'); - var prop = el; - // If animating shape - animatingShape = pathSplitted[0] === 'shape'; - for (var i = 0, l = pathSplitted.length; i < l; i++) { - if (!prop) { - continue; - } - prop = prop[pathSplitted[i]]; - } - if (prop) { - target = prop; - } - } - else { - target = el; - } - - if (!target) { - log( - 'Property "' - + path - + '" is not existed in element ' - + el.id - ); - return; - } - - var animators = el.animators; - - var animator = new Animator(target, loop); - - animator.during(function (target) { - el.dirty(animatingShape); - }) - .done(function () { - // FIXME Animator will not be removed if use `Animator#stop` to stop animation - animators.splice(util.indexOf(animators, animator), 1); - }); - - animators.push(animator); - - // If animate after added to the zrender - if (zr) { - zr.animation.addAnimator(animator); - } - - return animator; - }, - - /** - * 停止动画 - * @param {boolean} forwardToLast If move to last frame before stop - */ - stopAnimation: function (forwardToLast) { - var animators = this.animators; - var len = animators.length; - for (var i = 0; i < len; i++) { - animators[i].stop(forwardToLast); - } - animators.length = 0; - - return this; - }, - - /** - * @param {Object} target - * @param {number} [time=500] Time in ms - * @param {string} [easing='linear'] - * @param {number} [delay=0] - * @param {Function} [callback] - * - * @example - * // Animate position - * el.animateTo({ - * position: [10, 10] - * }, function () { // done }) - * - * // Animate shape, style and position in 100ms, delayed 100ms, with cubicOut easing - * el.animateTo({ - * shape: { - * width: 500 - * }, - * style: { - * fill: 'red' - * } - * position: [10, 10] - * }, 100, 100, 'cubicOut', function () { // done }) - */ - // TODO Return animation key - animateTo: function (target, time, delay, easing, callback) { - // animateTo(target, time, easing, callback); - if (isString(delay)) { - callback = easing; - easing = delay; - delay = 0; - } - // animateTo(target, time, delay, callback); - else if (isFunction(easing)) { - callback = easing; - easing = 'linear'; - delay = 0; - } - // animateTo(target, time, callback); - else if (isFunction(delay)) { - callback = delay; - delay = 0; - } - // animateTo(target, callback) - else if (isFunction(time)) { - callback = time; - time = 500; - } - // animateTo(target) - else if (!time) { - time = 500; - } - // Stop all previous animations - this.stopAnimation(); - this._animateToShallow('', this, target, time, delay, easing, callback); - - // Animators may be removed immediately after start - // if there is nothing to animate - var animators = this.animators.slice(); - var count = animators.length; - function done() { - count--; - if (!count) { - callback && callback(); - } - } - - // No animators. This should be checked before animators[i].start(), - // because 'done' may be executed immediately if no need to animate. - if (!count) { - callback && callback(); - } - // Start after all animators created - // Incase any animator is done immediately when all animation properties are not changed - for (var i = 0; i < animators.length; i++) { - animators[i] - .done(done) - .start(easing); - } - }, - - /** - * @private - * @param {string} path='' - * @param {Object} source=this - * @param {Object} target - * @param {number} [time=500] - * @param {number} [delay=0] - * - * @example - * // Animate position - * el._animateToShallow({ - * position: [10, 10] - * }) - * - * // Animate shape, style and position in 100ms, delayed 100ms - * el._animateToShallow({ - * shape: { - * width: 500 - * }, - * style: { - * fill: 'red' - * } - * position: [10, 10] - * }, 100, 100) - */ - _animateToShallow: function (path, source, target, time, delay) { - var objShallow = {}; - var propertyCount = 0; - for (var name in target) { - if (source[name] != null) { - if (isObject(target[name]) && !util.isArrayLike(target[name])) { - this._animateToShallow( - path ? path + '.' + name : name, - source[name], - target[name], - time, - delay - ); - } - else { - objShallow[name] = target[name]; - propertyCount++; - } - } - else if (target[name] != null) { - // Attr directly if not has property - // FIXME, if some property not needed for element ? - if (!path) { - this.attr(name, target[name]); - } - else { // Shape or style - var props = {}; - props[path] = {}; - props[path][name] = target[name]; - this.attr(props); - } - } - } - - if (propertyCount > 0) { - this.animate(path, false) - .when(time == null ? 500 : time, objShallow) - .delay(delay || 0); - } - - return this; - } - }; - - return Animatable; -}); -/** - * @module zrender/Element - */ -define('zrender/Element',['require','./core/guid','./mixin/Eventful','./mixin/Transformable','./mixin/Animatable','./core/util'],function(require) { - - - var guid = require('./core/guid'); - var Eventful = require('./mixin/Eventful'); - var Transformable = require('./mixin/Transformable'); - var Animatable = require('./mixin/Animatable'); - var zrUtil = require('./core/util'); - - /** - * @alias module:zrender/Element - * @constructor - * @extends {module:zrender/mixin/Animatable} - * @extends {module:zrender/mixin/Transformable} - * @extends {module:zrender/mixin/Eventful} - */ - var Element = function (opts) { - - Transformable.call(this, opts); - Eventful.call(this, opts); - Animatable.call(this, opts); - - /** - * 画布元素ID - * @type {string} - */ - this.id = opts.id || guid(); - }; - - Element.prototype = { - - /** - * 元素类型 - * Element type - * @type {string} - */ - type: 'element', - - /** - * 元素名字 - * Element name - * @type {string} - */ - name: '', - - /** - * ZRender 实例对象,会在 element 添加到 zrender 实例中后自动赋值 - * ZRender instance will be assigned when element is associated with zrender - * @name module:/zrender/Element#__zr - * @type {module:zrender/ZRender} - */ - __zr: null, - - /** - * 图形是否忽略,为true时忽略图形的绘制以及事件触发 - * If ignore drawing and events of the element object - * @name module:/zrender/Element#ignore - * @type {boolean} - * @default false - */ - ignore: false, - - /** - * 用于裁剪的路径(shape),所有 Group 内的路径在绘制时都会被这个路径裁剪 - * 该路径会继承被裁减对象的变换 - * @type {module:zrender/graphic/Path} - * @see http://www.w3.org/TR/2dcontext/#clipping-region - * @readOnly - */ - clipPath: null, - - /** - * Drift element - * @param {number} dx dx on the global space - * @param {number} dy dy on the global space - */ - drift: function (dx, dy) { - switch (this.draggable) { - case 'horizontal': - dy = 0; - break; - case 'vertical': - dx = 0; - break; - } - - var m = this.transform; - if (!m) { - m = this.transform = [1, 0, 0, 1, 0, 0]; - } - m[4] += dx; - m[5] += dy; - - this.decomposeTransform(); - this.dirty(); - }, - - /** - * Hook before update - */ - beforeUpdate: function () {}, - /** - * Hook after update - */ - afterUpdate: function () {}, - /** - * Update each frame - */ - update: function () { - this.updateTransform(); - }, - - /** - * @param {Function} cb - * @param {} context - */ - traverse: function (cb, context) {}, - - /** - * @protected - */ - attrKV: function (key, value) { - if (key === 'position' || key === 'scale' || key === 'origin') { - // Copy the array - if (value) { - var target = this[key]; - if (!target) { - target = this[key] = []; - } - target[0] = value[0]; - target[1] = value[1]; - } - } - else { - this[key] = value; - } - }, - - /** - * Hide the element - */ - hide: function () { - this.ignore = true; - this.__zr && this.__zr.refresh(); - }, - - /** - * Show the element - */ - show: function () { - this.ignore = false; - this.__zr && this.__zr.refresh(); - }, - - /** - * @param {string|Object} key - * @param {*} value - */ - attr: function (key, value) { - if (typeof key === 'string') { - this.attrKV(key, value); - } - else if (zrUtil.isObject(key)) { - for (var name in key) { - if (key.hasOwnProperty(name)) { - this.attrKV(name, key[name]); - } - } - } - this.dirty(); - - return this; - }, - - /** - * @param {module:zrender/graphic/Path} clipPath - */ - setClipPath: function (clipPath) { - var zr = this.__zr; - if (zr) { - clipPath.addSelfToZr(zr); - } - - // Remove previous clip path - if (this.clipPath && this.clipPath !== clipPath) { - this.removeClipPath(); - } - - this.clipPath = clipPath; - clipPath.__zr = zr; - clipPath.__clipTarget = this; - - this.dirty(); - }, - - /** - */ - removeClipPath: function () { - var clipPath = this.clipPath; - if (clipPath) { - if (clipPath.__zr) { - clipPath.removeSelfFromZr(clipPath.__zr); - } - - clipPath.__zr = null; - clipPath.__clipTarget = null; - this.clipPath = null; - - this.dirty(); - } - }, - - /** - * Add self from zrender instance. - * Not recursively because it will be invoked when element added to storage. - * @param {module:zrender/ZRender} zr - */ - addSelfToZr: function (zr) { - this.__zr = zr; - // 添加动画 - var animators = this.animators; - if (animators) { - for (var i = 0; i < animators.length; i++) { - zr.animation.addAnimator(animators[i]); - } - } - - if (this.clipPath) { - this.clipPath.addSelfToZr(zr); - } - }, - - /** - * Remove self from zrender instance. - * Not recursively because it will be invoked when element added to storage. - * @param {module:zrender/ZRender} zr - */ - removeSelfFromZr: function (zr) { - this.__zr = null; - // 移除动画 - var animators = this.animators; - if (animators) { - for (var i = 0; i < animators.length; i++) { - zr.animation.removeAnimator(animators[i]); - } - } - - if (this.clipPath) { - this.clipPath.removeSelfFromZr(zr); - } - } - }; - - zrUtil.mixin(Element, Animatable); - zrUtil.mixin(Element, Transformable); - zrUtil.mixin(Element, Eventful); - - return Element; -}); -/** - * Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上 - * @module zrender/graphic/Group - * @example - * var Group = require('zrender/container/Group'); - * var Circle = require('zrender/graphic/shape/Circle'); - * var g = new Group(); - * g.position[0] = 100; - * g.position[1] = 100; - * g.add(new Circle({ - * style: { - * x: 100, - * y: 100, - * r: 20, - * } - * })); - * zr.add(g); - */ -define('zrender/container/Group',['require','../core/util','../Element','../core/BoundingRect'],function (require) { - - var zrUtil = require('../core/util'); - var Element = require('../Element'); - var BoundingRect = require('../core/BoundingRect'); - - /** - * @alias module:zrender/graphic/Group - * @constructor - * @extends module:zrender/mixin/Transformable - * @extends module:zrender/mixin/Eventful - */ - var Group = function (opts) { - - opts = opts || {}; - - Element.call(this, opts); - - for (var key in opts) { - this[key] = opts[key]; - } - - this._children = []; - - this.__storage = null; - - this.__dirty = true; - }; - - Group.prototype = { - - constructor: Group, - - /** - * @type {string} - */ - type: 'group', - - /** - * @return {Array.} - */ - children: function () { - return this._children.slice(); - }, - - /** - * 获取指定 index 的儿子节点 - * @param {number} idx - * @return {module:zrender/Element} - */ - childAt: function (idx) { - return this._children[idx]; - }, - - /** - * 获取指定名字的儿子节点 - * @param {string} name - * @return {module:zrender/Element} - */ - childOfName: function (name) { - var children = this._children; - for (var i = 0; i < children.length; i++) { - if (children[i].name === name) { - return children[i]; - } - } - }, - - /** - * @return {number} - */ - childCount: function () { - return this._children.length; - }, - - /** - * 添加子节点到最后 - * @param {module:zrender/Element} child - */ - add: function (child) { - if (child && child !== this && child.parent !== this) { - - this._children.push(child); - - this._doAdd(child); - } - - return this; - }, - - /** - * 添加子节点在 nextSibling 之前 - * @param {module:zrender/Element} child - * @param {module:zrender/Element} nextSibling - */ - addBefore: function (child, nextSibling) { - if (child && child !== this && child.parent !== this - && nextSibling && nextSibling.parent === this) { - - var children = this._children; - var idx = children.indexOf(nextSibling); - - if (idx >= 0) { - children.splice(idx, 0, child); - this._doAdd(child); - } - } - - return this; - }, - - _doAdd: function (child) { - if (child.parent) { - child.parent.remove(child); - } - - child.parent = this; - - var storage = this.__storage; - var zr = this.__zr; - if (storage && storage !== child.__storage) { - - storage.addToMap(child); - - if (child instanceof Group) { - child.addChildrenToStorage(storage); - } - } - - zr && zr.refresh(); - }, - - /** - * 移除子节点 - * @param {module:zrender/Element} child - */ - remove: function (child) { - var zr = this.__zr; - var storage = this.__storage; - var children = this._children; - - var idx = zrUtil.indexOf(children, child); - if (idx < 0) { - return this; - } - children.splice(idx, 1); - - child.parent = null; - - if (storage) { - - storage.delFromMap(child.id); - - if (child instanceof Group) { - child.delChildrenFromStorage(storage); - } - } - - zr && zr.refresh(); - - return this; - }, - - /** - * 移除所有子节点 - */ - removeAll: function () { - var children = this._children; - var storage = this.__storage; - var child; - var i; - for (i = 0; i < children.length; i++) { - child = children[i]; - if (storage) { - storage.delFromMap(child.id); - if (child instanceof Group) { - child.delChildrenFromStorage(storage); - } - } - child.parent = null; - } - children.length = 0; - - return this; - }, - - /** - * 遍历所有子节点 - * @param {Function} cb - * @param {} context - */ - eachChild: function (cb, context) { - var children = this._children; - for (var i = 0; i < children.length; i++) { - var child = children[i]; - cb.call(context, child, i); - } - return this; - }, - - /** - * 深度优先遍历所有子孙节点 - * @param {Function} cb - * @param {} context - */ - traverse: function (cb, context) { - for (var i = 0; i < this._children.length; i++) { - var child = this._children[i]; - cb.call(context, child); - - if (child.type === 'group') { - child.traverse(cb, context); - } - } - return this; - }, - - addChildrenToStorage: function (storage) { - for (var i = 0; i < this._children.length; i++) { - var child = this._children[i]; - storage.addToMap(child); - if (child instanceof Group) { - child.addChildrenToStorage(storage); - } - } - }, - - delChildrenFromStorage: function (storage) { - for (var i = 0; i < this._children.length; i++) { - var child = this._children[i]; - storage.delFromMap(child.id); - if (child instanceof Group) { - child.delChildrenFromStorage(storage); - } - } - }, - - dirty: function () { - this.__dirty = true; - this.__zr && this.__zr.refresh(); - return this; - }, - - /** - * @return {module:zrender/core/BoundingRect} - */ - getBoundingRect: function (includeChildren) { - // TODO Caching - // TODO Transform - var rect = null; - var tmpRect = new BoundingRect(0, 0, 0, 0); - var children = includeChildren || this._children; - var tmpMat = []; - - for (var i = 0; i < children.length; i++) { - var child = children[i]; - if (child.ignore || child.invisible) { - continue; - } - - var childRect = child.getBoundingRect(); - var transform = child.getLocalTransform(tmpMat); - if (transform) { - tmpRect.copy(childRect); - tmpRect.applyTransform(transform); - rect = rect || tmpRect.clone(); - rect.union(tmpRect); - } - else { - rect = rect || childRect.clone(); - rect.union(childRect); - } - } - return rect || tmpRect; - } - }; - - zrUtil.inherits(Group, Element); - - return Group; -}); -define('echarts/view/Component',['require','zrender/container/Group','../util/component','../util/clazz'],function (require) { + clockwise: true + }, - var Group = require('zrender/container/Group'); - var componentUtil = require('../util/component'); - var clazzUtil = require('../util/clazz'); + buildPath: function (ctx, shape) { - var Component = function () { - /** - * @type {module:zrender/container/Group} - * @readOnly - */ - this.group = new Group(); + var x = shape.cx; + var y = shape.cy; + var r0 = Math.max(shape.r0 || 0, 0); + var r = Math.max(shape.r, 0); + var startAngle = shape.startAngle; + var endAngle = shape.endAngle; + var clockwise = shape.clockwise; - /** - * @type {string} - * @readOnly - */ - this.uid = componentUtil.getUID('viewComponent'); - }; + var unitX = Math.cos(startAngle); + var unitY = Math.sin(startAngle); - Component.prototype = { + ctx.moveTo(unitX * r0 + x, unitY * r0 + y); - constructor: Component, + ctx.lineTo(unitX * r + x, unitY * r + y); - init: function (ecModel, api) {}, + ctx.arc(x, y, r, startAngle, endAngle, !clockwise); - render: function (componentModel, ecModel, api, payload) {}, + ctx.lineTo( + Math.cos(endAngle) * r0 + x, + Math.sin(endAngle) * r0 + y + ); - dispose: function () {} - }; + if (r0 !== 0) { + ctx.arc(x, y, r0, endAngle, startAngle, clockwise); + } - var componentProto = Component.prototype; - componentProto.updateView - = componentProto.updateLayout - = componentProto.updateVisual - = function (seriesModel, ecModel, api, payload) { - // Do nothing; - }; - // Enable Component.extend. - clazzUtil.enableClassExtend(Component); + ctx.closePath(); + } + }); - // Enable capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. - clazzUtil.enableClassManagement(Component, {registerWhenExtend: true}); - return Component; -}); -define('echarts/view/Chart',['require','zrender/container/Group','../util/component','../util/clazz'],function (require) { - - var Group = require('zrender/container/Group'); - var componentUtil = require('../util/component'); - var clazzUtil = require('../util/clazz'); - - function Chart() { - - /** - * @type {module:zrender/container/Group} - * @readOnly - */ - this.group = new Group(); - - /** - * @type {string} - * @readOnly - */ - this.uid = componentUtil.getUID('viewChart'); - } - - Chart.prototype = { - - type: 'chart', - - /** - * Init the chart - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - */ - init: function (ecModel, api) {}, - - /** - * Render the chart - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - * @param {Object} payload - */ - render: function (seriesModel, ecModel, api, payload) {}, - - /** - * Highlight series or specified data item - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - * @param {Object} payload - */ - highlight: function (seriesModel, ecModel, api, payload) { - toggleHighlight(seriesModel.getData(), payload, 'emphasis'); - }, - - /** - * Downplay series or specified data item - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - * @param {Object} payload - */ - downplay: function (seriesModel, ecModel, api, payload) { - toggleHighlight(seriesModel.getData(), payload, 'normal'); - }, - - /** - * Remove self - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - */ - remove: function (ecModel, api) { - this.group.removeAll(); - }, - - /** - * Dispose self - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - */ - dispose: function () {} - }; - - var chartProto = Chart.prototype; - chartProto.updateView - = chartProto.updateLayout - = chartProto.updateVisual - = function (seriesModel, ecModel, api, payload) { - this.render(seriesModel, ecModel, api, payload); - }; - - /** - * Set state of single element - * @param {module:zrender/Element} el - * @param {string} state - */ - function elSetState(el, state) { - if (el) { - el.trigger(state); - if (el.type === 'group') { - for (var i = 0; i < el.childCount(); i++) { - elSetState(el.childAt(i), state); - } - } - } - } - /** - * @param {module:echarts/data/List} data - * @param {Object} payload - * @param {string} state 'normal'|'emphasis' - * @inner - */ - function toggleHighlight(data, payload, state) { - if (payload.dataIndex != null) { - var el = data.getItemGraphicEl(payload.dataIndex); - elSetState(el, state); - } - else if (payload.name) { - var dataIndex = data.indexOfName(payload.name); - var el = data.getItemGraphicEl(dataIndex); - elSetState(el, state); - } - else { - data.eachItemGraphicEl(function (el) { - elSetState(el, state); - }); - } - } - - // Enable Chart.extend. - clazzUtil.enableClassExtend(Chart); - - // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. - clazzUtil.enableClassManagement(Chart, {registerWhenExtend: true}); - - return Chart; -}); -/** - * @module zrender/graphic/Style - */ - -define('zrender/graphic/Style',['require'],function (require) { - - var STYLE_LIST_COMMON = [ - 'lineCap', 'lineJoin', 'miterLimit', - 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'shadowColor' - ]; - - var Style = function (opts) { - this.extendFrom(opts); - }; - - Style.prototype = { - - constructor: Style, - - /** - * @type {string} - */ - fill: '#000000', - - /** - * @type {string} - */ - stroke: null, - - /** - * @type {number} - */ - opacity: 1, - - /** - * @type {Array.} - */ - lineDash: null, - - /** - * @type {number} - */ - lineDashOffset: 0, - - /** - * @type {number} - */ - shadowBlur: 0, - - /** - * @type {number} - */ - shadowOffsetX: 0, - - /** - * @type {number} - */ - shadowOffsetY: 0, - - /** - * @type {number} - */ - lineWidth: 1, - - /** - * If stroke ignore scale - * @type {Boolean} - */ - strokeNoScale: false, - - // Bounding rect text configuration - // Not affected by element transform - /** - * @type {string} - */ - text: null, - - /** - * @type {string} - */ - textFill: '#000', - - /** - * @type {string} - */ - textStroke: null, - - /** - * 'inside', 'left', 'right', 'top', 'bottom' - * [x, y] - * @type {string|Array.} - * @default 'inside' - */ - textPosition: 'inside', - - /** - * @type {string} - */ - textBaseline: null, - - /** - * @type {string} - */ - textAlign: null, - - /** - * @type {number} - */ - textDistance: 5, - - /** - * @type {number} - */ - textShadowBlur: 0, - - /** - * @type {number} - */ - textShadowOffsetX: 0, - - /** - * @type {number} - */ - textShadowOffsetY: 0, - - /** - * @param {CanvasRenderingContext2D} ctx - */ - bind: function (ctx, el) { - var fill = this.fill; - var stroke = this.stroke; - for (var i = 0; i < STYLE_LIST_COMMON.length; i++) { - var styleName = STYLE_LIST_COMMON[i]; - - if (this[styleName] != null) { - ctx[styleName] = this[styleName]; - } - } - if (stroke != null) { - var lineWidth = this.lineWidth; - ctx.lineWidth = lineWidth / ( - (this.strokeNoScale && el && el.getLineScale) ? el.getLineScale() : 1 - ); - } - if (fill != null) { - // Use canvas gradient if has - ctx.fillStyle = fill.canvasGradient ? fill.canvasGradient : fill; - } - if (stroke != null) { - // Use canvas gradient if has - ctx.strokeStyle = stroke.canvasGradient ? stroke.canvasGradient : stroke; - } - this.opacity != null && (ctx.globalAlpha = this.opacity); - }, - - /** - * Extend from other style - * @param {zrender/graphic/Style} otherStyle - * @param {boolean} overwrite - */ - extendFrom: function (otherStyle, overwrite) { - if (otherStyle) { - var target = this; - for (var name in otherStyle) { - if (otherStyle.hasOwnProperty(name) - && (overwrite || ! target.hasOwnProperty(name)) - ) { - target[name] = otherStyle[name]; - } - } - } - }, - - /** - * Batch setting style with a given object - * @param {Object|string} obj - * @param {*} [obj] - */ - set: function (obj, value) { - if (typeof obj === 'string') { - this[obj] = value; - } - else { - this.extendFrom(obj, true); - } - }, - - /** - * Clone - * @return {zrender/graphic/Style} [description] - */ - clone: function () { - var newStyle = new this.constructor(); - newStyle.extendFrom(this, true); - return newStyle; - } - }; - - var styleProto = Style.prototype; - var name; - var i; - for (i = 0; i < STYLE_LIST_COMMON.length; i++) { - name = STYLE_LIST_COMMON[i]; - if (!(name in styleProto)) { - styleProto[name] = null; - } - } - - return Style; -}); -/** - * Mixin for drawing text in a element bounding rect - * @module zrender/mixin/RectText - */ - -define('zrender/graphic/mixin/RectText',['require','../../contain/text','../../core/BoundingRect'],function (require) { - - var textContain = require('../../contain/text'); - var BoundingRect = require('../../core/BoundingRect'); - - var tmpRect = new BoundingRect(); - - var RectText = function () {}; - - function parsePercent(value, maxValue) { - if (typeof value === 'string') { - if (value.lastIndexOf('%') >= 0) { - return parseFloat(value) / 100 * maxValue; - } - return parseFloat(value); - } - return value; - } - - function setTransform(ctx, m) { - ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); - } - - RectText.prototype = { - - constructor: RectText, - - /** - * Draw text in a rect with specified position. - * @param {CanvasRenderingContext} ctx - * @param {Object} rect Displayable rect - * @return {Object} textRect Alternative precalculated text bounding rect - */ - drawRectText: function (ctx, rect, textRect) { - var style = this.style; - var text = style.text; - // Convert to string - text != null && (text += ''); - if (!text) { - return; - } - var x; - var y; - var textPosition = style.textPosition; - var distance = style.textDistance; - var align = style.textAlign; - var font = style.textFont || style.font; - var baseline = style.textBaseline; - - textRect = textRect || textContain.getBoundingRect(text, font, align, baseline); - - // Transform rect to view space - var transform = this.transform; - var invTransform = this.invTransform; - if (transform) { - tmpRect.copy(rect); - tmpRect.applyTransform(transform); - rect = tmpRect; - // Transform back - setTransform(ctx, invTransform); - } - - // Text position represented by coord - if (textPosition instanceof Array) { - // Percent - x = rect.x + parsePercent(textPosition[0], rect.width); - y = rect.y + parsePercent(textPosition[1], rect.height); - align = align || 'left'; - baseline = baseline || 'top'; - } - else { - var res = textContain.adjustTextPositionOnRect( - textPosition, rect, textRect, distance - ); - x = res.x; - y = res.y; - // Default align and baseline when has textPosition - align = align || res.textAlign; - baseline = baseline || res.textBaseline; - } - - ctx.textAlign = align; - ctx.textBaseline = baseline; - - var textFill = style.textFill; - var textStroke = style.textStroke; - textFill && (ctx.fillStyle = textFill); - textStroke && (ctx.strokeStyle = textStroke); - ctx.font = font; - - // Text shadow - ctx.shadowColor = style.textShadowColor; - ctx.shadowBlur = style.textShadowBlur; - ctx.shadowOffsetX = style.textShadowOffsetX; - ctx.shadowOffsetY = style.textShadowOffsetY; - - var textLines = text.split('\n'); - for (var i = 0; i < textLines.length; i++) { - textFill && ctx.fillText(textLines[i], x, y); - textStroke && ctx.strokeText(textLines[i], x, y); - y += textRect.lineHeight; - } - - // Transform again - transform && setTransform(ctx, transform); - } - }; - - return RectText; -}); -/** - * 可绘制的图形基类 - * Base class of all displayable graphic objects - * @module zrender/graphic/Displayable - */ - -define('zrender/graphic/Displayable',['require','../core/util','./Style','../Element','./mixin/RectText'],function (require) { - - var zrUtil = require('../core/util'); - - var Style = require('./Style'); - - var Element = require('../Element'); - var RectText = require('./mixin/RectText'); - // var Stateful = require('./mixin/Stateful'); - - /** - * @alias module:zrender/graphic/Displayable - * @extends module:zrender/Element - * @extends module:zrender/graphic/mixin/RectText - */ - function Displayable(opts) { - - opts = opts || {}; - - Element.call(this, opts); - - // Extend properties - for (var name in opts) { - if ( - opts.hasOwnProperty(name) && - name !== 'style' - ) { - this[name] = opts[name]; - } - } - - /** - * @type {module:zrender/graphic/Style} - */ - this.style = new Style(opts.style); - - this._rect = null; - // Shapes for cascade clipping. - this.__clipPaths = []; - - // FIXME Stateful must be mixined after style is setted - // Stateful.call(this, opts); - } - - Displayable.prototype = { - - constructor: Displayable, - - type: 'displayable', - - /** - * Displayable 是否为脏,Painter 中会根据该标记判断是否需要是否需要重新绘制 - * Dirty flag. From which painter will determine if this displayable object needs brush - * @name module:zrender/graphic/Displayable#__dirty - * @type {boolean} - */ - __dirty: true, - - /** - * 图形是否可见,为true时不绘制图形,但是仍能触发鼠标事件 - * If ignore drawing of the displayable object. Mouse event will still be triggered - * @name module:/zrender/graphic/Displayable#invisible - * @type {boolean} - * @default false - */ - invisible: false, - - /** - * @name module:/zrender/graphic/Displayable#z - * @type {number} - * @default 0 - */ - z: 0, - - /** - * @name module:/zrender/graphic/Displayable#z - * @type {number} - * @default 0 - */ - z2: 0, - - /** - * z层level,决定绘画在哪层canvas中 - * @name module:/zrender/graphic/Displayable#zlevel - * @type {number} - * @default 0 - */ - zlevel: 0, - - /** - * 是否可拖拽 - * @name module:/zrender/graphic/Displayable#draggable - * @type {boolean} - * @default false - */ - draggable: false, - - /** - * 是否正在拖拽 - * @name module:/zrender/graphic/Displayable#draggable - * @type {boolean} - * @default false - */ - dragging: false, - - /** - * 是否相应鼠标事件 - * @name module:/zrender/graphic/Displayable#silent - * @type {boolean} - * @default false - */ - silent: false, - - /** - * If enable culling - * @type {boolean} - * @default false - */ - culling: false, - - /** - * Mouse cursor when hovered - * @name module:/zrender/graphic/Displayable#cursor - * @type {string} - */ - cursor: 'pointer', - - /** - * If hover area is bounding rect - * @name module:/zrender/graphic/Displayable#rectHover - * @type {string} - */ - rectHover: false, - - beforeBrush: function (ctx) {}, - - afterBrush: function (ctx) {}, - - /** - * 图形绘制方法 - * @param {Canvas2DRenderingContext} ctx - */ - // Interface - brush: function (ctx) {}, - - /** - * 获取最小包围盒 - * @return {module:zrender/core/BoundingRect} - */ - // Interface - getBoundingRect: function () {}, - - /** - * 判断坐标 x, y 是否在图形上 - * If displayable element contain coord x, y - * @param {number} x - * @param {number} y - * @return {boolean} - */ - contain: function (x, y) { - return this.rectContain(x, y); - }, - - /** - * @param {Function} cb - * @param {} context - */ - traverse: function (cb, context) { - cb.call(context, this); - }, - - /** - * 判断坐标 x, y 是否在图形的包围盒上 - * If bounding rect of element contain coord x, y - * @param {number} x - * @param {number} y - * @return {boolean} - */ - rectContain: function (x, y) { - var coord = this.transformCoordToLocal(x, y); - var rect = this.getBoundingRect(); - return rect.contain(coord[0], coord[1]); - }, - - /** - * 标记图形元素为脏,并且在下一帧重绘 - * Mark displayable element dirty and refresh next frame - */ - dirty: function () { - this.__dirty = true; - - this._rect = null; - - this.__zr && this.__zr.refresh(); - }, - - /** - * 图形是否会触发事件 - * If displayable object binded any event - * @return {boolean} - */ - // TODO, 通过 bind 绑定的事件 - // isSilent: function () { - // return !( - // this.hoverable || this.draggable - // || this.onmousemove || this.onmouseover || this.onmouseout - // || this.onmousedown || this.onmouseup || this.onclick - // || this.ondragenter || this.ondragover || this.ondragleave - // || this.ondrop - // ); - // }, - /** - * Alias for animate('style') - * @param {boolean} loop - */ - animateStyle: function (loop) { - return this.animate('style', loop); - }, - - attrKV: function (key, value) { - if (key !== 'style') { - Element.prototype.attrKV.call(this, key, value); - } - else { - this.style.set(value); - } - }, - - /** - * @param {Object|string} key - * @param {*} value - */ - setStyle: function (key, value) { - this.style.set(key, value); - this.dirty(); - return this; - } - }; - - zrUtil.inherits(Displayable, Element); - - zrUtil.mixin(Displayable, RectText); - // zrUtil.mixin(Displayable, Stateful); - - return Displayable; -}); -/** - * 曲线辅助模块 - * @module zrender/core/curve - * @author pissang(https://www.github.com/pissang) - */ -define('zrender/core/curve',['require','./vector'],function(require) { - - - - var vec2 = require('./vector'); - var v2Create = vec2.create; - var v2DistSquare = vec2.distSquare; - var mathPow = Math.pow; - var mathSqrt = Math.sqrt; - - var EPSILON = 1e-4; - - var THREE_SQRT = mathSqrt(3); - var ONE_THIRD = 1 / 3; - - // 临时变量 - var _v0 = v2Create(); - var _v1 = v2Create(); - var _v2 = v2Create(); - // var _v3 = vec2.create(); - - function isAroundZero(val) { - return val > -EPSILON && val < EPSILON; - } - function isNotAroundZero(val) { - return val > EPSILON || val < -EPSILON; - } - /** - * 计算三次贝塞尔值 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} t - * @return {number} - */ - function cubicAt(p0, p1, p2, p3, t) { - var onet = 1 - t; - return onet * onet * (onet * p0 + 3 * t * p1) - + t * t * (t * p3 + 3 * onet * p2); - } - - /** - * 计算三次贝塞尔导数值 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} t - * @return {number} - */ - function cubicDerivativeAt(p0, p1, p2, p3, t) { - var onet = 1 - t; - return 3 * ( - ((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet - + (p3 - p2) * t * t - ); - } - - /** - * 计算三次贝塞尔方程根,使用盛金公式 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} val - * @param {Array.} roots - * @return {number} 有效根数目 - */ - function cubicRootAt(p0, p1, p2, p3, val, roots) { - // Evaluate roots of cubic functions - var a = p3 + 3 * (p1 - p2) - p0; - var b = 3 * (p2 - p1 * 2 + p0); - var c = 3 * (p1 - p0); - var d = p0 - val; - - var A = b * b - 3 * a * c; - var B = b * c - 9 * a * d; - var C = c * c - 3 * b * d; - - var n = 0; - - if (isAroundZero(A) && isAroundZero(B)) { - if (isAroundZero(b)) { - roots[0] = 0; - } - else { - var t1 = -c / b; //t1, t2, t3, b is not zero - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - } - } - else { - var disc = B * B - 4 * A * C; - - if (isAroundZero(disc)) { - var K = B / A; - var t1 = -b / a + K; // t1, a is not zero - var t2 = -K / 2; // t2, t3 - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - if (t2 >= 0 && t2 <= 1) { - roots[n++] = t2; - } - } - else if (disc > 0) { - var discSqrt = mathSqrt(disc); - var Y1 = A * b + 1.5 * a * (-B + discSqrt); - var Y2 = A * b + 1.5 * a * (-B - discSqrt); - if (Y1 < 0) { - Y1 = -mathPow(-Y1, ONE_THIRD); - } - else { - Y1 = mathPow(Y1, ONE_THIRD); - } - if (Y2 < 0) { - Y2 = -mathPow(-Y2, ONE_THIRD); - } - else { - Y2 = mathPow(Y2, ONE_THIRD); - } - var t1 = (-b - (Y1 + Y2)) / (3 * a); - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - } - else { - var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt(A * A * A)); - var theta = Math.acos(T) / 3; - var ASqrt = mathSqrt(A); - var tmp = Math.cos(theta); - - var t1 = (-b - 2 * ASqrt * tmp) / (3 * a); - var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a); - var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a); - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - if (t2 >= 0 && t2 <= 1) { - roots[n++] = t2; - } - if (t3 >= 0 && t3 <= 1) { - roots[n++] = t3; - } - } - } - return n; - } - - /** - * 计算三次贝塞尔方程极限值的位置 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {Array.} extrema - * @return {number} 有效数目 - */ - function cubicExtrema(p0, p1, p2, p3, extrema) { - var b = 6 * p2 - 12 * p1 + 6 * p0; - var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2; - var c = 3 * p1 - 3 * p0; - - var n = 0; - if (isAroundZero(a)) { - if (isNotAroundZero(b)) { - var t1 = -c / b; - if (t1 >= 0 && t1 <=1) { - extrema[n++] = t1; - } - } - } - else { - var disc = b * b - 4 * a * c; - if (isAroundZero(disc)) { - extrema[0] = -b / (2 * a); - } - else if (disc > 0) { - var discSqrt = mathSqrt(disc); - var t1 = (-b + discSqrt) / (2 * a); - var t2 = (-b - discSqrt) / (2 * a); - if (t1 >= 0 && t1 <= 1) { - extrema[n++] = t1; - } - if (t2 >= 0 && t2 <= 1) { - extrema[n++] = t2; - } - } - } - return n; - } - - /** - * 细分三次贝塞尔曲线 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} t - * @param {Array.} out - */ - function cubicSubdivide(p0, p1, p2, p3, t, out) { - var p01 = (p1 - p0) * t + p0; - var p12 = (p2 - p1) * t + p1; - var p23 = (p3 - p2) * t + p2; - - var p012 = (p12 - p01) * t + p01; - var p123 = (p23 - p12) * t + p12; - - var p0123 = (p123 - p012) * t + p012; - // Seg0 - out[0] = p0; - out[1] = p01; - out[2] = p012; - out[3] = p0123; - // Seg1 - out[4] = p0123; - out[5] = p123; - out[6] = p23; - out[7] = p3; - } - - /** - * 投射点到三次贝塞尔曲线上,返回投射距离。 - * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x3 - * @param {number} y3 - * @param {number} x - * @param {number} y - * @param {Array.} [out] 投射点 - * @return {number} - */ - function cubicProjectPoint( - x0, y0, x1, y1, x2, y2, x3, y3, - x, y, out - ) { - // http://pomax.github.io/bezierinfo/#projections - var t; - var interval = 0.005; - var d = Infinity; - var prev; - var next; - var d1; - var d2; - - _v0[0] = x; - _v0[1] = y; - - // 先粗略估计一下可能的最小距离的 t 值 - // PENDING - for (var _t = 0; _t < 1; _t += 0.05) { - _v1[0] = cubicAt(x0, x1, x2, x3, _t); - _v1[1] = cubicAt(y0, y1, y2, y3, _t); - d1 = v2DistSquare(_v0, _v1); - if (d1 < d) { - t = _t; - d = d1; - } - } - d = Infinity; - - // At most 32 iteration - for (var i = 0; i < 32; i++) { - if (interval < EPSILON) { - break; - } - prev = t - interval; - next = t + interval; - // t - interval - _v1[0] = cubicAt(x0, x1, x2, x3, prev); - _v1[1] = cubicAt(y0, y1, y2, y3, prev); - - d1 = v2DistSquare(_v1, _v0); - - if (prev >= 0 && d1 < d) { - t = prev; - d = d1; - } - else { - // t + interval - _v2[0] = cubicAt(x0, x1, x2, x3, next); - _v2[1] = cubicAt(y0, y1, y2, y3, next); - d2 = v2DistSquare(_v2, _v0); - - if (next <= 1 && d2 < d) { - t = next; - d = d2; - } - else { - interval *= 0.5; - } - } - } - // t - if (out) { - out[0] = cubicAt(x0, x1, x2, x3, t); - out[1] = cubicAt(y0, y1, y2, y3, t); - } - // console.log(interval, i); - return mathSqrt(d); - } - - /** - * 计算二次方贝塞尔值 - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} t - * @return {number} - */ - function quadraticAt(p0, p1, p2, t) { - var onet = 1 - t; - return onet * (onet * p0 + 2 * t * p1) + t * t * p2; - } - - /** - * 计算二次方贝塞尔导数值 - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} t - * @return {number} - */ - function quadraticDerivativeAt(p0, p1, p2, t) { - return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1)); - } - - /** - * 计算二次方贝塞尔方程根 - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} t - * @param {Array.} roots - * @return {number} 有效根数目 - */ - function quadraticRootAt(p0, p1, p2, val, roots) { - var a = p0 - 2 * p1 + p2; - var b = 2 * (p1 - p0); - var c = p0 - val; - - var n = 0; - if (isAroundZero(a)) { - if (isNotAroundZero(b)) { - var t1 = -c / b; - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - } - } - else { - var disc = b * b - 4 * a * c; - if (isAroundZero(disc)) { - var t1 = -b / (2 * a); - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - } - else if (disc > 0) { - var discSqrt = mathSqrt(disc); - var t1 = (-b + discSqrt) / (2 * a); - var t2 = (-b - discSqrt) / (2 * a); - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - if (t2 >= 0 && t2 <= 1) { - roots[n++] = t2; - } - } - } - return n; - } - - /** - * 计算二次贝塞尔方程极限值 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @return {number} - */ - function quadraticExtremum(p0, p1, p2) { - var divider = p0 + p2 - 2 * p1; - if (divider === 0) { - // p1 is center of p0 and p2 - return 0.5; - } - else { - return (p0 - p1) / divider; - } - } - - /** - * 细分二次贝塞尔曲线 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} t - * @param {Array.} out - */ - function quadraticSubdivide(p0, p1, p2, t, out) { - var p01 = (p1 - p0) * t + p0; - var p12 = (p2 - p1) * t + p1; - var p012 = (p12 - p01) * t + p01; - - // Seg0 - out[0] = p0; - out[1] = p01; - out[2] = p012; - - // Seg1 - out[3] = p012; - out[4] = p12; - out[5] = p2; - } - - /** - * 投射点到二次贝塞尔曲线上,返回投射距离。 - * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x - * @param {number} y - * @param {Array.} out 投射点 - * @return {number} - */ - function quadraticProjectPoint( - x0, y0, x1, y1, x2, y2, - x, y, out - ) { - // http://pomax.github.io/bezierinfo/#projections - var t; - var interval = 0.005; - var d = Infinity; - - _v0[0] = x; - _v0[1] = y; - - // 先粗略估计一下可能的最小距离的 t 值 - // PENDING - for (var _t = 0; _t < 1; _t += 0.05) { - _v1[0] = quadraticAt(x0, x1, x2, _t); - _v1[1] = quadraticAt(y0, y1, y2, _t); - var d1 = v2DistSquare(_v0, _v1); - if (d1 < d) { - t = _t; - d = d1; - } - } - d = Infinity; - - // At most 32 iteration - for (var i = 0; i < 32; i++) { - if (interval < EPSILON) { - break; - } - var prev = t - interval; - var next = t + interval; - // t - interval - _v1[0] = quadraticAt(x0, x1, x2, prev); - _v1[1] = quadraticAt(y0, y1, y2, prev); - - var d1 = v2DistSquare(_v1, _v0); - - if (prev >= 0 && d1 < d) { - t = prev; - d = d1; - } - else { - // t + interval - _v2[0] = quadraticAt(x0, x1, x2, next); - _v2[1] = quadraticAt(y0, y1, y2, next); - var d2 = v2DistSquare(_v2, _v0); - if (next <= 1 && d2 < d) { - t = next; - d = d2; - } - else { - interval *= 0.5; - } - } - } - // t - if (out) { - out[0] = quadraticAt(x0, x1, x2, t); - out[1] = quadraticAt(y0, y1, y2, t); - } - // console.log(interval, i); - return mathSqrt(d); - } - - return { - - cubicAt: cubicAt, - - cubicDerivativeAt: cubicDerivativeAt, - - cubicRootAt: cubicRootAt, - - cubicExtrema: cubicExtrema, - - cubicSubdivide: cubicSubdivide, - - cubicProjectPoint: cubicProjectPoint, - - quadraticAt: quadraticAt, - - quadraticDerivativeAt: quadraticDerivativeAt, - - quadraticRootAt: quadraticRootAt, - - quadraticExtremum: quadraticExtremum, - - quadraticSubdivide: quadraticSubdivide, - - quadraticProjectPoint: quadraticProjectPoint - }; -}); -/** - * @author Yi Shen(https://github.com/pissang) - */ -define('zrender/core/bbox',['require','./vector','./curve'],function (require) { - - var vec2 = require('./vector'); - var curve = require('./curve'); - - var bbox = {}; - var mathMin = Math.min; - var mathMax = Math.max; - var mathSin = Math.sin; - var mathCos = Math.cos; - - var start = vec2.create(); - var end = vec2.create(); - var extremity = vec2.create(); - - var PI2 = Math.PI * 2; - /** - * 从顶点数组中计算出最小包围盒,写入`min`和`max`中 - * @module zrender/core/bbox - * @param {Array} points 顶点数组 - * @param {number} min - * @param {number} max - */ - bbox.fromPoints = function(points, min, max) { - if (points.length === 0) { - return; - } - var p = points[0]; - var left = p[0]; - var right = p[0]; - var top = p[1]; - var bottom = p[1]; - var i; - - for (i = 1; i < points.length; i++) { - p = points[i]; - left = mathMin(left, p[0]); - right = mathMax(right, p[0]); - top = mathMin(top, p[1]); - bottom = mathMax(bottom, p[1]); - } - - min[0] = left; - min[1] = top; - max[0] = right; - max[1] = bottom; - }; - - /** - * @memberOf module:zrender/core/bbox - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {Array.} min - * @param {Array.} max - */ - bbox.fromLine = function (x0, y0, x1, y1, min, max) { - min[0] = mathMin(x0, x1); - min[1] = mathMin(y0, y1); - max[0] = mathMax(x0, x1); - max[1] = mathMax(y0, y1); - }; - - /** - * 从三阶贝塞尔曲线(p0, p1, p2, p3)中计算出最小包围盒,写入`min`和`max`中 - * @memberOf module:zrender/core/bbox - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x3 - * @param {number} y3 - * @param {Array.} min - * @param {Array.} max - */ - bbox.fromCubic = function( - x0, y0, x1, y1, x2, y2, x3, y3, min, max - ) { - var xDim = []; - var yDim = []; - var cubicExtrema = curve.cubicExtrema; - var cubicAt = curve.cubicAt; - var left, right, top, bottom; - var i; - var n = cubicExtrema(x0, x1, x2, x3, xDim); - - for (i = 0; i < n; i++) { - xDim[i] = cubicAt(x0, x1, x2, x3, xDim[i]); - } - n = cubicExtrema(y0, y1, y2, y3, yDim); - for (i = 0; i < n; i++) { - yDim[i] = cubicAt(y0, y1, y2, y3, yDim[i]); - } - - xDim.push(x0, x3); - yDim.push(y0, y3); - - left = mathMin.apply(null, xDim); - right = mathMax.apply(null, xDim); - top = mathMin.apply(null, yDim); - bottom = mathMax.apply(null, yDim); - - min[0] = left; - min[1] = top; - max[0] = right; - max[1] = bottom; - }; - - /** - * 从二阶贝塞尔曲线(p0, p1, p2)中计算出最小包围盒,写入`min`和`max`中 - * @memberOf module:zrender/core/bbox - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {Array.} min - * @param {Array.} max - */ - bbox.fromQuadratic = function(x0, y0, x1, y1, x2, y2, min, max) { - var quadraticExtremum = curve.quadraticExtremum; - var quadraticAt = curve.quadraticAt; - // Find extremities, where derivative in x dim or y dim is zero - var tx = - mathMax( - mathMin(quadraticExtremum(x0, x1, x2), 1), 0 - ); - var ty = - mathMax( - mathMin(quadraticExtremum(y0, y1, y2), 1), 0 - ); - - var x = quadraticAt(x0, x1, x2, tx); - var y = quadraticAt(y0, y1, y2, ty); - - min[0] = mathMin(x0, x2, x); - min[1] = mathMin(y0, y2, y); - max[0] = mathMax(x0, x2, x); - max[1] = mathMax(y0, y2, y); - }; - - /** - * 从圆弧中计算出最小包围盒,写入`min`和`max`中 - * @method - * @memberOf module:zrender/core/bbox - * @param {number} x - * @param {number} y - * @param {number} rx - * @param {number} ry - * @param {number} startAngle - * @param {number} endAngle - * @param {number} anticlockwise - * @param {Array.} min - * @param {Array.} max - */ - bbox.fromArc = function ( - x, y, rx, ry, startAngle, endAngle, anticlockwise, min, max - ) { - var vec2Min = vec2.min; - var vec2Max = vec2.max; - - var diff = Math.abs(startAngle - endAngle); - - - if (diff % PI2 < 1e-4 && diff > 1e-4) { - // Is a circle - min[0] = x - rx; - min[1] = y - ry; - max[0] = x + rx; - max[1] = y + ry; - return; - } - - start[0] = mathCos(startAngle) * rx + x; - start[1] = mathSin(startAngle) * ry + y; - - end[0] = mathCos(endAngle) * rx + x; - end[1] = mathSin(endAngle) * ry + y; - - vec2Min(min, start, end); - vec2Max(max, start, end); - - // Thresh to [0, Math.PI * 2] - startAngle = startAngle % (PI2); - if (startAngle < 0) { - startAngle = startAngle + PI2; - } - endAngle = endAngle % (PI2); - if (endAngle < 0) { - endAngle = endAngle + PI2; - } - - if (startAngle > endAngle && !anticlockwise) { - endAngle += PI2; - } - else if (startAngle < endAngle && anticlockwise) { - startAngle += PI2; - } - if (anticlockwise) { - var tmp = endAngle; - endAngle = startAngle; - startAngle = tmp; - } - - // var number = 0; - // var step = (anticlockwise ? -Math.PI : Math.PI) / 2; - for (var angle = 0; angle < endAngle; angle += Math.PI / 2) { - if (angle > startAngle) { - extremity[0] = mathCos(angle) * rx + x; - extremity[1] = mathSin(angle) * ry + y; - - vec2Min(min, extremity, min); - vec2Max(max, extremity, max); - } - } - }; - - return bbox; -}); -/** - * Path 代理,可以在`buildPath`中用于替代`ctx`, 会保存每个path操作的命令到pathCommands属性中 - * 可以用于 isInsidePath 判断以及获取boundingRect - * - * @module zrender/core/PathProxy - * @author Yi Shen (http://www.github.com/pissang) - */ - - // TODO getTotalLength, getPointAtLength -define('zrender/core/PathProxy',['require','./curve','./vector','./bbox','./BoundingRect'],function (require) { - - - var curve = require('./curve'); - var vec2 = require('./vector'); - var bbox = require('./bbox'); - var BoundingRect = require('./BoundingRect'); - - var CMD = { - M: 1, - L: 2, - C: 3, - Q: 4, - A: 5, - Z: 6, - // Rect - R: 7 - }; - - var min = []; - var max = []; - var min2 = []; - var max2 = []; - var mathMin = Math.min; - var mathMax = Math.max; - var mathCos = Math.cos; - var mathSin = Math.sin; - var mathSqrt = Math.sqrt; - - var hasTypedArray = typeof Float32Array != 'undefined'; - - /** - * @alias module:zrender/core/PathProxy - * @constructor - */ - var PathProxy = function () { - - /** - * Path data. Stored as flat array - * @type {Array.} - */ - this.data = []; - - this._len = 0; - - this._ctx = null; - - this._xi = 0; - this._yi = 0; - - this._x0 = 0; - this._y0 = 0; - }; - - /** - * 快速计算Path包围盒(并不是最小包围盒) - * @return {Object} - */ - PathProxy.prototype = { - - constructor: PathProxy, - - _lineDash: null, - - _dashOffset: 0, - - _dashIdx: 0, - - _dashSum: 0, - - getContext: function () { - return this._ctx; - }, - - /** - * @param {CanvasRenderingContext2D} ctx - * @return {module:zrender/core/PathProxy} - */ - beginPath: function (ctx) { - this._ctx = ctx; - - ctx && ctx.beginPath(); - - // Reset - this._len = 0; - - if (this._lineDash) { - this._lineDash = null; - - this._dashOffset = 0; - } - - return this; - }, - - /** - * @param {number} x - * @param {number} y - * @return {module:zrender/core/PathProxy} - */ - moveTo: function (x, y) { - this.addData(CMD.M, x, y); - this._ctx && this._ctx.moveTo(x, y); - - // x0, y0, xi, yi 是记录在 _dashedXXXXTo 方法中使用 - // xi, yi 记录当前点, x0, y0 在 closePath 的时候回到起始点。 - // 有可能在 beginPath 之后直接调用 lineTo,这时候 x0, y0 需要 - // 在 lineTo 方法中记录,这里先不考虑这种情况,dashed line 也只在 IE10- 中不支持 - this._x0 = x; - this._y0 = y; - - this._xi = x; - this._yi = y; - - return this; - }, - - /** - * @param {number} x - * @param {number} y - * @return {module:zrender/core/PathProxy} - */ - lineTo: function (x, y) { - this.addData(CMD.L, x, y); - if (this._ctx) { - this._needsDash() ? this._dashedLineTo(x, y) - : this._ctx.lineTo(x, y); - } - this._xi = x; - this._yi = y; - return this; - }, - - /** - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x3 - * @param {number} y3 - * @return {module:zrender/core/PathProxy} - */ - bezierCurveTo: function (x1, y1, x2, y2, x3, y3) { - this.addData(CMD.C, x1, y1, x2, y2, x3, y3); - if (this._ctx) { - this._needsDash() ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3) - : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3); - } - this._xi = x3; - this._yi = y3; - return this; - }, - - /** - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @return {module:zrender/core/PathProxy} - */ - quadraticCurveTo: function (x1, y1, x2, y2) { - this.addData(CMD.Q, x1, y1, x2, y2); - if (this._ctx) { - this._needsDash() ? this._dashedQuadraticTo(x1, y1, x2, y2) - : this._ctx.quadraticCurveTo(x1, y1, x2, y2); - } - this._xi = x2; - this._yi = y2; - return this; - }, - - /** - * @param {number} cx - * @param {number} cy - * @param {number} r - * @param {number} startAngle - * @param {number} endAngle - * @param {boolean} anticlockwise - * @return {module:zrender/core/PathProxy} - */ - arc: function (cx, cy, r, startAngle, endAngle, anticlockwise) { - this.addData( - CMD.A, cx, cy, r, r, startAngle, endAngle - startAngle, 0, anticlockwise ? 0 : 1 - ); - this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise); - - this._xi = mathCos(endAngle) * r + cx; - this._xi = mathSin(endAngle) * r + cx; - return this; - }, - - // TODO - arcTo: function (x1, y1, x2, y2, radius) { - if (this._ctx) { - this._ctx.arcTo(x1, y1, x2, y2, radius); - } - return this; - }, - - // TODO - rect: function (x, y, w, h) { - this._ctx && this._ctx.rect(x, y, w, h); - this.addData(CMD.R, x, y, w, h); - return this; - }, - - /** - * @return {module:zrender/core/PathProxy} - */ - closePath: function () { - this.addData(CMD.Z); - - var ctx = this._ctx; - var x0 = this._x0; - var y0 = this._y0; - if (ctx) { - this._needsDash() && this._dashedLineTo(x0, y0); - ctx.closePath(); - } - - this._xi = x0; - this._yi = y0; - return this; - }, - - /** - * Context 从外部传入,因为有可能是 rebuildPath 完之后再 fill。 - * stroke 同样 - * @param {CanvasRenderingContext2D} ctx - * @return {module:zrender/core/PathProxy} - */ - fill: function (ctx) { - ctx && ctx.fill(); - this.toStatic(); - }, - - /** - * @param {CanvasRenderingContext2D} ctx - * @return {module:zrender/core/PathProxy} - */ - stroke: function (ctx) { - ctx && ctx.stroke(); - this.toStatic(); - }, - - /** - * 必须在其它绘制命令前调用 - * Must be invoked before all other path drawing methods - * @return {module:zrender/core/PathProxy} - */ - setLineDash: function (lineDash) { - if (lineDash instanceof Array) { - this._lineDash = lineDash; - - this._dashIdx = 0; - - var lineDashSum = 0; - for (var i = 0; i < lineDash.length; i++) { - lineDashSum += lineDash[i]; - } - this._dashSum = lineDashSum; - } - return this; - }, - - /** - * 必须在其它绘制命令前调用 - * Must be invoked before all other path drawing methods - * @return {module:zrender/core/PathProxy} - */ - setLineDashOffset: function (offset) { - this._dashOffset = offset; - return this; - }, - - /** - * - * @return {boolean} - */ - len: function () { - return this._len; - }, - - /** - * 直接设置 Path 数据 - */ - setData: function (data) { - - var len = data.length; - - if (! (this.data && this.data.length == len) && hasTypedArray) { - this.data = new Float32Array(len); - } - - for (var i = 0; i < len; i++) { - this.data[i] = data[i]; - } - - this._len = len; - }, - - /** - * 添加子路径 - * @param {module:zrender/core/PathProxy|Array.} path - */ - appendPath: function (path) { - if (!(path instanceof Array)) { - path = [path]; - } - var len = path.length; - var appendSize = 0; - var offset = this._len; - for (var i = 0; i < len; i++) { - appendSize += path[i].len(); - } - if (hasTypedArray && (this.data instanceof Float32Array)) { - this.data = new Float32Array(offset + appendSize); - } - for (var i = 0; i < len; i++) { - var appendPathData = path[i].data; - for (var k = 0; k < appendPathData.length; k++) { - this.data[offset++] = appendPathData[k]; - } - } - this._len = offset; - }, - - /** - * 填充 Path 数据。 - * 尽量复用而不申明新的数组。大部分图形重绘的指令数据长度都是不变的。 - */ - addData: function (cmd) { - var data = this.data; - if (this._len + arguments.length > data.length) { - // 因为之前的数组已经转换成静态的 Float32Array - // 所以不够用时需要扩展一个新的动态数组 - this._expandData(); - data = this.data; - } - for (var i = 0; i < arguments.length; i++) { - data[this._len++] = arguments[i]; - } - - this._prevCmd = cmd; - }, - - _expandData: function () { - // Only if data is Float32Array - if (!(this.data instanceof Array)) { - var newData = []; - for (var i = 0; i < this._len; i++) { - newData[i] = this.data[i]; - } - this.data = newData; - } - }, - - /** - * If needs js implemented dashed line - * @return {boolean} - * @private - */ - _needsDash: function () { - return this._lineDash; - }, - - _dashedLineTo: function (x1, y1) { - var dashSum = this._dashSum; - var offset = this._dashOffset; - var lineDash = this._lineDash; - var ctx = this._ctx; - - var x0 = this._xi; - var y0 = this._yi; - var dx = x1 - x0; - var dy = y1 - y0; - var dist = mathSqrt(dx * dx + dy * dy); - var x = x0; - var y = y0; - var dash; - var nDash = lineDash.length; - var idx; - dx /= dist; - dy /= dist; - - if (offset < 0) { - // Convert to positive offset - offset = dashSum + offset; - } - offset %= dashSum; - x -= offset * dx; - y -= offset * dy; - - while ((dx >= 0 && x <= x1) || (dx < 0 && x > x1)) { - idx = this._dashIdx; - dash = lineDash[idx]; - x += dx * dash; - y += dy * dash; - this._dashIdx = (idx + 1) % nDash; - // Skip positive offset - if ((dx > 0 && x < x0) || (dx < 0 && x > x0)) { - continue; - } - ctx[idx % 2 ? 'moveTo' : 'lineTo']( - dx >= 0 ? mathMin(x, x1) : mathMax(x, x1), - dy >= 0 ? mathMin(y, y1) : mathMax(y, y1) - ); - } - // Offset for next lineTo - dx = x - x1; - dy = y - y1; - this._dashOffset = -mathSqrt(dx * dx + dy * dy); - }, - - // Not accurate dashed line to - _dashedBezierTo: function (x1, y1, x2, y2, x3, y3) { - var dashSum = this._dashSum; - var offset = this._dashOffset; - var lineDash = this._lineDash; - var ctx = this._ctx; - - var x0 = this._xi; - var y0 = this._yi; - var t; - var dx; - var dy; - var cubicAt = curve.cubicAt; - var bezierLen = 0; - var idx = this._dashIdx; - var nDash = lineDash.length; - - var x; - var y; - - var tmpLen = 0; - - if (offset < 0) { - // Convert to positive offset - offset = dashSum + offset; - } - offset %= dashSum; - // Bezier approx length - for (t = 0; t < 1; t += 0.1) { - dx = cubicAt(x0, x1, x2, x3, t + 0.1) - - cubicAt(x0, x1, x2, x3, t); - dy = cubicAt(y0, y1, y2, y3, t + 0.1) - - cubicAt(y0, y1, y2, y3, t); - bezierLen += mathSqrt(dx * dx + dy * dy); - } - - // Find idx after add offset - for (; idx < nDash; idx++) { - tmpLen += lineDash[idx]; - if (tmpLen > offset) { - break; - } - } - t = (tmpLen - offset) / bezierLen; - - while (t <= 1) { - - x = cubicAt(x0, x1, x2, x3, t); - y = cubicAt(y0, y1, y2, y3, t); - - // Use line to approximate dashed bezier - // Bad result if dash is long - idx % 2 ? ctx.moveTo(x, y) - : ctx.lineTo(x, y); - - t += lineDash[idx] / bezierLen; - - idx = (idx + 1) % nDash; - } - - // Finish the last segment and calculate the new offset - (idx % 2 !== 0) && ctx.lineTo(x3, y3); - dx = x3 - x; - dy = y3 - y; - this._dashOffset = -mathSqrt(dx * dx + dy * dy); - }, - - _dashedQuadraticTo: function (x1, y1, x2, y2) { - // Convert quadratic to cubic using degree elevation - var x3 = x2; - var y3 = y2; - x2 = (x2 + 2 * x1) / 3; - y2 = (y2 + 2 * y1) / 3; - x1 = (this._xi + 2 * x1) / 3; - y1 = (this._yi + 2 * y1) / 3; - - this._dashedBezierTo(x1, y1, x2, y2, x3, y3); - }, - - /** - * 转成静态的 Float32Array 减少堆内存占用 - * Convert dynamic array to static Float32Array - */ - toStatic: function () { - var data = this.data; - if (data instanceof Array) { - data.length = this._len; - if (hasTypedArray) { - this.data = new Float32Array(data); - } - } - }, - - /** - * @return {module:zrender/core/BoundingRect} - */ - getBoundingRect: function () { - min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE; - max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE; - - var data = this.data; - var xi = 0; - var yi = 0; - var x0 = 0; - var y0 = 0; - - for (var i = 0; i < data.length;) { - var cmd = data[i++]; - - if (i == 1) { - // 如果第一个命令是 L, C, Q - // 则 previous point 同绘制命令的第一个 point - // - // 第一个命令为 Arc 的情况下会在后面特殊处理 - xi = data[i]; - yi = data[i + 1]; - - x0 = xi; - y0 = yi; - } - - switch (cmd) { - case CMD.M: - // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点 - // 在 closePath 的时候使用 - x0 = data[i++]; - y0 = data[i++]; - xi = x0; - yi = y0; - min2[0] = x0; - min2[1] = y0; - max2[0] = x0; - max2[1] = y0; - break; - case CMD.L: - bbox.fromLine(xi, yi, data[i], data[i + 1], min2, max2); - xi = data[i++]; - yi = data[i++]; - break; - case CMD.C: - bbox.fromCubic( - xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], - min2, max2 - ); - xi = data[i++]; - yi = data[i++]; - break; - case CMD.Q: - bbox.fromQuadratic( - xi, yi, data[i++], data[i++], data[i], data[i + 1], - min2, max2 - ); - xi = data[i++]; - yi = data[i++]; - break; - case CMD.A: - // TODO Arc 判断的开销比较大 - var cx = data[i++]; - var cy = data[i++]; - var rx = data[i++]; - var ry = data[i++]; - var startAngle = data[i++]; - var endAngle = data[i++] + startAngle; - // TODO Arc 旋转 - var psi = data[i++]; - var anticlockwise = 1 - data[i++]; - - if (i == 1) { - // 直接使用 arc 命令 - // 第一个命令起点还未定义 - x0 = mathCos(startAngle) * rx + cx; - y0 = mathSin(startAngle) * ry + cy; - } - - bbox.fromArc( - cx, cy, rx, ry, startAngle, endAngle, - anticlockwise, min2, max2 - ); - - xi = mathCos(endAngle) * rx + cx; - yi = mathSin(endAngle) * ry + cy; - break; - case CMD.R: - x0 = xi = data[i++]; - y0 = yi = data[i++]; - var width = data[i++]; - var height = data[i++]; - // Use fromLine - bbox.fromLine(x0, y0, x0 + width, y0 + height, min2, max2); - break; - case CMD.Z: - xi = x0; - yi = y0; - break; - } - - // Union - vec2.min(min, min, min2); - vec2.max(max, max, max2); - } - - // No data - if (i === 0) { - min[0] = min[1] = max[0] = max[1] = 0; - } - - return new BoundingRect( - min[0], min[1], max[0] - min[0], max[1] - min[1] - ); - }, - - /** - * Rebuild path from current data - * Rebuild path will not consider javascript implemented line dash. - * @param {CanvasRenderingContext} ctx - */ - rebuildPath: function (ctx) { - var d = this.data; - for (var i = 0; i < this._len;) { - var cmd = d[i++]; - switch (cmd) { - case CMD.M: - ctx.moveTo(d[i++], d[i++]); - break; - case CMD.L: - ctx.lineTo(d[i++], d[i++]); - break; - case CMD.C: - ctx.bezierCurveTo( - d[i++], d[i++], d[i++], d[i++], d[i++], d[i++] - ); - break; - case CMD.Q: - ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]); - break; - case CMD.A: - var cx = d[i++]; - var cy = d[i++]; - var rx = d[i++]; - var ry = d[i++]; - var theta = d[i++]; - var dTheta = d[i++]; - var psi = d[i++]; - var fs = d[i++]; - var r = (rx > ry) ? rx : ry; - var scaleX = (rx > ry) ? 1 : rx / ry; - var scaleY = (rx > ry) ? ry / rx : 1; - var isEllipse = Math.abs(rx - ry) > 1e-3; - if (isEllipse) { - ctx.translate(cx, cy); - ctx.rotate(psi); - ctx.scale(scaleX, scaleY); - ctx.arc(0, 0, r, theta, theta + dTheta, 1 - fs); - ctx.scale(1 / scaleX, 1 / scaleY); - ctx.rotate(-psi); - ctx.translate(-cx, -cy); - } - else { - ctx.arc(cx, cy, r, theta, theta + dTheta, 1 - fs); - } - break; - case CMD.R: - ctx.rect(d[i++], d[i++], d[i++], d[i++]); - break; - case CMD.Z: - ctx.closePath(); - } - } - } - }; - - PathProxy.CMD = CMD; - - return PathProxy; -}); -define('zrender/contain/line',[],function () { - return { - /** - * 线段包含判断 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} lineWidth - * @param {number} x - * @param {number} y - * @return {boolean} - */ - containStroke: function (x0, y0, x1, y1, lineWidth, x, y) { - if (lineWidth === 0) { - return false; - } - var _l = lineWidth; - var _a = 0; - var _b = x0; - // Quick reject - 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) - ) { - return false; - } - - if (x0 !== x1) { - _a = (y0 - y1) / (x0 - x1); - _b = (x0 * y1 - x1 * y0) / (x0 - x1) ; - } - else { - return Math.abs(x - x0) <= _l / 2; - } - var tmp = _a * x - y + _b; - var _s = tmp * tmp / (_a * _a + 1); - return _s <= _l / 2 * _l / 2; - } - }; -}); -define('zrender/contain/cubic',['require','../core/curve'],function (require) { - - var curve = require('../core/curve'); - - return { - /** - * 三次贝塞尔曲线描边包含判断 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x3 - * @param {number} y3 - * @param {number} lineWidth - * @param {number} x - * @param {number} y - * @return {boolean} - */ - containStroke: function(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) { - if (lineWidth === 0) { - return false; - } - var _l = lineWidth; - // Quick reject - 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) - ) { - return false; - } - var d = curve.cubicProjectPoint( - x0, y0, x1, y1, x2, y2, x3, y3, - x, y, null - ); - return d <= _l / 2; - } - }; -}); -define('zrender/contain/quadratic',['require','../core/curve'],function (require) { - - var curve = require('../core/curve'); - - return { - /** - * 二次贝塞尔曲线描边包含判断 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} lineWidth - * @param {number} x - * @param {number} y - * @return {boolean} - */ - containStroke: function (x0, y0, x1, y1, x2, y2, lineWidth, x, y) { - if (lineWidth === 0) { - return false; - } - var _l = lineWidth; - // Quick reject - 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) - ) { - return false; - } - var d = curve.quadraticProjectPoint( - x0, y0, x1, y1, x2, y2, - x, y, null - ); - return d <= _l / 2; - } - }; -}); -define('zrender/contain/util',['require'],function (require) { - - var PI2 = Math.PI * 2; - return { - normalizeRadian: function(angle) { - angle %= PI2; - if (angle < 0) { - angle += PI2; - } - return angle; - } - }; -}); -define('zrender/contain/arc',['require','./util'],function (require) { - - var normalizeRadian = require('./util').normalizeRadian; - var PI2 = Math.PI * 2; - - return { - /** - * 圆弧描边包含判断 - * @param {number} cx - * @param {number} cy - * @param {number} r - * @param {number} startAngle - * @param {number} endAngle - * @param {boolean} anticlockwise - * @param {number} lineWidth - * @param {number} x - * @param {number} y - * @return {Boolean} - */ - containStroke: function ( - cx, cy, r, startAngle, endAngle, anticlockwise, - lineWidth, x, y - ) { - - if (lineWidth === 0) { - return false; - } - var _l = lineWidth; - - x -= cx; - y -= cy; - var d = Math.sqrt(x * x + y * y); - - if ((d - _l > r) || (d + _l < r)) { - return false; - } - if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) { - // Is a circle - return true; - } - if (anticlockwise) { - var tmp = startAngle; - startAngle = normalizeRadian(endAngle); - endAngle = normalizeRadian(tmp); - } else { - startAngle = normalizeRadian(startAngle); - endAngle = normalizeRadian(endAngle); - } - if (startAngle > endAngle) { - endAngle += PI2; - } - - var angle = Math.atan2(y, x); - if (angle < 0) { - angle += PI2; - } - return (angle >= startAngle && angle <= endAngle) - || (angle + PI2 >= startAngle && angle + PI2 <= endAngle); - } - }; -}); -define('zrender/contain/windingLine',[],function () { - return function windingLine(x0, y0, x1, y1, x, y) { - if ((y > y0 && y > y1) || (y < y0 && y < y1)) { - return 0; - } - if (y1 === y0) { - return 0; - } - var dir = y1 < y0 ? 1 : -1; - var t = (y - y0) / (y1 - y0); - var x_ = t * (x1 - x0) + x0; - - return x_ > x ? dir : 0; - }; -}); -define('zrender/contain/path',['require','../core/PathProxy','./line','./cubic','./quadratic','./arc','./util','../core/curve','./windingLine'],function (require) { - - - - var CMD = require('../core/PathProxy').CMD; - var line = require('./line'); - var cubic = require('./cubic'); - var quadratic = require('./quadratic'); - var arc = require('./arc'); - var normalizeRadian = require('./util').normalizeRadian; - var curve = require('../core/curve'); - - var windingLine = require('./windingLine'); - - var containStroke = line.containStroke; - - var PI2 = Math.PI * 2; - - var EPSILON = 1e-4; - - function isAroundEqual(a, b) { - return Math.abs(a - b) < EPSILON; - } - - // 临时数组 - var roots = [-1, -1, -1]; - var extrema = [-1, -1]; - - function swapExtrema() { - var tmp = extrema[0]; - extrema[0] = extrema[1]; - extrema[1] = tmp; - } - - function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) { - // Quick reject - if ( - (y > y0 && y > y1 && y > y2 && y > y3) - || (y < y0 && y < y1 && y < y2 && y < y3) - ) { - return 0; - } - var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots); - if (nRoots === 0) { - return 0; - } - else { - var w = 0; - var nExtrema = -1; - var y0_, y1_; - for (var i = 0; i < nRoots; i++) { - var t = roots[i]; - var x_ = curve.cubicAt(x0, x1, x2, x3, t); - if (x_ < x) { // Quick reject - continue; - } - if (nExtrema < 0) { - nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema); - if (extrema[1] < extrema[0] && nExtrema > 1) { - swapExtrema(); - } - y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]); - if (nExtrema > 1) { - y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]); - } - } - if (nExtrema == 2) { - // 分成三段单调函数 - if (t < extrema[0]) { - w += y0_ < y0 ? 1 : -1; - } - else if (t < extrema[1]) { - w += y1_ < y0_ ? 1 : -1; - } - else { - w += y3 < y1_ ? 1 : -1; - } - } - else { - // 分成两段单调函数 - if (t < extrema[0]) { - w += y0_ < y0 ? 1 : -1; - } - else { - w += y3 < y0_ ? 1 : -1; - } - } - } - return w; - } - } - - function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) { - // Quick reject - if ( - (y > y0 && y > y1 && y > y2) - || (y < y0 && y < y1 && y < y2) - ) { - return 0; - } - var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots); - if (nRoots === 0) { - return 0; - } - else { - var t = curve.quadraticExtremum(y0, y1, y2); - if (t >=0 && t <= 1) { - var w = 0; - var y_ = curve.quadraticAt(y0, y1, y2, t); - for (var i = 0; i < nRoots; i++) { - var x_ = curve.quadraticAt(x0, x1, x2, roots[i]); - if (x_ > x) { - continue; - } - if (roots[i] < t) { - w += y_ < y0 ? 1 : -1; - } - else { - w += y2 < y_ ? 1 : -1; - } - } - return w; - } - else { - var x_ = curve.quadraticAt(x0, x1, x2, roots[0]); - if (x_ > x) { - return 0; - } - return y2 < y0 ? 1 : -1; - } - } - } - - // TODO - // Arc 旋转 - function windingArc( - cx, cy, r, startAngle, endAngle, anticlockwise, x, y - ) { - y -= cy; - if (y > r || y < -r) { - return 0; - } - var tmp = Math.sqrt(r * r - y * y); - roots[0] = -tmp; - roots[1] = tmp; - - var diff = Math.abs(startAngle - endAngle); - if (diff < 1e-4) { - return 0; - } - if (diff % PI2 < 1e-4) { - // Is a circle - startAngle = 0; - endAngle = PI2; - var dir = anticlockwise ? 1 : -1; - if (x >= roots[0] + cx && x <= roots[1] + cx) { - return dir; - } else { - return 0; - } - } - - if (anticlockwise) { - var tmp = startAngle; - startAngle = normalizeRadian(endAngle); - endAngle = normalizeRadian(tmp); - } - else { - startAngle = normalizeRadian(startAngle); - endAngle = normalizeRadian(endAngle); - } - if (startAngle > endAngle) { - endAngle += PI2; - } - - var w = 0; - for (var i = 0; i < 2; i++) { - var x_ = roots[i]; - if (x_ + cx > x) { - var angle = Math.atan2(y, x_); - var dir = anticlockwise ? 1 : -1; - if (angle < 0) { - angle = PI2 + angle; - } - if ( - (angle >= startAngle && angle <= endAngle) - || (angle + PI2 >= startAngle && angle + PI2 <= endAngle) - ) { - if (angle > Math.PI / 2 && angle < Math.PI * 1.5) { - dir = -dir; - } - w += dir; - } - } - } - return w; - } - - function containPath(data, lineWidth, isStroke, x, y) { - var w = 0; - var xi = 0; - var yi = 0; - var x0 = 0; - var y0 = 0; - - for (var i = 0; i < data.length;) { - var cmd = data[i++]; - // Begin a new subpath - if (cmd === CMD.M && i > 1) { - // Close previous subpath - if (!isStroke) { - w += windingLine(xi, yi, x0, y0, x, y); - } - // 如果被任何一个 subpath 包含 - if (w !== 0) { - return true; - } - } - - if (i == 1) { - // 如果第一个命令是 L, C, Q - // 则 previous point 同绘制命令的第一个 point - // - // 第一个命令为 Arc 的情况下会在后面特殊处理 - xi = data[i]; - yi = data[i + 1]; - - x0 = xi; - y0 = yi; - } - - switch (cmd) { - case CMD.M: - // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点 - // 在 closePath 的时候使用 - x0 = data[i++]; - y0 = data[i++]; - xi = x0; - yi = y0; - break; - case CMD.L: - if (isStroke) { - if (containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) { - return true; - } - } - else { - // NOTE 在第一个命令为 L, C, Q 的时候会计算出 NaN - w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0; - } - xi = data[i++]; - yi = data[i++]; - break; - case CMD.C: - if (isStroke) { - if (cubic.containStroke(xi, yi, - data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], - lineWidth, x, y - )) { - return true; - } - } - else { - w += windingCubic( - xi, yi, - data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], - x, y - ) || 0; - } - xi = data[i++]; - yi = data[i++]; - break; - case CMD.Q: - if (isStroke) { - if (quadratic.containStroke(xi, yi, - data[i++], data[i++], data[i], data[i + 1], - lineWidth, x, y - )) { - return true; - } - } - else { - w += windingQuadratic( - xi, yi, - data[i++], data[i++], data[i], data[i + 1], - x, y - ) || 0; - } - xi = data[i++]; - yi = data[i++]; - break; - case CMD.A: - // TODO Arc 判断的开销比较大 - var cx = data[i++]; - var cy = data[i++]; - var rx = data[i++]; - var ry = data[i++]; - var theta = data[i++]; - var dTheta = data[i++]; - // TODO Arc 旋转 - var psi = data[i++]; - var anticlockwise = 1 - data[i++]; - var x1 = Math.cos(theta) * rx + cx; - var y1 = Math.sin(theta) * ry + cy; - // 不是直接使用 arc 命令 - if (i > 1) { - w += windingLine(xi, yi, x1, y1, x, y); - } - else { - // 第一个命令起点还未定义 - x0 = x1; - y0 = y1; - } - // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放 - var _x = (x - cx) * ry / rx + cx; - if (isStroke) { - if (arc.containStroke( - cx, cy, ry, theta, theta + dTheta, anticlockwise, - lineWidth, _x, y - )) { - return true; - } - } - else { - w += windingArc( - cx, cy, ry, theta, theta + dTheta, anticlockwise, - _x, y - ); - } - xi = Math.cos(theta + dTheta) * rx + cx; - yi = Math.sin(theta + dTheta) * ry + cy; - break; - case CMD.R: - x0 = xi = data[i++]; - y0 = yi = data[i++]; - var width = data[i++]; - var height = data[i++]; - var x1 = x0 + width; - var y1 = y0 + height; - if (isStroke) { - if (containStroke(x0, y0, x1, y0, lineWidth, x, y) - || containStroke(x1, y0, x1, y1, lineWidth, x, y) - || containStroke(x1, y1, x0, y1, lineWidth, x, y) - || containStroke(x0, y1, x1, y1, lineWidth, x, y) - ) { - return true; - } - } - else { - // FIXME Clockwise ? - w += windingLine(x1, y0, x1, y1, x, y); - w += windingLine(x0, y1, x0, y0, x, y); - } - break; - case CMD.Z: - if (isStroke) { - if (containStroke( - xi, yi, x0, y0, lineWidth, x, y - )) { - return true; - } - } - else { - // Close a subpath - w += windingLine(xi, yi, x0, y0, x, y); - // 如果被任何一个 subpath 包含 - if (w !== 0) { - return true; - } - } - xi = x0; - yi = y0; - break; - } - } - if (!isStroke && !isAroundEqual(yi, y0)) { - w += windingLine(xi, yi, x0, y0, x, y) || 0; - } - return w !== 0; - } - - return { - contain: function (pathData, x, y) { - return containPath(pathData, 0, false, x, y); - }, - - containStroke: function (pathData, lineWidth, x, y) { - return containPath(pathData, lineWidth, true, x, y); - } - }; -}); -/** - * Path element - * @module zrender/graphic/Path - */ - -define('zrender/graphic/Path',['require','./Displayable','../core/util','../core/PathProxy','../contain/path','./Gradient'],function (require) { - - var Displayable = require('./Displayable'); - var zrUtil = require('../core/util'); - var PathProxy = require('../core/PathProxy'); - var pathContain = require('../contain/path'); - - var Gradient = require('./Gradient'); - - function pathHasFill(style) { - var fill = style.fill; - return fill != null && fill !== 'none'; - } - - function pathHasStroke(style) { - var stroke = style.stroke; - return stroke != null && stroke !== 'none' && style.lineWidth > 0; - } - - var abs = Math.abs; - - /** - * @alias module:zrender/graphic/Path - * @extends module:zrender/graphic/Displayable - * @constructor - * @param {Object} opts - */ - function Path(opts) { - Displayable.call(this, opts); - - /** - * @type {module:zrender/core/PathProxy} - * @readOnly - */ - this.path = new PathProxy(); - } - - Path.prototype = { - - constructor: Path, - - type: 'path', - - __dirtyPath: true, - - strokeContainThreshold: 5, - - brush: function (ctx) { - ctx.save(); - - var style = this.style; - var path = this.path; - var hasStroke = pathHasStroke(style); - var hasFill = pathHasFill(style); - - if (this.__dirtyPath) { - // Update gradient because bounding rect may changed - if (hasFill && (style.fill instanceof Gradient)) { - style.fill.updateCanvasGradient(this, ctx); - } - if (hasStroke && (style.stroke instanceof Gradient)) { - style.stroke.updateCanvasGradient(this, ctx); - } - } - - style.bind(ctx, this); - this.setTransform(ctx); - - var lineDash = style.lineDash; - var lineDashOffset = style.lineDashOffset; - - var ctxLineDash = !!ctx.setLineDash; - - // Proxy context - // Rebuild path in following 2 cases - // 1. Path is dirty - // 2. Path needs javascript implemented lineDash stroking. - // In this case, lineDash information will not be saved in PathProxy - if (this.__dirtyPath || ( - lineDash && !ctxLineDash && hasStroke - )) { - path = this.path.beginPath(ctx); - - // Setting line dash before build path - if (lineDash && !ctxLineDash) { - path.setLineDash(lineDash); - path.setLineDashOffset(lineDashOffset); - } - - this.buildPath(path, this.shape); - - // Clear path dirty flag - this.__dirtyPath = false; - } - else { - // Replay path building - ctx.beginPath(); - this.path.rebuildPath(ctx); - } - - hasFill && path.fill(ctx); - - if (lineDash && ctxLineDash) { - ctx.setLineDash(lineDash); - ctx.lineDashOffset = lineDashOffset; - } - - hasStroke && path.stroke(ctx); - - // Draw rect text - if (style.text != null) { - // var rect = this.getBoundingRect(); - this.drawRectText(ctx, this.getBoundingRect()); - } - - ctx.restore(); - }, - - buildPath: function (ctx, shapeCfg) {}, - - getBoundingRect: function () { - var rect = this._rect; - var style = this.style; - if (!rect) { - var path = this.path; - if (this.__dirtyPath) { - path.beginPath(); - this.buildPath(path, this.shape); - } - rect = path.getBoundingRect(); - } - /** - * Needs update rect with stroke lineWidth when - * 1. Element changes scale or lineWidth - * 2. First create rect - */ - if (pathHasStroke(style) && (this.__dirty || !this._rect)) { - var rectWithStroke = this._rectWithStroke - || (this._rectWithStroke = rect.clone()); - rectWithStroke.copy(rect); - // FIXME Must after updateTransform - var w = style.lineWidth; - // PENDING, Min line width is needed when line is horizontal or vertical - var lineScale = style.strokeNoScale ? this.getLineScale() : 1; - - // Only add extra hover lineWidth when there are no fill - if (!pathHasFill(style)) { - w = Math.max(w, this.strokeContainThreshold); - } - // Consider line width - // Line scale can't be 0; - if (lineScale > 1e-10) { - rectWithStroke.width += w / lineScale; - rectWithStroke.height += w / lineScale; - rectWithStroke.x -= w / lineScale / 2; - rectWithStroke.y -= w / lineScale / 2; - } - return rectWithStroke; - } - this._rect = rect; - return rect; - }, - - contain: function (x, y) { - var localPos = this.transformCoordToLocal(x, y); - var rect = this.getBoundingRect(); - var style = this.style; - x = localPos[0]; - y = localPos[1]; - - if (rect.contain(x, y)) { - var pathData = this.path.data; - if (pathHasStroke(style)) { - var lineWidth = style.lineWidth; - var lineScale = style.strokeNoScale ? this.getLineScale() : 1; - // Line scale can't be 0; - if (lineScale > 1e-10) { - // Only add extra hover lineWidth when there are no fill - if (!pathHasFill(style)) { - lineWidth = Math.max(lineWidth, this.strokeContainThreshold); - } - if (pathContain.containStroke( - pathData, lineWidth / lineScale, x, y - )) { - return true; - } - } - } - if (pathHasFill(style)) { - return pathContain.contain(pathData, x, y); - } - } - return false; - }, - - /** - * @param {boolean} dirtyPath - */ - dirty: function (dirtyPath) { - if (arguments.length ===0) { - dirtyPath = true; - } - // Only mark dirty, not mark clean - if (dirtyPath) { - this.__dirtyPath = dirtyPath; - this._rect = null; - } - - this.__dirty = true; - - this.__zr && this.__zr.refresh(); - - // Used as a clipping path - if (this.__clipTarget) { - this.__clipTarget.dirty(); - } - }, - - /** - * Alias for animate('shape') - * @param {boolean} loop - */ - animateShape: function (loop) { - return this.animate('shape', loop); - }, - - // Overwrite attrKV - attrKV: function (key, value) { - // FIXME - if (key === 'shape') { - this.setShape(value); - } - else { - Displayable.prototype.attrKV.call(this, key, value); - } - }, - /** - * @param {Object|string} key - * @param {*} value - */ - setShape: function (key, value) { - var shape = this.shape; - // Path from string may not have shape - if (shape) { - if (zrUtil.isObject(key)) { - for (var name in key) { - shape[name] = key[name]; - } - } - else { - shape[key] = value; - } - this.dirty(true); - } - return this; - }, - - getLineScale: function () { - var m = this.transform; - // Get the line scale. - // Determinant of `m` means how much the area is enlarged by the - // transformation. So its square root can be used as a scale factor - // for width. - return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10 - ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1])) - : 1; - } - }; - - /** - * 扩展一个 Path element, 比如星形,圆等。 - * Extend a path element - * @param {Object} props - * @param {string} props.type Path type - * @param {Function} props.init Initialize - * @param {Function} props.buildPath Overwrite buildPath method - * @param {Object} [props.style] Extended default style config - * @param {Object} [props.shape] Extended default shape config - */ - Path.extend = function (defaults) { - var Sub = function (opts) { - Path.call(this, opts); - - if (defaults.style) { - // Extend default style - this.style.extendFrom(defaults.style, false); - } - - // Extend default shape - var defaultShape = defaults.shape; - if (defaultShape) { - this.shape = this.shape || {}; - var thisShape = this.shape; - for (var name in defaultShape) { - if ( - ! thisShape.hasOwnProperty(name) - && defaultShape.hasOwnProperty(name) - ) { - thisShape[name] = defaultShape[name]; - } - } - } - - defaults.init && defaults.init.call(this, opts); - }; - - zrUtil.inherits(Sub, Path); - - // FIXME 不能 extend position, rotation 等引用对象 - for (var name in defaults) { - // Extending prototype values and methods - if (name !== 'style' && name !== 'shape') { - Sub.prototype[name] = defaults[name]; - } - } - - return Sub; - }; - - zrUtil.inherits(Path, Displayable); - - return Path; -}); -define('zrender/tool/transformPath',['require','../core/PathProxy','../core/vector'],function (require) { - - var CMD = require('../core/PathProxy').CMD; - var vec2 = require('../core/vector'); - var v2ApplyTransform = vec2.applyTransform; - - var points = [[], [], []]; - var mathSqrt = Math.sqrt; - var mathAtan2 = Math.atan2; - function transformPath(path, m) { - var data = path.data; - var cmd; - var nPoint; - var i; - var j; - var k; - var p; - - var M = CMD.M; - var C = CMD.C; - var L = CMD.L; - var R = CMD.R; - var A = CMD.A; - var Q = CMD.Q; - - for (i = 0, j = 0; i < data.length;) { - cmd = data[i++]; - j = i; - nPoint = 0; - - switch (cmd) { - case M: - nPoint = 1; - break; - case L: - nPoint = 1; - break; - case C: - nPoint = 3; - break; - case Q: - nPoint = 2; - break; - case A: - var x = m[4]; - var y = m[5]; - var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]); - var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]); - var angle = mathAtan2(-m[1] / sy, m[0] / sx); - // cx - data[i++] += x; - // cy - data[i++] += y; - // Scale rx and ry - // FIXME Assume psi is 0 here - data[i++] *= sx; - data[i++] *= sy; - - // Start angle - data[i++] += angle; - // end angle - data[i++] += angle; - // FIXME psi - i += 2; - j = i; - break; - case R: - // x0, y0 - p[0] = data[i++]; - p[1] = data[i++]; - v2ApplyTransform(p, p, m); - data[j++] = p[0]; - data[j++] = p[1]; - // x1, y1 - p[0] += data[i++]; - p[1] += data[i++]; - v2ApplyTransform(p, p, m); - data[j++] = p[0]; - data[j++] = p[1]; - } - - for (k = 0; k < nPoint; k++) { - var p = points[k]; - p[0] = data[i++]; - p[1] = data[i++]; - - v2ApplyTransform(p, p, m); - // Write back - data[j++] = p[0]; - data[j++] = p[1]; - } - } - } - - return transformPath; -}); -define('zrender/tool/path',['require','../graphic/Path','../core/PathProxy','./transformPath','../core/matrix'],function (require) { - - var Path = require('../graphic/Path'); - var PathProxy = require('../core/PathProxy'); - var transformPath = require('./transformPath'); - var matrix = require('../core/matrix'); - - // command chars - var cc = [ - 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z', - 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A' - ]; - - var mathSqrt = Math.sqrt; - var mathSin = Math.sin; - var mathCos = Math.cos; - var PI = Math.PI; - - var vMag = function(v) { - return Math.sqrt(v[0] * v[0] + v[1] * v[1]); - }; - var vRatio = function(u, v) { - return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v)); - }; - var vAngle = function(u, v) { - return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) - * Math.acos(vRatio(u, v)); - }; - - function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) { - var psi = psiDeg * (PI / 180.0); - var xp = mathCos(psi) * (x1 - x2) / 2.0 - + mathSin(psi) * (y1 - y2) / 2.0; - var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0 - + mathCos(psi) * (y1 - y2) / 2.0; - - var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry); - - if (lambda > 1) { - rx *= mathSqrt(lambda); - ry *= mathSqrt(lambda); - } - - var f = (fa === fs ? -1 : 1) - * mathSqrt((((rx * rx) * (ry * ry)) - - ((rx * rx) * (yp * yp)) - - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp) - + (ry * ry) * (xp * xp)) - ) || 0; - - var cxp = f * rx * yp / ry; - var cyp = f * -ry * xp / rx; - - var cx = (x1 + x2) / 2.0 - + mathCos(psi) * cxp - - mathSin(psi) * cyp; - var cy = (y1 + y2) / 2.0 - + mathSin(psi) * cxp - + mathCos(psi) * cyp; - - var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]); - var u = [ (xp - cxp) / rx, (yp - cyp) / ry ]; - var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ]; - var dTheta = vAngle(u, v); - - if (vRatio(u, v) <= -1) { - dTheta = PI; - } - if (vRatio(u, v) >= 1) { - dTheta = 0; - } - if (fs === 0 && dTheta > 0) { - dTheta = dTheta - 2 * PI; - } - if (fs === 1 && dTheta < 0) { - dTheta = dTheta + 2 * PI; - } - - path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs); - } - - function createPathProxyFromString(data) { - if (!data) { - return []; - } - - // command string - var cs = data.replace(/-/g, ' -') - .replace(/ /g, ' ') - .replace(/ /g, ',') - .replace(/,,/g, ','); - - var n; - // create pipes so that we can split the data - for (n = 0; n < cc.length; n++) { - cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]); - } - - // create array - var arr = cs.split('|'); - // init context point - var cpx = 0; - var cpy = 0; - - var path = new PathProxy(); - var CMD = PathProxy.CMD; - - var prevCmd; - for (n = 1; n < arr.length; n++) { - var str = arr[n]; - var c = str.charAt(0); - var off = 0; - var p = str.slice(1).replace(/e,-/g, 'e-').split(','); - var cmd; - - if (p.length > 0 && p[0] === '') { - p.shift(); - } - - for (var i = 0; i < p.length; i++) { - p[i] = parseFloat(p[i]); - } - while (off < p.length && !isNaN(p[off])) { - if (isNaN(p[0])) { - break; - } - var ctlPtx; - var ctlPty; - - var rx; - var ry; - var psi; - var fa; - var fs; - - var x1 = cpx; - var y1 = cpy; - - // convert l, H, h, V, and v to L - switch (c) { - case 'l': - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'L': - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'm': - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.M; - path.addData(cmd, cpx, cpy); - c = 'l'; - break; - case 'M': - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.M; - path.addData(cmd, cpx, cpy); - c = 'L'; - break; - case 'h': - cpx += p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'H': - cpx = p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'v': - cpy += p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'V': - cpy = p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'C': - cmd = CMD.C; - path.addData( - cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++] - ); - cpx = p[off - 2]; - cpy = p[off - 1]; - break; - case 'c': - cmd = CMD.C; - path.addData( - cmd, - p[off++] + cpx, p[off++] + cpy, - p[off++] + cpx, p[off++] + cpy, - p[off++] + cpx, p[off++] + cpy - ); - cpx += p[off - 2]; - cpy += p[off - 1]; - break; - case 'S': - ctlPtx = cpx; - ctlPty = cpy; - var len = path.len(); - var pathData = path.data; - if (prevCmd === CMD.C) { - ctlPtx += cpx - pathData[len - 4]; - ctlPty += cpy - pathData[len - 3]; - } - cmd = CMD.C; - x1 = p[off++]; - y1 = p[off++]; - cpx = p[off++]; - cpy = p[off++]; - path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy); - break; - case 's': - ctlPtx = cpx; - ctlPty = cpy; - var len = path.len(); - var pathData = path.data; - if (prevCmd === CMD.C) { - ctlPtx += cpx - pathData[len - 4]; - ctlPty += cpy - pathData[len - 3]; - } - cmd = CMD.C; - x1 = cpx + p[off++]; - y1 = cpy + p[off++]; - cpx += p[off++]; - cpy += p[off++]; - path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy); - break; - case 'Q': - x1 = p[off++]; - y1 = p[off++]; - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.Q; - path.addData(cmd, x1, y1, cpx, cpy); - break; - case 'q': - x1 = p[off++] + cpx; - y1 = p[off++] + cpy; - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.Q; - path.addData(cmd, x1, y1, cpx, cpy); - break; - case 'T': - ctlPtx = cpx; - ctlPty = cpy; - var len = path.len(); - var pathData = path.data; - if (prevCmd === CMD.Q) { - ctlPtx += cpx - pathData[len - 4]; - ctlPty += cpy - pathData[len - 3]; - } - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.Q; - path.addData(cmd, ctlPtx, ctlPty, cpx, cpy); - break; - case 't': - ctlPtx = cpx; - ctlPty = cpy; - var len = path.len(); - var pathData = path.data; - if (prevCmd === CMD.Q) { - ctlPtx += cpx - pathData[len - 4]; - ctlPty += cpy - pathData[len - 3]; - } - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.Q; - path.addData(cmd, ctlPtx, ctlPty, cpx, cpy); - break; - case 'A': - rx = p[off++]; - ry = p[off++]; - psi = p[off++]; - fa = p[off++]; - fs = p[off++]; - - x1 = cpx, y1 = cpy; - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.A; - processArc( - x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path - ); - break; - case 'a': - rx = p[off++]; - ry = p[off++]; - psi = p[off++]; - fa = p[off++]; - fs = p[off++]; - - x1 = cpx, y1 = cpy; - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.A; - processArc( - x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path - ); - break; - } - } - - if (c === 'z' || c === 'Z') { - cmd = CMD.Z; - path.addData(cmd); - } - - prevCmd = cmd; - } - - path.toStatic(); - - return path; - } - - // TODO Optimize double memory cost problem - function createPathOptions(str, opts) { - var pathProxy = createPathProxyFromString(str); - var transform; - opts = opts || {}; - opts.buildPath = function (path) { - path.setData(pathProxy.data); - transform && transformPath(path, transform); - // Svg and vml renderer don't have context - var ctx = path.getContext(); - if (ctx) { - path.rebuildPath(ctx); - } - }; - - opts.applyTransform = function (m) { - if (!transform) { - transform = matrix.create(); - } - matrix.mul(transform, m, transform); - }; - - return opts; - } - - return { - /** - * Create a Path object from path string data - * http://www.w3.org/TR/SVG/paths.html#PathData - * @param {Object} opts Other options - */ - createFromString: function (str, opts) { - return new Path(createPathOptions(str, opts)); - }, - - /** - * Create a Path class from path string data - * @param {string} str - * @param {Object} opts Other options - */ - extendFromString: function (str, opts) { - return Path.extend(createPathOptions(str, opts)); - }, - - /** - * Merge multiple paths - */ - // TODO Apply transform - // TODO stroke dash - // TODO Optimize double memory cost problem - mergePath: function (pathEls, opts) { - var pathList = []; - var len = pathEls.length; - var pathEl; - var i; - for (i = 0; i < len; i++) { - pathEl = pathEls[i]; - if (pathEl.__dirty) { - pathEl.buildPath(pathEl.path, pathEl.shape); - } - pathList.push(pathEl.path); - } - - var pathBundle = new Path(opts); - pathBundle.buildPath = function (path) { - path.appendPath(pathList); - // Svg and vml renderer don't have context - var ctx = path.getContext(); - if (ctx) { - path.rebuildPath(ctx); - } - }; - - return pathBundle; - } - }; -}); -define('zrender/graphic/helper/roundRect',['require'],function (require) { - - return { - buildPath: function (ctx, shape) { - var x = shape.x; - var y = shape.y; - var width = shape.width; - var height = shape.height; - var r = shape.r; - var r1; - var r2; - var r3; - var r4; - - // Convert width and height to positive for better borderRadius - if (width < 0) { - x = x + width; - width = -width; - } - if (height < 0) { - y = y + height; - height = -height; - } - - if (typeof r === 'number') { - r1 = r2 = r3 = r4 = r; - } - else if (r instanceof Array) { - if (r.length === 1) { - r1 = r2 = r3 = r4 = r[0]; - } - else if (r.length === 2) { - r1 = r3 = r[0]; - r2 = r4 = r[1]; - } - else if (r.length === 3) { - r1 = r[0]; - r2 = r4 = r[1]; - r3 = r[2]; - } - else { - r1 = r[0]; - r2 = r[1]; - r3 = r[2]; - r4 = r[3]; - } - } - else { - r1 = r2 = r3 = r4 = 0; - } - - var total; - if (r1 + r2 > width) { - total = r1 + r2; - r1 *= width / total; - r2 *= width / total; - } - if (r3 + r4 > width) { - total = r3 + r4; - r3 *= width / total; - r4 *= width / total; - } - if (r2 + r3 > height) { - total = r2 + r3; - r2 *= height / total; - r3 *= height / total; - } - if (r1 + r4 > height) { - total = r1 + r4; - r1 *= height / total; - r4 *= height / total; - } - ctx.moveTo(x + r1, y); - ctx.lineTo(x + width - r2, y); - r2 !== 0 && ctx.quadraticCurveTo( - x + width, y, x + width, y + r2 - ); - ctx.lineTo(x + width, y + height - r3); - r3 !== 0 && ctx.quadraticCurveTo( - x + width, y + height, x + width - r3, y + height - ); - ctx.lineTo(x + r4, y + height); - r4 !== 0 && ctx.quadraticCurveTo( - x, y + height, x, y + height - r4 - ); - ctx.lineTo(x, y + r1); - r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y); - } - }; -}); -// Simple LRU cache use doubly linked list -// @module zrender/core/LRU -define('zrender/core/LRU',['require'],function(require) { - - /** - * Simple double linked list. Compared with array, it has O(1) remove operation. - * @constructor - */ - var LinkedList = function() { - - /** - * @type {module:zrender/core/LRU~Entry} - */ - this.head = null; - - /** - * @type {module:zrender/core/LRU~Entry} - */ - this.tail = null; - - this._len = 0; - }; - - var linkedListProto = LinkedList.prototype; - /** - * Insert a new value at the tail - * @param {} val - * @return {module:zrender/core/LRU~Entry} - */ - linkedListProto.insert = function(val) { - var entry = new Entry(val); - this.insertEntry(entry); - return entry; - }; - - /** - * Insert an entry at the tail - * @param {module:zrender/core/LRU~Entry} entry - */ - linkedListProto.insertEntry = function(entry) { - if (!this.head) { - this.head = this.tail = entry; - } - else { - this.tail.next = entry; - entry.prev = this.tail; - this.tail = entry; - } - this._len++; - }; - - /** - * Remove entry. - * @param {module:zrender/core/LRU~Entry} entry - */ - linkedListProto.remove = function(entry) { - var prev = entry.prev; - var next = entry.next; - if (prev) { - prev.next = next; - } - else { - // Is head - this.head = next; - } - if (next) { - next.prev = prev; - } - else { - // Is tail - this.tail = prev; - } - entry.next = entry.prev = null; - this._len--; - }; - - /** - * @return {number} - */ - linkedListProto.len = function() { - return this._len; - }; - - /** - * @constructor - * @param {} val - */ - var Entry = function(val) { - /** - * @type {} - */ - this.value = val; - - /** - * @type {module:zrender/core/LRU~Entry} - */ - this.next; - - /** - * @type {module:zrender/core/LRU~Entry} - */ - this.prev; - }; - - /** - * LRU Cache - * @constructor - * @alias module:zrender/core/LRU - */ - var LRU = function(maxSize) { - - this._list = new LinkedList(); - - this._map = {}; - - this._maxSize = maxSize || 10; - }; - - var LRUProto = LRU.prototype; - - /** - * @param {string} key - * @param {} value - */ - LRUProto.put = function(key, value) { - var list = this._list; - var map = this._map; - if (map[key] == null) { - var len = list.len(); - if (len >= this._maxSize && len > 0) { - // Remove the least recently used - var leastUsedEntry = list.head; - list.remove(leastUsedEntry); - delete map[leastUsedEntry.key]; - } - - var entry = list.insert(value); - entry.key = key; - map[key] = entry; - } - }; - - /** - * @param {string} key - * @return {} - */ - LRUProto.get = function(key) { - var entry = this._map[key]; - var list = this._list; - if (entry != null) { - // Put the latest used entry in the tail - if (entry !== list.tail) { - list.remove(entry); - list.insertEntry(entry); - } - - return entry.value; - } - }; - - /** - * Clear the cache - */ - LRUProto.clear = function() { - this._list.clear(); - this._map = {}; - }; - - return LRU; -}); -/** - * Image element - * @module zrender/graphic/Image - */ - -define('zrender/graphic/Image',['require','./Displayable','../core/BoundingRect','../core/util','./helper/roundRect','../core/LRU'],function (require) { - - var Displayable = require('./Displayable'); - var BoundingRect = require('../core/BoundingRect'); - var zrUtil = require('../core/util'); - var roundRectHelper = require('./helper/roundRect'); - - var LRU = require('../core/LRU'); - var globalImageCache = new LRU(50); - /** - * @alias zrender/graphic/Image - * @extends module:zrender/graphic/Displayable - * @constructor - * @param {Object} opts - */ - var ZImage = function (opts) { - Displayable.call(this, opts); - }; - - ZImage.prototype = { - - constructor: ZImage, - - type: 'image', - - brush: function (ctx) { - var style = this.style; - var src = style.image; - var image; - // style.image is a url string - if (typeof src === 'string') { - image = this._image; - } - // style.image is an HTMLImageElement or HTMLCanvasElement or Canvas - else { - image = src; - } - // FIXME Case create many images with src - if (!image && src) { - // Try get from global image cache - var cachedImgObj = globalImageCache.get(src); - if (!cachedImgObj) { - // Create a new image - image = new Image(); - image.onload = function () { - image.onload = null; - for (var i = 0; i < cachedImgObj.pending.length; i++) { - cachedImgObj.pending[i].dirty(); - } - }; - cachedImgObj = { - image: image, - pending: [this] - }; - image.src = src; - globalImageCache.put(src, cachedImgObj); - this._image = image; - return; - } - else { - image = cachedImgObj.image; - this._image = image; - // Image is not complete finish, add to pending list - if (!image.width || !image.height) { - cachedImgObj.pending.push(this); - return; - } - } - } - - if (image) { - // 图片已经加载完成 - // if (image.nodeName.toUpperCase() == 'IMG') { - // if (!image.complete) { - // return; - // } - // } - // Else is canvas - - var width = style.width || image.width; - var height = style.height || image.height; - var x = style.x || 0; - var y = style.y || 0; - // 图片加载失败 - if (!image.width || !image.height) { - return; - } - - ctx.save(); - - style.bind(ctx); - - // 设置transform - this.setTransform(ctx); - - if (style.r) { - // Border radius clipping - // FIXME - ctx.beginPath(); - roundRectHelper.buildPath(ctx, style); - ctx.clip(); - } - - if (style.sWidth && style.sHeight) { - var sx = style.sx || 0; - var sy = style.sy || 0; - ctx.drawImage( - image, - sx, sy, style.sWidth, style.sHeight, - x, y, width, height - ); - } - else if (style.sx && style.sy) { - var sx = style.sx; - var sy = style.sy; - var sWidth = width - sx; - var sHeight = height - sy; - ctx.drawImage( - image, - sx, sy, sWidth, sHeight, - x, y, width, height - ); - } - else { - ctx.drawImage(image, x, y, width, height); - } - - // 如果没设置宽和高的话自动根据图片宽高设置 - if (style.width == null) { - style.width = width; - } - if (style.height == null) { - style.height = height; - } - - // Draw rect text - if (style.text != null) { - this.drawRectText(ctx, this.getBoundingRect()); - } - - ctx.restore(); - } - }, - - getBoundingRect: function () { - var style = this.style; - if (! this._rect) { - this._rect = new BoundingRect( - style.x || 0, style.y || 0, style.width || 0, style.height || 0 - ); - } - return this._rect; - } - }; - - zrUtil.inherits(ZImage, Displayable); - - return ZImage; -}); -/** - * Text element - * @module zrender/graphic/Text - * - * TODO Wrapping - */ - -define('zrender/graphic/Text',['require','./Displayable','../core/util','../contain/text'],function (require) { - - var Displayable = require('./Displayable'); - var zrUtil = require('../core/util'); - var textContain = require('../contain/text'); - - /** - * @alias zrender/graphic/Text - * @extends module:zrender/graphic/Displayable - * @constructor - * @param {Object} opts - */ - var Text = function (opts) { - Displayable.call(this, opts); - }; - - Text.prototype = { - - constructor: Text, - - type: 'text', - - brush: function (ctx) { - var style = this.style; - var x = style.x || 0; - var y = style.y || 0; - // Convert to string - var text = style.text; - var textFill = style.fill; - var textStroke = style.stroke; - - // Convert to string - text != null && (text += ''); - - if (text) { - ctx.save(); - - this.style.bind(ctx); - this.setTransform(ctx); - - textFill && (ctx.fillStyle = textFill); - textStroke && (ctx.strokeStyle = textStroke); - - ctx.font = style.textFont || style.font; - ctx.textAlign = style.textAlign; - ctx.textBaseline = style.textBaseline; - - var lineHeight = textContain.measureText('国', ctx.font).width; - - var textLines = text.split('\n'); - for (var i = 0; i < textLines.length; i++) { - textFill && ctx.fillText(textLines[i], x, y); - textStroke && ctx.strokeText(textLines[i], x, y); - y += lineHeight; - } - - ctx.restore(); - } - }, - - getBoundingRect: function () { - if (!this._rect) { - var style = this.style; - var rect = textContain.getBoundingRect( - style.text + '', style.textFont, style.textAlign, style.textBaseline - ); - rect.x += style.x || 0; - rect.y += style.y || 0; - this._rect = rect; - } - return this._rect; - } - }; - - zrUtil.inherits(Text, Displayable); - - return Text; -}); -/** - * 圆形 - * @module zrender/shape/Circle - */ - -define('zrender/graphic/shape/Circle',['require','../Path'],function (require) { - - - return require('../Path').extend({ - - type: 'circle', - - shape: { - cx: 0, - cy: 0, - r: 0 - }, - - buildPath : function (ctx, shape) { - // Better stroking in ShapeBundle - ctx.moveTo(shape.cx + shape.r, shape.cy); - ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true); - return; - } - }); -}); +/***/ }, +/* 65 */ +/***/ function(module, exports, __webpack_require__) { -/** - * 扇形 - * @module zrender/graphic/shape/Sector - */ + /** + * 圆环 + * @module zrender/graphic/shape/Ring + */ -// FIXME clockwise seems wrong -define('zrender/graphic/shape/Sector',['require','../Path'],function (require) { - return require('../Path').extend({ + module.exports = __webpack_require__(44).extend({ - type: 'sector', + type: 'ring', - shape: { + shape: { + cx: 0, + cy: 0, + r: 0, + r0: 0 + }, - cx: 0, + buildPath: function (ctx, shape) { + var x = shape.cx; + var y = shape.cy; + var PI2 = Math.PI * 2; + ctx.moveTo(x + shape.r, y); + ctx.arc(x, y, shape.r, 0, PI2, false); + ctx.moveTo(x + shape.r0, y); + ctx.arc(x, y, shape.r0, 0, PI2, true); + } + }); - cy: 0, - r0: 0, - r: 0, +/***/ }, +/* 66 */ +/***/ function(module, exports, __webpack_require__) { - startAngle: 0, + /** + * 多边形 + * @module zrender/shape/Polygon + */ - endAngle: Math.PI * 2, - clockwise: true - }, + var polyHelper = __webpack_require__(67); - buildPath: function (ctx, shape) { + module.exports = __webpack_require__(44).extend({ + + type: 'polygon', - var x = shape.cx; - var y = shape.cy; - var r0 = Math.max(shape.r0 || 0, 0); - var r = Math.max(shape.r, 0); - var startAngle = shape.startAngle; - var endAngle = shape.endAngle; - var clockwise = shape.clockwise; + shape: { + points: null, - var unitX = Math.cos(startAngle); - var unitY = Math.sin(startAngle); + smooth: false, - ctx.moveTo(unitX * r0 + x, unitY * r0 + y); + smoothConstraint: null + }, + + buildPath: function (ctx, shape) { + polyHelper.buildPath(ctx, shape, true); + } + }); + + +/***/ }, +/* 67 */ +/***/ function(module, exports, __webpack_require__) { + + + + var smoothSpline = __webpack_require__(68); + var smoothBezier = __webpack_require__(69); + + module.exports = { + buildPath: function (ctx, shape, closePath) { + var points = shape.points; + var smooth = shape.smooth; + if (points && points.length >= 2) { + if (smooth && smooth !== 'spline') { + var controlPoints = smoothBezier( + points, smooth, closePath, shape.smoothConstraint + ); + + ctx.moveTo(points[0][0], points[0][1]); + var len = points.length; + for (var i = 0; i < (closePath ? len : len - 1); i++) { + var cp1 = controlPoints[i * 2]; + var cp2 = controlPoints[i * 2 + 1]; + var p = points[(i + 1) % len]; + ctx.bezierCurveTo( + cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1] + ); + } + } + else { + if (smooth === 'spline') { + points = smoothSpline(points, closePath); + } + + ctx.moveTo(points[0][0], points[0][1]); + for (var i = 1, l = points.length; i < l; i++) { + ctx.lineTo(points[i][0], points[i][1]); + } + } + + closePath && ctx.closePath(); + } + } + }; + + +/***/ }, +/* 68 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Catmull-Rom spline 插值折线 + * @module zrender/shape/util/smoothSpline + * @author pissang (https://www.github.com/pissang) + * Kener (@Kener-林峰, kener.linfeng@gmail.com) + * errorrik (errorrik@gmail.com) + */ + + var vec2 = __webpack_require__(16); + + /** + * @inner + */ + function interpolate(p0, p1, p2, p3, t, t2, t3) { + var v0 = (p2 - p0) * 0.5; + var v1 = (p3 - p1) * 0.5; + return (2 * (p1 - p2) + v0 + v1) * t3 + + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + + v0 * t + p1; + } + + /** + * @alias module:zrender/shape/util/smoothSpline + * @param {Array} points 线段顶点数组 + * @param {boolean} isLoop + * @return {Array} + */ + module.exports = function (points, isLoop) { + var len = points.length; + var ret = []; + + var distance = 0; + for (var i = 1; i < len; i++) { + distance += vec2.distance(points[i - 1], points[i]); + } + + var segs = distance / 2; + segs = segs < len ? len : segs; + for (var i = 0; i < segs; i++) { + var pos = i / (segs - 1) * (isLoop ? len : len - 1); + var idx = Math.floor(pos); + + var w = pos - idx; + + var p0; + var p1 = points[idx % len]; + var p2; + var p3; + if (!isLoop) { + p0 = points[idx === 0 ? idx : idx - 1]; + p2 = points[idx > len - 2 ? len - 1 : idx + 1]; + p3 = points[idx > len - 3 ? len - 1 : idx + 2]; + } + else { + p0 = points[(idx - 1 + len) % len]; + p2 = points[(idx + 1) % len]; + p3 = points[(idx + 2) % len]; + } + + var w2 = w * w; + var w3 = w * w2; + + ret.push([ + interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3), + interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3) + ]); + } + return ret; + }; + + + +/***/ }, +/* 69 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 贝塞尔平滑曲线 + * @module zrender/shape/util/smoothBezier + * @author pissang (https://www.github.com/pissang) + * Kener (@Kener-林峰, kener.linfeng@gmail.com) + * errorrik (errorrik@gmail.com) + */ + + + var vec2 = __webpack_require__(16); + var v2Min = vec2.min; + var v2Max = vec2.max; + var v2Scale = vec2.scale; + var v2Distance = vec2.distance; + var v2Add = vec2.add; + + /** + * 贝塞尔平滑曲线 + * @alias module:zrender/shape/util/smoothBezier + * @param {Array} points 线段顶点数组 + * @param {number} smooth 平滑等级, 0-1 + * @param {boolean} isLoop + * @param {Array} constraint 将计算出来的控制点约束在一个包围盒内 + * 比如 [[0, 0], [100, 100]], 这个包围盒会与 + * 整个折线的包围盒做一个并集用来约束控制点。 + * @param {Array} 计算出来的控制点数组 + */ + module.exports = function (points, smooth, isLoop, constraint) { + var cps = []; + + var v = []; + var v1 = []; + var v2 = []; + var prevPoint; + var nextPoint; + + var min, max; + if (constraint) { + min = [Infinity, Infinity]; + max = [-Infinity, -Infinity]; + for (var i = 0, len = points.length; i < len; i++) { + v2Min(min, min, points[i]); + v2Max(max, max, points[i]); + } + // 与指定的包围盒做并集 + v2Min(min, min, constraint[0]); + v2Max(max, max, constraint[1]); + } + + for (var i = 0, len = points.length; i < len; i++) { + var point = points[i]; + + if (isLoop) { + prevPoint = points[i ? i - 1 : len - 1]; + nextPoint = points[(i + 1) % len]; + } + else { + if (i === 0 || i === len - 1) { + cps.push(vec2.clone(points[i])); + continue; + } + else { + prevPoint = points[i - 1]; + nextPoint = points[i + 1]; + } + } + + vec2.sub(v, nextPoint, prevPoint); + + // use degree to scale the handle length + v2Scale(v, v, smooth); + + var d0 = v2Distance(point, prevPoint); + var d1 = v2Distance(point, nextPoint); + var sum = d0 + d1; + if (sum !== 0) { + d0 /= sum; + d1 /= sum; + } + + v2Scale(v1, v, -d0); + v2Scale(v2, v, d1); + var cp0 = v2Add([], point, v1); + var cp1 = v2Add([], point, v2); + if (constraint) { + v2Max(cp0, cp0, min); + v2Min(cp0, cp0, max); + v2Max(cp1, cp1, min); + v2Min(cp1, cp1, max); + } + cps.push(cp0); + cps.push(cp1); + } + + if (isLoop) { + cps.push(cps.shift()); + } + + return cps; + }; + + + +/***/ }, +/* 70 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module zrender/graphic/shape/Polyline + */ + + + var polyHelper = __webpack_require__(67); + + module.exports = __webpack_require__(44).extend({ + + type: 'polyline', + + shape: { + points: null, + + smooth: false, + + smoothConstraint: null + }, + + style: { + stroke: '#000', + + fill: null + }, + + buildPath: function (ctx, shape) { + polyHelper.buildPath(ctx, shape, false); + } + }); + + +/***/ }, +/* 71 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 矩形 + * @module zrender/graphic/shape/Rect + */ + + + var roundRectHelper = __webpack_require__(60); + + module.exports = __webpack_require__(44).extend({ + + type: 'rect', + + shape: { + // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4 + // r缩写为1 相当于 [1, 1, 1, 1] + // r缩写为[1] 相当于 [1, 1, 1, 1] + // r缩写为[1, 2] 相当于 [1, 2, 1, 2] + // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2] + r: 0, + + x: 0, + y: 0, + width: 0, + height: 0 + }, + + buildPath: function (ctx, shape) { + var x = shape.x; + var y = shape.y; + var width = shape.width; + var height = shape.height; + if (!shape.r) { + ctx.rect(x, y, width, height); + } + else { + roundRectHelper.buildPath(ctx, shape); + } + ctx.closePath(); + return; + } + }); + + + +/***/ }, +/* 72 */ +/***/ function(module, exports, __webpack_require__) { - ctx.lineTo(unitX * r + x, unitY * r + y); + /** + * 直线 + * @module zrender/graphic/shape/Line + */ - ctx.arc(x, y, r, startAngle, endAngle, !clockwise); + module.exports = __webpack_require__(44).extend({ - ctx.lineTo( - Math.cos(endAngle) * r0 + x, - Math.sin(endAngle) * r0 + y - ); + type: 'line', + + shape: { + // Start point + x1: 0, + y1: 0, + // End point + x2: 0, + y2: 0, + + percent: 1 + }, + + style: { + stroke: '#000', + fill: null + }, + + buildPath: function (ctx, shape) { + var x1 = shape.x1; + var y1 = shape.y1; + var x2 = shape.x2; + var y2 = shape.y2; + var percent = shape.percent; + + if (percent === 0) { + return; + } + + ctx.moveTo(x1, y1); + + if (percent < 1) { + x2 = x1 * (1 - percent) + x2 * percent; + y2 = y1 * (1 - percent) + y2 * percent; + } + ctx.lineTo(x2, y2); + }, + + /** + * Get point at percent + * @param {number} percent + * @return {Array.} + */ + pointAt: function (p) { + var shape = this.shape; + return [ + shape.x1 * (1 - p) + shape.x2 * p, + shape.y1 * (1 - p) + shape.y2 * p + ]; + } + }); + + + +/***/ }, +/* 73 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 贝塞尔曲线 + * @module zrender/shape/BezierCurve + */ + + + var curveTool = __webpack_require__(49); + var quadraticSubdivide = curveTool.quadraticSubdivide; + var cubicSubdivide = curveTool.cubicSubdivide; + var quadraticAt = curveTool.quadraticAt; + var cubicAt = curveTool.cubicAt; + + var out = []; + module.exports = __webpack_require__(44).extend({ + + type: 'bezier-curve', + + shape: { + x1: 0, + y1: 0, + x2: 0, + y2: 0, + cpx1: 0, + cpy1: 0, + // cpx2: 0, + // cpy2: 0 + + // Curve show percent, for animating + percent: 1 + }, + + style: { + stroke: '#000', + fill: null + }, + + buildPath: function (ctx, shape) { + var x1 = shape.x1; + var y1 = shape.y1; + var x2 = shape.x2; + var y2 = shape.y2; + var cpx1 = shape.cpx1; + var cpy1 = shape.cpy1; + var cpx2 = shape.cpx2; + var cpy2 = shape.cpy2; + var percent = shape.percent; + if (percent === 0) { + return; + } + + ctx.moveTo(x1, y1); + + if (cpx2 == null || cpy2 == null) { + if (percent < 1) { + quadraticSubdivide( + x1, cpx1, x2, percent, out + ); + cpx1 = out[1]; + x2 = out[2]; + quadraticSubdivide( + y1, cpy1, y2, percent, out + ); + cpy1 = out[1]; + y2 = out[2]; + } + + ctx.quadraticCurveTo( + cpx1, cpy1, + x2, y2 + ); + } + else { + if (percent < 1) { + cubicSubdivide( + x1, cpx1, cpx2, x2, percent, out + ); + cpx1 = out[1]; + cpx2 = out[2]; + x2 = out[3]; + cubicSubdivide( + y1, cpy1, cpy2, y2, percent, out + ); + cpy1 = out[1]; + cpy2 = out[2]; + y2 = out[3]; + } + ctx.bezierCurveTo( + cpx1, cpy1, + cpx2, cpy2, + x2, y2 + ); + } + }, + + /** + * Get point at percent + * @param {number} percent + * @return {Array.} + */ + pointAt: function (p) { + var shape = this.shape; + var cpx2 = shape.cpx2; + var cpy2 = shape.cpy2; + if (cpx2 === null || cpy2 === null) { + return [ + quadraticAt(shape.x1, shape.cpx1, shape.x2, p), + quadraticAt(shape.y1, shape.cpy1, shape.y2, p) + ]; + } + else { + return [ + cubicAt(shape.x1, shape.cpx1, shape.cpx1, shape.x2, p), + cubicAt(shape.y1, shape.cpy1, shape.cpy1, shape.y2, p) + ]; + } + } + }); + + + +/***/ }, +/* 74 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 圆弧 + * @module zrender/graphic/shape/Arc + */ + + + module.exports = __webpack_require__(44).extend({ + + type: 'arc', + + shape: { + + cx: 0, + + cy: 0, + + r: 0, + + startAngle: 0, + + endAngle: Math.PI * 2, - if (r0 !== 0) { - ctx.arc(x, y, r0, endAngle, startAngle, clockwise); - } + clockwise: true + }, - ctx.closePath(); - } - }); -}); + style: { -/** - * Catmull-Rom spline 插值折线 - * @module zrender/shape/util/smoothSpline - * @author pissang (https://www.github.com/pissang) - * Kener (@Kener-林峰, kener.linfeng@gmail.com) - * errorrik (errorrik@gmail.com) - */ -define('zrender/graphic/helper/smoothSpline',['require','../../core/vector'],function (require) { - var vec2 = require('../../core/vector'); - - /** - * @inner - */ - function interpolate(p0, p1, p2, p3, t, t2, t3) { - var v0 = (p2 - p0) * 0.5; - var v1 = (p3 - p1) * 0.5; - return (2 * (p1 - p2) + v0 + v1) * t3 - + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 - + v0 * t + p1; - } - - /** - * @alias module:zrender/shape/util/smoothSpline - * @param {Array} points 线段顶点数组 - * @param {boolean} isLoop - * @return {Array} - */ - return function (points, isLoop) { - var len = points.length; - var ret = []; - - var distance = 0; - for (var i = 1; i < len; i++) { - distance += vec2.distance(points[i - 1], points[i]); - } - - var segs = distance / 2; - segs = segs < len ? len : segs; - for (var i = 0; i < segs; i++) { - var pos = i / (segs - 1) * (isLoop ? len : len - 1); - var idx = Math.floor(pos); - - var w = pos - idx; - - var p0; - var p1 = points[idx % len]; - var p2; - var p3; - if (!isLoop) { - p0 = points[idx === 0 ? idx : idx - 1]; - p2 = points[idx > len - 2 ? len - 1 : idx + 1]; - p3 = points[idx > len - 3 ? len - 1 : idx + 2]; - } - else { - p0 = points[(idx - 1 + len) % len]; - p2 = points[(idx + 1) % len]; - p3 = points[(idx + 2) % len]; - } - - var w2 = w * w; - var w3 = w * w2; - - ret.push([ - interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3), - interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3) - ]); - } - return ret; - }; -}); + stroke: '#000', -/** - * 贝塞尔平滑曲线 - * @module zrender/shape/util/smoothBezier - * @author pissang (https://www.github.com/pissang) - * Kener (@Kener-林峰, kener.linfeng@gmail.com) - * errorrik (errorrik@gmail.com) - */ -define('zrender/graphic/helper/smoothBezier',['require','../../core/vector'],function (require) { - - var vec2 = require('../../core/vector'); - var v2Min = vec2.min; - var v2Max = vec2.max; - var v2Scale = vec2.scale; - var v2Distance = vec2.distance; - var v2Add = vec2.add; - - /** - * 贝塞尔平滑曲线 - * @alias module:zrender/shape/util/smoothBezier - * @param {Array} points 线段顶点数组 - * @param {number} smooth 平滑等级, 0-1 - * @param {boolean} isLoop - * @param {Array} constraint 将计算出来的控制点约束在一个包围盒内 - * 比如 [[0, 0], [100, 100]], 这个包围盒会与 - * 整个折线的包围盒做一个并集用来约束控制点。 - * @param {Array} 计算出来的控制点数组 - */ - return function (points, smooth, isLoop, constraint) { - var cps = []; - - var v = []; - var v1 = []; - var v2 = []; - var prevPoint; - var nextPoint; - - var min, max; - if (constraint) { - min = [Infinity, Infinity]; - max = [-Infinity, -Infinity]; - for (var i = 0, len = points.length; i < len; i++) { - v2Min(min, min, points[i]); - v2Max(max, max, points[i]); - } - // 与指定的包围盒做并集 - v2Min(min, min, constraint[0]); - v2Max(max, max, constraint[1]); - } - - for (var i = 0, len = points.length; i < len; i++) { - var point = points[i]; - - if (isLoop) { - prevPoint = points[i ? i - 1 : len - 1]; - nextPoint = points[(i + 1) % len]; - } - else { - if (i === 0 || i === len - 1) { - cps.push(vec2.clone(points[i])); - continue; - } - else { - prevPoint = points[i - 1]; - nextPoint = points[i + 1]; - } - } - - vec2.sub(v, nextPoint, prevPoint); - - // use degree to scale the handle length - v2Scale(v, v, smooth); - - var d0 = v2Distance(point, prevPoint); - var d1 = v2Distance(point, nextPoint); - var sum = d0 + d1; - if (sum !== 0) { - d0 /= sum; - d1 /= sum; - } - - v2Scale(v1, v, -d0); - v2Scale(v2, v, d1); - var cp0 = v2Add([], point, v1); - var cp1 = v2Add([], point, v2); - if (constraint) { - v2Max(cp0, cp0, min); - v2Min(cp0, cp0, max); - v2Max(cp1, cp1, min); - v2Min(cp1, cp1, max); - } - cps.push(cp0); - cps.push(cp1); - } - - if (isLoop) { - cps.push(cps.shift()); - } - - return cps; - }; -}); + fill: null + }, -define('zrender/graphic/helper/poly',['require','./smoothSpline','./smoothBezier'],function (require) { - - var smoothSpline = require('./smoothSpline'); - var smoothBezier = require('./smoothBezier'); - - return { - buildPath: function (ctx, shape, closePath) { - var points = shape.points; - var smooth = shape.smooth; - if (points && points.length >= 2) { - if (smooth && smooth !== 'spline') { - var controlPoints = smoothBezier( - points, smooth, closePath, shape.smoothConstraint - ); - - ctx.moveTo(points[0][0], points[0][1]); - var len = points.length; - for (var i = 0; i < (closePath ? len : len - 1); i++) { - var cp1 = controlPoints[i * 2]; - var cp2 = controlPoints[i * 2 + 1]; - var p = points[(i + 1) % len]; - ctx.bezierCurveTo( - cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1] - ); - } - } - else { - if (smooth === 'spline') { - points = smoothSpline(points, closePath); - } - - ctx.moveTo(points[0][0], points[0][1]); - for (var i = 1, l = points.length; i < l; i++) { - ctx.lineTo(points[i][0], points[i][1]); - } - } - - closePath && ctx.closePath(); - } - } - }; -}); -/** - * 多边形 - * @module zrender/shape/Polygon - */ -define('zrender/graphic/shape/Polygon',['require','../helper/poly','../Path'],function (require) { + buildPath: function (ctx, shape) { - var polyHelper = require('../helper/poly'); + var x = shape.cx; + var y = shape.cy; + var r = Math.max(shape.r, 0); + var startAngle = shape.startAngle; + var endAngle = shape.endAngle; + var clockwise = shape.clockwise; - return require('../Path').extend({ - - type: 'polygon', + var unitX = Math.cos(startAngle); + var unitY = Math.sin(startAngle); - shape: { - points: null, + ctx.moveTo(unitX * r + x, unitY * r + y); + ctx.arc(x, y, r, startAngle, endAngle, !clockwise); + } + }); - smooth: false, - smoothConstraint: null - }, +/***/ }, +/* 75 */ +/***/ function(module, exports, __webpack_require__) { - buildPath: function (ctx, shape) { - polyHelper.buildPath(ctx, shape, true); - } - }); -}); -/** - * @module zrender/graphic/shape/Polyline - */ -define('zrender/graphic/shape/Polyline',['require','../helper/poly','../Path'],function (require) { + 'use strict'; - var polyHelper = require('../helper/poly'); - return require('../Path').extend({ - - type: 'polyline', + var zrUtil = __webpack_require__(3); - shape: { - points: null, + var Gradient = __webpack_require__(4); - smooth: false, + /** + * x, y, x2, y2 are all percent from 0 to 1 + * @param {number} [x=0] + * @param {number} [y=0] + * @param {number} [x2=1] + * @param {number} [y2=0] + * @param {Array.} colorStops + */ + var LinearGradient = function (x, y, x2, y2, colorStops) { + this.x = x == null ? 0 : x; - smoothConstraint: null - }, + this.y = y == null ? 0 : y; - style: { - stroke: '#000', + this.x2 = x2 == null ? 1 : x2; - fill: null - }, + this.y2 = y2 == null ? 0 : y2; - buildPath: function (ctx, shape) { - polyHelper.buildPath(ctx, shape, false); - } - }); -}); -/** - * 矩形 - * @module zrender/graphic/shape/Rect - */ - -define('zrender/graphic/shape/Rect',['require','../helper/roundRect','../Path'],function (require) { - var roundRectHelper = require('../helper/roundRect'); - - return require('../Path').extend({ - - type: 'rect', - - shape: { - // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4 - // r缩写为1 相当于 [1, 1, 1, 1] - // r缩写为[1] 相当于 [1, 1, 1, 1] - // r缩写为[1, 2] 相当于 [1, 2, 1, 2] - // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2] - r: 0, - - x: 0, - y: 0, - width: 0, - height: 0 - }, - - buildPath: function (ctx, shape) { - var x = shape.x; - var y = shape.y; - var width = shape.width; - var height = shape.height; - if (!shape.r) { - ctx.rect(x, y, width, height); - } - else { - roundRectHelper.buildPath(ctx, shape); - } - ctx.closePath(); - return; - } - }); -}); + Gradient.call(this, colorStops); + }; -/** - * 直线 - * @module zrender/graphic/shape/Line - */ -define('zrender/graphic/shape/Line',['require','../Path'],function (require) { - return require('../Path').extend({ - - type: 'line', - - shape: { - // Start point - x1: 0, - y1: 0, - // End point - x2: 0, - y2: 0, - - percent: 1 - }, - - style: { - stroke: '#000', - fill: null - }, - - buildPath: function (ctx, shape) { - var x1 = shape.x1; - var y1 = shape.y1; - var x2 = shape.x2; - var y2 = shape.y2; - var percent = shape.percent; - - if (percent === 0) { - return; - } - - ctx.moveTo(x1, y1); - - if (percent < 1) { - x2 = x1 * (1 - percent) + x2 * percent; - y2 = y1 * (1 - percent) + y2 * percent; - } - ctx.lineTo(x2, y2); - }, - - /** - * Get point at percent - * @param {number} percent - * @return {Array.} - */ - pointAt: function (p) { - var shape = this.shape; - return [ - shape.x1 * (1 - p) + shape.x2 * p, - shape.y1 * (1 - p) + shape.y2 * p - ]; - } - }); -}); + LinearGradient.prototype = { -/** - * 贝塞尔曲线 - * @module zrender/shape/BezierCurve - */ -define('zrender/graphic/shape/BezierCurve',['require','../../core/curve','../Path'],function (require) { - - - var curveTool = require('../../core/curve'); - var quadraticSubdivide = curveTool.quadraticSubdivide; - var cubicSubdivide = curveTool.cubicSubdivide; - var quadraticAt = curveTool.quadraticAt; - var cubicAt = curveTool.cubicAt; - - var out = []; - return require('../Path').extend({ - - type: 'bezier-curve', - - shape: { - x1: 0, - y1: 0, - x2: 0, - y2: 0, - cpx1: 0, - cpy1: 0, - // cpx2: 0, - // cpy2: 0 - - // Curve show percent, for animating - percent: 1 - }, - - style: { - stroke: '#000', - fill: null - }, - - buildPath: function (ctx, shape) { - var x1 = shape.x1; - var y1 = shape.y1; - var x2 = shape.x2; - var y2 = shape.y2; - var cpx1 = shape.cpx1; - var cpy1 = shape.cpy1; - var cpx2 = shape.cpx2; - var cpy2 = shape.cpy2; - var percent = shape.percent; - if (percent === 0) { - return; - } - - ctx.moveTo(x1, y1); - - if (cpx2 == null || cpy2 == null) { - if (percent < 1) { - quadraticSubdivide( - x1, cpx1, x2, percent, out - ); - cpx1 = out[1]; - x2 = out[2]; - quadraticSubdivide( - y1, cpy1, y2, percent, out - ); - cpy1 = out[1]; - y2 = out[2]; - } - - ctx.quadraticCurveTo( - cpx1, cpy1, - x2, y2 - ); - } - else { - if (percent < 1) { - cubicSubdivide( - x1, cpx1, cpx2, x2, percent, out - ); - cpx1 = out[1]; - cpx2 = out[2]; - x2 = out[3]; - cubicSubdivide( - y1, cpy1, cpy2, y2, percent, out - ); - cpy1 = out[1]; - cpy2 = out[2]; - y2 = out[3]; - } - ctx.bezierCurveTo( - cpx1, cpy1, - cpx2, cpy2, - x2, y2 - ); - } - }, - - /** - * Get point at percent - * @param {number} percent - * @return {Array.} - */ - pointAt: function (p) { - var shape = this.shape; - var cpx2 = shape.cpx2; - var cpy2 = shape.cpy2; - if (cpx2 === null || cpy2 === null) { - return [ - quadraticAt(shape.x1, shape.cpx1, shape.x2, p), - quadraticAt(shape.y1, shape.cpy1, shape.y2, p) - ]; - } - else { - return [ - cubicAt(shape.x1, shape.cpx1, shape.cpx1, shape.x2, p), - cubicAt(shape.y1, shape.cpy1, shape.cpy1, shape.y2, p) - ]; - } - } - }); -}); + constructor: LinearGradient, -/** - * 圆弧 - * @module zrender/graphic/shape/Arc - */ - define('zrender/graphic/shape/Arc',['require','../Path'],function (require) { + type: 'linear', - return require('../Path').extend({ + updateCanvasGradient: function (shape, ctx) { + var rect = shape.getBoundingRect(); + // var size = + var x = this.x * rect.width + rect.x; + var x2 = this.x2 * rect.width + rect.x; + var y = this.y * rect.height + rect.y; + var y2 = this.y2 * rect.height + rect.y; - type: 'arc', + var canvasGradient = ctx.createLinearGradient(x, y, x2, y2); - shape: { + var colorStops = this.colorStops; + for (var i = 0; i < colorStops.length; i++) { + canvasGradient.addColorStop( + colorStops[i].offset, colorStops[i].color + ); + } - cx: 0, + this.canvasGradient = canvasGradient; + } - cy: 0, + }; - r: 0, + zrUtil.inherits(LinearGradient, Gradient); - startAngle: 0, + module.exports = LinearGradient; - endAngle: Math.PI * 2, - clockwise: true - }, +/***/ }, +/* 76 */ +/***/ function(module, exports, __webpack_require__) { - style: { + 'use strict'; - stroke: '#000', - fill: null - }, + var zrUtil = __webpack_require__(3); - buildPath: function (ctx, shape) { + var Gradient = __webpack_require__(4); - var x = shape.cx; - var y = shape.cy; - var r = Math.max(shape.r, 0); - var startAngle = shape.startAngle; - var endAngle = shape.endAngle; - var clockwise = shape.clockwise; + /** + * x, y, r are all percent from 0 to 1 + * @param {number} [x=0.5] + * @param {number} [y=0.5] + * @param {number} [r=0.5] + * @param {Array.} [colorStops] + */ + var RadialGradient = function (x, y, r, colorStops) { + this.x = x == null ? 0.5 : x; - var unitX = Math.cos(startAngle); - var unitY = Math.sin(startAngle); + this.y = y == null ? 0.5 : y; - ctx.moveTo(unitX * r + x, unitY * r + y); - ctx.arc(x, y, r, startAngle, endAngle, !clockwise); - } - }); -}); -define('zrender/graphic/LinearGradient',['require','../core/util','./Gradient'],function(require) { - + this.r = r == null ? 0.5 : r; - var zrUtil = require('../core/util'); + Gradient.call(this, colorStops); + }; - var Gradient = require('./Gradient'); + RadialGradient.prototype = { - /** - * x, y, x2, y2 are all percent from 0 to 1 - * @param {number} [x=0] - * @param {number} [y=0] - * @param {number} [x2=1] - * @param {number} [y2=0] - * @param {Array.} colorStops - */ - var LinearGradient = function (x, y, x2, y2, colorStops) { - this.x = x == null ? 0 : x; + constructor: RadialGradient, - this.y = y == null ? 0 : y; + type: 'radial', - this.x2 = x2 == null ? 1 : x2; + updateCanvasGradient: function (shape, ctx) { + var rect = shape.getBoundingRect(); - this.y2 = y2 == null ? 0 : y2; + var width = rect.width; + var height = rect.height; + var min = Math.min(width, height); + // var max = Math.max(width, height); - Gradient.call(this, colorStops); - }; + var x = this.x * width + rect.x; + var y = this.y * height + rect.y; + var r = this.r * min; - LinearGradient.prototype = { + var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r); - constructor: LinearGradient, + var colorStops = this.colorStops; + for (var i = 0; i < colorStops.length; i++) { + canvasGradient.addColorStop( + colorStops[i].offset, colorStops[i].color + ); + } - type: 'linear', + this.canvasGradient = canvasGradient; + } + }; + + zrUtil.inherits(RadialGradient, Gradient); + + module.exports = RadialGradient; - updateCanvasGradient: function (shape, ctx) { - var rect = shape.getBoundingRect(); - // var size = - var x = this.x * rect.width + rect.x; - var x2 = this.x2 * rect.width + rect.x; - var y = this.y * rect.height + rect.y; - var y2 = this.y2 * rect.height + rect.y; - var canvasGradient = ctx.createLinearGradient(x, y, x2, y2); +/***/ }, +/* 77 */ +/***/ function(module, exports, __webpack_require__) { + + /*! + * ZRender, a high performance 2d drawing library. + * + * Copyright (c) 2013, Baidu Inc. + * All rights reserved. + * + * LICENSE + * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt + */ + // Global defines + + var guid = __webpack_require__(31); + var env = __webpack_require__(78); + + var Handler = __webpack_require__(79); + var Storage = __webpack_require__(83); + var Animation = __webpack_require__(84); + + var useVML = !env.canvasSupported; + + var painterCtors = { + canvas: __webpack_require__(85) + }; + + var instances = {}; // ZRender实例map索引 + + var zrender = {}; + /** + * @type {string} + */ + zrender.version = '3.0.4'; + + /** + * @param {HTMLElement} dom + * @param {Object} opts + * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg' + * @param {number} [opts.devicePixelRatio] + * @return {module:zrender/ZRender} + */ + zrender.init = function(dom, opts) { + var zr = new ZRender(guid(), dom, opts); + instances[zr.id] = zr; + return zr; + }; + + /** + * Dispose zrender instance + * @param {module:zrender/ZRender} zr + */ + zrender.dispose = function (zr) { + if (zr) { + zr.dispose(); + } + else { + for (var key in instances) { + instances[key].dispose(); + } + instances = {}; + } + + return zrender; + }; + + /** + * 获取zrender实例 + * @param {string} id ZRender对象索引 + * @return {module:zrender/ZRender} + */ + zrender.getInstance = function (id) { + return instances[id]; + }; + + zrender.registerPainter = function (name, Ctor) { + painterCtors[name] = Ctor; + }; + + function delInstance(id) { + delete instances[id]; + } + + /** + * @module zrender/ZRender + */ + /** + * @constructor + * @alias module:zrender/ZRender + * @param {string} id + * @param {HTMLDomElement} dom + * @param {Object} opts + * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg' + * @param {number} [opts.devicePixelRatio] + */ + var ZRender = function(id, dom, opts) { + + opts = opts || {}; + + /** + * @type {HTMLDomElement} + */ + this.dom = dom; + + /** + * @type {string} + */ + this.id = id; + + var self = this; + var storage = new Storage(); + + var rendererType = opts.renderer; + if (useVML) { + if (!painterCtors.vml) { + throw new Error('You need to require \'zrender/vml/vml\' to support IE8'); + } + rendererType = 'vml'; + } + else if (!rendererType || !painterCtors[rendererType]) { + rendererType = 'canvas'; + } + var painter = new painterCtors[rendererType](dom, storage, opts); + + this.storage = storage; + this.painter = painter; + if (!env.node) { + this.handler = new Handler(painter.getViewportRoot(), storage, painter); + } + + /** + * @type {module:zrender/animation/Animation} + */ + this.animation = new Animation({ + stage: { + update: function () { + if (self._needsRefresh) { + self.refreshImmediately(); + } + } + } + }); + this.animation.start(); + + /** + * @type {boolean} + * @private + */ + this._needsRefresh; + + // 修改 storage.delFromMap, 每次删除元素之前删除动画 + // FIXME 有点ugly + var oldDelFromMap = storage.delFromMap; + var oldAddToMap = storage.addToMap; + + storage.delFromMap = function (elId) { + var el = storage.get(elId); + + oldDelFromMap.call(storage, elId); + + el && el.removeSelfFromZr(self); + }; + + storage.addToMap = function (el) { + oldAddToMap.call(storage, el); + + el.addSelfToZr(self); + }; + }; + + ZRender.prototype = { + + constructor: ZRender, + /** + * 获取实例唯一标识 + * @return {string} + */ + getId: function () { + return this.id; + }, + + /** + * 添加元素 + * @param {string|module:zrender/Element} el + */ + add: function (el) { + this.storage.addRoot(el); + this._needsRefresh = true; + }, + + /** + * 删除元素 + * @param {string|module:zrender/Element} el + */ + remove: function (el) { + this.storage.delRoot(el); + this._needsRefresh = true; + }, + + /** + * 修改指定zlevel的绘制配置项 + * + * @param {string} zLevel + * @param {Object} config 配置对象 + * @param {string} [config.clearColor=0] 每次清空画布的颜色 + * @param {string} [config.motionBlur=false] 是否开启动态模糊 + * @param {number} [config.lastFrameAlpha=0.7] + * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 + */ + configLayer: function (zLevel, config) { + this.painter.configLayer(zLevel, config); + this._needsRefresh = true; + }, + + /** + * 视图更新 + */ + refreshImmediately: function () { + // Clear needsRefresh ahead to avoid something wrong happens in refresh + // Or it will cause zrender refreshes again and again. + this._needsRefresh = false; + this.painter.refresh(); + /** + * Avoid trigger zr.refresh in Element#beforeUpdate hook + */ + this._needsRefresh = false; + }, + + /** + * 标记视图在浏览器下一帧需要绘制 + */ + refresh: function() { + this._needsRefresh = true; + }, + + /** + * 调整视图大小 + */ + resize: function() { + this.painter.resize(); + this.handler && this.handler.resize(); + }, + + /** + * 停止所有动画 + */ + clearAnimation: function () { + this.animation.clear(); + }, + + /** + * 获取视图宽度 + */ + getWidth: function() { + return this.painter.getWidth(); + }, + + /** + * 获取视图高度 + */ + getHeight: function() { + return this.painter.getHeight(); + }, + + /** + * 图像导出 + * @param {string} type + * @param {string} [backgroundColor='#fff'] 背景色 + * @return {string} 图片的Base64 url + */ + toDataURL: function(type, backgroundColor, args) { + return this.painter.toDataURL(type, backgroundColor, args); + }, + + /** + * 将常规shape转成image shape + * @param {module:zrender/graphic/Path} e + * @param {number} width + * @param {number} height + */ + pathToImage: function(e, width, height) { + var id = guid(); + return this.painter.pathToImage(id, e, width, height); + }, + + /** + * 设置默认的cursor style + * @param {string} cursorStyle 例如 crosshair + */ + setDefaultCursorStyle: function (cursorStyle) { + this.handler.setDefaultCursorStyle(cursorStyle); + }, + + /** + * 事件绑定 + * + * @param {string} eventName 事件名称 + * @param {Function} eventHandler 响应函数 + * @param {Object} [context] 响应函数 + */ + on: function(eventName, eventHandler, context) { + this.handler && this.handler.on(eventName, eventHandler, context); + }, + + /** + * 事件解绑定,参数为空则解绑所有自定义事件 + * + * @param {string} eventName 事件名称 + * @param {Function} eventHandler 响应函数 + */ + off: function(eventName, eventHandler) { + this.handler && this.handler.off(eventName, eventHandler); + }, + + /** + * 事件触发 + * + * @param {string} eventName 事件名称,resize,hover,drag,etc + * @param {event=} event event dom事件对象 + */ + trigger: function (eventName, event) { + this.handler && this.handler.trigger(eventName, event); + }, + + + /** + * 清除当前ZRender下所有类图的数据和显示,clear后MVC和已绑定事件均还存在在,ZRender可用 + */ + clear: function () { + this.storage.delRoot(); + this.painter.clear(); + }, + + /** + * 释放当前ZR实例(删除包括dom,数据、显示和事件绑定),dispose后ZR不可用 + */ + dispose: function () { + this.animation.stop(); + + this.clear(); + this.storage.dispose(); + this.painter.dispose(); + this.handler && this.handler.dispose(); + + this.animation = + this.storage = + this.painter = + this.handler = null; + + delInstance(this.id); + } + }; + + module.exports = zrender; + + + +/***/ }, +/* 78 */ +/***/ function(module, exports) { + + /** + * echarts设备环境识别 + * + * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。 + * @author firede[firede@firede.us] + * @desc thanks zepto. + */ + + var env = {}; + if (typeof navigator === 'undefined') { + // In node + env = { + browser: {}, + os: {}, + node: true, + // Assume canvas is supported + canvasSupported: true + }; + } + else { + env = detect(navigator.userAgent); + } + + module.exports = env; + + // Zepto.js + // (c) 2010-2013 Thomas Fuchs + // Zepto.js may be freely distributed under the MIT license. + + function detect(ua) { + var os = {}; + var browser = {}; + var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/); + var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); + var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); + var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); + var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/); + var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/); + var touchpad = webos && ua.match(/TouchPad/); + var kindle = ua.match(/Kindle\/([\d.]+)/); + var silk = ua.match(/Silk\/([\d._]+)/); + var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/); + var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/); + var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/); + var playbook = ua.match(/PlayBook/); + var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/); + var firefox = ua.match(/Firefox\/([\d.]+)/); + var safari = webkit && ua.match(/Mobile\//) && !chrome; + var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome; + var ie = ua.match(/MSIE\s([\d.]+)/) + // IE 11 Trident/7.0; rv:11.0 + || ua.match(/Trident\/.+?rv:(([\d.]+))/); + var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+ + + // Todo: clean this up with a better OS/browser seperation: + // - discern (more) between multiple browsers on android + // - decide if kindle fire in silk mode is android or not + // - Firefox on Android doesn't specify the Android version + // - possibly devide in os, device and browser hashes + + if (browser.webkit = !!webkit) browser.version = webkit[1]; + + if (android) os.android = true, os.version = android[2]; + if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.'); + if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.'); + if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null; + if (webos) os.webos = true, os.version = webos[2]; + if (touchpad) os.touchpad = true; + if (blackberry) os.blackberry = true, os.version = blackberry[2]; + if (bb10) os.bb10 = true, os.version = bb10[2]; + if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2]; + if (playbook) browser.playbook = true; + if (kindle) os.kindle = true, os.version = kindle[1]; + if (silk) browser.silk = true, browser.version = silk[1]; + if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true; + if (chrome) browser.chrome = true, browser.version = chrome[1]; + if (firefox) browser.firefox = true, browser.version = firefox[1]; + if (ie) browser.ie = true, browser.version = ie[1]; + if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true; + if (webview) browser.webview = true; + if (ie) browser.ie = true, browser.version = ie[1]; + if (edge) browser.edge = true, browser.version = edge[1]; + + os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) || + (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/))); + 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/)))); + + return { + browser: browser, + os: os, + node: false, + // 原生canvas支持,改极端点了 + // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9) + canvasSupported : document.createElement('canvas').getContext ? true : false, + // @see + // works on most browsers + // IE10/11 does not support touch event, and MS Edge supports them but not by + // default, so we dont check navigator.maxTouchPoints for them here. + touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge, + // . + pointerEventsSupported: 'onpointerdown' in window + // Firefox supports pointer but not by default, + // only MS browsers are reliable on pointer events currently. + && (browser.edge || (browser.ie && browser.version >= 10)) + }; + } + + +/***/ }, +/* 79 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Handler控制模块 + * @module zrender/Handler + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + * errorrik (errorrik@gmail.com) + * pissang (shenyi.914@gmail.com) + */ + + + var env = __webpack_require__(78); + var eventTool = __webpack_require__(80); + var util = __webpack_require__(3); + var Draggable = __webpack_require__(81); + var GestureMgr = __webpack_require__(82); + + var Eventful = __webpack_require__(32); + + var mouseHandlerNames = [ + 'click', 'dblclick', 'mousewheel', 'mouseout' + ]; + !usePointerEvent() && mouseHandlerNames.push( + 'mouseup', 'mousedown', 'mousemove' + ); + + var touchHandlerNames = [ + 'touchstart', 'touchend', 'touchmove' + ]; + + var pointerHandlerNames = [ + 'pointerdown', 'pointerup', 'pointermove' + ]; + + var TOUCH_CLICK_DELAY = 300; + + // touch指尖错觉的尝试偏移量配置 + // var MOBILE_TOUCH_OFFSETS = [ + // { x: 10 }, + // { x: -20 }, + // { x: 10, y: 10 }, + // { y: -20 } + // ]; + + var addEventListener = eventTool.addEventListener; + var removeEventListener = eventTool.removeEventListener; + var normalizeEvent = eventTool.normalizeEvent; + + function makeEventPacket(eveType, target, event) { + return { + type: eveType, + event: event, + target: target, + cancelBubble: false, + offsetX: event.zrX, + offsetY: event.zrY, + gestureEvent: event.gestureEvent, + pinchX: event.pinchX, + pinchY: event.pinchY, + pinchScale: event.pinchScale, + wheelDelta: event.zrDelta + }; + } + + var domHandlers = { + /** + * Mouse move handler + * @inner + * @param {Event} event + */ + mousemove: function (event) { + event = normalizeEvent(this.root, event); + + var x = event.zrX; + var y = event.zrY; + + var hovered = this.findHover(x, y, null); + var lastHovered = this._hovered; + + this._hovered = hovered; + + this.root.style.cursor = hovered ? hovered.cursor : this._defaultCursorStyle; + // Mouse out on previous hovered element + if (lastHovered && hovered !== lastHovered && lastHovered.__zr) { + this._dispatchProxy(lastHovered, 'mouseout', event); + } + + // Mouse moving on one element + this._dispatchProxy(hovered, 'mousemove', event); + + // Mouse over on a new element + if (hovered && hovered !== lastHovered) { + this._dispatchProxy(hovered, 'mouseover', event); + } + }, + + /** + * Mouse out handler + * @inner + * @param {Event} event + */ + mouseout: function (event) { + event = normalizeEvent(this.root, event); + + var element = event.toElement || event.relatedTarget; + if (element != this.root) { + while (element && element.nodeType != 9) { + // 忽略包含在root中的dom引起的mouseOut + if (element === this.root) { + return; + } + + element = element.parentNode; + } + } + + this._dispatchProxy(this._hovered, 'mouseout', event); + + this.trigger('globalout', { + event: event + }); + }, + + /** + * Touch开始响应函数 + * @inner + * @param {Event} event + */ + touchstart: function (event) { + // FIXME + // 移动端可能需要default行为,例如静态图表时。 + // eventTool.stop(event);// 阻止浏览器默认事件,重要 + event = normalizeEvent(this.root, event); + + this._lastTouchMoment = new Date(); + + processGesture(this, event, 'start'); + + // 平板补充一次findHover + // this._mobileFindFixed(event); + // Trigger mousemove and mousedown + domHandlers.mousemove.call(this, event); + + domHandlers.mousedown.call(this, event); + + setTouchTimer(this); + }, + + /** + * Touch移动响应函数 + * @inner + * @param {Event} event + */ + touchmove: function (event) { + // eventTool.stop(event);// 阻止浏览器默认事件,重要 + event = normalizeEvent(this.root, event); + + processGesture(this, event, 'change'); + + // Mouse move should always be triggered no matter whether + // there is gestrue event, because mouse move and pinch may + // be used at the same time. + domHandlers.mousemove.call(this, event); + + setTouchTimer(this); + }, + + /** + * Touch结束响应函数 + * @inner + * @param {Event} event + */ + touchend: function (event) { + // eventTool.stop(event);// 阻止浏览器默认事件,重要 + event = normalizeEvent(this.root, event); + + processGesture(this, event, 'end'); + + domHandlers.mouseup.call(this, event); + + // click event should always be triggered no matter whether + // there is gestrue event. System click can not be prevented. + if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) { + // this._mobileFindFixed(event); + domHandlers.click.call(this, event); + } + + setTouchTimer(this); + } + }; + + // Common handlers + util.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick'], function (name) { + domHandlers[name] = function (event) { + event = normalizeEvent(this.root, event); + // Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover + var hovered = this.findHover(event.zrX, event.zrY, null); + this._dispatchProxy(hovered, name, event); + }; + }); + + // Pointer event handlers + // util.each(['pointerdown', 'pointermove', 'pointerup'], function (name) { + // domHandlers[name] = function (event) { + // var mouseName = name.replace('pointer', 'mouse'); + // domHandlers[mouseName].call(this, event); + // }; + // }); + + function processGesture(zrHandler, event, stage) { + var gestureMgr = zrHandler._gestureMgr; + + stage === 'start' && gestureMgr.clear(); + + var gestureInfo = gestureMgr.recognize( + event, + zrHandler.findHover(event.zrX, event.zrY, null) + ); + + stage === 'end' && gestureMgr.clear(); + + if (gestureInfo) { + // eventTool.stop(event); + var type = gestureInfo.type; + event.gestureEvent = type; + + zrHandler._dispatchProxy(gestureInfo.target, type, gestureInfo.event); + } + } + + /** + * 为控制类实例初始化dom 事件处理函数 + * + * @inner + * @param {module:zrender/Handler} instance 控制类实例 + */ + function initDomHandler(instance) { + var handlerNames = touchHandlerNames.concat(pointerHandlerNames); + for (var i = 0; i < handlerNames.length; i++) { + var name = handlerNames[i]; + instance._handlers[name] = util.bind(domHandlers[name], instance); + } + + for (var i = 0; i < mouseHandlerNames.length; i++) { + var name = mouseHandlerNames[i]; + instance._handlers[name] = makeMouseHandler(domHandlers[name], instance); + } + + function makeMouseHandler(fn, instance) { + return function () { + if (instance._touching) { + return; + } + return fn.apply(instance, arguments); + }; + } + } + + /** + * @alias module:zrender/Handler + * @constructor + * @extends module:zrender/mixin/Eventful + * @param {HTMLElement} root Main HTML element for painting. + * @param {module:zrender/Storage} storage Storage instance. + * @param {module:zrender/Painter} painter Painter instance. + */ + var Handler = function(root, storage, painter) { + Eventful.call(this); + + this.root = root; + this.storage = storage; + this.painter = painter; + + /** + * @private + * @type {boolean} + */ + this._hovered; + + /** + * @private + * @type {Date} + */ + this._lastTouchMoment; + + /** + * @private + * @type {number} + */ + this._lastX; + + /** + * @private + * @type {number} + */ + this._lastY; + + /** + * @private + * @type {string} + */ + this._defaultCursorStyle = 'default'; + + /** + * @private + * @type {module:zrender/core/GestureMgr} + */ + this._gestureMgr = new GestureMgr(); + + /** + * @private + * @type {Array.} + */ + this._handlers = []; + + /** + * @private + * @type {boolean} + */ + this._touching = false; + + /** + * @private + * @type {number} + */ + this._touchTimer; + + initDomHandler(this); + + if (usePointerEvent()) { + mountHandlers(pointerHandlerNames, this); + } + else if (useTouchEvent()) { + mountHandlers(touchHandlerNames, this); + + // Handler of 'mouseout' event is needed in touch mode, which will be mounted below. + // addEventListener(root, 'mouseout', this._mouseoutHandler); + } + + // Considering some devices that both enable touch and mouse event (like MS Surface + // and lenovo X240, @see #2350), we make mouse event be always listened, otherwise + // mouse event can not be handle in those devices. + mountHandlers(mouseHandlerNames, this); + + Draggable.call(this); + + function mountHandlers(handlerNames, instance) { + util.each(handlerNames, function (name) { + addEventListener(root, eventNameFix(name), instance._handlers[name]); + }, instance); + } + }; + + Handler.prototype = { + + constructor: Handler, + + /** + * Resize + */ + resize: function (event) { + this._hovered = null; + }, + + /** + * Dispatch event + * @param {string} eventName + * @param {event=} eventArgs + */ + dispatch: function (eventName, eventArgs) { + var handler = this._handlers[eventName]; + handler && handler.call(this, eventArgs); + }, + + /** + * Dispose + */ + dispose: function () { + var root = this.root; + + var handlerNames = mouseHandlerNames.concat(touchHandlerNames); + + for (var i = 0; i < handlerNames.length; i++) { + var name = handlerNames[i]; + removeEventListener(root, eventNameFix(name), this._handlers[name]); + } + + this.root = + this.storage = + this.painter = null; + }, + + /** + * 设置默认的cursor style + * @param {string} cursorStyle 例如 crosshair + */ + setDefaultCursorStyle: function (cursorStyle) { + this._defaultCursorStyle = cursorStyle; + }, + + /** + * 事件分发代理 + * + * @private + * @param {Object} targetEl 目标图形元素 + * @param {string} eventName 事件名称 + * @param {Object} event 事件对象 + */ + _dispatchProxy: function (targetEl, eventName, event) { + var eventHandler = 'on' + eventName; + var eventPacket = makeEventPacket(eventName, targetEl, event); + + var el = targetEl; + + while (el) { + el[eventHandler] + && (eventPacket.cancelBubble = el[eventHandler].call(el, eventPacket)); + + el.trigger(eventName, eventPacket); + + el = el.parent; + + if (eventPacket.cancelBubble) { + break; + } + } + + if (!eventPacket.cancelBubble) { + // 冒泡到顶级 zrender 对象 + this.trigger(eventName, eventPacket); + // 分发事件到用户自定义层 + // 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在 + this.painter && this.painter.eachOtherLayer(function (layer) { + if (typeof(layer[eventHandler]) == 'function') { + layer[eventHandler].call(layer, eventPacket); + } + if (layer.trigger) { + layer.trigger(eventName, eventPacket); + } + }); + } + }, + + /** + * @private + * @param {number} x + * @param {number} y + * @param {module:zrender/graphic/Displayable} exclude + * @method + */ + findHover: function(x, y, exclude) { + var list = this.storage.getDisplayList(); + for (var i = list.length - 1; i >= 0 ; i--) { + if (!list[i].silent + && list[i] !== exclude + // getDisplayList may include ignored item in VML mode + && !list[i].ignore + && isHover(list[i], x, y)) { + return list[i]; + } + } + } + }; + + function isHover(displayable, x, y) { + if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) { + var p = displayable.parent; + while (p) { + if (p.clipPath && !p.clipPath.contain(x, y)) { + // Clipped by parents + return false; + } + p = p.parent; + } + return true; + } + + return false; + } + + /** + * Prevent mouse event from being dispatched after Touch Events action + * @see + * 1. Mobile browsers dispatch mouse events 300ms after touchend. + * 2. Chrome for Android dispatch mousedown for long-touch about 650ms + * Result: Blocking Mouse Events for 700ms. + */ + function setTouchTimer(instance) { + instance._touching = true; + clearTimeout(instance._touchTimer); + instance._touchTimer = setTimeout(function () { + instance._touching = false; + }, 700); + } + + /** + * Althought MS Surface support screen touch, IE10/11 do not support + * touch event and MS Edge supported them but not by default (but chrome + * and firefox do). Thus we use Pointer event on MS browsers to handle touch. + */ + function usePointerEvent() { + // TODO + // pointermove event dont trigger when using finger. + // We may figger it out latter. + return false; + // return env.pointerEventsSupported + // In no-touch device we dont use pointer evnets but just + // use mouse event for avoiding problems. + // && window.navigator.maxTouchPoints; + } + + function useTouchEvent() { + return env.touchEventsSupported; + } + + function eventNameFix(name) { + return (name === 'mousewheel' && env.browser.firefox) ? 'DOMMouseScroll' : name; + } + + util.mixin(Handler, Eventful); + util.mixin(Handler, Draggable); + + module.exports = Handler; + + +/***/ }, +/* 80 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 事件辅助类 + * @module zrender/core/event + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + */ + + + var Eventful = __webpack_require__(32); + + var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener; + + function getBoundingClientRect(el) { + // BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect + return el.getBoundingClientRect ? el.getBoundingClientRect() : { left: 0, top: 0}; + } + /** + * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标 + */ + function normalizeEvent(el, e) { + + e = e || window.event; + + if (e.zrX != null) { + return e; + } + + var eventType = e.type; + var isTouch = eventType && eventType.indexOf('touch') >= 0; + + if (!isTouch) { + var box = getBoundingClientRect(el); + e.zrX = e.clientX - box.left; + e.zrY = e.clientY - box.top; + e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3; + } + else { + var touch = eventType != 'touchend' + ? e.targetTouches[0] + : e.changedTouches[0]; + if (touch) { + var rBounding = getBoundingClientRect(el); + // touch事件坐标是全屏的~ + e.zrX = touch.clientX - rBounding.left; + e.zrY = touch.clientY - rBounding.top; + } + } + + return e; + } + + function addEventListener(el, name, handler) { + if (isDomLevel2) { + el.addEventListener(name, handler); + } + else { + el.attachEvent('on' + name, handler); + } + } + + function removeEventListener(el, name, handler) { + if (isDomLevel2) { + el.removeEventListener(name, handler); + } + else { + el.detachEvent('on' + name, handler); + } + } + + /** + * 停止冒泡和阻止默认行为 + * @memberOf module:zrender/core/event + * @method + * @param {Event} e : event对象 + */ + var stop = isDomLevel2 + ? function (e) { + e.preventDefault(); + e.stopPropagation(); + e.cancelBubble = true; + } + : function (e) { + e.returnValue = false; + e.cancelBubble = true; + }; + + module.exports = { + normalizeEvent: normalizeEvent, + addEventListener: addEventListener, + removeEventListener: removeEventListener, + + stop: stop, + // 做向上兼容 + Dispatcher: Eventful + }; + + + +/***/ }, +/* 81 */ +/***/ function(module, exports) { + + // TODO Draggable for group + // FIXME Draggable on element which has parent rotation or scale + + function Draggable() { + + this.on('mousedown', this._dragStart, this); + this.on('mousemove', this._drag, this); + this.on('mouseup', this._dragEnd, this); + this.on('globalout', this._dragEnd, this); + // this._dropTarget = null; + // this._draggingTarget = null; + + // this._x = 0; + // this._y = 0; + } + + Draggable.prototype = { + + constructor: Draggable, + + _dragStart: function (e) { + var draggingTarget = e.target; + if (draggingTarget && draggingTarget.draggable) { + this._draggingTarget = draggingTarget; + draggingTarget.dragging = true; + this._x = e.offsetX; + this._y = e.offsetY; + + this._dispatchProxy(draggingTarget, 'dragstart', e.event); + } + }, + + _drag: function (e) { + var draggingTarget = this._draggingTarget; + if (draggingTarget) { + + var x = e.offsetX; + var y = e.offsetY; + + var dx = x - this._x; + var dy = y - this._y; + this._x = x; + this._y = y; + + draggingTarget.drift(dx, dy, e); + this._dispatchProxy(draggingTarget, 'drag', e.event); + + var dropTarget = this.findHover(x, y, draggingTarget); + var lastDropTarget = this._dropTarget; + this._dropTarget = dropTarget; + + if (draggingTarget !== dropTarget) { + if (lastDropTarget && dropTarget !== lastDropTarget) { + this._dispatchProxy(lastDropTarget, 'dragleave', e.event); + } + if (dropTarget && dropTarget !== lastDropTarget) { + this._dispatchProxy(dropTarget, 'dragenter', e.event); + } + } + } + }, + + _dragEnd: function (e) { + var draggingTarget = this._draggingTarget; + + if (draggingTarget) { + draggingTarget.dragging = false; + } + + this._dispatchProxy(draggingTarget, 'dragend', e.event); + + if (this._dropTarget) { + this._dispatchProxy(this._dropTarget, 'drop', e.event); + } + + this._draggingTarget = null; + this._dropTarget = null; + } - var colorStops = this.colorStops; - for (var i = 0; i < colorStops.length; i++) { - canvasGradient.addColorStop( - colorStops[i].offset, colorStops[i].color - ); - } + }; - this.canvasGradient = canvasGradient; - } + module.exports = Draggable; - }; - zrUtil.inherits(LinearGradient, Gradient); +/***/ }, +/* 82 */ +/***/ function(module, exports) { - return LinearGradient; -}); -define('zrender/graphic/RadialGradient',['require','../core/util','./Gradient'],function(require) { - + 'use strict'; + /** + * Only implements needed gestures for mobile. + */ - var zrUtil = require('../core/util'); - var Gradient = require('./Gradient'); + var GestureMgr = function () { + + /** + * @private + * @type {Array.} + */ + this._track = []; + }; + + GestureMgr.prototype = { + + constructor: GestureMgr, - /** - * x, y, r are all percent from 0 to 1 - * @param {number} [x=0.5] - * @param {number} [y=0.5] - * @param {number} [r=0.5] - * @param {Array.} [colorStops] - */ - var RadialGradient = function (x, y, r, colorStops) { - this.x = x == null ? 0.5 : x; + recognize: function (event, target) { + this._doTrack(event, target); + return this._recognize(event); + }, - this.y = y == null ? 0.5 : y; + clear: function () { + this._track.length = 0; + return this; + }, + + _doTrack: function (event, target) { + var touches = event.touches; + + if (!touches) { + return; + } - this.r = r == null ? 0.5 : r; + var trackItem = { + points: [], + touches: [], + target: target, + event: event + }; - Gradient.call(this, colorStops); - }; + for (var i = 0, len = touches.length; i < len; i++) { + var touch = touches[i]; + trackItem.points.push([touch.clientX, touch.clientY]); + trackItem.touches.push(touch); + } + + this._track.push(trackItem); + }, + + _recognize: function (event) { + for (var eventName in recognizers) { + if (recognizers.hasOwnProperty(eventName)) { + var gestureInfo = recognizers[eventName](this._track, event); + if (gestureInfo) { + return gestureInfo; + } + } + } + } + }; + + function dist(pointPair) { + var dx = pointPair[1][0] - pointPair[0][0]; + var dy = pointPair[1][1] - pointPair[0][1]; + + return Math.sqrt(dx * dx + dy * dy); + } - RadialGradient.prototype = { + function center(pointPair) { + return [ + (pointPair[0][0] + pointPair[1][0]) / 2, + (pointPair[0][1] + pointPair[1][1]) / 2 + ]; + } + + var recognizers = { + + pinch: function (track, event) { + var trackLen = track.length; + + if (!trackLen) { + return; + } + + var pinchEnd = (track[trackLen - 1] || {}).points; + var pinchPre = (track[trackLen - 2] || {}).points || pinchEnd; + + if (pinchPre + && pinchPre.length > 1 + && pinchEnd + && pinchEnd.length > 1 + ) { + var pinchScale = dist(pinchEnd) / dist(pinchPre); + !isFinite(pinchScale) && (pinchScale = 1); + + event.pinchScale = pinchScale; + + var pinchCenter = center(pinchEnd); + event.pinchX = pinchCenter[0]; + event.pinchY = pinchCenter[1]; + + return { + type: 'pinch', + target: track[0].target, + event: event + }; + } + } + + // Only pinch currently. + }; + + module.exports = GestureMgr; + + + +/***/ }, +/* 83 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Storage内容仓库模块 + * @module zrender/Storage + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + * @author errorrik (errorrik@gmail.com) + * @author pissang (https://github.com/pissang/) + */ + + + var util = __webpack_require__(3); + + var Group = __webpack_require__(29); + + function shapeCompareFunc(a, b) { + if (a.zlevel === b.zlevel) { + if (a.z === b.z) { + if (a.z2 === b.z2) { + return a.__renderidx - b.__renderidx; + } + return a.z2 - b.z2; + } + return a.z - b.z; + } + return a.zlevel - b.zlevel; + } + /** + * 内容仓库 (M) + * @alias module:zrender/Storage + * @constructor + */ + var Storage = function () { + // 所有常规形状,id索引的map + this._elements = {}; + + this._roots = []; + + this._displayList = []; + + this._displayListLen = 0; + }; + + Storage.prototype = { + + constructor: Storage, + + /** + * 返回所有图形的绘制队列 + * @param {boolean} [update=false] 是否在返回前更新该数组 + * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组, 在 update 为 true 的时候有效 + * + * 详见{@link module:zrender/graphic/Displayable.prototype.updateDisplayList} + * @return {Array.} + */ + getDisplayList: function (update, includeIgnore) { + includeIgnore = includeIgnore || false; + if (update) { + this.updateDisplayList(includeIgnore); + } + return this._displayList; + }, + + /** + * 更新图形的绘制队列。 + * 每次绘制前都会调用,该方法会先深度优先遍历整个树,更新所有Group和Shape的变换并且把所有可见的Shape保存到数组中, + * 最后根据绘制的优先级(zlevel > z > 插入顺序)排序得到绘制队列 + * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组 + */ + updateDisplayList: function (includeIgnore) { + this._displayListLen = 0; + var roots = this._roots; + var displayList = this._displayList; + for (var i = 0, len = roots.length; i < len; i++) { + this._updateAndAddDisplayable(roots[i], null, includeIgnore); + } + displayList.length = this._displayListLen; + + for (var i = 0, len = displayList.length; i < len; i++) { + displayList[i].__renderidx = i; + } + + displayList.sort(shapeCompareFunc); + }, + + _updateAndAddDisplayable: function (el, clipPaths, includeIgnore) { + + if (el.ignore && !includeIgnore) { + return; + } + + el.beforeUpdate(); + + el.update(); + + el.afterUpdate(); + + var clipPath = el.clipPath; + if (clipPath) { + // clipPath 的变换是基于 group 的变换 + clipPath.parent = el; + clipPath.updateTransform(); + + // FIXME 效率影响 + if (clipPaths) { + clipPaths = clipPaths.slice(); + clipPaths.push(clipPath); + } + else { + clipPaths = [clipPath]; + } + } + + if (el.type == 'group') { + var children = el._children; + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + + // Force to mark as dirty if group is dirty + // FIXME __dirtyPath ? + child.__dirty = el.__dirty || child.__dirty; + + this._updateAndAddDisplayable(child, clipPaths, includeIgnore); + } + + // Mark group clean here + el.__dirty = false; + + } + else { + el.__clipPaths = clipPaths; + + this._displayList[this._displayListLen++] = el; + } + }, + + /** + * 添加图形(Shape)或者组(Group)到根节点 + * @param {module:zrender/Element} el + */ + addRoot: function (el) { + // Element has been added + if (this._elements[el.id]) { + return; + } + + if (el instanceof Group) { + el.addChildrenToStorage(this); + } + + this.addToMap(el); + this._roots.push(el); + }, + + /** + * 删除指定的图形(Shape)或者组(Group) + * @param {string|Array.} [elId] 如果为空清空整个Storage + */ + delRoot: function (elId) { + if (elId == null) { + // 不指定elId清空 + for (var i = 0; i < this._roots.length; i++) { + var root = this._roots[i]; + if (root instanceof Group) { + root.delChildrenFromStorage(this); + } + } + + this._elements = {}; + this._roots = []; + this._displayList = []; + this._displayListLen = 0; + + return; + } + + if (elId instanceof Array) { + for (var i = 0, l = elId.length; i < l; i++) { + this.delRoot(elId[i]); + } + return; + } + + var el; + if (typeof(elId) == 'string') { + el = this._elements[elId]; + } + else { + el = elId; + } + + var idx = util.indexOf(this._roots, el); + if (idx >= 0) { + this.delFromMap(el.id); + this._roots.splice(idx, 1); + if (el instanceof Group) { + el.delChildrenFromStorage(this); + } + } + }, + + addToMap: function (el) { + if (el instanceof Group) { + el.__storage = this; + } + el.dirty(); + + this._elements[el.id] = el; + + return this; + }, + + get: function (elId) { + return this._elements[elId]; + }, + + delFromMap: function (elId) { + var elements = this._elements; + var el = elements[elId]; + if (el) { + delete elements[elId]; + if (el instanceof Group) { + el.__storage = null; + } + } + + return this; + }, + + /** + * 清空并且释放Storage + */ + dispose: function () { + this._elements = + this._renderList = + this._roots = null; + } + }; + + module.exports = Storage; + + + +/***/ }, +/* 84 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 动画主类, 调度和管理所有动画控制器 + * + * @module zrender/animation/Animation + * @author pissang(https://github.com/pissang) + */ + // TODO Additive animation + // http://iosoteric.com/additive-animations-animatewithduration-in-ios-8/ + // https://developer.apple.com/videos/wwdc2014/#236 + + + var util = __webpack_require__(3); + var Dispatcher = __webpack_require__(80).Dispatcher; + + var requestAnimationFrame = (typeof window !== 'undefined' && + (window.requestAnimationFrame + || window.msRequestAnimationFrame + || window.mozRequestAnimationFrame + || window.webkitRequestAnimationFrame)) + || function (func) { + setTimeout(func, 16); + }; + + var Animator = __webpack_require__(35); + /** + * @typedef {Object} IZRenderStage + * @property {Function} update + */ + + /** + * @alias module:zrender/animation/Animation + * @constructor + * @param {Object} [options] + * @param {Function} [options.onframe] + * @param {IZRenderStage} [options.stage] + * @example + * var animation = new Animation(); + * var obj = { + * x: 100, + * y: 100 + * }; + * animation.animate(node.position) + * .when(1000, { + * x: 500, + * y: 500 + * }) + * .when(2000, { + * x: 100, + * y: 100 + * }) + * .start('spline'); + */ + var Animation = function (options) { + + options = options || {}; + + this.stage = options.stage || {}; + + this.onframe = options.onframe || function() {}; + + // private properties + this._clips = []; + + this._running = false; + + this._time = 0; + + Dispatcher.call(this); + }; + + Animation.prototype = { + + constructor: Animation, + /** + * 添加 clip + * @param {module:zrender/animation/Clip} clip + */ + addClip: function (clip) { + this._clips.push(clip); + }, + /** + * 添加 animator + * @param {module:zrender/animation/Animator} animator + */ + addAnimator: function (animator) { + animator.animation = this; + var clips = animator.getClips(); + for (var i = 0; i < clips.length; i++) { + this.addClip(clips[i]); + } + }, + /** + * 删除动画片段 + * @param {module:zrender/animation/Clip} clip + */ + removeClip: function(clip) { + var idx = util.indexOf(this._clips, clip); + if (idx >= 0) { + this._clips.splice(idx, 1); + } + }, + + /** + * 删除动画片段 + * @param {module:zrender/animation/Animator} animator + */ + removeAnimator: function (animator) { + var clips = animator.getClips(); + for (var i = 0; i < clips.length; i++) { + this.removeClip(clips[i]); + } + animator.animation = null; + }, + + _update: function() { + + var time = new Date().getTime(); + var delta = time - this._time; + var clips = this._clips; + var len = clips.length; + + var deferredEvents = []; + var deferredClips = []; + for (var i = 0; i < len; i++) { + var clip = clips[i]; + var e = clip.step(time); + // Throw out the events need to be called after + // stage.update, like destroy + if (e) { + deferredEvents.push(e); + deferredClips.push(clip); + } + } + + // Remove the finished clip + for (var i = 0; i < len;) { + if (clips[i]._needsRemove) { + clips[i] = clips[len - 1]; + clips.pop(); + len--; + } + else { + i++; + } + } + + len = deferredEvents.length; + for (var i = 0; i < len; i++) { + deferredClips[i].fire(deferredEvents[i]); + } + + this._time = time; + + this.onframe(delta); + + this.trigger('frame', delta); + + if (this.stage.update) { + this.stage.update(); + } + }, + /** + * 开始运行动画 + */ + start: function () { + var self = this; + + this._running = true; + + function step() { + if (self._running) { + + requestAnimationFrame(step); + + self._update(); + } + } + + this._time = new Date().getTime(); + requestAnimationFrame(step); + }, + /** + * 停止运行动画 + */ + stop: function () { + this._running = false; + }, + /** + * 清除所有动画片段 + */ + clear: function () { + this._clips = []; + }, + /** + * 对一个目标创建一个animator对象,可以指定目标中的属性使用动画 + * @param {Object} target + * @param {Object} options + * @param {boolean} [options.loop=false] 是否循环播放动画 + * @param {Function} [options.getter=null] + * 如果指定getter函数,会通过getter函数取属性值 + * @param {Function} [options.setter=null] + * 如果指定setter函数,会通过setter函数设置属性值 + * @return {module:zrender/animation/Animation~Animator} + */ + animate: function (target, options) { + options = options || {}; + var animator = new Animator( + target, + options.loop, + options.getter, + options.setter + ); + + return animator; + } + }; + + util.mixin(Animation, Dispatcher); + + module.exports = Animation; + + + +/***/ }, +/* 85 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Default canvas painter + * @module zrender/Painter + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + * errorrik (errorrik@gmail.com) + * pissang (https://www.github.com/pissang) + */ + + + var config = __webpack_require__(40); + var util = __webpack_require__(3); + var log = __webpack_require__(39); + var BoundingRect = __webpack_require__(15); + + var Layer = __webpack_require__(86); + + function parseInt10(val) { + return parseInt(val, 10); + } + + function isLayerValid(layer) { + if (!layer) { + return false; + } + + if (layer.isBuildin) { + return true; + } + + if (typeof(layer.resize) !== 'function' + || typeof(layer.refresh) !== 'function' + ) { + return false; + } + + return true; + } + + function preProcessLayer(layer) { + layer.__unusedCount++; + } + + function postProcessLayer(layer) { + layer.__dirty = false; + if (layer.__unusedCount == 1) { + layer.clear(); + } + } + + var tmpRect = new BoundingRect(0, 0, 0, 0); + var viewRect = new BoundingRect(0, 0, 0, 0); + function isDisplayableCulled(el, width, height) { + tmpRect.copy(el.getBoundingRect()); + if (el.transform) { + tmpRect.applyTransform(el.transform); + } + viewRect.width = width; + viewRect.height = height; + return !tmpRect.intersect(viewRect); + } + + function isClipPathChanged(clipPaths, prevClipPaths) { + if (!clipPaths || !prevClipPaths || (clipPaths.length !== prevClipPaths.length)) { + return true; + } + for (var i = 0; i < clipPaths.length; i++) { + if (clipPaths[i] !== prevClipPaths[i]) { + return true; + } + } + } + + function doClip(clipPaths, ctx) { + for (var i = 0; i < clipPaths.length; i++) { + var clipPath = clipPaths[i]; + var m; + if (clipPath.transform) { + m = clipPath.transform; + ctx.transform( + m[0], m[1], + m[2], m[3], + m[4], m[5] + ); + } + var path = clipPath.path; + path.beginPath(ctx); + clipPath.buildPath(path, clipPath.shape); + ctx.clip(); + // Transform back + if (clipPath.transform) { + m = clipPath.invTransform; + ctx.transform( + m[0], m[1], + m[2], m[3], + m[4], m[5] + ); + } + } + } + + /** + * @alias module:zrender/Painter + * @constructor + * @param {HTMLElement} root 绘图容器 + * @param {module:zrender/Storage} storage + * @param {Ojbect} opts + */ + var Painter = function (root, storage, opts) { + var singleCanvas = !root.nodeName // In node ? + || root.nodeName.toUpperCase() === 'CANVAS'; + + opts = opts || {}; + + /** + * @type {number} + */ + this.dpr = opts.devicePixelRatio || config.devicePixelRatio; + /** + * @type {boolean} + * @private + */ + this._singleCanvas = singleCanvas; + /** + * 绘图容器 + * @type {HTMLElement} + */ + this.root = root; + + var rootStyle = root.style; + + // In node environment using node-canvas + if (rootStyle) { + rootStyle['-webkit-tap-highlight-color'] = 'transparent'; + rootStyle['-webkit-user-select'] = 'none'; + rootStyle['user-select'] = 'none'; + rootStyle['-webkit-touch-callout'] = 'none'; + + root.innerHTML = ''; + } + + /** + * @type {module:zrender/Storage} + */ + this.storage = storage; + + if (!singleCanvas) { + var width = this._getWidth(); + var height = this._getHeight(); + this._width = width; + this._height = height; + + var domRoot = document.createElement('div'); + this._domRoot = domRoot; + var domRootStyle = domRoot.style; + + // domRoot.onselectstart = returnFalse; // 避免页面选中的尴尬 + domRootStyle.position = 'relative'; + domRootStyle.overflow = 'hidden'; + domRootStyle.width = this._width + 'px'; + domRootStyle.height = this._height + 'px'; + root.appendChild(domRoot); + + /** + * @type {Object.} + * @private + */ + this._layers = {}; + /** + * @type {Array.} + * @private + */ + this._zlevelList = []; + } + else { + // Use canvas width and height directly + var width = root.width; + var height = root.height; + this._width = width; + this._height = height; + + // Create layer if only one given canvas + // Device pixel ratio is fixed to 1 because given canvas has its specified width and height + var mainLayer = new Layer(root, this, 1); + mainLayer.initContext(); + // FIXME Use canvas width and height + // mainLayer.resize(width, height); + this._layers = { + 0: mainLayer + }; + this._zlevelList = [0]; + } + + this._layerConfig = {}; + + this.pathToImage = this._createPathToImage(); + }; + + Painter.prototype = { + + constructor: Painter, + + /** + * If painter use a single canvas + * @return {boolean} + */ + isSingleCanvas: function () { + return this._singleCanvas; + }, + /** + * @return {HTMLDivElement} + */ + getViewportRoot: function () { + return this._singleCanvas ? this._layers[0].dom : this._domRoot; + }, + + /** + * 刷新 + * @param {boolean} [paintAll=false] 强制绘制所有displayable + */ + refresh: function (paintAll) { + var list = this.storage.getDisplayList(true); + var zlevelList = this._zlevelList; + + this._paintList(list, paintAll); + + // Paint custum layers + for (var i = 0; i < zlevelList.length; i++) { + var z = zlevelList[i]; + var layer = this._layers[z]; + if (!layer.isBuildin && layer.refresh) { + layer.refresh(); + } + } + + return this; + }, + + _paintList: function (list, paintAll) { + + if (paintAll == null) { + paintAll = false; + } + + this._updateLayerStatus(list); + + var currentLayer; + var currentZLevel; + var ctx; + + var viewWidth = this._width; + var viewHeight = this._height; + + this.eachBuildinLayer(preProcessLayer); + + // var invTransform = []; + var prevElClipPaths = null; + + for (var i = 0, l = list.length; i < l; i++) { + var el = list[i]; + var elZLevel = this._singleCanvas ? 0 : el.zlevel; + // Change draw layer + if (currentZLevel !== elZLevel) { + // Only 0 zlevel if only has one canvas + currentZLevel = elZLevel; + currentLayer = this.getLayer(currentZLevel); + + if (!currentLayer.isBuildin) { + log( + 'ZLevel ' + currentZLevel + + ' has been used by unkown layer ' + currentLayer.id + ); + } + + ctx = currentLayer.ctx; + + // Reset the count + currentLayer.__unusedCount = 0; + + if (currentLayer.__dirty || paintAll) { + currentLayer.clear(); + } + } + + if ( + (currentLayer.__dirty || paintAll) + // Ignore invisible element + && !el.invisible + // Ignore transparent element + && el.style.opacity !== 0 + // Ignore scale 0 element, in some environment like node-canvas + // Draw a scale 0 element can cause all following draw wrong + && el.scale[0] && el.scale[1] + // Ignore culled element + && !(el.culling && isDisplayableCulled(el, viewWidth, viewHeight)) + ) { + var clipPaths = el.__clipPaths; + + // Optimize when clipping on group with several elements + if (isClipPathChanged(clipPaths, prevElClipPaths)) { + // If has previous clipping state, restore from it + if (prevElClipPaths) { + ctx.restore(); + } + // New clipping state + if (clipPaths) { + ctx.save(); + doClip(clipPaths, ctx); + } + prevElClipPaths = clipPaths; + } + // TODO Use events ? + el.beforeBrush && el.beforeBrush(ctx); + el.brush(ctx, false); + el.afterBrush && el.afterBrush(ctx); + } + + el.__dirty = false; + } + + // If still has clipping state + if (prevElClipPaths) { + ctx.restore(); + } + + this.eachBuildinLayer(postProcessLayer); + }, + + /** + * 获取 zlevel 所在层,如果不存在则会创建一个新的层 + * @param {number} zlevel + * @return {module:zrender/Layer} + */ + getLayer: function (zlevel) { + if (this._singleCanvas) { + return this._layers[0]; + } + + var layer = this._layers[zlevel]; + if (!layer) { + // Create a new layer + layer = new Layer('zr_' + zlevel, this, this.dpr); + layer.isBuildin = true; + + if (this._layerConfig[zlevel]) { + util.merge(layer, this._layerConfig[zlevel], true); + } + + this.insertLayer(zlevel, layer); + + // Context is created after dom inserted to document + // Or excanvas will get 0px clientWidth and clientHeight + layer.initContext(); + } + + return layer; + }, + + insertLayer: function (zlevel, layer) { + + var layersMap = this._layers; + var zlevelList = this._zlevelList; + var len = zlevelList.length; + var prevLayer = null; + var i = -1; + var domRoot = this._domRoot; + + if (layersMap[zlevel]) { + log('ZLevel ' + zlevel + ' has been used already'); + return; + } + // Check if is a valid layer + if (!isLayerValid(layer)) { + log('Layer of zlevel ' + zlevel + ' is not valid'); + return; + } + + if (len > 0 && zlevel > zlevelList[0]) { + for (i = 0; i < len - 1; i++) { + if ( + zlevelList[i] < zlevel + && zlevelList[i + 1] > zlevel + ) { + break; + } + } + prevLayer = layersMap[zlevelList[i]]; + } + zlevelList.splice(i + 1, 0, zlevel); + + if (prevLayer) { + var prevDom = prevLayer.dom; + if (prevDom.nextSibling) { + domRoot.insertBefore( + layer.dom, + prevDom.nextSibling + ); + } + else { + domRoot.appendChild(layer.dom); + } + } + else { + if (domRoot.firstChild) { + domRoot.insertBefore(layer.dom, domRoot.firstChild); + } + else { + domRoot.appendChild(layer.dom); + } + } + + layersMap[zlevel] = layer; + }, + + // Iterate each layer + eachLayer: function (cb, context) { + var zlevelList = this._zlevelList; + var z; + var i; + for (i = 0; i < zlevelList.length; i++) { + z = zlevelList[i]; + cb.call(context, this._layers[z], z); + } + }, + + // Iterate each buildin layer + eachBuildinLayer: function (cb, context) { + var zlevelList = this._zlevelList; + var layer; + var z; + var i; + for (i = 0; i < zlevelList.length; i++) { + z = zlevelList[i]; + layer = this._layers[z]; + if (layer.isBuildin) { + cb.call(context, layer, z); + } + } + }, + + // Iterate each other layer except buildin layer + eachOtherLayer: function (cb, context) { + var zlevelList = this._zlevelList; + var layer; + var z; + var i; + for (i = 0; i < zlevelList.length; i++) { + z = zlevelList[i]; + layer = this._layers[z]; + if (! layer.isBuildin) { + cb.call(context, layer, z); + } + } + }, + + /** + * 获取所有已创建的层 + * @param {Array.} [prevLayer] + */ + getLayers: function () { + return this._layers; + }, + + _updateLayerStatus: function (list) { + + var layers = this._layers; + + var elCounts = {}; + + this.eachBuildinLayer(function (layer, z) { + elCounts[z] = layer.elCount; + layer.elCount = 0; + }); + + for (var i = 0, l = list.length; i < l; i++) { + var el = list[i]; + var zlevel = this._singleCanvas ? 0 : el.zlevel; + var layer = layers[zlevel]; + if (layer) { + layer.elCount++; + // 已经被标记为需要刷新 + if (layer.__dirty) { + continue; + } + layer.__dirty = el.__dirty; + } + } + + // 层中的元素数量有发生变化 + this.eachBuildinLayer(function (layer, z) { + if (elCounts[z] !== layer.elCount) { + layer.__dirty = true; + } + }); + }, + + /** + * 清除hover层外所有内容 + */ + clear: function () { + this.eachBuildinLayer(this._clearLayer); + return this; + }, + + _clearLayer: function (layer) { + layer.clear(); + }, + + /** + * 修改指定zlevel的绘制参数 + * + * @param {string} zlevel + * @param {Object} config 配置对象 + * @param {string} [config.clearColor=0] 每次清空画布的颜色 + * @param {string} [config.motionBlur=false] 是否开启动态模糊 + * @param {number} [config.lastFrameAlpha=0.7] + * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 + */ + configLayer: function (zlevel, config) { + if (config) { + var layerConfig = this._layerConfig; + if (!layerConfig[zlevel]) { + layerConfig[zlevel] = config; + } + else { + util.merge(layerConfig[zlevel], config, true); + } + + var layer = this._layers[zlevel]; + + if (layer) { + util.merge(layer, layerConfig[zlevel], true); + } + } + }, + + /** + * 删除指定层 + * @param {number} zlevel 层所在的zlevel + */ + delLayer: function (zlevel) { + var layers = this._layers; + var zlevelList = this._zlevelList; + var layer = layers[zlevel]; + if (!layer) { + return; + } + layer.dom.parentNode.removeChild(layer.dom); + delete layers[zlevel]; + + zlevelList.splice(util.indexOf(zlevelList, zlevel), 1); + }, + + /** + * 区域大小变化后重绘 + */ + resize: function (width, height) { + var domRoot = this._domRoot; + // FIXME Why ? + domRoot.style.display = 'none'; + + width = width || this._getWidth(); + height = height || this._getHeight(); + + domRoot.style.display = ''; + + // 优化没有实际改变的resize + if (this._width != width || height != this._height) { + domRoot.style.width = width + 'px'; + domRoot.style.height = height + 'px'; + + for (var id in this._layers) { + this._layers[id].resize(width, height); + } + + this.refresh(true); + } + + this._width = width; + this._height = height; + + return this; + }, + + /** + * 清除单独的一个层 + * @param {number} zlevel + */ + clearLayer: function (zlevel) { + var layer = this._layers[zlevel]; + if (layer) { + layer.clear(); + } + }, + + /** + * 释放 + */ + dispose: function () { + this.root.innerHTML = ''; + + this.root = + this.storage = + + this._domRoot = + this._layers = null; + }, + + /** + * Get canvas which has all thing rendered + * @param {Object} opts + * @param {string} [opts.backgroundColor] + */ + getRenderedCanvas: function (opts) { + opts = opts || {}; + if (this._singleCanvas) { + return this._layers[0].dom; + } + + var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr); + imageLayer.initContext(); + + var ctx = imageLayer.ctx; + imageLayer.clearColor = opts.backgroundColor; + imageLayer.clear(); + + var displayList = this.storage.getDisplayList(true); + + for (var i = 0; i < displayList.length; i++) { + var el = displayList[i]; + if (!el.invisible) { + el.beforeBrush && el.beforeBrush(ctx); + // TODO Check image cross origin + el.brush(ctx, false); + el.afterBrush && el.afterBrush(ctx); + } + } + + return imageLayer.dom; + }, + /** + * 获取绘图区域宽度 + */ + getWidth: function () { + return this._width; + }, + + /** + * 获取绘图区域高度 + */ + getHeight: function () { + return this._height; + }, + + _getWidth: function () { + var root = this.root; + var stl = document.defaultView.getComputedStyle(root); + + // FIXME Better way to get the width and height when element has not been append to the document + return ((root.clientWidth || parseInt10(stl.width) || parseInt10(root.style.width)) + - (parseInt10(stl.paddingLeft) || 0) + - (parseInt10(stl.paddingRight) || 0)) | 0; + }, + + _getHeight: function () { + var root = this.root; + var stl = document.defaultView.getComputedStyle(root); + + return ((root.clientHeight || parseInt10(stl.height) || parseInt10(root.style.height)) + - (parseInt10(stl.paddingTop) || 0) + - (parseInt10(stl.paddingBottom) || 0)) | 0; + }, + + _pathToImage: function (id, path, width, height, dpr) { + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + + canvas.width = width * dpr; + canvas.height = height * dpr; + + ctx.clearRect(0, 0, width * dpr, height * dpr); + + var pathTransform = { + position: path.position, + rotation: path.rotation, + scale: path.scale + }; + path.position = [0, 0, 0]; + path.rotation = 0; + path.scale = [1, 1]; + if (path) { + path.brush(ctx); + } + + var ImageShape = __webpack_require__(59); + var imgShape = new ImageShape({ + id: id, + style: { + x: 0, + y: 0, + image: canvas + } + }); + + if (pathTransform.position != null) { + imgShape.position = path.position = pathTransform.position; + } + + if (pathTransform.rotation != null) { + imgShape.rotation = path.rotation = pathTransform.rotation; + } + + if (pathTransform.scale != null) { + imgShape.scale = path.scale = pathTransform.scale; + } + + return imgShape; + }, + + _createPathToImage: function () { + var me = this; + + return function (id, e, width, height) { + return me._pathToImage( + id, e, width, height, me.dpr + ); + }; + } + }; + + module.exports = Painter; + + + +/***/ }, +/* 86 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module zrender/Layer + * @author pissang(https://www.github.com/pissang) + */ + + + var util = __webpack_require__(3); + var config = __webpack_require__(40); + + function returnFalse() { + return false; + } + + /** + * 创建dom + * + * @inner + * @param {string} id dom id 待用 + * @param {string} type dom type,such as canvas, div etc. + * @param {Painter} painter painter instance + * @param {number} number + */ + function createDom(id, type, painter, dpr) { + var newDom = document.createElement(type); + var width = painter.getWidth(); + var height = painter.getHeight(); + + var newDomStyle = newDom.style; + // 没append呢,请原谅我这样写,清晰~ + newDomStyle.position = 'absolute'; + newDomStyle.left = 0; + newDomStyle.top = 0; + newDomStyle.width = width + 'px'; + newDomStyle.height = height + 'px'; + newDom.width = width * dpr; + newDom.height = height * dpr; + + // id不作为索引用,避免可能造成的重名,定义为私有属性 + newDom.setAttribute('data-zr-dom-id', id); + return newDom; + } + + /** + * @alias module:zrender/Layer + * @constructor + * @extends module:zrender/mixin/Transformable + * @param {string} id + * @param {module:zrender/Painter} painter + * @param {number} [dpr] + */ + var Layer = function(id, painter, dpr) { + var dom; + dpr = dpr || config.devicePixelRatio; + if (typeof id === 'string') { + dom = createDom(id, 'canvas', painter, dpr); + } + // Not using isDom because in node it will return false + else if (util.isObject(id)) { + dom = id; + id = dom.id; + } + this.id = id; + this.dom = dom; + + var domStyle = dom.style; + if (domStyle) { // Not in node + dom.onselectstart = returnFalse; // 避免页面选中的尴尬 + domStyle['-webkit-user-select'] = 'none'; + domStyle['user-select'] = 'none'; + domStyle['-webkit-touch-callout'] = 'none'; + domStyle['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)'; + } + + this.domBack = null; + this.ctxBack = null; + + this.painter = painter; + + this.config = null; + + // Configs + /** + * 每次清空画布的颜色 + * @type {string} + * @default 0 + */ + this.clearColor = 0; + /** + * 是否开启动态模糊 + * @type {boolean} + * @default false + */ + this.motionBlur = false; + /** + * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 + * @type {number} + * @default 0.7 + */ + this.lastFrameAlpha = 0.7; + + /** + * Layer dpr + * @type {number} + */ + this.dpr = dpr; + }; + + Layer.prototype = { + + constructor: Layer, + + elCount: 0, + + __dirty: true, + + initContext: function () { + this.ctx = this.dom.getContext('2d'); + + var dpr = this.dpr; + if (dpr != 1) { + this.ctx.scale(dpr, dpr); + } + }, + + createBackBuffer: function () { + var dpr = this.dpr; + + this.domBack = createDom('back-' + this.id, 'canvas', this.painter, dpr); + this.ctxBack = this.domBack.getContext('2d'); + + if (dpr != 1) { + this.ctxBack.scale(dpr, dpr); + } + }, + + /** + * @param {number} width + * @param {number} height + */ + resize: function (width, height) { + var dpr = this.dpr; + + var dom = this.dom; + var domStyle = dom.style; + var domBack = this.domBack; + + domStyle.width = width + 'px'; + domStyle.height = height + 'px'; + + dom.width = width * dpr; + dom.height = height * dpr; + + if (dpr != 1) { + this.ctx.scale(dpr, dpr); + } + + if (domBack) { + domBack.width = width * dpr; + domBack.height = height * dpr; + + if (dpr != 1) { + this.ctxBack.scale(dpr, dpr); + } + } + }, + + /** + * 清空该层画布 + * @param {boolean} clearAll Clear all with out motion blur + */ + clear: function (clearAll) { + var dom = this.dom; + var ctx = this.ctx; + var width = dom.width; + var height = dom.height; + + var haveClearColor = this.clearColor; + var haveMotionBLur = this.motionBlur && !clearAll; + var lastFrameAlpha = this.lastFrameAlpha; + + var dpr = this.dpr; + + if (haveMotionBLur) { + if (!this.domBack) { + this.createBackBuffer(); + } + + this.ctxBack.globalCompositeOperation = 'copy'; + this.ctxBack.drawImage( + dom, 0, 0, + width / dpr, + height / dpr + ); + } + + ctx.clearRect(0, 0, width / dpr, height / dpr); + if (haveClearColor) { + ctx.save(); + ctx.fillStyle = this.clearColor; + ctx.fillRect(0, 0, width / dpr, height / dpr); + ctx.restore(); + } + + if (haveMotionBLur) { + var domBack = this.domBack; + ctx.save(); + ctx.globalAlpha = lastFrameAlpha; + ctx.drawImage(domBack, 0, 0, width / dpr, height / dpr); + ctx.restore(); + } + } + }; + + module.exports = Layer; + + +/***/ }, +/* 87 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + var PI = Math.PI; + /** + * @param {module:echarts/ExtensionAPI} api + * @param {Object} [opts] + * @param {string} [opts.text] + * @param {string} [opts.color] + * @param {string} [opts.textColor] + * @return {module:zrender/Element} + */ + module.exports = function (api, opts) { + opts = opts || {}; + zrUtil.defaults(opts, { + text: 'loading', + color: '#c23531', + textColor: '#000', + maskColor: 'rgba(255, 255, 255, 0.8)', + zlevel: 0 + }); + var mask = new graphic.Rect({ + style: { + fill: opts.maskColor + }, + zlevel: opts.zlevel, + z: 10000 + }); + var arc = new graphic.Arc({ + shape: { + startAngle: -PI / 2, + endAngle: -PI / 2 + 0.1, + r: 10 + }, + style: { + stroke: opts.color, + lineCap: 'round', + lineWidth: 5 + }, + zlevel: opts.zlevel, + z: 10001 + }); + var labelRect = new graphic.Rect({ + style: { + fill: 'none', + text: opts.text, + textPosition: 'right', + textDistance: 10, + textFill: opts.textColor + }, + zlevel: opts.zlevel, + z: 10001 + }); + + arc.animateShape(true) + .when(1000, { + endAngle: PI * 3 / 2 + }) + .start('circularInOut'); + arc.animateShape(true) + .when(1000, { + startAngle: PI * 3 / 2 + }) + .delay(300) + .start('circularInOut'); + + var group = new graphic.Group(); + group.add(arc); + group.add(labelRect); + group.add(mask); + // Inject resize + group.resize = function () { + var cx = api.getWidth() / 2; + var cy = api.getHeight() / 2; + arc.setShape({ + cx: cx, + cy: cy + }); + var r = arc.shape.r; + labelRect.setShape({ + x: cx - r, + y: cy - r, + width: r * 2, + height: r * 2 + }); + + mask.setShape({ + x: 0, + y: 0, + width: api.getWidth(), + height: api.getHeight() + }); + }; + group.resize(); + return group; + }; + + +/***/ }, +/* 88 */ +/***/ function(module, exports, __webpack_require__) { + + + var Gradient = __webpack_require__(4); + module.exports = function (seriesType, styleType, ecModel) { + function encodeColor(seriesModel) { + var colorAccessPath = [styleType, 'normal', 'color']; + var colorList = ecModel.get('color'); + var data = seriesModel.getData(); + var color = seriesModel.get(colorAccessPath) // Set in itemStyle + || colorList[seriesModel.seriesIndex % colorList.length]; // Default color + + // FIXME Set color function or use the platte color + data.setVisual('color', color); + + // Only visible series has each data be visual encoded + if (!ecModel.isSeriesFiltered(seriesModel)) { + if (typeof color === 'function' && !(color instanceof Gradient)) { + data.each(function (idx) { + data.setItemVisual( + idx, 'color', color(seriesModel.getDataParams(idx)) + ); + }); + } + + data.each(function (idx) { + var itemModel = data.getItemModel(idx); + var color = itemModel.get(colorAccessPath, true); + if (color != null) { + data.setItemVisual(idx, 'color', color); + } + }); + } + } + seriesType ? ecModel.eachSeriesByType(seriesType, encodeColor) + : ecModel.eachSeries(encodeColor); + }; + + +/***/ }, +/* 89 */ +/***/ function(module, exports, __webpack_require__) { + + // Compatitable with 2.0 + + + var zrUtil = __webpack_require__(3); + var compatStyle = __webpack_require__(90); + + function get(opt, path) { + path = path.split(','); + var obj = opt; + for (var i = 0; i < path.length; i++) { + obj = obj && obj[path[i]]; + if (obj == null) { + break; + } + } + return obj; + } + + function set(opt, path, val, overwrite) { + path = path.split(','); + var obj = opt; + var key; + for (var i = 0; i < path.length - 1; i++) { + key = path[i]; + if (obj[key] == null) { + obj[key] = {}; + } + obj = obj[key]; + } + if (overwrite || obj[path[i]] == null) { + obj[path[i]] = val; + } + } + + function compatLayoutProperties(option) { + each(LAYOUT_PROPERTIES, function (prop) { + if (prop[0] in option && !(prop[1] in option)) { + option[prop[1]] = option[prop[0]]; + } + }); + } + + var LAYOUT_PROPERTIES = [ + ['x', 'left'], ['y', 'top'], ['x2', 'right'], ['y2', 'bottom'] + ]; + + var COMPATITABLE_COMPONENTS = [ + 'grid', 'geo', 'parallel', 'legend', 'toolbox', 'title', 'visualMap', 'dataZoom', 'timeline' + ]; + + var COMPATITABLE_SERIES = [ + 'bar', 'boxplot', 'candlestick', 'chord', 'effectScatter', + 'funnel', 'gauge', 'lines', 'graph', 'heatmap', 'line', 'map', 'parallel', + 'pie', 'radar', 'sankey', 'scatter', 'treemap' + ]; + + var each = zrUtil.each; + + module.exports = function (option) { + each(option.series, function (seriesOpt) { + if (!zrUtil.isObject(seriesOpt)) { + return; + } + + var seriesType = seriesOpt.type; + + compatStyle(seriesOpt); + + if (seriesType === 'pie' || seriesType === 'gauge') { + if (seriesOpt.clockWise != null) { + seriesOpt.clockwise = seriesOpt.clockWise; + } + } + if (seriesType === 'gauge') { + var pointerColor = get(seriesOpt, 'pointer.color'); + pointerColor != null + && set(seriesOpt, 'itemStyle.normal.color', pointerColor); + } + + for (var i = 0; i < COMPATITABLE_SERIES.length; i++) { + if (COMPATITABLE_SERIES[i] === seriesOpt.type) { + compatLayoutProperties(seriesOpt); + break; + } + } + }); + + // dataRange has changed to visualMap + if (option.dataRange) { + option.visualMap = option.dataRange; + } + + each(COMPATITABLE_COMPONENTS, function (componentName) { + var options = option[componentName]; + if (options) { + if (!zrUtil.isArray(options)) { + options = [options]; + } + each(options, function (option) { + compatLayoutProperties(option); + }); + } + }); + }; + + +/***/ }, +/* 90 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + var POSSIBLE_STYLES = [ + 'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle', + 'chordStyle', 'label', 'labelLine' + ]; + + function compatItemStyle(opt) { + var itemStyleOpt = opt && opt.itemStyle; + if (itemStyleOpt) { + zrUtil.each(POSSIBLE_STYLES, function (styleName) { + var normalItemStyleOpt = itemStyleOpt.normal; + var emphasisItemStyleOpt = itemStyleOpt.emphasis; + if (normalItemStyleOpt && normalItemStyleOpt[styleName]) { + opt[styleName] = opt[styleName] || {}; + if (!opt[styleName].normal) { + opt[styleName].normal = normalItemStyleOpt[styleName]; + } + else { + zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]); + } + normalItemStyleOpt[styleName] = null; + } + if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) { + opt[styleName] = opt[styleName] || {}; + if (!opt[styleName].emphasis) { + opt[styleName].emphasis = emphasisItemStyleOpt[styleName]; + } + else { + zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]); + } + emphasisItemStyleOpt[styleName] = null; + } + }); + } + } + + module.exports = function (seriesOpt) { + if (!seriesOpt) { + return; + } + compatItemStyle(seriesOpt); + compatItemStyle(seriesOpt.markPoint); + compatItemStyle(seriesOpt.markLine); + var data = seriesOpt.data; + if (data) { + for (var i = 0; i < data.length; i++) { + compatItemStyle(data[i]); + } + // mark point data + var markPoint = seriesOpt.markPoint; + if (markPoint && markPoint.data) { + var mpData = markPoint.data; + for (var i = 0; i < mpData.length; i++) { + compatItemStyle(mpData[i]); + } + } + // mark line data + var markLine = seriesOpt.markLine; + if (markLine && markLine.data) { + var mlData = markLine.data; + for (var i = 0; i < mlData.length; i++) { + if (zrUtil.isArray(mlData[i])) { + compatItemStyle(mlData[i][0]); + compatItemStyle(mlData[i][1]); + } + else { + compatItemStyle(mlData[i]); + } + } + } + } + }; + + +/***/ }, +/* 91 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var echarts = __webpack_require__(1); + + __webpack_require__(92); + __webpack_require__(97); + + echarts.registerVisualCoding('chart', zrUtil.curry( + __webpack_require__(103), 'line', 'circle', 'line' + )); + echarts.registerLayout(zrUtil.curry( + __webpack_require__(104), 'line' + )); + + // Down sample after filter + echarts.registerProcessor('statistic', zrUtil.curry( + __webpack_require__(105), 'line' + )); + + // In case developer forget to include grid component + __webpack_require__(106); + + +/***/ }, +/* 92 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var createListFromArray = __webpack_require__(93); + var SeriesModel = __webpack_require__(27); + + module.exports = SeriesModel.extend({ + + type: 'series.line', + + dependencies: ['grid', 'polar'], + + getInitialData: function (option, ecModel) { + return createListFromArray(option.data, this, ecModel); + }, + + defaultOption: { + zlevel: 0, // 一级层叠 + z: 2, // 二级层叠 + coordinateSystem: 'cartesian2d', + legendHoverLink: true, + + hoverAnimation: true, + // stack: null + xAxisIndex: 0, + yAxisIndex: 0, + + polarIndex: 0, + + // If clip the overflow value + clipOverflow: true, + + label: { + normal: { + // show: false, + position: 'top' + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 + // 'inside'|'left'|'right'|'top'|'bottom' + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + } + // emphasis: { + // show: false, + // position: 'top' + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 + // 'inside'|'left'|'right'|'top'|'bottom' + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + // } + }, + // itemStyle: { + // normal: { + // // color: 各异 + // }, + // emphasis: { + // // color: 各异, + // } + // }, + lineStyle: { + normal: { + width: 2, + type: 'solid' + } + }, + // areaStyle: { + // }, + // smooth: false, + // smoothMonotone: null, + // 拐点图形类型 + symbol: 'emptyCircle', + // 拐点图形大小 + symbolSize: 4, + // 拐点图形旋转控制 + // symbolRotate: null, + + // 是否显示 symbol, 只有在 tooltip hover 的时候显示 + showSymbol: true, + // 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略) + // showAllSymbol: false + // + // 大数据过滤,'average', 'max', 'min', 'sum' + // sampling: 'none' + + animationEasing: 'linear' + } + }); + + +/***/ }, +/* 93 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var List = __webpack_require__(94); + var completeDimensions = __webpack_require__(96); + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var CoordinateSystem = __webpack_require__(25); + var getDataItemValue = modelUtil.getDataItemValue; + var converDataValue = modelUtil.converDataValue; + + function firstDataNotNull(data) { + var i = 0; + while (i < data.length && data[i] == null) { + i++; + } + return data[i]; + } + function ifNeedCompleteOrdinalData(data) { + var sampleItem = firstDataNotNull(data); + return sampleItem != null + && !zrUtil.isArray(getDataItemValue(sampleItem)); + } + + /** + * Helper function to create a list from option data + */ + function createListFromArray(data, seriesModel, ecModel) { + // If data is undefined + data = data || []; + + var coordSysName = seriesModel.get('coordinateSystem'); + var creator = creators[coordSysName]; + var registeredCoordSys = CoordinateSystem.get(coordSysName); + // FIXME + var result = creator && creator(data, seriesModel, ecModel); + var dimensions = result && result.dimensions; + if (!dimensions) { + // Get dimensions from registered coordinate system + dimensions = (registeredCoordSys && registeredCoordSys.dimensions) || ['x', 'y']; + dimensions = completeDimensions(dimensions, data, dimensions.concat(['value'])); + } + var categoryAxisModel = result && result.categoryAxisModel; + + var categoryDimIndex = dimensions[0].type === 'ordinal' + ? 0 : (dimensions[1].type === 'ordinal' ? 1 : -1); + + var list = new List(dimensions, seriesModel); + + var nameList = createNameList(result, data); + + var dimValueGetter = (categoryAxisModel && ifNeedCompleteOrdinalData(data)) + ? function (itemOpt, dimName, dataIndex, dimIndex) { + // Use dataIndex as ordinal value in categoryAxis + return dimIndex === categoryDimIndex + ? dataIndex + : converDataValue(getDataItemValue(itemOpt), dimensions[dimIndex]); + } + : function (itemOpt, dimName, dataIndex, dimIndex) { + var val = getDataItemValue(itemOpt); + return converDataValue(val && val[dimIndex], dimensions[dimIndex]); + }; + + list.initData(data, nameList, dimValueGetter); + + return list; + } + + function isStackable(axisType) { + return axisType !== 'category' && axisType !== 'time'; + } + + function getDimTypeByAxis(axisType) { + return axisType === 'category' + ? 'ordinal' + : axisType === 'time' + ? 'time' + : 'float'; + } + + /** + * Creaters for each coord system. + * @return {Object} {dimensions, categoryAxisModel}; + */ + var creators = { + + cartesian2d: function (data, seriesModel, ecModel) { + var xAxisModel = ecModel.getComponent('xAxis', seriesModel.get('xAxisIndex')); + var yAxisModel = ecModel.getComponent('yAxis', seriesModel.get('yAxisIndex')); + var xAxisType = xAxisModel.get('type'); + var yAxisType = yAxisModel.get('type'); + + var dimensions = [ + { + name: 'x', + type: getDimTypeByAxis(xAxisType), + stackable: isStackable(xAxisType) + }, + { + name: 'y', + // If two category axes + type: getDimTypeByAxis(yAxisType), + stackable: isStackable(yAxisType) + } + ]; + + completeDimensions(dimensions, data, ['x', 'y', 'z']); + + return { + dimensions: dimensions, + categoryAxisModel: xAxisType === 'category' + ? xAxisModel + : (yAxisType === 'category' ? yAxisModel : null) + }; + }, + + polar: function (data, seriesModel, ecModel) { + var polarIndex = seriesModel.get('polarIndex') || 0; + + var axisFinder = function (axisModel) { + return axisModel.get('polarIndex') === polarIndex; + }; + + var angleAxisModel = ecModel.findComponents({ + mainType: 'angleAxis', filter: axisFinder + })[0]; + var radiusAxisModel = ecModel.findComponents({ + mainType: 'radiusAxis', filter: axisFinder + })[0]; + + var radiusAxisType = radiusAxisModel.get('type'); + var angleAxisType = angleAxisModel.get('type'); + + var dimensions = [ + { + name: 'radius', + type: getDimTypeByAxis(radiusAxisType), + stackable: isStackable(radiusAxisType) + }, + { + name: 'angle', + type: getDimTypeByAxis(angleAxisType), + stackable: isStackable(angleAxisType) + } + ]; + + completeDimensions(dimensions, data, ['radius', 'angle', 'value']); + + return { + dimensions: dimensions, + categoryAxisModel: angleAxisType === 'category' + ? angleAxisModel + : (radiusAxisType === 'category' ? radiusAxisModel : null) + }; + }, + + geo: function (data, seriesModel, ecModel) { + // TODO Region + // 多个散点图系列在同一个地区的时候 + return { + dimensions: completeDimensions([ + {name: 'lng'}, + {name: 'lat'} + ], data, ['lng', 'lat', 'value']) + }; + } + }; + + function createNameList(result, data) { + var nameList = []; + + if (result && result.categoryAxisModel) { + // FIXME Two category axis + var categories = result.categoryAxisModel.getCategories(); + if (categories) { + var dataLen = data.length; + // Ordered data is given explicitly like + // [[3, 0.2], [1, 0.3], [2, 0.15]] + // or given scatter data, + // pick the category + if (zrUtil.isArray(data[0]) && data[0].length > 1) { + nameList = []; + for (var i = 0; i < dataLen; i++) { + nameList[i] = categories[data[i][0]]; + } + } + else { + nameList = categories.slice(0); + } + } + } + + return nameList; + } + + module.exports = createListFromArray; + + + +/***/ }, +/* 94 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global) {/** + * List for data storage + * @module echarts/data/List + */ + + + var UNDEFINED = 'undefined'; + var globalObj = typeof window === 'undefined' ? global : window; + var Float64Array = typeof globalObj.Float64Array === UNDEFINED + ? Array : globalObj.Float64Array; + var Int32Array = typeof globalObj.Int32Array === UNDEFINED + ? Array : globalObj.Int32Array; + + var dataCtors = { + 'float': Float64Array, + 'int': Int32Array, + // Ordinal data type can be string or int + 'ordinal': Array, + 'number': Array, + 'time': Array + }; + + var Model = __webpack_require__(8); + var DataDiffer = __webpack_require__(95); + + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var isObject = zrUtil.isObject; + + var IMMUTABLE_PROPERTIES = [ + 'stackedOn', '_nameList', '_idList', '_rawData' + ]; + + var transferImmuProperties = function (a, b, wrappedMethod) { + zrUtil.each(IMMUTABLE_PROPERTIES.concat(wrappedMethod || []), function (propName) { + if (b.hasOwnProperty(propName)) { + a[propName] = b[propName]; + } + }); + }; + + /** + * @constructor + * @alias module:echarts/data/List + * + * @param {Array.} dimensions + * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius + * @param {module:echarts/model/Model} hostModel + */ + var List = function (dimensions, hostModel) { + + dimensions = dimensions || ['x', 'y']; + + var dimensionInfos = {}; + var dimensionNames = []; + for (var i = 0; i < dimensions.length; i++) { + var dimensionName; + var dimensionInfo = {}; + if (typeof dimensions[i] === 'string') { + dimensionName = dimensions[i]; + dimensionInfo = { + name: dimensionName, + stackable: false, + // Type can be 'float', 'int', 'number' + // Default is number, Precision of float may not enough + type: 'number' + }; + } + else { + dimensionInfo = dimensions[i]; + dimensionName = dimensionInfo.name; + dimensionInfo.type = dimensionInfo.type || 'number'; + } + dimensionNames.push(dimensionName); + dimensionInfos[dimensionName] = dimensionInfo; + } + /** + * @readOnly + * @type {Array.} + */ + this.dimensions = dimensionNames; + + /** + * Infomation of each data dimension, like data type. + * @type {Object} + */ + this._dimensionInfos = dimensionInfos; + + /** + * @type {module:echarts/model/Model} + */ + this.hostModel = hostModel; + + /** + * Indices stores the indices of data subset after filtered. + * This data subset will be used in chart. + * @type {Array.} + * @readOnly + */ + this.indices = []; + + /** + * Data storage + * @type {Object.} + * @private + */ + this._storage = {}; + + /** + * @type {Array.} + */ + this._nameList = []; + /** + * @type {Array.} + */ + this._idList = []; + /** + * Models of data option is stored sparse for optimizing memory cost + * @type {Array.} + * @private + */ + this._optionModels = []; + + /** + * @param {module:echarts/data/List} + */ + this.stackedOn = null; + + /** + * Global visual properties after visual coding + * @type {Object} + * @private + */ + this._visual = {}; + + /** + * Globel layout properties. + * @type {Object} + * @private + */ + this._layout = {}; + + /** + * Item visual properties after visual coding + * @type {Array.} + * @private + */ + this._itemVisuals = []; + + /** + * Item layout properties after layout + * @type {Array.} + * @private + */ + this._itemLayouts = []; + + /** + * Graphic elemnents + * @type {Array.} + * @private + */ + this._graphicEls = []; + + /** + * @type {Array.} + * @private + */ + this._rawData; + + /** + * @type {Object} + * @private + */ + this._extent; + }; + + var listProto = List.prototype; + + listProto.type = 'list'; + + /** + * Get dimension name + * @param {string|number} dim + * Dimension can be concrete names like x, y, z, lng, lat, angle, radius + * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius' + */ + listProto.getDimension = function (dim) { + if (!isNaN(dim)) { + dim = this.dimensions[dim] || dim; + } + return dim; + }; + /** + * Get type and stackable info of particular dimension + * @param {string|number} dim + * Dimension can be concrete names like x, y, z, lng, lat, angle, radius + * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius' + */ + listProto.getDimensionInfo = function (dim) { + return zrUtil.clone(this._dimensionInfos[this.getDimension(dim)]); + }; + + /** + * Initialize from data + * @param {Array.} data + * @param {Array.} [nameList] + * @param {Function} [dimValueGetter] (dataItem, dimName, dataIndex, dimIndex) => number + */ + listProto.initData = function (data, nameList, dimValueGetter) { + data = data || []; + + this._rawData = data; + + // Clear + var storage = this._storage = {}; + var indices = this.indices = []; + + var dimensions = this.dimensions; + var size = data.length; + var dimensionInfoMap = this._dimensionInfos; + + var idList = []; + var nameRepeatCount = {}; + + nameList = nameList || []; + + // Init storage + for (var i = 0; i < dimensions.length; i++) { + var dimInfo = dimensionInfoMap[dimensions[i]]; + var DataCtor = dataCtors[dimInfo.type]; + storage[dimensions[i]] = new DataCtor(size); + } + + // Default dim value getter + dimValueGetter = dimValueGetter || function (dataItem, dimName, dataIndex, dimIndex) { + var value = modelUtil.getDataItemValue(dataItem); + return modelUtil.converDataValue( + zrUtil.isArray(value) + ? value[dimIndex] + // If value is a single number or something else not array. + : value, + dimensionInfoMap[dimName] + ); + }; + + for (var idx = 0; idx < data.length; idx++) { + var dataItem = data[idx]; + // Each data item is value + // [1, 2] + // 2 + // Bar chart, line chart which uses category axis + // only gives the 'y' value. 'x' value is the indices of cateogry + // Use a tempValue to normalize the value to be a (x, y) value + + // Store the data by dimensions + for (var k = 0; k < dimensions.length; k++) { + var dim = dimensions[k]; + var dimStorage = storage[dim]; + // PENDING NULL is empty or zero + dimStorage[idx] = dimValueGetter(dataItem, dim, idx, k); + } + + indices.push(idx); + } + + // Use the name in option and create id + for (var i = 0; i < data.length; i++) { + var id = ''; + if (!nameList[i]) { + nameList[i] = data[i].name; + // Try using the id in option + id = data[i].id; + } + var name = nameList[i] || ''; + if (!id && name) { + // Use name as id and add counter to avoid same name + nameRepeatCount[name] = nameRepeatCount[name] || 0; + id = name; + if (nameRepeatCount[name] > 0) { + id += '__ec__' + nameRepeatCount[name]; + } + nameRepeatCount[name]++; + } + id && (idList[i] = id); + } + + this._nameList = nameList; + this._idList = idList; + }; + + /** + * @return {number} + */ + listProto.count = function () { + return this.indices.length; + }; + + /** + * Get value. Return NaN if idx is out of range. + * @param {string} dim Dim must be concrete name. + * @param {number} idx + * @param {boolean} stack + * @return {number} + */ + listProto.get = function (dim, idx, stack) { + var storage = this._storage; + var dataIndex = this.indices[idx]; + + // If value not exists + if (dataIndex == null) { + return NaN; + } + + var value = storage[dim] && storage[dim][dataIndex]; + // FIXME ordinal data type is not stackable + if (stack) { + var dimensionInfo = this._dimensionInfos[dim]; + if (dimensionInfo && dimensionInfo.stackable) { + var stackedOn = this.stackedOn; + while (stackedOn) { + // Get no stacked data of stacked on + var stackedValue = stackedOn.get(dim, idx); + // Considering positive stack, negative stack and empty data + if ((value >= 0 && stackedValue > 0) // Positive stack + || (value <= 0 && stackedValue < 0) // Negative stack + ) { + value += stackedValue; + } + stackedOn = stackedOn.stackedOn; + } + } + } + return value; + }; + + /** + * Get value for multi dimensions. + * @param {Array.} [dimensions] If ignored, using all dimensions. + * @param {number} idx + * @param {boolean} stack + * @return {number} + */ + listProto.getValues = function (dimensions, idx, stack) { + var values = []; + + if (!zrUtil.isArray(dimensions)) { + stack = idx; + idx = dimensions; + dimensions = this.dimensions; + } + + for (var i = 0, len = dimensions.length; i < len; i++) { + values.push(this.get(dimensions[i], idx, stack)); + } + + return values; + }; + + /** + * If value is NaN. Inlcuding '-' + * @param {string} dim + * @param {number} idx + * @return {number} + */ + listProto.hasValue = function (idx) { + var dimensions = this.dimensions; + var dimensionInfos = this._dimensionInfos; + for (var i = 0, len = dimensions.length; i < len; i++) { + if ( + // Ordinal type can be string or number + dimensionInfos[dimensions[i]].type !== 'ordinal' + && isNaN(this.get(dimensions[i], idx)) + ) { + return false; + } + } + return true; + }; + + /** + * Get extent of data in one dimension + * @param {string} dim + * @param {boolean} stack + */ + listProto.getDataExtent = function (dim, stack) { + var dimData = this._storage[dim]; + var dimInfo = this.getDimensionInfo(dim); + stack = (dimInfo && dimInfo.stackable) && stack; + var dimExtent = (this._extent || (this._extent = {}))[dim + (!!stack)]; + var value; + if (dimExtent) { + return dimExtent; + } + // var dimInfo = this._dimensionInfos[dim]; + if (dimData) { + var min = Infinity; + var max = -Infinity; + // var isOrdinal = dimInfo.type === 'ordinal'; + for (var i = 0, len = this.count(); i < len; i++) { + value = this.get(dim, i, stack); + // FIXME + // if (isOrdinal && typeof value === 'string') { + // value = zrUtil.indexOf(dimData, value); + // console.log(value); + // } + value < min && (min = value); + value > max && (max = value); + } + return (this._extent[dim + stack] = [min, max]); + } + else { + return [Infinity, -Infinity]; + } + }; + + /** + * Get sum of data in one dimension + * @param {string} dim + * @param {boolean} stack + */ + listProto.getSum = function (dim, stack) { + var dimData = this._storage[dim]; + var sum = 0; + if (dimData) { + for (var i = 0, len = this.count(); i < len; i++) { + var value = this.get(dim, i, stack); + if (!isNaN(value)) { + sum += value; + } + } + } + return sum; + }; + + /** + * Retreive the index with given value + * @param {number} idx + * @param {number} value + * @return {number} + */ + // FIXME Precision of float value + listProto.indexOf = function (dim, value) { + var storage = this._storage; + var dimData = storage[dim]; + var indices = this.indices; + + if (dimData) { + for (var i = 0, len = indices.length; i < len; i++) { + var rawIndex = indices[i]; + if (dimData[rawIndex] === value) { + return i; + } + } + } + return -1; + }; + + /** + * Retreive the index with given name + * @param {number} idx + * @param {number} name + * @return {number} + */ + listProto.indexOfName = function (name) { + var indices = this.indices; + var nameList = this._nameList; + + for (var i = 0, len = indices.length; i < len; i++) { + var rawIndex = indices[i]; + if (nameList[rawIndex] === name) { + return i; + } + } + + return -1; + }; + + /** + * Retreive the index of nearest value + * @param {string>} dim + * @param {number} value + * @param {boolean} stack If given value is after stacked + * @return {number} + */ + listProto.indexOfNearest = function (dim, value, stack) { + var storage = this._storage; + var dimData = storage[dim]; + + if (dimData) { + var minDist = Number.MAX_VALUE; + var nearestIdx = -1; + for (var i = 0, len = this.count(); i < len; i++) { + var dist = Math.abs(this.get(dim, i, stack) - value); + if (dist <= minDist) { + minDist = dist; + nearestIdx = i; + } + } + return nearestIdx; + } + return -1; + }; + + /** + * Get raw data index + * @param {number} idx + * @return {number} + */ + listProto.getRawIndex = function (idx) { + var rawIdx = this.indices[idx]; + return rawIdx == null ? -1 : rawIdx; + }; + + /** + * @param {number} idx + * @param {boolean} [notDefaultIdx=false] + * @return {string} + */ + listProto.getName = function (idx) { + return this._nameList[this.indices[idx]] || ''; + }; + + /** + * @param {number} idx + * @param {boolean} [notDefaultIdx=false] + * @return {string} + */ + listProto.getId = function (idx) { + return this._idList[this.indices[idx]] || (this.getRawIndex(idx) + ''); + }; + + + function normalizeDimensions(dimensions) { + if (!zrUtil.isArray(dimensions)) { + dimensions = [dimensions]; + } + return dimensions; + } + + /** + * Data iteration + * @param {string|Array.} + * @param {Function} cb + * @param {boolean} [stack=false] + * @param {*} [context=this] + * + * @example + * list.each('x', function (x, idx) {}); + * list.each(['x', 'y'], function (x, y, idx) {}); + * list.each(function (idx) {}) + */ + listProto.each = function (dimensions, cb, stack, context) { + if (typeof dimensions === 'function') { + context = stack; + stack = cb; + cb = dimensions; + dimensions = []; + } + + dimensions = zrUtil.map( + normalizeDimensions(dimensions), this.getDimension, this + ); + + var value = []; + var dimSize = dimensions.length; + var indices = this.indices; + + context = context || this; + + for (var i = 0; i < indices.length; i++) { + if (dimSize === 0) { + cb.call(context, i); + } + // Simple optimization + else if (dimSize === 1) { + cb.call(context, this.get(dimensions[0], i, stack), i); + } + else { + for (var k = 0; k < dimSize; k++) { + value[k] = this.get(dimensions[k], i, stack); + } + // Index + value[k] = i; + cb.apply(context, value); + } + } + }; + + /** + * Data filter + * @param {string|Array.} + * @param {Function} cb + * @param {boolean} [stack=false] + * @param {*} [context=this] + */ + listProto.filterSelf = function (dimensions, cb, stack, context) { + if (typeof dimensions === 'function') { + context = stack; + stack = cb; + cb = dimensions; + dimensions = []; + } + + dimensions = zrUtil.map( + normalizeDimensions(dimensions), this.getDimension, this + ); + + var newIndices = []; + var value = []; + var dimSize = dimensions.length; + var indices = this.indices; + + context = context || this; + + for (var i = 0; i < indices.length; i++) { + var keep; + // Simple optimization + if (dimSize === 1) { + keep = cb.call( + context, this.get(dimensions[0], i, stack), i + ); + } + else { + for (var k = 0; k < dimSize; k++) { + value[k] = this.get(dimensions[k], i, stack); + } + value[k] = i; + keep = cb.apply(context, value); + } + if (keep) { + newIndices.push(indices[i]); + } + } + + this.indices = newIndices; + + // Reset data extent + this._extent = {}; + + return this; + }; + + /** + * Data mapping to a plain array + * @param {string|Array.} [dimensions] + * @param {Function} cb + * @param {boolean} [stack=false] + * @param {*} [context=this] + * @return {Array} + */ + listProto.mapArray = function (dimensions, cb, stack, context) { + if (typeof dimensions === 'function') { + context = stack; + stack = cb; + cb = dimensions; + dimensions = []; + } + + var result = []; + this.each(dimensions, function () { + result.push(cb && cb.apply(this, arguments)); + }, stack, context); + return result; + }; + + function cloneListForMapAndSample(original, excludeDimensions) { + var allDimensions = original.dimensions; + var list = new List( + zrUtil.map(allDimensions, original.getDimensionInfo, original), + original.hostModel + ); + // FIXME If needs stackedOn, value may already been stacked + transferImmuProperties(list, original, original._wrappedMethods); + + var storage = list._storage = {}; + var originalStorage = original._storage; + // Init storage + for (var i = 0; i < allDimensions.length; i++) { + var dim = allDimensions[i]; + var dimStore = originalStorage[dim]; + if (zrUtil.indexOf(excludeDimensions, dim) >= 0) { + storage[dim] = new dimStore.constructor( + originalStorage[dim].length + ); + } + else { + // Direct reference for other dimensions + storage[dim] = originalStorage[dim]; + } + } + return list; + } + + /** + * Data mapping to a new List with given dimensions + * @param {string|Array.} dimensions + * @param {Function} cb + * @param {boolean} [stack=false] + * @param {*} [context=this] + * @return {Array} + */ + listProto.map = function (dimensions, cb, stack, context) { + dimensions = zrUtil.map( + normalizeDimensions(dimensions), this.getDimension, this + ); + + var list = cloneListForMapAndSample(this, dimensions); + // Following properties are all immutable. + // So we can reference to the same value + var indices = list.indices = this.indices; + + var storage = list._storage; + + var tmpRetValue = []; + this.each(dimensions, function () { + var idx = arguments[arguments.length - 1]; + var retValue = cb && cb.apply(this, arguments); + if (retValue != null) { + // a number + if (typeof retValue === 'number') { + tmpRetValue[0] = retValue; + retValue = tmpRetValue; + } + for (var i = 0; i < retValue.length; i++) { + var dim = dimensions[i]; + var dimStore = storage[dim]; + var rawIdx = indices[idx]; + if (dimStore) { + dimStore[rawIdx] = retValue[i]; + } + } + } + }, stack, context); + + return list; + }; + + /** + * Large data down sampling on given dimension + * @param {string} dimension + * @param {number} rate + * @param {Function} sampleValue + * @param {Function} sampleIndex Sample index for name and id + */ + listProto.downSample = function (dimension, rate, sampleValue, sampleIndex) { + var list = cloneListForMapAndSample(this, [dimension]); + var storage = this._storage; + var targetStorage = list._storage; + + var originalIndices = this.indices; + var indices = list.indices = []; + + var frameValues = []; + var frameIndices = []; + var frameSize = Math.floor(1 / rate); + + var dimStore = targetStorage[dimension]; + var len = this.count(); + // Copy data from original data + for (var i = 0; i < storage[dimension].length; i++) { + targetStorage[dimension][i] = storage[dimension][i]; + } + for (var i = 0; i < len; i += frameSize) { + // Last frame + if (frameSize > len - i) { + frameSize = len - i; + frameValues.length = frameSize; + } + for (var k = 0; k < frameSize; k++) { + var idx = originalIndices[i + k]; + frameValues[k] = dimStore[idx]; + frameIndices[k] = idx; + } + var value = sampleValue(frameValues); + var idx = frameIndices[sampleIndex(frameValues, value) || 0]; + // Only write value on the filtered data + dimStore[idx] = value; + indices.push(idx); + } + return list; + }; + + /** + * Get model of one data item. + * + * @param {number} idx + */ + // FIXME Model proxy ? + listProto.getItemModel = function (idx) { + var hostModel = this.hostModel; + idx = this.indices[idx]; + return new Model(this._rawData[idx], hostModel, hostModel.ecModel); + }; + + /** + * Create a data differ + * @param {module:echarts/data/List} otherList + * @return {module:echarts/data/DataDiffer} + */ + listProto.diff = function (otherList) { + var idList = this._idList; + var otherIdList = otherList && otherList._idList; + return new DataDiffer( + otherList ? otherList.indices : [], this.indices, function (idx) { + return otherIdList[idx] || (idx + ''); + }, function (idx) { + return idList[idx] || (idx + ''); + } + ); + }; + /** + * Get visual property. + * @param {string} key + */ + listProto.getVisual = function (key) { + var visual = this._visual; + return visual && visual[key]; + }; + + /** + * Set visual property + * @param {string|Object} key + * @param {*} [value] + * + * @example + * setVisual('color', color); + * setVisual({ + * 'color': color + * }); + */ + listProto.setVisual = function (key, val) { + if (isObject(key)) { + for (var name in key) { + if (key.hasOwnProperty(name)) { + this.setVisual(name, key[name]); + } + } + return; + } + this._visual = this._visual || {}; + this._visual[key] = val; + }; + + /** + * Set layout property. + * @param {string} key + * @param {*} [val] + */ + listProto.setLayout = function (key, val) { + if (isObject(key)) { + for (var name in key) { + if (key.hasOwnProperty(name)) { + this.setLayout(name, key[name]); + } + } + return; + } + this._layout[key] = val; + }; + + /** + * Get layout property. + * @param {string} key. + * @return {*} + */ + listProto.getLayout = function (key) { + return this._layout[key]; + }; + + /** + * Get layout of single data item + * @param {number} idx + */ + listProto.getItemLayout = function (idx) { + return this._itemLayouts[idx]; + }, + + /** + * Set layout of single data item + * @param {number} idx + * @param {Object} layout + * @param {boolean=} [merge=false] + */ + listProto.setItemLayout = function (idx, layout, merge) { + this._itemLayouts[idx] = merge + ? zrUtil.extend(this._itemLayouts[idx] || {}, layout) + : layout; + }, + + /** + * Get visual property of single data item + * @param {number} idx + * @param {string} key + * @param {boolean} ignoreParent + */ + listProto.getItemVisual = function (idx, key, ignoreParent) { + var itemVisual = this._itemVisuals[idx]; + var val = itemVisual && itemVisual[key]; + if (val == null && !ignoreParent) { + // Use global visual property + return this.getVisual(key); + } + return val; + }, + + /** + * Set visual property of single data item + * + * @param {number} idx + * @param {string|Object} key + * @param {*} [value] + * + * @example + * setItemVisual(0, 'color', color); + * setItemVisual(0, { + * 'color': color + * }); + */ + listProto.setItemVisual = function (idx, key, value) { + var itemVisual = this._itemVisuals[idx] || {}; + this._itemVisuals[idx] = itemVisual; + + if (isObject(key)) { + for (var name in key) { + if (key.hasOwnProperty(name)) { + itemVisual[name] = key[name]; + } + } + return; + } + itemVisual[key] = value; + }; + + var setItemDataAndSeriesIndex = function (child) { + child.seriesIndex = this.seriesIndex; + child.dataIndex = this.dataIndex; + }; + /** + * Set graphic element relative to data. It can be set as null + * @param {number} idx + * @param {module:zrender/Element} [el] + */ + listProto.setItemGraphicEl = function (idx, el) { + var hostModel = this.hostModel; + + if (el) { + // Add data index and series index for indexing the data by element + // Useful in tooltip + el.dataIndex = idx; + el.seriesIndex = hostModel && hostModel.seriesIndex; + if (el.type === 'group') { + el.traverse(setItemDataAndSeriesIndex, el); + } + } + + this._graphicEls[idx] = el; + }; + + /** + * @param {number} idx + * @return {module:zrender/Element} + */ + listProto.getItemGraphicEl = function (idx) { + return this._graphicEls[idx]; + }; + + /** + * @param {Function} cb + * @param {*} context + */ + listProto.eachItemGraphicEl = function (cb, context) { + zrUtil.each(this._graphicEls, function (el, idx) { + if (el) { + cb && cb.call(context, el, idx); + } + }); + }; + + /** + * Shallow clone a new list except visual and layout properties, and graph elements. + * New list only change the indices. + */ + listProto.cloneShallow = function () { + var dimensionInfoList = zrUtil.map(this.dimensions, this.getDimensionInfo, this); + var list = new List(dimensionInfoList, this.hostModel); + + // FIXME + list._storage = this._storage; + + transferImmuProperties(list, this, this._wrappedMethods); + + list.indices = this.indices.slice(); + + return list; + }; + + /** + * Wrap some method to add more feature + * @param {string} methodName + * @param {Function} injectFunction + */ + listProto.wrapMethod = function (methodName, injectFunction) { + var originalMethod = this[methodName]; + if (typeof originalMethod !== 'function') { + return; + } + this._wrappedMethods = this._wrappedMethods || []; + this._wrappedMethods.push(methodName); + this[methodName] = function () { + var res = originalMethod.apply(this, arguments); + return injectFunction.call(this, res); + }; + }; + + module.exports = List; + + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }, +/* 95 */ +/***/ function(module, exports) { + + 'use strict'; + + + function defaultKeyGetter(item) { + return item; + } + + function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter) { + this._old = oldArr; + this._new = newArr; + + this._oldKeyGetter = oldKeyGetter || defaultKeyGetter; + this._newKeyGetter = newKeyGetter || defaultKeyGetter; + } + + DataDiffer.prototype = { + + constructor: DataDiffer, + + /** + * Callback function when add a data + */ + add: function (func) { + this._add = func; + return this; + }, + + /** + * Callback function when update a data + */ + update: function (func) { + this._update = func; + return this; + }, + + /** + * Callback function when remove a data + */ + remove: function (func) { + this._remove = func; + return this; + }, + + execute: function () { + var oldArr = this._old; + var newArr = this._new; + var oldKeyGetter = this._oldKeyGetter; + var newKeyGetter = this._newKeyGetter; + + var oldDataIndexMap = {}; + var newDataIndexMap = {}; + var i; + + initIndexMap(oldArr, oldDataIndexMap, oldKeyGetter); + initIndexMap(newArr, newDataIndexMap, newKeyGetter); + + // Travel by inverted order to make sure order consistency + // when duplicate keys exists (consider newDataIndex.pop() below). + // For performance consideration, these code below do not look neat. + for (i = 0; i < oldArr.length; i++) { + var key = oldKeyGetter(oldArr[i]); + var idx = newDataIndexMap[key]; + + // idx can never be empty array here. see 'set null' logic below. + if (idx != null) { + // Consider there is duplicate key (for example, use dataItem.name as key). + // We should make sure every item in newArr and oldArr can be visited. + var len = idx.length; + if (len) { + len === 1 && (newDataIndexMap[key] = null); + idx = idx.unshift(); + } + else { + newDataIndexMap[key] = null; + } + this._update && this._update(idx, i); + } + else { + this._remove && this._remove(i); + } + } + + for (var key in newDataIndexMap) { + if (newDataIndexMap.hasOwnProperty(key)) { + var idx = newDataIndexMap[key]; + if (idx == null) { + continue; + } + // idx can never be empty array here. see 'set null' logic above. + if (!idx.length) { + this._add && this._add(idx); + } + else { + for (var i = 0, len = idx.length; i < len; i++) { + this._add && this._add(idx[i]); + } + } + } + } + } + }; + + function initIndexMap(arr, map, keyGetter) { + for (var i = 0; i < arr.length; i++) { + var key = keyGetter(arr[i]); + var existence = map[key]; + if (existence == null) { + map[key] = i; + } + else { + if (!existence.length) { + map[key] = existence = [existence]; + } + existence.push(i); + } + } + } + + module.exports = DataDiffer; + + +/***/ }, +/* 96 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Complete dimensions by data (guess dimension). + */ + + + var zrUtil = __webpack_require__(3); + + /** + * Complete the dimensions array guessed from the data structure. + * @param {Array.} dimensions Necessary dimensions, like ['x', 'y'] + * @param {Array} data Data list. [[1, 2, 3], [2, 3, 4]] + * @param {Array.} defaultNames Default names to fill not necessary dimensions, like ['value'] + * @param {string} extraPrefix Prefix of name when filling the left dimensions. + * @return {Array.} + */ + function completeDimensions(dimensions, data, defaultNames, extraPrefix) { + if (!data) { + return dimensions; + } + + var value0 = retrieveValue(data[0]); + var dimSize = zrUtil.isArray(value0) && value0.length || 1; + + defaultNames = defaultNames || []; + extraPrefix = extraPrefix || 'extra'; + for (var i = 0; i < dimSize; i++) { + if (!dimensions[i]) { + var name = defaultNames[i] || (extraPrefix + (i - defaultNames.length)); + dimensions[i] = guessOrdinal(data, i) + ? {type: 'ordinal', name: name} + : name; + } + } + + return dimensions; + } + + // The rule should not be complex, otherwise user might not + // be able to known where the data is wrong. + function guessOrdinal(data, dimIndex) { + for (var i = 0, len = data.length; i < len; i++) { + var value = retrieveValue(data[i]); + + if (!zrUtil.isArray(value)) { + return false; + } + + var value = value[dimIndex]; + if (value != null && isFinite(value)) { + return false; + } + else if (zrUtil.isString(value) && value !== '-') { + return true; + } + } + return false; + } + + function retrieveValue(o) { + return zrUtil.isArray(o) ? o : zrUtil.isObject(o) ? o.value: o; + } + + module.exports = completeDimensions; + + + +/***/ }, +/* 97 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var SymbolDraw = __webpack_require__(98); + var Symbol = __webpack_require__(99); + var lineAnimationDiff = __webpack_require__(101); + var graphic = __webpack_require__(42); + + var polyHelper = __webpack_require__(102); + + var ChartView = __webpack_require__(41); + + function isPointsSame(points1, points2) { + if (points1.length !== points2.length) { + return; + } + for (var i = 0; i < points1.length; i++) { + var p1 = points1[i]; + var p2 = points2[i]; + if (p1[0] !== p2[0] || p1[1] !== p2[1]) { + return; + } + } + return true; + } + + function getSmooth(smooth) { + return typeof (smooth) === 'number' ? smooth : (smooth ? 0.3 : 0); + } + + function getAxisExtentWithGap(axis) { + var extent = axis.getGlobalExtent(); + if (axis.onBand) { + // Remove extra 1px to avoid line miter in clipped edge + var halfBandWidth = axis.getBandWidth() / 2 - 1; + var dir = extent[1] > extent[0] ? 1 : -1; + extent[0] += dir * halfBandWidth; + extent[1] -= dir * halfBandWidth; + } + return extent; + } + + function sign(val) { + return val >= 0 ? 1 : -1; + } + /** + * @param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys + * @param {module:echarts/data/List} data + * @param {Array.>} points + * @private + */ + function getStackedOnPoints(coordSys, data) { + var baseAxis = coordSys.getBaseAxis(); + var valueAxis = coordSys.getOtherAxis(baseAxis); + var valueStart = baseAxis.onZero + ? 0 : valueAxis.scale.getExtent()[0]; + + var valueDim = valueAxis.dim; + + var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0; + + return data.mapArray([valueDim], function (val, idx) { + var stackedOnSameSign; + var stackedOn = data.stackedOn; + // Find first stacked value with same sign + while (stackedOn && + sign(stackedOn.get(valueDim, idx)) === sign(val) + ) { + stackedOnSameSign = stackedOn; + break; + } + var stackedData = []; + stackedData[baseDataOffset] = data.get(baseAxis.dim, idx); + stackedData[1 - baseDataOffset] = stackedOnSameSign + ? stackedOnSameSign.get(valueDim, idx, true) : valueStart; + + return coordSys.dataToPoint(stackedData); + }, true); + } + + function queryDataIndex(data, payload) { + if (payload.dataIndex != null) { + return payload.dataIndex; + } + else if (payload.name != null) { + return data.indexOfName(payload.name); + } + } + + function createGridClipShape(cartesian, hasAnimation, seriesModel) { + var xExtent = getAxisExtentWithGap(cartesian.getAxis('x')); + var yExtent = getAxisExtentWithGap(cartesian.getAxis('y')); + var isHorizontal = cartesian.getBaseAxis().isHorizontal(); + + var x = xExtent[0]; + var y = yExtent[0]; + var width = xExtent[1] - x; + var height = yExtent[1] - y; + // Expand clip shape to avoid line value exceeds axis + if (!seriesModel.get('clipOverflow')) { + if (isHorizontal) { + y -= height; + height *= 3; + } + else { + x -= width; + width *= 3; + } + } + var clipPath = new graphic.Rect({ + shape: { + x: x, + y: y, + width: width, + height: height + } + }); + + if (hasAnimation) { + clipPath.shape[isHorizontal ? 'width' : 'height'] = 0; + graphic.initProps(clipPath, { + shape: { + width: width, + height: height + } + }, seriesModel); + } + + return clipPath; + } + + function createPolarClipShape(polar, hasAnimation, seriesModel) { + var angleAxis = polar.getAngleAxis(); + var radiusAxis = polar.getRadiusAxis(); + + var radiusExtent = radiusAxis.getExtent(); + var angleExtent = angleAxis.getExtent(); + + var RADIAN = Math.PI / 180; + + var clipPath = new graphic.Sector({ + shape: { + cx: polar.cx, + cy: polar.cy, + r0: radiusExtent[0], + r: radiusExtent[1], + startAngle: -angleExtent[0] * RADIAN, + endAngle: -angleExtent[1] * RADIAN, + clockwise: angleAxis.inverse + } + }); + + if (hasAnimation) { + clipPath.shape.endAngle = -angleExtent[0] * RADIAN; + graphic.initProps(clipPath, { + shape: { + endAngle: -angleExtent[1] * RADIAN + } + }, seriesModel); + } + + return clipPath; + } + + function createClipShape(coordSys, hasAnimation, seriesModel) { + return coordSys.type === 'polar' + ? createPolarClipShape(coordSys, hasAnimation, seriesModel) + : createGridClipShape(coordSys, hasAnimation, seriesModel); + } + + module.exports = ChartView.extend({ + + type: 'line', + + init: function () { + var lineGroup = new graphic.Group(); + + var symbolDraw = new SymbolDraw(); + this.group.add(symbolDraw.group); + + this._symbolDraw = symbolDraw; + this._lineGroup = lineGroup; + }, + + render: function (seriesModel, ecModel, api) { + var coordSys = seriesModel.coordinateSystem; + var group = this.group; + var data = seriesModel.getData(); + var lineStyleModel = seriesModel.getModel('lineStyle.normal'); + var areaStyleModel = seriesModel.getModel('areaStyle.normal'); + + var points = data.mapArray(data.getItemLayout, true); + + var isCoordSysPolar = coordSys.type === 'polar'; + var prevCoordSys = this._coordSys; + + var symbolDraw = this._symbolDraw; + var polyline = this._polyline; + var polygon = this._polygon; + + var lineGroup = this._lineGroup; + + var hasAnimation = seriesModel.get('animation'); + + var isAreaChart = !areaStyleModel.isEmpty(); + var stackedOnPoints = getStackedOnPoints(coordSys, data); + + var showSymbol = seriesModel.get('showSymbol'); + + var isSymbolIgnore = showSymbol && !isCoordSysPolar && !seriesModel.get('showAllSymbol') + && this._getSymbolIgnoreFunc(data, coordSys); + + // Remove temporary symbols + var oldData = this._data; + oldData && oldData.eachItemGraphicEl(function (el, idx) { + if (el.__temp) { + group.remove(el); + oldData.setItemGraphicEl(idx, null); + } + }); + + // Remove previous created symbols if showSymbol changed to false + if (!showSymbol) { + symbolDraw.remove(); + } + + group.add(lineGroup); + + // Initialization animation or coordinate system changed + if ( + !(polyline && prevCoordSys.type === coordSys.type) + ) { + showSymbol && symbolDraw.updateData(data, isSymbolIgnore); + + polyline = this._newPolyline(points, coordSys, hasAnimation); + if (isAreaChart) { + polygon = this._newPolygon( + points, stackedOnPoints, + coordSys, hasAnimation + ); + } + lineGroup.setClipPath(createClipShape(coordSys, true, seriesModel)); + } + else { + if (isAreaChart && !polygon) { + // If areaStyle is added + polygon = this._newPolygon( + points, stackedOnPoints, + coordSys, hasAnimation + ); + } + else if (polygon && !isAreaChart) { + // If areaStyle is removed + lineGroup.remove(polygon); + polygon = this._polygon = null; + } + + // Update clipPath + lineGroup.setClipPath(createClipShape(coordSys, false, seriesModel)); + + // Always update, or it is wrong in the case turning on legend + // because points are not changed + showSymbol && symbolDraw.updateData(data, isSymbolIgnore); + + // Stop symbol animation and sync with line points + // FIXME performance? + data.eachItemGraphicEl(function (el) { + el.stopAnimation(true); + }); + + // In the case data zoom triggerred refreshing frequently + // Data may not change if line has a category axis. So it should animate nothing + if (!isPointsSame(this._stackedOnPoints, stackedOnPoints) + || !isPointsSame(this._points, points) + ) { + if (hasAnimation) { + this._updateAnimation( + data, stackedOnPoints, coordSys, api + ); + } + else { + polyline.setShape({ + points: points + }); + polygon && polygon.setShape({ + points: points, + stackedOnPoints: stackedOnPoints + }); + } + } + } + + polyline.setStyle(zrUtil.defaults( + // Use color in lineStyle first + lineStyleModel.getLineStyle(), + { + stroke: data.getVisual('color'), + lineJoin: 'bevel' + } + )); + + var smooth = seriesModel.get('smooth'); + smooth = getSmooth(seriesModel.get('smooth')); + polyline.setShape({ + smooth: smooth, + smoothMonotone: seriesModel.get('smoothMonotone') + }); + + if (polygon) { + var stackedOn = data.stackedOn; + var stackedOnSmooth = 0; + + polygon.style.opacity = 0.7; + polygon.setStyle(zrUtil.defaults( + areaStyleModel.getAreaStyle(), + { + fill: data.getVisual('color'), + lineJoin: 'bevel' + } + )); + + if (stackedOn) { + var stackedOnSeries = stackedOn.hostModel; + stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth')); + } + + polygon.setShape({ + smooth: smooth, + stackedOnSmooth: stackedOnSmooth, + smoothMonotone: seriesModel.get('smoothMonotone') + }); + } + + this._data = data; + // Save the coordinate system for transition animation when data changed + this._coordSys = coordSys; + this._stackedOnPoints = stackedOnPoints; + this._points = points; + }, + + highlight: function (seriesModel, ecModel, api, payload) { + var data = seriesModel.getData(); + var dataIndex = queryDataIndex(data, payload); + + if (dataIndex != null && dataIndex >= 0) { + var symbol = data.getItemGraphicEl(dataIndex); + if (!symbol) { + // Create a temporary symbol if it is not exists + var pt = data.getItemLayout(dataIndex); + symbol = new Symbol(data, dataIndex, api); + symbol.position = pt; + symbol.setZ( + seriesModel.get('zlevel'), + seriesModel.get('z') + ); + symbol.ignore = isNaN(pt[0]) || isNaN(pt[1]); + symbol.__temp = true; + data.setItemGraphicEl(dataIndex, symbol); + + // Stop scale animation + symbol.stopSymbolAnimation(true); + + this.group.add(symbol); + } + symbol.highlight(); + } + else { + // Highlight whole series + ChartView.prototype.highlight.call( + this, seriesModel, ecModel, api, payload + ); + } + }, + + downplay: function (seriesModel, ecModel, api, payload) { + var data = seriesModel.getData(); + var dataIndex = queryDataIndex(data, payload); + if (dataIndex != null && dataIndex >= 0) { + var symbol = data.getItemGraphicEl(dataIndex); + if (symbol) { + if (symbol.__temp) { + data.setItemGraphicEl(dataIndex, null); + this.group.remove(symbol); + } + else { + symbol.downplay(); + } + } + } + else { + // Downplay whole series + ChartView.prototype.downplay.call( + this, seriesModel, ecModel, api, payload + ); + } + }, + + /** + * @param {module:zrender/container/Group} group + * @param {Array.>} points + * @private + */ + _newPolyline: function (points) { + var polyline = this._polyline; + // Remove previous created polyline + if (polyline) { + this._lineGroup.remove(polyline); + } + + polyline = new polyHelper.Polyline({ + shape: { + points: points + }, + silent: true, + z2: 10 + }); + + this._lineGroup.add(polyline); + + this._polyline = polyline; + + return polyline; + }, + + /** + * @param {module:zrender/container/Group} group + * @param {Array.>} stackedOnPoints + * @param {Array.>} points + * @private + */ + _newPolygon: function (points, stackedOnPoints) { + var polygon = this._polygon; + // Remove previous created polygon + if (polygon) { + this._lineGroup.remove(polygon); + } + + polygon = new polyHelper.Polygon({ + shape: { + points: points, + stackedOnPoints: stackedOnPoints + }, + silent: true + }); + + this._lineGroup.add(polygon); + + this._polygon = polygon; + return polygon; + }, + /** + * @private + */ + _getSymbolIgnoreFunc: function (data, coordSys) { + var categoryAxis = coordSys.getAxesByScale('ordinal')[0]; + // `getLabelInterval` is provided by echarts/component/axis + if (categoryAxis && categoryAxis.isLabelIgnored) { + return zrUtil.bind(categoryAxis.isLabelIgnored, categoryAxis); + } + }, + + /** + * @private + */ + // FIXME Two value axis + _updateAnimation: function (data, stackedOnPoints, coordSys, api) { + var polyline = this._polyline; + var polygon = this._polygon; + var seriesModel = data.hostModel; + + var diff = lineAnimationDiff( + this._data, data, + this._stackedOnPoints, stackedOnPoints, + this._coordSys, coordSys + ); + polyline.shape.points = diff.current; + + graphic.updateProps(polyline, { + shape: { + points: diff.next + } + }, seriesModel); + + if (polygon) { + polygon.setShape({ + points: diff.current, + stackedOnPoints: diff.stackedOnCurrent + }); + graphic.updateProps(polygon, { + shape: { + points: diff.next, + stackedOnPoints: diff.stackedOnNext + } + }, seriesModel); + } + + var updatedDataInfo = []; + var diffStatus = diff.status; + + for (var i = 0; i < diffStatus.length; i++) { + var cmd = diffStatus[i].cmd; + if (cmd === '=') { + var el = data.getItemGraphicEl(diffStatus[i].idx1); + if (el) { + updatedDataInfo.push({ + el: el, + ptIdx: i // Index of points + }); + } + } + } + + if (polyline.animators && polyline.animators.length) { + polyline.animators[0].during(function () { + for (var i = 0; i < updatedDataInfo.length; i++) { + var el = updatedDataInfo[i].el; + el.attr('position', polyline.shape.points[updatedDataInfo[i].ptIdx]); + } + }); + } + }, + + remove: function (ecModel) { + var group = this.group; + var oldData = this._data; + this._lineGroup.removeAll(); + this._symbolDraw.remove(true); + // Remove temporary created elements when highlighting + oldData && oldData.eachItemGraphicEl(function (el, idx) { + if (el.__temp) { + group.remove(el); + oldData.setItemGraphicEl(idx, null); + } + }); + + this._polyline = + this._polygon = + this._coordSys = + this._points = + this._stackedOnPoints = + this._data = null; + } + }); + + +/***/ }, +/* 98 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/chart/helper/SymbolDraw + */ + + + var graphic = __webpack_require__(42); + var Symbol = __webpack_require__(99); + + /** + * @constructor + * @alias module:echarts/chart/helper/SymbolDraw + * @param {module:zrender/graphic/Group} [symbolCtor] + */ + function SymbolDraw(symbolCtor) { + this.group = new graphic.Group(); + + this._symbolCtor = symbolCtor || Symbol; + } + + var symbolDrawProto = SymbolDraw.prototype; + + function symbolNeedsDraw(data, idx, isIgnore) { + var point = data.getItemLayout(idx); + return point && !isNaN(point[0]) && !isNaN(point[1]) && !(isIgnore && isIgnore(idx)) + && data.getItemVisual(idx, 'symbol') !== 'none'; + } + /** + * Update symbols draw by new data + * @param {module:echarts/data/List} data + * @param {Array.} [isIgnore] + */ + symbolDrawProto.updateData = function (data, isIgnore) { + var group = this.group; + var seriesModel = data.hostModel; + var oldData = this._data; + + var SymbolCtor = this._symbolCtor; + + data.diff(oldData) + .add(function (newIdx) { + var point = data.getItemLayout(newIdx); + if (symbolNeedsDraw(data, newIdx, isIgnore)) { + var symbolEl = new SymbolCtor(data, newIdx); + symbolEl.attr('position', point); + data.setItemGraphicEl(newIdx, symbolEl); + group.add(symbolEl); + } + }) + .update(function (newIdx, oldIdx) { + var symbolEl = oldData.getItemGraphicEl(oldIdx); + var point = data.getItemLayout(newIdx); + if (!symbolNeedsDraw(data, newIdx, isIgnore)) { + group.remove(symbolEl); + return; + } + if (!symbolEl) { + symbolEl = new SymbolCtor(data, newIdx); + symbolEl.attr('position', point); + } + else { + symbolEl.updateData(data, newIdx); + graphic.updateProps(symbolEl, { + position: point + }, seriesModel); + } + + // Add back + group.add(symbolEl); + + data.setItemGraphicEl(newIdx, symbolEl); + }) + .remove(function (oldIdx) { + var el = oldData.getItemGraphicEl(oldIdx); + el && el.fadeOut(function () { + group.remove(el); + }); + }) + .execute(); + + this._data = data; + }; + + symbolDrawProto.updateLayout = function () { + var data = this._data; + if (data) { + // Not use animation + data.eachItemGraphicEl(function (el, idx) { + el.attr('position', data.getItemLayout(idx)); + }); + } + }; + + symbolDrawProto.remove = function (enableAnimation) { + var group = this.group; + var data = this._data; + if (data) { + if (enableAnimation) { + data.eachItemGraphicEl(function (el) { + el.fadeOut(function () { + group.remove(el); + }); + }); + } + else { + group.removeAll(); + } + } + }; + + module.exports = SymbolDraw; + + +/***/ }, +/* 99 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/chart/helper/Symbol + */ + + + var zrUtil = __webpack_require__(3); + var symbolUtil = __webpack_require__(100); + var graphic = __webpack_require__(42); + var numberUtil = __webpack_require__(7); + + function normalizeSymbolSize(symbolSize) { + if (!zrUtil.isArray(symbolSize)) { + symbolSize = [+symbolSize, +symbolSize]; + } + return symbolSize; + } + + /** + * @constructor + * @alias {module:echarts/chart/helper/Symbol} + * @param {module:echarts/data/List} data + * @param {number} idx + * @extends {module:zrender/graphic/Group} + */ + function Symbol(data, idx) { + graphic.Group.call(this); + + this.updateData(data, idx); + } + + var symbolProto = Symbol.prototype; + + function driftSymbol(dx, dy) { + this.parent.drift(dx, dy); + } + + symbolProto._createSymbol = function (symbolType, data, idx) { + // Remove paths created before + this.removeAll(); + + var seriesModel = data.hostModel; + var color = data.getItemVisual(idx, 'color'); + + var symbolPath = symbolUtil.createSymbol( + symbolType, -0.5, -0.5, 1, 1, color + ); + + symbolPath.attr({ + style: { + strokeNoScale: true + }, + z2: 100, + culling: true, + scale: [0, 0] + }); + // Rewrite drift method + symbolPath.drift = driftSymbol; + + var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); + + graphic.initProps(symbolPath, { + scale: size + }, seriesModel); + + this._symbolType = symbolType; + + this.add(symbolPath); + }; + + /** + * Stop animation + * @param {boolean} toLastFrame + */ + symbolProto.stopSymbolAnimation = function (toLastFrame) { + this.childAt(0).stopAnimation(toLastFrame); + }; + + /** + * Get scale(aka, current symbol size). + * Including the change caused by animation + * @param {Array.} toLastFrame + */ + symbolProto.getScale = function () { + return this.childAt(0).scale; + }; + + /** + * Highlight symbol + */ + symbolProto.highlight = function () { + this.childAt(0).trigger('emphasis'); + }; + + /** + * Downplay symbol + */ + symbolProto.downplay = function () { + this.childAt(0).trigger('normal'); + }; + + /** + * @param {number} zlevel + * @param {number} z + */ + symbolProto.setZ = function (zlevel, z) { + var symbolPath = this.childAt(0); + symbolPath.zlevel = zlevel; + symbolPath.z = z; + }; + + symbolProto.setDraggable = function (draggable) { + var symbolPath = this.childAt(0); + symbolPath.draggable = draggable; + symbolPath.cursor = draggable ? 'move' : 'pointer'; + }; + /** + * Update symbol properties + * @param {module:echarts/data/List} data + * @param {number} idx + */ + symbolProto.updateData = function (data, idx) { + var symbolType = data.getItemVisual(idx, 'symbol') || 'circle'; + var seriesModel = data.hostModel; + var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); + if (symbolType !== this._symbolType) { + this._createSymbol(symbolType, data, idx); + } + else { + var symbolPath = this.childAt(0); + graphic.updateProps(symbolPath, { + scale: symbolSize + }, seriesModel); + } + this._updateCommon(data, idx, symbolSize); + + this._seriesModel = seriesModel; + }; + + // Update common properties + var normalStyleAccessPath = ['itemStyle', 'normal']; + var emphasisStyleAccessPath = ['itemStyle', 'emphasis']; + var normalLabelAccessPath = ['label', 'normal']; + var emphasisLabelAccessPath = ['label', 'emphasis']; + + symbolProto._updateCommon = function (data, idx, symbolSize) { + var symbolPath = this.childAt(0); + var seriesModel = data.hostModel; + var itemModel = data.getItemModel(idx); + var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath); + var color = data.getItemVisual(idx, 'color'); + + var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle(); + + symbolPath.rotation = itemModel.getShallow('symbolRotate') * Math.PI / 180 || 0; + + var symbolOffset = itemModel.getShallow('symbolOffset'); + if (symbolOffset) { + var pos = symbolPath.position; + pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]); + pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]); + } + + symbolPath.setColor(color); + + zrUtil.extend( + symbolPath.style, + // Color must be excluded. + // Because symbol provide setColor individually to set fill and stroke + normalItemStyleModel.getItemStyle(['color']) + ); + + var labelModel = itemModel.getModel(normalLabelAccessPath); + var hoverLabelModel = itemModel.getModel(emphasisLabelAccessPath); + + var elStyle = symbolPath.style; + + // Get last value dim + var dimensions = data.dimensions.slice(); + var valueDim = dimensions.pop(); + var dataType; + while ( + ((dataType = data.getDimensionInfo(valueDim).type) === 'ordinal') + || (dataType === 'time') + ) { + valueDim = dimensions.pop(); + } + + if (labelModel.get('show')) { + graphic.setText(elStyle, labelModel, color); + elStyle.text = zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'normal'), + data.get(valueDim, idx) + ); + } + else { + elStyle.text = ''; + } + + if (hoverLabelModel.getShallow('show')) { + graphic.setText(hoverStyle, hoverLabelModel, color); + hoverStyle.text = zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'emphasis'), + data.get(valueDim, idx) + ); + } + else { + hoverStyle.text = ''; + } + + var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); + + symbolPath.off('mouseover') + .off('mouseout') + .off('emphasis') + .off('normal'); + + graphic.setHoverStyle(symbolPath, hoverStyle); + + if (itemModel.getShallow('hoverAnimation')) { + var onEmphasis = function() { + var ratio = size[1] / size[0]; + this.animateTo({ + scale: [ + Math.max(size[0] * 1.1, size[0] + 3), + Math.max(size[1] * 1.1, size[1] + 3 * ratio) + ] + }, 400, 'elasticOut'); + }; + var onNormal = function() { + this.animateTo({ + scale: size + }, 400, 'elasticOut'); + }; + symbolPath.on('mouseover', onEmphasis) + .on('mouseout', onNormal) + .on('emphasis', onEmphasis) + .on('normal', onNormal); + } + }; + + symbolProto.fadeOut = function (cb) { + var symbolPath = this.childAt(0); + // Not show text when animating + symbolPath.style.text = ''; + graphic.updateProps(symbolPath, { + scale: [0, 0] + }, this._seriesModel, cb); + }; + + zrUtil.inherits(Symbol, graphic.Group); + + module.exports = Symbol; + + +/***/ }, +/* 100 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // Symbol factory + + + var graphic = __webpack_require__(42); + var BoundingRect = __webpack_require__(15); + + /** + * Triangle shape + * @inner + */ + var Triangle = graphic.extendShape({ + type: 'triangle', + shape: { + cx: 0, + cy: 0, + width: 0, + height: 0 + }, + buildPath: function (path, shape) { + var cx = shape.cx; + var cy = shape.cy; + var width = shape.width / 2; + var height = shape.height / 2; + path.moveTo(cx, cy - height); + path.lineTo(cx + width, cy + height); + path.lineTo(cx - width, cy + height); + path.closePath(); + } + }); + /** + * Diamond shape + * @inner + */ + var Diamond = graphic.extendShape({ + type: 'diamond', + shape: { + cx: 0, + cy: 0, + width: 0, + height: 0 + }, + buildPath: function (path, shape) { + var cx = shape.cx; + var cy = shape.cy; + var width = shape.width / 2; + var height = shape.height / 2; + path.moveTo(cx, cy - height); + path.lineTo(cx + width, cy); + path.lineTo(cx, cy + height); + path.lineTo(cx - width, cy); + path.closePath(); + } + }); + + /** + * Pin shape + * @inner + */ + var Pin = graphic.extendShape({ + type: 'pin', + shape: { + // x, y on the cusp + x: 0, + y: 0, + width: 0, + height: 0 + }, + + buildPath: function (path, shape) { + var x = shape.x; + var y = shape.y; + var w = shape.width / 5 * 3; + // Height must be larger than width + var h = Math.max(w, shape.height); + var r = w / 2; + + // Dist on y with tangent point and circle center + var dy = r * r / (h - r); + var cy = y - h + r + dy; + var angle = Math.asin(dy / r); + // Dist on x with tangent point and circle center + var dx = Math.cos(angle) * r; + + var tanX = Math.sin(angle); + var tanY = Math.cos(angle); + + path.arc( + x, cy, r, + Math.PI - angle, + Math.PI * 2 + angle + ); + + var cpLen = r * 0.6; + var cpLen2 = r * 0.7; + path.bezierCurveTo( + x + dx - tanX * cpLen, cy + dy + tanY * cpLen, + x, y - cpLen2, + x, y + ); + path.bezierCurveTo( + x, y - cpLen2, + x - dx + tanX * cpLen, cy + dy + tanY * cpLen, + x - dx, cy + dy + ); + path.closePath(); + } + }); + + /** + * Arrow shape + * @inner + */ + var Arrow = graphic.extendShape({ + + type: 'arrow', + + shape: { + x: 0, + y: 0, + width: 0, + height: 0 + }, + + buildPath: function (ctx, shape) { + var height = shape.height; + var width = shape.width; + var x = shape.x; + var y = shape.y; + var dx = width / 3 * 2; + ctx.moveTo(x, y); + ctx.lineTo(x + dx, y + height); + ctx.lineTo(x, y + height / 4 * 3); + ctx.lineTo(x - dx, y + height); + ctx.lineTo(x, y); + ctx.closePath(); + } + }); + + /** + * Map of path contructors + * @type {Object.} + */ + var symbolCtors = { + line: graphic.Line, + + rect: graphic.Rect, + + roundRect: graphic.Rect, + + square: graphic.Rect, + + circle: graphic.Circle, + + diamond: Diamond, + + pin: Pin, + + arrow: Arrow, + + triangle: Triangle + }; + + var symbolShapeMakers = { + + line: function (x, y, w, h, shape) { + // FIXME + shape.x1 = x; + shape.y1 = y + h / 2; + shape.x2 = x + w; + shape.y2 = y + h / 2; + }, + + rect: function (x, y, w, h, shape) { + shape.x = x; + shape.y = y; + shape.width = w; + shape.height = h; + }, + + roundRect: function (x, y, w, h, shape) { + shape.x = x; + shape.y = y; + shape.width = w; + shape.height = h; + shape.r = Math.min(w, h) / 4; + }, + + square: function (x, y, w, h, shape) { + var size = Math.min(w, h); + shape.x = x; + shape.y = y; + shape.width = size; + shape.height = size; + }, + + circle: function (x, y, w, h, shape) { + // Put circle in the center of square + shape.cx = x + w / 2; + shape.cy = y + h / 2; + shape.r = Math.min(w, h) / 2; + }, + + diamond: function (x, y, w, h, shape) { + shape.cx = x + w / 2; + shape.cy = y + h / 2; + shape.width = w; + shape.height = h; + }, + + pin: function (x, y, w, h, shape) { + shape.x = x + w / 2; + shape.y = y + h / 2; + shape.width = w; + shape.height = h; + }, + + arrow: function (x, y, w, h, shape) { + shape.x = x + w / 2; + shape.y = y + h / 2; + shape.width = w; + shape.height = h; + }, + + triangle: function (x, y, w, h, shape) { + shape.cx = x + w / 2; + shape.cy = y + h / 2; + shape.width = w; + shape.height = h; + } + }; + + var symbolBuildProxies = {}; + for (var name in symbolCtors) { + symbolBuildProxies[name] = new symbolCtors[name](); + } + + var Symbol = graphic.extendShape({ + + type: 'symbol', + + shape: { + symbolType: '', + x: 0, + y: 0, + width: 0, + height: 0 + }, + + beforeBrush: function () { + var style = this.style; + var shape = this.shape; + // FIXME + if (shape.symbolType === 'pin' && style.textPosition === 'inside') { + style.textPosition = ['50%', '40%']; + style.textAlign = 'center'; + style.textVerticalAlign = 'middle'; + } + }, + + buildPath: function (ctx, shape) { + var symbolType = shape.symbolType; + var proxySymbol = symbolBuildProxies[symbolType]; + if (shape.symbolType !== 'none') { + if (!proxySymbol) { + // Default rect + symbolType = 'rect'; + proxySymbol = symbolBuildProxies[symbolType]; + } + symbolShapeMakers[symbolType]( + shape.x, shape.y, shape.width, shape.height, proxySymbol.shape + ); + proxySymbol.buildPath(ctx, proxySymbol.shape); + } + } + }); + + // Provide setColor helper method to avoid determine if set the fill or stroke outside + var symbolPathSetColor = function (color) { + if (this.type !== 'image') { + var symbolStyle = this.style; + var symbolShape = this.shape; + if (symbolShape && symbolShape.symbolType === 'line') { + symbolStyle.stroke = color; + } + else if (this.__isEmptyBrush) { + symbolStyle.stroke = color; + symbolStyle.fill = '#fff'; + } + else { + // FIXME 判断图形默认是填充还是描边,使用 onlyStroke ? + symbolStyle.fill && (symbolStyle.fill = color); + symbolStyle.stroke && (symbolStyle.stroke = color); + } + this.dirty(); + } + }; + + var symbolUtil = { + /** + * Create a symbol element with given symbol configuration: shape, x, y, width, height, color + * @param {string} symbolType + * @param {number} x + * @param {number} y + * @param {number} w + * @param {number} h + * @param {string} color + */ + createSymbol: function (symbolType, x, y, w, h, color) { + var isEmpty = symbolType.indexOf('empty') === 0; + if (isEmpty) { + symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6); + } + var symbolPath; + + if (symbolType.indexOf('image://') === 0) { + symbolPath = new graphic.Image({ + style: { + image: symbolType.slice(8), + x: x, + y: y, + width: w, + height: h + } + }); + } + else if (symbolType.indexOf('path://') === 0) { + symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h)); + } + else { + symbolPath = new Symbol({ + shape: { + symbolType: symbolType, + x: x, + y: y, + width: w, + height: h + } + }); + } + + symbolPath.__isEmptyBrush = isEmpty; + + symbolPath.setColor = symbolPathSetColor; + + symbolPath.setColor(color); + + return symbolPath; + } + }; + + module.exports = symbolUtil; + + +/***/ }, +/* 101 */ +/***/ function(module, exports) { + + + + // var arrayDiff = require('zrender/lib/core/arrayDiff'); + // 'zrender/core/arrayDiff' has been used before, but it did + // not do well in performance when roam with fixed dataZoom window. + + function sign(val) { + return val >= 0 ? 1 : -1; + } + + function getStackedOnPoint(coordSys, data, idx) { + var baseAxis = coordSys.getBaseAxis(); + var valueAxis = coordSys.getOtherAxis(baseAxis); + var valueStart = baseAxis.onZero + ? 0 : valueAxis.scale.getExtent()[0]; + + var valueDim = valueAxis.dim; + var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0; + + var stackedOnSameSign; + var stackedOn = data.stackedOn; + var val = data.get(valueDim, idx); + // Find first stacked value with same sign + while (stackedOn && + sign(stackedOn.get(valueDim, idx)) === sign(val) + ) { + stackedOnSameSign = stackedOn; + break; + } + var stackedData = []; + stackedData[baseDataOffset] = data.get(baseAxis.dim, idx); + stackedData[1 - baseDataOffset] = stackedOnSameSign + ? stackedOnSameSign.get(valueDim, idx, true) : valueStart; + + return coordSys.dataToPoint(stackedData); + } + + // function convertToIntId(newIdList, oldIdList) { + // // Generate int id instead of string id. + // // Compare string maybe slow in score function of arrDiff + + // // Assume id in idList are all unique + // var idIndicesMap = {}; + // var idx = 0; + // for (var i = 0; i < newIdList.length; i++) { + // idIndicesMap[newIdList[i]] = idx; + // newIdList[i] = idx++; + // } + // for (var i = 0; i < oldIdList.length; i++) { + // var oldId = oldIdList[i]; + // // Same with newIdList + // if (idIndicesMap[oldId]) { + // oldIdList[i] = idIndicesMap[oldId]; + // } + // else { + // oldIdList[i] = idx++; + // } + // } + // } + + function diffData(oldData, newData) { + var diffResult = []; + + newData.diff(oldData) + .add(function (idx) { + diffResult.push({cmd: '+', idx: idx}); + }) + .update(function (newIdx, oldIdx) { + diffResult.push({cmd: '=', idx: oldIdx, idx1: newIdx}); + }) + .remove(function (idx) { + diffResult.push({cmd: '-', idx: idx}); + }) + .execute(); + + return diffResult; + } + + module.exports = function ( + oldData, newData, + oldStackedOnPoints, newStackedOnPoints, + oldCoordSys, newCoordSys + ) { + var diff = diffData(oldData, newData); + + // var newIdList = newData.mapArray(newData.getId); + // var oldIdList = oldData.mapArray(oldData.getId); + + // convertToIntId(newIdList, oldIdList); + + // // FIXME One data ? + // diff = arrayDiff(oldIdList, newIdList); + + var currPoints = []; + var nextPoints = []; + // Points for stacking base line + var currStackedPoints = []; + var nextStackedPoints = []; + + var status = []; + var sortedIndices = []; + var rawIndices = []; + var dims = newCoordSys.dimensions; + for (var i = 0; i < diff.length; i++) { + var diffItem = diff[i]; + var pointAdded = true; + + // FIXME, animation is not so perfect when dataZoom window moves fast + // Which is in case remvoing or add more than one data in the tail or head + switch (diffItem.cmd) { + case '=': + var currentPt = oldData.getItemLayout(diffItem.idx); + var nextPt = newData.getItemLayout(diffItem.idx1); + // If previous data is NaN, use next point directly + if (isNaN(currentPt[0]) || isNaN(currentPt[1])) { + currentPt = nextPt.slice(); + } + currPoints.push(currentPt); + nextPoints.push(nextPt); + + currStackedPoints.push(oldStackedOnPoints[diffItem.idx]); + nextStackedPoints.push(newStackedOnPoints[diffItem.idx1]); + + rawIndices.push(newData.getRawIndex(diffItem.idx1)); + break; + case '+': + var idx = diffItem.idx; + currPoints.push( + oldCoordSys.dataToPoint([ + newData.get(dims[0], idx, true), newData.get(dims[1], idx, true) + ]) + ); + + nextPoints.push(newData.getItemLayout(idx).slice()); + + currStackedPoints.push( + getStackedOnPoint(oldCoordSys, newData, idx) + ); + nextStackedPoints.push(newStackedOnPoints[idx]); + + rawIndices.push(newData.getRawIndex(idx)); + break; + case '-': + var idx = diffItem.idx; + var rawIndex = oldData.getRawIndex(idx); + // Data is replaced. In the case of dynamic data queue + // FIXME FIXME FIXME + if (rawIndex !== idx) { + currPoints.push(oldData.getItemLayout(idx)); + nextPoints.push(newCoordSys.dataToPoint([ + oldData.get(dims[0], idx, true), oldData.get(dims[1], idx, true) + ])); + + currStackedPoints.push(oldStackedOnPoints[idx]); + nextStackedPoints.push( + getStackedOnPoint( + newCoordSys, oldData, idx + ) + ); + + rawIndices.push(rawIndex); + } + else { + pointAdded = false; + } + } + + // Original indices + if (pointAdded) { + status.push(diffItem); + sortedIndices.push(sortedIndices.length); + } + } + + // Diff result may be crossed if all items are changed + // Sort by data index + sortedIndices.sort(function (a, b) { + return rawIndices[a] - rawIndices[b]; + }); + + var sortedCurrPoints = []; + var sortedNextPoints = []; + + var sortedCurrStackedPoints = []; + var sortedNextStackedPoints = []; + + var sortedStatus = []; + for (var i = 0; i < sortedIndices.length; i++) { + var idx = sortedIndices[i]; + sortedCurrPoints[i] = currPoints[idx]; + sortedNextPoints[i] = nextPoints[idx]; + + sortedCurrStackedPoints[i] = currStackedPoints[idx]; + sortedNextStackedPoints[i] = nextStackedPoints[idx]; + + sortedStatus[i] = status[idx]; + } + + return { + current: sortedCurrPoints, + next: sortedNextPoints, + + stackedOnCurrent: sortedCurrStackedPoints, + stackedOnNext: sortedNextStackedPoints, + + status: sortedStatus + }; + }; + + +/***/ }, +/* 102 */ +/***/ function(module, exports, __webpack_require__) { + + // Poly path support NaN point + + + var Path = __webpack_require__(44); + var vec2 = __webpack_require__(16); + + var vec2Min = vec2.min; + var vec2Max = vec2.max; + + var scaleAndAdd = vec2.scaleAndAdd; + var v2Copy = vec2.copy; + + // Temporary variable + var v = []; + var cp0 = []; + var cp1 = []; + + function drawSegment( + ctx, points, start, stop, len, + dir, smoothMin, smoothMax, smooth, smoothMonotone + ) { + var idx = start; + for (var k = 0; k < len; k++) { + var p = points[idx]; + if (idx >= stop || idx < 0 || isNaN(p[0]) || isNaN(p[1])) { + break; + } + + if (idx === start) { + ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]); + v2Copy(cp0, p); + } + else { + if (smooth > 0) { + var prevIdx = idx - dir; + var nextIdx = idx + dir; + + var ratioNextSeg = 0.5; + var prevP = points[prevIdx]; + var nextP = points[nextIdx]; + // Last point + if ((dir > 0 && (idx === len - 1 || isNaN(nextP[0]) || isNaN(nextP[1]))) + || (dir <= 0 && (idx === 0 || isNaN(nextP[0]) || isNaN(nextP[1]))) + ) { + v2Copy(cp1, p); + } + else { + // If next data is null + if (isNaN(nextP[0]) || isNaN(nextP[1])) { + nextP = p; + } + + vec2.sub(v, nextP, prevP); + + var lenPrevSeg; + var lenNextSeg; + if (smoothMonotone === 'x' || smoothMonotone === 'y') { + var dim = smoothMonotone === 'x' ? 0 : 1; + lenPrevSeg = Math.abs(p[dim] - prevP[dim]); + lenNextSeg = Math.abs(p[dim] - nextP[dim]); + } + else { + lenPrevSeg = vec2.dist(p, prevP); + lenNextSeg = vec2.dist(p, nextP); + } + + // Use ratio of seg length + ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg); + + scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg)); + } + // Smooth constraint + vec2Min(cp0, cp0, smoothMax); + vec2Max(cp0, cp0, smoothMin); + vec2Min(cp1, cp1, smoothMax); + vec2Max(cp1, cp1, smoothMin); + + ctx.bezierCurveTo( + cp0[0], cp0[1], + cp1[0], cp1[1], + p[0], p[1] + ); + // cp0 of next segment + scaleAndAdd(cp0, p, v, smooth * ratioNextSeg); + } + else { + ctx.lineTo(p[0], p[1]); + } + } + + idx += dir; + } + + return k; + } + + function getBoundingBox(points, smoothConstraint) { + var ptMin = [Infinity, Infinity]; + var ptMax = [-Infinity, -Infinity]; + if (smoothConstraint) { + for (var i = 0; i < points.length; i++) { + var pt = points[i]; + if (pt[0] < ptMin[0]) { ptMin[0] = pt[0]; } + if (pt[1] < ptMin[1]) { ptMin[1] = pt[1]; } + if (pt[0] > ptMax[0]) { ptMax[0] = pt[0]; } + if (pt[1] > ptMax[1]) { ptMax[1] = pt[1]; } + } + } + return { + min: smoothConstraint ? ptMin : ptMax, + max: smoothConstraint ? ptMax : ptMin + }; + } + + module.exports = { + + Polyline: Path.extend({ + + type: 'ec-polyline', + + shape: { + points: [], + + smooth: 0, + + smoothConstraint: true, + + smoothMonotone: null + }, + + style: { + fill: null, + + stroke: '#000' + }, + + buildPath: function (ctx, shape) { + var points = shape.points; + + var i = 0; + var len = points.length; + + var result = getBoundingBox(points, shape.smoothConstraint); + + while (i < len) { + i += drawSegment( + ctx, points, i, len, len, + 1, result.min, result.max, shape.smooth, + shape.smoothMonotone + ) + 1; + } + } + }), + + Polygon: Path.extend({ + + type: 'ec-polygon', + + shape: { + points: [], + + // Offset between stacked base points and points + stackedOnPoints: [], + + smooth: 0, + + stackedOnSmooth: 0, + + smoothConstraint: true, + + smoothMonotone: null + }, + + buildPath: function (ctx, shape) { + var points = shape.points; + var stackedOnPoints = shape.stackedOnPoints; + + var i = 0; + var len = points.length; + var smoothMonotone = shape.smoothMonotone; + var bbox = getBoundingBox(points, shape.smoothConstraint); + var stackedOnBBox = getBoundingBox(stackedOnPoints, shape.smoothConstraint); + while (i < len) { + var k = drawSegment( + ctx, points, i, len, len, + 1, bbox.min, bbox.max, shape.smooth, + smoothMonotone + ); + drawSegment( + ctx, stackedOnPoints, i + k - 1, len, k, + -1, stackedOnBBox.min, stackedOnBBox.max, shape.stackedOnSmooth, + smoothMonotone + ); + i += k + 1; + + ctx.closePath(); + } + } + }) + }; + + +/***/ }, +/* 103 */ +/***/ function(module, exports) { + + + + module.exports = function (seriesType, defaultSymbolType, legendSymbol, ecModel, api) { + + // Encoding visual for all series include which is filtered for legend drawing + ecModel.eachRawSeriesByType(seriesType, function (seriesModel) { + var data = seriesModel.getData(); + + var symbolType = seriesModel.get('symbol') || defaultSymbolType; + var symbolSize = seriesModel.get('symbolSize'); + + data.setVisual({ + legendSymbol: legendSymbol || symbolType, + symbol: symbolType, + symbolSize: symbolSize + }); + + // Only visible series has each data be visual encoded + if (!ecModel.isSeriesFiltered(seriesModel)) { + if (typeof symbolSize === 'function') { + data.each(function (idx) { + var rawValue = seriesModel.getRawValue(idx); + // FIXME + var params = seriesModel.getDataParams(idx); + data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params)); + }); + } + data.each(function (idx) { + var itemModel = data.getItemModel(idx); + var itemSymbolType = itemModel.get('symbol', true); + var itemSymbolSize = itemModel.get('symbolSize', true); + // If has item symbol + if (itemSymbolType != null) { + data.setItemVisual(idx, 'symbol', itemSymbolType); + } + if (itemSymbolSize != null) { + // PENDING Transform symbolSize ? + data.setItemVisual(idx, 'symbolSize', itemSymbolSize); + } + }); + } + }); + }; + + +/***/ }, +/* 104 */ +/***/ function(module, exports) { + + + + module.exports = function (seriesType, ecModel, api) { + ecModel.eachSeriesByType(seriesType, function (seriesModel) { + var data = seriesModel.getData(); + var coordSys = seriesModel.coordinateSystem; + + var dims = coordSys.dimensions; + data.each(dims, function (x, y, idx) { + var point; + if (!isNaN(x) && !isNaN(y)) { + point = coordSys.dataToPoint([x, y]); + } + else { + // Also {Array.}, not undefined to avoid if...else... statement + point = [NaN, NaN]; + } + + data.setItemLayout(idx, point); + }, true); + }); + }; + + +/***/ }, +/* 105 */ +/***/ function(module, exports) { + + + var samplers = { + average: function (frame) { + var sum = 0; + var count = 0; + for (var i = 0; i < frame.length; i++) { + if (!isNaN(frame[i])) { + sum += frame[i]; + count++; + } + } + // Return NaN if count is 0 + return count === 0 ? NaN : sum / count; + }, + sum: function (frame) { + var sum = 0; + for (var i = 0; i < frame.length; i++) { + // Ignore NaN + sum += frame[i] || 0; + } + return sum; + }, + max: function (frame) { + var max = -Infinity; + for (var i = 0; i < frame.length; i++) { + frame[i] > max && (max = frame[i]); + } + return max; + }, + min: function (frame) { + var min = Infinity; + for (var i = 0; i < frame.length; i++) { + frame[i] < min && (min = frame[i]); + } + return min; + } + }; + + var indexSampler = function (frame, value) { + return Math.round(frame.length / 2); + }; + module.exports = function (seriesType, ecModel, api) { + ecModel.eachSeriesByType(seriesType, function (seriesModel) { + var data = seriesModel.getData(); + var sampling = seriesModel.get('sampling'); + var coordSys = seriesModel.coordinateSystem; + // Only cartesian2d support down sampling + if (coordSys.type === 'cartesian2d' && sampling) { + var baseAxis = coordSys.getBaseAxis(); + var valueAxis = coordSys.getOtherAxis(baseAxis); + var extent = baseAxis.getExtent(); + // Coordinste system has been resized + var size = extent[1] - extent[0]; + var rate = Math.round(data.count() / size); + if (rate > 1) { + var sampler; + if (typeof sampling === 'string') { + sampler = samplers[sampling]; + } + else if (typeof sampling === 'function') { + sampler = sampling; + } + if (sampler) { + data = data.downSample( + valueAxis.dim, 1 / rate, sampler, indexSampler + ); + seriesModel.setData(data); + } + } + } + }, this); + }; + + +/***/ }, +/* 106 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + + __webpack_require__(107); + + __webpack_require__(124); + + // Grid view + __webpack_require__(1).extendComponentView({ + + type: 'grid', + + render: function (gridModel, ecModel) { + this.group.removeAll(); + if (gridModel.get('show')) { + this.group.add(new graphic.Rect({ + shape:gridModel.coordinateSystem.getRect(), + style: zrUtil.defaults({ + fill: gridModel.get('backgroundColor') + }, gridModel.getItemStyle()), + silent: true + })); + } + } + }); + + +/***/ }, +/* 107 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Grid is a region which contains at most 4 cartesian systems + * + * TODO Default cartesian + */ + var factory = exports; + + var layout = __webpack_require__(21); + var axisHelper = __webpack_require__(108); + + var zrUtil = __webpack_require__(3); + var Cartesian2D = __webpack_require__(114); + var Axis2D = __webpack_require__(116); + + var each = zrUtil.each; + + var ifAxisCrossZero = axisHelper.ifAxisCrossZero; + var niceScaleExtent = axisHelper.niceScaleExtent; + + // 依赖 GridModel, AxisModel 做预处理 + __webpack_require__(119); + + /** + * Check if the axis is used in the specified grid + * @inner + */ + function isAxisUsedInTheGrid(axisModel, gridModel, ecModel) { + return ecModel.getComponent('grid', axisModel.get('gridIndex')) === gridModel; + } + + function getLabelUnionRect(axis) { + var axisModel = axis.model; + var labels = axisModel.getFormattedLabels(); + var rect; + var step = 1; + var labelCount = labels.length; + if (labelCount > 40) { + // Simple optimization for large amount of labels + step = Math.ceil(labelCount / 40); + } + for (var i = 0; i < labelCount; i += step) { + if (!axis.isLabelIgnored(i)) { + var singleRect = axisModel.getTextRect(labels[i]); + // FIXME consider label rotate + rect ? rect.union(singleRect) : (rect = singleRect); + } + } + return rect; + } + + function Grid(gridModel, ecModel, api) { + /** + * @type {Object.} + * @private + */ + this._coordsMap = {}; + + /** + * @type {Array.} + * @private + */ + this._coordsList = []; + + /** + * @type {Object.} + * @private + */ + this._axesMap = {}; + + /** + * @type {Array.} + * @private + */ + this._axesList = []; + + this._initCartesian(gridModel, ecModel, api); + + this._model = gridModel; + } + + var gridProto = Grid.prototype; + + gridProto.type = 'grid'; + + gridProto.getRect = function () { + return this._rect; + }; + + gridProto.update = function (ecModel, api) { + + var axesMap = this._axesMap; + + this._updateScale(ecModel, this._model); + + function ifAxisCanNotOnZero(otherAxisDim) { + var axes = axesMap[otherAxisDim]; + for (var idx in axes) { + var axis = axes[idx]; + if (axis && (axis.type === 'category' || !ifAxisCrossZero(axis))) { + return true; + } + } + return false; + } + + each(axesMap.x, function (xAxis) { + niceScaleExtent(xAxis, xAxis.model); + }); + each(axesMap.y, function (yAxis) { + niceScaleExtent(yAxis, yAxis.model); + }); + // Fix configuration + each(axesMap.x, function (xAxis) { + // onZero can not be enabled in these two situations + // 1. When any other axis is a category axis + // 2. When any other axis not across 0 point + if (ifAxisCanNotOnZero('y')) { + xAxis.onZero = false; + } + }); + each(axesMap.y, function (yAxis) { + if (ifAxisCanNotOnZero('x')) { + yAxis.onZero = false; + } + }); + + // Resize again if containLabel is enabled + // FIXME It may cause getting wrong grid size in data processing stage + this.resize(this._model, api); + }; + + /** + * Resize the grid + * @param {module:echarts/coord/cartesian/GridModel} gridModel + * @param {module:echarts/ExtensionAPI} api + */ + gridProto.resize = function (gridModel, api) { + + var gridRect = layout.getLayoutRect( + gridModel.getBoxLayoutParams(), { + width: api.getWidth(), + height: api.getHeight() + }); + + this._rect = gridRect; + + var axesList = this._axesList; + + adjustAxes(); + + // Minus label size + if (gridModel.get('containLabel')) { + each(axesList, function (axis) { + if (!axis.model.get('axisLabel.inside')) { + var labelUnionRect = getLabelUnionRect(axis); + if (labelUnionRect) { + var dim = axis.isHorizontal() ? 'height' : 'width'; + var margin = axis.model.get('axisLabel.margin'); + gridRect[dim] -= labelUnionRect[dim] + margin; + if (axis.position === 'top') { + gridRect.y += labelUnionRect.height + margin; + } + else if (axis.position === 'left') { + gridRect.x += labelUnionRect.width + margin; + } + } + } + }); + + adjustAxes(); + } + + function adjustAxes() { + each(axesList, function (axis) { + var isHorizontal = axis.isHorizontal(); + var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height]; + var idx = axis.inverse ? 1 : 0; + axis.setExtent(extent[idx], extent[1 - idx]); + updateAxisTransfrom(axis, isHorizontal ? gridRect.x : gridRect.y); + }); + } + }; + + /** + * @param {string} axisType + * @param {ndumber} [axisIndex] + */ + gridProto.getAxis = function (axisType, axisIndex) { + var axesMapOnDim = this._axesMap[axisType]; + if (axesMapOnDim != null) { + if (axisIndex == null) { + // Find first axis + for (var name in axesMapOnDim) { + return axesMapOnDim[name]; + } + } + return axesMapOnDim[axisIndex]; + } + }; + + gridProto.getCartesian = function (xAxisIndex, yAxisIndex) { + var key = 'x' + xAxisIndex + 'y' + yAxisIndex; + return this._coordsMap[key]; + }; + + /** + * Initialize cartesian coordinate systems + * @private + */ + gridProto._initCartesian = function (gridModel, ecModel, api) { + var axisPositionUsed = { + left: false, + right: false, + top: false, + bottom: false + }; + + var axesMap = { + x: {}, + y: {} + }; + var axesCount = { + x: 0, + y: 0 + }; + + /// Create axis + ecModel.eachComponent('xAxis', createAxisCreator('x'), this); + ecModel.eachComponent('yAxis', createAxisCreator('y'), this); + + if (!axesCount.x || !axesCount.y) { + // Roll back when there no either x or y axis + this._axesMap = {}; + this._axesList = []; + return; + } + + this._axesMap = axesMap; + + /// Create cartesian2d + each(axesMap.x, function (xAxis, xAxisIndex) { + each(axesMap.y, function (yAxis, yAxisIndex) { + var key = 'x' + xAxisIndex + 'y' + yAxisIndex; + var cartesian = new Cartesian2D(key); + + cartesian.grid = this; + + this._coordsMap[key] = cartesian; + this._coordsList.push(cartesian); + + cartesian.addAxis(xAxis); + cartesian.addAxis(yAxis); + }, this); + }, this); + + function createAxisCreator(axisType) { + return function (axisModel, idx) { + if (!isAxisUsedInTheGrid(axisModel, gridModel, ecModel)) { + return; + } + + var axisPosition = axisModel.get('position'); + if (axisType === 'x') { + // Fix position + if (axisPosition !== 'top' && axisPosition !== 'bottom') { + // Default bottom of X + axisPosition = 'bottom'; + } + if (axisPositionUsed[axisPosition]) { + axisPosition = axisPosition === 'top' ? 'bottom' : 'top'; + } + } + else { + // Fix position + if (axisPosition !== 'left' && axisPosition !== 'right') { + // Default left of Y + axisPosition = 'left'; + } + if (axisPositionUsed[axisPosition]) { + axisPosition = axisPosition === 'left' ? 'right' : 'left'; + } + } + axisPositionUsed[axisPosition] = true; + + var axis = new Axis2D( + axisType, axisHelper.createScaleByModel(axisModel), + [0, 0], + axisModel.get('type'), + axisPosition + ); + + var isCategory = axis.type === 'category'; + axis.onBand = isCategory && axisModel.get('boundaryGap'); + axis.inverse = axisModel.get('inverse'); + + axis.onZero = axisModel.get('axisLine.onZero'); + + // Inject axis into axisModel + axisModel.axis = axis; + + // Inject axisModel into axis + axis.model = axisModel; + + // Index of axis, can be used as key + axis.index = idx; + + this._axesList.push(axis); + + axesMap[axisType][idx] = axis; + axesCount[axisType]++; + }; + } + }; + + /** + * Update cartesian properties from series + * @param {module:echarts/model/Option} option + * @private + */ + gridProto._updateScale = function (ecModel, gridModel) { + // Reset scale + zrUtil.each(this._axesList, function (axis) { + axis.scale.setExtent(Infinity, -Infinity); + }); + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.get('coordinateSystem') === 'cartesian2d') { + var xAxisIndex = seriesModel.get('xAxisIndex'); + var yAxisIndex = seriesModel.get('yAxisIndex'); + + var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex); + var yAxisModel = ecModel.getComponent('yAxis', yAxisIndex); + + if (!isAxisUsedInTheGrid(xAxisModel, gridModel, ecModel) + || !isAxisUsedInTheGrid(yAxisModel, gridModel, ecModel) + ) { + return; + } + + var cartesian = this.getCartesian(xAxisIndex, yAxisIndex); + var data = seriesModel.getData(); + var xAxis = cartesian.getAxis('x'); + var yAxis = cartesian.getAxis('y'); + + if (data.type === 'list') { + unionExtent(data, xAxis, seriesModel); + unionExtent(data, yAxis, seriesModel); + } + } + }, this); + + function unionExtent(data, axis, seriesModel) { + each(seriesModel.coordDimToDataDim(axis.dim), function (dim) { + axis.scale.unionExtent(data.getDataExtent( + dim, axis.scale.type !== 'ordinal' + )); + }); + } + }; + + /** + * @inner + */ + function updateAxisTransfrom(axis, coordBase) { + var axisExtent = axis.getExtent(); + var axisExtentSum = axisExtent[0] + axisExtent[1]; + + // Fast transform + axis.toGlobalCoord = axis.dim === 'x' + ? function (coord) { + return coord + coordBase; + } + : function (coord) { + return axisExtentSum - coord + coordBase; + }; + axis.toLocalCoord = axis.dim === 'x' + ? function (coord) { + return coord - coordBase; + } + : function (coord) { + return axisExtentSum - coord + coordBase; + }; + } + + Grid.create = function (ecModel, api) { + var grids = []; + ecModel.eachComponent('grid', function (gridModel, idx) { + var grid = new Grid(gridModel, ecModel, api); + grid.name = 'grid_' + idx; + grid.resize(gridModel, api); + + gridModel.coordinateSystem = grid; + + grids.push(grid); + }); + + // Inject the coordinateSystems into seriesModel + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.get('coordinateSystem') !== 'cartesian2d') { + return; + } + var xAxisIndex = seriesModel.get('xAxisIndex'); + // TODO Validate + var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex); + var grid = grids[xAxisModel.get('gridIndex')]; + seriesModel.coordinateSystem = grid.getCartesian( + xAxisIndex, seriesModel.get('yAxisIndex') + ); + }); + + return grids; + }; + + // For deciding which dimensions to use when creating list data + Grid.dimensions = Cartesian2D.prototype.dimensions; + + __webpack_require__(25).register('cartesian2d', Grid); + + module.exports = Grid; + + +/***/ }, +/* 108 */ +/***/ function(module, exports, __webpack_require__) { + + + + var OrdinalScale = __webpack_require__(109); + var IntervalScale = __webpack_require__(111); + __webpack_require__(112); + __webpack_require__(113); + var Scale = __webpack_require__(110); + + var numberUtil = __webpack_require__(7); + var zrUtil = __webpack_require__(3); + var textContain = __webpack_require__(14); + var axisHelper = {}; + + /** + * Get axis scale extent before niced. + */ + axisHelper.getScaleExtent = function (axis, model) { + var scale = axis.scale; + var originalExtent = scale.getExtent(); + var span = originalExtent[1] - originalExtent[0]; + if (scale.type === 'ordinal') { + // If series has no data, scale extent may be wrong + if (!isFinite(span)) { + return [0, 0]; + } + else { + return originalExtent; + } + } + var min = model.getMin ? model.getMin() : model.get('min'); + var max = model.getMax ? model.getMax() : model.get('max'); + var crossZero = model.getNeedCrossZero + ? model.getNeedCrossZero() : !model.get('scale'); + var boundaryGap = model.get('boundaryGap'); + if (!zrUtil.isArray(boundaryGap)) { + boundaryGap = [boundaryGap || 0, boundaryGap || 0]; + } + boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], 1); + boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], 1); + var fixMin = true; + var fixMax = true; + // Add boundary gap + if (min == null) { + min = originalExtent[0] - boundaryGap[0] * span; + fixMin = false; + } + if (max == null) { + max = originalExtent[1] + boundaryGap[1] * span; + fixMax = false; + } + // TODO Only one data + if (min === 'dataMin') { + min = originalExtent[0]; + } + if (max === 'dataMax') { + max = originalExtent[1]; + } + // Evaluate if axis needs cross zero + if (crossZero) { + // Axis is over zero and min is not set + if (min > 0 && max > 0 && !fixMin) { + min = 0; + } + // Axis is under zero and max is not set + if (min < 0 && max < 0 && !fixMax) { + max = 0; + } + } + return [min, max]; + }; + + axisHelper.niceScaleExtent = function (axis, model) { + var scale = axis.scale; + var extent = axisHelper.getScaleExtent(axis, model); + var fixMin = model.get('min') != null; + var fixMax = model.get('max') != null; + scale.setExtent(extent[0], extent[1]); + scale.niceExtent(model.get('splitNumber'), fixMin, fixMax); + + // If some one specified the min, max. And the default calculated interval + // is not good enough. He can specify the interval. It is often appeared + // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard + // to be 60. + // FIXME + var interval = model.get('interval'); + if (interval != null) { + scale.setInterval && scale.setInterval(interval); + } + }; + + /** + * @param {module:echarts/model/Model} model + * @param {string} [axisType] Default retrieve from model.type + * @return {module:echarts/scale/*} + */ + axisHelper.createScaleByModel = function(model, axisType) { + axisType = axisType || model.get('type'); + if (axisType) { + switch (axisType) { + // Buildin scale + case 'category': + return new OrdinalScale( + model.getCategories(), [Infinity, -Infinity] + ); + case 'value': + return new IntervalScale(); + // Extended scale, like time and log + default: + return (Scale.getClass(axisType) || IntervalScale).create(model); + } + } + }; + + /** + * Check if the axis corss 0 + */ + axisHelper.ifAxisCrossZero = function (axis) { + var dataExtent = axis.scale.getExtent(); + var min = dataExtent[0]; + var max = dataExtent[1]; + return !((min > 0 && max > 0) || (min < 0 && max < 0)); + }; + + /** + * @param {Array.} tickCoords In axis self coordinate. + * @param {Array.} labels + * @param {string} font + * @param {boolean} isAxisHorizontal + * @return {number} + */ + axisHelper.getAxisLabelInterval = function (tickCoords, labels, font, isAxisHorizontal) { + // FIXME + // 不同角的axis和label,不只是horizontal和vertical. + + var textSpaceTakenRect; + var autoLabelInterval = 0; + var accumulatedLabelInterval = 0; + + var step = 1; + if (labels.length > 40) { + // Simple optimization for large amount of labels + step = Math.round(labels.length / 40); + } + for (var i = 0; i < tickCoords.length; i += step) { + var tickCoord = tickCoords[i]; + var rect = textContain.getBoundingRect( + labels[i], font, 'center', 'top' + ); + rect[isAxisHorizontal ? 'x' : 'y'] += tickCoord; + rect[isAxisHorizontal ? 'width' : 'height'] *= 1.5; + if (!textSpaceTakenRect) { + textSpaceTakenRect = rect.clone(); + } + // There is no space for current label; + else if (textSpaceTakenRect.intersect(rect)) { + accumulatedLabelInterval++; + autoLabelInterval = Math.max(autoLabelInterval, accumulatedLabelInterval); + } + else { + textSpaceTakenRect.union(rect); + // Reset + accumulatedLabelInterval = 0; + } + } + if (autoLabelInterval === 0 && step > 1) { + return step; + } + return autoLabelInterval * step; + }; + + /** + * @param {Object} axis + * @param {Function} labelFormatter + * @return {Array.} + */ + axisHelper.getFormattedLabels = function (axis, labelFormatter) { + var scale = axis.scale; + var labels = scale.getTicksLabels(); + var ticks = scale.getTicks(); + if (typeof labelFormatter === 'string') { + labelFormatter = (function (tpl) { + return function (val) { + return tpl.replace('{value}', val); + }; + })(labelFormatter); + return zrUtil.map(labels, labelFormatter); + } + else if (typeof labelFormatter === 'function') { + return zrUtil.map(ticks, function (tick, idx) { + return labelFormatter( + axis.type === 'category' ? scale.getLabel(tick) : tick, + idx + ); + }, this); + } + else { + return labels; + } + }; + + module.exports = axisHelper; + + +/***/ }, +/* 109 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Linear continuous scale + * @module echarts/coord/scale/Ordinal + * + * http://en.wikipedia.org/wiki/Level_of_measurement + */ + + // FIXME only one data + + + var zrUtil = __webpack_require__(3); + var Scale = __webpack_require__(110); + + var scaleProto = Scale.prototype; + + var OrdinalScale = Scale.extend({ + + type: 'ordinal', + + init: function (data, extent) { + this._data = data; + this._extent = extent || [0, data.length - 1]; + }, + + parse: function (val) { + return typeof val === 'string' + ? zrUtil.indexOf(this._data, val) + // val might be float. + : Math.round(val); + }, + + contain: function (rank) { + rank = this.parse(rank); + return scaleProto.contain.call(this, rank) + && this._data[rank] != null; + }, + + /** + * Normalize given rank or name to linear [0, 1] + * @param {number|string} [val] + * @return {number} + */ + normalize: function (val) { + return scaleProto.normalize.call(this, this.parse(val)); + }, + + scale: function (val) { + return Math.round(scaleProto.scale.call(this, val)); + }, + + /** + * @return {Array} + */ + getTicks: function () { + var ticks = []; + var extent = this._extent; + var rank = extent[0]; + + while (rank <= extent[1]) { + ticks.push(rank); + rank++; + } + + return ticks; + }, + + /** + * Get item on rank n + * @param {number} n + * @return {string} + */ + getLabel: function (n) { + return this._data[n]; + }, + + /** + * @return {number} + */ + count: function () { + return this._extent[1] - this._extent[0] + 1; + }, + + niceTicks: zrUtil.noop, + niceExtent: zrUtil.noop + }); + + /** + * @return {module:echarts/scale/Time} + */ + OrdinalScale.create = function () { + return new OrdinalScale(); + }; + + module.exports = OrdinalScale; + + +/***/ }, +/* 110 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * // Scale class management + * @module echarts/scale/Scale + */ + + + var clazzUtil = __webpack_require__(9); + + function Scale() { + /** + * Extent + * @type {Array.} + * @protected + */ + this._extent = [Infinity, -Infinity]; + + /** + * Step is calculated in adjustExtent + * @type {Array.} + * @protected + */ + this._interval = 0; + + this.init && this.init.apply(this, arguments); + } + + var scaleProto = Scale.prototype; + + /** + * Parse input val to valid inner number. + * @param {*} val + * @return {number} + */ + scaleProto.parse = function (val) { + // Notice: This would be a trap here, If the implementation + // of this method depends on extent, and this method is used + // before extent set (like in dataZoom), it would be wrong. + // Nevertheless, parse does not depend on extent generally. + return val; + }; + + scaleProto.contain = function (val) { + var extent = this._extent; + return val >= extent[0] && val <= extent[1]; + }; + + /** + * Normalize value to linear [0, 1], return 0.5 if extent span is 0 + * @param {number} val + * @return {number} + */ + scaleProto.normalize = function (val) { + var extent = this._extent; + if (extent[1] === extent[0]) { + return 0.5; + } + return (val - extent[0]) / (extent[1] - extent[0]); + }; + + /** + * Scale normalized value + * @param {number} val + * @return {number} + */ + scaleProto.scale = function (val) { + var extent = this._extent; + return val * (extent[1] - extent[0]) + extent[0]; + }; + + /** + * Set extent from data + * @param {Array.} other + */ + scaleProto.unionExtent = function (other) { + var extent = this._extent; + other[0] < extent[0] && (extent[0] = other[0]); + other[1] > extent[1] && (extent[1] = other[1]); + // not setExtent because in log axis it may transformed to power + // this.setExtent(extent[0], extent[1]); + }; + + /** + * Get extent + * @return {Array.} + */ + scaleProto.getExtent = function () { + return this._extent.slice(); + }; + + /** + * Set extent + * @param {number} start + * @param {number} end + */ + scaleProto.setExtent = function (start, end) { + var thisExtent = this._extent; + if (!isNaN(start)) { + thisExtent[0] = start; + } + if (!isNaN(end)) { + thisExtent[1] = end; + } + }; + + /** + * @return {Array.} + */ + scaleProto.getTicksLabels = function () { + var labels = []; + var ticks = this.getTicks(); + for (var i = 0; i < ticks.length; i++) { + labels.push(this.getLabel(ticks[i])); + } + return labels; + }; + + clazzUtil.enableClassExtend(Scale); + clazzUtil.enableClassManagement(Scale, { + registerWhenExtend: true + }); + + module.exports = Scale; + + +/***/ }, +/* 111 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Interval scale + * @module echarts/scale/Interval + */ + + + + var numberUtil = __webpack_require__(7); + var formatUtil = __webpack_require__(6); + var Scale = __webpack_require__(110); + + var mathFloor = Math.floor; + var mathCeil = Math.ceil; + /** + * @alias module:echarts/coord/scale/Interval + * @constructor + */ + var IntervalScale = Scale.extend({ + + type: 'interval', + + _interval: 0, + + setExtent: function (start, end) { + var thisExtent = this._extent; + //start,end may be a Number like '25',so... + if (!isNaN(start)) { + thisExtent[0] = parseFloat(start); + } + if (!isNaN(end)) { + thisExtent[1] = parseFloat(end); + } + }, + + unionExtent: function (other) { + var extent = this._extent; + other[0] < extent[0] && (extent[0] = other[0]); + other[1] > extent[1] && (extent[1] = other[1]); + + // unionExtent may called by it's sub classes + IntervalScale.prototype.setExtent.call(this, extent[0], extent[1]); + }, + /** + * Get interval + */ + getInterval: function () { + if (!this._interval) { + this.niceTicks(); + } + return this._interval; + }, + + /** + * Set interval + */ + setInterval: function (interval) { + this._interval = interval; + // Dropped auto calculated niceExtent and use user setted extent + // We assume user wan't to set both interval, min, max to get a better result + this._niceExtent = this._extent.slice(); + }, + + /** + * @return {Array.} + */ + getTicks: function () { + if (!this._interval) { + this.niceTicks(); + } + var interval = this._interval; + var extent = this._extent; + var ticks = []; + + // Consider this case: using dataZoom toolbox, zoom and zoom. + var safeLimit = 10000; + + if (interval) { + var niceExtent = this._niceExtent; + if (extent[0] < niceExtent[0]) { + ticks.push(extent[0]); + } + var tick = niceExtent[0]; + while (tick <= niceExtent[1]) { + ticks.push(tick); + // Avoid rounding error + tick = numberUtil.round(tick + interval); + if (ticks.length > safeLimit) { + return []; + } + } + if (extent[1] > niceExtent[1]) { + ticks.push(extent[1]); + } + } + + return ticks; + }, + + /** + * @return {Array.} + */ + getTicksLabels: function () { + var labels = []; + var ticks = this.getTicks(); + for (var i = 0; i < ticks.length; i++) { + labels.push(this.getLabel(ticks[i])); + } + return labels; + }, + + /** + * @param {number} n + * @return {number} + */ + getLabel: function (data) { + return formatUtil.addCommas(data); + }, + + /** + * Update interval and extent of intervals for nice ticks + * + * @param {number} [splitNumber = 5] Desired number of ticks + */ + niceTicks: function (splitNumber) { + splitNumber = splitNumber || 5; + var extent = this._extent; + var span = extent[1] - extent[0]; + if (!isFinite(span)) { + return; + } + // User may set axis min 0 and data are all negative + // FIXME If it needs to reverse ? + if (span < 0) { + span = -span; + extent.reverse(); + } + + // From "Nice Numbers for Graph Labels" of Graphic Gems + // var niceSpan = numberUtil.nice(span, false); + var step = numberUtil.nice(span / splitNumber, true); + + // Niced extent inside original extent + var niceExtent = [ + numberUtil.round(mathCeil(extent[0] / step) * step), + numberUtil.round(mathFloor(extent[1] / step) * step) + ]; + + this._interval = step; + this._niceExtent = niceExtent; + }, + + /** + * Nice extent. + * @param {number} [splitNumber = 5] Given approx tick number + * @param {boolean} [fixMin=false] + * @param {boolean} [fixMax=false] + */ + niceExtent: function (splitNumber, fixMin, fixMax) { + var extent = this._extent; + // If extent start and end are same, expand them + if (extent[0] === extent[1]) { + if (extent[0] !== 0) { + // Expand extent + var expandSize = extent[0] / 2; + extent[0] -= expandSize; + extent[1] += expandSize; + } + else { + extent[1] = 1; + } + } + var span = extent[1] - extent[0]; + // If there are no data and extent are [Infinity, -Infinity] + if (!isFinite(span)) { + extent[0] = 0; + extent[1] = 1; + } + + this.niceTicks(splitNumber); + + // var extent = this._extent; + var interval = this._interval; + + if (!fixMin) { + extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval); + } + if (!fixMax) { + extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval); + } + } + }); + + /** + * @return {module:echarts/scale/Time} + */ + IntervalScale.create = function () { + return new IntervalScale(); + }; + + module.exports = IntervalScale; + + + +/***/ }, +/* 112 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Interval scale + * @module echarts/coord/scale/Time + */ + + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var formatUtil = __webpack_require__(6); + + var IntervalScale = __webpack_require__(111); + + var intervalScaleProto = IntervalScale.prototype; + + var mathCeil = Math.ceil; + var mathFloor = Math.floor; + var ONE_DAY = 3600000 * 24; + + // FIXME 公用? + var bisect = function (a, x, lo, hi) { + while (lo < hi) { + var mid = lo + hi >>> 1; + if (a[mid][2] < x) { + lo = mid + 1; + } + else { + hi = mid; + } + } + return lo; + }; + + /** + * @alias module:echarts/coord/scale/Time + * @constructor + */ + var TimeScale = IntervalScale.extend({ + type: 'time', + + // Overwrite + getLabel: function (val) { + var stepLvl = this._stepLvl; + + var date = new Date(val); + + return formatUtil.formatTime(stepLvl[0], date); + }, + + // Overwrite + niceExtent: function (approxTickNum, fixMin, fixMax) { + var extent = this._extent; + // If extent start and end are same, expand them + if (extent[0] === extent[1]) { + // Expand extent + extent[0] -= ONE_DAY; + extent[1] += ONE_DAY; + } + // If there are no data and extent are [Infinity, -Infinity] + if (extent[1] === -Infinity && extent[0] === Infinity) { + var d = new Date(); + extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate()); + extent[0] = extent[1] - ONE_DAY; + } + + this.niceTicks(approxTickNum, fixMin, fixMax); + + // var extent = this._extent; + var interval = this._interval; + + if (!fixMin) { + extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval); + } + if (!fixMax) { + extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval); + } + }, + + // Overwrite + niceTicks: function (approxTickNum) { + approxTickNum = approxTickNum || 10; + + var extent = this._extent; + var span = extent[1] - extent[0]; + var approxInterval = span / approxTickNum; + var scaleLevelsLen = scaleLevels.length; + var idx = bisect(scaleLevels, approxInterval, 0, scaleLevelsLen); + + var level = scaleLevels[Math.min(idx, scaleLevelsLen - 1)]; + var interval = level[2]; + // Same with interval scale if span is much larger than 1 year + if (level[0] === 'year') { + var yearSpan = span / interval; + + // From "Nice Numbers for Graph Labels" of Graphic Gems + // var niceYearSpan = numberUtil.nice(yearSpan, false); + var yearStep = numberUtil.nice(yearSpan / approxTickNum, true); + + interval *= yearStep; + } + + var niceExtent = [ + mathCeil(extent[0] / interval) * interval, + mathFloor(extent[1] / interval) * interval + ]; + + this._stepLvl = level; + // Interval will be used in getTicks + this._interval = interval; + this._niceExtent = niceExtent; + }, + + parse: function (val) { + // val might be float. + return +numberUtil.parseDate(val); + } + }); + + zrUtil.each(['contain', 'normalize'], function (methodName) { + TimeScale.prototype[methodName] = function (val) { + return intervalScaleProto[methodName].call(this, this.parse(val)); + }; + }); + + // Steps from d3 + var scaleLevels = [ + // Format step interval + ['hh:mm:ss', 1, 1000], // 1s + ['hh:mm:ss', 5, 1000 * 5], // 5s + ['hh:mm:ss', 10, 1000 * 10], // 10s + ['hh:mm:ss', 15, 1000 * 15], // 15s + ['hh:mm:ss', 30, 1000 * 30], // 30s + ['hh:mm\nMM-dd',1, 60000], // 1m + ['hh:mm\nMM-dd',5, 60000 * 5], // 5m + ['hh:mm\nMM-dd',10, 60000 * 10], // 10m + ['hh:mm\nMM-dd',15, 60000 * 15], // 15m + ['hh:mm\nMM-dd',30, 60000 * 30], // 30m + ['hh:mm\nMM-dd',1, 3600000], // 1h + ['hh:mm\nMM-dd',2, 3600000 * 2], // 2h + ['hh:mm\nMM-dd',6, 3600000 * 6], // 6h + ['hh:mm\nMM-dd',12, 3600000 * 12], // 12h + ['MM-dd\nyyyy', 1, ONE_DAY], // 1d + ['week', 7, ONE_DAY * 7], // 7d + ['month', 1, ONE_DAY * 31], // 1M + ['quarter', 3, ONE_DAY * 380 / 4], // 3M + ['half-year', 6, ONE_DAY * 380 / 2], // 6M + ['year', 1, ONE_DAY * 380] // 1Y + ]; + + /** + * @return {module:echarts/scale/Time} + */ + TimeScale.create = function () { + return new TimeScale(); + }; + + module.exports = TimeScale; + + +/***/ }, +/* 113 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Log scale + * @module echarts/scale/Log + */ + + + var zrUtil = __webpack_require__(3); + var Scale = __webpack_require__(110); + var numberUtil = __webpack_require__(7); + + // Use some method of IntervalScale + var IntervalScale = __webpack_require__(111); + + var scaleProto = Scale.prototype; + var intervalScaleProto = IntervalScale.prototype; + + var mathFloor = Math.floor; + var mathCeil = Math.ceil; + var mathPow = Math.pow; + + var LOG_BASE = 10; + var mathLog = Math.log; + + var LogScale = Scale.extend({ + + type: 'log', + + /** + * @return {Array.} + */ + getTicks: function () { + return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) { + return numberUtil.round(mathPow(LOG_BASE, val)); + }); + }, + + /** + * @param {number} val + * @return {string} + */ + getLabel: intervalScaleProto.getLabel, + + /** + * @param {number} val + * @return {number} + */ + scale: function (val) { + val = scaleProto.scale.call(this, val); + return mathPow(LOG_BASE, val); + }, + + /** + * @param {number} start + * @param {number} end + */ + setExtent: function (start, end) { + start = mathLog(start) / mathLog(LOG_BASE); + end = mathLog(end) / mathLog(LOG_BASE); + intervalScaleProto.setExtent.call(this, start, end); + }, + + /** + * @return {number} end + */ + getExtent: function () { + var extent = scaleProto.getExtent.call(this); + extent[0] = mathPow(LOG_BASE, extent[0]); + extent[1] = mathPow(LOG_BASE, extent[1]); + return extent; + }, + + /** + * @param {Array.} extent + */ + unionExtent: function (extent) { + extent[0] = mathLog(extent[0]) / mathLog(LOG_BASE); + extent[1] = mathLog(extent[1]) / mathLog(LOG_BASE); + scaleProto.unionExtent.call(this, extent); + }, + + /** + * Update interval and extent of intervals for nice ticks + * @param {number} [approxTickNum = 10] Given approx tick number + */ + niceTicks: function (approxTickNum) { + approxTickNum = approxTickNum || 10; + var extent = this._extent; + var span = extent[1] - extent[0]; + if (span === Infinity || span <= 0) { + return; + } + + var interval = mathPow(10, mathFloor(mathLog(span / approxTickNum) / Math.LN10)); + var err = approxTickNum / span * interval; + + // Filter ticks to get closer to the desired count. + if (err <= 0.5) { + interval *= 10; + } + var niceExtent = [ + numberUtil.round(mathCeil(extent[0] / interval) * interval), + numberUtil.round(mathFloor(extent[1] / interval) * interval) + ]; + + this._interval = interval; + this._niceExtent = niceExtent; + }, + + /** + * Nice extent. + * @param {number} [approxTickNum = 10] Given approx tick number + * @param {boolean} [fixMin=false] + * @param {boolean} [fixMax=false] + */ + niceExtent: intervalScaleProto.niceExtent + }); + + zrUtil.each(['contain', 'normalize'], function (methodName) { + LogScale.prototype[methodName] = function (val) { + val = mathLog(val) / mathLog(LOG_BASE); + return scaleProto[methodName].call(this, val); + }; + }); + + LogScale.create = function () { + return new LogScale(); + }; + + module.exports = LogScale; + + +/***/ }, +/* 114 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var Cartesian = __webpack_require__(115); + + function Cartesian2D(name) { + + Cartesian.call(this, name); + } + + Cartesian2D.prototype = { + + constructor: Cartesian2D, + + type: 'cartesian2d', + + /** + * @type {Array.} + * @readOnly + */ + dimensions: ['x', 'y'], + + /** + * Base axis will be used on stacking. + * + * @return {module:echarts/coord/cartesian/Axis2D} + */ + getBaseAxis: function () { + return this.getAxesByScale('ordinal')[0] + || this.getAxesByScale('time')[0] + || this.getAxis('x'); + }, + + /** + * If contain point + * @param {Array.} point + * @return {boolean} + */ + containPoint: function (point) { + var axisX = this.getAxis('x'); + var axisY = this.getAxis('y'); + return axisX.contain(axisX.toLocalCoord(point[0])) + && axisY.contain(axisY.toLocalCoord(point[1])); + }, + + /** + * If contain data + * @param {Array.} data + * @return {boolean} + */ + containData: function (data) { + return this.getAxis('x').containData(data[0]) + && this.getAxis('y').containData(data[1]); + }, + + /** + * Convert series data to an array of points + * @param {module:echarts/data/List} data + * @param {boolean} stack + * @return {Array} + * Return array of points. For example: + * `[[10, 10], [20, 20], [30, 30]]` + */ + dataToPoints: function (data, stack) { + return data.mapArray(['x', 'y'], function (x, y) { + return this.dataToPoint([x, y]); + }, stack, this); + }, + + /** + * @param {Array.} data + * @param {boolean} [clamp=false] + * @return {Array.} + */ + dataToPoint: function (data, clamp) { + var xAxis = this.getAxis('x'); + var yAxis = this.getAxis('y'); + return [ + xAxis.toGlobalCoord(xAxis.dataToCoord(data[0], clamp)), + yAxis.toGlobalCoord(yAxis.dataToCoord(data[1], clamp)) + ]; + }, + + /** + * @param {Array.} point + * @param {boolean} [clamp=false] + * @return {Array.} + */ + pointToData: function (point, clamp) { + var xAxis = this.getAxis('x'); + var yAxis = this.getAxis('y'); + return [ + xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp), + yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp) + ]; + }, + + /** + * Get other axis + * @param {module:echarts/coord/cartesian/Axis2D} axis + */ + getOtherAxis: function (axis) { + return this.getAxis(axis.dim === 'x' ? 'y' : 'x'); + } + }; + + zrUtil.inherits(Cartesian2D, Cartesian); + + module.exports = Cartesian2D; + + +/***/ }, +/* 115 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Cartesian coordinate system + * @module echarts/coord/Cartesian + * + */ + + + var zrUtil = __webpack_require__(3); + + function dimAxisMapper(dim) { + return this._axes[dim]; + } + + /** + * @alias module:echarts/coord/Cartesian + * @constructor + */ + var Cartesian = function (name) { + this._axes = {}; + + this._dimList = []; + + /** + * @type {string} + */ + this.name = name || ''; + }; + + Cartesian.prototype = { + + constructor: Cartesian, + + type: 'cartesian', + + /** + * Get axis + * @param {number|string} dim + * @return {module:echarts/coord/Cartesian~Axis} + */ + getAxis: function (dim) { + return this._axes[dim]; + }, + + /** + * Get axes list + * @return {Array.} + */ + getAxes: function () { + return zrUtil.map(this._dimList, dimAxisMapper, this); + }, + + /** + * Get axes list by given scale type + */ + getAxesByScale: function (scaleType) { + scaleType = scaleType.toLowerCase(); + return zrUtil.filter( + this.getAxes(), + function (axis) { + return axis.scale.type === scaleType; + } + ); + }, + + /** + * Add axis + * @param {module:echarts/coord/Cartesian.Axis} + */ + addAxis: function (axis) { + var dim = axis.dim; + + this._axes[dim] = axis; + + this._dimList.push(dim); + }, + + /** + * Convert data to coord in nd space + * @param {Array.|Object.} val + * @return {Array.|Object.} + */ + dataToCoord: function (val) { + return this._dataCoordConvert(val, 'dataToCoord'); + }, + + /** + * Convert coord in nd space to data + * @param {Array.|Object.} val + * @return {Array.|Object.} + */ + coordToData: function (val) { + return this._dataCoordConvert(val, 'coordToData'); + }, + + _dataCoordConvert: function (input, method) { + var dimList = this._dimList; + + var output = input instanceof Array ? [] : {}; + + for (var i = 0; i < dimList.length; i++) { + var dim = dimList[i]; + var axis = this._axes[dim]; + + output[dim] = axis[method](input[dim]); + } + + return output; + } + }; + + module.exports = Cartesian; + + +/***/ }, +/* 116 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var Axis = __webpack_require__(117); + var axisLabelInterval = __webpack_require__(118); + + /** + * Extend axis 2d + * @constructor module:echarts/coord/cartesian/Axis2D + * @extends {module:echarts/coord/cartesian/Axis} + * @param {string} dim + * @param {*} scale + * @param {Array.} coordExtent + * @param {string} axisType + * @param {string} position + */ + var Axis2D = function (dim, scale, coordExtent, axisType, position) { + Axis.call(this, dim, scale, coordExtent); + /** + * Axis type + * - 'category' + * - 'value' + * - 'time' + * - 'log' + * @type {string} + */ + this.type = axisType || 'value'; + + /** + * Axis position + * - 'top' + * - 'bottom' + * - 'left' + * - 'right' + */ + this.position = position || 'bottom'; + }; + + Axis2D.prototype = { + + constructor: Axis2D, + + /** + * Index of axis, can be used as key + */ + index: 0, + /** + * If axis is on the zero position of the other axis + * @type {boolean} + */ + onZero: false, + + /** + * Axis model + * @param {module:echarts/coord/cartesian/AxisModel} + */ + model: null, + + isHorizontal: function () { + var position = this.position; + return position === 'top' || position === 'bottom'; + }, + + getGlobalExtent: function () { + var ret = this.getExtent(); + ret[0] = this.toGlobalCoord(ret[0]); + ret[1] = this.toGlobalCoord(ret[1]); + return ret; + }, + + /** + * @return {number} + */ + getLabelInterval: function () { + var labelInterval = this._labelInterval; + if (!labelInterval) { + labelInterval = this._labelInterval = axisLabelInterval(this); + } + return labelInterval; + }, + + /** + * If label is ignored. + * Automatically used when axis is category and label can not be all shown + * @param {number} idx + * @return {boolean} + */ + isLabelIgnored: function (idx) { + if (this.type === 'category') { + var labelInterval = this.getLabelInterval(); + return ((typeof labelInterval === 'function') + && !labelInterval(idx, this.scale.getLabel(idx))) + || idx % (labelInterval + 1); + } + }, + + /** + * Transform global coord to local coord, + * i.e. var localCoord = axis.toLocalCoord(80); + * designate by module:echarts/coord/cartesian/Grid. + * @type {Function} + */ + toLocalCoord: null, + + /** + * Transform global coord to local coord, + * i.e. var globalCoord = axis.toLocalCoord(40); + * designate by module:echarts/coord/cartesian/Grid. + * @type {Function} + */ + toGlobalCoord: null + + }; + zrUtil.inherits(Axis2D, Axis); + + module.exports = Axis2D; + + +/***/ }, +/* 117 */ +/***/ function(module, exports, __webpack_require__) { + + + + var numberUtil = __webpack_require__(7); + var linearMap = numberUtil.linearMap; + var zrUtil = __webpack_require__(3); + + function fixExtentWithBands(extent, nTick) { + var size = extent[1] - extent[0]; + var len = nTick; + var margin = size / len / 2; + extent[0] += margin; + extent[1] -= margin; + } + + var normalizedExtent = [0, 1]; + /** + * @name module:echarts/coord/CartesianAxis + * @constructor + */ + var Axis = function (dim, scale, extent) { + + /** + * Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius' + * @type {string} + */ + this.dim = dim; + + /** + * Axis scale + * @type {module:echarts/coord/scale/*} + */ + this.scale = scale; + + /** + * @type {Array.} + * @private + */ + this._extent = extent || [0, 0]; + + /** + * @type {boolean} + */ + this.inverse = false; + + /** + * Usually true when axis has a ordinal scale + * @type {boolean} + */ + this.onBand = false; + }; + + Axis.prototype = { + + constructor: Axis, + + /** + * If axis extent contain given coord + * @param {number} coord + * @return {boolean} + */ + contain: function (coord) { + var extent = this._extent; + var min = Math.min(extent[0], extent[1]); + var max = Math.max(extent[0], extent[1]); + return coord >= min && coord <= max; + }, + + /** + * If axis extent contain given data + * @param {number} data + * @return {boolean} + */ + containData: function (data) { + return this.contain(this.dataToCoord(data)); + }, + + /** + * Get coord extent. + * @return {Array.} + */ + getExtent: function () { + var ret = this._extent.slice(); + return ret; + }, + + /** + * Get precision used for formatting + * @param {Array.} [dataExtent] + * @return {number} + */ + getPixelPrecision: function (dataExtent) { + return numberUtil.getPixelPrecision( + dataExtent || this.scale.getExtent(), + this._extent + ); + }, + + /** + * Set coord extent + * @param {number} start + * @param {number} end + */ + setExtent: function (start, end) { + var extent = this._extent; + extent[0] = start; + extent[1] = end; + }, + + /** + * Convert data to coord. Data is the rank if it has a ordinal scale + * @param {number} data + * @param {boolean} clamp + * @return {number} + */ + dataToCoord: function (data, clamp) { + var extent = this._extent; + var scale = this.scale; + data = scale.normalize(data); + + if (this.onBand && scale.type === 'ordinal') { + extent = extent.slice(); + fixExtentWithBands(extent, scale.count()); + } + + return linearMap(data, normalizedExtent, extent, clamp); + }, + + /** + * Convert coord to data. Data is the rank if it has a ordinal scale + * @param {number} coord + * @param {boolean} clamp + * @return {number} + */ + coordToData: function (coord, clamp) { + var extent = this._extent; + var scale = this.scale; + + if (this.onBand && scale.type === 'ordinal') { + extent = extent.slice(); + fixExtentWithBands(extent, scale.count()); + } + + var t = linearMap(coord, extent, normalizedExtent, clamp); + + return this.scale.scale(t); + }, + /** + * @return {Array.} + */ + getTicksCoords: function () { + if (this.onBand) { + var bands = this.getBands(); + var coords = []; + for (var i = 0; i < bands.length; i++) { + coords.push(bands[i][0]); + } + if (bands[i - 1]) { + coords.push(bands[i - 1][1]); + } + return coords; + } + else { + return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this); + } + }, + + /** + * Coords of labels are on the ticks or on the middle of bands + * @return {Array.} + */ + getLabelsCoords: function () { + if (this.onBand) { + var bands = this.getBands(); + var coords = []; + var band; + for (var i = 0; i < bands.length; i++) { + band = bands[i]; + coords.push((band[0] + band[1]) / 2); + } + return coords; + } + else { + return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this); + } + }, + + /** + * Get bands. + * + * If axis has labels [1, 2, 3, 4]. Bands on the axis are + * |---1---|---2---|---3---|---4---|. + * + * @return {Array} + */ + // FIXME Situation when labels is on ticks + getBands: function () { + var extent = this.getExtent(); + var bands = []; + var len = this.scale.count(); + var start = extent[0]; + var end = extent[1]; + var span = end - start; + + for (var i = 0; i < len; i++) { + bands.push([ + span * i / len + start, + span * (i + 1) / len + start + ]); + } + return bands; + }, + + /** + * Get width of band + * @return {number} + */ + getBandWidth: function () { + var axisExtent = this._extent; + var dataExtent = this.scale.getExtent(); + + var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0); + + var size = Math.abs(axisExtent[1] - axisExtent[0]); + + return Math.abs(size) / len; + } + }; + + module.exports = Axis; + + +/***/ }, +/* 118 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Helper function for axisLabelInterval calculation + */ + + + + var zrUtil = __webpack_require__(3); + var axisHelper = __webpack_require__(108); + + module.exports = function (axis) { + var axisModel = axis.model; + var labelModel = axisModel.getModel('axisLabel'); + var labelInterval = labelModel.get('interval'); + if (!(axis.type === 'category' && labelInterval === 'auto')) { + return labelInterval === 'auto' ? 0 : labelInterval; + } + + return axisHelper.getAxisLabelInterval( + zrUtil.map(axis.scale.getTicks(), axis.dataToCoord, axis), + axisModel.getFormattedLabels(), + labelModel.getModel('textStyle').getFont(), + axis.isHorizontal() + ); + }; + + +/***/ }, +/* 119 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // Grid 是在有直角坐标系的时候必须要存在的 + // 所以这里也要被 Cartesian2D 依赖 + + + __webpack_require__(120); + var ComponentModel = __webpack_require__(19); + + module.exports = ComponentModel.extend({ + + type: 'grid', + + dependencies: ['xAxis', 'yAxis'], + + layoutMode: 'box', + + /** + * @type {module:echarts/coord/cartesian/Grid} + */ + coordinateSystem: null, + + defaultOption: { + show: false, + zlevel: 0, + z: 0, + left: '10%', + top: 60, + right: '10%', + bottom: 60, + // If grid size contain label + containLabel: false, + // width: {totalWidth} - left - right, + // height: {totalHeight} - top - bottom, + backgroundColor: 'rgba(0,0,0,0)', + borderWidth: 1, + borderColor: '#ccc' + } + }); + + +/***/ }, +/* 120 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var ComponentModel = __webpack_require__(19); + var zrUtil = __webpack_require__(3); + var axisModelCreator = __webpack_require__(121); + + var AxisModel = ComponentModel.extend({ + + type: 'cartesian2dAxis', + + /** + * @type {module:echarts/coord/cartesian/Axis2D} + */ + axis: null, + + /** + * @override + */ + init: function () { + AxisModel.superApply(this, 'init', arguments); + this._resetRange(); + }, + + /** + * @override + */ + mergeOption: function () { + AxisModel.superApply(this, 'mergeOption', arguments); + this._resetRange(); + }, + + /** + * @override + */ + restoreData: function () { + AxisModel.superApply(this, 'restoreData', arguments); + this._resetRange(); + }, + + /** + * @public + * @param {number} rangeStart + * @param {number} rangeEnd + */ + setRange: function (rangeStart, rangeEnd) { + this.option.rangeStart = rangeStart; + this.option.rangeEnd = rangeEnd; + }, + + /** + * @public + * @return {Array.} + */ + getMin: function () { + var option = this.option; + return option.rangeStart != null ? option.rangeStart : option.min; + }, + + /** + * @public + * @return {Array.} + */ + getMax: function () { + var option = this.option; + return option.rangeEnd != null ? option.rangeEnd : option.max; + }, + + /** + * @public + * @return {boolean} + */ + getNeedCrossZero: function () { + var option = this.option; + return (option.rangeStart != null || option.rangeEnd != null) + ? false : !option.scale; + }, + + /** + * @private + */ + _resetRange: function () { + // rangeStart and rangeEnd is readonly. + this.option.rangeStart = this.option.rangeEnd = null; + } + + }); + + function getAxisType(axisDim, option) { + // Default axis with data is category axis + return option.type || (option.data ? 'category' : 'value'); + } + + zrUtil.merge(AxisModel.prototype, __webpack_require__(123)); + + var extraOption = { + gridIndex: 0 + }; + + axisModelCreator('x', AxisModel, getAxisType, extraOption); + axisModelCreator('y', AxisModel, getAxisType, extraOption); + + module.exports = AxisModel; + + +/***/ }, +/* 121 */ +/***/ function(module, exports, __webpack_require__) { + + + + var axisDefault = __webpack_require__(122); + var zrUtil = __webpack_require__(3); + var ComponentModel = __webpack_require__(19); + var layout = __webpack_require__(21); + + // FIXME axisType is fixed ? + var AXIS_TYPES = ['value', 'category', 'time', 'log']; + + /** + * Generate sub axis model class + * @param {string} axisName 'x' 'y' 'radius' 'angle' 'parallel' + * @param {module:echarts/model/Component} BaseAxisModelClass + * @param {Function} axisTypeDefaulter + * @param {Object} [extraDefaultOption] + */ + module.exports = function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) { + + zrUtil.each(AXIS_TYPES, function (axisType) { + + BaseAxisModelClass.extend({ + + type: axisName + 'Axis.' + axisType, + + mergeDefaultAndTheme: function (option, ecModel) { + var layoutMode = this.layoutMode; + var inputPositionParams = layoutMode + ? layout.getLayoutParams(option) : {}; + + var themeModel = ecModel.getTheme(); + zrUtil.merge(option, themeModel.get(axisType + 'Axis')); + zrUtil.merge(option, this.getDefaultOption()); + + option.type = axisTypeDefaulter(axisName, option); + + if (layoutMode) { + layout.mergeLayoutParam(option, inputPositionParams, layoutMode); + } + }, + + defaultOption: zrUtil.mergeAll( + [ + {}, + axisDefault[axisType + 'Axis'], + extraDefaultOption + ], + true + ) + }); + }); + + ComponentModel.registerSubTypeDefaulter( + axisName + 'Axis', + zrUtil.curry(axisTypeDefaulter, axisName) + ); + }; + + +/***/ }, +/* 122 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + var defaultOption = { + show: true, + zlevel: 0, // 一级层叠 + z: 0, // 二级层叠 + // 反向坐标轴 + inverse: false, + // 坐标轴名字,默认为空 + name: '', + // 坐标轴名字位置,支持'start' | 'middle' | 'end' + nameLocation: 'end', + // 坐标轴文字样式,默认取全局样式 + nameTextStyle: {}, + // 文字与轴线距离 + nameGap: 15, + // 坐标轴线 + axisLine: { + // 默认显示,属性show控制显示与否 + show: true, + onZero: true, + // 属性lineStyle控制线条样式 + lineStyle: { + color: '#333', + width: 1, + type: 'solid' + } + }, + // 坐标轴小标记 + axisTick: { + // 属性show控制显示与否,默认显示 + show: true, + // 控制小标记是否在grid里 + inside: false, + // 属性length控制线长 + length: 5, + // 属性lineStyle控制线条样式 + lineStyle: { + color: '#333', + width: 1 + } + }, + // 坐标轴文本标签,详见axis.axisLabel + axisLabel: { + show: true, + // 控制文本标签是否在grid里 + inside: false, + rotate: 0, + margin: 8, + // formatter: null, + // 其余属性默认使用全局文本样式,详见TEXTSTYLE + textStyle: { + color: '#333', + fontSize: 12 + } + }, + // 分隔线 + splitLine: { + // 默认显示,属性show控制显示与否 + show: true, + // 属性lineStyle(详见lineStyle)控制线条样式 + lineStyle: { + color: ['#ccc'], + width: 1, + type: 'solid' + } + }, + // 分隔区域 + splitArea: { + // 默认不显示,属性show控制显示与否 + show: false, + // 属性areaStyle(详见areaStyle)控制区域样式 + areaStyle: { + color: ['rgba(250,250,250,0.3)','rgba(200,200,200,0.3)'] + } + } + }; + + var categoryAxis = zrUtil.merge({ + // 类目起始和结束两端空白策略 + boundaryGap: true, + // 坐标轴小标记 + axisTick: { + interval: 'auto' + }, + // 坐标轴文本标签,详见axis.axisLabel + axisLabel: { + interval: 'auto' + } + }, defaultOption); + + var valueAxis = zrUtil.defaults({ + // 数值起始和结束两端空白策略 + boundaryGap: [0, 0], + // 最小值, 设置成 'dataMin' 则从数据中计算最小值 + // min: null, + // 最大值,设置成 'dataMax' 则从数据中计算最大值 + // max: null, + // Readonly prop, specifies start value of the range when using data zoom. + // rangeStart: null + // Readonly prop, specifies end value of the range when using data zoom. + // rangeEnd: null + // 脱离0值比例,放大聚焦到最终_min,_max区间 + // scale: false, + // 分割段数,默认为5 + splitNumber: 5 + }, defaultOption); + + // FIXME + var timeAxis = zrUtil.defaults({ + scale: true, + min: 'dataMin', + max: 'dataMax' + }, valueAxis); + var logAxis = zrUtil.defaults({}, valueAxis); + logAxis.scale = true; + + module.exports = { + categoryAxis: categoryAxis, + valueAxis: valueAxis, + timeAxis: timeAxis, + logAxis: logAxis + }; + + +/***/ }, +/* 123 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var axisHelper = __webpack_require__(108); + + function getName(obj) { + if (zrUtil.isObject(obj) && obj.value != null) { + return obj.value; + } + else { + return obj; + } + } + /** + * Get categories + */ + function getCategories() { + return this.get('type') === 'category' + && zrUtil.map(this.get('data'), getName); + } + + /** + * Format labels + * @return {Array.} + */ + function getFormattedLabels() { + return axisHelper.getFormattedLabels( + this.axis, + this.get('axisLabel.formatter') + ); + } + + module.exports = { + + getFormattedLabels: getFormattedLabels, + + getCategories: getCategories + }; + + +/***/ }, +/* 124 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // TODO boundaryGap + + + __webpack_require__(120); + + __webpack_require__(125); + + +/***/ }, +/* 125 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var AxisBuilder = __webpack_require__(126); + var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick; + var getInterval = AxisBuilder.getInterval; + + var axisBuilderAttrs = [ + 'axisLine', 'axisLabel', 'axisTick', 'axisName' + ]; + var selfBuilderAttrs = [ + 'splitLine', 'splitArea' + ]; + + var AxisView = __webpack_require__(1).extendComponentView({ + + type: 'axis', + + render: function (axisModel, ecModel) { + + this.group.removeAll(); + + if (!axisModel.get('show')) { + return; + } + + var gridModel = ecModel.getComponent('grid', axisModel.get('gridIndex')); + + var layout = layoutAxis(gridModel, axisModel); + + var axisBuilder = new AxisBuilder(axisModel, layout); + + zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder); + + this.group.add(axisBuilder.getGroup()); + + zrUtil.each(selfBuilderAttrs, function (name) { + if (axisModel.get(name +'.show')) { + this['_' + name](axisModel, gridModel, layout.labelInterval); + } + }, this); + }, + + /** + * @param {module:echarts/coord/cartesian/AxisModel} axisModel + * @param {module:echarts/coord/cartesian/GridModel} gridModel + * @param {number|Function} labelInterval + * @private + */ + _splitLine: function (axisModel, gridModel, labelInterval) { + var axis = axisModel.axis; + + var splitLineModel = axisModel.getModel('splitLine'); + var lineStyleModel = splitLineModel.getModel('lineStyle'); + var lineWidth = lineStyleModel.get('width'); + var lineColors = lineStyleModel.get('color'); + + var lineInterval = getInterval(splitLineModel, labelInterval); + + lineColors = zrUtil.isArray(lineColors) ? lineColors : [lineColors]; + + var gridRect = gridModel.coordinateSystem.getRect(); + var isHorizontal = axis.isHorizontal(); + + var splitLines = []; + var lineCount = 0; + + var ticksCoords = axis.getTicksCoords(); + + var p1 = []; + var p2 = []; + for (var i = 0; i < ticksCoords.length; i++) { + if (ifIgnoreOnTick(axis, i, lineInterval)) { + continue; + } + + var tickCoord = axis.toGlobalCoord(ticksCoords[i]); + + if (isHorizontal) { + p1[0] = tickCoord; + p1[1] = gridRect.y; + p2[0] = tickCoord; + p2[1] = gridRect.y + gridRect.height; + } + else { + p1[0] = gridRect.x; + p1[1] = tickCoord; + p2[0] = gridRect.x + gridRect.width; + p2[1] = tickCoord; + } + + var colorIndex = (lineCount++) % lineColors.length; + splitLines[colorIndex] = splitLines[colorIndex] || []; + splitLines[colorIndex].push(new graphic.Line(graphic.subPixelOptimizeLine({ + shape: { + x1: p1[0], + y1: p1[1], + x2: p2[0], + y2: p2[1] + }, + style: { + lineWidth: lineWidth + }, + silent: true + }))); + } + + // Simple optimization + // Batching the lines if color are the same + var lineStyle = lineStyleModel.getLineStyle(); + for (var i = 0; i < splitLines.length; i++) { + this.group.add(graphic.mergePath(splitLines[i], { + style: zrUtil.defaults({ + stroke: lineColors[i % lineColors.length] + }, lineStyle), + silent: true + })); + } + }, + + /** + * @param {module:echarts/coord/cartesian/AxisModel} axisModel + * @param {module:echarts/coord/cartesian/GridModel} gridModel + * @param {number|Function} labelInterval + * @private + */ + _splitArea: function (axisModel, gridModel, labelInterval) { + var axis = axisModel.axis; + + var splitAreaModel = axisModel.getModel('splitArea'); + var areaStyleModel = splitAreaModel.getModel('areaStyle'); + var areaColors = areaStyleModel.get('color'); + + var gridRect = gridModel.coordinateSystem.getRect(); + var ticksCoords = axis.getTicksCoords(); + + var prevX = axis.toGlobalCoord(ticksCoords[0]); + var prevY = axis.toGlobalCoord(ticksCoords[0]); + + var splitAreaRects = []; + var count = 0; + + var areaInterval = getInterval(splitAreaModel, labelInterval); + + areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors]; + + for (var i = 1; i < ticksCoords.length; i++) { + if (ifIgnoreOnTick(axis, i, areaInterval)) { + continue; + } + + var tickCoord = axis.toGlobalCoord(ticksCoords[i]); + + var x; + var y; + var width; + var height; + if (axis.isHorizontal()) { + x = prevX; + y = gridRect.y; + width = tickCoord - x; + height = gridRect.height; + } + else { + x = gridRect.x; + y = prevY; + width = gridRect.width; + height = tickCoord - y; + } + + var colorIndex = (count++) % areaColors.length; + splitAreaRects[colorIndex] = splitAreaRects[colorIndex] || []; + splitAreaRects[colorIndex].push(new graphic.Rect({ + shape: { + x: x, + y: y, + width: width, + height: height + }, + silent: true + })); + + prevX = x + width; + prevY = y + height; + } + + // Simple optimization + // Batching the rects if color are the same + var areaStyle = areaStyleModel.getAreaStyle(); + for (var i = 0; i < splitAreaRects.length; i++) { + this.group.add(graphic.mergePath(splitAreaRects[i], { + style: zrUtil.defaults({ + fill: areaColors[i % areaColors.length] + }, areaStyle), + silent: true + })); + } + } + }); + + AxisView.extend({ + type: 'xAxis' + }); + AxisView.extend({ + type: 'yAxis' + }); + + /** + * @inner + */ + function layoutAxis(gridModel, axisModel) { + var grid = gridModel.coordinateSystem; + var axis = axisModel.axis; + var layout = {}; + + var rawAxisPosition = axis.position; + var axisPosition = axis.onZero ? 'onZero' : rawAxisPosition; + var axisDim = axis.dim; + + // [left, right, top, bottom] + var rect = grid.getRect(); + var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height]; + + var posMap = { + x: {top: rectBound[2], bottom: rectBound[3]}, + y: {left: rectBound[0], right: rectBound[1]} + }; + posMap.x.onZero = Math.max(Math.min(getZero('y'), posMap.x.bottom), posMap.x.top); + posMap.y.onZero = Math.max(Math.min(getZero('x'), posMap.y.right), posMap.y.left); + + function getZero(dim, val) { + var theAxis = grid.getAxis(dim); + return theAxis.toGlobalCoord(theAxis.dataToCoord(0)); + } + + // Axis position + layout.position = [ + axisDim === 'y' ? posMap.y[axisPosition] : rectBound[0], + axisDim === 'x' ? posMap.x[axisPosition] : rectBound[3] + ]; + + // Axis rotation + var r = {x: 0, y: 1}; + layout.rotation = Math.PI / 2 * r[axisDim]; + + // Tick and label direction, x y is axisDim + var dirMap = {top: -1, bottom: 1, left: -1, right: 1}; + + layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition]; + if (axis.onZero) { + layout.labelOffset = posMap[axisDim][rawAxisPosition] - posMap[axisDim].onZero; + } + + if (axisModel.getModel('axisTick').get('inside')) { + layout.tickDirection = -layout.tickDirection; + } + if (axisModel.getModel('axisLabel').get('inside')) { + layout.labelDirection = -layout.labelDirection; + } + + // Special label rotation + var labelRotation = axisModel.getModel('axisLabel').get('rotate'); + layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation; + + // label interval when auto mode. + layout.labelInterval = axis.getLabelInterval(); + + // Over splitLine and splitArea + layout.z2 = 1; + + return layout; + } + + +/***/ }, +/* 126 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var Model = __webpack_require__(8); + var numberUtil = __webpack_require__(7); + var remRadian = numberUtil.remRadian; + var isRadianAroundZero = numberUtil.isRadianAroundZero; + + var PI = Math.PI; + + /** + * A final axis is translated and rotated from a "standard axis". + * So opt.position and opt.rotation is required. + * + * A standard axis is and axis from [0, 0] to [0, axisExtent[1]], + * for example: (0, 0) ------------> (0, 50) + * + * nameDirection or tickDirection or labelDirection is 1 means tick + * or label is below the standard axis, whereas is -1 means above + * the standard axis. labelOffset means offset between label and axis, + * which is useful when 'onZero', where axisLabel is in the grid and + * label in outside grid. + * + * Tips: like always, + * positive rotation represents anticlockwise, and negative rotation + * represents clockwise. + * The direction of position coordinate is the same as the direction + * of screen coordinate. + * + * Do not need to consider axis 'inverse', which is auto processed by + * axis extent. + * + * @param {module:zrender/container/Group} group + * @param {Object} axisModel + * @param {Object} opt Standard axis parameters. + * @param {Array.} opt.position [x, y] + * @param {number} opt.rotation by radian + * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'. + * @param {number} [opt.tickDirection=1] 1 or -1 + * @param {number} [opt.labelDirection=1] 1 or -1 + * @param {number} [opt.labelOffset=0] Usefull when onZero. + * @param {string} [opt.axisName] default get from axisModel. + * @param {number} [opt.labelRotation] by degree, default get from axisModel. + * @param {number} [opt.labelInterval] Default label interval when label + * interval from model is null or 'auto'. + * @param {number} [opt.strokeContainThreshold] Default label interval when label + * @param {number} [opt.silent=true] + */ + var AxisBuilder = function (axisModel, opt) { + + /** + * @readOnly + */ + this.opt = opt; + + /** + * @readOnly + */ + this.axisModel = axisModel; + + // Default value + zrUtil.defaults( + opt, + { + labelOffset: 0, + nameDirection: 1, + tickDirection: 1, + labelDirection: 1, + silent: true + } + ); + + /** + * @readOnly + */ + this.group = new graphic.Group({ + position: opt.position.slice(), + rotation: opt.rotation + }); + }; + + AxisBuilder.prototype = { + + constructor: AxisBuilder, + + hasBuilder: function (name) { + return !!builders[name]; + }, + + add: function (name) { + builders[name].call(this); + }, + + getGroup: function () { + return this.group; + } + + }; + + var builders = { + + /** + * @private + */ + axisLine: function () { + var opt = this.opt; + var axisModel = this.axisModel; + + if (!axisModel.get('axisLine.show')) { + return; + } + + var extent = this.axisModel.axis.getExtent(); + + this.group.add(new graphic.Line({ + shape: { + x1: extent[0], + y1: 0, + x2: extent[1], + y2: 0 + }, + style: zrUtil.extend( + {lineCap: 'round'}, + axisModel.getModel('axisLine.lineStyle').getLineStyle() + ), + strokeContainThreshold: opt.strokeContainThreshold, + silent: !!opt.silent, + z2: 1 + })); + }, + + /** + * @private + */ + axisTick: function () { + var axisModel = this.axisModel; + + if (!axisModel.get('axisTick.show')) { + return; + } + + var axis = axisModel.axis; + var tickModel = axisModel.getModel('axisTick'); + var opt = this.opt; + + var lineStyleModel = tickModel.getModel('lineStyle'); + var tickLen = tickModel.get('length'); + var tickInterval = getInterval(tickModel, opt.labelInterval); + var ticksCoords = axis.getTicksCoords(); + var tickLines = []; + + for (var i = 0; i < ticksCoords.length; i++) { + // Only ordinal scale support tick interval + if (ifIgnoreOnTick(axis, i, tickInterval)) { + continue; + } + + var tickCoord = ticksCoords[i]; + + // Tick line + tickLines.push(new graphic.Line(graphic.subPixelOptimizeLine({ + shape: { + x1: tickCoord, + y1: 0, + x2: tickCoord, + y2: opt.tickDirection * tickLen + }, + style: { + lineWidth: lineStyleModel.get('width') + }, + silent: true + }))); + } + + this.group.add(graphic.mergePath(tickLines, { + style: lineStyleModel.getLineStyle(), + z2: 2, + silent: true + })); + }, + + /** + * @param {module:echarts/coord/cartesian/AxisModel} axisModel + * @param {module:echarts/coord/cartesian/GridModel} gridModel + * @private + */ + axisLabel: function () { + var axisModel = this.axisModel; + + if (!axisModel.get('axisLabel.show')) { + return; + } + + var opt = this.opt; + var axis = axisModel.axis; + var labelModel = axisModel.getModel('axisLabel'); + var textStyleModel = labelModel.getModel('textStyle'); + var labelMargin = labelModel.get('margin'); + var ticks = axis.scale.getTicks(); + var labels = axisModel.getFormattedLabels(); + + // Special label rotate. + var labelRotation = opt.labelRotation; + if (labelRotation == null) { + labelRotation = labelModel.get('rotate') || 0; + } + // To radian. + labelRotation = labelRotation * PI / 180; + + var labelLayout = innerTextLayout(opt, labelRotation, opt.labelDirection); + var categoryData = axisModel.get('data'); + + var textEls = []; + for (var i = 0; i < ticks.length; i++) { + if (ifIgnoreOnTick(axis, i, opt.labelInterval)) { + continue; + } + + var itemTextStyleModel = textStyleModel; + if (categoryData && categoryData[i] && categoryData[i].textStyle) { + itemTextStyleModel = new Model( + categoryData[i].textStyle, textStyleModel, axisModel.ecModel + ); + } + + var tickCoord = axis.dataToCoord(ticks[i]); + var pos = [ + tickCoord, + opt.labelOffset + opt.labelDirection * labelMargin + ]; + + var textEl = new graphic.Text({ + style: { + text: labels[i], + textAlign: itemTextStyleModel.get('align', true) || labelLayout.textAlign, + textVerticalAlign: itemTextStyleModel.get('baseline', true) || labelLayout.verticalAlign, + textFont: itemTextStyleModel.getFont(), + fill: itemTextStyleModel.getTextColor() + }, + position: pos, + rotation: labelLayout.rotation, + silent: true, + z2: 10 + }); + textEls.push(textEl); + this.group.add(textEl); + } + + function isTwoLabelOverlapped(current, next) { + var firstRect = current && current.getBoundingRect().clone(); + var nextRect = next && next.getBoundingRect().clone(); + if (firstRect && nextRect) { + firstRect.applyTransform(current.getLocalTransform()); + nextRect.applyTransform(next.getLocalTransform()); + return firstRect.intersect(nextRect); + } + } + if (axis.type !== 'category') { + // If min or max are user set, we need to check + // If the tick on min(max) are overlap on their neighbour tick + // If they are overlapped, we need to hide the min(max) tick label + if (axisModel.getMin ? axisModel.getMin() : axisModel.get('min')) { + var firstLabel = textEls[0]; + var nextLabel = textEls[1]; + if (isTwoLabelOverlapped(firstLabel, nextLabel)) { + firstLabel.ignore = true; + } + } + if (axisModel.getMax ? axisModel.getMax() : axisModel.get('max')) { + var lastLabel = textEls[textEls.length - 1]; + var prevLabel = textEls[textEls.length - 2]; + if (isTwoLabelOverlapped(prevLabel, lastLabel)) { + lastLabel.ignore = true; + } + } + } + }, + + /** + * @private + */ + axisName: function () { + var opt = this.opt; + var axisModel = this.axisModel; + + var name = this.opt.axisName; + // If name is '', do not get name from axisMode. + if (name == null) { + name = axisModel.get('name'); + } + + if (!name) { + return; + } + + var nameLocation = axisModel.get('nameLocation'); + var nameDirection = opt.nameDirection; + var textStyleModel = axisModel.getModel('nameTextStyle'); + var gap = axisModel.get('nameGap') || 0; + + var extent = this.axisModel.axis.getExtent(); + var gapSignal = extent[0] > extent[1] ? -1 : 1; + var pos = [ + nameLocation === 'start' + ? extent[0] - gapSignal * gap + : nameLocation === 'end' + ? extent[1] + gapSignal * gap + : (extent[0] + extent[1]) / 2, // 'middle' + // Reuse labelOffset. + nameLocation === 'middle' ? opt.labelOffset + nameDirection * gap : 0 + ]; + + var labelLayout; + + if (nameLocation === 'middle') { + labelLayout = innerTextLayout(opt, opt.rotation, nameDirection); + } + else { + labelLayout = endTextLayout(opt, nameLocation, extent); + } + + this.group.add(new graphic.Text({ + style: { + text: name, + textFont: textStyleModel.getFont(), + fill: textStyleModel.getTextColor() + || axisModel.get('axisLine.lineStyle.color'), + textAlign: labelLayout.textAlign, + textVerticalAlign: labelLayout.verticalAlign + }, + position: pos, + rotation: labelLayout.rotation, + silent: true, + z2: 1 + })); + } + + }; + + /** + * @inner + */ + function innerTextLayout(opt, textRotation, direction) { + var rotationDiff = remRadian(textRotation - opt.rotation); + var textAlign; + var verticalAlign; + + if (isRadianAroundZero(rotationDiff)) { // Label is parallel with axis line. + verticalAlign = direction > 0 ? 'top' : 'bottom'; + textAlign = 'center'; + } + else if (isRadianAroundZero(rotationDiff - PI)) { // Label is inverse parallel with axis line. + verticalAlign = direction > 0 ? 'bottom' : 'top'; + textAlign = 'center'; + } + else { + verticalAlign = 'middle'; + + if (rotationDiff > 0 && rotationDiff < PI) { + textAlign = direction > 0 ? 'right' : 'left'; + } + else { + textAlign = direction > 0 ? 'left' : 'right'; + } + } + + return { + rotation: rotationDiff, + textAlign: textAlign, + verticalAlign: verticalAlign + }; + } + + /** + * @inner + */ + function endTextLayout(opt, textPosition, extent) { + var rotationDiff = remRadian(-opt.rotation); + var textAlign; + var verticalAlign; + var inverse = extent[0] > extent[1]; + var onLeft = (textPosition === 'start' && !inverse) + || (textPosition !== 'start' && inverse); + + if (isRadianAroundZero(rotationDiff - PI / 2)) { + verticalAlign = onLeft ? 'bottom' : 'top'; + textAlign = 'center'; + } + else if (isRadianAroundZero(rotationDiff - PI * 1.5)) { + verticalAlign = onLeft ? 'top' : 'bottom'; + textAlign = 'center'; + } + else { + verticalAlign = 'middle'; + if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) { + textAlign = onLeft ? 'left' : 'right'; + } + else { + textAlign = onLeft ? 'right' : 'left'; + } + } + + return { + rotation: rotationDiff, + textAlign: textAlign, + verticalAlign: verticalAlign + }; + } + + /** + * @static + */ + var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (axis, i, interval) { + var rawTick; + var scale = axis.scale; + return scale.type === 'ordinal' + && ( + typeof interval === 'function' + ? ( + rawTick = scale.getTicks()[i], + !interval(rawTick, scale.getLabel(rawTick)) + ) + : i % (interval + 1) + ); + }; + + /** + * @static + */ + var getInterval = AxisBuilder.getInterval = function (model, labelInterval) { + var interval = model.get('interval'); + if (interval == null || interval == 'auto') { + interval = labelInterval; + } + return interval; + }; + + module.exports = AxisBuilder; + + + +/***/ }, +/* 127 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + __webpack_require__(107); + + __webpack_require__(128); + __webpack_require__(129); + + var barLayoutGrid = __webpack_require__(131); + var echarts = __webpack_require__(1); + + echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar')); + // Visual coding for legend + echarts.registerVisualCoding('chart', function (ecModel) { + ecModel.eachSeriesByType('bar', function (seriesModel) { + var data = seriesModel.getData(); + data.setVisual('legendSymbol', 'roundRect'); + }); + }); + + // In case developer forget to include grid component + __webpack_require__(106); + + +/***/ }, +/* 128 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var SeriesModel = __webpack_require__(27); + var createListFromArray = __webpack_require__(93); + + module.exports = SeriesModel.extend({ + + type: 'series.bar', + + dependencies: ['grid', 'polar'], + + getInitialData: function (option, ecModel) { + return createListFromArray(option.data, this, ecModel); + }, + + getMarkerPosition: function (value) { + var coordSys = this.coordinateSystem; + if (coordSys) { + var pt = coordSys.dataToPoint(value); + var data = this.getData(); + var offset = data.getLayout('offset'); + var size = data.getLayout('size'); + var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1; + pt[offsetIndex] += offset + size / 2; + return pt; + } + return [NaN, NaN]; + }, + + defaultOption: { + zlevel: 0, // 一级层叠 + z: 2, // 二级层叠 + coordinateSystem: 'cartesian2d', + legendHoverLink: true, + // stack: null + + // Cartesian coordinate system + xAxisIndex: 0, + yAxisIndex: 0, + + // 最小高度改为0 + barMinHeight: 0, + + // barMaxWidth: null, + // 默认自适应 + // barWidth: null, + // 柱间距离,默认为柱形宽度的30%,可设固定值 + // barGap: '30%', + // 类目间柱形距离,默认为类目间距的20%,可设固定值 + // barCategoryGap: '20%', + // label: { + // normal: { + // show: false + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + + // // 默认自适应,水平布局为'top',垂直布局为'right',可选为 + // // 'inside' | 'insideleft' | 'insideTop' | 'insideRight' | 'insideBottom' | + // // 'outside' |'left' | 'right'|'top'|'bottom' + // position: + + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + // } + // }, + itemStyle: { + normal: { + // color: '各异', + // 柱条边线 + barBorderColor: '#fff', + // 柱条边线线宽,单位px,默认为1 + barBorderWidth: 0 + }, + emphasis: { + // color: '各异', + // 柱条边线 + barBorderColor: '#fff', + // 柱条边线线宽,单位px,默认为1 + barBorderWidth: 0 + } + } + } + }); + + +/***/ }, +/* 129 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + + zrUtil.extend(__webpack_require__(8).prototype, __webpack_require__(130)); + + function fixLayoutWithLineWidth(layout, lineWidth) { + var signX = layout.width > 0 ? 1 : -1; + var signY = layout.height > 0 ? 1 : -1; + // In case width or height are too small. + lineWidth = Math.min(lineWidth, Math.abs(layout.width), Math.abs(layout.height)); + layout.x += signX * lineWidth / 2; + layout.y += signY * lineWidth / 2; + layout.width -= signX * lineWidth; + layout.height -= signY * lineWidth; + } + + module.exports = __webpack_require__(1).extendChartView({ + + type: 'bar', + + render: function (seriesModel, ecModel, api) { + var coordinateSystemType = seriesModel.get('coordinateSystem'); + + if (coordinateSystemType === 'cartesian2d') { + this._renderOnCartesian(seriesModel, ecModel, api); + } + + return this.group; + }, + + _renderOnCartesian: function (seriesModel, ecModel, api) { + var group = this.group; + var data = seriesModel.getData(); + var oldData = this._data; + + var cartesian = seriesModel.coordinateSystem; + var baseAxis = cartesian.getBaseAxis(); + var isHorizontal = baseAxis.isHorizontal(); + + var enableAnimation = seriesModel.get('animation'); + + var barBorderWidthQuery = ['itemStyle', 'normal', 'barBorderWidth']; + + function createRect(dataIndex, isUpdate) { + var layout = data.getItemLayout(dataIndex); + var lineWidth = data.getItemModel(dataIndex).get(barBorderWidthQuery) || 0; + fixLayoutWithLineWidth(layout, lineWidth); + + var rect = new graphic.Rect({ + shape: zrUtil.extend({}, layout) + }); + // Animation + if (enableAnimation) { + var rectShape = rect.shape; + var animateProperty = isHorizontal ? 'height' : 'width'; + var animateTarget = {}; + rectShape[animateProperty] = 0; + animateTarget[animateProperty] = layout[animateProperty]; + graphic[isUpdate? 'updateProps' : 'initProps'](rect, { + shape: animateTarget + }, seriesModel); + } + return rect; + } + data.diff(oldData) + .add(function (dataIndex) { + // 空数据 + if (!data.hasValue(dataIndex)) { + return; + } + + var rect = createRect(dataIndex); + + data.setItemGraphicEl(dataIndex, rect); + + group.add(rect); + + }) + .update(function (newIndex, oldIndex) { + var rect = oldData.getItemGraphicEl(oldIndex); + // 空数据 + if (!data.hasValue(newIndex)) { + group.remove(rect); + return; + } + if (!rect) { + rect = createRect(newIndex, true); + } + + var layout = data.getItemLayout(newIndex); + var lineWidth = data.getItemModel(newIndex).get(barBorderWidthQuery) || 0; + fixLayoutWithLineWidth(layout, lineWidth); + + graphic.updateProps(rect, { + shape: layout + }, seriesModel); + + data.setItemGraphicEl(newIndex, rect); + + // Add back + group.add(rect); + }) + .remove(function (idx) { + var rect = oldData.getItemGraphicEl(idx); + if (rect) { + // Not show text when animating + rect.style.text = ''; + graphic.updateProps(rect, { + shape: { + width: 0 + } + }, seriesModel, function () { + group.remove(rect); + }); + } + }) + .execute(); + + this._updateStyle(seriesModel, data, isHorizontal); + + this._data = data; + }, + + _updateStyle: function (seriesModel, data, isHorizontal) { + function setLabel(style, model, color, labelText, labelPositionOutside) { + graphic.setText(style, model, color); + style.text = labelText; + if (style.textPosition === 'outside') { + style.textPosition = labelPositionOutside; + } + } + + data.eachItemGraphicEl(function (rect, idx) { + var itemModel = data.getItemModel(idx); + var color = data.getItemVisual(idx, 'color'); + var layout = data.getItemLayout(idx); + var itemStyleModel = itemModel.getModel('itemStyle.normal'); + + var hoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle(); + + rect.setShape('r', itemStyleModel.get('barBorderRadius') || 0); + + rect.setStyle(zrUtil.defaults( + { + fill: color + }, + itemStyleModel.getBarItemStyle() + )); + + var labelPositionOutside = isHorizontal + ? (layout.height > 0 ? 'bottom' : 'top') + : (layout.width > 0 ? 'left' : 'right'); + + var labelModel = itemModel.getModel('label.normal'); + var hoverLabelModel = itemModel.getModel('label.emphasis'); + var rectStyle = rect.style; + if (labelModel.get('show')) { + setLabel( + rectStyle, labelModel, color, + zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'normal'), + seriesModel.getRawValue(idx) + ), + labelPositionOutside + ); + } + else { + rectStyle.text = ''; + } + if (hoverLabelModel.get('show')) { + setLabel( + hoverStyle, hoverLabelModel, color, + zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'emphasis'), + seriesModel.getRawValue(idx) + ), + labelPositionOutside + ); + } + else { + hoverStyle.text = ''; + } + graphic.setHoverStyle(rect, hoverStyle); + }); + }, + + remove: function (ecModel, api) { + var group = this.group; + if (ecModel.get('animation')) { + if (this._data) { + this._data.eachItemGraphicEl(function (el) { + // Not show text when animating + el.style.text = ''; + graphic.updateProps(el, { + shape: { + width: 0 + } + }, ecModel, function () { + group.remove(el); + }); + }); + } + } + else { + group.removeAll(); + } + } + }); + + +/***/ }, +/* 130 */ +/***/ function(module, exports, __webpack_require__) { + + + module.exports = { + getBarItemStyle: __webpack_require__(11)( + [ + ['fill', 'color'], + ['stroke', 'barBorderColor'], + ['lineWidth', 'barBorderWidth'], + ['opacity'], + ['shadowBlur'], + ['shadowOffsetX'], + ['shadowOffsetY'], + ['shadowColor'] + ] + ) + }; + + +/***/ }, +/* 131 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var parsePercent = numberUtil.parsePercent; + + function getSeriesStackId(seriesModel) { + return seriesModel.get('stack') || '__ec_stack_' + seriesModel.seriesIndex; + } + + function calBarWidthAndOffset(barSeries, api) { + // Columns info on each category axis. Key is cartesian name + var columnsMap = {}; + + zrUtil.each(barSeries, function (seriesModel, idx) { + var cartesian = seriesModel.coordinateSystem; + + var baseAxis = cartesian.getBaseAxis(); + + var columnsOnAxis = columnsMap[baseAxis.index] || { + remainedWidth: baseAxis.getBandWidth(), + autoWidthCount: 0, + categoryGap: '20%', + gap: '30%', + axis: baseAxis, + stacks: {} + }; + var stacks = columnsOnAxis.stacks; + columnsMap[baseAxis.index] = columnsOnAxis; + + var stackId = getSeriesStackId(seriesModel); + + if (!stacks[stackId]) { + columnsOnAxis.autoWidthCount++; + } + stacks[stackId] = stacks[stackId] || { + width: 0, + maxWidth: 0 + }; + + var barWidth = seriesModel.get('barWidth'); + var barMaxWidth = seriesModel.get('barMaxWidth'); + var barGap = seriesModel.get('barGap'); + var barCategoryGap = seriesModel.get('barCategoryGap'); + // TODO + if (barWidth && ! stacks[stackId].width) { + barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth); + stacks[stackId].width = barWidth; + columnsOnAxis.remainedWidth -= barWidth; + } + + barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth); + (barGap != null) && (columnsOnAxis.gap = barGap); + (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap); + }); + + var result = {}; + + zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) { + + result[coordSysName] = {}; + + var stacks = columnsOnAxis.stacks; + var baseAxis = columnsOnAxis.axis; + var bandWidth = baseAxis.getBandWidth(); + var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth); + var barGapPercent = parsePercent(columnsOnAxis.gap, 1); + + var remainedWidth = columnsOnAxis.remainedWidth; + var autoWidthCount = columnsOnAxis.autoWidthCount; + var autoWidth = (remainedWidth - categoryGap) + / (autoWidthCount + (autoWidthCount - 1) * barGapPercent); + autoWidth = Math.max(autoWidth, 0); + + // Find if any auto calculated bar exceeded maxBarWidth + zrUtil.each(stacks, function (column, stack) { + var maxWidth = column.maxWidth; + if (!column.width && maxWidth && maxWidth < autoWidth) { + maxWidth = Math.min(maxWidth, remainedWidth); + remainedWidth -= maxWidth; + column.width = maxWidth; + autoWidthCount--; + } + }); + + // Recalculate width again + autoWidth = (remainedWidth - categoryGap) + / (autoWidthCount + (autoWidthCount - 1) * barGapPercent); + autoWidth = Math.max(autoWidth, 0); + + var widthSum = 0; + var lastColumn; + zrUtil.each(stacks, function (column, idx) { + if (!column.width) { + column.width = autoWidth; + } + lastColumn = column; + widthSum += column.width * (1 + barGapPercent); + }); + if (lastColumn) { + widthSum -= lastColumn.width * barGapPercent; + } + + var offset = -widthSum / 2; + zrUtil.each(stacks, function (column, stackId) { + result[coordSysName][stackId] = result[coordSysName][stackId] || { + offset: offset, + width: column.width + }; + + offset += column.width * (1 + barGapPercent); + }); + }); + + return result; + } + + /** + * @param {string} seriesType + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + */ + function barLayoutGrid(seriesType, ecModel, api) { + + var barWidthAndOffset = calBarWidthAndOffset( + zrUtil.filter( + ecModel.getSeriesByType(seriesType), + function (seriesModel) { + return !ecModel.isSeriesFiltered(seriesModel) + && seriesModel.coordinateSystem + && seriesModel.coordinateSystem.type === 'cartesian2d'; + } + ) + ); + + var lastStackCoords = {}; + + ecModel.eachSeriesByType(seriesType, function (seriesModel) { + + var data = seriesModel.getData(); + var cartesian = seriesModel.coordinateSystem; + var baseAxis = cartesian.getBaseAxis(); + + var stackId = getSeriesStackId(seriesModel); + var columnLayoutInfo = barWidthAndOffset[baseAxis.index][stackId]; + var columnOffset = columnLayoutInfo.offset; + var columnWidth = columnLayoutInfo.width; + var valueAxis = cartesian.getOtherAxis(baseAxis); + + var barMinHeight = seriesModel.get('barMinHeight') || 0; + + var valueAxisStart = baseAxis.onZero + ? valueAxis.toGlobalCoord(valueAxis.dataToCoord(0)) + : valueAxis.getGlobalExtent()[0]; + + var coords = cartesian.dataToPoints(data, true); + lastStackCoords[stackId] = lastStackCoords[stackId] || []; + + data.setLayout({ + offset: columnOffset, + size: columnWidth + }); + data.each(valueAxis.dim, function (value, idx) { + // 空数据 + if (isNaN(value)) { + return; + } + if (!lastStackCoords[stackId][idx]) { + lastStackCoords[stackId][idx] = { + // Positive stack + p: valueAxisStart, + // Negative stack + n: valueAxisStart + }; + } + var sign = value >= 0 ? 'p' : 'n'; + var coord = coords[idx]; + var lastCoord = lastStackCoords[stackId][idx][sign]; + var x, y, width, height; + if (valueAxis.isHorizontal()) { + x = lastCoord; + y = coord[1] + columnOffset; + width = coord[0] - lastCoord; + height = columnWidth; + + if (Math.abs(width) < barMinHeight) { + width = (width < 0 ? -1 : 1) * barMinHeight; + } + lastStackCoords[stackId][idx][sign] += width; + } + else { + x = coord[0] + columnOffset; + y = lastCoord; + width = columnWidth; + height = coord[1] - lastCoord; + if (Math.abs(height) < barMinHeight) { + // Include zero to has a positive bar + height = (height <= 0 ? -1 : 1) * barMinHeight; + } + lastStackCoords[stackId][idx][sign] += height; + } + + data.setItemLayout(idx, { + x: x, + y: y, + width: width, + height: height + }); + }, true); + + }, this); + } + + module.exports = barLayoutGrid; + + +/***/ }, +/* 132 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var echarts = __webpack_require__(1); + + __webpack_require__(133); + __webpack_require__(135); + + __webpack_require__(136)('pie', [{ + type: 'pieToggleSelect', + event: 'pieselectchanged', + method: 'toggleSelected' + }, { + type: 'pieSelect', + event: 'pieselected', + method: 'select' + }, { + type: 'pieUnSelect', + event: 'pieunselected', + method: 'unSelect' + }]); + + echarts.registerVisualCoding( + 'chart', zrUtil.curry(__webpack_require__(137), 'pie') + ); + + echarts.registerLayout(zrUtil.curry( + __webpack_require__(138), 'pie' + )); + + echarts.registerProcessor( + 'filter', zrUtil.curry(__webpack_require__(140), 'pie') + ); + + +/***/ }, +/* 133 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var List = __webpack_require__(94); + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var completeDimensions = __webpack_require__(96); + + var dataSelectableMixin = __webpack_require__(134); + + var PieSeries = __webpack_require__(1).extendSeriesModel({ + + type: 'series.pie', + + // Overwrite + init: function (option) { + PieSeries.superApply(this, 'init', arguments); + + // Enable legend selection for each data item + // Use a function instead of direct access because data reference may changed + this.legendDataProvider = function () { + return this._dataBeforeProcessed; + }; + + this.updateSelectedMap(); + + this._defaultLabelLine(option); + }, + + // Overwrite + mergeOption: function (newOption) { + PieSeries.superCall(this, 'mergeOption', newOption); + this.updateSelectedMap(); + }, + + getInitialData: function (option, ecModel) { + var dimensions = completeDimensions(['value'], option.data); + var list = new List(dimensions, this); + list.initData(option.data); + return list; + }, + + // Overwrite + getDataParams: function (dataIndex) { + var data = this._data; + var params = PieSeries.superCall(this, 'getDataParams', dataIndex); + var sum = data.getSum('value'); + // FIXME toFixed? + // + // Percent is 0 if sum is 0 + params.percent = !sum ? 0 : +(data.get('value', dataIndex) / sum * 100).toFixed(2); + + params.$vars.push('percent'); + return params; + }, + + _defaultLabelLine: function (option) { + // Extend labelLine emphasis + modelUtil.defaultEmphasis(option.labelLine, ['show']); + + var labelLineNormalOpt = option.labelLine.normal; + var labelLineEmphasisOpt = option.labelLine.emphasis; + // Not show label line if `label.normal.show = false` + labelLineNormalOpt.show = labelLineNormalOpt.show + && option.label.normal.show; + labelLineEmphasisOpt.show = labelLineEmphasisOpt.show + && option.label.emphasis.show; + }, + + defaultOption: { + zlevel: 0, + z: 2, + legendHoverLink: true, + + hoverAnimation: true, + // 默认全局居中 + center: ['50%', '50%'], + radius: [0, '75%'], + // 默认顺时针 + clockwise: true, + startAngle: 90, + // 最小角度改为0 + minAngle: 0, + // 选中是扇区偏移量 + selectedOffset: 10, + + // If use strategy to avoid label overlapping + avoidLabelOverlap: true, + // 选择模式,默认关闭,可选single,multiple + // selectedMode: false, + // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积) + // roseType: null, + + label: { + normal: { + // If rotate around circle + rotate: false, + show: true, + // 'outer', 'inside', 'center' + position: 'outer' + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数 + }, + emphasis: {} + }, + // Enabled when label.normal.position is 'outer' + labelLine: { + normal: { + show: true, + // 引导线两段中的第一段长度 + length: 20, + // 引导线两段中的第二段长度 + length2: 5, + smooth: false, + lineStyle: { + // color: 各异, + width: 1, + type: 'solid' + } + } + }, + itemStyle: { + normal: { + // color: 各异, + borderColor: 'rgba(0,0,0,0)', + borderWidth: 1 + }, + emphasis: { + // color: 各异, + borderColor: 'rgba(0,0,0,0)', + borderWidth: 1 + } + }, + + animationEasing: 'cubicOut', + + data: [] + } + }); + + zrUtil.mixin(PieSeries, dataSelectableMixin); + + module.exports = PieSeries; + + +/***/ }, +/* 134 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Data selectable mixin for chart series. + * To eanble data select, option of series must have `selectedMode`. + * And each data item will use `selected` to toggle itself selected status + * + * @module echarts/chart/helper/DataSelectable + */ + + + var zrUtil = __webpack_require__(3); + + module.exports = { + + updateSelectedMap: function () { + var option = this.option; + this._dataOptMap = zrUtil.reduce(option.data, function (dataOptMap, dataOpt) { + dataOptMap[dataOpt.name] = dataOpt; + return dataOptMap; + }, {}); + }, + /** + * @param {string} name + */ + // PENGING If selectedMode is null ? + select: function (name) { + var dataOptMap = this._dataOptMap; + var dataOpt = dataOptMap[name]; + var selectedMode = this.get('selectedMode'); + if (selectedMode === 'single') { + zrUtil.each(dataOptMap, function (dataOpt) { + dataOpt.selected = false; + }); + } + dataOpt && (dataOpt.selected = true); + }, + + /** + * @param {string} name + */ + unSelect: function (name) { + var dataOpt = this._dataOptMap[name]; + // var selectedMode = this.get('selectedMode'); + // selectedMode !== 'single' && dataOpt && (dataOpt.selected = false); + dataOpt && (dataOpt.selected = false); + }, + + /** + * @param {string} name + */ + toggleSelected: function (name) { + var dataOpt = this._dataOptMap[name]; + if (dataOpt != null) { + this[dataOpt.selected ? 'unSelect' : 'select'](name); + return dataOpt.selected; + } + }, + + /** + * @param {string} name + */ + isSelected: function (name) { + var dataOpt = this._dataOptMap[name]; + return dataOpt && dataOpt.selected; + } + }; + + +/***/ }, +/* 135 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + + /** + * @param {module:echarts/model/Series} seriesModel + * @param {boolean} hasAnimation + * @inner + */ + function updateDataSelected(uid, seriesModel, hasAnimation, api) { + var data = seriesModel.getData(); + var dataIndex = this.dataIndex; + var name = data.getName(dataIndex); + var selectedOffset = seriesModel.get('selectedOffset'); + + api.dispatchAction({ + type: 'pieToggleSelect', + from: uid, + name: name, + seriesId: seriesModel.id + }); + + data.each(function (idx) { + toggleItemSelected( + data.getItemGraphicEl(idx), + data.getItemLayout(idx), + seriesModel.isSelected(data.getName(idx)), + selectedOffset, + hasAnimation + ); + }); + } + + /** + * @param {module:zrender/graphic/Sector} el + * @param {Object} layout + * @param {boolean} isSelected + * @param {number} selectedOffset + * @param {boolean} hasAnimation + * @inner + */ + function toggleItemSelected(el, layout, isSelected, selectedOffset, hasAnimation) { + var midAngle = (layout.startAngle + layout.endAngle) / 2; + + var dx = Math.cos(midAngle); + var dy = Math.sin(midAngle); + + var offset = isSelected ? selectedOffset : 0; + var position = [dx * offset, dy * offset]; + + hasAnimation + // animateTo will stop revious animation like update transition + ? el.animate() + .when(200, { + position: position + }) + .start('bounceOut') + : el.attr('position', position); + } + + /** + * Piece of pie including Sector, Label, LabelLine + * @constructor + * @extends {module:zrender/graphic/Group} + */ + function PiePiece(data, idx) { + + graphic.Group.call(this); + + var sector = new graphic.Sector({ + z2: 2 + }); + var polyline = new graphic.Polyline(); + var text = new graphic.Text(); + this.add(sector); + this.add(polyline); + this.add(text); + + this.updateData(data, idx, true); + + // Hover to change label and labelLine + function onEmphasis() { + polyline.ignore = polyline.hoverIgnore; + text.ignore = text.hoverIgnore; + } + function onNormal() { + polyline.ignore = polyline.normalIgnore; + text.ignore = text.normalIgnore; + } + this.on('emphasis', onEmphasis) + .on('normal', onNormal) + .on('mouseover', onEmphasis) + .on('mouseout', onNormal); + } + + var piePieceProto = PiePiece.prototype; + + function getLabelStyle(data, idx, state, labelModel, labelPosition) { + var textStyleModel = labelModel.getModel('textStyle'); + var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner'; + return { + fill: textStyleModel.getTextColor() + || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')), + textFont: textStyleModel.getFont(), + text: zrUtil.retrieve( + data.hostModel.getFormattedLabel(idx, state), data.getName(idx) + ) + }; + } + + piePieceProto.updateData = function (data, idx, firstCreate) { + + var sector = this.childAt(0); + + var seriesModel = data.hostModel; + var itemModel = data.getItemModel(idx); + var layout = data.getItemLayout(idx); + var sectorShape = zrUtil.extend({}, layout); + sectorShape.label = null; + if (firstCreate) { + sector.setShape(sectorShape); + sector.shape.endAngle = layout.startAngle; + graphic.updateProps(sector, { + shape: { + endAngle: layout.endAngle + } + }, seriesModel); + } + else { + graphic.updateProps(sector, { + shape: sectorShape + }, seriesModel); + } + + // Update common style + var itemStyleModel = itemModel.getModel('itemStyle'); + var visualColor = data.getItemVisual(idx, 'color'); + + sector.setStyle( + zrUtil.defaults( + { + fill: visualColor + }, + itemStyleModel.getModel('normal').getItemStyle() + ) + ); + sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle(); + + // Toggle selected + toggleItemSelected( + this, + data.getItemLayout(idx), + itemModel.get('selected'), + seriesModel.get('selectedOffset'), + seriesModel.get('animation') + ); + + function onEmphasis() { + // Sector may has animation of updating data. Force to move to the last frame + // Or it may stopped on the wrong shape + sector.stopAnimation(true); + sector.animateTo({ + shape: { + r: layout.r + 10 + } + }, 300, 'elasticOut'); + } + function onNormal() { + sector.stopAnimation(true); + sector.animateTo({ + shape: { + r: layout.r + } + }, 300, 'elasticOut'); + } + sector.off('mouseover').off('mouseout').off('emphasis').off('normal'); + if (itemModel.get('hoverAnimation')) { + sector + .on('mouseover', onEmphasis) + .on('mouseout', onNormal) + .on('emphasis', onEmphasis) + .on('normal', onNormal); + } + + this._updateLabel(data, idx); + + graphic.setHoverStyle(this); + }; + + piePieceProto._updateLabel = function (data, idx) { + + var labelLine = this.childAt(1); + var labelText = this.childAt(2); + + var seriesModel = data.hostModel; + var itemModel = data.getItemModel(idx); + var layout = data.getItemLayout(idx); + var labelLayout = layout.label; + var visualColor = data.getItemVisual(idx, 'color'); + + graphic.updateProps(labelLine, { + shape: { + points: labelLayout.linePoints || [ + [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y] + ] + } + }, seriesModel); + + graphic.updateProps(labelText, { + style: { + x: labelLayout.x, + y: labelLayout.y + } + }, seriesModel); + labelText.attr({ + style: { + textVerticalAlign: labelLayout.verticalAlign, + textAlign: labelLayout.textAlign, + textFont: labelLayout.font + }, + rotation: labelLayout.rotation, + origin: [labelLayout.x, labelLayout.y], + z2: 10 + }); + + var labelModel = itemModel.getModel('label.normal'); + var labelHoverModel = itemModel.getModel('label.emphasis'); + var labelLineModel = itemModel.getModel('labelLine.normal'); + var labelLineHoverModel = itemModel.getModel('labelLine.emphasis'); + var labelPosition = labelModel.get('position') || labelHoverModel.get('position'); + + labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel, labelPosition)); + + labelText.ignore = labelText.normalIgnore = !labelModel.get('show'); + labelText.hoverIgnore = !labelHoverModel.get('show'); + + labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show'); + labelLine.hoverIgnore = !labelLineHoverModel.get('show'); + + // Default use item visual color + labelLine.setStyle({ + stroke: visualColor + }); + labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle()); + + labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel, labelPosition); + labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle(); + + var smooth = labelLineModel.get('smooth'); + if (smooth && smooth === true) { + smooth = 0.4; + } + labelLine.setShape({ + smooth: smooth + }); + }; + + zrUtil.inherits(PiePiece, graphic.Group); + + + // Pie view + var Pie = __webpack_require__(41).extend({ + + type: 'pie', + + init: function () { + var sectorGroup = new graphic.Group(); + this._sectorGroup = sectorGroup; + }, + + render: function (seriesModel, ecModel, api, payload) { + if (payload && (payload.from === this.uid)) { + return; + } + + var data = seriesModel.getData(); + var oldData = this._data; + var group = this.group; + + var hasAnimation = ecModel.get('animation'); + var isFirstRender = !oldData; + + var onSectorClick = zrUtil.curry( + updateDataSelected, this.uid, seriesModel, hasAnimation, api + ); + + var selectedMode = seriesModel.get('selectedMode'); + + data.diff(oldData) + .add(function (idx) { + var piePiece = new PiePiece(data, idx); + if (isFirstRender) { + piePiece.eachChild(function (child) { + child.stopAnimation(true); + }); + } + + selectedMode && piePiece.on('click', onSectorClick); + + data.setItemGraphicEl(idx, piePiece); + + group.add(piePiece); + }) + .update(function (newIdx, oldIdx) { + var piePiece = oldData.getItemGraphicEl(oldIdx); + + piePiece.updateData(data, newIdx); + + piePiece.off('click'); + selectedMode && piePiece.on('click', onSectorClick); + group.add(piePiece); + data.setItemGraphicEl(newIdx, piePiece); + }) + .remove(function (idx) { + var piePiece = oldData.getItemGraphicEl(idx); + group.remove(piePiece); + }) + .execute(); + + if (hasAnimation && isFirstRender && data.count() > 0) { + var shape = data.getItemLayout(0); + var r = Math.max(api.getWidth(), api.getHeight()) / 2; + + var removeClipPath = zrUtil.bind(group.removeClipPath, group); + group.setClipPath(this._createClipPath( + shape.cx, shape.cy, r, shape.startAngle, shape.clockwise, removeClipPath, seriesModel + )); + } + + this._data = data; + }, + + _createClipPath: function ( + cx, cy, r, startAngle, clockwise, cb, seriesModel + ) { + var clipPath = new graphic.Sector({ + shape: { + cx: cx, + cy: cy, + r0: 0, + r: r, + startAngle: startAngle, + endAngle: startAngle, + clockwise: clockwise + } + }); + + graphic.initProps(clipPath, { + shape: { + endAngle: startAngle + (clockwise ? 1 : -1) * Math.PI * 2 + } + }, seriesModel, cb); + + return clipPath; + } + }); + + module.exports = Pie; + + +/***/ }, +/* 136 */ +/***/ function(module, exports, __webpack_require__) { + + + var echarts = __webpack_require__(1); + var zrUtil = __webpack_require__(3); + module.exports = function (seriesType, actionInfos) { + zrUtil.each(actionInfos, function (actionInfo) { + actionInfo.update = 'updateView'; + /** + * @payload + * @property {string} seriesName + * @property {string} name + */ + echarts.registerAction(actionInfo, function (payload, ecModel) { + var selected = {}; + ecModel.eachComponent( + {mainType: 'series', subType: seriesType, query: payload}, + function (seriesModel) { + if (seriesModel[actionInfo.method]) { + seriesModel[actionInfo.method](payload.name); + } + var data = seriesModel.getData(); + // Create selected map + data.each(function (idx) { + var name = data.getName(idx); + selected[name] = seriesModel.isSelected(name) || false; + }); + } + ); + return { + name: payload.name, + selected: selected + }; + }); + }); + }; + + +/***/ }, +/* 137 */ +/***/ function(module, exports) { + + // Pick color from palette for each data item + + + module.exports = function (seriesType, ecModel) { + var globalColorList = ecModel.get('color'); + var offset = 0; + ecModel.eachRawSeriesByType(seriesType, function (seriesModel) { + var colorList = seriesModel.get('color', true); + var dataAll = seriesModel.getRawData(); + if (!ecModel.isSeriesFiltered(seriesModel)) { + var data = seriesModel.getData(); + data.each(function (idx) { + var itemModel = data.getItemModel(idx); + var rawIdx = data.getRawIndex(idx); + // If series.itemStyle.normal.color is a function. itemVisual may be encoded + var singleDataColor = data.getItemVisual(idx, 'color', true); + if (!singleDataColor) { + var paletteColor = colorList ? colorList[rawIdx % colorList.length] + : globalColorList[(rawIdx + offset) % globalColorList.length]; + var color = itemModel.get('itemStyle.normal.color') || paletteColor; + // Legend may use the visual info in data before processed + dataAll.setItemVisual(rawIdx, 'color', color); + data.setItemVisual(idx, 'color', color); + } + else { + // Set data all color for legend + dataAll.setItemVisual(rawIdx, 'color', singleDataColor); + } + }); + } + offset += dataAll.count(); + }); + }; + + +/***/ }, +/* 138 */ +/***/ function(module, exports, __webpack_require__) { + + // TODO minAngle + + + + var numberUtil = __webpack_require__(7); + var parsePercent = numberUtil.parsePercent; + var labelLayout = __webpack_require__(139); + var zrUtil = __webpack_require__(3); + + var PI2 = Math.PI * 2; + var RADIAN = Math.PI / 180; + + module.exports = function (seriesType, ecModel, api) { + ecModel.eachSeriesByType(seriesType, function (seriesModel) { + var center = seriesModel.get('center'); + var radius = seriesModel.get('radius'); + + if (!zrUtil.isArray(radius)) { + radius = [0, radius]; + } + if (!zrUtil.isArray(center)) { + center = [center, center]; + } + + var width = api.getWidth(); + var height = api.getHeight(); + var size = Math.min(width, height); + var cx = parsePercent(center[0], width); + var cy = parsePercent(center[1], height); + var r0 = parsePercent(radius[0], size / 2); + var r = parsePercent(radius[1], size / 2); + + var data = seriesModel.getData(); + + var startAngle = -seriesModel.get('startAngle') * RADIAN; + + var minAngle = seriesModel.get('minAngle') * RADIAN; + + var sum = data.getSum('value'); + // Sum may be 0 + var unitRadian = Math.PI / (sum || data.count()) * 2; + + var clockwise = seriesModel.get('clockwise'); + + var roseType = seriesModel.get('roseType'); + + // [0...max] + var extent = data.getDataExtent('value'); + extent[0] = 0; + + // In the case some sector angle is smaller than minAngle + var restAngle = PI2; + var valueSumLargerThanMinAngle = 0; + + var currentAngle = startAngle; + + var dir = clockwise ? 1 : -1; + data.each('value', function (value, idx) { + var angle; + // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样? + if (roseType !== 'area') { + angle = sum === 0 ? unitRadian : (value * unitRadian); + } + else { + angle = PI2 / (data.count() || 1); + } + + if (angle < minAngle) { + angle = minAngle; + restAngle -= minAngle; + } + else { + valueSumLargerThanMinAngle += value; + } + + var endAngle = currentAngle + dir * angle; + data.setItemLayout(idx, { + angle: angle, + startAngle: currentAngle, + endAngle: endAngle, + clockwise: clockwise, + cx: cx, + cy: cy, + r0: r0, + r: roseType + ? numberUtil.linearMap(value, extent, [r0, r]) + : r + }); + + currentAngle = endAngle; + }, true); + + // Some sector is constrained by minAngle + // Rest sectors needs recalculate angle + if (restAngle < PI2) { + // Average the angle if rest angle is not enough after all angles is + // Constrained by minAngle + if (restAngle <= 1e-3) { + var angle = PI2 / data.count(); + data.each(function (idx) { + var layout = data.getItemLayout(idx); + layout.startAngle = startAngle + dir * idx * angle; + layout.endAngle = startAngle + dir * (idx + 1) * angle; + }); + } + else { + unitRadian = restAngle / valueSumLargerThanMinAngle; + currentAngle = startAngle; + data.each('value', function (value, idx) { + var layout = data.getItemLayout(idx); + var angle = layout.angle === minAngle + ? minAngle : value * unitRadian; + layout.startAngle = currentAngle; + layout.endAngle = currentAngle + dir * angle; + currentAngle += angle; + }); + } + } + + labelLayout(seriesModel, r, width, height); + }); + }; + + +/***/ }, +/* 139 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // FIXME emphasis label position is not same with normal label position + + + var textContain = __webpack_require__(14); + + function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) { + list.sort(function (a, b) { + return a.y - b.y; + }); + + // 压 + function shiftDown(start, end, delta, dir) { + for (var j = start; j < end; j++) { + list[j].y += delta; + if (j > start + && j + 1 < end + && list[j + 1].y > list[j].y + list[j].height + ) { + shiftUp(j, delta / 2); + return; + } + } + + shiftUp(end - 1, delta / 2); + } + + // 弹 + function shiftUp(end, delta) { + for (var j = end; j >= 0; j--) { + list[j].y -= delta; + if (j > 0 + && list[j].y > list[j - 1].y + list[j - 1].height + ) { + break; + } + } + } + + // function changeX(list, isDownList, cx, cy, r, dir) { + // var deltaX; + // var deltaY; + // var length; + // var lastDeltaX = dir > 0 + // ? isDownList // 右侧 + // ? Number.MAX_VALUE // 下 + // : 0 // 上 + // : isDownList // 左侧 + // ? Number.MAX_VALUE // 下 + // : 0; // 上 + + // for (var i = 0, l = list.length; i < l; i++) { + // deltaY = Math.abs(list[i].y - cy); + // length = list[i].length; + // deltaX = (deltaY < r + length) + // ? Math.sqrt( + // (r + length + 20) * (r + length + 20) + // - Math.pow(list[i].y - cy, 2) + // ) + // : Math.abs( + // list[i].x - cx + // ); + // if (isDownList && deltaX >= lastDeltaX) { + // // 右下,左下 + // deltaX = lastDeltaX - 10; + // } + // if (!isDownList && deltaX <= lastDeltaX) { + // // 右上,左上 + // deltaX = lastDeltaX + 10; + // } + + // list[i].x = cx + deltaX * dir; + // lastDeltaX = deltaX; + // } + // } + + var lastY = 0; + var delta; + var len = list.length; + var upList = []; + var downList = []; + for (var i = 0; i < len; i++) { + delta = list[i].y - lastY; + if (delta < 0) { + shiftDown(i, len, -delta, dir); + } + lastY = list[i].y + list[i].height; + } + if (viewHeight - lastY < 0) { + shiftUp(len - 1, lastY - viewHeight); + } + for (var i = 0; i < len; i++) { + if (list[i].y >= cy) { + downList.push(list[i]); + } + else { + upList.push(list[i]); + } + } + // changeX(downList, true, cx, cy, r, dir); + // changeX(upList, false, cx, cy, r, dir); + } + + function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) { + var leftList = []; + var rightList = []; + for (var i = 0; i < labelLayoutList.length; i++) { + if (labelLayoutList[i].x < cx) { + leftList.push(labelLayoutList[i]); + } + else { + rightList.push(labelLayoutList[i]); + } + } + + adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight); + adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight); + + for (var i = 0; i < labelLayoutList.length; i++) { + var linePoints = labelLayoutList[i].linePoints; + if (linePoints) { + if (labelLayoutList[i].x < cx) { + linePoints[2][0] = labelLayoutList[i].x + 3; + } + else { + linePoints[2][0] = labelLayoutList[i].x - 3; + } + linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y; + } + } + } + + module.exports = function (seriesModel, r, viewWidth, viewHeight) { + var data = seriesModel.getData(); + var labelLayoutList = []; + var cx; + var cy; + var hasLabelRotate = false; + + data.each(function (idx) { + var layout = data.getItemLayout(idx); + + var itemModel = data.getItemModel(idx); + var labelModel = itemModel.getModel('label.normal'); + // Use position in normal or emphasis + var labelPosition = labelModel.get('position') || itemModel.get('label.emphasis.position'); + + var labelLineModel = itemModel.getModel('labelLine.normal'); + var labelLineLen = labelLineModel.get('length'); + var labelLineLen2 = labelLineModel.get('length2'); + + var midAngle = (layout.startAngle + layout.endAngle) / 2; + var dx = Math.cos(midAngle); + var dy = Math.sin(midAngle); + + var textX; + var textY; + var linePoints; + var textAlign; + + cx = layout.cx; + cy = layout.cy; + + if (labelPosition === 'center') { + textX = layout.cx; + textY = layout.cy; + textAlign = 'center'; + } + else { + var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner'; + var x1 = (isLabelInside ? layout.r / 2 * dx : layout.r * dx) + cx; + var y1 = (isLabelInside ? layout.r / 2 * dy : layout.r * dy) + cy; + + // For roseType + labelLineLen += r - layout.r; + + textX = x1 + dx * 3; + textY = y1 + dy * 3; + + if (!isLabelInside) { + var x2 = x1 + dx * labelLineLen; + var y2 = y1 + dy * labelLineLen; + var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2); + var y3 = y2; + + textX = x3 + (dx < 0 ? -5 : 5); + textY = y3; + linePoints = [[x1, y1], [x2, y2], [x3, y3]]; + } + + textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right'); + } + var font = labelModel.getModel('textStyle').getFont(); + + var labelRotate = labelModel.get('rotate') + ? (dx < 0 ? -midAngle + Math.PI : -midAngle) : 0; + var text = seriesModel.getFormattedLabel(idx, 'normal') + || data.getName(idx); + var textRect = textContain.getBoundingRect( + text, font, textAlign, 'top' + ); + hasLabelRotate = !!labelRotate; + layout.label = { + x: textX, + y: textY, + height: textRect.height, + length: labelLineLen, + length2: labelLineLen2, + linePoints: linePoints, + textAlign: textAlign, + verticalAlign: 'middle', + font: font, + rotation: labelRotate + }; + + labelLayoutList.push(layout.label); + }); + if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) { + avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight); + } + }; + + +/***/ }, +/* 140 */ +/***/ function(module, exports) { + + + module.exports = function (seriesType, ecModel) { + var legendModels = ecModel.findComponents({ + mainType: 'legend' + }); + if (!legendModels || !legendModels.length) { + return; + } + ecModel.eachSeriesByType(seriesType, function (series) { + var data = series.getData(); + data.filterSelf(function (idx) { + var name = data.getName(idx); + // If in any legend component the status is not selected. + for (var i = 0; i < legendModels.length; i++) { + if (!legendModels[i].isSelected(name)) { + return false; + } + } + return true; + }, this); + }, this); + }; + + +/***/ }, +/* 141 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var echarts = __webpack_require__(1); + + __webpack_require__(142); + __webpack_require__(143); + + echarts.registerVisualCoding('chart', zrUtil.curry( + __webpack_require__(103), 'scatter', 'circle', null + )); + echarts.registerLayout(zrUtil.curry( + __webpack_require__(104), 'scatter' + )); + + // In case developer forget to include grid component + __webpack_require__(106); + + +/***/ }, +/* 142 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var createListFromArray = __webpack_require__(93); + var SeriesModel = __webpack_require__(27); + + module.exports = SeriesModel.extend({ + + type: 'series.scatter', + + dependencies: ['grid', 'polar'], + + getInitialData: function (option, ecModel) { + var list = createListFromArray(option.data, this, ecModel); + return list; + }, + + defaultOption: { + coordinateSystem: 'cartesian2d', + zlevel: 0, + z: 2, + legendHoverLink: true, + + hoverAnimation: true, + // Cartesian coordinate system + xAxisIndex: 0, + yAxisIndex: 0, + + // Polar coordinate system + polarIndex: 0, + + // Geo coordinate system + geoIndex: 0, + + // symbol: null, // 图形类型 + symbolSize: 10, // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2 + // symbolRotate: null, // 图形旋转控制 + + large: false, + // Available when large is true + largeThreshold: 2000, + + // label: { + // normal: { + // show: false + // distance: 5, + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 + // 'inside'|'left'|'right'|'top'|'bottom' + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + // } + // }, + itemStyle: { + normal: { + opacity: 0.8 + // color: 各异 + } + } + } + }); + + +/***/ }, +/* 143 */ +/***/ function(module, exports, __webpack_require__) { + + + + var SymbolDraw = __webpack_require__(98); + var LargeSymbolDraw = __webpack_require__(144); + + __webpack_require__(1).extendChartView({ + + type: 'scatter', + + init: function () { + this._normalSymbolDraw = new SymbolDraw(); + this._largeSymbolDraw = new LargeSymbolDraw(); + }, + + render: function (seriesModel, ecModel, api) { + var data = seriesModel.getData(); + var largeSymbolDraw = this._largeSymbolDraw; + var normalSymbolDraw = this._normalSymbolDraw; + var group = this.group; + + var symbolDraw = seriesModel.get('large') && data.count() > seriesModel.get('largeThreshold') + ? largeSymbolDraw : normalSymbolDraw; + + this._symbolDraw = symbolDraw; + symbolDraw.updateData(data); + group.add(symbolDraw.group); + + group.remove( + symbolDraw === largeSymbolDraw + ? normalSymbolDraw.group : largeSymbolDraw.group + ); + }, + + updateLayout: function (seriesModel) { + this._symbolDraw.updateLayout(seriesModel); + }, + + remove: function (ecModel, api) { + this._symbolDraw && this._symbolDraw.remove(api, true); + } + }); + + +/***/ }, +/* 144 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var symbolUtil = __webpack_require__(100); + var zrUtil = __webpack_require__(3); + + var LargeSymbolPath = graphic.extendShape({ + shape: { + points: null, + sizes: null + }, + + symbolProxy: null, + + buildPath: function (path, shape) { + var points = shape.points; + var sizes = shape.sizes; + + var symbolProxy = this.symbolProxy; + var symbolProxyShape = symbolProxy.shape; + for (var i = 0; i < points.length; i++) { + var pt = points[i]; + var size = sizes[i]; + if (size[0] < 4) { + // Optimize for small symbol + path.rect( + pt[0] - size[0] / 2, pt[1] - size[1] / 2, + size[0], size[1] + ); + } + else { + symbolProxyShape.x = pt[0] - size[0] / 2; + symbolProxyShape.y = pt[1] - size[1] / 2; + symbolProxyShape.width = size[0]; + symbolProxyShape.height = size[1]; + + symbolProxy.buildPath(path, symbolProxyShape); + } + } + } + }); + + function LargeSymbolDraw() { + this.group = new graphic.Group(); + + this._symbolEl = new LargeSymbolPath({ + silent: true + }); + } + + var largeSymbolProto = LargeSymbolDraw.prototype; - constructor: RadialGradient, + /** + * Update symbols draw by new data + * @param {module:echarts/data/List} data + */ + largeSymbolProto.updateData = function (data) { + this.group.removeAll(); - type: 'radial', + var symbolEl = this._symbolEl; + + var seriesModel = data.hostModel; + + symbolEl.setShape({ + points: data.mapArray(data.getItemLayout), + sizes: data.mapArray( + function (idx) { + var size = data.getItemVisual(idx, 'symbolSize'); + if (!zrUtil.isArray(size)) { + size = [size, size]; + } + return size; + } + ) + }); + + // Create symbolProxy to build path for each data + symbolEl.symbolProxy = symbolUtil.createSymbol( + data.getVisual('symbol'), 0, 0, 0, 0 + ); + // Use symbolProxy setColor method + symbolEl.setColor = symbolEl.symbolProxy.setColor; + + symbolEl.setStyle( + seriesModel.getModel('itemStyle.normal').getItemStyle(['color']) + ); + + var visualColor = data.getVisual('color'); + if (visualColor) { + symbolEl.setColor(visualColor); + } + + // Add back + this.group.add(this._symbolEl); + }; + + largeSymbolProto.updateLayout = function (seriesModel) { + var data = seriesModel.getData(); + this._symbolEl.setShape({ + points: data.mapArray(data.getItemLayout) + }); + }; + + largeSymbolProto.remove = function () { + this.group.removeAll(); + }; + + module.exports = LargeSymbolDraw; + + +/***/ }, +/* 145 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var echarts = __webpack_require__(1); + + // Must use radar component + __webpack_require__(146); + + __webpack_require__(151); + __webpack_require__(152); + + echarts.registerVisualCoding( + 'chart', zrUtil.curry(__webpack_require__(137), 'radar') + ); + echarts.registerVisualCoding('chart', zrUtil.curry( + __webpack_require__(103), 'radar', 'circle', null + )); + echarts.registerLayout(__webpack_require__(153)); + + echarts.registerProcessor( + 'filter', zrUtil.curry(__webpack_require__(140), 'radar') + ); + + echarts.registerPreprocessor(__webpack_require__(154)); + + +/***/ }, +/* 146 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(147); + __webpack_require__(149); + + __webpack_require__(150); + + +/***/ }, +/* 147 */ +/***/ function(module, exports, __webpack_require__) { + + // TODO clockwise + + + var zrUtil = __webpack_require__(3); + var IndicatorAxis = __webpack_require__(148); + var IntervalScale = __webpack_require__(111); + var numberUtil = __webpack_require__(7); + var axisHelper = __webpack_require__(108); + + function Radar(radarModel, ecModel, api) { + + this._model = radarModel; + /** + * Radar dimensions + * @type {Array.} + */ + this.dimensions = []; + + this._indicatorAxes = zrUtil.map(radarModel.getIndicatorModels(), function (indicatorModel, idx) { + var dim = 'indicator_' + idx; + var indicatorAxis = new IndicatorAxis(dim, new IntervalScale()); + indicatorAxis.name = indicatorModel.get('name'); + // Inject model and axis + indicatorAxis.model = indicatorModel; + indicatorModel.axis = indicatorAxis; + this.dimensions.push(dim); + return indicatorAxis; + }, this); + + this.resize(radarModel, api); + + /** + * @type {number} + * @readOnly + */ + this.cx; + /** + * @type {number} + * @readOnly + */ + this.cy; + /** + * @type {number} + * @readOnly + */ + this.r; + /** + * @type {number} + * @readOnly + */ + this.startAngle; + } + + Radar.prototype.getIndicatorAxes = function () { + return this._indicatorAxes; + }; + + Radar.prototype.dataToPoint = function (value, indicatorIndex) { + var indicatorAxis = this._indicatorAxes[indicatorIndex]; + + return this.coordToPoint(indicatorAxis.dataToCoord(value), indicatorIndex); + }; + + Radar.prototype.coordToPoint = function (coord, indicatorIndex) { + var indicatorAxis = this._indicatorAxes[indicatorIndex]; + var angle = indicatorAxis.angle; + var x = this.cx + coord * Math.cos(angle); + var y = this.cy - coord * Math.sin(angle); + return [x, y]; + }; + + Radar.prototype.pointToData = function (pt) { + var dx = pt[0] - this.cx; + var dy = pt[1] - this.cy; + var radius = Math.sqrt(dx * dx + dy * dy); + dx /= radius; + dy /= radius; + + var radian = Math.atan2(-dy, dx); + + // Find the closest angle + // FIXME index can calculated directly + var minRadianDiff = Infinity; + var closestAxis; + var closestAxisIdx = -1; + for (var i = 0; i < this._indicatorAxes.length; i++) { + var indicatorAxis = this._indicatorAxes[i]; + var diff = Math.abs(radian - indicatorAxis.angle); + if (diff < minRadianDiff) { + closestAxis = indicatorAxis; + closestAxisIdx = i; + minRadianDiff = diff; + } + } + + return [closestAxisIdx, +(closestAxis && closestAxis.coodToData(radius))]; + }; + + Radar.prototype.resize = function (radarModel, api) { + var center = radarModel.get('center'); + var viewWidth = api.getWidth(); + var viewHeight = api.getHeight(); + var viewSize = Math.min(viewWidth, viewHeight) / 2; + this.cx = numberUtil.parsePercent(center[0], viewWidth); + this.cy = numberUtil.parsePercent(center[1], viewHeight); + + this.startAngle = radarModel.get('startAngle') * Math.PI / 180; + + this.r = numberUtil.parsePercent(radarModel.get('radius'), viewSize); + + zrUtil.each(this._indicatorAxes, function (indicatorAxis, idx) { + indicatorAxis.setExtent(0, this.r); + var angle = (this.startAngle + idx * Math.PI * 2 / this._indicatorAxes.length); + // Normalize to [-PI, PI] + angle = Math.atan2(Math.sin(angle), Math.cos(angle)); + indicatorAxis.angle = angle; + }, this); + }; + + Radar.prototype.update = function (ecModel, api) { + var indicatorAxes = this._indicatorAxes; + var radarModel = this._model; + zrUtil.each(indicatorAxes, function (indicatorAxis) { + indicatorAxis.scale.setExtent(Infinity, -Infinity); + }); + ecModel.eachSeriesByType('radar', function (radarSeries, idx) { + if (radarSeries.get('coordinateSystem') !== 'radar' + || ecModel.getComponent('radar', radarSeries.get('radarIndex')) !== radarModel + ) { + return; + } + var data = radarSeries.getData(); + zrUtil.each(indicatorAxes, function (indicatorAxis) { + indicatorAxis.scale.unionExtent(data.getDataExtent(indicatorAxis.dim)); + }); + }, this); + + var splitNumber = radarModel.get('splitNumber'); + + function increaseInterval(interval) { + var exp10 = Math.pow(10, Math.floor(Math.log(interval) / Math.LN10)); + // Increase interval + var f = interval / exp10; + if (f === 2) { + f = 5; + } + else { // f is 2 or 5 + f *= 2; + } + return f * exp10; + } + // Force all the axis fixing the maxSplitNumber. + zrUtil.each(indicatorAxes, function (indicatorAxis, idx) { + var rawExtent = axisHelper.getScaleExtent(indicatorAxis, indicatorAxis.model); + axisHelper.niceScaleExtent(indicatorAxis, indicatorAxis.model); + + var axisModel = indicatorAxis.model; + var scale = indicatorAxis.scale; + var fixedMin = axisModel.get('min'); + var fixedMax = axisModel.get('max'); + var interval = scale.getInterval(); + + if (fixedMin != null && fixedMax != null) { + // User set min, max, divide to get new interval + // FIXME precision + scale.setInterval( + (fixedMax - fixedMin) / splitNumber + ); + } + else if (fixedMin != null) { + var max; + // User set min, expand extent on the other side + do { + max = fixedMin + interval * splitNumber; + scale.setExtent(+fixedMin, max); + // Interval must been set after extent + // FIXME + scale.setInterval(interval); + + interval = increaseInterval(interval); + } while (max < rawExtent[1] && isFinite(max) && isFinite(rawExtent[1])); + } + else if (fixedMax != null) { + var min; + // User set min, expand extent on the other side + do { + min = fixedMax - interval * splitNumber; + scale.setExtent(min, +fixedMax); + scale.setInterval(interval); + interval = increaseInterval(interval); + } while (min > rawExtent[0] && isFinite(min) && isFinite(rawExtent[0])); + } + else { + var nicedSplitNumber = scale.getTicks().length - 1; + if (nicedSplitNumber > splitNumber) { + interval = increaseInterval(interval); + } + // PENDING + var center = Math.round((rawExtent[0] + rawExtent[1]) / 2 / interval) * interval; + var halfSplitNumber = Math.round(splitNumber / 2); + scale.setExtent( + numberUtil.round(center - halfSplitNumber * interval), + numberUtil.round(center + (splitNumber - halfSplitNumber) * interval) + ); + scale.setInterval(interval); + } + }); + }; + + /** + * Radar dimensions is based on the data + * @type {Array} + */ + Radar.dimensions = []; + + Radar.create = function (ecModel, api) { + var radarList = []; + ecModel.eachComponent('radar', function (radarModel) { + var radar = new Radar(radarModel, ecModel, api); + radarList.push(radar); + radarModel.coordinateSystem = radar; + }); + ecModel.eachSeriesByType('radar', function (radarSeries) { + if (radarSeries.get('coordinateSystem') === 'radar') { + // Inject coordinate system + radarSeries.coordinateSystem = radarList[radarSeries.get('radarIndex') || 0]; + } + }); + return radarList; + }; + + __webpack_require__(25).register('radar', Radar); + module.exports = Radar; + + +/***/ }, +/* 148 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var Axis = __webpack_require__(117); + + function IndicatorAxis(dim, scale, radiusExtent) { + Axis.call(this, dim, scale, radiusExtent); + + /** + * Axis type + * - 'category' + * - 'value' + * - 'time' + * - 'log' + * @type {string} + */ + this.type = 'value'; + + this.angle = 0; + + /** + * Indicator name + * @type {string} + */ + this.name = ''; + /** + * @type {module:echarts/model/Model} + */ + this.model; + } + + zrUtil.inherits(IndicatorAxis, Axis); + + module.exports = IndicatorAxis; + + +/***/ }, +/* 149 */ +/***/ function(module, exports, __webpack_require__) { + + + + + var axisDefault = __webpack_require__(122); + var valueAxisDefault = axisDefault.valueAxis; + var Model = __webpack_require__(8); + var zrUtil = __webpack_require__(3); + + var axisModelCommonMixin = __webpack_require__(123); + + function defaultsShow(opt, show) { + return zrUtil.defaults({ + show: show + }, opt); + } + + var RadarModel = __webpack_require__(1).extendComponentModel({ + + type: 'radar', + + optionUpdated: function () { + var boundaryGap = this.get('boundaryGap'); + var splitNumber = this.get('splitNumber'); + var scale = this.get('scale'); + var axisLine = this.get('axisLine'); + var axisTick = this.get('axisTick'); + var axisLabel = this.get('axisLabel'); + var nameTextStyle = this.get('name.textStyle'); + var showName = this.get('name.show'); + var nameFormatter = this.get('name.formatter'); + var nameGap = this.get('nameGap'); + var indicatorModels = zrUtil.map(this.get('indicator') || [], function (indicatorOpt) { + // PENDING + if (indicatorOpt.max != null && indicatorOpt.max > 0) { + indicatorOpt.min = 0; + } + else if (indicatorOpt.min != null && indicatorOpt.min < 0) { + indicatorOpt.max = 0; + } + // Use same configuration + indicatorOpt = zrUtil.extend({ + boundaryGap: boundaryGap, + splitNumber: splitNumber, + scale: scale, + axisLine: axisLine, + axisTick: axisTick, + axisLabel: axisLabel, + // Competitable with 2 and use text + name: indicatorOpt.text, + nameLocation: 'end', + nameGap: nameGap, + // min: 0, + nameTextStyle: nameTextStyle + }, indicatorOpt); + if (!showName) { + indicatorOpt.name = ''; + } + if (typeof nameFormatter === 'string') { + indicatorOpt.name = nameFormatter.replace('{value}', indicatorOpt.name); + } + else if (typeof nameFormatter === 'function') { + indicatorOpt.name = nameFormatter( + indicatorOpt.name, indicatorOpt + ); + } + return zrUtil.extend( + new Model(indicatorOpt, null, this.ecModel), + axisModelCommonMixin + ); + }, this); + this.getIndicatorModels = function () { + return indicatorModels; + }; + }, + + defaultOption: { + + zlevel: 0, + + z: 0, + + center: ['50%', '50%'], + + radius: '75%', + + startAngle: 90, + + name: { + show: true + // formatter: null + // textStyle: {} + }, + + boundaryGap: [0, 0], + + splitNumber: 5, + + nameGap: 15, + + scale: false, + + // Polygon or circle + shape: 'polygon', + + axisLine: zrUtil.merge( + { + lineStyle: { + color: '#bbb' + } + }, + valueAxisDefault.axisLine + ), + axisLabel: defaultsShow(valueAxisDefault.axisLabel, false), + axisTick: defaultsShow(valueAxisDefault.axisTick, false), + splitLine: defaultsShow(valueAxisDefault.splitLine, true), + splitArea: defaultsShow(valueAxisDefault.splitArea, true), + + // {text, min, max} + indicator: [] + } + }); + + module.exports = RadarModel; + + +/***/ }, +/* 150 */ +/***/ function(module, exports, __webpack_require__) { + + + + var AxisBuilder = __webpack_require__(126); + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + + var axisBuilderAttrs = [ + 'axisLine', 'axisLabel', 'axisTick', 'axisName' + ]; + + module.exports = __webpack_require__(1).extendComponentView({ + + type: 'radar', + + render: function (radarModel, ecModel, api) { + var group = this.group; + group.removeAll(); + + this._buildAxes(radarModel); + this._buildSplitLineAndArea(radarModel); + }, + + _buildAxes: function (radarModel) { + var radar = radarModel.coordinateSystem; + var indicatorAxes = radar.getIndicatorAxes(); + var axisBuilders = zrUtil.map(indicatorAxes, function (indicatorAxis) { + var axisBuilder = new AxisBuilder(indicatorAxis.model, { + position: [radar.cx, radar.cy], + rotation: indicatorAxis.angle, + labelDirection: -1, + tickDirection: -1, + nameDirection: 1 + }); + return axisBuilder; + }); + + zrUtil.each(axisBuilders, function (axisBuilder) { + zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder); + this.group.add(axisBuilder.getGroup()); + }, this); + }, + + _buildSplitLineAndArea: function (radarModel) { + var radar = radarModel.coordinateSystem; + var splitNumber = radarModel.get('splitNumber'); + var indicatorAxes = radar.getIndicatorAxes(); + if (!indicatorAxes.length) { + return; + } + var shape = radarModel.get('shape'); + var splitLineModel = radarModel.getModel('splitLine'); + var splitAreaModel = radarModel.getModel('splitArea'); + var lineStyleModel = splitLineModel.getModel('lineStyle'); + var areaStyleModel = splitAreaModel.getModel('areaStyle'); + + var showSplitLine = splitLineModel.get('show'); + var showSplitArea = splitAreaModel.get('show'); + var splitLineColors = lineStyleModel.get('color'); + var splitAreaColors = areaStyleModel.get('color'); + + splitLineColors = zrUtil.isArray(splitLineColors) ? splitLineColors : [splitLineColors]; + splitAreaColors = zrUtil.isArray(splitAreaColors) ? splitAreaColors : [splitAreaColors]; + + var splitLines = []; + var splitAreas = []; + + function getColorIndex(areaOrLine, areaOrLineColorList, idx) { + var colorIndex = idx % areaOrLineColorList.length; + areaOrLine[colorIndex] = areaOrLine[colorIndex] || []; + return colorIndex; + } + + if (shape === 'circle') { + var ticksRadius = indicatorAxes[0].getTicksCoords(); + var cx = radar.cx; + var cy = radar.cy; + for (var i = 0; i < ticksRadius.length; i++) { + if (showSplitLine) { + var colorIndex = getColorIndex(splitLines, splitLineColors, i); + splitLines[colorIndex].push(new graphic.Circle({ + shape: { + cx: cx, + cy: cy, + r: ticksRadius[i] + } + })); + } + if (showSplitArea && i < ticksRadius.length - 1) { + var colorIndex = getColorIndex(splitAreas, splitAreaColors, i); + splitAreas[colorIndex].push(new graphic.Ring({ + shape: { + cx: cx, + cy: cy, + r0: ticksRadius[i], + r: ticksRadius[i + 1] + } + })); + } + } + } + // Polyyon + else { + var axesTicksPoints = zrUtil.map(indicatorAxes, function (indicatorAxis, idx) { + var ticksCoords = indicatorAxis.getTicksCoords(); + return zrUtil.map(ticksCoords, function (tickCoord) { + return radar.coordToPoint(tickCoord, idx); + }); + }); + + var prevPoints = []; + for (var i = 0; i <= splitNumber; i++) { + var points = []; + for (var j = 0; j < indicatorAxes.length; j++) { + points.push(axesTicksPoints[j][i]); + } + // Close + points.push(points[0].slice()); + if (showSplitLine) { + var colorIndex = getColorIndex(splitLines, splitLineColors, i); + splitLines[colorIndex].push(new graphic.Polyline({ + shape: { + points: points + } + })); + } + if (showSplitArea && prevPoints) { + var colorIndex = getColorIndex(splitAreas, splitAreaColors, i - 1); + splitAreas[colorIndex].push(new graphic.Polygon({ + shape: { + points: points.concat(prevPoints) + } + })); + } + prevPoints = points.slice().reverse(); + } + } + + var lineStyle = lineStyleModel.getLineStyle(); + var areaStyle = areaStyleModel.getAreaStyle(); + // Add splitArea before splitLine + zrUtil.each(splitAreas, function (splitAreas, idx) { + this.group.add(graphic.mergePath( + splitAreas, { + style: zrUtil.defaults({ + stroke: 'none', + fill: splitAreaColors[idx % splitAreaColors.length] + }, areaStyle), + silent: true + } + )); + }, this); + + zrUtil.each(splitLines, function (splitLines, idx) { + this.group.add(graphic.mergePath( + splitLines, { + style: zrUtil.defaults({ + fill: 'none', + stroke: splitLineColors[idx % splitLineColors.length] + }, lineStyle), + silent: true + } + )); + }, this); + + } + }); + + +/***/ }, +/* 151 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var SeriesModel = __webpack_require__(27); + var List = __webpack_require__(94); + var completeDimensions = __webpack_require__(96); + var zrUtil = __webpack_require__(3); + var formatUtil = __webpack_require__(6); + + var RadarSeries = SeriesModel.extend({ + + type: 'series.radar', + + dependencies: ['radar'], + + + // Overwrite + init: function (option) { + RadarSeries.superApply(this, 'init', arguments); + + // Enable legend selection for each data item + // Use a function instead of direct access because data reference may changed + this.legendDataProvider = function () { + return this._dataBeforeProcessed; + }; + }, + + getInitialData: function (option, ecModel) { + var data = option.data || []; + var dimensions = completeDimensions( + [], data, [], 'indicator_' + ); + var list = new List(dimensions, this); + list.initData(data); + return list; + }, + + formatTooltip: function (dataIndex) { + var value = this.getRawValue(dataIndex); + var coordSys = this.coordinateSystem; + var indicatorAxes = coordSys.getIndicatorAxes(); + return this._data.getName(dataIndex) + '
' + + zrUtil.map(indicatorAxes, function (axis, idx) { + return axis.name + ' : ' + value[idx]; + }).join('
'); + }, + + getFormattedLabel: function (dataIndex, status, formatter, indicatorIndex) { + status = status || 'normal'; + var data = this.getData(); + var itemModel = data.getItemModel(dataIndex); + + var params = this.getDataParams(dataIndex); + if (formatter == null) { + formatter = itemModel.get(['label', status, 'formatter']); + } + // Get value of specified indicator + params.value = params.value[indicatorIndex || 0]; + if (typeof formatter === 'function') { + params.status = status; + return formatter(params); + } + else if (typeof formatter === 'string') { + return formatUtil.formatTpl(formatter, params); + } + }, + + defaultOption: { + zlevel: 0, + z: 2, + coordinateSystem: 'radar', + legendHoverLink: true, + radarIndex: 0, + lineStyle: { + normal: { + width: 2, + type: 'solid' + } + }, + label: { + normal: { + position: 'top' + } + }, + // areaStyle: { + // }, + // itemStyle: {} + symbol: 'emptyCircle', + symbolSize: 4 + // symbolRotate: null + } + }); + + module.exports = RadarSeries; + + +/***/ }, +/* 152 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + var symbolUtil = __webpack_require__(100); + + function normalizeSymbolSize(symbolSize) { + if (!zrUtil.isArray(symbolSize)) { + symbolSize = [+symbolSize, +symbolSize]; + } + return symbolSize; + } + module.exports = __webpack_require__(1).extendChartView({ + type: 'radar', + + render: function (seriesModel, ecModel, api) { + var polar = seriesModel.coordinateSystem; + var group = this.group; + + var data = seriesModel.getData(); + var oldData = this._data; + + function createSymbol(data, idx) { + var symbolType = data.getItemVisual(idx, 'symbol') || 'circle'; + var color = data.getItemVisual(idx, 'color'); + if (symbolType === 'none') { + return; + } + var symbolPath = symbolUtil.createSymbol( + symbolType, -0.5, -0.5, 1, 1, color + ); + symbolPath.attr({ + style: { + strokeNoScale: true + }, + z2: 100, + scale: normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')) + }); + return symbolPath; + } + + function updateSymbols(oldPoints, newPoints, symbolGroup, data, idx, isInit) { + // Simply rerender all + symbolGroup.removeAll(); + for (var i = 0; i < newPoints.length - 1; i++) { + var symbolPath = createSymbol(data, idx); + if (symbolPath) { + symbolPath.__dimIdx = i; + if (oldPoints[i]) { + symbolPath.attr('position', oldPoints[i]); + graphic[isInit ? 'initProps' : 'updateProps']( + symbolPath, { + position: newPoints[i] + }, seriesModel + ); + } + else { + symbolPath.attr('position', newPoints[i]); + } + symbolGroup.add(symbolPath); + } + } + } + + function getInitialPoints(points) { + return zrUtil.map(points, function (pt) { + return [polar.cx, polar.cy]; + }); + } + data.diff(oldData) + .add(function (idx) { + var points = data.getItemLayout(idx); + if (!points) { + return; + } + var polygon = new graphic.Polygon(); + var polyline = new graphic.Polyline(); + var target = { + shape: { + points: points + } + }; + polygon.shape.points = getInitialPoints(points); + polyline.shape.points = getInitialPoints(points); + graphic.initProps(polygon, target, seriesModel); + graphic.initProps(polyline, target, seriesModel); + + var itemGroup = new graphic.Group(); + var symbolGroup = new graphic.Group(); + itemGroup.add(polyline); + itemGroup.add(polygon); + itemGroup.add(symbolGroup); + + updateSymbols( + polyline.shape.points, points, symbolGroup, data, idx, true + ); + + data.setItemGraphicEl(idx, itemGroup); + }) + .update(function (newIdx, oldIdx) { + var itemGroup = oldData.getItemGraphicEl(oldIdx); + var polyline = itemGroup.childAt(0); + var polygon = itemGroup.childAt(1); + var symbolGroup = itemGroup.childAt(2); + var target = { + shape: { + points: data.getItemLayout(newIdx) + } + }; + if (!target.shape.points) { + return; + } + updateSymbols( + polyline.shape.points, target.shape.points, symbolGroup, data, newIdx, false + ); + + graphic.updateProps(polyline, target, seriesModel); + graphic.updateProps(polygon, target, seriesModel); + + data.setItemGraphicEl(newIdx, itemGroup); + }) + .remove(function (idx) { + group.remove(oldData.getItemGraphicEl(idx)); + }) + .execute(); + + data.eachItemGraphicEl(function (itemGroup, idx) { + var itemModel = data.getItemModel(idx); + var polyline = itemGroup.childAt(0); + var polygon = itemGroup.childAt(1); + var symbolGroup = itemGroup.childAt(2); + var color = data.getItemVisual(idx, 'color'); + + group.add(itemGroup); + + polyline.setStyle( + zrUtil.extend( + itemModel.getModel('lineStyle.normal').getLineStyle(), + { + stroke: color + } + ) + ); + polyline.hoverStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle(); + + var areaStyleModel = itemModel.getModel('areaStyle.normal'); + var hoverAreaStyleModel = itemModel.getModel('areaStyle.emphasis'); + var polygonIgnore = areaStyleModel.isEmpty() && areaStyleModel.parentModel.isEmpty(); + var hoverPolygonIgnore = hoverAreaStyleModel.isEmpty() && hoverAreaStyleModel.parentModel.isEmpty(); + + hoverPolygonIgnore = hoverPolygonIgnore && polygonIgnore; + polygon.ignore = polygonIgnore; + + polygon.setStyle( + zrUtil.defaults( + areaStyleModel.getAreaStyle(), + { + fill: color, + opacity: 0.7 + } + ) + ); + polygon.hoverStyle = hoverAreaStyleModel.getAreaStyle(); + + var itemStyle = itemModel.getModel('itemStyle.normal').getItemStyle(['color']); + var itemHoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle(); + var labelModel = itemModel.getModel('label.normal'); + var labelHoverModel = itemModel.getModel('label.emphasis'); + symbolGroup.eachChild(function (symbolPath) { + symbolPath.setStyle(itemStyle); + symbolPath.hoverStyle = zrUtil.clone(itemHoverStyle); + + var defaultText = data.get(data.dimensions[symbolPath.__dimIdx], idx); + graphic.setText(symbolPath.style, labelModel, color); + symbolPath.setStyle({ + text: labelModel.get('show') ? zrUtil.retrieve( + seriesModel.getFormattedLabel( + idx, 'normal', null, symbolPath.__dimIdx + ), + defaultText + ) : '' + }); + + graphic.setText(symbolPath.hoverStyle, labelHoverModel, color); + symbolPath.hoverStyle.text = labelHoverModel.get('show') ? zrUtil.retrieve( + seriesModel.getFormattedLabel( + idx, 'emphasis', null, symbolPath.__dimIdx + ), + defaultText + ) : ''; + }); + + function onEmphasis() { + polygon.attr('ignore', hoverPolygonIgnore); + } + + function onNormal() { + polygon.attr('ignore', polygonIgnore); + } + + itemGroup.off('mouseover').off('mouseout').off('normal').off('emphasis'); + itemGroup.on('emphasis', onEmphasis) + .on('mouseover', onEmphasis) + .on('normal', onNormal) + .on('mouseout', onNormal); + + graphic.setHoverStyle(itemGroup); + }); + + this._data = data; + }, + + remove: function () { + this.group.removeAll(); + this._data = null; + } + }); + + +/***/ }, +/* 153 */ +/***/ function(module, exports) { + + + + module.exports = function (ecModel, api) { + ecModel.eachSeriesByType('radar', function (seriesModel) { + var data = seriesModel.getData(); + var points = []; + var coordSys = seriesModel.coordinateSystem; + if (!coordSys) { + return; + } + + function pointsConverter(val, idx) { + points[idx] = points[idx] || []; + points[idx][i] = coordSys.dataToPoint(val, i); + } + for (var i = 0; i < coordSys.getIndicatorAxes().length; i++) { + var dim = data.dimensions[i]; + data.each(dim, pointsConverter); + } + + data.each(function (idx) { + // Close polygon + points[idx][0] && points[idx].push(points[idx][0].slice()); + data.setItemLayout(idx, points[idx]); + }); + }); + }; + + +/***/ }, +/* 154 */ +/***/ function(module, exports, __webpack_require__) { + + // Backward compat for radar chart in 2 + + + var zrUtil = __webpack_require__(3); + + module.exports = function (option) { + var polarOptArr = option.polar; + if (polarOptArr) { + if (!zrUtil.isArray(polarOptArr)) { + polarOptArr = [polarOptArr]; + } + var polarNotRadar = []; + zrUtil.each(polarOptArr, function (polarOpt, idx) { + if (polarOpt.indicator) { + if (polarOpt.type && !polarOpt.shape) { + polarOpt.shape = polarOpt.type; + } + option.radar = option.radar || []; + if (!zrUtil.isArray(option.radar)) { + option.radar = [option.radar]; + } + option.radar.push(polarOpt); + } + else { + polarNotRadar.push(polarOpt); + } + }); + option.polar = polarNotRadar; + } + zrUtil.each(option.series, function (seriesOpt) { + if (seriesOpt.type === 'radar' && seriesOpt.polarIndex) { + seriesOpt.radarIndex = seriesOpt.polarIndex; + } + }); + }; + + +/***/ }, +/* 155 */ +/***/ function(module, exports, __webpack_require__) { + + + + var echarts = __webpack_require__(1); + + __webpack_require__(156); + + __webpack_require__(157); + + __webpack_require__(161); + + __webpack_require__(163); + + echarts.registerLayout(__webpack_require__(173)); + + echarts.registerVisualCoding('chart', __webpack_require__(174)); + + echarts.registerProcessor('statistic', __webpack_require__(175)); + + echarts.registerPreprocessor(__webpack_require__(176)); - updateCanvasGradient: function (shape, ctx) { - var rect = shape.getBoundingRect(); + __webpack_require__(136)('map', [{ + type: 'mapToggleSelect', + event: 'mapselectchanged', + method: 'toggleSelected' + }, { + type: 'mapSelect', + event: 'mapselected', + method: 'select' + }, { + type: 'mapUnSelect', + event: 'mapunselected', + method: 'unSelect' + }]); + + +/***/ }, +/* 156 */ +/***/ function(module, exports, __webpack_require__) { + + + + var List = __webpack_require__(94); + var echarts = __webpack_require__(1); + var SeriesModel = __webpack_require__(27); + var zrUtil = __webpack_require__(3); + var completeDimensions = __webpack_require__(96); + + var formatUtil = __webpack_require__(6); + var encodeHTML = formatUtil.encodeHTML; + var addCommas = formatUtil.addCommas; + + var dataSelectableMixin = __webpack_require__(134); + + function fillData(dataOpt, geoJson) { + var dataNameMap = {}; + var features = geoJson.features; + for (var i = 0; i < dataOpt.length; i++) { + dataNameMap[dataOpt[i].name] = dataOpt[i]; + } + + for (var i = 0; i < features.length; i++) { + var name = features[i].properties.name; + if (!dataNameMap[name]) { + dataOpt.push({ + value: NaN, + name: name + }); + } + } + return dataOpt; + } + + var MapSeries = SeriesModel.extend({ + + type: 'series.map', + + /** + * Only first map series of same mapType will drawMap + * @type {boolean} + */ + needsDrawMap: false, + + /** + * Group of all map series with same mapType + * @type {boolean} + */ + seriesGroup: [], + + init: function (option) { + + option = this._fillOption(option); + this.option = option; + + MapSeries.superApply(this, 'init', arguments); + + this.updateSelectedMap(); + }, + + getInitialData: function (option) { + var dimensions = completeDimensions(['value'], option.data || []); + + var list = new List(dimensions, this); + + list.initData(option.data); + + return list; + }, + + mergeOption: function (newOption) { + newOption = this._fillOption(newOption); + + MapSeries.superCall(this, 'mergeOption', newOption); + + this.updateSelectedMap(); + }, + + _fillOption: function (option) { + // Shallow clone + option = zrUtil.extend({}, option); + + var map = echarts.getMap(option.mapType); + var geoJson = map && map.geoJson; + geoJson && option.data + && (option.data = fillData(option.data, geoJson)); + + return option; + }, + + /** + * @param {number} zoom + */ + setRoamZoom: function (zoom) { + var roamDetail = this.option.roamDetail; + roamDetail && (roamDetail.zoom = zoom); + }, + + /** + * @param {number} x + * @param {number} y + */ + setRoamPan: function (x, y) { + var roamDetail = this.option.roamDetail; + if (roamDetail) { + roamDetail.x = x; + roamDetail.y = y; + } + }, + + getRawValue: function (dataIndex) { + // Use value stored in data instead because it is calculated from multiple series + // FIXME Provide all value of multiple series ? + return this._data.get('value', dataIndex); + }, + + /** + * Map tooltip formatter + * + * @param {number} dataIndex + */ + formatTooltip: function (dataIndex) { + var data = this._data; + var formattedValue = addCommas(this.getRawValue(dataIndex)); + var name = data.getName(dataIndex); + + var seriesGroup = this.seriesGroup; + var seriesNames = []; + for (var i = 0; i < seriesGroup.length; i++) { + if (!isNaN(seriesGroup[i].getRawValue(dataIndex))) { + seriesNames.push( + encodeHTML(seriesGroup[i].name) + ); + } + } + + return seriesNames.join(', ') + '
' + + name + ' : ' + formattedValue; + }, + + defaultOption: { + // 一级层叠 + zlevel: 0, + // 二级层叠 + z: 2, + coordinateSystem: 'geo', + // 各省的 map 暂时都用中文 + map: 'china', + + // 'center' | 'left' | 'right' | 'x%' | {number} + left: 'center', + // 'center' | 'top' | 'bottom' | 'x%' | {number} + top: 'center', + // right + // bottom + // width: + // height // 自适应 + + // 数值合并方式,默认加和,可选为: + // 'sum' | 'average' | 'max' | 'min' + // mapValueCalculation: 'sum', + // 地图数值计算结果小数精度 + // mapValuePrecision: 0, + // 显示图例颜色标识(系列标识的小圆点),图例开启时有效 + showLegendSymbol: true, + // 选择模式,默认关闭,可选single,multiple + // selectedMode: false, + dataRangeHoverLink: true, + // 是否开启缩放及漫游模式 + // roam: false, + + // 在 roam 开启的时候使用 + roamDetail: { + x: 0, + y: 0, + zoom: 1 + }, + + label: { + normal: { + show: false, + textStyle: { + color: '#000' + } + }, + emphasis: { + show: false, + textStyle: { + color: '#000' + } + } + }, + // scaleLimit: null, + itemStyle: { + normal: { + // color: 各异, + borderWidth: 0.5, + borderColor: '#444', + areaColor: '#eee' + }, + // 也是选中样式 + emphasis: { + areaColor: 'rgba(255,215, 0, 0.8)' + } + } + } + }); + + zrUtil.mixin(MapSeries, dataSelectableMixin); + + module.exports = MapSeries; + + +/***/ }, +/* 157 */ +/***/ function(module, exports, __webpack_require__) { + + + + // var zrUtil = require('zrender/lib/core/util'); + var graphic = __webpack_require__(42); + + var MapDraw = __webpack_require__(158); + + __webpack_require__(1).extendChartView({ + + type: 'map', + + render: function (mapModel, ecModel, api, payload) { + // Not render if it is an toggleSelect action from self + if (payload && payload.type === 'mapToggleSelect' + && payload.from === this.uid + ) { + return; + } + + var group = this.group; + group.removeAll(); + // Not update map if it is an roam action from self + if (!(payload && payload.type === 'geoRoam' + && payload.component === 'series' + && payload.name === mapModel.name)) { + + if (mapModel.needsDrawMap) { + var mapDraw = this._mapDraw || new MapDraw(api, true); + group.add(mapDraw.group); + + mapDraw.draw(mapModel, ecModel, api, this); + + this._mapDraw = mapDraw; + } + else { + // Remove drawed map + this._mapDraw && this._mapDraw.remove(); + this._mapDraw = null; + } + } + else { + var mapDraw = this._mapDraw; + mapDraw && group.add(mapDraw.group); + } + + mapModel.get('showLegendSymbol') && ecModel.getComponent('legend') + && this._renderSymbols(mapModel, ecModel, api); + }, + + remove: function () { + this._mapDraw && this._mapDraw.remove(); + this._mapDraw = null; + this.group.removeAll(); + }, + + _renderSymbols: function (mapModel, ecModel, api) { + var data = mapModel.getData(); + var group = this.group; + + data.each('value', function (value, idx) { + if (isNaN(value)) { + return; + } + + var layout = data.getItemLayout(idx); + + if (!layout || !layout.point) { + // Not exists in map + return; + } + + var point = layout.point; + var offset = layout.offset; + + var circle = new graphic.Circle({ + style: { + fill: data.getVisual('color') + }, + shape: { + cx: point[0] + offset * 9, + cy: point[1], + r: 3 + }, + silent: true, + z2: 10 + }); + + // First data on the same region + if (!offset) { + var labelText = data.getName(idx); + + var itemModel = data.getItemModel(idx); + var labelModel = itemModel.getModel('label.normal'); + var hoverLabelModel = itemModel.getModel('label.emphasis'); + + var textStyleModel = labelModel.getModel('textStyle'); + var hoverTextStyleModel = hoverLabelModel.getModel('textStyle'); + + var polygonGroups = data.getItemGraphicEl(idx); + circle.setStyle({ + textPosition: 'bottom' + }); + + var onEmphasis = function () { + circle.setStyle({ + text: hoverLabelModel.get('show') ? labelText : '', + textFill: hoverTextStyleModel.getTextColor(), + textFont: hoverTextStyleModel.getFont() + }); + }; + + var onNormal = function () { + circle.setStyle({ + text: labelModel.get('show') ? labelText : '', + textFill: textStyleModel.getTextColor(), + textFont: textStyleModel.getFont() + }); + }; + + polygonGroups.on('mouseover', onEmphasis) + .on('mouseout', onNormal) + .on('emphasis', onEmphasis) + .on('normal', onNormal); + + onNormal(); + } + + group.add(circle); + }); + } + }); + + +/***/ }, +/* 158 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/component/helper/MapDraw + */ + + + var RoamController = __webpack_require__(159); + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + + function getFixedItemStyle(model, scale) { + var itemStyle = model.getItemStyle(); + var areaColor = model.get('areaColor'); + if (areaColor) { + itemStyle.fill = areaColor; + } + + return itemStyle; + } + + function updateMapSelectHandler(mapOrGeoModel, data, group, api, fromView) { + group.off('click'); + mapOrGeoModel.get('selectedMode') + && group.on('click', function (e) { + var dataIndex = e.target.dataIndex; + if (dataIndex != null) { + var name = data.getName(dataIndex); + + api.dispatchAction({ + type: 'mapToggleSelect', + seriesIndex: mapOrGeoModel.seriesIndex, + name: name, + from: fromView.uid + }); + + updateMapSelected(mapOrGeoModel, data, api); + } + }); + } + + function updateMapSelected(mapOrGeoModel, data) { + data.eachItemGraphicEl(function (el, idx) { + var name = data.getName(idx); + el.trigger(mapOrGeoModel.isSelected(name) ? 'emphasis' : 'normal'); + }); + } + + /** + * @alias module:echarts/component/helper/MapDraw + * @param {module:echarts/ExtensionAPI} api + * @param {boolean} updateGroup + */ + function MapDraw(api, updateGroup) { + + var group = new graphic.Group(); + + /** + * @type {module:echarts/component/helper/RoamController} + * @private + */ + this._controller = new RoamController( + api.getZr(), updateGroup ? group : null, null + ); + + /** + * @type {module:zrender/container/Group} + * @readOnly + */ + this.group = group; + + /** + * @type {boolean} + * @private + */ + this._updateGroup = updateGroup; + } + + MapDraw.prototype = { + + constructor: MapDraw, + + draw: function (mapOrGeoModel, ecModel, api, fromView) { + + // geoModel has no data + var data = mapOrGeoModel.getData && mapOrGeoModel.getData(); + + var geo = mapOrGeoModel.coordinateSystem; + + var group = this.group; + group.removeAll(); + + var scale = geo.scale; + group.position = geo.position.slice(); + group.scale = scale.slice(); + + var itemStyleModel; + var hoverItemStyleModel; + var itemStyle; + var hoverItemStyle; + + var labelModel; + var hoverLabelModel; + + var itemStyleAccessPath = ['itemStyle', 'normal']; + var hoverItemStyleAccessPath = ['itemStyle', 'emphasis']; + var labelAccessPath = ['label', 'normal']; + var hoverLabelAccessPath = ['label', 'emphasis']; + if (!data) { + itemStyleModel = mapOrGeoModel.getModel(itemStyleAccessPath); + hoverItemStyleModel = mapOrGeoModel.getModel(hoverItemStyleAccessPath); + + itemStyle = getFixedItemStyle(itemStyleModel, scale); + hoverItemStyle = getFixedItemStyle(hoverItemStyleModel, scale); + + labelModel = mapOrGeoModel.getModel(labelAccessPath); + hoverLabelModel = mapOrGeoModel.getModel(hoverLabelAccessPath); + } + + zrUtil.each(geo.regions, function (region) { + + var regionGroup = new graphic.Group(); + var dataIdx; + // Use the itemStyle in data if has data + if (data) { + // FIXME If dataIdx < 0 + dataIdx = data.indexOfName(region.name); + var itemModel = data.getItemModel(dataIdx); + + // Only visual color of each item will be used. It can be encoded by dataRange + // But visual color of series is used in symbol drawing + // + // Visual color for each series is for the symbol draw + var visualColor = data.getItemVisual(dataIdx, 'color', true); + + itemStyleModel = itemModel.getModel(itemStyleAccessPath); + hoverItemStyleModel = itemModel.getModel(hoverItemStyleAccessPath); + + itemStyle = getFixedItemStyle(itemStyleModel, scale); + hoverItemStyle = getFixedItemStyle(hoverItemStyleModel, scale); + + labelModel = itemModel.getModel(labelAccessPath); + hoverLabelModel = itemModel.getModel(hoverLabelAccessPath); + + if (visualColor) { + itemStyle.fill = visualColor; + } + } + var textStyleModel = labelModel.getModel('textStyle'); + var hoverTextStyleModel = hoverLabelModel.getModel('textStyle'); + + zrUtil.each(region.contours, function (contour) { + + var polygon = new graphic.Polygon({ + shape: { + points: contour + }, + style: { + strokeNoScale: true + }, + culling: true + }); + + polygon.setStyle(itemStyle); + + regionGroup.add(polygon); + }); + + // Label + var showLabel = labelModel.get('show'); + var hoverShowLabel = hoverLabelModel.get('show'); + + var isDataNaN = data && isNaN(data.get('value', dataIdx)); + var itemLayout = data && data.getItemLayout(dataIdx); + // In the following cases label will be drawn + // 1. In map series and data value is NaN + // 2. In geo component + // 4. Region has no series legendSymbol, which will be add a showLabel flag in mapSymbolLayout + if ( + (!data || isDataNaN && (showLabel || hoverShowLabel)) + || (itemLayout && itemLayout.showLabel) + ) { + var query = data ? dataIdx : region.name; + var formattedStr = mapOrGeoModel.getFormattedLabel(query, 'normal'); + var hoverFormattedStr = mapOrGeoModel.getFormattedLabel(query, 'emphasis'); + var text = new graphic.Text({ + style: { + text: showLabel ? (formattedStr || region.name) : '', + fill: textStyleModel.getTextColor(), + textFont: textStyleModel.getFont(), + textAlign: 'center', + textVerticalAlign: 'middle' + }, + hoverStyle: { + text: hoverShowLabel ? (hoverFormattedStr || region.name) : '', + fill: hoverTextStyleModel.getTextColor(), + textFont: hoverTextStyleModel.getFont() + }, + position: region.center.slice(), + scale: [1 / scale[0], 1 / scale[1]], + z2: 10, + silent: true + }); + + regionGroup.add(text); + } + + // setItemGraphicEl, setHoverStyle after all polygons and labels + // are added to the rigionGroup + data && data.setItemGraphicEl(dataIdx, regionGroup); + + graphic.setHoverStyle(regionGroup, hoverItemStyle); + + group.add(regionGroup); + }); + + this._updateController(mapOrGeoModel, ecModel, api); + + data && updateMapSelectHandler(mapOrGeoModel, data, group, api, fromView); + + data && updateMapSelected(mapOrGeoModel, data); + }, + + remove: function () { + this.group.removeAll(); + this._controller.dispose(); + }, + + _updateController: function (mapOrGeoModel, ecModel, api) { + var geo = mapOrGeoModel.coordinateSystem; + var controller = this._controller; + // roamType is will be set default true if it is null + controller.enable(mapOrGeoModel.get('roam') || false); + // FIXME mainType, subType 作为 component 的属性? + var mainType = mapOrGeoModel.type.split('.')[0]; + controller.off('pan') + .on('pan', function (dx, dy) { + api.dispatchAction({ + type: 'geoRoam', + component: mainType, + name: mapOrGeoModel.name, + dx: dx, + dy: dy + }); + }); + controller.off('zoom') + .on('zoom', function (zoom, mouseX, mouseY) { + api.dispatchAction({ + type: 'geoRoam', + component: mainType, + name: mapOrGeoModel.name, + zoom: zoom, + originX: mouseX, + originY: mouseY + }); + + if (this._updateGroup) { + var group = this.group; + var scale = group.scale; + group.traverse(function (el) { + if (el.type === 'text') { + el.attr('scale', [1 / scale[0], 1 / scale[1]]); + } + }); + } + }, this); + + controller.rect = geo.getViewRect(); + } + }; + + module.exports = MapDraw; + + +/***/ }, +/* 159 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/component/helper/RoamController + */ + + + + var Eventful = __webpack_require__(32); + var zrUtil = __webpack_require__(3); + var eventTool = __webpack_require__(80); + var interactionMutex = __webpack_require__(160); + + function mousedown(e) { + if (e.target && e.target.draggable) { + return; + } + + var x = e.offsetX; + var y = e.offsetY; + var rect = this.rect; + if (rect && rect.contain(x, y)) { + this._x = x; + this._y = y; + this._dragging = true; + } + } + + function mousemove(e) { + if (!this._dragging) { + return; + } + + eventTool.stop(e.event); + + if (e.gestureEvent !== 'pinch') { + + if (interactionMutex.isTaken('globalPan', this._zr)) { + return; + } + + var x = e.offsetX; + var y = e.offsetY; + + var dx = x - this._x; + var dy = y - this._y; + + this._x = x; + this._y = y; + + var target = this.target; + + if (target) { + var pos = target.position; + pos[0] += dx; + pos[1] += dy; + target.dirty(); + } + + eventTool.stop(e.event); + this.trigger('pan', dx, dy); + } + } + + function mouseup(e) { + this._dragging = false; + } + + function mousewheel(e) { + eventTool.stop(e.event); + // Convenience: + // Mac and VM Windows on Mac: scroll up: zoom out. + // Windows: scroll up: zoom in. + var zoomDelta = e.wheelDelta > 0 ? 1.1 : 1 / 1.1; + zoom.call(this, e, zoomDelta, e.offsetX, e.offsetY); + } + + function pinch(e) { + if (interactionMutex.isTaken('globalPan', this._zr)) { + return; + } + + eventTool.stop(e.event); + var zoomDelta = e.pinchScale > 1 ? 1.1 : 1 / 1.1; + zoom.call(this, e, zoomDelta, e.pinchX, e.pinchY); + } + + function zoom(e, zoomDelta, zoomX, zoomY) { + var rect = this.rect; + + if (rect && rect.contain(zoomX, zoomY)) { + + var target = this.target; + + if (target) { + var pos = target.position; + var scale = target.scale; + + var newZoom = this._zoom = this._zoom || 1; + newZoom *= zoomDelta; + // newZoom = Math.max( + // Math.min(target.maxZoom, newZoom), + // target.minZoom + // ); + var zoomScale = newZoom / this._zoom; + this._zoom = newZoom; + // Keep the mouse center when scaling + pos[0] -= (zoomX - pos[0]) * (zoomScale - 1); + pos[1] -= (zoomY - pos[1]) * (zoomScale - 1); + scale[0] *= zoomScale; + scale[1] *= zoomScale; + + target.dirty(); + } + + this.trigger('zoom', zoomDelta, zoomX, zoomY); + } + } + + /** + * @alias module:echarts/component/helper/RoamController + * @constructor + * @mixin {module:zrender/mixin/Eventful} + * + * @param {module:zrender/zrender~ZRender} zr + * @param {module:zrender/Element} target + * @param {module:zrender/core/BoundingRect} rect + */ + function RoamController(zr, target, rect) { + + /** + * @type {module:zrender/Element} + */ + this.target = target; + + /** + * @type {module:zrender/core/BoundingRect} + */ + this.rect = rect; + + /** + * @type {module:zrender} + */ + this._zr = zr; + + // Avoid two roamController bind the same handler + var bind = zrUtil.bind; + var mousedownHandler = bind(mousedown, this); + var mousemoveHandler = bind(mousemove, this); + var mouseupHandler = bind(mouseup, this); + var mousewheelHandler = bind(mousewheel, this); + var pinchHandler = bind(pinch, this); + + Eventful.call(this); + + /** + * Notice: only enable needed types. For example, if 'zoom' + * is not needed, 'zoom' should not be enabled, otherwise + * default mousewheel behaviour (scroll page) will be disabled. + * + * @param {boolean|string} [controlType=true] Specify the control type, + * which can be null/undefined or true/false + * or 'pan/move' or 'zoom'/'scale' + */ + this.enable = function (controlType) { + // Disable previous first + this.disable(); + + if (controlType == null) { + controlType = true; + } + + if (controlType === true || (controlType === 'move' || controlType === 'pan')) { + zr.on('mousedown', mousedownHandler); + zr.on('mousemove', mousemoveHandler); + zr.on('mouseup', mouseupHandler); + } + if (controlType === true || (controlType === 'scale' || controlType === 'zoom')) { + zr.on('mousewheel', mousewheelHandler); + zr.on('pinch', pinchHandler); + } + }; + + this.disable = function () { + zr.off('mousedown', mousedownHandler); + zr.off('mousemove', mousemoveHandler); + zr.off('mouseup', mouseupHandler); + zr.off('mousewheel', mousewheelHandler); + zr.off('pinch', pinchHandler); + }; + + this.dispose = this.disable; + + this.isDragging = function () { + return this._dragging; + }; + + this.isPinching = function () { + return this._pinching; + }; + } + + zrUtil.mixin(RoamController, Eventful); + + module.exports = RoamController; + + +/***/ }, +/* 160 */ +/***/ function(module, exports) { + + + + var ATTR = '\0_ec_interaction_mutex'; + + var interactionMutex = { + + take: function (key, zr) { + getStore(zr)[key] = true; + }, + + release: function (key, zr) { + getStore(zr)[key] = false; + }, + + isTaken: function (key, zr) { + return !!getStore(zr)[key]; + } + }; + + function getStore(zr) { + return zr[ATTR] || (zr[ATTR] = {}); + } + + module.exports = interactionMutex; + + +/***/ }, +/* 161 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var roamHelper = __webpack_require__(162); + + var echarts = __webpack_require__(1); + var actionInfo = { + type: 'geoRoam', + event: 'geoRoam', + update: 'updateLayout' + }; + + /** + * @payload + * @property {string} [component=series] + * @property {string} name Component name + * @property {number} [dx] + * @property {number} [dy] + * @property {number} [zoom] + * @property {number} [originX] + * @property {number} [originY] + */ + echarts.registerAction(actionInfo, function (payload, ecModel) { + var componentType = payload.component || 'series'; - var width = rect.width; - var height = rect.height; - var min = Math.min(width, height); - // var max = Math.max(width, height); + ecModel.eachComponent(componentType, function (componentModel) { + if (componentModel.name === payload.name) { + var geo = componentModel.coordinateSystem; + if (geo.type !== 'geo') { + return; + } + + var roamDetailModel = componentModel.getModel('roamDetail'); + var res = roamHelper.calcPanAndZoom(roamDetailModel, payload); - var x = this.x * width + rect.x; - var y = this.y * height + rect.y; - var r = this.r * min; + componentModel.setRoamPan + && componentModel.setRoamPan(res.x, res.y); - var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r); + componentModel.setRoamZoom + && componentModel.setRoamZoom(res.zoom); - var colorStops = this.colorStops; - for (var i = 0; i < colorStops.length; i++) { - canvasGradient.addColorStop( - colorStops[i].offset, colorStops[i].color - ); - } + geo && geo.setPan(res.x, res.y); + geo && geo.setZoom(res.zoom); - this.canvasGradient = canvasGradient; - } - }; + // All map series with same `map` use the same geo coordinate system + // So the roamDetail must be in sync. Include the series not selected by legend + if (componentType === 'series') { + zrUtil.each(componentModel.seriesGroup, function (seriesModel) { + seriesModel.setRoamPan(res.x, res.y); + seriesModel.setRoamZoom(res.zoom); + }); + } + } + }); + }); - zrUtil.inherits(RadialGradient, Gradient); - return RadialGradient; -}); -define('echarts/util/graphic',['require','zrender/core/util','zrender/tool/path','zrender/graphic/Path','zrender/tool/color','zrender/core/matrix','zrender/core/vector','zrender/graphic/Gradient','zrender/container/Group','zrender/graphic/Image','zrender/graphic/Text','zrender/graphic/shape/Circle','zrender/graphic/shape/Sector','zrender/graphic/shape/Polygon','zrender/graphic/shape/Polyline','zrender/graphic/shape/Rect','zrender/graphic/shape/Line','zrender/graphic/shape/BezierCurve','zrender/graphic/shape/Arc','zrender/graphic/LinearGradient','zrender/graphic/RadialGradient','zrender/core/BoundingRect'],function(require) { +/***/ }, +/* 162 */ +/***/ function(module, exports) { - + - var zrUtil = require('zrender/core/util'); + var roamHelper = {}; - var pathTool = require('zrender/tool/path'); - var round = Math.round; - var Path = require('zrender/graphic/Path'); - var colorTool = require('zrender/tool/color'); - var matrix = require('zrender/core/matrix'); - var vector = require('zrender/core/vector'); - var Gradient = require('zrender/graphic/Gradient'); + /** + * Calculate pan and zoom which from roamDetail model + * @param {module:echarts/model/Model} roamDetailModel + * @param {Object} payload + */ + roamHelper.calcPanAndZoom = function (roamDetailModel, payload) { + var dx = payload.dx; + var dy = payload.dy; + var zoom = payload.zoom; + + var panX = roamDetailModel.get('x') || 0; + var panY = roamDetailModel.get('y') || 0; + + var previousZoom = roamDetailModel.get('zoom') || 1; + + if (dx != null && dy != null) { + panX += dx; + panY += dy; + } + if (zoom != null) { + var fixX = (payload.originX - panX) * (zoom - 1); + var fixY = (payload.originY - panY) * (zoom - 1); + + panX -= fixX; + panY -= fixY; + } + + return { + x: panX, + y: panY, + zoom: (zoom || 1) * previousZoom + }; + }; + + module.exports = roamHelper; + + +/***/ }, +/* 163 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(164); + + var Geo = __webpack_require__(165); + + var layout = __webpack_require__(21); + var zrUtil = __webpack_require__(3); + + var mapDataStores = {}; + + /** + * Resize method bound to the geo + * @param {module:echarts/coord/geo/GeoModel|module:echarts/chart/map/MapModel} geoModel + * @param {module:echarts/ExtensionAPI} api + */ + function resizeGeo (geoModel, api) { + var rect = this.getBoundingRect(); + + var boxLayoutOption = geoModel.getBoxLayoutParams(); + // 0.75 rate + boxLayoutOption.aspect = rect.width / rect.height * 0.75; + + var viewRect = layout.getLayoutRect(boxLayoutOption, { + width: api.getWidth(), + height: api.getHeight() + }); + + this.setViewRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height); + + var roamDetailModel = geoModel.getModel('roamDetail'); + + var panX = roamDetailModel.get('x') || 0; + var panY = roamDetailModel.get('y') || 0; + var zoom = roamDetailModel.get('zoom') || 1; + + this.setPan(panX, panY); + this.setZoom(zoom); + } + + /** + * @param {module:echarts/coord/Geo} geo + * @param {module:echarts/model/Model} model + * @inner + */ + function setGeoCoords(geo, model) { + zrUtil.each(model.get('geoCoord'), function (geoCoord, name) { + geo.addGeoCoord(name, geoCoord); + }); + } + + function mapNotExistsError(name) { + console.error('Map ' + name + ' not exists'); + } + + var geoCreator = { + + // For deciding which dimensions to use when creating list data + dimensions: Geo.prototype.dimensions, + + create: function (ecModel, api) { + var geoList = []; + + // FIXME Create each time may be slow + ecModel.eachComponent('geo', function (geoModel, idx) { + var name = geoModel.get('map'); + var mapData = mapDataStores[name]; + if (!mapData) { + mapNotExistsError(name); + } + var geo = new Geo( + name + idx, name, + mapData && mapData.geoJson, mapData && mapData.specialAreas, + geoModel.get('nameMap') + ); + geoList.push(geo); + + setGeoCoords(geo, geoModel); + + geoModel.coordinateSystem = geo; + geo.model = geoModel; + + // Inject resize method + geo.resize = resizeGeo; + + geo.resize(geoModel, api); + }); + + ecModel.eachSeries(function (seriesModel) { + var coordSys = seriesModel.get('coordinateSystem'); + if (coordSys === 'geo') { + var geoIndex = seriesModel.get('geoIndex') || 0; + seriesModel.coordinateSystem = geoList[geoIndex]; + } + }); + + // If has map series + var mapModelGroupBySeries = {}; + + ecModel.eachSeriesByType('map', function (seriesModel) { + var mapType = seriesModel.get('map'); + + mapModelGroupBySeries[mapType] = mapModelGroupBySeries[mapType] || []; + + mapModelGroupBySeries[mapType].push(seriesModel); + }); + + zrUtil.each(mapModelGroupBySeries, function (mapSeries, mapType) { + var mapData = mapDataStores[mapType]; + if (!mapData) { + mapNotExistsError(name); + } + + var nameMapList = zrUtil.map(mapSeries, function (singleMapSeries) { + return singleMapSeries.get('nameMap'); + }); + var geo = new Geo( + mapType, mapType, + mapData && mapData.geoJson, mapData && mapData.specialAreas, + zrUtil.mergeAll(nameMapList) + ); + geoList.push(geo); + + // Inject resize method + geo.resize = resizeGeo; + + geo.resize(mapSeries[0], api); + + zrUtil.each(mapSeries, function (singleMapSeries) { + singleMapSeries.coordinateSystem = geo; + + setGeoCoords(geo, singleMapSeries); + }); + }); + + return geoList; + }, + + /** + * @param {string} mapName + * @param {Object|string} geoJson + * @param {Object} [specialAreas] + * + * @example + * $.get('USA.json', function (geoJson) { + * echarts.registerMap('USA', geoJson); + * // Or + * echarts.registerMap('USA', { + * geoJson: geoJson, + * specialAreas: {} + * }) + * }); + */ + registerMap: function (mapName, geoJson, specialAreas) { + if (geoJson.geoJson && !geoJson.features) { + specialAreas = geoJson.specialAreas; + geoJson = geoJson.geoJson; + } + if (typeof geoJson === 'string') { + geoJson = (typeof JSON !== 'undefined' && JSON.parse) + ? JSON.parse(geoJson) : (new Function('return (' + geoJson + ');'))(); + } + mapDataStores[mapName] = { + geoJson: geoJson, + specialAreas: specialAreas + }; + }, + + /** + * @param {string} mapName + * @return {Object} + */ + getMap: function (mapName) { + return mapDataStores[mapName]; + } + }; + + // Inject methods into echarts + var echarts = __webpack_require__(1); + + echarts.registerMap = geoCreator.registerMap; + + echarts.getMap = geoCreator.getMap; + + // TODO + echarts.loadMap = function () {}; + + echarts.registerCoordinateSystem('geo', geoCreator); + + +/***/ }, +/* 164 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var modelUtil = __webpack_require__(5); + var ComponentModel = __webpack_require__(19); + + ComponentModel.extend({ + + type: 'geo', + + /** + * @type {module:echarts/coord/geo/Geo} + */ + coordinateSystem: null, + + init: function (option) { + ComponentModel.prototype.init.apply(this, arguments); + + // Default label emphasis `position` and `show` + modelUtil.defaultEmphasis( + option.label, ['position', 'show', 'textStyle', 'distance', 'formatter'] + ); + }, + + defaultOption: { + + zlevel: 0, + + z: 0, + + show: true, + + left: 'center', + + top: 'center', + + // 自适应 + // width:, + // height:, + // right + // bottom + + // Map type + map: '', + + // 在 roam 开启的时候使用 + roamDetail: { + x: 0, + y: 0, + zoom: 1 + }, + + label: { + normal: { + show: false, + textStyle: { + color: '#000' + } + }, + emphasis: { + show: true, + textStyle: { + color: 'rgb(100,0,0)' + } + } + }, + + itemStyle: { + normal: { + // color: 各异, + borderWidth: 0.5, + borderColor: '#444', + color: '#eee' + }, + emphasis: { // 也是选中样式 + color: 'rgba(255,215,0,0.8)' + } + } + }, + + /** + * Format label + * @param {string} name Region name + * @param {string} [status='normal'] 'normal' or 'emphasis' + * @return {string} + */ + getFormattedLabel: function (name, status) { + var formatter = this.get('label.' + status + '.formatter'); + var params = { + name: name + }; + if (typeof formatter === 'function') { + params.status = status; + return formatter(params); + } + else if (typeof formatter === 'string') { + return formatter.replace('{a}', params.seriesName); + } + }, + + setRoamZoom: function (zoom) { + var roamDetail = this.option.roamDetail; + roamDetail && (roamDetail.zoom = zoom); + }, + + setRoamPan: function (x, y) { + var roamDetail = this.option.roamDetail; + if (roamDetail) { + roamDetail.x = x; + roamDetail.y = y; + } + } + }); + + +/***/ }, +/* 165 */ +/***/ function(module, exports, __webpack_require__) { + + + + var parseGeoJson = __webpack_require__(166); + + var zrUtil = __webpack_require__(3); + + var BoundingRect = __webpack_require__(15); + + var View = __webpack_require__(169); + + + // Geo fix functions + var geoFixFuncs = [ + __webpack_require__(170), + __webpack_require__(171), + __webpack_require__(172) + ]; + + /** + * [Geo description] + * @param {string} name Geo name + * @param {string} map Map type + * @param {Object} geoJson + * @param {Object} [specialAreas] + * Specify the positioned areas by left, top, width, height + * @param {Object.} [nameMap] + * Specify name alias + */ + function Geo(name, map, geoJson, specialAreas, nameMap) { + + View.call(this, name); + + /** + * Map type + * @type {string} + */ + this.map = map; + + this._nameCoordMap = {}; + + this.loadGeoJson(geoJson, specialAreas, nameMap); + } + + Geo.prototype = { + + constructor: Geo, + + type: 'geo', + + /** + * @param {Array.} + * @readOnly + */ + dimensions: ['lng', 'lat'], + + /** + * @param {Object} geoJson + * @param {Object} [specialAreas] + * Specify the positioned areas by left, top, width, height + * @param {Object.} [nameMap] + * Specify name alias + */ + loadGeoJson: function (geoJson, specialAreas, nameMap) { + // https://jsperf.com/try-catch-performance-overhead + try { + this.regions = geoJson ? parseGeoJson(geoJson) : []; + } + catch (e) { + throw 'Invalid geoJson format\n' + e; + } + specialAreas = specialAreas || {}; + nameMap = nameMap || {}; + var regions = this.regions; + var regionsMap = {}; + for (var i = 0; i < regions.length; i++) { + var regionName = regions[i].name; + // Try use the alias in nameMap + regionName = nameMap[regionName] || regionName; + regions[i].name = regionName; + + regionsMap[regionName] = regions[i]; + // Add geoJson + this.addGeoCoord(regionName, regions[i].center); + + // Some area like Alaska in USA map needs to be tansformed + // to look better + var specialArea = specialAreas[regionName]; + if (specialArea) { + regions[i].transformTo( + specialArea.left, specialArea.top, specialArea.width, specialArea.height + ); + } + } + + this._regionsMap = regionsMap; + + this._rect = null; + + zrUtil.each(geoFixFuncs, function (fixFunc) { + fixFunc(this); + }, this); + }, + + // Overwrite + transformTo: function (x, y, width, height) { + var rect = this.getBoundingRect(); + + rect = rect.clone(); + // Longitute is inverted + rect.y = -rect.y - rect.height; + + var viewTransform = this._viewTransform; + + viewTransform.transform = rect.calculateTransform( + new BoundingRect(x, y, width, height) + ); + + viewTransform.decomposeTransform(); + + var scale = viewTransform.scale; + scale[1] = -scale[1]; + + viewTransform.updateTransform(); + + this._updateTransform(); + }, + + /** + * @param {string} name + * @return {module:echarts/coord/geo/Region} + */ + getRegion: function (name) { + return this._regionsMap[name]; + }, + + /** + * Add geoCoord for indexing by name + * @param {string} name + * @param {Array.} geoCoord + */ + addGeoCoord: function (name, geoCoord) { + this._nameCoordMap[name] = geoCoord; + }, + + /** + * Get geoCoord by name + * @param {string} name + * @return {Array.} + */ + getGeoCoord: function (name) { + return this._nameCoordMap[name]; + }, + + // Overwrite + getBoundingRect: function () { + if (this._rect) { + return this._rect; + } + var rect; + + var regions = this.regions; + for (var i = 0; i < regions.length; i++) { + var regionRect = regions[i].getBoundingRect(); + rect = rect || regionRect.clone(); + rect.union(regionRect); + } + // FIXME Always return new ? + return (this._rect = rect || new BoundingRect(0, 0, 0, 0)); + }, + + /** + * Convert series data to a list of points + * @param {module:echarts/data/List} data + * @param {boolean} stack + * @return {Array} + * Return list of points. For example: + * `[[10, 10], [20, 20], [30, 30]]` + */ + dataToPoints: function (data) { + var item = []; + return data.mapArray(['lng', 'lat'], function (lon, lat) { + item[0] = lon; + item[1] = lat; + return this.dataToPoint(item); + }, this); + }, + + // Overwrite + /** + * @param {string|Array.} data + * @return {Array.} + */ + dataToPoint: function (data) { + if (typeof data === 'string') { + // Map area name to geoCoord + data = this.getGeoCoord(data); + } + if (data) { + return View.prototype.dataToPoint.call(this, data); + } + } + }; + + zrUtil.mixin(Geo, View); + + module.exports = Geo; + + +/***/ }, +/* 166 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Parse and decode geo json + * @module echarts/coord/geo/parseGeoJson + */ + + + var zrUtil = __webpack_require__(3); + + var Region = __webpack_require__(167); + + function decode(json) { + if (!json.UTF8Encoding) { + return json; + } + var features = json.features; + + for (var f = 0; f < features.length; f++) { + var feature = features[f]; + var geometry = feature.geometry; + var coordinates = geometry.coordinates; + var encodeOffsets = geometry.encodeOffsets; + + for (var c = 0; c < coordinates.length; c++) { + var coordinate = coordinates[c]; + + if (geometry.type === 'Polygon') { + coordinates[c] = decodePolygon( + coordinate, + encodeOffsets[c] + ); + } + else if (geometry.type === 'MultiPolygon') { + for (var c2 = 0; c2 < coordinate.length; c2++) { + var polygon = coordinate[c2]; + coordinate[c2] = decodePolygon( + polygon, + encodeOffsets[c][c2] + ); + } + } + } + } + // Has been decoded + json.UTF8Encoding = false; + return json; + } + + function decodePolygon(coordinate, encodeOffsets) { + var result = []; + var prevX = encodeOffsets[0]; + var prevY = encodeOffsets[1]; + + for (var i = 0; i < coordinate.length; i += 2) { + var x = coordinate.charCodeAt(i) - 64; + var y = coordinate.charCodeAt(i + 1) - 64; + // ZigZag decoding + x = (x >> 1) ^ (-(x & 1)); + y = (y >> 1) ^ (-(y & 1)); + // Delta deocding + x += prevX; + y += prevY; + + prevX = x; + prevY = y; + // Dequantize + result.push([x / 1024, y / 1024]); + } + + return result; + } + + /** + * @inner + */ + function flattern2D(array) { + var ret = []; + for (var i = 0; i < array.length; i++) { + for (var k = 0; k < array[i].length; k++) { + ret.push(array[i][k]); + } + } + return ret; + } + + /** + * @alias module:echarts/coord/geo/parseGeoJson + * @param {Object} geoJson + * @return {module:zrender/container/Group} + */ + module.exports = function (geoJson) { + + decode(geoJson); + + return zrUtil.map(zrUtil.filter(geoJson.features, function (featureObj) { + // Output of mapshaper may have geometry null + return featureObj.geometry && featureObj.properties; + }), function (featureObj) { + var properties = featureObj.properties; + var geometry = featureObj.geometry; + + var coordinates = geometry.coordinates; + + if (geometry.type === 'MultiPolygon') { + coordinates = flattern2D(coordinates); + } + + return new Region( + properties.name, + coordinates, + properties.cp + ); + }); + }; + + +/***/ }, +/* 167 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/coord/geo/Region + */ + + + var polygonContain = __webpack_require__(168); + + var BoundingRect = __webpack_require__(15); + + var bbox = __webpack_require__(50); + var vec2 = __webpack_require__(16); + + /** + * @param {string} name + * @param {Array} contours + * @param {Array.} cp + */ + function Region(name, contours, cp) { + + /** + * @type {string} + * @readOnly + */ + this.name = name; + + /** + * @type {Array.} + * @readOnly + */ + this.contours = contours; + + if (!cp) { + var rect = this.getBoundingRect(); + cp = [ + rect.x + rect.width / 2, + rect.y + rect.height / 2 + ]; + } + else { + cp = [cp[0], cp[1]]; + } + /** + * @type {Array.} + */ + this.center = cp; + } + + Region.prototype = { + + constructor: Region, + + /** + * @return {module:zrender/core/BoundingRect} + */ + getBoundingRect: function () { + var rect = this._rect; + if (rect) { + return rect; + } + + var MAX_NUMBER = Number.MAX_VALUE; + var min = [MAX_NUMBER, MAX_NUMBER]; + var max = [-MAX_NUMBER, -MAX_NUMBER]; + var min2 = []; + var max2 = []; + var contours = this.contours; + for (var i = 0; i < contours.length; i++) { + bbox.fromPoints(contours[i], min2, max2); + vec2.min(min, min, min2); + vec2.max(max, max, max2); + } + // No data + if (i === 0) { + min[0] = min[1] = max[0] = max[1] = 0; + } + + return (this._rect = new BoundingRect( + min[0], min[1], max[0] - min[0], max[1] - min[1] + )); + }, + + /** + * @param {} coord + * @return {boolean} + */ + contain: function (coord) { + var rect = this.getBoundingRect(); + var contours = this.contours; + if (rect.contain(coord[0], coord[1])) { + for (var i = 0, len = contours.length; i < len; i++) { + if (polygonContain.contain(contours[i], coord[0], coord[1])) { + return true; + } + } + } + return false; + }, + + transformTo: function (x, y, width, height) { + var rect = this.getBoundingRect(); + var aspect = rect.width / rect.height; + if (!width) { + width = aspect * height; + } + else if (!height) { + height = width / aspect ; + } + var target = new BoundingRect(x, y, width, height); + var transform = rect.calculateTransform(target); + var contours = this.contours; + for (var i = 0; i < contours.length; i++) { + for (var p = 0; p < contours[i].length; p++) { + vec2.applyTransform(contours[i][p], contours[i][p], transform); + } + } + rect = this._rect; + rect.copy(target); + // Update center + this.center = [ + rect.x + rect.width / 2, + rect.y + rect.height / 2 + ]; + } + }; + + module.exports = Region; + + +/***/ }, +/* 168 */ +/***/ function(module, exports, __webpack_require__) { + + + + var windingLine = __webpack_require__(57); + + var EPSILON = 1e-8; + + function isAroundEqual(a, b) { + return Math.abs(a - b) < EPSILON; + } + + function contain(points, x, y) { + var w = 0; + var p = points[0]; + + if (!p) { + return false; + } + + for (var i = 1; i < points.length; i++) { + var p2 = points[i]; + w += windingLine(p[0], p[1], p2[0], p2[1], x, y); + p = p2; + } + + // Close polygon + var p0 = points[0]; + if (!isAroundEqual(p[0], p0[0]) || !isAroundEqual(p[1], p0[1])) { + w += windingLine(p[0], p[1], p0[0], p0[1], x, y); + } + + return w !== 0; + } + + + module.exports = { + contain: contain + }; + + +/***/ }, +/* 169 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Simple view coordinate system + * Mapping given x, y to transformd view x, y + */ + + + var vector = __webpack_require__(16); + var matrix = __webpack_require__(17); + + var Transformable = __webpack_require__(33); + var zrUtil = __webpack_require__(3); + + var BoundingRect = __webpack_require__(15); + + var v2ApplyTransform = vector.applyTransform; + + // Dummy transform node + function TransformDummy() { + Transformable.call(this); + } + zrUtil.mixin(TransformDummy, Transformable); + + function View(name) { + /** + * @type {string} + */ + this.name = name; + + Transformable.call(this); + + this._roamTransform = new TransformDummy(); + + this._viewTransform = new TransformDummy(); + } + + View.prototype = { + + constructor: View, + + type: 'view', + + /** + * @param {Array.} + * @readOnly + */ + dimensions: ['x', 'y'], - var graphic = {}; + /** + * Set bounding rect + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + */ + + // PENDING to getRect + setBoundingRect: function (x, y, width, height) { + this._rect = new BoundingRect(x, y, width, height); + return this._rect; + }, + + /** + * @return {module:zrender/core/BoundingRect} + */ + // PENDING to getRect + getBoundingRect: function () { + return this._rect; + }, + + /** + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + */ + setViewRect: function (x, y, width, height) { + this.transformTo(x, y, width, height); + this._viewRect = new BoundingRect(x, y, width, height); + }, + + /** + * Transformed to particular position and size + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + */ + transformTo: function (x, y, width, height) { + var rect = this.getBoundingRect(); + var viewTransform = this._viewTransform; + + viewTransform.transform = rect.calculateTransform( + new BoundingRect(x, y, width, height) + ); + + viewTransform.decomposeTransform(); + + this._updateTransform(); + }, + + /** + * @param {number} x + * @param {number} y + */ + setPan: function (x, y) { + + this._roamTransform.position = [x, y]; + + this._updateTransform(); + }, + + /** + * @param {number} zoom + */ + setZoom: function (zoom) { + this._roamTransform.scale = [zoom, zoom]; + + this._updateTransform(); + }, + + /** + * @return {Array.} data + * @return {Array.} + */ + dataToPoint: function (data) { + var transform = this.transform; + return transform + ? v2ApplyTransform([], data, transform) + : [data[0], data[1]]; + }, + + /** + * Convert a (x, y) point to (lon, lat) data + * @param {Array.} point + * @return {Array.} + */ + pointToData: function (point) { + var invTransform = this.invTransform; + return invTransform + ? v2ApplyTransform([], point, invTransform) + : [point[0], point[1]]; + } + + /** + * @return {number} + */ + // getScalarScale: function () { + // // Use determinant square root of transform to mutiply scalar + // var m = this.transform; + // var det = Math.sqrt(Math.abs(m[0] * m[3] - m[2] * m[1])); + // return det; + // } + }; + + zrUtil.mixin(View, Transformable); + + module.exports = View; + + +/***/ }, +/* 170 */ +/***/ function(module, exports, __webpack_require__) { + + // Fix for 南海诸岛 + + + var Region = __webpack_require__(167); + + var geoCoord = [126, 25]; + + var points = [ + [[0,3.5],[7,11.2],[15,11.9],[30,7],[42,0.7],[52,0.7], + [56,7.7],[59,0.7],[64,0.7],[64,0],[5,0],[0,3.5]], + [[13,16.1],[19,14.7],[16,21.7],[11,23.1],[13,16.1]], + [[12,32.2],[14,38.5],[15,38.5],[13,32.2],[12,32.2]], + [[16,47.6],[12,53.2],[13,53.2],[18,47.6],[16,47.6]], + [[6,64.4],[8,70],[9,70],[8,64.4],[6,64.4]], + [[23,82.6],[29,79.8],[30,79.8],[25,82.6],[23,82.6]], + [[37,70.7],[43,62.3],[44,62.3],[39,70.7],[37,70.7]], + [[48,51.1],[51,45.5],[53,45.5],[50,51.1],[48,51.1]], + [[51,35],[51,28.7],[53,28.7],[53,35],[51,35]], + [[52,22.4],[55,17.5],[56,17.5],[53,22.4],[52,22.4]], + [[58,12.6],[62,7],[63,7],[60,12.6],[58,12.6]], + [[0,3.5],[0,93.1],[64,93.1],[64,0],[63,0],[63,92.4], + [1,92.4],[1,3.5],[0,3.5]] + ]; + for (var i = 0; i < points.length; i++) { + for (var k = 0; k < points[i].length; k++) { + points[i][k][0] /= 10.5; + points[i][k][1] /= -10.5 / 0.75; + + points[i][k][0] += geoCoord[0]; + points[i][k][1] += geoCoord[1]; + } + } + module.exports = function (geo) { + if (geo.map === 'china') { + geo.regions.push(new Region( + '南海诸岛', points, geoCoord + )); + } + }; + + +/***/ }, +/* 171 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + var coordsOffsetMap = { + '南海诸岛' : [32, 80], + // 全国 + '广东': [0, -10], + '香港': [10, 5], + '澳门': [-10, 10], + //'北京': [-10, 0], + '天津': [5, 5] + }; + + module.exports = function (geo) { + zrUtil.each(geo.regions, function (region) { + var coordFix = coordsOffsetMap[region.name]; + if (coordFix) { + var cp = region.center; + cp[0] += coordFix[0] / 10.5; + cp[1] += -coordFix[1] / (10.5 / 0.75); + } + }); + }; + + +/***/ }, +/* 172 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + var geoCoordMap = { + 'Russia': [100, 60], + 'United States of America': [-99, 38] + }; + + module.exports = function (geo) { + zrUtil.each(geo.regions, function (region) { + var geoCoord = geoCoordMap[region.name]; + if (geoCoord) { + var cp = region.center; + cp[0] = geoCoord[0]; + cp[1] = geoCoord[1]; + } + }); + }; + + +/***/ }, +/* 173 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + module.exports = function (ecModel) { + + var processedMapType = {}; + + ecModel.eachSeriesByType('map', function (mapSeries) { + var mapType = mapSeries.get('mapType'); + if (processedMapType[mapType]) { + return; + } + + var mapSymbolOffsets = {}; + + zrUtil.each(mapSeries.seriesGroup, function (subMapSeries) { + var geo = subMapSeries.coordinateSystem; + var data = subMapSeries.getData(); + if (subMapSeries.get('showLegendSymbol') && ecModel.getComponent('legend')) { + data.each('value', function (value, idx) { + var name = data.getName(idx); + var region = geo.getRegion(name); + + // No region or no value + // In MapSeries data regions will be filled with NaN + // If they are not in the series.data array. + // So here must validate if value is NaN + if (!region || isNaN(value)) { + return; + } + + var offset = mapSymbolOffsets[name] || 0; + + var point = geo.dataToPoint(region.center); + + mapSymbolOffsets[name] = offset + 1; + + data.setItemLayout(idx, { + point: point, + offset: offset + }); + }); + } + }); + + // Show label of those region not has legendSymbol(which is offset 0) + var data = mapSeries.getData(); + data.each(function (idx) { + var name = data.getName(idx); + var layout = data.getItemLayout(idx) || {}; + layout.showLabel = !mapSymbolOffsets[name]; + data.setItemLayout(idx, layout); + }); + + processedMapType[mapType] = true; + }); + }; + + +/***/ }, +/* 174 */ +/***/ function(module, exports) { + + + module.exports = function (ecModel) { + ecModel.eachSeriesByType('map', function (seriesModel) { + var colorList = seriesModel.get('color'); + var itemStyleModel = seriesModel.getModel('itemStyle.normal'); + + var areaColor = itemStyleModel.get('areaColor'); + var color = itemStyleModel.get('color') + || colorList[seriesModel.seriesIndex % colorList.length]; + + seriesModel.getData().setVisual({ + 'areaColor': areaColor, + 'color': color + }); + }); + }; + + +/***/ }, +/* 175 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + // FIXME 公用? + /** + * @param {Array.} datas + * @param {string} statisticsType 'average' 'sum' + * @inner + */ + function dataStatistics(datas, statisticsType) { + var dataNameMap = {}; + var dims = ['value']; + + for (var i = 0; i < datas.length; i++) { + datas[i].each(dims, function (value, idx) { + var name = datas[i].getName(idx); + dataNameMap[name] = dataNameMap[name] || []; + if (!isNaN(value)) { + dataNameMap[name].push(value); + } + }); + } + + return datas[0].map(dims, function (value, idx) { + var name = datas[0].getName(idx); + var sum = 0; + var min = Infinity; + var max = -Infinity; + var len = dataNameMap[name].length; + for (var i = 0; i < len; i++) { + min = Math.min(min, dataNameMap[name][i]); + max = Math.max(max, dataNameMap[name][i]); + sum += dataNameMap[name][i]; + } + var result; + if (statisticsType === 'min') { + result = min; + } + else if (statisticsType === 'max') { + result = max; + } + else if (statisticsType === 'average') { + result = sum / len; + } + else { + result = sum; + } + return len === 0 ? NaN : result; + }); + } + + module.exports = function (ecModel) { + var seriesGroupByMapType = {}; + ecModel.eachSeriesByType('map', function (seriesModel) { + var mapType = seriesModel.get('map'); + seriesGroupByMapType[mapType] = seriesGroupByMapType[mapType] || []; + seriesGroupByMapType[mapType].push(seriesModel); + }); + + zrUtil.each(seriesGroupByMapType, function (seriesList, mapType) { + var data = dataStatistics( + zrUtil.map(seriesList, function (seriesModel) { + return seriesModel.getData(); + }), + seriesList[0].get('mapValueCalculation') + ); + + seriesList[0].seriesGroup = []; + + seriesList[0].setData(data); + + // FIXME Put where? + for (var i = 0; i < seriesList.length; i++) { + seriesList[i].seriesGroup = seriesList; + seriesList[i].needsDrawMap = i === 0; + } + }); + }; + + +/***/ }, +/* 176 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var geoProps = [ + 'x', 'y', 'x2', 'y2', 'width', 'height', 'map', 'roam', 'roamDetail', 'label', 'itemStyle' + ]; + + var geoCoordsMap = {}; + + function createGeoFromMap(mapSeriesOpt) { + var geoOpt = {}; + zrUtil.each(geoProps, function (propName) { + if (mapSeriesOpt[propName] != null) { + geoOpt[propName] = mapSeriesOpt[propName]; + } + }); + return geoOpt; + } + module.exports = function (option) { + // Save geoCoord + var mapSeries = []; + zrUtil.each(option.series, function (seriesOpt) { + if (seriesOpt.type === 'map') { + mapSeries.push(seriesOpt); + } + zrUtil.extend(geoCoordsMap, seriesOpt.geoCoord); + }); + + var newCreatedGeoOptMap = {}; + zrUtil.each(mapSeries, function (seriesOpt) { + seriesOpt.map = seriesOpt.map || seriesOpt.mapType; + // Put x, y, width, height, x2, y2 in the top level + zrUtil.defaults(seriesOpt, seriesOpt.mapLocation); + if (seriesOpt.markPoint) { + var markPoint = seriesOpt.markPoint; + // Convert name or geoCoord in markPoint to lng and lat + // For example + // { name: 'xxx', value: 10} Or + // { geoCoord: [lng, lat], value: 10} to + // { name: 'xxx', value: [lng, lat, 10]} + markPoint.data = zrUtil.map(markPoint.data, function (dataOpt) { + if (!zrUtil.isArray(dataOpt.value)) { + var geoCoord; + if (dataOpt.geoCoord) { + geoCoord = dataOpt.geoCoord; + } + else if (dataOpt.name) { + geoCoord = geoCoordsMap[dataOpt.name]; + } + var newValue = geoCoord ? [geoCoord[0], geoCoord[1]] : [NaN, NaN]; + if (dataOpt.value != null) { + newValue.push(dataOpt.value); + } + dataOpt.value = newValue; + } + return dataOpt; + }); + // Convert map series which only has markPoint without data to scatter series + // FIXME + if (!(seriesOpt.data && seriesOpt.data.length)) { + if (!option.geo) { + option.geo = []; + } + + // Use same geo if multiple map series has same map type + var geoOpt = newCreatedGeoOptMap[seriesOpt.map]; + if (!geoOpt) { + geoOpt = newCreatedGeoOptMap[seriesOpt.map] = createGeoFromMap(seriesOpt); + option.geo.push(geoOpt); + } + + var scatterSeries = seriesOpt.markPoint; + scatterSeries.type = option.effect && option.effect.show ? 'effectScatter' : 'scatter'; + scatterSeries.coordinateSystem = 'geo'; + scatterSeries.geoIndex = zrUtil.indexOf(option.geo, geoOpt); + scatterSeries.name = seriesOpt.name; + + option.series.splice(zrUtil.indexOf(option.series, seriesOpt), 1, scatterSeries); + } + } + }); + }; + + +/***/ }, +/* 177 */ +/***/ function(module, exports, __webpack_require__) { + + + + var echarts = __webpack_require__(1); + + __webpack_require__(178); + __webpack_require__(181); + __webpack_require__(185); + + echarts.registerVisualCoding('chart', __webpack_require__(186)); + + echarts.registerLayout(__webpack_require__(188)); + + +/***/ }, +/* 178 */ +/***/ function(module, exports, __webpack_require__) { + + + + var SeriesModel = __webpack_require__(27); + var Tree = __webpack_require__(179); + var zrUtil = __webpack_require__(3); + var Model = __webpack_require__(8); + var formatUtil = __webpack_require__(6); + var encodeHTML = formatUtil.encodeHTML; + var addCommas = formatUtil.addCommas; + + + module.exports = SeriesModel.extend({ + + type: 'series.treemap', + + dependencies: ['grid', 'polar'], + + defaultOption: { + // center: ['50%', '50%'], // not supported in ec3. + // size: ['80%', '80%'], // deprecated, compatible with ec2. + left: 'center', + top: 'middle', + right: null, + bottom: null, + width: '80%', + height: '80%', + sort: true, // Can be null or false or true + // (order by desc default, asc not supported yet (strange effect)) + clipWindow: 'origin', // 缩放时窗口大小。'origin' or 'fullscreen' + squareRatio: 0.5 * (1 + Math.sqrt(5)), // golden ratio + root: null, // default: tree root. This feature doesnt work unless node have id. + visualDimension: 0, // Can be 0, 1, 2, 3. + zoomToNodeRatio: 0.32 * 0.32, // zoom to node时 node占可视区域的面积比例。 + roam: true, // true, false, 'scale' or 'zoom', 'move' + nodeClick: 'zoomToNode', // 'zoomToNode', 'link', false + animation: true, + animationDurationUpdate: 1500, + animationEasing: 'quinticInOut', + breadcrumb: { + show: true, + height: 22, + left: 'center', + top: 'bottom', + // right + // bottom + emptyItemWidth: 25, // 空节点宽度 + itemStyle: { + normal: { + color: 'rgba(0,0,0,0.7)', //'#5793f3', + borderColor: 'rgba(255,255,255,0.7)', + borderWidth: 1, + shadowColor: 'rgba(150,150,150,1)', + shadowBlur: 3, + shadowOffsetX: 0, + shadowOffsetY: 0, + textStyle: { + color: '#fff' + } + }, + emphasis: { + textStyle: {} + } + } + }, + label: { + normal: { + show: true, + position: ['50%', '50%'], // 可以是 5 '5%' 'insideTopLeft', ... + textStyle: { + align: 'center', + baseline: 'middle', + color: '#fff', + ellipsis: true + } + } + }, + itemStyle: { + normal: { + color: null, // 各异 如不需,可设为'none' + colorAlpha: null, // 默认不设置 如不需,可设为'none' + colorSaturation: null, // 默认不设置 如不需,可设为'none' + borderWidth: 0, + gapWidth: 0, + borderColor: '#fff', + borderColorSaturation: null // 如果设置,则borderColor的设置无效,而是取当前节点计算出的颜色,再经由borderColorSaturation处理。 + }, + emphasis: {} + }, + color: 'none', // 为数组,表示同一level的color 选取列表。默认空,在level[0].color中取系统color列表。 + colorAlpha: null, // 为数组,表示同一level的color alpha 选取范围。 + colorSaturation: null, // 为数组,表示同一level的color alpha 选取范围。 + colorMappingBy: 'index', // 'value' or 'index' or 'id'. + visibleMin: 10, // If area less than this threshold (unit: pixel^2), node will not be rendered. + // Only works when sort is 'asc' or 'desc'. + childrenVisibleMin: null, // If area of a node less than this threshold (unit: pixel^2), + // grandchildren will not show. + // Why grandchildren? If not grandchildren but children, + // some siblings show children and some not, + // the appearance may be mess and not consistent, + levels: [] // Each item: { + // visibleMin, itemStyle, visualDimension, label + // } + // data: { + // value: [], + // children: [], + // link: 'http://xxx.xxx.xxx', + // target: 'blank' or 'self' + // } + }, + + /** + * @override + */ + getInitialData: function (option, ecModel) { + var data = option.data || []; + var rootName = option.name; + rootName == null && (rootName = option.name); + + // Create a virtual root. + var root = {name: rootName, children: option.data}; + var value0 = (data[0] || {}).value; + + completeTreeValue(root, zrUtil.isArray(value0) ? value0.length : -1); + + // FIXME + // sereis.mergeOption 的 getInitData是否放在merge后,从而能直接获取merege后的结果而非手动判断。 + var levels = option.levels || []; + + levels = option.levels = setDefault(levels, ecModel); + + // Make sure always a new tree is created when setOption, + // in TreemapView, we check whether oldTree === newTree + // to choose mappings approach among old shapes and new shapes. + return Tree.createTree(root, this, levels).data; + }, + + /** + * @public + */ + getViewRoot: function () { + var optionRoot = this.option.root; + var treeRoot = this.getData().tree.root; + return optionRoot && treeRoot.getNodeById(optionRoot) || treeRoot; + }, + + /** + * @override + * @param {number} dataIndex + * @param {boolean} [mutipleSeries=false] + */ + formatTooltip: function (dataIndex) { + var data = this.getData(); + var value = this.getRawValue(dataIndex); + var formattedValue = zrUtil.isArray(value) + ? addCommas(value[0]) : addCommas(value); + var name = data.getName(dataIndex); + + return encodeHTML(name) + ': ' + formattedValue; + }, + + /** + * Add tree path to tooltip param + * + * @override + * @param {number} dataIndex + * @return {Object} + */ + getDataParams: function (dataIndex) { + var params = SeriesModel.prototype.getDataParams.apply(this, arguments); + + var data = this.getData(); + var node = data.tree.getNodeByDataIndex(dataIndex); + var treePathInfo = params.treePathInfo = []; + + while (node) { + var nodeDataIndex = node.dataIndex; + treePathInfo.push({ + name: node.name, + dataIndex: nodeDataIndex, + value: this.getRawValue(nodeDataIndex) + }); + node = node.parentNode; + } + + treePathInfo.reverse(); + + return params; + }, + + /** + * @public + * @param {Object} layoutInfo { + * x: containerGroup x + * y: containerGroup y + * width: containerGroup width + * height: containerGroup height + * } + */ + setLayoutInfo: function (layoutInfo) { + /** + * @readOnly + * @type {Object} + */ + this.layoutInfo = this.layoutInfo || {}; + zrUtil.extend(this.layoutInfo, layoutInfo); + }, + + /** + * @param {string} id + * @return {number} index + */ + mapIdToIndex: function (id) { + // A feature is implemented: + // index is monotone increasing with the sequence of + // input id at the first time. + // This feature can make sure that each data item and its + // mapped color have the same index between data list and + // color list at the beginning, which is useful for user + // to adjust data-color mapping. + + /** + * @private + * @type {Object} + */ + var idIndexMap = this._idIndexMap; + + if (!idIndexMap) { + idIndexMap = this._idIndexMap = {}; + /** + * @private + * @type {number} + */ + this._idIndexMapCount = 0; + } + + var index = idIndexMap[id]; + if (index == null) { + idIndexMap[id] = index = this._idIndexMapCount++; + } + + return index; + } + }); + + /** + * @param {Object} dataNode + */ + function completeTreeValue(dataNode, arrValueLength) { + // Postorder travel tree. + // If value of none-leaf node is not set, + // calculate it by suming up the value of all children. + var sum = 0; + + zrUtil.each(dataNode.children, function (child) { + + completeTreeValue(child, arrValueLength); + + var childValue = child.value; + zrUtil.isArray(childValue) && (childValue = childValue[0]); + + sum += childValue; + }); + + var thisValue = dataNode.value; + + if (arrValueLength >= 0) { + if (!zrUtil.isArray(thisValue)) { + dataNode.value = new Array(arrValueLength); + } + else { + thisValue = thisValue[0]; + } + } + + if (thisValue == null || isNaN(thisValue)) { + thisValue = sum; + } + // Value should not less than 0. + if (thisValue < 0) { + thisValue = 0; + } + + arrValueLength >= 0 + ? (dataNode.value[0] = thisValue) + : (dataNode.value = thisValue); + } + + /** + * set default to level configuration + */ + function setDefault(levels, ecModel) { + var globalColorList = ecModel.get('color'); + + if (!globalColorList) { + return; + } + + levels = levels || []; + var hasColorDefine; + zrUtil.each(levels, function (levelDefine) { + var model = new Model(levelDefine); + var modelColor = model.get('color'); + if (model.get('itemStyle.normal.color') + || (modelColor && modelColor !== 'none') + ) { + hasColorDefine = true; + } + }); + + if (!hasColorDefine) { + var level0 = levels[0] || (levels[0] = {}); + level0.color = globalColorList.slice(); + } + + return levels; + } + + + +/***/ }, +/* 179 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Tree data structure + * + * @module echarts/data/Tree + */ + + + var zrUtil = __webpack_require__(3); + var Model = __webpack_require__(8); + var List = __webpack_require__(94); + var linkListHelper = __webpack_require__(180); + var completeDimensions = __webpack_require__(96); + + /** + * @constructor module:echarts/data/Tree~TreeNode + * @param {string} name + * @param {number} [dataIndex=-1] + * @param {module:echarts/data/Tree} hostTree + */ + var TreeNode = function (name, dataIndex, hostTree) { + /** + * @type {string} + */ + this.name = name || ''; + + /** + * Depth of node + * + * @type {number} + * @readOnly + */ + this.depth = 0; + + /** + * Height of the subtree rooted at this node. + * @type {number} + * @readOnly + */ + this.height = 0; + + /** + * @type {module:echarts/data/Tree~TreeNode} + * @readOnly + */ + this.parentNode = null; + + /** + * Reference to list item. + * Do not persistent dataIndex outside, + * besause it may be changed by list. + * If dataIndex -1, + * this node is logical deleted (filtered) in list. + * + * @type {Object} + * @readOnly + */ + this.dataIndex = dataIndex == null ? -1 : dataIndex; + + /** + * @type {Array.} + * @readOnly + */ + this.children = []; + + /** + * @type {Array.} + * @pubilc + */ + this.viewChildren = []; + + /** + * @type {moduel:echarts/data/Tree} + * @readOnly + */ + this.hostTree = hostTree; + }; + + TreeNode.prototype = { + + constructor: TreeNode, + + /** + * The node is removed. + * @return {boolean} is removed. + */ + isRemoved: function () { + return this.dataIndex < 0; + }, + + /** + * Travel this subtree (include this node). + * Usage: + * node.eachNode(function () { ... }); // preorder + * node.eachNode('preorder', function () { ... }); // preorder + * node.eachNode('postorder', function () { ... }); // postorder + * node.eachNode( + * {order: 'postorder', attr: 'viewChildren'}, + * function () { ... } + * ); // postorder + * + * @param {(Object|string)} options If string, means order. + * @param {string=} options.order 'preorder' or 'postorder' + * @param {string=} options.attr 'children' or 'viewChildren' + * @param {Function} cb If in preorder and return false, + * its subtree will not be visited. + * @param {Object} [context] + */ + eachNode: function (options, cb, context) { + if (typeof options === 'function') { + context = cb; + cb = options; + options = null; + } + + options = options || {}; + if (zrUtil.isString(options)) { + options = {order: options}; + } + + var order = options.order || 'preorder'; + var children = this[options.attr || 'children']; + + var suppressVisitSub; + order === 'preorder' && (suppressVisitSub = cb.call(context, this)); + + for (var i = 0; !suppressVisitSub && i < children.length; i++) { + children[i].eachNode(options, cb, context); + } + + order === 'postorder' && cb.call(context, this); + }, + + /** + * Update depth and height of this subtree. + * + * @param {number} depth + */ + updateDepthAndHeight: function (depth) { + var height = 0; + this.depth = depth; + for (var i = 0; i < this.children.length; i++) { + var child = this.children[i]; + child.updateDepthAndHeight(depth + 1); + if (child.height > height) { + height = child.height; + } + } + this.height = height + 1; + }, + + /** + * @param {string} id + * @return {module:echarts/data/Tree~TreeNode} + */ + getNodeById: function (id) { + if (this.getId() === id) { + return this; + } + for (var i = 0, children = this.children, len = children.length; i < len; i++) { + var res = children[i].getNodeById(id); + if (res) { + return res; + } + } + }, + + /** + * @param {module:echarts/data/Tree~TreeNode} node + * @return {boolean} + */ + contains: function (node) { + if (node === this) { + return true; + } + for (var i = 0, children = this.children, len = children.length; i < len; i++) { + var res = children[i].contains(node); + if (res) { + return res; + } + } + }, + + /** + * @param {boolean} includeSelf Default false. + * @return {Array.} order: [root, child, grandchild, ...] + */ + getAncestors: function (includeSelf) { + var ancestors = []; + var node = includeSelf ? this : this.parentNode; + while (node) { + ancestors.push(node); + node = node.parentNode; + } + ancestors.reverse(); + return ancestors; + }, + + /** + * @param {string|Array=} [dimension='value'] Default 'value'. can be 0, 1, 2, 3 + * @return {number} Value. + */ + getValue: function (dimension) { + var data = this.hostTree.data; + return data.get(data.getDimension(dimension || 'value'), this.dataIndex); + }, + + /** + * @param {Object} layout + * @param {boolean=} [merge=false] + */ + setLayout: function (layout, merge) { + this.dataIndex >= 0 + && this.hostTree.data.setItemLayout(this.dataIndex, layout, merge); + }, + + /** + * @return {Object} layout + */ + getLayout: function () { + return this.hostTree.data.getItemLayout(this.dataIndex); + }, + + /** + * @param {string} path + * @return {module:echarts/model/Model} + */ + getModel: function (path) { + if (this.dataIndex < 0) { + return; + } + var hostTree = this.hostTree; + var itemModel = hostTree.data.getItemModel(this.dataIndex); + var levelModel = this.getLevelModel(); + + return itemModel.getModel(path, (levelModel || hostTree.hostModel).getModel(path)); + }, + + /** + * @return {module:echarts/model/Model} + */ + getLevelModel: function () { + return (this.hostTree.levelModels || [])[this.depth]; + }, + + /** + * @example + * setItemVisual('color', color); + * setItemVisual({ + * 'color': color + * }); + */ + setVisual: function (key, value) { + this.dataIndex >= 0 + && this.hostTree.data.setItemVisual(this.dataIndex, key, value); + }, + + /** + * @public + */ + getVisual: function (key, ignoreParent) { + return this.hostTree.data.getItemVisual(this.dataIndex, key, ignoreParent); + }, + + /** + * @public + * @return {number} + */ + getRawIndex: function () { + return this.hostTree.data.getRawIndex(this.dataIndex); + }, + + /** + * @public + * @return {string} + */ + getId: function () { + return this.hostTree.data.getId(this.dataIndex); + } + }; + + /** + * @constructor + * @alias module:echarts/data/Tree + * @param {module:echarts/model/Model} hostModel + * @param {Array.} levelOptions + */ + function Tree(hostModel, levelOptions) { + /** + * @type {module:echarts/data/Tree~TreeNode} + * @readOnly + */ + this.root; + + /** + * @type {module:echarts/data/List} + * @readOnly + */ + this.data; + + /** + * Index of each item is the same as the raw index of coresponding list item. + * @private + * @type {Array.} levelOptions + * @return module:echarts/data/Tree + */ + Tree.createTree = function (dataRoot, hostModel, levelOptions) { + + var tree = new Tree(hostModel, levelOptions); + var listData = []; + + buildHierarchy(dataRoot); + + function buildHierarchy(dataNode, parentNode) { + listData.push(dataNode); + + var node = new TreeNode(dataNode.name, listData.length - 1, tree); + parentNode + ? addChild(node, parentNode) + : (tree.root = node); + + var children = dataNode.children; + if (children) { + for (var i = 0; i < children.length; i++) { + buildHierarchy(children[i], node); + } + } + } + + tree.root.updateDepthAndHeight(0); + + var dimensions = completeDimensions([{name: 'value'}], listData); + var list = new List(dimensions, hostModel); + list.initData(listData); + + linkListHelper.linkToTree(list, tree); + + return tree; + }; + + /** + * It is needed to consider the mess of 'list', 'hostModel' when creating a TreeNote, + * so this function is not ready and not necessary to be public. + * + * @param {(module:echarts/data/Tree~TreeNode|Object)} child + */ + function addChild(child, node) { + var children = node.children; + if (child.parentNode === node) { + return; + } + + children.push(child); + child.parentNode = node; + + node.hostTree._nodes.push(child); + } + + module.exports = Tree; + + +/***/ }, +/* 180 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Link list to graph or tree + */ + + + var zrUtil = __webpack_require__(3); + var arraySlice = Array.prototype.slice; + + // Caution: + // In most case, only one of the list and its shallow clones (see list.cloneShallow) + // can be active in echarts process. Considering heap memory consumption, + // we do not clone tree or graph, but share them among list and its shallow clones. + // But in some rare case, we have to keep old list (like do animation in chart). So + // please take care that both the old list and the new list share the same tree/graph. + + function linkList(list, target, targetType) { + zrUtil.each(listProxyMethods, function (method, methodName) { + var originMethod = list[methodName]; + list[methodName] = zrUtil.curry(method, originMethod, target, targetType); + }); + + list[targetType] = target; + target.data = list; + + return list; + } + + var listProxyMethods = { + cloneShallow: function (originMethod, target, targetType) { + var newList = originMethod.apply(this, arraySlice.call(arguments, 3)); + return linkList(newList, target, targetType); + }, + map: function (originMethod, target, targetType) { + var newList = originMethod.apply(this, arraySlice.call(arguments, 3)); + return linkList(newList, target, targetType); + }, + filterSelf: function (originMethod, target, targetType) { + var result = originMethod.apply(this, arraySlice.call(arguments, 3)); + target.update(); + return result; + } + }; + + module.exports = { + linkToGraph: function (list, graph) { + linkList(list, graph, 'graph'); + }, + + linkToTree: function (list, tree) { + linkList(list, tree, 'tree'); + } + }; + + +/***/ }, +/* 181 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var DataDiffer = __webpack_require__(95); + var helper = __webpack_require__(182); + var Breadcrumb = __webpack_require__(183); + var RoamController = __webpack_require__(159); + var BoundingRect = __webpack_require__(15); + var matrix = __webpack_require__(17); + var animationUtil = __webpack_require__(184); + var bind = zrUtil.bind; + var Group = graphic.Group; + var Rect = graphic.Rect; + var each = zrUtil.each; + + var DRAG_THRESHOLD = 3; + + module.exports = __webpack_require__(1).extendChartView({ + + type: 'treemap', + + /** + * @override + */ + init: function (o, api) { + + /** + * @private + * @type {module:zrender/container/Group} + */ + this._containerGroup; + + /** + * @private + * @type {Object.>} + */ + this._storage = createStorage(); + + /** + * @private + * @type {module:echarts/data/Tree} + */ + this._oldTree; + + /** + * @private + * @type {module:echarts/chart/treemap/Breadcrumb} + */ + this._breadcrumb; + + /** + * @private + * @type {module:echarts/component/helper/RoamController} + */ + this._controller; + + /** + * 'ready', 'animating' + * @private + */ + this._state = 'ready'; + + /** + * @private + * @type {boolean} + */ + this._mayClick; + }, + + /** + * @override + */ + render: function (seriesModel, ecModel, api, payload) { + + var models = ecModel.findComponents({ + mainType: 'series', subType: 'treemap', query: payload + }); + if (zrUtil.indexOf(models, seriesModel) < 0) { + return; + } + + this.seriesModel = seriesModel; + this.api = api; + this.ecModel = ecModel; + + var payloadType = payload && payload.type; + var layoutInfo = seriesModel.layoutInfo; + var isInit = !this._oldTree; + + var containerGroup = this._giveContainerGroup(layoutInfo); + + var renderResult = this._doRender(containerGroup, seriesModel); + + (!isInit && (!payloadType || payloadType === 'treemapZoomToNode')) + ? this._doAnimation(containerGroup, renderResult, seriesModel) + : renderResult.renderFinally(); + + this._resetController(api); + + var targetInfo = helper.retrieveTargetInfo(payload, seriesModel); + this._renderBreadcrumb(seriesModel, api, targetInfo); + }, + + /** + * @private + */ + _giveContainerGroup: function (layoutInfo) { + var containerGroup = this._containerGroup; + if (!containerGroup) { + // FIXME + // 加一层containerGroup是为了clip,但是现在clip功能并没有实现。 + containerGroup = this._containerGroup = new Group(); + this._initEvents(containerGroup); + this.group.add(containerGroup); + } + containerGroup.position = [layoutInfo.x, layoutInfo.y]; + + return containerGroup; + }, + + /** + * @private + */ + _doRender: function (containerGroup, seriesModel) { + var thisTree = seriesModel.getData().tree; + var oldTree = this._oldTree; + + // Clear last shape records. + var lastsForAnimation = createStorage(); + var thisStorage = createStorage(); + var oldStorage = this._storage; + var willInvisibleEls = []; + var willVisibleEls = []; + var willDeleteEls = []; + var renderNode = bind( + this._renderNode, this, + thisStorage, oldStorage, lastsForAnimation, willInvisibleEls, willVisibleEls + ); + var viewRoot = seriesModel.getViewRoot(); + + // Notice: when thisTree and oldTree are the same tree (see list.cloneShadow), + // the oldTree is actually losted, so we can not find all of the old graphic + // elements from tree. So we use this stragegy: make element storage, move + // from old storage to new storage, clear old storage. + + dualTravel( + thisTree.root ? [thisTree.root] : [], + (oldTree && oldTree.root) ? [oldTree.root] : [], + containerGroup, + thisTree === oldTree || !oldTree, + viewRoot === thisTree.root + ); + + // Process all removing. + var willDeleteEls = clearStorage(oldStorage); + + this._oldTree = thisTree; + this._storage = thisStorage; + + return { + lastsForAnimation: lastsForAnimation, + willDeleteEls: willDeleteEls, + renderFinally: renderFinally + }; + + function dualTravel(thisViewChildren, oldViewChildren, parentGroup, sameTree, inView) { + // When 'render' is triggered by action, + // 'this' and 'old' may be the same tree, + // we use rawIndex in that case. + if (sameTree) { + oldViewChildren = thisViewChildren; + each(thisViewChildren, function (child, index) { + !child.isRemoved() && processNode(index, index); + }); + } + // Diff hierarchically (diff only in each subtree, but not whole). + // because, consistency of view is important. + else { + (new DataDiffer(oldViewChildren, thisViewChildren, getKey, getKey)) + .add(processNode) + .update(processNode) + .remove(zrUtil.curry(processNode, null)) + .execute(); + } + + function getKey(node) { + // Identify by name or raw index. + return node.getId(); + } + + function processNode(newIndex, oldIndex) { + var thisNode = newIndex != null ? thisViewChildren[newIndex] : null; + var oldNode = oldIndex != null ? oldViewChildren[oldIndex] : null; + + // Whether under viewRoot. + var subInView = inView || thisNode === viewRoot; + // If not under viewRoot, only remove. + if (!subInView) { + thisNode = null; + } + + var group = renderNode(thisNode, oldNode, parentGroup); + + group && dualTravel( + thisNode && thisNode.viewChildren || [], + oldNode && oldNode.viewChildren || [], + group, + sameTree, + subInView + ); + } + } + + function clearStorage(storage) { + var willDeleteEls = createStorage(); + storage && each(storage, function (store, storageName) { + var delEls = willDeleteEls[storageName]; + each(store, function (el) { + el && (delEls.push(el), el.__tmWillDelete = storageName); + }); + }); + return willDeleteEls; + } + + function renderFinally() { + each(willDeleteEls, function (els) { + each(els, function (el) { + el.parent && el.parent.remove(el); + }); + }); + // Theoritically there is no intersection between willInvisibleEls + // and willVisibleEls have, but we set visible after for robustness. + each(willInvisibleEls, function (el) { + el.invisible = true; + // Setting invisible is for optimizing, so no need to set dirty, + // just mark as invisible. + }); + each(willVisibleEls, function (el) { + el.invisible = false; + el.__tmWillVisible = false; + el.dirty(); + }); + } + }, + + /** + * @private + */ + _renderNode: function ( + thisStorage, oldStorage, lastsForAnimation, + willInvisibleEls, willVisibleEls, + thisNode, oldNode, parentGroup + ) { + var thisRawIndex = thisNode && thisNode.getRawIndex(); + var oldRawIndex = oldNode && oldNode.getRawIndex(); + + // Deleting things will performed finally. This method just find element from + // old storage, or create new element, set them to new storage, and set styles. + if (!thisNode) { + return; + } + + var layout = thisNode.getLayout(); + var thisWidth = layout.width; + var thisHeight = layout.height; + var invisible = layout.invisible; + + // Node group + var group = giveGraphic('nodeGroup', Group); + if (!group) { + return; + } + parentGroup.add(group); + group.position = [layout.x, layout.y]; + group.__tmNodeWidth = thisWidth; + group.__tmNodeHeight = thisHeight; + + // Background + var bg = giveGraphic('background', Rect); + if (bg) { + bg.setShape({x: 0, y: 0, width: thisWidth, height: thisHeight}); + updateStyle(bg, {fill: thisNode.getVisual('borderColor', true)}); + group.add(bg); + } + + var thisViewChildren = thisNode.viewChildren; + + // No children, render content. + if (!thisViewChildren || !thisViewChildren.length) { + var borderWidth = layout.borderWidth; + var content = giveGraphic('content', Rect); + + if (content) { + var contentWidth = Math.max(thisWidth - 2 * borderWidth, 0); + var contentHeight = Math.max(thisHeight - 2 * borderWidth, 0); + var labelModel = thisNode.getModel('label.normal'); + var textStyleModel = thisNode.getModel('label.normal.textStyle'); + var text = thisNode.getModel().get('name'); + var textRect = textStyleModel.getTextRect(text); + var showLabel = labelModel.get('show'); + + if (!showLabel || textRect.height > contentHeight) { + text = ''; + } + else if (textRect.width > contentWidth) { + text = textStyleModel.get('ellipsis') + ? textStyleModel.ellipsis(text, contentWidth) : ''; + } + + // For tooltip. + content.dataIndex = thisNode.dataIndex; + content.seriesIndex = this.seriesModel.seriesIndex; + + content.culling = true; + content.setShape({ + x: borderWidth, + y: borderWidth, + width: contentWidth, + height: contentHeight + }); + updateStyle(content, { + fill: thisNode.getVisual('color', true), + text: text, + textPosition: labelModel.get('position'), + textFill: textStyleModel.getTextColor(), + textAlign: textStyleModel.get('align'), + textVerticalAlign: textStyleModel.get('baseline'), + textFont: textStyleModel.getFont() + }); + group.add(content); + } + } + + return group; + + function giveGraphic(storageName, Ctor) { + var element = oldRawIndex != null && oldStorage[storageName][oldRawIndex]; + var lasts = lastsForAnimation[storageName]; + + if (element) { + // Remove from oldStorage + oldStorage[storageName][oldRawIndex] = null; + prepareAnimationWhenHasOld(lasts, element, storageName); + } + // If invisible and no old element, do not create new element (for optimizing). + else if (!invisible) { + element = new Ctor(); + prepareAnimationWhenNoOld(lasts, element, storageName); + } + + // Set to thisStorage + return (thisStorage[storageName][thisRawIndex] = element); + } + + function prepareAnimationWhenHasOld(lasts, element, storageName) { + var lastCfg = lasts[thisRawIndex] = {}; + lastCfg.old = storageName === 'nodeGroup' + ? element.position.slice() + : zrUtil.extend({}, element.shape); + } + + // If a element is new, we need to find the animation start point carefully, + // otherwise it will looks strange when 'zoomToNode'. + function prepareAnimationWhenNoOld(lasts, element, storageName) { + // New background do not animate but delay show. + if (storageName === 'background') { + element.invisible = true; + element.__tmWillVisible = true; + willVisibleEls.push(element); + } + else { + var parentNode = thisNode.parentNode; + var parentOldBg; + var parentOldX = 0; + var parentOldY = 0; + // For convenient, get old bounding rect from background. + if (parentNode && ( + parentOldBg = lastsForAnimation.background[parentNode.getRawIndex()] + )) { + parentOldX = parentOldBg.old.width; + parentOldY = parentOldBg.old.height; + } + // When no parent old shape found, its parent is new too, + // so we can just use {x:0, y:0}. + var lastCfg = lasts[thisRawIndex] = {}; + lastCfg.old = storageName === 'nodeGroup' + ? [parentOldX, parentOldY] + : {x: parentOldX, y: parentOldY, width: 0, height: 0}; + + // Fade in, user can be aware that these nodes are new. + lastCfg.fadein = storageName !== 'nodeGroup'; + } + } + + function updateStyle(element, style) { + if (!invisible) { + // If invisible, do not set visual, otherwise the element will + // change immediately before animation. We think it is OK to + // remain its origin color when moving out of the view window. + element.setStyle(style); + if (!element.__tmWillVisible) { + element.invisible = false; + } + } + else { + // Delay invisible setting utill animation finished, + // avoid element vanish suddenly before animation. + !element.invisible && willInvisibleEls.push(element); + } + } + }, + + /** + * @private + */ + _doAnimation: function (containerGroup, renderResult, seriesModel) { + if (!seriesModel.get('animation')) { + return; + } + + var duration = seriesModel.get('animationDurationUpdate'); + var easing = seriesModel.get('animationEasing'); + + var animationWrap = animationUtil.createWrap(); + + // Make delete animations. + var viewRoot = this.seriesModel.getViewRoot(); + var rootGroup = this._storage.nodeGroup[viewRoot.getRawIndex()]; + rootGroup && rootGroup.traverse(function (el) { + var storageName; + if (el.invisible || !(storageName = el.__tmWillDelete)) { + return; + } + var targetX = 0; + var targetY = 0; + var parent = el.parent; // Always has parent, and parent is nodeGroup. + if (!parent.__tmWillDelete) { + // Let node animate to right-bottom corner, cooperating with fadeout, + // which is perfect for user understanding. + targetX = parent.__tmNodeWidth; + targetY = parent.__tmNodeHeight; + } + var target = storageName === 'nodeGroup' + ? {position: [targetX, targetY], style: {opacity: 0}} + : {shape: {x: targetX, y: targetY, width: 0, height: 0}, style: {opacity: 0}}; + animationWrap.add(el, target, duration, easing); + }); + + // Make other animations + each(this._storage, function (store, storageName) { + each(store, function (el, rawIndex) { + var last = renderResult.lastsForAnimation[storageName][rawIndex]; + var target; + + if (!last) { + return; + } + + if (storageName === 'nodeGroup') { + target = {position: el.position.slice()}; + el.position = last.old; + } + else { + target = {shape: zrUtil.extend({}, el.shape)}; + el.setShape(last.old); + + if (last.fadein) { + el.setStyle('opacity', 0); + target.style = {opacity: 1}; + } + // When animation is stopped for succedent animation starting, + // el.style.opacity might not be 1 + else if (el.style.opacity !== 1) { + target.style = {opacity: 1}; + } + } + animationWrap.add(el, target, duration, easing); + }); + }, this); + + this._state = 'animating'; + + animationWrap + .done(bind(function () { + this._state = 'ready'; + renderResult.renderFinally(); + }, this)) + .start(); + }, + + /** + * @private + */ + _resetController: function (api) { + var controller = this._controller; + + // Init controller. + if (!controller) { + controller = this._controller = new RoamController(api.getZr()); + controller.enable(this.seriesModel.get('roam')); + controller.on('pan', bind(this._onPan, this)); + controller.on('zoom', bind(this._onZoom, this)); + } + + controller.rect = new BoundingRect(0, 0, api.getWidth(), api.getHeight()); + }, + + /** + * @private + */ + _clearController: function () { + var controller = this._controller; + if (controller) { + controller.off('pan').off('zoom'); + controller = null; + } + }, + + /** + * @private + */ + _onPan: function (dx, dy) { + this._mayClick = false; + + if (this._state !== 'animating' + && (Math.abs(dx) > DRAG_THRESHOLD || Math.abs(dy) > DRAG_THRESHOLD) + ) { + // These param must not be cached. + var viewRoot = this.seriesModel.getViewRoot(); + + if (!viewRoot) { + return; + } + + var rootLayout = viewRoot.getLayout(); + + if (!rootLayout) { + return; + } + + this.api.dispatchAction({ + type: 'treemapMove', + from: this.uid, + seriesId: this.seriesModel.id, + rootRect: { + x: rootLayout.x + dx, y: rootLayout.y + dy, + width: rootLayout.width, height: rootLayout.height + } + }); + } + }, + + /** + * @private + */ + _onZoom: function (scale, mouseX, mouseY) { + this._mayClick = false; + + if (this._state !== 'animating') { + // These param must not be cached. + var viewRoot = this.seriesModel.getViewRoot(); + + if (!viewRoot) { + return; + } + + var rootLayout = viewRoot.getLayout(); + + if (!rootLayout) { + return; + } + + var rect = new BoundingRect( + rootLayout.x, rootLayout.y, rootLayout.width, rootLayout.height + ); + var layoutInfo = this.seriesModel.layoutInfo; + + // Transform mouse coord from global to containerGroup. + mouseX -= layoutInfo.x; + mouseY -= layoutInfo.y; + + // Scale root bounding rect. + var m = matrix.create(); + matrix.translate(m, m, [-mouseX, -mouseY]); + matrix.scale(m, m, [scale, scale]); + matrix.translate(m, m, [mouseX, mouseY]); + + rect.applyTransform(m); + + this.api.dispatchAction({ + type: 'treemapRender', + from: this.uid, + seriesId: this.seriesModel.id, + rootRect: { + x: rect.x, y: rect.y, + width: rect.width, height: rect.height + } + }); + } + }, + + /** + * @private + */ + _initEvents: function (containerGroup) { + // FIXME + // 不用click以及silent的原因是,animate时视图设置silent true来避免click生效, + // 但是animate中,按下鼠标,animate结束后(silent设回为false)松开鼠标, + // 还是会触发click,期望是不触发。 + + // Mousedown occurs when drag start, and mouseup occurs when drag end, + // click event should not be triggered in that case. + + containerGroup.on('mousedown', function (e) { + this._state === 'ready' && (this._mayClick = true); + }, this); + containerGroup.on('mouseup', function (e) { + if (this._mayClick) { + this._mayClick = false; + this._state === 'ready' && onClick.call(this, e); + } + }, this); + + function onClick(e) { + var nodeClick = this.seriesModel.get('nodeClick', true); + + if (!nodeClick) { + return; + } + + var targetInfo = this.findTarget(e.offsetX, e.offsetY); + + if (targetInfo) { + if (nodeClick === 'zoomToNode') { + this._zoomToNode(targetInfo); + } + else if (nodeClick === 'link') { + var node = targetInfo.node; + var itemModel = node.hostTree.data.getItemModel(node.dataIndex); + var link = itemModel.get('link', true); + var linkTarget = itemModel.get('target', true) || 'blank'; + link && window.open(link, linkTarget); + } + } + } + }, + + /** + * @private + */ + _renderBreadcrumb: function (seriesModel, api, targetInfo) { + if (!targetInfo) { + // Find breadcrumb tail on center of containerGroup. + targetInfo = this.findTarget(api.getWidth() / 2, api.getHeight() / 2); + + if (!targetInfo) { + targetInfo = {node: seriesModel.getData().tree.root}; + } + } + + (this._breadcrumb || (this._breadcrumb = new Breadcrumb(this.group, bind(onSelect, this)))) + .render(seriesModel, api, targetInfo.node); + + function onSelect(node) { + this._zoomToNode({node: node}); + } + }, + + /** + * @override + */ + remove: function () { + this._clearController(); + this._containerGroup && this._containerGroup.removeAll(); + this._storage = createStorage(); + this._state = 'ready'; + this._breadcrumb && this._breadcrumb.remove(); + }, + + dispose: function () { + this._clearController(); + }, + + /** + * @private + */ + _zoomToNode: function (targetInfo) { + this.api.dispatchAction({ + type: 'treemapZoomToNode', + from: this.uid, + seriesId: this.seriesModel.id, + targetNode: targetInfo.node + }); + }, + + /** + * @public + * @param {number} x Global coord x. + * @param {number} y Global coord y. + * @return {Object} info If not found, return undefined; + * @return {number} info.node Target node. + * @return {number} info.offsetX x refer to target node. + * @return {number} info.offsetY y refer to target node. + */ + findTarget: function (x, y) { + var targetInfo; + var viewRoot = this.seriesModel.getViewRoot(); + + viewRoot.eachNode({attr: 'viewChildren', order: 'preorder'}, function (node) { + var bgEl = this._storage.background[node.getRawIndex()]; + // If invisible, there might be no element. + if (bgEl) { + var point = bgEl.transformCoordToLocal(x, y); + var shape = bgEl.shape; + + // For performance consideration, dont use 'getBoundingRect'. + if (shape.x <= point[0] + && point[0] <= shape.x + shape.width + && shape.y <= point[1] + && point[1] <= shape.y + shape.height + ) { + targetInfo = {node: node, offsetX: point[0], offsetY: point[1]}; + } + else { + return false; // Suppress visit subtree. + } + } + }, this); + + return targetInfo; + } + + }); + + function createStorage() { + return {nodeGroup: [], background: [], content: []}; + } + + +/***/ }, +/* 182 */ +/***/ function(module, exports) { + + + + var helper = { + + retrieveTargetInfo: function (payload, seriesModel) { + if (!payload || payload.type !== 'treemapZoomToNode') { + return; + } + + var root = seriesModel.getData().tree.root; + var targetNode = payload.targetNode; + if (targetNode && root.contains(targetNode)) { + return {node: targetNode}; + } + + var targetNodeId = payload.targetNodeId; + if (targetNodeId != null && (targetNode = root.getNodeById(targetNodeId))) { + return {node: targetNode}; + } + + return null; + } + + }; + + module.exports = helper; + + +/***/ }, +/* 183 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var layout = __webpack_require__(21); + var zrUtil = __webpack_require__(3); + + var TEXT_PADDING = 8; + var ITEM_GAP = 8; + var ARRAY_LENGTH = 5; + + function Breadcrumb(containerGroup, onSelect) { + /** + * @private + * @type {module:zrender/container/Group} + */ + this.group = new graphic.Group(); + + containerGroup.add(this.group); + + /** + * @private + * @type {Function} + */ + this._onSelect = onSelect || zrUtil.noop; + } + + Breadcrumb.prototype = { + + constructor: Breadcrumb, + + render: function (seriesModel, api, targetNode) { + var model = seriesModel.getModel('breadcrumb'); + var thisGroup = this.group; + + thisGroup.removeAll(); + + if (!model.get('show') || !targetNode) { + return; + } + + var normalStyleModel = model.getModel('itemStyle.normal'); + // var emphasisStyleModel = model.getModel('itemStyle.emphasis'); + var textStyleModel = normalStyleModel.getModel('textStyle'); + + var layoutParam = { + pos: { + left: model.get('left'), + right: model.get('right'), + top: model.get('top'), + bottom: model.get('bottom') + }, + box: { + width: api.getWidth(), + height: api.getHeight() + }, + emptyItemWidth: model.get('emptyItemWidth'), + totalWidth: 0, + renderList: [] + }; + + this._prepare( + model, targetNode, layoutParam, textStyleModel + ); + this._renderContent( + model, targetNode, layoutParam, normalStyleModel, textStyleModel + ); + + layout.positionGroup(thisGroup, layoutParam.pos, layoutParam.box); + }, + + /** + * Prepare render list and total width + * @private + */ + _prepare: function (model, targetNode, layoutParam, textStyleModel) { + for (var node = targetNode; node; node = node.parentNode) { + var text = node.getModel().get('name'); + var textRect = textStyleModel.getTextRect(text); + var itemWidth = Math.max( + textRect.width + TEXT_PADDING * 2, + layoutParam.emptyItemWidth + ); + layoutParam.totalWidth += itemWidth + ITEM_GAP; + layoutParam.renderList.push({node: node, text: text, width: itemWidth}); + } + }, + + /** + * @private + */ + _renderContent: function ( + model, targetNode, layoutParam, normalStyleModel, textStyleModel + ) { + // Start rendering. + var lastX = 0; + var emptyItemWidth = layoutParam.emptyItemWidth; + var height = model.get('height'); + var availableSize = layout.getAvailableSize(layoutParam.pos, layoutParam.box); + var totalWidth = layoutParam.totalWidth; + var renderList = layoutParam.renderList; + + for (var i = renderList.length - 1; i >= 0; i--) { + var item = renderList[i]; + var itemWidth = item.width; + var text = item.text; + + // Hdie text and shorten width if necessary. + if (totalWidth > availableSize.width) { + totalWidth -= itemWidth - emptyItemWidth; + itemWidth = emptyItemWidth; + text = ''; + } + + this.group.add(new graphic.Polygon({ + shape: { + points: makeItemPoints( + lastX, 0, itemWidth, height, + i === renderList.length - 1, i === 0 + ) + }, + style: zrUtil.defaults( + normalStyleModel.getItemStyle(), + { + lineJoin: 'bevel', + text: text, + textFill: textStyleModel.getTextColor(), + textFont: textStyleModel.getFont() + } + ), + onclick: zrUtil.bind(this._onSelect, this, item.node) + })); + + lastX += itemWidth + ITEM_GAP; + } + }, + + /** + * @override + */ + remove: function () { + this.group.removeAll(); + } + }; + + function makeItemPoints(x, y, itemWidth, itemHeight, head, tail) { + var points = [ + [head ? x : x - ARRAY_LENGTH, y], + [x + itemWidth, y], + [x + itemWidth, y + itemHeight], + [head ? x : x - ARRAY_LENGTH, y + itemHeight] + ]; + !tail && points.splice(2, 0, [x + itemWidth + ARRAY_LENGTH, y + itemHeight / 2]); + !head && points.push([x, y + itemHeight / 2]); + return points; + } + + module.exports = Breadcrumb; + + +/***/ }, +/* 184 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + /** + * @param {number} [time=500] Time in ms + * @param {string} [easing='linear'] + * @param {number} [delay=0] + * @param {Function} [callback] + * + * @example + * // Animate position + * animation + * .createWrap() + * .add(el1, {position: [10, 10]}) + * .add(el2, {shape: {width: 500}, style: {fill: 'red'}}, 400) + * .done(function () { // done }) + * .start('cubicOut'); + */ + function createWrap() { + + var storage = []; + var elExistsMap = {}; + var doneCallback; + + return { + + /** + * Caution: a el can only be added once, otherwise 'done' + * might not be called. This method checks this (by el.id), + * suppresses adding and returns false when existing el found. + * + * @param {modele:zrender/Element} el + * @param {Object} target + * @param {number} [time=500] + * @param {number} [delay=0] + * @param {string} [easing='linear'] + * @return {boolean} Whether adding succeeded. + * + * @example + * add(el, target, time, delay, easing); + * add(el, target, time, easing); + * add(el, target, time); + * add(el, target); + */ + add: function (el, target, time, delay, easing) { + if (zrUtil.isString(delay)) { + easing = delay; + delay = 0; + } + + if (elExistsMap[el.id]) { + return false; + } + elExistsMap[el.id] = 1; + + storage.push( + {el: el, target: target, time: time, delay: delay, easing: easing} + ); + + return true; + }, + + /** + * Only execute when animation finished. Will not execute when any + * of 'stop' or 'stopAnimation' called. + * + * @param {Function} callback + */ + done: function (callback) { + doneCallback = callback; + return this; + }, + + /** + * Will stop exist animation firstly. + */ + start: function () { + var count = storage.length; + + for (var i = 0, len = storage.length; i < len; i++) { + var item = storage[i]; + item.el.animateTo(item.target, item.time, item.delay, item.easing, done); + } + + return this; + + function done() { + count--; + if (!count) { + storage.length = 0; + elExistsMap = {}; + doneCallback && doneCallback(); + } + } + } + }; + } + + module.exports = {createWrap: createWrap}; + + +/***/ }, +/* 185 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Treemap action + */ + + + var echarts = __webpack_require__(1); + + var noop = function () {}; + + echarts.registerAction({type: 'treemapZoomToNode', update: 'updateView'}, noop); + echarts.registerAction({type: 'treemapRender', update: 'updateView'}, noop); + echarts.registerAction({type: 'treemapMove', update: 'updateView'}, noop); + + + +/***/ }, +/* 186 */ +/***/ function(module, exports, __webpack_require__) { + + + + var VisualMapping = __webpack_require__(187); + var zrColor = __webpack_require__(38); + var zrUtil = __webpack_require__(3); + var isArray = zrUtil.isArray; + + var ITEM_STYLE_NORMAL = 'itemStyle.normal'; + + module.exports = function (ecModel, payload) { + + var condition = {mainType: 'series', subType: 'treemap', query: payload}; + ecModel.eachComponent(condition, function (seriesModel) { + + var tree = seriesModel.getData().tree; + var root = tree.root; + var seriesItemStyleModel = seriesModel.getModel(ITEM_STYLE_NORMAL); + + if (root.isRemoved()) { + return; + } + + var levelItemStyles = zrUtil.map(tree.levelModels, function (levelModel) { + return levelModel ? levelModel.get(ITEM_STYLE_NORMAL) : null; + }); + + travelTree( + root, + {}, + levelItemStyles, + seriesItemStyleModel, + seriesModel.getViewRoot().getAncestors(), + seriesModel + ); + }); + }; + + function travelTree( + node, designatedVisual, levelItemStyles, seriesItemStyleModel, + viewRootAncestors, seriesModel + ) { + var nodeModel = node.getModel(); + var nodeLayout = node.getLayout(); + + // Optimize + if (nodeLayout.invisible) { + return; + } + + var nodeItemStyleModel = node.getModel(ITEM_STYLE_NORMAL); + var levelItemStyle = levelItemStyles[node.depth]; + var visuals = buildVisuals( + nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel + ); + + // calculate border color + var borderColor = nodeItemStyleModel.get('borderColor'); + var borderColorSaturation = nodeItemStyleModel.get('borderColorSaturation'); + var thisNodeColor; + if (borderColorSaturation != null) { + // For performance, do not always execute 'calculateColor'. + thisNodeColor = calculateColor(visuals, node); + borderColor = calculateBorderColor(borderColorSaturation, thisNodeColor); + } + node.setVisual('borderColor', borderColor); + + var viewChildren = node.viewChildren; + if (!viewChildren || !viewChildren.length) { + thisNodeColor = calculateColor(visuals, node); + // Apply visual to this node. + node.setVisual('color', thisNodeColor); + } + else { + var mapping = buildVisualMapping( + node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren + ); + // Designate visual to children. + zrUtil.each(viewChildren, function (child, index) { + // If higher than viewRoot, only ancestors of viewRoot is needed to visit. + if (child.depth >= viewRootAncestors.length + || child === viewRootAncestors[child.depth] + ) { + var childVisual = mapVisual( + nodeModel, visuals, child, index, mapping, seriesModel + ); + travelTree( + child, childVisual, levelItemStyles, seriesItemStyleModel, + viewRootAncestors, seriesModel + ); + } + }); + } + } + + function buildVisuals( + nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel + ) { + var visuals = zrUtil.extend({}, designatedVisual); + + zrUtil.each(['color', 'colorAlpha', 'colorSaturation'], function (visualName) { + // Priority: thisNode > thisLevel > parentNodeDesignated > seriesModel + var val = nodeItemStyleModel.get(visualName, true); // Ignore parent + val == null && levelItemStyle && (val = levelItemStyle[visualName]); + val == null && (val = designatedVisual[visualName]); + val == null && (val = seriesItemStyleModel.get(visualName)); + + val != null && (visuals[visualName] = val); + }); + + return visuals; + } + + function calculateColor(visuals) { + var color = getValueVisualDefine(visuals, 'color'); + + if (color) { + var colorAlpha = getValueVisualDefine(visuals, 'colorAlpha'); + var colorSaturation = getValueVisualDefine(visuals, 'colorSaturation'); + if (colorSaturation) { + color = zrColor.modifyHSL(color, null, null, colorSaturation); + } + if (colorAlpha) { + color = zrColor.modifyAlpha(color, colorAlpha); + } + + return color; + } + } + + function calculateBorderColor(borderColorSaturation, thisNodeColor) { + return thisNodeColor != null + ? zrColor.modifyHSL(thisNodeColor, null, null, borderColorSaturation) + : null; + } + + function getValueVisualDefine(visuals, name) { + var value = visuals[name]; + if (value != null && value !== 'none') { + return value; + } + } + + function buildVisualMapping( + node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren + ) { + if (!viewChildren || !viewChildren.length) { + return; + } + + var rangeVisual = getRangeVisual(nodeModel, 'color') + || ( + visuals.color != null + && visuals.color !== 'none' + && ( + getRangeVisual(nodeModel, 'colorAlpha') + || getRangeVisual(nodeModel, 'colorSaturation') + ) + ); + + if (!rangeVisual) { + return; + } + + var colorMappingBy = nodeModel.get('colorMappingBy'); + var opt = { + type: rangeVisual.name, + dataExtent: nodeLayout.dataExtent, + visual: rangeVisual.range + }; + if (opt.type === 'color' + && (colorMappingBy === 'index' || colorMappingBy === 'id') + ) { + opt.mappingMethod = 'category'; + opt.loop = true; + // categories is ordinal, so do not set opt.categories. + } + else { + opt.mappingMethod = 'linear'; + } + + var mapping = new VisualMapping(opt); + mapping.__drColorMappingBy = colorMappingBy; + + return mapping; + } + + // Notice: If we dont have the attribute 'colorRange', but only use + // attribute 'color' to represent both concepts of 'colorRange' and 'color', + // (It means 'colorRange' when 'color' is Array, means 'color' when not array), + // this problem will be encountered: + // If a level-1 node dont have children, and its siblings has children, + // and colorRange is set on level-1, then the node can not be colored. + // So we separate 'colorRange' and 'color' to different attributes. + function getRangeVisual(nodeModel, name) { + // 'colorRange', 'colorARange', 'colorSRange'. + // If not exsits on this node, fetch from levels and series. + var range = nodeModel.get(name); + return (isArray(range) && range.length) ? {name: name, range: range} : null; + } + + function mapVisual(nodeModel, visuals, child, index, mapping, seriesModel) { + var childVisuals = zrUtil.extend({}, visuals); + + if (mapping) { + var mappingType = mapping.type; + var colorMappingBy = mappingType === 'color' && mapping.__drColorMappingBy; + var value = + colorMappingBy === 'index' + ? index + : colorMappingBy === 'id' + ? seriesModel.mapIdToIndex(child.getId()) + : child.getValue(nodeModel.get('visualDimension')); + + childVisuals[mappingType] = mapping.mapValueToVisual(value); + } + + return childVisuals; + } + + + +/***/ }, +/* 187 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Visual mapping. + */ + + + var zrUtil = __webpack_require__(3); + var zrColor = __webpack_require__(38); + var linearMap = __webpack_require__(7).linearMap; + var each = zrUtil.each; + var isObject = zrUtil.isObject; + + var CATEGORY_DEFAULT_VISUAL_INDEX = -1; + + function linearMapArray(val, domain, range, clamp) { + if (zrUtil.isArray(val)) { + return zrUtil.map(val, function (v) { + return linearMap(v, domain, range, clamp); + }); + } + return linearMap(val, domain, range, clamp); + } + /** + * @param {Object} option + * @param {string} [option.type] See visualHandlers. + * @param {string} [option.mappingMethod] 'linear' or 'piecewise' or 'category' + * @param {Array.=} [option.dataExtent] [minExtent, maxExtent], + * required when mappingMethod is 'linear' + * @param {Array.=} [option.pieceList] [ + * {value: someValue}, + * {interval: [min1, max1], visual: {...}}, + * {interval: [min2, max2]} + * ], + * required when mappingMethod is 'piecewise'. + * Visual for only each piece can be specified. + * @param {Array.=} [option.categories] ['cate1', 'cate2'] + * required when mappingMethod is 'category'. + * If no option.categories, it represents + * categories is [0, 1, 2, ...]. + * @param {boolean} [option.loop=false] Whether loop mapping when mappingMethod is 'category'. + * @param {(Array|Object|*)} [option.visual] Visual data. + * when mappingMethod is 'category', + * visual data can be array or object + * (like: {cate1: '#222', none: '#fff'}) + * or primary types (which represents + * defualt category visual), otherwise visual + * can only be array. + * + */ + var VisualMapping = function (option) { + var mappingMethod = option.mappingMethod; + var visualType = option.type; + + /** + * @readOnly + * @type {string} + */ + this.type = visualType; + + /** + * @readOnly + * @type {string} + */ + this.mappingMethod = mappingMethod; + + /** + * @readOnly + * @type {Object} + */ + var thisOption = this.option = zrUtil.clone(option); + + /** + * @private + * @type {Function} + */ + this._normalizeData = normalizers[mappingMethod]; + + /** + * @private + * @type {Function} + */ + this._getSpecifiedVisual = zrUtil.bind( + specifiedVisualGetters[mappingMethod], this, visualType + ); + + zrUtil.extend(this, visualHandlers[visualType]); + + if (mappingMethod === 'piecewise') { + preprocessForPiecewise(thisOption); + } + if (mappingMethod === 'category') { + preprocessForCategory(thisOption); + } + }; + + VisualMapping.prototype = { + + constructor: VisualMapping, + + applyVisual: null, + + isValueActive: null, + + mapValueToVisual: null, + + getNormalizer: function () { + return zrUtil.bind(this._normalizeData, this); + } + }; + + var visualHandlers = VisualMapping.visualHandlers = { + + color: { + + applyVisual: defaultApplyColor, + + /** + * Create a mapper function + * @return {Function} + */ + getColorMapper: function () { + var visual = isCategory(this) + ? this.option.visual + : zrUtil.map(this.option.visual, zrColor.parse); + return zrUtil.bind( + isCategory(this) + ? function (value, isNormalized) { + !isNormalized && (value = this._normalizeData(value)); + return getVisualForCategory(this, visual, value); + } + : function (value, isNormalized, out) { + // If output rgb array + // which will be much faster and useful in pixel manipulation + var returnRGBArray = !!out; + !isNormalized && (value = this._normalizeData(value)); + out = zrColor.fastMapToColor(value, visual, out); + return returnRGBArray ? out : zrUtil.stringify(out, 'rgba'); + }, this); + }, + + // value: + // (1) {number} + // (2) {Array.} Represents a interval, for colorStops. + // Return type: + // (1) {string} color value like '#444' + // (2) {Array.} colorStops, + // like [{color: '#fff', offset: 0}, {color: '#444', offset: 1}] + // where offset is between 0 and 1. + mapValueToVisual: function (value) { + var visual = this.option.visual; + + if (zrUtil.isArray(value)) { + value = [ + this._normalizeData(value[0]), + this._normalizeData(value[1]) + ]; + + // For creating gradient color list. + return zrColor.mapIntervalToColor(value, visual); + } + else { + var normalized = this._normalizeData(value); + var result = this._getSpecifiedVisual(value); + + if (result == null) { + result = isCategory(this) + ? getVisualForCategory(this, visual, normalized) + : zrColor.mapToColor(normalized, visual); + } + + return result; + } + } + }, + + colorHue: makePartialColorVisualHandler(function (color, value) { + return zrColor.modifyHSL(color, value); + }), + + colorSaturation: makePartialColorVisualHandler(function (color, value) { + return zrColor.modifyHSL(color, null, value); + }), + + colorLightness: makePartialColorVisualHandler(function (color, value) { + return zrColor.modifyHSL(color, null, null, value); + }), + + colorAlpha: makePartialColorVisualHandler(function (color, value) { + return zrColor.modifyAlpha(color, value); + }), + + symbol: { + applyVisual: function (value, getter, setter) { + var symbolCfg = this.mapValueToVisual(value); + if (zrUtil.isString(symbolCfg)) { + setter('symbol', symbolCfg); + } + else if (isObject(symbolCfg)) { + for (var name in symbolCfg) { + if (symbolCfg.hasOwnProperty(name)) { + setter(name, symbolCfg[name]); + } + } + } + }, + + mapValueToVisual: function (value) { + var normalized = this._normalizeData(value); + var result = this._getSpecifiedVisual(value); + var visual = this.option.visual; + + if (result == null) { + result = isCategory(this) + ? getVisualForCategory(this, visual, normalized) + : (arrayGetByNormalizedValue(visual, normalized) || {}); + } + + return result; + } + }, + + symbolSize: { + applyVisual: function (value, getter, setter) { + setter('symbolSize', this.mapValueToVisual(value)); + }, + + mapValueToVisual: function (value) { + var normalized = this._normalizeData(value); + var result = this._getSpecifiedVisual(value); + var visual = this.option.visual; + + if (result == null) { + result = isCategory(this) + ? getVisualForCategory(this, visual, normalized) + : linearMapArray(normalized, [0, 1], visual, true); + } + return result; + } + } + }; + + function preprocessForPiecewise(thisOption) { + var pieceList = thisOption.pieceList; + thisOption.hasSpecialVisual = false; + + zrUtil.each(pieceList, function (piece, index) { + piece.originIndex = index; + if (piece.visual) { + thisOption.hasSpecialVisual = true; + } + }); + } + + function preprocessForCategory(thisOption) { + // Hash categories. + var categories = thisOption.categories; + var visual = thisOption.visual; + var isVisualArray = zrUtil.isArray(visual); + + if (!categories) { + if (!isVisualArray) { + // visual should be array when no categories. + throw new Error(); + } + else { + return; + } + } + + var categoryMap = thisOption.categoryMap = {}; + each(categories, function (cate, index) { + categoryMap[cate] = index; + }); + + // Process visual map input. + if (!isVisualArray) { + var visualArr = []; + + if (zrUtil.isObject(visual)) { + each(visual, function (v, cate) { + var index = categoryMap[cate]; + visualArr[index != null ? index : CATEGORY_DEFAULT_VISUAL_INDEX] = v; + }); + } + else { // Is primary type, represents default visual. + visualArr[CATEGORY_DEFAULT_VISUAL_INDEX] = visual; + } + + visual = thisOption.visual = visualArr; + } + + // Remove categories that has no visual, + // then we can mapping them to CATEGORY_DEFAULT_VISUAL_INDEX. + for (var i = categories.length - 1; i >= 0; i--) { + if (visual[i] == null) { + delete categoryMap[categories[i]]; + categories.pop(); + } + } + } + + function makePartialColorVisualHandler(applyValue) { + return { + + applyVisual: function (value, getter, setter) { + // color can be {string} or {Array.} (for gradient color stops) + var color = getter('color'); + var isArrayValue = zrUtil.isArray(value); + value = isArrayValue + ? [this.mapValueToVisual(value[0]), this.mapValueToVisual(value[1])] + : this.mapValueToVisual(value); + + if (zrUtil.isArray(color)) { + for (var i = 0, len = color.length; i < len; i++) { + color[i].color = applyValue( + color[i].color, isArrayValue ? value[i] : value + ); + } + } + else { + // Must not be array value + setter('color', applyValue(color, value)); + } + }, + + mapValueToVisual: function (value) { + var normalized = this._normalizeData(value); + var result = this._getSpecifiedVisual(value); + var visual = this.option.visual; + + if (result == null) { + result = isCategory(this) + ? getVisualForCategory(this, visual, normalized) + : linearMapArray(normalized, [0, 1], visual, true); + } + return result; + } + }; + } + + function arrayGetByNormalizedValue(arr, normalized) { + return arr[ + Math.round(linearMapArray(normalized, [0, 1], [0, arr.length - 1], true)) + ]; + } + + function defaultApplyColor(value, getter, setter) { + setter('color', this.mapValueToVisual(value)); + } + + function getVisualForCategory(me, visual, normalized) { + return visual[ + (me.option.loop && normalized !== CATEGORY_DEFAULT_VISUAL_INDEX) + ? normalized % visual.length + : normalized + ]; + } + + function isCategory(me) { + return me.option.mappingMethod === 'category'; + } + + + var normalizers = { + + linear: function (value) { + return linearMapArray(value, this.option.dataExtent, [0, 1], true); + }, + + piecewise: function (value) { + var pieceList = this.option.pieceList; + var pieceIndex = VisualMapping.findPieceIndex(value, pieceList); + if (pieceIndex != null) { + return linearMapArray(pieceIndex, [0, pieceList.length - 1], [0, 1], true); + } + }, + + category: function (value) { + var index = this.option.categories + ? this.option.categoryMap[value] + : value; // ordinal + return index == null ? CATEGORY_DEFAULT_VISUAL_INDEX : index; + } + }; + + + // FIXME + // refactor + var specifiedVisualGetters = { + + // Linear do not support this feature. + linear: zrUtil.noop, + + piecewise: function (visualType, value) { + var thisOption = this.option; + var pieceList = thisOption.pieceList; + if (thisOption.hasSpecialVisual) { + var pieceIndex = VisualMapping.findPieceIndex(value, pieceList); + var piece = pieceList[pieceIndex]; + if (piece && piece.visual) { + return piece.visual[visualType]; + } + } + }, + + // Category do not need to support this feature. + // Visual can be set in visualMap.inRange or + // visualMap.outOfRange directly. + category: zrUtil.noop + }; + + /** + * @public + */ + VisualMapping.addVisualHandler = function (name, handler) { + visualHandlers[name] = handler; + }; + + /** + * @public + */ + VisualMapping.isValidType = function (visualType) { + return visualHandlers.hasOwnProperty(visualType); + }; + + /** + * Convinent method. + * Visual can be Object or Array or primary type. + * + * @public + */ + VisualMapping.eachVisual = function (visual, callback, context) { + if (zrUtil.isObject(visual)) { + zrUtil.each(visual, callback, context); + } + else { + callback.call(context, visual); + } + }; + + VisualMapping.mapVisual = function (visual, callback, context) { + var isPrimary; + var newVisual = zrUtil.isArray(visual) + ? [] + : zrUtil.isObject(visual) + ? {} + : (isPrimary = true, null); + + VisualMapping.eachVisual(visual, function (v, key) { + var newVal = callback.call(context, v, key); + isPrimary ? (newVisual = newVal) : (newVisual[key] = newVal); + }); + return newVisual; + }; + + /** + * 'color', 'colorSaturation', 'colorAlpha', ... are in the same visualCluster named 'color'. + * Other visuals are in the cluster named as the same as theirselves. + * + * @public + * @param {string} visualType + * @param {string} visualCluster + * @return {boolean} + */ + VisualMapping.isInVisualCluster = function (visualType, visualCluster) { + return visualCluster === 'color' + ? !!(visualType && visualType.indexOf(visualCluster) === 0) + : visualType === visualCluster; + }; + + /** + * @public + * @param {Object} obj + * @return {Oject} new object containers visual values. + * If no visuals, return null. + */ + VisualMapping.retrieveVisuals = function (obj) { + var ret = {}; + var hasVisual; + + obj && each(visualHandlers, function (h, visualType) { + if (obj.hasOwnProperty(visualType)) { + ret[visualType] = obj[visualType]; + hasVisual = true; + } + }); + + return hasVisual ? ret : null; + }; + + /** + * Give order to visual types, considering colorSaturation, colorAlpha depends on color. + * + * @public + * @param {(Object|Array)} visualTypes If Object, like: {color: ..., colorSaturation: ...} + * IF Array, like: ['color', 'symbol', 'colorSaturation'] + * @return {Array.} Sorted visual types. + */ + VisualMapping.prepareVisualTypes = function (visualTypes) { + if (isObject(visualTypes)) { + var types = []; + each(visualTypes, function (item, type) { + types.push(type); + }); + visualTypes = types; + } + else if (zrUtil.isArray(visualTypes)) { + visualTypes = visualTypes.slice(); + } + else { + return []; + } + + visualTypes.sort(function (type1, type2) { + // color should be front of colorSaturation, colorAlpha, ... + // symbol and symbolSize do not matter. + return (type2 === 'color' && type1 !== 'color' && type1.indexOf('color') === 0) + ? 1 : -1; + }); + + return visualTypes; + }; + + /** + * @public {Array.} [{value: ..., interval: [min, max]}, ...] + * @return {number} index + */ + VisualMapping.findPieceIndex = function (value, pieceList) { + // value has high priority. + for (var i = 0, len = pieceList.length; i < len; i++) { + var piece = pieceList[i]; + if (piece.value != null && piece.value === value) { + return i; + } + } + + for (var i = 0, len = pieceList.length; i < len; i++) { + var piece = pieceList[i]; + var interval = piece.interval; + if (interval) { + if (interval[0] === -Infinity) { + if (value < interval[1]) { + return i; + } + } + else if (interval[1] === Infinity) { + if (interval[0] < value) { + return i; + } + } + else if ( + piece.interval[0] <= value + && value <= piece.interval[1] + ) { + return i; + } + } + } + }; + + module.exports = VisualMapping; + + + + +/***/ }, +/* 188 */ +/***/ function(module, exports, __webpack_require__) { + + + + var mathMax = Math.max; + var mathMin = Math.min; + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var layout = __webpack_require__(21); + var parsePercent = numberUtil.parsePercent; + var retrieveValue = zrUtil.retrieve; + var BoundingRect = __webpack_require__(15); + var helper = __webpack_require__(182); + + /** + * @public + */ + function update(ecModel, api, payload) { + // Layout result in each node: + // {x, y, width, height, area, borderWidth} + var condition = {mainType: 'series', subType: 'treemap', query: payload}; + ecModel.eachComponent(condition, function (seriesModel) { + + var ecWidth = api.getWidth(); + var ecHeight = api.getHeight(); + + var size = seriesModel.get('size') || []; // Compatible with ec2. + var containerWidth = parsePercent( + retrieveValue(seriesModel.get('width'), size[0]), + ecWidth + ); + var containerHeight = parsePercent( + retrieveValue(seriesModel.get('height'), size[1]), + ecHeight + ); + + var layoutInfo = layout.getLayoutRect( + seriesModel.getBoxLayoutParams(), + { + width: api.getWidth(), + height: api.getHeight() + } + ); + + // Fetch payload info. + var payloadType = payload && payload.type; + var targetInfo = helper.retrieveTargetInfo(payload, seriesModel); + var rootRect = (payloadType === 'treemapRender' || payloadType === 'treemapMove') + ? payload.rootRect : null; + var viewRoot = seriesModel.getViewRoot(); + + if (payloadType !== 'treemapMove') { + var rootSize = payloadType === 'treemapZoomToNode' + ? estimateRootSize(seriesModel, targetInfo, containerWidth, containerHeight) + : rootRect + ? [rootRect.width, rootRect.height] + : [containerWidth, containerHeight]; + + var sort = seriesModel.get('sort'); + if (sort && sort !== 'asc' && sort !== 'desc') { + sort = 'desc'; + } + var options = { + squareRatio: seriesModel.get('squareRatio'), + sort: sort + }; + + viewRoot.setLayout({ + x: 0, y: 0, + width: rootSize[0], height: rootSize[1], + area: rootSize[0] * rootSize[1] + }); + + squarify(viewRoot, options); + } + + // Set root position + viewRoot.setLayout( + calculateRootPosition(layoutInfo, rootRect, targetInfo), + true + ); + + seriesModel.setLayoutInfo(layoutInfo); + + // Optimize + // FIXME + // 现在没有clip功能,暂时取ec高宽。 + prunning( + viewRoot, + new BoundingRect(-layoutInfo.x, -layoutInfo.y, ecWidth, ecHeight) + ); + + }); + } + + /** + * Layout treemap with squarify algorithm. + * @see https://graphics.ethz.ch/teaching/scivis_common/Literature/squarifiedTreeMaps.pdf + * @see https://github.com/mbostock/d3/blob/master/src/layout/treemap.js + * + * @protected + * @param {module:echarts/data/Tree~TreeNode} node + * @param {Object} options + * @param {string} options.sort 'asc' or 'desc' + * @param {boolean} options.hideChildren + * @param {number} options.squareRatio + */ + function squarify(node, options) { + var width; + var height; + + if (node.isRemoved()) { + return; + } + + var thisLayout = node.getLayout(); + width = thisLayout.width; + height = thisLayout.height; + + // Considering border and gap + var itemStyleModel = node.getModel('itemStyle.normal'); + var borderWidth = itemStyleModel.get('borderWidth'); + var halfGapWidth = itemStyleModel.get('gapWidth') / 2; + var layoutOffset = borderWidth - halfGapWidth; + var nodeModel = node.getModel(); + + node.setLayout({borderWidth: borderWidth}, true); + + width = mathMax(width - 2 * layoutOffset, 0); + height = mathMax(height - 2 * layoutOffset, 0); + + var totalArea = width * height; + var viewChildren = initChildren(node, nodeModel, totalArea, options); + + if (!viewChildren.length) { + return; + } + + var rect = {x: layoutOffset, y: layoutOffset, width: width, height: height}; + var rowFixedLength = mathMin(width, height); + var best = Infinity; // the best row score so far + var row = []; + row.area = 0; + + for (var i = 0, len = viewChildren.length; i < len;) { + var child = viewChildren[i]; + + row.push(child); + row.area += child.getLayout().area; + var score = worst(row, rowFixedLength, options.squareRatio); + + // continue with this orientation + if (score <= best) { + i++; + best = score; + } + // abort, and try a different orientation + else { + row.area -= row.pop().getLayout().area; + position(row, rowFixedLength, rect, halfGapWidth, false); + rowFixedLength = mathMin(rect.width, rect.height); + row.length = row.area = 0; + best = Infinity; + } + } + + if (row.length) { + position(row, rowFixedLength, rect, halfGapWidth, true); + } + + // Update option carefully. + var hideChildren; + if (!options.hideChildren) { + var childrenVisibleMin = nodeModel.get('childrenVisibleMin'); + if (childrenVisibleMin != null && totalArea < childrenVisibleMin) { + hideChildren = true; + } + } + + for (var i = 0, len = viewChildren.length; i < len; i++) { + var childOption = zrUtil.extend({ + hideChildren: hideChildren + }, options); + + squarify(viewChildren[i], childOption); + } + } + + /** + * Set area to each child, and calculate data extent for visual coding. + */ + function initChildren(node, nodeModel, totalArea, options) { + var viewChildren = node.children || []; + var orderBy = options.sort; + orderBy !== 'asc' && orderBy !== 'desc' && (orderBy = null); + + if (options.hideChildren) { + return (node.viewChildren = []); + } + + // Sort children, order by desc. + viewChildren = zrUtil.filter(viewChildren, function (child) { + return !child.isRemoved(); + }); + + sort(viewChildren, orderBy); + + var info = statistic(nodeModel, viewChildren, orderBy); + + if (info.sum === 0) { + return (node.viewChildren = []); + } + + info.sum = filterByThreshold(nodeModel, totalArea, info.sum, orderBy, viewChildren); + + if (info.sum === 0) { + return (node.viewChildren = []); + } + + // Set area to each child. + for (var i = 0, len = viewChildren.length; i < len; i++) { + var area = viewChildren[i].getValue() / info.sum * totalArea; + // Do not use setLayout({...}, true), because it is needed to clear last layout. + viewChildren[i].setLayout({area: area}); + } + + node.viewChildren = viewChildren; + node.setLayout({dataExtent: info.dataExtent}, true); + + return viewChildren; + } + + /** + * Consider 'visibleMin'. Modify viewChildren and get new sum. + */ + function filterByThreshold(nodeModel, totalArea, sum, orderBy, orderedChildren) { + + // visibleMin is not supported yet when no option.sort. + if (!orderBy) { + return sum; + } + + var visibleMin = nodeModel.get('visibleMin'); + var len = orderedChildren.length; + var deletePoint = len; + + // Always travel from little value to big value. + for (var i = len - 1; i >= 0; i--) { + var value = orderedChildren[ + orderBy === 'asc' ? len - i - 1 : i + ].getValue(); + + if (value / sum * totalArea < visibleMin) { + deletePoint = i; + sum -= value; + } + } + + orderBy === 'asc' + ? orderedChildren.splice(0, len - deletePoint) + : orderedChildren.splice(deletePoint, len - deletePoint); + + return sum; + } + + /** + * Sort + */ + function sort(viewChildren, orderBy) { + if (orderBy) { + viewChildren.sort(function (a, b) { + return orderBy === 'asc' + ? a.getValue() - b.getValue() : b.getValue() - a.getValue(); + }); + } + return viewChildren; + } + + /** + * Statistic + */ + function statistic(nodeModel, children, orderBy) { + // Calculate sum. + var sum = 0; + for (var i = 0, len = children.length; i < len; i++) { + sum += children[i].getValue(); + } + + // Statistic data extent for latter visual coding. + // Notice: data extent should be calculate based on raw children + // but not filtered view children, otherwise visual mapping will not + // be stable when zoom (where children is filtered by visibleMin). + + var dimension = nodeModel.get('visualDimension'); + var dataExtent; + + // The same as area dimension. + if (!children || !children.length) { + dataExtent = [NaN, NaN]; + } + else if (dimension === 'value' && orderBy) { + dataExtent = [ + children[children.length - 1].getValue(), + children[0].getValue() + ]; + orderBy === 'asc' && dataExtent.reverse(); + } + // Other dimension. + else { + var dataExtent = [Infinity, -Infinity]; + zrUtil.each(children, function (child) { + var value = child.getValue(dimension); + value < dataExtent[0] && (dataExtent[0] = value); + value > dataExtent[1] && (dataExtent[1] = value); + }); + } + + return {sum: sum, dataExtent: dataExtent}; + } + + /** + * Computes the score for the specified row, + * as the worst aspect ratio. + */ + function worst(row, rowFixedLength, ratio) { + var areaMax = 0; + var areaMin = Infinity; + + for (var i = 0, area, len = row.length; i < len; i++) { + area = row[i].getLayout().area; + if (area) { + area < areaMin && (areaMin = area); + area > areaMax && (areaMax = area); + } + } + + var squareArea = row.area * row.area; + var f = rowFixedLength * rowFixedLength * ratio; + + return squareArea + ? mathMax( + (f * areaMax) / squareArea, + squareArea / (f * areaMin) + ) + : Infinity; + } + + /** + * Positions the specified row of nodes. Modifies `rect`. + */ + function position(row, rowFixedLength, rect, halfGapWidth, flush) { + // When rowFixedLength === rect.width, + // it is horizontal subdivision, + // rowFixedLength is the width of the subdivision, + // rowOtherLength is the height of the subdivision, + // and nodes will be positioned from left to right. + + // wh[idx0WhenH] means: when horizontal, + // wh[idx0WhenH] => wh[0] => 'width'. + // xy[idx1WhenH] => xy[1] => 'y'. + var idx0WhenH = rowFixedLength === rect.width ? 0 : 1; + var idx1WhenH = 1 - idx0WhenH; + var xy = ['x', 'y']; + var wh = ['width', 'height']; + + var last = rect[xy[idx0WhenH]]; + var rowOtherLength = rowFixedLength + ? row.area / rowFixedLength : 0; + + if (flush || rowOtherLength > rect[wh[idx1WhenH]]) { + rowOtherLength = rect[wh[idx1WhenH]]; // over+underflow + } + for (var i = 0, rowLen = row.length; i < rowLen; i++) { + var node = row[i]; + var nodeLayout = {}; + var step = rowOtherLength + ? node.getLayout().area / rowOtherLength : 0; + + var wh1 = nodeLayout[wh[idx1WhenH]] = mathMax(rowOtherLength - 2 * halfGapWidth, 0); + + // We use Math.max/min to avoid negative width/height when considering gap width. + var remain = rect[xy[idx0WhenH]] + rect[wh[idx0WhenH]] - last; + var modWH = (i === rowLen - 1 || remain < step) ? remain : step; + var wh0 = nodeLayout[wh[idx0WhenH]] = mathMax(modWH - 2 * halfGapWidth, 0); + + nodeLayout[xy[idx1WhenH]] = rect[xy[idx1WhenH]] + mathMin(halfGapWidth, wh1 / 2); + nodeLayout[xy[idx0WhenH]] = last + mathMin(halfGapWidth, wh0 / 2); + + last += modWH; + node.setLayout(nodeLayout, true); + } + + rect[xy[idx1WhenH]] += rowOtherLength; + rect[wh[idx1WhenH]] -= rowOtherLength; + } + + // Return [containerWidth, containerHeight] as defualt. + function estimateRootSize(seriesModel, targetInfo, containerWidth, containerHeight) { + // If targetInfo.node exists, we zoom to the node, + // so estimate whold width and heigth by target node. + var currNode = (targetInfo || {}).node; + var defaultSize = [containerWidth, containerHeight]; + + if (!currNode || currNode === seriesModel.getViewRoot()) { + return defaultSize; + } + + var parent; + var viewArea = containerWidth * containerHeight; + var area = viewArea * seriesModel.get('zoomToNodeRatio'); + + while (parent = currNode.parentNode) { // jshint ignore:line + var sum = 0; + var siblings = parent.children; + + for (var i = 0, len = siblings.length; i < len; i++) { + sum += siblings[i].getValue(); + } + var currNodeValue = currNode.getValue(); + if (currNodeValue === 0) { + return defaultSize; + } + area *= sum / currNodeValue; + + var borderWidth = parent.getModel('itemStyle.normal').get('borderWidth'); + + if (isFinite(borderWidth)) { + // Considering border, suppose aspect ratio is 1. + area += 4 * borderWidth * borderWidth + 4 * borderWidth * Math.pow(area, 0.5); + } + + area > numberUtil.MAX_SAFE_INTEGER && (area = numberUtil.MAX_SAFE_INTEGER); + + currNode = parent; + } + + area < viewArea && (area = viewArea); + var scale = Math.pow(area / viewArea, 0.5); + + return [containerWidth * scale, containerHeight * scale]; + } + + // Root postion base on coord of containerGroup + function calculateRootPosition(layoutInfo, rootRect, targetInfo) { + if (rootRect) { + return {x: rootRect.x, y: rootRect.y}; + } + + var defaultPosition = {x: 0, y: 0}; + if (!targetInfo) { + return defaultPosition; + } - graphic.Group = require('zrender/container/Group'); + // If targetInfo is fetched by 'retrieveTargetInfo', + // old tree and new tree are the same tree, + // so the node still exists and we can visit it. - graphic.Image = require('zrender/graphic/Image'); + var targetNode = targetInfo.node; + var layout = targetNode.getLayout(); - graphic.Text = require('zrender/graphic/Text'); + if (!layout) { + return defaultPosition; + } - graphic.Circle = require('zrender/graphic/shape/Circle'); - - graphic.Sector = require('zrender/graphic/shape/Sector'); - - graphic.Polygon = require('zrender/graphic/shape/Polygon'); - - graphic.Polyline = require('zrender/graphic/shape/Polyline'); - - graphic.Rect = require('zrender/graphic/shape/Rect'); - - graphic.Line = require('zrender/graphic/shape/Line'); - - graphic.BezierCurve = require('zrender/graphic/shape/BezierCurve'); - - graphic.Arc = require('zrender/graphic/shape/Arc'); - - graphic.LinearGradient = require('zrender/graphic/LinearGradient'); - - graphic.RadialGradient = require('zrender/graphic/RadialGradient'); - - graphic.BoundingRect = require('zrender/core/BoundingRect'); - - /** - * Extend shape with parameters - */ - graphic.extendShape = function (opts) { - return Path.extend(opts); - }; - - /** - * Extend path - */ - graphic.extendPath = function (pathData, opts) { - return pathTool.extendFromString(pathData, opts); - }; - - /** - * Create a path element from path data string - * @param {string} pathData - * @param {Object} opts - * @param {module:zrender/core/BoundingRect} rect - * @param {string} [layout=cover] 'center' or 'cover' - */ - graphic.makePath = function (pathData, opts, rect, layout) { - var path = pathTool.createFromString(pathData, opts); - var boundingRect = path.getBoundingRect(); - if (rect) { - var aspect = boundingRect.width / boundingRect.height; - - if (layout === 'center') { - // Set rect to center, keep width / height ratio. - var width = rect.height * aspect; - var height; - if (width <= rect.width) { - height = rect.height; - } - else { - width = rect.width; - height = width / aspect; - } - var cx = rect.x + rect.width / 2; - var cy = rect.y + rect.height / 2; - - rect.x = cx - width / 2; - rect.y = cy - height / 2; - rect.width = width; - rect.height = height; - } - - this.resizePath(path, rect); - } - return path; - }; - - graphic.mergePath = pathTool.mergePath, - - /** - * Resize a path to fit the rect - * @param {module:zrender/graphic/Path} path - * @param {Object} rect - */ - graphic.resizePath = function (path, rect) { - if (!path.applyTransform) { - return; - } - - var pathRect = path.getBoundingRect(); - - var m = pathRect.calculateTransform(rect); - - path.applyTransform(m); - }; - - /** - * Sub pixel optimize line for canvas - * - * @param {Object} param - * @param {Object} [param.shape] - * @param {number} [param.shape.x1] - * @param {number} [param.shape.y1] - * @param {number} [param.shape.x2] - * @param {number} [param.shape.y2] - * @param {Object} [param.style] - * @param {number} [param.style.lineWidth] - * @return {Object} Modified param - */ - graphic.subPixelOptimizeLine = function (param) { - var subPixelOptimize = graphic.subPixelOptimize; - var shape = param.shape; - var lineWidth = param.style.lineWidth; - - if (round(shape.x1 * 2) === round(shape.x2 * 2)) { - shape.x1 = shape.x2 = subPixelOptimize(shape.x1, lineWidth, true); - } - if (round(shape.y1 * 2) === round(shape.y2 * 2)) { - shape.y1 = shape.y2 = subPixelOptimize(shape.y1, lineWidth, true); - } - return param; - }; - - /** - * Sub pixel optimize rect for canvas - * - * @param {Object} param - * @param {Object} [param.shape] - * @param {number} [param.shape.x] - * @param {number} [param.shape.y] - * @param {number} [param.shape.width] - * @param {number} [param.shape.height] - * @param {Object} [param.style] - * @param {number} [param.style.lineWidth] - * @return {Object} Modified param - */ - graphic.subPixelOptimizeRect = function (param) { - var subPixelOptimize = graphic.subPixelOptimize; - var shape = param.shape; - var lineWidth = param.style.lineWidth; - var originX = shape.x; - var originY = shape.y; - var originWidth = shape.width; - var originHeight = shape.height; - shape.x = subPixelOptimize(shape.x, lineWidth, true); - shape.y = subPixelOptimize(shape.y, lineWidth, true); - shape.width = Math.max( - subPixelOptimize(originX + originWidth, lineWidth, false) - shape.x, - originWidth === 0 ? 0 : 1 - ); - shape.height = Math.max( - subPixelOptimize(originY + originHeight, lineWidth, false) - shape.y, - originHeight === 0 ? 0 : 1 - ); - return param; - }; - - /** - * Sub pixel optimize for canvas - * - * @param {number} position Coordinate, such as x, y - * @param {number} lineWidth Should be nonnegative integer. - * @param {boolean=} positiveOrNegative Default false (negative). - * @return {number} Optimized position. - */ - graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) { - // Assure that (position + lineWidth / 2) is near integer edge, - // otherwise line will be fuzzy in canvas. - var doubledPosition = round(position * 2); - return (doubledPosition + round(lineWidth)) % 2 === 0 - ? doubledPosition / 2 - : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2; - }; - - /** - * @private - */ - function doSingleEnterHover(el) { - if (el.__isHover) { - return; - } - if (el.__hoverStlDirty) { - var stroke = el.style.stroke; - var fill = el.style.fill; - - // Create hoverStyle on mouseover - var hoverStyle = el.__hoverStl; - hoverStyle.fill = hoverStyle.fill - || (fill instanceof Gradient ? fill : colorTool.lift(fill, -0.1)); - hoverStyle.stroke = hoverStyle.stroke - || (stroke instanceof Gradient ? stroke : colorTool.lift(stroke, -0.1)); - - var normalStyle = {}; - for (var name in hoverStyle) { - if (hoverStyle.hasOwnProperty(name)) { - normalStyle[name] = el.style[name]; - } - } - - el.__normalStl = normalStyle; - - el.__hoverStlDirty = false; - } - el.setStyle(el.__hoverStl); - el.z2 += 1; - - el.__isHover = true; - } - - /** - * @inner - */ - function doSingleLeaveHover(el) { - if (!el.__isHover) { - return; - } - - var normalStl = el.__normalStl; - normalStl && el.setStyle(normalStl); - el.z2 -= 1; - - el.__isHover = false; - } - - /** - * @inner - */ - function doEnterHover(el) { - el.type === 'group' - ? el.traverse(function (child) { - if (child.type !== 'group') { - doSingleEnterHover(child); - } - }) - : doSingleEnterHover(el); - } - - function doLeaveHover(el) { - el.type === 'group' - ? el.traverse(function (child) { - if (child.type !== 'group') { - doSingleLeaveHover(child); - } - }) - : doSingleLeaveHover(el); - } - - /** - * @inner - */ - function setElementHoverStl(el, hoverStl) { - // If element has sepcified hoverStyle, then use it instead of given hoverStyle - // Often used when item group has a label element and it's hoverStyle is different - el.__hoverStl = el.hoverStyle || hoverStl; - el.__hoverStlDirty = true; - } - - /** - * @inner - */ - function onElementMouseOver() { - // Only if element is not in emphasis status - !this.__isEmphasis && doEnterHover(this); - } - - /** - * @inner - */ - function onElementMouseOut() { - // Only if element is not in emphasis status - !this.__isEmphasis && doLeaveHover(this); - } - - /** - * @inner - */ - function enterEmphasis() { - this.__isEmphasis = true; - doEnterHover(this); - } - - /** - * @inner - */ - function leaveEmphasis() { - this.__isEmphasis = false; - doLeaveHover(this); - } - - /** - * Set hover style of element - * @param {module:zrender/Element} el - * @param {Object} [hoverStyle] - */ - graphic.setHoverStyle = function (el, hoverStyle) { - hoverStyle = hoverStyle || {}; - el.type === 'group' - ? el.traverse(function (child) { - if (child.type !== 'group') { - setElementHoverStl(child, hoverStyle); - } - }) - : setElementHoverStl(el, hoverStyle); - // Remove previous bound handlers - el.on('mouseover', onElementMouseOver) - .on('mouseout', onElementMouseOut); - - // Emphasis, normal can be triggered manually - el.on('emphasis', enterEmphasis) - .on('normal', leaveEmphasis); - }; - - /** - * Set text option in the style - * @param {Object} textStyle - * @param {module:echarts/model/Model} labelModel - * @param {string} color - */ - graphic.setText = function (textStyle, labelModel, color) { - var labelPosition = labelModel.getShallow('position') || 'inside'; - var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color; - var textStyleModel = labelModel.getModel('textStyle'); - zrUtil.extend(textStyle, { - textDistance: labelModel.getShallow('distance') || 5, - textFont: textStyleModel.getFont(), - textPosition: labelPosition, - textFill: textStyleModel.getTextColor() || labelColor - }); - }; - - function animateOrSetProps(isUpdate, el, props, animatableModel, cb) { - var postfix = isUpdate ? 'Update' : ''; - var duration = animatableModel - && animatableModel.getShallow('animationDuration' + postfix); - var animationEasing = animatableModel - && animatableModel.getShallow('animationEasing' + postfix); - - animatableModel && animatableModel.getShallow('animation') - ? el.animateTo(props, duration, animationEasing, cb) - : (el.attr(props), cb && cb()); - } - /** - * Update graphic element properties with or without animation according to the configuration in series - * @param {module:zrender/Element} el - * @param {Object} props - * @param {module:echarts/model/Model} [animatableModel] - * @param {Function} cb - */ - graphic.updateProps = zrUtil.curry(animateOrSetProps, true); - - /** - * Init graphic element properties with or without animation according to the configuration in series - * @param {module:zrender/Element} el - * @param {Object} props - * @param {module:echarts/model/Model} [animatableModel] - * @param {Function} cb - */ - graphic.initProps = zrUtil.curry(animateOrSetProps, false); - - /** - * Get transform matrix of target (param target), - * in coordinate of its ancestor (param ancestor) - * - * @param {module:zrender/mixin/Transformable} target - * @param {module:zrender/mixin/Transformable} ancestor - */ - graphic.getTransform = function (target, ancestor) { - var mat = matrix.identity([]); - - while (target && target !== ancestor) { - matrix.mul(mat, target.getLocalTransform(), mat); - target = target.parent; - } - - return mat; - }; - - /** - * Apply transform to an vertex. - * @param {Array.} vertex [x, y] - * @param {Array.} transform Transform matrix: like [1, 0, 0, 1, 0, 0] - * @param {boolean=} invert Whether use invert matrix. - * @return {Array.} [x, y] - */ - graphic.applyTransform = function (vertex, transform, invert) { - if (invert) { - transform = matrix.invert([], transform); - } - return vector.applyTransform([], vertex, transform); - }; - - /** - * @param {string} direction 'left' 'right' 'top' 'bottom' - * @param {Array.} transform Transform matrix: like [1, 0, 0, 1, 0, 0] - * @param {boolean=} invert Whether use invert matrix. - * @return {string} Transformed direction. 'left' 'right' 'top' 'bottom' - */ - graphic.transformDirection = function (direction, transform, invert) { - - // Pick a base, ensure that transform result will not be (0, 0). - var hBase = (transform[4] === 0 || transform[5] === 0 || transform[0] === 0) - ? 1 : Math.abs(2 * transform[4] / transform[0]); - var vBase = (transform[4] === 0 || transform[5] === 0 || transform[2] === 0) - ? 1 : Math.abs(2 * transform[4] / transform[2]); - - var vertex = [ - direction === 'left' ? -hBase : direction === 'right' ? hBase : 0, - direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0 - ]; - - vertex = graphic.applyTransform(vertex, transform, invert); - - return Math.abs(vertex[0]) > Math.abs(vertex[1]) - ? (vertex[0] > 0 ? 'right' : 'left') - : (vertex[1] > 0 ? 'bottom' : 'top'); - }; - - return graphic; -}); -/** - * echarts设备环境识别 - * - * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。 - * @author firede[firede@firede.us] - * @desc thanks zepto. - */ -define('zrender/core/env',[],function () { - var env = {}; - if (typeof navigator === 'undefined') { - // In node - env = { - browser: {}, - os: {}, - node: true, - // Assume canvas is supported - canvasSupported: true - }; - } - else { - env = detect(navigator.userAgent); - } - - return env; - - // Zepto.js - // (c) 2010-2013 Thomas Fuchs - // Zepto.js may be freely distributed under the MIT license. - - function detect(ua) { - var os = {}; - var browser = {}; - var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/); - var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); - var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); - var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); - var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/); - var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/); - var touchpad = webos && ua.match(/TouchPad/); - var kindle = ua.match(/Kindle\/([\d.]+)/); - var silk = ua.match(/Silk\/([\d._]+)/); - var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/); - var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/); - var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/); - var playbook = ua.match(/PlayBook/); - var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/); - var firefox = ua.match(/Firefox\/([\d.]+)/); - var safari = webkit && ua.match(/Mobile\//) && !chrome; - var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome; - var ie = ua.match(/MSIE\s([\d.]+)/) - // IE 11 Trident/7.0; rv:11.0 - || ua.match(/Trident\/.+?rv:(([\d.]+))/); - var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+ - - // Todo: clean this up with a better OS/browser seperation: - // - discern (more) between multiple browsers on android - // - decide if kindle fire in silk mode is android or not - // - Firefox on Android doesn't specify the Android version - // - possibly devide in os, device and browser hashes - - if (browser.webkit = !!webkit) browser.version = webkit[1]; - - if (android) os.android = true, os.version = android[2]; - if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.'); - if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.'); - if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null; - if (webos) os.webos = true, os.version = webos[2]; - if (touchpad) os.touchpad = true; - if (blackberry) os.blackberry = true, os.version = blackberry[2]; - if (bb10) os.bb10 = true, os.version = bb10[2]; - if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2]; - if (playbook) browser.playbook = true; - if (kindle) os.kindle = true, os.version = kindle[1]; - if (silk) browser.silk = true, browser.version = silk[1]; - if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true; - if (chrome) browser.chrome = true, browser.version = chrome[1]; - if (firefox) browser.firefox = true, browser.version = firefox[1]; - if (ie) browser.ie = true, browser.version = ie[1]; - if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true; - if (webview) browser.webview = true; - if (ie) browser.ie = true, browser.version = ie[1]; - if (edge) browser.edge = true, browser.version = edge[1]; - - os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) || - (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/))); - 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/)))); - - return { - browser: browser, - os: os, - node: false, - // 原生canvas支持,改极端点了 - // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9) - canvasSupported : document.createElement('canvas').getContext ? true : false, - // @see - // works on most browsers - // IE10/11 does not support touch event, and MS Edge supports them but not by - // default, so we dont check navigator.maxTouchPoints for them here. - touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge, - // . - pointerEventsSupported: 'onpointerdown' in window - // Firefox supports pointer but not by default, - // only MS browsers are reliable on pointer events currently. - && (browser.edge || (browser.ie && browser.version >= 10)) - }; - } -}); -/** - * 事件辅助类 - * @module zrender/core/event - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - */ -define('zrender/core/event',['require','../mixin/Eventful'],function(require) { - - - - var Eventful = require('../mixin/Eventful'); - - var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener; - - function getBoundingClientRect(el) { - // BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect - return el.getBoundingClientRect ? el.getBoundingClientRect() : { left: 0, top: 0}; - } - /** - * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标 - */ - function normalizeEvent(el, e) { - - e = e || window.event; - - if (e.zrX != null) { - return e; - } - - var eventType = e.type; - var isTouch = eventType && eventType.indexOf('touch') >= 0; - - if (!isTouch) { - var box = getBoundingClientRect(el); - e.zrX = e.clientX - box.left; - e.zrY = e.clientY - box.top; - e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3; - } - else { - var touch = eventType != 'touchend' - ? e.targetTouches[0] - : e.changedTouches[0]; - if (touch) { - var rBounding = getBoundingClientRect(el); - // touch事件坐标是全屏的~ - e.zrX = touch.clientX - rBounding.left; - e.zrY = touch.clientY - rBounding.top; - } - } - - return e; - } - - function addEventListener(el, name, handler) { - if (isDomLevel2) { - el.addEventListener(name, handler); - } - else { - el.attachEvent('on' + name, handler); - } - } - - function removeEventListener(el, name, handler) { - if (isDomLevel2) { - el.removeEventListener(name, handler); - } - else { - el.detachEvent('on' + name, handler); - } - } - - /** - * 停止冒泡和阻止默认行为 - * @memberOf module:zrender/core/event - * @method - * @param {Event} e : event对象 - */ - var stop = isDomLevel2 - ? function (e) { - e.preventDefault(); - e.stopPropagation(); - e.cancelBubble = true; - } - : function (e) { - e.returnValue = false; - e.cancelBubble = true; - }; - - return { - normalizeEvent: normalizeEvent, - addEventListener: addEventListener, - removeEventListener: removeEventListener, - - stop: stop, - // 做向上兼容 - Dispatcher: Eventful - }; -}); + // Transform coord from local to container. + var targetCenter = [layout.width / 2, layout.height / 2]; + var node = targetNode; + while (node) { + var nodeLayout = node.getLayout(); + targetCenter[0] += nodeLayout.x; + targetCenter[1] += nodeLayout.y; + node = node.parentNode; + } -// TODO Draggable for group -// FIXME Draggable on element which has parent rotation or scale -define('zrender/mixin/Draggable',['require'],function (require) { - function Draggable() { + return { + x: layoutInfo.width / 2 - targetCenter[0], + y: layoutInfo.height / 2 - targetCenter[1] + }; + } - this.on('mousedown', this._dragStart, this); - this.on('mousemove', this._drag, this); - this.on('mouseup', this._dragEnd, this); - this.on('globalout', this._dragEnd, this); - // this._dropTarget = null; - // this._draggingTarget = null; + // Mark invisible nodes for prunning when visual coding and rendering. + // Prunning depends on layout and root position, so we have to do it after them. + function prunning(node, clipRect) { + var nodeLayout = node.getLayout(); + + node.setLayout({invisible: !clipRect.intersect(nodeLayout)}, true); + + var viewChildren = node.viewChildren || []; + for (var i = 0, len = viewChildren.length; i < len; i++) { + // Transform to child coordinate. + var childClipRect = new BoundingRect( + clipRect.x - nodeLayout.x, + clipRect.y - nodeLayout.y, + clipRect.width, + clipRect.height + ); + prunning(viewChildren[i], childClipRect); + } + } + + module.exports = update; + + +/***/ }, +/* 189 */ +/***/ function(module, exports, __webpack_require__) { + + + + var echarts = __webpack_require__(1); + var zrUtil = __webpack_require__(3); + + __webpack_require__(190); + __webpack_require__(193); + + __webpack_require__(197); + + echarts.registerProcessor('filter', __webpack_require__(198)); + + echarts.registerVisualCoding('chart', zrUtil.curry( + __webpack_require__(103), 'graph', 'circle', null + )); + echarts.registerVisualCoding('chart', __webpack_require__(199)); + + echarts.registerLayout(__webpack_require__(200)); + echarts.registerLayout(__webpack_require__(202)); + echarts.registerLayout(__webpack_require__(204)); + + // Graph view coordinate system + echarts.registerCoordinateSystem('graphView', { + create: __webpack_require__(206) + }); + + +/***/ }, +/* 190 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var List = __webpack_require__(94); + var zrUtil = __webpack_require__(3); + + var createGraphFromNodeEdge = __webpack_require__(191); + + var GraphSeries = __webpack_require__(1).extendSeriesModel({ + + type: 'series.graph', + + init: function (option) { + GraphSeries.superApply(this, 'init', arguments); + + // Provide data for legend select + this.legendDataProvider = function () { + return this._categoriesData; + }; + + this._updateCategoriesData(); + }, + + mergeOption: function (option) { + GraphSeries.superApply(this, 'mergeOption', arguments); + + this._updateCategoriesData(); + }, + + getInitialData: function (option, ecModel) { + var edges = option.edges || option.links; + var nodes = option.data || option.nodes; + if (nodes && edges) { + var graph = createGraphFromNodeEdge(nodes, edges, this, true); + var list = graph.data; + var self = this; + // Overwrite list.getItemModel to + list.wrapMethod('getItemModel', function (model) { + var categoriesModels = self._categoriesModels; + var categoryIdx = model.getShallow('category'); + var categoryModel = categoriesModels[categoryIdx]; + if (categoryModel) { + categoryModel.parentModel = model.parentModel; + model.parentModel = categoryModel; + } + return model; + }); + return list; + } + }, + + restoreData: function () { + GraphSeries.superApply(this, 'restoreData', arguments); + this.getGraph().restoreData(); + }, + + /** + * @return {module:echarts/data/Graph} + */ + getGraph: function () { + return this.getData().graph; + }, + + /** + * @return {module:echarts/data/List} + */ + getEdgeData: function () { + return this.getGraph().edgeData; + }, + + /** + * @return {module:echarts/data/List} + */ + getCategoriesData: function () { + return this._categoriesData; + }, + + _updateCategoriesData: function () { + var categories = zrUtil.map(this.option.categories || [], function (category) { + // Data must has value + return category.value != null ? category : zrUtil.extend({ + value: 0 + }, category); + }); + var categoriesData = new List(['value'], this); + categoriesData.initData(categories); + + this._categoriesData = categoriesData; + + this._categoriesModels = categoriesData.mapArray(function (idx) { + return categoriesData.getItemModel(idx, true); + }); + }, + + /** + * @param {number} zoom + */ + setRoamZoom: function (zoom) { + var roamDetail = this.option.roamDetail; + roamDetail && (roamDetail.zoom = zoom); + }, + + /** + * @param {number} x + * @param {number} y + */ + setRoamPan: function (x, y) { + var roamDetail = this.option.roamDetail; + if (roamDetail) { + roamDetail.x = x; + roamDetail.y = y; + } + }, + + defaultOption: { + zlevel: 0, + z: 2, + + color: ['#61a0a8', '#d14a61', '#fd9c35', '#675bba', '#fec42c', + '#dd4444', '#fd9c35', '#cd4870'], + + coordinateSystem: 'view', + + legendHoverLink: true, + + hoverAnimation: true, + + layout: null, + + // Configuration of force + force: { + initLayout: null, + repulsion: 50, + gravity: 0.1, + edgeLength: 30, + + layoutAnimation: true + }, + + left: 'center', + top: 'center', + // right: null, + // bottom: null, + // width: '80%', + // height: '80%', + + symbol: 'circle', + symbolSize: 10, + + draggable: false, + + roam: false, + roamDetail: { + x: 0, + y: 0, + zoom: 1 + }, + + // Symbol size scale ratio in roam + nodeScaleRatio: 0.6, + + // Line width scale ratio in roam + // edgeScaleRatio: 0.1, + + // categories: [], + + // data: [] + // Or + // nodes: [] + // + // links: [] + // Or + // edges: [] + + label: { + normal: { + show: false + }, + emphasis: { + show: true + } + }, + + itemStyle: { + normal: {}, + emphasis: {} + }, + + lineStyle: { + normal: { + color: '#aaa', + width: 1, + curveness: 0, + opacity: 0.5 + }, + emphasis: {} + } + } + }); + + module.exports = GraphSeries; + + +/***/ }, +/* 191 */ +/***/ function(module, exports, __webpack_require__) { + + + + var List = __webpack_require__(94); + var Graph = __webpack_require__(192); + var linkList = __webpack_require__(180); + var completeDimensions = __webpack_require__(96); + var zrUtil = __webpack_require__(3); + + module.exports = function (nodes, edges, hostModel, directed) { + var graph = new Graph(directed); + for (var i = 0; i < nodes.length; i++) { + graph.addNode(zrUtil.retrieve( + // Id, name, dataIndex + nodes[i].id, nodes[i].name, i + ), i); + } + + var linkNameList = []; + var validEdges = []; + for (var i = 0; i < edges.length; i++) { + var link = edges[i]; + // addEdge may fail when source or target not exists + if (graph.addEdge(link.source, link.target, i)) { + validEdges.push(link); + linkNameList.push(zrUtil.retrieve(link.id, link.source + ' - ' + link.target)); + } + } + + // FIXME + var dimensionNames = completeDimensions(['value'], nodes); + + var nodeData = new List(dimensionNames, hostModel); + var edgeData = new List(['value'], hostModel); + + nodeData.initData(nodes); + edgeData.initData(validEdges, linkNameList); + + graph.setEdgeData(edgeData); + + linkList.linkToGraph(nodeData, graph); + // Update dataIndex of nodes and edges because invalid edge may be removed + graph.update(); + + return graph; + }; + + +/***/ }, +/* 192 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Graph data structure + * + * @module echarts/data/Graph + * @author Yi Shen(https://www.github.com/pissang) + */ + + + var zrUtil = __webpack_require__(3); + + /** + * @alias module:echarts/data/Graph + * @constructor + * @param {boolean} directed + */ + var Graph = function(directed) { + /** + * 是否是有向图 + * @type {boolean} + * @private + */ + this._directed = directed || false; + + /** + * @type {Array.} + * @readOnly + */ + this.nodes = []; + + /** + * @type {Array.} + * @readOnly + */ + this.edges = []; + + /** + * @type {Object.} + * @private + */ + this._nodesMap = {}; + /** + * @type {Object.} + * @private + */ + this._edgesMap = {}; + + /** + * @type {module:echarts/data/List} + * @readOnly + */ + this.data; + + /** + * @type {module:echarts/data/List} + * @readOnly + */ + this.edgeData; + }; + + var graphProto = Graph.prototype; + /** + * @type {string} + */ + graphProto.type = 'graph'; + + /** + * If is directed graph + * @return {boolean} + */ + graphProto.isDirected = function () { + return this._directed; + }; + + /** + * Add a new node + * @param {string} id + * @param {number} [dataIndex] + */ + graphProto.addNode = function (id, dataIndex) { + var nodesMap = this._nodesMap; + + if (nodesMap[id]) { + return; + } + + var node = new Node(id, dataIndex); + node.hostGraph = this; + + this.nodes.push(node); + + nodesMap[id] = node; + return node; + }; + + /** + * Get node by data index + * @param {number} dataIndex + * @return {module:echarts/data/Graph~Node} + */ + graphProto.getNodeByIndex = function (dataIndex) { + var rawIdx = this.data.getRawIndex(dataIndex); + return this.nodes[rawIdx]; + }; + /** + * Get node by id + * @param {string} id + * @return {module:echarts/data/Graph.Node} + */ + graphProto.getNodeById = function (id) { + return this._nodesMap[id]; + }; + + /** + * Add a new edge + * @param {string|module:echarts/data/Graph.Node} n1 + * @param {string|module:echarts/data/Graph.Node} n2 + * @param {number} [dataIndex=-1] + * @return {module:echarts/data/Graph.Edge} + */ + graphProto.addEdge = function (n1, n2, dataIndex) { + var nodesMap = this._nodesMap; + var edgesMap = this._edgesMap; + + if (!(n1 instanceof Node)) { + n1 = nodesMap[n1]; + } + if (!(n2 instanceof Node)) { + n2 = nodesMap[n2]; + } + if (!n1 || !n2) { + return; + } + + var key = n1.id + '-' + n2.id; + // PENDING + if (edgesMap[key]) { + return; + } + + var edge = new Edge(n1, n2, dataIndex); + edge.hostGraph = this; + + if (this._directed) { + n1.outEdges.push(edge); + n2.inEdges.push(edge); + } + n1.edges.push(edge); + if (n1 !== n2) { + n2.edges.push(edge); + } + + this.edges.push(edge); + edgesMap[key] = edge; + + return edge; + }; + + /** + * Get edge by data index + * @param {number} dataIndex + * @return {module:echarts/data/Graph~Node} + */ + graphProto.getEdgeByIndex = function (dataIndex) { + var rawIdx = this.edgeData.getRawIndex(dataIndex); + return this.edges[rawIdx]; + }; + /** + * Get edge by two linked nodes + * @param {module:echarts/data/Graph.Node|string} n1 + * @param {module:echarts/data/Graph.Node|string} n2 + * @return {module:echarts/data/Graph.Edge} + */ + graphProto.getEdge = function (n1, n2) { + if (n1 instanceof Node) { + n1 = n1.id; + } + if (n2 instanceof Node) { + n2 = n2.id; + } + + var edgesMap = this._edgesMap; + + if (this._directed) { + return edgesMap[n1 + '-' + n2]; + } else { + return edgesMap[n1 + '-' + n2] + || edgesMap[n2 + '-' + n1]; + } + }; + + /** + * Iterate all nodes + * @param {Function} cb + * @param {*} [context] + */ + graphProto.eachNode = function (cb, context) { + var nodes = this.nodes; + var len = nodes.length; + for (var i = 0; i < len; i++) { + if (nodes[i].dataIndex >= 0) { + cb.call(context, nodes[i], i); + } + } + }; + + /** + * Iterate all edges + * @param {Function} cb + * @param {*} [context] + */ + graphProto.eachEdge = function (cb, context) { + var edges = this.edges; + var len = edges.length; + for (var i = 0; i < len; i++) { + if (edges[i].dataIndex >= 0 + && edges[i].node1.dataIndex >= 0 + && edges[i].node2.dataIndex >= 0 + ) { + cb.call(context, edges[i], i); + } + } + }; + + /** + * Breadth first traverse + * @param {Function} cb + * @param {module:echarts/data/Graph.Node} startNode + * @param {string} [direction='none'] 'none'|'in'|'out' + * @param {*} [context] + */ + graphProto.breadthFirstTraverse = function ( + cb, startNode, direction, context + ) { + if (!(startNode instanceof Node)) { + startNode = this._nodesMap[startNode]; + } + if (!startNode) { + return; + } + + var edgeType = direction === 'out' + ? 'outEdges' : (direction === 'in' ? 'inEdges' : 'edges'); + + for (var i = 0; i < this.nodes.length; i++) { + this.nodes[i].__visited = false; + } + + if (cb.call(context, startNode, null)) { + return; + } + + var queue = [startNode]; + while (queue.length) { + var currentNode = queue.shift(); + var edges = currentNode[edgeType]; + + for (var i = 0; i < edges.length; i++) { + var e = edges[i]; + var otherNode = e.node1 === currentNode + ? e.node2 : e.node1; + if (!otherNode.__visited) { + if (cb.call(otherNode, otherNode, currentNode)) { + // Stop traversing + return; + } + queue.push(otherNode); + otherNode.__visited = true; + } + } + } + }; + + // TODO + // graphProto.depthFirstTraverse = function ( + // cb, startNode, direction, context + // ) { + + // }; + + // Filter update + graphProto.update = function () { + var data = this.data; + var edgeData = this.edgeData; + var nodes = this.nodes; + var edges = this.edges; + + for (var i = 0, len = nodes.length; i < len; i++) { + nodes[i].dataIndex = -1; + } + for (var i = 0, len = data.count(); i < len; i++) { + nodes[data.getRawIndex(i)].dataIndex = i; + } + + edgeData.filterSelf(function (idx) { + var edge = edges[edgeData.getRawIndex(idx)]; + return edge.node1.dataIndex >= 0 && edge.node2.dataIndex >= 0; + }); + + // Update edge + for (var i = 0, len = edges.length; i < len; i++) { + edges[i].dataIndex = -1; + } + for (var i = 0, len = edgeData.count(); i < len; i++) { + edges[edgeData.getRawIndex(i)].dataIndex = i; + } + }; + + /** + * Set edge data + * @param {module:echarts/data/List} edgeData + */ + graphProto.setEdgeData = function (edgeData) { + this.edgeData = edgeData; + this._edgeDataSaved = edgeData.cloneShallow(); + }; + + graphProto.restoreData = function () { + this.edgeData = this._edgeDataSaved.cloneShallow(); + }; + + /** + * @return {module:echarts/data/Graph} + */ + graphProto.clone = function () { + var graph = new Graph(this._directed); + var nodes = this.nodes; + var edges = this.edges; + for (var i = 0; i < nodes.length; i++) { + graph.addNode(nodes[i].id, nodes[i].dataIndex); + } + for (var i = 0; i < edges.length; i++) { + var e = edges[i]; + graph.addEdge(e.node1.id, e.node2.id, e.dataIndex); + } + return graph; + }; + + + /** + * @alias module:echarts/data/Graph.Node + */ + function Node(id, dataIndex) { + /** + * @type {string} + */ + this.id = id == null ? '' : id; + + /** + * @type {Array.} + */ + this.inEdges = []; + /** + * @type {Array.} + */ + this.outEdges = []; + /** + * @type {Array.} + */ + this.edges = []; + /** + * @type {module:echarts/data/Graph} + */ + this.hostGraph; + + /** + * @type {number} + */ + this.dataIndex = dataIndex == null ? -1 : dataIndex; + } + + Node.prototype = { + + constructor: Node, + + /** + * @return {number} + */ + degree: function () { + return this.edges.length; + }, + + /** + * @return {number} + */ + inDegree: function () { + return this.inEdges.length; + }, + + /** + * @return {number} + */ + outDegree: function () { + return this.outEdges.length; + }, + + /** + * @param {string} [path] + * @return {module:echarts/model/Model} + */ + getModel: function (path) { + if (this.dataIndex < 0) { + return; + } + var graph = this.hostGraph; + var itemModel = graph.data.getItemModel(this.dataIndex); + + return itemModel.getModel(path); + } + }; + + /** + * 图边 + * @alias module:echarts/data/Graph.Edge + * @param {module:echarts/data/Graph.Node} n1 + * @param {module:echarts/data/Graph.Node} n2 + * @param {number} [dataIndex=-1] + */ + function Edge(n1, n2, dataIndex) { + + /** + * 节点1,如果是有向图则为源节点 + * @type {module:echarts/data/Graph.Node} + */ + this.node1 = n1; + + /** + * 节点2,如果是有向图则为目标节点 + * @type {module:echarts/data/Graph.Node} + */ + this.node2 = n2; + + this.dataIndex = dataIndex == null ? -1 : dataIndex; + } + + /** + * @param {string} [path] + * @return {module:echarts/model/Model} + */ + Edge.prototype.getModel = function (path) { + if (this.dataIndex < 0) { + return; + } + var graph = this.hostGraph; + var itemModel = graph.edgeData.getItemModel(this.dataIndex); + + return itemModel.getModel(path); + }; + + var createGraphDataProxyMixin = function (hostName, dataName) { + return { + /** + * @param {string=} [dimension='value'] Default 'value'. can be 'a', 'b', 'c', 'd', 'e'. + * @return {number} + */ + getValue: function (dimension) { + var data = this[hostName][dataName]; + return data.get(data.getDimension(dimension || 'value'), this.dataIndex); + }, + + /** + * @param {Object|string} key + * @param {*} [value] + */ + setVisual: function (key, value) { + this.dataIndex >= 0 + && this[hostName][dataName].setItemVisual(this.dataIndex, key, value); + }, + + /** + * @param {string} key + * @return {boolean} + */ + getVisual: function (key, ignoreParent) { + return this[hostName][dataName].getItemVisual(this.dataIndex, key, ignoreParent); + }, + + /** + * @param {Object} layout + * @return {boolean} [merge=false] + */ + setLayout: function (layout, merge) { + this.dataIndex >= 0 + && this[hostName][dataName].setItemLayout(this.dataIndex, layout, merge); + }, + + /** + * @return {Object} + */ + getLayout: function () { + return this[hostName][dataName].getItemLayout(this.dataIndex); + }, + + /** + * @return {module:zrender/Element} + */ + getGraphicEl: function () { + return this[hostName][dataName].getItemGraphicEl(this.dataIndex); + }, + + /** + * @return {number} + */ + getRawIndex: function () { + return this[hostName][dataName].getRawIndex(this.dataIndex); + } + }; + }; + + zrUtil.mixin(Node, createGraphDataProxyMixin('hostGraph', 'data')); + zrUtil.mixin(Edge, createGraphDataProxyMixin('hostGraph', 'edgeData')); + + Graph.Node = Node; + Graph.Edge = Edge; + + module.exports = Graph; + + +/***/ }, +/* 193 */ +/***/ function(module, exports, __webpack_require__) { + + + + + var SymbolDraw = __webpack_require__(98); + var LineDraw = __webpack_require__(194); + var RoamController = __webpack_require__(159); + + var modelUtil = __webpack_require__(5); + var graphic = __webpack_require__(42); + + __webpack_require__(1).extendChartView({ + + type: 'graph', + + init: function (ecModel, api) { + var symbolDraw = new SymbolDraw(); + var lineDraw = new LineDraw(); + var group = this.group; + + var controller = new RoamController(api.getZr(), group); + + group.add(symbolDraw.group); + group.add(lineDraw.group); + + this._symbolDraw = symbolDraw; + this._lineDraw = lineDraw; + this._controller = controller; + + this._firstRender = true; + }, + + render: function (seriesModel, ecModel, api) { + var coordSys = seriesModel.coordinateSystem; + // Only support view and geo coordinate system + if (coordSys.type !== 'geo' && coordSys.type !== 'view') { + return; + } + + var data = seriesModel.getData(); + this._model = seriesModel; + + var symbolDraw = this._symbolDraw; + var lineDraw = this._lineDraw; + + symbolDraw.updateData(data); + + var edgeData = data.graph.edgeData; + var rawOption = seriesModel.option; + var formatModel = modelUtil.createDataFormatModel( + seriesModel, edgeData, rawOption.edges || rawOption.links + ); + formatModel.formatTooltip = function (dataIndex) { + var params = this.getDataParams(dataIndex); + var rawDataOpt = params.data; + var html = rawDataOpt.source + ' > ' + rawDataOpt.target; + if (params.value) { + html += ':' + params.value; + } + return html; + }; + lineDraw.updateData(edgeData, null, null); + edgeData.eachItemGraphicEl(function (el) { + el.traverse(function (child) { + child.hostModel = formatModel; + }); + }); + + // Save the original lineWidth + data.graph.eachEdge(function (edge) { + edge.__lineWidth = edge.getModel('lineStyle.normal').get('width'); + }); + + var group = this.group; + var groupNewProp = { + position: coordSys.position, + scale: coordSys.scale + }; + if (this._firstRender) { + group.attr(groupNewProp); + } + else { + graphic.updateProps(group, groupNewProp, seriesModel); + } + + this._nodeScaleRatio = seriesModel.get('nodeScaleRatio'); + // this._edgeScaleRatio = seriesModel.get('edgeScaleRatio'); + + this._updateNodeAndLinkScale(); + + this._updateController(seriesModel, coordSys, api); + + clearTimeout(this._layoutTimeout); + var forceLayout = seriesModel.forceLayout; + var layoutAnimation = seriesModel.get('force.layoutAnimation'); + if (forceLayout) { + this._startForceLayoutIteration(forceLayout, layoutAnimation); + } + // Update draggable + data.eachItemGraphicEl(function (el, idx) { + var draggable = data.getItemModel(idx).get('draggable'); + if (draggable && forceLayout) { + el.on('drag', function () { + forceLayout.warmUp(); + !this._layouting + && this._startForceLayoutIteration(forceLayout, layoutAnimation); + forceLayout.setFixed(idx); + // Write position back to layout + data.setItemLayout(idx, el.position); + }, this).on('dragend', function () { + forceLayout.setUnfixed(idx); + }, this); + } + else { + el.off('drag'); + } + el.setDraggable(draggable); + }, this); + + this._firstRender = false; + }, + + _startForceLayoutIteration: function (forceLayout, layoutAnimation) { + var self = this; + (function step() { + forceLayout.step(function (stopped) { + self.updateLayout(); + (self._layouting = !stopped) && ( + layoutAnimation + ? (self._layoutTimeout = setTimeout(step, 16)) + : step() + ); + }); + })(); + }, + + _updateController: function (seriesModel, coordSys, api) { + var controller = this._controller; + controller.rect = coordSys.getViewRect(); + + controller.enable(seriesModel.get('roam')); + + controller + .off('pan') + .off('zoom') + .on('pan', function (dx, dy) { + api.dispatchAction({ + seriesId: seriesModel.id, + type: 'graphRoam', + dx: dx, + dy: dy + }); + }) + .on('zoom', function (zoom, mouseX, mouseY) { + api.dispatchAction({ + seriesId: seriesModel.id, + type: 'graphRoam', + zoom: zoom, + originX: mouseX, + originY: mouseY + }); + }) + .on('zoom', this._updateNodeAndLinkScale, this); + }, + + _updateNodeAndLinkScale: function () { + var seriesModel = this._model; + var data = seriesModel.getData(); + + var group = this.group; + var nodeScaleRatio = this._nodeScaleRatio; + // var edgeScaleRatio = this._edgeScaleRatio; + + // Assume scale aspect is 1 + var groupScale = group.scale[0]; + + var nodeScale = (groupScale - 1) * nodeScaleRatio + 1; + // var edgeScale = (groupScale - 1) * edgeScaleRatio + 1; + var invScale = [ + nodeScale / groupScale, + nodeScale / groupScale + ]; + + data.eachItemGraphicEl(function (el, idx) { + el.attr('scale', invScale); + }); + // data.graph.eachEdge(function (edge) { + // var lineGroup = edge.getGraphicEl(); + // // FIXME + // lineGroup.childOfName('line').setStyle( + // 'lineWidth', + // edge.__lineWidth * edgeScale / groupScale + // ); + // }); + }, + + updateLayout: function (seriesModel, ecModel) { + this._symbolDraw.updateLayout(); + this._lineDraw.updateLayout(); + }, + + remove: function (ecModel, api) { + this._symbolDraw && this._symbolDraw.remove(); + this._lineDraw && this._lineDraw.remove(); + } + }); + + +/***/ }, +/* 194 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/chart/helper/LineDraw + */ + + + var graphic = __webpack_require__(42); + var LineGroup = __webpack_require__(195); + + /** + * @alias module:echarts/component/marker/LineDraw + * @constructor + */ + function LineDraw(ctor) { + this._ctor = ctor || LineGroup; + this.group = new graphic.Group(); + } + + var lineDrawProto = LineDraw.prototype; + + /** + * @param {module:echarts/data/List} lineData + * @param {module:echarts/data/List} [fromData] + * @param {module:echarts/data/List} [toData] + */ + lineDrawProto.updateData = function (lineData, fromData, toData) { + + var oldLineData = this._lineData; + var group = this.group; + var LineCtor = this._ctor; + + lineData.diff(oldLineData) + .add(function (idx) { + var lineGroup = new LineCtor(lineData, fromData, toData, idx); + + lineData.setItemGraphicEl(idx, lineGroup); + + group.add(lineGroup); + }) + .update(function (newIdx, oldIdx) { + var lineGroup = oldLineData.getItemGraphicEl(oldIdx); + lineGroup.updateData(lineData, fromData, toData, newIdx); + + lineData.setItemGraphicEl(newIdx, lineGroup); + + group.add(lineGroup); + }) + .remove(function (idx) { + group.remove(oldLineData.getItemGraphicEl(idx)); + }) + .execute(); + + this._lineData = lineData; + this._fromData = fromData; + this._toData = toData; + }; + + lineDrawProto.updateLayout = function () { + var lineData = this._lineData; + lineData.eachItemGraphicEl(function (el, idx) { + el.updateLayout(lineData, this._fromData, this._toData, idx); + }, this); + }; + + lineDrawProto.remove = function () { + this.group.removeAll(); + }; + + module.exports = LineDraw; + + +/***/ }, +/* 195 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/chart/helper/Line + */ + + + var symbolUtil = __webpack_require__(100); + var vector = __webpack_require__(16); + var LinePath = __webpack_require__(196); + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + + /** + * @inner + */ + function createSymbol(name, data, idx) { + var color = data.getItemVisual(idx, 'color'); + var symbolType = data.getItemVisual(idx, 'symbol'); + var symbolSize = data.getItemVisual(idx, 'symbolSize'); + + if (symbolType === 'none') { + return; + } + + if (!zrUtil.isArray(symbolSize)) { + symbolSize = [symbolSize, symbolSize]; + } + var symbolPath = symbolUtil.createSymbol( + symbolType, -symbolSize[0] / 2, -symbolSize[1] / 2, + symbolSize[0], symbolSize[1], color + ); + symbolPath.name = name; + + return symbolPath; + } + + function createLine(points) { + var line = new LinePath({ + name: 'line', + style: { + strokeNoScale: true + } + }); + setLinePoints(line.shape, points); + return line; + } + + function setLinePoints(targetShape, points) { + var p1 = points[0]; + var p2 = points[1]; + var cp1 = points[2]; + targetShape.x1 = p1[0]; + targetShape.y1 = p1[1]; + targetShape.x2 = p2[0]; + targetShape.y2 = p2[1]; + targetShape.percent = 1; + + if (cp1) { + targetShape.cpx1 = cp1[0]; + targetShape.cpy1 = cp1[1]; + } + } + + function isSymbolArrow(symbol) { + return symbol.type === 'symbol' && symbol.shape.symbolType === 'arrow'; + } + + function updateSymbolBeforeLineUpdate () { + var lineGroup = this; + var line = lineGroup.childOfName('line'); + // If line not changed + if (!this.__dirty && !line.__dirty) { + return; + } + var symbolFrom = lineGroup.childOfName('fromSymbol'); + var symbolTo = lineGroup.childOfName('toSymbol'); + var label = lineGroup.childOfName('label'); + var fromPos = line.pointAt(0); + var toPos = line.pointAt(line.shape.percent); + + var d = vector.sub([], toPos, fromPos); + vector.normalize(d, d); + + if (symbolFrom) { + symbolFrom.attr('position', fromPos); + // Rotate the arrow + // FIXME Hard coded ? + if (isSymbolArrow(symbolFrom)) { + symbolFrom.attr('rotation', tangentRotation(toPos, fromPos)); + } + } + if (symbolTo) { + symbolTo.attr('position', toPos); + if (isSymbolArrow(symbolTo)) { + symbolTo.attr('rotation', tangentRotation(fromPos, toPos)); + } + } + + label.attr('position', toPos); + + var textPosition; + var textAlign; + var textVerticalAlign; + // End + if (label.__position === 'end') { + textPosition = [d[0] * 5 + toPos[0], d[1] * 5 + toPos[1]]; + textAlign = d[0] > 0.8 ? 'left' : (d[0] < -0.8 ? 'right' : 'center'); + textVerticalAlign = d[1] > 0.8 ? 'top' : (d[1] < -0.8 ? 'bottom' : 'middle'); + } + // Start + else { + textPosition = [-d[0] * 5 + fromPos[0], -d[1] * 5 + fromPos[1]]; + textAlign = d[0] > 0.8 ? 'right' : (d[0] < -0.8 ? 'left' : 'center'); + textVerticalAlign = d[1] > 0.8 ? 'bottom' : (d[1] < -0.8 ? 'top' : 'middle'); + } + label.attr({ + style: { + // Use the user specified text align and baseline first + textVerticalAlign: label.__verticalAlign || textVerticalAlign, + textAlign: label.__textAlign || textAlign + }, + position: textPosition + }); + } + + function tangentRotation(p1, p2) { + return -Math.PI / 2 - Math.atan2( + p2[1] - p1[1], p2[0] - p1[0] + ); + } + + /** + * @constructor + * @extends {module:zrender/graphic/Group} + * @alias {module:echarts/chart/helper/Line} + */ + function Line(lineData, fromData, toData, idx) { + graphic.Group.call(this); + + this._createLine(lineData, fromData, toData, idx); + } + + var lineProto = Line.prototype; + + // Update symbol position and rotation + lineProto.beforeUpdate = updateSymbolBeforeLineUpdate; + + lineProto._createLine = function (lineData, fromData, toData, idx) { + var seriesModel = lineData.hostModel; + var linePoints = lineData.getItemLayout(idx); + + var line = createLine(linePoints); + line.shape.percent = 0; + graphic.initProps(line, { + shape: { + percent: 1 + } + }, seriesModel); + + this.add(line); + + var label = new graphic.Text({ + name: 'label' + }); + this.add(label); + + if (fromData) { + var symbolFrom = createSymbol('fromSymbol', fromData, idx); + // symbols must added after line to make sure + // it will be updated after line#update. + // Or symbol position and rotation update in line#beforeUpdate will be one frame slow + this.add(symbolFrom); + + this._fromSymbolType = fromData.getItemVisual(idx, 'symbol'); + } + if (toData) { + var symbolTo = createSymbol('toSymbol', toData, idx); + this.add(symbolTo); + + this._toSymbolType = toData.getItemVisual(idx, 'symbol'); + } + + this._updateCommonStl(lineData, fromData, toData, idx); + }; + + lineProto.updateData = function (lineData, fromData, toData, idx) { + var seriesModel = lineData.hostModel; + + var line = this.childOfName('line'); + var linePoints = lineData.getItemLayout(idx); + var target = { + shape: {} + }; + setLinePoints(target.shape, linePoints); + graphic.updateProps(line, target, seriesModel); + + // Symbol changed + if (fromData) { + var fromSymbolType = fromData.getItemVisual(idx, 'symbol'); + if (this._fromSymbolType !== fromSymbolType) { + var symbolFrom = createSymbol('fromSymbol', fromData, idx); + this.remove(this.childOfName('fromSymbol')); + this.add(symbolFrom); + } + this._fromSymbolType = fromSymbolType; + } + if (toData) { + var toSymbolType = toData.getItemVisual(idx, 'symbol'); + // Symbol changed + if (toSymbolType !== this._toSymbolType) { + var symbolTo = createSymbol('toSymbol', toData, idx); + this.remove(this.childOfName('toSymbol')); + this.add(symbolTo); + } + this._toSymbolType = toSymbolType; + } + + this._updateCommonStl(lineData, fromData, toData, idx); + }; + + lineProto._updateCommonStl = function (lineData, fromData, toData, idx) { + var seriesModel = lineData.hostModel; + + var line = this.childOfName('line'); + var itemModel = lineData.getItemModel(idx); + + var labelModel = itemModel.getModel('label.normal'); + var textStyleModel = labelModel.getModel('textStyle'); + var labelHoverModel = itemModel.getModel('label.emphasis'); + var textStyleHoverModel = labelHoverModel.getModel('textStyle'); + + var defaultText = numberUtil.round(seriesModel.getRawValue(idx)); + if (isNaN(defaultText)) { + // Use name + defaultText = lineData.getName(idx); + } + line.setStyle(zrUtil.extend( + { + stroke: lineData.getItemVisual(idx, 'color') + }, + itemModel.getModel('lineStyle.normal').getLineStyle() + )); + + var label = this.childOfName('label'); + label.setStyle({ + text: labelModel.get('show') + ? zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'normal'), + defaultText + ) + : '', + textFont: textStyleModel.getFont(), + fill: textStyleModel.getTextColor() || lineData.getItemVisual(idx, 'color') + }); + label.hoverStyle = { + text: labelHoverModel.get('show') + ? zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'emphasis'), + defaultText + ) + : '', + textFont: textStyleModel.getFont(), + fill: textStyleHoverModel.getTextColor() + }; + label.__textAlign = textStyleModel.get('align'); + label.__verticalAlign = textStyleModel.get('baseline'); + label.__position = labelModel.get('position'); + + graphic.setHoverStyle( + this, itemModel.getModel('lineStyle.emphasis').getLineStyle() + ); + }; + + lineProto.updateLayout = function (lineData, fromData, toData, idx) { + var points = lineData.getItemLayout(idx); + var linePath = this.childOfName('line'); + setLinePoints(linePath.shape, points); + linePath.dirty(true); + fromData && fromData.getItemGraphicEl(idx).attr('position', points[0]); + toData && toData.getItemGraphicEl(idx).attr('position', points[1]); + }; + + zrUtil.inherits(Line, graphic.Group); + + module.exports = Line; + + +/***/ }, +/* 196 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Line path for bezier and straight line draw + */ + + var graphic = __webpack_require__(42); + + var straightLineProto = graphic.Line.prototype; + var bezierCurveProto = graphic.BezierCurve.prototype; + + module.exports = graphic.extendShape({ + + type: 'ec-line', + + style: { + stroke: '#000', + fill: null + }, + + shape: { + x1: 0, + y1: 0, + x2: 0, + y2: 0, + percent: 1, + cpx1: null, + cpy1: null + }, + + buildPath: function (ctx, shape) { + (shape.cpx1 == null || shape.cpy1 == null + ? straightLineProto : bezierCurveProto).buildPath(ctx, shape); + }, + + pointAt: function (t) { + var shape = this.shape; + return shape.cpx1 == null || shape.cpy1 == null + ? straightLineProto.pointAt.call(this, t) + : bezierCurveProto.pointAt.call(this, t); + } + }); + + +/***/ }, +/* 197 */ +/***/ function(module, exports, __webpack_require__) { + + + + var echarts = __webpack_require__(1); + var roamHelper = __webpack_require__(162); + + var actionInfo = { + type: 'graphRoam', + event: 'graphRoam', + update: 'none' + }; + + /** + * @payload + * @property {string} name Series name + * @property {number} [dx] + * @property {number} [dy] + * @property {number} [zoom] + * @property {number} [originX] + * @property {number} [originY] + */ + + echarts.registerAction(actionInfo, function (payload, ecModel) { + ecModel.eachComponent({mainType: 'series', query: payload}, function (seriesModel) { + var coordSys = seriesModel.coordinateSystem; + + var roamDetailModel = seriesModel.getModel('roamDetail'); + var res = roamHelper.calcPanAndZoom(roamDetailModel, payload); + + seriesModel.setRoamPan + && seriesModel.setRoamPan(res.x, res.y); + + seriesModel.setRoamZoom + && seriesModel.setRoamZoom(res.zoom); + + coordSys && coordSys.setPan(res.x, res.y); + coordSys && coordSys.setZoom(res.zoom); + }); + }); + + +/***/ }, +/* 198 */ +/***/ function(module, exports) { + + + + module.exports = function (ecModel) { + var legendModels = ecModel.findComponents({ + mainType: 'legend' + }); + if (!legendModels || !legendModels.length) { + return; + } + ecModel.eachSeriesByType('graph', function (graphSeries) { + var categoriesData = graphSeries.getCategoriesData(); + var graph = graphSeries.getGraph(); + var data = graph.data; + + var categoryNames = categoriesData.mapArray(categoriesData.getName); + + data.filterSelf(function (idx) { + var model = data.getItemModel(idx); + var category = model.getShallow('category'); + if (category != null) { + if (typeof category === 'number') { + category = categoryNames[category]; + } + // If in any legend component the status is not selected. + for (var i = 0; i < legendModels.length; i++) { + if (!legendModels[i].isSelected(category)) { + return false; + } + } + } + return true; + }); + }, this); + }; + + +/***/ }, +/* 199 */ +/***/ function(module, exports) { + + + + module.exports = function (ecModel) { + ecModel.eachSeriesByType('graph', function (seriesModel) { + var colorList = seriesModel.get('color'); + var categoriesData = seriesModel.getCategoriesData(); + var data = seriesModel.getData(); + + var categoryNameIdxMap = {}; + + categoriesData.each(function (idx) { + categoryNameIdxMap[categoriesData.getName(idx)] = idx; + + var itemModel = categoriesData.getItemModel(idx); + var rawIdx = categoriesData.getRawIndex(idx); + var color = itemModel.get('itemStyle.normal.color') + || colorList[rawIdx % colorList.length]; + categoriesData.setItemVisual(idx, 'color', color); + }); + + // Assign category color to visual + if (categoriesData.count()) { + data.each(function (idx) { + var model = data.getItemModel(idx); + var category = model.getShallow('category'); + if (category != null) { + if (typeof category === 'string') { + category = categoryNameIdxMap[category]; + } + data.setItemVisual( + idx, 'color', + categoriesData.getItemVisual(category, 'color') + ); + } + }); + } + }); + }; + + +/***/ }, +/* 200 */ +/***/ function(module, exports, __webpack_require__) { + + + + var simpleLayoutHelper = __webpack_require__(201); + module.exports = function (ecModel, api) { + ecModel.eachSeriesByType('graph', function (seriesModel) { + var layout = seriesModel.get('layout'); + if (!layout || layout === 'none') { + simpleLayoutHelper(seriesModel); + } + }); + }; + + +/***/ }, +/* 201 */ +/***/ function(module, exports) { + + + module.exports = function (seriesModel) { + var coordSys = seriesModel.coordinateSystem; + if (coordSys && coordSys.type !== 'view') { + return; + } + var graph = seriesModel.getGraph(); + + graph.eachNode(function (node) { + var model = node.getModel(); + node.setLayout([+model.get('x'), +model.get('y')]); + }); + + graph.eachEdge(function (edge) { + var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0; + var p1 = edge.node1.getLayout(); + var p2 = edge.node2.getLayout(); + var cp1; + if (curveness > 0) { + cp1 = [ + (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * curveness, + (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * curveness + ]; + } + edge.setLayout([p1, p2, cp1]); + }); + }; + + +/***/ }, +/* 202 */ +/***/ function(module, exports, __webpack_require__) { + + + var circularLayoutHelper = __webpack_require__(203); + module.exports = function (ecModel, api) { + ecModel.eachSeriesByType('graph', function (seriesModel) { + if (seriesModel.get('layout') === 'circular') { + circularLayoutHelper(seriesModel); + } + }); + }; + + +/***/ }, +/* 203 */ +/***/ function(module, exports) { + + + module.exports = function (seriesModel) { + var coordSys = seriesModel.coordinateSystem; + if (coordSys && coordSys.type !== 'view') { + return; + } + + var rect = coordSys.getBoundingRect(); + + var nodeData = seriesModel.getData(); + var graph = nodeData.graph; + + var angle = 0; + var sum = nodeData.getSum('value'); + var unitAngle = Math.PI * 2 / (sum || nodeData.count()); + + var cx = rect.width / 2 + rect.x; + var cy = rect.height / 2 + rect.y; + + var r = Math.min(rect.width, rect.height) / 2; + + graph.eachNode(function (node) { + var value = node.getValue('value'); + + angle += unitAngle * (sum ? value : 2) / 2; + + node.setLayout([ + r * Math.cos(angle) + cx, + r * Math.sin(angle) + cy + ]); + + angle += unitAngle * (sum ? value : 2) / 2; + }); + + graph.eachEdge(function (edge) { + var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0; + var p1 = edge.node1.getLayout(); + var p2 = edge.node2.getLayout(); + var cp1; + if (curveness > 0) { + cp1 = [cx, cy]; + } + edge.setLayout([p1, p2, cp1]); + }); + }; + + +/***/ }, +/* 204 */ +/***/ function(module, exports, __webpack_require__) { + + + + var forceHelper = __webpack_require__(205); + var numberUtil = __webpack_require__(7); + var simpleLayoutHelper = __webpack_require__(201); + var circularLayoutHelper = __webpack_require__(203); + var vec2 = __webpack_require__(16); + + module.exports = function (ecModel, api) { + ecModel.eachSeriesByType('graph', function (graphSeries) { + if (graphSeries.get('layout') === 'force') { + var preservedPoints = graphSeries.preservedPoints || {}; + var graph = graphSeries.getGraph(); + var nodeData = graph.data; + var edgeData = graph.edgeData; + var forceModel = graphSeries.getModel('force'); + var initLayout = forceModel.get('initLayout'); + if (graphSeries.preservedPoints) { + nodeData.each(function (idx) { + var id = nodeData.getId(idx); + nodeData.setItemLayout(idx, preservedPoints[id] || [NaN, NaN]); + }); + } + else if (!initLayout || initLayout === 'none') { + simpleLayoutHelper(graphSeries); + } + else if (initLayout === 'circular') { + circularLayoutHelper(graphSeries); + } + + var nodeDataExtent = nodeData.getDataExtent('value'); + // var edgeDataExtent = edgeData.getDataExtent('value'); + var repulsion = forceModel.get('repulsion'); + var edgeLength = forceModel.get('edgeLength'); + var nodes = nodeData.mapArray('value', function (value, idx) { + var point = nodeData.getItemLayout(idx); + // var w = numberUtil.linearMap(value, nodeDataExtent, [0, 50]); + var rep = numberUtil.linearMap(value, nodeDataExtent, [0, repulsion]) || (repulsion / 2); + return { + w: rep, + rep: rep, + p: (!point || isNaN(point[0]) || isNaN(point[1])) ? null : point + }; + }); + var edges = edgeData.mapArray('value', function (value, idx) { + var edge = graph.getEdgeByIndex(idx); + // var w = numberUtil.linearMap(value, edgeDataExtent, [0, 100]); + return { + n1: nodes[edge.node1.dataIndex], + n2: nodes[edge.node2.dataIndex], + d: edgeLength, + curveness: edge.getModel().get('lineStyle.normal.curveness') || 0 + }; + }); + + var coordSys = graphSeries.coordinateSystem; + var rect = coordSys.getBoundingRect(); + var forceInstance = forceHelper(nodes, edges, { + rect: rect, + gravity: forceModel.get('gravity') + }); + var oldStep = forceInstance.step; + forceInstance.step = function (cb) { + for (var i = 0, l = nodes.length; i < l; i++) { + if (nodes[i].fixed) { + // Write back to layout instance + vec2.copy(nodes[i].p, graph.getNodeByIndex(i).getLayout()); + } + } + oldStep(function (nodes, edges, stopped) { + for (var i = 0, l = nodes.length; i < l; i++) { + if (!nodes[i].fixed) { + graph.getNodeByIndex(i).setLayout(nodes[i].p); + } + preservedPoints[nodeData.getId(i)] = nodes[i].p; + } + for (var i = 0, l = edges.length; i < l; i++) { + var e = edges[i]; + var p1 = e.n1.p; + var p2 = e.n2.p; + var points = [p1, p2]; + if (e.curveness > 0) { + points.push([ + (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * e.curveness, + (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * e.curveness + ]); + } + graph.getEdgeByIndex(i).setLayout(points); + } + // Update layout + + cb && cb(stopped); + }); + }; + graphSeries.forceLayout = forceInstance; + graphSeries.preservedPoints = preservedPoints; + + // Step to get the layout + forceInstance.step(); + } + else { + // Remove prev injected forceLayout instance + graphSeries.forceLayout = null; + } + }); + }; + + +/***/ }, +/* 205 */ +/***/ function(module, exports, __webpack_require__) { + + + + var vec2 = __webpack_require__(16); + var scaleAndAdd = vec2.scaleAndAdd; + + // function adjacentNode(n, e) { + // return e.n1 === n ? e.n2 : e.n1; + // } + + module.exports = function (nodes, edges, opts) { + var rect = opts.rect; + var width = rect.width; + var height = rect.height; + var center = [rect.x + width / 2, rect.y + height / 2]; + // var scale = opts.scale || 1; + var gravity = opts.gravity == null ? 0.1 : opts.gravity; + + // for (var i = 0; i < edges.length; i++) { + // var e = edges[i]; + // var n1 = e.n1; + // var n2 = e.n2; + // n1.edges = n1.edges || []; + // n2.edges = n2.edges || []; + // n1.edges.push(e); + // n2.edges.push(e); + // } + // Init position + for (var i = 0; i < nodes.length; i++) { + var n = nodes[i]; + if (!n.p) { + // Use the position from first adjecent node with defined position + // Or use a random position + // From d3 + // if (n.edges) { + // var j = -1; + // while (++j < n.edges.length) { + // var e = n.edges[j]; + // var other = adjacentNode(n, e); + // if (other.p) { + // n.p = vec2.clone(other.p); + // break; + // } + // } + // } + // if (!n.p) { + n.p = vec2.create( + width * (Math.random() - 0.5) + center[0], + height * (Math.random() - 0.5) + center[1] + ); + // } + } + n.pp = vec2.clone(n.p); + n.edges = null; + } + + // Formula in 'Graph Drawing by Force-directed Placement' + // var k = scale * Math.sqrt(width * height / nodes.length); + // var k2 = k * k; + + var friction = 0.6; + + return { + warmUp: function () { + friction = 0.5; + }, + + setFixed: function (idx) { + nodes[idx].fixed = true; + }, + + setUnfixed: function (idx) { + nodes[idx].fixed = false; + }, + + step: function (cb) { + var v12 = []; + var nLen = nodes.length; + for (var i = 0; i < edges.length; i++) { + var e = edges[i]; + var n1 = e.n1; + var n2 = e.n2; + + vec2.sub(v12, n2.p, n1.p); + var d = vec2.len(v12) - e.d; + var w = n2.w / (n1.w + n2.w); + vec2.normalize(v12, v12); + + !n1.fixed && scaleAndAdd(n1.p, n1.p, v12, w * d * friction); + !n2.fixed && scaleAndAdd(n2.p, n2.p, v12, -(1 - w) * d * friction); + } + // Gravity + for (var i = 0; i < nLen; i++) { + var n = nodes[i]; + if (!n.fixed) { + vec2.sub(v12, center, n.p); + // var d = vec2.len(v12); + // vec2.scale(v12, v12, 1 / d); + // var gravityFactor = gravity; + vec2.scaleAndAdd(n.p, n.p, v12, gravity * friction); + } + } + + // Repulsive + // PENDING + for (var i = 0; i < nLen; i++) { + var n1 = nodes[i]; + for (var j = i + 1; j < nLen; j++) { + var n2 = nodes[j]; + vec2.sub(v12, n2.p, n1.p); + var d = vec2.len(v12); + if (d === 0) { + // Random repulse + vec2.set(v12, Math.random() - 0.5, Math.random() - 0.5); + d = 1; + } + var repFact = (n1.rep + n2.rep) / d / d; + !n1.fixed && scaleAndAdd(n1.pp, n1.pp, v12, repFact); + !n2.fixed && scaleAndAdd(n2.pp, n2.pp, v12, -repFact); + } + } + var v = []; + for (var i = 0; i < nLen; i++) { + var n = nodes[i]; + if (!n.fixed) { + vec2.sub(v, n.p, n.pp); + vec2.scaleAndAdd(n.p, n.p, v, friction); + vec2.copy(n.pp, n.p); + } + } + + friction = friction * 0.992; + + cb && cb(nodes, edges, friction < 0.01); + } + }; + }; + + +/***/ }, +/* 206 */ +/***/ function(module, exports, __webpack_require__) { + + + // FIXME Where to create the simple view coordinate system + var View = __webpack_require__(169); + var layout = __webpack_require__(21); + var bbox = __webpack_require__(50); + + function getViewRect(seriesModel, api, aspect) { + var option = seriesModel.getBoxLayoutParams(); + option.aspect = aspect; + return layout.getLayoutRect(option, { + width: api.getWidth(), + height: api.getHeight() + }); + } + + module.exports = function (ecModel, api) { + var viewList = []; + ecModel.eachSeriesByType('graph', function (seriesModel) { + var coordSysType = seriesModel.get('coordinateSystem'); + if (!coordSysType || coordSysType === 'view') { + var viewCoordSys = new View(); + viewList.push(viewCoordSys); + + var data = seriesModel.getData(); + var positions = data.mapArray(function (idx) { + var itemModel = data.getItemModel(idx); + return [+itemModel.get('x'), +itemModel.get('y')]; + }); + + var min = []; + var max = []; + + bbox.fromPoints(positions, min, max); + + // FIXME If get view rect after data processed? + var viewRect = getViewRect( + seriesModel, api, (max[0] - min[0]) / (max[1] - min[1]) || 1 + ); + // Position may be NaN, use view rect instead + if (isNaN(min[0]) || isNaN(min[1])) { + min = [viewRect.x, viewRect.y]; + max = [viewRect.x + viewRect.width, viewRect.y + viewRect.height]; + } + + var bbWidth = max[0] - min[0]; + var bbHeight = max[1] - min[1]; + + var viewWidth = viewRect.width; + var viewHeight = viewRect.height; + + viewCoordSys = seriesModel.coordinateSystem = new View(); + + viewCoordSys.setBoundingRect( + min[0], min[1], bbWidth, bbHeight + ); + viewCoordSys.setViewRect( + viewRect.x, viewRect.y, viewWidth, viewHeight + ); + + // Update roam info + var roamDetailModel = seriesModel.getModel('roamDetail'); + viewCoordSys.setPan(roamDetailModel.get('x') || 0, roamDetailModel.get('y') || 0); + viewCoordSys.setZoom(roamDetailModel.get('zoom') || 1); + } + }); + return viewList; + }; + + +/***/ }, +/* 207 */ +/***/ function(module, exports, __webpack_require__) { + + + __webpack_require__(208); + __webpack_require__(209); + + +/***/ }, +/* 208 */ +/***/ function(module, exports, __webpack_require__) { + + + + var List = __webpack_require__(94); + var SeriesModel = __webpack_require__(27); + var zrUtil = __webpack_require__(3); + + var GaugeSeries = SeriesModel.extend({ + + type: 'series.gauge', + + getInitialData: function (option, ecModel) { + var list = new List(['value'], this); + var dataOpt = option.data || []; + if (!zrUtil.isArray(dataOpt)) { + dataOpt = [dataOpt]; + } + // Only use the first data item + list.initData(dataOpt); + return list; + }, + + defaultOption: { + zlevel: 0, + z: 2, + // 默认全局居中 + center: ['50%', '50%'], + legendHoverLink: true, + radius: '75%', + startAngle: 225, + endAngle: -45, + clockwise: true, + // 最小值 + min: 0, + // 最大值 + max: 100, + // 分割段数,默认为10 + splitNumber: 10, + // 坐标轴线 + axisLine: { + // 默认显示,属性show控制显示与否 + show: true, + lineStyle: { // 属性lineStyle控制线条样式 + color: [[0.2, '#91c7ae'], [0.8, '#63869e'], [1, '#c23531']], + width: 30 + } + }, + // 分隔线 + splitLine: { + // 默认显示,属性show控制显示与否 + show: true, + // 属性length控制线长 + length: 30, + // 属性lineStyle(详见lineStyle)控制线条样式 + lineStyle: { + color: '#eee', + width: 2, + type: 'solid' + } + }, + // 坐标轴小标记 + axisTick: { + // 属性show控制显示与否,默认不显示 + show: true, + // 每份split细分多少段 + splitNumber: 5, + // 属性length控制线长 + length: 8, + // 属性lineStyle控制线条样式 + lineStyle: { + color: '#eee', + width: 1, + type: 'solid' + } + }, + axisLabel: { + show: true, + // formatter: null, + textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE + color: 'auto' + } + }, + pointer: { + show: true, + length: '80%', + width: 8 + }, + itemStyle: { + normal: { + color: 'auto' + } + }, + title: { + show: true, + // x, y,单位px + offsetCenter: [0, '-40%'], + // 其余属性默认使用全局文本样式,详见TEXTSTYLE + textStyle: { + color: '#333', + fontSize: 15 + } + }, + detail: { + show: true, + backgroundColor: 'rgba(0,0,0,0)', + borderWidth: 0, + borderColor: '#ccc', + width: 100, + height: 40, + // x, y,单位px + offsetCenter: [0, '40%'], + // formatter: null, + // 其余属性默认使用全局文本样式,详见TEXTSTYLE + textStyle: { + color: 'auto', + fontSize: 30 + } + } + } + }); + + module.exports = GaugeSeries; + + +/***/ }, +/* 209 */ +/***/ function(module, exports, __webpack_require__) { + + + + var PointerPath = __webpack_require__(210); + + var graphic = __webpack_require__(42); + var numberUtil = __webpack_require__(7); + var parsePercent = numberUtil.parsePercent; + + function parsePosition(seriesModel, api) { + var center = seriesModel.get('center'); + var width = api.getWidth(); + var height = api.getHeight(); + var size = Math.min(width, height); + var cx = parsePercent(center[0], api.getWidth()); + var cy = parsePercent(center[1], api.getHeight()); + var r = parsePercent(seriesModel.get('radius'), size / 2); + + return { + cx: cx, + cy: cy, + r: r + }; + } + + function formatLabel(label, labelFormatter) { + if (labelFormatter) { + if (typeof labelFormatter === 'string') { + label = labelFormatter.replace('{value}', label); + } + else if (typeof labelFormatter === 'function') { + label = labelFormatter(label); + } + } + + return label; + } + + var PI2 = Math.PI * 2; + + var GaugeView = __webpack_require__(41).extend({ + + type: 'gauge', + + render: function (seriesModel, ecModel, api) { + + this.group.removeAll(); + + var colorList = seriesModel.get('axisLine.lineStyle.color'); + var posInfo = parsePosition(seriesModel, api); + + this._renderMain( + seriesModel, ecModel, api, colorList, posInfo + ); + }, + + _renderMain: function (seriesModel, ecModel, api, colorList, posInfo) { + var group = this.group; + + var axisLineModel = seriesModel.getModel('axisLine'); + var lineStyleModel = axisLineModel.getModel('lineStyle'); + + var clockwise = seriesModel.get('clockwise'); + var startAngle = -seriesModel.get('startAngle') / 180 * Math.PI; + var endAngle = -seriesModel.get('endAngle') / 180 * Math.PI; + + var angleRangeSpan = (endAngle - startAngle) % PI2; + + var prevEndAngle = startAngle; + var axisLineWidth = lineStyleModel.get('width'); + + for (var i = 0; i < colorList.length; i++) { + var endAngle = startAngle + angleRangeSpan * colorList[i][0]; + var sector = new graphic.Sector({ + shape: { + startAngle: prevEndAngle, + endAngle: endAngle, + cx: posInfo.cx, + cy: posInfo.cy, + clockwise: clockwise, + r0: posInfo.r - axisLineWidth, + r: posInfo.r + }, + silent: true + }); + + sector.setStyle({ + fill: colorList[i][1] + }); + + sector.setStyle(lineStyleModel.getLineStyle( + // Because we use sector to simulate arc + // so the properties for stroking are useless + ['color', 'borderWidth', 'borderColor'] + )); + + group.add(sector); + + prevEndAngle = endAngle; + } + + var getColor = function (percent) { + // Less than 0 + if (percent <= 0) { + return colorList[0][1]; + } + for (var i = 0; i < colorList.length; i++) { + if (colorList[i][0] >= percent + && (i === 0 ? 0 : colorList[i - 1][0]) < percent + ) { + return colorList[i][1]; + } + } + // More than 1 + return colorList[i - 1][1]; + }; + + if (!clockwise) { + var tmp = startAngle; + startAngle = endAngle; + endAngle = tmp; + } + + this._renderTicks( + seriesModel, ecModel, api, getColor, posInfo, + startAngle, endAngle, clockwise + ); + + this._renderPointer( + seriesModel, ecModel, api, getColor, posInfo, + startAngle, endAngle, clockwise + ); + + this._renderTitle( + seriesModel, ecModel, api, getColor, posInfo + ); + this._renderDetail( + seriesModel, ecModel, api, getColor, posInfo + ); + }, + + _renderTicks: function ( + seriesModel, ecModel, api, getColor, posInfo, + startAngle, endAngle, clockwise + ) { + var group = this.group; + var cx = posInfo.cx; + var cy = posInfo.cy; + var r = posInfo.r; + + var minVal = seriesModel.get('min'); + var maxVal = seriesModel.get('max'); + + var splitLineModel = seriesModel.getModel('splitLine'); + var tickModel = seriesModel.getModel('axisTick'); + var labelModel = seriesModel.getModel('axisLabel'); + + var splitNumber = seriesModel.get('splitNumber'); + var subSplitNumber = tickModel.get('splitNumber'); + + var splitLineLen = parsePercent( + splitLineModel.get('length'), r + ); + var tickLen = parsePercent( + tickModel.get('length'), r + ); + + var angle = startAngle; + var step = (endAngle - startAngle) / splitNumber; + var subStep = step / subSplitNumber; + + var splitLineStyle = splitLineModel.getModel('lineStyle').getLineStyle(); + var tickLineStyle = tickModel.getModel('lineStyle').getLineStyle(); + var textStyleModel = labelModel.getModel('textStyle'); + + for (var i = 0; i <= splitNumber; i++) { + var unitX = Math.cos(angle); + var unitY = Math.sin(angle); + // Split line + if (splitLineModel.get('show')) { + var splitLine = new graphic.Line({ + shape: { + x1: unitX * r + cx, + y1: unitY * r + cy, + x2: unitX * (r - splitLineLen) + cx, + y2: unitY * (r - splitLineLen) + cy + }, + style: splitLineStyle, + silent: true + }); + if (splitLineStyle.stroke === 'auto') { + splitLine.setStyle({ + stroke: getColor(i / splitNumber) + }); + } + + group.add(splitLine); + } + + // Label + if (labelModel.get('show')) { + var label = formatLabel( + numberUtil.round(i / splitNumber * (maxVal - minVal) + minVal), + labelModel.get('formatter') + ); + + var text = new graphic.Text({ + style: { + text: label, + x: unitX * (r - splitLineLen - 5) + cx, + y: unitY * (r - splitLineLen - 5) + cy, + fill: textStyleModel.getTextColor(), + textFont: textStyleModel.getFont(), + textVerticalAlign: unitY < -0.4 ? 'top' : (unitY > 0.4 ? 'bottom' : 'middle'), + textAlign: unitX < -0.4 ? 'left' : (unitX > 0.4 ? 'right' : 'center') + }, + silent: true + }); + if (text.style.fill === 'auto') { + text.setStyle({ + fill: getColor(i / splitNumber) + }); + } + + group.add(text); + } + + // Axis tick + if (tickModel.get('show') && i !== splitNumber) { + for (var j = 0; j <= subSplitNumber; j++) { + var unitX = Math.cos(angle); + var unitY = Math.sin(angle); + var tickLine = new graphic.Line({ + shape: { + x1: unitX * r + cx, + y1: unitY * r + cy, + x2: unitX * (r - tickLen) + cx, + y2: unitY * (r - tickLen) + cy + }, + silent: true, + style: tickLineStyle + }); + + if (tickLineStyle.stroke === 'auto') { + tickLine.setStyle({ + stroke: getColor((i + j / subSplitNumber) / splitNumber) + }); + } + + group.add(tickLine); + angle += subStep; + } + angle -= subStep; + } + else { + angle += step; + } + } + }, + + _renderPointer: function ( + seriesModel, ecModel, api, getColor, posInfo, + startAngle, endAngle, clockwise + ) { + var linearMap = numberUtil.linearMap; + var valueExtent = [+seriesModel.get('min'), +seriesModel.get('max')]; + var angleExtent = [startAngle, endAngle]; + + if (!clockwise) { + angleExtent = angleExtent.reverse(); + } + + var data = seriesModel.getData(); + var oldData = this._data; + + var group = this.group; + + data.diff(oldData) + .add(function (idx) { + var pointer = new PointerPath({ + shape: { + angle: startAngle + } + }); + + graphic.updateProps(pointer, { + shape: { + angle: linearMap(data.get('value', idx), valueExtent, angleExtent) + } + }, seriesModel); + + group.add(pointer); + data.setItemGraphicEl(idx, pointer); + }) + .update(function (newIdx, oldIdx) { + var pointer = oldData.getItemGraphicEl(oldIdx); + + graphic.updateProps(pointer, { + shape: { + angle: linearMap(data.get('value', newIdx), valueExtent, angleExtent) + } + }, seriesModel); + + group.add(pointer); + data.setItemGraphicEl(newIdx, pointer); + }) + .remove(function (idx) { + var pointer = oldData.getItemGraphicEl(idx); + group.remove(pointer); + }) + .execute(); + + data.eachItemGraphicEl(function (pointer, idx) { + var itemModel = data.getItemModel(idx); + var pointerModel = itemModel.getModel('pointer'); + + pointer.attr({ + shape: { + x: posInfo.cx, + y: posInfo.cy, + width: parsePercent( + pointerModel.get('width'), posInfo.r + ), + r: parsePercent(pointerModel.get('length'), posInfo.r) + }, + style: itemModel.getModel('itemStyle.normal').getItemStyle() + }); + + if (pointer.style.fill === 'auto') { + pointer.setStyle('fill', getColor( + (data.get('value', idx) - valueExtent[0]) / (valueExtent[1] - valueExtent[0]) + )); + } + + graphic.setHoverStyle( + pointer, itemModel.getModel('itemStyle.emphasis').getItemStyle() + ); + }); + + this._data = data; + }, + + _renderTitle: function ( + seriesModel, ecModel, api, getColor, posInfo + ) { + var titleModel = seriesModel.getModel('title'); + if (titleModel.get('show')) { + var textStyleModel = titleModel.getModel('textStyle'); + var offsetCenter = titleModel.get('offsetCenter'); + var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r); + var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r); + var text = new graphic.Text({ + style: { + x: x, + y: y, + // FIXME First data name ? + text: seriesModel.getData().getName(0), + fill: textStyleModel.getTextColor(), + textFont: textStyleModel.getFont(), + textAlign: 'center', + textVerticalAlign: 'middle' + } + }); + this.group.add(text); + } + }, + + _renderDetail: function ( + seriesModel, ecModel, api, getColor, posInfo + ) { + var detailModel = seriesModel.getModel('detail'); + var minVal = seriesModel.get('min'); + var maxVal = seriesModel.get('max'); + if (detailModel.get('show')) { + var textStyleModel = detailModel.getModel('textStyle'); + var offsetCenter = detailModel.get('offsetCenter'); + var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r); + var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r); + var width = parsePercent(detailModel.get('width'), posInfo.r); + var height = parsePercent(detailModel.get('height'), posInfo.r); + var value = seriesModel.getData().get('value', 0); + var rect = new graphic.Rect({ + shape: { + x: x - width / 2, + y: y - height / 2, + width: width, + height: height + }, + style: { + text: formatLabel( + // FIXME First data name ? + value, detailModel.get('formatter') + ), + fill: detailModel.get('backgroundColor'), + textFill: textStyleModel.getTextColor(), + textFont: textStyleModel.getFont() + } + }); + if (rect.style.textFill === 'auto') { + rect.setStyle('textFill', getColor((value - minVal) / (maxVal - minVal))); + } + rect.setStyle(detailModel.getItemStyle(['color'])); + this.group.add(rect); + } + } + }); + + module.exports = GaugeView; + + +/***/ }, +/* 210 */ +/***/ function(module, exports, __webpack_require__) { + + + + module.exports = __webpack_require__(44).extend({ + + type: 'echartsGaugePointer', + + shape: { + angle: 0, + + width: 10, + + r: 10, + + x: 0, + + y: 0 + }, + + buildPath: function (ctx, shape) { + var mathCos = Math.cos; + var mathSin = Math.sin; + + var r = shape.r; + var width = shape.width; + var angle = shape.angle; + var x = shape.x - mathCos(angle) * width * (width >= r / 3 ? 1 : 2); + var y = shape.y - mathSin(angle) * width * (width >= r / 3 ? 1 : 2); + + angle = shape.angle - Math.PI / 2; + ctx.moveTo(x, y); + ctx.lineTo( + shape.x + mathCos(angle) * width, + shape.y + mathSin(angle) * width + ); + ctx.lineTo( + shape.x + mathCos(shape.angle) * r, + shape.y + mathSin(shape.angle) * r + ); + ctx.lineTo( + shape.x - mathCos(angle) * width, + shape.y - mathSin(angle) * width + ); + ctx.lineTo(x, y); + return; + } + }); + + +/***/ }, +/* 211 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var echarts = __webpack_require__(1); + + __webpack_require__(212); + __webpack_require__(213); + + echarts.registerVisualCoding( + 'chart', zrUtil.curry(__webpack_require__(137), 'funnel') + ); + echarts.registerLayout(__webpack_require__(214)); + + echarts.registerProcessor( + 'filter', zrUtil.curry(__webpack_require__(140), 'funnel') + ); + + +/***/ }, +/* 212 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var List = __webpack_require__(94); + var modelUtil = __webpack_require__(5); + var completeDimensions = __webpack_require__(96); + + var FunnelSeries = __webpack_require__(1).extendSeriesModel({ + + type: 'series.funnel', + + init: function (option) { + FunnelSeries.superApply(this, 'init', arguments); + + // Enable legend selection for each data item + // Use a function instead of direct access because data reference may changed + this.legendDataProvider = function () { + return this._dataBeforeProcessed; + }; + // Extend labelLine emphasis + this._defaultLabelLine(option); + }, + + getInitialData: function (option, ecModel) { + var dimensions = completeDimensions(['value'], option.data); + var list = new List(dimensions, this); + list.initData(option.data); + return list; + }, + + _defaultLabelLine: function (option) { + // Extend labelLine emphasis + modelUtil.defaultEmphasis(option.labelLine, ['show']); + + var labelLineNormalOpt = option.labelLine.normal; + var labelLineEmphasisOpt = option.labelLine.emphasis; + // Not show label line if `label.normal.show = false` + labelLineNormalOpt.show = labelLineNormalOpt.show + && option.label.normal.show; + labelLineEmphasisOpt.show = labelLineEmphasisOpt.show + && option.label.emphasis.show; + }, + + defaultOption: { + zlevel: 0, // 一级层叠 + z: 2, // 二级层叠 + legendHoverLink: true, + left: 80, + top: 60, + right: 80, + bottom: 60, + // width: {totalWidth} - left - right, + // height: {totalHeight} - top - bottom, + + // 默认取数据最小最大值 + // min: 0, + // max: 100, + minSize: '0%', + maxSize: '100%', + sort: 'descending', // 'ascending', 'descending' + gap: 0, + funnelAlign: 'center', + label: { + normal: { + show: true, + position: 'outer' + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + }, + emphasis: { + show: true + } + }, + labelLine: { + normal: { + show: true, + length: 20, + lineStyle: { + // color: 各异, + width: 1, + type: 'solid' + } + }, + emphasis: {} + }, + itemStyle: { + normal: { + // color: 各异, + borderColor: '#fff', + borderWidth: 1 + }, + emphasis: { + // color: 各异, + } + } + } + }); + + module.exports = FunnelSeries; + + +/***/ }, +/* 213 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + + /** + * Piece of pie including Sector, Label, LabelLine + * @constructor + * @extends {module:zrender/graphic/Group} + */ + function FunnelPiece(data, idx) { + + graphic.Group.call(this); + + var polygon = new graphic.Polygon(); + var labelLine = new graphic.Polyline(); + var text = new graphic.Text(); + this.add(polygon); + this.add(labelLine); + this.add(text); + + this.updateData(data, idx, true); + + // Hover to change label and labelLine + function onEmphasis() { + labelLine.ignore = labelLine.hoverIgnore; + text.ignore = text.hoverIgnore; + } + function onNormal() { + labelLine.ignore = labelLine.normalIgnore; + text.ignore = text.normalIgnore; + } + this.on('emphasis', onEmphasis) + .on('normal', onNormal) + .on('mouseover', onEmphasis) + .on('mouseout', onNormal); + } + + var funnelPieceProto = FunnelPiece.prototype; + + function getLabelStyle(data, idx, state, labelModel) { + var textStyleModel = labelModel.getModel('textStyle'); + var position = labelModel.get('position'); + var isLabelInside = position === 'inside' || position === 'inner' || position === 'center'; + return { + fill: textStyleModel.getTextColor() + || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')), + textFont: textStyleModel.getFont(), + text: zrUtil.retrieve( + data.hostModel.getFormattedLabel(idx, state), + data.getName(idx) + ) + }; + } + + var opacityAccessPath = ['itemStyle', 'normal', 'opacity']; + funnelPieceProto.updateData = function (data, idx, firstCreate) { + + var polygon = this.childAt(0); + + var seriesModel = data.hostModel; + var itemModel = data.getItemModel(idx); + var layout = data.getItemLayout(idx); + var opacity = data.getItemModel(idx).get(opacityAccessPath); + opacity = opacity == null ? 1 : opacity; + if (firstCreate) { + polygon.setShape({ + points: layout.points + }); + polygon.setStyle({ opacity : 0 }); + graphic.updateProps(polygon, { + style: { + opacity: opacity + } + }, seriesModel); + } + else { + graphic.initProps(polygon, { + shape: { + points: layout.points + } + }, seriesModel); + } + + // Update common style + var itemStyleModel = itemModel.getModel('itemStyle'); + var visualColor = data.getItemVisual(idx, 'color'); + + polygon.setStyle( + zrUtil.defaults( + { + fill: visualColor + }, + itemStyleModel.getModel('normal').getItemStyle() + ) + ); + polygon.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle(); + + this._updateLabel(data, idx); + + graphic.setHoverStyle(this); + }; + + funnelPieceProto._updateLabel = function (data, idx) { + + var labelLine = this.childAt(1); + var labelText = this.childAt(2); + + var seriesModel = data.hostModel; + var itemModel = data.getItemModel(idx); + var layout = data.getItemLayout(idx); + var labelLayout = layout.label; + var visualColor = data.getItemVisual(idx, 'color'); + + graphic.updateProps(labelLine, { + shape: { + points: labelLayout.linePoints || labelLayout.linePoints + } + }, seriesModel); + + graphic.updateProps(labelText, { + style: { + x: labelLayout.x, + y: labelLayout.y + } + }, seriesModel); + labelText.attr({ + style: { + textAlign: labelLayout.textAlign, + textVerticalAlign: labelLayout.verticalAlign, + textFont: labelLayout.font + }, + rotation: labelLayout.rotation, + origin: [labelLayout.x, labelLayout.y], + z2: 10 + }); + + var labelModel = itemModel.getModel('label.normal'); + var labelHoverModel = itemModel.getModel('label.emphasis'); + var labelLineModel = itemModel.getModel('labelLine.normal'); + var labelLineHoverModel = itemModel.getModel('labelLine.emphasis'); + + labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel)); + + labelText.ignore = labelText.normalIgnore = !labelModel.get('show'); + labelText.hoverIgnore = !labelHoverModel.get('show'); + + labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show'); + labelLine.hoverIgnore = !labelLineHoverModel.get('show'); + + // Default use item visual color + labelLine.setStyle({ + stroke: visualColor + }); + labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle()); + + labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel); + labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle(); + }; + + zrUtil.inherits(FunnelPiece, graphic.Group); + + + var Funnel = __webpack_require__(41).extend({ + + type: 'funnel', + + render: function (seriesModel, ecModel, api) { + var data = seriesModel.getData(); + var oldData = this._data; + + var group = this.group; + + data.diff(oldData) + .add(function (idx) { + var funnelPiece = new FunnelPiece(data, idx); + + data.setItemGraphicEl(idx, funnelPiece); + + group.add(funnelPiece); + }) + .update(function (newIdx, oldIdx) { + var piePiece = oldData.getItemGraphicEl(oldIdx); + + piePiece.updateData(data, newIdx); + + group.add(piePiece); + data.setItemGraphicEl(newIdx, piePiece); + }) + .remove(function (idx) { + var piePiece = oldData.getItemGraphicEl(idx); + group.remove(piePiece); + }) + .execute(); + + this._data = data; + }, + + remove: function () { + this.group.removeAll(); + this._data = null; + } + }); + + module.exports = Funnel; + + +/***/ }, +/* 214 */ +/***/ function(module, exports, __webpack_require__) { + + + + var layout = __webpack_require__(21); + var number = __webpack_require__(7); + + var parsePercent = number.parsePercent; + + function getViewRect(seriesModel, api) { + return layout.getLayoutRect( + seriesModel.getBoxLayoutParams(), { + width: api.getWidth(), + height: api.getHeight() + } + ); + } + + function getSortedIndices(data, sort) { + var valueArr = data.mapArray('value', function (val) { + return val; + }); + var indices = []; + var isAscending = sort === 'ascending'; + for (var i = 0, len = data.count(); i < len; i++) { + indices[i] = i; + } + indices.sort(function (a, b) { + return isAscending ? valueArr[a] - valueArr[b] : valueArr[b] - valueArr[a]; + }); + return indices; + } + + function labelLayout (data) { + data.each(function (idx) { + var itemModel = data.getItemModel(idx); + var labelModel = itemModel.getModel('label.normal'); + var labelPosition = labelModel.get('position'); + + var labelLineModel = itemModel.getModel('labelLine.normal'); + + var layout = data.getItemLayout(idx); + var points = layout.points; + + var isLabelInside = labelPosition === 'inner' + || labelPosition === 'inside' || labelPosition === 'center'; + + var textAlign; + var textX; + var textY; + var linePoints; + + if (isLabelInside) { + textX = (points[0][0] + points[1][0] + points[2][0] + points[3][0]) / 4; + textY = (points[0][1] + points[1][1] + points[2][1] + points[3][1]) / 4; + textAlign = 'center'; + linePoints = [ + [textX, textY], [textX, textY] + ]; + } + else { + var x1; + var y1; + var x2; + var labelLineLen = labelLineModel.get('length'); + if (labelPosition === 'left') { + // Left side + x1 = (points[3][0] + points[0][0]) / 2; + y1 = (points[3][1] + points[0][1]) / 2; + x2 = x1 - labelLineLen; + textX = x2 - 5; + textAlign = 'right'; + } + else { + // Right side + x1 = (points[1][0] + points[2][0]) / 2; + y1 = (points[1][1] + points[2][1]) / 2; + x2 = x1 + labelLineLen; + textX = x2 + 5; + textAlign = 'left'; + } + var y2 = y1; + + linePoints = [[x1, y1], [x2, y2]]; + textY = y2; + } + + layout.label = { + linePoints: linePoints, + x: textX, + y: textY, + verticalAlign: 'middle', + textAlign: textAlign, + inside: isLabelInside + }; + }); + } + + module.exports = function (ecModel, api) { + ecModel.eachSeriesByType('funnel', function (seriesModel) { + var data = seriesModel.getData(); + var sort = seriesModel.get('sort'); + var viewRect = getViewRect(seriesModel, api); + var indices = getSortedIndices(data, sort); + + var sizeExtent = [ + parsePercent(seriesModel.get('minSize'), viewRect.width), + parsePercent(seriesModel.get('maxSize'), viewRect.width) + ]; + var dataExtent = data.getDataExtent('value'); + var min = seriesModel.get('min'); + var max = seriesModel.get('max'); + if (min == null) { + min = Math.min(dataExtent[0], 0); + } + if (max == null) { + max = dataExtent[1]; + } + + var funnelAlign = seriesModel.get('funnelAlign'); + var gap = seriesModel.get('gap'); + var itemHeight = (viewRect.height - gap * (data.count() - 1)) / data.count(); + + var y = viewRect.y; + + var getLinePoints = function (idx, offY) { + // End point index is data.count() and we assign it 0 + var val = data.get('value', idx) || 0; + var itemWidth = number.linearMap(val, [min, max], sizeExtent, true); + var x0; + switch (funnelAlign) { + case 'left': + x0 = viewRect.x; + break; + case 'center': + x0 = viewRect.x + (viewRect.width - itemWidth) / 2; + break; + case 'right': + x0 = viewRect.x + viewRect.width - itemWidth; + break; + } + return [ + [x0, offY], + [x0 + itemWidth, offY] + ]; + }; + + if (sort === 'ascending') { + // From bottom to top + itemHeight = -itemHeight; + gap = -gap; + y += viewRect.height; + indices = indices.reverse(); + } + + for (var i = 0; i < indices.length; i++) { + var idx = indices[i]; + var nextIdx = indices[i + 1]; + var start = getLinePoints(idx, y); + var end = getLinePoints(nextIdx, y + itemHeight); + + y += itemHeight + gap; + + data.setItemLayout(idx, { + points: start.concat(end.slice().reverse()) + }); + } + + labelLayout(data); + }); + }; + + +/***/ }, +/* 215 */ +/***/ function(module, exports, __webpack_require__) { - // this._x = 0; - // this._y = 0; - } + - Draggable.prototype = { + var echarts = __webpack_require__(1); - constructor: Draggable, + __webpack_require__(216); - _dragStart: function (e) { - var draggingTarget = e.target; - if (draggingTarget && draggingTarget.draggable) { - this._draggingTarget = draggingTarget; - draggingTarget.dragging = true; - this._x = e.offsetX; - this._y = e.offsetY; + __webpack_require__(227); + __webpack_require__(228); - this._dispatchProxy(draggingTarget, 'dragstart', e.event); - } - }, + echarts.registerVisualCoding('chart', __webpack_require__(229)); - _drag: function (e) { - var draggingTarget = this._draggingTarget; - if (draggingTarget) { - var x = e.offsetX; - var y = e.offsetY; - var dx = x - this._x; - var dy = y - this._y; - this._x = x; - this._y = y; +/***/ }, +/* 216 */ +/***/ function(module, exports, __webpack_require__) { - draggingTarget.drift(dx, dy, e); - this._dispatchProxy(draggingTarget, 'drag', e.event); + - var dropTarget = this.findHover(x, y, draggingTarget); - var lastDropTarget = this._dropTarget; - this._dropTarget = dropTarget; + __webpack_require__(217); + __webpack_require__(220); + __webpack_require__(222); - if (draggingTarget !== dropTarget) { - if (lastDropTarget && dropTarget !== lastDropTarget) { - this._dispatchProxy(lastDropTarget, 'dragleave', e.event); - } - if (dropTarget && dropTarget !== lastDropTarget) { - this._dispatchProxy(dropTarget, 'dragenter', e.event); - } - } - } - }, + var echarts = __webpack_require__(1); - _dragEnd: function (e) { - var draggingTarget = this._draggingTarget; + // Parallel view + echarts.extendComponentView({ + type: 'parallel' + }); - if (draggingTarget) { - draggingTarget.dragging = false; - } + echarts.registerPreprocessor( + __webpack_require__(226) + ); - this._dispatchProxy(draggingTarget, 'dragend', e.event); - if (this._dropTarget) { - this._dispatchProxy(this._dropTarget, 'drop', e.event); - } - this._draggingTarget = null; - this._dropTarget = null; - } +/***/ }, +/* 217 */ +/***/ function(module, exports, __webpack_require__) { - }; + /** + * Parallel coordinate system creater. + */ - return Draggable; -}); -/** - * Only implements needed gestures for mobile. - */ -define('zrender/core/GestureMgr',['require'],function(require) { - - - - var GestureMgr = function () { - - /** - * @private - * @type {Array.} - */ - this._track = []; - }; - - GestureMgr.prototype = { - - constructor: GestureMgr, - - recognize: function (event, target) { - this._doTrack(event, target); - return this._recognize(event); - }, - - clear: function () { - this._track.length = 0; - return this; - }, - - _doTrack: function (event, target) { - var touches = event.touches; - - if (!touches) { - return; - } - - var trackItem = { - points: [], - touches: [], - target: target, - event: event - }; - - for (var i = 0, len = touches.length; i < len; i++) { - var touch = touches[i]; - trackItem.points.push([touch.clientX, touch.clientY]); - trackItem.touches.push(touch); - } - - this._track.push(trackItem); - }, - - _recognize: function (event) { - for (var eventName in recognizers) { - if (recognizers.hasOwnProperty(eventName)) { - var gestureInfo = recognizers[eventName](this._track, event); - if (gestureInfo) { - return gestureInfo; - } - } - } - } - }; - - function dist(pointPair) { - var dx = pointPair[1][0] - pointPair[0][0]; - var dy = pointPair[1][1] - pointPair[0][1]; - - return Math.sqrt(dx * dx + dy * dy); - } - - function center(pointPair) { - return [ - (pointPair[0][0] + pointPair[1][0]) / 2, - (pointPair[0][1] + pointPair[1][1]) / 2 - ]; - } - - var recognizers = { - - pinch: function (track, event) { - var trackLen = track.length; - - if (!trackLen) { - return; - } - - var pinchEnd = (track[trackLen - 1] || {}).points; - var pinchPre = (track[trackLen - 2] || {}).points || pinchEnd; - - if (pinchPre - && pinchPre.length > 1 - && pinchEnd - && pinchEnd.length > 1 - ) { - var pinchScale = dist(pinchEnd) / dist(pinchPre); - !isFinite(pinchScale) && (pinchScale = 1); - - event.pinchScale = pinchScale; - - var pinchCenter = center(pinchEnd); - event.pinchX = pinchCenter[0]; - event.pinchY = pinchCenter[1]; - - return { - type: 'pinch', - target: track[0].target, - event: event - }; - } - } - - // Only pinch currently. - }; - - return GestureMgr; -}); -/** - * Handler控制模块 - * @module zrender/Handler - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - * errorrik (errorrik@gmail.com) - * pissang (shenyi.914@gmail.com) - */ -define('zrender/Handler',['require','./core/env','./core/event','./core/util','./mixin/Draggable','./core/GestureMgr','./mixin/Eventful'],function (require) { - - - - var env = require('./core/env'); - var eventTool = require('./core/event'); - var util = require('./core/util'); - var Draggable = require('./mixin/Draggable'); - var GestureMgr = require('./core/GestureMgr'); - - var Eventful = require('./mixin/Eventful'); - - var mouseHandlerNames = [ - 'click', 'dblclick', 'mousewheel', 'mouseout' - ]; - !usePointerEvent() && mouseHandlerNames.push( - 'mouseup', 'mousedown', 'mousemove' - ); - - var touchHandlerNames = [ - 'touchstart', 'touchend', 'touchmove' - ]; - - var pointerHandlerNames = [ - 'pointerdown', 'pointerup', 'pointermove' - ]; - - var TOUCH_CLICK_DELAY = 300; - - // touch指尖错觉的尝试偏移量配置 - // var MOBILE_TOUCH_OFFSETS = [ - // { x: 10 }, - // { x: -20 }, - // { x: 10, y: 10 }, - // { y: -20 } - // ]; - - var addEventListener = eventTool.addEventListener; - var removeEventListener = eventTool.removeEventListener; - var normalizeEvent = eventTool.normalizeEvent; - - function makeEventPacket(eveType, target, event) { - return { - type: eveType, - event: event, - target: target, - cancelBubble: false, - offsetX: event.zrX, - offsetY: event.zrY, - gestureEvent: event.gestureEvent, - pinchX: event.pinchX, - pinchY: event.pinchY, - pinchScale: event.pinchScale, - wheelDelta: event.zrDelta - }; - } - - var domHandlers = { - /** - * Mouse move handler - * @inner - * @param {Event} event - */ - mousemove: function (event) { - event = normalizeEvent(this.root, event); - - var x = event.zrX; - var y = event.zrY; - - var hovered = this.findHover(x, y, null); - var lastHovered = this._hovered; - - this._hovered = hovered; - - this.root.style.cursor = hovered ? hovered.cursor : this._defaultCursorStyle; - // Mouse out on previous hovered element - if (lastHovered && hovered !== lastHovered && lastHovered.__zr) { - this._dispatchProxy(lastHovered, 'mouseout', event); - } - - // Mouse moving on one element - this._dispatchProxy(hovered, 'mousemove', event); - - // Mouse over on a new element - if (hovered && hovered !== lastHovered) { - this._dispatchProxy(hovered, 'mouseover', event); - } - }, - - /** - * Mouse out handler - * @inner - * @param {Event} event - */ - mouseout: function (event) { - event = normalizeEvent(this.root, event); - - var element = event.toElement || event.relatedTarget; - if (element != this.root) { - while (element && element.nodeType != 9) { - // 忽略包含在root中的dom引起的mouseOut - if (element === this.root) { - return; - } - - element = element.parentNode; - } - } - - this._dispatchProxy(this._hovered, 'mouseout', event); - - this.trigger('globalout', { - event: event - }); - }, - - /** - * Touch开始响应函数 - * @inner - * @param {Event} event - */ - touchstart: function (event) { - // FIXME - // 移动端可能需要default行为,例如静态图表时。 - // eventTool.stop(event);// 阻止浏览器默认事件,重要 - event = normalizeEvent(this.root, event); - - this._lastTouchMoment = new Date(); - - processGesture(this, event, 'start'); - - // 平板补充一次findHover - // this._mobileFindFixed(event); - // Trigger mousemove and mousedown - domHandlers.mousemove.call(this, event); - - domHandlers.mousedown.call(this, event); - - setTouchTimer(this); - }, - - /** - * Touch移动响应函数 - * @inner - * @param {Event} event - */ - touchmove: function (event) { - // eventTool.stop(event);// 阻止浏览器默认事件,重要 - event = normalizeEvent(this.root, event); - - processGesture(this, event, 'change'); - - // Mouse move should always be triggered no matter whether - // there is gestrue event, because mouse move and pinch may - // be used at the same time. - domHandlers.mousemove.call(this, event); - - setTouchTimer(this); - }, - - /** - * Touch结束响应函数 - * @inner - * @param {Event} event - */ - touchend: function (event) { - // eventTool.stop(event);// 阻止浏览器默认事件,重要 - event = normalizeEvent(this.root, event); - - processGesture(this, event, 'end'); - - domHandlers.mouseup.call(this, event); - - // click event should always be triggered no matter whether - // there is gestrue event. System click can not be prevented. - if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) { - // this._mobileFindFixed(event); - domHandlers.click.call(this, event); - } - - setTouchTimer(this); - } - }; - - // Common handlers - util.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick'], function (name) { - domHandlers[name] = function (event) { - event = normalizeEvent(this.root, event); - // Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover - var hovered = this.findHover(event.zrX, event.zrY, null); - this._dispatchProxy(hovered, name, event); - }; - }); - - // Pointer event handlers - // util.each(['pointerdown', 'pointermove', 'pointerup'], function (name) { - // domHandlers[name] = function (event) { - // var mouseName = name.replace('pointer', 'mouse'); - // domHandlers[mouseName].call(this, event); - // }; - // }); - - function processGesture(zrHandler, event, stage) { - var gestureMgr = zrHandler._gestureMgr; - - stage === 'start' && gestureMgr.clear(); - - var gestureInfo = gestureMgr.recognize( - event, - zrHandler.findHover(event.zrX, event.zrY, null) - ); - - stage === 'end' && gestureMgr.clear(); - - if (gestureInfo) { - // eventTool.stop(event); - var type = gestureInfo.type; - event.gestureEvent = type; - - zrHandler._dispatchProxy(gestureInfo.target, type, gestureInfo.event); - } - } - - /** - * 为控制类实例初始化dom 事件处理函数 - * - * @inner - * @param {module:zrender/Handler} instance 控制类实例 - */ - function initDomHandler(instance) { - var handlerNames = touchHandlerNames.concat(pointerHandlerNames); - for (var i = 0; i < handlerNames.length; i++) { - var name = handlerNames[i]; - instance._handlers[name] = util.bind(domHandlers[name], instance); - } - - for (var i = 0; i < mouseHandlerNames.length; i++) { - var name = mouseHandlerNames[i]; - instance._handlers[name] = makeMouseHandler(domHandlers[name], instance); - } - - function makeMouseHandler(fn, instance) { - return function () { - if (instance._touching) { - return; - } - return fn.apply(instance, arguments); - }; - } - } - - /** - * @alias module:zrender/Handler - * @constructor - * @extends module:zrender/mixin/Eventful - * @param {HTMLElement} root Main HTML element for painting. - * @param {module:zrender/Storage} storage Storage instance. - * @param {module:zrender/Painter} painter Painter instance. - */ - var Handler = function(root, storage, painter) { - Eventful.call(this); - - this.root = root; - this.storage = storage; - this.painter = painter; - - /** - * @private - * @type {boolean} - */ - this._hovered; - - /** - * @private - * @type {Date} - */ - this._lastTouchMoment; - - /** - * @private - * @type {number} - */ - this._lastX; - - /** - * @private - * @type {number} - */ - this._lastY; - - /** - * @private - * @type {string} - */ - this._defaultCursorStyle = 'default'; - - /** - * @private - * @type {module:zrender/core/GestureMgr} - */ - this._gestureMgr = new GestureMgr(); - - /** - * @private - * @type {Array.} - */ - this._handlers = []; - - /** - * @private - * @type {boolean} - */ - this._touching = false; - - /** - * @private - * @type {number} - */ - this._touchTimer; - - initDomHandler(this); - - if (usePointerEvent()) { - mountHandlers(pointerHandlerNames, this); - } - else if (useTouchEvent()) { - mountHandlers(touchHandlerNames, this); - - // Handler of 'mouseout' event is needed in touch mode, which will be mounted below. - // addEventListener(root, 'mouseout', this._mouseoutHandler); - } - - // Considering some devices that both enable touch and mouse event (like MS Surface - // and lenovo X240, @see #2350), we make mouse event be always listened, otherwise - // mouse event can not be handle in those devices. - mountHandlers(mouseHandlerNames, this); - - Draggable.call(this); - - function mountHandlers(handlerNames, instance) { - util.each(handlerNames, function (name) { - addEventListener(root, eventNameFix(name), instance._handlers[name]); - }, instance); - } - }; - - Handler.prototype = { - - constructor: Handler, - - /** - * Resize - */ - resize: function (event) { - this._hovered = null; - }, - - /** - * Dispatch event - * @param {string} eventName - * @param {event=} eventArgs - */ - dispatch: function (eventName, eventArgs) { - var handler = this._handlers[eventName]; - handler && handler.call(this, eventArgs); - }, - - /** - * Dispose - */ - dispose: function () { - var root = this.root; - - var handlerNames = mouseHandlerNames.concat(touchHandlerNames); - - for (var i = 0; i < handlerNames.length; i++) { - var name = handlerNames[i]; - removeEventListener(root, eventNameFix(name), this._handlers[name]); - } - - this.root = - this.storage = - this.painter = null; - }, - - /** - * 设置默认的cursor style - * @param {string} cursorStyle 例如 crosshair - */ - setDefaultCursorStyle: function (cursorStyle) { - this._defaultCursorStyle = cursorStyle; - }, - - /** - * 事件分发代理 - * - * @private - * @param {Object} targetEl 目标图形元素 - * @param {string} eventName 事件名称 - * @param {Object} event 事件对象 - */ - _dispatchProxy: function (targetEl, eventName, event) { - var eventHandler = 'on' + eventName; - var eventPacket = makeEventPacket(eventName, targetEl, event); - - var el = targetEl; - - while (el) { - el[eventHandler] - && (eventPacket.cancelBubble = el[eventHandler].call(el, eventPacket)); - - el.trigger(eventName, eventPacket); - - el = el.parent; - - if (eventPacket.cancelBubble) { - break; - } - } - - if (!eventPacket.cancelBubble) { - // 冒泡到顶级 zrender 对象 - this.trigger(eventName, eventPacket); - // 分发事件到用户自定义层 - // 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在 - this.painter && this.painter.eachOtherLayer(function (layer) { - if (typeof(layer[eventHandler]) == 'function') { - layer[eventHandler].call(layer, eventPacket); - } - if (layer.trigger) { - layer.trigger(eventName, eventPacket); - } - }); - } - }, - - /** - * @private - * @param {number} x - * @param {number} y - * @param {module:zrender/graphic/Displayable} exclude - * @method - */ - findHover: function(x, y, exclude) { - var list = this.storage.getDisplayList(); - for (var i = list.length - 1; i >= 0 ; i--) { - if (!list[i].silent - && list[i] !== exclude - && isHover(list[i], x, y)) { - return list[i]; - } - } - } - }; - - function isHover(displayable, x, y) { - if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) { - var p = displayable.parent; - while (p) { - if (p.clipPath && !p.clipPath.contain(x, y)) { - // Clipped by parents - return false; - } - p = p.parent; - } - return true; - } - - return false; - } - - /** - * Prevent mouse event from being dispatched after Touch Events action - * @see - * 1. Mobile browsers dispatch mouse events 300ms after touchend. - * 2. Chrome for Android dispatch mousedown for long-touch about 650ms - * Result: Blocking Mouse Events for 700ms. - */ - function setTouchTimer(instance) { - instance._touching = true; - clearTimeout(instance._touchTimer); - instance._touchTimer = setTimeout(function () { - instance._touching = false; - }, 700); - } - - /** - * Althought MS Surface support screen touch, IE10/11 do not support - * touch event and MS Edge supported them but not by default (but chrome - * and firefox do). Thus we use Pointer event on MS browsers to handle touch. - */ - function usePointerEvent() { - // TODO - // pointermove event dont trigger when using finger. - // We may figger it out latter. - return false; - // return env.pointerEventsSupported - // In no-touch device we dont use pointer evnets but just - // use mouse event for avoiding problems. - // && window.navigator.maxTouchPoints; - } - - function useTouchEvent() { - return env.touchEventsSupported; - } - - function eventNameFix(name) { - return (name === 'mousewheel' && env.firefox) ? 'DOMMouseScroll' : name; - } - - util.mixin(Handler, Eventful); - util.mixin(Handler, Draggable); - - return Handler; -}); -/** - * Storage内容仓库模块 - * @module zrender/Storage - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - * @author errorrik (errorrik@gmail.com) - * @author pissang (https://github.com/pissang/) - */ -define('zrender/Storage',['require','./core/util','./container/Group'],function (require) { - - - - var util = require('./core/util'); - - var Group = require('./container/Group'); - - function shapeCompareFunc(a, b) { - if (a.zlevel === b.zlevel) { - if (a.z === b.z) { - if (a.z2 === b.z2) { - return a.__renderidx - b.__renderidx; - } - return a.z2 - b.z2; - } - return a.z - b.z; - } - return a.zlevel - b.zlevel; - } - /** - * 内容仓库 (M) - * @alias module:zrender/Storage - * @constructor - */ - var Storage = function () { - // 所有常规形状,id索引的map - this._elements = {}; - - this._roots = []; - - this._displayList = []; - - this._displayListLen = 0; - }; - - Storage.prototype = { - - constructor: Storage, - - /** - * 返回所有图形的绘制队列 - * @param {boolean} [update=false] 是否在返回前更新该数组 - * 详见{@link module:zrender/graphic/Displayable.prototype.updateDisplayList} - * @return {Array.} - */ - getDisplayList: function (update) { - if (update) { - this.updateDisplayList(); - } - return this._displayList; - }, - - /** - * 更新图形的绘制队列。 - * 每次绘制前都会调用,该方法会先深度优先遍历整个树,更新所有Group和Shape的变换并且把所有可见的Shape保存到数组中, - * 最后根据绘制的优先级(zlevel > z > 插入顺序)排序得到绘制队列 - */ - updateDisplayList: function () { - this._displayListLen = 0; - var roots = this._roots; - var displayList = this._displayList; - for (var i = 0, len = roots.length; i < len; i++) { - var root = roots[i]; - this._updateAndAddDisplayable(root); - } - displayList.length = this._displayListLen; - - for (var i = 0, len = displayList.length; i < len; i++) { - displayList[i].__renderidx = i; - } - - displayList.sort(shapeCompareFunc); - }, - - _updateAndAddDisplayable: function (el, clipPaths) { - - if (el.ignore) { - return; - } - - el.beforeUpdate(); - - el.update(); - - el.afterUpdate(); - - var clipPath = el.clipPath; - if (clipPath) { - // clipPath 的变换是基于 group 的变换 - clipPath.parent = el; - clipPath.updateTransform(); - - // FIXME 效率影响 - if (clipPaths) { - clipPaths = clipPaths.slice(); - clipPaths.push(clipPath); - } - else { - clipPaths = [clipPath]; - } - } - - if (el.type == 'group') { - var children = el._children; - - for (var i = 0; i < children.length; i++) { - var child = children[i]; - - // Force to mark as dirty if group is dirty - // FIXME __dirtyPath ? - child.__dirty = el.__dirty || child.__dirty; - - this._updateAndAddDisplayable(child, clipPaths); - } - - // Mark group clean here - el.__dirty = false; - - } - else { - el.__clipPaths = clipPaths; - - this._displayList[this._displayListLen++] = el; - } - }, - - /** - * 添加图形(Shape)或者组(Group)到根节点 - * @param {module:zrender/Element} el - */ - addRoot: function (el) { - // Element has been added - if (this._elements[el.id]) { - return; - } - - if (el instanceof Group) { - el.addChildrenToStorage(this); - } - - this.addToMap(el); - this._roots.push(el); - }, - - /** - * 删除指定的图形(Shape)或者组(Group) - * @param {string|Array.} [elId] 如果为空清空整个Storage - */ - delRoot: function (elId) { - if (elId == null) { - // 不指定elId清空 - for (var i = 0; i < this._roots.length; i++) { - var root = this._roots[i]; - if (root instanceof Group) { - root.delChildrenFromStorage(this); - } - } - - this._elements = {}; - this._roots = []; - this._displayList = []; - this._displayListLen = 0; - - return; - } - - if (elId instanceof Array) { - for (var i = 0, l = elId.length; i < l; i++) { - this.delRoot(elId[i]); - } - return; - } - - var el; - if (typeof(elId) == 'string') { - el = this._elements[elId]; - } - else { - el = elId; - } - - var idx = util.indexOf(this._roots, el); - if (idx >= 0) { - this.delFromMap(el.id); - this._roots.splice(idx, 1); - if (el instanceof Group) { - el.delChildrenFromStorage(this); - } - } - }, - - addToMap: function (el) { - if (el instanceof Group) { - el.__storage = this; - } - el.dirty(); - - this._elements[el.id] = el; - - return this; - }, - - get: function (elId) { - return this._elements[elId]; - }, - - delFromMap: function (elId) { - var elements = this._elements; - var el = elements[elId]; - if (el) { - delete elements[elId]; - if (el instanceof Group) { - el.__storage = null; - } - } - - return this; - }, - - /** - * 清空并且释放Storage - */ - dispose: function () { - this._elements = - this._renderList = - this._roots = null; - } - }; - - return Storage; -}); + var Parallel = __webpack_require__(218); -/** - * 动画主类, 调度和管理所有动画控制器 - * - * @module zrender/animation/Animation - * @author pissang(https://github.com/pissang) - */ -// TODO Additive animation -// http://iosoteric.com/additive-animations-animatewithduration-in-ios-8/ -// https://developer.apple.com/videos/wwdc2014/#236 -define('zrender/animation/Animation',['require','../core/util','../core/event','./Animator'],function(require) { - - - - var util = require('../core/util'); - var Dispatcher = require('../core/event').Dispatcher; - - var requestAnimationFrame = (typeof window !== 'undefined' && - (window.requestAnimationFrame - || window.msRequestAnimationFrame - || window.mozRequestAnimationFrame - || window.webkitRequestAnimationFrame)) - || function (func) { - setTimeout(func, 16); - }; - - var Animator = require('./Animator'); - /** - * @typedef {Object} IZRenderStage - * @property {Function} update - */ - - /** - * @alias module:zrender/animation/Animation - * @constructor - * @param {Object} [options] - * @param {Function} [options.onframe] - * @param {IZRenderStage} [options.stage] - * @example - * var animation = new Animation(); - * var obj = { - * x: 100, - * y: 100 - * }; - * animation.animate(node.position) - * .when(1000, { - * x: 500, - * y: 500 - * }) - * .when(2000, { - * x: 100, - * y: 100 - * }) - * .start('spline'); - */ - var Animation = function (options) { - - options = options || {}; - - this.stage = options.stage || {}; - - this.onframe = options.onframe || function() {}; - - // private properties - this._clips = []; - - this._running = false; - - this._time = 0; - - Dispatcher.call(this); - }; - - Animation.prototype = { - - constructor: Animation, - /** - * 添加 clip - * @param {module:zrender/animation/Clip} clip - */ - addClip: function (clip) { - this._clips.push(clip); - }, - /** - * 添加 animator - * @param {module:zrender/animation/Animator} animator - */ - addAnimator: function (animator) { - animator.animation = this; - var clips = animator.getClips(); - for (var i = 0; i < clips.length; i++) { - this.addClip(clips[i]); - } - }, - /** - * 删除动画片段 - * @param {module:zrender/animation/Clip} clip - */ - removeClip: function(clip) { - var idx = util.indexOf(this._clips, clip); - if (idx >= 0) { - this._clips.splice(idx, 1); - } - }, - - /** - * 删除动画片段 - * @param {module:zrender/animation/Animator} animator - */ - removeAnimator: function (animator) { - var clips = animator.getClips(); - for (var i = 0; i < clips.length; i++) { - this.removeClip(clips[i]); - } - animator.animation = null; - }, - - _update: function() { - - var time = new Date().getTime(); - var delta = time - this._time; - var clips = this._clips; - var len = clips.length; - - var deferredEvents = []; - var deferredClips = []; - for (var i = 0; i < len; i++) { - var clip = clips[i]; - var e = clip.step(time); - // Throw out the events need to be called after - // stage.update, like destroy - if (e) { - deferredEvents.push(e); - deferredClips.push(clip); - } - } - - // Remove the finished clip - for (var i = 0; i < len;) { - if (clips[i]._needsRemove) { - clips[i] = clips[len - 1]; - clips.pop(); - len--; - } - else { - i++; - } - } - - len = deferredEvents.length; - for (var i = 0; i < len; i++) { - deferredClips[i].fire(deferredEvents[i]); - } - - this._time = time; - - this.onframe(delta); - - this.trigger('frame', delta); - - if (this.stage.update) { - this.stage.update(); - } - }, - /** - * 开始运行动画 - */ - start: function () { - var self = this; - - this._running = true; - - function step() { - if (self._running) { - - requestAnimationFrame(step); - - self._update(); - } - } - - this._time = new Date().getTime(); - requestAnimationFrame(step); - }, - /** - * 停止运行动画 - */ - stop: function () { - this._running = false; - }, - /** - * 清除所有动画片段 - */ - clear: function () { - this._clips = []; - }, - /** - * 对一个目标创建一个animator对象,可以指定目标中的属性使用动画 - * @param {Object} target - * @param {Object} options - * @param {boolean} [options.loop=false] 是否循环播放动画 - * @param {Function} [options.getter=null] - * 如果指定getter函数,会通过getter函数取属性值 - * @param {Function} [options.setter=null] - * 如果指定setter函数,会通过setter函数设置属性值 - * @return {module:zrender/animation/Animation~Animator} - */ - animate: function (target, options) { - options = options || {}; - var animator = new Animator( - target, - options.loop, - options.getter, - options.setter - ); - - return animator; - } - }; - - util.mixin(Animation, Dispatcher); - - return Animation; -}); + function create(ecModel, api) { + var coordSysList = []; -/** - * @module zrender/Layer - * @author pissang(https://www.github.com/pissang) - */ -define('zrender/Layer',['require','./core/util','./config'],function (require) { - - var util = require('./core/util'); - var config = require('./config'); - - function returnFalse() { - return false; - } - - /** - * 创建dom - * - * @inner - * @param {string} id dom id 待用 - * @param {string} type dom type,such as canvas, div etc. - * @param {Painter} painter painter instance - * @param {number} number - */ - function createDom(id, type, painter, dpr) { - var newDom = document.createElement(type); - var width = painter.getWidth(); - var height = painter.getHeight(); - - var newDomStyle = newDom.style; - // 没append呢,请原谅我这样写,清晰~ - newDomStyle.position = 'absolute'; - newDomStyle.left = 0; - newDomStyle.top = 0; - newDomStyle.width = width + 'px'; - newDomStyle.height = height + 'px'; - newDom.width = width * dpr; - newDom.height = height * dpr; - - // id不作为索引用,避免可能造成的重名,定义为私有属性 - newDom.setAttribute('data-zr-dom-id', id); - return newDom; - } - - /** - * @alias module:zrender/Layer - * @constructor - * @extends module:zrender/mixin/Transformable - * @param {string} id - * @param {module:zrender/Painter} painter - * @param {number} [dpr] - */ - var Layer = function(id, painter, dpr) { - var dom; - dpr = dpr || config.devicePixelRatio; - if (typeof id === 'string') { - dom = createDom(id, 'canvas', painter, dpr); - } - // Not using isDom because in node it will return false - else if (util.isObject(id)) { - dom = id; - id = dom.id; - } - this.id = id; - this.dom = dom; - - var domStyle = dom.style; - if (domStyle) { // Not in node - dom.onselectstart = returnFalse; // 避免页面选中的尴尬 - domStyle['-webkit-user-select'] = 'none'; - domStyle['user-select'] = 'none'; - domStyle['-webkit-touch-callout'] = 'none'; - domStyle['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)'; - } - - this.domBack = null; - this.ctxBack = null; - - this.painter = painter; - - this.config = null; - - // Configs - /** - * 每次清空画布的颜色 - * @type {string} - * @default 0 - */ - this.clearColor = 0; - /** - * 是否开启动态模糊 - * @type {boolean} - * @default false - */ - this.motionBlur = false; - /** - * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 - * @type {number} - * @default 0.7 - */ - this.lastFrameAlpha = 0.7; - - /** - * Layer dpr - * @type {number} - */ - this.dpr = dpr; - }; - - Layer.prototype = { - - constructor: Layer, - - elCount: 0, - - __dirty: true, - - initContext: function () { - this.ctx = this.dom.getContext('2d'); - - var dpr = this.dpr; - if (dpr != 1) { - this.ctx.scale(dpr, dpr); - } - }, - - createBackBuffer: function () { - var dpr = this.dpr; - - this.domBack = createDom('back-' + this.id, 'canvas', this.painter, dpr); - this.ctxBack = this.domBack.getContext('2d'); - - if (dpr != 1) { - this.ctxBack.scale(dpr, dpr); - } - }, - - /** - * @param {number} width - * @param {number} height - */ - resize: function (width, height) { - var dpr = this.dpr; - - var dom = this.dom; - var domStyle = dom.style; - var domBack = this.domBack; - - domStyle.width = width + 'px'; - domStyle.height = height + 'px'; - - dom.width = width * dpr; - dom.height = height * dpr; - - if (dpr != 1) { - this.ctx.scale(dpr, dpr); - } - - if (domBack) { - domBack.width = width * dpr; - domBack.height = height * dpr; - - if (dpr != 1) { - this.ctxBack.scale(dpr, dpr); - } - } - }, - - /** - * 清空该层画布 - * @param {boolean} clearAll Clear all with out motion blur - */ - clear: function (clearAll) { - var dom = this.dom; - var ctx = this.ctx; - var width = dom.width; - var height = dom.height; - - var haveClearColor = this.clearColor; - var haveMotionBLur = this.motionBlur && !clearAll; - var lastFrameAlpha = this.lastFrameAlpha; - - var dpr = this.dpr; - - if (haveMotionBLur) { - if (!this.domBack) { - this.createBackBuffer(); - } - - this.ctxBack.globalCompositeOperation = 'copy'; - this.ctxBack.drawImage( - dom, 0, 0, - width / dpr, - height / dpr - ); - } - - ctx.clearRect(0, 0, width / dpr, height / dpr); - if (haveClearColor) { - ctx.save(); - ctx.fillStyle = this.clearColor; - ctx.fillRect(0, 0, width / dpr, height / dpr); - ctx.restore(); - } - - if (haveMotionBLur) { - var domBack = this.domBack; - ctx.save(); - ctx.globalAlpha = lastFrameAlpha; - ctx.drawImage(domBack, 0, 0, width / dpr, height / dpr); - ctx.restore(); - } - } - }; - - return Layer; -}); -/** - * Default canvas painter - * @module zrender/Painter - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - * errorrik (errorrik@gmail.com) - * pissang (https://www.github.com/pissang) - */ - define('zrender/Painter',['require','./config','./core/util','./core/log','./core/BoundingRect','./Layer','./graphic/Image'],function (require) { - - - var config = require('./config'); - var util = require('./core/util'); - var log = require('./core/log'); - var BoundingRect = require('./core/BoundingRect'); - - var Layer = require('./Layer'); - - function parseInt10(val) { - return parseInt(val, 10); - } - - function isLayerValid(layer) { - if (!layer) { - return false; - } - - if (layer.isBuildin) { - return true; - } - - if (typeof(layer.resize) !== 'function' - || typeof(layer.refresh) !== 'function' - ) { - return false; - } - - return true; - } - - function preProcessLayer(layer) { - layer.__unusedCount++; - } - - function postProcessLayer(layer) { - layer.__dirty = false; - if (layer.__unusedCount == 1) { - layer.clear(); - } - } - - var tmpRect = new BoundingRect(0, 0, 0, 0); - var viewRect = new BoundingRect(0, 0, 0, 0); - function isDisplayableCulled(el, width, height) { - tmpRect.copy(el.getBoundingRect()); - if (el.transform) { - tmpRect.applyTransform(el.transform); - } - viewRect.width = width; - viewRect.height = height; - return !tmpRect.intersect(viewRect); - } - - function isClipPathChanged(clipPaths, prevClipPaths) { - if (!clipPaths || !prevClipPaths || (clipPaths.length !== prevClipPaths.length)) { - return true; - } - for (var i = 0; i < clipPaths.length; i++) { - if (clipPaths[i] !== prevClipPaths[i]) { - return true; - } - } - } - - function doClip(clipPaths, ctx) { - for (var i = 0; i < clipPaths.length; i++) { - var clipPath = clipPaths[i]; - var m; - if (clipPath.transform) { - m = clipPath.transform; - ctx.transform( - m[0], m[1], - m[2], m[3], - m[4], m[5] - ); - } - var path = clipPath.path; - path.beginPath(ctx); - clipPath.buildPath(path, clipPath.shape); - ctx.clip(); - // Transform back - if (clipPath.transform) { - m = clipPath.invTransform; - ctx.transform( - m[0], m[1], - m[2], m[3], - m[4], m[5] - ); - } - } - } - - /** - * @alias module:zrender/Painter - * @constructor - * @param {HTMLElement} root 绘图容器 - * @param {module:zrender/Storage} storage - * @param {Ojbect} opts - */ - var Painter = function (root, storage, opts) { - var singleCanvas = !root.nodeName // In node ? - || root.nodeName.toUpperCase() === 'CANVAS'; - - opts = opts || {}; - - /** - * @type {number} - */ - this.dpr = opts.devicePixelRatio || config.devicePixelRatio; - /** - * @type {boolean} - * @private - */ - this._singleCanvas = singleCanvas; - /** - * 绘图容器 - * @type {HTMLElement} - */ - this.root = root; - - var rootStyle = root.style; - - // In node environment using node-canvas - if (rootStyle) { - rootStyle['-webkit-tap-highlight-color'] = 'transparent'; - rootStyle['-webkit-user-select'] = 'none'; - rootStyle['user-select'] = 'none'; - rootStyle['-webkit-touch-callout'] = 'none'; - - root.innerHTML = ''; - } - - /** - * @type {module:zrender/Storage} - */ - this.storage = storage; - - if (!singleCanvas) { - var width = this._getWidth(); - var height = this._getHeight(); - this._width = width; - this._height = height; - - var domRoot = document.createElement('div'); - this._domRoot = domRoot; - var domRootStyle = domRoot.style; - - // domRoot.onselectstart = returnFalse; // 避免页面选中的尴尬 - domRootStyle.position = 'relative'; - domRootStyle.overflow = 'hidden'; - domRootStyle.width = this._width + 'px'; - domRootStyle.height = this._height + 'px'; - root.appendChild(domRoot); - - /** - * @type {Object.} - * @private - */ - this._layers = {}; - /** - * @type {Array.} - * @private - */ - this._zlevelList = []; - } - else { - // Use canvas width and height directly - var width = root.width; - var height = root.height; - this._width = width; - this._height = height; - - // Create layer if only one given canvas - // Device pixel ratio is fixed to 1 because given canvas has its specified width and height - var mainLayer = new Layer(root, this, 1); - mainLayer.initContext(); - // FIXME Use canvas width and height - // mainLayer.resize(width, height); - this._layers = { - 0: mainLayer - }; - this._zlevelList = [0]; - } - - this._layerConfig = {}; - - this.pathToImage = this._createPathToImage(); - }; - - Painter.prototype = { - - constructor: Painter, - - /** - * If painter use a single canvas - * @return {boolean} - */ - isSingleCanvas: function () { - return this._singleCanvas; - }, - /** - * @return {HTMLDivElement} - */ - getViewportRoot: function () { - return this._singleCanvas ? this._layers[0].dom : this._domRoot; - }, - - /** - * 刷新 - * @param {boolean} [paintAll=false] 强制绘制所有displayable - */ - refresh: function (paintAll) { - var list = this.storage.getDisplayList(true); - var zlevelList = this._zlevelList; - - this._paintList(list, paintAll); - - // Paint custum layers - for (var i = 0; i < zlevelList.length; i++) { - var z = zlevelList[i]; - var layer = this._layers[z]; - if (!layer.isBuildin && layer.refresh) { - layer.refresh(); - } - } - - return this; - }, - - _paintList: function (list, paintAll) { - - if (paintAll == null) { - paintAll = false; - } - - this._updateLayerStatus(list); - - var currentLayer; - var currentZLevel; - var ctx; - - var viewWidth = this._width; - var viewHeight = this._height; - - this.eachBuildinLayer(preProcessLayer); - - // var invTransform = []; - var prevElClipPaths = null; - - for (var i = 0, l = list.length; i < l; i++) { - var el = list[i]; - var elZLevel = this._singleCanvas ? 0 : el.zlevel; - // Change draw layer - if (currentZLevel !== elZLevel) { - // Only 0 zlevel if only has one canvas - currentZLevel = elZLevel; - currentLayer = this.getLayer(currentZLevel); - - if (!currentLayer.isBuildin) { - log( - 'ZLevel ' + currentZLevel - + ' has been used by unkown layer ' + currentLayer.id - ); - } - - ctx = currentLayer.ctx; - - // Reset the count - currentLayer.__unusedCount = 0; - - if (currentLayer.__dirty || paintAll) { - currentLayer.clear(); - } - } - - if ( - (currentLayer.__dirty || paintAll) - // Ignore invisible element - && !el.invisible - // Ignore transparent element - && el.style.opacity !== 0 - // Ignore scale 0 element, in some environment like node-canvas - // Draw a scale 0 element can cause all following draw wrong - && el.scale[0] && el.scale[1] - // Ignore culled element - && !(el.culling && isDisplayableCulled(el, viewWidth, viewHeight)) - ) { - var clipPaths = el.__clipPaths; - - // Optimize when clipping on group with several elements - if (isClipPathChanged(clipPaths, prevElClipPaths)) { - // If has previous clipping state, restore from it - if (prevElClipPaths) { - ctx.restore(); - } - // New clipping state - if (clipPaths) { - ctx.save(); - doClip(clipPaths, ctx); - } - prevElClipPaths = clipPaths; - } - // TODO Use events ? - el.beforeBrush && el.beforeBrush(ctx); - el.brush(ctx, false); - el.afterBrush && el.afterBrush(ctx); - } - - el.__dirty = false; - } - - // If still has clipping state - if (prevElClipPaths) { - ctx.restore(); - } - - this.eachBuildinLayer(postProcessLayer); - }, - - /** - * 获取 zlevel 所在层,如果不存在则会创建一个新的层 - * @param {number} zlevel - * @return {module:zrender/Layer} - */ - getLayer: function (zlevel) { - if (this._singleCanvas) { - return this._layers[0]; - } - - var layer = this._layers[zlevel]; - if (!layer) { - // Create a new layer - layer = new Layer('zr_' + zlevel, this, this.dpr); - layer.isBuildin = true; - - if (this._layerConfig[zlevel]) { - util.merge(layer, this._layerConfig[zlevel], true); - } - - this.insertLayer(zlevel, layer); - - // Context is created after dom inserted to document - // Or excanvas will get 0px clientWidth and clientHeight - layer.initContext(); - } - - return layer; - }, - - insertLayer: function (zlevel, layer) { - - var layersMap = this._layers; - var zlevelList = this._zlevelList; - var len = zlevelList.length; - var prevLayer = null; - var i = -1; - var domRoot = this._domRoot; - - if (layersMap[zlevel]) { - log('ZLevel ' + zlevel + ' has been used already'); - return; - } - // Check if is a valid layer - if (!isLayerValid(layer)) { - log('Layer of zlevel ' + zlevel + ' is not valid'); - return; - } - - if (len > 0 && zlevel > zlevelList[0]) { - for (i = 0; i < len - 1; i++) { - if ( - zlevelList[i] < zlevel - && zlevelList[i + 1] > zlevel - ) { - break; - } - } - prevLayer = layersMap[zlevelList[i]]; - } - zlevelList.splice(i + 1, 0, zlevel); - - if (prevLayer) { - var prevDom = prevLayer.dom; - if (prevDom.nextSibling) { - domRoot.insertBefore( - layer.dom, - prevDom.nextSibling - ); - } - else { - domRoot.appendChild(layer.dom); - } - } - else { - if (domRoot.firstChild) { - domRoot.insertBefore(layer.dom, domRoot.firstChild); - } - else { - domRoot.appendChild(layer.dom); - } - } - - layersMap[zlevel] = layer; - }, - - // Iterate each layer - eachLayer: function (cb, context) { - var zlevelList = this._zlevelList; - var z; - var i; - for (i = 0; i < zlevelList.length; i++) { - z = zlevelList[i]; - cb.call(context, this._layers[z], z); - } - }, - - // Iterate each buildin layer - eachBuildinLayer: function (cb, context) { - var zlevelList = this._zlevelList; - var layer; - var z; - var i; - for (i = 0; i < zlevelList.length; i++) { - z = zlevelList[i]; - layer = this._layers[z]; - if (layer.isBuildin) { - cb.call(context, layer, z); - } - } - }, - - // Iterate each other layer except buildin layer - eachOtherLayer: function (cb, context) { - var zlevelList = this._zlevelList; - var layer; - var z; - var i; - for (i = 0; i < zlevelList.length; i++) { - z = zlevelList[i]; - layer = this._layers[z]; - if (! layer.isBuildin) { - cb.call(context, layer, z); - } - } - }, - - /** - * 获取所有已创建的层 - * @param {Array.} [prevLayer] - */ - getLayers: function () { - return this._layers; - }, - - _updateLayerStatus: function (list) { - - var layers = this._layers; - - var elCounts = {}; - - this.eachBuildinLayer(function (layer, z) { - elCounts[z] = layer.elCount; - layer.elCount = 0; - }); - - for (var i = 0, l = list.length; i < l; i++) { - var el = list[i]; - var zlevel = this._singleCanvas ? 0 : el.zlevel; - var layer = layers[zlevel]; - if (layer) { - layer.elCount++; - // 已经被标记为需要刷新 - if (layer.__dirty) { - continue; - } - layer.__dirty = el.__dirty; - } - } - - // 层中的元素数量有发生变化 - this.eachBuildinLayer(function (layer, z) { - if (elCounts[z] !== layer.elCount) { - layer.__dirty = true; - } - }); - }, - - /** - * 清除hover层外所有内容 - */ - clear: function () { - this.eachBuildinLayer(this._clearLayer); - return this; - }, - - _clearLayer: function (layer) { - layer.clear(); - }, - - /** - * 修改指定zlevel的绘制参数 - * - * @param {string} zlevel - * @param {Object} config 配置对象 - * @param {string} [config.clearColor=0] 每次清空画布的颜色 - * @param {string} [config.motionBlur=false] 是否开启动态模糊 - * @param {number} [config.lastFrameAlpha=0.7] - * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 - */ - configLayer: function (zlevel, config) { - if (config) { - var layerConfig = this._layerConfig; - if (!layerConfig[zlevel]) { - layerConfig[zlevel] = config; - } - else { - util.merge(layerConfig[zlevel], config, true); - } - - var layer = this._layers[zlevel]; - - if (layer) { - util.merge(layer, layerConfig[zlevel], true); - } - } - }, - - /** - * 删除指定层 - * @param {number} zlevel 层所在的zlevel - */ - delLayer: function (zlevel) { - var layers = this._layers; - var zlevelList = this._zlevelList; - var layer = layers[zlevel]; - if (!layer) { - return; - } - layer.dom.parentNode.removeChild(layer.dom); - delete layers[zlevel]; - - zlevelList.splice(util.indexOf(zlevelList, zlevel), 1); - }, - - /** - * 区域大小变化后重绘 - */ - resize: function (width, height) { - var domRoot = this._domRoot; - // FIXME Why ? - domRoot.style.display = 'none'; - - width = width || this._getWidth(); - height = height || this._getHeight(); - - domRoot.style.display = ''; - - // 优化没有实际改变的resize - if (this._width != width || height != this._height) { - domRoot.style.width = width + 'px'; - domRoot.style.height = height + 'px'; - - for (var id in this._layers) { - this._layers[id].resize(width, height); - } - - this.refresh(true); - } - - this._width = width; - this._height = height; - - return this; - }, - - /** - * 清除单独的一个层 - * @param {number} zlevel - */ - clearLayer: function (zlevel) { - var layer = this._layers[zlevel]; - if (layer) { - layer.clear(); - } - }, - - /** - * 释放 - */ - dispose: function () { - this.root.innerHTML = ''; - - this.root = - this.storage = - - this._domRoot = - this._layers = null; - }, - - /** - * Get canvas which has all thing rendered - * @param {Object} opts - * @param {string} [opts.backgroundColor] - */ - getRenderedCanvas: function (opts) { - opts = opts || {}; - if (this._singleCanvas) { - return this._layers[0].dom; - } - - var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr); - imageLayer.initContext(); - - var ctx = imageLayer.ctx; - imageLayer.clearColor = opts.backgroundColor; - imageLayer.clear(); - - var displayList = this.storage.getDisplayList(true); - - for (var i = 0; i < displayList.length; i++) { - var el = displayList[i]; - if (!el.invisible) { - el.beforeBrush && el.beforeBrush(ctx); - // TODO Check image cross origin - el.brush(ctx, false); - el.afterBrush && el.afterBrush(ctx); - } - } - - return imageLayer.dom; - }, - /** - * 获取绘图区域宽度 - */ - getWidth: function () { - return this._width; - }, - - /** - * 获取绘图区域高度 - */ - getHeight: function () { - return this._height; - }, - - _getWidth: function () { - var root = this.root; - var stl = document.defaultView.getComputedStyle(root); - - // FIXME Better way to get the width and height when element has not been append to the document - return ((root.clientWidth || parseInt10(stl.width) || parseInt10(root.style.width)) - - (parseInt10(stl.paddingLeft) || 0) - - (parseInt10(stl.paddingRight) || 0)) | 0; - }, - - _getHeight: function () { - var root = this.root; - var stl = document.defaultView.getComputedStyle(root); - - return ((root.clientHeight || parseInt10(stl.height) || parseInt10(root.style.height)) - - (parseInt10(stl.paddingTop) || 0) - - (parseInt10(stl.paddingBottom) || 0)) | 0; - }, - - _pathToImage: function (id, path, width, height, dpr) { - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - - canvas.width = width * dpr; - canvas.height = height * dpr; - - ctx.clearRect(0, 0, width * dpr, height * dpr); - - var pathTransform = { - position: path.position, - rotation: path.rotation, - scale: path.scale - }; - path.position = [0, 0, 0]; - path.rotation = 0; - path.scale = [1, 1]; - if (path) { - path.brush(ctx); - } - - var ImageShape = require('./graphic/Image'); - var imgShape = new ImageShape({ - id: id, - style: { - x: 0, - y: 0, - image: canvas - } - }); - - if (pathTransform.position != null) { - imgShape.position = path.position = pathTransform.position; - } - - if (pathTransform.rotation != null) { - imgShape.rotation = path.rotation = pathTransform.rotation; - } - - if (pathTransform.scale != null) { - imgShape.scale = path.scale = pathTransform.scale; - } - - return imgShape; - }, - - _createPathToImage: function () { - var me = this; - - return function (id, e, width, height) { - return me._pathToImage( - id, e, width, height, me.dpr - ); - }; - } - }; - - return Painter; -}); + ecModel.eachComponent('parallel', function (parallelModel, idx) { + var coordSys = new Parallel(parallelModel, ecModel, api); -/*! - * ZRender, a high performance 2d drawing library. - * - * Copyright (c) 2013, Baidu Inc. - * All rights reserved. - * - * LICENSE - * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt - */ -// Global defines -define('zrender/zrender',['require','./core/guid','./core/env','./Handler','./Storage','./animation/Animation','./Painter'],function(require) { - var guid = require('./core/guid'); - var env = require('./core/env'); - - var Handler = require('./Handler'); - var Storage = require('./Storage'); - var Animation = require('./animation/Animation'); - - var useVML = !env.canvasSupported; - - var painterCtors = { - canvas: require('./Painter') - }; - - var instances = {}; // ZRender实例map索引 - - var zrender = {}; - /** - * @type {string} - */ - zrender.version = '3.0.3'; - - /** - * @param {HTMLElement} dom - * @param {Object} opts - * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg' - * @param {number} [opts.devicePixelRatio] - * @return {module:zrender/ZRender} - */ - zrender.init = function(dom, opts) { - var zr = new ZRender(guid(), dom, opts); - instances[zr.id] = zr; - return zr; - }; - - /** - * Dispose zrender instance - * @param {module:zrender/ZRender} zr - */ - zrender.dispose = function (zr) { - if (zr) { - zr.dispose(); - } - else { - for (var key in instances) { - instances[key].dispose(); - } - instances = {}; - } - - return zrender; - }; - - /** - * 获取zrender实例 - * @param {string} id ZRender对象索引 - * @return {module:zrender/ZRender} - */ - zrender.getInstance = function (id) { - return instances[id]; - }; - - zrender.registerPainter = function (name, Ctor) { - painterCtors[name] = Ctor; - }; - - function delInstance(id) { - delete instances[id]; - } - - /** - * @module zrender/ZRender - */ - /** - * @constructor - * @alias module:zrender/ZRender - * @param {string} id - * @param {HTMLDomElement} dom - * @param {Object} opts - * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg' - * @param {number} [opts.devicePixelRatio] - */ - var ZRender = function(id, dom, opts) { - - opts = opts || {}; - - /** - * @type {HTMLDomElement} - */ - this.dom = dom; - - /** - * @type {string} - */ - this.id = id; - - var self = this; - var storage = new Storage(); - - var rendererType = opts.renderer; - if (useVML) { - if (!painterCtors.vml) { - throw new Error('You need to require \'zrender/vml/vml\' to support IE8'); - } - rendererType = 'vml'; - } - else if (!rendererType || !painterCtors[rendererType]) { - rendererType = 'canvas'; - } - var painter = new painterCtors[rendererType](dom, storage, opts); - - this.storage = storage; - this.painter = painter; - if (!env.node) { - this.handler = new Handler(painter.getViewportRoot(), storage, painter); - } - - /** - * @type {module:zrender/animation/Animation} - */ - this.animation = new Animation({ - stage: { - update: function () { - if (self._needsRefresh) { - self.refreshImmediately(); - } - } - } - }); - this.animation.start(); - - /** - * @type {boolean} - * @private - */ - this._needsRefresh; - - // 修改 storage.delFromMap, 每次删除元素之前删除动画 - // FIXME 有点ugly - var oldDelFromMap = storage.delFromMap; - var oldAddToMap = storage.addToMap; - - storage.delFromMap = function (elId) { - var el = storage.get(elId); - - oldDelFromMap.call(storage, elId); - - el && el.removeSelfFromZr(self); - }; - - storage.addToMap = function (el) { - oldAddToMap.call(storage, el); - - el.addSelfToZr(self); - }; - }; - - ZRender.prototype = { - - constructor: ZRender, - /** - * 获取实例唯一标识 - * @return {string} - */ - getId: function () { - return this.id; - }, - - /** - * 添加元素 - * @param {string|module:zrender/Element} el - */ - add: function (el) { - this.storage.addRoot(el); - this._needsRefresh = true; - }, - - /** - * 删除元素 - * @param {string|module:zrender/Element} el - */ - remove: function (el) { - this.storage.delRoot(el); - this._needsRefresh = true; - }, - - /** - * 修改指定zlevel的绘制配置项 - * - * @param {string} zLevel - * @param {Object} config 配置对象 - * @param {string} [config.clearColor=0] 每次清空画布的颜色 - * @param {string} [config.motionBlur=false] 是否开启动态模糊 - * @param {number} [config.lastFrameAlpha=0.7] - * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 - */ - configLayer: function (zLevel, config) { - this.painter.configLayer(zLevel, config); - this._needsRefresh = true; - }, - - /** - * 视图更新 - */ - refreshImmediately: function () { - // Clear needsRefresh ahead to avoid something wrong happens in refresh - // Or it will cause zrender refreshes again and again. - this._needsRefresh = false; - this.painter.refresh(); - /** - * Avoid trigger zr.refresh in Element#beforeUpdate hook - */ - this._needsRefresh = false; - }, - - /** - * 标记视图在浏览器下一帧需要绘制 - */ - refresh: function() { - this._needsRefresh = true; - }, - - /** - * 调整视图大小 - */ - resize: function() { - this.painter.resize(); - this.handler && this.handler.resize(); - }, - - /** - * 停止所有动画 - */ - clearAnimation: function () { - this.animation.clear(); - }, - - /** - * 获取视图宽度 - */ - getWidth: function() { - return this.painter.getWidth(); - }, - - /** - * 获取视图高度 - */ - getHeight: function() { - return this.painter.getHeight(); - }, - - /** - * 图像导出 - * @param {string} type - * @param {string} [backgroundColor='#fff'] 背景色 - * @return {string} 图片的Base64 url - */ - toDataURL: function(type, backgroundColor, args) { - return this.painter.toDataURL(type, backgroundColor, args); - }, - - /** - * 将常规shape转成image shape - * @param {module:zrender/graphic/Path} e - * @param {number} width - * @param {number} height - */ - pathToImage: function(e, width, height) { - var id = guid(); - return this.painter.pathToImage(id, e, width, height); - }, - - /** - * 设置默认的cursor style - * @param {string} cursorStyle 例如 crosshair - */ - setDefaultCursorStyle: function (cursorStyle) { - this.handler.setDefaultCursorStyle(cursorStyle); - }, - - /** - * 事件绑定 - * - * @param {string} eventName 事件名称 - * @param {Function} eventHandler 响应函数 - * @param {Object} [context] 响应函数 - */ - on: function(eventName, eventHandler, context) { - this.handler && this.handler.on(eventName, eventHandler, context); - }, - - /** - * 事件解绑定,参数为空则解绑所有自定义事件 - * - * @param {string} eventName 事件名称 - * @param {Function} eventHandler 响应函数 - */ - off: function(eventName, eventHandler) { - this.handler && this.handler.off(eventName, eventHandler); - }, - - /** - * 事件触发 - * - * @param {string} eventName 事件名称,resize,hover,drag,etc - * @param {event=} event event dom事件对象 - */ - trigger: function (eventName, event) { - this.handler && this.handler.trigger(eventName, event); - }, - - - /** - * 清除当前ZRender下所有类图的数据和显示,clear后MVC和已绑定事件均还存在在,ZRender可用 - */ - clear: function () { - this.storage.delRoot(); - this.painter.clear(); - }, - - /** - * 释放当前ZR实例(删除包括dom,数据、显示和事件绑定),dispose后ZR不可用 - */ - dispose: function () { - this.animation.stop(); - - this.clear(); - this.storage.dispose(); - this.painter.dispose(); - this.handler && this.handler.dispose(); - - this.animation = - this.storage = - this.painter = - this.handler = null; - - delInstance(this.id); - } - }; - - return zrender; -}); + coordSys.name = 'parallel_' + idx; + coordSys.resize(parallelModel, api); -define('zrender', ['zrender/zrender'], function (main) { return main; }); - -define('echarts/loading/default',['require','../util/graphic','zrender/core/util'],function (require) { - - var graphic = require('../util/graphic'); - var zrUtil = require('zrender/core/util'); - var PI = Math.PI; - /** - * @param {module:echarts/ExtensionAPI} api - * @param {Object} [opts] - * @param {string} [opts.text] - * @param {string} [opts.color] - * @param {string} [opts.textColor] - * @return {module:zrender/Element} - */ - return function (api, opts) { - opts = opts || {}; - zrUtil.defaults(opts, { - text: 'loading', - color: '#c23531', - textColor: '#000', - maskColor: 'rgba(255, 255, 255, 0.8)', - zlevel: 0 - }); - var mask = new graphic.Rect({ - style: { - fill: opts.maskColor - }, - zlevel: opts.zlevel, - z: 10000 - }); - var arc = new graphic.Arc({ - shape: { - startAngle: -PI / 2, - endAngle: -PI / 2 + 0.1, - r: 10 - }, - style: { - stroke: opts.color, - lineCap: 'round', - lineWidth: 5 - }, - zlevel: opts.zlevel, - z: 10001 - }); - var labelRect = new graphic.Rect({ - style: { - fill: 'none', - text: opts.text, - textPosition: 'right', - textDistance: 10, - textFill: opts.textColor - }, - zlevel: opts.zlevel, - z: 10001 - }); - - arc.animateShape(true) - .when(1000, { - endAngle: PI * 3 / 2 - }) - .start('circularInOut'); - arc.animateShape(true) - .when(1000, { - startAngle: PI * 3 / 2 - }) - .delay(300) - .start('circularInOut'); - - var group = new graphic.Group(); - group.add(arc); - group.add(labelRect); - group.add(mask); - // Inject resize - group.resize = function () { - var cx = api.getWidth() / 2; - var cy = api.getHeight() / 2; - arc.setShape({ - cx: cx, - cy: cy - }); - var r = arc.shape.r; - labelRect.setShape({ - x: cx - r, - y: cy - r, - width: r * 2, - height: r * 2 - }); - - mask.setShape({ - x: 0, - y: 0, - width: api.getWidth(), - height: api.getHeight() - }); - }; - group.resize(); - return group; - }; -}); -define('echarts/visual/seriesColor',['require','zrender/graphic/Gradient'],function (require) { - var Gradient = require('zrender/graphic/Gradient'); - return function (seriesType, styleType, ecModel) { - function encodeColor(seriesModel) { - var colorAccessPath = [styleType, 'normal', 'color']; - var colorList = ecModel.get('color'); - var data = seriesModel.getData(); - var color = seriesModel.get(colorAccessPath) // Set in itemStyle - || colorList[seriesModel.seriesIndex % colorList.length]; // Default color - - // FIXME Set color function or use the platte color - data.setVisual('color', color); - - // Only visible series has each data be visual encoded - if (!ecModel.isSeriesFiltered(seriesModel)) { - if (typeof color === 'function' && !(color instanceof Gradient)) { - data.each(function (idx) { - data.setItemVisual( - idx, 'color', color(seriesModel.getDataParams(idx)) - ); - }); - } - - data.each(function (idx) { - var itemModel = data.getItemModel(idx); - var color = itemModel.get(colorAccessPath, true); - if (color != null) { - data.setItemVisual(idx, 'color', color); - } - }); - } - } - seriesType ? ecModel.eachSeriesByType(seriesType, encodeColor) - : ecModel.eachSeries(encodeColor); - }; -}); -define('echarts/preprocessor/helper/compatStyle',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - var POSSIBLE_STYLES = [ - 'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle', - 'chordStyle', 'label', 'labelLine' - ]; - - function compatItemStyle(opt) { - var itemStyleOpt = opt && opt.itemStyle; - if (itemStyleOpt) { - zrUtil.each(POSSIBLE_STYLES, function (styleName) { - var normalItemStyleOpt = itemStyleOpt.normal; - var emphasisItemStyleOpt = itemStyleOpt.emphasis; - if (normalItemStyleOpt && normalItemStyleOpt[styleName]) { - opt[styleName] = opt[styleName] || {}; - if (!opt[styleName].normal) { - opt[styleName].normal = normalItemStyleOpt[styleName]; - } - else { - zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]); - } - normalItemStyleOpt[styleName] = null; - } - if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) { - opt[styleName] = opt[styleName] || {}; - if (!opt[styleName].emphasis) { - opt[styleName].emphasis = emphasisItemStyleOpt[styleName]; - } - else { - zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]); - } - emphasisItemStyleOpt[styleName] = null; - } - }); - } - } - - return function (seriesOpt) { - compatItemStyle(seriesOpt); - var data = seriesOpt.data; - if (data) { - for (var i = 0; i < data.length; i++) { - compatItemStyle(data[i]); - } - // mark point data - var markPoint = seriesOpt.markPoint; - if (markPoint && markPoint.data) { - var mpData = markPoint.data; - for (var i = 0; i < mpData.length; i++) { - compatItemStyle(mpData[i]); - } - } - // mark line data - var markLine = seriesOpt.markLine; - if (markLine && markLine.data) { - var mlData = markLine.data; - for (var i = 0; i < mlData.length; i++) { - if (zrUtil.isArray(mlData[i])) { - compatItemStyle(mlData[i][0]); - compatItemStyle(mlData[i][1]); - } - else { - compatItemStyle(mlData[i]); - } - } - } - } - }; -}); -// Compatitable with 2.0 -define('echarts/preprocessor/backwardCompat',['require','zrender/core/util','./helper/compatStyle'],function (require) { - - var zrUtil = require('zrender/core/util'); - var compatStyle = require('./helper/compatStyle'); - - function get(opt, path) { - path = path.split(','); - var obj = opt; - for (var i = 0; i < path.length; i++) { - obj = obj && obj[path[i]]; - if (obj == null) { - break; - } - } - return obj; - } - - function set(opt, path, val, overwrite) { - path = path.split(','); - var obj = opt; - var key; - for (var i = 0; i < path.length - 1; i++) { - key = path[i]; - if (obj[key] == null) { - obj[key] = {}; - } - obj = obj[key]; - } - if (overwrite || obj[path[i]] == null) { - obj[path[i]] = val; - } - } - - function compatLayoutProperties(option) { - each(LAYOUT_PROPERTIES, function (prop) { - if (prop[0] in option && !(prop[1] in option)) { - option[prop[1]] = option[prop[0]]; - } - }); - } - - var LAYOUT_PROPERTIES = [ - ['x', 'left'], ['y', 'top'], ['x2', 'right'], ['y2', 'bottom'] - ]; - - var COMPATITABLE_COMPONENTS = [ - 'grid', 'geo', 'parallel', 'legend', 'toolbox', 'title', 'visualMap', 'dataZoom', 'timeline' - ]; - - var COMPATITABLE_SERIES = [ - 'bar', 'boxplot', 'candlestick', 'chord', 'effectScatter', - 'funnel', 'gauge', 'lines', 'graph', 'heatmap', 'line', 'map', 'parallel', - 'pie', 'radar', 'sankey', 'scatter', 'treemap' - ]; - - var each = zrUtil.each; - - return function (option) { - each(option.series, function (seriesOpt) { - if (!zrUtil.isObject(seriesOpt)) { - return; - } - - var seriesType = seriesOpt.type; - - compatStyle(seriesOpt); - - if (seriesType === 'pie' || seriesType === 'gauge') { - if (seriesOpt.clockWise != null) { - seriesOpt.clockwise = seriesOpt.clockWise; - } - } - if (seriesType === 'gauge') { - var pointerColor = get(seriesOpt, 'pointer.color'); - pointerColor != null - && set(seriesOpt, 'itemStyle.normal.color', pointerColor); - } - - for (var i = 0; i < COMPATITABLE_SERIES.length; i++) { - if (COMPATITABLE_SERIES[i] === seriesOpt.type) { - compatLayoutProperties(seriesOpt); - break; - } - } - }); - - // dataRange has changed to visualMap - if (option.dataRange) { - option.visualMap = option.dataRange; - } - - each(COMPATITABLE_COMPONENTS, function (componentName) { - var options = option[componentName]; - if (options) { - if (!zrUtil.isArray(options)) { - options = [options]; - } - each(options, function (option) { - compatLayoutProperties(option); - }); - } - }); - }; -}); -/*! - * ECharts, a javascript interactive chart library. - * - * Copyright (c) 2015, Baidu Inc. - * All rights reserved. - * - * LICENSE - * https://github.com/ecomfe/echarts/blob/master/LICENSE.txt - */ - -/** - * @module echarts - */ -define('echarts/echarts',['require','./model/Global','./ExtensionAPI','./CoordinateSystem','./model/OptionManager','./model/Component','./model/Series','./view/Component','./view/Chart','./util/graphic','zrender','zrender/core/util','zrender/tool/color','zrender/core/env','zrender/mixin/Eventful','./loading/default','./visual/seriesColor','./preprocessor/backwardCompat','./util/graphic','./util/number','./util/format','zrender/core/matrix','zrender/core/vector'],function (require) { - - var GlobalModel = require('./model/Global'); - var ExtensionAPI = require('./ExtensionAPI'); - var CoordinateSystemManager = require('./CoordinateSystem'); - var OptionManager = require('./model/OptionManager'); - - var ComponentModel = require('./model/Component'); - var SeriesModel = require('./model/Series'); - - var ComponentView = require('./view/Component'); - var ChartView = require('./view/Chart'); - var graphic = require('./util/graphic'); - - var zrender = require('zrender'); - var zrUtil = require('zrender/core/util'); - var colorTool = require('zrender/tool/color'); - var env = require('zrender/core/env'); - var Eventful = require('zrender/mixin/Eventful'); - - var each = zrUtil.each; - - var VISUAL_CODING_STAGES = ['echarts', 'chart', 'component']; - - // TODO Transform first or filter first - var PROCESSOR_STAGES = ['transform', 'filter', 'statistic']; - - function createRegisterEventWithLowercaseName(method) { - return function (eventName, handler, context) { - // Event name is all lowercase - eventName = eventName && eventName.toLowerCase(); - Eventful.prototype[method].call(this, eventName, handler, context); - }; - } - /** - * @module echarts~MessageCenter - */ - function MessageCenter() { - Eventful.call(this); - } - MessageCenter.prototype.on = createRegisterEventWithLowercaseName('on'); - MessageCenter.prototype.off = createRegisterEventWithLowercaseName('off'); - MessageCenter.prototype.one = createRegisterEventWithLowercaseName('one'); - zrUtil.mixin(MessageCenter, Eventful); - /** - * @module echarts~ECharts - */ - function ECharts (dom, theme, opts) { - opts = opts || {}; - - // Get theme by name - if (typeof theme === 'string') { - theme = themeStorage[theme]; - } - - if (theme) { - each(optionPreprocessorFuncs, function (preProcess) { - preProcess(theme); - }); - } - /** - * @type {string} - */ - this.id; - /** - * Group id - * @type {string} - */ - this.group; - /** - * @type {HTMLDomElement} - * @private - */ - this._dom = dom; - /** - * @type {module:zrender/ZRender} - * @private - */ - this._zr = zrender.init(dom, { - renderer: opts.renderer || 'canvas', - devicePixelRatio: opts.devicePixelRatio - }); - - /** - * @type {Object} - * @private - */ - this._theme = zrUtil.clone(theme); - - /** - * @type {Array.} - * @private - */ - this._chartsViews = []; - - /** - * @type {Object.} - * @private - */ - this._chartsMap = {}; - - /** - * @type {Array.} - * @private - */ - this._componentsViews = []; - - /** - * @type {Object.} - * @private - */ - this._componentsMap = {}; - - /** - * @type {module:echarts/ExtensionAPI} - * @private - */ - this._api = new ExtensionAPI(this); - - /** - * @type {module:echarts/CoordinateSystem} - * @private - */ - this._coordSysMgr = new CoordinateSystemManager(); - - Eventful.call(this); - - /** - * @type {module:echarts~MessageCenter} - * @private - */ - this._messageCenter = new MessageCenter(); - - // Init mouse events - this._initEvents(); - - // In case some people write `window.onresize = chart.resize` - this.resize = zrUtil.bind(this.resize, this); - } - - var echartsProto = ECharts.prototype; - - /** - * @return {HTMLDomElement} - */ - echartsProto.getDom = function () { - return this._dom; - }; - - /** - * @return {module:zrender~ZRender} - */ - echartsProto.getZr = function () { - return this._zr; - }; - - /** - * @param {Object} option - * @param {boolean} notMerge - * @param {boolean} [notRefreshImmediately=false] Useful when setOption frequently. - */ - echartsProto.setOption = function (option, notMerge, notRefreshImmediately) { - if (!this._model || notMerge) { - this._model = new GlobalModel( - null, null, this._theme, new OptionManager(this._api) - ); - } - - this._model.setOption(option, optionPreprocessorFuncs); - - updateMethods.prepareAndUpdate.call(this); - - !notRefreshImmediately && this._zr.refreshImmediately(); - }; - - /** - * @DEPRECATED - */ - echartsProto.setTheme = function () { - console.log('ECharts#setTheme() is DEPRECATED in ECharts 3.0'); - }; - - /** - * @return {module:echarts/model/Global} - */ - echartsProto.getModel = function () { - return this._model; - }; - - /** - * @return {Object} - */ - echartsProto.getOption = function () { - return this._model.getOption(); - }; - - /** - * @return {number} - */ - echartsProto.getWidth = function () { - return this._zr.getWidth(); - }; - - /** - * @return {number} - */ - echartsProto.getHeight = function () { - return this._zr.getHeight(); - }; - - /** - * Get canvas which has all thing rendered - * @param {Object} opts - * @param {string} [opts.backgroundColor] - */ - echartsProto.getRenderedCanvas = function (opts) { - if (!env.canvasSupported) { - return; - } - opts = opts || {}; - opts.pixelRatio = opts.pixelRatio || 1; - opts.backgroundColor = opts.backgroundColor - || this._model.get('backgroundColor'); - var zr = this._zr; - var list = zr.storage.getDisplayList(); - // Stop animations - zrUtil.each(list, function (el) { - el.stopAnimation(true); - }); - return zr.painter.getRenderedCanvas(opts); - }; - /** - * @return {string} - * @param {Object} opts - * @param {string} [opts.type='png'] - * @param {string} [opts.pixelRatio=1] - * @param {string} [opts.backgroundColor] - */ - echartsProto.getDataURL = function (opts) { - opts = opts || {}; - var excludeComponents = opts.excludeComponents; - var ecModel = this._model; - var excludesComponentViews = []; - var self = this; - - each(excludeComponents, function (componentType) { - ecModel.eachComponent({ - mainType: componentType - }, function (component) { - var view = self._componentsMap[component.__viewId]; - if (!view.group.ignore) { - excludesComponentViews.push(view); - view.group.ignore = true; - } - }); - }); - - var url = this.getRenderedCanvas(opts).toDataURL( - 'image/' + (opts && opts.type || 'png') - ); - - each(excludesComponentViews, function (view) { - view.group.ignore = false; - }); - return url; - }; - - - /** - * @return {string} - * @param {Object} opts - * @param {string} [opts.type='png'] - * @param {string} [opts.pixelRatio=1] - * @param {string} [opts.backgroundColor] - */ - echartsProto.getConnectedDataURL = function (opts) { - if (!env.canvasSupported) { - return; - } - var groupId = this.group; - var mathMin = Math.min; - var mathMax = Math.max; - var MAX_NUMBER = Infinity; - if (connectedGroups[groupId]) { - var left = MAX_NUMBER; - var top = MAX_NUMBER; - var right = -MAX_NUMBER; - var bottom = -MAX_NUMBER; - var canvasList = []; - var dpr = (opts && opts.pixelRatio) || 1; - for (var id in instances) { - var chart = instances[id]; - if (chart.group === groupId) { - var canvas = chart.getRenderedCanvas( - zrUtil.clone(opts) - ); - var boundingRect = chart.getDom().getBoundingClientRect(); - left = mathMin(boundingRect.left, left); - top = mathMin(boundingRect.top, top); - right = mathMax(boundingRect.right, right); - bottom = mathMax(boundingRect.bottom, bottom); - canvasList.push({ - dom: canvas, - left: boundingRect.left, - top: boundingRect.top - }); - } - } - - left *= dpr; - top *= dpr; - right *= dpr; - bottom *= dpr; - var width = right - left; - var height = bottom - top; - var targetCanvas = zrUtil.createCanvas(); - targetCanvas.width = width; - targetCanvas.height = height; - var zr = zrender.init(targetCanvas); - - each(canvasList, function (item) { - var img = new graphic.Image({ - style: { - x: item.left * dpr - left, - y: item.top * dpr - top, - image: item.dom - } - }); - zr.add(img); - }); - zr.refreshImmediately(); - - return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png')); - } - else { - return this.getDataURL(opts); - } - }; - - var updateMethods = { - - /** - * @param {Object} payload - * @private - */ - update: function (payload) { - // console.time && console.time('update'); - - var ecModel = this._model; - var api = this._api; - var coordSysMgr = this._coordSysMgr; - // update before setOption - if (!ecModel) { - return; - } - - ecModel.restoreData(); - - // TODO - // Save total ecModel here for undo/redo (after restoring data and before processing data). - // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call. - - // Create new coordinate system each update - // In LineView may save the old coordinate system and use it to get the orignal point - coordSysMgr.create(this._model, this._api); - - processData.call(this, ecModel, api); - - stackSeriesData.call(this, ecModel); - - coordSysMgr.update(ecModel, api); - - doLayout.call(this, ecModel, payload); - - doVisualCoding.call(this, ecModel, payload); - - doRender.call(this, ecModel, payload); - - // Set background - var backgroundColor = ecModel.get('backgroundColor') || 'transparent'; - - var painter = this._zr.painter; - // TODO all use clearColor ? - if (painter.isSingleCanvas && painter.isSingleCanvas()) { - this._zr.configLayer(0, { - clearColor: backgroundColor - }); - } - else { - // In IE8 - if (!env.canvasSupported) { - var colorArr = colorTool.parse(backgroundColor); - backgroundColor = colorTool.stringify(colorArr, 'rgb'); - if (colorArr[3] === 0) { - backgroundColor = 'transparent'; - } - } - backgroundColor = backgroundColor; - this._dom.style.backgroundColor = backgroundColor; - } - - // console.time && console.timeEnd('update'); - }, - - // PENDING - /** - * @param {Object} payload - * @private - */ - updateView: function (payload) { - var ecModel = this._model; - - // update before setOption - if (!ecModel) { - return; - } - - doLayout.call(this, ecModel, payload); - - doVisualCoding.call(this, ecModel, payload); - - invokeUpdateMethod.call(this, 'updateView', ecModel, payload); - }, - - /** - * @param {Object} payload - * @private - */ - updateVisual: function (payload) { - var ecModel = this._model; - - // update before setOption - if (!ecModel) { - return; - } - - doVisualCoding.call(this, ecModel, payload); - - invokeUpdateMethod.call(this, 'updateVisual', ecModel, payload); - }, - - /** - * @param {Object} payload - * @private - */ - updateLayout: function (payload) { - var ecModel = this._model; - - // update before setOption - if (!ecModel) { - return; - } - - doLayout.call(this, ecModel, payload); - - invokeUpdateMethod.call(this, 'updateLayout', ecModel, payload); - }, - - /** - * @param {Object} payload - * @private - */ - highlight: function (payload) { - toggleHighlight.call(this, 'highlight', payload); - }, - - /** - * @param {Object} payload - * @private - */ - downplay: function (payload) { - toggleHighlight.call(this, 'downplay', payload); - }, - - /** - * @param {Object} payload - * @private - */ - prepareAndUpdate: function (payload) { - var ecModel = this._model; - - prepareView.call(this, 'component', ecModel); - - prepareView.call(this, 'chart', ecModel); - - updateMethods.update.call(this, payload); - } - }; - - /** - * @param {Object} payload - * @private - */ - function toggleHighlight(method, payload) { - var ecModel = this._model; - - // dispatchAction before setOption - if (!ecModel) { - return; - } - - ecModel.eachComponent( - {mainType: 'series', query: payload}, - function (seriesModel, index) { - var chartView = this._chartsMap[seriesModel.__viewId]; - if (chartView && chartView.__alive) { - chartView[method]( - seriesModel, ecModel, this._api, payload - ); - } - }, - this - ); - } - - /** - * Resize the chart - */ - echartsProto.resize = function () { - this._zr.resize(); - - var optionChanged = this._model && this._model.resetOption('media'); - updateMethods[optionChanged ? 'prepareAndUpdate' : 'update'].call(this); - - // Resize loading effect - this._loadingFX && this._loadingFX.resize(); - }; - - var defaultLoadingEffect = require('./loading/default'); - /** - * Show loading effect - * @param {string} [name='default'] - * @param {Object} [cfg] - */ - echartsProto.showLoading = function (name, cfg) { - if (zrUtil.isObject(name)) { - cfg = name; - name = 'default'; - } - var el = defaultLoadingEffect(this._api, cfg); - var zr = this._zr; - this._loadingFX = el; - - zr.add(el); - }; - - /** - * Hide loading effect - */ - echartsProto.hideLoading = function () { - this._loadingFX && this._zr.remove(this._loadingFX); - this._loadingFX = null; - }; - - /** - * @param {Object} eventObj - * @return {Object} - */ - echartsProto.makeActionFromEvent = function (eventObj) { - var payload = zrUtil.extend({}, eventObj); - payload.type = eventActionMap[eventObj.type]; - return payload; - }; - - /** - * @pubilc - * @param {Object} payload - * @param {string} [payload.type] Action type - * @param {boolean} [silent=false] Whether trigger event. - */ - echartsProto.dispatchAction = function (payload, silent) { - var actionWrap = actions[payload.type]; - if (actionWrap) { - var actionInfo = actionWrap.actionInfo; - var updateMethod = actionInfo.update || 'update'; - - var payloads = [payload]; - var batched = false; - // Batch action - if (payload.batch) { - batched = true; - payloads = zrUtil.map(payload.batch, function (item) { - item = zrUtil.defaults(zrUtil.extend({}, item), payload); - item.batch = null; - return item; - }); - } - - var eventObjBatch = []; - var eventObj; - var isHighlightOrDownplay = payload.type === 'highlight' || payload.type === 'downplay'; - for (var i = 0; i < payloads.length; i++) { - var batchItem = payloads[i]; - // Action can specify the event by return it. - eventObj = actionWrap.action(batchItem, this._model); - // Emit event outside - eventObj = eventObj || zrUtil.extend({}, batchItem); - // Convert type to eventType - eventObj.type = actionInfo.event || eventObj.type; - eventObjBatch.push(eventObj); - - // Highlight and downplay are special. - isHighlightOrDownplay && updateMethods[updateMethod].call(this, batchItem); - } - - (updateMethod !== 'none' && !isHighlightOrDownplay) - && updateMethods[updateMethod].call(this, payload); - if (!silent) { - // Follow the rule of action batch - if (batched) { - eventObj = { - type: eventObjBatch[0].type, - batch: eventObjBatch - }; - } - else { - eventObj = eventObjBatch[0]; - } - this._messageCenter.trigger(eventObj.type, eventObj); - } - } - }; - - /** - * Register event - * @method - */ - echartsProto.on = createRegisterEventWithLowercaseName('on'); - echartsProto.off = createRegisterEventWithLowercaseName('off'); - echartsProto.one = createRegisterEventWithLowercaseName('one'); - - /** - * @param {string} methodName - * @private - */ - function invokeUpdateMethod(methodName, ecModel, payload) { - var api = this._api; - - // Update all components - each(this._componentsViews, function (component) { - var componentModel = component.__model; - component[methodName](componentModel, ecModel, api, payload); - - updateZ(componentModel, component); - }, this); - - // Upate all charts - ecModel.eachSeries(function (seriesModel, idx) { - var chart = this._chartsMap[seriesModel.__viewId]; - chart[methodName](seriesModel, ecModel, api, payload); - - updateZ(seriesModel, chart); - }, this); - - } - - /** - * Prepare view instances of charts and components - * @param {module:echarts/model/Global} ecModel - * @private - */ - function prepareView(type, ecModel) { - var isComponent = type === 'component'; - var viewList = isComponent ? this._componentsViews : this._chartsViews; - var viewMap = isComponent ? this._componentsMap : this._chartsMap; - var zr = this._zr; - - for (var i = 0; i < viewList.length; i++) { - viewList[i].__alive = false; - } - - ecModel[isComponent ? 'eachComponent' : 'eachSeries'](function (componentType, model) { - if (isComponent) { - if (componentType === 'series') { - return; - } - } - else { - model = componentType; - } - - // Consider: id same and type changed. - var viewId = model.id + '_' + model.type; - var view = viewMap[viewId]; - if (!view) { - var classType = ComponentModel.parseClassType(model.type); - var Clazz = isComponent - ? ComponentView.getClass(classType.main, classType.sub) - : ChartView.getClass(classType.sub); - if (Clazz) { - view = new Clazz(); - view.init(ecModel, this._api); - viewMap[viewId] = view; - viewList.push(view); - zr.add(view.group); - } - else { - // Error - return; - } - } - - model.__viewId = viewId; - view.__alive = true; - view.__id = viewId; - view.__model = model; - }, this); - - for (var i = 0; i < viewList.length;) { - var view = viewList[i]; - if (!view.__alive) { - zr.remove(view.group); - view.dispose(ecModel, this._api); - viewList.splice(i, 1); - delete viewMap[view.__id]; - } - else { - i++; - } - } - } - - /** - * Processor data in each series - * - * @param {module:echarts/model/Global} ecModel - * @private - */ - function processData(ecModel, api) { - each(PROCESSOR_STAGES, function (stage) { - each(dataProcessorFuncs[stage] || [], function (process) { - process(ecModel, api); - }); - }); - } - - /** - * @private - */ - function stackSeriesData(ecModel) { - var stackedDataMap = {}; - ecModel.eachSeries(function (series) { - var stack = series.get('stack'); - var data = series.getData(); - if (stack && data.type === 'list') { - var previousStack = stackedDataMap[stack]; - if (previousStack) { - data.stackedOn = previousStack; - } - stackedDataMap[stack] = data; - } - }); - } - - /** - * Layout before each chart render there series, after visual coding and data processing - * - * @param {module:echarts/model/Global} ecModel - * @private - */ - function doLayout(ecModel, payload) { - var api = this._api; - each(layoutFuncs, function (layout) { - layout(ecModel, api, payload); - }); - } - - /** - * Code visual infomation from data after data processing - * - * @param {module:echarts/model/Global} ecModel - * @private - */ - function doVisualCoding(ecModel, payload) { - each(VISUAL_CODING_STAGES, function (stage) { - each(visualCodingFuncs[stage] || [], function (visualCoding) { - visualCoding(ecModel, payload); - }); - }); - } - - /** - * Render each chart and component - * @private - */ - function doRender(ecModel, payload) { - var api = this._api; - // Render all components - each(this._componentsViews, function (componentView) { - var componentModel = componentView.__model; - componentView.render(componentModel, ecModel, api, payload); - - updateZ(componentModel, componentView); - }, this); - - each(this._chartsViews, function (chart) { - chart.__alive = false; - }, this); - - // Render all charts - ecModel.eachSeries(function (seriesModel, idx) { - var chartView = this._chartsMap[seriesModel.__viewId]; - chartView.__alive = true; - chartView.render(seriesModel, ecModel, api, payload); - - updateZ(seriesModel, chartView); - }, this); - - // Remove groups of unrendered charts - each(this._chartsViews, function (chart) { - if (!chart.__alive) { - chart.remove(ecModel, api); - } - }, this); - } - - var MOUSE_EVENT_NAMES = [ - 'click', 'dblclick', 'mouseover', 'mouseout', 'globalout' - ]; - /** - * @private - */ - echartsProto._initEvents = function () { - var zr = this._zr; - each(MOUSE_EVENT_NAMES, function (eveName) { - zr.on(eveName, function (e) { - var ecModel = this.getModel(); - var el = e.target; - if (el && el.dataIndex != null) { - var hostModel = el.hostModel || ecModel.getSeriesByIndex(el.seriesIndex); - var params = hostModel && hostModel.getDataParams(el.dataIndex) || {}; - params.event = e; - params.type = eveName; - this.trigger(eveName, params); - } - }, this); - }, this); - - each(eventActionMap, function (actionType, eventType) { - this._messageCenter.on(eventType, function (event) { - this.trigger(eventType, event); - }, this); - }, this); - }; - - /** - * @return {boolean} - */ - echartsProto.isDisposed = function () { - return this._disposed; - }; - - /** - * Clear - */ - echartsProto.clear = function () { - this.setOption({}, true); - }; - /** - * Dispose instance - */ - echartsProto.dispose = function () { - this._disposed = true; - var api = this._api; - var ecModel = this._model; - - each(this._componentsViews, function (component) { - component.dispose(ecModel, api); - }); - each(this._chartsViews, function (chart) { - chart.dispose(ecModel, api); - }); - - this._zr.dispose(); - - instances[this.id] = null; - }; - - zrUtil.mixin(ECharts, Eventful); - - /** - * @param {module:echarts/model/Series|module:echarts/model/Component} model - * @param {module:echarts/view/Component|module:echarts/view/Chart} view - * @return {string} - */ - function updateZ(model, view) { - var z = model.get('z'); - var zlevel = model.get('zlevel'); - // Set z and zlevel - view.group.traverse(function (el) { - z != null && (el.z = z); - zlevel != null && (el.zlevel = zlevel); - }); - } - /** - * @type {Array.} - * @inner - */ - var actions = []; - - /** - * Map eventType to actionType - * @type {Object} - */ - var eventActionMap = {}; - - /** - * @type {Array.} - * @inner - */ - var layoutFuncs = []; - - /** - * Data processor functions of each stage - * @type {Array.>} - * @inner - */ - var dataProcessorFuncs = {}; - - /** - * @type {Array.} - * @inner - */ - var optionPreprocessorFuncs = []; - - /** - * Visual coding functions of each stage - * @type {Array.>} - * @inner - */ - var visualCodingFuncs = {}; - /** - * Theme storage - * @type {Object.} - */ - var themeStorage = {}; - - - var instances = {}; - var connectedGroups = {}; - - var idBase = new Date() - 0; - var groupIdBase = new Date() - 0; - var DOM_ATTRIBUTE_KEY = '_echarts_instance_'; - /** - * @alias module:echarts - */ - var echarts = { - /** - * @type {number} - */ - version: '3.1.2', - dependencies: { - zrender: '3.0.3' - } - }; - - function enableConnect(chart) { - - var STATUS_PENDING = 0; - var STATUS_UPDATING = 1; - var STATUS_UPDATED = 2; - var STATUS_KEY = '__connectUpdateStatus'; - function updateConnectedChartsStatus(charts, status) { - for (var i = 0; i < charts.length; i++) { - var otherChart = charts[i]; - otherChart[STATUS_KEY] = status; - } - } - zrUtil.each(eventActionMap, function (actionType, eventType) { - chart._messageCenter.on(eventType, function (event) { - if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) { - var action = chart.makeActionFromEvent(event); - var otherCharts = []; - for (var id in instances) { - var otherChart = instances[id]; - if (otherChart !== chart && otherChart.group === chart.group) { - otherCharts.push(otherChart); - } - } - updateConnectedChartsStatus(otherCharts, STATUS_PENDING); - each(otherCharts, function (otherChart) { - if (otherChart[STATUS_KEY] !== STATUS_UPDATING) { - otherChart.dispatchAction(action); - } - }); - updateConnectedChartsStatus(otherCharts, STATUS_UPDATED); - } - }); - }); - - } - /** - * @param {HTMLDomElement} dom - * @param {Object} [theme] - * @param {Object} opts - */ - echarts.init = function (dom, theme, opts) { - // Check version - if ((zrender.version.replace('.', '') - 0) < (echarts.dependencies.zrender.replace('.', '') - 0)) { - throw new Error( - 'ZRender ' + zrender.version - + ' is too old for ECharts ' + echarts.version - + '. Current version need ZRender ' - + echarts.dependencies.zrender + '+' - ); - } - if (!dom) { - throw new Error('Initialize failed: invalid dom.'); - } - - var chart = new ECharts(dom, theme, opts); - chart.id = 'ec_' + idBase++; - instances[chart.id] = chart; - - dom.setAttribute && - dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id); - - enableConnect(chart); - - return chart; - }; - - /** - * @return {string|Array.} groupId - */ - echarts.connect = function (groupId) { - // Is array of charts - if (zrUtil.isArray(groupId)) { - var charts = groupId; - groupId = null; - // If any chart has group - zrUtil.each(charts, function (chart) { - if (chart.group != null) { - groupId = chart.group; - } - }); - groupId = groupId || ('g_' + groupIdBase++); - zrUtil.each(charts, function (chart) { - chart.group = groupId; - }); - } - connectedGroups[groupId] = true; - return groupId; - }; - - /** - * @return {string} groupId - */ - echarts.disConnect = function (groupId) { - connectedGroups[groupId] = false; - }; - - /** - * Dispose a chart instance - * @param {module:echarts~ECharts|HTMLDomElement|string} chart - */ - echarts.dispose = function (chart) { - if (zrUtil.isDom(chart)) { - chart = echarts.getInstanceByDom(chart); - } - else if (typeof chart === 'string') { - chart = instances[chart]; - } - if ((chart instanceof ECharts) && !chart.isDisposed()) { - chart.dispose(); - } - }; - - /** - * @param {HTMLDomElement} dom - * @return {echarts~ECharts} - */ - echarts.getInstanceByDom = function (dom) { - var key = dom.getAttribute(DOM_ATTRIBUTE_KEY); - return instances[key]; - }; - /** - * @param {string} key - * @return {echarts~ECharts} - */ - echarts.getInstanceById = function (key) { - return instances[key]; - }; - - /** - * Register theme - */ - echarts.registerTheme = function (name, theme) { - themeStorage[name] = theme; - }; - - /** - * Register option preprocessor - * @param {Function} preprocessorFunc - */ - echarts.registerPreprocessor = function (preprocessorFunc) { - optionPreprocessorFuncs.push(preprocessorFunc); - }; - - /** - * @param {string} stage - * @param {Function} processorFunc - */ - echarts.registerProcessor = function (stage, processorFunc) { - if (zrUtil.indexOf(PROCESSOR_STAGES, stage) < 0) { - throw new Error('stage should be one of ' + PROCESSOR_STAGES); - } - var funcs = dataProcessorFuncs[stage] || (dataProcessorFuncs[stage] = []); - funcs.push(processorFunc); - }; - - /** - * Usage: - * registerAction('someAction', 'someEvent', function () { ... }); - * registerAction('someAction', function () { ... }); - * registerAction( - * {type: 'someAction', event: 'someEvent', update: 'updateView'}, - * function () { ... } - * ); - * - * @param {(string|Object)} actionInfo - * @param {string} actionInfo.type - * @param {string} [actionInfo.event] - * @param {string} [actionInfo.update] - * @param {string} [eventName] - * @param {Function} action - */ - echarts.registerAction = function (actionInfo, eventName, action) { - if (typeof eventName === 'function') { - action = eventName; - eventName = ''; - } - var actionType = zrUtil.isObject(actionInfo) - ? actionInfo.type - : ([actionInfo, actionInfo = { - event: eventName - }][0]); - - // Event name is all lowercase - actionInfo.event = (actionInfo.event || actionType).toLowerCase(); - eventName = actionInfo.event; - - if (!actions[actionType]) { - actions[actionType] = {action: action, actionInfo: actionInfo}; - } - eventActionMap[eventName] = actionType; - }; - - /** - * @param {string} type - * @param {*} CoordinateSystem - */ - echarts.registerCoordinateSystem = function (type, CoordinateSystem) { - CoordinateSystemManager.register(type, CoordinateSystem); - }; - - /** - * @param {*} layout - */ - echarts.registerLayout = function (layout) { - // PENDING All functions ? - if (zrUtil.indexOf(layoutFuncs, layout) < 0) { - layoutFuncs.push(layout); - } - }; - - /** - * @param {string} stage - * @param {Function} visualCodingFunc - */ - echarts.registerVisualCoding = function (stage, visualCodingFunc) { - if (zrUtil.indexOf(VISUAL_CODING_STAGES, stage) < 0) { - throw new Error('stage should be one of ' + VISUAL_CODING_STAGES); - } - var funcs = visualCodingFuncs[stage] || (visualCodingFuncs[stage] = []); - funcs.push(visualCodingFunc); - }; - - /** - * @param {Object} opts - */ - echarts.extendChartView = function (opts) { - return ChartView.extend(opts); - }; - - /** - * @param {Object} opts - */ - echarts.extendComponentModel = function (opts) { - return ComponentModel.extend(opts); - }; - - /** - * @param {Object} opts - */ - echarts.extendSeriesModel = function (opts) { - return SeriesModel.extend(opts); - }; - - /** - * @param {Object} opts - */ - echarts.extendComponentView = function (opts) { - return ComponentView.extend(opts); - }; - - /** - * ZRender need a canvas context to do measureText. - * But in node environment canvas may be created by node-canvas. - * So we need to specify how to create a canvas instead of using document.createElement('canvas') - * - * Be careful of using it in the browser. - * - * @param {Function} creator - * @example - * var Canvas = require('canvas'); - * var echarts = require('echarts'); - * echarts.setCanvasCreator(function () { - * // Small size is enough. - * return new Canvas(32, 32); - * }); - */ - echarts.setCanvasCreator = function (creator) { - zrUtil.createCanvas = creator; - }; - - echarts.registerVisualCoding('echarts', zrUtil.curry( - require('./visual/seriesColor'), '', 'itemStyle' - )); - echarts.registerPreprocessor(require('./preprocessor/backwardCompat')); - - // Default action - echarts.registerAction({ - type: 'highlight', - event: 'highlight', - update: 'highlight' - }, zrUtil.noop); - echarts.registerAction({ - type: 'downplay', - event: 'downplay', - update: 'downplay' - }, zrUtil.noop); - - - // -------- - // Exports - // -------- - - echarts.graphic = require('./util/graphic'); - echarts.number = require('./util/number'); - echarts.format = require('./util/format'); - echarts.matrix = require('zrender/core/matrix'); - echarts.vector = require('zrender/core/vector'); - - echarts.util = {}; - each([ - 'map', 'each', 'filter', 'indexOf', 'inherits', - 'reduce', 'filter', 'bind', 'curry', 'isArray', - 'isString', 'isObject', 'isFunction', 'extend' - ], - function (name) { - echarts.util[name] = zrUtil[name]; - } - ); - - return echarts; -}); -define('echarts', ['echarts/echarts'], function (main) { return main; }); - -define('echarts/data/DataDiffer',['require'],function(require) { - - - function defaultKeyGetter(item) { - return item; - } - - function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter) { - this._old = oldArr; - this._new = newArr; - - this._oldKeyGetter = oldKeyGetter || defaultKeyGetter; - this._newKeyGetter = newKeyGetter || defaultKeyGetter; - } - - DataDiffer.prototype = { - - constructor: DataDiffer, - - /** - * Callback function when add a data - */ - add: function (func) { - this._add = func; - return this; - }, - - /** - * Callback function when update a data - */ - update: function (func) { - this._update = func; - return this; - }, - - /** - * Callback function when remove a data - */ - remove: function (func) { - this._remove = func; - return this; - }, - - execute: function () { - var oldArr = this._old; - var newArr = this._new; - var oldKeyGetter = this._oldKeyGetter; - var newKeyGetter = this._newKeyGetter; - - var oldDataIndexMap = {}; - var newDataIndexMap = {}; - var i; - - initIndexMap(oldArr, oldDataIndexMap, oldKeyGetter); - initIndexMap(newArr, newDataIndexMap, newKeyGetter); - - // Travel by inverted order to make sure order consistency - // when duplicate keys exists (consider newDataIndex.pop() below). - // For performance consideration, these code below do not look neat. - for (i = 0; i < oldArr.length; i++) { - var key = oldKeyGetter(oldArr[i]); - var idx = newDataIndexMap[key]; - - // idx can never be empty array here. see 'set null' logic below. - if (idx != null) { - // Consider there is duplicate key (for example, use dataItem.name as key). - // We should make sure every item in newArr and oldArr can be visited. - var len = idx.length; - if (len) { - len === 1 && (newDataIndexMap[key] = null); - idx = idx.unshift(); - } - else { - newDataIndexMap[key] = null; - } - this._update && this._update(idx, i); - } - else { - this._remove && this._remove(i); - } - } - - for (var key in newDataIndexMap) { - if (newDataIndexMap.hasOwnProperty(key)) { - var idx = newDataIndexMap[key]; - if (idx == null) { - continue; - } - // idx can never be empty array here. see 'set null' logic above. - if (!idx.length) { - this._add && this._add(idx); - } - else { - for (var i = 0, len = idx.length; i < len; i++) { - this._add && this._add(idx[i]); - } - } - } - } - } - }; - - function initIndexMap(arr, map, keyGetter) { - for (var i = 0; i < arr.length; i++) { - var key = keyGetter(arr[i]); - var existence = map[key]; - if (existence == null) { - map[key] = i; - } - else { - if (!existence.length) { - map[key] = existence = [existence]; - } - existence.push(i); - } - } - } - - return DataDiffer; -}); -/** - * List for data storage - * @module echarts/data/List - */ -define('echarts/data/List',['require','../model/Model','./DataDiffer','zrender/core/util','../util/model'],function (require) { - - var UNDEFINED = 'undefined'; - var globalObj = typeof window === 'undefined' ? global : window; - var Float64Array = typeof globalObj.Float64Array === UNDEFINED - ? Array : globalObj.Float64Array; - var Int32Array = typeof globalObj.Int32Array === UNDEFINED - ? Array : globalObj.Int32Array; - - var dataCtors = { - 'float': Float64Array, - 'int': Int32Array, - // Ordinal data type can be string or int - 'ordinal': Array, - 'number': Array, - 'time': Array - }; - - var Model = require('../model/Model'); - var DataDiffer = require('./DataDiffer'); - - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../util/model'); - var isObject = zrUtil.isObject; - - var IMMUTABLE_PROPERTIES = [ - 'stackedOn', '_nameList', '_idList', '_rawData' - ]; - - var transferImmuProperties = function (a, b, wrappedMethod) { - zrUtil.each(IMMUTABLE_PROPERTIES.concat(wrappedMethod || []), function (propName) { - if (b.hasOwnProperty(propName)) { - a[propName] = b[propName]; - } - }); - }; - - /** - * @constructor - * @alias module:echarts/data/List - * - * @param {Array.} dimensions - * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius - * @param {module:echarts/model/Model} hostModel - */ - var List = function (dimensions, hostModel) { - - dimensions = dimensions || ['x', 'y']; - - var dimensionInfos = {}; - var dimensionNames = []; - for (var i = 0; i < dimensions.length; i++) { - var dimensionName; - var dimensionInfo = {}; - if (typeof dimensions[i] === 'string') { - dimensionName = dimensions[i]; - dimensionInfo = { - name: dimensionName, - stackable: false, - // Type can be 'float', 'int', 'number' - // Default is number, Precision of float may not enough - type: 'number' - }; - } - else { - dimensionInfo = dimensions[i]; - dimensionName = dimensionInfo.name; - dimensionInfo.type = dimensionInfo.type || 'number'; - } - dimensionNames.push(dimensionName); - dimensionInfos[dimensionName] = dimensionInfo; - } - /** - * @readOnly - * @type {Array.} - */ - this.dimensions = dimensionNames; - - /** - * Infomation of each data dimension, like data type. - * @type {Object} - */ - this._dimensionInfos = dimensionInfos; - - /** - * @type {module:echarts/model/Model} - */ - this.hostModel = hostModel; - - /** - * Indices stores the indices of data subset after filtered. - * This data subset will be used in chart. - * @type {Array.} - * @readOnly - */ - this.indices = []; - - /** - * Data storage - * @type {Object.} - * @private - */ - this._storage = {}; - - /** - * @type {Array.} - */ - this._nameList = []; - /** - * @type {Array.} - */ - this._idList = []; - /** - * Models of data option is stored sparse for optimizing memory cost - * @type {Array.} - * @private - */ - this._optionModels = []; - - /** - * @param {module:echarts/data/List} - */ - this.stackedOn = null; - - /** - * Global visual properties after visual coding - * @type {Object} - * @private - */ - this._visual = {}; - - /** - * Globel layout properties. - * @type {Object} - * @private - */ - this._layout = {}; - - /** - * Item visual properties after visual coding - * @type {Array.} - * @private - */ - this._itemVisuals = []; - - /** - * Item layout properties after layout - * @type {Array.} - * @private - */ - this._itemLayouts = []; - - /** - * Graphic elemnents - * @type {Array.} - * @private - */ - this._graphicEls = []; - - /** - * @type {Array.} - * @private - */ - this._rawData; - - /** - * @type {Object} - * @private - */ - this._extent; - }; - - var listProto = List.prototype; - - listProto.type = 'list'; - - /** - * Get dimension name - * @param {string|number} dim - * Dimension can be concrete names like x, y, z, lng, lat, angle, radius - * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius' - */ - listProto.getDimension = function (dim) { - if (!isNaN(dim)) { - dim = this.dimensions[dim] || dim; - } - return dim; - }; - /** - * Get type and stackable info of particular dimension - * @param {string|number} dim - * Dimension can be concrete names like x, y, z, lng, lat, angle, radius - * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius' - */ - listProto.getDimensionInfo = function (dim) { - return zrUtil.clone(this._dimensionInfos[this.getDimension(dim)]); - }; - - /** - * Initialize from data - * @param {Array.} data - * @param {Array.} [nameList] - * @param {Function} [dimValueGetter] (dataItem, dimName, dataIndex, dimIndex) => number - */ - listProto.initData = function (data, nameList, dimValueGetter) { - data = data || []; - - this._rawData = data; - - // Clear - var storage = this._storage = {}; - var indices = this.indices = []; - - var dimensions = this.dimensions; - var size = data.length; - var dimensionInfoMap = this._dimensionInfos; - - var idList = []; - var nameRepeatCount = {}; - - nameList = nameList || []; - - // Init storage - for (var i = 0; i < dimensions.length; i++) { - var dimInfo = dimensionInfoMap[dimensions[i]]; - var DataCtor = dataCtors[dimInfo.type]; - storage[dimensions[i]] = new DataCtor(size); - } - - // Default dim value getter - dimValueGetter = dimValueGetter || function (dataItem, dimName, dataIndex, dimIndex) { - var value = modelUtil.getDataItemValue(dataItem); - return modelUtil.converDataValue( - zrUtil.isArray(value) - ? value[dimIndex] - // If value is a single number or something else not array. - : value, - dimensionInfoMap[dimName] - ); - }; - - for (var idx = 0; idx < data.length; idx++) { - var dataItem = data[idx]; - // Each data item is value - // [1, 2] - // 2 - // Bar chart, line chart which uses category axis - // only gives the 'y' value. 'x' value is the indices of cateogry - // Use a tempValue to normalize the value to be a (x, y) value - - // Store the data by dimensions - for (var k = 0; k < dimensions.length; k++) { - var dim = dimensions[k]; - var dimStorage = storage[dim]; - // PENDING NULL is empty or zero - dimStorage[idx] = dimValueGetter(dataItem, dim, idx, k); - } - - indices.push(idx); - } - - // Use the name in option and create id - for (var i = 0; i < data.length; i++) { - var id = ''; - if (!nameList[i]) { - nameList[i] = data[i].name; - // Try using the id in option - id = data[i].id; - } - var name = nameList[i] || ''; - if (!id && name) { - // Use name as id and add counter to avoid same name - nameRepeatCount[name] = nameRepeatCount[name] || 0; - id = name; - if (nameRepeatCount[name] > 0) { - id += '__ec__' + nameRepeatCount[name]; - } - nameRepeatCount[name]++; - } - id && (idList[i] = id); - } - - this._nameList = nameList; - this._idList = idList; - }; - - /** - * @return {number} - */ - listProto.count = function () { - return this.indices.length; - }; - - /** - * Get value - * @param {string} dim Dim must be concrete name. - * @param {number} idx - * @param {boolean} stack - * @return {number} - */ - listProto.get = function (dim, idx, stack) { - var storage = this._storage; - var dataIndex = this.indices[idx]; - - var value = storage[dim] && storage[dim][dataIndex]; - // FIXME ordinal data type is not stackable - if (stack) { - var dimensionInfo = this._dimensionInfos[dim]; - if (dimensionInfo && dimensionInfo.stackable) { - var stackedOn = this.stackedOn; - while (stackedOn) { - // Get no stacked data of stacked on - var stackedValue = stackedOn.get(dim, idx); - // Considering positive stack, negative stack and empty data - if ((value >= 0 && stackedValue > 0) // Positive stack - || (value <= 0 && stackedValue < 0) // Negative stack - ) { - value += stackedValue; - } - stackedOn = stackedOn.stackedOn; - } - } - } - return value; - }; - - /** - * Get value for multi dimensions. - * @param {Array.} [dimensions] If ignored, using all dimensions. - * @param {number} idx - * @param {boolean} stack - * @return {number} - */ - listProto.getValues = function (dimensions, idx, stack) { - var values = []; - - if (!zrUtil.isArray(dimensions)) { - stack = idx; - idx = dimensions; - dimensions = this.dimensions; - } - - for (var i = 0, len = dimensions.length; i < len; i++) { - values.push(this.get(dimensions[i], idx, stack)); - } - - return values; - }; - - /** - * If value is NaN. Inlcuding '-' - * @param {string} dim - * @param {number} idx - * @return {number} - */ - listProto.hasValue = function (idx) { - var dimensions = this.dimensions; - var dimensionInfos = this._dimensionInfos; - for (var i = 0, len = dimensions.length; i < len; i++) { - if ( - // Ordinal type can be string or number - dimensionInfos[dimensions[i]].type !== 'ordinal' - && isNaN(this.get(dimensions[i], idx)) - ) { - return false; - } - } - return true; - }; - - /** - * Get extent of data in one dimension - * @param {string} dim - * @param {boolean} stack - */ - listProto.getDataExtent = function (dim, stack) { - var dimData = this._storage[dim]; - var dimInfo = this.getDimensionInfo(dim); - stack = (dimInfo && dimInfo.stackable) && stack; - var dimExtent = (this._extent || (this._extent = {}))[dim + (!!stack)]; - var value; - if (dimExtent) { - return dimExtent; - } - // var dimInfo = this._dimensionInfos[dim]; - if (dimData) { - var min = Infinity; - var max = -Infinity; - // var isOrdinal = dimInfo.type === 'ordinal'; - for (var i = 0, len = this.count(); i < len; i++) { - value = this.get(dim, i, stack); - // FIXME - // if (isOrdinal && typeof value === 'string') { - // value = zrUtil.indexOf(dimData, value); - // console.log(value); - // } - value < min && (min = value); - value > max && (max = value); - } - return (this._extent[dim + stack] = [min, max]); - } - else { - return [Infinity, -Infinity]; - } - }; - - /** - * Get sum of data in one dimension - * @param {string} dim - * @param {boolean} stack - */ - listProto.getSum = function (dim, stack) { - var dimData = this._storage[dim]; - var sum = 0; - if (dimData) { - for (var i = 0, len = this.count(); i < len; i++) { - var value = this.get(dim, i, stack); - if (!isNaN(value)) { - sum += value; - } - } - } - return sum; - }; - - /** - * Retreive the index with given value - * @param {number} idx - * @param {number} value - * @return {number} - */ - // FIXME Precision of float value - listProto.indexOf = function (dim, value) { - var storage = this._storage; - var dimData = storage[dim]; - var indices = this.indices; - - if (dimData) { - for (var i = 0, len = indices.length; i < len; i++) { - var rawIndex = indices[i]; - if (dimData[rawIndex] === value) { - return i; - } - } - } - return -1; - }; - - /** - * Retreive the index with given name - * @param {number} idx - * @param {number} name - * @return {number} - */ - listProto.indexOfName = function (name) { - var indices = this.indices; - var nameList = this._nameList; - - for (var i = 0, len = indices.length; i < len; i++) { - var rawIndex = indices[i]; - if (nameList[rawIndex] === name) { - return i; - } - } - - return -1; - }; - - /** - * Retreive the index of nearest value - * @param {string>} dim - * @param {number} value - * @param {boolean} stack If given value is after stacked - * @return {number} - */ - listProto.indexOfNearest = function (dim, value, stack) { - var storage = this._storage; - var dimData = storage[dim]; - - if (dimData) { - var minDist = Number.MAX_VALUE; - var nearestIdx = -1; - for (var i = 0, len = this.count(); i < len; i++) { - var dist = Math.abs(this.get(dim, i, stack) - value); - if (dist <= minDist) { - minDist = dist; - nearestIdx = i; - } - } - return nearestIdx; - } - return -1; - }; - - /** - * Get raw data index - * @param {number} idx - * @return {number} - */ - listProto.getRawIndex = function (idx) { - var rawIdx = this.indices[idx]; - return rawIdx == null ? -1 : rawIdx; - }; - - /** - * @param {number} idx - * @param {boolean} [notDefaultIdx=false] - * @return {string} - */ - listProto.getName = function (idx) { - return this._nameList[this.indices[idx]] || ''; - }; - - /** - * @param {number} idx - * @param {boolean} [notDefaultIdx=false] - * @return {string} - */ - listProto.getId = function (idx) { - return this._idList[this.indices[idx]] || (this.getRawIndex(idx) + ''); - }; - - - function normalizeDimensions(dimensions) { - if (!zrUtil.isArray(dimensions)) { - dimensions = [dimensions]; - } - return dimensions; - } - - /** - * Data iteration - * @param {string|Array.} - * @param {Function} cb - * @param {boolean} [stack=false] - * @param {*} [context=this] - * - * @example - * list.each('x', function (x, idx) {}); - * list.each(['x', 'y'], function (x, y, idx) {}); - * list.each(function (idx) {}) - */ - listProto.each = function (dimensions, cb, stack, context) { - if (typeof dimensions === 'function') { - context = stack; - stack = cb; - cb = dimensions; - dimensions = []; - } - - dimensions = zrUtil.map( - normalizeDimensions(dimensions), this.getDimension, this - ); - - var value = []; - var dimSize = dimensions.length; - var indices = this.indices; - - context = context || this; - - for (var i = 0; i < indices.length; i++) { - if (dimSize === 0) { - cb.call(context, i); - } - // Simple optimization - else if (dimSize === 1) { - cb.call(context, this.get(dimensions[0], i, stack), i); - } - else { - for (var k = 0; k < dimSize; k++) { - value[k] = this.get(dimensions[k], i, stack); - } - // Index - value[k] = i; - cb.apply(context, value); - } - } - }; - - /** - * Data filter - * @param {string|Array.} - * @param {Function} cb - * @param {boolean} [stack=false] - * @param {*} [context=this] - */ - listProto.filterSelf = function (dimensions, cb, stack, context) { - if (typeof dimensions === 'function') { - context = stack; - stack = cb; - cb = dimensions; - dimensions = []; - } - - dimensions = zrUtil.map( - normalizeDimensions(dimensions), this.getDimension, this - ); - - var newIndices = []; - var value = []; - var dimSize = dimensions.length; - var indices = this.indices; - - context = context || this; - - for (var i = 0; i < indices.length; i++) { - var keep; - // Simple optimization - if (dimSize === 1) { - keep = cb.call( - context, this.get(dimensions[0], i, stack), i - ); - } - else { - for (var k = 0; k < dimSize; k++) { - value[k] = this.get(dimensions[k], i, stack); - } - value[k] = i; - keep = cb.apply(context, value); - } - if (keep) { - newIndices.push(indices[i]); - } - } - - this.indices = newIndices; - - // Reset data extent - this._extent = {}; - - return this; - }; - - /** - * Data mapping to a plain array - * @param {string|Array.} [dimensions] - * @param {Function} cb - * @param {boolean} [stack=false] - * @param {*} [context=this] - * @return {Array} - */ - listProto.mapArray = function (dimensions, cb, stack, context) { - if (typeof dimensions === 'function') { - context = stack; - stack = cb; - cb = dimensions; - dimensions = []; - } - - var result = []; - this.each(dimensions, function () { - result.push(cb && cb.apply(this, arguments)); - }, stack, context); - return result; - }; - - function cloneListForMapAndSample(original, excludeDimensions) { - var allDimensions = original.dimensions; - var list = new List( - zrUtil.map(allDimensions, original.getDimensionInfo, original), - original.hostModel - ); - // FIXME If needs stackedOn, value may already been stacked - transferImmuProperties(list, original, original._wrappedMethods); - - var storage = list._storage = {}; - var originalStorage = original._storage; - // Init storage - for (var i = 0; i < allDimensions.length; i++) { - var dim = allDimensions[i]; - var dimStore = originalStorage[dim]; - if (zrUtil.indexOf(excludeDimensions, dim) >= 0) { - storage[dim] = new dimStore.constructor( - originalStorage[dim].length - ); - } - else { - // Direct reference for other dimensions - storage[dim] = originalStorage[dim]; - } - } - return list; - } - - /** - * Data mapping to a new List with given dimensions - * @param {string|Array.} dimensions - * @param {Function} cb - * @param {boolean} [stack=false] - * @param {*} [context=this] - * @return {Array} - */ - listProto.map = function (dimensions, cb, stack, context) { - dimensions = zrUtil.map( - normalizeDimensions(dimensions), this.getDimension, this - ); - - var list = cloneListForMapAndSample(this, dimensions); - // Following properties are all immutable. - // So we can reference to the same value - var indices = list.indices = this.indices; - - var storage = list._storage; - - var tmpRetValue = []; - this.each(dimensions, function () { - var idx = arguments[arguments.length - 1]; - var retValue = cb && cb.apply(this, arguments); - if (retValue != null) { - // a number - if (typeof retValue === 'number') { - tmpRetValue[0] = retValue; - retValue = tmpRetValue; - } - for (var i = 0; i < retValue.length; i++) { - var dim = dimensions[i]; - var dimStore = storage[dim]; - var rawIdx = indices[idx]; - if (dimStore) { - dimStore[rawIdx] = retValue[i]; - } - } - } - }, stack, context); - - return list; - }; - - /** - * Large data down sampling on given dimension - * @param {string} dimension - * @param {number} rate - * @param {Function} sampleValue - * @param {Function} sampleIndex Sample index for name and id - */ - listProto.downSample = function (dimension, rate, sampleValue, sampleIndex) { - var list = cloneListForMapAndSample(this, [dimension]); - var storage = this._storage; - var targetStorage = list._storage; - - var originalIndices = this.indices; - var indices = list.indices = []; - - var frameValues = []; - var frameIndices = []; - var frameSize = Math.floor(1 / rate); - - var dimStore = targetStorage[dimension]; - var len = this.count(); - // Copy data from original data - for (var i = 0; i < storage[dimension].length; i++) { - targetStorage[dimension][i] = storage[dimension][i]; - } - for (var i = 0; i < len; i += frameSize) { - // Last frame - if (frameSize > len - i) { - frameSize = len - i; - frameValues.length = frameSize; - } - for (var k = 0; k < frameSize; k++) { - var idx = originalIndices[i + k]; - frameValues[k] = dimStore[idx]; - frameIndices[k] = idx; - } - var value = sampleValue(frameValues); - var idx = frameIndices[sampleIndex(frameValues, value) || 0]; - // Only write value on the filtered data - dimStore[idx] = value; - indices.push(idx); - } - return list; - }; - - /** - * Get model of one data item. - * - * @param {number} idx - */ - // FIXME Model proxy ? - listProto.getItemModel = function (idx) { - var hostModel = this.hostModel; - idx = this.indices[idx]; - return new Model(this._rawData[idx], hostModel, hostModel.ecModel); - }; - - /** - * Create a data differ - * @param {module:echarts/data/List} otherList - * @return {module:echarts/data/DataDiffer} - */ - listProto.diff = function (otherList) { - var idList = this._idList; - var otherIdList = otherList && otherList._idList; - return new DataDiffer( - otherList ? otherList.indices : [], this.indices, function (idx) { - return otherIdList[idx] || (idx + ''); - }, function (idx) { - return idList[idx] || (idx + ''); - } - ); - }; - /** - * Get visual property. - * @param {string} key - */ - listProto.getVisual = function (key) { - var visual = this._visual; - return visual && visual[key]; - }; - - /** - * Set visual property - * @param {string|Object} key - * @param {*} [value] - * - * @example - * setVisual('color', color); - * setVisual({ - * 'color': color - * }); - */ - listProto.setVisual = function (key, val) { - if (isObject(key)) { - for (var name in key) { - if (key.hasOwnProperty(name)) { - this.setVisual(name, key[name]); - } - } - return; - } - this._visual = this._visual || {}; - this._visual[key] = val; - }; - - /** - * Set layout property. - * @param {string} key - * @param {*} [val] - */ - listProto.setLayout = function (key, val) { - if (isObject(key)) { - for (var name in key) { - if (key.hasOwnProperty(name)) { - this.setLayout(name, key[name]); - } - } - return; - } - this._layout[key] = val; - }; - - /** - * Get layout property. - * @param {string} key. - * @return {*} - */ - listProto.getLayout = function (key) { - return this._layout[key]; - }; - - /** - * Get layout of single data item - * @param {number} idx - */ - listProto.getItemLayout = function (idx) { - return this._itemLayouts[idx]; - }, - - /** - * Set layout of single data item - * @param {number} idx - * @param {Object} layout - * @param {boolean=} [merge=false] - */ - listProto.setItemLayout = function (idx, layout, merge) { - this._itemLayouts[idx] = merge - ? zrUtil.extend(this._itemLayouts[idx] || {}, layout) - : layout; - }, - - /** - * Get visual property of single data item - * @param {number} idx - * @param {string} key - * @param {boolean} ignoreParent - */ - listProto.getItemVisual = function (idx, key, ignoreParent) { - var itemVisual = this._itemVisuals[idx]; - var val = itemVisual && itemVisual[key]; - if (val == null && !ignoreParent) { - // Use global visual property - return this.getVisual(key); - } - return val; - }, - - /** - * Set visual property of single data item - * - * @param {number} idx - * @param {string|Object} key - * @param {*} [value] - * - * @example - * setItemVisual(0, 'color', color); - * setItemVisual(0, { - * 'color': color - * }); - */ - listProto.setItemVisual = function (idx, key, value) { - var itemVisual = this._itemVisuals[idx] || {}; - this._itemVisuals[idx] = itemVisual; - - if (isObject(key)) { - for (var name in key) { - if (key.hasOwnProperty(name)) { - itemVisual[name] = key[name]; - } - } - return; - } - itemVisual[key] = value; - }; - - var setItemDataAndSeriesIndex = function (child) { - child.seriesIndex = this.seriesIndex; - child.dataIndex = this.dataIndex; - }; - /** - * Set graphic element relative to data. It can be set as null - * @param {number} idx - * @param {module:zrender/Element} [el] - */ - listProto.setItemGraphicEl = function (idx, el) { - var hostModel = this.hostModel; - - if (el) { - // Add data index and series index for indexing the data by element - // Useful in tooltip - el.dataIndex = idx; - el.seriesIndex = hostModel && hostModel.seriesIndex; - if (el.type === 'group') { - el.traverse(setItemDataAndSeriesIndex, el); - } - } - - this._graphicEls[idx] = el; - }; - - /** - * @param {number} idx - * @return {module:zrender/Element} - */ - listProto.getItemGraphicEl = function (idx) { - return this._graphicEls[idx]; - }; - - /** - * @param {Function} cb - * @param {*} context - */ - listProto.eachItemGraphicEl = function (cb, context) { - zrUtil.each(this._graphicEls, function (el, idx) { - if (el) { - cb && cb.call(context, el, idx); - } - }); - }; - - /** - * Shallow clone a new list except visual and layout properties, and graph elements. - * New list only change the indices. - */ - listProto.cloneShallow = function () { - var dimensionInfoList = zrUtil.map(this.dimensions, this.getDimensionInfo, this); - var list = new List(dimensionInfoList, this.hostModel); - - // FIXME - list._storage = this._storage; - - transferImmuProperties(list, this, this._wrappedMethods); - - list.indices = this.indices.slice(); - - return list; - }; - - /** - * Wrap some method to add more feature - * @param {string} methodName - * @param {Function} injectFunction - */ - listProto.wrapMethod = function (methodName, injectFunction) { - var originalMethod = this[methodName]; - if (typeof originalMethod !== 'function') { - return; - } - this._wrappedMethods = this._wrappedMethods || []; - this._wrappedMethods.push(methodName); - this[methodName] = function () { - var res = originalMethod.apply(this, arguments); - return injectFunction.call(this, res); - }; - }; - - return List; -}); -/** - * Complete dimensions by data (guess dimension). - */ -define('echarts/data/helper/completeDimensions',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - function completeDimensions(dimensions, data, defaultNames) { - if (!data) { - return dimensions; - } - - var value0 = retrieveValue(data[0]); - var dimSize = zrUtil.isArray(value0) && value0.length || 1; - - defaultNames = defaultNames || []; - for (var i = 0; i < dimSize; i++) { - if (!dimensions[i]) { - var name = defaultNames[i] || ('extra' + (i - defaultNames.length)); - dimensions[i] = guessOrdinal(data, i) - ? {type: 'ordinal', name: name} - : name; - } - } - - return dimensions; - } - - // The rule should not be complex, otherwise user might not - // be able to known where the data is wrong. - function guessOrdinal(data, dimIndex) { - for (var i = 0, len = data.length; i < len; i++) { - var value = retrieveValue(data[i]); - - if (!zrUtil.isArray(value)) { - return false; - } - - var value = value[dimIndex]; - if (value != null && isFinite(value)) { - return false; - } - else if (zrUtil.isString(value) && value !== '-') { - return true; - } - } - return false; - } - - function retrieveValue(o) { - return zrUtil.isArray(o) ? o : zrUtil.isObject(o) ? o.value: o; - } - - return completeDimensions; + parallelModel.coordinateSystem = coordSys; + coordSys.model = parallelModel; -}); -define('echarts/chart/helper/createListFromArray',['require','../../data/List','../../data/helper/completeDimensions','zrender/core/util','../../util/model','../../CoordinateSystem'],function(require) { - - - var List = require('../../data/List'); - var completeDimensions = require('../../data/helper/completeDimensions'); - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../../util/model'); - var CoordinateSystem = require('../../CoordinateSystem'); - var getDataItemValue = modelUtil.getDataItemValue; - var converDataValue = modelUtil.converDataValue; - - function firstDataNotNull(data) { - var i = 0; - while (i < data.length && data[i] == null) { - i++; - } - return data[i]; - } - function ifNeedCompleteOrdinalData(data) { - var sampleItem = firstDataNotNull(data); - return sampleItem != null - && !zrUtil.isArray(getDataItemValue(sampleItem)); - } - - /** - * Helper function to create a list from option data - */ - function createListFromArray(data, seriesModel, ecModel) { - // If data is undefined - data = data || []; - - var coordSysName = seriesModel.get('coordinateSystem'); - var creator = creators[coordSysName]; - var registeredCoordSys = CoordinateSystem.get(coordSysName); - // FIXME - var result = creator && creator(data, seriesModel, ecModel); - var dimensions = result && result.dimensions; - if (!dimensions) { - // Get dimensions from registered coordinate system - dimensions = (registeredCoordSys && registeredCoordSys.dimensions) || ['x', 'y']; - dimensions = completeDimensions(dimensions, data, dimensions.concat(['value'])); - } - var categoryAxisModel = result && result.categoryAxisModel; - - var categoryDimIndex = dimensions[0].type === 'ordinal' - ? 0 : (dimensions[1].type === 'ordinal' ? 1 : -1); - - var list = new List(dimensions, seriesModel); - - var nameList = createNameList(result, data); - - var dimValueGetter = (categoryAxisModel && ifNeedCompleteOrdinalData(data)) - ? function (itemOpt, dimName, dataIndex, dimIndex) { - // Use dataIndex as ordinal value in categoryAxis - return dimIndex === categoryDimIndex - ? dataIndex - : converDataValue(getDataItemValue(itemOpt), dimensions[dimIndex]); - } - : function (itemOpt, dimName, dataIndex, dimIndex) { - var val = getDataItemValue(itemOpt); - return converDataValue(val && val[dimIndex], dimensions[dimIndex]); - }; - - list.initData(data, nameList, dimValueGetter); - - return list; - } - - function isStackable(axisType) { - return axisType !== 'category' && axisType !== 'time'; - } - - function getDimTypeByAxis(axisType) { - return axisType === 'category' - ? 'ordinal' - : axisType === 'time' - ? 'time' - : 'float'; - } - - /** - * Creaters for each coord system. - * @return {Object} {dimensions, categoryAxisModel}; - */ - var creators = { - - cartesian2d: function (data, seriesModel, ecModel) { - var xAxisModel = ecModel.getComponent('xAxis', seriesModel.get('xAxisIndex')); - var yAxisModel = ecModel.getComponent('yAxis', seriesModel.get('yAxisIndex')); - var xAxisType = xAxisModel.get('type'); - var yAxisType = yAxisModel.get('type'); - - var dimensions = [ - { - name: 'x', - type: getDimTypeByAxis(xAxisType), - stackable: isStackable(xAxisType) - }, - { - name: 'y', - // If two category axes - type: getDimTypeByAxis(yAxisType), - stackable: isStackable(yAxisType) - } - ]; - - completeDimensions(dimensions, data, ['x', 'y', 'z']); - - return { - dimensions: dimensions, - categoryAxisModel: xAxisType === 'category' - ? xAxisModel - : (yAxisType === 'category' ? yAxisModel : null) - }; - }, - - polar: function (data, seriesModel, ecModel) { - var polarIndex = seriesModel.get('polarIndex') || 0; - - var axisFinder = function (axisModel) { - return axisModel.get('polarIndex') === polarIndex; - }; - - var angleAxisModel = ecModel.findComponents({ - mainType: 'angleAxis', filter: axisFinder - })[0]; - var radiusAxisModel = ecModel.findComponents({ - mainType: 'radiusAxis', filter: axisFinder - })[0]; - - var radiusAxisType = radiusAxisModel.get('type'); - var angleAxisType = angleAxisModel.get('type'); - - var dimensions = [ - { - name: 'radius', - type: getDimTypeByAxis(radiusAxisType), - stackable: isStackable(radiusAxisType) - }, - { - name: 'angle', - type: getDimTypeByAxis(angleAxisType), - stackable: isStackable(angleAxisType) - } - ]; - - completeDimensions(dimensions, data, ['radius', 'angle', 'value']); - - return { - dimensions: dimensions, - categoryAxisModel: angleAxisType === 'category' - ? angleAxisModel - : (radiusAxisType === 'category' ? radiusAxisModel : null) - }; - }, - - geo: function (data, seriesModel, ecModel) { - // TODO Region - // 多个散点图系列在同一个地区的时候 - return { - dimensions: completeDimensions([ - {name: 'lng'}, - {name: 'lat'} - ], data, ['lng', 'lat', 'value']) - }; - } - }; - - function createNameList(result, data) { - var nameList = []; - - if (result && result.categoryAxisModel) { - // FIXME Two category axis - var categories = result.categoryAxisModel.getCategories(); - if (categories) { - var dataLen = data.length; - // Ordered data is given explicitly like - // [[3, 0.2], [1, 0.3], [2, 0.15]] - // or given scatter data, - // pick the category - if (zrUtil.isArray(data[0]) && data[0].length > 1) { - nameList = []; - for (var i = 0; i < dataLen; i++) { - nameList[i] = categories[data[i][0]]; - } - } - else { - nameList = categories.slice(0); - } - } - } - - return nameList; - } - - return createListFromArray; + coordSysList.push(coordSys); + }); -}); -define('echarts/chart/line/LineSeries',['require','../helper/createListFromArray','../../model/Series'],function(require) { - - - - var createListFromArray = require('../helper/createListFromArray'); - var SeriesModel = require('../../model/Series'); - - return SeriesModel.extend({ - - type: 'series.line', - - dependencies: ['grid', 'polar'], - - getInitialData: function (option, ecModel) { - return createListFromArray(option.data, this, ecModel); - }, - - defaultOption: { - zlevel: 0, // 一级层叠 - z: 2, // 二级层叠 - coordinateSystem: 'cartesian2d', - legendHoverLink: true, - - hoverAnimation: true, - // stack: null - xAxisIndex: 0, - yAxisIndex: 0, - - polarIndex: 0, - - // If clip the overflow value - clipOverflow: true, - - label: { - normal: { - // show: false, - position: 'top' - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 - // 'inside'|'left'|'right'|'top'|'bottom' - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - }, - emphasis: { - // show: false, - position: 'top' - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 - // 'inside'|'left'|'right'|'top'|'bottom' - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - } - }, - // itemStyle: { - // normal: { - // // color: 各异 - // }, - // emphasis: { - // // color: 各异, - // } - // }, - lineStyle: { - normal: { - width: 2, - type: 'solid' - } - }, - // areaStyle: { - // }, - // smooth: false, - // smoothMonotone: null, - // 拐点图形类型 - symbol: 'emptyCircle', - // 拐点图形大小 - symbolSize: 4, - // 拐点图形旋转控制 - // symbolRotate: null, - - // 是否显示 symbol, 只有在 tooltip hover 的时候显示 - showSymbol: true, - // 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略) - // showAllSymbol: false - // - // 大数据过滤,'average', 'max', 'min', 'sum' - // sampling: 'none' - - animationEasing: 'linear' - } - }); -}); -// Symbol factory -define('echarts/util/symbol',['require','./graphic','zrender/core/BoundingRect'],function(require) { - - - - var graphic = require('./graphic'); - var BoundingRect = require('zrender/core/BoundingRect'); - - /** - * Triangle shape - * @inner - */ - var Triangle = graphic.extendShape({ - type: 'triangle', - shape: { - cx: 0, - cy: 0, - width: 0, - height: 0 - }, - buildPath: function (path, shape) { - var cx = shape.cx; - var cy = shape.cy; - var width = shape.width / 2; - var height = shape.height / 2; - path.moveTo(cx, cy - height); - path.lineTo(cx + width, cy + height); - path.lineTo(cx - width, cy + height); - path.closePath(); - } - }); - /** - * Diamond shape - * @inner - */ - var Diamond = graphic.extendShape({ - type: 'diamond', - shape: { - cx: 0, - cy: 0, - width: 0, - height: 0 - }, - buildPath: function (path, shape) { - var cx = shape.cx; - var cy = shape.cy; - var width = shape.width / 2; - var height = shape.height / 2; - path.moveTo(cx, cy - height); - path.lineTo(cx + width, cy); - path.lineTo(cx, cy + height); - path.lineTo(cx - width, cy); - path.closePath(); - } - }); - - /** - * Pin shape - * @inner - */ - var Pin = graphic.extendShape({ - type: 'pin', - shape: { - // x, y on the cusp - x: 0, - y: 0, - width: 0, - height: 0 - }, - - buildPath: function (path, shape) { - var x = shape.x; - var y = shape.y; - var w = shape.width / 5 * 3; - // Height must be larger than width - var h = Math.max(w, shape.height); - var r = w / 2; - - // Dist on y with tangent point and circle center - var dy = r * r / (h - r); - var cy = y - h + r + dy; - var angle = Math.asin(dy / r); - // Dist on x with tangent point and circle center - var dx = Math.cos(angle) * r; - - var tanX = Math.sin(angle); - var tanY = Math.cos(angle); - - path.arc( - x, cy, r, - Math.PI - angle, - Math.PI * 2 + angle - ); - - var cpLen = r * 0.6; - var cpLen2 = r * 0.7; - path.bezierCurveTo( - x + dx - tanX * cpLen, cy + dy + tanY * cpLen, - x, y - cpLen2, - x, y - ); - path.bezierCurveTo( - x, y - cpLen2, - x - dx + tanX * cpLen, cy + dy + tanY * cpLen, - x - dx, cy + dy - ); - path.closePath(); - } - }); - - /** - * Arrow shape - * @inner - */ - var Arrow = graphic.extendShape({ - - type: 'arrow', - - shape: { - x: 0, - y: 0, - width: 0, - height: 0 - }, - - buildPath: function (ctx, shape) { - var height = shape.height; - var width = shape.width; - var x = shape.x; - var y = shape.y; - var dx = width / 3 * 2; - ctx.moveTo(x, y); - ctx.lineTo(x + dx, y + height); - ctx.lineTo(x, y + height / 4 * 3); - ctx.lineTo(x - dx, y + height); - ctx.lineTo(x, y); - ctx.closePath(); - } - }); - - /** - * Map of path contructors - * @type {Object.} - */ - var symbolCtors = { - line: graphic.Line, - - rect: graphic.Rect, - - roundRect: graphic.Rect, - - square: graphic.Rect, - - circle: graphic.Circle, - - diamond: Diamond, - - pin: Pin, - - arrow: Arrow, - - triangle: Triangle - }; - - var symbolShapeMakers = { - - line: function (x, y, w, h, shape) { - // FIXME - shape.x1 = x; - shape.y1 = y + h / 2; - shape.x2 = x + w; - shape.y2 = y + h / 2; - }, - - rect: function (x, y, w, h, shape) { - shape.x = x; - shape.y = y; - shape.width = w; - shape.height = h; - }, - - roundRect: function (x, y, w, h, shape) { - shape.x = x; - shape.y = y; - shape.width = w; - shape.height = h; - shape.r = Math.min(w, h) / 4; - }, - - square: function (x, y, w, h, shape) { - var size = Math.min(w, h); - shape.x = x; - shape.y = y; - shape.width = size; - shape.height = size; - }, - - circle: function (x, y, w, h, shape) { - // Put circle in the center of square - shape.cx = x + w / 2; - shape.cy = y + h / 2; - shape.r = Math.min(w, h) / 2; - }, - - diamond: function (x, y, w, h, shape) { - shape.cx = x + w / 2; - shape.cy = y + h / 2; - shape.width = w; - shape.height = h; - }, - - pin: function (x, y, w, h, shape) { - shape.x = x + w / 2; - shape.y = y + h / 2; - shape.width = w; - shape.height = h; - }, - - arrow: function (x, y, w, h, shape) { - shape.x = x + w / 2; - shape.y = y + h / 2; - shape.width = w; - shape.height = h; - }, - - triangle: function (x, y, w, h, shape) { - shape.cx = x + w / 2; - shape.cy = y + h / 2; - shape.width = w; - shape.height = h; - } - }; - - var symbolBuildProxies = {}; - for (var name in symbolCtors) { - symbolBuildProxies[name] = new symbolCtors[name](); - } - - var Symbol = graphic.extendShape({ - - type: 'symbol', - - shape: { - symbolType: '', - x: 0, - y: 0, - width: 0, - height: 0 - }, - - beforeBrush: function () { - var style = this.style; - var shape = this.shape; - // FIXME - if (shape.symbolType === 'pin' && style.textPosition === 'inside') { - style.textPosition = ['50%', '40%']; - style.textAlign = 'center'; - style.textBaseline = 'middle'; - } - }, - - buildPath: function (ctx, shape) { - var symbolType = shape.symbolType; - var proxySymbol = symbolBuildProxies[symbolType]; - if (shape.symbolType !== 'none') { - if (!proxySymbol) { - // Default rect - symbolType = 'rect'; - proxySymbol = symbolBuildProxies[symbolType]; - } - symbolShapeMakers[symbolType]( - shape.x, shape.y, shape.width, shape.height, proxySymbol.shape - ); - proxySymbol.buildPath(ctx, proxySymbol.shape); - } - } - }); - - // Provide setColor helper method to avoid determine if set the fill or stroke outside - var symbolPathSetColor = function (color) { - if (this.type !== 'image') { - var symbolStyle = this.style; - var symbolShape = this.shape; - if (symbolShape && symbolShape.symbolType === 'line') { - symbolStyle.stroke = color; - } - else if (this.__isEmptyBrush) { - symbolStyle.stroke = color; - symbolStyle.fill = '#fff'; - } - else { - // FIXME 判断图形默认是填充还是描边,使用 onlyStroke ? - symbolStyle.fill && (symbolStyle.fill = color); - symbolStyle.stroke && (symbolStyle.stroke = color); - } - this.dirty(); - } - }; - - var symbolUtil = { - /** - * Create a symbol element with given symbol configuration: shape, x, y, width, height, color - * @param {string} symbolType - * @param {number} x - * @param {number} y - * @param {number} w - * @param {number} h - * @param {string} color - */ - createSymbol: function (symbolType, x, y, w, h, color) { - var isEmpty = symbolType.indexOf('empty') === 0; - if (isEmpty) { - symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6); - } - var symbolPath; - - if (symbolType.indexOf('image://') === 0) { - symbolPath = new graphic.Image({ - style: { - image: symbolType.slice(8), - x: x, - y: y, - width: w, - height: h - } - }); - } - else if (symbolType.indexOf('path://') === 0) { - symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h)); - } - else { - symbolPath = new Symbol({ - shape: { - symbolType: symbolType, - x: x, - y: y, - width: w, - height: h - } - }); - } - - symbolPath.__isEmptyBrush = isEmpty; - - symbolPath.setColor = symbolPathSetColor; - - symbolPath.setColor(color); - - return symbolPath; - } - }; - - return symbolUtil; -}); -/** - * @module echarts/chart/helper/Symbol - */ -define('echarts/chart/helper/Symbol',['require','zrender/core/util','../../util/symbol','../../util/graphic','../../util/number'],function (require) { - - var zrUtil = require('zrender/core/util'); - var symbolUtil = require('../../util/symbol'); - var graphic = require('../../util/graphic'); - var numberUtil = require('../../util/number'); - - function normalizeSymbolSize(symbolSize) { - if (!zrUtil.isArray(symbolSize)) { - symbolSize = [+symbolSize, +symbolSize]; - } - return symbolSize; - } - - /** - * @constructor - * @alias {module:echarts/chart/helper/Symbol} - * @param {module:echarts/data/List} data - * @param {number} idx - * @extends {module:zrender/graphic/Group} - */ - function Symbol(data, idx) { - graphic.Group.call(this); - - this.updateData(data, idx); - } - - var symbolProto = Symbol.prototype; - - function driftSymbol(dx, dy) { - this.parent.drift(dx, dy); - } - - symbolProto._createSymbol = function (symbolType, data, idx) { - // Remove paths created before - this.removeAll(); - - var seriesModel = data.hostModel; - var color = data.getItemVisual(idx, 'color'); - - var symbolPath = symbolUtil.createSymbol( - symbolType, -0.5, -0.5, 1, 1, color - ); - - symbolPath.attr({ - style: { - strokeNoScale: true - }, - z2: 100, - culling: true, - scale: [0, 0] - }); - // Rewrite drift method - symbolPath.drift = driftSymbol; - - var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); - - graphic.initProps(symbolPath, { - scale: size - }, seriesModel); - - this._symbolType = symbolType; - - this.add(symbolPath); - }; - - /** - * Stop animation - * @param {boolean} toLastFrame - */ - symbolProto.stopSymbolAnimation = function (toLastFrame) { - this.childAt(0).stopAnimation(toLastFrame); - }; - - /** - * Get scale(aka, current symbol size). - * Including the change caused by animation - * @param {Array.} toLastFrame - */ - symbolProto.getScale = function () { - return this.childAt(0).scale; - }; - - /** - * Highlight symbol - */ - symbolProto.highlight = function () { - this.childAt(0).trigger('emphasis'); - }; - - /** - * Downplay symbol - */ - symbolProto.downplay = function () { - this.childAt(0).trigger('normal'); - }; - - /** - * @param {number} zlevel - * @param {number} z - */ - symbolProto.setZ = function (zlevel, z) { - var symbolPath = this.childAt(0); - symbolPath.zlevel = zlevel; - symbolPath.z = z; - }; - - symbolProto.setDraggable = function (draggable) { - var symbolPath = this.childAt(0); - symbolPath.draggable = draggable; - symbolPath.cursor = draggable ? 'move' : 'pointer'; - }; - /** - * Update symbol properties - * @param {module:echarts/data/List} data - * @param {number} idx - */ - symbolProto.updateData = function (data, idx) { - var symbolType = data.getItemVisual(idx, 'symbol') || 'circle'; - var seriesModel = data.hostModel; - var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); - if (symbolType !== this._symbolType) { - this._createSymbol(symbolType, data, idx); - } - else { - var symbolPath = this.childAt(0); - graphic.updateProps(symbolPath, { - scale: symbolSize - }, seriesModel); - } - this._updateCommon(data, idx, symbolSize); - - this._seriesModel = seriesModel; - }; - - // Update common properties - var normalStyleAccessPath = ['itemStyle', 'normal']; - var emphasisStyleAccessPath = ['itemStyle', 'emphasis']; - var normalLabelAccessPath = ['label', 'normal']; - var emphasisLabelAccessPath = ['label', 'emphasis']; - - symbolProto._updateCommon = function (data, idx, symbolSize) { - var symbolPath = this.childAt(0); - var seriesModel = data.hostModel; - var itemModel = data.getItemModel(idx); - var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath); - var color = data.getItemVisual(idx, 'color'); - - var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle(); - - symbolPath.rotation = itemModel.getShallow('symbolRotate') * Math.PI / 180 || 0; - - var symbolOffset = itemModel.getShallow('symbolOffset'); - if (symbolOffset) { - var pos = symbolPath.position; - pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]); - pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]); - } - - symbolPath.setColor(color); - - zrUtil.extend( - symbolPath.style, - // Color must be excluded. - // Because symbol provide setColor individually to set fill and stroke - normalItemStyleModel.getItemStyle(['color']) - ); - - var labelModel = itemModel.getModel(normalLabelAccessPath); - var hoverLabelModel = itemModel.getModel(emphasisLabelAccessPath); - - var elStyle = symbolPath.style; - - // Get last value dim - var dimensions = data.dimensions.slice(); - var valueDim = dimensions.pop(); - var dataType; - while ( - ((dataType = data.getDimensionInfo(valueDim).type) === 'ordinal') - || (dataType === 'time') - ) { - valueDim = dimensions.pop(); - } - - if (labelModel.get('show')) { - graphic.setText(elStyle, labelModel, color); - elStyle.text = zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'normal'), - data.get(valueDim, idx) - ); - } - else { - elStyle.text = ''; - } - - if (hoverLabelModel.getShallow('show')) { - graphic.setText(hoverStyle, hoverLabelModel, color); - hoverStyle.text = zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'emphasis'), - data.get(valueDim, idx) - ); - } - else { - hoverStyle.text = ''; - } - - var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); - - symbolPath.off('mouseover') - .off('mouseout') - .off('emphasis') - .off('normal'); - - graphic.setHoverStyle(symbolPath, hoverStyle); - - if (itemModel.getShallow('hoverAnimation')) { - var onEmphasis = function() { - var ratio = size[1] / size[0]; - this.animateTo({ - scale: [ - Math.max(size[0] * 1.1, size[0] + 3), - Math.max(size[1] * 1.1, size[1] + 3 * ratio) - ] - }, 400, 'elasticOut'); - }; - var onNormal = function() { - this.animateTo({ - scale: size - }, 400, 'elasticOut'); - }; - symbolPath.on('mouseover', onEmphasis) - .on('mouseout', onNormal) - .on('emphasis', onEmphasis) - .on('normal', onNormal); - } - }; - - symbolProto.fadeOut = function (cb) { - var symbolPath = this.childAt(0); - // Not show text when animating - symbolPath.style.text = ''; - graphic.updateProps(symbolPath, { - scale: [0, 0] - }, this._seriesModel, cb); - }; - - zrUtil.inherits(Symbol, graphic.Group); - - return Symbol; -}); -/** - * @module echarts/chart/helper/SymbolDraw - */ -define('echarts/chart/helper/SymbolDraw',['require','../../util/graphic','./Symbol'],function (require) { - - var graphic = require('../../util/graphic'); - var Symbol = require('./Symbol'); - - /** - * @constructor - * @alias module:echarts/chart/helper/SymbolDraw - * @param {module:zrender/graphic/Group} [symbolCtor] - */ - function SymbolDraw(symbolCtor) { - this.group = new graphic.Group(); - - this._symbolCtor = symbolCtor || Symbol; - } - - var symbolDrawProto = SymbolDraw.prototype; - - function symbolNeedsDraw(data, idx, isIgnore) { - var point = data.getItemLayout(idx); - return point && !isNaN(point[0]) && !isNaN(point[1]) && !(isIgnore && isIgnore(idx)) - && data.getItemVisual(idx, 'symbol') !== 'none'; - } - /** - * Update symbols draw by new data - * @param {module:echarts/data/List} data - * @param {Array.} [isIgnore] - */ - symbolDrawProto.updateData = function (data, isIgnore) { - var group = this.group; - var seriesModel = data.hostModel; - var oldData = this._data; - - var SymbolCtor = this._symbolCtor; - - data.diff(oldData) - .add(function (newIdx) { - var point = data.getItemLayout(newIdx); - if (symbolNeedsDraw(data, newIdx, isIgnore)) { - var symbolEl = new SymbolCtor(data, newIdx); - symbolEl.attr('position', point); - data.setItemGraphicEl(newIdx, symbolEl); - group.add(symbolEl); - } - }) - .update(function (newIdx, oldIdx) { - var symbolEl = oldData.getItemGraphicEl(oldIdx); - var point = data.getItemLayout(newIdx); - if (!symbolNeedsDraw(data, newIdx, isIgnore)) { - group.remove(symbolEl); - return; - } - if (!symbolEl) { - symbolEl = new SymbolCtor(data, newIdx); - symbolEl.attr('position', point); - } - else { - symbolEl.updateData(data, newIdx); - graphic.updateProps(symbolEl, { - position: point - }, seriesModel); - } - - // Add back - group.add(symbolEl); - - data.setItemGraphicEl(newIdx, symbolEl); - }) - .remove(function (oldIdx) { - var el = oldData.getItemGraphicEl(oldIdx); - el && el.fadeOut(function () { - group.remove(el); - }); - }) - .execute(); - - this._data = data; - }; - - symbolDrawProto.updateLayout = function () { - var data = this._data; - if (data) { - // Not use animation - data.eachItemGraphicEl(function (el, idx) { - el.attr('position', data.getItemLayout(idx)); - }); - } - }; - - symbolDrawProto.remove = function (enableAnimation) { - var group = this.group; - var data = this._data; - if (data) { - if (enableAnimation) { - data.eachItemGraphicEl(function (el) { - el.fadeOut(function () { - group.remove(el); - }); - }); - } - else { - group.removeAll(); - } - } - }; - - return SymbolDraw; -}); -define('echarts/chart/line/lineAnimationDiff',['require'],function (require) { - - // var arrayDiff = require('zrender/core/arrayDiff'); - // 'zrender/core/arrayDiff' has been used before, but it did - // not do well in performance when roam with fixed dataZoom window. - - function sign(val) { - return val >= 0 ? 1 : -1; - } - - function getStackedOnPoint(coordSys, data, idx) { - var baseAxis = coordSys.getBaseAxis(); - var valueAxis = coordSys.getOtherAxis(baseAxis); - var valueStart = baseAxis.onZero - ? 0 : valueAxis.scale.getExtent()[0]; - - var valueDim = valueAxis.dim; - var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0; - - var stackedOnSameSign; - var stackedOn = data.stackedOn; - var val = data.get(valueDim, idx); - // Find first stacked value with same sign - while (stackedOn && - sign(stackedOn.get(valueDim, idx)) === sign(val) - ) { - stackedOnSameSign = stackedOn; - break; - } - var stackedData = []; - stackedData[baseDataOffset] = data.get(baseAxis.dim, idx); - stackedData[1 - baseDataOffset] = stackedOnSameSign - ? stackedOnSameSign.get(valueDim, idx, true) : valueStart; - - return coordSys.dataToPoint(stackedData); - } - - // function convertToIntId(newIdList, oldIdList) { - // // Generate int id instead of string id. - // // Compare string maybe slow in score function of arrDiff - - // // Assume id in idList are all unique - // var idIndicesMap = {}; - // var idx = 0; - // for (var i = 0; i < newIdList.length; i++) { - // idIndicesMap[newIdList[i]] = idx; - // newIdList[i] = idx++; - // } - // for (var i = 0; i < oldIdList.length; i++) { - // var oldId = oldIdList[i]; - // // Same with newIdList - // if (idIndicesMap[oldId]) { - // oldIdList[i] = idIndicesMap[oldId]; - // } - // else { - // oldIdList[i] = idx++; - // } - // } - // } - - function diffData(oldData, newData) { - var diffResult = []; - - newData.diff(oldData) - .add(function (idx) { - diffResult.push({cmd: '+', idx: idx}); - }) - .update(function (newIdx, oldIdx) { - diffResult.push({cmd: '=', idx: oldIdx, idx1: newIdx}); - }) - .remove(function (idx) { - diffResult.push({cmd: '-', idx: idx}); - }) - .execute(); - - return diffResult; - } - - return function ( - oldData, newData, - oldStackedOnPoints, newStackedOnPoints, - oldCoordSys, newCoordSys - ) { - var diff = diffData(oldData, newData); - - // var newIdList = newData.mapArray(newData.getId); - // var oldIdList = oldData.mapArray(oldData.getId); - - // convertToIntId(newIdList, oldIdList); - - // // FIXME One data ? - // diff = arrayDiff(oldIdList, newIdList); - - var currPoints = []; - var nextPoints = []; - // Points for stacking base line - var currStackedPoints = []; - var nextStackedPoints = []; - - var status = []; - var sortedIndices = []; - var rawIndices = []; - var dims = newCoordSys.dimensions; - for (var i = 0; i < diff.length; i++) { - var diffItem = diff[i]; - var pointAdded = true; - - // FIXME, animation is not so perfect when dataZoom window moves fast - // Which is in case remvoing or add more than one data in the tail or head - switch (diffItem.cmd) { - case '=': - var currentPt = oldData.getItemLayout(diffItem.idx); - var nextPt = newData.getItemLayout(diffItem.idx1); - // If previous data is NaN, use next point directly - if (isNaN(currentPt[0]) || isNaN(currentPt[1])) { - currentPt = nextPt.slice(); - } - currPoints.push(currentPt); - nextPoints.push(nextPt); - - currStackedPoints.push(oldStackedOnPoints[diffItem.idx]); - nextStackedPoints.push(newStackedOnPoints[diffItem.idx1]); - - rawIndices.push(newData.getRawIndex(diffItem.idx1)); - break; - case '+': - var idx = diffItem.idx; - currPoints.push( - oldCoordSys.dataToPoint([ - newData.get(dims[0], idx, true), newData.get(dims[1], idx, true) - ]) - ); - - nextPoints.push(newData.getItemLayout(idx).slice()); - - currStackedPoints.push( - getStackedOnPoint(oldCoordSys, newData, idx) - ); - nextStackedPoints.push(newStackedOnPoints[idx]); - - rawIndices.push(newData.getRawIndex(idx)); - break; - case '-': - var idx = diffItem.idx; - var rawIndex = oldData.getRawIndex(idx); - // Data is replaced. In the case of dynamic data queue - // FIXME FIXME FIXME - if (rawIndex !== idx) { - currPoints.push(oldData.getItemLayout(idx)); - nextPoints.push(newCoordSys.dataToPoint([ - oldData.get(dims[0], idx, true), oldData.get(dims[1], idx, true) - ])); - - currStackedPoints.push(oldStackedOnPoints[idx]); - nextStackedPoints.push( - getStackedOnPoint( - newCoordSys, oldData, idx - ) - ); - - rawIndices.push(rawIndex); - } - else { - pointAdded = false; - } - } - - // Original indices - if (pointAdded) { - status.push(diffItem); - sortedIndices.push(sortedIndices.length); - } - } - - // Diff result may be crossed if all items are changed - // Sort by data index - sortedIndices.sort(function (a, b) { - return rawIndices[a] - rawIndices[b]; - }); - - var sortedCurrPoints = []; - var sortedNextPoints = []; - - var sortedCurrStackedPoints = []; - var sortedNextStackedPoints = []; - - var sortedStatus = []; - for (var i = 0; i < sortedIndices.length; i++) { - var idx = sortedIndices[i]; - sortedCurrPoints[i] = currPoints[idx]; - sortedNextPoints[i] = nextPoints[idx]; - - sortedCurrStackedPoints[i] = currStackedPoints[idx]; - sortedNextStackedPoints[i] = nextStackedPoints[idx]; - - sortedStatus[i] = status[idx]; - } - - return { - current: sortedCurrPoints, - next: sortedNextPoints, - - stackedOnCurrent: sortedCurrStackedPoints, - stackedOnNext: sortedNextStackedPoints, - - status: sortedStatus - }; - }; -}); -// Poly path support NaN point -define('echarts/chart/line/poly',['require','zrender/graphic/Path','zrender/core/vector'],function (require) { - - var Path = require('zrender/graphic/Path'); - var vec2 = require('zrender/core/vector'); - - var vec2Min = vec2.min; - var vec2Max = vec2.max; - - var scaleAndAdd = vec2.scaleAndAdd; - var v2Copy = vec2.copy; - - // Temporary variable - var v = []; - var cp0 = []; - var cp1 = []; - - function drawSegment( - ctx, points, start, stop, len, - dir, smoothMin, smoothMax, smooth, smoothMonotone - ) { - var idx = start; - for (var k = 0; k < len; k++) { - var p = points[idx]; - if (idx >= stop || idx < 0 || isNaN(p[0]) || isNaN(p[1])) { - break; - } - - if (idx === start) { - ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]); - v2Copy(cp0, p); - } - else { - if (smooth > 0) { - var prevIdx = idx - dir; - var nextIdx = idx + dir; - - var ratioNextSeg = 0.5; - var prevP = points[prevIdx]; - var nextP = points[nextIdx]; - // Last point - if ((dir > 0 && (idx === len - 1 || isNaN(nextP[0]) || isNaN(nextP[1]))) - || (dir <= 0 && (idx === 0 || isNaN(nextP[0]) || isNaN(nextP[1]))) - ) { - v2Copy(cp1, p); - } - else { - // If next data is null - if (isNaN(nextP[0]) || isNaN(nextP[1])) { - nextP = p; - } - - vec2.sub(v, nextP, prevP); - - var lenPrevSeg; - var lenNextSeg; - if (smoothMonotone === 'x' || smoothMonotone === 'y') { - var dim = smoothMonotone === 'x' ? 0 : 1; - lenPrevSeg = Math.abs(p[dim] - prevP[dim]); - lenNextSeg = Math.abs(p[dim] - nextP[dim]); - } - else { - lenPrevSeg = vec2.dist(p, prevP); - lenNextSeg = vec2.dist(p, nextP); - } - - // Use ratio of seg length - ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg); - - scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg)); - } - // Smooth constraint - vec2Min(cp0, cp0, smoothMax); - vec2Max(cp0, cp0, smoothMin); - vec2Min(cp1, cp1, smoothMax); - vec2Max(cp1, cp1, smoothMin); - - ctx.bezierCurveTo( - cp0[0], cp0[1], - cp1[0], cp1[1], - p[0], p[1] - ); - // cp0 of next segment - scaleAndAdd(cp0, p, v, smooth * ratioNextSeg); - } - else { - ctx.lineTo(p[0], p[1]); - } - } - - idx += dir; - } - - return k; - } - - function getBoundingBox(points, smoothConstraint) { - var ptMin = [Infinity, Infinity]; - var ptMax = [-Infinity, -Infinity]; - if (smoothConstraint) { - for (var i = 0; i < points.length; i++) { - var pt = points[i]; - if (pt[0] < ptMin[0]) { ptMin[0] = pt[0]; } - if (pt[1] < ptMin[1]) { ptMin[1] = pt[1]; } - if (pt[0] > ptMax[0]) { ptMax[0] = pt[0]; } - if (pt[1] > ptMax[1]) { ptMax[1] = pt[1]; } - } - } - return { - min: smoothConstraint ? ptMin : ptMax, - max: smoothConstraint ? ptMax : ptMin - }; - } - - return { - - Polyline: Path.extend({ - - type: 'ec-polyline', - - shape: { - points: [], - - smooth: 0, - - smoothConstraint: true, - - smoothMonotone: null - }, - - style: { - fill: null, - - stroke: '#000' - }, - - buildPath: function (ctx, shape) { - var points = shape.points; - - var i = 0; - var len = points.length; - - var result = getBoundingBox(points, shape.smoothConstraint); - - while (i < len) { - i += drawSegment( - ctx, points, i, len, len, - 1, result.min, result.max, shape.smooth, - shape.smoothMonotone - ) + 1; - } - } - }), - - Polygon: Path.extend({ - - type: 'ec-polygon', - - shape: { - points: [], - - // Offset between stacked base points and points - stackedOnPoints: [], - - smooth: 0, - - stackedOnSmooth: 0, - - smoothConstraint: true, - - smoothMonotone: null - }, - - buildPath: function (ctx, shape) { - var points = shape.points; - var stackedOnPoints = shape.stackedOnPoints; - - var i = 0; - var len = points.length; - var smoothMonotone = shape.smoothMonotone; - var bbox = getBoundingBox(points, shape.smoothConstraint); - var stackedOnBBox = getBoundingBox(stackedOnPoints, shape.smoothConstraint); - while (i < len) { - var k = drawSegment( - ctx, points, i, len, len, - 1, bbox.min, bbox.max, shape.smooth, - smoothMonotone - ); - drawSegment( - ctx, stackedOnPoints, i + k - 1, len, k, - -1, stackedOnBBox.min, stackedOnBBox.max, shape.stackedOnSmooth, - smoothMonotone - ); - i += k + 1; - - ctx.closePath(); - } - } - }) - }; -}); -define('echarts/chart/line/LineView',['require','zrender/core/util','../helper/SymbolDraw','../helper/Symbol','./lineAnimationDiff','../../util/graphic','./poly','../../view/Chart'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var SymbolDraw = require('../helper/SymbolDraw'); - var Symbol = require('../helper/Symbol'); - var lineAnimationDiff = require('./lineAnimationDiff'); - var graphic = require('../../util/graphic'); - - var polyHelper = require('./poly'); - - var ChartView = require('../../view/Chart'); - - function isPointsSame(points1, points2) { - if (points1.length !== points2.length) { - return; - } - for (var i = 0; i < points1.length; i++) { - var p1 = points1[i]; - var p2 = points2[i]; - if (p1[0] !== p2[0] || p1[1] !== p2[1]) { - return; - } - } - return true; - } - - function getSmooth(smooth) { - return typeof (smooth) === 'number' ? smooth : (smooth ? 0.3 : 0); - } - - function getAxisExtentWithGap(axis) { - var extent = axis.getGlobalExtent(); - if (axis.onBand) { - // Remove extra 1px to avoid line miter in clipped edge - var halfBandWidth = axis.getBandWidth() / 2 - 1; - var dir = extent[1] > extent[0] ? 1 : -1; - extent[0] += dir * halfBandWidth; - extent[1] -= dir * halfBandWidth; - } - return extent; - } - - function sign(val) { - return val >= 0 ? 1 : -1; - } - /** - * @param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys - * @param {module:echarts/data/List} data - * @param {Array.>} points - * @private - */ - function getStackedOnPoints(coordSys, data) { - var baseAxis = coordSys.getBaseAxis(); - var valueAxis = coordSys.getOtherAxis(baseAxis); - var valueStart = baseAxis.onZero - ? 0 : valueAxis.scale.getExtent()[0]; - - var valueDim = valueAxis.dim; - - var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0; - - return data.mapArray([valueDim], function (val, idx) { - var stackedOnSameSign; - var stackedOn = data.stackedOn; - // Find first stacked value with same sign - while (stackedOn && - sign(stackedOn.get(valueDim, idx)) === sign(val) - ) { - stackedOnSameSign = stackedOn; - break; - } - var stackedData = []; - stackedData[baseDataOffset] = data.get(baseAxis.dim, idx); - stackedData[1 - baseDataOffset] = stackedOnSameSign - ? stackedOnSameSign.get(valueDim, idx, true) : valueStart; - - return coordSys.dataToPoint(stackedData); - }, true); - } - - function queryDataIndex(data, payload) { - if (payload.dataIndex != null) { - return payload.dataIndex; - } - else if (payload.name != null) { - return data.indexOfName(payload.name); - } - } - - function createGridClipShape(cartesian, hasAnimation, seriesModel) { - var xExtent = getAxisExtentWithGap(cartesian.getAxis('x')); - var yExtent = getAxisExtentWithGap(cartesian.getAxis('y')); - var isHorizontal = cartesian.getBaseAxis().isHorizontal(); - - var x = xExtent[0]; - var y = yExtent[0]; - var width = xExtent[1] - x; - var height = yExtent[1] - y; - // Expand clip shape to avoid line value exceeds axis - if (!seriesModel.get('clipOverflow')) { - if (isHorizontal) { - y -= height; - height *= 3; - } - else { - x -= width; - width *= 3; - } - } - var clipPath = new graphic.Rect({ - shape: { - x: x, - y: y, - width: width, - height: height - } - }); - - if (hasAnimation) { - clipPath.shape[isHorizontal ? 'width' : 'height'] = 0; - graphic.initProps(clipPath, { - shape: { - width: width, - height: height - } - }, seriesModel); - } - - return clipPath; - } - - function createPolarClipShape(polar, hasAnimation, seriesModel) { - var angleAxis = polar.getAngleAxis(); - var radiusAxis = polar.getRadiusAxis(); - - var radiusExtent = radiusAxis.getExtent(); - var angleExtent = angleAxis.getExtent(); - - var RADIAN = Math.PI / 180; - - var clipPath = new graphic.Sector({ - shape: { - cx: polar.cx, - cy: polar.cy, - r0: radiusExtent[0], - r: radiusExtent[1], - startAngle: -angleExtent[0] * RADIAN, - endAngle: -angleExtent[1] * RADIAN, - clockwise: angleAxis.inverse - } - }); - - if (hasAnimation) { - clipPath.shape.endAngle = -angleExtent[0] * RADIAN; - graphic.initProps(clipPath, { - shape: { - endAngle: -angleExtent[1] * RADIAN - } - }, seriesModel); - } - - return clipPath; - } - - function createClipShape(coordSys, hasAnimation, seriesModel) { - return coordSys.type === 'polar' - ? createPolarClipShape(coordSys, hasAnimation, seriesModel) - : createGridClipShape(coordSys, hasAnimation, seriesModel); - } - - return ChartView.extend({ - - type: 'line', - - init: function () { - var lineGroup = new graphic.Group(); - - var symbolDraw = new SymbolDraw(); - this.group.add(symbolDraw.group); - - this._symbolDraw = symbolDraw; - this._lineGroup = lineGroup; - }, - - render: function (seriesModel, ecModel, api) { - var coordSys = seriesModel.coordinateSystem; - var group = this.group; - var data = seriesModel.getData(); - var lineStyleModel = seriesModel.getModel('lineStyle.normal'); - var areaStyleModel = seriesModel.getModel('areaStyle.normal'); - - var points = data.mapArray(data.getItemLayout, true); - - var isCoordSysPolar = coordSys.type === 'polar'; - var prevCoordSys = this._coordSys; - - var symbolDraw = this._symbolDraw; - var polyline = this._polyline; - var polygon = this._polygon; - - var lineGroup = this._lineGroup; - - var hasAnimation = seriesModel.get('animation'); - - var isAreaChart = !areaStyleModel.isEmpty(); - var stackedOnPoints = getStackedOnPoints(coordSys, data); - - var showSymbol = seriesModel.get('showSymbol'); - - var isSymbolIgnore = showSymbol && !isCoordSysPolar && !seriesModel.get('showAllSymbol') - && this._getSymbolIgnoreFunc(data, coordSys); - - // Remove temporary symbols - var oldData = this._data; - oldData && oldData.eachItemGraphicEl(function (el, idx) { - if (el.__temp) { - group.remove(el); - oldData.setItemGraphicEl(idx, null); - } - }); - - // Remove previous created symbols if showSymbol changed to false - if (!showSymbol) { - symbolDraw.remove(); - } - - group.add(lineGroup); - - // Initialization animation or coordinate system changed - if ( - !(polyline && prevCoordSys.type === coordSys.type) - ) { - showSymbol && symbolDraw.updateData(data, isSymbolIgnore); - - polyline = this._newPolyline(points, coordSys, hasAnimation); - if (isAreaChart) { - polygon = this._newPolygon( - points, stackedOnPoints, - coordSys, hasAnimation - ); - } - lineGroup.setClipPath(createClipShape(coordSys, true, seriesModel)); - } - else { - if (isAreaChart && !polygon) { - // If areaStyle is added - polygon = this._newPolygon( - points, stackedOnPoints, - coordSys, hasAnimation - ); - } - else if (polygon && !isAreaChart) { - // If areaStyle is removed - lineGroup.remove(polygon); - polygon = this._polygon = null; - } - - // Update clipPath - lineGroup.setClipPath(createClipShape(coordSys, false, seriesModel)); - - // Always update, or it is wrong in the case turning on legend - // because points are not changed - showSymbol && symbolDraw.updateData(data, isSymbolIgnore); - - // Stop symbol animation and sync with line points - // FIXME performance? - data.eachItemGraphicEl(function (el) { - el.stopAnimation(true); - }); - - // In the case data zoom triggerred refreshing frequently - // Data may not change if line has a category axis. So it should animate nothing - if (!isPointsSame(this._stackedOnPoints, stackedOnPoints) - || !isPointsSame(this._points, points) - ) { - if (hasAnimation) { - this._updateAnimation( - data, stackedOnPoints, coordSys, api - ); - } - else { - polyline.setShape({ - points: points - }); - polygon && polygon.setShape({ - points: points, - stackedOnPoints: stackedOnPoints - }); - } - } - } - - polyline.setStyle(zrUtil.defaults( - // Use color in lineStyle first - lineStyleModel.getLineStyle(), - { - stroke: data.getVisual('color'), - lineJoin: 'bevel' - } - )); - - var smooth = seriesModel.get('smooth'); - smooth = getSmooth(seriesModel.get('smooth')); - polyline.setShape({ - smooth: smooth, - smoothMonotone: seriesModel.get('smoothMonotone') - }); - - if (polygon) { - var stackedOn = data.stackedOn; - var stackedOnSmooth = 0; - - polygon.style.opacity = 0.7; - polygon.setStyle(zrUtil.defaults( - areaStyleModel.getAreaStyle(), - { - fill: data.getVisual('color'), - lineJoin: 'bevel' - } - )); - - if (stackedOn) { - var stackedOnSeries = stackedOn.hostModel; - stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth')); - } - - polygon.setShape({ - smooth: smooth, - stackedOnSmooth: stackedOnSmooth, - smoothMonotone: seriesModel.get('smoothMonotone') - }); - } - - this._data = data; - // Save the coordinate system for transition animation when data changed - this._coordSys = coordSys; - this._stackedOnPoints = stackedOnPoints; - this._points = points; - }, - - highlight: function (seriesModel, ecModel, api, payload) { - var data = seriesModel.getData(); - var dataIndex = queryDataIndex(data, payload); - - if (dataIndex != null && dataIndex >= 0) { - var symbol = data.getItemGraphicEl(dataIndex); - if (!symbol) { - // Create a temporary symbol if it is not exists - var pt = data.getItemLayout(dataIndex); - symbol = new Symbol(data, dataIndex, api); - symbol.position = pt; - symbol.setZ( - seriesModel.get('zlevel'), - seriesModel.get('z') - ); - symbol.ignore = isNaN(pt[0]) || isNaN(pt[1]); - symbol.__temp = true; - data.setItemGraphicEl(dataIndex, symbol); - - // Stop scale animation - symbol.stopSymbolAnimation(true); - - this.group.add(symbol); - } - symbol.highlight(); - } - else { - // Highlight whole series - ChartView.prototype.highlight.call( - this, seriesModel, ecModel, api, payload - ); - } - }, - - downplay: function (seriesModel, ecModel, api, payload) { - var data = seriesModel.getData(); - var dataIndex = queryDataIndex(data, payload); - if (dataIndex != null && dataIndex >= 0) { - var symbol = data.getItemGraphicEl(dataIndex); - if (symbol) { - if (symbol.__temp) { - data.setItemGraphicEl(dataIndex, null); - this.group.remove(symbol); - } - else { - symbol.downplay(); - } - } - } - else { - // Downplay whole series - ChartView.prototype.downplay.call( - this, seriesModel, ecModel, api, payload - ); - } - }, - - /** - * @param {module:zrender/container/Group} group - * @param {Array.>} points - * @private - */ - _newPolyline: function (points) { - var polyline = this._polyline; - // Remove previous created polyline - if (polyline) { - this._lineGroup.remove(polyline); - } - - polyline = new polyHelper.Polyline({ - shape: { - points: points - }, - silent: true, - z2: 10 - }); - - this._lineGroup.add(polyline); - - this._polyline = polyline; - - return polyline; - }, - - /** - * @param {module:zrender/container/Group} group - * @param {Array.>} stackedOnPoints - * @param {Array.>} points - * @private - */ - _newPolygon: function (points, stackedOnPoints) { - var polygon = this._polygon; - // Remove previous created polygon - if (polygon) { - this._lineGroup.remove(polygon); - } - - polygon = new polyHelper.Polygon({ - shape: { - points: points, - stackedOnPoints: stackedOnPoints - }, - silent: true - }); - - this._lineGroup.add(polygon); - - this._polygon = polygon; - return polygon; - }, - /** - * @private - */ - _getSymbolIgnoreFunc: function (data, coordSys) { - var categoryAxis = coordSys.getAxesByScale('ordinal')[0]; - // `getLabelInterval` is provided by echarts/component/axis - if (categoryAxis && categoryAxis.isLabelIgnored) { - return zrUtil.bind(categoryAxis.isLabelIgnored, categoryAxis); - } - }, - - /** - * @private - */ - // FIXME Two value axis - _updateAnimation: function (data, stackedOnPoints, coordSys, api) { - var polyline = this._polyline; - var polygon = this._polygon; - var seriesModel = data.hostModel; - - var diff = lineAnimationDiff( - this._data, data, - this._stackedOnPoints, stackedOnPoints, - this._coordSys, coordSys - ); - polyline.shape.points = diff.current; - - graphic.updateProps(polyline, { - shape: { - points: diff.next - } - }, seriesModel); - - if (polygon) { - polygon.setShape({ - points: diff.current, - stackedOnPoints: diff.stackedOnCurrent - }); - graphic.updateProps(polygon, { - shape: { - points: diff.next, - stackedOnPoints: diff.stackedOnNext - } - }, seriesModel); - } - - var updatedDataInfo = []; - var diffStatus = diff.status; - - for (var i = 0; i < diffStatus.length; i++) { - var cmd = diffStatus[i].cmd; - if (cmd === '=') { - var el = data.getItemGraphicEl(diffStatus[i].idx1); - if (el) { - updatedDataInfo.push({ - el: el, - ptIdx: i // Index of points - }); - } - } - } - - if (polyline.animators && polyline.animators.length) { - polyline.animators[0].during(function () { - for (var i = 0; i < updatedDataInfo.length; i++) { - var el = updatedDataInfo[i].el; - el.attr('position', polyline.shape.points[updatedDataInfo[i].ptIdx]); - } - }); - } - }, - - remove: function (ecModel) { - this._lineGroup.removeAll(); - this._symbolDraw.remove(true); - - this._polyline = - this._polygon = - this._coordSys = - this._points = - this._stackedOnPoints = - this._data = null; - } - }); -}); -define('echarts/visual/symbol',['require'],function (require) { - - return function (seriesType, defaultSymbolType, legendSymbol, ecModel, api) { - - // Encoding visual for all series include which is filtered for legend drawing - ecModel.eachRawSeriesByType(seriesType, function (seriesModel) { - var data = seriesModel.getData(); - - var symbolType = seriesModel.get('symbol') || defaultSymbolType; - var symbolSize = seriesModel.get('symbolSize'); - - data.setVisual({ - legendSymbol: legendSymbol || symbolType, - symbol: symbolType, - symbolSize: symbolSize - }); - - // Only visible series has each data be visual encoded - if (!ecModel.isSeriesFiltered(seriesModel)) { - if (typeof symbolSize === 'function') { - data.each(function (idx) { - var rawValue = seriesModel.getRawValue(idx); - // FIXME - var params = seriesModel.getDataParams(idx); - data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params)); - }); - } - data.each(function (idx) { - var itemModel = data.getItemModel(idx); - var itemSymbolType = itemModel.get('symbol', true); - var itemSymbolSize = itemModel.get('symbolSize', true); - // If has item symbol - if (itemSymbolType != null) { - data.setItemVisual(idx, 'symbol', itemSymbolType); - } - if (itemSymbolSize != null) { - // PENDING Transform symbolSize ? - data.setItemVisual(idx, 'symbolSize', itemSymbolSize); - } - }); - } - }); - }; -}); -define('echarts/layout/points',['require'],function (require) { - - return function (seriesType, ecModel, api) { - ecModel.eachSeriesByType(seriesType, function (seriesModel) { - var data = seriesModel.getData(); - var coordSys = seriesModel.coordinateSystem; - - var dims = coordSys.dimensions; - data.each(dims, function (x, y, idx) { - var point; - if (!isNaN(x) && !isNaN(y)) { - point = coordSys.dataToPoint([x, y]); - } - else { - // Also {Array.}, not undefined to avoid if...else... statement - point = [NaN, NaN]; - } - - data.setItemLayout(idx, point); - }, true); - }); - }; -}); -define('echarts/processor/dataSample',[],function () { - var samplers = { - average: function (frame) { - var sum = 0; - var count = 0; - for (var i = 0; i < frame.length; i++) { - if (!isNaN(frame[i])) { - sum += frame[i]; - count++; - } - } - // Return NaN if count is 0 - return count === 0 ? NaN : sum / count; - }, - sum: function (frame) { - var sum = 0; - for (var i = 0; i < frame.length; i++) { - // Ignore NaN - sum += frame[i] || 0; - } - return sum; - }, - max: function (frame) { - var max = -Infinity; - for (var i = 0; i < frame.length; i++) { - frame[i] > max && (max = frame[i]); - } - return max; - }, - min: function (frame) { - var min = Infinity; - for (var i = 0; i < frame.length; i++) { - frame[i] < min && (min = frame[i]); - } - return min; - } - }; - - var indexSampler = function (frame, value) { - return Math.round(frame.length / 2); - }; - return function (seriesType, ecModel, api) { - ecModel.eachSeriesByType(seriesType, function (seriesModel) { - var data = seriesModel.getData(); - var sampling = seriesModel.get('sampling'); - var coordSys = seriesModel.coordinateSystem; - // Only cartesian2d support down sampling - if (coordSys.type === 'cartesian2d' && sampling) { - var baseAxis = coordSys.getBaseAxis(); - var valueAxis = coordSys.getOtherAxis(baseAxis); - var extent = baseAxis.getExtent(); - // Coordinste system has been resized - var size = extent[1] - extent[0]; - var rate = Math.round(data.count() / size); - if (rate > 1) { - var sampler; - if (typeof sampling === 'string') { - sampler = samplers[sampling]; - } - else if (typeof sampling === 'function') { - sampler = sampling; - } - if (sampler) { - data = data.downSample( - valueAxis.dim, 1 / rate, sampler, indexSampler - ); - seriesModel.setData(data); - } - } - } - }, this); - }; -}); -define('echarts/chart/line',['require','zrender/core/util','../echarts','./line/LineSeries','./line/LineView','../visual/symbol','../layout/points','../processor/dataSample'],function (require) { + // Inject the coordinateSystems into seriesModel + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.get('coordinateSystem') === 'parallel') { + var parallelIndex = seriesModel.get('parallelIndex'); + seriesModel.coordinateSystem = coordSysList[parallelIndex]; + } + }); - var zrUtil = require('zrender/core/util'); - var echarts = require('../echarts'); + return coordSysList; + } - require('./line/LineSeries'); - require('./line/LineView'); + __webpack_require__(25).register('parallel', {create: create}); - echarts.registerVisualCoding('chart', zrUtil.curry( - require('../visual/symbol'), 'line', 'circle', 'line' - )); - echarts.registerLayout(zrUtil.curry( - require('../layout/points'), 'line' - )); - // Down sample after filter - echarts.registerProcessor('statistic', zrUtil.curry( - require('../processor/dataSample'), 'line' - )); -}); -/** - * // Scale class management - * @module echarts/scale/Scale - */ -define('echarts/scale/Scale',['require','../util/clazz'],function (require) { - - var clazzUtil = require('../util/clazz'); - - function Scale() { - /** - * Extent - * @type {Array.} - * @protected - */ - this._extent = [Infinity, -Infinity]; - - /** - * Step is calculated in adjustExtent - * @type {Array.} - * @protected - */ - this._interval = 0; - - this.init && this.init.apply(this, arguments); - } - - var scaleProto = Scale.prototype; - - /** - * Parse input val to valid inner number. - * @param {*} val - * @return {number} - */ - scaleProto.parse = function (val) { - // Notice: This would be a trap here, If the implementation - // of this method depends on extent, and this method is used - // before extent set (like in dataZoom), it would be wrong. - // Nevertheless, parse does not depend on extent generally. - return val; - }; - - scaleProto.contain = function (val) { - var extent = this._extent; - return val >= extent[0] && val <= extent[1]; - }; - - /** - * Normalize value to linear [0, 1], return 0.5 if extent span is 0 - * @param {number} val - * @return {number} - */ - scaleProto.normalize = function (val) { - var extent = this._extent; - if (extent[1] === extent[0]) { - return 0.5; - } - return (val - extent[0]) / (extent[1] - extent[0]); - }; - - /** - * Scale normalized value - * @param {number} val - * @return {number} - */ - scaleProto.scale = function (val) { - var extent = this._extent; - return val * (extent[1] - extent[0]) + extent[0]; - }; - - /** - * Set extent from data - * @param {Array.} other - */ - scaleProto.unionExtent = function (other) { - var extent = this._extent; - other[0] < extent[0] && (extent[0] = other[0]); - other[1] > extent[1] && (extent[1] = other[1]); - // not setExtent because in log axis it may transformed to power - // this.setExtent(extent[0], extent[1]); - }; - - /** - * Get extent - * @return {Array.} - */ - scaleProto.getExtent = function () { - return this._extent.slice(); - }; - - /** - * Set extent - * @param {number} start - * @param {number} end - */ - scaleProto.setExtent = function (start, end) { - var thisExtent = this._extent; - if (!isNaN(start)) { - thisExtent[0] = start; - } - if (!isNaN(end)) { - thisExtent[1] = end; - } - }; - - /** - * @return {Array.} - */ - scaleProto.getTicksLabels = function () { - var labels = []; - var ticks = this.getTicks(); - for (var i = 0; i < ticks.length; i++) { - labels.push(this.getLabel(ticks[i])); - } - return labels; - }; - - clazzUtil.enableClassExtend(Scale); - clazzUtil.enableClassManagement(Scale, { - registerWhenExtend: true - }); - - return Scale; -}); -/** - * Linear continuous scale - * @module echarts/coord/scale/Ordinal - * - * http://en.wikipedia.org/wiki/Level_of_measurement - */ - -// FIXME only one data -define('echarts/scale/Ordinal',['require','zrender/core/util','./Scale'],function (require) { - - var zrUtil = require('zrender/core/util'); - var Scale = require('./Scale'); - - var scaleProto = Scale.prototype; - - var OrdinalScale = Scale.extend({ - - type: 'ordinal', - - init: function (data, extent) { - this._data = data; - this._extent = extent || [0, data.length - 1]; - }, - - parse: function (val) { - return typeof val === 'string' - ? zrUtil.indexOf(this._data, val) - // val might be float. - : Math.round(val); - }, - - contain: function (rank) { - rank = this.parse(rank); - return scaleProto.contain.call(this, rank) - && this._data[rank] != null; - }, - - /** - * Normalize given rank or name to linear [0, 1] - * @param {number|string} [val] - * @return {number} - */ - normalize: function (val) { - return scaleProto.normalize.call(this, this.parse(val)); - }, - - scale: function (val) { - return Math.round(scaleProto.scale.call(this, val)); - }, - - /** - * @return {Array} - */ - getTicks: function () { - var ticks = []; - var extent = this._extent; - var rank = extent[0]; - - while (rank <= extent[1]) { - ticks.push(rank); - rank++; - } - - return ticks; - }, - - /** - * Get item on rank n - * @param {number} n - * @return {string} - */ - getLabel: function (n) { - return this._data[n]; - }, - - /** - * @return {number} - */ - count: function () { - return this._extent[1] - this._extent[0] + 1; - }, - - niceTicks: zrUtil.noop, - niceExtent: zrUtil.noop - }); - - /** - * @return {module:echarts/scale/Time} - */ - OrdinalScale.create = function () { - return new OrdinalScale(); - }; - - return OrdinalScale; -}); -/** - * Interval scale - * @module echarts/scale/Interval - */ - -define('echarts/scale/Interval',['require','../util/number','../util/format','./Scale'],function (require) { - - var numberUtil = require('../util/number'); - var formatUtil = require('../util/format'); - var Scale = require('./Scale'); - - var mathFloor = Math.floor; - var mathCeil = Math.ceil; - /** - * @alias module:echarts/coord/scale/Interval - * @constructor - */ - var IntervalScale = Scale.extend({ - - type: 'interval', - - _interval: 0, - - setExtent: function (start, end) { - var thisExtent = this._extent; - //start,end may be a Number like '25',so... - if (!isNaN(start)) { - thisExtent[0] = parseFloat(start); - } - if (!isNaN(end)) { - thisExtent[1] = parseFloat(end); - } - }, - - unionExtent: function (other) { - var extent = this._extent; - other[0] < extent[0] && (extent[0] = other[0]); - other[1] > extent[1] && (extent[1] = other[1]); - - // unionExtent may called by it's sub classes - IntervalScale.prototype.setExtent.call(this, extent[0], extent[1]); - }, - /** - * Get interval - */ - getInterval: function () { - if (!this._interval) { - this.niceTicks(); - } - return this._interval; - }, - - /** - * Set interval - */ - setInterval: function (interval) { - this._interval = interval; - // Dropped auto calculated niceExtent and use user setted extent - // We assume user wan't to set both interval, min, max to get a better result - this._niceExtent = this._extent.slice(); - }, - - /** - * @return {Array.} - */ - getTicks: function () { - if (!this._interval) { - this.niceTicks(); - } - var interval = this._interval; - var extent = this._extent; - var ticks = []; - - // Consider this case: using dataZoom toolbox, zoom and zoom. - var safeLimit = 10000; - - if (interval) { - var niceExtent = this._niceExtent; - if (extent[0] < niceExtent[0]) { - ticks.push(extent[0]); - } - var tick = niceExtent[0]; - while (tick <= niceExtent[1]) { - ticks.push(tick); - // Avoid rounding error - tick = numberUtil.round(tick + interval); - if (ticks.length > safeLimit) { - return []; - } - } - if (extent[1] > niceExtent[1]) { - ticks.push(extent[1]); - } - } - - return ticks; - }, - - /** - * @return {Array.} - */ - getTicksLabels: function () { - var labels = []; - var ticks = this.getTicks(); - for (var i = 0; i < ticks.length; i++) { - labels.push(this.getLabel(ticks[i])); - } - return labels; - }, - - /** - * @param {number} n - * @return {number} - */ - getLabel: function (data) { - return formatUtil.addCommas(data); - }, - - /** - * Update interval and extent of intervals for nice ticks - * Algorithm from d3.js - * @param {number} [approxTickNum = 10] Given approx tick number - */ - niceTicks: function (approxTickNum) { - approxTickNum = approxTickNum || 10; - var extent = this._extent; - var span = extent[1] - extent[0]; - if (span === Infinity || span <= 0) { - return; - } - - // Figure out step quantity, for example 0.1, 1, 10, 100 - var interval = Math.pow(10, Math.floor(Math.log(span / approxTickNum) / Math.LN10)); - var err = approxTickNum / span * interval; - - // Filter ticks to get closer to the desired count. - if (err <= 0.15) { - interval *= 10; - } - else if (err <= 0.3) { - interval *= 5; - } - else if (err <= 0.45) { - interval *= 3; - } - else if (err <= 0.75) { - interval *= 2; - } - - var niceExtent = [ - numberUtil.round(mathCeil(extent[0] / interval) * interval), - numberUtil.round(mathFloor(extent[1] / interval) * interval) - ]; - - this._interval = interval; - this._niceExtent = niceExtent; - }, - - /** - * Nice extent. - * @param {number} [approxTickNum = 10] Given approx tick number - * @param {boolean} [fixMin=false] - * @param {boolean} [fixMax=false] - */ - niceExtent: function (approxTickNum, fixMin, fixMax) { - var extent = this._extent; - // If extent start and end are same, expand them - if (extent[0] === extent[1]) { - if (extent[0] !== 0) { - // Expand extent - var expandSize = extent[0] / 2; - extent[0] -= expandSize; - extent[1] += expandSize; - } - else { - extent[1] = 1; - } - } - // If there are no data and extent are [Infinity, -Infinity] - if (extent[1] === -Infinity && extent[0] === Infinity) { - extent[0] = 0; - extent[1] = 1; - } - - this.niceTicks(approxTickNum, fixMin, fixMax); - - // var extent = this._extent; - var interval = this._interval; - - if (!fixMin) { - extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval); - } - if (!fixMax) { - extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval); - } - } - }); - - /** - * @return {module:echarts/scale/Time} - */ - IntervalScale.create = function () { - return new IntervalScale(); - }; - - return IntervalScale; -}); -/** - * Interval scale - * @module echarts/coord/scale/Time - */ - -define('echarts/scale/Time',['require','zrender/core/util','../util/number','../util/format','./Interval'],function (require) { - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../util/number'); - var formatUtil = require('../util/format'); - - var IntervalScale = require('./Interval'); - - var intervalScaleProto = IntervalScale.prototype; - - var mathCeil = Math.ceil; - var mathFloor = Math.floor; - var ONE_DAY = 3600000 * 24; - - // FIXME 公用? - var bisect = function (a, x, lo, hi) { - while (lo < hi) { - var mid = lo + hi >>> 1; - if (a[mid][2] < x) { - lo = mid + 1; - } - else { - hi = mid; - } - } - return lo; - }; - - /** - * @alias module:echarts/coord/scale/Time - * @constructor - */ - var TimeScale = IntervalScale.extend({ - type: 'time', - - // Overwrite - getLabel: function (val) { - var stepLvl = this._stepLvl; - - var date = new Date(val); - - return formatUtil.formatTime(stepLvl[0], date); - }, - - // Overwrite - niceExtent: function (approxTickNum, fixMin, fixMax) { - var extent = this._extent; - // If extent start and end are same, expand them - if (extent[0] === extent[1]) { - // Expand extent - extent[0] -= ONE_DAY; - extent[1] += ONE_DAY; - } - // If there are no data and extent are [Infinity, -Infinity] - if (extent[1] === -Infinity && extent[0] === Infinity) { - var d = new Date(); - extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate()); - extent[0] = extent[1] - ONE_DAY; - } - - this.niceTicks(approxTickNum, fixMin, fixMax); - - // var extent = this._extent; - var interval = this._interval; - - if (!fixMin) { - extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval); - } - if (!fixMax) { - extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval); - } - }, - - // Overwrite - niceTicks: function (approxTickNum) { - approxTickNum = approxTickNum || 10; - - var extent = this._extent; - var span = extent[1] - extent[0]; - var approxInterval = span / approxTickNum; - var scaleLevelsLen = scaleLevels.length; - var idx = bisect(scaleLevels, approxInterval, 0, scaleLevelsLen); - - var level = scaleLevels[Math.min(idx, scaleLevelsLen - 1)]; - var interval = level[2]; - // Same with interval scale if span is much larger than 1 year - if (level[0] === 'year') { - var year = span / interval; - var yearInterval = Math.pow(10, Math.floor(Math.log(year / approxTickNum) / Math.LN10)); - var err = approxTickNum / year * yearInterval; - // Filter ticks to get closer to the desired count. - if (err <= 0.15) { - yearInterval *= 10; - } - else if (err <= 0.3) { - yearInterval *= 5; - } - else if (err <= 0.75) { - yearInterval *= 2; - } - interval *= yearInterval; - } - - var niceExtent = [ - mathCeil(extent[0] / interval) * interval, - mathFloor(extent[1] / interval) * interval - ]; - - this._stepLvl = level; - // Interval will be used in getTicks - this._interval = interval; - this._niceExtent = niceExtent; - }, - - parse: function (val) { - // val might be float. - return +numberUtil.parseDate(val); - } - }); - - zrUtil.each(['contain', 'normalize'], function (methodName) { - TimeScale.prototype[methodName] = function (val) { - return intervalScaleProto[methodName].call(this, this.parse(val)); - }; - }); - - // Steps from d3 - var scaleLevels = [ - // Format step interval - ['hh:mm:ss', 1, 1000], // 1s - ['hh:mm:ss', 5, 1000 * 5], // 5s - ['hh:mm:ss', 10, 1000 * 10], // 10s - ['hh:mm:ss', 15, 1000 * 15], // 15s - ['hh:mm:ss', 30, 1000 * 30], // 30s - ['hh:mm\nMM-dd',1, 60000], // 1m - ['hh:mm\nMM-dd',5, 60000 * 5], // 5m - ['hh:mm\nMM-dd',10, 60000 * 10], // 10m - ['hh:mm\nMM-dd',15, 60000 * 15], // 15m - ['hh:mm\nMM-dd',30, 60000 * 30], // 30m - ['hh:mm\nMM-dd',1, 3600000], // 1h - ['hh:mm\nMM-dd',2, 3600000 * 2], // 2h - ['hh:mm\nMM-dd',6, 3600000 * 6], // 6h - ['hh:mm\nMM-dd',12, 3600000 * 12], // 12h - ['MM-dd\nyyyy', 1, ONE_DAY], // 1d - ['week', 7, ONE_DAY * 7], // 7d - ['month', 1, ONE_DAY * 31], // 1M - ['quarter', 3, ONE_DAY * 380 / 4], // 3M - ['half-year', 6, ONE_DAY * 380 / 2], // 6M - ['year', 1, ONE_DAY * 380] // 1Y - ]; - - /** - * @return {module:echarts/scale/Time} - */ - TimeScale.create = function () { - return new TimeScale(); - }; - - return TimeScale; -}); -/** - * Log scale - * @module echarts/scale/Log - */ -define('echarts/scale/Log',['require','zrender/core/util','./Scale','../util/number','./Interval'],function (require) { - - var zrUtil = require('zrender/core/util'); - var Scale = require('./Scale'); - var numberUtil = require('../util/number'); - - // Use some method of IntervalScale - var IntervalScale = require('./Interval'); - - var scaleProto = Scale.prototype; - var intervalScaleProto = IntervalScale.prototype; - - var mathFloor = Math.floor; - var mathCeil = Math.ceil; - var mathPow = Math.pow; - - var LOG_BASE = 10; - var mathLog = Math.log; - - var LogScale = Scale.extend({ - - type: 'log', - - /** - * @return {Array.} - */ - getTicks: function () { - return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) { - return numberUtil.round(mathPow(LOG_BASE, val)); - }); - }, - - /** - * @param {number} val - * @return {string} - */ - getLabel: intervalScaleProto.getLabel, - - /** - * @param {number} val - * @return {number} - */ - scale: function (val) { - val = scaleProto.scale.call(this, val); - return mathPow(LOG_BASE, val); - }, - - /** - * @param {number} start - * @param {number} end - */ - setExtent: function (start, end) { - start = mathLog(start) / mathLog(LOG_BASE); - end = mathLog(end) / mathLog(LOG_BASE); - intervalScaleProto.setExtent.call(this, start, end); - }, - - /** - * @return {number} end - */ - getExtent: function () { - var extent = scaleProto.getExtent.call(this); - extent[0] = mathPow(LOG_BASE, extent[0]); - extent[1] = mathPow(LOG_BASE, extent[1]); - return extent; - }, - - /** - * @param {Array.} extent - */ - unionExtent: function (extent) { - extent[0] = mathLog(extent[0]) / mathLog(LOG_BASE); - extent[1] = mathLog(extent[1]) / mathLog(LOG_BASE); - scaleProto.unionExtent.call(this, extent); - }, - - /** - * Update interval and extent of intervals for nice ticks - * @param {number} [approxTickNum = 10] Given approx tick number - */ - niceTicks: function (approxTickNum) { - approxTickNum = approxTickNum || 10; - var extent = this._extent; - var span = extent[1] - extent[0]; - if (span === Infinity || span <= 0) { - return; - } - - var interval = mathPow(10, mathFloor(mathLog(span / approxTickNum) / Math.LN10)); - var err = approxTickNum / span * interval; - - // Filter ticks to get closer to the desired count. - if (err <= 0.5) { - interval *= 10; - } - var niceExtent = [ - numberUtil.round(mathCeil(extent[0] / interval) * interval), - numberUtil.round(mathFloor(extent[1] / interval) * interval) - ]; - - this._interval = interval; - this._niceExtent = niceExtent; - }, - - /** - * Nice extent. - * @param {number} [approxTickNum = 10] Given approx tick number - * @param {boolean} [fixMin=false] - * @param {boolean} [fixMax=false] - */ - niceExtent: intervalScaleProto.niceExtent - }); - - zrUtil.each(['contain', 'normalize'], function (methodName) { - LogScale.prototype[methodName] = function (val) { - val = mathLog(val) / mathLog(LOG_BASE); - return scaleProto[methodName].call(this, val); - }; - }); - - LogScale.create = function () { - return new LogScale(); - }; - - return LogScale; -}); -define('echarts/coord/axisHelper',['require','../scale/Ordinal','../scale/Interval','../scale/Time','../scale/Log','../scale/Scale','../util/number','zrender/core/util','zrender/contain/text'],function (require) { - - var OrdinalScale = require('../scale/Ordinal'); - var IntervalScale = require('../scale/Interval'); - require('../scale/Time'); - require('../scale/Log'); - var Scale = require('../scale/Scale'); - - var numberUtil = require('../util/number'); - var zrUtil = require('zrender/core/util'); - var textContain = require('zrender/contain/text'); - var axisHelper = {}; - - axisHelper.niceScaleExtent = function (axis, model) { - var scale = axis.scale; - var originalExtent = scale.getExtent(); - var span = originalExtent[1] - originalExtent[0]; - if (scale.type === 'ordinal') { - // If series has no data, scale extent may be wrong - if (!isFinite(span)) { - scale.setExtent(0, 0); - } - return; - } - var min = model.get('min'); - var max = model.get('max'); - var crossZero = !model.get('scale'); - var boundaryGap = model.get('boundaryGap'); - if (!zrUtil.isArray(boundaryGap)) { - boundaryGap = [boundaryGap || 0, boundaryGap || 0]; - } - boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], 1); - boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], 1); - var fixMin = true; - var fixMax = true; - // Add boundary gap - if (min == null) { - min = originalExtent[0] - boundaryGap[0] * span; - fixMin = false; - } - if (max == null) { - max = originalExtent[1] + boundaryGap[1] * span; - fixMax = false; - } - // TODO Only one data - if (min === 'dataMin') { - min = originalExtent[0]; - } - if (max === 'dataMax') { - max = originalExtent[1]; - } - // Evaluate if axis needs cross zero - if (crossZero) { - // Axis is over zero and min is not set - if (min > 0 && max > 0 && !fixMin) { - min = 0; - } - // Axis is under zero and max is not set - if (min < 0 && max < 0 && !fixMax) { - max = 0; - } - } - scale.setExtent(min, max); - scale.niceExtent(model.get('splitNumber'), fixMin, fixMax); - - // If some one specified the min, max. And the default calculated interval - // is not good enough. He can specify the interval. It is often appeared - // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard - // to be 60. - // FIXME - var interval = model.get('interval'); - if (interval != null) { - scale.setInterval && scale.setInterval(interval); - } - }; - - /** - * @param {module:echarts/model/Model} model - * @param {string} [axisType] Default retrieve from model.type - * @return {module:echarts/scale/*} - */ - axisHelper.createScaleByModel = function(model, axisType) { - axisType = axisType || model.get('type'); - if (axisType) { - switch (axisType) { - // Buildin scale - case 'category': - return new OrdinalScale( - model.getCategories(), [Infinity, -Infinity] - ); - case 'value': - return new IntervalScale(); - // Extended scale, like time and log - default: - return (Scale.getClass(axisType) || IntervalScale).create(model); - } - } - }; - - /** - * Check if the axis corss 0 - */ - axisHelper.ifAxisCrossZero = function (axis) { - var dataExtent = axis.scale.getExtent(); - var min = dataExtent[0]; - var max = dataExtent[1]; - return !((min > 0 && max > 0) || (min < 0 && max < 0)); - }; - - /** - * @param {Array.} tickCoords In axis self coordinate. - * @param {Array.} labels - * @param {string} font - * @param {boolean} isAxisHorizontal - * @return {number} - */ - axisHelper.getAxisLabelInterval = function (tickCoords, labels, font, isAxisHorizontal) { - // FIXME - // 不同角的axis和label,不只是horizontal和vertical. - - var textSpaceTakenRect; - var autoLabelInterval = 0; - var accumulatedLabelInterval = 0; - - var step = 1; - if (labels.length > 40) { - // Simple optimization for large amount of labels - step = Math.round(labels.length / 40); - } - for (var i = 0; i < tickCoords.length; i += step) { - var tickCoord = tickCoords[i]; - var rect = textContain.getBoundingRect( - labels[i], font, 'center', 'top' - ); - rect[isAxisHorizontal ? 'x' : 'y'] += tickCoord; - rect[isAxisHorizontal ? 'width' : 'height'] *= 1.5; - if (!textSpaceTakenRect) { - textSpaceTakenRect = rect.clone(); - } - // There is no space for current label; - else if (textSpaceTakenRect.intersect(rect)) { - accumulatedLabelInterval++; - autoLabelInterval = Math.max(autoLabelInterval, accumulatedLabelInterval); - } - else { - textSpaceTakenRect.union(rect); - // Reset - accumulatedLabelInterval = 0; - } - } - if (autoLabelInterval === 0 && step > 1) { - return step; - } - return autoLabelInterval * step; - }; - - /** - * @param {Object} axis - * @param {Function} labelFormatter - * @return {Array.} - */ - axisHelper.getFormattedLabels = function (axis, labelFormatter) { - var scale = axis.scale; - var labels = scale.getTicksLabels(); - var ticks = scale.getTicks(); - if (typeof labelFormatter === 'string') { - labelFormatter = (function (tpl) { - return function (val) { - return tpl.replace('{value}', val); - }; - })(labelFormatter); - return zrUtil.map(labels, labelFormatter); - } - else if (typeof labelFormatter === 'function') { - return zrUtil.map(ticks, function (tick, idx) { - return labelFormatter( - axis.type === 'category' ? scale.getLabel(tick) : tick, - idx - ); - }, this); - } - else { - return labels; - } - }; - - return axisHelper; -}); -/** - * Cartesian coordinate system - * @module echarts/coord/Cartesian - * - */ -define('echarts/coord/cartesian/Cartesian',['require','zrender/core/util'],function (require) { - - - - var zrUtil = require('zrender/core/util'); - - function dimAxisMapper(dim) { - return this._axes[dim]; - } - - /** - * @alias module:echarts/coord/Cartesian - * @constructor - */ - var Cartesian = function (name) { - this._axes = {}; - - this._dimList = []; - - /** - * @type {string} - */ - this.name = name || ''; - }; - - Cartesian.prototype = { - - constructor: Cartesian, - - type: 'cartesian', - - /** - * Get axis - * @param {number|string} dim - * @return {module:echarts/coord/Cartesian~Axis} - */ - getAxis: function (dim) { - return this._axes[dim]; - }, - - /** - * Get axes list - * @return {Array.} - */ - getAxes: function () { - return zrUtil.map(this._dimList, dimAxisMapper, this); - }, - - /** - * Get axes list by given scale type - */ - getAxesByScale: function (scaleType) { - scaleType = scaleType.toLowerCase(); - return zrUtil.filter( - this.getAxes(), - function (axis) { - return axis.scale.type === scaleType; - } - ); - }, - - /** - * Add axis - * @param {module:echarts/coord/Cartesian.Axis} - */ - addAxis: function (axis) { - var dim = axis.dim; - - this._axes[dim] = axis; - - this._dimList.push(dim); - }, - - /** - * Convert data to coord in nd space - * @param {Array.|Object.} val - * @return {Array.|Object.} - */ - dataToCoord: function (val) { - return this._dataCoordConvert(val, 'dataToCoord'); - }, - - /** - * Convert coord in nd space to data - * @param {Array.|Object.} val - * @return {Array.|Object.} - */ - coordToData: function (val) { - return this._dataCoordConvert(val, 'coordToData'); - }, - - _dataCoordConvert: function (input, method) { - var dimList = this._dimList; - - var output = input instanceof Array ? [] : {}; - - for (var i = 0; i < dimList.length; i++) { - var dim = dimList[i]; - var axis = this._axes[dim]; - - output[dim] = axis[method](input[dim]); - } - - return output; - } - }; - - return Cartesian; -}); -define('echarts/coord/cartesian/Cartesian2D',['require','zrender/core/util','./Cartesian'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var Cartesian = require('./Cartesian'); - - function Cartesian2D(name) { - - Cartesian.call(this, name); - } - - Cartesian2D.prototype = { - - constructor: Cartesian2D, - - type: 'cartesian2d', - - /** - * @type {Array.} - * @readOnly - */ - dimensions: ['x', 'y'], - - /** - * Base axis will be used on stacking. - * - * @return {module:echarts/coord/cartesian/Axis2D} - */ - getBaseAxis: function () { - return this.getAxesByScale('ordinal')[0] - || this.getAxesByScale('time')[0] - || this.getAxis('x'); - }, - - /** - * If contain point - * @param {Array.} point - * @return {boolean} - */ - containPoint: function (point) { - var axisX = this.getAxis('x'); - var axisY = this.getAxis('y'); - return axisX.contain(axisX.toLocalCoord(point[0])) - && axisY.contain(axisY.toLocalCoord(point[1])); - }, - - /** - * If contain data - * @param {Array.} data - * @return {boolean} - */ - containData: function (data) { - return this.getAxis('x').containData(data[0]) - && this.getAxis('y').containData(data[1]); - }, - - /** - * Convert series data to an array of points - * @param {module:echarts/data/List} data - * @param {boolean} stack - * @return {Array} - * Return array of points. For example: - * `[[10, 10], [20, 20], [30, 30]]` - */ - dataToPoints: function (data, stack) { - return data.mapArray(['x', 'y'], function (x, y) { - return this.dataToPoint([x, y]); - }, stack, this); - }, - - /** - * @param {Array.} data - * @param {boolean} [clamp=false] - * @return {Array.} - */ - dataToPoint: function (data, clamp) { - var xAxis = this.getAxis('x'); - var yAxis = this.getAxis('y'); - return [ - xAxis.toGlobalCoord(xAxis.dataToCoord(data[0], clamp)), - yAxis.toGlobalCoord(yAxis.dataToCoord(data[1], clamp)) - ]; - }, - - /** - * @param {Array.} point - * @param {boolean} [clamp=false] - * @return {Array.} - */ - pointToData: function (point, clamp) { - var xAxis = this.getAxis('x'); - var yAxis = this.getAxis('y'); - return [ - xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp), - yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp) - ]; - }, - - /** - * Get other axis - * @param {module:echarts/coord/cartesian/Axis2D} axis - */ - getOtherAxis: function (axis) { - return this.getAxis(axis.dim === 'x' ? 'y' : 'x'); - } - }; - - zrUtil.inherits(Cartesian2D, Cartesian); - - return Cartesian2D; -}); -define('echarts/coord/Axis',['require','../util/number','zrender/core/util'],function (require) { - - var numberUtil = require('../util/number'); - var linearMap = numberUtil.linearMap; - var zrUtil = require('zrender/core/util'); - - function fixExtentWithBands(extent, nTick) { - var size = extent[1] - extent[0]; - var len = nTick; - var margin = size / len / 2; - extent[0] += margin; - extent[1] -= margin; - } - - var normalizedExtent = [0, 1]; - /** - * @name module:echarts/coord/CartesianAxis - * @constructor - */ - var Axis = function (dim, scale, extent) { - - /** - * Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius' - * @type {string} - */ - this.dim = dim; - - /** - * Axis scale - * @type {module:echarts/coord/scale/*} - */ - this.scale = scale; - - /** - * @type {Array.} - * @private - */ - this._extent = extent || [0, 0]; - - /** - * @type {boolean} - */ - this.inverse = false; - - /** - * Usually true when axis has a ordinal scale - * @type {boolean} - */ - this.onBand = false; - }; - - Axis.prototype = { - - constructor: Axis, - - /** - * If axis extent contain given coord - * @param {number} coord - * @return {boolean} - */ - contain: function (coord) { - var extent = this._extent; - var min = Math.min(extent[0], extent[1]); - var max = Math.max(extent[0], extent[1]); - return coord >= min && coord <= max; - }, - - /** - * If axis extent contain given data - * @param {number} data - * @return {boolean} - */ - containData: function (data) { - return this.contain(this.dataToCoord(data)); - }, - - /** - * Get coord extent. - * @return {Array.} - */ - getExtent: function () { - var ret = this._extent.slice(); - return ret; - }, - - /** - * Get precision used for formatting - * @param {Array.} [dataExtent] - * @return {number} - */ - getPixelPrecision: function (dataExtent) { - return numberUtil.getPixelPrecision( - dataExtent || this.scale.getExtent(), - this._extent - ); - }, - - /** - * Set coord extent - * @param {number} start - * @param {number} end - */ - setExtent: function (start, end) { - var extent = this._extent; - extent[0] = start; - extent[1] = end; - }, - - /** - * Convert data to coord. Data is the rank if it has a ordinal scale - * @param {number} data - * @param {boolean} clamp - * @return {number} - */ - dataToCoord: function (data, clamp) { - var extent = this._extent; - var scale = this.scale; - data = scale.normalize(data); - - if (this.onBand && scale.type === 'ordinal') { - extent = extent.slice(); - fixExtentWithBands(extent, scale.count()); - } - - return linearMap(data, normalizedExtent, extent, clamp); - }, - - /** - * Convert coord to data. Data is the rank if it has a ordinal scale - * @param {number} coord - * @param {boolean} clamp - * @return {number} - */ - coordToData: function (coord, clamp) { - var extent = this._extent; - var scale = this.scale; - - if (this.onBand && scale.type === 'ordinal') { - extent = extent.slice(); - fixExtentWithBands(extent, scale.count()); - } - - var t = linearMap(coord, extent, normalizedExtent, clamp); - - return this.scale.scale(t); - }, - /** - * @return {Array.} - */ - getTicksCoords: function () { - if (this.onBand) { - var bands = this.getBands(); - var coords = []; - for (var i = 0; i < bands.length; i++) { - coords.push(bands[i][0]); - } - if (bands[i - 1]) { - coords.push(bands[i - 1][1]); - } - return coords; - } - else { - return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this); - } - }, - - /** - * Coords of labels are on the ticks or on the middle of bands - * @return {Array.} - */ - getLabelsCoords: function () { - if (this.onBand) { - var bands = this.getBands(); - var coords = []; - var band; - for (var i = 0; i < bands.length; i++) { - band = bands[i]; - coords.push((band[0] + band[1]) / 2); - } - return coords; - } - else { - return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this); - } - }, - - /** - * Get bands. - * - * If axis has labels [1, 2, 3, 4]. Bands on the axis are - * |---1---|---2---|---3---|---4---|. - * - * @return {Array} - */ - // FIXME Situation when labels is on ticks - getBands: function () { - var extent = this.getExtent(); - var bands = []; - var len = this.scale.count(); - var start = extent[0]; - var end = extent[1]; - var span = end - start; - - for (var i = 0; i < len; i++) { - bands.push([ - span * i / len + start, - span * (i + 1) / len + start - ]); - } - return bands; - }, - - /** - * Get width of band - * @return {number} - */ - getBandWidth: function () { - var axisExtent = this._extent; - var dataExtent = this.scale.getExtent(); - - var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0); - - var size = Math.abs(axisExtent[1] - axisExtent[0]); - - return Math.abs(size) / len; - } - }; - - return Axis; -}); -/** - * Helper function for axisLabelInterval calculation - */ - -define('echarts/coord/cartesian/axisLabelInterval',['require','zrender/core/util','../axisHelper'],function(require) { - - - var zrUtil = require('zrender/core/util'); - var axisHelper = require('../axisHelper'); - - return function (axis) { - var axisModel = axis.model; - var labelModel = axisModel.getModel('axisLabel'); - var labelInterval = labelModel.get('interval'); - if (!(axis.type === 'category' && labelInterval === 'auto')) { - return labelInterval === 'auto' ? 0 : labelInterval; - } - - return axisHelper.getAxisLabelInterval( - zrUtil.map(axis.scale.getTicks(), axis.dataToCoord, axis), - axisModel.getFormattedLabels(), - labelModel.getModel('textStyle').getFont(), - axis.isHorizontal() - ); - }; -}); -define('echarts/coord/cartesian/Axis2D',['require','zrender/core/util','../Axis','./axisLabelInterval'],function (require) { - - var zrUtil = require('zrender/core/util'); - var Axis = require('../Axis'); - var axisLabelInterval = require('./axisLabelInterval'); - - /** - * Extend axis 2d - * @constructor module:echarts/coord/cartesian/Axis2D - * @extends {module:echarts/coord/cartesian/Axis} - * @param {string} dim - * @param {*} scale - * @param {Array.} coordExtent - * @param {string} axisType - * @param {string} position - */ - var Axis2D = function (dim, scale, coordExtent, axisType, position) { - Axis.call(this, dim, scale, coordExtent); - /** - * Axis type - * - 'category' - * - 'value' - * - 'time' - * - 'log' - * @type {string} - */ - this.type = axisType || 'value'; - - /** - * Axis position - * - 'top' - * - 'bottom' - * - 'left' - * - 'right' - */ - this.position = position || 'bottom'; - }; - - Axis2D.prototype = { - - constructor: Axis2D, - - /** - * Index of axis, can be used as key - */ - index: 0, - /** - * If axis is on the zero position of the other axis - * @type {boolean} - */ - onZero: false, - - /** - * Axis model - * @param {module:echarts/coord/cartesian/AxisModel} - */ - model: null, - - isHorizontal: function () { - var position = this.position; - return position === 'top' || position === 'bottom'; - }, - - getGlobalExtent: function () { - var ret = this.getExtent(); - ret[0] = this.toGlobalCoord(ret[0]); - ret[1] = this.toGlobalCoord(ret[1]); - return ret; - }, - - /** - * @return {number} - */ - getLabelInterval: function () { - var labelInterval = this._labelInterval; - if (!labelInterval) { - labelInterval = this._labelInterval = axisLabelInterval(this); - } - return labelInterval; - }, - - /** - * If label is ignored. - * Automatically used when axis is category and label can not be all shown - * @param {number} idx - * @return {boolean} - */ - isLabelIgnored: function (idx) { - if (this.type === 'category') { - var labelInterval = this.getLabelInterval(); - return ((typeof labelInterval === 'function') - && !labelInterval(idx, this.scale.getLabel(idx))) - || idx % (labelInterval + 1); - } - }, - - /** - * Transform global coord to local coord, - * i.e. var localCoord = axis.toLocalCoord(80); - * designate by module:echarts/coord/cartesian/Grid. - * @type {Function} - */ - toLocalCoord: null, - - /** - * Transform global coord to local coord, - * i.e. var globalCoord = axis.toLocalCoord(40); - * designate by module:echarts/coord/cartesian/Grid. - * @type {Function} - */ - toGlobalCoord: null - - }; - zrUtil.inherits(Axis2D, Axis); - - return Axis2D; -}); -define('echarts/coord/axisDefault',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - var defaultOption = { - show: true, - zlevel: 0, // 一级层叠 - z: 0, // 二级层叠 - // 反向坐标轴 - inverse: false, - // 坐标轴名字,默认为空 - name: '', - // 坐标轴名字位置,支持'start' | 'middle' | 'end' - nameLocation: 'end', - // 坐标轴文字样式,默认取全局样式 - nameTextStyle: {}, - // 文字与轴线距离 - nameGap: 15, - // 坐标轴线 - axisLine: { - // 默认显示,属性show控制显示与否 - show: true, - onZero: true, - // 属性lineStyle控制线条样式 - lineStyle: { - color: '#333', - width: 1, - type: 'solid' - } - }, - // 坐标轴小标记 - axisTick: { - // 属性show控制显示与否,默认显示 - show: true, - // 控制小标记是否在grid里 - inside: false, - // 属性length控制线长 - length: 5, - // 属性lineStyle控制线条样式 - lineStyle: { - color: '#333', - width: 1 - } - }, - // 坐标轴文本标签,详见axis.axisLabel - axisLabel: { - show: true, - // 控制文本标签是否在grid里 - inside: false, - rotate: 0, - margin: 8, - // formatter: null, - // 其余属性默认使用全局文本样式,详见TEXTSTYLE - textStyle: { - color: '#333', - fontSize: 12 - } - }, - // 分隔线 - splitLine: { - // 默认显示,属性show控制显示与否 - show: true, - // 属性lineStyle(详见lineStyle)控制线条样式 - lineStyle: { - color: ['#ccc'], - width: 1, - type: 'solid' - } - }, - // 分隔区域 - splitArea: { - // 默认不显示,属性show控制显示与否 - show: false, - // 属性areaStyle(详见areaStyle)控制区域样式 - areaStyle: { - color: ['rgba(250,250,250,0.3)','rgba(200,200,200,0.3)'] - } - } - }; - - var categoryAxis = zrUtil.merge({ - // 类目起始和结束两端空白策略 - boundaryGap: true, - // 坐标轴小标记 - axisTick: { - interval: 'auto' - }, - // 坐标轴文本标签,详见axis.axisLabel - axisLabel: { - interval: 'auto' - } - }, defaultOption); - - var valueAxis = zrUtil.defaults({ - // 数值起始和结束两端空白策略 - boundaryGap: [0, 0], - // 最小值, 设置成 'dataMin' 则从数据中计算最小值 - // min: null, - // 最大值,设置成 'dataMax' 则从数据中计算最大值 - // max: null, - // 脱离0值比例,放大聚焦到最终_min,_max区间 - // scale: false, - // 分割段数,默认为5 - splitNumber: 5 - }, defaultOption); - - // FIXME - var timeAxis = zrUtil.defaults({ - scale: true, - min: 'dataMin', - max: 'dataMax' - }, valueAxis); - var logAxis = zrUtil.defaults({}, valueAxis); - logAxis.scale = true; - - return { - categoryAxis: categoryAxis, - valueAxis: valueAxis, - timeAxis: timeAxis, - logAxis: logAxis - }; -}); -define('echarts/coord/axisModelCreator',['require','./axisDefault','zrender/core/util','../model/Component','../util/layout'],function (require) { - - var axisDefault = require('./axisDefault'); - var zrUtil = require('zrender/core/util'); - var ComponentModel = require('../model/Component'); - var layout = require('../util/layout'); - - // FIXME axisType is fixed ? - var AXIS_TYPES = ['value', 'category', 'time', 'log']; - - /** - * Generate sub axis model class - * @param {string} axisName 'x' 'y' 'radius' 'angle' 'parallel' - * @param {module:echarts/model/Component} BaseAxisModelClass - * @param {Function} axisTypeDefaulter - * @param {Object} [extraDefaultOption] - */ - return function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) { - - zrUtil.each(AXIS_TYPES, function (axisType) { - - BaseAxisModelClass.extend({ - - type: axisName + 'Axis.' + axisType, - - mergeDefaultAndTheme: function (option, ecModel) { - var layoutMode = this.layoutMode; - var inputPositionParams = layoutMode - ? layout.getLayoutParams(option) : {}; - - var themeModel = ecModel.getTheme(); - zrUtil.merge(option, themeModel.get(axisType + 'Axis')); - zrUtil.merge(option, this.getDefaultOption()); - - option.type = axisTypeDefaulter(axisName, option); - - if (layoutMode) { - layout.mergeLayoutParam(option, inputPositionParams, layoutMode); - } - }, - - defaultOption: zrUtil.mergeAll( - [ - {}, - axisDefault[axisType + 'Axis'], - extraDefaultOption - ], - true - ) - }); - }); - - ComponentModel.registerSubTypeDefaulter( - axisName + 'Axis', - zrUtil.curry(axisTypeDefaulter, axisName) - ); - }; -}); -define('echarts/coord/axisModelCommonMixin',['require','zrender/core/util','./axisHelper'],function (require) { - - var zrUtil = require('zrender/core/util'); - var axisHelper = require('./axisHelper'); - - function getName(obj) { - if (zrUtil.isObject(obj) && obj.value != null) { - return obj.value; - } - else { - return obj; - } - } - /** - * Get categories - */ - function getCategories() { - return this.get('type') === 'category' - && zrUtil.map(this.get('data'), getName); - } - - /** - * Format labels - * @return {Array.} - */ - function getFormattedLabels() { - return axisHelper.getFormattedLabels( - this.axis, - this.get('axisLabel.formatter') - ); - } - - return { - - getFormattedLabels: getFormattedLabels, - - getCategories: getCategories - }; -}); -define('echarts/coord/cartesian/AxisModel',['require','../../model/Component','zrender/core/util','../axisModelCreator','../axisModelCommonMixin'],function(require) { - - - - var ComponentModel = require('../../model/Component'); - var zrUtil = require('zrender/core/util'); - var axisModelCreator = require('../axisModelCreator'); - - var AxisModel = ComponentModel.extend({ - - type: 'cartesian2dAxis', - - /** - * @type {module:echarts/coord/cartesian/Axis2D} - */ - axis: null, - - /** - * @public - * @param {boolean} needs Whether axis needs cross zero. - */ - setNeedsCrossZero: function (needs) { - this.option.scale = !needs; - }, - - /** - * @public - * @param {number} min - */ - setMin: function (min) { - this.option.min = min; - }, - - /** - * @public - * @param {number} max - */ - setMax: function (max) { - this.option.max = max; - } - }); - - function getAxisType(axisDim, option) { - // Default axis with data is category axis - return option.type || (option.data ? 'category' : 'value'); - } - - zrUtil.merge(AxisModel.prototype, require('../axisModelCommonMixin')); - - var extraOption = { - gridIndex: 0 - }; - - axisModelCreator('x', AxisModel, getAxisType, extraOption); - axisModelCreator('y', AxisModel, getAxisType, extraOption); - - return AxisModel; -}); -// Grid 是在有直角坐标系的时候必须要存在的 -// 所以这里也要被 Cartesian2D 依赖 -define('echarts/coord/cartesian/GridModel',['require','./AxisModel','../../model/Component'],function(require) { - - - - require('./AxisModel'); - var ComponentModel = require('../../model/Component'); - - return ComponentModel.extend({ - - type: 'grid', - - dependencies: ['xAxis', 'yAxis'], - - layoutMode: 'box', - - /** - * @type {module:echarts/coord/cartesian/Grid} - */ - coordinateSystem: null, - - defaultOption: { - show: false, - zlevel: 0, - z: 0, - left: '10%', - top: 60, - right: '10%', - bottom: 60, - // If grid size contain label - containLabel: false, - // width: {totalWidth} - left - right, - // height: {totalHeight} - top - bottom, - backgroundColor: 'rgba(0,0,0,0)', - borderWidth: 1, - borderColor: '#ccc' - } - }); -}); -/** - * Grid is a region which contains at most 4 cartesian systems - * - * TODO Default cartesian - */ -define('echarts/coord/cartesian/Grid',['require','exports','module','../../util/layout','../../coord/axisHelper','zrender/core/util','./Cartesian2D','./Axis2D','./GridModel','../../CoordinateSystem'],function(require, factory) { - - var layout = require('../../util/layout'); - var axisHelper = require('../../coord/axisHelper'); - - var zrUtil = require('zrender/core/util'); - var Cartesian2D = require('./Cartesian2D'); - var Axis2D = require('./Axis2D'); - - var each = zrUtil.each; - - var ifAxisCrossZero = axisHelper.ifAxisCrossZero; - var niceScaleExtent = axisHelper.niceScaleExtent; - - // 依赖 GridModel, AxisModel 做预处理 - require('./GridModel'); - - /** - * Check if the axis is used in the specified grid - * @inner - */ - function isAxisUsedInTheGrid(axisModel, gridModel, ecModel) { - return ecModel.getComponent('grid', axisModel.get('gridIndex')) === gridModel; - } - - function getLabelUnionRect(axis) { - var axisModel = axis.model; - var labels = axisModel.getFormattedLabels(); - var rect; - var step = 1; - var labelCount = labels.length; - if (labelCount > 40) { - // Simple optimization for large amount of labels - step = Math.ceil(labelCount / 40); - } - for (var i = 0; i < labelCount; i += step) { - if (!axis.isLabelIgnored(i)) { - var singleRect = axisModel.getTextRect(labels[i]); - // FIXME consider label rotate - rect ? rect.union(singleRect) : (rect = singleRect); - } - } - return rect; - } - - function Grid(gridModel, ecModel, api) { - /** - * @type {Object.} - * @private - */ - this._coordsMap = {}; - - /** - * @type {Array.} - * @private - */ - this._coordsList = []; - - /** - * @type {Object.} - * @private - */ - this._axesMap = {}; - - /** - * @type {Array.} - * @private - */ - this._axesList = []; - - this._initCartesian(gridModel, ecModel, api); - - this._model = gridModel; - } - - var gridProto = Grid.prototype; - - gridProto.type = 'grid'; - - gridProto.getRect = function () { - return this._rect; - }; - - gridProto.update = function (ecModel, api) { - - var axesMap = this._axesMap; - - this._updateScale(ecModel, this._model); - - function ifAxisCanNotOnZero(otherAxisDim) { - var axes = axesMap[otherAxisDim]; - for (var idx in axes) { - var axis = axes[idx]; - if (axis && (axis.type === 'category' || !ifAxisCrossZero(axis))) { - return true; - } - } - return false; - } - - each(axesMap.x, function (xAxis) { - niceScaleExtent(xAxis, xAxis.model); - }); - each(axesMap.y, function (yAxis) { - niceScaleExtent(yAxis, yAxis.model); - }); - // Fix configuration - each(axesMap.x, function (xAxis) { - // onZero can not be enabled in these two situations - // 1. When any other axis is a category axis - // 2. When any other axis not across 0 point - if (ifAxisCanNotOnZero('y')) { - xAxis.onZero = false; - } - }); - each(axesMap.y, function (yAxis) { - if (ifAxisCanNotOnZero('x')) { - yAxis.onZero = false; - } - }); - - // Resize again if containLabel is enabled - // FIXME It may cause getting wrong grid size in data processing stage - this.resize(this._model, api); - }; - - /** - * Resize the grid - * @param {module:echarts/coord/cartesian/GridModel} gridModel - * @param {module:echarts/ExtensionAPI} api - */ - gridProto.resize = function (gridModel, api) { - - var gridRect = layout.getLayoutRect( - gridModel.getBoxLayoutParams(), { - width: api.getWidth(), - height: api.getHeight() - }); - - this._rect = gridRect; - - var axesList = this._axesList; - - adjustAxes(); - - // Minus label size - if (gridModel.get('containLabel')) { - each(axesList, function (axis) { - if (!axis.model.get('axisLabel.inside')) { - var labelUnionRect = getLabelUnionRect(axis); - if (labelUnionRect) { - var dim = axis.isHorizontal() ? 'height' : 'width'; - var margin = axis.model.get('axisLabel.margin'); - gridRect[dim] -= labelUnionRect[dim] + margin; - if (axis.position === 'top') { - gridRect.y += labelUnionRect.height + margin; - } - else if (axis.position === 'left') { - gridRect.x += labelUnionRect.width + margin; - } - } - } - }); - - adjustAxes(); - } - - function adjustAxes() { - each(axesList, function (axis) { - var isHorizontal = axis.isHorizontal(); - var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height]; - var idx = axis.inverse ? 1 : 0; - axis.setExtent(extent[idx], extent[1 - idx]); - updateAxisTransfrom(axis, isHorizontal ? gridRect.x : gridRect.y); - }); - } - }; - - /** - * @param {string} axisType - * @param {ndumber} [axisIndex] - */ - gridProto.getAxis = function (axisType, axisIndex) { - var axesMapOnDim = this._axesMap[axisType]; - if (axesMapOnDim != null) { - if (axisIndex == null) { - // Find first axis - for (var name in axesMapOnDim) { - return axesMapOnDim[name]; - } - } - return axesMapOnDim[axisIndex]; - } - }; - - gridProto.getCartesian = function (xAxisIndex, yAxisIndex) { - var key = 'x' + xAxisIndex + 'y' + yAxisIndex; - return this._coordsMap[key]; - }; - - /** - * Initialize cartesian coordinate systems - * @private - */ - gridProto._initCartesian = function (gridModel, ecModel, api) { - var axisPositionUsed = { - left: false, - right: false, - top: false, - bottom: false - }; - - var axesMap = { - x: {}, - y: {} - }; - var axesCount = { - x: 0, - y: 0 - }; - - /// Create axis - ecModel.eachComponent('xAxis', createAxisCreator('x'), this); - ecModel.eachComponent('yAxis', createAxisCreator('y'), this); - - if (!axesCount.x || !axesCount.y) { - // Roll back when there no either x or y axis - this._axesMap = {}; - this._axesList = []; - return; - } - - this._axesMap = axesMap; - - /// Create cartesian2d - each(axesMap.x, function (xAxis, xAxisIndex) { - each(axesMap.y, function (yAxis, yAxisIndex) { - var key = 'x' + xAxisIndex + 'y' + yAxisIndex; - var cartesian = new Cartesian2D(key); - - cartesian.grid = this; - - this._coordsMap[key] = cartesian; - this._coordsList.push(cartesian); - - cartesian.addAxis(xAxis); - cartesian.addAxis(yAxis); - }, this); - }, this); - - function createAxisCreator(axisType) { - return function (axisModel, idx) { - if (!isAxisUsedInTheGrid(axisModel, gridModel, ecModel)) { - return; - } - - var axisPosition = axisModel.get('position'); - if (axisType === 'x') { - // Fix position - if (axisPosition !== 'top' && axisPosition !== 'bottom') { - // Default bottom of X - axisPosition = 'bottom'; - } - if (axisPositionUsed[axisPosition]) { - axisPosition = axisPosition === 'top' ? 'bottom' : 'top'; - } - } - else { - // Fix position - if (axisPosition !== 'left' && axisPosition !== 'right') { - // Default left of Y - axisPosition = 'left'; - } - if (axisPositionUsed[axisPosition]) { - axisPosition = axisPosition === 'left' ? 'right' : 'left'; - } - } - axisPositionUsed[axisPosition] = true; - - var axis = new Axis2D( - axisType, axisHelper.createScaleByModel(axisModel), - [0, 0], - axisModel.get('type'), - axisPosition - ); - - var isCategory = axis.type === 'category'; - axis.onBand = isCategory && axisModel.get('boundaryGap'); - axis.inverse = axisModel.get('inverse'); - - axis.onZero = axisModel.get('axisLine.onZero'); - - // Inject axis into axisModel - axisModel.axis = axis; - - // Inject axisModel into axis - axis.model = axisModel; - - // Index of axis, can be used as key - axis.index = idx; - - this._axesList.push(axis); - - axesMap[axisType][idx] = axis; - axesCount[axisType]++; - }; - } - }; - - /** - * Update cartesian properties from series - * @param {module:echarts/model/Option} option - * @private - */ - gridProto._updateScale = function (ecModel, gridModel) { - // Reset scale - zrUtil.each(this._axesList, function (axis) { - axis.scale.setExtent(Infinity, -Infinity); - }); - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.get('coordinateSystem') === 'cartesian2d') { - var xAxisIndex = seriesModel.get('xAxisIndex'); - var yAxisIndex = seriesModel.get('yAxisIndex'); - - var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex); - var yAxisModel = ecModel.getComponent('yAxis', yAxisIndex); - - if (!isAxisUsedInTheGrid(xAxisModel, gridModel, ecModel) - || !isAxisUsedInTheGrid(yAxisModel, gridModel, ecModel) - ) { - return; - } - - var cartesian = this.getCartesian(xAxisIndex, yAxisIndex); - var data = seriesModel.getData(); - var xAxis = cartesian.getAxis('x'); - var yAxis = cartesian.getAxis('y'); - - if (data.type === 'list') { - unionExtent(data, xAxis, seriesModel); - unionExtent(data, yAxis, seriesModel); - } - } - }, this); - - function unionExtent(data, axis, seriesModel) { - each(seriesModel.coordDimToDataDim(axis.dim), function (dim) { - axis.scale.unionExtent(data.getDataExtent( - dim, axis.scale.type !== 'ordinal' - )); - }); - } - }; - - /** - * @inner - */ - function updateAxisTransfrom(axis, coordBase) { - var axisExtent = axis.getExtent(); - var axisExtentSum = axisExtent[0] + axisExtent[1]; - - // Fast transform - axis.toGlobalCoord = axis.dim === 'x' - ? function (coord) { - return coord + coordBase; - } - : function (coord) { - return axisExtentSum - coord + coordBase; - }; - axis.toLocalCoord = axis.dim === 'x' - ? function (coord) { - return coord - coordBase; - } - : function (coord) { - return axisExtentSum - coord + coordBase; - }; - } - - Grid.create = function (ecModel, api) { - var grids = []; - ecModel.eachComponent('grid', function (gridModel, idx) { - var grid = new Grid(gridModel, ecModel, api); - grid.name = 'grid_' + idx; - grid.resize(gridModel, api); - - gridModel.coordinateSystem = grid; - - grids.push(grid); - }); - - // Inject the coordinateSystems into seriesModel - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.get('coordinateSystem') !== 'cartesian2d') { - return; - } - var xAxisIndex = seriesModel.get('xAxisIndex'); - // TODO Validate - var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex); - var grid = grids[xAxisModel.get('gridIndex')]; - seriesModel.coordinateSystem = grid.getCartesian( - xAxisIndex, seriesModel.get('yAxisIndex') - ); - }); - - return grids; - }; - - // For deciding which dimensions to use when creating list data - Grid.dimensions = Cartesian2D.prototype.dimensions; - - require('../../CoordinateSystem').register('cartesian2d', Grid); - - return Grid; -}); -define('echarts/chart/bar/BarSeries',['require','../../model/Series','../helper/createListFromArray'],function(require) { - - - - var SeriesModel = require('../../model/Series'); - var createListFromArray = require('../helper/createListFromArray'); - - return SeriesModel.extend({ - - type: 'series.bar', - - dependencies: ['grid', 'polar'], - - getInitialData: function (option, ecModel) { - return createListFromArray(option.data, this, ecModel); - }, - - getMarkerPosition: function (value) { - var coordSys = this.coordinateSystem; - if (coordSys) { - var pt = coordSys.dataToPoint(value); - var data = this.getData(); - var offset = data.getLayout('offset'); - var size = data.getLayout('size'); - var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1; - pt[offsetIndex] += offset + size / 2; - return pt; - } - return [NaN, NaN]; - }, - - defaultOption: { - zlevel: 0, // 一级层叠 - z: 2, // 二级层叠 - coordinateSystem: 'cartesian2d', - legendHoverLink: true, - // stack: null - - // Cartesian coordinate system - xAxisIndex: 0, - yAxisIndex: 0, - - // 最小高度改为0 - barMinHeight: 0, - - // barMaxWidth: null, - // 默认自适应 - // barWidth: null, - // 柱间距离,默认为柱形宽度的30%,可设固定值 - // barGap: '30%', - // 类目间柱形距离,默认为类目间距的20%,可设固定值 - // barCategoryGap: '20%', - // label: { - // normal: { - // show: false - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - - // // 默认自适应,水平布局为'top',垂直布局为'right',可选为 - // // 'inside' | 'insideleft' | 'insideTop' | 'insideRight' | 'insideBottom' | - // // 'outside' |'left' | 'right'|'top'|'bottom' - // position: - - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - // } - // }, - itemStyle: { - normal: { - // color: '各异', - // 柱条边线 - barBorderColor: '#fff', - // 柱条边线线宽,单位px,默认为1 - barBorderWidth: 0 - }, - emphasis: { - // color: '各异', - // 柱条边线 - barBorderColor: '#fff', - // 柱条边线线宽,单位px,默认为1 - barBorderWidth: 0 - } - } - } - }); -}); -define('echarts/chart/bar/barItemStyle',['require','../../model/mixin/makeStyleMapper'],function (require) { - return { - getBarItemStyle: require('../../model/mixin/makeStyleMapper')( - [ - ['fill', 'color'], - ['stroke', 'barBorderColor'], - ['lineWidth', 'barBorderWidth'], - ['opacity'], - ['shadowBlur'], - ['shadowOffsetX'], - ['shadowOffsetY'], - ['shadowColor'] - ] - ) - }; -}); -define('echarts/chart/bar/BarView',['require','zrender/core/util','../../util/graphic','../../model/Model','./barItemStyle','../../echarts'],function (require) { - - - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - - zrUtil.extend(require('../../model/Model').prototype, require('./barItemStyle')); - - function fixLayoutWithLineWidth(layout, lineWidth) { - var signX = layout.width > 0 ? 1 : -1; - var signY = layout.height > 0 ? 1 : -1; - // In case width or height are too small. - lineWidth = Math.min(lineWidth, Math.abs(layout.width), Math.abs(layout.height)); - layout.x += signX * lineWidth / 2; - layout.y += signY * lineWidth / 2; - layout.width -= signX * lineWidth; - layout.height -= signY * lineWidth; - } - - return require('../../echarts').extendChartView({ - - type: 'bar', - - render: function (seriesModel, ecModel, api) { - var coordinateSystemType = seriesModel.get('coordinateSystem'); - - if (coordinateSystemType === 'cartesian2d') { - this._renderOnCartesian(seriesModel, ecModel, api); - } - - return this.group; - }, - - _renderOnCartesian: function (seriesModel, ecModel, api) { - var group = this.group; - var data = seriesModel.getData(); - var oldData = this._data; - - var cartesian = seriesModel.coordinateSystem; - var baseAxis = cartesian.getBaseAxis(); - var isHorizontal = baseAxis.isHorizontal(); - - var enableAnimation = seriesModel.get('animation'); - - var barBorderWidthQuery = ['itemStyle', 'normal', 'barBorderWidth']; - - function createRect(dataIndex, isUpdate) { - var layout = data.getItemLayout(dataIndex); - var lineWidth = data.getItemModel(dataIndex).get(barBorderWidthQuery) || 0; - fixLayoutWithLineWidth(layout, lineWidth); - - var rect = new graphic.Rect({ - shape: zrUtil.extend({}, layout) - }); - // Animation - if (enableAnimation) { - var rectShape = rect.shape; - var animateProperty = isHorizontal ? 'height' : 'width'; - var animateTarget = {}; - rectShape[animateProperty] = 0; - animateTarget[animateProperty] = layout[animateProperty]; - graphic[isUpdate? 'updateProps' : 'initProps'](rect, { - shape: animateTarget - }, seriesModel); - } - return rect; - } - data.diff(oldData) - .add(function (dataIndex) { - // 空数据 - if (!data.hasValue(dataIndex)) { - return; - } - - var rect = createRect(dataIndex); - - data.setItemGraphicEl(dataIndex, rect); - - group.add(rect); - - }) - .update(function (newIndex, oldIndex) { - var rect = oldData.getItemGraphicEl(oldIndex); - // 空数据 - if (!data.hasValue(newIndex)) { - group.remove(rect); - return; - } - if (!rect) { - rect = createRect(newIndex, true); - } - - var layout = data.getItemLayout(newIndex); - var lineWidth = data.getItemModel(newIndex).get(barBorderWidthQuery) || 0; - fixLayoutWithLineWidth(layout, lineWidth); - - graphic.updateProps(rect, { - shape: layout - }, seriesModel); - - data.setItemGraphicEl(newIndex, rect); - - // Add back - group.add(rect); - }) - .remove(function (idx) { - var rect = oldData.getItemGraphicEl(idx); - if (rect) { - // Not show text when animating - rect.style.text = ''; - graphic.updateProps(rect, { - shape: { - width: 0 - } - }, seriesModel, function () { - group.remove(rect); - }); - } - }) - .execute(); - - this._updateStyle(seriesModel, data, isHorizontal); - - this._data = data; - }, - - _updateStyle: function (seriesModel, data, isHorizontal) { - function setLabel(style, model, color, labelText, labelPositionOutside) { - graphic.setText(style, model, color); - style.text = labelText; - if (style.textPosition === 'outside') { - style.textPosition = labelPositionOutside; - } - } - - data.eachItemGraphicEl(function (rect, idx) { - var itemModel = data.getItemModel(idx); - var color = data.getItemVisual(idx, 'color'); - var layout = data.getItemLayout(idx); - var itemStyleModel = itemModel.getModel('itemStyle.normal'); - - var hoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle(); - - rect.setShape('r', itemStyleModel.get('barBorderRadius') || 0); - - rect.setStyle(zrUtil.defaults( - { - fill: color - }, - itemStyleModel.getBarItemStyle() - )); - - var labelPositionOutside = isHorizontal - ? (layout.height > 0 ? 'bottom' : 'top') - : (layout.width > 0 ? 'left' : 'right'); - - var labelModel = itemModel.getModel('label.normal'); - var hoverLabelModel = itemModel.getModel('label.emphasis'); - var rectStyle = rect.style; - if (labelModel.get('show')) { - setLabel( - rectStyle, labelModel, color, - zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'normal'), - seriesModel.getRawValue(idx) - ), - labelPositionOutside - ); - } - else { - rectStyle.text = ''; - } - if (hoverLabelModel.get('show')) { - setLabel( - hoverStyle, hoverLabelModel, color, - zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'emphasis'), - seriesModel.getRawValue(idx) - ), - labelPositionOutside - ); - } - else { - hoverStyle.text = ''; - } - graphic.setHoverStyle(rect, hoverStyle); - }); - }, - - remove: function (ecModel, api) { - var group = this.group; - if (ecModel.get('animation')) { - if (this._data) { - this._data.eachItemGraphicEl(function (el) { - // Not show text when animating - el.style.text = ''; - graphic.updateProps(el, { - shape: { - width: 0 - } - }, ecModel, function () { - group.remove(el); - }); - }); - } - } - else { - group.removeAll(); - } - } - }); -}); -define('echarts/layout/barGrid',['require','zrender/core/util','../util/number'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../util/number'); - var parsePercent = numberUtil.parsePercent; - - function getSeriesStackId(seriesModel) { - return seriesModel.get('stack') || '__ec_stack_' + seriesModel.seriesIndex; - } - - function calBarWidthAndOffset(barSeries, api) { - // Columns info on each category axis. Key is cartesian name - var columnsMap = {}; - - zrUtil.each(barSeries, function (seriesModel, idx) { - var cartesian = seriesModel.coordinateSystem; - - var baseAxis = cartesian.getBaseAxis(); - - var columnsOnAxis = columnsMap[baseAxis.index] || { - remainedWidth: baseAxis.getBandWidth(), - autoWidthCount: 0, - categoryGap: '20%', - gap: '30%', - axis: baseAxis, - stacks: {} - }; - var stacks = columnsOnAxis.stacks; - columnsMap[baseAxis.index] = columnsOnAxis; - - var stackId = getSeriesStackId(seriesModel); - - if (!stacks[stackId]) { - columnsOnAxis.autoWidthCount++; - } - stacks[stackId] = stacks[stackId] || { - width: 0, - maxWidth: 0 - }; - - var barWidth = seriesModel.get('barWidth'); - var barMaxWidth = seriesModel.get('barMaxWidth'); - var barGap = seriesModel.get('barGap'); - var barCategoryGap = seriesModel.get('barCategoryGap'); - // TODO - if (barWidth && ! stacks[stackId].width) { - barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth); - stacks[stackId].width = barWidth; - columnsOnAxis.remainedWidth -= barWidth; - } - - barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth); - (barGap != null) && (columnsOnAxis.gap = barGap); - (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap); - }); - - var result = {}; - - zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) { - - result[coordSysName] = {}; - - var stacks = columnsOnAxis.stacks; - var baseAxis = columnsOnAxis.axis; - var bandWidth = baseAxis.getBandWidth(); - var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth); - var barGapPercent = parsePercent(columnsOnAxis.gap, 1); - - var remainedWidth = columnsOnAxis.remainedWidth; - var autoWidthCount = columnsOnAxis.autoWidthCount; - var autoWidth = (remainedWidth - categoryGap) - / (autoWidthCount + (autoWidthCount - 1) * barGapPercent); - autoWidth = Math.max(autoWidth, 0); - - // Find if any auto calculated bar exceeded maxBarWidth - zrUtil.each(stacks, function (column, stack) { - var maxWidth = column.maxWidth; - if (!column.width && maxWidth && maxWidth < autoWidth) { - maxWidth = Math.min(maxWidth, remainedWidth); - remainedWidth -= maxWidth; - column.width = maxWidth; - autoWidthCount--; - } - }); - - // Recalculate width again - autoWidth = (remainedWidth - categoryGap) - / (autoWidthCount + (autoWidthCount - 1) * barGapPercent); - autoWidth = Math.max(autoWidth, 0); - - var widthSum = 0; - var lastColumn; - zrUtil.each(stacks, function (column, idx) { - if (!column.width) { - column.width = autoWidth; - } - lastColumn = column; - widthSum += column.width * (1 + barGapPercent); - }); - if (lastColumn) { - widthSum -= lastColumn.width * barGapPercent; - } - - var offset = -widthSum / 2; - zrUtil.each(stacks, function (column, stackId) { - result[coordSysName][stackId] = result[coordSysName][stackId] || { - offset: offset, - width: column.width - }; - - offset += column.width * (1 + barGapPercent); - }); - }); - - return result; - } - - /** - * @param {string} seriesType - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - */ - function barLayoutGrid(seriesType, ecModel, api) { - - var barWidthAndOffset = calBarWidthAndOffset( - zrUtil.filter( - ecModel.getSeriesByType(seriesType), - function (seriesModel) { - return !ecModel.isSeriesFiltered(seriesModel) - && seriesModel.coordinateSystem - && seriesModel.coordinateSystem.type === 'cartesian2d'; - } - ) - ); - - var lastStackCoords = {}; - - ecModel.eachSeriesByType(seriesType, function (seriesModel) { - - var data = seriesModel.getData(); - var cartesian = seriesModel.coordinateSystem; - var baseAxis = cartesian.getBaseAxis(); - - var stackId = getSeriesStackId(seriesModel); - var columnLayoutInfo = barWidthAndOffset[baseAxis.index][stackId]; - var columnOffset = columnLayoutInfo.offset; - var columnWidth = columnLayoutInfo.width; - var valueAxis = cartesian.getOtherAxis(baseAxis); - - var barMinHeight = seriesModel.get('barMinHeight') || 0; - - var valueAxisStart = baseAxis.onZero - ? valueAxis.toGlobalCoord(valueAxis.dataToCoord(0)) - : valueAxis.getGlobalExtent()[0]; - - var coords = cartesian.dataToPoints(data, true); - lastStackCoords[stackId] = lastStackCoords[stackId] || []; - - data.setLayout({ - offset: columnOffset, - size: columnWidth - }); - data.each(valueAxis.dim, function (value, idx) { - // 空数据 - if (isNaN(value)) { - return; - } - if (!lastStackCoords[stackId][idx]) { - lastStackCoords[stackId][idx] = { - // Positive stack - p: valueAxisStart, - // Negative stack - n: valueAxisStart - }; - } - var sign = value >= 0 ? 'p' : 'n'; - var coord = coords[idx]; - var lastCoord = lastStackCoords[stackId][idx][sign]; - var x, y, width, height; - if (valueAxis.isHorizontal()) { - x = lastCoord; - y = coord[1] + columnOffset; - width = coord[0] - lastCoord; - height = columnWidth; - - if (Math.abs(width) < barMinHeight) { - width = (width < 0 ? -1 : 1) * barMinHeight; - } - lastStackCoords[stackId][idx][sign] += width; - } - else { - x = coord[0] + columnOffset; - y = lastCoord; - width = columnWidth; - height = coord[1] - lastCoord; - if (Math.abs(height) < barMinHeight) { - // Include zero to has a positive bar - height = (height <= 0 ? -1 : 1) * barMinHeight; - } - lastStackCoords[stackId][idx][sign] += height; - } - - data.setItemLayout(idx, { - x: x, - y: y, - width: width, - height: height - }); - }, true); - - }, this); - } - - return barLayoutGrid; -}); -define('echarts/chart/bar',['require','zrender/core/util','../coord/cartesian/Grid','./bar/BarSeries','./bar/BarView','../layout/barGrid','../echarts'],function (require) { +/***/ }, +/* 218 */ +/***/ function(module, exports, __webpack_require__) { - var zrUtil = require('zrender/core/util'); + /** + * Parallel Coordinates + * + */ - require('../coord/cartesian/Grid'); - require('./bar/BarSeries'); - require('./bar/BarView'); + var layout = __webpack_require__(21); + var axisHelper = __webpack_require__(108); + var zrUtil = __webpack_require__(3); + var ParallelAxis = __webpack_require__(219); + var matrix = __webpack_require__(17); + var vector = __webpack_require__(16); - var barLayoutGrid = require('../layout/barGrid'); - var echarts = require('../echarts'); + var each = zrUtil.each; - echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar')); - // Visual coding for legend - echarts.registerVisualCoding('chart', function (ecModel) { - ecModel.eachSeriesByType('bar', function (seriesModel) { - var data = seriesModel.getData(); - data.setVisual('legendSymbol', 'roundRect'); - }); - }); -}); -define('echarts/component/axis/AxisBuilder',['require','zrender/core/util','../../util/graphic','../../model/Model','../../util/number'],function (require) { - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var Model = require('../../model/Model'); - var numberUtil = require('../../util/number'); - var remRadian = numberUtil.remRadian; - var isRadianAroundZero = numberUtil.isRadianAroundZero; - - var PI = Math.PI; - - /** - * A final axis is translated and rotated from a "standard axis". - * So opt.position and opt.rotation is required. - * - * A standard axis is and axis from [0, 0] to [0, axisExtent[1]], - * for example: (0, 0) ------------> (0, 50) - * - * nameDirection or tickDirection or labelDirection is 1 means tick - * or label is below the standard axis, whereas is -1 means above - * the standard axis. labelOffset means offset between label and axis, - * which is useful when 'onZero', where axisLabel is in the grid and - * label in outside grid. - * - * Tips: like always, - * positive rotation represents anticlockwise, and negative rotation - * represents clockwise. - * The direction of position coordinate is the same as the direction - * of screen coordinate. - * - * Do not need to consider axis 'inverse', which is auto processed by - * axis extent. - * - * @param {module:zrender/container/Group} group - * @param {Object} axisModel - * @param {Object} opt Standard axis parameters. - * @param {Array.} opt.position [x, y] - * @param {number} opt.rotation by radian - * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'. - * @param {number} [opt.tickDirection=1] 1 or -1 - * @param {number} [opt.labelDirection=1] 1 or -1 - * @param {number} [opt.labelOffset=0] Usefull when onZero. - * @param {string} [opt.axisName] default get from axisModel. - * @param {number} [opt.labelRotation] by degree, default get from axisModel. - * @param {number} [opt.labelInterval] Default label interval when label - * interval from model is null or 'auto'. - * @param {number} [opt.strokeContainThreshold] Default label interval when label - * @param {number} [opt.silent=true] - */ - var AxisBuilder = function (axisModel, opt) { - - /** - * @readOnly - */ - this.opt = opt; - - /** - * @readOnly - */ - this.axisModel = axisModel; - - // Default value - zrUtil.defaults( - opt, - { - labelOffset: 0, - nameDirection: 1, - tickDirection: 1, - labelDirection: 1, - silent: true - } - ); - - /** - * @readOnly - */ - this.group = new graphic.Group({ - position: opt.position.slice(), - rotation: opt.rotation - }); - }; - - AxisBuilder.prototype = { - - constructor: AxisBuilder, - - hasBuilder: function (name) { - return !!builders[name]; - }, - - add: function (name) { - builders[name].call(this); - }, - - getGroup: function () { - return this.group; - } - - }; - - var builders = { - - /** - * @private - */ - axisLine: function () { - var opt = this.opt; - var axisModel = this.axisModel; - - if (!axisModel.get('axisLine.show')) { - return; - } - - var extent = this.axisModel.axis.getExtent(); - - this.group.add(new graphic.Line({ - shape: { - x1: extent[0], - y1: 0, - x2: extent[1], - y2: 0 - }, - style: zrUtil.extend( - {lineCap: 'round'}, - axisModel.getModel('axisLine.lineStyle').getLineStyle() - ), - strokeContainThreshold: opt.strokeContainThreshold, - silent: !!opt.silent, - z2: 1 - })); - }, - - /** - * @private - */ - axisTick: function () { - var axisModel = this.axisModel; - - if (!axisModel.get('axisTick.show')) { - return; - } - - var axis = axisModel.axis; - var tickModel = axisModel.getModel('axisTick'); - var opt = this.opt; - - var lineStyleModel = tickModel.getModel('lineStyle'); - var tickLen = tickModel.get('length'); - var tickInterval = getInterval(tickModel, opt.labelInterval); - var ticksCoords = axis.getTicksCoords(); - var tickLines = []; - - for (var i = 0; i < ticksCoords.length; i++) { - // Only ordinal scale support tick interval - if (ifIgnoreOnTick(axis, i, tickInterval)) { - continue; - } - - var tickCoord = ticksCoords[i]; - - // Tick line - tickLines.push(new graphic.Line(graphic.subPixelOptimizeLine({ - shape: { - x1: tickCoord, - y1: 0, - x2: tickCoord, - y2: opt.tickDirection * tickLen - }, - style: { - lineWidth: lineStyleModel.get('width') - }, - silent: true - }))); - } - - this.group.add(graphic.mergePath(tickLines, { - style: lineStyleModel.getLineStyle(), - silent: true - })); - }, - - /** - * @param {module:echarts/coord/cartesian/AxisModel} axisModel - * @param {module:echarts/coord/cartesian/GridModel} gridModel - * @private - */ - axisLabel: function () { - var axisModel = this.axisModel; - - if (!axisModel.get('axisLabel.show')) { - return; - } - - var opt = this.opt; - var axis = axisModel.axis; - var labelModel = axisModel.getModel('axisLabel'); - var textStyleModel = labelModel.getModel('textStyle'); - var labelMargin = labelModel.get('margin'); - var ticks = axis.scale.getTicks(); - var labels = axisModel.getFormattedLabels(); - - // Special label rotate. - var labelRotation = opt.labelRotation; - if (labelRotation == null) { - labelRotation = labelModel.get('rotate') || 0; - } - // To radian. - labelRotation = labelRotation * PI / 180; - - var labelLayout = innerTextLayout(opt, labelRotation, opt.labelDirection); - var categoryData = axisModel.get('data'); - - var textEls = []; - for (var i = 0; i < ticks.length; i++) { - if (ifIgnoreOnTick(axis, i, opt.labelInterval)) { - continue; - } - - var itemTextStyleModel = textStyleModel; - if (categoryData && categoryData[i] && categoryData[i].textStyle) { - itemTextStyleModel = new Model( - categoryData[i].textStyle, textStyleModel, axisModel.ecModel - ); - } - - var tickCoord = axis.dataToCoord(ticks[i]); - var pos = [ - tickCoord, - opt.labelOffset + opt.labelDirection * labelMargin - ]; - - var textEl = new graphic.Text({ - style: { - text: labels[i], - textAlign: itemTextStyleModel.get('align', true) || labelLayout.textAlign, - textBaseline: itemTextStyleModel.get('baseline', true) || labelLayout.textBaseline, - textFont: itemTextStyleModel.getFont(), - fill: itemTextStyleModel.getTextColor() - }, - position: pos, - rotation: labelLayout.rotation, - silent: true, - z2: 10 - }); - textEls.push(textEl); - this.group.add(textEl); - } - - function isTwoLabelOverlapped(current, next) { - var firstRect = current && current.getBoundingRect().clone(); - var nextRect = next && next.getBoundingRect().clone(); - if (firstRect && nextRect) { - firstRect.applyTransform(current.getLocalTransform()); - nextRect.applyTransform(next.getLocalTransform()); - return firstRect.intersect(nextRect); - } - } - if (axis.type !== 'category') { - // If min or max are user set, we need to check - // If the tick on min(max) are overlap on their neighbour tick - // If they are overlapped, we need to hide the min(max) tick label - if (axisModel.get('min')) { - var firstLabel = textEls[0]; - var nextLabel = textEls[1]; - if (isTwoLabelOverlapped(firstLabel, nextLabel)) { - firstLabel.ignore = true; - } - } - if (axisModel.get('max')) { - var lastLabel = textEls[textEls.length - 1]; - var prevLabel = textEls[textEls.length - 2]; - if (isTwoLabelOverlapped(prevLabel, lastLabel)) { - lastLabel.ignore = true; - } - } - } - }, - - /** - * @private - */ - axisName: function () { - var opt = this.opt; - var axisModel = this.axisModel; - - var name = this.opt.axisName; - // If name is '', do not get name from axisMode. - if (name == null) { - name = axisModel.get('name'); - } - - if (!name) { - return; - } - - var nameLocation = axisModel.get('nameLocation'); - var nameDirection = opt.nameDirection; - var textStyleModel = axisModel.getModel('nameTextStyle'); - var gap = axisModel.get('nameGap') || 0; - - var extent = this.axisModel.axis.getExtent(); - var gapSignal = extent[0] > extent[1] ? -1 : 1; - var pos = [ - nameLocation === 'start' - ? extent[0] - gapSignal * gap - : nameLocation === 'end' - ? extent[1] + gapSignal * gap - : (extent[0] + extent[1]) / 2, // 'middle' - // Reuse labelOffset. - nameLocation === 'middle' ? opt.labelOffset + nameDirection * gap : 0 - ]; - - var labelLayout; - - if (nameLocation === 'middle') { - labelLayout = innerTextLayout(opt, opt.rotation, nameDirection); - } - else { - labelLayout = endTextLayout(opt, nameLocation, extent); - } - - this.group.add(new graphic.Text({ - style: { - text: name, - textFont: textStyleModel.getFont(), - fill: textStyleModel.getTextColor() - || axisModel.get('axisLine.lineStyle.color'), - textAlign: labelLayout.textAlign, - textBaseline: labelLayout.textBaseline - }, - position: pos, - rotation: labelLayout.rotation, - silent: true, - z2: 1 - })); - } - - }; - - /** - * @inner - */ - function innerTextLayout(opt, textRotation, direction) { - var rotationDiff = remRadian(textRotation - opt.rotation); - var textAlign; - var textBaseline; - - if (isRadianAroundZero(rotationDiff)) { // Label is parallel with axis line. - textBaseline = direction > 0 ? 'top' : 'bottom'; - textAlign = 'center'; - } - else if (isRadianAroundZero(rotationDiff - PI)) { // Label is inverse parallel with axis line. - textBaseline = direction > 0 ? 'bottom' : 'top'; - textAlign = 'center'; - } - else { - textBaseline = 'middle'; - - if (rotationDiff > 0 && rotationDiff < PI) { - textAlign = direction > 0 ? 'right' : 'left'; - } - else { - textAlign = direction > 0 ? 'left' : 'right'; - } - } - - return { - rotation: rotationDiff, - textAlign: textAlign, - textBaseline: textBaseline - }; - } - - /** - * @inner - */ - function endTextLayout(opt, textPosition, extent) { - var rotationDiff = remRadian(-opt.rotation); - var textAlign; - var textBaseline; - var inverse = extent[0] > extent[1]; - var onLeft = (textPosition === 'start' && !inverse) - || (textPosition !== 'start' && inverse); - - if (isRadianAroundZero(rotationDiff - PI / 2)) { - textBaseline = onLeft ? 'bottom' : 'top'; - textAlign = 'center'; - } - else if (isRadianAroundZero(rotationDiff - PI * 1.5)) { - textBaseline = onLeft ? 'top' : 'bottom'; - textAlign = 'center'; - } - else { - textBaseline = 'middle'; - if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) { - textAlign = onLeft ? 'left' : 'right'; - } - else { - textAlign = onLeft ? 'right' : 'left'; - } - } - - return { - rotation: rotationDiff, - textAlign: textAlign, - textBaseline: textBaseline - }; - } - - /** - * @static - */ - var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (axis, i, interval) { - var rawTick; - var scale = axis.scale; - return scale.type === 'ordinal' - && ( - typeof interval === 'function' - ? ( - rawTick = scale.getTicks()[i], - !interval(rawTick, scale.getLabel(rawTick)) - ) - : i % (interval + 1) - ); - }; - - /** - * @static - */ - var getInterval = AxisBuilder.getInterval = function (model, labelInterval) { - var interval = model.get('interval'); - if (interval == null || interval == 'auto') { - interval = labelInterval; - } - return interval; - }; - - return AxisBuilder; + var PI = Math.PI; -}); -define('echarts/component/axis/AxisView',['require','zrender/core/util','../../util/graphic','./AxisBuilder','../../echarts'],function (require) { - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var AxisBuilder = require('./AxisBuilder'); - var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick; - var getInterval = AxisBuilder.getInterval; - - var axisBuilderAttrs = [ - 'axisLine', 'axisLabel', 'axisTick', 'axisName' - ]; - var selfBuilderAttrs = [ - 'splitLine', 'splitArea' - ]; - - var AxisView = require('../../echarts').extendComponentView({ - - type: 'axis', - - render: function (axisModel, ecModel) { - - this.group.removeAll(); - - if (!axisModel.get('show')) { - return; - } - - var gridModel = ecModel.getComponent('grid', axisModel.get('gridIndex')); - - var layout = layoutAxis(gridModel, axisModel); - - var axisBuilder = new AxisBuilder(axisModel, layout); - - zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder); - - this.group.add(axisBuilder.getGroup()); - - zrUtil.each(selfBuilderAttrs, function (name) { - if (axisModel.get(name +'.show')) { - this['_' + name](axisModel, gridModel, layout.labelInterval); - } - }, this); - }, - - /** - * @param {module:echarts/coord/cartesian/AxisModel} axisModel - * @param {module:echarts/coord/cartesian/GridModel} gridModel - * @param {number|Function} labelInterval - * @private - */ - _splitLine: function (axisModel, gridModel, labelInterval) { - var axis = axisModel.axis; - - var splitLineModel = axisModel.getModel('splitLine'); - var lineStyleModel = splitLineModel.getModel('lineStyle'); - var lineWidth = lineStyleModel.get('width'); - var lineColors = lineStyleModel.get('color'); - - var lineInterval = getInterval(splitLineModel, labelInterval); - - lineColors = lineColors instanceof Array ? lineColors : [lineColors]; - - var gridRect = gridModel.coordinateSystem.getRect(); - var isHorizontal = axis.isHorizontal(); - - var splitLines = []; - var lineCount = 0; - - var ticksCoords = axis.getTicksCoords(); - - var p1 = []; - var p2 = []; - for (var i = 0; i < ticksCoords.length; i++) { - if (ifIgnoreOnTick(axis, i, lineInterval)) { - continue; - } - - var tickCoord = axis.toGlobalCoord(ticksCoords[i]); - - if (isHorizontal) { - p1[0] = tickCoord; - p1[1] = gridRect.y; - p2[0] = tickCoord; - p2[1] = gridRect.y + gridRect.height; - } - else { - p1[0] = gridRect.x; - p1[1] = tickCoord; - p2[0] = gridRect.x + gridRect.width; - p2[1] = tickCoord; - } - - var colorIndex = (lineCount++) % lineColors.length; - splitLines[colorIndex] = splitLines[colorIndex] || []; - splitLines[colorIndex].push(new graphic.Line(graphic.subPixelOptimizeLine({ - shape: { - x1: p1[0], - y1: p1[1], - x2: p2[0], - y2: p2[1] - }, - style: { - lineWidth: lineWidth - }, - silent: true - }))); - } - - // Simple optimization - // Batching the lines if color are the same - for (var i = 0; i < splitLines.length; i++) { - this.group.add(graphic.mergePath(splitLines[i], { - style: { - stroke: lineColors[i % lineColors.length], - lineDash: lineStyleModel.getLineDash(), - lineWidth: lineWidth - }, - silent: true - })); - } - }, - - /** - * @param {module:echarts/coord/cartesian/AxisModel} axisModel - * @param {module:echarts/coord/cartesian/GridModel} gridModel - * @param {number|Function} labelInterval - * @private - */ - _splitArea: function (axisModel, gridModel, labelInterval) { - var axis = axisModel.axis; - - var splitAreaModel = axisModel.getModel('splitArea'); - var areaColors = splitAreaModel.get('areaStyle.color'); - - var gridRect = gridModel.coordinateSystem.getRect(); - var ticksCoords = axis.getTicksCoords(); - - var prevX = axis.toGlobalCoord(ticksCoords[0]); - var prevY = axis.toGlobalCoord(ticksCoords[0]); - - var splitAreaRects = []; - var count = 0; - - var areaInterval = getInterval(splitAreaModel, labelInterval); - - areaColors = areaColors instanceof Array ? areaColors : [areaColors]; - - for (var i = 1; i < ticksCoords.length; i++) { - if (ifIgnoreOnTick(axis, i, areaInterval)) { - continue; - } - - var tickCoord = axis.toGlobalCoord(ticksCoords[i]); - - var x; - var y; - var width; - var height; - if (axis.isHorizontal()) { - x = prevX; - y = gridRect.y; - width = tickCoord - x; - height = gridRect.height; - } - else { - x = gridRect.x; - y = prevY; - width = gridRect.width; - height = tickCoord - y; - } - - var colorIndex = (count++) % areaColors.length; - splitAreaRects[colorIndex] = splitAreaRects[colorIndex] || []; - splitAreaRects[colorIndex].push(new graphic.Rect({ - shape: { - x: x, - y: y, - width: width, - height: height - }, - silent: true - })); - - prevX = x + width; - prevY = y + height; - } - - // Simple optimization - // Batching the rects if color are the same - for (var i = 0; i < splitAreaRects.length; i++) { - this.group.add(graphic.mergePath(splitAreaRects[i], { - style: { - fill: areaColors[i % areaColors.length] - }, - silent: true - })); - } - } - }); - - AxisView.extend({ - type: 'xAxis' - }); - AxisView.extend({ - type: 'yAxis' - }); - - /** - * @inner - */ - function layoutAxis(gridModel, axisModel) { - var grid = gridModel.coordinateSystem; - var axis = axisModel.axis; - var layout = {}; - - var rawAxisPosition = axis.position; - var axisPosition = axis.onZero ? 'onZero' : rawAxisPosition; - var axisDim = axis.dim; - - // [left, right, top, bottom] - var rect = grid.getRect(); - var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height]; - - var posMap = { - x: {top: rectBound[2], bottom: rectBound[3]}, - y: {left: rectBound[0], right: rectBound[1]} - }; - posMap.x.onZero = Math.max(Math.min(getZero('y'), posMap.x.bottom), posMap.x.top); - posMap.y.onZero = Math.max(Math.min(getZero('x'), posMap.y.right), posMap.y.left); - - function getZero(dim, val) { - var theAxis = grid.getAxis(dim); - return theAxis.toGlobalCoord(theAxis.dataToCoord(0)); - } - - // Axis position - layout.position = [ - axisDim === 'y' ? posMap.y[axisPosition] : rectBound[0], - axisDim === 'x' ? posMap.x[axisPosition] : rectBound[3] - ]; - - // Axis rotation - var r = {x: 0, y: 1}; - layout.rotation = Math.PI / 2 * r[axisDim]; - - // Tick and label direction, x y is axisDim - var dirMap = {top: -1, bottom: 1, left: -1, right: 1}; - - layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition]; - if (axis.onZero) { - layout.labelOffset = posMap[axisDim][rawAxisPosition] - posMap[axisDim].onZero; - } - - if (axisModel.getModel('axisTick').get('inside')) { - layout.tickDirection = -layout.tickDirection; - } - if (axisModel.getModel('axisLabel').get('inside')) { - layout.labelDirection = -layout.labelDirection; - } - - // Special label rotation - var labelRotation = axisModel.getModel('axisLabel').get('rotate'); - layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation; - - // label interval when auto mode. - layout.labelInterval = axis.getLabelInterval(); - - // Over splitLine and splitArea - layout.z2 = 1; - - return layout; - } -}); -// TODO boundaryGap -define('echarts/component/axis',['require','../coord/cartesian/AxisModel','./axis/AxisView'],function(require) { - + function Parallel(parallelModel, ecModel, api) { - require('../coord/cartesian/AxisModel'); + /** + * key: dimension + * @type {Object.} + * @private + */ + this._axesMap = {}; - require('./axis/AxisView'); -}); -define('echarts/component/grid',['require','../util/graphic','zrender/core/util','../coord/cartesian/Grid','./axis','../echarts'],function(require) { - - - var graphic = require('../util/graphic'); - var zrUtil = require('zrender/core/util'); - - require('../coord/cartesian/Grid'); - - require('./axis'); - - // Grid view - require('../echarts').extendComponentView({ - - type: 'grid', - - render: function (gridModel, ecModel) { - this.group.removeAll(); - if (gridModel.get('show')) { - this.group.add(new graphic.Rect({ - shape:gridModel.coordinateSystem.getRect(), - style: zrUtil.defaults({ - fill: gridModel.get('backgroundColor') - }, gridModel.getItemStyle()), - silent: true - })); - } - } - }); -}); -/** - * Data selectable mixin for chart series. - * To eanble data select, option of series must have `selectedMode`. - * And each data item will use `selected` to toggle itself selected status - * - * @module echarts/chart/helper/DataSelectable - */ -define('echarts/chart/helper/dataSelectableMixin',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - return { - - updateSelectedMap: function () { - var option = this.option; - this._dataOptMap = zrUtil.reduce(option.data, function (dataOptMap, dataOpt) { - dataOptMap[dataOpt.name] = dataOpt; - return dataOptMap; - }, {}); - }, - /** - * @param {string} name - */ - // PENGING If selectedMode is null ? - select: function (name) { - var dataOptMap = this._dataOptMap; - var dataOpt = dataOptMap[name]; - var selectedMode = this.get('selectedMode'); - if (selectedMode === 'single') { - zrUtil.each(dataOptMap, function (dataOpt) { - dataOpt.selected = false; - }); - } - dataOpt && (dataOpt.selected = true); - }, - - /** - * @param {string} name - */ - unSelect: function (name) { - var dataOpt = this._dataOptMap[name]; - // var selectedMode = this.get('selectedMode'); - // selectedMode !== 'single' && dataOpt && (dataOpt.selected = false); - dataOpt && (dataOpt.selected = false); - }, - - /** - * @param {string} name - */ - toggleSelected: function (name) { - var dataOpt = this._dataOptMap[name]; - if (dataOpt != null) { - this[dataOpt.selected ? 'unSelect' : 'select'](name); - return dataOpt.selected; - } - }, - - /** - * @param {string} name - */ - isSelected: function (name) { - var dataOpt = this._dataOptMap[name]; - return dataOpt && dataOpt.selected; - } - }; -}); -define('echarts/chart/pie/PieSeries',['require','../../data/List','zrender/core/util','../../util/model','../../data/helper/completeDimensions','../helper/dataSelectableMixin','../../echarts'],function(require) { - - - - var List = require('../../data/List'); - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../../util/model'); - var completeDimensions = require('../../data/helper/completeDimensions'); - - var dataSelectableMixin = require('../helper/dataSelectableMixin'); - - var PieSeries = require('../../echarts').extendSeriesModel({ - - type: 'series.pie', - - // Overwrite - init: function (option) { - PieSeries.superApply(this, 'init', arguments); - - // Enable legend selection for each data item - // Use a function instead of direct access because data reference may changed - this.legendDataProvider = function () { - return this._dataBeforeProcessed; - }; - - this.updateSelectedMap(); - - this._defaultLabelLine(option); - }, - - // Overwrite - mergeOption: function (newOption) { - PieSeries.superCall(this, 'mergeOption', newOption); - this.updateSelectedMap(); - }, - - getInitialData: function (option, ecModel) { - var dimensions = completeDimensions(['value'], option.data); - var list = new List(dimensions, this); - list.initData(option.data); - return list; - }, - - // Overwrite - getDataParams: function (dataIndex) { - var data = this._data; - var params = PieSeries.superCall(this, 'getDataParams', dataIndex); - var sum = data.getSum('value'); - // FIXME toFixed? - // - // Percent is 0 if sum is 0 - params.percent = !sum ? 0 : +(data.get('value', dataIndex) / sum * 100).toFixed(2); - - params.$vars.push('percent'); - return params; - }, - - _defaultLabelLine: function (option) { - // Extend labelLine emphasis - modelUtil.defaultEmphasis(option.labelLine, ['show']); - - var labelLineNormalOpt = option.labelLine.normal; - var labelLineEmphasisOpt = option.labelLine.emphasis; - // Not show label line if `label.normal.show = false` - labelLineNormalOpt.show = labelLineNormalOpt.show - && option.label.normal.show; - labelLineEmphasisOpt.show = labelLineEmphasisOpt.show - && option.label.emphasis.show; - }, - - defaultOption: { - zlevel: 0, - z: 2, - legendHoverLink: true, - - hoverAnimation: true, - // 默认全局居中 - center: ['50%', '50%'], - radius: [0, '75%'], - // 默认顺时针 - clockwise: true, - startAngle: 90, - // 最小角度改为0 - minAngle: 0, - // 选中是扇区偏移量 - selectedOffset: 10, - - // If use strategy to avoid label overlapping - avoidLabelOverlap: true, - // 选择模式,默认关闭,可选single,multiple - // selectedMode: false, - // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积) - // roseType: null, - - label: { - normal: { - // If rotate around circle - rotate: false, - show: true, - // 'outer', 'inside', 'center' - position: 'outer' - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数 - }, - emphasis: {} - }, - // Enabled when label.normal.position is 'outer' - labelLine: { - normal: { - show: true, - // 引导线两段中的第一段长度 - length: 20, - // 引导线两段中的第二段长度 - length2: 5, - smooth: false, - lineStyle: { - // color: 各异, - width: 1, - type: 'solid' - } - } - }, - itemStyle: { - normal: { - // color: 各异, - borderColor: 'rgba(0,0,0,0)', - borderWidth: 1 - }, - emphasis: { - // color: 各异, - borderColor: 'rgba(0,0,0,0)', - borderWidth: 1 - } - }, - - animationEasing: 'cubicOut', - - data: [] - } - }); - - zrUtil.mixin(PieSeries, dataSelectableMixin); - - return PieSeries; -}); -define('echarts/chart/pie/PieView',['require','../../util/graphic','zrender/core/util','../../view/Chart'],function (require) { - - var graphic = require('../../util/graphic'); - var zrUtil = require('zrender/core/util'); - - /** - * @param {module:echarts/model/Series} seriesModel - * @param {boolean} hasAnimation - * @inner - */ - function updateDataSelected(uid, seriesModel, hasAnimation, api) { - var data = seriesModel.getData(); - var dataIndex = this.dataIndex; - var name = data.getName(dataIndex); - var selectedOffset = seriesModel.get('selectedOffset'); - - api.dispatchAction({ - type: 'pieToggleSelect', - from: uid, - name: name, - seriesId: seriesModel.id - }); - - data.each(function (idx) { - toggleItemSelected( - data.getItemGraphicEl(idx), - data.getItemLayout(idx), - seriesModel.isSelected(data.getName(idx)), - selectedOffset, - hasAnimation - ); - }); - } - - /** - * @param {module:zrender/graphic/Sector} el - * @param {Object} layout - * @param {boolean} isSelected - * @param {number} selectedOffset - * @param {boolean} hasAnimation - * @inner - */ - function toggleItemSelected(el, layout, isSelected, selectedOffset, hasAnimation) { - var midAngle = (layout.startAngle + layout.endAngle) / 2; - - var dx = Math.cos(midAngle); - var dy = Math.sin(midAngle); - - var offset = isSelected ? selectedOffset : 0; - var position = [dx * offset, dy * offset]; - - hasAnimation - // animateTo will stop revious animation like update transition - ? el.animate() - .when(200, { - position: position - }) - .start('bounceOut') - : el.attr('position', position); - } - - /** - * Piece of pie including Sector, Label, LabelLine - * @constructor - * @extends {module:zrender/graphic/Group} - */ - function PiePiece(data, idx) { - - graphic.Group.call(this); - - var sector = new graphic.Sector({ - z2: 2 - }); - var polyline = new graphic.Polyline(); - var text = new graphic.Text(); - this.add(sector); - this.add(polyline); - this.add(text); - - this.updateData(data, idx, true); - - // Hover to change label and labelLine - function onEmphasis() { - polyline.ignore = polyline.hoverIgnore; - text.ignore = text.hoverIgnore; - } - function onNormal() { - polyline.ignore = polyline.normalIgnore; - text.ignore = text.normalIgnore; - } - this.on('emphasis', onEmphasis) - .on('normal', onNormal) - .on('mouseover', onEmphasis) - .on('mouseout', onNormal); - } - - var piePieceProto = PiePiece.prototype; - - function getLabelStyle(data, idx, state, labelModel) { - var textStyleModel = labelModel.getModel('textStyle'); - var position = labelModel.get('position'); - var isLabelInside = position === 'inside' || position === 'inner'; - return { - fill: textStyleModel.getTextColor() - || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')), - textFont: textStyleModel.getFont(), - text: zrUtil.retrieve( - data.hostModel.getFormattedLabel(idx, state), data.getName(idx) - ) - }; - } - - piePieceProto.updateData = function (data, idx, firstCreate) { - - var sector = this.childAt(0); - - var seriesModel = data.hostModel; - var itemModel = data.getItemModel(idx); - var layout = data.getItemLayout(idx); - var sectorShape = zrUtil.extend({}, layout); - sectorShape.label = null; - if (firstCreate) { - sector.setShape(sectorShape); - sector.shape.endAngle = layout.startAngle; - graphic.updateProps(sector, { - shape: { - endAngle: layout.endAngle - } - }, seriesModel); - } - else { - graphic.updateProps(sector, { - shape: sectorShape - }, seriesModel); - } - - // Update common style - var itemStyleModel = itemModel.getModel('itemStyle'); - var visualColor = data.getItemVisual(idx, 'color'); - - sector.setStyle( - zrUtil.defaults( - { - fill: visualColor - }, - itemStyleModel.getModel('normal').getItemStyle() - ) - ); - sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle(); - - // Toggle selected - toggleItemSelected( - this, - data.getItemLayout(idx), - itemModel.get('selected'), - seriesModel.get('selectedOffset'), - seriesModel.get('animation') - ); - - function onEmphasis() { - // Sector may has animation of updating data. Force to move to the last frame - // Or it may stopped on the wrong shape - sector.stopAnimation(true); - sector.animateTo({ - shape: { - r: layout.r + 10 - } - }, 300, 'elasticOut'); - } - function onNormal() { - sector.stopAnimation(true); - sector.animateTo({ - shape: { - r: layout.r - } - }, 300, 'elasticOut'); - } - sector.off('mouseover').off('mouseout').off('emphasis').off('normal'); - if (itemModel.get('hoverAnimation')) { - sector - .on('mouseover', onEmphasis) - .on('mouseout', onNormal) - .on('emphasis', onEmphasis) - .on('normal', onNormal); - } - - this._updateLabel(data, idx); - - graphic.setHoverStyle(this); - }; - - piePieceProto._updateLabel = function (data, idx) { - - var labelLine = this.childAt(1); - var labelText = this.childAt(2); - - var seriesModel = data.hostModel; - var itemModel = data.getItemModel(idx); - var layout = data.getItemLayout(idx); - var labelLayout = layout.label; - var visualColor = data.getItemVisual(idx, 'color'); - - graphic.updateProps(labelLine, { - shape: { - points: labelLayout.linePoints || [ - [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y] - ] - } - }, seriesModel); - - graphic.updateProps(labelText, { - style: { - x: labelLayout.x, - y: labelLayout.y - } - }, seriesModel); - labelText.attr({ - style: { - textAlign: labelLayout.textAlign, - textBaseline: labelLayout.textBaseline, - textFont: labelLayout.font - }, - rotation: labelLayout.rotation, - origin: [labelLayout.x, labelLayout.y], - z2: 10 - }); - - var labelModel = itemModel.getModel('label.normal'); - var labelHoverModel = itemModel.getModel('label.emphasis'); - var labelLineModel = itemModel.getModel('labelLine.normal'); - var labelLineHoverModel = itemModel.getModel('labelLine.emphasis'); - - labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel)); - - labelText.ignore = labelText.normalIgnore = !labelModel.get('show'); - labelText.hoverIgnore = !labelHoverModel.get('show'); - - labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show'); - labelLine.hoverIgnore = !labelLineHoverModel.get('show'); - - // Default use item visual color - labelLine.setStyle({ - stroke: visualColor - }); - labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle()); - - labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel); - labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle(); - - var smooth = labelLineModel.get('smooth'); - if (smooth && smooth === true) { - smooth = 0.4; - } - labelLine.setShape({ - smooth: smooth - }); - }; - - zrUtil.inherits(PiePiece, graphic.Group); - - - // Pie view - var Pie = require('../../view/Chart').extend({ - - type: 'pie', - - init: function () { - var sectorGroup = new graphic.Group(); - this._sectorGroup = sectorGroup; - }, - - render: function (seriesModel, ecModel, api, payload) { - if (payload && (payload.from === this.uid)) { - return; - } - - var data = seriesModel.getData(); - var oldData = this._data; - var group = this.group; - - var hasAnimation = ecModel.get('animation'); - var isFirstRender = !oldData; - - var onSectorClick = zrUtil.curry( - updateDataSelected, this.uid, seriesModel, hasAnimation, api - ); - - var selectedMode = seriesModel.get('selectedMode'); - - data.diff(oldData) - .add(function (idx) { - var piePiece = new PiePiece(data, idx); - if (isFirstRender) { - piePiece.eachChild(function (child) { - child.stopAnimation(true); - }); - } - - selectedMode && piePiece.on('click', onSectorClick); - - data.setItemGraphicEl(idx, piePiece); - - group.add(piePiece); - }) - .update(function (newIdx, oldIdx) { - var piePiece = oldData.getItemGraphicEl(oldIdx); - - piePiece.updateData(data, newIdx); - - piePiece.off('click'); - selectedMode && piePiece.on('click', onSectorClick); - group.add(piePiece); - data.setItemGraphicEl(newIdx, piePiece); - }) - .remove(function (idx) { - var piePiece = oldData.getItemGraphicEl(idx); - group.remove(piePiece); - }) - .execute(); - - if (hasAnimation && isFirstRender && data.count() > 0) { - var shape = data.getItemLayout(0); - var r = Math.max(api.getWidth(), api.getHeight()) / 2; - - var removeClipPath = zrUtil.bind(group.removeClipPath, group); - group.setClipPath(this._createClipPath( - shape.cx, shape.cy, r, shape.startAngle, shape.clockwise, removeClipPath, seriesModel - )); - } - - this._data = data; - }, - - _createClipPath: function ( - cx, cy, r, startAngle, clockwise, cb, seriesModel - ) { - var clipPath = new graphic.Sector({ - shape: { - cx: cx, - cy: cy, - r0: 0, - r: r, - startAngle: startAngle, - endAngle: startAngle, - clockwise: clockwise - } - }); - - graphic.initProps(clipPath, { - shape: { - endAngle: startAngle + (clockwise ? 1 : -1) * Math.PI * 2 - } - }, seriesModel, cb); - - return clipPath; - } - }); - - return Pie; -}); -define('echarts/action/createDataSelectAction',['require','../echarts','zrender/core/util'],function (require) { - var echarts = require('../echarts'); - var zrUtil = require('zrender/core/util'); - return function (seriesType, actionInfos) { - zrUtil.each(actionInfos, function (actionInfo) { - actionInfo.update = 'updateView'; - /** - * @payload - * @property {string} seriesName - * @property {string} name - */ - echarts.registerAction(actionInfo, function (payload, ecModel) { - var selected = {}; - ecModel.eachComponent( - {mainType: 'series', subType: seriesType, query: payload}, - function (seriesModel) { - if (seriesModel[actionInfo.method]) { - seriesModel[actionInfo.method](payload.name); - } - var data = seriesModel.getData(); - // Create selected map - data.each(function (idx) { - var name = data.getName(idx); - selected[name] = seriesModel.isSelected(name) || false; - }); - } - ); - return { - name: payload.name, - selected: selected - }; - }); - }); - }; -}); -// Pick color from palette for each data item -define('echarts/visual/dataColor',['require'],function (require) { - - return function (seriesType, ecModel) { - var globalColorList = ecModel.get('color'); - var offset = 0; - ecModel.eachRawSeriesByType(seriesType, function (seriesModel) { - var colorList = seriesModel.get('color', true); - var dataAll = seriesModel.getRawData(); - if (!ecModel.isSeriesFiltered(seriesModel)) { - var data = seriesModel.getData(); - data.each(function (idx) { - var itemModel = data.getItemModel(idx); - var rawIdx = data.getRawIndex(idx); - // If series.itemStyle.normal.color is a function. itemVisual may be encoded - var singleDataColor = data.getItemVisual(idx, 'color', true); - if (!singleDataColor) { - var paletteColor = colorList ? colorList[rawIdx % colorList.length] - : globalColorList[(rawIdx + offset) % globalColorList.length]; - var color = itemModel.get('itemStyle.normal.color') || paletteColor; - // Legend may use the visual info in data before processed - dataAll.setItemVisual(rawIdx, 'color', color); - data.setItemVisual(idx, 'color', color); - } - else { - // Set data all color for legend - dataAll.setItemVisual(rawIdx, 'color', singleDataColor); - } - }); - } - offset += dataAll.count(); - }); - }; -}); -// FIXME emphasis label position is not same with normal label position -define('echarts/chart/pie/labelLayout',['require','zrender/contain/text'],function (require) { - - - - var textContain = require('zrender/contain/text'); - - function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) { - list.sort(function (a, b) { - return a.y - b.y; - }); - - // 压 - function shiftDown(start, end, delta, dir) { - for (var j = start; j < end; j++) { - list[j].y += delta; - if (j > start - && j + 1 < end - && list[j + 1].y > list[j].y + list[j].height - ) { - shiftUp(j, delta / 2); - return; - } - } - - shiftUp(end - 1, delta / 2); - } - - // 弹 - function shiftUp(end, delta) { - for (var j = end; j >= 0; j--) { - list[j].y -= delta; - if (j > 0 - && list[j].y > list[j - 1].y + list[j - 1].height - ) { - break; - } - } - } - - // function changeX(list, isDownList, cx, cy, r, dir) { - // var deltaX; - // var deltaY; - // var length; - // var lastDeltaX = dir > 0 - // ? isDownList // 右侧 - // ? Number.MAX_VALUE // 下 - // : 0 // 上 - // : isDownList // 左侧 - // ? Number.MAX_VALUE // 下 - // : 0; // 上 - - // for (var i = 0, l = list.length; i < l; i++) { - // deltaY = Math.abs(list[i].y - cy); - // length = list[i].length; - // deltaX = (deltaY < r + length) - // ? Math.sqrt( - // (r + length + 20) * (r + length + 20) - // - Math.pow(list[i].y - cy, 2) - // ) - // : Math.abs( - // list[i].x - cx - // ); - // if (isDownList && deltaX >= lastDeltaX) { - // // 右下,左下 - // deltaX = lastDeltaX - 10; - // } - // if (!isDownList && deltaX <= lastDeltaX) { - // // 右上,左上 - // deltaX = lastDeltaX + 10; - // } - - // list[i].x = cx + deltaX * dir; - // lastDeltaX = deltaX; - // } - // } - - var lastY = 0; - var delta; - var len = list.length; - var upList = []; - var downList = []; - for (var i = 0; i < len; i++) { - delta = list[i].y - lastY; - if (delta < 0) { - shiftDown(i, len, -delta, dir); - } - lastY = list[i].y + list[i].height; - } - if (viewHeight - lastY < 0) { - shiftUp(len - 1, lastY - viewHeight); - } - for (var i = 0; i < len; i++) { - if (list[i].y >= cy) { - downList.push(list[i]); - } - else { - upList.push(list[i]); - } - } - // changeX(downList, true, cx, cy, r, dir); - // changeX(upList, false, cx, cy, r, dir); - } - - function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) { - var leftList = []; - var rightList = []; - for (var i = 0; i < labelLayoutList.length; i++) { - if (labelLayoutList[i].x < cx) { - leftList.push(labelLayoutList[i]); - } - else { - rightList.push(labelLayoutList[i]); - } - } - - adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight); - adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight); - - for (var i = 0; i < labelLayoutList.length; i++) { - var linePoints = labelLayoutList[i].linePoints; - if (linePoints) { - if (labelLayoutList[i].x < cx) { - linePoints[2][0] = labelLayoutList[i].x + 3; - } - else { - linePoints[2][0] = labelLayoutList[i].x - 3; - } - linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y; - } - } - } - - return function (seriesModel, r, viewWidth, viewHeight) { - var data = seriesModel.getData(); - var labelLayoutList = []; - var cx; - var cy; - var hasLabelRotate = false; - - data.each(function (idx) { - var layout = data.getItemLayout(idx); - - var itemModel = data.getItemModel(idx); - var labelModel = itemModel.getModel('label.normal'); - var labelPosition = labelModel.get('position'); - - var labelLineModel = itemModel.getModel('labelLine.normal'); - var labelLineLen = labelLineModel.get('length'); - var labelLineLen2 = labelLineModel.get('length2'); - - var midAngle = (layout.startAngle + layout.endAngle) / 2; - var dx = Math.cos(midAngle); - var dy = Math.sin(midAngle); - - var textX; - var textY; - var linePoints; - var textAlign; - - cx = layout.cx; - cy = layout.cy; - - if (labelPosition === 'center') { - textX = layout.cx; - textY = layout.cy; - textAlign = 'center'; - } - else { - var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner'; - var x1 = (isLabelInside ? layout.r / 2 * dx : layout.r * dx) + cx; - var y1 = (isLabelInside ? layout.r / 2 * dy : layout.r * dy) + cy; - - // For roseType - labelLineLen += r - layout.r; - - textX = x1 + dx * 3; - textY = y1 + dy * 3; - - if (!isLabelInside) { - var x2 = x1 + dx * labelLineLen; - var y2 = y1 + dy * labelLineLen; - var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2); - var y3 = y2; - - textX = x3 + (dx < 0 ? -5 : 5); - textY = y3; - linePoints = [[x1, y1], [x2, y2], [x3, y3]]; - } - - textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right'); - } - var textBaseline = 'middle'; - var font = labelModel.getModel('textStyle').getFont(); - - var labelRotate = labelModel.get('rotate') - ? (dx < 0 ? -midAngle + Math.PI : -midAngle) : 0; - var text = seriesModel.getFormattedLabel(idx, 'normal') - || data.getName(idx); - var textRect = textContain.getBoundingRect( - text, font, textAlign, textBaseline - ); - hasLabelRotate = !!labelRotate; - layout.label = { - x: textX, - y: textY, - height: textRect.height, - length: labelLineLen, - length2: labelLineLen2, - linePoints: linePoints, - textAlign: textAlign, - textBaseline: textBaseline, - font: font, - rotation: labelRotate - }; - - labelLayoutList.push(layout.label); - }); - if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) { - avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight); - } - }; -}); -// TODO minAngle - -define('echarts/chart/pie/pieLayout',['require','../../util/number','./labelLayout','zrender/core/util'],function (require) { - - var numberUtil = require('../../util/number'); - var parsePercent = numberUtil.parsePercent; - var labelLayout = require('./labelLayout'); - var zrUtil = require('zrender/core/util'); - - var PI2 = Math.PI * 2; - var RADIAN = Math.PI / 180; - - return function (seriesType, ecModel, api) { - ecModel.eachSeriesByType(seriesType, function (seriesModel) { - var center = seriesModel.get('center'); - var radius = seriesModel.get('radius'); - - if (!zrUtil.isArray(radius)) { - radius = [0, radius]; - } - if (!zrUtil.isArray(center)) { - center = [center, center]; - } - - var width = api.getWidth(); - var height = api.getHeight(); - var size = Math.min(width, height); - var cx = parsePercent(center[0], width); - var cy = parsePercent(center[1], height); - var r0 = parsePercent(radius[0], size / 2); - var r = parsePercent(radius[1], size / 2); - - var data = seriesModel.getData(); - - var startAngle = -seriesModel.get('startAngle') * RADIAN; - - var minAngle = seriesModel.get('minAngle') * RADIAN; - - var sum = data.getSum('value'); - // Sum may be 0 - var unitRadian = Math.PI / (sum || data.count()) * 2; - - var clockwise = seriesModel.get('clockwise'); - - var roseType = seriesModel.get('roseType'); - - // [0...max] - var extent = data.getDataExtent('value'); - extent[0] = 0; - - // In the case some sector angle is smaller than minAngle - var restAngle = PI2; - var valueSumLargerThanMinAngle = 0; - - var currentAngle = startAngle; - - var dir = clockwise ? 1 : -1; - data.each('value', function (value, idx) { - var angle; - // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样? - if (roseType !== 'area') { - angle = sum === 0 ? unitRadian : (value * unitRadian); - } - else { - angle = PI2 / (data.count() || 1); - } - - if (angle < minAngle) { - angle = minAngle; - restAngle -= minAngle; - } - else { - valueSumLargerThanMinAngle += value; - } - - var endAngle = currentAngle + dir * angle; - data.setItemLayout(idx, { - angle: angle, - startAngle: currentAngle, - endAngle: endAngle, - clockwise: clockwise, - cx: cx, - cy: cy, - r0: r0, - r: roseType - ? numberUtil.linearMap(value, extent, [r0, r]) - : r - }); - - currentAngle = endAngle; - }, true); - - // Some sector is constrained by minAngle - // Rest sectors needs recalculate angle - if (restAngle < PI2) { - // Average the angle if rest angle is not enough after all angles is - // Constrained by minAngle - if (restAngle <= 1e-3) { - var angle = PI2 / data.count(); - data.each(function (idx) { - var layout = data.getItemLayout(idx); - layout.startAngle = startAngle + dir * idx * angle; - layout.endAngle = startAngle + dir * (idx + 1) * angle; - }); - } - else { - unitRadian = restAngle / valueSumLargerThanMinAngle; - currentAngle = startAngle; - data.each('value', function (value, idx) { - var layout = data.getItemLayout(idx); - var angle = layout.angle === minAngle - ? minAngle : value * unitRadian; - layout.startAngle = currentAngle; - layout.endAngle = currentAngle + dir * angle; - currentAngle += angle; - }); - } - } - - labelLayout(seriesModel, r, width, height); - }); - }; -}); -define('echarts/processor/dataFilter',[],function () { - return function (seriesType, ecModel) { - var legendModels = ecModel.findComponents({ - mainType: 'legend' - }); - if (!legendModels || !legendModels.length) { - return; - } - ecModel.eachSeriesByType(seriesType, function (series) { - var data = series.getData(); - data.filterSelf(function (idx) { - var name = data.getName(idx); - // If in any legend component the status is not selected. - for (var i = 0; i < legendModels.length; i++) { - if (!legendModels[i].isSelected(name)) { - return false; - } - } - return true; - }, this); - }, this); - }; -}); -define('echarts/chart/pie',['require','zrender/core/util','../echarts','./pie/PieSeries','./pie/PieView','../action/createDataSelectAction','../visual/dataColor','./pie/pieLayout','../processor/dataFilter'],function (require) { - - var zrUtil = require('zrender/core/util'); - var echarts = require('../echarts'); - - require('./pie/PieSeries'); - require('./pie/PieView'); - - require('../action/createDataSelectAction')('pie', [{ - type: 'pieToggleSelect', - event: 'pieselectchanged', - method: 'toggleSelected' - }, { - type: 'pieSelect', - event: 'pieselected', - method: 'select' - }, { - type: 'pieUnSelect', - event: 'pieunselected', - method: 'unSelect' - }]); - - echarts.registerVisualCoding( - 'chart', zrUtil.curry(require('../visual/dataColor'), 'pie') - ); - - echarts.registerLayout(zrUtil.curry( - require('./pie/pieLayout'), 'pie' - )); - - echarts.registerProcessor( - 'filter', zrUtil.curry(require('../processor/dataFilter'), 'pie') - ); -}); -define('echarts/chart/scatter/ScatterSeries',['require','../helper/createListFromArray','../../model/Series'],function (require) { - - - - var createListFromArray = require('../helper/createListFromArray'); - var SeriesModel = require('../../model/Series'); - - return SeriesModel.extend({ - - type: 'series.scatter', - - dependencies: ['grid', 'polar'], - - getInitialData: function (option, ecModel) { - var list = createListFromArray(option.data, this, ecModel); - return list; - }, - - defaultOption: { - coordinateSystem: 'cartesian2d', - zlevel: 0, - z: 2, - legendHoverLink: true, - - hoverAnimation: true, - // Cartesian coordinate system - xAxisIndex: 0, - yAxisIndex: 0, - - // Polar coordinate system - polarIndex: 0, - - // Geo coordinate system - geoIndex: 0, - - // symbol: null, // 图形类型 - symbolSize: 10, // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2 - // symbolRotate: null, // 图形旋转控制 - - large: false, - // Available when large is true - largeThreshold: 2000, - - // label: { - // normal: { - // show: false - // distance: 5, - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 - // 'inside'|'left'|'right'|'top'|'bottom' - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - // } - // }, - itemStyle: { - normal: { - opacity: 0.8 - // color: 各异 - } - } - } - }); -}); -define('echarts/chart/helper/LargeSymbolDraw',['require','../../util/graphic','../../util/symbol','zrender/core/util'],function (require) { - - var graphic = require('../../util/graphic'); - var symbolUtil = require('../../util/symbol'); - var zrUtil = require('zrender/core/util'); - - var LargeSymbolPath = graphic.extendShape({ - shape: { - points: null, - sizes: null - }, - - symbolProxy: null, - - buildPath: function (path, shape) { - var points = shape.points; - var sizes = shape.sizes; - - var symbolProxy = this.symbolProxy; - var symbolProxyShape = symbolProxy.shape; - for (var i = 0; i < points.length; i++) { - var pt = points[i]; - var size = sizes[i]; - if (size[0] < 4) { - // Optimize for small symbol - path.rect( - pt[0] - size[0] / 2, pt[1] - size[1] / 2, - size[0], size[1] - ); - } - else { - symbolProxyShape.x = pt[0] - size[0] / 2; - symbolProxyShape.y = pt[1] - size[1] / 2; - symbolProxyShape.width = size[0]; - symbolProxyShape.height = size[1]; - - symbolProxy.buildPath(path, symbolProxyShape); - } - } - } - }); - - function LargeSymbolDraw() { - this.group = new graphic.Group(); - - this._symbolEl = new LargeSymbolPath({ - silent: true - }); - } - - var largeSymbolProto = LargeSymbolDraw.prototype; - - /** - * Update symbols draw by new data - * @param {module:echarts/data/List} data - */ - largeSymbolProto.updateData = function (data) { - this.group.removeAll(); - - var symbolEl = this._symbolEl; - - var seriesModel = data.hostModel; - - symbolEl.setShape({ - points: data.mapArray(data.getItemLayout), - sizes: data.mapArray( - function (idx) { - var size = data.getItemVisual(idx, 'symbolSize'); - if (!zrUtil.isArray(size)) { - size = [size, size]; - } - return size; - } - ) - }); - - // Create symbolProxy to build path for each data - symbolEl.symbolProxy = symbolUtil.createSymbol( - data.getVisual('symbol'), 0, 0, 0, 0 - ); - // Use symbolProxy setColor method - symbolEl.setColor = symbolEl.symbolProxy.setColor; - - symbolEl.setStyle( - seriesModel.getModel('itemStyle.normal').getItemStyle(['color']) - ); - - var visualColor = data.getVisual('color'); - if (visualColor) { - symbolEl.setColor(visualColor); - } - - // Add back - this.group.add(this._symbolEl); - }; - - largeSymbolProto.updateLayout = function (seriesModel) { - var data = seriesModel.getData(); - this._symbolEl.setShape({ - points: data.mapArray(data.getItemLayout) - }); - }; - - largeSymbolProto.remove = function () { - this.group.removeAll(); - }; - - return LargeSymbolDraw; -}); -define('echarts/chart/scatter/ScatterView',['require','../helper/SymbolDraw','../helper/LargeSymbolDraw','../../echarts'],function (require) { + /** + * key: dimension + * value: {position: [], rotation, } + * @type {Object.} + * @private + */ + this._axesLayout = {}; - var SymbolDraw = require('../helper/SymbolDraw'); - var LargeSymbolDraw = require('../helper/LargeSymbolDraw'); + /** + * Always follow axis order. + * @type {Array.} + * @readOnly + */ + this.dimensions = parallelModel.dimensions; - require('../../echarts').extendChartView({ + /** + * @type {module:zrender/core/BoundingRect} + */ + this._rect; + + /** + * @type {module:echarts/coord/parallel/ParallelModel} + */ + this._model = parallelModel; + + this._init(parallelModel, ecModel, api); + } + + Parallel.prototype = { + + type: 'parallel', + + constructor: Parallel, + + /** + * Initialize cartesian coordinate systems + * @private + */ + _init: function (parallelModel, ecModel, api) { + + var dimensions = parallelModel.dimensions; + var parallelAxisIndex = parallelModel.parallelAxisIndex; + + each(dimensions, function (dim, idx) { + + var axisIndex = parallelAxisIndex[idx]; + var axisModel = ecModel.getComponent('parallelAxis', axisIndex); + + var axis = this._axesMap[dim] = new ParallelAxis( + dim, + axisHelper.createScaleByModel(axisModel), + [0, 0], + axisModel.get('type'), + axisIndex + ); + + var isCategory = axis.type === 'category'; + axis.onBand = isCategory && axisModel.get('boundaryGap'); + axis.inverse = axisModel.get('inverse'); + + // Inject axis into axisModel + axisModel.axis = axis; + + // Inject axisModel into axis + axis.model = axisModel; + }, this); + }, + + /** + * Update axis scale after data processed + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + */ + update: function (ecModel, api) { + this._updateAxesFromSeries(this._model, ecModel); + }, + + /** + * Update properties from series + * @private + */ + _updateAxesFromSeries: function (parallelModel, ecModel) { + ecModel.eachSeries(function (seriesModel) { + + if (!parallelModel.contains(seriesModel, ecModel)) { + return; + } + + var data = seriesModel.getData(); + + each(this.dimensions, function (dim) { + var axis = this._axesMap[dim]; + axis.scale.unionExtent(data.getDataExtent(dim)); + axisHelper.niceScaleExtent(axis, axis.model); + }, this); + }, this); + }, + + /** + * Resize the parallel coordinate system. + * @param {module:echarts/coord/parallel/ParallelModel} parallelModel + * @param {module:echarts/ExtensionAPI} api + */ + resize: function (parallelModel, api) { + this._rect = layout.getLayoutRect( + parallelModel.getBoxLayoutParams(), + { + width: api.getWidth(), + height: api.getHeight() + } + ); + + this._layoutAxes(parallelModel); + }, + + /** + * @return {module:zrender/core/BoundingRect} + */ + getRect: function () { + return this._rect; + }, + + /** + * @private + */ + _layoutAxes: function (parallelModel) { + var rect = this._rect; + var layout = parallelModel.get('layout'); + var axes = this._axesMap; + var dimensions = this.dimensions; + + var size = [rect.width, rect.height]; + var sizeIdx = layout === 'horizontal' ? 0 : 1; + var layoutLength = size[sizeIdx]; + var axisLength = size[1 - sizeIdx]; + var axisExtent = [0, axisLength]; + + each(axes, function (axis) { + var idx = axis.inverse ? 1 : 0; + axis.setExtent(axisExtent[idx], axisExtent[1 - idx]); + }); + + each(dimensions, function (dim, idx) { + var pos = layoutLength * idx / (dimensions.length - 1); + + var positionTable = { + horizontal: { + x: pos, + y: axisLength + }, + vertical: { + x: 0, + y: pos + } + }; + var rotationTable = { + horizontal: PI / 2, + vertical: 0 + }; + + var position = [ + positionTable[layout].x + rect.x, + positionTable[layout].y + rect.y + ]; + + var rotation = rotationTable[layout]; + var transform = matrix.create(); + matrix.rotate(transform, transform, rotation); + matrix.translate(transform, transform, position); + + // TODO + // tick等排布信息。 + + // TODO + // 根据axis order 更新 dimensions顺序。 + + this._axesLayout[dim] = { + position: position, + rotation: rotation, + transform: transform, + tickDirection: 1, + labelDirection: 1 + }; + }, this); + }, + + /** + * Get axis by dim. + * @param {string} dim + * @return {module:echarts/coord/parallel/ParallelAxis} [description] + */ + getAxis: function (dim) { + return this._axesMap[dim]; + }, + + /** + * Convert a dim value of a single item of series data to Point. + * @param {*} value + * @param {string} dim + * @return {Array} + */ + dataToPoint: function (value, dim) { + return this.axisCoordToPoint( + this._axesMap[dim].dataToCoord(value), + dim + ); + }, + + /** + * @param {module:echarts/data/List} data + * @param {Functio} cb param: {string} activeState 'active' or 'inactive' or 'normal' + * {number} dataIndex + * @param {Object} context + */ + eachActiveState: function (data, callback, context) { + var dimensions = this.dimensions; + var axesMap = this._axesMap; + var hasActiveSet = false; + + for (var j = 0, lenj = dimensions.length; j < lenj; j++) { + if (axesMap[dimensions[j]].model.getActiveState() !== 'normal') { + hasActiveSet = true; + } + } + + for (var i = 0, len = data.count(); i < len; i++) { + var values = data.getValues(dimensions, i); + var activeState; + + if (!hasActiveSet) { + activeState = 'normal'; + } + else { + activeState = 'active'; + for (var j = 0, lenj = dimensions.length; j < lenj; j++) { + var dimName = dimensions[j]; + var state = axesMap[dimName].model.getActiveState(values[j], j); + + if (state === 'inactive') { + activeState = 'inactive'; + break; + } + } + } + + callback.call(context, activeState, i); + } + }, + + /** + * Convert coords of each axis to Point. + * Return point. For example: [10, 20] + * @param {Array.} coords + * @param {string} dim + * @return {Array.} + */ + axisCoordToPoint: function (coord, dim) { + var axisLayout = this._axesLayout[dim]; + var point = [coord, 0]; + vector.applyTransform(point, point, axisLayout.transform); + return point; + }, + + /** + * Get axis layout. + */ + getAxisLayout: function (dim) { + return zrUtil.clone(this._axesLayout[dim]); + } + + }; + + module.exports = Parallel; + + +/***/ }, +/* 219 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var Axis = __webpack_require__(117); + + /** + * @constructor module:echarts/coord/parallel/ParallelAxis + * @extends {module:echarts/coord/Axis} + * @param {string} dim + * @param {*} scale + * @param {Array.} coordExtent + * @param {string} axisType + */ + var ParallelAxis = function (dim, scale, coordExtent, axisType, axisIndex) { + + Axis.call(this, dim, scale, coordExtent); + + /** + * Axis type + * - 'category' + * - 'value' + * - 'time' + * - 'log' + * @type {string} + */ + this.type = axisType || 'value'; + + /** + * @type {number} + * @readOnly + */ + this.axisIndex = axisIndex; + }; + + ParallelAxis.prototype = { + + constructor: ParallelAxis, + + /** + * Axis model + * @param {module:echarts/coord/parallel/AxisModel} + */ + model: null + + }; + + zrUtil.inherits(ParallelAxis, Axis); + + module.exports = ParallelAxis; + + +/***/ }, +/* 220 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var Component = __webpack_require__(19); + + __webpack_require__(221); + + Component.extend({ + + type: 'parallel', + + dependencies: ['parallelAxis'], + + /** + * @type {module:echarts/coord/parallel/Parallel} + */ + coordinateSystem: null, + + /** + * Each item like: 'dim0', 'dim1', 'dim2', ... + * @type {Array.} + * @readOnly + */ + dimensions: null, - type: 'scatter', + /** + * Coresponding to dimensions. + * @type {Array.} + * @readOnly + */ + parallelAxisIndex: null, - init: function () { - this._normalSymbolDraw = new SymbolDraw(); - this._largeSymbolDraw = new LargeSymbolDraw(); - }, + defaultOption: { + zlevel: 0, // 一级层叠 + z: 0, // 二级层叠 + left: 80, + top: 60, + right: 80, + bottom: 60, + // width: {totalWidth} - left - right, + // height: {totalHeight} - top - bottom, + + layout: 'horizontal', // 'horizontal' or 'vertical' + + parallelAxisDefault: null + }, + + /** + * @override + */ + init: function () { + Component.prototype.init.apply(this, arguments); + + this.mergeOption({}); + }, + + /** + * @override + */ + mergeOption: function (newOption) { + var thisOption = this.option; + + newOption && zrUtil.merge(thisOption, newOption, true); + + this._initDimensions(); + }, + + /** + * Whether series or axis is in this coordinate system. + * @param {module:echarts/model/Series|module:echarts/coord/parallel/AxisModel} model + * @param {module:echarts/model/Global} ecModel + */ + contains: function (model, ecModel) { + var parallelIndex = model.get('parallelIndex'); + return parallelIndex != null + && ecModel.getComponent('parallel', parallelIndex) === this; + }, + + /** + * @private + */ + _initDimensions: function () { + var dimensions = this.dimensions = []; + var parallelAxisIndex = this.parallelAxisIndex = []; + + var axisModels = zrUtil.filter(this.dependentModels.parallelAxis, function (axisModel) { + // Can not use this.contains here, because + // initialization has not been completed yet. + return axisModel.get('parallelIndex') === this.componentIndex; + }); + + zrUtil.each(axisModels, function (axisModel) { + dimensions.push('dim' + axisModel.get('dim')); + parallelAxisIndex.push(axisModel.componentIndex); + }); + } + + }); + + + +/***/ }, +/* 221 */ +/***/ function(module, exports, __webpack_require__) { + + + + var ComponentModel = __webpack_require__(19); + var zrUtil = __webpack_require__(3); + var makeStyleMapper = __webpack_require__(11); + var axisModelCreator = __webpack_require__(121); + var numberUtil = __webpack_require__(7); + + var AxisModel = ComponentModel.extend({ + + type: 'baseParallelAxis', + + /** + * @type {module:echarts/coord/parallel/Axis} + */ + axis: null, + + /** + * @type {Array.} + * @readOnly + */ + activeIntervals: [], + + /** + * @return {Object} + */ + getAreaSelectStyle: function () { + return makeStyleMapper( + [ + ['fill', 'color'], + ['lineWidth', 'borderWidth'], + ['stroke', 'borderColor'], + ['width', 'width'], + ['opacity', 'opacity'] + ] + ).call(this.getModel('areaSelectStyle')); + }, + + /** + * The code of this feature is put on AxisModel but not ParallelAxis, + * because axisModel can be alive after echarts updating but instance of + * ParallelAxis having been disposed. this._activeInterval should be kept + * when action dispatched (i.e. legend click). + * + * @param {Array.>} intervals interval.length === 0 + * means set all active. + * @public + */ + setActiveIntervals: function (intervals) { + var activeIntervals = this.activeIntervals = zrUtil.clone(intervals); + + // Normalize + if (activeIntervals) { + for (var i = activeIntervals.length - 1; i >= 0; i--) { + numberUtil.asc(activeIntervals[i]); + } + } + }, + + /** + * @param {number|string} [value] When attempting to detect 'no activeIntervals set', + * value can not be input. + * @return {string} 'normal': no activeIntervals set, + * 'active', + * 'inactive'. + * @public + */ + getActiveState: function (value) { + var activeIntervals = this.activeIntervals; + + if (!activeIntervals.length) { + return 'normal'; + } + + if (value == null) { + return 'inactive'; + } + + for (var i = 0, len = activeIntervals.length; i < len; i++) { + if (activeIntervals[i][0] <= value && value <= activeIntervals[i][1]) { + return 'active'; + } + } + return 'inactive'; + } - render: function (seriesModel, ecModel, api) { - var data = seriesModel.getData(); - var largeSymbolDraw = this._largeSymbolDraw; - var normalSymbolDraw = this._normalSymbolDraw; - var group = this.group; + }); + + var defaultOption = { + + type: 'value', - var symbolDraw = seriesModel.get('large') && data.count() > seriesModel.get('largeThreshold') - ? largeSymbolDraw : normalSymbolDraw; + /** + * @type {Array.} + */ + dim: null, // 0, 1, 2, ... + + parallelIndex: null, + + areaSelectStyle: { + width: 20, + borderWidth: 1, + borderColor: 'rgba(160,197,232)', + color: 'rgba(160,197,232)', + opacity: 0.3 + }, + + z: 10 + }; + + zrUtil.merge(AxisModel.prototype, __webpack_require__(123)); + + function getAxisType(axisName, option) { + return option.type || (option.data ? 'category' : 'value'); + } + + axisModelCreator('parallel', AxisModel, getAxisType, defaultOption); + + module.exports = AxisModel; + + +/***/ }, +/* 222 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(217); + __webpack_require__(223); + __webpack_require__(224); - this._symbolDraw = symbolDraw; - symbolDraw.updateData(data); - group.add(symbolDraw.group); - group.remove( - symbolDraw === largeSymbolDraw - ? normalSymbolDraw.group : largeSymbolDraw.group - ); - }, - updateLayout: function (seriesModel) { - this._symbolDraw.updateLayout(seriesModel); - }, +/***/ }, +/* 223 */ +/***/ function(module, exports, __webpack_require__) { - remove: function (ecModel, api) { - this._symbolDraw && this._symbolDraw.remove(api, true); - } - }); -}); -define('echarts/chart/scatter',['require','zrender/core/util','../echarts','./scatter/ScatterSeries','./scatter/ScatterView','../visual/symbol','../layout/points'],function (require) { + - var zrUtil = require('zrender/core/util'); - var echarts = require('../echarts'); + var echarts = __webpack_require__(1); - require('./scatter/ScatterSeries'); - require('./scatter/ScatterView'); + var actionInfo = { + type: 'axisAreaSelect', + event: 'axisAreaSelected', + update: 'updateVisual' + }; - echarts.registerVisualCoding('chart', zrUtil.curry( - require('../visual/symbol'), 'scatter', 'circle', null - )); - echarts.registerLayout(zrUtil.curry( - require('../layout/points'), 'scatter' - )); -}); -define('echarts/component/tooltip/TooltipModel',['require','../../echarts'],function (require) { + /** + * @payload + * @property {string} parallelAxisId + * @property {Array.>} intervals + */ + echarts.registerAction(actionInfo, function (payload, ecModel) { + ecModel.eachComponent( + {mainType: 'parallelAxis', query: payload}, + function (parallelAxisModel) { + parallelAxisModel.axis.model.setActiveIntervals(payload.intervals); + } + ); - require('../../echarts').extendComponentModel({ + }); - type: 'tooltip', - defaultOption: { - zlevel: 0, +/***/ }, +/* 224 */ +/***/ function(module, exports, __webpack_require__) { - z: 8, + - show: true, + var zrUtil = __webpack_require__(3); + var AxisBuilder = __webpack_require__(126); + var SelectController = __webpack_require__(225); - // tooltip主体内容 - showContent: true, + var elementList = ['axisLine', 'axisLabel', 'axisTick', 'axisName']; - // 触发类型,默认数据触发,见下图,可选为:'item' ¦ 'axis' - trigger: 'item', + var AxisView = __webpack_require__(1).extendComponentView({ - // 触发条件,支持 'click' | 'mousemove' - triggerOn: 'mousemove', + type: 'parallelAxis', - // 是否永远显示 content - alwaysShowContent: false, + /** + * @type {module:echarts/component/helper/SelectController} + */ + _selectController: null, - // 位置 {Array} | {Function} - // position: null + /** + * @override + */ + render: function (axisModel, ecModel, api, payload) { + if (fromAxisAreaSelect(axisModel, ecModel, payload)) { + return; + } - // 内容格式器:{string}(Template) ¦ {Function} - // formatter: null + this.axisModel = axisModel; + this.api = api; - // 隐藏延迟,单位ms - hideDelay: 100, + this.group.removeAll(); - // 动画变换时间,单位s - transitionDuration: 0.4, + if (!axisModel.get('show')) { + return; + } + + var coordSys = ecModel.getComponent( + 'parallel', axisModel.get('parallelIndex') + ).coordinateSystem; - enterable: false, + var areaSelectStyle = axisModel.getAreaSelectStyle(); + var areaWidth = areaSelectStyle.width; - // 提示背景颜色,默认为透明度为0.7的黑色 - backgroundColor: 'rgba(50,50,50,0.7)', + var axisLayout = coordSys.getAxisLayout(axisModel.axis.dim); + var builderOpt = zrUtil.extend( + { + strokeContainThreshold: areaWidth, + // lineWidth === 0 or no value. + silent: !(areaWidth > 0) // jshint ignore:line + }, + axisLayout + ); - // 提示边框颜色 - borderColor: '#333', + var axisBuilder = new AxisBuilder(axisModel, builderOpt); - // 提示边框圆角,单位px,默认为4 - borderRadius: 4, + zrUtil.each(elementList, axisBuilder.add, axisBuilder); + + var axisGroup = axisBuilder.getGroup(); + + this.group.add(axisGroup); + + this._buildSelectController( + axisGroup, areaSelectStyle, axisModel, api + ); + }, + + _buildSelectController: function (axisGroup, areaSelectStyle, axisModel, api) { + + var axis = axisModel.axis; + var selectController = this._selectController; + + if (!selectController) { + selectController = this._selectController = new SelectController( + 'line', + api.getZr(), + areaSelectStyle + ); + + selectController.on('selected', zrUtil.bind(this._onSelected, this)); + } + + selectController.enable(axisGroup); + + // After filtering, axis may change, select area needs to be update. + var ranges = zrUtil.map(axisModel.activeIntervals, function (interval) { + return [ + axis.dataToCoord(interval[0], true), + axis.dataToCoord(interval[1], true) + ]; + }); + selectController.update(ranges); + }, + + _onSelected: function (ranges) { + // Do not cache these object, because the mey be changed. + var axisModel = this.axisModel; + var axis = axisModel.axis; + + var intervals = zrUtil.map(ranges, function (range) { + return [ + axis.coordToData(range[0], true), + axis.coordToData(range[1], true) + ]; + }); + this.api.dispatchAction({ + type: 'axisAreaSelect', + parallelAxisId: axisModel.id, + intervals: intervals + }); + }, + + /** + * @override + */ + remove: function () { + this._selectController && this._selectController.disable(); + }, + + /** + * @override + */ + dispose: function () { + if (this._selectController) { + this._selectController.dispose(); + this._selectController = null; + } + } + }); + + function fromAxisAreaSelect(axisModel, ecModel, payload) { + return payload + && payload.type === 'axisAreaSelect' + && ecModel.findComponents( + {mainType: 'parallelAxis', query: payload} + )[0] === axisModel; + } + + module.exports = AxisView; + + +/***/ }, +/* 225 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Box selection tool. + * + * @module echarts/component/helper/SelectController + */ + + + + var Eventful = __webpack_require__(32); + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var bind = zrUtil.bind; + var each = zrUtil.each; + var mathMin = Math.min; + var mathMax = Math.max; + var mathPow = Math.pow; + + var COVER_Z = 10000; + var UNSELECT_THRESHOLD = 2; + var EVENTS = ['mousedown', 'mousemove', 'mouseup']; + + /** + * @alias module:echarts/component/helper/SelectController + * @constructor + * @mixin {module:zrender/mixin/Eventful} + * + * @param {string} type 'line', 'rect' + * @param {module:zrender/zrender~ZRender} zr + * @param {Object} [opt] + * @param {number} [opt.width] + * @param {number} [opt.lineWidth] + * @param {string} [opt.stroke] + * @param {string} [opt.fill] + */ + function SelectController(type, zr, opt) { + + Eventful.call(this); + + /** + * @type {string} + * @readOnly + */ + this.type = type; + + /** + * @type {module:zrender/zrender~ZRender} + */ + this.zr = zr; + + /** + * @type {Object} + * @readOnly + */ + this.opt = zrUtil.clone(opt); + + /** + * @type {module:zrender/container/Group} + * @readOnly + */ + this.group = new graphic.Group(); + + /** + * @type {module:zrender/core/BoundingRect} + */ + this._containerRect = null; + + /** + * @type {Array.} + * @private + */ + this._track = []; + + /** + * @type {boolean} + */ + this._dragging; + + /** + * @type {module:zrender/Element} + * @private + */ + this._cover; + + /** + * @type {boolean} + * @private + */ + this._disabled = true; + + /** + * @type {Object} + * @private + */ + this._handlers = { + mousedown: bind(mousedown, this), + mousemove: bind(mousemove, this), + mouseup: bind(mouseup, this) + }; + + each(EVENTS, function (eventName) { + this.zr.on(eventName, this._handlers[eventName]); + }, this); + } + + SelectController.prototype = { + + constructor: SelectController, + + /** + * @param {module:zrender/mixin/Transformable} container + * @param {module:zrender/core/BoundingRect|boolean} [rect] If not specified, + * use container.getBoundingRect(). + * If false, do not use containerRect. + */ + enable: function (container, rect) { + + this._disabled = false; + + // Remove from old container. + removeGroup.call(this); + + // boundingRect will change when dragging, so we have + // to keep initial boundingRect. + this._containerRect = rect !== false + ? (rect || container.getBoundingRect()) : null; + + // Add to new container. + container.add(this.group); + }, + + /** + * Update cover location. + * @param {Array.|Object} ranges If null/undefined, remove cover. + */ + update: function (ranges) { + // TODO + // Only support one interval yet. + renderCover.call(this, ranges && zrUtil.clone(ranges)); + }, + + disable: function () { + this._disabled = true; + + removeGroup.call(this); + }, + + dispose: function () { + this.disable(); + + each(EVENTS, function (eventName) { + this.zr.off(eventName, this._handlers[eventName]); + }, this); + } + }; + + + zrUtil.mixin(SelectController, Eventful); + + function updateZ(group) { + group.traverse(function (el) { + el.z = COVER_Z; + }); + } + + function isInContainer(x, y) { + var localPos = this.group.transformCoordToLocal(x, y); + return !this._containerRect + || this._containerRect.contain(localPos[0], localPos[1]); + } + + function preventDefault(e) { + var rawE = e.event; + rawE.preventDefault && rawE.preventDefault(); + } + + function mousedown(e) { + if (this._disabled || (e.target && e.target.draggable)) { + return; + } + + preventDefault(e); + + var x = e.offsetX; + var y = e.offsetY; + + if (isInContainer.call(this, x, y)) { + this._dragging = true; + this._track = [[x, y]]; + } + } + + function mousemove(e) { + if (!this._dragging || this._disabled) { + return; + } + + preventDefault(e); + + updateViewByCursor.call(this, e); + } + + function mouseup(e) { + if (!this._dragging || this._disabled) { + return; + } + + preventDefault(e); + + updateViewByCursor.call(this, e, true); + + this._dragging = false; + this._track = []; + } + + function updateViewByCursor(e, isEnd) { + var x = e.offsetX; + var y = e.offsetY; + + if (isInContainer.call(this, x, y)) { + this._track.push([x, y]); + + // Create or update cover. + var ranges = shouldShowCover.call(this) + ? coverRenderers[this.type].getRanges.call(this) + // Remove cover. + : []; + + renderCover.call(this, ranges); + + this.trigger('selected', zrUtil.clone(ranges)); + + if (isEnd) { + this.trigger('selectEnd', zrUtil.clone(ranges)); + } + } + } + + function shouldShowCover() { + var track = this._track; + + if (!track.length) { + return false; + } + + var p2 = track[track.length - 1]; + var p1 = track[0]; + var dx = p2[0] - p1[0]; + var dy = p2[1] - p1[1]; + var dist = mathPow(dx * dx + dy * dy, 0.5); + + return dist > UNSELECT_THRESHOLD; + } + + function renderCover(ranges) { + var coverRenderer = coverRenderers[this.type]; + + if (ranges && ranges.length) { + if (!this._cover) { + this._cover = coverRenderer.create.call(this); + this.group.add(this._cover); + } + coverRenderer.update.call(this, ranges); + } + else { + this.group.remove(this._cover); + this._cover = null; + } + + updateZ(this.group); + } + + function removeGroup() { + // container may 'removeAll' outside. + var group = this.group; + var container = group.parent; + if (container) { + container.remove(group); + } + } + + function createRectCover() { + var opt = this.opt; + return new graphic.Rect({ + // FIXME + // customize style. + style: { + stroke: opt.stroke, + fill: opt.fill, + lineWidth: opt.lineWidth, + opacity: opt.opacity + } + }); + } + + function getLocalTrack() { + return zrUtil.map(this._track, function (point) { + return this.group.transformCoordToLocal(point[0], point[1]); + }, this); + } + + function getLocalTrackEnds() { + var localTrack = getLocalTrack.call(this); + var tail = localTrack.length - 1; + tail < 0 && (tail = 0); + return [localTrack[0], localTrack[tail]]; + } + + /** + * key: this.type + * @type {Object} + */ + var coverRenderers = { + + line: { + + create: createRectCover, + + getRanges: function () { + var ends = getLocalTrackEnds.call(this); + var min = mathMin(ends[0][0], ends[1][0]); + var max = mathMax(ends[0][0], ends[1][0]); + + return [[min, max]]; + }, + + update: function (ranges) { + var range = ranges[0]; + var width = this.opt.width; + this._cover.setShape({ + x: range[0], + y: -width / 2, + width: range[1] - range[0], + height: width + }); + } + }, + + rect: { + + create: createRectCover, + + getRanges: function () { + var ends = getLocalTrackEnds.call(this); + + var min = [ + mathMin(ends[1][0], ends[0][0]), + mathMin(ends[1][1], ends[0][1]) + ]; + var max = [ + mathMax(ends[1][0], ends[0][0]), + mathMax(ends[1][1], ends[0][1]) + ]; + + return [[ + [min[0], max[0]], // x range + [min[1], max[1]] // y range + ]]; + }, + + update: function (ranges) { + var range = ranges[0]; + this._cover.setShape({ + x: range[0][0], + y: range[1][0], + width: range[0][1] - range[0][0], + height: range[1][1] - range[1][0] + }); + } + } + }; + + module.exports = SelectController; + + +/***/ }, +/* 226 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + + module.exports = function (option) { + createParallelIfNeeded(option); + mergeAxisOptionFromParallel(option); + }; + + /** + * Create a parallel coordinate if not exists. + * @inner + */ + function createParallelIfNeeded(option) { + if (option.parallel) { + return; + } + + var hasParallelSeries = false; + + zrUtil.each(option.series, function (seriesOpt) { + if (seriesOpt && seriesOpt.type === 'parallel') { + hasParallelSeries = true; + } + }); + + if (hasParallelSeries) { + option.parallel = [{}]; + } + } + + /** + * Merge aixs definition from parallel option (if exists) to axis option. + * @inner + */ + function mergeAxisOptionFromParallel(option) { + var axes = modelUtil.normalizeToArray(option.parallelAxis); + + zrUtil.each(axes, function (axisOption) { + if (!zrUtil.isObject(axisOption)) { + return; + } + + var parallelIndex = axisOption.parallelIndex || 0; + var parallelOption = modelUtil.normalizeToArray(option.parallel)[parallelIndex]; + + if (parallelOption && parallelOption.parallelAxisDefault) { + zrUtil.merge(axisOption, parallelOption.parallelAxisDefault, false); + } + }); + } + + + +/***/ }, +/* 227 */ +/***/ function(module, exports, __webpack_require__) { + + + + var List = __webpack_require__(94); + var zrUtil = __webpack_require__(3); + var SeriesModel = __webpack_require__(27); + + module.exports = SeriesModel.extend({ + + type: 'series.parallel', + + dependencies: ['parallel'], + + getInitialData: function (option, ecModel) { + var parallelModel = ecModel.getComponent( + 'parallel', this.get('parallelIndex') + ); + var dimensions = parallelModel.dimensions; + var parallelAxisIndices = parallelModel.parallelAxisIndex; + + var rawData = option.data; + + var dimensionsInfo = zrUtil.map(dimensions, function (dim, index) { + var axisModel = ecModel.getComponent( + 'parallelAxis', parallelAxisIndices[index] + ); + if (axisModel.get('type') === 'category') { + translateCategoryValue(axisModel, dim, rawData); + return {name: dim, type: 'ordinal'}; + } + else { + return dim; + } + }); + + var list = new List(dimensionsInfo, this); + list.initData(rawData); + + return list; + }, + + defaultOption: { + zlevel: 0, // 一级层叠 + z: 2, // 二级层叠 + + coordinateSystem: 'parallel', + parallelIndex: 0, + + // FIXME 尚无用 + label: { + normal: { + show: false + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 + // 'inside'|'left'|'right'|'top'|'bottom' + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + }, + emphasis: { + show: false + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 + // 'inside'|'left'|'right'|'top'|'bottom' + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + } + }, + + inactiveOpacity: 0.05, + activeOpacity: 1, + + lineStyle: { + normal: { + width: 2, + opacity: 0.45, + type: 'solid' + } + }, + // smooth: false + + animationEasing: 'linear' + } + }); + + function translateCategoryValue(axisModel, dim, rawData) { + var axisData = axisModel.get('data'); + var numberDim = +dim.replace('dim', ''); + + if (axisData && axisData.length) { + zrUtil.each(rawData, function (dataItem) { + if (!dataItem) { + return; + } + var index = zrUtil.indexOf(axisData, dataItem[numberDim]); + dataItem[numberDim] = index >= 0 ? index : NaN; + }); + } + // FIXME + // 如果没有设置axis data, 应自动算出,或者提示。 + } + + +/***/ }, +/* 228 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + + var ParallelView = __webpack_require__(41).extend({ + + type: 'parallel', + + init: function () { + + /** + * @type {module:zrender/container/Group} + * @private + */ + this._dataGroup = new graphic.Group(); + + this.group.add(this._dataGroup); + /** + * @type {module:echarts/data/List} + */ + this._data; + }, + + /** + * @override + */ + render: function (seriesModel, ecModel, api, payload) { + + var dataGroup = this._dataGroup; + var data = seriesModel.getData(); + var oldData = this._data; + var coordSys = seriesModel.coordinateSystem; + var dimensions = coordSys.dimensions; + + data.diff(oldData) + .add(add) + .update(update) + .remove(remove) + .execute(); + + // Update style + data.eachItemGraphicEl(function (elGroup, idx) { + var itemModel = data.getItemModel(idx); + var lineStyleModel = itemModel.getModel('lineStyle.normal'); + elGroup.eachChild(function (child) { + child.setStyle(zrUtil.extend( + lineStyleModel.getLineStyle(), + { + stroke: data.getItemVisual(idx, 'color'), + opacity: data.getItemVisual(idx, 'opacity') + } + )); + }); + }); + + // First create + if (!this._data) { + dataGroup.setClipPath(createGridClipShape( + coordSys, seriesModel, function () { + dataGroup.removeClipPath(); + } + )); + } + + this._data = data; + + function add(newDataIndex) { + var values = data.getValues(dimensions, newDataIndex); + var elGroup = new graphic.Group(); + dataGroup.add(elGroup); + + eachAxisPair( + values, dimensions, coordSys, + function (pointPair, pairIndex) { + // FIXME + // init animation + if (pointPair) { + elGroup.add(createEl(pointPair)); + } + } + ); + + data.setItemGraphicEl(newDataIndex, elGroup); + } + + function update(newDataIndex, oldDataIndex) { + var values = data.getValues(dimensions, newDataIndex); + var elGroup = oldData.getItemGraphicEl(oldDataIndex); + var newEls = []; + var elGroupIndex = 0; + + eachAxisPair( + values, dimensions, coordSys, + function (pointPair, pairIndex) { + var el = elGroup.childAt(elGroupIndex++); + + if (pointPair && !el) { + newEls.push(createEl(pointPair)); + } + else if (pointPair) { + graphic.updateProps(el, { + shape: { + points: pointPair + } + }, seriesModel); + } + } + ); + + // Remove redundent els + for (var i = elGroup.childCount() - 1; i >= elGroupIndex; i--) { + elGroup.remove(elGroup.childAt(i)); + } + + // Add new els + for (var i = 0, len = newEls.length; i < len; i++) { + elGroup.add(newEls[i]); + } + + data.setItemGraphicEl(newDataIndex, elGroup); + } + + function remove(oldDataIndex) { + var elGroup = oldData.getItemGraphicEl(oldDataIndex); + dataGroup.remove(elGroup); + } + }, + + /** + * @override + */ + remove: function () { + this._dataGroup && this._dataGroup.removeAll(); + this._data = null; + } + }); + + function createGridClipShape(coordSys, seriesModel, cb) { + var parallelModel = coordSys.model; + var rect = coordSys.getRect(); + var rectEl = new graphic.Rect({ + shape: { + x: rect.x, + y: rect.y, + width: rect.width, + height: rect.height + } + }); + var dim = parallelModel.get('layout') === 'horizontal' ? 'width' : 'height'; + rectEl.setShape(dim, 0); + graphic.initProps(rectEl, { + shape: { + width: rect.width, + height: rect.height + } + }, seriesModel, cb); + return rectEl; + } + + function eachAxisPair(values, dimensions, coordSys, cb) { + for (var i = 0, len = dimensions.length - 1; i < len; i++) { + var dimA = dimensions[i]; + var dimB = dimensions[i + 1]; + var valueA = values[i]; + var valueB = values[i + 1]; + + cb( + (isEmptyValue(valueA, coordSys.getAxis(dimA).type) + || isEmptyValue(valueB, coordSys.getAxis(dimB).type) + ) + ? null + : [ + coordSys.dataToPoint(valueA, dimA), + coordSys.dataToPoint(valueB, dimB) + ], + i + ); + } + } + + function createEl(pointPair) { + return new graphic.Polyline({ + shape: {points: pointPair}, + silent: true + }); + } + + + // FIXME + // 公用方法? + function isEmptyValue(val, axisType) { + return axisType === 'category' + ? val == null + : (val == null || isNaN(val)); // axisType === 'value' + } + + module.exports = ParallelView; + + +/***/ }, +/* 229 */ +/***/ function(module, exports) { + + + + /** + * @payload + * @property {string} parallelAxisId + * @property {Array.} extent + */ + module.exports = function (ecModel, payload) { + + ecModel.eachSeriesByType('parallel', function (seriesModel) { + + var itemStyleModel = seriesModel.getModel('itemStyle.normal'); + var globalColors = ecModel.get('color'); + + var color = itemStyleModel.get('color') + || globalColors[seriesModel.seriesIndex % globalColors.length]; + var inactiveOpacity = seriesModel.get('inactiveOpacity'); + var activeOpacity = seriesModel.get('activeOpacity'); + var lineStyle = seriesModel.getModel('lineStyle.normal').getLineStyle(); + + var coordSys = seriesModel.coordinateSystem; + var data = seriesModel.getData(); + + var opacityMap = { + normal: lineStyle.opacity, + active: activeOpacity, + inactive: inactiveOpacity + }; + + coordSys.eachActiveState(data, function (activeState, dataIndex) { + data.setItemVisual(dataIndex, 'opacity', opacityMap[activeState]); + }); + + data.setVisual('color', color); + }); + }; + + +/***/ }, +/* 230 */ +/***/ function(module, exports, __webpack_require__) { + + + + var echarts = __webpack_require__(1); + + __webpack_require__(231); + __webpack_require__(232); + echarts.registerLayout(__webpack_require__(233)); + echarts.registerVisualCoding('chart', __webpack_require__(235)); + + +/***/ }, +/* 231 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var SeriesModel = __webpack_require__(27); + var createGraphFromNodeEdge = __webpack_require__(191); - // 提示边框线宽,单位px,默认为0(无边框) - borderWidth: 0, + module.exports = SeriesModel.extend({ - // 提示内边距,单位px,默认各方向内边距为5, - // 接受数组分别设定上右下左边距,同css - padding: 5, + type: 'series.sankey', - // 坐标轴指示器,坐标轴触发有效 - axisPointer: { - // 默认为直线 - // 可选为:'line' | 'shadow' | 'cross' - type: 'line', + layoutInfo: null, - // type 为 line 的时候有效,指定 tooltip line 所在的轴,可选 - // 可选 'x' | 'y' | 'angle' | 'radius' | 'auto' - // 默认 'auto',会选择类型为 cateogry 的轴,对于双数值轴,笛卡尔坐标系会默认选择 x 轴 - // 极坐标系会默认选择 angle 轴 - axis: 'auto', + getInitialData: function (option, ecModel) { + var links = option.edges || option.links; + var nodes = option.data || option.nodes; + if (nodes && links) { + var graph = createGraphFromNodeEdge(nodes, links, this, true); + return graph.data; + } + }, - animation: true, - animationDurationUpdate: 200, - animationEasingUpdate: 'exponentialOut', + /** + * @return {module:echarts/data/Graph} + */ + getGraph: function () { + return this.getData().graph; + }, - // 直线指示器样式设置 - lineStyle: { - color: '#555', - width: 1, - type: 'solid' - }, + /** + * return {module:echarts/data/List} + */ + getEdgeData: function() { + return this.getGraph().edgeData; + }, - crossStyle: { - color: '#555', - width: 1, - type: 'dashed', + defaultOption: { + zlevel: 0, + z: 2, - // TODO formatter - textStyle: {} - }, + coordinateSystem: 'view', + + layout : null, - // 阴影指示器样式设置 - shadowStyle: { - color: 'rgba(150,150,150,0.3)' - } - }, - textStyle: { - color: '#fff', - fontSize: 14 - } - } - }); -}); -/** - * @module echarts/component/tooltip/TooltipContent - */ -define('echarts/component/tooltip/TooltipContent',['require','zrender/core/util','zrender/tool/color','zrender/core/event','../../util/format'],function (require) { - - var zrUtil = require('zrender/core/util'); - var zrColor = require('zrender/tool/color'); - var eventUtil = require('zrender/core/event'); - var formatUtil = require('../../util/format'); - var each = zrUtil.each; - var toCamelCase = formatUtil.toCamelCase; - - var vendors = ['', '-webkit-', '-moz-', '-o-']; - - var gCssText = 'position:absolute;display:block;border-style:solid;white-space:nowrap;'; - - /** - * @param {number} duration - * @return {string} - * @inner - */ - function assembleTransition(duration) { - var transitionCurve = 'cubic-bezier(0.23, 1, 0.32, 1)'; - var transitionText = 'left ' + duration + 's ' + transitionCurve + ',' - + 'top ' + duration + 's ' + transitionCurve; - return zrUtil.map(vendors, function (vendorPrefix) { - return vendorPrefix + 'transition:' + transitionText; - }).join(';'); - } - - /** - * @param {Object} textStyle - * @return {string} - * @inner - */ - function assembleFont(textStyleModel) { - var cssText = []; - - var fontSize = textStyleModel.get('fontSize'); - var color = textStyleModel.getTextColor(); - - color && cssText.push('color:' + color); - - cssText.push('font:' + textStyleModel.getFont()); - - fontSize && - cssText.push('line-height:' + Math.round(fontSize * 3 / 2) + 'px'); - - each(['decoration', 'align'], function (name) { - var val = textStyleModel.get(name); - val && cssText.push('text-' + name + ':' + val); - }); - - return cssText.join(';'); - } - - /** - * @param {Object} tooltipModel - * @return {string} - * @inner - */ - function assembleCssText(tooltipModel) { - - tooltipModel = tooltipModel; - - var cssText = []; - - var transitionDuration = tooltipModel.get('transitionDuration'); - var backgroundColor = tooltipModel.get('backgroundColor'); - var textStyleModel = tooltipModel.getModel('textStyle'); - var padding = tooltipModel.get('padding'); - - // Animation transition - transitionDuration && - cssText.push(assembleTransition(transitionDuration)); - - if (backgroundColor) { - // for ie - cssText.push( - 'background-Color:' + zrColor.toHex(backgroundColor) - ); - cssText.push('filter:alpha(opacity=70)'); - cssText.push('background-Color:' + backgroundColor); - } - - // Border style - each(['width', 'color', 'radius'], function (name) { - var borderName = 'border-' + name; - var camelCase = toCamelCase(borderName); - var val = tooltipModel.get(camelCase); - val != null && - cssText.push(borderName + ':' + val + (name === 'color' ? '' : 'px')); - }); - - // Text style - cssText.push(assembleFont(textStyleModel)); - - // Padding - if (padding != null) { - cssText.push('padding:' + formatUtil.normalizeCssArray(padding).join('px ') + 'px'); - } - - return cssText.join(';') + ';'; - } - - /** - * @alias module:echarts/component/tooltip/TooltipContent - * @constructor - */ - function TooltipContent(container, api) { - var el = document.createElement('div'); - var zr = api.getZr(); - - this.el = el; - - this._x = api.getWidth() / 2; - this._y = api.getHeight() / 2; - - container.appendChild(el); - - this._container = container; - - this._show = false; - - /** - * @private - */ - this._hideTimeout; - - var self = this; - el.onmouseenter = function () { - // clear the timeout in hideLater and keep showing tooltip - if (self.enterable) { - clearTimeout(self._hideTimeout); - self._show = true; - } - self._inContent = true; - }; - el.onmousemove = function (e) { - if (!self.enterable) { - // Try trigger zrender event to avoid mouse - // in and out shape too frequently - var handler = zr.handler; - eventUtil.normalizeEvent(container, e); - handler.dispatch('mousemove', e); - } - }; - el.onmouseleave = function () { - if (self.enterable) { - if (self._show) { - self.hideLater(self._hideDelay); - } - } - self._inContent = false; - }; - - compromiseMobile(el, container); - } - - function compromiseMobile(tooltipContentEl, container) { - // Prevent default behavior on mobile. For example, - // defuault pinch gesture will cause browser zoom. - // We do not preventing event on tooltip contnet el, - // because user may need customization in tooltip el. - eventUtil.addEventListener(container, 'touchstart', preventDefault); - eventUtil.addEventListener(container, 'touchmove', preventDefault); - eventUtil.addEventListener(container, 'touchend', preventDefault); - - function preventDefault(e) { - if (contains(e.target)) { - e.preventDefault(); - } - } - - function contains(targetEl) { - while (targetEl && targetEl !== container) { - if (targetEl === tooltipContentEl) { - return true; - } - targetEl = targetEl.parentNode; - } - } - } - - TooltipContent.prototype = { - - constructor: TooltipContent, - - enterable: true, - - /** - * Update when tooltip is rendered - */ - update: function () { - var container = this._container; - var stl = container.currentStyle - || document.defaultView.getComputedStyle(container); - var domStyle = container.style; - if (domStyle.position !== 'absolute' && stl.position !== 'absolute') { - domStyle.position = 'relative'; - } - // Hide the tooltip - // PENDING - // this.hide(); - }, - - show: function (tooltipModel) { - clearTimeout(this._hideTimeout); - - this.el.style.cssText = gCssText + assembleCssText(tooltipModel) - // http://stackoverflow.com/questions/21125587/css3-transition-not-working-in-chrome-anymore - + ';left:' + this._x + 'px;top:' + this._y + 'px;'; - - this._show = true; - }, - - setContent: function (content) { - var el = this.el; - el.innerHTML = content; - el.style.display = content ? 'block' : 'none'; - }, - - moveTo: function (x, y) { - var style = this.el.style; - style.left = x + 'px'; - style.top = y + 'px'; - - this._x = x; - this._y = y; - }, - - hide: function () { - this.el.style.display = 'none'; - this._show = false; - }, - - // showLater: function () - - hideLater: function (time) { - if (this._show && !(this._inContent && this.enterable)) { - if (time) { - this._hideDelay = time; - // Set show false to avoid invoke hideLater mutiple times - this._show = false; - this._hideTimeout = setTimeout(zrUtil.bind(this.hide, this), time); - } - else { - this.hide(); - } - } - }, - - isShow: function () { - return this._show; - } - }; - - return TooltipContent; -}); -define('echarts/component/tooltip/TooltipView',['require','./TooltipContent','../../util/graphic','zrender/core/util','../../util/format','../../util/number','zrender/core/env','../../echarts'],function (require) { - - var TooltipContent = require('./TooltipContent'); - var graphic = require('../../util/graphic'); - var zrUtil = require('zrender/core/util'); - var formatUtil = require('../../util/format'); - var numberUtil = require('../../util/number'); - var parsePercent = numberUtil.parsePercent; - var env = require('zrender/core/env'); - - function dataEqual(a, b) { - if (!a || !b) { - return false; - } - var round = numberUtil.round; - return round(a[0]) === round(b[0]) - && round(a[1]) === round(b[1]); - } - /** - * @inner - */ - function makeLineShape(x1, y1, x2, y2) { - return { - x1: x1, - y1: y1, - x2: x2, - y2: y2 - }; - } - - /** - * @inner - */ - function makeRectShape(x, y, width, height) { - return { - x: x, - y: y, - width: width, - height: height - }; - } - - /** - * @inner - */ - function makeSectorShape(cx, cy, r0, r, startAngle, endAngle) { - return { - cx: cx, - cy: cy, - r0: r0, - r: r, - startAngle: startAngle, - endAngle: endAngle, - clockwise: true - }; - } - - function refixTooltipPosition(x, y, el, viewWidth, viewHeight) { - var width = el.clientWidth; - var height = el.clientHeight; - var gap = 20; - - if (x + width + gap > viewWidth) { - x -= width + gap; - } - else { - x += gap; - } - if (y + height + gap > viewHeight) { - y -= height + gap; - } - else { - y += gap; - } - return [x, y]; - } - - function calcTooltipPosition(position, rect, dom) { - var domWidth = dom.clientWidth; - var domHeight = dom.clientHeight; - var gap = 5; - var x = 0; - var y = 0; - var rectWidth = rect.width; - var rectHeight = rect.height; - switch (position) { - case 'inside': - x = rect.x + rectWidth / 2 - domWidth / 2; - y = rect.y + rectHeight / 2 - domHeight / 2; - break; - case 'top': - x = rect.x + rectWidth / 2 - domWidth / 2; - y = rect.y - domHeight - gap; - break; - case 'bottom': - x = rect.x + rectWidth / 2 - domWidth / 2; - y = rect.y + rectHeight + gap; - break; - case 'left': - x = rect.x - domWidth - gap; - y = rect.y + rectHeight / 2 - domHeight / 2; - break; - case 'right': - x = rect.x + rectWidth + gap; - y = rect.y + rectHeight / 2 - domHeight / 2; - } - return [x, y]; - } - - /** - * @param {string|Function|Array.} positionExpr - * @param {number} x Mouse x - * @param {number} y Mouse y - * @param {module:echarts/component/tooltip/TooltipContent} content - * @param {Object|} params - * @param {module:zrender/Element} el target element - * @param {module:echarts/ExtensionAPI} api - * @return {Array.} - */ - function updatePosition(positionExpr, x, y, content, params, el, api) { - var viewWidth = api.getWidth(); - var viewHeight = api.getHeight(); - - var rect = el && el.getBoundingRect().clone(); - el && rect.applyTransform(el.transform); - if (typeof positionExpr === 'function') { - // Callback of position can be an array or a string specify the positiont - positionExpr = positionExpr([x, y], params, rect); - } - - if (zrUtil.isArray(positionExpr)) { - x = parsePercent(positionExpr[0], viewWidth); - y = parsePercent(positionExpr[1], viewHeight); - } - // Specify tooltip position by string 'top' 'bottom' 'left' 'right' around graphic element - else if (typeof positionExpr === 'string' && el) { - var pos = calcTooltipPosition( - positionExpr, rect, content.el - ); - x = pos[0]; - y = pos[1]; - } - else { - var pos = refixTooltipPosition( - x, y, content.el, viewWidth, viewHeight - ); - x = pos[0]; - y = pos[1]; - } - - content.moveTo(x, y); - } - - function ifSeriesSupportAxisTrigger(seriesModel) { - var coordSys = seriesModel.coordinateSystem; - var trigger = seriesModel.get('tooltip.trigger', true); - // Ignore series use item tooltip trigger and series coordinate system is not cartesian or - return !(!coordSys - || (coordSys.type !== 'cartesian2d' && coordSys.type !== 'polar' && coordSys.type !== 'single') - || trigger === 'item'); - } - - require('../../echarts').extendComponentView({ - - type: 'tooltip', - - _axisPointers: {}, - - init: function (ecModel, api) { - if (env.node) { - return; - } - var tooltipContent = new TooltipContent(api.getDom(), api); - this._tooltipContent = tooltipContent; - - api.on('showTip', this._manuallyShowTip, this); - api.on('hideTip', this._manuallyHideTip, this); - }, - - render: function (tooltipModel, ecModel, api) { - if (env.node) { - return; - } - - // Reset - this.group.removeAll(); - - /** - * @type {Object} - * @private - */ - this._axisPointers = {}; - - /** - * @private - * @type {module:echarts/component/tooltip/TooltipModel} - */ - this._tooltipModel = tooltipModel; - - /** - * @private - * @type {module:echarts/model/Global} - */ - this._ecModel = ecModel; - - /** - * @private - * @type {module:echarts/ExtensionAPI} - */ - this._api = api; - - /** - * @type {Object} - * @private - */ - this._lastHover = { - // data - // payloadBatch - }; - - var tooltipContent = this._tooltipContent; - tooltipContent.update(); - tooltipContent.enterable = tooltipModel.get('enterable'); - this._alwaysShowContent = tooltipModel.get('alwaysShowContent'); - - /** - * @type {Object.} - */ - this._seriesGroupByAxis = this._prepareAxisTriggerData( - tooltipModel, ecModel - ); - - var crossText = this._crossText; - if (crossText) { - this.group.add(crossText); - } - - // Try to keep the tooltip show when refreshing - if (this._lastX != null && this._lastY != null) { - var self = this; - clearTimeout(this._refreshUpdateTimeout); - this._refreshUpdateTimeout = setTimeout(function () { - // Show tip next tick after other charts are rendered - // In case highlight action has wrong result - // FIXME - self._manuallyShowTip({ - x: self._lastX, - y: self._lastY - }); - }); - } - - var zr = this._api.getZr(); - var tryShow = this._tryShow; - zr.off('click', tryShow); - zr.off('mousemove', tryShow); - zr.off('mouseout', this._hide); - if (tooltipModel.get('triggerOn') === 'click') { - zr.on('click', tryShow, this); - } - else { - zr.on('mousemove', tryShow, this); - zr.on('mouseout', this._hide, this); - } - - }, - - /** - * Show tip manually by - * dispatchAction({ - * type: 'showTip', - * x: 10, - * y: 10 - * }); - * Or - * dispatchAction({ - * type: 'showTip', - * seriesIndex: 0, - * dataIndex: 1 - * }); - * - * TODO Batch - */ - _manuallyShowTip: function (event) { - // From self - if (event.from === this.uid) { - return; - } - - var ecModel = this._ecModel; - var seriesIndex = event.seriesIndex; - var dataIndex = event.dataIndex; - var seriesModel = ecModel.getSeriesByIndex(seriesIndex); - var api = this._api; - - if (event.x == null || event.y == null) { - if (!seriesModel) { - // Find the first series can use axis trigger - ecModel.eachSeries(function (_series) { - if (ifSeriesSupportAxisTrigger(_series) && !seriesModel) { - seriesModel = _series; - } - }); - } - if (seriesModel) { - var data = seriesModel.getData(); - if (dataIndex == null) { - dataIndex = data.indexOfName(event.name); - } - var el = data.getItemGraphicEl(dataIndex); - var cx, cy; - // Try to get the point in coordinate system - var coordSys = seriesModel.coordinateSystem; - if (coordSys && coordSys.dataToPoint) { - var point = coordSys.dataToPoint( - data.getValues(coordSys.dimensions, dataIndex, true) - ); - cx = point && point[0]; - cy = point && point[1]; - } - else if (el) { - // Use graphic bounding rect - var rect = el.getBoundingRect().clone(); - rect.applyTransform(el.transform); - cx = rect.x + rect.width / 2; - cy = rect.y + rect.height / 2; - } - if (cx != null && cy != null) { - this._tryShow({ - offsetX: cx, - offsetY: cy, - target: el, - event: {} - }); - } - } - } - else { - var el = api.getZr().handler.findHover(event.x, event.y); - this._tryShow({ - offsetX: event.x, - offsetY: event.y, - target: el, - event: {} - }); - } - }, - - _manuallyHideTip: function (e) { - if (e.from === this.uid) { - return; - } - - this._hide(); - }, - - _prepareAxisTriggerData: function (tooltipModel, ecModel) { - // Prepare data for axis trigger - var seriesGroupByAxis = {}; - ecModel.eachSeries(function (seriesModel) { - if (ifSeriesSupportAxisTrigger(seriesModel)) { - var coordSys = seriesModel.coordinateSystem; - var baseAxis; - var key; - - // Only cartesian2d and polar support axis trigger - if (coordSys.type === 'cartesian2d') { - // FIXME `axisPointer.axis` is not baseAxis - baseAxis = coordSys.getBaseAxis(); - key = baseAxis.dim + baseAxis.index; - } - else if (coordSys.type === 'single') { - baseAxis = coordSys.getAxis(); - key = baseAxis.dim + baseAxis.type; - } - else { - baseAxis = coordSys.getBaseAxis(); - key = baseAxis.dim + coordSys.name; - } - - seriesGroupByAxis[key] = seriesGroupByAxis[key] || { - coordSys: [], - series: [] - }; - seriesGroupByAxis[key].coordSys.push(coordSys); - seriesGroupByAxis[key].series.push(seriesModel); - } - }, this); - - return seriesGroupByAxis; - }, - - /** - * mousemove handler - * @param {Object} e - * @private - */ - _tryShow: function (e) { - var el = e.target; - var tooltipModel = this._tooltipModel; - var globalTrigger = tooltipModel.get('trigger'); - var ecModel = this._ecModel; - var api = this._api; - - if (!tooltipModel) { - return; - } - - // Save mouse x, mouse y. So we can try to keep showing the tip if chart is refreshed - this._lastX = e.offsetX; - this._lastY = e.offsetY; - - // Always show item tooltip if mouse is on the element with dataIndex - if (el && el.dataIndex != null) { - // Use hostModel in element if possible - // Used when mouseover on a element like markPoint or edge - // In which case, the data is not main data in series. - var hostModel = el.hostModel || ecModel.getSeriesByIndex(el.seriesIndex); - var dataIndex = el.dataIndex; - var itemModel = hostModel.getData().getItemModel(dataIndex); - // Series or single data may use item trigger when global is axis trigger - if ((itemModel.get('tooltip.trigger') || globalTrigger) === 'axis') { - this._showAxisTooltip(tooltipModel, ecModel, e); - } - else { - // Reset ticket - this._ticket = ''; - // If either single data or series use item trigger - this._hideAxisPointer(); - // Reset last hover and dispatch downplay action - this._resetLastHover(); - - this._showItemTooltipContent(hostModel, dataIndex, e); - } - - api.dispatchAction({ - type: 'showTip', - from: this.uid, - dataIndex: el.dataIndex, - seriesIndex: el.seriesIndex - }); - } - else { - if (globalTrigger === 'item') { - this._hide(); - } - else { - // Try show axis tooltip - this._showAxisTooltip(tooltipModel, ecModel, e); - } - - // Action of cross pointer - // other pointer types will trigger action in _dispatchAndShowSeriesTooltipContent method - if (tooltipModel.get('axisPointer.type') === 'cross') { - api.dispatchAction({ - type: 'showTip', - from: this.uid, - x: e.offsetX, - y: e.offsetY - }); - } - } - }, - - /** - * Show tooltip on axis - * @param {module:echarts/component/tooltip/TooltipModel} tooltipModel - * @param {module:echarts/model/Global} ecModel - * @param {Object} e - * @private - */ - _showAxisTooltip: function (tooltipModel, ecModel, e) { - var axisPointerModel = tooltipModel.getModel('axisPointer'); - var axisPointerType = axisPointerModel.get('type'); - - if (axisPointerType === 'cross') { - var el = e.target; - if (el && el.dataIndex != null) { - var seriesModel = ecModel.getSeriesByIndex(el.seriesIndex); - var dataIndex = el.dataIndex; - this._showItemTooltipContent(seriesModel, dataIndex, e); - } - } - - this._showAxisPointer(); - var allNotShow = true; - zrUtil.each(this._seriesGroupByAxis, function (seriesCoordSysSameAxis) { - // Try show the axis pointer - var allCoordSys = seriesCoordSysSameAxis.coordSys; - var coordSys = allCoordSys[0]; - - // If mouse position is not in the grid or polar - var point = [e.offsetX, e.offsetY]; - - if (!coordSys.containPoint(point)) { - // Hide axis pointer - this._hideAxisPointer(coordSys.name); - return; - } - - allNotShow = false; - // Make sure point is discrete on cateogry axis - var dimensions = coordSys.dimensions; - var value = coordSys.pointToData(point, true); - point = coordSys.dataToPoint(value); - var baseAxis = coordSys.getBaseAxis(); - var axisType = axisPointerModel.get('axis'); - if (axisType === 'auto') { - axisType = baseAxis.dim; - } - - var contentNotChange = false; - var lastHover = this._lastHover; - if (axisPointerType === 'cross') { - // If hover data not changed - // Possible when two axes are all category - if (dataEqual(lastHover.data, value)) { - contentNotChange = true; - } - lastHover.data = value; - } - else { - var valIndex = zrUtil.indexOf(dimensions, axisType); - - // If hover data not changed on the axis dimension - if (lastHover.data === value[valIndex]) { - contentNotChange = true; - } - lastHover.data = value[valIndex]; - } - - if (coordSys.type === 'cartesian2d' && !contentNotChange) { - this._showCartesianPointer( - axisPointerModel, coordSys, axisType, point - ); - } - else if (coordSys.type === 'polar' && !contentNotChange) { - this._showPolarPointer( - axisPointerModel, coordSys, axisType, point - ); - } - else if (coordSys.type === 'single' && !contentNotChange) { - this._showSinglePointer( - axisPointerModel, coordSys, axisType, point - ); - } - - if (axisPointerType !== 'cross') { - this._dispatchAndShowSeriesTooltipContent( - coordSys, seriesCoordSysSameAxis.series, point, value, contentNotChange - ); - } - }, this); - - if (allNotShow) { - this._hide(); - } - }, - - /** - * Show tooltip on axis of cartesian coordinate - * @param {module:echarts/model/Model} axisPointerModel - * @param {module:echarts/coord/cartesian/Cartesian2D} cartesians - * @param {string} axisType - * @param {Array.} point - * @private - */ - _showCartesianPointer: function (axisPointerModel, cartesian, axisType, point) { - var self = this; - - var axisPointerType = axisPointerModel.get('type'); - var moveAnimation = axisPointerType !== 'cross'; - - if (axisPointerType === 'cross') { - moveGridLine('x', point, cartesian.getAxis('y').getGlobalExtent()); - moveGridLine('y', point, cartesian.getAxis('x').getGlobalExtent()); - - this._updateCrossText(cartesian, point, axisPointerModel); - } - else { - var otherAxis = cartesian.getAxis(axisType === 'x' ? 'y' : 'x'); - var otherExtent = otherAxis.getGlobalExtent(); - - if (cartesian.type === 'cartesian2d') { - (axisPointerType === 'line' ? moveGridLine : moveGridShadow)( - axisType, point, otherExtent - ); - } - } - - /** - * @inner - */ - function moveGridLine(axisType, point, otherExtent) { - var targetShape = axisType === 'x' - ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1]) - : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]); - - var pointerEl = self._getPointerElement( - cartesian, axisPointerModel, axisType, targetShape - ); - moveAnimation - ? graphic.updateProps(pointerEl, { - shape: targetShape - }, axisPointerModel) - : pointerEl.attr({ - shape: targetShape - }); - } - - /** - * @inner - */ - function moveGridShadow(axisType, point, otherExtent) { - var axis = cartesian.getAxis(axisType); - var bandWidth = axis.getBandWidth(); - var span = otherExtent[1] - otherExtent[0]; - var targetShape = axisType === 'x' - ? makeRectShape(point[0] - bandWidth / 2, otherExtent[0], bandWidth, span) - : makeRectShape(otherExtent[0], point[1] - bandWidth / 2, span, bandWidth); - - var pointerEl = self._getPointerElement( - cartesian, axisPointerModel, axisType, targetShape - ); - moveAnimation - ? graphic.updateProps(pointerEl, { - shape: targetShape - }, axisPointerModel) - : pointerEl.attr({ - shape: targetShape - }); - } - }, - - _showSinglePointer: function (axisPointerModel, single, axisType, point) { - var self = this; - var axisPointerType = axisPointerModel.get('type'); - var moveAnimation = axisPointerType !== 'cross'; - var rect = single.getRect(); - var otherExtent = [rect.y, rect.y + rect.height]; - - moveSingleLine(axisType, point, otherExtent); - - /** - * @inner - */ - function moveSingleLine(axisType, point, otherExtent) { - var axis = single.getAxis(); - var orient = axis.orient; - - var targetShape = orient === 'horizontal' - ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1]) - : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]); - - var pointerEl = self._getPointerElement( - single, axisPointerModel, axisType, targetShape - ); - moveAnimation - ? graphic.updateProps(pointerEl, { - shape: targetShape - }, axisPointerModel) - : pointerEl.attr({ - shape: targetShape - }); - } - - }, - - /** - * Show tooltip on axis of polar coordinate - * @param {module:echarts/model/Model} axisPointerModel - * @param {Array.} polar - * @param {string} axisType - * @param {Array.} point - */ - _showPolarPointer: function (axisPointerModel, polar, axisType, point) { - var self = this; - - var axisPointerType = axisPointerModel.get('type'); - - var angleAxis = polar.getAngleAxis(); - var radiusAxis = polar.getRadiusAxis(); - - var moveAnimation = axisPointerType !== 'cross'; - - if (axisPointerType === 'cross') { - movePolarLine('angle', point, radiusAxis.getExtent()); - movePolarLine('radius', point, angleAxis.getExtent()); - - this._updateCrossText(polar, point, axisPointerModel); - } - else { - var otherAxis = polar.getAxis(axisType === 'radius' ? 'angle' : 'radius'); - var otherExtent = otherAxis.getExtent(); - - (axisPointerType === 'line' ? movePolarLine : movePolarShadow)( - axisType, point, otherExtent - ); - } - /** - * @inner - */ - function movePolarLine(axisType, point, otherExtent) { - var mouseCoord = polar.pointToCoord(point); - - var targetShape; - - if (axisType === 'angle') { - var p1 = polar.coordToPoint([otherExtent[0], mouseCoord[1]]); - var p2 = polar.coordToPoint([otherExtent[1], mouseCoord[1]]); - targetShape = makeLineShape(p1[0], p1[1], p2[0], p2[1]); - } - else { - targetShape = { - cx: polar.cx, - cy: polar.cy, - r: mouseCoord[0] - }; - } - - var pointerEl = self._getPointerElement( - polar, axisPointerModel, axisType, targetShape - ); - - moveAnimation - ? graphic.updateProps(pointerEl, { - shape: targetShape - }, axisPointerModel) - : pointerEl.attr({ - shape: targetShape - }); - } - - /** - * @inner - */ - function movePolarShadow(axisType, point, otherExtent) { - var axis = polar.getAxis(axisType); - var bandWidth = axis.getBandWidth(); - - var mouseCoord = polar.pointToCoord(point); - - var targetShape; - - var radian = Math.PI / 180; - - if (axisType === 'angle') { - targetShape = makeSectorShape( - polar.cx, polar.cy, - otherExtent[0], otherExtent[1], - // In ECharts y is negative if angle is positive - (-mouseCoord[1] - bandWidth / 2) * radian, - (-mouseCoord[1] + bandWidth / 2) * radian - ); - } - else { - targetShape = makeSectorShape( - polar.cx, polar.cy, - mouseCoord[0] - bandWidth / 2, - mouseCoord[0] + bandWidth / 2, - 0, Math.PI * 2 - ); - } - - var pointerEl = self._getPointerElement( - polar, axisPointerModel, axisType, targetShape - ); - moveAnimation - ? graphic.updateProps(pointerEl, { - shape: targetShape - }, axisPointerModel) - : pointerEl.attr({ - shape: targetShape - }); - } - }, - - _updateCrossText: function (coordSys, point, axisPointerModel) { - var crossStyleModel = axisPointerModel.getModel('crossStyle'); - var textStyleModel = crossStyleModel.getModel('textStyle'); - - var tooltipModel = this._tooltipModel; - - var text = this._crossText; - if (!text) { - text = this._crossText = new graphic.Text({ - style: { - textAlign: 'left', - textBaseline: 'bottom' - } - }); - this.group.add(text); - } - - var value = coordSys.pointToData(point); - - var dims = coordSys.dimensions; - value = zrUtil.map(value, function (val, idx) { - var axis = coordSys.getAxis(dims[idx]); - if (axis.type === 'category' || axis.type === 'time') { - val = axis.scale.getLabel(val); - } - else { - val = formatUtil.addCommas( - val.toFixed(axis.getPixelPrecision()) - ); - } - return val; - }); - - text.setStyle({ - fill: textStyleModel.getTextColor() || crossStyleModel.get('color'), - textFont: textStyleModel.getFont(), - text: value.join(', '), - x: point[0] + 5, - y: point[1] - 5 - }); - text.z = tooltipModel.get('z'); - text.zlevel = tooltipModel.get('zlevel'); - }, - - _getPointerElement: function (coordSys, pointerModel, axisType, initShape) { - var tooltipModel = this._tooltipModel; - var z = tooltipModel.get('z'); - var zlevel = tooltipModel.get('zlevel'); - var axisPointers = this._axisPointers; - var coordSysName = coordSys.name; - axisPointers[coordSysName] = axisPointers[coordSysName] || {}; - if (axisPointers[coordSysName][axisType]) { - return axisPointers[coordSysName][axisType]; - } - - // Create if not exists - var pointerType = pointerModel.get('type'); - var styleModel = pointerModel.getModel(pointerType + 'Style'); - var isShadow = pointerType === 'shadow'; - var style = styleModel[isShadow ? 'getAreaStyle' : 'getLineStyle'](); - - var elementType = coordSys.type === 'polar' - ? (isShadow ? 'Sector' : (axisType === 'radius' ? 'Circle' : 'Line')) - : (isShadow ? 'Rect' : 'Line'); - - isShadow ? (style.stroke = null) : (style.fill = null); - - var el = axisPointers[coordSysName][axisType] = new graphic[elementType]({ - style: style, - z: z, - zlevel: zlevel, - silent: true, - shape: initShape - }); - - this.group.add(el); - return el; - }, - - /** - * Dispatch actions and show tooltip on series - * @param {Array.} seriesList - * @param {Array.} point - * @param {Array.} value - * @param {boolean} contentNotChange - * @param {Object} e - */ - _dispatchAndShowSeriesTooltipContent: function ( - coordSys, seriesList, point, value, contentNotChange - ) { - - var rootTooltipModel = this._tooltipModel; - var tooltipContent = this._tooltipContent; - - var baseAxis = coordSys.getBaseAxis(); - - var payloadBatch = zrUtil.map(seriesList, function (series) { - return { - seriesIndex: series.seriesIndex, - dataIndex: series.getAxisTooltipDataIndex - ? series.getAxisTooltipDataIndex(series.coordDimToDataDim(baseAxis.dim), value, baseAxis) - : series.getData().indexOfNearest( - series.coordDimToDataDim(baseAxis.dim)[0], - value[baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1] - ) - }; - }); - - var lastHover = this._lastHover; - var api = this._api; - // Dispatch downplay action - if (lastHover.payloadBatch && !contentNotChange) { - api.dispatchAction({ - type: 'downplay', - batch: lastHover.payloadBatch - }); - } - // Dispatch highlight action - if (!contentNotChange) { - api.dispatchAction({ - type: 'highlight', - batch: payloadBatch - }); - lastHover.payloadBatch = payloadBatch; - } - // Dispatch showTip action - api.dispatchAction({ - type: 'showTip', - dataIndex: payloadBatch[0].dataIndex, - seriesIndex: payloadBatch[0].seriesIndex, - from: this.uid - }); - - if (baseAxis && rootTooltipModel.get('showContent')) { - - var formatter = rootTooltipModel.get('formatter'); - var positionExpr = rootTooltipModel.get('position'); - var html; - - var paramsList = zrUtil.map(seriesList, function (series, index) { - return series.getDataParams(payloadBatch[index].dataIndex); - }); - // If only one series - // FIXME - // if (paramsList.length === 1) { - // paramsList = paramsList[0]; - // } - - tooltipContent.show(rootTooltipModel); - - // Update html content - var firstDataIndex = payloadBatch[0].dataIndex; - if (!contentNotChange) { - // Reset ticket - this._ticket = ''; - if (!formatter) { - // Default tooltip content - // FIXME - // (1) shold be the first data which has name? - // (2) themeRiver, firstDataIndex is array, and first line is unnecessary. - var firstLine = seriesList[0].getData().getName(firstDataIndex); - html = (firstLine ? firstLine + '
' : '') - + zrUtil.map(seriesList, function (series, index) { - return series.formatTooltip(payloadBatch[index].dataIndex, true); - }).join('
'); - } - else { - if (typeof formatter === 'string') { - html = formatUtil.formatTpl(formatter, paramsList); - } - else if (typeof formatter === 'function') { - var self = this; - var ticket = 'axis_' + coordSys.name + '_' + firstDataIndex; - var callback = function (cbTicket, html) { - if (cbTicket === self._ticket) { - tooltipContent.setContent(html); - - updatePosition( - positionExpr, point[0], point[1], - tooltipContent, paramsList, null, api - ); - } - }; - self._ticket = ticket; - html = formatter(paramsList, ticket, callback); - } - } - - tooltipContent.setContent(html); - } - - updatePosition( - positionExpr, point[0], point[1], - tooltipContent, paramsList, null, api - ); - } - }, - - /** - * Show tooltip on item - * @param {module:echarts/model/Series} seriesModel - * @param {number} dataIndex - * @param {Object} e - */ - _showItemTooltipContent: function (seriesModel, dataIndex, e) { - // FIXME Graph data - var api = this._api; - var data = seriesModel.getData(); - var itemModel = data.getItemModel(dataIndex); - - var rootTooltipModel = this._tooltipModel; - - var tooltipContent = this._tooltipContent; - - var tooltipModel = itemModel.getModel('tooltip'); - - // If series model - if (tooltipModel.parentModel) { - tooltipModel.parentModel.parentModel = rootTooltipModel; - } - else { - tooltipModel.parentModel = this._tooltipModel; - } - - if (tooltipModel.get('showContent')) { - var formatter = tooltipModel.get('formatter'); - var positionExpr = tooltipModel.get('position'); - var params = seriesModel.getDataParams(dataIndex); - var html; - if (!formatter) { - html = seriesModel.formatTooltip(dataIndex); - } - else { - if (typeof formatter === 'string') { - html = formatUtil.formatTpl(formatter, params); - } - else if (typeof formatter === 'function') { - var self = this; - var ticket = 'item_' + seriesModel.name + '_' + dataIndex; - var callback = function (cbTicket, html) { - if (cbTicket === self._ticket) { - tooltipContent.setContent(html); - - updatePosition( - positionExpr, e.offsetX, e.offsetY, - tooltipContent, params, e.target, api - ); - } - }; - self._ticket = ticket; - html = formatter(params, ticket, callback); - } - } - - tooltipContent.show(tooltipModel); - tooltipContent.setContent(html); - - updatePosition( - positionExpr, e.offsetX, e.offsetY, - tooltipContent, params, e.target, api - ); - } - }, - - /** - * Show axis pointer - * @param {string} [coordSysName] - */ - _showAxisPointer: function (coordSysName) { - if (coordSysName) { - var axisPointers = this._axisPointers[coordSysName]; - axisPointers && zrUtil.each(axisPointers, function (el) { - el.show(); - }); - } - else { - this.group.eachChild(function (child) { - child.show(); - }); - this.group.show(); - } - }, - - _resetLastHover: function () { - var lastHover = this._lastHover; - if (lastHover.payloadBatch) { - this._api.dispatchAction({ - type: 'downplay', - batch: lastHover.payloadBatch - }); - } - // Reset lastHover - this._lastHover = {}; - }, - /** - * Hide axis pointer - * @param {string} [coordSysName] - */ - _hideAxisPointer: function (coordSysName) { - if (coordSysName) { - var axisPointers = this._axisPointers[coordSysName]; - axisPointers && zrUtil.each(axisPointers, function (el) { - el.hide(); - }); - } - else { - this.group.hide(); - } - }, - - _hide: function () { - this._hideAxisPointer(); - this._resetLastHover(); - if (!this._alwaysShowContent) { - this._tooltipContent.hideLater(this._tooltipModel.get('hideDelay')); - } - - this._api.dispatchAction({ - type: 'hideTip', - from: this.uid - }); - }, - - dispose: function (ecModel, api) { - if (env.node) { - return; - } - var zr = api.getZr(); - this._tooltipContent.hide(); - - zr.off('click', this._tryShow); - zr.off('mousemove', this._tryShow); - zr.off('mouseout', this._hide); - - api.off('showTip', this._manuallyShowTip); - api.off('hideTip', this._manuallyHideTip); - } - }); -}); -// FIXME Better way to pack data in graphic element -define('echarts/component/tooltip',['require','./tooltip/TooltipModel','./tooltip/TooltipView','../echarts','../echarts'],function (require) { - - require('./tooltip/TooltipModel'); - - require('./tooltip/TooltipView'); - - // Show tip action - /** - * @action - * @property {string} type - * @property {number} seriesIndex - * @property {number} dataIndex - * @property {number} [x] - * @property {number} [y] - */ - require('../echarts').registerAction( - { - type: 'showTip', - event: 'showTip', - update: 'none' - }, - // noop - function () {} - ); - // Hide tip action - require('../echarts').registerAction( - { - type: 'hideTip', - event: 'hideTip', - update: 'none' - }, - // noop - function () {} - ); -}); -define('echarts/coord/polar/RadiusAxis',['require','zrender/core/util','../Axis'],function (require) { - + // the position of the whole view + left: '5%', + top: '5%', + right: '20%', + bottom: '5%', - var zrUtil = require('zrender/core/util'); - var Axis = require('../Axis'); + // the dx of the node + nodeWidth: 20, - function RadiusAxis(scale, radiusExtent) { + // the distance between two nodes + nodeGap: 8, - Axis.call(this, 'radius', scale, radiusExtent); + // the number of iterations to change the position of the node + layoutIterations: 32, - /** - * Axis type - * - 'category' - * - 'value' - * - 'time' - * - 'log' - * @type {string} - */ - this.type = 'category'; - } + label: { + normal: { + show: true, + position: 'right', + textStyle: { + color: '#000', + fontSize: 12 + } + }, + emphasis: { + show: true + } + }, - RadiusAxis.prototype = { + itemStyle: { + normal: { + borderWidth: 1, + borderColor: '#aaa' + } + }, + + lineStyle: { + normal: { + color: '#314656', + opacity: 0.2, + curveness: 0.5 + }, + emphasis: { + opacity: 0.6 + } + }, + + + // colorEncoded node + + color: ['#9e0142', '#d53e4f', '#f46d43', '#fdae61', '#fee08b','#ffffbf', + '#e6f598', '#abdda4', '#66c2a5', '#3288bd', '#5e4fa2'], + + animationEasing: 'linear', + + animationDuration: 1000 + } + + }); + + + +/***/ }, +/* 232 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var modelUtil = __webpack_require__(5); + var zrUtil = __webpack_require__(3); + + var SankeyShape = graphic.extendShape({ + shape: { + x1: 0, y1: 0, + x2: 0, y2: 0, + cpx1: 0, cpy1: 0, + cpx2: 0, cpy2: 0, + + extent: 0 + }, + + buildPath: function (ctx, shape) { + var halfExtent = shape.extent / 2; + ctx.moveTo(shape.x1, shape.y1 - halfExtent); + ctx.bezierCurveTo( + shape.cpx1, shape.cpy1 - halfExtent, + shape.cpx2, shape.cpy2 - halfExtent, + shape.x2, shape.y2 - halfExtent + ); + ctx.lineTo(shape.x2, shape.y2 + halfExtent); + ctx.bezierCurveTo( + shape.cpx2, shape.cpy2 + halfExtent, + shape.cpx1, shape.cpy1 + halfExtent, + shape.x1, shape.y1 + halfExtent + ); + ctx.closePath(); + } + }); + + module.exports = __webpack_require__(1).extendChartView({ + + type: 'sankey', + + /** + * @private + * @type {module:echarts/chart/sankey/SankeySeries} + */ + _model: null, + + render: function(seriesModel, ecModel, api) { + var graph = seriesModel.getGraph(); + var group = this.group; + var layoutInfo = seriesModel.layoutInfo; + + this._model = seriesModel; + + group.removeAll(); + + group.position = [layoutInfo.x, layoutInfo.y]; + + var edgeData = graph.edgeData; + var rawOption = seriesModel.option; + var formatModel = modelUtil.createDataFormatModel( + seriesModel, edgeData, rawOption.edges || rawOption.links + ); + + formatModel.formatTooltip = function (dataIndex) { + var params = this.getDataParams(dataIndex); + var rawDataOpt = params.data; + var html = rawDataOpt.source + ' -- ' + rawDataOpt.target; + if (params.value) { + html += ':' + params.value; + } + return html; + }; + + // generate a rect for each node + graph.eachNode(function (node) { + var layout = node.getLayout(); + var itemModel = node.getModel(); + var labelModel = itemModel.getModel('label.normal'); + var textStyleModel = labelModel.getModel('textStyle'); + var labelHoverModel = itemModel.getModel('label.emphasis'); + var textStyleHoverModel = labelHoverModel.getModel('textStyle'); + + var rect = new graphic.Rect({ + shape: { + x: layout.x, + y: layout.y, + width: node.getLayout().dx, + height: node.getLayout().dy + }, + style: { + // Get formatted label in label.normal option. Use node id if it is not specified + text: labelModel.get('show') + ? seriesModel.getFormattedLabel(node.dataIndex, 'normal') || node.id + // Use empty string to hide the label + : '', + textFont: textStyleModel.getFont(), + textFill: textStyleModel.getTextColor(), + textPosition: labelModel.get('position') + } + }); + + rect.setStyle(zrUtil.defaults( + { + fill: node.getVisual('color') + }, + itemModel.getModel('itemStyle.normal').getItemStyle() + )); + + graphic.setHoverStyle(rect, zrUtil.extend( + node.getModel('itemStyle.emphasis'), + { + text: labelHoverModel.get('show') + ? seriesModel.getFormattedLabel(node.dataIndex, 'emphasis') || node.id + : '', + textFont: textStyleHoverModel.getFont(), + textFill: textStyleHoverModel.getTextColor(), + textPosition: labelHoverModel.get('position') + } + )); + + group.add(rect); + }); + + // generate a bezire Curve for each edge + graph.eachEdge(function (edge) { + var curve = new SankeyShape(); + + curve.dataIndex = edge.dataIndex; + curve.hostModel = formatModel; + + var lineStyleModel = edge.getModel('lineStyle.normal'); + var curvature = lineStyleModel.get('curveness'); + var n1Layout = edge.node1.getLayout(); + var n2Layout = edge.node2.getLayout(); + var edgeLayout = edge.getLayout(); + + curve.shape.extent = Math.max(1, edgeLayout.dy); + + var x1 = n1Layout.x + n1Layout.dx; + var y1 = n1Layout.y + edgeLayout.sy + edgeLayout.dy / 2; + var x2 = n2Layout.x; + var y2 = n2Layout.y + edgeLayout.ty + edgeLayout.dy /2; + var cpx1 = x1 * (1 - curvature) + x2 * curvature; + var cpy1 = y1; + var cpx2 = x1 * curvature + x2 * (1 - curvature); + var cpy2 = y2; + + curve.setShape({ + x1: x1, + y1: y1, + x2: x2, + y2: y2, + cpx1: cpx1, + cpy1: cpy1, + cpx2: cpx2, + cpy2: cpy2 + }); + + curve.setStyle(lineStyleModel.getItemStyle()); + graphic.setHoverStyle(curve, edge.getModel('lineStyle.emphasis').getItemStyle()); + + group.add(curve); + + }); + if (!this._data) { + group.setClipPath(createGridClipShape(group.getBoundingRect(), seriesModel, function () { + group.removeClipPath(); + })); + } + this._data = seriesModel.getData(); + } + }); + + //add animation to the view + function createGridClipShape(rect, seriesModel, cb) { + var rectEl = new graphic.Rect({ + shape: { + x: rect.x - 10, + y: rect.y - 10, + width: 0, + height: rect.height + 20 + } + }); + graphic.initProps(rectEl, { + shape: { + width: rect.width + 20, + height: rect.height + 20 + } + }, seriesModel, cb); + + return rectEl; + } + + +/***/ }, +/* 233 */ +/***/ function(module, exports, __webpack_require__) { + + + + var layout = __webpack_require__(21); + var nest = __webpack_require__(234); + var zrUtil = __webpack_require__(3); + + module.exports = function (ecModel, api) { + + ecModel.eachSeriesByType('sankey', function (seriesModel) { + + var nodeWidth = seriesModel.get('nodeWidth'); + var nodeGap = seriesModel.get('nodeGap'); + + var layoutInfo = getViewRect(seriesModel, api); + + seriesModel.layoutInfo = layoutInfo; + + var width = layoutInfo.width; + var height = layoutInfo.height; + + var graph = seriesModel.getGraph(); + + var nodes = graph.nodes; + var edges = graph.edges; + + computeNodeValues(nodes); + + var filteredNodes = nodes.filter(function (node) { + return node.getLayout().value === 0; + }); + + var iterations = filteredNodes.length !== 0 + ? 0 : seriesModel.get('layoutIterations'); + + layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations); + }); + }; + + /** + * get the layout position of the whole view. + */ + function getViewRect(seriesModel, api) { + return layout.getLayoutRect( + seriesModel.getBoxLayoutParams(), { + width: api.getWidth(), + height: api.getHeight() + } + ); + } + + function layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations) { + computeNodeBreadths(nodes, nodeWidth, width); + computeNodeDepths(nodes, edges, height, nodeGap, iterations); + computeEdgeDepths(nodes); + } + + /** + * compute the value of each node by summing the associated edge's value. + * @param {module:echarts/data/Graph~Node} nodes + */ + function computeNodeValues(nodes) { + zrUtil.each(nodes, function (node) { + var value1 = sum(node.outEdges, getEdgeValue); + var value2 = sum(node.inEdges, getEdgeValue); + var value = Math.max(value1, value2); + node.setLayout({value: value}, true); + }); + } + + /** + * compute the x-position for each node. + * @param {module:echarts/data/Graph~Node} nodes + * @param {number} nodeWidth + * @param {number} width + */ + function computeNodeBreadths(nodes, nodeWidth, width) { + var remainNodes = nodes; + var nextNode = null; + var x = 0; + var kx = 0; + + while (remainNodes.length) { + nextNode = []; + + for (var i = 0, len = remainNodes.length; i < len; i++) { + var node = remainNodes[i]; + node.setLayout({x: x}, true); + node.setLayout({dx: nodeWidth}, true); + + for (var j = 0, lenj = node.outEdges.length; j < lenj; j++) { + nextNode.push(node.outEdges[j].node2); + } + } + remainNodes = nextNode; + ++x; + } + + moveSinksRight(nodes, x); + kx = (width - nodeWidth) / (x - 1); + + scaleNodeBreadths(nodes, kx); + } + + /** + * all the node without outEgdes are assigned maximum breadth and + * be aligned in the last column. + * @param {module:echarts/data/Graph~Node} nodes + * @param {number} x + */ + function moveSinksRight(nodes, x) { + zrUtil.each(nodes, function (node) { + if(!node.outEdges.length) { + node.setLayout({x: x-1}, true); + } + }); + } + + /** + * scale node x-position to the width. + * @param {module:echarts/data/Graph~Node} nodes + * @param {number} kx + */ + function scaleNodeBreadths(nodes, kx) { + zrUtil.each(nodes, function(node) { + var nodeX = node.getLayout().x * kx; + node.setLayout({x: nodeX}, true); + }); + } + + /** + * using Gauss-Seidel iterations method to compute the node depth(y-position). + * @param {module:echarts/data/Graph~Node} nodes + * @param {module:echarts/data/Graph~Edge} edges + * @param {number} height + * @param {numbber} nodeGap + * @param {number} iterations + */ + function computeNodeDepths(nodes, edges, height, nodeGap, iterations) { + var nodesByBreadth = nest() + .key(function (d) { + return d.getLayout().x; + }) + .sortKeys(ascending) + .entries(nodes) + .map(function (d) { + return d.values; + }); + + initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap); + resolveCollisions(nodesByBreadth, nodeGap, height); + + for (var alpha = 1; iterations > 0; iterations--) { + alpha *= 0.99; + relaxRightToLeft(nodesByBreadth, alpha); + resolveCollisions(nodesByBreadth, nodeGap, height); + relaxLeftToRight(nodesByBreadth, alpha); + resolveCollisions(nodesByBreadth, nodeGap, height); + } + } + + /** + * compute the original y-position for each node. + * @param {module:echarts/data/Graph~Node} nodes + * @param {Array.>} nodesByBreadth + * @param {module:echarts/data/Graph~Edge} edges + * @param {number} height + * @param {number} nodeGap + */ + function initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap) { + var kyArray = []; + zrUtil.each(nodesByBreadth, function (nodes) { + var n = nodes.length; + var sum = 0; + zrUtil.each(nodes, function (node) { + sum += node.getLayout().value; + }); + var ky = (height - (n-1) * nodeGap) / sum; + kyArray.push(ky); + }); + kyArray.sort(function (a, b) { + return a - b; + }); + var ky0 = kyArray[0]; + + zrUtil.each(nodesByBreadth, function (nodes) { + zrUtil.each(nodes, function (node, i) { + node.setLayout({y: i}, true); + var nodeDy = node.getLayout().value * ky0; + node.setLayout({dy: nodeDy}, true); + }); + }); + + zrUtil.each(edges, function (edge) { + var edgeDy = +edge.getValue() * ky0; + edge.setLayout({dy: edgeDy}, true); + }); + } + + /** + * resolve the collision of initialized depth. + * @param {Array.>} nodesByBreadth + * @param {number} nodeGap + * @param {number} height + */ + function resolveCollisions(nodesByBreadth, nodeGap, height) { + zrUtil.each(nodesByBreadth, function (nodes) { + var node; + var dy; + var y0 = 0; + var n = nodes.length; + var i; + + nodes.sort(ascendingDepth); + + for (i = 0; i < n; i++) { + node = nodes[i]; + dy = y0 - node.getLayout().y; + if(dy > 0) { + var nodeY = node.getLayout().y + dy; + node.setLayout({y: nodeY}, true); + } + y0 = node.getLayout().y + node.getLayout().dy + nodeGap; + } + + // if the bottommost node goes outside the biunds, push it back up + dy = y0 - nodeGap - height; + if (dy > 0) { + var nodeY = node.getLayout().y -dy; + node.setLayout({y: nodeY}, true); + y0 = node.getLayout().y; + for (i = n - 2; i >= 0; --i) { + node = nodes[i]; + dy = node.getLayout().y + node.getLayout().dy + nodeGap - y0; + if (dy > 0) { + nodeY = node.getLayout().y - dy; + node.setLayout({y: nodeY}, true); + } + y0 = node.getLayout().y; + } + } + }); + } + + /** + * change the y-position of the nodes, except most the right side nodes. + * @param {Array.>} nodesByBreadth + * @param {number} alpha + */ + function relaxRightToLeft(nodesByBreadth, alpha) { + zrUtil.each(nodesByBreadth.slice().reverse(), function (nodes) { + zrUtil.each(nodes, function (node) { + if (node.outEdges.length) { + var y = sum(node.outEdges, weightedTarget) / sum(node.outEdges, getEdgeValue); + var nodeY = node.getLayout().y + (y - center(node)) * alpha; + node.setLayout({y: nodeY}, true); + } + }); + }); + } + + function weightedTarget(edge) { + return center(edge.node2) * edge.getValue(); + } + + /** + * change the y-position of the nodes, except most the left side nodes. + * @param {Array.>} nodesByBreadth + * @param {number} alpha + */ + function relaxLeftToRight(nodesByBreadth, alpha) { + zrUtil.each(nodesByBreadth, function (nodes) { + zrUtil.each(nodes, function (node) { + if (node.inEdges.length) { + var y = sum(node.inEdges, weightedSource) / sum(node.inEdges, getEdgeValue); + var nodeY = node.getLayout().y + (y - center(node)) * alpha; + node.setLayout({y: nodeY}, true); + } + }); + }); + } + + function weightedSource(edge) { + return center(edge.node1) * edge.getValue(); + } + + /** + * compute the depth(y-position) of each edge. + * @param {module:echarts/data/Graph~Node} nodes + */ + function computeEdgeDepths(nodes) { + zrUtil.each(nodes, function (node) { + node.outEdges.sort(ascendingTargetDepth); + node.inEdges.sort(ascendingSourceDepth); + }); + zrUtil.each(nodes, function (node) { + var sy = 0; + var ty = 0; + zrUtil.each(node.outEdges, function (edge) { + edge.setLayout({sy: sy}, true); + sy += edge.getLayout().dy; + }); + zrUtil.each(node.inEdges, function (edge) { + edge.setLayout({ty: ty}, true); + ty += edge.getLayout().dy; + }); + }); + } + + function ascendingTargetDepth(a, b) { + return a.node2.getLayout().y - b.node2.getLayout().y; + } + + function ascendingSourceDepth(a, b) { + return a.node1.getLayout().y - b.node1.getLayout().y; + } + + function sum(array, f) { + var s = 0; + var n = array.length; + var a; + var i = -1; + if (arguments.length === 1) { + while (++i < n) { + a = +array[i]; + if (!isNaN(a)) { + s += a; + } + } + } + else { + while (++i < n) { + a = +f.call(array, array[i], i); + if(!isNaN(a)) { + s += a; + } + } + } + return s; + } + + function center(node) { + return node.getLayout().y + node.getLayout().dy / 2; + } + + function ascendingDepth(a, b) { + return a.getLayout().y - b.getLayout().y; + } + + function ascending(a, b) { + return a < b ? -1 : a > b ? 1 : a == b ? 0 : NaN; + } + + function getEdgeValue(edge) { + return edge.getValue(); + } + + + +/***/ }, +/* 234 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + /** + * nest helper used to group by the array. + * can specified the keys and sort the keys. + */ + function nest() { + + var keysFunction = []; + var sortKeysFunction = []; + + /** + * map an Array into the mapObject. + * @param {Array} array + * @param {number} depth + */ + function map(array, depth) { + if (depth >= keysFunction.length) { + return array; + } + var i = -1; + var n = array.length; + var keyFunction = keysFunction[depth++]; + var mapObject = {}; + var valuesByKey = {}; + + while (++i < n) { + var keyValue = keyFunction(array[i]); + var values = valuesByKey[keyValue]; + + if (values) { + values.push(array[i]); + } + else { + valuesByKey[keyValue] = [array[i]]; + } + } + + zrUtil.each(valuesByKey, function (value, key) { + mapObject[key] = map(value, depth); + }); + + return mapObject; + } + + /** + * transform the Map Object to multidimensional Array + * @param {Object} map + * @param {number} depth + */ + function entriesMap(mapObject, depth) { + if (depth >= keysFunction.length) { + return mapObject; + } + var array = []; + var sortKeyFunction = sortKeysFunction[depth++]; + + zrUtil.each(mapObject, function (value, key) { + array.push({ + key: key, values: entriesMap(value, depth) + }); + }); + + if (sortKeyFunction) { + return array.sort(function (a, b) { + return sortKeyFunction(a.key, b.key); + }); + } + else { + return array; + } + } + + return { + /** + * specified the key to groupby the arrays. + * users can specified one more keys. + * @param {Function} d + */ + key: function (d) { + keysFunction.push(d); + return this; + }, + + /** + * specified the comparator to sort the keys + * @param {Function} order + */ + sortKeys: function (order) { + sortKeysFunction[keysFunction.length - 1] = order; + return this; + }, + + /** + * the array to be grouped by. + * @param {Array} array + */ + entries: function (array) { + return entriesMap(map(array, 0), 0); + } + }; + } + module.exports = nest; + + +/***/ }, +/* 235 */ +/***/ function(module, exports, __webpack_require__) { + + + + var VisualMapping = __webpack_require__(187); + + module.exports = function (ecModel, payload) { + ecModel.eachSeriesByType('sankey', function (seriesModel) { + var graph = seriesModel.getGraph(); + var nodes = graph.nodes; + + nodes.sort(function (a, b) { + return a.getLayout().value - b.getLayout().value; + }); + + var minValue = nodes[0].getLayout().value; + var maxValue = nodes[nodes.length - 1].getLayout().value; + + nodes.forEach(function (node) { + var mapping = new VisualMapping({ + type: 'color', + mappingMethod: 'linear', + dataExtent: [minValue, maxValue], + visual: seriesModel.get('color') + }); + + var mapValueToColor = mapping.mapValueToVisual(node.getLayout().value); + node.setVisual('color', mapValueToColor); + }); + + }) ; + }; + + +/***/ }, +/* 236 */ +/***/ function(module, exports, __webpack_require__) { + + + + var echarts = __webpack_require__(1); + + __webpack_require__(237); + __webpack_require__(240); - constructor: RadiusAxis, + echarts.registerVisualCoding('chart', __webpack_require__(241)); + echarts.registerLayout(__webpack_require__(242)); - dataToRadius: Axis.prototype.dataToCoord, - radiusToData: Axis.prototype.coordToData - }; - zrUtil.inherits(RadiusAxis, Axis); +/***/ }, +/* 237 */ +/***/ function(module, exports, __webpack_require__) { - return RadiusAxis; -}); -define('echarts/coord/polar/AngleAxis',['require','zrender/core/util','../Axis'],function(require) { - + 'use strict'; - var zrUtil = require('zrender/core/util'); - var Axis = require('../Axis'); - function AngleAxis(scale, angleExtent) { + var zrUtil = __webpack_require__(3); + var SeriesModel = __webpack_require__(27); + var whiskerBoxCommon = __webpack_require__(238); + + var BoxplotSeries = SeriesModel.extend({ - angleExtent = angleExtent || [0, 360]; + type: 'series.boxplot', - Axis.call(this, 'angle', scale, angleExtent); + dependencies: ['xAxis', 'yAxis', 'grid'], - /** - * Axis type - * - 'category' - * - 'value' - * - 'time' - * - 'log' - * @type {string} - */ - this.type = 'category'; - } + // TODO + // box width represents group size, so dimension should have 'size'. - AngleAxis.prototype = { + /** + * @see + * The meanings of 'min' and 'max' depend on user, + * and echarts do not need to know it. + * @readOnly + */ + valueDimensions: ['min', 'Q1', 'median', 'Q3', 'max'], - constructor: AngleAxis, + /** + * @type {Array.} + * @readOnly + */ + dimensions: null, - dataToAngle: Axis.prototype.dataToCoord, + /** + * @override + */ + defaultOption: { + zlevel: 0, // 一级层叠 + z: 2, // 二级层叠 + coordinateSystem: 'cartesian2d', + legendHoverLink: true, - angleToData: Axis.prototype.coordToData - }; + hoverAnimation: true, - zrUtil.inherits(AngleAxis, Axis); + xAxisIndex: 0, + yAxisIndex: 0, - return AngleAxis; -}); -/** - * @module echarts/coord/polar/Polar - */ -define('echarts/coord/polar/Polar',['require','./RadiusAxis','./AngleAxis'],function(require) { - - - - var RadiusAxis = require('./RadiusAxis'); - var AngleAxis = require('./AngleAxis'); - - /** - * @alias {module:echarts/coord/polar/Polar} - * @constructor - * @param {string} name - */ - var Polar = function (name) { - - /** - * @type {string} - */ - this.name = name || ''; - - /** - * x of polar center - * @type {number} - */ - this.cx = 0; - - /** - * y of polar center - * @type {number} - */ - this.cy = 0; - - /** - * @type {module:echarts/coord/polar/RadiusAxis} - * @private - */ - this._radiusAxis = new RadiusAxis(); - - /** - * @type {module:echarts/coord/polar/AngleAxis} - * @private - */ - this._angleAxis = new AngleAxis(); - }; - - Polar.prototype = { - - constructor: Polar, - - type: 'polar', - - /** - * @param {Array.} - * @readOnly - */ - dimensions: ['radius', 'angle'], - - /** - * If contain coord - * @param {Array.} point - * @return {boolean} - */ - containPoint: function (point) { - var coord = this.pointToCoord(point); - return this._radiusAxis.contain(coord[0]) - && this._angleAxis.contain(coord[1]); - }, - - /** - * If contain data - * @param {Array.} data - * @return {boolean} - */ - containData: function (data) { - return this._radiusAxis.containData(data[0]) - && this._angleAxis.containData(data[1]); - }, - - /** - * @param {string} axisType - * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis} - */ - getAxis: function (axisType) { - return this['_' + axisType + 'Axis']; - }, - - /** - * Get axes by type of scale - * @param {string} scaleType - * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis} - */ - getAxesByScale: function (scaleType) { - var axes = []; - var angleAxis = this._angleAxis; - var radiusAxis = this._radiusAxis; - angleAxis.scale.type === scaleType && axes.push(angleAxis); - radiusAxis.scale.type === scaleType && axes.push(radiusAxis); - - return axes; - }, - - /** - * @return {module:echarts/coord/polar/AngleAxis} - */ - getAngleAxis: function () { - return this._angleAxis; - }, - - /** - * @return {module:echarts/coord/polar/RadiusAxis} - */ - getRadiusAxis: function () { - return this._radiusAxis; - }, - - /** - * @param {module:echarts/coord/polar/Axis} - * @return {module:echarts/coord/polar/Axis} - */ - getOtherAxis: function (axis) { - var angleAxis = this._angleAxis; - return axis === angleAxis ? this._radiusAxis : angleAxis; - }, - - /** - * Base axis will be used on stacking. - * - * @return {module:echarts/coord/polar/Axis} - */ - getBaseAxis: function () { - return this.getAxesByScale('ordinal')[0] - || this.getAxesByScale('time')[0] - || this.getAngleAxis(); - }, - - /** - * Convert series data to a list of (x, y) points - * @param {module:echarts/data/List} data - * @return {Array} - * Return list of coordinates. For example: - * `[[10, 10], [20, 20], [30, 30]]` - */ - dataToPoints: function (data) { - return data.mapArray(this.dimensions, function (radius, angle) { - return this.dataToPoint([radius, angle]); - }, this); - }, - - /** - * Convert a single data item to (x, y) point. - * Parameter data is an array which the first element is radius and the second is angle - * @param {Array.} data - * @param {boolean} [clamp=false] - * @return {Array.} - */ - dataToPoint: function (data, clamp) { - return this.coordToPoint([ - this._radiusAxis.dataToRadius(data[0], clamp), - this._angleAxis.dataToAngle(data[1], clamp) - ]); - }, - - /** - * Convert a (x, y) point to data - * @param {Array.} point - * @param {boolean} [clamp=false] - * @return {Array.} - */ - pointToData: function (point, clamp) { - var coord = this.pointToCoord(point); - return [ - this._radiusAxis.radiusToData(coord[0], clamp), - this._angleAxis.angleToData(coord[1], clamp) - ]; - }, - - /** - * Convert a (x, y) point to (radius, angle) coord - * @param {Array.} point - * @return {Array.} - */ - pointToCoord: function (point) { - var dx = point[0] - this.cx; - var dy = point[1] - this.cy; - var angleAxis = this.getAngleAxis(); - var extent = angleAxis.getExtent(); - var minAngle = Math.min(extent[0], extent[1]); - var maxAngle = Math.max(extent[0], extent[1]); - // Fix fixed extent in polarCreator - // FIXME - angleAxis.inverse - ? (minAngle = maxAngle - 360) - : (maxAngle = minAngle + 360); - - var radius = Math.sqrt(dx * dx + dy * dy); - dx /= radius; - dy /= radius; - - var radian = Math.atan2(-dy, dx) / Math.PI * 180; - - // move to angleExtent - var dir = radian < minAngle ? 1 : -1; - while (radian < minAngle || radian > maxAngle) { - radian += dir * 360; - } - - return [radius, radian]; - }, - - /** - * Convert a (radius, angle) coord to (x, y) point - * @param {Array.} coord - * @return {Array.} - */ - coordToPoint: function (coord) { - var radius = coord[0]; - var radian = coord[1] / 180 * Math.PI; - var x = Math.cos(radian) * radius + this.cx; - // Inverse the y - var y = -Math.sin(radian) * radius + this.cy; - - return [x, y]; - } - }; - - return Polar; -}); -define('echarts/coord/polar/AxisModel',['require','zrender/core/util','../../model/Component','../axisModelCreator','../axisModelCommonMixin'],function(require) { + layout: null, // 'horizontal' or 'vertical' + boxWidth: [7, 50], // [min, max] can be percent of band width. - + itemStyle: { + normal: { + color: '#fff', + borderWidth: 1 + }, + emphasis: { + borderWidth: 2, + shadowBlur: 5, + shadowOffsetX: 2, + shadowOffsetY: 2, + shadowColor: 'rgba(0,0,0,0.4)' + } + }, - var zrUtil = require('zrender/core/util'); - var ComponentModel = require('../../model/Component'); - var axisModelCreator = require('../axisModelCreator'); + animationEasing: 'elasticOut', + animationDuration: 800 + } + }); + + zrUtil.mixin(BoxplotSeries, whiskerBoxCommon.seriesModelMixin, true); + + module.exports = BoxplotSeries; + + + +/***/ }, +/* 238 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var List = __webpack_require__(94); + var completeDimensions = __webpack_require__(96); + var WhiskerBoxDraw = __webpack_require__(239); + var zrUtil = __webpack_require__(3); + + function getItemValue(item) { + return item.value == null ? item : item.value; + } + + var seriesModelMixin = { + + /** + * @private + * @type {string} + */ + _baseAxisDim: null, + + /** + * @override + */ + getInitialData: function (option, ecModel) { + // When both types of xAxis and yAxis are 'value', layout is + // needed to be specified by user. Otherwise, layout can be + // judged by which axis is category. + + var categories; + + var xAxisModel = ecModel.getComponent('xAxis', this.get('xAxisIndex')); + var yAxisModel = ecModel.getComponent('yAxis', this.get('yAxisIndex')); + var xAxisType = xAxisModel.get('type'); + var yAxisType = yAxisModel.get('type'); + var addOrdinal; + + // FIXME + // 考虑时间轴 + + if (xAxisType === 'category') { + option.layout = 'horizontal'; + categories = xAxisModel.getCategories(); + addOrdinal = true; + } + else if (yAxisType === 'category') { + option.layout = 'vertical'; + categories = yAxisModel.getCategories(); + addOrdinal = true; + } + else { + option.layout = option.layout || 'horizontal'; + } + + this._baseAxisDim = option.layout === 'horizontal' ? 'x' : 'y'; + + var data = option.data; + var dimensions = this.dimensions = ['base'].concat(this.valueDimensions); + completeDimensions(dimensions, data); + + var list = new List(dimensions, this); + list.initData(data, categories ? categories.slice() : null, function (dataItem, dimName, idx, dimIdx) { + var value = getItemValue(dataItem); + return addOrdinal ? (dimName === 'base' ? idx : value[dimIdx - 1]) : value[dimIdx]; + }); + + return list; + }, + + /** + * Used by Gird. + * @param {string} axisDim 'x' or 'y' + * @return {Array.} dimensions on the axis. + */ + coordDimToDataDim: function (axisDim) { + var dims = this.valueDimensions.slice(); + var baseDim = ['base']; + var map = { + horizontal: {x: baseDim, y: dims}, + vertical: {x: dims, y: baseDim} + }; + return map[this.get('layout')][axisDim]; + }, + + /** + * @override + * @param {string|number} dataDim + * @return {string} coord dimension + */ + dataDimToCoordDim: function (dataDim) { + var dim; + + zrUtil.each(['x', 'y'], function (coordDim, index) { + var dataDims = this.coordDimToDataDim(coordDim); + if (zrUtil.indexOf(dataDims, dataDim) >= 0) { + dim = coordDim; + } + }, this); + + return dim; + }, + + /** + * If horizontal, base axis is x, otherwise y. + * @override + */ + getBaseAxis: function () { + var dim = this._baseAxisDim; + return this.ecModel.getComponent(dim + 'Axis', this.get(dim + 'AxisIndex')).axis; + } + }; + + var viewMixin = { + + init: function () { + /** + * Old data. + * @private + * @type {module:echarts/chart/helper/WhiskerBoxDraw} + */ + var whiskerBoxDraw = this._whiskerBoxDraw = new WhiskerBoxDraw( + this.getStyleUpdater() + ); + this.group.add(whiskerBoxDraw.group); + }, + + render: function (seriesModel, ecModel, api) { + this._whiskerBoxDraw.updateData(seriesModel.getData()); + }, + + remove: function (ecModel) { + this._whiskerBoxDraw.remove(); + } + }; + + module.exports = { + seriesModelMixin: seriesModelMixin, + viewMixin: viewMixin + }; + + +/***/ }, +/* 239 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/chart/helper/Symbol + */ + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var Path = __webpack_require__(44); + + var WhiskerPath = Path.extend({ + + type: 'whiskerInBox', + + shape: {}, + + buildPath: function (ctx, shape) { + for (var i in shape) { + if (i.indexOf('ends') === 0) { + var pts = shape[i]; + ctx.moveTo(pts[0][0], pts[0][1]); + ctx.lineTo(pts[1][0], pts[1][1]); + } + } + } + }); + + /** + * @constructor + * @alias {module:echarts/chart/helper/WhiskerBox} + * @param {module:echarts/data/List} data + * @param {number} idx + * @param {Function} styleUpdater + * @param {boolean} isInit + * @extends {module:zrender/graphic/Group} + */ + function WhiskerBox(data, idx, styleUpdater, isInit) { + graphic.Group.call(this); + + /** + * @type {number} + * @readOnly + */ + this.bodyIndex; + + /** + * @type {number} + * @readOnly + */ + this.whiskerIndex; + + /** + * @type {Function} + */ + this.styleUpdater = styleUpdater; + + this._createContent(data, idx, isInit); + + this.updateData(data, idx, isInit); + + /** + * Last series model. + * @type {module:echarts/model/Series} + */ + this._seriesModel; + } + + var whiskerBoxProto = WhiskerBox.prototype; + + whiskerBoxProto._createContent = function (data, idx, isInit) { + var itemLayout = data.getItemLayout(idx); + var constDim = itemLayout.chartLayout === 'horizontal' ? 1 : 0; + var count = 0; + + // Whisker element. + this.add(new graphic.Polygon({ + shape: { + points: isInit + ? transInit(itemLayout.bodyEnds, constDim, itemLayout) + : itemLayout.bodyEnds + }, + style: {strokeNoScale: true}, + z2: 100 + })); + this.bodyIndex = count++; + + // Box element. + var whiskerEnds = zrUtil.map(itemLayout.whiskerEnds, function (ends) { + return isInit ? transInit(ends, constDim, itemLayout) : ends; + }); + this.add(new WhiskerPath({ + shape: makeWhiskerEndsShape(whiskerEnds), + style: {strokeNoScale: true}, + z2: 100 + })); + this.whiskerIndex = count++; + }; + + function transInit(points, dim, itemLayout) { + return zrUtil.map(points, function (point) { + point = point.slice(); + point[dim] = itemLayout.initBaseline; + return point; + }); + } + + function makeWhiskerEndsShape(whiskerEnds) { + // zr animation only support 2-dim array. + var shape = {}; + zrUtil.each(whiskerEnds, function (ends, i) { + shape['ends' + i] = ends; + }); + return shape; + } + + /** + * Update symbol properties + * @param {module:echarts/data/List} data + * @param {number} idx + */ + whiskerBoxProto.updateData = function (data, idx, isInit) { + var seriesModel = this._seriesModel = data.hostModel; + var itemLayout = data.getItemLayout(idx); + var updateMethod = graphic[isInit ? 'initProps' : 'updateProps']; + // this.childAt(this.bodyIndex).stopAnimation(true); + // this.childAt(this.whiskerIndex).stopAnimation(true); + updateMethod( + this.childAt(this.bodyIndex), + {shape: {points: itemLayout.bodyEnds}}, + seriesModel + ); + updateMethod( + this.childAt(this.whiskerIndex), + {shape: makeWhiskerEndsShape(itemLayout.whiskerEnds)}, + seriesModel + ); + + this.styleUpdater.call(null, this, data, idx); + }; + + zrUtil.inherits(WhiskerBox, graphic.Group); + + + /** + * @constructor + * @alias module:echarts/chart/helper/WhiskerBoxDraw + */ + function WhiskerBoxDraw(styleUpdater) { + this.group = new graphic.Group(); + this.styleUpdater = styleUpdater; + } + + var whiskerBoxDrawProto = WhiskerBoxDraw.prototype; + + /** + * Update symbols draw by new data + * @param {module:echarts/data/List} data + */ + whiskerBoxDrawProto.updateData = function (data) { + var group = this.group; + var oldData = this._data; + var styleUpdater = this.styleUpdater; + + data.diff(oldData) + .add(function (newIdx) { + if (data.hasValue(newIdx)) { + var symbolEl = new WhiskerBox(data, newIdx, styleUpdater, true); + data.setItemGraphicEl(newIdx, symbolEl); + group.add(symbolEl); + } + }) + .update(function (newIdx, oldIdx) { + var symbolEl = oldData.getItemGraphicEl(oldIdx); + + // Empty data + if (!data.hasValue(newIdx)) { + group.remove(symbolEl); + return; + } + + if (!symbolEl) { + symbolEl = new WhiskerBox(data, newIdx, styleUpdater); + } + else { + symbolEl.updateData(data, newIdx); + } + + // Add back + group.add(symbolEl); + + data.setItemGraphicEl(newIdx, symbolEl); + }) + .remove(function (oldIdx) { + var el = oldData.getItemGraphicEl(oldIdx); + el && group.remove(el); + }) + .execute(); + + this._data = data; + }; + + /** + * Remove symbols. + * @param {module:echarts/data/List} data + */ + whiskerBoxDrawProto.remove = function () { + var group = this.group; + var data = this._data; + this._data = null; + data && data.eachItemGraphicEl(function (el) { + el && group.remove(el); + }); + }; + + module.exports = WhiskerBoxDraw; + + +/***/ }, +/* 240 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var ChartView = __webpack_require__(41); + var graphic = __webpack_require__(42); + var whiskerBoxCommon = __webpack_require__(238); - var PolarAxisModel = ComponentModel.extend({ - type: 'polarAxis', - /** - * @type {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis} - */ - axis: null - }); + var BoxplotView = ChartView.extend({ - zrUtil.merge(PolarAxisModel.prototype, require('../axisModelCommonMixin')); + type: 'boxplot', - var polarAxisDefaultExtendedOption = { - angle: { - polarIndex: 0, + getStyleUpdater: function () { + return updateStyle; + } + }); - startAngle: 90, + zrUtil.mixin(BoxplotView, whiskerBoxCommon.viewMixin, true); - clockwise: true, + // Update common properties + var normalStyleAccessPath = ['itemStyle', 'normal']; + var emphasisStyleAccessPath = ['itemStyle', 'emphasis']; + + function updateStyle(itemGroup, data, idx) { + var itemModel = data.getItemModel(idx); + var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath); + var borderColor = data.getItemVisual(idx, 'color'); + + // Exclude borderColor. + var itemStyle = normalItemStyleModel.getItemStyle(['borderColor']); - splitNumber: 12, + var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex); + whiskerEl.style.set(itemStyle); + whiskerEl.style.stroke = borderColor; + whiskerEl.dirty(); + + var bodyEl = itemGroup.childAt(itemGroup.bodyIndex); + bodyEl.style.set(itemStyle); + bodyEl.style.stroke = borderColor; + bodyEl.dirty(); - axisLabel: { - rotate: false - } - }, - radius: { - polarIndex: 0, + var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle(); + graphic.setHoverStyle(itemGroup, hoverStyle); + } - splitNumber: 5 - } - }; + module.exports = BoxplotView; - function getAxisType(axisDim, option) { - // Default axis with data is category axis - return option.type || (option.data ? 'category' : 'value'); - } - axisModelCreator('angle', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.angle); - axisModelCreator('radius', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.radius); -}); -define('echarts/coord/polar/PolarModel',['require','./AxisModel','../../echarts'],function (require) { +/***/ }, +/* 241 */ +/***/ function(module, exports) { - + - require('./AxisModel'); + var borderColorQuery = ['itemStyle', 'normal', 'borderColor']; - require('../../echarts').extendComponentModel({ + module.exports = function (ecModel, api) { - type: 'polar', + var globalColors = ecModel.get('color'); - dependencies: ['polarAxis', 'angleAxis'], + ecModel.eachRawSeriesByType('boxplot', function (seriesModel) { - /** - * @type {module:echarts/coord/polar/Polar} - */ - coordinateSystem: null, + var defaulColor = globalColors[seriesModel.seriesIndex % globalColors.length]; + var data = seriesModel.getData(); - /** - * @param {string} axisType - * @return {module:echarts/coord/polar/AxisModel} - */ - findAxisModel: function (axisType) { - var angleAxisModel; - var ecModel = this.ecModel; - ecModel.eachComponent(axisType, function (axisModel) { - if (ecModel.getComponent( - 'polar', axisModel.getShallow('polarIndex') - ) === this) { - angleAxisModel = axisModel; - } - }, this); - return angleAxisModel; - }, + data.setVisual({ + legendSymbol: 'roundRect', + // Use name 'color' but not 'borderColor' for legend usage and + // visual coding from other component like dataRange. + color: seriesModel.get(borderColorQuery) || defaulColor + }); - defaultOption: { + // Only visible series has each data be visual encoded + if (!ecModel.isSeriesFiltered(seriesModel)) { + data.each(function (idx) { + var itemModel = data.getItemModel(idx); + data.setItemVisual( + idx, + {color: itemModel.get(borderColorQuery, true)} + ); + }); + } + }); + + }; - zlevel: 0, - z: 0, +/***/ }, +/* 242 */ +/***/ function(module, exports, __webpack_require__) { - center: ['50%', '50%'], + - radius: '80%' - } - }); -}); -// TODO Axis scale -define('echarts/coord/polar/polarCreator',['require','./Polar','../../util/number','../../coord/axisHelper','./PolarModel','../../CoordinateSystem'],function (require) { - - var Polar = require('./Polar'); - var numberUtil = require('../../util/number'); - - var axisHelper = require('../../coord/axisHelper'); - var niceScaleExtent = axisHelper.niceScaleExtent; - - // 依赖 PolarModel 做预处理 - require('./PolarModel'); - - /** - * Resize method bound to the polar - * @param {module:echarts/coord/polar/PolarModel} polarModel - * @param {module:echarts/ExtensionAPI} api - */ - function resizePolar(polarModel, api) { - var center = polarModel.get('center'); - var radius = polarModel.get('radius'); - var width = api.getWidth(); - var height = api.getHeight(); - var parsePercent = numberUtil.parsePercent; - - this.cx = parsePercent(center[0], width); - this.cy = parsePercent(center[1], height); - - var radiusAxis = this.getRadiusAxis(); - var size = Math.min(width, height) / 2; - // var idx = radiusAxis.inverse ? 1 : 0; - radiusAxis.setExtent(0, parsePercent(radius, size)); - } - - /** - * Update polar - */ - function updatePolarScale(ecModel, api) { - var polar = this; - var angleAxis = polar.getAngleAxis(); - var radiusAxis = polar.getRadiusAxis(); - // Reset scale - angleAxis.scale.setExtent(Infinity, -Infinity); - radiusAxis.scale.setExtent(Infinity, -Infinity); - - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.coordinateSystem === polar) { - var data = seriesModel.getData(); - radiusAxis.scale.unionExtent( - data.getDataExtent('radius', radiusAxis.type !== 'category') - ); - angleAxis.scale.unionExtent( - data.getDataExtent('angle', angleAxis.type !== 'category') - ); - } - }); - - niceScaleExtent(angleAxis, angleAxis.model); - niceScaleExtent(radiusAxis, radiusAxis.model); - - // Fix extent of category angle axis - if (angleAxis.type === 'category' && !angleAxis.onBand) { - var extent = angleAxis.getExtent(); - var diff = 360 / angleAxis.scale.count(); - angleAxis.inverse ? (extent[1] += diff) : (extent[1] -= diff); - angleAxis.setExtent(extent[0], extent[1]); - } - } - - /** - * Set common axis properties - * @param {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis} - * @param {module:echarts/coord/polar/AxisModel} - * @inner - */ - function setAxis(axis, axisModel) { - axis.type = axisModel.get('type'); - axis.scale = axisHelper.createScaleByModel(axisModel); - axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category'; - - // FIXME Radius axis not support inverse axis - if (axisModel.mainType === 'angleAxis') { - var startAngle = axisModel.get('startAngle'); - axis.inverse = axisModel.get('inverse') ^ axisModel.get('clockwise'); - axis.setExtent(startAngle, startAngle + (axis.inverse ? -360 : 360)); - } - - // Inject axis instance - axisModel.axis = axis; - axis.model = axisModel; - } - - - var polarCreator = { - - dimensions: Polar.prototype.dimensions, - - create: function (ecModel, api) { - var polarList = []; - ecModel.eachComponent('polar', function (polarModel, idx) { - var polar = new Polar(idx); - // Inject resize and update method - polar.resize = resizePolar; - polar.update = updatePolarScale; - - var radiusAxis = polar.getRadiusAxis(); - var angleAxis = polar.getAngleAxis(); - - var radiusAxisModel = polarModel.findAxisModel('radiusAxis'); - var angleAxisModel = polarModel.findAxisModel('angleAxis'); - - setAxis(radiusAxis, radiusAxisModel); - setAxis(angleAxis, angleAxisModel); - - polar.resize(polarModel, api); - polarList.push(polar); - - polarModel.coordinateSystem = polar; - }); - // Inject coordinateSystem to series - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.get('coordinateSystem') === 'polar') { - seriesModel.coordinateSystem = polarList[seriesModel.get('polarIndex')]; - } - }); - - return polarList; - } - }; - - require('../../CoordinateSystem').register('polar', polarCreator); -}); -define('echarts/component/axis/AngleAxisView',['require','zrender/core/util','../../util/graphic','../../model/Model','../../echarts'],function (require) { - - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var Model = require('../../model/Model'); - - var elementList = ['axisLine', 'axisLabel', 'axisTick', 'splitLine', 'splitArea']; - - function getAxisLineShape(polar, r0, r, angle) { - var start = polar.coordToPoint([r0, angle]); - var end = polar.coordToPoint([r, angle]); - - return { - x1: start[0], - y1: start[1], - x2: end[0], - y2: end[1] - }; - } - require('../../echarts').extendComponentView({ - - type: 'angleAxis', - - render: function (angleAxisModel, ecModel) { - this.group.removeAll(); - if (!angleAxisModel.get('show')) { - return; - } - - var polarModel = ecModel.getComponent('polar', angleAxisModel.get('polarIndex')); - var angleAxis = angleAxisModel.axis; - var polar = polarModel.coordinateSystem; - var radiusExtent = polar.getRadiusAxis().getExtent(); - var ticksAngles = angleAxis.getTicksCoords(); - - if (angleAxis.type !== 'category') { - // Remove the last tick which will overlap the first tick - ticksAngles.pop(); - } - - zrUtil.each(elementList, function (name) { - if (angleAxisModel.get(name +'.show')) { - this['_' + name](angleAxisModel, polar, ticksAngles, radiusExtent); - } - }, this); - }, - - /** - * @private - */ - _axisLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) { - var lineStyleModel = angleAxisModel.getModel('axisLine.lineStyle'); - - var circle = new graphic.Circle({ - shape: { - cx: polar.cx, - cy: polar.cy, - r: radiusExtent[1] - }, - style: lineStyleModel.getLineStyle(), - z2: 1, - silent: true - }); - circle.style.fill = null; - - this.group.add(circle); - }, - - /** - * @private - */ - _axisTick: function (angleAxisModel, polar, ticksAngles, radiusExtent) { - var tickModel = angleAxisModel.getModel('axisTick'); - - var tickLen = (tickModel.get('inside') ? -1 : 1) * tickModel.get('length'); - - var lines = zrUtil.map(ticksAngles, function (tickAngle) { - return new graphic.Line({ - shape: getAxisLineShape(polar, radiusExtent[1], radiusExtent[1] + tickLen, tickAngle) - }); - }); - this.group.add(graphic.mergePath( - lines, { - style: tickModel.getModel('lineStyle').getLineStyle() - } - )); - }, - - /** - * @private - */ - _axisLabel: function (angleAxisModel, polar, ticksAngles, radiusExtent) { - var axis = angleAxisModel.axis; - - var categoryData = angleAxisModel.get('data'); - - var labelModel = angleAxisModel.getModel('axisLabel'); - var axisTextStyleModel = labelModel.getModel('textStyle'); - - var labels = angleAxisModel.getFormattedLabels(); - - var labelMargin = labelModel.get('margin'); - var labelsAngles = axis.getLabelsCoords(); - - // Use length of ticksAngles because it may remove the last tick to avoid overlapping - for (var i = 0; i < ticksAngles.length; i++) { - var r = radiusExtent[1]; - var p = polar.coordToPoint([r + labelMargin, labelsAngles[i]]); - var cx = polar.cx; - var cy = polar.cy; - - var labelTextAlign = Math.abs(p[0] - cx) / r < 0.3 - ? 'center' : (p[0] > cx ? 'left' : 'right'); - var labelTextBaseline = Math.abs(p[1] - cy) / r < 0.3 - ? 'middle' : (p[1] > cy ? 'top' : 'bottom'); - - var textStyleModel = axisTextStyleModel; - if (categoryData && categoryData[i] && categoryData[i].textStyle) { - textStyleModel = new Model( - categoryData[i].textStyle, axisTextStyleModel - ); - } - this.group.add(new graphic.Text({ - style: { - x: p[0], - y: p[1], - fill: textStyleModel.getTextColor(), - text: labels[i], - textAlign: labelTextAlign, - textBaseline: labelTextBaseline, - textFont: textStyleModel.getFont() - }, - silent: true - })); - } - }, - - /** - * @private - */ - _splitLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) { - var splitLineModel = angleAxisModel.getModel('splitLine'); - var lineStyleModel = splitLineModel.getModel('lineStyle'); - var lineColors = lineStyleModel.get('color'); - var lineCount = 0; - - lineColors = lineColors instanceof Array ? lineColors : [lineColors]; - - var splitLines = []; - - for (var i = 0; i < ticksAngles.length; i++) { - var colorIndex = (lineCount++) % lineColors.length; - splitLines[colorIndex] = splitLines[colorIndex] || []; - splitLines[colorIndex].push(new graphic.Line({ - shape: getAxisLineShape(polar, radiusExtent[0], radiusExtent[1], ticksAngles[i]) - })); - } - - // Simple optimization - // Batching the lines if color are the same - for (var i = 0; i < splitLines.length; i++) { - this.group.add(graphic.mergePath(splitLines[i], { - style: zrUtil.defaults({ - stroke: lineColors[i % lineColors.length] - }, lineStyleModel.getLineStyle()), - silent: true, - z: angleAxisModel.get('z') - })); - } - }, - - /** - * @private - */ - _splitArea: function (angleAxisModel, polar, ticksAngles, radiusExtent) { - - var splitAreaModel = angleAxisModel.getModel('splitArea'); - var areaStyleModel = splitAreaModel.getModel('areaStyle'); - var areaColors = areaStyleModel.get('color'); - var lineCount = 0; - - areaColors = areaColors instanceof Array ? areaColors : [areaColors]; - - var splitAreas = []; - - var RADIAN = Math.PI / 180; - var prevAngle = -ticksAngles[0] * RADIAN; - var r0 = Math.min(radiusExtent[0], radiusExtent[1]); - var r1 = Math.max(radiusExtent[0], radiusExtent[1]); - - var clockwise = angleAxisModel.get('clockwise'); - - for (var i = 1; i < ticksAngles.length; i++) { - var colorIndex = (lineCount++) % areaColors.length; - splitAreas[colorIndex] = splitAreas[colorIndex] || []; - splitAreas[colorIndex].push(new graphic.Sector({ - shape: { - cx: polar.cx, - cy: polar.cy, - r0: r0, - r: r1, - startAngle: prevAngle, - endAngle: -ticksAngles[i] * RADIAN, - clockwise: clockwise - }, - silent: true - })); - prevAngle = -ticksAngles[i] * RADIAN; - } - - // Simple optimization - // Batching the lines if color are the same - for (var i = 0; i < splitAreas.length; i++) { - this.group.add(graphic.mergePath(splitAreas[i], { - style: zrUtil.defaults({ - fill: areaColors[i % areaColors.length] - }, areaStyleModel.getAreaStyle()), - silent: true - })); - } - } - }); -}); -define('echarts/component/angleAxis',['require','../coord/polar/polarCreator','./axis/AngleAxisView'],function(require) { - + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var parsePercent = numberUtil.parsePercent; + var each = zrUtil.each; + + module.exports = function (ecModel, api) { + + var groupResult = groupSeriesByAxis(ecModel); + + each(groupResult, function (groupItem) { + var seriesModels = groupItem.seriesModels; + + if (!seriesModels.length) { + return; + } + + calculateBase(groupItem); + + each(seriesModels, function (seriesModel, idx) { + layoutSingleSeries( + seriesModel, + groupItem.boxOffsetList[idx], + groupItem.boxWidthList[idx] + ); + }); + }); + }; + + /** + * Group series by axis. + */ + function groupSeriesByAxis(ecModel) { + var result = []; + var axisList = []; + + ecModel.eachSeriesByType('boxplot', function (seriesModel) { + var baseAxis = seriesModel.getBaseAxis(); + var idx = zrUtil.indexOf(axisList, baseAxis); + + if (idx < 0) { + idx = axisList.length; + axisList[idx] = baseAxis; + result[idx] = {axis: baseAxis, seriesModels: []}; + } + + result[idx].seriesModels.push(seriesModel); + }); + + return result; + } + + /** + * Calculate offset and box width for each series. + */ + function calculateBase(groupItem) { + var extent; + var baseAxis = groupItem.axis; + var seriesModels = groupItem.seriesModels; + var seriesCount = seriesModels.length; + + var boxWidthList = groupItem.boxWidthList = []; + var boxOffsetList = groupItem.boxOffsetList = []; + var boundList = []; + + var bandWidth; + if (baseAxis.type === 'category') { + bandWidth = baseAxis.getBandWidth(); + } + else { + var maxDataCount = 0; + each(seriesModels, function (seriesModel) { + maxDataCount = Math.max(maxDataCount, seriesModel.getData().count()); + }); + extent = baseAxis.getExtent(), + Math.abs(extent[1] - extent[0]) / maxDataCount; + } + + each(seriesModels, function (seriesModel) { + var boxWidthBound = seriesModel.get('boxWidth'); + if (!zrUtil.isArray(boxWidthBound)) { + boxWidthBound = [boxWidthBound, boxWidthBound]; + } + boundList.push([ + parsePercent(boxWidthBound[0], bandWidth) || 0, + parsePercent(boxWidthBound[1], bandWidth) || 0 + ]); + }); + + var availableWidth = bandWidth * 0.8 - 2; + var boxGap = availableWidth / seriesCount * 0.3; + var boxWidth = (availableWidth - boxGap * (seriesCount - 1)) / seriesCount; + var base = boxWidth / 2 - availableWidth / 2; + + each(seriesModels, function (seriesModel, idx) { + boxOffsetList.push(base); + base += boxGap + boxWidth; + + boxWidthList.push( + Math.min(Math.max(boxWidth, boundList[idx][0]), boundList[idx][1]) + ); + }); + } + + /** + * Calculate points location for each series. + */ + function layoutSingleSeries(seriesModel, offset, boxWidth) { + var coordSys = seriesModel.coordinateSystem; + var data = seriesModel.getData(); + var dimensions = seriesModel.dimensions; + var chartLayout = seriesModel.get('layout'); + var halfWidth = boxWidth / 2; + + data.each(dimensions, function () { + var args = arguments; + var dimLen = dimensions.length; + var axisDimVal = args[0]; + var idx = args[dimLen]; + var variableDim = chartLayout === 'horizontal' ? 0 : 1; + var constDim = 1 - variableDim; + + var median = getPoint(args[3]); + var end1 = getPoint(args[1]); + var end5 = getPoint(args[5]); + var whiskerEnds = [ + [end1, getPoint(args[2])], + [end5, getPoint(args[4])] + ]; + layEndLine(end1); + layEndLine(end5); + layEndLine(median); + + var bodyEnds = []; + addBodyEnd(whiskerEnds[0][1], 0); + addBodyEnd(whiskerEnds[1][1], 1); + + data.setItemLayout(idx, { + chartLayout: chartLayout, + initBaseline: median[constDim], + median: median, + bodyEnds: bodyEnds, + whiskerEnds: whiskerEnds + }); + + function getPoint(val) { + var p = []; + p[variableDim] = axisDimVal; + p[constDim] = val; + var point; + if (isNaN(axisDimVal) || isNaN(val)) { + point = [NaN, NaN]; + } + else { + point = coordSys.dataToPoint(p); + point[variableDim] += offset; + } + return point; + } + + function addBodyEnd(point, start) { + var point1 = point.slice(); + var point2 = point.slice(); + point1[variableDim] += halfWidth; + point2[variableDim] -= halfWidth; + start + ? bodyEnds.push(point1, point2) + : bodyEnds.push(point2, point1); + } + + function layEndLine(endCenter) { + var line = [endCenter.slice(), endCenter.slice()]; + line[0][variableDim] -= halfWidth; + line[1][variableDim] += halfWidth; + whiskerEnds.push(line); + } + }); + } + + + +/***/ }, +/* 243 */ +/***/ function(module, exports, __webpack_require__) { + + + + var echarts = __webpack_require__(1); + + __webpack_require__(244); + __webpack_require__(245); + + echarts.registerPreprocessor( + __webpack_require__(246) + ); + + echarts.registerVisualCoding('chart', __webpack_require__(247)); + echarts.registerLayout(__webpack_require__(248)); + + + +/***/ }, +/* 244 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var SeriesModel = __webpack_require__(27); + var whiskerBoxCommon = __webpack_require__(238); + var formatUtil = __webpack_require__(6); + var encodeHTML = formatUtil.encodeHTML; + var addCommas = formatUtil.addCommas; + + var CandlestickSeries = SeriesModel.extend({ + + type: 'series.candlestick', + + dependencies: ['xAxis', 'yAxis', 'grid'], + + /** + * @readOnly + */ + valueDimensions: ['open', 'close', 'lowest', 'highest'], + + /** + * @type {Array.} + * @readOnly + */ + dimensions: null, - require('../coord/polar/polarCreator'); + /** + * @override + */ + defaultOption: { + zlevel: 0, // 一级层叠 + z: 2, // 二级层叠 + coordinateSystem: 'cartesian2d', + legendHoverLink: true, + + hoverAnimation: true, - require('./axis/AngleAxisView'); -}); -define('echarts/component/axis/RadiusAxisView',['require','zrender/core/util','../../util/graphic','./AxisBuilder','../../echarts'],function (require) { - - - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var AxisBuilder = require('./AxisBuilder'); - - var axisBuilderAttrs = [ - 'axisLine', 'axisLabel', 'axisTick', 'axisName' - ]; - var selfBuilderAttrs = [ - 'splitLine', 'splitArea' - ]; - - require('../../echarts').extendComponentView({ - - type: 'radiusAxis', - - render: function (radiusAxisModel, ecModel) { - this.group.removeAll(); - if (!radiusAxisModel.get('show')) { - return; - } - var polarModel = ecModel.getComponent('polar', radiusAxisModel.get('polarIndex')); - var angleAxis = polarModel.coordinateSystem.getAngleAxis(); - var radiusAxis = radiusAxisModel.axis; - var polar = polarModel.coordinateSystem; - var ticksCoords = radiusAxis.getTicksCoords(); - var axisAngle = angleAxis.getExtent()[0]; - var radiusExtent = radiusAxis.getExtent(); - - var layout = layoutAxis(polar, radiusAxisModel, axisAngle); - var axisBuilder = new AxisBuilder(radiusAxisModel, layout); - zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder); - this.group.add(axisBuilder.getGroup()); - - zrUtil.each(selfBuilderAttrs, function (name) { - if (radiusAxisModel.get(name +'.show')) { - this['_' + name](radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords); - } - }, this); - }, - - /** - * @private - */ - _splitLine: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) { - var splitLineModel = radiusAxisModel.getModel('splitLine'); - var lineStyleModel = splitLineModel.getModel('lineStyle'); - var lineColors = lineStyleModel.get('color'); - var lineCount = 0; - - lineColors = lineColors instanceof Array ? lineColors : [lineColors]; - - var splitLines = []; - - for (var i = 0; i < ticksCoords.length; i++) { - var colorIndex = (lineCount++) % lineColors.length; - splitLines[colorIndex] = splitLines[colorIndex] || []; - splitLines[colorIndex].push(new graphic.Circle({ - shape: { - cx: polar.cx, - cy: polar.cy, - r: ticksCoords[i] - }, - silent: true - })); - } - - // Simple optimization - // Batching the lines if color are the same - for (var i = 0; i < splitLines.length; i++) { - this.group.add(graphic.mergePath(splitLines[i], { - style: zrUtil.defaults({ - stroke: lineColors[i % lineColors.length], - fill: null - }, lineStyleModel.getLineStyle()), - silent: true - })); - } - }, - - /** - * @private - */ - _splitArea: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) { - - var splitAreaModel = radiusAxisModel.getModel('splitArea'); - var areaStyleModel = splitAreaModel.getModel('areaStyle'); - var areaColors = areaStyleModel.get('color'); - var lineCount = 0; - - areaColors = areaColors instanceof Array ? areaColors : [areaColors]; - - var splitAreas = []; - - var prevRadius = ticksCoords[0]; - for (var i = 1; i < ticksCoords.length; i++) { - var colorIndex = (lineCount++) % areaColors.length; - splitAreas[colorIndex] = splitAreas[colorIndex] || []; - splitAreas[colorIndex].push(new graphic.Sector({ - shape: { - cx: polar.cx, - cy: polar.cy, - r0: prevRadius, - r: ticksCoords[i], - startAngle: 0, - endAngle: Math.PI * 2 - }, - silent: true - })); - prevRadius = ticksCoords[i]; - } - - // Simple optimization - // Batching the lines if color are the same - for (var i = 0; i < splitAreas.length; i++) { - this.group.add(graphic.mergePath(splitAreas[i], { - style: zrUtil.defaults({ - fill: areaColors[i % areaColors.length] - }, areaStyleModel.getAreaStyle()), - silent: true - })); - } - } - }); - - /** - * @inner - */ - function layoutAxis(polar, radiusAxisModel, axisAngle) { - return { - position: [polar.cx, polar.cy], - rotation: axisAngle / 180 * Math.PI, - labelDirection: -1, - tickDirection: -1, - nameDirection: 1, - labelRotation: radiusAxisModel.getModel('axisLabel').get('rotate'), - // Over splitLine and splitArea - z2: 1 - }; - } -}); -define('echarts/component/radiusAxis',['require','../coord/polar/polarCreator','./axis/RadiusAxisView'],function(require) { + xAxisIndex: 0, + yAxisIndex: 0, + + layout: null, // 'horizontal' or 'vertical' - require('../coord/polar/polarCreator'); + itemStyle: { + normal: { + color: '#c23531', // 阳线 positive + color0: '#314656', // 阴线 negative '#c23531', '#314656' + borderWidth: 1, + // FIXME + // ec2中使用的是lineStyle.color 和 lineStyle.color0 + borderColor: '#c23531', + borderColor0: '#314656' + }, + emphasis: { + borderWidth: 2 + } + }, - require('./axis/RadiusAxisView'); -}); -define('echarts/component/polar',['require','../coord/polar/polarCreator','./angleAxis','./radiusAxis','../echarts'],function(require) { - + animationUpdate: false, + animationEasing: 'linear', + animationDuration: 300 + }, - require('../coord/polar/polarCreator'); - require('./angleAxis'); - require('./radiusAxis'); + /** + * Get dimension for shadow in dataZoom + * @return {string} dimension name + */ + getShadowDim: function () { + return 'open'; + }, - // Polar view - require('../echarts').extendComponentView({ - type: 'polar' - }); -}); -define('echarts/chart/radar/RadarSeries',['require','../helper/createListFromArray','../../model/Series','zrender/core/util','../../util/number','../../component/polar'],function(require) { - - - - var createListFromArray = require('../helper/createListFromArray'); - var SeriesModel = require('../../model/Series'); - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../../util/number'); - var linearMap = numberUtil.linearMap; - - // Must have polar coordinate system - require('../../component/polar'); - - return SeriesModel.extend({ - - type: 'series.radar', - - dependencies: ['polar'], - - getInitialData: function (option, ecModel) { - var indicators = option.indicator; - var data = createListFromArray(option.data, this, ecModel); - if (indicators) { - var indicatorMap = zrUtil.reduce(indicators, function (map, value, idx) { - map[value.name] = value; - return map; - }, {}); - // Linear map to indicator min-max - // Only radius axis can be value - data = data.map(['radius'], function (radius, idx) { - var indicator = indicatorMap[data.getName(idx)]; - if (indicator && indicator.max) { - // Map to 0-1 percent value - return linearMap(radius, [indicator.min || 0, indicator.max], [0, 1]); - } - }); - - // FIXME - var oldGetRawValue = this.getRawValue; - this.getRawValue = function (idx) { - var val = oldGetRawValue.call(this, idx); - var indicator = indicatorMap[data.getName(idx)]; - if (indicator && indicator.max != null) { - return linearMap(val, [0, 1], [indicator.min || 0, indicator.max]); - } - }; - } - return data; - }, - - defaultOption: { - zlevel: 0, // 一级层叠 - z: 2, // 二级层叠 - coordinateSystem: 'polar', - legendHoverLink: true, - polarIndex: 0, - lineStyle: { - normal: { - width: 2, - type: 'solid' - } - }, - // areaStyle: { - // }, - // 拐点图形类型 - symbol: 'emptyCircle', - // 拐点图形大小 - symbolSize: 4, - // 拐点图形旋转控制 - // symbolRotate: null, - // 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略) - showAllSymbol: false - - // Indicators for each chart - // indicator: [{ - // name: '', - // min: 0, - // max: 100 - // }] - } - }); -}); -define('echarts/chart/radar/RadarView',['require','../helper/SymbolDraw','../../util/graphic','zrender/core/util','../../echarts'],function (require) { - - var SymbolDraw = require('../helper/SymbolDraw'); - var graphic = require('../../util/graphic'); - var zrUtil = require('zrender/core/util'); - - return require('../../echarts').extendChartView({ - type: 'radar', - - init: function () { - this._symbolDraw = new SymbolDraw(); - }, - - render: function (seriesModel, ecModel, api) { - var polar = seriesModel.coordinateSystem; - var group = this.group; - - var data = seriesModel.getData(); - - var points = data.mapArray(data.getItemLayout, true); - if (points.length < 1) { - return; - } - points.push(points[0].slice()); - - var polygon = this._polygon || (this._polygon = new graphic.Polygon({ - shape: { - points: [] - } - })); - var polyline = this._polyline || (this._polyline = new graphic.Polyline({ - shape: { - points: [] - }, - z2: 10 - })); - - var polylineShape = polyline.shape; - var polygonShape = polygon.shape; - function getInitialPoints() { - return zrUtil.map(points, function (pt) { - return [polar.cx, polar.cy]; - }); - } - var target = { - shape: { - points: points - } - }; - // Initialize or data changed - if (polylineShape.points.length !== points.length) { - polygonShape.points = getInitialPoints(); - polylineShape.points = getInitialPoints(); - graphic.initProps(polyline, target, seriesModel); - graphic.initProps(polygon, target, seriesModel); - } - else { - graphic.updateProps(polyline, target, seriesModel); - graphic.updateProps(polygon, target, seriesModel); - } - - this._symbolDraw.updateData(data); - - polyline.setStyle( - zrUtil.extend( - seriesModel.getModel('lineStyle.normal').getLineStyle(), - { - stroke: data.getVisual('color') - } - ) - ); - - var areaStyleModel = seriesModel.getModel('areaStyle.normal'); - polygon.ignore = areaStyleModel.isEmpty(); - graphic.setHoverStyle( - polyline, - seriesModel.getModel('lineStyle.emphasis').getLineStyle() - ); - - if (!polygon.ignore) { - polygon.setStyle( - zrUtil.defaults( - areaStyleModel.getAreaStyle(), - { - fill: data.getVisual('color'), - opacity: 0.7 - } - ) - ); - graphic.setHoverStyle( - polygon, - seriesModel.getModel('areaStyle.emphasis').getLineStyle() - ); - } - - group.add(polyline); - group.add(polygon); - group.add(this._symbolDraw.group); - - this._data = data; - } - }); -}); -// Backward compat for radar chart in 2 -define('echarts/chart/radar/backwardCompat',['require','zrender/core/util','../../scale/Interval'],function (require) { - - var zrUtil = require('zrender/core/util'); - var IntervalScale = require('../../scale/Interval'); - var isArray = zrUtil.isArray; - var each = zrUtil.each; - var filter = zrUtil.filter; - - return function (option) { - var polarOptList = option.polar; - var radiusAxisOptList = option.radiusAxis; - var angleAxisOptList = option.angleAxis; - var radarSeries = filter(option.series, function (seriesOpt) { - return seriesOpt.type === 'radar'; - }) || []; - if (polarOptList && radarSeries.length) { - if (!isArray(polarOptList)) { - polarOptList = [polarOptList]; - } - // In 2.0 there is no radiusAxis and angleAxis - if (!radiusAxisOptList) { - radiusAxisOptList = option.radiusAxis = []; - } - else if (!isArray(radiusAxisOptList)) { - radiusAxisOptList = [radiusAxisOptList]; - } - if (!angleAxisOptList) { - angleAxisOptList = option.angleAxis = []; - } - else if (!isArray(angleAxisOptList)) { - angleAxisOptList = [angleAxisOptList]; - } - each(polarOptList, function (polarOpt, idx) { - // Is 2.0 version - if (polarOpt.indicator) { - var indicators = zrUtil.map(polarOpt.indicator, function (indicator) { - var min = indicator.min; - var max = indicator.max; - if (max != null && max >= 0) { - min = 0; - } - return { - name: indicator.text, - min: min, - max: max - }; - }); - var radiusAxisOpt = zrUtil.find(radiusAxisOptList, function (radiusAxisOpt) { - return (radiusAxisOpt.polarIndex || 0) === idx; - }); - var angleAxisOpt = zrUtil.find(angleAxisOptList, function (angleAxisOpt) { - return (angleAxisOpt.polarIndex || 0) === idx; - }); - if (!radiusAxisOpt) { - radiusAxisOpt = { - type: 'value', - polarIndex: idx - }; - radiusAxisOptList.push(radiusAxisOpt); - } - if (!angleAxisOpt) { - angleAxisOpt = { - type: 'category', - polarIndex: idx - }; - angleAxisOptList.push(angleAxisOpt); - } - angleAxisOpt.data = zrUtil.map(polarOpt.indicator, function (indicator) { - var obj = { - value: indicator.text - }; - var axisLabel = indicator.axisLabel; - if (axisLabel && axisLabel.textStyle) { - obj.textStyle = axisLabel.textStyle; - } - return obj; - }); - angleAxisOpt.startAngle = polarOpt.startAngle || 90; - // axisLine in 2.0 is same like splitLine of angleAxis - if (polarOpt.axisLine) { - angleAxisOpt.splitLine = polarOpt.axisLine; - } - if (polarOpt.axisLabel) { - angleAxisOpt.axisLabel = polarOpt.axisLabel; - } - // splitLine in 2.0 is same with splitLine of radiusAxis - if (polarOpt.splitLine) { - radiusAxisOpt.splitLine = polarOpt.splitLine; - } - if (polarOpt.splitArea) { - radiusAxisOpt.splitArea = polarOpt.splitArea; - } - // Default show splitLine and splitArea - radiusAxisOpt.splitLine = radiusAxisOpt.splitLine || {}; - radiusAxisOpt.splitArea = radiusAxisOpt.splitArea || {}; - - if (radiusAxisOpt.splitLine.show == null) { - radiusAxisOpt.splitLine.show = true; - } - if (radiusAxisOpt.splitArea.show == null) { - radiusAxisOpt.splitArea.show = true; - } - - angleAxisOpt.boundaryGap = false; - // indicators will be normalized to 0 - 1 - radiusAxisOpt.min = 0; - radiusAxisOpt.max = 1; - radiusAxisOpt.interval = 1 / (polarOpt.splitNumber || 5); - radiusAxisOpt.axisLine = { - show: false - }; - radiusAxisOpt.axisLabel = { - show: false - }; - radiusAxisOpt.axisTick = { - show: false - }; - - var radarSeriesOfSamePolar = filter(radarSeries, function (seriesOpt) { - return (seriesOpt.polarIndex || 0) === idx; - }); - - var dataGroupPyIndicator = zrUtil.map(indicators, function () { - return []; - }); - - // Find polar use current polarOpt - each(radarSeriesOfSamePolar, function (seriesOpt) { - seriesOpt.indicator = indicators; - // Data format in 2.0 radar is strange, like following - // data : [ - // { - // value : [4300, 10000, 28000, 35000, 50000, 19000], - // name : '预算分配(Allocated Budget)' - // }, - // { - // value : [5000, 14000, 28000, 31000, 42000, 21000], - // name : '实际开销(Actual Spending)' - // } - // ] - // Convert them to series - if ( - seriesOpt.data[0] && zrUtil.isArray(seriesOpt.data[0].value) - ) { - var dataList = seriesOpt.data; - var dataOpt = dataList[0]; - seriesOpt.data = dataOpt.value; - seriesOpt.name = dataOpt.name; - for (var i = 1; i < dataList.length; i++) { - var dataOpt = dataList[i]; - var newSeriesOpt = zrUtil.clone(seriesOpt); - option.series.push(zrUtil.extend(newSeriesOpt, { - name: dataOpt.name, - data: dataOpt.value, - indicator: indicators - })); - } - - for (var i = 0; i < dataOpt.value.length; i++) { - for (var j = 0; j < dataList.length; j++) { - dataGroupPyIndicator[i].push(dataList[j].value[i]); - } - } - } - }); - - // Calculate min, max of each indicator from data - each(dataGroupPyIndicator, function (valuePerIndicator, idx) { - var intervalScale = new IntervalScale(); - var min = Infinity; - var max = -Infinity; - var len = valuePerIndicator.length; - if (!len) { - return; - } - for (var i = 0; i < len; i++) { - min = Math.min(min, valuePerIndicator[i]); - max = Math.max(max, valuePerIndicator[i]); - } - intervalScale.setExtent(min, max); - intervalScale.niceExtent(polarOpt.splitNumber || 5); - var intervalExtent = intervalScale.getExtent(); - if (indicators[idx].min == null) { - indicators[idx].min = intervalExtent[0]; - } - if (indicators[idx].max == null) { - indicators[idx].max = intervalExtent[1]; - } - }); - } - }); - } - }; -}); -define('echarts/chart/radar',['require','zrender/core/util','../echarts','./radar/RadarSeries','./radar/RadarView','../visual/symbol','../layout/points','./radar/backwardCompat'],function (require) { + /** + * @override + */ + formatTooltip: function (dataIndex, mutipleSeries) { + // It rearly use mutiple candlestick series in one cartesian, + // so only consider one series in this default tooltip. + var valueHTMLArr = zrUtil.map(this.valueDimensions, function (dim) { + return dim + ': ' + addCommas(this._data.get(dim, dataIndex)); + }, this); - var zrUtil = require('zrender/core/util'); - var echarts = require('../echarts'); + return encodeHTML(this.name) + '
' + valueHTMLArr.join('
'); + } - require('./radar/RadarSeries'); - require('./radar/RadarView'); + }); - echarts.registerVisualCoding('chart', zrUtil.curry( - require('../visual/symbol'), 'radar', 'circle', null - )); - echarts.registerLayout(zrUtil.curry( - require('../layout/points'), 'radar' - )); + zrUtil.mixin(CandlestickSeries, whiskerBoxCommon.seriesModelMixin, true); - echarts.registerPreprocessor(require('./radar/backwardCompat')); -}); -define('echarts/component/legend/LegendModel',['require','zrender/core/util','../../model/Model','../../echarts'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var Model = require('../../model/Model'); - - var LegendModel = require('../../echarts').extendComponentModel({ - - type: 'legend', - - dependencies: ['series'], - - layoutMode: { - type: 'box', - ignoreSize: true - }, - - init: function (option, parentModel, ecModel) { - this.mergeDefaultAndTheme(option, ecModel); - - option.selected = option.selected || {}; - - this._updateData(ecModel); - - var legendData = this._data; - // If has any selected in option.selected - var selectedMap = this.option.selected; - // If selectedMode is single, try to select one - if (legendData[0] && this.get('selectedMode') === 'single') { - var hasSelected = false; - for (var name in selectedMap) { - if (selectedMap[name]) { - this.select(name); - hasSelected = true; - } - } - // Try select the first if selectedMode is single - !hasSelected && this.select(legendData[0].get('name')); - } - }, - - mergeOption: function (option) { - LegendModel.superCall(this, 'mergeOption', option); - - this._updateData(this.ecModel); - }, - - _updateData: function (ecModel) { - var legendData = zrUtil.map(this.get('data') || [], function (dataItem) { - if (typeof dataItem === 'string') { - dataItem = { - name: dataItem - }; - } - return new Model(dataItem, this, this.ecModel); - }, this); - this._data = legendData; - - var availableNames = zrUtil.map(ecModel.getSeries(), function (series) { - return series.name; - }); - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.legendDataProvider) { - var data = seriesModel.legendDataProvider(); - availableNames = availableNames.concat(data.mapArray(data.getName)); - } - }); - /** - * @type {Array.} - * @private - */ - this._availableNames = availableNames; - }, - - /** - * @return {Array.} - */ - getData: function () { - return this._data; - }, - - /** - * @param {string} name - */ - select: function (name) { - var selected = this.option.selected; - var selectedMode = this.get('selectedMode'); - if (selectedMode === 'single') { - var data = this._data; - zrUtil.each(data, function (dataItem) { - selected[dataItem.get('name')] = false; - }); - } - selected[name] = true; - }, - - /** - * @param {string} name - */ - unSelect: function (name) { - if (this.get('selectedMode') !== 'single') { - this.option.selected[name] = false; - } - }, - - /** - * @param {string} name - */ - toggleSelected: function (name) { - var selected = this.option.selected; - // Default is true - if (!(name in selected)) { - selected[name] = true; - } - this[selected[name] ? 'unSelect' : 'select'](name); - }, - - /** - * @param {string} name - */ - isSelected: function (name) { - var selected = this.option.selected; - return !((name in selected) && !selected[name]) - && zrUtil.indexOf(this._availableNames, name) >= 0; - }, - - defaultOption: { - // 一级层叠 - zlevel: 0, - // 二级层叠 - z: 4, - show: true, - - // 布局方式,默认为水平布局,可选为: - // 'horizontal' | 'vertical' - orient: 'horizontal', - - left: 'center', - // right: 'center', - - top: 'top', - // bottom: 'top', - - // 水平对齐 - // 'auto' | 'left' | 'right' - // 默认为 'auto', 根据 x 的位置判断是左对齐还是右对齐 - align: 'auto', - - backgroundColor: 'rgba(0,0,0,0)', - // 图例边框颜色 - borderColor: '#ccc', - // 图例边框线宽,单位px,默认为0(无边框) - borderWidth: 0, - // 图例内边距,单位px,默认各方向内边距为5, - // 接受数组分别设定上右下左边距,同css - padding: 5, - // 各个item之间的间隔,单位px,默认为10, - // 横向布局时为水平间隔,纵向布局时为纵向间隔 - itemGap: 10, - // 图例图形宽度 - itemWidth: 25, - // 图例图形高度 - itemHeight: 14, - textStyle: { - // 图例文字颜色 - color: '#333' - }, - // formatter: '', - // 选择模式,默认开启图例开关 - selectedMode: true - // 配置默认选中状态,可配合LEGEND.SELECTED事件做动态数据载入 - // selected: null, - // 图例内容(详见legend.data,数组中每一项代表一个item - // data: [], - } - }); - - return LegendModel; -}); -/** - * @file Legend action - */ -define('echarts/component/legend/legendAction',['require','../../echarts','zrender/core/util'],function(require) { - - var echarts = require('../../echarts'); - var zrUtil = require('zrender/core/util'); - - function legendSelectActionHandler(methodName, payload, ecModel) { - var selectedMap = {}; - var isToggleSelect = methodName === 'toggleSelected'; - var isSelected; - // Update all legend components - ecModel.eachComponent('legend', function (legendModel) { - if (isToggleSelect && isSelected != null) { - // Force other legend has same selected status - // Or the first is toggled to true and other are toggled to false - // In the case one legend has some item unSelected in option. And if other legend - // doesn't has the item, they will assume it is selected. - legendModel[isSelected ? 'select' : 'unSelect'](payload.name); - } - else { - legendModel[methodName](payload.name); - isSelected = legendModel.isSelected(payload.name); - } - var legendData = legendModel.getData(); - zrUtil.each(legendData, function (model) { - var name = model.get('name'); - // Wrap element - if (name === '\n' || name === '') { - return; - } - var isItemSelected = legendModel.isSelected(name); - if (name in selectedMap) { - // Unselected if any legend is unselected - selectedMap[name] = selectedMap[name] && isItemSelected; - } - else { - selectedMap[name] = isItemSelected; - } - }); - }); - // Return the event explicitly - return { - name: payload.name, - selected: selectedMap - }; - } - /** - * @event legendToggleSelect - * @type {Object} - * @property {string} type 'legendToggleSelect' - * @property {string} [from] - * @property {string} name Series name or data item name - */ - echarts.registerAction( - 'legendToggleSelect', 'legendselectchanged', - zrUtil.curry(legendSelectActionHandler, 'toggleSelected') - ); - - /** - * @event legendSelect - * @type {Object} - * @property {string} type 'legendSelect' - * @property {string} name Series name or data item name - */ - echarts.registerAction( - 'legendSelect', 'legendselected', - zrUtil.curry(legendSelectActionHandler, 'select') - ); - - /** - * @event legendUnSelect - * @type {Object} - * @property {string} type 'legendUnSelect' - * @property {string} name Series name or data item name - */ - echarts.registerAction( - 'legendUnSelect', 'legendunselected', - zrUtil.curry(legendSelectActionHandler, 'unSelect') - ); -}); -define('echarts/component/helper/listComponent',['require','../../util/layout','../../util/format','../../util/graphic'],function (require) { - // List layout - var layout = require('../../util/layout'); - var formatUtil = require('../../util/format'); - var graphic = require('../../util/graphic'); - - function positionGroup(group, model, api) { - layout.positionGroup( - group, model.getBoxLayoutParams(), - { - width: api.getWidth(), - height: api.getHeight() - }, - model.get('padding') - ); - } - - return { - /** - * Layout list like component. - * It will box layout each items in group of component and then position the whole group in the viewport - * @param {module:zrender/group/Group} group - * @param {module:echarts/model/Component} componentModel - * @param {module:echarts/ExtensionAPI} - */ - layout: function (group, componentModel, api) { - var rect = layout.getLayoutRect(componentModel.getBoxLayoutParams(), { - width: api.getWidth(), - height: api.getHeight() - }, componentModel.get('padding')); - layout.box( - componentModel.get('orient'), - group, - componentModel.get('itemGap'), - rect.width, - rect.height - ); - - positionGroup(group, componentModel, api); - }, - - addBackground: function (group, componentModel) { - var padding = formatUtil.normalizeCssArray( - componentModel.get('padding') - ); - var boundingRect = group.getBoundingRect(); - var style = componentModel.getItemStyle(['color', 'opacity']); - style.fill = componentModel.get('backgroundColor'); - var rect = new graphic.Rect({ - shape: { - x: boundingRect.x - padding[3], - y: boundingRect.y - padding[0], - width: boundingRect.width + padding[1] + padding[3], - height: boundingRect.height + padding[0] + padding[2] - }, - style: style, - silent: true, - z2: -1 - }); - graphic.subPixelOptimizeRect(rect); - - group.add(rect); - } - }; -}); -define('echarts/component/legend/LegendView',['require','zrender/core/util','../../util/symbol','../../util/graphic','../helper/listComponent','../../echarts'],function (require) { - - var zrUtil = require('zrender/core/util'); - var symbolCreator = require('../../util/symbol'); - var graphic = require('../../util/graphic'); - var listComponentHelper = require('../helper/listComponent'); - - var curry = zrUtil.curry; - - var LEGEND_DISABLE_COLOR = '#ccc'; - - function dispatchSelectAction(name, api) { - api.dispatchAction({ - type: 'legendToggleSelect', - name: name - }); - } - - function dispatchHighlightAction(seriesModel, dataName, api) { - seriesModel.get('legendHoverLink') && api.dispatchAction({ - type: 'highlight', - seriesName: seriesModel.name, - name: dataName - }); - } - - function dispatchDownplayAction(seriesModel, dataName, api) { - seriesModel.get('legendHoverLink') &&api.dispatchAction({ - type: 'downplay', - seriesName: seriesModel.name, - name: dataName - }); - } - - return require('../../echarts').extendComponentView({ - - type: 'legend', - - init: function () { - this._symbolTypeStore = {}; - }, - - render: function (legendModel, ecModel, api) { - var group = this.group; - group.removeAll(); - - if (!legendModel.get('show')) { - return; - } - - var selectMode = legendModel.get('selectedMode'); - var itemWidth = legendModel.get('itemWidth'); - var itemHeight = legendModel.get('itemHeight'); - var itemAlign = legendModel.get('align'); - - if (itemAlign === 'auto') { - itemAlign = (legendModel.get('left') === 'right' - && legendModel.get('orient') === 'vertical') - ? 'right' : 'left'; - } - - var legendItemMap = {}; - var legendDrawedMap = {}; - zrUtil.each(legendModel.getData(), function (itemModel) { - var seriesName = itemModel.get('name'); - // Use empty string or \n as a newline string - if (seriesName === '' || seriesName === '\n') { - group.add(new graphic.Group({ - newline: true - })); - } - - var seriesModel = ecModel.getSeriesByName(seriesName)[0]; - - legendItemMap[seriesName] = itemModel; - - if (!seriesModel || legendDrawedMap[seriesName]) { - // Series not exists - return; - } - - var data = seriesModel.getData(); - var color = data.getVisual('color'); - - if (!legendModel.isSelected(seriesName)) { - color = LEGEND_DISABLE_COLOR; - } - - // If color is a callback function - if (typeof color === 'function') { - // Use the first data - color = color(seriesModel.getDataParams(0)); - } - - // Using rect symbol defaultly - var legendSymbolType = data.getVisual('legendSymbol') || 'roundRect'; - var symbolType = data.getVisual('symbol'); - - var itemGroup = this._createItem( - seriesName, itemModel, legendModel, - legendSymbolType, symbolType, - itemWidth, itemHeight, itemAlign, color, - selectMode - ); - - itemGroup.on('click', curry(dispatchSelectAction, seriesName, api)) - .on('mouseover', curry(dispatchHighlightAction, seriesModel, '', api)) - .on('mouseout', curry(dispatchDownplayAction, seriesModel, '', api)); - - legendDrawedMap[seriesName] = true; - }, this); - - ecModel.eachRawSeries(function (seriesModel) { - if (seriesModel.legendDataProvider) { - var data = seriesModel.legendDataProvider(); - data.each(function (idx) { - var name = data.getName(idx); - - // Avoid mutiple series use the same data name - if (!legendItemMap[name] || legendDrawedMap[name]) { - return; - } - - var color = data.getItemVisual(idx, 'color'); - - if (!legendModel.isSelected(name)) { - color = LEGEND_DISABLE_COLOR; - } - - var legendSymbolType = 'roundRect'; - - var itemGroup = this._createItem( - name, legendItemMap[name], legendModel, - legendSymbolType, null, - itemWidth, itemHeight, itemAlign, color, - selectMode - ); - - itemGroup.on('click', curry(dispatchSelectAction, name, api)) - // FIXME Should not specify the series name - .on('mouseover', curry(dispatchHighlightAction, seriesModel, name, api)) - .on('mouseout', curry(dispatchDownplayAction, seriesModel, name, api)); - - legendDrawedMap[name] = true; - }, false, this); - } - }, this); - - listComponentHelper.layout(group, legendModel, api); - // Render background after group is layout - // FIXME - listComponentHelper.addBackground(group, legendModel); - }, - - _createItem: function ( - name, itemModel, legendModel, - legendSymbolType, symbolType, - itemWidth, itemHeight, itemAlign, color, - selectMode - ) { - var itemGroup = new graphic.Group(); - - var textStyleModel = itemModel.getModel('textStyle'); - - var itemIcon = itemModel.get('icon'); - // Use user given icon first - legendSymbolType = itemIcon || legendSymbolType; - itemGroup.add(symbolCreator.createSymbol( - legendSymbolType, 0, 0, itemWidth, itemHeight, color - )); - - // Compose symbols - // PENDING - if (!itemIcon && symbolType - && symbolType !== legendSymbolType - && symbolType != 'none' - ) { - var size = itemHeight * 0.8; - // Put symbol in the center - itemGroup.add(symbolCreator.createSymbol( - symbolType, (itemWidth - size) / 2, (itemHeight - size) / 2, size, size, color - )); - } - - // Text - var textX = itemAlign === 'left' ? itemWidth + 5 : -5; - var textAlign = itemAlign; - - var formatter = legendModel.get('formatter'); - if (typeof formatter === 'string' && formatter) { - name = formatter.replace('{name}', name); - } - else if (typeof formatter === 'function') { - name = formatter(name); - } - - var text = new graphic.Text({ - style: { - text: name, - x: textX, - y: itemHeight / 2, - fill: textStyleModel.getTextColor(), - textFont: textStyleModel.getFont(), - textAlign: textAlign, - textBaseline: 'middle' - } - }); - itemGroup.add(text); - - // Add a invisible rect to increase the area of mouse hover - itemGroup.add(new graphic.Rect({ - shape: itemGroup.getBoundingRect(), - invisible: true - })); - - itemGroup.eachChild(function (child) { - child.silent = !selectMode; - }); - - this.group.add(itemGroup); - - return itemGroup; - } - }); -}); -define('echarts/component/legend/legendFilter',[],function () { - return function (ecModel) { - var legendModels = ecModel.findComponents({ - mainType: 'legend' - }); - if (legendModels && legendModels.length) { - ecModel.filterSeries(function (series) { - // If in any legend component the status is not selected. - // Because in legend series - for (var i = 0; i < legendModels.length; i++) { - if (!legendModels[i].isSelected(series.name)) { - return false; - } - } - return true; - }); - } - }; -}); -/** - * Legend component entry file8 - */ -define('echarts/component/legend',['require','./legend/LegendModel','./legend/legendAction','./legend/LegendView','../echarts','./legend/legendFilter'],function (require) { - - require('./legend/LegendModel'); - require('./legend/legendAction'); - require('./legend/LegendView'); - - var echarts = require('../echarts'); - // Series Filter - echarts.registerProcessor('filter', require('./legend/legendFilter')); -}); -define('echarts/chart/map/MapSeries',['require','../../data/List','../../echarts','../../model/Series','zrender/core/util','../../data/helper/completeDimensions','../../util/format','../helper/dataSelectableMixin'],function (require) { - - var List = require('../../data/List'); - var echarts = require('../../echarts'); - var SeriesModel = require('../../model/Series'); - var zrUtil = require('zrender/core/util'); - var completeDimensions = require('../../data/helper/completeDimensions'); - - var formatUtil = require('../../util/format'); - var encodeHTML = formatUtil.encodeHTML; - var addCommas = formatUtil.addCommas; - - var dataSelectableMixin = require('../helper/dataSelectableMixin'); - - function fillData(dataOpt, geoJson) { - var dataNameMap = {}; - var features = geoJson.features; - for (var i = 0; i < dataOpt.length; i++) { - dataNameMap[dataOpt[i].name] = dataOpt[i]; - } - - for (var i = 0; i < features.length; i++) { - var name = features[i].properties.name; - if (!dataNameMap[name]) { - dataOpt.push({ - value: NaN, - name: name - }); - } - } - return dataOpt; - } - - var MapSeries = SeriesModel.extend({ - - type: 'series.map', - - /** - * Only first map series of same mapType will drawMap - * @type {boolean} - */ - needsDrawMap: false, - - /** - * Group of all map series with same mapType - * @type {boolean} - */ - seriesGroup: [], - - init: function (option) { - - option = this._fillOption(option); - this.option = option; - - MapSeries.superApply(this, 'init', arguments); - - this.updateSelectedMap(); - }, - - getInitialData: function (option) { - var dimensions = completeDimensions(['value'], option.data || []); - - var list = new List(dimensions, this); - - list.initData(option.data); - - return list; - }, - - mergeOption: function (newOption) { - newOption = this._fillOption(newOption); - SeriesModel.prototype.mergeOption.call(this, newOption); - this.updateSelectedMap(); - }, - - _fillOption: function (option) { - // Shallow clone - option = zrUtil.extend({}, option); - - var map = echarts.getMap(option.mapType); - var geoJson = map && map.geoJson; - geoJson && option.data - && (option.data = fillData(option.data, geoJson)); - - return option; - }, - - /** - * @param {number} zoom - */ - setRoamZoom: function (zoom) { - var roamDetail = this.option.roamDetail; - roamDetail && (roamDetail.zoom = zoom); - }, - - /** - * @param {number} x - * @param {number} y - */ - setRoamPan: function (x, y) { - var roamDetail = this.option.roamDetail; - if (roamDetail) { - roamDetail.x = x; - roamDetail.y = y; - } - }, - - getRawValue: function (dataIndex) { - // Use value stored in data instead because it is calculated from multiple series - // FIXME Provide all value of multiple series ? - return this._data.get('value', dataIndex); - }, - - /** - * Map tooltip formatter - * - * @param {number} dataIndex - */ - formatTooltip: function (dataIndex) { - var data = this._data; - var formattedValue = addCommas(this.getRawValue(dataIndex)); - var name = data.getName(dataIndex); - - var seriesGroup = this.seriesGroup; - var seriesNames = []; - for (var i = 0; i < seriesGroup.length; i++) { - if (!isNaN(seriesGroup[i].getRawValue(dataIndex))) { - seriesNames.push( - encodeHTML(seriesGroup[i].name) - ); - } - } - - return seriesNames.join(', ') + '
' - + name + ' : ' + formattedValue; - }, - - defaultOption: { - // 一级层叠 - zlevel: 0, - // 二级层叠 - z: 2, - coordinateSystem: 'geo', - // 各省的 map 暂时都用中文 - map: 'china', - - // 'center' | 'left' | 'right' | 'x%' | {number} - left: 'center', - // 'center' | 'top' | 'bottom' | 'x%' | {number} - top: 'center', - // right - // bottom - // width: - // height // 自适应 - - // 数值合并方式,默认加和,可选为: - // 'sum' | 'average' | 'max' | 'min' - // mapValueCalculation: 'sum', - // 地图数值计算结果小数精度 - // mapValuePrecision: 0, - // 显示图例颜色标识(系列标识的小圆点),图例开启时有效 - showLegendSymbol: true, - // 选择模式,默认关闭,可选single,multiple - // selectedMode: false, - dataRangeHoverLink: true, - // 是否开启缩放及漫游模式 - // roam: false, - - // 在 roam 开启的时候使用 - roamDetail: { - x: 0, - y: 0, - zoom: 1 - }, - - label: { - normal: { - show: false, - textStyle: { - color: '#000' - } - }, - emphasis: { - show: false, - textStyle: { - color: '#000' - } - } - }, - // scaleLimit: null, - itemStyle: { - normal: { - // color: 各异, - borderWidth: 0.5, - borderColor: '#444', - areaColor: '#eee' - }, - // 也是选中样式 - emphasis: { - areaColor: 'rgba(255,215, 0, 0.8)' - } - } - } - }); - - zrUtil.mixin(MapSeries, dataSelectableMixin); - - return MapSeries; -}); -define('echarts/component/helper/interactionMutex',['require'],function (require) { + module.exports = CandlestickSeries; - var ATTR = '\0_ec_interaction_mutex'; - var interactionMutex = { - take: function (key, zr) { - getStore(zr)[key] = true; - }, +/***/ }, +/* 245 */ +/***/ function(module, exports, __webpack_require__) { - release: function (key, zr) { - getStore(zr)[key] = false; - }, + 'use strict'; - isTaken: function (key, zr) { - return !!getStore(zr)[key]; - } - }; - function getStore(zr) { - return zr[ATTR] || (zr[ATTR] = {}); - } + var zrUtil = __webpack_require__(3); + var ChartView = __webpack_require__(41); + var graphic = __webpack_require__(42); + var whiskerBoxCommon = __webpack_require__(238); - return interactionMutex; -}); -/** - * @module echarts/component/helper/RoamController - */ - -define('echarts/component/helper/RoamController',['require','zrender/mixin/Eventful','zrender/core/util','zrender/core/event','./interactionMutex'],function (require) { - - var Eventful = require('zrender/mixin/Eventful'); - var zrUtil = require('zrender/core/util'); - var eventTool = require('zrender/core/event'); - var interactionMutex = require('./interactionMutex'); - - function mousedown(e) { - if (e.target && e.target.draggable) { - return; - } - - var x = e.offsetX; - var y = e.offsetY; - var rect = this.rect; - if (rect && rect.contain(x, y)) { - this._x = x; - this._y = y; - this._dragging = true; - } - } - - function mousemove(e) { - if (!this._dragging) { - return; - } - - eventTool.stop(e.event); - - if (e.gestureEvent !== 'pinch') { - - if (interactionMutex.isTaken('globalPan', this._zr)) { - return; - } - - var x = e.offsetX; - var y = e.offsetY; - - var dx = x - this._x; - var dy = y - this._y; - - this._x = x; - this._y = y; - - var target = this.target; - - if (target) { - var pos = target.position; - pos[0] += dx; - pos[1] += dy; - target.dirty(); - } - - eventTool.stop(e.event); - this.trigger('pan', dx, dy); - } - } - - function mouseup(e) { - this._dragging = false; - } - - function mousewheel(e) { - eventTool.stop(e.event); - // Convenience: - // Mac and VM Windows on Mac: scroll up: zoom out. - // Windows: scroll up: zoom in. - var zoomDelta = e.wheelDelta > 0 ? 1.1 : 1 / 1.1; - zoom.call(this, e, zoomDelta, e.offsetX, e.offsetY); - } - - function pinch(e) { - if (interactionMutex.isTaken('globalPan', this._zr)) { - return; - } - - eventTool.stop(e.event); - var zoomDelta = e.pinchScale > 1 ? 1.1 : 1 / 1.1; - zoom.call(this, e, zoomDelta, e.pinchX, e.pinchY); - } - - function zoom(e, zoomDelta, zoomX, zoomY) { - var rect = this.rect; - - if (rect && rect.contain(zoomX, zoomY)) { - - var target = this.target; - - if (target) { - var pos = target.position; - var scale = target.scale; - - var newZoom = this._zoom = this._zoom || 1; - newZoom *= zoomDelta; - // newZoom = Math.max( - // Math.min(target.maxZoom, newZoom), - // target.minZoom - // ); - var zoomScale = newZoom / this._zoom; - this._zoom = newZoom; - // Keep the mouse center when scaling - pos[0] -= (zoomX - pos[0]) * (zoomScale - 1); - pos[1] -= (zoomY - pos[1]) * (zoomScale - 1); - scale[0] *= zoomScale; - scale[1] *= zoomScale; - - target.dirty(); - } - - this.trigger('zoom', zoomDelta, zoomX, zoomY); - } - } - - /** - * @alias module:echarts/component/helper/RoamController - * @constructor - * @mixin {module:zrender/mixin/Eventful} - * - * @param {module:zrender/zrender~ZRender} zr - * @param {module:zrender/Element} target - * @param {module:zrender/core/BoundingRect} rect - */ - function RoamController(zr, target, rect) { - - /** - * @type {module:zrender/Element} - */ - this.target = target; - - /** - * @type {module:zrender/core/BoundingRect} - */ - this.rect = rect; - - /** - * @type {module:zrender} - */ - this._zr = zr; - - // Avoid two roamController bind the same handler - var bind = zrUtil.bind; - var mousedownHandler = bind(mousedown, this); - var mousemoveHandler = bind(mousemove, this); - var mouseupHandler = bind(mouseup, this); - var mousewheelHandler = bind(mousewheel, this); - var pinchHandler = bind(pinch, this); - - Eventful.call(this); - - /** - * Notice: only enable needed types. For example, if 'zoom' - * is not needed, 'zoom' should not be enabled, otherwise - * default mousewheel behaviour (scroll page) will be disabled. - * - * @param {boolean|string} [controlType=true] Specify the control type, - * which can be null/undefined or true/false - * or 'pan/move' or 'zoom'/'scale' - */ - this.enable = function (controlType) { - // Disable previous first - this.disable(); - - if (controlType == null) { - controlType = true; - } - - if (controlType === true || (controlType === 'move' || controlType === 'pan')) { - zr.on('mousedown', mousedownHandler); - zr.on('mousemove', mousemoveHandler); - zr.on('mouseup', mouseupHandler); - } - if (controlType === true || (controlType === 'scale' || controlType === 'zoom')) { - zr.on('mousewheel', mousewheelHandler); - zr.on('pinch', pinchHandler); - } - }; - - this.disable = function () { - zr.off('mousedown', mousedownHandler); - zr.off('mousemove', mousemoveHandler); - zr.off('mouseup', mouseupHandler); - zr.off('mousewheel', mousewheelHandler); - zr.off('pinch', pinchHandler); - }; - - this.dispose = this.disable; - - this.isDragging = function () { - return this._dragging; - }; - - this.isPinching = function () { - return this._pinching; - }; - } - - zrUtil.mixin(RoamController, Eventful); - - return RoamController; -}); -/** - * @module echarts/component/helper/MapDraw - */ -define('echarts/component/helper/MapDraw',['require','./RoamController','../../util/graphic','zrender/core/util'],function (require) { - - var RoamController = require('./RoamController'); - var graphic = require('../../util/graphic'); - var zrUtil = require('zrender/core/util'); - - function getFixedItemStyle(model, scale) { - var itemStyle = model.getItemStyle(); - var areaColor = model.get('areaColor'); - if (areaColor) { - itemStyle.fill = areaColor; - } - - return itemStyle; - } - - function updateMapSelectHandler(mapOrGeoModel, data, group, api, fromView) { - group.off('click'); - mapOrGeoModel.get('selectedMode') - && group.on('click', function (e) { - var dataIndex = e.target.dataIndex; - if (dataIndex != null) { - var name = data.getName(dataIndex); - - api.dispatchAction({ - type: 'mapToggleSelect', - seriesIndex: mapOrGeoModel.seriesIndex, - name: name, - from: fromView.uid - }); - - updateMapSelected(mapOrGeoModel, data, api); - } - }); - } - - function updateMapSelected(mapOrGeoModel, data) { - data.eachItemGraphicEl(function (el, idx) { - var name = data.getName(idx); - el.trigger(mapOrGeoModel.isSelected(name) ? 'emphasis' : 'normal'); - }); - } - - /** - * @alias module:echarts/component/helper/MapDraw - * @param {module:echarts/ExtensionAPI} api - * @param {boolean} updateGroup - */ - function MapDraw(api, updateGroup) { - - var group = new graphic.Group(); - - /** - * @type {module:echarts/component/helper/RoamController} - * @private - */ - this._controller = new RoamController( - api.getZr(), updateGroup ? group : null, null - ); - - /** - * @type {module:zrender/container/Group} - * @readOnly - */ - this.group = group; - - /** - * @type {boolean} - * @private - */ - this._updateGroup = updateGroup; - } - - MapDraw.prototype = { - - constructor: MapDraw, - - draw: function (mapOrGeoModel, ecModel, api, fromView) { - - // geoModel has no data - var data = mapOrGeoModel.getData && mapOrGeoModel.getData(); - - var geo = mapOrGeoModel.coordinateSystem; - - var group = this.group; - group.removeAll(); - - var scale = geo.scale; - group.position = geo.position.slice(); - group.scale = scale.slice(); - - var itemStyleModel; - var hoverItemStyleModel; - var itemStyle; - var hoverItemStyle; - - var labelModel; - var hoverLabelModel; - - var itemStyleAccessPath = ['itemStyle', 'normal']; - var hoverItemStyleAccessPath = ['itemStyle', 'emphasis']; - var labelAccessPath = ['label', 'normal']; - var hoverLabelAccessPath = ['label', 'emphasis']; - if (!data) { - itemStyleModel = mapOrGeoModel.getModel(itemStyleAccessPath); - hoverItemStyleModel = mapOrGeoModel.getModel(hoverItemStyleAccessPath); - - itemStyle = getFixedItemStyle(itemStyleModel, scale); - hoverItemStyle = getFixedItemStyle(hoverItemStyleModel, scale); - - labelModel = mapOrGeoModel.getModel(labelAccessPath); - hoverLabelModel = mapOrGeoModel.getModel(hoverLabelAccessPath); - } - - zrUtil.each(geo.regions, function (region) { - - var regionGroup = new graphic.Group(); - var dataIdx; - // Use the itemStyle in data if has data - if (data) { - // FIXME If dataIdx < 0 - dataIdx = data.indexOfName(region.name); - var itemModel = data.getItemModel(dataIdx); - - // Only visual color of each item will be used. It can be encoded by dataRange - // But visual color of series is used in symbol drawing - // - // Visual color for each series is for the symbol draw - var visualColor = data.getItemVisual(dataIdx, 'color', true); - - itemStyleModel = itemModel.getModel(itemStyleAccessPath); - hoverItemStyleModel = itemModel.getModel(hoverItemStyleAccessPath); - - itemStyle = getFixedItemStyle(itemStyleModel, scale); - hoverItemStyle = getFixedItemStyle(hoverItemStyleModel, scale); - - labelModel = itemModel.getModel(labelAccessPath); - hoverLabelModel = itemModel.getModel(hoverLabelAccessPath); - - if (visualColor) { - itemStyle.fill = visualColor; - } - } - var textStyleModel = labelModel.getModel('textStyle'); - var hoverTextStyleModel = hoverLabelModel.getModel('textStyle'); - - zrUtil.each(region.contours, function (contour) { - - var polygon = new graphic.Polygon({ - shape: { - points: contour - }, - style: { - strokeNoScale: true - }, - culling: true - }); - - polygon.setStyle(itemStyle); - - regionGroup.add(polygon); - }); - - // Label - var showLabel = labelModel.get('show'); - var hoverShowLabel = hoverLabelModel.get('show'); - - var isDataNaN = data && isNaN(data.get('value', dataIdx)); - var itemLayout = data && data.getItemLayout(dataIdx); - // In the following cases label will be drawn - // 1. In map series and data value is NaN - // 2. In geo component - // 4. Region has no series legendSymbol, which will be add a showLabel flag in mapSymbolLayout - if ( - (!data || isDataNaN && (showLabel || hoverShowLabel)) - || (itemLayout && itemLayout.showLabel) - ) { - var query = data ? dataIdx : region.name; - var formattedStr = mapOrGeoModel.getFormattedLabel(query, 'normal'); - var hoverFormattedStr = mapOrGeoModel.getFormattedLabel(query, 'emphasis'); - var text = new graphic.Text({ - style: { - text: showLabel ? (formattedStr || region.name) : '', - fill: textStyleModel.getTextColor(), - textFont: textStyleModel.getFont(), - textAlign: 'center', - textBaseline: 'middle' - }, - hoverStyle: { - text: hoverShowLabel ? (hoverFormattedStr || region.name) : '', - fill: hoverTextStyleModel.getTextColor(), - textFont: hoverTextStyleModel.getFont() - }, - position: region.center.slice(), - scale: [1 / scale[0], 1 / scale[1]], - z2: 10, - silent: true - }); - - regionGroup.add(text); - } - - // setItemGraphicEl, setHoverStyle after all polygons and labels - // are added to the rigionGroup - data && data.setItemGraphicEl(dataIdx, regionGroup); - - graphic.setHoverStyle(regionGroup, hoverItemStyle); - - group.add(regionGroup); - }); - - this._updateController(mapOrGeoModel, ecModel, api); - - data && updateMapSelectHandler(mapOrGeoModel, data, group, api, fromView); - - data && updateMapSelected(mapOrGeoModel, data); - }, - - remove: function () { - this.group.removeAll(); - this._controller.dispose(); - }, - - _updateController: function (mapOrGeoModel, ecModel, api) { - var geo = mapOrGeoModel.coordinateSystem; - var controller = this._controller; - // roamType is will be set default true if it is null - controller.enable(mapOrGeoModel.get('roam') || false); - // FIXME mainType, subType 作为 component 的属性? - var mainType = mapOrGeoModel.type.split('.')[0]; - controller.off('pan') - .on('pan', function (dx, dy) { - api.dispatchAction({ - type: 'geoRoam', - component: mainType, - name: mapOrGeoModel.name, - dx: dx, - dy: dy - }); - }); - controller.off('zoom') - .on('zoom', function (zoom, mouseX, mouseY) { - api.dispatchAction({ - type: 'geoRoam', - component: mainType, - name: mapOrGeoModel.name, - zoom: zoom, - originX: mouseX, - originY: mouseY - }); - - if (this._updateGroup) { - var group = this.group; - var scale = group.scale; - group.traverse(function (el) { - if (el.type === 'text') { - el.attr('scale', [1 / scale[0], 1 / scale[1]]); - } - }); - } - }, this); - - controller.rect = geo.getViewRect(); - } - }; - - return MapDraw; -}); -define('echarts/chart/map/MapView',['require','../../util/graphic','../../component/helper/MapDraw','../../echarts'],function (require) { - - // var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - - var MapDraw = require('../../component/helper/MapDraw'); - - require('../../echarts').extendChartView({ - - type: 'map', - - render: function (mapModel, ecModel, api, payload) { - // Not render if it is an toggleSelect action from self - if (payload && payload.type === 'mapToggleSelect' - && payload.from === this.uid - ) { - return; - } - - var group = this.group; - group.removeAll(); - // Not update map if it is an roam action from self - if (!(payload && payload.type === 'geoRoam' - && payload.component === 'series' - && payload.name === mapModel.name)) { - - if (mapModel.needsDrawMap) { - var mapDraw = this._mapDraw || new MapDraw(api, true); - group.add(mapDraw.group); - - mapDraw.draw(mapModel, ecModel, api, this); - - this._mapDraw = mapDraw; - } - else { - // Remove drawed map - this._mapDraw && this._mapDraw.remove(); - this._mapDraw = null; - } - } - else { - var mapDraw = this._mapDraw; - mapDraw && group.add(mapDraw.group); - } - - mapModel.get('showLegendSymbol') && ecModel.getComponent('legend') - && this._renderSymbols(mapModel, ecModel, api); - }, - - remove: function () { - this._mapDraw && this._mapDraw.remove(); - this._mapDraw = null; - this.group.removeAll(); - }, - - _renderSymbols: function (mapModel, ecModel, api) { - var data = mapModel.getData(); - var group = this.group; - - data.each('value', function (value, idx) { - if (isNaN(value)) { - return; - } - - var layout = data.getItemLayout(idx); - - if (!layout || !layout.point) { - // Not exists in map - return; - } - - var point = layout.point; - var offset = layout.offset; - - var circle = new graphic.Circle({ - style: { - fill: data.getVisual('color') - }, - shape: { - cx: point[0] + offset * 9, - cy: point[1], - r: 3 - }, - silent: true, - z2: 10 - }); - - // First data on the same region - if (!offset) { - var labelText = data.getName(idx); - - var itemModel = data.getItemModel(idx); - var labelModel = itemModel.getModel('label.normal'); - var hoverLabelModel = itemModel.getModel('label.emphasis'); - - var textStyleModel = labelModel.getModel('textStyle'); - var hoverTextStyleModel = hoverLabelModel.getModel('textStyle'); - - var polygonGroups = data.getItemGraphicEl(idx); - circle.setStyle({ - textPosition: 'bottom' - }); - - var onEmphasis = function () { - circle.setStyle({ - text: hoverLabelModel.get('show') ? labelText : '', - textFill: hoverTextStyleModel.getTextColor(), - textFont: hoverTextStyleModel.getFont() - }); - }; - - var onNormal = function () { - circle.setStyle({ - text: labelModel.get('show') ? labelText : '', - textFill: textStyleModel.getTextColor(), - textFont: textStyleModel.getFont() - }); - }; - - polygonGroups.on('mouseover', onEmphasis) - .on('mouseout', onNormal) - .on('emphasis', onEmphasis) - .on('normal', onNormal); - - onNormal(); - } - - group.add(circle); - }); - } - }); -}); -define('echarts/action/roamHelper',['require'],function (require) { - - var roamHelper = {}; - - /** - * Calculate pan and zoom which from roamDetail model - * @param {module:echarts/model/Model} roamDetailModel - * @param {Object} payload - */ - roamHelper.calcPanAndZoom = function (roamDetailModel, payload) { - var dx = payload.dx; - var dy = payload.dy; - var zoom = payload.zoom; - - var panX = roamDetailModel.get('x') || 0; - var panY = roamDetailModel.get('y') || 0; - - var previousZoom = roamDetailModel.get('zoom') || 1; - - if (dx != null && dy != null) { - panX += dx; - panY += dy; - } - if (zoom != null) { - var fixX = (payload.originX - panX) * (zoom - 1); - var fixY = (payload.originY - panY) * (zoom - 1); - - panX -= fixX; - panY -= fixY; - } - - return { - x: panX, - y: panY, - zoom: (zoom || 1) * previousZoom - }; - }; - - return roamHelper; -}); -define('echarts/action/geoRoam',['require','zrender/core/util','./roamHelper','../echarts'],function (require) { - - var zrUtil = require('zrender/core/util'); - var roamHelper = require('./roamHelper'); - - var echarts = require('../echarts'); - var actionInfo = { - type: 'geoRoam', - event: 'geoRoam', - update: 'updateLayout' - }; - - /** - * @payload - * @property {string} [component=series] - * @property {string} name Component name - * @property {number} [dx] - * @property {number} [dy] - * @property {number} [zoom] - * @property {number} [originX] - * @property {number} [originY] - */ - echarts.registerAction(actionInfo, function (payload, ecModel) { - var componentType = payload.component || 'series'; - - ecModel.eachComponent(componentType, function (componentModel) { - if (componentModel.name === payload.name) { - var geo = componentModel.coordinateSystem; - if (geo.type !== 'geo') { - return; - } - - var roamDetailModel = componentModel.getModel('roamDetail'); - var res = roamHelper.calcPanAndZoom(roamDetailModel, payload); - - componentModel.setRoamPan - && componentModel.setRoamPan(res.x, res.y); - - componentModel.setRoamZoom - && componentModel.setRoamZoom(res.zoom); - - geo && geo.setPan(res.x, res.y); - geo && geo.setZoom(res.zoom); - - // All map series with same `map` use the same geo coordinate system - // So the roamDetail must be in sync. Include the series not selected by legend - if (componentType === 'series') { - zrUtil.each(componentModel.seriesGroup, function (seriesModel) { - seriesModel.setRoamPan(res.x, res.y); - seriesModel.setRoamZoom(res.zoom); - }); - } - } - }); - }); -}); -define('echarts/coord/geo/GeoModel',['require','../../util/model','../../model/Component'],function (require) { - - - var modelUtil = require('../../util/model'); - var ComponentModel = require('../../model/Component'); - - ComponentModel.extend({ - - type: 'geo', - - /** - * @type {module:echarts/coord/geo/Geo} - */ - coordinateSystem: null, - - init: function (option) { - ComponentModel.prototype.init.apply(this, arguments); - - // Default label emphasis `position` and `show` - modelUtil.defaultEmphasis( - option.label, ['position', 'show', 'textStyle', 'distance', 'formatter'] - ); - }, - - defaultOption: { - - zlevel: 0, - - z: 0, - - show: true, - - left: 'center', - - top: 'center', - - // 自适应 - // width:, - // height:, - // right - // bottom - - // Map type - map: '', - - // 在 roam 开启的时候使用 - roamDetail: { - x: 0, - y: 0, - zoom: 1 - }, - - label: { - normal: { - show: false, - textStyle: { - color: '#000' - } - }, - emphasis: { - show: true, - textStyle: { - color: 'rgb(100,0,0)' - } - } - }, - - itemStyle: { - normal: { - // color: 各异, - borderWidth: 0.5, - borderColor: '#444', - color: '#eee' - }, - emphasis: { // 也是选中样式 - color: 'rgba(255,215,0,0.8)' - } - } - }, - - /** - * Format label - * @param {string} name Region name - * @param {string} [status='normal'] 'normal' or 'emphasis' - * @return {string} - */ - getFormattedLabel: function (name, status) { - var formatter = this.get('label.' + status + '.formatter'); - var params = { - name: name - }; - if (typeof formatter === 'function') { - params.status = status; - return formatter(params); - } - else if (typeof formatter === 'string') { - return formatter.replace('{a}', params.seriesName); - } - }, - - setRoamZoom: function (zoom) { - var roamDetail = this.option.roamDetail; - roamDetail && (roamDetail.zoom = zoom); - }, - - setRoamPan: function (x, y) { - var roamDetail = this.option.roamDetail; - if (roamDetail) { - roamDetail.x = x; - roamDetail.y = y; - } - } - }); -}); -define('zrender/contain/polygon',['require','./windingLine'],function (require) { + var CandlestickView = ChartView.extend({ - var windingLine = require('./windingLine'); + type: 'candlestick', - var EPSILON = 1e-8; + getStyleUpdater: function () { + return updateStyle; + } - function isAroundEqual(a, b) { - return Math.abs(a - b) < EPSILON; - } + }); - function contain(points, x, y) { - var w = 0; - var p = points[0]; + zrUtil.mixin(CandlestickView, whiskerBoxCommon.viewMixin, true); - if (!p) { - return false; - } + // Update common properties + var normalStyleAccessPath = ['itemStyle', 'normal']; + var emphasisStyleAccessPath = ['itemStyle', 'emphasis']; - for (var i = 1; i < points.length; i++) { - var p2 = points[i]; - w += windingLine(p[0], p[1], p2[0], p2[1], x, y); - p = p2; - } + function updateStyle(itemGroup, data, idx) { + var itemModel = data.getItemModel(idx); + var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath); + var color = data.getItemVisual(idx, 'color'); + var borderColor = data.getItemVisual(idx, 'borderColor'); - // Close polygon - var p0 = points[0]; - if (!isAroundEqual(p[0], p0[0]) || !isAroundEqual(p[1], p0[1])) { - w += windingLine(p[0], p[1], p0[0], p0[1], x, y); - } + // Color must be excluded. + // Because symbol provide setColor individually to set fill and stroke + var itemStyle = normalItemStyleModel.getItemStyle( + ['color', 'color0', 'borderColor', 'borderColor0'] + ); - return w !== 0; - } + var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex); + whiskerEl.style.set(itemStyle); + whiskerEl.style.stroke = borderColor; + whiskerEl.dirty(); + var bodyEl = itemGroup.childAt(itemGroup.bodyIndex); + bodyEl.style.set(itemStyle); + bodyEl.style.fill = color; + bodyEl.style.stroke = borderColor; + bodyEl.dirty(); - return { - contain: contain - }; -}); -/** - * @module echarts/coord/geo/Region - */ -define('echarts/coord/geo/Region',['require','zrender/contain/polygon','zrender/core/BoundingRect','zrender/core/bbox','zrender/core/vector'],function (require) { - - var polygonContain = require('zrender/contain/polygon'); - - var BoundingRect = require('zrender/core/BoundingRect'); - - var bbox = require('zrender/core/bbox'); - var vec2 = require('zrender/core/vector'); - - /** - * @param {string} name - * @param {Array} contours - * @param {Array.} cp - */ - function Region(name, contours, cp) { - - /** - * @type {string} - * @readOnly - */ - this.name = name; - - /** - * @type {Array.} - * @readOnly - */ - this.contours = contours; - - if (!cp) { - var rect = this.getBoundingRect(); - cp = [ - rect.x + rect.width / 2, - rect.y + rect.height / 2 - ]; - } - else { - cp = [cp[0], cp[1]]; - } - /** - * @type {Array.} - */ - this.center = cp; - } - - Region.prototype = { - - constructor: Region, - - /** - * @return {module:zrender/core/BoundingRect} - */ - getBoundingRect: function () { - var rect = this._rect; - if (rect) { - return rect; - } - - var MAX_NUMBER = Number.MAX_VALUE; - var min = [MAX_NUMBER, MAX_NUMBER]; - var max = [-MAX_NUMBER, -MAX_NUMBER]; - var min2 = []; - var max2 = []; - var contours = this.contours; - for (var i = 0; i < contours.length; i++) { - bbox.fromPoints(contours[i], min2, max2); - vec2.min(min, min, min2); - vec2.max(max, max, max2); - } - // No data - if (i === 0) { - min[0] = min[1] = max[0] = max[1] = 0; - } - - return (this._rect = new BoundingRect( - min[0], min[1], max[0] - min[0], max[1] - min[1] - )); - }, - - /** - * @param {} coord - * @return {boolean} - */ - contain: function (coord) { - var rect = this.getBoundingRect(); - var contours = this.contours; - if (rect.contain(coord[0], coord[1])) { - for (var i = 0, len = contours.length; i < len; i++) { - if (polygonContain.contain(contours[i], coord[0], coord[1])) { - return true; - } - } - } - return false; - }, - - transformTo: function (x, y, width, height) { - var rect = this.getBoundingRect(); - var aspect = rect.width / rect.height; - if (!width) { - width = aspect * height; - } - else if (!height) { - height = width / aspect ; - } - var target = new BoundingRect(x, y, width, height); - var transform = rect.calculateTransform(target); - var contours = this.contours; - for (var i = 0; i < contours.length; i++) { - for (var p = 0; p < contours[i].length; p++) { - vec2.applyTransform(contours[i][p], contours[i][p], transform); - } - } - rect = this._rect; - rect.copy(target); - // Update center - this.center = [ - rect.x + rect.width / 2, - rect.y + rect.height / 2 - ]; - } - }; - - return Region; -}); -/** - * Parse and decode geo json - * @module echarts/coord/geo/parseGeoJson - */ -define('echarts/coord/geo/parseGeoJson',['require','zrender/core/util','./Region'],function (require) { - - var zrUtil = require('zrender/core/util'); - - var Region = require('./Region'); - - function decode(json) { - if (!json.UTF8Encoding) { - return json; - } - var features = json.features; - - for (var f = 0; f < features.length; f++) { - var feature = features[f]; - var geometry = feature.geometry; - var coordinates = geometry.coordinates; - var encodeOffsets = geometry.encodeOffsets; - - for (var c = 0; c < coordinates.length; c++) { - var coordinate = coordinates[c]; - - if (geometry.type === 'Polygon') { - coordinates[c] = decodePolygon( - coordinate, - encodeOffsets[c] - ); - } - else if (geometry.type === 'MultiPolygon') { - for (var c2 = 0; c2 < coordinate.length; c2++) { - var polygon = coordinate[c2]; - coordinate[c2] = decodePolygon( - polygon, - encodeOffsets[c][c2] - ); - } - } - } - } - // Has been decoded - json.UTF8Encoding = false; - return json; - } - - function decodePolygon(coordinate, encodeOffsets) { - var result = []; - var prevX = encodeOffsets[0]; - var prevY = encodeOffsets[1]; - - for (var i = 0; i < coordinate.length; i += 2) { - var x = coordinate.charCodeAt(i) - 64; - var y = coordinate.charCodeAt(i + 1) - 64; - // ZigZag decoding - x = (x >> 1) ^ (-(x & 1)); - y = (y >> 1) ^ (-(y & 1)); - // Delta deocding - x += prevX; - y += prevY; - - prevX = x; - prevY = y; - // Dequantize - result.push([x / 1024, y / 1024]); - } - - return result; - } - - /** - * @inner - */ - function flattern2D(array) { - var ret = []; - for (var i = 0; i < array.length; i++) { - for (var k = 0; k < array[i].length; k++) { - ret.push(array[i][k]); - } - } - return ret; - } - - /** - * @alias module:echarts/coord/geo/parseGeoJson - * @param {Object} geoJson - * @return {module:zrender/container/Group} - */ - return function (geoJson) { - - decode(geoJson); - - return zrUtil.map(zrUtil.filter(geoJson.features, function (featureObj) { - // Output of mapshaper may have geometry null - return featureObj.geometry && featureObj.properties; - }), function (featureObj) { - var properties = featureObj.properties; - var geometry = featureObj.geometry; - - var coordinates = geometry.coordinates; - - if (geometry.type === 'MultiPolygon') { - coordinates = flattern2D(coordinates); - } - - return new Region( - properties.name, - coordinates, - properties.cp - ); - }); - }; -}); -/** - * Simple view coordinate system - * Mapping given x, y to transformd view x, y - */ -define('echarts/coord/View',['require','zrender/core/vector','zrender/core/matrix','zrender/mixin/Transformable','zrender/core/util','zrender/core/BoundingRect'],function (require) { - - var vector = require('zrender/core/vector'); - var matrix = require('zrender/core/matrix'); - - var Transformable = require('zrender/mixin/Transformable'); - var zrUtil = require('zrender/core/util'); - - var BoundingRect = require('zrender/core/BoundingRect'); - - var v2ApplyTransform = vector.applyTransform; - - // Dummy transform node - function TransformDummy() { - Transformable.call(this); - } - zrUtil.mixin(TransformDummy, Transformable); - - function View(name) { - /** - * @type {string} - */ - this.name = name; - - Transformable.call(this); - - this._roamTransform = new TransformDummy(); - - this._viewTransform = new TransformDummy(); - } - - View.prototype = { - - constructor: View, - - type: 'view', - - /** - * @param {Array.} - * @readOnly - */ - dimensions: ['x', 'y'], - - /** - * Set bounding rect - * @param {number} x - * @param {number} y - * @param {number} width - * @param {number} height - */ - - // PENDING to getRect - setBoundingRect: function (x, y, width, height) { - this._rect = new BoundingRect(x, y, width, height); - return this._rect; - }, - - /** - * @return {module:zrender/core/BoundingRect} - */ - // PENDING to getRect - getBoundingRect: function () { - return this._rect; - }, - - /** - * @param {number} x - * @param {number} y - * @param {number} width - * @param {number} height - */ - setViewRect: function (x, y, width, height) { - this.transformTo(x, y, width, height); - this._viewRect = new BoundingRect(x, y, width, height); - }, - - /** - * Transformed to particular position and size - * @param {number} x - * @param {number} y - * @param {number} width - * @param {number} height - */ - transformTo: function (x, y, width, height) { - var rect = this.getBoundingRect(); - var viewTransform = this._viewTransform; - - viewTransform.transform = rect.calculateTransform( - new BoundingRect(x, y, width, height) - ); - - viewTransform.decomposeTransform(); - - this._updateTransform(); - }, - - /** - * @param {number} x - * @param {number} y - */ - setPan: function (x, y) { - - this._roamTransform.position = [x, y]; - - this._updateTransform(); - }, - - /** - * @param {number} zoom - */ - setZoom: function (zoom) { - this._roamTransform.scale = [zoom, zoom]; - - this._updateTransform(); - }, - - /** - * @return {Array.} data - * @return {Array.} - */ - dataToPoint: function (data) { - var transform = this.transform; - return transform - ? v2ApplyTransform([], data, transform) - : [data[0], data[1]]; - }, - - /** - * Convert a (x, y) point to (lon, lat) data - * @param {Array.} point - * @return {Array.} - */ - pointToData: function (point) { - var invTransform = this.invTransform; - return invTransform - ? v2ApplyTransform([], point, invTransform) - : [point[0], point[1]]; - } - - /** - * @return {number} - */ - // getScalarScale: function () { - // // Use determinant square root of transform to mutiply scalar - // var m = this.transform; - // var det = Math.sqrt(Math.abs(m[0] * m[3] - m[2] * m[1])); - // return det; - // } - }; - - zrUtil.mixin(View, Transformable); - - return View; -}); -// Fix for 南海诸岛 -define('echarts/coord/geo/fix/nanhai',['require','../Region'],function (require) { - - var Region = require('../Region'); - - var geoCoord = [126, 25]; - - var points = [ - [[0,3.5],[7,11.2],[15,11.9],[30,7],[42,0.7],[52,0.7], - [56,7.7],[59,0.7],[64,0.7],[64,0],[5,0],[0,3.5]], - [[13,16.1],[19,14.7],[16,21.7],[11,23.1],[13,16.1]], - [[12,32.2],[14,38.5],[15,38.5],[13,32.2],[12,32.2]], - [[16,47.6],[12,53.2],[13,53.2],[18,47.6],[16,47.6]], - [[6,64.4],[8,70],[9,70],[8,64.4],[6,64.4]], - [[23,82.6],[29,79.8],[30,79.8],[25,82.6],[23,82.6]], - [[37,70.7],[43,62.3],[44,62.3],[39,70.7],[37,70.7]], - [[48,51.1],[51,45.5],[53,45.5],[50,51.1],[48,51.1]], - [[51,35],[51,28.7],[53,28.7],[53,35],[51,35]], - [[52,22.4],[55,17.5],[56,17.5],[53,22.4],[52,22.4]], - [[58,12.6],[62,7],[63,7],[60,12.6],[58,12.6]], - [[0,3.5],[0,93.1],[64,93.1],[64,0],[63,0],[63,92.4], - [1,92.4],[1,3.5],[0,3.5]] - ]; - for (var i = 0; i < points.length; i++) { - for (var k = 0; k < points[i].length; k++) { - points[i][k][0] /= 10.5; - points[i][k][1] /= -10.5 / 0.75; - - points[i][k][0] += geoCoord[0]; - points[i][k][1] += geoCoord[1]; - } - } - return function (geo) { - if (geo.map === 'china') { - geo.regions.push(new Region( - '南海诸岛', points, geoCoord - )); - } - }; -}); -define('echarts/coord/geo/fix/textCoord',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - var coordsOffsetMap = { - '南海诸岛' : [32, 80], - // 全国 - '广东': [0, -10], - '香港': [10, 5], - '澳门': [-10, 10], - //'北京': [-10, 0], - '天津': [5, 5] - }; - - return function (geo) { - zrUtil.each(geo.regions, function (region) { - var coordFix = coordsOffsetMap[region.name]; - if (coordFix) { - var cp = region.center; - cp[0] += coordFix[0] / 10.5; - cp[1] += -coordFix[1] / (10.5 / 0.75); - } - }); - }; -}); -define('echarts/coord/geo/fix/geoCoord',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - var geoCoordMap = { - 'Russia': [100, 60], - 'United States of America': [-99, 38] - }; - - return function (geo) { - zrUtil.each(geo.regions, function (region) { - var geoCoord = geoCoordMap[region.name]; - if (geoCoord) { - var cp = region.center; - cp[0] = geoCoord[0]; - cp[1] = geoCoord[1]; - } - }); - }; -}); -define('echarts/coord/geo/Geo',['require','./parseGeoJson','zrender/core/util','zrender/core/BoundingRect','../View','./fix/nanhai','./fix/textCoord','./fix/geoCoord'],function (require) { - - var parseGeoJson = require('./parseGeoJson'); - - var zrUtil = require('zrender/core/util'); - - var BoundingRect = require('zrender/core/BoundingRect'); - - var View = require('../View'); - - - // Geo fix functions - var geoFixFuncs = [ - require('./fix/nanhai'), - require('./fix/textCoord'), - require('./fix/geoCoord') - ]; - - /** - * [Geo description] - * @param {string} name Geo name - * @param {string} map Map type - * @param {Object} geoJson - * @param {Object} [specialAreas] - * Specify the positioned areas by left, top, width, height - * @param {Object.} [nameMap] - * Specify name alias - */ - function Geo(name, map, geoJson, specialAreas, nameMap) { - - View.call(this, name); - - /** - * Map type - * @type {string} - */ - this.map = map; - - this._nameCoordMap = {}; - - this.loadGeoJson(geoJson, specialAreas, nameMap); - } - - Geo.prototype = { - - constructor: Geo, - - type: 'geo', - - /** - * @param {Array.} - * @readOnly - */ - dimensions: ['lng', 'lat'], - - /** - * @param {Object} geoJson - * @param {Object} [specialAreas] - * Specify the positioned areas by left, top, width, height - * @param {Object.} [nameMap] - * Specify name alias - */ - loadGeoJson: function (geoJson, specialAreas, nameMap) { - // https://jsperf.com/try-catch-performance-overhead - try { - this.regions = geoJson ? parseGeoJson(geoJson) : []; - } - catch (e) { - throw 'Invalid geoJson format\n' + e; - } - specialAreas = specialAreas || {}; - nameMap = nameMap || {}; - var regions = this.regions; - var regionsMap = {}; - for (var i = 0; i < regions.length; i++) { - var regionName = regions[i].name; - // Try use the alias in nameMap - regionName = nameMap[regionName] || regionName; - regions[i].name = regionName; - - regionsMap[regionName] = regions[i]; - // Add geoJson - this.addGeoCoord(regionName, regions[i].center); - - // Some area like Alaska in USA map needs to be tansformed - // to look better - var specialArea = specialAreas[regionName]; - if (specialArea) { - regions[i].transformTo( - specialArea.left, specialArea.top, specialArea.width, specialArea.height - ); - } - } - - this._regionsMap = regionsMap; - - this._rect = null; - - zrUtil.each(geoFixFuncs, function (fixFunc) { - fixFunc(this); - }, this); - }, - - // Overwrite - transformTo: function (x, y, width, height) { - var rect = this.getBoundingRect(); - - rect = rect.clone(); - // Longitute is inverted - rect.y = -rect.y - rect.height; - - var viewTransform = this._viewTransform; - - viewTransform.transform = rect.calculateTransform( - new BoundingRect(x, y, width, height) - ); - - viewTransform.decomposeTransform(); - - var scale = viewTransform.scale; - scale[1] = -scale[1]; - - viewTransform.updateTransform(); - - this._updateTransform(); - }, - - /** - * @param {string} name - * @return {module:echarts/coord/geo/Region} - */ - getRegion: function (name) { - return this._regionsMap[name]; - }, - - /** - * Add geoCoord for indexing by name - * @param {string} name - * @param {Array.} geoCoord - */ - addGeoCoord: function (name, geoCoord) { - this._nameCoordMap[name] = geoCoord; - }, - - /** - * Get geoCoord by name - * @param {string} name - * @return {Array.} - */ - getGeoCoord: function (name) { - return this._nameCoordMap[name]; - }, - - // Overwrite - getBoundingRect: function () { - if (this._rect) { - return this._rect; - } - var rect; - - var regions = this.regions; - for (var i = 0; i < regions.length; i++) { - var regionRect = regions[i].getBoundingRect(); - rect = rect || regionRect.clone(); - rect.union(regionRect); - } - // FIXME Always return new ? - return (this._rect = rect || new BoundingRect(0, 0, 0, 0)); - }, - - /** - * Convert series data to a list of points - * @param {module:echarts/data/List} data - * @param {boolean} stack - * @return {Array} - * Return list of points. For example: - * `[[10, 10], [20, 20], [30, 30]]` - */ - dataToPoints: function (data) { - var item = []; - return data.mapArray(['lng', 'lat'], function (lon, lat) { - item[0] = lon; - item[1] = lat; - return this.dataToPoint(item); - }, this); - }, - - // Overwrite - /** - * @param {string|Array.} data - * @return {Array.} - */ - dataToPoint: function (data) { - if (typeof data === 'string') { - // Map area name to geoCoord - data = this.getGeoCoord(data); - } - if (data) { - return View.prototype.dataToPoint.call(this, data); - } - } - }; - - zrUtil.mixin(Geo, View); - - return Geo; -}); -define('echarts/coord/geo/geoCreator',['require','./GeoModel','./Geo','../../util/layout','zrender/core/util','../../echarts'],function (require) { + var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle(); + graphic.setHoverStyle(itemGroup, hoverStyle); + } - require('./GeoModel'); - var Geo = require('./Geo'); + module.exports = CandlestickView; - var layout = require('../../util/layout'); - var zrUtil = require('zrender/core/util'); - var mapDataStores = {}; - /** - * Resize method bound to the geo - * @param {module:echarts/coord/geo/GeoModel|module:echarts/chart/map/MapModel} geoModel - * @param {module:echarts/ExtensionAPI} api - */ - function resizeGeo (geoModel, api) { - var rect = this.getBoundingRect(); - - var boxLayoutOption = geoModel.getBoxLayoutParams(); - // 0.75 rate - boxLayoutOption.aspect = rect.width / rect.height * 0.75; - - var viewRect = layout.getLayoutRect(boxLayoutOption, { - width: api.getWidth(), - height: api.getHeight() - }); - - this.setViewRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height); - - var roamDetailModel = geoModel.getModel('roamDetail'); - - var panX = roamDetailModel.get('x') || 0; - var panY = roamDetailModel.get('y') || 0; - var zoom = roamDetailModel.get('zoom') || 1; - - this.setPan(panX, panY); - this.setZoom(zoom); - } - - /** - * @param {module:echarts/coord/Geo} geo - * @param {module:echarts/model/Model} model - * @inner - */ - function setGeoCoords(geo, model) { - zrUtil.each(model.get('geoCoord'), function (geoCoord, name) { - geo.addGeoCoord(name, geoCoord); - }); - } - - function mapNotExistsError(name) { - console.error('Map ' + name + ' not exists'); - } - - var geoCreator = { - - // For deciding which dimensions to use when creating list data - dimensions: Geo.prototype.dimensions, - - create: function (ecModel, api) { - var geoList = []; - - // FIXME Create each time may be slow - ecModel.eachComponent('geo', function (geoModel, idx) { - var name = geoModel.get('map'); - var mapData = mapDataStores[name]; - if (!mapData) { - mapNotExistsError(name); - } - var geo = new Geo( - name + idx, name, - mapData && mapData.geoJson, mapData && mapData.specialAreas, - geoModel.get('nameMap') - ); - geoList.push(geo); - - setGeoCoords(geo, geoModel); - - geoModel.coordinateSystem = geo; - geo.model = geoModel; - - // Inject resize method - geo.resize = resizeGeo; - - geo.resize(geoModel, api); - }); - - ecModel.eachSeries(function (seriesModel) { - var coordSys = seriesModel.get('coordinateSystem'); - if (coordSys === 'geo') { - var geoIndex = seriesModel.get('geoIndex') || 0; - seriesModel.coordinateSystem = geoList[geoIndex]; - } - }); - - // If has map series - var mapModelGroupBySeries = {}; - - ecModel.eachSeriesByType('map', function (seriesModel) { - var mapType = seriesModel.get('map'); - - mapModelGroupBySeries[mapType] = mapModelGroupBySeries[mapType] || []; - - mapModelGroupBySeries[mapType].push(seriesModel); - }); - - zrUtil.each(mapModelGroupBySeries, function (mapSeries, mapType) { - var mapData = mapDataStores[mapType]; - if (!mapData) { - mapNotExistsError(name); - } - - var nameMapList = zrUtil.map(mapSeries, function (singleMapSeries) { - return singleMapSeries.get('nameMap'); - }); - var geo = new Geo( - mapType, mapType, - mapData && mapData.geoJson, mapData && mapData.specialAreas, - zrUtil.mergeAll(nameMapList) - ); - geoList.push(geo); - - // Inject resize method - geo.resize = resizeGeo; - - geo.resize(mapSeries[0], api); - - zrUtil.each(mapSeries, function (singleMapSeries) { - singleMapSeries.coordinateSystem = geo; - - setGeoCoords(geo, singleMapSeries); - }); - }); - - return geoList; - }, - - /** - * @param {string} mapName - * @param {Object|string} geoJson - * @param {Object} [specialAreas] - * - * @example - * $.get('USA.json', function (geoJson) { - * echarts.registerMap('USA', geoJson); - * // Or - * echarts.registerMap('USA', { - * geoJson: geoJson, - * specialAreas: {} - * }) - * }); - */ - registerMap: function (mapName, geoJson, specialAreas) { - if (geoJson.geoJson && !geoJson.features) { - specialAreas = geoJson.specialAreas; - geoJson = geoJson.geoJson; - } - if (typeof geoJson === 'string') { - geoJson = (typeof JSON !== 'undefined' && JSON.parse) - ? JSON.parse(geoJson) : (new Function('return (' + geoJson + ');'))(); - } - mapDataStores[mapName] = { - geoJson: geoJson, - specialAreas: specialAreas - }; - }, - - /** - * @param {string} mapName - * @return {Object} - */ - getMap: function (mapName) { - return mapDataStores[mapName]; - } - }; - - // Inject methods into echarts - var echarts = require('../../echarts'); - - echarts.registerMap = geoCreator.registerMap; - - echarts.getMap = geoCreator.getMap; - - // TODO - echarts.loadMap = function () {}; - - echarts.registerCoordinateSystem('geo', geoCreator); -}); -define('echarts/chart/map/mapSymbolLayout',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - return function (ecModel) { - - var processedMapType = {}; - - ecModel.eachSeriesByType('map', function (mapSeries) { - var mapType = mapSeries.get('mapType'); - if (processedMapType[mapType]) { - return; - } - - var mapSymbolOffsets = {}; - - zrUtil.each(mapSeries.seriesGroup, function (subMapSeries) { - var geo = subMapSeries.coordinateSystem; - var data = subMapSeries.getData(); - if (subMapSeries.get('showLegendSymbol') && ecModel.getComponent('legend')) { - data.each('value', function (value, idx) { - var name = data.getName(idx); - var region = geo.getRegion(name); - - // No region or no value - // In MapSeries data regions will be filled with NaN - // If they are not in the series.data array. - // So here must validate if value is NaN - if (!region || isNaN(value)) { - return; - } - - var offset = mapSymbolOffsets[name] || 0; - - var point = geo.dataToPoint(region.center); - - mapSymbolOffsets[name] = offset + 1; - - data.setItemLayout(idx, { - point: point, - offset: offset - }); - }); - } - }); - - // Show label of those region not has legendSymbol(which is offset 0) - var data = mapSeries.getData(); - data.each(function (idx) { - var name = data.getName(idx); - var layout = data.getItemLayout(idx) || {}; - layout.showLabel = !mapSymbolOffsets[name]; - data.setItemLayout(idx, layout); - }); - - processedMapType[mapType] = true; - }); - }; -}); -define('echarts/chart/map/mapVisual',['require'],function (require) { - return function (ecModel) { - ecModel.eachSeriesByType('map', function (seriesModel) { - var colorList = seriesModel.get('color'); - var itemStyleModel = seriesModel.getModel('itemStyle.normal'); - - var areaColor = itemStyleModel.get('areaColor'); - var color = itemStyleModel.get('color') - || colorList[seriesModel.seriesIndex % colorList.length]; - - seriesModel.getData().setVisual({ - 'areaColor': areaColor, - 'color': color - }); - }); - }; -}); -define('echarts/chart/map/mapDataStatistic',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - // FIXME 公用? - /** - * @param {Array.} datas - * @param {string} statisticsType 'average' 'sum' - * @inner - */ - function dataStatistics(datas, statisticsType) { - var dataNameMap = {}; - var dims = ['value']; - - for (var i = 0; i < datas.length; i++) { - datas[i].each(dims, function (value, idx) { - var name = datas[i].getName(idx); - dataNameMap[name] = dataNameMap[name] || []; - if (!isNaN(value)) { - dataNameMap[name].push(value); - } - }); - } - - return datas[0].map(dims, function (value, idx) { - var name = datas[0].getName(idx); - var sum = 0; - var min = Infinity; - var max = -Infinity; - var len = dataNameMap[name].length; - for (var i = 0; i < len; i++) { - min = Math.min(min, dataNameMap[name][i]); - max = Math.max(max, dataNameMap[name][i]); - sum += dataNameMap[name][i]; - } - var result; - if (statisticsType === 'min') { - result = min; - } - else if (statisticsType === 'max') { - result = max; - } - else if (statisticsType === 'average') { - result = sum / len; - } - else { - result = sum; - } - return len === 0 ? NaN : result; - }); - } - - return function (ecModel) { - var seriesGroupByMapType = {}; - ecModel.eachSeriesByType('map', function (seriesModel) { - var mapType = seriesModel.get('map'); - seriesGroupByMapType[mapType] = seriesGroupByMapType[mapType] || []; - seriesGroupByMapType[mapType].push(seriesModel); - }); - - zrUtil.each(seriesGroupByMapType, function (seriesList, mapType) { - var data = dataStatistics( - zrUtil.map(seriesList, function (seriesModel) { - return seriesModel.getData(); - }), - seriesList[0].get('mapValueCalculation') - ); - - seriesList[0].seriesGroup = []; - - seriesList[0].setData(data); - - // FIXME Put where? - for (var i = 0; i < seriesList.length; i++) { - seriesList[i].seriesGroup = seriesList; - seriesList[i].needsDrawMap = i === 0; - } - }); - }; -}); -define('echarts/chart/map/backwardCompat',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - var geoProps = [ - 'x', 'y', 'x2', 'y2', 'width', 'height', 'map', 'roam', 'roamDetail', 'label', 'itemStyle' - ]; - - var geoCoordsMap = {}; - - function createGeoFromMap(mapSeriesOpt) { - var geoOpt = {}; - zrUtil.each(geoProps, function (propName) { - if (mapSeriesOpt[propName] != null) { - geoOpt[propName] = mapSeriesOpt[propName]; - } - }); - return geoOpt; - } - return function (option) { - // Save geoCoord - var mapSeries = []; - zrUtil.each(option.series, function (seriesOpt) { - if (seriesOpt.type === 'map') { - mapSeries.push(seriesOpt); - } - zrUtil.extend(geoCoordsMap, seriesOpt.geoCoord); - }); - - var newCreatedGeoOptMap = {}; - zrUtil.each(mapSeries, function (seriesOpt) { - seriesOpt.map = seriesOpt.map || seriesOpt.mapType; - // Put x, y, width, height, x2, y2 in the top level - zrUtil.defaults(seriesOpt, seriesOpt.mapLocation); - if (seriesOpt.markPoint) { - var markPoint = seriesOpt.markPoint; - // Convert name or geoCoord in markPoint to lng and lat - // For example - // { name: 'xxx', value: 10} Or - // { geoCoord: [lng, lat], value: 10} to - // { name: 'xxx', value: [lng, lat, 10]} - markPoint.data = zrUtil.map(markPoint.data, function (dataOpt) { - if (!zrUtil.isArray(dataOpt.value)) { - var geoCoord; - if (dataOpt.geoCoord) { - geoCoord = dataOpt.geoCoord; - } - else if (dataOpt.name) { - geoCoord = geoCoordsMap[dataOpt.name]; - } - var newValue = geoCoord ? [geoCoord[0], geoCoord[1]] : [NaN, NaN]; - if (dataOpt.value != null) { - newValue.push(dataOpt.value); - } - dataOpt.value = newValue; - } - return dataOpt; - }); - // Convert map series which only has markPoint without data to scatter series - // FIXME - if (!(seriesOpt.data && seriesOpt.data.length)) { - if (!option.geo) { - option.geo = []; - } - - // Use same geo if multiple map series has same map type - var geoOpt = newCreatedGeoOptMap[seriesOpt.map]; - if (!geoOpt) { - geoOpt = newCreatedGeoOptMap[seriesOpt.map] = createGeoFromMap(seriesOpt); - option.geo.push(geoOpt); - } - - var scatterSeries = seriesOpt.markPoint; - scatterSeries.type = option.effect && option.effect.show ? 'effectScatter' : 'scatter'; - scatterSeries.coordinateSystem = 'geo'; - scatterSeries.geoIndex = zrUtil.indexOf(option.geo, geoOpt); - scatterSeries.name = seriesOpt.name; - - option.series.splice(zrUtil.indexOf(option.series, seriesOpt), 1, scatterSeries); - } - } - }); - }; -}); -define('echarts/chart/map',['require','../echarts','./map/MapSeries','./map/MapView','../action/geoRoam','../coord/geo/geoCreator','./map/mapSymbolLayout','./map/mapVisual','./map/mapDataStatistic','./map/backwardCompat','../action/createDataSelectAction'],function (require) { +/***/ }, +/* 246 */ +/***/ function(module, exports, __webpack_require__) { - var echarts = require('../echarts'); + - require('./map/MapSeries'); + var zrUtil = __webpack_require__(3); - require('./map/MapView'); + module.exports = function (option) { + if (!option || !zrUtil.isArray(option.series)) { + return; + } - require('../action/geoRoam'); + // Translate 'k' to 'candlestick'. + zrUtil.each(option.series, function (seriesItem) { + if (zrUtil.isObject(seriesItem) && seriesItem.type === 'k') { + seriesItem.type = 'candlestick'; + } + }); + }; - require('../coord/geo/geoCreator'); - echarts.registerLayout(require('./map/mapSymbolLayout')); - echarts.registerVisualCoding('chart', require('./map/mapVisual')); +/***/ }, +/* 247 */ +/***/ function(module, exports) { - echarts.registerProcessor('statistic', require('./map/mapDataStatistic')); + - echarts.registerPreprocessor(require('./map/backwardCompat')); + var positiveBorderColorQuery = ['itemStyle', 'normal', 'borderColor']; + var negativeBorderColorQuery = ['itemStyle', 'normal', 'borderColor0']; + var positiveColorQuery = ['itemStyle', 'normal', 'color']; + var negativeColorQuery = ['itemStyle', 'normal', 'color0']; - require('../action/createDataSelectAction')('map', [{ - type: 'mapToggleSelect', - event: 'mapselectchanged', - method: 'toggleSelected' - }, { - type: 'mapSelect', - event: 'mapselected', - method: 'select' - }, { - type: 'mapUnSelect', - event: 'mapunselected', - method: 'unSelect' - }]); -}); -/** - * Link list to graph or tree - */ -define('echarts/data/helper/linkList',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - var arraySlice = Array.prototype.slice; - - // Caution: - // In most case, only one of the list and its shallow clones (see list.cloneShallow) - // can be active in echarts process. Considering heap memory consumption, - // we do not clone tree or graph, but share them among list and its shallow clones. - // But in some rare case, we have to keep old list (like do animation in chart). So - // please take care that both the old list and the new list share the same tree/graph. - - function linkList(list, target, targetType) { - zrUtil.each(listProxyMethods, function (method, methodName) { - var originMethod = list[methodName]; - list[methodName] = zrUtil.curry(method, originMethod, target, targetType); - }); - - list[targetType] = target; - target.data = list; - - return list; - } - - var listProxyMethods = { - cloneShallow: function (originMethod, target, targetType) { - var newList = originMethod.apply(this, arraySlice.call(arguments, 3)); - return linkList(newList, target, targetType); - }, - map: function (originMethod, target, targetType) { - var newList = originMethod.apply(this, arraySlice.call(arguments, 3)); - return linkList(newList, target, targetType); - }, - filterSelf: function (originMethod, target, targetType) { - var result = originMethod.apply(this, arraySlice.call(arguments, 3)); - target.update(); - return result; - } - }; - - return { - linkToGraph: function (list, graph) { - linkList(list, graph, 'graph'); - }, - - linkToTree: function (list, tree) { - linkList(list, tree, 'tree'); - } - }; -}); -/** - * Tree data structure - * - * @module echarts/data/Tree - */ -define('echarts/data/Tree',['require','zrender/core/util','../model/Model','./List','./helper/linkList','./helper/completeDimensions'],function(require) { - - var zrUtil = require('zrender/core/util'); - var Model = require('../model/Model'); - var List = require('./List'); - var linkListHelper = require('./helper/linkList'); - var completeDimensions = require('./helper/completeDimensions'); - - /** - * @constructor module:echarts/data/Tree~TreeNode - * @param {string} name - * @param {number} [dataIndex=-1] - * @param {module:echarts/data/Tree} hostTree - */ - var TreeNode = function (name, dataIndex, hostTree) { - /** - * @type {string} - */ - this.name = name || ''; - - /** - * Depth of node - * - * @type {number} - * @readOnly - */ - this.depth = 0; - - /** - * Height of the subtree rooted at this node. - * @type {number} - * @readOnly - */ - this.height = 0; - - /** - * @type {module:echarts/data/Tree~TreeNode} - * @readOnly - */ - this.parentNode = null; - - /** - * Reference to list item. - * Do not persistent dataIndex outside, - * besause it may be changed by list. - * If dataIndex -1, - * this node is logical deleted (filtered) in list. - * - * @type {Object} - * @readOnly - */ - this.dataIndex = dataIndex == null ? -1 : dataIndex; - - /** - * @type {Array.} - * @readOnly - */ - this.children = []; - - /** - * @type {Array.} - * @pubilc - */ - this.viewChildren = []; - - /** - * @type {moduel:echarts/data/Tree} - * @readOnly - */ - this.hostTree = hostTree; - }; - - TreeNode.prototype = { - - constructor: TreeNode, - - /** - * The node is removed. - * @return {boolean} is removed. - */ - isRemoved: function () { - return this.dataIndex < 0; - }, - - /** - * Travel this subtree (include this node). - * Usage: - * node.eachNode(function () { ... }); // preorder - * node.eachNode('preorder', function () { ... }); // preorder - * node.eachNode('postorder', function () { ... }); // postorder - * node.eachNode( - * {order: 'postorder', attr: 'viewChildren'}, - * function () { ... } - * ); // postorder - * - * @param {(Object|string)} options If string, means order. - * @param {string=} options.order 'preorder' or 'postorder' - * @param {string=} options.attr 'children' or 'viewChildren' - * @param {Function} cb If in preorder and return false, - * its subtree will not be visited. - * @param {Object} [context] - */ - eachNode: function (options, cb, context) { - if (typeof options === 'function') { - context = cb; - cb = options; - options = null; - } - - options = options || {}; - if (zrUtil.isString(options)) { - options = {order: options}; - } - - var order = options.order || 'preorder'; - var children = this[options.attr || 'children']; - - var suppressVisitSub; - order === 'preorder' && (suppressVisitSub = cb.call(context, this)); - - for (var i = 0; !suppressVisitSub && i < children.length; i++) { - children[i].eachNode(options, cb, context); - } - - order === 'postorder' && cb.call(context, this); - }, - - /** - * Update depth and height of this subtree. - * - * @param {number} depth - */ - updateDepthAndHeight: function (depth) { - var height = 0; - this.depth = depth; - for (var i = 0; i < this.children.length; i++) { - var child = this.children[i]; - child.updateDepthAndHeight(depth + 1); - if (child.height > height) { - height = child.height; - } - } - this.height = height + 1; - }, - - /** - * @param {string} id - * @return {module:echarts/data/Tree~TreeNode} - */ - getNodeById: function (id) { - if (this.getId() === id) { - return this; - } - for (var i = 0, children = this.children, len = children.length; i < len; i++) { - var res = children[i].getNodeById(id); - if (res) { - return res; - } - } - }, - - /** - * @param {module:echarts/data/Tree~TreeNode} node - * @return {boolean} - */ - contains: function (node) { - if (node === this) { - return true; - } - for (var i = 0, children = this.children, len = children.length; i < len; i++) { - var res = children[i].contains(node); - if (res) { - return res; - } - } - }, - - /** - * @param {boolean} includeSelf Default false. - * @return {Array.} order: [root, child, grandchild, ...] - */ - getAncestors: function (includeSelf) { - var ancestors = []; - var node = includeSelf ? this : this.parentNode; - while (node) { - ancestors.push(node); - node = node.parentNode; - } - ancestors.reverse(); - return ancestors; - }, - - /** - * @param {string|Array=} [dimension='value'] Default 'value'. can be 0, 1, 2, 3 - * @return {number} Value. - */ - getValue: function (dimension) { - var data = this.hostTree.data; - return data.get(data.getDimension(dimension || 'value'), this.dataIndex); - }, - - /** - * @param {Object} layout - * @param {boolean=} [merge=false] - */ - setLayout: function (layout, merge) { - this.dataIndex >= 0 - && this.hostTree.data.setItemLayout(this.dataIndex, layout, merge); - }, - - /** - * @return {Object} layout - */ - getLayout: function () { - return this.hostTree.data.getItemLayout(this.dataIndex); - }, - - /** - * @param {string} path - * @return {module:echarts/model/Model} - */ - getModel: function (path) { - if (this.dataIndex < 0) { - return; - } - var hostTree = this.hostTree; - var itemModel = hostTree.data.getItemModel(this.dataIndex); - var levelModel = this.getLevelModel(); - - return itemModel.getModel(path, (levelModel || hostTree.hostModel).getModel(path)); - }, - - /** - * @return {module:echarts/model/Model} - */ - getLevelModel: function () { - return (this.hostTree.levelModels || [])[this.depth]; - }, - - /** - * @example - * setItemVisual('color', color); - * setItemVisual({ - * 'color': color - * }); - */ - setVisual: function (key, value) { - this.dataIndex >= 0 - && this.hostTree.data.setItemVisual(this.dataIndex, key, value); - }, - - /** - * @public - */ - getVisual: function (key, ignoreParent) { - return this.hostTree.data.getItemVisual(this.dataIndex, key, ignoreParent); - }, - - /** - * @public - * @return {number} - */ - getRawIndex: function () { - return this.hostTree.data.getRawIndex(this.dataIndex); - }, - - /** - * @public - * @return {string} - */ - getId: function () { - return this.hostTree.data.getId(this.dataIndex); - } - }; - - /** - * @constructor - * @alias module:echarts/data/Tree - * @param {module:echarts/model/Model} hostModel - * @param {Array.} levelOptions - */ - function Tree(hostModel, levelOptions) { - /** - * @type {module:echarts/data/Tree~TreeNode} - * @readOnly - */ - this.root; - - /** - * @type {module:echarts/data/List} - * @readOnly - */ - this.data; - - /** - * Index of each item is the same as the raw index of coresponding list item. - * @private - * @type {Array.} levelOptions - * @return module:echarts/data/Tree - */ - Tree.createTree = function (dataRoot, hostModel, levelOptions) { - - var tree = new Tree(hostModel, levelOptions); - var listData = []; - - buildHierarchy(dataRoot); - - function buildHierarchy(dataNode, parentNode) { - listData.push(dataNode); - - var node = new TreeNode(dataNode.name, listData.length - 1, tree); - parentNode - ? addChild(node, parentNode) - : (tree.root = node); - - var children = dataNode.children; - if (children) { - for (var i = 0; i < children.length; i++) { - buildHierarchy(children[i], node); - } - } - } - - tree.root.updateDepthAndHeight(0); - - var dimensions = completeDimensions([{name: 'value'}], listData); - var list = new List(dimensions, hostModel); - list.initData(listData); - - linkListHelper.linkToTree(list, tree); - - return tree; - }; - - /** - * It is needed to consider the mess of 'list', 'hostModel' when creating a TreeNote, - * so this function is not ready and not necessary to be public. - * - * @param {(module:echarts/data/Tree~TreeNode|Object)} child - */ - function addChild(child, node) { - var children = node.children; - if (child.parentNode === node) { - return; - } - - children.push(child); - child.parentNode = node; - - node.hostTree._nodes.push(child); - } - - return Tree; -}); -define('echarts/chart/treemap/TreemapSeries',['require','../../model/Series','../../data/Tree','zrender/core/util','../../model/Model','../../util/format'],function(require) { - - var SeriesModel = require('../../model/Series'); - var Tree = require('../../data/Tree'); - var zrUtil = require('zrender/core/util'); - var Model = require('../../model/Model'); - var formatUtil = require('../../util/format'); - var encodeHTML = formatUtil.encodeHTML; - var addCommas = formatUtil.addCommas; - - - return SeriesModel.extend({ - - type: 'series.treemap', - - dependencies: ['grid', 'polar'], - - defaultOption: { - // center: ['50%', '50%'], // not supported in ec3. - // size: ['80%', '80%'], // deprecated, compatible with ec2. - left: 'center', - top: 'middle', - right: null, - bottom: null, - width: '80%', - height: '80%', - sort: true, // Can be null or false or true - // (order by desc default, asc not supported yet (strange effect)) - clipWindow: 'origin', // 缩放时窗口大小。'origin' or 'fullscreen' - squareRatio: 0.5 * (1 + Math.sqrt(5)), // golden ratio - root: null, // default: tree root. This feature doesnt work unless node have id. - visualDimension: 0, // Can be 0, 1, 2, 3. - zoomToNodeRatio: 0.32 * 0.32, // zoom to node时 node占可视区域的面积比例。 - roam: true, // true, false, 'scale' or 'zoom', 'move' - nodeClick: 'zoomToNode', // 'zoomToNode', 'link', false - animation: true, - animationDurationUpdate: 1500, - animationEasing: 'quinticInOut', - breadcrumb: { - show: true, - height: 22, - left: 'center', - top: 'bottom', - // right - // bottom - emptyItemWidth: 25, // 空节点宽度 - itemStyle: { - normal: { - color: 'rgba(0,0,0,0.7)', //'#5793f3', - borderColor: 'rgba(255,255,255,0.7)', - borderWidth: 1, - shadowColor: 'rgba(150,150,150,1)', - shadowBlur: 3, - shadowOffsetX: 0, - shadowOffsetY: 0, - textStyle: { - color: '#fff' - } - }, - emphasis: { - textStyle: {} - } - } - }, - label: { - normal: { - show: true, - position: ['50%', '50%'], // 可以是 5 '5%' 'insideTopLeft', ... - textStyle: { - align: 'center', - baseline: 'middle', - color: '#fff', - ellipsis: true - } - } - }, - itemStyle: { - normal: { - color: null, // 各异 如不需,可设为'none' - colorAlpha: null, // 默认不设置 如不需,可设为'none' - colorSaturation: null, // 默认不设置 如不需,可设为'none' - borderWidth: 0, - gapWidth: 0, - borderColor: '#fff', - borderColorSaturation: null // 如果设置,则borderColor的设置无效,而是取当前节点计算出的颜色,再经由borderColorSaturation处理。 - }, - emphasis: {} - }, - color: 'none', // 为数组,表示同一level的color 选取列表。默认空,在level[0].color中取系统color列表。 - colorAlpha: null, // 为数组,表示同一level的color alpha 选取范围。 - colorSaturation: null, // 为数组,表示同一level的color alpha 选取范围。 - colorMappingBy: 'index', // 'value' or 'index' or 'id'. - visibleMin: 10, // If area less than this threshold (unit: pixel^2), node will not be rendered. - // Only works when sort is 'asc' or 'desc'. - childrenVisibleMin: null, // If area of a node less than this threshold (unit: pixel^2), - // grandchildren will not show. - // Why grandchildren? If not grandchildren but children, - // some siblings show children and some not, - // the appearance may be mess and not consistent, - levels: [] // Each item: { - // visibleMin, itemStyle, visualDimension, label - // } - // data: { - // value: [], - // children: [], - // link: 'http://xxx.xxx.xxx', - // target: 'blank' or 'self' - // } - }, - - /** - * @override - */ - getInitialData: function (option, ecModel) { - var data = option.data || []; - var rootName = option.name; - rootName == null && (rootName = option.name); - - // Create a virtual root. - var root = {name: rootName, children: option.data}; - var value0 = (data[0] || {}).value; - - completeTreeValue(root, zrUtil.isArray(value0) ? value0.length : -1); - - // FIXME - // sereis.mergeOption 的 getInitData是否放在merge后,从而能直接获取merege后的结果而非手动判断。 - var levels = option.levels || []; - - levels = option.levels = setDefault(levels, ecModel); - - // Make sure always a new tree is created when setOption, - // in TreemapView, we check whether oldTree === newTree - // to choose mappings approach among old shapes and new shapes. - return Tree.createTree(root, this, levels).data; - }, - - /** - * @public - */ - getViewRoot: function () { - var optionRoot = this.option.root; - var treeRoot = this.getData().tree.root; - return optionRoot && treeRoot.getNodeById(optionRoot) || treeRoot; - }, - - /** - * @override - * @param {number} dataIndex - * @param {boolean} [mutipleSeries=false] - */ - formatTooltip: function (dataIndex) { - var data = this.getData(); - var value = this.getRawValue(dataIndex); - var formattedValue = zrUtil.isArray(value) - ? addCommas(value[0]) : addCommas(value); - var name = data.getName(dataIndex); - - return encodeHTML(name) + ': ' + formattedValue; - }, - - /** - * Add tree path to tooltip param - * - * @override - * @param {number} dataIndex - * @return {Object} - */ - getDataParams: function (dataIndex) { - var params = SeriesModel.prototype.getDataParams.apply(this, arguments); - - var data = this.getData(); - var node = data.tree.getNodeByDataIndex(dataIndex); - var treePathInfo = params.treePathInfo = []; - - while (node) { - var nodeDataIndex = node.dataIndex; - treePathInfo.push({ - name: node.name, - dataIndex: nodeDataIndex, - value: this.getRawValue(nodeDataIndex) - }); - node = node.parentNode; - } - - treePathInfo.reverse(); - - return params; - }, - - /** - * @public - * @param {Object} layoutInfo { - * x: containerGroup x - * y: containerGroup y - * width: containerGroup width - * height: containerGroup height - * } - */ - setLayoutInfo: function (layoutInfo) { - /** - * @readOnly - * @type {Object} - */ - this.layoutInfo = this.layoutInfo || {}; - zrUtil.extend(this.layoutInfo, layoutInfo); - }, - - /** - * @param {string} id - * @return {number} index - */ - mapIdToIndex: function (id) { - // A feature is implemented: - // index is monotone increasing with the sequence of - // input id at the first time. - // This feature can make sure that each data item and its - // mapped color have the same index between data list and - // color list at the beginning, which is useful for user - // to adjust data-color mapping. - - /** - * @private - * @type {Object} - */ - var idIndexMap = this._idIndexMap; - - if (!idIndexMap) { - idIndexMap = this._idIndexMap = {}; - /** - * @private - * @type {number} - */ - this._idIndexMapCount = 0; - } - - var index = idIndexMap[id]; - if (index == null) { - idIndexMap[id] = index = this._idIndexMapCount++; - } - - return index; - } - }); - - /** - * @param {Object} dataNode - */ - function completeTreeValue(dataNode, arrValueLength) { - // Postorder travel tree. - // If value of none-leaf node is not set, - // calculate it by suming up the value of all children. - var sum = 0; - - zrUtil.each(dataNode.children, function (child) { - - completeTreeValue(child, arrValueLength); - - var childValue = child.value; - zrUtil.isArray(childValue) && (childValue = childValue[0]); - - sum += childValue; - }); - - var thisValue = dataNode.value; - - if (arrValueLength >= 0) { - if (!zrUtil.isArray(thisValue)) { - dataNode.value = new Array(arrValueLength); - } - else { - thisValue = thisValue[0]; - } - } - - if (thisValue == null || isNaN(thisValue)) { - thisValue = sum; - } - // Value should not less than 0. - if (thisValue < 0) { - thisValue = 0; - } - - arrValueLength >= 0 - ? (dataNode.value[0] = thisValue) - : (dataNode.value = thisValue); - } - - /** - * set default to level configuration - */ - function setDefault(levels, ecModel) { - var globalColorList = ecModel.get('color'); - - if (!globalColorList) { - return; - } - - levels = levels || []; - var hasColorDefine; - zrUtil.each(levels, function (levelDefine) { - var model = new Model(levelDefine); - var modelColor = model.get('color'); - if (model.get('itemStyle.normal.color') - || (modelColor && modelColor !== 'none') - ) { - hasColorDefine = true; - } - }); - - if (!hasColorDefine) { - var level0 = levels[0] || (levels[0] = {}); - level0.color = globalColorList.slice(); - } - - return levels; - } + module.exports = function (ecModel, api) { -}); -define('echarts/chart/treemap/helper',['require'],function (require) { + ecModel.eachRawSeriesByType('candlestick', function (seriesModel) { - var helper = { + var data = seriesModel.getData(); - retrieveTargetInfo: function (payload, seriesModel) { - if (!payload || payload.type !== 'treemapZoomToNode') { - return; - } + data.setVisual({ + legendSymbol: 'roundRect' + }); - var root = seriesModel.getData().tree.root; - var targetNode = payload.targetNode; - if (targetNode && root.contains(targetNode)) { - return {node: targetNode}; - } + // Only visible series has each data be visual encoded + if (!ecModel.isSeriesFiltered(seriesModel)) { + data.each(function (idx) { + var itemModel = data.getItemModel(idx); + var sign = data.getItemLayout(idx).sign; - var targetNodeId = payload.targetNodeId; - if (targetNodeId != null && (targetNode = root.getNodeById(targetNodeId))) { - return {node: targetNode}; - } + data.setItemVisual( + idx, + { + color: itemModel.get( + sign > 0 ? positiveColorQuery : negativeColorQuery + ), + borderColor: itemModel.get( + sign > 0 ? positiveBorderColorQuery : negativeBorderColorQuery + ) + } + ); + }); + } + }); + + }; + + +/***/ }, +/* 248 */ +/***/ function(module, exports) { + + + + var CANDLE_MIN_WIDTH = 2; + var CANDLE_MIN_NICE_WIDTH = 5; + var GPA_MIN = 4; + + module.exports = function (ecModel, api) { - return null; - } + ecModel.eachSeriesByType('candlestick', function (seriesModel) { - }; + var coordSys = seriesModel.coordinateSystem; + var data = seriesModel.getData(); + var dimensions = seriesModel.dimensions; + var chartLayout = seriesModel.get('layout'); - return helper; -}); - define('echarts/chart/treemap/Breadcrumb',['require','../../util/graphic','../../util/layout','zrender/core/util'],function(require) { - - var graphic = require('../../util/graphic'); - var layout = require('../../util/layout'); - var zrUtil = require('zrender/core/util'); - - var TEXT_PADDING = 8; - var ITEM_GAP = 8; - var ARRAY_LENGTH = 5; - - function Breadcrumb(containerGroup, onSelect) { - /** - * @private - * @type {module:zrender/container/Group} - */ - this.group = new graphic.Group(); - - containerGroup.add(this.group); - - /** - * @private - * @type {Function} - */ - this._onSelect = onSelect || zrUtil.noop; - } - - Breadcrumb.prototype = { - - constructor: Breadcrumb, - - render: function (seriesModel, api, targetNode) { - var model = seriesModel.getModel('breadcrumb'); - var thisGroup = this.group; - - thisGroup.removeAll(); - - if (!model.get('show') || !targetNode) { - return; - } - - var normalStyleModel = model.getModel('itemStyle.normal'); - // var emphasisStyleModel = model.getModel('itemStyle.emphasis'); - var textStyleModel = normalStyleModel.getModel('textStyle'); - - var layoutParam = { - pos: { - left: model.get('left'), - right: model.get('right'), - top: model.get('top'), - bottom: model.get('bottom') - }, - box: { - width: api.getWidth(), - height: api.getHeight() - }, - emptyItemWidth: model.get('emptyItemWidth'), - totalWidth: 0, - renderList: [] - }; - - this._prepare( - model, targetNode, layoutParam, textStyleModel - ); - this._renderContent( - model, targetNode, layoutParam, normalStyleModel, textStyleModel - ); - - layout.positionGroup(thisGroup, layoutParam.pos, layoutParam.box); - }, - - /** - * Prepare render list and total width - * @private - */ - _prepare: function (model, targetNode, layoutParam, textStyleModel) { - for (var node = targetNode; node; node = node.parentNode) { - var text = node.getModel().get('name'); - var textRect = textStyleModel.getTextRect(text); - var itemWidth = Math.max( - textRect.width + TEXT_PADDING * 2, - layoutParam.emptyItemWidth - ); - layoutParam.totalWidth += itemWidth + ITEM_GAP; - layoutParam.renderList.push({node: node, text: text, width: itemWidth}); - } - }, - - /** - * @private - */ - _renderContent: function ( - model, targetNode, layoutParam, normalStyleModel, textStyleModel - ) { - // Start rendering. - var lastX = 0; - var emptyItemWidth = layoutParam.emptyItemWidth; - var height = model.get('height'); - var availableSize = layout.getAvailableSize(layoutParam.pos, layoutParam.box); - var totalWidth = layoutParam.totalWidth; - var renderList = layoutParam.renderList; - - for (var i = renderList.length - 1; i >= 0; i--) { - var item = renderList[i]; - var itemWidth = item.width; - var text = item.text; - - // Hdie text and shorten width if necessary. - if (totalWidth > availableSize.width) { - totalWidth -= itemWidth - emptyItemWidth; - itemWidth = emptyItemWidth; - text = ''; - } - - this.group.add(new graphic.Polygon({ - shape: { - points: makeItemPoints( - lastX, 0, itemWidth, height, - i === renderList.length - 1, i === 0 - ) - }, - style: zrUtil.defaults( - normalStyleModel.getItemStyle(), - { - lineJoin: 'bevel', - text: text, - textFill: textStyleModel.getTextColor(), - textFont: textStyleModel.getFont() - } - ), - onclick: zrUtil.bind(this._onSelect, this, item.node) - })); - - lastX += itemWidth + ITEM_GAP; - } - }, - - /** - * @override - */ - remove: function () { - this.group.removeAll(); - } - }; - - function makeItemPoints(x, y, itemWidth, itemHeight, head, tail) { - var points = [ - [head ? x : x - ARRAY_LENGTH, y], - [x + itemWidth, y], - [x + itemWidth, y + itemHeight], - [head ? x : x - ARRAY_LENGTH, y + itemHeight] - ]; - !tail && points.splice(2, 0, [x + itemWidth + ARRAY_LENGTH, y + itemHeight / 2]); - !head && points.push([x, y + itemHeight / 2]); - return points; - } - - return Breadcrumb; -}); - define('echarts/util/animation',['require','zrender/core/util'],function(require) { - - var zrUtil = require('zrender/core/util'); - - /** - * @param {number} [time=500] Time in ms - * @param {string} [easing='linear'] - * @param {number} [delay=0] - * @param {Function} [callback] - * - * @example - * // Animate position - * animation - * .createWrap() - * .add(el1, {position: [10, 10]}) - * .add(el2, {shape: {width: 500}, style: {fill: 'red'}}, 400) - * .done(function () { // done }) - * .start('cubicOut'); - */ - function createWrap() { - - var storage = []; - var elExistsMap = {}; - var doneCallback; - - return { - - /** - * Caution: a el can only be added once, otherwise 'done' - * might not be called. This method checks this (by el.id), - * suppresses adding and returns false when existing el found. - * - * @param {modele:zrender/Element} el - * @param {Object} target - * @param {number} [time=500] - * @param {number} [delay=0] - * @param {string} [easing='linear'] - * @return {boolean} Whether adding succeeded. - * - * @example - * add(el, target, time, delay, easing); - * add(el, target, time, easing); - * add(el, target, time); - * add(el, target); - */ - add: function (el, target, time, delay, easing) { - if (zrUtil.isString(delay)) { - easing = delay; - delay = 0; - } - - if (elExistsMap[el.id]) { - return false; - } - elExistsMap[el.id] = 1; - - storage.push( - {el: el, target: target, time: time, delay: delay, easing: easing} - ); - - return true; - }, - - /** - * Only execute when animation finished. Will not execute when any - * of 'stop' or 'stopAnimation' called. - * - * @param {Function} callback - */ - done: function (callback) { - doneCallback = callback; - return this; - }, - - /** - * Will stop exist animation firstly. - */ - start: function () { - var count = storage.length; - - for (var i = 0, len = storage.length; i < len; i++) { - var item = storage[i]; - item.el.animateTo(item.target, item.time, item.delay, item.easing, done); - } - - return this; - - function done() { - count--; - if (!count) { - storage.length = 0; - elExistsMap = {}; - doneCallback && doneCallback(); - } - } - } - }; - } - - return {createWrap: createWrap}; -}); - define('echarts/chart/treemap/TreemapView',['require','zrender/core/util','../../util/graphic','../../data/DataDiffer','./helper','./Breadcrumb','../../component/helper/RoamController','zrender/core/BoundingRect','zrender/core/matrix','../../util/animation','../../echarts'],function(require) { - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var DataDiffer = require('../../data/DataDiffer'); - var helper = require('./helper'); - var Breadcrumb = require('./Breadcrumb'); - var RoamController = require('../../component/helper/RoamController'); - var BoundingRect = require('zrender/core/BoundingRect'); - var matrix = require('zrender/core/matrix'); - var animationUtil = require('../../util/animation'); - var bind = zrUtil.bind; - var Group = graphic.Group; - var Rect = graphic.Rect; - var each = zrUtil.each; - - var DRAG_THRESHOLD = 3; - - return require('../../echarts').extendChartView({ - - type: 'treemap', - - /** - * @override - */ - init: function (o, api) { - - /** - * @private - * @type {module:zrender/container/Group} - */ - this._containerGroup; - - /** - * @private - * @type {Object.>} - */ - this._storage = createStorage(); - - /** - * @private - * @type {module:echarts/data/Tree} - */ - this._oldTree; - - /** - * @private - * @type {module:echarts/chart/treemap/Breadcrumb} - */ - this._breadcrumb; - - /** - * @private - * @type {module:echarts/component/helper/RoamController} - */ - this._controller; - - /** - * 'ready', 'animating' - * @private - */ - this._state = 'ready'; - - /** - * @private - * @type {boolean} - */ - this._mayClick; - }, - - /** - * @override - */ - render: function (seriesModel, ecModel, api, payload) { - - var models = ecModel.findComponents({ - mainType: 'series', subType: 'treemap', query: payload - }); - if (zrUtil.indexOf(models, seriesModel) < 0) { - return; - } - - this.seriesModel = seriesModel; - this.api = api; - this.ecModel = ecModel; - - var payloadType = payload && payload.type; - var layoutInfo = seriesModel.layoutInfo; - var isInit = !this._oldTree; - - var containerGroup = this._giveContainerGroup(layoutInfo); - - var renderResult = this._doRender(containerGroup, seriesModel); - - (!isInit && (!payloadType || payloadType === 'treemapZoomToNode')) - ? this._doAnimation(containerGroup, renderResult, seriesModel) - : renderResult.renderFinally(); - - this._resetController(api); - - var targetInfo = helper.retrieveTargetInfo(payload, seriesModel); - this._renderBreadcrumb(seriesModel, api, targetInfo); - }, - - /** - * @private - */ - _giveContainerGroup: function (layoutInfo) { - var containerGroup = this._containerGroup; - if (!containerGroup) { - // FIXME - // 加一层containerGroup是为了clip,但是现在clip功能并没有实现。 - containerGroup = this._containerGroup = new Group(); - this._initEvents(containerGroup); - this.group.add(containerGroup); - } - containerGroup.position = [layoutInfo.x, layoutInfo.y]; - - return containerGroup; - }, - - /** - * @private - */ - _doRender: function (containerGroup, seriesModel) { - var thisTree = seriesModel.getData().tree; - var oldTree = this._oldTree; - - // Clear last shape records. - var lastsForAnimation = createStorage(); - var thisStorage = createStorage(); - var oldStorage = this._storage; - var willInvisibleEls = []; - var willVisibleEls = []; - var willDeleteEls = []; - var renderNode = bind( - this._renderNode, this, - thisStorage, oldStorage, lastsForAnimation, willInvisibleEls, willVisibleEls - ); - var viewRoot = seriesModel.getViewRoot(); - - // Notice: when thisTree and oldTree are the same tree (see list.cloneShadow), - // the oldTree is actually losted, so we can not find all of the old graphic - // elements from tree. So we use this stragegy: make element storage, move - // from old storage to new storage, clear old storage. - - dualTravel( - thisTree.root ? [thisTree.root] : [], - (oldTree && oldTree.root) ? [oldTree.root] : [], - containerGroup, - thisTree === oldTree || !oldTree, - viewRoot === thisTree.root - ); - - // Process all removing. - var willDeleteEls = clearStorage(oldStorage); - - this._oldTree = thisTree; - this._storage = thisStorage; - - return { - lastsForAnimation: lastsForAnimation, - willDeleteEls: willDeleteEls, - renderFinally: renderFinally - }; - - function dualTravel(thisViewChildren, oldViewChildren, parentGroup, sameTree, inView) { - // When 'render' is triggered by action, - // 'this' and 'old' may be the same tree, - // we use rawIndex in that case. - if (sameTree) { - oldViewChildren = thisViewChildren; - each(thisViewChildren, function (child, index) { - !child.isRemoved() && processNode(index, index); - }); - } - // Diff hierarchically (diff only in each subtree, but not whole). - // because, consistency of view is important. - else { - (new DataDiffer(oldViewChildren, thisViewChildren, getKey, getKey)) - .add(processNode) - .update(processNode) - .remove(zrUtil.curry(processNode, null)) - .execute(); - } - - function getKey(node) { - // Identify by name or raw index. - return node.getId(); - } - - function processNode(newIndex, oldIndex) { - var thisNode = newIndex != null ? thisViewChildren[newIndex] : null; - var oldNode = oldIndex != null ? oldViewChildren[oldIndex] : null; - - // Whether under viewRoot. - var subInView = inView || thisNode === viewRoot; - // If not under viewRoot, only remove. - if (!subInView) { - thisNode = null; - } - - var group = renderNode(thisNode, oldNode, parentGroup); - - group && dualTravel( - thisNode && thisNode.viewChildren || [], - oldNode && oldNode.viewChildren || [], - group, - sameTree, - subInView - ); - } - } - - function clearStorage(storage) { - var willDeleteEls = createStorage(); - storage && each(storage, function (store, storageName) { - var delEls = willDeleteEls[storageName]; - each(store, function (el) { - el && (delEls.push(el), el.__tmWillDelete = storageName); - }); - }); - return willDeleteEls; - } - - function renderFinally() { - each(willDeleteEls, function (els) { - each(els, function (el) { - el.parent && el.parent.remove(el); - }); - }); - // Theoritically there is no intersection between willInvisibleEls - // and willVisibleEls have, but we set visible after for robustness. - each(willInvisibleEls, function (el) { - el.invisible = true; - // Setting invisible is for optimizing, so no need to set dirty, - // just mark as invisible. - }); - each(willVisibleEls, function (el) { - el.invisible = false; - el.__tmWillVisible = false; - el.dirty(); - }); - } - }, - - /** - * @private - */ - _renderNode: function ( - thisStorage, oldStorage, lastsForAnimation, - willInvisibleEls, willVisibleEls, - thisNode, oldNode, parentGroup - ) { - var thisRawIndex = thisNode && thisNode.getRawIndex(); - var oldRawIndex = oldNode && oldNode.getRawIndex(); - - // Deleting things will performed finally. This method just find element from - // old storage, or create new element, set them to new storage, and set styles. - if (!thisNode) { - return; - } - - var layout = thisNode.getLayout(); - var thisWidth = layout.width; - var thisHeight = layout.height; - var invisible = layout.invisible; - - // Node group - var group = giveGraphic('nodeGroup', Group); - if (!group) { - return; - } - parentGroup.add(group); - group.position = [layout.x, layout.y]; - group.__tmNodeWidth = thisWidth; - group.__tmNodeHeight = thisHeight; - - // Background - var bg = giveGraphic('background', Rect); - if (bg) { - bg.setShape({x: 0, y: 0, width: thisWidth, height: thisHeight}); - updateStyle(bg, {fill: thisNode.getVisual('borderColor', true)}); - group.add(bg); - } - - var thisViewChildren = thisNode.viewChildren; - - // No children, render content. - if (!thisViewChildren || !thisViewChildren.length) { - var borderWidth = layout.borderWidth; - var content = giveGraphic('content', Rect); - - if (content) { - var contentWidth = Math.max(thisWidth - 2 * borderWidth, 0); - var contentHeight = Math.max(thisHeight - 2 * borderWidth, 0); - var labelModel = thisNode.getModel('label.normal'); - var textStyleModel = thisNode.getModel('label.normal.textStyle'); - var text = thisNode.getModel().get('name'); - var textRect = textStyleModel.getTextRect(text); - var showLabel = labelModel.get('show'); - - if (!showLabel || textRect.height > contentHeight) { - text = ''; - } - else if (textRect.width > contentWidth) { - text = textStyleModel.get('ellipsis') - ? textStyleModel.ellipsis(text, contentWidth) : ''; - } - - // For tooltip. - content.dataIndex = thisNode.dataIndex; - content.seriesIndex = this.seriesModel.seriesIndex; - - content.culling = true; - content.setShape({ - x: borderWidth, - y: borderWidth, - width: contentWidth, - height: contentHeight - }); - updateStyle(content, { - fill: thisNode.getVisual('color', true), - text: text, - textPosition: labelModel.get('position'), - textFill: textStyleModel.getTextColor(), - textAlign: textStyleModel.get('align'), - textBaseline: textStyleModel.get('baseline'), - textFont: textStyleModel.getFont() - }); - group.add(content); - } - } - - return group; - - function giveGraphic(storageName, Ctor) { - var element = oldRawIndex != null && oldStorage[storageName][oldRawIndex]; - var lasts = lastsForAnimation[storageName]; - - if (element) { - // Remove from oldStorage - oldStorage[storageName][oldRawIndex] = null; - prepareAnimationWhenHasOld(lasts, element, storageName); - } - // If invisible and no old element, do not create new element (for optimizing). - else if (!invisible) { - element = new Ctor(); - prepareAnimationWhenNoOld(lasts, element, storageName); - } - - // Set to thisStorage - return (thisStorage[storageName][thisRawIndex] = element); - } - - function prepareAnimationWhenHasOld(lasts, element, storageName) { - var lastCfg = lasts[thisRawIndex] = {}; - lastCfg.old = storageName === 'nodeGroup' - ? element.position.slice() - : zrUtil.extend({}, element.shape); - } - - // If a element is new, we need to find the animation start point carefully, - // otherwise it will looks strange when 'zoomToNode'. - function prepareAnimationWhenNoOld(lasts, element, storageName) { - // New background do not animate but delay show. - if (storageName === 'background') { - element.invisible = true; - element.__tmWillVisible = true; - willVisibleEls.push(element); - } - else { - var parentNode = thisNode.parentNode; - var parentOldBg; - var parentOldX = 0; - var parentOldY = 0; - // For convenient, get old bounding rect from background. - if (parentNode && ( - parentOldBg = lastsForAnimation.background[parentNode.getRawIndex()] - )) { - parentOldX = parentOldBg.old.width; - parentOldY = parentOldBg.old.height; - } - // When no parent old shape found, its parent is new too, - // so we can just use {x:0, y:0}. - var lastCfg = lasts[thisRawIndex] = {}; - lastCfg.old = storageName === 'nodeGroup' - ? [parentOldX, parentOldY] - : {x: parentOldX, y: parentOldY, width: 0, height: 0}; - - // Fade in, user can be aware that these nodes are new. - lastCfg.fadein = storageName !== 'nodeGroup'; - } - } - - function updateStyle(element, style) { - if (!invisible) { - // If invisible, do not set visual, otherwise the element will - // change immediately before animation. We think it is OK to - // remain its origin color when moving out of the view window. - element.setStyle(style); - if (!element.__tmWillVisible) { - element.invisible = false; - } - } - else { - // Delay invisible setting utill animation finished, - // avoid element vanish suddenly before animation. - !element.invisible && willInvisibleEls.push(element); - } - } - }, - - /** - * @private - */ - _doAnimation: function (containerGroup, renderResult, seriesModel) { - if (!seriesModel.get('animation')) { - return; - } - - var duration = seriesModel.get('animationDurationUpdate'); - var easing = seriesModel.get('animationEasing'); - - var animationWrap = animationUtil.createWrap(); - - // Make delete animations. - var viewRoot = this.seriesModel.getViewRoot(); - var rootGroup = this._storage.nodeGroup[viewRoot.getRawIndex()]; - rootGroup && rootGroup.traverse(function (el) { - var storageName; - if (el.invisible || !(storageName = el.__tmWillDelete)) { - return; - } - var targetX = 0; - var targetY = 0; - var parent = el.parent; // Always has parent, and parent is nodeGroup. - if (!parent.__tmWillDelete) { - // Let node animate to right-bottom corner, cooperating with fadeout, - // which is perfect for user understanding. - targetX = parent.__tmNodeWidth; - targetY = parent.__tmNodeHeight; - } - var target = storageName === 'nodeGroup' - ? {position: [targetX, targetY], style: {opacity: 0}} - : {shape: {x: targetX, y: targetY, width: 0, height: 0}, style: {opacity: 0}}; - animationWrap.add(el, target, duration, easing); - }); - - // Make other animations - each(this._storage, function (store, storageName) { - each(store, function (el, rawIndex) { - var last = renderResult.lastsForAnimation[storageName][rawIndex]; - var target; - - if (!last) { - return; - } - - if (storageName === 'nodeGroup') { - target = {position: el.position.slice()}; - el.position = last.old; - } - else { - target = {shape: zrUtil.extend({}, el.shape)}; - el.setShape(last.old); - - if (last.fadein) { - el.setStyle('opacity', 0); - target.style = {opacity: 1}; - } - // When animation is stopped for succedent animation starting, - // el.style.opacity might not be 1 - else if (el.style.opacity !== 1) { - target.style = {opacity: 1}; - } - } - animationWrap.add(el, target, duration, easing); - }); - }, this); - - this._state = 'animating'; - - animationWrap - .done(bind(function () { - this._state = 'ready'; - renderResult.renderFinally(); - }, this)) - .start(); - }, - - /** - * @private - */ - _resetController: function (api) { - var controller = this._controller; - - // Init controller. - if (!controller) { - controller = this._controller = new RoamController(api.getZr()); - controller.enable(this.seriesModel.get('roam')); - controller.on('pan', bind(this._onPan, this)); - controller.on('zoom', bind(this._onZoom, this)); - } - - controller.rect = new BoundingRect(0, 0, api.getWidth(), api.getHeight()); - }, - - /** - * @private - */ - _clearController: function () { - var controller = this._controller; - if (controller) { - controller.off('pan').off('zoom'); - controller = null; - } - }, - - /** - * @private - */ - _onPan: function (dx, dy) { - this._mayClick = false; - - if (this._state !== 'animating' - && (Math.abs(dx) > DRAG_THRESHOLD || Math.abs(dy) > DRAG_THRESHOLD) - ) { - // These param must not be cached. - var viewRoot = this.seriesModel.getViewRoot(); - - if (!viewRoot) { - return; - } - - var rootLayout = viewRoot.getLayout(); - - if (!rootLayout) { - return; - } - - this.api.dispatchAction({ - type: 'treemapMove', - from: this.uid, - seriesId: this.seriesModel.id, - rootRect: { - x: rootLayout.x + dx, y: rootLayout.y + dy, - width: rootLayout.width, height: rootLayout.height - } - }); - } - }, - - /** - * @private - */ - _onZoom: function (scale, mouseX, mouseY) { - this._mayClick = false; - - if (this._state !== 'animating') { - // These param must not be cached. - var viewRoot = this.seriesModel.getViewRoot(); - - if (!viewRoot) { - return; - } - - var rootLayout = viewRoot.getLayout(); - - if (!rootLayout) { - return; - } - - var rect = new BoundingRect( - rootLayout.x, rootLayout.y, rootLayout.width, rootLayout.height - ); - var layoutInfo = this.seriesModel.layoutInfo; - - // Transform mouse coord from global to containerGroup. - mouseX -= layoutInfo.x; - mouseY -= layoutInfo.y; - - // Scale root bounding rect. - var m = matrix.create(); - matrix.translate(m, m, [-mouseX, -mouseY]); - matrix.scale(m, m, [scale, scale]); - matrix.translate(m, m, [mouseX, mouseY]); - - rect.applyTransform(m); - - this.api.dispatchAction({ - type: 'treemapRender', - from: this.uid, - seriesId: this.seriesModel.id, - rootRect: { - x: rect.x, y: rect.y, - width: rect.width, height: rect.height - } - }); - } - }, - - /** - * @private - */ - _initEvents: function (containerGroup) { - // FIXME - // 不用click以及silent的原因是,animate时视图设置silent true来避免click生效, - // 但是animate中,按下鼠标,animate结束后(silent设回为false)松开鼠标, - // 还是会触发click,期望是不触发。 - - // Mousedown occurs when drag start, and mouseup occurs when drag end, - // click event should not be triggered in that case. - - containerGroup.on('mousedown', function (e) { - this._state === 'ready' && (this._mayClick = true); - }, this); - containerGroup.on('mouseup', function (e) { - if (this._mayClick) { - this._mayClick = false; - this._state === 'ready' && onClick.call(this, e); - } - }, this); - - function onClick(e) { - var nodeClick = this.seriesModel.get('nodeClick', true); - - if (!nodeClick) { - return; - } - - var targetInfo = this.findTarget(e.offsetX, e.offsetY); - - if (targetInfo) { - if (nodeClick === 'zoomToNode') { - this._zoomToNode(targetInfo); - } - else if (nodeClick === 'link') { - var node = targetInfo.node; - var itemModel = node.hostTree.data.getItemModel(node.dataIndex); - var link = itemModel.get('link', true); - var linkTarget = itemModel.get('target', true) || 'blank'; - link && window.open(link, linkTarget); - } - } - } - }, - - /** - * @private - */ - _renderBreadcrumb: function (seriesModel, api, targetInfo) { - if (!targetInfo) { - // Find breadcrumb tail on center of containerGroup. - targetInfo = this.findTarget(api.getWidth() / 2, api.getHeight() / 2); - - if (!targetInfo) { - targetInfo = {node: seriesModel.getData().tree.root}; - } - } - - (this._breadcrumb || (this._breadcrumb = new Breadcrumb(this.group, bind(onSelect, this)))) - .render(seriesModel, api, targetInfo.node); - - function onSelect(node) { - this._zoomToNode({node: node}); - } - }, - - /** - * @override - */ - remove: function () { - this._clearController(); - this._containerGroup && this._containerGroup.removeAll(); - this._storage = createStorage(); - this._state = 'ready'; - this._breadcrumb && this._breadcrumb.remove(); - }, - - dispose: function () { - this._clearController(); - }, - - /** - * @private - */ - _zoomToNode: function (targetInfo) { - this.api.dispatchAction({ - type: 'treemapZoomToNode', - from: this.uid, - seriesId: this.seriesModel.id, - targetNode: targetInfo.node - }); - }, - - /** - * @public - * @param {number} x Global coord x. - * @param {number} y Global coord y. - * @return {Object} info If not found, return undefined; - * @return {number} info.node Target node. - * @return {number} info.offsetX x refer to target node. - * @return {number} info.offsetY y refer to target node. - */ - findTarget: function (x, y) { - var targetInfo; - var viewRoot = this.seriesModel.getViewRoot(); - - viewRoot.eachNode({attr: 'viewChildren', order: 'preorder'}, function (node) { - var bgEl = this._storage.background[node.getRawIndex()]; - // If invisible, there might be no element. - if (bgEl) { - var point = bgEl.transformCoordToLocal(x, y); - var shape = bgEl.shape; - - // For performance consideration, dont use 'getBoundingRect'. - if (shape.x <= point[0] - && point[0] <= shape.x + shape.width - && shape.y <= point[1] - && point[1] <= shape.y + shape.height - ) { - targetInfo = {node: node, offsetX: point[0], offsetY: point[1]}; - } - else { - return false; // Suppress visit subtree. - } - } - }, this); - - return targetInfo; - } - - }); - - function createStorage() { - return {nodeGroup: [], background: [], content: []}; - } -}); -/** - * @file Treemap action - */ -define('echarts/chart/treemap/treemapAction',['require','../../echarts'],function(require) { + var candleWidth = calculateCandleWidth(seriesModel, data); - var echarts = require('../../echarts'); + data.each(dimensions, function () { + var args = arguments; + var dimLen = dimensions.length; + var axisDimVal = args[0]; + var idx = args[dimLen]; + var variableDim = chartLayout === 'horizontal' ? 0 : 1; + var constDim = 1 - variableDim; - var noop = function () {}; + var openVal = args[1]; + var closeVal = args[2]; + var lowestVal = args[3]; + var highestVal = args[4]; + + var ocLow = Math.min(openVal, closeVal); + var ocHigh = Math.max(openVal, closeVal); + + var ocLowPoint = getPoint(ocLow); + var ocHighPoint = getPoint(ocHigh); + var lowestPoint = getPoint(lowestVal); + var highestPoint = getPoint(highestVal); - echarts.registerAction({type: 'treemapZoomToNode', update: 'updateView'}, noop); - echarts.registerAction({type: 'treemapRender', update: 'updateView'}, noop); - echarts.registerAction({type: 'treemapMove', update: 'updateView'}, noop); + var whiskerEnds = [ + [highestPoint, ocHighPoint], + [lowestPoint, ocLowPoint] + ]; -}); -/** - * @file Visual mapping. - */ -define('echarts/visual/VisualMapping',['require','zrender/core/util','zrender/tool/color','../util/number'],function (require) { - - var zrUtil = require('zrender/core/util'); - var zrColor = require('zrender/tool/color'); - var linearMap = require('../util/number').linearMap; - var each = zrUtil.each; - var isObject = zrUtil.isObject; - - var CATEGORY_DEFAULT_VISUAL_INDEX = -1; - - function linearMapArray(val, domain, range, clamp) { - if (zrUtil.isArray(val)) { - return zrUtil.map(val, function (v) { - return linearMap(v, domain, range, clamp); - }); - } - return linearMap(val, domain, range, clamp); - } - /** - * @param {Object} option - * @param {string} [option.type] See visualHandlers. - * @param {string} [option.mappingMethod] 'linear' or 'piecewise' or 'category' - * @param {Array.=} [option.dataExtent] [minExtent, maxExtent], - * required when mappingMethod is 'linear' - * @param {Array.=} [option.pieceList] [ - * {value: someValue}, - * {interval: [min1, max1], visual: {...}}, - * {interval: [min2, max2]} - * ], - * required when mappingMethod is 'piecewise'. - * Visual for only each piece can be specified. - * @param {Array.=} [option.categories] ['cate1', 'cate2'] - * required when mappingMethod is 'category'. - * If no option.categories, it represents - * categories is [0, 1, 2, ...]. - * @param {boolean} [option.loop=false] Whether loop mapping when mappingMethod is 'category'. - * @param {(Array|Object|*)} [option.visual] Visual data. - * when mappingMethod is 'category', - * visual data can be array or object - * (like: {cate1: '#222', none: '#fff'}) - * or primary types (which represents - * defualt category visual), otherwise visual - * can only be array. - * - */ - var VisualMapping = function (option) { - var mappingMethod = option.mappingMethod; - var visualType = option.type; - - /** - * @readOnly - * @type {string} - */ - this.type = visualType; - - /** - * @readOnly - * @type {string} - */ - this.mappingMethod = mappingMethod; - - /** - * @readOnly - * @type {Object} - */ - var thisOption = this.option = zrUtil.clone(option); - - /** - * @private - * @type {Function} - */ - this._normalizeData = normalizers[mappingMethod]; - - /** - * @private - * @type {Function} - */ - this._getSpecifiedVisual = zrUtil.bind( - specifiedVisualGetters[mappingMethod], this, visualType - ); - - zrUtil.extend(this, visualHandlers[visualType]); - - if (mappingMethod === 'piecewise') { - preprocessForPiecewise(thisOption); - } - if (mappingMethod === 'category') { - preprocessForCategory(thisOption); - } - }; - - VisualMapping.prototype = { - - constructor: VisualMapping, - - applyVisual: null, - - isValueActive: null, - - mapValueToVisual: null, - - getNormalizer: function () { - return zrUtil.bind(this._normalizeData, this); - } - }; - - var visualHandlers = VisualMapping.visualHandlers = { - - color: { - - applyVisual: defaultApplyColor, - - /** - * Create a mapper function - * @return {Function} - */ - getColorMapper: function () { - var visual = isCategory(this) - ? this.option.visual - : zrUtil.map(this.option.visual, zrColor.parse); - return zrUtil.bind( - isCategory(this) - ? function (value, isNormalized) { - !isNormalized && (value = this._normalizeData(value)); - return getVisualForCategory(this, visual, value); - } - : function (value, isNormalized, out) { - // If output rgb array - // which will be much faster and useful in pixel manipulation - var returnRGBArray = !!out; - !isNormalized && (value = this._normalizeData(value)); - out = zrColor.fastMapToColor(value, visual, out); - return returnRGBArray ? out : zrUtil.stringify(out, 'rgba'); - }, this); - }, - - // value: - // (1) {number} - // (2) {Array.} Represents a interval, for colorStops. - // Return type: - // (1) {string} color value like '#444' - // (2) {Array.} colorStops, - // like [{color: '#fff', offset: 0}, {color: '#444', offset: 1}] - // where offset is between 0 and 1. - mapValueToVisual: function (value) { - var visual = this.option.visual; - - if (zrUtil.isArray(value)) { - value = [ - this._normalizeData(value[0]), - this._normalizeData(value[1]) - ]; - - // For creating gradient color list. - return zrColor.mapIntervalToColor(value, visual); - } - else { - var normalized = this._normalizeData(value); - var result = this._getSpecifiedVisual(value); - - if (result == null) { - result = isCategory(this) - ? getVisualForCategory(this, visual, normalized) - : zrColor.mapToColor(normalized, visual); - } - - return result; - } - } - }, - - colorHue: makePartialColorVisualHandler(function (color, value) { - return zrColor.modifyHSL(color, value); - }), - - colorSaturation: makePartialColorVisualHandler(function (color, value) { - return zrColor.modifyHSL(color, null, value); - }), - - colorLightness: makePartialColorVisualHandler(function (color, value) { - return zrColor.modifyHSL(color, null, null, value); - }), - - colorAlpha: makePartialColorVisualHandler(function (color, value) { - return zrColor.modifyAlpha(color, value); - }), - - symbol: { - applyVisual: function (value, getter, setter) { - var symbolCfg = this.mapValueToVisual(value); - if (zrUtil.isString(symbolCfg)) { - setter('symbol', symbolCfg); - } - else if (isObject(symbolCfg)) { - for (var name in symbolCfg) { - if (symbolCfg.hasOwnProperty(name)) { - setter(name, symbolCfg[name]); - } - } - } - }, - - mapValueToVisual: function (value) { - var normalized = this._normalizeData(value); - var result = this._getSpecifiedVisual(value); - var visual = this.option.visual; - - if (result == null) { - result = isCategory(this) - ? getVisualForCategory(this, visual, normalized) - : (arrayGetByNormalizedValue(visual, normalized) || {}); - } - - return result; - } - }, - - symbolSize: { - applyVisual: function (value, getter, setter) { - setter('symbolSize', this.mapValueToVisual(value)); - }, - - mapValueToVisual: function (value) { - var normalized = this._normalizeData(value); - var result = this._getSpecifiedVisual(value); - var visual = this.option.visual; - - if (result == null) { - result = isCategory(this) - ? getVisualForCategory(this, visual, normalized) - : linearMapArray(normalized, [0, 1], visual, true); - } - return result; - } - } - }; - - function preprocessForPiecewise(thisOption) { - var pieceList = thisOption.pieceList; - thisOption.hasSpecialVisual = false; - - zrUtil.each(pieceList, function (piece, index) { - piece.originIndex = index; - if (piece.visual) { - thisOption.hasSpecialVisual = true; - } - }); - } - - function preprocessForCategory(thisOption) { - // Hash categories. - var categories = thisOption.categories; - var visual = thisOption.visual; - var isVisualArray = zrUtil.isArray(visual); - - if (!categories) { - if (!isVisualArray) { - // visual should be array when no categories. - throw new Error(); - } - else { - return; - } - } - - var categoryMap = thisOption.categoryMap = {}; - each(categories, function (cate, index) { - categoryMap[cate] = index; - }); - - // Process visual map input. - if (!isVisualArray) { - var visualArr = []; - - if (zrUtil.isObject(visual)) { - each(visual, function (v, cate) { - var index = categoryMap[cate]; - visualArr[index != null ? index : CATEGORY_DEFAULT_VISUAL_INDEX] = v; - }); - } - else { // Is primary type, represents default visual. - visualArr[CATEGORY_DEFAULT_VISUAL_INDEX] = visual; - } - - visual = thisOption.visual = visualArr; - } - - // Remove categories that has no visual, - // then we can mapping them to CATEGORY_DEFAULT_VISUAL_INDEX. - for (var i = categories.length - 1; i >= 0; i--) { - if (visual[i] == null) { - delete categoryMap[categories[i]]; - categories.pop(); - } - } - } - - function makePartialColorVisualHandler(applyValue) { - return { - - applyVisual: function (value, getter, setter) { - // color can be {string} or {Array.} (for gradient color stops) - var color = getter('color'); - var isArrayValue = zrUtil.isArray(value); - value = isArrayValue - ? [this.mapValueToVisual(value[0]), this.mapValueToVisual(value[1])] - : this.mapValueToVisual(value); - - if (zrUtil.isArray(color)) { - for (var i = 0, len = color.length; i < len; i++) { - color[i].color = applyValue( - color[i].color, isArrayValue ? value[i] : value - ); - } - } - else { - // Must not be array value - setter('color', applyValue(color, value)); - } - }, - - mapValueToVisual: function (value) { - var normalized = this._normalizeData(value); - var result = this._getSpecifiedVisual(value); - var visual = this.option.visual; - - if (result == null) { - result = isCategory(this) - ? getVisualForCategory(this, visual, normalized) - : linearMapArray(normalized, [0, 1], visual, true); - } - return result; - } - }; - } - - function arrayGetByNormalizedValue(arr, normalized) { - return arr[ - Math.round(linearMapArray(normalized, [0, 1], [0, arr.length - 1], true)) - ]; - } - - function defaultApplyColor(value, getter, setter) { - setter('color', this.mapValueToVisual(value)); - } - - function getVisualForCategory(me, visual, normalized) { - return visual[ - (me.option.loop && normalized !== CATEGORY_DEFAULT_VISUAL_INDEX) - ? normalized % visual.length - : normalized - ]; - } - - function isCategory(me) { - return me.option.mappingMethod === 'category'; - } - - - var normalizers = { - - linear: function (value) { - return linearMapArray(value, this.option.dataExtent, [0, 1], true); - }, - - piecewise: function (value) { - var pieceList = this.option.pieceList; - var pieceIndex = VisualMapping.findPieceIndex(value, pieceList); - if (pieceIndex != null) { - return linearMapArray(pieceIndex, [0, pieceList.length - 1], [0, 1], true); - } - }, - - category: function (value) { - var index = this.option.categories - ? this.option.categoryMap[value] - : value; // ordinal - return index == null ? CATEGORY_DEFAULT_VISUAL_INDEX : index; - } - }; - - - // FIXME - // refactor - var specifiedVisualGetters = { - - // Linear do not support this feature. - linear: zrUtil.noop, - - piecewise: function (visualType, value) { - var thisOption = this.option; - var pieceList = thisOption.pieceList; - if (thisOption.hasSpecialVisual) { - var pieceIndex = VisualMapping.findPieceIndex(value, pieceList); - var piece = pieceList[pieceIndex]; - if (piece && piece.visual) { - return piece.visual[visualType]; - } - } - }, - - // Category do not need to support this feature. - // Visual can be set in visualMap.inRange or - // visualMap.outOfRange directly. - category: zrUtil.noop - }; - - /** - * @public - */ - VisualMapping.addVisualHandler = function (name, handler) { - visualHandlers[name] = handler; - }; - - /** - * @public - */ - VisualMapping.isValidType = function (visualType) { - return visualHandlers.hasOwnProperty(visualType); - }; - - /** - * Convinent method. - * Visual can be Object or Array or primary type. - * - * @public - */ - VisualMapping.eachVisual = function (visual, callback, context) { - if (zrUtil.isObject(visual)) { - zrUtil.each(visual, callback, context); - } - else { - callback.call(context, visual); - } - }; - - VisualMapping.mapVisual = function (visual, callback, context) { - var isPrimary; - var newVisual = zrUtil.isArray(visual) - ? [] - : zrUtil.isObject(visual) - ? {} - : (isPrimary = true, null); - - VisualMapping.eachVisual(visual, function (v, key) { - var newVal = callback.call(context, v, key); - isPrimary ? (newVisual = newVal) : (newVisual[key] = newVal); - }); - return newVisual; - }; - - /** - * 'color', 'colorSaturation', 'colorAlpha', ... are in the same visualCluster named 'color'. - * Other visuals are in the cluster named as the same as theirselves. - * - * @public - * @param {string} visualType - * @param {string} visualCluster - * @return {boolean} - */ - VisualMapping.isInVisualCluster = function (visualType, visualCluster) { - return visualCluster === 'color' - ? !!(visualType && visualType.indexOf(visualCluster) === 0) - : visualType === visualCluster; - }; - - /** - * @public - * @param {Object} obj - * @return {Oject} new object containers visual values. - * If no visuals, return null. - */ - VisualMapping.retrieveVisuals = function (obj) { - var ret = {}; - var hasVisual; - - obj && each(visualHandlers, function (h, visualType) { - if (obj.hasOwnProperty(visualType)) { - ret[visualType] = obj[visualType]; - hasVisual = true; - } - }); - - return hasVisual ? ret : null; - }; - - /** - * Give order to visual types, considering colorSaturation, colorAlpha depends on color. - * - * @public - * @param {(Object|Array)} visualTypes If Object, like: {color: ..., colorSaturation: ...} - * IF Array, like: ['color', 'symbol', 'colorSaturation'] - * @return {Array.} Sorted visual types. - */ - VisualMapping.prepareVisualTypes = function (visualTypes) { - if (isObject(visualTypes)) { - var types = []; - each(visualTypes, function (item, type) { - types.push(type); - }); - visualTypes = types; - } - else if (zrUtil.isArray(visualTypes)) { - visualTypes = visualTypes.slice(); - } - else { - return []; - } - - visualTypes.sort(function (type1, type2) { - // color should be front of colorSaturation, colorAlpha, ... - // symbol and symbolSize do not matter. - return (type2 === 'color' && type1 !== 'color' && type1.indexOf('color') === 0) - ? 1 : -1; - }); - - return visualTypes; - }; - - /** - * @public {Array.} [{value: ..., interval: [min, max]}, ...] - * @return {number} index - */ - VisualMapping.findPieceIndex = function (value, pieceList) { - // value has high priority. - for (var i = 0, len = pieceList.length; i < len; i++) { - var piece = pieceList[i]; - if (piece.value != null && piece.value === value) { - return i; - } - } - - for (var i = 0, len = pieceList.length; i < len; i++) { - var piece = pieceList[i]; - var interval = piece.interval; - if (interval) { - if (interval[0] === -Infinity) { - if (value < interval[1]) { - return i; - } - } - else if (interval[1] === Infinity) { - if (interval[0] < value) { - return i; - } - } - else if ( - piece.interval[0] <= value - && value <= piece.interval[1] - ) { - return i; - } - } - } - }; - - return VisualMapping; + var bodyEnds = []; + addBodyEnd(ocHighPoint, 0); + addBodyEnd(ocLowPoint, 1); -}); + data.setItemLayout(idx, { + chartLayout: chartLayout, + sign: openVal > closeVal ? -1 : openVal < closeVal ? 1 : 0, + initBaseline: openVal > closeVal + ? ocHighPoint[constDim] : ocLowPoint[constDim], // open point. + bodyEnds: bodyEnds, + whiskerEnds: whiskerEnds + }); -define('echarts/chart/treemap/treemapVisual',['require','../../visual/VisualMapping','zrender/tool/color','zrender/core/util'],function (require) { - - var VisualMapping = require('../../visual/VisualMapping'); - var zrColor = require('zrender/tool/color'); - var zrUtil = require('zrender/core/util'); - var isArray = zrUtil.isArray; - - var ITEM_STYLE_NORMAL = 'itemStyle.normal'; - - return function (ecModel, payload) { - - var condition = {mainType: 'series', subType: 'treemap', query: payload}; - ecModel.eachComponent(condition, function (seriesModel) { - - var tree = seriesModel.getData().tree; - var root = tree.root; - var seriesItemStyleModel = seriesModel.getModel(ITEM_STYLE_NORMAL); - - if (root.isRemoved()) { - return; - } - - var levelItemStyles = zrUtil.map(tree.levelModels, function (levelModel) { - return levelModel ? levelModel.get(ITEM_STYLE_NORMAL) : null; - }); - - travelTree( - root, - {}, - levelItemStyles, - seriesItemStyleModel, - seriesModel.getViewRoot().getAncestors(), - seriesModel - ); - }); - }; - - function travelTree( - node, designatedVisual, levelItemStyles, seriesItemStyleModel, - viewRootAncestors, seriesModel - ) { - var nodeModel = node.getModel(); - var nodeLayout = node.getLayout(); - - // Optimize - if (nodeLayout.invisible) { - return; - } - - var nodeItemStyleModel = node.getModel(ITEM_STYLE_NORMAL); - var levelItemStyle = levelItemStyles[node.depth]; - var visuals = buildVisuals( - nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel - ); - - // calculate border color - var borderColor = nodeItemStyleModel.get('borderColor'); - var borderColorSaturation = nodeItemStyleModel.get('borderColorSaturation'); - var thisNodeColor; - if (borderColorSaturation != null) { - // For performance, do not always execute 'calculateColor'. - thisNodeColor = calculateColor(visuals, node); - borderColor = calculateBorderColor(borderColorSaturation, thisNodeColor); - } - node.setVisual('borderColor', borderColor); - - var viewChildren = node.viewChildren; - if (!viewChildren || !viewChildren.length) { - thisNodeColor = calculateColor(visuals, node); - // Apply visual to this node. - node.setVisual('color', thisNodeColor); - } - else { - var mapping = buildVisualMapping( - node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren - ); - // Designate visual to children. - zrUtil.each(viewChildren, function (child, index) { - // If higher than viewRoot, only ancestors of viewRoot is needed to visit. - if (child.depth >= viewRootAncestors.length - || child === viewRootAncestors[child.depth] - ) { - var childVisual = mapVisual( - nodeModel, visuals, child, index, mapping, seriesModel - ); - travelTree( - child, childVisual, levelItemStyles, seriesItemStyleModel, - viewRootAncestors, seriesModel - ); - } - }); - } - } - - function buildVisuals( - nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel - ) { - var visuals = zrUtil.extend({}, designatedVisual); - - zrUtil.each(['color', 'colorAlpha', 'colorSaturation'], function (visualName) { - // Priority: thisNode > thisLevel > parentNodeDesignated > seriesModel - var val = nodeItemStyleModel.get(visualName, true); // Ignore parent - val == null && levelItemStyle && (val = levelItemStyle[visualName]); - val == null && (val = designatedVisual[visualName]); - val == null && (val = seriesItemStyleModel.get(visualName)); - - val != null && (visuals[visualName] = val); - }); - - return visuals; - } - - function calculateColor(visuals) { - var color = getValueVisualDefine(visuals, 'color'); - - if (color) { - var colorAlpha = getValueVisualDefine(visuals, 'colorAlpha'); - var colorSaturation = getValueVisualDefine(visuals, 'colorSaturation'); - if (colorSaturation) { - color = zrColor.modifyHSL(color, null, null, colorSaturation); - } - if (colorAlpha) { - color = zrColor.modifyAlpha(color, colorAlpha); - } - - return color; - } - } - - function calculateBorderColor(borderColorSaturation, thisNodeColor) { - return thisNodeColor != null - ? zrColor.modifyHSL(thisNodeColor, null, null, borderColorSaturation) - : null; - } - - function getValueVisualDefine(visuals, name) { - var value = visuals[name]; - if (value != null && value !== 'none') { - return value; - } - } - - function buildVisualMapping( - node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren - ) { - if (!viewChildren || !viewChildren.length) { - return; - } - - var rangeVisual = getRangeVisual(nodeModel, 'color') - || ( - visuals.color != null - && visuals.color !== 'none' - && ( - getRangeVisual(nodeModel, 'colorAlpha') - || getRangeVisual(nodeModel, 'colorSaturation') - ) - ); - - if (!rangeVisual) { - return; - } - - var colorMappingBy = nodeModel.get('colorMappingBy'); - var opt = { - type: rangeVisual.name, - dataExtent: nodeLayout.dataExtent, - visual: rangeVisual.range - }; - if (opt.type === 'color' - && (colorMappingBy === 'index' || colorMappingBy === 'id') - ) { - opt.mappingMethod = 'category'; - opt.loop = true; - // categories is ordinal, so do not set opt.categories. - } - else { - opt.mappingMethod = 'linear'; - } - - var mapping = new VisualMapping(opt); - mapping.__drColorMappingBy = colorMappingBy; - - return mapping; - } - - // Notice: If we dont have the attribute 'colorRange', but only use - // attribute 'color' to represent both concepts of 'colorRange' and 'color', - // (It means 'colorRange' when 'color' is Array, means 'color' when not array), - // this problem will be encountered: - // If a level-1 node dont have children, and its siblings has children, - // and colorRange is set on level-1, then the node can not be colored. - // So we separate 'colorRange' and 'color' to different attributes. - function getRangeVisual(nodeModel, name) { - // 'colorRange', 'colorARange', 'colorSRange'. - // If not exsits on this node, fetch from levels and series. - var range = nodeModel.get(name); - return (isArray(range) && range.length) ? {name: name, range: range} : null; - } - - function mapVisual(nodeModel, visuals, child, index, mapping, seriesModel) { - var childVisuals = zrUtil.extend({}, visuals); - - if (mapping) { - var mappingType = mapping.type; - var colorMappingBy = mappingType === 'color' && mapping.__drColorMappingBy; - var value = - colorMappingBy === 'index' - ? index - : colorMappingBy === 'id' - ? seriesModel.mapIdToIndex(child.getId()) - : child.getValue(nodeModel.get('visualDimension')); - - childVisuals[mappingType] = mapping.mapValueToVisual(value); - } - - return childVisuals; - } + function getPoint(val) { + var p = []; + p[variableDim] = axisDimVal; + p[constDim] = val; + return (isNaN(axisDimVal) || isNaN(val)) + ? [NaN, NaN] + : coordSys.dataToPoint(p); + } + + function addBodyEnd(point, start) { + var point1 = point.slice(); + var point2 = point.slice(); + point1[variableDim] += candleWidth / 2; + point2[variableDim] -= candleWidth / 2; + start + ? bodyEnds.push(point1, point2) + : bodyEnds.push(point2, point1); + } + + }, true); + }); + }; + + function calculateCandleWidth(seriesModel, data) { + var baseAxis = seriesModel.getBaseAxis(); + var extent; + + var bandWidth = baseAxis.type === 'category' + ? baseAxis.getBandWidth() + : ( + extent = baseAxis.getExtent(), + Math.abs(extent[1] - extent[0]) / data.count() + ); + + // Half band width is perfect when space is enouph, otherwise + // try not to be smaller than CANDLE_MIN_NICE_WIDTH (and only + // gap is compressed), otherwise ensure not to be smaller than + // CANDLE_MIN_WIDTH in spite of overlap. -}); -define('echarts/chart/treemap/treemapLayout',['require','zrender/core/util','../../util/number','../../util/layout','zrender/core/BoundingRect','./helper'],function (require) { - - var mathMax = Math.max; - var mathMin = Math.min; - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../../util/number'); - var layout = require('../../util/layout'); - var parsePercent = numberUtil.parsePercent; - var retrieveValue = zrUtil.retrieve; - var BoundingRect = require('zrender/core/BoundingRect'); - var helper = require('./helper'); - - /** - * @public - */ - function update(ecModel, api, payload) { - // Layout result in each node: - // {x, y, width, height, area, borderWidth} - var condition = {mainType: 'series', subType: 'treemap', query: payload}; - ecModel.eachComponent(condition, function (seriesModel) { - - var ecWidth = api.getWidth(); - var ecHeight = api.getHeight(); - - var size = seriesModel.get('size') || []; // Compatible with ec2. - var containerWidth = parsePercent( - retrieveValue(seriesModel.get('width'), size[0]), - ecWidth - ); - var containerHeight = parsePercent( - retrieveValue(seriesModel.get('height'), size[1]), - ecHeight - ); - - var layoutInfo = layout.getLayoutRect( - seriesModel.getBoxLayoutParams(), - { - width: api.getWidth(), - height: api.getHeight() - } - ); - - // Fetch payload info. - var payloadType = payload && payload.type; - var targetInfo = helper.retrieveTargetInfo(payload, seriesModel); - var rootRect = (payloadType === 'treemapRender' || payloadType === 'treemapMove') - ? payload.rootRect : null; - var viewRoot = seriesModel.getViewRoot(); - - if (payloadType !== 'treemapMove') { - var rootSize = payloadType === 'treemapZoomToNode' - ? estimateRootSize(seriesModel, targetInfo, containerWidth, containerHeight) - : rootRect - ? [rootRect.width, rootRect.height] - : [containerWidth, containerHeight]; - - var sort = seriesModel.get('sort'); - if (sort && sort !== 'asc' && sort !== 'desc') { - sort = 'desc'; - } - var options = { - squareRatio: seriesModel.get('squareRatio'), - sort: sort - }; - - viewRoot.setLayout({ - x: 0, y: 0, - width: rootSize[0], height: rootSize[1], - area: rootSize[0] * rootSize[1] - }); - - squarify(viewRoot, options); - } - - // Set root position - viewRoot.setLayout( - calculateRootPosition(layoutInfo, rootRect, targetInfo), - true - ); - - seriesModel.setLayoutInfo(layoutInfo); - - // Optimize - // FIXME - // 现在没有clip功能,暂时取ec高宽。 - prunning( - viewRoot, - new BoundingRect(-layoutInfo.x, -layoutInfo.y, ecWidth, ecHeight) - ); - - }); - } - - /** - * Layout treemap with squarify algorithm. - * @see https://graphics.ethz.ch/teaching/scivis_common/Literature/squarifiedTreeMaps.pdf - * @see https://github.com/mbostock/d3/blob/master/src/layout/treemap.js - * - * @protected - * @param {module:echarts/data/Tree~TreeNode} node - * @param {Object} options - * @param {string} options.sort 'asc' or 'desc' - * @param {boolean} options.hideChildren - * @param {number} options.squareRatio - */ - function squarify(node, options) { - var width; - var height; - - if (node.isRemoved()) { - return; - } - - var thisLayout = node.getLayout(); - width = thisLayout.width; - height = thisLayout.height; - - // Considering border and gap - var itemStyleModel = node.getModel('itemStyle.normal'); - var borderWidth = itemStyleModel.get('borderWidth'); - var halfGapWidth = itemStyleModel.get('gapWidth') / 2; - var layoutOffset = borderWidth - halfGapWidth; - var nodeModel = node.getModel(); - - node.setLayout({borderWidth: borderWidth}, true); - - width = mathMax(width - 2 * layoutOffset, 0); - height = mathMax(height - 2 * layoutOffset, 0); - - var totalArea = width * height; - var viewChildren = initChildren(node, nodeModel, totalArea, options); - - if (!viewChildren.length) { - return; - } - - var rect = {x: layoutOffset, y: layoutOffset, width: width, height: height}; - var rowFixedLength = mathMin(width, height); - var best = Infinity; // the best row score so far - var row = []; - row.area = 0; - - for (var i = 0, len = viewChildren.length; i < len;) { - var child = viewChildren[i]; - - row.push(child); - row.area += child.getLayout().area; - var score = worst(row, rowFixedLength, options.squareRatio); - - // continue with this orientation - if (score <= best) { - i++; - best = score; - } - // abort, and try a different orientation - else { - row.area -= row.pop().getLayout().area; - position(row, rowFixedLength, rect, halfGapWidth, false); - rowFixedLength = mathMin(rect.width, rect.height); - row.length = row.area = 0; - best = Infinity; - } - } - - if (row.length) { - position(row, rowFixedLength, rect, halfGapWidth, true); - } - - // Update option carefully. - var hideChildren; - if (!options.hideChildren) { - var childrenVisibleMin = nodeModel.get('childrenVisibleMin'); - if (childrenVisibleMin != null && totalArea < childrenVisibleMin) { - hideChildren = true; - } - } - - for (var i = 0, len = viewChildren.length; i < len; i++) { - var childOption = zrUtil.extend({ - hideChildren: hideChildren - }, options); - - squarify(viewChildren[i], childOption); - } - } - - /** - * Set area to each child, and calculate data extent for visual coding. - */ - function initChildren(node, nodeModel, totalArea, options) { - var viewChildren = node.children || []; - var orderBy = options.sort; - orderBy !== 'asc' && orderBy !== 'desc' && (orderBy = null); - - if (options.hideChildren) { - return (node.viewChildren = []); - } - - // Sort children, order by desc. - viewChildren = zrUtil.filter(viewChildren, function (child) { - return !child.isRemoved(); - }); - - sort(viewChildren, orderBy); - - var info = statistic(nodeModel, viewChildren, orderBy); - - if (info.sum === 0) { - return (node.viewChildren = []); - } - - info.sum = filterByThreshold(nodeModel, totalArea, info.sum, orderBy, viewChildren); - - if (info.sum === 0) { - return (node.viewChildren = []); - } - - // Set area to each child. - for (var i = 0, len = viewChildren.length; i < len; i++) { - var area = viewChildren[i].getValue() / info.sum * totalArea; - // Do not use setLayout({...}, true), because it is needed to clear last layout. - viewChildren[i].setLayout({area: area}); - } - - node.viewChildren = viewChildren; - node.setLayout({dataExtent: info.dataExtent}, true); - - return viewChildren; - } - - /** - * Consider 'visibleMin'. Modify viewChildren and get new sum. - */ - function filterByThreshold(nodeModel, totalArea, sum, orderBy, orderedChildren) { - - // visibleMin is not supported yet when no option.sort. - if (!orderBy) { - return sum; - } - - var visibleMin = nodeModel.get('visibleMin'); - var len = orderedChildren.length; - var deletePoint = len; - - // Always travel from little value to big value. - for (var i = len - 1; i >= 0; i--) { - var value = orderedChildren[ - orderBy === 'asc' ? len - i - 1 : i - ].getValue(); - - if (value / sum * totalArea < visibleMin) { - deletePoint = i; - sum -= value; - } - } - - orderBy === 'asc' - ? orderedChildren.splice(0, len - deletePoint) - : orderedChildren.splice(deletePoint, len - deletePoint); - - return sum; - } - - /** - * Sort - */ - function sort(viewChildren, orderBy) { - if (orderBy) { - viewChildren.sort(function (a, b) { - return orderBy === 'asc' - ? a.getValue() - b.getValue() : b.getValue() - a.getValue(); - }); - } - return viewChildren; - } - - /** - * Statistic - */ - function statistic(nodeModel, children, orderBy) { - // Calculate sum. - var sum = 0; - for (var i = 0, len = children.length; i < len; i++) { - sum += children[i].getValue(); - } - - // Statistic data extent for latter visual coding. - // Notice: data extent should be calculate based on raw children - // but not filtered view children, otherwise visual mapping will not - // be stable when zoom (where children is filtered by visibleMin). - - var dimension = nodeModel.get('visualDimension'); - var dataExtent; - - // The same as area dimension. - if (!children || !children.length) { - dataExtent = [NaN, NaN]; - } - else if (dimension === 'value' && orderBy) { - dataExtent = [ - children[children.length - 1].getValue(), - children[0].getValue() - ]; - orderBy === 'asc' && dataExtent.reverse(); - } - // Other dimension. - else { - var dataExtent = [Infinity, -Infinity]; - zrUtil.each(children, function (child) { - var value = child.getValue(dimension); - value < dataExtent[0] && (dataExtent[0] = value); - value > dataExtent[1] && (dataExtent[1] = value); - }); - } - - return {sum: sum, dataExtent: dataExtent}; - } - - /** - * Computes the score for the specified row, - * as the worst aspect ratio. - */ - function worst(row, rowFixedLength, ratio) { - var areaMax = 0; - var areaMin = Infinity; - - for (var i = 0, area, len = row.length; i < len; i++) { - area = row[i].getLayout().area; - if (area) { - area < areaMin && (areaMin = area); - area > areaMax && (areaMax = area); - } - } - - var squareArea = row.area * row.area; - var f = rowFixedLength * rowFixedLength * ratio; - - return squareArea - ? mathMax( - (f * areaMax) / squareArea, - squareArea / (f * areaMin) - ) - : Infinity; - } - - /** - * Positions the specified row of nodes. Modifies `rect`. - */ - function position(row, rowFixedLength, rect, halfGapWidth, flush) { - // When rowFixedLength === rect.width, - // it is horizontal subdivision, - // rowFixedLength is the width of the subdivision, - // rowOtherLength is the height of the subdivision, - // and nodes will be positioned from left to right. - - // wh[idx0WhenH] means: when horizontal, - // wh[idx0WhenH] => wh[0] => 'width'. - // xy[idx1WhenH] => xy[1] => 'y'. - var idx0WhenH = rowFixedLength === rect.width ? 0 : 1; - var idx1WhenH = 1 - idx0WhenH; - var xy = ['x', 'y']; - var wh = ['width', 'height']; - - var last = rect[xy[idx0WhenH]]; - var rowOtherLength = rowFixedLength - ? row.area / rowFixedLength : 0; - - if (flush || rowOtherLength > rect[wh[idx1WhenH]]) { - rowOtherLength = rect[wh[idx1WhenH]]; // over+underflow - } - for (var i = 0, rowLen = row.length; i < rowLen; i++) { - var node = row[i]; - var nodeLayout = {}; - var step = rowOtherLength - ? node.getLayout().area / rowOtherLength : 0; - - var wh1 = nodeLayout[wh[idx1WhenH]] = mathMax(rowOtherLength - 2 * halfGapWidth, 0); - - // We use Math.max/min to avoid negative width/height when considering gap width. - var remain = rect[xy[idx0WhenH]] + rect[wh[idx0WhenH]] - last; - var modWH = (i === rowLen - 1 || remain < step) ? remain : step; - var wh0 = nodeLayout[wh[idx0WhenH]] = mathMax(modWH - 2 * halfGapWidth, 0); - - nodeLayout[xy[idx1WhenH]] = rect[xy[idx1WhenH]] + mathMin(halfGapWidth, wh1 / 2); - nodeLayout[xy[idx0WhenH]] = last + mathMin(halfGapWidth, wh0 / 2); - - last += modWH; - node.setLayout(nodeLayout, true); - } - - rect[xy[idx1WhenH]] += rowOtherLength; - rect[wh[idx1WhenH]] -= rowOtherLength; - } - - // Return [containerWidth, containerHeight] as defualt. - function estimateRootSize(seriesModel, targetInfo, containerWidth, containerHeight) { - // If targetInfo.node exists, we zoom to the node, - // so estimate whold width and heigth by target node. - var currNode = (targetInfo || {}).node; - var defaultSize = [containerWidth, containerHeight]; - - if (!currNode || currNode === seriesModel.getViewRoot()) { - return defaultSize; - } - - var parent; - var viewArea = containerWidth * containerHeight; - var area = viewArea * seriesModel.get('zoomToNodeRatio'); - - while (parent = currNode.parentNode) { // jshint ignore:line - var sum = 0; - var siblings = parent.children; - - for (var i = 0, len = siblings.length; i < len; i++) { - sum += siblings[i].getValue(); - } - var currNodeValue = currNode.getValue(); - if (currNodeValue === 0) { - return defaultSize; - } - area *= sum / currNodeValue; - - var borderWidth = parent.getModel('itemStyle.normal').get('borderWidth'); - - if (isFinite(borderWidth)) { - // Considering border, suppose aspect ratio is 1. - area += 4 * borderWidth * borderWidth + 4 * borderWidth * Math.pow(area, 0.5); - } - - area > numberUtil.MAX_SAFE_INTEGER && (area = numberUtil.MAX_SAFE_INTEGER); - - currNode = parent; - } - - area < viewArea && (area = viewArea); - var scale = Math.pow(area / viewArea, 0.5); - - return [containerWidth * scale, containerHeight * scale]; - } - - // Root postion base on coord of containerGroup - function calculateRootPosition(layoutInfo, rootRect, targetInfo) { - if (rootRect) { - return {x: rootRect.x, y: rootRect.y}; - } - - var defaultPosition = {x: 0, y: 0}; - if (!targetInfo) { - return defaultPosition; - } - - // If targetInfo is fetched by 'retrieveTargetInfo', - // old tree and new tree are the same tree, - // so the node still exists and we can visit it. - - var targetNode = targetInfo.node; - var layout = targetNode.getLayout(); - - if (!layout) { - return defaultPosition; - } - - // Transform coord from local to container. - var targetCenter = [layout.width / 2, layout.height / 2]; - var node = targetNode; - while (node) { - var nodeLayout = node.getLayout(); - targetCenter[0] += nodeLayout.x; - targetCenter[1] += nodeLayout.y; - node = node.parentNode; - } - - return { - x: layoutInfo.width / 2 - targetCenter[0], - y: layoutInfo.height / 2 - targetCenter[1] - }; - } - - // Mark invisible nodes for prunning when visual coding and rendering. - // Prunning depends on layout and root position, so we have to do it after them. - function prunning(node, clipRect) { - var nodeLayout = node.getLayout(); - - node.setLayout({invisible: !clipRect.intersect(nodeLayout)}, true); - - var viewChildren = node.viewChildren || []; - for (var i = 0, len = viewChildren.length; i < len; i++) { - // Transform to child coordinate. - var childClipRect = new BoundingRect( - clipRect.x - nodeLayout.x, - clipRect.y - nodeLayout.y, - clipRect.width, - clipRect.height - ); - prunning(viewChildren[i], childClipRect); - } - } - - return update; -}); -define('echarts/chart/treemap',['require','../echarts','./treemap/TreemapSeries','./treemap/TreemapView','./treemap/treemapAction','./treemap/treemapVisual','./treemap/treemapLayout'],function (require) { + return bandWidth / 2 - 2 > CANDLE_MIN_NICE_WIDTH // "- 2" is minus border width + ? bandWidth / 2 - 2 + : bandWidth - CANDLE_MIN_NICE_WIDTH > GPA_MIN + ? CANDLE_MIN_NICE_WIDTH + : Math.max(bandWidth - GPA_MIN, CANDLE_MIN_WIDTH); + } - var echarts = require('../echarts'); - require('./treemap/TreemapSeries'); - require('./treemap/TreemapView'); - require('./treemap/treemapAction'); - echarts.registerVisualCoding('chart', require('./treemap/treemapVisual')); +/***/ }, +/* 249 */ +/***/ function(module, exports, __webpack_require__) { - echarts.registerLayout(require('./treemap/treemapLayout')); -}); -/** - * Graph data structure - * - * @module echarts/data/Graph - * @author Yi Shen(https://www.github.com/pissang) - */ -define('echarts/data/Graph',['require','zrender/core/util'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - - /** - * @alias module:echarts/data/Graph - * @constructor - * @param {boolean} directed - */ - var Graph = function(directed) { - /** - * 是否是有向图 - * @type {boolean} - * @private - */ - this._directed = directed || false; - - /** - * @type {Array.} - * @readOnly - */ - this.nodes = []; - - /** - * @type {Array.} - * @readOnly - */ - this.edges = []; - - /** - * @type {Object.} - * @private - */ - this._nodesMap = {}; - /** - * @type {Object.} - * @private - */ - this._edgesMap = {}; - - /** - * @type {module:echarts/data/List} - * @readOnly - */ - this.data; - - /** - * @type {module:echarts/data/List} - * @readOnly - */ - this.edgeData; - }; - - var graphProto = Graph.prototype; - /** - * @type {string} - */ - graphProto.type = 'graph'; - - /** - * If is directed graph - * @return {boolean} - */ - graphProto.isDirected = function () { - return this._directed; - }; - - /** - * Add a new node - * @param {string} id - * @param {number} [dataIndex] - */ - graphProto.addNode = function (id, dataIndex) { - var nodesMap = this._nodesMap; - - if (nodesMap[id]) { - return; - } - - var node = new Node(id, dataIndex); - node.hostGraph = this; - - this.nodes.push(node); - - nodesMap[id] = node; - return node; - }; - - /** - * Get node by data index - * @param {number} dataIndex - * @return {module:echarts/data/Graph~Node} - */ - graphProto.getNodeByIndex = function (dataIndex) { - var rawIdx = this.data.getRawIndex(dataIndex); - return this.nodes[rawIdx]; - }; - /** - * Get node by id - * @param {string} id - * @return {module:echarts/data/Graph.Node} - */ - graphProto.getNodeById = function (id) { - return this._nodesMap[id]; - }; - - /** - * Add a new edge - * @param {string|module:echarts/data/Graph.Node} n1 - * @param {string|module:echarts/data/Graph.Node} n2 - * @param {number} [dataIndex=-1] - * @return {module:echarts/data/Graph.Edge} - */ - graphProto.addEdge = function (n1, n2, dataIndex) { - var nodesMap = this._nodesMap; - var edgesMap = this._edgesMap; - - if (!(n1 instanceof Node)) { - n1 = nodesMap[n1]; - } - if (!(n2 instanceof Node)) { - n2 = nodesMap[n2]; - } - if (!n1 || !n2) { - return; - } - - var key = n1.id + '-' + n2.id; - // PENDING - if (edgesMap[key]) { - return; - } - - var edge = new Edge(n1, n2, dataIndex); - edge.hostGraph = this; - - if (this._directed) { - n1.outEdges.push(edge); - n2.inEdges.push(edge); - } - n1.edges.push(edge); - if (n1 !== n2) { - n2.edges.push(edge); - } - - this.edges.push(edge); - edgesMap[key] = edge; - - return edge; - }; - - /** - * Get edge by data index - * @param {number} dataIndex - * @return {module:echarts/data/Graph~Node} - */ - graphProto.getEdgeByIndex = function (dataIndex) { - var rawIdx = this.edgeData.getRawIndex(dataIndex); - return this.edges[rawIdx]; - }; - /** - * Get edge by two linked nodes - * @param {module:echarts/data/Graph.Node|string} n1 - * @param {module:echarts/data/Graph.Node|string} n2 - * @return {module:echarts/data/Graph.Edge} - */ - graphProto.getEdge = function (n1, n2) { - if (n1 instanceof Node) { - n1 = n1.id; - } - if (n2 instanceof Node) { - n2 = n2.id; - } - - var edgesMap = this._edgesMap; - - if (this._directed) { - return edgesMap[n1 + '-' + n2]; - } else { - return edgesMap[n1 + '-' + n2] - || edgesMap[n2 + '-' + n1]; - } - }; - - /** - * Iterate all nodes - * @param {Function} cb - * @param {*} [context] - */ - graphProto.eachNode = function (cb, context) { - var nodes = this.nodes; - var len = nodes.length; - for (var i = 0; i < len; i++) { - if (nodes[i].dataIndex >= 0) { - cb.call(context, nodes[i], i); - } - } - }; - - /** - * Iterate all edges - * @param {Function} cb - * @param {*} [context] - */ - graphProto.eachEdge = function (cb, context) { - var edges = this.edges; - var len = edges.length; - for (var i = 0; i < len; i++) { - if (edges[i].dataIndex >= 0 - && edges[i].node1.dataIndex >= 0 - && edges[i].node2.dataIndex >= 0 - ) { - cb.call(context, edges[i], i); - } - } - }; - - /** - * Breadth first traverse - * @param {Function} cb - * @param {module:echarts/data/Graph.Node} startNode - * @param {string} [direction='none'] 'none'|'in'|'out' - * @param {*} [context] - */ - graphProto.breadthFirstTraverse = function ( - cb, startNode, direction, context - ) { - if (!(startNode instanceof Node)) { - startNode = this._nodesMap[startNode]; - } - if (!startNode) { - return; - } - - var edgeType = direction === 'out' - ? 'outEdges' : (direction === 'in' ? 'inEdges' : 'edges'); - - for (var i = 0; i < this.nodes.length; i++) { - this.nodes[i].__visited = false; - } - - if (cb.call(context, startNode, null)) { - return; - } - - var queue = [startNode]; - while (queue.length) { - var currentNode = queue.shift(); - var edges = currentNode[edgeType]; - - for (var i = 0; i < edges.length; i++) { - var e = edges[i]; - var otherNode = e.node1 === currentNode - ? e.node2 : e.node1; - if (!otherNode.__visited) { - if (cb.call(otherNode, otherNode, currentNode)) { - // Stop traversing - return; - } - queue.push(otherNode); - otherNode.__visited = true; - } - } - } - }; - - // TODO - // graphProto.depthFirstTraverse = function ( - // cb, startNode, direction, context - // ) { - - // }; - - // Filter update - graphProto.update = function () { - var data = this.data; - var edgeData = this.edgeData; - var nodes = this.nodes; - var edges = this.edges; - - for (var i = 0, len = nodes.length; i < len; i++) { - nodes[i].dataIndex = -1; - } - for (var i = 0, len = data.count(); i < len; i++) { - nodes[data.getRawIndex(i)].dataIndex = i; - } - - edgeData.filterSelf(function (idx) { - var edge = edges[edgeData.getRawIndex(idx)]; - return edge.node1.dataIndex >= 0 && edge.node2.dataIndex >= 0; - }); - - // Update edge - for (var i = 0, len = edges.length; i < len; i++) { - edges[i].dataIndex = -1; - } - for (var i = 0, len = edgeData.count(); i < len; i++) { - edges[edgeData.getRawIndex(i)].dataIndex = i; - } - }; - - /** - * Set edge data - * @param {module:echarts/data/List} edgeData - */ - graphProto.setEdgeData = function (edgeData) { - this.edgeData = edgeData; - this._edgeDataSaved = edgeData.cloneShallow(); - }; - - graphProto.restoreData = function () { - this.edgeData = this._edgeDataSaved.cloneShallow(); - }; - - /** - * @return {module:echarts/data/Graph} - */ - graphProto.clone = function () { - var graph = new Graph(this._directed); - var nodes = this.nodes; - var edges = this.edges; - for (var i = 0; i < nodes.length; i++) { - graph.addNode(nodes[i].id, nodes[i].dataIndex); - } - for (var i = 0; i < edges.length; i++) { - var e = edges[i]; - graph.addEdge(e.node1.id, e.node2.id, e.dataIndex); - } - return graph; - }; - - - /** - * @alias module:echarts/data/Graph.Node - */ - function Node(id, dataIndex) { - /** - * @type {string} - */ - this.id = id == null ? '' : id; - - /** - * @type {Array.} - */ - this.inEdges = []; - /** - * @type {Array.} - */ - this.outEdges = []; - /** - * @type {Array.} - */ - this.edges = []; - /** - * @type {module:echarts/data/Graph} - */ - this.hostGraph; - - /** - * @type {number} - */ - this.dataIndex = dataIndex == null ? -1 : dataIndex; - } - - Node.prototype = { - - constructor: Node, - - /** - * @return {number} - */ - degree: function () { - return this.edges.length; - }, - - /** - * @return {number} - */ - inDegree: function () { - return this.inEdges.length; - }, - - /** - * @return {number} - */ - outDegree: function () { - return this.outEdges.length; - }, - - /** - * @param {string} [path] - * @return {module:echarts/model/Model} - */ - getModel: function (path) { - if (this.dataIndex < 0) { - return; - } - var graph = this.hostGraph; - var itemModel = graph.data.getItemModel(this.dataIndex); - - return itemModel.getModel(path); - } - }; - - /** - * 图边 - * @alias module:echarts/data/Graph.Edge - * @param {module:echarts/data/Graph.Node} n1 - * @param {module:echarts/data/Graph.Node} n2 - * @param {number} [dataIndex=-1] - */ - function Edge(n1, n2, dataIndex) { - - /** - * 节点1,如果是有向图则为源节点 - * @type {module:echarts/data/Graph.Node} - */ - this.node1 = n1; - - /** - * 节点2,如果是有向图则为目标节点 - * @type {module:echarts/data/Graph.Node} - */ - this.node2 = n2; - - this.dataIndex = dataIndex == null ? -1 : dataIndex; - } - - /** - * @param {string} [path] - * @return {module:echarts/model/Model} - */ - Edge.prototype.getModel = function (path) { - if (this.dataIndex < 0) { - return; - } - var graph = this.hostGraph; - var itemModel = graph.edgeData.getItemModel(this.dataIndex); - - return itemModel.getModel(path); - }; - - var createGraphDataProxyMixin = function (hostName, dataName) { - return { - /** - * @param {string=} [dimension='value'] Default 'value'. can be 'a', 'b', 'c', 'd', 'e'. - * @return {number} - */ - getValue: function (dimension) { - var data = this[hostName][dataName]; - return data.get(data.getDimension(dimension || 'value'), this.dataIndex); - }, - - /** - * @param {Object|string} key - * @param {*} [value] - */ - setVisual: function (key, value) { - this.dataIndex >= 0 - && this[hostName][dataName].setItemVisual(this.dataIndex, key, value); - }, - - /** - * @param {string} key - * @return {boolean} - */ - getVisual: function (key, ignoreParent) { - return this[hostName][dataName].getItemVisual(this.dataIndex, key, ignoreParent); - }, - - /** - * @param {Object} layout - * @return {boolean} [merge=false] - */ - setLayout: function (layout, merge) { - this.dataIndex >= 0 - && this[hostName][dataName].setItemLayout(this.dataIndex, layout, merge); - }, - - /** - * @return {Object} - */ - getLayout: function () { - return this[hostName][dataName].getItemLayout(this.dataIndex); - }, - - /** - * @return {module:zrender/Element} - */ - getGraphicEl: function () { - return this[hostName][dataName].getItemGraphicEl(this.dataIndex); - }, - - /** - * @return {number} - */ - getRawIndex: function () { - return this[hostName][dataName].getRawIndex(this.dataIndex); - } - }; - }; - - zrUtil.mixin(Node, createGraphDataProxyMixin('hostGraph', 'data')); - zrUtil.mixin(Edge, createGraphDataProxyMixin('hostGraph', 'edgeData')); - - Graph.Node = Node; - Graph.Edge = Edge; - - return Graph; -}); -define('echarts/chart/helper/createGraphFromNodeEdge',['require','../../data/List','../../data/Graph','../../data/helper/linkList','../../data/helper/completeDimensions','zrender/core/util'],function (require) { - - var List = require('../../data/List'); - var Graph = require('../../data/Graph'); - var linkList = require('../../data/helper/linkList'); - var completeDimensions = require('../../data/helper/completeDimensions'); - var zrUtil = require('zrender/core/util'); - - return function (nodes, edges, hostModel, directed) { - var graph = new Graph(directed); - for (var i = 0; i < nodes.length; i++) { - graph.addNode(zrUtil.retrieve( - // Id, name, dataIndex - nodes[i].id, nodes[i].name, i - ), i); - } - - var linkNameList = []; - var validEdges = []; - for (var i = 0; i < edges.length; i++) { - var link = edges[i]; - // addEdge may fail when source or target not exists - if (graph.addEdge(link.source, link.target, i)) { - validEdges.push(link); - linkNameList.push(zrUtil.retrieve(link.id, link.source + ' - ' + link.target)); - } - } - - // FIXME - var dimensionNames = completeDimensions(['value'], nodes); - - var nodeData = new List(dimensionNames, hostModel); - var edgeData = new List(['value'], hostModel); - - nodeData.initData(nodes); - edgeData.initData(validEdges, linkNameList); - - graph.setEdgeData(edgeData); - - linkList.linkToGraph(nodeData, graph); - // Update dataIndex of nodes and edges because invalid edge may be removed - graph.update(); - - return graph; - }; -}); -define('echarts/chart/graph/GraphSeries',['require','../../data/List','zrender/core/util','../helper/createGraphFromNodeEdge','../../echarts'],function (require) { - - - - var List = require('../../data/List'); - var zrUtil = require('zrender/core/util'); - - var createGraphFromNodeEdge = require('../helper/createGraphFromNodeEdge'); - - var GraphSeries = require('../../echarts').extendSeriesModel({ - - type: 'series.graph', - - init: function (option) { - GraphSeries.superApply(this, 'init', arguments); - - // Provide data for legend select - this.legendDataProvider = function () { - return this._categoriesData; - }; - - this._updateCategoriesData(); - }, - - mergeOption: function (option) { - GraphSeries.superApply(this, 'mergeOption', arguments); - - this._updateCategoriesData(); - }, - - getInitialData: function (option, ecModel) { - var edges = option.edges || option.links; - var nodes = option.data || option.nodes; - if (nodes && edges) { - var graph = createGraphFromNodeEdge(nodes, edges, this, true); - var list = graph.data; - var self = this; - // Overwrite list.getItemModel to - list.wrapMethod('getItemModel', function (model) { - var categoriesModels = self._categoriesModels; - var categoryIdx = model.getShallow('category'); - var categoryModel = categoriesModels[categoryIdx]; - if (categoryModel) { - categoryModel.parentModel = model.parentModel; - model.parentModel = categoryModel; - } - return model; - }); - return list; - } - }, - - restoreData: function () { - GraphSeries.superApply(this, 'restoreData', arguments); - this.getGraph().restoreData(); - }, - - /** - * @return {module:echarts/data/Graph} - */ - getGraph: function () { - return this.getData().graph; - }, - - /** - * @return {module:echarts/data/List} - */ - getEdgeData: function () { - return this.getGraph().edgeData; - }, - - /** - * @return {module:echarts/data/List} - */ - getCategoriesData: function () { - return this._categoriesData; - }, - - _updateCategoriesData: function () { - var categories = zrUtil.map(this.option.categories || [], function (category) { - // Data must has value - return category.value != null ? category : zrUtil.extend({ - value: 0 - }, category); - }); - var categoriesData = new List(['value'], this); - categoriesData.initData(categories); - - this._categoriesData = categoriesData; - - this._categoriesModels = categoriesData.mapArray(function (idx) { - return categoriesData.getItemModel(idx, true); - }); - }, - - /** - * @param {number} zoom - */ - setRoamZoom: function (zoom) { - var roamDetail = this.option.roamDetail; - roamDetail && (roamDetail.zoom = zoom); - }, - - /** - * @param {number} x - * @param {number} y - */ - setRoamPan: function (x, y) { - var roamDetail = this.option.roamDetail; - if (roamDetail) { - roamDetail.x = x; - roamDetail.y = y; - } - }, - - defaultOption: { - zlevel: 0, - z: 2, - - color: ['#61a0a8', '#d14a61', '#fd9c35', '#675bba', '#fec42c', - '#dd4444', '#fd9c35', '#cd4870'], - - coordinateSystem: 'view', - - legendHoverLink: true, - - hoverAnimation: true, - - layout: null, - - // Configuration of force - force: { - initLayout: null, - repulsion: 50, - gravity: 0.1, - edgeLength: 30, - - layoutAnimation: true - }, - - left: 'center', - top: 'center', - // right: null, - // bottom: null, - // width: '80%', - // height: '80%', - - symbol: 'circle', - symbolSize: 10, - - draggable: false, - - roam: false, - roamDetail: { - x: 0, - y: 0, - zoom: 1 - }, - - // Symbol size scale ratio in roam - nodeScaleRatio: 0.6, - - // Line width scale ratio in roam - // edgeScaleRatio: 0.1, - - // categories: [], - - // data: [] - // Or - // nodes: [] - // - // links: [] - // Or - // edges: [] - - label: { - normal: { - show: false - }, - emphasis: { - show: true - } - }, - - itemStyle: { - normal: {}, - emphasis: {} - }, - - lineStyle: { - normal: { - color: '#aaa', - width: 1, - curveness: 0, - opacity: 0.5 - }, - emphasis: {} - } - } - }); - - return GraphSeries; -}); -/** - * Line path for bezier and straight line draw - */ -define('echarts/chart/helper/LinePath',['require','../../util/graphic'],function (require) { - var graphic = require('../../util/graphic'); - - var straightLineProto = graphic.Line.prototype; - var bezierCurveProto = graphic.BezierCurve.prototype; - - return graphic.extendShape({ - - type: 'ec-line', - - style: { - stroke: '#000', - fill: null - }, - - shape: { - x1: 0, - y1: 0, - x2: 0, - y2: 0, - percent: 1, - cpx1: null, - cpy1: null - }, - - buildPath: function (ctx, shape) { - (shape.cpx1 == null || shape.cpy1 == null - ? straightLineProto : bezierCurveProto).buildPath(ctx, shape); - }, - - pointAt: function (t) { - var shape = this.shape; - return shape.cpx1 == null || shape.cpy1 == null - ? straightLineProto.pointAt.call(this, t) - : bezierCurveProto.pointAt.call(this, t); - } - }); -}); -/** - * @module echarts/chart/helper/Line - */ -define('echarts/chart/helper/Line',['require','../../util/symbol','zrender/core/vector','./LinePath','../../util/graphic','zrender/core/util','../../util/number'],function (require) { - - var symbolUtil = require('../../util/symbol'); - var vector = require('zrender/core/vector'); - var LinePath = require('./LinePath'); - var graphic = require('../../util/graphic'); - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../../util/number'); - - /** - * @inner - */ - function createSymbol(name, data, idx) { - var color = data.getItemVisual(idx, 'color'); - var symbolType = data.getItemVisual(idx, 'symbol'); - var symbolSize = data.getItemVisual(idx, 'symbolSize'); - - if (symbolType === 'none') { - return; - } - - if (!zrUtil.isArray(symbolSize)) { - symbolSize = [symbolSize, symbolSize]; - } - var symbolPath = symbolUtil.createSymbol( - symbolType, -symbolSize[0] / 2, -symbolSize[1] / 2, - symbolSize[0], symbolSize[1], color - ); - symbolPath.name = name; - - return symbolPath; - } - - function createLine(points) { - var line = new LinePath({ - name: 'line', - style: { - strokeNoScale: true - } - }); - setLinePoints(line.shape, points); - return line; - } - - function setLinePoints(targetShape, points) { - var p1 = points[0]; - var p2 = points[1]; - var cp1 = points[2]; - targetShape.x1 = p1[0]; - targetShape.y1 = p1[1]; - targetShape.x2 = p2[0]; - targetShape.y2 = p2[1]; - targetShape.percent = 1; - - if (cp1) { - targetShape.cpx1 = cp1[0]; - targetShape.cpy1 = cp1[1]; - } - } - - function isSymbolArrow(symbol) { - return symbol.type === 'symbol' && symbol.shape.symbolType === 'arrow'; - } - - function updateSymbolBeforeLineUpdate () { - var lineGroup = this; - var line = lineGroup.childOfName('line'); - // If line not changed - if (!this.__dirty && !line.__dirty) { - return; - } - var symbolFrom = lineGroup.childOfName('fromSymbol'); - var symbolTo = lineGroup.childOfName('toSymbol'); - var label = lineGroup.childOfName('label'); - var fromPos = line.pointAt(0); - var toPos = line.pointAt(line.shape.percent); - - var d = vector.sub([], toPos, fromPos); - vector.normalize(d, d); - - if (symbolFrom) { - symbolFrom.attr('position', fromPos); - // Rotate the arrow - // FIXME Hard coded ? - if (isSymbolArrow(symbolTo)) { - symbolTo.attr('rotation', tangentRotation(fromPos, toPos)); - } - } - if (symbolTo) { - symbolTo.attr('position', toPos); - if (isSymbolArrow(symbolFrom)) { - symbolFrom.attr('rotation', tangentRotation(toPos, fromPos)); - } - } - - label.attr('position', toPos); - - var textPosition; - var textAlign; - var textBaseline; - // End - if (label.__position === 'end') { - textPosition = [d[0] * 5 + toPos[0], d[1] * 5 + toPos[1]]; - textAlign = d[0] > 0.8 ? 'left' : (d[0] < -0.8 ? 'right' : 'center'); - textBaseline = d[1] > 0.8 ? 'top' : (d[1] < -0.8 ? 'bottom' : 'middle'); - } - // Start - else { - textPosition = [-d[0] * 5 + fromPos[0], -d[1] * 5 + fromPos[1]]; - textAlign = d[0] > 0.8 ? 'right' : (d[0] < -0.8 ? 'left' : 'center'); - textBaseline = d[1] > 0.8 ? 'bottom' : (d[1] < -0.8 ? 'top' : 'middle'); - } - label.attr({ - style: { - // Use the user specified text align and baseline first - textBaseline: label.__textBaseline || textBaseline, - textAlign: label.__textAlign || textAlign - }, - position: textPosition - }); - } - - function tangentRotation(p1, p2) { - return -Math.PI / 2 - Math.atan2( - p2[1] - p1[1], p2[0] - p1[0] - ); - } - - /** - * @constructor - * @extends {module:zrender/graphic/Group} - * @alias {module:echarts/chart/helper/Line} - */ - function Line(lineData, fromData, toData, idx) { - graphic.Group.call(this); - - this._createLine(lineData, fromData, toData, idx); - } - - var lineProto = Line.prototype; - - // Update symbol position and rotation - lineProto.beforeUpdate = updateSymbolBeforeLineUpdate; - - lineProto._createLine = function (lineData, fromData, toData, idx) { - var seriesModel = lineData.hostModel; - var linePoints = lineData.getItemLayout(idx); - - var line = createLine(linePoints); - line.shape.percent = 0; - graphic.initProps(line, { - shape: { - percent: 1 - } - }, seriesModel); - - this.add(line); - - var label = new graphic.Text({ - name: 'label' - }); - this.add(label); - - if (fromData) { - var symbolFrom = createSymbol('fromSymbol', fromData, idx); - // symbols must added after line to make sure - // it will be updated after line#update. - // Or symbol position and rotation update in line#beforeUpdate will be one frame slow - this.add(symbolFrom); - - this._fromSymbolType = fromData.getItemVisual(idx, 'symbol'); - } - if (toData) { - var symbolTo = createSymbol('toSymbol', toData, idx); - this.add(symbolTo); - - this._toSymbolType = toData.getItemVisual(idx, 'symbol'); - } - - this._updateCommonStl(lineData, fromData, toData, idx); - }; - - lineProto.updateData = function (lineData, fromData, toData, idx) { - var seriesModel = lineData.hostModel; - - var line = this.childOfName('line'); - var linePoints = lineData.getItemLayout(idx); - var target = { - shape: {} - }; - setLinePoints(target.shape, linePoints); - graphic.updateProps(line, target, seriesModel); - - // Symbol changed - if (fromData) { - var fromSymbolType = fromData.getItemVisual(idx, 'symbol'); - if (this._fromSymbolType !== fromSymbolType) { - var symbolFrom = createSymbol('fromSymbol', fromData, idx); - this.remove(line.childOfName('fromSymbol')); - this.add(symbolFrom); - } - this._fromSymbolType = fromSymbolType; - } - if (toData) { - var toSymbolType = toData.getItemVisual(idx, 'symbol'); - // Symbol changed - if (toSymbolType !== this._toSymbolType) { - var symbolTo = createSymbol('toSymbol', toData, idx); - this.remove(line.childOfName('toSymbol')); - this.add(symbolTo); - } - this._toSymbolType = toSymbolType; - } - - this._updateCommonStl(lineData, fromData, toData, idx); - }; - - lineProto._updateCommonStl = function (lineData, fromData, toData, idx) { - var seriesModel = lineData.hostModel; - - var line = this.childOfName('line'); - var itemModel = lineData.getItemModel(idx); - - var labelModel = itemModel.getModel('label.normal'); - var textStyleModel = labelModel.getModel('textStyle'); - var labelHoverModel = itemModel.getModel('label.emphasis'); - var textStyleHoverModel = labelHoverModel.getModel('textStyle'); - - var defaultText = numberUtil.round(seriesModel.getRawValue(idx)); - if (isNaN(defaultText)) { - // Use name - defaultText = lineData.getName(idx); - } - line.setStyle(zrUtil.extend( - { - stroke: lineData.getItemVisual(idx, 'color') - }, - itemModel.getModel('lineStyle.normal').getLineStyle() - )); - - var label = this.childOfName('label'); - label.setStyle({ - text: labelModel.get('show') - ? zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'normal'), - defaultText - ) - : '', - textFont: textStyleModel.getFont(), - fill: textStyleModel.getTextColor() || lineData.getItemVisual(idx, 'color') - }); - label.hoverStyle = { - text: labelHoverModel.get('show') - ? zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'emphasis'), - defaultText - ) - : '', - textFont: textStyleModel.getFont(), - fill: textStyleHoverModel.getTextColor() - }; - label.__textAlign = textStyleModel.get('align'); - label.__textBaseline = textStyleModel.get('baseline'); - label.__position = labelModel.get('position'); - - graphic.setHoverStyle( - this, itemModel.getModel('lineStyle.emphasis').getLineStyle() - ); - }; - - lineProto.updateLayout = function (lineData, fromData, toData, idx) { - var points = lineData.getItemLayout(idx); - var linePath = this.childOfName('line'); - setLinePoints(linePath.shape, points); - linePath.dirty(true); - fromData && fromData.getItemGraphicEl(idx).attr('position', points[0]); - toData && toData.getItemGraphicEl(idx).attr('position', points[1]); - }; - - zrUtil.inherits(Line, graphic.Group); - - return Line; -}); -/** - * @module echarts/chart/helper/LineDraw - */ -define('echarts/chart/helper/LineDraw',['require','../../util/graphic','./Line'],function (require) { - - var graphic = require('../../util/graphic'); - var LineGroup = require('./Line'); - - /** - * @alias module:echarts/component/marker/LineDraw - * @constructor - */ - function LineDraw(ctor) { - this._ctor = ctor || LineGroup; - this.group = new graphic.Group(); - } - - var lineDrawProto = LineDraw.prototype; - - /** - * @param {module:echarts/data/List} lineData - * @param {module:echarts/data/List} [fromData] - * @param {module:echarts/data/List} [toData] - */ - lineDrawProto.updateData = function (lineData, fromData, toData) { - - var oldLineData = this._lineData; - var group = this.group; - var LineCtor = this._ctor; - - lineData.diff(oldLineData) - .add(function (idx) { - var lineGroup = new LineCtor(lineData, fromData, toData, idx); - - lineData.setItemGraphicEl(idx, lineGroup); - - group.add(lineGroup); - }) - .update(function (newIdx, oldIdx) { - var lineGroup = oldLineData.getItemGraphicEl(oldIdx); - lineGroup.updateData(lineData, fromData, toData, newIdx); - - lineData.setItemGraphicEl(newIdx, lineGroup); - - group.add(lineGroup); - }) - .remove(function (idx) { - group.remove(oldLineData.getItemGraphicEl(idx)); - }) - .execute(); - - this._lineData = lineData; - this._fromData = fromData; - this._toData = toData; - }; - - lineDrawProto.updateLayout = function () { - var lineData = this._lineData; - lineData.eachItemGraphicEl(function (el, idx) { - el.updateLayout(lineData, this._fromData, this._toData, idx); - }, this); - }; - - lineDrawProto.remove = function () { - this.group.removeAll(); - }; - - return LineDraw; -}); + -define('echarts/chart/graph/GraphView',['require','../helper/SymbolDraw','../helper/LineDraw','../../component/helper/RoamController','../../util/model','../../util/graphic','../../echarts'],function (require) { - - var SymbolDraw = require('../helper/SymbolDraw'); - var LineDraw = require('../helper/LineDraw'); - var RoamController = require('../../component/helper/RoamController'); - - var modelUtil = require('../../util/model'); - var graphic = require('../../util/graphic'); - - require('../../echarts').extendChartView({ - - type: 'graph', - - init: function (ecModel, api) { - var symbolDraw = new SymbolDraw(); - var lineDraw = new LineDraw(); - var group = this.group; - - var controller = new RoamController(api.getZr(), group); - - group.add(symbolDraw.group); - group.add(lineDraw.group); - - this._symbolDraw = symbolDraw; - this._lineDraw = lineDraw; - this._controller = controller; - - this._firstRender = true; - }, - - render: function (seriesModel, ecModel, api) { - var coordSys = seriesModel.coordinateSystem; - // Only support view and geo coordinate system - if (coordSys.type !== 'geo' && coordSys.type !== 'view') { - return; - } - - var data = seriesModel.getData(); - this._model = seriesModel; - - var symbolDraw = this._symbolDraw; - var lineDraw = this._lineDraw; - - symbolDraw.updateData(data); - - var edgeData = data.graph.edgeData; - var rawOption = seriesModel.option; - var formatModel = modelUtil.createDataFormatModel( - seriesModel, edgeData, rawOption.edges || rawOption.links - ); - formatModel.formatTooltip = function (dataIndex) { - var params = this.getDataParams(dataIndex); - var rawDataOpt = params.data; - var html = rawDataOpt.source + ' > ' + rawDataOpt.target; - if (params.value) { - html += ':' + params.value; - } - return html; - }; - lineDraw.updateData(edgeData, null, null); - edgeData.eachItemGraphicEl(function (el) { - el.traverse(function (child) { - child.hostModel = formatModel; - }); - }); - - // Save the original lineWidth - data.graph.eachEdge(function (edge) { - edge.__lineWidth = edge.getModel('lineStyle.normal').get('width'); - }); - - var group = this.group; - var groupNewProp = { - position: coordSys.position, - scale: coordSys.scale - }; - if (this._firstRender) { - group.attr(groupNewProp); - } - else { - graphic.updateProps(group, groupNewProp, seriesModel); - } - - this._nodeScaleRatio = seriesModel.get('nodeScaleRatio'); - // this._edgeScaleRatio = seriesModel.get('edgeScaleRatio'); - - this._updateNodeAndLinkScale(); - - this._updateController(seriesModel, coordSys, api); - - clearTimeout(this._layoutTimeout); - var forceLayout = seriesModel.forceLayout; - var layoutAnimation = seriesModel.get('force.layoutAnimation'); - if (forceLayout) { - this._startForceLayoutIteration(forceLayout, layoutAnimation); - } - // Update draggable - data.eachItemGraphicEl(function (el, idx) { - var draggable = data.getItemModel(idx).get('draggable'); - if (draggable && forceLayout) { - el.on('drag', function () { - forceLayout.warmUp(); - !this._layouting - && this._startForceLayoutIteration(forceLayout, layoutAnimation); - forceLayout.setFixed(idx); - // Write position back to layout - data.setItemLayout(idx, el.position); - }, this).on('dragend', function () { - forceLayout.setUnfixed(idx); - }, this); - } - else { - el.off('drag'); - } - el.setDraggable(draggable); - }, this); - - this._firstRender = false; - }, - - _startForceLayoutIteration: function (forceLayout, layoutAnimation) { - var self = this; - (function step() { - forceLayout.step(function (stopped) { - self.updateLayout(); - (self._layouting = !stopped) && ( - layoutAnimation - ? (self._layoutTimeout = setTimeout(step, 16)) - : step() - ); - }); - })(); - }, - - _updateController: function (seriesModel, coordSys, api) { - var controller = this._controller; - controller.rect = coordSys.getViewRect(); - - controller.enable(seriesModel.get('roam')); - - controller - .off('pan') - .off('zoom') - .on('pan', function (dx, dy) { - api.dispatchAction({ - seriesId: seriesModel.id, - type: 'graphRoam', - dx: dx, - dy: dy - }); - }) - .on('zoom', function (zoom, mouseX, mouseY) { - api.dispatchAction({ - seriesId: seriesModel.id, - type: 'graphRoam', - zoom: zoom, - originX: mouseX, - originY: mouseY - }); - }) - .on('zoom', this._updateNodeAndLinkScale, this); - }, - - _updateNodeAndLinkScale: function () { - var seriesModel = this._model; - var data = seriesModel.getData(); - - var group = this.group; - var nodeScaleRatio = this._nodeScaleRatio; - // var edgeScaleRatio = this._edgeScaleRatio; - - // Assume scale aspect is 1 - var groupScale = group.scale[0]; - - var nodeScale = (groupScale - 1) * nodeScaleRatio + 1; - // var edgeScale = (groupScale - 1) * edgeScaleRatio + 1; - var invScale = [ - nodeScale / groupScale, - nodeScale / groupScale - ]; - - data.eachItemGraphicEl(function (el, idx) { - el.attr('scale', invScale); - }); - // data.graph.eachEdge(function (edge) { - // var lineGroup = edge.getGraphicEl(); - // // FIXME - // lineGroup.childOfName('line').setStyle( - // 'lineWidth', - // edge.__lineWidth * edgeScale / groupScale - // ); - // }); - }, - - updateLayout: function (seriesModel, ecModel) { - this._symbolDraw.updateLayout(); - this._lineDraw.updateLayout(); - }, - - remove: function (ecModel, api) { - this._symbolDraw && this._symbolDraw.remove(); - this._lineDraw && this._lineDraw.remove(); - } - }); -}); -define('echarts/chart/graph/roamAction',['require','../../echarts','../../action/roamHelper'],function (require) { - - var echarts = require('../../echarts'); - var roamHelper = require('../../action/roamHelper'); - - var actionInfo = { - type: 'graphRoam', - event: 'graphRoam', - update: 'none' - }; - - /** - * @payload - * @property {string} name Series name - * @property {number} [dx] - * @property {number} [dy] - * @property {number} [zoom] - * @property {number} [originX] - * @property {number} [originY] - */ - - echarts.registerAction(actionInfo, function (payload, ecModel) { - ecModel.eachComponent({mainType: 'series', query: payload}, function (seriesModel) { - var coordSys = seriesModel.coordinateSystem; - - var roamDetailModel = seriesModel.getModel('roamDetail'); - var res = roamHelper.calcPanAndZoom(roamDetailModel, payload); - - seriesModel.setRoamPan - && seriesModel.setRoamPan(res.x, res.y); - - seriesModel.setRoamZoom - && seriesModel.setRoamZoom(res.zoom); - - coordSys && coordSys.setPan(res.x, res.y); - coordSys && coordSys.setZoom(res.zoom); - }); - }); -}); -define('echarts/chart/graph/categoryFilter',['require'],function (require) { - - return function (ecModel) { - var legendModels = ecModel.findComponents({ - mainType: 'legend' - }); - if (!legendModels || !legendModels.length) { - return; - } - ecModel.eachSeriesByType('graph', function (graphSeries) { - var categoriesData = graphSeries.getCategoriesData(); - var graph = graphSeries.getGraph(); - var data = graph.data; - - var categoryNames = categoriesData.mapArray(categoriesData.getName); - - data.filterSelf(function (idx) { - var model = data.getItemModel(idx); - var category = model.getShallow('category'); - if (category != null) { - if (typeof category === 'number') { - category = categoryNames[category]; - } - // If in any legend component the status is not selected. - for (var i = 0; i < legendModels.length; i++) { - if (!legendModels[i].isSelected(category)) { - return false; - } - } - } - return true; - }); - }, this); - }; -}); -define('echarts/chart/graph/categoryVisual',['require'],function (require) { - - return function (ecModel) { - ecModel.eachSeriesByType('graph', function (seriesModel) { - var colorList = seriesModel.get('color'); - var categoriesData = seriesModel.getCategoriesData(); - var data = seriesModel.getData(); - - var categoryNameIdxMap = {}; - - categoriesData.each(function (idx) { - categoryNameIdxMap[categoriesData.getName(idx)] = idx; - - var itemModel = categoriesData.getItemModel(idx); - var rawIdx = categoriesData.getRawIndex(idx); - var color = itemModel.get('itemStyle.normal.color') - || colorList[rawIdx % colorList.length]; - categoriesData.setItemVisual(idx, 'color', color); - }); - - // Assign category color to visual - if (categoriesData.count()) { - data.each(function (idx) { - var model = data.getItemModel(idx); - var category = model.getShallow('category'); - if (category != null) { - if (typeof category === 'string') { - category = categoryNameIdxMap[category]; - } - data.setItemVisual( - idx, 'color', - categoriesData.getItemVisual(category, 'color') - ); - } - }); - } - }); - }; -}); -define('echarts/chart/graph/simpleLayoutHelper',['require'],function (require) { - return function (seriesModel) { - var coordSys = seriesModel.coordinateSystem; - if (coordSys && coordSys.type !== 'view') { - return; - } - var graph = seriesModel.getGraph(); - - graph.eachNode(function (node) { - var model = node.getModel(); - node.setLayout([+model.get('x'), +model.get('y')]); - }); - - graph.eachEdge(function (edge) { - var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0; - var p1 = edge.node1.getLayout(); - var p2 = edge.node2.getLayout(); - var cp1; - if (curveness > 0) { - cp1 = [ - (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * curveness, - (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * curveness - ]; - } - edge.setLayout([p1, p2, cp1]); - }); - }; -}); -define('echarts/chart/graph/simpleLayout',['require','./simpleLayoutHelper'],function (require) { - - var simpleLayoutHelper = require('./simpleLayoutHelper'); - return function (ecModel, api) { - ecModel.eachSeriesByType('graph', function (seriesModel) { - var layout = seriesModel.get('layout'); - if (!layout || layout === 'none') { - simpleLayoutHelper(seriesModel); - } - }); - }; -}); -define('echarts/chart/graph/circularLayoutHelper',['require'],function (require) { - return function (seriesModel) { - var coordSys = seriesModel.coordinateSystem; - if (coordSys && coordSys.type !== 'view') { - return; - } - - var rect = coordSys.getBoundingRect(); - - var nodeData = seriesModel.getData(); - var graph = nodeData.graph; - - var angle = 0; - var sum = nodeData.getSum('value'); - var unitAngle = Math.PI * 2 / (sum || nodeData.count()); - - var cx = rect.width / 2 + rect.x; - var cy = rect.height / 2 + rect.y; - - var r = Math.min(rect.width, rect.height) / 2; - - graph.eachNode(function (node) { - var value = node.getValue('value'); - - angle += unitAngle * (sum ? value : 2) / 2; - - node.setLayout([ - r * Math.cos(angle) + cx, - r * Math.sin(angle) + cy - ]); - - angle += unitAngle * (sum ? value : 2) / 2; - }); - - graph.eachEdge(function (edge) { - var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0; - var p1 = edge.node1.getLayout(); - var p2 = edge.node2.getLayout(); - var cp1; - if (curveness > 0) { - cp1 = [cx, cy]; - } - edge.setLayout([p1, p2, cp1]); - }); - }; -}); -define('echarts/chart/graph/circularLayout',['require','./circularLayoutHelper'],function (require) { - var circularLayoutHelper = require('./circularLayoutHelper'); - return function (ecModel, api) { - ecModel.eachSeriesByType('graph', function (seriesModel) { - if (seriesModel.get('layout') === 'circular') { - circularLayoutHelper(seriesModel); - } - }); - }; -}); -define('echarts/chart/graph/forceHelper',['require','zrender/core/vector'],function (require) { - - var vec2 = require('zrender/core/vector'); - var scaleAndAdd = vec2.scaleAndAdd; - - // function adjacentNode(n, e) { - // return e.n1 === n ? e.n2 : e.n1; - // } - - return function (nodes, edges, opts) { - var rect = opts.rect; - var width = rect.width; - var height = rect.height; - var center = [rect.x + width / 2, rect.y + height / 2]; - // var scale = opts.scale || 1; - var gravity = opts.gravity == null ? 0.1 : opts.gravity; - - // for (var i = 0; i < edges.length; i++) { - // var e = edges[i]; - // var n1 = e.n1; - // var n2 = e.n2; - // n1.edges = n1.edges || []; - // n2.edges = n2.edges || []; - // n1.edges.push(e); - // n2.edges.push(e); - // } - // Init position - for (var i = 0; i < nodes.length; i++) { - var n = nodes[i]; - if (!n.p) { - // Use the position from first adjecent node with defined position - // Or use a random position - // From d3 - // if (n.edges) { - // var j = -1; - // while (++j < n.edges.length) { - // var e = n.edges[j]; - // var other = adjacentNode(n, e); - // if (other.p) { - // n.p = vec2.clone(other.p); - // break; - // } - // } - // } - // if (!n.p) { - n.p = vec2.create( - width * (Math.random() - 0.5) + center[0], - height * (Math.random() - 0.5) + center[1] - ); - // } - } - n.pp = vec2.clone(n.p); - n.edges = null; - } - - // Formula in 'Graph Drawing by Force-directed Placement' - // var k = scale * Math.sqrt(width * height / nodes.length); - // var k2 = k * k; - - var friction = 0.6; - - return { - warmUp: function () { - friction = 0.5; - }, - - setFixed: function (idx) { - nodes[idx].fixed = true; - }, - - setUnfixed: function (idx) { - nodes[idx].fixed = false; - }, - - step: function (cb) { - var v12 = []; - var nLen = nodes.length; - for (var i = 0; i < edges.length; i++) { - var e = edges[i]; - var n1 = e.n1; - var n2 = e.n2; - - vec2.sub(v12, n2.p, n1.p); - var d = vec2.len(v12) - e.d; - var w = n2.w / (n1.w + n2.w); - vec2.normalize(v12, v12); - - !n1.fixed && scaleAndAdd(n1.p, n1.p, v12, w * d * friction); - !n2.fixed && scaleAndAdd(n2.p, n2.p, v12, -(1 - w) * d * friction); - } - // Gravity - for (var i = 0; i < nLen; i++) { - var n = nodes[i]; - if (!n.fixed) { - vec2.sub(v12, center, n.p); - // var d = vec2.len(v12); - // vec2.scale(v12, v12, 1 / d); - // var gravityFactor = gravity; - vec2.scaleAndAdd(n.p, n.p, v12, gravity * friction); - } - } - - // Repulsive - // PENDING - for (var i = 0; i < nLen; i++) { - var n1 = nodes[i]; - for (var j = i + 1; j < nLen; j++) { - var n2 = nodes[j]; - vec2.sub(v12, n2.p, n1.p); - var d = vec2.len(v12); - if (d === 0) { - // Random repulse - vec2.set(v12, Math.random() - 0.5, Math.random() - 0.5); - d = 1; - } - var repFact = (n1.rep + n2.rep) / d / d; - !n1.fixed && scaleAndAdd(n1.pp, n1.pp, v12, repFact); - !n2.fixed && scaleAndAdd(n2.pp, n2.pp, v12, -repFact); - } - } - var v = []; - for (var i = 0; i < nLen; i++) { - var n = nodes[i]; - if (!n.fixed) { - vec2.sub(v, n.p, n.pp); - vec2.scaleAndAdd(n.p, n.p, v, friction); - vec2.copy(n.pp, n.p); - } - } - - friction = friction * 0.992; - - cb && cb(nodes, edges, friction < 0.01); - } - }; - }; -}); -define('echarts/chart/graph/forceLayout',['require','./forceHelper','../../util/number','./simpleLayoutHelper','./circularLayoutHelper','zrender/core/vector'],function (require) { - - var forceHelper = require('./forceHelper'); - var numberUtil = require('../../util/number'); - var simpleLayoutHelper = require('./simpleLayoutHelper'); - var circularLayoutHelper = require('./circularLayoutHelper'); - var vec2 = require('zrender/core/vector'); - - return function (ecModel, api) { - ecModel.eachSeriesByType('graph', function (graphSeries) { - if (graphSeries.get('layout') === 'force') { - var preservedPoints = graphSeries.preservedPoints || {}; - var graph = graphSeries.getGraph(); - var nodeData = graph.data; - var edgeData = graph.edgeData; - var forceModel = graphSeries.getModel('force'); - var initLayout = forceModel.get('initLayout'); - if (graphSeries.preservedPoints) { - nodeData.each(function (idx) { - var id = nodeData.getId(idx); - nodeData.setItemLayout(idx, preservedPoints[id] || [NaN, NaN]); - }); - } - else if (!initLayout || initLayout === 'none') { - simpleLayoutHelper(graphSeries); - } - else if (initLayout === 'circular') { - circularLayoutHelper(graphSeries); - } - - var nodeDataExtent = nodeData.getDataExtent('value'); - // var edgeDataExtent = edgeData.getDataExtent('value'); - var repulsion = forceModel.get('repulsion'); - var edgeLength = forceModel.get('edgeLength'); - var nodes = nodeData.mapArray('value', function (value, idx) { - var point = nodeData.getItemLayout(idx); - // var w = numberUtil.linearMap(value, nodeDataExtent, [0, 50]); - var rep = numberUtil.linearMap(value, nodeDataExtent, [0, repulsion]) || (repulsion / 2); - return { - w: rep, - rep: rep, - p: (!point || isNaN(point[0]) || isNaN(point[1])) ? null : point - }; - }); - var edges = edgeData.mapArray('value', function (value, idx) { - var edge = graph.getEdgeByIndex(idx); - // var w = numberUtil.linearMap(value, edgeDataExtent, [0, 100]); - return { - n1: nodes[edge.node1.dataIndex], - n2: nodes[edge.node2.dataIndex], - d: edgeLength, - curveness: edge.getModel().get('lineStyle.normal.curveness') || 0 - }; - }); - - var coordSys = graphSeries.coordinateSystem; - var rect = coordSys.getBoundingRect(); - var forceInstance = forceHelper(nodes, edges, { - rect: rect, - gravity: forceModel.get('gravity') - }); - var oldStep = forceInstance.step; - forceInstance.step = function (cb) { - for (var i = 0, l = nodes.length; i < l; i++) { - if (nodes[i].fixed) { - // Write back to layout instance - vec2.copy(nodes[i].p, graph.getNodeByIndex(i).getLayout()); - } - } - oldStep(function (nodes, edges, stopped) { - for (var i = 0, l = nodes.length; i < l; i++) { - if (!nodes[i].fixed) { - graph.getNodeByIndex(i).setLayout(nodes[i].p); - } - preservedPoints[nodeData.getId(i)] = nodes[i].p; - } - for (var i = 0, l = edges.length; i < l; i++) { - var e = edges[i]; - var p1 = e.n1.p; - var p2 = e.n2.p; - var points = [p1, p2]; - if (e.curveness > 0) { - points.push([ - (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * e.curveness, - (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * e.curveness - ]); - } - graph.getEdgeByIndex(i).setLayout(points); - } - // Update layout - - cb && cb(stopped); - }); - }; - graphSeries.forceLayout = forceInstance; - graphSeries.preservedPoints = preservedPoints; - - // Step to get the layout - forceInstance.step(); - } - else { - // Remove prev injected forceLayout instance - graphSeries.forceLayout = null; - } - }); - }; -}); -define('echarts/chart/graph/createView',['require','../../coord/View','../../util/layout','zrender/core/bbox'],function (require) { - // FIXME Where to create the simple view coordinate system - var View = require('../../coord/View'); - var layout = require('../../util/layout'); - var bbox = require('zrender/core/bbox'); - - function getViewRect(seriesModel, api, aspect) { - var option = seriesModel.getBoxLayoutParams(); - option.aspect = aspect; - return layout.getLayoutRect(option, { - width: api.getWidth(), - height: api.getHeight() - }); - } - - return function (ecModel, api) { - var viewList = []; - ecModel.eachSeriesByType('graph', function (seriesModel) { - var coordSysType = seriesModel.get('coordinateSystem'); - if (!coordSysType || coordSysType === 'view') { - var viewCoordSys = new View(); - viewList.push(viewCoordSys); - - var data = seriesModel.getData(); - var positions = data.mapArray(function (idx) { - var itemModel = data.getItemModel(idx); - return [+itemModel.get('x'), +itemModel.get('y')]; - }); - - var min = []; - var max = []; - - bbox.fromPoints(positions, min, max); - - // FIXME If get view rect after data processed? - var viewRect = getViewRect( - seriesModel, api, (max[0] - min[0]) / (max[1] - min[1]) || 1 - ); - // Position may be NaN, use view rect instead - if (isNaN(min[0]) || isNaN(min[1])) { - min = [viewRect.x, viewRect.y]; - max = [viewRect.x + viewRect.width, viewRect.y + viewRect.height]; - } - - var bbWidth = max[0] - min[0]; - var bbHeight = max[1] - min[1]; - - var viewWidth = viewRect.width; - var viewHeight = viewRect.height; - - viewCoordSys = seriesModel.coordinateSystem = new View(); - - viewCoordSys.setBoundingRect( - min[0], min[1], bbWidth, bbHeight - ); - viewCoordSys.setViewRect( - viewRect.x, viewRect.y, viewWidth, viewHeight - ); - - // Update roam info - var roamDetailModel = seriesModel.getModel('roamDetail'); - viewCoordSys.setPan(roamDetailModel.get('x') || 0, roamDetailModel.get('y') || 0); - viewCoordSys.setZoom(roamDetailModel.get('zoom') || 1); - } - }); - return viewList; - }; -}); -define('echarts/chart/graph',['require','../echarts','zrender/core/util','./graph/GraphSeries','./graph/GraphView','./graph/roamAction','./graph/categoryFilter','../visual/symbol','./graph/categoryVisual','./graph/simpleLayout','./graph/circularLayout','./graph/forceLayout','./graph/createView'],function (require) { + var zrUtil = __webpack_require__(3); + var echarts = __webpack_require__(1); + + __webpack_require__(250); + __webpack_require__(251); + + echarts.registerVisualCoding('chart', zrUtil.curry( + __webpack_require__(103), 'effectScatter', 'circle', null + )); + echarts.registerLayout(zrUtil.curry( + __webpack_require__(104), 'effectScatter' + )); + + +/***/ }, +/* 250 */ +/***/ function(module, exports, __webpack_require__) { - var echarts = require('../echarts'); - var zrUtil = require('zrender/core/util'); + 'use strict'; - require('./graph/GraphSeries'); - require('./graph/GraphView'); - require('./graph/roamAction'); + var createListFromArray = __webpack_require__(93); + var SeriesModel = __webpack_require__(27); + + module.exports = SeriesModel.extend({ - echarts.registerProcessor('filter', require('./graph/categoryFilter')); + type: 'series.effectScatter', - echarts.registerVisualCoding('chart', zrUtil.curry( - require('../visual/symbol'), 'graph', 'circle', null - )); - echarts.registerVisualCoding('chart', require('./graph/categoryVisual')); + dependencies: ['grid', 'polar'], - echarts.registerLayout(require('./graph/simpleLayout')); - echarts.registerLayout(require('./graph/circularLayout')); - echarts.registerLayout(require('./graph/forceLayout')); + getInitialData: function (option, ecModel) { + var list = createListFromArray(option.data, this, ecModel); + return list; + }, - // Graph view coordinate system - echarts.registerCoordinateSystem('graphView', { - create: require('./graph/createView') - }); -}); -define('echarts/chart/gauge/GaugeSeries',['require','../../data/List','../../model/Series','zrender/core/util'],function (require) { - - var List = require('../../data/List'); - var SeriesModel = require('../../model/Series'); - var zrUtil = require('zrender/core/util'); - - var GaugeSeries = SeriesModel.extend({ - - type: 'series.gauge', - - getInitialData: function (option, ecModel) { - var list = new List(['value'], this); - var dataOpt = option.data || []; - if (!zrUtil.isArray(dataOpt)) { - dataOpt = [dataOpt]; - } - // Only use the first data item - list.initData(dataOpt); - return list; - }, - - defaultOption: { - zlevel: 0, - z: 2, - // 默认全局居中 - center: ['50%', '50%'], - legendHoverLink: true, - radius: '75%', - startAngle: 225, - endAngle: -45, - clockwise: true, - // 最小值 - min: 0, - // 最大值 - max: 100, - // 分割段数,默认为10 - splitNumber: 10, - // 坐标轴线 - axisLine: { - // 默认显示,属性show控制显示与否 - show: true, - lineStyle: { // 属性lineStyle控制线条样式 - color: [[0.2, '#91c7ae'], [0.8, '#63869e'], [1, '#c23531']], - width: 30 - } - }, - // 分隔线 - splitLine: { - // 默认显示,属性show控制显示与否 - show: true, - // 属性length控制线长 - length: 30, - // 属性lineStyle(详见lineStyle)控制线条样式 - lineStyle: { - color: '#eee', - width: 2, - type: 'solid' - } - }, - // 坐标轴小标记 - axisTick: { - // 属性show控制显示与否,默认不显示 - show: true, - // 每份split细分多少段 - splitNumber: 5, - // 属性length控制线长 - length: 8, - // 属性lineStyle控制线条样式 - lineStyle: { - color: '#eee', - width: 1, - type: 'solid' - } - }, - axisLabel: { - show: true, - // formatter: null, - textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE - color: 'auto' - } - }, - pointer: { - show: true, - length: '80%', - width: 8 - }, - itemStyle: { - normal: { - color: 'auto' - } - }, - title: { - show: true, - // x, y,单位px - offsetCenter: [0, '-40%'], - // 其余属性默认使用全局文本样式,详见TEXTSTYLE - textStyle: { - color: '#333', - fontSize: 15 - } - }, - detail: { - show: true, - backgroundColor: 'rgba(0,0,0,0)', - borderWidth: 0, - borderColor: '#ccc', - width: 100, - height: 40, - // x, y,单位px - offsetCenter: [0, '40%'], - // formatter: null, - // 其余属性默认使用全局文本样式,详见TEXTSTYLE - textStyle: { - color: 'auto', - fontSize: 30 - } - } - } - }); - - return GaugeSeries; -}); -define('echarts/chart/gauge/PointerPath',['require','zrender/graphic/Path'],function (require) { - - return require('zrender/graphic/Path').extend({ - - type: 'echartsGaugePointer', - - shape: { - angle: 0, - - width: 10, - - r: 10, - - x: 0, - - y: 0 - }, - - buildPath: function (ctx, shape) { - var mathCos = Math.cos; - var mathSin = Math.sin; - - var r = shape.r; - var width = shape.width; - var angle = shape.angle; - var x = shape.x - mathCos(angle) * width * (width >= r / 3 ? 1 : 2); - var y = shape.y - mathSin(angle) * width * (width >= r / 3 ? 1 : 2); - - angle = shape.angle - Math.PI / 2; - ctx.moveTo(x, y); - ctx.lineTo( - shape.x + mathCos(angle) * width, - shape.y + mathSin(angle) * width - ); - ctx.lineTo( - shape.x + mathCos(shape.angle) * r, - shape.y + mathSin(shape.angle) * r - ); - ctx.lineTo( - shape.x - mathCos(angle) * width, - shape.y - mathSin(angle) * width - ); - ctx.lineTo(x, y); - return; - } - }); -}); -define('echarts/chart/gauge/GaugeView',['require','./PointerPath','../../util/graphic','../../util/number','../../view/Chart'],function (require) { - - var PointerPath = require('./PointerPath'); - - var graphic = require('../../util/graphic'); - var numberUtil = require('../../util/number'); - var parsePercent = numberUtil.parsePercent; - - function parsePosition(seriesModel, api) { - var center = seriesModel.get('center'); - var width = api.getWidth(); - var height = api.getHeight(); - var size = Math.min(width, height); - var cx = parsePercent(center[0], api.getWidth()); - var cy = parsePercent(center[1], api.getHeight()); - var r = parsePercent(seriesModel.get('radius'), size / 2); - - return { - cx: cx, - cy: cy, - r: r - }; - } - - function formatLabel(label, labelFormatter) { - if (labelFormatter) { - if (typeof labelFormatter === 'string') { - label = labelFormatter.replace('{value}', label); - } - else if (typeof labelFormatter === 'function') { - label = labelFormatter(label); - } - } - - return label; - } - - var PI2 = Math.PI * 2; - - var GaugeView = require('../../view/Chart').extend({ - - type: 'gauge', - - render: function (seriesModel, ecModel, api) { - - this.group.removeAll(); - - var colorList = seriesModel.get('axisLine.lineStyle.color'); - var posInfo = parsePosition(seriesModel, api); - - this._renderMain( - seriesModel, ecModel, api, colorList, posInfo - ); - }, - - _renderMain: function (seriesModel, ecModel, api, colorList, posInfo) { - var group = this.group; - - var axisLineModel = seriesModel.getModel('axisLine'); - var lineStyleModel = axisLineModel.getModel('lineStyle'); - - var clockwise = seriesModel.get('clockwise'); - var startAngle = -seriesModel.get('startAngle') / 180 * Math.PI; - var endAngle = -seriesModel.get('endAngle') / 180 * Math.PI; - - var angleRangeSpan = (endAngle - startAngle) % PI2; - - var prevEndAngle = startAngle; - var axisLineWidth = lineStyleModel.get('width'); - - for (var i = 0; i < colorList.length; i++) { - var endAngle = startAngle + angleRangeSpan * colorList[i][0]; - var sector = new graphic.Sector({ - shape: { - startAngle: prevEndAngle, - endAngle: endAngle, - cx: posInfo.cx, - cy: posInfo.cy, - clockwise: clockwise, - r0: posInfo.r - axisLineWidth, - r: posInfo.r - }, - silent: true - }); - - sector.setStyle({ - fill: colorList[i][1] - }); - - sector.setStyle(lineStyleModel.getLineStyle( - // Because we use sector to simulate arc - // so the properties for stroking are useless - ['color', 'borderWidth', 'borderColor'] - )); - - group.add(sector); - - prevEndAngle = endAngle; - } - - var getColor = function (percent) { - // Less than 0 - if (percent <= 0) { - return colorList[0][1]; - } - for (var i = 0; i < colorList.length; i++) { - if (colorList[i][0] >= percent - && (i === 0 ? 0 : colorList[i - 1][0]) < percent - ) { - return colorList[i][1]; - } - } - // More than 1 - return colorList[i - 1][1]; - }; - - if (!clockwise) { - var tmp = startAngle; - startAngle = endAngle; - endAngle = tmp; - } - - this._renderTicks( - seriesModel, ecModel, api, getColor, posInfo, - startAngle, endAngle, clockwise - ); - - this._renderPointer( - seriesModel, ecModel, api, getColor, posInfo, - startAngle, endAngle, clockwise - ); - - this._renderTitle( - seriesModel, ecModel, api, getColor, posInfo - ); - this._renderDetail( - seriesModel, ecModel, api, getColor, posInfo - ); - }, - - _renderTicks: function ( - seriesModel, ecModel, api, getColor, posInfo, - startAngle, endAngle, clockwise - ) { - var group = this.group; - var cx = posInfo.cx; - var cy = posInfo.cy; - var r = posInfo.r; - - var minVal = seriesModel.get('min'); - var maxVal = seriesModel.get('max'); - - var splitLineModel = seriesModel.getModel('splitLine'); - var tickModel = seriesModel.getModel('axisTick'); - var labelModel = seriesModel.getModel('axisLabel'); - - var splitNumber = seriesModel.get('splitNumber'); - var subSplitNumber = tickModel.get('splitNumber'); - - var splitLineLen = parsePercent( - splitLineModel.get('length'), r - ); - var tickLen = parsePercent( - tickModel.get('length'), r - ); - - var angle = startAngle; - var step = (endAngle - startAngle) / splitNumber; - var subStep = step / subSplitNumber; - - var splitLineStyle = splitLineModel.getModel('lineStyle').getLineStyle(); - var tickLineStyle = tickModel.getModel('lineStyle').getLineStyle(); - var textStyleModel = labelModel.getModel('textStyle'); - - for (var i = 0; i <= splitNumber; i++) { - var unitX = Math.cos(angle); - var unitY = Math.sin(angle); - // Split line - if (splitLineModel.get('show')) { - var splitLine = new graphic.Line({ - shape: { - x1: unitX * r + cx, - y1: unitY * r + cy, - x2: unitX * (r - splitLineLen) + cx, - y2: unitY * (r - splitLineLen) + cy - }, - style: splitLineStyle, - silent: true - }); - if (splitLineStyle.stroke === 'auto') { - splitLine.setStyle({ - stroke: getColor(i / splitNumber) - }); - } - - group.add(splitLine); - } - - // Label - if (labelModel.get('show')) { - var label = formatLabel( - numberUtil.round(i / splitNumber * (maxVal - minVal) + minVal), - labelModel.get('formatter') - ); - - var text = new graphic.Text({ - style: { - text: label, - x: unitX * (r - splitLineLen - 5) + cx, - y: unitY * (r - splitLineLen - 5) + cy, - fill: textStyleModel.getTextColor(), - textFont: textStyleModel.getFont(), - textBaseline: unitY < -0.4 ? 'top' : (unitY > 0.4 ? 'bottom' : 'middle'), - textAlign: unitX < -0.4 ? 'left' : (unitX > 0.4 ? 'right' : 'center') - }, - silent: true - }); - if (text.style.fill === 'auto') { - text.setStyle({ - fill: getColor(i / splitNumber) - }); - } - - group.add(text); - } - - // Axis tick - if (tickModel.get('show') && i !== splitNumber) { - for (var j = 0; j <= subSplitNumber; j++) { - var unitX = Math.cos(angle); - var unitY = Math.sin(angle); - var tickLine = new graphic.Line({ - shape: { - x1: unitX * r + cx, - y1: unitY * r + cy, - x2: unitX * (r - tickLen) + cx, - y2: unitY * (r - tickLen) + cy - }, - silent: true, - style: tickLineStyle - }); - - if (tickLineStyle.stroke === 'auto') { - tickLine.setStyle({ - stroke: getColor((i + j / subSplitNumber) / splitNumber) - }); - } - - group.add(tickLine); - angle += subStep; - } - angle -= subStep; - } - else { - angle += step; - } - } - }, - - _renderPointer: function ( - seriesModel, ecModel, api, getColor, posInfo, - startAngle, endAngle, clockwise - ) { - var linearMap = numberUtil.linearMap; - var valueExtent = [+seriesModel.get('min'), +seriesModel.get('max')]; - var angleExtent = [startAngle, endAngle]; - - if (!clockwise) { - angleExtent = angleExtent.reverse(); - } - - var data = seriesModel.getData(); - var oldData = this._data; - - var group = this.group; - - data.diff(oldData) - .add(function (idx) { - var pointer = new PointerPath({ - shape: { - angle: startAngle - } - }); - - graphic.updateProps(pointer, { - shape: { - angle: linearMap(data.get('value', idx), valueExtent, angleExtent) - } - }, seriesModel); - - group.add(pointer); - data.setItemGraphicEl(idx, pointer); - }) - .update(function (newIdx, oldIdx) { - var pointer = oldData.getItemGraphicEl(oldIdx); - - graphic.updateProps(pointer, { - shape: { - angle: linearMap(data.get('value', newIdx), valueExtent, angleExtent) - } - }, seriesModel); - - group.add(pointer); - data.setItemGraphicEl(newIdx, pointer); - }) - .remove(function (idx) { - var pointer = oldData.getItemGraphicEl(idx); - group.remove(pointer); - }) - .execute(); - - data.eachItemGraphicEl(function (pointer, idx) { - var itemModel = data.getItemModel(idx); - var pointerModel = itemModel.getModel('pointer'); - - pointer.attr({ - shape: { - x: posInfo.cx, - y: posInfo.cy, - width: parsePercent( - pointerModel.get('width'), posInfo.r - ), - r: parsePercent(pointerModel.get('length'), posInfo.r) - }, - style: itemModel.getModel('itemStyle.normal').getItemStyle() - }); - - if (pointer.style.fill === 'auto') { - pointer.setStyle('fill', getColor( - (data.get('value', idx) - valueExtent[0]) / (valueExtent[1] - valueExtent[0]) - )); - } - - graphic.setHoverStyle( - pointer, itemModel.getModel('itemStyle.emphasis').getItemStyle() - ); - }); - - this._data = data; - }, - - _renderTitle: function ( - seriesModel, ecModel, api, getColor, posInfo - ) { - var titleModel = seriesModel.getModel('title'); - if (titleModel.get('show')) { - var textStyleModel = titleModel.getModel('textStyle'); - var offsetCenter = titleModel.get('offsetCenter'); - var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r); - var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r); - var text = new graphic.Text({ - style: { - x: x, - y: y, - // FIXME First data name ? - text: seriesModel.getData().getName(0), - fill: textStyleModel.getTextColor(), - textFont: textStyleModel.getFont(), - textAlign: 'center', - textBaseline: 'middle' - } - }); - this.group.add(text); - } - }, - - _renderDetail: function ( - seriesModel, ecModel, api, getColor, posInfo - ) { - var detailModel = seriesModel.getModel('detail'); - var minVal = seriesModel.get('min'); - var maxVal = seriesModel.get('max'); - if (detailModel.get('show')) { - var textStyleModel = detailModel.getModel('textStyle'); - var offsetCenter = detailModel.get('offsetCenter'); - var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r); - var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r); - var width = parsePercent(detailModel.get('width'), posInfo.r); - var height = parsePercent(detailModel.get('height'), posInfo.r); - var value = seriesModel.getData().get('value', 0); - var rect = new graphic.Rect({ - shape: { - x: x - width / 2, - y: y - height / 2, - width: width, - height: height - }, - style: { - text: formatLabel( - // FIXME First data name ? - value, detailModel.get('formatter') - ), - fill: detailModel.get('backgroundColor'), - textFill: textStyleModel.getTextColor(), - textFont: textStyleModel.getFont() - } - }); - if (rect.style.textFill === 'auto') { - rect.setStyle('textFill', getColor((value - minVal) / (maxVal - minVal))); - } - rect.setStyle(detailModel.getItemStyle(['color'])); - this.group.add(rect); - } - } - }); - - return GaugeView; -}); -define('echarts/chart/gauge',['require','./gauge/GaugeSeries','./gauge/GaugeView'],function (require) { - require('./gauge/GaugeSeries'); - require('./gauge/GaugeView'); -}); -define('echarts/chart/funnel/FunnelSeries',['require','../../data/List','../../util/model','../../data/helper/completeDimensions','../../echarts'],function(require) { - - - - var List = require('../../data/List'); - var modelUtil = require('../../util/model'); - var completeDimensions = require('../../data/helper/completeDimensions'); - - var FunnelSeries = require('../../echarts').extendSeriesModel({ - - type: 'series.funnel', - - init: function (option) { - FunnelSeries.superApply(this, 'init', arguments); - - // Enable legend selection for each data item - // Use a function instead of direct access because data reference may changed - this.legendDataProvider = function () { - return this._dataBeforeProcessed; - }; - // Extend labelLine emphasis - this._defaultLabelLine(option); - }, - - getInitialData: function (option, ecModel) { - var dimensions = completeDimensions(['value'], option.data); - var list = new List(dimensions, this); - list.initData(option.data); - return list; - }, - - _defaultLabelLine: function (option) { - // Extend labelLine emphasis - modelUtil.defaultEmphasis(option.labelLine, ['show']); - - var labelLineNormalOpt = option.labelLine.normal; - var labelLineEmphasisOpt = option.labelLine.emphasis; - // Not show label line if `label.normal.show = false` - labelLineNormalOpt.show = labelLineNormalOpt.show - && option.label.normal.show; - labelLineEmphasisOpt.show = labelLineEmphasisOpt.show - && option.label.emphasis.show; - }, - - defaultOption: { - zlevel: 0, // 一级层叠 - z: 2, // 二级层叠 - legendHoverLink: true, - left: 80, - top: 60, - right: 80, - bottom: 60, - // width: {totalWidth} - left - right, - // height: {totalHeight} - top - bottom, - - // 默认取数据最小最大值 - // min: 0, - // max: 100, - minSize: '0%', - maxSize: '100%', - sort: 'descending', // 'ascending', 'descending' - gap: 0, - funnelAlign: 'center', - label: { - normal: { - show: true, - position: 'outer' - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - }, - emphasis: { - show: true - } - }, - labelLine: { - normal: { - show: true, - length: 20, - lineStyle: { - // color: 各异, - width: 1, - type: 'solid' - } - }, - emphasis: {} - }, - itemStyle: { - normal: { - // color: 各异, - borderColor: '#fff', - borderWidth: 1 - }, - emphasis: { - // color: 各异, - } - } - } - }); - - return FunnelSeries; -}); -define('echarts/chart/funnel/FunnelView',['require','../../util/graphic','zrender/core/util','../../view/Chart'],function (require) { - - var graphic = require('../../util/graphic'); - var zrUtil = require('zrender/core/util'); - - /** - * Piece of pie including Sector, Label, LabelLine - * @constructor - * @extends {module:zrender/graphic/Group} - */ - function FunnelPiece(data, idx) { - - graphic.Group.call(this); - - var polygon = new graphic.Polygon(); - var labelLine = new graphic.Polyline(); - var text = new graphic.Text(); - this.add(polygon); - this.add(labelLine); - this.add(text); - - this.updateData(data, idx, true); - - // Hover to change label and labelLine - function onEmphasis() { - labelLine.ignore = labelLine.hoverIgnore; - text.ignore = text.hoverIgnore; - } - function onNormal() { - labelLine.ignore = labelLine.normalIgnore; - text.ignore = text.normalIgnore; - } - this.on('emphasis', onEmphasis) - .on('normal', onNormal) - .on('mouseover', onEmphasis) - .on('mouseout', onNormal); - } - - var funnelPieceProto = FunnelPiece.prototype; - - function getLabelStyle(data, idx, state, labelModel) { - var textStyleModel = labelModel.getModel('textStyle'); - var position = labelModel.get('position'); - var isLabelInside = position === 'inside' || position === 'inner' || position === 'center'; - return { - fill: textStyleModel.getTextColor() - || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')), - textFont: textStyleModel.getFont(), - text: zrUtil.retrieve( - data.hostModel.getFormattedLabel(idx, state), - data.getName(idx) - ) - }; - } - - var opacityAccessPath = ['itemStyle', 'normal', 'opacity']; - funnelPieceProto.updateData = function (data, idx, firstCreate) { - - var polygon = this.childAt(0); - - var seriesModel = data.hostModel; - var itemModel = data.getItemModel(idx); - var layout = data.getItemLayout(idx); - var opacity = data.getItemModel(idx).get(opacityAccessPath); - opacity = opacity == null ? 1 : opacity; - if (firstCreate) { - polygon.setShape({ - points: layout.points - }); - polygon.setStyle({ opacity : 0 }); - graphic.updateProps(polygon, { - style: { - opacity: opacity - } - }, seriesModel); - } - else { - graphic.initProps(polygon, { - shape: { - points: layout.points - } - }, seriesModel); - } - - // Update common style - var itemStyleModel = itemModel.getModel('itemStyle'); - var visualColor = data.getItemVisual(idx, 'color'); - - polygon.setStyle( - zrUtil.defaults( - { - fill: visualColor - }, - itemStyleModel.getModel('normal').getItemStyle() - ) - ); - polygon.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle(); - - this._updateLabel(data, idx); - - graphic.setHoverStyle(this); - }; - - funnelPieceProto._updateLabel = function (data, idx) { - - var labelLine = this.childAt(1); - var labelText = this.childAt(2); - - var seriesModel = data.hostModel; - var itemModel = data.getItemModel(idx); - var layout = data.getItemLayout(idx); - var labelLayout = layout.label; - var visualColor = data.getItemVisual(idx, 'color'); - - graphic.updateProps(labelLine, { - shape: { - points: labelLayout.linePoints || labelLayout.linePoints - } - }, seriesModel); - - graphic.updateProps(labelText, { - style: { - x: labelLayout.x, - y: labelLayout.y - } - }, seriesModel); - labelText.attr({ - style: { - textAlign: labelLayout.textAlign, - textBaseline: labelLayout.textBaseline, - textFont: labelLayout.font - }, - rotation: labelLayout.rotation, - origin: [labelLayout.x, labelLayout.y], - z2: 10 - }); - - var labelModel = itemModel.getModel('label.normal'); - var labelHoverModel = itemModel.getModel('label.emphasis'); - var labelLineModel = itemModel.getModel('labelLine.normal'); - var labelLineHoverModel = itemModel.getModel('labelLine.emphasis'); - - labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel)); - - labelText.ignore = labelText.normalIgnore = !labelModel.get('show'); - labelText.hoverIgnore = !labelHoverModel.get('show'); - - labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show'); - labelLine.hoverIgnore = !labelLineHoverModel.get('show'); - - // Default use item visual color - labelLine.setStyle({ - stroke: visualColor - }); - labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle()); - - labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel); - labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle(); - }; - - zrUtil.inherits(FunnelPiece, graphic.Group); - - - var Funnel = require('../../view/Chart').extend({ - - type: 'funnel', - - render: function (seriesModel, ecModel, api) { - var data = seriesModel.getData(); - var oldData = this._data; - - var group = this.group; - - data.diff(oldData) - .add(function (idx) { - var funnelPiece = new FunnelPiece(data, idx); - - data.setItemGraphicEl(idx, funnelPiece); - - group.add(funnelPiece); - }) - .update(function (newIdx, oldIdx) { - var piePiece = oldData.getItemGraphicEl(oldIdx); - - piePiece.updateData(data, newIdx); - - group.add(piePiece); - data.setItemGraphicEl(newIdx, piePiece); - }) - .remove(function (idx) { - var piePiece = oldData.getItemGraphicEl(idx); - group.remove(piePiece); - }) - .execute(); + defaultOption: { + coordinateSystem: 'cartesian2d', + zlevel: 0, + z: 2, + legendHoverLink: true, - this._data = data; - }, + effectType: 'ripple', - remove: function () { - this.group.removeAll(); - this._data = null; - } - }); - - return Funnel; -}); -define('echarts/chart/funnel/funnelLayout',['require','../../util/layout','../../util/number'],function (require) { - - var layout = require('../../util/layout'); - var number = require('../../util/number'); - - var parsePercent = number.parsePercent; - - function getViewRect(seriesModel, api) { - return layout.getLayoutRect( - seriesModel.getBoxLayoutParams(), { - width: api.getWidth(), - height: api.getHeight() - } - ); - } - - function getSortedIndices(data, sort) { - var valueArr = data.mapArray('value', function (val) { - return val; - }); - var indices = []; - var isAscending = sort === 'ascending'; - for (var i = 0, len = data.count(); i < len; i++) { - indices[i] = i; - } - indices.sort(function (a, b) { - return isAscending ? valueArr[a] - valueArr[b] : valueArr[b] - valueArr[a]; - }); - return indices; - } - - function labelLayout (data) { - data.each(function (idx) { - var itemModel = data.getItemModel(idx); - var labelModel = itemModel.getModel('label.normal'); - var labelPosition = labelModel.get('position'); - - var labelLineModel = itemModel.getModel('labelLine.normal'); - - var layout = data.getItemLayout(idx); - var points = layout.points; - - var isLabelInside = labelPosition === 'inner' - || labelPosition === 'inside' || labelPosition === 'center'; - - var textAlign; - var textX; - var textY; - var linePoints; - - if (isLabelInside) { - textX = (points[0][0] + points[1][0] + points[2][0] + points[3][0]) / 4; - textY = (points[0][1] + points[1][1] + points[2][1] + points[3][1]) / 4; - textAlign = 'center'; - linePoints = [ - [textX, textY], [textX, textY] - ]; - } - else { - var x1; - var y1; - var x2; - var labelLineLen = labelLineModel.get('length'); - if (labelPosition === 'left') { - // Left side - x1 = (points[3][0] + points[0][0]) / 2; - y1 = (points[3][1] + points[0][1]) / 2; - x2 = x1 - labelLineLen; - textX = x2 - 5; - textAlign = 'right'; - } - else { - // Right side - x1 = (points[1][0] + points[2][0]) / 2; - y1 = (points[1][1] + points[2][1]) / 2; - x2 = x1 + labelLineLen; - textX = x2 + 5; - textAlign = 'left'; - } - var y2 = y1; - - linePoints = [[x1, y1], [x2, y2]]; - textY = y2; - } - - layout.label = { - linePoints: linePoints, - x: textX, - y: textY, - textBaseline: 'middle', - textAlign: textAlign, - inside: isLabelInside - }; - }); - } - - return function (ecModel, api) { - ecModel.eachSeriesByType('funnel', function (seriesModel) { - var data = seriesModel.getData(); - var sort = seriesModel.get('sort'); - var viewRect = getViewRect(seriesModel, api); - var indices = getSortedIndices(data, sort); - - var sizeExtent = [ - parsePercent(seriesModel.get('minSize'), viewRect.width), - parsePercent(seriesModel.get('maxSize'), viewRect.width) - ]; - var dataExtent = data.getDataExtent('value'); - var min = seriesModel.get('min'); - var max = seriesModel.get('max'); - if (min == null) { - min = Math.min(dataExtent[0], 0); - } - if (max == null) { - max = dataExtent[1]; - } - - var funnelAlign = seriesModel.get('funnelAlign'); - var gap = seriesModel.get('gap'); - var itemHeight = (viewRect.height - gap * (data.count() - 1)) / data.count(); - - var y = viewRect.y; - - var getLinePoints = function (idx, offY) { - // End point index is data.count() and we assign it 0 - var val = data.get('value', idx) || 0; - var itemWidth = number.linearMap(val, [min, max], sizeExtent, true); - var x0; - switch (funnelAlign) { - case 'left': - x0 = viewRect.x; - break; - case 'center': - x0 = viewRect.x + (viewRect.width - itemWidth) / 2; - break; - case 'right': - x0 = viewRect.x + viewRect.width - itemWidth; - break; - } - return [ - [x0, offY], - [x0 + itemWidth, offY] - ]; - }; - - if (sort === 'ascending') { - // From bottom to top - itemHeight = -itemHeight; - gap = -gap; - y += viewRect.height; - indices = indices.reverse(); - } - - for (var i = 0; i < indices.length; i++) { - var idx = indices[i]; - var nextIdx = indices[i + 1]; - var start = getLinePoints(idx, y); - var end = getLinePoints(nextIdx, y + itemHeight); - - y += itemHeight + gap; - - data.setItemLayout(idx, { - points: start.concat(end.slice().reverse()) - }); - } - - labelLayout(data); - }); - }; -}); -define('echarts/chart/funnel',['require','zrender/core/util','../echarts','./funnel/FunnelSeries','./funnel/FunnelView','../visual/dataColor','./funnel/funnelLayout','../processor/dataFilter'],function (require) { + // When to show the effect, option: 'render'|'emphasis' + showEffectOn: 'render', - var zrUtil = require('zrender/core/util'); - var echarts = require('../echarts'); + // Ripple effect config + rippleEffect: { + period: 4, + // Scale of ripple + scale: 2.5, + // Brush type can be fill or stroke + brushType: 'fill' + }, - require('./funnel/FunnelSeries'); - require('./funnel/FunnelView'); + // Cartesian coordinate system + xAxisIndex: 0, + yAxisIndex: 0, - echarts.registerVisualCoding( - 'chart', zrUtil.curry(require('../visual/dataColor'), 'funnel') - ); - echarts.registerLayout(require('./funnel/funnelLayout')); + // Polar coordinate system + polarIndex: 0, - echarts.registerProcessor( - 'filter', zrUtil.curry(require('../processor/dataFilter'), 'funnel') - ); -}); -define('echarts/coord/parallel/ParallelAxis',['require','zrender/core/util','../Axis'],function (require) { - - var zrUtil = require('zrender/core/util'); - var Axis = require('../Axis'); - - /** - * @constructor module:echarts/coord/parallel/ParallelAxis - * @extends {module:echarts/coord/Axis} - * @param {string} dim - * @param {*} scale - * @param {Array.} coordExtent - * @param {string} axisType - */ - var ParallelAxis = function (dim, scale, coordExtent, axisType, axisIndex) { - - Axis.call(this, dim, scale, coordExtent); - - /** - * Axis type - * - 'category' - * - 'value' - * - 'time' - * - 'log' - * @type {string} - */ - this.type = axisType || 'value'; - - /** - * @type {number} - * @readOnly - */ - this.axisIndex = axisIndex; - }; - - ParallelAxis.prototype = { - - constructor: ParallelAxis, - - /** - * Axis model - * @param {module:echarts/coord/parallel/AxisModel} - */ - model: null - - }; - - zrUtil.inherits(ParallelAxis, Axis); - - return ParallelAxis; -}); -/** - * Parallel Coordinates - * - */ -define('echarts/coord/parallel/Parallel',['require','../../util/layout','../../coord/axisHelper','zrender/core/util','./ParallelAxis','zrender/core/matrix','zrender/core/vector'],function(require) { - - var layout = require('../../util/layout'); - var axisHelper = require('../../coord/axisHelper'); - var zrUtil = require('zrender/core/util'); - var ParallelAxis = require('./ParallelAxis'); - var matrix = require('zrender/core/matrix'); - var vector = require('zrender/core/vector'); - - var each = zrUtil.each; - - var PI = Math.PI; - - function Parallel(parallelModel, ecModel, api) { - - /** - * key: dimension - * @type {Object.} - * @private - */ - this._axesMap = {}; - - /** - * key: dimension - * value: {position: [], rotation, } - * @type {Object.} - * @private - */ - this._axesLayout = {}; - - /** - * Always follow axis order. - * @type {Array.} - * @readOnly - */ - this.dimensions = parallelModel.dimensions; - - /** - * @type {module:zrender/core/BoundingRect} - */ - this._rect; - - /** - * @type {module:echarts/coord/parallel/ParallelModel} - */ - this._model = parallelModel; - - this._init(parallelModel, ecModel, api); - } - - Parallel.prototype = { - - type: 'parallel', - - constructor: Parallel, - - /** - * Initialize cartesian coordinate systems - * @private - */ - _init: function (parallelModel, ecModel, api) { - - var dimensions = parallelModel.dimensions; - var parallelAxisIndex = parallelModel.parallelAxisIndex; - - each(dimensions, function (dim, idx) { - - var axisIndex = parallelAxisIndex[idx]; - var axisModel = ecModel.getComponent('parallelAxis', axisIndex); - - var axis = this._axesMap[dim] = new ParallelAxis( - dim, - axisHelper.createScaleByModel(axisModel), - [0, 0], - axisModel.get('type'), - axisIndex - ); - - var isCategory = axis.type === 'category'; - axis.onBand = isCategory && axisModel.get('boundaryGap'); - axis.inverse = axisModel.get('inverse'); - - // Inject axis into axisModel - axisModel.axis = axis; - - // Inject axisModel into axis - axis.model = axisModel; - }, this); - }, - - /** - * Update axis scale after data processed - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - */ - update: function (ecModel, api) { - this._updateAxesFromSeries(this._model, ecModel); - }, - - /** - * Update properties from series - * @private - */ - _updateAxesFromSeries: function (parallelModel, ecModel) { - ecModel.eachSeries(function (seriesModel) { - - if (!parallelModel.contains(seriesModel, ecModel)) { - return; - } - - var data = seriesModel.getData(); - - each(this.dimensions, function (dim) { - var axis = this._axesMap[dim]; - axis.scale.unionExtent(data.getDataExtent(dim)); - axisHelper.niceScaleExtent(axis, axis.model); - }, this); - }, this); - }, - - /** - * Resize the parallel coordinate system. - * @param {module:echarts/coord/parallel/ParallelModel} parallelModel - * @param {module:echarts/ExtensionAPI} api - */ - resize: function (parallelModel, api) { - this._rect = layout.getLayoutRect( - parallelModel.getBoxLayoutParams(), - { - width: api.getWidth(), - height: api.getHeight() - } - ); - - this._layoutAxes(parallelModel); - }, - - /** - * @return {module:zrender/core/BoundingRect} - */ - getRect: function () { - return this._rect; - }, - - /** - * @private - */ - _layoutAxes: function (parallelModel) { - var rect = this._rect; - var layout = parallelModel.get('layout'); - var axes = this._axesMap; - var dimensions = this.dimensions; - - var size = [rect.width, rect.height]; - var sizeIdx = layout === 'horizontal' ? 0 : 1; - var layoutLength = size[sizeIdx]; - var axisLength = size[1 - sizeIdx]; - var axisExtent = [0, axisLength]; - - each(axes, function (axis) { - var idx = axis.inverse ? 1 : 0; - axis.setExtent(axisExtent[idx], axisExtent[1 - idx]); - }); - - each(dimensions, function (dim, idx) { - var pos = layoutLength * idx / (dimensions.length - 1); - - var positionTable = { - horizontal: { - x: pos, - y: axisLength - }, - vertical: { - x: 0, - y: pos - } - }; - var rotationTable = { - horizontal: PI / 2, - vertical: 0 - }; - - var position = [ - positionTable[layout].x + rect.x, - positionTable[layout].y + rect.y - ]; - - var rotation = rotationTable[layout]; - var transform = matrix.create(); - matrix.rotate(transform, transform, rotation); - matrix.translate(transform, transform, position); - - // TODO - // tick等排布信息。 - - // TODO - // 根据axis order 更新 dimensions顺序。 - - this._axesLayout[dim] = { - position: position, - rotation: rotation, - transform: transform, - tickDirection: 1, - labelDirection: 1 - }; - }, this); - }, - - /** - * Get axis by dim. - * @param {string} dim - * @return {module:echarts/coord/parallel/ParallelAxis} [description] - */ - getAxis: function (dim) { - return this._axesMap[dim]; - }, - - /** - * Convert a dim value of a single item of series data to Point. - * @param {*} value - * @param {string} dim - * @return {Array} - */ - dataToPoint: function (value, dim) { - return this.axisCoordToPoint( - this._axesMap[dim].dataToCoord(value), - dim - ); - }, - - /** - * @param {module:echarts/data/List} data - * @param {Functio} cb param: {string} activeState 'active' or 'inactive' or 'normal' - * {number} dataIndex - * @param {Object} context - */ - eachActiveState: function (data, callback, context) { - var dimensions = this.dimensions; - var axesMap = this._axesMap; - var hasActiveSet = false; - - for (var j = 0, lenj = dimensions.length; j < lenj; j++) { - if (axesMap[dimensions[j]].model.getActiveState() !== 'normal') { - hasActiveSet = true; - } - } - - for (var i = 0, len = data.count(); i < len; i++) { - var values = data.getValues(dimensions, i); - var activeState; - - if (!hasActiveSet) { - activeState = 'normal'; - } - else { - activeState = 'active'; - for (var j = 0, lenj = dimensions.length; j < lenj; j++) { - var dimName = dimensions[j]; - var state = axesMap[dimName].model.getActiveState(values[j], j); - - if (state === 'inactive') { - activeState = 'inactive'; - break; - } - } - } - - callback.call(context, activeState, i); - } - }, - - /** - * Convert coords of each axis to Point. - * Return point. For example: [10, 20] - * @param {Array.} coords - * @param {string} dim - * @return {Array.} - */ - axisCoordToPoint: function (coord, dim) { - var axisLayout = this._axesLayout[dim]; - var point = [coord, 0]; - vector.applyTransform(point, point, axisLayout.transform); - return point; - }, - - /** - * Get axis layout. - */ - getAxisLayout: function (dim) { - return zrUtil.clone(this._axesLayout[dim]); - } - - }; - - return Parallel; -}); -/** - * Parallel coordinate system creater. - */ -define('echarts/coord/parallel/parallelCreator',['require','./Parallel','../../CoordinateSystem'],function(require) { + // Geo coordinate system + geoIndex: 0, - var Parallel = require('./Parallel'); + // symbol: null, // 图形类型 + symbolSize: 10 // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2 + // symbolRotate: null, // 图形旋转控制 - function create(ecModel, api) { - var coordSysList = []; + // large: false, + // Available when large is true + // largeThreshold: 2000, - ecModel.eachComponent('parallel', function (parallelModel, idx) { - var coordSys = new Parallel(parallelModel, ecModel, api); + // itemStyle: { + // normal: { + // opacity: 1 + // } + // } + } + }); - coordSys.name = 'parallel_' + idx; - coordSys.resize(parallelModel, api); - parallelModel.coordinateSystem = coordSys; - coordSys.model = parallelModel; +/***/ }, +/* 251 */ +/***/ function(module, exports, __webpack_require__) { - coordSysList.push(coordSys); - }); + - // Inject the coordinateSystems into seriesModel - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.get('coordinateSystem') === 'parallel') { - var parallelIndex = seriesModel.get('parallelIndex'); - seriesModel.coordinateSystem = coordSysList[parallelIndex]; - } - }); + var SymbolDraw = __webpack_require__(98); + var EffectSymbol = __webpack_require__(252); - return coordSysList; - } + __webpack_require__(1).extendChartView({ + + type: 'effectScatter', + + init: function () { + this._symbolDraw = new SymbolDraw(EffectSymbol); + }, + + render: function (seriesModel, ecModel, api) { + var data = seriesModel.getData(); + var effectSymbolDraw = this._symbolDraw; + effectSymbolDraw.updateData(data); + this.group.add(effectSymbolDraw.group); + }, + + updateLayout: function () { + this._symbolDraw.updateLayout(); + }, + + remove: function (ecModel, api) { + this._symbolDraw && this._symbolDraw.remove(api); + } + }); + + +/***/ }, +/* 252 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Symbol with ripple effect + * @module echarts/chart/helper/EffectSymbol + */ + + + var zrUtil = __webpack_require__(3); + var symbolUtil = __webpack_require__(100); + var graphic = __webpack_require__(42); + var numberUtil = __webpack_require__(7); + var Symbol = __webpack_require__(99); + var Group = graphic.Group; + + var EFFECT_RIPPLE_NUMBER = 3; + + function normalizeSymbolSize(symbolSize) { + if (!zrUtil.isArray(symbolSize)) { + symbolSize = [+symbolSize, +symbolSize]; + } + return symbolSize; + } + /** + * @constructor + * @param {module:echarts/data/List} data + * @param {number} idx + * @extends {module:zrender/graphic/Group} + */ + function EffectSymbol(data, idx) { + Group.call(this); + + var symbol = new Symbol(data, idx); + var rippleGroup = new Group(); + this.add(symbol); + this.add(rippleGroup); + + rippleGroup.beforeUpdate = function () { + this.attr(symbol.getScale()); + }; + this.updateData(data, idx); + } + + var effectSymbolProto = EffectSymbol.prototype; + + effectSymbolProto.stopEffectAnimation = function () { + this.childAt(1).removeAll(); + }; + + effectSymbolProto.startEffectAnimation = function ( + period, brushType, rippleScale, effectOffset, z, zlevel + ) { + var symbolType = this._symbolType; + var color = this._color; + + var rippleGroup = this.childAt(1); + + for (var i = 0; i < EFFECT_RIPPLE_NUMBER; i++) { + var ripplePath = symbolUtil.createSymbol( + symbolType, -0.5, -0.5, 1, 1, color + ); + ripplePath.attr({ + style: { + stroke: brushType === 'stroke' ? color : null, + fill: brushType === 'fill' ? color : null, + strokeNoScale: true + }, + z2: 99, + silent: true, + scale: [1, 1], + z: z, + zlevel: zlevel + }); + + var delay = -i / EFFECT_RIPPLE_NUMBER * period + effectOffset; + // TODO Configurable period + ripplePath.animate('', true) + .when(period, { + scale: [rippleScale, rippleScale] + }) + .delay(delay) + .start(); + ripplePath.animateStyle(true) + .when(period, { + opacity: 0 + }) + .delay(delay) + .start(); + + rippleGroup.add(ripplePath); + } + }; + + /** + * Highlight symbol + */ + effectSymbolProto.highlight = function () { + this.trigger('emphasis'); + }; + + /** + * Downplay symbol + */ + effectSymbolProto.downplay = function () { + this.trigger('normal'); + }; + + /** + * Update symbol properties + * @param {module:echarts/data/List} data + * @param {number} idx + */ + effectSymbolProto.updateData = function (data, idx) { + var seriesModel = data.hostModel; + + this.childAt(0).updateData(data, idx); + + var rippleGroup = this.childAt(1); + var itemModel = data.getItemModel(idx); + var symbolType = data.getItemVisual(idx, 'symbol'); + var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); + var color = data.getItemVisual(idx, 'color'); + + rippleGroup.attr('scale', symbolSize); + + rippleGroup.traverse(function (ripplePath) { + ripplePath.attr({ + fill: color + }); + }); + + var symbolOffset = itemModel.getShallow('symbolOffset'); + if (symbolOffset) { + var pos = rippleGroup.position; + pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]); + pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]); + } + + this._symbolType = symbolType; + this._color = color; + + var showEffectOn = seriesModel.get('showEffectOn'); + var rippleScale = itemModel.get('rippleEffect.scale'); + var brushType = itemModel.get('rippleEffect.brushType'); + var effectPeriod = itemModel.get('rippleEffect.period') * 1000; + var effectOffset = idx / data.count(); + var z = itemModel.getShallow('z') || 0; + var zlevel = itemModel.getShallow('zlevel') || 0; + + this.stopEffectAnimation(); + if (showEffectOn === 'render') { + this.startEffectAnimation( + effectPeriod, brushType, rippleScale, effectOffset, z, zlevel + ); + } + var symbol = this.childAt(0); + function onEmphasis() { + symbol.trigger('emphasis'); + if (showEffectOn !== 'render') { + this.startEffectAnimation( + effectPeriod, brushType, rippleScale, effectOffset, z, zlevel + ); + } + } + function onNormal() { + symbol.trigger('normal'); + if (showEffectOn !== 'render') { + this.stopEffectAnimation(); + } + } + this.on('mouseover', onEmphasis, this) + .on('mouseout', onNormal, this) + .on('emphasis', onEmphasis, this) + .on('normal', onNormal, this); + }; + + effectSymbolProto.fadeOut = function (cb) { + cb && cb(); + }; + + zrUtil.inherits(EffectSymbol, Group); + + module.exports = EffectSymbol; + + +/***/ }, +/* 253 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(254); + __webpack_require__(255); + + var zrUtil = __webpack_require__(3); + var echarts = __webpack_require__(1); + echarts.registerLayout( + __webpack_require__(257) + ); + + echarts.registerVisualCoding( + 'chart', zrUtil.curry(__webpack_require__(88), 'lines', 'lineStyle') + ); + + +/***/ }, +/* 254 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var SeriesModel = __webpack_require__(27); + var List = __webpack_require__(94); + var zrUtil = __webpack_require__(3); + var CoordinateSystem = __webpack_require__(25); + + module.exports = SeriesModel.extend({ + + type: 'series.lines', + + dependencies: ['grid', 'polar'], + + getInitialData: function (option, ecModel) { + var fromDataArr = []; + var toDataArr = []; + var lineDataArr = []; + zrUtil.each(option.data, function (opt) { + fromDataArr.push(opt[0]); + toDataArr.push(opt[1]); + lineDataArr.push(zrUtil.extend( + zrUtil.extend({}, zrUtil.isArray(opt[0]) ? null : opt[0]), + zrUtil.isArray(opt[1]) ? null : opt[1] + )); + }); + + // var coordSys = option.coordinateSystem; + // if (coordSys !== 'cartesian2d' && coordSys !== 'geo') { + // throw new Error('Coordinate system can only be cartesian2d or geo in lines'); + // } + + // var dimensions = coordSys === 'geo' ? ['lng', 'lat'] : ['x', 'y']; + var coordSys = CoordinateSystem.get(option.coordinateSystem); + if (!coordSys) { + throw new Error('Invalid coordinate system'); + } + var dimensions = coordSys.dimensions; + + var fromData = new List(dimensions, this); + var toData = new List(dimensions, this); + var lineData = new List(['value'], this); + + function geoCoordGetter(item, dim, dataIndex, dimIndex) { + return item.coord && item.coord[dimIndex]; + } + + fromData.initData(fromDataArr, null, geoCoordGetter); + toData.initData(toDataArr, null, geoCoordGetter); + lineData.initData(lineDataArr); + + this.fromData = fromData; + this.toData = toData; + + return lineData; + }, + + formatTooltip: function (dataIndex) { + var fromName = this.fromData.getName(dataIndex); + var toName = this.toData.getName(dataIndex); + return fromName + ' > ' + toName; + }, + + defaultOption: { + coordinateSystem: 'geo', + zlevel: 0, + z: 2, + legendHoverLink: true, + + hoverAnimation: true, + // Cartesian coordinate system + xAxisIndex: 0, + yAxisIndex: 0, + + // Geo coordinate system + geoIndex: 0, + + // symbol: null, + // symbolSize: 10, + // symbolRotate: null, + + effect: { + show: false, + period: 4, + symbol: 'circle', + symbolSize: 3, + // Length of trail, 0 - 1 + trailLength: 0.2 + // Same with lineStyle.normal.color + // color + }, + + large: false, + // Available when large is true + largeThreshold: 2000, + + label: { + normal: { + show: false, + position: 'end' + // distance: 5, + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + } + }, + // itemStyle: { + // normal: { + // } + // }, + lineStyle: { + normal: { + opacity: 0.5 + } + } + } + }); + + +/***/ }, +/* 255 */ +/***/ function(module, exports, __webpack_require__) { + + + + var LineDraw = __webpack_require__(194); + var EffectLine = __webpack_require__(256); + var Line = __webpack_require__(195); + + __webpack_require__(1).extendChartView({ + + type: 'lines', + + init: function () {}, + + render: function (seriesModel, ecModel, api) { + var data = seriesModel.getData(); + var lineDraw = this._lineDraw; + + var hasEffect = seriesModel.get('effect.show'); + if (hasEffect !== this._hasEffet) { + if (lineDraw) { + lineDraw.remove(); + } + lineDraw = this._lineDraw = new LineDraw( + hasEffect ? EffectLine : Line + ); + this._hasEffet = hasEffect; + } + + var zlevel = seriesModel.get('zlevel'); + var trailLength = seriesModel.get('effect.trailLength'); + + var zr = api.getZr(); + // Avoid the drag cause ghost shadow + // FIXME Better way ? + zr.painter.getLayer(zlevel).clear(true); + // Config layer with motion blur + if (this._lastZlevel != null) { + zr.configLayer(this._lastZlevel, { + motionBlur: false + }); + } + if (hasEffect && trailLength) { + zr.configLayer(zlevel, { + motionBlur: true, + lastFrameAlpha: Math.max(Math.min(trailLength / 10 + 0.9, 1), 0) + }); + } + + this.group.add(lineDraw.group); + + lineDraw.updateData(data); + + this._lastZlevel = zlevel; + }, + + updateLayout: function (seriesModel, ecModel, api) { + this._lineDraw.updateLayout(); + // Not use motion when dragging or zooming + var zr = api.getZr(); + zr.painter.getLayer(this._lastZlevel).clear(true); + }, + + remove: function (ecModel, api) { + this._lineDraw && this._lineDraw.remove(api, true); + } + }); + + +/***/ }, +/* 256 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/chart/helper/EffectLine + */ + + + var graphic = __webpack_require__(42); + var Line = __webpack_require__(195); + var zrUtil = __webpack_require__(3); + var symbolUtil = __webpack_require__(100); + + var curveUtil = __webpack_require__(49); + + /** + * @constructor + * @extends {module:zrender/graphic/Group} + * @alias {module:echarts/chart/helper/Line} + */ + function EffectLine(lineData, fromData, toData, idx) { + graphic.Group.call(this); + + var line = new Line(lineData, fromData, toData, idx); + this.add(line); + + this._updateEffectSymbol(lineData, idx); + } + + var effectLineProto = EffectLine.prototype; + + function setAnimationPoints(symbol, points) { + symbol.__p1 = points[0]; + symbol.__p2 = points[1]; + symbol.__cp1 = points[2] || [ + (points[0][0] + points[1][0]) / 2, + (points[0][1] + points[1][1]) / 2 + ]; + } + + function updateSymbolPosition() { + var p1 = this.__p1; + var p2 = this.__p2; + var cp1 = this.__cp1; + var t = this.__t; + var pos = this.position; + var quadraticAt = curveUtil.quadraticAt; + var quadraticDerivativeAt = curveUtil.quadraticDerivativeAt; + pos[0] = quadraticAt(p1[0], cp1[0], p2[0], t); + pos[1] = quadraticAt(p1[1], cp1[1], p2[1], t); + + // Tangent + var tx = quadraticDerivativeAt(p1[0], cp1[0], p2[0], t); + var ty = quadraticDerivativeAt(p1[1], cp1[1], p2[1], t); + + this.rotation = -Math.atan2(ty, tx) - Math.PI / 2; + + this.ignore = false; + } + + effectLineProto._updateEffectSymbol = function (lineData, idx) { + var itemModel = lineData.getItemModel(idx); + var effectModel = itemModel.getModel('effect'); + var size = effectModel.get('symbolSize'); + var symbolType = effectModel.get('symbol'); + if (!zrUtil.isArray(size)) { + size = [size, size]; + } + var color = effectModel.get('color') || lineData.getItemVisual(idx, 'color'); + var symbol = this.childAt(1); + var period = effectModel.get('period') * 1000; + if (this._symbolType !== symbolType || period !== this._period) { + symbol = symbolUtil.createSymbol( + symbolType, -0.5, -0.5, 1, 1, color + ); + symbol.ignore = true; + symbol.z2 = 100; + this._symbolType = symbolType; + this._period = period; + + this.add(symbol); + + symbol.__t = 0; + symbol.animate('', true) + .when(period, { + __t: 1 + }) + .delay(idx / lineData.count() * period / 2) + .during(zrUtil.bind(updateSymbolPosition, symbol)) + .start(); + } + // Shadow color is same with color in default + symbol.setStyle('shadowColor', color); + symbol.setStyle(effectModel.getItemStyle(['color'])); + + symbol.attr('scale', size); + var points = lineData.getItemLayout(idx); + setAnimationPoints(symbol, points); + + symbol.setColor(color); + symbol.attr('scale', size); + }; + + effectLineProto.updateData = function (lineData, fromData, toData, idx) { + this.childAt(0).updateData(lineData, fromData, toData, idx); + this._updateEffectSymbol(lineData, idx); + }; + + effectLineProto.updateLayout = function (lineData, fromData, toData, idx) { + this.childAt(0).updateLayout(lineData, fromData, toData, idx); + var symbol = this.childAt(1); + var points = lineData.getItemLayout(idx); + setAnimationPoints(symbol, points); + }; + + zrUtil.inherits(EffectLine, graphic.Group); + + module.exports = EffectLine; + + +/***/ }, +/* 257 */ +/***/ function(module, exports) { + + + + module.exports = function (ecModel) { + ecModel.eachSeriesByType('lines', function (seriesModel) { + var coordSys = seriesModel.coordinateSystem; + var fromData = seriesModel.fromData; + var toData = seriesModel.toData; + var lineData = seriesModel.getData(); + + var dims = coordSys.dimensions; + fromData.each(dims, function (x, y, idx) { + fromData.setItemLayout(idx, coordSys.dataToPoint([x, y])); + }); + toData.each(dims, function (x, y, idx) { + toData.setItemLayout(idx, coordSys.dataToPoint([x, y])); + }); + lineData.each(function (idx) { + var p1 = fromData.getItemLayout(idx); + var p2 = toData.getItemLayout(idx); + var curveness = lineData.getItemModel(idx).get('lineStyle.normal.curveness'); + var cp1; + if (curveness > 0) { + cp1 = [ + (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * curveness, + (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * curveness + ]; + } + lineData.setItemLayout(idx, [p1, p2, cp1]); + }); + }); + }; + + +/***/ }, +/* 258 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(259); + __webpack_require__(260); + + +/***/ }, +/* 259 */ +/***/ function(module, exports, __webpack_require__) { + + + + var SeriesModel = __webpack_require__(27); + var createListFromArray = __webpack_require__(93); + + module.exports = SeriesModel.extend({ + type: 'series.heatmap', + + getInitialData: function (option, ecModel) { + return createListFromArray(option.data, this, ecModel); + }, + + defaultOption: { + + // Cartesian2D or geo + coordinateSystem: 'cartesian2d', + + zlevel: 0, + + z: 2, + + // Cartesian coordinate system + xAxisIndex: 0, + yAxisIndex: 0, + + // Geo coordinate system + geoIndex: 0, + + blurSize: 30, + + pointSize: 20 + } + }); + + +/***/ }, +/* 260 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var HeatmapLayer = __webpack_require__(261); + var zrUtil = __webpack_require__(3); + + function getIsInPiecewiseRange(dataExtent, pieceList, selected) { + var dataSpan = dataExtent[1] - dataExtent[0]; + pieceList = zrUtil.map(pieceList, function (piece) { + return { + interval: [ + (piece.interval[0] - dataExtent[0]) / dataSpan, + (piece.interval[1] - dataExtent[0]) / dataSpan + ] + }; + }); + var len = pieceList.length; + var lastIndex = 0; + return function (val) { + // Try to find in the location of the last found + for (var i = lastIndex; i < len; i++) { + var interval = pieceList[i].interval; + if (interval[0] <= val && val <= interval[1]) { + lastIndex = i; + break; + } + } + if (i === len) { // Not found, back interation + for (var i = lastIndex - 1; i >= 0; i--) { + var interval = pieceList[i].interval; + if (interval[0] <= val && val <= interval[1]) { + lastIndex = i; + break; + } + } + } + return i >= 0 && i < len && selected[i]; + }; + } + + function getIsInContinuousRange(dataExtent, range) { + var dataSpan = dataExtent[1] - dataExtent[0]; + range = [ + (range[0] - dataExtent[0]) / dataSpan, + (range[1] - dataExtent[0]) / dataSpan + ]; + return function (val) { + return val >= range[0] && val <= range[1]; + }; + } + + function isGeoCoordSys(coordSys) { + var dimensions = coordSys.dimensions; + // Not use coorSys.type === 'geo' because coordSys maybe extended + return dimensions[0] === 'lng' && dimensions[1] === 'lat'; + } + + module.exports = __webpack_require__(1).extendChartView({ + + type: 'heatmap', + + render: function (seriesModel, ecModel, api) { + var visualMapOfThisSeries; + ecModel.eachComponent('visualMap', function (visualMap) { + visualMap.eachTargetSeries(function (targetSeries) { + if (targetSeries === seriesModel) { + visualMapOfThisSeries = visualMap; + } + }); + }); + + if (!visualMapOfThisSeries) { + throw new Error('Heatmap must use with visualMap'); + } + + this.group.removeAll(); + var coordSys = seriesModel.coordinateSystem; + if (coordSys.type === 'cartesian2d') { + this._renderOnCartesian(coordSys, seriesModel, api); + } + else if (isGeoCoordSys(coordSys)) { + this._renderOnGeo( + coordSys, seriesModel, visualMapOfThisSeries, api + ); + } + }, + + _renderOnCartesian: function (cartesian, seriesModel, api) { + var xAxis = cartesian.getAxis('x'); + var yAxis = cartesian.getAxis('y'); + var group = this.group; + + if (!(xAxis.type === 'category' && yAxis.type === 'category')) { + throw new Error('Heatmap on cartesian must have two category axes'); + } + if (!(xAxis.onBand && yAxis.onBand)) { + throw new Error('Heatmap on cartesian must have two axes with boundaryGap true'); + } + var width = xAxis.getBandWidth(); + var height = yAxis.getBandWidth(); + + var data = seriesModel.getData(); + data.each(['x', 'y', 'z'], function (x, y, z, idx) { + var itemModel = data.getItemModel(idx); + var point = cartesian.dataToPoint([x, y]); + // Ignore empty data + if (isNaN(z)) { + return; + } + var rect = new graphic.Rect({ + shape: { + x: point[0] - width / 2, + y: point[1] - height / 2, + width: width, + height: height + }, + style: { + fill: data.getItemVisual(idx, 'color') + } + }); + var style = itemModel.getModel('itemStyle.normal').getItemStyle(['color']); + var hoverStl = itemModel.getModel('itemStyle.emphasis').getItemStyle(); + var labelModel = itemModel.getModel('label.normal'); + var hoverLabelModel = itemModel.getModel('label.emphasis'); + + var rawValue = seriesModel.getRawValue(idx); + var defaultText = '-'; + if (rawValue && rawValue[2] != null) { + defaultText = rawValue[2]; + } + if (labelModel.get('show')) { + graphic.setText(style, labelModel); + style.text = seriesModel.getFormattedLabel(idx, 'normal') || defaultText; + } + if (hoverLabelModel.get('show')) { + graphic.setText(hoverStl, hoverLabelModel); + hoverStl.text = seriesModel.getFormattedLabel(idx, 'emphasis') || defaultText; + } + + rect.setStyle(style); + + graphic.setHoverStyle(rect, hoverStl); + + group.add(rect); + data.setItemGraphicEl(idx, rect); + }); + }, + + _renderOnGeo: function (geo, seriesModel, visualMapModel, api) { + var inRangeVisuals = visualMapModel.targetVisuals.inRange; + var outOfRangeVisuals = visualMapModel.targetVisuals.outOfRange; + // if (!visualMapping) { + // throw new Error('Data range must have color visuals'); + // } + + var data = seriesModel.getData(); + var hmLayer = this._hmLayer || (this._hmLayer || new HeatmapLayer()); + hmLayer.blurSize = seriesModel.get('blurSize'); + hmLayer.pointSize = seriesModel.get('pointSize'); + + var rect = geo.getViewRect().clone(); + var roamTransform = geo.getRoamTransform(); + rect.applyTransform(roamTransform); + + // Clamp on viewport + var x = Math.max(rect.x, 0); + var y = Math.max(rect.y, 0); + var x2 = Math.min(rect.width + rect.x, api.getWidth()); + var y2 = Math.min(rect.height + rect.y, api.getHeight()); + var width = x2 - x; + var height = y2 - y; + + var points = data.mapArray(['lng', 'lat', 'value'], function (lng, lat, value) { + var pt = geo.dataToPoint([lng, lat]); + pt[0] -= x; + pt[1] -= y; + pt.push(value); + return pt; + }); + + var dataExtent = visualMapModel.getExtent(); + var isInRange = visualMapModel.type === 'visualMap.continuous' + ? getIsInContinuousRange(dataExtent, visualMapModel.option.range) + : getIsInPiecewiseRange( + dataExtent, visualMapModel.getPieceList(), visualMapModel.option.selected + ); + + hmLayer.update( + points, width, height, + inRangeVisuals.color.getNormalizer(), + { + inRange: inRangeVisuals.color.getColorMapper(), + outOfRange: outOfRangeVisuals.color.getColorMapper() + }, + isInRange + ); + var img = new graphic.Image({ + style: { + width: width, + height: height, + x: x, + y: y, + image: hmLayer.canvas + }, + silent: true + }); + this.group.add(img); + } + }); + + +/***/ }, +/* 261 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file defines echarts Heatmap Chart + * @author Ovilia (me@zhangwenli.com) + * Inspired by https://github.com/mourner/simpleheat + * + * @module + */ + + + var GRADIENT_LEVELS = 256; + var zrUtil = __webpack_require__(3); + + /** + * Heatmap Chart + * + * @class + */ + function Heatmap() { + var canvas = zrUtil.createCanvas(); + this.canvas = canvas; + + this.blurSize = 30; + this.pointSize = 20; + this.opacity = 1; + + this._gradientPixels = {}; + } + + Heatmap.prototype = { + /** + * Renders Heatmap and returns the rendered canvas + * @param {Array} data array of data, each has x, y, value + * @param {number} width canvas width + * @param {number} height canvas height + */ + update: function(data, width, height, normalize, colorFunc, isInRange) { + var brush = this._getBrush(); + var gradientInRange = this._getGradient(data, colorFunc, 'inRange'); + var gradientOutOfRange = this._getGradient(data, colorFunc, 'outOfRange'); + var r = this.pointSize + this.blurSize; + + var canvas = this.canvas; + var ctx = canvas.getContext('2d'); + var len = data.length; + canvas.width = width; + canvas.height = height; + for (var i = 0; i < len; ++i) { + var p = data[i]; + var x = p[0]; + var y = p[1]; + var value = p[2]; + + // calculate alpha using value + var alpha = normalize(value); + + // draw with the circle brush with alpha + ctx.globalAlpha = alpha; + ctx.drawImage(brush, x - r, y - r); + } + + // colorize the canvas using alpha value and set with gradient + var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); + var pixels = imageData.data; + var offset = 0; + var pixelLen = pixels.length; + while(offset < pixelLen) { + var alpha = pixels[offset + 3] / 256; + var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4; + // Simple optimize to ignore the empty data + if (alpha > 0) { + var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange; + pixels[offset++] = gradient[gradientOffset]; + pixels[offset++] = gradient[gradientOffset + 1]; + pixels[offset++] = gradient[gradientOffset + 2]; + pixels[offset++] *= this.opacity * gradient[gradientOffset + 3]; + } + else { + offset += 4; + } + } + ctx.putImageData(imageData, 0, 0); + + return canvas; + }, + + /** + * get canvas of a black circle brush used for canvas to draw later + * @private + * @returns {Object} circle brush canvas + */ + _getBrush: function() { + var brushCanvas = this._brushCanvas || (this._brushCanvas = zrUtil.createCanvas()); + // set brush size + var r = this.pointSize + this.blurSize; + var d = r * 2; + brushCanvas.width = d; + brushCanvas.height = d; + + var ctx = brushCanvas.getContext('2d'); + ctx.clearRect(0, 0, d, d); + + // in order to render shadow without the distinct circle, + // draw the distinct circle in an invisible place, + // and use shadowOffset to draw shadow in the center of the canvas + ctx.shadowOffsetX = d; + ctx.shadowBlur = this.blurSize; + // draw the shadow in black, and use alpha and shadow blur to generate + // color in color map + ctx.shadowColor = '#000'; + + // draw circle in the left to the canvas + ctx.beginPath(); + ctx.arc(-r, r, this.pointSize, 0, Math.PI * 2, true); + ctx.closePath(); + ctx.fill(); + return brushCanvas; + }, + + /** + * get gradient color map + * @private + */ + _getGradient: function (data, colorFunc, state) { + var gradientPixels = this._gradientPixels; + var pixelsSingleState = gradientPixels[state] || (gradientPixels[state] = new Uint8ClampedArray(256 * 4)); + var color = []; + var off = 0; + for (var i = 0; i < 256; i++) { + colorFunc[state](i / 255, true, color); + pixelsSingleState[off++] = color[0]; + pixelsSingleState[off++] = color[1]; + pixelsSingleState[off++] = color[2]; + pixelsSingleState[off++] = color[3]; + } + return pixelsSingleState; + } + }; + + module.exports = Heatmap; + + + +/***/ }, +/* 262 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Legend component entry file8 + */ + + + __webpack_require__(263); + __webpack_require__(264); + __webpack_require__(265); + + var echarts = __webpack_require__(1); + // Series Filter + echarts.registerProcessor('filter', __webpack_require__(267)); + + +/***/ }, +/* 263 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var Model = __webpack_require__(8); + + var LegendModel = __webpack_require__(1).extendComponentModel({ + + type: 'legend', + + dependencies: ['series'], + + layoutMode: { + type: 'box', + ignoreSize: true + }, + + init: function (option, parentModel, ecModel) { + this.mergeDefaultAndTheme(option, ecModel); + + option.selected = option.selected || {}; + + this._updateData(ecModel); + + var legendData = this._data; + // If has any selected in option.selected + var selectedMap = this.option.selected; + // If selectedMode is single, try to select one + if (legendData[0] && this.get('selectedMode') === 'single') { + var hasSelected = false; + for (var name in selectedMap) { + if (selectedMap[name]) { + this.select(name); + hasSelected = true; + } + } + // Try select the first if selectedMode is single + !hasSelected && this.select(legendData[0].get('name')); + } + }, + + mergeOption: function (option) { + LegendModel.superCall(this, 'mergeOption', option); + + this._updateData(this.ecModel); + }, + + _updateData: function (ecModel) { + var legendData = zrUtil.map(this.get('data') || [], function (dataItem) { + if (typeof dataItem === 'string') { + dataItem = { + name: dataItem + }; + } + return new Model(dataItem, this, this.ecModel); + }, this); + this._data = legendData; + + var availableNames = zrUtil.map(ecModel.getSeries(), function (series) { + return series.name; + }); + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.legendDataProvider) { + var data = seriesModel.legendDataProvider(); + availableNames = availableNames.concat(data.mapArray(data.getName)); + } + }); + /** + * @type {Array.} + * @private + */ + this._availableNames = availableNames; + }, + + /** + * @return {Array.} + */ + getData: function () { + return this._data; + }, + + /** + * @param {string} name + */ + select: function (name) { + var selected = this.option.selected; + var selectedMode = this.get('selectedMode'); + if (selectedMode === 'single') { + var data = this._data; + zrUtil.each(data, function (dataItem) { + selected[dataItem.get('name')] = false; + }); + } + selected[name] = true; + }, + + /** + * @param {string} name + */ + unSelect: function (name) { + if (this.get('selectedMode') !== 'single') { + this.option.selected[name] = false; + } + }, + + /** + * @param {string} name + */ + toggleSelected: function (name) { + var selected = this.option.selected; + // Default is true + if (!(name in selected)) { + selected[name] = true; + } + this[selected[name] ? 'unSelect' : 'select'](name); + }, + + /** + * @param {string} name + */ + isSelected: function (name) { + var selected = this.option.selected; + return !((name in selected) && !selected[name]) + && zrUtil.indexOf(this._availableNames, name) >= 0; + }, + + defaultOption: { + // 一级层叠 + zlevel: 0, + // 二级层叠 + z: 4, + show: true, + + // 布局方式,默认为水平布局,可选为: + // 'horizontal' | 'vertical' + orient: 'horizontal', + + left: 'center', + // right: 'center', + + top: 'top', + // bottom: 'top', + + // 水平对齐 + // 'auto' | 'left' | 'right' + // 默认为 'auto', 根据 x 的位置判断是左对齐还是右对齐 + align: 'auto', + + backgroundColor: 'rgba(0,0,0,0)', + // 图例边框颜色 + borderColor: '#ccc', + // 图例边框线宽,单位px,默认为0(无边框) + borderWidth: 0, + // 图例内边距,单位px,默认各方向内边距为5, + // 接受数组分别设定上右下左边距,同css + padding: 5, + // 各个item之间的间隔,单位px,默认为10, + // 横向布局时为水平间隔,纵向布局时为纵向间隔 + itemGap: 10, + // 图例图形宽度 + itemWidth: 25, + // 图例图形高度 + itemHeight: 14, + textStyle: { + // 图例文字颜色 + color: '#333' + }, + // formatter: '', + // 选择模式,默认开启图例开关 + selectedMode: true + // 配置默认选中状态,可配合LEGEND.SELECTED事件做动态数据载入 + // selected: null, + // 图例内容(详见legend.data,数组中每一项代表一个item + // data: [], + } + }); + + module.exports = LegendModel; + + +/***/ }, +/* 264 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Legend action + */ + + + var echarts = __webpack_require__(1); + var zrUtil = __webpack_require__(3); + + function legendSelectActionHandler(methodName, payload, ecModel) { + var selectedMap = {}; + var isToggleSelect = methodName === 'toggleSelected'; + var isSelected; + // Update all legend components + ecModel.eachComponent('legend', function (legendModel) { + if (isToggleSelect && isSelected != null) { + // Force other legend has same selected status + // Or the first is toggled to true and other are toggled to false + // In the case one legend has some item unSelected in option. And if other legend + // doesn't has the item, they will assume it is selected. + legendModel[isSelected ? 'select' : 'unSelect'](payload.name); + } + else { + legendModel[methodName](payload.name); + isSelected = legendModel.isSelected(payload.name); + } + var legendData = legendModel.getData(); + zrUtil.each(legendData, function (model) { + var name = model.get('name'); + // Wrap element + if (name === '\n' || name === '') { + return; + } + var isItemSelected = legendModel.isSelected(name); + if (name in selectedMap) { + // Unselected if any legend is unselected + selectedMap[name] = selectedMap[name] && isItemSelected; + } + else { + selectedMap[name] = isItemSelected; + } + }); + }); + // Return the event explicitly + return { + name: payload.name, + selected: selectedMap + }; + } + /** + * @event legendToggleSelect + * @type {Object} + * @property {string} type 'legendToggleSelect' + * @property {string} [from] + * @property {string} name Series name or data item name + */ + echarts.registerAction( + 'legendToggleSelect', 'legendselectchanged', + zrUtil.curry(legendSelectActionHandler, 'toggleSelected') + ); + + /** + * @event legendSelect + * @type {Object} + * @property {string} type 'legendSelect' + * @property {string} name Series name or data item name + */ + echarts.registerAction( + 'legendSelect', 'legendselected', + zrUtil.curry(legendSelectActionHandler, 'select') + ); + + /** + * @event legendUnSelect + * @type {Object} + * @property {string} type 'legendUnSelect' + * @property {string} name Series name or data item name + */ + echarts.registerAction( + 'legendUnSelect', 'legendunselected', + zrUtil.curry(legendSelectActionHandler, 'unSelect') + ); + + +/***/ }, +/* 265 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var symbolCreator = __webpack_require__(100); + var graphic = __webpack_require__(42); + var listComponentHelper = __webpack_require__(266); + + var curry = zrUtil.curry; + + var LEGEND_DISABLE_COLOR = '#ccc'; + + function dispatchSelectAction(name, api) { + api.dispatchAction({ + type: 'legendToggleSelect', + name: name + }); + } + + function dispatchHighlightAction(seriesModel, dataName, api) { + seriesModel.get('legendHoverLink') && api.dispatchAction({ + type: 'highlight', + seriesName: seriesModel.name, + name: dataName + }); + } + + function dispatchDownplayAction(seriesModel, dataName, api) { + seriesModel.get('legendHoverLink') &&api.dispatchAction({ + type: 'downplay', + seriesName: seriesModel.name, + name: dataName + }); + } + + module.exports = __webpack_require__(1).extendComponentView({ + + type: 'legend', + + init: function () { + this._symbolTypeStore = {}; + }, + + render: function (legendModel, ecModel, api) { + var group = this.group; + group.removeAll(); + + if (!legendModel.get('show')) { + return; + } + + var selectMode = legendModel.get('selectedMode'); + var itemAlign = legendModel.get('align'); + + if (itemAlign === 'auto') { + itemAlign = (legendModel.get('left') === 'right' + && legendModel.get('orient') === 'vertical') + ? 'right' : 'left'; + } + + var legendItemMap = {}; + var legendDrawedMap = {}; + zrUtil.each(legendModel.getData(), function (itemModel) { + var seriesName = itemModel.get('name'); + // Use empty string or \n as a newline string + if (seriesName === '' || seriesName === '\n') { + group.add(new graphic.Group({ + newline: true + })); + } + + var seriesModel = ecModel.getSeriesByName(seriesName)[0]; + + legendItemMap[seriesName] = itemModel; + + if (!seriesModel || legendDrawedMap[seriesName]) { + // Series not exists + return; + } + + var data = seriesModel.getData(); + var color = data.getVisual('color'); + + // If color is a callback function + if (typeof color === 'function') { + // Use the first data + color = color(seriesModel.getDataParams(0)); + } + + // Using rect symbol defaultly + var legendSymbolType = data.getVisual('legendSymbol') || 'roundRect'; + var symbolType = data.getVisual('symbol'); + + var itemGroup = this._createItem( + seriesName, itemModel, legendModel, + legendSymbolType, symbolType, + itemAlign, color, + selectMode + ); + + itemGroup.on('click', curry(dispatchSelectAction, seriesName, api)) + .on('mouseover', curry(dispatchHighlightAction, seriesModel, '', api)) + .on('mouseout', curry(dispatchDownplayAction, seriesModel, '', api)); + + legendDrawedMap[seriesName] = true; + }, this); + + ecModel.eachRawSeries(function (seriesModel) { + if (seriesModel.legendDataProvider) { + var data = seriesModel.legendDataProvider(); + data.each(function (idx) { + var name = data.getName(idx); + + // Avoid mutiple series use the same data name + if (!legendItemMap[name] || legendDrawedMap[name]) { + return; + } + + var color = data.getItemVisual(idx, 'color'); + + var legendSymbolType = 'roundRect'; + + var itemGroup = this._createItem( + name, legendItemMap[name], legendModel, + legendSymbolType, null, + itemAlign, color, + selectMode + ); + + itemGroup.on('click', curry(dispatchSelectAction, name, api)) + // FIXME Should not specify the series name + .on('mouseover', curry(dispatchHighlightAction, seriesModel, name, api)) + .on('mouseout', curry(dispatchDownplayAction, seriesModel, name, api)); + + legendDrawedMap[name] = true; + }, false, this); + } + }, this); + + listComponentHelper.layout(group, legendModel, api); + // Render background after group is layout + // FIXME + listComponentHelper.addBackground(group, legendModel); + }, + + _createItem: function ( + name, itemModel, legendModel, + legendSymbolType, symbolType, + itemAlign, color, selectMode + ) { + var itemWidth = legendModel.get('itemWidth'); + var itemHeight = legendModel.get('itemHeight'); + + var isSelected = legendModel.isSelected(name); + var itemGroup = new graphic.Group(); + + var textStyleModel = itemModel.getModel('textStyle'); + + var itemIcon = itemModel.get('icon'); + + // Use user given icon first + legendSymbolType = itemIcon || legendSymbolType; + itemGroup.add(symbolCreator.createSymbol( + legendSymbolType, 0, 0, itemWidth, itemHeight, isSelected ? color : LEGEND_DISABLE_COLOR + )); + + // Compose symbols + // PENDING + if (!itemIcon && symbolType + // At least show one symbol, can't be all none + && ((symbolType !== legendSymbolType) || symbolType == 'none') + ) { + var size = itemHeight * 0.8; + if (symbolType === 'none') { + symbolType = 'circle'; + } + // Put symbol in the center + itemGroup.add(symbolCreator.createSymbol( + symbolType, (itemWidth - size) / 2, (itemHeight - size) / 2, size, size, + isSelected ? color : LEGEND_DISABLE_COLOR + )); + } + + // Text + var textX = itemAlign === 'left' ? itemWidth + 5 : -5; + var textAlign = itemAlign; + + var formatter = legendModel.get('formatter'); + if (typeof formatter === 'string' && formatter) { + name = formatter.replace('{name}', name); + } + else if (typeof formatter === 'function') { + name = formatter(name); + } + + var text = new graphic.Text({ + style: { + text: name, + x: textX, + y: itemHeight / 2, + fill: isSelected ? textStyleModel.getTextColor() : LEGEND_DISABLE_COLOR, + textFont: textStyleModel.getFont(), + textAlign: textAlign, + textVerticalAlign: 'middle' + } + }); + itemGroup.add(text); + + // Add a invisible rect to increase the area of mouse hover + itemGroup.add(new graphic.Rect({ + shape: itemGroup.getBoundingRect(), + invisible: true + })); + + itemGroup.eachChild(function (child) { + child.silent = !selectMode; + }); + + this.group.add(itemGroup); + + return itemGroup; + } + }); + + +/***/ }, +/* 266 */ +/***/ function(module, exports, __webpack_require__) { + + + // List layout + var layout = __webpack_require__(21); + var formatUtil = __webpack_require__(6); + var graphic = __webpack_require__(42); + + function positionGroup(group, model, api) { + layout.positionGroup( + group, model.getBoxLayoutParams(), + { + width: api.getWidth(), + height: api.getHeight() + }, + model.get('padding') + ); + } + + module.exports = { + /** + * Layout list like component. + * It will box layout each items in group of component and then position the whole group in the viewport + * @param {module:zrender/group/Group} group + * @param {module:echarts/model/Component} componentModel + * @param {module:echarts/ExtensionAPI} + */ + layout: function (group, componentModel, api) { + var rect = layout.getLayoutRect(componentModel.getBoxLayoutParams(), { + width: api.getWidth(), + height: api.getHeight() + }, componentModel.get('padding')); + layout.box( + componentModel.get('orient'), + group, + componentModel.get('itemGap'), + rect.width, + rect.height + ); + + positionGroup(group, componentModel, api); + }, + + addBackground: function (group, componentModel) { + var padding = formatUtil.normalizeCssArray( + componentModel.get('padding') + ); + var boundingRect = group.getBoundingRect(); + var style = componentModel.getItemStyle(['color', 'opacity']); + style.fill = componentModel.get('backgroundColor'); + var rect = new graphic.Rect({ + shape: { + x: boundingRect.x - padding[3], + y: boundingRect.y - padding[0], + width: boundingRect.width + padding[1] + padding[3], + height: boundingRect.height + padding[0] + padding[2] + }, + style: style, + silent: true, + z2: -1 + }); + graphic.subPixelOptimizeRect(rect); + + group.add(rect); + } + }; + + +/***/ }, +/* 267 */ +/***/ function(module, exports) { + + + module.exports = function (ecModel) { + var legendModels = ecModel.findComponents({ + mainType: 'legend' + }); + if (legendModels && legendModels.length) { + ecModel.filterSeries(function (series) { + // If in any legend component the status is not selected. + // Because in legend series + for (var i = 0; i < legendModels.length; i++) { + if (!legendModels[i].isSelected(series.name)) { + return false; + } + } + return true; + }); + } + }; + + +/***/ }, +/* 268 */ +/***/ function(module, exports, __webpack_require__) { + + // FIXME Better way to pack data in graphic element + + + __webpack_require__(269); + + __webpack_require__(270); + + // Show tip action + /** + * @action + * @property {string} type + * @property {number} seriesIndex + * @property {number} dataIndex + * @property {number} [x] + * @property {number} [y] + */ + __webpack_require__(1).registerAction( + { + type: 'showTip', + event: 'showTip', + update: 'none' + }, + // noop + function () {} + ); + // Hide tip action + __webpack_require__(1).registerAction( + { + type: 'hideTip', + event: 'hideTip', + update: 'none' + }, + // noop + function () {} + ); + + +/***/ }, +/* 269 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(1).extendComponentModel({ + + type: 'tooltip', + + defaultOption: { + zlevel: 0, + + z: 8, + + show: true, + + // tooltip主体内容 + showContent: true, + + // 触发类型,默认数据触发,见下图,可选为:'item' ¦ 'axis' + trigger: 'item', + + // 触发条件,支持 'click' | 'mousemove' + triggerOn: 'mousemove', + + // 是否永远显示 content + alwaysShowContent: false, + + // 位置 {Array} | {Function} + // position: null + + // 内容格式器:{string}(Template) ¦ {Function} + // formatter: null + + // 隐藏延迟,单位ms + hideDelay: 100, + + // 动画变换时间,单位s + transitionDuration: 0.4, + + enterable: false, + + // 提示背景颜色,默认为透明度为0.7的黑色 + backgroundColor: 'rgba(50,50,50,0.7)', + + // 提示边框颜色 + borderColor: '#333', + + // 提示边框圆角,单位px,默认为4 + borderRadius: 4, + + // 提示边框线宽,单位px,默认为0(无边框) + borderWidth: 0, + + // 提示内边距,单位px,默认各方向内边距为5, + // 接受数组分别设定上右下左边距,同css + padding: 5, + + // 坐标轴指示器,坐标轴触发有效 + axisPointer: { + // 默认为直线 + // 可选为:'line' | 'shadow' | 'cross' + type: 'line', + + // type 为 line 的时候有效,指定 tooltip line 所在的轴,可选 + // 可选 'x' | 'y' | 'angle' | 'radius' | 'auto' + // 默认 'auto',会选择类型为 cateogry 的轴,对于双数值轴,笛卡尔坐标系会默认选择 x 轴 + // 极坐标系会默认选择 angle 轴 + axis: 'auto', + + animation: true, + animationDurationUpdate: 200, + animationEasingUpdate: 'exponentialOut', + + // 直线指示器样式设置 + lineStyle: { + color: '#555', + width: 1, + type: 'solid' + }, + + crossStyle: { + color: '#555', + width: 1, + type: 'dashed', + + // TODO formatter + textStyle: {} + }, + + // 阴影指示器样式设置 + shadowStyle: { + color: 'rgba(150,150,150,0.3)' + } + }, + textStyle: { + color: '#fff', + fontSize: 14 + } + } + }); + + +/***/ }, +/* 270 */ +/***/ function(module, exports, __webpack_require__) { + + + + var TooltipContent = __webpack_require__(271); + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + var formatUtil = __webpack_require__(6); + var numberUtil = __webpack_require__(7); + var parsePercent = numberUtil.parsePercent; + var env = __webpack_require__(78); + + function dataEqual(a, b) { + if (!a || !b) { + return false; + } + var round = numberUtil.round; + return round(a[0]) === round(b[0]) + && round(a[1]) === round(b[1]); + } + /** + * @inner + */ + function makeLineShape(x1, y1, x2, y2) { + return { + x1: x1, + y1: y1, + x2: x2, + y2: y2 + }; + } + + /** + * @inner + */ + function makeRectShape(x, y, width, height) { + return { + x: x, + y: y, + width: width, + height: height + }; + } + + /** + * @inner + */ + function makeSectorShape(cx, cy, r0, r, startAngle, endAngle) { + return { + cx: cx, + cy: cy, + r0: r0, + r: r, + startAngle: startAngle, + endAngle: endAngle, + clockwise: true + }; + } + + function refixTooltipPosition(x, y, el, viewWidth, viewHeight) { + var width = el.clientWidth; + var height = el.clientHeight; + var gap = 20; + + if (x + width + gap > viewWidth) { + x -= width + gap; + } + else { + x += gap; + } + if (y + height + gap > viewHeight) { + y -= height + gap; + } + else { + y += gap; + } + return [x, y]; + } + + function calcTooltipPosition(position, rect, dom) { + var domWidth = dom.clientWidth; + var domHeight = dom.clientHeight; + var gap = 5; + var x = 0; + var y = 0; + var rectWidth = rect.width; + var rectHeight = rect.height; + switch (position) { + case 'inside': + x = rect.x + rectWidth / 2 - domWidth / 2; + y = rect.y + rectHeight / 2 - domHeight / 2; + break; + case 'top': + x = rect.x + rectWidth / 2 - domWidth / 2; + y = rect.y - domHeight - gap; + break; + case 'bottom': + x = rect.x + rectWidth / 2 - domWidth / 2; + y = rect.y + rectHeight + gap; + break; + case 'left': + x = rect.x - domWidth - gap; + y = rect.y + rectHeight / 2 - domHeight / 2; + break; + case 'right': + x = rect.x + rectWidth + gap; + y = rect.y + rectHeight / 2 - domHeight / 2; + } + return [x, y]; + } + + /** + * @param {string|Function|Array.} positionExpr + * @param {number} x Mouse x + * @param {number} y Mouse y + * @param {module:echarts/component/tooltip/TooltipContent} content + * @param {Object|} params + * @param {module:zrender/Element} el target element + * @param {module:echarts/ExtensionAPI} api + * @return {Array.} + */ + function updatePosition(positionExpr, x, y, content, params, el, api) { + var viewWidth = api.getWidth(); + var viewHeight = api.getHeight(); + + var rect = el && el.getBoundingRect().clone(); + el && rect.applyTransform(el.transform); + if (typeof positionExpr === 'function') { + // Callback of position can be an array or a string specify the positiont + positionExpr = positionExpr([x, y], params, rect); + } + + if (zrUtil.isArray(positionExpr)) { + x = parsePercent(positionExpr[0], viewWidth); + y = parsePercent(positionExpr[1], viewHeight); + } + // Specify tooltip position by string 'top' 'bottom' 'left' 'right' around graphic element + else if (typeof positionExpr === 'string' && el) { + var pos = calcTooltipPosition( + positionExpr, rect, content.el + ); + x = pos[0]; + y = pos[1]; + } + else { + var pos = refixTooltipPosition( + x, y, content.el, viewWidth, viewHeight + ); + x = pos[0]; + y = pos[1]; + } + + content.moveTo(x, y); + } + + function ifSeriesSupportAxisTrigger(seriesModel) { + var coordSys = seriesModel.coordinateSystem; + var trigger = seriesModel.get('tooltip.trigger', true); + // Ignore series use item tooltip trigger and series coordinate system is not cartesian or + return !(!coordSys + || (coordSys.type !== 'cartesian2d' && coordSys.type !== 'polar' && coordSys.type !== 'single') + || trigger === 'item'); + } + + __webpack_require__(1).extendComponentView({ + + type: 'tooltip', + + _axisPointers: {}, + + init: function (ecModel, api) { + if (env.node) { + return; + } + var tooltipContent = new TooltipContent(api.getDom(), api); + this._tooltipContent = tooltipContent; + + api.on('showTip', this._manuallyShowTip, this); + api.on('hideTip', this._manuallyHideTip, this); + }, + + render: function (tooltipModel, ecModel, api) { + if (env.node) { + return; + } + + // Reset + this.group.removeAll(); + + /** + * @type {Object} + * @private + */ + this._axisPointers = {}; + + /** + * @private + * @type {module:echarts/component/tooltip/TooltipModel} + */ + this._tooltipModel = tooltipModel; + + /** + * @private + * @type {module:echarts/model/Global} + */ + this._ecModel = ecModel; + + /** + * @private + * @type {module:echarts/ExtensionAPI} + */ + this._api = api; + + /** + * @type {Object} + * @private + */ + this._lastHover = { + // data + // payloadBatch + }; + + var tooltipContent = this._tooltipContent; + tooltipContent.update(); + tooltipContent.enterable = tooltipModel.get('enterable'); + this._alwaysShowContent = tooltipModel.get('alwaysShowContent'); + + /** + * @type {Object.} + */ + this._seriesGroupByAxis = this._prepareAxisTriggerData( + tooltipModel, ecModel + ); + + var crossText = this._crossText; + if (crossText) { + this.group.add(crossText); + } + + // Try to keep the tooltip show when refreshing + if (this._lastX != null && this._lastY != null) { + var self = this; + clearTimeout(this._refreshUpdateTimeout); + this._refreshUpdateTimeout = setTimeout(function () { + // Show tip next tick after other charts are rendered + // In case highlight action has wrong result + // FIXME + self._manuallyShowTip({ + x: self._lastX, + y: self._lastY + }); + }); + } + + var zr = this._api.getZr(); + var tryShow = this._tryShow; + zr.off('click', tryShow); + zr.off('mousemove', tryShow); + zr.off('mouseout', this._hide); + if (tooltipModel.get('triggerOn') === 'click') { + zr.on('click', tryShow, this); + } + else { + zr.on('mousemove', tryShow, this); + zr.on('mouseout', this._hide, this); + } + + }, + + /** + * Show tip manually by + * dispatchAction({ + * type: 'showTip', + * x: 10, + * y: 10 + * }); + * Or + * dispatchAction({ + * type: 'showTip', + * seriesIndex: 0, + * dataIndex: 1 + * }); + * + * TODO Batch + */ + _manuallyShowTip: function (event) { + // From self + if (event.from === this.uid) { + return; + } + + var ecModel = this._ecModel; + var seriesIndex = event.seriesIndex; + var dataIndex = event.dataIndex; + var seriesModel = ecModel.getSeriesByIndex(seriesIndex); + var api = this._api; + + if (event.x == null || event.y == null) { + if (!seriesModel) { + // Find the first series can use axis trigger + ecModel.eachSeries(function (_series) { + if (ifSeriesSupportAxisTrigger(_series) && !seriesModel) { + seriesModel = _series; + } + }); + } + if (seriesModel) { + var data = seriesModel.getData(); + if (dataIndex == null) { + dataIndex = data.indexOfName(event.name); + } + var el = data.getItemGraphicEl(dataIndex); + var cx, cy; + // Try to get the point in coordinate system + var coordSys = seriesModel.coordinateSystem; + if (coordSys && coordSys.dataToPoint) { + var point = coordSys.dataToPoint( + data.getValues(coordSys.dimensions, dataIndex, true) + ); + cx = point && point[0]; + cy = point && point[1]; + } + else if (el) { + // Use graphic bounding rect + var rect = el.getBoundingRect().clone(); + rect.applyTransform(el.transform); + cx = rect.x + rect.width / 2; + cy = rect.y + rect.height / 2; + } + if (cx != null && cy != null) { + this._tryShow({ + offsetX: cx, + offsetY: cy, + target: el, + event: {} + }); + } + } + } + else { + var el = api.getZr().handler.findHover(event.x, event.y); + this._tryShow({ + offsetX: event.x, + offsetY: event.y, + target: el, + event: {} + }); + } + }, + + _manuallyHideTip: function (e) { + if (e.from === this.uid) { + return; + } + + this._hide(); + }, + + _prepareAxisTriggerData: function (tooltipModel, ecModel) { + // Prepare data for axis trigger + var seriesGroupByAxis = {}; + ecModel.eachSeries(function (seriesModel) { + if (ifSeriesSupportAxisTrigger(seriesModel)) { + var coordSys = seriesModel.coordinateSystem; + var baseAxis; + var key; + + // Only cartesian2d, polar and single support axis trigger + if (coordSys.type === 'cartesian2d') { + // FIXME `axisPointer.axis` is not baseAxis + baseAxis = coordSys.getBaseAxis(); + key = baseAxis.dim + baseAxis.index; + } + else if (coordSys.type === 'single') { + baseAxis = coordSys.getAxis(); + key = baseAxis.dim + baseAxis.type; + } + else { + baseAxis = coordSys.getBaseAxis(); + key = baseAxis.dim + coordSys.name; + } + + seriesGroupByAxis[key] = seriesGroupByAxis[key] || { + coordSys: [], + series: [] + }; + seriesGroupByAxis[key].coordSys.push(coordSys); + seriesGroupByAxis[key].series.push(seriesModel); + } + }, this); + + return seriesGroupByAxis; + }, + + /** + * mousemove handler + * @param {Object} e + * @private + */ + _tryShow: function (e) { + var el = e.target; + var tooltipModel = this._tooltipModel; + var globalTrigger = tooltipModel.get('trigger'); + var ecModel = this._ecModel; + var api = this._api; + + if (!tooltipModel) { + return; + } + + // Save mouse x, mouse y. So we can try to keep showing the tip if chart is refreshed + this._lastX = e.offsetX; + this._lastY = e.offsetY; + + // Always show item tooltip if mouse is on the element with dataIndex + if (el && el.dataIndex != null) { + // Use hostModel in element if possible + // Used when mouseover on a element like markPoint or edge + // In which case, the data is not main data in series. + var hostModel = el.hostModel || ecModel.getSeriesByIndex(el.seriesIndex); + var dataIndex = el.dataIndex; + var itemModel = hostModel.getData().getItemModel(dataIndex); + // Series or single data may use item trigger when global is axis trigger + if ((itemModel.get('tooltip.trigger') || globalTrigger) === 'axis') { + this._showAxisTooltip(tooltipModel, ecModel, e); + } + else { + // Reset ticket + this._ticket = ''; + // If either single data or series use item trigger + this._hideAxisPointer(); + // Reset last hover and dispatch downplay action + this._resetLastHover(); + + this._showItemTooltipContent(hostModel, dataIndex, e); + } + + api.dispatchAction({ + type: 'showTip', + from: this.uid, + dataIndex: el.dataIndex, + seriesIndex: el.seriesIndex + }); + } + else { + if (globalTrigger === 'item') { + this._hide(); + } + else { + // Try show axis tooltip + this._showAxisTooltip(tooltipModel, ecModel, e); + } + + // Action of cross pointer + // other pointer types will trigger action in _dispatchAndShowSeriesTooltipContent method + if (tooltipModel.get('axisPointer.type') === 'cross') { + api.dispatchAction({ + type: 'showTip', + from: this.uid, + x: e.offsetX, + y: e.offsetY + }); + } + } + }, + + /** + * Show tooltip on axis + * @param {module:echarts/component/tooltip/TooltipModel} tooltipModel + * @param {module:echarts/model/Global} ecModel + * @param {Object} e + * @private + */ + _showAxisTooltip: function (tooltipModel, ecModel, e) { + var axisPointerModel = tooltipModel.getModel('axisPointer'); + var axisPointerType = axisPointerModel.get('type'); + + if (axisPointerType === 'cross') { + var el = e.target; + if (el && el.dataIndex != null) { + var seriesModel = ecModel.getSeriesByIndex(el.seriesIndex); + var dataIndex = el.dataIndex; + this._showItemTooltipContent(seriesModel, dataIndex, e); + } + } + + this._showAxisPointer(); + var allNotShow = true; + zrUtil.each(this._seriesGroupByAxis, function (seriesCoordSysSameAxis) { + // Try show the axis pointer + var allCoordSys = seriesCoordSysSameAxis.coordSys; + var coordSys = allCoordSys[0]; + + // If mouse position is not in the grid or polar + var point = [e.offsetX, e.offsetY]; + + if (!coordSys.containPoint(point)) { + // Hide axis pointer + this._hideAxisPointer(coordSys.name); + return; + } + + allNotShow = false; + // Make sure point is discrete on cateogry axis + var dimensions = coordSys.dimensions; + var value = coordSys.pointToData(point, true); + point = coordSys.dataToPoint(value); + var baseAxis = coordSys.getBaseAxis(); + var axisType = axisPointerModel.get('axis'); + if (axisType === 'auto') { + axisType = baseAxis.dim; + } + + var contentNotChange = false; + var lastHover = this._lastHover; + if (axisPointerType === 'cross') { + // If hover data not changed + // Possible when two axes are all category + if (dataEqual(lastHover.data, value)) { + contentNotChange = true; + } + lastHover.data = value; + } + else { + var valIndex = zrUtil.indexOf(dimensions, axisType); + + // If hover data not changed on the axis dimension + if (lastHover.data === value[valIndex]) { + contentNotChange = true; + } + lastHover.data = value[valIndex]; + } + + if (coordSys.type === 'cartesian2d' && !contentNotChange) { + this._showCartesianPointer( + axisPointerModel, coordSys, axisType, point + ); + } + else if (coordSys.type === 'polar' && !contentNotChange) { + this._showPolarPointer( + axisPointerModel, coordSys, axisType, point + ); + } + else if (coordSys.type === 'single' && !contentNotChange) { + this._showSinglePointer( + axisPointerModel, coordSys, axisType, point + ); + } + + if (axisPointerType !== 'cross') { + this._dispatchAndShowSeriesTooltipContent( + coordSys, seriesCoordSysSameAxis.series, point, value, contentNotChange + ); + } + }, this); + + if (allNotShow) { + this._hide(); + } + }, + + /** + * Show tooltip on axis of cartesian coordinate + * @param {module:echarts/model/Model} axisPointerModel + * @param {module:echarts/coord/cartesian/Cartesian2D} cartesians + * @param {string} axisType + * @param {Array.} point + * @private + */ + _showCartesianPointer: function (axisPointerModel, cartesian, axisType, point) { + var self = this; + + var axisPointerType = axisPointerModel.get('type'); + var moveAnimation = axisPointerType !== 'cross'; + + if (axisPointerType === 'cross') { + moveGridLine('x', point, cartesian.getAxis('y').getGlobalExtent()); + moveGridLine('y', point, cartesian.getAxis('x').getGlobalExtent()); + + this._updateCrossText(cartesian, point, axisPointerModel); + } + else { + var otherAxis = cartesian.getAxis(axisType === 'x' ? 'y' : 'x'); + var otherExtent = otherAxis.getGlobalExtent(); + + if (cartesian.type === 'cartesian2d') { + (axisPointerType === 'line' ? moveGridLine : moveGridShadow)( + axisType, point, otherExtent + ); + } + } + + /** + * @inner + */ + function moveGridLine(axisType, point, otherExtent) { + var targetShape = axisType === 'x' + ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1]) + : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]); + + var pointerEl = self._getPointerElement( + cartesian, axisPointerModel, axisType, targetShape + ); + moveAnimation + ? graphic.updateProps(pointerEl, { + shape: targetShape + }, axisPointerModel) + : pointerEl.attr({ + shape: targetShape + }); + } + + /** + * @inner + */ + function moveGridShadow(axisType, point, otherExtent) { + var axis = cartesian.getAxis(axisType); + var bandWidth = axis.getBandWidth(); + var span = otherExtent[1] - otherExtent[0]; + var targetShape = axisType === 'x' + ? makeRectShape(point[0] - bandWidth / 2, otherExtent[0], bandWidth, span) + : makeRectShape(otherExtent[0], point[1] - bandWidth / 2, span, bandWidth); + + var pointerEl = self._getPointerElement( + cartesian, axisPointerModel, axisType, targetShape + ); + moveAnimation + ? graphic.updateProps(pointerEl, { + shape: targetShape + }, axisPointerModel) + : pointerEl.attr({ + shape: targetShape + }); + } + }, + + _showSinglePointer: function (axisPointerModel, single, axisType, point) { + var self = this; + var axisPointerType = axisPointerModel.get('type'); + var moveAnimation = axisPointerType !== 'cross'; + var rect = single.getRect(); + var otherExtent = [rect.y, rect.y + rect.height]; + + moveSingleLine(axisType, point, otherExtent); + + /** + * @inner + */ + function moveSingleLine(axisType, point, otherExtent) { + var axis = single.getAxis(); + var orient = axis.orient; + + var targetShape = orient === 'horizontal' + ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1]) + : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]); + + var pointerEl = self._getPointerElement( + single, axisPointerModel, axisType, targetShape + ); + moveAnimation + ? graphic.updateProps(pointerEl, { + shape: targetShape + }, axisPointerModel) + : pointerEl.attr({ + shape: targetShape + }); + } + + }, + + /** + * Show tooltip on axis of polar coordinate + * @param {module:echarts/model/Model} axisPointerModel + * @param {Array.} polar + * @param {string} axisType + * @param {Array.} point + */ + _showPolarPointer: function (axisPointerModel, polar, axisType, point) { + var self = this; + + var axisPointerType = axisPointerModel.get('type'); + + var angleAxis = polar.getAngleAxis(); + var radiusAxis = polar.getRadiusAxis(); + + var moveAnimation = axisPointerType !== 'cross'; + + if (axisPointerType === 'cross') { + movePolarLine('angle', point, radiusAxis.getExtent()); + movePolarLine('radius', point, angleAxis.getExtent()); + + this._updateCrossText(polar, point, axisPointerModel); + } + else { + var otherAxis = polar.getAxis(axisType === 'radius' ? 'angle' : 'radius'); + var otherExtent = otherAxis.getExtent(); + + (axisPointerType === 'line' ? movePolarLine : movePolarShadow)( + axisType, point, otherExtent + ); + } + /** + * @inner + */ + function movePolarLine(axisType, point, otherExtent) { + var mouseCoord = polar.pointToCoord(point); + + var targetShape; + + if (axisType === 'angle') { + var p1 = polar.coordToPoint([otherExtent[0], mouseCoord[1]]); + var p2 = polar.coordToPoint([otherExtent[1], mouseCoord[1]]); + targetShape = makeLineShape(p1[0], p1[1], p2[0], p2[1]); + } + else { + targetShape = { + cx: polar.cx, + cy: polar.cy, + r: mouseCoord[0] + }; + } + + var pointerEl = self._getPointerElement( + polar, axisPointerModel, axisType, targetShape + ); + + moveAnimation + ? graphic.updateProps(pointerEl, { + shape: targetShape + }, axisPointerModel) + : pointerEl.attr({ + shape: targetShape + }); + } + + /** + * @inner + */ + function movePolarShadow(axisType, point, otherExtent) { + var axis = polar.getAxis(axisType); + var bandWidth = axis.getBandWidth(); + + var mouseCoord = polar.pointToCoord(point); + + var targetShape; + + var radian = Math.PI / 180; + + if (axisType === 'angle') { + targetShape = makeSectorShape( + polar.cx, polar.cy, + otherExtent[0], otherExtent[1], + // In ECharts y is negative if angle is positive + (-mouseCoord[1] - bandWidth / 2) * radian, + (-mouseCoord[1] + bandWidth / 2) * radian + ); + } + else { + targetShape = makeSectorShape( + polar.cx, polar.cy, + mouseCoord[0] - bandWidth / 2, + mouseCoord[0] + bandWidth / 2, + 0, Math.PI * 2 + ); + } + + var pointerEl = self._getPointerElement( + polar, axisPointerModel, axisType, targetShape + ); + moveAnimation + ? graphic.updateProps(pointerEl, { + shape: targetShape + }, axisPointerModel) + : pointerEl.attr({ + shape: targetShape + }); + } + }, + + _updateCrossText: function (coordSys, point, axisPointerModel) { + var crossStyleModel = axisPointerModel.getModel('crossStyle'); + var textStyleModel = crossStyleModel.getModel('textStyle'); + + var tooltipModel = this._tooltipModel; + + var text = this._crossText; + if (!text) { + text = this._crossText = new graphic.Text({ + style: { + textAlign: 'left', + textVerticalAlign: 'bottom' + } + }); + this.group.add(text); + } + + var value = coordSys.pointToData(point); + + var dims = coordSys.dimensions; + value = zrUtil.map(value, function (val, idx) { + var axis = coordSys.getAxis(dims[idx]); + if (axis.type === 'category' || axis.type === 'time') { + val = axis.scale.getLabel(val); + } + else { + val = formatUtil.addCommas( + val.toFixed(axis.getPixelPrecision()) + ); + } + return val; + }); + + text.setStyle({ + fill: textStyleModel.getTextColor() || crossStyleModel.get('color'), + textFont: textStyleModel.getFont(), + text: value.join(', '), + x: point[0] + 5, + y: point[1] - 5 + }); + text.z = tooltipModel.get('z'); + text.zlevel = tooltipModel.get('zlevel'); + }, + + _getPointerElement: function (coordSys, pointerModel, axisType, initShape) { + var tooltipModel = this._tooltipModel; + var z = tooltipModel.get('z'); + var zlevel = tooltipModel.get('zlevel'); + var axisPointers = this._axisPointers; + var coordSysName = coordSys.name; + axisPointers[coordSysName] = axisPointers[coordSysName] || {}; + if (axisPointers[coordSysName][axisType]) { + return axisPointers[coordSysName][axisType]; + } + + // Create if not exists + var pointerType = pointerModel.get('type'); + var styleModel = pointerModel.getModel(pointerType + 'Style'); + var isShadow = pointerType === 'shadow'; + var style = styleModel[isShadow ? 'getAreaStyle' : 'getLineStyle'](); + + var elementType = coordSys.type === 'polar' + ? (isShadow ? 'Sector' : (axisType === 'radius' ? 'Circle' : 'Line')) + : (isShadow ? 'Rect' : 'Line'); + + isShadow ? (style.stroke = null) : (style.fill = null); + + var el = axisPointers[coordSysName][axisType] = new graphic[elementType]({ + style: style, + z: z, + zlevel: zlevel, + silent: true, + shape: initShape + }); + + this.group.add(el); + return el; + }, + + /** + * Dispatch actions and show tooltip on series + * @param {Array.} seriesList + * @param {Array.} point + * @param {Array.} value + * @param {boolean} contentNotChange + * @param {Object} e + */ + _dispatchAndShowSeriesTooltipContent: function ( + coordSys, seriesList, point, value, contentNotChange + ) { + + var rootTooltipModel = this._tooltipModel; + var tooltipContent = this._tooltipContent; + + var baseAxis = coordSys.getBaseAxis(); + + var payloadBatch = zrUtil.map(seriesList, function (series) { + return { + seriesIndex: series.seriesIndex, + dataIndex: series.getAxisTooltipDataIndex + ? series.getAxisTooltipDataIndex(series.coordDimToDataDim(baseAxis.dim), value, baseAxis) + : series.getData().indexOfNearest( + series.coordDimToDataDim(baseAxis.dim)[0], + value[baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1] + ) + }; + }); + + var lastHover = this._lastHover; + var api = this._api; + // Dispatch downplay action + if (lastHover.payloadBatch && !contentNotChange) { + api.dispatchAction({ + type: 'downplay', + batch: lastHover.payloadBatch + }); + } + // Dispatch highlight action + if (!contentNotChange) { + api.dispatchAction({ + type: 'highlight', + batch: payloadBatch + }); + lastHover.payloadBatch = payloadBatch; + } + // Dispatch showTip action + api.dispatchAction({ + type: 'showTip', + dataIndex: payloadBatch[0].dataIndex, + seriesIndex: payloadBatch[0].seriesIndex, + from: this.uid + }); + + if (baseAxis && rootTooltipModel.get('showContent')) { + + var formatter = rootTooltipModel.get('formatter'); + var positionExpr = rootTooltipModel.get('position'); + var html; + + var paramsList = zrUtil.map(seriesList, function (series, index) { + return series.getDataParams(payloadBatch[index].dataIndex); + }); + // If only one series + // FIXME + // if (paramsList.length === 1) { + // paramsList = paramsList[0]; + // } + + tooltipContent.show(rootTooltipModel); + + // Update html content + var firstDataIndex = payloadBatch[0].dataIndex; + if (!contentNotChange) { + // Reset ticket + this._ticket = ''; + if (!formatter) { + // Default tooltip content + // FIXME + // (1) shold be the first data which has name? + // (2) themeRiver, firstDataIndex is array, and first line is unnecessary. + var firstLine = seriesList[0].getData().getName(firstDataIndex); + html = (firstLine ? firstLine + '
' : '') + + zrUtil.map(seriesList, function (series, index) { + return series.formatTooltip(payloadBatch[index].dataIndex, true); + }).join('
'); + } + else { + if (typeof formatter === 'string') { + html = formatUtil.formatTpl(formatter, paramsList); + } + else if (typeof formatter === 'function') { + var self = this; + var ticket = 'axis_' + coordSys.name + '_' + firstDataIndex; + var callback = function (cbTicket, html) { + if (cbTicket === self._ticket) { + tooltipContent.setContent(html); + + updatePosition( + positionExpr, point[0], point[1], + tooltipContent, paramsList, null, api + ); + } + }; + self._ticket = ticket; + html = formatter(paramsList, ticket, callback); + } + } + + tooltipContent.setContent(html); + } + + updatePosition( + positionExpr, point[0], point[1], + tooltipContent, paramsList, null, api + ); + } + }, + + /** + * Show tooltip on item + * @param {module:echarts/model/Series} seriesModel + * @param {number} dataIndex + * @param {Object} e + */ + _showItemTooltipContent: function (seriesModel, dataIndex, e) { + // FIXME Graph data + var api = this._api; + var data = seriesModel.getData(); + var itemModel = data.getItemModel(dataIndex); + + var rootTooltipModel = this._tooltipModel; + + var tooltipContent = this._tooltipContent; + + var tooltipModel = itemModel.getModel('tooltip'); + + // If series model + if (tooltipModel.parentModel) { + tooltipModel.parentModel.parentModel = rootTooltipModel; + } + else { + tooltipModel.parentModel = this._tooltipModel; + } + + if (tooltipModel.get('showContent')) { + var formatter = tooltipModel.get('formatter'); + var positionExpr = tooltipModel.get('position'); + var params = seriesModel.getDataParams(dataIndex); + var html; + if (!formatter) { + html = seriesModel.formatTooltip(dataIndex); + } + else { + if (typeof formatter === 'string') { + html = formatUtil.formatTpl(formatter, params); + } + else if (typeof formatter === 'function') { + var self = this; + var ticket = 'item_' + seriesModel.name + '_' + dataIndex; + var callback = function (cbTicket, html) { + if (cbTicket === self._ticket) { + tooltipContent.setContent(html); + + updatePosition( + positionExpr, e.offsetX, e.offsetY, + tooltipContent, params, e.target, api + ); + } + }; + self._ticket = ticket; + html = formatter(params, ticket, callback); + } + } + + tooltipContent.show(tooltipModel); + tooltipContent.setContent(html); + + updatePosition( + positionExpr, e.offsetX, e.offsetY, + tooltipContent, params, e.target, api + ); + } + }, + + /** + * Show axis pointer + * @param {string} [coordSysName] + */ + _showAxisPointer: function (coordSysName) { + if (coordSysName) { + var axisPointers = this._axisPointers[coordSysName]; + axisPointers && zrUtil.each(axisPointers, function (el) { + el.show(); + }); + } + else { + this.group.eachChild(function (child) { + child.show(); + }); + this.group.show(); + } + }, + + _resetLastHover: function () { + var lastHover = this._lastHover; + if (lastHover.payloadBatch) { + this._api.dispatchAction({ + type: 'downplay', + batch: lastHover.payloadBatch + }); + } + // Reset lastHover + this._lastHover = {}; + }, + /** + * Hide axis pointer + * @param {string} [coordSysName] + */ + _hideAxisPointer: function (coordSysName) { + if (coordSysName) { + var axisPointers = this._axisPointers[coordSysName]; + axisPointers && zrUtil.each(axisPointers, function (el) { + el.hide(); + }); + } + else { + this.group.hide(); + } + }, + + _hide: function () { + this._hideAxisPointer(); + this._resetLastHover(); + if (!this._alwaysShowContent) { + this._tooltipContent.hideLater(this._tooltipModel.get('hideDelay')); + } + + this._api.dispatchAction({ + type: 'hideTip', + from: this.uid + }); + }, + + dispose: function (ecModel, api) { + if (env.node) { + return; + } + var zr = api.getZr(); + this._tooltipContent.hide(); + + zr.off('click', this._tryShow); + zr.off('mousemove', this._tryShow); + zr.off('mouseout', this._hide); + + api.off('showTip', this._manuallyShowTip); + api.off('hideTip', this._manuallyHideTip); + } + }); + + +/***/ }, +/* 271 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/component/tooltip/TooltipContent + */ + + + var zrUtil = __webpack_require__(3); + var zrColor = __webpack_require__(38); + var eventUtil = __webpack_require__(80); + var formatUtil = __webpack_require__(6); + var each = zrUtil.each; + var toCamelCase = formatUtil.toCamelCase; + + var vendors = ['', '-webkit-', '-moz-', '-o-']; + + var gCssText = 'position:absolute;display:block;border-style:solid;white-space:nowrap;'; + + /** + * @param {number} duration + * @return {string} + * @inner + */ + function assembleTransition(duration) { + var transitionCurve = 'cubic-bezier(0.23, 1, 0.32, 1)'; + var transitionText = 'left ' + duration + 's ' + transitionCurve + ',' + + 'top ' + duration + 's ' + transitionCurve; + return zrUtil.map(vendors, function (vendorPrefix) { + return vendorPrefix + 'transition:' + transitionText; + }).join(';'); + } + + /** + * @param {Object} textStyle + * @return {string} + * @inner + */ + function assembleFont(textStyleModel) { + var cssText = []; + + var fontSize = textStyleModel.get('fontSize'); + var color = textStyleModel.getTextColor(); + + color && cssText.push('color:' + color); + + cssText.push('font:' + textStyleModel.getFont()); + + fontSize && + cssText.push('line-height:' + Math.round(fontSize * 3 / 2) + 'px'); + + each(['decoration', 'align'], function (name) { + var val = textStyleModel.get(name); + val && cssText.push('text-' + name + ':' + val); + }); + + return cssText.join(';'); + } + + /** + * @param {Object} tooltipModel + * @return {string} + * @inner + */ + function assembleCssText(tooltipModel) { + + tooltipModel = tooltipModel; + + var cssText = []; + + var transitionDuration = tooltipModel.get('transitionDuration'); + var backgroundColor = tooltipModel.get('backgroundColor'); + var textStyleModel = tooltipModel.getModel('textStyle'); + var padding = tooltipModel.get('padding'); + + // Animation transition + transitionDuration && + cssText.push(assembleTransition(transitionDuration)); + + if (backgroundColor) { + // for ie + cssText.push( + 'background-Color:' + zrColor.toHex(backgroundColor) + ); + cssText.push('filter:alpha(opacity=70)'); + cssText.push('background-Color:' + backgroundColor); + } + + // Border style + each(['width', 'color', 'radius'], function (name) { + var borderName = 'border-' + name; + var camelCase = toCamelCase(borderName); + var val = tooltipModel.get(camelCase); + val != null && + cssText.push(borderName + ':' + val + (name === 'color' ? '' : 'px')); + }); + + // Text style + cssText.push(assembleFont(textStyleModel)); + + // Padding + if (padding != null) { + cssText.push('padding:' + formatUtil.normalizeCssArray(padding).join('px ') + 'px'); + } + + return cssText.join(';') + ';'; + } + + /** + * @alias module:echarts/component/tooltip/TooltipContent + * @constructor + */ + function TooltipContent(container, api) { + var el = document.createElement('div'); + var zr = api.getZr(); + + this.el = el; + + this._x = api.getWidth() / 2; + this._y = api.getHeight() / 2; + + container.appendChild(el); + + this._container = container; + + this._show = false; + + /** + * @private + */ + this._hideTimeout; + + var self = this; + el.onmouseenter = function () { + // clear the timeout in hideLater and keep showing tooltip + if (self.enterable) { + clearTimeout(self._hideTimeout); + self._show = true; + } + self._inContent = true; + }; + el.onmousemove = function (e) { + if (!self.enterable) { + // Try trigger zrender event to avoid mouse + // in and out shape too frequently + var handler = zr.handler; + eventUtil.normalizeEvent(container, e); + handler.dispatch('mousemove', e); + } + }; + el.onmouseleave = function () { + if (self.enterable) { + if (self._show) { + self.hideLater(self._hideDelay); + } + } + self._inContent = false; + }; + + compromiseMobile(el, container); + } + + function compromiseMobile(tooltipContentEl, container) { + // Prevent default behavior on mobile. For example, + // defuault pinch gesture will cause browser zoom. + // We do not preventing event on tooltip contnet el, + // because user may need customization in tooltip el. + eventUtil.addEventListener(container, 'touchstart', preventDefault); + eventUtil.addEventListener(container, 'touchmove', preventDefault); + eventUtil.addEventListener(container, 'touchend', preventDefault); + + function preventDefault(e) { + if (contains(e.target)) { + e.preventDefault(); + } + } + + function contains(targetEl) { + while (targetEl && targetEl !== container) { + if (targetEl === tooltipContentEl) { + return true; + } + targetEl = targetEl.parentNode; + } + } + } + + TooltipContent.prototype = { + + constructor: TooltipContent, + + enterable: true, + + /** + * Update when tooltip is rendered + */ + update: function () { + var container = this._container; + var stl = container.currentStyle + || document.defaultView.getComputedStyle(container); + var domStyle = container.style; + if (domStyle.position !== 'absolute' && stl.position !== 'absolute') { + domStyle.position = 'relative'; + } + // Hide the tooltip + // PENDING + // this.hide(); + }, + + show: function (tooltipModel) { + clearTimeout(this._hideTimeout); + + this.el.style.cssText = gCssText + assembleCssText(tooltipModel) + // http://stackoverflow.com/questions/21125587/css3-transition-not-working-in-chrome-anymore + + ';left:' + this._x + 'px;top:' + this._y + 'px;'; + + this._show = true; + }, + + setContent: function (content) { + var el = this.el; + el.innerHTML = content; + el.style.display = content ? 'block' : 'none'; + }, + + moveTo: function (x, y) { + var style = this.el.style; + style.left = x + 'px'; + style.top = y + 'px'; + + this._x = x; + this._y = y; + }, + + hide: function () { + this.el.style.display = 'none'; + this._show = false; + }, + + // showLater: function () + + hideLater: function (time) { + if (this._show && !(this._inContent && this.enterable)) { + if (time) { + this._hideDelay = time; + // Set show false to avoid invoke hideLater mutiple times + this._show = false; + this._hideTimeout = setTimeout(zrUtil.bind(this.hide, this), time); + } + else { + this.hide(); + } + } + }, + + isShow: function () { + return this._show; + } + }; + + module.exports = TooltipContent; + + +/***/ }, +/* 272 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + __webpack_require__(273); + __webpack_require__(279); + __webpack_require__(281); + + // Polar view + __webpack_require__(1).extendComponentView({ + type: 'polar' + }); + + +/***/ }, +/* 273 */ +/***/ function(module, exports, __webpack_require__) { + + // TODO Axis scale + + + var Polar = __webpack_require__(274); + var numberUtil = __webpack_require__(7); + + var axisHelper = __webpack_require__(108); + var niceScaleExtent = axisHelper.niceScaleExtent; + + // 依赖 PolarModel 做预处理 + __webpack_require__(277); + + /** + * Resize method bound to the polar + * @param {module:echarts/coord/polar/PolarModel} polarModel + * @param {module:echarts/ExtensionAPI} api + */ + function resizePolar(polarModel, api) { + var center = polarModel.get('center'); + var radius = polarModel.get('radius'); + var width = api.getWidth(); + var height = api.getHeight(); + var parsePercent = numberUtil.parsePercent; + + this.cx = parsePercent(center[0], width); + this.cy = parsePercent(center[1], height); + + var radiusAxis = this.getRadiusAxis(); + var size = Math.min(width, height) / 2; + // var idx = radiusAxis.inverse ? 1 : 0; + radiusAxis.setExtent(0, parsePercent(radius, size)); + } + + /** + * Update polar + */ + function updatePolarScale(ecModel, api) { + var polar = this; + var angleAxis = polar.getAngleAxis(); + var radiusAxis = polar.getRadiusAxis(); + // Reset scale + angleAxis.scale.setExtent(Infinity, -Infinity); + radiusAxis.scale.setExtent(Infinity, -Infinity); + + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.coordinateSystem === polar) { + var data = seriesModel.getData(); + radiusAxis.scale.unionExtent( + data.getDataExtent('radius', radiusAxis.type !== 'category') + ); + angleAxis.scale.unionExtent( + data.getDataExtent('angle', angleAxis.type !== 'category') + ); + } + }); + + niceScaleExtent(angleAxis, angleAxis.model); + niceScaleExtent(radiusAxis, radiusAxis.model); + + // Fix extent of category angle axis + if (angleAxis.type === 'category' && !angleAxis.onBand) { + var extent = angleAxis.getExtent(); + var diff = 360 / angleAxis.scale.count(); + angleAxis.inverse ? (extent[1] += diff) : (extent[1] -= diff); + angleAxis.setExtent(extent[0], extent[1]); + } + } + + /** + * Set common axis properties + * @param {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis} + * @param {module:echarts/coord/polar/AxisModel} + * @inner + */ + function setAxis(axis, axisModel) { + axis.type = axisModel.get('type'); + axis.scale = axisHelper.createScaleByModel(axisModel); + axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category'; + + // FIXME Radius axis not support inverse axis + if (axisModel.mainType === 'angleAxis') { + var startAngle = axisModel.get('startAngle'); + axis.inverse = axisModel.get('inverse') ^ axisModel.get('clockwise'); + axis.setExtent(startAngle, startAngle + (axis.inverse ? -360 : 360)); + } + + // Inject axis instance + axisModel.axis = axis; + axis.model = axisModel; + } + + + var polarCreator = { + + dimensions: Polar.prototype.dimensions, + + create: function (ecModel, api) { + var polarList = []; + ecModel.eachComponent('polar', function (polarModel, idx) { + var polar = new Polar(idx); + // Inject resize and update method + polar.resize = resizePolar; + polar.update = updatePolarScale; + + var radiusAxis = polar.getRadiusAxis(); + var angleAxis = polar.getAngleAxis(); + + var radiusAxisModel = polarModel.findAxisModel('radiusAxis'); + var angleAxisModel = polarModel.findAxisModel('angleAxis'); + + setAxis(radiusAxis, radiusAxisModel); + setAxis(angleAxis, angleAxisModel); + + polar.resize(polarModel, api); + polarList.push(polar); + + polarModel.coordinateSystem = polar; + }); + // Inject coordinateSystem to series + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.get('coordinateSystem') === 'polar') { + seriesModel.coordinateSystem = polarList[seriesModel.get('polarIndex')]; + } + }); + + return polarList; + } + }; + + __webpack_require__(25).register('polar', polarCreator); + + +/***/ }, +/* 274 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * @module echarts/coord/polar/Polar + */ + + + var RadiusAxis = __webpack_require__(275); + var AngleAxis = __webpack_require__(276); + + /** + * @alias {module:echarts/coord/polar/Polar} + * @constructor + * @param {string} name + */ + var Polar = function (name) { + + /** + * @type {string} + */ + this.name = name || ''; + + /** + * x of polar center + * @type {number} + */ + this.cx = 0; + + /** + * y of polar center + * @type {number} + */ + this.cy = 0; + + /** + * @type {module:echarts/coord/polar/RadiusAxis} + * @private + */ + this._radiusAxis = new RadiusAxis(); + + /** + * @type {module:echarts/coord/polar/AngleAxis} + * @private + */ + this._angleAxis = new AngleAxis(); + }; + + Polar.prototype = { + + constructor: Polar, + + type: 'polar', + + /** + * @param {Array.} + * @readOnly + */ + dimensions: ['radius', 'angle'], + + /** + * If contain coord + * @param {Array.} point + * @return {boolean} + */ + containPoint: function (point) { + var coord = this.pointToCoord(point); + return this._radiusAxis.contain(coord[0]) + && this._angleAxis.contain(coord[1]); + }, + + /** + * If contain data + * @param {Array.} data + * @return {boolean} + */ + containData: function (data) { + return this._radiusAxis.containData(data[0]) + && this._angleAxis.containData(data[1]); + }, + + /** + * @param {string} axisType + * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis} + */ + getAxis: function (axisType) { + return this['_' + axisType + 'Axis']; + }, + + /** + * Get axes by type of scale + * @param {string} scaleType + * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis} + */ + getAxesByScale: function (scaleType) { + var axes = []; + var angleAxis = this._angleAxis; + var radiusAxis = this._radiusAxis; + angleAxis.scale.type === scaleType && axes.push(angleAxis); + radiusAxis.scale.type === scaleType && axes.push(radiusAxis); + + return axes; + }, + + /** + * @return {module:echarts/coord/polar/AngleAxis} + */ + getAngleAxis: function () { + return this._angleAxis; + }, + + /** + * @return {module:echarts/coord/polar/RadiusAxis} + */ + getRadiusAxis: function () { + return this._radiusAxis; + }, + + /** + * @param {module:echarts/coord/polar/Axis} + * @return {module:echarts/coord/polar/Axis} + */ + getOtherAxis: function (axis) { + var angleAxis = this._angleAxis; + return axis === angleAxis ? this._radiusAxis : angleAxis; + }, + + /** + * Base axis will be used on stacking. + * + * @return {module:echarts/coord/polar/Axis} + */ + getBaseAxis: function () { + return this.getAxesByScale('ordinal')[0] + || this.getAxesByScale('time')[0] + || this.getAngleAxis(); + }, + + /** + * Convert series data to a list of (x, y) points + * @param {module:echarts/data/List} data + * @return {Array} + * Return list of coordinates. For example: + * `[[10, 10], [20, 20], [30, 30]]` + */ + dataToPoints: function (data) { + return data.mapArray(this.dimensions, function (radius, angle) { + return this.dataToPoint([radius, angle]); + }, this); + }, + + /** + * Convert a single data item to (x, y) point. + * Parameter data is an array which the first element is radius and the second is angle + * @param {Array.} data + * @param {boolean} [clamp=false] + * @return {Array.} + */ + dataToPoint: function (data, clamp) { + return this.coordToPoint([ + this._radiusAxis.dataToRadius(data[0], clamp), + this._angleAxis.dataToAngle(data[1], clamp) + ]); + }, + + /** + * Convert a (x, y) point to data + * @param {Array.} point + * @param {boolean} [clamp=false] + * @return {Array.} + */ + pointToData: function (point, clamp) { + var coord = this.pointToCoord(point); + return [ + this._radiusAxis.radiusToData(coord[0], clamp), + this._angleAxis.angleToData(coord[1], clamp) + ]; + }, + + /** + * Convert a (x, y) point to (radius, angle) coord + * @param {Array.} point + * @return {Array.} + */ + pointToCoord: function (point) { + var dx = point[0] - this.cx; + var dy = point[1] - this.cy; + var angleAxis = this.getAngleAxis(); + var extent = angleAxis.getExtent(); + var minAngle = Math.min(extent[0], extent[1]); + var maxAngle = Math.max(extent[0], extent[1]); + // Fix fixed extent in polarCreator + // FIXME + angleAxis.inverse + ? (minAngle = maxAngle - 360) + : (maxAngle = minAngle + 360); + + var radius = Math.sqrt(dx * dx + dy * dy); + dx /= radius; + dy /= radius; + + var radian = Math.atan2(-dy, dx) / Math.PI * 180; + + // move to angleExtent + var dir = radian < minAngle ? 1 : -1; + while (radian < minAngle || radian > maxAngle) { + radian += dir * 360; + } + + return [radius, radian]; + }, + + /** + * Convert a (radius, angle) coord to (x, y) point + * @param {Array.} coord + * @return {Array.} + */ + coordToPoint: function (coord) { + var radius = coord[0]; + var radian = coord[1] / 180 * Math.PI; + var x = Math.cos(radian) * radius + this.cx; + // Inverse the y + var y = -Math.sin(radian) * radius + this.cy; + + return [x, y]; + } + }; + + module.exports = Polar; - require('../../CoordinateSystem').register('parallel', {create: create}); -}); -define('echarts/coord/parallel/AxisModel',['require','../../model/Component','zrender/core/util','../../model/mixin/makeStyleMapper','../axisModelCreator','../../util/number','../axisModelCommonMixin'],function(require) { - - var ComponentModel = require('../../model/Component'); - var zrUtil = require('zrender/core/util'); - var makeStyleMapper = require('../../model/mixin/makeStyleMapper'); - var axisModelCreator = require('../axisModelCreator'); - var numberUtil = require('../../util/number'); - - var AxisModel = ComponentModel.extend({ - - type: 'baseParallelAxis', - - /** - * @type {module:echarts/coord/parallel/Axis} - */ - axis: null, - - /** - * @type {Array.} - * @readOnly - */ - activeIntervals: [], - - /** - * @return {Object} - */ - getAreaSelectStyle: function () { - return makeStyleMapper( - [ - ['fill', 'color'], - ['lineWidth', 'borderWidth'], - ['stroke', 'borderColor'], - ['width', 'width'], - ['opacity', 'opacity'] - ] - ).call(this.getModel('areaSelectStyle')); - }, - - /** - * The code of this feature is put on AxisModel but not ParallelAxis, - * because axisModel can be alive after echarts updating but instance of - * ParallelAxis having been disposed. this._activeInterval should be kept - * when action dispatched (i.e. legend click). - * - * @param {Array.>} intervals interval.length === 0 - * means set all active. - * @public - */ - setActiveIntervals: function (intervals) { - var activeIntervals = this.activeIntervals = zrUtil.clone(intervals); - - // Normalize - if (activeIntervals) { - for (var i = activeIntervals.length - 1; i >= 0; i--) { - numberUtil.asc(activeIntervals[i]); - } - } - }, - - /** - * @param {number|string} [value] When attempting to detect 'no activeIntervals set', - * value can not be input. - * @return {string} 'normal': no activeIntervals set, - * 'active', - * 'inactive'. - * @public - */ - getActiveState: function (value) { - var activeIntervals = this.activeIntervals; - - if (!activeIntervals.length) { - return 'normal'; - } - - if (value == null) { - return 'inactive'; - } - - for (var i = 0, len = activeIntervals.length; i < len; i++) { - if (activeIntervals[i][0] <= value && value <= activeIntervals[i][1]) { - return 'active'; - } - } - return 'inactive'; - } - - }); - - var defaultOption = { - - type: 'value', - - /** - * @type {Array.} - */ - dim: null, // 0, 1, 2, ... - - parallelIndex: null, - - areaSelectStyle: { - width: 20, - borderWidth: 1, - borderColor: 'rgba(160,197,232)', - color: 'rgba(160,197,232)', - opacity: 0.3 - }, - - z: 10 - }; - - zrUtil.merge(AxisModel.prototype, require('../axisModelCommonMixin')); - - function getAxisType(axisName, option) { - return option.type || (option.data ? 'category' : 'value'); - } - - axisModelCreator('parallel', AxisModel, getAxisType, defaultOption); - - return AxisModel; -}); -define('echarts/coord/parallel/ParallelModel',['require','zrender/core/util','../../model/Component','./AxisModel'],function(require) { - - var zrUtil = require('zrender/core/util'); - var Component = require('../../model/Component'); - - require('./AxisModel'); - - Component.extend({ - - type: 'parallel', - - dependencies: ['parallelAxis'], - - /** - * @type {module:echarts/coord/parallel/Parallel} - */ - coordinateSystem: null, - - /** - * Each item like: 'dim0', 'dim1', 'dim2', ... - * @type {Array.} - * @readOnly - */ - dimensions: null, - - /** - * Coresponding to dimensions. - * @type {Array.} - * @readOnly - */ - parallelAxisIndex: null, - - defaultOption: { - zlevel: 0, // 一级层叠 - z: 0, // 二级层叠 - left: 80, - top: 60, - right: 80, - bottom: 60, - // width: {totalWidth} - left - right, - // height: {totalHeight} - top - bottom, - - layout: 'horizontal', // 'horizontal' or 'vertical' - - parallelAxisDefault: null - }, - - /** - * @override - */ - init: function () { - Component.prototype.init.apply(this, arguments); - - this.mergeOption({}); - }, - - /** - * @override - */ - mergeOption: function (newOption) { - var thisOption = this.option; - - newOption && zrUtil.merge(thisOption, newOption, true); - - this._initDimensions(); - }, - - /** - * Whether series or axis is in this coordinate system. - * @param {module:echarts/model/Series|module:echarts/coord/parallel/AxisModel} model - * @param {module:echarts/model/Global} ecModel - */ - contains: function (model, ecModel) { - var parallelIndex = model.get('parallelIndex'); - return parallelIndex != null - && ecModel.getComponent('parallel', parallelIndex) === this; - }, - - /** - * @private - */ - _initDimensions: function () { - var dimensions = this.dimensions = []; - var parallelAxisIndex = this.parallelAxisIndex = []; - - var axisModels = zrUtil.filter(this.dependentModels.parallelAxis, function (axisModel) { - // Can not use this.contains here, because - // initialization has not been completed yet. - return axisModel.get('parallelIndex') === this.componentIndex; - }); - - zrUtil.each(axisModels, function (axisModel) { - dimensions.push('dim' + axisModel.get('dim')); - parallelAxisIndex.push(axisModel.componentIndex); - }); - } - - }); +/***/ }, +/* 275 */ +/***/ function(module, exports, __webpack_require__) { -}); -define('echarts/component/axis/parallelAxisAction',['require','../../echarts'],function (require) { - - var echarts = require('../../echarts'); - - var actionInfo = { - type: 'axisAreaSelect', - event: 'axisAreaSelected', - update: 'updateVisual' - }; - - /** - * @payload - * @property {string} parallelAxisId - * @property {Array.>} intervals - */ - echarts.registerAction(actionInfo, function (payload, ecModel) { - ecModel.eachComponent( - {mainType: 'parallelAxis', query: payload}, - function (parallelAxisModel) { - parallelAxisModel.axis.model.setActiveIntervals(payload.intervals); - } - ); - - }); -}); -/** - * Box selection tool. - * - * @module echarts/component/helper/SelectController - */ - -define('echarts/component/helper/SelectController',['require','zrender/mixin/Eventful','zrender/core/util','../../util/graphic'],function (require) { - - var Eventful = require('zrender/mixin/Eventful'); - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var bind = zrUtil.bind; - var each = zrUtil.each; - var mathMin = Math.min; - var mathMax = Math.max; - var mathPow = Math.pow; - - var COVER_Z = 10000; - var UNSELECT_THRESHOLD = 2; - var EVENTS = ['mousedown', 'mousemove', 'mouseup']; - - /** - * @alias module:echarts/component/helper/SelectController - * @constructor - * @mixin {module:zrender/mixin/Eventful} - * - * @param {string} type 'line', 'rect' - * @param {module:zrender/zrender~ZRender} zr - * @param {Object} [opt] - * @param {number} [opt.width] - * @param {number} [opt.lineWidth] - * @param {string} [opt.stroke] - * @param {string} [opt.fill] - */ - function SelectController(type, zr, opt) { - - Eventful.call(this); - - /** - * @type {string} - * @readOnly - */ - this.type = type; - - /** - * @type {module:zrender/zrender~ZRender} - */ - this.zr = zr; - - /** - * @type {Object} - * @readOnly - */ - this.opt = zrUtil.clone(opt); - - /** - * @type {module:zrender/container/Group} - * @readOnly - */ - this.group = new graphic.Group(); - - /** - * @type {module:zrender/core/BoundingRect} - */ - this._containerRect = null; - - /** - * @type {Array.} - * @private - */ - this._track = []; - - /** - * @type {boolean} - */ - this._dragging; - - /** - * @type {module:zrender/Element} - * @private - */ - this._cover; - - /** - * @type {boolean} - * @private - */ - this._disabled = true; - - /** - * @type {Object} - * @private - */ - this._handlers = { - mousedown: bind(mousedown, this), - mousemove: bind(mousemove, this), - mouseup: bind(mouseup, this) - }; - - each(EVENTS, function (eventName) { - this.zr.on(eventName, this._handlers[eventName]); - }, this); - } - - SelectController.prototype = { - - constructor: SelectController, - - /** - * @param {module:zrender/mixin/Transformable} container - * @param {module:zrender/core/BoundingRect|boolean} [rect] If not specified, - * use container.getBoundingRect(). - * If false, do not use containerRect. - */ - enable: function (container, rect) { - - this._disabled = false; - - // Remove from old container. - removeGroup.call(this); - - // boundingRect will change when dragging, so we have - // to keep initial boundingRect. - this._containerRect = rect !== false - ? (rect || container.getBoundingRect()) : null; - - // Add to new container. - container.add(this.group); - }, - - /** - * Update cover location. - * @param {Array.|Object} ranges If null/undefined, remove cover. - */ - update: function (ranges) { - // TODO - // Only support one interval yet. - renderCover.call(this, ranges && zrUtil.clone(ranges)); - }, - - disable: function () { - this._disabled = true; - - removeGroup.call(this); - }, - - dispose: function () { - this.disable(); - - each(EVENTS, function (eventName) { - this.zr.off(eventName, this._handlers[eventName]); - }, this); - } - }; - - - zrUtil.mixin(SelectController, Eventful); - - function updateZ(group) { - group.traverse(function (el) { - el.z = COVER_Z; - }); - } - - function isInContainer(x, y) { - var localPos = this.group.transformCoordToLocal(x, y); - return !this._containerRect - || this._containerRect.contain(localPos[0], localPos[1]); - } - - function preventDefault(e) { - var rawE = e.event; - rawE.preventDefault && rawE.preventDefault(); - } - - function mousedown(e) { - if (this._disabled || (e.target && e.target.draggable)) { - return; - } - - preventDefault(e); - - var x = e.offsetX; - var y = e.offsetY; - - if (isInContainer.call(this, x, y)) { - this._dragging = true; - this._track = [[x, y]]; - } - } - - function mousemove(e) { - if (!this._dragging || this._disabled) { - return; - } - - preventDefault(e); - - updateViewByCursor.call(this, e); - } - - function mouseup(e) { - if (!this._dragging || this._disabled) { - return; - } - - preventDefault(e); - - updateViewByCursor.call(this, e, true); - - this._dragging = false; - this._track = []; - } - - function updateViewByCursor(e, isEnd) { - var x = e.offsetX; - var y = e.offsetY; - - if (isInContainer.call(this, x, y)) { - this._track.push([x, y]); - - // Create or update cover. - var ranges = shouldShowCover.call(this) - ? coverRenderers[this.type].getRanges.call(this) - // Remove cover. - : []; - - renderCover.call(this, ranges); - - this.trigger('selected', zrUtil.clone(ranges)); - - if (isEnd) { - this.trigger('selectEnd', zrUtil.clone(ranges)); - } - } - } - - function shouldShowCover() { - var track = this._track; - - if (!track.length) { - return false; - } - - var p2 = track[track.length - 1]; - var p1 = track[0]; - var dx = p2[0] - p1[0]; - var dy = p2[1] - p1[1]; - var dist = mathPow(dx * dx + dy * dy, 0.5); - - return dist > UNSELECT_THRESHOLD; - } - - function renderCover(ranges) { - var coverRenderer = coverRenderers[this.type]; - - if (ranges && ranges.length) { - if (!this._cover) { - this._cover = coverRenderer.create.call(this); - this.group.add(this._cover); - } - coverRenderer.update.call(this, ranges); - } - else { - this.group.remove(this._cover); - this._cover = null; - } - - updateZ(this.group); - } - - function removeGroup() { - // container may 'removeAll' outside. - var group = this.group; - var container = group.parent; - if (container) { - container.remove(group); - } - } - - function createRectCover() { - var opt = this.opt; - return new graphic.Rect({ - // FIXME - // customize style. - style: { - stroke: opt.stroke, - fill: opt.fill, - lineWidth: opt.lineWidth, - opacity: opt.opacity - } - }); - } - - function getLocalTrack() { - return zrUtil.map(this._track, function (point) { - return this.group.transformCoordToLocal(point[0], point[1]); - }, this); - } - - function getLocalTrackEnds() { - var localTrack = getLocalTrack.call(this); - var tail = localTrack.length - 1; - tail < 0 && (tail = 0); - return [localTrack[0], localTrack[tail]]; - } - - /** - * key: this.type - * @type {Object} - */ - var coverRenderers = { - - line: { - - create: createRectCover, - - getRanges: function () { - var ends = getLocalTrackEnds.call(this); - var min = mathMin(ends[0][0], ends[1][0]); - var max = mathMax(ends[0][0], ends[1][0]); - - return [[min, max]]; - }, - - update: function (ranges) { - var range = ranges[0]; - var width = this.opt.width; - this._cover.setShape({ - x: range[0], - y: -width / 2, - width: range[1] - range[0], - height: width - }); - } - }, - - rect: { - - create: createRectCover, - - getRanges: function () { - var ends = getLocalTrackEnds.call(this); - - var min = [ - mathMin(ends[1][0], ends[0][0]), - mathMin(ends[1][1], ends[0][1]) - ]; - var max = [ - mathMax(ends[1][0], ends[0][0]), - mathMax(ends[1][1], ends[0][1]) - ]; - - return [[ - [min[0], max[0]], // x range - [min[1], max[1]] // y range - ]]; - }, - - update: function (ranges) { - var range = ranges[0]; - this._cover.setShape({ - x: range[0][0], - y: range[1][0], - width: range[0][1] - range[0][0], - height: range[1][1] - range[1][0] - }); - } - } - }; - - return SelectController; -}); -define('echarts/component/axis/ParallelAxisView',['require','zrender/core/util','./AxisBuilder','../helper/SelectController','../../echarts'],function (require) { + 'use strict'; - var zrUtil = require('zrender/core/util'); - var AxisBuilder = require('./AxisBuilder'); - var SelectController = require('../helper/SelectController'); - - var elementList = ['axisLine', 'axisLabel', 'axisTick', 'axisName']; - - var AxisView = require('../../echarts').extendComponentView({ - - type: 'parallelAxis', - - /** - * @type {module:echarts/component/helper/SelectController} - */ - _selectController: null, - - /** - * @override - */ - render: function (axisModel, ecModel, api, payload) { - if (fromAxisAreaSelect(axisModel, ecModel, payload)) { - return; - } - - this.axisModel = axisModel; - this.api = api; - - this.group.removeAll(); - - if (!axisModel.get('show')) { - return; - } - - var coordSys = ecModel.getComponent( - 'parallel', axisModel.get('parallelIndex') - ).coordinateSystem; - - var areaSelectStyle = axisModel.getAreaSelectStyle(); - var areaWidth = areaSelectStyle.width; - - var axisLayout = coordSys.getAxisLayout(axisModel.axis.dim); - var builderOpt = zrUtil.extend( - { - strokeContainThreshold: areaWidth, - // lineWidth === 0 or no value. - silent: !(areaWidth > 0) // jshint ignore:line - }, - axisLayout - ); - - var axisBuilder = new AxisBuilder(axisModel, builderOpt); - - zrUtil.each(elementList, axisBuilder.add, axisBuilder); - - var axisGroup = axisBuilder.getGroup(); - - this.group.add(axisGroup); - - this._buildSelectController( - axisGroup, areaSelectStyle, axisModel, api - ); - }, - - _buildSelectController: function (axisGroup, areaSelectStyle, axisModel, api) { - - var axis = axisModel.axis; - var selectController = this._selectController; - - if (!selectController) { - selectController = this._selectController = new SelectController( - 'line', - api.getZr(), - areaSelectStyle - ); - - selectController.on('selected', zrUtil.bind(this._onSelected, this)); - } - - selectController.enable(axisGroup); - - // After filtering, axis may change, select area needs to be update. - var ranges = zrUtil.map(axisModel.activeIntervals, function (interval) { - return [ - axis.dataToCoord(interval[0], true), - axis.dataToCoord(interval[1], true) - ]; - }); - selectController.update(ranges); - }, - - _onSelected: function (ranges) { - // Do not cache these object, because the mey be changed. - var axisModel = this.axisModel; - var axis = axisModel.axis; - - var intervals = zrUtil.map(ranges, function (range) { - return [ - axis.coordToData(range[0], true), - axis.coordToData(range[1], true) - ]; - }); - this.api.dispatchAction({ - type: 'axisAreaSelect', - parallelAxisId: axisModel.id, - intervals: intervals - }); - }, - - /** - * @override - */ - remove: function () { - this._selectController && this._selectController.disable(); - }, - - /** - * @override - */ - dispose: function () { - if (this._selectController) { - this._selectController.dispose(); - this._selectController = null; - } - } - }); - - function fromAxisAreaSelect(axisModel, ecModel, payload) { - return payload - && payload.type === 'axisAreaSelect' - && ecModel.findComponents( - {mainType: 'parallelAxis', query: payload} - )[0] === axisModel; - } - - return AxisView; -}); -define('echarts/component/parallelAxis',['require','../coord/parallel/parallelCreator','./axis/parallelAxisAction','./axis/ParallelAxisView'],function(require) { - require('../coord/parallel/parallelCreator'); - require('./axis/parallelAxisAction'); - require('./axis/ParallelAxisView'); + var zrUtil = __webpack_require__(3); + var Axis = __webpack_require__(117); + + function RadiusAxis(scale, radiusExtent) { + + Axis.call(this, 'radius', scale, radiusExtent); + + /** + * Axis type + * - 'category' + * - 'value' + * - 'time' + * - 'log' + * @type {string} + */ + this.type = 'category'; + } -}); -define('echarts/coord/parallel/parallelPreprocessor',['require','zrender/core/util','../../util/model'],function (require) { - - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../../util/model'); - - return function (option) { - createParallelIfNeeded(option); - mergeAxisOptionFromParallel(option); - }; - - /** - * Create a parallel coordinate if not exists. - * @inner - */ - function createParallelIfNeeded(option) { - if (option.parallel) { - return; - } - - var hasParallelSeries = false; - - zrUtil.each(option.series, function (seriesOpt) { - if (seriesOpt && seriesOpt.type === 'parallel') { - hasParallelSeries = true; - } - }); - - if (hasParallelSeries) { - option.parallel = [{}]; - } - } - - /** - * Merge aixs definition from parallel option (if exists) to axis option. - * @inner - */ - function mergeAxisOptionFromParallel(option) { - var axes = modelUtil.normalizeToArray(option.parallelAxis); - - zrUtil.each(axes, function (axisOption) { - if (!zrUtil.isObject(axisOption)) { - return; - } - - var parallelIndex = axisOption.parallelIndex || 0; - var parallelOption = modelUtil.normalizeToArray(option.parallel)[parallelIndex]; - - if (parallelOption && parallelOption.parallelAxisDefault) { - zrUtil.merge(axisOption, parallelOption.parallelAxisDefault, false); - } - }); - } + RadiusAxis.prototype = { -}); -define('echarts/component/parallel',['require','../coord/parallel/parallelCreator','../coord/parallel/ParallelModel','./parallelAxis','../echarts','../coord/parallel/parallelPreprocessor'],function(require) { + constructor: RadiusAxis, - require('../coord/parallel/parallelCreator'); - require('../coord/parallel/ParallelModel'); - require('./parallelAxis'); + dataToRadius: Axis.prototype.dataToCoord, - var echarts = require('../echarts'); + radiusToData: Axis.prototype.coordToData + }; - // Parallel view - echarts.extendComponentView({ - type: 'parallel' - }); + zrUtil.inherits(RadiusAxis, Axis); - echarts.registerPreprocessor( - require('../coord/parallel/parallelPreprocessor') - ); + module.exports = RadiusAxis; -}); -define('echarts/chart/parallel/ParallelSeries',['require','../../data/List','zrender/core/util','../../model/Series'],function(require) { - - var List = require('../../data/List'); - var zrUtil = require('zrender/core/util'); - var SeriesModel = require('../../model/Series'); - - return SeriesModel.extend({ - - type: 'series.parallel', - - dependencies: ['parallel'], - - getInitialData: function (option, ecModel) { - var parallelModel = ecModel.getComponent( - 'parallel', this.get('parallelIndex') - ); - var dimensions = parallelModel.dimensions; - var parallelAxisIndices = parallelModel.parallelAxisIndex; - - var rawData = option.data; - - var dimensionsInfo = zrUtil.map(dimensions, function (dim, index) { - var axisModel = ecModel.getComponent( - 'parallelAxis', parallelAxisIndices[index] - ); - if (axisModel.get('type') === 'category') { - translateCategoryValue(axisModel, dim, rawData); - return {name: dim, type: 'ordinal'}; - } - else { - return dim; - } - }); - - var list = new List(dimensionsInfo, this); - list.initData(rawData); - - return list; - }, - - defaultOption: { - zlevel: 0, // 一级层叠 - z: 2, // 二级层叠 - - coordinateSystem: 'parallel', - parallelIndex: 0, - - // FIXME 尚无用 - label: { - normal: { - show: false - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 - // 'inside'|'left'|'right'|'top'|'bottom' - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - }, - emphasis: { - show: false - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 - // 'inside'|'left'|'right'|'top'|'bottom' - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - } - }, - - inactiveOpacity: 0.05, - activeOpacity: 1, - - lineStyle: { - normal: { - width: 2, - opacity: 0.45, - type: 'solid' - } - }, - // smooth: false - - animationEasing: 'linear' - } - }); - - function translateCategoryValue(axisModel, dim, rawData) { - var axisData = axisModel.get('data'); - var numberDim = +dim.replace('dim', ''); - - if (axisData && axisData.length) { - zrUtil.each(rawData, function (dataItem) { - if (!dataItem) { - return; - } - var index = zrUtil.indexOf(axisData, dataItem[numberDim]); - dataItem[numberDim] = index >= 0 ? index : NaN; - }); - } - // FIXME - // 如果没有设置axis data, 应自动算出,或者提示。 - } -}); -define('echarts/chart/parallel/ParallelView',['require','../../util/graphic','zrender/core/util','../../view/Chart'],function (require) { - - var graphic = require('../../util/graphic'); - var zrUtil = require('zrender/core/util'); - - var ParallelView = require('../../view/Chart').extend({ - - type: 'parallel', - - init: function () { - - /** - * @type {module:zrender/container/Group} - * @private - */ - this._dataGroup = new graphic.Group(); - - this.group.add(this._dataGroup); - /** - * @type {module:echarts/data/List} - */ - this._data; - }, - - /** - * @override - */ - render: function (seriesModel, ecModel, api, payload) { - - var dataGroup = this._dataGroup; - var data = seriesModel.getData(); - var oldData = this._data; - var coordSys = seriesModel.coordinateSystem; - var dimensions = coordSys.dimensions; - - data.diff(oldData) - .add(add) - .update(update) - .remove(remove) - .execute(); - - // Update style - data.eachItemGraphicEl(function (elGroup, idx) { - var itemModel = data.getItemModel(idx); - var lineStyleModel = itemModel.getModel('lineStyle.normal'); - elGroup.eachChild(function (child) { - child.setStyle(zrUtil.extend( - lineStyleModel.getLineStyle(), - { - stroke: data.getItemVisual(idx, 'color'), - opacity: data.getItemVisual(idx, 'opacity') - } - )); - }); - }); - - // First create - if (!this._data) { - dataGroup.setClipPath(createGridClipShape( - coordSys, seriesModel, function () { - dataGroup.removeClipPath(); - } - )); - } - - this._data = data; - - function add(newDataIndex) { - var values = data.getValues(dimensions, newDataIndex); - var elGroup = new graphic.Group(); - dataGroup.add(elGroup); - - eachAxisPair( - values, dimensions, coordSys, - function (pointPair, pairIndex) { - // FIXME - // init animation - if (pointPair) { - elGroup.add(createEl(pointPair)); - } - } - ); - - data.setItemGraphicEl(newDataIndex, elGroup); - } - - function update(newDataIndex, oldDataIndex) { - var values = data.getValues(dimensions, newDataIndex); - var elGroup = oldData.getItemGraphicEl(oldDataIndex); - var newEls = []; - var elGroupIndex = 0; - - eachAxisPair( - values, dimensions, coordSys, - function (pointPair, pairIndex) { - var el = elGroup.childAt(elGroupIndex++); - - if (pointPair && !el) { - newEls.push(createEl(pointPair)); - } - else if (pointPair) { - graphic.updateProps(el, { - shape: { - points: pointPair - } - }, seriesModel); - } - } - ); - - // Remove redundent els - for (var i = elGroup.childCount() - 1; i >= elGroupIndex; i--) { - elGroup.remove(elGroup.childAt(i)); - } - - // Add new els - for (var i = 0, len = newEls.length; i < len; i++) { - elGroup.add(newEls[i]); - } - - data.setItemGraphicEl(newDataIndex, elGroup); - } - - function remove(oldDataIndex) { - var elGroup = oldData.getItemGraphicEl(oldDataIndex); - dataGroup.remove(elGroup); - } - }, - - /** - * @override - */ - remove: function () { - this._dataGroup && this._dataGroup.removeAll(); - this._data = null; - } - }); - - function createGridClipShape(coordSys, seriesModel, cb) { - var parallelModel = coordSys.model; - var rect = coordSys.getRect(); - var rectEl = new graphic.Rect({ - shape: { - x: rect.x, - y: rect.y, - width: rect.width, - height: rect.height - } - }); - var dim = parallelModel.get('layout') === 'horizontal' ? 'width' : 'height'; - rectEl.setShape(dim, 0); - graphic.initProps(rectEl, { - shape: { - width: rect.width, - height: rect.height - } - }, seriesModel, cb); - return rectEl; - } - - function eachAxisPair(values, dimensions, coordSys, cb) { - for (var i = 0, len = dimensions.length - 1; i < len; i++) { - var dimA = dimensions[i]; - var dimB = dimensions[i + 1]; - var valueA = values[i]; - var valueB = values[i + 1]; - - cb( - (isEmptyValue(valueA, coordSys.getAxis(dimA).type) - || isEmptyValue(valueB, coordSys.getAxis(dimB).type) - ) - ? null - : [ - coordSys.dataToPoint(valueA, dimA), - coordSys.dataToPoint(valueB, dimB) - ], - i - ); - } - } - - function createEl(pointPair) { - return new graphic.Polyline({ - shape: {points: pointPair}, - silent: true - }); - } - - - // FIXME - // 公用方法? - function isEmptyValue(val, axisType) { - return axisType === 'category' - ? val == null - : (val == null || isNaN(val)); // axisType === 'value' - } - - return ParallelView; -}); -define('echarts/chart/parallel/parallelVisual',['require'],function (require) { - - /** - * @payload - * @property {string} parallelAxisId - * @property {Array.} extent - */ - return function (ecModel, payload) { - - ecModel.eachSeriesByType('parallel', function (seriesModel) { - - var itemStyleModel = seriesModel.getModel('itemStyle.normal'); - var globalColors = ecModel.get('color'); - - var color = itemStyleModel.get('color') - || globalColors[seriesModel.seriesIndex % globalColors.length]; - var inactiveOpacity = seriesModel.get('inactiveOpacity'); - var activeOpacity = seriesModel.get('activeOpacity'); - var lineStyle = seriesModel.getModel('lineStyle.normal').getLineStyle(); - - var coordSys = seriesModel.coordinateSystem; - var data = seriesModel.getData(); - - var opacityMap = { - normal: lineStyle.opacity, - active: activeOpacity, - inactive: inactiveOpacity - }; - - coordSys.eachActiveState(data, function (activeState, dataIndex) { - data.setItemVisual(dataIndex, 'opacity', opacityMap[activeState]); - }); - - data.setVisual('color', color); - }); - }; -}); -define('echarts/chart/parallel',['require','../echarts','../component/parallel','./parallel/ParallelSeries','./parallel/ParallelView','./parallel/parallelVisual'],function (require) { - var echarts = require('../echarts'); +/***/ }, +/* 276 */ +/***/ function(module, exports, __webpack_require__) { - require('../component/parallel'); + 'use strict'; - require('./parallel/ParallelSeries'); - require('./parallel/ParallelView'); - echarts.registerVisualCoding('chart', require('./parallel/parallelVisual')); + var zrUtil = __webpack_require__(3); + var Axis = __webpack_require__(117); -}); -define('echarts/chart/sankey/SankeySeries',['require','../../model/Series','../helper/createGraphFromNodeEdge'],function (require) { - - - - var SeriesModel = require('../../model/Series'); - var createGraphFromNodeEdge = require('../helper/createGraphFromNodeEdge'); - - return SeriesModel.extend({ - - type: 'series.sankey', - - layoutInfo: null, - - getInitialData: function (option, ecModel) { - var links = option.edges || option.links; - var nodes = option.data || option.nodes; - if (nodes && links) { - var graph = createGraphFromNodeEdge(nodes, links, this, true); - return graph.data; - } - }, - - /** - * @return {module:echarts/data/Graph} - */ - getGraph: function () { - return this.getData().graph; - }, - - /** - * return {module:echarts/data/List} - */ - getEdgeData: function() { - return this.getGraph().edgeData; - }, - - defaultOption: { - zlevel: 0, - z: 2, - - coordinateSystem: 'view', - - layout : null, - - // the position of the whole view - left: '5%', - top: '5%', - right: '20%', - bottom: '5%', - - // the dx of the node - nodeWidth: 20, - - // the distance between two nodes - nodeGap: 8, - - // the number of iterations to change the position of the node - layoutIterations: 32, - - label: { - normal: { - show: true, - position: 'right', - textStyle: { - color: '#000', - fontSize: 12 - } - }, - emphasis: { - show: true - } - }, - - itemStyle: { - normal: { - borderWidth: 1, - borderColor: '#aaa' - } - }, - - lineStyle: { - normal: { - color: '#314656', - opacity: 0.2, - curveness: 0.5 - }, - emphasis: { - opacity: 0.6 - } - }, - - - // colorEncoded node - - color: ['#9e0142', '#d53e4f', '#f46d43', '#fdae61', '#fee08b','#ffffbf', - '#e6f598', '#abdda4', '#66c2a5', '#3288bd', '#5e4fa2'], - - animationEasing: 'linear', - - animationDuration: 1000 - } + function AngleAxis(scale, angleExtent) { - }); + angleExtent = angleExtent || [0, 360]; -}); -define('echarts/chart/sankey/SankeyView',['require','../../util/graphic','../../util/model','zrender/core/util','../../echarts'],function (require) { - - var graphic = require('../../util/graphic'); - var modelUtil = require('../../util/model'); - var zrUtil = require('zrender/core/util'); - - var SankeyShape = graphic.extendShape({ - shape: { - x1: 0, y1: 0, - x2: 0, y2: 0, - cpx1: 0, cpy1: 0, - cpx2: 0, cpy2: 0, - - extent: 0 - }, - - buildPath: function (ctx, shape) { - var halfExtent = shape.extent / 2; - ctx.moveTo(shape.x1, shape.y1 - halfExtent); - ctx.bezierCurveTo( - shape.cpx1, shape.cpy1 - halfExtent, - shape.cpx2, shape.cpy2 - halfExtent, - shape.x2, shape.y2 - halfExtent - ); - ctx.lineTo(shape.x2, shape.y2 + halfExtent); - ctx.bezierCurveTo( - shape.cpx2, shape.cpy2 + halfExtent, - shape.cpx1, shape.cpy1 + halfExtent, - shape.x1, shape.y1 + halfExtent - ); - ctx.closePath(); - } - }); - - return require('../../echarts').extendChartView({ - - type: 'sankey', - - /** - * @private - * @type {module:echarts/chart/sankey/SankeySeries} - */ - _model: null, - - render: function(seriesModel, ecModel, api) { - var graph = seriesModel.getGraph(); - var group = this.group; - var layoutInfo = seriesModel.layoutInfo; - - this._model = seriesModel; - - group.removeAll(); - - group.position = [layoutInfo.x, layoutInfo.y]; - - var edgeData = graph.edgeData; - var rawOption = seriesModel.option; - var formatModel = modelUtil.createDataFormatModel( - seriesModel, edgeData, rawOption.edges || rawOption.links - ); - - formatModel.formatTooltip = function (dataIndex) { - var params = this.getDataParams(dataIndex); - var rawDataOpt = params.data; - var html = rawDataOpt.source + ' -- ' + rawDataOpt.target; - if (params.value) { - html += ':' + params.value; - } - return html; - }; - - // generate a rect for each node - graph.eachNode(function (node) { - var layout = node.getLayout(); - var itemModel = node.getModel(); - var labelModel = itemModel.getModel('label.normal'); - var textStyleModel = labelModel.getModel('textStyle'); - var labelHoverModel = itemModel.getModel('label.emphasis'); - var textStyleHoverModel = labelHoverModel.getModel('textStyle'); - - var rect = new graphic.Rect({ - shape: { - x: layout.x, - y: layout.y, - width: node.getLayout().dx, - height: node.getLayout().dy - }, - style: { - // Get formatted label in label.normal option. Use node id if it is not specified - text: labelModel.get('show') - ? seriesModel.getFormattedLabel(node.dataIndex, 'normal') || node.id - // Use empty string to hide the label - : '', - textFont: textStyleModel.getFont(), - textFill: textStyleModel.getTextColor(), - textPosition: labelModel.get('position') - } - }); - - rect.setStyle(zrUtil.defaults( - { - fill: node.getVisual('color') - }, - itemModel.getModel('itemStyle.normal').getItemStyle() - )); - - graphic.setHoverStyle(rect, zrUtil.extend( - node.getModel('itemStyle.emphasis'), - { - text: labelHoverModel.get('show') - ? seriesModel.getFormattedLabel(node.dataIndex, 'emphasis') || node.id - : '', - textFont: textStyleHoverModel.getFont(), - textFill: textStyleHoverModel.getTextColor(), - textPosition: labelHoverModel.get('position') - } - )); - - group.add(rect); - }); - - // generate a bezire Curve for each edge - graph.eachEdge(function (edge) { - var curve = new SankeyShape(); - - curve.dataIndex = edge.dataIndex; - curve.hostModel = formatModel; - - var lineStyleModel = edge.getModel('lineStyle.normal'); - var curvature = lineStyleModel.get('curveness'); - var n1Layout = edge.node1.getLayout(); - var n2Layout = edge.node2.getLayout(); - var edgeLayout = edge.getLayout(); - - curve.shape.extent = Math.max(1, edgeLayout.dy); - - var x1 = n1Layout.x + n1Layout.dx; - var y1 = n1Layout.y + edgeLayout.sy + edgeLayout.dy / 2; - var x2 = n2Layout.x; - var y2 = n2Layout.y + edgeLayout.ty + edgeLayout.dy /2; - var cpx1 = x1 * (1 - curvature) + x2 * curvature; - var cpy1 = y1; - var cpx2 = x1 * curvature + x2 * (1 - curvature); - var cpy2 = y2; - - curve.setShape({ - x1: x1, - y1: y1, - x2: x2, - y2: y2, - cpx1: cpx1, - cpy1: cpy1, - cpx2: cpx2, - cpy2: cpy2 - }); - - curve.setStyle(lineStyleModel.getItemStyle()); - graphic.setHoverStyle(curve, edge.getModel('lineStyle.emphasis').getItemStyle()); - - group.add(curve); - - }); - if (!this._data) { - group.setClipPath(createGridClipShape(group.getBoundingRect(), seriesModel, function () { - group.removeClipPath(); - })); - } - this._data = seriesModel.getData(); - } - }); - - //add animation to the view - function createGridClipShape(rect, seriesModel, cb) { - var rectEl = new graphic.Rect({ - shape: { - x: rect.x - 10, - y: rect.y - 10, - width: 0, - height: rect.height + 20 - } - }); - graphic.initProps(rectEl, { - shape: { - width: rect.width + 20, - height: rect.height + 20 - } - }, seriesModel, cb); - - return rectEl; - } -}); -define('echarts/util/array/nest',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - /** - * nest helper used to group by the array. - * can specified the keys and sort the keys. - */ - function nest() { - - var keysFunction = []; - var sortKeysFunction = []; - - /** - * map an Array into the mapObject. - * @param {Array} array - * @param {number} depth - */ - function map(array, depth) { - if (depth >= keysFunction.length) { - return array; - } - var i = -1; - var n = array.length; - var keyFunction = keysFunction[depth++]; - var mapObject = {}; - var valuesByKey = {}; - - while (++i < n) { - var keyValue = keyFunction(array[i]); - var values = valuesByKey[keyValue]; - - if (values) { - values.push(array[i]); - } - else { - valuesByKey[keyValue] = [array[i]]; - } - } - - zrUtil.each(valuesByKey, function (value, key) { - mapObject[key] = map(value, depth); - }); - - return mapObject; - } - - /** - * transform the Map Object to multidimensional Array - * @param {Object} map - * @param {number} depth - */ - function entriesMap(mapObject, depth) { - if (depth >= keysFunction.length) { - return mapObject; - } - var array = []; - var sortKeyFunction = sortKeysFunction[depth++]; - - zrUtil.each(mapObject, function (value, key) { - array.push({ - key: key, values: entriesMap(value, depth) - }); - }); - - if (sortKeyFunction) { - return array.sort(function (a, b) { - return sortKeyFunction(a.key, b.key); - }); - } - else { - return array; - } - } - - return { - /** - * specified the key to groupby the arrays. - * users can specified one more keys. - * @param {Function} d - */ - key: function (d) { - keysFunction.push(d); - return this; - }, - - /** - * specified the comparator to sort the keys - * @param {Function} order - */ - sortKeys: function (order) { - sortKeysFunction[keysFunction.length - 1] = order; - return this; - }, - - /** - * the array to be grouped by. - * @param {Array} array - */ - entries: function (array) { - return entriesMap(map(array, 0), 0); - } - }; - } - return nest; -}); -define('echarts/chart/sankey/sankeyLayout',['require','../../util/layout','../../util/array/nest','zrender/core/util'],function (require) { - - var layout = require('../../util/layout'); - var nest = require('../../util/array/nest'); - var zrUtil = require('zrender/core/util'); - - return function (ecModel, api) { - - ecModel.eachSeriesByType('sankey', function (seriesModel) { - - var nodeWidth = seriesModel.get('nodeWidth'); - var nodeGap = seriesModel.get('nodeGap'); - - var layoutInfo = getViewRect(seriesModel, api); - - seriesModel.layoutInfo = layoutInfo; - - var width = layoutInfo.width; - var height = layoutInfo.height; - - var graph = seriesModel.getGraph(); - - var nodes = graph.nodes; - var edges = graph.edges; - - computeNodeValues(nodes); - - var filteredNodes = nodes.filter(function (node) { - return node.getLayout().value === 0; - }); - - var iterations = filteredNodes.length !== 0 - ? 0 : seriesModel.get('layoutIterations'); - - layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations); - }); - }; - - /** - * get the layout position of the whole view. - */ - function getViewRect(seriesModel, api) { - return layout.getLayoutRect( - seriesModel.getBoxLayoutParams(), { - width: api.getWidth(), - height: api.getHeight() - } - ); - } - - function layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations) { - computeNodeBreadths(nodes, nodeWidth, width); - computeNodeDepths(nodes, edges, height, nodeGap, iterations); - computeEdgeDepths(nodes); - } - - /** - * compute the value of each node by summing the associated edge's value. - * @param {module:echarts/data/Graph~Node} nodes - */ - function computeNodeValues(nodes) { - zrUtil.each(nodes, function (node) { - var value1 = sum(node.outEdges, getEdgeValue); - var value2 = sum(node.inEdges, getEdgeValue); - var value = Math.max(value1, value2); - node.setLayout({value: value}, true); - }); - } - - /** - * compute the x-position for each node. - * @param {module:echarts/data/Graph~Node} nodes - * @param {number} nodeWidth - * @param {number} width - */ - function computeNodeBreadths(nodes, nodeWidth, width) { - var remainNodes = nodes; - var nextNode = null; - var x = 0; - var kx = 0; - - while (remainNodes.length) { - nextNode = []; - - for (var i = 0, len = remainNodes.length; i < len; i++) { - var node = remainNodes[i]; - node.setLayout({x: x}, true); - node.setLayout({dx: nodeWidth}, true); - - for (var j = 0, lenj = node.outEdges.length; j < lenj; j++) { - nextNode.push(node.outEdges[j].node2); - } - } - remainNodes = nextNode; - ++x; - } - - moveSinksRight(nodes, x); - kx = (width - nodeWidth) / (x - 1); - - scaleNodeBreadths(nodes, kx); - } - - /** - * all the node without outEgdes are assigned maximum breadth and - * be aligned in the last column. - * @param {module:echarts/data/Graph~Node} nodes - * @param {number} x - */ - function moveSinksRight(nodes, x) { - zrUtil.each(nodes, function (node) { - if(!node.outEdges.length) { - node.setLayout({x: x-1}, true); - } - }); - } - - /** - * scale node x-position to the width. - * @param {module:echarts/data/Graph~Node} nodes - * @param {number} kx - */ - function scaleNodeBreadths(nodes, kx) { - zrUtil.each(nodes, function(node) { - var nodeX = node.getLayout().x * kx; - node.setLayout({x: nodeX}, true); - }); - } - - /** - * using Gauss-Seidel iterations method to compute the node depth(y-position). - * @param {module:echarts/data/Graph~Node} nodes - * @param {module:echarts/data/Graph~Edge} edges - * @param {number} height - * @param {numbber} nodeGap - * @param {number} iterations - */ - function computeNodeDepths(nodes, edges, height, nodeGap, iterations) { - var nodesByBreadth = nest() - .key(function (d) { - return d.getLayout().x; - }) - .sortKeys(ascending) - .entries(nodes) - .map(function (d) { - return d.values; - }); - - initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap); - resolveCollisions(nodesByBreadth, nodeGap, height); - - for (var alpha = 1; iterations > 0; iterations--) { - alpha *= 0.99; - relaxRightToLeft(nodesByBreadth, alpha); - resolveCollisions(nodesByBreadth, nodeGap, height); - relaxLeftToRight(nodesByBreadth, alpha); - resolveCollisions(nodesByBreadth, nodeGap, height); - } - } - - /** - * compute the original y-position for each node. - * @param {module:echarts/data/Graph~Node} nodes - * @param {Array.>} nodesByBreadth - * @param {module:echarts/data/Graph~Edge} edges - * @param {number} height - * @param {number} nodeGap - */ - function initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap) { - var kyArray = []; - zrUtil.each(nodesByBreadth, function (nodes) { - var n = nodes.length; - var sum = 0; - zrUtil.each(nodes, function (node) { - sum += node.getLayout().value; - }); - var ky = (height - (n-1) * nodeGap) / sum; - kyArray.push(ky); - }); - kyArray.sort(function (a, b) { - return a - b; - }); - var ky0 = kyArray[0]; - - zrUtil.each(nodesByBreadth, function (nodes) { - zrUtil.each(nodes, function (node, i) { - node.setLayout({y: i}, true); - var nodeDy = node.getLayout().value * ky0; - node.setLayout({dy: nodeDy}, true); - }); - }); - - zrUtil.each(edges, function (edge) { - var edgeDy = +edge.getValue() * ky0; - edge.setLayout({dy: edgeDy}, true); - }); - } - - /** - * resolve the collision of initialized depth. - * @param {Array.>} nodesByBreadth - * @param {number} nodeGap - * @param {number} height - */ - function resolveCollisions(nodesByBreadth, nodeGap, height) { - zrUtil.each(nodesByBreadth, function (nodes) { - var node; - var dy; - var y0 = 0; - var n = nodes.length; - var i; - - nodes.sort(ascendingDepth); - - for (i = 0; i < n; i++) { - node = nodes[i]; - dy = y0 - node.getLayout().y; - if(dy > 0) { - var nodeY = node.getLayout().y + dy; - node.setLayout({y: nodeY}, true); - } - y0 = node.getLayout().y + node.getLayout().dy + nodeGap; - } - - // if the bottommost node goes outside the biunds, push it back up - dy = y0 - nodeGap - height; - if (dy > 0) { - var nodeY = node.getLayout().y -dy; - node.setLayout({y: nodeY}, true); - y0 = node.getLayout().y; - for (i = n - 2; i >= 0; --i) { - node = nodes[i]; - dy = node.getLayout().y + node.getLayout().dy + nodeGap - y0; - if (dy > 0) { - nodeY = node.getLayout().y - dy; - node.setLayout({y: nodeY}, true); - } - y0 = node.getLayout().y; - } - } - }); - } - - /** - * change the y-position of the nodes, except most the right side nodes. - * @param {Array.>} nodesByBreadth - * @param {number} alpha - */ - function relaxRightToLeft(nodesByBreadth, alpha) { - zrUtil.each(nodesByBreadth.slice().reverse(), function (nodes) { - zrUtil.each(nodes, function (node) { - if (node.outEdges.length) { - var y = sum(node.outEdges, weightedTarget) / sum(node.outEdges, getEdgeValue); - var nodeY = node.getLayout().y + (y - center(node)) * alpha; - node.setLayout({y: nodeY}, true); - } - }); - }); - } - - function weightedTarget(edge) { - return center(edge.node2) * edge.getValue(); - } - - /** - * change the y-position of the nodes, except most the left side nodes. - * @param {Array.>} nodesByBreadth - * @param {number} alpha - */ - function relaxLeftToRight(nodesByBreadth, alpha) { - zrUtil.each(nodesByBreadth, function (nodes) { - zrUtil.each(nodes, function (node) { - if (node.inEdges.length) { - var y = sum(node.inEdges, weightedSource) / sum(node.inEdges, getEdgeValue); - var nodeY = node.getLayout().y + (y - center(node)) * alpha; - node.setLayout({y: nodeY}, true); - } - }); - }); - } - - function weightedSource(edge) { - return center(edge.node1) * edge.getValue(); - } - - /** - * compute the depth(y-position) of each edge. - * @param {module:echarts/data/Graph~Node} nodes - */ - function computeEdgeDepths(nodes) { - zrUtil.each(nodes, function (node) { - node.outEdges.sort(ascendingTargetDepth); - node.inEdges.sort(ascendingSourceDepth); - }); - zrUtil.each(nodes, function (node) { - var sy = 0; - var ty = 0; - zrUtil.each(node.outEdges, function (edge) { - edge.setLayout({sy: sy}, true); - sy += edge.getLayout().dy; - }); - zrUtil.each(node.inEdges, function (edge) { - edge.setLayout({ty: ty}, true); - ty += edge.getLayout().dy; - }); - }); - } - - function ascendingTargetDepth(a, b) { - return a.node2.getLayout().y - b.node2.getLayout().y; - } - - function ascendingSourceDepth(a, b) { - return a.node1.getLayout().y - b.node1.getLayout().y; - } - - function sum(array, f) { - var s = 0; - var n = array.length; - var a; - var i = -1; - if (arguments.length === 1) { - while (++i < n) { - a = +array[i]; - if (!isNaN(a)) { - s += a; - } - } - } - else { - while (++i < n) { - a = +f.call(array, array[i], i); - if(!isNaN(a)) { - s += a; - } - } - } - return s; - } - - function center(node) { - return node.getLayout().y + node.getLayout().dy / 2; - } - - function ascendingDepth(a, b) { - return a.getLayout().y - b.getLayout().y; - } - - function ascending(a, b) { - return a < b ? -1 : a > b ? 1 : a == b ? 0 : NaN; - } - - function getEdgeValue(edge) { - return edge.getValue(); - } + Axis.call(this, 'angle', scale, angleExtent); -}); -define('echarts/chart/sankey/sankeyVisual',['require','../../visual/VisualMapping'],function (require) { + /** + * Axis type + * - 'category' + * - 'value' + * - 'time' + * - 'log' + * @type {string} + */ + this.type = 'category'; + } - var VisualMapping = require('../../visual/VisualMapping'); + AngleAxis.prototype = { - return function (ecModel, payload) { - ecModel.eachSeriesByType('sankey', function (seriesModel) { - var graph = seriesModel.getGraph(); - var nodes = graph.nodes; + constructor: AngleAxis, - nodes.sort(function (a, b) { - return a.getLayout().value - b.getLayout().value; - }); + dataToAngle: Axis.prototype.dataToCoord, - var minValue = nodes[0].getLayout().value; - var maxValue = nodes[nodes.length - 1].getLayout().value; + angleToData: Axis.prototype.coordToData + }; - nodes.forEach(function (node) { - var mapping = new VisualMapping({ - type: 'color', - mappingMethod: 'linear', - dataExtent: [minValue, maxValue], - visual: seriesModel.get('color') - }); + zrUtil.inherits(AngleAxis, Axis); - var mapValueToColor = mapping.mapValueToVisual(node.getLayout().value); - node.setVisual('color', mapValueToColor); - }); + module.exports = AngleAxis; - }) ; - }; -}); -define('echarts/chart/sankey',['require','../echarts','./sankey/SankeySeries','./sankey/SankeyView','./sankey/sankeyLayout','./sankey/sankeyVisual'],function (require) { - var echarts = require('../echarts'); +/***/ }, +/* 277 */ +/***/ function(module, exports, __webpack_require__) { - require('./sankey/SankeySeries'); - require('./sankey/SankeyView'); - echarts.registerLayout(require('./sankey/sankeyLayout')); - echarts.registerVisualCoding('chart', require('./sankey/sankeyVisual')); -}); -/** - * @module echarts/chart/helper/Symbol - */ -define('echarts/chart/helper/WhiskerBoxDraw',['require','zrender/core/util','../../util/graphic','zrender/graphic/Path'],function (require) { - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var Path = require('zrender/graphic/Path'); - - var WhiskerPath = Path.extend({ - - type: 'whiskerInBox', - - shape: {}, - - buildPath: function (ctx, shape) { - for (var i in shape) { - if (i.indexOf('ends') === 0) { - var pts = shape[i]; - ctx.moveTo(pts[0][0], pts[0][1]); - ctx.lineTo(pts[1][0], pts[1][1]); - } - } - } - }); - - /** - * @constructor - * @alias {module:echarts/chart/helper/WhiskerBox} - * @param {module:echarts/data/List} data - * @param {number} idx - * @param {Function} styleUpdater - * @param {boolean} isInit - * @extends {module:zrender/graphic/Group} - */ - function WhiskerBox(data, idx, styleUpdater, isInit) { - graphic.Group.call(this); - - /** - * @type {number} - * @readOnly - */ - this.bodyIndex; - - /** - * @type {number} - * @readOnly - */ - this.whiskerIndex; - - /** - * @type {Function} - */ - this.styleUpdater = styleUpdater; - - this._createContent(data, idx, isInit); - - this.updateData(data, idx, isInit); - - /** - * Last series model. - * @type {module:echarts/model/Series} - */ - this._seriesModel; - } - - var whiskerBoxProto = WhiskerBox.prototype; - - whiskerBoxProto._createContent = function (data, idx, isInit) { - var itemLayout = data.getItemLayout(idx); - var constDim = itemLayout.chartLayout === 'horizontal' ? 1 : 0; - var count = 0; - - // Whisker element. - this.add(new graphic.Polygon({ - shape: { - points: isInit - ? transInit(itemLayout.bodyEnds, constDim, itemLayout) - : itemLayout.bodyEnds - }, - style: {strokeNoScale: true}, - z2: 100 - })); - this.bodyIndex = count++; - - // Box element. - var whiskerEnds = zrUtil.map(itemLayout.whiskerEnds, function (ends) { - return isInit ? transInit(ends, constDim, itemLayout) : ends; - }); - this.add(new WhiskerPath({ - shape: makeWhiskerEndsShape(whiskerEnds), - style: {strokeNoScale: true}, - z2: 100 - })); - this.whiskerIndex = count++; - }; - - function transInit(points, dim, itemLayout) { - return zrUtil.map(points, function (point) { - point = point.slice(); - point[dim] = itemLayout.initBaseline; - return point; - }); - } - - function makeWhiskerEndsShape(whiskerEnds) { - // zr animation only support 2-dim array. - var shape = {}; - zrUtil.each(whiskerEnds, function (ends, i) { - shape['ends' + i] = ends; - }); - return shape; - } - - /** - * Update symbol properties - * @param {module:echarts/data/List} data - * @param {number} idx - */ - whiskerBoxProto.updateData = function (data, idx, isInit) { - var seriesModel = this._seriesModel = data.hostModel; - var itemLayout = data.getItemLayout(idx); - var updateMethod = graphic[isInit ? 'initProps' : 'updateProps']; - // this.childAt(this.bodyIndex).stopAnimation(true); - // this.childAt(this.whiskerIndex).stopAnimation(true); - updateMethod( - this.childAt(this.bodyIndex), - {shape: {points: itemLayout.bodyEnds}}, - seriesModel - ); - updateMethod( - this.childAt(this.whiskerIndex), - {shape: makeWhiskerEndsShape(itemLayout.whiskerEnds)}, - seriesModel - ); - - this.styleUpdater.call(null, this, data, idx); - }; - - zrUtil.inherits(WhiskerBox, graphic.Group); - - - /** - * @constructor - * @alias module:echarts/chart/helper/WhiskerBoxDraw - */ - function WhiskerBoxDraw(styleUpdater) { - this.group = new graphic.Group(); - this.styleUpdater = styleUpdater; - } - - var whiskerBoxDrawProto = WhiskerBoxDraw.prototype; - - /** - * Update symbols draw by new data - * @param {module:echarts/data/List} data - */ - whiskerBoxDrawProto.updateData = function (data) { - var group = this.group; - var oldData = this._data; - var styleUpdater = this.styleUpdater; - - data.diff(oldData) - .add(function (newIdx) { - if (data.hasValue(newIdx)) { - var symbolEl = new WhiskerBox(data, newIdx, styleUpdater, true); - data.setItemGraphicEl(newIdx, symbolEl); - group.add(symbolEl); - } - }) - .update(function (newIdx, oldIdx) { - var symbolEl = oldData.getItemGraphicEl(oldIdx); - - // Empty data - if (!data.hasValue(newIdx)) { - group.remove(symbolEl); - return; - } - - if (!symbolEl) { - symbolEl = new WhiskerBox(data, newIdx, styleUpdater); - } - else { - symbolEl.updateData(data, newIdx); - } - - // Add back - group.add(symbolEl); - - data.setItemGraphicEl(newIdx, symbolEl); - }) - .remove(function (oldIdx) { - var el = oldData.getItemGraphicEl(oldIdx); - el && group.remove(el); - }) - .execute(); - - this._data = data; - }; - - /** - * Remove symbols. - * @param {module:echarts/data/List} data - */ - whiskerBoxDrawProto.remove = function () { - var group = this.group; - var data = this._data; - this._data = null; - data && data.eachItemGraphicEl(function (el) { - el && group.remove(el); - }); - }; - - return WhiskerBoxDraw; -}); -define('echarts/chart/helper/whiskerBoxCommon',['require','../../data/List','../../data/helper/completeDimensions','../helper/WhiskerBoxDraw','zrender/core/util'],function(require) { - - - - var List = require('../../data/List'); - var completeDimensions = require('../../data/helper/completeDimensions'); - var WhiskerBoxDraw = require('../helper/WhiskerBoxDraw'); - var zrUtil = require('zrender/core/util'); - - function getItemValue(item) { - return item.value == null ? item : item.value; - } - - var seriesModelMixin = { - - /** - * @private - * @type {string} - */ - _baseAxisDim: null, - - /** - * @override - */ - getInitialData: function (option, ecModel) { - // When both types of xAxis and yAxis are 'value', layout is - // needed to be specified by user. Otherwise, layout can be - // judged by which axis is category. - - var categories; - - var xAxisModel = ecModel.getComponent('xAxis', this.get('xAxisIndex')); - var yAxisModel = ecModel.getComponent('yAxis', this.get('yAxisIndex')); - var xAxisType = xAxisModel.get('type'); - var yAxisType = yAxisModel.get('type'); - var addOrdinal; - - // FIXME - // 考虑时间轴 - - if (xAxisType === 'category') { - option.layout = 'horizontal'; - categories = xAxisModel.getCategories(); - addOrdinal = true; - } - else if (yAxisType === 'category') { - option.layout = 'vertical'; - categories = yAxisModel.getCategories(); - addOrdinal = true; - } - else { - option.layout = option.layout || 'horizontal'; - } - - this._baseAxisDim = option.layout === 'horizontal' ? 'x' : 'y'; - - var data = option.data; - var dimensions = this.dimensions = ['base'].concat(this.valueDimensions); - completeDimensions(dimensions, data); - - var list = new List(dimensions, this); - list.initData(data, categories ? categories.slice() : null, function (dataItem, dimName, idx, dimIdx) { - var value = getItemValue(dataItem); - return addOrdinal ? (dimName === 'base' ? idx : value[dimIdx - 1]) : value[dimIdx]; - }); - - return list; - }, - - /** - * Used by Gird. - * @param {string} axisDim 'x' or 'y' - * @return {Array.} dimensions on the axis. - */ - coordDimToDataDim: function (axisDim) { - var dims = this.valueDimensions.slice(); - var baseDim = ['base']; - var map = { - horizontal: {x: baseDim, y: dims}, - vertical: {x: dims, y: baseDim} - }; - return map[this.get('layout')][axisDim]; - }, - - /** - * @override - * @param {string|number} dataDim - * @return {string} coord dimension - */ - dataDimToCoordDim: function (dataDim) { - var dim; - - zrUtil.each(['x', 'y'], function (coordDim, index) { - var dataDims = this.coordDimToDataDim(coordDim); - if (zrUtil.indexOf(dataDims, dataDim) >= 0) { - dim = coordDim; - } - }, this); - - return dim; - }, - - /** - * If horizontal, base axis is x, otherwise y. - * @override - */ - getBaseAxis: function () { - var dim = this._baseAxisDim; - return this.ecModel.getComponent(dim + 'Axis', this.get(dim + 'AxisIndex')).axis; - } - }; - - var viewMixin = { - - init: function () { - /** - * Old data. - * @private - * @type {module:echarts/chart/helper/WhiskerBoxDraw} - */ - var whiskerBoxDraw = this._whiskerBoxDraw = new WhiskerBoxDraw( - this.getStyleUpdater() - ); - this.group.add(whiskerBoxDraw.group); - }, - - render: function (seriesModel, ecModel, api) { - this._whiskerBoxDraw.updateData(seriesModel.getData()); - }, - - remove: function (ecModel) { - this._whiskerBoxDraw.remove(); - } - }; - - return { - seriesModelMixin: seriesModelMixin, - viewMixin: viewMixin - }; -}); -define('echarts/chart/boxplot/BoxplotSeries',['require','zrender/core/util','../../model/Series','../helper/whiskerBoxCommon'],function(require) { + 'use strict'; - - var zrUtil = require('zrender/core/util'); - var SeriesModel = require('../../model/Series'); - var whiskerBoxCommon = require('../helper/whiskerBoxCommon'); + __webpack_require__(278); - var BoxplotSeries = SeriesModel.extend({ + __webpack_require__(1).extendComponentModel({ - type: 'series.boxplot', + type: 'polar', - dependencies: ['xAxis', 'yAxis', 'grid'], + dependencies: ['polarAxis', 'angleAxis'], - // TODO - // box width represents group size, so dimension should have 'size'. + /** + * @type {module:echarts/coord/polar/Polar} + */ + coordinateSystem: null, - /** - * @see - * The meanings of 'min' and 'max' depend on user, - * and echarts do not need to know it. - * @readOnly - */ - valueDimensions: ['min', 'Q1', 'median', 'Q3', 'max'], + /** + * @param {string} axisType + * @return {module:echarts/coord/polar/AxisModel} + */ + findAxisModel: function (axisType) { + var angleAxisModel; + var ecModel = this.ecModel; + ecModel.eachComponent(axisType, function (axisModel) { + if (ecModel.getComponent( + 'polar', axisModel.getShallow('polarIndex') + ) === this) { + angleAxisModel = axisModel; + } + }, this); + return angleAxisModel; + }, - /** - * @type {Array.} - * @readOnly - */ - dimensions: null, + defaultOption: { - /** - * @override - */ - defaultOption: { - zlevel: 0, // 一级层叠 - z: 2, // 二级层叠 - coordinateSystem: 'cartesian2d', - legendHoverLink: true, + zlevel: 0, - hoverAnimation: true, + z: 0, - xAxisIndex: 0, - yAxisIndex: 0, + center: ['50%', '50%'], - layout: null, // 'horizontal' or 'vertical' - boxWidth: [7, 50], // [min, max] can be percent of band width. + radius: '80%' + } + }); - itemStyle: { - normal: { - color: '#fff', - borderWidth: 1 - }, - emphasis: { - borderWidth: 2, - shadowBlur: 5, - shadowOffsetX: 2, - shadowOffsetY: 2, - shadowColor: 'rgba(0,0,0,0.4)' - } - }, - animationEasing: 'elasticOut', - animationDuration: 800 - } - }); +/***/ }, +/* 278 */ +/***/ function(module, exports, __webpack_require__) { - zrUtil.mixin(BoxplotSeries, whiskerBoxCommon.seriesModelMixin, true); + 'use strict'; - return BoxplotSeries; -}); -define('echarts/chart/boxplot/BoxplotView',['require','zrender/core/util','../../view/Chart','../../util/graphic','../helper/whiskerBoxCommon'],function(require) { + var zrUtil = __webpack_require__(3); + var ComponentModel = __webpack_require__(19); + var axisModelCreator = __webpack_require__(121); - + var PolarAxisModel = ComponentModel.extend({ + type: 'polarAxis', + /** + * @type {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis} + */ + axis: null + }); - var zrUtil = require('zrender/core/util'); - var ChartView = require('../../view/Chart'); - var graphic = require('../../util/graphic'); - var whiskerBoxCommon = require('../helper/whiskerBoxCommon'); + zrUtil.merge(PolarAxisModel.prototype, __webpack_require__(123)); - var BoxplotView = ChartView.extend({ + var polarAxisDefaultExtendedOption = { + angle: { + polarIndex: 0, - type: 'boxplot', + startAngle: 90, - getStyleUpdater: function () { - return updateStyle; - } - }); + clockwise: true, - zrUtil.mixin(BoxplotView, whiskerBoxCommon.viewMixin, true); + splitNumber: 12, - // Update common properties - var normalStyleAccessPath = ['itemStyle', 'normal']; - var emphasisStyleAccessPath = ['itemStyle', 'emphasis']; + axisLabel: { + rotate: false + } + }, + radius: { + polarIndex: 0, - function updateStyle(itemGroup, data, idx) { - var itemModel = data.getItemModel(idx); - var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath); - var borderColor = data.getItemVisual(idx, 'color'); + splitNumber: 5 + } + }; - // Exclude borderColor. - var itemStyle = normalItemStyleModel.getItemStyle(['borderColor']); + function getAxisType(axisDim, option) { + // Default axis with data is category axis + return option.type || (option.data ? 'category' : 'value'); + } - var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex); - whiskerEl.style.set(itemStyle); - whiskerEl.style.stroke = borderColor; - whiskerEl.dirty(); + axisModelCreator('angle', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.angle); + axisModelCreator('radius', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.radius); - var bodyEl = itemGroup.childAt(itemGroup.bodyIndex); - bodyEl.style.set(itemStyle); - bodyEl.style.stroke = borderColor; - bodyEl.dirty(); - var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle(); - graphic.setHoverStyle(itemGroup, hoverStyle); - } - return BoxplotView; +/***/ }, +/* 279 */ +/***/ function(module, exports, __webpack_require__) { -}); -define('echarts/chart/boxplot/boxplotVisual',['require'],function (require) { + 'use strict'; - var borderColorQuery = ['itemStyle', 'normal', 'borderColor']; - return function (ecModel, api) { + __webpack_require__(273); - var globalColors = ecModel.get('color'); + __webpack_require__(280); - ecModel.eachRawSeriesByType('boxplot', function (seriesModel) { - var defaulColor = globalColors[seriesModel.seriesIndex % globalColors.length]; - var data = seriesModel.getData(); +/***/ }, +/* 280 */ +/***/ function(module, exports, __webpack_require__) { - data.setVisual({ - legendSymbol: 'roundRect', - // Use name 'color' but not 'borderColor' for legend usage and - // visual coding from other component like dataRange. - color: seriesModel.get(borderColorQuery) || defaulColor - }); + 'use strict'; - // Only visible series has each data be visual encoded - if (!ecModel.isSeriesFiltered(seriesModel)) { - data.each(function (idx) { - var itemModel = data.getItemModel(idx); - data.setItemVisual( - idx, - {color: itemModel.get(borderColorQuery, true)} - ); - }); - } - }); - }; -}); -define('echarts/chart/boxplot/boxplotLayout',['require','zrender/core/util','../../util/number'],function (require) { - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../../util/number'); - var parsePercent = numberUtil.parsePercent; - var each = zrUtil.each; - - return function (ecModel, api) { - - var groupResult = groupSeriesByAxis(ecModel); - - each(groupResult, function (groupItem) { - var seriesModels = groupItem.seriesModels; - - if (!seriesModels.length) { - return; - } - - calculateBase(groupItem); - - each(seriesModels, function (seriesModel, idx) { - layoutSingleSeries( - seriesModel, - groupItem.boxOffsetList[idx], - groupItem.boxWidthList[idx] - ); - }); - }); - }; - - /** - * Group series by axis. - */ - function groupSeriesByAxis(ecModel) { - var result = []; - var axisList = []; - - ecModel.eachSeriesByType('boxplot', function (seriesModel) { - var baseAxis = seriesModel.getBaseAxis(); - var idx = zrUtil.indexOf(axisList, baseAxis); - - if (idx < 0) { - idx = axisList.length; - axisList[idx] = baseAxis; - result[idx] = {axis: baseAxis, seriesModels: []}; - } - - result[idx].seriesModels.push(seriesModel); - }); - - return result; - } - - /** - * Calculate offset and box width for each series. - */ - function calculateBase(groupItem) { - var extent; - var baseAxis = groupItem.axis; - var seriesModels = groupItem.seriesModels; - var seriesCount = seriesModels.length; - - var boxWidthList = groupItem.boxWidthList = []; - var boxOffsetList = groupItem.boxOffsetList = []; - var boundList = []; - - var bandWidth; - if (baseAxis.type === 'category') { - bandWidth = baseAxis.getBandWidth(); - } - else { - var maxDataCount = 0; - each(seriesModels, function (seriesModel) { - maxDataCount = Math.max(maxDataCount, seriesModel.getData().count()); - }); - extent = baseAxis.getExtent(), - Math.abs(extent[1] - extent[0]) / maxDataCount; - } - - each(seriesModels, function (seriesModel) { - var boxWidthBound = seriesModel.get('boxWidth'); - if (!zrUtil.isArray(boxWidthBound)) { - boxWidthBound = [boxWidthBound, boxWidthBound]; - } - boundList.push([ - parsePercent(boxWidthBound[0], bandWidth) || 0, - parsePercent(boxWidthBound[1], bandWidth) || 0 - ]); - }); - - var availableWidth = bandWidth * 0.8 - 2; - var boxGap = availableWidth / seriesCount * 0.3; - var boxWidth = (availableWidth - boxGap * (seriesCount - 1)) / seriesCount; - var base = boxWidth / 2 - availableWidth / 2; - - each(seriesModels, function (seriesModel, idx) { - boxOffsetList.push(base); - base += boxGap + boxWidth; - - boxWidthList.push( - Math.min(Math.max(boxWidth, boundList[idx][0]), boundList[idx][1]) - ); - }); - } - - /** - * Calculate points location for each series. - */ - function layoutSingleSeries(seriesModel, offset, boxWidth) { - var coordSys = seriesModel.coordinateSystem; - var data = seriesModel.getData(); - var dimensions = seriesModel.dimensions; - var chartLayout = seriesModel.get('layout'); - var halfWidth = boxWidth / 2; - - data.each(dimensions, function () { - var args = arguments; - var dimLen = dimensions.length; - var axisDimVal = args[0]; - var idx = args[dimLen]; - var variableDim = chartLayout === 'horizontal' ? 0 : 1; - var constDim = 1 - variableDim; - - var median = getPoint(args[3]); - var end1 = getPoint(args[1]); - var end5 = getPoint(args[5]); - var whiskerEnds = [ - [end1, getPoint(args[2])], - [end5, getPoint(args[4])] - ]; - layEndLine(end1); - layEndLine(end5); - layEndLine(median); - - var bodyEnds = []; - addBodyEnd(whiskerEnds[0][1], 0); - addBodyEnd(whiskerEnds[1][1], 1); - - data.setItemLayout(idx, { - chartLayout: chartLayout, - initBaseline: median[constDim], - median: median, - bodyEnds: bodyEnds, - whiskerEnds: whiskerEnds - }); - - function getPoint(val) { - var p = []; - p[variableDim] = axisDimVal; - p[constDim] = val; - var point; - if (isNaN(axisDimVal) || isNaN(val)) { - point = [NaN, NaN]; - } - else { - point = coordSys.dataToPoint(p); - point[variableDim] += offset; - } - return point; - } - - function addBodyEnd(point, start) { - var point1 = point.slice(); - var point2 = point.slice(); - point1[variableDim] += halfWidth; - point2[variableDim] -= halfWidth; - start - ? bodyEnds.push(point1, point2) - : bodyEnds.push(point2, point1); - } - - function layEndLine(endCenter) { - var line = [endCenter.slice(), endCenter.slice()]; - line[0][variableDim] -= halfWidth; - line[1][variableDim] += halfWidth; - whiskerEnds.push(line); - } - }); - } + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var Model = __webpack_require__(8); -}); -define('echarts/chart/boxplot',['require','../echarts','./boxplot/BoxplotSeries','./boxplot/BoxplotView','./boxplot/boxplotVisual','./boxplot/boxplotLayout'],function (require) { + var elementList = ['axisLine', 'axisLabel', 'axisTick', 'splitLine', 'splitArea']; - var echarts = require('../echarts'); + function getAxisLineShape(polar, r0, r, angle) { + var start = polar.coordToPoint([r0, angle]); + var end = polar.coordToPoint([r, angle]); - require('./boxplot/BoxplotSeries'); - require('./boxplot/BoxplotView'); + return { + x1: start[0], + y1: start[1], + x2: end[0], + y2: end[1] + }; + } + __webpack_require__(1).extendComponentView({ - echarts.registerVisualCoding('chart', require('./boxplot/boxplotVisual')); - echarts.registerLayout(require('./boxplot/boxplotLayout')); + type: 'angleAxis', -}); -define('echarts/chart/candlestick/CandlestickSeries',['require','zrender/core/util','../../model/Series','../helper/whiskerBoxCommon','../../util/format'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var SeriesModel = require('../../model/Series'); - var whiskerBoxCommon = require('../helper/whiskerBoxCommon'); - var formatUtil = require('../../util/format'); - var encodeHTML = formatUtil.encodeHTML; - var addCommas = formatUtil.addCommas; - - var CandlestickSeries = SeriesModel.extend({ - - type: 'series.candlestick', - - dependencies: ['xAxis', 'yAxis', 'grid'], - - /** - * @readOnly - */ - valueDimensions: ['open', 'close', 'lowest', 'highest'], - - /** - * @type {Array.} - * @readOnly - */ - dimensions: null, - - /** - * @override - */ - defaultOption: { - zlevel: 0, // 一级层叠 - z: 2, // 二级层叠 - coordinateSystem: 'cartesian2d', - legendHoverLink: true, - - hoverAnimation: true, - - xAxisIndex: 0, - yAxisIndex: 0, - - layout: null, // 'horizontal' or 'vertical' - - itemStyle: { - normal: { - color: '#c23531', // 阳线 positive - color0: '#314656', // 阴线 negative '#c23531', '#314656' - borderWidth: 1, - // FIXME - // ec2中使用的是lineStyle.color 和 lineStyle.color0 - borderColor: '#c23531', - borderColor0: '#314656' - }, - emphasis: { - borderWidth: 2 - } - }, - - animationUpdate: false, - animationEasing: 'linear', - animationDuration: 300 - }, - - /** - * Get dimension for shadow in dataZoom - * @return {string} dimension name - */ - getShadowDim: function () { - return 'open'; - }, - - /** - * @override - */ - formatTooltip: function (dataIndex, mutipleSeries) { - // It rearly use mutiple candlestick series in one cartesian, - // so only consider one series in this default tooltip. - var valueHTMLArr = zrUtil.map(this.valueDimensions, function (dim) { - return dim + ': ' + addCommas(this._data.get(dim, dataIndex)); - }, this); - - return encodeHTML(this.name) + '
' + valueHTMLArr.join('
'); - } - - }); - - zrUtil.mixin(CandlestickSeries, whiskerBoxCommon.seriesModelMixin, true); - - return CandlestickSeries; + render: function (angleAxisModel, ecModel) { + this.group.removeAll(); + if (!angleAxisModel.get('show')) { + return; + } + + var polarModel = ecModel.getComponent('polar', angleAxisModel.get('polarIndex')); + var angleAxis = angleAxisModel.axis; + var polar = polarModel.coordinateSystem; + var radiusExtent = polar.getRadiusAxis().getExtent(); + var ticksAngles = angleAxis.getTicksCoords(); + + if (angleAxis.type !== 'category') { + // Remove the last tick which will overlap the first tick + ticksAngles.pop(); + } + + zrUtil.each(elementList, function (name) { + if (angleAxisModel.get(name +'.show')) { + this['_' + name](angleAxisModel, polar, ticksAngles, radiusExtent); + } + }, this); + }, + + /** + * @private + */ + _axisLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) { + var lineStyleModel = angleAxisModel.getModel('axisLine.lineStyle'); + + var circle = new graphic.Circle({ + shape: { + cx: polar.cx, + cy: polar.cy, + r: radiusExtent[1] + }, + style: lineStyleModel.getLineStyle(), + z2: 1, + silent: true + }); + circle.style.fill = null; + + this.group.add(circle); + }, + + /** + * @private + */ + _axisTick: function (angleAxisModel, polar, ticksAngles, radiusExtent) { + var tickModel = angleAxisModel.getModel('axisTick'); + + var tickLen = (tickModel.get('inside') ? -1 : 1) * tickModel.get('length'); + + var lines = zrUtil.map(ticksAngles, function (tickAngle) { + return new graphic.Line({ + shape: getAxisLineShape(polar, radiusExtent[1], radiusExtent[1] + tickLen, tickAngle) + }); + }); + this.group.add(graphic.mergePath( + lines, { + style: tickModel.getModel('lineStyle').getLineStyle() + } + )); + }, + + /** + * @private + */ + _axisLabel: function (angleAxisModel, polar, ticksAngles, radiusExtent) { + var axis = angleAxisModel.axis; + + var categoryData = angleAxisModel.get('data'); + + var labelModel = angleAxisModel.getModel('axisLabel'); + var axisTextStyleModel = labelModel.getModel('textStyle'); + + var labels = angleAxisModel.getFormattedLabels(); + + var labelMargin = labelModel.get('margin'); + var labelsAngles = axis.getLabelsCoords(); + + // Use length of ticksAngles because it may remove the last tick to avoid overlapping + for (var i = 0; i < ticksAngles.length; i++) { + var r = radiusExtent[1]; + var p = polar.coordToPoint([r + labelMargin, labelsAngles[i]]); + var cx = polar.cx; + var cy = polar.cy; + + var labelTextAlign = Math.abs(p[0] - cx) / r < 0.3 + ? 'center' : (p[0] > cx ? 'left' : 'right'); + var labelTextBaseline = Math.abs(p[1] - cy) / r < 0.3 + ? 'middle' : (p[1] > cy ? 'top' : 'bottom'); + + var textStyleModel = axisTextStyleModel; + if (categoryData && categoryData[i] && categoryData[i].textStyle) { + textStyleModel = new Model( + categoryData[i].textStyle, axisTextStyleModel + ); + } + this.group.add(new graphic.Text({ + style: { + x: p[0], + y: p[1], + fill: textStyleModel.getTextColor(), + text: labels[i], + textAlign: labelTextAlign, + textVerticalAlign: labelTextBaseline, + textFont: textStyleModel.getFont() + }, + silent: true + })); + } + }, + + /** + * @private + */ + _splitLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) { + var splitLineModel = angleAxisModel.getModel('splitLine'); + var lineStyleModel = splitLineModel.getModel('lineStyle'); + var lineColors = lineStyleModel.get('color'); + var lineCount = 0; + + lineColors = lineColors instanceof Array ? lineColors : [lineColors]; + + var splitLines = []; + + for (var i = 0; i < ticksAngles.length; i++) { + var colorIndex = (lineCount++) % lineColors.length; + splitLines[colorIndex] = splitLines[colorIndex] || []; + splitLines[colorIndex].push(new graphic.Line({ + shape: getAxisLineShape(polar, radiusExtent[0], radiusExtent[1], ticksAngles[i]) + })); + } + + // Simple optimization + // Batching the lines if color are the same + for (var i = 0; i < splitLines.length; i++) { + this.group.add(graphic.mergePath(splitLines[i], { + style: zrUtil.defaults({ + stroke: lineColors[i % lineColors.length] + }, lineStyleModel.getLineStyle()), + silent: true, + z: angleAxisModel.get('z') + })); + } + }, + + /** + * @private + */ + _splitArea: function (angleAxisModel, polar, ticksAngles, radiusExtent) { + + var splitAreaModel = angleAxisModel.getModel('splitArea'); + var areaStyleModel = splitAreaModel.getModel('areaStyle'); + var areaColors = areaStyleModel.get('color'); + var lineCount = 0; + + areaColors = areaColors instanceof Array ? areaColors : [areaColors]; + + var splitAreas = []; + + var RADIAN = Math.PI / 180; + var prevAngle = -ticksAngles[0] * RADIAN; + var r0 = Math.min(radiusExtent[0], radiusExtent[1]); + var r1 = Math.max(radiusExtent[0], radiusExtent[1]); + + var clockwise = angleAxisModel.get('clockwise'); + + for (var i = 1; i < ticksAngles.length; i++) { + var colorIndex = (lineCount++) % areaColors.length; + splitAreas[colorIndex] = splitAreas[colorIndex] || []; + splitAreas[colorIndex].push(new graphic.Sector({ + shape: { + cx: polar.cx, + cy: polar.cy, + r0: r0, + r: r1, + startAngle: prevAngle, + endAngle: -ticksAngles[i] * RADIAN, + clockwise: clockwise + }, + silent: true + })); + prevAngle = -ticksAngles[i] * RADIAN; + } + + // Simple optimization + // Batching the lines if color are the same + for (var i = 0; i < splitAreas.length; i++) { + this.group.add(graphic.mergePath(splitAreas[i], { + style: zrUtil.defaults({ + fill: areaColors[i % areaColors.length] + }, areaStyleModel.getAreaStyle()), + silent: true + })); + } + } + }); + + +/***/ }, +/* 281 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(273); + + __webpack_require__(282); + + +/***/ }, +/* 282 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var AxisBuilder = __webpack_require__(126); + + var axisBuilderAttrs = [ + 'axisLine', 'axisLabel', 'axisTick', 'axisName' + ]; + var selfBuilderAttrs = [ + 'splitLine', 'splitArea' + ]; + + __webpack_require__(1).extendComponentView({ + + type: 'radiusAxis', + + render: function (radiusAxisModel, ecModel) { + this.group.removeAll(); + if (!radiusAxisModel.get('show')) { + return; + } + var polarModel = ecModel.getComponent('polar', radiusAxisModel.get('polarIndex')); + var angleAxis = polarModel.coordinateSystem.getAngleAxis(); + var radiusAxis = radiusAxisModel.axis; + var polar = polarModel.coordinateSystem; + var ticksCoords = radiusAxis.getTicksCoords(); + var axisAngle = angleAxis.getExtent()[0]; + var radiusExtent = radiusAxis.getExtent(); + + var layout = layoutAxis(polar, radiusAxisModel, axisAngle); + var axisBuilder = new AxisBuilder(radiusAxisModel, layout); + zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder); + this.group.add(axisBuilder.getGroup()); + + zrUtil.each(selfBuilderAttrs, function (name) { + if (radiusAxisModel.get(name +'.show')) { + this['_' + name](radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords); + } + }, this); + }, + + /** + * @private + */ + _splitLine: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) { + var splitLineModel = radiusAxisModel.getModel('splitLine'); + var lineStyleModel = splitLineModel.getModel('lineStyle'); + var lineColors = lineStyleModel.get('color'); + var lineCount = 0; + + lineColors = lineColors instanceof Array ? lineColors : [lineColors]; + + var splitLines = []; + + for (var i = 0; i < ticksCoords.length; i++) { + var colorIndex = (lineCount++) % lineColors.length; + splitLines[colorIndex] = splitLines[colorIndex] || []; + splitLines[colorIndex].push(new graphic.Circle({ + shape: { + cx: polar.cx, + cy: polar.cy, + r: ticksCoords[i] + }, + silent: true + })); + } + + // Simple optimization + // Batching the lines if color are the same + for (var i = 0; i < splitLines.length; i++) { + this.group.add(graphic.mergePath(splitLines[i], { + style: zrUtil.defaults({ + stroke: lineColors[i % lineColors.length], + fill: null + }, lineStyleModel.getLineStyle()), + silent: true + })); + } + }, + + /** + * @private + */ + _splitArea: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) { + + var splitAreaModel = radiusAxisModel.getModel('splitArea'); + var areaStyleModel = splitAreaModel.getModel('areaStyle'); + var areaColors = areaStyleModel.get('color'); + var lineCount = 0; + + areaColors = areaColors instanceof Array ? areaColors : [areaColors]; + + var splitAreas = []; + + var prevRadius = ticksCoords[0]; + for (var i = 1; i < ticksCoords.length; i++) { + var colorIndex = (lineCount++) % areaColors.length; + splitAreas[colorIndex] = splitAreas[colorIndex] || []; + splitAreas[colorIndex].push(new graphic.Sector({ + shape: { + cx: polar.cx, + cy: polar.cy, + r0: prevRadius, + r: ticksCoords[i], + startAngle: 0, + endAngle: Math.PI * 2 + }, + silent: true + })); + prevRadius = ticksCoords[i]; + } + + // Simple optimization + // Batching the lines if color are the same + for (var i = 0; i < splitAreas.length; i++) { + this.group.add(graphic.mergePath(splitAreas[i], { + style: zrUtil.defaults({ + fill: areaColors[i % areaColors.length] + }, areaStyleModel.getAreaStyle()), + silent: true + })); + } + } + }); + + /** + * @inner + */ + function layoutAxis(polar, radiusAxisModel, axisAngle) { + return { + position: [polar.cx, polar.cy], + rotation: axisAngle / 180 * Math.PI, + labelDirection: -1, + tickDirection: -1, + nameDirection: 1, + labelRotation: radiusAxisModel.getModel('axisLabel').get('rotate'), + // Over splitLine and splitArea + z2: 1 + }; + } + + +/***/ }, +/* 283 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(163); + + __webpack_require__(284); + + __webpack_require__(161); + + +/***/ }, +/* 284 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var MapDraw = __webpack_require__(158); + + module.exports = __webpack_require__(1).extendComponentView({ + + type: 'geo', + + init: function (ecModel, api) { + var mapDraw = new MapDraw(api, true); + this._mapDraw = mapDraw; + + this.group.add(mapDraw.group); + }, + + render: function (geoModel, ecModel, api) { + geoModel.get('show') && + this._mapDraw.draw(geoModel, ecModel, api); + } + }); + + +/***/ }, +/* 285 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var echarts = __webpack_require__(1); + var graphic = __webpack_require__(42); + var layout = __webpack_require__(21); + + // Model + echarts.extendComponentModel({ + + type: 'title', + + layoutMode: {type: 'box', ignoreSize: true}, + + defaultOption: { + // 一级层叠 + zlevel: 0, + // 二级层叠 + z: 6, + show: true, + + text: '', + // 超链接跳转 + // link: null, + // 仅支持self | blank + target: 'blank', + subtext: '', + + // 超链接跳转 + // sublink: null, + // 仅支持self | blank + subtarget: 'blank', + + // 'center' ¦ 'left' ¦ 'right' + // ¦ {number}(x坐标,单位px) + left: 0, + // 'top' ¦ 'bottom' ¦ 'center' + // ¦ {number}(y坐标,单位px) + top: 0, + + // 水平对齐 + // 'auto' | 'left' | 'right' + // 默认根据 x 的位置判断是左对齐还是右对齐 + //textAlign: null + + backgroundColor: 'rgba(0,0,0,0)', + + // 标题边框颜色 + borderColor: '#ccc', + + // 标题边框线宽,单位px,默认为0(无边框) + borderWidth: 0, + + // 标题内边距,单位px,默认各方向内边距为5, + // 接受数组分别设定上右下左边距,同css + padding: 5, + + // 主副标题纵向间隔,单位px,默认为10, + itemGap: 10, + textStyle: { + fontSize: 18, + fontWeight: 'bolder', + // 主标题文字颜色 + color: '#333' + }, + subtextStyle: { + // 副标题文字颜色 + color: '#aaa' + } + } + }); + + // View + echarts.extendComponentView({ + + type: 'title', + + render: function (titleModel, ecModel, api) { + this.group.removeAll(); + + if (!titleModel.get('show')) { + return; + } + + var group = this.group; + + var textStyleModel = titleModel.getModel('textStyle'); + var subtextStyleModel = titleModel.getModel('subtextStyle'); + + var textAlign = titleModel.get('textAlign'); + + var textEl = new graphic.Text({ + style: { + text: titleModel.get('text'), + textFont: textStyleModel.getFont(), + fill: textStyleModel.getTextColor(), + textBaseline: 'top' + }, + z2: 10 + }); + + var textRect = textEl.getBoundingRect(); + + var subText = titleModel.get('subtext'); + var subTextEl = new graphic.Text({ + style: { + text: subText, + textFont: subtextStyleModel.getFont(), + fill: subtextStyleModel.getTextColor(), + y: textRect.height + titleModel.get('itemGap'), + textBaseline: 'top' + }, + z2: 10 + }); + + var link = titleModel.get('link'); + var sublink = titleModel.get('sublink'); + + textEl.silent = !link; + subTextEl.silent = !sublink; + + if (link) { + textEl.on('click', function () { + window.open(link, titleModel.get('target')); + }); + } + if (sublink) { + subTextEl.on('click', function () { + window.open(sublink, titleModel.get('subtarget')); + }); + } + + group.add(textEl); + subText && group.add(subTextEl); + // If no subText, but add subTextEl, there will be an empty line. + + var groupRect = group.getBoundingRect(); + var layoutOption = titleModel.getBoxLayoutParams(); + layoutOption.width = groupRect.width; + layoutOption.height = groupRect.height; + var layoutRect = layout.getLayoutRect( + layoutOption, { + width: api.getWidth(), + height: api.getHeight() + }, titleModel.get('padding') + ); + // Adjust text align based on position + if (!textAlign) { + // Align left if title is on the left. center and right is same + textAlign = titleModel.get('left') || titleModel.get('right'); + if (textAlign === 'middle') { + textAlign = 'center'; + } + // Adjust layout by text align + if (textAlign === 'right') { + layoutRect.x += layoutRect.width; + } + else if (textAlign === 'center') { + layoutRect.x += layoutRect.width / 2; + } + } + group.position = [layoutRect.x, layoutRect.y]; + textEl.setStyle('textAlign', textAlign); + subTextEl.setStyle('textAlign', textAlign); + + // Render background + // Get groupRect again because textAlign has been changed + groupRect = group.getBoundingRect(); + var padding = layoutRect.margin; + var style = titleModel.getItemStyle(['color', 'opacity']); + style.fill = titleModel.get('backgroundColor'); + var rect = new graphic.Rect({ + shape: { + x: groupRect.x - padding[3], + y: groupRect.y - padding[0], + width: groupRect.width + padding[1] + padding[3], + height: groupRect.height + padding[0] + padding[2] + }, + style: style, + silent: true + }); + graphic.subPixelOptimizeRect(rect); + + group.add(rect); + } + }); + + +/***/ }, +/* 286 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * DataZoom component entry + */ + + + __webpack_require__(287); + + __webpack_require__(288); + __webpack_require__(290); + + __webpack_require__(291); + __webpack_require__(292); + + __webpack_require__(295); + __webpack_require__(296); + + __webpack_require__(298); + __webpack_require__(299); + + + +/***/ }, +/* 287 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(19).registerSubTypeDefaulter('dataZoom', function (option) { + // Default 'slider' when no type specified. + return 'slider'; + }); + + + +/***/ }, +/* 288 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Data zoom model + */ + + + var zrUtil = __webpack_require__(3); + var env = __webpack_require__(78); + var echarts = __webpack_require__(1); + var modelUtil = __webpack_require__(5); + var AxisProxy = __webpack_require__(289); + var each = zrUtil.each; + var eachAxisDim = modelUtil.eachAxisDim; + + var DataZoomModel = echarts.extendComponentModel({ + + type: 'dataZoom', + + dependencies: [ + 'xAxis', 'yAxis', 'zAxis', 'radiusAxis', 'angleAxis', 'series' + ], + + /** + * @protected + */ + defaultOption: { + zlevel: 0, + z: 4, // Higher than normal component (z: 2). + orient: null, // Default auto by axisIndex. Possible value: 'horizontal', 'vertical'. + xAxisIndex: null, // Default all horizontal category axis. + yAxisIndex: null, // Default all vertical category axis. + angleAxisIndex: null, + radiusAxisIndex: null, + filterMode: 'filter', // Possible values: 'filter' or 'empty'. + // 'filter': data items which are out of window will be removed. + // This option is applicable when filtering outliers. + // 'empty': data items which are out of window will be set to empty. + // This option is applicable when user should not neglect + // that there are some data items out of window. + // Taking line chart as an example, line will be broken in + // the filtered points when filterModel is set to 'empty', but + // be connected when set to 'filter'. + + throttle: 100, // Dispatch action by the fixed rate, avoid frequency. + // default 100. Do not throttle when use null/undefined. + start: 0, // Start percent. 0 ~ 100 + end: 100, // End percent. 0 ~ 100 + startValue: null, // Start value. If startValue specified, start is ignored. + endValue: null // End value. If endValue specified, end is ignored. + }, -}); -define('echarts/chart/candlestick/CandlestickView',['require','zrender/core/util','../../view/Chart','../../util/graphic','../helper/whiskerBoxCommon'],function(require) { + /** + * @override + */ + init: function (option, parentModel, ecModel) { + + /** + * key like x_0, y_1 + * @private + * @type {Object} + */ + this._dataIntervalByAxis = {}; + + /** + * @private + */ + this._dataInfo = {}; + + /** + * key like x_0, y_1 + * @private + */ + this._axisProxies = {}; + + /** + * @readOnly + */ + this.textStyleModel; + + var rawOption = retrieveRaw(option); + + this.mergeDefaultAndTheme(option, ecModel); + + this.doInit(rawOption); + }, + + /** + * @override + */ + mergeOption: function (newOption) { + var rawOption = retrieveRaw(newOption); + + //FIX #2591 + zrUtil.merge(this.option, newOption, true); + + this.doInit(rawOption); + }, + + /** + * @protected + */ + doInit: function (rawOption) { + var thisOption = this.option; + + // Disable realtime view update if canvas is not supported. + if (!env.canvasSupported) { + thisOption.realtime = false; + } + + processRangeProp('start', 'startValue', rawOption, thisOption); + processRangeProp('end', 'endValue', rawOption, thisOption); + + this.textStyleModel = this.getModel('textStyle'); + + this._resetTarget(); + + this._giveAxisProxies(); + }, + + /** + * @private + */ + _giveAxisProxies: function () { + var axisProxies = this._axisProxies; + + this.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel, ecModel) { + var axisModel = this.dependentModels[dimNames.axis][axisIndex]; + + // If exists, share axisProxy with other dataZoomModels. + var axisProxy = axisModel.__dzAxisProxy || ( + // Use the first dataZoomModel as the main model of axisProxy. + axisModel.__dzAxisProxy = new AxisProxy( + dimNames.name, axisIndex, this, ecModel + ) + ); + // FIXME + // dispose __dzAxisProxy + + axisProxies[dimNames.name + '_' + axisIndex] = axisProxy; + }, this); + }, + + /** + * @private + */ + _resetTarget: function () { + var thisOption = this.option; + + var autoMode = this._judgeAutoMode(); + + eachAxisDim(function (dimNames) { + var axisIndexName = dimNames.axisIndex; + thisOption[axisIndexName] = modelUtil.normalizeToArray( + thisOption[axisIndexName] + ); + }, this); + + if (autoMode === 'axisIndex') { + this._autoSetAxisIndex(); + } + else if (autoMode === 'orient') { + this._autoSetOrient(); + } + }, + + /** + * @private + */ + _judgeAutoMode: function () { + // Auto set only works for setOption at the first time. + // The following is user's reponsibility. So using merged + // option is OK. + var thisOption = this.option; + + var hasIndexSpecified = false; + eachAxisDim(function (dimNames) { + // When user set axisIndex as a empty array, we think that user specify axisIndex + // but do not want use auto mode. Because empty array may be encountered when + // some error occured. + if (thisOption[dimNames.axisIndex] != null) { + hasIndexSpecified = true; + } + }, this); + + var orient = thisOption.orient; + + if (orient == null && hasIndexSpecified) { + return 'orient'; + } + else if (!hasIndexSpecified) { + if (orient == null) { + thisOption.orient = 'horizontal'; + } + return 'axisIndex'; + } + }, + + /** + * @private + */ + _autoSetAxisIndex: function () { + var autoAxisIndex = true; + var orient = this.get('orient', true); + var thisOption = this.option; + + if (autoAxisIndex) { + // Find axis that parallel to dataZoom as default. + var dimNames = orient === 'vertical' + ? {dim: 'y', axisIndex: 'yAxisIndex', axis: 'yAxis'} + : {dim: 'x', axisIndex: 'xAxisIndex', axis: 'xAxis'}; + + if (this.dependentModels[dimNames.axis].length) { + thisOption[dimNames.axisIndex] = [0]; + autoAxisIndex = false; + } + } + + if (autoAxisIndex) { + // Find the first category axis as default. (consider polar) + eachAxisDim(function (dimNames) { + if (!autoAxisIndex) { + return; + } + var axisIndices = []; + var axisModels = this.dependentModels[dimNames.axis]; + if (axisModels.length && !axisIndices.length) { + for (var i = 0, len = axisModels.length; i < len; i++) { + if (axisModels[i].get('type') === 'category') { + axisIndices.push(i); + } + } + } + thisOption[dimNames.axisIndex] = axisIndices; + if (axisIndices.length) { + autoAxisIndex = false; + } + }, this); + } + + if (autoAxisIndex) { + // FIXME + // 这里是兼容ec2的写法(没指定xAxisIndex和yAxisIndex时把scatter和双数值轴折柱纳入dataZoom控制), + // 但是实际是否需要Grid.js#getScaleByOption来判断(考虑time,log等axis type)? + + // If both dataZoom.xAxisIndex and dataZoom.yAxisIndex is not specified, + // dataZoom component auto adopts series that reference to + // both xAxis and yAxis which type is 'value'. + this.ecModel.eachSeries(function (seriesModel) { + if (this._isSeriesHasAllAxesTypeOf(seriesModel, 'value')) { + eachAxisDim(function (dimNames) { + var axisIndices = thisOption[dimNames.axisIndex]; + var axisIndex = seriesModel.get(dimNames.axisIndex); + if (zrUtil.indexOf(axisIndices, axisIndex) < 0) { + axisIndices.push(axisIndex); + } + }); + } + }, this); + } + }, + + /** + * @private + */ + _autoSetOrient: function () { + var dim; + + // Find the first axis + this.eachTargetAxis(function (dimNames) { + !dim && (dim = dimNames.name); + }, this); + + this.option.orient = dim === 'y' ? 'vertical' : 'horizontal'; + }, + + /** + * @private + */ + _isSeriesHasAllAxesTypeOf: function (seriesModel, axisType) { + // FIXME + // 需要series的xAxisIndex和yAxisIndex都首先自动设置上。 + // 例如series.type === scatter时。 + + var is = true; + eachAxisDim(function (dimNames) { + var seriesAxisIndex = seriesModel.get(dimNames.axisIndex); + var axisModel = this.dependentModels[dimNames.axis][seriesAxisIndex]; + + if (!axisModel || axisModel.get('type') !== axisType) { + is = false; + } + }, this); + return is; + }, + + /** + * @public + */ + getFirstTargetAxisModel: function () { + var firstAxisModel; + eachAxisDim(function (dimNames) { + if (firstAxisModel == null) { + var indices = this.get(dimNames.axisIndex); + if (indices.length) { + firstAxisModel = this.dependentModels[dimNames.axis][indices[0]]; + } + } + }, this); + + return firstAxisModel; + }, + + /** + * @public + * @param {Function} callback param: axisModel, dimNames, axisIndex, dataZoomModel, ecModel + */ + eachTargetAxis: function (callback, context) { + var ecModel = this.ecModel; + eachAxisDim(function (dimNames) { + each( + this.get(dimNames.axisIndex), + function (axisIndex) { + callback.call(context, dimNames, axisIndex, this, ecModel); + }, + this + ); + }, this); + }, + + getAxisProxy: function (dimName, axisIndex) { + return this._axisProxies[dimName + '_' + axisIndex]; + }, + + /** + * If not specified, set to undefined. + * + * @public + * @param {Object} opt + * @param {number} [opt.start] + * @param {number} [opt.end] + * @param {number} [opt.startValue] + * @param {number} [opt.endValue] + */ + setRawRange: function (opt) { + each(['start', 'end', 'startValue', 'endValue'], function (name) { + // If any of those prop is null/undefined, we should alos set + // them, because only one pair between start/end and + // startValue/endValue can work. + this.option[name] = opt[name]; + }, this); + }, + + /** + * @public + * @return {Array.} [startPercent, endPercent] + */ + getPercentRange: function () { + var axisProxy = this.findRepresentativeAxisProxy(); + if (axisProxy) { + return axisProxy.getDataPercentWindow(); + } + }, + + /** + * @public + * For example, chart.getModel().getComponent('dataZoom').getValueRange('y', 0); + * + * @param {string} [axisDimName] + * @param {number} [axisIndex] + * @return {Array.} [startValue, endValue] + */ + getValueRange: function (axisDimName, axisIndex) { + if (axisDimName == null && axisIndex == null) { + var axisProxy = this.findRepresentativeAxisProxy(); + if (axisProxy) { + return axisProxy.getDataValueWindow(); + } + } + else { + return this.getAxisProxy(axisDimName, axisIndex).getDataValueWindow(); + } + }, + + /** + * @public + * @return {module:echarts/component/dataZoom/AxisProxy} + */ + findRepresentativeAxisProxy: function () { + // Find the first hosted axisProxy + var axisProxies = this._axisProxies; + for (var key in axisProxies) { + if (axisProxies.hasOwnProperty(key) && axisProxies[key].hostedBy(this)) { + return axisProxies[key]; + } + } + + // If no hosted axis find not hosted axisProxy. + // Consider this case: dataZoomModel1 and dataZoomModel2 control the same axis, + // and the option.start or option.end settings are different. The percentRange + // should follow axisProxy. + // (We encounter this problem in toolbox data zoom.) + for (var key in axisProxies) { + if (axisProxies.hasOwnProperty(key) && !axisProxies[key].hostedBy(this)) { + return axisProxies[key]; + } + } + } + + }); + + function retrieveRaw(option) { + var ret = {}; + each( + ['start', 'end', 'startValue', 'endValue'], + function (name) { + ret[name] = option[name]; + } + ); + return ret; + } + + function processRangeProp(percentProp, valueProp, rawOption, thisOption) { + // start/end has higher priority over startValue/endValue, + // but we should make chart.setOption({endValue: 1000}) effective, + // rather than chart.setOption({endValue: 1000, end: null}). + if (rawOption[valueProp] != null && rawOption[percentProp] == null) { + thisOption[percentProp] = null; + } + // Otherwise do nothing and use the merge result. + } + + module.exports = DataZoomModel; + + + +/***/ }, +/* 289 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Axis operator + */ + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var each = zrUtil.each; + var asc = numberUtil.asc; + + /** + * Operate single axis. + * One axis can only operated by one axis operator. + * Different dataZoomModels may be defined to operate the same axis. + * (i.e. 'inside' data zoom and 'slider' data zoom components) + * So dataZoomModels share one axisProxy in that case. + * + * @class + */ + var AxisProxy = function (dimName, axisIndex, dataZoomModel, ecModel) { + + /** + * @private + * @type {string} + */ + this._dimName = dimName; + + /** + * @private + */ + this._axisIndex = axisIndex; + + /** + * @private + * @type {Array.} + */ + this._valueWindow; + + /** + * @private + * @type {Array.} + */ + this._percentWindow; + + /** + * @private + * @type {Array.} + */ + this._dataExtent; + + /** + * @readOnly + * @type {module: echarts/model/Global} + */ + this.ecModel = ecModel; + + /** + * @private + * @type {module: echarts/component/dataZoom/DataZoomModel} + */ + this._dataZoomModel = dataZoomModel; + }; + + AxisProxy.prototype = { + + constructor: AxisProxy, + + /** + * Whether the axisProxy is hosted by dataZoomModel. + * + * @public + * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel + * @return {boolean} + */ + hostedBy: function (dataZoomModel) { + return this._dataZoomModel === dataZoomModel; + }, + + /** + * @return {Array.} + */ + getDataExtent: function () { + return this._dataExtent.slice(); + }, + + /** + * @return {Array.} + */ + getDataValueWindow: function () { + return this._valueWindow.slice(); + }, + + /** + * @return {Array.} + */ + getDataPercentWindow: function () { + return this._percentWindow.slice(); + }, + + /** + * @public + * @param {number} axisIndex + * @return {Array} seriesModels + */ + getTargetSeriesModels: function () { + var seriesModels = []; + + this.ecModel.eachSeries(function (seriesModel) { + if (this._axisIndex === seriesModel.get(this._dimName + 'AxisIndex')) { + seriesModels.push(seriesModel); + } + }, this); + + return seriesModels; + }, + + getAxisModel: function () { + return this.ecModel.getComponent(this._dimName + 'Axis', this._axisIndex); + }, + + getOtherAxisModel: function () { + var axisDim = this._dimName; + var ecModel = this.ecModel; + var axisModel = this.getAxisModel(); + var isCartesian = axisDim === 'x' || axisDim === 'y'; + var otherAxisDim; + var coordSysIndexName; + if (isCartesian) { + coordSysIndexName = 'gridIndex'; + otherAxisDim = axisDim === 'x' ? 'y' : 'x'; + } + else { + coordSysIndexName = 'polarIndex'; + otherAxisDim = axisDim === 'angle' ? 'radius' : 'angle'; + } + var foundOtherAxisModel; + ecModel.eachComponent(otherAxisDim + 'Axis', function (otherAxisModel) { + if ((otherAxisModel.get(coordSysIndexName) || 0) + === (axisModel.get(coordSysIndexName) || 0)) { + foundOtherAxisModel = otherAxisModel; + } + }); + return foundOtherAxisModel; + }, + + /** + * Notice: reset should not be called before series.restoreData() called, + * so it is recommanded to be called in "process stage" but not "model init + * stage". + * + * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel + */ + reset: function (dataZoomModel) { + if (dataZoomModel !== this._dataZoomModel) { + return; + } + + // Culculate data window and data extent, and record them. + var dataExtent = this._dataExtent = calculateDataExtent( + this._dimName, this.getTargetSeriesModels() + ); + var dataWindow = calculateDataWindow( + dataZoomModel.option, dataExtent, this + ); + this._valueWindow = dataWindow.valueWindow; + this._percentWindow = dataWindow.percentWindow; + + // Update axis setting then. + setAxisModel(this); + }, + + /** + * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel + */ + restore: function (dataZoomModel) { + if (dataZoomModel !== this._dataZoomModel) { + return; + } + + this._valueWindow = this._percentWindow = null; + setAxisModel(this, true); + }, + + /** + * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel + */ + filterData: function (dataZoomModel) { + if (dataZoomModel !== this._dataZoomModel) { + return; + } + + var axisDim = this._dimName; + var seriesModels = this.getTargetSeriesModels(); + var filterMode = dataZoomModel.get('filterMode'); + var valueWindow = this._valueWindow; + + // FIXME + // Toolbox may has dataZoom injected. And if there are stacked bar chart + // with NaN data. NaN will be filtered and stack will be wrong. + // So we need to force the mode to be set empty + var otherAxisModel = this.getOtherAxisModel(); + if (dataZoomModel.get('$fromToolbox') + && otherAxisModel && otherAxisModel.get('type') === 'category') { + filterMode = 'empty'; + } + // Process series data + each(seriesModels, function (seriesModel) { + var seriesData = seriesModel.getData(); + if (!seriesData) { + return; + } + + each(seriesModel.coordDimToDataDim(axisDim), function (dim) { + if (filterMode === 'empty') { + seriesModel.setData( + seriesData.map(dim, function (value) { + return !isInWindow(value) ? NaN : value; + }) + ); + } + else { + seriesData.filterSelf(dim, isInWindow); + } + }); + }); + + function isInWindow(value) { + return value >= valueWindow[0] && value <= valueWindow[1]; + } + } + }; + + function calculateDataExtent(axisDim, seriesModels) { + var dataExtent = [Infinity, -Infinity]; + + each(seriesModels, function (seriesModel) { + var seriesData = seriesModel.getData(); + if (seriesData) { + each(seriesModel.coordDimToDataDim(axisDim), function (dim) { + var seriesExtent = seriesData.getDataExtent(dim); + seriesExtent[0] < dataExtent[0] && (dataExtent[0] = seriesExtent[0]); + seriesExtent[1] > dataExtent[1] && (dataExtent[1] = seriesExtent[1]); + }); + } + }, this); + + return dataExtent; + } + + function calculateDataWindow(opt, dataExtent, axisProxy) { + var axisModel = axisProxy.getAxisModel(); + var scale = axisModel.axis.scale; + var percentExtent = [0, 100]; + var percentWindow = [ + opt.start, + opt.end + ]; + var valueWindow = []; + + // In percent range is used and axis min/max/scale is set, + // window should be based on min/max/0, but should not be + // based on the extent of filtered data. + dataExtent = dataExtent.slice(); + fixExtendByAxis(dataExtent, axisModel, scale); + + each(['startValue', 'endValue'], function (prop) { + valueWindow.push( + opt[prop] != null + ? scale.parse(opt[prop]) + : null + ); + }); + + // Normalize bound. + each([0, 1], function (idx) { + var boundValue = valueWindow[idx]; + var boundPercent = percentWindow[idx]; + + // start/end has higher priority over startValue/endValue, + // because start/end can be consistent among different type + // of axis but startValue/endValue not. + + if (boundPercent != null || boundValue == null) { + if (boundPercent == null) { + boundPercent = percentExtent[idx]; + } + // Use scale.parse to math round for category or time axis. + boundValue = scale.parse(numberUtil.linearMap( + boundPercent, percentExtent, dataExtent, true + )); + } + else { // boundPercent == null && boundValue != null + boundPercent = numberUtil.linearMap( + boundValue, dataExtent, percentExtent, true + ); + } + // Avoid rounding error + valueWindow[idx] = numberUtil.round(boundValue); + percentWindow[idx] = numberUtil.round(boundPercent); + }); + + return { + valueWindow: asc(valueWindow), + percentWindow: asc(percentWindow) + }; + } + + function fixExtendByAxis(dataExtent, axisModel, scale) { + each(['min', 'max'], function (minMax, index) { + var axisMax = axisModel.get(minMax, true); + // Consider 'dataMin', 'dataMax' + if (axisMax != null && (axisMax + '').toLowerCase() !== 'data' + minMax) { + dataExtent[index] = scale.parse(axisMax); + } + }); + + if (!axisModel.get('scale', true)) { + dataExtent[0] > 0 && (dataExtent[0] = 0); + dataExtent[1] < 0 && (dataExtent[1] = 0); + } + + return dataExtent; + } + + function setAxisModel(axisProxy, isRestore) { + var axisModel = axisProxy.getAxisModel(); + + var percentWindow = axisProxy._percentWindow; + var valueWindow = axisProxy._valueWindow; + + if (!percentWindow) { + return; + } + + var isFull = isRestore || (percentWindow[0] === 0 && percentWindow[1] === 100); + // [0, 500]: arbitrary value, guess axis extent. + var precision = !isRestore && numberUtil.getPixelPrecision(valueWindow, [0, 500]); + // toFixed() digits argument must be between 0 and 20 + var invalidPrecision = !isRestore && !(precision < 20 && precision >= 0); + + var useOrigin = isRestore || isFull || invalidPrecision; + + axisModel.setRange && axisModel.setRange( + useOrigin ? null : +valueWindow[0].toFixed(precision), + useOrigin ? null : +valueWindow[1].toFixed(precision) + ); + } + + module.exports = AxisProxy; + + + +/***/ }, +/* 290 */ +/***/ function(module, exports, __webpack_require__) { + + + + var ComponentView = __webpack_require__(28); + + module.exports = ComponentView.extend({ + + type: 'dataZoom', + + render: function (dataZoomModel, ecModel, api, payload) { + this.dataZoomModel = dataZoomModel; + this.ecModel = ecModel; + this.api = api; + }, + + /** + * Find the first target coordinate system. + * + * @protected + * @return {Object} { + * cartesians: [ + * {model: coord0, axisModels: [axis1, axis3], coordIndex: 1}, + * {model: coord1, axisModels: [axis0, axis2], coordIndex: 0}, + * ... + * ], // cartesians must not be null/undefined. + * polars: [ + * {model: coord0, axisModels: [axis4], coordIndex: 0}, + * ... + * ], // polars must not be null/undefined. + * axisModels: [axis0, axis1, axis2, axis3, axis4] + * // axisModels must not be null/undefined. + * } + */ + getTargetInfo: function () { + var dataZoomModel = this.dataZoomModel; + var ecModel = this.ecModel; + var cartesians = []; + var polars = []; + var axisModels = []; + + dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) { + var axisModel = ecModel.getComponent(dimNames.axis, axisIndex); + if (axisModel) { + axisModels.push(axisModel); + + var gridIndex = axisModel.get('gridIndex'); + var polarIndex = axisModel.get('polarIndex'); + + if (gridIndex != null) { + var coordModel = ecModel.getComponent('grid', gridIndex); + save(coordModel, axisModel, cartesians, gridIndex); + } + else if (polarIndex != null) { + var coordModel = ecModel.getComponent('polar', polarIndex); + save(coordModel, axisModel, polars, polarIndex); + } + } + }, this); + + function save(coordModel, axisModel, store, coordIndex) { + var item; + for (var i = 0; i < store.length; i++) { + if (store[i].model === coordModel) { + item = store[i]; + break; + } + } + if (!item) { + store.push(item = { + model: coordModel, axisModels: [], coordIndex: coordIndex + }); + } + item.axisModels.push(axisModel); + } + + return { + cartesians: cartesians, + polars: polars, + axisModels: axisModels + }; + } + + }); + + + +/***/ }, +/* 291 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Data zoom model + */ + + + var DataZoomModel = __webpack_require__(288); + var layout = __webpack_require__(21); + var zrUtil = __webpack_require__(3); + + var SliderZoomModel = DataZoomModel.extend({ + + type: 'dataZoom.slider', + + layoutMode: 'box', + + /** + * @protected + */ + defaultOption: { + show: true, + + // ph => placeholder. Using placehoder here because + // deault value can only be drived in view stage. + right: 'ph', // Default align to grid rect. + top: 'ph', // Default align to grid rect. + width: 'ph', // Default align to grid rect. + height: 'ph', // Default align to grid rect. + left: null, // Default align to grid rect. + bottom: null, // Default align to grid rect. + + backgroundColor: 'rgba(47,69,84,0)', // Background of slider zoom component. + dataBackgroundColor: '#ddd', // Background of data shadow. + fillerColor: 'rgba(47,69,84,0.25)', // Color of selected area. + handleColor: 'rgba(47,69,84,0.65)', // Color of handle. + handleSize: 10, + + labelPrecision: null, + labelFormatter: null, + showDetail: true, + showDataShadow: 'auto', // Default auto decision. + realtime: true, + zoomLock: false, // Whether disable zoom. + textStyle: { + color: '#333' + } + }, + + /** + * @public + */ + setDefaultLayoutParams: function (params) { + var option = this.option; + zrUtil.each(['right', 'top', 'width', 'height'], function (name) { + if (option[name] === 'ph') { + option[name] = params[name]; + }; + }); + }, + + /** + * @override + */ + mergeOption: function (option) { + SliderZoomModel.superApply(this, 'mergeOption', arguments); + } + + }); + + module.exports = SliderZoomModel; + + + +/***/ }, +/* 292 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var throttle = __webpack_require__(293); + var DataZoomView = __webpack_require__(290); + var Rect = graphic.Rect; + var numberUtil = __webpack_require__(7); + var linearMap = numberUtil.linearMap; + var layout = __webpack_require__(21); + var sliderMove = __webpack_require__(294); + var asc = numberUtil.asc; + var bind = zrUtil.bind; + var mathRound = Math.round; + var mathMax = Math.max; + var each = zrUtil.each; + + // Constants + var DEFAULT_LOCATION_EDGE_GAP = 7; + var DEFAULT_FRAME_BORDER_WIDTH = 1; + var DEFAULT_FILLER_SIZE = 30; + var HORIZONTAL = 'horizontal'; + var VERTICAL = 'vertical'; + var LABEL_GAP = 5; + var SHOW_DATA_SHADOW_SERIES_TYPE = ['line', 'bar', 'candlestick', 'scatter']; + + var SliderZoomView = DataZoomView.extend({ + + type: 'dataZoom.slider', + + init: function (ecModel, api) { + + /** + * @private + * @type {Object} + */ + this._displayables = {}; + + /** + * @private + * @type {string} + */ + this._orient; + + /** + * [0, 100] + * @private + */ + this._range; + + /** + * [coord of the first handle, coord of the second handle] + * @private + */ + this._handleEnds; + + /** + * [length, thick] + * @private + * @type {Array.} + */ + this._size; + + /** + * @private + * @type {number} + */ + this._halfHandleSize; + + /** + * @private + */ + this._location; + + /** + * @private + */ + this._dragging; + + /** + * @private + */ + this._dataShadowInfo; + + this.api = api; + }, + + /** + * @override + */ + render: function (dataZoomModel, ecModel, api, payload) { + SliderZoomView.superApply(this, 'render', arguments); + + throttle.createOrUpdate( + this, + '_dispatchZoomAction', + this.dataZoomModel.get('throttle'), + 'fixRate' + ); + + this._orient = dataZoomModel.get('orient'); + this._halfHandleSize = mathRound(dataZoomModel.get('handleSize') / 2); + + if (this.dataZoomModel.get('show') === false) { + this.group.removeAll(); + return; + } + + // Notice: this._resetInterval() should not be executed when payload.type + // is 'dataZoom', origin this._range should be maintained, otherwise 'pan' + // or 'zoom' info will be missed because of 'throttle' of this.dispatchAction, + if (!payload || payload.type !== 'dataZoom' || payload.from !== this.uid) { + this._buildView(); + } + + this._updateView(); + }, + + /** + * @override + */ + remove: function () { + SliderZoomView.superApply(this, 'remove', arguments); + throttle.clear(this, '_dispatchZoomAction'); + }, + + /** + * @override + */ + dispose: function () { + SliderZoomView.superApply(this, 'dispose', arguments); + throttle.clear(this, '_dispatchZoomAction'); + }, + + _buildView: function () { + var thisGroup = this.group; + + thisGroup.removeAll(); + + this._resetLocation(); + this._resetInterval(); + + var barGroup = this._displayables.barGroup = new graphic.Group(); + + this._renderBackground(); + this._renderDataShadow(); + this._renderHandle(); + + thisGroup.add(barGroup); + + this._positionGroup(); + }, + + /** + * @private + */ + _resetLocation: function () { + var dataZoomModel = this.dataZoomModel; + var api = this.api; + + // If some of x/y/width/height are not specified, + // auto-adapt according to target grid. + var coordRect = this._findCoordRect(); + var ecSize = {width: api.getWidth(), height: api.getHeight()}; + + // Default align by coordinate system rect. + var positionInfo = this._orient === HORIZONTAL + ? { + // Why using 'right', because right should be used in vertical, + // and it is better to be consistent for dealing with position param merge. + right: ecSize.width - coordRect.x - coordRect.width, + top: (ecSize.height - DEFAULT_FILLER_SIZE - DEFAULT_LOCATION_EDGE_GAP), + width: coordRect.width, + height: DEFAULT_FILLER_SIZE + } + : { // vertical + right: DEFAULT_LOCATION_EDGE_GAP, + top: coordRect.y, + width: DEFAULT_FILLER_SIZE, + height: coordRect.height + }; + + // Write back to option for chart.getOption(). (and may then + // chart.setOption() again, where current location value is needed); + // dataZoomModel.setLayoutParams(positionInfo); + dataZoomModel.setDefaultLayoutParams(positionInfo); + + var layoutRect = layout.getLayoutRect( + dataZoomModel.option, + ecSize, + dataZoomModel.padding + ); + + this._location = {x: layoutRect.x, y: layoutRect.y}; + this._size = [layoutRect.width, layoutRect.height]; + this._orient === VERTICAL && this._size.reverse(); + }, + + /** + * @private + */ + _positionGroup: function () { + var thisGroup = this.group; + var location = this._location; + var orient = this._orient; + + // Just use the first axis to determine mapping. + var targetAxisModel = this.dataZoomModel.getFirstTargetAxisModel(); + var inverse = targetAxisModel && targetAxisModel.get('inverse'); + + var barGroup = this._displayables.barGroup; + var otherAxisInverse = (this._dataShadowInfo || {}).otherAxisInverse; + + // Transform barGroup. + barGroup.attr( + (orient === HORIZONTAL && !inverse) + ? {scale: otherAxisInverse ? [1, 1] : [1, -1]} + : (orient === HORIZONTAL && inverse) + ? {scale: otherAxisInverse ? [-1, 1] : [-1, -1]} + : (orient === VERTICAL && !inverse) + ? {scale: otherAxisInverse ? [1, -1] : [1, 1], rotation: Math.PI / 2} + // Dont use Math.PI, considering shadow direction. + : {scale: otherAxisInverse ? [-1, -1] : [-1, 1], rotation: Math.PI / 2} + ); + + // Position barGroup + var rect = thisGroup.getBoundingRect([barGroup]); + thisGroup.position[0] = location.x - rect.x; + thisGroup.position[1] = location.y - rect.y; + }, + + /** + * @private + */ + _getViewExtent: function () { + // View total length. + var halfHandleSize = this._halfHandleSize; + var totalLength = mathMax(this._size[0], halfHandleSize * 4); + var extent = [halfHandleSize, totalLength - halfHandleSize]; + + return extent; + }, + + _renderBackground : function () { + var dataZoomModel = this.dataZoomModel; + var size = this._size; + + this._displayables.barGroup.add(new Rect({ + silent: true, + shape: { + x: 0, y: 0, width: size[0], height: size[1] + }, + style: { + fill: dataZoomModel.get('backgroundColor') + } + })); + }, + + _renderDataShadow: function () { + var info = this._dataShadowInfo = this._prepareDataShadowInfo(); + + if (!info) { + return; + } + + var size = this._size; + var seriesModel = info.series; + var data = seriesModel.getRawData(); + var otherDim = seriesModel.getShadowDim + ? seriesModel.getShadowDim() // @see candlestick + : info.otherDim; + + var otherDataExtent = data.getDataExtent(otherDim); + // Nice extent. + var otherOffset = (otherDataExtent[1] - otherDataExtent[0]) * 0.3; + otherDataExtent = [ + otherDataExtent[0] - otherOffset, + otherDataExtent[1] + otherOffset + ]; + var otherShadowExtent = [0, size[1]]; + + var thisShadowExtent = [0, size[0]]; + + var points = [[size[0], 0], [0, 0]]; + var step = thisShadowExtent[1] / (data.count() - 1); + var thisCoord = 0; + + // Optimize for large data shadow + var stride = Math.round(data.count() / size[0]); + data.each([otherDim], function (value, index) { + if (stride > 0 && (index % stride)) { + thisCoord += step; + return; + } + // FIXME + // 应该使用统计的空判断?还是在list里进行空判断? + var otherCoord = (value == null || isNaN(value) || value === '') + ? null + : linearMap(value, otherDataExtent, otherShadowExtent, true); + otherCoord != null && points.push([thisCoord, otherCoord]); + + thisCoord += step; + }); + + this._displayables.barGroup.add(new graphic.Polyline({ + shape: {points: points}, + style: {fill: this.dataZoomModel.get('dataBackgroundColor'), lineWidth: 0}, + silent: true, + z2: -20 + })); + }, + + _prepareDataShadowInfo: function () { + var dataZoomModel = this.dataZoomModel; + var showDataShadow = dataZoomModel.get('showDataShadow'); + + if (showDataShadow === false) { + return; + } + + // Find a representative series. + var result; + var ecModel = this.ecModel; + + dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) { + var seriesModels = dataZoomModel + .getAxisProxy(dimNames.name, axisIndex) + .getTargetSeriesModels(); + + zrUtil.each(seriesModels, function (seriesModel) { + if (result) { + return; + } + + if (showDataShadow !== true && zrUtil.indexOf( + SHOW_DATA_SHADOW_SERIES_TYPE, seriesModel.get('type') + ) < 0 + ) { + return; + } + + var otherDim = getOtherDim(dimNames.name); + + var thisAxis = ecModel.getComponent(dimNames.axis, axisIndex).axis; + + result = { + thisAxis: thisAxis, + series: seriesModel, + thisDim: dimNames.name, + otherDim: otherDim, + otherAxisInverse: seriesModel + .coordinateSystem.getOtherAxis(thisAxis).inverse + }; + + }, this); + + }, this); + + return result; + }, + + _renderHandle: function () { + var displaybles = this._displayables; + var handles = displaybles.handles = []; + var handleLabels = displaybles.handleLabels = []; + var barGroup = this._displayables.barGroup; + var size = this._size; + + barGroup.add(displaybles.filler = new Rect({ + draggable: true, + cursor: 'move', + drift: bind(this._onDragMove, this, 'all'), + ondragend: bind(this._onDragEnd, this), + onmouseover: bind(this._showDataInfo, this, true), + onmouseout: bind(this._showDataInfo, this, false), + style: { + fill: this.dataZoomModel.get('fillerColor'), + // text: ':::', + textPosition : 'inside' + } + })); + + // Frame border. + barGroup.add(new Rect(graphic.subPixelOptimizeRect({ + silent: true, + shape: { + x: 0, + y: 0, + width: size[0], + height: size[1] + }, + style: { + stroke: this.dataZoomModel.get('dataBackgroundColor'), + lineWidth: DEFAULT_FRAME_BORDER_WIDTH, + fill: 'rgba(0,0,0,0)' + } + }))); + + each([0, 1], function (handleIndex) { + + barGroup.add(handles[handleIndex] = new Rect({ + style: { + fill: this.dataZoomModel.get('handleColor') + }, + cursor: 'move', + draggable: true, + drift: bind(this._onDragMove, this, handleIndex), + ondragend: bind(this._onDragEnd, this), + onmouseover: bind(this._showDataInfo, this, true), + onmouseout: bind(this._showDataInfo, this, false) + })); + + var textStyleModel = this.dataZoomModel.textStyleModel; + + this.group.add( + handleLabels[handleIndex] = new graphic.Text({ + silent: true, + invisible: true, + style: { + x: 0, y: 0, text: '', + textVerticalAlign: 'middle', + textAlign: 'center', + fill: textStyleModel.getTextColor(), + textFont: textStyleModel.getFont() + } + })); + + }, this); + }, + + /** + * @private + */ + _resetInterval: function () { + var range = this._range = this.dataZoomModel.getPercentRange(); + var viewExtent = this._getViewExtent(); + + this._handleEnds = [ + linearMap(range[0], [0, 100], viewExtent, true), + linearMap(range[1], [0, 100], viewExtent, true) + ]; + }, + + /** + * @private + * @param {(number|string)} handleIndex 0 or 1 or 'all' + * @param {number} dx + * @param {number} dy + */ + _updateInterval: function (handleIndex, delta) { + var handleEnds = this._handleEnds; + var viewExtend = this._getViewExtent(); + + sliderMove( + delta, + handleEnds, + viewExtend, + (handleIndex === 'all' || this.dataZoomModel.get('zoomLock')) + ? 'rigid' : 'cross', + handleIndex + ); + + this._range = asc([ + linearMap(handleEnds[0], viewExtend, [0, 100], true), + linearMap(handleEnds[1], viewExtend, [0, 100], true) + ]); + }, + + /** + * @private + */ + _updateView: function () { + var displaybles = this._displayables; + var handleEnds = this._handleEnds; + var handleInterval = asc(handleEnds.slice()); + var size = this._size; + var halfHandleSize = this._halfHandleSize; + + each([0, 1], function (handleIndex) { + + // Handles + var handle = displaybles.handles[handleIndex]; + handle.setShape({ + x: handleEnds[handleIndex] - halfHandleSize, + y: -1, + width: halfHandleSize * 2, + height: size[1] + 2, + r: 1 + }); + + }, this); + + // Filler + displaybles.filler.setShape({ + x: handleInterval[0], + y: 0, + width: handleInterval[1] - handleInterval[0], + height: this._size[1] + }); + + this._updateDataInfo(); + }, + + /** + * @private + */ + _updateDataInfo: function () { + var dataZoomModel = this.dataZoomModel; + var displaybles = this._displayables; + var handleLabels = displaybles.handleLabels; + var orient = this._orient; + var labelTexts = ['', '']; + + // FIXME + // date型,支持formatter,autoformatter(ec2 date.getAutoFormatter) + if (dataZoomModel.get('showDetail')) { + var dataInterval; + var axis; + dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) { + // Using dataInterval of the first axis. + if (!dataInterval) { + dataInterval = dataZoomModel + .getAxisProxy(dimNames.name, axisIndex) + .getDataValueWindow(); + axis = this.ecModel.getComponent(dimNames.axis, axisIndex).axis; + } + }, this); + + if (dataInterval) { + labelTexts = [ + this._formatLabel(dataInterval[0], axis), + this._formatLabel(dataInterval[1], axis) + ]; + } + } + + var orderedHandleEnds = asc(this._handleEnds.slice()); + + setLabel.call(this, 0); + setLabel.call(this, 1); + + function setLabel(handleIndex) { + // Label + // Text should not transform by barGroup. + var barTransform = graphic.getTransform( + displaybles.handles[handleIndex], this.group + ); + var direction = graphic.transformDirection( + handleIndex === 0 ? 'right' : 'left', barTransform + ); + var offset = this._halfHandleSize + LABEL_GAP; + var textPoint = graphic.applyTransform( + [ + orderedHandleEnds[handleIndex] + (handleIndex === 0 ? -offset : offset), + this._size[1] / 2 + ], + barTransform + ); + handleLabels[handleIndex].setStyle({ + x: textPoint[0], + y: textPoint[1], + textVerticalAlign: orient === HORIZONTAL ? 'middle' : direction, + textAlign: orient === HORIZONTAL ? direction : 'center', + text: labelTexts[handleIndex] + }); + } + }, + + /** + * @private + */ + _formatLabel: function (value, axis) { + var dataZoomModel = this.dataZoomModel; + var labelFormatter = dataZoomModel.get('labelFormatter'); + if (zrUtil.isFunction(labelFormatter)) { + return labelFormatter(value); + } + + var labelPrecision = dataZoomModel.get('labelPrecision'); + if (labelPrecision == null || labelPrecision === 'auto') { + labelPrecision = axis.getPixelPrecision(); + } + + value = (value == null && isNaN(value)) + ? '' + // FIXME Glue code + : (axis.type === 'category' || axis.type === 'time') + ? axis.scale.getLabel(Math.round(value)) + // param of toFixed should less then 20. + : value.toFixed(Math.min(labelPrecision, 20)); + + if (zrUtil.isString(labelFormatter)) { + value = labelFormatter.replace('{value}', value); + } + + return value; + }, + + /** + * @private + * @param {boolean} showOrHide true: show, false: hide + */ + _showDataInfo: function (showOrHide) { + // Always show when drgging. + showOrHide = this._dragging || showOrHide; + + var handleLabels = this._displayables.handleLabels; + handleLabels[0].attr('invisible', !showOrHide); + handleLabels[1].attr('invisible', !showOrHide); + }, + + _onDragMove: function (handleIndex, dx, dy) { + this._dragging = true; + + // Transform dx, dy to bar coordination. + var vertex = this._applyBarTransform([dx, dy], true); + + this._updateInterval(handleIndex, vertex[0]); + this._updateView(); + + if (this.dataZoomModel.get('realtime')) { + this._dispatchZoomAction(); + } + }, + + _onDragEnd: function () { + this._dragging = false; + this._showDataInfo(false); + this._dispatchZoomAction(); + }, + + /** + * This action will be throttled. + * @private + */ + _dispatchZoomAction: function () { + var range = this._range; + + this.api.dispatchAction({ + type: 'dataZoom', + from: this.uid, + dataZoomId: this.dataZoomModel.id, + start: range[0], + end: range[1] + }); + }, + + /** + * @private + */ + _applyBarTransform: function (vertex, inverse) { + var barTransform = this._displayables.barGroup.getLocalTransform(); + return graphic.applyTransform(vertex, barTransform, inverse); + }, + + /** + * @private + */ + _findCoordRect: function () { + // Find the grid coresponding to the first axis referred by dataZoom. + var targetInfo = this.getTargetInfo(); + + // FIXME + // 判断是catesian还是polar + var rect; + if (targetInfo.cartesians.length) { + rect = targetInfo.cartesians[0].model.coordinateSystem.getRect(); + } + else { // Polar + // FIXME + // 暂时随便写的 + var width = this.api.getWidth(); + var height = this.api.getHeight(); + rect = { + x: width * 0.2, + y: height * 0.2, + width: width * 0.6, + height: height * 0.6 + }; + } + + return rect; + } + + }); + + function getOtherDim(thisDim) { + // FIXME + // 这个逻辑和getOtherAxis里一致,但是写在这里是否不好 + return thisDim === 'x' ? 'y' : 'x'; + } + + module.exports = SliderZoomView; + + + +/***/ }, +/* 293 */ +/***/ function(module, exports) { + + + + var lib = {}; + + var ORIGIN_METHOD = '\0__throttleOriginMethod'; + var RATE = '\0__throttleRate'; + + /** + * 频率控制 返回函数连续调用时,fn 执行频率限定为每多少时间执行一次 + * 例如常见效果: + * notifyWhenChangesStop + * 频繁调用时,只保证最后一次执行 + * 配成:trailing:true;debounce:true 即可 + * notifyAtFixRate + * 频繁调用时,按规律心跳执行 + * 配成:trailing:true;debounce:false 即可 + * 注意: + * 根据model更新view的时候,可以使用throttle, + * 但是根据view更新model的时候,避免使用这种延迟更新的方式。 + * 因为这可能导致model和server同步出现问题。 + * + * @public + * @param {(Function|Array.)} fn 需要调用的函数 + * 如果fn为array,则表示可以对多个函数进行throttle。 + * 他们共享同一个timer。 + * @param {number} delay 延迟时间,单位毫秒 + * @param {bool} trailing 是否保证最后一次触发的执行 + * true:表示保证最后一次调用会触发执行。 + * 但任何调用后不可能立即执行,总会delay。 + * false:表示不保证最后一次调用会触发执行。 + * 但只要间隔大于delay,调用就会立即执行。 + * @param {bool} debounce 节流 + * true:表示:频繁调用(间隔小于delay)时,根本不执行 + * false:表示:频繁调用(间隔小于delay)时,按规律心跳执行 + * @return {(Function|Array.)} 实际调用函数。 + * 当输入的fn为array时,返回值也为array。 + * 每项是Function。 + */ + lib.throttle = function (fn, delay, trailing, debounce) { + + var currCall = (new Date()).getTime(); + var lastCall = 0; + var lastExec = 0; + var timer = null; + var diff; + var scope; + var args; + var isSingle = typeof fn === 'function'; + delay = delay || 0; + + if (isSingle) { + return createCallback(); + } + else { + var ret = []; + for (var i = 0; i < fn.length; i++) { + ret[i] = createCallback(i); + } + return ret; + } + + function createCallback(index) { + + function exec() { + lastExec = (new Date()).getTime(); + timer = null; + (isSingle ? fn : fn[index]).apply(scope, args || []); + } + + var cb = function () { + currCall = (new Date()).getTime(); + scope = this; + args = arguments; + diff = currCall - (debounce ? lastCall : lastExec) - delay; + + clearTimeout(timer); + + if (debounce) { + if (trailing) { + timer = setTimeout(exec, delay); + } + else if (diff >= 0) { + exec(); + } + } + else { + if (diff >= 0) { + exec(); + } + else if (trailing) { + timer = setTimeout(exec, -diff); + } + } + + lastCall = currCall; + }; + + /** + * Clear throttle. + * @public + */ + cb.clear = function () { + if (timer) { + clearTimeout(timer); + timer = null; + } + }; + + return cb; + } + }; + + /** + * 按一定频率执行,最后一次调用总归会执行 + * + * @public + */ + lib.fixRate = function (fn, delay) { + return delay != null + ? lib.throttle(fn, delay, true, false) + : fn; + }; + + /** + * 直到不频繁调用了才会执行,最后一次调用总归会执行 + * + * @public + */ + lib.debounce = function (fn, delay) { + return delay != null + ? lib.throttle(fn, delay, true, true) + : fn; + }; + + + /** + * Create throttle method or update throttle rate. + * + * @example + * ComponentView.prototype.render = function () { + * ... + * throttle.createOrUpdate( + * this, + * '_dispatchAction', + * this.model.get('throttle'), + * 'fixRate' + * ); + * }; + * ComponentView.prototype.remove = function () { + * throttle.clear(this, '_dispatchAction'); + * }; + * ComponentView.prototype.dispose = function () { + * throttle.clear(this, '_dispatchAction'); + * }; + * + * @public + * @param {Object} obj + * @param {string} fnAttr + * @param {number} rate + * @param {string} throttleType 'fixRate' or 'debounce' + */ + lib.createOrUpdate = function (obj, fnAttr, rate, throttleType) { + var fn = obj[fnAttr]; + + if (!fn || rate == null || !throttleType) { + return; + } + + var originFn = fn[ORIGIN_METHOD] || fn; + var lastRate = fn[RATE]; + + if (lastRate !== rate) { + fn = obj[fnAttr] = lib[throttleType](originFn, rate); + fn[ORIGIN_METHOD] = originFn; + fn[RATE] = rate; + } + }; + + /** + * Clear throttle. Example see throttle.createOrUpdate. + * + * @public + * @param {Object} obj + * @param {string} fnAttr + */ + lib.clear = function (obj, fnAttr) { + var fn = obj[fnAttr]; + if (fn && fn[ORIGIN_METHOD]) { + obj[fnAttr] = fn[ORIGIN_METHOD]; + } + }; + + module.exports = lib; + + + +/***/ }, +/* 294 */ +/***/ function(module, exports) { + + + + /** + * Calculate slider move result. + * + * @param {number} delta Move length. + * @param {Array.} handleEnds handleEnds[0] and be bigger then handleEnds[1]. + * handleEnds will be modified in this method. + * @param {Array.} extent handleEnds is restricted by extent. + * extent[0] should less or equals than extent[1]. + * @param {string} mode 'rigid': Math.abs(handleEnds[0] - handleEnds[1]) remain unchanged, + * 'cross' handleEnds[0] can be bigger then handleEnds[1], + * 'push' handleEnds[0] can not be bigger then handleEnds[1], + * when they touch, one push other. + * @param {number} handleIndex If mode is 'rigid', handleIndex is not required. + * @param {Array.} The input handleEnds. + */ + module.exports = function (delta, handleEnds, extent, mode, handleIndex) { + if (!delta) { + return handleEnds; + } + + if (mode === 'rigid') { + delta = getRealDelta(delta, handleEnds, extent); + handleEnds[0] += delta; + handleEnds[1] += delta; + } + else { + delta = getRealDelta(delta, handleEnds[handleIndex], extent); + handleEnds[handleIndex] += delta; + + if (mode === 'push' && handleEnds[0] > handleEnds[1]) { + handleEnds[1 - handleIndex] = handleEnds[handleIndex]; + } + } + + return handleEnds; + + function getRealDelta(delta, handleEnds, extent) { + var handleMinMax = !handleEnds.length + ? [handleEnds, handleEnds] + : handleEnds.slice(); + handleEnds[0] > handleEnds[1] && handleMinMax.reverse(); + + if (delta < 0 && handleMinMax[0] + delta < extent[0]) { + delta = extent[0] - handleMinMax[0]; + } + if (delta > 0 && handleMinMax[1] + delta > extent[1]) { + delta = extent[1] - handleMinMax[1]; + } + return delta; + } + }; + + +/***/ }, +/* 295 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Data zoom model + */ + + + module.exports = __webpack_require__(288).extend({ + + type: 'dataZoom.inside', + + /** + * @protected + */ + defaultOption: { + zoomLock: false // Whether disable zoom but only pan. + } + }); + + +/***/ }, +/* 296 */ +/***/ function(module, exports, __webpack_require__) { + + + + var DataZoomView = __webpack_require__(290); + var zrUtil = __webpack_require__(3); + var sliderMove = __webpack_require__(294); + var roams = __webpack_require__(297); + var bind = zrUtil.bind; + + var InsideZoomView = DataZoomView.extend({ + + type: 'dataZoom.inside', + + /** + * @override + */ + init: function (ecModel, api) { + /** + * 'throttle' is used in this.dispatchAction, so we save range + * to avoid missing some 'pan' info. + * @private + * @type {Array.} + */ + this._range; + }, + + /** + * @override + */ + render: function (dataZoomModel, ecModel, api, payload) { + InsideZoomView.superApply(this, 'render', arguments); + + // Notice: origin this._range should be maintained, and should not be re-fetched + // from dataZoomModel when payload.type is 'dataZoom', otherwise 'pan' or 'zoom' + // info will be missed because of 'throttle' of this.dispatchAction. + if (roams.shouldRecordRange(payload, dataZoomModel.id)) { + this._range = dataZoomModel.getPercentRange(); + } + + // Reset controllers. + zrUtil.each(this.getTargetInfo().cartesians, function (coordInfo) { + var coordModel = coordInfo.model; + roams.register( + api, + { + coordId: coordModel.id, + coordType: coordModel.type, + coordinateSystem: coordModel.coordinateSystem, + dataZoomId: dataZoomModel.id, + throttleRage: dataZoomModel.get('throttle', true), + panGetRange: bind(this._onPan, this, coordInfo), + zoomGetRange: bind(this._onZoom, this, coordInfo) + } + ); + }, this); + + // TODO + // polar支持 + }, + + /** + * @override + */ + remove: function () { + roams.unregister(this.api, this.dataZoomModel.id); + InsideZoomView.superApply(this, 'remove', arguments); + this._range = null; + }, + + /** + * @override + */ + dispose: function () { + roams.unregister(this.api, this.dataZoomModel.id); + InsideZoomView.superApply(this, 'dispose', arguments); + this._range = null; + }, + + /** + * @private + */ + _onPan: function (coordInfo, controller, dx, dy) { + return ( + this._range = panCartesian( + [dx, dy], this._range, controller, coordInfo + ) + ); + }, + + /** + * @private + */ + _onZoom: function (coordInfo, controller, scale, mouseX, mouseY) { + var dataZoomModel = this.dataZoomModel; + + if (dataZoomModel.option.zoomLock) { + return; + } + + return ( + this._range = scaleCartesian( + 1 / scale, [mouseX, mouseY], this._range, + controller, coordInfo, dataZoomModel + ) + ); + } + + }); + + function panCartesian(pixelDeltas, range, controller, coordInfo) { + range = range.slice(); + + // Calculate transform by the first axis. + var axisModel = coordInfo.axisModels[0]; + if (!axisModel) { + return; + } + + var directionInfo = getDirectionInfo(pixelDeltas, axisModel, controller); + + var percentDelta = directionInfo.signal + * (range[1] - range[0]) + * directionInfo.pixel / directionInfo.pixelLength; + + sliderMove( + percentDelta, + range, + [0, 100], + 'rigid' + ); + + return range; + } + + function scaleCartesian(scale, mousePoint, range, controller, coordInfo, dataZoomModel) { + range = range.slice(); + + // Calculate transform by the first axis. + var axisModel = coordInfo.axisModels[0]; + if (!axisModel) { + return; + } + + var directionInfo = getDirectionInfo(mousePoint, axisModel, controller); + + var mouse = directionInfo.pixel - directionInfo.pixelStart; + var percentPoint = mouse / directionInfo.pixelLength * (range[1] - range[0]) + range[0]; + + scale = Math.max(scale, 0); + range[0] = (range[0] - percentPoint) * scale + percentPoint; + range[1] = (range[1] - percentPoint) * scale + percentPoint; + + return fixRange(range); + } + + function getDirectionInfo(xy, axisModel, controller) { + var axis = axisModel.axis; + var rect = controller.rect; + var ret = {}; + + if (axis.dim === 'x') { + ret.pixel = xy[0]; + ret.pixelLength = rect.width; + ret.pixelStart = rect.x; + ret.signal = axis.inverse ? 1 : -1; + } + else { // axis.dim === 'y' + ret.pixel = xy[1]; + ret.pixelLength = rect.height; + ret.pixelStart = rect.y; + ret.signal = axis.inverse ? -1 : 1; + } + + return ret; + } + + function fixRange(range) { + // Clamp, using !(<= or >=) to handle NaN. + // jshint ignore:start + var bound = [0, 100]; + !(range[0] <= bound[1]) && (range[0] = bound[1]); + !(range[1] <= bound[1]) && (range[1] = bound[1]); + !(range[0] >= bound[0]) && (range[0] = bound[0]); + !(range[1] >= bound[0]) && (range[1] = bound[0]); + // jshint ignore:end + + return range; + } + + module.exports = InsideZoomView; + + +/***/ }, +/* 297 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Roam controller manager. + */ + + + // Only create one roam controller for each coordinate system. + // one roam controller might be refered by two inside data zoom + // components (for example, one for x and one for y). When user + // pan or zoom, only dispatch one action for those data zoom + // components. + + var zrUtil = __webpack_require__(3); + var RoamController = __webpack_require__(159); + var throttle = __webpack_require__(293); + var curry = zrUtil.curry; + + var ATTR = '\0_ec_dataZoom_roams'; + + var roams = { + + /** + * @public + * @param {module:echarts/ExtensionAPI} api + * @param {Object} dataZoomInfo + * @param {string} dataZoomInfo.coordType + * @param {string} dataZoomInfo.coordId + * @param {Object} dataZoomInfo.coordinateSystem + * @param {string} dataZoomInfo.dataZoomId + * @param {number} dataZoomInfo.throttleRate + * @param {Function} dataZoomInfo.panGetRange + * @param {Function} dataZoomInfo.zoomGetRange + */ + register: function (api, dataZoomInfo) { + var store = giveStore(api); + var theDataZoomId = dataZoomInfo.dataZoomId; + var theCoordId = dataZoomInfo.coordType + '\0_' + dataZoomInfo.coordId; + + // Do clean when a dataZoom changes its target coordnate system. + zrUtil.each(store, function (record, coordId) { + var dataZoomInfos = record.dataZoomInfos; + if (dataZoomInfos[theDataZoomId] && coordId !== theCoordId) { + delete dataZoomInfos[theDataZoomId]; + record.count--; + } + }); + + cleanStore(store); + + var record = store[theCoordId]; + + // Create if needed. + if (!record) { + record = store[theCoordId] = { + coordId: theCoordId, + dataZoomInfos: {}, + count: 0 + }; + record.controller = createController(api, dataZoomInfo, record); + record.dispatchAction = zrUtil.curry(dispatchAction, api); + } + + // Update. + if (record) { + throttle.createOrUpdate( + record, + 'dispatchAction', + dataZoomInfo.throttleRate, + 'fixRate' + ); + + !record.dataZoomInfos[theDataZoomId] && record.count++; + record.dataZoomInfos[theDataZoomId] = dataZoomInfo; + } + }, + + /** + * @public + * @param {module:echarts/ExtensionAPI} api + * @param {string} dataZoomId + */ + unregister: function (api, dataZoomId) { + var store = giveStore(api); + + zrUtil.each(store, function (record, coordId) { + var dataZoomInfos = record.dataZoomInfos; + if (dataZoomInfos[dataZoomId]) { + delete dataZoomInfos[dataZoomId]; + record.count--; + } + }); + + cleanStore(store); + }, + + /** + * @public + */ + shouldRecordRange: function (payload, dataZoomId) { + if (payload && payload.type === 'dataZoom' && payload.batch) { + for (var i = 0, len = payload.batch.length; i < len; i++) { + if (payload.batch[i].dataZoomId === dataZoomId) { + return false; + } + } + } + return true; + } + + }; + + /** + * Key: coordId, value: {dataZoomInfos: [], count, controller} + * @type {Array.} + */ + function giveStore(api) { + // Mount store on zrender instance, so that we do not + // need to worry about dispose. + var zr = api.getZr(); + return zr[ATTR] || (zr[ATTR] = {}); + } + + function createController(api, dataZoomInfo, newRecord) { + var controller = new RoamController(api.getZr()); + controller.enable(); + controller.on('pan', curry(onPan, newRecord)); + controller.on('zoom', curry(onZoom, newRecord)); + controller.rect = dataZoomInfo.coordinateSystem.getRect().clone(); + + return controller; + } + + function cleanStore(store) { + zrUtil.each(store, function (record, coordId) { + if (!record.count) { + record.controller.off('pan').off('zoom'); + delete store[coordId]; + } + }); + } + + function onPan(record, dx, dy) { + wrapAndDispatch(record, function (info) { + return info.panGetRange(record.controller, dx, dy); + }); + } + + function onZoom(record, scale, mouseX, mouseY) { + wrapAndDispatch(record, function (info) { + return info.zoomGetRange(record.controller, scale, mouseX, mouseY); + }); + } + + function wrapAndDispatch(record, getRange) { + var batch = []; + + zrUtil.each(record.dataZoomInfos, function (info) { + var range = getRange(info); + range && batch.push({ + dataZoomId: info.dataZoomId, + start: range[0], + end: range[1] + }); + }); + + record.dispatchAction(batch); + } + + /** + * This action will be throttled. + */ + function dispatchAction(api, batch) { + api.dispatchAction({ + type: 'dataZoom', + batch: batch + }); + } + + module.exports = roams; + + + +/***/ }, +/* 298 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Data zoom processor + */ + + + var echarts = __webpack_require__(1); + + echarts.registerProcessor('filter', function (ecModel, api) { + + ecModel.eachComponent('dataZoom', function (dataZoomModel) { + // We calculate window and reset axis here but not in model + // init stage and not after action dispatch handler, because + // reset should be called after seriesData.restoreData. + dataZoomModel.eachTargetAxis(resetSingleAxis); + + // Caution: data zoom filtering is order sensitive when using + // percent range and no min/max/scale set on axis. + // For example, we have dataZoom definition: + // [ + // {xAxisIndex: 0, start: 30, end: 70}, + // {yAxisIndex: 0, start: 20, end: 80} + // ] + // In this case, [20, 80] of y-dataZoom should be based on data + // that have filtered by x-dataZoom using range of [30, 70], + // but should not be based on full raw data. Thus sliding + // x-dataZoom will change both ranges of xAxis and yAxis, + // while sliding y-dataZoom will only change the range of yAxis. + // So we should filter x-axis after reset x-axis immediately, + // and then reset y-axis and filter y-axis. + dataZoomModel.eachTargetAxis(filterSingleAxis); + }); + + ecModel.eachComponent('dataZoom', function (dataZoomModel) { + // Fullfill all of the range props so that user + // is able to get them from chart.getOption(). + var axisProxy = dataZoomModel.findRepresentativeAxisProxy(); + var percentRange = axisProxy.getDataPercentWindow(); + var valueRange = axisProxy.getDataValueWindow(); + dataZoomModel.setRawRange({ + start: percentRange[0], + end: percentRange[1], + startValue: valueRange[0], + endValue: valueRange[1] + }); + }); + }); - + function resetSingleAxis(dimNames, axisIndex, dataZoomModel) { + dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel); + } - var zrUtil = require('zrender/core/util'); - var ChartView = require('../../view/Chart'); - var graphic = require('../../util/graphic'); - var whiskerBoxCommon = require('../helper/whiskerBoxCommon'); + function filterSingleAxis(dimNames, axisIndex, dataZoomModel) { + dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel); + } - var CandlestickView = ChartView.extend({ - type: 'candlestick', - getStyleUpdater: function () { - return updateStyle; - } - }); +/***/ }, +/* 299 */ +/***/ function(module, exports, __webpack_require__) { - zrUtil.mixin(CandlestickView, whiskerBoxCommon.viewMixin, true); + /** + * @file Data zoom action + */ - // Update common properties - var normalStyleAccessPath = ['itemStyle', 'normal']; - var emphasisStyleAccessPath = ['itemStyle', 'emphasis']; - function updateStyle(itemGroup, data, idx) { - var itemModel = data.getItemModel(idx); - var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath); - var color = data.getItemVisual(idx, 'color'); - var borderColor = data.getItemVisual(idx, 'borderColor'); + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var echarts = __webpack_require__(1); - // Color must be excluded. - // Because symbol provide setColor individually to set fill and stroke - var itemStyle = normalItemStyleModel.getItemStyle( - ['color', 'color0', 'borderColor', 'borderColor0'] - ); - var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex); - whiskerEl.style.set(itemStyle); - whiskerEl.style.stroke = borderColor; - whiskerEl.dirty(); + echarts.registerAction('dataZoom', function (payload, ecModel) { - var bodyEl = itemGroup.childAt(itemGroup.bodyIndex); - bodyEl.style.set(itemStyle); - bodyEl.style.fill = color; - bodyEl.style.stroke = borderColor; - bodyEl.dirty(); + var linkedNodesFinder = modelUtil.createLinkedNodesFinder( + zrUtil.bind(ecModel.eachComponent, ecModel, 'dataZoom'), + modelUtil.eachAxisDim, + function (model, dimNames) { + return model.get(dimNames.axisIndex); + } + ); - var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle(); - graphic.setHoverStyle(itemGroup, hoverStyle); - } + var effectedModels = []; + ecModel.eachComponent( + {mainType: 'dataZoom', query: payload}, + function (model, index) { + effectedModels.push.apply( + effectedModels, linkedNodesFinder(model).nodes + ); + } + ); - return CandlestickView; + zrUtil.each(effectedModels, function (dataZoomModel, index) { + dataZoomModel.setRawRange({ + start: payload.start, + end: payload.end, + startValue: payload.startValue, + endValue: payload.endValue + }); + }); -}); -define('echarts/chart/candlestick/preprocessor',['require','zrender/core/util'],function (require) { + }); - var zrUtil = require('zrender/core/util'); - return function (option) { - if (!option || !zrUtil.isArray(option.series)) { - return; - } - // Translate 'k' to 'candlestick'. - zrUtil.each(option.series, function (seriesItem) { - if (zrUtil.isObject(seriesItem) && seriesItem.type === 'k') { - seriesItem.type = 'candlestick'; - } - }); - }; +/***/ }, +/* 300 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * visualMap component entry + */ + + + __webpack_require__(301); + __webpack_require__(312); -}); -define('echarts/chart/candlestick/candlestickVisual',['require'],function (require) { - - var positiveBorderColorQuery = ['itemStyle', 'normal', 'borderColor']; - var negativeBorderColorQuery = ['itemStyle', 'normal', 'borderColor0']; - var positiveColorQuery = ['itemStyle', 'normal', 'color']; - var negativeColorQuery = ['itemStyle', 'normal', 'color0']; - - return function (ecModel, api) { - - ecModel.eachRawSeriesByType('candlestick', function (seriesModel) { - - var data = seriesModel.getData(); - - data.setVisual({ - legendSymbol: 'roundRect' - }); - - // Only visible series has each data be visual encoded - if (!ecModel.isSeriesFiltered(seriesModel)) { - data.each(function (idx) { - var itemModel = data.getItemModel(idx); - var sign = data.getItemLayout(idx).sign; - - data.setItemVisual( - idx, - { - color: itemModel.get( - sign > 0 ? positiveColorQuery : negativeColorQuery - ), - borderColor: itemModel.get( - sign > 0 ? positiveBorderColorQuery : negativeBorderColorQuery - ) - } - ); - }); - } - }); - - }; -}); -define('echarts/chart/candlestick/candlestickLayout',['require'],function (require) { - - var CANDLE_MIN_WIDTH = 2; - var CANDLE_MIN_NICE_WIDTH = 5; - var GPA_MIN = 4; - - return function (ecModel, api) { - - ecModel.eachSeriesByType('candlestick', function (seriesModel) { - - var coordSys = seriesModel.coordinateSystem; - var data = seriesModel.getData(); - var dimensions = seriesModel.dimensions; - var chartLayout = seriesModel.get('layout'); - - var candleWidth = calculateCandleWidth(seriesModel, data); - - data.each(dimensions, function () { - var args = arguments; - var dimLen = dimensions.length; - var axisDimVal = args[0]; - var idx = args[dimLen]; - var variableDim = chartLayout === 'horizontal' ? 0 : 1; - var constDim = 1 - variableDim; - - var openVal = args[1]; - var closeVal = args[2]; - var lowestVal = args[3]; - var highestVal = args[4]; - - var ocLow = Math.min(openVal, closeVal); - var ocHigh = Math.max(openVal, closeVal); - - var ocLowPoint = getPoint(ocLow); - var ocHighPoint = getPoint(ocHigh); - var lowestPoint = getPoint(lowestVal); - var highestPoint = getPoint(highestVal); - - var whiskerEnds = [ - [highestPoint, ocHighPoint], - [lowestPoint, ocLowPoint] - ]; - - var bodyEnds = []; - addBodyEnd(ocHighPoint, 0); - addBodyEnd(ocLowPoint, 1); - - data.setItemLayout(idx, { - chartLayout: chartLayout, - sign: openVal > closeVal ? -1 : openVal < closeVal ? 1 : 0, - initBaseline: openVal > closeVal - ? ocHighPoint[constDim] : ocLowPoint[constDim], // open point. - bodyEnds: bodyEnds, - whiskerEnds: whiskerEnds - }); - - function getPoint(val) { - var p = []; - p[variableDim] = axisDimVal; - p[constDim] = val; - return (isNaN(axisDimVal) || isNaN(val)) - ? [NaN, NaN] - : coordSys.dataToPoint(p); - } - - function addBodyEnd(point, start) { - var point1 = point.slice(); - var point2 = point.slice(); - point1[variableDim] += candleWidth / 2; - point2[variableDim] -= candleWidth / 2; - start - ? bodyEnds.push(point1, point2) - : bodyEnds.push(point2, point1); - } - - }, true); - }); - }; - - function calculateCandleWidth(seriesModel, data) { - var baseAxis = seriesModel.getBaseAxis(); - var extent; - - var bandWidth = baseAxis.type === 'category' - ? baseAxis.getBandWidth() - : ( - extent = baseAxis.getExtent(), - Math.abs(extent[1] - extent[0]) / data.count() - ); - - // Half band width is perfect when space is enouph, otherwise - // try not to be smaller than CANDLE_MIN_NICE_WIDTH (and only - // gap is compressed), otherwise ensure not to be smaller than - // CANDLE_MIN_WIDTH in spite of overlap. - - return bandWidth / 2 - 2 > CANDLE_MIN_NICE_WIDTH // "- 2" is minus border width - ? bandWidth / 2 - 2 - : bandWidth - CANDLE_MIN_NICE_WIDTH > GPA_MIN - ? CANDLE_MIN_NICE_WIDTH - : Math.max(bandWidth - GPA_MIN, CANDLE_MIN_WIDTH); - } -}); -define('echarts/chart/candlestick',['require','../echarts','./candlestick/CandlestickSeries','./candlestick/CandlestickView','./candlestick/preprocessor','./candlestick/candlestickVisual','./candlestick/candlestickLayout'],function (require) { - var echarts = require('../echarts'); +/***/ }, +/* 301 */ +/***/ function(module, exports, __webpack_require__) { - require('./candlestick/CandlestickSeries'); - require('./candlestick/CandlestickView'); + /** + * DataZoom component entry + */ - echarts.registerPreprocessor( - require('./candlestick/preprocessor') - ); - echarts.registerVisualCoding('chart', require('./candlestick/candlestickVisual')); - echarts.registerLayout(require('./candlestick/candlestickLayout')); + __webpack_require__(1).registerPreprocessor( + __webpack_require__(302) + ); -}); -define('echarts/chart/effectScatter/EffectScatterSeries',['require','../helper/createListFromArray','../../model/Series'],function (require) { + __webpack_require__(303); + __webpack_require__(304); + __webpack_require__(305); + __webpack_require__(308); + __webpack_require__(311); - - var createListFromArray = require('../helper/createListFromArray'); - var SeriesModel = require('../../model/Series'); - return SeriesModel.extend({ +/***/ }, +/* 302 */ +/***/ function(module, exports, __webpack_require__) { - type: 'series.effectScatter', + /** + * @file VisualMap preprocessor + */ - dependencies: ['grid', 'polar'], - getInitialData: function (option, ecModel) { - var list = createListFromArray(option.data, this, ecModel); - return list; - }, + var zrUtil = __webpack_require__(3); + var each = zrUtil.each; - defaultOption: { - coordinateSystem: 'cartesian2d', - zlevel: 0, - z: 2, - legendHoverLink: true, + module.exports = function (option) { + var visualMap = option && option.visualMap; - effectType: 'ripple', + if (!zrUtil.isArray(visualMap)) { + visualMap = visualMap ? [visualMap] : []; + } - // When to show the effect, option: 'render'|'emphasis' - showEffectOn: 'render', + each(visualMap, function (opt) { + if (!opt) { + return; + } - // Ripple effect config - rippleEffect: { - period: 4, - // Scale of ripple - scale: 2.5, - // Brush type can be fill or stroke - brushType: 'fill' - }, + // rename splitList to pieces + if (has(opt, 'splitList') && !has(opt, 'pieces')) { + opt.pieces = opt.splitList; + delete opt.splitList; + } - // Cartesian coordinate system - xAxisIndex: 0, - yAxisIndex: 0, + var pieces = opt.pieces; + if (pieces && zrUtil.isArray(pieces)) { + each(pieces, function (piece) { + if (zrUtil.isObject(piece)) { + if (has(piece, 'start') && !has(piece, 'min')) { + piece.min = piece.start; + } + if (has(piece, 'end') && !has(piece, 'max')) { + piece.max = piece.end; + } + } + }); + } + }); + }; - // Polar coordinate system - polarIndex: 0, + function has(obj, name) { + return obj && obj.hasOwnProperty && obj.hasOwnProperty(name); + } - // Geo coordinate system - geoIndex: 0, - // symbol: null, // 图形类型 - symbolSize: 10 // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2 - // symbolRotate: null, // 图形旋转控制 - // large: false, - // Available when large is true - // largeThreshold: 2000, +/***/ }, +/* 303 */ +/***/ function(module, exports, __webpack_require__) { - // itemStyle: { - // normal: { - // opacity: 1 - // } - // } - } - }); -}); -/** - * Symbol with ripple effect - * @module echarts/chart/helper/EffectSymbol - */ -define('echarts/chart/helper/EffectSymbol',['require','zrender/core/util','../../util/symbol','../../util/graphic','../../util/number','./Symbol'],function (require) { - - var zrUtil = require('zrender/core/util'); - var symbolUtil = require('../../util/symbol'); - var graphic = require('../../util/graphic'); - var numberUtil = require('../../util/number'); - var Symbol = require('./Symbol'); - var Group = graphic.Group; - - var EFFECT_RIPPLE_NUMBER = 3; - - function normalizeSymbolSize(symbolSize) { - if (!zrUtil.isArray(symbolSize)) { - symbolSize = [+symbolSize, +symbolSize]; - } - return symbolSize; - } - /** - * @constructor - * @param {module:echarts/data/List} data - * @param {number} idx - * @extends {module:zrender/graphic/Group} - */ - function EffectSymbol(data, idx) { - Group.call(this); - - var symbol = new Symbol(data, idx); - var rippleGroup = new Group(); - this.add(symbol); - this.add(rippleGroup); - - rippleGroup.beforeUpdate = function () { - this.attr(symbol.getScale()); - }; - this.updateData(data, idx); - } - - var effectSymbolProto = EffectSymbol.prototype; - - effectSymbolProto.stopEffectAnimation = function () { - this.childAt(1).removeAll(); - }; - - effectSymbolProto.startEffectAnimation = function ( - period, brushType, rippleScale, effectOffset, z, zlevel - ) { - var symbolType = this._symbolType; - var color = this._color; - - var rippleGroup = this.childAt(1); - - for (var i = 0; i < EFFECT_RIPPLE_NUMBER; i++) { - var ripplePath = symbolUtil.createSymbol( - symbolType, -0.5, -0.5, 1, 1, color - ); - ripplePath.attr({ - style: { - stroke: brushType === 'stroke' ? color : null, - fill: brushType === 'fill' ? color : null, - strokeNoScale: true - }, - z2: 99, - silent: true, - scale: [1, 1], - z: z, - zlevel: zlevel - }); - - var delay = -i / EFFECT_RIPPLE_NUMBER * period + effectOffset; - // TODO Configurable period - ripplePath.animate('', true) - .when(period, { - scale: [rippleScale, rippleScale] - }) - .delay(delay) - .start(); - ripplePath.animateStyle(true) - .when(period, { - opacity: 0 - }) - .delay(delay) - .start(); - - rippleGroup.add(ripplePath); - } - }; - - /** - * Highlight symbol - */ - effectSymbolProto.highlight = function () { - this.trigger('emphasis'); - }; - - /** - * Downplay symbol - */ - effectSymbolProto.downplay = function () { - this.trigger('normal'); - }; - - /** - * Update symbol properties - * @param {module:echarts/data/List} data - * @param {number} idx - */ - effectSymbolProto.updateData = function (data, idx) { - var seriesModel = data.hostModel; - - this.childAt(0).updateData(data, idx); - - var rippleGroup = this.childAt(1); - var itemModel = data.getItemModel(idx); - var symbolType = data.getItemVisual(idx, 'symbol'); - var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); - var color = data.getItemVisual(idx, 'color'); - - rippleGroup.attr('scale', symbolSize); - - rippleGroup.traverse(function (ripplePath) { - ripplePath.attr({ - fill: color - }); - }); - - var symbolOffset = itemModel.getShallow('symbolOffset'); - if (symbolOffset) { - var pos = rippleGroup.position; - pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]); - pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]); - } - - this._symbolType = symbolType; - this._color = color; - - var showEffectOn = seriesModel.get('showEffectOn'); - var rippleScale = itemModel.get('rippleEffect.scale'); - var brushType = itemModel.get('rippleEffect.brushType'); - var effectPeriod = itemModel.get('rippleEffect.period') * 1000; - var effectOffset = idx / data.count(); - var z = itemModel.getShallow('z') || 0; - var zlevel = itemModel.getShallow('zlevel') || 0; - - this.stopEffectAnimation(); - if (showEffectOn === 'render') { - this.startEffectAnimation( - effectPeriod, brushType, rippleScale, effectOffset, z, zlevel - ); - } - var symbol = this.childAt(0); - function onEmphasis() { - symbol.trigger('emphasis'); - if (showEffectOn !== 'render') { - this.startEffectAnimation( - effectPeriod, brushType, rippleScale, effectOffset, z, zlevel - ); - } - } - function onNormal() { - symbol.trigger('normal'); - if (showEffectOn !== 'render') { - this.stopEffectAnimation(); - } - } - this.on('mouseover', onEmphasis, this) - .on('mouseout', onNormal, this) - .on('emphasis', onEmphasis, this) - .on('normal', onNormal, this); - }; - - effectSymbolProto.fadeOut = function (cb) { - cb && cb(); - }; - - zrUtil.inherits(EffectSymbol, Group); - - return EffectSymbol; -}); -define('echarts/chart/effectScatter/EffectScatterView',['require','../helper/SymbolDraw','../helper/EffectSymbol','../../echarts'],function (require) { + + + __webpack_require__(19).registerSubTypeDefaulter('visualMap', function (option) { + // Compatible with ec2, when splitNumber === 0, continuous visualMap will be used. + return ( + !option.categories + && ( + !( + option.pieces + ? option.pieces.length > 0 + : option.splitNumber > 0 + ) + || option.calculable + ) + ) + ? 'continuous' : 'piecewise'; + }); - var SymbolDraw = require('../helper/SymbolDraw'); - var EffectSymbol = require('../helper/EffectSymbol'); - require('../../echarts').extendChartView({ - type: 'effectScatter', +/***/ }, +/* 304 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Data range visual coding. + */ + + + var echarts = __webpack_require__(1); + var VisualMapping = __webpack_require__(187); + var zrUtil = __webpack_require__(3); + + echarts.registerVisualCoding('component', function (ecModel) { + ecModel.eachComponent('visualMap', function (visualMapModel) { + processSingleVisualMap(visualMapModel, ecModel); + }); + }); + + function processSingleVisualMap(visualMapModel, ecModel) { + var visualMappings = visualMapModel.targetVisuals; + var visualTypesMap = {}; + zrUtil.each(['inRange', 'outOfRange'], function (state) { + var visualTypes = VisualMapping.prepareVisualTypes(visualMappings[state]); + visualTypesMap[state] = visualTypes; + }); + + visualMapModel.eachTargetSeries(function (seriesModel) { + var data = seriesModel.getData(); + var dimension = visualMapModel.getDataDimension(data); + var dataIndex; + + function getVisual(key) { + return data.getItemVisual(dataIndex, key); + } + + function setVisual(key, value) { + data.setItemVisual(dataIndex, key, value); + } + + data.each([dimension], function (value, index) { + // For performance consideration, do not use curry. + dataIndex = index; + var valueState = visualMapModel.getValueState(value); + var mappings = visualMappings[valueState]; + var visualTypes = visualTypesMap[valueState]; + for (var i = 0, len = visualTypes.length; i < len; i++) { + var type = visualTypes[i]; + mappings[type] && mappings[type].applyVisual(value, getVisual, setVisual); + } + }); + }); + } + + + + +/***/ }, +/* 305 */ +/***/ function(module, exports, __webpack_require__) { + + + /** + * @file Data zoom model + */ + + + var VisualMapModel = __webpack_require__(306); + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + + // Constant + var DEFAULT_BAR_BOUND = [20, 140]; + + var ContinuousModel = VisualMapModel.extend({ + + type: 'visualMap.continuous', + + /** + * @protected + */ + defaultOption: { + handlePosition: 'auto', // 'auto', 'left', 'right', 'top', 'bottom' + calculable: false, // 是否值域漫游,启用后无视splitNumber和pieces,线性渐变 + range: [-Infinity, Infinity], // 当前选中范围 + hoverLink: true, + realtime: true, + itemWidth: null, // 值域图形宽度 + itemHeight: null // 值域图形高度 + }, + + /** + * @override + */ + doMergeOption: function (newOption, isInit) { + ContinuousModel.superApply(this, 'doMergeOption', arguments); + + this.resetTargetSeries(newOption, isInit); + this.resetExtent(); + + this.resetVisual(function (mappingOption) { + mappingOption.mappingMethod = 'linear'; + }); + + this._resetRange(); + }, + + /** + * @protected + * @override + */ + resetItemSize: function () { + VisualMapModel.prototype.resetItemSize.apply(this, arguments); + + var itemSize = this.itemSize; + + this._orient === 'horizontal' && itemSize.reverse(); + + (itemSize[0] == null || isNaN(itemSize[0])) && (itemSize[0] = DEFAULT_BAR_BOUND[0]); + (itemSize[1] == null || isNaN(itemSize[1])) && (itemSize[1] = DEFAULT_BAR_BOUND[1]); + }, + + /** + * @private + */ + _resetRange: function () { + var dataExtent = this.getExtent(); + var range = this.option.range; + if (range[0] > range[1]) { + range.reverse(); + } + range[0] = Math.max(range[0], dataExtent[0]); + range[1] = Math.min(range[1], dataExtent[1]); + }, + + /** + * @protected + * @override + */ + completeVisualOption: function () { + VisualMapModel.prototype.completeVisualOption.apply(this, arguments); + + zrUtil.each(this.stateList, function (state) { + var symbolSize = this.option.controller[state].symbolSize; + if (symbolSize && symbolSize[0] !== symbolSize[1]) { + symbolSize[0] = 0; // For good looking. + } + }, this); + }, + + /** + * @public + * @override + */ + setSelected: function (selected) { + this.option.range = selected.slice(); + this._resetRange(); + }, + + /** + * @public + */ + getSelected: function () { + var dataExtent = this.getExtent(); + + var dataInterval = numberUtil.asc( + (this.get('range') || []).slice() + ); + + // Clamp + dataInterval[0] > dataExtent[1] && (dataInterval[0] = dataExtent[1]); + dataInterval[1] > dataExtent[1] && (dataInterval[1] = dataExtent[1]); + dataInterval[0] < dataExtent[0] && (dataInterval[0] = dataExtent[0]); + dataInterval[1] < dataExtent[0] && (dataInterval[1] = dataExtent[0]); + + return dataInterval; + }, + + /** + * @public + * @override + */ + getValueState: function (value) { + var range = this.option.range; + var dataExtent = this.getExtent(); + + // When range[0] === dataExtent[0], any value larger than dataExtent[0] maps to 'inRange'. + // range[1] is processed likewise. + return ( + (range[0] <= dataExtent[0] || range[0] <= value) + && (range[1] >= dataExtent[1] || value <= range[1]) + ) ? 'inRange' : 'outOfRange'; + } + + }); + + module.exports = ContinuousModel; + + + +/***/ }, +/* 306 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Data zoom model + */ + + + var zrUtil = __webpack_require__(3); + var env = __webpack_require__(78); + var echarts = __webpack_require__(1); + var modelUtil = __webpack_require__(5); + var visualDefault = __webpack_require__(307); + var VisualMapping = __webpack_require__(187); + var mapVisual = VisualMapping.mapVisual; + var eachVisual = VisualMapping.eachVisual; + var numberUtil = __webpack_require__(7); + var isArray = zrUtil.isArray; + var each = zrUtil.each; + var asc = numberUtil.asc; + var linearMap = numberUtil.linearMap; + + var VisualMapModel = echarts.extendComponentModel({ + + type: 'visualMap', + + dependencies: ['series'], + + /** + * [lowerBound, upperBound] + * + * @readOnly + * @type {Array.} + */ + dataBound: [-Infinity, Infinity], + + /** + * @readOnly + * @type {Array.} + */ + stateList: ['inRange', 'outOfRange'], + + /** + * @readOnly + * @type {string|Object} + */ + layoutMode: {type: 'box', ignoreSize: true}, + + /** + * @protected + */ + defaultOption: { + show: true, + + zlevel: 0, + z: 4, + + // set min: 0, max: 200, only for campatible with ec2. + // In fact min max should not have default value. + min: 0, // min value, must specified if pieces is not specified. + max: 200, // max value, must specified if pieces is not specified. + + dimension: null, + inRange: null, // 'color', 'colorHue', 'colorSaturation', 'colorLightness', 'colorAlpha', + // 'symbol', 'symbolSize' + outOfRange: null, // 'color', 'colorHue', 'colorSaturation', + // 'colorLightness', 'colorAlpha', + // 'symbol', 'symbolSize' + + left: 0, // 'center' ¦ 'left' ¦ 'right' ¦ {number} (px) + right: null, // The same as left. + top: null, // 'top' ¦ 'bottom' ¦ 'center' ¦ {number} (px) + bottom: 0, // The same as top. + + itemWidth: null, + itemHeight: null, + inverse: false, + orient: 'vertical', // 'horizontal' ¦ 'vertical' + + seriesIndex: null, // 所控制的series indices,默认所有有value的series. + backgroundColor: 'rgba(0,0,0,0)', + borderColor: '#ccc', // 值域边框颜色 + contentColor: '#5793f3', + inactiveColor: '#aaa', + borderWidth: 0, // 值域边框线宽,单位px,默认为0(无边框) + padding: 5, // 值域内边距,单位px,默认各方向内边距为5, + // 接受数组分别设定上右下左边距,同css + textGap: 10, // + precision: 0, // 小数精度,默认为0,无小数点 + color: ['#bf444c', '#d88273', '#f6efa6'], //颜色(deprecated,兼容ec2,顺序同pieces,不同于inRange/outOfRange) + + formatter: null, + text: null, // 文本,如['高', '低'],兼容ec2,text[0]对应高值,text[1]对应低值 + textStyle: { + color: '#333' // 值域文字颜色 + } + }, + + /** + * @protected + */ + init: function (option, parentModel, ecModel) { + /** + * @private + * @type {boolean} + */ + this._autoSeriesIndex = false; + + /** + * @private + * @type {Array.} + */ + this._dataExtent; + + /** + * @readOnly + */ + this.controllerVisuals = {}; + + /** + * @readOnly + */ + this.targetVisuals = {}; + + /** + * @readOnly + */ + this.textStyleModel; + + /** + * [width, height] + * @readOnly + * @type {Array.} + */ + this.itemSize; + + this.mergeDefaultAndTheme(option, ecModel); + this.doMergeOption({}, true); + }, + + /** + * @public + */ + mergeOption: function (option) { + VisualMapModel.superApply(this, 'mergeOption', arguments); + this.doMergeOption(option, false); + }, + + /** + * @protected + */ + doMergeOption: function (newOption, isInit) { + var thisOption = this.option; + + // FIXME + // necessary? + // Disable realtime view update if canvas is not supported. + if (!env.canvasSupported) { + thisOption.realtime = false; + } + + this.textStyleModel = this.getModel('textStyle'); + + this.resetItemSize(); + + this.completeVisualOption(); + }, + + /** + * @example + * this.formatValueText(someVal); // format single numeric value to text. + * this.formatValueText(someVal, true); // format single category value to text. + * this.formatValueText([min, max]); // format numeric min-max to text. + * this.formatValueText([this.dataBound[0], max]); // using data lower bound. + * this.formatValueText([min, this.dataBound[1]]); // using data upper bound. + * + * @param {number|Array.} value Real value, or this.dataBound[0 or 1]. + * @param {boolean} [isCategory=false] Only available when value is number. + * @return {string} + * @protected + */ + formatValueText: function(value, isCategory) { + var option = this.option; + var precision = option.precision; + var dataBound = this.dataBound; + var formatter = option.formatter; + var isMinMax; + var textValue; + + if (zrUtil.isArray(value)) { + value = value.slice(); + isMinMax = true; + } + + textValue = isCategory + ? value + : (isMinMax + ? [toFixed(value[0]), toFixed(value[1])] + : toFixed(value) + ); + + if (zrUtil.isString(formatter)) { + return formatter + .replace('{value}', isMinMax ? textValue[0] : textValue) + .replace('{value2}', isMinMax ? textValue[1] : textValue); + } + else if (zrUtil.isFunction(formatter)) { + return isMinMax + ? formatter(value[0], value[1]) + : formatter(value); + } + + if (isMinMax) { + if (value[0] === dataBound[0]) { + return '< ' + textValue[1]; + } + else if (value[1] === dataBound[1]) { + return '> ' + textValue[0]; + } + else { + return textValue[0] + ' - ' + textValue[1]; + } + } + else { // Format single value (includes category case). + return textValue; + } + + function toFixed(val) { + return val === dataBound[0] + ? 'min' + : val === dataBound[1] + ? 'max' + : (+val).toFixed(precision); + } + }, + + /** + * @protected + */ + resetTargetSeries: function (newOption, isInit) { + var thisOption = this.option; + var autoSeriesIndex = this._autoSeriesIndex = + (isInit ? thisOption : newOption).seriesIndex == null; + thisOption.seriesIndex = autoSeriesIndex + ? [] : modelUtil.normalizeToArray(thisOption.seriesIndex); + + autoSeriesIndex && this.ecModel.eachSeries(function (seriesModel, index) { + var data = seriesModel.getData(); + // FIXME + // 只考虑了list,还没有考虑map等。 + + // FIXME + // 这里可能应该这么判断:data.dimensions中有超出其所属coordSystem的量。 + if (data.type === 'list') { + thisOption.seriesIndex.push(index); + } + }); + }, + + /** + * @protected + */ + resetExtent: function () { + var thisOption = this.option; + + // Can not calculate data extent by data here. + // Because series and data may be modified in processing stage. + // So we do not support the feature "auto min/max". + + var extent = asc([thisOption.min, thisOption.max]); + + this._dataExtent = extent; + }, + + /** + * @protected + */ + getDataDimension: function (list) { + var optDim = this.option.dimension; + return optDim != null + ? optDim : list.dimensions.length - 1; + }, + + /** + * @public + * @override + */ + getExtent: function () { + return this._dataExtent.slice(); + }, + + /** + * @protected + */ + resetVisual: function (fillVisualOption) { + var dataExtent = this.getExtent(); + + doReset.call(this, 'controller', this.controllerVisuals); + doReset.call(this, 'target', this.targetVisuals); + + function doReset(baseAttr, visualMappings) { + each(this.stateList, function (state) { + var mappings = visualMappings[state] || (visualMappings[state] = {}); + var visaulOption = this.option[baseAttr][state] || {}; + each(visaulOption, function (visualData, visualType) { + if (!VisualMapping.isValidType(visualType)) { + return; + } + var mappingOption = { + type: visualType, + dataExtent: dataExtent, + visual: visualData + }; + fillVisualOption && fillVisualOption.call(this, mappingOption, state); + mappings[visualType] = new VisualMapping(mappingOption); + }, this); + }, this); + } + }, + + /** + * @protected + */ + completeVisualOption: function () { + var thisOption = this.option; + var base = {inRange: thisOption.inRange, outOfRange: thisOption.outOfRange}; + + var target = thisOption.target || (thisOption.target = {}); + var controller = thisOption.controller || (thisOption.controller = {}); + + zrUtil.merge(target, base); // Do not override + zrUtil.merge(controller, base); // Do not override + + var isCategory = this.isCategory(); + + completeSingle.call(this, target); + completeSingle.call(this, controller); + completeInactive.call(this, target, 'inRange', 'outOfRange'); + completeInactive.call(this, target, 'outOfRange', 'inRange'); + completeController.call(this, controller); + + function completeSingle(base) { + // Compatible with ec2 dataRange.color. + // The mapping order of dataRange.color is: [high value, ..., low value] + // whereas inRange.color and outOfRange.color is [low value, ..., high value] + // Notice: ec2 has no inverse. + if (isArray(thisOption.color) + // If there has been inRange: {symbol: ...}, adding color is a mistake. + // So adding color only when no inRange defined. + && !base.inRange + ) { + base.inRange = {color: thisOption.color.slice().reverse()}; + } + + // If using shortcut like: {inRange: 'symbol'}, complete default value. + each(this.stateList, function (state) { + var visualType = base[state]; + + if (zrUtil.isString(visualType)) { + var defa = visualDefault.get(visualType, 'active', isCategory); + if (defa) { + base[state] = {}; + base[state][visualType] = defa; + } + else { + // Mark as not specified. + delete base[state]; + } + } + }, this); + } + + function completeInactive(base, stateExist, stateAbsent) { + var optExist = base[stateExist]; + var optAbsent = base[stateAbsent]; + + if (optExist && !optAbsent) { + optAbsent = base[stateAbsent] = {}; + each(optExist, function (visualData, visualType) { + var defa = visualDefault.get(visualType, 'inactive', isCategory); + if (VisualMapping.isValidType(visualType) && defa) { + optAbsent[visualType] = defa; + } + }); + } + } + + function completeController(controller) { + var symbolExists = (controller.inRange || {}).symbol + || (controller.outOfRange || {}).symbol; + var symbolSizeExists = (controller.inRange || {}).symbolSize + || (controller.outOfRange || {}).symbolSize; + var inactiveColor = this.get('inactiveColor'); + + each(this.stateList, function (state) { + + var itemSize = this.itemSize; + var visuals = controller[state]; + + // Set inactive color for controller if no other color attr (like colorAlpha) specified. + if (!visuals) { + visuals = controller[state] = { + color: isCategory ? inactiveColor : [inactiveColor] + }; + } + + // Consistent symbol and symbolSize if not specified. + if (!visuals.symbol) { + visuals.symbol = symbolExists + && zrUtil.clone(symbolExists) + || (isCategory ? 'roundRect' : ['roundRect']); + } + if (!visuals.symbolSize) { + visuals.symbolSize = symbolSizeExists + && zrUtil.clone(symbolSizeExists) + || (isCategory ? itemSize[0] : [itemSize[0], itemSize[0]]); + } + + // Filter square and none. + visuals.symbol = mapVisual(visuals.symbol, function (symbol) { + return (symbol === 'none' || symbol === 'square') ? 'roundRect' : symbol; + }); + + // Normalize symbolSize + var symbolSize = visuals.symbolSize; + + if (symbolSize) { + var max = -Infinity; + // symbolSize can be object when categories defined. + eachVisual(symbolSize, function (value) { + value > max && (max = value); + }); + visuals.symbolSize = mapVisual(symbolSize, function (value) { + return linearMap(value, [0, max], [0, itemSize[0]], true); + }); + } + + }, this); + } + }, + + /** + * @public + */ + eachTargetSeries: function (callback, context) { + zrUtil.each(this.option.seriesIndex, function (seriesIndex) { + callback.call(context, this.ecModel.getSeriesByIndex(seriesIndex)); + }, this); + }, + + /** + * @public + */ + isCategory: function () { + return !!this.option.categories; + }, + + /** + * @protected + */ + resetItemSize: function () { + this.itemSize = [ + parseFloat(this.get('itemWidth')), + parseFloat(this.get('itemHeight')) + ]; + }, + + /** + * @public + * @abstract + */ + setSelected: zrUtil.noop, + + /** + * @public + * @abstract + */ + getValueState: zrUtil.noop + + }); + + module.exports = VisualMapModel; + + + +/***/ }, +/* 307 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Visual mapping. + */ + + + var zrUtil = __webpack_require__(3); + + var visualDefault = { + + /** + * @public + */ + get: function (visualType, key, isCategory) { + var value = zrUtil.clone( + (defaultOption[visualType] || {})[key] + ); + + return isCategory + ? (zrUtil.isArray(value) ? value[value.length - 1] : value) + : value; + } + + }; + + var defaultOption = { + + color: { + active: ['#006edd', '#e0ffff'], + inactive: ['rgba(0,0,0,0)'] + }, + + colorHue: { + active: [0, 360], + inactive: [0, 0] + }, + + colorSaturation: { + active: [0.3, 1], + inactive: [0, 0] + }, + + colorLightness: { + active: [0.9, 0.5], + inactive: [0, 0] + }, + + colorAlpha: { + active: [0.3, 1], + inactive: [0, 0] + }, + + symbol: { + active: ['circle', 'roundRect', 'diamond'], + inactive: ['none'] + }, + + symbolSize: { + active: [10, 50], + inactive: [0, 0] + } + }; + + module.exports = visualDefault; + + + + +/***/ }, +/* 308 */ +/***/ function(module, exports, __webpack_require__) { - init: function () { - this._symbolDraw = new SymbolDraw(EffectSymbol); - }, + - render: function (seriesModel, ecModel, api) { - var data = seriesModel.getData(); - var effectSymbolDraw = this._symbolDraw; - effectSymbolDraw.updateData(data); - this.group.add(effectSymbolDraw.group); - }, + var VisualMapView = __webpack_require__(309); + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var sliderMove = __webpack_require__(294); + var linearMap = numberUtil.linearMap; + var LinearGradient = __webpack_require__(75); + var helper = __webpack_require__(310); + var each = zrUtil.each; - updateLayout: function () { - this._symbolDraw.updateLayout(); - }, + // Notice: + // Any "interval" should be by the order of [low, high]. + // "handle0" (handleIndex === 0) maps to + // low data value: this._dataInterval[0] and has low coord. + // "handle1" (handleIndex === 1) maps to + // high data value: this._dataInterval[1] and has high coord. + // The logic of transform is implemented in this._createBarGroup. - remove: function (ecModel, api) { - this._symbolDraw && this._symbolDraw.remove(api); - } - }); -}); -define('echarts/chart/effectScatter',['require','zrender/core/util','../echarts','./effectScatter/EffectScatterSeries','./effectScatter/EffectScatterView','../visual/symbol','../layout/points'],function (require) { + var ContinuousVisualMapView = VisualMapView.extend({ - var zrUtil = require('zrender/core/util'); - var echarts = require('../echarts'); + type: 'visualMap.continuous', + + /** + * @override + */ + init: function () { + + VisualMapView.prototype.init.apply(this, arguments); + + /** + * @private + */ + this._shapes = {}; + + /** + * @private + */ + this._dataInterval = []; + + /** + * @private + */ + this._handleEnds = []; + + /** + * @private + */ + this._orient; + + /** + * @private + */ + this._useHandle; + }, + + /** + * @protected + * @override + */ + doRender: function (visualMapModel, ecModel, api, payload) { + if (!payload || payload.type !== 'selectDataRange' || payload.from !== this.uid) { + this._buildView(); + } + else { + this._updateView(); + } + }, + + /** + * @private + */ + _buildView: function () { + this.group.removeAll(); + + var visualMapModel = this.visualMapModel; + var thisGroup = this.group; + + this._orient = visualMapModel.get('orient'); + this._useHandle = visualMapModel.get('calculable'); + + this._resetInterval(); + + this._renderBar(thisGroup); + + var dataRangeText = visualMapModel.get('text'); + this._renderEndsText(thisGroup, dataRangeText, 0); + this._renderEndsText(thisGroup, dataRangeText, 1); + + // Do this for background size calculation. + this._updateView(true); + + // After updating view, inner shapes is built completely, + // and then background can be rendered. + this.renderBackground(thisGroup); + + // Real update view + this._updateView(); + + this.positionGroup(thisGroup); + }, + + /** + * @private + */ + _renderEndsText: function (group, dataRangeText, endsIndex) { + if (!dataRangeText) { + return; + } + + // Compatible with ec2, text[0] map to high value, text[1] map low value. + var text = dataRangeText[1 - endsIndex]; + text = text != null ? text + '' : ''; + + var visualMapModel = this.visualMapModel; + var textGap = visualMapModel.get('textGap'); + var itemSize = visualMapModel.itemSize; + + var barGroup = this._shapes.barGroup; + var position = this._applyTransform( + [ + itemSize[0] / 2, + endsIndex === 0 ? -textGap : itemSize[1] + textGap + ], + barGroup + ); + var align = this._applyTransform( + endsIndex === 0 ? 'bottom' : 'top', + barGroup + ); + var orient = this._orient; + var textStyleModel = this.visualMapModel.textStyleModel; + + this.group.add(new graphic.Text({ + style: { + x: position[0], + y: position[1], + textVerticalAlign: orient === 'horizontal' ? 'middle' : align, + textAlign: orient === 'horizontal' ? align : 'center', + text: text, + textFont: textStyleModel.getFont(), + fill: textStyleModel.getTextColor() + } + })); + }, + + /** + * @private + */ + _renderBar: function (targetGroup) { + var visualMapModel = this.visualMapModel; + var shapes = this._shapes; + var itemSize = visualMapModel.itemSize; + var orient = this._orient; + var useHandle = this._useHandle; + var itemAlign = helper.getItemAlign(visualMapModel, this.api, itemSize); + var barGroup = shapes.barGroup = this._createBarGroup(itemAlign); + + // Bar + barGroup.add(shapes.outOfRange = createPolygon()); + barGroup.add(shapes.inRange = createPolygon( + null, + zrUtil.bind(this._modifyHandle, this, 'all'), + useHandle ? 'move' : null + )); + + var textRect = visualMapModel.textStyleModel.getTextRect('国'); + var textSize = Math.max(textRect.width, textRect.height); + + // Handle + if (useHandle) { + shapes.handleGroups = []; + shapes.handleThumbs = []; + shapes.handleLabels = []; + shapes.handleLabelPoints = []; + + this._createHandle(barGroup, 0, itemSize, textSize, orient, itemAlign); + this._createHandle(barGroup, 1, itemSize, textSize, orient, itemAlign); + } + + // Indicator + // FIXME + + targetGroup.add(barGroup); + }, + + /** + * @private + */ + _createHandle: function (barGroup, handleIndex, itemSize, textSize, orient) { + var handleGroup = new graphic.Group({position: [itemSize[0], 0]}); + var handleThumb = createPolygon( + createHandlePoints(handleIndex, textSize), + zrUtil.bind(this._modifyHandle, this, handleIndex), + 'move' + ); + handleGroup.add(handleThumb); + + // For text locating. Text is always horizontal layout + // but should not be effected by transform. + var handleLabelPoint = { + x: orient === 'horizontal' + ? textSize / 2 + : textSize * 1.5, + y: orient === 'horizontal' + ? (handleIndex === 0 ? -(textSize * 1.5) : (textSize * 1.5)) + : (handleIndex === 0 ? -textSize / 2 : textSize / 2) + }; + + var textStyleModel = this.visualMapModel.textStyleModel; + var handleLabel = new graphic.Text({ + silent: true, + style: { + x: 0, y: 0, text: '', + textVerticalAlign: 'middle', + textFont: textStyleModel.getFont(), + fill: textStyleModel.getTextColor() + } + }); + + this.group.add(handleLabel); // Text do not transform + + var shapes = this._shapes; + shapes.handleThumbs[handleIndex] = handleThumb; + shapes.handleGroups[handleIndex] = handleGroup; + shapes.handleLabelPoints[handleIndex] = handleLabelPoint; + shapes.handleLabels[handleIndex] = handleLabel; + + barGroup.add(handleGroup); + }, + + /** + * @private + */ + _modifyHandle: function (handleIndex, dx, dy) { + if (!this._useHandle) { + return; + } + + // Transform dx, dy to bar coordination. + var vertex = this._applyTransform([dx, dy], this._shapes.barGroup, true); + this._updateInterval(handleIndex, vertex[1]); + + this.api.dispatchAction({ + type: 'selectDataRange', + from: this.uid, + visualMapId: this.visualMapModel.id, + selected: this._dataInterval.slice() + }); + }, + + /** + * @private + */ + _resetInterval: function () { + var visualMapModel = this.visualMapModel; + + var dataInterval = this._dataInterval = visualMapModel.getSelected(); + var dataExtent = visualMapModel.getExtent(); + var sizeExtent = [0, visualMapModel.itemSize[1]]; + + this._handleEnds = [ + linearMap(dataInterval[0], dataExtent, sizeExtent,true), + linearMap(dataInterval[1], dataExtent, sizeExtent,true) + ]; + }, + + /** + * @private + * @param {(number|string)} handleIndex 0 or 1 or 'all' + * @param {number} dx + * @param {number} dy + */ + _updateInterval: function (handleIndex, delta) { + delta = delta || 0; + var visualMapModel = this.visualMapModel; + var handleEnds = this._handleEnds; + + sliderMove( + delta, + handleEnds, + [0, visualMapModel.itemSize[1]], + handleIndex === 'all' ? 'rigid' : 'push', + handleIndex + ); + var dataExtent = visualMapModel.getExtent(); + var sizeExtent = [0, visualMapModel.itemSize[1]]; + // Update data interval. + this._dataInterval = [ + linearMap(handleEnds[0], sizeExtent, dataExtent, true), + linearMap(handleEnds[1], sizeExtent, dataExtent, true) + ]; + }, + + /** + * @private + */ + _updateView: function (forSketch) { + var visualMapModel = this.visualMapModel; + var dataExtent = visualMapModel.getExtent(); + var shapes = this._shapes; + var dataInterval = this._dataInterval; + + var outOfRangeHandleEnds = [0, visualMapModel.itemSize[1]]; + var inRangeHandleEnds = forSketch ? outOfRangeHandleEnds : this._handleEnds; + + var visualInRange = this._createBarVisual( + dataInterval, dataExtent, inRangeHandleEnds, 'inRange' + ); + var visualOutOfRange = this._createBarVisual( + dataExtent, dataExtent, outOfRangeHandleEnds, 'outOfRange' + ); + + shapes.inRange + .setStyle('fill', visualInRange.barColor) + .setShape('points', visualInRange.barPoints); + shapes.outOfRange + .setStyle('fill', visualOutOfRange.barColor) + .setShape('points', visualOutOfRange.barPoints); + + this._useHandle && each([0, 1], function (handleIndex) { + + shapes.handleThumbs[handleIndex].setStyle( + 'fill', visualInRange.handlesColor[handleIndex] + ); + + shapes.handleLabels[handleIndex].setStyle({ + text: visualMapModel.formatValueText(dataInterval[handleIndex]), + textAlign: this._applyTransform( + this._orient === 'horizontal' + ? (handleIndex === 0 ? 'bottom' : 'top') + : 'left', + shapes.barGroup + ) + }); + + }, this); + + this._updateHandlePosition(inRangeHandleEnds); + }, + + /** + * @private + */ + _createBarVisual: function (dataInterval, dataExtent, handleEnds, forceState) { + var colorStops = this.getControllerVisual(dataInterval, forceState, 'color').color; + + var symbolSizes = [ + this.getControllerVisual(dataInterval[0], forceState, 'symbolSize').symbolSize, + this.getControllerVisual(dataInterval[1], forceState, 'symbolSize').symbolSize + ]; + var barPoints = this._createBarPoints(handleEnds, symbolSizes); + + return { + barColor: new LinearGradient(0, 0, 1, 1, colorStops), + barPoints: barPoints, + handlesColor: [ + colorStops[0].color, + colorStops[colorStops.length - 1].color + ] + }; + }, + + /** + * @private + */ + _createBarPoints: function (handleEnds, symbolSizes) { + var itemSize = this.visualMapModel.itemSize; + + return [ + [itemSize[0] - symbolSizes[0], handleEnds[0]], + [itemSize[0], handleEnds[0]], + [itemSize[0], handleEnds[1]], + [itemSize[0] - symbolSizes[1], handleEnds[1]] + ]; + }, + + /** + * @private + */ + _createBarGroup: function (itemAlign) { + var orient = this._orient; + var inverse = this.visualMapModel.get('inverse'); + + return new graphic.Group( + (orient === 'horizontal' && !inverse) + ? {scale: itemAlign === 'bottom' ? [1, 1] : [-1, 1], rotation: Math.PI / 2} + : (orient === 'horizontal' && inverse) + ? {scale: itemAlign === 'bottom' ? [-1, 1] : [1, 1], rotation: -Math.PI / 2} + : (orient === 'vertical' && !inverse) + ? {scale: itemAlign === 'left' ? [1, -1] : [-1, -1]} + : {scale: itemAlign === 'left' ? [1, 1] : [-1, 1]} + ); + }, + + /** + * @private + */ + _updateHandlePosition: function (handleEnds) { + if (!this._useHandle) { + return; + } + + var shapes = this._shapes; + + each([0, 1], function (handleIndex) { + var handleGroup = shapes.handleGroups[handleIndex]; + handleGroup.position[1] = handleEnds[handleIndex]; + + // Update handle label position. + var labelPoint = shapes.handleLabelPoints[handleIndex]; + var textPoint = graphic.applyTransform( + [labelPoint.x, labelPoint.y], + graphic.getTransform(handleGroup, this.group) + ); + + shapes.handleLabels[handleIndex].setStyle({ + x: textPoint[0], y: textPoint[1] + }); + }, this); + }, + + /** + * @private + */ + _applyTransform: function (vertex, element, inverse) { + var transform = graphic.getTransform(element, this.group); + + return graphic[ + zrUtil.isArray(vertex) + ? 'applyTransform' : 'transformDirection' + ](vertex, transform, inverse); + } + + }); + + function createPolygon(points, onDrift, cursor) { + return new graphic.Polygon({ + shape: {points: points}, + draggable: !!onDrift, + cursor: cursor, + drift: onDrift + }); + } + + function createHandlePoints(handleIndex, textSize) { + return handleIndex === 0 + ? [[0, 0], [textSize, 0], [textSize, -textSize]] + : [[0, 0], [textSize, 0], [textSize, textSize]]; + } + + module.exports = ContinuousVisualMapView; + + + +/***/ }, +/* 309 */ +/***/ function(module, exports, __webpack_require__) { + + + + var echarts = __webpack_require__(1); + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var formatUtil = __webpack_require__(6); + var layout = __webpack_require__(21); + var VisualMapping = __webpack_require__(187); + + module.exports = echarts.extendComponentView({ + + type: 'visualMap', + + /** + * @readOnly + * @type {Object} + */ + autoPositionValues: {left: 1, right: 1, top: 1, bottom: 1}, + + init: function (ecModel, api) { + /** + * @readOnly + * @type {module:echarts/model/Global} + */ + this.ecModel = ecModel; + + /** + * @readOnly + * @type {module:echarts/ExtensionAPI} + */ + this.api = api; + + /** + * @readOnly + * @type {module:echarts/component/visualMap/visualMapModel} + */ + this.visualMapModel; + + /** + * @private + * @type {Object} + */ + this._updatableShapes = {}; + }, + + /** + * @protected + */ + render: function (visualMapModel, ecModel, api, payload) { + this.visualMapModel = visualMapModel; + + if (visualMapModel.get('show') === false) { + this.group.removeAll(); + return; + } + + this.doRender.apply(this, arguments); + }, + + /** + * @protected + */ + renderBackground: function (group) { + var visualMapModel = this.visualMapModel; + var padding = formatUtil.normalizeCssArray(visualMapModel.get('padding') || 0); + var rect = group.getBoundingRect(); + + group.add(new graphic.Rect({ + z2: -1, // Lay background rect on the lowest layer. + silent: true, + shape: { + x: rect.x - padding[3], + y: rect.y - padding[0], + width: rect.width + padding[3] + padding[1], + height: rect.height + padding[0] + padding[2] + }, + style: { + fill: visualMapModel.get('backgroundColor'), + stroke: visualMapModel.get('borderColor'), + lineWidth: visualMapModel.get('borderWidth') + } + })); + }, + + /** + * @protected + * @param {(number|Array)} targetValue + * @param {string=} forceState Specify state, instead of using getValueState method. + * @param {string=} visualCluster Specify visual type, defualt all available visualClusters. + */ + getControllerVisual: function (targetValue, forceState, visualCluster) { + var visualMapModel = this.visualMapModel; + var targetIsArray = zrUtil.isArray(targetValue); + + // targetValue is array when caculate gradient color, + // where forceState is required. + if (targetIsArray && (!forceState || visualCluster !== 'color')) { + throw new Error(targetValue); + } + + var mappings = visualMapModel.controllerVisuals[ + forceState || visualMapModel.getValueState(targetValue) + ]; + var defaultColor = visualMapModel.get('contentColor'); + var visualObj = { + symbol: visualMapModel.get('itemSymbol'), + color: targetIsArray + ? [{color: defaultColor, offset: 0}, {color: defaultColor, offset: 1}] + : defaultColor + }; + + function getter(key) { + return visualObj[key]; + } + + function setter(key, value) { + visualObj[key] = value; + } + + var visualTypes = VisualMapping.prepareVisualTypes(mappings); + + zrUtil.each(visualTypes, function (type) { + var visualMapping = mappings[type]; + if (!visualCluster || VisualMapping.isInVisualCluster(type, visualCluster)) { + visualMapping && visualMapping.applyVisual(targetValue, getter, setter); + } + }); + + return visualObj; + }, + + /** + * @protected + */ + positionGroup: function (group) { + var model = this.visualMapModel; + var api = this.api; + + layout.positionGroup( + group, + model.getBoxLayoutParams(), + {width: api.getWidth(), height: api.getHeight()} + ); + }, + + /** + * @protected + * @abstract + */ + doRender: zrUtil.noop + + }); + + +/***/ }, +/* 310 */ +/***/ function(module, exports, __webpack_require__) { + + + + var layout = __webpack_require__(21); + + var helper = { + + /** + * @param {module:echarts/component/visualMap/VisualMapModel} visualMapModel\ + * @param {module:echarts/ExtensionAPI} api + * @param {Array.} itemSize always [short, long] + * @return {string} 'left' or 'right' or 'top' or 'bottom' + */ + getItemAlign: function (visualMapModel, api, itemSize) { + var modelOption = visualMapModel.option; + var itemAlign = modelOption.align; - require('./effectScatter/EffectScatterSeries'); - require('./effectScatter/EffectScatterView'); + if (itemAlign != null && itemAlign !== 'auto') { + return itemAlign; + } - echarts.registerVisualCoding('chart', zrUtil.curry( - require('../visual/symbol'), 'effectScatter', 'circle', null - )); - echarts.registerLayout(zrUtil.curry( - require('../layout/points'), 'effectScatter' - )); -}); -define('echarts/chart/lines/LinesSeries',['require','../../model/Series','../../data/List','zrender/core/util','../../CoordinateSystem'],function (require) { - - - - var SeriesModel = require('../../model/Series'); - var List = require('../../data/List'); - var zrUtil = require('zrender/core/util'); - var CoordinateSystem = require('../../CoordinateSystem'); - - return SeriesModel.extend({ - - type: 'series.lines', - - dependencies: ['grid', 'polar'], - - getInitialData: function (option, ecModel) { - var fromDataArr = []; - var toDataArr = []; - var lineDataArr = []; - zrUtil.each(option.data, function (opt) { - fromDataArr.push(opt[0]); - toDataArr.push(opt[1]); - lineDataArr.push(zrUtil.extend( - zrUtil.extend({}, zrUtil.isArray(opt[0]) ? null : opt[0]), - zrUtil.isArray(opt[1]) ? null : opt[1] - )); - }); - - // var coordSys = option.coordinateSystem; - // if (coordSys !== 'cartesian2d' && coordSys !== 'geo') { - // throw new Error('Coordinate system can only be cartesian2d or geo in lines'); - // } - - // var dimensions = coordSys === 'geo' ? ['lng', 'lat'] : ['x', 'y']; - var coordSys = CoordinateSystem.get(option.coordinateSystem); - if (!coordSys) { - throw new Error('Invalid coordinate system'); - } - var dimensions = coordSys.dimensions; - - var fromData = new List(dimensions, this); - var toData = new List(dimensions, this); - var lineData = new List(['value'], this); - - function geoCoordGetter(item, dim, dataIndex, dimIndex) { - return item.coord && item.coord[dimIndex]; - } - - fromData.initData(fromDataArr, null, geoCoordGetter); - toData.initData(toDataArr, null, geoCoordGetter); - lineData.initData(lineDataArr); - - this.fromData = fromData; - this.toData = toData; - - return lineData; - }, - - formatTooltip: function (dataIndex) { - var fromName = this.fromData.getName(dataIndex); - var toName = this.toData.getName(dataIndex); - return fromName + ' > ' + toName; - }, - - defaultOption: { - coordinateSystem: 'geo', - zlevel: 0, - z: 2, - legendHoverLink: true, - - hoverAnimation: true, - // Cartesian coordinate system - xAxisIndex: 0, - yAxisIndex: 0, - - // Geo coordinate system - geoIndex: 0, - - // symbol: null, - // symbolSize: 10, - // symbolRotate: null, - - effect: { - show: false, - period: 4, - symbol: 'circle', - symbolSize: 3, - // Length of trail, 0 - 1 - trailLength: 0.2 - // Same with lineStyle.normal.color - // color - }, - - large: false, - // Available when large is true - largeThreshold: 2000, - - label: { - normal: { - show: false, - position: 'end' - // distance: 5, - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - } - }, - // itemStyle: { - // normal: { - // } - // }, - lineStyle: { - normal: { - opacity: 0.5 - } - } - } - }); -}); -/** - * @module echarts/chart/helper/EffectLine - */ -define('echarts/chart/helper/EffectLine',['require','../../util/graphic','./Line','zrender/core/util','../../util/symbol','zrender/core/curve'],function (require) { - - var graphic = require('../../util/graphic'); - var Line = require('./Line'); - var zrUtil = require('zrender/core/util'); - var symbolUtil = require('../../util/symbol'); - - var curveUtil = require('zrender/core/curve'); - - /** - * @constructor - * @extends {module:zrender/graphic/Group} - * @alias {module:echarts/chart/helper/Line} - */ - function EffectLine(lineData, fromData, toData, idx) { - graphic.Group.call(this); - - var line = new Line(lineData, fromData, toData, idx); - this.add(line); - - this._updateEffectSymbol(lineData, idx); - } - - var effectLineProto = EffectLine.prototype; - - function setAnimationPoints(symbol, points) { - symbol.__p1 = points[0]; - symbol.__p2 = points[1]; - symbol.__cp1 = points[2] || [ - (points[0][0] + points[1][0]) / 2, - (points[0][1] + points[1][1]) / 2 - ]; - } - - function updateSymbolPosition() { - var p1 = this.__p1; - var p2 = this.__p2; - var cp1 = this.__cp1; - var t = this.__t; - var pos = this.position; - var quadraticAt = curveUtil.quadraticAt; - var quadraticDerivativeAt = curveUtil.quadraticDerivativeAt; - pos[0] = quadraticAt(p1[0], cp1[0], p2[0], t); - pos[1] = quadraticAt(p1[1], cp1[1], p2[1], t); - - // Tangent - var tx = quadraticDerivativeAt(p1[0], cp1[0], p2[0], t); - var ty = quadraticDerivativeAt(p1[1], cp1[1], p2[1], t); - - this.rotation = -Math.atan2(ty, tx) - Math.PI / 2; - - this.ignore = false; - } - - effectLineProto._updateEffectSymbol = function (lineData, idx) { - var itemModel = lineData.getItemModel(idx); - var effectModel = itemModel.getModel('effect'); - var size = effectModel.get('symbolSize'); - var symbolType = effectModel.get('symbol'); - if (!zrUtil.isArray(size)) { - size = [size, size]; - } - var color = effectModel.get('color') || lineData.getItemVisual(idx, 'color'); - var symbol = this.childAt(1); - var period = effectModel.get('period') * 1000; - if (this._symbolType !== symbolType || period !== this._period) { - symbol = symbolUtil.createSymbol( - symbolType, -0.5, -0.5, 1, 1, color - ); - symbol.ignore = true; - symbol.z2 = 100; - this._symbolType = symbolType; - this._period = period; - - this.add(symbol); - - symbol.__t = 0; - symbol.animate('', true) - .when(period, { - __t: 1 - }) - .delay(idx / lineData.count() * period / 2) - .during(zrUtil.bind(updateSymbolPosition, symbol)) - .start(); - } - // Shadow color is same with color in default - symbol.setStyle('shadowColor', color); - symbol.setStyle(effectModel.getItemStyle(['color'])); - - symbol.attr('scale', size); - var points = lineData.getItemLayout(idx); - setAnimationPoints(symbol, points); - - symbol.setColor(color); - symbol.attr('scale', size); - }; - - effectLineProto.updateData = function (lineData, fromData, toData, idx) { - this.childAt(0).updateData(lineData, fromData, toData, idx); - this._updateEffectSymbol(lineData, idx); - }; - - effectLineProto.updateLayout = function (lineData, fromData, toData, idx) { - this.childAt(0).updateLayout(lineData, fromData, toData, idx); - var symbol = this.childAt(1); - var points = lineData.getItemLayout(idx); - setAnimationPoints(symbol, points); - }; - - zrUtil.inherits(EffectLine, graphic.Group); - - return EffectLine; -}); -define('echarts/chart/lines/LinesView',['require','../helper/LineDraw','../helper/EffectLine','../helper/Line','../../echarts'],function (require) { - - var LineDraw = require('../helper/LineDraw'); - var EffectLine = require('../helper/EffectLine'); - var Line = require('../helper/Line'); - - require('../../echarts').extendChartView({ - - type: 'lines', - - init: function () {}, - - render: function (seriesModel, ecModel, api) { - var data = seriesModel.getData(); - var lineDraw = this._lineDraw; - - var hasEffect = seriesModel.get('effect.show'); - if (hasEffect !== this._hasEffet) { - if (lineDraw) { - lineDraw.remove(); - } - lineDraw = this._lineDraw = new LineDraw( - hasEffect ? EffectLine : Line - ); - this._hasEffet = hasEffect; - } - - var zlevel = seriesModel.get('zlevel'); - var trailLength = seriesModel.get('effect.trailLength'); - - var zr = api.getZr(); - // Avoid the drag cause ghost shadow - // FIXME Better way ? - zr.painter.getLayer(zlevel).clear(true); - // Config layer with motion blur - if (this._lastZlevel != null) { - zr.configLayer(this._lastZlevel, { - motionBlur: false - }); - } - if (hasEffect && trailLength) { - zr.configLayer(zlevel, { - motionBlur: true, - lastFrameAlpha: Math.max(Math.min(trailLength / 10 + 0.9, 1), 0) - }); - } - - this.group.add(lineDraw.group); - - lineDraw.updateData(data); - - this._lastZlevel = zlevel; - }, - - updateLayout: function (seriesModel, ecModel, api) { - this._lineDraw.updateLayout(); - // Not use motion when dragging or zooming - var zr = api.getZr(); - zr.painter.getLayer(this._lastZlevel).clear(true); - }, - - remove: function (ecModel, api) { - this._lineDraw && this._lineDraw.remove(api, true); - } - }); -}); -define('echarts/chart/lines/linesLayout',['require'],function (require) { - - return function (ecModel) { - ecModel.eachSeriesByType('lines', function (seriesModel) { - var coordSys = seriesModel.coordinateSystem; - var fromData = seriesModel.fromData; - var toData = seriesModel.toData; - var lineData = seriesModel.getData(); - - var dims = coordSys.dimensions; - fromData.each(dims, function (x, y, idx) { - fromData.setItemLayout(idx, coordSys.dataToPoint([x, y])); - }); - toData.each(dims, function (x, y, idx) { - toData.setItemLayout(idx, coordSys.dataToPoint([x, y])); - }); - lineData.each(function (idx) { - var p1 = fromData.getItemLayout(idx); - var p2 = toData.getItemLayout(idx); - var curveness = lineData.getItemModel(idx).get('lineStyle.normal.curveness'); - var cp1; - if (curveness > 0) { - cp1 = [ - (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * curveness, - (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * curveness - ]; - } - lineData.setItemLayout(idx, [p1, p2, cp1]); - }); - }); - }; -}); -define('echarts/chart/lines',['require','./lines/LinesSeries','./lines/LinesView','zrender/core/util','../echarts','./lines/linesLayout','../visual/seriesColor'],function (require) { + // Auto decision align. + var ecSize = {width: api.getWidth(), height: api.getHeight()}; + var realIndex = modelOption.orient === 'horizontal' ? 1 : 0; - require('./lines/LinesSeries'); - require('./lines/LinesView'); + var paramsSet = [ + ['left', 'right', 'width'], + ['top', 'bottom', 'height'] + ]; + var reals = paramsSet[realIndex]; + var fakeValue = [0, null, 10]; + + var layoutInput = {}; + for (var i = 0; i < 3; i++) { + layoutInput[paramsSet[1 - realIndex][i]] = fakeValue[i]; + layoutInput[reals[i]] = i === 2 ? itemSize[0] : modelOption[reals[i]]; + } + + var rParam = [['x', 'width', 3], ['y', 'height', 0]][realIndex]; + var rect = layout.getLayoutRect(layoutInput, ecSize, modelOption.padding); + + return reals[ + (rect.margin[rParam[2]] || 0) + rect[rParam[0]] + rect[rParam[1]] * 0.5 + < ecSize[rParam[1]] * 0.5 ? 0 : 1 + ]; + } + }; + + module.exports = helper; + + + +/***/ }, +/* 311 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Data range action + */ + + + var echarts = __webpack_require__(1); + + var actionInfo = { + type: 'selectDataRange', + event: 'dataRangeSelected', + // FIXME use updateView appears wrong + update: 'update' + }; + + echarts.registerAction(actionInfo, function (payload, ecModel) { + + ecModel.eachComponent({mainType: 'visualMap', query: payload}, function (model) { + model.setSelected(payload.selected); + }); + + }); + + + +/***/ }, +/* 312 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * DataZoom component entry + */ + + + __webpack_require__(1).registerPreprocessor( + __webpack_require__(302) + ); + + __webpack_require__(303); + __webpack_require__(304); + __webpack_require__(313); + __webpack_require__(314); + __webpack_require__(311); + + + +/***/ }, +/* 313 */ +/***/ function(module, exports, __webpack_require__) { + + + + var VisualMapModel = __webpack_require__(306); + var zrUtil = __webpack_require__(3); + var VisualMapping = __webpack_require__(187); + + var PiecewiseModel = VisualMapModel.extend({ + + type: 'visualMap.piecewise', + + /** + * Order Rule: + * + * option.categories / option.pieces / option.text / option.selected: + * If !option.inverse, + * Order when vertical: ['top', ..., 'bottom']. + * Order when horizontal: ['left', ..., 'right']. + * If option.inverse, the meaning of + * the order should be reversed. + * + * this._pieceList: + * The order is always [low, ..., high]. + * + * Mapping from location to low-high: + * If !option.inverse + * When vertical, top is high. + * When horizontal, right is high. + * If option.inverse, reverse. + */ + + /** + * @protected + */ + defaultOption: { + selected: null, // Object. If not specified, means selected. + // When pieces and splitNumber: {'0': true, '5': true} + // When categories: {'cate1': false, 'cate3': true} + // When selected === false, means all unselected. + align: 'auto', // 'auto', 'left', 'right' + itemWidth: 20, // 值域图形宽度 + itemHeight: 14, // 值域图形高度 + itemSymbol: 'roundRect', + pieceList: null, // 值顺序:由高到低, item can be: + // {min, max, value, color, colorSaturation, colorAlpha, symbol, symbolSize} + categories: null, // 描述 category 数据。如:['some1', 'some2', 'some3'],设置后,min max失效。 + splitNumber: 5, // 分割段数,默认为5,为0时为线性渐变 (continous) + selectedMode: 'multiple', + itemGap: 10 // 各个item之间的间隔,单位px,默认为10, + // 横向布局时为水平间隔,纵向布局时为纵向间隔 + }, + + /** + * @override + */ + doMergeOption: function (newOption, isInit) { + PiecewiseModel.superApply(this, 'doMergeOption', arguments); + + /** + * The order is always [low, ..., high]. + * [{text: string, interval: Array.}, ...] + * @private + * @type {Array.} + */ + this._pieceList = []; + + this.resetTargetSeries(newOption, isInit); + this.resetExtent(); + + /** + * 'pieces', 'categories', 'splitNumber' + * @type {string} + */ + var mode = this._mode = this._decideMode(); + + resetMethods[this._mode].call(this); + + this._resetSelected(newOption, isInit); + + var categories = this.option.categories; + this.resetVisual(function (mappingOption, state) { + if (mode === 'categories') { + mappingOption.mappingMethod = 'category'; + mappingOption.categories = zrUtil.clone(categories); + } + else { + mappingOption.mappingMethod = 'piecewise'; + mappingOption.pieceList = zrUtil.map(this._pieceList, function (piece) { + var piece = zrUtil.clone(piece); + if (state !== 'inRange') { + piece.visual = null; + } + return piece; + }); + } + }); + }, + + _resetSelected: function (newOption, isInit) { + var thisOption = this.option; + var pieceList = this._pieceList; + + // Selected do not merge but all override. + var selected = (isInit ? thisOption : newOption).selected || {}; + thisOption.selected = selected; + + // Consider 'not specified' means true. + zrUtil.each(pieceList, function (piece, index) { + var key = this.getSelectedMapKey(piece); + if (!(key in selected)) { + selected[key] = true; + } + }, this); + + if (thisOption.selectedMode === 'single') { + // Ensure there is only one selected. + var hasSel = false; + + zrUtil.each(pieceList, function (piece, index) { + var key = this.getSelectedMapKey(piece); + if (selected[key]) { + hasSel + ? (selected[key] = false) + : (hasSel = true); + } + }, this); + } + // thisOption.selectedMode === 'multiple', default: all selected. + }, + + /** + * @public + */ + getSelectedMapKey: function (piece) { + return this._mode === 'categories' + ? piece.value + '' : piece.index + ''; + }, + + /** + * @public + */ + getPieceList: function () { + return this._pieceList; + }, + + /** + * @private + * @return {string} + */ + _decideMode: function () { + var option = this.option; + + return option.pieces && option.pieces.length > 0 + ? 'pieces' + : this.option.categories + ? 'categories' + : 'splitNumber'; + }, + + /** + * @public + * @override + */ + setSelected: function (selected) { + this.option.selected = zrUtil.clone(selected); + }, + + /** + * @public + * @override + */ + getValueState: function (value) { + var pieceList = this._pieceList; + var index = VisualMapping.findPieceIndex(value, pieceList); + + return index != null + ? (this.option.selected[this.getSelectedMapKey(pieceList[index])] + ? 'inRange' : 'outOfRange' + ) + : 'outOfRange'; + } + + }); + + /** + * Key is this._mode + * @type {Object} + * @this {module:echarts/component/viusalMap/PiecewiseMode} + */ + var resetMethods = { + + splitNumber: function () { + var thisOption = this.option; + var precision = thisOption.precision; + var dataExtent = this.getExtent(); + var splitNumber = thisOption.splitNumber; + splitNumber = Math.max(parseInt(splitNumber, 10), 1); + thisOption.splitNumber = splitNumber; + + var splitStep = (dataExtent[1] - dataExtent[0]) / splitNumber; + // Precision auto-adaption + while (+splitStep.toFixed(precision) !== splitStep && precision < 5) { + precision++; + } + thisOption.precision = precision; + splitStep = +splitStep.toFixed(precision); + + for (var i = 0, curr = dataExtent[0]; i < splitNumber; i++, curr += splitStep) { + var max = i === splitNumber - 1 ? dataExtent[1] : (curr + splitStep); + + this._pieceList.push({ + text: this.formatValueText([curr, max]), + index: i, + interval: [curr, max] + }); + } + }, + + categories: function () { + var thisOption = this.option; + zrUtil.each(thisOption.categories, function (cate) { + // FIXME category模式也使用pieceList,但在visualMapping中不是使用pieceList。 + // 是否改一致。 + this._pieceList.push({ + text: this.formatValueText(cate, true), + value: cate + }); + }, this); + + // See "Order Rule". + normalizeReverse(thisOption, this._pieceList); + }, + + pieces: function () { + var thisOption = this.option; + zrUtil.each(thisOption.pieces, function (pieceListItem, index) { + + if (!zrUtil.isObject(pieceListItem)) { + pieceListItem = {value: pieceListItem}; + } + + var item = {text: '', index: index}; + var hasLabel; + + if (pieceListItem.label != null) { + item.text = pieceListItem.label; + hasLabel = true; + } + + if (pieceListItem.hasOwnProperty('value')) { + item.value = pieceListItem.value; + + if (!hasLabel) { + item.text = this.formatValueText(item.value); + } + } + else { + var min = pieceListItem.min; + var max = pieceListItem.max; + min == null && (min = -Infinity); + max == null && (max = Infinity); + if (min === max) { + // Consider: [{min: 5, max: 5, visual: {...}}, {min: 0, max: 5}], + // we use value to lift the priority when min === max + item.value = min; + } + item.interval = [min, max]; + + if (!hasLabel) { + item.text = this.formatValueText([min, max]); + } + } + + item.visual = VisualMapping.retrieveVisuals(pieceListItem); + + this._pieceList.push(item); + + }, this); + + // See "Order Rule". + normalizeReverse(thisOption, this._pieceList); + } + }; + + function normalizeReverse(thisOption, arr) { + var inverse = thisOption.inverse; + if (thisOption.orient === 'vertical' ? !inverse : inverse) { + arr.reverse(); + } + } + + module.exports = PiecewiseModel; + + + +/***/ }, +/* 314 */ +/***/ function(module, exports, __webpack_require__) { + + + + var VisualMapView = __webpack_require__(309); + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var symbolCreators = __webpack_require__(100); + var layout = __webpack_require__(21); + var helper = __webpack_require__(310); + + var PiecewiseVisualMapView = VisualMapView.extend({ + + type: 'visualMap.piecewise', + + /** + * @protected + * @override + */ + doRender: function () { + var thisGroup = this.group; + + thisGroup.removeAll(); + + var visualMapModel = this.visualMapModel; + var textGap = visualMapModel.get('textGap'); + var textStyleModel = visualMapModel.textStyleModel; + var textFont = textStyleModel.getFont(); + var textFill = textStyleModel.getTextColor(); + var itemAlign = this._getItemAlign(); + var itemSize = visualMapModel.itemSize; + + var viewData = this._getViewData(); + var showLabel = !viewData.endsText; + var showEndsText = !showLabel; + + showEndsText && this._renderEndsText(thisGroup, viewData.endsText[0], itemSize); + + zrUtil.each(viewData.pieceList, renderItem, this); + + showEndsText && this._renderEndsText(thisGroup, viewData.endsText[1], itemSize); + + layout.box( + visualMapModel.get('orient'), thisGroup, visualMapModel.get('itemGap') + ); + + this.renderBackground(thisGroup); + + this.positionGroup(thisGroup); + + function renderItem(item) { + var itemGroup = new graphic.Group(); + itemGroup.onclick = zrUtil.bind(this._onItemClick, this, item.piece); + + this._createItemSymbol(itemGroup, item.piece, [0, 0, itemSize[0], itemSize[1]]); + + if (showLabel) { + itemGroup.add(new graphic.Text({ + style: { + x: itemAlign === 'right' ? -textGap : itemSize[0] + textGap, + y: itemSize[1] / 2, + text: item.piece.text, + textVerticalAlign: 'middle', + textAlign: itemAlign, + textFont: textFont, + fill: textFill + } + })); + } + + thisGroup.add(itemGroup); + } + }, + + /** + * @private + */ + _getItemAlign: function () { + var visualMapModel = this.visualMapModel; + var modelOption = visualMapModel.option; + if (modelOption.orient === 'vertical') { + return helper.getItemAlign( + visualMapModel, this.api, visualMapModel.itemSize + ); + } + else { // horizontal, most case left unless specifying right. + var align = modelOption.align; + if (!align || align === 'auto') { + align = 'left'; + } + return align; + } + }, + + /** + * @private + */ + _renderEndsText: function (group, text, itemSize) { + if (!text) { + return; + } + var itemGroup = new graphic.Group(); + var textStyleModel = this.visualMapModel.textStyleModel; + itemGroup.add(new graphic.Text({ + style: { + x: itemSize[0] / 2, + y: itemSize[1] / 2, + textVerticalAlign: 'middle', + textAlign: 'center', + text: text, + textFont: textStyleModel.getFont(), + fill: textStyleModel.getTextColor() + } + })); + + group.add(itemGroup); + }, + + /** + * @private + * @return {Object} {peiceList, endsText} The order is the same as screen pixel order. + */ + _getViewData: function () { + var visualMapModel = this.visualMapModel; + + var pieceList = zrUtil.map(visualMapModel.getPieceList(), function (piece, index) { + return {piece: piece, index: index}; + }); + var endsText = visualMapModel.get('text'); + + // Consider orient and inverse. + var orient = visualMapModel.get('orient'); + var inverse = visualMapModel.get('inverse'); + + // Order of pieceList is always [low, ..., high] + if (orient === 'horizontal' ? inverse : !inverse) { + pieceList.reverse(); + } + // Origin order of endsText is [high, low] + else if (endsText) { + endsText = endsText.slice().reverse(); + } + + return {pieceList: pieceList, endsText: endsText}; + }, + + /** + * @private + */ + _createItemSymbol: function (group, piece, shapeParam) { + var representValue; + if (this.visualMapModel.isCategory()) { + representValue = piece.value; + } + else { + if (piece.value != null) { + representValue = piece.value; + } + else { + var pieceInterval = piece.interval || []; + representValue = (pieceInterval[0] + pieceInterval[1]) / 2; + } + } + + var visualObj = this.getControllerVisual(representValue); + + group.add(symbolCreators.createSymbol( + visualObj.symbol, + shapeParam[0], shapeParam[1], shapeParam[2], shapeParam[3], + visualObj.color + )); + }, + + /** + * @private + */ + _onItemClick: function (piece) { + var visualMapModel = this.visualMapModel; + var option = visualMapModel.option; + var selected = zrUtil.clone(option.selected); + var newKey = visualMapModel.getSelectedMapKey(piece); + + if (option.selectedMode === 'single') { + selected[newKey] = true; + zrUtil.each(selected, function (o, key) { + selected[key] = key === newKey; + }); + } + else { + selected[newKey] = !selected[newKey]; + } + + this.api.dispatchAction({ + type: 'selectDataRange', + from: this.uid, + visualMapId: this.visualMapModel.id, + selected: selected + }); + } + }); + + module.exports = PiecewiseVisualMapView; + + + +/***/ }, +/* 315 */ +/***/ function(module, exports, __webpack_require__) { + + // HINT Markpoint can't be used too much + + + __webpack_require__(316); + __webpack_require__(317); + + __webpack_require__(1).registerPreprocessor(function (opt) { + // Make sure markPoint component is enabled + opt.markPoint = opt.markPoint || {}; + }); + + +/***/ }, +/* 316 */ +/***/ function(module, exports, __webpack_require__) { + + + // Default enable markPoint + // var globalDefault = require('../../model/globalDefault'); + var modelUtil = __webpack_require__(5); + // // Force to load markPoint component + // globalDefault.markPoint = {}; + + var MarkPointModel = __webpack_require__(1).extendComponentModel({ + + type: 'markPoint', + + dependencies: ['series', 'grid', 'polar'], + /** + * @overrite + */ + init: function (option, parentModel, ecModel, extraOpt) { + this.mergeDefaultAndTheme(option, ecModel); + this.mergeOption(option, ecModel, extraOpt.createdBySelf, true); + }, + + mergeOption: function (newOpt, ecModel, createdBySelf, isInit) { + if (!createdBySelf) { + ecModel.eachSeries(function (seriesModel) { + var markPointOpt = seriesModel.get('markPoint'); + var mpModel = seriesModel.markPointModel; + if (!markPointOpt || !markPointOpt.data) { + seriesModel.markPointModel = null; + return; + } + if (!mpModel) { + if (isInit) { + // Default label emphasis `position` and `show` + modelUtil.defaultEmphasis( + markPointOpt.label, + ['position', 'show', 'textStyle', 'distance', 'formatter'] + ); + } + var opt = { + // Use the same series index and name + seriesIndex: seriesModel.seriesIndex, + name: seriesModel.name, + createdBySelf: true + }; + mpModel = new MarkPointModel( + markPointOpt, this, ecModel, opt + ); + } + else { + mpModel.mergeOption(markPointOpt, ecModel, true); + } + seriesModel.markPointModel = mpModel; + }, this); + } + }, + + defaultOption: { + zlevel: 0, + z: 5, + symbol: 'pin', // 标注类型 + symbolSize: 50, // 标注大小 + // symbolRotate: null, // 标注旋转控制 + tooltip: { + trigger: 'item' + }, + label: { + normal: { + show: true, + // 标签文本格式器,同Tooltip.formatter,不支持回调 + // formatter: null, + // 可选为'left'|'right'|'top'|'bottom' + position: 'inside' + // 默认使用全局文本样式,详见TEXTSTYLE + // textStyle: null + }, + emphasis: { + show: true + // 标签文本格式器,同Tooltip.formatter,不支持回调 + // formatter: null, + // position: 'inside' // 'left'|'right'|'top'|'bottom' + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + } + }, + itemStyle: { + normal: { + // color: 各异, + // 标注边线颜色,优先于color + // borderColor: 各异, + // 标注边线线宽,单位px,默认为1 + borderWidth: 2 + }, + emphasis: { + // color: 各异 + } + } + } + }); + + module.exports = MarkPointModel; + + +/***/ }, +/* 317 */ +/***/ function(module, exports, __webpack_require__) { + + + + var SymbolDraw = __webpack_require__(98); + var zrUtil = __webpack_require__(3); + var formatUtil = __webpack_require__(6); + var modelUtil = __webpack_require__(5); + var numberUtil = __webpack_require__(7); + + var addCommas = formatUtil.addCommas; + var encodeHTML = formatUtil.encodeHTML; + + var List = __webpack_require__(94); + + var markerHelper = __webpack_require__(318); + + // FIXME + var markPointFormatMixin = { + getRawDataArray: function () { + return this.option.data; + }, + + formatTooltip: function (dataIndex) { + var data = this.getData(); + var value = this.getRawValue(dataIndex); + var formattedValue = zrUtil.isArray(value) + ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); + var name = data.getName(dataIndex); + return this.name + '
' + + ((name ? encodeHTML(name) + ' : ' : '') + formattedValue); + }, + + getData: function () { + return this._data; + }, + + setData: function (data) { + this._data = data; + } + }; + + zrUtil.defaults(markPointFormatMixin, modelUtil.dataFormatMixin); + + __webpack_require__(1).extendComponentView({ + + type: 'markPoint', + + init: function () { + this._symbolDrawMap = {}; + }, + + render: function (markPointModel, ecModel, api) { + var symbolDrawMap = this._symbolDrawMap; + for (var name in symbolDrawMap) { + symbolDrawMap[name].__keep = false; + } + + ecModel.eachSeries(function (seriesModel) { + var mpModel = seriesModel.markPointModel; + mpModel && this._renderSeriesMP(seriesModel, mpModel, api); + }, this); + + for (var name in symbolDrawMap) { + if (!symbolDrawMap[name].__keep) { + symbolDrawMap[name].remove(); + this.group.remove(symbolDrawMap[name].group); + } + } + }, + + _renderSeriesMP: function (seriesModel, mpModel, api) { + var coordSys = seriesModel.coordinateSystem; + var seriesName = seriesModel.name; + var seriesData = seriesModel.getData(); + + var symbolDrawMap = this._symbolDrawMap; + var symbolDraw = symbolDrawMap[seriesName]; + if (!symbolDraw) { + symbolDraw = symbolDrawMap[seriesName] = new SymbolDraw(); + } + + var mpData = createList(coordSys, seriesModel, mpModel); + var dims = coordSys && coordSys.dimensions; + + // FIXME + zrUtil.mixin(mpModel, markPointFormatMixin); + mpModel.setData(mpData); + + mpData.each(function (idx) { + var itemModel = mpData.getItemModel(idx); + var point; + var xPx = itemModel.getShallow('x'); + var yPx = itemModel.getShallow('y'); + if (xPx != null && yPx != null) { + point = [ + numberUtil.parsePercent(xPx, api.getWidth()), + numberUtil.parsePercent(yPx, api.getHeight()) + ]; + } + // Chart like bar may have there own marker positioning logic + else if (seriesModel.getMarkerPosition) { + // Use the getMarkerPoisition + point = seriesModel.getMarkerPosition( + mpData.getValues(mpData.dimensions, idx) + ); + } + else if (coordSys) { + var x = mpData.get(dims[0], idx); + var y = mpData.get(dims[1], idx); + point = coordSys.dataToPoint([x, y]); + } + + mpData.setItemLayout(idx, point); + + var symbolSize = itemModel.getShallow('symbolSize'); + if (typeof symbolSize === 'function') { + // FIXME 这里不兼容 ECharts 2.x,2.x 貌似参数是整个数据? + symbolSize = symbolSize( + mpModel.getRawValue(idx), mpModel.getDataParams(idx) + ); + } + mpData.setItemVisual(idx, { + symbolSize: symbolSize, + color: itemModel.get('itemStyle.normal.color') + || seriesData.getVisual('color'), + symbol: itemModel.getShallow('symbol') + }); + }); + + // TODO Text are wrong + symbolDraw.updateData(mpData); + this.group.add(symbolDraw.group); + + // Set host model for tooltip + // FIXME + mpData.eachItemGraphicEl(function (el) { + el.traverse(function (child) { + child.hostModel = mpModel; + }); + }); + + symbolDraw.__keep = true; + } + }); + + /** + * @inner + * @param {module:echarts/coord/*} [coordSys] + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/model/Model} mpModel + */ + function createList(coordSys, seriesModel, mpModel) { + var coordDimsInfos = zrUtil.map(coordSys.dimensions, function (coordDim) { + var info = seriesModel.getData().getDimensionInfo( + seriesModel.coordDimToDataDim(coordDim)[0] + ); + info.name = coordDim; + return info; + }); + + var mpData = new List(coordDimsInfos, mpModel); + + if (coordSys) { + mpData.initData( + zrUtil.filter( + zrUtil.map(mpModel.get('data'), zrUtil.curry( + markerHelper.dataTransform, seriesModel + )), + zrUtil.curry(markerHelper.dataFilter, coordSys) + ), + null, + markerHelper.dimValueGetter + ); + } + + return mpData; + } + + + +/***/ }, +/* 318 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var indexOf = zrUtil.indexOf; + + function getPrecision(data, valueAxisDim, dataIndex) { + var precision = -1; + do { + precision = Math.max( + numberUtil.getPrecision(data.get( + valueAxisDim, dataIndex + )), + precision + ); + data = data.stackedOn; + } while (data); + + return precision; + } + + function markerTypeCalculatorWithExtent( + mlType, data, baseDataDim, valueDataDim, baseCoordIndex, valueCoordIndex + ) { + var coordArr = []; + var value = numCalculate(data, valueDataDim, mlType); + + var dataIndex = data.indexOfNearest(valueDataDim, value, true); + coordArr[baseCoordIndex] = data.get(baseDataDim, dataIndex, true); + coordArr[valueCoordIndex] = data.get(valueDataDim, dataIndex, true); + + var precision = getPrecision(data, valueDataDim, dataIndex); + if (precision >= 0) { + coordArr[valueCoordIndex] = +coordArr[valueCoordIndex].toFixed(precision); + } + + return coordArr; + } + + var curry = zrUtil.curry; + // TODO Specified percent + var markerTypeCalculator = { + /** + * @method + * @param {module:echarts/data/List} data + * @param {string} baseAxisDim + * @param {string} valueAxisDim + */ + min: curry(markerTypeCalculatorWithExtent, 'min'), + /** + * @method + * @param {module:echarts/data/List} data + * @param {string} baseAxisDim + * @param {string} valueAxisDim + */ + max: curry(markerTypeCalculatorWithExtent, 'max'), + /** + * @method + * @param {module:echarts/data/List} data + * @param {string} baseAxisDim + * @param {string} valueAxisDim + */ + average: curry(markerTypeCalculatorWithExtent, 'average') + }; + + /** + * Transform markPoint data item to format used in List by do the following + * 1. Calculate statistic like `max`, `min`, `average` + * 2. Convert `item.xAxis`, `item.yAxis` to `item.coord` array + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/coord/*} [coordSys] + * @param {Object} item + * @return {Object} + */ + var dataTransform = function (seriesModel, item) { + var data = seriesModel.getData(); + var coordSys = seriesModel.coordinateSystem; + + // 1. If not specify the position with pixel directly + // 2. If `coord` is not a data array. Which uses `xAxis`, + // `yAxis` to specify the coord on each dimension + if ((isNaN(item.x) || isNaN(item.y)) + && !zrUtil.isArray(item.coord) + && coordSys + ) { + var axisInfo = getAxisInfo(item, data, coordSys, seriesModel); + + // Clone the option + // Transform the properties xAxis, yAxis, radiusAxis, angleAxis, geoCoord to value + item = zrUtil.clone(item); + + if (item.type + && markerTypeCalculator[item.type] + && axisInfo.baseAxis && axisInfo.valueAxis + ) { + var dims = coordSys.dimensions; + var baseCoordIndex = indexOf(dims, axisInfo.baseAxis.dim); + var valueCoordIndex = indexOf(dims, axisInfo.valueAxis.dim); + + item.coord = markerTypeCalculator[item.type]( + data, axisInfo.baseDataDim, axisInfo.valueDataDim, + baseCoordIndex, valueCoordIndex + ); + // Force to use the value of calculated value. + item.value = item.coord[valueCoordIndex]; + } + else { + // FIXME Only has one of xAxis and yAxis. + item.coord = [ + item.xAxis != null ? item.xAxis : item.radiusAxis, + item.yAxis != null ? item.yAxis : item.angleAxis + ]; + } + } + return item; + }; + + var getAxisInfo = function (item, data, coordSys, seriesModel) { + var ret = {}; + + if (item.valueIndex != null || item.valueDim != null) { + ret.valueDataDim = item.valueIndex != null + ? data.getDimension(item.valueIndex) : item.valueDim; + ret.valueAxis = coordSys.getAxis(seriesModel.dataDimToCoordDim(ret.valueDataDim)); + ret.baseAxis = coordSys.getOtherAxis(ret.valueAxis); + ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0]; + } + else { + ret.baseAxis = seriesModel.getBaseAxis(); + ret.valueAxis = coordSys.getOtherAxis(ret.baseAxis); + ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0]; + ret.valueDataDim = seriesModel.coordDimToDataDim(ret.valueAxis.dim)[0]; + } + + return ret; + }; + + /** + * Filter data which is out of coordinateSystem range + * [dataFilter description] + * @param {module:echarts/coord/*} [coordSys] + * @param {Object} item + * @return {boolean} + */ + var dataFilter = function (coordSys, item) { + // Alwalys return true if there is no coordSys + return (coordSys && item.coord && (item.x == null || item.y == null)) + ? coordSys.containData(item.coord) : true; + }; + + var dimValueGetter = function (item, dimName, dataIndex, dimIndex) { + // x, y, radius, angle + if (dimIndex < 2) { + return item.coord && item.coord[dimIndex]; + } + else { + item.value; + } + }; + + var numCalculate = function (data, valueDataDim, mlType) { + return mlType === 'average' + ? data.getSum(valueDataDim, true) / data.count() + : data.getDataExtent(valueDataDim, true)[mlType === 'max' ? 1 : 0]; + }; + + module.exports = { + dataTransform: dataTransform, + dataFilter: dataFilter, + dimValueGetter: dimValueGetter, + getAxisInfo: getAxisInfo, + numCalculate: numCalculate + }; + + +/***/ }, +/* 319 */ +/***/ function(module, exports, __webpack_require__) { + + + + __webpack_require__(320); + __webpack_require__(321); + + __webpack_require__(1).registerPreprocessor(function (opt) { + // Make sure markLine component is enabled + opt.markLine = opt.markLine || {}; + }); + + +/***/ }, +/* 320 */ +/***/ function(module, exports, __webpack_require__) { + + + + // Default enable markLine + // var globalDefault = require('../../model/globalDefault'); + var modelUtil = __webpack_require__(5); + + // // Force to load markLine component + // globalDefault.markLine = {}; + + var MarkLineModel = __webpack_require__(1).extendComponentModel({ + + type: 'markLine', + + dependencies: ['series', 'grid', 'polar'], + /** + * @overrite + */ + init: function (option, parentModel, ecModel, extraOpt) { + this.mergeDefaultAndTheme(option, ecModel); + this.mergeOption(option, ecModel, extraOpt.createdBySelf, true); + }, + + mergeOption: function (newOpt, ecModel, createdBySelf, isInit) { + if (!createdBySelf) { + ecModel.eachSeries(function (seriesModel) { + var markLineOpt = seriesModel.get('markLine'); + var mlModel = seriesModel.markLineModel; + if (!markLineOpt || !markLineOpt.data) { + seriesModel.markLineModel = null; + return; + } + if (!mlModel) { + if (isInit) { + // Default label emphasis `position` and `show` + modelUtil.defaultEmphasis( + markLineOpt.label, + ['position', 'show', 'textStyle', 'distance', 'formatter'] + ); + } + var opt = { + // Use the same series index and name + seriesIndex: seriesModel.seriesIndex, + name: seriesModel.name, + createdBySelf: true + }; + mlModel = new MarkLineModel( + markLineOpt, this, ecModel, opt + ); + } + else { + mlModel.mergeOption(markLineOpt, ecModel, true); + } + seriesModel.markLineModel = mlModel; + }, this); + } + }, + + defaultOption: { + zlevel: 0, + z: 5, + // 标线起始和结束的symbol介绍类型,如果都一样,可以直接传string + symbol: ['circle', 'arrow'], + // 标线起始和结束的symbol大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2 + symbolSize: [8, 16], + // 标线起始和结束的symbol旋转控制 + //symbolRotate: null, + //smooth: false, + precision: 2, + tooltip: { + trigger: 'item' + }, + label: { + normal: { + show: true, + // 标签文本格式器,同Tooltip.formatter,不支持回调 + // formatter: null, + // 可选为 'start'|'end'|'left'|'right'|'top'|'bottom' + position: 'end' + // 默认使用全局文本样式,详见TEXTSTYLE + // textStyle: null + }, + emphasis: { + show: true + } + }, + lineStyle: { + normal: { + // color + // width + type: 'dashed' + // shadowColor: 'rgba(0,0,0,0)', + // shadowBlur: 0, + // shadowOffsetX: 0, + // shadowOffsetY: 0 + }, + emphasis: { + width: 3 + } + }, + animationEasing: 'linear' + } + }); + + module.exports = MarkLineModel; + + +/***/ }, +/* 321 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var List = __webpack_require__(94); + var formatUtil = __webpack_require__(6); + var modelUtil = __webpack_require__(5); + var numberUtil = __webpack_require__(7); + + var addCommas = formatUtil.addCommas; + var encodeHTML = formatUtil.encodeHTML; + + var markerHelper = __webpack_require__(318); + + var LineDraw = __webpack_require__(194); + + var markLineTransform = function (seriesModel, coordSys, mlModel, item) { + var data = seriesModel.getData(); + // Special type markLine like 'min', 'max', 'average' + var mlType = item.type; + + if (!zrUtil.isArray(item) + && (mlType === 'min' || mlType === 'max' || mlType === 'average') + ) { + var axisInfo = markerHelper.getAxisInfo(item, data, coordSys, seriesModel); + + var baseAxisKey = axisInfo.baseAxis.dim + 'Axis'; + var valueAxisKey = axisInfo.valueAxis.dim + 'Axis'; + var baseScaleExtent = axisInfo.baseAxis.scale.getExtent(); + + var mlFrom = zrUtil.clone(item); + var mlTo = {}; + + mlFrom.type = null; + + // FIXME Polar should use circle + mlFrom[baseAxisKey] = baseScaleExtent[0]; + mlTo[baseAxisKey] = baseScaleExtent[1]; + + var value = markerHelper.numCalculate(data, axisInfo.valueDataDim, mlType); + + // Round if axis is cateogry + value = axisInfo.valueAxis.coordToData(axisInfo.valueAxis.dataToCoord(value)); + + var precision = mlModel.get('precision'); + if (precision >= 0) { + value = +value.toFixed(precision); + } + + mlFrom[valueAxisKey] = mlTo[valueAxisKey] = value; + + item = [mlFrom, mlTo, { // Extra option for tooltip and label + type: mlType, + valueIndex: item.valueIndex, + // Force to use the value of calculated value. + value: value + }]; + } + + item = [ + markerHelper.dataTransform(seriesModel, item[0]), + markerHelper.dataTransform(seriesModel, item[1]), + zrUtil.extend({}, item[2]) + ]; + + // Avoid line data type is extended by from(to) data type + item[2].type = item[2].type || ''; + + // Merge from option and to option into line option + zrUtil.merge(item[2], item[0]); + zrUtil.merge(item[2], item[1]); + + return item; + }; + + function markLineFilter(coordSys, item) { + return markerHelper.dataFilter(coordSys, item[0]) + && markerHelper.dataFilter(coordSys, item[1]); + } + + var markLineFormatMixin = { + formatTooltip: function (dataIndex) { + var data = this._data; + var value = this.getRawValue(dataIndex); + var formattedValue = zrUtil.isArray(value) + ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); + var name = data.getName(dataIndex); + return this.name + '
' + + ((name ? encodeHTML(name) + ' : ' : '') + formattedValue); + }, + + getRawDataArray: function () { + return this.option.data; + }, + + getData: function () { + return this._data; + }, + + setData: function (data) { + this._data = data; + } + }; + + zrUtil.defaults(markLineFormatMixin, modelUtil.dataFormatMixin); + + __webpack_require__(1).extendComponentView({ + + type: 'markLine', + + init: function () { + /** + * Markline grouped by series + * @private + * @type {Object} + */ + this._markLineMap = {}; + }, + + render: function (markLineModel, ecModel, api) { + var lineDrawMap = this._markLineMap; + for (var name in lineDrawMap) { + lineDrawMap[name].__keep = false; + } + + ecModel.eachSeries(function (seriesModel) { + var mlModel = seriesModel.markLineModel; + mlModel && this._renderSeriesML(seriesModel, mlModel, ecModel, api); + }, this); + + for (var name in lineDrawMap) { + if (!lineDrawMap[name].__keep) { + this.group.remove(lineDrawMap[name].group); + } + } + }, + + _renderSeriesML: function (seriesModel, mlModel, ecModel, api) { + var coordSys = seriesModel.coordinateSystem; + var seriesName = seriesModel.name; + var seriesData = seriesModel.getData(); + + var lineDrawMap = this._markLineMap; + var lineDraw = lineDrawMap[seriesName]; + if (!lineDraw) { + lineDraw = lineDrawMap[seriesName] = new LineDraw(); + } + this.group.add(lineDraw.group); + + var mlData = createList(coordSys, seriesModel, mlModel); + var dims = coordSys.dimensions; + + var fromData = mlData.from; + var toData = mlData.to; + var lineData = mlData.line; + + // Line data for tooltip and formatter + zrUtil.extend(mlModel, markLineFormatMixin); + mlModel.setData(lineData); + + var symbolType = mlModel.get('symbol'); + var symbolSize = mlModel.get('symbolSize'); + if (!zrUtil.isArray(symbolType)) { + symbolType = [symbolType, symbolType]; + } + if (typeof symbolSize === 'number') { + symbolSize = [symbolSize, symbolSize]; + } + + // Update visual and layout of from symbol and to symbol + mlData.from.each(function (idx) { + var lineModel = lineData.getItemModel(idx); + var mlType = lineModel.get('type'); + var valueIndex = lineModel.get('valueIndex'); + updateDataVisualAndLayout(fromData, idx, true, mlType, valueIndex); + updateDataVisualAndLayout(toData, idx, false, mlType, valueIndex); + }); + + // Update visual and layout of line + lineData.each(function (idx) { + var lineColor = lineData.getItemModel(idx).get('lineStyle.normal.color'); + lineData.setItemVisual(idx, { + color: lineColor || fromData.getItemVisual(idx, 'color') + }); + lineData.setItemLayout(idx, [ + fromData.getItemLayout(idx), + toData.getItemLayout(idx) + ]); + }); + + lineDraw.updateData(lineData, fromData, toData); + + // Set host model for tooltip + // FIXME + mlData.line.eachItemGraphicEl(function (el, idx) { + el.traverse(function (child) { + child.hostModel = mlModel; + }); + }); + + function updateDataVisualAndLayout(data, idx, isFrom, mlType, valueIndex) { + var itemModel = data.getItemModel(idx); + + var point; + var xPx = itemModel.get('x'); + var yPx = itemModel.get('y'); + if (xPx != null && yPx != null) { + point = [ + numberUtil.parsePercent(xPx, api.getWidth()), + numberUtil.parsePercent(yPx, api.getHeight()) + ]; + } + else { + // Chart like bar may have there own marker positioning logic + if (seriesModel.getMarkerPosition) { + // Use the getMarkerPoisition + point = seriesModel.getMarkerPosition( + data.getValues(data.dimensions, idx) + ); + } + else { + var x = data.get(dims[0], idx); + var y = data.get(dims[1], idx); + point = coordSys.dataToPoint([x, y]); + } + // Expand min, max, average line to the edge of grid + // FIXME Glue code + if (mlType && coordSys.type === 'cartesian2d') { + var mlOnAxis = valueIndex != null + ? coordSys.getAxis(valueIndex === 1 ? 'x' : 'y') + : coordSys.getAxesByScale('ordinal')[0]; + if (mlOnAxis && mlOnAxis.onBand) { + point[mlOnAxis.dim === 'x' ? 0 : 1] = + mlOnAxis.toGlobalCoord(mlOnAxis.getExtent()[isFrom ? 0 : 1]); + } + } + } + + data.setItemLayout(idx, point); + + data.setItemVisual(idx, { + symbolSize: itemModel.get('symbolSize') + || symbolSize[isFrom ? 0 : 1], + symbol: itemModel.get('symbol', true) + || symbolType[isFrom ? 0 : 1], + color: itemModel.get('itemStyle.normal.color') + || seriesData.getVisual('color') + }); + } + + lineDraw.__keep = true; + } + }); + + /** + * @inner + * @param {module:echarts/coord/*} coordSys + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/model/Model} mpModel + */ + function createList(coordSys, seriesModel, mlModel) { + + var coordDimsInfos = zrUtil.map(coordSys.dimensions, function (coordDim) { + var info = seriesModel.getData().getDimensionInfo( + seriesModel.coordDimToDataDim(coordDim)[0] + ); + info.name = coordDim; + return info; + }); + var fromData = new List(coordDimsInfos, mlModel); + var toData = new List(coordDimsInfos, mlModel); + // No dimensions + var lineData = new List([], mlModel); + + if (coordSys) { + var optData = zrUtil.filter( + zrUtil.map(mlModel.get('data'), zrUtil.curry( + markLineTransform, seriesModel, coordSys, mlModel + )), + zrUtil.curry(markLineFilter, coordSys) + ); + fromData.initData( + zrUtil.map(optData, function (item) { return item[0]; }), + null, + markerHelper.dimValueGetter + ); + toData.initData( + zrUtil.map(optData, function (item) { return item[1]; }), + null, + markerHelper.dimValueGetter + ); + lineData.initData( + zrUtil.map(optData, function (item) { return item[2]; }) + ); + + } + return { + from: fromData, + to: toData, + line: lineData + }; + } + + +/***/ }, +/* 322 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * DataZoom component entry + */ + + + var echarts = __webpack_require__(1); + + echarts.registerPreprocessor(__webpack_require__(323)); + + __webpack_require__(324); + __webpack_require__(325); + __webpack_require__(326); + __webpack_require__(328); + + + +/***/ }, +/* 323 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Timeline preprocessor + */ + + + var zrUtil = __webpack_require__(3); + + module.exports = function (option) { + var timelineOpt = option && option.timeline; + + if (!zrUtil.isArray(timelineOpt)) { + timelineOpt = timelineOpt ? [timelineOpt] : []; + } + + zrUtil.each(timelineOpt, function (opt) { + if (!opt) { + return; + } + + compatibleEC2(opt); + }); + }; + + function compatibleEC2(opt) { + var type = opt.type; - var zrUtil = require('zrender/core/util'); - var echarts = require('../echarts'); - echarts.registerLayout( - require('./lines/linesLayout') - ); + var ec2Types = {'number': 'value', 'time': 'time'}; + + // Compatible with ec2 + if (ec2Types[type]) { + opt.axisType = ec2Types[type]; + delete opt.type; + } - echarts.registerVisualCoding( - 'chart', zrUtil.curry(require('../visual/seriesColor'), 'lines', 'lineStyle') - ); -}); -define('echarts/chart/heatmap/HeatmapSeries',['require','../../model/Series','../helper/createListFromArray'],function (require) { + transferItem(opt); - var SeriesModel = require('../../model/Series'); - var createListFromArray = require('../helper/createListFromArray'); + if (has(opt, 'controlPosition')) { + var controlStyle = opt.controlStyle || (opt.controlStyle = {}); + if (!has(controlStyle, 'position')) { + controlStyle.position = opt.controlPosition; + } + if (controlStyle.position === 'none' && !has(controlStyle, 'show')) { + controlStyle.show = false; + delete controlStyle.position; + } + delete opt.controlPosition; + } - return SeriesModel.extend({ - type: 'series.heatmap', + zrUtil.each(opt.data || [], function (dataItem) { + if (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem)) { + if (!has(dataItem, 'value') && has(dataItem, 'name')) { + // In ec2, using name as value. + dataItem.value = dataItem.name; + } + transferItem(dataItem); + } + }); + } - getInitialData: function (option, ecModel) { - return createListFromArray(option.data, this, ecModel); - }, + function transferItem(opt) { + var itemStyle = opt.itemStyle || (opt.itemStyle = {}); - defaultOption: { + var itemStyleEmphasis = itemStyle.emphasis || (itemStyle.emphasis = {}); - // Cartesian2D or geo - coordinateSystem: 'cartesian2d', + // Transfer label out + var label = opt.label || (opt.label || {}); + var labelNormal = label.normal || (label.normal = {}); + var excludeLabelAttr = {normal: 1, emphasis: 1}; - zlevel: 0, + zrUtil.each(label, function (value, name) { + if (!excludeLabelAttr[name] && !has(labelNormal, name)) { + labelNormal[name] = value; + } + }); - z: 2, + if (itemStyleEmphasis.label && !has(label, 'emphasis')) { + label.emphasis = itemStyleEmphasis.label; + delete itemStyleEmphasis.label; + } + } - // Cartesian coordinate system - xAxisIndex: 0, - yAxisIndex: 0, + function has(obj, attr) { + return obj.hasOwnProperty(attr); + } - // Geo coordinate system - geoIndex: 0, - blurSize: 30, - pointSize: 20 - } - }); -}); -/** - * @file defines echarts Heatmap Chart - * @author Ovilia (me@zhangwenli.com) - * Inspired by https://github.com/mourner/simpleheat - * - * @module - */ -define('echarts/chart/heatmap/HeatmapLayer',['require','zrender/core/util'],function (require) { - - var GRADIENT_LEVELS = 256; - var zrUtil = require('zrender/core/util'); - - /** - * Heatmap Chart - * - * @class - */ - function Heatmap() { - var canvas = zrUtil.createCanvas(); - this.canvas = canvas; - - this.blurSize = 30; - this.pointSize = 20; - this.opacity = 1; - - this._gradientPixels = {}; - } - - Heatmap.prototype = { - /** - * Renders Heatmap and returns the rendered canvas - * @param {Array} data array of data, each has x, y, value - * @param {number} width canvas width - * @param {number} height canvas height - */ - update: function(data, width, height, normalize, colorFunc, isInRange) { - var brush = this._getBrush(); - var gradientInRange = this._getGradient(data, colorFunc, 'inRange'); - var gradientOutOfRange = this._getGradient(data, colorFunc, 'outOfRange'); - var r = this.pointSize + this.blurSize; - - var canvas = this.canvas; - var ctx = canvas.getContext('2d'); - var len = data.length; - canvas.width = width; - canvas.height = height; - for (var i = 0; i < len; ++i) { - var p = data[i]; - var x = p[0]; - var y = p[1]; - var value = p[2]; - - // calculate alpha using value - var alpha = normalize(value); - - // draw with the circle brush with alpha - ctx.globalAlpha = alpha; - ctx.drawImage(brush, x - r, y - r); - } - - // colorize the canvas using alpha value and set with gradient - var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); - var pixels = imageData.data; - var offset = 0; - var pixelLen = pixels.length; - while(offset < pixelLen) { - var alpha = pixels[offset + 3] / 256; - var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4; - // Simple optimize to ignore the empty data - if (alpha > 0) { - var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange; - pixels[offset++] = gradient[gradientOffset]; - pixels[offset++] = gradient[gradientOffset + 1]; - pixels[offset++] = gradient[gradientOffset + 2]; - pixels[offset++] *= this.opacity * gradient[gradientOffset + 3]; - } - else { - offset += 4; - } - } - ctx.putImageData(imageData, 0, 0); - - return canvas; - }, - - /** - * get canvas of a black circle brush used for canvas to draw later - * @private - * @returns {Object} circle brush canvas - */ - _getBrush: function() { - var brushCanvas = this._brushCanvas || (this._brushCanvas = zrUtil.createCanvas()); - // set brush size - var r = this.pointSize + this.blurSize; - var d = r * 2; - brushCanvas.width = d; - brushCanvas.height = d; - - var ctx = brushCanvas.getContext('2d'); - ctx.clearRect(0, 0, d, d); - - // in order to render shadow without the distinct circle, - // draw the distinct circle in an invisible place, - // and use shadowOffset to draw shadow in the center of the canvas - ctx.shadowOffsetX = d; - ctx.shadowBlur = this.blurSize; - // draw the shadow in black, and use alpha and shadow blur to generate - // color in color map - ctx.shadowColor = '#000'; - - // draw circle in the left to the canvas - ctx.beginPath(); - ctx.arc(-r, r, this.pointSize, 0, Math.PI * 2, true); - ctx.closePath(); - ctx.fill(); - return brushCanvas; - }, - - /** - * get gradient color map - * @private - */ - _getGradient: function (data, colorFunc, state) { - var gradientPixels = this._gradientPixels; - var pixelsSingleState = gradientPixels[state] || (gradientPixels[state] = new Uint8ClampedArray(256 * 4)); - var color = []; - var off = 0; - for (var i = 0; i < 256; i++) { - colorFunc[state](i / 255, true, color); - pixelsSingleState[off++] = color[0]; - pixelsSingleState[off++] = color[1]; - pixelsSingleState[off++] = color[2]; - pixelsSingleState[off++] = color[3]; - } - return pixelsSingleState; - } - }; - - return Heatmap; -}); +/***/ }, +/* 324 */ +/***/ function(module, exports, __webpack_require__) { -define('echarts/chart/heatmap/HeatmapView',['require','../../util/graphic','./HeatmapLayer','zrender/core/util','../../echarts'],function (require) { - - var graphic = require('../../util/graphic'); - var HeatmapLayer = require('./HeatmapLayer'); - var zrUtil = require('zrender/core/util'); - - function getIsInPiecewiseRange(dataExtent, pieceList, selected) { - var dataSpan = dataExtent[1] - dataExtent[0]; - pieceList = zrUtil.map(pieceList, function (piece) { - return { - interval: [ - (piece.interval[0] - dataExtent[0]) / dataSpan, - (piece.interval[1] - dataExtent[0]) / dataSpan - ] - }; - }); - var len = pieceList.length; - var lastIndex = 0; - return function (val) { - // Try to find in the location of the last found - for (var i = lastIndex; i < len; i++) { - var interval = pieceList[i].interval; - if (interval[0] <= val && val <= interval[1]) { - lastIndex = i; - break; - } - } - if (i === len) { // Not found, back interation - for (var i = lastIndex - 1; i >= 0; i--) { - var interval = pieceList[i].interval; - if (interval[0] <= val && val <= interval[1]) { - lastIndex = i; - break; - } - } - } - return i >= 0 && i < len && selected[i]; - }; - } - - function getIsInContinuousRange(dataExtent, range) { - var dataSpan = dataExtent[1] - dataExtent[0]; - range = [ - (range[0] - dataExtent[0]) / dataSpan, - (range[1] - dataExtent[0]) / dataSpan - ]; - return function (val) { - return val >= range[0] && val <= range[1]; - }; - } - - function isGeoCoordSys(coordSys) { - var dimensions = coordSys.dimensions; - // Not use coorSys.type === 'geo' because coordSys maybe extended - return dimensions[0] === 'lng' && dimensions[1] === 'lat'; - } - - return require('../../echarts').extendChartView({ - - type: 'heatmap', - - render: function (seriesModel, ecModel, api) { - var visualMapOfThisSeries; - ecModel.eachComponent('visualMap', function (visualMap) { - visualMap.eachTargetSeries(function (targetSeries) { - if (targetSeries === seriesModel) { - visualMapOfThisSeries = visualMap; - } - }); - }); - - if (!visualMapOfThisSeries) { - throw new Error('Heatmap must use with visualMap'); - } - - this.group.removeAll(); - var coordSys = seriesModel.coordinateSystem; - if (coordSys.type === 'cartesian2d') { - this._renderOnCartesian(coordSys, seriesModel, api); - } - else if (isGeoCoordSys(coordSys)) { - this._renderOnGeo( - coordSys, seriesModel, visualMapOfThisSeries, api - ); - } - }, - - _renderOnCartesian: function (cartesian, seriesModel, api) { - var xAxis = cartesian.getAxis('x'); - var yAxis = cartesian.getAxis('y'); - var group = this.group; - - if (!(xAxis.type === 'category' && yAxis.type === 'category')) { - throw new Error('Heatmap on cartesian must have two category axes'); - } - if (!(xAxis.onBand && yAxis.onBand)) { - throw new Error('Heatmap on cartesian must have two axes with boundaryGap true'); - } - var width = xAxis.getBandWidth(); - var height = yAxis.getBandWidth(); - - var data = seriesModel.getData(); - data.each(['x', 'y', 'z'], function (x, y, z, idx) { - var itemModel = data.getItemModel(idx); - var point = cartesian.dataToPoint([x, y]); - // Ignore empty data - if (isNaN(z)) { - return; - } - var rect = new graphic.Rect({ - shape: { - x: point[0] - width / 2, - y: point[1] - height / 2, - width: width, - height: height - }, - style: { - fill: data.getItemVisual(idx, 'color') - } - }); - var style = itemModel.getModel('itemStyle.normal').getItemStyle(['color']); - var hoverStl = itemModel.getModel('itemStyle.emphasis').getItemStyle(); - var labelModel = itemModel.getModel('label.normal'); - var hoverLabelModel = itemModel.getModel('label.emphasis'); - - var rawValue = seriesModel.getRawValue(idx); - var defaultText = '-'; - if (rawValue && rawValue[2] != null) { - defaultText = rawValue[2]; - } - if (labelModel.get('show')) { - graphic.setText(style, labelModel); - style.text = seriesModel.getFormattedLabel(idx, 'normal') || defaultText; - } - if (hoverLabelModel.get('show')) { - graphic.setText(hoverStl, hoverLabelModel); - hoverStl.text = seriesModel.getFormattedLabel(idx, 'emphasis') || defaultText; - } - - rect.setStyle(style); - - graphic.setHoverStyle(rect, hoverStl); - - group.add(rect); - data.setItemGraphicEl(idx, rect); - }); - }, - - _renderOnGeo: function (geo, seriesModel, visualMapModel, api) { - var inRangeVisuals = visualMapModel.targetVisuals.inRange; - var outOfRangeVisuals = visualMapModel.targetVisuals.outOfRange; - // if (!visualMapping) { - // throw new Error('Data range must have color visuals'); - // } - - var data = seriesModel.getData(); - var hmLayer = this._hmLayer || (this._hmLayer || new HeatmapLayer()); - hmLayer.blurSize = seriesModel.get('blurSize'); - hmLayer.pointSize = seriesModel.get('pointSize'); - - var rect = geo.getViewRect().clone(); - var roamTransform = geo.getRoamTransform(); - rect.applyTransform(roamTransform); - - // Clamp on viewport - var x = Math.max(rect.x, 0); - var y = Math.max(rect.y, 0); - var x2 = Math.min(rect.width + rect.x, api.getWidth()); - var y2 = Math.min(rect.height + rect.y, api.getHeight()); - var width = x2 - x; - var height = y2 - y; - - var points = data.mapArray(['lng', 'lat', 'value'], function (lng, lat, value) { - var pt = geo.dataToPoint([lng, lat]); - pt[0] -= x; - pt[1] -= y; - pt.push(value); - return pt; - }); - - var dataExtent = visualMapModel.getExtent(); - var isInRange = visualMapModel.type === 'visualMap.continuous' - ? getIsInContinuousRange(dataExtent, visualMapModel.option.range) - : getIsInPiecewiseRange( - dataExtent, visualMapModel.getPieceList(), visualMapModel.option.selected - ); - - hmLayer.update( - points, width, height, - inRangeVisuals.color.getNormalizer(), - { - inRange: inRangeVisuals.color.getColorMapper(), - outOfRange: outOfRangeVisuals.color.getColorMapper() - }, - isInRange - ); - var img = new graphic.Image({ - style: { - width: width, - height: height, - x: x, - y: y, - image: hmLayer.canvas - }, - silent: true - }); - this.group.add(img); - } - }); -}); -define('echarts/chart/heatmap',['require','./heatmap/HeatmapSeries','./heatmap/HeatmapView'],function (require) { + - require('./heatmap/HeatmapSeries'); - require('./heatmap/HeatmapView'); -}); -define('echarts/component/geo/GeoView',['require','../helper/MapDraw','../../echarts'],function (require) { + __webpack_require__(19).registerSubTypeDefaulter('timeline', function () { + // Only slider now. + return 'slider'; + }); - - var MapDraw = require('../helper/MapDraw'); - return require('../../echarts').extendComponentView({ +/***/ }, +/* 325 */ +/***/ function(module, exports, __webpack_require__) { - type: 'geo', + /** + * @file Timeilne action + */ + + + var echarts = __webpack_require__(1); + + echarts.registerAction( + + {type: 'timelineChange', event: 'timelineChanged', update: 'prepareAndUpdate'}, + + function (payload, ecModel) { + + var timelineModel = ecModel.getComponent('timeline'); + if (timelineModel && payload.currentIndex != null) { + timelineModel.setCurrentIndex(payload.currentIndex); + + if (!timelineModel.get('loop', true) && timelineModel.isIndexMax()) { + timelineModel.setPlayState(false); + } + } + + ecModel.resetOption('timeline'); + } + ); + + echarts.registerAction( + + {type: 'timelinePlayChange', event: 'timelinePlayChanged', update: 'update'}, + + function (payload, ecModel) { + var timelineModel = ecModel.getComponent('timeline'); + if (timelineModel && payload.playState != null) { + timelineModel.setPlayState(payload.playState); + } + } + ); + + + +/***/ }, +/* 326 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Silder timeline model + */ + + + var TimelineModel = __webpack_require__(327); + + module.exports = TimelineModel.extend({ + + type: 'timeline.slider', + + /** + * @protected + */ + defaultOption: { + + backgroundColor: 'rgba(0,0,0,0)', // 时间轴背景颜色 + borderColor: '#ccc', // 时间轴边框颜色 + borderWidth: 0, // 时间轴边框线宽,单位px,默认为0(无边框) + + orient: 'horizontal', // 'vertical' + inverse: false, + + tooltip: { // boolean or Object + trigger: 'item' // data item may also have tootip attr. + }, + + symbol: 'emptyCircle', + symbolSize: 10, + + lineStyle: { + show: true, + width: 2, + color: '#304654' + }, + label: { // 文本标签 + position: 'auto', // auto left right top bottom + // When using number, label position is not + // restricted by viewRect. + // positive: right/bottom, negative: left/top + normal: { + show: true, + interval: 'auto', + rotate: 0, + // formatter: null, + textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE + color: '#304654' + } + }, + emphasis: { + show: true, + textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE + color: '#c23531' + } + } + }, + itemStyle: { + normal: { + color: '#304654', + borderWidth: 1 + }, + emphasis: { + color: '#c23531' + } + }, + + checkpointStyle: { + symbol: 'circle', + symbolSize: 13, + color: '#c23531', + borderWidth: 5, + borderColor: 'rgba(194,53,49, 0.5)', + animation: true, + animationDuration: 300, + animationEasing: 'quinticInOut' + }, + + controlStyle: { + show: true, + showPlayBtn: true, + showPrevBtn: true, + showNextBtn: true, + itemSize: 22, + itemGap: 12, + position: 'left', // 'left' 'right' 'top' 'bottom' + playIcon: 'path://M31.6,53C17.5,53,6,41.5,6,27.4S17.5,1.8,31.6,1.8C45.7,1.8,57.2,13.3,57.2,27.4S45.7,53,31.6,53z M31.6,3.3 C18.4,3.3,7.5,14.1,7.5,27.4c0,13.3,10.8,24.1,24.1,24.1C44.9,51.5,55.7,40.7,55.7,27.4C55.7,14.1,44.9,3.3,31.6,3.3z M24.9,21.3 c0-2.2,1.6-3.1,3.5-2l10.5,6.1c1.899,1.1,1.899,2.9,0,4l-10.5,6.1c-1.9,1.1-3.5,0.2-3.5-2V21.3z', // jshint ignore:line + stopIcon: 'path://M30.9,53.2C16.8,53.2,5.3,41.7,5.3,27.6S16.8,2,30.9,2C45,2,56.4,13.5,56.4,27.6S45,53.2,30.9,53.2z M30.9,3.5C17.6,3.5,6.8,14.4,6.8,27.6c0,13.3,10.8,24.1,24.101,24.1C44.2,51.7,55,40.9,55,27.6C54.9,14.4,44.1,3.5,30.9,3.5z M36.9,35.8c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H36c0.5,0,0.9,0.4,0.9,1V35.8z M27.8,35.8 c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H27c0.5,0,0.9,0.4,0.9,1L27.8,35.8L27.8,35.8z', // jshint ignore:line + nextIcon: 'path://M18.6,50.8l22.5-22.5c0.2-0.2,0.3-0.4,0.3-0.7c0-0.3-0.1-0.5-0.3-0.7L18.7,4.4c-0.1-0.1-0.2-0.3-0.2-0.5 c0-0.4,0.3-0.8,0.8-0.8c0.2,0,0.5,0.1,0.6,0.3l23.5,23.5l0,0c0.2,0.2,0.3,0.4,0.3,0.7c0,0.3-0.1,0.5-0.3,0.7l-0.1,0.1L19.7,52 c-0.1,0.1-0.3,0.2-0.5,0.2c-0.4,0-0.8-0.3-0.8-0.8C18.4,51.2,18.5,51,18.6,50.8z', // jshint ignore:line + prevIcon: 'path://M43,52.8L20.4,30.3c-0.2-0.2-0.3-0.4-0.3-0.7c0-0.3,0.1-0.5,0.3-0.7L42.9,6.4c0.1-0.1,0.2-0.3,0.2-0.5 c0-0.4-0.3-0.8-0.8-0.8c-0.2,0-0.5,0.1-0.6,0.3L18.3,28.8l0,0c-0.2,0.2-0.3,0.4-0.3,0.7c0,0.3,0.1,0.5,0.3,0.7l0.1,0.1L41.9,54 c0.1,0.1,0.3,0.2,0.5,0.2c0.4,0,0.8-0.3,0.8-0.8C43.2,53.2,43.1,53,43,52.8z', // jshint ignore:line + normal: { + color: '#304654', + borderColor: '#304654', + borderWidth: 1 + }, + emphasis: { + color: '#c23531', + borderColor: '#c23531', + borderWidth: 2 + } + }, + data: [] + } + + }); + + + +/***/ }, +/* 327 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Timeline model + */ + + + var ComponentModel = __webpack_require__(19); + var List = __webpack_require__(94); + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + + var TimelineModel = ComponentModel.extend({ + + type: 'timeline', + + layoutMode: 'box', + + /** + * @protected + */ + defaultOption: { + + zlevel: 0, // 一级层叠 + z: 4, // 二级层叠 + show: true, + + axisType: 'time', // 模式是时间类型,支持 value, category + + realtime: true, + + left: '20%', + top: null, + right: '20%', + bottom: 0, + width: null, + height: 40, + padding: 5, + + controlPosition: 'left', // 'left' 'right' 'top' 'bottom' 'none' + autoPlay: false, + rewind: false, // 反向播放 + loop: true, + playInterval: 2000, // 播放时间间隔,单位ms + + currentIndex: 0, + + itemStyle: { + normal: {}, + emphasis: {} + }, + label: { + normal: { + textStyle: { + color: '#000' + } + }, + emphasis: {} + }, + + data: [] + }, + + /** + * @override + */ + init: function (option, parentModel, ecModel) { + + /** + * @private + * @type {module:echarts/data/List} + */ + this._data; + + /** + * @private + * @type {Array.} + */ + this._names; + + this.mergeDefaultAndTheme(option, ecModel); + this._initData(); + }, + + /** + * @override + */ + mergeOption: function (option) { + TimelineModel.superApply(this, 'mergeOption', arguments); + this._initData(); + }, + + /** + * @param {number} [currentIndex] + */ + setCurrentIndex: function (currentIndex) { + if (currentIndex == null) { + currentIndex = this.option.currentIndex; + } + var count = this._data.count(); + + if (this.option.loop) { + currentIndex = (currentIndex % count + count) % count; + } + else { + currentIndex >= count && (currentIndex = count - 1); + currentIndex < 0 && (currentIndex = 0); + } + + this.option.currentIndex = currentIndex; + }, + + /** + * @return {number} currentIndex + */ + getCurrentIndex: function () { + return this.option.currentIndex; + }, + + /** + * @return {boolean} + */ + isIndexMax: function () { + return this.getCurrentIndex() >= this._data.count() - 1; + }, + + /** + * @param {boolean} state true: play, false: stop + */ + setPlayState: function (state) { + this.option.autoPlay = !!state; + }, + + /** + * @return {boolean} true: play, false: stop + */ + getPlayState: function () { + return !!this.option.autoPlay; + }, + + /** + * @private + */ + _initData: function () { + var thisOption = this.option; + var dataArr = thisOption.data || []; + var axisType = thisOption.axisType; + var names = this._names = []; + + if (axisType === 'category') { + var idxArr = []; + zrUtil.each(dataArr, function (item, index) { + var value = modelUtil.getDataItemValue(item); + var newItem; + + if (zrUtil.isObject(item)) { + newItem = zrUtil.clone(item); + newItem.value = index; + } + else { + newItem = index; + } + + idxArr.push(newItem); + + if (!zrUtil.isString(value) && (value == null || isNaN(value))) { + value = ''; + } + + names.push(value + ''); + }); + dataArr = idxArr; + } + + var dimType = ({category: 'ordinal', time: 'time'})[axisType] || 'number'; + + var data = this._data = new List([{name: 'value', type: dimType}], this); + + data.initData(dataArr, names); + }, + + getData: function () { + return this._data; + }, + + /** + * @public + * @return {Array.} categoreis + */ + getCategories: function () { + if (this.get('axisType') === 'category') { + return this._names.slice(); + } + } + + }); + + module.exports = TimelineModel; + + +/***/ }, +/* 328 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Silder timeline view + */ + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var layout = __webpack_require__(21); + var TimelineView = __webpack_require__(329); + var TimelineAxis = __webpack_require__(330); + var symbolUtil = __webpack_require__(100); + var axisHelper = __webpack_require__(108); + var BoundingRect = __webpack_require__(15); + var matrix = __webpack_require__(17); + var numberUtil = __webpack_require__(7); + var modelUtil = __webpack_require__(5); + var formatUtil = __webpack_require__(6); + var encodeHTML = formatUtil.encodeHTML; + + var bind = zrUtil.bind; + var each = zrUtil.each; + + var PI = Math.PI; + + module.exports = TimelineView.extend({ + + type: 'timeline.slider', + + init: function (ecModel, api) { + + this.api = api; + + /** + * @private + * @type {module:echarts/component/timeline/TimelineAxis} + */ + this._axis; + + /** + * @private + * @type {module:zrender/core/BoundingRect} + */ + this._viewRect; + + /** + * @type {number} + */ + this._timer; + + /** + * @type {module:zrende/Element} + */ + this._currentPointer; + + /** + * @type {module:zrender/container/Group} + */ + this._mainGroup; + + /** + * @type {module:zrender/container/Group} + */ + this._labelGroup; + }, + + /** + * @override + */ + render: function (timelineModel, ecModel, api, payload) { + this.model = timelineModel; + this.api = api; + this.ecModel = ecModel; + + this.group.removeAll(); + + if (timelineModel.get('show', true)) { + + var layoutInfo = this._layout(timelineModel, api); + var mainGroup = this._createGroup('mainGroup'); + var labelGroup = this._createGroup('labelGroup'); + + /** + * @private + * @type {module:echarts/component/timeline/TimelineAxis} + */ + var axis = this._axis = this._createAxis(layoutInfo, timelineModel); + + each( + ['AxisLine', 'AxisTick', 'Control', 'CurrentPointer'], + function (name) { + this['_render' + name](layoutInfo, mainGroup, axis, timelineModel); + }, + this + ); + + this._renderAxisLabel(layoutInfo, labelGroup, axis, timelineModel); + + this._position(layoutInfo, timelineModel); + } + + this._doPlayStop(); + }, + + /** + * @override + */ + remove: function () { + this._clearTimer(); + this.group.removeAll(); + }, + + /** + * @override + */ + dispose: function () { + this._clearTimer(); + }, + + _layout: function (timelineModel, api) { + var labelPosOpt = timelineModel.get('label.normal.position'); + var orient = timelineModel.get('orient'); + var viewRect = getViewRect(timelineModel, api); + // Auto label offset. + if (labelPosOpt == null || labelPosOpt === 'auto') { + labelPosOpt = orient === 'horizontal' + ? ((viewRect.y + viewRect.height / 2) < api.getHeight() / 2 ? '-' : '+') + : ((viewRect.x + viewRect.width / 2) < api.getWidth() / 2 ? '+' : '-'); + } + else if (isNaN(labelPosOpt)) { + labelPosOpt = ({ + horizontal: {top: '-', bottom: '+'}, + vertical: {left: '-', right: '+'} + })[orient][labelPosOpt]; + } + + // FIXME + // 暂没有实现用户传入 + // var labelAlign = timelineModel.get('label.normal.textStyle.align'); + // var labelBaseline = timelineModel.get('label.normal.textStyle.baseline'); + var labelAlignMap = { + horizontal: 'center', + vertical: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'left' : 'right' + }; + + var labelBaselineMap = { + horizontal: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'top' : 'bottom', + vertical: 'middle' + }; + var rotationMap = { + horizontal: 0, + vertical: PI / 2 + }; + + // Position + var mainLength = orient === 'vertical' ? viewRect.height : viewRect.width; + + var controlModel = timelineModel.getModel('controlStyle'); + var showControl = controlModel.get('show'); + var controlSize = showControl ? controlModel.get('itemSize') : 0; + var controlGap = showControl ? controlModel.get('itemGap') : 0; + var sizePlusGap = controlSize + controlGap; + + // Special label rotate. + var labelRotation = timelineModel.get('label.normal.rotate') || 0; + labelRotation = labelRotation * PI / 180; // To radian. + + var playPosition; + var prevBtnPosition; + var nextBtnPosition; + var axisExtent; + var controlPosition = controlModel.get('position', true); + var showControl = controlModel.get('show', true); + var showPlayBtn = showControl && controlModel.get('showPlayBtn', true); + var showPrevBtn = showControl && controlModel.get('showPrevBtn', true); + var showNextBtn = showControl && controlModel.get('showNextBtn', true); + var xLeft = 0; + var xRight = mainLength; + + // position[0] means left, position[1] means middle. + if (controlPosition === 'left' || controlPosition === 'bottom') { + showPlayBtn && (playPosition = [0, 0], xLeft += sizePlusGap); + showPrevBtn && (prevBtnPosition = [xLeft, 0], xLeft += sizePlusGap); + showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap); + } + else { // 'top' 'right' + showPlayBtn && (playPosition = [xRight - controlSize, 0], xRight -= sizePlusGap); + showPrevBtn && (prevBtnPosition = [0, 0], xLeft += sizePlusGap); + showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap); + } + axisExtent = [xLeft, xRight]; + + if (timelineModel.get('inverse')) { + axisExtent.reverse(); + } + + return { + viewRect: viewRect, + mainLength: mainLength, + orient: orient, + + rotation: rotationMap[orient], + labelRotation: labelRotation, + labelPosOpt: labelPosOpt, + labelAlign: labelAlignMap[orient], + labelBaseline: labelBaselineMap[orient], + + // Based on mainGroup. + playPosition: playPosition, + prevBtnPosition: prevBtnPosition, + nextBtnPosition: nextBtnPosition, + axisExtent: axisExtent, + + controlSize: controlSize, + controlGap: controlGap + }; + }, + + _position: function (layoutInfo, timelineModel) { + // Position is be called finally, because bounding rect is needed for + // adapt content to fill viewRect (auto adapt offset). + + // Timeline may be not all in the viewRect when 'offset' is specified + // as a number, because it is more appropriate that label aligns at + // 'offset' but not the other edge defined by viewRect. + + var mainGroup = this._mainGroup; + var labelGroup = this._labelGroup; + + var viewRect = layoutInfo.viewRect; + if (layoutInfo.orient === 'vertical') { + // transfrom to horizontal, inverse rotate by left-top point. + var m = matrix.create(); + var rotateOriginX = viewRect.x; + var rotateOriginY = viewRect.y + viewRect.height; + matrix.translate(m, m, [-rotateOriginX, -rotateOriginY]); + matrix.rotate(m, m, -PI / 2); + matrix.translate(m, m, [rotateOriginX, rotateOriginY]); + viewRect = viewRect.clone(); + viewRect.applyTransform(m); + } + + var viewBound = getBound(viewRect); + var mainBound = getBound(mainGroup.getBoundingRect()); + var labelBound = getBound(labelGroup.getBoundingRect()); + + var mainPosition = mainGroup.position; + var labelsPosition = labelGroup.position; + + labelsPosition[0] = mainPosition[0] = viewBound[0][0]; + + var labelPosOpt = layoutInfo.labelPosOpt; + + if (isNaN(labelPosOpt)) { // '+' or '-' + var mainBoundIdx = labelPosOpt === '+' ? 0 : 1; + toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx); + toBound(labelsPosition, labelBound, viewBound, 1, 1 - mainBoundIdx); + } + else { + var mainBoundIdx = labelPosOpt >= 0 ? 0 : 1; + toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx); + labelsPosition[1] = mainPosition[1] + labelPosOpt; + } + + mainGroup.position = mainPosition; + labelGroup.position = labelsPosition; + mainGroup.rotation = labelGroup.rotation = layoutInfo.rotation; + + setOrigin(mainGroup); + setOrigin(labelGroup); + + function setOrigin(targetGroup) { + var pos = targetGroup.position; + targetGroup.origin = [ + viewBound[0][0] - pos[0], + viewBound[1][0] - pos[1] + ]; + } + + function getBound(rect) { + // [[xmin, xmax], [ymin, ymax]] + return [ + [rect.x, rect.x + rect.width], + [rect.y, rect.y + rect.height] + ]; + } + + function toBound(fromPos, from, to, dimIdx, boundIdx) { + fromPos[dimIdx] += to[dimIdx][boundIdx] - from[dimIdx][boundIdx]; + } + }, + + _createAxis: function (layoutInfo, timelineModel) { + var data = timelineModel.getData(); + var axisType = timelineModel.get('axisType'); + + var scale = axisHelper.createScaleByModel(timelineModel, axisType); + var dataExtent = data.getDataExtent('value'); + scale.setExtent(dataExtent[0], dataExtent[1]); + this._customizeScale(scale, data); + scale.niceTicks(); + + var axis = new TimelineAxis('value', scale, layoutInfo.axisExtent, axisType); + axis.model = timelineModel; + + return axis; + }, + + _customizeScale: function (scale, data) { + + scale.getTicks = function () { + return data.mapArray(['value'], function (value) { + return value; + }); + }; + + scale.getTicksLabels = function () { + return zrUtil.map(this.getTicks(), scale.getLabel, scale); + }; + }, + + _createGroup: function (name) { + var newGroup = this['_' + name] = new graphic.Group(); + this.group.add(newGroup); + return newGroup; + }, + + _renderAxisLine: function (layoutInfo, group, axis, timelineModel) { + var axisExtent = axis.getExtent(); + + if (!timelineModel.get('lineStyle.show')) { + return; + } + + group.add(new graphic.Line({ + shape: { + x1: axisExtent[0], y1: 0, + x2: axisExtent[1], y2: 0 + }, + style: zrUtil.extend( + {lineCap: 'round'}, + timelineModel.getModel('lineStyle').getLineStyle() + ), + silent: true, + z2: 1 + })); + }, + + /** + * @private + */ + _renderAxisTick: function (layoutInfo, group, axis, timelineModel) { + var data = timelineModel.getData(); + var ticks = axis.scale.getTicks(); + var tooltipHostModel = this._prepareTooltipHostModel(data, timelineModel); + + each(ticks, function (value, dataIndex) { + + var tickCoord = axis.dataToCoord(value); + var itemModel = data.getItemModel(dataIndex); + var itemStyleModel = itemModel.getModel('itemStyle.normal'); + var hoverStyleModel = itemModel.getModel('itemStyle.emphasis'); + var symbolOpt = { + position: [tickCoord, 0], + onclick: bind(this._changeTimeline, this, dataIndex) + }; + var el = giveSymbol(itemModel, itemStyleModel, group, symbolOpt); + graphic.setHoverStyle(el, hoverStyleModel.getItemStyle()); + + if (itemModel.get('tooltip')) { + el.dataIndex = dataIndex; + el.hostModel = tooltipHostModel; + } + else { + el.dataIndex = el.hostModel = null; + } + + }, this); + }, + + /** + * @private + */ + _prepareTooltipHostModel: function (data, timelineModel) { + var tooltipHostModel = modelUtil.createDataFormatModel( + {}, data, timelineModel.get('data') + ); + var me = this; + + tooltipHostModel.formatTooltip = function (dataIndex) { + return encodeHTML(me._axis.scale.getLabel(dataIndex)); + }; + + return tooltipHostModel; + }, + + /** + * @private + */ + _renderAxisLabel: function (layoutInfo, group, axis, timelineModel) { + var labelModel = timelineModel.getModel('label.normal'); + + if (!labelModel.get('show')) { + return; + } + + var data = timelineModel.getData(); + var ticks = axis.scale.getTicks(); + var labels = axisHelper.getFormattedLabels( + axis, labelModel.get('formatter') + ); + var labelInterval = axis.getLabelInterval(); + + each(ticks, function (tick, dataIndex) { + if (axis.isLabelIgnored(dataIndex, labelInterval)) { + return; + } + + var itemModel = data.getItemModel(dataIndex); + var itemTextStyleModel = itemModel.getModel('label.normal.textStyle'); + var hoverTextStyleModel = itemModel.getModel('label.emphasis.textStyle'); + var tickCoord = axis.dataToCoord(tick); + var textEl = new graphic.Text({ + style: { + text: labels[dataIndex], + textAlign: layoutInfo.labelAlign, + textVerticalAlign: layoutInfo.labelBaseline, + textFont: itemTextStyleModel.getFont(), + fill: itemTextStyleModel.getTextColor() + }, + position: [tickCoord, 0], + rotation: layoutInfo.labelRotation - layoutInfo.rotation, + onclick: bind(this._changeTimeline, this, dataIndex), + silent: false + }); + + group.add(textEl); + graphic.setHoverStyle(textEl, hoverTextStyleModel.getItemStyle()); + + }, this); + }, + + /** + * @private + */ + _renderControl: function (layoutInfo, group, axis, timelineModel) { + var controlSize = layoutInfo.controlSize; + var rotation = layoutInfo.rotation; + + var itemStyle = timelineModel.getModel('controlStyle.normal').getItemStyle(); + var hoverStyle = timelineModel.getModel('controlStyle.emphasis').getItemStyle(); + var rect = [0, -controlSize / 2, controlSize, controlSize]; + var playState = timelineModel.getPlayState(); + var inverse = timelineModel.get('inverse', true); + + makeBtn( + layoutInfo.nextBtnPosition, + 'controlStyle.nextIcon', + bind(this._changeTimeline, this, inverse ? '-' : '+') + ); + makeBtn( + layoutInfo.prevBtnPosition, + 'controlStyle.prevIcon', + bind(this._changeTimeline, this, inverse ? '+' : '-') + ); + makeBtn( + layoutInfo.playPosition, + 'controlStyle.' + (playState ? 'stopIcon' : 'playIcon'), + bind(this._handlePlayClick, this, !playState), + true + ); + + function makeBtn(position, iconPath, onclick, willRotate) { + if (!position) { + return; + } + var opt = { + position: position, + origin: [controlSize / 2, 0], + rotation: willRotate ? -rotation : 0, + rectHover: true, + style: itemStyle, + onclick: onclick + }; + var btn = makeIcon(timelineModel, iconPath, rect, opt); + group.add(btn); + graphic.setHoverStyle(btn, hoverStyle); + } + }, + + _renderCurrentPointer: function (layoutInfo, group, axis, timelineModel) { + var data = timelineModel.getData(); + var currentIndex = timelineModel.getCurrentIndex(); + var pointerModel = data.getItemModel(currentIndex).getModel('checkpointStyle'); + var me = this; + + var callback = { + onCreate: function (pointer) { + pointer.draggable = true; + pointer.drift = bind(me._handlePointerDrag, me); + pointer.ondragend = bind(me._handlePointerDragend, me); + pointerMoveTo(pointer, currentIndex, axis, timelineModel, true); + }, + onUpdate: function (pointer) { + pointerMoveTo(pointer, currentIndex, axis, timelineModel); + } + }; + + // Reuse when exists, for animation and drag. + this._currentPointer = giveSymbol( + pointerModel, pointerModel, this._mainGroup, {}, this._currentPointer, callback + ); + }, + + _handlePlayClick: function (nextState) { + this._clearTimer(); + this.api.dispatchAction({ + type: 'timelinePlayChange', + playState: nextState, + from: this.uid + }); + }, + + _handlePointerDrag: function (dx, dy, e) { + this._clearTimer(); + this._pointerChangeTimeline([e.offsetX, e.offsetY]); + }, + + _handlePointerDragend: function (e) { + this._pointerChangeTimeline([e.offsetX, e.offsetY], true); + }, + + _pointerChangeTimeline: function (mousePos, trigger) { + var toCoord = this._toAxisCoord(mousePos)[0]; + + var axis = this._axis; + var axisExtent = numberUtil.asc(axis.getExtent().slice()); + + toCoord > axisExtent[1] && (toCoord = axisExtent[1]); + toCoord < axisExtent[0] && (toCoord = axisExtent[0]); + + this._currentPointer.position[0] = toCoord; + this._currentPointer.dirty(); + + var targetDataIndex = this._findNearestTick(toCoord); + var timelineModel = this.model; + + if (trigger || ( + targetDataIndex !== timelineModel.getCurrentIndex() + && timelineModel.get('realtime') + )) { + this._changeTimeline(targetDataIndex); + } + }, + + _doPlayStop: function () { + this._clearTimer(); + + if (this.model.getPlayState()) { + this._timer = setTimeout( + bind(handleFrame, this), + this.model.get('playInterval') + ); + } + + function handleFrame() { + // Do not cache + var timelineModel = this.model; + this._changeTimeline( + timelineModel.getCurrentIndex() + + (timelineModel.get('rewind', true) ? -1 : 1) + ); + } + }, + + _toAxisCoord: function (vertex) { + var trans = this._mainGroup.getLocalTransform(); + return graphic.applyTransform(vertex, trans, true); + }, + + _findNearestTick: function (axisCoord) { + var data = this.model.getData(); + var dist = Infinity; + var targetDataIndex; + var axis = this._axis; + + data.each(['value'], function (value, dataIndex) { + var coord = axis.dataToCoord(value); + var d = Math.abs(coord - axisCoord); + if (d < dist) { + dist = d; + targetDataIndex = dataIndex; + } + }); + + return targetDataIndex; + }, + + _clearTimer: function () { + if (this._timer) { + clearTimeout(this._timer); + this._timer = null; + } + }, + + _changeTimeline: function (nextIndex) { + var currentIndex = this.model.getCurrentIndex(); + + if (nextIndex === '+') { + nextIndex = currentIndex + 1; + } + else if (nextIndex === '-') { + nextIndex = currentIndex - 1; + } + + this.api.dispatchAction({ + type: 'timelineChange', + currentIndex: nextIndex, + from: this.uid + }); + } + + }); + + function getViewRect(model, api) { + return layout.getLayoutRect( + model.getBoxLayoutParams(), + { + width: api.getWidth(), + height: api.getHeight() + }, + model.get('padding') + ); + } + + function makeIcon(timelineModel, objPath, rect, opts) { + var icon = graphic.makePath( + timelineModel.get(objPath).replace(/^path:\/\//, ''), + zrUtil.clone(opts || {}), + new BoundingRect(rect[0], rect[1], rect[2], rect[3]), + 'center' + ); + + return icon; + } + + /** + * Create symbol or update symbol + */ + function giveSymbol(hostModel, itemStyleModel, group, opt, symbol, callback) { + var symbolType = hostModel.get('symbol'); + var color = itemStyleModel.get('color'); + var symbolSize = hostModel.get('symbolSize'); + var halfSymbolSize = symbolSize / 2; + var itemStyle = itemStyleModel.getItemStyle(['color', 'symbol', 'symbolSize']); + + if (!symbol) { + symbol = symbolUtil.createSymbol( + symbolType, -halfSymbolSize, -halfSymbolSize, symbolSize, symbolSize, color + ); + group.add(symbol); + callback && callback.onCreate(symbol); + } + else { + symbol.setStyle(itemStyle); + symbol.setColor(color); + group.add(symbol); // Group may be new, also need to add. + callback && callback.onUpdate(symbol); + } + + opt = zrUtil.merge({ + rectHover: true, + style: itemStyle, + z2: 100 + }, opt, true); + + symbol.attr(opt); + + return symbol; + } + + function pointerMoveTo(pointer, dataIndex, axis, timelineModel, noAnimation) { + if (pointer.dragging) { + return; + } + + var pointerModel = timelineModel.getModel('checkpointStyle'); + var toCoord = axis.dataToCoord(timelineModel.getData().get(['value'], dataIndex)); + + if (noAnimation || !pointerModel.get('animation', true)) { + pointer.attr({position: [toCoord, 0]}); + } + else { + pointer.stopAnimation(true); + pointer.animateTo( + {position: [toCoord, 0]}, + pointerModel.get('animationDuration', true), + pointerModel.get('animationEasing', true) + ); + } + } + + + +/***/ }, +/* 329 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file Timeline view + */ + + + // var zrUtil = require('zrender/lib/core/util'); + // var graphic = require('../../util/graphic'); + var ComponentView = __webpack_require__(28); + + module.exports = ComponentView.extend({ + + type: 'timeline' + }); + + + +/***/ }, +/* 330 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var Axis = __webpack_require__(117); + var axisHelper = __webpack_require__(108); + + /** + * Extend axis 2d + * @constructor module:echarts/coord/cartesian/Axis2D + * @extends {module:echarts/coord/cartesian/Axis} + * @param {string} dim + * @param {*} scale + * @param {Array.} coordExtent + * @param {string} axisType + * @param {string} position + */ + var TimelineAxis = function (dim, scale, coordExtent, axisType) { + + Axis.call(this, dim, scale, coordExtent); + + /** + * Axis type + * - 'category' + * - 'value' + * - 'time' + * - 'log' + * @type {string} + */ + this.type = axisType || 'value'; + + /** + * @private + * @type {number} + */ + this._autoLabelInterval; + + /** + * Axis model + * @param {module:echarts/component/TimelineModel} + */ + this.model = null; + }; - init: function (ecModel, api) { - var mapDraw = new MapDraw(api, true); - this._mapDraw = mapDraw; + TimelineAxis.prototype = { - this.group.add(mapDraw.group); - }, + constructor: TimelineAxis, - render: function (geoModel, ecModel, api) { - geoModel.get('show') && - this._mapDraw.draw(geoModel, ecModel, api); - } - }); -}); -define('echarts/component/geo',['require','../coord/geo/geoCreator','./geo/GeoView','../action/geoRoam'],function (require) { + /** + * @public + * @return {number} + */ + getLabelInterval: function () { + var timelineModel = this.model; + var labelModel = timelineModel.getModel('label.normal'); + var labelInterval = labelModel.get('interval'); - require('../coord/geo/geoCreator'); + if (labelInterval != null && labelInterval != 'auto') { + return labelInterval; + } - require('./geo/GeoView'); + var labelInterval = this._autoLabelInterval; - require('../action/geoRoam'); -}); -define('echarts/component/title',['require','../echarts','../util/graphic','../util/layout'],function(require) { - - - - var echarts = require('../echarts'); - var graphic = require('../util/graphic'); - var layout = require('../util/layout'); - - // Model - echarts.extendComponentModel({ - - type: 'title', - - layoutMode: {type: 'box', ignoreSize: true}, - - defaultOption: { - // 一级层叠 - zlevel: 0, - // 二级层叠 - z: 6, - show: true, - - text: '', - // 超链接跳转 - // link: null, - // 仅支持self | blank - target: 'blank', - subtext: '', - - // 超链接跳转 - // sublink: null, - // 仅支持self | blank - subtarget: 'blank', - - // 'center' ¦ 'left' ¦ 'right' - // ¦ {number}(x坐标,单位px) - left: 0, - // 'top' ¦ 'bottom' ¦ 'center' - // ¦ {number}(y坐标,单位px) - top: 0, - - // 水平对齐 - // 'auto' | 'left' | 'right' - // 默认根据 x 的位置判断是左对齐还是右对齐 - //textAlign: null - - backgroundColor: 'rgba(0,0,0,0)', - - // 标题边框颜色 - borderColor: '#ccc', - - // 标题边框线宽,单位px,默认为0(无边框) - borderWidth: 0, - - // 标题内边距,单位px,默认各方向内边距为5, - // 接受数组分别设定上右下左边距,同css - padding: 5, - - // 主副标题纵向间隔,单位px,默认为10, - itemGap: 10, - textStyle: { - fontSize: 18, - fontWeight: 'bolder', - // 主标题文字颜色 - color: '#333' - }, - subtextStyle: { - // 副标题文字颜色 - color: '#aaa' - } - } - }); - - // View - echarts.extendComponentView({ - - type: 'title', - - render: function (titleModel, ecModel, api) { - this.group.removeAll(); - - if (!titleModel.get('show')) { - return; - } - - var group = this.group; - - var textStyleModel = titleModel.getModel('textStyle'); - var subtextStyleModel = titleModel.getModel('subtextStyle'); - - var textAlign = titleModel.get('textAlign'); - - var textEl = new graphic.Text({ - style: { - text: titleModel.get('text'), - textFont: textStyleModel.getFont(), - fill: textStyleModel.getTextColor(), - textBaseline: 'top' - }, - z2: 10 - }); - - var textRect = textEl.getBoundingRect(); - - var subText = titleModel.get('subtext'); - var subTextEl = new graphic.Text({ - style: { - text: subText, - textFont: subtextStyleModel.getFont(), - fill: subtextStyleModel.getTextColor(), - y: textRect.height + titleModel.get('itemGap'), - textBaseline: 'top' - }, - z2: 10 - }); - - var link = titleModel.get('link'); - var sublink = titleModel.get('sublink'); - - textEl.silent = !link; - subTextEl.silent = !sublink; - - if (link) { - textEl.on('click', function () { - window.open(link, titleModel.get('target')); - }); - } - if (sublink) { - subTextEl.on('click', function () { - window.open(sublink, titleModel.get('subtarget')); - }); - } - - group.add(textEl); - subText && group.add(subTextEl); - // If no subText, but add subTextEl, there will be an empty line. - - var groupRect = group.getBoundingRect(); - var layoutOption = titleModel.getBoxLayoutParams(); - layoutOption.width = groupRect.width; - layoutOption.height = groupRect.height; - var layoutRect = layout.getLayoutRect( - layoutOption, { - width: api.getWidth(), - height: api.getHeight() - }, titleModel.get('padding') - ); - // Adjust text align based on position - if (!textAlign) { - // Align left if title is on the left. center and right is same - textAlign = titleModel.get('left') || titleModel.get('right'); - if (textAlign === 'middle') { - textAlign = 'center'; - } - // Adjust layout by text align - if (textAlign === 'right') { - layoutRect.x += layoutRect.width; - } - else if (textAlign === 'center') { - layoutRect.x += layoutRect.width / 2; - } - } - group.position = [layoutRect.x, layoutRect.y]; - textEl.setStyle('textAlign', textAlign); - subTextEl.setStyle('textAlign', textAlign); - - // Render background - // Get groupRect again because textAlign has been changed - groupRect = group.getBoundingRect(); - var padding = layoutRect.margin; - var style = titleModel.getItemStyle(['color', 'opacity']); - style.fill = titleModel.get('backgroundColor'); - var rect = new graphic.Rect({ - shape: { - x: groupRect.x - padding[3], - y: groupRect.y - padding[0], - width: groupRect.width + padding[1] + padding[3], - height: groupRect.height + padding[0] + padding[2] - }, - style: style, - silent: true - }); - graphic.subPixelOptimizeRect(rect); - - group.add(rect); - } - }); -}); -define('echarts/component/dataZoom/typeDefaulter',['require','../../model/Component'],function (require) { + if (!labelInterval) { + labelInterval = this._autoLabelInterval = axisHelper.getAxisLabelInterval( + zrUtil.map(this.scale.getTicks(), this.dataToCoord, this), + axisHelper.getFormattedLabels(this, labelModel.get('formatter')), + labelModel.getModel('textStyle').getFont(), + timelineModel.get('orient') === 'horizontal' + ); + } - require('../../model/Component').registerSubTypeDefaulter('dataZoom', function (option) { - // Default 'slider' when no type specified. - return 'slider'; - }); + return labelInterval; + }, -}); -/** - * @file Axis operator - */ -define('echarts/component/dataZoom/AxisProxy',['require','zrender/core/util','../../util/number'],function(require) { - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../../util/number'); - var each = zrUtil.each; - var asc = numberUtil.asc; - - /** - * Operate single axis. - * One axis can only operated by one axis operator. - * Different dataZoomModels may be defined to operate the same axis. - * (i.e. 'inside' data zoom and 'slider' data zoom components) - * So dataZoomModels share one axisProxy in that case. - * - * @class - */ - var AxisProxy = function (dimName, axisIndex, dataZoomModel, ecModel) { - - /** - * @private - * @type {string} - */ - this._dimName = dimName; - - /** - * @private - */ - this._axisIndex = axisIndex; - - /** - * {scale, min, max} - * @private - * @type {Object} - */ - this._backup; - - /** - * @private - * @type {Array.} - */ - this._valueWindow; - - /** - * @private - * @type {Array.} - */ - this._percentWindow; - - /** - * @private - * @type {Array.} - */ - this._dataExtent; - - /** - * @readOnly - * @type {module: echarts/model/Global} - */ - this.ecModel = ecModel; - - /** - * @private - * @type {module: echarts/component/dataZoom/DataZoomModel} - */ - this._dataZoomModel = dataZoomModel; - }; - - AxisProxy.prototype = { - - constructor: AxisProxy, - - /** - * Whether the axisProxy is hosted by dataZoomModel. - * - * @public - * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel - * @return {boolean} - */ - hostedBy: function (dataZoomModel) { - return this._dataZoomModel === dataZoomModel; - }, - - /** - * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel - * @param {Object} option - */ - backup: function (dataZoomModel, option) { - if (dataZoomModel === this._dataZoomModel) { - var axisModel = this.getAxisModel(); - this._backup = { - scale: axisModel.get('scale', true), - min: axisModel.get('min', true), - max: axisModel.get('max', true) - }; - } - }, - - /** - * @return {Array.} - */ - getDataExtent: function () { - return this._dataExtent.slice(); - }, - - /** - * @return {Array.} - */ - getDataValueWindow: function () { - return this._valueWindow.slice(); - }, - - /** - * @return {Array.} - */ - getDataPercentWindow: function () { - return this._percentWindow.slice(); - }, - - /** - * @public - * @param {number} axisIndex - * @return {Array} seriesModels - */ - getTargetSeriesModels: function () { - var seriesModels = []; - - this.ecModel.eachSeries(function (seriesModel) { - if (this._axisIndex === seriesModel.get(this._dimName + 'AxisIndex')) { - seriesModels.push(seriesModel); - } - }, this); - - return seriesModels; - }, - - getAxisModel: function () { - return this.ecModel.getComponent(this._dimName + 'Axis', this._axisIndex); - }, - - getOtherAxisModel: function () { - var axisDim = this._dimName; - var ecModel = this.ecModel; - var axisModel = this.getAxisModel(); - var isCartesian = axisDim === 'x' || axisDim === 'y'; - var otherAxisDim; - var coordSysIndexName; - if (isCartesian) { - coordSysIndexName = 'gridIndex'; - otherAxisDim = axisDim === 'x' ? 'y' : 'x'; - } - else { - coordSysIndexName = 'polarIndex'; - otherAxisDim = axisDim === 'angle' ? 'radius' : 'angle'; - } - var foundOtherAxisModel; - ecModel.eachComponent(otherAxisDim + 'Axis', function (otherAxisModel) { - if ((otherAxisModel.get(coordSysIndexName) || 0) - === (axisModel.get(coordSysIndexName) || 0)) { - foundOtherAxisModel = otherAxisModel; - } - }); - return foundOtherAxisModel; - }, - - /** - * Notice: reset should not be called before series.restoreData() called, - * so it is recommanded to be called in "process stage" but not "model init - * stage". - * - * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel - */ - reset: function (dataZoomModel) { - if (dataZoomModel !== this._dataZoomModel) { - return; - } - - // Culculate data window and data extent, and record them. - var dataExtent = this._dataExtent = calculateDataExtent( - this._dimName, this.getTargetSeriesModels() - ); - var dataWindow = calculateDataWindow( - dataZoomModel.option, dataExtent, this - ); - this._valueWindow = dataWindow.valueWindow; - this._percentWindow = dataWindow.percentWindow; - - // Update axis setting then. - setAxisModel(this); - }, - - /** - * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel - */ - restore: function (dataZoomModel) { - if (dataZoomModel !== this._dataZoomModel) { - return; - } - - this._valueWindow = this._percentWindow = null; - setAxisModel(this, true); - }, - - /** - * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel - */ - filterData: function (dataZoomModel) { - if (dataZoomModel !== this._dataZoomModel) { - return; - } - - var axisDim = this._dimName; - var seriesModels = this.getTargetSeriesModels(); - var filterMode = dataZoomModel.get('filterMode'); - var valueWindow = this._valueWindow; - - // FIXME - // Toolbox may has dataZoom injected. And if there are stacked bar chart - // with NaN data. NaN will be filtered and stack will be wrong. - // So we need to force the mode to be set empty - var otherAxisModel = this.getOtherAxisModel(); - if (dataZoomModel.get('$fromToolbox') - && otherAxisModel && otherAxisModel.get('type') === 'category') { - filterMode = 'empty'; - } - // Process series data - each(seriesModels, function (seriesModel) { - var seriesData = seriesModel.getData(); - if (!seriesData) { - return; - } - - each(seriesModel.coordDimToDataDim(axisDim), function (dim) { - if (filterMode === 'empty') { - seriesModel.setData( - seriesData.map(dim, function (value) { - return !isInWindow(value) ? NaN : value; - }) - ); - } - else { - seriesData.filterSelf(dim, isInWindow); - } - }); - }); - - function isInWindow(value) { - return value >= valueWindow[0] && value <= valueWindow[1]; - } - } - }; - - function calculateDataExtent(axisDim, seriesModels) { - var dataExtent = [Infinity, -Infinity]; - - each(seriesModels, function (seriesModel) { - var seriesData = seriesModel.getData(); - if (seriesData) { - each(seriesModel.coordDimToDataDim(axisDim), function (dim) { - var seriesExtent = seriesData.getDataExtent(dim); - seriesExtent[0] < dataExtent[0] && (dataExtent[0] = seriesExtent[0]); - seriesExtent[1] > dataExtent[1] && (dataExtent[1] = seriesExtent[1]); - }); - } - }, this); - - return dataExtent; - } - - function calculateDataWindow(opt, dataExtent, axisProxy) { - var axisModel = axisProxy.getAxisModel(); - var scale = axisModel.axis.scale; - var percentExtent = [0, 100]; - var percentWindow = [ - opt.start, - opt.end - ]; - var valueWindow = []; - - // In percent range is used and axis min/max/scale is set, - // window should be based on min/max/0, but should not be - // based on the extent of filtered data. - var backup = axisProxy._backup; - dataExtent = dataExtent.slice(); - fixExtendByAxis(dataExtent, backup, scale); - - each(['startValue', 'endValue'], function (prop) { - valueWindow.push( - opt[prop] != null - ? scale.parse(opt[prop]) - : null - ); - }); - - // Normalize bound. - each([0, 1], function (idx) { - var boundValue = valueWindow[idx]; - var boundPercent = percentWindow[idx]; - - // start/end has higher priority over startValue/endValue, - // because start/end can be consistent among different type - // of axis but startValue/endValue not. - - if (boundPercent != null || boundValue == null) { - if (boundPercent == null) { - boundPercent = percentExtent[idx]; - } - // Use scale.parse to math round for category or time axis. - boundValue = scale.parse(numberUtil.linearMap( - boundPercent, percentExtent, dataExtent, true - )); - } - else { // boundPercent == null && boundValue != null - boundPercent = numberUtil.linearMap( - boundValue, dataExtent, percentExtent, true - ); - } - valueWindow[idx] = boundValue; - percentWindow[idx] = boundPercent; - }); - - return { - valueWindow: asc(valueWindow), - percentWindow: asc(percentWindow) - }; - } - - function fixExtendByAxis(dataExtent, backup, scale) { - each(['min', 'max'], function (minMax, index) { - var axisMax = backup[minMax]; - // Consider 'dataMin', 'dataMax' - if (axisMax != null && (axisMax + '').toLowerCase() !== 'data' + minMax) { - dataExtent[index] = scale.parse(axisMax); - } - }); - - if (!backup.scale) { - dataExtent[0] > 0 && (dataExtent[0] = 0); - dataExtent[1] < 0 && (dataExtent[1] = 0); - } - - return dataExtent; - } - - function setAxisModel(axisProxy, isRestore) { - var axisModel = axisProxy.getAxisModel(); - - var backup = axisProxy._backup; - var percentWindow = axisProxy._percentWindow; - var valueWindow = axisProxy._valueWindow; - - if (!backup) { - return; - } - - var isFull = isRestore || (percentWindow[0] === 0 && percentWindow[1] === 100); - // [0, 500]: arbitrary value, guess axis extent. - var precision = !isRestore && numberUtil.getPixelPrecision(valueWindow, [0, 500]); - // toFixed() digits argument must be between 0 and 20 - var invalidPrecision = !isRestore && !(precision < 20 && precision >= 0); - - axisModel.setNeedsCrossZero && axisModel.setNeedsCrossZero( - (isRestore || isFull) ? !backup.scale : false - ); - axisModel.setMin && axisModel.setMin( - (isRestore || isFull || invalidPrecision) - ? backup.min - : +valueWindow[0].toFixed(precision) - ); - axisModel.setMax && axisModel.setMax( - (isRestore || isFull || invalidPrecision) - ? backup.max - : +valueWindow[1].toFixed(precision) - ); - } - - return AxisProxy; + /** + * If label is ignored. + * Automatically used when axis is category and label can not be all shown + * @public + * @param {number} idx + * @return {boolean} + */ + isLabelIgnored: function (idx) { + if (this.type === 'category') { + var labelInterval = this.getLabelInterval(); + return ((typeof labelInterval === 'function') + && !labelInterval(idx, this.scale.getLabel(idx))) + || idx % (labelInterval + 1); + } + } -}); -/** - * @file Data zoom model - */ -define('echarts/component/dataZoom/DataZoomModel',['require','zrender/core/util','zrender/core/env','../../echarts','../../util/model','./AxisProxy','../../util/layout'],function(require) { - - var zrUtil = require('zrender/core/util'); - var env = require('zrender/core/env'); - var echarts = require('../../echarts'); - var modelUtil = require('../../util/model'); - var AxisProxy = require('./AxisProxy'); - var layout = require('../../util/layout'); - var each = zrUtil.each; - var eachAxisDim = modelUtil.eachAxisDim; - - var DataZoomModel = echarts.extendComponentModel({ - - type: 'dataZoom', - - dependencies: [ - 'xAxis', 'yAxis', 'zAxis', 'radiusAxis', 'angleAxis', 'series' - ], - - /** - * @protected - */ - defaultOption: { - zlevel: 0, - z: 4, // Higher than normal component (z: 2). - orient: null, // Default auto by axisIndex. Possible value: 'horizontal', 'vertical'. - xAxisIndex: null, // Default all horizontal category axis. - yAxisIndex: null, // Default all vertical category axis. - angleAxisIndex: null, - radiusAxisIndex: null, - filterMode: 'filter', // Possible values: 'filter' or 'empty'. - // 'filter': data items which are out of window will be removed. - // This option is applicable when filtering outliers. - // 'empty': data items which are out of window will be set to empty. - // This option is applicable when user should not neglect - // that there are some data items out of window. - // Taking line chart as an example, line will be broken in - // the filtered points when filterModel is set to 'empty', but - // be connected when set to 'filter'. - - throttle: 100, // Dispatch action by the fixed rate, avoid frequency. - // default 100. Do not throttle when use null/undefined. - start: 0, // Start percent. 0 ~ 100 - end: 100, // End percent. 0 ~ 100 - startValue: null, // Start value. If startValue specified, start is ignored. - endValue: null // End value. If endValue specified, end is ignored. - }, - - /** - * @override - */ - init: function (option, parentModel, ecModel) { - - /** - * key like x_0, y_1 - * @private - * @type {Object} - */ - this._dataIntervalByAxis = {}; - - /** - * @private - */ - this._dataInfo = {}; - - /** - * key like x_0, y_1 - * @private - */ - this._axisProxies = {}; - - /** - * @readOnly - */ - this.textStyleModel; - - var rawOption = retrieveRaw(option); - - this.mergeDefaultAndTheme(option, ecModel); - - this.doInit(rawOption); - }, - - /** - * @override - */ - mergeOption: function (newOption) { - var rawOption = retrieveRaw(newOption); - - //FIX #2591 - zrUtil.merge(this.option, newOption, true); - - this.doInit(rawOption); - }, - - /** - * @protected - */ - doInit: function (rawOption) { - var thisOption = this.option; - - // Disable realtime view update if canvas is not supported. - if (!env.canvasSupported) { - thisOption.realtime = false; - } - - processRangeProp('start', 'startValue', rawOption, thisOption); - processRangeProp('end', 'endValue', rawOption, thisOption); - - this.textStyleModel = this.getModel('textStyle'); - - this._resetTarget(); - - this._giveAxisProxies(); - - this._backup(); - }, - - /** - * @protected - */ - restoreData: function () { - DataZoomModel.superApply(this, 'restoreData', arguments); - - // If use dataZoom while dynamic setOption, axis setting should - // be restored before new option setting, otherwise axis status - // that is set by dataZoom will be recorded in _backup calling. - this.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) { - dataZoomModel.getAxisProxy(dimNames.name, axisIndex).restore(dataZoomModel); - }); - }, - - /** - * @private - */ - _giveAxisProxies: function () { - var axisProxies = this._axisProxies; - - this.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel, ecModel) { - var axisModel = this.dependentModels[dimNames.axis][axisIndex]; - - // If exists, share axisProxy with other dataZoomModels. - var axisProxy = axisModel.__dzAxisProxy || ( - // Use the first dataZoomModel as the main model of axisProxy. - axisModel.__dzAxisProxy = new AxisProxy( - dimNames.name, axisIndex, this, ecModel - ) - ); - // FIXME - // dispose __dzAxisProxy - - axisProxies[dimNames.name + '_' + axisIndex] = axisProxy; - }, this); - }, - - /** - * @private - */ - _resetTarget: function () { - var thisOption = this.option; - - var autoMode = this._judgeAutoMode(); - - eachAxisDim(function (dimNames) { - var axisIndexName = dimNames.axisIndex; - thisOption[axisIndexName] = modelUtil.normalizeToArray( - thisOption[axisIndexName] - ); - }, this); - - if (autoMode === 'axisIndex') { - this._autoSetAxisIndex(); - } - else if (autoMode === 'orient') { - this._autoSetOrient(); - } - }, - - /** - * @private - */ - _judgeAutoMode: function () { - // Auto set only works for setOption at the first time. - // The following is user's reponsibility. So using merged - // option is OK. - var thisOption = this.option; - - var hasIndexSpecified = false; - eachAxisDim(function (dimNames) { - // When user set axisIndex as a empty array, we think that user specify axisIndex - // but do not want use auto mode. Because empty array may be encountered when - // some error occured. - if (thisOption[dimNames.axisIndex] != null) { - hasIndexSpecified = true; - } - }, this); - - var orient = thisOption.orient; - - if (orient == null && hasIndexSpecified) { - return 'orient'; - } - else if (!hasIndexSpecified) { - if (orient == null) { - thisOption.orient = 'horizontal'; - } - return 'axisIndex'; - } - }, - - /** - * @private - */ - _autoSetAxisIndex: function () { - var autoAxisIndex = true; - var orient = this.get('orient', true); - var thisOption = this.option; - - if (autoAxisIndex) { - // Find axis that parallel to dataZoom as default. - var dimNames = orient === 'vertical' - ? {dim: 'y', axisIndex: 'yAxisIndex', axis: 'yAxis'} - : {dim: 'x', axisIndex: 'xAxisIndex', axis: 'xAxis'}; - - if (this.dependentModels[dimNames.axis].length) { - thisOption[dimNames.axisIndex] = [0]; - autoAxisIndex = false; - } - } - - if (autoAxisIndex) { - // Find the first category axis as default. (consider polar) - eachAxisDim(function (dimNames) { - if (!autoAxisIndex) { - return; - } - var axisIndices = []; - var axisModels = this.dependentModels[dimNames.axis]; - if (axisModels.length && !axisIndices.length) { - for (var i = 0, len = axisModels.length; i < len; i++) { - if (axisModels[i].get('type') === 'category') { - axisIndices.push(i); - } - } - } - thisOption[dimNames.axisIndex] = axisIndices; - if (axisIndices.length) { - autoAxisIndex = false; - } - }, this); - } - - if (autoAxisIndex) { - // FIXME - // 这里是兼容ec2的写法(没指定xAxisIndex和yAxisIndex时把scatter和双数值轴折柱纳入dataZoom控制), - // 但是实际是否需要Grid.js#getScaleByOption来判断(考虑time,log等axis type)? - - // If both dataZoom.xAxisIndex and dataZoom.yAxisIndex is not specified, - // dataZoom component auto adopts series that reference to - // both xAxis and yAxis which type is 'value'. - this.ecModel.eachSeries(function (seriesModel) { - if (this._isSeriesHasAllAxesTypeOf(seriesModel, 'value')) { - eachAxisDim(function (dimNames) { - var axisIndices = thisOption[dimNames.axisIndex]; - var axisIndex = seriesModel.get(dimNames.axisIndex); - if (zrUtil.indexOf(axisIndices, axisIndex) < 0) { - axisIndices.push(axisIndex); - } - }); - } - }, this); - } - }, - - /** - * @private - */ - _autoSetOrient: function () { - var dim; - - // Find the first axis - this.eachTargetAxis(function (dimNames) { - !dim && (dim = dimNames.name); - }, this); - - this.option.orient = dim === 'y' ? 'vertical' : 'horizontal'; - }, - - /** - * @private - */ - _isSeriesHasAllAxesTypeOf: function (seriesModel, axisType) { - // FIXME - // 需要series的xAxisIndex和yAxisIndex都首先自动设置上。 - // 例如series.type === scatter时。 - - var is = true; - eachAxisDim(function (dimNames) { - var seriesAxisIndex = seriesModel.get(dimNames.axisIndex); - var axisModel = this.dependentModels[dimNames.axis][seriesAxisIndex]; - - if (!axisModel || axisModel.get('type') !== axisType) { - is = false; - } - }, this); - return is; - }, - - /** - * @private - */ - _backup: function () { - this.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel, ecModel) { - this.getAxisProxy(dimNames.name, axisIndex).backup(dataZoomModel); - }, this); - }, - - /** - * @public - */ - getFirstTargetAxisModel: function () { - var firstAxisModel; - eachAxisDim(function (dimNames) { - if (firstAxisModel == null) { - var indices = this.get(dimNames.axisIndex); - if (indices.length) { - firstAxisModel = this.dependentModels[dimNames.axis][indices[0]]; - } - } - }, this); - - return firstAxisModel; - }, - - /** - * @public - * @param {Function} callback param: axisModel, dimNames, axisIndex, dataZoomModel, ecModel - */ - eachTargetAxis: function (callback, context) { - var ecModel = this.ecModel; - eachAxisDim(function (dimNames) { - each( - this.get(dimNames.axisIndex), - function (axisIndex) { - callback.call(context, dimNames, axisIndex, this, ecModel); - }, - this - ); - }, this); - }, - - getAxisProxy: function (dimName, axisIndex) { - return this._axisProxies[dimName + '_' + axisIndex]; - }, - - /** - * If not specified, set to undefined. - * - * @public - * @param {Object} opt - * @param {number} [opt.start] - * @param {number} [opt.end] - * @param {number} [opt.startValue] - * @param {number} [opt.endValue] - */ - setRawRange: function (opt) { - each(['start', 'end', 'startValue', 'endValue'], function (name) { - // If any of those prop is null/undefined, we should alos set - // them, because only one pair between start/end and - // startValue/endValue can work. - this.option[name] = opt[name]; - }, this); - }, - - /** - * @public - */ - setLayoutParams: function (params) { - layout.copyLayoutParams(this.option, params); - }, - - /** - * @public - * @return {Array.} [startPercent, endPercent] - */ - getPercentRange: function () { - var axisProxy = this.findRepresentativeAxisProxy(); - if (axisProxy) { - return axisProxy.getDataPercentWindow(); - } - }, - - /** - * @public - * For example, chart.getModel().getComponent('dataZoom').getValueRange('y', 0); - * - * @param {string} [axisDimName] - * @param {number} [axisIndex] - * @return {Array.} [startValue, endValue] - */ - getValueRange: function (axisDimName, axisIndex) { - if (axisDimName == null && axisIndex == null) { - var axisProxy = this.findRepresentativeAxisProxy(); - if (axisProxy) { - return axisProxy.getDataValueWindow(); - } - } - else { - return this.getAxisProxy(axisDimName, axisIndex).getDataValueWindow(); - } - }, - - /** - * @public - * @return {module:echarts/component/dataZoom/AxisProxy} - */ - findRepresentativeAxisProxy: function () { - // Find the first hosted axisProxy - var axisProxies = this._axisProxies; - for (var key in axisProxies) { - if (axisProxies.hasOwnProperty(key) && axisProxies[key].hostedBy(this)) { - return axisProxies[key]; - } - } - - // If no hosted axis find not hosted axisProxy. - // Consider this case: dataZoomModel1 and dataZoomModel2 control the same axis, - // and the option.start or option.end settings are different. The percentRange - // should follow axisProxy. - // (We encounter this problem in toolbox data zoom.) - for (var key in axisProxies) { - if (axisProxies.hasOwnProperty(key) && !axisProxies[key].hostedBy(this)) { - return axisProxies[key]; - } - } - } - - }); - - function retrieveRaw(option) { - var ret = {}; - each( - ['start', 'end', 'startValue', 'endValue'], - function (name) { - ret[name] = option[name]; - } - ); - return ret; - } - - function processRangeProp(percentProp, valueProp, rawOption, thisOption) { - // start/end has higher priority over startValue/endValue, - // but we should make chart.setOption({endValue: 1000}) effective, - // rather than chart.setOption({endValue: 1000, end: null}). - if (rawOption[valueProp] != null && rawOption[percentProp] == null) { - thisOption[percentProp] = null; - } - // Otherwise do nothing and use the merge result. - } - - return DataZoomModel; -}); + }; -define('echarts/component/dataZoom/DataZoomView',['require','../../view/Component'],function (require) { - - var ComponentView = require('../../view/Component'); - - return ComponentView.extend({ - - type: 'dataZoom', - - render: function (dataZoomModel, ecModel, api, payload) { - this.dataZoomModel = dataZoomModel; - this.ecModel = ecModel; - this.api = api; - }, - - /** - * Find the first target coordinate system. - * - * @protected - * @return {Object} { - * cartesians: [ - * {model: coord0, axisModels: [axis1, axis3], coordIndex: 1}, - * {model: coord1, axisModels: [axis0, axis2], coordIndex: 0}, - * ... - * ], // cartesians must not be null/undefined. - * polars: [ - * {model: coord0, axisModels: [axis4], coordIndex: 0}, - * ... - * ], // polars must not be null/undefined. - * axisModels: [axis0, axis1, axis2, axis3, axis4] - * // axisModels must not be null/undefined. - * } - */ - getTargetInfo: function () { - var dataZoomModel = this.dataZoomModel; - var ecModel = this.ecModel; - var cartesians = []; - var polars = []; - var axisModels = []; - - dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) { - var axisModel = ecModel.getComponent(dimNames.axis, axisIndex); - if (axisModel) { - axisModels.push(axisModel); - - var gridIndex = axisModel.get('gridIndex'); - var polarIndex = axisModel.get('polarIndex'); - - if (gridIndex != null) { - var coordModel = ecModel.getComponent('grid', gridIndex); - save(coordModel, axisModel, cartesians, gridIndex); - } - else if (polarIndex != null) { - var coordModel = ecModel.getComponent('polar', polarIndex); - save(coordModel, axisModel, polars, polarIndex); - } - } - }, this); - - function save(coordModel, axisModel, store, coordIndex) { - var item; - for (var i = 0; i < store.length; i++) { - if (store[i].model === coordModel) { - item = store[i]; - break; - } - } - if (!item) { - store.push(item = { - model: coordModel, axisModels: [], coordIndex: coordIndex - }); - } - item.axisModels.push(axisModel); - } - - return { - cartesians: cartesians, - polars: polars, - axisModels: axisModels - }; - } - - }); + zrUtil.inherits(TimelineAxis, Axis); -}); -/** - * @file Data zoom model - */ -define('echarts/component/dataZoom/SliderZoomModel',['require','./DataZoomModel','../../util/layout'],function(require) { - - var DataZoomModel = require('./DataZoomModel'); - var layout = require('../../util/layout'); - - var SliderZoomModel = DataZoomModel.extend({ - - type: 'dataZoom.slider', - - /** - * @readOnly - */ - inputPositionParams: null, - - /** - * @protected - */ - defaultOption: { - show: true, - - left: null, // Default align to grid rect. - right: null, // Default align to grid rect. - top: null, // Default align to grid rect. - bottom: null, // Default align to grid rect. - width: null, // Default align to grid rect. - height: null, // Default align to grid rect. - - backgroundColor: 'rgba(47,69,84,0)', // Background of slider zoom component. - dataBackgroundColor: '#ddd', // Background of data shadow. - fillerColor: 'rgba(47,69,84,0.25)', // Color of selected area. - handleColor: 'rgba(47,69,84,0.65)', // Color of handle. - handleSize: 10, - - labelPrecision: null, - labelFormatter: null, - showDetail: true, - showDataShadow: 'auto', // Default auto decision. - realtime: true, - zoomLock: false, // Whether disable zoom. - textStyle: { - color: '#333' - } - }, - - /** - * @override - */ - init: function (option) { - this.inputPositionParams = layout.getLayoutParams(option); - SliderZoomModel.superApply(this, 'init', arguments); - }, - - /** - * @override - */ - mergeOption: function (option) { - this.inputPositionParams = layout.getLayoutParams(option); - SliderZoomModel.superApply(this, 'mergeOption', arguments); - } - - }); - - return SliderZoomModel; + module.exports = TimelineAxis; -}); -define('echarts/util/throttle',[],function () { - - var lib = {}; - - var ORIGIN_METHOD = '\0__throttleOriginMethod'; - var RATE = '\0__throttleRate'; - - /** - * 频率控制 返回函数连续调用时,fn 执行频率限定为每多少时间执行一次 - * 例如常见效果: - * notifyWhenChangesStop - * 频繁调用时,只保证最后一次执行 - * 配成:trailing:true;debounce:true 即可 - * notifyAtFixRate - * 频繁调用时,按规律心跳执行 - * 配成:trailing:true;debounce:false 即可 - * 注意: - * 根据model更新view的时候,可以使用throttle, - * 但是根据view更新model的时候,避免使用这种延迟更新的方式。 - * 因为这可能导致model和server同步出现问题。 - * - * @public - * @param {(Function|Array.)} fn 需要调用的函数 - * 如果fn为array,则表示可以对多个函数进行throttle。 - * 他们共享同一个timer。 - * @param {number} delay 延迟时间,单位毫秒 - * @param {bool} trailing 是否保证最后一次触发的执行 - * true:表示保证最后一次调用会触发执行。 - * 但任何调用后不可能立即执行,总会delay。 - * false:表示不保证最后一次调用会触发执行。 - * 但只要间隔大于delay,调用就会立即执行。 - * @param {bool} debounce 节流 - * true:表示:频繁调用(间隔小于delay)时,根本不执行 - * false:表示:频繁调用(间隔小于delay)时,按规律心跳执行 - * @return {(Function|Array.)} 实际调用函数。 - * 当输入的fn为array时,返回值也为array。 - * 每项是Function。 - */ - lib.throttle = function (fn, delay, trailing, debounce) { - - var currCall = (new Date()).getTime(); - var lastCall = 0; - var lastExec = 0; - var timer = null; - var diff; - var scope; - var args; - var isSingle = typeof fn === 'function'; - delay = delay || 0; - - if (isSingle) { - return createCallback(); - } - else { - var ret = []; - for (var i = 0; i < fn.length; i++) { - ret[i] = createCallback(i); - } - return ret; - } - - function createCallback(index) { - - function exec() { - lastExec = (new Date()).getTime(); - timer = null; - (isSingle ? fn : fn[index]).apply(scope, args || []); - } - - var cb = function () { - currCall = (new Date()).getTime(); - scope = this; - args = arguments; - diff = currCall - (debounce ? lastCall : lastExec) - delay; - - clearTimeout(timer); - - if (debounce) { - if (trailing) { - timer = setTimeout(exec, delay); - } - else if (diff >= 0) { - exec(); - } - } - else { - if (diff >= 0) { - exec(); - } - else if (trailing) { - timer = setTimeout(exec, -diff); - } - } - - lastCall = currCall; - }; - - /** - * Clear throttle. - * @public - */ - cb.clear = function () { - if (timer) { - clearTimeout(timer); - timer = null; - } - }; - - return cb; - } - }; - - /** - * 按一定频率执行,最后一次调用总归会执行 - * - * @public - */ - lib.fixRate = function (fn, delay) { - return delay != null - ? lib.throttle(fn, delay, true, false) - : fn; - }; - - /** - * 直到不频繁调用了才会执行,最后一次调用总归会执行 - * - * @public - */ - lib.debounce = function (fn, delay) { - return delay != null - ? lib.throttle(fn, delay, true, true) - : fn; - }; - - - /** - * Create throttle method or update throttle rate. - * - * @example - * ComponentView.prototype.render = function () { - * ... - * throttle.createOrUpdate( - * this, - * '_dispatchAction', - * this.model.get('throttle'), - * 'fixRate' - * ); - * }; - * ComponentView.prototype.remove = function () { - * throttle.clear(this, '_dispatchAction'); - * }; - * ComponentView.prototype.dispose = function () { - * throttle.clear(this, '_dispatchAction'); - * }; - * - * @public - * @param {Object} obj - * @param {string} fnAttr - * @param {number} rate - * @param {string} throttleType 'fixRate' or 'debounce' - */ - lib.createOrUpdate = function (obj, fnAttr, rate, throttleType) { - var fn = obj[fnAttr]; - - if (!fn || rate == null || !throttleType) { - return; - } - - var originFn = fn[ORIGIN_METHOD] || fn; - var lastRate = fn[RATE]; - - if (lastRate !== rate) { - fn = obj[fnAttr] = lib[throttleType](originFn, rate); - fn[ORIGIN_METHOD] = originFn; - fn[RATE] = rate; - } - }; - - /** - * Clear throttle. Example see throttle.createOrUpdate. - * - * @public - * @param {Object} obj - * @param {string} fnAttr - */ - lib.clear = function (obj, fnAttr) { - var fn = obj[fnAttr]; - if (fn && fn[ORIGIN_METHOD]) { - obj[fnAttr] = fn[ORIGIN_METHOD]; - } - }; - - return lib; -}); -define('echarts/component/helper/sliderMove',['require'],function (require) { - - /** - * Calculate slider move result. - * - * @param {number} delta Move length. - * @param {Array.} handleEnds handleEnds[0] and be bigger then handleEnds[1]. - * handleEnds will be modified in this method. - * @param {Array.} extent handleEnds is restricted by extent. - * extent[0] should less or equals than extent[1]. - * @param {string} mode 'rigid': Math.abs(handleEnds[0] - handleEnds[1]) remain unchanged, - * 'cross' handleEnds[0] can be bigger then handleEnds[1], - * 'push' handleEnds[0] can not be bigger then handleEnds[1], - * when they touch, one push other. - * @param {number} handleIndex If mode is 'rigid', handleIndex is not required. - * @param {Array.} The input handleEnds. - */ - return function (delta, handleEnds, extent, mode, handleIndex) { - if (!delta) { - return handleEnds; - } - - if (mode === 'rigid') { - delta = getRealDelta(delta, handleEnds, extent); - handleEnds[0] += delta; - handleEnds[1] += delta; - } - else { - delta = getRealDelta(delta, handleEnds[handleIndex], extent); - handleEnds[handleIndex] += delta; - - if (mode === 'push' && handleEnds[0] > handleEnds[1]) { - handleEnds[1 - handleIndex] = handleEnds[handleIndex]; - } - } - - return handleEnds; - - function getRealDelta(delta, handleEnds, extent) { - var handleMinMax = !handleEnds.length - ? [handleEnds, handleEnds] - : handleEnds.slice(); - handleEnds[0] > handleEnds[1] && handleMinMax.reverse(); - - if (delta < 0 && handleMinMax[0] + delta < extent[0]) { - delta = extent[0] - handleMinMax[0]; - } - if (delta > 0 && handleMinMax[1] + delta > extent[1]) { - delta = extent[1] - handleMinMax[1]; - } - return delta; - } - }; -}); -define('echarts/component/dataZoom/SliderZoomView',['require','zrender/core/util','../../util/graphic','../../util/throttle','./DataZoomView','../../util/number','../../util/layout','../helper/sliderMove'],function (require) { - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var throttle = require('../../util/throttle'); - var DataZoomView = require('./DataZoomView'); - var Rect = graphic.Rect; - var numberUtil = require('../../util/number'); - var linearMap = numberUtil.linearMap; - var layout = require('../../util/layout'); - var sliderMove = require('../helper/sliderMove'); - var asc = numberUtil.asc; - var bind = zrUtil.bind; - var mathRound = Math.round; - var mathMax = Math.max; - var each = zrUtil.each; - - // Constants - var DEFAULT_LOCATION_EDGE_GAP = 7; - var DEFAULT_FRAME_BORDER_WIDTH = 1; - var DEFAULT_FILLER_SIZE = 30; - var HORIZONTAL = 'horizontal'; - var VERTICAL = 'vertical'; - var LABEL_GAP = 5; - var SHOW_DATA_SHADOW_SERIES_TYPE = ['line', 'bar', 'candlestick', 'scatter']; - - var SliderZoomView = DataZoomView.extend({ - - type: 'dataZoom.slider', - - init: function (ecModel, api) { - - /** - * @private - * @type {Object} - */ - this._displayables = {}; - - /** - * @private - * @type {string} - */ - this._orient; - - /** - * [0, 100] - * @private - */ - this._range; - - /** - * [coord of the first handle, coord of the second handle] - * @private - */ - this._handleEnds; - - /** - * [length, thick] - * @private - * @type {Array.} - */ - this._size; - - /** - * @private - * @type {number} - */ - this._halfHandleSize; - - /** - * @private - */ - this._location; - - /** - * @private - */ - this._dragging; - - /** - * @private - */ - this._dataShadowInfo; - - this.api = api; - }, - - /** - * @override - */ - render: function (dataZoomModel, ecModel, api, payload) { - SliderZoomView.superApply(this, 'render', arguments); - - throttle.createOrUpdate( - this, - '_dispatchZoomAction', - this.dataZoomModel.get('throttle'), - 'fixRate' - ); - - this._orient = dataZoomModel.get('orient'); - this._halfHandleSize = mathRound(dataZoomModel.get('handleSize') / 2); - - if (this.dataZoomModel.get('show') === false) { - this.group.removeAll(); - return; - } - - // Notice: this._resetInterval() should not be executed when payload.type - // is 'dataZoom', origin this._range should be maintained, otherwise 'pan' - // or 'zoom' info will be missed because of 'throttle' of this.dispatchAction, - if (!payload || payload.type !== 'dataZoom' || payload.from !== this.uid) { - this._buildView(); - } - - this._updateView(); - }, - - /** - * @override - */ - remove: function () { - SliderZoomView.superApply(this, 'remove', arguments); - throttle.clear(this, '_dispatchZoomAction'); - }, - - /** - * @override - */ - dispose: function () { - SliderZoomView.superApply(this, 'dispose', arguments); - throttle.clear(this, '_dispatchZoomAction'); - }, - - _buildView: function () { - var thisGroup = this.group; - - thisGroup.removeAll(); - - this._resetLocation(); - this._resetInterval(); - - var barGroup = this._displayables.barGroup = new graphic.Group(); - - this._renderBackground(); - this._renderDataShadow(); - this._renderHandle(); - - thisGroup.add(barGroup); - - this._positionGroup(); - }, - - /** - * @private - */ - _resetLocation: function () { - var dataZoomModel = this.dataZoomModel; - var api = this.api; - - // If some of x/y/width/height are not specified, - // auto-adapt according to target grid. - var coordRect = this._findCoordRect(); - var ecSize = {width: api.getWidth(), height: api.getHeight()}; - - // Default align by coordinate system rect. - var positionInfo = this._orient === HORIZONTAL - ? { - left: coordRect.x, - top: (ecSize.height - DEFAULT_FILLER_SIZE - DEFAULT_LOCATION_EDGE_GAP), - width: coordRect.width, - height: DEFAULT_FILLER_SIZE - } - : { // vertical - right: DEFAULT_LOCATION_EDGE_GAP, - top: coordRect.y, - width: DEFAULT_FILLER_SIZE, - height: coordRect.height - }; - - layout.mergeLayoutParam(positionInfo, dataZoomModel.inputPositionParams); - - // Write back to option for chart.getOption(). (and may then - // chart.setOption() again, where current location value is needed); - dataZoomModel.setLayoutParams(positionInfo); - - var layoutRect = layout.getLayoutRect( - positionInfo, - ecSize, - dataZoomModel.padding - ); - - this._location = {x: layoutRect.x, y: layoutRect.y}; - this._size = [layoutRect.width, layoutRect.height]; - this._orient === VERTICAL && this._size.reverse(); - }, - - /** - * @private - */ - _positionGroup: function () { - var thisGroup = this.group; - var location = this._location; - var orient = this._orient; - - // Just use the first axis to determine mapping. - var targetAxisModel = this.dataZoomModel.getFirstTargetAxisModel(); - var inverse = targetAxisModel && targetAxisModel.get('inverse'); - - var barGroup = this._displayables.barGroup; - var otherAxisInverse = (this._dataShadowInfo || {}).otherAxisInverse; - - // Transform barGroup. - barGroup.attr( - (orient === HORIZONTAL && !inverse) - ? {scale: otherAxisInverse ? [1, 1] : [1, -1]} - : (orient === HORIZONTAL && inverse) - ? {scale: otherAxisInverse ? [-1, 1] : [-1, -1]} - : (orient === VERTICAL && !inverse) - ? {scale: otherAxisInverse ? [1, -1] : [1, 1], rotation: Math.PI / 2} - // Dont use Math.PI, considering shadow direction. - : {scale: otherAxisInverse ? [-1, -1] : [-1, 1], rotation: Math.PI / 2} - ); - - // Position barGroup - var rect = thisGroup.getBoundingRect([barGroup]); - thisGroup.position[0] = location.x - rect.x; - thisGroup.position[1] = location.y - rect.y; - }, - - /** - * @private - */ - _getViewExtent: function () { - // View total length. - var halfHandleSize = this._halfHandleSize; - var totalLength = mathMax(this._size[0], halfHandleSize * 4); - var extent = [halfHandleSize, totalLength - halfHandleSize]; - - return extent; - }, - - _renderBackground : function () { - var dataZoomModel = this.dataZoomModel; - var size = this._size; - - this._displayables.barGroup.add(new Rect({ - silent: true, - shape: { - x: 0, y: 0, width: size[0], height: size[1] - }, - style: { - fill: dataZoomModel.get('backgroundColor') - } - })); - }, - - _renderDataShadow: function () { - var info = this._dataShadowInfo = this._prepareDataShadowInfo(); - - if (!info) { - return; - } - - var size = this._size; - var seriesModel = info.series; - var data = seriesModel.getRawData(); - var otherDim = seriesModel.getShadowDim - ? seriesModel.getShadowDim() // @see candlestick - : info.otherDim; - - var otherDataExtent = data.getDataExtent(otherDim); - // Nice extent. - var otherOffset = (otherDataExtent[1] - otherDataExtent[0]) * 0.3; - otherDataExtent = [ - otherDataExtent[0] - otherOffset, - otherDataExtent[1] + otherOffset - ]; - var otherShadowExtent = [0, size[1]]; - - var thisShadowExtent = [0, size[0]]; - - var points = [[size[0], 0], [0, 0]]; - var step = thisShadowExtent[1] / (data.count() - 1); - var thisCoord = 0; - - // Optimize for large data shadow - var stride = Math.round(data.count() / size[0]); - data.each([otherDim], function (value, index) { - if (stride > 0 && (index % stride)) { - thisCoord += step; - return; - } - // FIXME - // 应该使用统计的空判断?还是在list里进行空判断? - var otherCoord = (value == null || isNaN(value) || value === '') - ? null - : linearMap(value, otherDataExtent, otherShadowExtent, true); - otherCoord != null && points.push([thisCoord, otherCoord]); - - thisCoord += step; - }); - - this._displayables.barGroup.add(new graphic.Polyline({ - shape: {points: points}, - style: {fill: this.dataZoomModel.get('dataBackgroundColor'), lineWidth: 0}, - silent: true, - z2: -20 - })); - }, - - _prepareDataShadowInfo: function () { - var dataZoomModel = this.dataZoomModel; - var showDataShadow = dataZoomModel.get('showDataShadow'); - - if (showDataShadow === false) { - return; - } - - // Find a representative series. - var result; - var ecModel = this.ecModel; - - dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) { - var seriesModels = dataZoomModel - .getAxisProxy(dimNames.name, axisIndex) - .getTargetSeriesModels(); - - zrUtil.each(seriesModels, function (seriesModel) { - if (result) { - return; - } - - if (showDataShadow !== true && zrUtil.indexOf( - SHOW_DATA_SHADOW_SERIES_TYPE, seriesModel.get('type') - ) < 0 - ) { - return; - } - - var otherDim = getOtherDim(dimNames.name); - - var thisAxis = ecModel.getComponent(dimNames.axis, axisIndex).axis; - - result = { - thisAxis: thisAxis, - series: seriesModel, - thisDim: dimNames.name, - otherDim: otherDim, - otherAxisInverse: seriesModel - .coordinateSystem.getOtherAxis(thisAxis).inverse - }; - - }, this); - - }, this); - - return result; - }, - - _renderHandle: function () { - var displaybles = this._displayables; - var handles = displaybles.handles = []; - var handleLabels = displaybles.handleLabels = []; - var barGroup = this._displayables.barGroup; - var size = this._size; - - barGroup.add(displaybles.filler = new Rect({ - draggable: true, - cursor: 'move', - drift: bind(this._onDragMove, this, 'all'), - ondragend: bind(this._onDragEnd, this), - onmouseover: bind(this._showDataInfo, this, true), - onmouseout: bind(this._showDataInfo, this, false), - style: { - fill: this.dataZoomModel.get('fillerColor'), - // text: ':::', - textPosition : 'inside' - } - })); - - // Frame border. - barGroup.add(new Rect(graphic.subPixelOptimizeRect({ - silent: true, - shape: { - x: 0, - y: 0, - width: size[0], - height: size[1] - }, - style: { - stroke: this.dataZoomModel.get('dataBackgroundColor'), - lineWidth: DEFAULT_FRAME_BORDER_WIDTH, - fill: 'rgba(0,0,0,0)' - } - }))); - - each([0, 1], function (handleIndex) { - - barGroup.add(handles[handleIndex] = new Rect({ - style: { - fill: this.dataZoomModel.get('handleColor') - }, - cursor: 'move', - draggable: true, - drift: bind(this._onDragMove, this, handleIndex), - ondragend: bind(this._onDragEnd, this), - onmouseover: bind(this._showDataInfo, this, true), - onmouseout: bind(this._showDataInfo, this, false) - })); - - var textStyleModel = this.dataZoomModel.textStyleModel; - - this.group.add( - handleLabels[handleIndex] = new graphic.Text({ - silent: true, - invisible: true, - style: { - x: 0, y: 0, text: '', - textBaseline: 'middle', - textAlign: 'center', - fill: textStyleModel.getTextColor(), - textFont: textStyleModel.getFont() - } - })); - - }, this); - }, - - /** - * @private - */ - _resetInterval: function () { - var range = this._range = this.dataZoomModel.getPercentRange(); - var viewExtent = this._getViewExtent(); - - this._handleEnds = [ - linearMap(range[0], [0, 100], viewExtent, true), - linearMap(range[1], [0, 100], viewExtent, true) - ]; - }, - - /** - * @private - * @param {(number|string)} handleIndex 0 or 1 or 'all' - * @param {number} dx - * @param {number} dy - */ - _updateInterval: function (handleIndex, delta) { - var handleEnds = this._handleEnds; - var viewExtend = this._getViewExtent(); - - sliderMove( - delta, - handleEnds, - viewExtend, - (handleIndex === 'all' || this.dataZoomModel.get('zoomLock')) - ? 'rigid' : 'cross', - handleIndex - ); - - this._range = asc([ - linearMap(handleEnds[0], viewExtend, [0, 100], true), - linearMap(handleEnds[1], viewExtend, [0, 100], true) - ]); - }, - - /** - * @private - */ - _updateView: function () { - var displaybles = this._displayables; - var handleEnds = this._handleEnds; - var handleInterval = asc(handleEnds.slice()); - var size = this._size; - var halfHandleSize = this._halfHandleSize; - - each([0, 1], function (handleIndex) { - - // Handles - var handle = displaybles.handles[handleIndex]; - handle.setShape({ - x: handleEnds[handleIndex] - halfHandleSize, - y: -1, - width: halfHandleSize * 2, - height: size[1] + 2, - r: 1 - }); - - }, this); - - // Filler - displaybles.filler.setShape({ - x: handleInterval[0], - y: 0, - width: handleInterval[1] - handleInterval[0], - height: this._size[1] - }); - - this._updateDataInfo(); - }, - - /** - * @private - */ - _updateDataInfo: function () { - var dataZoomModel = this.dataZoomModel; - var displaybles = this._displayables; - var handleLabels = displaybles.handleLabels; - var orient = this._orient; - var labelTexts = ['', '']; - - // FIXME - // date型,支持formatter,autoformatter(ec2 date.getAutoFormatter) - if (dataZoomModel.get('showDetail')) { - var dataInterval; - var axis; - dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) { - // Using dataInterval of the first axis. - if (!dataInterval) { - dataInterval = dataZoomModel - .getAxisProxy(dimNames.name, axisIndex) - .getDataValueWindow(); - axis = this.ecModel.getComponent(dimNames.axis, axisIndex).axis; - } - }, this); - - if (dataInterval) { - labelTexts = [ - this._formatLabel(dataInterval[0], axis), - this._formatLabel(dataInterval[1], axis) - ]; - } - } - - var orderedHandleEnds = asc(this._handleEnds.slice()); - - setLabel.call(this, 0); - setLabel.call(this, 1); - - function setLabel(handleIndex) { - // Label - // Text should not transform by barGroup. - var barTransform = graphic.getTransform( - displaybles.handles[handleIndex], this.group - ); - var direction = graphic.transformDirection( - handleIndex === 0 ? 'right' : 'left', barTransform - ); - var offset = this._halfHandleSize + LABEL_GAP; - var textPoint = graphic.applyTransform( - [ - orderedHandleEnds[handleIndex] + (handleIndex === 0 ? -offset : offset), - this._size[1] / 2 - ], - barTransform - ); - handleLabels[handleIndex].setStyle({ - x: textPoint[0], - y: textPoint[1], - textBaseline: orient === HORIZONTAL ? 'middle' : direction, - textAlign: orient === HORIZONTAL ? direction : 'center', - text: labelTexts[handleIndex] - }); - } - }, - - /** - * @private - */ - _formatLabel: function (value, axis) { - var dataZoomModel = this.dataZoomModel; - var labelFormatter = dataZoomModel.get('labelFormatter'); - if (zrUtil.isFunction(labelFormatter)) { - return labelFormatter(value); - } - - var labelPrecision = dataZoomModel.get('labelPrecision'); - if (labelPrecision == null || labelPrecision === 'auto') { - labelPrecision = axis.getPixelPrecision(); - } - - value = (value == null && isNaN(value)) - ? '' - // FIXME Glue code - : (axis.type === 'category' || axis.type === 'time') - ? axis.scale.getLabel(Math.round(value)) - // param of toFixed should less then 20. - : value.toFixed(Math.min(labelPrecision, 20)); - - if (zrUtil.isString(labelFormatter)) { - value = labelFormatter.replace('{value}', value); - } - - return value; - }, - - /** - * @private - * @param {boolean} showOrHide true: show, false: hide - */ - _showDataInfo: function (showOrHide) { - // Always show when drgging. - showOrHide = this._dragging || showOrHide; - - var handleLabels = this._displayables.handleLabels; - handleLabels[0].attr('invisible', !showOrHide); - handleLabels[1].attr('invisible', !showOrHide); - }, - - _onDragMove: function (handleIndex, dx, dy) { - this._dragging = true; - - // Transform dx, dy to bar coordination. - var vertex = this._applyBarTransform([dx, dy], true); - - this._updateInterval(handleIndex, vertex[0]); - this._updateView(); - - if (this.dataZoomModel.get('realtime')) { - this._dispatchZoomAction(); - } - }, - - _onDragEnd: function () { - this._dragging = false; - this._showDataInfo(false); - this._dispatchZoomAction(); - }, - - /** - * This action will be throttled. - * @private - */ - _dispatchZoomAction: function () { - var range = this._range; - - this.api.dispatchAction({ - type: 'dataZoom', - from: this.uid, - dataZoomId: this.dataZoomModel.id, - start: range[0], - end: range[1] - }); - }, - - /** - * @private - */ - _applyBarTransform: function (vertex, inverse) { - var barTransform = this._displayables.barGroup.getLocalTransform(); - return graphic.applyTransform(vertex, barTransform, inverse); - }, - - /** - * @private - */ - _findCoordRect: function () { - // Find the grid coresponding to the first axis referred by dataZoom. - var targetInfo = this.getTargetInfo(); - - // FIXME - // 判断是catesian还是polar - var rect; - if (targetInfo.cartesians.length) { - rect = targetInfo.cartesians[0].model.coordinateSystem.getRect(); - } - else { // Polar - // FIXME - // 暂时随便写的 - var width = this.api.getWidth(); - var height = this.api.getHeight(); - rect = { - x: width * 0.2, - y: height * 0.2, - width: width * 0.6, - height: height * 0.6 - }; - } - - return rect; - } - - }); - - function getOtherDim(thisDim) { - // FIXME - // 这个逻辑和getOtherAxis里一致,但是写在这里是否不好 - return thisDim === 'x' ? 'y' : 'x'; - } - - return SliderZoomView; +/***/ }, +/* 331 */ +/***/ function(module, exports, __webpack_require__) { -}); -/** - * @file Data zoom model - */ -define('echarts/component/dataZoom/InsideZoomModel',['require','./DataZoomModel'],function(require) { - - return require('./DataZoomModel').extend({ - - type: 'dataZoom.inside', - - /** - * @protected - */ - defaultOption: { - zoomLock: false // Whether disable zoom but only pan. - } - }); -}); -/** - * @file Roam controller manager. - */ -define('echarts/component/dataZoom/roams',['require','zrender/core/util','../../component/helper/RoamController','../../util/throttle'],function(require) { - - // Only create one roam controller for each coordinate system. - // one roam controller might be refered by two inside data zoom - // components (for example, one for x and one for y). When user - // pan or zoom, only dispatch one action for those data zoom - // components. - - var zrUtil = require('zrender/core/util'); - var RoamController = require('../../component/helper/RoamController'); - var throttle = require('../../util/throttle'); - var curry = zrUtil.curry; - - var ATTR = '\0_ec_dataZoom_roams'; - - var roams = { - - /** - * @public - * @param {module:echarts/ExtensionAPI} api - * @param {Object} dataZoomInfo - * @param {string} dataZoomInfo.coordType - * @param {string} dataZoomInfo.coordId - * @param {Object} dataZoomInfo.coordinateSystem - * @param {string} dataZoomInfo.dataZoomId - * @param {number} dataZoomInfo.throttleRate - * @param {Function} dataZoomInfo.panGetRange - * @param {Function} dataZoomInfo.zoomGetRange - */ - register: function (api, dataZoomInfo) { - var store = giveStore(api); - var theDataZoomId = dataZoomInfo.dataZoomId; - var theCoordId = dataZoomInfo.coordType + '\0_' + dataZoomInfo.coordId; - - // Do clean when a dataZoom changes its target coordnate system. - zrUtil.each(store, function (record, coordId) { - var dataZoomInfos = record.dataZoomInfos; - if (dataZoomInfos[theDataZoomId] && coordId !== theCoordId) { - delete dataZoomInfos[theDataZoomId]; - record.count--; - } - }); - - cleanStore(store); - - var record = store[theCoordId]; - - // Create if needed. - if (!record) { - record = store[theCoordId] = { - coordId: theCoordId, - dataZoomInfos: {}, - count: 0 - }; - record.controller = createController(api, dataZoomInfo, record); - record.dispatchAction = zrUtil.curry(dispatchAction, api); - } - - // Update. - if (record) { - throttle.createOrUpdate( - record, - 'dispatchAction', - dataZoomInfo.throttleRate, - 'fixRate' - ); - - !record.dataZoomInfos[theDataZoomId] && record.count++; - record.dataZoomInfos[theDataZoomId] = dataZoomInfo; - } - }, - - /** - * @public - * @param {module:echarts/ExtensionAPI} api - * @param {string} dataZoomId - */ - unregister: function (api, dataZoomId) { - var store = giveStore(api); - - zrUtil.each(store, function (record, coordId) { - var dataZoomInfos = record.dataZoomInfos; - if (dataZoomInfos[dataZoomId]) { - delete dataZoomInfos[dataZoomId]; - record.count--; - } - }); - - cleanStore(store); - }, - - /** - * @public - */ - shouldRecordRange: function (payload, dataZoomId) { - if (payload && payload.type === 'dataZoom' && payload.batch) { - for (var i = 0, len = payload.batch.length; i < len; i++) { - if (payload.batch[i].dataZoomId === dataZoomId) { - return false; - } - } - } - return true; - } - - }; - - /** - * Key: coordId, value: {dataZoomInfos: [], count, controller} - * @type {Array.} - */ - function giveStore(api) { - // Mount store on zrender instance, so that we do not - // need to worry about dispose. - var zr = api.getZr(); - return zr[ATTR] || (zr[ATTR] = {}); - } - - function createController(api, dataZoomInfo, newRecord) { - var controller = new RoamController(api.getZr()); - controller.enable(); - controller.on('pan', curry(onPan, newRecord)); - controller.on('zoom', curry(onZoom, newRecord)); - controller.rect = dataZoomInfo.coordinateSystem.getRect().clone(); - - return controller; - } - - function cleanStore(store) { - zrUtil.each(store, function (record, coordId) { - if (!record.count) { - record.controller.off('pan').off('zoom'); - delete store[coordId]; - } - }); - } - - function onPan(record, dx, dy) { - wrapAndDispatch(record, function (info) { - return info.panGetRange(record.controller, dx, dy); - }); - } - - function onZoom(record, scale, mouseX, mouseY) { - wrapAndDispatch(record, function (info) { - return info.zoomGetRange(record.controller, scale, mouseX, mouseY); - }); - } - - function wrapAndDispatch(record, getRange) { - var batch = []; - - zrUtil.each(record.dataZoomInfos, function (info) { - var range = getRange(info); - range && batch.push({ - dataZoomId: info.dataZoomId, - start: range[0], - end: range[1] - }); - }); - - record.dispatchAction(batch); - } - - /** - * This action will be throttled. - */ - function dispatchAction(api, batch) { - api.dispatchAction({ - type: 'dataZoom', - batch: batch - }); - } - - return roams; - -}); -define('echarts/component/dataZoom/InsideZoomView',['require','./DataZoomView','zrender/core/util','../helper/sliderMove','./roams'],function (require) { - - var DataZoomView = require('./DataZoomView'); - var zrUtil = require('zrender/core/util'); - var sliderMove = require('../helper/sliderMove'); - var roams = require('./roams'); - var bind = zrUtil.bind; - - var InsideZoomView = DataZoomView.extend({ - - type: 'dataZoom.inside', - - /** - * @override - */ - init: function (ecModel, api) { - /** - * 'throttle' is used in this.dispatchAction, so we save range - * to avoid missing some 'pan' info. - * @private - * @type {Array.} - */ - this._range; - }, - - /** - * @override - */ - render: function (dataZoomModel, ecModel, api, payload) { - InsideZoomView.superApply(this, 'render', arguments); - - // Notice: origin this._range should be maintained, and should not be re-fetched - // from dataZoomModel when payload.type is 'dataZoom', otherwise 'pan' or 'zoom' - // info will be missed because of 'throttle' of this.dispatchAction. - if (roams.shouldRecordRange(payload, dataZoomModel.id)) { - this._range = dataZoomModel.getPercentRange(); - } - - // Reset controllers. - zrUtil.each(this.getTargetInfo().cartesians, function (coordInfo) { - var coordModel = coordInfo.model; - roams.register( - api, - { - coordId: coordModel.id, - coordType: coordModel.type, - coordinateSystem: coordModel.coordinateSystem, - dataZoomId: dataZoomModel.id, - throttleRage: dataZoomModel.get('throttle', true), - panGetRange: bind(this._onPan, this, coordInfo), - zoomGetRange: bind(this._onZoom, this, coordInfo) - } - ); - }, this); - - // TODO - // polar支持 - }, - - /** - * @override - */ - remove: function () { - roams.unregister(this.api, this.dataZoomModel.id); - InsideZoomView.superApply(this, 'remove', arguments); - this._range = null; - }, - - /** - * @override - */ - dispose: function () { - roams.unregister(this.api, this.dataZoomModel.id); - InsideZoomView.superApply(this, 'dispose', arguments); - this._range = null; - }, - - /** - * @private - */ - _onPan: function (coordInfo, controller, dx, dy) { - return ( - this._range = panCartesian( - [dx, dy], this._range, controller, coordInfo - ) - ); - }, - - /** - * @private - */ - _onZoom: function (coordInfo, controller, scale, mouseX, mouseY) { - var dataZoomModel = this.dataZoomModel; - - if (dataZoomModel.option.zoomLock) { - return; - } - - return ( - this._range = scaleCartesian( - 1 / scale, [mouseX, mouseY], this._range, - controller, coordInfo, dataZoomModel - ) - ); - } - - }); - - function panCartesian(pixelDeltas, range, controller, coordInfo) { - range = range.slice(); - - // Calculate transform by the first axis. - var axisModel = coordInfo.axisModels[0]; - if (!axisModel) { - return; - } - - var directionInfo = getDirectionInfo(pixelDeltas, axisModel, controller); - - var percentDelta = directionInfo.signal - * (range[1] - range[0]) - * directionInfo.pixel / directionInfo.pixelLength; - - sliderMove( - percentDelta, - range, - [0, 100], - 'rigid' - ); - - return range; - } - - function scaleCartesian(scale, mousePoint, range, controller, coordInfo, dataZoomModel) { - range = range.slice(); - - // Calculate transform by the first axis. - var axisModel = coordInfo.axisModels[0]; - if (!axisModel) { - return; - } - - var directionInfo = getDirectionInfo(mousePoint, axisModel, controller); - - var mouse = directionInfo.pixel - directionInfo.pixelStart; - var percentPoint = mouse / directionInfo.pixelLength * (range[1] - range[0]) + range[0]; - - scale = Math.max(scale, 0); - range[0] = (range[0] - percentPoint) * scale + percentPoint; - range[1] = (range[1] - percentPoint) * scale + percentPoint; - - return fixRange(range); - } - - function getDirectionInfo(xy, axisModel, controller) { - var axis = axisModel.axis; - var rect = controller.rect; - var ret = {}; - - if (axis.dim === 'x') { - ret.pixel = xy[0]; - ret.pixelLength = rect.width; - ret.pixelStart = rect.x; - ret.signal = axis.inverse ? 1 : -1; - } - else { // axis.dim === 'y' - ret.pixel = xy[1]; - ret.pixelLength = rect.height; - ret.pixelStart = rect.y; - ret.signal = axis.inverse ? -1 : 1; - } - - return ret; - } - - function fixRange(range) { - // Clamp, using !(<= or >=) to handle NaN. - // jshint ignore:start - var bound = [0, 100]; - !(range[0] <= bound[1]) && (range[0] = bound[1]); - !(range[1] <= bound[1]) && (range[1] = bound[1]); - !(range[0] >= bound[0]) && (range[0] = bound[0]); - !(range[1] >= bound[0]) && (range[1] = bound[0]); - // jshint ignore:end - - return range; - } - - return InsideZoomView; -}); -/** - * @file Data zoom processor - */ -define('echarts/component/dataZoom/dataZoomProcessor',['require','../../echarts'],function (require) { - - var echarts = require('../../echarts'); - - echarts.registerProcessor('filter', function (ecModel, api) { - - ecModel.eachComponent('dataZoom', function (dataZoomModel) { - // We calculate window and reset axis here but not in model - // init stage and not after action dispatch handler, because - // reset should be called after seriesData.restoreData. - dataZoomModel.eachTargetAxis(resetSingleAxis); - - // Caution: data zoom filtering is order sensitive when using - // percent range and no min/max/scale set on axis. - // For example, we have dataZoom definition: - // [ - // {xAxisIndex: 0, start: 30, end: 70}, - // {yAxisIndex: 0, start: 20, end: 80} - // ] - // In this case, [20, 80] of y-dataZoom should be based on data - // that have filtered by x-dataZoom using range of [30, 70], - // but should not be based on full raw data. Thus sliding - // x-dataZoom will change both ranges of xAxis and yAxis, - // while sliding y-dataZoom will only change the range of yAxis. - // So we should filter x-axis after reset x-axis immediately, - // and then reset y-axis and filter y-axis. - dataZoomModel.eachTargetAxis(filterSingleAxis); - }); - - ecModel.eachComponent('dataZoom', function (dataZoomModel) { - // Fullfill all of the range props so that user - // is able to get them from chart.getOption(). - var axisProxy = dataZoomModel.findRepresentativeAxisProxy(); - var percentRange = axisProxy.getDataPercentWindow(); - var valueRange = axisProxy.getDataValueWindow(); - dataZoomModel.setRawRange({ - start: percentRange[0], - end: percentRange[1], - startValue: valueRange[0], - endValue: valueRange[1] - }); - }); - }); - - function resetSingleAxis(dimNames, axisIndex, dataZoomModel) { - dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel); - } - - function filterSingleAxis(dimNames, axisIndex, dataZoomModel) { - dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel); - } - -}); - -/** - * @file Data zoom action - */ -define('echarts/component/dataZoom/dataZoomAction',['require','zrender/core/util','../../util/model','../../echarts'],function(require) { - - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../../util/model'); - var echarts = require('../../echarts'); - - - echarts.registerAction('dataZoom', function (payload, ecModel) { - - var linkedNodesFinder = modelUtil.createLinkedNodesFinder( - zrUtil.bind(ecModel.eachComponent, ecModel, 'dataZoom'), - modelUtil.eachAxisDim, - function (model, dimNames) { - return model.get(dimNames.axisIndex); - } - ); - - var effectedModels = []; - - ecModel.eachComponent( - {mainType: 'dataZoom', query: payload}, - function (model, index) { - effectedModels.push.apply( - effectedModels, linkedNodesFinder(model).nodes - ); - } - ); + - zrUtil.each(effectedModels, function (dataZoomModel, index) { - dataZoomModel.setRawRange({ - start: payload.start, - end: payload.end, - startValue: payload.startValue, - endValue: payload.endValue - }); - }); - - }); - -}); -/** - * DataZoom component entry - */ -define('echarts/component/dataZoom',['require','./dataZoom/typeDefaulter','./dataZoom/DataZoomModel','./dataZoom/DataZoomView','./dataZoom/SliderZoomModel','./dataZoom/SliderZoomView','./dataZoom/InsideZoomModel','./dataZoom/InsideZoomView','./dataZoom/dataZoomProcessor','./dataZoom/dataZoomAction'],function (require) { - - require('./dataZoom/typeDefaulter'); - - require('./dataZoom/DataZoomModel'); - require('./dataZoom/DataZoomView'); - - require('./dataZoom/SliderZoomModel'); - require('./dataZoom/SliderZoomView'); - - require('./dataZoom/InsideZoomModel'); - require('./dataZoom/InsideZoomView'); - - require('./dataZoom/dataZoomProcessor'); - require('./dataZoom/dataZoomAction'); - -}); -/** - * @file VisualMap preprocessor - */ -define('echarts/component/visualMap/preprocessor',['require','zrender/core/util'],function(require) { - - var zrUtil = require('zrender/core/util'); - var each = zrUtil.each; - - return function (option) { - var visualMap = option && option.visualMap; - - if (!zrUtil.isArray(visualMap)) { - visualMap = visualMap ? [visualMap] : []; - } - - each(visualMap, function (opt) { - if (!opt) { - return; - } - - // rename splitList to pieces - if (has(opt, 'splitList') && !has(opt, 'pieces')) { - opt.pieces = opt.splitList; - delete opt.splitList; - } - - var pieces = opt.pieces; - if (pieces && zrUtil.isArray(pieces)) { - each(pieces, function (piece) { - if (zrUtil.isObject(piece)) { - if (has(piece, 'start') && !has(piece, 'min')) { - piece.min = piece.start; - } - if (has(piece, 'end') && !has(piece, 'max')) { - piece.max = piece.end; - } - } - }); - } - }); - }; - - function has(obj, name) { - return obj && obj.hasOwnProperty && obj.hasOwnProperty(name); - } - -}); -define('echarts/component/visualMap/typeDefaulter',['require','../../model/Component'],function (require) { - - require('../../model/Component').registerSubTypeDefaulter('visualMap', function (option) { - // Compatible with ec2, when splitNumber === 0, continuous visualMap will be used. - return ( - !option.categories - && ( - !( - option.pieces - ? option.pieces.length > 0 - : option.splitNumber > 0 - ) - || option.calculable - ) - ) - ? 'continuous' : 'piecewise'; - }); - -}); -/** - * @file Data range visual coding. - */ -define('echarts/component/visualMap/visualCoding',['require','../../echarts','../../visual/VisualMapping','zrender/core/util'],function (require) { - - var echarts = require('../../echarts'); - var VisualMapping = require('../../visual/VisualMapping'); - var zrUtil = require('zrender/core/util'); - - echarts.registerVisualCoding('component', function (ecModel) { - ecModel.eachComponent('visualMap', function (visualMapModel) { - processSingleVisualMap(visualMapModel, ecModel); - }); - }); - - function processSingleVisualMap(visualMapModel, ecModel) { - var visualMappings = visualMapModel.targetVisuals; - var visualTypesMap = {}; - zrUtil.each(['inRange', 'outOfRange'], function (state) { - var visualTypes = VisualMapping.prepareVisualTypes(visualMappings[state]); - visualTypesMap[state] = visualTypes; - }); - - visualMapModel.eachTargetSeries(function (seriesModel) { - var data = seriesModel.getData(); - var dimension = visualMapModel.getDataDimension(data); - var dataIndex; - - function getVisual(key) { - return data.getItemVisual(dataIndex, key); - } - - function setVisual(key, value) { - data.setItemVisual(dataIndex, key, value); - } - - data.each([dimension], function (value, index) { - // For performance consideration, do not use curry. - dataIndex = index; - var valueState = visualMapModel.getValueState(value); - var mappings = visualMappings[valueState]; - var visualTypes = visualTypesMap[valueState]; - for (var i = 0, len = visualTypes.length; i < len; i++) { - var type = visualTypes[i]; - mappings[type] && mappings[type].applyVisual(value, getVisual, setVisual); - } - }); - }); - } + __webpack_require__(332); + __webpack_require__(334); -}); + __webpack_require__(336); + __webpack_require__(337); + __webpack_require__(338); + __webpack_require__(339); + __webpack_require__(344); -/** - * @file Visual mapping. - */ -define('echarts/visual/visualDefault',['require','zrender/core/util'],function (require) { - var zrUtil = require('zrender/core/util'); +/***/ }, +/* 332 */ +/***/ function(module, exports, __webpack_require__) { - var visualDefault = { + - /** - * @public - */ - get: function (visualType, key, isCategory) { - var value = zrUtil.clone( - (defaultOption[visualType] || {})[key] - ); + var featureManager = __webpack_require__(333); + var zrUtil = __webpack_require__(3); - return isCategory - ? (zrUtil.isArray(value) ? value[value.length - 1] : value) - : value; - } + var ToolboxModel = __webpack_require__(1).extendComponentModel({ - }; + type: 'toolbox', - var defaultOption = { + layoutMode: { + type: 'box', + ignoreSize: true + }, - color: { - active: ['#006edd', '#e0ffff'], - inactive: ['rgba(0,0,0,0)'] - }, + mergeDefaultAndTheme: function (option) { + ToolboxModel.superApply(this, 'mergeDefaultAndTheme', arguments); - colorHue: { - active: [0, 360], - inactive: [0, 0] - }, + zrUtil.each(this.option.feature, function (featureOpt, featureName) { + var Feature = featureManager.get(featureName); + Feature && zrUtil.merge(featureOpt, Feature.defaultOption); + }); + }, - colorSaturation: { - active: [0.3, 1], - inactive: [0, 0] - }, + defaultOption: { - colorLightness: { - active: [0.9, 0.5], - inactive: [0, 0] - }, + show: true, - colorAlpha: { - active: [0.3, 1], - inactive: [0, 0] - }, + z: 6, - symbol: { - active: ['circle', 'roundRect', 'diamond'], - inactive: ['none'] - }, + zlevel: 0, - symbolSize: { - active: [10, 50], - inactive: [0, 0] - } - }; + orient: 'horizontal', - return visualDefault; + left: 'right', -}); + top: 'top', -/** - * @file Data zoom model - */ -define('echarts/component/visualMap/VisualMapModel',['require','zrender/core/util','zrender/core/env','../../echarts','../../util/model','../../visual/visualDefault','../../visual/VisualMapping','../../util/number'],function(require) { - - var zrUtil = require('zrender/core/util'); - var env = require('zrender/core/env'); - var echarts = require('../../echarts'); - var modelUtil = require('../../util/model'); - var visualDefault = require('../../visual/visualDefault'); - var VisualMapping = require('../../visual/VisualMapping'); - var mapVisual = VisualMapping.mapVisual; - var eachVisual = VisualMapping.eachVisual; - var numberUtil = require('../../util/number'); - var isArray = zrUtil.isArray; - var each = zrUtil.each; - var asc = numberUtil.asc; - var linearMap = numberUtil.linearMap; - - var VisualMapModel = echarts.extendComponentModel({ - - type: 'visualMap', - - dependencies: ['series'], - - /** - * [lowerBound, upperBound] - * - * @readOnly - * @type {Array.} - */ - dataBound: [-Infinity, Infinity], - - /** - * @readOnly - * @type {Array.} - */ - stateList: ['inRange', 'outOfRange'], - - /** - * @readOnly - * @type {string|Object} - */ - layoutMode: {type: 'box', ignoreSize: true}, - - /** - * @protected - */ - defaultOption: { - show: true, - - zlevel: 0, - z: 4, - - // set min: 0, max: 200, only for campatible with ec2. - // In fact min max should not have default value. - min: 0, // min value, must specified if pieces is not specified. - max: 200, // max value, must specified if pieces is not specified. - - dimension: null, - inRange: null, // 'color', 'colorHue', 'colorSaturation', 'colorLightness', 'colorAlpha', - // 'symbol', 'symbolSize' - outOfRange: null, // 'color', 'colorHue', 'colorSaturation', - // 'colorLightness', 'colorAlpha', - // 'symbol', 'symbolSize' - - left: 0, // 'center' ¦ 'left' ¦ 'right' ¦ {number} (px) - right: null, // The same as left. - top: null, // 'top' ¦ 'bottom' ¦ 'center' ¦ {number} (px) - bottom: 0, // The same as top. - - itemWidth: null, - itemHeight: null, - inverse: false, - orient: 'vertical', // 'horizontal' ¦ 'vertical' - - seriesIndex: null, // 所控制的series indices,默认所有有value的series. - backgroundColor: 'rgba(0,0,0,0)', - borderColor: '#ccc', // 值域边框颜色 - contentColor: '#5793f3', - inactiveColor: '#aaa', - borderWidth: 0, // 值域边框线宽,单位px,默认为0(无边框) - padding: 5, // 值域内边距,单位px,默认各方向内边距为5, - // 接受数组分别设定上右下左边距,同css - textGap: 10, // - precision: 0, // 小数精度,默认为0,无小数点 - color: ['#bf444c', '#d88273', '#f6efa6'], //颜色(deprecated,兼容ec2,顺序同pieces,不同于inRange/outOfRange) - - formatter: null, - text: null, // 文本,如['高', '低'],兼容ec2,text[0]对应高值,text[1]对应低值 - textStyle: { - color: '#333' // 值域文字颜色 - } - }, - - /** - * @protected - */ - init: function (option, parentModel, ecModel) { - /** - * @private - * @type {boolean} - */ - this._autoSeriesIndex = false; - - /** - * @private - * @type {Array.} - */ - this._dataExtent; - - /** - * @readOnly - */ - this.controllerVisuals = {}; - - /** - * @readOnly - */ - this.targetVisuals = {}; - - /** - * @readOnly - */ - this.textStyleModel; - - /** - * [width, height] - * @readOnly - * @type {Array.} - */ - this.itemSize; - - this.mergeDefaultAndTheme(option, ecModel); - this.doMergeOption({}, true); - }, - - /** - * @public - */ - mergeOption: function (option) { - VisualMapModel.superApply(this, 'mergeOption', arguments); - this.doMergeOption(option, false); - }, - - /** - * @protected - */ - doMergeOption: function (newOption, isInit) { - var thisOption = this.option; - - // FIXME - // necessary? - // Disable realtime view update if canvas is not supported. - if (!env.canvasSupported) { - thisOption.realtime = false; - } - - this.textStyleModel = this.getModel('textStyle'); - - this.resetItemSize(); - - this.completeVisualOption(); - }, - - /** - * @example - * this.formatValueText(someVal); // format single numeric value to text. - * this.formatValueText(someVal, true); // format single category value to text. - * this.formatValueText([min, max]); // format numeric min-max to text. - * this.formatValueText([this.dataBound[0], max]); // using data lower bound. - * this.formatValueText([min, this.dataBound[1]]); // using data upper bound. - * - * @param {number|Array.} value Real value, or this.dataBound[0 or 1]. - * @param {boolean} [isCategory=false] Only available when value is number. - * @return {string} - * @protected - */ - formatValueText: function(value, isCategory) { - var option = this.option; - var precision = option.precision; - var dataBound = this.dataBound; - var formatter = option.formatter; - var isMinMax; - var textValue; - - if (zrUtil.isArray(value)) { - value = value.slice(); - isMinMax = true; - } - - textValue = isCategory - ? value - : (isMinMax - ? [toFixed(value[0]), toFixed(value[1])] - : toFixed(value) - ); - - if (zrUtil.isString(formatter)) { - return formatter - .replace('{value}', isMinMax ? textValue[0] : textValue) - .replace('{value2}', isMinMax ? textValue[1] : textValue); - } - else if (zrUtil.isFunction(formatter)) { - return isMinMax - ? formatter(value[0], value[1]) - : formatter(value); - } - - if (isMinMax) { - if (value[0] === dataBound[0]) { - return '< ' + textValue[1]; - } - else if (value[1] === dataBound[1]) { - return '> ' + textValue[0]; - } - else { - return textValue[0] + ' - ' + textValue[1]; - } - } - else { // Format single value (includes category case). - return textValue; - } - - function toFixed(val) { - return val === dataBound[0] - ? 'min' - : val === dataBound[1] - ? 'max' - : (+val).toFixed(precision); - } - }, - - /** - * @protected - */ - resetTargetSeries: function (newOption, isInit) { - var thisOption = this.option; - var autoSeriesIndex = this._autoSeriesIndex = - (isInit ? thisOption : newOption).seriesIndex == null; - thisOption.seriesIndex = autoSeriesIndex - ? [] : modelUtil.normalizeToArray(thisOption.seriesIndex); - - autoSeriesIndex && this.ecModel.eachSeries(function (seriesModel, index) { - var data = seriesModel.getData(); - // FIXME - // 只考虑了list,还没有考虑map等。 - - // FIXME - // 这里可能应该这么判断:data.dimensions中有超出其所属coordSystem的量。 - if (data.type === 'list') { - thisOption.seriesIndex.push(index); - } - }); - }, - - /** - * @protected - */ - resetExtent: function () { - var thisOption = this.option; - - // Can not calculate data extent by data here. - // Because series and data may be modified in processing stage. - // So we do not support the feature "auto min/max". - - var extent = asc([thisOption.min, thisOption.max]); - - this._dataExtent = extent; - }, - - /** - * @protected - */ - getDataDimension: function (list) { - var optDim = this.option.dimension; - return optDim != null - ? optDim : list.dimensions.length - 1; - }, - - /** - * @public - * @override - */ - getExtent: function () { - return this._dataExtent.slice(); - }, - - /** - * @protected - */ - resetVisual: function (fillVisualOption) { - var dataExtent = this.getExtent(); - - doReset.call(this, 'controller', this.controllerVisuals); - doReset.call(this, 'target', this.targetVisuals); - - function doReset(baseAttr, visualMappings) { - each(this.stateList, function (state) { - var mappings = visualMappings[state] || (visualMappings[state] = {}); - var visaulOption = this.option[baseAttr][state] || {}; - each(visaulOption, function (visualData, visualType) { - if (!VisualMapping.isValidType(visualType)) { - return; - } - var mappingOption = { - type: visualType, - dataExtent: dataExtent, - visual: visualData - }; - fillVisualOption && fillVisualOption.call(this, mappingOption, state); - mappings[visualType] = new VisualMapping(mappingOption); - }, this); - }, this); - } - }, - - /** - * @protected - */ - completeVisualOption: function () { - var thisOption = this.option; - var base = {inRange: thisOption.inRange, outOfRange: thisOption.outOfRange}; - - var target = thisOption.target || (thisOption.target = {}); - var controller = thisOption.controller || (thisOption.controller = {}); - - zrUtil.merge(target, base); // Do not override - zrUtil.merge(controller, base); // Do not override - - var isCategory = this.isCategory(); - - completeSingle.call(this, target); - completeSingle.call(this, controller); - completeInactive.call(this, target, 'inRange', 'outOfRange'); - completeInactive.call(this, target, 'outOfRange', 'inRange'); - completeController.call(this, controller); - - function completeSingle(base) { - // Compatible with ec2 dataRange.color. - // The mapping order of dataRange.color is: [high value, ..., low value] - // whereas inRange.color and outOfRange.color is [low value, ..., high value] - // Notice: ec2 has no inverse. - if (isArray(thisOption.color) - // If there has been inRange: {symbol: ...}, adding color is a mistake. - // So adding color only when no inRange defined. - && !base.inRange - ) { - base.inRange = {color: thisOption.color.slice().reverse()}; - } - - // If using shortcut like: {inRange: 'symbol'}, complete default value. - each(this.stateList, function (state) { - var visualType = base[state]; - - if (zrUtil.isString(visualType)) { - var defa = visualDefault.get(visualType, 'active', isCategory); - if (defa) { - base[state] = {}; - base[state][visualType] = defa; - } - else { - // Mark as not specified. - delete base[state]; - } - } - }, this); - } - - function completeInactive(base, stateExist, stateAbsent) { - var optExist = base[stateExist]; - var optAbsent = base[stateAbsent]; - - if (optExist && !optAbsent) { - optAbsent = base[stateAbsent] = {}; - each(optExist, function (visualData, visualType) { - var defa = visualDefault.get(visualType, 'inactive', isCategory); - if (VisualMapping.isValidType(visualType) && defa) { - optAbsent[visualType] = defa; - } - }); - } - } - - function completeController(controller) { - var symbolExists = (controller.inRange || {}).symbol - || (controller.outOfRange || {}).symbol; - var symbolSizeExists = (controller.inRange || {}).symbolSize - || (controller.outOfRange || {}).symbolSize; - var inactiveColor = this.get('inactiveColor'); - - each(this.stateList, function (state) { - - var itemSize = this.itemSize; - var visuals = controller[state]; - - // Set inactive color for controller if no other color attr (like colorAlpha) specified. - if (!visuals) { - visuals = controller[state] = { - color: isCategory ? inactiveColor : [inactiveColor] - }; - } - - // Consistent symbol and symbolSize if not specified. - if (!visuals.symbol) { - visuals.symbol = symbolExists - && zrUtil.clone(symbolExists) - || (isCategory ? 'roundRect' : ['roundRect']); - } - if (!visuals.symbolSize) { - visuals.symbolSize = symbolSizeExists - && zrUtil.clone(symbolSizeExists) - || (isCategory ? itemSize[0] : [itemSize[0], itemSize[0]]); - } - - // Filter square and none. - visuals.symbol = mapVisual(visuals.symbol, function (symbol) { - return (symbol === 'none' || symbol === 'square') ? 'roundRect' : symbol; - }); - - // Normalize symbolSize - var symbolSize = visuals.symbolSize; - - if (symbolSize) { - var max = -Infinity; - // symbolSize can be object when categories defined. - eachVisual(symbolSize, function (value) { - value > max && (max = value); - }); - visuals.symbolSize = mapVisual(symbolSize, function (value) { - return linearMap(value, [0, max], [0, itemSize[0]], true); - }); - } - - }, this); - } - }, - - /** - * @public - */ - eachTargetSeries: function (callback, context) { - zrUtil.each(this.option.seriesIndex, function (seriesIndex) { - callback.call(context, this.ecModel.getSeriesByIndex(seriesIndex)); - }, this); - }, - - /** - * @public - */ - isCategory: function () { - return !!this.option.categories; - }, - - /** - * @protected - */ - resetItemSize: function () { - this.itemSize = [ - parseFloat(this.get('itemWidth')), - parseFloat(this.get('itemHeight')) - ]; - }, - - /** - * @public - * @abstract - */ - setSelected: zrUtil.noop, - - /** - * @public - * @abstract - */ - getValueState: zrUtil.noop - - }); - - return VisualMapModel; + // right + // bottom -}); + backgroundColor: 'transparent', -/** - * @file Data zoom model - */ -define('echarts/component/visualMap/ContinuousModel',['require','./VisualMapModel','zrender/core/util','../../util/number'],function(require) { - - var VisualMapModel = require('./VisualMapModel'); - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../../util/number'); - - // Constant - var DEFAULT_BAR_BOUND = [20, 140]; - - var ContinuousModel = VisualMapModel.extend({ - - type: 'visualMap.continuous', - - /** - * @protected - */ - defaultOption: { - handlePosition: 'auto', // 'auto', 'left', 'right', 'top', 'bottom' - calculable: false, // 是否值域漫游,启用后无视splitNumber和pieces,线性渐变 - range: [-Infinity, Infinity], // 当前选中范围 - hoverLink: true, - realtime: true, - itemWidth: null, // 值域图形宽度 - itemHeight: null // 值域图形高度 - }, - - /** - * @override - */ - doMergeOption: function (newOption, isInit) { - ContinuousModel.superApply(this, 'doMergeOption', arguments); - - this.resetTargetSeries(newOption, isInit); - this.resetExtent(); - - this.resetVisual(function (mappingOption) { - mappingOption.mappingMethod = 'linear'; - }); - - this._resetRange(); - }, - - /** - * @protected - * @override - */ - resetItemSize: function () { - VisualMapModel.prototype.resetItemSize.apply(this, arguments); - - var itemSize = this.itemSize; - - this._orient === 'horizontal' && itemSize.reverse(); - - (itemSize[0] == null || isNaN(itemSize[0])) && (itemSize[0] = DEFAULT_BAR_BOUND[0]); - (itemSize[1] == null || isNaN(itemSize[1])) && (itemSize[1] = DEFAULT_BAR_BOUND[1]); - }, - - /** - * @private - */ - _resetRange: function () { - var dataExtent = this.getExtent(); - var range = this.option.range; - if (range[0] > range[1]) { - range.reverse(); - } - range[0] = Math.max(range[0], dataExtent[0]); - range[1] = Math.min(range[1], dataExtent[1]); - }, - - /** - * @protected - * @override - */ - completeVisualOption: function () { - VisualMapModel.prototype.completeVisualOption.apply(this, arguments); - - zrUtil.each(this.stateList, function (state) { - var symbolSize = this.option.controller[state].symbolSize; - if (symbolSize && symbolSize[0] !== symbolSize[1]) { - symbolSize[0] = 0; // For good looking. - } - }, this); - }, - - /** - * @public - * @override - */ - setSelected: function (selected) { - this.option.range = selected.slice(); - this._resetRange(); - }, - - /** - * @public - */ - getSelected: function () { - var dataExtent = this.getExtent(); - - var dataInterval = numberUtil.asc( - (this.get('range') || []).slice() - ); - - // Clamp - dataInterval[0] > dataExtent[1] && (dataInterval[0] = dataExtent[1]); - dataInterval[1] > dataExtent[1] && (dataInterval[1] = dataExtent[1]); - dataInterval[0] < dataExtent[0] && (dataInterval[0] = dataExtent[0]); - dataInterval[1] < dataExtent[0] && (dataInterval[1] = dataExtent[0]); - - return dataInterval; - }, - - /** - * @public - * @override - */ - getValueState: function (value) { - var range = this.option.range; - var dataExtent = this.getExtent(); - - // When range[0] === dataExtent[0], any value larger than dataExtent[0] maps to 'inRange'. - // range[1] is processed likewise. - return ( - (range[0] <= dataExtent[0] || range[0] <= value) - && (range[1] >= dataExtent[1] || value <= range[1]) - ) ? 'inRange' : 'outOfRange'; - } - - }); - - return ContinuousModel; + borderColor: '#ccc', -}); -define('echarts/component/visualMap/VisualMapView',['require','../../echarts','zrender/core/util','../../util/graphic','../../util/format','../../util/layout','../../visual/VisualMapping'],function (require) { - - var echarts = require('../../echarts'); - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var formatUtil = require('../../util/format'); - var layout = require('../../util/layout'); - var VisualMapping = require('../../visual/VisualMapping'); - - return echarts.extendComponentView({ - - type: 'visualMap', - - /** - * @readOnly - * @type {Object} - */ - autoPositionValues: {left: 1, right: 1, top: 1, bottom: 1}, - - init: function (ecModel, api) { - /** - * @readOnly - * @type {module:echarts/model/Global} - */ - this.ecModel = ecModel; - - /** - * @readOnly - * @type {module:echarts/ExtensionAPI} - */ - this.api = api; - - /** - * @readOnly - * @type {module:echarts/component/visualMap/visualMapModel} - */ - this.visualMapModel; - - /** - * @private - * @type {Object} - */ - this._updatableShapes = {}; - }, - - /** - * @protected - */ - render: function (visualMapModel, ecModel, api, payload) { - this.visualMapModel = visualMapModel; - - if (visualMapModel.get('show') === false) { - this.group.removeAll(); - return; - } - - this.doRender.apply(this, arguments); - }, - - /** - * @protected - */ - renderBackground: function (group) { - var visualMapModel = this.visualMapModel; - var padding = formatUtil.normalizeCssArray(visualMapModel.get('padding') || 0); - var rect = group.getBoundingRect(); - - group.add(new graphic.Rect({ - z2: -1, // Lay background rect on the lowest layer. - silent: true, - shape: { - x: rect.x - padding[3], - y: rect.y - padding[0], - width: rect.width + padding[3] + padding[1], - height: rect.height + padding[0] + padding[2] - }, - style: { - fill: visualMapModel.get('backgroundColor'), - stroke: visualMapModel.get('borderColor'), - lineWidth: visualMapModel.get('borderWidth') - } - })); - }, - - /** - * @protected - * @param {(number|Array)} targetValue - * @param {string=} forceState Specify state, instead of using getValueState method. - * @param {string=} visualCluster Specify visual type, defualt all available visualClusters. - */ - getControllerVisual: function (targetValue, forceState, visualCluster) { - var visualMapModel = this.visualMapModel; - var targetIsArray = zrUtil.isArray(targetValue); - - // targetValue is array when caculate gradient color, - // where forceState is required. - if (targetIsArray && (!forceState || visualCluster !== 'color')) { - throw new Error(targetValue); - } - - var mappings = visualMapModel.controllerVisuals[ - forceState || visualMapModel.getValueState(targetValue) - ]; - var defaultColor = visualMapModel.get('contentColor'); - var visualObj = { - symbol: visualMapModel.get('itemSymbol'), - color: targetIsArray - ? [{color: defaultColor, offset: 0}, {color: defaultColor, offset: 1}] - : defaultColor - }; - - function getter(key) { - return visualObj[key]; - } - - function setter(key, value) { - visualObj[key] = value; - } - - var visualTypes = VisualMapping.prepareVisualTypes(mappings); - - zrUtil.each(visualTypes, function (type) { - var visualMapping = mappings[type]; - if (!visualCluster || VisualMapping.isInVisualCluster(type, visualCluster)) { - visualMapping && visualMapping.applyVisual(targetValue, getter, setter); - } - }); - - return visualObj; - }, - - /** - * @protected - */ - positionGroup: function (group) { - var model = this.visualMapModel; - var api = this.api; - - layout.positionGroup( - group, - model.getBoxLayoutParams(), - {width: api.getWidth(), height: api.getHeight()} - ); - }, - - /** - * @protected - * @abstract - */ - doRender: zrUtil.noop - - }); -}); -define('echarts/component/visualMap/helper',['require','../../util/layout'],function(require) { - - var layout = require('../../util/layout'); - - var helper = { - - /** - * @param {module:echarts/component/visualMap/VisualMapModel} visualMapModel\ - * @param {module:echarts/ExtensionAPI} api - * @param {Array.} itemSize always [short, long] - * @return {string} 'left' or 'right' or 'top' or 'bottom' - */ - getItemAlign: function (visualMapModel, api, itemSize) { - var modelOption = visualMapModel.option; - var itemAlign = modelOption.align; - - if (itemAlign != null && itemAlign !== 'auto') { - return itemAlign; - } - - // Auto decision align. - var ecSize = {width: api.getWidth(), height: api.getHeight()}; - var realIndex = modelOption.orient === 'horizontal' ? 1 : 0; - - var paramsSet = [ - ['left', 'right', 'width'], - ['top', 'bottom', 'height'] - ]; - var reals = paramsSet[realIndex]; - var fakeValue = [0, null, 10]; - - var layoutInput = {}; - for (var i = 0; i < 3; i++) { - layoutInput[paramsSet[1 - realIndex][i]] = fakeValue[i]; - layoutInput[reals[i]] = i === 2 ? itemSize[0] : modelOption[reals[i]]; - } - - var rParam = [['x', 'width', 3], ['y', 'height', 0]][realIndex]; - var rect = layout.getLayoutRect(layoutInput, ecSize, modelOption.padding); - - return reals[ - (rect.margin[rParam[2]] || 0) + rect[rParam[0]] + rect[rParam[1]] * 0.5 - < ecSize[rParam[1]] * 0.5 ? 0 : 1 - ]; - } - }; - - return helper; -}); + borderWidth: 0, -define('echarts/component/visualMap/ContinuousView',['require','./VisualMapView','../../util/graphic','zrender/core/util','../../util/number','../helper/sliderMove','zrender/graphic/LinearGradient','./helper'],function(require) { - - var VisualMapView = require('./VisualMapView'); - var graphic = require('../../util/graphic'); - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../../util/number'); - var sliderMove = require('../helper/sliderMove'); - var linearMap = numberUtil.linearMap; - var LinearGradient = require('zrender/graphic/LinearGradient'); - var helper = require('./helper'); - var each = zrUtil.each; - - // Notice: - // Any "interval" should be by the order of [low, high]. - // "handle0" (handleIndex === 0) maps to - // low data value: this._dataInterval[0] and has low coord. - // "handle1" (handleIndex === 1) maps to - // high data value: this._dataInterval[1] and has high coord. - // The logic of transform is implemented in this._createBarGroup. - - var ContinuousVisualMapView = VisualMapView.extend({ - - type: 'visualMap.continuous', - - /** - * @override - */ - init: function () { - - VisualMapView.prototype.init.apply(this, arguments); - - /** - * @private - */ - this._shapes = {}; - - /** - * @private - */ - this._dataInterval = []; - - /** - * @private - */ - this._handleEnds = []; - - /** - * @private - */ - this._orient; - - /** - * @private - */ - this._useHandle; - }, - - /** - * @protected - * @override - */ - doRender: function (visualMapModel, ecModel, api, payload) { - if (!payload || payload.type !== 'selectDataRange' || payload.from !== this.uid) { - this._buildView(); - } - else { - this._updateView(); - } - }, - - /** - * @private - */ - _buildView: function () { - this.group.removeAll(); - - var visualMapModel = this.visualMapModel; - var thisGroup = this.group; - - this._orient = visualMapModel.get('orient'); - this._useHandle = visualMapModel.get('calculable'); - - this._resetInterval(); - - this._renderBar(thisGroup); - - var dataRangeText = visualMapModel.get('text'); - this._renderEndsText(thisGroup, dataRangeText, 0); - this._renderEndsText(thisGroup, dataRangeText, 1); - - // Do this for background size calculation. - this._updateView(true); - - // After updating view, inner shapes is built completely, - // and then background can be rendered. - this.renderBackground(thisGroup); - - // Real update view - this._updateView(); - - this.positionGroup(thisGroup); - }, - - /** - * @private - */ - _renderEndsText: function (group, dataRangeText, endsIndex) { - if (!dataRangeText) { - return; - } - - // Compatible with ec2, text[0] map to high value, text[1] map low value. - var text = dataRangeText[1 - endsIndex]; - text = text != null ? text + '' : ''; - - var visualMapModel = this.visualMapModel; - var textGap = visualMapModel.get('textGap'); - var itemSize = visualMapModel.itemSize; - - var barGroup = this._shapes.barGroup; - var position = this._applyTransform( - [ - itemSize[0] / 2, - endsIndex === 0 ? -textGap : itemSize[1] + textGap - ], - barGroup - ); - var align = this._applyTransform( - endsIndex === 0 ? 'bottom' : 'top', - barGroup - ); - var orient = this._orient; - var textStyleModel = this.visualMapModel.textStyleModel; - - this.group.add(new graphic.Text({ - style: { - x: position[0], - y: position[1], - textBaseline: orient === 'horizontal' ? 'middle' : align, - textAlign: orient === 'horizontal' ? align : 'center', - text: text, - textFont: textStyleModel.getFont(), - fill: textStyleModel.getTextColor() - } - })); - }, - - /** - * @private - */ - _renderBar: function (targetGroup) { - var visualMapModel = this.visualMapModel; - var shapes = this._shapes; - var itemSize = visualMapModel.itemSize; - var orient = this._orient; - var useHandle = this._useHandle; - var itemAlign = helper.getItemAlign(visualMapModel, this.api, itemSize); - var barGroup = shapes.barGroup = this._createBarGroup(itemAlign); - - // Bar - barGroup.add(shapes.outOfRange = createPolygon()); - barGroup.add(shapes.inRange = createPolygon( - null, - zrUtil.bind(this._modifyHandle, this, 'all'), - useHandle ? 'move' : null - )); - - var textRect = visualMapModel.textStyleModel.getTextRect('国'); - var textSize = Math.max(textRect.width, textRect.height); - - // Handle - if (useHandle) { - shapes.handleGroups = []; - shapes.handleThumbs = []; - shapes.handleLabels = []; - shapes.handleLabelPoints = []; - - this._createHandle(barGroup, 0, itemSize, textSize, orient, itemAlign); - this._createHandle(barGroup, 1, itemSize, textSize, orient, itemAlign); - } - - // Indicator - // FIXME - - targetGroup.add(barGroup); - }, - - /** - * @private - */ - _createHandle: function (barGroup, handleIndex, itemSize, textSize, orient) { - var handleGroup = new graphic.Group({position: [itemSize[0], 0]}); - var handleThumb = createPolygon( - createHandlePoints(handleIndex, textSize), - zrUtil.bind(this._modifyHandle, this, handleIndex), - 'move' - ); - handleGroup.add(handleThumb); - - // For text locating. Text is always horizontal layout - // but should not be effected by transform. - var handleLabelPoint = { - x: orient === 'horizontal' - ? textSize / 2 - : textSize * 1.5, - y: orient === 'horizontal' - ? (handleIndex === 0 ? -(textSize * 1.5) : (textSize * 1.5)) - : (handleIndex === 0 ? -textSize / 2 : textSize / 2) - }; - - var textStyleModel = this.visualMapModel.textStyleModel; - var handleLabel = new graphic.Text({ - silent: true, - style: { - x: 0, y: 0, text: '', - textBaseline: 'middle', - textFont: textStyleModel.getFont(), - fill: textStyleModel.getTextColor() - } - }); - - this.group.add(handleLabel); // Text do not transform - - var shapes = this._shapes; - shapes.handleThumbs[handleIndex] = handleThumb; - shapes.handleGroups[handleIndex] = handleGroup; - shapes.handleLabelPoints[handleIndex] = handleLabelPoint; - shapes.handleLabels[handleIndex] = handleLabel; - - barGroup.add(handleGroup); - }, - - /** - * @private - */ - _modifyHandle: function (handleIndex, dx, dy) { - if (!this._useHandle) { - return; - } - - // Transform dx, dy to bar coordination. - var vertex = this._applyTransform([dx, dy], this._shapes.barGroup, true); - this._updateInterval(handleIndex, vertex[1]); - - this.api.dispatchAction({ - type: 'selectDataRange', - from: this.uid, - visualMapId: this.visualMapModel.id, - selected: this._dataInterval.slice() - }); - }, - - /** - * @private - */ - _resetInterval: function () { - var visualMapModel = this.visualMapModel; - - var dataInterval = this._dataInterval = visualMapModel.getSelected(); - var dataExtent = visualMapModel.getExtent(); - var sizeExtent = [0, visualMapModel.itemSize[1]]; - - this._handleEnds = [ - linearMap(dataInterval[0], dataExtent, sizeExtent,true), - linearMap(dataInterval[1], dataExtent, sizeExtent,true) - ]; - }, - - /** - * @private - * @param {(number|string)} handleIndex 0 or 1 or 'all' - * @param {number} dx - * @param {number} dy - */ - _updateInterval: function (handleIndex, delta) { - delta = delta || 0; - var visualMapModel = this.visualMapModel; - var handleEnds = this._handleEnds; - - sliderMove( - delta, - handleEnds, - [0, visualMapModel.itemSize[1]], - handleIndex === 'all' ? 'rigid' : 'push', - handleIndex - ); - var dataExtent = visualMapModel.getExtent(); - var sizeExtent = [0, visualMapModel.itemSize[1]]; - // Update data interval. - this._dataInterval = [ - linearMap(handleEnds[0], sizeExtent, dataExtent, true), - linearMap(handleEnds[1], sizeExtent, dataExtent, true) - ]; - }, - - /** - * @private - */ - _updateView: function (forSketch) { - var visualMapModel = this.visualMapModel; - var dataExtent = visualMapModel.getExtent(); - var shapes = this._shapes; - var dataInterval = this._dataInterval; - - var outOfRangeHandleEnds = [0, visualMapModel.itemSize[1]]; - var inRangeHandleEnds = forSketch ? outOfRangeHandleEnds : this._handleEnds; - - var visualInRange = this._createBarVisual( - dataInterval, dataExtent, inRangeHandleEnds, 'inRange' - ); - var visualOutOfRange = this._createBarVisual( - dataExtent, dataExtent, outOfRangeHandleEnds, 'outOfRange' - ); - - shapes.inRange - .setStyle('fill', visualInRange.barColor) - .setShape('points', visualInRange.barPoints); - shapes.outOfRange - .setStyle('fill', visualOutOfRange.barColor) - .setShape('points', visualOutOfRange.barPoints); - - this._useHandle && each([0, 1], function (handleIndex) { - - shapes.handleThumbs[handleIndex].setStyle( - 'fill', visualInRange.handlesColor[handleIndex] - ); - - shapes.handleLabels[handleIndex].setStyle({ - text: visualMapModel.formatValueText(dataInterval[handleIndex]), - textAlign: this._applyTransform( - this._orient === 'horizontal' - ? (handleIndex === 0 ? 'bottom' : 'top') - : 'left', - shapes.barGroup - ) - }); - - }, this); - - this._updateHandlePosition(inRangeHandleEnds); - }, - - /** - * @private - */ - _createBarVisual: function (dataInterval, dataExtent, handleEnds, forceState) { - var colorStops = this.getControllerVisual(dataInterval, forceState, 'color').color; - - var symbolSizes = [ - this.getControllerVisual(dataInterval[0], forceState, 'symbolSize').symbolSize, - this.getControllerVisual(dataInterval[1], forceState, 'symbolSize').symbolSize - ]; - var barPoints = this._createBarPoints(handleEnds, symbolSizes); - - return { - barColor: new LinearGradient(0, 0, 1, 1, colorStops), - barPoints: barPoints, - handlesColor: [ - colorStops[0].color, - colorStops[colorStops.length - 1].color - ] - }; - }, - - /** - * @private - */ - _createBarPoints: function (handleEnds, symbolSizes) { - var itemSize = this.visualMapModel.itemSize; - - return [ - [itemSize[0] - symbolSizes[0], handleEnds[0]], - [itemSize[0], handleEnds[0]], - [itemSize[0], handleEnds[1]], - [itemSize[0] - symbolSizes[1], handleEnds[1]] - ]; - }, - - /** - * @private - */ - _createBarGroup: function (itemAlign) { - var orient = this._orient; - var inverse = this.visualMapModel.get('inverse'); - - return new graphic.Group( - (orient === 'horizontal' && !inverse) - ? {scale: itemAlign === 'bottom' ? [1, 1] : [-1, 1], rotation: Math.PI / 2} - : (orient === 'horizontal' && inverse) - ? {scale: itemAlign === 'bottom' ? [-1, 1] : [1, 1], rotation: -Math.PI / 2} - : (orient === 'vertical' && !inverse) - ? {scale: itemAlign === 'left' ? [1, -1] : [-1, -1]} - : {scale: itemAlign === 'left' ? [1, 1] : [-1, 1]} - ); - }, - - /** - * @private - */ - _updateHandlePosition: function (handleEnds) { - if (!this._useHandle) { - return; - } - - var shapes = this._shapes; - - each([0, 1], function (handleIndex) { - var handleGroup = shapes.handleGroups[handleIndex]; - handleGroup.position[1] = handleEnds[handleIndex]; - - // Update handle label position. - var labelPoint = shapes.handleLabelPoints[handleIndex]; - var textPoint = graphic.applyTransform( - [labelPoint.x, labelPoint.y], - graphic.getTransform(handleGroup, this.group) - ); - - shapes.handleLabels[handleIndex].setStyle({ - x: textPoint[0], y: textPoint[1] - }); - }, this); - }, - - /** - * @private - */ - _applyTransform: function (vertex, element, inverse) { - var transform = graphic.getTransform(element, this.group); - - return graphic[ - zrUtil.isArray(vertex) - ? 'applyTransform' : 'transformDirection' - ](vertex, transform, inverse); - } - - }); - - function createPolygon(points, onDrift, cursor) { - return new graphic.Polygon({ - shape: {points: points}, - draggable: !!onDrift, - cursor: cursor, - drift: onDrift - }); - } - - function createHandlePoints(handleIndex, textSize) { - return handleIndex === 0 - ? [[0, 0], [textSize, 0], [textSize, -textSize]] - : [[0, 0], [textSize, 0], [textSize, textSize]]; - } - - return ContinuousVisualMapView; -}); + padding: 5, -/** - * @file Data range action - */ -define('echarts/component/visualMap/visualMapAction',['require','../../echarts'],function(require) { + itemSize: 15, - var echarts = require('../../echarts'); + itemGap: 8, - var actionInfo = { - type: 'selectDataRange', - event: 'dataRangeSelected', - // FIXME use updateView appears wrong - update: 'update' - }; + showTitle: true, - echarts.registerAction(actionInfo, function (payload, ecModel) { + iconStyle: { + normal: { + borderColor: '#666', + color: 'none' + }, + emphasis: { + borderColor: '#3E98C5' + } + } + // textStyle: {}, - ecModel.eachComponent({mainType: 'visualMap', query: payload}, function (model) { - model.setSelected(payload.selected); - }); + // feature + } + }); - }); + module.exports = ToolboxModel; -}); -/** - * DataZoom component entry - */ -define('echarts/component/visualMapContinuous',['require','../echarts','./visualMap/preprocessor','./visualMap/typeDefaulter','./visualMap/visualCoding','./visualMap/ContinuousModel','./visualMap/ContinuousView','./visualMap/visualMapAction'],function (require) { - require('../echarts').registerPreprocessor( - require('./visualMap/preprocessor') - ); +/***/ }, +/* 333 */ +/***/ function(module, exports) { - require('./visualMap/typeDefaulter'); - require('./visualMap/visualCoding'); - require('./visualMap/ContinuousModel'); - require('./visualMap/ContinuousView'); - require('./visualMap/visualMapAction'); + 'use strict'; -}); -define('echarts/component/visualMap/PiecewiseModel',['require','./VisualMapModel','zrender/core/util','../../visual/VisualMapping'],function(require) { - - var VisualMapModel = require('./VisualMapModel'); - var zrUtil = require('zrender/core/util'); - var VisualMapping = require('../../visual/VisualMapping'); - - var PiecewiseModel = VisualMapModel.extend({ - - type: 'visualMap.piecewise', - - /** - * Order Rule: - * - * option.categories / option.pieces / option.text / option.selected: - * If !option.inverse, - * Order when vertical: ['top', ..., 'bottom']. - * Order when horizontal: ['left', ..., 'right']. - * If option.inverse, the meaning of - * the order should be reversed. - * - * this._pieceList: - * The order is always [low, ..., high]. - * - * Mapping from location to low-high: - * If !option.inverse - * When vertical, top is high. - * When horizontal, right is high. - * If option.inverse, reverse. - */ - - /** - * @protected - */ - defaultOption: { - selected: null, // Object. If not specified, means selected. - // When pieces and splitNumber: {'0': true, '5': true} - // When categories: {'cate1': false, 'cate3': true} - // When selected === false, means all unselected. - align: 'auto', // 'auto', 'left', 'right' - itemWidth: 20, // 值域图形宽度 - itemHeight: 14, // 值域图形高度 - itemSymbol: 'roundRect', - pieceList: null, // 值顺序:由高到低, item can be: - // {min, max, value, color, colorSaturation, colorAlpha, symbol, symbolSize} - categories: null, // 描述 category 数据。如:['some1', 'some2', 'some3'],设置后,min max失效。 - splitNumber: 5, // 分割段数,默认为5,为0时为线性渐变 (continous) - selectedMode: 'multiple', - itemGap: 10 // 各个item之间的间隔,单位px,默认为10, - // 横向布局时为水平间隔,纵向布局时为纵向间隔 - }, - - /** - * @override - */ - doMergeOption: function (newOption, isInit) { - PiecewiseModel.superApply(this, 'doMergeOption', arguments); - - /** - * The order is always [low, ..., high]. - * [{text: string, interval: Array.}, ...] - * @private - * @type {Array.} - */ - this._pieceList = []; - - this.resetTargetSeries(newOption, isInit); - this.resetExtent(); - - /** - * 'pieces', 'categories', 'splitNumber' - * @type {string} - */ - var mode = this._mode = this._decideMode(); - - resetMethods[this._mode].call(this); - - this._resetSelected(newOption, isInit); - - var categories = this.option.categories; - this.resetVisual(function (mappingOption, state) { - if (mode === 'categories') { - mappingOption.mappingMethod = 'category'; - mappingOption.categories = zrUtil.clone(categories); - } - else { - mappingOption.mappingMethod = 'piecewise'; - mappingOption.pieceList = zrUtil.map(this._pieceList, function (piece) { - var piece = zrUtil.clone(piece); - if (state !== 'inRange') { - piece.visual = null; - } - return piece; - }); - } - }); - }, - - _resetSelected: function (newOption, isInit) { - var thisOption = this.option; - var pieceList = this._pieceList; - - // Selected do not merge but all override. - var selected = (isInit ? thisOption : newOption).selected || {}; - thisOption.selected = selected; - - // Consider 'not specified' means true. - zrUtil.each(pieceList, function (piece, index) { - var key = this.getSelectedMapKey(piece); - if (!(key in selected)) { - selected[key] = true; - } - }, this); - - if (thisOption.selectedMode === 'single') { - // Ensure there is only one selected. - var hasSel = false; - - zrUtil.each(pieceList, function (piece, index) { - var key = this.getSelectedMapKey(piece); - if (selected[key]) { - hasSel - ? (selected[key] = false) - : (hasSel = true); - } - }, this); - } - // thisOption.selectedMode === 'multiple', default: all selected. - }, - - /** - * @public - */ - getSelectedMapKey: function (piece) { - return this._mode === 'categories' - ? piece.value + '' : piece.index + ''; - }, - - /** - * @public - */ - getPieceList: function () { - return this._pieceList; - }, - - /** - * @private - * @return {string} - */ - _decideMode: function () { - var option = this.option; - - return option.pieces && option.pieces.length > 0 - ? 'pieces' - : this.option.categories - ? 'categories' - : 'splitNumber'; - }, - - /** - * @public - * @override - */ - setSelected: function (selected) { - this.option.selected = zrUtil.clone(selected); - }, - - /** - * @public - * @override - */ - getValueState: function (value) { - var pieceList = this._pieceList; - var index = VisualMapping.findPieceIndex(value, pieceList); - - return index != null - ? (this.option.selected[this.getSelectedMapKey(pieceList[index])] - ? 'inRange' : 'outOfRange' - ) - : 'outOfRange'; - } - - }); - - /** - * Key is this._mode - * @type {Object} - * @this {module:echarts/component/viusalMap/PiecewiseMode} - */ - var resetMethods = { - - splitNumber: function () { - var thisOption = this.option; - var precision = thisOption.precision; - var dataExtent = this.getExtent(); - var splitNumber = thisOption.splitNumber; - splitNumber = Math.max(parseInt(splitNumber, 10), 1); - thisOption.splitNumber = splitNumber; - - var splitStep = (dataExtent[1] - dataExtent[0]) / splitNumber; - // Precision auto-adaption - while (+splitStep.toFixed(precision) !== splitStep && precision < 5) { - precision++; - } - thisOption.precision = precision; - splitStep = +splitStep.toFixed(precision); - - for (var i = 0, curr = dataExtent[0]; i < splitNumber; i++, curr += splitStep) { - var max = i === splitNumber - 1 ? dataExtent[1] : (curr + splitStep); - - this._pieceList.push({ - text: this.formatValueText([curr, max]), - index: i, - interval: [curr, max] - }); - } - }, - - categories: function () { - var thisOption = this.option; - zrUtil.each(thisOption.categories, function (cate) { - // FIXME category模式也使用pieceList,但在visualMapping中不是使用pieceList。 - // 是否改一致。 - this._pieceList.push({ - text: this.formatValueText(cate, true), - value: cate - }); - }, this); - - // See "Order Rule". - normalizeReverse(thisOption, this._pieceList); - }, - - pieces: function () { - var thisOption = this.option; - zrUtil.each(thisOption.pieces, function (pieceListItem, index) { - - if (!zrUtil.isObject(pieceListItem)) { - pieceListItem = {value: pieceListItem}; - } - - var item = {text: '', index: index}; - var hasLabel; - - if (pieceListItem.label != null) { - item.text = pieceListItem.label; - hasLabel = true; - } - - if (pieceListItem.hasOwnProperty('value')) { - item.value = pieceListItem.value; - - if (!hasLabel) { - item.text = this.formatValueText(item.value); - } - } - else { - var min = pieceListItem.min; - var max = pieceListItem.max; - min == null && (min = -Infinity); - max == null && (max = Infinity); - if (min === max) { - // Consider: [{min: 5, max: 5, visual: {...}}, {min: 0, max: 5}], - // we use value to lift the priority when min === max - item.value = min; - } - item.interval = [min, max]; - - if (!hasLabel) { - item.text = this.formatValueText([min, max]); - } - } - - item.visual = VisualMapping.retrieveVisuals(pieceListItem); - - this._pieceList.push(item); - - }, this); - - // See "Order Rule". - normalizeReverse(thisOption, this._pieceList); - } - }; - - function normalizeReverse(thisOption, arr) { - var inverse = thisOption.inverse; - if (thisOption.orient === 'vertical' ? !inverse : inverse) { - arr.reverse(); - } - } - - return PiecewiseModel; -}); -define('echarts/component/visualMap/PiecewiseView',['require','./VisualMapView','zrender/core/util','../../util/graphic','../../util/symbol','../../util/layout','./helper'],function(require) { - - var VisualMapView = require('./VisualMapView'); - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var symbolCreators = require('../../util/symbol'); - var layout = require('../../util/layout'); - var helper = require('./helper'); - - var PiecewiseVisualMapView = VisualMapView.extend({ - - type: 'visualMap.piecewise', - - /** - * @protected - * @override - */ - doRender: function () { - var thisGroup = this.group; - - thisGroup.removeAll(); - - var visualMapModel = this.visualMapModel; - var textGap = visualMapModel.get('textGap'); - var textStyleModel = visualMapModel.textStyleModel; - var textFont = textStyleModel.getFont(); - var textFill = textStyleModel.getTextColor(); - var itemAlign = this._getItemAlign(); - var itemSize = visualMapModel.itemSize; - - var viewData = this._getViewData(); - var showLabel = !viewData.endsText; - var showEndsText = !showLabel; - - showEndsText && this._renderEndsText(thisGroup, viewData.endsText[0], itemSize); - - zrUtil.each(viewData.pieceList, renderItem, this); - - showEndsText && this._renderEndsText(thisGroup, viewData.endsText[1], itemSize); - - layout.box( - visualMapModel.get('orient'), thisGroup, visualMapModel.get('itemGap') - ); - - this.renderBackground(thisGroup); - - this.positionGroup(thisGroup); - - function renderItem(item) { - var itemGroup = new graphic.Group(); - itemGroup.onclick = zrUtil.bind(this._onItemClick, this, item.piece); - - this._createItemSymbol(itemGroup, item.piece, [0, 0, itemSize[0], itemSize[1]]); - - if (showLabel) { - itemGroup.add(new graphic.Text({ - style: { - x: itemAlign === 'right' ? -textGap : itemSize[0] + textGap, - y: itemSize[1] / 2, - text: item.piece.text, - textBaseline: 'middle', - textAlign: itemAlign, - textFont: textFont, - fill: textFill - } - })); - } - - thisGroup.add(itemGroup); - } - }, - - /** - * @private - */ - _getItemAlign: function () { - var visualMapModel = this.visualMapModel; - var modelOption = visualMapModel.option; - if (modelOption.orient === 'vertical') { - return helper.getItemAlign( - visualMapModel, this.api, visualMapModel.itemSize - ); - } - else { // horizontal, most case left unless specifying right. - var align = modelOption.align; - if (!align || align === 'auto') { - align = 'left'; - } - return align; - } - }, - - /** - * @private - */ - _renderEndsText: function (group, text, itemSize) { - if (!text) { - return; - } - var itemGroup = new graphic.Group(); - var textStyleModel = this.visualMapModel.textStyleModel; - itemGroup.add(new graphic.Text({ - style: { - x: itemSize[0] / 2, - y: itemSize[1] / 2, - textBaseline: 'middle', - textAlign: 'center', - text: text, - textFont: textStyleModel.getFont(), - fill: textStyleModel.getTextColor() - } - })); - - group.add(itemGroup); - }, - - /** - * @private - * @return {Object} {peiceList, endsText} The order is the same as screen pixel order. - */ - _getViewData: function () { - var visualMapModel = this.visualMapModel; - - var pieceList = zrUtil.map(visualMapModel.getPieceList(), function (piece, index) { - return {piece: piece, index: index}; - }); - var endsText = visualMapModel.get('text'); - - // Consider orient and inverse. - var orient = visualMapModel.get('orient'); - var inverse = visualMapModel.get('inverse'); - - // Order of pieceList is always [low, ..., high] - if (orient === 'horizontal' ? inverse : !inverse) { - pieceList.reverse(); - } - // Origin order of endsText is [high, low] - else if (endsText) { - endsText = endsText.slice().reverse(); - } - - return {pieceList: pieceList, endsText: endsText}; - }, - - /** - * @private - */ - _createItemSymbol: function (group, piece, shapeParam) { - var representValue; - if (this.visualMapModel.isCategory()) { - representValue = piece.value; - } - else { - if (piece.value != null) { - representValue = piece.value; - } - else { - var pieceInterval = piece.interval || []; - representValue = (pieceInterval[0] + pieceInterval[1]) / 2; - } - } - - var visualObj = this.getControllerVisual(representValue); - - group.add(symbolCreators.createSymbol( - visualObj.symbol, - shapeParam[0], shapeParam[1], shapeParam[2], shapeParam[3], - visualObj.color - )); - }, - - /** - * @private - */ - _onItemClick: function (piece) { - var visualMapModel = this.visualMapModel; - var option = visualMapModel.option; - var selected = zrUtil.clone(option.selected); - var newKey = visualMapModel.getSelectedMapKey(piece); - - if (option.selectedMode === 'single') { - selected[newKey] = true; - zrUtil.each(selected, function (o, key) { - selected[key] = key === newKey; - }); - } - else { - selected[newKey] = !selected[newKey]; - } - - this.api.dispatchAction({ - type: 'selectDataRange', - from: this.uid, - visualMapId: this.visualMapModel.id, - selected: selected - }); - } - }); - - return PiecewiseVisualMapView; -}); + var features = {}; -/** - * DataZoom component entry - */ -define('echarts/component/visualMapPiecewise',['require','../echarts','./visualMap/preprocessor','./visualMap/typeDefaulter','./visualMap/visualCoding','./visualMap/PiecewiseModel','./visualMap/PiecewiseView','./visualMap/visualMapAction'],function (require) { + module.exports = { + register: function (name, ctor) { + features[name] = ctor; + }, - require('../echarts').registerPreprocessor( - require('./visualMap/preprocessor') - ); + get: function (name) { + return features[name]; + } + }; - require('./visualMap/typeDefaulter'); - require('./visualMap/visualCoding'); - require('./visualMap/PiecewiseModel'); - require('./visualMap/PiecewiseView'); - require('./visualMap/visualMapAction'); -}); -/** - * visualMap component entry - */ -define('echarts/component/visualMap',['require','./visualMapContinuous','./visualMapPiecewise'],function (require) { +/***/ }, +/* 334 */ +/***/ function(module, exports, __webpack_require__) { - require('./visualMapContinuous'); - require('./visualMapPiecewise'); + /* WEBPACK VAR INJECTION */(function(process) { -}); -define('echarts/component/marker/MarkPointModel',['require','../../util/model','../../echarts'],function (require) { - // Default enable markPoint - // var globalDefault = require('../../model/globalDefault'); - var modelUtil = require('../../util/model'); - // // Force to load markPoint component - // globalDefault.markPoint = {}; - - var MarkPointModel = require('../../echarts').extendComponentModel({ - - type: 'markPoint', - - dependencies: ['series', 'grid', 'polar'], - /** - * @overrite - */ - init: function (option, parentModel, ecModel, extraOpt) { - this.mergeDefaultAndTheme(option, ecModel); - this.mergeOption(option, ecModel, extraOpt.createdBySelf, true); - }, - - mergeOption: function (newOpt, ecModel, createdBySelf, isInit) { - if (!createdBySelf) { - ecModel.eachSeries(function (seriesModel) { - var markPointOpt = seriesModel.get('markPoint'); - var mpModel = seriesModel.markPointModel; - if (!markPointOpt || !markPointOpt.data) { - seriesModel.markPointModel = null; - return; - } - if (!mpModel) { - if (isInit) { - // Default label emphasis `position` and `show` - modelUtil.defaultEmphasis( - markPointOpt.label, - ['position', 'show', 'textStyle', 'distance', 'formatter'] - ); - } - var opt = { - // Use the same series index and name - seriesIndex: seriesModel.seriesIndex, - name: seriesModel.name, - createdBySelf: true - }; - mpModel = new MarkPointModel( - markPointOpt, this, ecModel, opt - ); - } - else { - mpModel.mergeOption(markPointOpt, ecModel, true); - } - seriesModel.markPointModel = mpModel; - }, this); - } - }, - - defaultOption: { - zlevel: 0, - z: 5, - symbol: 'pin', // 标注类型 - symbolSize: 50, // 标注大小 - // symbolRotate: null, // 标注旋转控制 - tooltip: { - trigger: 'item' - }, - label: { - normal: { - show: true, - // 标签文本格式器,同Tooltip.formatter,不支持回调 - // formatter: null, - // 可选为'left'|'right'|'top'|'bottom' - position: 'inside' - // 默认使用全局文本样式,详见TEXTSTYLE - // textStyle: null - }, - emphasis: { - show: true - // 标签文本格式器,同Tooltip.formatter,不支持回调 - // formatter: null, - // position: 'inside' // 'left'|'right'|'top'|'bottom' - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - } - }, - itemStyle: { - normal: { - // color: 各异, - // 标注边线颜色,优先于color - // borderColor: 各异, - // 标注边线线宽,单位px,默认为1 - borderWidth: 2 - }, - emphasis: { - // color: 各异 - } - } - } - }); - - return MarkPointModel; -}); -define('echarts/component/marker/markerHelper',['require','zrender/core/util','../../util/number'],function (require) { - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../../util/number'); - var indexOf = zrUtil.indexOf; - - function getPrecision(data, valueAxisDim, dataIndex) { - var precision = -1; - do { - precision = Math.max( - numberUtil.getPrecision(data.get( - valueAxisDim, dataIndex - )), - precision - ); - data = data.stackedOn; - } while (data); - - return precision; - } - - function markerTypeCalculatorWithExtent( - mlType, data, baseDataDim, valueDataDim, baseCoordIndex, valueCoordIndex - ) { - var coordArr = []; - var value = numCalculate(data, valueDataDim, mlType); - - var dataIndex = data.indexOfNearest(valueDataDim, value, true); - coordArr[baseCoordIndex] = data.get(baseDataDim, dataIndex, true); - coordArr[valueCoordIndex] = data.get(valueDataDim, dataIndex, true); - - var precision = getPrecision(data, valueDataDim, dataIndex); - if (precision >= 0) { - coordArr[valueCoordIndex] = +coordArr[valueCoordIndex].toFixed(precision); - } - - return coordArr; - } - - var curry = zrUtil.curry; - // TODO Specified percent - var markerTypeCalculator = { - /** - * @method - * @param {module:echarts/data/List} data - * @param {string} baseAxisDim - * @param {string} valueAxisDim - */ - min: curry(markerTypeCalculatorWithExtent, 'min'), - /** - * @method - * @param {module:echarts/data/List} data - * @param {string} baseAxisDim - * @param {string} valueAxisDim - */ - max: curry(markerTypeCalculatorWithExtent, 'max'), - /** - * @method - * @param {module:echarts/data/List} data - * @param {string} baseAxisDim - * @param {string} valueAxisDim - */ - average: curry(markerTypeCalculatorWithExtent, 'average') - }; - - /** - * Transform markPoint data item to format used in List by do the following - * 1. Calculate statistic like `max`, `min`, `average` - * 2. Convert `item.xAxis`, `item.yAxis` to `item.coord` array - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/coord/*} [coordSys] - * @param {Object} item - * @return {Object} - */ - var dataTransform = function (seriesModel, item) { - var data = seriesModel.getData(); - var coordSys = seriesModel.coordinateSystem; - - // 1. If not specify the position with pixel directly - // 2. If `coord` is not a data array. Which uses `xAxis`, - // `yAxis` to specify the coord on each dimension - if ((isNaN(item.x) || isNaN(item.y)) - && !zrUtil.isArray(item.coord) - && coordSys - ) { - var axisInfo = getAxisInfo(item, data, coordSys, seriesModel); - - // Clone the option - // Transform the properties xAxis, yAxis, radiusAxis, angleAxis, geoCoord to value - item = zrUtil.clone(item); - - if (item.type - && markerTypeCalculator[item.type] - && axisInfo.baseAxis && axisInfo.valueAxis - ) { - var dims = coordSys.dimensions; - var baseCoordIndex = indexOf(dims, axisInfo.baseAxis.dim); - var valueCoordIndex = indexOf(dims, axisInfo.valueAxis.dim); - - item.coord = markerTypeCalculator[item.type]( - data, axisInfo.baseDataDim, axisInfo.valueDataDim, - baseCoordIndex, valueCoordIndex - ); - // Force to use the value of calculated value. - item.value = item.coord[valueCoordIndex]; - } - else { - // FIXME Only has one of xAxis and yAxis. - item.coord = [ - item.xAxis != null ? item.xAxis : item.radiusAxis, - item.yAxis != null ? item.yAxis : item.angleAxis - ]; - } - } - return item; - }; - - var getAxisInfo = function (item, data, coordSys, seriesModel) { - var ret = {}; - - if (item.valueIndex != null || item.valueDim != null) { - ret.valueDataDim = item.valueIndex != null - ? data.getDimension(item.valueIndex) : item.valueDim; - ret.valueAxis = coordSys.getAxis(seriesModel.dataDimToCoordDim(ret.valueDataDim)); - ret.baseAxis = coordSys.getOtherAxis(ret.valueAxis); - ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0]; - } - else { - ret.baseAxis = seriesModel.getBaseAxis(); - ret.valueAxis = coordSys.getOtherAxis(ret.baseAxis); - ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0]; - ret.valueDataDim = seriesModel.coordDimToDataDim(ret.valueAxis.dim)[0]; - } - - return ret; - }; - - /** - * Filter data which is out of coordinateSystem range - * [dataFilter description] - * @param {module:echarts/coord/*} [coordSys] - * @param {Object} item - * @return {boolean} - */ - var dataFilter = function (coordSys, item) { - // Alwalys return true if there is no coordSys - return (coordSys && item.coord && (item.x == null || item.y == null)) - ? coordSys.containData(item.coord) : true; - }; - - var dimValueGetter = function (item, dimName, dataIndex, dimIndex) { - // x, y, radius, angle - if (dimIndex < 2) { - return item.coord && item.coord[dimIndex]; - } - else { - item.value; - } - }; - - var numCalculate = function (data, valueDataDim, mlType) { - return mlType === 'average' - ? data.getSum(valueDataDim, true) / data.count() - : data.getDataExtent(valueDataDim, true)[mlType === 'max' ? 1 : 0]; - }; - - return { - dataTransform: dataTransform, - dataFilter: dataFilter, - dimValueGetter: dimValueGetter, - getAxisInfo: getAxisInfo, - numCalculate: numCalculate - }; -}); -define('echarts/component/marker/MarkPointView',['require','../../chart/helper/SymbolDraw','zrender/core/util','../../util/format','../../util/model','../../util/number','../../data/List','./markerHelper','../../echarts'],function (require) { - - var SymbolDraw = require('../../chart/helper/SymbolDraw'); - var zrUtil = require('zrender/core/util'); - var formatUtil = require('../../util/format'); - var modelUtil = require('../../util/model'); - var numberUtil = require('../../util/number'); - - var addCommas = formatUtil.addCommas; - var encodeHTML = formatUtil.encodeHTML; - - var List = require('../../data/List'); - - var markerHelper = require('./markerHelper'); - - // FIXME - var markPointFormatMixin = { - getRawDataArray: function () { - return this.option.data; - }, - - formatTooltip: function (dataIndex) { - var data = this.getData(); - var value = this.getRawValue(dataIndex); - var formattedValue = zrUtil.isArray(value) - ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); - var name = data.getName(dataIndex); - return this.name + '
' - + ((name ? encodeHTML(name) + ' : ' : '') + formattedValue); - }, - - getData: function () { - return this._data; - }, - - setData: function (data) { - this._data = data; - } - }; - - zrUtil.defaults(markPointFormatMixin, modelUtil.dataFormatMixin); - - require('../../echarts').extendComponentView({ - - type: 'markPoint', - - init: function () { - this._symbolDrawMap = {}; - }, - - render: function (markPointModel, ecModel, api) { - var symbolDrawMap = this._symbolDrawMap; - for (var name in symbolDrawMap) { - symbolDrawMap[name].__keep = false; - } - - ecModel.eachSeries(function (seriesModel) { - var mpModel = seriesModel.markPointModel; - mpModel && this._renderSeriesMP(seriesModel, mpModel, api); - }, this); - - for (var name in symbolDrawMap) { - if (!symbolDrawMap[name].__keep) { - symbolDrawMap[name].remove(); - this.group.remove(symbolDrawMap[name].group); - } - } - }, - - _renderSeriesMP: function (seriesModel, mpModel, api) { - var coordSys = seriesModel.coordinateSystem; - var seriesName = seriesModel.name; - var seriesData = seriesModel.getData(); - - var symbolDrawMap = this._symbolDrawMap; - var symbolDraw = symbolDrawMap[seriesName]; - if (!symbolDraw) { - symbolDraw = symbolDrawMap[seriesName] = new SymbolDraw(); - } - - var mpData = createList(coordSys, seriesModel, mpModel); - var dims = coordSys && coordSys.dimensions; - - // FIXME - zrUtil.mixin(mpModel, markPointFormatMixin); - mpModel.setData(mpData); - - mpData.each(function (idx) { - var itemModel = mpData.getItemModel(idx); - var point; - var xPx = itemModel.getShallow('x'); - var yPx = itemModel.getShallow('y'); - if (xPx != null && yPx != null) { - point = [ - numberUtil.parsePercent(xPx, api.getWidth()), - numberUtil.parsePercent(yPx, api.getHeight()) - ]; - } - // Chart like bar may have there own marker positioning logic - else if (seriesModel.getMarkerPosition) { - // Use the getMarkerPoisition - point = seriesModel.getMarkerPosition( - mpData.getValues(mpData.dimensions, idx) - ); - } - else if (coordSys) { - var x = mpData.get(dims[0], idx); - var y = mpData.get(dims[1], idx); - point = coordSys.dataToPoint([x, y]); - } - - mpData.setItemLayout(idx, point); - - var symbolSize = itemModel.getShallow('symbolSize'); - if (typeof symbolSize === 'function') { - // FIXME 这里不兼容 ECharts 2.x,2.x 貌似参数是整个数据? - symbolSize = symbolSize( - mpModel.getRawValue(idx), mpModel.getDataParams(idx) - ); - } - mpData.setItemVisual(idx, { - symbolSize: symbolSize, - color: itemModel.get('itemStyle.normal.color') - || seriesData.getVisual('color'), - symbol: itemModel.getShallow('symbol') - }); - }); - - // TODO Text are wrong - symbolDraw.updateData(mpData); - this.group.add(symbolDraw.group); - - // Set host model for tooltip - // FIXME - mpData.eachItemGraphicEl(function (el) { - el.traverse(function (child) { - child.hostModel = mpModel; - }); - }); - - symbolDraw.__keep = true; - } - }); - - /** - * @inner - * @param {module:echarts/coord/*} [coordSys] - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/model/Model} mpModel - */ - function createList(coordSys, seriesModel, mpModel) { - var coordDimsInfos = zrUtil.map(coordSys.dimensions, function (coordDim) { - var info = seriesModel.getData().getDimensionInfo( - seriesModel.coordDimToDataDim(coordDim)[0] - ); - info.name = coordDim; - return info; - }); - - var mpData = new List(coordDimsInfos, mpModel); - - if (coordSys) { - mpData.initData( - zrUtil.filter( - zrUtil.map(mpModel.get('data'), zrUtil.curry( - markerHelper.dataTransform, seriesModel - )), - zrUtil.curry(markerHelper.dataFilter, coordSys) - ), - null, - markerHelper.dimValueGetter - ); - } - - return mpData; - } + var featureManager = __webpack_require__(333); + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var Model = __webpack_require__(8); + var DataDiffer = __webpack_require__(95); + var listComponentHelper = __webpack_require__(266); + var textContain = __webpack_require__(14); -}); -// HINT Markpoint can't be used too much -define('echarts/component/markPoint',['require','./marker/MarkPointModel','./marker/MarkPointView','../echarts'],function (require) { + module.exports = __webpack_require__(1).extendComponentView({ + + type: 'toolbox', + + render: function (toolboxModel, ecModel, api) { + var group = this.group; + group.removeAll(); + + if (!toolboxModel.get('show')) { + return; + } + + var itemSize = +toolboxModel.get('itemSize'); + var featureOpts = toolboxModel.get('feature') || {}; + var features = this._features || (this._features = {}); + + var featureNames = []; + zrUtil.each(featureOpts, function (opt, name) { + featureNames.push(name); + }); + + (new DataDiffer(this._featureNames || [], featureNames)) + .add(process) + .update(process) + .remove(zrUtil.curry(process, null)) + .execute(); + + // Keep for diff. + this._featureNames = featureNames; + + function process(newIndex, oldIndex) { + var featureName = featureNames[newIndex]; + var oldName = featureNames[oldIndex]; + var featureOpt = featureOpts[featureName]; + var featureModel = new Model(featureOpt, toolboxModel, toolboxModel.ecModel); + var feature; + + if (featureName && !oldName) { // Create + if (isUserFeatureName(featureName)) { + feature = { + model: featureModel, + onclick: featureModel.option.onclick, + featureName: featureName + }; + } + else { + var Feature = featureManager.get(featureName); + if (!Feature) { + return; + } + feature = new Feature(featureModel); + } + features[featureName] = feature; + } + else { + feature = features[oldName]; + // If feature does not exsit. + if (!feature) { + return; + } + feature.model = featureModel; + } + + if (!featureName && oldName) { + feature.dispose && feature.dispose(ecModel, api); + return; + } + + if (!featureModel.get('show') || feature.unusable) { + feature.remove && feature.remove(ecModel, api); + return; + } + + createIconPaths(featureModel, feature, featureName); + + featureModel.setIconStatus = function (iconName, status) { + var option = this.option; + var iconPaths = this.iconPaths; + option.iconStatus = option.iconStatus || {}; + option.iconStatus[iconName] = status; + // FIXME + iconPaths[iconName] && iconPaths[iconName].trigger(status); + }; + + if (feature.render) { + feature.render(featureModel, ecModel, api); + } + } + + function createIconPaths(featureModel, feature, featureName) { + var iconStyleModel = featureModel.getModel('iconStyle'); + + // If one feature has mutiple icon. they are orginaized as + // { + // icon: { + // foo: '', + // bar: '' + // }, + // title: { + // foo: '', + // bar: '' + // } + // } + var icons = feature.getIcons ? feature.getIcons() : featureModel.get('icon'); + var titles = featureModel.get('title') || {}; + if (typeof icons === 'string') { + var icon = icons; + var title = titles; + icons = {}; + titles = {}; + icons[featureName] = icon; + titles[featureName] = title; + } + var iconPaths = featureModel.iconPaths = {}; + zrUtil.each(icons, function (icon, iconName) { + var normalStyle = iconStyleModel.getModel('normal').getItemStyle(); + var hoverStyle = iconStyleModel.getModel('emphasis').getItemStyle(); + + var style = { + x: -itemSize / 2, + y: -itemSize / 2, + width: itemSize, + height: itemSize + }; + var path = icon.indexOf('image://') === 0 + ? ( + style.image = icon.slice(8), + new graphic.Image({style: style}) + ) + : graphic.makePath( + icon.replace('path://', ''), + { + style: normalStyle, + hoverStyle: hoverStyle, + rectHover: true + }, + style, + 'center' + ); + + graphic.setHoverStyle(path); + + if (toolboxModel.get('showTitle')) { + path.__title = titles[iconName]; + path.on('mouseover', function () { + path.setStyle({ + text: titles[iconName], + textPosition: hoverStyle.textPosition || 'bottom', + textFill: hoverStyle.fill || hoverStyle.stroke || '#000', + textAlign: hoverStyle.textAlign || 'center' + }); + }) + .on('mouseout', function () { + path.setStyle({ + textFill: null + }); + }); + } + path.trigger(featureModel.get('iconStatus.' + iconName) || 'normal'); + + group.add(path); + path.on('click', zrUtil.bind( + feature.onclick, feature, ecModel, api, iconName + )); + + iconPaths[iconName] = path; + }); + } + + listComponentHelper.layout(group, toolboxModel, api); + // Render background after group is layout + // FIXME + listComponentHelper.addBackground(group, toolboxModel); + + // Adjust icon title positions to avoid them out of screen + group.eachChild(function (icon) { + var titleText = icon.__title; + var hoverStyle = icon.hoverStyle; + // May be background element + if (hoverStyle && titleText) { + var rect = textContain.getBoundingRect( + titleText, hoverStyle.font + ); + var offsetX = icon.position[0] + group.position[0]; + var offsetY = icon.position[1] + group.position[1] + itemSize; + + var needPutOnTop = false; + if (offsetY + rect.height > api.getHeight()) { + hoverStyle.textPosition = 'top'; + needPutOnTop = true; + } + var topOffset = needPutOnTop ? (-5 - rect.height) : (itemSize + 8); + if (offsetX + rect.width / 2 > api.getWidth()) { + hoverStyle.textPosition = ['100%', topOffset]; + hoverStyle.textAlign = 'right'; + } + else if (offsetX - rect.width / 2 < 0) { + hoverStyle.textPosition = [0, topOffset]; + hoverStyle.textAlign = 'left'; + } + } + }); + }, + + remove: function (ecModel, api) { + zrUtil.each(this._features, function (feature) { + feature.remove && feature.remove(ecModel, api); + }); + this.group.removeAll(); + }, + + dispose: function (ecModel, api) { + zrUtil.each(this._features, function (feature) { + feature.dispose && feature.dispose(ecModel, api); + }); + } + }); + + function isUserFeatureName(featureName) { + return featureName.indexOf('my') === 0; + } + + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(335))) + +/***/ }, +/* 335 */ +/***/ function(module, exports) { + + // shim for using process in browser + + var process = module.exports = {}; + var queue = []; + var draining = false; + var currentQueue; + var queueIndex = -1; + + function cleanUpNextTick() { + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } + } + + function drainQueue() { + if (draining) { + return; + } + var timeout = setTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + clearTimeout(timeout); + } + + process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + setTimeout(drainQueue, 0); + } + }; + + // v8 likes predictible objects + function Item(fun, array) { + this.fun = fun; + this.array = array; + } + Item.prototype.run = function () { + this.fun.apply(null, this.array); + }; + process.title = 'browser'; + process.browser = true; + process.env = {}; + process.argv = []; + process.version = ''; // empty string to avoid regexp issues + process.versions = {}; + + function noop() {} + + process.on = noop; + process.addListener = noop; + process.once = noop; + process.off = noop; + process.removeListener = noop; + process.removeAllListeners = noop; + process.emit = noop; + + process.binding = function (name) { + throw new Error('process.binding is not supported'); + }; + + process.cwd = function () { return '/' }; + process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); + }; + process.umask = function() { return 0; }; + + +/***/ }, +/* 336 */ +/***/ function(module, exports, __webpack_require__) { + + + + var env = __webpack_require__(78); + + function SaveAsImage (model) { + this.model = model; + } + + SaveAsImage.defaultOption = { + show: true, + icon: 'M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0', + title: '保存为图片', + type: 'png', + // Default use option.backgroundColor + // backgroundColor: '#fff', + name: '', + excludeComponents: ['toolbox'], + pixelRatio: 1, + lang: ['右键另存为图片'] + }; + + SaveAsImage.prototype.unusable = !env.canvasSupported; + + var proto = SaveAsImage.prototype; + + proto.onclick = function (ecModel, api) { + var model = this.model; + var title = model.get('name') || ecModel.get('title.0.text') || 'echarts'; + var $a = document.createElement('a'); + var type = model.get('type', true) || 'png'; + $a.download = title + '.' + type; + $a.target = '_blank'; + var url = api.getConnectedDataURL({ + type: type, + backgroundColor: model.get('backgroundColor', true) + || ecModel.get('backgroundColor') || '#fff', + excludeComponents: model.get('excludeComponents'), + pixelRatio: model.get('pixelRatio') + }); + $a.href = url; + // Chrome and Firefox + if (typeof MouseEvent === 'function') { + var evt = new MouseEvent('click', { + view: window, + bubbles: true, + cancelable: false + }); + $a.dispatchEvent(evt); + } + // IE + else { + var lang = model.get('lang'); + var html = '' + + '' + + '' + + ''; + var tab = window.open(); + tab.document.write(html); + } + }; + + __webpack_require__(333).register( + 'saveAsImage', SaveAsImage + ); + + module.exports = SaveAsImage; + + +/***/ }, +/* 337 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + + function MagicType(model) { + this.model = model; + } + + MagicType.defaultOption = { + show: true, + type: [], + // Icon group + icon: { + line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4', + bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7', + stack: 'M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z', // jshint ignore:line + tiled: 'M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z' + }, + title: { + line: '切换为折线图', + bar: '切换为柱状图', + stack: '切换为堆叠', + tiled: '切换为平铺' + }, + option: {}, + seriesIndex: {} + }; + + var proto = MagicType.prototype; + + proto.getIcons = function () { + var model = this.model; + var availableIcons = model.get('icon'); + var icons = {}; + zrUtil.each(model.get('type'), function (type) { + if (availableIcons[type]) { + icons[type] = availableIcons[type]; + } + }); + return icons; + }; + + var seriesOptGenreator = { + 'line': function (seriesType, seriesId, seriesModel, model) { + if (seriesType === 'bar') { + return zrUtil.merge({ + id: seriesId, + type: 'line', + // Preserve data related option + data: seriesModel.get('data'), + stack: seriesModel.get('stack'), + markPoint: seriesModel.get('markPoint'), + markLine: seriesModel.get('markLine') + }, model.get('option.line')); + } + }, + 'bar': function (seriesType, seriesId, seriesModel, model) { + if (seriesType === 'line') { + return zrUtil.merge({ + id: seriesId, + type: 'bar', + // Preserve data related option + data: seriesModel.get('data'), + stack: seriesModel.get('stack'), + markPoint: seriesModel.get('markPoint'), + markLine: seriesModel.get('markLine') + }, model.get('option.bar')); + } + }, + 'stack': function (seriesType, seriesId, seriesModel, model) { + if (seriesType === 'line' || seriesType === 'bar') { + return { + id: seriesId, + stack: '__ec_magicType_stack__' + }; + } + }, + 'tiled': function (seriesType, seriesId, seriesModel, model) { + if (seriesType === 'line' || seriesType === 'bar') { + return { + id: seriesId, + stack: '' + }; + } + } + }; + + var radioTypes = [ + ['line', 'bar'], + ['stack', 'tiled'] + ]; + + proto.onclick = function (ecModel, api, type) { + var model = this.model; + var seriesIndex = model.get('seriesIndex.' + type); + // Not supported magicType + if (!seriesOptGenreator[type]) { + return; + } + var newOption = { + series: [] + }; + var generateNewSeriesTypes = function (seriesModel) { + var seriesType = seriesModel.subType; + var seriesId = seriesModel.id; + var newSeriesOpt = seriesOptGenreator[type]( + seriesType, seriesId, seriesModel, model + ); + if (newSeriesOpt) { + // PENDING If merge original option? + zrUtil.defaults(newSeriesOpt, seriesModel.option); + newOption.series.push(newSeriesOpt); + } + }; + + zrUtil.each(radioTypes, function (radio) { + if (zrUtil.indexOf(radio, type) >= 0) { + zrUtil.each(radio, function (item) { + model.setIconStatus(item, 'normal'); + }); + } + }); + + model.setIconStatus(type, 'emphasis'); + + ecModel.eachComponent( + { + mainType: 'series', + seriesIndex: seriesIndex + }, generateNewSeriesTypes + ); + api.dispatchAction({ + type: 'changeMagicType', + currentType: type, + newOption: newOption + }); + }; + + var echarts = __webpack_require__(1); + echarts.registerAction({ + type: 'changeMagicType', + event: 'magicTypeChanged', + update: 'prepareAndUpdate' + }, function (payload, ecModel) { + ecModel.mergeOption(payload.newOption); + }); + + __webpack_require__(333).register('magicType', MagicType); + + module.exports = MagicType; + + +/***/ }, +/* 338 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/component/toolbox/feature/DataView + */ + + + + var zrUtil = __webpack_require__(3); + var eventTool = __webpack_require__(80); + + + var BLOCK_SPLITER = new Array(60).join('-'); + var ITEM_SPLITER = '\t'; + /** + * Group series into two types + * 1. on category axis, like line, bar + * 2. others, like scatter, pie + * @param {module:echarts/model/Global} ecModel + * @return {Object} + * @inner + */ + function groupSeries(ecModel) { + var seriesGroupByCategoryAxis = {}; + var otherSeries = []; + var meta = []; + ecModel.eachRawSeries(function (seriesModel) { + var coordSys = seriesModel.coordinateSystem; + + if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) { + var baseAxis = coordSys.getBaseAxis(); + if (baseAxis.type === 'category') { + var key = baseAxis.dim + '_' + baseAxis.index; + if (!seriesGroupByCategoryAxis[key]) { + seriesGroupByCategoryAxis[key] = { + categoryAxis: baseAxis, + valueAxis: coordSys.getOtherAxis(baseAxis), + series: [] + }; + meta.push({ + axisDim: baseAxis.dim, + axisIndex: baseAxis.index + }); + } + seriesGroupByCategoryAxis[key].series.push(seriesModel); + } + else { + otherSeries.push(seriesModel); + } + } + else { + otherSeries.push(seriesModel); + } + }); + + return { + seriesGroupByCategoryAxis: seriesGroupByCategoryAxis, + other: otherSeries, + meta: meta + }; + } + + /** + * Assemble content of series on cateogory axis + * @param {Array.} series + * @return {string} + * @inner + */ + function assembleSeriesWithCategoryAxis(series) { + var tables = []; + zrUtil.each(series, function (group, key) { + var categoryAxis = group.categoryAxis; + var valueAxis = group.valueAxis; + var valueAxisDim = valueAxis.dim; + + var headers = [' '].concat(zrUtil.map(group.series, function (series) { + return series.name; + })); + var columns = [categoryAxis.model.getCategories()]; + zrUtil.each(group.series, function (series) { + columns.push(series.getRawData().mapArray(valueAxisDim, function (val) { + return val; + })); + }); + // Assemble table content + var lines = [headers.join(ITEM_SPLITER)]; + for (var i = 0; i < columns[0].length; i++) { + var items = []; + for (var j = 0; j < columns.length; j++) { + items.push(columns[j][i]); + } + lines.push(items.join(ITEM_SPLITER)); + } + tables.push(lines.join('\n')); + }); + return tables.join('\n\n' + BLOCK_SPLITER + '\n\n'); + } + + /** + * Assemble content of other series + * @param {Array.} series + * @return {string} + * @inner + */ + function assembleOtherSeries(series) { + return zrUtil.map(series, function (series) { + var data = series.getRawData(); + var lines = [series.name]; + var vals = []; + data.each(data.dimensions, function () { + var argLen = arguments.length; + var dataIndex = arguments[argLen - 1]; + var name = data.getName(dataIndex); + for (var i = 0; i < argLen - 1; i++) { + vals[i] = arguments[i]; + } + lines.push((name ? (name + ITEM_SPLITER) : '') + vals.join(ITEM_SPLITER)); + }); + return lines.join('\n'); + }).join('\n\n' + BLOCK_SPLITER + '\n\n'); + } + + /** + * @param {module:echarts/model/Global} + * @return {string} + * @inner + */ + function getContentFromModel(ecModel) { + + var result = groupSeries(ecModel); + + return { + value: zrUtil.filter([ + assembleSeriesWithCategoryAxis(result.seriesGroupByCategoryAxis), + assembleOtherSeries(result.other) + ], function (str) { + return str.replace(/[\n\t\s]/g, ''); + }).join('\n\n' + BLOCK_SPLITER + '\n\n'), + + meta: result.meta + }; + } + + + function trim(str) { + return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); + } + /** + * If a block is tsv format + */ + function isTSVFormat(block) { + // Simple method to find out if a block is tsv format + var firstLine = block.slice(0, block.indexOf('\n')); + if (firstLine.indexOf(ITEM_SPLITER) >= 0) { + return true; + } + } + + var itemSplitRegex = new RegExp('[' + ITEM_SPLITER + ']+', 'g'); + /** + * @param {string} tsv + * @return {Array.} + */ + function parseTSVContents(tsv) { + var tsvLines = tsv.split(/\n+/g); + var headers = trim(tsvLines.shift()).split(itemSplitRegex); + + var categories = []; + var series = zrUtil.map(headers, function (header) { + return { + name: header, + data: [] + }; + }); + for (var i = 0; i < tsvLines.length; i++) { + var items = trim(tsvLines[i]).split(itemSplitRegex); + categories.push(items.shift()); + for (var j = 0; j < items.length; j++) { + series[j] && (series[j].data[i] = items[j]); + } + } + return { + series: series, + categories: categories + }; + } + + /** + * @param {string} str + * @return {Array.} + * @inner + */ + function parseListContents(str) { + var lines = str.split(/\n+/g); + var seriesName = trim(lines.shift()); + + var data = []; + for (var i = 0; i < lines.length; i++) { + var items = trim(lines[i]).split(itemSplitRegex); + var name = ''; + var value; + var hasName = false; + if (isNaN(items[0])) { // First item is name + hasName = true; + name = items[0]; + items = items.slice(1); + data[i] = { + name: name, + value: [] + }; + value = data[i].value; + } + else { + value = data[i] = []; + } + for (var j = 0; j < items.length; j++) { + value.push(+items[j]); + } + if (value.length === 1) { + hasName ? (data[i].value = value[0]) : (data[i] = value[0]); + } + } + + return { + name: seriesName, + data: data + }; + } + + /** + * @param {string} str + * @param {Array.} blockMetaList + * @return {Object} + * @inner + */ + function parseContents(str, blockMetaList) { + var blocks = str.split(new RegExp('\n*' + BLOCK_SPLITER + '\n*', 'g')); + var newOption = { + series: [] + }; + zrUtil.each(blocks, function (block, idx) { + if (isTSVFormat(block)) { + var result = parseTSVContents(block); + var blockMeta = blockMetaList[idx]; + var axisKey = blockMeta.axisDim + 'Axis'; + + if (blockMeta) { + newOption[axisKey] = newOption[axisKey] || []; + newOption[axisKey][blockMeta.axisIndex] = { + data: result.categories + }; + newOption.series = newOption.series.concat(result.series); + } + } + else { + var result = parseListContents(block); + newOption.series.push(result); + } + }); + return newOption; + } + + /** + * @alias {module:echarts/component/toolbox/feature/DataView} + * @constructor + * @param {module:echarts/model/Model} model + */ + function DataView(model) { + + this._dom = null; + + this.model = model; + } + + DataView.defaultOption = { + show: true, + readOnly: false, + icon: 'M17.5,17.3H33 M17.5,17.3H33 M45.4,29.5h-28 M11.5,2v56H51V14.8L38.4,2H11.5z M38.4,2.2v12.7H51 M45.4,41.7h-28', + title: '数据视图', + lang: ['数据视图', '关闭', '刷新'], + backgroundColor: '#fff', + textColor: '#000', + textareaColor: '#fff', + textareaBorderColor: '#333', + buttonColor: '#c23531', + buttonTextColor: '#fff' + }; + + DataView.prototype.onclick = function (ecModel, api) { + var container = api.getDom(); + var model = this.model; + if (this._dom) { + container.removeChild(this._dom); + } + var root = document.createElement('div'); + root.style.cssText = 'position:absolute;left:5px;top:5px;bottom:5px;right:5px;'; + root.style.backgroundColor = model.get('backgroundColor') || '#fff'; + + // Create elements + var header = document.createElement('h4'); + var lang = model.get('lang') || []; + header.innerHTML = lang[0] || model.get('title'); + header.style.cssText = 'margin: 10px 20px;'; + header.style.color = model.get('textColor'); + + var textarea = document.createElement('textarea'); + // Textarea style + textarea.style.cssText = 'display:block;width:100%;font-size:14px;line-height:1.6rem;font-family:Monaco,Consolas,Courier new,monospace'; + textarea.readOnly = model.get('readOnly'); + textarea.style.color = model.get('textColor'); + textarea.style.borderColor = model.get('textareaBorderColor'); + textarea.style.backgroundColor = model.get('textareaColor'); + + var result = getContentFromModel(ecModel); + textarea.value = result.value; + var blockMetaList = result.meta; + + var buttonContainer = document.createElement('div'); + buttonContainer.style.cssText = 'position:absolute;bottom:0;left:0;right:0;'; + + var buttonStyle = 'float:right;margin-right:20px;border:none;' + + 'cursor:pointer;padding:2px 5px;font-size:12px;border-radius:3px'; + var closeButton = document.createElement('div'); + var refreshButton = document.createElement('div'); + + buttonStyle += ';background-color:' + model.get('buttonColor'); + buttonStyle += ';color:' + model.get('buttonTextColor'); + + var self = this; + + function close() { + container.removeChild(root); + self._dom = null; + } + eventTool.addEventListener(closeButton, 'click', close); + + eventTool.addEventListener(refreshButton, 'click', function () { + var newOption; + try { + newOption = parseContents(textarea.value, blockMetaList); + } + catch (e) { + close(); + throw new Error('Data view format error ' + e); + } + api.dispatchAction({ + type: 'changeDataView', + newOption: newOption + }); + + close(); + }); + + closeButton.innerHTML = lang[1]; + refreshButton.innerHTML = lang[2]; + refreshButton.style.cssText = buttonStyle; + closeButton.style.cssText = buttonStyle; + + buttonContainer.appendChild(refreshButton); + buttonContainer.appendChild(closeButton); + + // http://stackoverflow.com/questions/6637341/use-tab-to-indent-in-textarea + eventTool.addEventListener(textarea, 'keydown', function (e) { + if ((e.keyCode || e.which) === 9) { + // get caret position/selection + var val = this.value; + var start = this.selectionStart; + var end = this.selectionEnd; + + // set textarea value to: text before caret + tab + text after caret + this.value = val.substring(0, start) + ITEM_SPLITER + val.substring(end); + + // put caret at right position again + this.selectionStart = this.selectionEnd = start + 1; + + // prevent the focus lose + eventTool.stop(e); + } + }); + + root.appendChild(header); + root.appendChild(textarea); + root.appendChild(buttonContainer); + + textarea.style.height = (container.clientHeight - 80) + 'px'; + + container.appendChild(root); + this._dom = root; + }; + + DataView.prototype.remove = function (ecModel, api) { + this._dom && api.getDom().removeChild(this._dom); + }; + + DataView.prototype.dispose = function (ecModel, api) { + this.remove(ecModel, api); + }; + + /** + * @inner + */ + function tryMergeDataOption(newData, originalData) { + return zrUtil.map(newData, function (newVal, idx) { + var original = originalData && originalData[idx]; + if (zrUtil.isObject(original) && !zrUtil.isArray(original)) { + if (zrUtil.isObject(newVal) && !zrUtil.isArray(newVal)) { + newVal = newVal.value; + } + // Original data has option + return zrUtil.defaults({ + value: newVal + }, original); + } + else { + return newVal; + } + }); + } + + __webpack_require__(333).register('dataView', DataView); + + __webpack_require__(1).registerAction({ + type: 'changeDataView', + event: 'dataViewChanged', + update: 'prepareAndUpdate' + }, function (payload, ecModel) { + var newSeriesOptList = []; + zrUtil.each(payload.newOption.series, function (seriesOpt) { + var seriesModel = ecModel.getSeriesByName(seriesOpt.name)[0]; + if (!seriesModel) { + // New created series + // Geuss the series type + newSeriesOptList.push(zrUtil.extend({ + // Default is scatter + type: 'scatter' + }, seriesOpt)); + } + else { + var originalData = seriesModel.get('data'); + newSeriesOptList.push({ + name: seriesOpt.name, + data: tryMergeDataOption(seriesOpt.data, originalData) + }); + } + }); + + ecModel.mergeOption(zrUtil.defaults({ + series: newSeriesOptList + }, payload.newOption)); + }); + + module.exports = DataView; + + +/***/ }, +/* 339 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var SelectController = __webpack_require__(225); + var BoundingRect = __webpack_require__(15); + var Group = __webpack_require__(29); + var history = __webpack_require__(340); + var interactionMutex = __webpack_require__(160); + + var each = zrUtil.each; + var asc = numberUtil.asc; + + // Use dataZoomSelect + __webpack_require__(341); + + // Spectial component id start with \0ec\0, see echarts/model/Global.js~hasInnerId + var DATA_ZOOM_ID_BASE = '\0_ec_\0toolbox-dataZoom_'; + + function DataZoom(model) { + this.model = model; + + /** + * @private + * @type {module:zrender/container/Group} + */ + this._controllerGroup; + + /** + * @private + * @type {module:echarts/component/helper/SelectController} + */ + this._controller; + + /** + * Is zoom active. + * @private + * @type {Object} + */ + this._isZoomActive; + } + + DataZoom.defaultOption = { + show: true, + // Icon group + icon: { + zoom: 'M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1', + back: 'M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26' + }, + title: { + zoom: '区域缩放', + back: '区域缩放还原' + } + }; + + var proto = DataZoom.prototype; + + proto.render = function (featureModel, ecModel, api) { + updateBackBtnStatus(featureModel, ecModel); + }; + + proto.onclick = function (ecModel, api, type) { + var controllerGroup = this._controllerGroup; + if (!this._controllerGroup) { + controllerGroup = this._controllerGroup = new Group(); + api.getZr().add(controllerGroup); + } + + handlers[type].call(this, controllerGroup, this.model, ecModel, api); + }; + + proto.remove = function (ecModel, api) { + this._disposeController(); + interactionMutex.release('globalPan', api.getZr()); + }; + + proto.dispose = function (ecModel, api) { + var zr = api.getZr(); + interactionMutex.release('globalPan', zr); + this._disposeController(); + this._controllerGroup && zr.remove(this._controllerGroup); + }; + + /** + * @private + */ + var handlers = { + + zoom: function (controllerGroup, featureModel, ecModel, api) { + var isZoomActive = this._isZoomActive = !this._isZoomActive; + var zr = api.getZr(); + + interactionMutex[isZoomActive ? 'take' : 'release']('globalPan', zr); + + featureModel.setIconStatus('zoom', isZoomActive ? 'emphasis' : 'normal'); + + if (isZoomActive) { + zr.setDefaultCursorStyle('crosshair'); + + this._createController( + controllerGroup, featureModel, ecModel, api + ); + } + else { + zr.setDefaultCursorStyle('default'); + this._disposeController(); + } + }, + + back: function (controllerGroup, featureModel, ecModel, api) { + this._dispatchAction(history.pop(ecModel), api); + } + }; + + /** + * @private + */ + proto._createController = function ( + controllerGroup, featureModel, ecModel, api + ) { + var controller = this._controller = new SelectController( + 'rect', + api.getZr(), + { + // FIXME + lineWidth: 3, + stroke: '#333', + fill: 'rgba(0,0,0,0.2)' + } + ); + controller.on( + 'selectEnd', + zrUtil.bind( + this._onSelected, this, controller, + featureModel, ecModel, api + ) + ); + controller.enable(controllerGroup, false); + }; + + proto._disposeController = function () { + var controller = this._controller; + if (controller) { + controller.off('selected'); + controller.dispose(); + } + }; + + function prepareCoordInfo(grid, ecModel) { + // Default use the first axis. + // FIXME + var coordInfo = [ + {axisModel: grid.getAxis('x').model, axisIndex: 0}, // x + {axisModel: grid.getAxis('y').model, axisIndex: 0} // y + ]; + coordInfo.grid = grid; + + ecModel.eachComponent( + {mainType: 'dataZoom', subType: 'select'}, + function (dzModel, dataZoomIndex) { + if (isTheAxis('xAxis', coordInfo[0].axisModel, dzModel, ecModel)) { + coordInfo[0].dataZoomModel = dzModel; + } + if (isTheAxis('yAxis', coordInfo[1].axisModel, dzModel, ecModel)) { + coordInfo[1].dataZoomModel = dzModel; + } + } + ); + + return coordInfo; + } + + function isTheAxis(axisName, axisModel, dataZoomModel, ecModel) { + var axisIndex = dataZoomModel.get(axisName + 'Index'); + return axisIndex != null + && ecModel.getComponent(axisName, axisIndex) === axisModel; + } + + /** + * @private + */ + proto._onSelected = function (controller, featureModel, ecModel, api, selRanges) { + if (!selRanges.length) { + return; + } + var selRange = selRanges[0]; + + controller.update(); // remove cover + + var snapshot = {}; + + // FIXME + // polar + + ecModel.eachComponent('grid', function (gridModel, gridIndex) { + var grid = gridModel.coordinateSystem; + var coordInfo = prepareCoordInfo(grid, ecModel); + var selDataRange = pointToDataInCartesian(selRange, coordInfo); + + if (selDataRange) { + var xBatchItem = scaleCartesianAxis(selDataRange, coordInfo, 0, 'x'); + var yBatchItem = scaleCartesianAxis(selDataRange, coordInfo, 1, 'y'); + + xBatchItem && (snapshot[xBatchItem.dataZoomId] = xBatchItem); + yBatchItem && (snapshot[yBatchItem.dataZoomId] = yBatchItem); + } + }, this); + + history.push(ecModel, snapshot); + + this._dispatchAction(snapshot, api); + }; + + function pointToDataInCartesian(selRange, coordInfo) { + var grid = coordInfo.grid; + + var selRect = new BoundingRect( + selRange[0][0], + selRange[1][0], + selRange[0][1] - selRange[0][0], + selRange[1][1] - selRange[1][0] + ); + if (!selRect.intersect(grid.getRect())) { + return; + } + var cartesian = grid.getCartesian(coordInfo[0].axisIndex, coordInfo[1].axisIndex); + var dataLeftTop = cartesian.pointToData([selRange[0][0], selRange[1][0]], true); + var dataRightBottom = cartesian.pointToData([selRange[0][1], selRange[1][1]], true); + + return [ + asc([dataLeftTop[0], dataRightBottom[0]]), // x, using asc to handle inverse + asc([dataLeftTop[1], dataRightBottom[1]]) // y, using asc to handle inverse + ]; + } + + function scaleCartesianAxis(selDataRange, coordInfo, dimIdx, dimName) { + var dimCoordInfo = coordInfo[dimIdx]; + var dataZoomModel = dimCoordInfo.dataZoomModel; + + if (dataZoomModel) { + return { + dataZoomId: dataZoomModel.id, + startValue: selDataRange[dimIdx][0], + endValue: selDataRange[dimIdx][1] + }; + } + } + + /** + * @private + */ + proto._dispatchAction = function (snapshot, api) { + var batch = []; + + each(snapshot, function (batchItem) { + batch.push(batchItem); + }); + + batch.length && api.dispatchAction({ + type: 'dataZoom', + from: this.uid, + batch: zrUtil.clone(batch, true) + }); + }; + + function updateBackBtnStatus(featureModel, ecModel) { + featureModel.setIconStatus( + 'back', + history.count(ecModel) > 1 ? 'emphasis' : 'normal' + ); + } + + + __webpack_require__(333).register('dataZoom', DataZoom); + + + // Create special dataZoom option for select + __webpack_require__(1).registerPreprocessor(function (option) { + if (!option) { + return; + } + + var dataZoomOpts = option.dataZoom || (option.dataZoom = []); + if (!zrUtil.isArray(dataZoomOpts)) { + dataZoomOpts = [dataZoomOpts]; + } + + var toolboxOpt = option.toolbox; + if (toolboxOpt) { + // Assume there is only one toolbox + if (zrUtil.isArray(toolboxOpt)) { + toolboxOpt = toolboxOpt[0]; + } + + if (toolboxOpt && toolboxOpt.feature) { + var dataZoomOpt = toolboxOpt.feature.dataZoom; + addForAxis('xAxis', dataZoomOpt); + addForAxis('yAxis', dataZoomOpt); + } + } + + function addForAxis(axisName, dataZoomOpt) { + if (!dataZoomOpt) { + return; + } + + var axisIndicesName = axisName + 'Index'; + var givenAxisIndices = dataZoomOpt[axisIndicesName]; + if (givenAxisIndices != null && !zrUtil.isArray(givenAxisIndices)) { + givenAxisIndices = givenAxisIndices === false ? [] : [givenAxisIndices]; + } + + forEachComponent(axisName, function (axisOpt, axisIndex) { + if (givenAxisIndices != null + && zrUtil.indexOf(givenAxisIndices, axisIndex) === -1 + ) { + return; + } + var newOpt = { + type: 'select', + $fromToolbox: true, + // Id for merge mapping. + id: DATA_ZOOM_ID_BASE + axisName + axisIndex + }; + // FIXME + // Only support one axis now. + newOpt[axisIndicesName] = axisIndex; + dataZoomOpts.push(newOpt); + }); + } + + function forEachComponent(mainType, cb) { + var opts = option[mainType]; + if (!zrUtil.isArray(opts)) { + opts = opts ? [opts] : []; + } + each(opts, cb); + } + }); + + module.exports = DataZoom; + + +/***/ }, +/* 340 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @file History manager. + */ + + + var zrUtil = __webpack_require__(3); + var each = zrUtil.each; + + var ATTR = '\0_ec_hist_store'; + + var history = { + + /** + * @public + * @param {module:echarts/model/Global} ecModel + * @param {Object} newSnapshot {dataZoomId, batch: [payloadInfo, ...]} + */ + push: function (ecModel, newSnapshot) { + var store = giveStore(ecModel); + + // If previous dataZoom can not be found, + // complete an range with current range. + each(newSnapshot, function (batchItem, dataZoomId) { + var i = store.length - 1; + for (; i >= 0; i--) { + var snapshot = store[i]; + if (snapshot[dataZoomId]) { + break; + } + } + if (i < 0) { + // No origin range set, create one by current range. + var dataZoomModel = ecModel.queryComponents( + {mainType: 'dataZoom', subType: 'select', id: dataZoomId} + )[0]; + if (dataZoomModel) { + var percentRange = dataZoomModel.getPercentRange(); + store[0][dataZoomId] = { + dataZoomId: dataZoomId, + start: percentRange[0], + end: percentRange[1] + }; + } + } + }); + + store.push(newSnapshot); + }, + + /** + * @public + * @param {module:echarts/model/Global} ecModel + * @return {Object} snapshot + */ + pop: function (ecModel) { + var store = giveStore(ecModel); + var head = store[store.length - 1]; + store.length > 1 && store.pop(); + + // Find top for all dataZoom. + var snapshot = {}; + each(head, function (batchItem, dataZoomId) { + for (var i = store.length - 1; i >= 0; i--) { + var batchItem = store[i][dataZoomId]; + if (batchItem) { + snapshot[dataZoomId] = batchItem; + break; + } + } + }); - require('./marker/MarkPointModel'); - require('./marker/MarkPointView'); + return snapshot; + }, - require('../echarts').registerPreprocessor(function (opt) { - // Make sure markPoint component is enabled - opt.markPoint = opt.markPoint || {}; - }); -}); -define('echarts/component/marker/MarkLineModel',['require','../../util/model','../../echarts'],function (require) { - - // Default enable markLine - // var globalDefault = require('../../model/globalDefault'); - var modelUtil = require('../../util/model'); - - // // Force to load markLine component - // globalDefault.markLine = {}; - - var MarkLineModel = require('../../echarts').extendComponentModel({ - - type: 'markLine', - - dependencies: ['series', 'grid', 'polar'], - /** - * @overrite - */ - init: function (option, parentModel, ecModel, extraOpt) { - this.mergeDefaultAndTheme(option, ecModel); - this.mergeOption(option, ecModel, extraOpt.createdBySelf, true); - }, - - mergeOption: function (newOpt, ecModel, createdBySelf, isInit) { - if (!createdBySelf) { - ecModel.eachSeries(function (seriesModel) { - var markLineOpt = seriesModel.get('markLine'); - var mlModel = seriesModel.markLineModel; - if (!markLineOpt || !markLineOpt.data) { - seriesModel.markLineModel = null; - return; - } - if (!mlModel) { - if (isInit) { - // Default label emphasis `position` and `show` - modelUtil.defaultEmphasis( - markLineOpt.label, - ['position', 'show', 'textStyle', 'distance', 'formatter'] - ); - } - var opt = { - // Use the same series index and name - seriesIndex: seriesModel.seriesIndex, - name: seriesModel.name, - createdBySelf: true - }; - mlModel = new MarkLineModel( - markLineOpt, this, ecModel, opt - ); - } - else { - mlModel.mergeOption(markLineOpt, ecModel, true); - } - seriesModel.markLineModel = mlModel; - }, this); - } - }, - - defaultOption: { - zlevel: 0, - z: 5, - // 标线起始和结束的symbol介绍类型,如果都一样,可以直接传string - symbol: ['circle', 'arrow'], - // 标线起始和结束的symbol大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2 - symbolSize: [8, 16], - // 标线起始和结束的symbol旋转控制 - //symbolRotate: null, - //smooth: false, - precision: 2, - tooltip: { - trigger: 'item' - }, - label: { - normal: { - show: true, - // 标签文本格式器,同Tooltip.formatter,不支持回调 - // formatter: null, - // 可选为 'start'|'end'|'left'|'right'|'top'|'bottom' - position: 'end' - // 默认使用全局文本样式,详见TEXTSTYLE - // textStyle: null - }, - emphasis: { - show: true - } - }, - lineStyle: { - normal: { - // color - // width - type: 'dashed' - // shadowColor: 'rgba(0,0,0,0)', - // shadowBlur: 0, - // shadowOffsetX: 0, - // shadowOffsetY: 0 - }, - emphasis: { - width: 3 - } - }, - animationEasing: 'linear' - } - }); - - return MarkLineModel; -}); -define('echarts/component/marker/MarkLineView',['require','zrender/core/util','../../data/List','../../util/format','../../util/model','../../util/number','./markerHelper','../../chart/helper/LineDraw','../../echarts'],function (require) { + /** + * @public + */ + clear: function (ecModel) { + ecModel[ATTR] = null; + }, - var zrUtil = require('zrender/core/util'); - var List = require('../../data/List'); - var formatUtil = require('../../util/format'); - var modelUtil = require('../../util/model'); - var numberUtil = require('../../util/number'); + /** + * @public + * @param {module:echarts/model/Global} ecModel + * @return {number} records. always >= 1. + */ + count: function (ecModel) { + return giveStore(ecModel).length; + } - var addCommas = formatUtil.addCommas; - var encodeHTML = formatUtil.encodeHTML; + }; - var markerHelper = require('./markerHelper'); - - var LineDraw = require('../../chart/helper/LineDraw'); + /** + * [{key: dataZoomId, value: {dataZoomId, range}}, ...] + * History length of each dataZoom may be different. + * this._history[0] is used to store origin range. + * @type {Array.} + */ + function giveStore(ecModel) { + var store = ecModel[ATTR]; + if (!store) { + store = ecModel[ATTR] = [{}]; + } + return store; + } - var markLineTransform = function (seriesModel, coordSys, mlModel, item) { - var data = seriesModel.getData(); - // Special type markLine like 'min', 'max', 'average' - var mlType = item.type; - - if (!zrUtil.isArray(item) - && (mlType === 'min' || mlType === 'max' || mlType === 'average') - ) { - var axisInfo = markerHelper.getAxisInfo(item, data, coordSys, seriesModel); - - var baseAxisKey = axisInfo.baseAxis.dim + 'Axis'; - var valueAxisKey = axisInfo.valueAxis.dim + 'Axis'; - var baseScaleExtent = axisInfo.baseAxis.scale.getExtent(); - - var mlFrom = zrUtil.clone(item); - var mlTo = {}; - - mlFrom.type = null; - - // FIXME Polar should use circle - mlFrom[baseAxisKey] = baseScaleExtent[0]; - mlTo[baseAxisKey] = baseScaleExtent[1]; - - var value = markerHelper.numCalculate(data, axisInfo.valueDataDim, mlType); - - // Round if axis is cateogry - value = axisInfo.valueAxis.coordToData(axisInfo.valueAxis.dataToCoord(value)); - - var precision = mlModel.get('precision'); - if (precision >= 0) { - value = +value.toFixed(precision); - } - - mlFrom[valueAxisKey] = mlTo[valueAxisKey] = value; - - item = [mlFrom, mlTo, { // Extra option for tooltip and label - type: mlType, - // Force to use the value of calculated value. - value: value - }]; - } - - item = [ - markerHelper.dataTransform(seriesModel, item[0]), - markerHelper.dataTransform(seriesModel, item[1]), - zrUtil.extend({}, item[2]) - ]; - - // Merge from option and to option into line option - zrUtil.merge(item[2], item[0]); - zrUtil.merge(item[2], item[1]); - - return item; - }; - - function markLineFilter(coordSys, item) { - return markerHelper.dataFilter(coordSys, item[0]) - && markerHelper.dataFilter(coordSys, item[1]); - } - - var markLineFormatMixin = { - formatTooltip: function (dataIndex) { - var data = this._data; - var value = this.getRawValue(dataIndex); - var formattedValue = zrUtil.isArray(value) - ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); - var name = data.getName(dataIndex); - return this.name + '
' - + ((name ? encodeHTML(name) + ' : ' : '') + formattedValue); - }, - - getRawDataArray: function () { - return this.option.data; - }, - - getData: function () { - return this._data; - }, - - setData: function (data) { - this._data = data; - } - }; - - zrUtil.defaults(markLineFormatMixin, modelUtil.dataFormatMixin); - - require('../../echarts').extendComponentView({ - - type: 'markLine', - - init: function () { - /** - * Markline grouped by series - * @private - * @type {Object} - */ - this._markLineMap = {}; - }, - - render: function (markLineModel, ecModel, api) { - var lineDrawMap = this._markLineMap; - for (var name in lineDrawMap) { - lineDrawMap[name].__keep = false; - } - - ecModel.eachSeries(function (seriesModel) { - var mlModel = seriesModel.markLineModel; - mlModel && this._renderSeriesML(seriesModel, mlModel, ecModel, api); - }, this); - - for (var name in lineDrawMap) { - if (!lineDrawMap[name].__keep) { - this.group.remove(lineDrawMap[name].group); - } - } - }, - - _renderSeriesML: function (seriesModel, mlModel, ecModel, api) { - var coordSys = seriesModel.coordinateSystem; - var seriesName = seriesModel.name; - var seriesData = seriesModel.getData(); - - var lineDrawMap = this._markLineMap; - var lineDraw = lineDrawMap[seriesName]; - if (!lineDraw) { - lineDraw = lineDrawMap[seriesName] = new LineDraw(); - } - this.group.add(lineDraw.group); - - var mlData = createList(coordSys, seriesModel, mlModel); - var dims = coordSys.dimensions; - - var fromData = mlData.from; - var toData = mlData.to; - var lineData = mlData.line; - - // Line data for tooltip and formatter - zrUtil.extend(mlModel, markLineFormatMixin); - mlModel.setData(lineData); - - var symbolType = mlModel.get('symbol'); - var symbolSize = mlModel.get('symbolSize'); - if (!zrUtil.isArray(symbolType)) { - symbolType = [symbolType, symbolType]; - } - if (typeof symbolSize === 'number') { - symbolSize = [symbolSize, symbolSize]; - } - - // Update visual and layout of from symbol and to symbol - mlData.from.each(function (idx) { - updateDataVisualAndLayout(fromData, idx, true); - updateDataVisualAndLayout(toData, idx); - }); - - // Update visual and layout of line - lineData.each(function (idx) { - var lineColor = lineData.getItemModel(idx).get('lineStyle.normal.color'); - lineData.setItemVisual(idx, { - color: lineColor || fromData.getItemVisual(idx, 'color') - }); - lineData.setItemLayout(idx, [ - fromData.getItemLayout(idx), - toData.getItemLayout(idx) - ]); - }); - - lineDraw.updateData(lineData, fromData, toData); - - // Set host model for tooltip - // FIXME - mlData.line.eachItemGraphicEl(function (el, idx) { - el.traverse(function (child) { - child.hostModel = mlModel; - }); - }); - - function updateDataVisualAndLayout(data, idx, isFrom) { - var itemModel = data.getItemModel(idx); - - var point; - var xPx = itemModel.get('x'); - var yPx = itemModel.get('y'); - if (xPx != null && yPx != null) { - point = [ - numberUtil.parsePercent(xPx, api.getWidth()), - numberUtil.parsePercent(yPx, api.getHeight()) - ]; - } - // Chart like bar may have there own marker positioning logic - else if (seriesModel.getMarkerPosition) { - // Use the getMarkerPoisition - point = seriesModel.getMarkerPosition( - data.getValues(data.dimensions, idx) - ); - } - else { - var x = data.get(dims[0], idx); - var y = data.get(dims[1], idx); - point = coordSys.dataToPoint([x, y]); - } - - data.setItemLayout(idx, point); - - data.setItemVisual(idx, { - symbolSize: itemModel.get('symbolSize') - || symbolSize[isFrom ? 0 : 1], - symbol: itemModel.get('symbol', true) - || symbolType[isFrom ? 0 : 1], - color: itemModel.get('itemStyle.normal.color') - || seriesData.getVisual('color') - }); - } - - lineDraw.__keep = true; - } - }); - - /** - * @inner - * @param {module:echarts/coord/*} coordSys - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/model/Model} mpModel - */ - function createList(coordSys, seriesModel, mlModel) { - - var coordDimsInfos = zrUtil.map(coordSys.dimensions, function (coordDim) { - var info = seriesModel.getData().getDimensionInfo( - seriesModel.coordDimToDataDim(coordDim)[0] - ); - info.name = coordDim; - return info; - }); - var fromData = new List(coordDimsInfos, mlModel); - var toData = new List(coordDimsInfos, mlModel); - // No dimensions - var lineData = new List([], mlModel); - - if (coordSys) { - var optData = zrUtil.filter( - zrUtil.map(mlModel.get('data'), zrUtil.curry( - markLineTransform, seriesModel, coordSys, mlModel - )), - zrUtil.curry(markLineFilter, coordSys) - ); - fromData.initData( - zrUtil.map(optData, function (item) { return item[0]; }), - null, - markerHelper.dimValueGetter - ); - toData.initData( - zrUtil.map(optData, function (item) { return item[1]; }), - null, - markerHelper.dimValueGetter - ); - lineData.initData( - zrUtil.map(optData, function (item) { return item[2]; }) - ); - - } - return { - from: fromData, - to: toData, - line: lineData - }; - } -}); -define('echarts/component/markLine',['require','./marker/MarkLineModel','./marker/MarkLineView','../echarts'],function (require) { + module.exports = history; - require('./marker/MarkLineModel'); - require('./marker/MarkLineView'); - require('../echarts').registerPreprocessor(function (opt) { - // Make sure markLine component is enabled - opt.markLine = opt.markLine || {}; - }); -}); -/** - * @file Timeline preprocessor - */ -define('echarts/component/timeline/preprocessor',['require','zrender/core/util'],function(require) { - - var zrUtil = require('zrender/core/util'); - - return function (option) { - var timelineOpt = option && option.timeline; - - if (!zrUtil.isArray(timelineOpt)) { - timelineOpt = timelineOpt ? [timelineOpt] : []; - } - - zrUtil.each(timelineOpt, function (opt) { - if (!opt) { - return; - } - - compatibleEC2(opt); - }); - }; - - function compatibleEC2(opt) { - var type = opt.type; - - var ec2Types = {'number': 'value', 'time': 'time'}; - - // Compatible with ec2 - if (ec2Types[type]) { - opt.axisType = ec2Types[type]; - delete opt.type; - } - - transferItem(opt); - - if (has(opt, 'controlPosition')) { - var controlStyle = opt.controlStyle || (opt.controlStyle = {}); - if (!has(controlStyle, 'position')) { - controlStyle.position = opt.controlPosition; - } - if (controlStyle.position === 'none' && !has(controlStyle, 'show')) { - controlStyle.show = false; - delete controlStyle.position; - } - delete opt.controlPosition; - } - - zrUtil.each(opt.data || [], function (dataItem) { - if (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem)) { - if (!has(dataItem, 'value') && has(dataItem, 'name')) { - // In ec2, using name as value. - dataItem.value = dataItem.name; - } - transferItem(dataItem); - } - }); - } - - function transferItem(opt) { - var itemStyle = opt.itemStyle || (opt.itemStyle = {}); - - var itemStyleEmphasis = itemStyle.emphasis || (itemStyle.emphasis = {}); - - // Transfer label out - var label = opt.label || (opt.label || {}); - var labelNormal = label.normal || (label.normal = {}); - var excludeLabelAttr = {normal: 1, emphasis: 1}; - - zrUtil.each(label, function (value, name) { - if (!excludeLabelAttr[name] && !has(labelNormal, name)) { - labelNormal[name] = value; - } - }); - - if (itemStyleEmphasis.label && !has(label, 'emphasis')) { - label.emphasis = itemStyleEmphasis.label; - delete itemStyleEmphasis.label; - } - } - - function has(obj, attr) { - return obj.hasOwnProperty(attr); - } -}); -define('echarts/component/timeline/typeDefaulter',['require','../../model/Component'],function (require) { +/***/ }, +/* 341 */ +/***/ function(module, exports, __webpack_require__) { - require('../../model/Component').registerSubTypeDefaulter('timeline', function () { - // Only slider now. - return 'slider'; - }); + /** + * DataZoom component entry + */ -}); -/** - * @file Timeilne action - */ -define('echarts/component/timeline/timelineAction',['require','../../echarts'],function(require) { - var echarts = require('../../echarts'); + __webpack_require__(287); - echarts.registerAction( + __webpack_require__(288); + __webpack_require__(290); - {type: 'timelineChange', event: 'timelineChanged', update: 'prepareAndUpdate'}, + __webpack_require__(342); + __webpack_require__(343); - function (payload, ecModel) { + __webpack_require__(298); + __webpack_require__(299); - var timelineModel = ecModel.getComponent('timeline'); - if (timelineModel && payload.currentIndex != null) { - timelineModel.setCurrentIndex(payload.currentIndex); - if (!timelineModel.get('loop', true) && timelineModel.isIndexMax()) { - timelineModel.setPlayState(false); - } - } - ecModel.resetOption('timeline'); - } - ); +/***/ }, +/* 342 */ +/***/ function(module, exports, __webpack_require__) { - echarts.registerAction( + /** + * @file Data zoom model + */ - {type: 'timelinePlayChange', event: 'timelinePlayChanged', update: 'update'}, - function (payload, ecModel) { - var timelineModel = ecModel.getComponent('timeline'); - if (timelineModel && payload.playState != null) { - timelineModel.setPlayState(payload.playState); - } - } - ); + var DataZoomModel = __webpack_require__(288); -}); -/** - * @file Timeline model - */ -define('echarts/component/timeline/TimelineModel',['require','../../model/Component','../../data/List','zrender/core/util','../../util/model'],function(require) { - - var ComponentModel = require('../../model/Component'); - var List = require('../../data/List'); - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../../util/model'); - - var TimelineModel = ComponentModel.extend({ - - type: 'timeline', - - layoutMode: 'box', - - /** - * @protected - */ - defaultOption: { - - zlevel: 0, // 一级层叠 - z: 4, // 二级层叠 - show: true, - - axisType: 'time', // 模式是时间类型,支持 value, category - - realtime: true, - - left: '20%', - top: null, - right: '20%', - bottom: 0, - width: null, - height: 40, - padding: 5, - - controlPosition: 'left', // 'left' 'right' 'top' 'bottom' 'none' - autoPlay: false, - rewind: false, // 反向播放 - loop: true, - playInterval: 2000, // 播放时间间隔,单位ms - - currentIndex: 0, - - itemStyle: { - normal: {}, - emphasis: {} - }, - label: { - normal: { - textStyle: { - color: '#000' - } - }, - emphasis: {} - }, - - data: [] - }, - - /** - * @override - */ - init: function (option, parentModel, ecModel) { - - /** - * @private - * @type {module:echarts/data/List} - */ - this._data; - - /** - * @private - * @type {Array.} - */ - this._names; - - this.mergeDefaultAndTheme(option, ecModel); - this._initData(); - }, - - /** - * @override - */ - mergeOption: function (option) { - TimelineModel.superApply(this, 'mergeOption', arguments); - this._initData(); - }, - - /** - * @param {number} [currentIndex] - */ - setCurrentIndex: function (currentIndex) { - if (currentIndex == null) { - currentIndex = this.option.currentIndex; - } - var count = this._data.count(); - - if (this.option.loop) { - currentIndex = (currentIndex % count + count) % count; - } - else { - currentIndex >= count && (currentIndex = count - 1); - currentIndex < 0 && (currentIndex = 0); - } - - this.option.currentIndex = currentIndex; - }, - - /** - * @return {number} currentIndex - */ - getCurrentIndex: function () { - return this.option.currentIndex; - }, - - /** - * @return {boolean} - */ - isIndexMax: function () { - return this.getCurrentIndex() >= this._data.count() - 1; - }, - - /** - * @param {boolean} state true: play, false: stop - */ - setPlayState: function (state) { - this.option.autoPlay = !!state; - }, - - /** - * @return {boolean} true: play, false: stop - */ - getPlayState: function () { - return !!this.option.autoPlay; - }, - - /** - * @private - */ - _initData: function () { - var thisOption = this.option; - var dataArr = thisOption.data || []; - var axisType = thisOption.axisType; - var names = this._names = []; - - if (axisType === 'category') { - var idxArr = []; - zrUtil.each(dataArr, function (item, index) { - var value = modelUtil.getDataItemValue(item); - var newItem; - - if (zrUtil.isObject(item)) { - newItem = zrUtil.clone(item); - newItem.value = index; - } - else { - newItem = index; - } - - idxArr.push(newItem); - - if (!zrUtil.isString(value) && (value == null || isNaN(value))) { - value = ''; - } - - names.push(value + ''); - }); - dataArr = idxArr; - } - - var dimType = ({category: 'ordinal', time: 'time'})[axisType] || 'number'; - - var data = this._data = new List([{name: 'value', type: dimType}], this); - - data.initData(dataArr, names); - }, - - getData: function () { - return this._data; - }, - - /** - * @public - * @return {Array.} categoreis - */ - getCategories: function () { - if (this.get('axisType') === 'category') { - return this._names.slice(); - } - } - - }); - - return TimelineModel; -}); -/** - * @file Silder timeline model - */ -define('echarts/component/timeline/SliderTimelineModel',['require','./TimelineModel'],function(require) { - - var TimelineModel = require('./TimelineModel'); - - return TimelineModel.extend({ - - type: 'timeline.slider', - - /** - * @protected - */ - defaultOption: { - - backgroundColor: 'rgba(0,0,0,0)', // 时间轴背景颜色 - borderColor: '#ccc', // 时间轴边框颜色 - borderWidth: 0, // 时间轴边框线宽,单位px,默认为0(无边框) - - orient: 'horizontal', // 'vertical' - inverse: false, - - tooltip: { // boolean or Object - trigger: 'item' // data item may also have tootip attr. - }, - - symbol: 'emptyCircle', - symbolSize: 10, - - lineStyle: { - show: true, - width: 2, - color: '#304654' - }, - label: { // 文本标签 - position: 'auto', // auto left right top bottom - // When using number, label position is not - // restricted by viewRect. - // positive: right/bottom, negative: left/top - normal: { - show: true, - interval: 'auto', - rotate: 0, - // formatter: null, - textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE - color: '#304654' - } - }, - emphasis: { - show: true, - textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE - color: '#c23531' - } - } - }, - itemStyle: { - normal: { - color: '#304654', - borderWidth: 1 - }, - emphasis: { - color: '#c23531' - } - }, - - checkpointStyle: { - symbol: 'circle', - symbolSize: 13, - color: '#c23531', - borderWidth: 5, - borderColor: 'rgba(194,53,49, 0.5)', - animation: true, - animationDuration: 300, - animationEasing: 'quinticInOut' - }, - - controlStyle: { - show: true, - showPlayBtn: true, - showPrevBtn: true, - showNextBtn: true, - itemSize: 22, - itemGap: 12, - position: 'left', // 'left' 'right' 'top' 'bottom' - playIcon: 'path://M31.6,53C17.5,53,6,41.5,6,27.4S17.5,1.8,31.6,1.8C45.7,1.8,57.2,13.3,57.2,27.4S45.7,53,31.6,53z M31.6,3.3 C18.4,3.3,7.5,14.1,7.5,27.4c0,13.3,10.8,24.1,24.1,24.1C44.9,51.5,55.7,40.7,55.7,27.4C55.7,14.1,44.9,3.3,31.6,3.3z M24.9,21.3 c0-2.2,1.6-3.1,3.5-2l10.5,6.1c1.899,1.1,1.899,2.9,0,4l-10.5,6.1c-1.9,1.1-3.5,0.2-3.5-2V21.3z', // jshint ignore:line - stopIcon: 'path://M30.9,53.2C16.8,53.2,5.3,41.7,5.3,27.6S16.8,2,30.9,2C45,2,56.4,13.5,56.4,27.6S45,53.2,30.9,53.2z M30.9,3.5C17.6,3.5,6.8,14.4,6.8,27.6c0,13.3,10.8,24.1,24.101,24.1C44.2,51.7,55,40.9,55,27.6C54.9,14.4,44.1,3.5,30.9,3.5z M36.9,35.8c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H36c0.5,0,0.9,0.4,0.9,1V35.8z M27.8,35.8 c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H27c0.5,0,0.9,0.4,0.9,1L27.8,35.8L27.8,35.8z', // jshint ignore:line - nextIcon: 'path://M18.6,50.8l22.5-22.5c0.2-0.2,0.3-0.4,0.3-0.7c0-0.3-0.1-0.5-0.3-0.7L18.7,4.4c-0.1-0.1-0.2-0.3-0.2-0.5 c0-0.4,0.3-0.8,0.8-0.8c0.2,0,0.5,0.1,0.6,0.3l23.5,23.5l0,0c0.2,0.2,0.3,0.4,0.3,0.7c0,0.3-0.1,0.5-0.3,0.7l-0.1,0.1L19.7,52 c-0.1,0.1-0.3,0.2-0.5,0.2c-0.4,0-0.8-0.3-0.8-0.8C18.4,51.2,18.5,51,18.6,50.8z', // jshint ignore:line - prevIcon: 'path://M43,52.8L20.4,30.3c-0.2-0.2-0.3-0.4-0.3-0.7c0-0.3,0.1-0.5,0.3-0.7L42.9,6.4c0.1-0.1,0.2-0.3,0.2-0.5 c0-0.4-0.3-0.8-0.8-0.8c-0.2,0-0.5,0.1-0.6,0.3L18.3,28.8l0,0c-0.2,0.2-0.3,0.4-0.3,0.7c0,0.3,0.1,0.5,0.3,0.7l0.1,0.1L41.9,54 c0.1,0.1,0.3,0.2,0.5,0.2c0.4,0,0.8-0.3,0.8-0.8C43.2,53.2,43.1,53,43,52.8z', // jshint ignore:line - normal: { - color: '#304654', - borderColor: '#304654', - borderWidth: 1 - }, - emphasis: { - color: '#c23531', - borderColor: '#c23531', - borderWidth: 2 - } - }, - data: [] - } - - }); + module.exports = DataZoomModel.extend({ -}); -/** - * @file Timeline view - */ -define('echarts/component/timeline/TimelineView',['require','../../view/Component'],function (require) { + type: 'dataZoom.select' - // var zrUtil = require('zrender/core/util'); - // var graphic = require('../../util/graphic'); - var ComponentView = require('../../view/Component'); + }); - return ComponentView.extend({ - type: 'timeline' - }); -}); -define('echarts/component/timeline/TimelineAxis',['require','zrender/core/util','../../coord/Axis','../../coord/axisHelper'],function (require) { - - var zrUtil = require('zrender/core/util'); - var Axis = require('../../coord/Axis'); - var axisHelper = require('../../coord/axisHelper'); - - /** - * Extend axis 2d - * @constructor module:echarts/coord/cartesian/Axis2D - * @extends {module:echarts/coord/cartesian/Axis} - * @param {string} dim - * @param {*} scale - * @param {Array.} coordExtent - * @param {string} axisType - * @param {string} position - */ - var TimelineAxis = function (dim, scale, coordExtent, axisType) { - - Axis.call(this, dim, scale, coordExtent); - - /** - * Axis type - * - 'category' - * - 'value' - * - 'time' - * - 'log' - * @type {string} - */ - this.type = axisType || 'value'; - - /** - * @private - * @type {number} - */ - this._autoLabelInterval; - - /** - * Axis model - * @param {module:echarts/component/TimelineModel} - */ - this.model = null; - }; - - TimelineAxis.prototype = { - - constructor: TimelineAxis, - - /** - * @public - * @return {number} - */ - getLabelInterval: function () { - var timelineModel = this.model; - var labelModel = timelineModel.getModel('label.normal'); - var labelInterval = labelModel.get('interval'); - - if (labelInterval != null && labelInterval != 'auto') { - return labelInterval; - } - - var labelInterval = this._autoLabelInterval; - - if (!labelInterval) { - labelInterval = this._autoLabelInterval = axisHelper.getAxisLabelInterval( - zrUtil.map(this.scale.getTicks(), this.dataToCoord, this), - axisHelper.getFormattedLabels(this, labelModel.get('formatter')), - labelModel.getModel('textStyle').getFont(), - timelineModel.get('orient') === 'horizontal' - ); - } - - return labelInterval; - }, - - /** - * If label is ignored. - * Automatically used when axis is category and label can not be all shown - * @public - * @param {number} idx - * @return {boolean} - */ - isLabelIgnored: function (idx) { - if (this.type === 'category') { - var labelInterval = this.getLabelInterval(); - return ((typeof labelInterval === 'function') - && !labelInterval(idx, this.scale.getLabel(idx))) - || idx % (labelInterval + 1); - } - } - - }; - - zrUtil.inherits(TimelineAxis, Axis); - - return TimelineAxis; -}); -/** - * @file Silder timeline view - */ -define('echarts/component/timeline/SliderTimelineView',['require','zrender/core/util','../../util/graphic','../../util/layout','./TimelineView','./TimelineAxis','../../util/symbol','../../coord/axisHelper','zrender/core/BoundingRect','zrender/core/matrix','../../util/number','../../util/model','../../util/format'],function (require) { - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var layout = require('../../util/layout'); - var TimelineView = require('./TimelineView'); - var TimelineAxis = require('./TimelineAxis'); - var symbolUtil = require('../../util/symbol'); - var axisHelper = require('../../coord/axisHelper'); - var BoundingRect = require('zrender/core/BoundingRect'); - var matrix = require('zrender/core/matrix'); - var numberUtil = require('../../util/number'); - var modelUtil = require('../../util/model'); - var formatUtil = require('../../util/format'); - var encodeHTML = formatUtil.encodeHTML; - - var bind = zrUtil.bind; - var each = zrUtil.each; - - var PI = Math.PI; - - return TimelineView.extend({ - - type: 'timeline.slider', - - init: function (ecModel, api) { - - this.api = api; - - /** - * @private - * @type {module:echarts/component/timeline/TimelineAxis} - */ - this._axis; - - /** - * @private - * @type {module:zrender/core/BoundingRect} - */ - this._viewRect; - - /** - * @type {number} - */ - this._timer; - - /** - * @type {module:zrende/Element} - */ - this._currentPointer; - - /** - * @type {module:zrender/container/Group} - */ - this._mainGroup; - - /** - * @type {module:zrender/container/Group} - */ - this._labelGroup; - }, - - /** - * @override - */ - render: function (timelineModel, ecModel, api, payload) { - this.model = timelineModel; - this.api = api; - this.ecModel = ecModel; - - this.group.removeAll(); - - if (timelineModel.get('show', true)) { - - var layoutInfo = this._layout(timelineModel, api); - var mainGroup = this._createGroup('mainGroup'); - var labelGroup = this._createGroup('labelGroup'); - - /** - * @private - * @type {module:echarts/component/timeline/TimelineAxis} - */ - var axis = this._axis = this._createAxis(layoutInfo, timelineModel); - - each( - ['AxisLine', 'AxisTick', 'Control', 'CurrentPointer'], - function (name) { - this['_render' + name](layoutInfo, mainGroup, axis, timelineModel); - }, - this - ); - - this._renderAxisLabel(layoutInfo, labelGroup, axis, timelineModel); - - this._position(layoutInfo, timelineModel); - } - - this._doPlayStop(); - }, - - /** - * @override - */ - remove: function () { - this._clearTimer(); - this.group.removeAll(); - }, - - /** - * @override - */ - dispose: function () { - this._clearTimer(); - }, - - _layout: function (timelineModel, api) { - var labelPosOpt = timelineModel.get('label.normal.position'); - var orient = timelineModel.get('orient'); - var viewRect = getViewRect(timelineModel, api); - // Auto label offset. - if (labelPosOpt == null || labelPosOpt === 'auto') { - labelPosOpt = orient === 'horizontal' - ? ((viewRect.y + viewRect.height / 2) < api.getHeight() / 2 ? '-' : '+') - : ((viewRect.x + viewRect.width / 2) < api.getWidth() / 2 ? '+' : '-'); - } - else if (isNaN(labelPosOpt)) { - labelPosOpt = ({ - horizontal: {top: '-', bottom: '+'}, - vertical: {left: '-', right: '+'} - })[orient][labelPosOpt]; - } - - // FIXME - // 暂没有实现用户传入 - // var labelAlign = timelineModel.get('label.normal.textStyle.align'); - // var labelBaseline = timelineModel.get('label.normal.textStyle.baseline'); - var labelAlignMap = { - horizontal: 'center', - vertical: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'left' : 'right' - }; - - var labelBaselineMap = { - horizontal: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'top' : 'bottom', - vertical: 'middle' - }; - var rotationMap = { - horizontal: 0, - vertical: PI / 2 - }; - - // Position - var mainLength = orient === 'vertical' ? viewRect.height : viewRect.width; - - var controlModel = timelineModel.getModel('controlStyle'); - var showControl = controlModel.get('show'); - var controlSize = showControl ? controlModel.get('itemSize') : 0; - var controlGap = showControl ? controlModel.get('itemGap') : 0; - var sizePlusGap = controlSize + controlGap; - - // Special label rotate. - var labelRotation = timelineModel.get('label.normal.rotate') || 0; - labelRotation = labelRotation * PI / 180; // To radian. - - var playPosition; - var prevBtnPosition; - var nextBtnPosition; - var axisExtent; - var controlPosition = controlModel.get('position', true); - var showControl = controlModel.get('show', true); - var showPlayBtn = showControl && controlModel.get('showPlayBtn', true); - var showPrevBtn = showControl && controlModel.get('showPrevBtn', true); - var showNextBtn = showControl && controlModel.get('showNextBtn', true); - var xLeft = 0; - var xRight = mainLength; - - // position[0] means left, position[1] means middle. - if (controlPosition === 'left' || controlPosition === 'bottom') { - showPlayBtn && (playPosition = [0, 0], xLeft += sizePlusGap); - showPrevBtn && (prevBtnPosition = [xLeft, 0], xLeft += sizePlusGap); - showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap); - } - else { // 'top' 'right' - showPlayBtn && (playPosition = [xRight - controlSize, 0], xRight -= sizePlusGap); - showPrevBtn && (prevBtnPosition = [0, 0], xLeft += sizePlusGap); - showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap); - } - axisExtent = [xLeft, xRight]; - - if (timelineModel.get('inverse')) { - axisExtent.reverse(); - } - - return { - viewRect: viewRect, - mainLength: mainLength, - orient: orient, - - rotation: rotationMap[orient], - labelRotation: labelRotation, - labelPosOpt: labelPosOpt, - labelAlign: labelAlignMap[orient], - labelBaseline: labelBaselineMap[orient], - - // Based on mainGroup. - playPosition: playPosition, - prevBtnPosition: prevBtnPosition, - nextBtnPosition: nextBtnPosition, - axisExtent: axisExtent, - - controlSize: controlSize, - controlGap: controlGap - }; - }, - - _position: function (layoutInfo, timelineModel) { - // Position is be called finally, because bounding rect is needed for - // adapt content to fill viewRect (auto adapt offset). - - // Timeline may be not all in the viewRect when 'offset' is specified - // as a number, because it is more appropriate that label aligns at - // 'offset' but not the other edge defined by viewRect. - - var mainGroup = this._mainGroup; - var labelGroup = this._labelGroup; - - var viewRect = layoutInfo.viewRect; - if (layoutInfo.orient === 'vertical') { - // transfrom to horizontal, inverse rotate by left-top point. - var m = matrix.create(); - var rotateOriginX = viewRect.x; - var rotateOriginY = viewRect.y + viewRect.height; - matrix.translate(m, m, [-rotateOriginX, -rotateOriginY]); - matrix.rotate(m, m, -PI / 2); - matrix.translate(m, m, [rotateOriginX, rotateOriginY]); - viewRect = viewRect.clone(); - viewRect.applyTransform(m); - } - - var viewBound = getBound(viewRect); - var mainBound = getBound(mainGroup.getBoundingRect()); - var labelBound = getBound(labelGroup.getBoundingRect()); - - var mainPosition = mainGroup.position; - var labelsPosition = labelGroup.position; - - labelsPosition[0] = mainPosition[0] = viewBound[0][0]; - - var labelPosOpt = layoutInfo.labelPosOpt; - - if (isNaN(labelPosOpt)) { // '+' or '-' - var mainBoundIdx = labelPosOpt === '+' ? 0 : 1; - toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx); - toBound(labelsPosition, labelBound, viewBound, 1, 1 - mainBoundIdx); - } - else { - var mainBoundIdx = labelPosOpt >= 0 ? 0 : 1; - toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx); - labelsPosition[1] = mainPosition[1] + labelPosOpt; - } - - mainGroup.position = mainPosition; - labelGroup.position = labelsPosition; - mainGroup.rotation = labelGroup.rotation = layoutInfo.rotation; - - setOrigin(mainGroup); - setOrigin(labelGroup); - - function setOrigin(targetGroup) { - var pos = targetGroup.position; - targetGroup.origin = [ - viewBound[0][0] - pos[0], - viewBound[1][0] - pos[1] - ]; - } - - function getBound(rect) { - // [[xmin, xmax], [ymin, ymax]] - return [ - [rect.x, rect.x + rect.width], - [rect.y, rect.y + rect.height] - ]; - } - - function toBound(fromPos, from, to, dimIdx, boundIdx) { - fromPos[dimIdx] += to[dimIdx][boundIdx] - from[dimIdx][boundIdx]; - } - }, - - _createAxis: function (layoutInfo, timelineModel) { - var data = timelineModel.getData(); - var axisType = timelineModel.get('axisType'); - - var scale = axisHelper.createScaleByModel(timelineModel, axisType); - var dataExtent = data.getDataExtent('value'); - scale.setExtent(dataExtent[0], dataExtent[1]); - this._customizeScale(scale, data); - scale.niceTicks(); - - var axis = new TimelineAxis('value', scale, layoutInfo.axisExtent, axisType); - axis.model = timelineModel; - - return axis; - }, - - _customizeScale: function (scale, data) { - - scale.getTicks = function () { - return data.mapArray(['value'], function (value) { - return value; - }); - }; - - scale.getTicksLabels = function () { - return zrUtil.map(this.getTicks(), scale.getLabel, scale); - }; - }, - - _createGroup: function (name) { - var newGroup = this['_' + name] = new graphic.Group(); - this.group.add(newGroup); - return newGroup; - }, - - _renderAxisLine: function (layoutInfo, group, axis, timelineModel) { - var axisExtent = axis.getExtent(); - - if (!timelineModel.get('lineStyle.show')) { - return; - } - - group.add(new graphic.Line({ - shape: { - x1: axisExtent[0], y1: 0, - x2: axisExtent[1], y2: 0 - }, - style: zrUtil.extend( - {lineCap: 'round'}, - timelineModel.getModel('lineStyle').getLineStyle() - ), - silent: true, - z2: 1 - })); - }, - - /** - * @private - */ - _renderAxisTick: function (layoutInfo, group, axis, timelineModel) { - var data = timelineModel.getData(); - var ticks = axis.scale.getTicks(); - var tooltipHostModel = this._prepareTooltipHostModel(data, timelineModel); - - each(ticks, function (value, dataIndex) { - - var tickCoord = axis.dataToCoord(value); - var itemModel = data.getItemModel(dataIndex); - var itemStyleModel = itemModel.getModel('itemStyle.normal'); - var hoverStyleModel = itemModel.getModel('itemStyle.emphasis'); - var symbolOpt = { - position: [tickCoord, 0], - onclick: bind(this._changeTimeline, this, dataIndex) - }; - var el = giveSymbol(itemModel, itemStyleModel, group, symbolOpt); - graphic.setHoverStyle(el, hoverStyleModel.getItemStyle()); - - if (itemModel.get('tooltip')) { - el.dataIndex = dataIndex; - el.hostModel = tooltipHostModel; - } - else { - el.dataIndex = el.hostModel = null; - } - - }, this); - }, - - /** - * @private - */ - _prepareTooltipHostModel: function (data, timelineModel) { - var tooltipHostModel = modelUtil.createDataFormatModel( - {}, data, timelineModel.get('data') - ); - var me = this; - - tooltipHostModel.formatTooltip = function (dataIndex) { - return encodeHTML(me._axis.scale.getLabel(dataIndex)); - }; - - return tooltipHostModel; - }, - - /** - * @private - */ - _renderAxisLabel: function (layoutInfo, group, axis, timelineModel) { - var labelModel = timelineModel.getModel('label.normal'); - - if (!labelModel.get('show')) { - return; - } - - var data = timelineModel.getData(); - var ticks = axis.scale.getTicks(); - var labels = axisHelper.getFormattedLabels( - axis, labelModel.get('formatter') - ); - var labelInterval = axis.getLabelInterval(); - - each(ticks, function (tick, dataIndex) { - if (axis.isLabelIgnored(dataIndex, labelInterval)) { - return; - } - - var itemModel = data.getItemModel(dataIndex); - var itemTextStyleModel = itemModel.getModel('label.normal.textStyle'); - var hoverTextStyleModel = itemModel.getModel('label.emphasis.textStyle'); - var tickCoord = axis.dataToCoord(tick); - var textEl = new graphic.Text({ - style: { - text: labels[dataIndex], - textAlign: layoutInfo.labelAlign, - textBaseline: layoutInfo.labelBaseline, - textFont: itemTextStyleModel.getFont(), - fill: itemTextStyleModel.getTextColor() - }, - position: [tickCoord, 0], - rotation: layoutInfo.labelRotation - layoutInfo.rotation, - onclick: bind(this._changeTimeline, this, dataIndex), - silent: false - }); - - group.add(textEl); - graphic.setHoverStyle(textEl, hoverTextStyleModel.getItemStyle()); - - }, this); - }, - - /** - * @private - */ - _renderControl: function (layoutInfo, group, axis, timelineModel) { - var controlSize = layoutInfo.controlSize; - var rotation = layoutInfo.rotation; - - var itemStyle = timelineModel.getModel('controlStyle.normal').getItemStyle(); - var hoverStyle = timelineModel.getModel('controlStyle.emphasis').getItemStyle(); - var rect = [0, -controlSize / 2, controlSize, controlSize]; - var playState = timelineModel.getPlayState(); - var inverse = timelineModel.get('inverse', true); - - makeBtn( - layoutInfo.nextBtnPosition, - 'controlStyle.nextIcon', - bind(this._changeTimeline, this, inverse ? '-' : '+') - ); - makeBtn( - layoutInfo.prevBtnPosition, - 'controlStyle.prevIcon', - bind(this._changeTimeline, this, inverse ? '+' : '-') - ); - makeBtn( - layoutInfo.playPosition, - 'controlStyle.' + (playState ? 'stopIcon' : 'playIcon'), - bind(this._handlePlayClick, this, !playState), - true - ); - - function makeBtn(position, iconPath, onclick, willRotate) { - if (!position) { - return; - } - var opt = { - position: position, - origin: [controlSize / 2, 0], - rotation: willRotate ? -rotation : 0, - rectHover: true, - style: itemStyle, - onclick: onclick - }; - var btn = makeIcon(timelineModel, iconPath, rect, opt); - group.add(btn); - graphic.setHoverStyle(btn, hoverStyle); - } - }, - - _renderCurrentPointer: function (layoutInfo, group, axis, timelineModel) { - var data = timelineModel.getData(); - var currentIndex = timelineModel.getCurrentIndex(); - var pointerModel = data.getItemModel(currentIndex).getModel('checkpointStyle'); - var me = this; - - var callback = { - onCreate: function (pointer) { - pointer.draggable = true; - pointer.drift = bind(me._handlePointerDrag, me); - pointer.ondragend = bind(me._handlePointerDragend, me); - pointerMoveTo(pointer, currentIndex, axis, timelineModel, true); - }, - onUpdate: function (pointer) { - pointerMoveTo(pointer, currentIndex, axis, timelineModel); - } - }; - - // Reuse when exists, for animation and drag. - this._currentPointer = giveSymbol( - pointerModel, pointerModel, this._mainGroup, {}, this._currentPointer, callback - ); - }, - - _handlePlayClick: function (nextState) { - this._clearTimer(); - this.api.dispatchAction({ - type: 'timelinePlayChange', - playState: nextState, - from: this.uid - }); - }, - - _handlePointerDrag: function (dx, dy, e) { - this._clearTimer(); - this._pointerChangeTimeline([e.offsetX, e.offsetY]); - }, - - _handlePointerDragend: function (e) { - this._pointerChangeTimeline([e.offsetX, e.offsetY], true); - }, - - _pointerChangeTimeline: function (mousePos, trigger) { - var toCoord = this._toAxisCoord(mousePos)[0]; - - var axis = this._axis; - var axisExtent = numberUtil.asc(axis.getExtent().slice()); - - toCoord > axisExtent[1] && (toCoord = axisExtent[1]); - toCoord < axisExtent[0] && (toCoord = axisExtent[0]); - - this._currentPointer.position[0] = toCoord; - this._currentPointer.dirty(); - - var targetDataIndex = this._findNearestTick(toCoord); - var timelineModel = this.model; - - if (trigger || ( - targetDataIndex !== timelineModel.getCurrentIndex() - && timelineModel.get('realtime') - )) { - this._changeTimeline(targetDataIndex); - } - }, - - _doPlayStop: function () { - this._clearTimer(); - - if (this.model.getPlayState()) { - this._timer = setTimeout( - bind(handleFrame, this), - this.model.get('playInterval') - ); - } - - function handleFrame() { - // Do not cache - var timelineModel = this.model; - this._changeTimeline( - timelineModel.getCurrentIndex() - + (timelineModel.get('rewind', true) ? -1 : 1) - ); - } - }, - - _toAxisCoord: function (vertex) { - var trans = this._mainGroup.getLocalTransform(); - return graphic.applyTransform(vertex, trans, true); - }, - - _findNearestTick: function (axisCoord) { - var data = this.model.getData(); - var dist = Infinity; - var targetDataIndex; - var axis = this._axis; - - data.each(['value'], function (value, dataIndex) { - var coord = axis.dataToCoord(value); - var d = Math.abs(coord - axisCoord); - if (d < dist) { - dist = d; - targetDataIndex = dataIndex; - } - }); - - return targetDataIndex; - }, - - _clearTimer: function () { - if (this._timer) { - clearTimeout(this._timer); - this._timer = null; - } - }, - - _changeTimeline: function (nextIndex) { - var currentIndex = this.model.getCurrentIndex(); - - if (nextIndex === '+') { - nextIndex = currentIndex + 1; - } - else if (nextIndex === '-') { - nextIndex = currentIndex - 1; - } - - this.api.dispatchAction({ - type: 'timelineChange', - currentIndex: nextIndex, - from: this.uid - }); - } - - }); - - function getViewRect(model, api) { - return layout.getLayoutRect( - model.getBoxLayoutParams(), - { - width: api.getWidth(), - height: api.getHeight() - }, - model.get('padding') - ); - } - - function makeIcon(timelineModel, objPath, rect, opts) { - var icon = graphic.makePath( - timelineModel.get(objPath).replace(/^path:\/\//, ''), - zrUtil.clone(opts || {}), - new BoundingRect(rect[0], rect[1], rect[2], rect[3]), - 'center' - ); - - return icon; - } - - /** - * Create symbol or update symbol - */ - function giveSymbol(hostModel, itemStyleModel, group, opt, symbol, callback) { - var symbolType = hostModel.get('symbol'); - var color = itemStyleModel.get('color'); - var symbolSize = hostModel.get('symbolSize'); - var halfSymbolSize = symbolSize / 2; - var itemStyle = itemStyleModel.getItemStyle(['color', 'symbol', 'symbolSize']); - - if (!symbol) { - symbol = symbolUtil.createSymbol( - symbolType, -halfSymbolSize, -halfSymbolSize, symbolSize, symbolSize, color - ); - group.add(symbol); - callback && callback.onCreate(symbol); - } - else { - symbol.setStyle(itemStyle); - symbol.setColor(color); - group.add(symbol); // Group may be new, also need to add. - callback && callback.onUpdate(symbol); - } - - opt = zrUtil.merge({ - rectHover: true, - style: itemStyle, - z2: 100 - }, opt, true); - - symbol.attr(opt); - - return symbol; - } - - function pointerMoveTo(pointer, dataIndex, axis, timelineModel, noAnimation) { - if (pointer.dragging) { - return; - } - - var pointerModel = timelineModel.getModel('checkpointStyle'); - var toCoord = axis.dataToCoord(timelineModel.getData().get(['value'], dataIndex)); - - if (noAnimation || !pointerModel.get('animation', true)) { - pointer.attr({position: [toCoord, 0]}); - } - else { - pointer.stopAnimation(true); - pointer.animateTo( - {position: [toCoord, 0]}, - pointerModel.get('animationDuration', true), - pointerModel.get('animationEasing', true) - ); - } - } +/***/ }, +/* 343 */ +/***/ function(module, exports, __webpack_require__) { -}); -/** - * DataZoom component entry - */ -define('echarts/component/timeline',['require','../echarts','./timeline/preprocessor','./timeline/typeDefaulter','./timeline/timelineAction','./timeline/SliderTimelineModel','./timeline/SliderTimelineView'],function (require) { - - var echarts = require('../echarts'); - - echarts.registerPreprocessor(require('./timeline/preprocessor')); - - require('./timeline/typeDefaulter'); - require('./timeline/timelineAction'); - require('./timeline/SliderTimelineModel'); - require('./timeline/SliderTimelineView'); - -}); -define('echarts/component/toolbox/featureManager',['require'],function(require) { - - - var features = {}; - - return { - register: function (name, ctor) { - features[name] = ctor; - }, - - get: function (name) { - return features[name]; - } - }; -}); -define('echarts/component/toolbox/ToolboxModel',['require','./featureManager','zrender/core/util','../../echarts'],function (require) { - - var featureManager = require('./featureManager'); - var zrUtil = require('zrender/core/util'); - - var ToolboxModel = require('../../echarts').extendComponentModel({ - - type: 'toolbox', - - layoutMode: { - type: 'box', - ignoreSize: true - }, - - mergeDefaultAndTheme: function (option) { - ToolboxModel.superApply(this, 'mergeDefaultAndTheme', arguments); - - zrUtil.each(this.option.feature, function (featureOpt, featureName) { - var Feature = featureManager.get(featureName); - Feature && zrUtil.merge(featureOpt, Feature.defaultOption); - }); - }, - - defaultOption: { - - show: true, - - z: 6, - - zlevel: 0, - - orient: 'horizontal', - - left: 'right', - - top: 'top', - - // right - // bottom - - backgroundColor: 'transparent', - - borderColor: '#ccc', - - borderWidth: 0, - - padding: 5, - - itemSize: 15, - - itemGap: 8, - - showTitle: true, - - iconStyle: { - normal: { - borderColor: '#666', - color: 'none' - }, - emphasis: { - borderColor: '#3E98C5' - } - } - // textStyle: {}, - - // feature - } - }); - - return ToolboxModel; -}); -define('echarts/component/toolbox/ToolboxView',['require','./featureManager','zrender/core/util','../../util/graphic','../../model/Model','../../data/DataDiffer','../helper/listComponent','zrender/contain/text','../../echarts'],function (require) { - - var featureManager = require('./featureManager'); - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var Model = require('../../model/Model'); - var DataDiffer = require('../../data/DataDiffer'); - var listComponentHelper = require('../helper/listComponent'); - var textContain = require('zrender/contain/text'); - - return require('../../echarts').extendComponentView({ - - type: 'toolbox', - - render: function (toolboxModel, ecModel, api) { - var group = this.group; - group.removeAll(); - - if (!toolboxModel.get('show')) { - return; - } - - var itemSize = +toolboxModel.get('itemSize'); - var featureOpts = toolboxModel.get('feature') || {}; - var features = this._features || (this._features = {}); - - var featureNames = []; - zrUtil.each(featureOpts, function (opt, name) { - featureNames.push(name); - }); - - (new DataDiffer(this._featureNames || [], featureNames)) - .add(process) - .update(process) - .remove(zrUtil.curry(process, null)) - .execute(); - - // Keep for diff. - this._featureNames = featureNames; - - function process(newIndex, oldIndex) { - var featureName = featureNames[newIndex]; - var oldName = featureNames[oldIndex]; - var featureOpt = featureOpts[featureName]; - var featureModel = new Model(featureOpt, toolboxModel, toolboxModel.ecModel); - var feature; - - if (featureName && !oldName) { // Create - if (isUserFeatureName(featureName)) { - feature = { - model: featureModel, - onclick: featureModel.option.onclick, - featureName: featureName - }; - } - else { - var Feature = featureManager.get(featureName); - if (!Feature) { - return; - } - feature = new Feature(featureModel); - } - features[featureName] = feature; - } - else { - feature = features[oldName]; - // If feature does not exsit. - if (!feature) { - return; - } - feature.model = featureModel; - } - - if (!featureName && oldName) { - feature.dispose && feature.dispose(ecModel, api); - return; - } - - if (!featureModel.get('show') || feature.unusable) { - feature.remove && feature.remove(ecModel, api); - return; - } - - createIconPaths(featureModel, feature, featureName); - - featureModel.setIconStatus = function (iconName, status) { - var option = this.option; - var iconPaths = this.iconPaths; - option.iconStatus = option.iconStatus || {}; - option.iconStatus[iconName] = status; - // FIXME - iconPaths[iconName] && iconPaths[iconName].trigger(status); - }; - - if (feature.render) { - feature.render(featureModel, ecModel, api); - } - } - - function createIconPaths(featureModel, feature, featureName) { - var iconStyleModel = featureModel.getModel('iconStyle'); - - // If one feature has mutiple icon. they are orginaized as - // { - // icon: { - // foo: '', - // bar: '' - // }, - // title: { - // foo: '', - // bar: '' - // } - // } - var icons = feature.getIcons ? feature.getIcons() : featureModel.get('icon'); - var titles = featureModel.get('title') || {}; - if (typeof icons === 'string') { - var icon = icons; - var title = titles; - icons = {}; - titles = {}; - icons[featureName] = icon; - titles[featureName] = title; - } - var iconPaths = featureModel.iconPaths = {}; - zrUtil.each(icons, function (icon, iconName) { - var normalStyle = iconStyleModel.getModel('normal').getItemStyle(); - var hoverStyle = iconStyleModel.getModel('emphasis').getItemStyle(); - - var style = { - x: -itemSize / 2, - y: -itemSize / 2, - width: itemSize, - height: itemSize - }; - var path = icon.indexOf('image://') === 0 - ? ( - style.image = icon.slice(8), - new graphic.Image({style: style}) - ) - : graphic.makePath( - icon.replace('path://', ''), - { - style: normalStyle, - hoverStyle: hoverStyle, - rectHover: true - }, - style, - 'center' - ); - - graphic.setHoverStyle(path); - - if (toolboxModel.get('showTitle')) { - path.__title = titles[iconName]; - path.on('mouseover', function () { - path.setStyle({ - text: titles[iconName], - textPosition: hoverStyle.textPosition || 'bottom', - textFill: hoverStyle.fill || hoverStyle.stroke || '#000', - textAlign: hoverStyle.textAlign || 'center' - }); - }) - .on('mouseout', function () { - path.setStyle({ - textFill: null - }); - }); - } - path.trigger(featureModel.get('iconStatus.' + iconName) || 'normal'); - - group.add(path); - path.on('click', zrUtil.bind( - feature.onclick, feature, ecModel, api, iconName - )); - - iconPaths[iconName] = path; - }); - } - - listComponentHelper.layout(group, toolboxModel, api); - // Render background after group is layout - // FIXME - listComponentHelper.addBackground(group, toolboxModel); - - // Adjust icon title positions to avoid them out of screen - group.eachChild(function (icon) { - var titleText = icon.__title; - var hoverStyle = icon.hoverStyle; - // May be background element - if (hoverStyle && titleText) { - var rect = textContain.getBoundingRect( - titleText, hoverStyle.font - ); - var offsetX = icon.position[0] + group.position[0]; - var offsetY = icon.position[1] + group.position[1] + itemSize; - - var needPutOnTop = false; - if (offsetY + rect.height > api.getHeight()) { - hoverStyle.textPosition = 'top'; - needPutOnTop = true; - } - var topOffset = needPutOnTop ? (-5 - rect.height) : (itemSize + 8); - if (offsetX + rect.width / 2 > api.getWidth()) { - hoverStyle.textPosition = ['100%', topOffset]; - hoverStyle.textAlign = 'right'; - } - else if (offsetX - rect.width / 2 < 0) { - hoverStyle.textPosition = [0, topOffset]; - hoverStyle.textAlign = 'left'; - } - } - }); - }, - - remove: function (ecModel, api) { - zrUtil.each(this._features, function (feature) { - feature.remove && feature.remove(ecModel, api); - }); - this.group.removeAll(); - }, - - dispose: function (ecModel, api) { - zrUtil.each(this._features, function (feature) { - feature.dispose && feature.dispose(ecModel, api); - }); - } - }); - - function isUserFeatureName(featureName) { - return featureName.indexOf('my') === 0; - } - -}); -define('echarts/component/toolbox/feature/SaveAsImage',['require','zrender/core/env','../featureManager'],function (require) { - - var env = require('zrender/core/env'); - - function SaveAsImage (model) { - this.model = model; - } - - SaveAsImage.defaultOption = { - show: true, - icon: 'M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0', - title: '保存为图片', - type: 'png', - // Default use option.backgroundColor - // backgroundColor: '#fff', - name: '', - excludeComponents: ['toolbox'], - pixelRatio: 1, - lang: ['右键另存为图片'] - }; - - SaveAsImage.prototype.unusable = !env.canvasSupported; - - var proto = SaveAsImage.prototype; - - proto.onclick = function (ecModel, api) { - var model = this.model; - var title = model.get('name') || ecModel.get('title.0.text') || 'echarts'; - var $a = document.createElement('a'); - var type = model.get('type', true) || 'png'; - $a.download = title + '.' + type; - $a.target = '_blank'; - var url = api.getConnectedDataURL({ - type: type, - backgroundColor: model.get('backgroundColor', true) - || ecModel.get('backgroundColor') || '#fff', - excludeComponents: model.get('excludeComponents'), - pixelRatio: model.get('pixelRatio') - }); - $a.href = url; - // Chrome and Firefox - if (typeof MouseEvent === 'function') { - var evt = new MouseEvent('click', { - view: window, - bubbles: true, - cancelable: false - }); - $a.dispatchEvent(evt); - } - // IE - else { - var lang = model.get('lang'); - var html = '' - + '' - + '' - + ''; - var tab = window.open(); - tab.document.write(html); - } - }; - - require('../featureManager').register( - 'saveAsImage', SaveAsImage - ); - - return SaveAsImage; -}); -define('echarts/component/toolbox/feature/MagicType',['require','zrender/core/util','../../../echarts','../featureManager'],function(require) { - - - var zrUtil = require('zrender/core/util'); - - function MagicType(model) { - this.model = model; - } - - MagicType.defaultOption = { - show: true, - type: [], - // Icon group - icon: { - line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4', - bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7', - stack: 'M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z', // jshint ignore:line - tiled: 'M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z' - }, - title: { - line: '切换为折线图', - bar: '切换为柱状图', - stack: '切换为堆叠', - tiled: '切换为平铺' - }, - option: {}, - seriesIndex: {} - }; - - var proto = MagicType.prototype; - - proto.getIcons = function () { - var model = this.model; - var availableIcons = model.get('icon'); - var icons = {}; - zrUtil.each(model.get('type'), function (type) { - if (availableIcons[type]) { - icons[type] = availableIcons[type]; - } - }); - return icons; - }; - - var seriesOptGenreator = { - 'line': function (seriesType, seriesId, seriesModel, model) { - if (seriesType === 'bar') { - return zrUtil.merge({ - id: seriesId, - type: 'line', - // Preserve data related option - data: seriesModel.get('data'), - stack: seriesModel.get('stack'), - markPoint: seriesModel.get('markPoint'), - markLine: seriesModel.get('markLine') - }, model.get('option.line')); - } - }, - 'bar': function (seriesType, seriesId, seriesModel, model) { - if (seriesType === 'line') { - return zrUtil.merge({ - id: seriesId, - type: 'bar', - // Preserve data related option - data: seriesModel.get('data'), - stack: seriesModel.get('stack'), - markPoint: seriesModel.get('markPoint'), - markLine: seriesModel.get('markLine') - }, model.get('option.bar')); - } - }, - 'stack': function (seriesType, seriesId, seriesModel, model) { - if (seriesType === 'line' || seriesType === 'bar') { - return { - id: seriesId, - stack: '__ec_magicType_stack__' - }; - } - }, - 'tiled': function (seriesType, seriesId, seriesModel, model) { - if (seriesType === 'line' || seriesType === 'bar') { - return { - id: seriesId, - stack: '' - }; - } - } - }; - - var radioTypes = [ - ['line', 'bar'], - ['stack', 'tiled'] - ]; - - proto.onclick = function (ecModel, api, type) { - var model = this.model; - var seriesIndex = model.get('seriesIndex.' + type); - // Not supported magicType - if (!seriesOptGenreator[type]) { - return; - } - var newOption = { - series: [] - }; - var generateNewSeriesTypes = function (seriesModel) { - var seriesType = seriesModel.subType; - var seriesId = seriesModel.id; - var newSeriesOpt = seriesOptGenreator[type]( - seriesType, seriesId, seriesModel, model - ); - if (newSeriesOpt) { - // PENDING If merge original option? - zrUtil.defaults(newSeriesOpt, seriesModel.option); - newOption.series.push(newSeriesOpt); - } - }; - - zrUtil.each(radioTypes, function (radio) { - if (zrUtil.indexOf(radio, type) >= 0) { - zrUtil.each(radio, function (item) { - model.setIconStatus(item, 'normal'); - }); - } - }); - - model.setIconStatus(type, 'emphasis'); - - ecModel.eachComponent( - { - mainType: 'series', - seriesIndex: seriesIndex - }, generateNewSeriesTypes - ); - api.dispatchAction({ - type: 'changeMagicType', - currentType: type, - newOption: newOption - }); - }; - - var echarts = require('../../../echarts'); - echarts.registerAction({ - type: 'changeMagicType', - event: 'magicTypeChanged', - update: 'prepareAndUpdate' - }, function (payload, ecModel) { - ecModel.mergeOption(payload.newOption); - }); - - require('../featureManager').register('magicType', MagicType); - - return MagicType; -}); -/** - * @module echarts/component/toolbox/feature/DataView - */ - -define('echarts/component/toolbox/feature/DataView',['require','zrender/core/util','zrender/core/event','../featureManager','../../../echarts'],function (require) { - - var zrUtil = require('zrender/core/util'); - var eventTool = require('zrender/core/event'); - - - var BLOCK_SPLITER = new Array(60).join('-'); - var ITEM_SPLITER = '\t'; - /** - * Group series into two types - * 1. on category axis, like line, bar - * 2. others, like scatter, pie - * @param {module:echarts/model/Global} ecModel - * @return {Object} - * @inner - */ - function groupSeries(ecModel) { - var seriesGroupByCategoryAxis = {}; - var otherSeries = []; - var meta = []; - ecModel.eachRawSeries(function (seriesModel) { - var coordSys = seriesModel.coordinateSystem; - - if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) { - var baseAxis = coordSys.getBaseAxis(); - if (baseAxis.type === 'category') { - var key = baseAxis.dim + '_' + baseAxis.index; - if (!seriesGroupByCategoryAxis[key]) { - seriesGroupByCategoryAxis[key] = { - categoryAxis: baseAxis, - valueAxis: coordSys.getOtherAxis(baseAxis), - series: [] - }; - meta.push({ - axisDim: baseAxis.dim, - axisIndex: baseAxis.index - }); - } - seriesGroupByCategoryAxis[key].series.push(seriesModel); - } - else { - otherSeries.push(seriesModel); - } - } - else { - otherSeries.push(seriesModel); - } - }); - - return { - seriesGroupByCategoryAxis: seriesGroupByCategoryAxis, - other: otherSeries, - meta: meta - }; - } - - /** - * Assemble content of series on cateogory axis - * @param {Array.} series - * @return {string} - * @inner - */ - function assembleSeriesWithCategoryAxis(series) { - var tables = []; - zrUtil.each(series, function (group, key) { - var categoryAxis = group.categoryAxis; - var valueAxis = group.valueAxis; - var valueAxisDim = valueAxis.dim; - - var headers = [' '].concat(zrUtil.map(group.series, function (series) { - return series.name; - })); - var columns = [categoryAxis.model.getCategories()]; - zrUtil.each(group.series, function (series) { - columns.push(series.getRawData().mapArray(valueAxisDim, function (val) { - return val; - })); - }); - // Assemble table content - var lines = [headers.join(ITEM_SPLITER)]; - for (var i = 0; i < columns[0].length; i++) { - var items = []; - for (var j = 0; j < columns.length; j++) { - items.push(columns[j][i]); - } - lines.push(items.join(ITEM_SPLITER)); - } - tables.push(lines.join('\n')); - }); - return tables.join('\n\n' + BLOCK_SPLITER + '\n\n'); - } - - /** - * Assemble content of other series - * @param {Array.} series - * @return {string} - * @inner - */ - function assembleOtherSeries(series) { - return zrUtil.map(series, function (series) { - var data = series.getRawData(); - var lines = [series.name]; - var vals = []; - data.each(data.dimensions, function () { - var argLen = arguments.length; - var dataIndex = arguments[argLen - 1]; - var name = data.getName(dataIndex); - for (var i = 0; i < argLen - 1; i++) { - vals[i] = arguments[i]; - } - lines.push((name ? (name + ITEM_SPLITER) : '') + vals.join(ITEM_SPLITER)); - }); - return lines.join('\n'); - }).join('\n\n' + BLOCK_SPLITER + '\n\n'); - } - - /** - * @param {module:echarts/model/Global} - * @return {string} - * @inner - */ - function getContentFromModel(ecModel) { - - var result = groupSeries(ecModel); - - return { - value: zrUtil.filter([ - assembleSeriesWithCategoryAxis(result.seriesGroupByCategoryAxis), - assembleOtherSeries(result.other) - ], function (str) { - return str.replace(/[\n\t\s]/g, ''); - }).join('\n\n' + BLOCK_SPLITER + '\n\n'), - - meta: result.meta - }; - } - - - function trim(str) { - return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); - } - /** - * If a block is tsv format - */ - function isTSVFormat(block) { - // Simple method to find out if a block is tsv format - var firstLine = block.slice(0, block.indexOf('\n')); - if (firstLine.indexOf(ITEM_SPLITER) >= 0) { - return true; - } - } - - var itemSplitRegex = new RegExp('[' + ITEM_SPLITER + ']+', 'g'); - /** - * @param {string} tsv - * @return {Array.} - */ - function parseTSVContents(tsv) { - var tsvLines = tsv.split(/\n+/g); - var headers = trim(tsvLines.shift()).split(itemSplitRegex); - - var categories = []; - var series = zrUtil.map(headers, function (header) { - return { - name: header, - data: [] - }; - }); - for (var i = 0; i < tsvLines.length; i++) { - var items = trim(tsvLines[i]).split(itemSplitRegex); - categories.push(items.shift()); - for (var j = 0; j < items.length; j++) { - series[j] && (series[j].data[i] = items[j]); - } - } - return { - series: series, - categories: categories - }; - } - - /** - * @param {string} str - * @return {Array.} - * @inner - */ - function parseListContents(str) { - var lines = str.split(/\n+/g); - var seriesName = trim(lines.shift()); - - var data = []; - for (var i = 0; i < lines.length; i++) { - var items = trim(lines[i]).split(itemSplitRegex); - var name = ''; - var value; - var hasName = false; - if (isNaN(items[0])) { // First item is name - hasName = true; - name = items[0]; - items = items.slice(1); - data[i] = { - name: name, - value: [] - }; - value = data[i].value; - } - else { - value = data[i] = []; - } - for (var j = 0; j < items.length; j++) { - value.push(+items[j]); - } - if (value.length === 1) { - hasName ? (data[i].value = value[0]) : (data[i] = value[0]); - } - } - - return { - name: seriesName, - data: data - }; - } - - /** - * @param {string} str - * @param {Array.} blockMetaList - * @return {Object} - * @inner - */ - function parseContents(str, blockMetaList) { - var blocks = str.split(new RegExp('\n*' + BLOCK_SPLITER + '\n*', 'g')); - var newOption = { - series: [] - }; - zrUtil.each(blocks, function (block, idx) { - if (isTSVFormat(block)) { - var result = parseTSVContents(block); - var blockMeta = blockMetaList[idx]; - var axisKey = blockMeta.axisDim + 'Axis'; - - if (blockMeta) { - newOption[axisKey] = newOption[axisKey] || []; - newOption[axisKey][blockMeta.axisIndex] = { - data: result.categories - }; - newOption.series = newOption.series.concat(result.series); - } - } - else { - var result = parseListContents(block); - newOption.series.push(result); - } - }); - return newOption; - } - - /** - * @alias {module:echarts/component/toolbox/feature/DataView} - * @constructor - * @param {module:echarts/model/Model} model - */ - function DataView(model) { - - this._dom = null; - - this.model = model; - } - - DataView.defaultOption = { - show: true, - readOnly: false, - icon: 'M17.5,17.3H33 M17.5,17.3H33 M45.4,29.5h-28 M11.5,2v56H51V14.8L38.4,2H11.5z M38.4,2.2v12.7H51 M45.4,41.7h-28', - title: '数据视图', - lang: ['数据视图', '关闭', '刷新'], - backgroundColor: '#fff', - textColor: '#000', - textareaColor: '#fff', - textareaBorderColor: '#333', - buttonColor: '#c23531', - buttonTextColor: '#fff' - }; - - DataView.prototype.onclick = function (ecModel, api) { - var container = api.getDom(); - var model = this.model; - if (this._dom) { - container.removeChild(this._dom); - } - var root = document.createElement('div'); - root.style.cssText = 'position:absolute;left:5px;top:5px;bottom:5px;right:5px;'; - root.style.backgroundColor = model.get('backgroundColor') || '#fff'; - - // Create elements - var header = document.createElement('h4'); - var lang = model.get('lang') || []; - header.innerHTML = lang[0] || model.get('title'); - header.style.cssText = 'margin: 10px 20px;'; - header.style.color = model.get('textColor'); - - var textarea = document.createElement('textarea'); - // Textarea style - textarea.style.cssText = 'display:block;width:100%;font-size:14px;line-height:1.6rem;font-family:Monaco,Consolas,Courier new,monospace'; - textarea.readOnly = model.get('readOnly'); - textarea.style.color = model.get('textColor'); - textarea.style.borderColor = model.get('textareaBorderColor'); - textarea.style.backgroundColor = model.get('textareaColor'); - - var result = getContentFromModel(ecModel); - textarea.value = result.value; - var blockMetaList = result.meta; - - var buttonContainer = document.createElement('div'); - buttonContainer.style.cssText = 'position:absolute;bottom:0;left:0;right:0;'; - - var buttonStyle = 'float:right;margin-right:20px;border:none;' - + 'cursor:pointer;padding:2px 5px;font-size:12px;border-radius:3px'; - var closeButton = document.createElement('div'); - var refreshButton = document.createElement('div'); - - buttonStyle += ';background-color:' + model.get('buttonColor'); - buttonStyle += ';color:' + model.get('buttonTextColor'); - - var self = this; - - function close() { - container.removeChild(root); - self._dom = null; - } - eventTool.addEventListener(closeButton, 'click', close); - - eventTool.addEventListener(refreshButton, 'click', function () { - var newOption; - try { - newOption = parseContents(textarea.value, blockMetaList); - } - catch (e) { - close(); - throw new Error('Data view format error ' + e); - } - api.dispatchAction({ - type: 'changeDataView', - newOption: newOption - }); - - close(); - }); - - closeButton.innerHTML = lang[1]; - refreshButton.innerHTML = lang[2]; - refreshButton.style.cssText = buttonStyle; - closeButton.style.cssText = buttonStyle; - - buttonContainer.appendChild(refreshButton); - buttonContainer.appendChild(closeButton); - - // http://stackoverflow.com/questions/6637341/use-tab-to-indent-in-textarea - eventTool.addEventListener(textarea, 'keydown', function (e) { - if ((e.keyCode || e.which) === 9) { - // get caret position/selection - var val = this.value; - var start = this.selectionStart; - var end = this.selectionEnd; - - // set textarea value to: text before caret + tab + text after caret - this.value = val.substring(0, start) + ITEM_SPLITER + val.substring(end); - - // put caret at right position again - this.selectionStart = this.selectionEnd = start + 1; - - // prevent the focus lose - eventTool.stop(e); - } - }); - - root.appendChild(header); - root.appendChild(textarea); - root.appendChild(buttonContainer); - - textarea.style.height = (container.clientHeight - 80) + 'px'; - - container.appendChild(root); - this._dom = root; - }; - - DataView.prototype.remove = function (ecModel, api) { - this._dom && api.getDom().removeChild(this._dom); - }; - - DataView.prototype.dispose = function (ecModel, api) { - this.remove(ecModel, api); - }; - - /** - * @inner - */ - function tryMergeDataOption(newData, originalData) { - return zrUtil.map(newData, function (newVal, idx) { - var original = originalData && originalData[idx]; - if (zrUtil.isObject(original) && !zrUtil.isArray(original)) { - if (zrUtil.isObject(newVal) && !zrUtil.isArray(newVal)) { - newVal = newVal.value; - } - // Original data has option - return zrUtil.defaults({ - value: newVal - }, original); - } - else { - return newVal; - } - }); - } - - require('../featureManager').register('dataView', DataView); - - require('../../../echarts').registerAction({ - type: 'changeDataView', - event: 'dataViewChanged', - update: 'prepareAndUpdate' - }, function (payload, ecModel) { - var newSeriesOptList = []; - zrUtil.each(payload.newOption.series, function (seriesOpt) { - var seriesModel = ecModel.getSeriesByName(seriesOpt.name)[0]; - if (!seriesModel) { - // New created series - // Geuss the series type - newSeriesOptList.push(zrUtil.extend({ - // Default is scatter - type: 'scatter' - }, seriesOpt)); - } - else { - var originalData = seriesModel.get('data'); - newSeriesOptList.push({ - name: seriesOpt.name, - data: tryMergeDataOption(seriesOpt.data, originalData) - }); - } - }); - - ecModel.mergeOption(zrUtil.defaults({ - series: newSeriesOptList - }, payload.newOption)); - }); - - return DataView; -}); -/** - * @file History manager. - */ -define('echarts/component/dataZoom/history',['require','zrender/core/util'],function(require) { - - var zrUtil = require('zrender/core/util'); - var each = zrUtil.each; - - var ATTR = '\0_ec_hist_store'; - - var history = { - - /** - * @public - * @param {module:echarts/model/Global} ecModel - * @param {Object} newSnapshot {dataZoomId, batch: [payloadInfo, ...]} - */ - push: function (ecModel, newSnapshot) { - var store = giveStore(ecModel); - - // If previous dataZoom can not be found, - // complete an range with current range. - each(newSnapshot, function (batchItem, dataZoomId) { - var i = store.length - 1; - for (; i >= 0; i--) { - var snapshot = store[i]; - if (snapshot[dataZoomId]) { - break; - } - } - if (i < 0) { - // No origin range set, create one by current range. - var dataZoomModel = ecModel.queryComponents( - {mainType: 'dataZoom', subType: 'select', id: dataZoomId} - )[0]; - if (dataZoomModel) { - var percentRange = dataZoomModel.getPercentRange(); - store[0][dataZoomId] = { - dataZoomId: dataZoomId, - start: percentRange[0], - end: percentRange[1] - }; - } - } - }); - - store.push(newSnapshot); - }, - - /** - * @public - * @param {module:echarts/model/Global} ecModel - * @return {Object} snapshot - */ - pop: function (ecModel) { - var store = giveStore(ecModel); - var head = store[store.length - 1]; - store.length > 1 && store.pop(); - - // Find top for all dataZoom. - var snapshot = {}; - each(head, function (batchItem, dataZoomId) { - for (var i = store.length - 1; i >= 0; i--) { - var batchItem = store[i][dataZoomId]; - if (batchItem) { - snapshot[dataZoomId] = batchItem; - break; - } - } - }); - - return snapshot; - }, - - /** - * @public - */ - clear: function (ecModel) { - ecModel[ATTR] = null; - }, - - /** - * @public - * @param {module:echarts/model/Global} ecModel - * @return {number} records. always >= 1. - */ - count: function (ecModel) { - return giveStore(ecModel).length; - } - - }; - - /** - * [{key: dataZoomId, value: {dataZoomId, range}}, ...] - * History length of each dataZoom may be different. - * this._history[0] is used to store origin range. - * @type {Array.} - */ - function giveStore(ecModel) { - var store = ecModel[ATTR]; - if (!store) { - store = ecModel[ATTR] = [{}]; - } - return store; - } - - return history; - -}); -/** - * @file Data zoom model - */ -define('echarts/component/dataZoom/SelectZoomModel',['require','./DataZoomModel'],function(require) { - - var DataZoomModel = require('./DataZoomModel'); - - return DataZoomModel.extend({ - - type: 'dataZoom.select' - - }); - -}); -define('echarts/component/dataZoom/SelectZoomView',['require','./DataZoomView'],function (require) { - - return require('./DataZoomView').extend({ - - type: 'dataZoom.select' - - }); - -}); -/** - * DataZoom component entry - */ -define('echarts/component/dataZoomSelect',['require','./dataZoom/typeDefaulter','./dataZoom/DataZoomModel','./dataZoom/DataZoomView','./dataZoom/SelectZoomModel','./dataZoom/SelectZoomView','./dataZoom/dataZoomProcessor','./dataZoom/dataZoomAction'],function (require) { - - require('./dataZoom/typeDefaulter'); - - require('./dataZoom/DataZoomModel'); - require('./dataZoom/DataZoomView'); - - require('./dataZoom/SelectZoomModel'); - require('./dataZoom/SelectZoomView'); - - require('./dataZoom/dataZoomProcessor'); - require('./dataZoom/dataZoomAction'); - -}); -define('echarts/component/toolbox/feature/DataZoom',['require','zrender/core/util','../../../util/number','../../helper/SelectController','zrender/core/BoundingRect','zrender/container/Group','../../dataZoom/history','../../helper/interactionMutex','../../dataZoomSelect','../featureManager','../../../echarts'],function(require) { - - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../../../util/number'); - var SelectController = require('../../helper/SelectController'); - var BoundingRect = require('zrender/core/BoundingRect'); - var Group = require('zrender/container/Group'); - var history = require('../../dataZoom/history'); - var interactionMutex = require('../../helper/interactionMutex'); - - var each = zrUtil.each; - var asc = numberUtil.asc; - - // Use dataZoomSelect - require('../../dataZoomSelect'); - - // Spectial component id start with \0ec\0, see echarts/model/Global.js~hasInnerId - var DATA_ZOOM_ID_BASE = '\0_ec_\0toolbox-dataZoom_'; - - function DataZoom(model) { - this.model = model; - - /** - * @private - * @type {module:zrender/container/Group} - */ - this._controllerGroup; - - /** - * @private - * @type {module:echarts/component/helper/SelectController} - */ - this._controller; - - /** - * Is zoom active. - * @private - * @type {Object} - */ - this._isZoomActive; - } - - DataZoom.defaultOption = { - show: true, - // Icon group - icon: { - zoom: 'M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1', - back: 'M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26' - }, - title: { - zoom: '区域缩放', - back: '区域缩放还原' - } - }; - - var proto = DataZoom.prototype; - - proto.render = function (featureModel, ecModel, api) { - updateBackBtnStatus(featureModel, ecModel); - }; - - proto.onclick = function (ecModel, api, type) { - var controllerGroup = this._controllerGroup; - if (!this._controllerGroup) { - controllerGroup = this._controllerGroup = new Group(); - api.getZr().add(controllerGroup); - } - - handlers[type].call(this, controllerGroup, this.model, ecModel, api); - }; - - proto.remove = function (ecModel, api) { - this._disposeController(); - interactionMutex.release('globalPan', api.getZr()); - }; - - proto.dispose = function (ecModel, api) { - var zr = api.getZr(); - interactionMutex.release('globalPan', zr); - this._disposeController(); - this._controllerGroup && zr.remove(this._controllerGroup); - }; - - /** - * @private - */ - var handlers = { - - zoom: function (controllerGroup, featureModel, ecModel, api) { - var isZoomActive = this._isZoomActive = !this._isZoomActive; - var zr = api.getZr(); - - interactionMutex[isZoomActive ? 'take' : 'release']('globalPan', zr); - - featureModel.setIconStatus('zoom', isZoomActive ? 'emphasis' : 'normal'); - - if (isZoomActive) { - zr.setDefaultCursorStyle('crosshair'); - - this._createController( - controllerGroup, featureModel, ecModel, api - ); - } - else { - zr.setDefaultCursorStyle('default'); - this._disposeController(); - } - }, - - back: function (controllerGroup, featureModel, ecModel, api) { - this._dispatchAction(history.pop(ecModel), api); - } - }; - - /** - * @private - */ - proto._createController = function ( - controllerGroup, featureModel, ecModel, api - ) { - var controller = this._controller = new SelectController( - 'rect', - api.getZr(), - { - // FIXME - lineWidth: 3, - stroke: '#333', - fill: 'rgba(0,0,0,0.2)' - } - ); - controller.on( - 'selectEnd', - zrUtil.bind( - this._onSelected, this, controller, - featureModel, ecModel, api - ) - ); - controller.enable(controllerGroup, false); - }; - - proto._disposeController = function () { - var controller = this._controller; - if (controller) { - controller.off('selected'); - controller.dispose(); - } - }; - - function prepareCoordInfo(grid, ecModel) { - // Default use the first axis. - // FIXME - var coordInfo = [ - {axisModel: grid.getAxis('x').model, axisIndex: 0}, // x - {axisModel: grid.getAxis('y').model, axisIndex: 0} // y - ]; - coordInfo.grid = grid; - - ecModel.eachComponent( - {mainType: 'dataZoom', subType: 'select'}, - function (dzModel, dataZoomIndex) { - if (isTheAxis('xAxis', coordInfo[0].axisModel, dzModel, ecModel)) { - coordInfo[0].dataZoomModel = dzModel; - } - if (isTheAxis('yAxis', coordInfo[1].axisModel, dzModel, ecModel)) { - coordInfo[1].dataZoomModel = dzModel; - } - } - ); - - return coordInfo; - } - - function isTheAxis(axisName, axisModel, dataZoomModel, ecModel) { - var axisIndex = dataZoomModel.get(axisName + 'Index'); - return axisIndex != null - && ecModel.getComponent(axisName, axisIndex) === axisModel; - } - - /** - * @private - */ - proto._onSelected = function (controller, featureModel, ecModel, api, selRanges) { - if (!selRanges.length) { - return; - } - var selRange = selRanges[0]; - - controller.update(); // remove cover - - var snapshot = {}; - - // FIXME - // polar - - ecModel.eachComponent('grid', function (gridModel, gridIndex) { - var grid = gridModel.coordinateSystem; - var coordInfo = prepareCoordInfo(grid, ecModel); - var selDataRange = pointToDataInCartesian(selRange, coordInfo); - - if (selDataRange) { - var xBatchItem = scaleCartesianAxis(selDataRange, coordInfo, 0, 'x'); - var yBatchItem = scaleCartesianAxis(selDataRange, coordInfo, 1, 'y'); - - xBatchItem && (snapshot[xBatchItem.dataZoomId] = xBatchItem); - yBatchItem && (snapshot[yBatchItem.dataZoomId] = yBatchItem); - } - }, this); - - history.push(ecModel, snapshot); - - this._dispatchAction(snapshot, api); - }; - - function pointToDataInCartesian(selRange, coordInfo) { - var grid = coordInfo.grid; - - var selRect = new BoundingRect( - selRange[0][0], - selRange[1][0], - selRange[0][1] - selRange[0][0], - selRange[1][1] - selRange[1][0] - ); - if (!selRect.intersect(grid.getRect())) { - return; - } - var cartesian = grid.getCartesian(coordInfo[0].axisIndex, coordInfo[1].axisIndex); - var dataLeftTop = cartesian.pointToData([selRange[0][0], selRange[1][0]], true); - var dataRightBottom = cartesian.pointToData([selRange[0][1], selRange[1][1]], true); - - return [ - asc([dataLeftTop[0], dataRightBottom[0]]), // x, using asc to handle inverse - asc([dataLeftTop[1], dataRightBottom[1]]) // y, using asc to handle inverse - ]; - } - - function scaleCartesianAxis(selDataRange, coordInfo, dimIdx, dimName) { - var dimCoordInfo = coordInfo[dimIdx]; - var dataZoomModel = dimCoordInfo.dataZoomModel; - - if (dataZoomModel) { - return { - dataZoomId: dataZoomModel.id, - startValue: selDataRange[dimIdx][0], - endValue: selDataRange[dimIdx][1] - }; - } - } - - /** - * @private - */ - proto._dispatchAction = function (snapshot, api) { - var batch = []; - - each(snapshot, function (batchItem) { - batch.push(batchItem); - }); - - batch.length && api.dispatchAction({ - type: 'dataZoom', - from: this.uid, - batch: zrUtil.clone(batch, true) - }); - }; - - function updateBackBtnStatus(featureModel, ecModel) { - featureModel.setIconStatus( - 'back', - history.count(ecModel) > 1 ? 'emphasis' : 'normal' - ); - } - - - require('../featureManager').register('dataZoom', DataZoom); - - - // Create special dataZoom option for select - require('../../../echarts').registerPreprocessor(function (option) { - if (!option) { - return; - } - - var dataZoomOpts = option.dataZoom || (option.dataZoom = []); - if (!zrUtil.isArray(dataZoomOpts)) { - dataZoomOpts = [dataZoomOpts]; - } - - var toolboxOpt = option.toolbox; - if (toolboxOpt) { - // Assume there is only one toolbox - if (zrUtil.isArray(toolboxOpt)) { - toolboxOpt = toolboxOpt[0]; - } - - if (toolboxOpt && toolboxOpt.feature) { - var dataZoomOpt = toolboxOpt.feature.dataZoom; - addForAxis('xAxis', dataZoomOpt); - addForAxis('yAxis', dataZoomOpt); - } - } - - function addForAxis(axisName, dataZoomOpt) { - if (!dataZoomOpt) { - return; - } - - var axisIndicesName = axisName + 'Index'; - var givenAxisIndices = dataZoomOpt[axisIndicesName]; - if (givenAxisIndices != null && !zrUtil.isArray(givenAxisIndices)) { - givenAxisIndices = givenAxisIndices === false ? [] : [givenAxisIndices]; - } - - forEachComponent(axisName, function (axisOpt, axisIndex) { - if (givenAxisIndices != null - && zrUtil.indexOf(givenAxisIndices, axisIndex) === -1 - ) { - return; - } - var newOpt = { - type: 'select', - $fromToolbox: true, - // Id for merge mapping. - id: DATA_ZOOM_ID_BASE + axisName + axisIndex - }; - // FIXME - // Only support one axis now. - newOpt[axisIndicesName] = axisIndex; - dataZoomOpts.push(newOpt); - }); - } - - function forEachComponent(mainType, cb) { - var opts = option[mainType]; - if (!zrUtil.isArray(opts)) { - opts = opts ? [opts] : []; - } - each(opts, cb); - } - }); - - return DataZoom; -}); -define('echarts/component/toolbox/feature/Restore',['require','../../dataZoom/history','../featureManager','../../../echarts'],function(require) { - - - var history = require('../../dataZoom/history'); - - function Restore(model) { - this.model = model; - } - - Restore.defaultOption = { - show: true, - icon: 'M3.8,33.4 M47,18.9h9.8V8.7 M56.3,20.1 C52.1,9,40.5,0.6,26.8,2.1C12.6,3.7,1.6,16.2,2.1,30.6 M13,41.1H3.1v10.2 M3.7,39.9c4.2,11.1,15.8,19.5,29.5,18 c14.2-1.6,25.2-14.1,24.7-28.5', - title: '还原' - }; - - var proto = Restore.prototype; - - proto.onclick = function (ecModel, api, type) { - history.clear(ecModel); - - api.dispatchAction({ - type: 'restore', - from: this.uid - }); - }; - - - require('../featureManager').register('restore', Restore); - - - require('../../../echarts').registerAction( - {type: 'restore', event: 'restore', update: 'prepareAndUpdate'}, - function (payload, ecModel) { - ecModel.resetOption('recreate'); - } - ); - - return Restore; -}); -define('echarts/component/toolbox',['require','./toolbox/ToolboxModel','./toolbox/ToolboxView','./toolbox/feature/SaveAsImage','./toolbox/feature/MagicType','./toolbox/feature/DataView','./toolbox/feature/DataZoom','./toolbox/feature/Restore'],function (require) { - - require('./toolbox/ToolboxModel'); - require('./toolbox/ToolboxView'); - - require('./toolbox/feature/SaveAsImage'); - require('./toolbox/feature/MagicType'); - require('./toolbox/feature/DataView'); - require('./toolbox/feature/DataZoom'); - require('./toolbox/feature/Restore'); -}); -define('zrender/vml/core',['require','exports','module','../core/env'],function (require, exports, module) { - -if (!require('../core/env').canvasSupported) { - var urn = 'urn:schemas-microsoft-com:vml'; - - var createNode; - var win = window; - var doc = win.document; - - var vmlInited = false; - - try { - !doc.namespaces.zrvml && doc.namespaces.add('zrvml', urn); - createNode = function (tagName) { - return doc.createElement(''); - }; - } - catch (e) { - createNode = function (tagName) { - return doc.createElement('<' + tagName + ' xmlns="' + urn + '" class="zrvml">'); - }; - } - - // From raphael - var initVML = function () { - if (vmlInited) { - return; - } - vmlInited = true; - - var styleSheets = doc.styleSheets; - if (styleSheets.length < 31) { - doc.createStyleSheet().addRule('.zrvml', 'behavior:url(#default#VML)'); - } - else { - // http://msdn.microsoft.com/en-us/library/ms531194%28VS.85%29.aspx - styleSheets[0].addRule('.zrvml', 'behavior:url(#default#VML)'); - } - }; - - // Not useing return to avoid error when converting to CommonJS module - module.exports = { - doc: doc, - initVML: initVML, - createNode: createNode - }; -} -}); -// http://www.w3.org/TR/NOTE-VML -// TODO Use proxy like svg instead of overwrite brush methods -define('zrender/vml/graphic',['require','../core/env','../core/vector','../core/BoundingRect','../core/PathProxy','../tool/color','../contain/text','../graphic/mixin/RectText','../graphic/Displayable','../graphic/Image','../graphic/Text','../graphic/Path','../graphic/Gradient','./core'],function (require) { - -if (!require('../core/env').canvasSupported) { - var vec2 = require('../core/vector'); - var BoundingRect = require('../core/BoundingRect'); - var CMD = require('../core/PathProxy').CMD; - var colorTool = require('../tool/color'); - var textContain = require('../contain/text'); - var RectText = require('../graphic/mixin/RectText'); - var Displayable = require('../graphic/Displayable'); - var ZImage = require('../graphic/Image'); - var Text = require('../graphic/Text'); - var Path = require('../graphic/Path'); - - var Gradient = require('../graphic/Gradient'); - - var vmlCore = require('./core'); - - var round = Math.round; - var sqrt = Math.sqrt; - var abs = Math.abs; - var cos = Math.cos; - var sin = Math.sin; - var mathMax = Math.max; - - var applyTransform = vec2.applyTransform; - - var comma = ','; - var imageTransformPrefix = 'progid:DXImageTransform.Microsoft'; - - var Z = 21600; - var Z2 = Z / 2; - - var ZLEVEL_BASE = 100000; - var Z_BASE = 1000; - - var initRootElStyle = function (el) { - el.style.cssText = 'position:absolute;left:0;top:0;width:1px;height:1px;'; - el.coordsize = Z + ',' + Z; - el.coordorigin = '0,0'; - }; - - var encodeHtmlAttribute = function (s) { - return String(s).replace(/&/g, '&').replace(/"/g, '"'); - }; - - var rgb2Str = function (r, g, b) { - return 'rgb(' + [r, g, b].join(',') + ')'; - }; - - var append = function (parent, child) { - if (child && parent && child.parentNode !== parent) { - parent.appendChild(child); - } - }; - - var remove = function (parent, child) { - if (child && parent && child.parentNode === parent) { - parent.removeChild(child); - } - }; - - var getZIndex = function (zlevel, z, z2) { - // z 的取值范围为 [0, 1000] - return (parseFloat(zlevel) || 0) * ZLEVEL_BASE + (parseFloat(z) || 0) * Z_BASE + z2; - }; - - var parsePercent = function (value, maxValue) { - if (typeof value === 'string') { - if (value.lastIndexOf('%') >= 0) { - return parseFloat(value) / 100 * maxValue; - } - return parseFloat(value); - } - return value; - }; - - /*************************************************** - * PATH - **************************************************/ - - var setColorAndOpacity = function (el, color, opacity) { - var colorArr = colorTool.parse(color); - opacity = +opacity; - if (isNaN(opacity)) { - opacity = 1; - } - if (colorArr) { - el.color = rgb2Str(colorArr[0], colorArr[1], colorArr[2]); - el.opacity = opacity * colorArr[3]; - } - }; - - var getColorAndAlpha = function (color) { - var colorArr = colorTool.parse(color); - return [ - rgb2Str(colorArr[0], colorArr[1], colorArr[2]), - colorArr[3] - ]; - }; - - var updateFillNode = function (el, style, zrEl) { - // TODO pattern - var fill = style.fill; - if (fill != null) { - // Modified from excanvas - if (fill instanceof Gradient) { - var gradientType; - var angle = 0; - var focus = [0, 0]; - // additional offset - var shift = 0; - // scale factor for offset - var expansion = 1; - var rect = zrEl.getBoundingRect(); - var rectWidth = rect.width; - var rectHeight = rect.height; - if (fill.type === 'linear') { - gradientType = 'gradient'; - var transform = zrEl.transform; - var p0 = [fill.x * rectWidth, fill.y * rectHeight]; - var p1 = [fill.x2 * rectWidth, fill.y2 * rectHeight]; - if (transform) { - applyTransform(p0, p0, transform); - applyTransform(p1, p1, transform); - } - var dx = p1[0] - p0[0]; - var dy = p1[1] - p0[1]; - angle = Math.atan2(dx, dy) * 180 / Math.PI; - // The angle should be a non-negative number. - if (angle < 0) { - angle += 360; - } - - // Very small angles produce an unexpected result because they are - // converted to a scientific notation string. - if (angle < 1e-6) { - angle = 0; - } - } - else { - gradientType = 'gradientradial'; - var p0 = [fill.x * rectWidth, fill.y * rectHeight]; - var transform = zrEl.transform; - var scale = zrEl.scale; - var width = rectWidth; - var height = rectHeight; - focus = [ - // Percent in bounding rect - (p0[0] - rect.x) / width, - (p0[1] - rect.y) / height - ]; - if (transform) { - applyTransform(p0, p0, transform); - } - - width /= scale[0] * Z; - height /= scale[1] * Z; - var dimension = mathMax(width, height); - shift = 2 * 0 / dimension; - expansion = 2 * fill.r / dimension - shift; - } - - // We need to sort the color stops in ascending order by offset, - // otherwise IE won't interpret it correctly. - var stops = fill.colorStops.slice(); - stops.sort(function(cs1, cs2) { - return cs1.offset - cs2.offset; - }); - - var length = stops.length; - // Color and alpha list of first and last stop - var colorAndAlphaList = []; - var colors = []; - for (var i = 0; i < length; i++) { - var stop = stops[i]; - var colorAndAlpha = getColorAndAlpha(stop.color); - colors.push(stop.offset * expansion + shift + ' ' + colorAndAlpha[0]); - if (i === 0 || i === length - 1) { - colorAndAlphaList.push(colorAndAlpha); - } - } - - if (length >= 2) { - var color1 = colorAndAlphaList[0][0]; - var color2 = colorAndAlphaList[1][0]; - var opacity1 = colorAndAlphaList[0][1] * style.opacity; - var opacity2 = colorAndAlphaList[1][1] * style.opacity; - - el.type = gradientType; - el.method = 'none'; - el.focus = '100%'; - el.angle = angle; - el.color = color1; - el.color2 = color2; - el.colors = colors.join(','); - // When colors attribute is used, the meanings of opacity and o:opacity2 - // are reversed. - el.opacity = opacity2; - // FIXME g_o_:opacity ? - el.opacity2 = opacity1; - } - if (gradientType === 'radial') { - el.focusposition = focus.join(','); - } - } - else { - // FIXME Change from Gradient fill to color fill - setColorAndOpacity(el, fill, style.opacity); - } - } - }; - - var updateStrokeNode = function (el, style) { - if (style.lineJoin != null) { - el.joinstyle = style.lineJoin; - } - if (style.miterLimit != null) { - el.miterlimit = style.miterLimit * Z; - } - if (style.lineCap != null) { - el.endcap = style.lineCap; - } - if (style.lineDash != null) { - el.dashstyle = style.lineDash.join(' '); - } - if (style.stroke != null && !(style.stroke instanceof Gradient)) { - setColorAndOpacity(el, style.stroke, style.opacity); - } - }; - - var updateFillAndStroke = function (vmlEl, type, style, zrEl) { - var isFill = type == 'fill'; - var el = vmlEl.getElementsByTagName(type)[0]; - // Stroke must have lineWidth - if (style[type] != null && style[type] !== 'none' && (isFill || (!isFill && style.lineWidth))) { - vmlEl[isFill ? 'filled' : 'stroked'] = 'true'; - // FIXME Remove before updating, or set `colors` will throw error - if (style[type] instanceof Gradient) { - remove(vmlEl, el); - } - if (!el) { - el = vmlCore.createNode(type); - } - - isFill ? updateFillNode(el, style, zrEl) : updateStrokeNode(el, style); - append(vmlEl, el); - } - else { - vmlEl[isFill ? 'filled' : 'stroked'] = 'false'; - remove(vmlEl, el); - } - }; - - var points = [[], [], []]; - var pathDataToString = function (data, m) { - var M = CMD.M; - var C = CMD.C; - var L = CMD.L; - var A = CMD.A; - var Q = CMD.Q; - - var str = []; - var nPoint; - var cmdStr; - var cmd; - var i; - var xi; - var yi; - for (i = 0; i < data.length;) { - cmd = data[i++]; - cmdStr = ''; - nPoint = 0; - switch (cmd) { - case M: - cmdStr = ' m '; - nPoint = 1; - xi = data[i++]; - yi = data[i++]; - points[0][0] = xi; - points[0][1] = yi; - break; - case L: - cmdStr = ' l '; - nPoint = 1; - xi = data[i++]; - yi = data[i++]; - points[0][0] = xi; - points[0][1] = yi; - break; - case Q: - case C: - cmdStr = ' c '; - nPoint = 3; - var x1 = data[i++]; - var y1 = data[i++]; - var x2 = data[i++]; - var y2 = data[i++]; - var x3; - var y3; - if (cmd === Q) { - // Convert quadratic to cubic using degree elevation - x3 = x2; - y3 = y2; - x2 = (x2 + 2 * x1) / 3; - y2 = (y2 + 2 * y1) / 3; - x1 = (xi + 2 * x1) / 3; - y1 = (yi + 2 * y1) / 3; - } - else { - x3 = data[i++]; - y3 = data[i++]; - } - points[0][0] = x1; - points[0][1] = y1; - points[1][0] = x2; - points[1][1] = y2; - points[2][0] = x3; - points[2][1] = y3; - - xi = x3; - yi = y3; - break; - case A: - var x = 0; - var y = 0; - var sx = 1; - var sy = 1; - var angle = 0; - if (m) { - // Extract SRT from matrix - x = m[4]; - y = m[5]; - sx = sqrt(m[0] * m[0] + m[1] * m[1]); - sy = sqrt(m[2] * m[2] + m[3] * m[3]); - angle = Math.atan2(-m[1] / sy, m[0] / sx); - } - - var cx = data[i++]; - var cy = data[i++]; - var rx = data[i++]; - var ry = data[i++]; - var startAngle = data[i++] + angle; - var endAngle = data[i++] + startAngle + angle; - // FIXME - // var psi = data[i++]; - i++; - var clockwise = data[i++]; - - var x0 = cx + cos(startAngle) * rx; - var y0 = cy + sin(startAngle) * ry; - - var x1 = cx + cos(endAngle) * rx; - var y1 = cy + sin(endAngle) * ry; - - var type = clockwise ? ' wa ' : ' at '; - - str.push( - type, - round(((cx - rx) * sx + x) * Z - Z2), comma, - round(((cy - ry) * sy + y) * Z - Z2), comma, - round(((cx + rx) * sx + x) * Z - Z2), comma, - round(((cy + ry) * sy + y) * Z - Z2), comma, - round((x0 * sx + x) * Z - Z2), comma, - round((y0 * sy + y) * Z - Z2), comma, - round((x1 * sx + x) * Z - Z2), comma, - round((y1 * sy + y) * Z - Z2) - ); - - xi = x1; - yi = y1; - break; - case CMD.R: - var p0 = points[0]; - var p1 = points[1]; - // x0, y0 - p0[0] = data[i++]; - p0[1] = data[i++]; - // x1, y1 - p1[0] = p0[0] + data[i++]; - p1[1] = p0[1] + data[i++]; - - if (m) { - applyTransform(p0, p0, m); - applyTransform(p1, p1, m); - } - - p0[0] = round(p0[0] * Z - Z2); - p1[0] = round(p1[0] * Z - Z2); - p0[1] = round(p0[1] * Z - Z2); - p1[1] = round(p1[1] * Z - Z2); - str.push( - // x0, y0 - ' m ', p0[0], comma, p0[1], - // x1, y0 - ' l ', p1[0], comma, p0[1], - // x1, y1 - ' l ', p1[0], comma, p1[1], - // x0, y1 - ' l ', p0[0], comma, p1[1] - ); - break; - case CMD.Z: - // FIXME Update xi, yi - str.push(' x '); - } - - if (nPoint > 0) { - str.push(cmdStr); - for (var k = 0; k < nPoint; k++) { - var p = points[k]; - - m && applyTransform(p, p, m); - // 不 round 会非常慢 - str.push( - round(p[0] * Z - Z2), comma, round(p[1] * Z - Z2), - k < nPoint - 1 ? comma : '' - ); - } - } - } - return str.join(''); - }; - - // Rewrite the original path method - Path.prototype.brush = function (vmlRoot) { - var style = this.style; - - var vmlEl = this._vmlEl; - if (!vmlEl) { - vmlEl = vmlCore.createNode('shape'); - initRootElStyle(vmlEl); - - this._vmlEl = vmlEl; - } - - updateFillAndStroke(vmlEl, 'fill', style, this); - updateFillAndStroke(vmlEl, 'stroke', style, this); - - var m = this.transform; - var needTransform = m != null; - var strokeEl = vmlEl.getElementsByTagName('stroke')[0]; - if (strokeEl) { - var lineWidth = style.lineWidth; - // Get the line scale. - // Determinant of this.m_ means how much the area is enlarged by the - // transformation. So its square root can be used as a scale factor - // for width. - if (needTransform && !style.strokeNoScale) { - var det = m[0] * m[3] - m[1] * m[2]; - lineWidth *= sqrt(abs(det)); - } - strokeEl.weight = lineWidth + 'px'; - } - - var path = this.path; - if (this.__dirtyPath) { - path.beginPath(); - this.buildPath(path, this.shape); - this.__dirtyPath = false; - } - - vmlEl.path = pathDataToString(path.data, this.transform); - - vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2); - - // Append to root - append(vmlRoot, vmlEl); - - // Text - if (style.text) { - this.drawRectText(vmlRoot, this.getBoundingRect()); - } - }; - - Path.prototype.onRemoveFromStorage = function (vmlRoot) { - remove(vmlRoot, this._vmlEl); - this.removeRectText(vmlRoot); - }; - - Path.prototype.onAddToStorage = function (vmlRoot) { - append(vmlRoot, this._vmlEl); - this.appendRectText(vmlRoot); - }; - - /*************************************************** - * IMAGE - **************************************************/ - var isImage = function (img) { - // FIXME img instanceof Image 如果 img 是一个字符串的时候,IE8 下会报错 - return (typeof img === 'object') && img.tagName && img.tagName.toUpperCase() === 'IMG'; - // return img instanceof Image; - }; - - // Rewrite the original path method - ZImage.prototype.brush = function (vmlRoot) { - var style = this.style; - var image = style.image; - - // Image original width, height - var ow; - var oh; - - if (isImage(image)) { - var src = image.src; - if (src === this._imageSrc) { - ow = this._imageWidth; - oh = this._imageHeight; - } - else { - var imageRuntimeStyle = image.runtimeStyle; - var oldRuntimeWidth = imageRuntimeStyle.width; - var oldRuntimeHeight = imageRuntimeStyle.height; - imageRuntimeStyle.width = 'auto'; - imageRuntimeStyle.height = 'auto'; - - // get the original size - ow = image.width; - oh = image.height; - - // and remove overides - imageRuntimeStyle.width = oldRuntimeWidth; - imageRuntimeStyle.height = oldRuntimeHeight; - - // Caching image original width, height and src - this._imageSrc = src; - this._imageWidth = ow; - this._imageHeight = oh; - } - image = src; - } - else { - if (image === this._imageSrc) { - ow = this._imageWidth; - oh = this._imageHeight; - } - } - if (!image) { - return; - } - - var x = style.x || 0; - var y = style.y || 0; - - var dw = style.width; - var dh = style.height; - - var sw = style.sWidth; - var sh = style.sHeight; - var sx = style.sx || 0; - var sy = style.sy || 0; - - var hasCrop = sw && sh; - - var vmlEl = this._vmlEl; - if (!vmlEl) { - // FIXME 使用 group 在 left, top 都不是 0 的时候就无法显示了。 - // vmlEl = vmlCore.createNode('group'); - vmlEl = vmlCore.doc.createElement('div'); - initRootElStyle(vmlEl); - - this._vmlEl = vmlEl; - } - - var vmlElStyle = vmlEl.style; - var hasRotation = false; - var m; - var scaleX = 1; - var scaleY = 1; - if (this.transform) { - m = this.transform; - scaleX = sqrt(m[0] * m[0] + m[1] * m[1]); - scaleY = sqrt(m[2] * m[2] + m[3] * m[3]); - - hasRotation = m[1] || m[2]; - } - if (hasRotation) { - // If filters are necessary (rotation exists), create them - // filters are bog-slow, so only create them if abbsolutely necessary - // The following check doesn't account for skews (which don't exist - // in the canvas spec (yet) anyway. - // From excanvas - var p0 = [x, y]; - var p1 = [x + dw, y]; - var p2 = [x, y + dh]; - var p3 = [x + dw, y + dh]; - applyTransform(p0, p0, m); - applyTransform(p1, p1, m); - applyTransform(p2, p2, m); - applyTransform(p3, p3, m); - - var maxX = mathMax(p0[0], p1[0], p2[0], p3[0]); - var maxY = mathMax(p0[1], p1[1], p2[1], p3[1]); - - var transformFilter = []; - transformFilter.push('M11=', m[0] / scaleX, comma, - 'M12=', m[2] / scaleY, comma, - 'M21=', m[1] / scaleX, comma, - 'M22=', m[3] / scaleY, comma, - 'Dx=', round(x * scaleX + m[4]), comma, - 'Dy=', round(y * scaleY + m[5])); - - vmlElStyle.padding = '0 ' + round(maxX) + 'px ' + round(maxY) + 'px 0'; - // FIXME DXImageTransform 在 IE11 的兼容模式下不起作用 - vmlElStyle.filter = imageTransformPrefix + '.Matrix(' - + transformFilter.join('') + ', SizingMethod=clip)'; - - } - else { - if (m) { - x = x * scaleX + m[4]; - y = y * scaleY + m[5]; - } - vmlElStyle.filter = ''; - vmlElStyle.left = round(x) + 'px'; - vmlElStyle.top = round(y) + 'px'; - } - - var imageEl = this._imageEl; - var cropEl = this._cropEl; - - if (! imageEl) { - imageEl = vmlCore.doc.createElement('div'); - this._imageEl = imageEl; - } - var imageELStyle = imageEl.style; - if (hasCrop) { - // Needs know image original width and height - if (! (ow && oh)) { - var tmpImage = new Image(); - var self = this; - tmpImage.onload = function () { - tmpImage.onload = null; - ow = tmpImage.width; - oh = tmpImage.height; - // Adjust image width and height to fit the ratio destinationSize / sourceSize - imageELStyle.width = round(scaleX * ow * dw / sw) + 'px'; - imageELStyle.height = round(scaleY * oh * dh / sh) + 'px'; - - // Caching image original width, height and src - self._imageWidth = ow; - self._imageHeight = oh; - self._imageSrc = image; - }; - tmpImage.src = image; - } - else { - imageELStyle.width = round(scaleX * ow * dw / sw) + 'px'; - imageELStyle.height = round(scaleY * oh * dh / sh) + 'px'; - } - - if (! cropEl) { - cropEl = vmlCore.doc.createElement('div'); - cropEl.style.overflow = 'hidden'; - this._cropEl = cropEl; - } - var cropElStyle = cropEl.style; - cropElStyle.width = round((dw + sx * dw / sw) * scaleX); - cropElStyle.height = round((dh + sy * dh / sh) * scaleY); - cropElStyle.filter = imageTransformPrefix + '.Matrix(Dx=' - + (-sx * dw / sw * scaleX) + ',Dy=' + (-sy * dh / sh * scaleY) + ')'; - - if (! cropEl.parentNode) { - vmlEl.appendChild(cropEl); - } - if (imageEl.parentNode != cropEl) { - cropEl.appendChild(imageEl); - } - } - else { - imageELStyle.width = round(scaleX * dw) + 'px'; - imageELStyle.height = round(scaleY * dh) + 'px'; - - vmlEl.appendChild(imageEl); - - if (cropEl && cropEl.parentNode) { - vmlEl.removeChild(cropEl); - this._cropEl = null; - } - } - - var filterStr = ''; - var alpha = style.opacity; - if (alpha < 1) { - filterStr += '.Alpha(opacity=' + round(alpha * 100) + ') '; - } - filterStr += imageTransformPrefix + '.AlphaImageLoader(src=' + image + ', SizingMethod=scale)'; - - imageELStyle.filter = filterStr; - - vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2); - - // Append to root - append(vmlRoot, vmlEl); - - // Text - if (style.text) { - this.drawRectText(vmlRoot, this.getBoundingRect()); - } - }; - - ZImage.prototype.onRemoveFromStorage = function (vmlRoot) { - remove(vmlRoot, this._vmlEl); - - this._vmlEl = null; - this._cropEl = null; - this._imageEl = null; - - this.removeRectText(vmlRoot); - }; - - ZImage.prototype.onAddToStorage = function (vmlRoot) { - append(vmlRoot, this._vmlEl); - this.appendRectText(vmlRoot); - }; - - - /*************************************************** - * TEXT - **************************************************/ - - var DEFAULT_STYLE_NORMAL = 'normal'; - - var fontStyleCache = {}; - var fontStyleCacheCount = 0; - var MAX_FONT_CACHE_SIZE = 100; - var fontEl = document.createElement('div'); - - var getFontStyle = function (fontString) { - var fontStyle = fontStyleCache[fontString]; - if (!fontStyle) { - // Clear cache - if (fontStyleCacheCount > MAX_FONT_CACHE_SIZE) { - fontStyleCacheCount = 0; - fontStyleCache = {}; - } - - var style = fontEl.style; - var fontFamily; - try { - style.font = fontString; - fontFamily = style.fontFamily.split(',')[0]; - } - catch (e) { - } - - fontStyle = { - style: style.fontStyle || DEFAULT_STYLE_NORMAL, - variant: style.fontVariant || DEFAULT_STYLE_NORMAL, - weight: style.fontWeight || DEFAULT_STYLE_NORMAL, - size: parseFloat(style.fontSize || 12) | 0, - family: fontFamily || 'Microsoft YaHei' - }; - - fontStyleCache[fontString] = fontStyle; - fontStyleCacheCount++; - } - return fontStyle; - }; - - var textMeasureEl; - // Overwrite measure text method - textContain.measureText = function (text, textFont) { - var doc = vmlCore.doc; - if (!textMeasureEl) { - textMeasureEl = doc.createElement('div'); - textMeasureEl.style.cssText = 'position:absolute;top:-20000px;left:0;' - + 'padding:0;margin:0;border:none;white-space:pre;'; - vmlCore.doc.body.appendChild(textMeasureEl); - } - - try { - textMeasureEl.style.font = textFont; - } catch (ex) { - // Ignore failures to set to invalid font. - } - textMeasureEl.innerHTML = ''; - // Don't use innerHTML or innerText because they allow markup/whitespace. - textMeasureEl.appendChild(doc.createTextNode(text)); - return { - width: textMeasureEl.offsetWidth - }; - }; - - var tmpRect = new BoundingRect(); - - var drawRectText = function (vmlRoot, rect, textRect, fromTextEl) { - - var style = this.style; - var text = style.text; - if (!text) { - return; - } - - var x; - var y; - var align = style.textAlign; - var fontStyle = getFontStyle(style.textFont); - // FIXME encodeHtmlAttribute ? - var font = fontStyle.style + ' ' + fontStyle.variant + ' ' + fontStyle.weight + ' ' - + fontStyle.size + 'px "' + fontStyle.family + '"'; - var baseline = style.textBaseline; - - textRect = textRect || textContain.getBoundingRect(text, font, align, baseline); - - // Transform rect to view space - var m = this.transform; - // Ignore transform for text in other element - if (m && !fromTextEl) { - tmpRect.copy(rect); - tmpRect.applyTransform(m); - rect = tmpRect; - } - - if (!fromTextEl) { - var textPosition = style.textPosition; - var distance = style.textDistance; - // Text position represented by coord - if (textPosition instanceof Array) { - x = rect.x + parsePercent(textPosition[0], rect.width); - y = rect.y + parsePercent(textPosition[1], rect.height); - - align = align || 'left'; - baseline = baseline || 'top'; - } - else { - var res = textContain.adjustTextPositionOnRect( - textPosition, rect, textRect, distance - ); - x = res.x; - y = res.y; - - // Default align and baseline when has textPosition - align = align || res.textAlign; - baseline = baseline || res.textBaseline; - } - } - else { - x = rect.x; - y = rect.y; - } - - var fontSize = fontStyle.size; - // 1.75 is an arbitrary number, as there is no info about the text baseline - var lineCount = (text + '').split('\n').length; // not precise. - switch (baseline) { - case 'hanging': - case 'top': - y += (fontSize / 1.75) * lineCount; - break; - case 'middle': - break; - default: - // case null: - // case 'alphabetic': - // case 'ideographic': - // case 'bottom': - y -= fontSize / 2.25; - break; - } - switch (align) { - case 'left': - break; - case 'center': - x -= textRect.width / 2; - break; - case 'right': - x -= textRect.width; - break; - // case 'end': - // align = elementStyle.direction == 'ltr' ? 'right' : 'left'; - // break; - // case 'start': - // align = elementStyle.direction == 'rtl' ? 'right' : 'left'; - // break; - // default: - // align = 'left'; - } - - var createNode = vmlCore.createNode; - - var textVmlEl = this._textVmlEl; - var pathEl; - var textPathEl; - var skewEl; - if (!textVmlEl) { - textVmlEl = createNode('line'); - pathEl = createNode('path'); - textPathEl = createNode('textpath'); - skewEl = createNode('skew'); - - // FIXME Why here is not cammel case - // Align 'center' seems wrong - textPathEl.style['v-text-align'] = 'left'; - - initRootElStyle(textVmlEl); - - pathEl.textpathok = true; - textPathEl.on = true; - - textVmlEl.from = '0 0'; - textVmlEl.to = '1000 0.05'; - - append(textVmlEl, skewEl); - append(textVmlEl, pathEl); - append(textVmlEl, textPathEl); - - this._textVmlEl = textVmlEl; - } - else { - // 这里是在前面 appendChild 保证顺序的前提下 - skewEl = textVmlEl.firstChild; - pathEl = skewEl.nextSibling; - textPathEl = pathEl.nextSibling; - } - - var coords = [x, y]; - var textVmlElStyle = textVmlEl.style; - // Ignore transform for text in other element - if (m && fromTextEl) { - applyTransform(coords, coords, m); - - skewEl.on = true; - - skewEl.matrix = m[0].toFixed(3) + comma + m[2].toFixed(3) + comma + - m[1].toFixed(3) + comma + m[3].toFixed(3) + ',0,0'; - - // Text position - skewEl.offset = (round(coords[0]) || 0) + ',' + (round(coords[1]) || 0); - // Left top point as origin - skewEl.origin = '0 0'; - - textVmlElStyle.left = '0px'; - textVmlElStyle.top = '0px'; - } - else { - skewEl.on = false; - textVmlElStyle.left = round(x) + 'px'; - textVmlElStyle.top = round(y) + 'px'; - } - - textPathEl.string = encodeHtmlAttribute(text); - // TODO - try { - textPathEl.style.font = font; - } - // Error font format - catch (e) {} - - updateFillAndStroke(textVmlEl, 'fill', { - fill: fromTextEl ? style.fill : style.textFill, - opacity: style.opacity - }, this); - updateFillAndStroke(textVmlEl, 'stroke', { - stroke: fromTextEl ? style.stroke : style.textStroke, - opacity: style.opacity, - lineDash: style.lineDash - }, this); - - textVmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2); - - // Attached to root - append(vmlRoot, textVmlEl); - }; - - var removeRectText = function (vmlRoot) { - remove(vmlRoot, this._textVmlEl); - this._textVmlEl = null; - }; - - var appendRectText = function (vmlRoot) { - append(vmlRoot, this._textVmlEl); - }; - - var list = [RectText, Displayable, ZImage, Path, Text]; - - // In case Displayable has been mixed in RectText - for (var i = 0; i < list.length; i++) { - var proto = list[i].prototype; - proto.drawRectText = drawRectText; - proto.removeRectText = removeRectText; - proto.appendRectText = appendRectText; - } - - Text.prototype.brush = function (root) { - var style = this.style; - if (style.text) { - this.drawRectText(root, { - x: style.x || 0, y: style.y || 0, - width: 0, height: 0 - }, this.getBoundingRect(), true); - } - }; - - Text.prototype.onRemoveFromStorage = function (vmlRoot) { - this.removeRectText(vmlRoot); - }; - - Text.prototype.onAddToStorage = function (vmlRoot) { - this.appendRectText(vmlRoot); - }; -} -}); -/** - * VML Painter. - * - * @module zrender/vml/Painter - */ - -define('zrender/vml/Painter',['require','../core/log','./core'],function (require) { - - var zrLog = require('../core/log'); - var vmlCore = require('./core'); - - function parseInt10(val) { - return parseInt(val, 10); - } - - /** - * @alias module:zrender/vml/Painter - */ - function VMLPainter(root, storage) { - - vmlCore.initVML(); - - this.root = root; - - this.storage = storage; - - var vmlViewport = document.createElement('div'); - - var vmlRoot = document.createElement('div'); - - vmlViewport.style.cssText = 'display:inline-block;overflow:hidden;position:relative;width:300px;height:150px;'; - - vmlRoot.style.cssText = 'position:absolute;left:0;top:0;'; - - root.appendChild(vmlViewport); - - this._vmlRoot = vmlRoot; - this._vmlViewport = vmlViewport; - - this.resize(); - - // Modify storage - var oldDelFromMap = storage.delFromMap; - var oldAddToMap = storage.addToMap; - storage.delFromMap = function (elId) { - var el = storage.get(elId); - - oldDelFromMap.call(storage, elId); - - if (el) { - el.onRemoveFromStorage && el.onRemoveFromStorage(vmlRoot); - } - }; - - storage.addToMap = function (el) { - // Displayable already has a vml node - el.onAddToStorage && el.onAddToStorage(vmlRoot); - - oldAddToMap.call(storage, el); - }; - - this._firstPaint = true; - } - - VMLPainter.prototype = { - - constructor: VMLPainter, - - /** - * @return {HTMLDivElement} - */ - getViewportRoot: function () { - return this._vmlViewport; - }, - - /** - * 刷新 - */ - refresh: function () { - - var list = this.storage.getDisplayList(true); - - this._paintList(list); - }, - - _paintList: function (list) { - var vmlRoot = this._vmlRoot; - for (var i = 0; i < list.length; i++) { - var el = list[i]; - if (el.__dirty && !el.invisible) { - el.beforeBrush && el.beforeBrush(); - el.brush(vmlRoot); - el.afterBrush && el.afterBrush(); - } - el.__dirty = false; - } - - if (this._firstPaint) { - // Detached from document at first time - // to avoid page refreshing too many times - - // FIXME 如果每次都先 removeChild 可能会导致一些填充和描边的效果改变 - this._vmlViewport.appendChild(vmlRoot); - this._firstPaint = false; - } - }, - - resize: function () { - var width = this._getWidth(); - var height = this._getHeight(); - - if (this._width != width && this._height != height) { - this._width = width; - this._height = height; - - var vmlViewportStyle = this._vmlViewport.style; - vmlViewportStyle.width = width + 'px'; - vmlViewportStyle.height = height + 'px'; - } - }, - - dispose: function () { - this.root.innerHTML = ''; - - this._vmlRoot = - this._vmlViewport = - this.storage = null; - }, - - getWidth: function () { - return this._width; - }, - - getHeight: function () { - return this._height; - }, - - _getWidth: function () { - var root = this.root; - var stl = root.currentStyle; - - return ((root.clientWidth || parseInt10(stl.width)) - - parseInt10(stl.paddingLeft) - - parseInt10(stl.paddingRight)) | 0; - }, - - _getHeight: function () { - var root = this.root; - var stl = root.currentStyle; - - return ((root.clientHeight || parseInt10(stl.height)) - - parseInt10(stl.paddingTop) - - parseInt10(stl.paddingBottom)) | 0; - } - }; - - // Not supported methods - function createMethodNotSupport(method) { - return function () { - zrLog('In IE8.0 VML mode painter not support method "' + method + '"'); - }; - } - - var notSupportedMethods = [ - 'getLayer', 'insertLayer', 'eachLayer', 'eachBuildinLayer', 'eachOtherLayer', 'getLayers', - 'modLayer', 'delLayer', 'clearLayer', 'toDataURL', 'pathToImage' - ]; - - for (var i = 0; i < notSupportedMethods.length; i++) { - var name = notSupportedMethods[i]; - VMLPainter.prototype[name] = createMethodNotSupport(name); - } - - return VMLPainter; -}); -define('zrender/vml/vml',['require','./graphic','../zrender','./Painter'],function (require) { - require('./graphic'); - require('../zrender').registerPainter('vml', require('./Painter')); -}); -var echarts = require('echarts'); + + module.exports = __webpack_require__(290).extend({ -require("echarts/chart/line"); + type: 'dataZoom.select' -require("echarts/chart/bar"); + }); -require("echarts/component/grid"); -require("echarts/chart/pie"); -require("echarts/chart/scatter"); +/***/ }, +/* 344 */ +/***/ function(module, exports, __webpack_require__) { -require("echarts/component/tooltip"); + 'use strict'; -require("echarts/component/polar"); -require("echarts/chart/radar"); + var history = __webpack_require__(340); -require("echarts/component/legend"); + function Restore(model) { + this.model = model; + } -require("echarts/chart/map"); + Restore.defaultOption = { + show: true, + icon: 'M3.8,33.4 M47,18.9h9.8V8.7 M56.3,20.1 C52.1,9,40.5,0.6,26.8,2.1C12.6,3.7,1.6,16.2,2.1,30.6 M13,41.1H3.1v10.2 M3.7,39.9c4.2,11.1,15.8,19.5,29.5,18 c14.2-1.6,25.2-14.1,24.7-28.5', + title: '还原' + }; -require("echarts/chart/treemap"); + var proto = Restore.prototype; -require("echarts/chart/graph"); + proto.onclick = function (ecModel, api, type) { + history.clear(ecModel); -require("echarts/chart/gauge"); + api.dispatchAction({ + type: 'restore', + from: this.uid + }); + }; -require("echarts/chart/funnel"); -require("echarts/chart/parallel"); + __webpack_require__(333).register('restore', Restore); -require("echarts/chart/sankey"); -require("echarts/chart/boxplot"); + __webpack_require__(1).registerAction( + {type: 'restore', event: 'restore', update: 'prepareAndUpdate'}, + function (payload, ecModel) { + ecModel.resetOption('recreate'); + } + ); -require("echarts/chart/candlestick"); + module.exports = Restore; -require("echarts/chart/effectScatter"); -require("echarts/chart/lines"); +/***/ }, +/* 345 */ +/***/ function(module, exports, __webpack_require__) { -require("echarts/chart/heatmap"); + + __webpack_require__(346); + __webpack_require__(77).registerPainter('vml', __webpack_require__(348)); -require("echarts/component/geo"); -require("echarts/component/parallel"); +/***/ }, +/* 346 */ +/***/ function(module, exports, __webpack_require__) { -require("echarts/component/title"); + // http://www.w3.org/TR/NOTE-VML + // TODO Use proxy like svg instead of overwrite brush methods -require("echarts/component/dataZoom"); -require("echarts/component/visualMap"); + if (!__webpack_require__(78).canvasSupported) { + var vec2 = __webpack_require__(16); + var BoundingRect = __webpack_require__(15); + var CMD = __webpack_require__(48).CMD; + var colorTool = __webpack_require__(38); + var textContain = __webpack_require__(14); + var RectText = __webpack_require__(47); + var Displayable = __webpack_require__(45); + var ZImage = __webpack_require__(59); + var Text = __webpack_require__(62); + var Path = __webpack_require__(44); -require("echarts/component/markPoint"); + var Gradient = __webpack_require__(4); -require("echarts/component/markLine"); + var vmlCore = __webpack_require__(347); -require("echarts/component/timeline"); + var round = Math.round; + var sqrt = Math.sqrt; + var abs = Math.abs; + var cos = Math.cos; + var sin = Math.sin; + var mathMax = Math.max; + + var applyTransform = vec2.applyTransform; + + var comma = ','; + var imageTransformPrefix = 'progid:DXImageTransform.Microsoft'; + + var Z = 21600; + var Z2 = Z / 2; + + var ZLEVEL_BASE = 100000; + var Z_BASE = 1000; + + var initRootElStyle = function (el) { + el.style.cssText = 'position:absolute;left:0;top:0;width:1px;height:1px;'; + el.coordsize = Z + ',' + Z; + el.coordorigin = '0,0'; + }; + + var encodeHtmlAttribute = function (s) { + return String(s).replace(/&/g, '&').replace(/"/g, '"'); + }; + + var rgb2Str = function (r, g, b) { + return 'rgb(' + [r, g, b].join(',') + ')'; + }; + + var append = function (parent, child) { + if (child && parent && child.parentNode !== parent) { + parent.appendChild(child); + } + }; + + var remove = function (parent, child) { + if (child && parent && child.parentNode === parent) { + parent.removeChild(child); + } + }; + + var getZIndex = function (zlevel, z, z2) { + // z 的取值范围为 [0, 1000] + return (parseFloat(zlevel) || 0) * ZLEVEL_BASE + (parseFloat(z) || 0) * Z_BASE + z2; + }; + + var parsePercent = function (value, maxValue) { + if (typeof value === 'string') { + if (value.lastIndexOf('%') >= 0) { + return parseFloat(value) / 100 * maxValue; + } + return parseFloat(value); + } + return value; + }; + + /*************************************************** + * PATH + **************************************************/ + + var setColorAndOpacity = function (el, color, opacity) { + var colorArr = colorTool.parse(color); + opacity = +opacity; + if (isNaN(opacity)) { + opacity = 1; + } + if (colorArr) { + el.color = rgb2Str(colorArr[0], colorArr[1], colorArr[2]); + el.opacity = opacity * colorArr[3]; + } + }; + + var getColorAndAlpha = function (color) { + var colorArr = colorTool.parse(color); + return [ + rgb2Str(colorArr[0], colorArr[1], colorArr[2]), + colorArr[3] + ]; + }; + + var updateFillNode = function (el, style, zrEl) { + // TODO pattern + var fill = style.fill; + if (fill != null) { + // Modified from excanvas + if (fill instanceof Gradient) { + var gradientType; + var angle = 0; + var focus = [0, 0]; + // additional offset + var shift = 0; + // scale factor for offset + var expansion = 1; + var rect = zrEl.getBoundingRect(); + var rectWidth = rect.width; + var rectHeight = rect.height; + if (fill.type === 'linear') { + gradientType = 'gradient'; + var transform = zrEl.transform; + var p0 = [fill.x * rectWidth, fill.y * rectHeight]; + var p1 = [fill.x2 * rectWidth, fill.y2 * rectHeight]; + if (transform) { + applyTransform(p0, p0, transform); + applyTransform(p1, p1, transform); + } + var dx = p1[0] - p0[0]; + var dy = p1[1] - p0[1]; + angle = Math.atan2(dx, dy) * 180 / Math.PI; + // The angle should be a non-negative number. + if (angle < 0) { + angle += 360; + } + + // Very small angles produce an unexpected result because they are + // converted to a scientific notation string. + if (angle < 1e-6) { + angle = 0; + } + } + else { + gradientType = 'gradientradial'; + var p0 = [fill.x * rectWidth, fill.y * rectHeight]; + var transform = zrEl.transform; + var scale = zrEl.scale; + var width = rectWidth; + var height = rectHeight; + focus = [ + // Percent in bounding rect + (p0[0] - rect.x) / width, + (p0[1] - rect.y) / height + ]; + if (transform) { + applyTransform(p0, p0, transform); + } + + width /= scale[0] * Z; + height /= scale[1] * Z; + var dimension = mathMax(width, height); + shift = 2 * 0 / dimension; + expansion = 2 * fill.r / dimension - shift; + } + + // We need to sort the color stops in ascending order by offset, + // otherwise IE won't interpret it correctly. + var stops = fill.colorStops.slice(); + stops.sort(function(cs1, cs2) { + return cs1.offset - cs2.offset; + }); + + var length = stops.length; + // Color and alpha list of first and last stop + var colorAndAlphaList = []; + var colors = []; + for (var i = 0; i < length; i++) { + var stop = stops[i]; + var colorAndAlpha = getColorAndAlpha(stop.color); + colors.push(stop.offset * expansion + shift + ' ' + colorAndAlpha[0]); + if (i === 0 || i === length - 1) { + colorAndAlphaList.push(colorAndAlpha); + } + } + + if (length >= 2) { + var color1 = colorAndAlphaList[0][0]; + var color2 = colorAndAlphaList[1][0]; + var opacity1 = colorAndAlphaList[0][1] * style.opacity; + var opacity2 = colorAndAlphaList[1][1] * style.opacity; + + el.type = gradientType; + el.method = 'none'; + el.focus = '100%'; + el.angle = angle; + el.color = color1; + el.color2 = color2; + el.colors = colors.join(','); + // When colors attribute is used, the meanings of opacity and o:opacity2 + // are reversed. + el.opacity = opacity2; + // FIXME g_o_:opacity ? + el.opacity2 = opacity1; + } + if (gradientType === 'radial') { + el.focusposition = focus.join(','); + } + } + else { + // FIXME Change from Gradient fill to color fill + setColorAndOpacity(el, fill, style.opacity); + } + } + }; + + var updateStrokeNode = function (el, style) { + if (style.lineJoin != null) { + el.joinstyle = style.lineJoin; + } + if (style.miterLimit != null) { + el.miterlimit = style.miterLimit * Z; + } + if (style.lineCap != null) { + el.endcap = style.lineCap; + } + if (style.lineDash != null) { + el.dashstyle = style.lineDash.join(' '); + } + if (style.stroke != null && !(style.stroke instanceof Gradient)) { + setColorAndOpacity(el, style.stroke, style.opacity); + } + }; + + var updateFillAndStroke = function (vmlEl, type, style, zrEl) { + var isFill = type == 'fill'; + var el = vmlEl.getElementsByTagName(type)[0]; + // Stroke must have lineWidth + if (style[type] != null && style[type] !== 'none' && (isFill || (!isFill && style.lineWidth))) { + vmlEl[isFill ? 'filled' : 'stroked'] = 'true'; + // FIXME Remove before updating, or set `colors` will throw error + if (style[type] instanceof Gradient) { + remove(vmlEl, el); + } + if (!el) { + el = vmlCore.createNode(type); + } + + isFill ? updateFillNode(el, style, zrEl) : updateStrokeNode(el, style); + append(vmlEl, el); + } + else { + vmlEl[isFill ? 'filled' : 'stroked'] = 'false'; + remove(vmlEl, el); + } + }; + + var points = [[], [], []]; + var pathDataToString = function (data, m) { + var M = CMD.M; + var C = CMD.C; + var L = CMD.L; + var A = CMD.A; + var Q = CMD.Q; + + var str = []; + var nPoint; + var cmdStr; + var cmd; + var i; + var xi; + var yi; + for (i = 0; i < data.length;) { + cmd = data[i++]; + cmdStr = ''; + nPoint = 0; + switch (cmd) { + case M: + cmdStr = ' m '; + nPoint = 1; + xi = data[i++]; + yi = data[i++]; + points[0][0] = xi; + points[0][1] = yi; + break; + case L: + cmdStr = ' l '; + nPoint = 1; + xi = data[i++]; + yi = data[i++]; + points[0][0] = xi; + points[0][1] = yi; + break; + case Q: + case C: + cmdStr = ' c '; + nPoint = 3; + var x1 = data[i++]; + var y1 = data[i++]; + var x2 = data[i++]; + var y2 = data[i++]; + var x3; + var y3; + if (cmd === Q) { + // Convert quadratic to cubic using degree elevation + x3 = x2; + y3 = y2; + x2 = (x2 + 2 * x1) / 3; + y2 = (y2 + 2 * y1) / 3; + x1 = (xi + 2 * x1) / 3; + y1 = (yi + 2 * y1) / 3; + } + else { + x3 = data[i++]; + y3 = data[i++]; + } + points[0][0] = x1; + points[0][1] = y1; + points[1][0] = x2; + points[1][1] = y2; + points[2][0] = x3; + points[2][1] = y3; + + xi = x3; + yi = y3; + break; + case A: + var x = 0; + var y = 0; + var sx = 1; + var sy = 1; + var angle = 0; + if (m) { + // Extract SRT from matrix + x = m[4]; + y = m[5]; + sx = sqrt(m[0] * m[0] + m[1] * m[1]); + sy = sqrt(m[2] * m[2] + m[3] * m[3]); + angle = Math.atan2(-m[1] / sy, m[0] / sx); + } + + var cx = data[i++]; + var cy = data[i++]; + var rx = data[i++]; + var ry = data[i++]; + var startAngle = data[i++] + angle; + var endAngle = data[i++] + startAngle + angle; + // FIXME + // var psi = data[i++]; + i++; + var clockwise = data[i++]; + + var x0 = cx + cos(startAngle) * rx; + var y0 = cy + sin(startAngle) * ry; + + var x1 = cx + cos(endAngle) * rx; + var y1 = cy + sin(endAngle) * ry; + + var type = clockwise ? ' wa ' : ' at '; + + str.push( + type, + round(((cx - rx) * sx + x) * Z - Z2), comma, + round(((cy - ry) * sy + y) * Z - Z2), comma, + round(((cx + rx) * sx + x) * Z - Z2), comma, + round(((cy + ry) * sy + y) * Z - Z2), comma, + round((x0 * sx + x) * Z - Z2), comma, + round((y0 * sy + y) * Z - Z2), comma, + round((x1 * sx + x) * Z - Z2), comma, + round((y1 * sy + y) * Z - Z2) + ); + + xi = x1; + yi = y1; + break; + case CMD.R: + var p0 = points[0]; + var p1 = points[1]; + // x0, y0 + p0[0] = data[i++]; + p0[1] = data[i++]; + // x1, y1 + p1[0] = p0[0] + data[i++]; + p1[1] = p0[1] + data[i++]; + + if (m) { + applyTransform(p0, p0, m); + applyTransform(p1, p1, m); + } + + p0[0] = round(p0[0] * Z - Z2); + p1[0] = round(p1[0] * Z - Z2); + p0[1] = round(p0[1] * Z - Z2); + p1[1] = round(p1[1] * Z - Z2); + str.push( + // x0, y0 + ' m ', p0[0], comma, p0[1], + // x1, y0 + ' l ', p1[0], comma, p0[1], + // x1, y1 + ' l ', p1[0], comma, p1[1], + // x0, y1 + ' l ', p0[0], comma, p1[1] + ); + break; + case CMD.Z: + // FIXME Update xi, yi + str.push(' x '); + } + + if (nPoint > 0) { + str.push(cmdStr); + for (var k = 0; k < nPoint; k++) { + var p = points[k]; + + m && applyTransform(p, p, m); + // 不 round 会非常慢 + str.push( + round(p[0] * Z - Z2), comma, round(p[1] * Z - Z2), + k < nPoint - 1 ? comma : '' + ); + } + } + } + return str.join(''); + }; + + // Rewrite the original path method + Path.prototype.brush = function (vmlRoot) { + var style = this.style; + + var vmlEl = this._vmlEl; + if (!vmlEl) { + vmlEl = vmlCore.createNode('shape'); + initRootElStyle(vmlEl); + + this._vmlEl = vmlEl; + } + + updateFillAndStroke(vmlEl, 'fill', style, this); + updateFillAndStroke(vmlEl, 'stroke', style, this); + + var m = this.transform; + var needTransform = m != null; + var strokeEl = vmlEl.getElementsByTagName('stroke')[0]; + if (strokeEl) { + var lineWidth = style.lineWidth; + // Get the line scale. + // Determinant of this.m_ means how much the area is enlarged by the + // transformation. So its square root can be used as a scale factor + // for width. + if (needTransform && !style.strokeNoScale) { + var det = m[0] * m[3] - m[1] * m[2]; + lineWidth *= sqrt(abs(det)); + } + strokeEl.weight = lineWidth + 'px'; + } + + var path = this.path; + if (this.__dirtyPath) { + path.beginPath(); + this.buildPath(path, this.shape); + this.__dirtyPath = false; + } + + vmlEl.path = pathDataToString(path.data, this.transform); + + vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2); + + // Append to root + append(vmlRoot, vmlEl); + + // Text + if (style.text) { + this.drawRectText(vmlRoot, this.getBoundingRect()); + } + }; + + Path.prototype.onRemoveFromStorage = function (vmlRoot) { + remove(vmlRoot, this._vmlEl); + this.removeRectText(vmlRoot); + }; + + Path.prototype.onAddToStorage = function (vmlRoot) { + append(vmlRoot, this._vmlEl); + this.appendRectText(vmlRoot); + }; + + /*************************************************** + * IMAGE + **************************************************/ + var isImage = function (img) { + // FIXME img instanceof Image 如果 img 是一个字符串的时候,IE8 下会报错 + return (typeof img === 'object') && img.tagName && img.tagName.toUpperCase() === 'IMG'; + // return img instanceof Image; + }; + + // Rewrite the original path method + ZImage.prototype.brush = function (vmlRoot) { + var style = this.style; + var image = style.image; + + // Image original width, height + var ow; + var oh; + + if (isImage(image)) { + var src = image.src; + if (src === this._imageSrc) { + ow = this._imageWidth; + oh = this._imageHeight; + } + else { + var imageRuntimeStyle = image.runtimeStyle; + var oldRuntimeWidth = imageRuntimeStyle.width; + var oldRuntimeHeight = imageRuntimeStyle.height; + imageRuntimeStyle.width = 'auto'; + imageRuntimeStyle.height = 'auto'; + + // get the original size + ow = image.width; + oh = image.height; + + // and remove overides + imageRuntimeStyle.width = oldRuntimeWidth; + imageRuntimeStyle.height = oldRuntimeHeight; + + // Caching image original width, height and src + this._imageSrc = src; + this._imageWidth = ow; + this._imageHeight = oh; + } + image = src; + } + else { + if (image === this._imageSrc) { + ow = this._imageWidth; + oh = this._imageHeight; + } + } + if (!image) { + return; + } + + var x = style.x || 0; + var y = style.y || 0; + + var dw = style.width; + var dh = style.height; + + var sw = style.sWidth; + var sh = style.sHeight; + var sx = style.sx || 0; + var sy = style.sy || 0; + + var hasCrop = sw && sh; + + var vmlEl = this._vmlEl; + if (!vmlEl) { + // FIXME 使用 group 在 left, top 都不是 0 的时候就无法显示了。 + // vmlEl = vmlCore.createNode('group'); + vmlEl = vmlCore.doc.createElement('div'); + initRootElStyle(vmlEl); + + this._vmlEl = vmlEl; + } + + var vmlElStyle = vmlEl.style; + var hasRotation = false; + var m; + var scaleX = 1; + var scaleY = 1; + if (this.transform) { + m = this.transform; + scaleX = sqrt(m[0] * m[0] + m[1] * m[1]); + scaleY = sqrt(m[2] * m[2] + m[3] * m[3]); + + hasRotation = m[1] || m[2]; + } + if (hasRotation) { + // If filters are necessary (rotation exists), create them + // filters are bog-slow, so only create them if abbsolutely necessary + // The following check doesn't account for skews (which don't exist + // in the canvas spec (yet) anyway. + // From excanvas + var p0 = [x, y]; + var p1 = [x + dw, y]; + var p2 = [x, y + dh]; + var p3 = [x + dw, y + dh]; + applyTransform(p0, p0, m); + applyTransform(p1, p1, m); + applyTransform(p2, p2, m); + applyTransform(p3, p3, m); + + var maxX = mathMax(p0[0], p1[0], p2[0], p3[0]); + var maxY = mathMax(p0[1], p1[1], p2[1], p3[1]); + + var transformFilter = []; + transformFilter.push('M11=', m[0] / scaleX, comma, + 'M12=', m[2] / scaleY, comma, + 'M21=', m[1] / scaleX, comma, + 'M22=', m[3] / scaleY, comma, + 'Dx=', round(x * scaleX + m[4]), comma, + 'Dy=', round(y * scaleY + m[5])); + + vmlElStyle.padding = '0 ' + round(maxX) + 'px ' + round(maxY) + 'px 0'; + // FIXME DXImageTransform 在 IE11 的兼容模式下不起作用 + vmlElStyle.filter = imageTransformPrefix + '.Matrix(' + + transformFilter.join('') + ', SizingMethod=clip)'; + + } + else { + if (m) { + x = x * scaleX + m[4]; + y = y * scaleY + m[5]; + } + vmlElStyle.filter = ''; + vmlElStyle.left = round(x) + 'px'; + vmlElStyle.top = round(y) + 'px'; + } + + var imageEl = this._imageEl; + var cropEl = this._cropEl; + + if (! imageEl) { + imageEl = vmlCore.doc.createElement('div'); + this._imageEl = imageEl; + } + var imageELStyle = imageEl.style; + if (hasCrop) { + // Needs know image original width and height + if (! (ow && oh)) { + var tmpImage = new Image(); + var self = this; + tmpImage.onload = function () { + tmpImage.onload = null; + ow = tmpImage.width; + oh = tmpImage.height; + // Adjust image width and height to fit the ratio destinationSize / sourceSize + imageELStyle.width = round(scaleX * ow * dw / sw) + 'px'; + imageELStyle.height = round(scaleY * oh * dh / sh) + 'px'; + + // Caching image original width, height and src + self._imageWidth = ow; + self._imageHeight = oh; + self._imageSrc = image; + }; + tmpImage.src = image; + } + else { + imageELStyle.width = round(scaleX * ow * dw / sw) + 'px'; + imageELStyle.height = round(scaleY * oh * dh / sh) + 'px'; + } + + if (! cropEl) { + cropEl = vmlCore.doc.createElement('div'); + cropEl.style.overflow = 'hidden'; + this._cropEl = cropEl; + } + var cropElStyle = cropEl.style; + cropElStyle.width = round((dw + sx * dw / sw) * scaleX); + cropElStyle.height = round((dh + sy * dh / sh) * scaleY); + cropElStyle.filter = imageTransformPrefix + '.Matrix(Dx=' + + (-sx * dw / sw * scaleX) + ',Dy=' + (-sy * dh / sh * scaleY) + ')'; + + if (! cropEl.parentNode) { + vmlEl.appendChild(cropEl); + } + if (imageEl.parentNode != cropEl) { + cropEl.appendChild(imageEl); + } + } + else { + imageELStyle.width = round(scaleX * dw) + 'px'; + imageELStyle.height = round(scaleY * dh) + 'px'; + + vmlEl.appendChild(imageEl); + + if (cropEl && cropEl.parentNode) { + vmlEl.removeChild(cropEl); + this._cropEl = null; + } + } + + var filterStr = ''; + var alpha = style.opacity; + if (alpha < 1) { + filterStr += '.Alpha(opacity=' + round(alpha * 100) + ') '; + } + filterStr += imageTransformPrefix + '.AlphaImageLoader(src=' + image + ', SizingMethod=scale)'; + + imageELStyle.filter = filterStr; + + vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2); + + // Append to root + append(vmlRoot, vmlEl); + + // Text + if (style.text) { + this.drawRectText(vmlRoot, this.getBoundingRect()); + } + }; + + ZImage.prototype.onRemoveFromStorage = function (vmlRoot) { + remove(vmlRoot, this._vmlEl); + + this._vmlEl = null; + this._cropEl = null; + this._imageEl = null; + + this.removeRectText(vmlRoot); + }; + + ZImage.prototype.onAddToStorage = function (vmlRoot) { + append(vmlRoot, this._vmlEl); + this.appendRectText(vmlRoot); + }; + + + /*************************************************** + * TEXT + **************************************************/ + + var DEFAULT_STYLE_NORMAL = 'normal'; + + var fontStyleCache = {}; + var fontStyleCacheCount = 0; + var MAX_FONT_CACHE_SIZE = 100; + var fontEl = document.createElement('div'); + + var getFontStyle = function (fontString) { + var fontStyle = fontStyleCache[fontString]; + if (!fontStyle) { + // Clear cache + if (fontStyleCacheCount > MAX_FONT_CACHE_SIZE) { + fontStyleCacheCount = 0; + fontStyleCache = {}; + } + + var style = fontEl.style; + var fontFamily; + try { + style.font = fontString; + fontFamily = style.fontFamily.split(',')[0]; + } + catch (e) { + } + + fontStyle = { + style: style.fontStyle || DEFAULT_STYLE_NORMAL, + variant: style.fontVariant || DEFAULT_STYLE_NORMAL, + weight: style.fontWeight || DEFAULT_STYLE_NORMAL, + size: parseFloat(style.fontSize || 12) | 0, + family: fontFamily || 'Microsoft YaHei' + }; + + fontStyleCache[fontString] = fontStyle; + fontStyleCacheCount++; + } + return fontStyle; + }; + + var textMeasureEl; + // Overwrite measure text method + textContain.measureText = function (text, textFont) { + var doc = vmlCore.doc; + if (!textMeasureEl) { + textMeasureEl = doc.createElement('div'); + textMeasureEl.style.cssText = 'position:absolute;top:-20000px;left:0;' + + 'padding:0;margin:0;border:none;white-space:pre;'; + vmlCore.doc.body.appendChild(textMeasureEl); + } + + try { + textMeasureEl.style.font = textFont; + } catch (ex) { + // Ignore failures to set to invalid font. + } + textMeasureEl.innerHTML = ''; + // Don't use innerHTML or innerText because they allow markup/whitespace. + textMeasureEl.appendChild(doc.createTextNode(text)); + return { + width: textMeasureEl.offsetWidth + }; + }; + + var tmpRect = new BoundingRect(); + + var drawRectText = function (vmlRoot, rect, textRect, fromTextEl) { + + var style = this.style; + var text = style.text; + if (!text) { + return; + } + + var x; + var y; + var align = style.textAlign; + var fontStyle = getFontStyle(style.textFont); + // FIXME encodeHtmlAttribute ? + var font = fontStyle.style + ' ' + fontStyle.variant + ' ' + fontStyle.weight + ' ' + + fontStyle.size + 'px "' + fontStyle.family + '"'; + var baseline = style.textBaseline; + var verticalAlign = style.textVerticalAlign; + + textRect = textRect || textContain.getBoundingRect(text, font, align, baseline); + + // Transform rect to view space + var m = this.transform; + // Ignore transform for text in other element + if (m && !fromTextEl) { + tmpRect.copy(rect); + tmpRect.applyTransform(m); + rect = tmpRect; + } + + if (!fromTextEl) { + var textPosition = style.textPosition; + var distance = style.textDistance; + // Text position represented by coord + if (textPosition instanceof Array) { + x = rect.x + parsePercent(textPosition[0], rect.width); + y = rect.y + parsePercent(textPosition[1], rect.height); + + align = align || 'left'; + baseline = baseline || 'top'; + } + else { + var res = textContain.adjustTextPositionOnRect( + textPosition, rect, textRect, distance + ); + x = res.x; + y = res.y; + + // Default align and baseline when has textPosition + align = align || res.textAlign; + baseline = baseline || res.textBaseline; + } + } + else { + x = rect.x; + y = rect.y; + } + if (verticalAlign) { + switch (verticalAlign) { + case 'middle': + y -= textRect.height / 2; + break; + case 'bottom': + y -= textRect.height; + break; + // 'top' + } + // Ignore baseline + baseline = 'top'; + } + + var fontSize = fontStyle.size; + // 1.75 is an arbitrary number, as there is no info about the text baseline + switch (baseline) { + case 'hanging': + case 'top': + y += fontSize / 1.75; + break; + case 'middle': + break; + default: + // case null: + // case 'alphabetic': + // case 'ideographic': + // case 'bottom': + y -= fontSize / 2.25; + break; + } + switch (align) { + case 'left': + break; + case 'center': + x -= textRect.width / 2; + break; + case 'right': + x -= textRect.width; + break; + // case 'end': + // align = elementStyle.direction == 'ltr' ? 'right' : 'left'; + // break; + // case 'start': + // align = elementStyle.direction == 'rtl' ? 'right' : 'left'; + // break; + // default: + // align = 'left'; + } + + var createNode = vmlCore.createNode; + + var textVmlEl = this._textVmlEl; + var pathEl; + var textPathEl; + var skewEl; + if (!textVmlEl) { + textVmlEl = createNode('line'); + pathEl = createNode('path'); + textPathEl = createNode('textpath'); + skewEl = createNode('skew'); + + // FIXME Why here is not cammel case + // Align 'center' seems wrong + textPathEl.style['v-text-align'] = 'left'; + + initRootElStyle(textVmlEl); + + pathEl.textpathok = true; + textPathEl.on = true; + + textVmlEl.from = '0 0'; + textVmlEl.to = '1000 0.05'; + + append(textVmlEl, skewEl); + append(textVmlEl, pathEl); + append(textVmlEl, textPathEl); + + this._textVmlEl = textVmlEl; + } + else { + // 这里是在前面 appendChild 保证顺序的前提下 + skewEl = textVmlEl.firstChild; + pathEl = skewEl.nextSibling; + textPathEl = pathEl.nextSibling; + } + + var coords = [x, y]; + var textVmlElStyle = textVmlEl.style; + // Ignore transform for text in other element + if (m && fromTextEl) { + applyTransform(coords, coords, m); + + skewEl.on = true; + + skewEl.matrix = m[0].toFixed(3) + comma + m[2].toFixed(3) + comma + + m[1].toFixed(3) + comma + m[3].toFixed(3) + ',0,0'; + + // Text position + skewEl.offset = (round(coords[0]) || 0) + ',' + (round(coords[1]) || 0); + // Left top point as origin + skewEl.origin = '0 0'; + + textVmlElStyle.left = '0px'; + textVmlElStyle.top = '0px'; + } + else { + skewEl.on = false; + textVmlElStyle.left = round(x) + 'px'; + textVmlElStyle.top = round(y) + 'px'; + } + + textPathEl.string = encodeHtmlAttribute(text); + // TODO + try { + textPathEl.style.font = font; + } + // Error font format + catch (e) {} + + updateFillAndStroke(textVmlEl, 'fill', { + fill: fromTextEl ? style.fill : style.textFill, + opacity: style.opacity + }, this); + updateFillAndStroke(textVmlEl, 'stroke', { + stroke: fromTextEl ? style.stroke : style.textStroke, + opacity: style.opacity, + lineDash: style.lineDash + }, this); + + textVmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2); + + // Attached to root + append(vmlRoot, textVmlEl); + }; + + var removeRectText = function (vmlRoot) { + remove(vmlRoot, this._textVmlEl); + this._textVmlEl = null; + }; + + var appendRectText = function (vmlRoot) { + append(vmlRoot, this._textVmlEl); + }; + + var list = [RectText, Displayable, ZImage, Path, Text]; + + // In case Displayable has been mixed in RectText + for (var i = 0; i < list.length; i++) { + var proto = list[i].prototype; + proto.drawRectText = drawRectText; + proto.removeRectText = removeRectText; + proto.appendRectText = appendRectText; + } + + Text.prototype.brush = function (root) { + var style = this.style; + if (style.text) { + this.drawRectText(root, { + x: style.x || 0, y: style.y || 0, + width: 0, height: 0 + }, this.getBoundingRect(), true); + } + }; + + Text.prototype.onRemoveFromStorage = function (vmlRoot) { + this.removeRectText(vmlRoot); + }; + + Text.prototype.onAddToStorage = function (vmlRoot) { + this.appendRectText(vmlRoot); + }; + } + + +/***/ }, +/* 347 */ +/***/ function(module, exports, __webpack_require__) { + + + + if (!__webpack_require__(78).canvasSupported) { + var urn = 'urn:schemas-microsoft-com:vml'; + + var createNode; + var win = window; + var doc = win.document; + + var vmlInited = false; + + try { + !doc.namespaces.zrvml && doc.namespaces.add('zrvml', urn); + createNode = function (tagName) { + return doc.createElement(''); + }; + } + catch (e) { + createNode = function (tagName) { + return doc.createElement('<' + tagName + ' xmlns="' + urn + '" class="zrvml">'); + }; + } + + // From raphael + var initVML = function () { + if (vmlInited) { + return; + } + vmlInited = true; + + var styleSheets = doc.styleSheets; + if (styleSheets.length < 31) { + doc.createStyleSheet().addRule('.zrvml', 'behavior:url(#default#VML)'); + } + else { + // http://msdn.microsoft.com/en-us/library/ms531194%28VS.85%29.aspx + styleSheets[0].addRule('.zrvml', 'behavior:url(#default#VML)'); + } + }; -require("echarts/component/toolbox"); + // Not useing return to avoid error when converting to CommonJS module + module.exports = { + doc: doc, + initVML: initVML, + createNode: createNode + }; + } -require("zrender/vml/vml"); +/***/ }, +/* 348 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * VML Painter. + * + * @module zrender/vml/Painter + */ + + + + var zrLog = __webpack_require__(39); + var vmlCore = __webpack_require__(347); + + function parseInt10(val) { + return parseInt(val, 10); + } + + /** + * @alias module:zrender/vml/Painter + */ + function VMLPainter(root, storage) { + + vmlCore.initVML(); + + this.root = root; + + this.storage = storage; + + var vmlViewport = document.createElement('div'); + + var vmlRoot = document.createElement('div'); + + vmlViewport.style.cssText = 'display:inline-block;overflow:hidden;position:relative;width:300px;height:150px;'; + + vmlRoot.style.cssText = 'position:absolute;left:0;top:0;'; + + root.appendChild(vmlViewport); + + this._vmlRoot = vmlRoot; + this._vmlViewport = vmlViewport; + + this.resize(); + + // Modify storage + var oldDelFromMap = storage.delFromMap; + var oldAddToMap = storage.addToMap; + storage.delFromMap = function (elId) { + var el = storage.get(elId); + + oldDelFromMap.call(storage, elId); + + if (el) { + el.onRemoveFromStorage && el.onRemoveFromStorage(vmlRoot); + } + }; + + storage.addToMap = function (el) { + // Displayable already has a vml node + el.onAddToStorage && el.onAddToStorage(vmlRoot); + + oldAddToMap.call(storage, el); + }; + + this._firstPaint = true; + } + + VMLPainter.prototype = { + + constructor: VMLPainter, + + /** + * @return {HTMLDivElement} + */ + getViewportRoot: function () { + return this._vmlViewport; + }, + + /** + * 刷新 + */ + refresh: function () { + + var list = this.storage.getDisplayList(true, true); + + this._paintList(list); + }, + + _paintList: function (list) { + var vmlRoot = this._vmlRoot; + for (var i = 0; i < list.length; i++) { + var el = list[i]; + if (el.invisible || el.ignore) { + if (!el.__alreadyNotVisible) { + el.onRemoveFromStorage(vmlRoot); + } + // Set as already invisible + el.__alreadyNotVisible = true; + } + else { + if (el.__alreadyNotVisible) { + el.onAddToStorage(vmlRoot); + } + el.__alreadyNotVisible = false; + if (el.__dirty) { + el.beforeBrush && el.beforeBrush(); + el.brush(vmlRoot); + el.afterBrush && el.afterBrush(); + } + } + el.__dirty = false; + } + + if (this._firstPaint) { + // Detached from document at first time + // to avoid page refreshing too many times + + // FIXME 如果每次都先 removeChild 可能会导致一些填充和描边的效果改变 + this._vmlViewport.appendChild(vmlRoot); + this._firstPaint = false; + } + }, -return echarts; -})); + resize: function () { + var width = this._getWidth(); + var height = this._getHeight(); + + if (this._width != width && this._height != height) { + this._width = width; + this._height = height; + + var vmlViewportStyle = this._vmlViewport.style; + vmlViewportStyle.width = width + 'px'; + vmlViewportStyle.height = height + 'px'; + } + }, + + dispose: function () { + this.root.innerHTML = ''; + + this._vmlRoot = + this._vmlViewport = + this.storage = null; + }, + + getWidth: function () { + return this._width; + }, + + getHeight: function () { + return this._height; + }, + + _getWidth: function () { + var root = this.root; + var stl = root.currentStyle; + + return ((root.clientWidth || parseInt10(stl.width)) + - parseInt10(stl.paddingLeft) + - parseInt10(stl.paddingRight)) | 0; + }, + + _getHeight: function () { + var root = this.root; + var stl = root.currentStyle; + + return ((root.clientHeight || parseInt10(stl.height)) + - parseInt10(stl.paddingTop) + - parseInt10(stl.paddingBottom)) | 0; + } + }; + + // Not supported methods + function createMethodNotSupport(method) { + return function () { + zrLog('In IE8.0 VML mode painter not support method "' + method + '"'); + }; + } + + var notSupportedMethods = [ + 'getLayer', 'insertLayer', 'eachLayer', 'eachBuildinLayer', 'eachOtherLayer', 'getLayers', + 'modLayer', 'delLayer', 'clearLayer', 'toDataURL', 'pathToImage' + ]; + + for (var i = 0; i < notSupportedMethods.length; i++) { + var name = notSupportedMethods[i]; + VMLPainter.prototype[name] = createMethodNotSupport(name); + } + + module.exports = VMLPainter; + + +/***/ } +/******/ ]) +}); +; \ No newline at end of file diff --git a/dist/echarts.min.js b/dist/echarts.min.js index d98e6d7a0e..fb0dc937c5 100644 --- a/dist/echarts.min.js +++ b/dist/echarts.min.js @@ -1,14 +1,32 @@ -!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():t.echarts=e()}(this,function(){var t,e;!function(){function i(t,e){if(!e)return t;if(0===t.indexOf(".")){var i=e.split("/"),n=t.split("/"),r=i.length-1,a=n.length,o=0,s=0;t:for(var l=0;a>l;l++)switch(n[l]){case"..":if(!(r>o))break t;o++,s++;break;case".":s++;break;default:break t}return i.length=r-o,n=n.slice(s),i.concat(n).join("/")}return t}function n(t){function e(e,o){if("string"==typeof e){var s=n[e];return s||(s=a(i(e,t)),n[e]=s),s}e instanceof Array&&(o=o||function(){},o.apply(this,r(e,o,t)))}var n={};return e}function r(e,n,r){for(var s=[],l=o[r],u=0,c=Math.min(e.length,n.length);c>u;u++){var h,d=i(e[u],r);switch(d){case"require":h=l&&l.require||t;break;case"exports":h=l.exports;break;case"module":h=l;break;default:h=a(d)}s.push(h)}return s}function a(t){var e=o[t];if(!e)throw new Error("No "+t);if(!e.defined){var i=e.factory,n=i.apply(this,r(e.deps||[],i,t));"undefined"!=typeof n&&(e.exports=n),e.defined=1}return e.exports}var o={};e=function(t,e,i){if(2===arguments.length&&(i=e,e=[],"function"!=typeof i)){var r=i;i=function(){return r}}o[t]={id:t,deps:e,factory:i,defined:0,exports:{},require:n(t)}},t=n("")}();var i="textStyleModel",n="../../visual/VisualMapping",r="categories",a="reverse",o="eachNode",s="_controller",l="enable",u="roamDetail",c="layout",h="itemGap",d="formatTooltip",f="orient",p="padding",v="../../util/format",m="legendDataProvider",g="selected",y="single",x="selectedMode",_="axisLine",w="axisTick",b="label.emphasis",M="label.normal",S="itemStyle.emphasis",A="itemStyle.normal",C="../../echarts",T="../../model/Model",k="coordDimToDataDim",L="getBoxLayoutParams",I="getRect",D="../../coord/axisHelper",P="../../util/layout",z="../../model/Component",R="axisLabel",V="coordToData",O="dataToCoord",E="getFormattedLabels",N="createScaleByModel",B="interval",G="splitNumber",Z="boundaryGap",F="niceScaleExtent",H="getLabel",W="getTicks",q="setExtent",U="unionExtent",j="../layout/points",X="../visual/symbol",Y="../echarts",K="cartesian2d",J="getLineStyle",Q="lineStyle.normal",$="_symbolDraw",tt="inverse",et="getAxis",it="getBandWidth",nt="onBand",rt="../../view/Chart",at="../helper/SymbolDraw",ot="dataToPoint",st="getExtent",lt="getOtherAxis",ut="execute",ct="getFormattedLabel",ht="getItemStyle",dt="circle",ft="symbol",pt="symbolSize",vt="createSymbol",mt="updateData",gt="../../util/number",yt="../../util/graphic",xt="../../util/symbol",_t="setColor",wt="../../model/Series",bt="../helper/createListFromArray",Mt="getCategories",St="category",At="../../CoordinateSystem",Ct="../../util/model",Tt="../../data/helper/completeDimensions",kt="../../data/List",Lt="setItemGraphicEl",It="getItemVisual",Dt="setItemLayout",Pt="getItemLayout",zt="getLayout",Rt="setLayout",Vt="getVisual",Ot="mapArray",Et="filterSelf",Nt="getSum",Bt="getDataExtent",Gt="getValues",Zt="initData",Ft="getDimension",Ht="dimensions",Wt="extendComponentView",qt="extendSeriesModel",Ut="extendComponentModel",jt="extendChartView",Xt="registerVisualCoding",Yt="registerLayout",Kt="registerAction",Jt="registerProcessor",Qt="registerPreprocessor",$t="hostModel",te="downplay",ee="highlight",ie="eachComponent",ne="_model",re="itemStyle.normal.color",ae="scatter",oe="dataZoom",se="legend",le="markPoint",ue="itemStyle",ce="lineStyle",he="eachSeries",de="eachSeriesByType",fe="setItemVisual",pe="isSeriesFiltered",ve="setVisual",me="dispose",ge="canvasSupported",ye="clientHeight",xe="backgroundColor",_e="appendChild",we="innerHTML",be="intersect",Me="resize",Se="zlevel",Ae="silent",Ce="getDisplayList",Te="storage",ke="parentNode",Le="offsetY",Ie="offsetX",De="mouseup",Pe="mousemove",ze="mousedown",Re="zrender/core/event",Ve="zrender/core/env",Oe="initProps",Ee="updateProps",Ne="animateTo",Be="getTextColor",Ge="setText",Ze="mouseout",Fe="mouseover",He="setHoverStyle",We="hoverStyle",qe="setStyle",Ue="subPixelOptimizeRect",je="extendShape",Xe="Polyline",Ye="Polygon",Ke="Sector",Je="Circle",Qe="offset",$e="points",ti="clockwise",ei="endAngle",ii="startAngle",ni="setData",ri="setShape",ai="restore",oi="buildPath",si="zrender/graphic/Path",li="closePath",ui="bezierCurveTo",ci="lineTo",hi="moveTo",di="beginPath",fi="quadraticAt",pi="contain",vi="textBaseline",mi="textAlign",gi="textPosition",yi="eachItemGraphicEl",xi="indexOfName",_i="getItemGraphicEl",wi="dataIndex",bi="trigger",Mi="render",Si="removeAll",Ai="updateLayout",Ci="invisible",Ti="traverse",ki="delFromMap",Li="addToMap",Ii="remove",Di="__dirty",Pi="refresh",zi="ignore",Ri="draggable",Vi="animate",Oi="stopAnimation",Ei="linear",Ni="isFunction",Bi="animation",Gi="zrender/tool/color",Zi="target",Fi="transformCoordToLocal",Hi="rotate",Wi="invTransform",qi="getLocalTransform",Ui="parent",ji="updateTransform",Xi="transform",Yi="origin",Ki="rotation",Ji="zrender/mixin/Eventful",Qi="
",$i="getBaseAxis",tn="coordinateSystem",en="addCommas",nn="encodeHTML",rn="getComponent",an="register",on="update",sn="dispatchAction",ln="getHeight",un="getWidth",cn="getDom",hn="findComponents",dn="isString",fn="splice",pn="series",vn="timeline",mn="mergeOption",gn="restoreData",yn="resetOption",xn="mergeDefaultAndTheme",_n="positionGroup",wn="margin",bn="getLayoutRect",Mn="normalizeCssArray",Sn="vertical",An="horizontal",Cn="childAt",Tn="position",kn="eachChild",Ln="registerSubTypeDefaulter",In="isObject",Dn="formatter",Pn="getDataParams",zn="getItemModel",Rn="getName",Vn="getRawIndex",On="getRawValue",En="ordinal",Nn="getData",Bn="seriesIndex",Gn="createDataFormatModel",Zn="retrieve",Fn="normal",Hn="emphasis",Wn="defaultEmphasis",qn="normalizeToArray",Un="axisIndex",jn="radius",Xn="option",Yn="../util/clazz",Kn="borderWidth",Jn="borderColor",Qn="baseline",$n="getFont",tr="getBoundingRect",er="textStyle",ir="getModel",nr="ecModel",rr="defaults",ar="inside",or="../core/BoundingRect",sr="../core/util",lr="zrender/contain/text",ur="translate",cr="create",hr="height",dr="applyTransform",fr="zrender/core/BoundingRect",pr="zrender/core/matrix",vr="distance",mr="undefined",gr="zrender/core/vector",yr="shadowColor",xr="shadowOffsetX",_r="shadowBlur",wr="opacity",br="stroke",Mr="lineWidth",Sr="getShallow",Ar="getClass",Cr="enableClassManagement",Tr="inherits",kr="superApply",Lr="extend",Ir="enableClassExtend",Dr="isArray",Pr="toUpperCase",zr="toLowerCase",Rr="getPixelPrecision",Vr="toFixed",Or="bottom",Er="middle",Nr="center",Br="parsePercent",Gr="linearMap",Zr="replace",Fr="function",Hr="concat",Wr="number",qr="string",Ur="indexOf",jr="getContext",Xr="canvas",Yr="createElement",Kr="length",Jr="object",Qr="reduce",$r="filter",ta="zrender/core/util",ea="prototype",ia="require";e("zrender/graphic/Gradient",[ia],function(t){var e=function(t){this.colorStops=t||[]};return e[ea]={constructor:e,addColorStop:function(t,e){this.colorStops.push({offset:t,color:e})}},e}),e(ta,[ia,"../graphic/Gradient"],function(t){function e(t){if(typeof t==Jr&&null!==t){var i=t;if(t instanceof Array){i=[];for(var n=0,r=t[Kr];r>n;n++)i[n]=e(t[n])}else if(!M(t)&&!S(t)){i={};for(var a in t)t.hasOwnProperty(a)&&(i[a]=e(t[a]))}return i}return t}function i(t,n,r){if(!b(n)||!b(t))return r?e(n):t;for(var a in n)if(n.hasOwnProperty(a)){var o=t[a],s=n[a];!b(s)||!b(o)||x(s)||x(o)||S(s)||S(o)||M(s)||M(o)?!r&&a in t||(t[a]=e(n[a],!0)):i(o,s,r)}return t}function n(t,e){for(var n=t[0],r=1,a=t[Kr];a>r;r++)n=i(n,t[r],e);return n}function r(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}function a(t,e,i){for(var n in e)e.hasOwnProperty(n)&&(i?null!=e[n]:null==t[n])&&(t[n]=e[n]);return t}function o(){return document[Yr](Xr)}function s(){return k||(k=N.createCanvas()[jr]("2d")),k}function l(t,e){if(t){if(t[Ur])return t[Ur](e);for(var i=0,n=t[Kr];n>i;i++)if(t[i]===e)return i}return-1}function u(t,e){function i(){}var n=t[ea];i[ea]=e[ea],t[ea]=new i;for(var r in n)t[ea][r]=n[r];t[ea].constructor=t,t.superClass=e}function c(t,e,i){t=ea in t?t[ea]:t,e=ea in e?e[ea]:e,a(t,e,i)}function h(t){return t?typeof t==qr?!1:typeof t[Kr]==Wr:void 0}function d(t,e,i){if(t&&e)if(t.forEach&&t.forEach===z)t.forEach(e,i);else if(t[Kr]===+t[Kr])for(var n=0,r=t[Kr];r>n;n++)e.call(i,t[n],n,t);else for(var a in t)t.hasOwnProperty(a)&&e.call(i,t[a],a,t)}function f(t,e,i){if(t&&e){if(t.map&&t.map===O)return t.map(e,i);for(var n=[],r=0,a=t[Kr];a>r;r++)n.push(e.call(i,t[r],r,t));return n}}function p(t,e,i,n){if(t&&e){if(t[Qr]&&t[Qr]===E)return t[Qr](e,i,n);for(var r=0,a=t[Kr];a>r;r++)i=e.call(n,i,t[r],r,t);return i}}function v(t,e,i){if(t&&e){if(t[$r]&&t[$r]===R)return t[$r](e,i);for(var n=[],r=0,a=t[Kr];a>r;r++)e.call(i,t[r],r,t)&&n.push(t[r]);return n}}function m(t,e,i){if(t&&e)for(var n=0,r=t[Kr];r>n;n++)if(e.call(i,t[n],n,t))return t[n]}function g(t,e){var i=V.call(arguments,2);return function(){return t.apply(e,i[Hr](V.call(arguments)))}}function y(t){var e=V.call(arguments,1);return function(){return t.apply(this,e[Hr](V.call(arguments)))}}function x(t){return"[object Array]"===D.call(t)}function _(t){return typeof t===Fr}function w(t){return"[object String]"===D.call(t)}function b(t){var e=typeof t;return e===Fr||!!t&&e==Jr}function M(t){return!!I[D.call(t)]||t instanceof L}function S(t){return t&&1===t.nodeType&&typeof t.nodeName==qr}function A(t){for(var e=0,i=arguments[Kr];i>e;e++)if(null!=arguments[e])return arguments[e]}function C(){return Function.call.apply(V,arguments)}function T(t,e){if(!t)throw new Error(e)}var k,L=t("../graphic/Gradient"),I={"[object Function]":1,"[object RegExp]":1,"[object Date]":1,"[object Error]":1,"[object CanvasGradient]":1},D=Object[ea].toString,P=Array[ea],z=P.forEach,R=P[$r],V=P.slice,O=P.map,E=P[Qr],N={inherits:u,mixin:c,clone:e,merge:i,mergeAll:n,extend:r,defaults:a,getContext:s,createCanvas:o,indexOf:l,slice:C,find:m,isArrayLike:h,each:d,map:f,reduce:p,filter:v,bind:g,curry:y,isArray:x,isString:w,isObject:b,isFunction:_,isBuildInObject:M,isDom:S,retrieve:A,assert:T,noop:function(){}};return N}),e("echarts/util/number",[ia],function(t){function e(t){return t[Zr](/^\s+/,"")[Zr](/\s+$/,"")}var i={},n=1e-4;return i[Gr]=function(t,e,i,n){var r=e[1]-e[0];if(0===r)return(i[0]+i[1])/2;var a=(t-e[0])/r;return n&&(a=Math.min(Math.max(a,0),1)),a*(i[1]-i[0])+i[0]},i[Br]=function(t,i){switch(t){case Nr:case Er:t="50%";break;case"left":case"top":t="0%";break;case"right":case Or:t="100%"}return typeof t===qr?e(t).match(/%$/)?parseFloat(t)/100*i:parseFloat(t):null==t?NaN:+t},i.round=function(t){return+(+t)[Vr](12)},i.asc=function(t){return t.sort(function(t,e){return t-e}),t},i.getPrecision=function(t){for(var e=1,i=0;Math.round(t*e)/e!==t;)e*=10,i++;return i},i[Rr]=function(t,e){var i=Math.log,n=Math.LN10,r=Math.floor(i(t[1]-t[0])/n),a=Math.round(i(Math.abs(e[1]-e[0]))/n);return Math.max(-r+a,0)},i.MAX_SAFE_INTEGER=9007199254740991,i.remRadian=function(t){var e=2*Math.PI;return(t%e+e)%e},i.isRadianAroundZero=function(t){return t>-n&&n>t},i.parseDate=function(t){return t instanceof Date?t:new Date(typeof t===qr?t[Zr](/-/g,"/"):Math.round(t))},i}),e("echarts/util/format",[ia,ta,"./number"],function(t){function e(t){return isNaN(t)?"-":(t=(t+"").split("."),t[0][Zr](/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,"$1,")+(t[Kr]>1?"."+t[1]:""))}function i(t){return t[zr]()[Zr](/-(.)/g,function(t,e){return e[Pr]()})}function n(t){var e=t[Kr];return typeof t===Wr?[t,t,t,t]:2===e?[t[0],t[1],t[0],t[1]]:3===e?[t[0],t[1],t[2],t[1]]:t}function r(t){return String(t)[Zr](/&/g,"&")[Zr](//g,">")[Zr](/"/g,""")[Zr](/'/g,"'")}function a(t,e){return"{"+t+(null==e?"":e)+"}"}function o(t,e){u[Dr](e)||(e=[e]);var i=e[Kr];if(!i)return"";for(var n=e[0].$vars,r=0;rs;s++)for(var l=0;lt?"0"+t:t}var u=t(ta),c=t("./number"),h=["a","b","c","d","e","f","g"];return{normalizeCssArray:n,addCommas:e,toCamelCase:i,encodeHTML:r,formatTpl:o,formatTime:s}}),e("echarts/util/clazz",[ia,ta],function(t){function e(t,e){var i=n.slice(arguments,2);return this.superClass[ea][e].apply(t,i)}function i(t,e,i){return this.superClass[ea][e].apply(t,i)}var n=t(ta),r={},a=".",o="___EC__COMPONENT__CONTAINER___",s=r.parseClassType=function(t){var e={main:"",sub:""};return t&&(t=t.split(a),e.main=t[0]||"",e.sub=t[1]||""),e};return r[Ir]=function(t,r){t[Lr]=function(a){var o=function(){r&&r.apply(this,arguments),t.apply(this,arguments)};return n[Lr](o[ea],a),o[Lr]=this[Lr],o.superCall=e,o[kr]=i,n[Tr](o,this),o.superClass=this,o}},r[Cr]=function(t,e){function i(t){var e=r[t.main];return e&&e[o]||(e=r[t.main]={},e[o]=!0),e}e=e||{};var r={};if(t.registerClass=function(t,e){if(e)if(e=s(e),e.sub){if(e.sub!==o){var n=i(e);n[e.sub]=t}}else{if(r[e.main])throw new Error(e.main+"exists");r[e.main]=t}return t},t[Ar]=function(t,e,i){var n=r[t];if(n&&n[o]&&(n=e?n[e]:null),i&&!n)throw new Error("Component "+t+"."+(e||"")+" not exists");return n},t.getClassesByMainType=function(t){t=s(t);var e=[],i=r[t.main];return i&&i[o]?n.each(i,function(t,i){i!==o&&e.push(t)}):e.push(i),e},t.hasClass=function(t){return t=s(t),!!r[t.main]},t.getAllClassMainTypes=function(){var t=[];return n.each(r,function(e,i){t.push(i)}),t},t.hasSubTypes=function(t){t=s(t);var e=r[t.main];return e&&e[o]},t.parseClassType=s,e.registerWhenExtend){var a=t[Lr];a&&(t[Lr]=function(e){var i=a.call(this,e);return t.registerClass(i,e.type)})}return t},r.setReadOnly=function(t,e){},r}),e("echarts/model/mixin/makeStyleMapper",[ia,ta],function(t){var e=t(ta);return function(t){for(var i=0;i=0)){var o=this[Sr](a);null!=o&&(n[t[r][0]]=o)}}return n}}}),e("echarts/model/mixin/lineStyle",[ia,"./makeStyleMapper"],function(t){var e=t("./makeStyleMapper")([[Mr,"width"],[br,"color"],[wr],[_r],[xr],["shadowOffsetY"],[yr]]);return{getLineStyle:function(t){var i=e.call(this,t),n=this.getLineDash();return n&&(i.lineDash=n),i},getLineDash:function(){var t=this.get("type");return"solid"===t||null==t?null:"dashed"===t?[5,5]:[1,1]}}}),e("echarts/model/mixin/areaStyle",[ia,"./makeStyleMapper"],function(t){return{getAreaStyle:t("./makeStyleMapper")([["fill","color"],[_r],[xr],["shadowOffsetY"],[wr],[yr]])}}),e(gr,[],function(){var t=typeof Float32Array===mr?Array:Float32Array,e={create:function(e,i){var n=new t(2);return n[0]=e||0,n[1]=i||0,n},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t},clone:function(e){var i=new t(2);return i[0]=e[0],i[1]=e[1],i},set:function(t,e,i){return t[0]=e,t[1]=i,t},add:function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t},scaleAndAdd:function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t},sub:function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t},len:function(t){return Math.sqrt(this.lenSquare(t))},lenSquare:function(t){return t[0]*t[0]+t[1]*t[1]},mul:function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t},div:function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},scale:function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},normalize:function(t,i){var n=e.len(i);return 0===n?(t[0]=0,t[1]=0):(t[0]=i[0]/n,t[1]=i[1]/n),t},distance:function(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))},distanceSquare:function(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])},negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},lerp:function(t,e,i,n){return t[0]=e[0]+n*(i[0]-e[0]),t[1]=e[1]+n*(i[1]-e[1]),t},applyTransform:function(t,e,i){var n=e[0],r=e[1];return t[0]=i[0]*n+i[2]*r+i[4],t[1]=i[1]*n+i[3]*r+i[5],t},min:function(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t},max:function(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t}};return e[Kr]=e.len,e.lengthSquare=e.lenSquare,e.dist=e[vr],e.distSquare=e.distanceSquare,e}),e(pr,[],function(){var t=typeof Float32Array===mr?Array:Float32Array,e={create:function(){var i=new t(6);return e.identity(i),i},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},mul:function(t,e,i){var n=e[0]*i[0]+e[2]*i[1],r=e[1]*i[0]+e[3]*i[1],a=e[0]*i[2]+e[2]*i[3],o=e[1]*i[2]+e[3]*i[3],s=e[0]*i[4]+e[2]*i[5]+e[4],l=e[1]*i[4]+e[3]*i[5]+e[5];return t[0]=n,t[1]=r,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t},translate:function(t,e,i){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4]+i[0],t[5]=e[5]+i[1],t},rotate:function(t,e,i){var n=e[0],r=e[2],a=e[4],o=e[1],s=e[3],l=e[5],u=Math.sin(i),c=Math.cos(i);return t[0]=n*c+o*u,t[1]=-n*u+o*c,t[2]=r*c+s*u,t[3]=-r*u+c*s,t[4]=c*a+u*l,t[5]=c*l-u*a,t},scale:function(t,e,i){var n=i[0],r=i[1];return t[0]=e[0]*n,t[1]=e[1]*r,t[2]=e[2]*n,t[3]=e[3]*r,t[4]=e[4]*n,t[5]=e[5]*r,t},invert:function(t,e){var i=e[0],n=e[2],r=e[4],a=e[1],o=e[3],s=e[5],l=i*o-a*n;return l?(l=1/l,t[0]=o*l,t[1]=-a*l,t[2]=-n*l,t[3]=i*l,t[4]=(n*s-o*r)*l,t[5]=(a*r-i*s)*l,t):null}};return e}),e(fr,[ia,"./vector","./matrix"],function(t){function e(t,e,i,n){this.x=t,this.y=e,this.width=i,this[hr]=n}var i=t("./vector"),n=t("./matrix"),r=i[dr],a=Math.min,o=Math.abs,s=Math.max;return e[ea]={constructor:e,union:function(t){var e=a(t.x,this.x),i=a(t.y,this.y);this.width=s(t.x+t.width,this.x+this.width)-e,this[hr]=s(t.y+t[hr],this.y+this[hr])-i,this.x=e,this.y=i},applyTransform:function(){var t=[],e=[];return function(i){i&&(t[0]=this.x,t[1]=this.y,e[0]=this.x+this.width,e[1]=this.y+this[hr],r(t,t,i),r(e,e,i),this.x=a(t[0],e[0]),this.y=a(t[1],e[1]),this.width=o(e[0]-t[0]),this[hr]=o(e[1]-t[1]))}}(),calculateTransform:function(t){var e=this,i=t.width/e.width,r=t[hr]/e[hr],a=n[cr]();return n[ur](a,a,[-e.x,-e.y]),n.scale(a,a,[i,r]),n[ur](a,a,[t.x,t.y]),a},intersect:function(t){var e=this,i=e.x,n=e.x+e.width,r=e.y,a=e.y+e[hr],o=t.x,s=t.x+t.width,l=t.y,u=t.y+t[hr];return!(o>n||i>s||l>a||r>u)},contain:function(t,e){var i=this;return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i[hr]},clone:function(){return new e(this.x,this.y,this.width,this[hr])},copy:function(t){this.x=t.x,this.y=t.y,this.width=t.width,this[hr]=t[hr]}},e}),e(lr,[ia,sr,or],function(t){function e(t,e){var i=t+":"+e;if(s[i])return s[i];for(var n=(t+"").split("\n"),r=0,a=0,o=n[Kr];o>a;a++)r=Math.max(d.measureText(n[a],e).width,r);return l>u&&(l=0,s={}),l++,s[i]=r,r}function i(t,i,n,r){var a=((t||"")+"").split("\n")[Kr],o=e(t,i),s=e("国",i),l=a*s,u=new h(0,0,o,l);switch(u.lineHeight=s,r){case Or:case"alphabetic":u.y-=s;break;case Er:u.y-=s/2}switch(n){case"end":case"right":u.x-=u.width;break;case Nr:u.x-=u.width/2}return u}function n(t,e,i,n){var r=e.x,a=e.y,o=e[hr],s=e.width,l=i[hr],u=o/2-l/2,c="left";switch(t){case"left":r-=n,a+=u,c="right";break;case"right":r+=n+s,a+=u,c="left";break;case"top":r+=s/2,a-=n+l,c=Nr;break;case Or:r+=s/2,a+=o+n,c=Nr;break;case ar:r+=s/2,a+=u,c=Nr;break;case"insideLeft":r+=n,a+=u,c="left";break;case"insideRight":r+=s-n,a+=u,c="right";break;case"insideTop":r+=s/2,a+=n,c=Nr;break;case"insideBottom":r+=s/2,a+=o-l-n,c=Nr;break;case"insideTopLeft":r+=n,a+=n,c="left";break;case"insideTopRight":r+=s-n,a+=n,c="right";break;case"insideBottomLeft":r+=n,a+=o-l-n;break;case"insideBottomRight":r+=s-n,a+=o-l-n,c="right"}return{x:r,y:a,textAlign:c,textBaseline:"top"}}function r(t,i,n,r){if(!n)return"";r=c[rr]({ellipsis:"...",minCharacters:3,maxIterations:3,cnCharWidth:e("国",i),ascCharWidth:e("a",i)},r,!0),n-=e(r.ellipsis);for(var o=(t+"").split("\n"),s=0,l=o[Kr];l>s;s++)o[s]=a(o[s],i,n,r);return o.join("\n")}function a(t,i,n,r){for(var a=0;;a++){var s=e(t,i);if(n>s||a>=r.maxIterations){t+=r.ellipsis;break}var l=0===a?o(t,n,r):Math.floor(t[Kr]*n/s);if(lr&&e>n;r++){var o=t.charCodeAt(r);n+=o>=0&&127>=o?i.ascCharWidth:i.cnCharWidth}return r}var s={},l=0,u=5e3,c=t(sr),h=t(or),d={getWidth:e,getBoundingRect:i,adjustTextPositionOnRect:n,ellipsis:r,measureText:function(t,e){var i=c[jr]();return i.font=e,i.measureText(t)}};return d}),e("echarts/model/mixin/textStyle",[ia,lr],function(t){function e(t,e){return t&&t[Sr](e)}var i=t(lr);return{getTextColor:function(){var t=this[nr];return this[Sr]("color")||t&&t.get("textStyle.color")},getFont:function(){var t=this[nr],i=t&&t[ir](er);return[this[Sr]("fontStyle")||e(i,"fontStyle"),this[Sr]("fontWeight")||e(i,"fontWeight"),(this[Sr]("fontSize")||e(i,"fontSize")||12)+"px",this[Sr]("fontFamily")||e(i,"fontFamily")||"sans-serif"].join(" ")},getTextRect:function(t){var e=this.get(er)||{};return i[tr](t,this[$n](),e.align,e[Qn])},ellipsis:function(t,e,n){return i.ellipsis(t,this[$n](),e,n)}}}),e("echarts/model/mixin/itemStyle",[ia,"./makeStyleMapper"],function(t){return{getItemStyle:t("./makeStyleMapper")([["fill","color"],[br,Jn],[Mr,Kn],[wr],[_r],[xr],["shadowOffsetY"],[yr]])}}),e("echarts/model/Model",[ia,ta,Yn,"./mixin/lineStyle","./mixin/areaStyle","./mixin/textStyle","./mixin/itemStyle"],function(t){function e(t,e,i,n){this.parentModel=e,this[nr]=i,this[Xn]=t,this.init&&(arguments[Kr]<=4?this.init(t,e,i,n):this.init.apply(this,arguments))}var i=t(ta),n=t(Yn);e[ea]={constructor:e,init:null,mergeOption:function(t){i.merge(this[Xn],t,!0)},get:function(t,e){if(!t)return this[Xn];typeof t===qr&&(t=t.split("."));for(var i=this[Xn],n=this.parentModel,r=0;r=0}function a(t,r){var a=!1;return e(function(e){n.each(i(t,e)||[],function(t){r.records[e.name][t]&&(a=!0)})}),a}function o(t,r){r.nodes.push(t),e(function(e){n.each(i(t,e)||[],function(t){r.records[e.name][t]=!0})})}return function(i){function n(t){!r(t,s)&&a(t,s)&&(o(t,s),l=!0)}var s={nodes:[],records:{}};if(e(function(t){s.records[t.name]={}}),!i)return s;o(i,s);var l;do l=!1,t(n);while(l);return s}},o[Wn]=function(t,e){if(t){var i=t[Hn]=t[Hn]||{},r=t[Fn]=t[Fn]||{};n.each(e,function(t){var e=n[Zn](i[t],r[t]);null!=e&&(i[t]=e)})}},o[Gn]=function(t,e,i){var a=new r;return n.mixin(a,o.dataFormatMixin),a[Bn]=t[Bn],a.name=t.name||"",a[Nn]=function(){return e},a.getRawDataArray=function(){return i},a},o.getDataItemValue=function(t){return t&&(null==t.value?t:t.value)},o.converDataValue=function(t,e){var n=e&&e.type;return n===En?t:("time"!==n||isFinite(t)||null==t||"-"===t||(t=+i.parseDate(t)),null==t||""===t?NaN:+t)},o.dataFormatMixin={getDataParams:function(t){var e=this[Nn](),i=this[Bn],n=this.name,r=this[On](t),a=e[Vn](t),o=e[Rn](t,!0),s=this.getRawDataArray(),l=s&&s[a];return{seriesIndex:i,seriesName:n,name:o,dataIndex:a,data:l,value:r,$vars:["seriesName","name","value"]}},getFormattedLabel:function(t,i,n){i=i||Fn;var r=this[Nn](),a=r[zn](t),o=this[Pn](t);return null==n&&(n=a.get(["label",i,Dn])),typeof n===Fr?(o.status=i,n(o)):typeof n===qr?e.formatTpl(n,o):void 0},getRawValue:function(t){var e=this[Nn]()[zn](t);if(e&&null!=e[Xn]){var i=e[Xn];return n[In](i)&&!n[Dr](i)?i.value:i}}},o.mappingToExists=function(t,e){e=(e||[]).slice();var i=n.map(t||[],function(t,e){return{exist:t}});return n.each(e,function(t,r){if(n[In](t))for(var a=0;a=i[Kr]&&i.push({option:t})}}),i},o.isIdInner=function(t){return n[In](t)&&t.id&&0===(t.id+"")[Ur]("\x00_ec_\x00")},o}),e("echarts/util/component",[ia,ta,"./clazz"],function(t){var e=t(ta),i=t("./clazz"),n=i.parseClassType,r=0,a={},o="_";return a.getUID=function(t){return[t||"",r++,Math.random()].join(o)},a.enableSubTypeDefaulter=function(t){var e={};return t[Ln]=function(t,i){t=n(t),e[t.main]=i},t.determineSubType=function(i,r){var a=r.type;if(!a){var o=n(i).main;t.hasSubTypes(i)&&e[o]&&(a=e[o](r))}return a},t},a.enableTopologicalTravel=function(t,i){function n(t){var n={},o=[];return e.each(t,function(s){var l=r(n,s),u=l.originalDeps=i(s),c=a(u,t);l.entryCount=c[Kr],0===l.entryCount&&o.push(s),e.each(c,function(t){e[Ur](l.predecessor,t)<0&&l.predecessor.push(t);var i=r(n,t);e[Ur](i.successor,t)<0&&i.successor.push(s)})}),{graph:n,noEntryList:o}}function r(t,e){return t[e]||(t[e]={predecessor:[],successor:[]}),t[e]}function a(t,i){var n=[];return e.each(t,function(t){e[Ur](i,t)>=0&&n.push(t)}),n}t.topologicalTravel=function(t,i,r,a){function o(t){u[t].entryCount--,0===u[t].entryCount&&c.push(t)}function s(t){h[t]=!0,o(t)}if(t[Kr]){var l=n(i),u=l.graph,c=l.noEntryList,h={};for(e.each(t,function(t){h[t]=!0});c[Kr];){var d=c.pop(),f=u[d],p=!!h[d];p&&(r.call(a,d,f.originalDeps.slice()),delete h[d]),e.each(f.successor,p?s:o)}e.each(h,function(){throw new Error("Circle dependency may exists")})}}},a}),e("echarts/util/layout",[ia,ta,fr,"./number","./format"],function(t){function e(t,e,i,n,r){var a=0,o=0;null==n&&(n=1/0),null==r&&(r=1/0);var s=0;e[kn](function(l,u){var c,h,d=l[Tn],f=l[tr](),p=e[Cn](u+1),v=p&&p[tr]();if(t===An){var m=f.width+(v?-v.x+f.x:0);c=a+m,c>n||l.newline?(a=0,c=m,o+=s+i,s=f[hr]):s=Math.max(s,f[hr])}else{var g=f[hr]+(v?-v.y+f.y:0);h=o+g,h>r||l.newline?(a+=s+i,o=0,h=g,s=f.width):s=Math.max(s,f.width)}l.newline||(d[0]=a,d[1]=o,t===An?a=c+i:o=h+i)})}var i=t(ta),n=t(fr),r=t("./number"),a=t("./format"),o=r[Br],s=i.each,l={},u=["left","right","top",Or,"width",hr];return l.box=e,l.vbox=i.curry(e,Sn),l.hbox=i.curry(e,An),l.getAvailableSize=function(t,e,i){var n=e.width,r=e[hr],s=o(t.x,n),l=o(t.y,r),u=o(t.x2,n),c=o(t.y2,r);return(isNaN(s)||isNaN(parseFloat(t.x)))&&(s=0),(isNaN(u)||isNaN(parseFloat(t.x2)))&&(u=n),(isNaN(l)||isNaN(parseFloat(t.y)))&&(l=0),(isNaN(c)||isNaN(parseFloat(t.y2)))&&(c=r),i=a[Mn](i||0),{width:Math.max(u-s-i[1]-i[3],0),height:Math.max(c-l-i[0]-i[2],0)}},l[bn]=function(t,e,i){i=a[Mn](i||0);var r=e.width,s=e[hr],l=o(t.left,r),u=o(t.top,s),c=o(t.right,r),h=o(t[Or],s),d=o(t.width,r),f=o(t[hr],s),p=i[2]+i[0],v=i[1]+i[3],m=t.aspect;switch(isNaN(d)&&(d=r-c-v-l),isNaN(f)&&(f=s-h-p-u),isNaN(d)&&isNaN(f)&&(m>r/s?d=.8*r:f=.8*s),null!=m&&(isNaN(d)&&(d=m*f),isNaN(f)&&(f=d/m)),isNaN(l)&&(l=r-c-d-v),isNaN(u)&&(u=s-h-f-p),t.left||t.right){case Nr:l=r/2-d/2-i[3];break;case"right":l=r-d-v}switch(t.top||t[Or]){case Er:case Nr:u=s/2-f/2-i[0];break;case Or:u=s-f-p}l=l||0,u=u||0,isNaN(d)&&(d=r-l-(c||0)),isNaN(f)&&(f=s-u-(h||0));var g=new n(l+i[3],u+i[0],d,f);return g[wn]=i,g},l[_n]=function(t,e,n,r){var a=t[tr]();e=i[Lr](i.clone(e),{width:a.width,height:a[hr]}),e=l[bn](e,n,r),t[Tn]=[e.x-a.x,e.y-a.y]},l.mergeLayoutParam=function(t,e,n){function r(i){var r={},l=0,u={},c=0,h=n.ignoreSize?1:2;if(s(i,function(e){u[e]=t[e]}),s(i,function(t){a(e,t)&&(r[t]=u[t]=e[t]),o(r,t)&&l++,o(u,t)&&c++}),c!==h&&l){if(l>=h)return r;for(var d=0;d=0;a--)r=n.merge(r,t[a],!0);this.__defaultOption=r}return this.__defaultOption}});return o[Ir](l,function(t,e,i,r){n[Lr](this,r),this.uid=a.getUID("componentModel"),this.setReadOnly(["type","id","uid","name","mainType","subType","dependentModels","componentIndex"])}),o[Cr](l,{registerWhenExtend:!0}),a.enableSubTypeDefaulter(l),a.enableTopologicalTravel(l,e),n.mixin(l,t("./mixin/boxLayout")),l}),e("echarts/model/globalDefault",[],function(){var t="";return typeof navigator!==mr&&(t=navigator.platform||""),{color:["#c23531","#314656","#61a0a8","#dd8668","#91c7ae","#6e7074","#ca8622","#bda29a","#44525d","#c4ccd3"],grid:{},textStyle:{fontFamily:t.match(/^Win/)?"Microsoft YaHei":"sans-serif",fontSize:12,fontStyle:"normal",fontWeight:"normal"},animation:!0,animationThreshold:2e3,animationDuration:1e3,animationDurationUpdate:300,animationEasing:"exponentialOut",animationEasingUpdate:"cubicOut"}}),e("echarts/model/Global",[ia,ta,"../util/model","./Model","./Component","./globalDefault"],function(t){function e(t,e){for(var i in e)y.hasClass(i)||(typeof e[i]===Jr?t[i]=t[i]?u.merge(t[i],e[i],!1):u.clone(e[i]):t[i]=e[i])}function i(t){t=t,this[Xn]={},this[Xn][_]=1,this._componentsMap={},this._seriesIndices=null,e(t,this._theme[Xn]),u.merge(t,x,!1),this[mn](t)}function n(t,e){u[Dr](e)||(e=e?[e]:[]);var i={};return d(e,function(e){i[e]=(t[e]||[]).slice()}),i}function r(t,e){var i={};d(e,function(t,e){var n=t.exist;n&&(i[n.id]=t)}),d(e,function(e,n){var r=e[Xn];if(u.assert(!r||null==r.id||!i[r.id]||i[r.id]===e,"id duplicates: "+(r&&r.id)),r&&null!=r.id&&(i[r.id]=e),g(r)){var o=a(t,r,e.exist);e.keyInfo={mainType:t,subType:o}}}),d(e,function(t,e){var n=t.exist,r=t[Xn],a=t.keyInfo;if(g(r)){if(a.name=null!=r.name?r.name+"":n?n.name:"\x00-",n)a.id=n.id;else if(null!=r.id)a.id=r.id+"";else{ -var o=0;do a.id="\x00"+a.name+"\x00"+o++;while(i[a.id])}i[a.id]=t}})}function a(t,e,i){var n=e.type?e.type:i?i.subType:y.determineSubType(t,e);return n}function o(t){return p(t,function(t){return t.componentIndex})||[]}function s(t,e){return e.hasOwnProperty("subType")?f(t,function(t){return t.subType===e.subType}):t}function l(t){if(!t._seriesIndices)throw new Error("Series is not initialized. Please depends sereis.")}var u=t(ta),c=t("../util/model"),h=t("./Model"),d=u.each,f=u[$r],p=u.map,v=u[Dr],m=u[Ur],g=u[In],y=t("./Component"),x=t("./globalDefault"),_="\x00_ec_inner",w=h[Lr]({constructor:w,init:function(t,e,i,n){i=i||{},this[Xn]=null,this._theme=new h(i),this._optionManager=n},setOption:function(t,e){u.assert(!(_ in t),"please use chart.getOption()"),this._optionManager.setOption(t,e),this[yn]()},resetOption:function(t){var e=!1,n=this._optionManager;if(!t||"recreate"===t){var r=n.mountOption("recreate"===t);this[Xn]&&"recreate"!==t?(this[gn](),this[mn](r)):i.call(this,r),e=!0}if((t===vn||"media"===t)&&this[gn](),!t||"recreate"===t||t===vn){var a=n.getTimelineOption(this);a&&(this[mn](a),e=!0)}if(!t||"recreate"===t||"media"===t){var o=n.getMediaOption(this,this._api);o[Kr]&&d(o,function(t){this[mn](t,e=!0)},this)}return e},mergeOption:function(t){function e(e,s){var l=c[qn](t[e]),h=c.mappingToExists(a[e],l);r(e,h);var f=n(a,s);i[e]=[],a[e]=[],d(h,function(t,n){var r=t.exist,o=t[Xn];if(u.assert(g(o)||r,"Empty component definition"),o){var s=y[Ar](e,t.keyInfo.subType,!0);r&&r instanceof s?r[mn](o,this):r=new s(o,this,this,u[Lr]({dependentModels:f,componentIndex:n},t.keyInfo))}else r[mn]({},this);a[e][n]=r,i[e][n]=r[Xn]},this),e===pn&&(this._seriesIndices=o(a[pn]))}var i=this[Xn],a=this._componentsMap,s=[];d(t,function(t,e){null!=t&&(y.hasClass(e)?s.push(e):i[e]=null==i[e]?u.clone(t):u.merge(i[e],t,!0))}),y.topologicalTravel(s,y.getAllClassMainTypes(),e,this)},getOption:function(){var t=u.clone(this[Xn]);return d(t,function(e,i){if(y.hasClass(i)){for(var e=c[qn](e),n=e[Kr]-1;n>=0;n--)c.isIdInner(e[n])&&e[fn](n,1);t[i]=e}}),delete t[_],t},getTheme:function(){return this._theme},getComponent:function(t,e){var i=this._componentsMap[t];return i?i[e||0]:void 0},queryComponents:function(t){var e=t.mainType;if(!e)return[];var i=t.index,n=t.id,r=t.name,a=this._componentsMap[e];if(!a||!a[Kr])return[];var o;if(null!=i)v(i)||(i=[i]),o=f(p(i,function(t){return a[t]}),function(t){return!!t});else if(null!=n){var l=v(n);o=f(a,function(t){return l&&m(n,t.id)>=0||!l&&t.id===n})}else if(null!=r){var u=v(r);o=f(a,function(t){return u&&m(r,t.name)>=0||!u&&t.name===r})}return s(o,t)},findComponents:function(t){function e(t){var e=r+"Index",i=r+"Id",n=r+"Name";return t&&(t.hasOwnProperty(e)||t.hasOwnProperty(i)||t.hasOwnProperty(n))?{mainType:r,index:t[e],id:t[i],name:t[n]}:null}function i(e){return t[$r]?f(e,t[$r]):e}var n=t.query,r=t.mainType,a=e(n),o=a?this.queryComponents(a):this._componentsMap[r];return i(s(o,t))},eachComponent:function(t,e,i){var n=this._componentsMap;if(typeof t===Fr)i=e,e=t,d(n,function(t,n){d(t,function(t,r){e.call(i,n,t,r)})});else if(u[dn](t))d(n[t],e,i);else if(g(t)){var r=this[hn](t);d(r,e,i)}},getSeriesByName:function(t){var e=this._componentsMap[pn];return f(e,function(e){return e.name===t})},getSeriesByIndex:function(t){return this._componentsMap[pn][t]},getSeriesByType:function(t){var e=this._componentsMap[pn];return f(e,function(e){return e.subType===t})},getSeries:function(){return this._componentsMap[pn].slice()},eachSeries:function(t,e){l(this),d(this._seriesIndices,function(i){var n=this._componentsMap[pn][i];t.call(e,n,i)},this)},eachRawSeries:function(t,e){d(this._componentsMap[pn],t,e)},eachSeriesByType:function(t,e,i){l(this),d(this._seriesIndices,function(n){var r=this._componentsMap[pn][n];r.subType===t&&e.call(i,r,n)},this)},eachRawSeriesByType:function(t,e,i){return d(this.getSeriesByType(t),e,i)},isSeriesFiltered:function(t){return l(this),u[Ur](this._seriesIndices,t.componentIndex)<0},filterSeries:function(t,e){l(this);var i=f(this._componentsMap[pn],t,e);this._seriesIndices=o(i)},restoreData:function(){var t=this._componentsMap;this._seriesIndices=o(t[pn]);var e=[];d(t,function(t,i){e.push(i)}),y.topologicalTravel(e,y.getAllClassMainTypes(),function(e,i){d(t[e],function(t){t[gn]()})})}});return w}),e("echarts/ExtensionAPI",[ia,ta],function(t){function e(t){i.each(n,function(e){this[e]=i.bind(t[e],t)},this)}var i=t(ta),n=[cn,"getZr",un,ln,sn,"on","off","getDataURL","getConnectedDataURL",ir,"getOption"];return e}),e("echarts/CoordinateSystem",[ia],function(t){function e(){this._coordinateSystems=[]}var i={};return e[ea]={constructor:e,create:function(t,e){var n=[];for(var r in i){var a=i[r][cr](t,e);a&&(n=n[Hr](a))}this._coordinateSystems=n},update:function(t,e){for(var i=this._coordinateSystems,n=0;n=e:"max"===i?e>=t:t===e}function a(t,e){return t.join(",")===e.join(",")}function o(t,e){e=e||{},c(e,function(e,i){if(null!=e){var n=t[i];if(u.hasClass(i)){e=l[qn](e),n=l[qn](n);var r=l.mappingToExists(n,e);t[i]=d(r,function(t){return t[Xn]&&t.exist?f(t.exist,t[Xn],!0):t.exist||t[Xn]})}else t[i]=f(n,e,!0)}})}var s=t(ta),l=t("../util/model"),u=t("./Component"),c=s.each,h=s.clone,d=s.map,f=s.merge,p=/^(min|max)?(.+)$/;return e[ea]={constructor:e,setOption:function(t,e){t=h(t,!0);var n=this._optionBackup,r=this._newOptionBackup=i.call(this,t,e);n?(o(n.baseOption,r.baseOption),r.timelineOptions[Kr]&&(n.timelineOptions=r.timelineOptions),r.mediaList[Kr]&&(n.mediaList=r.mediaList),r.mediaDefault&&(n.mediaDefault=r.mediaDefault)):this._optionBackup=r},mountOption:function(t){var e=t?this._optionBackup:this._newOptionBackup;return this._timelineOptions=d(e.timelineOptions,h),this._mediaList=d(e.mediaList,h),this._mediaDefault=h(e.mediaDefault),this._currentMediaIndices=[],h(e.baseOption)},getTimelineOption:function(t){var e,i=this._timelineOptions;if(i[Kr]){var n=t[rn](vn);n&&(e=h(i[n.getCurrentIndex()],!0))}return e},getMediaOption:function(t){var e=this._api[un](),i=this._api[ln](),r=this._mediaList,o=this._mediaDefault,s=[],l=[];if(!r[Kr]&&!o)return l;for(var u=0,c=r[Kr];c>u;u++)n(r[u].query,e,i)&&s.push(u);return!s[Kr]&&o&&(s=[-1]),s[Kr]&&!a(s,this._currentMediaIndices)&&(l=d(s,function(t){return h(-1===t?o[Xn]:r[t][Xn])})),this._currentMediaIndices=s,l}},e}),e("echarts/model/Series",[ia,ta,"../util/format","../util/model","./Component"],function(t){var e=t(ta),i=t("../util/format"),n=t("../util/model"),r=t("./Component"),a=i[nn],o=i[en],s=r[Lr]({type:"series",seriesIndex:0,coordinateSystem:null,defaultOption:null,legendDataProvider:null,init:function(t,e,i,n){this[Bn]=this.componentIndex,this[xn](t,i),this._dataBeforeProcessed=this.getInitialData(t,i),this._data=this._dataBeforeProcessed.cloneShallow()},mergeDefaultAndTheme:function(t,i){e.merge(t,i.getTheme().get(this.subType)),e.merge(t,this.getDefaultOption()),n[Wn](t.label,[Tn,"show",er,vr,Dn])},mergeOption:function(t,i){t=e.merge(this[Xn],t,!0);var n=this.getInitialData(t,i);n&&(this._data=n,this._dataBeforeProcessed=n.cloneShallow())},getInitialData:function(){},getData:function(){return this._data},setData:function(t){this._data=t},getRawData:function(){return this._dataBeforeProcessed},getRawDataArray:function(){return this[Xn].data},coordDimToDataDim:function(t){return[t]},dataDimToCoordDim:function(t){return t},getBaseAxis:function(){var t=this[tn];return t&&t[$i]&&t[$i]()},formatTooltip:function(t,i){var n=this._data,r=this[On](t),s=e[Dr](r)?e.map(r,o).join(", "):o(r),l=n[Rn](t);return i?a(this.name)+" : "+s:a(this.name)+Qi+(l?a(l)+" : "+s:s)},restoreData:function(){this._data=this._dataBeforeProcessed.cloneShallow()}});return e.mixin(s,n.dataFormatMixin),s}),e("zrender/core/guid",[],function(){var t=2311;return function(){return"zr_"+t++}}),e(Ji,[ia,sr],function(t){var e=Array[ea].slice,i=t(sr),n=i[Ur],r=function(){this._$handlers={}};return r[ea]={constructor:r,one:function(t,e,i){var r=this._$handlers;return e&&t?(r[t]||(r[t]=[]),n(r[t],t)>=0?this:(r[t].push({h:e,one:!0,ctx:i||this}),this)):this},on:function(t,e,i){var n=this._$handlers;return e&&t?(n[t]||(n[t]=[]),n[t].push({h:e,one:!1,ctx:i||this}),this):this},isSilent:function(t){var e=this._$handlers;return e[t]&&e[t][Kr]},off:function(t,e){var i=this._$handlers;if(!t)return this._$handlers={},this;if(e){if(i[t]){for(var n=[],r=0,a=i[t][Kr];a>r;r++)i[t][r].h!=e&&n.push(i[t][r]);i[t]=n}i[t]&&0===i[t][Kr]&&delete i[t]}else delete i[t];return this},trigger:function(t){if(this._$handlers[t]){var i=arguments,n=i[Kr];n>3&&(i=e.call(i,1));for(var r=this._$handlers[t],a=r[Kr],o=0;a>o;){switch(n){case 1:r[o].h.call(r[o].ctx);break;case 2:r[o].h.call(r[o].ctx,i[1]);break;case 3:r[o].h.call(r[o].ctx,i[1],i[2]);break;default:r[o].h.apply(r[o].ctx,i)}r[o].one?(r[fn](o,1),a--):o++}}return this},triggerWithContext:function(t){if(this._$handlers[t]){var i=arguments,n=i[Kr];n>4&&(i=e.call(i,1,i[Kr]-1));for(var r=i[i[Kr]-1],a=this._$handlers[t],o=a[Kr],s=0;o>s;){switch(n){case 1:a[s].h.call(r);break;case 2:a[s].h.call(r,i[1]);break;case 3:a[s].h.call(r,i[1],i[2]);break;default:a[s].h.apply(r,i)}a[s].one?(a[fn](s,1),o--):s++}}return this}},r}),e("zrender/mixin/Transformable",[ia,"../core/matrix","../core/vector"],function(t){function e(t){return t>a||-a>t}var i=t("../core/matrix"),n=t("../core/vector"),r=i.identity,a=5e-5,o=function(t){t=t||{},t[Tn]||(this[Tn]=[0,0]),null==t[Ki]&&(this[Ki]=0),t.scale||(this.scale=[1,1]),this[Yi]=this[Yi]||null},s=o[ea];s[Xi]=null,s.needLocalTransform=function(){return e(this[Ki])||e(this[Tn][0])||e(this[Tn][1])||e(this.scale[0]-1)||e(this.scale[1]-1)},s[ji]=function(){var t=this[Ui],e=t&&t[Xi],n=this.needLocalTransform(),a=this[Xi];return n||e?(a=a||i[cr](),n?this[qi](a):r(a),e&&(n?i.mul(a,t[Xi],a):i.copy(a,t[Xi])),this[Xi]=a,this[Wi]=this[Wi]||i[cr](),void i.invert(this[Wi],a)):void(a&&r(a))},s[qi]=function(t){t=t||[],r(t);var e=this[Yi],n=this.scale,a=this[Ki],o=this[Tn];return e&&(t[4]-=e[0],t[5]-=e[1]),i.scale(t,t,n),a&&i[Hi](t,t,a),e&&(t[4]+=e[0],t[5]+=e[1]),t[4]+=o[0],t[5]+=o[1],t},s.setTransform=function(t){var e=this[Xi];e&&t[Xi](e[0],e[1],e[2],e[3],e[4],e[5])};var l=[];return s.decomposeTransform=function(){if(this[Xi]){var t=this[Ui],n=this[Xi];t&&t[Xi]&&(i.mul(l,t[Wi],n),n=l);var r=n[0]*n[0]+n[1]*n[1],a=n[2]*n[2]+n[3]*n[3],o=this[Tn],s=this.scale;e(r-1)&&(r=Math.sqrt(r)),e(a-1)&&(a=Math.sqrt(a)),n[0]<0&&(r=-r),n[3]<0&&(a=-a),o[0]=n[4],o[1]=n[5],s[0]=r,s[1]=a,this[Ki]=Math.atan2(-n[1]/a,n[0]/r)}},s[Fi]=function(t,e){var i=[t,e],r=this[Wi];return r&&n[dr](i,i,r),i},s.transformCoordToGlobal=function(t,e){var i=[t,e],r=this[Xi];return r&&n[dr](i,i,r),i},o}),e("zrender/animation/easing",[],function(){var t={linear:function(t){return t},quadraticIn:function(t){return t*t},quadraticOut:function(t){return t*(2-t)},quadraticInOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},cubicIn:function(t){return t*t*t},cubicOut:function(t){return--t*t*t+1},cubicInOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},quarticIn:function(t){return t*t*t*t},quarticOut:function(t){return 1- --t*t*t*t},quarticInOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},quinticIn:function(t){return t*t*t*t*t},quinticOut:function(t){return--t*t*t*t*t+1},quinticInOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},sinusoidalIn:function(t){return 1-Math.cos(t*Math.PI/2)},sinusoidalOut:function(t){return Math.sin(t*Math.PI/2)},sinusoidalInOut:function(t){return.5*(1-Math.cos(Math.PI*t))},exponentialIn:function(t){return 0===t?0:Math.pow(1024,t-1)},exponentialOut:function(t){return 1===t?1:1-Math.pow(2,-10*t)},exponentialInOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(2,-10*(t-1))+2)},circularIn:function(t){return 1-Math.sqrt(1-t*t)},circularOut:function(t){return Math.sqrt(1- --t*t)},circularInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},elasticIn:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),-(i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)))},elasticOut:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/n)+1)},elasticInOut:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),(t*=2)<1?-.5*(i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)):i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)*.5+1)},backIn:function(t){var e=1.70158;return t*t*((e+1)*t-e)},backOut:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},backInOut:function(t){var e=2.5949095;return(t*=2)<1?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+2)},bounceIn:function(e){return 1-t.bounceOut(1-e)},bounceOut:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},bounceInOut:function(e){return.5>e?.5*t.bounceIn(2*e):.5*t.bounceOut(2*e-1)+.5}};return t}),e("zrender/animation/Clip",[ia,"./easing"],function(t){function e(t){this._target=t[Zi],this._life=t.life||1e3,this._delay=t.delay||0,this._initialized=!1,this.loop=null==t.loop?!1:t.loop,this.gap=t.gap||0,this.easing=t.easing||"Linear",this.onframe=t.onframe,this.ondestroy=t.ondestroy,this.onrestart=t.onrestart}var i=t("./easing");return e[ea]={constructor:e,step:function(t){this._initialized||(this._startTime=(new Date).getTime()+this._delay,this._initialized=!0);var e=(t-this._startTime)/this._life;if(!(0>e)){e=Math.min(e,1);var n=this.easing,r=typeof n==qr?i[n]:n,a=typeof r===Fr?r(e):e;return this.fire("frame",a),1==e?this.loop?(this.restart(),"restart"):(this._needsRemove=!0,"destroy"):null}},restart:function(){var t=(new Date).getTime(),e=(t-this._startTime)%this._life;this._startTime=(new Date).getTime()-e+this.gap,this._needsRemove=!1},fire:function(t,e){t="on"+t,this[t]&&this[t](this._target,e)}},e}),e(Gi,[ia],function(t){function e(t){return t=Math.round(t),0>t?0:t>255?255:t}function i(t){return t=Math.round(t),0>t?0:t>360?360:t}function n(t){return 0>t?0:t>1?1:t}function r(t){return e(t[Kr]&&"%"===t.charAt(t[Kr]-1)?parseFloat(t)/100*255:parseInt(t,10))}function a(t){return n(t[Kr]&&"%"===t.charAt(t[Kr]-1)?parseFloat(t)/100:parseFloat(t))}function o(t,e,i){return 0>i?i+=1:i>1&&(i-=1),1>6*i?t+(e-t)*i*6:1>2*i?e:2>3*i?t+(e-t)*(2/3-i)*6:t}function s(t,e,i){return t+(e-t)*i}function l(t){if(t){t+="";var e=t[Zr](/ /g,"")[zr]();if(e in x)return x[e].slice();if("#"!==e.charAt(0)){var i=e[Ur]("("),n=e[Ur](")");if(-1!==i&&n+1===e[Kr]){var o=e.substr(0,i),s=e.substr(i+1,n-(i+1)).split(","),l=1;switch(o){case"rgba":if(4!==s[Kr])return;l=a(s.pop());case"rgb":if(3!==s[Kr])return;return[r(s[0]),r(s[1]),r(s[2]),l];case"hsla":if(4!==s[Kr])return;return s[3]=a(s[3]),u(s);case"hsl":if(3!==s[Kr])return;return u(s);default:return}}}else{if(4===e[Kr]){var c=parseInt(e.substr(1),16);if(!(c>=0&&4095>=c))return;return[(3840&c)>>4|(3840&c)>>8,240&c|(240&c)>>4,15&c|(15&c)<<4,1]}if(7===e[Kr]){var c=parseInt(e.substr(1),16);if(!(c>=0&&16777215>=c))return;return[(16711680&c)>>16,(65280&c)>>8,255&c,1]}}}}function u(t){var i=(parseFloat(t[0])%360+360)%360/360,n=a(t[1]),r=a(t[2]),s=.5>=r?r*(n+1):r+n-r*n,l=2*r-s,u=[e(255*o(l,s,i+1/3)),e(255*o(l,s,i)),e(255*o(l,s,i-1/3))];return 4===t[Kr]&&(u[3]=t[3]),u}function c(t){if(t){var e,i,n=t[0]/255,r=t[1]/255,a=t[2]/255,o=Math.min(n,r,a),s=Math.max(n,r,a),l=s-o,u=(s+o)/2;if(0===l)e=0,i=0;else{i=.5>u?l/(s+o):l/(2-s-o);var c=((s-n)/6+l/2)/l,h=((s-r)/6+l/2)/l,d=((s-a)/6+l/2)/l;n===s?e=d-h:r===s?e=1/3+c-d:a===s&&(e=2/3+h-c),0>e&&(e+=1),e>1&&(e-=1)}var f=[360*e,i,u];return null!=t[3]&&f.push(t[3]),f}}function h(t,e){var i=l(t);if(i){for(var n=0;3>n;n++)0>e?i[n]=i[n]*(1-e)|0:i[n]=(255-i[n])*e+i[n]|0;return y(i,4===i[Kr]?"rgba":"rgb")}}function d(t,e){var i=l(t);return i?((1<<24)+(i[0]<<16)+(i[1]<<8)+ +i[2]).toString(16).slice(1):void 0}function f(t,i,n){if(i&&i[Kr]&&t>=0&&1>=t){n=n||[0,0,0,0];var r=t*(i[Kr]-1),a=Math.floor(r),o=Math.ceil(r),l=i[a],u=i[o],c=r-a;return n[0]=e(s(l[0],u[0],c)),n[1]=e(s(l[1],u[1],c)),n[2]=e(s(l[2],u[2],c)),n[3]=e(s(l[3],u[3],c)),n}}function p(t,i,r){if(i&&i[Kr]&&t>=0&&1>=t){var a=t*(i[Kr]-1),o=Math.floor(a),u=Math.ceil(a),c=l(i[o]),h=l(i[u]),d=a-o,f=y([e(s(c[0],h[0],d)),e(s(c[1],h[1],d)),e(s(c[2],h[2],d)),n(s(c[3],h[3],d))],"rgba");return r?{color:f,leftIndex:o,rightIndex:u,value:a}:f}}function v(t,e){if(!(2!==t[Kr]||t[1]0&&s>=l;l++)r.push({color:e[l],offset:(l-i.value)/a});return r.push({color:n.color,offset:1}),r}}function m(t,e,n,r){return t=l(t),t?(t=c(t),null!=e&&(t[0]=i(e)),null!=n&&(t[1]=a(n)),null!=r&&(t[2]=a(r)),y(u(t),"rgba")):void 0}function g(t,e){return t=l(t),t&&null!=e?(t[3]=n(e),y(t,"rgba")):void 0}function y(t,e){return("rgb"===e||"hsv"===e||"hsl"===e)&&(t=t.slice(0,3)),e+"("+t.join(",")+")"}var x={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};return{parse:l,lift:h,toHex:d,fastMapToColor:f,mapToColor:p,mapIntervalToColor:v,modifyHSL:m,modifyAlpha:g,stringify:y}}),e("zrender/animation/Animator",[ia,"./Clip","../tool/color",sr],function(t){function e(t,e){return t[e]}function i(t,e,i){t[e]=i}function n(t,e,i){return(e-t)*i+t}function r(t,e,i){return i>.5?e:t}function a(t,e,i,r,a){var o=t[Kr];if(1==a)for(var s=0;o>s;s++)r[s]=n(t[s],e[s],i);else for(var l=t[0][Kr],s=0;o>s;s++)for(var u=0;l>u;u++)r[s][u]=n(t[s][u],e[s][u],i)}function o(t,e,i){var n=t[Kr],r=e[Kr];if(n!==r){var a=n>r;if(a)t[Kr]=r;else for(var o=n;r>o;o++)t.push(1===i?e[o]:g.call(e[o]))}}function s(t,e,i){if(t===e)return!0;var n=t[Kr];if(n!==e[Kr])return!1;if(1===i){for(var r=0;n>r;r++)if(t[r]!==e[r])return!1}else for(var a=t[0][Kr],r=0;n>r;r++)for(var o=0;a>o;o++)if(t[r][o]!==e[r][o])return!1;return!0}function l(t,e,i,n,r,a,o,s,l){var c=t[Kr];if(1==l)for(var h=0;c>h;h++)s[h]=u(t[h],e[h],i[h],n[h],r,a,o);else for(var d=t[0][Kr],h=0;c>h;h++)for(var f=0;d>f;f++)s[h][f]=u(t[h][f],e[h][f],i[h][f],n[h][f],r,a,o)}function u(t,e,i,n,r,a,o){var s=.5*(i-t),l=.5*(n-e);return(2*(e-i)+s+l)*o+(-3*(e-i)-2*s-l)*a+s*r+e}function c(t){if(m(t)){var e=t[Kr];if(m(t[0])){for(var i=[],n=0;e>n;n++)i.push(g.call(t[n]));return i}return g.call(t)}return t}function h(t){return t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.floor(t[2]),"rgba("+t.join(",")+")"}function d(t,e,i,c,d){var v=t._getter,g=t._setter,y="spline"===e,x=c[Kr];if(x){var _,w=c[0].value,b=m(w),M=!1,S=!1,A=b&&m(w[0])?2:1;c.sort(function(t,e){return t.time-e.time}),_=c[x-1].time;for(var C=[],T=[],k=c[0].value,L=!0,I=0;x>I;I++){C.push(c[I].time/_);var D=c[I].value;if(b&&s(D,k,A)||!b&&D===k||(L=!1),k=D,typeof D==qr){var P=p.parse(D);P?(D=P,M=!0):S=!0}T.push(D)}if(!L){if(b){for(var z=T[x-1],I=0;x-1>I;I++)o(T[I],z,A);o(v(t._target,d),z,A)}var R,V,O,E,N,B,G=0,Z=0;if(M)var F=[0,0,0,0];var H=function(t,e){var i;if(Z>e){for(R=Math.min(G+1,x-1),i=R;i>=0&&!(C[i]<=e);i--);i=Math.min(i,x-2)}else{for(i=G;x>i&&!(C[i]>e);i++);i=Math.min(i-1,x-2)}G=i,Z=e;var o=C[i+1]-C[i];if(0!==o)if(V=(e-C[i])/o,y)if(E=T[i],O=T[0===i?i:i-1],N=T[i>x-2?x-1:i+1],B=T[i>x-3?x-1:i+2],b)l(O,E,N,B,V,V*V,V*V*V,v(t,d),A);else{var s;if(M)s=l(O,E,N,B,V,V*V,V*V*V,F,1),s=h(F);else{if(S)return r(E,N,V);s=u(O,E,N,B,V,V*V,V*V*V)}g(t,d,s)}else if(b)a(T[i],T[i+1],V,v(t,d),A);else{var s;if(M)a(T[i],T[i+1],V,F,1),s=h(F);else{if(S)return r(T[i],T[i+1],V);s=n(T[i],T[i+1],V)}g(t,d,s)}},W=new f({target:t._target,life:_,loop:t._loop,delay:t._delay,onframe:H,ondestroy:i});return e&&"spline"!==e&&(W.easing=e),W}}}var f=t("./Clip"),p=t("../tool/color"),v=t(sr),m=v.isArrayLike,g=Array[ea].slice,y=function(t,n,r,a){this._tracks={},this._target=t,this._loop=n||!1,this._getter=r||e,this._setter=a||i,this._clipCount=0,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]};return y[ea]={when:function(t,e){var i=this._tracks;for(var n in e){if(!i[n]){i[n]=[];var r=this._getter(this._target,n);if(null==r)continue;0!==t&&i[n].push({time:0,value:c(r)})}i[n].push({time:t,value:e[n]})}return this},during:function(t){return this._onframeList.push(t),this},_doneCallback:function(){this._tracks={},this._clipList[Kr]=0;for(var t=this._doneList,e=t[Kr],i=0;e>i;i++)t[i].call(this)},start:function(t){var e,i=this,n=0,r=function(){n--,n||i._doneCallback()};for(var a in this._tracks){var o=d(this,t,r,this._tracks[a],a);o&&(this._clipList.push(o),n++,this[Bi]&&this[Bi].addClip(o),e=o)}if(e){var s=e.onframe;e.onframe=function(t,e){s(t,e);for(var n=0;n1)for(var t in arguments)console.log(arguments[t])}}),e("zrender/mixin/Animatable",[ia,"../animation/Animator",sr,"../core/log"],function(t){var e=t("../animation/Animator"),i=t(sr),n=i[dn],r=i[Ni],a=i[In],o=t("../core/log"),s=function(){this.animators=[]};return s[ea]={constructor:s,animate:function(t,n){var r,a=!1,s=this,l=this.__zr;if(t){var u=t.split("."),c=s;a="shape"===u[0];for(var h=0,d=u[Kr];d>h;h++)c&&(c=c[u[h]]);c&&(r=c)}else r=s;if(!r)return void o('Property "'+t+'" is not existed in element '+s.id);var f=s.animators,p=new e(r,n);return p.during(function(t){s.dirty(a)}).done(function(){f[fn](i[Ur](f,p),1)}),f.push(p),l&&l[Bi].addAnimator(p),p},stopAnimation:function(t){for(var e=this.animators,i=e[Kr],n=0;i>n;n++)e[n].stop(t);return e[Kr]=0,this},animateTo:function(t,e,i,a,o){function s(){u--,u||o&&o()}n(i)?(o=a,a=i,i=0):r(a)?(o=a,a=Ei,i=0):r(i)?(o=i,i=0):r(e)?(o=e,e=500):e||(e=500),this[Oi](),this._animateToShallow("",this,t,e,i,a,o);var l=this.animators.slice(),u=l[Kr];u||o&&o();for(var c=0;c0&&this[Vi](t,!1).when(null==r?500:r,s).delay(o||0),this}},s}),e("zrender/Element",[ia,"./core/guid","./mixin/Eventful","./mixin/Transformable","./mixin/Animatable","./core/util"],function(t){var e=t("./core/guid"),i=t("./mixin/Eventful"),n=t("./mixin/Transformable"),r=t("./mixin/Animatable"),a=t("./core/util"),o=function(t){n.call(this,t),i.call(this,t),r.call(this,t),this.id=t.id||e()};return o[ea]={type:"element",name:"",__zr:null,ignore:!1,clipPath:null,drift:function(t,e){switch(this[Ri]){case An:e=0;break;case Sn:t=0}var i=this[Xi];i||(i=this[Xi]=[1,0,0,1,0,0]),i[4]+=t,i[5]+=e,this.decomposeTransform(),this.dirty()},beforeUpdate:function(){},afterUpdate:function(){},update:function(){this[ji]()},traverse:function(t,e){},attrKV:function(t,e){if(t===Tn||"scale"===t||t===Yi){if(e){var i=this[t];i||(i=this[t]=[]),i[0]=e[0],i[1]=e[1]}}else this[t]=e},hide:function(){this[zi]=!0,this.__zr&&this.__zr[Pi]()},show:function(){this[zi]=!1,this.__zr&&this.__zr[Pi]()},attr:function(t,e){if(typeof t===qr)this.attrKV(t,e);else if(a[In](t))for(var i in t)t.hasOwnProperty(i)&&this.attrKV(i,t[i]);return this.dirty(),this},setClipPath:function(t){var e=this.__zr;e&&t.addSelfToZr(e),this.clipPath&&this.clipPath!==t&&this.removeClipPath(),this.clipPath=t,t.__zr=e,t.__clipTarget=this,this.dirty()},removeClipPath:function(){var t=this.clipPath;t&&(t.__zr&&t.removeSelfFromZr(t.__zr),t.__zr=null,t.__clipTarget=null,this.clipPath=null,this.dirty())},addSelfToZr:function(t){this.__zr=t;var e=this.animators;if(e)for(var i=0;i=0&&(i[fn](n,0,t),this._doAdd(t))}return this},_doAdd:function(t){t[Ui]&&t[Ui][Ii](t),t[Ui]=this;var e=this.__storage,i=this.__zr;e&&e!==t.__storage&&(e[Li](t),t instanceof r&&t.addChildrenToStorage(e)),i&&i[Pi]()},remove:function(t){var i=this.__zr,n=this.__storage,a=this._children,o=e[Ur](a,t);return 0>o?this:(a[fn](o,1),t[Ui]=null,n&&(n[ki](t.id),t instanceof r&&t.delChildrenFromStorage(n)),i&&i[Pi](),this)},removeAll:function(){var t,e,i=this._children,n=this.__storage;for(e=0;e=0?parseFloat(t)/100*e:parseFloat(t):t}function i(t,e){t[Xi](e[0],e[1],e[2],e[3],e[4],e[5])}var n=t("../../contain/text"),r=t("../../core/BoundingRect"),a=new r,o=function(){};return o[ea]={constructor:o,drawRectText:function(t,r,o){var s=this.style,l=s.text;if(null!=l&&(l+=""),l){var u,c,h=s[gi],d=s.textDistance,f=s[mi],p=s.textFont||s.font,v=s[vi];o=o||n[tr](l,p,f,v);var m=this[Xi],g=this[Wi];if(m&&(a.copy(r),a[dr](m),r=a,i(t,g)),h instanceof Array)u=r.x+e(h[0],r.width),c=r.y+e(h[1],r[hr]),f=f||"left",v=v||"top";else{var y=n.adjustTextPositionOnRect(h,r,o,d);u=y.x,c=y.y,f=f||y[mi],v=v||y[vi]}t[mi]=f,t[vi]=v;var x=s.textFill,_=s.textStroke;x&&(t.fillStyle=x),_&&(t.strokeStyle=_),t.font=p,t[yr]=s.textShadowColor,t[_r]=s.textShadowBlur,t[xr]=s.textShadowOffsetX,t.shadowOffsetY=s.textShadowOffsetY;for(var w=l.split("\n"),b=0;b-_&&_>t}function i(t){return t>_||-_>t}function n(t,e,i,n,r){var a=1-r;return a*a*(a*t+3*r*e)+r*r*(r*n+3*a*i)}function r(t,e,i,n,r){var a=1-r;return 3*(((e-t)*a+2*(i-e)*r)*a+(n-i)*r*r)}function a(t,i,n,r,a,o){var s=r+3*(i-n)-t,l=3*(n-2*i+t),u=3*(i-t),c=t-a,h=l*l-3*s*u,d=l*u-9*s*c,f=u*u-3*l*c,p=0;if(e(h)&&e(d))if(e(l))o[0]=0;else{var v=-u/l;v>=0&&1>=v&&(o[p++]=v)}else{var m=d*d-4*h*f;if(e(m)){var g=d/h,v=-l/s+g,_=-g/2;v>=0&&1>=v&&(o[p++]=v),_>=0&&1>=_&&(o[p++]=_)}else if(m>0){var M=x(m),S=h*l+1.5*s*(-d+M),A=h*l+1.5*s*(-d-M);S=0>S?-y(-S,b):y(S,b),A=0>A?-y(-A,b):y(A,b);var v=(-l-(S+A))/(3*s);v>=0&&1>=v&&(o[p++]=v)}else{var C=(2*h*l-3*s*d)/(2*x(h*h*h)),T=Math.acos(C)/3,k=x(h),L=Math.cos(T),v=(-l-2*k*L)/(3*s),_=(-l+k*(L+w*Math.sin(T)))/(3*s),I=(-l+k*(L-w*Math.sin(T)))/(3*s);v>=0&&1>=v&&(o[p++]=v),_>=0&&1>=_&&(o[p++]=_),I>=0&&1>=I&&(o[p++]=I)}}return p}function o(t,n,r,a,o){var s=6*r-12*n+6*t,l=9*n+3*a-3*t-9*r,u=3*n-3*t,c=0;if(e(l)){if(i(s)){var h=-u/s;h>=0&&1>=h&&(o[c++]=h)}}else{var d=s*s-4*l*u;if(e(d))o[0]=-s/(2*l);else if(d>0){var f=x(d),h=(-s+f)/(2*l),p=(-s-f)/(2*l);h>=0&&1>=h&&(o[c++]=h),p>=0&&1>=p&&(o[c++]=p)}}return c}function s(t,e,i,n,r,a){var o=(e-t)*r+t,s=(i-e)*r+e,l=(n-i)*r+i,u=(s-o)*r+o,c=(l-s)*r+s,h=(c-u)*r+u;a[0]=t,a[1]=o,a[2]=u,a[3]=h,a[4]=h,a[5]=c,a[6]=l,a[7]=n}function l(t,e,i,r,a,o,s,l,u,c,h){var d,f,p,v,m,y=.005,w=1/0;M[0]=u,M[1]=c;for(var b=0;1>b;b+=.05)S[0]=n(t,i,a,s,b),S[1]=n(e,r,o,l,b),v=g(M,S),w>v&&(d=b,w=v);w=1/0;for(var C=0;32>C&&!(_>y);C++)f=d-y,p=d+y,S[0]=n(t,i,a,s,f),S[1]=n(e,r,o,l,f),v=g(S,M),f>=0&&w>v?(d=f,w=v):(A[0]=n(t,i,a,s,p),A[1]=n(e,r,o,l,p),m=g(A,M),1>=p&&w>m?(d=p,w=m):y*=.5);return h&&(h[0]=n(t,i,a,s,d),h[1]=n(e,r,o,l,d)),x(w)}function u(t,e,i,n){var r=1-n;return r*(r*t+2*n*e)+n*n*i}function c(t,e,i,n){return 2*((1-n)*(e-t)+n*(i-e))}function h(t,n,r,a,o){var s=t-2*n+r,l=2*(n-t),u=t-a,c=0;if(e(s)){if(i(l)){var h=-u/l;h>=0&&1>=h&&(o[c++]=h)}}else{var d=l*l-4*s*u;if(e(d)){var h=-l/(2*s);h>=0&&1>=h&&(o[c++]=h)}else if(d>0){var f=x(d),h=(-l+f)/(2*s),p=(-l-f)/(2*s);h>=0&&1>=h&&(o[c++]=h),p>=0&&1>=p&&(o[c++]=p)}}return c}function d(t,e,i){var n=t+i-2*e;return 0===n?.5:(t-e)/n}function f(t,e,i,n,r){var a=(e-t)*n+t,o=(i-e)*n+e,s=(o-a)*n+a;r[0]=t,r[1]=a,r[2]=s,r[3]=s,r[4]=o,r[5]=i}function p(t,e,i,n,r,a,o,s,l){var c,h=.005,d=1/0;M[0]=o,M[1]=s;for(var f=0;1>f;f+=.05){S[0]=u(t,i,r,f),S[1]=u(e,n,a,f);var p=g(M,S);d>p&&(c=f,d=p)}d=1/0;for(var v=0;32>v&&!(_>h);v++){var m=c-h,y=c+h;S[0]=u(t,i,r,m),S[1]=u(e,n,a,m);var p=g(S,M);if(m>=0&&d>p)c=m,d=p;else{A[0]=u(t,i,r,y),A[1]=u(e,n,a,y);var w=g(A,M);1>=y&&d>w?(c=y,d=w):h*=.5}}return l&&(l[0]=u(t,i,r,c),l[1]=u(e,n,a,c)),x(d)}var v=t("./vector"),m=v[cr],g=v.distSquare,y=Math.pow,x=Math.sqrt,_=1e-4,w=x(3),b=1/3,M=m(),S=m(),A=m();return{cubicAt:n,cubicDerivativeAt:r,cubicRootAt:a,cubicExtrema:o,cubicSubdivide:s,cubicProjectPoint:l,quadraticAt:u,quadraticDerivativeAt:c,quadraticRootAt:h,quadraticExtremum:d,quadraticSubdivide:f,quadraticProjectPoint:p}}),e("zrender/core/bbox",[ia,"./vector","./curve"],function(t){var e=t("./vector"),i=t("./curve"),n={},r=Math.min,a=Math.max,o=Math.sin,s=Math.cos,l=e[cr](),u=e[cr](),c=e[cr](),h=2*Math.PI;return n.fromPoints=function(t,e,i){if(0!==t[Kr]){var n,o=t[0],s=o[0],l=o[0],u=o[1],c=o[1];for(n=1;ng;g++)y[g]=w(t,n,s,u,y[g]);for(b=_(e,o,l,c,x),g=0;b>g;g++)x[g]=w(e,o,l,c,x[g]);y.push(t,u),x.push(e,c),f=r.apply(null,y),p=a.apply(null,y),v=r.apply(null,x),m=a.apply(null,x),h[0]=f,h[1]=v,d[0]=p,d[1]=m},n.fromQuadratic=function(t,e,n,o,s,l,u,c){var h=i.quadraticExtremum,d=i[fi],f=a(r(h(t,n,s),1),0),p=a(r(h(e,o,l),1),0),v=d(t,n,s,f),m=d(e,o,l,p);u[0]=r(t,s,v),u[1]=r(e,l,m),c[0]=a(t,s,v),c[1]=a(e,l,m)},n.fromArc=function(t,i,n,r,a,d,f,p,v){var m=e.min,g=e.max,y=Math.abs(a-d);if(1e-4>y%h&&y>1e-4)return p[0]=t-n,p[1]=i-r,v[0]=t+n,void(v[1]=i+r);if(l[0]=s(a)*n+t,l[1]=o(a)*r+i,u[0]=s(d)*n+t,u[1]=o(d)*r+i,m(p,l,u),g(v,l,u),a%=h,0>a&&(a+=h),d%=h,0>d&&(d+=h),a>d&&!f?d+=h:d>a&&f&&(a+=h),f){var x=d;d=a,a=x}for(var _=0;d>_;_+=Math.PI/2)_>a&&(c[0]=s(_)*n+t,c[1]=o(_)*r+i,m(p,c,p),g(v,c,v))},n}),e("zrender/core/PathProxy",[ia,"./curve","./vector","./bbox","./BoundingRect"],function(t){var e=t("./curve"),i=t("./vector"),n=t("./bbox"),r=t("./BoundingRect"),a={M:1,L:2,C:3,Q:4,A:5,Z:6,R:7},o=[],s=[],l=[],u=[],c=Math.min,h=Math.max,d=Math.cos,f=Math.sin,p=Math.sqrt,v=typeof Float32Array!=mr,m=function(){this.data=[],this._len=0,this._ctx=null,this._xi=0,this._yi=0,this._x0=0,this._y0=0};return m[ea]={constructor:m,_lineDash:null,_dashOffset:0,_dashIdx:0,_dashSum:0,getContext:function(){return this._ctx},beginPath:function(t){return this._ctx=t,t&&t[di](),this._len=0,this._lineDash&&(this._lineDash=null,this._dashOffset=0),this},moveTo:function(t,e){return this.addData(a.M,t,e),this._ctx&&this._ctx[hi](t,e),this._x0=t,this._y0=e,this._xi=t,this._yi=e,this},lineTo:function(t,e){return this.addData(a.L,t,e),this._ctx&&(this._needsDash()?this._dashedLineTo(t,e):this._ctx[ci](t,e)),this._xi=t,this._yi=e,this},bezierCurveTo:function(t,e,i,n,r,o){return this.addData(a.C,t,e,i,n,r,o),this._ctx&&(this._needsDash()?this._dashedBezierTo(t,e,i,n,r,o):this._ctx[ui](t,e,i,n,r,o)),this._xi=r,this._yi=o,this},quadraticCurveTo:function(t,e,i,n){return this.addData(a.Q,t,e,i,n),this._ctx&&(this._needsDash()?this._dashedQuadraticTo(t,e,i,n):this._ctx.quadraticCurveTo(t,e,i,n)),this._xi=i,this._yi=n,this},arc:function(t,e,i,n,r,o){return this.addData(a.A,t,e,i,i,n,r-n,0,o?0:1),this._ctx&&this._ctx.arc(t,e,i,n,r,o),this._xi=d(r)*i+t,this._xi=f(r)*i+t,this},arcTo:function(t,e,i,n,r){return this._ctx&&this._ctx.arcTo(t,e,i,n,r),this},rect:function(t,e,i,n){return this._ctx&&this._ctx.rect(t,e,i,n),this.addData(a.R,t,e,i,n),this},closePath:function(){this.addData(a.Z);var t=this._ctx,e=this._x0,i=this._y0;return t&&(this._needsDash()&&this._dashedLineTo(e,i),t[li]()),this._xi=e,this._yi=i,this},fill:function(t){t&&t.fill(),this.toStatic()},stroke:function(t){t&&t[br](),this.toStatic()},setLineDash:function(t){if(t instanceof Array){this._lineDash=t,this._dashIdx=0;for(var e=0,i=0;ii;i++)this.data[i]=t[i];this._len=e},appendPath:function(t){t instanceof Array||(t=[t]);for(var e=t[Kr],i=0,n=this._len,r=0;e>r;r++)i+=t[r].len();v&&this.data instanceof Float32Array&&(this.data=new Float32Array(n+i));for(var r=0;e>r;r++)for(var a=t[r].data,o=0;oe[Kr]&&(this._expandData(),e=this.data);for(var i=0;ia&&(a=r+a),a%=r,m-=a*d,g-=a*f;d>=0&&t>=m||0>d&&m>t;)n=this._dashIdx,i=o[n],m+=d*i,g+=f*i,this._dashIdx=(n+1)%y,d>0&&l>m||0>d&&m>l||s[n%2?hi:ci](d>=0?c(m,t):h(m,t),f>=0?c(g,e):h(g,e));d=m-t,f=g-e,this._dashOffset=-p(d*d+f*f)},_dashedBezierTo:function(t,i,n,r,a,o){var s,l,u,c,h,d=this._dashSum,f=this._dashOffset,v=this._lineDash,m=this._ctx,g=this._xi,y=this._yi,x=e.cubicAt,_=0,w=this._dashIdx,b=v[Kr],M=0;for(0>f&&(f=d+f),f%=d,s=0;1>s;s+=.1)l=x(g,t,n,a,s+.1)-x(g,t,n,a,s),u=x(y,i,r,o,s+.1)-x(y,i,r,o,s),_+=p(l*l+u*u);for(;b>w&&(M+=v[w],!(M>f));w++);for(s=(M-f)/_;1>=s;)c=x(g,t,n,a,s),h=x(y,i,r,o,s),w%2?m[hi](c,h):m[ci](c,h),s+=v[w]/_,w=(w+1)%b;w%2!==0&&m[ci](a,o),l=a-c,u=o-h,this._dashOffset=-p(l*l+u*u)},_dashedQuadraticTo:function(t,e,i,n){var r=i,a=n;i=(i+2*t)/3,n=(n+2*e)/3,t=(this._xi+2*t)/3,e=(this._yi+2*e)/3,this._dashedBezierTo(t,e,i,n,r,a)},toStatic:function(){var t=this.data;t instanceof Array&&(t[Kr]=this._len,v&&(this.data=new Float32Array(t)))},getBoundingRect:function(){o[0]=o[1]=l[0]=l[1]=Number.MAX_VALUE,s[0]=s[1]=u[0]=u[1]=-Number.MAX_VALUE;for(var t=this.data,e=0,c=0,h=0,p=0,v=0;vl?s:l,p=s>l?1:s/l,v=s>l?l/s:1,m=Math.abs(s-l)>.001;m?(t[ur](r,o),t[Hi](h),t.scale(p,v),t.arc(0,0,f,u,u+c,1-d),t.scale(1/p,1/v),t[Hi](-h),t[ur](-r,-o)):t.arc(r,o,f,u,u+c,1-d);break;case a.R:t.rect(e[i++],e[i++],e[i++],e[i++]);break;case a.Z:t[li]()}}}},m.CMD=a,m}),e("zrender/contain/line",[],function(){return{containStroke:function(t,e,i,n,r,a,o){if(0===r)return!1;var s=r,l=0,u=t;if(o>e+s&&o>n+s||e-s>o&&n-s>o||a>t+s&&a>i+s||t-s>a&&i-s>a)return!1;if(t===i)return Math.abs(a-t)<=s/2;l=(e-n)/(t-i),u=(t*n-i*e)/(t-i);var c=l*a-o+u,h=c*c/(l*l+1);return s/2*s/2>=h}}}),e("zrender/contain/cubic",[ia,"../core/curve"],function(t){var e=t("../core/curve");return{containStroke:function(t,i,n,r,a,o,s,l,u,c,h){if(0===u)return!1;var d=u;if(h>i+d&&h>r+d&&h>o+d&&h>l+d||i-d>h&&r-d>h&&o-d>h&&l-d>h||c>t+d&&c>n+d&&c>a+d&&c>s+d||t-d>c&&n-d>c&&a-d>c&&s-d>c)return!1;var f=e.cubicProjectPoint(t,i,n,r,a,o,s,l,c,h,null);return d/2>=f}}}),e("zrender/contain/quadratic",[ia,"../core/curve"],function(t){var e=t("../core/curve");return{containStroke:function(t,i,n,r,a,o,s,l,u){if(0===s)return!1;var c=s;if(u>i+c&&u>r+c&&u>o+c||i-c>u&&r-c>u&&o-c>u||l>t+c&&l>n+c&&l>a+c||t-c>l&&n-c>l&&a-c>l)return!1;var h=e.quadraticProjectPoint(t,i,n,r,a,o,l,u,null);return c/2>=h}}}),e("zrender/contain/util",[ia],function(t){var e=2*Math.PI;return{normalizeRadian:function(t){return t%=e,0>t&&(t+=e),t}}}),e("zrender/contain/arc",[ia,"./util"],function(t){var e=t("./util").normalizeRadian,i=2*Math.PI;return{containStroke:function(t,n,r,a,o,s,l,u,c){if(0===l)return!1;var h=l;u-=t,c-=n;var d=Math.sqrt(u*u+c*c);if(d-h>r||r>d+h)return!1;if(Math.abs(a-o)%i<1e-4)return!0;if(s){var f=a;a=e(o),o=e(f)}else a=e(a),o=e(o);a>o&&(o+=i);var p=Math.atan2(c,u);return 0>p&&(p+=i),p>=a&&o>=p||p+i>=a&&o>=p+i}}}),e("zrender/contain/windingLine",[],function(){return function(t,e,i,n,r,a){if(a>e&&a>n||e>a&&n>a)return 0;if(n===e)return 0;var o=e>n?1:-1,s=(a-e)/(n-e),l=s*(i-t)+t;return l>r?o:0}}),e("zrender/contain/path",[ia,"../core/PathProxy","./line","./cubic","./quadratic","./arc","./util","../core/curve","./windingLine"],function(t){function e(t,e){return Math.abs(t-e)e&&c>r&&c>o&&c>l||e>c&&r>c&&o>c&&l>c)return 0;var h=f.cubicRootAt(e,r,o,l,c,y);if(0===h)return 0;for(var d,p,v=0,m=-1,g=0;h>g;g++){var _=y[g],w=f.cubicAt(t,n,a,s,_);u>w||(0>m&&(m=f.cubicExtrema(e,r,o,l,x),x[1]1&&i(),d=f.cubicAt(e,r,o,l,x[0]),m>1&&(p=f.cubicAt(e,r,o,l,x[1]))),v+=2==m?_d?1:-1:_p?1:-1:p>l?1:-1:_d?1:-1:d>l?1:-1)}return v}function r(t,e,i,n,r,a,o,s){if(s>e&&s>n&&s>a||e>s&&n>s&&a>s)return 0;var l=f.quadraticRootAt(e,n,a,s,y);if(0===l)return 0;var u=f.quadraticExtremum(e,n,a);if(u>=0&&1>=u){for(var c=0,h=f[fi](e,n,a,u),d=0;l>d;d++){var p=f[fi](t,i,r,y[d]);p>o||(c+=y[d]h?1:-1:h>a?1:-1)}return c}var p=f[fi](t,i,r,y[0]);return p>o?0:e>a?1:-1}function a(t,e,i,n,r,a,o,s){if(s-=e,s>i||-i>s)return 0;var l=Math.sqrt(i*i-s*s);y[0]=-l,y[1]=l;var u=Math.abs(n-r);if(1e-4>u)return 0;if(1e-4>u%m){n=0,r=m;var c=a?1:-1;return o>=y[0]+t&&o<=y[1]+t?c:0}if(a){var l=n;n=d(r),r=d(l)}else n=d(n),r=d(r);n>r&&(r+=m);for(var h=0,f=0;2>f;f++){var p=y[f];if(p+t>o){var v=Math.atan2(s,p),c=a?1:-1;0>v&&(v=m+v),(v>=n&&r>=v||v+m>=n&&r>=v+m)&&(v>Math.PI/2&&v<1.5*Math.PI&&(c=-c),h+=c)}}return h}function o(t,i,o,l,d){for(var f=0,m=0,g=0,y=0,x=0,_=0;_1&&(o||(f+=p(m,g,y,x,l,d)),0!==f))return!0;switch(1==_&&(m=t[_],g=t[_+1],y=m,x=g),w){case s.M:y=t[_++],x=t[_++],m=y,g=x;break;case s.L:if(o){if(v(m,g,t[_],t[_+1],i,l,d))return!0}else f+=p(m,g,t[_],t[_+1],l,d)||0;m=t[_++],g=t[_++];break;case s.C:if(o){if(u.containStroke(m,g,t[_++],t[_++],t[_++],t[_++],t[_],t[_+1],i,l,d))return!0}else f+=n(m,g,t[_++],t[_++],t[_++],t[_++],t[_],t[_+1],l,d)||0;m=t[_++],g=t[_++];break;case s.Q:if(o){if(c.containStroke(m,g,t[_++],t[_++],t[_],t[_+1],i,l,d))return!0}else f+=r(m,g,t[_++],t[_++],t[_],t[_+1],l,d)||0;m=t[_++],g=t[_++];break;case s.A:var b=t[_++],M=t[_++],S=t[_++],A=t[_++],C=t[_++],T=t[_++],k=(t[_++],1-t[_++]),L=Math.cos(C)*S+b,I=Math.sin(C)*A+M;_>1?f+=p(m,g,L,I,l,d):(y=L,x=I);var D=(l-b)*A/S+b;if(o){if(h.containStroke(b,M,A,C,C+T,k,i,D,d))return!0}else f+=a(b,M,A,C,C+T,k,D,d);m=Math.cos(C+T)*S+b,g=Math.sin(C+T)*A+M;break;case s.R:y=m=t[_++],x=g=t[_++];var P=t[_++],z=t[_++],L=y+P,I=x+z;if(o){if(v(y,x,L,x,i,l,d)||v(L,x,L,I,i,l,d)||v(L,I,y,I,i,l,d)||v(y,I,L,I,i,l,d))return!0}else f+=p(L,x,L,I,l,d),f+=p(y,I,y,x,l,d);break;case s.Z:if(o){if(v(m,g,y,x,i,l,d))return!0}else if(f+=p(m,g,y,x,l,d),0!==f)return!0;m=y,g=x}}return o||e(g,x)||(f+=p(m,g,y,x,l,d)||0),0!==f}var s=t("../core/PathProxy").CMD,l=t("./line"),u=t("./cubic"),c=t("./quadratic"),h=t("./arc"),d=t("./util").normalizeRadian,f=t("../core/curve"),p=t("./windingLine"),v=l.containStroke,m=2*Math.PI,g=1e-4,y=[-1,-1,-1],x=[-1,-1];return{contain:function(t,e,i){return o(t,0,!1,e,i)},containStroke:function(t,e,i,n){return o(t,e,!0,i,n)}}}),e(si,[ia,"./Displayable",sr,"../core/PathProxy","../contain/path","./Gradient"],function(t){function e(t){var e=t.fill;return null!=e&&"none"!==e}function i(t){var e=t[br];return null!=e&&"none"!==e&&t[Mr]>0}function n(t){r.call(this,t),this.path=new o}var r=t("./Displayable"),a=t(sr),o=t("../core/PathProxy"),s=t("../contain/path"),l=t("./Gradient"),u=Math.abs;return n[ea]={constructor:n,type:"path",__dirtyPath:!0,strokeContainThreshold:5,brush:function(t){t.save();var n=this.style,r=this.path,a=i(n),o=e(n);this.__dirtyPath&&(o&&n.fill instanceof l&&n.fill.updateCanvasGradient(this,t),a&&n[br]instanceof l&&n[br].updateCanvasGradient(this,t)),n.bind(t,this),this.setTransform(t);var s=n.lineDash,u=n.lineDashOffset,c=!!t.setLineDash;this.__dirtyPath||s&&!c&&a?(r=this.path[di](t),s&&!c&&(r.setLineDash(s),r.setLineDashOffset(u)),this[oi](r,this.shape),this.__dirtyPath=!1):(t[di](),this.path.rebuildPath(t)),o&&r.fill(t),s&&c&&(t.setLineDash(s),t.lineDashOffset=u),a&&r[br](t),null!=n.text&&this.drawRectText(t,this[tr]()),t[ai]()},buildPath:function(t,e){},getBoundingRect:function(){var t=this._rect,n=this.style;if(!t){var r=this.path;this.__dirtyPath&&(r[di](),this[oi](r,this.shape)),t=r[tr]()}if(i(n)&&(this[Di]||!this._rect)){var a=this._rectWithStroke||(this._rectWithStroke=t.clone());a.copy(t);var o=n[Mr],s=n.strokeNoScale?this.getLineScale():1;return e(n)||(o=Math.max(o,this.strokeContainThreshold)),s>1e-10&&(a.width+=o/s,a[hr]+=o/s,a.x-=o/s/2,a.y-=o/s/2),a}return this._rect=t,t},contain:function(t,n){var r=this[Fi](t,n),a=this[tr](),o=this.style;if(t=r[0],n=r[1],a[pi](t,n)){var l=this.path.data;if(i(o)){var u=o[Mr],c=o.strokeNoScale?this.getLineScale():1;if(c>1e-10&&(e(o)||(u=Math.max(u,this.strokeContainThreshold)),s.containStroke(l,u/c,t,n)))return!0}if(e(o))return s[pi](l,t,n)}return!1},dirty:function(t){0===arguments[Kr]&&(t=!0),t&&(this.__dirtyPath=t,this._rect=null),this[Di]=!0,this.__zr&&this.__zr[Pi](),this.__clipTarget&&this.__clipTarget.dirty()},animateShape:function(t){return this[Vi]("shape",t)},attrKV:function(t,e){"shape"===t?this[ri](e):r[ea].attrKV.call(this,t,e)},setShape:function(t,e){var i=this.shape;if(i){if(a[In](t))for(var n in t)i[n]=t[n];else i[t]=e;this.dirty(!0)}return this},getLineScale:function(){var t=this[Xi];return t&&u(t[0]-1)>1e-10&&u(t[3]-1)>1e-10?Math.sqrt(u(t[0]*t[3]-t[2]*t[1])):1}},n[Lr]=function(t){var e=function(e){n.call(this,e),t.style&&this.style.extendFrom(t.style,!1);var i=t.shape;if(i){this.shape=this.shape||{};var r=this.shape;for(var a in i)!r.hasOwnProperty(a)&&i.hasOwnProperty(a)&&(r[a]=i[a])}t.init&&t.init.call(this,e)};a[Tr](e,n);for(var i in t)"style"!==i&&"shape"!==i&&(e[ea][i]=t[i]);return e},a[Tr](n,r),n}),e("zrender/tool/transformPath",[ia,"../core/PathProxy","../core/vector"],function(t){function e(t,e){var n,l,u,c,h,d,f=t.data,p=i.M,v=i.C,m=i.L,g=i.R,y=i.A,x=i.Q;for(u=0,c=0;uh;h++){var d=a[h];d[0]=f[u++],d[1]=f[u++],r(d,d,e),f[c++]=d[0],f[c++]=d[1]}}}var i=t("../core/PathProxy").CMD,n=t("../core/vector"),r=n[dr],a=[[],[],[]],o=Math.sqrt,s=Math.atan2;return e}),e("zrender/tool/path",[ia,"../graphic/Path","../core/PathProxy","./transformPath","../core/matrix"],function(t){function e(t,e,i,n,r,a,o,s,l,f,m){var g=l*(d/180),y=h(g)*(t-i)/2+c(g)*(e-n)/2,x=-1*c(g)*(t-i)/2+h(g)*(e-n)/2,_=y*y/(o*o)+x*x/(s*s);_>1&&(o*=u(_),s*=u(_));var w=(r===a?-1:1)*u((o*o*(s*s)-o*o*(x*x)-s*s*(y*y))/(o*o*(x*x)+s*s*(y*y)))||0,b=w*o*x/s,M=w*-s*y/o,S=(t+i)/2+h(g)*b-c(g)*M,A=(e+n)/2+c(g)*b+h(g)*M,C=v([1,0],[(y-b)/o,(x-M)/s]),T=[(y-b)/o,(x-M)/s],k=[(-1*y-b)/o,(-1*x-M)/s],L=v(T,k);p(T,k)<=-1&&(L=d),p(T,k)>=1&&(L=0),0===a&&L>0&&(L-=2*d),1===a&&0>L&&(L+=2*d),m.addData(f,S,A,o,s,C,L,g,a)}function i(t){if(!t)return[];var i,n=t[Zr](/-/g," -")[Zr](/ /g," ")[Zr](/ /g,",")[Zr](/,,/g,",");for(i=0;i0&&""===m[0]&&m.shift();for(var g=0;gn;n++)i=t[n],i[Di]&&i[oi](i.path,i.shape),a.push(i.path);var s=new r(e);return s[oi]=function(t){t.appendPath(a);var e=t[jr]();e&&t.rebuildPath(e)},s}}}),e("zrender/graphic/helper/roundRect",[ia],function(t){return{buildPath:function(t,e){var i,n,r,a,o=e.x,s=e.y,l=e.width,u=e[hr],c=e.r;0>l&&(o+=l,l=-l),0>u&&(s+=u,u=-u),typeof c===Wr?i=n=r=a=c:c instanceof Array?1===c[Kr]?i=n=r=a=c[0]:2===c[Kr]?(i=r=c[0],n=a=c[1]):3===c[Kr]?(i=c[0],n=a=c[1],r=c[2]):(i=c[0],n=c[1],r=c[2],a=c[3]):i=n=r=a=0;var h;i+n>l&&(h=i+n,i*=l/h,n*=l/h),r+a>l&&(h=r+a,r*=l/h,a*=l/h),n+r>u&&(h=n+r,n*=u/h,r*=u/h),i+a>u&&(h=i+a,i*=u/h,a*=u/h),t[hi](o+i,s),t[ci](o+l-n,s),0!==n&&t.quadraticCurveTo(o+l,s,o+l,s+n),t[ci](o+l,s+u-r),0!==r&&t.quadraticCurveTo(o+l,s+u,o+l-r,s+u),t[ci](o+a,s+u),0!==a&&t.quadraticCurveTo(o,s+u,o,s+u-a),t[ci](o,s+i),0!==i&&t.quadraticCurveTo(o,s,o+i,s)}}}),e("zrender/core/LRU",[ia],function(t){var e=function(){this.head=null,this.tail=null,this._len=0},i=e[ea];i.insert=function(t){var e=new n(t);return this.insertEntry(e),e},i.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,this.tail=t):this.head=this.tail=t,this._len++},i[Ii]=function(t){var e=t.prev,i=t.next;e?e.next=i:this.head=i,i?i.prev=e:this.tail=e,t.next=t.prev=null,this._len--},i.len=function(){return this._len};var n=function(t){this.value=t,this.next,this.prev},r=function(t){this._list=new e,this._map={},this._maxSize=t||10},a=r[ea];return a.put=function(t,e){var i=this._list,n=this._map;if(null==n[t]){var r=i.len();if(r>=this._maxSize&&r>0){var a=i.head;i[Ii](a),delete n[a.key]}var o=i.insert(e);o.key=t,n[t]=o}},a.get=function(t){var e=this._map[t],i=this._list;return null!=e?(e!==i.tail&&(i[Ii](e),i.insertEntry(e)),e.value):void 0},a.clear=function(){this._list.clear(),this._map={}},r}),e("zrender/graphic/Image",[ia,"./Displayable",or,sr,"./helper/roundRect","../core/LRU"],function(t){var e=t("./Displayable"),i=t(or),n=t(sr),r=t("./helper/roundRect"),a=t("../core/LRU"),o=new a(50),s=function(t){e.call(this,t)};return s[ea]={constructor:s,type:"image",brush:function(t){var e,i=this.style,n=i.image;if(e=typeof n===qr?this._image:n,!e&&n){var a=o.get(n);if(!a)return e=new Image,e.onload=function(){e.onload=null;for(var t=0;ts;s++)o+=i[vr](t[s-1],t[s]);var l=o/2;l=r>l?r:l;for(var s=0;l>s;s++){var u,c,h,d=s/(l-1)*(n?r:r-1),f=Math.floor(d),p=d-f,v=t[f%r];n?(u=t[(f-1+r)%r],c=t[(f+1)%r],h=t[(f+2)%r]):(u=t[0===f?f:f-1],c=t[f>r-2?r-1:f+1],h=t[f>r-3?r-1:f+2]);var m=p*p,g=p*m;a.push([e(u[0],v[0],c[0],h[0],p,m,g),e(u[1],v[1],c[1],h[1],p,m,g)])}return a}}),e("zrender/graphic/helper/smoothBezier",[ia,"../../core/vector"],function(t){var e=t("../../core/vector"),i=e.min,n=e.max,r=e.scale,a=e[vr],o=e.add;return function(t,s,l,u){var c,h,d,f,p=[],v=[],m=[],g=[];if(u){d=[1/0,1/0],f=[-(1/0),-(1/0)];for(var y=0,x=t[Kr];x>y;y++)i(d,d,t[y]),n(f,f,t[y]);i(d,d,u[0]),n(f,f,u[1])}for(var y=0,x=t[Kr];x>y;y++){var _=t[y];if(l)c=t[y?y-1:x-1],h=t[(y+1)%x];else{if(0===y||y===x-1){p.push(e.clone(t[y]));continue}c=t[y-1],h=t[y+1]}e.sub(v,h,c),r(v,v,s);var w=a(_,c),b=a(_,h),M=w+b;0!==M&&(w/=M,b/=M),r(m,v,-w),r(g,v,b);var S=o([],_,m),A=o([],_,g);u&&(n(S,S,d),i(S,S,f),n(A,A,d),i(A,A,f)),p.push(S),p.push(A)}return l&&p.push(p.shift()),p}}),e("zrender/graphic/helper/poly",[ia,"./smoothSpline","./smoothBezier"],function(t){var e=t("./smoothSpline"),i=t("./smoothBezier");return{buildPath:function(t,n,r){var a=n[$e],o=n.smooth;if(a&&a[Kr]>=2){if(o&&"spline"!==o){var s=i(a,o,r,n.smoothConstraint);t[hi](a[0][0],a[0][1]);for(var l=a[Kr],u=0;(r?l:l-1)>u;u++){var c=s[2*u],h=s[2*u+1],d=a[(u+1)%l];t[ui](c[0],c[1],h[0],h[1],d[0],d[1])}}else{"spline"===o&&(a=e(a,r)),t[hi](a[0][0],a[0][1]);for(var u=1,f=a[Kr];f>u;u++)t[ci](a[u][0],a[u][1])}r&&t[li]()}}}}),e("zrender/graphic/shape/Polygon",[ia,"../helper/poly","../Path"],function(t){var e=t("../helper/poly");return t("../Path")[Lr]({type:"polygon",shape:{points:null,smooth:!1,smoothConstraint:null},buildPath:function(t,i){e[oi](t,i,!0)}})}),e("zrender/graphic/shape/Polyline",[ia,"../helper/poly","../Path"],function(t){var e=t("../helper/poly");return t("../Path")[Lr]({type:"polyline", -shape:{points:null,smooth:!1,smoothConstraint:null},style:{stroke:"#000",fill:null},buildPath:function(t,i){e[oi](t,i,!1)}})}),e("zrender/graphic/shape/Rect",[ia,"../helper/roundRect","../Path"],function(t){var e=t("../helper/roundRect");return t("../Path")[Lr]({type:"rect",shape:{r:0,x:0,y:0,width:0,height:0},buildPath:function(t,i){var n=i.x,r=i.y,a=i.width,o=i[hr];i.r?e[oi](t,i):t.rect(n,r,a,o),t[li]()}})}),e("zrender/graphic/shape/Line",[ia,"../Path"],function(t){return t("../Path")[Lr]({type:"line",shape:{x1:0,y1:0,x2:0,y2:0,percent:1},style:{stroke:"#000",fill:null},buildPath:function(t,e){var i=e.x1,n=e.y1,r=e.x2,a=e.y2,o=e.percent;0!==o&&(t[hi](i,n),1>o&&(r=i*(1-o)+r*o,a=n*(1-o)+a*o),t[ci](r,a))},pointAt:function(t){var e=this.shape;return[e.x1*(1-t)+e.x2*t,e.y1*(1-t)+e.y2*t]}})}),e("zrender/graphic/shape/BezierCurve",[ia,"../../core/curve","../Path"],function(t){var e=t("../../core/curve"),i=e.quadraticSubdivide,n=e.cubicSubdivide,r=e[fi],a=e.cubicAt,o=[];return t("../Path")[Lr]({type:"bezier-curve",shape:{x1:0,y1:0,x2:0,y2:0,cpx1:0,cpy1:0,percent:1},style:{stroke:"#000",fill:null},buildPath:function(t,e){var r=e.x1,a=e.y1,s=e.x2,l=e.y2,u=e.cpx1,c=e.cpy1,h=e.cpx2,d=e.cpy2,f=e.percent;0!==f&&(t[hi](r,a),null==h||null==d?(1>f&&(i(r,u,s,f,o),u=o[1],s=o[2],i(a,c,l,f,o),c=o[1],l=o[2]),t.quadraticCurveTo(u,c,s,l)):(1>f&&(n(r,u,h,s,f,o),u=o[1],h=o[2],s=o[3],n(a,c,d,l,f,o),c=o[1],d=o[2],l=o[3]),t[ui](u,c,h,d,s,l)))},pointAt:function(t){var e=this.shape,i=e.cpx2,n=e.cpy2;return null===i||null===n?[r(e.x1,e.cpx1,e.x2,t),r(e.y1,e.cpy1,e.y2,t)]:[a(e.x1,e.cpx1,e.cpx1,e.x2,t),a(e.y1,e.cpy1,e.cpy1,e.y2,t)]}})}),e("zrender/graphic/shape/Arc",[ia,"../Path"],function(t){return t("../Path")[Lr]({type:"arc",shape:{cx:0,cy:0,r:0,startAngle:0,endAngle:2*Math.PI,clockwise:!0},style:{stroke:"#000",fill:null},buildPath:function(t,e){var i=e.cx,n=e.cy,r=Math.max(e.r,0),a=e[ii],o=e[ei],s=e[ti],l=Math.cos(a),u=Math.sin(a);t[hi](l*r+i,u*r+n),t.arc(i,n,r,a,o,!s)}})}),e("zrender/graphic/LinearGradient",[ia,sr,"./Gradient"],function(t){var e=t(sr),i=t("./Gradient"),n=function(t,e,n,r,a){this.x=null==t?0:t,this.y=null==e?0:e,this.x2=null==n?1:n,this.y2=null==r?0:r,i.call(this,a)};return n[ea]={constructor:n,type:"linear",updateCanvasGradient:function(t,e){for(var i=t[tr](),n=this.x*i.width+i.x,r=this.x2*i.width+i.x,a=this.y*i[hr]+i.y,o=this.y2*i[hr]+i.y,s=e.createLinearGradient(n,a,r,o),l=this.colorStops,u=0;u=0?"white":i,a=e[ir](er);h[Lr](t,{textDistance:e[Sr](vr)||5,textFont:a[$n](),textPosition:n,textFill:a[Be]()||r})},x[Ee]=h.curry(c,!0),x[Oe]=h.curry(c,!1),x.getTransform=function(t,e){for(var i=m.identity([]);t&&t!==e;)m.mul(i,t[qi](),i),t=t[Ui];return i},x[dr]=function(t,e,i){return i&&(e=m.invert([],e)),g[dr]([],t,e)},x.transformDirection=function(t,e,i){var n=0===e[4]||0===e[5]||0===e[0]?1:Math.abs(2*e[4]/e[0]),r=0===e[4]||0===e[5]||0===e[2]?1:Math.abs(2*e[4]/e[2]),a=["left"===t?-n:"right"===t?n:0,"top"===t?-r:t===Or?r:0];return a=x[dr](a,e,i),Math.abs(a[0])>Math.abs(a[1])?a[0]>0?"right":"left":a[1]>0?Or:"top"},x}),e(Ve,[],function(){function t(t){var e={},i={},n=t.match(/Web[kK]it[\/]{0,1}([\d.]+)/),r=t.match(/(Android);?[\s\/]+([\d.]+)?/),a=t.match(/(iPad).*OS\s([\d_]+)/),o=t.match(/(iPod)(.*OS\s([\d_]+))?/),s=!a&&t.match(/(iPhone\sOS)\s([\d_]+)/),l=t.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),u=l&&t.match(/TouchPad/),c=t.match(/Kindle\/([\d.]+)/),h=t.match(/Silk\/([\d._]+)/),d=t.match(/(BlackBerry).*Version\/([\d.]+)/),f=t.match(/(BB10).*Version\/([\d.]+)/),p=t.match(/(RIM\sTablet\sOS)\s([\d.]+)/),v=t.match(/PlayBook/),m=t.match(/Chrome\/([\d.]+)/)||t.match(/CriOS\/([\d.]+)/),g=t.match(/Firefox\/([\d.]+)/),y=n&&t.match(/Mobile\//)&&!m,x=t.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/)&&!m,_=t.match(/MSIE\s([\d.]+)/)||t.match(/Trident\/.+?rv:(([\d.]+))/),w=t.match(/Edge\/([\d.]+)/);return(i.webkit=!!n)&&(i.version=n[1]),r&&(e.android=!0,e.version=r[2]),s&&!o&&(e.ios=e.iphone=!0,e.version=s[2][Zr](/_/g,".")),a&&(e.ios=e.ipad=!0,e.version=a[2][Zr](/_/g,".")),o&&(e.ios=e.ipod=!0,e.version=o[3]?o[3][Zr](/_/g,"."):null),l&&(e.webos=!0,e.version=l[2]),u&&(e.touchpad=!0),d&&(e.blackberry=!0,e.version=d[2]),f&&(e.bb10=!0,e.version=f[2]),p&&(e.rimtabletos=!0,e.version=p[2]),v&&(i.playbook=!0),c&&(e.kindle=!0,e.version=c[1]),h&&(i.silk=!0,i.version=h[1]),!h&&e.android&&t.match(/Kindle Fire/)&&(i.silk=!0),m&&(i.chrome=!0,i.version=m[1]),g&&(i.firefox=!0,i.version=g[1]),_&&(i.ie=!0,i.version=_[1]),y&&(t.match(/Safari/)||e.ios)&&(i.safari=!0),x&&(i.webview=!0),_&&(i.ie=!0,i.version=_[1]),w&&(i.edge=!0,i.version=w[1]),e.tablet=!!(a||v||r&&!t.match(/Mobile/)||g&&t.match(/Tablet/)||_&&!t.match(/Phone/)&&t.match(/Touch/)),e.phone=!(e.tablet||e.ipod||!(r||s||l||d||f||m&&t.match(/Android/)||m&&t.match(/CriOS\/([\d.]+)/)||g&&t.match(/Mobile/)||_&&t.match(/Touch/))),{browser:i,os:e,node:!1,canvasSupported:document[Yr](Xr)[jr]?!0:!1,touchEventsSupported:"ontouchstart"in window&&!i.ie&&!i.edge,pointerEventsSupported:"onpointerdown"in window&&(i.edge||i.ie&&i.version>=10)}}var e={};return e=typeof navigator===mr?{browser:{},os:{},node:!0,canvasSupported:!0}:t(navigator.userAgent)}),e(Re,[ia,"../mixin/Eventful"],function(t){function e(t){return t.getBoundingClientRect?t.getBoundingClientRect():{left:0,top:0}}function i(t,i){if(i=i||window.event,null!=i.zrX)return i;var n=i.type,r=n&&n[Ur]("touch")>=0;if(r){var a="touchend"!=n?i.targetTouches[0]:i.changedTouches[0];if(a){var o=e(t);i.zrX=a.clientX-o.left,i.zrY=a.clientY-o.top}}else{var s=e(t);i.zrX=i.clientX-s.left,i.zrY=i.clientY-s.top,i.zrDelta=i.wheelDelta?i.wheelDelta/120:-(i.detail||0)/3}return i}function n(t,e,i){o?t.addEventListener(e,i):t.attachEvent("on"+e,i)}function r(t,e,i){o?t.removeEventListener(e,i):t.detachEvent("on"+e,i)}var a=t("../mixin/Eventful"),o=typeof window!==mr&&!!window.addEventListener,s=o?function(t){t.preventDefault(),t.stopPropagation(),t.cancelBubble=!0}:function(t){t.returnValue=!1,t.cancelBubble=!0};return{normalizeEvent:i,addEventListener:n,removeEventListener:r,stop:s,Dispatcher:a}}),e("zrender/mixin/Draggable",[ia],function(t){function e(){this.on(ze,this._dragStart,this),this.on(Pe,this._drag,this),this.on(De,this._dragEnd,this),this.on("globalout",this._dragEnd,this)}return e[ea]={constructor:e,_dragStart:function(t){var e=t[Zi];e&&e[Ri]&&(this._draggingTarget=e,e.dragging=!0,this._x=t[Ie],this._y=t[Le],this._dispatchProxy(e,"dragstart",t.event))},_drag:function(t){var e=this._draggingTarget;if(e){var i=t[Ie],n=t[Le],r=i-this._x,a=n-this._y;this._x=i,this._y=n,e.drift(r,a,t),this._dispatchProxy(e,"drag",t.event);var o=this.findHover(i,n,e),s=this._dropTarget;this._dropTarget=o,e!==o&&(s&&o!==s&&this._dispatchProxy(s,"dragleave",t.event),o&&o!==s&&this._dispatchProxy(o,"dragenter",t.event))}},_dragEnd:function(t){var e=this._draggingTarget;e&&(e.dragging=!1),this._dispatchProxy(e,"dragend",t.event),this._dropTarget&&this._dispatchProxy(this._dropTarget,"drop",t.event),this._draggingTarget=null,this._dropTarget=null}},e}),e("zrender/core/GestureMgr",[ia],function(t){function e(t){var e=t[1][0]-t[0][0],i=t[1][1]-t[0][1];return Math.sqrt(e*e+i*i)}function i(t){return[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2]}var n=function(){this._track=[]};n[ea]={constructor:n,recognize:function(t,e){return this._doTrack(t,e),this._recognize(t)},clear:function(){return this._track[Kr]=0,this},_doTrack:function(t,e){var i=t.touches;if(i){for(var n={points:[],touches:[],target:e,event:t},r=0,a=i[Kr];a>r;r++){var o=i[r];n[$e].push([o.clientX,o.clientY]),n.touches.push(o)}this._track.push(n)}},_recognize:function(t){for(var e in r)if(r.hasOwnProperty(e)){var i=r[e](this._track,t);if(i)return i}}};var r={pinch:function(t,n){var r=t[Kr];if(r){var a=(t[r-1]||{})[$e],o=(t[r-2]||{})[$e]||a;if(o&&o[Kr]>1&&a&&a[Kr]>1){var s=e(a)/e(o);!isFinite(s)&&(s=1),n.pinchScale=s;var l=i(a);return n.pinchX=l[0],n.pinchY=l[1],{type:"pinch",target:t[0][Zi],event:n}}}}};return n}),e("zrender/Handler",[ia,"./core/env","./core/event","./core/util","./mixin/Draggable","./core/GestureMgr","./mixin/Eventful"],function(t){function e(t,e,i){return{type:t,event:i,target:e,cancelBubble:!1,offsetX:i.zrX,offsetY:i.zrY,gestureEvent:i.gestureEvent,pinchX:i.pinchX,pinchY:i.pinchY,pinchScale:i.pinchScale,wheelDelta:i.zrDelta}}function i(t,e,i){var n=t._gestureMgr;"start"===i&&n.clear();var r=n.recognize(e,t.findHover(e.zrX,e.zrY,null));if("end"===i&&n.clear(),r){var a=r.type;e.gestureEvent=a,t._dispatchProxy(r[Zi],a,r.event)}}function n(t){function e(t,e){return function(){return e._touching?void 0:t.apply(e,arguments)}}for(var i=m[Hr](g),n=0;n=0;a--)if(!n[a][Ae]&&n[a]!==i&&r(n[a],t,e))return n[a]}},h.mixin(M,p),h.mixin(M,d),M}),e("zrender/Storage",[ia,"./core/util","./container/Group"],function(t){function e(t,e){return t[Se]===e[Se]?t.z===e.z?t.z2===e.z2?t.__renderidx-e.__renderidx:t.z2-e.z2:t.z-e.z:t[Se]-e[Se]}var i=t("./core/util"),n=t("./container/Group"),r=function(){this._elements={},this._roots=[],this._displayList=[],this._displayListLen=0};return r[ea]={constructor:r,getDisplayList:function(t){return t&&this.updateDisplayList(),this._displayList},updateDisplayList:function(){this._displayListLen=0;for(var t=this._roots,i=this._displayList,n=0,r=t[Kr];r>n;n++){var a=t[n];this._updateAndAddDisplayable(a)}i[Kr]=this._displayListLen;for(var n=0,r=i[Kr];r>n;n++)i[n].__renderidx=n;i.sort(e)},_updateAndAddDisplayable:function(t,e){if(!t[zi]){t.beforeUpdate(),t[on](),t.afterUpdate();var i=t.clipPath;if(i&&(i[Ui]=t,i[ji](),e?(e=e.slice(),e.push(i)):e=[i]),"group"==t.type){for(var n=t._children,r=0;re;e++)this.delRoot(t[e]);else{var o;o=typeof t==qr?this._elements[t]:t;var s=i[Ur](this._roots,o);s>=0&&(this[ki](o.id),this._roots[fn](s,1),o instanceof n&&o.delChildrenFromStorage(this))}},addToMap:function(t){return t instanceof n&&(t.__storage=this),t.dirty(),this._elements[t.id]=t,this},get:function(t){return this._elements[t]},delFromMap:function(t){var e=this._elements,i=e[t];return i&&(delete e[t],i instanceof n&&(i.__storage=null)),this},dispose:function(){this._elements=this._renderList=this._roots=null}},r}),e("zrender/animation/Animation",[ia,sr,"../core/event","./Animator"],function(t){var e=t(sr),i=t("../core/event").Dispatcher,n=typeof window!==mr&&(window.requestAnimationFrame||window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(t){setTimeout(t,16)},r=t("./Animator"),a=function(t){t=t||{},this.stage=t.stage||{},this.onframe=t.onframe||function(){},this._clips=[],this._running=!1,this._time=0,i.call(this)};return a[ea]={constructor:a,addClip:function(t){this._clips.push(t)},addAnimator:function(t){t[Bi]=this;for(var e=t.getClips(),i=0;i=0&&this._clips[fn](i,1)},removeAnimator:function(t){for(var e=t.getClips(),i=0;io;o++){var s=i[o],l=s.step(t);l&&(r.push(l),a.push(s))}for(var o=0;n>o;)i[o]._needsRemove?(i[o]=i[n-1],i.pop(),n--):o++;n=r[Kr];for(var o=0;n>o;o++)a[o].fire(r[o]);this._time=t,this.onframe(e),this[bi]("frame",e),this.stage[on]&&this.stage[on]()},start:function(){function t(){e._running&&(n(t),e._update())}var e=this;this._running=!0,this._time=(new Date).getTime(),n(t)},stop:function(){this._running=!1},clear:function(){this._clips=[]},animate:function(t,e){e=e||{};var i=new r(t,e.loop,e.getter,e.setter);return i}},e.mixin(a,i),a}),e("zrender/Layer",[ia,"./core/util","./config"],function(t){function e(){return!1}function i(t,e,i,n){var r=document[Yr](e),a=i[un](),o=i[ln](),s=r.style;return s[Tn]="absolute",s.left=0,s.top=0,s.width=a+"px",s[hr]=o+"px",r.width=a*n,r[hr]=o*n,r.setAttribute("data-zr-dom-id",t),r}var n=t("./core/util"),r=t("./config"),a=function(t,a,o){var s;o=o||r.devicePixelRatio,typeof t===qr?s=i(t,Xr,a,o):n[In](t)&&(s=t,t=s.id),this.id=t,this.dom=s;var l=s.style;l&&(s.onselectstart=e,l["-webkit-user-select"]="none",l["user-select"]="none",l["-webkit-touch-callout"]="none",l["-webkit-tap-highlight-color"]="rgba(0,0,0,0)"),this.domBack=null,this.ctxBack=null,this.painter=a,this.config=null,this.clearColor=0,this.motionBlur=!1,this.lastFrameAlpha=.7,this.dpr=o};return a[ea]={constructor:a,elCount:0,__dirty:!0,initContext:function(){this.ctx=this.dom[jr]("2d");var t=this.dpr;1!=t&&this.ctx.scale(t,t)},createBackBuffer:function(){var t=this.dpr;this.domBack=i("back-"+this.id,Xr,this.painter,t),this.ctxBack=this.domBack[jr]("2d"),1!=t&&this.ctxBack.scale(t,t)},resize:function(t,e){var i=this.dpr,n=this.dom,r=n.style,a=this.domBack;r.width=t+"px",r[hr]=e+"px",n.width=t*i,n[hr]=e*i,1!=i&&this.ctx.scale(i,i),a&&(a.width=t*i,a[hr]=e*i,1!=i&&this.ctxBack.scale(i,i))},clear:function(t){var e=this.dom,i=this.ctx,n=e.width,r=e[hr],a=this.clearColor,o=this.motionBlur&&!t,s=this.lastFrameAlpha,l=this.dpr;if(o&&(this.domBack||this.createBackBuffer(),this.ctxBack.globalCompositeOperation="copy",this.ctxBack.drawImage(e,0,0,n/l,r/l)),i.clearRect(0,0,n/l,r/l),a&&(i.save(),i.fillStyle=this.clearColor,i.fillRect(0,0,n/l,r/l),i[ai]()),o){var u=this.domBack;i.save(),i.globalAlpha=s,i.drawImage(u,0,0,n/l,r/l),i[ai]()}}},a}),e("zrender/Painter",[ia,"./config","./core/util","./core/log","./core/BoundingRect","./Layer","./graphic/Image"],function(t){function e(t){return parseInt(t,10)}function i(t){return t?t.isBuildin?!0:typeof t[Me]!==Fr||typeof t[Pi]!==Fr?!1:!0:!1}function n(t){t.__unusedCount++}function r(t){t[Di]=!1,1==t.__unusedCount&&t.clear()}function a(t,e,i){return f.copy(t[tr]()),t[Xi]&&f[dr](t[Xi]),p.width=e,p[hr]=i,!f[be](p)}function o(t,e){if(!t||!e||t[Kr]!==e[Kr])return!0;for(var i=0;ip;p++){var m=t[p],g=this._singleCanvas?0:m[Se];if(l!==g&&(l=g,i=this.getLayer(l),i.isBuildin||c("ZLevel "+l+" has been used by unkown layer "+i.id),u=i.ctx,i.__unusedCount=0,(i[Di]||e)&&i.clear()),(i[Di]||e)&&!m[Ci]&&0!==m.style[wr]&&m.scale[0]&&m.scale[1]&&(!m.culling||!a(m,h,d))){var y=m.__clipPaths;o(y,f)&&(f&&u[ai](),y&&(u.save(),s(y,u)),f=y),m.beforeBrush&&m.beforeBrush(u),m.brush(u,!1),m.afterBrush&&m.afterBrush(u)}m[Di]=!1}f&&u[ai](),this.eachBuildinLayer(r)},getLayer:function(t){if(this._singleCanvas)return this._layers[0];var e=this._layers[t];return e||(e=new d("zr_"+t,this,this.dpr),e.isBuildin=!0,this._layerConfig[t]&&u.merge(e,this._layerConfig[t],!0),this.insertLayer(t,e),e.initContext()),e},insertLayer:function(t,e){var n=this._layers,r=this._zlevelList,a=r[Kr],o=null,s=-1,l=this._domRoot;if(n[t])return void c("ZLevel "+t+" has been used already");if(!i(e))return void c("Layer of zlevel "+t+" is not valid");if(a>0&&t>r[0]){for(s=0;a-1>s&&!(r[s]t);s++);o=n[r[s]]}if(r[fn](s+1,0,t),o){var u=o.dom;u.nextSibling?l.insertBefore(e.dom,u.nextSibling):l[_e](e.dom)}else l.firstChild?l.insertBefore(e.dom,l.firstChild):l[_e](e.dom);n[t]=e},eachLayer:function(t,e){var i,n,r=this._zlevelList;for(n=0;nn;n++){var a=t[n],o=this._singleCanvas?0:a[Se],s=e[o];if(s){if(s.elCount++,s[Di])continue;s[Di]=a[Di]}}this.eachBuildinLayer(function(t,e){i[e]!==t.elCount&&(t[Di]=!0)})},clear:function(){return this.eachBuildinLayer(this._clearLayer),this},_clearLayer:function(t){t.clear()},configLayer:function(t,e){if(e){var i=this._layerConfig;i[t]?u.merge(i[t],e,!0):i[t]=e;var n=this._layers[t];n&&u.merge(n,i[t],!0)}},delLayer:function(t){var e=this._layers,i=this._zlevelList,n=e[t];n&&(n.dom[ke].removeChild(n.dom),delete e[t],i[fn](u[Ur](i,t),1))},resize:function(t,e){var i=this._domRoot;if(i.style.display="none",t=t||this._getWidth(),e=e||this._getHeight(),i.style.display="",this._width!=t||e!=this._height){i.style.width=t+"px",i.style[hr]=e+"px";for(var n in this._layers)this._layers[n][Me](t,e);this[Pi](!0)}return this._width=t,this._height=e,this},clearLayer:function(t){var e=this._layers[t];e&&e.clear()},dispose:function(){this.root[we]="",this.root=this[Te]=this._domRoot=this._layers=null},getRenderedCanvas:function(t){if(t=t||{},this._singleCanvas)return this._layers[0].dom;var e=new d("image",this,t.pixelRatio||this.dpr);e.initContext();var i=e.ctx;e.clearColor=t[xe],e.clear();for(var n=this[Te][Ce](!0),r=0;rt;t++)this._add&&this._add(u[t]);else this._add&&this._add(u)}}},i}),e("echarts/data/List",[ia,"../model/Model","./DataDiffer",ta,"../util/model"],function(t){function e(t){return c[Dr](t)||(t=[t]),t}function i(t,e){var i=t[Ht],n=new v(c.map(i,t.getDimensionInfo,t),t[$t]);p(n,t,t._wrappedMethods);for(var r=n._storage={},a=t._storage,o=0;o=0?r[s]=new l.constructor(a[s][Kr]):r[s]=a[s]}return n}var n=mr,r=typeof window===mr?global:window,a=typeof r.Float64Array===n?Array:r.Float64Array,o=typeof r.Int32Array===n?Array:r.Int32Array,s={"float":a,"int":o,ordinal:Array,number:Array,time:Array},l=t("../model/Model"),u=t("./DataDiffer"),c=t(ta),h=t("../util/model"),d=c[In],f=["stackedOn","_nameList","_idList","_rawData"],p=function(t,e,i){c.each(f[Hr](i||[]),function(i){e.hasOwnProperty(i)&&(t[i]=e[i])})},v=function(t,e){t=t||["x","y"];for(var i={},n=[],r=0;r0&&(w+="__ec__"+d[b]),d[b]++),w&&(u[f]=w)}this._nameList=e,this._idList=u},m.count=function(){return this.indices[Kr]},m.get=function(t,e,i){var n=this._storage,r=this.indices[e],a=n[t]&&n[t][r];if(i){var o=this._dimensionInfos[t];if(o&&o.stackable)for(var s=this.stackedOn;s;){var l=s.get(t,e);(a>=0&&l>0||0>=a&&0>l)&&(a+=l),s=s.stackedOn}}return a},m[Gt]=function(t,e,i){var n=[];c[Dr](t)||(i=e,e=t,t=this[Ht]);for(var r=0,a=t[Kr];a>r;r++)n.push(this.get(t[r],e,i));return n},m.hasValue=function(t){for(var e=this[Ht],i=this._dimensionInfos,n=0,r=e[Kr];r>n;n++)if(i[e[n]].type!==En&&isNaN(this.get(e[n],t)))return!1;return!0},m[Bt]=function(t,e){var i=this._storage[t],n=this.getDimensionInfo(t);e=n&&n.stackable&&e;var r,a=(this._extent||(this._extent={}))[t+!!e];if(a)return a;if(i){for(var o=1/0,s=-(1/0),l=0,u=this.count();u>l;l++)r=this.get(t,l,e),o>r&&(o=r),r>s&&(s=r);return this._extent[t+e]=[o,s]}return[1/0,-(1/0)]},m[Nt]=function(t,e){var i=this._storage[t],n=0;if(i)for(var r=0,a=this.count();a>r;r++){var o=this.get(t,r,e);isNaN(o)||(n+=o)}return n},m[Ur]=function(t,e){var i=this._storage,n=i[t],r=this.indices;if(n)for(var a=0,o=r[Kr];o>a;a++){var s=r[a];if(n[s]===e)return a}return-1},m[xi]=function(t){for(var e=this.indices,i=this._nameList,n=0,r=e[Kr];r>n;n++){var a=e[n];if(i[a]===t)return n}return-1},m.indexOfNearest=function(t,e,i){var n=this._storage,r=n[t];if(r){for(var a=Number.MAX_VALUE,o=-1,s=0,l=this.count();l>s;s++){var u=Math.abs(this.get(t,s,i)-e);a>=u&&(a=u,o=s)}return o}return-1},m[Vn]=function(t){var e=this.indices[t];return null==e?-1:e},m[Rn]=function(t){return this._nameList[this.indices[t]]||""},m.getId=function(t){return this._idList[this.indices[t]]||this[Vn](t)+""},m.each=function(t,i,n,r){typeof t===Fr&&(r=n,n=i,i=t,t=[]),t=c.map(e(t),this[Ft],this);var a=[],o=t[Kr],s=this.indices;r=r||this;for(var l=0;lu;u++)a[u]=this.get(t[u],l,n);a[u]=l,i.apply(r,a)}},m[Et]=function(t,i,n,r){typeof t===Fr&&(r=n,n=i,i=t,t=[]),t=c.map(e(t),this[Ft],this);var a=[],o=[],s=t[Kr],l=this.indices;r=r||this;for(var u=0;ud;d++)o[d]=this.get(t[d],u,n);o[d]=u,h=i.apply(r,o)}h&&a.push(l[u])}return this.indices=a,this._extent={},this},m[Ot]=function(t,e,i,n){typeof t===Fr&&(n=i,i=e,e=t,t=[]);var r=[];return this.each(t,function(){r.push(e&&e.apply(this,arguments))},i,n),r},m.map=function(t,n,r,a){t=c.map(e(t),this[Ft],this);var o=i(this,t),s=o.indices=this.indices,l=o._storage,u=[];return this.each(t,function(){var e=arguments[arguments[Kr]-1],i=n&&n.apply(this,arguments);if(null!=i){typeof i===Wr&&(u[0]=i,i=u);for(var r=0;rv;v+=d){d>p-v&&(d=p-v,c[Kr]=d);for(var m=0;d>m;m++){var g=l[v+m];c[m]=f[g],h[m]=g}var y=n(c),g=h[r(c,y)||0];f[g]=y,u.push(g)}return a},m[zn]=function(t){var e=this[$t];return t=this.indices[t],new l(this._rawData[t],e,e[nr])},m.diff=function(t){var e=this._idList,i=t&&t._idList;return new u(t?t.indices:[],this.indices,function(t){return i[t]||t+""},function(t){return e[t]||t+""})},m[Vt]=function(t){var e=this._visual;return e&&e[t]},m[ve]=function(t,e){if(d(t))for(var i in t)t.hasOwnProperty(i)&&this[ve](i,t[i]);else this._visual=this._visual||{},this._visual[t]=e},m[Rt]=function(t,e){if(d(t))for(var i in t)t.hasOwnProperty(i)&&this[Rt](i,t[i]);else this._layout[t]=e},m[zt]=function(t){return this._layout[t]},m[Pt]=function(t){return this._itemLayouts[t]},m[Dt]=function(t,e,i){this._itemLayouts[t]=i?c[Lr](this._itemLayouts[t]||{},e):e},m[It]=function(t,e,i){var n=this._itemVisuals[t],r=n&&n[e];return null!=r||i?r:this[Vt](e)},m[fe]=function(t,e,i){var n=this._itemVisuals[t]||{};if(this._itemVisuals[t]=n,d(e))for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);else n[e]=i};var g=function(t){t[Bn]=this[Bn],t[wi]=this[wi]};return m[Lt]=function(t,e){var i=this[$t];e&&(e[wi]=t,e[Bn]=i&&i[Bn],"group"===e.type&&e[Ti](g,e)),this._graphicEls[t]=e},m[_i]=function(t){return this._graphicEls[t]},m[yi]=function(t,e){c.each(this._graphicEls,function(i,n){i&&t&&t.call(e,i,n)})},m.cloneShallow=function(){var t=c.map(this[Ht],this.getDimensionInfo,this),e=new v(t,this[$t]);return e._storage=this._storage,p(e,this,this._wrappedMethods),e.indices=this.indices.slice(),e},m.wrapMethod=function(t,e){var i=this[t];typeof i===Fr&&(this._wrappedMethods=this._wrappedMethods||[],this._wrappedMethods.push(t),this[t]=function(){var t=i.apply(this,arguments);return e.call(this,t)})},v}),e("echarts/data/helper/completeDimensions",[ia,ta],function(t){function e(t,e,a){if(!e)return t;var o=n(e[0]),s=r[Dr](o)&&o[Kr]||1;a=a||[];for(var l=0;s>l;l++)if(!t[l]){var u=a[l]||"extra"+(l-a[Kr]);t[l]=i(e,l)?{type:"ordinal",name:u}:u}return t}function i(t,e){for(var i=0,a=t[Kr];a>i;i++){var o=n(t[i]);if(!r[Dr](o))return!1;var o=o[e];if(null!=o&&isFinite(o))return!1;if(r[dn](o)&&"-"!==o)return!0}return!1}function n(t){return r[Dr](t)?t:r[In](t)?t.value:t}var r=t(ta);return e}),e("echarts/chart/helper/createListFromArray",[ia,kt,Tt,ta,Ct,At],function(t){function e(t){for(var e=0;e1){i=[];for(var a=0;r>a;a++)i[a]=n[e[a][0]]}else i=n.slice(0)}}return i}var s=t(kt),l=t(Tt),u=t(ta),c=t(Ct),h=t(At),d=c.getDataItemValue,f=c.converDataValue,p={cartesian2d:function(t,e,i){var n=i[rn]("xAxis",e.get("xAxisIndex")),o=i[rn]("yAxis",e.get("yAxisIndex")),s=n.get("type"),u=o.get("type"),c=[{name:"x",type:a(s),stackable:r(s)},{name:"y",type:a(u),stackable:r(u)}];return l(c,t,["x","y","z"]),{dimensions:c,categoryAxisModel:s===St?n:u===St?o:null}},polar:function(t,e,i){var n=e.get("polarIndex")||0,o=function(t){return t.get("polarIndex")===n},s=i[hn]({mainType:"angleAxis",filter:o})[0],u=i[hn]({mainType:"radiusAxis",filter:o})[0],c=u.get("type"),h=s.get("type"),d=[{name:"radius",type:a(c),stackable:r(c)},{name:"angle",type:a(h),stackable:r(h)}];return l(d,t,[jn,"angle","value"]),{dimensions:d,categoryAxisModel:h===St?s:c===St?u:null}},geo:function(t,e,i){return{dimensions:l([{name:"lng"},{name:"lat"}],t,["lng","lat","value"])}}};return n}),e("echarts/chart/line/LineSeries",[ia,bt,wt],function(t){var e=t(bt),i=t(wt);return i[Lr]({type:"series.line",dependencies:["grid","polar"],getInitialData:function(t,i){return e(t.data,this,i)},defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,hoverAnimation:!0,xAxisIndex:0,yAxisIndex:0,polarIndex:0,clipOverflow:!0,label:{normal:{position:"top"},emphasis:{position:"top"}},lineStyle:{normal:{width:2,type:"solid"}},symbol:"emptyCircle",symbolSize:4,showSymbol:!0,animationEasing:"linear"}})}),e("echarts/util/symbol",[ia,"./graphic",fr],function(t){var e=t("./graphic"),i=t(fr),n=e[je]({type:"triangle",shape:{cx:0,cy:0,width:0,height:0},buildPath:function(t,e){var i=e.cx,n=e.cy,r=e.width/2,a=e[hr]/2;t[hi](i,n-a),t[ci](i+r,n+a),t[ci](i-r,n+a),t[li]()}}),r=e[je]({type:"diamond",shape:{cx:0,cy:0,width:0,height:0},buildPath:function(t,e){var i=e.cx,n=e.cy,r=e.width/2,a=e[hr]/2;t[hi](i,n-a),t[ci](i+r,n),t[ci](i,n+a),t[ci](i-r,n),t[li]()}}),a=e[je]({type:"pin",shape:{x:0,y:0,width:0,height:0},buildPath:function(t,e){var i=e.x,n=e.y,r=e.width/5*3,a=Math.max(r,e[hr]),o=r/2,s=o*o/(a-o),l=n-a+o+s,u=Math.asin(s/o),c=Math.cos(u)*o,h=Math.sin(u),d=Math.cos(u);t.arc(i,l,o,Math.PI-u,2*Math.PI+u);var f=.6*o,p=.7*o;t[ui](i+c-h*f,l+s+d*f,i,n-p,i,n),t[ui](i,n-p,i-c+h*f,l+s+d*f,i-c,l+s),t[li]()}}),o=e[je]({type:"arrow",shape:{x:0,y:0,width:0,height:0},buildPath:function(t,e){var i=e[hr],n=e.width,r=e.x,a=e.y,o=n/3*2;t[hi](r,a),t[ci](r+o,a+i),t[ci](r,a+i/4*3),t[ci](r-o,a+i),t[ci](r,a),t[li]()}}),s={line:e.Line,rect:e.Rect,roundRect:e.Rect,square:e.Rect,circle:e[Je],diamond:r,pin:a,arrow:o,triangle:n},l={line:function(t,e,i,n,r){r.x1=t,r.y1=e+n/2,r.x2=t+i,r.y2=e+n/2},rect:function(t,e,i,n,r){r.x=t,r.y=e,r.width=i,r[hr]=n},roundRect:function(t,e,i,n,r){r.x=t,r.y=e,r.width=i,r[hr]=n,r.r=Math.min(i,n)/4},square:function(t,e,i,n,r){var a=Math.min(i,n);r.x=t,r.y=e,r.width=a,r[hr]=a},circle:function(t,e,i,n,r){r.cx=t+i/2,r.cy=e+n/2,r.r=Math.min(i,n)/2},diamond:function(t,e,i,n,r){r.cx=t+i/2,r.cy=e+n/2,r.width=i,r[hr]=n},pin:function(t,e,i,n,r){r.x=t+i/2,r.y=e+n/2,r.width=i,r[hr]=n},arrow:function(t,e,i,n,r){r.x=t+i/2,r.y=e+n/2,r.width=i,r[hr]=n},triangle:function(t,e,i,n,r){r.cx=t+i/2,r.cy=e+n/2,r.width=i,r[hr]=n}},u={};for(var c in s)u[c]=new s[c];var h=e[je]({type:"symbol",shape:{symbolType:"",x:0,y:0,width:0,height:0},beforeBrush:function(){var t=this.style,e=this.shape;"pin"===e.symbolType&&t[gi]===ar&&(t[gi]=["50%","40%"],t[mi]=Nr,t[vi]=Er)},buildPath:function(t,e){var i=e.symbolType,n=u[i];"none"!==e.symbolType&&(n||(i="rect",n=u[i]),l[i](e.x,e.y,e.width,e[hr],n.shape),n[oi](t,n.shape))}}),d=function(t){if("image"!==this.type){var e=this.style,i=this.shape;i&&"line"===i.symbolType?e[br]=t:this.__isEmptyBrush?(e[br]=t,e.fill="#fff"):(e.fill&&(e.fill=t),e[br]&&(e[br]=t)),this.dirty()}},f={createSymbol:function(t,n,r,a,o,s){var l=0===t[Ur]("empty");l&&(t=t.substr(5,1)[zr]()+t.substr(6));var u;return u=0===t[Ur]("image://")?new e.Image({style:{image:t.slice(8),x:n,y:r,width:a,height:o}}):0===t[Ur]("path://")?e.makePath(t.slice(7),{},new i(n,r,a,o)):new h({shape:{symbolType:t,x:n,y:r,width:a,height:o}}),u.__isEmptyBrush=l,u[_t]=d,u[_t](s),u}};return f}),e("echarts/chart/helper/Symbol",[ia,ta,xt,yt,gt],function(t){function e(t){return r[Dr](t)||(t=[+t,+t]),t}function i(t,e){o.Group.call(this),this[mt](t,e)}function n(t,e){this[Ui].drift(t,e)}var r=t(ta),a=t(xt),o=t(yt),s=t(gt),l=i[ea];l._createSymbol=function(t,i,r){this[Si]();var s=i[$t],l=i[It](r,"color"),u=a[vt](t,-.5,-.5,1,1,l);u.attr({style:{strokeNoScale:!0},z2:100,culling:!0,scale:[0,0]}),u.drift=n;var c=e(i[It](r,pt));o[Oe](u,{scale:c},s),this._symbolType=t,this.add(u)},l.stopSymbolAnimation=function(t){this[Cn](0)[Oi](t)},l.getScale=function(){return this[Cn](0).scale},l[ee]=function(){this[Cn](0)[bi](Hn)},l[te]=function(){this[Cn](0)[bi](Fn)},l.setZ=function(t,e){var i=this[Cn](0);i[Se]=t,i.z=e},l.setDraggable=function(t){var e=this[Cn](0);e[Ri]=t,e.cursor=t?"move":"pointer"},l[mt]=function(t,i){var n=t[It](i,ft)||dt,r=t[$t],a=e(t[It](i,pt));if(n!==this._symbolType)this._createSymbol(n,t,i);else{var s=this[Cn](0);o[Ee](s,{scale:a},r)}this._updateCommon(t,i,a),this._seriesModel=r};var u=[ue,Fn],c=[ue,Hn],h=["label",Fn],d=["label",Hn];return l._updateCommon=function(t,i,n){var a=this[Cn](0),l=t[$t],f=t[zn](i),p=f[ir](u),v=t[It](i,"color"),m=f[ir](c)[ht]();a[Ki]=f[Sr]("symbolRotate")*Math.PI/180||0;var g=f[Sr]("symbolOffset");if(g){var y=a[Tn];y[0]=s[Br](g[0],n[0]),y[1]=s[Br](g[1],n[1])}a[_t](v),r[Lr](a.style,p[ht](["color"]));for(var x,_=f[ir](h),w=f[ir](d),b=a.style,M=t[Ht].slice(),S=M.pop();(x=t.getDimensionInfo(S).type)===En||"time"===x;)S=M.pop();_.get("show")?(o[Ge](b,_,v),b.text=r[Zn](l[ct](i,Fn),t.get(S,i))):b.text="",w[Sr]("show")?(o[Ge](m,w,v),m.text=r[Zn](l[ct](i,Hn),t.get(S,i))):m.text="";var A=e(t[It](i,pt));if(a.off(Fe).off(Ze).off(Hn).off(Fn),o[He](a,m),f[Sr]("hoverAnimation")){var C=function(){var t=A[1]/A[0];this[Ne]({scale:[Math.max(1.1*A[0],A[0]+3),Math.max(1.1*A[1],A[1]+3*t)]},400,"elasticOut")},T=function(){this[Ne]({scale:A},400,"elasticOut")};a.on(Fe,C).on(Ze,T).on(Hn,C).on(Fn,T)}},l.fadeOut=function(t){var e=this[Cn](0);e.style.text="",o[Ee](e,{scale:[0,0]},this._seriesModel,t)},r[Tr](i,o.Group),i}),e("echarts/chart/helper/SymbolDraw",[ia,yt,"./Symbol"],function(t){function e(t){this.group=new n.Group,this._symbolCtor=t||r}function i(t,e,i){var n=t[Pt](e);return n&&!isNaN(n[0])&&!isNaN(n[1])&&!(i&&i(e))&&"none"!==t[It](e,ft)}var n=t(yt),r=t("./Symbol"),a=e[ea];return a[mt]=function(t,e){var r=this.group,a=t[$t],o=this._data,s=this._symbolCtor;t.diff(o).add(function(n){var a=t[Pt](n);if(i(t,n,e)){var o=new s(t,n);o.attr(Tn,a),t[Lt](n,o),r.add(o)}})[on](function(l,u){var c=o[_i](u),h=t[Pt](l);return i(t,l,e)?(c?(c[mt](t,l),n[Ee](c,{position:h},a)):(c=new s(t,l),c.attr(Tn,h)),r.add(c),void t[Lt](l,c)):void r[Ii](c)})[Ii](function(t){var e=o[_i](t);e&&e.fadeOut(function(){r[Ii](e)})})[ut](),this._data=t},a[Ai]=function(){var t=this._data;t&&t[yi](function(e,i){e.attr(Tn,t[Pt](i))})},a[Ii]=function(t){var e=this.group,i=this._data;i&&(t?i[yi](function(t){t.fadeOut(function(){e[Ii](t)})}):e[Si]())},e}),e("echarts/chart/line/lineAnimationDiff",[ia],function(t){function e(t){return t>=0?1:-1}function i(t,i,n){for(var r,a=t[$i](),o=t[lt](a),s=a.onZero?0:o.scale[st]()[0],l=o.dim,u="x"===l||l===jn?1:0,c=i.stackedOn,h=i.get(l,n);c&&e(c.get(l,n))===e(h);){r=c;break}var d=[];return d[u]=i.get(a.dim,n),d[1-u]=r?r.get(l,n,!0):s,t[ot](d)}function n(t,e){var i=[];return e.diff(t).add(function(t){i.push({cmd:"+",idx:t})})[on](function(t,e){i.push({cmd:"=",idx:e,idx1:t})})[Ii](function(t){i.push({cmd:"-",idx:t})})[ut](),i}return function(t,e,r,a,o,s){for(var l=n(t,e),u=[],c=[],h=[],d=[],f=[],p=[],v=[],m=s[Ht],g=0;gx;x++){var _=e[y];if(y>=n||0>y||isNaN(_[0])||isNaN(_[1]))break;if(y===i)t[f>0?hi:ci](_[0],_[1]),l(c,_);else if(m>0){var w=y-f,b=y+f,M=.5,S=e[w],A=e[b];if(f>0&&(y===d-1||isNaN(A[0])||isNaN(A[1]))||0>=f&&(0===y||isNaN(A[0])||isNaN(A[1])))l(h,_);else{(isNaN(A[0])||isNaN(A[1]))&&(A=_),r.sub(u,A,S);var C,T;if("x"===g||"y"===g){var k="x"===g?0:1;C=Math.abs(_[k]-S[k]),T=Math.abs(_[k]-A[k])}else C=r.dist(_,S),T=r.dist(_,A);M=T/(T+C),s(h,_,u,-m*(1-M))}a(c,c,v),o(c,c,p),a(h,h,v),o(h,h,p),t[ui](c[0],c[1],h[0],h[1],_[0],_[1]),s(c,_,u,m*M)}else t[ci](_[0],_[1]);y+=f}return x}function i(t,e){var i=[1/0,1/0],n=[-(1/0),-(1/0)];if(e)for(var r=0;rn[0]&&(n[0]=a[0]),a[1]>n[1]&&(n[1]=a[1])}return{min:e?i:n,max:e?n:i}}var n=t(si),r=t(gr),a=r.min,o=r.max,s=r.scaleAndAdd,l=r.copy,u=[],c=[],h=[];return{Polyline:n[Lr]({type:"ec-polyline",shape:{points:[],smooth:0,smoothConstraint:!0,smoothMonotone:null},style:{fill:null,stroke:"#000"},buildPath:function(t,n){for(var r=n[$e],a=0,o=r[Kr],s=i(r,n.smoothConstraint);o>a;)a+=e(t,r,a,o,o,1,s.min,s.max,n.smooth,n.smoothMonotone)+1}}),Polygon:n[Lr]({type:"ec-polygon",shape:{points:[],stackedOnPoints:[],smooth:0,stackedOnSmooth:0,smoothConstraint:!0,smoothMonotone:null},buildPath:function(t,n){for(var r=n[$e],a=n.stackedOnPoints,o=0,s=r[Kr],l=n.smoothMonotone,u=i(r,n.smoothConstraint),c=i(a,n.smoothConstraint);s>o;){var h=e(t,r,o,s,s,1,u.min,u.max,n.smooth,l);e(t,a,o+h-1,s,h,-1,c.min,c.max,n.stackedOnSmooth,l),o+=h+1,t[li]()}}})}}),e("echarts/chart/line/LineView",[ia,ta,at,"../helper/Symbol","./lineAnimationDiff",yt,"./poly",rt],function(t){function e(t,e){if(t[Kr]===e[Kr]){for(var i=0;ie[0]?1:-1;e[0]+=n*i,e[1]-=n*i}return e}function r(t){return t>=0?1:-1}function a(t,e){var i=t[$i](),n=t[lt](i),a=i.onZero?0:n.scale[st]()[0],o=n.dim,s="x"===o||o===jn?1:0;return e[Ot]([o],function(n,l){for(var u,c=e.stackedOn;c&&r(c.get(o,l))===r(n);){u=c;break}var h=[];return h[s]=e.get(i.dim,l),h[1-s]=u?u.get(o,l,!0):a,t[ot](h)},!0)}function o(t,e){return null!=e[wi]?e[wi]:null!=e.name?t[xi](e.name):void 0}function s(t,e,i){var r=n(t[et]("x")),a=n(t[et]("y")),o=t[$i]().isHorizontal(),s=r[0],l=a[0],u=r[1]-s,c=a[1]-l;i.get("clipOverflow")||(o?(l-=c,c*=3):(s-=u,u*=3));var h=new p.Rect({shape:{x:s,y:l,width:u,height:c}});return e&&(h.shape[o?"width":hr]=0,p[Oe](h,{shape:{width:u,height:c}},i)),h}function l(t,e,i){var n=t.getAngleAxis(),r=t.getRadiusAxis(),a=r[st](),o=n[st](),s=Math.PI/180,l=new p[Ke]({shape:{cx:t.cx,cy:t.cy,r0:a[0],r:a[1],startAngle:-o[0]*s,endAngle:-o[1]*s,clockwise:n[tt]}});return e&&(l.shape[ei]=-o[0]*s,p[Oe](l,{shape:{endAngle:-o[1]*s}},i)),l}function u(t,e,i){return"polar"===t.type?l(t,e,i):s(t,e,i)}var c=t(ta),h=t(at),d=t("../helper/Symbol"),f=t("./lineAnimationDiff"),p=t(yt),v=t("./poly"),m=t(rt);return m[Lr]({type:"line",init:function(){var t=new p.Group,e=new h;this.group.add(e.group),this[$]=e,this._lineGroup=t},render:function(t,n,r){var o=t[tn],s=this.group,l=t[Nn](),h=t[ir](Q),d=t[ir]("areaStyle.normal"),f=l[Ot](l[Pt],!0),p="polar"===o.type,v=this._coordSys,m=this[$],g=this._polyline,y=this._polygon,x=this._lineGroup,_=t.get(Bi),w=!d.isEmpty(),b=a(o,l),M=t.get("showSymbol"),S=M&&!p&&!t.get("showAllSymbol")&&this._getSymbolIgnoreFunc(l,o),A=this._data;A&&A[yi](function(t,e){t.__temp&&(s[Ii](t),A[Lt](e,null))}),M||m[Ii](),s.add(x),g&&v.type===o.type?(w&&!y?y=this._newPolygon(f,b,o,_):y&&!w&&(x[Ii](y),y=this._polygon=null),x.setClipPath(u(o,!1,t)),M&&m[mt](l,S),l[yi](function(t){t[Oi](!0)}),e(this._stackedOnPoints,b)&&e(this._points,f)||(_?this._updateAnimation(l,b,o,r):(g[ri]({points:f}),y&&y[ri]({points:f,stackedOnPoints:b})))):(M&&m[mt](l,S),g=this._newPolyline(f,o,_),w&&(y=this._newPolygon(f,b,o,_)),x.setClipPath(u(o,!0,t))),g[qe](c[rr](h[J](),{stroke:l[Vt]("color"),lineJoin:"bevel"}));var C=t.get("smooth");if(C=i(t.get("smooth")),g[ri]({smooth:C,smoothMonotone:t.get("smoothMonotone")}),y){var T=l.stackedOn,k=0;if(y.style[wr]=.7,y[qe](c[rr](d.getAreaStyle(),{fill:l[Vt]("color"),lineJoin:"bevel"})),T){var L=T[$t];k=i(L.get("smooth"))}y[ri]({smooth:C,stackedOnSmooth:k,smoothMonotone:t.get("smoothMonotone") -})}this._data=l,this._coordSys=o,this._stackedOnPoints=b,this._points=f},highlight:function(t,e,i,n){var r=t[Nn](),a=o(r,n);if(null!=a&&a>=0){var s=r[_i](a);if(!s){var l=r[Pt](a);s=new d(r,a,i),s[Tn]=l,s.setZ(t.get(Se),t.get("z")),s[zi]=isNaN(l[0])||isNaN(l[1]),s.__temp=!0,r[Lt](a,s),s.stopSymbolAnimation(!0),this.group.add(s)}s[ee]()}else m[ea][ee].call(this,t,e,i,n)},downplay:function(t,e,i,n){var r=t[Nn](),a=o(r,n);if(null!=a&&a>=0){var s=r[_i](a);s&&(s.__temp?(r[Lt](a,null),this.group[Ii](s)):s[te]())}else m[ea][te].call(this,t,e,i,n)},_newPolyline:function(t){var e=this._polyline;return e&&this._lineGroup[Ii](e),e=new v[Xe]({shape:{points:t},silent:!0,z2:10}),this._lineGroup.add(e),this._polyline=e,e},_newPolygon:function(t,e){var i=this._polygon;return i&&this._lineGroup[Ii](i),i=new v[Ye]({shape:{points:t,stackedOnPoints:e},silent:!0}),this._lineGroup.add(i),this._polygon=i,i},_getSymbolIgnoreFunc:function(t,e){var i=e.getAxesByScale(En)[0];return i&&i.isLabelIgnored?c.bind(i.isLabelIgnored,i):void 0},_updateAnimation:function(t,e,i,n){var r=this._polyline,a=this._polygon,o=t[$t],s=f(this._data,t,this._stackedOnPoints,e,this._coordSys,i);r.shape[$e]=s.current,p[Ee](r,{shape:{points:s.next}},o),a&&(a[ri]({points:s.current,stackedOnPoints:s.stackedOnCurrent}),p[Ee](a,{shape:{points:s.next,stackedOnPoints:s.stackedOnNext}},o));for(var l=[],u=s.status,c=0;ce&&(e=t[i]);return e},min:function(t){for(var e=1/0,i=0;i1){var h;typeof r===qr?h=t[r]:typeof r===Fr&&(h=r),h&&(n=n.downSample(s.dim,1/c,h,e),i[ni](n))}}},this)}}),e("echarts/chart/line",[ia,ta,Y,"./line/LineSeries","./line/LineView",X,j,"../processor/dataSample"],function(t){var e=t(ta),i=t(Y);t("./line/LineSeries"),t("./line/LineView"),i[Xt]("chart",e.curry(t(X),"line",dt,"line")),i[Yt](e.curry(t(j),"line")),i[Jt]("statistic",e.curry(t("../processor/dataSample"),"line"))}),e("echarts/scale/Scale",[ia,Yn],function(t){function e(){this._extent=[1/0,-(1/0)],this._interval=0,this.init&&this.init.apply(this,arguments)}var i=t(Yn),n=e[ea];return n.parse=function(t){return t},n[pi]=function(t){var e=this._extent;return t>=e[0]&&t<=e[1]},n.normalize=function(t){var e=this._extent;return e[1]===e[0]?.5:(t-e[0])/(e[1]-e[0])},n.scale=function(t){var e=this._extent;return t*(e[1]-e[0])+e[0]},n[U]=function(t){var e=this._extent;t[0]e[1]&&(e[1]=t[1])},n[st]=function(){return this._extent.slice()},n[q]=function(t,e){var i=this._extent;isNaN(t)||(i[0]=t),isNaN(e)||(i[1]=e)},n.getTicksLabels=function(){for(var t=[],e=this[W](),i=0;ie[1]&&(e[1]=t[1]),o[ea][q].call(this,e[0],e[1])},getInterval:function(){return this._interval||this.niceTicks(),this._interval},setInterval:function(t){this._interval=t,this._niceExtent=this._extent.slice()},getTicks:function(){this._interval||this.niceTicks();var t=this._interval,i=this._extent,n=[],r=1e4;if(t){var a=this._niceExtent;i[0]r)return[];i[1]>a[1]&&n.push(i[1])}return n},getTicksLabels:function(){for(var t=[],e=this[W](),i=0;i=n)){var o=Math.pow(10,Math.floor(Math.log(n/t)/Math.LN10)),s=t/n*o;.15>=s?o*=10:.3>=s?o*=5:.45>=s?o*=3:.75>=s&&(o*=2);var l=[e.round(a(i[0]/o)*o),e.round(r(i[1]/o)*o)];this._interval=o,this._niceExtent=l}},niceExtent:function(t,i,n){var o=this._extent;if(o[0]===o[1])if(0!==o[0]){var s=o[0]/2;o[0]-=s,o[1]+=s}else o[1]=1;o[1]===-(1/0)&&o[0]===1/0&&(o[0]=0,o[1]=1),this.niceTicks(t,i,n);var l=this._interval;i||(o[0]=e.round(r(o[0]/l)*l)),n||(o[1]=e.round(a(o[1]/l)*l))}});return o[cr]=function(){return new o},o}),e("echarts/scale/Time",[ia,ta,"../util/number","../util/format","./Interval"],function(t){var e=t(ta),i=t("../util/number"),n=t("../util/format"),r=t("./Interval"),a=r[ea],o=Math.ceil,s=Math.floor,l=864e5,u=function(t,e,i,n){for(;n>i;){var r=i+n>>>1;t[r][2]=p?f*=10:.3>=p?f*=5:.75>=p&&(f*=2),c*=f}var v=[o(e[0]/c)*c,s(e[1]/c)*c];this._stepLvl=l,this._interval=c,this._niceExtent=v},parse:function(t){return+i.parseDate(t)}});e.each([pi,"normalize"],function(t){c[ea][t]=function(e){return a[t].call(this,this.parse(e))}});var h=[["hh:mm:ss",1,1e3],["hh:mm:ss",5,5e3],["hh:mm:ss",10,1e4],["hh:mm:ss",15,15e3],["hh:mm:ss",30,3e4],["hh:mm\nMM-dd",1,6e4],["hh:mm\nMM-dd",5,3e5],["hh:mm\nMM-dd",10,6e5],["hh:mm\nMM-dd",15,9e5],["hh:mm\nMM-dd",30,18e5],["hh:mm\nMM-dd",1,36e5],["hh:mm\nMM-dd",2,72e5],["hh:mm\nMM-dd",6,216e5],["hh:mm\nMM-dd",12,432e5],["MM-dd\nyyyy",1,l],["week",7,7*l],["month",1,31*l],["quarter",3,380*l/4],["half-year",6,380*l/2],["year",1,380*l]];return c[cr]=function(){return new c},c}),e("echarts/scale/Log",[ia,ta,"./Scale","../util/number","./Interval"],function(t){var e=t(ta),i=t("./Scale"),n=t("../util/number"),r=t("./Interval"),a=i[ea],o=r[ea],s=Math.floor,l=Math.ceil,u=Math.pow,c=10,h=Math.log,d=i[Lr]({type:"log",getTicks:function(){return e.map(o[W].call(this),function(t){return n.round(u(c,t))})},getLabel:o[H],scale:function(t){return t=a.scale.call(this,t),u(c,t)},setExtent:function(t,e){t=h(t)/h(c),e=h(e)/h(c),o[q].call(this,t,e)},getExtent:function(){var t=a[st].call(this);return t[0]=u(c,t[0]),t[1]=u(c,t[1]),t},unionExtent:function(t){t[0]=h(t[0])/h(c),t[1]=h(t[1])/h(c),a[U].call(this,t)},niceTicks:function(t){t=t||10;var e=this._extent,i=e[1]-e[0];if(!(i===1/0||0>=i)){var r=u(10,s(h(i/t)/Math.LN10)),a=t/i*r;.5>=a&&(r*=10);var o=[n.round(l(e[0]/r)*r),n.round(s(e[1]/r)*r)];this._interval=r,this._niceExtent=o}},niceExtent:o.niceExtent});return e.each([pi,"normalize"],function(t){d[ea][t]=function(e){return e=h(e)/h(c),a[t].call(this,e)}}),d[cr]=function(){return new d},d}),e("echarts/coord/axisHelper",[ia,"../scale/Ordinal","../scale/Interval","../scale/Time","../scale/Log","../scale/Scale","../util/number",ta,lr],function(t){var e=t("../scale/Ordinal"),i=t("../scale/Interval");t("../scale/Time"),t("../scale/Log");var n=t("../scale/Scale"),r=t("../util/number"),a=t(ta),o=t(lr),s={};return s[F]=function(t,e){var i=t.scale,n=i[st](),o=n[1]-n[0];if(i.type===En)return void(isFinite(o)||i[q](0,0));var s=e.get("min"),l=e.get("max"),u=!e.get("scale"),c=e.get(Z);a[Dr](c)||(c=[c||0,c||0]),c[0]=r[Br](c[0],1),c[1]=r[Br](c[1],1);var h=!0,d=!0;null==s&&(s=n[0]-c[0]*o,h=!1),null==l&&(l=n[1]+c[1]*o,d=!1),"dataMin"===s&&(s=n[0]),"dataMax"===l&&(l=n[1]),u&&(s>0&&l>0&&!h&&(s=0),0>s&&0>l&&!d&&(l=0)),i[q](s,l),i.niceExtent(e.get(G),h,d);var f=e.get(B);null!=f&&i.setInterval&&i.setInterval(f)},s[N]=function(t,r){if(r=r||t.get("type"))switch(r){case St:return new e(t[Mt](),[1/0,-(1/0)]);case"value":return new i;default:return(n[Ar](r)||i)[cr](t)}},s.ifAxisCrossZero=function(t){var e=t.scale[st](),i=e[0],n=e[1];return!(i>0&&n>0||0>i&&0>n)},s.getAxisLabelInterval=function(t,e,i,n){var r,a=0,s=0,l=1;e[Kr]>40&&(l=Math.round(e[Kr]/40));for(var u=0;u1?l:a*l},s[E]=function(t,e){var i=t.scale,n=i.getTicksLabels(),r=i[W]();return typeof e===qr?(e=function(t){return function(e){return t[Zr]("{value}",e)}}(e),a.map(n,e)):typeof e===Fr?a.map(r,function(n,r){return e(t.type===St?i[H](n):n,r)},this):n},s}),e("echarts/coord/cartesian/Cartesian",[ia,ta],function(t){function e(t){return this._axes[t]}var i=t(ta),n=function(t){this._axes={},this._dimList=[],this.name=t||""};return n[ea]={constructor:n,type:"cartesian",getAxis:function(t){return this._axes[t]},getAxes:function(){return i.map(this._dimList,e,this)},getAxesByScale:function(t){return t=t[zr](),i[$r](this.getAxes(),function(e){return e.scale.type===t})},addAxis:function(t){var e=t.dim;this._axes[e]=t,this._dimList.push(e)},dataToCoord:function(t){return this._dataCoordConvert(t,O)},coordToData:function(t){return this._dataCoordConvert(t,V)},_dataCoordConvert:function(t,e){for(var i=this._dimList,n=t instanceof Array?[]:{},r=0;r=i&&n>=t},containData:function(t){return this[pi](this[O](t))},getExtent:function(){var t=this._extent.slice();return t},getPixelPrecision:function(t){return i[Rr](t||this.scale[st](),this._extent)},setExtent:function(t,e){var i=this._extent;i[0]=t,i[1]=e},dataToCoord:function(t,i){var r=this._extent,o=this.scale;return t=o.normalize(t),this[nt]&&o.type===En&&(r=r.slice(),e(r,o.count())),n(t,a,r,i)},coordToData:function(t,i){var r=this._extent,o=this.scale;this[nt]&&o.type===En&&(r=r.slice(),e(r,o.count()));var s=n(t,r,a,i);return this.scale.scale(s)},getTicksCoords:function(){if(this[nt]){for(var t=this.getBands(),e=[],i=0;io;o++)e.push([a*o/i+n,a*(o+1)/i+n]);return e},getBandWidth:function(){var t=this._extent,e=this.scale[st](),i=e[1]-e[0]+(this[nt]?1:0),n=Math.abs(t[1]-t[0]);return Math.abs(n)/i}},o}),e("echarts/coord/cartesian/axisLabelInterval",[ia,ta,"../axisHelper"],function(t){var e=t(ta),i=t("../axisHelper");return function(t){var n=t.model,r=n[ir](R),a=r.get(B);return t.type!==St||"auto"!==a?"auto"===a?0:a:i.getAxisLabelInterval(e.map(t.scale[W](),t[O],t),n[E](),r[ir](er)[$n](),t.isHorizontal())}}),e("echarts/coord/cartesian/Axis2D",[ia,ta,"../Axis","./axisLabelInterval"],function(t){var e=t(ta),i=t("../Axis"),n=t("./axisLabelInterval"),r=function(t,e,n,r,a){i.call(this,t,e,n),this.type=r||"value",this[Tn]=a||Or};return r[ea]={constructor:r,index:0,onZero:!1,model:null,isHorizontal:function(){var t=this[Tn];return"top"===t||t===Or},getGlobalExtent:function(){var t=this[st]();return t[0]=this.toGlobalCoord(t[0]),t[1]=this.toGlobalCoord(t[1]),t},getLabelInterval:function(){var t=this._labelInterval;return t||(t=this._labelInterval=n(this)),t},isLabelIgnored:function(t){if(this.type===St){var e=this.getLabelInterval();return typeof e===Fr&&!e(t,this.scale[H](t))||t%(e+1)}},toLocalCoord:null,toGlobalCoord:null},e[Tr](r,i),r}),e("echarts/coord/axisDefault",[ia,ta],function(t){var e=t(ta),i={show:!0,zlevel:0,z:0,inverse:!1,name:"",nameLocation:"end",nameTextStyle:{},nameGap:15,axisLine:{show:!0,onZero:!0,lineStyle:{color:"#333",width:1,type:"solid"}},axisTick:{show:!0,inside:!1,length:5,lineStyle:{color:"#333",width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{color:"#333",fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}}},n=e.merge({boundaryGap:!0,axisTick:{interval:"auto"},axisLabel:{interval:"auto"}},i),r=e[rr]({boundaryGap:[0,0],splitNumber:5},i),a=e[rr]({scale:!0,min:"dataMin",max:"dataMax"},r),o=e[rr]({},r);return o.scale=!0,{categoryAxis:n,valueAxis:r,timeAxis:a,logAxis:o}}),e("echarts/coord/axisModelCreator",[ia,"./axisDefault",ta,"../model/Component","../util/layout"],function(t){var e=t("./axisDefault"),i=t(ta),n=t("../model/Component"),r=t("../util/layout"),a=["value",St,"time","log"];return function(t,o,s,l){i.each(a,function(n){o[Lr]({type:t+"Axis."+n,mergeDefaultAndTheme:function(e,a){var o=this.layoutMode,l=o?r.getLayoutParams(e):{},u=a.getTheme();i.merge(e,u.get(n+"Axis")),i.merge(e,this.getDefaultOption()),e.type=s(t,e),o&&r.mergeLayoutParam(e,l,o)},defaultOption:i.mergeAll([{},e[n+"Axis"],l],!0)})}),n[Ln](t+"Axis",i.curry(s,t))}}),e("echarts/coord/axisModelCommonMixin",[ia,ta,"./axisHelper"],function(t){function e(t){return r[In](t)&&null!=t.value?t.value:t}function i(){return this.get("type")===St&&r.map(this.get("data"),e)}function n(){return a[E](this.axis,this.get("axisLabel.formatter"))}var r=t(ta),a=t("./axisHelper");return{getFormattedLabels:n,getCategories:i}}),e("echarts/coord/cartesian/AxisModel",[ia,z,ta,"../axisModelCreator","../axisModelCommonMixin"],function(t){function e(t,e){return e.type||(e.data?St:"value")}var i=t(z),n=t(ta),r=t("../axisModelCreator"),a=i[Lr]({type:"cartesian2dAxis",axis:null,setNeedsCrossZero:function(t){this[Xn].scale=!t},setMin:function(t){this[Xn].min=t},setMax:function(t){this[Xn].max=t}});n.merge(a[ea],t("../axisModelCommonMixin"));var o={gridIndex:0};return r("x",a,e,o),r("y",a,e,o),a}),e("echarts/coord/cartesian/GridModel",[ia,"./AxisModel",z],function(t){t("./AxisModel");var e=t(z);return e[Lr]({type:"grid",dependencies:["xAxis","yAxis"],layoutMode:"box",coordinateSystem:null,defaultOption:{show:!1,zlevel:0,z:0,left:"10%",top:60,right:"10%",bottom:60,containLabel:!1,backgroundColor:"rgba(0,0,0,0)",borderWidth:1,borderColor:"#ccc"}})}),e("echarts/coord/cartesian/Grid",[ia,"exports","module",P,D,ta,"./Cartesian2D","./Axis2D","./GridModel",At],function(t,e){function i(t,e,i){return i[rn]("grid",t.get("gridIndex"))===e}function n(t){var e,i=t.model,n=i[E](),r=1,a=n[Kr];a>40&&(r=Math.ceil(a/40));for(var o=0;a>o;o+=r)if(!t.isLabelIgnored(o)){var s=i.getTextRect(n[o]);e?e.union(s):e=s}return e}function r(t,e,i){this._coordsMap={},this._coordsList=[],this._axesMap={},this._axesList=[],this._initCartesian(t,e,i),this[ne]=t}function a(t,e){var i=t[st](),n=i[0]+i[1];t.toGlobalCoord="x"===t.dim?function(t){return t+e}:function(t){return n-t+e},t.toLocalCoord="x"===t.dim?function(t){return t-e}:function(t){return n-t+e}}var o=t(P),s=t(D),l=t(ta),u=t("./Cartesian2D"),c=t("./Axis2D"),h=l.each,d=s.ifAxisCrossZero,f=s[F];t("./GridModel");var p=r[ea];return p.type="grid",p[I]=function(){return this._rect},p[on]=function(t,e){function i(t){var e=n[t];for(var i in e){var r=e[i];if(r&&(r.type===St||!d(r)))return!0}return!1}var n=this._axesMap;this._updateScale(t,this[ne]),h(n.x,function(t){f(t,t.model)}),h(n.y,function(t){f(t,t.model)}),h(n.x,function(t){i("y")&&(t.onZero=!1)}),h(n.y,function(t){i("x")&&(t.onZero=!1)}),this[Me](this[ne],e)},p[Me]=function(t,e){function i(){h(s,function(t){var e=t.isHorizontal(),i=e?[0,r.width]:[0,r[hr]],n=t[tt]?1:0;t[q](i[n],i[1-n]),a(t,e?r.x:r.y)})}var r=o[bn](t[L](),{width:e[un](),height:e[ln]()});this._rect=r;var s=this._axesList;i(),t.get("containLabel")&&(h(s,function(t){if(!t.model.get("axisLabel.inside")){var e=n(t);if(e){var i=t.isHorizontal()?hr:"width",a=t.model.get("axisLabel.margin");r[i]-=e[i]+a,"top"===t[Tn]?r.y+=e[hr]+a:"left"===t[Tn]&&(r.x+=e.width+a)}}}),i())},p[et]=function(t,e){var i=this._axesMap[t];if(null!=i){if(null==e)for(var n in i)return i[n];return i[e]}},p.getCartesian=function(t,e){var i="x"+t+"y"+e;return this._coordsMap[i]},p._initCartesian=function(t,e,n){function r(n){return function(r,u){if(i(r,t,e)){var h=r.get(Tn);"x"===n?("top"!==h&&h!==Or&&(h=Or),a[h]&&(h="top"===h?Or:"top")):("left"!==h&&"right"!==h&&(h="left"),a[h]&&(h="left"===h?"right":"left")),a[h]=!0;var d=new c(n,s[N](r),[0,0],r.get("type"),h),f=d.type===St;d[nt]=f&&r.get(Z),d[tt]=r.get(tt),d.onZero=r.get("axisLine.onZero"),r.axis=d,d.model=r,d.index=u,this._axesList.push(d),o[n][u]=d,l[n]++}}}var a={left:!1,right:!1,top:!1,bottom:!1},o={x:{},y:{}},l={x:0,y:0};return e[ie]("xAxis",r("x"),this),e[ie]("yAxis",r("y"),this),l.x&&l.y?(this._axesMap=o,void h(o.x,function(t,e){h(o.y,function(i,n){var r="x"+e+"y"+n,a=new u(r);a.grid=this,this._coordsMap[r]=a,this._coordsList.push(a),a.addAxis(t),a.addAxis(i)},this)},this)):(this._axesMap={},void(this._axesList=[]))},p._updateScale=function(t,e){function n(t,e,i){h(i[k](e.dim),function(i){e.scale[U](t[Bt](i,e.scale.type!==En))})}l.each(this._axesList,function(t){t.scale[q](1/0,-(1/0))}),t[he](function(r){if(r.get(tn)===K){var a=r.get("xAxisIndex"),o=r.get("yAxisIndex"),s=t[rn]("xAxis",a),l=t[rn]("yAxis",o);if(!i(s,e,t)||!i(l,e,t))return;var u=this.getCartesian(a,o),c=r[Nn](),h=u[et]("x"),d=u[et]("y");"list"===c.type&&(n(c,h,r),n(c,d,r))}},this)},r[cr]=function(t,e){var i=[];return t[ie]("grid",function(n,a){var o=new r(n,t,e);o.name="grid_"+a,o[Me](n,e),n[tn]=o,i.push(o)}),t[he](function(e){if(e.get(tn)===K){var n=e.get("xAxisIndex"),r=t[rn]("xAxis",n),a=i[r.get("gridIndex")];e[tn]=a.getCartesian(n,e.get("yAxisIndex"))}}),i},r[Ht]=u[ea][Ht],t(At)[an](K,r),r}),e("echarts/chart/bar/BarSeries",[ia,wt,bt],function(t){var e=t(wt),i=t(bt);return e[Lr]({type:"series.bar",dependencies:["grid","polar"],getInitialData:function(t,e){return i(t.data,this,e)},getMarkerPosition:function(t){var e=this[tn];if(e){var i=e[ot](t),n=this[Nn](),r=n[zt](Qe),a=n[zt]("size"),o=e[$i]().isHorizontal()?0:1;return i[o]+=r+a/2,i}return[NaN,NaN]},defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,xAxisIndex:0,yAxisIndex:0,barMinHeight:0,itemStyle:{normal:{barBorderColor:"#fff",barBorderWidth:0},emphasis:{barBorderColor:"#fff",barBorderWidth:0}}}})}),e("echarts/chart/bar/barItemStyle",[ia,"../../model/mixin/makeStyleMapper"],function(t){return{getBarItemStyle:t("../../model/mixin/makeStyleMapper")([["fill","color"],[br,"barBorderColor"],[Mr,"barBorderWidth"],[wr],[_r],[xr],["shadowOffsetY"],[yr]])}}),e("echarts/chart/bar/BarView",[ia,ta,yt,T,"./barItemStyle",C],function(t){function e(t,e){var i=t.width>0?1:-1,n=t[hr]>0?1:-1;e=Math.min(e,Math.abs(t.width),Math.abs(t[hr])),t.x+=i*e/2,t.y+=n*e/2,t.width-=i*e,t[hr]-=n*e}var i=t(ta),n=t(yt);return i[Lr](t(T)[ea],t("./barItemStyle")),t(C)[jt]({type:"bar",render:function(t,e,i){var n=t.get(tn);return n===K&&this._renderOnCartesian(t,e,i),this.group},_renderOnCartesian:function(t,r,a){function o(r,a){var o=l[Pt](r),s=l[zn](r).get(p)||0;e(o,s);var u=new n.Rect({shape:i[Lr]({},o)});if(f){var c=u.shape,h=d?hr:"width",v={};c[h]=0,v[h]=o[h],n[a?Ee:Oe](u,{shape:v},t)}return u}var s=this.group,l=t[Nn](),u=this._data,c=t[tn],h=c[$i](),d=h.isHorizontal(),f=t.get(Bi),p=[ue,Fn,"barBorderWidth"];l.diff(u).add(function(t){if(l.hasValue(t)){var e=o(t);l[Lt](t,e),s.add(e)}})[on](function(i,r){var a=u[_i](r);if(!l.hasValue(i))return void s[Ii](a);a||(a=o(i,!0));var c=l[Pt](i),h=l[zn](i).get(p)||0;e(c,h),n[Ee](a,{shape:c},t),l[Lt](i,a),s.add(a)})[Ii](function(e){var i=u[_i](e);i&&(i.style.text="",n[Ee](i,{shape:{width:0}},t,function(){s[Ii](i)}))})[ut](),this._updateStyle(t,l,d),this._data=l},_updateStyle:function(t,e,r){function a(t,e,i,r,a){n[Ge](t,e,i),t.text=r,"outside"===t[gi]&&(t[gi]=a)}e[yi](function(o,s){var l=e[zn](s),u=e[It](s,"color"),c=e[Pt](s),h=l[ir](A),d=l[ir](S)[ht]();o[ri]("r",h.get("barBorderRadius")||0),o[qe](i[rr]({fill:u},h.getBarItemStyle()));var f=r?c[hr]>0?Or:"top":c.width>0?"left":"right",p=l[ir](M),v=l[ir](b),m=o.style;p.get("show")?a(m,p,u,i[Zn](t[ct](s,Fn),t[On](s)),f):m.text="",v.get("show")?a(d,v,u,i[Zn](t[ct](s,Hn),t[On](s)),f):d.text="",n[He](o,d)})},remove:function(t,e){var i=this.group;t.get(Bi)?this._data&&this._data[yi](function(e){e.style.text="",n[Ee](e,{shape:{width:0}},t,function(){i[Ii](e)})}):i[Si]()}})}),e("echarts/layout/barGrid",[ia,ta,"../util/number"],function(t){function e(t){return t.get("stack")||"__ec_stack_"+t[Bn]}function i(t,i){var n={};r.each(t,function(t,i){var r=t[tn],a=r[$i](),o=n[a.index]||{remainedWidth:a[it](),autoWidthCount:0,categoryGap:"20%",gap:"30%",axis:a,stacks:{}},s=o.stacks;n[a.index]=o;var l=e(t);s[l]||o.autoWidthCount++,s[l]=s[l]||{width:0,maxWidth:0};var u=t.get("barWidth"),c=t.get("barMaxWidth"),h=t.get("barGap"),d=t.get("barCategoryGap");u&&!s[l].width&&(u=Math.min(o.remainedWidth,u),s[l].width=u,o.remainedWidth-=u),c&&(s[l].maxWidth=c),null!=h&&(o.gap=h),null!=d&&(o.categoryGap=d)});var a={};return r.each(n,function(t,e){a[e]={};var i=t.stacks,n=t.axis,s=n[it](),l=o(t.categoryGap,s),u=o(t.gap,1),c=t.remainedWidth,h=t.autoWidthCount,d=(c-l)/(h+(h-1)*u);d=Math.max(d,0),r.each(i,function(t,e){var i=t.maxWidth;!t.width&&i&&d>i&&(i=Math.min(i,c),c-=i,t.width=i,h--)}),d=(c-l)/(h+(h-1)*u),d=Math.max(d,0);var f,p=0;r.each(i,function(t,e){t.width||(t.width=d),f=t,p+=t.width*(1+u)}),f&&(p-=f.width*u);var v=-p/2;r.each(i,function(t,i){a[e][i]=a[e][i]||{offset:v,width:t.width},v+=t.width*(1+u)})}),a}function n(t,n,a){var o=i(r[$r](n.getSeriesByType(t),function(t){return!n[pe](t)&&t[tn]&&t[tn].type===K})),s={};n[de](t,function(t){var i=t[Nn](),n=t[tn],r=n[$i](),a=e(t),l=o[r.index][a],u=l[Qe],c=l.width,h=n[lt](r),d=t.get("barMinHeight")||0,f=r.onZero?h.toGlobalCoord(h[O](0)):h.getGlobalExtent()[0],p=n.dataToPoints(i,!0);s[a]=s[a]||[],i[Rt]({offset:u,size:c}),i.each(h.dim,function(t,e){if(!isNaN(t)){s[a][e]||(s[a][e]={p:f,n:f});var n,r,o,l,v=t>=0?"p":"n",m=p[e],g=s[a][e][v];h.isHorizontal()?(n=g,r=m[1]+u,o=m[0]-g,l=c,Math.abs(o)o?-1:1)*d),s[a][e][v]+=o):(n=m[0]+u,r=g,o=c,l=m[1]-g,Math.abs(l)=l?-1:1)*d),s[a][e][v]+=l),i[Dt](e,{x:n,y:r,width:o,height:l})}},!0)},this)}var r=t(ta),a=t("../util/number"),o=a[Br];return n}),e("echarts/chart/bar",[ia,ta,"../coord/cartesian/Grid","./bar/BarSeries","./bar/BarView","../layout/barGrid",Y],function(t){var e=t(ta);t("../coord/cartesian/Grid"),t("./bar/BarSeries"),t("./bar/BarView");var i=t("../layout/barGrid"),n=t(Y);n[Yt](e.curry(i,"bar")),n[Xt]("chart",function(t){t[de]("bar",function(t){var e=t[Nn]();e[ve]("legendSymbol","roundRect")})})}),e("echarts/component/axis/AxisBuilder",[ia,ta,yt,T,gt],function(t){function e(t,e,i){var n,r,a=s(e-t[Ki]);return l(a)?(r=i>0?"top":Or,n=Nr):l(a-u)?(r=i>0?Or:"top",n=Nr):(r=Er,n=a>0&&u>a?i>0?"right":"left":i>0?"left":"right"),{rotation:a,textAlign:n,textBaseline:r}}function i(t,e,i){var n,r,a=s(-t[Ki]),o=i[0]>i[1],c="start"===e&&!o||"start"!==e&&o;return l(a-u/2)?(r=c?Or:"top",n=Nr):l(a-1.5*u)?(r=c?"top":Or,n=Nr):(r=Er,n=1.5*u>a&&a>u/2?c?"left":"right":c?"right":"left"),{rotation:a,textAlign:n,textBaseline:r}}var n=t(ta),r=t(yt),a=t(T),o=t(gt),s=o.remRadian,l=o.isRadianAroundZero,u=Math.PI,c=function(t,e){this.opt=e,this.axisModel=t,n[rr](e,{labelOffset:0,nameDirection:1,tickDirection:1,labelDirection:1,silent:!0}),this.group=new r.Group({position:e[Tn].slice(),rotation:e[Ki]})};c[ea]={constructor:c,hasBuilder:function(t){return!!h[t]},add:function(t){h[t].call(this)},getGroup:function(){return this.group}};var h={axisLine:function(){var t=this.opt,e=this.axisModel;if(e.get("axisLine.show")){var i=this.axisModel.axis[st]();this.group.add(new r.Line({shape:{x1:i[0],y1:0,x2:i[1],y2:0},style:n[Lr]({lineCap:"round"},e[ir]("axisLine.lineStyle")[J]()),strokeContainThreshold:t.strokeContainThreshold,silent:!!t[Ae],z2:1}))}},axisTick:function(){var t=this.axisModel;if(t.get("axisTick.show")){for(var e=t.axis,i=t[ir](w),n=this.opt,a=i[ir](ce),o=i.get(Kr),s=f(i,n.labelInterval),l=e.getTicksCoords(),u=[],c=0;ch[1]?-1:1,f=["start"===s?h[0]-d*c:"end"===s?h[1]+d*c:(h[0]+h[1])/2,s===Er?t.labelOffset+l*c:0];o=s===Er?e(t,t[Ki],l):i(t,s,h),this.group.add(new r.Text({style:{text:a,textFont:u[$n](),fill:u[Be]()||n.get("axisLine.lineStyle.color"),textAlign:o[mi],textBaseline:o[vi]},position:f,rotation:o[Ki],silent:!0,z2:1}))}}},d=c.ifIgnoreOnTick=function(t,e,i){var n,r=t.scale;return r.type===En&&(typeof i===Fr?(n=r[W]()[e],!i(n,r[H](n))):e%(i+1))},f=c.getInterval=function(t,e){var i=t.get(B);return(null==i||"auto"==i)&&(i=e),i};return c}),e("echarts/component/axis/AxisView",[ia,ta,yt,"./AxisBuilder",C],function(t){function e(t,e){function i(t,e){var i=n[et](t);return i.toGlobalCoord(i[O](0))}var n=t[tn],r=e.axis,a={},o=r[Tn],s=r.onZero?"onZero":o,l=r.dim,u=n[I](),c=[u.x,u.x+u.width,u.y,u.y+u[hr]],h={x:{top:c[2],bottom:c[3]},y:{left:c[0],right:c[1]}};h.x.onZero=Math.max(Math.min(i("y"),h.x[Or]),h.x.top),h.y.onZero=Math.max(Math.min(i("x"),h.y.right),h.y.left),a[Tn]=["y"===l?h.y[s]:c[0],"x"===l?h.x[s]:c[3]];var d={x:0,y:1};a[Ki]=Math.PI/2*d[l];var f={top:-1,bottom:1,left:-1,right:1};a.labelDirection=a.tickDirection=a.nameDirection=f[o],r.onZero&&(a.labelOffset=h[l][o]-h[l].onZero),e[ir](w).get(ar)&&(a.tickDirection=-a.tickDirection),e[ir](R).get(ar)&&(a.labelDirection=-a.labelDirection);var p=e[ir](R).get(Hi);return a.labelRotation="top"===s?-p:p,a.labelInterval=r.getLabelInterval(),a.z2=1,a}var i=t(ta),n=t(yt),r=t("./AxisBuilder"),a=r.ifIgnoreOnTick,o=r.getInterval,s=[_,R,w,"axisName"],l=["splitLine","splitArea"],u=t(C)[Wt]({type:"axis",render:function(t,n){if(this.group[Si](),t.get("show")){var a=n[rn]("grid",t.get("gridIndex")),o=e(a,t),u=new r(t,o);i.each(s,u.add,u),this.group.add(u.getGroup()),i.each(l,function(e){t.get(e+".show")&&this["_"+e](t,a,o.labelInterval)},this)}},_splitLine:function(t,e,i){var r=t.axis,s=t[ir]("splitLine"),l=s[ir](ce),u=l.get("width"),c=l.get("color"),h=o(s,i);c=c instanceof Array?c:[c];for(var d=e[tn][I](),f=r.isHorizontal(),p=[],v=0,m=r.getTicksCoords(),g=[],y=[],x=0;x0){var p=s[Pt](0),v=Math.max(r[un](),r[ln]())/2,m=o.bind(u.removeClipPath,u);u.setClipPath(this._createClipPath(p.cx,p.cy,v,p[ii],p[ti],m,t))}this._data=s}},_createClipPath:function(t,e,i,n,r,o,s){var l=new a[Ke]({shape:{cx:t,cy:e,r0:0,r:i,startAngle:n,endAngle:n,clockwise:r}});return a[Oe](l,{shape:{endAngle:n+(r?1:-1)*Math.PI*2}},s,o),l}});return l}),e("echarts/action/createDataSelectAction",[ia,Y,ta],function(t){var e=t(Y),i=t(ta);return function(t,n){i.each(n,function(i){i[on]="updateView",e[Kt](i,function(e,n){var r={};return n[ie]({mainType:"series",subType:t,query:e},function(t){t[i.method]&&t[i.method](e.name);var n=t[Nn]();n.each(function(e){var i=n[Rn](e);r[i]=t.isSelected(i)||!1})}),{name:e.name,selected:r}})})}}),e("echarts/visual/dataColor",[ia],function(t){return function(t,e){var i=e.get("color"),n=0;e.eachRawSeriesByType(t,function(t){var r=t.get("color",!0),a=t.getRawData();if(!e[pe](t)){var o=t[Nn]();o.each(function(t){var e=o[zn](t),s=o[Vn](t),l=o[It](t,"color",!0);if(l)a[fe](s,"color",l);else{var u=r?r[s%r[Kr]]:i[(s+n)%i[Kr]],c=e.get(re)||u;a[fe](s,"color",c),o[fe](t,"color",c)}})}n+=a.count()})}}),e("echarts/chart/pie/labelLayout",[ia,lr],function(t){function e(t,e,i,n,r,a,o){function s(e,i,n,r){for(var a=e;i>a;a++)if(t[a].y+=n,a>e&&i>a+1&&t[a+1].y>t[a].y+t[a][hr])return void l(a,n/2);l(i-1,n/2)}function l(e,i){for(var n=e;n>=0&&(t[n].y-=i,!(n>0&&t[n].y>t[n-1].y+t[n-1][hr]));n--);}t.sort(function(t,e){return t.y-e.y});for(var u,c=0,h=t[Kr],d=[],f=[],p=0;h>p;p++)u=t[p].y-c,0>u&&s(p,h,-u,r),c=t[p].y+t[p][hr];0>o-c&&l(h-1,c-o);for(var p=0;h>p;p++)t[p].y>=i?f.push(t[p]):d.push(t[p])}function i(t,i,n,r,a,o){for(var s=[],l=[],u=0;uw?-1:1)*x,I=k;r=L+(0>w?-5:5),a=I,h=[[A,C],[T,k],[L,I]]}d=S?Nr:w>0?"left":"right"}var D=Er,P=v[ir](er)[$n](),z=v.get(Hi)?0>w?-_+Math.PI:-_:0,R=t[ct](i,Fn)||l[Rn](i),V=n[tr](R,P,d,D);c=!!z,f.label={x:r,y:a,height:V[hr],length:y,length2:x,linePoints:h,textAlign:d,textBaseline:D,font:P,rotation:z},u.push(f.label)}),!c&&t.get("avoidLabelOverlap")&&i(u,o,s,e,r,a)}}),e("echarts/chart/pie/pieLayout",[ia,gt,"./labelLayout",ta],function(t){var e=t(gt),i=e[Br],n=t("./labelLayout"),r=t(ta),a=2*Math.PI,o=Math.PI/180;return function(t,s,l){s[de](t,function(t){var s=t.get(Nr),u=t.get(jn);r[Dr](u)||(u=[0,u]),r[Dr](s)||(s=[s,s]);var c=l[un](),h=l[ln](),d=Math.min(c,h),f=i(s[0],c),p=i(s[1],h),v=i(u[0],d/2),m=i(u[1],d/2),g=t[Nn](),y=-t.get(ii)*o,x=t.get("minAngle")*o,_=g[Nt]("value"),w=Math.PI/(_||g.count())*2,b=t.get(ti),M=t.get("roseType"),S=g[Bt]("value");S[0]=0;var A=a,C=0,T=y,k=b?1:-1;if(g.each("value",function(t,i){var n;n="area"!==M?0===_?w:t*w:a/(g.count()||1),x>n?(n=x,A-=x):C+=t;var r=T+k*n;g[Dt](i,{angle:n,startAngle:T,endAngle:r,clockwise:b,cx:f,cy:p,r0:v,r:M?e[Gr](t,S,[v,m]):m}),T=r},!0),a>A)if(.001>=A){var L=a/g.count();g.each(function(t){var e=g[Pt](t);e[ii]=y+k*t*L,e[ei]=y+k*(t+1)*L})}else w=A/C,T=y,g.each("value",function(t,e){var i=g[Pt](e),n=i.angle===x?x:t*w;i[ii]=T,i[ei]=T+k*n,T+=n});n(t,m,c,h)})}}),e("echarts/processor/dataFilter",[],function(){return function(t,e){var i=e[hn]({mainType:"legend"});i&&i[Kr]&&e[de](t,function(t){var e=t[Nn]();e[Et](function(t){for(var n=e[Rn](t),r=0;rt.get("largeThreshold")?r:a;this[$]=s,s[mt](n),o.add(s.group),o[Ii](s===r?a.group:r.group)},updateLayout:function(t){this[$][Ai](t)},remove:function(t,e){this[$]&&this[$][Ii](e,!0)}})}),e("echarts/chart/scatter",[ia,ta,Y,"./scatter/ScatterSeries","./scatter/ScatterView",X,j],function(t){var e=t(ta),i=t(Y);t("./scatter/ScatterSeries"),t("./scatter/ScatterView"),i[Xt]("chart",e.curry(t(X),ae,dt,null)),i[Yt](e.curry(t(j),ae))}),e("echarts/component/tooltip/TooltipModel",[ia,C],function(t){t(C)[Ut]({type:"tooltip",defaultOption:{zlevel:0,z:8,show:!0,showContent:!0,trigger:"item",triggerOn:"mousemove",alwaysShowContent:!1,hideDelay:100,transitionDuration:.4,enterable:!1,backgroundColor:"rgba(50,50,50,0.7)",borderColor:"#333",borderRadius:4,borderWidth:0,padding:5,axisPointer:{type:"line",axis:"auto",animation:!0,animationDurationUpdate:200,animationEasingUpdate:"exponentialOut",lineStyle:{color:"#555",width:1,type:"solid"},crossStyle:{color:"#555",width:1,type:"dashed",textStyle:{}},shadowStyle:{color:"rgba(150,150,150,0.3)"}},textStyle:{color:"#fff",fontSize:14}}})}),e("echarts/component/tooltip/TooltipContent",[ia,ta,Gi,Re,v],function(t){function e(t){var e="cubic-bezier(0.23, 1, 0.32, 1)",i="left "+t+"s "+e+",top "+t+"s "+e;return o.map(d,function(t){return t+"transition:"+i}).join(";")}function i(t){var e=[],i=t.get("fontSize"),n=t[Be]();return n&&e.push("color:"+n),e.push("font:"+t[$n]()),i&&e.push("line-height:"+Math.round(3*i/2)+"px"),c(["decoration","align"],function(i){var n=t.get(i);n&&e.push("text-"+i+":"+n)}),e.join(";")}function n(t){t=t;var n=[],r=t.get("transitionDuration"),a=t.get(xe),o=t[ir](er),l=t.get(p);return r&&n.push(e(r)),a&&(n.push("background-Color:"+s.toHex(a)),n.push("filter:alpha(opacity=70)"),n.push("background-Color:"+a)),c(["width","color",jn],function(e){var i="border-"+e,r=h(i),a=t.get(r);null!=a&&n.push(i+":"+a+("color"===e?"":"px"))}),n.push(i(o)),null!=l&&n.push("padding:"+u[Mn](l).join("px ")+"px"),n.join(";")+";"}function r(t,e){var i=document[Yr]("div"),n=e.getZr();this.el=i,this._x=e[un]()/2,this._y=e[ln]()/2,t[_e](i),this._container=t,this._show=!1,this._hideTimeout;var r=this;i.onmouseenter=function(){r.enterable&&(clearTimeout(r._hideTimeout),r._show=!0),r._inContent=!0},i.onmousemove=function(e){if(!r.enterable){var i=n.handler;l.normalizeEvent(t,e),i.dispatch(Pe,e)}},i.onmouseleave=function(){r.enterable&&r._show&&r.hideLater(r._hideDelay),r._inContent=!1},a(i,t)}function a(t,e){function i(t){n(t[Zi])&&t.preventDefault()}function n(i){for(;i&&i!==e;){if(i===t)return!0;i=i[ke]}}l.addEventListener(e,"touchstart",i),l.addEventListener(e,"touchmove",i),l.addEventListener(e,"touchend",i)}var o=t(ta),s=t(Gi),l=t(Re),u=t(v),c=o.each,h=u.toCamelCase,d=["","-webkit-","-moz-","-o-"],f="position:absolute;display:block;border-style:solid;white-space:nowrap;";return r[ea]={constructor:r,enterable:!0,update:function(){var t=this._container,e=t.currentStyle||document.defaultView.getComputedStyle(t),i=t.style;"absolute"!==i[Tn]&&"absolute"!==e[Tn]&&(i[Tn]="relative")},show:function(t){clearTimeout(this._hideTimeout),this.el.style.cssText=f+n(t)+";left:"+this._x+"px;top:"+this._y+"px;",this._show=!0},setContent:function(t){var e=this.el;e[we]=t,e.style.display=t?"block":"none"},moveTo:function(t,e){var i=this.el.style;i.left=t+"px",i.top=e+"px",this._x=t,this._y=e},hide:function(){this.el.style.display="none",this._show=!1},hideLater:function(t){!this._show||this._inContent&&this.enterable||(t?(this._hideDelay=t,this._show=!1,this._hideTimeout=setTimeout(o.bind(this.hide,this),t)):this.hide())},isShow:function(){return this._show}},r}),e("echarts/component/tooltip/TooltipView",[ia,"./TooltipContent",yt,ta,v,gt,Ve,C],function(t){function e(t,e){if(!t||!e)return!1;var i=m.round;return i(t[0])===i(e[0])&&i(t[1])===i(e[1])}function i(t,e,i,n){return{x1:t,y1:e,x2:i,y2:n}}function n(t,e,i,n){return{x:t,y:e,width:i,height:n}}function r(t,e,i,n,r,a){return{cx:t,cy:e,r0:i,r:n,startAngle:r,endAngle:a,clockwise:!0}}function a(t,e,i,n,r){var a=i.clientWidth,o=i[ye],s=20;return t+a+s>n?t-=a+s:t+=s,e+o+s>r?e-=o+s:e+=s,[t,e]}function o(t,e,i){var n=i.clientWidth,r=i[ye],a=5,o=0,s=0,l=e.width,u=e[hr];switch(t){case ar:o=e.x+l/2-n/2,s=e.y+u/2-r/2;break;case"top":o=e.x+l/2-n/2,s=e.y-r-a;break;case Or:o=e.x+l/2-n/2,s=e.y+u+a;break;case"left":o=e.x-n-a,s=e.y+u/2-r/2;break;case"right":o=e.x+l+a,s=e.y+u/2-r/2}return[o,s]}function s(t,e,i,n,r,s,l){var u=l[un](),c=l[ln](),d=s&&s[tr]().clone();if(s&&d[dr](s[Xi]),typeof t===Fr&&(t=t([e,i],r,d)),h[Dr](t))e=g(t[0],u),i=g(t[1],c);else if(typeof t===qr&&s){var f=o(t,d,n.el);e=f[0],i=f[1]}else{var f=a(e,i,n.el,u,c);e=f[0],i=f[1]}n[hi](e,i)}function l(t){var e=t[tn],i=t.get("tooltip.trigger",!0);return!(!e||e.type!==K&&"polar"!==e.type&&e.type!==y||"item"===i)}var u=t("./TooltipContent"),c=t(yt),h=t(ta),p=t(v),m=t(gt),g=m[Br],x=t(Ve);t(C)[Wt]({type:"tooltip",_axisPointers:{},init:function(t,e){if(!x.node){var i=new u(e[cn](),e);this._tooltipContent=i,e.on("showTip",this._manuallyShowTip,this),e.on("hideTip",this._manuallyHideTip,this)}},render:function(t,e,i){if(!x.node){this.group[Si](),this._axisPointers={},this._tooltipModel=t,this._ecModel=e,this._api=i,this._lastHover={};var n=this._tooltipContent;n[on](),n.enterable=t.get("enterable"),this._alwaysShowContent=t.get("alwaysShowContent"),this._seriesGroupByAxis=this._prepareAxisTriggerData(t,e);var r=this._crossText;if(r&&this.group.add(r),null!=this._lastX&&null!=this._lastY){var a=this;clearTimeout(this._refreshUpdateTimeout),this._refreshUpdateTimeout=setTimeout(function(){a._manuallyShowTip({x:a._lastX,y:a._lastY})})}var o=this._api.getZr(),s=this._tryShow;o.off("click",s),o.off(Pe,s),o.off(Ze,this._hide),"click"===t.get("triggerOn")?o.on("click",s,this):(o.on(Pe,s,this),o.on(Ze,this._hide,this))}},_manuallyShowTip:function(t){if(t.from!==this.uid){var e=this._ecModel,i=t[Bn],n=t[wi],r=e.getSeriesByIndex(i),a=this._api;if(null==t.x||null==t.y){if(r||e[he](function(t){l(t)&&!r&&(r=t)}),r){var o=r[Nn]();null==n&&(n=o[xi](t.name));var s,u,c=o[_i](n),h=r[tn];if(h&&h[ot]){var d=h[ot](o[Gt](h[Ht],n,!0));s=d&&d[0],u=d&&d[1]}else if(c){var f=c[tr]().clone();f[dr](c[Xi]),s=f.x+f.width/2,u=f.y+f[hr]/2}null!=s&&null!=u&&this._tryShow({offsetX:s,offsetY:u,target:c,event:{}})}}else{var c=a.getZr().handler.findHover(t.x,t.y);this._tryShow({offsetX:t.x,offsetY:t.y,target:c,event:{}})}}},_manuallyHideTip:function(t){t.from!==this.uid&&this._hide()},_prepareAxisTriggerData:function(t,e){var i={};return e[he](function(t){if(l(t)){var e,n,r=t[tn];r.type===K?(e=r[$i](),n=e.dim+e.index):r.type===y?(e=r[et](),n=e.dim+e.type):(e=r[$i](),n=e.dim+r.name),i[n]=i[n]||{coordSys:[],series:[]},i[n].coordSys.push(r),i[n][pn].push(t)}},this),i},_tryShow:function(t){var e=t[Zi],i=this._tooltipModel,n=i.get(bi),r=this._ecModel,a=this._api;if(i)if(this._lastX=t[Ie],this._lastY=t[Le],e&&null!=e[wi]){var o=e[$t]||r.getSeriesByIndex(e[Bn]),s=e[wi],l=o[Nn]()[zn](s);"axis"===(l.get("tooltip.trigger")||n)?this._showAxisTooltip(i,r,t):(this._ticket="",this._hideAxisPointer(),this._resetLastHover(),this._showItemTooltipContent(o,s,t)),a[sn]({type:"showTip",from:this.uid,dataIndex:e[wi],seriesIndex:e[Bn]})}else"item"===n?this._hide():this._showAxisTooltip(i,r,t),"cross"===i.get("axisPointer.type")&&a[sn]({type:"showTip",from:this.uid,x:t[Ie],y:t[Le]})},_showAxisTooltip:function(t,i,n){var r=t[ir]("axisPointer"),a=r.get("type");if("cross"===a){var o=n[Zi];if(o&&null!=o[wi]){var s=i.getSeriesByIndex(o[Bn]),l=o[wi];this._showItemTooltipContent(s,l,n)}}this._showAxisPointer();var u=!0;h.each(this._seriesGroupByAxis,function(t){var i=t.coordSys,o=i[0],s=[n[Ie],n[Le]];if(!o.containPoint(s))return void this._hideAxisPointer(o.name);u=!1;var l=o[Ht],c=o.pointToData(s,!0);s=o[ot](c);var d=o[$i](),f=r.get("axis");"auto"===f&&(f=d.dim);var p=!1,v=this._lastHover;if("cross"===a)e(v.data,c)&&(p=!0),v.data=c;else{var m=h[Ur](l,f);v.data===c[m]&&(p=!0),v.data=c[m]}o.type!==K||p?"polar"!==o.type||p?o.type!==y||p||this._showSinglePointer(r,o,f,s):this._showPolarPointer(r,o,f,s):this._showCartesianPointer(r,o,f,s),"cross"!==a&&this._dispatchAndShowSeriesTooltipContent(o,t[pn],s,c,p)},this),u&&this._hide()},_showCartesianPointer:function(t,e,r,a){function o(n,r,a){var o="x"===n?i(r[0],a[0],r[0],a[1]):i(a[0],r[1],a[1],r[1]),s=l._getPointerElement(e,t,n,o);h?c[Ee](s,{shape:o},t):s.attr({shape:o})}function s(i,r,a){var o=e[et](i),s=o[it](),u=a[1]-a[0],d="x"===i?n(r[0]-s/2,a[0],s,u):n(a[0],r[1]-s/2,u,s),f=l._getPointerElement(e,t,i,d);h?c[Ee](f,{shape:d},t):f.attr({shape:d})}var l=this,u=t.get("type"),h="cross"!==u;if("cross"===u)o("x",a,e[et]("y").getGlobalExtent()),o("y",a,e[et]("x").getGlobalExtent()),this._updateCrossText(e,a,t);else{var d=e[et]("x"===r?"y":"x"),f=d.getGlobalExtent();e.type===K&&("line"===u?o:s)(r,a,f)}},_showSinglePointer:function(t,e,n,r){function a(n,r,a){var s=e[et](),u=s[f],h=u===An?i(r[0],a[0],r[0],a[1]):i(a[0],r[1],a[1],r[1]),d=o._getPointerElement(e,t,n,h);l?c[Ee](d,{shape:h},t):d.attr({shape:h})}var o=this,s=t.get("type"),l="cross"!==s,u=e[I](),h=[u.y,u.y+u[hr]];a(n,r,h)},_showPolarPointer:function(t,e,n,a){function o(n,r,a){var o,s=e.pointToCoord(r);if("angle"===n){var u=e.coordToPoint([a[0],s[1]]),h=e.coordToPoint([a[1],s[1]]);o=i(u[0],u[1],h[0],h[1])}else o={cx:e.cx,cy:e.cy,r:s[0]};var d=l._getPointerElement(e,t,n,o);f?c[Ee](d,{shape:o},t):d.attr({shape:o})}function s(i,n,a){var o,s=e[et](i),u=s[it](),h=e.pointToCoord(n),d=Math.PI/180;o="angle"===i?r(e.cx,e.cy,a[0],a[1],(-h[1]-u/2)*d,(-h[1]+u/2)*d):r(e.cx,e.cy,h[0]-u/2,h[0]+u/2,0,2*Math.PI);var p=l._getPointerElement(e,t,i,o);f?c[Ee](p,{shape:o},t):p.attr({shape:o})}var l=this,u=t.get("type"),h=e.getAngleAxis(),d=e.getRadiusAxis(),f="cross"!==u;if("cross"===u)o("angle",a,d[st]()),o(jn,a,h[st]()),this._updateCrossText(e,a,t);else{var p=e[et](n===jn?"angle":jn),v=p[st]();("line"===u?o:s)(n,a,v)}},_updateCrossText:function(t,e,i){var n=i[ir]("crossStyle"),r=n[ir](er),a=this._tooltipModel,o=this._crossText;o||(o=this._crossText=new c.Text({style:{textAlign:"left",textBaseline:"bottom"}}),this.group.add(o));var s=t.pointToData(e),l=t[Ht];s=h.map(s,function(e,i){var n=t[et](l[i]);return e=n.type===St||"time"===n.type?n.scale[H](e):p[en](e[Vr](n[Rr]()))}),o[qe]({fill:r[Be]()||n.get("color"),textFont:r[$n](),text:s.join(", "),x:e[0]+5,y:e[1]-5}),o.z=a.get("z"),o[Se]=a.get(Se)},_getPointerElement:function(t,e,i,n){var r=this._tooltipModel,a=r.get("z"),o=r.get(Se),s=this._axisPointers,l=t.name;if(s[l]=s[l]||{},s[l][i])return s[l][i];var u=e.get("type"),h=e[ir](u+"Style"),d="shadow"===u,f=h[d?"getAreaStyle":J](),p="polar"===t.type?d?Ke:i===jn?Je:"Line":d?"Rect":"Line";d?f[br]=null:f.fill=null;var v=s[l][i]=new c[p]({style:f,z:a,zlevel:o,silent:!0,shape:n});return this.group.add(v),v},_dispatchAndShowSeriesTooltipContent:function(t,e,i,n,r){var a=this._tooltipModel,o=this._tooltipContent,l=t[$i](),u=h.map(e,function(t){return{seriesIndex:t[Bn],dataIndex:t.getAxisTooltipDataIndex?t.getAxisTooltipDataIndex(t[k](l.dim),n,l):t[Nn]().indexOfNearest(t[k](l.dim)[0],n["x"===l.dim||l.dim===jn?0:1])}}),c=this._lastHover,f=this._api;if(c.payloadBatch&&!r&&f[sn]({type:"downplay",batch:c.payloadBatch}),r||(f[sn]({type:"highlight",batch:u}),c.payloadBatch=u),f[sn]({type:"showTip",dataIndex:u[0][wi],seriesIndex:u[0][Bn],from:this.uid}),l&&a.get("showContent")){var v,m=a.get(Dn),g=a.get(Tn),y=h.map(e,function(t,e){return t[Pn](u[e][wi])});o.show(a);var x=u[0][wi];if(!r){if(this._ticket="",m){if(typeof m===qr)v=p.formatTpl(m,y);else if(typeof m===Fr){var _=this,w="axis_"+t.name+"_"+x,b=function(t,e){t===_._ticket&&(o.setContent(e),s(g,i[0],i[1],o,y,null,f))};_._ticket=w,v=m(y,w,b)}}else{var M=e[0][Nn]()[Rn](x);v=(M?M+Qi:"")+h.map(e,function(t,e){return t[d](u[e][wi],!0)}).join(Qi)}o.setContent(v)}s(g,i[0],i[1],o,y,null,f)}},_showItemTooltipContent:function(t,e,i){var n=this._api,r=t[Nn](),a=r[zn](e),o=this._tooltipModel,l=this._tooltipContent,u=a[ir]("tooltip");if(u.parentModel?u.parentModel.parentModel=o:u.parentModel=this._tooltipModel,u.get("showContent")){var c,h=u.get(Dn),f=u.get(Tn),v=t[Pn](e);if(h){if(typeof h===qr)c=p.formatTpl(h,v);else if(typeof h===Fr){var m=this,g="item_"+t.name+"_"+e,y=function(t,e){t===m._ticket&&(l.setContent(e),s(f,i[Ie],i[Le],l,v,i[Zi],n))};m._ticket=g,c=h(v,g,y)}}else c=t[d](e);l.show(u),l.setContent(c),s(f,i[Ie],i[Le],l,v,i[Zi],n)}},_showAxisPointer:function(t){if(t){var e=this._axisPointers[t];e&&h.each(e,function(t){t.show()})}else this.group[kn](function(t){t.show()}),this.group.show()},_resetLastHover:function(){var t=this._lastHover;t.payloadBatch&&this._api[sn]({type:"downplay",batch:t.payloadBatch}),this._lastHover={}},_hideAxisPointer:function(t){if(t){var e=this._axisPointers[t];e&&h.each(e,function(t){t.hide()})}else this.group.hide()},_hide:function(){this._hideAxisPointer(),this._resetLastHover(),this._alwaysShowContent||this._tooltipContent.hideLater(this._tooltipModel.get("hideDelay")),this._api[sn]({type:"hideTip",from:this.uid})},dispose:function(t,e){if(!x.node){var i=e.getZr();this._tooltipContent.hide(),i.off("click",this._tryShow),i.off(Pe,this._tryShow),i.off(Ze,this._hide),e.off("showTip",this._manuallyShowTip),e.off("hideTip",this._manuallyHideTip)}}})}),e("echarts/component/tooltip",[ia,"./tooltip/TooltipModel","./tooltip/TooltipView",Y,Y],function(t){t("./tooltip/TooltipModel"),t("./tooltip/TooltipView"),t(Y)[Kt]({type:"showTip",event:"showTip",update:"none"},function(){}),t(Y)[Kt]({type:"hideTip",event:"hideTip",update:"none"},function(){})}),e("echarts/coord/polar/RadiusAxis",[ia,ta,"../Axis"],function(t){function e(t,e){n.call(this,jn,t,e),this.type=St}var i=t(ta),n=t("../Axis");return e[ea]={constructor:e,dataToRadius:n[ea][O],radiusToData:n[ea][V]},i[Tr](e,n),e}),e("echarts/coord/polar/AngleAxis",[ia,ta,"../Axis"],function(t){function e(t,e){e=e||[0,360],n.call(this,"angle",t,e),this.type=St}var i=t(ta),n=t("../Axis");return e[ea]={constructor:e,dataToAngle:n[ea][O],angleToData:n[ea][V]},i[Tr](e,n),e}),e("echarts/coord/polar/Polar",[ia,"./RadiusAxis","./AngleAxis"],function(t){var e=t("./RadiusAxis"),i=t("./AngleAxis"),n=function(t){this.name=t||"",this.cx=0,this.cy=0,this._radiusAxis=new e,this._angleAxis=new i};return n[ea]={constructor:n,type:"polar",dimensions:[jn,"angle"],containPoint:function(t){var e=this.pointToCoord(t);return this._radiusAxis[pi](e[0])&&this._angleAxis[pi](e[1])},containData:function(t){return this._radiusAxis.containData(t[0])&&this._angleAxis.containData(t[1])},getAxis:function(t){return this["_"+t+"Axis"]},getAxesByScale:function(t){var e=[],i=this._angleAxis,n=this._radiusAxis;return i.scale.type===t&&e.push(i),n.scale.type===t&&e.push(n),e},getAngleAxis:function(){return this._angleAxis},getRadiusAxis:function(){return this._radiusAxis},getOtherAxis:function(t){var e=this._angleAxis;return t===e?this._radiusAxis:e},getBaseAxis:function(){return this.getAxesByScale(En)[0]||this.getAxesByScale("time")[0]||this.getAngleAxis()},dataToPoints:function(t){return t[Ot](this[Ht],function(t,e){return this[ot]([t,e])},this)},dataToPoint:function(t,e){return this.coordToPoint([this._radiusAxis.dataToRadius(t[0],e),this._angleAxis.dataToAngle(t[1],e)])},pointToData:function(t,e){var i=this.pointToCoord(t);return[this._radiusAxis.radiusToData(i[0],e),this._angleAxis.angleToData(i[1],e)]},pointToCoord:function(t){var e=t[0]-this.cx,i=t[1]-this.cy,n=this.getAngleAxis(),r=n[st](),a=Math.min(r[0],r[1]),o=Math.max(r[0],r[1]);n[tt]?a=o-360:o=a+360;var s=Math.sqrt(e*e+i*i);e/=s,i/=s;for(var l=Math.atan2(-i,e)/Math.PI*180,u=a>l?1:-1;a>l||l>o;)l+=360*u;return[s,l]},coordToPoint:function(t){var e=t[0],i=t[1]/180*Math.PI,n=Math.cos(i)*e+this.cx,r=-Math.sin(i)*e+this.cy;return[n,r]}},n}),e("echarts/coord/polar/AxisModel",[ia,ta,z,"../axisModelCreator","../axisModelCommonMixin"],function(t){function e(t,e){return e.type||(e.data?St:"value")}var i=t(ta),n=t(z),r=t("../axisModelCreator"),a=n[Lr]({type:"polarAxis",axis:null});i.merge(a[ea],t("../axisModelCommonMixin"));var o={angle:{polarIndex:0,startAngle:90,clockwise:!0,splitNumber:12,axisLabel:{rotate:!1}},radius:{polarIndex:0,splitNumber:5}};r("angle",a,e,o.angle),r(jn,a,e,o[jn])}),e("echarts/coord/polar/PolarModel",[ia,"./AxisModel",C],function(t){t("./AxisModel"),t(C)[Ut]({type:"polar",dependencies:["polarAxis","angleAxis"],coordinateSystem:null,findAxisModel:function(t){var e,i=this[nr];return i[ie](t,function(t){i[rn]("polar",t[Sr]("polarIndex"))===this&&(e=t)},this),e},defaultOption:{zlevel:0,z:0,center:["50%","50%"],radius:"80%"}})}),e("echarts/coord/polar/polarCreator",[ia,"./Polar",gt,D,"./PolarModel",At],function(t){function e(t,e){var i=t.get(Nr),n=t.get(jn),r=e[un](),o=e[ln](),s=a[Br];this.cx=s(i[0],r),this.cy=s(i[1],o);var l=this.getRadiusAxis(),u=Math.min(r,o)/2;l[q](0,s(n,u))}function i(t,e){var i=this,n=i.getAngleAxis(),r=i.getRadiusAxis();if(n.scale[q](1/0,-(1/0)),r.scale[q](1/0,-(1/0)),t[he](function(t){if(t[tn]===i){var e=t[Nn]();r.scale[U](e[Bt](jn,r.type!==St)),n.scale[U](e[Bt]("angle",n.type!==St))}}),s(n,n.model),s(r,r.model),n.type===St&&!n[nt]){var a=n[st](),o=360/n.scale.count();n[tt]?a[1]+=o:a[1]-=o,n[q](a[0],a[1])}}function n(t,e){if(t.type=e.get("type"),t.scale=o[N](e),t[nt]=e.get(Z)&&t.type===St,"angleAxis"===e.mainType){var i=e.get(ii);t[tt]=e.get(tt)^e.get(ti),t[q](i,i+(t[tt]?-360:360))}e.axis=t,t.model=e}var r=t("./Polar"),a=t(gt),o=t(D),s=o[F];t("./PolarModel");var l={dimensions:r[ea][Ht],create:function(t,a){var o=[];return t[ie]("polar",function(t,s){var l=new r(s);l[Me]=e,l[on]=i;var u=l.getRadiusAxis(),c=l.getAngleAxis(),h=t.findAxisModel("radiusAxis"),d=t.findAxisModel("angleAxis");n(u,h),n(c,d),l[Me](t,a),o.push(l),t[tn]=l}),t[he](function(t){"polar"===t.get(tn)&&(t[tn]=o[t.get("polarIndex")])}),o}};t(At)[an]("polar",l)}),e("echarts/component/axis/AngleAxisView",[ia,ta,yt,T,C],function(t){function e(t,e,i,n){var r=t.coordToPoint([e,n]),a=t.coordToPoint([i,n]);return{x1:r[0],y1:r[1],x2:a[0],y2:a[1]}}var i=t(ta),n=t(yt),r=t(T),a=[_,R,w,"splitLine","splitArea"];t(C)[Wt]({type:"angleAxis",render:function(t,e){if(this.group[Si](),t.get("show")){var n=e[rn]("polar",t.get("polarIndex")),r=t.axis,o=n[tn],s=o.getRadiusAxis()[st](),l=r.getTicksCoords();r.type!==St&&l.pop(),i.each(a,function(e){t.get(e+".show")&&this["_"+e](t,o,l,s)},this)}},_axisLine:function(t,e,i,r){var a=t[ir]("axisLine.lineStyle"),o=new n[Je]({shape:{cx:e.cx,cy:e.cy,r:r[1]},style:a[J](),z2:1,silent:!0});o.style.fill=null,this.group.add(o)},_axisTick:function(t,r,a,o){var s=t[ir](w),l=(s.get(ar)?-1:1)*s.get(Kr),u=i.map(a,function(t){return new n.Line({shape:e(r,o[1],o[1]+l,t)})});this.group.add(n.mergePath(u,{style:s[ir](ce)[J]()}))},_axisLabel:function(t,e,i,a){for(var o=t.axis,s=t.get("data"),l=t[ir](R),u=l[ir](er),c=t[E](),h=l.get(wn),d=o.getLabelsCoords(),f=0;fm?"left":"right",x=Math.abs(v[1]-g)/p<.3?Er:v[1]>g?"top":Or,_=u;s&&s[f]&&s[f][er]&&(_=new r(s[f][er],u)),this.group.add(new n.Text({style:{x:v[0],y:v[1],fill:_[Be](),text:c[f],textAlign:y,textBaseline:x,textFont:_[$n]()},silent:!0}))}},_splitLine:function(t,r,a,o){var s=t[ir]("splitLine"),l=s[ir](ce),u=l.get("color"),c=0;u=u instanceof Array?u:[u];for(var h=[],d=0;d=0&&(e=0),{name:t.text,min:e,max:i}}),h=e.find(s,function(t){return(t.polarIndex||0)===o}),d=e.find(l,function(t){return(t.polarIndex||0)===o});h||(h={type:"value",polarIndex:o},s.push(h)),d||(d={type:"category",polarIndex:o},l.push(d)),d.data=e.map(n.indicator,function(t){var e={value:t.text},i=t[R];return i&&i[er]&&(e[er]=i[er]),e}),d[ii]=n[ii]||90,n[_]&&(d.splitLine=n[_]),n[R]&&(d[R]=n[R]),n.splitLine&&(h.splitLine=n.splitLine),n.splitArea&&(h.splitArea=n.splitArea),h.splitLine=h.splitLine||{},h.splitArea=h.splitArea||{},null==h.splitLine.show&&(h.splitLine.show=!0),null==h.splitArea.show&&(h.splitArea.show=!0),d[Z]=!1,h.min=0,h.max=1,h[B]=1/(n[G]||5),h[_]={show:!1},h[R]={show:!1},h[w]={show:!1};var f=a(u,function(t){return(t.polarIndex||0)===o}),p=e.map(c,function(){return[]});r(f,function(i){if(i.indicator=c,i.data[0]&&e[Dr](i.data[0].value)){var n=i.data,r=n[0];i.data=r.value,i.name=r.name;for(var a=1;al;l++)a=Math.min(a,t[l]),o=Math.max(o,t[l]);r[q](a,o),r.niceExtent(n[G]||5);var u=r[st]();null==c[e].min&&(c[e].min=u[0]),null==c[e].max&&(c[e].max=u[1])}})}}))}}),e("echarts/chart/radar",[ia,ta,Y,"./radar/RadarSeries","./radar/RadarView",X,j,"./radar/backwardCompat"],function(t){var e=t(ta),i=t(Y);t("./radar/RadarSeries"),t("./radar/RadarView"),i[Xt]("chart",e.curry(t(X),"radar",dt,null)),i[Yt](e.curry(t(j),"radar")),i[Qt](t("./radar/backwardCompat"))}),e("echarts/component/legend/LegendModel",[ia,ta,T,C],function(t){var e=t(ta),i=t(T),n=t(C)[Ut]({type:"legend",dependencies:[pn],layoutMode:{type:"box",ignoreSize:!0},init:function(t,e,i){this[xn](t,i),t[g]=t[g]||{},this._updateData(i);var n=this._data,r=this[Xn][g];if(n[0]&&this.get(x)===y){var a=!1;for(var o in r)r[o]&&(this.select(o),a=!0);!a&&this.select(n[0].get("name"))}},mergeOption:function(t){n.superCall(this,mn,t),this._updateData(this[nr])},_updateData:function(t){var n=e.map(this.get("data")||[],function(t){return typeof t===qr&&(t={name:t}),new i(t,this,this[nr])},this);this._data=n;var r=e.map(t.getSeries(),function(t){return t.name});t[he](function(t){if(t[m]){var e=t[m]();r=r[Hr](e[Ot](e[Rn]))}}),this._availableNames=r},getData:function(){return this._data},select:function(t){var i=this[Xn][g],n=this.get(x);if(n===y){var r=this._data;e.each(r,function(t){i[t.get("name")]=!1})}i[t]=!0},unSelect:function(t){this.get(x)!==y&&(this[Xn][g][t]=!1)},toggleSelected:function(t){var e=this[Xn][g];t in e||(e[t]=!0),this[e[t]?"unSelect":"select"](t)},isSelected:function(t){var i=this[Xn][g];return!(t in i&&!i[t])&&e[Ur](this._availableNames,t)>=0},defaultOption:{zlevel:0,z:4,show:!0,orient:"horizontal",left:"center",top:"top",align:"auto",backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",borderWidth:0,padding:5,itemGap:10,itemWidth:25,itemHeight:14,textStyle:{color:"#333"},selectedMode:!0}});return n}),e("echarts/component/legend/legendAction",[ia,C,ta],function(t){function e(t,e,i){var r,a={},o="toggleSelected"===t;return i[ie](se,function(i){o&&null!=r?i[r?"select":"unSelect"](e.name):(i[t](e.name),r=i.isSelected(e.name));var s=i[Nn]();n.each(s,function(t){var e=t.get("name");if("\n"!==e&&""!==e){var n=i.isSelected(e);e in a?a[e]=a[e]&&n:a[e]=n}})}),{name:e.name,selected:a}}var i=t(C),n=t(ta);i[Kt]("legendToggleSelect","legendselectchanged",n.curry(e,"toggleSelected")),i[Kt]("legendSelect","legendselected",n.curry(e,"select")),i[Kt]("legendUnSelect","legendunselected",n.curry(e,"unSelect"))}),e("echarts/component/helper/listComponent",[ia,P,v,yt],function(t){function e(t,e,n){i[_n](t,e[L](),{width:n[un](),height:n[ln]()},e.get(p))}var i=t(P),n=t(v),r=t(yt);return{layout:function(t,n,r){var a=i[bn](n[L](),{width:r[un](),height:r[ln]()},n.get(p));i.box(n.get(f),t,n.get(h),a.width,a[hr]),e(t,n,r)},addBackground:function(t,e){var i=n[Mn](e.get(p)),a=t[tr](),o=e[ht](["color",wr]);o.fill=e.get(xe);var s=new r.Rect({shape:{x:a.x-i[3],y:a.y-i[0],width:a.width+i[1]+i[3],height:a[hr]+i[0]+i[2]},style:o,silent:!0,z2:-1});r[Ue](s),t.add(s)}}}),e("echarts/component/legend/LegendView",[ia,ta,xt,yt,"../helper/listComponent",C],function(t){function e(t,e){e[sn]({type:"legendToggleSelect",name:t})}function i(t,e,i){t.get("legendHoverLink")&&i[sn]({type:"highlight",seriesName:t.name,name:e})}function n(t,e,i){t.get("legendHoverLink")&&i[sn]({type:"downplay",seriesName:t.name,name:e})}var r=t(ta),a=t(xt),o=t(yt),s=t("../helper/listComponent"),l=r.curry,u="#ccc";return t(C)[Wt]({type:"legend",init:function(){this._symbolTypeStore={}},render:function(t,a,h){var d=this.group;if(d[Si](),t.get("show")){var p=t.get(x),v=t.get("itemWidth"),g=t.get("itemHeight"),y=t.get("align");"auto"===y&&(y="right"===t.get("left")&&t.get(f)===Sn?"right":"left");var _={},w={};r.each(t[Nn](),function(r){var s=r.get("name");(""===s||"\n"===s)&&d.add(new o.Group({newline:!0}));var c=a.getSeriesByName(s)[0];if(_[s]=r,c&&!w[s]){var f=c[Nn](),m=f[Vt]("color");t.isSelected(s)||(m=u),typeof m===Fr&&(m=m(c[Pn](0)));var x=f[Vt]("legendSymbol")||"roundRect",b=f[Vt](ft),M=this._createItem(s,r,t,x,b,v,g,y,m,p);M.on("click",l(e,s,h)).on(Fe,l(i,c,"",h)).on(Ze,l(n,c,"",h)),w[s]=!0}},this),a.eachRawSeries(function(r){if(r[m]){var a=r[m]();a.each(function(o){var s=a[Rn](o);if(_[s]&&!w[s]){var c=a[It](o,"color");t.isSelected(s)||(c=u);var d="roundRect",f=this._createItem(s,_[s],t,d,null,v,g,y,c,p);f.on("click",l(e,s,h)).on(Fe,l(i,r,s,h)).on(Ze,l(n,r,s,h)),w[s]=!0}},!1,this)}},this),s[c](d,t,h),s.addBackground(d,t)}},_createItem:function(t,e,i,n,r,s,l,u,c,h){var d=new o.Group,f=e[ir](er),p=e.get("icon");if(n=p||n,d.add(a[vt](n,0,0,s,l,c)),!p&&r&&r!==n&&"none"!=r){var v=.8*l;d.add(a[vt](r,(s-v)/2,(l-v)/2,v,v,c))}var m="left"===u?s+5:-5,g=u,y=i.get(Dn);typeof y===qr&&y?t=y[Zr]("{name}",t):typeof y===Fr&&(t=y(t));var x=new o.Text({style:{text:t,x:m,y:l/2,fill:f[Be](),textFont:f[$n](),textAlign:g,textBaseline:"middle"}});return d.add(x),d.add(new o.Rect({shape:d[tr](),invisible:!0})),d[kn](function(t){t[Ae]=!h}),this.group.add(d),d}})}),e("echarts/component/legend/legendFilter",[],function(){return function(t){var e=t[hn]({mainType:"legend"});e&&e[Kr]&&t.filterSeries(function(t){for(var i=0;i0?1.1:1/1.1;o.call(this,t,e,t[Ie],t[Le])}function a(t){if(!d.isTaken("globalPan",this._zr)){h.stop(t.event);var e=t.pinchScale>1?1.1:1/1.1;o.call(this,t,e,t.pinchX,t.pinchY)}}function o(t,e,i,n){var r=this.rect;if(r&&r[pi](i,n)){var a=this[Zi];if(a){var o=a[Tn],s=a.scale,l=this._zoom=this._zoom||1;l*=e;var u=l/this._zoom;this._zoom=l,o[0]-=(i-o[0])*(u-1),o[1]-=(n-o[1])*(u-1),s[0]*=u,s[1]*=u,a.dirty()}this[bi]("zoom",e,i,n)}}function s(t,o,s){this[Zi]=o,this.rect=s,this._zr=t;var h=c.bind,d=h(e,this),f=h(i,this),p=h(n,this),v=h(r,this),m=h(a,this);u.call(this),this[l]=function(e){this.disable(),null==e&&(e=!0),(e===!0||"move"===e||"pan"===e)&&(t.on(ze,d),t.on(Pe,f),t.on(De,p)),(e===!0||"scale"===e||"zoom"===e)&&(t.on("mousewheel",v),t.on("pinch",m))},this.disable=function(){t.off(ze,d),t.off(Pe,f),t.off(De,p),t.off("mousewheel",v),t.off("pinch",m)},this[me]=this.disable,this.isDragging=function(){return this._dragging},this.isPinching=function(){return this._pinching}}var u=t(Ji),c=t(ta),h=t(Re),d=t("./interactionMutex");return c.mixin(s,u),s}),e("echarts/component/helper/MapDraw",[ia,"./RoamController",yt,ta],function(t){function e(t,e){var i=t[ht](),n=t.get("areaColor");return n&&(i.fill=n),i}function i(t,e,i,r,a){i.off("click"),t.get(x)&&i.on("click",function(i){var o=i[Zi][wi];if(null!=o){var s=e[Rn](o);r[sn]({type:"mapToggleSelect",seriesIndex:t[Bn],name:s,from:a.uid}),n(t,e,r)}})}function n(t,e){e[yi](function(i,n){var r=e[Rn](n);i[bi](t.isSelected(r)?Hn:Fn)})}function r(t,e){var i=new o.Group;this[s]=new a(t.getZr(),e?i:null,null),this.group=i,this._updateGroup=e}var a=t("./RoamController"),o=t(yt),u=t(ta);return r[ea]={constructor:r,draw:function(t,r,a,s){var l=t[Nn]&&t[Nn](),c=t[tn],h=this.group;h[Si]();var d=c.scale;h[Tn]=c[Tn].slice(),h.scale=d.slice();var f,p,v,m,g,y,x=[ue,Fn],_=[ue,Hn],w=["label",Fn],b=["label",Hn];l||(f=t[ir](x),p=t[ir](_),v=e(f,d),m=e(p,d),g=t[ir](w),y=t[ir](b)),u.each(c.regions,function(i){var n,r=new o.Group;if(l){n=l[xi](i.name);var a=l[zn](n),s=l[It](n,"color",!0);f=a[ir](x),p=a[ir](_),v=e(f,d),m=e(p,d),g=a[ir](w),y=a[ir](b),s&&(v.fill=s)}var c=g[ir](er),M=y[ir](er);u.each(i.contours,function(t){var e=new o[Ye]({shape:{points:t},style:{strokeNoScale:!0},culling:!0});e[qe](v),r.add(e)});var S=g.get("show"),A=y.get("show"),C=l&&isNaN(l.get("value",n)),T=l&&l[Pt](n);if(!l||C&&(S||A)||T&&T.showLabel){var k=l?n:i.name,L=t[ct](k,Fn),I=t[ct](k,Hn),D=new o.Text({style:{text:S?L||i.name:"",fill:c[Be](),textFont:c[$n](),textAlign:"center",textBaseline:"middle"},hoverStyle:{text:A?I||i.name:"",fill:M[Be](),textFont:M[$n]()},position:i[Nr].slice(),scale:[1/d[0],1/d[1]],z2:10,silent:!0});r.add(D)}l&&l[Lt](n,r),o[He](r,m),h.add(r)}),this._updateController(t,r,a),l&&i(t,l,h,a,s),l&&n(t,l)},remove:function(){this.group[Si](),this[s][me]()},_updateController:function(t,e,i){var n=t[tn],r=this[s];r[l](t.get("roam")||!1);var a=t.type.split(".")[0];r.off("pan").on("pan",function(e,n){i[sn]({type:"geoRoam",component:a,name:t.name,dx:e,dy:n})}),r.off("zoom").on("zoom",function(e,n,r){if(i[sn]({type:"geoRoam",component:a,name:t.name,zoom:e,originX:n,originY:r}),this._updateGroup){var o=this.group,s=o.scale;o[Ti](function(t){"text"===t.type&&t.attr("scale",[1/s[0],1/s[1]])})}},this),r.rect=n.getViewRect()}},r}),e("echarts/chart/map/MapView",[ia,yt,"../../component/helper/MapDraw",C],function(t){var e=t(yt),i=t("../../component/helper/MapDraw");t(C)[jt]({type:"map",render:function(t,e,n,r){if(!r||"mapToggleSelect"!==r.type||r.from!==this.uid){var a=this.group;if(a[Si](),r&&"geoRoam"===r.type&&r.component===pn&&r.name===t.name){var o=this._mapDraw;o&&a.add(o.group)}else if(t.needsDrawMap){var o=this._mapDraw||new i(n,!0);a.add(o.group),o.draw(t,e,n,this),this._mapDraw=o}else this._mapDraw&&this._mapDraw[Ii](),this._mapDraw=null;t.get("showLegendSymbol")&&e[rn](se)&&this._renderSymbols(t,e,n)}},remove:function(){this._mapDraw&&this._mapDraw[Ii](),this._mapDraw=null,this.group[Si]()},_renderSymbols:function(t,i,n){var r=t[Nn](),a=this.group;r.each("value",function(t,i){if(!isNaN(t)){var n=r[Pt](i);if(n&&n.point){var o=n.point,s=n[Qe],l=new e[Je]({style:{fill:r[Vt]("color")},shape:{cx:o[0]+9*s,cy:o[1],r:3},silent:!0,z2:10});if(!s){var u=r[Rn](i),c=r[zn](i),h=c[ir](M),d=c[ir](b),f=h[ir](er),p=d[ir](er),v=r[_i](i);l[qe]({textPosition:"bottom"});var m=function(){l[qe]({text:d.get("show")?u:"",textFill:p[Be](),textFont:p[$n]()})},g=function(){l[qe]({text:h.get("show")?u:"",textFill:f[Be](),textFont:f[$n]()})};v.on(Fe,m).on(Ze,g).on(Hn,m).on(Fn,g),g()}a.add(l)}}})}})}),e("echarts/action/roamHelper",[ia],function(t){var e={};return e.calcPanAndZoom=function(t,e){var i=e.dx,n=e.dy,r=e.zoom,a=t.get("x")||0,o=t.get("y")||0,s=t.get("zoom")||1;if(null!=i&&null!=n&&(a+=i,o+=n),null!=r){var l=(e.originX-a)*(r-1),u=(e.originY-o)*(r-1);a-=l,o-=u}return{x:a,y:o,zoom:(r||1)*s}},e}),e("echarts/action/geoRoam",[ia,ta,"./roamHelper",Y],function(t){var e=t(ta),i=t("./roamHelper"),n=t(Y),r={type:"geoRoam",event:"geoRoam",update:"updateLayout"};n[Kt](r,function(t,n){var r=t.component||pn;n[ie](r,function(n){if(n.name===t.name){var a=n[tn];if("geo"!==a.type)return;var o=n[ir](u),s=i.calcPanAndZoom(o,t);n.setRoamPan&&n.setRoamPan(s.x,s.y),n.setRoamZoom&&n.setRoamZoom(s.zoom),a&&a.setPan(s.x,s.y),a&&a.setZoom(s.zoom),r===pn&&e.each(n.seriesGroup,function(t){t.setRoamPan(s.x,s.y),t.setRoamZoom(s.zoom)})}})})}),e("echarts/coord/geo/GeoModel",[ia,Ct,z],function(t){var e=t(Ct),i=t(z);i[Lr]({type:"geo",coordinateSystem:null,init:function(t){i[ea].init.apply(this,arguments),e[Wn](t.label,[Tn,"show",er,vr,Dn])},defaultOption:{zlevel:0,z:0,show:!0,left:"center",top:"center",map:"",roamDetail:{x:0,y:0,zoom:1},label:{normal:{show:!1,textStyle:{color:"#000"}},emphasis:{show:!0,textStyle:{color:"rgb(100,0,0)"}}},itemStyle:{normal:{borderWidth:.5,borderColor:"#444",color:"#eee"},emphasis:{color:"rgba(255,215,0,0.8)"}}},getFormattedLabel:function(t,e){var i=this.get("label."+e+".formatter"),n={name:t};return typeof i===Fr?(n.status=e,i(n)):typeof i===qr?i[Zr]("{a}",n.seriesName):void 0},setRoamZoom:function(t){var e=this[Xn][u];e&&(e.zoom=t)},setRoamPan:function(t,e){var i=this[Xn][u];i&&(i.x=t,i.y=e)}})}),e("zrender/contain/polygon",[ia,"./windingLine"],function(t){function e(t,e){return Math.abs(t-e)r;r++)if(i[pi](n[r],t[0],t[1]))return!0;return!1},transformTo:function(t,e,i,r){var o=this[tr](),s=o.width/o[hr];i?r||(r=i/s):i=s*r;for(var l=new n(t,e,i,r),u=o.calculateTransform(l),c=this.contours,h=0;h>1^-(1&o),s=s>>1^-(1&s),o+=n,s+=r,n=o,r=s,i.push([o/1024,s/1024])}return i}function n(t){for(var e=[],i=0;ic;c++)s=Math.min(s,i[a][c]),l=Math.max(l,i[a][c]),o+=i[a][c];var h;return h="min"===e?s:"max"===e?l:"average"===e?o/u:o,0===u?NaN:h})}var i=t(ta);return function(t){var n={};t[de]("map",function(t){var e=t.get("map");n[e]=n[e]||[],n[e].push(t)}),i.each(n,function(t,n){var r=e(i.map(t,function(t){return t[Nn]()}),t[0].get("mapValueCalculation"));t[0].seriesGroup=[],t[0][ni](r);for(var a=0;ae&&(e=n[hr])}this[hr]=e+1},getNodeById:function(t){if(this.getId()===t)return this;for(var e=0,i=this.children,n=i[Kr];n>e;e++){var r=i[e].getNodeById(t);if(r)return r}},contains:function(t){if(t===this)return!0;for(var e=0,i=this.children,n=i[Kr];n>e;e++){var r=i[e].contains(t);if(r)return r}},getAncestors:function(t){for(var e=[],i=t?this:this[ke];i;)e.push(i),i=i[ke];return e[a](),e},getValue:function(t){var e=this.hostTree.data;return e.get(e[Ft](t||"value"),this[wi])},setLayout:function(t,e){this[wi]>=0&&this.hostTree.data[Dt](this[wi],t,e)},getLayout:function(){return this.hostTree.data[Pt](this[wi]); -},getModel:function(t){if(!(this[wi]<0)){var e=this.hostTree,i=e.data[zn](this[wi]),n=this.getLevelModel();return i[ir](t,(n||e[$t])[ir](t))}},getLevelModel:function(){return(this.hostTree.levelModels||[])[this.depth]},setVisual:function(t,e){this[wi]>=0&&this.hostTree.data[fe](this[wi],t,e)},getVisual:function(t,e){return this.hostTree.data[It](this[wi],t,e)},getRawIndex:function(){return this.hostTree.data[Vn](this[wi])},getId:function(){return this.hostTree.data.getId(this[wi])}},e[ea]={constructor:e,type:"tree",eachNode:function(t,e,i){this.root[o](t,e,i)},getNodeByDataIndex:function(t){var e=this.data[Vn](t);return this._nodes[e]},getNodeByName:function(t){return this.root.getNodeByName(t)},update:function(){for(var t=this.data,e=this._nodes,i=0,n=e[Kr];n>i;i++)e[i][wi]=-1;for(var i=0,n=t.count();n>i;i++)e[t[Vn](i)][wi]=i}},e.createTree=function(t,n,r){function a(t,e){h.push(t);var n=new c(t.name,h[Kr]-1,o);e?i(n,e):o.root=n;var r=t.children;if(r)for(var s=0;s=0&&(o[Dr](r)?r=r[0]:t.value=new Array(i)),(null==r||isNaN(r))&&(r=n),0>r&&(r=0),i>=0?t.value[0]=r:t.value=r}function i(t,e){var i=e.get("color");if(i){t=t||[];var n;if(o.each(t,function(t){var e=new s(t),i=e.get("color");(e.get(re)||i&&"none"!==i)&&(n=!0)}),!n){var r=t[0]||(t[0]={});r.color=i.slice()}return t}}var n=t(wt),r=t("../../data/Tree"),o=t(ta),s=t(T),l=t(v),u=l[nn],c=l[en];return n[Lr]({type:"series.treemap",dependencies:["grid","polar"],defaultOption:{left:"center",top:"middle",right:null,bottom:null,width:"80%",height:"80%",sort:!0,clipWindow:"origin",squareRatio:.5*(1+Math.sqrt(5)),root:null,visualDimension:0,zoomToNodeRatio:.1024,roam:!0,nodeClick:"zoomToNode",animation:!0,animationDurationUpdate:1500,animationEasing:"quinticInOut",breadcrumb:{show:!0,height:22,left:"center",top:"bottom",emptyItemWidth:25,itemStyle:{normal:{color:"rgba(0,0,0,0.7)",borderColor:"rgba(255,255,255,0.7)",borderWidth:1,shadowColor:"rgba(150,150,150,1)",shadowBlur:3,shadowOffsetX:0,shadowOffsetY:0,textStyle:{color:"#fff"}},emphasis:{textStyle:{}}}},label:{normal:{show:!0,position:["50%","50%"],textStyle:{align:"center",baseline:"middle",color:"#fff",ellipsis:!0}}},itemStyle:{normal:{color:null,colorAlpha:null,colorSaturation:null,borderWidth:0,gapWidth:0,borderColor:"#fff",borderColorSaturation:null},emphasis:{}},color:"none",colorAlpha:null,colorSaturation:null,colorMappingBy:"index",visibleMin:10,childrenVisibleMin:null,levels:[]},getInitialData:function(t,n){var a=t.data||[],s=t.name;null==s&&(s=t.name);var l={name:s,children:t.data},u=(a[0]||{}).value;e(l,o[Dr](u)?u[Kr]:-1);var c=t.levels||[];return c=t.levels=i(c,n),r.createTree(l,this,c).data},getViewRoot:function(){var t=this[Xn].root,e=this[Nn]().tree.root;return t&&e.getNodeById(t)||e},formatTooltip:function(t){var e=this[Nn](),i=this[On](t),n=c(o[Dr](i)?i[0]:i),r=e[Rn](t);return u(r)+": "+n},getDataParams:function(t){for(var e=n[ea][Pn].apply(this,arguments),i=this[Nn](),r=i.tree.getNodeByDataIndex(t),o=e.treePathInfo=[];r;){var s=r[wi];o.push({name:r.name,dataIndex:s,value:this[On](s)}),r=r[ke]}return o[a](),e},setLayoutInfo:function(t){this.layoutInfo=this.layoutInfo||{},o[Lr](this.layoutInfo,t)},mapIdToIndex:function(t){var e=this._idIndexMap;e||(e=this._idIndexMap={},this._idIndexMapCount=0);var i=e[t];return null==i&&(e[t]=i=this._idIndexMapCount++),i}})}),e("echarts/chart/treemap/helper",[ia],function(t){var e={retrieveTargetInfo:function(t,e){if(t&&"treemapZoomToNode"===t.type){var i=e[Nn]().tree.root,n=t.targetNode;if(n&&i.contains(n))return{node:n};var r=t.targetNodeId;return null!=r&&(n=i.getNodeById(r))?{node:n}:null}}};return e}),e("echarts/chart/treemap/Breadcrumb",[ia,yt,P,ta],function(t){function e(t,e){this.group=new n.Group,t.add(this.group),this._onSelect=e||a.noop}function i(t,e,i,n,r,a){var o=[[r?t:t-l,e],[t+i,e],[t+i,e+n],[r?t:t-l,e+n]];return!a&&o[fn](2,0,[t+i+l,e+n/2]),!r&&o.push([t,e+n/2]),o}var n=t(yt),r=t(P),a=t(ta),o=8,s=8,l=5;return e[ea]={constructor:e,render:function(t,e,i){var n=t[ir]("breadcrumb"),a=this.group;if(a[Si](),n.get("show")&&i){var o=n[ir](A),s=o[ir](er),l={pos:{left:n.get("left"),right:n.get("right"),top:n.get("top"),bottom:n.get(Or)},box:{width:e[un](),height:e[ln]()},emptyItemWidth:n.get("emptyItemWidth"),totalWidth:0,renderList:[]};this._prepare(n,i,l,s),this._renderContent(n,i,l,o,s),r[_n](a,l.pos,l.box)}},_prepare:function(t,e,i,n){for(var r=e;r;r=r[ke]){var a=r[ir]().get("name"),l=n.getTextRect(a),u=Math.max(l.width+2*o,i.emptyItemWidth);i.totalWidth+=u+s,i.renderList.push({node:r,text:a,width:u})}},_renderContent:function(t,e,o,l,u){for(var c=0,h=o.emptyItemWidth,d=t.get(hr),f=r.getAvailableSize(o.pos,o.box),p=o.totalWidth,v=o.renderList,m=v[Kr]-1;m>=0;m--){var g=v[m],y=g.width,x=g.text;p>f.width&&(p-=y-h,y=h,x=""),this.group.add(new n[Ye]({shape:{points:i(c,0,y,d,m===v[Kr]-1,0===m)},style:a[rr](l[ht](),{lineJoin:"bevel",text:x,textFill:u[Be](),textFont:u[$n]()}),onclick:a.bind(this._onSelect,this,g.node)})),c+=y+s}},remove:function(){this.group[Si]()}},e}),e("echarts/util/animation",[ia,ta],function(t){function e(){var t,e=[],n={};return{add:function(t,r,a,o,s){return i[dn](o)&&(s=o,o=0),n[t.id]?!1:(n[t.id]=1,e.push({el:t,target:r,time:a,delay:o,easing:s}),!0)},done:function(e){return t=e,this},start:function(){function i(){r--,r||(e[Kr]=0,n={},t&&t())}for(var r=e[Kr],a=0,o=e[Kr];o>a;a++){var s=e[a];s.el[Ne](s[Zi],s.time,s.delay,s.easing,i)}return this}}}var i=t(ta);return{createWrap:e}}),e("echarts/chart/treemap/TreemapView",[ia,ta,yt,"../../data/DataDiffer","./helper","./Breadcrumb","../../component/helper/RoamController",fr,pr,"../../util/animation",C],function(t){function e(){return{nodeGroup:[],background:[],content:[]}}var i=t(ta),n=t(yt),r=t("../../data/DataDiffer"),a=t("./helper"),u=t("./Breadcrumb"),c=t("../../component/helper/RoamController"),h=t(fr),d=t(pr),f=t("../../util/animation"),p=i.bind,v=n.Group,m=n.Rect,g=i.each,y=3;return t(C)[jt]({type:"treemap",init:function(t,i){this._containerGroup,this._storage=e(),this._oldTree,this._breadcrumb,this[s],this._state="ready",this._mayClick},render:function(t,e,n,r){var o=e[hn]({mainType:"series",subType:"treemap",query:r});if(!(i[Ur](o,t)<0)){this.seriesModel=t,this.api=n,this[nr]=e;var s=r&&r.type,l=t.layoutInfo,u=!this._oldTree,c=this._giveContainerGroup(l),h=this._doRender(c,t);u||s&&"treemapZoomToNode"!==s?h.renderFinally():this._doAnimation(c,h,t),this._resetController(n);var d=a.retrieveTargetInfo(r,t);this._renderBreadcrumb(t,n,d)}},_giveContainerGroup:function(t){var e=this._containerGroup;return e||(e=this._containerGroup=new v,this._initEvents(e),this.group.add(e)),e[Tn]=[t.x,t.y],e},_doRender:function(t,n){function a(t,e,n,o,s){function l(t){return t.getId()}function u(i,r){var l=null!=i?t[i]:null,u=null!=r?e[r]:null,c=s||l===x;c||(l=null);var h=y(l,u,n);h&&a(l&&l.viewChildren||[],u&&u.viewChildren||[],h,o,c)}o?(e=t,g(t,function(t,e){!t.isRemoved()&&u(e,e)})):new r(e,t,l,l).add(u)[on](u)[Ii](i.curry(u,null))[ut]()}function o(t){var i=e();return t&&g(t,function(t,e){var n=i[e];g(t,function(t){t&&(n.push(t),t.__tmWillDelete=e)})}),i}function s(){g(m,function(t){g(t,function(t){t[Ui]&&t[Ui][Ii](t)})}),g(f,function(t){t[Ci]=!0}),g(v,function(t){t[Ci]=!1,t.__tmWillVisible=!1,t.dirty()})}var l=n[Nn]().tree,u=this._oldTree,c=e(),h=e(),d=this._storage,f=[],v=[],m=[],y=p(this._renderNode,this,h,d,c,f,v),x=n.getViewRoot();a(l.root?[l.root]:[],u&&u.root?[u.root]:[],t,l===u||!u,x===l.root);var m=o(d);return this._oldTree=l,this._storage=h,{lastsForAnimation:c,willDeleteEls:m,renderFinally:s}},_renderNode:function(t,e,n,r,a,o,s,l){function u(i,r){var a=null!=p&&e[i][p],o=n[i];return a?(e[i][p]=null,c(o,a,i)):_||(a=new r,h(o,a,i)),t[i][f]=a}function c(t,e,n){var r=t[f]={};r.old="nodeGroup"===n?e[Tn].slice():i[Lr]({},e.shape)}function h(t,e,i){if("background"===i)e[Ci]=!0,e.__tmWillVisible=!0,a.push(e);else{var r,s=o[ke],l=0,u=0;s&&(r=n.background[s[Vn]()])&&(l=r.old.width,u=r.old[hr]);var c=t[f]={};c.old="nodeGroup"===i?[l,u]:{x:l,y:u,width:0,height:0},c.fadein="nodeGroup"!==i}}function d(t,e){_?!t[Ci]&&r.push(t):(t[qe](e),t.__tmWillVisible||(t[Ci]=!1))}var f=o&&o[Vn](),p=s&&s[Vn]();if(o){var g=o[zt](),y=g.width,x=g[hr],_=g[Ci],w=u("nodeGroup",v);if(w){l.add(w),w[Tn]=[g.x,g.y],w.__tmNodeWidth=y,w.__tmNodeHeight=x;var b=u("background",m);b&&(b[ri]({x:0,y:0,width:y,height:x}),d(b,{fill:o[Vt](Jn,!0)}),w.add(b));var S=o.viewChildren;if(!S||!S[Kr]){var A=g[Kn],C=u("content",m);if(C){var T=Math.max(y-2*A,0),k=Math.max(x-2*A,0),L=o[ir](M),I=o[ir]("label.normal.textStyle"),D=o[ir]().get("name"),P=I.getTextRect(D),z=L.get("show");!z||P[hr]>k?D="":P.width>T&&(D=I.get("ellipsis")?I.ellipsis(D,T):""),C[wi]=o[wi],C[Bn]=this.seriesModel[Bn],C.culling=!0,C[ri]({x:A,y:A,width:T,height:k}),d(C,{fill:o[Vt]("color",!0),text:D,textPosition:L.get(Tn),textFill:I[Be](),textAlign:I.get("align"),textBaseline:I.get(Qn),textFont:I[$n]()}),w.add(C)}}return w}}},_doAnimation:function(t,e,n){if(n.get(Bi)){var r=n.get("animationDurationUpdate"),a=n.get("animationEasing"),o=f.createWrap(),s=this.seriesModel.getViewRoot(),l=this._storage.nodeGroup[s[Vn]()];l&&l[Ti](function(t){var e;if(!t[Ci]&&(e=t.__tmWillDelete)){var i=0,n=0,s=t[Ui];s.__tmWillDelete||(i=s.__tmNodeWidth,n=s.__tmNodeHeight);var l="nodeGroup"===e?{position:[i,n],style:{opacity:0}}:{shape:{x:i,y:n,width:0,height:0},style:{opacity:0}};o.add(t,l,r,a)}}),g(this._storage,function(t,n){g(t,function(t,s){var l,u=e.lastsForAnimation[n][s];u&&("nodeGroup"===n?(l={position:t[Tn].slice()},t[Tn]=u.old):(l={shape:i[Lr]({},t.shape)},t[ri](u.old),u.fadein?(t[qe](wr,0),l.style={opacity:1}):1!==t.style[wr]&&(l.style={opacity:1})),o.add(t,l,r,a))})},this),this._state="animating",o.done(p(function(){this._state="ready",e.renderFinally()},this)).start()}},_resetController:function(t){var e=this[s];e||(e=this[s]=new c(t.getZr()),e[l](this.seriesModel.get("roam")),e.on("pan",p(this._onPan,this)),e.on("zoom",p(this._onZoom,this))),e.rect=new h(0,0,t[un](),t[ln]())},_clearController:function(){var t=this[s];t&&(t.off("pan").off("zoom"),t=null)},_onPan:function(t,e){if(this._mayClick=!1,"animating"!==this._state&&(Math.abs(t)>y||Math.abs(e)>y)){var i=this.seriesModel.getViewRoot();if(!i)return;var n=i[zt]();if(!n)return;this.api[sn]({type:"treemapMove",from:this.uid,seriesId:this.seriesModel.id,rootRect:{x:n.x+t,y:n.y+e,width:n.width,height:n[hr]}})}},_onZoom:function(t,e,i){if(this._mayClick=!1,"animating"!==this._state){var n=this.seriesModel.getViewRoot();if(!n)return;var r=n[zt]();if(!r)return;var a=new h(r.x,r.y,r.width,r[hr]),o=this.seriesModel.layoutInfo;e-=o.x,i-=o.y;var s=d[cr]();d[ur](s,s,[-e,-i]),d.scale(s,s,[t,t]),d[ur](s,s,[e,i]),a[dr](s),this.api[sn]({type:"treemapRender",from:this.uid,seriesId:this.seriesModel.id,rootRect:{x:a.x,y:a.y,width:a.width,height:a[hr]}})}},_initEvents:function(t){function e(t){var e=this.seriesModel.get("nodeClick",!0);if(e){var i=this.findTarget(t[Ie],t[Le]);if(i)if("zoomToNode"===e)this._zoomToNode(i);else if("link"===e){var n=i.node,r=n.hostTree.data[zn](n[wi]),a=r.get("link",!0),o=r.get(Zi,!0)||"blank";a&&window.open(a,o)}}}t.on(ze,function(t){"ready"===this._state&&(this._mayClick=!0)},this),t.on(De,function(t){this._mayClick&&(this._mayClick=!1,"ready"===this._state&&e.call(this,t))},this)},_renderBreadcrumb:function(t,e,i){function n(t){this._zoomToNode({node:t})}i||(i=this.findTarget(e[un]()/2,e[ln]()/2),i||(i={node:t[Nn]().tree.root})),(this._breadcrumb||(this._breadcrumb=new u(this.group,p(n,this))))[Mi](t,e,i.node)},remove:function(){this._clearController(),this._containerGroup&&this._containerGroup[Si](),this._storage=e(),this._state="ready",this._breadcrumb&&this._breadcrumb[Ii]()},dispose:function(){this._clearController()},_zoomToNode:function(t){this.api[sn]({type:"treemapZoomToNode",from:this.uid,seriesId:this.seriesModel.id,targetNode:t.node})},findTarget:function(t,e){var i,n=this.seriesModel.getViewRoot();return n[o]({attr:"viewChildren",order:"preorder"},function(n){var r=this._storage.background[n[Vn]()];if(r){var a=r[Fi](t,e),o=r.shape;if(!(o.x<=a[0]&&a[0]<=o.x+o.width&&o.y<=a[1]&&a[1]<=o.y+o[hr]))return!1;i={node:n,offsetX:a[0],offsetY:a[1]}}},this),i}})}),e("echarts/chart/treemap/treemapAction",[ia,C],function(t){var e=t(C),i=function(){};e[Kt]({type:"treemapZoomToNode",update:"updateView"},i),e[Kt]({type:"treemapRender",update:"updateView"},i),e[Kt]({type:"treemapMove",update:"updateView"},i)}),e("echarts/visual/VisualMapping",[ia,ta,Gi,"../util/number"],function(t){function e(t,e,i,n){return c[Dr](t)?c.map(t,function(t){return d(t,e,i,n)}):d(t,e,i,n)}function i(t){var e=t.pieceList;t.hasSpecialVisual=!1,c.each(e,function(e,i){e.originIndex=i,e.visual&&(t.hasSpecialVisual=!0)})}function n(t){var e=t[r],i=t.visual,n=c[Dr](i);if(!e){if(n)return;throw new Error}var a=t.categoryMap={};if(f(e,function(t,e){a[t]=e}),!n){var o=[];c[In](i)?f(i,function(t,e){var i=a[e];o[null!=i?i:v]=t}):o[v]=i,i=t.visual=o}for(var s=e[Kr]-1;s>=0;s--)null==i[s]&&(delete a[e[s]],e.pop())}function a(t){return{applyVisual:function(e,i,n){var r=i("color"),a=c[Dr](e);if(e=a?[this.mapValueToVisual(e[0]),this.mapValueToVisual(e[1])]:this.mapValueToVisual(e),c[Dr](r))for(var o=0,s=r[Kr];s>o;o++)r[o].color=t(r[o].color,a?e[o]:e);else n("color",t(r,e))},mapValueToVisual:function(t){var i=this._normalizeData(t),n=this._getSpecifiedVisual(t),r=this[Xn].visual;return null==n&&(n=u(this)?l(this,r,i):e(i,[0,1],r,!0)),n}}}function o(t,i){return t[Math.round(e(i,[0,1],[0,t[Kr]-1],!0))]}function s(t,e,i){i("color",this.mapValueToVisual(t))}function l(t,e,i){return e[t[Xn].loop&&i!==v?i%e[Kr]:i]}function u(t){return t[Xn].mappingMethod===St}var c=t(ta),h=t(Gi),d=t("../util/number")[Gr],f=c.each,p=c[In],v=-1,m=function(t){var e=t.mappingMethod,r=t.type;this.type=r,this.mappingMethod=e;var a=this[Xn]=c.clone(t);this._normalizeData=y[e],this._getSpecifiedVisual=c.bind(x[e],this,r),c[Lr](this,g[r]),"piecewise"===e&&i(a),e===St&&n(a)};m[ea]={constructor:m,applyVisual:null,isValueActive:null,mapValueToVisual:null,getNormalizer:function(){return c.bind(this._normalizeData,this)}};var g=m.visualHandlers={color:{applyVisual:s,getColorMapper:function(){var t=u(this)?this[Xn].visual:c.map(this[Xn].visual,h.parse);return c.bind(u(this)?function(e,i){return!i&&(e=this._normalizeData(e)),l(this,t,e)}:function(e,i,n){var r=!!n;return!i&&(e=this._normalizeData(e)),n=h.fastMapToColor(e,t,n),r?n:c.stringify(n,"rgba")},this)},mapValueToVisual:function(t){var e=this[Xn].visual;if(c[Dr](t))return t=[this._normalizeData(t[0]),this._normalizeData(t[1])],h.mapIntervalToColor(t,e);var i=this._normalizeData(t),n=this._getSpecifiedVisual(t);return null==n&&(n=u(this)?l(this,e,i):h.mapToColor(i,e)),n}},colorHue:a(function(t,e){return h.modifyHSL(t,e)}),colorSaturation:a(function(t,e){return h.modifyHSL(t,null,e)}),colorLightness:a(function(t,e){return h.modifyHSL(t,null,null,e)}),colorAlpha:a(function(t,e){return h.modifyAlpha(t,e)}),symbol:{applyVisual:function(t,e,i){var n=this.mapValueToVisual(t);if(c[dn](n))i(ft,n);else if(p(n))for(var r in n)n.hasOwnProperty(r)&&i(r,n[r])},mapValueToVisual:function(t){var e=this._normalizeData(t),i=this._getSpecifiedVisual(t),n=this[Xn].visual;return null==i&&(i=u(this)?l(this,n,e):o(n,e)||{}),i}},symbolSize:{applyVisual:function(t,e,i){i(pt,this.mapValueToVisual(t))},mapValueToVisual:function(t){var i=this._normalizeData(t),n=this._getSpecifiedVisual(t),r=this[Xn].visual;return null==n&&(n=u(this)?l(this,r,i):e(i,[0,1],r,!0)),n}}},y={linear:function(t){return e(t,this[Xn].dataExtent,[0,1],!0)},piecewise:function(t){var i=this[Xn].pieceList,n=m.findPieceIndex(t,i);return null!=n?e(n,[0,i[Kr]-1],[0,1],!0):void 0},category:function(t){var e=this[Xn][r]?this[Xn].categoryMap[t]:t;return null==e?v:e}},x={linear:c.noop,piecewise:function(t,e){var i=this[Xn],n=i.pieceList;if(i.hasSpecialVisual){var r=m.findPieceIndex(e,n),a=n[r];if(a&&a.visual)return a.visual[t]}},category:c.noop};return m.addVisualHandler=function(t,e){g[t]=e},m.isValidType=function(t){return g.hasOwnProperty(t)},m.eachVisual=function(t,e,i){c[In](t)?c.each(t,e,i):e.call(i,t)},m.mapVisual=function(t,e,i){var n,r=c[Dr](t)?[]:c[In](t)?{}:(n=!0,null);return m.eachVisual(t,function(t,a){var o=e.call(i,t,a);n?r=o:r[a]=o}),r},m.isInVisualCluster=function(t,e){return"color"===e?!(!t||0!==t[Ur](e)):t===e},m.retrieveVisuals=function(t){var e,i={};return t&&f(g,function(n,r){t.hasOwnProperty(r)&&(i[r]=t[r],e=!0)}),e?i:null},m.prepareVisualTypes=function(t){if(p(t)){var e=[];f(t,function(t,i){e.push(i)}),t=e}else{if(!c[Dr](t))return[];t=t.slice()}return t.sort(function(t,e){return"color"===e&&"color"!==t&&0===t[Ur]("color")?1:-1}),t},m.findPieceIndex=function(t,e){for(var i=0,n=e[Kr];n>i;i++){var r=e[i];if(null!=r.value&&r.value===t)return i}for(var i=0,n=e[Kr];n>i;i++){var r=e[i],a=r[B];if(a)if(a[0]===-(1/0)){if(t=c[Kr]||t===c[t.depth]){var n=u(f,x,t,i,M,h);e(t,n,o,l,c,h)}})}else m=r(x,t),t[ve]("color",m)}}function i(t,e,i,n){var r=d[Lr]({},e);return d.each(["color","colorAlpha","colorSaturation"],function(a){var o=t.get(a,!0);null==o&&i&&(o=i[a]),null==o&&(o=e[a]),null==o&&(o=n.get(a)),null!=o&&(r[a]=o)}),r}function r(t){var e=o(t,"color");if(e){var i=o(t,"colorAlpha"),n=o(t,"colorSaturation");return n&&(e=h.modifyHSL(e,null,null,n)),i&&(e=h.modifyAlpha(e,i)),e}}function a(t,e){return null!=e?h.modifyHSL(e,null,null,t):null}function o(t,e){var i=t[e];return null!=i&&"none"!==i?i:void 0}function s(t,e,i,n,r,a){if(a&&a[Kr]){var o=l(e,"color")||null!=r.color&&"none"!==r.color&&(l(e,"colorAlpha")||l(e,"colorSaturation"));if(o){var s=e.get("colorMappingBy"),u={type:o.name,dataExtent:i.dataExtent,visual:o.range};"color"!==u.type||"index"!==s&&"id"!==s?u.mappingMethod=Ei:(u.mappingMethod=St,u.loop=!0);var h=new c(u);return h.__drColorMappingBy=s,h}}}function l(t,e){var i=t.get(e);return f(i)&&i[Kr]?{name:e,range:i}:null}function u(t,e,i,n,r,a){var o=d[Lr]({},e);if(r){var s=r.type,l="color"===s&&r.__drColorMappingBy,u="index"===l?n:"id"===l?a.mapIdToIndex(i.getId()):i.getValue(t.get("visualDimension"));o[s]=r.mapValueToVisual(u)}return o}var c=t(n),h=t(Gi),d=t(ta),f=d[Dr],p=A;return function(t,i){var n={mainType:"series",subType:"treemap",query:i};t[ie](n,function(t){var i=t[Nn]().tree,n=i.root,r=t[ir](p);if(!n.isRemoved()){var a=d.map(i.levelModels,function(t){return t?t.get(p):null});e(n,{},a,r,t.getViewRoot().getAncestors(),t)}})}}),e("echarts/chart/treemap/treemapLayout",[ia,ta,gt,P,fr,"./helper"],function(t){function e(t,e,n){var r={mainType:"series",subType:"treemap",query:n};t[ie](r,function(t){var r=e[un](),a=e[ln](),o=t.get("size")||[],s=y(x(t.get("width"),o[0]),r),l=y(x(t.get(hr),o[1]),a),u=g[bn](t[L](),{width:e[un](),height:e[ln]()}),f=n&&n.type,p=w.retrieveTargetInfo(n,t),v="treemapRender"===f||"treemapMove"===f?n.rootRect:null,m=t.getViewRoot();if("treemapMove"!==f){var b="treemapZoomToNode"===f?c(t,p,s,l):v?[v.width,v[hr]]:[s,l],M=t.get("sort");M&&"asc"!==M&&"desc"!==M&&(M="desc");var S={squareRatio:t.get("squareRatio"),sort:M};m[Rt]({x:0,y:0,width:b[0],height:b[1],area:b[0]*b[1]}),i(m,S)}m[Rt](h(u,v,p),!0),t.setLayoutInfo(u),d(m,new _(-u.x,-u.y,r,a))})}function i(t,e){var r,a;if(!t.isRemoved()){var o=t[zt]();r=o.width,a=o[hr];var s=t[ir](A),c=s.get(Kn),h=s.get("gapWidth")/2,d=c-h,m=t[ir]();t[Rt]({borderWidth:c},!0),r=f(r-2*d,0),a=f(a-2*d,0);var g=r*a,y=n(t,m,g,e);if(y[Kr]){var x={x:d,y:d,width:r,height:a},_=p(r,a),w=1/0,b=[];b.area=0;for(var M=0,S=y[Kr];S>M;){var C=y[M];b.push(C),b.area+=C[zt]().area;var T=l(b,_,e.squareRatio);w>=T?(M++,w=T):(b.area-=b.pop()[zt]().area,u(b,_,x,h,!1),_=p(x.width,x[hr]),b[Kr]=b.area=0,w=1/0)}b[Kr]&&u(b,_,x,h,!0);var k;if(!e.hideChildren){var L=m.get("childrenVisibleMin");null!=L&&L>g&&(k=!0)}for(var M=0,S=y[Kr];S>M;M++){var I=v[Lr]({hideChildren:k},e);i(y[M],I)}}}}function n(t,e,i,n){var a=t.children||[],l=n.sort;if("asc"!==l&&"desc"!==l&&(l=null),n.hideChildren)return t.viewChildren=[];a=v[$r](a,function(t){return!t.isRemoved()}),o(a,l);var u=s(e,a,l);if(0===u.sum)return t.viewChildren=[];if(u.sum=r(e,i,u.sum,l,a),0===u.sum)return t.viewChildren=[];for(var c=0,h=a[Kr];h>c;c++){var d=a[c].getValue()/u.sum*i;a[c][Rt]({area:d})}return t.viewChildren=a,t[Rt]({dataExtent:u.dataExtent},!0),a}function r(t,e,i,n,r){if(!n)return i;for(var a=t.get("visibleMin"),o=r[Kr],s=o,l=o-1;l>=0;l--){var u=r["asc"===n?o-l-1:l].getValue();a>u/i*e&&(s=l,i-=u)}return"asc"===n?r[fn](0,o-s):r[fn](s,o-s),i}function o(t,e){return e&&t.sort(function(t,i){return"asc"===e?t.getValue()-i.getValue():i.getValue()-t.getValue()}),t}function s(t,e,i){for(var n=0,r=0,o=e[Kr];o>r;r++)n+=e[r].getValue();var s,l=t.get("visualDimension");if(e&&e[Kr])if("value"===l&&i)s=[e[e[Kr]-1].getValue(),e[0].getValue()],"asc"===i&&s[a]();else{var s=[1/0,-(1/0)];v.each(e,function(t){var e=t.getValue(l);es[1]&&(s[1]=e)})}else s=[NaN,NaN];return{sum:n,dataExtent:s}}function l(t,e,i){for(var n,r=0,a=1/0,o=0,s=t[Kr];s>o;o++)n=t[o][zt]().area,n&&(a>n&&(a=n),n>r&&(r=n));var l=t.area*t.area,u=e*e*i;return l?f(u*r/l,l/(u*a)):1/0}function u(t,e,i,n,r){var a=e===i.width?0:1,o=1-a,s=["x","y"],l=["width",hr],u=i[s[a]],c=e?t.area/e:0;(r||c>i[l[o]])&&(c=i[l[o]]);for(var h=0,d=t[Kr];d>h;h++){var v=t[h],m={},g=c?v[zt]().area/c:0,y=m[l[o]]=f(c-2*n,0),x=i[s[a]]+i[l[a]]-u,_=h===d-1||g>x?x:g,w=m[l[a]]=f(_-2*n,0);m[s[o]]=i[s[o]]+p(n,y/2),m[s[a]]=u+p(n,w/2),u+=_,v[Rt](m,!0)}i[s[o]]+=c,i[l[o]]-=c}function c(t,e,i,n){var r=(e||{}).node,a=[i,n];if(!r||r===t.getViewRoot())return a;for(var o,s=i*n,l=s*t.get("zoomToNodeRatio");o=r[ke];){for(var u=0,c=o.children,h=0,d=c[Kr];d>h;h++)u+=c[h].getValue();var f=r.getValue();if(0===f)return a;l*=u/f;var p=o[ir](A).get(Kn);isFinite(p)&&(l+=4*p*p+4*p*Math.pow(l,.5)),l>m.MAX_SAFE_INTEGER&&(l=m.MAX_SAFE_INTEGER),r=o}s>l&&(l=s);var v=Math.pow(l/s,.5);return[i*v,n*v]}function h(t,e,i){if(e)return{x:e.x,y:e.y};var n={x:0,y:0};if(!i)return n;var r=i.node,a=r[zt]();if(!a)return n;for(var o=[a.width/2,a[hr]/2],s=r;s;){var l=s[zt]();o[0]+=l.x,o[1]+=l.y,s=s[ke]}return{x:t.width/2-o[0],y:t[hr]/2-o[1]}}function d(t,e){var i=t[zt]();t[Rt]({invisible:!e[be](i)},!0);for(var n=t.viewChildren||[],r=0,a=n[Kr];a>r;r++){var o=new _(e.x-i.x,e.y-i.y,e.width,e[hr]);d(n[r],o)}}var f=Math.max,p=Math.min,v=t(ta),m=t(gt),g=t(P),y=m[Br],x=v[Zn],_=t(fr),w=t("./helper");return e}),e("echarts/chart/treemap",[ia,Y,"./treemap/TreemapSeries","./treemap/TreemapView","./treemap/treemapAction","./treemap/treemapVisual","./treemap/treemapLayout"],function(t){var e=t(Y);t("./treemap/TreemapSeries"),t("./treemap/TreemapView"),t("./treemap/treemapAction"),e[Xt]("chart",t("./treemap/treemapVisual")),e[Yt](t("./treemap/treemapLayout"))}),e("echarts/data/Graph",[ia,ta],function(t){function e(t,e){this.id=null==t?"":t,this.inEdges=[],this.outEdges=[],this.edges=[],this.hostGraph,this[wi]=null==e?-1:e}function i(t,e,i){this.node1=t,this.node2=e,this[wi]=null==i?-1:i}var n=t(ta),r=function(t){this._directed=t||!1,this.nodes=[],this.edges=[],this._nodesMap={},this._edgesMap={},this.data,this.edgeData},a=r[ea];a.type="graph",a.isDirected=function(){return this._directed},a.addNode=function(t,i){var n=this._nodesMap;if(!n[t]){var r=new e(t,i);return r.hostGraph=this,this.nodes.push(r),n[t]=r,r}},a.getNodeByIndex=function(t){var e=this.data[Vn](t);return this.nodes[e]},a.getNodeById=function(t){return this._nodesMap[t]},a.addEdge=function(t,n,r){var a=this._nodesMap,o=this._edgesMap;if(t instanceof e||(t=a[t]),n instanceof e||(n=a[n]),t&&n){var s=t.id+"-"+n.id;if(!o[s]){var l=new i(t,n,r);return l.hostGraph=this,this._directed&&(t.outEdges.push(l),n.inEdges.push(l)),t.edges.push(l),t!==n&&n.edges.push(l),this.edges.push(l),o[s]=l,l}}},a.getEdgeByIndex=function(t){var e=this.edgeData[Vn](t);return this.edges[e]},a.getEdge=function(t,i){t instanceof e&&(t=t.id),i instanceof e&&(i=i.id);var n=this._edgesMap;return this._directed?n[t+"-"+i]:n[t+"-"+i]||n[i+"-"+t]},a[o]=function(t,e){for(var i=this.nodes,n=i[Kr],r=0;n>r;r++)i[r][wi]>=0&&t.call(e,i[r],r)},a.eachEdge=function(t,e){for(var i=this.edges,n=i[Kr],r=0;n>r;r++)i[r][wi]>=0&&i[r].node1[wi]>=0&&i[r].node2[wi]>=0&&t.call(e,i[r],r)},a.breadthFirstTraverse=function(t,i,n,r){if(i instanceof e||(i=this._nodesMap[i]),i){for(var a="out"===n?"outEdges":"in"===n?"inEdges":"edges",o=0;or;r++)i[r][wi]=-1;for(var r=0,a=t.count();a>r;r++)i[t[Vn](r)][wi]=r;e[Et](function(t){var i=n[e[Vn](t)];return i.node1[wi]>=0&&i.node2[wi]>=0});for(var r=0,a=n[Kr];a>r;r++)n[r][wi]=-1;for(var r=0,a=e.count();a>r;r++)n[e[Vn](r)][wi]=r},a.setEdgeData=function(t){this.edgeData=t,this._edgeDataSaved=t.cloneShallow()},a[gn]=function(){this.edgeData=this._edgeDataSaved.cloneShallow()},a.clone=function(){for(var t=new r(this._directed),e=this.nodes,i=this.edges,n=0;n=0&&this[t][e][fe](this[wi],i,n)},getVisual:function(i,n){return this[t][e][It](this[wi],i,n)},setLayout:function(i,n){this[wi]>=0&&this[t][e][Dt](this[wi],i,n)},getLayout:function(){return this[t][e][Pt](this[wi])},getGraphicEl:function(){return this[t][e][_i](this[wi])},getRawIndex:function(){return this[t][e][Vn](this[wi])}}};return n.mixin(e,s("hostGraph","data")),n.mixin(i,s("hostGraph","edgeData")),r.Node=e,r.Edge=i,r}),e("echarts/chart/helper/createGraphFromNodeEdge",[ia,kt,"../../data/Graph","../../data/helper/linkList",Tt,ta],function(t){var e=t(kt),i=t("../../data/Graph"),n=t("../../data/helper/linkList"),r=t(Tt),a=t(ta);return function(t,o,s,l){for(var u=new i(l),c=0;c.8?"left":c[0]<-.8?"right":Nr,f=c[1]>.8?"top":c[1]<-.8?Or:Er):(h=[5*-c[0]+s[0],5*-c[1]+s[1]],d=c[0]>.8?"right":c[0]<-.8?"left":Nr,f=c[1]>.8?Or:c[1]<-.8?"top":Er),a.attr({style:{textBaseline:a.__textBaseline||f,textAlign:a.__textAlign||d},position:h})}}function o(t,e){return-Math.PI/2-Math.atan2(e[1]-t[1],e[0]-t[0])}function s(t,e,i,n){h.Group.call(this),this._createLine(t,e,i,n)}var l=t(xt),u=t(gr),c=t("./LinePath"),h=t(yt),d=t(ta),f=t(gt),p=s[ea];return p.beforeUpdate=a,p._createLine=function(t,n,r,a){var o=t[$t],s=t[Pt](a),l=i(s);l.shape.percent=0,h[Oe](l,{shape:{percent:1}},o),this.add(l);var u=new h.Text({name:"label"});if(this.add(u),n){var c=e("fromSymbol",n,a);this.add(c),this._fromSymbolType=n[It](a,ft)}if(r){var d=e("toSymbol",r,a);this.add(d),this._toSymbolType=r[It](a,ft)}this._updateCommonStl(t,n,r,a)},p[mt]=function(t,i,r,a){var o=t[$t],s=this.childOfName("line"),l=t[Pt](a),u={shape:{}};if(n(u.shape,l),h[Ee](s,u,o),i){var c=i[It](a,ft);if(this._fromSymbolType!==c){var d=e("fromSymbol",i,a);this[Ii](s.childOfName("fromSymbol")),this.add(d)}this._fromSymbolType=c}if(r){var f=r[It](a,ft);if(f!==this._toSymbolType){var p=e("toSymbol",r,a);this[Ii](s.childOfName("toSymbol")),this.add(p)}this._toSymbolType=f}this._updateCommonStl(t,i,r,a)},p._updateCommonStl=function(t,e,i,n){var r=t[$t],a=this.childOfName("line"),o=t[zn](n),s=o[ir](M),l=s[ir](er),u=o[ir](b),c=u[ir](er),p=f.round(r[On](n)); -isNaN(p)&&(p=t[Rn](n)),a[qe](d[Lr]({stroke:t[It](n,"color")},o[ir](Q)[J]()));var v=this.childOfName("label");v[qe]({text:s.get("show")?d[Zn](r[ct](n,Fn),p):"",textFont:l[$n](),fill:l[Be]()||t[It](n,"color")}),v[We]={text:u.get("show")?d[Zn](r[ct](n,Hn),p):"",textFont:l[$n](),fill:c[Be]()},v.__textAlign=l.get("align"),v.__textBaseline=l.get(Qn),v.__position=s.get(Tn),h[He](this,o[ir]("lineStyle.emphasis")[J]())},p[Ai]=function(t,e,i,r){var a=t[Pt](r),o=this.childOfName("line");n(o.shape,a),o.dirty(!0),e&&e[_i](r).attr(Tn,a[0]),i&&i[_i](r).attr(Tn,a[1])},d[Tr](s,h.Group),s}),e("echarts/chart/helper/LineDraw",[ia,yt,"./Line"],function(t){function e(t){this._ctor=t||n,this.group=new i.Group}var i=t(yt),n=t("./Line"),r=e[ea];return r[mt]=function(t,e,i){var n=this._lineData,r=this.group,a=this._ctor;t.diff(n).add(function(n){var o=new a(t,e,i,n);t[Lt](n,o),r.add(o)})[on](function(a,o){var s=n[_i](o);s[mt](t,e,i,a),t[Lt](a,s),r.add(s)})[Ii](function(t){r[Ii](n[_i](t))})[ut](),this._lineData=t,this._fromData=e,this._toData=i},r[Ai]=function(){var t=this._lineData;t[yi](function(e,i){e[Ai](t,this._fromData,this._toData,i)},this)},r[Ii]=function(){this.group[Si]()},e}),e("echarts/chart/graph/GraphView",[ia,at,"../helper/LineDraw","../../component/helper/RoamController",Ct,yt,C],function(t){var e=t(at),i=t("../helper/LineDraw"),n=t("../../component/helper/RoamController"),r=t(Ct),a=t(yt);t(C)[jt]({type:"graph",init:function(t,r){var a=new e,o=new i,l=this.group,u=new n(r.getZr(),l);l.add(a.group),l.add(o.group),this[$]=a,this._lineDraw=o,this[s]=u,this._firstRender=!0},render:function(t,e,i){var n=t[tn];if("geo"===n.type||"view"===n.type){var o=t[Nn]();this[ne]=t;var s=this[$],l=this._lineDraw;s[mt](o);var u=o.graph.edgeData,c=t[Xn],h=r[Gn](t,u,c.edges||c.links);h[d]=function(t){var e=this[Pn](t),i=e.data,n=i.source+" > "+i[Zi];return e.value&&(n+=":"+e.value),n},l[mt](u,null,null),u[yi](function(t){t[Ti](function(t){t[$t]=h})}),o.graph.eachEdge(function(t){t.__lineWidth=t[ir](Q).get("width")});var f=this.group,p={position:n[Tn],scale:n.scale};this._firstRender?f.attr(p):a[Ee](f,p,t),this._nodeScaleRatio=t.get("nodeScaleRatio"),this._updateNodeAndLinkScale(),this._updateController(t,n,i),clearTimeout(this._layoutTimeout);var v=t.forceLayout,m=t.get("force.layoutAnimation");v&&this._startForceLayoutIteration(v,m),o[yi](function(t,e){var i=o[zn](e).get(Ri);i&&v?t.on("drag",function(){v.warmUp(),!this._layouting&&this._startForceLayoutIteration(v,m),v.setFixed(e),o[Dt](e,t[Tn])},this).on("dragend",function(){v.setUnfixed(e)},this):t.off("drag"),t.setDraggable(i)},this),this._firstRender=!1}},_startForceLayoutIteration:function(t,e){var i=this;!function n(){t.step(function(t){i[Ai](),(i._layouting=!t)&&(e?i._layoutTimeout=setTimeout(n,16):n())})}()},_updateController:function(t,e,i){var n=this[s];n.rect=e.getViewRect(),n[l](t.get("roam")),n.off("pan").off("zoom").on("pan",function(e,n){i[sn]({seriesId:t.id,type:"graphRoam",dx:e,dy:n})}).on("zoom",function(e,n,r){i[sn]({seriesId:t.id,type:"graphRoam",zoom:e,originX:n,originY:r})}).on("zoom",this._updateNodeAndLinkScale,this)},_updateNodeAndLinkScale:function(){var t=this[ne],e=t[Nn](),i=this.group,n=this._nodeScaleRatio,r=i.scale[0],a=(r-1)*n+1,o=[a/r,a/r];e[yi](function(t,e){t.attr("scale",o)})},updateLayout:function(t,e){this[$][Ai](),this._lineDraw[Ai]()},remove:function(t,e){this[$]&&this[$][Ii](),this._lineDraw&&this._lineDraw[Ii]()}})}),e("echarts/chart/graph/roamAction",[ia,C,"../../action/roamHelper"],function(t){var e=t(C),i=t("../../action/roamHelper"),n={type:"graphRoam",event:"graphRoam",update:"none"};e[Kt](n,function(t,e){e[ie]({mainType:"series",query:t},function(e){var n=e[tn],r=e[ir](u),a=i.calcPanAndZoom(r,t);e.setRoamPan&&e.setRoamPan(a.x,a.y),e.setRoamZoom&&e.setRoamZoom(a.zoom),n&&n.setPan(a.x,a.y),n&&n.setZoom(a.zoom)})})}),e("echarts/chart/graph/categoryFilter",[ia],function(t){return function(t){var e=t[hn]({mainType:"legend"});e&&e[Kr]&&t[de]("graph",function(t){var i=t.getCategoriesData(),n=t.getGraph(),r=n.data,a=i[Ot](i[Rn]);r[Et](function(t){var i=r[zn](t),n=i[Sr](St);if(null!=n){typeof n===Wr&&(n=a[n]);for(var o=0;o0&&(e=[(n[0]+r[0])/2-(n[1]-r[1])*i,(n[1]+r[1])/2-(r[0]-n[0])*i]),t[Rt]([n,r,e])})}}}),e("echarts/chart/graph/simpleLayout",[ia,"./simpleLayoutHelper"],function(t){var e=t("./simpleLayoutHelper");return function(t,i){t[de]("graph",function(t){var i=t.get(c);i&&"none"!==i||e(t)})}}),e("echarts/chart/graph/circularLayoutHelper",[ia],function(t){return function(t){var e=t[tn];if(!e||"view"===e.type){var i=e[tr](),n=t[Nn](),r=n.graph,a=0,s=n[Nt]("value"),l=2*Math.PI/(s||n.count()),u=i.width/2+i.x,c=i[hr]/2+i.y,h=Math.min(i.width,i[hr])/2;r[o](function(t){var e=t.getValue("value");a+=l*(s?e:2)/2,t[Rt]([h*Math.cos(a)+u,h*Math.sin(a)+c]),a+=l*(s?e:2)/2}),r.eachEdge(function(t){var e,i=t[ir]().get("lineStyle.normal.curveness")||0,n=t.node1[zt](),r=t.node2[zt]();i>0&&(e=[u,c]),t[Rt]([n,r,e])})}}}),e("echarts/chart/graph/circularLayout",[ia,"./circularLayoutHelper"],function(t){var e=t("./circularLayoutHelper");return function(t,i){t[de]("graph",function(t){"circular"===t.get(c)&&e(t)})}}),e("echarts/chart/graph/forceHelper",[ia,gr],function(t){var e=t(gr),i=e.scaleAndAdd;return function(t,n,r){for(var a=r.rect,o=a.width,s=a[hr],l=[a.x+o/2,a.y+s/2],u=null==r.gravity?.1:r.gravity,c=0;cs;s++){var m=t[s];m.fixed||(e.sub(a,l,m.p),e.scaleAndAdd(m.p,m.p,a,u*d))}for(var s=0;o>s;s++)for(var h=t[s],g=s+1;o>g;g++){var f=t[g];e.sub(a,f.p,h.p);var p=e.len(a);0===p&&(e.set(a,Math.random()-.5,Math.random()-.5),p=1);var y=(h.rep+f.rep)/p/p;!h.fixed&&i(h.pp,h.pp,a,y),!f.fixed&&i(f.pp,f.pp,a,-y)}for(var x=[],s=0;o>s;s++){var m=t[s];m.fixed||(e.sub(x,m.p,m.pp),e.scaleAndAdd(m.p,m.p,x,d),e.copy(m.pp,m.p))}d=.992*d,r&&r(t,n,.01>d)}}}}),e("echarts/chart/graph/forceLayout",[ia,"./forceHelper",gt,"./simpleLayoutHelper","./circularLayoutHelper",gr],function(t){var e=t("./forceHelper"),i=t(gt),n=t("./simpleLayoutHelper"),r=t("./circularLayoutHelper"),a=t(gr);return function(t,o){t[de]("graph",function(t){if("force"===t.get(c)){var o=t.preservedPoints||{},s=t.getGraph(),l=s.data,u=s.edgeData,h=t[ir]("force"),d=h.get("initLayout");t.preservedPoints?l.each(function(t){var e=l.getId(t);l[Dt](t,o[e]||[NaN,NaN])}):d&&"none"!==d?"circular"===d&&r(t):n(t);var f=l[Bt]("value"),p=h.get("repulsion"),v=h.get("edgeLength"),m=l[Ot]("value",function(t,e){var n=l[Pt](e),r=i[Gr](t,f,[0,p])||p/2;return{w:r,rep:r,p:!n||isNaN(n[0])||isNaN(n[1])?null:n}}),g=u[Ot]("value",function(t,e){var i=s.getEdgeByIndex(e);return{n1:m[i.node1[wi]],n2:m[i.node2[wi]],d:v,curveness:i[ir]().get("lineStyle.normal.curveness")||0}}),y=t[tn],x=y[tr](),_=e(m,g,{rect:x,gravity:h.get("gravity")}),w=_.step;_.step=function(t){for(var e=0,i=m[Kr];i>e;e++)m[e].fixed&&a.copy(m[e].p,s.getNodeByIndex(e)[zt]());w(function(e,i,n){for(var r=0,a=e[Kr];a>r;r++)e[r].fixed||s.getNodeByIndex(r)[Rt](e[r].p),o[l.getId(r)]=e[r].p;for(var r=0,a=i[Kr];a>r;r++){var u=i[r],c=u.n1.p,h=u.n2.p,d=[c,h];u.curveness>0&&d.push([(c[0]+h[0])/2-(c[1]-h[1])*u.curveness,(c[1]+h[1])/2-(h[0]-c[0])*u.curveness]),s.getEdgeByIndex(r)[Rt](d)}t&&t(n)})},t.forceLayout=_,t.preservedPoints=o,_.step()}else t.forceLayout=null})}}),e("echarts/chart/graph/createView",[ia,"../../coord/View",P,"zrender/core/bbox"],function(t){function e(t,e,i){var r=t[L]();return r.aspect=i,n[bn](r,{width:e[un](),height:e[ln]()})}var i=t("../../coord/View"),n=t(P),r=t("zrender/core/bbox");return function(t,n){var a=[];return t[de]("graph",function(t){var o=t.get(tn);if(!o||"view"===o){var s=new i;a.push(s);var l=t[Nn](),c=l[Ot](function(t){var e=l[zn](t);return[+e.get("x"),+e.get("y")]}),h=[],d=[];r.fromPoints(c,h,d);var f=e(t,n,(d[0]-h[0])/(d[1]-h[1])||1);(isNaN(h[0])||isNaN(h[1]))&&(h=[f.x,f.y],d=[f.x+f.width,f.y+f[hr]]);var p=d[0]-h[0],v=d[1]-h[1],m=f.width,g=f[hr];s=t[tn]=new i,s.setBoundingRect(h[0],h[1],p,v),s.setViewRect(f.x,f.y,m,g);var y=t[ir](u);s.setPan(y.get("x")||0,y.get("y")||0),s.setZoom(y.get("zoom")||1)}}),a}}),e("echarts/chart/graph",[ia,Y,ta,"./graph/GraphSeries","./graph/GraphView","./graph/roamAction","./graph/categoryFilter",X,"./graph/categoryVisual","./graph/simpleLayout","./graph/circularLayout","./graph/forceLayout","./graph/createView"],function(t){var e=t(Y),i=t(ta);t("./graph/GraphSeries"),t("./graph/GraphView"),t("./graph/roamAction"),e[Jt]($r,t("./graph/categoryFilter")),e[Xt]("chart",i.curry(t(X),"graph",dt,null)),e[Xt]("chart",t("./graph/categoryVisual")),e[Yt](t("./graph/simpleLayout")),e[Yt](t("./graph/circularLayout")),e[Yt](t("./graph/forceLayout")),e.registerCoordinateSystem("graphView",{create:t("./graph/createView")})}),e("echarts/chart/gauge/GaugeSeries",[ia,kt,wt,ta],function(t){var e=t(kt),i=t(wt),n=t(ta),r=i[Lr]({type:"series.gauge",getInitialData:function(t,i){var r=new e(["value"],this),a=t.data||[];return n[Dr](a)||(a=[a]),r[Zt](a),r},defaultOption:{zlevel:0,z:2,center:["50%","50%"],legendHoverLink:!0,radius:"75%",startAngle:225,endAngle:-45,clockwise:!0,min:0,max:100,splitNumber:10,axisLine:{show:!0,lineStyle:{color:[[.2,"#91c7ae"],[.8,"#63869e"],[1,"#c23531"]],width:30}},splitLine:{show:!0,length:30,lineStyle:{color:"#eee",width:2,type:"solid"}},axisTick:{show:!0,splitNumber:5,length:8,lineStyle:{color:"#eee",width:1,type:"solid"}},axisLabel:{show:!0,textStyle:{color:"auto"}},pointer:{show:!0,length:"80%",width:8},itemStyle:{normal:{color:"auto"}},title:{show:!0,offsetCenter:[0,"-40%"],textStyle:{color:"#333",fontSize:15}},detail:{show:!0,backgroundColor:"rgba(0,0,0,0)",borderWidth:0,borderColor:"#ccc",width:100,height:40,offsetCenter:[0,"40%"],textStyle:{color:"auto",fontSize:30}}}});return r}),e("echarts/chart/gauge/PointerPath",[ia,si],function(t){return t(si)[Lr]({type:"echartsGaugePointer",shape:{angle:0,width:10,r:10,x:0,y:0},buildPath:function(t,e){var i=Math.cos,n=Math.sin,r=e.r,a=e.width,o=e.angle,s=e.x-i(o)*a*(a>=r/3?1:2),l=e.y-n(o)*a*(a>=r/3?1:2);o=e.angle-Math.PI/2,t[hi](s,l),t[ci](e.x+i(o)*a,e.y+n(o)*a),t[ci](e.x+i(e.angle)*r,e.y+n(e.angle)*r),t[ci](e.x-i(o)*a,e.y-n(o)*a),t[ci](s,l)}})}),e("echarts/chart/gauge/GaugeView",[ia,"./PointerPath",yt,gt,rt],function(t){function e(t,e){var i=t.get(Nr),n=e[un](),r=e[ln](),a=Math.min(n,r),o=s(i[0],e[un]()),l=s(i[1],e[ln]()),u=s(t.get(jn),a/2);return{cx:o,cy:l,r:u}}function i(t,e){return e&&(typeof e===qr?t=e[Zr]("{value}",t):typeof e===Fr&&(t=e(t))),t}var n=t("./PointerPath"),r=t(yt),o=t(gt),s=o[Br],l=2*Math.PI,u=t(rt)[Lr]({type:"gauge",render:function(t,i,n){this.group[Si]();var r=t.get("axisLine.lineStyle.color"),a=e(t,n);this._renderMain(t,i,n,r,a)},_renderMain:function(t,e,i,n,a){for(var o=this.group,s=t[ir](_),u=s[ir](ce),c=t.get(ti),h=-t.get(ii)/180*Math.PI,d=-t.get(ei)/180*Math.PI,f=(d-h)%l,p=h,v=u.get("width"),m=0;m=t)return n[0][1];for(var e=0;e=t&&(0===e?0:n[e-1][0])=P;P++){var z=Math.cos(C),V=Math.sin(C);if(y.get("show")){var O=new r.Line({shape:{x1:z*v+f,y1:V*v+p,x2:z*(v-S)+f,y2:V*(v-S)+p},style:L,silent:!0});"auto"===L[br]&&O[qe]({stroke:a(P/b)}),d.add(O)}if(_.get("show")){var E=i(o.round(P/b*(g-m)+m),_.get(Dn)),N=new r.Text({style:{text:E,x:z*(v-S-5)+f,y:V*(v-S-5)+p,fill:D[Be](),textFont:D[$n](),textBaseline:-.4>V?"top":V>.4?Or:Er,textAlign:-.4>z?"left":z>.4?"right":Nr},silent:!0});"auto"===N.style.fill&&N[qe]({fill:a(P/b)}),d.add(N)}if(x.get("show")&&P!==b){for(var B=0;M>=B;B++){var z=Math.cos(C),V=Math.sin(C),Z=new r.Line({shape:{x1:z*v+f,y1:V*v+p,x2:z*(v-A)+f,y2:V*(v-A)+p},silent:!0,style:I});"auto"===I[br]&&Z[qe]({stroke:a((P+B/M)/b)}),d.add(Z),C+=k}C-=k}else C+=T}},_renderPointer:function(t,e,i,l,u,c,h,d){var f=o[Gr],p=[+t.get("min"),+t.get("max")],v=[c,h];d||(v=v[a]());var m=t[Nn](),g=this._data,y=this.group;m.diff(g).add(function(e){var i=new n({shape:{angle:c}});r[Ee](i,{shape:{angle:f(m.get("value",e),p,v)}},t),y.add(i),m[Lt](e,i)})[on](function(e,i){var n=g[_i](i);r[Ee](n,{shape:{angle:f(m.get("value",e),p,v)}},t),y.add(n),m[Lt](e,n)})[Ii](function(t){var e=g[_i](t);y[Ii](e)})[ut](),m[yi](function(t,e){var i=m[zn](e),n=i[ir]("pointer");t.attr({shape:{x:u.cx,y:u.cy,width:s(n.get("width"),u.r),r:s(n.get(Kr),u.r)},style:i[ir](A)[ht]()}),"auto"===t.style.fill&&t[qe]("fill",l((m.get("value",e)-p[0])/(p[1]-p[0]))),r[He](t,i[ir](S)[ht]())}),this._data=m},_renderTitle:function(t,e,i,n,a){var o=t[ir]("title");if(o.get("show")){var l=o[ir](er),u=o.get("offsetCenter"),c=a.cx+s(u[0],a.r),h=a.cy+s(u[1],a.r),d=new r.Text({style:{x:c,y:h,text:t[Nn]()[Rn](0),fill:l[Be](),textFont:l[$n](),textAlign:"center",textBaseline:"middle"}});this.group.add(d)}},_renderDetail:function(t,e,n,a,o){var l=t[ir]("detail"),u=t.get("min"),c=t.get("max");if(l.get("show")){var h=l[ir](er),d=l.get("offsetCenter"),f=o.cx+s(d[0],o.r),p=o.cy+s(d[1],o.r),v=s(l.get("width"),o.r),m=s(l.get(hr),o.r),g=t[Nn]().get("value",0),y=new r.Rect({shape:{x:f-v/2,y:p-m/2,width:v,height:m},style:{text:i(g,l.get(Dn)),fill:l.get(xe),textFill:h[Be](),textFont:h[$n]()}});"auto"===y.style.textFill&&y[qe]("textFill",a((g-u)/(c-u))),y[qe](l[ht](["color"])),this.group.add(y)}}});return u}),e("echarts/chart/gauge",[ia,"./gauge/GaugeSeries","./gauge/GaugeView"],function(t){t("./gauge/GaugeSeries"),t("./gauge/GaugeView")}),e("echarts/chart/funnel/FunnelSeries",[ia,kt,Ct,Tt,C],function(t){var e=t(kt),i=t(Ct),n=t(Tt),r=t(C)[qt]({type:"series.funnel",init:function(t){r[kr](this,"init",arguments),this[m]=function(){return this._dataBeforeProcessed},this._defaultLabelLine(t)},getInitialData:function(t,i){var r=n(["value"],t.data),a=new e(r,this);return a[Zt](t.data),a},_defaultLabelLine:function(t){i[Wn](t.labelLine,["show"]);var e=t.labelLine[Fn],n=t.labelLine[Hn];e.show=e.show&&t.label[Fn].show,n.show=n.show&&t.label[Hn].show},defaultOption:{zlevel:0,z:2,legendHoverLink:!0,left:80,top:60,right:80,bottom:60,minSize:"0%",maxSize:"100%",sort:"descending",gap:0,funnelAlign:"center",label:{normal:{show:!0,position:"outer"},emphasis:{show:!0}},labelLine:{normal:{show:!0,length:20,lineStyle:{width:1,type:"solid"}},emphasis:{}},itemStyle:{normal:{borderColor:"#fff",borderWidth:1},emphasis:{}}}});return r}),e("echarts/chart/funnel/FunnelView",[ia,yt,ta,rt],function(t){function e(t,e){function i(){o[zi]=o.hoverIgnore,s[zi]=s.hoverIgnore}function r(){o[zi]=o.normalIgnore,s[zi]=s.normalIgnore}n.Group.call(this);var a=new n[Ye],o=new n[Xe],s=new n.Text;this.add(a),this.add(o),this.add(s),this[mt](t,e,!0),this.on(Hn,i).on(Fn,r).on(Fe,i).on(Ze,r)}function i(t,e,i,n){var a=n[ir](er),o=n.get(Tn),s=o===ar||"inner"===o||o===Nr;return{fill:a[Be]()||(s?"#fff":t[It](e,"color")),textFont:a[$n](),text:r[Zn](t[$t][ct](e,i),t[Rn](e))}}var n=t(yt),r=t(ta),a=e[ea],o=[ue,Fn,wr];a[mt]=function(t,e,i){var a=this[Cn](0),s=t[$t],l=t[zn](e),u=t[Pt](e),c=t[zn](e).get(o);c=null==c?1:c,i?(a[ri]({points:u[$e]}),a[qe]({opacity:0}),n[Ee](a,{style:{opacity:c}},s)):n[Oe](a,{shape:{points:u[$e]}},s);var h=l[ir](ue),d=t[It](e,"color");a[qe](r[rr]({fill:d},h[ir](Fn)[ht]())),a[We]=h[ir](Hn)[ht](),this._updateLabel(t,e),n[He](this)},a._updateLabel=function(t,e){var r=this[Cn](1),a=this[Cn](2),o=t[$t],s=t[zn](e),l=t[Pt](e),u=l.label,c=t[It](e,"color");n[Ee](r,{shape:{points:u.linePoints||u.linePoints}},o),n[Ee](a,{style:{x:u.x,y:u.y}},o),a.attr({style:{textAlign:u[mi],textBaseline:u[vi],textFont:u.font},rotation:u[Ki],origin:[u.x,u.y],z2:10});var h=s[ir](M),d=s[ir](b),f=s[ir]("labelLine.normal"),p=s[ir]("labelLine.emphasis");a[qe](i(t,e,Fn,h)),a[zi]=a.normalIgnore=!h.get("show"),a.hoverIgnore=!d.get("show"),r[zi]=r.normalIgnore=!f.get("show"),r.hoverIgnore=!p.get("show"),r[qe]({stroke:c}),r[qe](f[ir](ce)[J]()),a[We]=i(t,e,Hn,d),r[We]=p[ir](ce)[J]()},r[Tr](e,n.Group);var s=t(rt)[Lr]({type:"funnel",render:function(t,i,n){var r=t[Nn](),a=this._data,o=this.group;r.diff(a).add(function(t){var i=new e(r,t);r[Lt](t,i),o.add(i)})[on](function(t,e){var i=a[_i](e);i[mt](r,t),o.add(i),r[Lt](t,i)})[Ii](function(t){var e=a[_i](t);o[Ii](e)})[ut](),this._data=r},remove:function(){this.group[Si](),this._data=null}});return s}),e("echarts/chart/funnel/funnelLayout",[ia,P,gt],function(t){function e(t,e){return r[bn](t[L](),{width:e[un](),height:e[ln]()})}function i(t,e){for(var i=t[Ot]("value",function(t){return t}),n=[],r="ascending"===e,a=0,o=t.count();o>a;a++)n[a]=a;return n.sort(function(t,e){return r?i[t]-i[e]:i[e]-i[t]}),n}function n(t){t.each(function(e){var i,n,r,a,o=t[zn](e),s=o[ir](M),l=s.get(Tn),u=o[ir]("labelLine.normal"),c=t[Pt](e),h=c[$e],d="inner"===l||l===ar||l===Nr;if(d)n=(h[0][0]+h[1][0]+h[2][0]+h[3][0])/4,r=(h[0][1]+h[1][1]+h[2][1]+h[3][1])/4,i=Nr,a=[[n,r],[n,r]];else{var f,p,v,m=u.get(Kr);"left"===l?(f=(h[3][0]+h[0][0])/2,p=(h[3][1]+h[0][1])/2,v=f-m,n=v-5,i="right"):(f=(h[1][0]+h[2][0])/2,p=(h[1][1]+h[2][1])/2,v=f+m,n=v+5,i="left");var g=p;a=[[f,p],[v,g]],r=g}c.label={linePoints:a,x:n,y:r,textBaseline:"middle",textAlign:i,inside:d}})}var r=t(P),o=t(gt),s=o[Br];return function(t,r){t[de]("funnel",function(t){var l=t[Nn](),u=t.get("sort"),c=e(t,r),h=i(l,u),d=[s(t.get("minSize"),c.width),s(t.get("maxSize"),c.width)],f=l[Bt]("value"),p=t.get("min"),v=t.get("max");null==p&&(p=Math.min(f[0],0)),null==v&&(v=f[1]);var m=t.get("funnelAlign"),g=t.get("gap"),y=(c[hr]-g*(l.count()-1))/l.count(),x=c.y,_=function(t,e){var i,n=l.get("value",t)||0,r=o[Gr](n,[p,v],d,!0);switch(m){case"left":i=c.x;break;case Nr:i=c.x+(c.width-r)/2;break;case"right":i=c.x+c.width-r}return[[i,e],[i+r,e]]};"ascending"===u&&(y=-y,g=-g,x+=c[hr],h=h[a]());for(var w=0;wo;o++)r[n[o]].model.getActiveState()!==Fn&&(a=!0);for(var l=0,u=t.count();u>l;l++){var c,h=t[Gt](n,l);if(a){c="active";for(var o=0,s=n[Kr];s>o;o++){var d=n[o],f=r[d].model.getActiveState(h[o],o);if("inactive"===f){c="inactive";break}}}else c=Fn;e.call(i,c,l)}},axisCoordToPoint:function(t,e){var i=this._axesLayout[e],n=[t,0];return s[dr](n,n,i[Xi]),n},getAxisLayout:function(t){return r.clone(this._axesLayout[t])}},e}),e("echarts/coord/parallel/parallelCreator",[ia,"./Parallel",At],function(t){function e(t,e){var n=[];return t[ie]("parallel",function(r,a){var o=new i(r,t,e);o.name="parallel_"+a,o[Me](r,e),r[tn]=o,o.model=r,n.push(o)}),t[he](function(t){if("parallel"===t.get(tn)){var e=t.get("parallelIndex");t[tn]=n[e]}}),n}var i=t("./Parallel");t(At)[an]("parallel",{create:e})}),e("echarts/coord/parallel/AxisModel",[ia,z,ta,"../../model/mixin/makeStyleMapper","../axisModelCreator",gt,"../axisModelCommonMixin"],function(t){function e(t,e){return e.type||(e.data?St:"value")}var i=t(z),n=t(ta),r=t("../../model/mixin/makeStyleMapper"),a=t("../axisModelCreator"),o=t(gt),s=i[Lr]({type:"baseParallelAxis",axis:null,activeIntervals:[],getAreaSelectStyle:function(){return r([["fill","color"],[Mr,Kn],[br,Jn],["width","width"],[wr,wr]]).call(this[ir]("areaSelectStyle"))},setActiveIntervals:function(t){var e=this.activeIntervals=n.clone(t);if(e)for(var i=e[Kr]-1;i>=0;i--)o.asc(e[i])},getActiveState:function(t){var e=this.activeIntervals;if(!e[Kr])return Fn;if(null==t)return"inactive";for(var i=0,n=e[Kr];n>i;i++)if(e[i][0]<=t&&t<=e[i][1])return"active";return"inactive"}}),l={type:"value",dim:null,parallelIndex:null,areaSelectStyle:{width:20,borderWidth:1,borderColor:"rgba(160,197,232)",color:"rgba(160,197,232)",opacity:.3},z:10};return n.merge(s[ea],t("../axisModelCommonMixin")),a("parallel",s,e,l),s}),e("echarts/coord/parallel/ParallelModel",[ia,ta,z,"./AxisModel"],function(t){var e=t(ta),i=t(z);t("./AxisModel"),i[Lr]({type:"parallel",dependencies:["parallelAxis"],coordinateSystem:null,dimensions:null,parallelAxisIndex:null,defaultOption:{zlevel:0,z:0,left:80,top:60,right:80,bottom:60,layout:"horizontal",parallelAxisDefault:null},init:function(){i[ea].init.apply(this,arguments),this[mn]({})},mergeOption:function(t){var i=this[Xn];t&&e.merge(i,t,!0),this._initDimensions()},contains:function(t,e){var i=t.get("parallelIndex");return null!=i&&e[rn]("parallel",i)===this},_initDimensions:function(){var t=this[Ht]=[],i=this.parallelAxisIndex=[],n=e[$r](this.dependentModels.parallelAxis,function(t){return t.get("parallelIndex")===this.componentIndex});e.each(n,function(e){t.push("dim"+e.get("dim")),i.push(e.componentIndex)})}})}),e("echarts/component/axis/parallelAxisAction",[ia,C],function(t){var e=t(C),i={type:"axisAreaSelect",event:"axisAreaSelected",update:"updateVisual"};e[Kt](i,function(t,e){e[ie]({mainType:"parallelAxis",query:t},function(e){e.axis.model.setActiveIntervals(t.intervals)})})}),e("echarts/component/helper/SelectController",[ia,Ji,ta,yt],function(t){function e(t,e,i){v.call(this),this.type=t,this.zr=e,this.opt=m.clone(i),this.group=new y.Group,this._containerRect=null,this._track=[],this._dragging,this._cover,this._disabled=!0,this._handlers={mousedown:x(a,this),mousemove:x(o,this),mouseup:x(s,this)},_(C,function(t){this.zr.on(t,this._handlers[t])},this)}function i(t){t[Ti](function(t){t.z=S})}function n(t,e){var i=this.group[Fi](t,e);return!this._containerRect||this._containerRect[pi](i[0],i[1])}function r(t){var e=t.event;e.preventDefault&&e.preventDefault()}function a(t){if(!(this._disabled||t[Zi]&&t[Zi][Ri])){r(t);var e=t[Ie],i=t[Le];n.call(this,e,i)&&(this._dragging=!0,this._track=[[e,i]])}}function o(t){this._dragging&&!this._disabled&&(r(t),l.call(this,t))}function s(t){this._dragging&&!this._disabled&&(r(t),l.call(this,t,!0),this._dragging=!1,this._track=[])}function l(t,e){var i=t[Ie],r=t[Le];if(n.call(this,i,r)){this._track.push([i,r]);var a=u.call(this)?T[this.type].getRanges.call(this):[];c.call(this,a),this[bi](g,m.clone(a)),e&&this[bi]("selectEnd",m.clone(a))}}function u(){var t=this._track;if(!t[Kr])return!1;var e=t[t[Kr]-1],i=t[0],n=e[0]-i[0],r=e[1]-i[1],a=M(n*n+r*r,.5);return a>A}function c(t){var e=T[this.type];t&&t[Kr]?(this._cover||(this._cover=e[cr].call(this),this.group.add(this._cover)),e[on].call(this,t)):(this.group[Ii](this._cover),this._cover=null),i(this.group)}function h(){var t=this.group,e=t[Ui];e&&e[Ii](t)}function d(){var t=this.opt;return new y.Rect({style:{stroke:t[br],fill:t.fill,lineWidth:t[Mr],opacity:t[wr]}})}function f(){return m.map(this._track,function(t){return this.group[Fi](t[0],t[1])},this)}function p(){var t=f.call(this),e=t[Kr]-1;return 0>e&&(e=0),[t[0],t[e]]}var v=t(Ji),m=t(ta),y=t(yt),x=m.bind,_=m.each,w=Math.min,b=Math.max,M=Math.pow,S=1e4,A=2,C=[ze,Pe,De];e[ea]={constructor:e,enable:function(t,e){this._disabled=!1,h.call(this),this._containerRect=e!==!1?e||t[tr]():null,t.add(this.group)},update:function(t){c.call(this,t&&m.clone(t))},disable:function(){this._disabled=!0,h.call(this)},dispose:function(){this.disable(),_(C,function(t){this.zr.off(t,this._handlers[t])},this)}},m.mixin(e,v);var T={line:{create:d,getRanges:function(){var t=p.call(this),e=w(t[0][0],t[1][0]),i=b(t[0][0],t[1][0]);return[[e,i]]},update:function(t){var e=t[0],i=this.opt.width;this._cover[ri]({x:e[0],y:-i/2,width:e[1]-e[0],height:i})}},rect:{create:d,getRanges:function(){var t=p.call(this),e=[w(t[1][0],t[0][0]),w(t[1][1],t[0][1])],i=[b(t[1][0],t[0][0]),b(t[1][1],t[0][1])];return[[[e[0],i[0]],[e[1],i[1]]]]},update:function(t){var e=t[0];this._cover[ri]({x:e[0][0],y:e[1][0],width:e[0][1]-e[0][0],height:e[1][1]-e[1][0]})}}};return e}),e("echarts/component/axis/ParallelAxisView",[ia,ta,"./AxisBuilder","../helper/SelectController",C],function(t){function e(t,e,i){return i&&"axisAreaSelect"===i.type&&e[hn]({mainType:"parallelAxis",query:i})[0]===t}var i=t(ta),n=t("./AxisBuilder"),r=t("../helper/SelectController"),a=[_,R,w,"axisName"],o=t(C)[Wt]({type:"parallelAxis",_selectController:null,render:function(t,r,o,s){if(!e(t,r,s)&&(this.axisModel=t,this.api=o,this.group[Si](),t.get("show"))){var l=r[rn]("parallel",t.get("parallelIndex"))[tn],u=t.getAreaSelectStyle(),c=u.width,h=l.getAxisLayout(t.axis.dim),d=i[Lr]({strokeContainThreshold:c,silent:!(c>0)},h),f=new n(t,d);i.each(a,f.add,f);var p=f.getGroup();this.group.add(p),this._buildSelectController(p,u,t,o)}},_buildSelectController:function(t,e,n,a){var o=n.axis,s=this._selectController;s||(s=this._selectController=new r("line",a.getZr(),e),s.on(g,i.bind(this._onSelected,this))),s[l](t);var u=i.map(n.activeIntervals,function(t){return[o[O](t[0],!0),o[O](t[1],!0)]});s[on](u)},_onSelected:function(t){var e=this.axisModel,n=e.axis,r=i.map(t,function(t){return[n[V](t[0],!0),n[V](t[1],!0)]});this.api[sn]({type:"axisAreaSelect",parallelAxisId:e.id,intervals:r})},remove:function(){this._selectController&&this._selectController.disable()},dispose:function(){this._selectController&&(this._selectController[me](),this._selectController=null)}});return o}),e("echarts/component/parallelAxis",[ia,"../coord/parallel/parallelCreator","./axis/parallelAxisAction","./axis/ParallelAxisView"],function(t){t("../coord/parallel/parallelCreator"),t("./axis/parallelAxisAction"),t("./axis/ParallelAxisView")}),e("echarts/coord/parallel/parallelPreprocessor",[ia,ta,Ct],function(t){function e(t){if(!t.parallel){var e=!1;n.each(t[pn],function(t){t&&"parallel"===t.type&&(e=!0)}),e&&(t.parallel=[{}])}}function i(t){var e=r[qn](t.parallelAxis);n.each(e,function(e){if(n[In](e)){var i=e.parallelIndex||0,a=r[qn](t.parallel)[i];a&&a.parallelAxisDefault&&n.merge(e,a.parallelAxisDefault,!1)}})}var n=t(ta),r=t(Ct);return function(t){e(t),i(t)}}),e("echarts/component/parallel",[ia,"../coord/parallel/parallelCreator","../coord/parallel/ParallelModel","./parallelAxis",Y,"../coord/parallel/parallelPreprocessor"],function(t){t("../coord/parallel/parallelCreator"),t("../coord/parallel/ParallelModel"),t("./parallelAxis");var e=t(Y);e[Wt]({type:"parallel"}),e[Qt](t("../coord/parallel/parallelPreprocessor"))}),e("echarts/chart/parallel/ParallelSeries",[ia,kt,ta,wt],function(t){function e(t,e,i){var r=t.get("data"),a=+e[Zr]("dim","");r&&r[Kr]&&n.each(i,function(t){if(t){var e=n[Ur](r,t[a]);t[a]=e>=0?e:NaN}})}var i=t(kt),n=t(ta),r=t(wt);return r[Lr]({type:"series.parallel",dependencies:["parallel"],getInitialData:function(t,r){var a=r[rn]("parallel",this.get("parallelIndex")),o=a[Ht],s=a.parallelAxisIndex,l=t.data,u=n.map(o,function(t,i){var n=r[rn]("parallelAxis",s[i]);return n.get("type")===St?(e(n,t,l),{name:t,type:"ordinal"}):t}),c=new i(u,this);return c[Zt](l),c},defaultOption:{zlevel:0,z:2,coordinateSystem:"parallel",parallelIndex:0,label:{normal:{show:!1},emphasis:{show:!1}},inactiveOpacity:.05,activeOpacity:1,lineStyle:{normal:{width:2,opacity:.45,type:"solid"}},animationEasing:"linear"}})}),e("echarts/chart/parallel/ParallelView",[ia,yt,ta,rt],function(t){function e(t,e,i){var n=t.model,r=t[I](),o=new a.Rect({shape:{x:r.x,y:r.y,width:r.width,height:r[hr]}}),s=n.get(c)===An?"width":hr;return o[ri](s,0),a[Oe](o,{shape:{width:r.width,height:r[hr]}},e,i),o}function i(t,e,i,n){for(var a=0,o=e[Kr]-1;o>a;a++){var s=e[a],l=e[a+1],u=t[a],c=t[a+1];n(r(u,i[et](s).type)||r(c,i[et](l).type)?null:[i[ot](u,s),i[ot](c,l)],a)}}function n(t){return new a[Xe]({shape:{points:t},silent:!0})}function r(t,e){return e===St?null==t:null==t||isNaN(t)}var a=t(yt),o=t(ta),s=t(rt)[Lr]({type:"parallel",init:function(){this._dataGroup=new a.Group,this.group.add(this._dataGroup),this._data},render:function(t,r,s,l){function u(t){var e=f[Gt](m,t),r=new a.Group;d.add(r),i(e,m,v,function(t,e){t&&r.add(n(t))}),f[Lt](t,r)}function c(e,r){var o=f[Gt](m,e),s=p[_i](r),l=[],u=0;i(o,m,v,function(e,i){var r=s[Cn](u++);e&&!r?l.push(n(e)):e&&a[Ee](r,{shape:{points:e}},t)});for(var c=s.childCount()-1;c>=u;c--)s[Ii](s[Cn](c));for(var c=0,h=l[Kr];h>c;c++)s.add(l[c]);f[Lt](e,s)}function h(t){var e=p[_i](t);d[Ii](e)}var d=this._dataGroup,f=t[Nn](),p=this._data,v=t[tn],m=v[Ht];f.diff(p).add(u)[on](c)[Ii](h)[ut](),f[yi](function(t,e){var i=f[zn](e),n=i[ir](Q);t[kn](function(t){t[qe](o[Lr](n[J](),{stroke:f[It](e,"color"),opacity:f[It](e,wr)}))})}),this._data||d.setClipPath(e(v,t,function(){d.removeClipPath()})),this._data=f},remove:function(){ -this._dataGroup&&this._dataGroup[Si](),this._data=null}});return s}),e("echarts/chart/parallel/parallelVisual",[ia],function(t){return function(t,e){t[de]("parallel",function(e){var i=e[ir](A),n=t.get("color"),r=i.get("color")||n[e[Bn]%n[Kr]],a=e.get("inactiveOpacity"),o=e.get("activeOpacity"),s=e[ir](Q)[J](),l=e[tn],u=e[Nn](),c={normal:s[wr],active:o,inactive:a};l.eachActiveState(u,function(t,e){u[fe](e,wr,c[t])}),u[ve]("color",r)})}}),e("echarts/chart/parallel",[ia,Y,"../component/parallel","./parallel/ParallelSeries","./parallel/ParallelView","./parallel/parallelVisual"],function(t){var e=t(Y);t("../component/parallel"),t("./parallel/ParallelSeries"),t("./parallel/ParallelView"),e[Xt]("chart",t("./parallel/parallelVisual"))}),e("echarts/chart/sankey/SankeySeries",[ia,wt,"../helper/createGraphFromNodeEdge"],function(t){var e=t(wt),i=t("../helper/createGraphFromNodeEdge");return e[Lr]({type:"series.sankey",layoutInfo:null,getInitialData:function(t,e){var n=t.edges||t.links,r=t.data||t.nodes;if(r&&n){var a=i(r,n,this,!0);return a.data}},getGraph:function(){return this[Nn]().graph},getEdgeData:function(){return this.getGraph().edgeData},defaultOption:{zlevel:0,z:2,coordinateSystem:"view",layout:null,left:"5%",top:"5%",right:"20%",bottom:"5%",nodeWidth:20,nodeGap:8,layoutIterations:32,label:{normal:{show:!0,position:"right",textStyle:{color:"#000",fontSize:12}},emphasis:{show:!0}},itemStyle:{normal:{borderWidth:1,borderColor:"#aaa"}},lineStyle:{normal:{color:"#314656",opacity:.2,curveness:.5},emphasis:{opacity:.6}},color:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],animationEasing:"linear",animationDuration:1e3}})}),e("echarts/chart/sankey/SankeyView",[ia,yt,Ct,ta,C],function(t){function e(t,e,n){var r=new i.Rect({shape:{x:t.x-10,y:t.y-10,width:0,height:t[hr]+20}});return i[Oe](r,{shape:{width:t.width+20,height:t[hr]+20}},e,n),r}var i=t(yt),n=t(Ct),r=t(ta),a=i[je]({shape:{x1:0,y1:0,x2:0,y2:0,cpx1:0,cpy1:0,cpx2:0,cpy2:0,extent:0},buildPath:function(t,e){var i=e.extent/2;t[hi](e.x1,e.y1-i),t[ui](e.cpx1,e.cpy1-i,e.cpx2,e.cpy2-i,e.x2,e.y2-i),t[ci](e.x2,e.y2+i),t[ui](e.cpx2,e.cpy2+i,e.cpx1,e.cpy1+i,e.x1,e.y1+i),t[li]()}});return t(C)[jt]({type:"sankey",_model:null,render:function(t,s,l){var u=t.getGraph(),c=this.group,h=t.layoutInfo;this[ne]=t,c[Si](),c[Tn]=[h.x,h.y];var f=u.edgeData,p=t[Xn],v=n[Gn](t,f,p.edges||p.links);v[d]=function(t){var e=this[Pn](t),i=e.data,n=i.source+" -- "+i[Zi];return e.value&&(n+=":"+e.value),n},u[o](function(e){var n=e[zt](),a=e[ir](),o=a[ir](M),s=o[ir](er),l=a[ir](b),u=l[ir](er),h=new i.Rect({shape:{x:n.x,y:n.y,width:e[zt]().dx,height:e[zt]().dy},style:{text:o.get("show")?t[ct](e[wi],Fn)||e.id:"",textFont:s[$n](),textFill:s[Be](),textPosition:o.get(Tn)}});h[qe](r[rr]({fill:e[Vt]("color")},a[ir](A)[ht]())),i[He](h,r[Lr](e[ir](S),{text:l.get("show")?t[ct](e[wi],Hn)||e.id:"",textFont:u[$n](),textFill:u[Be](),textPosition:l.get(Tn)})),c.add(h)}),u.eachEdge(function(t){var e=new a;e[wi]=t[wi],e[$t]=v;var n=t[ir](Q),r=n.get("curveness"),o=t.node1[zt](),s=t.node2[zt](),l=t[zt]();e.shape.extent=Math.max(1,l.dy);var u=o.x+o.dx,h=o.y+l.sy+l.dy/2,d=s.x,f=s.y+l.ty+l.dy/2,p=u*(1-r)+d*r,m=h,g=u*r+d*(1-r),y=f;e[ri]({x1:u,y1:h,x2:d,y2:f,cpx1:p,cpy1:m,cpx2:g,cpy2:y}),e[qe](n[ht]()),i[He](e,t[ir]("lineStyle.emphasis")[ht]()),c.add(e)}),this._data||c.setClipPath(e(c[tr](),t,function(){c.removeClipPath()})),this._data=t[Nn]()}})}),e("echarts/util/array/nest",[ia,ta],function(t){function e(){function t(e,r){if(r>=n[Kr])return e;for(var a=-1,o=e[Kr],s=n[r++],l={},u={};++a=n[Kr])return t;var o=[],s=r[a++];return i.each(t,function(t,i){o.push({key:i,values:e(t,a)})}),s?o.sort(function(t,e){return s(t.key,e.key)}):o}var n=[],r=[];return{key:function(t){return n.push(t),this},sortKeys:function(t){return r[n[Kr]-1]=t,this},entries:function(i){return e(t(i,0),0)}}}var i=t(ta);return e}),e("echarts/chart/sankey/sankeyLayout",[ia,P,"../../util/array/nest",ta],function(t){function e(t,e){return M[bn](t[L](),{width:e[un](),height:e[ln]()})}function i(t,e,i,n,a,o,s){r(t,i,a),l(t,e,o,n,s),v(t)}function n(t){A.each(t,function(t){var e=y(t.outEdges,b),i=y(t.inEdges,b),n=Math.max(e,i);t[Rt]({value:n},!0)})}function r(t,e,i){for(var n=t,r=null,a=0,l=0;n[Kr];){r=[];for(var u=0,c=n[Kr];c>u;u++){var h=n[u];h[Rt]({x:a},!0),h[Rt]({dx:e},!0);for(var d=0,f=h.outEdges[Kr];f>d;d++)r.push(h.outEdges[d].node2)}n=r,++a}o(t,a),l=(i-e)/(a-1),s(t,l)}function o(t,e){A.each(t,function(t){t.outEdges[Kr]||t[Rt]({x:e-1},!0)})}function s(t,e){A.each(t,function(t){var i=t[zt]().x*e;t[Rt]({x:i},!0)})}function l(t,e,i,n,r){var a=S().key(function(t){return t[zt]().x}).sortKeys(w).entries(t).map(function(t){return t.values});u(t,a,e,i,n),c(a,n,i);for(var o=1;r>0;r--)o*=.99,h(a,o),c(a,n,i),f(a,o),c(a,n,i)}function u(t,e,i,n,r){var a=[];A.each(e,function(t){var e=t[Kr],i=0;A.each(t,function(t){i+=t[zt]().value});var o=(n-(e-1)*r)/i;a.push(o)}),a.sort(function(t,e){return t-e});var o=a[0];A.each(e,function(t){A.each(t,function(t,e){t[Rt]({y:e},!0);var i=t[zt]().value*o;t[Rt]({dy:i},!0)})}),A.each(i,function(t){var e=+t.getValue()*o;t[Rt]({dy:e},!0)})}function c(t,e,i){A.each(t,function(t){var n,r,a,o=0,s=t[Kr];for(t.sort(_),a=0;s>a;a++){if(n=t[a],r=o-n[zt]().y,r>0){var l=n[zt]().y+r;n[Rt]({y:l},!0)}o=n[zt]().y+n[zt]().dy+e}if(r=o-e-i,r>0){var l=n[zt]().y-r;for(n[Rt]({y:l},!0),o=n[zt]().y,a=s-2;a>=0;--a)n=t[a],r=n[zt]().y+n[zt]().dy+e-o,r>0&&(l=n[zt]().y-r,n[Rt]({y:l},!0)),o=n[zt]().y}})}function h(t,e){A.each(t.slice()[a](),function(t){A.each(t,function(t){if(t.outEdges[Kr]){var i=y(t.outEdges,d)/y(t.outEdges,b),n=t[zt]().y+(i-x(t))*e;t[Rt]({y:n},!0)}})})}function d(t){return x(t.node2)*t.getValue()}function f(t,e){A.each(t,function(t){A.each(t,function(t){if(t.inEdges[Kr]){var i=y(t.inEdges,p)/y(t.inEdges,b),n=t[zt]().y+(i-x(t))*e;t[Rt]({y:n},!0)}})})}function p(t){return x(t.node1)*t.getValue()}function v(t){A.each(t,function(t){t.outEdges.sort(m),t.inEdges.sort(g)}),A.each(t,function(t){var e=0,i=0;A.each(t.outEdges,function(t){t[Rt]({sy:e},!0),e+=t[zt]().dy}),A.each(t.inEdges,function(t){t[Rt]({ty:i},!0),i+=t[zt]().dy})})}function m(t,e){return t.node2[zt]().y-e.node2[zt]().y}function g(t,e){return t.node1[zt]().y-e.node1[zt]().y}function y(t,e){var i,n=0,r=t[Kr],a=-1;if(1===arguments[Kr])for(;++at?-1:t>e?1:t==e?0:NaN}function b(t){return t.getValue()}var M=t(P),S=t("../../util/array/nest"),A=t(ta);return function(t,r){t[de]("sankey",function(t){var a=t.get("nodeWidth"),o=t.get("nodeGap"),s=e(t,r);t.layoutInfo=s;var l=s.width,u=s[hr],c=t.getGraph(),h=c.nodes,d=c.edges;n(h);var f=h[$r](function(t){return 0===t[zt]().value}),p=0!==f[Kr]?0:t.get("layoutIterations");i(h,d,a,o,l,u,p)})}}),e("echarts/chart/sankey/sankeyVisual",[ia,n],function(t){var e=t(n);return function(t,i){t[de]("sankey",function(t){var i=t.getGraph(),n=i.nodes;n.sort(function(t,e){return t[zt]().value-e[zt]().value});var r=n[0][zt]().value,a=n[n[Kr]-1][zt]().value;n.forEach(function(i){var n=new e({type:"color",mappingMethod:"linear",dataExtent:[r,a],visual:t.get("color")}),o=n.mapValueToVisual(i[zt]().value);i[ve]("color",o)})})}}),e("echarts/chart/sankey",[ia,Y,"./sankey/SankeySeries","./sankey/SankeyView","./sankey/sankeyLayout","./sankey/sankeyVisual"],function(t){var e=t(Y);t("./sankey/SankeySeries"),t("./sankey/SankeyView"),e[Yt](t("./sankey/sankeyLayout")),e[Xt]("chart",t("./sankey/sankeyVisual"))}),e("echarts/chart/helper/WhiskerBoxDraw",[ia,ta,yt,si],function(t){function e(t,e,i,n){o.Group.call(this),this.bodyIndex,this.whiskerIndex,this.styleUpdater=i,this._createContent(t,e,n),this[mt](t,e,n),this._seriesModel}function i(t,e,i){return a.map(t,function(t){return t=t.slice(),t[e]=i.initBaseline,t})}function n(t){var e={};return a.each(t,function(t,i){e["ends"+i]=t}),e}function r(t){this.group=new o.Group,this.styleUpdater=t}var a=t(ta),o=t(yt),s=t(si),l=s[Lr]({type:"whiskerInBox",shape:{},buildPath:function(t,e){for(var i in e)if(0===i[Ur]("ends")){var n=e[i];t[hi](n[0][0],n[0][1]),t[ci](n[1][0],n[1][1])}}}),u=e[ea];u._createContent=function(t,e,r){var s=t[Pt](e),u=s.chartLayout===An?1:0,c=0;this.add(new o[Ye]({shape:{points:r?i(s.bodyEnds,u,s):s.bodyEnds},style:{strokeNoScale:!0},z2:100})),this.bodyIndex=c++;var h=a.map(s.whiskerEnds,function(t){return r?i(t,u,s):t});this.add(new l({shape:n(h),style:{strokeNoScale:!0},z2:100})),this.whiskerIndex=c++},u[mt]=function(t,e,i){var r=this._seriesModel=t[$t],a=t[Pt](e),s=o[i?Oe:Ee];s(this[Cn](this.bodyIndex),{shape:{points:a.bodyEnds}},r),s(this[Cn](this.whiskerIndex),{shape:n(a.whiskerEnds)},r),this.styleUpdater.call(null,this,t,e)},a[Tr](e,o.Group);var c=r[ea];return c[mt]=function(t){var i=this.group,n=this._data,r=this.styleUpdater;t.diff(n).add(function(n){if(t.hasValue(n)){var a=new e(t,n,r,!0);t[Lt](n,a),i.add(a)}})[on](function(a,o){var s=n[_i](o);return t.hasValue(a)?(s?s[mt](t,a):s=new e(t,a,r),i.add(s),void t[Lt](a,s)):void i[Ii](s)})[Ii](function(t){var e=n[_i](t);e&&i[Ii](e)})[ut](),this._data=t},c[Ii]=function(){var t=this.group,e=this._data;this._data=null,e&&e[yi](function(e){e&&t[Ii](e)})},r}),e("echarts/chart/helper/whiskerBoxCommon",[ia,kt,Tt,"../helper/WhiskerBoxDraw",ta],function(t){function e(t){return null==t.value?t:t.value}var i=t(kt),n=t(Tt),r=t("../helper/WhiskerBoxDraw"),a=t(ta),o={_baseAxisDim:null,getInitialData:function(t,r){var a,o,s=r[rn]("xAxis",this.get("xAxisIndex")),l=r[rn]("yAxis",this.get("yAxisIndex")),u=s.get("type"),h=l.get("type");u===St?(t[c]=An,a=s[Mt](),o=!0):h===St?(t[c]=Sn,a=l[Mt](),o=!0):t[c]=t[c]||An,this._baseAxisDim=t[c]===An?"x":"y";var d=t.data,f=this[Ht]=["base"][Hr](this.valueDimensions);n(f,d);var p=new i(f,this);return p[Zt](d,a?a.slice():null,function(t,i,n,r){var a=e(t);return o?"base"===i?n:a[r-1]:a[r]}),p},coordDimToDataDim:function(t){var e=this.valueDimensions.slice(),i=["base"],n={horizontal:{x:i,y:e},vertical:{x:e,y:i}};return n[this.get(c)][t]},dataDimToCoordDim:function(t){var e;return a.each(["x","y"],function(i,n){var r=this[k](i);a[Ur](r,t)>=0&&(e=i)},this),e},getBaseAxis:function(){var t=this._baseAxisDim;return this[nr][rn](t+"Axis",this.get(t+"AxisIndex")).axis}},s={init:function(){var t=this._whiskerBoxDraw=new r(this.getStyleUpdater());this.group.add(t.group)},render:function(t,e,i){this._whiskerBoxDraw[mt](t[Nn]())},remove:function(t){this._whiskerBoxDraw[Ii]()}};return{seriesModelMixin:o,viewMixin:s}}),e("echarts/chart/boxplot/BoxplotSeries",[ia,ta,wt,"../helper/whiskerBoxCommon"],function(t){var e=t(ta),i=t(wt),n=t("../helper/whiskerBoxCommon"),r=i[Lr]({type:"series.boxplot",dependencies:["xAxis","yAxis","grid"],valueDimensions:["min","Q1","median","Q3","max"],dimensions:null,defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,hoverAnimation:!0,xAxisIndex:0,yAxisIndex:0,layout:null,boxWidth:[7,50],itemStyle:{normal:{color:"#fff",borderWidth:1},emphasis:{borderWidth:2,shadowBlur:5,shadowOffsetX:2,shadowOffsetY:2,shadowColor:"rgba(0,0,0,0.4)"}},animationEasing:"elasticOut",animationDuration:800}});return e.mixin(r,n.seriesModelMixin,!0),r}),e("echarts/chart/boxplot/BoxplotView",[ia,ta,rt,yt,"../helper/whiskerBoxCommon"],function(t){function e(t,e,i){var n=e[zn](i),a=n[ir](s),o=e[It](i,"color"),u=a[ht]([Jn]),c=t[Cn](t.whiskerIndex);c.style.set(u),c.style[br]=o,c.dirty();var h=t[Cn](t.bodyIndex);h.style.set(u),h.style[br]=o,h.dirty();var d=n[ir](l)[ht]();r[He](t,d)}var i=t(ta),n=t(rt),r=t(yt),a=t("../helper/whiskerBoxCommon"),o=n[Lr]({type:"boxplot",getStyleUpdater:function(){return e}});i.mixin(o,a.viewMixin,!0);var s=[ue,Fn],l=[ue,Hn];return o}),e("echarts/chart/boxplot/boxplotVisual",[ia],function(t){var e=[ue,Fn,Jn];return function(t,i){var n=t.get("color");t.eachRawSeriesByType("boxplot",function(i){var r=n[i[Bn]%n[Kr]],a=i[Nn]();a[ve]({legendSymbol:"roundRect",color:i.get(e)||r}),t[pe](i)||a.each(function(t){var i=a[zn](t);a[fe](t,{color:i.get(e,!0)})})})}}),e("echarts/chart/boxplot/boxplotLayout",[ia,ta,gt],function(t){function e(t){var e=[],i=[];return t[de]("boxplot",function(t){var n=t[$i](),a=r[Ur](i,n);0>a&&(a=i[Kr],i[a]=n,e[a]={axis:n,seriesModels:[]}),e[a].seriesModels.push(t)}),e}function i(t){var e,i,n=t.axis,a=t.seriesModels,l=a[Kr],u=t.boxWidthList=[],c=t.boxOffsetList=[],h=[];if(n.type===St)i=n[it]();else{var d=0;s(a,function(t){d=Math.max(d,t[Nn]().count())}),e=n[st](),Math.abs(e[1]-e[0])/d}s(a,function(t){var e=t.get("boxWidth");r[Dr](e)||(e=[e,e]),h.push([o(e[0],i)||0,o(e[1],i)||0])});var f=.8*i-2,p=f/l*.3,v=(f-p*(l-1))/l,m=v/2-f/2;s(a,function(t,e){c.push(m),m+=p+v,u.push(Math.min(Math.max(v,h[e][0]),h[e][1]))})}function n(t,e,i){var n=t[tn],r=t[Nn](),a=t[Ht],o=t.get(c),s=i/2;r.each(a,function(){function t(t){var i=[];i[f]=h,i[p]=t;var r;return isNaN(h)||isNaN(t)?r=[NaN,NaN]:(r=n[ot](i),r[f]+=e),r}function i(t,e){var i=t.slice(),n=t.slice();i[f]+=s,n[f]-=s,e?x.push(i,n):x.push(n,i)}function l(t){var e=[t.slice(),t.slice()];e[0][f]-=s,e[1][f]+=s,y.push(e)}var u=arguments,c=a[Kr],h=u[0],d=u[c],f=o===An?0:1,p=1-f,v=t(u[3]),m=t(u[1]),g=t(u[5]),y=[[m,t(u[2])],[g,t(u[4])]];l(m),l(g),l(v);var x=[];i(y[0][1],0),i(y[1][1],1),r[Dt](d,{chartLayout:o,initBaseline:v[p],median:v,bodyEnds:x,whiskerEnds:y})})}var r=t(ta),a=t(gt),o=a[Br],s=r.each;return function(t,r){var a=e(t);s(a,function(t){var e=t.seriesModels;e[Kr]&&(i(t),s(e,function(e,i){n(e,t.boxOffsetList[i],t.boxWidthList[i])}))})}}),e("echarts/chart/boxplot",[ia,Y,"./boxplot/BoxplotSeries","./boxplot/BoxplotView","./boxplot/boxplotVisual","./boxplot/boxplotLayout"],function(t){var e=t(Y);t("./boxplot/BoxplotSeries"),t("./boxplot/BoxplotView"),e[Xt]("chart",t("./boxplot/boxplotVisual")),e[Yt](t("./boxplot/boxplotLayout"))}),e("echarts/chart/candlestick/CandlestickSeries",[ia,ta,wt,"../helper/whiskerBoxCommon",v],function(t){var e=t(ta),i=t(wt),n=t("../helper/whiskerBoxCommon"),r=t(v),a=r[nn],o=r[en],s=i[Lr]({type:"series.candlestick",dependencies:["xAxis","yAxis","grid"],valueDimensions:["open","close","lowest","highest"],dimensions:null,defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,hoverAnimation:!0,xAxisIndex:0,yAxisIndex:0,layout:null,itemStyle:{normal:{color:"#c23531",color0:"#314656",borderWidth:1,borderColor:"#c23531",borderColor0:"#314656"},emphasis:{borderWidth:2}},animationUpdate:!1,animationEasing:"linear",animationDuration:300},getShadowDim:function(){return"open"},formatTooltip:function(t,i){var n=e.map(this.valueDimensions,function(e){return e+": "+o(this._data.get(e,t))},this);return a(this.name)+Qi+n.join(Qi)}});return e.mixin(s,n.seriesModelMixin,!0),s}),e("echarts/chart/candlestick/CandlestickView",[ia,ta,rt,yt,"../helper/whiskerBoxCommon"],function(t){function e(t,e,i){var n=e[zn](i),a=n[ir](s),o=e[It](i,"color"),u=e[It](i,Jn),c=a[ht](["color","color0",Jn,"borderColor0"]),h=t[Cn](t.whiskerIndex);h.style.set(c),h.style[br]=u,h.dirty();var d=t[Cn](t.bodyIndex);d.style.set(c),d.style.fill=o,d.style[br]=u,d.dirty();var f=n[ir](l)[ht]();r[He](t,f)}var i=t(ta),n=t(rt),r=t(yt),a=t("../helper/whiskerBoxCommon"),o=n[Lr]({type:"candlestick",getStyleUpdater:function(){return e}});i.mixin(o,a.viewMixin,!0);var s=[ue,Fn],l=[ue,Hn];return o}),e("echarts/chart/candlestick/preprocessor",[ia,ta],function(t){var e=t(ta);return function(t){t&&e[Dr](t[pn])&&e.each(t[pn],function(t){e[In](t)&&"k"===t.type&&(t.type="candlestick")})}}),e("echarts/chart/candlestick/candlestickVisual",[ia],function(t){var e=[ue,Fn,Jn],i=[ue,Fn,"borderColor0"],n=[ue,Fn,"color"],r=[ue,Fn,"color0"];return function(t,a){t.eachRawSeriesByType("candlestick",function(a){var o=a[Nn]();o[ve]({legendSymbol:"roundRect"}),t[pe](a)||o.each(function(t){var a=o[zn](t),s=o[Pt](t).sign;o[fe](t,{color:a.get(s>0?n:r),borderColor:a.get(s>0?e:i)})})})}}),e("echarts/chart/candlestick/candlestickLayout",[ia],function(t){function e(t,e){var a,o=t[$i](),s=o.type===St?o[it]():(a=o[st](),Math.abs(a[1]-a[0])/e.count());return s/2-2>n?s/2-2:s-n>r?n:Math.max(s-r,i)}var i=2,n=5,r=4;return function(t,i){t[de]("candlestick",function(t){var i=t[tn],n=t[Nn](),r=t[Ht],a=t.get(c),o=e(t,n);n.each(r,function(){function t(t){var e=[];return e[h]=u,e[d]=t,isNaN(u)||isNaN(t)?[NaN,NaN]:i[ot](e)}function e(t,e){var i=t.slice(),n=t.slice();i[h]+=o/2,n[h]-=o/2,e?S.push(i,n):S.push(n,i)}var s=arguments,l=r[Kr],u=s[0],c=s[l],h=a===An?0:1,d=1-h,f=s[1],p=s[2],v=s[3],m=s[4],g=Math.min(f,p),y=Math.max(f,p),x=t(g),_=t(y),w=t(v),b=t(m),M=[[b,_],[w,x]],S=[];e(_,0),e(x,1),n[Dt](c,{chartLayout:a,sign:f>p?-1:p>f?1:0,initBaseline:f>p?_[d]:x[d],bodyEnds:S,whiskerEnds:M})},!0)})}}),e("echarts/chart/candlestick",[ia,Y,"./candlestick/CandlestickSeries","./candlestick/CandlestickView","./candlestick/preprocessor","./candlestick/candlestickVisual","./candlestick/candlestickLayout"],function(t){var e=t(Y);t("./candlestick/CandlestickSeries"),t("./candlestick/CandlestickView"),e[Qt](t("./candlestick/preprocessor")),e[Xt]("chart",t("./candlestick/candlestickVisual")),e[Yt](t("./candlestick/candlestickLayout"))}),e("echarts/chart/effectScatter/EffectScatterSeries",[ia,bt,wt],function(t){var e=t(bt),i=t(wt);return i[Lr]({type:"series.effectScatter",dependencies:["grid","polar"],getInitialData:function(t,i){var n=e(t.data,this,i);return n},defaultOption:{coordinateSystem:"cartesian2d",zlevel:0,z:2,legendHoverLink:!0,effectType:"ripple",showEffectOn:"render",rippleEffect:{period:4,scale:2.5,brushType:"fill"},xAxisIndex:0,yAxisIndex:0,polarIndex:0,geoIndex:0,symbolSize:10}})}),e("echarts/chart/helper/EffectSymbol",[ia,ta,xt,yt,gt,"./Symbol"],function(t){function e(t){return n[Dr](t)||(t=[+t,+t]),t}function i(t,e){l.call(this);var i=new s(t,e),n=new l;this.add(i),this.add(n),n.beforeUpdate=function(){this.attr(i.getScale())},this[mt](t,e)}var n=t(ta),r=t(xt),a=t(yt),o=t(gt),s=t("./Symbol"),l=a.Group,u=3,c=i[ea];return c.stopEffectAnimation=function(){this[Cn](1)[Si]()},c.startEffectAnimation=function(t,e,i,n,a,o){for(var s=this._symbolType,l=this._color,c=this[Cn](1),h=0;u>h;h++){var d=r[vt](s,-.5,-.5,1,1,l);d.attr({style:{stroke:e===br?l:null,fill:"fill"===e?l:null,strokeNoScale:!0},z2:99,silent:!0,scale:[1,1],z:a,zlevel:o});var f=-h/u*t+n;d[Vi]("",!0).when(t,{scale:[i,i]}).delay(f).start(),d.animateStyle(!0).when(t,{opacity:0}).delay(f).start(),c.add(d)}},c[ee]=function(){this[bi](Hn)},c[te]=function(){this[bi](Fn)},c[mt]=function(t,i){function n(){w[bi](Hn),p!==Mi&&this.startEffectAnimation(g,m,v,y,x,_)}function r(){w[bi](Fn),p!==Mi&&this.stopEffectAnimation()}var a=t[$t];this[Cn](0)[mt](t,i);var s=this[Cn](1),l=t[zn](i),u=t[It](i,ft),c=e(t[It](i,pt)),h=t[It](i,"color");s.attr("scale",c),s[Ti](function(t){t.attr({fill:h})});var d=l[Sr]("symbolOffset");if(d){var f=s[Tn];f[0]=o[Br](d[0],c[0]),f[1]=o[Br](d[1],c[1])}this._symbolType=u,this._color=h;var p=a.get("showEffectOn"),v=l.get("rippleEffect.scale"),m=l.get("rippleEffect.brushType"),g=1e3*l.get("rippleEffect.period"),y=i/t.count(),x=l[Sr]("z")||0,_=l[Sr](Se)||0;this.stopEffectAnimation(),p===Mi&&this.startEffectAnimation(g,m,v,y,x,_);var w=this[Cn](0);this.on(Fe,n,this).on(Ze,r,this).on(Hn,n,this).on(Fn,r,this)},c.fadeOut=function(t){t&&t()},n[Tr](i,l),i}),e("echarts/chart/effectScatter/EffectScatterView",[ia,at,"../helper/EffectSymbol",C],function(t){var e=t(at),i=t("../helper/EffectSymbol");t(C)[jt]({type:"effectScatter",init:function(){this[$]=new e(i)},render:function(t,e,i){var n=t[Nn](),r=this[$];r[mt](n),this.group.add(r.group)},updateLayout:function(){this[$][Ai]()},remove:function(t,e){this[$]&&this[$][Ii](e)}})}),e("echarts/chart/effectScatter",[ia,ta,Y,"./effectScatter/EffectScatterSeries","./effectScatter/EffectScatterView",X,j],function(t){var e=t(ta),i=t(Y);t("./effectScatter/EffectScatterSeries"),t("./effectScatter/EffectScatterView"),i[Xt]("chart",e.curry(t(X),"effectScatter",dt,null)),i[Yt](e.curry(t(j),"effectScatter"))}),e("echarts/chart/lines/LinesSeries",[ia,wt,kt,ta,At],function(t){var e=t(wt),i=t(kt),n=t(ta),r=t(At);return e[Lr]({type:"series.lines",dependencies:["grid","polar"],getInitialData:function(t,e){function a(t,e,i,n){return t.coord&&t.coord[n]}var o=[],s=[],l=[];n.each(t.data,function(t){o.push(t[0]),s.push(t[1]),l.push(n[Lr](n[Lr]({},n[Dr](t[0])?null:t[0]),n[Dr](t[1])?null:t[1]))});var u=r.get(t[tn]);if(!u)throw new Error("Invalid coordinate system");var c=u[Ht],h=new i(c,this),d=new i(c,this),f=new i(["value"],this);return h[Zt](o,null,a),d[Zt](s,null,a),f[Zt](l),this.fromData=h,this.toData=d,f},formatTooltip:function(t){var e=this.fromData[Rn](t),i=this.toData[Rn](t);return e+" > "+i},defaultOption:{coordinateSystem:"geo",zlevel:0,z:2,legendHoverLink:!0,hoverAnimation:!0,xAxisIndex:0,yAxisIndex:0,geoIndex:0,effect:{show:!1,period:4,symbol:"circle",symbolSize:3,trailLength:.2},large:!1,largeThreshold:2e3,label:{normal:{show:!1,position:"end"}},lineStyle:{normal:{opacity:.5}}}})}),e("echarts/chart/helper/EffectLine",[ia,yt,"./Line",ta,xt,"zrender/core/curve"],function(t){function e(t,e,i,n){r.Group.call(this);var o=new a(t,e,i,n);this.add(o),this._updateEffectSymbol(t,n)}function i(t,e){t.__p1=e[0],t.__p2=e[1],t.__cp1=e[2]||[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2]}function n(){var t=this.__p1,e=this.__p2,i=this.__cp1,n=this.__t,r=this[Tn],a=l[fi],o=l.quadraticDerivativeAt;r[0]=a(t[0],i[0],e[0],n),r[1]=a(t[1],i[1],e[1],n);var s=o(t[0],i[0],e[0],n),u=o(t[1],i[1],e[1],n);this[Ki]=-Math.atan2(u,s)-Math.PI/2,this[zi]=!1}var r=t(yt),a=t("./Line"),o=t(ta),s=t(xt),l=t("zrender/core/curve"),u=e[ea];return u._updateEffectSymbol=function(t,e){var r=t[zn](e),a=r[ir]("effect"),l=a.get(pt),u=a.get(ft);o[Dr](l)||(l=[l,l]);var c=a.get("color")||t[It](e,"color"),h=this[Cn](1),d=1e3*a.get("period");(this._symbolType!==u||d!==this._period)&&(h=s[vt](u,-.5,-.5,1,1,c),h[zi]=!0,h.z2=100,this._symbolType=u,this._period=d,this.add(h),h.__t=0,h[Vi]("",!0).when(d,{__t:1}).delay(e/t.count()*d/2).during(o.bind(n,h)).start()),h[qe](yr,c),h[qe](a[ht](["color"])),h.attr("scale",l);var f=t[Pt](e);i(h,f),h[_t](c),h.attr("scale",l)},u[mt]=function(t,e,i,n){this[Cn](0)[mt](t,e,i,n),this._updateEffectSymbol(t,n)},u[Ai]=function(t,e,n,r){this[Cn](0)[Ai](t,e,n,r);var a=this[Cn](1),o=t[Pt](r);i(a,o)},o[Tr](e,r.Group),e}),e("echarts/chart/lines/LinesView",[ia,"../helper/LineDraw","../helper/EffectLine","../helper/Line",C],function(t){var e=t("../helper/LineDraw"),i=t("../helper/EffectLine"),n=t("../helper/Line");t(C)[jt]({type:"lines",init:function(){},render:function(t,r,a){var o=t[Nn](),s=this._lineDraw,l=t.get("effect.show");l!==this._hasEffet&&(s&&s[Ii](),s=this._lineDraw=new e(l?i:n),this._hasEffet=l);var u=t.get(Se),c=t.get("effect.trailLength"),h=a.getZr();h.painter.getLayer(u).clear(!0),null!=this._lastZlevel&&h.configLayer(this._lastZlevel,{motionBlur:!1}),l&&c&&h.configLayer(u,{motionBlur:!0,lastFrameAlpha:Math.max(Math.min(c/10+.9,1),0)}),this.group.add(s.group),s[mt](o),this._lastZlevel=u},updateLayout:function(t,e,i){this._lineDraw[Ai]();var n=i.getZr();n.painter.getLayer(this._lastZlevel).clear(!0)},remove:function(t,e){this._lineDraw&&this._lineDraw[Ii](e,!0)}})}),e("echarts/chart/lines/linesLayout",[ia],function(t){return function(t){t[de]("lines",function(t){var e=t[tn],i=t.fromData,n=t.toData,r=t[Nn](),a=e[Ht];i.each(a,function(t,n,r){i[Dt](r,e[ot]([t,n]))}),n.each(a,function(t,i,r){n[Dt](r,e[ot]([t,i]))}),r.each(function(t){var e,a=i[Pt](t),o=n[Pt](t),s=r[zn](t).get("lineStyle.normal.curveness");s>0&&(e=[(a[0]+o[0])/2-(a[1]-o[1])*s,(a[1]+o[1])/2-(o[0]-a[0])*s]),r[Dt](t,[a,o,e])})})}}),e("echarts/chart/lines",[ia,"./lines/LinesSeries","./lines/LinesView",ta,Y,"./lines/linesLayout","../visual/seriesColor"],function(t){t("./lines/LinesSeries"),t("./lines/LinesView");var e=t(ta),i=t(Y);i[Yt](t("./lines/linesLayout")),i[Xt]("chart",e.curry(t("../visual/seriesColor"),"lines",ce))}),e("echarts/chart/heatmap/HeatmapSeries",[ia,wt,bt],function(t){var e=t(wt),i=t(bt);return e[Lr]({type:"series.heatmap",getInitialData:function(t,e){return i(t.data,this,e)},defaultOption:{coordinateSystem:"cartesian2d",zlevel:0,z:2,xAxisIndex:0,yAxisIndex:0,geoIndex:0,blurSize:30,pointSize:20}})}),e("echarts/chart/heatmap/HeatmapLayer",[ia,ta],function(t){function e(){var t=n.createCanvas();this[Xr]=t,this.blurSize=30,this.pointSize=20,this[wr]=1,this._gradientPixels={}}var i=256,n=t(ta);return e[ea]={update:function(t,e,n,r,a,o){var s=this._getBrush(),l=this._getGradient(t,a,"inRange"),u=this._getGradient(t,a,"outOfRange"),c=this.pointSize+this.blurSize,h=this[Xr],d=h[jr]("2d"),f=t[Kr];h.width=e,h[hr]=n;for(var p=0;f>p;++p){var v=t[p],m=v[0],g=v[1],y=v[2],x=r(y);d.globalAlpha=x,d.drawImage(s,m-c,g-c)}for(var _=d.getImageData(0,0,h.width,h[hr]),w=_.data,b=0,M=w[Kr];M>b;){var x=w[b+3]/256,S=4*Math.floor(x*(i-1));if(x>0){var A=o(x)?l:u;w[b++]=A[S],w[b++]=A[S+1],w[b++]=A[S+2],w[b++]*=this[wr]*A[S+3]}else b+=4}return d.putImageData(_,0,0),h},_getBrush:function(){var t=this._brushCanvas||(this._brushCanvas=n.createCanvas()),e=this.pointSize+this.blurSize,i=2*e;t.width=i,t[hr]=i;var r=t[jr]("2d");return r.clearRect(0,0,i,i),r[xr]=i,r[_r]=this.blurSize,r[yr]="#000",r[di](),r.arc(-e,e,this.pointSize,0,2*Math.PI,!0),r[li](),r.fill(),t},_getGradient:function(t,e,i){for(var n=this._gradientPixels,r=n[i]||(n[i]=new Uint8ClampedArray(1024)),a=[],o=0,s=0;256>s;s++)e[i](s/255,!0,a),r[o++]=a[0],r[o++]=a[1],r[o++]=a[2],r[o++]=a[3];return r}},e}),e("echarts/chart/heatmap/HeatmapView",[ia,yt,"./HeatmapLayer",ta,C],function(t){function e(t,e,i){var n=t[1]-t[0];e=o.map(e,function(e){return{interval:[(e[B][0]-t[0])/n,(e[B][1]-t[0])/n]}});var r=e[Kr],a=0;return function(t){for(var n=a;r>n;n++){var o=e[n][B];if(o[0]<=t&&t<=o[1]){a=n;break}}if(n===r)for(var n=a-1;n>=0;n--){var o=e[n][B];if(o[0]<=t&&t<=o[1]){a=n;break}}return n>=0&&r>n&&i[n]}}function i(t,e){var i=t[1]-t[0];return e=[(e[0]-t[0])/i,(e[1]-t[0])/i],function(t){return t>=e[0]&&t<=e[1]}}function n(t){var e=t[Ht];return"lng"===e[0]&&"lat"===e[1]}var r=t(yt),a=t("./HeatmapLayer"),o=t(ta);return t(C)[jt]({type:"heatmap",render:function(t,e,i){var r;if(e[ie]("visualMap",function(e){e.eachTargetSeries(function(i){i===t&&(r=e)})}),!r)throw new Error("Heatmap must use with visualMap");this.group[Si]();var a=t[tn];a.type===K?this._renderOnCartesian(a,t,i):n(a)&&this._renderOnGeo(a,t,r,i)},_renderOnCartesian:function(t,e,i){var n=t[et]("x"),a=t[et]("y"),o=this.group;if(n.type!==St||a.type!==St)throw new Error("Heatmap on cartesian must have two category axes");if(!n[nt]||!a[nt])throw new Error("Heatmap on cartesian must have two axes with boundaryGap true");var s=n[it](),l=a[it](),u=e[Nn]();u.each(["x","y","z"],function(i,n,a,c){var h=u[zn](c),d=t[ot]([i,n]);if(!isNaN(a)){var f=new r.Rect({shape:{x:d[0]-s/2,y:d[1]-l/2,width:s,height:l},style:{fill:u[It](c,"color")}}),p=h[ir](A)[ht](["color"]),v=h[ir](S)[ht](),m=h[ir](M),g=h[ir](b),y=e[On](c),x="-";y&&null!=y[2]&&(x=y[2]),m.get("show")&&(r[Ge](p,m),p.text=e[ct](c,Fn)||x),g.get("show")&&(r[Ge](v,g),v.text=e[ct](c,Hn)||x),f[qe](p),r[He](f,v),o.add(f),u[Lt](c,f)}})},_renderOnGeo:function(t,n,o,s){var l=o.targetVisuals.inRange,u=o.targetVisuals.outOfRange,c=n[Nn](),h=this._hmLayer||this._hmLayer||new a;h.blurSize=n.get("blurSize"),h.pointSize=n.get("pointSize");var d=t.getViewRect().clone(),f=t.getRoamTransform();d[dr](f);var p=Math.max(d.x,0),v=Math.max(d.y,0),m=Math.min(d.width+d.x,s[un]()),y=Math.min(d[hr]+d.y,s[ln]()),x=m-p,_=y-v,w=c[Ot](["lng","lat","value"],function(e,i,n){var r=t[ot]([e,i]);return r[0]-=p,r[1]-=v,r.push(n),r}),b=o[st](),M="visualMap.continuous"===o.type?i(b,o[Xn].range):e(b,o.getPieceList(),o[Xn][g]);h[on](w,x,_,l.color.getNormalizer(),{inRange:l.color.getColorMapper(),outOfRange:u.color.getColorMapper()},M);var S=new r.Image({style:{width:x,height:_,x:p,y:v,image:h[Xr]},silent:!0});this.group.add(S)}})}),e("echarts/chart/heatmap",[ia,"./heatmap/HeatmapSeries","./heatmap/HeatmapView"],function(t){t("./heatmap/HeatmapSeries"),t("./heatmap/HeatmapView")}),e("echarts/component/geo/GeoView",[ia,"../helper/MapDraw",C],function(t){var e=t("../helper/MapDraw");return t(C)[Wt]({type:"geo",init:function(t,i){var n=new e(i,!0);this._mapDraw=n,this.group.add(n.group)},render:function(t,e,i){t.get("show")&&this._mapDraw.draw(t,e,i)}})}),e("echarts/component/geo",[ia,"../coord/geo/geoCreator","./geo/GeoView","../action/geoRoam"],function(t){t("../coord/geo/geoCreator"),t("./geo/GeoView"),t("../action/geoRoam")}),e("echarts/component/title",[ia,Y,"../util/graphic","../util/layout"],function(t){var e=t(Y),i=t("../util/graphic"),n=t("../util/layout");e[Ut]({type:"title",layoutMode:{type:"box",ignoreSize:!0},defaultOption:{zlevel:0,z:6,show:!0,text:"",target:"blank",subtext:"",subtarget:"blank",left:0,top:0,backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",borderWidth:0,padding:5,itemGap:10,textStyle:{fontSize:18,fontWeight:"bolder",color:"#333"},subtextStyle:{color:"#aaa"}}}),e[Wt]({type:"title",render:function(t,e,r){if(this.group[Si](),t.get("show")){var a=this.group,o=t[ir](er),s=t[ir]("subtextStyle"),l=t.get(mi),u=new i.Text({style:{text:t.get("text"),textFont:o[$n](),fill:o[Be](),textBaseline:"top"},z2:10}),c=u[tr](),d=t.get("subtext"),f=new i.Text({style:{text:d,textFont:s[$n](),fill:s[Be](),y:c[hr]+t.get(h),textBaseline:"top"},z2:10}),v=t.get("link"),m=t.get("sublink");u[Ae]=!v,f[Ae]=!m,v&&u.on("click",function(){window.open(v,t.get(Zi))}),m&&f.on("click",function(){window.open(m,t.get("subtarget"))}),a.add(u),d&&a.add(f);var g=a[tr](),y=t[L]();y.width=g.width,y[hr]=g[hr];var x=n[bn](y,{width:r[un](),height:r[ln]()},t.get(p));l||(l=t.get("left")||t.get("right"),l===Er&&(l=Nr),"right"===l?x.x+=x.width:l===Nr&&(x.x+=x.width/2)),a[Tn]=[x.x,x.y],u[qe](mi,l),f[qe](mi,l),g=a[tr]();var _=x[wn],w=t[ht](["color",wr]);w.fill=t.get(xe);var b=new i.Rect({shape:{x:g.x-_[3],y:g.y-_[0],width:g.width+_[1]+_[3],height:g[hr]+_[0]+_[2]},style:w,silent:!0});i[Ue](b),a.add(b)}}})}),e("echarts/component/dataZoom/typeDefaulter",[ia,z],function(t){t(z)[Ln](oe,function(t){return"slider"})}),e("echarts/component/dataZoom/AxisProxy",[ia,ta,gt],function(t){function e(t,e){var i=[1/0,-(1/0)];return s(e,function(e){var n=e[Nn]();n&&s(e[k](t),function(t){var e=n[Bt](t);e[0]i[1]&&(i[1]=e[1])})},this),i}function i(t,e,i){var r=i.getAxisModel(),a=r.axis.scale,u=[0,100],c=[t.start,t.end],h=[],d=i._backup;return e=e.slice(),n(e,d,a),s(["startValue","endValue"],function(e){h.push(null!=t[e]?a.parse(t[e]):null)}),s([0,1],function(t){var i=h[t],n=c[t];null!=n||null==i?(null==n&&(n=u[t]),i=a.parse(o[Gr](n,u,e,!0))):n=o[Gr](i,e,u,!0),h[t]=i,c[t]=n}),{valueWindow:l(h),percentWindow:l(c)}}function n(t,e,i){return s(["min","max"],function(n,r){var a=e[n];null!=a&&(a+"")[zr]()!=="data"+n&&(t[r]=i.parse(a))}),e.scale||(t[0]>0&&(t[0]=0),t[1]<0&&(t[1]=0)),t}function r(t,e){var i=t.getAxisModel(),n=t._backup,r=t._percentWindow,a=t._valueWindow;if(n){var s=e||0===r[0]&&100===r[1],l=!e&&o[Rr](a,[0,500]),u=!(e||20>l&&l>=0);i.setNeedsCrossZero&&i.setNeedsCrossZero(e||s?!n.scale:!1),i.setMin&&i.setMin(e||s||u?n.min:+a[0][Vr](l)),i.setMax&&i.setMax(e||s||u?n.max:+a[1][Vr](l))}}var a=t(ta),o=t(gt),s=a.each,l=o.asc,u=function(t,e,i,n){this._dimName=t,this._axisIndex=e,this._backup,this._valueWindow,this._percentWindow,this._dataExtent,this[nr]=n,this._dataZoomModel=i};return u[ea]={constructor:u,hostedBy:function(t){return this._dataZoomModel===t},backup:function(t,e){if(t===this._dataZoomModel){var i=this.getAxisModel();this._backup={scale:i.get("scale",!0),min:i.get("min",!0),max:i.get("max",!0)}}},getDataExtent:function(){return this._dataExtent.slice()},getDataValueWindow:function(){return this._valueWindow.slice()},getDataPercentWindow:function(){return this._percentWindow.slice()},getTargetSeriesModels:function(){ -var t=[];return this[nr][he](function(e){this._axisIndex===e.get(this._dimName+"AxisIndex")&&t.push(e)},this),t},getAxisModel:function(){return this[nr][rn](this._dimName+"Axis",this._axisIndex)},getOtherAxisModel:function(){var t,e,i=this._dimName,n=this[nr],r=this.getAxisModel(),a="x"===i||"y"===i;a?(e="gridIndex",t="x"===i?"y":"x"):(e="polarIndex",t="angle"===i?jn:"angle");var o;return n[ie](t+"Axis",function(t){(t.get(e)||0)===(r.get(e)||0)&&(o=t)}),o},reset:function(t){if(t===this._dataZoomModel){var n=this._dataExtent=e(this._dimName,this.getTargetSeriesModels()),a=i(t[Xn],n,this);this._valueWindow=a.valueWindow,this._percentWindow=a.percentWindow,r(this)}},restore:function(t){t===this._dataZoomModel&&(this._valueWindow=this._percentWindow=null,r(this,!0))},filterData:function(t){function e(t){return t>=a[0]&&t<=a[1]}if(t===this._dataZoomModel){var i=this._dimName,n=this.getTargetSeriesModels(),r=t.get("filterMode"),a=this._valueWindow,o=this.getOtherAxisModel();t.get("$fromToolbox")&&o&&o.get("type")===St&&(r="empty"),s(n,function(t){var n=t[Nn]();n&&s(t[k](i),function(i){"empty"===r?t[ni](n.map(i,function(t){return e(t)?t:NaN})):n[Et](i,e)})})}}},u}),e("echarts/component/dataZoom/DataZoomModel",[ia,ta,Ve,C,Ct,"./AxisProxy",P],function(t){function e(t){var e={};return c(["start","end","startValue","endValue"],function(i){e[i]=t[i]}),e}function n(t,e,i,n){null!=i[e]&&null==i[t]&&(n[t]=null)}var r=t(ta),a=t(Ve),o=t(C),s=t(Ct),l=t("./AxisProxy"),u=t(P),c=r.each,h=s.eachAxisDim,d=o[Ut]({type:"dataZoom",dependencies:["xAxis","yAxis","zAxis","radiusAxis","angleAxis",pn],defaultOption:{zlevel:0,z:4,orient:null,xAxisIndex:null,yAxisIndex:null,angleAxisIndex:null,radiusAxisIndex:null,filterMode:"filter",throttle:100,start:0,end:100,startValue:null,endValue:null},init:function(t,n,r){this._dataIntervalByAxis={},this._dataInfo={},this._axisProxies={},this[i];var a=e(t);this[xn](t,r),this.doInit(a)},mergeOption:function(t){var i=e(t);r.merge(this[Xn],t,!0),this.doInit(i)},doInit:function(t){var e=this[Xn];a[ge]||(e.realtime=!1),n("start","startValue",t,e),n("end","endValue",t,e),this[i]=this[ir](er),this._resetTarget(),this._giveAxisProxies(),this._backup()},restoreData:function(){d[kr](this,gn,arguments),this.eachTargetAxis(function(t,e,i){i.getAxisProxy(t.name,e)[ai](i)})},_giveAxisProxies:function(){var t=this._axisProxies;this.eachTargetAxis(function(e,i,n,r){var a=this.dependentModels[e.axis][i],o=a.__dzAxisProxy||(a.__dzAxisProxy=new l(e.name,i,this,r));t[e.name+"_"+i]=o},this)},_resetTarget:function(){var t=this[Xn],e=this._judgeAutoMode();h(function(e){var i=e[Un];t[i]=s[qn](t[i])},this),e===Un?this._autoSetAxisIndex():e===f&&this._autoSetOrient()},_judgeAutoMode:function(){var t=this[Xn],e=!1;h(function(i){null!=t[i[Un]]&&(e=!0)},this);var i=t[f];return null==i&&e?f:e?void 0:(null==i&&(t[f]=An),Un)},_autoSetAxisIndex:function(){var t=!0,e=this.get(f,!0),i=this[Xn];if(t){var n=e===Sn?{dim:"y",axisIndex:"yAxisIndex",axis:"yAxis"}:{dim:"x",axisIndex:"xAxisIndex",axis:"xAxis"};this.dependentModels[n.axis][Kr]&&(i[n[Un]]=[0],t=!1)}t&&h(function(e){if(t){var n=[],r=this.dependentModels[e.axis];if(r[Kr]&&!n[Kr])for(var a=0,o=r[Kr];o>a;a++)r[a].get("type")===St&&n.push(a);i[e[Un]]=n,n[Kr]&&(t=!1)}},this),t&&this[nr][he](function(t){this._isSeriesHasAllAxesTypeOf(t,"value")&&h(function(e){var n=i[e[Un]],a=t.get(e[Un]);r[Ur](n,a)<0&&n.push(a)})},this)},_autoSetOrient:function(){var t;this.eachTargetAxis(function(e){!t&&(t=e.name)},this),this[Xn][f]="y"===t?Sn:An},_isSeriesHasAllAxesTypeOf:function(t,e){var i=!0;return h(function(n){var r=t.get(n[Un]),a=this.dependentModels[n.axis][r];a&&a.get("type")===e||(i=!1)},this),i},_backup:function(){this.eachTargetAxis(function(t,e,i,n){this.getAxisProxy(t.name,e).backup(i)},this)},getFirstTargetAxisModel:function(){var t;return h(function(e){if(null==t){var i=this.get(e[Un]);i[Kr]&&(t=this.dependentModels[e.axis][i[0]])}},this),t},eachTargetAxis:function(t,e){var i=this[nr];h(function(n){c(this.get(n[Un]),function(r){t.call(e,n,r,this,i)},this)},this)},getAxisProxy:function(t,e){return this._axisProxies[t+"_"+e]},setRawRange:function(t){c(["start","end","startValue","endValue"],function(e){this[Xn][e]=t[e]},this)},setLayoutParams:function(t){u.copyLayoutParams(this[Xn],t)},getPercentRange:function(){var t=this.findRepresentativeAxisProxy();return t?t.getDataPercentWindow():void 0},getValueRange:function(t,e){if(null!=t||null!=e)return this.getAxisProxy(t,e).getDataValueWindow();var i=this.findRepresentativeAxisProxy();return i?i.getDataValueWindow():void 0},findRepresentativeAxisProxy:function(){var t=this._axisProxies;for(var e in t)if(t.hasOwnProperty(e)&&t[e].hostedBy(this))return t[e];for(var e in t)if(t.hasOwnProperty(e)&&!t[e].hostedBy(this))return t[e]}});return d}),e("echarts/component/dataZoom/DataZoomView",[ia,"../../view/Component"],function(t){var e=t("../../view/Component");return e[Lr]({type:"dataZoom",render:function(t,e,i,n){this.dataZoomModel=t,this[nr]=e,this.api=i},getTargetInfo:function(){function t(t,e,i,n){for(var r,a=0;a=0&&f():a>=0?f():i&&(h=setTimeout(f,-a)),u=l};return p.clear=function(){h&&(clearTimeout(h),h=null)},p}var a,o,s,l=(new Date).getTime(),u=0,c=0,h=null,d=typeof t===Fr;if(e=e||0,d)return r();for(var f=[],p=0;pe[1]&&n[a](),0>t&&n[0]+t0&&n[1]+t>i[1]&&(t=i[1]-n[1]),t}return t?("rigid"===n?(t=o(t,e,i),e[0]+=t,e[1]+=t):(t=o(t,e[r],i),e[r]+=t,"push"===n&&e[0]>e[1]&&(e[1-r]=e[r])),e):e}}),e("echarts/component/dataZoom/SliderZoomView",[ia,ta,yt,"../../util/throttle","./DataZoomView",gt,P,"../helper/sliderMove"],function(t){function e(t){return"x"===t?"y":"x"}var n=t(ta),r=t(yt),o=t("../../util/throttle"),s=t("./DataZoomView"),l=r.Rect,u=t(gt),c=u[Gr],h=t(P),d=t("../helper/sliderMove"),v=u.asc,m=n.bind,g=Math.round,y=Math.max,x=n.each,_=7,w=1,b=30,M=An,S=Sn,A=5,C=["line","bar","candlestick",ae],T=s[Lr]({type:"dataZoom.slider",init:function(t,e){this._displayables={},this._orient,this._range,this._handleEnds,this._size,this._halfHandleSize,this._location,this._dragging,this._dataShadowInfo,this.api=e},render:function(t,e,i,n){return T[kr](this,Mi,arguments),o.createOrUpdate(this,"_dispatchZoomAction",this.dataZoomModel.get("throttle"),"fixRate"),this._orient=t.get(f),this._halfHandleSize=g(t.get("handleSize")/2),this.dataZoomModel.get("show")===!1?void this.group[Si]():(n&&n.type===oe&&n.from===this.uid||this._buildView(),void this._updateView())},remove:function(){T[kr](this,Ii,arguments),o.clear(this,"_dispatchZoomAction")},dispose:function(){T[kr](this,me,arguments),o.clear(this,"_dispatchZoomAction")},_buildView:function(){var t=this.group;t[Si](),this._resetLocation(),this._resetInterval();var e=this._displayables.barGroup=new r.Group;this._renderBackground(),this._renderDataShadow(),this._renderHandle(),t.add(e),this._positionGroup()},_resetLocation:function(){var t=this.dataZoomModel,e=this.api,i=this._findCoordRect(),n={width:e[un](),height:e[ln]()},r=this._orient===M?{left:i.x,top:n[hr]-b-_,width:i.width,height:b}:{right:_,top:i.y,width:b,height:i[hr]};h.mergeLayoutParam(r,t.inputPositionParams),t.setLayoutParams(r);var o=h[bn](r,n,t[p]);this._location={x:o.x,y:o.y},this._size=[o.width,o[hr]],this._orient===S&&this._size[a]()},_positionGroup:function(){var t=this.group,e=this._location,i=this._orient,n=this.dataZoomModel.getFirstTargetAxisModel(),r=n&&n.get(tt),a=this._displayables.barGroup,o=(this._dataShadowInfo||{}).otherAxisInverse;a.attr(i!==M||r?i===M&&r?{scale:o?[-1,1]:[-1,-1]}:i!==S||r?{scale:o?[-1,-1]:[-1,1],rotation:Math.PI/2}:{scale:o?[1,-1]:[1,1],rotation:Math.PI/2}:{scale:o?[1,1]:[1,-1]});var s=t[tr]([a]);t[Tn][0]=e.x-s.x,t[Tn][1]=e.y-s.y},_getViewExtent:function(){var t=this._halfHandleSize,e=y(this._size[0],4*t),i=[t,e-t];return i},_renderBackground:function(){var t=this.dataZoomModel,e=this._size;this._displayables.barGroup.add(new l({silent:!0,shape:{x:0,y:0,width:e[0],height:e[1]},style:{fill:t.get(xe)}}))},_renderDataShadow:function(){var t=this._dataShadowInfo=this._prepareDataShadowInfo();if(t){var e=this._size,i=t[pn],n=i.getRawData(),a=i.getShadowDim?i.getShadowDim():t.otherDim,o=n[Bt](a),s=.3*(o[1]-o[0]);o=[o[0]-s,o[1]+s];var l=[0,e[1]],u=[0,e[0]],h=[[e[0],0],[0,0]],d=u[1]/(n.count()-1),f=0,p=Math.round(n.count()/e[0]);n.each([a],function(t,e){if(p>0&&e%p)return void(f+=d);var i=null==t||isNaN(t)||""===t?null:c(t,o,l,!0);null!=i&&h.push([f,i]),f+=d}),this._displayables.barGroup.add(new r[Xe]({shape:{points:h},style:{fill:this.dataZoomModel.get("dataBackgroundColor"),lineWidth:0},silent:!0,z2:-20}))}},_prepareDataShadowInfo:function(){var t=this.dataZoomModel,i=t.get("showDataShadow");if(i!==!1){var r,a=this[nr];return t.eachTargetAxis(function(o,s){var l=t.getAxisProxy(o.name,s).getTargetSeriesModels();n.each(l,function(t){if(!(r||i!==!0&&n[Ur](C,t.get("type"))<0)){var l=e(o.name),u=a[rn](o.axis,s).axis;r={thisAxis:u,series:t,thisDim:o.name,otherDim:l,otherAxisInverse:t[tn][lt](u)[tt]}}},this)},this),r}},_renderHandle:function(){var t=this._displayables,e=t.handles=[],n=t.handleLabels=[],a=this._displayables.barGroup,o=this._size;a.add(t.filler=new l({draggable:!0,cursor:"move",drift:m(this._onDragMove,this,"all"),ondragend:m(this._onDragEnd,this),onmouseover:m(this._showDataInfo,this,!0),onmouseout:m(this._showDataInfo,this,!1),style:{fill:this.dataZoomModel.get("fillerColor"),textPosition:"inside"}})),a.add(new l(r[Ue]({silent:!0,shape:{x:0,y:0,width:o[0],height:o[1]},style:{stroke:this.dataZoomModel.get("dataBackgroundColor"),lineWidth:w,fill:"rgba(0,0,0,0)"}}))),x([0,1],function(t){a.add(e[t]=new l({style:{fill:this.dataZoomModel.get("handleColor")},cursor:"move",draggable:!0,drift:m(this._onDragMove,this,t),ondragend:m(this._onDragEnd,this),onmouseover:m(this._showDataInfo,this,!0),onmouseout:m(this._showDataInfo,this,!1)}));var o=this.dataZoomModel[i];this.group.add(n[t]=new r.Text({silent:!0,invisible:!0,style:{x:0,y:0,text:"",textBaseline:"middle",textAlign:"center",fill:o[Be](),textFont:o[$n]()}}))},this)},_resetInterval:function(){var t=this._range=this.dataZoomModel.getPercentRange(),e=this._getViewExtent();this._handleEnds=[c(t[0],[0,100],e,!0),c(t[1],[0,100],e,!0)]},_updateInterval:function(t,e){var i=this._handleEnds,n=this._getViewExtent();d(e,i,n,"all"===t||this.dataZoomModel.get("zoomLock")?"rigid":"cross",t),this._range=v([c(i[0],n,[0,100],!0),c(i[1],n,[0,100],!0)])},_updateView:function(){var t=this._displayables,e=this._handleEnds,i=v(e.slice()),n=this._size,r=this._halfHandleSize;x([0,1],function(i){var a=t.handles[i];a[ri]({x:e[i]-r,y:-1,width:2*r,height:n[1]+2,r:1})},this),t.filler[ri]({x:i[0],y:0,width:i[1]-i[0],height:this._size[1]}),this._updateDataInfo()},_updateDataInfo:function(){function t(t){var e=r.getTransform(i.handles[t],this.group),s=r.transformDirection(0===t?"right":"left",e),l=this._halfHandleSize+A,c=r[dr]([u[t]+(0===t?-l:l),this._size[1]/2],e);n[t][qe]({x:c[0],y:c[1],textBaseline:a===M?Er:s,textAlign:a===M?s:Nr,text:o[t]})}var e=this.dataZoomModel,i=this._displayables,n=i.handleLabels,a=this._orient,o=["",""];if(e.get("showDetail")){var s,l;e.eachTargetAxis(function(t,i){s||(s=e.getAxisProxy(t.name,i).getDataValueWindow(),l=this[nr][rn](t.axis,i).axis)},this),s&&(o=[this._formatLabel(s[0],l),this._formatLabel(s[1],l)])}var u=v(this._handleEnds.slice());t.call(this,0),t.call(this,1)},_formatLabel:function(t,e){var i=this.dataZoomModel,r=i.get("labelFormatter");if(n[Ni](r))return r(t);var a=i.get("labelPrecision");return(null==a||"auto"===a)&&(a=e[Rr]()),t=null==t&&isNaN(t)?"":e.type===St||"time"===e.type?e.scale[H](Math.round(t)):t[Vr](Math.min(a,20)),n[dn](r)&&(t=r[Zr]("{value}",t)),t},_showDataInfo:function(t){t=this._dragging||t;var e=this._displayables.handleLabels;e[0].attr(Ci,!t),e[1].attr(Ci,!t)},_onDragMove:function(t,e,i){this._dragging=!0;var n=this._applyBarTransform([e,i],!0);this._updateInterval(t,n[0]),this._updateView(),this.dataZoomModel.get("realtime")&&this._dispatchZoomAction()},_onDragEnd:function(){this._dragging=!1,this._showDataInfo(!1),this._dispatchZoomAction()},_dispatchZoomAction:function(){var t=this._range;this.api[sn]({type:"dataZoom",from:this.uid,dataZoomId:this.dataZoomModel.id,start:t[0],end:t[1]})},_applyBarTransform:function(t,e){var i=this._displayables.barGroup[qi]();return r[dr](t,i,e)},_findCoordRect:function(){var t,e=this.getTargetInfo();if(e.cartesians[Kr])t=e.cartesians[0].model[tn][I]();else{var i=this.api[un](),n=this.api[ln]();t={x:.2*i,y:.2*n,width:.6*i,height:.6*n}}return t}});return T}),e("echarts/component/dataZoom/InsideZoomModel",[ia,"./DataZoomModel"],function(t){return t("./DataZoomModel")[Lr]({type:"dataZoom.inside",defaultOption:{zoomLock:!1}})}),e("echarts/component/dataZoom/roams",[ia,ta,"../../component/helper/RoamController","../../util/throttle"],function(t){function e(t){var e=t.getZr();return e[f]||(e[f]={})}function i(t,e,i){var n=new c(t.getZr());return n[l](),n.on("pan",d(r,i)),n.on("zoom",d(a,i)),n.rect=e[tn][I]().clone(),n}function n(t){u.each(t,function(e,i){e.count||(e.controller.off("pan").off("zoom"),delete t[i])})}function r(t,e,i){o(t,function(n){return n.panGetRange(t.controller,e,i)})}function a(t,e,i,n){o(t,function(r){return r.zoomGetRange(t.controller,e,i,n)})}function o(t,e){var i=[];u.each(t.dataZoomInfos,function(t){var n=e(t);n&&i.push({dataZoomId:t.dataZoomId,start:n[0],end:n[1]})}),t[sn](i)}function s(t,e){t[sn]({type:"dataZoom",batch:e})}var u=t(ta),c=t("../../component/helper/RoamController"),h=t("../../util/throttle"),d=u.curry,f="\x00_ec_dataZoom_roams",p={register:function(t,r){var a=e(t),o=r.dataZoomId,l=r.coordType+"\x00_"+r.coordId;u.each(a,function(t,e){var i=t.dataZoomInfos;i[o]&&e!==l&&(delete i[o],t.count--)}),n(a);var c=a[l];c||(c=a[l]={coordId:l,dataZoomInfos:{},count:0},c.controller=i(t,r,c),c[sn]=u.curry(s,t)),c&&(h.createOrUpdate(c,sn,r.throttleRate,"fixRate"),!c.dataZoomInfos[o]&&c.count++,c.dataZoomInfos[o]=r)},unregister:function(t,i){var r=e(t);u.each(r,function(t,e){var n=t.dataZoomInfos;n[i]&&(delete n[i],t.count--)}),n(r)},shouldRecordRange:function(t,e){if(t&&t.type===oe&&t.batch)for(var i=0,n=t.batch[Kr];n>i;i++)if(t.batch[i].dataZoomId===e)return!1;return!0}};return p}),e("echarts/component/dataZoom/InsideZoomView",[ia,"./DataZoomView",ta,"../helper/sliderMove","./roams"],function(t){function e(t,e,i,r){e=e.slice();var a=r.axisModels[0];if(a){var o=n(t,a,i),l=o.signal*(e[1]-e[0])*o.pixel/o.pixelLength;return s(l,e,[0,100],"rigid"),e}}function i(t,e,i,a,o,s){i=i.slice();var l=o.axisModels[0];if(l){var u=n(e,l,a),c=u.pixel-u.pixelStart,h=c/u.pixelLength*(i[1]-i[0])+i[0];return t=Math.max(t,0),i[0]=(i[0]-h)*t+h,i[1]=(i[1]-h)*t+h,r(i)}}function n(t,e,i){var n=e.axis,r=i.rect,a={};return"x"===n.dim?(a.pixel=t[0],a.pixelLength=r.width,a.pixelStart=r.x,a.signal=n[tt]?1:-1):(a.pixel=t[1],a.pixelLength=r[hr],a.pixelStart=r.y,a.signal=n[tt]?-1:1),a}function r(t){var e=[0,100];return!(t[0]<=e[1])&&(t[0]=e[1]),!(t[1]<=e[1])&&(t[1]=e[1]),!(t[0]>=e[0])&&(t[0]=e[0]),!(t[1]>=e[0])&&(t[1]=e[0]),t}var a=t("./DataZoomView"),o=t(ta),s=t("../helper/sliderMove"),l=t("./roams"),u=o.bind,c=a[Lr]({type:"dataZoom.inside",init:function(t,e){this._range},render:function(t,e,i,n){c[kr](this,Mi,arguments),l.shouldRecordRange(n,t.id)&&(this._range=t.getPercentRange()),o.each(this.getTargetInfo().cartesians,function(e){var n=e.model;l[an](i,{coordId:n.id,coordType:n.type,coordinateSystem:n[tn],dataZoomId:t.id,throttleRage:t.get("throttle",!0),panGetRange:u(this._onPan,this,e),zoomGetRange:u(this._onZoom,this,e)})},this)},remove:function(){l.unregister(this.api,this.dataZoomModel.id),c[kr](this,Ii,arguments),this._range=null},dispose:function(){l.unregister(this.api,this.dataZoomModel.id),c[kr](this,me,arguments),this._range=null},_onPan:function(t,i,n,r){return this._range=e([n,r],this._range,i,t)},_onZoom:function(t,e,n,r,a){var o=this.dataZoomModel;if(!o[Xn].zoomLock)return this._range=i(1/n,[r,a],this._range,e,t,o)}});return c}),e("echarts/component/dataZoom/dataZoomProcessor",[ia,C],function(t){function e(t,e,i){i.getAxisProxy(t.name,e).reset(i)}function i(t,e,i){i.getAxisProxy(t.name,e).filterData(i)}var n=t(C);n[Jt]($r,function(t,n){t[ie](oe,function(t){t.eachTargetAxis(e),t.eachTargetAxis(i)}),t[ie](oe,function(t){var e=t.findRepresentativeAxisProxy(),i=e.getDataPercentWindow(),n=e.getDataValueWindow();t.setRawRange({start:i[0],end:i[1],startValue:n[0],endValue:n[1]})})})}),e("echarts/component/dataZoom/dataZoomAction",[ia,ta,Ct,C],function(t){var e=t(ta),i=t(Ct),n=t(C);n[Kt](oe,function(t,n){var r=i.createLinkedNodesFinder(e.bind(n[ie],n,oe),i.eachAxisDim,function(t,e){return t.get(e[Un])}),a=[];n[ie]({mainType:"dataZoom",query:t},function(t,e){a.push.apply(a,r(t).nodes)}),e.each(a,function(e,i){e.setRawRange({start:t.start,end:t.end,startValue:t.startValue,endValue:t.endValue})})})}),e("echarts/component/dataZoom",[ia,"./dataZoom/typeDefaulter","./dataZoom/DataZoomModel","./dataZoom/DataZoomView","./dataZoom/SliderZoomModel","./dataZoom/SliderZoomView","./dataZoom/InsideZoomModel","./dataZoom/InsideZoomView","./dataZoom/dataZoomProcessor","./dataZoom/dataZoomAction"],function(t){t("./dataZoom/typeDefaulter"),t("./dataZoom/DataZoomModel"),t("./dataZoom/DataZoomView"),t("./dataZoom/SliderZoomModel"),t("./dataZoom/SliderZoomView"),t("./dataZoom/InsideZoomModel"),t("./dataZoom/InsideZoomView"),t("./dataZoom/dataZoomProcessor"),t("./dataZoom/dataZoomAction")}),e("echarts/component/visualMap/preprocessor",[ia,ta],function(t){function e(t,e){return t&&t.hasOwnProperty&&t.hasOwnProperty(e)}var i=t(ta),n=i.each;return function(t){var r=t&&t.visualMap;i[Dr](r)||(r=r?[r]:[]),n(r,function(t){if(t){e(t,"splitList")&&!e(t,"pieces")&&(t.pieces=t.splitList,delete t.splitList);var r=t.pieces;r&&i[Dr](r)&&n(r,function(t){i[In](t)&&(e(t,"start")&&!e(t,"min")&&(t.min=t.start),e(t,"end")&&!e(t,"max")&&(t.max=t.end))})}})}}),e("echarts/component/visualMap/typeDefaulter",[ia,z],function(t){t(z)[Ln]("visualMap",function(t){return t[r]||(t.pieces?t.pieces[Kr]>0:t[G]>0)&&!t.calculable?"piecewise":"continuous"})}),e("echarts/component/visualMap/visualCoding",[ia,C,n,ta],function(t){function e(t,e){var i=t.targetVisuals,n={};a.each(["inRange","outOfRange"],function(t){var e=r.prepareVisualTypes(i[t]);n[t]=e}),t.eachTargetSeries(function(e){function r(t){return s[It](o,t)}function a(t,e){s[fe](o,t,e)}var o,s=e[Nn](),l=t.getDataDimension(s);s.each([l],function(e,s){o=s;for(var l=t.getValueState(e),u=i[l],c=n[l],h=0,d=c[Kr];d>h;h++){var f=c[h];u[f]&&u[f].applyVisual(e,r,a)}})})}var i=t(C),r=t(n),a=t(ta);i[Xt]("component",function(t){t[ie]("visualMap",function(i){e(i,t)})})}),e("echarts/visual/visualDefault",[ia,ta],function(t){var e=t(ta),i={get:function(t,i,r){var a=e.clone((n[t]||{})[i]);return r&&e[Dr](a)?a[a[Kr]-1]:a}},n={color:{active:["#006edd","#e0ffff"],inactive:["rgba(0,0,0,0)"]},colorHue:{active:[0,360],inactive:[0,0]},colorSaturation:{active:[.3,1],inactive:[0,0]},colorLightness:{active:[.9,.5],inactive:[0,0]},colorAlpha:{active:[.3,1],inactive:[0,0]},symbol:{active:[dt,"roundRect","diamond"],inactive:["none"]},symbolSize:{active:[10,50],inactive:[0,0]}};return i}),e("echarts/component/visualMap/VisualMapModel",[ia,ta,Ve,C,Ct,"../../visual/visualDefault",n,gt],function(t){var e=t(ta),o=t(Ve),s=t(C),l=t(Ct),u=t("../../visual/visualDefault"),c=t(n),h=c.mapVisual,d=c.eachVisual,f=t(gt),p=e[Dr],v=e.each,m=f.asc,g=f[Gr],y=s[Ut]({type:"visualMap",dependencies:[pn],dataBound:[-(1/0),1/0],stateList:["inRange","outOfRange"],layoutMode:{type:"box",ignoreSize:!0},defaultOption:{show:!0,zlevel:0,z:4,min:0,max:200,dimension:null,inRange:null,outOfRange:null,left:0,right:null,top:null,bottom:0,itemWidth:null,itemHeight:null,inverse:!1,orient:"vertical",seriesIndex:null,backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",contentColor:"#5793f3",inactiveColor:"#aaa",borderWidth:0,padding:5,textGap:10,precision:0,color:["#bf444c","#d88273","#f6efa6"],formatter:null,text:null,textStyle:{color:"#333"}},init:function(t,e,n){this._autoSeriesIndex=!1,this._dataExtent,this.controllerVisuals={},this.targetVisuals={},this[i],this.itemSize,this[xn](t,n),this.doMergeOption({},!0)},mergeOption:function(t){y[kr](this,mn,arguments),this.doMergeOption(t,!1)},doMergeOption:function(t,e){var n=this[Xn];o[ge]||(n.realtime=!1),this[i]=this[ir](er),this.resetItemSize(),this.completeVisualOption()},formatValueText:function(t,i){function n(t){return t===l[0]?"min":t===l[1]?"max":(+t)[Vr](s)}var r,a,o=this[Xn],s=o.precision,l=this.dataBound,u=o[Dn];return e[Dr](t)&&(t=t.slice(),r=!0),a=i?t:r?[n(t[0]),n(t[1])]:n(t),e[dn](u)?u[Zr]("{value}",r?a[0]:a)[Zr]("{value2}",r?a[1]:a):e[Ni](u)?r?u(t[0],t[1]):u(t):r?t[0]===l[0]?"< "+a[1]:t[1]===l[1]?"> "+a[0]:a[0]+" - "+a[1]:a},resetTargetSeries:function(t,e){var i=this[Xn],n=this._autoSeriesIndex=null==(e?i:t)[Bn];i[Bn]=n?[]:l[qn](i[Bn]),n&&this[nr][he](function(t,e){var n=t[Nn]();"list"===n.type&&i[Bn].push(e)})},resetExtent:function(){var t=this[Xn],e=m([t.min,t.max]);this._dataExtent=e},getDataDimension:function(t){var e=this[Xn].dimension;return null!=e?e:t[Ht][Kr]-1},getExtent:function(){return this._dataExtent.slice()},resetVisual:function(t){function e(e,n){v(this.stateList,function(r){var a=n[r]||(n[r]={}),o=this[Xn][e][r]||{};v(o,function(e,n){if(c.isValidType(n)){var o={type:n,dataExtent:i,visual:e};t&&t.call(this,o,r),a[n]=new c(o)}},this)},this)}var i=this[st]();e.call(this,"controller",this.controllerVisuals),e.call(this,Zi,this.targetVisuals)},completeVisualOption:function(){function t(t){p(r.color)&&!t.inRange&&(t.inRange={color:r.color.slice()[a]()}),v(this.stateList,function(i){var n=t[i];if(e[dn](n)){var r=u.get(n,"active",f);r?(t[i]={},t[i][n]=r):delete t[i]}},this)}function i(t,e,i){var n=t[e],r=t[i];n&&!r&&(r=t[i]={},v(n,function(t,e){var i=u.get(e,"inactive",f);c.isValidType(e)&&i&&(r[e]=i)}))}function n(t){var i=(t.inRange||{})[ft]||(t.outOfRange||{})[ft],n=(t.inRange||{})[pt]||(t.outOfRange||{})[pt],r=this.get("inactiveColor");v(this.stateList,function(a){var o=this.itemSize,s=t[a];s||(s=t[a]={color:f?r:[r]}),s[ft]||(s[ft]=i&&e.clone(i)||(f?"roundRect":["roundRect"])),s[pt]||(s[pt]=n&&e.clone(n)||(f?o[0]:[o[0],o[0]])),s[ft]=h(s[ft],function(t){return"none"===t||"square"===t?"roundRect":t});var l=s[pt];if(l){var u=-(1/0);d(l,function(t){t>u&&(u=t)}),s[pt]=h(l,function(t){return g(t,[0,u],[0,o[0]],!0)})}},this)}var r=this[Xn],o={inRange:r.inRange,outOfRange:r.outOfRange},s=r[Zi]||(r[Zi]={}),l=r.controller||(r.controller={});e.merge(s,o),e.merge(l,o);var f=this.isCategory();t.call(this,s),t.call(this,l),i.call(this,s,"inRange","outOfRange"),i.call(this,s,"outOfRange","inRange"),n.call(this,l)},eachTargetSeries:function(t,i){e.each(this[Xn][Bn],function(e){t.call(i,this[nr].getSeriesByIndex(e))},this)},isCategory:function(){return!!this[Xn][r]},resetItemSize:function(){this.itemSize=[parseFloat(this.get("itemWidth")),parseFloat(this.get("itemHeight"))]},setSelected:e.noop,getValueState:e.noop});return y}),e("echarts/component/visualMap/ContinuousModel",[ia,"./VisualMapModel",ta,gt],function(t){var e=t("./VisualMapModel"),i=t(ta),n=t(gt),r=[20,140],o=e[Lr]({type:"visualMap.continuous",defaultOption:{handlePosition:"auto",calculable:!1,range:[-(1/0),1/0],hoverLink:!0,realtime:!0,itemWidth:null,itemHeight:null},doMergeOption:function(t,e){o[kr](this,"doMergeOption",arguments),this.resetTargetSeries(t,e),this.resetExtent(),this.resetVisual(function(t){t.mappingMethod=Ei}),this._resetRange()},resetItemSize:function(){e[ea].resetItemSize.apply(this,arguments);var t=this.itemSize;this._orient===An&&t[a](),(null==t[0]||isNaN(t[0]))&&(t[0]=r[0]),(null==t[1]||isNaN(t[1]))&&(t[1]=r[1])},_resetRange:function(){var t=this[st](),e=this[Xn].range;e[0]>e[1]&&e[a](),e[0]=Math.max(e[0],t[0]),e[1]=Math.min(e[1],t[1])},completeVisualOption:function(){e[ea].completeVisualOption.apply(this,arguments),i.each(this.stateList,function(t){var e=this[Xn].controller[t][pt];e&&e[0]!==e[1]&&(e[0]=0)},this)},setSelected:function(t){this[Xn].range=t.slice(),this._resetRange()},getSelected:function(){var t=this[st](),e=n.asc((this.get("range")||[]).slice());return e[0]>t[1]&&(e[0]=t[1]),e[1]>t[1]&&(e[1]=t[1]),e[0]=i[1]||t<=e[1])?"inRange":"outOfRange"}});return o}),e("echarts/component/visualMap/VisualMapView",[ia,C,ta,yt,v,P,n],function(t){var e=t(C),i=t(ta),r=t(yt),a=t(v),o=t(P),s=t(n);return e[Wt]({type:"visualMap",autoPositionValues:{left:1,right:1,top:1,bottom:1},init:function(t,e){this[nr]=t,this.api=e,this.visualMapModel,this._updatableShapes={}},render:function(t,e,i,n){return this.visualMapModel=t,t.get("show")===!1?void this.group[Si]():void this.doRender.apply(this,arguments)},renderBackground:function(t){var e=this.visualMapModel,i=a[Mn](e.get(p)||0),n=t[tr]();t.add(new r.Rect({z2:-1,silent:!0,shape:{x:n.x-i[3],y:n.y-i[0],width:n.width+i[3]+i[1],height:n[hr]+i[0]+i[2]},style:{fill:e.get(xe),stroke:e.get(Jn),lineWidth:e.get(Kn)}}))},getControllerVisual:function(t,e,n){function r(t){return h[t]}function a(t,e){h[t]=e}var o=this.visualMapModel,l=i[Dr](t);if(l&&(!e||"color"!==n))throw new Error(t);var u=o.controllerVisuals[e||o.getValueState(t)],c=o.get("contentColor"),h={symbol:o.get("itemSymbol"),color:l?[{color:c,offset:0},{color:c,offset:1}]:c},d=s.prepareVisualTypes(u);return i.each(d,function(e){var i=u[e];(!n||s.isInVisualCluster(e,n))&&i&&i.applyVisual(t,r,a)}),h},positionGroup:function(t){var e=this.visualMapModel,i=this.api;o[_n](t,e[L](),{width:i[un](),height:i[ln]()})},doRender:i.noop})}),e("echarts/component/visualMap/helper",[ia,P],function(t){var e=t(P),i={getItemAlign:function(t,i,n){var r=t[Xn],a=r.align;if(null!=a&&"auto"!==a)return a;for(var o={width:i[un](),height:i[ln]()},s=r[f]===An?1:0,l=[["left","right","width"],["top",Or,hr]],u=l[s],c=[0,null,10],h={},d=0;3>d;d++)h[l[1-s][d]]=c[d],h[u[d]]=2===d?n[0]:r[u[d]];var v=[["x","width",3],["y",hr,0]][s],m=e[bn](h,o,r[p]);return u[(m[wn][v[2]]||0)+m[v[0]]+.5*m[v[1]]<.5*o[v[1]]?0:1]}};return i}),e("echarts/component/visualMap/ContinuousView",[ia,"./VisualMapView",yt,ta,gt,"../helper/sliderMove","zrender/graphic/LinearGradient","./helper"],function(t){function e(t,e,i){return new a[Ye]({shape:{points:t},draggable:!!e,cursor:i,drift:e})}function n(t,e){return 0===t?[[0,0],[e,0],[e,-e]]:[[0,0],[e,0],[e,e]]}var r=t("./VisualMapView"),a=t(yt),o=t(ta),s=t(gt),l=t("../helper/sliderMove"),u=s[Gr],c=t("zrender/graphic/LinearGradient"),h=t("./helper"),d=o.each,p=r[Lr]({type:"visualMap.continuous",init:function(){r[ea].init.apply(this,arguments),this._shapes={},this._dataInterval=[],this._handleEnds=[],this._orient,this._useHandle},doRender:function(t,e,i,n){n&&"selectDataRange"===n.type&&n.from===this.uid?this._updateView():this._buildView()},_buildView:function(){this.group[Si]();var t=this.visualMapModel,e=this.group;this._orient=t.get(f),this._useHandle=t.get("calculable"),this._resetInterval(),this._renderBar(e);var i=t.get("text");this._renderEndsText(e,i,0),this._renderEndsText(e,i,1),this._updateView(!0),this.renderBackground(e),this._updateView(),this[_n](e)},_renderEndsText:function(t,e,n){if(e){var r=e[1-n];r=null!=r?r+"":"";var o=this.visualMapModel,s=o.get("textGap"),l=o.itemSize,u=this._shapes.barGroup,c=this._applyTransform([l[0]/2,0===n?-s:l[1]+s],u),h=this._applyTransform(0===n?Or:"top",u),d=this._orient,f=this.visualMapModel[i];this.group.add(new a.Text({style:{x:c[0],y:c[1],textBaseline:d===An?Er:h,textAlign:d===An?h:Nr,text:r,textFont:f[$n](),fill:f[Be]()}}))}},_renderBar:function(t){var n=this.visualMapModel,r=this._shapes,a=n.itemSize,s=this._orient,l=this._useHandle,u=h.getItemAlign(n,this.api,a),c=r.barGroup=this._createBarGroup(u);c.add(r.outOfRange=e()),c.add(r.inRange=e(null,o.bind(this._modifyHandle,this,"all"),l?"move":null));var d=n[i].getTextRect("国"),f=Math.max(d.width,d[hr]);l&&(r.handleGroups=[],r.handleThumbs=[],r.handleLabels=[],r.handleLabelPoints=[],this._createHandle(c,0,a,f,s,u),this._createHandle(c,1,a,f,s,u)),t.add(c)},_createHandle:function(t,r,s,l,u){var c=new a.Group({position:[s[0],0]}),h=e(n(r,l),o.bind(this._modifyHandle,this,r),"move");c.add(h);var d={x:u===An?l/2:1.5*l,y:u===An?0===r?-(1.5*l):1.5*l:0===r?-l/2:l/2},f=this.visualMapModel[i],p=new a.Text({silent:!0,style:{x:0,y:0,text:"",textBaseline:"middle",textFont:f[$n](),fill:f[Be]()}});this.group.add(p);var v=this._shapes;v.handleThumbs[r]=h,v.handleGroups[r]=c,v.handleLabelPoints[r]=d,v.handleLabels[r]=p,t.add(c)},_modifyHandle:function(t,e,i){if(this._useHandle){var n=this._applyTransform([e,i],this._shapes.barGroup,!0);this._updateInterval(t,n[1]),this.api[sn]({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:this._dataInterval.slice()})}},_resetInterval:function(){var t=this.visualMapModel,e=this._dataInterval=t.getSelected(),i=t[st](),n=[0,t.itemSize[1]];this._handleEnds=[u(e[0],i,n,!0),u(e[1],i,n,!0)]},_updateInterval:function(t,e){e=e||0;var i=this.visualMapModel,n=this._handleEnds;l(e,n,[0,i.itemSize[1]],"all"===t?"rigid":"push",t);var r=i[st](),a=[0,i.itemSize[1]];this._dataInterval=[u(n[0],a,r,!0),u(n[1],a,r,!0)]},_updateView:function(t){var e=this.visualMapModel,i=e[st](),n=this._shapes,r=this._dataInterval,a=[0,e.itemSize[1]],o=t?a:this._handleEnds,s=this._createBarVisual(r,i,o,"inRange"),l=this._createBarVisual(i,i,a,"outOfRange");n.inRange[qe]("fill",s.barColor)[ri]($e,s.barPoints),n.outOfRange[qe]("fill",l.barColor)[ri]($e,l.barPoints),this._useHandle&&d([0,1],function(t){n.handleThumbs[t][qe]("fill",s.handlesColor[t]),n.handleLabels[t][qe]({text:e.formatValueText(r[t]),textAlign:this._applyTransform(this._orient===An?0===t?Or:"top":"left",n.barGroup)})},this),this._updateHandlePosition(o)},_createBarVisual:function(t,e,i,n){var r=this.getControllerVisual(t,n,"color").color,a=[this.getControllerVisual(t[0],n,pt)[pt],this.getControllerVisual(t[1],n,pt)[pt]],o=this._createBarPoints(i,a); -return{barColor:new c(0,0,1,1,r),barPoints:o,handlesColor:[r[0].color,r[r[Kr]-1].color]}},_createBarPoints:function(t,e){var i=this.visualMapModel.itemSize;return[[i[0]-e[0],t[0]],[i[0],t[0]],[i[0],t[1]],[i[0]-e[1],t[1]]]},_createBarGroup:function(t){var e=this._orient,i=this.visualMapModel.get(tt);return new a.Group(e!==An||i?e===An&&i?{scale:t===Or?[-1,1]:[1,1],rotation:-Math.PI/2}:e!==Sn||i?{scale:"left"===t?[1,1]:[-1,1]}:{scale:"left"===t?[1,-1]:[-1,-1]}:{scale:t===Or?[1,1]:[-1,1],rotation:Math.PI/2})},_updateHandlePosition:function(t){if(this._useHandle){var e=this._shapes;d([0,1],function(i){var n=e.handleGroups[i];n[Tn][1]=t[i];var r=e.handleLabelPoints[i],o=a[dr]([r.x,r.y],a.getTransform(n,this.group));e.handleLabels[i][qe]({x:o[0],y:o[1]})},this)}},_applyTransform:function(t,e,i){var n=a.getTransform(e,this.group);return a[o[Dr](t)?dr:"transformDirection"](t,n,i)}});return p}),e("echarts/component/visualMap/visualMapAction",[ia,C],function(t){var e=t(C),i={type:"selectDataRange",event:"dataRangeSelected",update:"update"};e[Kt](i,function(t,e){e[ie]({mainType:"visualMap",query:t},function(e){e.setSelected(t[g])})})}),e("echarts/component/visualMapContinuous",[ia,Y,"./visualMap/preprocessor","./visualMap/typeDefaulter","./visualMap/visualCoding","./visualMap/ContinuousModel","./visualMap/ContinuousView","./visualMap/visualMapAction"],function(t){t(Y)[Qt](t("./visualMap/preprocessor")),t("./visualMap/typeDefaulter"),t("./visualMap/visualCoding"),t("./visualMap/ContinuousModel"),t("./visualMap/ContinuousView"),t("./visualMap/visualMapAction")}),e("echarts/component/visualMap/PiecewiseModel",[ia,"./VisualMapModel",ta,n],function(t){function e(t,e){var i=t[tt];(t[f]===Sn?!i:i)&&e[a]()}var i=t("./VisualMapModel"),o=t(ta),s=t(n),l=i[Lr]({type:"visualMap.piecewise",defaultOption:{selected:null,align:"auto",itemWidth:20,itemHeight:14,itemSymbol:"roundRect",pieceList:null,categories:null,splitNumber:5,selectedMode:"multiple",itemGap:10},doMergeOption:function(t,e){l[kr](this,"doMergeOption",arguments),this._pieceList=[],this.resetTargetSeries(t,e),this.resetExtent();var i=this._mode=this._decideMode();u[this._mode].call(this),this._resetSelected(t,e);var n=this[Xn][r];this.resetVisual(function(t,e){i===r?(t.mappingMethod=St,t[r]=o.clone(n)):(t.mappingMethod="piecewise",t.pieceList=o.map(this._pieceList,function(t){var t=o.clone(t);return"inRange"!==e&&(t.visual=null),t}))})},_resetSelected:function(t,e){var i=this[Xn],n=this._pieceList,r=(e?i:t)[g]||{};if(i[g]=r,o.each(n,function(t,e){var i=this.getSelectedMapKey(t);i in r||(r[i]=!0)},this),i[x]===y){var a=!1;o.each(n,function(t,e){var i=this.getSelectedMapKey(t);r[i]&&(a?r[i]=!1:a=!0)},this)}},getSelectedMapKey:function(t){return this._mode===r?t.value+"":t.index+""},getPieceList:function(){return this._pieceList},_decideMode:function(){var t=this[Xn];return t.pieces&&t.pieces[Kr]>0?"pieces":this[Xn][r]?r:G},setSelected:function(t){this[Xn][g]=o.clone(t)},getValueState:function(t){var e=this._pieceList,i=s.findPieceIndex(t,e);return null!=i&&this[Xn][g][this.getSelectedMapKey(e[i])]?"inRange":"outOfRange"}}),u={splitNumber:function(){var t=this[Xn],e=t.precision,i=this[st](),n=t[G];n=Math.max(parseInt(n,10),1),t[G]=n;for(var r=(i[1]-i[0])/n;+r[Vr](e)!==r&&5>e;)e++;t.precision=e,r=+r[Vr](e);for(var a=0,o=i[0];n>a;a++,o+=r){var s=a===n-1?i[1]:o+r;this._pieceList.push({text:this.formatValueText([o,s]),index:a,interval:[o,s]})}},categories:function(){var t=this[Xn];o.each(t[r],function(t){this._pieceList.push({text:this.formatValueText(t,!0),value:t})},this),e(t,this._pieceList)},pieces:function(){var t=this[Xn];o.each(t.pieces,function(t,e){o[In](t)||(t={value:t});var i,n={text:"",index:e};if(null!=t.label&&(n.text=t.label,i=!0),t.hasOwnProperty("value"))n.value=t.value,i||(n.text=this.formatValueText(n.value));else{var r=t.min,a=t.max;null==r&&(r=-(1/0)),null==a&&(a=1/0),r===a&&(n.value=r),n[B]=[r,a],i||(n.text=this.formatValueText([r,a]))}n.visual=s.retrieveVisuals(t),this._pieceList.push(n)},this),e(t,this._pieceList)}};return l}),e("echarts/component/visualMap/PiecewiseView",[ia,"./VisualMapView",ta,yt,xt,P,"./helper"],function(t){var e=t("./VisualMapView"),n=t(ta),r=t(yt),o=t(xt),s=t(P),l=t("./helper"),u=e[Lr]({type:"visualMap.piecewise",doRender:function(){function t(t){var i=new r.Group;i.onclick=n.bind(this._onItemClick,this,t.piece),this._createItemSymbol(i,t.piece,[0,0,p[0],p[1]]),m&&i.add(new r.Text({style:{x:"right"===d?-o:p[0]+o,y:p[1]/2,text:t.piece.text,textBaseline:"middle",textAlign:d,textFont:u,fill:c}})),e.add(i)}var e=this.group;e[Si]();var a=this.visualMapModel,o=a.get("textGap"),l=a[i],u=l[$n](),c=l[Be](),d=this._getItemAlign(),p=a.itemSize,v=this._getViewData(),m=!v.endsText,g=!m;g&&this._renderEndsText(e,v.endsText[0],p),n.each(v.pieceList,t,this),g&&this._renderEndsText(e,v.endsText[1],p),s.box(a.get(f),e,a.get(h)),this.renderBackground(e),this[_n](e)},_getItemAlign:function(){var t=this.visualMapModel,e=t[Xn];if(e[f]===Sn)return l.getItemAlign(t,this.api,t.itemSize);var i=e.align;return i&&"auto"!==i||(i="left"),i},_renderEndsText:function(t,e,n){if(e){var a=new r.Group,o=this.visualMapModel[i];a.add(new r.Text({style:{x:n[0]/2,y:n[1]/2,textBaseline:"middle",textAlign:"center",text:e,textFont:o[$n](),fill:o[Be]()}})),t.add(a)}},_getViewData:function(){var t=this.visualMapModel,e=n.map(t.getPieceList(),function(t,e){return{piece:t,index:e}}),i=t.get("text"),r=t.get(f),o=t.get(tt);return(r===An?o:!o)?e[a]():i&&(i=i.slice()[a]()),{pieceList:e,endsText:i}},_createItemSymbol:function(t,e,i){var n;if(this.visualMapModel.isCategory())n=e.value;else if(null!=e.value)n=e.value;else{var r=e[B]||[];n=(r[0]+r[1])/2}var a=this.getControllerVisual(n);t.add(o[vt](a[ft],i[0],i[1],i[2],i[3],a.color))},_onItemClick:function(t){var e=this.visualMapModel,i=e[Xn],r=n.clone(i[g]),a=e.getSelectedMapKey(t);i[x]===y?(r[a]=!0,n.each(r,function(t,e){r[e]=e===a})):r[a]=!r[a],this.api[sn]({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:r})}});return u}),e("echarts/component/visualMapPiecewise",[ia,Y,"./visualMap/preprocessor","./visualMap/typeDefaulter","./visualMap/visualCoding","./visualMap/PiecewiseModel","./visualMap/PiecewiseView","./visualMap/visualMapAction"],function(t){t(Y)[Qt](t("./visualMap/preprocessor")),t("./visualMap/typeDefaulter"),t("./visualMap/visualCoding"),t("./visualMap/PiecewiseModel"),t("./visualMap/PiecewiseView"),t("./visualMap/visualMapAction")}),e("echarts/component/visualMap",[ia,"./visualMapContinuous","./visualMapPiecewise"],function(t){t("./visualMapContinuous"),t("./visualMapPiecewise")}),e("echarts/component/marker/MarkPointModel",[ia,Ct,C],function(t){var e=t(Ct),i=t(C)[Ut]({type:"markPoint",dependencies:[pn,"grid","polar"],init:function(t,e,i,n){this[xn](t,i),this[mn](t,i,n.createdBySelf,!0)},mergeOption:function(t,n,r,a){r||n[he](function(t){var r=t.get(le),o=t.markPointModel;if(!r||!r.data)return void(t.markPointModel=null);if(o)o[mn](r,n,!0);else{a&&e[Wn](r.label,[Tn,"show",er,vr,Dn]);var s={seriesIndex:t[Bn],name:t.name,createdBySelf:!0};o=new i(r,this,n,s)}t.markPointModel=o},this)},defaultOption:{zlevel:0,z:5,symbol:"pin",symbolSize:50,tooltip:{trigger:"item"},label:{normal:{show:!0,position:"inside"},emphasis:{show:!0}},itemStyle:{normal:{borderWidth:2},emphasis:{}}}});return i}),e("echarts/component/marker/markerHelper",[ia,ta,gt],function(t){function e(t,e,i){var n=-1;do n=Math.max(r.getPrecision(t.get(e,i)),n),t=t.stackedOn;while(t);return n}function i(t,i,n,r,a,o){var s=[],l=d(i,r,t),u=i.indexOfNearest(r,l,!0);s[a]=i.get(n,u,!0),s[o]=i.get(r,u,!0);var c=e(i,r,u);return c>=0&&(s[o]=+s[o][Vr](c)),s}var n=t(ta),r=t(gt),a=n[Ur],o=n.curry,s={min:o(i,"min"),max:o(i,"max"),average:o(i,"average")},l=function(t,e){var i=t[Nn](),r=t[tn];if((isNaN(e.x)||isNaN(e.y))&&!n[Dr](e.coord)&&r){var o=u(e,i,r,t);if(e=n.clone(e),e.type&&s[e.type]&&o.baseAxis&&o.valueAxis){var l=r[Ht],c=a(l,o.baseAxis.dim),h=a(l,o.valueAxis.dim);e.coord=s[e.type](i,o.baseDataDim,o.valueDataDim,c,h),e.value=e.coord[h]}else e.coord=[null!=e.xAxis?e.xAxis:e.radiusAxis,null!=e.yAxis?e.yAxis:e.angleAxis]}return e},u=function(t,e,i,n){var r={};return null!=t.valueIndex||null!=t.valueDim?(r.valueDataDim=null!=t.valueIndex?e[Ft](t.valueIndex):t.valueDim,r.valueAxis=i[et](n.dataDimToCoordDim(r.valueDataDim)),r.baseAxis=i[lt](r.valueAxis),r.baseDataDim=n[k](r.baseAxis.dim)[0]):(r.baseAxis=n[$i](),r.valueAxis=i[lt](r.baseAxis),r.baseDataDim=n[k](r.baseAxis.dim)[0],r.valueDataDim=n[k](r.valueAxis.dim)[0]),r},c=function(t,e){return t&&e.coord&&(null==e.x||null==e.y)?t.containData(e.coord):!0},h=function(t,e,i,n){return 2>n?t.coord&&t.coord[n]:void t.value},d=function(t,e,i){return"average"===i?t[Nt](e,!0)/t.count():t[Bt](e,!0)["max"===i?1:0]};return{dataTransform:l,dataFilter:c,dimValueGetter:h,getAxisInfo:u,numCalculate:d}}),e("echarts/component/marker/MarkPointView",[ia,"../../chart/helper/SymbolDraw",ta,v,Ct,gt,kt,"./markerHelper",C],function(t){function e(t,e,i){var r=n.map(t[Ht],function(t){var i=e[Nn]().getDimensionInfo(e[k](t)[0]);return i.name=t,i}),a=new u(r,i);return t&&a[Zt](n[$r](n.map(i.get("data"),n.curry(c.dataTransform,e)),n.curry(c.dataFilter,t)),null,c.dimValueGetter),a}var i=t("../../chart/helper/SymbolDraw"),n=t(ta),r=t(v),a=t(Ct),o=t(gt),s=r[en],l=r[nn],u=t(kt),c=t("./markerHelper"),h={getRawDataArray:function(){return this[Xn].data},formatTooltip:function(t){var e=this[Nn](),i=this[On](t),r=n[Dr](i)?n.map(i,s).join(", "):s(i),a=e[Rn](t);return this.name+Qi+((a?l(a)+" : ":"")+r)},getData:function(){return this._data},setData:function(t){this._data=t}};n[rr](h,a.dataFormatMixin),t(C)[Wt]({type:"markPoint",init:function(){this._symbolDrawMap={}},render:function(t,e,i){var n=this._symbolDrawMap;for(var r in n)n[r].__keep=!1;e[he](function(t){var e=t.markPointModel;e&&this._renderSeriesMP(t,e,i)},this);for(var r in n)n[r].__keep||(n[r][Ii](),this.group[Ii](n[r].group))},_renderSeriesMP:function(t,r,a){var s=t[tn],l=t.name,u=t[Nn](),c=this._symbolDrawMap,d=c[l];d||(d=c[l]=new i);var f=e(s,t,r),p=s&&s[Ht];n.mixin(r,h),r[ni](f),f.each(function(e){var i,n=f[zn](e),l=n[Sr]("x"),c=n[Sr]("y");if(null!=l&&null!=c)i=[o[Br](l,a[un]()),o[Br](c,a[ln]())];else if(t.getMarkerPosition)i=t.getMarkerPosition(f[Gt](f[Ht],e));else if(s){var h=f.get(p[0],e),d=f.get(p[1],e);i=s[ot]([h,d])}f[Dt](e,i);var v=n[Sr](pt);typeof v===Fr&&(v=v(r[On](e),r[Pn](e))),f[fe](e,{symbolSize:v,color:n.get(re)||u[Vt]("color"),symbol:n[Sr](ft)})}),d[mt](f),this.group.add(d.group),f[yi](function(t){t[Ti](function(t){t[$t]=r})}),d.__keep=!0}})}),e("echarts/component/markPoint",[ia,"./marker/MarkPointModel","./marker/MarkPointView",Y],function(t){t("./marker/MarkPointModel"),t("./marker/MarkPointView"),t(Y)[Qt](function(t){t[le]=t[le]||{}})}),e("echarts/component/marker/MarkLineModel",[ia,Ct,C],function(t){var e=t(Ct),i=t(C)[Ut]({type:"markLine",dependencies:[pn,"grid","polar"],init:function(t,e,i,n){this[xn](t,i),this[mn](t,i,n.createdBySelf,!0)},mergeOption:function(t,n,r,a){r||n[he](function(t){var r=t.get("markLine"),o=t.markLineModel;if(!r||!r.data)return void(t.markLineModel=null);if(o)o[mn](r,n,!0);else{a&&e[Wn](r.label,[Tn,"show",er,vr,Dn]);var s={seriesIndex:t[Bn],name:t.name,createdBySelf:!0};o=new i(r,this,n,s)}t.markLineModel=o},this)},defaultOption:{zlevel:0,z:5,symbol:[dt,"arrow"],symbolSize:[8,16],precision:2,tooltip:{trigger:"item"},label:{normal:{show:!0,position:"end"},emphasis:{show:!0}},lineStyle:{normal:{type:"dashed"},emphasis:{width:3}},animationEasing:"linear"}});return i}),e("echarts/component/marker/MarkLineView",[ia,ta,kt,v,Ct,gt,"./markerHelper","../../chart/helper/LineDraw",C],function(t){function e(t,e){return c.dataFilter(t,e[0])&&c.dataFilter(t,e[1])}function i(t,i,a){var o=n.map(t[Ht],function(t){var e=i[Nn]().getDimensionInfo(i[k](t)[0]);return e.name=t,e}),s=new r(o,a),l=new r(o,a),u=new r([],a);if(t){var h=n[$r](n.map(a.get("data"),n.curry(d,i,t,a)),n.curry(e,t));s[Zt](n.map(h,function(t){return t[0]}),null,c.dimValueGetter),l[Zt](n.map(h,function(t){return t[1]}),null,c.dimValueGetter),u[Zt](n.map(h,function(t){return t[2]}))}return{from:s,to:l,line:u}}var n=t(ta),r=t(kt),a=t(v),o=t(Ct),s=t(gt),l=a[en],u=a[nn],c=t("./markerHelper"),h=t("../../chart/helper/LineDraw"),d=function(t,e,i,r){var a=t[Nn](),o=r.type;if(!n[Dr](r)&&("min"===o||"max"===o||"average"===o)){var s=c.getAxisInfo(r,a,e,t),l=s.baseAxis.dim+"Axis",u=s.valueAxis.dim+"Axis",h=s.baseAxis.scale[st](),d=n.clone(r),f={};d.type=null,d[l]=h[0],f[l]=h[1];var p=c.numCalculate(a,s.valueDataDim,o);p=s.valueAxis[V](s.valueAxis[O](p));var v=i.get("precision");v>=0&&(p=+p[Vr](v)),d[u]=f[u]=p,r=[d,f,{type:o,value:p}]}return r=[c.dataTransform(t,r[0]),c.dataTransform(t,r[1]),n[Lr]({},r[2])],n.merge(r[2],r[0]),n.merge(r[2],r[1]),r},f={formatTooltip:function(t){var e=this._data,i=this[On](t),r=n[Dr](i)?n.map(i,l).join(", "):l(i),a=e[Rn](t);return this.name+Qi+((a?u(a)+" : ":"")+r)},getRawDataArray:function(){return this[Xn].data},getData:function(){return this._data},setData:function(t){this._data=t}};n[rr](f,o.dataFormatMixin),t(C)[Wt]({type:"markLine",init:function(){this._markLineMap={}},render:function(t,e,i){var n=this._markLineMap;for(var r in n)n[r].__keep=!1;e[he](function(t){var n=t.markLineModel;n&&this._renderSeriesML(t,n,e,i)},this);for(var r in n)n[r].__keep||this.group[Ii](n[r].group)},_renderSeriesML:function(t,e,r,a){function o(e,i,n){var r,o=e[zn](i),u=o.get("x"),h=o.get("y");if(null!=u&&null!=h)r=[s[Br](u,a[un]()),s[Br](h,a[ln]())];else if(t.getMarkerPosition)r=t.getMarkerPosition(e[Gt](e[Ht],i));else{var d=e.get(m[0],i),f=e.get(m[1],i);r=l[ot]([d,f])}e[Dt](i,r),e[fe](i,{symbolSize:o.get(pt)||w[n?0:1],symbol:o.get(ft,!0)||_[n?0:1],color:o.get(re)||c[Vt]("color")})}var l=t[tn],u=t.name,c=t[Nn](),d=this._markLineMap,p=d[u];p||(p=d[u]=new h),this.group.add(p.group);var v=i(l,t,e),m=l[Ht],g=v.from,y=v.to,x=v.line;n[Lr](e,f),e[ni](x);var _=e.get(ft),w=e.get(pt);n[Dr](_)||(_=[_,_]),typeof w===Wr&&(w=[w,w]),v.from.each(function(t){o(g,t,!0),o(y,t)}),x.each(function(t){var e=x[zn](t).get("lineStyle.normal.color");x[fe](t,{color:e||g[It](t,"color")}),x[Dt](t,[g[Pt](t),y[Pt](t)])}),p[mt](x,g,y),v.line[yi](function(t,i){t[Ti](function(t){t[$t]=e})}),p.__keep=!0}})}),e("echarts/component/markLine",[ia,"./marker/MarkLineModel","./marker/MarkLineView",Y],function(t){t("./marker/MarkLineModel"),t("./marker/MarkLineView"),t(Y)[Qt](function(t){t.markLine=t.markLine||{}})}),e("echarts/component/timeline/preprocessor",[ia,ta],function(t){function e(t){var e=t.type,a={number:"value",time:"time"};if(a[e]&&(t.axisType=a[e],delete t.type),i(t),n(t,"controlPosition")){var o=t.controlStyle||(t.controlStyle={});n(o,Tn)||(o[Tn]=t.controlPosition),"none"!==o[Tn]||n(o,"show")||(o.show=!1,delete o[Tn]),delete t.controlPosition}r.each(t.data||[],function(t){r[In](t)&&!r[Dr](t)&&(!n(t,"value")&&n(t,"name")&&(t.value=t.name),i(t))})}function i(t){var e=t[ue]||(t[ue]={}),i=e[Hn]||(e[Hn]={}),a=t.label||t.label||{},o=a[Fn]||(a[Fn]={}),s={normal:1,emphasis:1};r.each(a,function(t,e){s[e]||n(o,e)||(o[e]=t)}),i.label&&!n(a,Hn)&&(a[Hn]=i.label,delete i.label)}function n(t,e){return t.hasOwnProperty(e)}var r=t(ta);return function(t){var i=t&&t[vn];r[Dr](i)||(i=i?[i]:[]),r.each(i,function(t){t&&e(t)})}}),e("echarts/component/timeline/typeDefaulter",[ia,z],function(t){t(z)[Ln](vn,function(){return"slider"})}),e("echarts/component/timeline/timelineAction",[ia,C],function(t){var e=t(C);e[Kt]({type:"timelineChange",event:"timelineChanged",update:"prepareAndUpdate"},function(t,e){var i=e[rn](vn);i&&null!=t.currentIndex&&(i.setCurrentIndex(t.currentIndex),!i.get("loop",!0)&&i.isIndexMax()&&i.setPlayState(!1)),e[yn](vn)}),e[Kt]({type:"timelinePlayChange",event:"timelinePlayChanged",update:"update"},function(t,e){var i=e[rn](vn);i&&null!=t.playState&&i.setPlayState(t.playState)})}),e("echarts/component/timeline/TimelineModel",[ia,z,kt,ta,Ct],function(t){var e=t(z),i=t(kt),n=t(ta),r=t(Ct),a=e[Lr]({type:"timeline",layoutMode:"box",defaultOption:{zlevel:0,z:4,show:!0,axisType:"time",realtime:!0,left:"20%",top:null,right:"20%",bottom:0,width:null,height:40,padding:5,controlPosition:"left",autoPlay:!1,rewind:!1,loop:!0,playInterval:2e3,currentIndex:0,itemStyle:{normal:{},emphasis:{}},label:{normal:{textStyle:{color:"#000"}},emphasis:{}},data:[]},init:function(t,e,i){this._data,this._names,this[xn](t,i),this._initData()},mergeOption:function(t){a[kr](this,mn,arguments),this._initData()},setCurrentIndex:function(t){null==t&&(t=this[Xn].currentIndex);var e=this._data.count();this[Xn].loop?t=(t%e+e)%e:(t>=e&&(t=e-1),0>t&&(t=0)),this[Xn].currentIndex=t},getCurrentIndex:function(){return this[Xn].currentIndex},isIndexMax:function(){return this.getCurrentIndex()>=this._data.count()-1},setPlayState:function(t){this[Xn].autoPlay=!!t},getPlayState:function(){return!!this[Xn].autoPlay},_initData:function(){var t=this[Xn],e=t.data||[],a=t.axisType,o=this._names=[];if(a===St){var s=[];n.each(e,function(t,e){var i,a=r.getDataItemValue(t);n[In](t)?(i=n.clone(t),i.value=e):i=e,s.push(i),n[dn](a)||null!=a&&!isNaN(a)||(a=""),o.push(a+"")}),e=s}var l={category:"ordinal",time:"time"}[a]||Wr,u=this._data=new i([{name:"value",type:l}],this);u[Zt](e,o)},getData:function(){return this._data},getCategories:function(){return this.get("axisType")===St?this._names.slice():void 0}});return a}),e("echarts/component/timeline/SliderTimelineModel",[ia,"./TimelineModel"],function(t){var e=t("./TimelineModel");return e[Lr]({type:"timeline.slider",defaultOption:{backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",borderWidth:0,orient:"horizontal",inverse:!1,tooltip:{trigger:"item"},symbol:"emptyCircle",symbolSize:10,lineStyle:{show:!0,width:2,color:"#304654"},label:{position:"auto",normal:{show:!0,interval:"auto",rotate:0,textStyle:{color:"#304654"}},emphasis:{show:!0,textStyle:{color:"#c23531"}}},itemStyle:{normal:{color:"#304654",borderWidth:1},emphasis:{color:"#c23531"}},checkpointStyle:{symbol:"circle",symbolSize:13,color:"#c23531",borderWidth:5,borderColor:"rgba(194,53,49, 0.5)",animation:!0,animationDuration:300,animationEasing:"quinticInOut"},controlStyle:{show:!0,showPlayBtn:!0,showPrevBtn:!0,showNextBtn:!0,itemSize:22,itemGap:12,position:"left",playIcon:"path://M31.6,53C17.5,53,6,41.5,6,27.4S17.5,1.8,31.6,1.8C45.7,1.8,57.2,13.3,57.2,27.4S45.7,53,31.6,53z M31.6,3.3 C18.4,3.3,7.5,14.1,7.5,27.4c0,13.3,10.8,24.1,24.1,24.1C44.9,51.5,55.7,40.7,55.7,27.4C55.7,14.1,44.9,3.3,31.6,3.3z M24.9,21.3 c0-2.2,1.6-3.1,3.5-2l10.5,6.1c1.899,1.1,1.899,2.9,0,4l-10.5,6.1c-1.9,1.1-3.5,0.2-3.5-2V21.3z",stopIcon:"path://M30.9,53.2C16.8,53.2,5.3,41.7,5.3,27.6S16.8,2,30.9,2C45,2,56.4,13.5,56.4,27.6S45,53.2,30.9,53.2z M30.9,3.5C17.6,3.5,6.8,14.4,6.8,27.6c0,13.3,10.8,24.1,24.101,24.1C44.2,51.7,55,40.9,55,27.6C54.9,14.4,44.1,3.5,30.9,3.5z M36.9,35.8c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H36c0.5,0,0.9,0.4,0.9,1V35.8z M27.8,35.8 c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H27c0.5,0,0.9,0.4,0.9,1L27.8,35.8L27.8,35.8z",nextIcon:"path://M18.6,50.8l22.5-22.5c0.2-0.2,0.3-0.4,0.3-0.7c0-0.3-0.1-0.5-0.3-0.7L18.7,4.4c-0.1-0.1-0.2-0.3-0.2-0.5 c0-0.4,0.3-0.8,0.8-0.8c0.2,0,0.5,0.1,0.6,0.3l23.5,23.5l0,0c0.2,0.2,0.3,0.4,0.3,0.7c0,0.3-0.1,0.5-0.3,0.7l-0.1,0.1L19.7,52 c-0.1,0.1-0.3,0.2-0.5,0.2c-0.4,0-0.8-0.3-0.8-0.8C18.4,51.2,18.5,51,18.6,50.8z",prevIcon:"path://M43,52.8L20.4,30.3c-0.2-0.2-0.3-0.4-0.3-0.7c0-0.3,0.1-0.5,0.3-0.7L42.9,6.4c0.1-0.1,0.2-0.3,0.2-0.5 c0-0.4-0.3-0.8-0.8-0.8c-0.2,0-0.5,0.1-0.6,0.3L18.3,28.8l0,0c-0.2,0.2-0.3,0.4-0.3,0.7c0,0.3,0.1,0.5,0.3,0.7l0.1,0.1L41.9,54 c0.1,0.1,0.3,0.2,0.5,0.2c0.4,0,0.8-0.3,0.8-0.8C43.2,53.2,43.1,53,43,52.8z",normal:{color:"#304654",borderColor:"#304654",borderWidth:1},emphasis:{color:"#c23531",borderColor:"#c23531",borderWidth:2}},data:[]}})}),e("echarts/component/timeline/TimelineView",[ia,"../../view/Component"],function(t){var e=t("../../view/Component");return e[Lr]({type:"timeline"})}),e("echarts/component/timeline/TimelineAxis",[ia,ta,"../../coord/Axis",D],function(t){var e=t(ta),i=t("../../coord/Axis"),n=t(D),r=function(t,e,n,r){i.call(this,t,e,n),this.type=r||"value",this._autoLabelInterval,this.model=null};return r[ea]={constructor:r,getLabelInterval:function(){var t=this.model,i=t[ir](M),r=i.get(B);if(null!=r&&"auto"!=r)return r;var r=this._autoLabelInterval;return r||(r=this._autoLabelInterval=n.getAxisLabelInterval(e.map(this.scale[W](),this[O],this),n[E](this,i.get(Dn)),i[ir](er)[$n](),t.get(f)===An)),r},isLabelIgnored:function(t){if(this.type===St){var e=this.getLabelInterval();return typeof e===Fr&&!e(t,this.scale[H](t))||t%(e+1)}}},e[Tr](r,i),r}),e("echarts/component/timeline/SliderTimelineView",[ia,ta,yt,P,"./TimelineView","./TimelineAxis",xt,D,fr,pr,gt,Ct,v],function(t){function e(t,e){return l[bn](t[L](),{width:e[un](),height:e[ln]()},t.get(p))}function i(t,e,i,n){var r=s.makePath(t.get(e)[Zr](/^path:\/\//,""),o.clone(n||{}),new y(i[0],i[1],i[2],i[3]),Nr);return r}function n(t,e,i,n,r,a){var s=t.get(ft),l=e.get("color"),u=t.get(pt),c=u/2,h=e[ht](["color",ft,pt]);return r?(r[qe](h),r[_t](l),i.add(r),a&&a.onUpdate(r)):(r=m[vt](s,-c,-c,u,u,l),i.add(r),a&&a.onCreate(r)),n=o.merge({rectHover:!0,style:h,z2:100},n,!0),r.attr(n),r}function r(t,e,i,n,r){if(!t.dragging){var a=n[ir]("checkpointStyle"),o=i[O](n[Nn]().get(["value"],e));r||!a.get(Bi,!0)?t.attr({position:[o,0]}):(t[Oi](!0),t[Ne]({position:[o,0]},a.get("animationDuration",!0),a.get("animationEasing",!0)))}}var o=t(ta),s=t(yt),l=t(P),u=t("./TimelineView"),c=t("./TimelineAxis"),m=t(xt),g=t(D),y=t(fr),x=t(pr),_=t(gt),w=t(Ct),b=t(v),C=b[nn],T=o.bind,k=o.each,I=Math.PI;return u[Lr]({type:"timeline.slider",init:function(t,e){this.api=e,this._axis,this._viewRect,this._timer,this._currentPointer,this._mainGroup,this._labelGroup},render:function(t,e,i,n){if(this.model=t,this.api=i,this[nr]=e,this.group[Si](),t.get("show",!0)){var r=this._layout(t,i),a=this._createGroup("mainGroup"),o=this._createGroup("labelGroup"),s=this._axis=this._createAxis(r,t);k(["AxisLine","AxisTick","Control","CurrentPointer"],function(e){this["_render"+e](r,a,s,t)},this),this._renderAxisLabel(r,o,s,t),this._position(r,t)}this._doPlayStop()},remove:function(){this._clearTimer(),this.group[Si]()},dispose:function(){this._clearTimer()},_layout:function(t,i){var n=t.get("label.normal.position"),r=t.get(f),o=e(t,i);null==n||"auto"===n?n=r===An?o.y+o[hr]/2=0||"+"===n?"left":"right"},l={horizontal:n>=0||"+"===n?"top":Or,vertical:"middle"},u={horizontal:0,vertical:I/2},c=r===Sn?o[hr]:o.width,d=t[ir]("controlStyle"),p=d.get("show"),v=p?d.get("itemSize"):0,m=p?d.get(h):0,g=v+m,y=t.get("label.normal.rotate")||0;y=y*I/180;var x,_,w,b,M=d.get(Tn,!0),p=d.get("show",!0),S=p&&d.get("showPlayBtn",!0),A=p&&d.get("showPrevBtn",!0),C=p&&d.get("showNextBtn",!0),T=0,k=c;return"left"===M||M===Or?(S&&(x=[0,0],T+=g),A&&(_=[T,0],T+=g),C&&(w=[k-v,0],k-=g)):(S&&(x=[k-v,0],k-=g),A&&(_=[0,0],T+=g),C&&(w=[k-v,0],k-=g)),b=[T,k],t.get(tt)&&b[a](),{viewRect:o,mainLength:c,orient:r,rotation:u[r],labelRotation:y,labelPosOpt:n,labelAlign:s[r],labelBaseline:l[r],playPosition:x,prevBtnPosition:_,nextBtnPosition:w,axisExtent:b,controlSize:v,controlGap:m}},_position:function(t,e){function i(t){var e=t[Tn];t[Yi]=[h[0][0]-e[0],h[1][0]-e[1]]}function n(t){return[[t.x,t.x+t.width],[t.y,t.y+t[hr]]]}function r(t,e,i,n,r){t[n]+=i[n][r]-e[n][r]}var a=this._mainGroup,o=this._labelGroup,s=t.viewRect;if(t[f]===Sn){var l=x[cr](),u=s.x,c=s.y+s[hr];x[ur](l,l,[-u,-c]),x[Hi](l,l,-I/2),x[ur](l,l,[u,c]),s=s.clone(),s[dr](l)}var h=n(s),d=n(a[tr]()),p=n(o[tr]()),v=a[Tn],m=o[Tn];m[0]=v[0]=h[0][0];var g=t.labelPosOpt;if(isNaN(g)){var y="+"===g?0:1;r(v,d,h,1,y),r(m,p,h,1,1-y)}else{var y=g>=0?0:1;r(v,d,h,1,y),m[1]=v[1]+g}a[Tn]=v,o[Tn]=m,a[Ki]=o[Ki]=t[Ki],i(a),i(o)},_createAxis:function(t,e){var i=e[Nn](),n=e.get("axisType"),r=g[N](e,n),a=i[Bt]("value");r[q](a[0],a[1]),this._customizeScale(r,i),r.niceTicks();var o=new c("value",r,t.axisExtent,n);return o.model=e,o},_customizeScale:function(t,e){t[W]=function(){return e[Ot](["value"],function(t){return t})},t.getTicksLabels=function(){return o.map(this[W](),t[H],t)}},_createGroup:function(t){var e=this["_"+t]=new s.Group;return this.group.add(e),e},_renderAxisLine:function(t,e,i,n){var r=i[st]();n.get("lineStyle.show")&&e.add(new s.Line({shape:{x1:r[0],y1:0,x2:r[1],y2:0},style:o[Lr]({lineCap:"round"},n[ir](ce)[J]()),silent:!0,z2:1}))},_renderAxisTick:function(t,e,i,r){var a=r[Nn](),o=i.scale[W](),l=this._prepareTooltipHostModel(a,r);k(o,function(t,r){var o=i[O](t),u=a[zn](r),c=u[ir](A),h=u[ir](S),d={position:[o,0],onclick:T(this._changeTimeline,this,r)},f=n(u,c,e,d);s[He](f,h[ht]()),u.get("tooltip")?(f[wi]=r,f[$t]=l):f[wi]=f[$t]=null},this)},_prepareTooltipHostModel:function(t,e){var i=w[Gn]({},t,e.get("data")),n=this;return i[d]=function(t){return C(n._axis.scale[H](t))},i},_renderAxisLabel:function(t,e,i,n){var r=n[ir](M);if(r.get("show")){var a=n[Nn](),o=i.scale[W](),l=g[E](i,r.get(Dn)),u=i.getLabelInterval();k(o,function(n,r){if(!i.isLabelIgnored(r,u)){var o=a[zn](r),c=o[ir]("label.normal.textStyle"),h=o[ir]("label.emphasis.textStyle"),d=i[O](n),f=new s.Text({style:{text:l[r],textAlign:t.labelAlign,textBaseline:t.labelBaseline,textFont:c[$n](),fill:c[Be]()},position:[d,0],rotation:t.labelRotation-t[Ki],onclick:T(this._changeTimeline,this,r),silent:!1});e.add(f),s[He](f,h[ht]())}},this)}},_renderControl:function(t,e,n,r){function a(t,n,a,d){if(t){var f={position:t,origin:[o/2,0],rotation:d?-l:0,rectHover:!0,style:u,onclick:a},p=i(r,n,h,f);e.add(p),s[He](p,c)}}var o=t.controlSize,l=t[Ki],u=r[ir]("controlStyle.normal")[ht](),c=r[ir]("controlStyle.emphasis")[ht](),h=[0,-o/2,o,o],d=r.getPlayState(),f=r.get(tt,!0);a(t.nextBtnPosition,"controlStyle.nextIcon",T(this._changeTimeline,this,f?"-":"+")),a(t.prevBtnPosition,"controlStyle.prevIcon",T(this._changeTimeline,this,f?"+":"-")),a(t.playPosition,"controlStyle."+(d?"stopIcon":"playIcon"),T(this._handlePlayClick,this,!d),!0)},_renderCurrentPointer:function(t,e,i,a){var o=a[Nn](),s=a.getCurrentIndex(),l=o[zn](s)[ir]("checkpointStyle"),u=this,c={onCreate:function(t){t[Ri]=!0,t.drift=T(u._handlePointerDrag,u),t.ondragend=T(u._handlePointerDragend,u),r(t,s,i,a,!0)},onUpdate:function(t){r(t,s,i,a)}};this._currentPointer=n(l,l,this._mainGroup,{},this._currentPointer,c)},_handlePlayClick:function(t){this._clearTimer(),this.api[sn]({type:"timelinePlayChange",playState:t,from:this.uid})},_handlePointerDrag:function(t,e,i){this._clearTimer(),this._pointerChangeTimeline([i[Ie],i[Le]])},_handlePointerDragend:function(t){this._pointerChangeTimeline([t[Ie],t[Le]],!0)},_pointerChangeTimeline:function(t,e){var i=this._toAxisCoord(t)[0],n=this._axis,r=_.asc(n[st]().slice());i>r[1]&&(i=r[1]),is&&(n=s,e=a)}),e},_clearTimer:function(){this._timer&&(clearTimeout(this._timer),this._timer=null)},_changeTimeline:function(t){var e=this.model.getCurrentIndex();"+"===t?t=e+1:"-"===t&&(t=e-1),this.api[sn]({type:"timelineChange",currentIndex:t,from:this.uid})}})}),e("echarts/component/timeline",[ia,Y,"./timeline/preprocessor","./timeline/typeDefaulter","./timeline/timelineAction","./timeline/SliderTimelineModel","./timeline/SliderTimelineView"],function(t){var e=t(Y);e[Qt](t("./timeline/preprocessor")),t("./timeline/typeDefaulter"),t("./timeline/timelineAction"),t("./timeline/SliderTimelineModel"),t("./timeline/SliderTimelineView")}),e("echarts/component/toolbox/featureManager",[ia],function(t){var e={};return{register:function(t,i){e[t]=i},get:function(t){return e[t]}}}),e("echarts/component/toolbox/ToolboxModel",[ia,"./featureManager",ta,C],function(t){var e=t("./featureManager"),i=t(ta),n=t(C)[Ut]({type:"toolbox",layoutMode:{type:"box",ignoreSize:!0},mergeDefaultAndTheme:function(t){n[kr](this,xn,arguments),i.each(this[Xn].feature,function(t,n){var r=e.get(n);r&&i.merge(t,r.defaultOption)})},defaultOption:{show:!0,z:6,zlevel:0,orient:"horizontal",left:"right",top:"top",backgroundColor:"transparent",borderColor:"#ccc",borderWidth:0,padding:5,itemSize:15,itemGap:8,showTitle:!0,iconStyle:{normal:{borderColor:"#666",color:"none"},emphasis:{borderColor:"#3E98C5"}}}});return n}),e("echarts/component/toolbox/ToolboxView",[ia,"./featureManager",ta,yt,T,"../../data/DataDiffer","../helper/listComponent",lr,C],function(t){function e(t){return 0===t[Ur]("my")}var i=t("./featureManager"),n=t(ta),r=t(yt),a=t(T),o=t("../../data/DataDiffer"),s=t("../helper/listComponent"),l=t(lr);return t(C)[Wt]({type:"toolbox",render:function(t,u,h){function d(n,r){var o,s=y[n],l=y[r],c=m[s],d=new a(c,t,t[nr]);if(s&&!l){if(e(s))o={model:d,onclick:d[Xn].onclick,featureName:s};else{var p=i.get(s);if(!p)return;o=new p(d)}g[s]=o}else{if(o=g[l],!o)return;o.model=d}return!s&&l?void(o[me]&&o[me](u,h)):!d.get("show")||o.unusable?void(o[Ii]&&o[Ii](u,h)):(f(d,o,s),d.setIconStatus=function(t,e){var i=this[Xn],n=this.iconPaths;i.iconStatus=i.iconStatus||{},i.iconStatus[t]=e,n[t]&&n[t][bi](e)},void(o[Mi]&&o[Mi](d,u,h)))}function f(e,i,a){var o=e[ir]("iconStyle"),s=i.getIcons?i.getIcons():e.get("icon"),l=e.get("title")||{};if(typeof s===qr){var c=s,d=l;s={},l={},s[a]=c,l[a]=d}var f=e.iconPaths={};n.each(s,function(a,s){var c=o[ir](Fn)[ht](),d=o[ir](Hn)[ht](),m={x:-v/2,y:-v/2,width:v,height:v},g=0===a[Ur]("image://")?(m.image=a.slice(8),new r.Image({style:m})):r.makePath(a[Zr]("path://",""),{style:c,hoverStyle:d,rectHover:!0},m,Nr);r[He](g),t.get("showTitle")&&(g.__title=l[s],g.on(Fe,function(){g[qe]({text:l[s],textPosition:d[gi]||Or,textFill:d.fill||d[br]||"#000",textAlign:d[mi]||Nr})}).on(Ze,function(){g[qe]({textFill:null})})),g[bi](e.get("iconStatus."+s)||Fn),p.add(g),g.on("click",n.bind(i.onclick,i,u,h,s)),f[s]=g})}var p=this.group;if(p[Si](),t.get("show")){var v=+t.get("itemSize"),m=t.get("feature")||{},g=this._features||(this._features={}),y=[];n.each(m,function(t,e){y.push(e)}),new o(this._featureNames||[],y).add(d)[on](d)[Ii](n.curry(d,null))[ut](),this._featureNames=y,s[c](p,t,h),s.addBackground(p,t),p[kn](function(t){var e=t.__title,i=t[We];if(i&&e){var n=l[tr](e,i.font),r=t[Tn][0]+p[Tn][0],a=t[Tn][1]+p[Tn][1]+v,o=!1;a+n[hr]>h[ln]()&&(i[gi]="top",o=!0);var s=o?-5-n[hr]:v+8;r+n.width/2>h[un]()?(i[gi]=["100%",s],i[mi]="right"):r-n.width/2<0&&(i[gi]=[0,s],i[mi]="left")}})}},remove:function(t,e){n.each(this._features,function(i){i[Ii]&&i[Ii](t,e)}),this.group[Si]()},dispose:function(t,e){n.each(this._features,function(i){i[me]&&i[me](t,e)})}})}),e("echarts/component/toolbox/feature/SaveAsImage",[ia,Ve,"../featureManager"],function(t){function e(t){this.model=t}var i=t(Ve);e.defaultOption={show:!0,icon:"M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0",title:"保存为图片",type:"png",name:"",excludeComponents:["toolbox"],pixelRatio:1,lang:["右键另存为图片"]},e[ea].unusable=!i[ge];var n=e[ea];return n.onclick=function(t,e){var i=this.model,n=i.get("name")||t.get("title.0.text")||"echarts",r=document[Yr]("a"),a=i.get("type",!0)||"png";r.download=n+"."+a,r[Zi]="_blank";var o=e.getConnectedDataURL({type:a,backgroundColor:i.get(xe,!0)||t.get(xe)||"#fff",excludeComponents:i.get("excludeComponents"),pixelRatio:i.get("pixelRatio")});if(r.href=o,typeof MouseEvent===Fr){ -var s=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});r.dispatchEvent(s)}else{var l=i.get("lang"),u='',c=window.open();c.document.write(u)}},t("../featureManager")[an]("saveAsImage",e),e}),e("echarts/component/toolbox/feature/MagicType",[ia,ta,"../../../echarts","../featureManager"],function(t){function e(t){this.model=t}var i=t(ta);e.defaultOption={show:!0,type:[],icon:{line:"M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4",bar:"M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7",stack:"M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z",tiled:"M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z"},title:{line:"切换为折线图",bar:"切换为柱状图",stack:"切换为堆叠",tiled:"切换为平铺"},option:{},seriesIndex:{}};var n=e[ea];n.getIcons=function(){var t=this.model,e=t.get("icon"),n={};return i.each(t.get("type"),function(t){e[t]&&(n[t]=e[t])}),n};var r={line:function(t,e,n,r){return"bar"===t?i.merge({id:e,type:"line",data:n.get("data"),stack:n.get("stack"),markPoint:n.get(le),markLine:n.get("markLine")},r.get("option.line")):void 0},bar:function(t,e,n,r){return"line"===t?i.merge({id:e,type:"bar",data:n.get("data"),stack:n.get("stack"),markPoint:n.get(le),markLine:n.get("markLine")},r.get("option.bar")):void 0},stack:function(t,e,i,n){return"line"===t||"bar"===t?{id:e,stack:"__ec_magicType_stack__"}:void 0},tiled:function(t,e,i,n){return"line"===t||"bar"===t?{id:e,stack:""}:void 0}},a=[["line","bar"],["stack","tiled"]];n.onclick=function(t,e,n){var o=this.model,s=o.get("seriesIndex."+n);if(r[n]){var l={series:[]},u=function(t){var e=t.subType,a=t.id,s=r[n](e,a,t,o);s&&(i[rr](s,t[Xn]),l[pn].push(s))};i.each(a,function(t){i[Ur](t,n)>=0&&i.each(t,function(t){o.setIconStatus(t,Fn)})}),o.setIconStatus(n,Hn),t[ie]({mainType:"series",seriesIndex:s},u),e[sn]({type:"changeMagicType",currentType:n,newOption:l})}};var o=t("../../../echarts");return o[Kt]({type:"changeMagicType",event:"magicTypeChanged",update:"prepareAndUpdate"},function(t,e){e[mn](t.newOption)}),t("../featureManager")[an]("magicType",e),e}),e("echarts/component/toolbox/feature/DataView",[ia,ta,Re,"../featureManager","../../../echarts"],function(t){function e(t){var e={},i=[],n=[];return t.eachRawSeries(function(t){var r=t[tn];if(!r||r.type!==K&&"polar"!==r.type)i.push(t);else{var a=r[$i]();if(a.type===St){var o=a.dim+"_"+a.index;e[o]||(e[o]={categoryAxis:a,valueAxis:r[lt](a),series:[]},n.push({axisDim:a.dim,axisIndex:a.index})),e[o][pn].push(t)}else i.push(t)}}),{seriesGroupByCategoryAxis:e,other:i,meta:n}}function i(t){var e=[];return f.each(t,function(t,i){var n=t.categoryAxis,r=t.valueAxis,a=r.dim,o=[" "][Hr](f.map(t[pn],function(t){return t.name})),s=[n.model[Mt]()];f.each(t[pn],function(t){s.push(t.getRawData()[Ot](a,function(t){return t}))});for(var l=[o.join(m)],u=0;uo;o++)n[o]=arguments[o];i.push((a?a+m:"")+n.join(m))}),i.join("\n")}).join("\n\n"+v+"\n\n")}function a(t){var r=e(t);return{value:f[$r]([i(r.seriesGroupByCategoryAxis),n(r.other)],function(t){return t[Zr](/[\n\t\s]/g,"")}).join("\n\n"+v+"\n\n"),meta:r.meta}}function o(t){return t[Zr](/^\s\s*/,"")[Zr](/\s\s*$/,"")}function s(t){var e=t.slice(0,t[Ur]("\n"));return e[Ur](m)>=0?!0:void 0}function l(t){for(var e=t.split(/\n+/g),i=o(e.shift()).split(g),n=[],r=f.map(i,function(t){return{name:t,data:[]}}),a=0;a=0;n--){var a=r[n];if(a[i])break}if(0>n){var o=t.queryComponents({mainType:"dataZoom",subType:"select",id:i})[0];if(o){var s=o.getPercentRange();r[0][i]={dataZoomId:i,start:s[0],end:s[1]}}}}),r.push(i)},pop:function(t){var i=e(t),r=i[i[Kr]-1];i[Kr]>1&&i.pop();var a={};return n(r,function(t,e){for(var n=i[Kr]-1;n>=0;n--){var t=i[n][e];if(t){a[e]=t;break}}}),a},clear:function(t){t[r]=null},count:function(t){return e(t)[Kr]}};return a}),e("echarts/component/dataZoom/SelectZoomModel",[ia,"./DataZoomModel"],function(t){var e=t("./DataZoomModel");return e[Lr]({type:"dataZoom.select"})}),e("echarts/component/dataZoom/SelectZoomView",[ia,"./DataZoomView"],function(t){return t("./DataZoomView")[Lr]({type:"dataZoom.select"})}),e("echarts/component/dataZoomSelect",[ia,"./dataZoom/typeDefaulter","./dataZoom/DataZoomModel","./dataZoom/DataZoomView","./dataZoom/SelectZoomModel","./dataZoom/SelectZoomView","./dataZoom/dataZoomProcessor","./dataZoom/dataZoomAction"],function(t){t("./dataZoom/typeDefaulter"),t("./dataZoom/DataZoomModel"),t("./dataZoom/DataZoomView"),t("./dataZoom/SelectZoomModel"),t("./dataZoom/SelectZoomView"),t("./dataZoom/dataZoomProcessor"),t("./dataZoom/dataZoomAction")}),e("echarts/component/toolbox/feature/DataZoom",[ia,ta,"../../../util/number","../../helper/SelectController",fr,"zrender/container/Group","../../dataZoom/history","../../helper/interactionMutex","../../dataZoomSelect","../featureManager","../../../echarts"],function(t){function e(t){this.model=t,this._controllerGroup,this[s],this._isZoomActive}function i(t,e){var i=[{axisModel:t[et]("x").model,axisIndex:0},{axisModel:t[et]("y").model,axisIndex:0}];return i.grid=t,e[ie]({mainType:"dataZoom",subType:"select"},function(t,r){n("xAxis",i[0].axisModel,t,e)&&(i[0].dataZoomModel=t),n("yAxis",i[1].axisModel,t,e)&&(i[1].dataZoomModel=t)}),i}function n(t,e,i,n){var r=i.get(t+"Index");return null!=r&&n[rn](t,r)===e}function r(t,e){var i=e.grid,n=new d(t[0][0],t[1][0],t[0][1]-t[0][0],t[1][1]-t[1][0]);if(n[be](i[I]())){var r=i.getCartesian(e[0][Un],e[1][Un]),a=r.pointToData([t[0][0],t[1][0]],!0),o=r.pointToData([t[0][1],t[1][1]],!0);return[y([a[0],o[0]]),y([a[1],o[1]])]}}function a(t,e,i,n){var r=e[i],a=r.dataZoomModel;return a?{dataZoomId:a.id,startValue:t[i][0],endValue:t[i][1]}:void 0}function o(t,e){t.setIconStatus("back",p.count(e)>1?Hn:Fn)}var u=t(ta),c=t("../../../util/number"),h=t("../../helper/SelectController"),d=t(fr),f=t("zrender/container/Group"),p=t("../../dataZoom/history"),v=t("../../helper/interactionMutex"),m=u.each,y=c.asc;t("../../dataZoomSelect");var x="\x00_ec_\x00toolbox-dataZoom_";e.defaultOption={show:!0,icon:{zoom:"M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1",back:"M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26"},title:{zoom:"区域缩放",back:"区域缩放还原"}};var _=e[ea];_[Mi]=function(t,e,i){o(t,e)},_.onclick=function(t,e,i){var n=this._controllerGroup;this._controllerGroup||(n=this._controllerGroup=new f,e.getZr().add(n)),w[i].call(this,n,this.model,t,e)},_[Ii]=function(t,e){this._disposeController(),v.release("globalPan",e.getZr())},_[me]=function(t,e){var i=e.getZr();v.release("globalPan",i),this._disposeController(),this._controllerGroup&&i[Ii](this._controllerGroup)};var w={zoom:function(t,e,i,n){var r=this._isZoomActive=!this._isZoomActive,a=n.getZr();v[r?"take":"release"]("globalPan",a),e.setIconStatus("zoom",r?Hn:Fn),r?(a.setDefaultCursorStyle("crosshair"),this._createController(t,e,i,n)):(a.setDefaultCursorStyle("default"),this._disposeController())},back:function(t,e,i,n){this._dispatchAction(p.pop(i),n)}};return _._createController=function(t,e,i,n){var r=this[s]=new h("rect",n.getZr(),{lineWidth:3,stroke:"#333",fill:"rgba(0,0,0,0.2)"});r.on("selectEnd",u.bind(this._onSelected,this,r,e,i,n)),r[l](t,!1)},_._disposeController=function(){var t=this[s];t&&(t.off(g),t[me]())},_._onSelected=function(t,e,n,o,s){if(s[Kr]){var l=s[0];t[on]();var u={};n[ie]("grid",function(t,e){var o=t[tn],s=i(o,n),c=r(l,s);if(c){var h=a(c,s,0,"x"),d=a(c,s,1,"y");h&&(u[h.dataZoomId]=h),d&&(u[d.dataZoomId]=d)}},this),p.push(n,u),this._dispatchAction(u,o)}},_._dispatchAction=function(t,e){var i=[];m(t,function(t){i.push(t)}),i[Kr]&&e[sn]({type:"dataZoom",from:this.uid,batch:u.clone(i,!0)})},t("../featureManager")[an](oe,e),t("../../../echarts")[Qt](function(t){function e(t,e){if(e){var r=t+"Index",a=e[r];null==a||u[Dr](a)||(a=a===!1?[]:[a]),i(t,function(e,i){if(null==a||-1!==u[Ur](a,i)){var o={type:"select",$fromToolbox:!0,id:x+t+i};o[r]=i,n.push(o)}})}}function i(e,i){var n=t[e];u[Dr](n)||(n=n?[n]:[]),m(n,i)}if(t){var n=t[oe]||(t[oe]=[]);u[Dr](n)||(n=[n]);var r=t.toolbox;if(r&&(u[Dr](r)&&(r=r[0]),r&&r.feature)){var a=r.feature[oe];e("xAxis",a),e("yAxis",a)}}}),e}),e("echarts/component/toolbox/feature/Restore",[ia,"../../dataZoom/history","../featureManager","../../../echarts"],function(t){function e(t){this.model=t}var i=t("../../dataZoom/history");e.defaultOption={show:!0,icon:"M3.8,33.4 M47,18.9h9.8V8.7 M56.3,20.1 C52.1,9,40.5,0.6,26.8,2.1C12.6,3.7,1.6,16.2,2.1,30.6 M13,41.1H3.1v10.2 M3.7,39.9c4.2,11.1,15.8,19.5,29.5,18 c14.2-1.6,25.2-14.1,24.7-28.5",title:"还原"};var n=e[ea];return n.onclick=function(t,e,n){i.clear(t),e[sn]({type:"restore",from:this.uid})},t("../featureManager")[an](ai,e),t("../../../echarts")[Kt]({type:"restore",event:"restore",update:"prepareAndUpdate"},function(t,e){e[yn]("recreate")}),e}),e("echarts/component/toolbox",[ia,"./toolbox/ToolboxModel","./toolbox/ToolboxView","./toolbox/feature/SaveAsImage","./toolbox/feature/MagicType","./toolbox/feature/DataView","./toolbox/feature/DataZoom","./toolbox/feature/Restore"],function(t){t("./toolbox/ToolboxModel"),t("./toolbox/ToolboxView"),t("./toolbox/feature/SaveAsImage"),t("./toolbox/feature/MagicType"),t("./toolbox/feature/DataView"),t("./toolbox/feature/DataZoom"),t("./toolbox/feature/Restore")}),e("zrender/vml/core",[ia,"exports","module","../core/env"],function(t,e,i){if(!t("../core/env")[ge]){var n,r="urn:schemas-microsoft-com:vml",a=window,o=a.document,s=!1;try{!o.namespaces.zrvml&&o.namespaces.add("zrvml",r),n=function(t){return o[Yr]("')}}catch(l){n=function(t){return o[Yr]("<"+t+' xmlns="'+r+'" class="zrvml">')}}var u=function(){if(!s){s=!0;var t=o.styleSheets;t[Kr]<31?o.createStyleSheet().addRule(".zrvml","behavior:url(#default#VML)"):t[0].addRule(".zrvml","behavior:url(#default#VML)")}};i.exports={doc:o,initVML:u,createNode:n}}}),e("zrender/vml/graphic",[ia,"../core/env","../core/vector",or,"../core/PathProxy","../tool/color","../contain/text","../graphic/mixin/RectText","../graphic/Displayable","../graphic/Image","../graphic/Text","../graphic/Path","../graphic/Gradient","./core"],function(t){if(!t("../core/env")[ge]){var e=t("../core/vector"),i=t(or),n=t("../core/PathProxy").CMD,r=t("../tool/color"),a=t("../contain/text"),o=t("../graphic/mixin/RectText"),s=t("../graphic/Displayable"),l=t("../graphic/Image"),u=t("../graphic/Text"),c=t("../graphic/Path"),h=t("../graphic/Gradient"),d=t("./core"),f=Math.round,v=Math.sqrt,m=Math.abs,g=Math.cos,y=Math.sin,x=Math.max,_=e[dr],w=",",b="progid:DXImageTransform.Microsoft",M=21600,S=M/2,A=1e5,C=1e3,T=function(t){t.style.cssText="position:absolute;left:0;top:0;width:1px;height:1px;",t.coordsize=M+","+M,t.coordorigin="0,0"},k=function(t){return String(t)[Zr](/&/g,"&")[Zr](/"/g,""")},L=function(t,e,i){return"rgb("+[t,e,i].join(",")+")"},I=function(t,e){e&&t&&e[ke]!==t&&t[_e](e)},D=function(t,e){e&&t&&e[ke]===t&&t.removeChild(e)},P=function(t,e,i){return(parseFloat(t)||0)*A+(parseFloat(e)||0)*C+i},z=function(t,e){return typeof t===qr?t.lastIndexOf("%")>=0?parseFloat(t)/100*e:parseFloat(t):t},R=function(t,e,i){var n=r.parse(e);i=+i,isNaN(i)&&(i=1),n&&(t.color=L(n[0],n[1],n[2]),t[wr]=i*n[3])},V=function(t){var e=r.parse(t);return[L(e[0],e[1],e[2]),e[3]]},O=function(t,e,i){var n=e.fill;if(null!=n)if(n instanceof h){var r,a=0,o=[0,0],s=0,l=1,u=i[tr](),c=u.width,d=u[hr];if(n.type===Ei){r="gradient";var f=i[Xi],p=[n.x*c,n.y*d],v=[n.x2*c,n.y2*d];f&&(_(p,p,f),_(v,v,f));var m=v[0]-p[0],g=v[1]-p[1];a=180*Math.atan2(m,g)/Math.PI,0>a&&(a+=360),1e-6>a&&(a=0)}else{r="gradientradial";var p=[n.x*c,n.y*d],f=i[Xi],y=i.scale,w=c,b=d;o=[(p[0]-u.x)/w,(p[1]-u.y)/b],f&&_(p,p,f),w/=y[0]*M,b/=y[1]*M;var S=x(w,b);s=0/S,l=2*n.r/S-s}var A=n.colorStops.slice();A.sort(function(t,e){return t[Qe]-e[Qe]});for(var C=A[Kr],T=[],k=[],L=0;C>L;L++){var I=A[L],D=V(I.color);k.push(I[Qe]*l+s+" "+D[0]),(0===L||L===C-1)&&T.push(D)}if(C>=2){var P=T[0][0],z=T[1][0],O=T[0][1]*e[wr],E=T[1][1]*e[wr];t.type=r,t.method="none",t.focus="100%",t.angle=a,t.color=P,t.color2=z,t.colors=k.join(","),t[wr]=E,t.opacity2=O}"radial"===r&&(t.focusposition=o.join(","))}else R(t,n,e[wr])},E=function(t,e){null!=e.lineJoin&&(t.joinstyle=e.lineJoin),null!=e.miterLimit&&(t.miterlimit=e.miterLimit*M),null!=e.lineCap&&(t.endcap=e.lineCap),null!=e.lineDash&&(t.dashstyle=e.lineDash.join(" ")),null==e[br]||e[br]instanceof h||R(t,e[br],e[wr])},N=function(t,e,i,n){var r="fill"==e,a=t.getElementsByTagName(e)[0];null!=i[e]&&"none"!==i[e]&&(r||!r&&i[Mr])?(t[r?"filled":"stroked"]="true",i[e]instanceof h&&D(t,a),a||(a=d.createNode(e)),r?O(a,i,n):E(a,i),I(t,a)):(t[r?"filled":"stroked"]="false",D(t,a))},B=[[],[],[]],G=function(t,e){var i,r,a,o,s,l,u=n.M,c=n.C,h=n.L,d=n.A,p=n.Q,m=[];for(o=0;o0){m.push(r);for(var j=0;i>j;j++){var X=B[j];e&&_(X,X,e),m.push(f(X[0]*M-S),w,f(X[1]*M-S),i-1>j?w:"")}}}return m.join("")};c[ea].brush=function(t){var e=this.style,i=this._vmlEl;i||(i=d.createNode("shape"),T(i),this._vmlEl=i),N(i,"fill",e,this),N(i,br,e,this);var n=this[Xi],r=null!=n,a=i.getElementsByTagName(br)[0];if(a){var o=e[Mr];if(r&&!e.strokeNoScale){var s=n[0]*n[3]-n[1]*n[2];o*=v(m(s))}a.weight=o+"px"}var l=this.path;this.__dirtyPath&&(l[di](),this[oi](l,this.shape),this.__dirtyPath=!1),i.path=G(l.data,this[Xi]),i.style.zIndex=P(this[Se],this.z,this.z2),I(t,i),e.text&&this.drawRectText(t,this[tr]())},c[ea].onRemoveFromStorage=function(t){D(t,this._vmlEl),this.removeRectText(t)},c[ea].onAddToStorage=function(t){I(t,this._vmlEl),this.appendRectText(t)};var Z=function(t){return typeof t===Jr&&t.tagName&&"IMG"===t.tagName[Pr]()};l[ea].brush=function(t){var e,i,n=this.style,r=n.image;if(Z(r)){var a=r.src;if(a===this._imageSrc)e=this._imageWidth,i=this._imageHeight;else{var o=r.runtimeStyle,s=o.width,l=o[hr];o.width="auto",o[hr]="auto",e=r.width,i=r[hr],o.width=s,o[hr]=l,this._imageSrc=a,this._imageWidth=e,this._imageHeight=i}r=a}else r===this._imageSrc&&(e=this._imageWidth,i=this._imageHeight);if(r){var u=n.x||0,c=n.y||0,h=n.width,m=n[hr],g=n.sWidth,y=n.sHeight,M=n.sx||0,S=n.sy||0,A=g&&y,C=this._vmlEl;C||(C=d.doc[Yr]("div"),T(C),this._vmlEl=C);var k,L=C.style,D=!1,z=1,R=1;if(this[Xi]&&(k=this[Xi],z=v(k[0]*k[0]+k[1]*k[1]),R=v(k[2]*k[2]+k[3]*k[3]),D=k[1]||k[2]),D){var V=[u,c],O=[u+h,c],E=[u,c+m],N=[u+h,c+m];_(V,V,k),_(O,O,k),_(E,E,k),_(N,N,k);var B=x(V[0],O[0],E[0],N[0]),G=x(V[1],O[1],E[1],N[1]),F=[];F.push("M11=",k[0]/z,w,"M12=",k[2]/R,w,"M21=",k[1]/z,w,"M22=",k[3]/R,w,"Dx=",f(u*z+k[4]),w,"Dy=",f(c*R+k[5])),L[p]="0 "+f(B)+"px "+f(G)+"px 0",L[$r]=b+".Matrix("+F.join("")+", SizingMethod=clip)"}else k&&(u=u*z+k[4],c=c*R+k[5]),L[$r]="",L.left=f(u)+"px",L.top=f(c)+"px";var H=this._imageEl,W=this._cropEl;H||(H=d.doc[Yr]("div"),this._imageEl=H);var q=H.style;if(A){if(e&&i)q.width=f(z*e*h/g)+"px",q[hr]=f(R*i*m/y)+"px";else{var U=new Image,j=this;U.onload=function(){U.onload=null,e=U.width,i=U[hr],q.width=f(z*e*h/g)+"px",q[hr]=f(R*i*m/y)+"px",j._imageWidth=e,j._imageHeight=i,j._imageSrc=r},U.src=r}W||(W=d.doc[Yr]("div"),W.style.overflow="hidden",this._cropEl=W);var X=W.style;X.width=f((h+M*h/g)*z),X[hr]=f((m+S*m/y)*R),X[$r]=b+".Matrix(Dx="+-M*h/g*z+",Dy="+-S*m/y*R+")",W[ke]||C[_e](W),H[ke]!=W&&W[_e](H)}else q.width=f(z*h)+"px",q[hr]=f(R*m)+"px",C[_e](H),W&&W[ke]&&(C.removeChild(W),this._cropEl=null);var Y="",K=n[wr];1>K&&(Y+=".Alpha(opacity="+f(100*K)+") "),Y+=b+".AlphaImageLoader(src="+r+", SizingMethod=scale)",q[$r]=Y,C.style.zIndex=P(this[Se],this.z,this.z2),I(t,C),n.text&&this.drawRectText(t,this[tr]())}},l[ea].onRemoveFromStorage=function(t){D(t,this._vmlEl),this._vmlEl=null,this._cropEl=null,this._imageEl=null,this.removeRectText(t)},l[ea].onAddToStorage=function(t){I(t,this._vmlEl),this.appendRectText(t)};var F,H=Fn,W={},q=0,U=100,j=document[Yr]("div"),X=function(t){var e=W[t];if(!e){q>U&&(q=0,W={});var i,n=j.style;try{n.font=t,i=n.fontFamily.split(",")[0]}catch(r){}e={style:n.fontStyle||H,variant:n.fontVariant||H,weight:n.fontWeight||H,size:0|parseFloat(n.fontSize||12),family:i||"Microsoft YaHei"},W[t]=e,q++}return e};a.measureText=function(t,e){var i=d.doc;F||(F=i[Yr]("div"),F.style.cssText="position:absolute;top:-20000px;left:0;padding:0;margin:0;border:none;white-space:pre;",d.doc.body[_e](F));try{F.style.font=e}catch(n){}return F[we]="",F[_e](i.createTextNode(t)),{width:F.offsetWidth}};for(var Y=new i,K=function(t,e,i,n){var r=this.style,o=r.text;if(o){var s,l,u=r[mi],c=X(r.textFont),h=c.style+" "+c.variant+" "+c.weight+" "+c.size+'px "'+c.family+'"',p=r[vi];i=i||a[tr](o,h,u,p);var v=this[Xi];if(v&&!n&&(Y.copy(e),Y[dr](v),e=Y),n)s=e.x,l=e.y;else{var m=r[gi],g=r.textDistance;if(m instanceof Array)s=e.x+z(m[0],e.width),l=e.y+z(m[1],e[hr]),u=u||"left",p=p||"top";else{var y=a.adjustTextPositionOnRect(m,e,i,g);s=y.x,l=y.y,u=u||y[mi],p=p||y[vi]}}var x=c.size,b=(o+"").split("\n")[Kr];switch(p){case"hanging":case"top":l+=x/1.75*b;break;case Er:break;default:l-=x/2.25}switch(u){case"left":break;case Nr:s-=i.width/2;break;case"right":s-=i.width}var M,S,A,C=d.createNode,L=this._textVmlEl;L?(A=L.firstChild,M=A.nextSibling,S=M.nextSibling):(L=C("line"),M=C("path"),S=C("textpath"),A=C("skew"),S.style["v-text-align"]="left",T(L),M.textpathok=!0,S.on=!0,L.from="0 0",L.to="1000 0.05",I(L,A),I(L,M),I(L,S),this._textVmlEl=L);var D=[s,l],R=L.style;v&&n?(_(D,D,v),A.on=!0,A.matrix=v[0][Vr](3)+w+v[2][Vr](3)+w+v[1][Vr](3)+w+v[3][Vr](3)+",0,0",A[Qe]=(f(D[0])||0)+","+(f(D[1])||0),A[Yi]="0 0",R.left="0px",R.top="0px"):(A.on=!1,R.left=f(s)+"px",R.top=f(l)+"px"),S[qr]=k(o);try{S.style.font=h}catch(V){}N(L,"fill",{fill:n?r.fill:r.textFill,opacity:r[wr]},this),N(L,br,{stroke:n?r[br]:r.textStroke,opacity:r[wr],lineDash:r.lineDash},this),L.style.zIndex=P(this[Se],this.z,this.z2),I(t,L)}},J=function(t){D(t,this._textVmlEl),this._textVmlEl=null},Q=function(t){I(t,this._textVmlEl)},$=[o,s,l,c,u],tt=0;tt<$[Kr];tt++){var et=$[tt][ea];et.drawRectText=K,et.removeRectText=J,et.appendRectText=Q}u[ea].brush=function(t){var e=this.style;e.text&&this.drawRectText(t,{x:e.x||0,y:e.y||0,width:0,height:0},this[tr](),!0)},u[ea].onRemoveFromStorage=function(t){this.removeRectText(t)},u[ea].onAddToStorage=function(t){this.appendRectText(t)}}}),e("zrender/vml/Painter",[ia,"../core/log","./core"],function(t){function e(t){return parseInt(t,10)}function i(t,e){a.initVML(),this.root=t,this[Te]=e;var i=document[Yr]("div"),n=document[Yr]("div");i.style.cssText="display:inline-block;overflow:hidden;position:relative;width:300px;height:150px;",n.style.cssText="position:absolute;left:0;top:0;",t[_e](i),this._vmlRoot=n,this._vmlViewport=i,this[Me]();var r=e[ki],o=e[Li];e[ki]=function(t){var i=e.get(t);r.call(e,t),i&&i.onRemoveFromStorage&&i.onRemoveFromStorage(n)},e[Li]=function(t){t.onAddToStorage&&t.onAddToStorage(n),o.call(e,t)},this._firstPaint=!0}function n(t){return function(){r('In IE8.0 VML mode painter not support method "'+t+'"')}}var r=t("../core/log"),a=t("./core");i[ea]={constructor:i,getViewportRoot:function(){return this._vmlViewport},refresh:function(){var t=this[Te][Ce](!0);this._paintList(t)},_paintList:function(t){for(var e=this._vmlRoot,i=0;ii;i++)e[i]=n(t[i])}else if(!A(t)&&!I(t)){e={};for(var o in t)t.hasOwnProperty(o)&&(e[o]=n(t[o]))}return e}return t}function a(t,e,i){if(!M(e)||!M(t))return i?n(e):t;for(var o in e)if(e.hasOwnProperty(o)){var r=t[o],s=e[o];!M(s)||!M(r)||w(s)||w(r)||I(s)||I(r)||A(s)||A(r)?!i&&o in t||(t[o]=n(e[o],!0)):a(r,s,i)}return t}function o(t,e){for(var i=t[0],n=1,o=t.length;o>n;n++)i=a(i,t[n],e);return i}function r(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}function s(t,e,i){for(var n in e)e.hasOwnProperty(n)&&(i?null!=e[n]:null==t[n])&&(t[n]=e[n]);return t}function l(){return document.createElement("canvas")}function h(){return D||(D=G.createCanvas().getContext("2d")),D}function u(t,e){if(t){if(t.indexOf)return t.indexOf(e);for(var i=0,n=t.length;n>i;i++)if(t[i]===e)return i}return-1}function c(t,e){function i(){}var n=t.prototype;i.prototype=e.prototype,t.prototype=new i;for(var a in n)t.prototype[a]=n[a];t.prototype.constructor=t,t.superClass=e}function d(t,e,i){t="prototype"in t?t.prototype:t,e="prototype"in e?e.prototype:e,s(t,e,i)}function f(t){return t?"string"==typeof t?!1:"number"==typeof t.length:void 0}function p(t,e,i){if(t&&e)if(t.forEach&&t.forEach===R)t.forEach(e,i);else if(t.length===+t.length)for(var n=0,a=t.length;a>n;n++)e.call(i,t[n],n,t);else for(var o in t)t.hasOwnProperty(o)&&e.call(i,t[o],o,t)}function g(t,e,i){if(t&&e){if(t.map&&t.map===N)return t.map(e,i);for(var n=[],a=0,o=t.length;o>a;a++)n.push(e.call(i,t[a],a,t));return n}}function m(t,e,i,n){if(t&&e){if(t.reduce&&t.reduce===B)return t.reduce(e,i,n);for(var a=0,o=t.length;o>a;a++)i=e.call(n,i,t[a],a,t);return i}}function v(t,e,i){if(t&&e){if(t.filter&&t.filter===O)return t.filter(e,i);for(var n=[],a=0,o=t.length;o>a;a++)e.call(i,t[a],a,t)&&n.push(t[a]);return n}}function y(t,e,i){if(t&&e)for(var n=0,a=t.length;a>n;n++)if(e.call(i,t[n],n,t))return t[n]}function x(t,e){var i=V.call(arguments,2);return function(){return t.apply(e,i.concat(V.call(arguments)))}}function _(t){var e=V.call(arguments,1);return function(){return t.apply(this,e.concat(V.call(arguments)))}}function w(t){return"[object Array]"===z.call(t)}function b(t){return"function"==typeof t}function S(t){return"[object String]"===z.call(t)}function M(t){var e=typeof t;return"function"===e||!!t&&"object"==e}function A(t){return!!k[z.call(t)]||t instanceof P}function I(t){return t&&1===t.nodeType&&"string"==typeof t.nodeName}function T(t){for(var e=0,i=arguments.length;i>e;e++)if(null!=arguments[e])return arguments[e]}function C(){return Function.call.apply(V,arguments)}function L(t,e){if(!t)throw new Error(e)}var D,P=i(16),k={"[object Function]":1,"[object RegExp]":1,"[object Date]":1,"[object Error]":1,"[object CanvasGradient]":1},z=Object.prototype.toString,E=Array.prototype,R=E.forEach,O=E.filter,V=E.slice,N=E.map,B=E.reduce,G={inherits:c,mixin:d,clone:n,merge:a,mergeAll:o,extend:r,defaults:s,getContext:h,createCanvas:l,indexOf:u,slice:C,find:y,isArrayLike:f,each:p,map:g,reduce:m,filter:v,bind:x,curry:_,isArray:w,isString:S,isObject:M,isFunction:b,isBuildInObject:A,isDom:I,retrieve:T,assert:L,noop:function(){}};t.exports=G},function(t,e,i){function n(t){return function(e,i,n){e=e&&e.toLowerCase(),L.prototype[t].call(this,e,i,n)}}function a(){L.call(this)}function o(t,e,i){i=i||{},"string"==typeof e&&(e=H[e]),e&&D(F,function(t){t(e)}),this.id,this.group,this._dom=t,this._zr=A.init(t,{renderer:i.renderer||"canvas",devicePixelRatio:i.devicePixelRatio}),this._theme=I.clone(e),this._chartsViews=[],this._chartsMap={},this._componentsViews=[],this._componentsMap={},this._api=new v(this),this._coordSysMgr=new y,L.call(this),this._messageCenter=new a,this._initEvents(),this.resize=I.bind(this.resize,this)}function r(t,e){var i=this._model;i&&i.eachComponent({mainType:"series",query:e},function(n,a){var o=this._chartsMap[n.__viewId];o&&o.__alive&&o[t](n,i,this._api,e)},this)}function s(t,e,i){var n=this._api;D(this._componentsViews,function(a){var o=a.__model;a[t](o,e,n,i),p(o,a)},this),e.eachSeries(function(a,o){var r=this._chartsMap[a.__viewId];r[t](a,e,n,i),p(a,r)},this)}function l(t,e){for(var i="component"===t,n=i?this._componentsViews:this._chartsViews,a=i?this._componentsMap:this._chartsMap,o=this._zr,r=0;r=0?"white":i,o=e.getModel("textStyle");f.extend(t,{textDistance:e.getShallow("distance")||5,textFont:o.getFont(),textPosition:n,textFill:o.getTextColor()||a})},w.updateProps=f.curry(d,!0),w.initProps=f.curry(d,!1),w.getTransform=function(t,e){for(var i=y.identity([]);t&&t!==e;)y.mul(i,t.getLocalTransform(),i),t=t.parent;return i},w.applyTransform=function(t,e,i){return i&&(e=y.invert([],e)),x.applyTransform([],t,e)},w.transformDirection=function(t,e,i){var n=0===e[4]||0===e[5]||0===e[0]?1:Math.abs(2*e[4]/e[0]),a=0===e[4]||0===e[5]||0===e[2]?1:Math.abs(2*e[4]/e[2]),o=["left"===t?-n:"right"===t?n:0,"top"===t?-a:"bottom"===t?a:0];return o=w.applyTransform(o,e,i),Math.abs(o[0])>Math.abs(o[1])?o[0]>0?"right":"left":o[1]>0?"bottom":"top"},t.exports=w},function(t,e){function i(t){return t.replace(/^\s+/,"").replace(/\s+$/,"")}var n={},a=1e-4;n.linearMap=function(t,e,i,n){var a=e[1]-e[0];if(0===a)return(i[0]+i[1])/2;var o=(t-e[0])/a;return n&&(o=Math.min(Math.max(o,0),1)),o*(i[1]-i[0])+i[0]},n.parsePercent=function(t,e){switch(t){case"center":case"middle":t="50%";break;case"left":case"top":t="0%";break;case"right":case"bottom":t="100%"}return"string"==typeof t?i(t).match(/%$/)?parseFloat(t)/100*e:parseFloat(t):null==t?NaN:+t},n.round=function(t){return+(+t).toFixed(12)},n.asc=function(t){return t.sort(function(t,e){return t-e}),t},n.getPrecision=function(t){if(isNaN(t))return 0;for(var e=1,i=0;Math.round(t*e)/e!==t;)e*=10,i++;return i},n.getPixelPrecision=function(t,e){var i=Math.log,n=Math.LN10,a=Math.floor(i(t[1]-t[0])/n),o=Math.round(i(Math.abs(e[1]-e[0]))/n);return Math.max(-a+o,0)},n.MAX_SAFE_INTEGER=9007199254740991,n.remRadian=function(t){var e=2*Math.PI;return(t%e+e)%e},n.isRadianAroundZero=function(t){return t>-a&&a>t},n.parseDate=function(t){return t instanceof Date?t:new Date("string"==typeof t?t.replace(/-/g,"/"):Math.round(t))},n.nice=function(t,e){var i,n=Math.floor(Math.log(t)/Math.LN10),a=Math.pow(10,n),o=t/a;return i=e?1.5>o?1:2.5>o?2:4>o?3:7>o?5:10:1>o?1:2>o?2:3>o?3:5>o?5:10,i*a},t.exports=n},function(t,e){var i="undefined"==typeof Float32Array?Array:Float32Array,n={create:function(t,e){var n=new i(2);return n[0]=t||0,n[1]=e||0,n},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t},clone:function(t){var e=new i(2);return e[0]=t[0],e[1]=t[1],e},set:function(t,e,i){return t[0]=e,t[1]=i,t},add:function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t},scaleAndAdd:function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t},sub:function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t},len:function(t){return Math.sqrt(this.lenSquare(t))},lenSquare:function(t){return t[0]*t[0]+t[1]*t[1]},mul:function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t},div:function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},scale:function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},normalize:function(t,e){var i=n.len(e);return 0===i?(t[0]=0,t[1]=0):(t[0]=e[0]/i,t[1]=e[1]/i),t},distance:function(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))},distanceSquare:function(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])},negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},lerp:function(t,e,i,n){return t[0]=e[0]+n*(i[0]-e[0]),t[1]=e[1]+n*(i[1]-e[1]),t},applyTransform:function(t,e,i){var n=e[0],a=e[1];return t[0]=i[0]*n+i[2]*a+i[4],t[1]=i[1]*n+i[3]*a+i[5],t},min:function(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t},max:function(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t}};n.length=n.len,n.lengthSquare=n.lenSquare,n.dist=n.distance,n.distSquare=n.distanceSquare,t.exports=n},function(t,e,i){function n(t){var e=t.fill;return null!=e&&"none"!==e}function a(t){var e=t.stroke;return null!=e&&"none"!==e&&t.lineWidth>0}function o(t){r.call(this,t),this.path=new l}var r=i(35),s=i(1),l=i(27),h=i(136),u=i(16),c=Math.abs;o.prototype={constructor:o,type:"path",__dirtyPath:!0,strokeContainThreshold:5,brush:function(t){t.save();var e=this.style,i=this.path,o=a(e),r=n(e);this.__dirtyPath&&(r&&e.fill instanceof u&&e.fill.updateCanvasGradient(this,t),o&&e.stroke instanceof u&&e.stroke.updateCanvasGradient(this,t)),e.bind(t,this),this.setTransform(t);var s=e.lineDash,l=e.lineDashOffset,h=!!t.setLineDash;this.__dirtyPath||s&&!h&&o?(i=this.path.beginPath(t),s&&!h&&(i.setLineDash(s),i.setLineDashOffset(l)),this.buildPath(i,this.shape),this.__dirtyPath=!1):(t.beginPath(),this.path.rebuildPath(t)),r&&i.fill(t),s&&h&&(t.setLineDash(s),t.lineDashOffset=l),o&&i.stroke(t),null!=e.text&&this.drawRectText(t,this.getBoundingRect()),t.restore()},buildPath:function(t,e){},getBoundingRect:function(){var t=this._rect,e=this.style;if(!t){var i=this.path;this.__dirtyPath&&(i.beginPath(),this.buildPath(i,this.shape)),t=i.getBoundingRect()}if(a(e)&&(this.__dirty||!this._rect)){var o=this._rectWithStroke||(this._rectWithStroke=t.clone());o.copy(t);var r=e.lineWidth,s=e.strokeNoScale?this.getLineScale():1;return n(e)||(r=Math.max(r,this.strokeContainThreshold)),s>1e-10&&(o.width+=r/s,o.height+=r/s,o.x-=r/s/2,o.y-=r/s/2),o}return this._rect=t,t},contain:function(t,e){var i=this.transformCoordToLocal(t,e),o=this.getBoundingRect(),r=this.style;if(t=i[0],e=i[1],o.contain(t,e)){var s=this.path.data;if(a(r)){var l=r.lineWidth,u=r.strokeNoScale?this.getLineScale():1;if(u>1e-10&&(n(r)||(l=Math.max(l,this.strokeContainThreshold)),h.containStroke(s,l/u,t,e)))return!0}if(n(r))return h.contain(s,t,e)}return!1},dirty:function(t){0===arguments.length&&(t=!0),t&&(this.__dirtyPath=t,this._rect=null),this.__dirty=!0,this.__zr&&this.__zr.refresh(),this.__clipTarget&&this.__clipTarget.dirty()},animateShape:function(t){return this.animate("shape",t)},attrKV:function(t,e){"shape"===t?this.setShape(e):r.prototype.attrKV.call(this,t,e)},setShape:function(t,e){var i=this.shape;if(i){if(s.isObject(t))for(var n in t)i[n]=t[n];else i[t]=e;this.dirty(!0)}return this},getLineScale:function(){var t=this.transform;return t&&c(t[0]-1)>1e-10&&c(t[3]-1)>1e-10?Math.sqrt(c(t[0]*t[3]-t[2]*t[1])):1}},o.extend=function(t){var e=function(e){o.call(this,e),t.style&&this.style.extendFrom(t.style,!1);var i=t.shape;if(i){this.shape=this.shape||{};var n=this.shape;for(var a in i)!n.hasOwnProperty(a)&&i.hasOwnProperty(a)&&(n[a]=i[a])}t.init&&t.init.call(this,e)};s.inherits(e,o);for(var i in t)"style"!==i&&"shape"!==i&&(e.prototype[i]=t[i]);return e},s.inherits(o,r),t.exports=o},function(t,e,i){var n=i(9),a=i(4),o=i(1),r=i(12),s=["x","y","z","radius","angle"],l={};l.createNameEach=function(t,e){t=t.slice();var i=o.map(t,l.capitalFirst);e=(e||[]).slice();var n=o.map(e,l.capitalFirst);return function(a,r){o.each(t,function(t,o){for(var s={name:t,capital:i[o]},l=0;l=0}function a(t,n){var a=!1;return e(function(e){o.each(i(t,e)||[],function(t){n.records[e.name][t]&&(a=!0)})}),a}function r(t,n){n.nodes.push(t),e(function(e){o.each(i(t,e)||[],function(t){n.records[e.name][t]=!0})})}return function(i){function o(t){!n(t,s)&&a(t,s)&&(r(t,s),l=!0)}var s={nodes:[],records:{}};if(e(function(t){s.records[t.name]={}}),!i)return s;r(i,s);var l;do l=!1,t(o);while(l);return s}},l.defaultEmphasis=function(t,e){if(t){var i=t.emphasis=t.emphasis||{},n=t.normal=t.normal||{};o.each(e,function(t){var e=o.retrieve(i[t],n[t]);null!=e&&(i[t]=e)})}},l.createDataFormatModel=function(t,e,i){var n=new r;return o.mixin(n,l.dataFormatMixin),n.seriesIndex=t.seriesIndex,n.name=t.name||"",n.getData=function(){return e},n.getRawDataArray=function(){return i},n},l.getDataItemValue=function(t){return t&&(null==t.value?t:t.value)},l.converDataValue=function(t,e){var i=e&&e.type;return"ordinal"===i?t:("time"!==i||isFinite(t)||null==t||"-"===t||(t=+a.parseDate(t)),null==t||""===t?NaN:+t)},l.dataFormatMixin={getDataParams:function(t){var e=this.getData(),i=this.seriesIndex,n=this.name,a=this.getRawValue(t),o=e.getRawIndex(t),r=e.getName(t,!0),s=this.getRawDataArray(),l=s&&s[o];return{seriesIndex:i,seriesName:n,name:r,dataIndex:o,data:l,value:a,$vars:["seriesName","name","value"]}},getFormattedLabel:function(t,e,i){e=e||"normal";var a=this.getData(),o=a.getItemModel(t),r=this.getDataParams(t);return null==i&&(i=o.get(["label",e,"formatter"])),"function"==typeof i?(r.status=e,i(r)):"string"==typeof i?n.formatTpl(i,r):void 0},getRawValue:function(t){var e=this.getData().getItemModel(t);if(e&&null!=e.option){var i=e.option;return o.isObject(i)&&!o.isArray(i)?i.value:i}}},l.mappingToExists=function(t,e){e=(e||[]).slice();var i=o.map(t||[],function(t,e){return{exist:t}});return o.each(e,function(t,n){if(o.isObject(t))for(var a=0;a=i.length&&i.push({option:t})}}),i},l.isIdInner=function(t){return o.isObject(t)&&t.id&&0===(t.id+"").indexOf("\x00_ec_\x00")},t.exports=l},function(t,e,i){"use strict";function n(t,e,i,n){this.x=t,this.y=e,this.width=i,this.height=n}var a=i(5),o=i(19),r=a.applyTransform,s=Math.min,l=Math.abs,h=Math.max;n.prototype={constructor:n,union:function(t){var e=s(t.x,this.x),i=s(t.y,this.y);this.width=h(t.x+t.width,this.x+this.width)-e,this.height=h(t.y+t.height,this.y+this.height)-i,this.x=e,this.y=i},applyTransform:function(){var t=[],e=[];return function(i){i&&(t[0]=this.x,t[1]=this.y,e[0]=this.x+this.width,e[1]=this.y+this.height,r(t,t,i),r(e,e,i),this.x=s(t[0],e[0]),this.y=s(t[1],e[1]),this.width=l(e[0]-t[0]),this.height=l(e[1]-t[1]))}}(),calculateTransform:function(t){var e=this,i=t.width/e.width,n=t.height/e.height,a=o.create();return o.translate(a,a,[-e.x,-e.y]),o.scale(a,a,[i,n]),o.translate(a,a,[t.x,t.y]),a},intersect:function(t){var e=this,i=e.x,n=e.x+e.width,a=e.y,o=e.y+e.height,r=t.x,s=t.x+t.width,l=t.y,h=t.y+t.height;return!(r>n||i>s||l>o||a>h)},contain:function(t,e){var i=this;return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i.height},clone:function(){return new n(this.x,this.y,this.width,this.height)},copy:function(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}},t.exports=n},function(t,e,i){function n(t){return isNaN(t)?"-":(t=(t+"").split("."),t[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,"$1,")+(t.length>1?"."+t[1]:""))}function a(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function o(t){var e=t.length;return"number"==typeof t?[t,t,t,t]:2===e?[t[0],t[1],t[0],t[1]]:3===e?[t[0],t[1],t[2],t[1]]:t}function r(t){return String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function s(t,e){return"{"+t+(null==e?"":e)+"}"}function l(t,e){c.isArray(e)||(e=[e]);var i=e.length;if(!i)return"";for(var n=e[0].$vars,a=0;ar;r++)for(var l=0;lt?"0"+t:t}var c=i(1),d=i(4),f=["a","b","c","d","e","f","g"];t.exports={normalizeCssArray:o,addCommas:n,toCamelCase:a,encodeHTML:r,formatTpl:l,formatTime:h}},function(t,e,i){function n(t){var e=[];return o.each(u.getClassesByMainType(t),function(t){r.apply(e,t.prototype.dependencies||[])}),o.map(e,function(t){return l.parseClassType(t).main})}var a=i(12),o=i(1),r=Array.prototype.push,s=i(41),l=i(20),h=i(11),u=a.extend({type:"component",id:"",name:"",mainType:"",subType:"",componentIndex:0,defaultOption:null,ecModel:null,dependentModels:[],uid:null,layoutMode:null,init:function(t,e,i,n){this.mergeDefaultAndTheme(this.option,this.ecModel)},mergeDefaultAndTheme:function(t,e){var i=this.layoutMode,n=i?h.getLayoutParams(t):{},a=e.getTheme();o.merge(t,a.get(this.mainType)),o.merge(t,this.getDefaultOption()),i&&h.mergeLayoutParam(t,n,i)},mergeOption:function(t){o.merge(this.option,t,!0);var e=this.layoutMode;e&&h.mergeLayoutParam(this.option,t,e)},optionUpdated:function(t){},getDefaultOption:function(){if(!this.hasOwnProperty("__defaultOption")){for(var t=[],e=this.constructor;e;){var i=e.prototype.defaultOption;i&&t.push(i),e=e.superClass}for(var n={},a=t.length-1;a>=0;a--)n=o.merge(n,t[a],!0);this.__defaultOption=n}return this.__defaultOption}});l.enableClassExtend(u,function(t,e,i,n){o.extend(this,n),this.uid=s.getUID("componentModel"),this.setReadOnly(["type","id","uid","name","mainType","subType","dependentModels","componentIndex"])}),l.enableClassManagement(u,{registerWhenExtend:!0}),s.enableSubTypeDefaulter(u),s.enableTopologicalTravel(u,n),o.mixin(u,i(115)),t.exports=u},function(t,e,i){"use strict";function n(t,e,i,n,a){var o=0,r=0;null==n&&(n=1/0),null==a&&(a=1/0);var s=0;e.eachChild(function(l,h){var u,c,d=l.position,f=l.getBoundingRect(),p=e.childAt(h+1),g=p&&p.getBoundingRect();if("horizontal"===t){var m=f.width+(g?-g.x+f.x:0);u=o+m,u>n||l.newline?(o=0,u=m,r+=s+i,s=f.height):s=Math.max(s,f.height)}else{var v=f.height+(g?-g.y+f.y:0);c=r+v,c>a||l.newline?(o+=s+i,r=0,c=v,s=f.width):s=Math.max(s,f.width)}l.newline||(d[0]=o,d[1]=r,"horizontal"===t?o=u+i:r=c+i)})}var a=i(1),o=i(8),r=i(4),s=i(9),l=r.parsePercent,h=a.each,u={},c=["left","right","top","bottom","width","height"];u.box=n,u.vbox=a.curry(n,"vertical"),u.hbox=a.curry(n,"horizontal"),u.getAvailableSize=function(t,e,i){var n=e.width,a=e.height,o=l(t.x,n),r=l(t.y,a),h=l(t.x2,n),u=l(t.y2,a);return(isNaN(o)||isNaN(parseFloat(t.x)))&&(o=0),(isNaN(h)||isNaN(parseFloat(t.x2)))&&(h=n),(isNaN(r)||isNaN(parseFloat(t.y)))&&(r=0),(isNaN(u)||isNaN(parseFloat(t.y2)))&&(u=a),i=s.normalizeCssArray(i||0),{width:Math.max(h-o-i[1]-i[3],0),height:Math.max(u-r-i[0]-i[2],0)}},u.getLayoutRect=function(t,e,i){i=s.normalizeCssArray(i||0);var n=e.width,a=e.height,r=l(t.left,n),h=l(t.top,a),u=l(t.right,n),c=l(t.bottom,a),d=l(t.width,n),f=l(t.height,a),p=i[2]+i[0],g=i[1]+i[3],m=t.aspect;switch(isNaN(d)&&(d=n-u-g-r),isNaN(f)&&(f=a-c-p-h),isNaN(d)&&isNaN(f)&&(m>n/a?d=.8*n:f=.8*a),null!=m&&(isNaN(d)&&(d=m*f),isNaN(f)&&(f=d/m)),isNaN(r)&&(r=n-u-d-g),isNaN(h)&&(h=a-c-f-p),t.left||t.right){case"center":r=n/2-d/2-i[3];break;case"right":r=n-d-g}switch(t.top||t.bottom){case"middle":case"center":h=a/2-f/2-i[0];break;case"bottom":h=a-f-p}r=r||0,h=h||0,isNaN(d)&&(d=n-r-(u||0)),isNaN(f)&&(f=a-h-(c||0));var v=new o(r+i[3],h+i[0],d,f);return v.margin=i,v},u.positionGroup=function(t,e,i,n){var o=t.getBoundingRect();e=a.extend(a.clone(e),{width:o.width,height:o.height}),e=u.getLayoutRect(e,i,n),t.position=[e.x-o.x,e.y-o.y]},u.mergeLayoutParam=function(t,e,i){function n(n){var a={},s=0,l={},u=0,c=i.ignoreSize?1:2;if(h(n,function(e){l[e]=t[e]}),h(n,function(t){o(e,t)&&(a[t]=l[t]=e[t]),r(a,t)&&s++,r(l,t)&&u++}),u!==c&&s){if(s>=c)return a;for(var d=0;d"+(r?s(r)+" : "+o:o)},restoreData:function(){this._data=this._dataBeforeProcessed.cloneShallow()}});n.mixin(h,o.dataFormatMixin),t.exports=h},function(t,e,i){(function(e){function n(t){return d.isArray(t)||(t=[t]),t}function a(t,e){var i=t.dimensions,n=new v(d.map(i,t.getDimensionInfo,t),t.hostModel);m(n,t,t._wrappedMethods);for(var a=n._storage={},o=t._storage,r=0;r=0?a[s]=new l.constructor(o[s].length):a[s]=o[s]}return n}var o="undefined",r="undefined"==typeof window?e:window,s=typeof r.Float64Array===o?Array:r.Float64Array,l=typeof r.Int32Array===o?Array:r.Int32Array,h={"float":s,"int":l,ordinal:Array,number:Array,time:Array},u=i(12),c=i(52),d=i(1),f=i(7),p=d.isObject,g=["stackedOn","_nameList","_idList","_rawData"],m=function(t,e,i){d.each(g.concat(i||[]),function(i){e.hasOwnProperty(i)&&(t[i]=e[i])})},v=function(t,e){t=t||["x","y"];for(var i={},n=[],a=0;a0&&(w+="__ec__"+u[b]),u[b]++),w&&(l[c]=w)}this._nameList=e,this._idList=l},y.count=function(){return this.indices.length},y.get=function(t,e,i){var n=this._storage,a=this.indices[e];if(null==a)return NaN;var o=n[t]&&n[t][a];if(i){var r=this._dimensionInfos[t];if(r&&r.stackable)for(var s=this.stackedOn;s;){var l=s.get(t,e);(o>=0&&l>0||0>=o&&0>l)&&(o+=l),s=s.stackedOn}}return o},y.getValues=function(t,e,i){var n=[];d.isArray(t)||(i=e,e=t,t=this.dimensions);for(var a=0,o=t.length;o>a;a++)n.push(this.get(t[a],e,i));return n},y.hasValue=function(t){for(var e=this.dimensions,i=this._dimensionInfos,n=0,a=e.length;a>n;n++)if("ordinal"!==i[e[n]].type&&isNaN(this.get(e[n],t)))return!1;return!0},y.getDataExtent=function(t,e){var i=this._storage[t],n=this.getDimensionInfo(t);e=n&&n.stackable&&e;var a,o=(this._extent||(this._extent={}))[t+!!e];if(o)return o;if(i){for(var r=1/0,s=-(1/0),l=0,h=this.count();h>l;l++)a=this.get(t,l,e),r>a&&(r=a),a>s&&(s=a);return this._extent[t+e]=[r,s]}return[1/0,-(1/0)]},y.getSum=function(t,e){var i=this._storage[t],n=0;if(i)for(var a=0,o=this.count();o>a;a++){var r=this.get(t,a,e);isNaN(r)||(n+=r)}return n},y.indexOf=function(t,e){var i=this._storage,n=i[t],a=this.indices;if(n)for(var o=0,r=a.length;r>o;o++){var s=a[o];if(n[s]===e)return o; +}return-1},y.indexOfName=function(t){for(var e=this.indices,i=this._nameList,n=0,a=e.length;a>n;n++){var o=e[n];if(i[o]===t)return n}return-1},y.indexOfNearest=function(t,e,i){var n=this._storage,a=n[t];if(a){for(var o=Number.MAX_VALUE,r=-1,s=0,l=this.count();l>s;s++){var h=Math.abs(this.get(t,s,i)-e);o>=h&&(o=h,r=s)}return r}return-1},y.getRawIndex=function(t){var e=this.indices[t];return null==e?-1:e},y.getName=function(t){return this._nameList[this.indices[t]]||""},y.getId=function(t){return this._idList[this.indices[t]]||this.getRawIndex(t)+""},y.each=function(t,e,i,a){"function"==typeof t&&(a=i,i=e,e=t,t=[]),t=d.map(n(t),this.getDimension,this);var o=[],r=t.length,s=this.indices;a=a||this;for(var l=0;lh;h++)o[h]=this.get(t[h],l,i);o[h]=l,e.apply(a,o)}},y.filterSelf=function(t,e,i,a){"function"==typeof t&&(a=i,i=e,e=t,t=[]),t=d.map(n(t),this.getDimension,this);var o=[],r=[],s=t.length,l=this.indices;a=a||this;for(var h=0;hc;c++)r[c]=this.get(t[c],h,i);r[c]=h,u=e.apply(a,r)}u&&o.push(l[h])}return this.indices=o,this._extent={},this},y.mapArray=function(t,e,i,n){"function"==typeof t&&(n=i,i=e,e=t,t=[]);var a=[];return this.each(t,function(){a.push(e&&e.apply(this,arguments))},i,n),a},y.map=function(t,e,i,o){t=d.map(n(t),this.getDimension,this);var r=a(this,t),s=r.indices=this.indices,l=r._storage,h=[];return this.each(t,function(){var i=arguments[arguments.length-1],n=e&&e.apply(this,arguments);if(null!=n){"number"==typeof n&&(h[0]=n,n=h);for(var a=0;ag;g+=d){d>p-g&&(d=p-g,u.length=d);for(var m=0;d>m;m++){var v=l[g+m];u[m]=f[v],c[m]=v}var y=i(u),v=c[n(u,y)||0];f[v]=y,h.push(v)}return o},y.getItemModel=function(t){var e=this.hostModel;return t=this.indices[t],new u(this._rawData[t],e,e.ecModel)},y.diff=function(t){var e=this._idList,i=t&&t._idList;return new c(t?t.indices:[],this.indices,function(t){return i[t]||t+""},function(t){return e[t]||t+""})},y.getVisual=function(t){var e=this._visual;return e&&e[t]},y.setVisual=function(t,e){if(p(t))for(var i in t)t.hasOwnProperty(i)&&this.setVisual(i,t[i]);else this._visual=this._visual||{},this._visual[t]=e},y.setLayout=function(t,e){if(p(t))for(var i in t)t.hasOwnProperty(i)&&this.setLayout(i,t[i]);else this._layout[t]=e},y.getLayout=function(t){return this._layout[t]},y.getItemLayout=function(t){return this._itemLayouts[t]},y.setItemLayout=function(t,e,i){this._itemLayouts[t]=i?d.extend(this._itemLayouts[t]||{},e):e},y.getItemVisual=function(t,e,i){var n=this._itemVisuals[t],a=n&&n[e];return null!=a||i?a:this.getVisual(e)},y.setItemVisual=function(t,e,i){var n=this._itemVisuals[t]||{};if(this._itemVisuals[t]=n,p(e))for(var a in e)e.hasOwnProperty(a)&&(n[a]=e[a]);else n[e]=i};var x=function(t){t.seriesIndex=this.seriesIndex,t.dataIndex=this.dataIndex};y.setItemGraphicEl=function(t,e){var i=this.hostModel;e&&(e.dataIndex=t,e.seriesIndex=i&&i.seriesIndex,"group"===e.type&&e.traverse(x,e)),this._graphicEls[t]=e},y.getItemGraphicEl=function(t){return this._graphicEls[t]},y.eachItemGraphicEl=function(t,e){d.each(this._graphicEls,function(i,n){i&&t&&t.call(e,i,n)})},y.cloneShallow=function(){var t=d.map(this.dimensions,this.getDimensionInfo,this),e=new v(t,this.hostModel);return e._storage=this._storage,m(e,this,this._wrappedMethods),e.indices=this.indices.slice(),e},y.wrapMethod=function(t,e){var i=this[t];"function"==typeof i&&(this._wrappedMethods=this._wrappedMethods||[],this._wrappedMethods.push(t),this[t]=function(){var t=i.apply(this,arguments);return e.call(this,t)})},t.exports=v}).call(e,function(){return this}())},function(t,e){function i(t){var e={},i={},n=t.match(/Web[kK]it[\/]{0,1}([\d.]+)/),a=t.match(/(Android);?[\s\/]+([\d.]+)?/),o=t.match(/(iPad).*OS\s([\d_]+)/),r=t.match(/(iPod)(.*OS\s([\d_]+))?/),s=!o&&t.match(/(iPhone\sOS)\s([\d_]+)/),l=t.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),h=l&&t.match(/TouchPad/),u=t.match(/Kindle\/([\d.]+)/),c=t.match(/Silk\/([\d._]+)/),d=t.match(/(BlackBerry).*Version\/([\d.]+)/),f=t.match(/(BB10).*Version\/([\d.]+)/),p=t.match(/(RIM\sTablet\sOS)\s([\d.]+)/),g=t.match(/PlayBook/),m=t.match(/Chrome\/([\d.]+)/)||t.match(/CriOS\/([\d.]+)/),v=t.match(/Firefox\/([\d.]+)/),y=n&&t.match(/Mobile\//)&&!m,x=t.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/)&&!m,_=t.match(/MSIE\s([\d.]+)/)||t.match(/Trident\/.+?rv:(([\d.]+))/),w=t.match(/Edge\/([\d.]+)/);return(i.webkit=!!n)&&(i.version=n[1]),a&&(e.android=!0,e.version=a[2]),s&&!r&&(e.ios=e.iphone=!0,e.version=s[2].replace(/_/g,".")),o&&(e.ios=e.ipad=!0,e.version=o[2].replace(/_/g,".")),r&&(e.ios=e.ipod=!0,e.version=r[3]?r[3].replace(/_/g,"."):null),l&&(e.webos=!0,e.version=l[2]),h&&(e.touchpad=!0),d&&(e.blackberry=!0,e.version=d[2]),f&&(e.bb10=!0,e.version=f[2]),p&&(e.rimtabletos=!0,e.version=p[2]),g&&(i.playbook=!0),u&&(e.kindle=!0,e.version=u[1]),c&&(i.silk=!0,i.version=c[1]),!c&&e.android&&t.match(/Kindle Fire/)&&(i.silk=!0),m&&(i.chrome=!0,i.version=m[1]),v&&(i.firefox=!0,i.version=v[1]),_&&(i.ie=!0,i.version=_[1]),y&&(t.match(/Safari/)||e.ios)&&(i.safari=!0),x&&(i.webview=!0),_&&(i.ie=!0,i.version=_[1]),w&&(i.edge=!0,i.version=w[1]),e.tablet=!!(o||g||a&&!t.match(/Mobile/)||v&&t.match(/Tablet/)||_&&!t.match(/Phone/)&&t.match(/Touch/)),e.phone=!(e.tablet||e.ipod||!(a||s||l||d||f||m&&t.match(/Android/)||m&&t.match(/CriOS\/([\d.]+)/)||v&&t.match(/Mobile/)||_&&t.match(/Touch/))),{browser:i,os:e,node:!1,canvasSupported:!!document.createElement("canvas").getContext,touchEventsSupported:"ontouchstart"in window&&!i.ie&&!i.edge,pointerEventsSupported:"onpointerdown"in window&&(i.edge||i.ie&&i.version>=10)}}var n={};n="undefined"==typeof navigator?{browser:{},os:{},node:!0,canvasSupported:!0}:i(navigator.userAgent),t.exports=n},function(t,e){var i=function(t){this.colorStops=t||[]};i.prototype={constructor:i,addColorStop:function(t,e){this.colorStops.push({offset:t,color:e})}},t.exports=i},function(t,e,i){function n(t,e){var i=t+":"+e;if(h[i])return h[i];for(var n=(t+"").split("\n"),a=0,o=0,r=n.length;r>o;o++)a=Math.max(p.measureText(n[o],e).width,a);return u>c&&(u=0,h={}),u++,h[i]=a,a}function a(t,e,i,a){var o=((t||"")+"").split("\n").length,r=n(t,e),s=n("国",e),l=o*s,h=new f(0,0,r,l);switch(h.lineHeight=s,a){case"bottom":case"alphabetic":h.y-=s;break;case"middle":h.y-=s/2}switch(i){case"end":case"right":h.x-=h.width;break;case"center":h.x-=h.width/2}return h}function o(t,e,i,n){var a=e.x,o=e.y,r=e.height,s=e.width,l=i.height,h=r/2-l/2,u="left";switch(t){case"left":a-=n,o+=h,u="right";break;case"right":a+=n+s,o+=h,u="left";break;case"top":a+=s/2,o-=n+l,u="center";break;case"bottom":a+=s/2,o+=r+n,u="center";break;case"inside":a+=s/2,o+=h,u="center";break;case"insideLeft":a+=n,o+=h,u="left";break;case"insideRight":a+=s-n,o+=h,u="right";break;case"insideTop":a+=s/2,o+=n,u="center";break;case"insideBottom":a+=s/2,o+=r-l-n,u="center";break;case"insideTopLeft":a+=n,o+=n,u="left";break;case"insideTopRight":a+=s-n,o+=n,u="right";break;case"insideBottomLeft":a+=n,o+=r-l-n;break;case"insideBottomRight":a+=s-n,o+=r-l-n,u="right"}return{x:a,y:o,textAlign:u,textBaseline:"top"}}function r(t,e,i,a){if(!i)return"";a=d.defaults({ellipsis:"...",minCharacters:3,maxIterations:3,cnCharWidth:n("国",e),ascCharWidth:n("a",e)},a,!0),i-=n(a.ellipsis);for(var o=(t+"").split("\n"),r=0,l=o.length;l>r;r++)o[r]=s(o[r],e,i,a);return o.join("\n")}function s(t,e,i,a){for(var o=0;;o++){var r=n(t,e);if(i>r||o>=a.maxIterations){t+=a.ellipsis;break}var s=0===o?l(t,i,a):Math.floor(t.length*i/r);if(sa&&e>n;a++){var r=t.charCodeAt(a);n+=r>=0&&127>=r?i.ascCharWidth:i.cnCharWidth}return a}var h={},u=0,c=5e3,d=i(1),f=i(8),p={getWidth:n,getBoundingRect:a,adjustTextPositionOnRect:o,ellipsis:r,measureText:function(t,e){var i=d.getContext();return i.font=e,i.measureText(t)}};t.exports=p},function(t,e,i){"use strict";function n(t){return t>-b&&b>t}function a(t){return t>b||-b>t}function o(t,e,i,n,a){var o=1-a;return o*o*(o*t+3*a*e)+a*a*(a*n+3*o*i)}function r(t,e,i,n,a){var o=1-a;return 3*(((e-t)*o+2*(i-e)*a)*o+(n-i)*a*a)}function s(t,e,i,a,o,r){var s=a+3*(e-i)-t,l=3*(i-2*e+t),h=3*(e-t),u=t-o,c=l*l-3*s*h,d=l*h-9*s*u,f=h*h-3*l*u,p=0;if(n(c)&&n(d))if(n(l))r[0]=0;else{var g=-h/l;g>=0&&1>=g&&(r[p++]=g)}else{var m=d*d-4*c*f;if(n(m)){var v=d/c,g=-l/s+v,y=-v/2;g>=0&&1>=g&&(r[p++]=g),y>=0&&1>=y&&(r[p++]=y)}else if(m>0){var x=w(m),b=c*l+1.5*s*(-d+x),A=c*l+1.5*s*(-d-x);b=0>b?-_(-b,M):_(b,M),A=0>A?-_(-A,M):_(A,M);var g=(-l-(b+A))/(3*s);g>=0&&1>=g&&(r[p++]=g)}else{var I=(2*c*l-3*s*d)/(2*w(c*c*c)),T=Math.acos(I)/3,C=w(c),L=Math.cos(T),g=(-l-2*C*L)/(3*s),y=(-l+C*(L+S*Math.sin(T)))/(3*s),D=(-l+C*(L-S*Math.sin(T)))/(3*s);g>=0&&1>=g&&(r[p++]=g),y>=0&&1>=y&&(r[p++]=y),D>=0&&1>=D&&(r[p++]=D)}}return p}function l(t,e,i,o,r){var s=6*i-12*e+6*t,l=9*e+3*o-3*t-9*i,h=3*e-3*t,u=0;if(n(l)){if(a(s)){var c=-h/s;c>=0&&1>=c&&(r[u++]=c)}}else{var d=s*s-4*l*h;if(n(d))r[0]=-s/(2*l);else if(d>0){var f=w(d),c=(-s+f)/(2*l),p=(-s-f)/(2*l);c>=0&&1>=c&&(r[u++]=c),p>=0&&1>=p&&(r[u++]=p)}}return u}function h(t,e,i,n,a,o){var r=(e-t)*a+t,s=(i-e)*a+e,l=(n-i)*a+i,h=(s-r)*a+r,u=(l-s)*a+s,c=(u-h)*a+h;o[0]=t,o[1]=r,o[2]=h,o[3]=c,o[4]=c,o[5]=u,o[6]=l,o[7]=n}function u(t,e,i,n,a,r,s,l,h,u,c){var d,f,p,g,m,v=.005,y=1/0;A[0]=h,A[1]=u;for(var _=0;1>_;_+=.05)I[0]=o(t,i,a,s,_),I[1]=o(e,n,r,l,_),g=x(A,I),y>g&&(d=_,y=g);y=1/0;for(var S=0;32>S&&!(b>v);S++)f=d-v,p=d+v,I[0]=o(t,i,a,s,f),I[1]=o(e,n,r,l,f),g=x(I,A),f>=0&&y>g?(d=f,y=g):(T[0]=o(t,i,a,s,p),T[1]=o(e,n,r,l,p),m=x(T,A),1>=p&&y>m?(d=p,y=m):v*=.5);return c&&(c[0]=o(t,i,a,s,d),c[1]=o(e,n,r,l,d)),w(y)}function c(t,e,i,n){var a=1-n;return a*(a*t+2*n*e)+n*n*i}function d(t,e,i,n){return 2*((1-n)*(e-t)+n*(i-e))}function f(t,e,i,o,r){var s=t-2*e+i,l=2*(e-t),h=t-o,u=0;if(n(s)){if(a(l)){var c=-h/l;c>=0&&1>=c&&(r[u++]=c)}}else{var d=l*l-4*s*h;if(n(d)){var c=-l/(2*s);c>=0&&1>=c&&(r[u++]=c)}else if(d>0){var f=w(d),c=(-l+f)/(2*s),p=(-l-f)/(2*s);c>=0&&1>=c&&(r[u++]=c),p>=0&&1>=p&&(r[u++]=p)}}return u}function p(t,e,i){var n=t+i-2*e;return 0===n?.5:(t-e)/n}function g(t,e,i,n,a){var o=(e-t)*n+t,r=(i-e)*n+e,s=(r-o)*n+o;a[0]=t,a[1]=o,a[2]=s,a[3]=s,a[4]=r,a[5]=i}function m(t,e,i,n,a,o,r,s,l){var h,u=.005,d=1/0;A[0]=r,A[1]=s;for(var f=0;1>f;f+=.05){I[0]=c(t,i,a,f),I[1]=c(e,n,o,f);var p=x(A,I);d>p&&(h=f,d=p)}d=1/0;for(var g=0;32>g&&!(b>u);g++){var m=h-u,v=h+u;I[0]=c(t,i,a,m),I[1]=c(e,n,o,m);var p=x(I,A);if(m>=0&&d>p)h=m,d=p;else{T[0]=c(t,i,a,v),T[1]=c(e,n,o,v);var y=x(T,A);1>=v&&d>y?(h=v,d=y):u*=.5}}return l&&(l[0]=c(t,i,a,h),l[1]=c(e,n,o,h)),w(d)}var v=i(5),y=v.create,x=v.distSquare,_=Math.pow,w=Math.sqrt,b=1e-4,S=w(3),M=1/3,A=y(),I=y(),T=y();t.exports={cubicAt:o,cubicDerivativeAt:r,cubicRootAt:s,cubicExtrema:l,cubicSubdivide:h,cubicProjectPoint:u,quadraticAt:c,quadraticDerivativeAt:d,quadraticRootAt:f,quadraticExtremum:p,quadraticSubdivide:g,quadraticProjectPoint:m}},function(t,e){var i="undefined"==typeof Float32Array?Array:Float32Array,n={create:function(){var t=new i(6);return n.identity(t),t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},mul:function(t,e,i){var n=e[0]*i[0]+e[2]*i[1],a=e[1]*i[0]+e[3]*i[1],o=e[0]*i[2]+e[2]*i[3],r=e[1]*i[2]+e[3]*i[3],s=e[0]*i[4]+e[2]*i[5]+e[4],l=e[1]*i[4]+e[3]*i[5]+e[5];return t[0]=n,t[1]=a,t[2]=o,t[3]=r,t[4]=s,t[5]=l,t},translate:function(t,e,i){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4]+i[0],t[5]=e[5]+i[1],t},rotate:function(t,e,i){var n=e[0],a=e[2],o=e[4],r=e[1],s=e[3],l=e[5],h=Math.sin(i),u=Math.cos(i);return t[0]=n*u+r*h,t[1]=-n*h+r*u,t[2]=a*u+s*h,t[3]=-a*h+u*s,t[4]=u*o+h*l,t[5]=u*l-h*o,t},scale:function(t,e,i){var n=i[0],a=i[1];return t[0]=e[0]*n,t[1]=e[1]*a,t[2]=e[2]*n,t[3]=e[3]*a,t[4]=e[4]*n,t[5]=e[5]*a,t},invert:function(t,e){var i=e[0],n=e[2],a=e[4],o=e[1],r=e[3],s=e[5],l=i*r-o*n;return l?(l=1/l,t[0]=r*l,t[1]=-o*l,t[2]=-n*l,t[3]=i*l,t[4]=(n*s-r*a)*l,t[5]=(o*a-i*s)*l,t):null}};t.exports=n},function(t,e,i){function n(t,e){var i=o.slice(arguments,2);return this.superClass.prototype[e].apply(t,i)}function a(t,e,i){return this.superClass.prototype[e].apply(t,i)}var o=i(1),r={},s=".",l="___EC__COMPONENT__CONTAINER___",h=r.parseClassType=function(t){var e={main:"",sub:""};return t&&(t=t.split(s),e.main=t[0]||"",e.sub=t[1]||""),e};r.enableClassExtend=function(t,e){t.extend=function(i){var r=function(){e&&e.apply(this,arguments),t.apply(this,arguments)};return o.extend(r.prototype,i),r.extend=this.extend,r.superCall=n,r.superApply=a,o.inherits(r,this),r.superClass=this,r}},r.enableClassManagement=function(t,e){function i(t){var e=n[t.main];return e&&e[l]||(e=n[t.main]={},e[l]=!0),e}e=e||{};var n={};if(t.registerClass=function(t,e){if(e)if(e=h(e),e.sub){if(e.sub!==l){var a=i(e);a[e.sub]=t}}else{if(n[e.main])throw new Error(e.main+"exists");n[e.main]=t}return t},t.getClass=function(t,e,i){var a=n[t];if(a&&a[l]&&(a=e?a[e]:null),i&&!a)throw new Error("Component "+t+"."+(e||"")+" not exists");return a},t.getClassesByMainType=function(t){t=h(t);var e=[],i=n[t.main];return i&&i[l]?o.each(i,function(t,i){i!==l&&e.push(t)}):e.push(i),e},t.hasClass=function(t){return t=h(t),!!n[t.main]},t.getAllClassMainTypes=function(){var t=[];return o.each(n,function(e,i){t.push(i)}),t},t.hasSubTypes=function(t){t=h(t);var e=n[t.main];return e&&e[l]},t.parseClassType=h,e.registerWhenExtend){var a=t.extend;a&&(t.extend=function(e){var i=a.call(this,e);return t.registerClass(i,e.type)})}return t},r.setReadOnly=function(t,e){},t.exports=r},function(t,e,i){var n=Array.prototype.slice,a=i(1),o=a.indexOf,r=function(){this._$handlers={}};r.prototype={constructor:r,one:function(t,e,i){var n=this._$handlers;return e&&t?(n[t]||(n[t]=[]),o(n[t],t)>=0?this:(n[t].push({h:e,one:!0,ctx:i||this}),this)):this},on:function(t,e,i){var n=this._$handlers;return e&&t?(n[t]||(n[t]=[]),n[t].push({h:e,one:!1,ctx:i||this}),this):this},isSilent:function(t){var e=this._$handlers;return e[t]&&e[t].length},off:function(t,e){var i=this._$handlers;if(!t)return this._$handlers={},this;if(e){if(i[t]){for(var n=[],a=0,o=i[t].length;o>a;a++)i[t][a].h!=e&&n.push(i[t][a]);i[t]=n}i[t]&&0===i[t].length&&delete i[t]}else delete i[t];return this},trigger:function(t){if(this._$handlers[t]){var e=arguments,i=e.length;i>3&&(e=n.call(e,1));for(var a=this._$handlers[t],o=a.length,r=0;o>r;){switch(i){case 1:a[r].h.call(a[r].ctx);break;case 2:a[r].h.call(a[r].ctx,e[1]);break;case 3:a[r].h.call(a[r].ctx,e[1],e[2]);break;default:a[r].h.apply(a[r].ctx,e)}a[r].one?(a.splice(r,1),o--):r++}}return this},triggerWithContext:function(t){if(this._$handlers[t]){var e=arguments,i=e.length;i>4&&(e=n.call(e,1,e.length-1));for(var a=e[e.length-1],o=this._$handlers[t],r=o.length,s=0;r>s;){switch(i){case 1:o[s].h.call(a);break;case 2:o[s].h.call(a,e[1]);break;case 3:o[s].h.call(a,e[1],e[2]);break;default:o[s].h.apply(a,e)}o[s].one?(o.splice(s,1),r--):s++}}return this}},t.exports=r},function(t,e){function i(t){return t=Math.round(t),0>t?0:t>255?255:t}function n(t){return t=Math.round(t),0>t?0:t>360?360:t}function a(t){return 0>t?0:t>1?1:t}function o(t){return i(t.length&&"%"===t.charAt(t.length-1)?parseFloat(t)/100*255:parseInt(t,10))}function r(t){return a(t.length&&"%"===t.charAt(t.length-1)?parseFloat(t)/100:parseFloat(t))}function s(t,e,i){return 0>i?i+=1:i>1&&(i-=1),1>6*i?t+(e-t)*i*6:1>2*i?e:2>3*i?t+(e-t)*(2/3-i)*6:t}function l(t,e,i){return t+(e-t)*i}function h(t){if(t){t+="";var e=t.replace(/ /g,"").toLowerCase();if(e in _)return _[e].slice();if("#"!==e.charAt(0)){var i=e.indexOf("("),n=e.indexOf(")");if(-1!==i&&n+1===e.length){var a=e.substr(0,i),s=e.substr(i+1,n-(i+1)).split(","),l=1;switch(a){case"rgba":if(4!==s.length)return;l=r(s.pop());case"rgb":if(3!==s.length)return;return[o(s[0]),o(s[1]),o(s[2]),l];case"hsla":if(4!==s.length)return;return s[3]=r(s[3]),u(s);case"hsl":if(3!==s.length)return;return u(s);default:return}}}else{if(4===e.length){var h=parseInt(e.substr(1),16);if(!(h>=0&&4095>=h))return;return[(3840&h)>>4|(3840&h)>>8,240&h|(240&h)>>4,15&h|(15&h)<<4,1]}if(7===e.length){var h=parseInt(e.substr(1),16);if(!(h>=0&&16777215>=h))return;return[(16711680&h)>>16,(65280&h)>>8,255&h,1]}}}}function u(t){var e=(parseFloat(t[0])%360+360)%360/360,n=r(t[1]),a=r(t[2]),o=.5>=a?a*(n+1):a+n-a*n,l=2*a-o,h=[i(255*s(l,o,e+1/3)),i(255*s(l,o,e)),i(255*s(l,o,e-1/3))];return 4===t.length&&(h[3]=t[3]),h}function c(t){if(t){var e,i,n=t[0]/255,a=t[1]/255,o=t[2]/255,r=Math.min(n,a,o),s=Math.max(n,a,o),l=s-r,h=(s+r)/2;if(0===l)e=0,i=0;else{i=.5>h?l/(s+r):l/(2-s-r);var u=((s-n)/6+l/2)/l,c=((s-a)/6+l/2)/l,d=((s-o)/6+l/2)/l;n===s?e=d-c:a===s?e=1/3+u-d:o===s&&(e=2/3+c-u),0>e&&(e+=1),e>1&&(e-=1)}var f=[360*e,i,h];return null!=t[3]&&f.push(t[3]),f}}function d(t,e){var i=h(t);if(i){for(var n=0;3>n;n++)0>e?i[n]=i[n]*(1-e)|0:i[n]=(255-i[n])*e+i[n]|0;return x(i,4===i.length?"rgba":"rgb")}}function f(t,e){var i=h(t);return i?((1<<24)+(i[0]<<16)+(i[1]<<8)+ +i[2]).toString(16).slice(1):void 0}function p(t,e,n){if(e&&e.length&&t>=0&&1>=t){n=n||[0,0,0,0];var a=t*(e.length-1),o=Math.floor(a),r=Math.ceil(a),s=e[o],h=e[r],u=a-o;return n[0]=i(l(s[0],h[0],u)),n[1]=i(l(s[1],h[1],u)),n[2]=i(l(s[2],h[2],u)),n[3]=i(l(s[3],h[3],u)),n}}function g(t,e,n){if(e&&e.length&&t>=0&&1>=t){var o=t*(e.length-1),r=Math.floor(o),s=Math.ceil(o),u=h(e[r]),c=h(e[s]),d=o-r,f=x([i(l(u[0],c[0],d)),i(l(u[1],c[1],d)),i(l(u[2],c[2],d)),a(l(u[3],c[3],d))],"rgba");return n?{color:f,leftIndex:r,rightIndex:s,value:o}:f}}function m(t,e){if(!(2!==t.length||t[1]0&&s>=l;l++)a.push({color:e[l],offset:(l-i.value)/o});return a.push({color:n.color,offset:1}),a}}function v(t,e,i,a){return t=h(t),t?(t=c(t),null!=e&&(t[0]=n(e)),null!=i&&(t[1]=r(i)),null!=a&&(t[2]=r(a)),x(u(t),"rgba")):void 0}function y(t,e){return t=h(t),t&&null!=e?(t[3]=a(e),x(t,"rgba")):void 0}function x(t,e){return"rgb"!==e&&"hsv"!==e&&"hsl"!==e||(t=t.slice(0,3)),e+"("+t.join(",")+")"}var _={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};t.exports={parse:h,lift:d,toHex:f,fastMapToColor:p,mapToColor:g,mapIntervalToColor:m,modifyHSL:v,modifyAlpha:y,stringify:x}},function(t,e,i){var n=i(123),a=i(37);i(124),i(122);var o=i(32),r=i(4),s=i(1),l=i(17),h={};h.getScaleExtent=function(t,e){var i=t.scale,n=i.getExtent(),a=n[1]-n[0];if("ordinal"===i.type)return isFinite(a)?n:[0,0];var o=e.getMin?e.getMin():e.get("min"),l=e.getMax?e.getMax():e.get("max"),h=e.getNeedCrossZero?e.getNeedCrossZero():!e.get("scale"),u=e.get("boundaryGap");s.isArray(u)||(u=[u||0,u||0]),u[0]=r.parsePercent(u[0],1),u[1]=r.parsePercent(u[1],1);var c=!0,d=!0;return null==o&&(o=n[0]-u[0]*a,c=!1),null==l&&(l=n[1]+u[1]*a,d=!1),"dataMin"===o&&(o=n[0]),"dataMax"===l&&(l=n[1]),h&&(o>0&&l>0&&!c&&(o=0),0>o&&0>l&&!d&&(l=0)),[o,l]},h.niceScaleExtent=function(t,e){var i=t.scale,n=h.getScaleExtent(t,e),a=null!=e.get("min"),o=null!=e.get("max");i.setExtent(n[0],n[1]),i.niceExtent(e.get("splitNumber"),a,o);var r=e.get("interval");null!=r&&i.setInterval&&i.setInterval(r)},h.createScaleByModel=function(t,e){if(e=e||t.get("type"))switch(e){case"category":return new n(t.getCategories(),[1/0,-(1/0)]);case"value":return new a;default:return(o.getClass(e)||a).create(t)}},h.ifAxisCrossZero=function(t){var e=t.scale.getExtent(),i=e[0],n=e[1];return!(i>0&&n>0||0>i&&0>n)},h.getAxisLabelInterval=function(t,e,i,n){var a,o=0,r=0,s=1;e.length>40&&(s=Math.round(e.length/40));for(var h=0;h1?s:o*s},h.getFormattedLabels=function(t,e){var i=t.scale,n=i.getTicksLabels(),a=i.getTicks();return"string"==typeof e?(e=function(t){return function(e){return t.replace("{value}",e)}}(e),s.map(n,e)):"function"==typeof e?s.map(a,function(n,a){return e("category"===t.type?i.getLabel(n):n,a)},this):n},t.exports=h},function(t,e,i){"use strict";var n=i(3),a=i(8),o=n.extendShape({type:"triangle",shape:{cx:0,cy:0,width:0,height:0},buildPath:function(t,e){var i=e.cx,n=e.cy,a=e.width/2,o=e.height/2;t.moveTo(i,n-o),t.lineTo(i+a,n+o),t.lineTo(i-a,n+o),t.closePath()}}),r=n.extendShape({type:"diamond",shape:{cx:0,cy:0,width:0,height:0},buildPath:function(t,e){var i=e.cx,n=e.cy,a=e.width/2,o=e.height/2;t.moveTo(i,n-o),t.lineTo(i+a,n),t.lineTo(i,n+o),t.lineTo(i-a,n),t.closePath()}}),s=n.extendShape({type:"pin",shape:{x:0,y:0,width:0,height:0},buildPath:function(t,e){var i=e.x,n=e.y,a=e.width/5*3,o=Math.max(a,e.height),r=a/2,s=r*r/(o-r),l=n-o+r+s,h=Math.asin(s/r),u=Math.cos(h)*r,c=Math.sin(h),d=Math.cos(h);t.arc(i,l,r,Math.PI-h,2*Math.PI+h);var f=.6*r,p=.7*r;t.bezierCurveTo(i+u-c*f,l+s+d*f,i,n-p,i,n),t.bezierCurveTo(i,n-p,i-u+c*f,l+s+d*f,i-u,l+s),t.closePath()}}),l=n.extendShape({type:"arrow",shape:{x:0,y:0,width:0,height:0},buildPath:function(t,e){var i=e.height,n=e.width,a=e.x,o=e.y,r=n/3*2;t.moveTo(a,o),t.lineTo(a+r,o+i),t.lineTo(a,o+i/4*3),t.lineTo(a-r,o+i),t.lineTo(a,o),t.closePath()}}),h={line:n.Line,rect:n.Rect,roundRect:n.Rect,square:n.Rect,circle:n.Circle,diamond:r,pin:s,arrow:l,triangle:o},u={line:function(t,e,i,n,a){a.x1=t,a.y1=e+n/2,a.x2=t+i,a.y2=e+n/2},rect:function(t,e,i,n,a){a.x=t,a.y=e,a.width=i,a.height=n},roundRect:function(t,e,i,n,a){a.x=t,a.y=e,a.width=i,a.height=n,a.r=Math.min(i,n)/4},square:function(t,e,i,n,a){var o=Math.min(i,n);a.x=t,a.y=e,a.width=o,a.height=o},circle:function(t,e,i,n,a){a.cx=t+i/2,a.cy=e+n/2,a.r=Math.min(i,n)/2},diamond:function(t,e,i,n,a){a.cx=t+i/2,a.cy=e+n/2,a.width=i,a.height=n},pin:function(t,e,i,n,a){a.x=t+i/2,a.y=e+n/2,a.width=i,a.height=n},arrow:function(t,e,i,n,a){a.x=t+i/2,a.y=e+n/2,a.width=i,a.height=n},triangle:function(t,e,i,n,a){a.cx=t+i/2,a.cy=e+n/2,a.width=i,a.height=n}},c={};for(var d in h)c[d]=new h[d];var f=n.extendShape({type:"symbol",shape:{symbolType:"",x:0,y:0,width:0,height:0},beforeBrush:function(){var t=this.style,e=this.shape;"pin"===e.symbolType&&"inside"===t.textPosition&&(t.textPosition=["50%","40%"],t.textAlign="center",t.textVerticalAlign="middle")},buildPath:function(t,e){var i=e.symbolType,n=c[i];"none"!==e.symbolType&&(n||(i="rect",n=c[i]),u[i](e.x,e.y,e.width,e.height,n.shape),n.buildPath(t,n.shape))}}),p=function(t){if("image"!==this.type){var e=this.style,i=this.shape;i&&"line"===i.symbolType?e.stroke=t:this.__isEmptyBrush?(e.stroke=t,e.fill="#fff"):(e.fill&&(e.fill=t),e.stroke&&(e.stroke=t)),this.dirty()}},g={createSymbol:function(t,e,i,o,r,s){var l=0===t.indexOf("empty");l&&(t=t.substr(5,1).toLowerCase()+t.substr(6));var h;return h=0===t.indexOf("image://")?new n.Image({style:{image:t.slice(8),x:e,y:i,width:o,height:r}}):0===t.indexOf("path://")?n.makePath(t.slice(7),{},new a(e,i,o,r)):new f({shape:{symbolType:t,x:e,y:i,width:o,height:r}}),h.__isEmptyBrush=l,h.setColor=p,h.setColor(s),h}};t.exports=g},function(t,e,i){function n(){this.group=new r,this.uid=s.getUID("viewChart")}function a(t,e){if(t&&(t.trigger(e),"group"===t.type))for(var i=0;i=0&&(i.splice(n,0,t),this._doAdd(t))}return this},_doAdd:function(t){t.parent&&t.parent.remove(t),t.parent=this;var e=this.__storage,i=this.__zr;e&&e!==t.__storage&&(e.addToMap(t),t instanceof r&&t.addChildrenToStorage(e)),i&&i.refresh()},remove:function(t){var e=this.__zr,i=this.__storage,a=this._children,o=n.indexOf(a,t);return 0>o?this:(a.splice(o,1),t.parent=null,i&&(i.delFromMap(t.id),t instanceof r&&t.delChildrenFromStorage(i)),e&&e.refresh(),this)},removeAll:function(){var t,e,i=this._children,n=this.__storage;for(e=0;ei;i++)this.data[i]=t[i];this._len=e},appendPath:function(t){t instanceof Array||(t=[t]);for(var e=t.length,i=0,n=this._len,a=0;e>a;a++)i+=t[a].len();v&&this.data instanceof Float32Array&&(this.data=new Float32Array(n+i));for(var a=0;e>a;a++)for(var o=t[a].data,r=0;re.length&&(this._expandData(),e=this.data);for(var i=0;io&&(o=a+o),o%=a,g-=o*u,v-=o*c;u>=0&&t>=g||0>u&&g>t;)n=this._dashIdx,i=r[n],g+=u*i,v+=c*i,this._dashIdx=(n+1)%y,u>0&&l>g||0>u&&g>l||s[n%2?"moveTo":"lineTo"](u>=0?d(g,t):f(g,t),c>=0?d(v,e):f(v,e));u=g-t,c=v-e,this._dashOffset=-m(u*u+c*c)},_dashedBezierTo:function(t,e,i,a,o,r){var s,l,h,u,c,d=this._dashSum,f=this._dashOffset,p=this._lineDash,g=this._ctx,v=this._xi,y=this._yi,x=n.cubicAt,_=0,w=this._dashIdx,b=p.length,S=0;for(0>f&&(f=d+f),f%=d,s=0;1>s;s+=.1)l=x(v,t,i,o,s+.1)-x(v,t,i,o,s),h=x(y,e,a,r,s+.1)-x(y,e,a,r,s),_+=m(l*l+h*h);for(;b>w&&(S+=p[w],!(S>f));w++);for(s=(S-f)/_;1>=s;)u=x(v,t,i,o,s),c=x(y,e,a,r,s),w%2?g.moveTo(u,c):g.lineTo(u,c),s+=p[w]/_,w=(w+1)%b;w%2!==0&&g.lineTo(o,r),l=o-u,h=r-c,this._dashOffset=-m(l*l+h*h)},_dashedQuadraticTo:function(t,e,i,n){var a=i,o=n;i=(i+2*t)/3,n=(n+2*e)/3,t=(this._xi+2*t)/3,e=(this._yi+2*e)/3,this._dashedBezierTo(t,e,i,n,a,o)},toStatic:function(){var t=this.data;t instanceof Array&&(t.length=this._len,v&&(this.data=new Float32Array(t)))},getBoundingRect:function(){l[0]=l[1]=u[0]=u[1]=Number.MAX_VALUE,h[0]=h[1]=c[0]=c[1]=-Number.MAX_VALUE;for(var t=this.data,e=0,i=0,n=0,d=0,f=0;fl?r:l,p=r>l?1:r/l,g=r>l?l/r:1,m=Math.abs(r-l)>.001;m?(t.translate(a,o),t.rotate(c),t.scale(p,g),t.arc(0,0,f,h,h+u,1-d),t.scale(1/p,1/g),t.rotate(-c),t.translate(-a,-o)):t.arc(a,o,f,h,h+u,1-d);break;case s.R:t.rect(e[i++],e[i++],e[i++],e[i++]);break;case s.Z:t.closePath()}}}},y.CMD=s,t.exports=y},function(t,e){"use strict";function i(){this._coordinateSystems=[]}var n={};i.prototype={constructor:i,create:function(t,e){var i=[];for(var a in n){var o=n[a].create(t,e);o&&(i=i.concat(o))}this._coordinateSystems=i},update:function(t,e){for(var i=this._coordinateSystems,n=0;n=0)){var r=this.getShallow(o);null!=r&&(i[t[a][0]]=r)}}return i}}},function(t,e,i){function n(t,e,i,n){if(!e)return t;var s=o(e[0]),l=r.isArray(s)&&s.length||1;i=i||[],n=n||"extra";for(var h=0;l>h;h++)if(!t[h]){var u=i[h]||n+(h-i.length);t[h]=a(e,h)?{type:"ordinal",name:u}:u}return t}function a(t,e){for(var i=0,n=t.length;n>i;i++){var a=o(t[i]);if(!r.isArray(a))return!1;var a=a[e];if(null!=a&&isFinite(a))return!1;if(r.isString(a)&&"-"!==a)return!0}return!1}function o(t){return r.isArray(t)?t:r.isObject(t)?t.value:t}var r=i(1);t.exports=n},function(t,e,i){function n(){this._extent=[1/0,-(1/0)],this._interval=0,this.init&&this.init.apply(this,arguments)}var a=i(20),o=n.prototype;o.parse=function(t){return t},o.contain=function(t){var e=this._extent;return t>=e[0]&&t<=e[1]},o.normalize=function(t){var e=this._extent;return e[1]===e[0]?.5:(t-e[0])/(e[1]-e[0])},o.scale=function(t){var e=this._extent;return t*(e[1]-e[0])+e[0]},o.unionExtent=function(t){var e=this._extent;t[0]e[1]&&(e[1]=t[1])},o.getExtent=function(){return this._extent.slice()},o.setExtent=function(t,e){var i=this._extent;isNaN(t)||(i[0]=t),isNaN(e)||(i[1]=e)},o.getTicksLabels=function(){for(var t=[],e=this.getTicks(),i=0;i=0;if(a){var o="touchend"!=i?e.targetTouches[0]:e.changedTouches[0];if(o){var r=n(t);e.zrX=o.clientX-r.left,e.zrY=o.clientY-r.top}}else{var s=n(t);e.zrX=e.clientX-s.left,e.zrY=e.clientY-s.top,e.zrDelta=e.wheelDelta?e.wheelDelta/120:-(e.detail||0)/3}return e}function o(t,e,i){l?t.addEventListener(e,i):t.attachEvent("on"+e,i)}function r(t,e,i){l?t.removeEventListener(e,i):t.detachEvent("on"+e,i)}var s=i(21),l="undefined"!=typeof window&&!!window.addEventListener,h=l?function(t){t.preventDefault(),t.stopPropagation(),t.cancelBubble=!0}:function(t){t.returnValue=!1,t.cancelBubble=!0};t.exports={normalizeEvent:a,addEventListener:o,removeEventListener:r,stop:h,Dispatcher:s}},function(t,e,i){"use strict";var n=i(3),a=i(1);i(51),i(95),i(2).extendComponentView({type:"grid",render:function(t,e){this.group.removeAll(),t.get("show")&&this.group.add(new n.Rect({shape:t.coordinateSystem.getRect(),style:a.defaults({fill:t.get("backgroundColor")},t.getItemStyle()),silent:!0}))}})},function(t,e,i){function n(t){t=t||{},r.call(this,t);for(var e in t)t.hasOwnProperty(e)&&"style"!==e&&(this[e]=t[e]);this.style=new o(t.style),this._rect=null,this.__clipPaths=[]}var a=i(1),o=i(141),r=i(55),s=i(66);n.prototype={constructor:n,type:"displayable",__dirty:!0,invisible:!1,z:0,z2:0,zlevel:0,draggable:!1,dragging:!1,silent:!1,culling:!1,cursor:"pointer",rectHover:!1,beforeBrush:function(t){},afterBrush:function(t){},brush:function(t){},getBoundingRect:function(){},contain:function(t,e){return this.rectContain(t,e)},traverse:function(t,e){t.call(e,this)},rectContain:function(t,e){var i=this.transformCoordToLocal(t,e),n=this.getBoundingRect();return n.contain(i[0],i[1])},dirty:function(){this.__dirty=!0,this._rect=null,this.__zr&&this.__zr.refresh()},animateStyle:function(t){return this.animate("style",t)},attrKV:function(t,e){"style"!==t?r.prototype.attrKV.call(this,t,e):this.style.set(e)},setStyle:function(t,e){return this.style.set(t,e),this.dirty(),this}},a.inherits(n,r),a.mixin(n,s),t.exports=n},function(t,e,i){"use strict";function n(t){for(var e=0;e1){i=[];for(var o=0;a>o;o++)i[o]=n[e[o][0]]}else i=n.slice(0)}}return i}var h=i(14),u=i(31),c=i(1),d=i(7),f=i(28),p=d.getDataItemValue,g=d.converDataValue,m={cartesian2d:function(t,e,i){var n=i.getComponent("xAxis",e.get("xAxisIndex")),a=i.getComponent("yAxis",e.get("yAxisIndex")),o=n.get("type"),l=a.get("type"),h=[{name:"x",type:s(o),stackable:r(o)},{name:"y",type:s(l),stackable:r(l)}];return u(h,t,["x","y","z"]),{dimensions:h,categoryAxisModel:"category"===o?n:"category"===l?a:null}},polar:function(t,e,i){var n=e.get("polarIndex")||0,a=function(t){return t.get("polarIndex")===n},o=i.findComponents({mainType:"angleAxis",filter:a})[0],l=i.findComponents({mainType:"radiusAxis",filter:a})[0],h=l.get("type"),c=o.get("type"),d=[{name:"radius",type:s(h),stackable:r(h)},{name:"angle",type:s(c),stackable:r(c)}];return u(d,t,["radius","angle","value"]),{dimensions:d,categoryAxisModel:"category"===c?o:"category"===h?l:null}},geo:function(t,e,i){return{dimensions:u([{name:"lng"},{name:"lat"}],t,["lng","lat","value"])}}};t.exports=o},function(t,e,i){var n=i(4),a=i(9),o=i(32),r=Math.floor,s=Math.ceil,l=o.extend({type:"interval",_interval:0,setExtent:function(t,e){var i=this._extent;isNaN(t)||(i[0]=parseFloat(t)),isNaN(e)||(i[1]=parseFloat(e))},unionExtent:function(t){var e=this._extent;t[0]e[1]&&(e[1]=t[1]),l.prototype.setExtent.call(this,e[0],e[1])},getInterval:function(){return this._interval||this.niceTicks(),this._interval},setInterval:function(t){this._interval=t,this._niceExtent=this._extent.slice()},getTicks:function(){this._interval||this.niceTicks();var t=this._interval,e=this._extent,i=[],a=1e4;if(t){var o=this._niceExtent;e[0]a)return[];e[1]>o[1]&&i.push(e[1])}return i},getTicksLabels:function(){for(var t=[],e=this.getTicks(),i=0;ii&&(i=-i,e.reverse());var a=n.nice(i/t,!0),o=[n.round(s(e[0]/a)*a),n.round(r(e[1]/a)*a)];this._interval=a,this._niceExtent=o}},niceExtent:function(t,e,i){var a=this._extent;if(a[0]===a[1])if(0!==a[0]){var o=a[0]/2;a[0]-=o,a[1]+=o}else a[1]=1;var l=a[1]-a[0];isFinite(l)||(a[0]=0,a[1]=1),this.niceTicks(t);var h=this._interval;e||(a[0]=n.round(r(a[0]/h)*h)),i||(a[1]=n.round(s(a[1]/h)*h))}});l.create=function(){return new l},t.exports=l},function(t,e,i){function n(t){this.group=new o.Group,this._symbolCtor=t||r}function a(t,e,i){var n=t.getItemLayout(e);return n&&!isNaN(n[0])&&!isNaN(n[1])&&!(i&&i(e))&&"none"!==t.getItemVisual(e,"symbol")}var o=i(3),r=i(47),s=n.prototype;s.updateData=function(t,e){var i=this.group,n=t.hostModel,r=this._data,s=this._symbolCtor;t.diff(r).add(function(n){var o=t.getItemLayout(n);if(a(t,n,e)){var r=new s(t,n);r.attr("position",o),t.setItemGraphicEl(n,r),i.add(r)}}).update(function(l,h){var u=r.getItemGraphicEl(h),c=t.getItemLayout(l);return a(t,l,e)?(u?(u.updateData(t,l),o.updateProps(u,{position:c},n)):(u=new s(t,l),u.attr("position",c)),i.add(u),void t.setItemGraphicEl(l,u)):void i.remove(u)}).remove(function(t){var e=r.getItemGraphicEl(t);e&&e.fadeOut(function(){i.remove(e)})}).execute(),this._data=t},s.updateLayout=function(){var t=this._data;t&&t.eachItemGraphicEl(function(e,i){e.attr("position",t.getItemLayout(i))})},s.remove=function(t){var e=this.group,i=this._data;i&&(t?i.eachItemGraphicEl(function(t){t.fadeOut(function(){e.remove(t)})}):e.removeAll())},t.exports=n},function(t,e,i){function n(t){var e={};return u(["start","end","startValue","endValue"],function(i){e[i]=t[i]}),e}function a(t,e,i,n){null!=i[e]&&null==i[t]&&(n[t]=null)}var o=i(1),r=i(15),s=i(2),l=i(7),h=i(166),u=o.each,c=l.eachAxisDim,d=s.extendComponentModel({type:"dataZoom",dependencies:["xAxis","yAxis","zAxis","radiusAxis","angleAxis","series"],defaultOption:{zlevel:0,z:4,orient:null,xAxisIndex:null,yAxisIndex:null,angleAxisIndex:null,radiusAxisIndex:null,filterMode:"filter",throttle:100,start:0,end:100,startValue:null,endValue:null},init:function(t,e,i){this._dataIntervalByAxis={},this._dataInfo={},this._axisProxies={},this.textStyleModel;var a=n(t);this.mergeDefaultAndTheme(t,i),this.doInit(a)},mergeOption:function(t){var e=n(t);o.merge(this.option,t,!0),this.doInit(e)},doInit:function(t){var e=this.option;r.canvasSupported||(e.realtime=!1),a("start","startValue",t,e),a("end","endValue",t,e),this.textStyleModel=this.getModel("textStyle"),this._resetTarget(),this._giveAxisProxies()},_giveAxisProxies:function(){var t=this._axisProxies;this.eachTargetAxis(function(e,i,n,a){var o=this.dependentModels[e.axis][i],r=o.__dzAxisProxy||(o.__dzAxisProxy=new h(e.name,i,this,a));t[e.name+"_"+i]=r},this)},_resetTarget:function(){var t=this.option,e=this._judgeAutoMode();c(function(e){var i=e.axisIndex;t[i]=l.normalizeToArray(t[i])},this),"axisIndex"===e?this._autoSetAxisIndex():"orient"===e&&this._autoSetOrient()},_judgeAutoMode:function(){var t=this.option,e=!1;c(function(i){null!=t[i.axisIndex]&&(e=!0)},this);var i=t.orient;return null==i&&e?"orient":e?void 0:(null==i&&(t.orient="horizontal"),"axisIndex")},_autoSetAxisIndex:function(){var t=!0,e=this.get("orient",!0),i=this.option;if(t){var n="vertical"===e?{dim:"y",axisIndex:"yAxisIndex",axis:"yAxis"}:{dim:"x",axisIndex:"xAxisIndex",axis:"xAxis"};this.dependentModels[n.axis].length&&(i[n.axisIndex]=[0],t=!1)}t&&c(function(e){if(t){var n=[],a=this.dependentModels[e.axis];if(a.length&&!n.length)for(var o=0,r=a.length;r>o;o++)"category"===a[o].get("type")&&n.push(o);i[e.axisIndex]=n,n.length&&(t=!1)}},this),t&&this.ecModel.eachSeries(function(t){this._isSeriesHasAllAxesTypeOf(t,"value")&&c(function(e){var n=i[e.axisIndex],a=t.get(e.axisIndex);o.indexOf(n,a)<0&&n.push(a)})},this)},_autoSetOrient:function(){var t;this.eachTargetAxis(function(e){!t&&(t=e.name)},this),this.option.orient="y"===t?"vertical":"horizontal"},_isSeriesHasAllAxesTypeOf:function(t,e){var i=!0;return c(function(n){var a=t.get(n.axisIndex),o=this.dependentModels[n.axis][a];o&&o.get("type")===e||(i=!1)},this),i},getFirstTargetAxisModel:function(){var t;return c(function(e){if(null==t){var i=this.get(e.axisIndex);i.length&&(t=this.dependentModels[e.axis][i[0]])}},this),t},eachTargetAxis:function(t,e){var i=this.ecModel;c(function(n){u(this.get(n.axisIndex),function(a){t.call(e,n,a,this,i)},this)},this)},getAxisProxy:function(t,e){return this._axisProxies[t+"_"+e]},setRawRange:function(t){u(["start","end","startValue","endValue"],function(e){this.option[e]=t[e]},this)},getPercentRange:function(){var t=this.findRepresentativeAxisProxy();return t?t.getDataPercentWindow():void 0},getValueRange:function(t,e){if(null!=t||null!=e)return this.getAxisProxy(t,e).getDataValueWindow();var i=this.findRepresentativeAxisProxy();return i?i.getDataValueWindow():void 0},findRepresentativeAxisProxy:function(){var t=this._axisProxies;for(var e in t)if(t.hasOwnProperty(e)&&t[e].hostedBy(this))return t[e];for(var e in t)if(t.hasOwnProperty(e)&&!t[e].hostedBy(this))return t[e]}});t.exports=d},function(t,e,i){var n=i(54);t.exports=n.extend({type:"dataZoom",render:function(t,e,i,n){this.dataZoomModel=t,this.ecModel=e,this.api=i},getTargetInfo:function(){function t(t,e,i,n){for(var a,o=0;o=0&&i.push(t)}),i}t.topologicalTravel=function(t,e,a,o){function r(t){h[t].entryCount--,0===h[t].entryCount&&u.push(t)}function s(t){c[t]=!0,r(t)}if(t.length){var l=i(e),h=l.graph,u=l.noEntryList,c={};for(n.each(t,function(t){c[t]=!0});u.length;){var d=u.pop(),f=h[d],p=!!c[d];p&&(a.call(o,d,f.originalDeps.slice()),delete c[d]),n.each(f.successor,p?s:r)}n.each(c,function(){throw new Error("Circle dependency may exists")})}}},t.exports=s},function(t,e){var i=1;"undefined"!=typeof window&&(i=Math.max(window.devicePixelRatio||1,1));var n={debugMode:0,devicePixelRatio:i};t.exports=n},function(t,e,i){function n(t,e){var i=t[1]-t[0],n=e,a=i/n/2;t[0]+=a,t[1]-=a}var a=i(4),o=a.linearMap,r=i(1),s=[0,1],l=function(t,e,i){this.dim=t,this.scale=e,this._extent=i||[0,0],this.inverse=!1,this.onBand=!1};l.prototype={constructor:l,contain:function(t){var e=this._extent,i=Math.min(e[0],e[1]),n=Math.max(e[0],e[1]);return t>=i&&n>=t},containData:function(t){return this.contain(this.dataToCoord(t))},getExtent:function(){var t=this._extent.slice();return t},getPixelPrecision:function(t){return a.getPixelPrecision(t||this.scale.getExtent(),this._extent)},setExtent:function(t,e){var i=this._extent;i[0]=t,i[1]=e},dataToCoord:function(t,e){var i=this._extent,a=this.scale;return t=a.normalize(t),this.onBand&&"ordinal"===a.type&&(i=i.slice(),n(i,a.count())),o(t,s,i,e)},coordToData:function(t,e){var i=this._extent,a=this.scale;this.onBand&&"ordinal"===a.type&&(i=i.slice(),n(i,a.count()));var r=o(t,i,s,e);return this.scale.scale(r)},getTicksCoords:function(){if(this.onBand){for(var t=this.getBands(),e=[],i=0;ir;r++)e.push([o*r/i+n,o*(r+1)/i+n]);return e},getBandWidth:function(){var t=this._extent,e=this.scale.getExtent(),i=e[1]-e[0]+(this.onBand?1:0),n=Math.abs(t[1]-t[0]);return Math.abs(n)/i}},t.exports=l},function(t,e){t.exports=function(t,e,i,n,a){n.eachRawSeriesByType(t,function(t){var a=t.getData(),o=t.get("symbol")||e,r=t.get("symbolSize");a.setVisual({legendSymbol:i||o,symbol:o,symbolSize:r}),n.isSeriesFiltered(t)||("function"==typeof r&&a.each(function(e){var i=t.getRawValue(e),n=t.getDataParams(e);a.setItemVisual(e,"symbolSize",r(i,n))}),a.each(function(t){var e=a.getItemModel(t),i=e.get("symbol",!0),n=e.get("symbolSize",!0);null!=i&&a.setItemVisual(t,"symbol",i),null!=n&&a.setItemVisual(t,"symbolSize",n)}))})}},function(t,e,i){var n=i(42);t.exports=function(){if(0!==n.debugMode)if(1==n.debugMode)for(var t in arguments)throw new Error(arguments[t]);else if(n.debugMode>1)for(var t in arguments)console.log(arguments[t])}},function(t,e,i){var n=i(35),a=i(8),o=i(1),r=i(60),s=i(139),l=new s(50),h=function(t){n.call(this,t)};h.prototype={constructor:h,type:"image",brush:function(t){var e,i=this.style,n=i.image;if(e="string"==typeof n?this._image:n,!e&&n){var a=l.get(n);if(!a)return e=new Image,e.onload=function(){e.onload=null;for(var t=0;t0?"top":"bottom",n="center"):u(o-c)?(a=i>0?"bottom":"top",n="center"):(a="middle",n=o>0&&c>o?i>0?"right":"left":i>0?"left":"right"),{rotation:o,textAlign:n,verticalAlign:a}}function a(t,e,i){var n,a,o=h(-t.rotation),r=i[0]>i[1],s="start"===e&&!r||"start"!==e&&r;return u(o-c/2)?(a=s?"bottom":"top",n="center"):u(o-1.5*c)?(a=s?"top":"bottom",n="center"):(a="middle",n=1.5*c>o&&o>c/2?s?"left":"right":s?"right":"left"),{rotation:o,textAlign:n,verticalAlign:a}}var o=i(1),r=i(3),s=i(12),l=i(4),h=l.remRadian,u=l.isRadianAroundZero,c=Math.PI,d=function(t,e){this.opt=e,this.axisModel=t,o.defaults(e,{labelOffset:0,nameDirection:1,tickDirection:1,labelDirection:1,silent:!0}),this.group=new r.Group({position:e.position.slice(),rotation:e.rotation})};d.prototype={constructor:d,hasBuilder:function(t){return!!f[t]},add:function(t){f[t].call(this)},getGroup:function(){return this.group}};var f={axisLine:function(){var t=this.opt,e=this.axisModel;if(e.get("axisLine.show")){var i=this.axisModel.axis.getExtent();this.group.add(new r.Line({shape:{x1:i[0],y1:0,x2:i[1],y2:0},style:o.extend({lineCap:"round"},e.getModel("axisLine.lineStyle").getLineStyle()),strokeContainThreshold:t.strokeContainThreshold,silent:!!t.silent,z2:1}))}},axisTick:function(){var t=this.axisModel;if(t.get("axisTick.show")){for(var e=t.axis,i=t.getModel("axisTick"),n=this.opt,a=i.getModel("lineStyle"),o=i.get("length"),s=g(i,n.labelInterval),l=e.getTicksCoords(),h=[],u=0;uc[1]?-1:1,f=["start"===s?c[0]-d*u:"end"===s?c[1]+d*u:(c[0]+c[1])/2,"middle"===s?t.labelOffset+l*u:0];o="middle"===s?n(t,t.rotation,l):a(t,s,c),this.group.add(new r.Text({style:{text:i,textFont:h.getFont(),fill:h.getTextColor()||e.get("axisLine.lineStyle.color"),textAlign:o.textAlign,textVerticalAlign:o.verticalAlign},position:f,rotation:o.rotation,silent:!0,z2:1}))}}},p=d.ifIgnoreOnTick=function(t,e,i){var n,a=t.scale;return"ordinal"===a.type&&("function"==typeof i?(n=a.getTicks()[e],!i(n,a.getLabel(n))):e%(i+1))},g=d.getInterval=function(t,e){var i=t.get("interval");return null!=i&&"auto"!=i||(i=e),i};t.exports=d},function(t,e,i){function n(t){return r.isObject(t)&&null!=t.value?t.value:t}function a(){return"category"===this.get("type")&&r.map(this.get("data"),n)}function o(){return s.getFormattedLabels(this.axis,this.get("axisLabel.formatter"))}var r=i(1),s=i(23);t.exports={getFormattedLabels:o,getCategories:a}},function(t,e,i){"use strict";function n(t,e){return e.type||(e.data?"category":"value")}var a=i(10),o=i(1),r=i(61),s=a.extend({type:"cartesian2dAxis",axis:null,init:function(){s.superApply(this,"init",arguments),this._resetRange()},mergeOption:function(){s.superApply(this,"mergeOption",arguments),this._resetRange()},restoreData:function(){s.superApply(this,"restoreData",arguments),this._resetRange()},setRange:function(t,e){this.option.rangeStart=t,this.option.rangeEnd=e},getMin:function(){var t=this.option;return null!=t.rangeStart?t.rangeStart:t.min},getMax:function(){var t=this.option;return null!=t.rangeEnd?t.rangeEnd:t.max},getNeedCrossZero:function(){var t=this.option;return null!=t.rangeStart||null!=t.rangeEnd?!1:!t.scale},_resetRange:function(){this.option.rangeStart=this.option.rangeEnd=null}});o.merge(s.prototype,i(49));var l={gridIndex:0};r("x",s,n,l),r("y",s,n,l),t.exports=s},function(t,e,i){function n(t,e,i){return i.getComponent("grid",t.get("gridIndex"))===e}function a(t){var e,i=t.model,n=i.getFormattedLabels(),a=1,o=n.length;o>40&&(a=Math.ceil(o/40));for(var r=0;o>r;r+=a)if(!t.isLabelIgnored(r)){var s=i.getTextRect(n[r]);e?e.union(s):e=s}return e}function o(t,e,i){this._coordsMap={},this._coordsList=[],this._axesMap={},this._axesList=[],this._initCartesian(t,e,i),this._model=t}function r(t,e){var i=t.getExtent(),n=i[0]+i[1];t.toGlobalCoord="x"===t.dim?function(t){return t+e}:function(t){return n-t+e},t.toLocalCoord="x"===t.dim?function(t){return t-e}:function(t){return n-t+e}}var s=i(11),l=i(23),h=i(1),u=i(106),c=i(104),d=h.each,f=l.ifAxisCrossZero,p=l.niceScaleExtent;i(107);var g=o.prototype;g.type="grid",g.getRect=function(){return this._rect},g.update=function(t,e){function i(t){var e=n[t];for(var i in e){var a=e[i];if(a&&("category"===a.type||!f(a)))return!0}return!1}var n=this._axesMap;this._updateScale(t,this._model),d(n.x,function(t){p(t,t.model)}),d(n.y,function(t){p(t,t.model)}),d(n.x,function(t){i("y")&&(t.onZero=!1)}),d(n.y,function(t){i("x")&&(t.onZero=!1)}),this.resize(this._model,e)},g.resize=function(t,e){function i(){d(o,function(t){var e=t.isHorizontal(),i=e?[0,n.width]:[0,n.height],a=t.inverse?1:0;t.setExtent(i[a],i[1-a]),r(t,e?n.x:n.y)})}var n=s.getLayoutRect(t.getBoxLayoutParams(),{width:e.getWidth(),height:e.getHeight()});this._rect=n;var o=this._axesList;i(),t.get("containLabel")&&(d(o,function(t){if(!t.model.get("axisLabel.inside")){var e=a(t);if(e){var i=t.isHorizontal()?"height":"width",o=t.model.get("axisLabel.margin");n[i]-=e[i]+o,"top"===t.position?n.y+=e.height+o:"left"===t.position&&(n.x+=e.width+o)}}}),i())},g.getAxis=function(t,e){var i=this._axesMap[t];if(null!=i){if(null==e)for(var n in i)return i[n];return i[e]}},g.getCartesian=function(t,e){var i="x"+t+"y"+e;return this._coordsMap[i]},g._initCartesian=function(t,e,i){function a(i){return function(a,h){if(n(a,t,e)){var u=a.get("position");"x"===i?("top"!==u&&"bottom"!==u&&(u="bottom"),o[u]&&(u="top"===u?"bottom":"top")):("left"!==u&&"right"!==u&&(u="left"),o[u]&&(u="left"===u?"right":"left")),o[u]=!0;var d=new c(i,l.createScaleByModel(a),[0,0],a.get("type"),u),f="category"===d.type;d.onBand=f&&a.get("boundaryGap"),d.inverse=a.get("inverse"),d.onZero=a.get("axisLine.onZero"),a.axis=d,d.model=a,d.index=h,this._axesList.push(d),r[i][h]=d,s[i]++}}}var o={left:!1,right:!1,top:!1,bottom:!1},r={x:{},y:{}},s={x:0,y:0};return e.eachComponent("xAxis",a("x"),this),e.eachComponent("yAxis",a("y"),this),s.x&&s.y?(this._axesMap=r,void d(r.x,function(t,e){d(r.y,function(i,n){var a="x"+e+"y"+n,o=new u(a);o.grid=this,this._coordsMap[a]=o,this._coordsList.push(o),o.addAxis(t),o.addAxis(i); +},this)},this)):(this._axesMap={},void(this._axesList=[]))},g._updateScale=function(t,e){function i(t,e,i){d(i.coordDimToDataDim(e.dim),function(i){e.scale.unionExtent(t.getDataExtent(i,"ordinal"!==e.scale.type))})}h.each(this._axesList,function(t){t.scale.setExtent(1/0,-(1/0))}),t.eachSeries(function(a){if("cartesian2d"===a.get("coordinateSystem")){var o=a.get("xAxisIndex"),r=a.get("yAxisIndex"),s=t.getComponent("xAxis",o),l=t.getComponent("yAxis",r);if(!n(s,e,t)||!n(l,e,t))return;var h=this.getCartesian(o,r),u=a.getData(),c=h.getAxis("x"),d=h.getAxis("y");"list"===u.type&&(i(u,c,a),i(u,d,a))}},this)},o.create=function(t,e){var i=[];return t.eachComponent("grid",function(n,a){var r=new o(n,t,e);r.name="grid_"+a,r.resize(n,e),n.coordinateSystem=r,i.push(r)}),t.eachSeries(function(e){if("cartesian2d"===e.get("coordinateSystem")){var n=e.get("xAxisIndex"),a=t.getComponent("xAxis",n),o=i[a.get("gridIndex")];e.coordinateSystem=o.getCartesian(n,e.get("yAxisIndex"))}}),i},o.dimensions=u.prototype.dimensions,i(28).register("cartesian2d",o),t.exports=o},function(t,e){"use strict";function i(t){return t}function n(t,e,n,a){this._old=t,this._new=e,this._oldKeyGetter=n||i,this._newKeyGetter=a||i}function a(t,e,i){for(var n=0;nt;t++)this._add&&this._add(h[t]);else this._add&&this._add(h)}}},t.exports=n},function(t,e){t.exports=function(t,e,i){e.eachSeriesByType(t,function(t){var e=t.getData(),i=t.coordinateSystem,n=i.dimensions;e.each(n,function(t,n,a){var o;o=isNaN(t)||isNaN(n)?[NaN,NaN]:i.dataToPoint([t,n]),e.setItemLayout(a,o)},!0)})}},function(t,e,i){var n=i(26),a=i(41),o=i(20),r=function(){this.group=new n,this.uid=a.getUID("viewComponent")};r.prototype={constructor:r,init:function(t,e){},render:function(t,e,i,n){},dispose:function(){}};var s=r.prototype;s.updateView=s.updateLayout=s.updateVisual=function(t,e,i,n){},o.enableClassExtend(r),o.enableClassManagement(r,{registerWhenExtend:!0}),t.exports=r},function(t,e,i){"use strict";var n=i(58),a=i(21),o=i(77),r=i(153),s=i(1),l=function(t){o.call(this,t),a.call(this,t),r.call(this,t),this.id=t.id||n()};l.prototype={type:"element",name:"",__zr:null,ignore:!1,clipPath:null,drift:function(t,e){switch(this.draggable){case"horizontal":e=0;break;case"vertical":t=0}var i=this.transform;i||(i=this.transform=[1,0,0,1,0,0]),i[4]+=t,i[5]+=e,this.decomposeTransform(),this.dirty()},beforeUpdate:function(){},afterUpdate:function(){},update:function(){this.updateTransform()},traverse:function(t,e){},attrKV:function(t,e){if("position"===t||"scale"===t||"origin"===t){if(e){var i=this[t];i||(i=this[t]=[]),i[0]=e[0],i[1]=e[1]}}else this[t]=e},hide:function(){this.ignore=!0,this.__zr&&this.__zr.refresh()},show:function(){this.ignore=!1,this.__zr&&this.__zr.refresh()},attr:function(t,e){if("string"==typeof t)this.attrKV(t,e);else if(s.isObject(t))for(var i in t)t.hasOwnProperty(i)&&this.attrKV(i,t[i]);return this.dirty(),this},setClipPath:function(t){var e=this.__zr;e&&t.addSelfToZr(e),this.clipPath&&this.clipPath!==t&&this.removeClipPath(),this.clipPath=t,t.__zr=e,t.__clipTarget=this,this.dirty()},removeClipPath:function(){var t=this.clipPath;t&&(t.__zr&&t.removeSelfFromZr(t.__zr),t.__zr=null,t.__clipTarget=null,this.clipPath=null,this.dirty())},addSelfToZr:function(t){this.__zr=t;var e=this.animators;if(e)for(var i=0;i.5?e:t}function s(t,e,i,n,a){var r=t.length;if(1==a)for(var s=0;r>s;s++)n[s]=o(t[s],e[s],i);else for(var l=t[0].length,s=0;r>s;s++)for(var h=0;l>h;h++)n[s][h]=o(t[s][h],e[s][h],i)}function l(t,e,i){var n=t.length,a=e.length;if(n!==a){var o=n>a;if(o)t.length=a;else for(var r=n;a>r;r++)t.push(1===i?e[r]:x.call(e[r]))}}function h(t,e,i){if(t===e)return!0;var n=t.length;if(n!==e.length)return!1;if(1===i){for(var a=0;n>a;a++)if(t[a]!==e[a])return!1}else for(var o=t[0].length,a=0;n>a;a++)for(var r=0;o>r;r++)if(t[a][r]!==e[a][r])return!1;return!0}function u(t,e,i,n,a,o,r,s,l){var h=t.length;if(1==l)for(var u=0;h>u;u++)s[u]=c(t[u],e[u],i[u],n[u],a,o,r);else for(var d=t[0].length,u=0;h>u;u++)for(var f=0;d>f;f++)s[u][f]=c(t[u][f],e[u][f],i[u][f],n[u][f],a,o,r)}function c(t,e,i,n,a,o,r){var s=.5*(i-t),l=.5*(n-e);return(2*(e-i)+s+l)*r+(-3*(e-i)-2*s-l)*o+s*a+e}function d(t){if(y(t)){var e=t.length;if(y(t[0])){for(var i=[],n=0;e>n;n++)i.push(x.call(t[n]));return i}return x.call(t)}return t}function f(t){return t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.floor(t[2]),"rgba("+t.join(",")+")"}function p(t,e,i,n,a){var d=t._getter,p=t._setter,v="spline"===e,x=n.length;if(x){var _,w=n[0].value,b=y(w),S=!1,M=!1,A=b&&y(w[0])?2:1;n.sort(function(t,e){return t.time-e.time}),_=n[x-1].time;for(var I=[],T=[],C=n[0].value,L=!0,D=0;x>D;D++){I.push(n[D].time/_);var P=n[D].value;if(b&&h(P,C,A)||!b&&P===C||(L=!1),C=P,"string"==typeof P){var k=m.parse(P);k?(P=k,S=!0):M=!0}T.push(P)}if(!L){if(b){for(var z=T[x-1],D=0;x-1>D;D++)l(T[D],z,A);l(d(t._target,a),z,A)}var E,R,O,V,N,B,G=0,F=0;if(S)var W=[0,0,0,0];var H=function(t,e){var i;if(F>e){for(E=Math.min(G+1,x-1),i=E;i>=0&&!(I[i]<=e);i--);i=Math.min(i,x-2)}else{for(i=G;x>i&&!(I[i]>e);i++);i=Math.min(i-1,x-2)}G=i,F=e;var n=I[i+1]-I[i];if(0!==n)if(R=(e-I[i])/n,v)if(V=T[i],O=T[0===i?i:i-1],N=T[i>x-2?x-1:i+1],B=T[i>x-3?x-1:i+2],b)u(O,V,N,B,R,R*R,R*R*R,d(t,a),A);else{var l;if(S)l=u(O,V,N,B,R,R*R,R*R*R,W,1),l=f(W);else{if(M)return r(V,N,R);l=c(O,V,N,B,R,R*R,R*R*R)}p(t,a,l)}else if(b)s(T[i],T[i+1],R,d(t,a),A);else{var l;if(S)s(T[i],T[i+1],R,W,1),l=f(W);else{if(M)return r(T[i],T[i+1],R);l=o(T[i],T[i+1],R)}p(t,a,l)}},Z=new g({target:t._target,life:_,loop:t._loop,delay:t._delay,onframe:H,ondestroy:i});return e&&"spline"!==e&&(Z.easing=e),Z}}}var g=i(131),m=i(22),v=i(1),y=v.isArrayLike,x=Array.prototype.slice,_=function(t,e,i,o){this._tracks={},this._target=t,this._loop=e||!1,this._getter=i||n,this._setter=o||a,this._clipCount=0,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]};_.prototype={when:function(t,e){var i=this._tracks;for(var n in e){if(!i[n]){i[n]=[];var a=this._getter(this._target,n);if(null==a)continue;0!==t&&i[n].push({time:0,value:d(a)})}i[n].push({time:t,value:e[n]})}return this},during:function(t){return this._onframeList.push(t),this},_doneCallback:function(){this._tracks={},this._clipList.length=0;for(var t=this._doneList,e=t.length,i=0;e>i;i++)t[i].call(this)},start:function(t){var e,i=this,n=0,a=function(){n--,n||i._doneCallback()};for(var o in this._tracks){var r=p(this,t,a,this._tracks[o],o);r&&(this._clipList.push(r),n++,this.animation&&this.animation.addClip(r),e=r)}if(e){var s=e.onframe;e.onframe=function(t,e){s(t,e);for(var n=0;nt&&(t+=i),t}}},function(t,e){var i=2311;t.exports=function(){return"zr_"+i++}},function(t,e,i){var n=i(143),a=i(142);t.exports={buildPath:function(t,e,i){var o=e.points,r=e.smooth;if(o&&o.length>=2){if(r&&"spline"!==r){var s=a(o,r,i,e.smoothConstraint);t.moveTo(o[0][0],o[0][1]);for(var l=o.length,h=0;(i?l:l-1)>h;h++){var u=s[2*h],c=s[2*h+1],d=o[(h+1)%l];t.bezierCurveTo(u[0],u[1],c[0],c[1],d[0],d[1])}}else{"spline"===r&&(o=n(o,i)),t.moveTo(o[0][0],o[0][1]);for(var h=1,f=o.length;f>h;h++)t.lineTo(o[h][0],o[h][1])}i&&t.closePath()}}}},function(t,e){t.exports={buildPath:function(t,e){var i,n,a,o,r=e.x,s=e.y,l=e.width,h=e.height,u=e.r;0>l&&(r+=l,l=-l),0>h&&(s+=h,h=-h),"number"==typeof u?i=n=a=o=u:u instanceof Array?1===u.length?i=n=a=o=u[0]:2===u.length?(i=a=u[0],n=o=u[1]):3===u.length?(i=u[0],n=o=u[1],a=u[2]):(i=u[0],n=u[1],a=u[2],o=u[3]):i=n=a=o=0;var c;i+n>l&&(c=i+n,i*=l/c,n*=l/c),a+o>l&&(c=a+o,a*=l/c,o*=l/c),n+a>h&&(c=n+a,n*=h/c,a*=h/c),i+o>h&&(c=i+o,i*=h/c,o*=h/c),t.moveTo(r+i,s),t.lineTo(r+l-n,s),0!==n&&t.quadraticCurveTo(r+l,s,r+l,s+n),t.lineTo(r+l,s+h-a),0!==a&&t.quadraticCurveTo(r+l,s+h,r+l-a,s+h),t.lineTo(r+o,s+h),0!==o&&t.quadraticCurveTo(r,s+h,r,s+h-o),t.lineTo(r,s+i),0!==i&&t.quadraticCurveTo(r,s,r+i,s)}}},function(t,e,i){var n=i(72),a=i(1),o=i(10),r=i(11),s=["value","category","time","log"];t.exports=function(t,e,i,l){a.each(s,function(o){e.extend({type:t+"Axis."+o,mergeDefaultAndTheme:function(e,n){var s=this.layoutMode,l=s?r.getLayoutParams(e):{},h=n.getTheme();a.merge(e,h.get(o+"Axis")),a.merge(e,this.getDefaultOption()),e.type=i(t,e),s&&r.mergeLayoutParam(e,l,s)},defaultOption:a.mergeAll([{},n[o+"Axis"],l],!0)})}),o.registerSubTypeDefaulter(t+"Axis",a.curry(i,t))}},function(t,e){t.exports=function(t,e){var i=e.findComponents({mainType:"legend"});i&&i.length&&e.eachSeriesByType(t,function(t){var e=t.getData();e.filterSelf(function(t){for(var n=e.getName(t),a=0;av;v++)y[v]=w(t,i,o,h,y[v]);for(b=_(e,n,l,u,x),v=0;b>v;v++)x[v]=w(e,n,l,u,x[v]);y.push(t,h),x.push(e,u),f=r.apply(null,y),p=s.apply(null,y),g=r.apply(null,x),m=s.apply(null,x),c[0]=f,c[1]=g,d[0]=p,d[1]=m},o.fromQuadratic=function(t,e,i,n,o,l,h,u){var c=a.quadraticExtremum,d=a.quadraticAt,f=s(r(c(t,i,o),1),0),p=s(r(c(e,n,l),1),0),g=d(t,i,o,f),m=d(e,n,l,p);h[0]=r(t,o,g),h[1]=r(e,l,m),u[0]=s(t,o,g),u[1]=s(e,l,m)},o.fromArc=function(t,e,i,a,o,r,s,p,g){var m=n.min,v=n.max,y=Math.abs(o-r);if(1e-4>y%f&&y>1e-4)return p[0]=t-i,p[1]=e-a,g[0]=t+i,void(g[1]=e+a);if(u[0]=h(o)*i+t,u[1]=l(o)*a+e,c[0]=h(r)*i+t,c[1]=l(r)*a+e,m(p,u,c),v(g,u,c),o%=f,0>o&&(o+=f),r%=f,0>r&&(r+=f),o>r&&!s?r+=f:r>o&&s&&(o+=f),s){var x=r;r=o,o=x}for(var _=0;r>_;_+=Math.PI/2)_>o&&(d[0]=h(_)*i+t,d[1]=l(_)*a+e,m(p,d,p),v(g,d,g))},t.exports=o},function(t,e,i){var n=i(35),a=i(1),o=i(17),r=function(t){n.call(this,t)};r.prototype={constructor:r,type:"text",brush:function(t){var e=this.style,i=e.x||0,n=e.y||0,a=e.text,r=e.fill,s=e.stroke;if(null!=a&&(a+=""),a){if(t.save(),this.style.bind(t),this.setTransform(t),r&&(t.fillStyle=r),s&&(t.strokeStyle=s),t.font=e.textFont||e.font,t.textAlign=e.textAlign,e.textVerticalAlign){var l=o.getBoundingRect(a,t.font,e.textAlign,"top");switch(t.textBaseline="top",e.textVerticalAlign){case"middle":n-=l.height/2;break;case"bottom":n-=l.height}}else t.textBaseline=e.textBaseline;for(var h=o.measureText("国",t.font).width,u=a.split("\n"),c=0;c=0?parseFloat(t)/100*e:parseFloat(t):t}function a(t,e){t.transform(e[0],e[1],e[2],e[3],e[4],e[5])}var o=i(17),r=i(8),s=new r,l=function(){};l.prototype={constructor:l,drawRectText:function(t,e,i){var r=this.style,l=r.text;if(null!=l&&(l+=""),l){var h,u,c=r.textPosition,d=r.textDistance,f=r.textAlign,p=r.textFont||r.font,g=r.textBaseline,m=r.textVerticalAlign;i=i||o.getBoundingRect(l,p,f,g);var v=this.transform,y=this.invTransform;if(v&&(s.copy(e),s.applyTransform(v),e=s,a(t,y)),c instanceof Array)h=e.x+n(c[0],e.width),u=e.y+n(c[1],e.height),f=f||"left",g=g||"top";else{var x=o.adjustTextPositionOnRect(c,e,i,d);h=x.x,u=x.y,f=f||x.textAlign,g=g||x.textBaseline}if(t.textAlign=f,m){switch(m){case"middle":u-=i.height/2;break;case"bottom":u-=i.height}t.textBaseline="top"}else t.textBaseline=g;var _=r.textFill,w=r.textStroke;_&&(t.fillStyle=_),w&&(t.strokeStyle=w),t.font=p,t.shadowColor=r.textShadowColor,t.shadowBlur=r.textShadowBlur,t.shadowOffsetX=r.textShadowOffsetX,t.shadowOffsetY=r.textShadowOffsetY;for(var b=l.split("\n"),S=0;S0?1.1:1/1.1;l.call(this,t,e,t.offsetX,t.offsetY)}function s(t){if(!f.isTaken("globalPan",this._zr)){d.stop(t.event);var e=t.pinchScale>1?1.1:1/1.1;l.call(this,t,e,t.pinchX,t.pinchY)}}function l(t,e,i,n){var a=this.rect;if(a&&a.contain(i,n)){var o=this.target;if(o){var r=o.position,s=o.scale,l=this._zoom=this._zoom||1;l*=e;var h=l/this._zoom;this._zoom=l,r[0]-=(i-r[0])*(h-1),r[1]-=(n-r[1])*(h-1),s[0]*=h,s[1]*=h,o.dirty()}this.trigger("zoom",e,i,n)}}function h(t,e,i){this.target=e,this.rect=i,this._zr=t;var l=c.bind,h=l(n,this),d=l(a,this),f=l(o,this),p=l(r,this),g=l(s,this);u.call(this),this.enable=function(e){this.disable(),null==e&&(e=!0),e!==!0&&"move"!==e&&"pan"!==e||(t.on("mousedown",h),t.on("mousemove",d),t.on("mouseup",f)),e!==!0&&"scale"!==e&&"zoom"!==e||(t.on("mousewheel",p),t.on("pinch",g))},this.disable=function(){t.off("mousedown",h),t.off("mousemove",d),t.off("mouseup",f),t.off("mousewheel",p),t.off("pinch",g)},this.dispose=this.disable,this.isDragging=function(){return this._dragging},this.isPinching=function(){return this._pinching}}var u=i(21),c=i(1),d=i(33),f=i(101);c.mixin(h,u),t.exports=h},function(t,e){t.exports=function(t,e,i,n,a){function o(t,e,i){var n=e.length?e.slice():[e,e];return e[0]>e[1]&&n.reverse(),0>t&&n[0]+t0&&n[1]+t>i[1]&&(t=i[1]-n[1]),t}return t?("rigid"===n?(t=o(t,e,i),e[0]+=t,e[1]+=t):(t=o(t,e[a],i),e[a]+=t,"push"===n&&e[0]>e[1]&&(e[1-a]=e[a])),e):e}},function(t,e,i){var n=i(1),a={show:!0,zlevel:0,z:0,inverse:!1,name:"",nameLocation:"end",nameTextStyle:{},nameGap:15,axisLine:{show:!0,onZero:!0,lineStyle:{color:"#333",width:1,type:"solid"}},axisTick:{show:!0,inside:!1,length:5,lineStyle:{color:"#333",width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{color:"#333",fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}}},o=n.merge({boundaryGap:!0,axisTick:{interval:"auto"},axisLabel:{interval:"auto"}},a),r=n.defaults({boundaryGap:[0,0],splitNumber:5},a),s=n.defaults({scale:!0,min:"dataMin",max:"dataMax"},r),l=n.defaults({},r);l.scale=!0,t.exports={categoryAxis:o,valueAxis:r,timeAxis:s,logAxis:l}},function(t,e,i){function n(t,e,i,n){return c.isArray(t)?c.map(t,function(t){return f(t,e,i,n)}):f(t,e,i,n)}function a(t){var e=t.pieceList;t.hasSpecialVisual=!1,c.each(e,function(e,i){e.originIndex=i,e.visual&&(t.hasSpecialVisual=!0)})}function o(t){var e=t.categories,i=t.visual,n=c.isArray(i);if(!e){if(n)return;throw new Error}var a=t.categoryMap={};if(p(e,function(t,e){a[t]=e}),!n){var o=[];c.isObject(i)?p(i,function(t,e){var i=a[e];o[null!=i?i:m]=t}):o[m]=i,i=t.visual=o}for(var r=e.length-1;r>=0;r--)null==i[r]&&(delete a[e[r]],e.pop())}function r(t){return{applyVisual:function(e,i,n){var a=i("color"),o=c.isArray(e);if(e=o?[this.mapValueToVisual(e[0]),this.mapValueToVisual(e[1])]:this.mapValueToVisual(e),c.isArray(a))for(var r=0,s=a.length;s>r;r++)a[r].color=t(a[r].color,o?e[r]:e);else n("color",t(a,e))},mapValueToVisual:function(t){var e=this._normalizeData(t),i=this._getSpecifiedVisual(t),a=this.option.visual;return null==i&&(i=u(this)?h(this,a,e):n(e,[0,1],a,!0)),i}}}function s(t,e){return t[Math.round(n(e,[0,1],[0,t.length-1],!0))]}function l(t,e,i){i("color",this.mapValueToVisual(t))}function h(t,e,i){return e[t.option.loop&&i!==m?i%e.length:i]}function u(t){return"category"===t.option.mappingMethod}var c=i(1),d=i(22),f=i(4).linearMap,p=c.each,g=c.isObject,m=-1,v=function(t){var e=t.mappingMethod,i=t.type;this.type=i,this.mappingMethod=e;var n=this.option=c.clone(t);this._normalizeData=x[e],this._getSpecifiedVisual=c.bind(_[e],this,i),c.extend(this,y[i]),"piecewise"===e&&a(n),"category"===e&&o(n)};v.prototype={constructor:v,applyVisual:null,isValueActive:null,mapValueToVisual:null,getNormalizer:function(){return c.bind(this._normalizeData,this)}};var y=v.visualHandlers={color:{applyVisual:l,getColorMapper:function(){var t=u(this)?this.option.visual:c.map(this.option.visual,d.parse);return c.bind(u(this)?function(e,i){return!i&&(e=this._normalizeData(e)),h(this,t,e)}:function(e,i,n){var a=!!n;return!i&&(e=this._normalizeData(e)),n=d.fastMapToColor(e,t,n),a?n:c.stringify(n,"rgba")},this)},mapValueToVisual:function(t){var e=this.option.visual;if(c.isArray(t))return t=[this._normalizeData(t[0]),this._normalizeData(t[1])],d.mapIntervalToColor(t,e);var i=this._normalizeData(t),n=this._getSpecifiedVisual(t);return null==n&&(n=u(this)?h(this,e,i):d.mapToColor(i,e)),n}},colorHue:r(function(t,e){return d.modifyHSL(t,e)}),colorSaturation:r(function(t,e){return d.modifyHSL(t,null,e)}),colorLightness:r(function(t,e){return d.modifyHSL(t,null,null,e)}),colorAlpha:r(function(t,e){return d.modifyAlpha(t,e)}),symbol:{applyVisual:function(t,e,i){var n=this.mapValueToVisual(t);if(c.isString(n))i("symbol",n);else if(g(n))for(var a in n)n.hasOwnProperty(a)&&i(a,n[a])},mapValueToVisual:function(t){var e=this._normalizeData(t),i=this._getSpecifiedVisual(t),n=this.option.visual;return null==i&&(i=u(this)?h(this,n,e):s(n,e)||{}),i}},symbolSize:{applyVisual:function(t,e,i){i("symbolSize",this.mapValueToVisual(t))},mapValueToVisual:function(t){var e=this._normalizeData(t),i=this._getSpecifiedVisual(t),a=this.option.visual;return null==i&&(i=u(this)?h(this,a,e):n(e,[0,1],a,!0)),i}}},x={linear:function(t){return n(t,this.option.dataExtent,[0,1],!0)},piecewise:function(t){var e=this.option.pieceList,i=v.findPieceIndex(t,e);return null!=i?n(i,[0,e.length-1],[0,1],!0):void 0},category:function(t){var e=this.option.categories?this.option.categoryMap[t]:t;return null==e?m:e}},_={linear:c.noop,piecewise:function(t,e){var i=this.option,n=i.pieceList;if(i.hasSpecialVisual){var a=v.findPieceIndex(e,n),o=n[a];if(o&&o.visual)return o.visual[t]}},category:c.noop};v.addVisualHandler=function(t,e){y[t]=e},v.isValidType=function(t){return y.hasOwnProperty(t)},v.eachVisual=function(t,e,i){c.isObject(t)?c.each(t,e,i):e.call(i,t)},v.mapVisual=function(t,e,i){var n,a=c.isArray(t)?[]:c.isObject(t)?{}:(n=!0,null);return v.eachVisual(t,function(t,o){var r=e.call(i,t,o);n?a=r:a[o]=r}),a},v.isInVisualCluster=function(t,e){return"color"===e?!(!t||0!==t.indexOf(e)):t===e},v.retrieveVisuals=function(t){var e,i={};return t&&p(y,function(n,a){t.hasOwnProperty(a)&&(i[a]=t[a],e=!0)}),e?i:null},v.prepareVisualTypes=function(t){if(g(t)){var e=[];p(t,function(t,i){e.push(i)}),t=e}else{if(!c.isArray(t))return[];t=t.slice()}return t.sort(function(t,e){return"color"===e&&"color"!==t&&0===t.indexOf("color")?1:-1}),t},v.findPieceIndex=function(t,e){for(var i=0,n=e.length;n>i;i++){var a=e[i];if(null!=a.value&&a.value===t)return i}for(var i=0,n=e.length;n>i;i++){var a=e[i],o=a.interval;if(o)if(o[0]===-(1/0)){if(te&&o>n||e>o&&n>o)return 0;if(n===e)return 0;var r=e>n?1:-1,s=(o-e)/(n-e),l=s*(i-t)+t;return l>a?r:0}},function(t,e,i){"use strict";var n=i(1),a=i(16),o=function(t,e,i,n,o){this.x=null==t?0:t,this.y=null==e?0:e,this.x2=null==i?1:i,this.y2=null==n?0:n,a.call(this,o)};o.prototype={constructor:o,type:"linear",updateCanvasGradient:function(t,e){for(var i=t.getBoundingRect(),n=this.x*i.width+i.x,a=this.x2*i.width+i.x,o=this.y*i.height+i.y,r=this.y2*i.height+i.y,s=e.createLinearGradient(n,o,a,r),l=this.colorStops,h=0;hs||-s>t}var a=i(19),o=i(5),r=a.identity,s=5e-5,l=function(t){t=t||{},t.position||(this.position=[0,0]),null==t.rotation&&(this.rotation=0),t.scale||(this.scale=[1,1]),this.origin=this.origin||null},h=l.prototype;h.transform=null,h.needLocalTransform=function(){return n(this.rotation)||n(this.position[0])||n(this.position[1])||n(this.scale[0]-1)||n(this.scale[1]-1)},h.updateTransform=function(){var t=this.parent,e=t&&t.transform,i=this.needLocalTransform(),n=this.transform;return i||e?(n=n||a.create(),i?this.getLocalTransform(n):r(n),e&&(i?a.mul(n,t.transform,n):a.copy(n,t.transform)),this.transform=n,this.invTransform=this.invTransform||a.create(),void a.invert(this.invTransform,n)):void(n&&r(n))},h.getLocalTransform=function(t){t=t||[],r(t);var e=this.origin,i=this.scale,n=this.rotation,o=this.position;return e&&(t[4]-=e[0],t[5]-=e[1]),a.scale(t,t,i),n&&a.rotate(t,t,n),e&&(t[4]+=e[0],t[5]+=e[1]),t[4]+=o[0],t[5]+=o[1],t},h.setTransform=function(t){var e=this.transform;e&&t.transform(e[0],e[1],e[2],e[3],e[4],e[5])};var u=[];h.decomposeTransform=function(){if(this.transform){var t=this.parent,e=this.transform;t&&t.transform&&(a.mul(u,t.invTransform,e),e=u);var i=e[0]*e[0]+e[1]*e[1],o=e[2]*e[2]+e[3]*e[3],r=this.position,s=this.scale;n(i-1)&&(i=Math.sqrt(i)),n(o-1)&&(o=Math.sqrt(o)),e[0]<0&&(i=-i),e[3]<0&&(o=-o),r[0]=e[4],r[1]=e[5],s[0]=i,s[1]=o,this.rotation=Math.atan2(-e[1]/o,e[0]/i)}},h.transformCoordToLocal=function(t,e){var i=[t,e],n=this.invTransform;return n&&o.applyTransform(i,i,n),i},h.transformCoordToGlobal=function(t,e){var i=[t,e],n=this.transform;return n&&o.applyTransform(i,i,n),i},t.exports=l},function(t,e,i){"use strict";function n(t){a.each(o,function(e){this[e]=a.bind(t[e],t)},this)}var a=i(1),o=["getDom","getZr","getWidth","getHeight","dispatchAction","on","off","getDataURL","getConnectedDataURL","getModel","getOption"];t.exports=n},function(t,e,i){var n=i(1);i(51),i(80),i(81);var a=i(109),o=i(2);o.registerLayout(n.curry(a,"bar")),o.registerVisualCoding("chart",function(t){t.eachSeriesByType("bar",function(t){var e=t.getData();e.setVisual("legendSymbol","roundRect")})}),i(34)},function(t,e,i){"use strict";var n=i(13),a=i(36);t.exports=n.extend({type:"series.bar",dependencies:["grid","polar"],getInitialData:function(t,e){return a(t.data,this,e)},getMarkerPosition:function(t){var e=this.coordinateSystem;if(e){var i=e.dataToPoint(t),n=this.getData(),a=n.getLayout("offset"),o=n.getLayout("size"),r=e.getBaseAxis().isHorizontal()?0:1;return i[r]+=a+o/2,i}return[NaN,NaN]},defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,xAxisIndex:0,yAxisIndex:0,barMinHeight:0,itemStyle:{normal:{barBorderColor:"#fff",barBorderWidth:0},emphasis:{barBorderColor:"#fff",barBorderWidth:0}}}})},function(t,e,i){"use strict";function n(t,e){var i=t.width>0?1:-1,n=t.height>0?1:-1;e=Math.min(e,Math.abs(t.width),Math.abs(t.height)),t.x+=i*e/2,t.y+=n*e/2,t.width-=i*e,t.height-=n*e}var a=i(1),o=i(3);a.extend(i(12).prototype,i(82)),t.exports=i(2).extendChartView({type:"bar",render:function(t,e,i){var n=t.get("coordinateSystem");return"cartesian2d"===n&&this._renderOnCartesian(t,e,i),this.group},_renderOnCartesian:function(t,e,i){function r(e,i){var r=l.getItemLayout(e),s=l.getItemModel(e).get(p)||0;n(r,s);var h=new o.Rect({shape:a.extend({},r)});if(f){var u=h.shape,c=d?"height":"width",g={};u[c]=0,g[c]=r[c],o[i?"updateProps":"initProps"](h,{shape:g},t)}return h}var s=this.group,l=t.getData(),h=this._data,u=t.coordinateSystem,c=u.getBaseAxis(),d=c.isHorizontal(),f=t.get("animation"),p=["itemStyle","normal","barBorderWidth"];l.diff(h).add(function(t){if(l.hasValue(t)){var e=r(t);l.setItemGraphicEl(t,e),s.add(e)}}).update(function(e,i){var a=h.getItemGraphicEl(i);if(!l.hasValue(e))return void s.remove(a);a||(a=r(e,!0));var u=l.getItemLayout(e),c=l.getItemModel(e).get(p)||0;n(u,c),o.updateProps(a,{shape:u},t),l.setItemGraphicEl(e,a),s.add(a)}).remove(function(e){var i=h.getItemGraphicEl(e);i&&(i.style.text="",o.updateProps(i,{shape:{width:0}},t,function(){s.remove(i)}))}).execute(),this._updateStyle(t,l,d),this._data=l},_updateStyle:function(t,e,i){function n(t,e,i,n,a){o.setText(t,e,i),t.text=n,"outside"===t.textPosition&&(t.textPosition=a)}e.eachItemGraphicEl(function(r,s){var l=e.getItemModel(s),h=e.getItemVisual(s,"color"),u=e.getItemLayout(s),c=l.getModel("itemStyle.normal"),d=l.getModel("itemStyle.emphasis").getItemStyle();r.setShape("r",c.get("barBorderRadius")||0),r.setStyle(a.defaults({fill:h},c.getBarItemStyle()));var f=i?u.height>0?"bottom":"top":u.width>0?"left":"right",p=l.getModel("label.normal"),g=l.getModel("label.emphasis"),m=r.style;p.get("show")?n(m,p,h,a.retrieve(t.getFormattedLabel(s,"normal"),t.getRawValue(s)),f):m.text="",g.get("show")?n(d,g,h,a.retrieve(t.getFormattedLabel(s,"emphasis"),t.getRawValue(s)),f):d.text="",o.setHoverStyle(r,d)})},remove:function(t,e){var i=this.group;t.get("animation")?this._data&&this._data.eachItemGraphicEl(function(e){e.style.text="",o.updateProps(e,{shape:{width:0}},t,function(){i.remove(e)})}):i.removeAll()}})},function(t,e,i){t.exports={getBarItemStyle:i(30)([["fill","color"],["stroke","barBorderColor"],["lineWidth","barBorderWidth"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]])}},function(t,e,i){function n(t,e,i){var n=e.getItemVisual(i,"color"),a=e.getItemVisual(i,"symbol"),o=e.getItemVisual(i,"symbolSize");if("none"!==a){p.isArray(o)||(o=[o,o]);var r=u.createSymbol(a,-o[0]/2,-o[1]/2,o[0],o[1],n);return r.name=t,r}}function a(t){var e=new d({name:"line",style:{strokeNoScale:!0}});return o(e.shape,t),e}function o(t,e){var i=e[0],n=e[1],a=e[2];t.x1=i[0],t.y1=i[1],t.x2=n[0],t.y2=n[1],t.percent=1,a&&(t.cpx1=a[0],t.cpy1=a[1])}function r(t){return"symbol"===t.type&&"arrow"===t.shape.symbolType}function s(){var t=this,e=t.childOfName("line");if(this.__dirty||e.__dirty){var i=t.childOfName("fromSymbol"),n=t.childOfName("toSymbol"),a=t.childOfName("label"),o=e.pointAt(0),s=e.pointAt(e.shape.percent),h=c.sub([],s,o);c.normalize(h,h),i&&(i.attr("position",o),r(i)&&i.attr("rotation",l(s,o))),n&&(n.attr("position",s),r(n)&&n.attr("rotation",l(o,s))),a.attr("position",s);var u,d,f;"end"===a.__position?(u=[5*h[0]+s[0],5*h[1]+s[1]],d=h[0]>.8?"left":h[0]<-.8?"right":"center",f=h[1]>.8?"top":h[1]<-.8?"bottom":"middle"):(u=[5*-h[0]+o[0],5*-h[1]+o[1]],d=h[0]>.8?"right":h[0]<-.8?"left":"center",f=h[1]>.8?"bottom":h[1]<-.8?"top":"middle"),a.attr({style:{textVerticalAlign:a.__verticalAlign||f,textAlign:a.__textAlign||d},position:u})}}function l(t,e){return-Math.PI/2-Math.atan2(e[1]-t[1],e[0]-t[0])}function h(t,e,i,n){f.Group.call(this),this._createLine(t,e,i,n)}var u=i(24),c=i(5),d=i(161),f=i(3),p=i(1),g=i(4),m=h.prototype;m.beforeUpdate=s,m._createLine=function(t,e,i,o){var r=t.hostModel,s=t.getItemLayout(o),l=a(s);l.shape.percent=0,f.initProps(l,{shape:{percent:1}},r),this.add(l);var h=new f.Text({name:"label"});if(this.add(h),e){var u=n("fromSymbol",e,o);this.add(u),this._fromSymbolType=e.getItemVisual(o,"symbol")}if(i){var c=n("toSymbol",i,o);this.add(c),this._toSymbolType=i.getItemVisual(o,"symbol")}this._updateCommonStl(t,e,i,o)},m.updateData=function(t,e,i,a){var r=t.hostModel,s=this.childOfName("line"),l=t.getItemLayout(a),h={shape:{}};if(o(h.shape,l),f.updateProps(s,h,r),e){var u=e.getItemVisual(a,"symbol");if(this._fromSymbolType!==u){var c=n("fromSymbol",e,a);this.remove(this.childOfName("fromSymbol")),this.add(c)}this._fromSymbolType=u}if(i){var d=i.getItemVisual(a,"symbol");if(d!==this._toSymbolType){var p=n("toSymbol",i,a);this.remove(this.childOfName("toSymbol")),this.add(p)}this._toSymbolType=d}this._updateCommonStl(t,e,i,a)},m._updateCommonStl=function(t,e,i,n){var a=t.hostModel,o=this.childOfName("line"),r=t.getItemModel(n),s=r.getModel("label.normal"),l=s.getModel("textStyle"),h=r.getModel("label.emphasis"),u=h.getModel("textStyle"),c=g.round(a.getRawValue(n));isNaN(c)&&(c=t.getName(n)),o.setStyle(p.extend({stroke:t.getItemVisual(n,"color")},r.getModel("lineStyle.normal").getLineStyle()));var d=this.childOfName("label");d.setStyle({text:s.get("show")?p.retrieve(a.getFormattedLabel(n,"normal"),c):"",textFont:l.getFont(),fill:l.getTextColor()||t.getItemVisual(n,"color")}),d.hoverStyle={text:h.get("show")?p.retrieve(a.getFormattedLabel(n,"emphasis"),c):"",textFont:l.getFont(),fill:u.getTextColor()},d.__textAlign=l.get("align"),d.__verticalAlign=l.get("baseline"),d.__position=s.get("position"),f.setHoverStyle(this,r.getModel("lineStyle.emphasis").getLineStyle())},m.updateLayout=function(t,e,i,n){var a=t.getItemLayout(n),r=this.childOfName("line");o(r.shape,a),r.dirty(!0),e&&e.getItemGraphicEl(n).attr("position",a[0]),i&&i.getItemGraphicEl(n).attr("position",a[1])},p.inherits(h,f.Group),t.exports=h},function(t,e,i){function n(t){this._ctor=t||o,this.group=new a.Group}var a=i(3),o=i(83),r=n.prototype;r.updateData=function(t,e,i){var n=this._lineData,a=this.group,o=this._ctor;t.diff(n).add(function(n){var r=new o(t,e,i,n);t.setItemGraphicEl(n,r),a.add(r)}).update(function(o,r){var s=n.getItemGraphicEl(r);s.updateData(t,e,i,o),t.setItemGraphicEl(o,s),a.add(s)}).remove(function(t){a.remove(n.getItemGraphicEl(t))}).execute(),this._lineData=t,this._fromData=e,this._toData=i},r.updateLayout=function(){var t=this._lineData;t.eachItemGraphicEl(function(e,i){e.updateLayout(t,this._fromData,this._toData,i)},this)},r.remove=function(){this.group.removeAll()},t.exports=n},function(t,e,i){var n=i(1),a=i(2);i(86),i(87),a.registerVisualCoding("chart",n.curry(i(44),"line","circle","line")),a.registerLayout(n.curry(i(53),"line")),a.registerProcessor("statistic",n.curry(i(121),"line")),i(34)},function(t,e,i){"use strict";var n=i(36),a=i(13);t.exports=a.extend({type:"series.line",dependencies:["grid","polar"],getInitialData:function(t,e){return n(t.data,this,e)},defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,hoverAnimation:!0,xAxisIndex:0,yAxisIndex:0,polarIndex:0,clipOverflow:!0,label:{normal:{position:"top"}},lineStyle:{normal:{width:2,type:"solid"}},symbol:"emptyCircle",symbolSize:4,showSymbol:!0,animationEasing:"linear"}})},function(t,e,i){"use strict";function n(t,e){if(t.length===e.length){for(var i=0;ie[0]?1:-1;e[0]+=n*i,e[1]-=n*i}return e}function r(t){return t>=0?1:-1}function s(t,e){var i=t.getBaseAxis(),n=t.getOtherAxis(i),a=i.onZero?0:n.scale.getExtent()[0],o=n.dim,s="x"===o||"radius"===o?1:0;return e.mapArray([o],function(n,l){for(var h,u=e.stackedOn;u&&r(u.get(o,l))===r(n);){h=u;break}var c=[];return c[s]=e.get(i.dim,l),c[1-s]=h?h.get(o,l,!0):a,t.dataToPoint(c)},!0)}function l(t,e){return null!=e.dataIndex?e.dataIndex:null!=e.name?t.indexOfName(e.name):void 0}function h(t,e,i){var n=o(t.getAxis("x")),a=o(t.getAxis("y")),r=t.getBaseAxis().isHorizontal(),s=n[0],l=a[0],h=n[1]-s,u=a[1]-l;i.get("clipOverflow")||(r?(l-=u,u*=3):(s-=h,h*=3));var c=new m.Rect({shape:{x:s,y:l,width:h,height:u}});return e&&(c.shape[r?"width":"height"]=0,m.initProps(c,{shape:{width:h,height:u}},i)),c}function u(t,e,i){var n=t.getAngleAxis(),a=t.getRadiusAxis(),o=a.getExtent(),r=n.getExtent(),s=Math.PI/180,l=new m.Sector({shape:{cx:t.cx,cy:t.cy,r0:o[0],r:o[1],startAngle:-r[0]*s,endAngle:-r[1]*s,clockwise:n.inverse}});return e&&(l.shape.endAngle=-r[0]*s,m.initProps(l,{shape:{endAngle:-r[1]*s}},i)),l}function c(t,e,i){return"polar"===t.type?u(t,e,i):h(t,e,i)}var d=i(1),f=i(38),p=i(47),g=i(88),m=i(3),v=i(89),y=i(25);t.exports=y.extend({type:"line",init:function(){var t=new m.Group,e=new f;this.group.add(e.group),this._symbolDraw=e,this._lineGroup=t},render:function(t,e,i){var o=t.coordinateSystem,r=this.group,l=t.getData(),h=t.getModel("lineStyle.normal"),u=t.getModel("areaStyle.normal"),f=l.mapArray(l.getItemLayout,!0),p="polar"===o.type,g=this._coordSys,m=this._symbolDraw,v=this._polyline,y=this._polygon,x=this._lineGroup,_=t.get("animation"),w=!u.isEmpty(),b=s(o,l),S=t.get("showSymbol"),M=S&&!p&&!t.get("showAllSymbol")&&this._getSymbolIgnoreFunc(l,o),A=this._data;A&&A.eachItemGraphicEl(function(t,e){t.__temp&&(r.remove(t),A.setItemGraphicEl(e,null))}),S||m.remove(),r.add(x),v&&g.type===o.type?(w&&!y?y=this._newPolygon(f,b,o,_):y&&!w&&(x.remove(y),y=this._polygon=null),x.setClipPath(c(o,!1,t)),S&&m.updateData(l,M),l.eachItemGraphicEl(function(t){t.stopAnimation(!0)}),n(this._stackedOnPoints,b)&&n(this._points,f)||(_?this._updateAnimation(l,b,o,i):(v.setShape({points:f}),y&&y.setShape({points:f,stackedOnPoints:b})))):(S&&m.updateData(l,M),v=this._newPolyline(f,o,_),w&&(y=this._newPolygon(f,b,o,_)),x.setClipPath(c(o,!0,t))),v.setStyle(d.defaults(h.getLineStyle(),{stroke:l.getVisual("color"),lineJoin:"bevel"}));var I=t.get("smooth");if(I=a(t.get("smooth")),v.setShape({smooth:I,smoothMonotone:t.get("smoothMonotone")}),y){var T=l.stackedOn,C=0;if(y.style.opacity=.7,y.setStyle(d.defaults(u.getAreaStyle(),{fill:l.getVisual("color"),lineJoin:"bevel"})),T){var L=T.hostModel;C=a(L.get("smooth"))}y.setShape({smooth:I,stackedOnSmooth:C,smoothMonotone:t.get("smoothMonotone")})}this._data=l,this._coordSys=o,this._stackedOnPoints=b,this._points=f},highlight:function(t,e,i,n){var a=t.getData(),o=l(a,n);if(null!=o&&o>=0){var r=a.getItemGraphicEl(o);if(!r){var s=a.getItemLayout(o);r=new p(a,o,i),r.position=s,r.setZ(t.get("zlevel"),t.get("z")),r.ignore=isNaN(s[0])||isNaN(s[1]),r.__temp=!0,a.setItemGraphicEl(o,r),r.stopSymbolAnimation(!0),this.group.add(r)}r.highlight()}else y.prototype.highlight.call(this,t,e,i,n)},downplay:function(t,e,i,n){var a=t.getData(),o=l(a,n);if(null!=o&&o>=0){var r=a.getItemGraphicEl(o);r&&(r.__temp?(a.setItemGraphicEl(o,null),this.group.remove(r)):r.downplay())}else y.prototype.downplay.call(this,t,e,i,n)},_newPolyline:function(t){var e=this._polyline;return e&&this._lineGroup.remove(e),e=new v.Polyline({shape:{points:t},silent:!0,z2:10}),this._lineGroup.add(e),this._polyline=e,e},_newPolygon:function(t,e){var i=this._polygon;return i&&this._lineGroup.remove(i),i=new v.Polygon({shape:{points:t,stackedOnPoints:e},silent:!0}),this._lineGroup.add(i),this._polygon=i,i},_getSymbolIgnoreFunc:function(t,e){var i=e.getAxesByScale("ordinal")[0];return i&&i.isLabelIgnored?d.bind(i.isLabelIgnored,i):void 0},_updateAnimation:function(t,e,i,n){var a=this._polyline,o=this._polygon,r=t.hostModel,s=g(this._data,t,this._stackedOnPoints,e,this._coordSys,i);a.shape.points=s.current,m.updateProps(a,{shape:{points:s.next}},r),o&&(o.setShape({points:s.current,stackedOnPoints:s.stackedOnCurrent}),m.updateProps(o,{shape:{points:s.next,stackedOnPoints:s.stackedOnNext}},r));for(var l=[],h=s.status,u=0;u=0?1:-1}function n(t,e,n){for(var a,o=t.getBaseAxis(),r=t.getOtherAxis(o),s=o.onZero?0:r.scale.getExtent()[0],l=r.dim,h="x"===l||"radius"===l?1:0,u=e.stackedOn,c=e.get(l,n);u&&i(u.get(l,n))===i(c);){a=u;break}var d=[];return d[h]=e.get(o.dim,n),d[1-h]=a?a.get(l,n,!0):s,t.dataToPoint(d)}function a(t,e){var i=[];return e.diff(t).add(function(t){i.push({cmd:"+",idx:t})}).update(function(t,e){i.push({cmd:"=",idx:e,idx1:t})}).remove(function(t){i.push({cmd:"-",idx:t})}).execute(),i}t.exports=function(t,e,i,o,r,s){for(var l=a(t,e),h=[],u=[],c=[],d=[],f=[],p=[],g=[],m=s.dimensions,v=0;vx;x++){var _=e[y];if(y>=n||0>y||isNaN(_[0])||isNaN(_[1]))break;if(y===i)t[o>0?"moveTo":"lineTo"](_[0],_[1]),u(d,_);else if(m>0){var w=y-o,b=y+o,S=.5,M=e[w],A=e[b];if(o>0&&(y===a-1||isNaN(A[0])||isNaN(A[1]))||0>=o&&(0===y||isNaN(A[0])||isNaN(A[1])))u(f,_);else{(isNaN(A[0])||isNaN(A[1]))&&(A=_),r.sub(c,A,M);var I,T;if("x"===v||"y"===v){var C="x"===v?0:1;I=Math.abs(_[C]-M[C]),T=Math.abs(_[C]-A[C])}else I=r.dist(_,M),T=r.dist(_,A);S=T/(T+I),h(f,_,c,-m*(1-S))}s(d,d,g),l(d,d,p),s(f,f,g),l(f,f,p),t.bezierCurveTo(d[0],d[1],f[0],f[1],_[0],_[1]),h(d,_,c,m*S)}else t.lineTo(_[0],_[1]);y+=o}return x}function a(t,e){var i=[1/0,1/0],n=[-(1/0),-(1/0)];if(e)for(var a=0;an[0]&&(n[0]=o[0]),o[1]>n[1]&&(n[1]=o[1])}return{min:e?i:n,max:e?n:i}}var o=i(6),r=i(5),s=r.min,l=r.max,h=r.scaleAndAdd,u=r.copy,c=[],d=[],f=[];t.exports={Polyline:o.extend({type:"ec-polyline",shape:{points:[],smooth:0,smoothConstraint:!0,smoothMonotone:null},style:{fill:null,stroke:"#000"},buildPath:function(t,e){for(var i=e.points,o=0,r=i.length,s=a(i,e.smoothConstraint);r>o;)o+=n(t,i,o,r,r,1,s.min,s.max,e.smooth,e.smoothMonotone)+1}}),Polygon:o.extend({type:"ec-polygon",shape:{points:[],stackedOnPoints:[],smooth:0,stackedOnSmooth:0,smoothConstraint:!0,smoothMonotone:null},buildPath:function(t,e){for(var i=e.points,o=e.stackedOnPoints,r=0,s=i.length,l=e.smoothMonotone,h=a(i,e.smoothConstraint),u=a(o,e.smoothConstraint);s>r;){var c=n(t,i,r,s,s,1,h.min,h.max,e.smooth,l);n(t,o,r+c-1,s,c,-1,u.min,u.max,e.stackedOnSmooth,l),r+=c+1,t.closePath()}}})}},function(t,e,i){var n=i(1),a=i(2);i(91),i(92),i(68)("pie",[{type:"pieToggleSelect",event:"pieselectchanged",method:"toggleSelected"},{type:"pieSelect",event:"pieselected",method:"select"},{type:"pieUnSelect",event:"pieunselected",method:"unSelect"}]),a.registerVisualCoding("chart",n.curry(i(63),"pie")),a.registerLayout(n.curry(i(94),"pie")),a.registerProcessor("filter",n.curry(i(62),"pie"))},function(t,e,i){"use strict";var n=i(14),a=i(1),o=i(7),r=i(31),s=i(69),l=i(2).extendSeriesModel({type:"series.pie",init:function(t){l.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._dataBeforeProcessed},this.updateSelectedMap(),this._defaultLabelLine(t)},mergeOption:function(t){l.superCall(this,"mergeOption",t),this.updateSelectedMap()},getInitialData:function(t,e){var i=r(["value"],t.data),a=new n(i,this);return a.initData(t.data),a},getDataParams:function(t){var e=this._data,i=l.superCall(this,"getDataParams",t),n=e.getSum("value");return i.percent=n?+(e.get("value",t)/n*100).toFixed(2):0,i.$vars.push("percent"),i},_defaultLabelLine:function(t){o.defaultEmphasis(t.labelLine,["show"]);var e=t.labelLine.normal,i=t.labelLine.emphasis;e.show=e.show&&t.label.normal.show,i.show=i.show&&t.label.emphasis.show},defaultOption:{zlevel:0,z:2,legendHoverLink:!0,hoverAnimation:!0,center:["50%","50%"],radius:[0,"75%"],clockwise:!0,startAngle:90,minAngle:0,selectedOffset:10,avoidLabelOverlap:!0,label:{normal:{rotate:!1,show:!0,position:"outer"},emphasis:{}},labelLine:{normal:{show:!0,length:20,length2:5,smooth:!1,lineStyle:{width:1,type:"solid"}}},itemStyle:{normal:{borderColor:"rgba(0,0,0,0)",borderWidth:1},emphasis:{borderColor:"rgba(0,0,0,0)",borderWidth:1}},animationEasing:"cubicOut",data:[] +}});a.mixin(l,s),t.exports=l},function(t,e,i){function n(t,e,i,n){var o=e.getData(),r=this.dataIndex,s=o.getName(r),l=e.get("selectedOffset");n.dispatchAction({type:"pieToggleSelect",from:t,name:s,seriesId:e.id}),o.each(function(t){a(o.getItemGraphicEl(t),o.getItemLayout(t),e.isSelected(o.getName(t)),l,i)})}function a(t,e,i,n,a){var o=(e.startAngle+e.endAngle)/2,r=Math.cos(o),s=Math.sin(o),l=i?n:0,h=[r*l,s*l];a?t.animate().when(200,{position:h}).start("bounceOut"):t.attr("position",h)}function o(t,e){function i(){o.ignore=o.hoverIgnore,r.ignore=r.hoverIgnore}function n(){o.ignore=o.normalIgnore,r.ignore=r.normalIgnore}s.Group.call(this);var a=new s.Sector({z2:2}),o=new s.Polyline,r=new s.Text;this.add(a),this.add(o),this.add(r),this.updateData(t,e,!0),this.on("emphasis",i).on("normal",n).on("mouseover",i).on("mouseout",n)}function r(t,e,i,n,a){var o=n.getModel("textStyle"),r="inside"===a||"inner"===a;return{fill:o.getTextColor()||(r?"#fff":t.getItemVisual(e,"color")),textFont:o.getFont(),text:l.retrieve(t.hostModel.getFormattedLabel(e,i),t.getName(e))}}var s=i(3),l=i(1),h=o.prototype;h.updateData=function(t,e,i){function n(){r.stopAnimation(!0),r.animateTo({shape:{r:c.r+10}},300,"elasticOut")}function o(){r.stopAnimation(!0),r.animateTo({shape:{r:c.r}},300,"elasticOut")}var r=this.childAt(0),h=t.hostModel,u=t.getItemModel(e),c=t.getItemLayout(e),d=l.extend({},c);d.label=null,i?(r.setShape(d),r.shape.endAngle=c.startAngle,s.updateProps(r,{shape:{endAngle:c.endAngle}},h)):s.updateProps(r,{shape:d},h);var f=u.getModel("itemStyle"),p=t.getItemVisual(e,"color");r.setStyle(l.defaults({fill:p},f.getModel("normal").getItemStyle())),r.hoverStyle=f.getModel("emphasis").getItemStyle(),a(this,t.getItemLayout(e),u.get("selected"),h.get("selectedOffset"),h.get("animation")),r.off("mouseover").off("mouseout").off("emphasis").off("normal"),u.get("hoverAnimation")&&r.on("mouseover",n).on("mouseout",o).on("emphasis",n).on("normal",o),this._updateLabel(t,e),s.setHoverStyle(this)},h._updateLabel=function(t,e){var i=this.childAt(1),n=this.childAt(2),a=t.hostModel,o=t.getItemModel(e),l=t.getItemLayout(e),h=l.label,u=t.getItemVisual(e,"color");s.updateProps(i,{shape:{points:h.linePoints||[[h.x,h.y],[h.x,h.y],[h.x,h.y]]}},a),s.updateProps(n,{style:{x:h.x,y:h.y}},a),n.attr({style:{textVerticalAlign:h.verticalAlign,textAlign:h.textAlign,textFont:h.font},rotation:h.rotation,origin:[h.x,h.y],z2:10});var c=o.getModel("label.normal"),d=o.getModel("label.emphasis"),f=o.getModel("labelLine.normal"),p=o.getModel("labelLine.emphasis"),g=c.get("position")||d.get("position");n.setStyle(r(t,e,"normal",c,g)),n.ignore=n.normalIgnore=!c.get("show"),n.hoverIgnore=!d.get("show"),i.ignore=i.normalIgnore=!f.get("show"),i.hoverIgnore=!p.get("show"),i.setStyle({stroke:u}),i.setStyle(f.getModel("lineStyle").getLineStyle()),n.hoverStyle=r(t,e,"emphasis",d,g),i.hoverStyle=p.getModel("lineStyle").getLineStyle();var m=f.get("smooth");m&&m===!0&&(m=.4),i.setShape({smooth:m})},l.inherits(o,s.Group);var u=i(25).extend({type:"pie",init:function(){var t=new s.Group;this._sectorGroup=t},render:function(t,e,i,a){if(!a||a.from!==this.uid){var r=t.getData(),s=this._data,h=this.group,u=e.get("animation"),c=!s,d=l.curry(n,this.uid,t,u,i),f=t.get("selectedMode");if(r.diff(s).add(function(t){var e=new o(r,t);c&&e.eachChild(function(t){t.stopAnimation(!0)}),f&&e.on("click",d),r.setItemGraphicEl(t,e),h.add(e)}).update(function(t,e){var i=s.getItemGraphicEl(e);i.updateData(r,t),i.off("click"),f&&i.on("click",d),h.add(i),r.setItemGraphicEl(t,i)}).remove(function(t){var e=s.getItemGraphicEl(t);h.remove(e)}).execute(),u&&c&&r.count()>0){var p=r.getItemLayout(0),g=Math.max(i.getWidth(),i.getHeight())/2,m=l.bind(h.removeClipPath,h);h.setClipPath(this._createClipPath(p.cx,p.cy,g,p.startAngle,p.clockwise,m,t))}this._data=r}},_createClipPath:function(t,e,i,n,a,o,r){var l=new s.Sector({shape:{cx:t,cy:e,r0:0,r:i,startAngle:n,endAngle:n,clockwise:a}});return s.initProps(l,{shape:{endAngle:n+(a?1:-1)*Math.PI*2}},r,o),l}});t.exports=u},function(t,e,i){"use strict";function n(t,e,i,n,a,o,r){function s(e,i,n,a){for(var o=e;i>o;o++)if(t[o].y+=n,o>e&&i>o+1&&t[o+1].y>t[o].y+t[o].height)return void l(o,n/2);l(i-1,n/2)}function l(e,i){for(var n=e;n>=0&&(t[n].y-=i,!(n>0&&t[n].y>t[n-1].y+t[n-1].height));n--);}t.sort(function(t,e){return t.y-e.y});for(var h,u=0,c=t.length,d=[],f=[],p=0;c>p;p++)h=t[p].y-u,0>h&&s(p,c,-h,a),u=t[p].y+t[p].height;0>r-u&&l(c-1,u-r);for(var p=0;c>p;p++)t[p].y>=i?f.push(t[p]):d.push(t[p])}function a(t,e,i,a,o,r){for(var s=[],l=[],h=0;hw?-1:1)*x,L=T;n=C+(0>w?-5:5),a=L,c=[[M,A],[I,T],[C,L]]}d=S?"center":w>0?"left":"right"}var D=g.getModel("textStyle").getFont(),P=g.get("rotate")?0>w?-_+Math.PI:-_:0,k=t.getFormattedLabel(i,"normal")||l.getName(i),z=o.getBoundingRect(k,D,d,"top");u=!!P,f.label={x:n,y:a,height:z.height,length:y,length2:x,linePoints:c,textAlign:d,verticalAlign:"middle",font:D,rotation:P},h.push(f.label)}),!u&&t.get("avoidLabelOverlap")&&a(h,r,s,e,i,n)}},function(t,e,i){var n=i(4),a=n.parsePercent,o=i(93),r=i(1),s=2*Math.PI,l=Math.PI/180;t.exports=function(t,e,i){e.eachSeriesByType(t,function(t){var e=t.get("center"),h=t.get("radius");r.isArray(h)||(h=[0,h]),r.isArray(e)||(e=[e,e]);var u=i.getWidth(),c=i.getHeight(),d=Math.min(u,c),f=a(e[0],u),p=a(e[1],c),g=a(h[0],d/2),m=a(h[1],d/2),v=t.getData(),y=-t.get("startAngle")*l,x=t.get("minAngle")*l,_=v.getSum("value"),w=Math.PI/(_||v.count())*2,b=t.get("clockwise"),S=t.get("roseType"),M=v.getDataExtent("value");M[0]=0;var A=s,I=0,T=y,C=b?1:-1;if(v.each("value",function(t,e){var i;i="area"!==S?0===_?w:t*w:s/(v.count()||1),x>i?(i=x,A-=x):I+=t;var a=T+C*i;v.setItemLayout(e,{angle:i,startAngle:T,endAngle:a,clockwise:b,cx:f,cy:p,r0:g,r:S?n.linearMap(t,M,[g,m]):m}),T=a},!0),s>A)if(.001>=A){var L=s/v.count();v.each(function(t){var e=v.getItemLayout(t);e.startAngle=y+C*t*L,e.endAngle=y+C*(t+1)*L})}else w=A/I,T=y,v.each("value",function(t,e){var i=v.getItemLayout(e),n=i.angle===x?x:t*w;i.startAngle=T,i.endAngle=T+C*n,T+=n});o(t,m,u,c)})}},function(t,e,i){"use strict";i(50),i(96)},function(t,e,i){function n(t,e){function i(t,e){var i=n.getAxis(t);return i.toGlobalCoord(i.dataToCoord(0))}var n=t.coordinateSystem,a=e.axis,o={},r=a.position,s=a.onZero?"onZero":r,l=a.dim,h=n.getRect(),u=[h.x,h.x+h.width,h.y,h.y+h.height],c={x:{top:u[2],bottom:u[3]},y:{left:u[0],right:u[1]}};c.x.onZero=Math.max(Math.min(i("y"),c.x.bottom),c.x.top),c.y.onZero=Math.max(Math.min(i("x"),c.y.right),c.y.left),o.position=["y"===l?c.y[s]:u[0],"x"===l?c.x[s]:u[3]];var d={x:0,y:1};o.rotation=Math.PI/2*d[l];var f={top:-1,bottom:1,left:-1,right:1};o.labelDirection=o.tickDirection=o.nameDirection=f[r],a.onZero&&(o.labelOffset=c[l][r]-c[l].onZero),e.getModel("axisTick").get("inside")&&(o.tickDirection=-o.tickDirection),e.getModel("axisLabel").get("inside")&&(o.labelDirection=-o.labelDirection);var p=e.getModel("axisLabel").get("rotate");return o.labelRotation="top"===s?-p:p,o.labelInterval=a.getLabelInterval(),o.z2=1,o}var a=i(1),o=i(3),r=i(48),s=r.ifIgnoreOnTick,l=r.getInterval,h=["axisLine","axisLabel","axisTick","axisName"],u=["splitLine","splitArea"],c=i(2).extendComponentView({type:"axis",render:function(t,e){if(this.group.removeAll(),t.get("show")){var i=e.getComponent("grid",t.get("gridIndex")),o=n(i,t),s=new r(t,o);a.each(h,s.add,s),this.group.add(s.getGroup()),a.each(u,function(e){t.get(e+".show")&&this["_"+e](t,i,o.labelInterval)},this)}},_splitLine:function(t,e,i){var n=t.axis,r=t.getModel("splitLine"),h=r.getModel("lineStyle"),u=h.get("width"),c=h.get("color"),d=l(r,i);c=a.isArray(c)?c:[c];for(var f=e.coordinateSystem.getRect(),p=n.isHorizontal(),g=[],m=0,v=n.getTicksCoords(),y=[],x=[],_=0;_=0;a--){var o=i[a];if(o[n])break}if(0>a){var r=t.queryComponents({mainType:"dataZoom",subType:"select",id:n})[0];if(r){var s=r.getPercentRange();i[0][n]={dataZoomId:n,start:s[0],end:s[1]}}}}),i.push(e)},pop:function(t){var e=n(t),i=e[e.length-1];e.length>1&&e.pop();var a={};return o(i,function(t,i){for(var n=e.length-1;n>=0;n--){var t=e[n][i];if(t){a[i]=t;break}}}),a},clear:function(t){t[r]=null},count:function(t){return n(t).length}};t.exports=s},function(t,e,i){i(10).registerSubTypeDefaulter("dataZoom",function(t){return"slider"})},function(t,e){function i(t){return t[n]||(t[n]={})}var n="\x00_ec_interaction_mutex",a={take:function(t,e){i(e)[t]=!0},release:function(t,e){i(e)[t]=!1},isTaken:function(t,e){return!!i(e)[t]}};t.exports=a},function(t,e,i){function n(t,e,i){a.positionGroup(t,e.getBoxLayoutParams(),{width:i.getWidth(),height:i.getHeight()},e.get("padding"))}var a=i(11),o=i(9),r=i(3);t.exports={layout:function(t,e,i){var o=a.getLayoutRect(e.getBoxLayoutParams(),{width:i.getWidth(),height:i.getHeight()},e.get("padding"));a.box(e.get("orient"),t,e.get("itemGap"),o.width,o.height),n(t,e,i)},addBackground:function(t,e){var i=o.normalizeCssArray(e.get("padding")),n=t.getBoundingRect(),a=e.getItemStyle(["color","opacity"]);a.fill=e.get("backgroundColor");var s=new r.Rect({shape:{x:n.x-i[3],y:n.y-i[0],width:n.width+i[1]+i[3],height:n.height+i[0]+i[2]},style:a,silent:!0,z2:-1});r.subPixelOptimizeRect(s),t.add(s)}}},function(t,e,i){function n(t,e,i){var n=-1;do n=Math.max(r.getPrecision(t.get(e,i)),n),t=t.stackedOn;while(t);return n}function a(t,e,i,a,o,r){var s=[],l=p(e,a,t),h=e.indexOfNearest(a,l,!0);s[o]=e.get(i,h,!0),s[r]=e.get(a,h,!0);var u=n(e,a,h);return u>=0&&(s[r]=+s[r].toFixed(u)),s}var o=i(1),r=i(4),s=o.indexOf,l=o.curry,h={min:l(a,"min"),max:l(a,"max"),average:l(a,"average")},u=function(t,e){var i=t.getData(),n=t.coordinateSystem;if((isNaN(e.x)||isNaN(e.y))&&!o.isArray(e.coord)&&n){var a=c(e,i,n,t);if(e=o.clone(e),e.type&&h[e.type]&&a.baseAxis&&a.valueAxis){var r=n.dimensions,l=s(r,a.baseAxis.dim),u=s(r,a.valueAxis.dim);e.coord=h[e.type](i,a.baseDataDim,a.valueDataDim,l,u),e.value=e.coord[u]}else e.coord=[null!=e.xAxis?e.xAxis:e.radiusAxis,null!=e.yAxis?e.yAxis:e.angleAxis]}return e},c=function(t,e,i,n){var a={};return null!=t.valueIndex||null!=t.valueDim?(a.valueDataDim=null!=t.valueIndex?e.getDimension(t.valueIndex):t.valueDim,a.valueAxis=i.getAxis(n.dataDimToCoordDim(a.valueDataDim)),a.baseAxis=i.getOtherAxis(a.valueAxis),a.baseDataDim=n.coordDimToDataDim(a.baseAxis.dim)[0]):(a.baseAxis=n.getBaseAxis(),a.valueAxis=i.getOtherAxis(a.baseAxis),a.baseDataDim=n.coordDimToDataDim(a.baseAxis.dim)[0],a.valueDataDim=n.coordDimToDataDim(a.valueAxis.dim)[0]),a},d=function(t,e){return t&&e.coord&&(null==e.x||null==e.y)?t.containData(e.coord):!0},f=function(t,e,i,n){return 2>n?t.coord&&t.coord[n]:void t.value},p=function(t,e,i){return"average"===i?t.getSum(e,!0)/t.count():t.getDataExtent(e,!0)["max"===i?1:0]};t.exports={dataTransform:u,dataFilter:d,dimValueGetter:f,getAxisInfo:c,numCalculate:p}},function(t,e,i){var n=i(1),a=i(43),o=i(108),r=function(t,e,i,n,o){a.call(this,t,e,i),this.type=n||"value",this.position=o||"bottom"};r.prototype={constructor:r,index:0,onZero:!1,model:null,isHorizontal:function(){var t=this.position;return"top"===t||"bottom"===t},getGlobalExtent:function(){var t=this.getExtent();return t[0]=this.toGlobalCoord(t[0]),t[1]=this.toGlobalCoord(t[1]),t},getLabelInterval:function(){var t=this._labelInterval;return t||(t=this._labelInterval=o(this)),t},isLabelIgnored:function(t){if("category"===this.type){var e=this.getLabelInterval();return"function"==typeof e&&!e(t,this.scale.getLabel(t))||t%(e+1)}},toLocalCoord:null,toGlobalCoord:null},n.inherits(r,a),t.exports=r},function(t,e,i){"use strict";function n(t){return this._axes[t]}var a=i(1),o=function(t){this._axes={},this._dimList=[],this.name=t||""};o.prototype={constructor:o,type:"cartesian",getAxis:function(t){return this._axes[t]},getAxes:function(){return a.map(this._dimList,n,this)},getAxesByScale:function(t){return t=t.toLowerCase(),a.filter(this.getAxes(),function(e){return e.scale.type===t})},addAxis:function(t){var e=t.dim;this._axes[e]=t,this._dimList.push(e)},dataToCoord:function(t){return this._dataCoordConvert(t,"dataToCoord")},coordToData:function(t){return this._dataCoordConvert(t,"coordToData")},_dataCoordConvert:function(t,e){for(var i=this._dimList,n=t instanceof Array?[]:{},a=0;ai&&(i=Math.min(i,u),u-=i,t.width=i,c--)}),d=(u-s)/(c+(c-1)*h),d=Math.max(d,0);var f,p=0;r.each(i,function(t,e){t.width||(t.width=d),f=t,p+=t.width*(1+h)}),f&&(p-=f.width*h);var g=-p/2;r.each(i,function(t,i){a[e][i]=a[e][i]||{offset:g,width:t.width},g+=t.width*(1+h)})}),a}function o(t,e,i){var o=a(r.filter(e.getSeriesByType(t),function(t){return!e.isSeriesFiltered(t)&&t.coordinateSystem&&"cartesian2d"===t.coordinateSystem.type})),s={};e.eachSeriesByType(t,function(t){var e=t.getData(),i=t.coordinateSystem,a=i.getBaseAxis(),r=n(t),l=o[a.index][r],h=l.offset,u=l.width,c=i.getOtherAxis(a),d=t.get("barMinHeight")||0,f=a.onZero?c.toGlobalCoord(c.dataToCoord(0)):c.getGlobalExtent()[0],p=i.dataToPoints(e,!0);s[r]=s[r]||[],e.setLayout({offset:h,size:u}),e.each(c.dim,function(t,i){if(!isNaN(t)){s[r][i]||(s[r][i]={p:f,n:f});var n,a,o,l,g=t>=0?"p":"n",m=p[i],v=s[r][i][g];c.isHorizontal()?(n=v,a=m[1]+h,o=m[0]-v,l=u,Math.abs(o)o?-1:1)*d),s[r][i][g]+=o):(n=m[0]+h,a=v,o=u,l=m[1]-v,Math.abs(l)=l?-1:1)*d),s[r][i][g]+=l),e.setItemLayout(i,{x:n,y:a,width:o,height:l})}},!0)},this)}var r=i(1),s=i(4),l=s.parsePercent;t.exports=o},function(t,e,i){var n=i(3),a=i(1),o=Math.PI;t.exports=function(t,e){e=e||{},a.defaults(e,{text:"loading",color:"#c23531",textColor:"#000",maskColor:"rgba(255, 255, 255, 0.8)",zlevel:0});var i=new n.Rect({style:{fill:e.maskColor},zlevel:e.zlevel,z:1e4}),r=new n.Arc({shape:{startAngle:-o/2,endAngle:-o/2+.1,r:10},style:{stroke:e.color,lineCap:"round",lineWidth:5},zlevel:e.zlevel,z:10001}),s=new n.Rect({style:{fill:"none",text:e.text,textPosition:"right",textDistance:10,textFill:e.textColor},zlevel:e.zlevel,z:10001});r.animateShape(!0).when(1e3,{endAngle:3*o/2}).start("circularInOut"),r.animateShape(!0).when(1e3,{startAngle:3*o/2}).delay(300).start("circularInOut");var l=new n.Group;return l.add(r),l.add(s),l.add(i),l.resize=function(){var e=t.getWidth()/2,n=t.getHeight()/2;r.setShape({cx:e,cy:n});var a=r.shape.r;s.setShape({x:e-a,y:n-a,width:2*a,height:2*a}),i.setShape({x:0,y:0,width:t.getWidth(),height:t.getHeight()})},l.resize(),l}},function(t,e,i){function n(t,e){for(var i in e)_.hasClass(i)||("object"==typeof e[i]?t[i]=t[i]?c.merge(t[i],e[i],!1):c.clone(e[i]):t[i]=e[i])}function a(t){t=t,this.option={},this.option[b]=1,this._componentsMap={},this._seriesIndices=null,n(t,this._theme.option),c.merge(t,w,!1),this.mergeOption(t)}function o(t,e){c.isArray(e)||(e=e?[e]:[]);var i={};return p(e,function(e){i[e]=(t[e]||[]).slice()}),i}function r(t,e){var i={};p(e,function(t,e){var n=t.exist;n&&(i[n.id]=t)}),p(e,function(e,n){var a=e.option;if(c.assert(!a||null==a.id||!i[a.id]||i[a.id]===e,"id duplicates: "+(a&&a.id)),a&&null!=a.id&&(i[a.id]=e),x(a)){var o=s(t,a,e.exist);e.keyInfo={mainType:t,subType:o}}}),p(e,function(t,e){var n=t.exist,a=t.option,o=t.keyInfo;if(x(a)){if(o.name=null!=a.name?a.name+"":n?n.name:"\x00-",n)o.id=n.id;else if(null!=a.id)o.id=a.id+"";else{var r=0;do o.id="\x00"+o.name+"\x00"+r++;while(i[o.id])}i[o.id]=t}})}function s(t,e,i){var n=e.type?e.type:i?i.subType:_.determineSubType(t,e);return n}function l(t){return m(t,function(t){return t.componentIndex})||[]}function h(t,e){return e.hasOwnProperty("subType")?g(t,function(t){return t.subType===e.subType}):t}function u(t){if(!t._seriesIndices)throw new Error("Series has not been initialized yet.")}var c=i(1),d=i(7),f=i(12),p=c.each,g=c.filter,m=c.map,v=c.isArray,y=c.indexOf,x=c.isObject,_=i(10),w=i(113),b="\x00_ec_inner",S=f.extend({constructor:S,init:function(t,e,i,n){i=i||{},this.option=null,this._theme=new f(i),this._optionManager=n},setOption:function(t,e){c.assert(!(b in t),"please use chart.getOption()"),this._optionManager.setOption(t,e),this.resetOption()},resetOption:function(t){var e=!1,i=this._optionManager;if(!t||"recreate"===t){var n=i.mountOption("recreate"===t);this.option&&"recreate"!==t?(this.restoreData(),this.mergeOption(n)):a.call(this,n),e=!0}if("timeline"!==t&&"media"!==t||this.restoreData(),!t||"recreate"===t||"timeline"===t){var o=i.getTimelineOption(this);o&&(this.mergeOption(o),e=!0)}if(!t||"recreate"===t||"media"===t){var r=i.getMediaOption(this,this._api);r.length&&p(r,function(t){this.mergeOption(t,e=!0)},this)}return e},mergeOption:function(t){function e(e,a){var s=d.normalizeToArray(t[e]),h=d.mappingToExists(n[e],s);r(e,h);var u=o(n,a);i[e]=[],n[e]=[],p(h,function(t,a){var o=t.exist,r=t.option;if(c.assert(x(r)||o,"Empty component definition"),r){var s=_.getClass(e,t.keyInfo.subType,!0);o&&o instanceof s?(o.mergeOption(r,this),o.optionUpdated(this)):(o=new s(r,this,this,c.extend({dependentModels:u,componentIndex:a},t.keyInfo)),o.optionUpdated(this))}else o.mergeOption({},this),o.optionUpdated(this);n[e][a]=o,i[e][a]=o.option},this),"series"===e&&(this._seriesIndices=l(n.series))}var i=this.option,n=this._componentsMap,a=[];p(t,function(t,e){null!=t&&(_.hasClass(e)?a.push(e):i[e]=null==i[e]?c.clone(t):c.merge(i[e],t,!0))}),_.topologicalTravel(a,_.getAllClassMainTypes(),e,this)},getOption:function(){var t=c.clone(this.option);return p(t,function(e,i){if(_.hasClass(i)){for(var e=d.normalizeToArray(e),n=e.length-1;n>=0;n--)d.isIdInner(e[n])&&e.splice(n,1);t[i]=e}}),delete t[b],t},getTheme:function(){return this._theme},getComponent:function(t,e){var i=this._componentsMap[t];return i?i[e||0]:void 0},queryComponents:function(t){var e=t.mainType;if(!e)return[];var i=t.index,n=t.id,a=t.name,o=this._componentsMap[e];if(!o||!o.length)return[];var r;if(null!=i)v(i)||(i=[i]),r=g(m(i,function(t){return o[t]}),function(t){return!!t});else if(null!=n){var s=v(n);r=g(o,function(t){return s&&y(n,t.id)>=0||!s&&t.id===n})}else if(null!=a){var l=v(a);r=g(o,function(t){return l&&y(a,t.name)>=0||!l&&t.name===a})}return h(r,t)},findComponents:function(t){function e(t){var e=a+"Index",i=a+"Id",n=a+"Name";return t&&(t.hasOwnProperty(e)||t.hasOwnProperty(i)||t.hasOwnProperty(n))?{mainType:a,index:t[e],id:t[i],name:t[n]}:null}function i(e){return t.filter?g(e,t.filter):e}var n=t.query,a=t.mainType,o=e(n),r=o?this.queryComponents(o):this._componentsMap[a];return i(h(r,t))},eachComponent:function(t,e,i){var n=this._componentsMap;if("function"==typeof t)i=e,e=t,p(n,function(t,n){p(t,function(t,a){e.call(i,n,t,a)})});else if(c.isString(t))p(n[t],e,i);else if(x(t)){var a=this.findComponents(t);p(a,e,i)}},getSeriesByName:function(t){var e=this._componentsMap.series;return g(e,function(e){return e.name===t})},getSeriesByIndex:function(t){return this._componentsMap.series[t]},getSeriesByType:function(t){var e=this._componentsMap.series;return g(e,function(e){return e.subType===t})},getSeries:function(){return this._componentsMap.series.slice()},eachSeries:function(t,e){u(this),p(this._seriesIndices,function(i){var n=this._componentsMap.series[i];t.call(e,n,i)},this)},eachRawSeries:function(t,e){p(this._componentsMap.series,t,e)},eachSeriesByType:function(t,e,i){u(this),p(this._seriesIndices,function(n){var a=this._componentsMap.series[n];a.subType===t&&e.call(i,a,n)},this)},eachRawSeriesByType:function(t,e,i){return p(this.getSeriesByType(t),e,i)},isSeriesFiltered:function(t){return u(this),c.indexOf(this._seriesIndices,t.componentIndex)<0},filterSeries:function(t,e){u(this);var i=g(this._componentsMap.series,t,e);this._seriesIndices=l(i)},restoreData:function(){var t=this._componentsMap;this._seriesIndices=l(t.series);var e=[];p(t,function(t,i){e.push(i)}),_.topologicalTravel(e,_.getAllClassMainTypes(),function(e,i){p(t[e],function(t){t.restoreData()})})}});t.exports=S},function(t,e,i){function n(t){this._api=t,this._timelineOptions=[],this._mediaList=[],this._mediaDefault,this._currentMediaIndices=[],this._optionBackup,this._newOptionBackup}function a(t,e){var i,n,a=[],o=[],r=t.timeline;if(t.baseOption&&(n=t.baseOption),(r||t.options)&&(n=n||{},a=(t.options||[]).slice()),t.media){n=n||{};var s=t.media;d(s,function(t){t&&t.option&&(t.query?o.push(t):i||(i=t))})}return n||(n=t),n.timeline||(n.timeline=r),d([n].concat(a).concat(h.map(o,function(t){return t.option})),function(t){d(e,function(e){e(t)})}),{baseOption:n,timelineOptions:a,mediaDefault:i,mediaList:o}}function o(t,e,i){var n={width:e,height:i,aspectratio:e/i},a=!0;return h.each(t,function(t,e){var i=e.match(m);if(i&&i[1]&&i[2]){var o=i[1],s=i[2].toLowerCase();r(n[s],t,o)||(a=!1)}}),a}function r(t,e,i){return"min"===i?t>=e:"max"===i?e>=t:t===e}function s(t,e){return t.join(",")===e.join(",")}function l(t,e){e=e||{},d(e,function(e,i){if(null!=e){var n=t[i];if(c.hasClass(i)){e=u.normalizeToArray(e),n=u.normalizeToArray(n);var a=u.mappingToExists(n,e);t[i]=p(a,function(t){return t.option&&t.exist?g(t.exist,t.option,!0):t.exist||t.option})}else t[i]=g(n,e,!0)}})}var h=i(1),u=i(7),c=i(10),d=h.each,f=h.clone,p=h.map,g=h.merge,m=/^(min|max)?(.+)$/;n.prototype={constructor:n,setOption:function(t,e){t=f(t,!0);var i=this._optionBackup,n=this._newOptionBackup=a.call(this,t,e);i?(l(i.baseOption,n.baseOption),n.timelineOptions.length&&(i.timelineOptions=n.timelineOptions),n.mediaList.length&&(i.mediaList=n.mediaList),n.mediaDefault&&(i.mediaDefault=n.mediaDefault)):this._optionBackup=n},mountOption:function(t){var e=t?this._optionBackup:this._newOptionBackup;return this._timelineOptions=p(e.timelineOptions,f),this._mediaList=p(e.mediaList,f),this._mediaDefault=f(e.mediaDefault),this._currentMediaIndices=[],f(e.baseOption)},getTimelineOption:function(t){var e,i=this._timelineOptions;if(i.length){var n=t.getComponent("timeline");n&&(e=f(i[n.getCurrentIndex()],!0))}return e},getMediaOption:function(t){var e=this._api.getWidth(),i=this._api.getHeight(),n=this._mediaList,a=this._mediaDefault,r=[],l=[];if(!n.length&&!a)return l;for(var h=0,u=n.length;u>h;h++)o(n[h].query,e,i)&&r.push(h);return!r.length&&a&&(r=[-1]),r.length&&!s(r,this._currentMediaIndices)&&(l=p(r,function(t){return f(-1===t?a.option:n[t].option)})),this._currentMediaIndices=r,l}},t.exports=n},function(t,e){var i="";"undefined"!=typeof navigator&&(i=navigator.platform||""),t.exports={color:["#c23531","#2f4554","#61a0a8","#d48265","#91c7ae","#749f83","#ca8622","#bda29a","#6e7074","#546570","#c4ccd3"],grid:{},textStyle:{fontFamily:i.match(/^Win/)?"Microsoft YaHei":"sans-serif",fontSize:12,fontStyle:"normal",fontWeight:"normal"},animation:!0,animationThreshold:2e3,animationDuration:1e3,animationDurationUpdate:300,animationEasing:"exponentialOut",animationEasingUpdate:"cubicOut"}},function(t,e,i){t.exports={getAreaStyle:i(30)([["fill","color"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["opacity"],["shadowColor"]])}},function(t,e){t.exports={getBoxLayoutParams:function(){return{left:this.get("left"),top:this.get("top"),right:this.get("right"),bottom:this.get("bottom"),width:this.get("width"),height:this.get("height")}}}},function(t,e,i){t.exports={getItemStyle:i(30)([["fill","color"],["stroke","borderColor"],["lineWidth","borderWidth"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]])}},function(t,e,i){var n=i(30)([["lineWidth","width"],["stroke","color"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]]);t.exports={getLineStyle:function(t){var e=n.call(this,t),i=this.getLineDash();return i&&(e.lineDash=i),e},getLineDash:function(){var t=this.get("type");return"solid"===t||null==t?null:"dashed"===t?[5,5]:[1,1]}}},function(t,e,i){function n(t,e){return t&&t.getShallow(e)}var a=i(17);t.exports={getTextColor:function(){var t=this.ecModel;return this.getShallow("color")||t&&t.get("textStyle.color")},getFont:function(){var t=this.ecModel,e=t&&t.getModel("textStyle");return[this.getShallow("fontStyle")||n(e,"fontStyle"),this.getShallow("fontWeight")||n(e,"fontWeight"),(this.getShallow("fontSize")||n(e,"fontSize")||12)+"px",this.getShallow("fontFamily")||n(e,"fontFamily")||"sans-serif"].join(" ")},getTextRect:function(t){var e=this.get("textStyle")||{};return a.getBoundingRect(t,this.getFont(),e.align,e.baseline)},ellipsis:function(t,e,i){return a.ellipsis(t,this.getFont(),e,i)}}},function(t,e,i){function n(t,e){e=e.split(",");for(var i=t,n=0;ne&&(e=t[i]);return e},min:function(t){for(var e=1/0,i=0;i1){var c;"string"==typeof a?c=i[a]:"function"==typeof a&&(c=a),c&&(e=e.downSample(s.dim,1/u,c,n),t.setData(e))}}},this)}},function(t,e,i){var n=i(1),a=i(32),o=i(4),r=i(37),s=a.prototype,l=r.prototype,h=Math.floor,u=Math.ceil,c=Math.pow,d=10,f=Math.log,p=a.extend({type:"log",getTicks:function(){return n.map(l.getTicks.call(this),function(t){return o.round(c(d,t))})},getLabel:l.getLabel,scale:function(t){return t=s.scale.call(this,t),c(d,t)},setExtent:function(t,e){t=f(t)/f(d),e=f(e)/f(d),l.setExtent.call(this,t,e)},getExtent:function(){var t=s.getExtent.call(this);return t[0]=c(d,t[0]),t[1]=c(d,t[1]),t},unionExtent:function(t){t[0]=f(t[0])/f(d),t[1]=f(t[1])/f(d),s.unionExtent.call(this,t)},niceTicks:function(t){t=t||10;var e=this._extent,i=e[1]-e[0];if(!(i===1/0||0>=i)){var n=c(10,h(f(i/t)/Math.LN10)),a=t/i*n;.5>=a&&(n*=10);var r=[o.round(u(e[0]/n)*n),o.round(h(e[1]/n)*n)];this._interval=n,this._niceExtent=r}},niceExtent:l.niceExtent});n.each(["contain","normalize"],function(t){p.prototype[t]=function(e){return e=f(e)/f(d),s[t].call(this,e)}}),p.create=function(){return new p},t.exports=p},function(t,e,i){var n=i(1),a=i(32),o=a.prototype,r=a.extend({type:"ordinal",init:function(t,e){this._data=t,this._extent=e||[0,t.length-1]},parse:function(t){return"string"==typeof t?n.indexOf(this._data,t):Math.round(t)},contain:function(t){return t=this.parse(t),o.contain.call(this,t)&&null!=this._data[t]},normalize:function(t){return o.normalize.call(this,this.parse(t))},scale:function(t){return Math.round(o.scale.call(this,t))},getTicks:function(){for(var t=[],e=this._extent,i=e[0];i<=e[1];)t.push(i),i++;return t},getLabel:function(t){return this._data[t]},count:function(){return this._extent[1]-this._extent[0]+1},niceTicks:n.noop,niceExtent:n.noop});r.create=function(){return new r},t.exports=r},function(t,e,i){var n=i(1),a=i(4),o=i(9),r=i(37),s=r.prototype,l=Math.ceil,h=Math.floor,u=864e5,c=function(t,e,i,n){for(;n>i;){var a=i+n>>>1;t[a][2]=0&&f():o>=0?f():i&&(c=setTimeout(f,-o)),h=l};return p.clear=function(){c&&(clearTimeout(c),c=null)},p}var o,r,s,l=(new Date).getTime(),h=0,u=0,c=null,d="function"==typeof t;if(e=e||0,d)return a();for(var f=[],p=0;p=0;a--)if(!n[a].silent&&n[a]!==i&&!n[a].ignore&&r(n[a],t,e))return n[a]}},f.mixin(A,m),f.mixin(A,p),t.exports=A},function(t,e,i){function n(){return!1}function a(t,e,i,n){var a=document.createElement(e),o=i.getWidth(),r=i.getHeight(),s=a.style;return s.position="absolute",s.left=0,s.top=0,s.width=o+"px",s.height=r+"px",a.width=o*n,a.height=r*n,a.setAttribute("data-zr-dom-id",t),a}var o=i(1),r=i(42),s=function(t,e,i){var s;i=i||r.devicePixelRatio,"string"==typeof t?s=a(t,"canvas",e,i):o.isObject(t)&&(s=t,t=s.id),this.id=t,this.dom=s;var l=s.style;l&&(s.onselectstart=n,l["-webkit-user-select"]="none",l["user-select"]="none",l["-webkit-touch-callout"]="none",l["-webkit-tap-highlight-color"]="rgba(0,0,0,0)"),this.domBack=null,this.ctxBack=null,this.painter=e,this.config=null,this.clearColor=0,this.motionBlur=!1,this.lastFrameAlpha=.7,this.dpr=i};s.prototype={constructor:s,elCount:0,__dirty:!0,initContext:function(){this.ctx=this.dom.getContext("2d");var t=this.dpr;1!=t&&this.ctx.scale(t,t)},createBackBuffer:function(){var t=this.dpr;this.domBack=a("back-"+this.id,"canvas",this.painter,t),this.ctxBack=this.domBack.getContext("2d"),1!=t&&this.ctxBack.scale(t,t)},resize:function(t,e){var i=this.dpr,n=this.dom,a=n.style,o=this.domBack;a.width=t+"px",a.height=e+"px",n.width=t*i,n.height=e*i,1!=i&&this.ctx.scale(i,i),o&&(o.width=t*i,o.height=e*i,1!=i&&this.ctxBack.scale(i,i))},clear:function(t){var e=this.dom,i=this.ctx,n=e.width,a=e.height,o=this.clearColor,r=this.motionBlur&&!t,s=this.lastFrameAlpha,l=this.dpr;if(r&&(this.domBack||this.createBackBuffer(),this.ctxBack.globalCompositeOperation="copy",this.ctxBack.drawImage(e,0,0,n/l,a/l)),i.clearRect(0,0,n/l,a/l),o&&(i.save(),i.fillStyle=this.clearColor,i.fillRect(0,0,n/l,a/l),i.restore()),r){var h=this.domBack;i.save(),i.globalAlpha=s,i.drawImage(h,0,0,n/l,a/l),i.restore()}}},t.exports=s},function(t,e,i){"use strict";function n(t){return parseInt(t,10)}function a(t){return t?t.isBuildin?!0:"function"==typeof t.resize&&"function"==typeof t.refresh:!1}function o(t){t.__unusedCount++}function r(t){t.__dirty=!1,1==t.__unusedCount&&t.clear()}function s(t,e,i){return g.copy(t.getBoundingRect()),t.transform&&g.applyTransform(t.transform),m.width=e,m.height=i,!g.intersect(m)}function l(t,e){if(!t||!e||t.length!==e.length)return!0;for(var i=0;ip;p++){var m=t[p],v=this._singleCanvas?0:m.zlevel;if(n!==v&&(n=v,i=this.getLayer(n),i.isBuildin||d("ZLevel "+n+" has been used by unkown layer "+i.id),a=i.ctx,i.__unusedCount=0,(i.__dirty||e)&&i.clear()),(i.__dirty||e)&&!m.invisible&&0!==m.style.opacity&&m.scale[0]&&m.scale[1]&&(!m.culling||!s(m,u,c))){var y=m.__clipPaths;l(y,f)&&(f&&a.restore(),y&&(a.save(),h(y,a)),f=y),m.beforeBrush&&m.beforeBrush(a),m.brush(a,!1),m.afterBrush&&m.afterBrush(a)}m.__dirty=!1}f&&a.restore(),this.eachBuildinLayer(r)},getLayer:function(t){if(this._singleCanvas)return this._layers[0];var e=this._layers[t];return e||(e=new p("zr_"+t,this,this.dpr),e.isBuildin=!0,this._layerConfig[t]&&c.merge(e,this._layerConfig[t],!0),this.insertLayer(t,e),e.initContext()),e},insertLayer:function(t,e){var i=this._layers,n=this._zlevelList,o=n.length,r=null,s=-1,l=this._domRoot;if(i[t])return void d("ZLevel "+t+" has been used already");if(!a(e))return void d("Layer of zlevel "+t+" is not valid");if(o>0&&t>n[0]){for(s=0;o-1>s&&!(n[s]t);s++);r=i[n[s]]}if(n.splice(s+1,0,t),r){var h=r.dom;h.nextSibling?l.insertBefore(e.dom,h.nextSibling):l.appendChild(e.dom)}else l.firstChild?l.insertBefore(e.dom,l.firstChild):l.appendChild(e.dom);i[t]=e},eachLayer:function(t,e){var i,n,a=this._zlevelList;for(n=0;nn;n++){var o=t[n],r=this._singleCanvas?0:o.zlevel,s=e[r];if(s){if(s.elCount++,s.__dirty)continue;s.__dirty=o.__dirty}}this.eachBuildinLayer(function(t,e){i[e]!==t.elCount&&(t.__dirty=!0)})},clear:function(){return this.eachBuildinLayer(this._clearLayer),this},_clearLayer:function(t){t.clear()},configLayer:function(t,e){if(e){var i=this._layerConfig;i[t]?c.merge(i[t],e,!0):i[t]=e;var n=this._layers[t];n&&c.merge(n,i[t],!0)}},delLayer:function(t){var e=this._layers,i=this._zlevelList,n=e[t];n&&(n.dom.parentNode.removeChild(n.dom),delete e[t],i.splice(c.indexOf(i,t),1))},resize:function(t,e){var i=this._domRoot;if(i.style.display="none",t=t||this._getWidth(),e=e||this._getHeight(),i.style.display="",this._width!=t||e!=this._height){i.style.width=t+"px",i.style.height=e+"px";for(var n in this._layers)this._layers[n].resize(t,e);this.refresh(!0)}return this._width=t,this._height=e,this},clearLayer:function(t){var e=this._layers[t];e&&e.clear()},dispose:function(){this.root.innerHTML="",this.root=this.storage=this._domRoot=this._layers=null},getRenderedCanvas:function(t){if(t=t||{},this._singleCanvas)return this._layers[0].dom;var e=new p("image",this,t.pixelRatio||this.dpr);e.initContext();var i=e.ctx;e.clearColor=t.backgroundColor,e.clear();for(var n=this.storage.getDisplayList(!0),a=0;aa;a++)this._updateAndAddDisplayable(e[a],null,t);i.length=this._displayListLen;for(var a=0,o=i.length;o>a;a++)i[a].__renderidx=a;i.sort(n)},_updateAndAddDisplayable:function(t,e,i){if(!t.ignore||i){t.beforeUpdate(),t.update(),t.afterUpdate();var n=t.clipPath;if(n&&(n.parent=t,n.updateTransform(),e?(e=e.slice(),e.push(n)):e=[n]),"group"==t.type){for(var a=t._children,o=0;oe;e++)this.delRoot(t[e]);else{var r;r="string"==typeof t?this._elements[t]:t;var s=a.indexOf(this._roots,r);s>=0&&(this.delFromMap(r.id),this._roots.splice(s,1),r instanceof o&&r.delChildrenFromStorage(this))}},addToMap:function(t){return t instanceof o&&(t.__storage=this),t.dirty(),this._elements[t.id]=t,this},get:function(t){return this._elements[t]},delFromMap:function(t){var e=this._elements,i=e[t];return i&&(delete e[t],i instanceof o&&(i.__storage=null)),this},dispose:function(){this._elements=this._renderList=this._roots=null}},t.exports=r},function(t,e,i){"use strict";var n=i(1),a=i(33).Dispatcher,o="undefined"!=typeof window&&(window.requestAnimationFrame||window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(t){setTimeout(t,16)},r=i(56),s=function(t){t=t||{},this.stage=t.stage||{},this.onframe=t.onframe||function(){},this._clips=[],this._running=!1,this._time=0,a.call(this)};s.prototype={constructor:s,addClip:function(t){this._clips.push(t)},addAnimator:function(t){t.animation=this;for(var e=t.getClips(),i=0;i=0&&this._clips.splice(e,1)},removeAnimator:function(t){for(var e=t.getClips(),i=0;ir;r++){var s=i[r],l=s.step(t);l&&(a.push(l),o.push(s))}for(var r=0;n>r;)i[r]._needsRemove?(i[r]=i[n-1],i.pop(),n--):r++;n=a.length;for(var r=0;n>r;r++)o[r].fire(a[r]);this._time=t,this.onframe(e),this.trigger("frame",e),this.stage.update&&this.stage.update()},start:function(){function t(){e._running&&(o(t),e._update())}var e=this;this._running=!0,this._time=(new Date).getTime(),o(t)},stop:function(){this._running=!1},clear:function(){this._clips=[]},animate:function(t,e){e=e||{};var i=new r(t,e.loop,e.getter,e.setter);return i}},n.mixin(s,a),t.exports=s},function(t,e,i){function n(t){this._target=t.target,this._life=t.life||1e3,this._delay=t.delay||0,this._initialized=!1,this.loop=null==t.loop?!1:t.loop,this.gap=t.gap||0,this.easing=t.easing||"Linear",this.onframe=t.onframe,this.ondestroy=t.ondestroy,this.onrestart=t.onrestart}var a=i(132);n.prototype={constructor:n,step:function(t){this._initialized||(this._startTime=(new Date).getTime()+this._delay,this._initialized=!0);var e=(t-this._startTime)/this._life;if(!(0>e)){e=Math.min(e,1);var i=this.easing,n="string"==typeof i?a[i]:i,o="function"==typeof n?n(e):e;return this.fire("frame",o),1==e?this.loop?(this.restart(),"restart"):(this._needsRemove=!0,"destroy"):null}},restart:function(){var t=(new Date).getTime(),e=(t-this._startTime)%this._life;this._startTime=(new Date).getTime()-e+this.gap,this._needsRemove=!1},fire:function(t,e){t="on"+t,this[t]&&this[t](this._target,e)}},t.exports=n},function(t,e){var i={linear:function(t){return t},quadraticIn:function(t){return t*t},quadraticOut:function(t){return t*(2-t)},quadraticInOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},cubicIn:function(t){return t*t*t},cubicOut:function(t){return--t*t*t+1},cubicInOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},quarticIn:function(t){return t*t*t*t},quarticOut:function(t){return 1- --t*t*t*t},quarticInOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},quinticIn:function(t){return t*t*t*t*t},quinticOut:function(t){return--t*t*t*t*t+1},quinticInOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},sinusoidalIn:function(t){return 1-Math.cos(t*Math.PI/2)},sinusoidalOut:function(t){return Math.sin(t*Math.PI/2)},sinusoidalInOut:function(t){return.5*(1-Math.cos(Math.PI*t))},exponentialIn:function(t){return 0===t?0:Math.pow(1024,t-1)},exponentialOut:function(t){return 1===t?1:1-Math.pow(2,-10*t)},exponentialInOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(2,-10*(t-1))+2)},circularIn:function(t){return 1-Math.sqrt(1-t*t)},circularOut:function(t){return Math.sqrt(1- --t*t)},circularInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},elasticIn:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),-(i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)))},elasticOut:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/n)+1)},elasticInOut:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),(t*=2)<1?-.5*(i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)):i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)*.5+1)},backIn:function(t){var e=1.70158;return t*t*((e+1)*t-e)},backOut:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},backInOut:function(t){var e=2.5949095;return(t*=2)<1?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+2)},bounceIn:function(t){return 1-i.bounceOut(1-t)},bounceOut:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},bounceInOut:function(t){return.5>t?.5*i.bounceIn(2*t):.5*i.bounceOut(2*t-1)+.5}};t.exports=i},function(t,e,i){var n=i(57).normalizeRadian,a=2*Math.PI;t.exports={containStroke:function(t,e,i,o,r,s,l,h,u){if(0===l)return!1;var c=l;h-=t,u-=e;var d=Math.sqrt(h*h+u*u);if(d-c>i||i>d+c)return!1;if(Math.abs(o-r)%a<1e-4)return!0;if(s){var f=o;o=n(r),r=n(f)}else o=n(o),r=n(r);o>r&&(r+=a);var p=Math.atan2(u,h);return 0>p&&(p+=a),p>=o&&r>=p||p+a>=o&&r>=p+a}}},function(t,e,i){var n=i(18);t.exports={containStroke:function(t,e,i,a,o,r,s,l,h,u,c){if(0===h)return!1;var d=h;if(c>e+d&&c>a+d&&c>r+d&&c>l+d||e-d>c&&a-d>c&&r-d>c&&l-d>c||u>t+d&&u>i+d&&u>o+d&&u>s+d||t-d>u&&i-d>u&&o-d>u&&s-d>u)return!1;var f=n.cubicProjectPoint(t,e,i,a,o,r,s,l,u,c,null);return d/2>=f}}},function(t,e){t.exports={containStroke:function(t,e,i,n,a,o,r){if(0===a)return!1;var s=a,l=0,h=t;if(r>e+s&&r>n+s||e-s>r&&n-s>r||o>t+s&&o>i+s||t-s>o&&i-s>o)return!1;if(t===i)return Math.abs(o-t)<=s/2;l=(e-n)/(t-i),h=(t*n-i*e)/(t-i);var u=l*o-r+h,c=u*u/(l*l+1);return s/2*s/2>=c}}},function(t,e,i){"use strict";function n(t,e){return Math.abs(t-e)e&&u>n&&u>r&&u>l||e>u&&n>u&&r>u&&l>u)return 0;var c=g.cubicRootAt(e,n,r,l,u,_);if(0===c)return 0;for(var d,f,p=0,m=-1,v=0;c>v;v++){var y=_[v],x=g.cubicAt(t,i,o,s,y);h>x||(0>m&&(m=g.cubicExtrema(e,n,r,l,w),w[1]1&&a(),d=g.cubicAt(e,n,r,l,w[0]),m>1&&(f=g.cubicAt(e,n,r,l,w[1]))),p+=2==m?yd?1:-1:yf?1:-1:f>l?1:-1:yd?1:-1:d>l?1:-1)}return p}function r(t,e,i,n,a,o,r,s){if(s>e&&s>n&&s>o||e>s&&n>s&&o>s)return 0;var l=g.quadraticRootAt(e,n,o,s,_);if(0===l)return 0;var h=g.quadraticExtremum(e,n,o);if(h>=0&&1>=h){for(var u=0,c=g.quadraticAt(e,n,o,h),d=0;l>d;d++){var f=g.quadraticAt(t,i,a,_[d]);f>r||(u+=_[d]c?1:-1:c>o?1:-1)}return u}var f=g.quadraticAt(t,i,a,_[0]);return f>r?0:e>o?1:-1}function s(t,e,i,n,a,o,r,s){if(s-=e,s>i||-i>s)return 0;var l=Math.sqrt(i*i-s*s);_[0]=-l,_[1]=l;var h=Math.abs(n-a);if(1e-4>h)return 0;if(1e-4>h%y){n=0,a=y;var u=o?1:-1;return r>=_[0]+t&&r<=_[1]+t?u:0}if(o){var l=n;n=p(a),a=p(l)}else n=p(n),a=p(a);n>a&&(a+=y);for(var c=0,d=0;2>d;d++){var f=_[d];if(f+t>r){var g=Math.atan2(s,f),u=o?1:-1;0>g&&(g=y+g),(g>=n&&a>=g||g+y>=n&&a>=g+y)&&(g>Math.PI/2&&g<1.5*Math.PI&&(u=-u),c+=u)}}return c}function l(t,e,i,a,l){for(var u=0,p=0,g=0,y=0,x=0,_=0;_1&&(i||(u+=m(p,g,y,x,a,l)),0!==u))return!0;switch(1==_&&(p=t[_],g=t[_+1],y=p,x=g),w){case h.M:y=t[_++],x=t[_++],p=y,g=x;break;case h.L:if(i){if(v(p,g,t[_],t[_+1],e,a,l))return!0}else u+=m(p,g,t[_],t[_+1],a,l)||0;p=t[_++],g=t[_++];break;case h.C:if(i){if(c.containStroke(p,g,t[_++],t[_++],t[_++],t[_++],t[_],t[_+1],e,a,l))return!0}else u+=o(p,g,t[_++],t[_++],t[_++],t[_++],t[_],t[_+1],a,l)||0;p=t[_++],g=t[_++];break;case h.Q:if(i){if(d.containStroke(p,g,t[_++],t[_++],t[_],t[_+1],e,a,l))return!0}else u+=r(p,g,t[_++],t[_++],t[_],t[_+1],a,l)||0;p=t[_++],g=t[_++];break;case h.A:var b=t[_++],S=t[_++],M=t[_++],A=t[_++],I=t[_++],T=t[_++],C=(t[_++],1-t[_++]),L=Math.cos(I)*M+b,D=Math.sin(I)*A+S;_>1?u+=m(p,g,L,D,a,l):(y=L,x=D);var P=(a-b)*A/M+b;if(i){if(f.containStroke(b,S,A,I,I+T,C,e,P,l))return!0}else u+=s(b,S,A,I,I+T,C,P,l);p=Math.cos(I+T)*M+b,g=Math.sin(I+T)*A+S;break;case h.R:y=p=t[_++],x=g=t[_++];var k=t[_++],z=t[_++],L=y+k,D=x+z;if(i){if(v(y,x,L,x,e,a,l)||v(L,x,L,D,e,a,l)||v(L,D,y,D,e,a,l)||v(y,D,L,D,e,a,l))return!0}else u+=m(L,x,L,D,a,l),u+=m(y,D,y,x,a,l);break;case h.Z:if(i){if(v(p,g,y,x,e,a,l))return!0}else if(u+=m(p,g,y,x,a,l),0!==u)return!0;p=y,g=x}}return i||n(g,x)||(u+=m(p,g,y,x,a,l)||0),0!==u}var h=i(27).CMD,u=i(135),c=i(134),d=i(137),f=i(133),p=i(57).normalizeRadian,g=i(18),m=i(75),v=u.containStroke,y=2*Math.PI,x=1e-4,_=[-1,-1,-1],w=[-1,-1];t.exports={contain:function(t,e,i){return l(t,0,!1,e,i)},containStroke:function(t,e,i,n){return l(t,e,!0,i,n)}}},function(t,e,i){var n=i(18);t.exports={containStroke:function(t,e,i,a,o,r,s,l,h){if(0===s)return!1;var u=s;if(h>e+u&&h>a+u&&h>r+u||e-u>h&&a-u>h&&r-u>h||l>t+u&&l>i+u&&l>o+u||t-u>l&&i-u>l&&o-u>l)return!1;var c=n.quadraticProjectPoint(t,e,i,a,o,r,l,h,null);return u/2>=c}}},function(t,e){"use strict";function i(t){var e=t[1][0]-t[0][0],i=t[1][1]-t[0][1];return Math.sqrt(e*e+i*i)}function n(t){return[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2]}var a=function(){this._track=[]};a.prototype={constructor:a,recognize:function(t,e){return this._doTrack(t,e),this._recognize(t)},clear:function(){return this._track.length=0,this},_doTrack:function(t,e){var i=t.touches;if(i){for(var n={points:[],touches:[],target:e,event:t},a=0,o=i.length;o>a;a++){var r=i[a];n.points.push([r.clientX,r.clientY]),n.touches.push(r)}this._track.push(n)}},_recognize:function(t){for(var e in o)if(o.hasOwnProperty(e)){var i=o[e](this._track,t);if(i)return i}}};var o={pinch:function(t,e){var a=t.length;if(a){var o=(t[a-1]||{}).points,r=(t[a-2]||{}).points||o;if(r&&r.length>1&&o&&o.length>1){var s=i(o)/i(r);!isFinite(s)&&(s=1),e.pinchScale=s;var l=n(o);return e.pinchX=l[0],e.pinchY=l[1],{type:"pinch",target:t[0].target,event:e}}}}};t.exports=a},function(t,e){var i=function(){this.head=null,this.tail=null,this._len=0},n=i.prototype;n.insert=function(t){var e=new a(t);return this.insertEntry(e),e},n.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,this.tail=t):this.head=this.tail=t,this._len++},n.remove=function(t){var e=t.prev,i=t.next;e?e.next=i:this.head=i,i?i.prev=e:this.tail=e,t.next=t.prev=null,this._len--},n.len=function(){return this._len};var a=function(t){this.value=t,this.next,this.prev},o=function(t){this._list=new i,this._map={},this._maxSize=t||10},r=o.prototype;r.put=function(t,e){var i=this._list,n=this._map;if(null==n[t]){var a=i.len();if(a>=this._maxSize&&a>0){var o=i.head;i.remove(o),delete n[o.key]}var r=i.insert(e);r.key=t,n[t]=r}},r.get=function(t){var e=this._map[t],i=this._list;return null!=e?(e!==i.tail&&(i.remove(e),i.insertEntry(e)),e.value):void 0},r.clear=function(){this._list.clear(),this._map={}},t.exports=o},function(t,e,i){"use strict";var n=i(1),a=i(16),o=function(t,e,i,n){this.x=null==t?.5:t,this.y=null==e?.5:e,this.r=null==i?.5:i,a.call(this,n)};o.prototype={constructor:o,type:"radial",updateCanvasGradient:function(t,e){for(var i=t.getBoundingRect(),n=i.width,a=i.height,o=Math.min(n,a),r=this.x*n+i.x,s=this.y*a+i.y,l=this.r*o,h=e.createRadialGradient(r,s,0,r,s,l),u=this.colorStops,c=0;cy;y++)a(d,d,t[y]),o(f,f,t[y]);a(d,d,h[0]),o(f,f,h[1])}for(var y=0,x=t.length;x>y;y++){var _=t[y];if(i)u=t[y?y-1:x-1],c=t[(y+1)%x];else{if(0===y||y===x-1){p.push(n.clone(t[y]));continue}u=t[y-1],c=t[y+1]}n.sub(g,c,u),r(g,g,e);var w=s(_,u),b=s(_,c),S=w+b;0!==S&&(w/=S,b/=S),r(m,g,-w),r(v,g,b);var M=l([],_,m),A=l([],_,v);h&&(o(M,M,d),a(M,M,f),o(A,A,d),a(A,A,f)),p.push(M),p.push(A)}return i&&p.push(p.shift()),p}},function(t,e,i){function n(t,e,i,n,a,o,r){var s=.5*(i-t),l=.5*(n-e);return(2*(e-i)+s+l)*r+(-3*(e-i)-2*s-l)*o+s*a+e}var a=i(5);t.exports=function(t,e){for(var i=t.length,o=[],r=0,s=1;i>s;s++)r+=a.distance(t[s-1],t[s]);var l=r/2;l=i>l?i:l;for(var s=0;l>s;s++){var h,u,c,d=s/(l-1)*(e?i:i-1),f=Math.floor(d),p=d-f,g=t[f%i];e?(h=t[(f-1+i)%i],u=t[(f+1)%i],c=t[(f+2)%i]):(h=t[0===f?f:f-1],u=t[f>i-2?i-1:f+1],c=t[f>i-3?i-1:f+2]);var m=p*p,v=p*m;o.push([n(h[0],g[0],u[0],c[0],p,m,v),n(h[1],g[1],u[1],c[1],p,m,v)])}return o}},function(t,e,i){t.exports=i(6).extend({type:"arc",shape:{cx:0,cy:0,r:0,startAngle:0,endAngle:2*Math.PI,clockwise:!0},style:{stroke:"#000",fill:null},buildPath:function(t,e){var i=e.cx,n=e.cy,a=Math.max(e.r,0),o=e.startAngle,r=e.endAngle,s=e.clockwise,l=Math.cos(o),h=Math.sin(o);t.moveTo(l*a+i,h*a+n),t.arc(i,n,a,o,r,!s)}}); +},function(t,e,i){"use strict";var n=i(18),a=n.quadraticSubdivide,o=n.cubicSubdivide,r=n.quadraticAt,s=n.cubicAt,l=[];t.exports=i(6).extend({type:"bezier-curve",shape:{x1:0,y1:0,x2:0,y2:0,cpx1:0,cpy1:0,percent:1},style:{stroke:"#000",fill:null},buildPath:function(t,e){var i=e.x1,n=e.y1,r=e.x2,s=e.y2,h=e.cpx1,u=e.cpy1,c=e.cpx2,d=e.cpy2,f=e.percent;0!==f&&(t.moveTo(i,n),null==c||null==d?(1>f&&(a(i,h,r,f,l),h=l[1],r=l[2],a(n,u,s,f,l),u=l[1],s=l[2]),t.quadraticCurveTo(h,u,r,s)):(1>f&&(o(i,h,c,r,f,l),h=l[1],c=l[2],r=l[3],o(n,u,d,s,f,l),u=l[1],d=l[2],s=l[3]),t.bezierCurveTo(h,u,c,d,r,s)))},pointAt:function(t){var e=this.shape,i=e.cpx2,n=e.cpy2;return null===i||null===n?[r(e.x1,e.cpx1,e.x2,t),r(e.y1,e.cpy1,e.y2,t)]:[s(e.x1,e.cpx1,e.cpx1,e.x2,t),s(e.y1,e.cpy1,e.cpy1,e.y2,t)]}})},function(t,e,i){"use strict";t.exports=i(6).extend({type:"circle",shape:{cx:0,cy:0,r:0},buildPath:function(t,e){t.moveTo(e.cx+e.r,e.cy),t.arc(e.cx,e.cy,e.r,0,2*Math.PI,!0)}})},function(t,e,i){t.exports=i(6).extend({type:"line",shape:{x1:0,y1:0,x2:0,y2:0,percent:1},style:{stroke:"#000",fill:null},buildPath:function(t,e){var i=e.x1,n=e.y1,a=e.x2,o=e.y2,r=e.percent;0!==r&&(t.moveTo(i,n),1>r&&(a=i*(1-r)+a*r,o=n*(1-r)+o*r),t.lineTo(a,o))},pointAt:function(t){var e=this.shape;return[e.x1*(1-t)+e.x2*t,e.y1*(1-t)+e.y2*t]}})},function(t,e,i){var n=i(59);t.exports=i(6).extend({type:"polygon",shape:{points:null,smooth:!1,smoothConstraint:null},buildPath:function(t,e){n.buildPath(t,e,!0)}})},function(t,e,i){var n=i(59);t.exports=i(6).extend({type:"polyline",shape:{points:null,smooth:!1,smoothConstraint:null},style:{stroke:"#000",fill:null},buildPath:function(t,e){n.buildPath(t,e,!1)}})},function(t,e,i){var n=i(60);t.exports=i(6).extend({type:"rect",shape:{r:0,x:0,y:0,width:0,height:0},buildPath:function(t,e){var i=e.x,a=e.y,o=e.width,r=e.height;e.r?n.buildPath(t,e):t.rect(i,a,o,r),t.closePath()}})},function(t,e,i){t.exports=i(6).extend({type:"ring",shape:{cx:0,cy:0,r:0,r0:0},buildPath:function(t,e){var i=e.cx,n=e.cy,a=2*Math.PI;t.moveTo(i+e.r,n),t.arc(i,n,e.r,0,a,!1),t.moveTo(i+e.r0,n),t.arc(i,n,e.r0,0,a,!0)}})},function(t,e,i){t.exports=i(6).extend({type:"sector",shape:{cx:0,cy:0,r0:0,r:0,startAngle:0,endAngle:2*Math.PI,clockwise:!0},buildPath:function(t,e){var i=e.cx,n=e.cy,a=Math.max(e.r0||0,0),o=Math.max(e.r,0),r=e.startAngle,s=e.endAngle,l=e.clockwise,h=Math.cos(r),u=Math.sin(r);t.moveTo(h*a+i,u*a+n),t.lineTo(h*o+i,u*o+n),t.arc(i,n,o,r,s,!l),t.lineTo(Math.cos(s)*a+i,Math.sin(s)*a+n),0!==a&&t.arc(i,n,a,s,r,l),t.closePath()}})},function(t,e,i){"use strict";var n=i(56),a=i(1),o=a.isString,r=a.isFunction,s=a.isObject,l=i(45),h=function(){this.animators=[]};h.prototype={constructor:h,animate:function(t,e){var i,o=!1,r=this,s=this.__zr;if(t){var h=t.split("."),u=r;o="shape"===h[0];for(var c=0,d=h.length;d>c;c++)u&&(u=u[h[c]]);u&&(i=u)}else i=r;if(!i)return void l('Property "'+t+'" is not existed in element '+r.id);var f=r.animators,p=new n(i,e);return p.during(function(t){r.dirty(o)}).done(function(){f.splice(a.indexOf(f,p),1)}),f.push(p),s&&s.animation.addAnimator(p),p},stopAnimation:function(t){for(var e=this.animators,i=e.length,n=0;i>n;n++)e[n].stop(t);return e.length=0,this},animateTo:function(t,e,i,n,a){function s(){h--,h||a&&a()}o(i)?(a=n,n=i,i=0):r(n)?(a=n,n="linear",i=0):r(i)?(a=i,i=0):r(e)?(a=e,e=500):e||(e=500),this.stopAnimation(),this._animateToShallow("",this,t,e,i,n,a);var l=this.animators.slice(),h=l.length;h||a&&a();for(var u=0;u0&&this.animate(t,!1).when(null==n?500:n,r).delay(o||0),this}},t.exports=h},function(t,e){function i(){this.on("mousedown",this._dragStart,this),this.on("mousemove",this._drag,this),this.on("mouseup",this._dragEnd,this),this.on("globalout",this._dragEnd,this)}i.prototype={constructor:i,_dragStart:function(t){var e=t.target;e&&e.draggable&&(this._draggingTarget=e,e.dragging=!0,this._x=t.offsetX,this._y=t.offsetY,this._dispatchProxy(e,"dragstart",t.event))},_drag:function(t){var e=this._draggingTarget;if(e){var i=t.offsetX,n=t.offsetY,a=i-this._x,o=n-this._y;this._x=i,this._y=n,e.drift(a,o,t),this._dispatchProxy(e,"drag",t.event);var r=this.findHover(i,n,e),s=this._dropTarget;this._dropTarget=r,e!==r&&(s&&r!==s&&this._dispatchProxy(s,"dragleave",t.event),r&&r!==s&&this._dispatchProxy(r,"dragenter",t.event))}},_dragEnd:function(t){var e=this._draggingTarget;e&&(e.dragging=!1),this._dispatchProxy(e,"dragend",t.event),this._dropTarget&&this._dispatchProxy(this._dropTarget,"drop",t.event),this._draggingTarget=null,this._dropTarget=null}},t.exports=i},function(t,e,i){function n(t,e,i,n,a,o,r,s,l,h,u){var g=l*(p/180),y=f(g)*(t-i)/2+d(g)*(e-n)/2,x=-1*d(g)*(t-i)/2+f(g)*(e-n)/2,_=y*y/(r*r)+x*x/(s*s);_>1&&(r*=c(_),s*=c(_));var w=(a===o?-1:1)*c((r*r*(s*s)-r*r*(x*x)-s*s*(y*y))/(r*r*(x*x)+s*s*(y*y)))||0,b=w*r*x/s,S=w*-s*y/r,M=(t+i)/2+f(g)*b-d(g)*S,A=(e+n)/2+d(g)*b+f(g)*S,I=v([1,0],[(y-b)/r,(x-S)/s]),T=[(y-b)/r,(x-S)/s],C=[(-1*y-b)/r,(-1*x-S)/s],L=v(T,C);m(T,C)<=-1&&(L=p),m(T,C)>=1&&(L=0),0===o&&L>0&&(L-=2*p),1===o&&0>L&&(L+=2*p),u.addData(h,M,A,r,s,I,L,g,o)}function a(t){if(!t)return[];var e,i=t.replace(/-/g," -").replace(/ /g," ").replace(/ /g,",").replace(/,,/g,",");for(e=0;e0&&""===m[0]&&m.shift();for(var v=0;vn;n++)i=t[n],i.__dirty&&i.buildPath(i.path,i.shape),a.push(i.path);var s=new r(e);return s.buildPath=function(t){t.appendPath(a);var e=t.getContext();e&&t.rebuildPath(e)},s}}},function(t,e,i){function n(t,e){var i,n,o,u,c,d,f=t.data,p=a.M,g=a.C,m=a.L,v=a.R,y=a.A,x=a.Q;for(o=0,u=0;oc;c++){var d=s[c];d[0]=f[o++],d[1]=f[o++],r(d,d,e),f[u++]=d[0],f[u++]=d[1]}}}var a=i(27).CMD,o=i(5),r=o.applyTransform,s=[[],[],[]],l=Math.sqrt,h=Math.atan2;t.exports=n},function(t,e,i){if(!i(15).canvasSupported){var n,a="urn:schemas-microsoft-com:vml",o=window,r=o.document,s=!1;try{!r.namespaces.zrvml&&r.namespaces.add("zrvml",a),n=function(t){return r.createElement("')}}catch(l){n=function(t){return r.createElement("<"+t+' xmlns="'+a+'" class="zrvml">')}}var h=function(){if(!s){s=!0;var t=r.styleSheets;t.length<31?r.createStyleSheet().addRule(".zrvml","behavior:url(#default#VML)"):t[0].addRule(".zrvml","behavior:url(#default#VML)")}};t.exports={doc:r,initVML:h,createNode:n}}},function(t,e,i){"use strict";function n(t){return null==t.value?t:t.value}var a=i(14),o=i(31),r=i(263),s=i(1),l={_baseAxisDim:null,getInitialData:function(t,e){var i,r,s=e.getComponent("xAxis",this.get("xAxisIndex")),l=e.getComponent("yAxis",this.get("yAxisIndex")),h=s.get("type"),u=l.get("type");"category"===h?(t.layout="horizontal",i=s.getCategories(),r=!0):"category"===u?(t.layout="vertical",i=l.getCategories(),r=!0):t.layout=t.layout||"horizontal",this._baseAxisDim="horizontal"===t.layout?"x":"y";var c=t.data,d=this.dimensions=["base"].concat(this.valueDimensions);o(d,c);var f=new a(d,this);return f.initData(c,i?i.slice():null,function(t,e,i,a){var o=n(t);return r?"base"===e?i:o[a-1]:o[a]}),f},coordDimToDataDim:function(t){var e=this.valueDimensions.slice(),i=["base"],n={horizontal:{x:i,y:e},vertical:{x:e,y:i}};return n[this.get("layout")][t]},dataDimToCoordDim:function(t){var e;return s.each(["x","y"],function(i,n){var a=this.coordDimToDataDim(i);s.indexOf(a,t)>=0&&(e=i)},this),e},getBaseAxis:function(){var t=this._baseAxisDim;return this.ecModel.getComponent(t+"Axis",this.get(t+"AxisIndex")).axis}},h={init:function(){var t=this._whiskerBoxDraw=new r(this.getStyleUpdater());this.group.add(t.group)},render:function(t,e,i){this._whiskerBoxDraw.updateData(t.getData())},remove:function(t){this._whiskerBoxDraw.remove()}};t.exports={seriesModelMixin:l,viewMixin:h}},function(t,e,i){function n(t,e,i){v.call(this),this.type=t,this.zr=e,this.opt=y.clone(i),this.group=new x.Group,this._containerRect=null,this._track=[],this._dragging,this._cover,this._disabled=!0,this._handlers={mousedown:_(s,this),mousemove:_(l,this),mouseup:_(h,this)},w(T,function(t){this.zr.on(t,this._handlers[t])},this)}function a(t){t.traverse(function(t){t.z=A})}function o(t,e){var i=this.group.transformCoordToLocal(t,e);return!this._containerRect||this._containerRect.contain(i[0],i[1])}function r(t){var e=t.event;e.preventDefault&&e.preventDefault()}function s(t){if(!(this._disabled||t.target&&t.target.draggable)){r(t);var e=t.offsetX,i=t.offsetY;o.call(this,e,i)&&(this._dragging=!0,this._track=[[e,i]])}}function l(t){this._dragging&&!this._disabled&&(r(t),u.call(this,t))}function h(t){this._dragging&&!this._disabled&&(r(t),u.call(this,t,!0),this._dragging=!1,this._track=[])}function u(t,e){var i=t.offsetX,n=t.offsetY;if(o.call(this,i,n)){this._track.push([i,n]);var a=c.call(this)?C[this.type].getRanges.call(this):[];d.call(this,a),this.trigger("selected",y.clone(a)),e&&this.trigger("selectEnd",y.clone(a))}}function c(){var t=this._track;if(!t.length)return!1;var e=t[t.length-1],i=t[0],n=e[0]-i[0],a=e[1]-i[1],o=M(n*n+a*a,.5);return o>I}function d(t){var e=C[this.type];t&&t.length?(this._cover||(this._cover=e.create.call(this),this.group.add(this._cover)),e.update.call(this,t)):(this.group.remove(this._cover),this._cover=null),a(this.group)}function f(){var t=this.group,e=t.parent;e&&e.remove(t)}function p(){var t=this.opt;return new x.Rect({style:{stroke:t.stroke,fill:t.fill,lineWidth:t.lineWidth,opacity:t.opacity}})}function g(){return y.map(this._track,function(t){return this.group.transformCoordToLocal(t[0],t[1])},this)}function m(){var t=g.call(this),e=t.length-1;return 0>e&&(e=0),[t[0],t[e]]}var v=i(21),y=i(1),x=i(3),_=y.bind,w=y.each,b=Math.min,S=Math.max,M=Math.pow,A=1e4,I=2,T=["mousedown","mousemove","mouseup"];n.prototype={constructor:n,enable:function(t,e){this._disabled=!1,f.call(this),this._containerRect=e!==!1?e||t.getBoundingRect():null,t.add(this.group)},update:function(t){d.call(this,t&&y.clone(t))},disable:function(){this._disabled=!0,f.call(this)},dispose:function(){this.disable(),w(T,function(t){this.zr.off(t,this._handlers[t])},this)}},y.mixin(n,v);var C={line:{create:p,getRanges:function(){var t=m.call(this),e=b(t[0][0],t[1][0]),i=S(t[0][0],t[1][0]);return[[e,i]]},update:function(t){var e=t[0],i=this.opt.width;this._cover.setShape({x:e[0],y:-i/2,width:e[1]-e[0],height:i})}},rect:{create:p,getRanges:function(){var t=m.call(this),e=[b(t[1][0],t[0][0]),b(t[1][1],t[0][1])],i=[S(t[1][0],t[0][0]),S(t[1][1],t[0][1])];return[[[e[0],i[0]],[e[1],i[1]]]]},update:function(t){var e=t[0];this._cover.setShape({x:e[0][0],y:e[1][0],width:e[0][1]-e[0][0],height:e[1][1]-e[1][0]})}}};t.exports=n},function(t,e,i){function n(){this.group=new a.Group,this._symbolEl=new s({silent:!0})}var a=i(3),o=i(24),r=i(1),s=a.extendShape({shape:{points:null,sizes:null},symbolProxy:null,buildPath:function(t,e){for(var i=e.points,n=e.sizes,a=this.symbolProxy,o=a.shape,r=0;rt.get("largeThreshold")?a:o;this._symbolDraw=s,s.updateData(n),r.add(s.group),r.remove(s===a?o.group:a.group)},updateLayout:function(t){this._symbolDraw.updateLayout(t)},remove:function(t,e){this._symbolDraw&&this._symbolDraw.remove(e,!0)}})},function(t,e,i){i(100),i(39),i(40),i(171),i(172),i(167),i(168),i(98),i(97)},function(t,e,i){function n(t,e){var i=[1/0,-(1/0)];return h(e,function(e){var n=e.getData();n&&h(e.coordDimToDataDim(t),function(t){var e=n.getDataExtent(t);e[0]i[1]&&(i[1]=e[1])})},this),i}function a(t,e,i){var n=i.getAxisModel(),a=n.axis.scale,r=[0,100],s=[t.start,t.end],c=[];return e=e.slice(),o(e,n,a),h(["startValue","endValue"],function(e){c.push(null!=t[e]?a.parse(t[e]):null)}),h([0,1],function(t){var i=c[t],n=s[t];null!=n||null==i?(null==n&&(n=r[t]),i=a.parse(l.linearMap(n,r,e,!0))):n=l.linearMap(i,e,r,!0),c[t]=l.round(i),s[t]=l.round(n)}),{valueWindow:u(c),percentWindow:u(s)}}function o(t,e,i){return h(["min","max"],function(n,a){var o=e.get(n,!0);null!=o&&(o+"").toLowerCase()!=="data"+n&&(t[a]=i.parse(o))}),e.get("scale",!0)||(t[0]>0&&(t[0]=0),t[1]<0&&(t[1]=0)),t}function r(t,e){var i=t.getAxisModel(),n=t._percentWindow,a=t._valueWindow;if(n){var o=e||0===n[0]&&100===n[1],r=!e&&l.getPixelPrecision(a,[0,500]),s=!(e||20>r&&r>=0),h=e||o||s;i.setRange&&i.setRange(h?null:+a[0].toFixed(r),h?null:+a[1].toFixed(r))}}var s=i(1),l=i(4),h=s.each,u=l.asc,c=function(t,e,i,n){this._dimName=t,this._axisIndex=e,this._valueWindow,this._percentWindow,this._dataExtent,this.ecModel=n,this._dataZoomModel=i};c.prototype={constructor:c,hostedBy:function(t){return this._dataZoomModel===t},getDataExtent:function(){return this._dataExtent.slice()},getDataValueWindow:function(){return this._valueWindow.slice()},getDataPercentWindow:function(){return this._percentWindow.slice()},getTargetSeriesModels:function(){var t=[];return this.ecModel.eachSeries(function(e){this._axisIndex===e.get(this._dimName+"AxisIndex")&&t.push(e)},this),t},getAxisModel:function(){return this.ecModel.getComponent(this._dimName+"Axis",this._axisIndex)},getOtherAxisModel:function(){var t,e,i=this._dimName,n=this.ecModel,a=this.getAxisModel(),o="x"===i||"y"===i;o?(e="gridIndex",t="x"===i?"y":"x"):(e="polarIndex",t="angle"===i?"radius":"angle");var r;return n.eachComponent(t+"Axis",function(t){(t.get(e)||0)===(a.get(e)||0)&&(r=t)}),r},reset:function(t){if(t===this._dataZoomModel){var e=this._dataExtent=n(this._dimName,this.getTargetSeriesModels()),i=a(t.option,e,this);this._valueWindow=i.valueWindow,this._percentWindow=i.percentWindow,r(this)}},restore:function(t){t===this._dataZoomModel&&(this._valueWindow=this._percentWindow=null,r(this,!0))},filterData:function(t){function e(t){return t>=o[0]&&t<=o[1]}if(t===this._dataZoomModel){var i=this._dimName,n=this.getTargetSeriesModels(),a=t.get("filterMode"),o=this._valueWindow,r=this.getOtherAxisModel();t.get("$fromToolbox")&&r&&"category"===r.get("type")&&(a="empty"),h(n,function(t){var n=t.getData();n&&h(t.coordDimToDataDim(i),function(i){"empty"===a?t.setData(n.map(i,function(t){return e(t)?t:NaN})):n.filterSelf(i,e)})})}}},t.exports=c},function(t,e,i){t.exports=i(39).extend({type:"dataZoom.inside",defaultOption:{zoomLock:!1}})},function(t,e,i){function n(t,e,i,n){e=e.slice();var a=n.axisModels[0];if(a){var r=o(t,a,i),s=r.signal*(e[1]-e[0])*r.pixel/r.pixelLength;return h(s,e,[0,100],"rigid"),e}}function a(t,e,i,n,a,s){i=i.slice();var l=a.axisModels[0];if(l){var h=o(e,l,n),u=h.pixel-h.pixelStart,c=u/h.pixelLength*(i[1]-i[0])+i[0];return t=Math.max(t,0),i[0]=(i[0]-c)*t+c,i[1]=(i[1]-c)*t+c,r(i)}}function o(t,e,i){var n=e.axis,a=i.rect,o={};return"x"===n.dim?(o.pixel=t[0],o.pixelLength=a.width,o.pixelStart=a.x,o.signal=n.inverse?1:-1):(o.pixel=t[1],o.pixelLength=a.height,o.pixelStart=a.y,o.signal=n.inverse?-1:1),o}function r(t){var e=[0,100];return!(t[0]<=e[1])&&(t[0]=e[1]),!(t[1]<=e[1])&&(t[1]=e[1]),!(t[0]>=e[0])&&(t[0]=e[0]),!(t[1]>=e[0])&&(t[1]=e[0]),t}var s=i(40),l=i(1),h=i(71),u=i(173),c=l.bind,d=s.extend({type:"dataZoom.inside",init:function(t,e){this._range},render:function(t,e,i,n){d.superApply(this,"render",arguments),u.shouldRecordRange(n,t.id)&&(this._range=t.getPercentRange()),l.each(this.getTargetInfo().cartesians,function(e){var n=e.model;u.register(i,{coordId:n.id,coordType:n.type,coordinateSystem:n.coordinateSystem,dataZoomId:t.id,throttleRage:t.get("throttle",!0),panGetRange:c(this._onPan,this,e),zoomGetRange:c(this._onZoom,this,e)})},this)},remove:function(){u.unregister(this.api,this.dataZoomModel.id),d.superApply(this,"remove",arguments),this._range=null},dispose:function(){u.unregister(this.api,this.dataZoomModel.id),d.superApply(this,"dispose",arguments),this._range=null},_onPan:function(t,e,i,a){return this._range=n([i,a],this._range,e,t)},_onZoom:function(t,e,i,n,o){var r=this.dataZoomModel;if(!r.option.zoomLock)return this._range=a(1/i,[n,o],this._range,e,t,r)}});t.exports=d},function(t,e,i){var n=i(39);t.exports=n.extend({type:"dataZoom.select"})},function(t,e,i){t.exports=i(40).extend({type:"dataZoom.select"})},function(t,e,i){var n=i(39),a=(i(11),i(1)),o=n.extend({type:"dataZoom.slider",layoutMode:"box",defaultOption:{show:!0,right:"ph",top:"ph",width:"ph",height:"ph",left:null,bottom:null,backgroundColor:"rgba(47,69,84,0)",dataBackgroundColor:"#ddd",fillerColor:"rgba(47,69,84,0.25)",handleColor:"rgba(47,69,84,0.65)",handleSize:10,labelPrecision:null,labelFormatter:null,showDetail:!0,showDataShadow:"auto",realtime:!0,zoomLock:!1,textStyle:{color:"#333"}},setDefaultLayoutParams:function(t){var e=this.option;a.each(["right","top","width","height"],function(i){"ph"===e[i]&&(e[i]=t[i])})},mergeOption:function(t){o.superApply(this,"mergeOption",arguments)}});t.exports=o},function(t,e,i){function n(t){return"x"===t?"y":"x"}var a=i(1),o=i(3),r=i(125),s=i(40),l=o.Rect,h=i(4),u=h.linearMap,c=i(11),d=i(71),f=h.asc,p=a.bind,g=Math.round,m=Math.max,v=a.each,y=7,x=1,_=30,w="horizontal",b="vertical",S=5,M=["line","bar","candlestick","scatter"],A=s.extend({type:"dataZoom.slider",init:function(t,e){this._displayables={},this._orient,this._range,this._handleEnds,this._size,this._halfHandleSize,this._location,this._dragging,this._dataShadowInfo,this.api=e},render:function(t,e,i,n){return A.superApply(this,"render",arguments),r.createOrUpdate(this,"_dispatchZoomAction",this.dataZoomModel.get("throttle"),"fixRate"),this._orient=t.get("orient"),this._halfHandleSize=g(t.get("handleSize")/2),this.dataZoomModel.get("show")===!1?void this.group.removeAll():(n&&"dataZoom"===n.type&&n.from===this.uid||this._buildView(),void this._updateView())},remove:function(){A.superApply(this,"remove",arguments),r.clear(this,"_dispatchZoomAction")},dispose:function(){A.superApply(this,"dispose",arguments),r.clear(this,"_dispatchZoomAction")},_buildView:function(){var t=this.group;t.removeAll(),this._resetLocation(),this._resetInterval();var e=this._displayables.barGroup=new o.Group;this._renderBackground(),this._renderDataShadow(),this._renderHandle(),t.add(e),this._positionGroup()},_resetLocation:function(){var t=this.dataZoomModel,e=this.api,i=this._findCoordRect(),n={width:e.getWidth(),height:e.getHeight()},a=this._orient===w?{right:n.width-i.x-i.width,top:n.height-_-y,width:i.width,height:_}:{right:y,top:i.y,width:_,height:i.height};t.setDefaultLayoutParams(a);var o=c.getLayoutRect(t.option,n,t.padding);this._location={x:o.x,y:o.y},this._size=[o.width,o.height],this._orient===b&&this._size.reverse()},_positionGroup:function(){var t=this.group,e=this._location,i=this._orient,n=this.dataZoomModel.getFirstTargetAxisModel(),a=n&&n.get("inverse"),o=this._displayables.barGroup,r=(this._dataShadowInfo||{}).otherAxisInverse;o.attr(i!==w||a?i===w&&a?{scale:r?[-1,1]:[-1,-1]}:i!==b||a?{scale:r?[-1,-1]:[-1,1],rotation:Math.PI/2}:{scale:r?[1,-1]:[1,1],rotation:Math.PI/2}:{scale:r?[1,1]:[1,-1]});var s=t.getBoundingRect([o]);t.position[0]=e.x-s.x,t.position[1]=e.y-s.y},_getViewExtent:function(){var t=this._halfHandleSize,e=m(this._size[0],4*t),i=[t,e-t];return i},_renderBackground:function(){var t=this.dataZoomModel,e=this._size;this._displayables.barGroup.add(new l({silent:!0,shape:{x:0,y:0,width:e[0],height:e[1]},style:{fill:t.get("backgroundColor")}}))},_renderDataShadow:function(){var t=this._dataShadowInfo=this._prepareDataShadowInfo();if(t){var e=this._size,i=t.series,n=i.getRawData(),a=i.getShadowDim?i.getShadowDim():t.otherDim,r=n.getDataExtent(a),s=.3*(r[1]-r[0]);r=[r[0]-s,r[1]+s];var l=[0,e[1]],h=[0,e[0]],c=[[e[0],0],[0,0]],d=h[1]/(n.count()-1),f=0,p=Math.round(n.count()/e[0]);n.each([a],function(t,e){if(p>0&&e%p)return void(f+=d);var i=null==t||isNaN(t)||""===t?null:u(t,r,l,!0);null!=i&&c.push([f,i]),f+=d}),this._displayables.barGroup.add(new o.Polyline({shape:{points:c},style:{fill:this.dataZoomModel.get("dataBackgroundColor"),lineWidth:0},silent:!0,z2:-20}))}},_prepareDataShadowInfo:function(){var t=this.dataZoomModel,e=t.get("showDataShadow");if(e!==!1){var i,o=this.ecModel;return t.eachTargetAxis(function(r,s){var l=t.getAxisProxy(r.name,s).getTargetSeriesModels();a.each(l,function(t){if(!(i||e!==!0&&a.indexOf(M,t.get("type"))<0)){var l=n(r.name),h=o.getComponent(r.axis,s).axis;i={thisAxis:h,series:t,thisDim:r.name,otherDim:l,otherAxisInverse:t.coordinateSystem.getOtherAxis(h).inverse}}},this)},this),i}},_renderHandle:function(){var t=this._displayables,e=t.handles=[],i=t.handleLabels=[],n=this._displayables.barGroup,a=this._size;n.add(t.filler=new l({draggable:!0,cursor:"move",drift:p(this._onDragMove,this,"all"),ondragend:p(this._onDragEnd,this),onmouseover:p(this._showDataInfo,this,!0),onmouseout:p(this._showDataInfo,this,!1),style:{fill:this.dataZoomModel.get("fillerColor"),textPosition:"inside"}})),n.add(new l(o.subPixelOptimizeRect({silent:!0,shape:{x:0,y:0,width:a[0],height:a[1]},style:{stroke:this.dataZoomModel.get("dataBackgroundColor"),lineWidth:x,fill:"rgba(0,0,0,0)"}}))),v([0,1],function(t){n.add(e[t]=new l({style:{fill:this.dataZoomModel.get("handleColor")},cursor:"move",draggable:!0,drift:p(this._onDragMove,this,t),ondragend:p(this._onDragEnd,this),onmouseover:p(this._showDataInfo,this,!0),onmouseout:p(this._showDataInfo,this,!1)}));var a=this.dataZoomModel.textStyleModel;this.group.add(i[t]=new o.Text({silent:!0,invisible:!0,style:{x:0,y:0,text:"",textVerticalAlign:"middle",textAlign:"center",fill:a.getTextColor(),textFont:a.getFont()}}))},this)},_resetInterval:function(){var t=this._range=this.dataZoomModel.getPercentRange(),e=this._getViewExtent();this._handleEnds=[u(t[0],[0,100],e,!0),u(t[1],[0,100],e,!0)]},_updateInterval:function(t,e){var i=this._handleEnds,n=this._getViewExtent();d(e,i,n,"all"===t||this.dataZoomModel.get("zoomLock")?"rigid":"cross",t),this._range=f([u(i[0],n,[0,100],!0),u(i[1],n,[0,100],!0)])},_updateView:function(){var t=this._displayables,e=this._handleEnds,i=f(e.slice()),n=this._size,a=this._halfHandleSize;v([0,1],function(i){var o=t.handles[i];o.setShape({x:e[i]-a,y:-1,width:2*a,height:n[1]+2,r:1})},this),t.filler.setShape({x:i[0],y:0,width:i[1]-i[0],height:this._size[1]}),this._updateDataInfo()},_updateDataInfo:function(){function t(t){var e=o.getTransform(i.handles[t],this.group),s=o.transformDirection(0===t?"right":"left",e),l=this._halfHandleSize+S,u=o.applyTransform([h[t]+(0===t?-l:l),this._size[1]/2],e);n[t].setStyle({x:u[0],y:u[1],textVerticalAlign:a===w?"middle":s,textAlign:a===w?s:"center",text:r[t]})}var e=this.dataZoomModel,i=this._displayables,n=i.handleLabels,a=this._orient,r=["",""];if(e.get("showDetail")){var s,l;e.eachTargetAxis(function(t,i){s||(s=e.getAxisProxy(t.name,i).getDataValueWindow(),l=this.ecModel.getComponent(t.axis,i).axis)},this),s&&(r=[this._formatLabel(s[0],l),this._formatLabel(s[1],l)])}var h=f(this._handleEnds.slice());t.call(this,0),t.call(this,1)},_formatLabel:function(t,e){var i=this.dataZoomModel,n=i.get("labelFormatter");if(a.isFunction(n))return n(t);var o=i.get("labelPrecision");return null!=o&&"auto"!==o||(o=e.getPixelPrecision()),t=null==t&&isNaN(t)?"":"category"===e.type||"time"===e.type?e.scale.getLabel(Math.round(t)):t.toFixed(Math.min(o,20)),a.isString(n)&&(t=n.replace("{value}",t)),t},_showDataInfo:function(t){t=this._dragging||t;var e=this._displayables.handleLabels;e[0].attr("invisible",!t),e[1].attr("invisible",!t)},_onDragMove:function(t,e,i){this._dragging=!0;var n=this._applyBarTransform([e,i],!0);this._updateInterval(t,n[0]),this._updateView(),this.dataZoomModel.get("realtime")&&this._dispatchZoomAction()},_onDragEnd:function(){this._dragging=!1,this._showDataInfo(!1),this._dispatchZoomAction()},_dispatchZoomAction:function(){var t=this._range;this.api.dispatchAction({type:"dataZoom",from:this.uid,dataZoomId:this.dataZoomModel.id,start:t[0],end:t[1]})},_applyBarTransform:function(t,e){var i=this._displayables.barGroup.getLocalTransform();return o.applyTransform(t,i,e)},_findCoordRect:function(){var t,e=this.getTargetInfo();if(e.cartesians.length)t=e.cartesians[0].model.coordinateSystem.getRect();else{var i=this.api.getWidth(),n=this.api.getHeight();t={x:.2*i,y:.2*n,width:.6*i,height:.6*n}}return t}});t.exports=A},function(t,e,i){function n(t){var e=t.getZr();return e[p]||(e[p]={})}function a(t,e,i){var n=new c(t.getZr());return n.enable(),n.on("pan",f(r,i)),n.on("zoom",f(s,i)),n.rect=e.coordinateSystem.getRect().clone(),n}function o(t){u.each(t,function(e,i){e.count||(e.controller.off("pan").off("zoom"),delete t[i])})}function r(t,e,i){l(t,function(n){return n.panGetRange(t.controller,e,i)})}function s(t,e,i,n){l(t,function(a){return a.zoomGetRange(t.controller,e,i,n)})}function l(t,e){var i=[];u.each(t.dataZoomInfos,function(t){var n=e(t);n&&i.push({dataZoomId:t.dataZoomId,start:n[0],end:n[1]})}),t.dispatchAction(i)}function h(t,e){t.dispatchAction({type:"dataZoom",batch:e})}var u=i(1),c=i(70),d=i(125),f=u.curry,p="\x00_ec_dataZoom_roams",g={register:function(t,e){var i=n(t),r=e.dataZoomId,s=e.coordType+"\x00_"+e.coordId;u.each(i,function(t,e){var i=t.dataZoomInfos;i[r]&&e!==s&&(delete i[r],t.count--)}),o(i);var l=i[s];l||(l=i[s]={coordId:s,dataZoomInfos:{},count:0},l.controller=a(t,e,l),l.dispatchAction=u.curry(h,t)),l&&(d.createOrUpdate(l,"dispatchAction",e.throttleRate,"fixRate"),!l.dataZoomInfos[r]&&l.count++,l.dataZoomInfos[r]=e)},unregister:function(t,e){var i=n(t);u.each(i,function(t,i){var n=t.dataZoomInfos;n[e]&&(delete n[e],t.count--)}),o(i)},shouldRecordRange:function(t,e){if(t&&"dataZoom"===t.type&&t.batch)for(var i=0,n=t.batch.length;n>i;i++)if(t.batch[i].dataZoomId===e)return!1;return!0}};t.exports=g},function(t,e,i){i(100),i(39),i(40),i(169),i(170),i(98),i(97)},function(t,e,i){i(176),i(178),i(177);var n=i(2);n.registerProcessor("filter",i(179))},function(t,e,i){"use strict";var n=i(1),a=i(12),o=i(2).extendComponentModel({type:"legend",dependencies:["series"],layoutMode:{type:"box",ignoreSize:!0},init:function(t,e,i){this.mergeDefaultAndTheme(t,i),t.selected=t.selected||{},this._updateData(i);var n=this._data,a=this.option.selected;if(n[0]&&"single"===this.get("selectedMode")){var o=!1;for(var r in a)a[r]&&(this.select(r),o=!0);!o&&this.select(n[0].get("name"))}},mergeOption:function(t){o.superCall(this,"mergeOption",t),this._updateData(this.ecModel)},_updateData:function(t){var e=n.map(this.get("data")||[],function(t){return"string"==typeof t&&(t={name:t}),new a(t,this,this.ecModel)},this);this._data=e;var i=n.map(t.getSeries(),function(t){return t.name});t.eachSeries(function(t){if(t.legendDataProvider){var e=t.legendDataProvider();i=i.concat(e.mapArray(e.getName))}}),this._availableNames=i},getData:function(){return this._data},select:function(t){var e=this.option.selected,i=this.get("selectedMode");if("single"===i){var a=this._data;n.each(a,function(t){e[t.get("name")]=!1})}e[t]=!0},unSelect:function(t){"single"!==this.get("selectedMode")&&(this.option.selected[t]=!1)},toggleSelected:function(t){ +var e=this.option.selected;t in e||(e[t]=!0),this[e[t]?"unSelect":"select"](t)},isSelected:function(t){var e=this.option.selected;return!(t in e&&!e[t])&&n.indexOf(this._availableNames,t)>=0},defaultOption:{zlevel:0,z:4,show:!0,orient:"horizontal",left:"center",top:"top",align:"auto",backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",borderWidth:0,padding:5,itemGap:10,itemWidth:25,itemHeight:14,textStyle:{color:"#333"},selectedMode:!0}});t.exports=o},function(t,e,i){function n(t,e){e.dispatchAction({type:"legendToggleSelect",name:t})}function a(t,e,i){t.get("legendHoverLink")&&i.dispatchAction({type:"highlight",seriesName:t.name,name:e})}function o(t,e,i){t.get("legendHoverLink")&&i.dispatchAction({type:"downplay",seriesName:t.name,name:e})}var r=i(1),s=i(24),l=i(3),h=i(102),u=r.curry,c="#ccc";t.exports=i(2).extendComponentView({type:"legend",init:function(){this._symbolTypeStore={}},render:function(t,e,i){var s=this.group;if(s.removeAll(),t.get("show")){var c=t.get("selectedMode"),d=t.get("align");"auto"===d&&(d="right"===t.get("left")&&"vertical"===t.get("orient")?"right":"left");var f={},p={};r.each(t.getData(),function(r){var h=r.get("name");""!==h&&"\n"!==h||s.add(new l.Group({newline:!0}));var g=e.getSeriesByName(h)[0];if(f[h]=r,g&&!p[h]){var m=g.getData(),v=m.getVisual("color");"function"==typeof v&&(v=v(g.getDataParams(0)));var y=m.getVisual("legendSymbol")||"roundRect",x=m.getVisual("symbol"),_=this._createItem(h,r,t,y,x,d,v,c);_.on("click",u(n,h,i)).on("mouseover",u(a,g,"",i)).on("mouseout",u(o,g,"",i)),p[h]=!0}},this),e.eachRawSeries(function(e){if(e.legendDataProvider){var r=e.legendDataProvider();r.each(function(s){var l=r.getName(s);if(f[l]&&!p[l]){var h=r.getItemVisual(s,"color"),g="roundRect",m=this._createItem(l,f[l],t,g,null,d,h,c);m.on("click",u(n,l,i)).on("mouseover",u(a,e,l,i)).on("mouseout",u(o,e,l,i)),p[l]=!0}},!1,this)}},this),h.layout(s,t,i),h.addBackground(s,t)}},_createItem:function(t,e,i,n,a,o,r,h){var u=i.get("itemWidth"),d=i.get("itemHeight"),f=i.isSelected(t),p=new l.Group,g=e.getModel("textStyle"),m=e.get("icon");if(n=m||n,p.add(s.createSymbol(n,0,0,u,d,f?r:c)),!m&&a&&(a!==n||"none"==a)){var v=.8*d;"none"===a&&(a="circle"),p.add(s.createSymbol(a,(u-v)/2,(d-v)/2,v,v,f?r:c))}var y="left"===o?u+5:-5,x=o,_=i.get("formatter");"string"==typeof _&&_?t=_.replace("{name}",t):"function"==typeof _&&(t=_(t));var w=new l.Text({style:{text:t,x:y,y:d/2,fill:f?g.getTextColor():c,textFont:g.getFont(),textAlign:x,textVerticalAlign:"middle"}});return p.add(w),p.add(new l.Rect({shape:p.getBoundingRect(),invisible:!0})),p.eachChild(function(t){t.silent=!h}),this.group.add(p),p}})},function(t,e,i){function n(t,e,i){var n,a={},r="toggleSelected"===t;return i.eachComponent("legend",function(i){r&&null!=n?i[n?"select":"unSelect"](e.name):(i[t](e.name),n=i.isSelected(e.name));var s=i.getData();o.each(s,function(t){var e=t.get("name");if("\n"!==e&&""!==e){var n=i.isSelected(e);e in a?a[e]=a[e]&&n:a[e]=n}})}),{name:e.name,selected:a}}var a=i(2),o=i(1);a.registerAction("legendToggleSelect","legendselectchanged",o.curry(n,"toggleSelected")),a.registerAction("legendSelect","legendselected",o.curry(n,"select")),a.registerAction("legendUnSelect","legendunselected",o.curry(n,"unSelect"))},function(t,e){t.exports=function(t){var e=t.findComponents({mainType:"legend"});e&&e.length&&t.filterSeries(function(t){for(var i=0;i=0&&(p=+p.toFixed(g)),c[h]=f[h]=p,n=[c,f,{type:r,valueIndex:n.valueIndex,value:p}]}return n=[d.dataTransform(t,n[0]),d.dataTransform(t,n[1]),o.extend({},n[2])],n[2].type=n[2].type||"",o.merge(n[2],n[0]),o.merge(n[2],n[1]),n},g={formatTooltip:function(t){var e=this._data,i=this.getRawValue(t),n=o.isArray(i)?o.map(i,u).join(", "):u(i),a=e.getName(t);return this.name+"
"+((a?c(a)+" : ":"")+n)},getRawDataArray:function(){return this.option.data},getData:function(){return this._data},setData:function(t){this._data=t}};o.defaults(g,l.dataFormatMixin),i(2).extendComponentView({type:"markLine",init:function(){this._markLineMap={}},render:function(t,e,i){var n=this._markLineMap;for(var a in n)n[a].__keep=!1;e.eachSeries(function(t){var n=t.markLineModel;n&&this._renderSeriesML(t,n,e,i)},this);for(var a in n)n[a].__keep||this.group.remove(n[a].group)},_renderSeriesML:function(t,e,i,n){function r(e,i,a,o,r){var l,c=e.getItemModel(i),d=c.get("x"),f=c.get("y");if(null!=d&&null!=f)l=[h.parsePercent(d,n.getWidth()),h.parsePercent(f,n.getHeight())];else{if(t.getMarkerPosition)l=t.getMarkerPosition(e.getValues(e.dimensions,i));else{var p=e.get(m[0],i),g=e.get(m[1],i);l=s.dataToPoint([p,g])}if(o&&"cartesian2d"===s.type){var v=null!=r?s.getAxis(1===r?"x":"y"):s.getAxesByScale("ordinal")[0];v&&v.onBand&&(l["x"===v.dim?0:1]=v.toGlobalCoord(v.getExtent()[a?0:1]))}}e.setItemLayout(i,l),e.setItemVisual(i,{symbolSize:c.get("symbolSize")||w[a?0:1],symbol:c.get("symbol",!0)||_[a?0:1],color:c.get("itemStyle.normal.color")||u.getVisual("color")})}var s=t.coordinateSystem,l=t.name,u=t.getData(),c=this._markLineMap,d=c[l];d||(d=c[l]=new f),this.group.add(d.group);var p=a(s,t,e),m=s.dimensions,v=p.from,y=p.to,x=p.line;o.extend(e,g),e.setData(x);var _=e.get("symbol"),w=e.get("symbolSize");o.isArray(_)||(_=[_,_]),"number"==typeof w&&(w=[w,w]),p.from.each(function(t){var e=x.getItemModel(t),i=e.get("type"),n=e.get("valueIndex");r(v,t,!0,i,n),r(y,t,!1,i,n)}),x.each(function(t){var e=x.getItemModel(t).get("lineStyle.normal.color");x.setItemVisual(t,{color:e||v.getItemVisual(t,"color")}),x.setItemLayout(t,[v.getItemLayout(t),y.getItemLayout(t)])}),d.updateData(x,v,y),p.line.eachItemGraphicEl(function(t,i){t.traverse(function(t){t.hostModel=e})}),d.__keep=!0}})},function(t,e,i){var n=i(7),a=i(2).extendComponentModel({type:"markPoint",dependencies:["series","grid","polar"],init:function(t,e,i,n){this.mergeDefaultAndTheme(t,i),this.mergeOption(t,i,n.createdBySelf,!0)},mergeOption:function(t,e,i,o){i||e.eachSeries(function(t){var i=t.get("markPoint"),r=t.markPointModel;if(!i||!i.data)return void(t.markPointModel=null);if(r)r.mergeOption(i,e,!0);else{o&&n.defaultEmphasis(i.label,["position","show","textStyle","distance","formatter"]);var s={seriesIndex:t.seriesIndex,name:t.name,createdBySelf:!0};r=new a(i,this,e,s)}t.markPointModel=r},this)},defaultOption:{zlevel:0,z:5,symbol:"pin",symbolSize:50,tooltip:{trigger:"item"},label:{normal:{show:!0,position:"inside"},emphasis:{show:!0}},itemStyle:{normal:{borderWidth:2},emphasis:{}}}});t.exports=a},function(t,e,i){function n(t,e,i){var n=o.map(t.dimensions,function(t){var i=e.getData().getDimensionInfo(e.coordDimToDataDim(t)[0]);return i.name=t,i}),a=new c(n,i);return t&&a.initData(o.filter(o.map(i.get("data"),o.curry(d.dataTransform,e)),o.curry(d.dataFilter,t)),null,d.dimValueGetter),a}var a=i(38),o=i(1),r=i(9),s=i(7),l=i(4),h=r.addCommas,u=r.encodeHTML,c=i(14),d=i(103),f={getRawDataArray:function(){return this.option.data},formatTooltip:function(t){var e=this.getData(),i=this.getRawValue(t),n=o.isArray(i)?o.map(i,h).join(", "):h(i),a=e.getName(t);return this.name+"
"+((a?u(a)+" : ":"")+n)},getData:function(){return this._data},setData:function(t){this._data=t}};o.defaults(f,s.dataFormatMixin),i(2).extendComponentView({type:"markPoint",init:function(){this._symbolDrawMap={}},render:function(t,e,i){var n=this._symbolDrawMap;for(var a in n)n[a].__keep=!1;e.eachSeries(function(t){var e=t.markPointModel;e&&this._renderSeriesMP(t,e,i)},this);for(var a in n)n[a].__keep||(n[a].remove(),this.group.remove(n[a].group))},_renderSeriesMP:function(t,e,i){var r=t.coordinateSystem,s=t.name,h=t.getData(),u=this._symbolDrawMap,c=u[s];c||(c=u[s]=new a);var d=n(r,t,e),p=r&&r.dimensions;o.mixin(e,f),e.setData(d),d.each(function(n){var a,o=d.getItemModel(n),s=o.getShallow("x"),u=o.getShallow("y");if(null!=s&&null!=u)a=[l.parsePercent(s,i.getWidth()),l.parsePercent(u,i.getHeight())];else if(t.getMarkerPosition)a=t.getMarkerPosition(d.getValues(d.dimensions,n));else if(r){var c=d.get(p[0],n),f=d.get(p[1],n);a=r.dataToPoint([c,f])}d.setItemLayout(n,a);var g=o.getShallow("symbolSize");"function"==typeof g&&(g=g(e.getRawValue(n),e.getDataParams(n))),d.setItemVisual(n,{symbolSize:g,color:o.get("itemStyle.normal.color")||h.getVisual("color"),symbol:o.getShallow("symbol")})}),c.updateData(d),this.group.add(c.group),d.eachItemGraphicEl(function(t){t.traverse(function(t){t.hostModel=e})}),c.__keep=!0}})},function(t,e,i){"use strict";var n=i(2),a=i(3),o=i(11);n.extendComponentModel({type:"title",layoutMode:{type:"box",ignoreSize:!0},defaultOption:{zlevel:0,z:6,show:!0,text:"",target:"blank",subtext:"",subtarget:"blank",left:0,top:0,backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",borderWidth:0,padding:5,itemGap:10,textStyle:{fontSize:18,fontWeight:"bolder",color:"#333"},subtextStyle:{color:"#aaa"}}}),n.extendComponentView({type:"title",render:function(t,e,i){if(this.group.removeAll(),t.get("show")){var n=this.group,r=t.getModel("textStyle"),s=t.getModel("subtextStyle"),l=t.get("textAlign"),h=new a.Text({style:{text:t.get("text"),textFont:r.getFont(),fill:r.getTextColor(),textBaseline:"top"},z2:10}),u=h.getBoundingRect(),c=t.get("subtext"),d=new a.Text({style:{text:c,textFont:s.getFont(),fill:s.getTextColor(),y:u.height+t.get("itemGap"),textBaseline:"top"},z2:10}),f=t.get("link"),p=t.get("sublink");h.silent=!f,d.silent=!p,f&&h.on("click",function(){window.open(f,t.get("target"))}),p&&d.on("click",function(){window.open(p,t.get("subtarget"))}),n.add(h),c&&n.add(d);var g=n.getBoundingRect(),m=t.getBoxLayoutParams();m.width=g.width,m.height=g.height;var v=o.getLayoutRect(m,{width:i.getWidth(),height:i.getHeight()},t.get("padding"));l||(l=t.get("left")||t.get("right"),"middle"===l&&(l="center"),"right"===l?v.x+=v.width:"center"===l&&(v.x+=v.width/2)),n.position=[v.x,v.y],h.setStyle("textAlign",l),d.setStyle("textAlign",l),g=n.getBoundingRect();var y=v.margin,x=t.getItemStyle(["color","opacity"]);x.fill=t.get("backgroundColor");var _=new a.Rect({shape:{x:g.x-y[3],y:g.y-y[0],width:g.width+y[1]+y[3],height:g.height+y[0]+y[2]},style:x,silent:!0});a.subPixelOptimizeRect(_),n.add(_)}}})},function(t,e,i){i(188),i(189),i(194),i(192),i(190),i(191),i(193)},function(t,e,i){var n=i(29),a=i(1),o=i(2).extendComponentModel({type:"toolbox",layoutMode:{type:"box",ignoreSize:!0},mergeDefaultAndTheme:function(t){o.superApply(this,"mergeDefaultAndTheme",arguments),a.each(this.option.feature,function(t,e){var i=n.get(e);i&&a.merge(t,i.defaultOption)})},defaultOption:{show:!0,z:6,zlevel:0,orient:"horizontal",left:"right",top:"top",backgroundColor:"transparent",borderColor:"#ccc",borderWidth:0,padding:5,itemSize:15,itemGap:8,showTitle:!0,iconStyle:{normal:{borderColor:"#666",color:"none"},emphasis:{borderColor:"#3E98C5"}}}});t.exports=o},function(t,e,i){(function(e){function n(t){return 0===t.indexOf("my")}var a=i(29),o=i(1),r=i(3),s=i(12),l=i(52),h=i(102),u=i(17);t.exports=i(2).extendComponentView({type:"toolbox",render:function(t,e,i){function c(o,r){var l,h=v[o],u=v[r],c=g[h],f=new s(c,t,t.ecModel);if(h&&!u){if(n(h))l={model:f,onclick:f.option.onclick,featureName:h};else{var p=a.get(h);if(!p)return;l=new p(f)}m[h]=l}else{if(l=m[u],!l)return;l.model=f}return!h&&u?void(l.dispose&&l.dispose(e,i)):!f.get("show")||l.unusable?void(l.remove&&l.remove(e,i)):(d(f,l,h),f.setIconStatus=function(t,e){var i=this.option,n=this.iconPaths;i.iconStatus=i.iconStatus||{},i.iconStatus[t]=e,n[t]&&n[t].trigger(e)},void(l.render&&l.render(f,e,i)))}function d(n,a,s){var l=n.getModel("iconStyle"),h=a.getIcons?a.getIcons():n.get("icon"),u=n.get("title")||{};if("string"==typeof h){var c=h,d=u;h={},u={},h[s]=c,u[s]=d}var g=n.iconPaths={};o.each(h,function(s,h){var c=l.getModel("normal").getItemStyle(),d=l.getModel("emphasis").getItemStyle(),m={x:-p/2,y:-p/2,width:p,height:p},v=0===s.indexOf("image://")?(m.image=s.slice(8),new r.Image({style:m})):r.makePath(s.replace("path://",""),{style:c,hoverStyle:d,rectHover:!0},m,"center");r.setHoverStyle(v),t.get("showTitle")&&(v.__title=u[h],v.on("mouseover",function(){v.setStyle({text:u[h],textPosition:d.textPosition||"bottom",textFill:d.fill||d.stroke||"#000",textAlign:d.textAlign||"center"})}).on("mouseout",function(){v.setStyle({textFill:null})})),v.trigger(n.get("iconStatus."+h)||"normal"),f.add(v),v.on("click",o.bind(a.onclick,a,e,i,h)),g[h]=v})}var f=this.group;if(f.removeAll(),t.get("show")){var p=+t.get("itemSize"),g=t.get("feature")||{},m=this._features||(this._features={}),v=[];o.each(g,function(t,e){v.push(e)}),new l(this._featureNames||[],v).add(c).update(c).remove(o.curry(c,null)).execute(),this._featureNames=v,h.layout(f,t,i),h.addBackground(f,t),f.eachChild(function(t){var e=t.__title,n=t.hoverStyle;if(n&&e){var a=u.getBoundingRect(e,n.font),o=t.position[0]+f.position[0],r=t.position[1]+f.position[1]+p,s=!1;r+a.height>i.getHeight()&&(n.textPosition="top",s=!0);var l=s?-5-a.height:p+8;o+a.width/2>i.getWidth()?(n.textPosition=["100%",l],n.textAlign="right"):o-a.width/2<0&&(n.textPosition=[0,l],n.textAlign="left")}})}},remove:function(t,e){o.each(this._features,function(i){i.remove&&i.remove(t,e)}),this.group.removeAll()},dispose:function(t,e){o.each(this._features,function(i){i.dispose&&i.dispose(t,e)})}})}).call(e,i(200))},function(t,e,i){function n(t){var e={},i=[],n=[];return t.eachRawSeries(function(t){var a=t.coordinateSystem;if(!a||"cartesian2d"!==a.type&&"polar"!==a.type)i.push(t);else{var o=a.getBaseAxis();if("category"===o.type){var r=o.dim+"_"+o.index;e[r]||(e[r]={categoryAxis:o,valueAxis:a.getOtherAxis(o),series:[]},n.push({axisDim:o.dim,axisIndex:o.index})),e[r].series.push(t)}else i.push(t)}}),{seriesGroupByCategoryAxis:e,other:i,meta:n}}function a(t){var e=[];return p.each(t,function(t,i){var n=t.categoryAxis,a=t.valueAxis,o=a.dim,r=[" "].concat(p.map(t.series,function(t){return t.name})),s=[n.model.getCategories()];p.each(t.series,function(t){s.push(t.getRawData().mapArray(o,function(t){return t}))});for(var l=[r.join(v)],h=0;hr;r++)n[r]=arguments[r];i.push((o?o+v:"")+n.join(v))}),i.join("\n")}).join("\n\n"+m+"\n\n")}function r(t){var e=n(t);return{value:p.filter([a(e.seriesGroupByCategoryAxis),o(e.other)],function(t){return t.replace(/[\n\t\s]/g,"")}).join("\n\n"+m+"\n\n"),meta:e.meta}}function s(t){return t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function l(t){var e=t.slice(0,t.indexOf("\n"));return e.indexOf(v)>=0?!0:void 0}function h(t){for(var e=t.split(/\n+/g),i=s(e.shift()).split(y),n=[],a=p.map(i,function(t){return{name:t,data:[]}}),o=0;o1?"emphasis":"normal")}var h=i(1),u=i(4),c=i(159),d=i(8),f=i(26),p=i(99),g=i(101),m=h.each,v=u.asc;i(174);var y="\x00_ec_\x00toolbox-dataZoom_";n.defaultOption={show:!0,icon:{zoom:"M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1",back:"M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26"},title:{zoom:"区域缩放",back:"区域缩放还原"}};var x=n.prototype;x.render=function(t,e,i){l(t,e)},x.onclick=function(t,e,i){var n=this._controllerGroup;this._controllerGroup||(n=this._controllerGroup=new f,e.getZr().add(n)),_[i].call(this,n,this.model,t,e)},x.remove=function(t,e){this._disposeController(),g.release("globalPan",e.getZr())},x.dispose=function(t,e){var i=e.getZr();g.release("globalPan",i),this._disposeController(),this._controllerGroup&&i.remove(this._controllerGroup)};var _={zoom:function(t,e,i,n){var a=this._isZoomActive=!this._isZoomActive,o=n.getZr();g[a?"take":"release"]("globalPan",o),e.setIconStatus("zoom",a?"emphasis":"normal"),a?(o.setDefaultCursorStyle("crosshair"),this._createController(t,e,i,n)):(o.setDefaultCursorStyle("default"),this._disposeController())},back:function(t,e,i,n){this._dispatchAction(p.pop(i),n)}};x._createController=function(t,e,i,n){var a=this._controller=new c("rect",n.getZr(),{lineWidth:3,stroke:"#333",fill:"rgba(0,0,0,0.2)"});a.on("selectEnd",h.bind(this._onSelected,this,a,e,i,n)),a.enable(t,!1)},x._disposeController=function(){var t=this._controller;t&&(t.off("selected"),t.dispose())},x._onSelected=function(t,e,i,n,o){if(o.length){var l=o[0];t.update();var h={};i.eachComponent("grid",function(t,e){var n=t.coordinateSystem,o=a(n,i),u=r(l,o);if(u){var c=s(u,o,0,"x"),d=s(u,o,1,"y");c&&(h[c.dataZoomId]=c),d&&(h[d.dataZoomId]=d)}},this),p.push(i,h),this._dispatchAction(h,n)}},x._dispatchAction=function(t,e){var i=[];m(t,function(t){i.push(t)}),i.length&&e.dispatchAction({type:"dataZoom",from:this.uid,batch:h.clone(i,!0)})},i(29).register("dataZoom",n),i(2).registerPreprocessor(function(t){function e(t,e){if(e){var a=t+"Index",o=e[a];null==o||h.isArray(o)||(o=o===!1?[]:[o]),i(t,function(e,i){if(null==o||-1!==h.indexOf(o,i)){var r={type:"select",$fromToolbox:!0,id:y+t+i};r[a]=i,n.push(r)}})}}function i(e,i){var n=t[e];h.isArray(n)||(n=n?[n]:[]),m(n,i)}if(t){var n=t.dataZoom||(t.dataZoom=[]);h.isArray(n)||(n=[n]);var a=t.toolbox;if(a&&(h.isArray(a)&&(a=a[0]),a&&a.feature)){var o=a.feature.dataZoom;e("xAxis",o),e("yAxis",o)}}}),t.exports=n},function(t,e,i){"use strict";function n(t){this.model=t}var a=i(1);n.defaultOption={show:!0,type:[],icon:{line:"M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4",bar:"M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7",stack:"M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z",tiled:"M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z"},title:{line:"切换为折线图",bar:"切换为柱状图",stack:"切换为堆叠",tiled:"切换为平铺"},option:{},seriesIndex:{}};var o=n.prototype;o.getIcons=function(){var t=this.model,e=t.get("icon"),i={};return a.each(t.get("type"),function(t){e[t]&&(i[t]=e[t])}),i};var r={line:function(t,e,i,n){return"bar"===t?a.merge({id:e,type:"line",data:i.get("data"),stack:i.get("stack"),markPoint:i.get("markPoint"),markLine:i.get("markLine")},n.get("option.line")):void 0},bar:function(t,e,i,n){return"line"===t?a.merge({id:e,type:"bar",data:i.get("data"),stack:i.get("stack"),markPoint:i.get("markPoint"),markLine:i.get("markLine")},n.get("option.bar")):void 0},stack:function(t,e,i,n){return"line"===t||"bar"===t?{id:e,stack:"__ec_magicType_stack__"}:void 0},tiled:function(t,e,i,n){return"line"===t||"bar"===t?{id:e,stack:""}:void 0}},s=[["line","bar"],["stack","tiled"]];o.onclick=function(t,e,i){var n=this.model,o=n.get("seriesIndex."+i);if(r[i]){var l={series:[]},h=function(t){var e=t.subType,o=t.id,s=r[i](e,o,t,n);s&&(a.defaults(s,t.option),l.series.push(s))};a.each(s,function(t){a.indexOf(t,i)>=0&&a.each(t,function(t){n.setIconStatus(t,"normal")})}),n.setIconStatus(i,"emphasis"),t.eachComponent({mainType:"series",seriesIndex:o},h),e.dispatchAction({type:"changeMagicType",currentType:i,newOption:l})}};var l=i(2);l.registerAction({type:"changeMagicType",event:"magicTypeChanged",update:"prepareAndUpdate"},function(t,e){e.mergeOption(t.newOption)}),i(29).register("magicType",n),t.exports=n},function(t,e,i){"use strict";function n(t){this.model=t}var a=i(99);n.defaultOption={show:!0,icon:"M3.8,33.4 M47,18.9h9.8V8.7 M56.3,20.1 C52.1,9,40.5,0.6,26.8,2.1C12.6,3.7,1.6,16.2,2.1,30.6 M13,41.1H3.1v10.2 M3.7,39.9c4.2,11.1,15.8,19.5,29.5,18 c14.2-1.6,25.2-14.1,24.7-28.5",title:"还原"};var o=n.prototype;o.onclick=function(t,e,i){a.clear(t),e.dispatchAction({type:"restore",from:this.uid})},i(29).register("restore",n),i(2).registerAction({type:"restore",event:"restore",update:"prepareAndUpdate"},function(t,e){e.resetOption("recreate")}),t.exports=n},function(t,e,i){function n(t){this.model=t}var a=i(15);n.defaultOption={show:!0,icon:"M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0",title:"保存为图片",type:"png",name:"",excludeComponents:["toolbox"],pixelRatio:1,lang:["右键另存为图片"]},n.prototype.unusable=!a.canvasSupported;var o=n.prototype;o.onclick=function(t,e){var i=this.model,n=i.get("name")||t.get("title.0.text")||"echarts",a=document.createElement("a"),o=i.get("type",!0)||"png";a.download=n+"."+o,a.target="_blank";var r=e.getConnectedDataURL({type:o,backgroundColor:i.get("backgroundColor",!0)||t.get("backgroundColor")||"#fff",excludeComponents:i.get("excludeComponents"),pixelRatio:i.get("pixelRatio")});if(a.href=r,"function"==typeof MouseEvent){var s=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});a.dispatchEvent(s)}else{var l=i.get("lang"),h='',u=window.open();u.document.write(h)}},i(29).register("saveAsImage",n),t.exports=n},function(t,e,i){i(197),i(198),i(2).registerAction({type:"showTip",event:"showTip",update:"none"},function(){}),i(2).registerAction({type:"hideTip",event:"hideTip",update:"none"},function(){})},function(t,e,i){function n(t){var e="cubic-bezier(0.23, 1, 0.32, 1)",i="left "+t+"s "+e+",top "+t+"s "+e;return l.map(p,function(t){return t+"transition:"+i}).join(";")}function a(t){var e=[],i=t.get("fontSize"),n=t.getTextColor();return n&&e.push("color:"+n),e.push("font:"+t.getFont()),i&&e.push("line-height:"+Math.round(3*i/2)+"px"),d(["decoration","align"],function(i){var n=t.get(i);n&&e.push("text-"+i+":"+n)}),e.join(";")}function o(t){t=t;var e=[],i=t.get("transitionDuration"),o=t.get("backgroundColor"),r=t.getModel("textStyle"),s=t.get("padding");return i&&e.push(n(i)),o&&(e.push("background-Color:"+h.toHex(o)),e.push("filter:alpha(opacity=70)"),e.push("background-Color:"+o)),d(["width","color","radius"],function(i){var n="border-"+i,a=f(n),o=t.get(a);null!=o&&e.push(n+":"+o+("color"===i?"":"px"))}),e.push(a(r)),null!=s&&e.push("padding:"+c.normalizeCssArray(s).join("px ")+"px"),e.join(";")+";"}function r(t,e){var i=document.createElement("div"),n=e.getZr();this.el=i,this._x=e.getWidth()/2,this._y=e.getHeight()/2,t.appendChild(i),this._container=t,this._show=!1,this._hideTimeout;var a=this;i.onmouseenter=function(){a.enterable&&(clearTimeout(a._hideTimeout),a._show=!0),a._inContent=!0},i.onmousemove=function(e){if(!a.enterable){var i=n.handler;u.normalizeEvent(t,e),i.dispatch("mousemove",e)}},i.onmouseleave=function(){a.enterable&&a._show&&a.hideLater(a._hideDelay),a._inContent=!1},s(i,t)}function s(t,e){function i(t){n(t.target)&&t.preventDefault()}function n(i){for(;i&&i!==e;){if(i===t)return!0;i=i.parentNode}}u.addEventListener(e,"touchstart",i),u.addEventListener(e,"touchmove",i),u.addEventListener(e,"touchend",i)}var l=i(1),h=i(22),u=i(33),c=i(9),d=l.each,f=c.toCamelCase,p=["","-webkit-","-moz-","-o-"],g="position:absolute;display:block;border-style:solid;white-space:nowrap;";r.prototype={constructor:r,enterable:!0,update:function(){var t=this._container,e=t.currentStyle||document.defaultView.getComputedStyle(t),i=t.style;"absolute"!==i.position&&"absolute"!==e.position&&(i.position="relative")},show:function(t){clearTimeout(this._hideTimeout),this.el.style.cssText=g+o(t)+";left:"+this._x+"px;top:"+this._y+"px;",this._show=!0},setContent:function(t){var e=this.el;e.innerHTML=t,e.style.display=t?"block":"none"},moveTo:function(t,e){var i=this.el.style;i.left=t+"px",i.top=e+"px",this._x=t,this._y=e},hide:function(){this.el.style.display="none",this._show=!1},hideLater:function(t){!this._show||this._inContent&&this.enterable||(t?(this._hideDelay=t,this._show=!1,this._hideTimeout=setTimeout(l.bind(this.hide,this),t)):this.hide())},isShow:function(){return this._show}},t.exports=r},function(t,e,i){i(2).extendComponentModel({type:"tooltip",defaultOption:{zlevel:0,z:8,show:!0,showContent:!0,trigger:"item",triggerOn:"mousemove",alwaysShowContent:!1,hideDelay:100,transitionDuration:.4,enterable:!1,backgroundColor:"rgba(50,50,50,0.7)",borderColor:"#333",borderRadius:4,borderWidth:0,padding:5,axisPointer:{type:"line",axis:"auto",animation:!0,animationDurationUpdate:200,animationEasingUpdate:"exponentialOut",lineStyle:{color:"#555",width:1,type:"solid"},crossStyle:{color:"#555",width:1,type:"dashed",textStyle:{}},shadowStyle:{color:"rgba(150,150,150,0.3)"}},textStyle:{color:"#fff",fontSize:14}}})},function(t,e,i){function n(t,e){if(!t||!e)return!1;var i=g.round;return i(t[0])===i(e[0])&&i(t[1])===i(e[1])}function a(t,e,i,n){return{x1:t,y1:e,x2:i,y2:n}}function o(t,e,i,n){return{x:t,y:e,width:i,height:n}}function r(t,e,i,n,a,o){return{cx:t,cy:e,r0:i,r:n,startAngle:a,endAngle:o,clockwise:!0}}function s(t,e,i,n,a){var o=i.clientWidth,r=i.clientHeight,s=20;return t+o+s>n?t-=o+s:t+=s,e+r+s>a?e-=r+s:e+=s,[t,e]}function l(t,e,i){var n=i.clientWidth,a=i.clientHeight,o=5,r=0,s=0,l=e.width,h=e.height;switch(t){case"inside":r=e.x+l/2-n/2,s=e.y+h/2-a/2;break;case"top":r=e.x+l/2-n/2,s=e.y-a-o;break;case"bottom":r=e.x+l/2-n/2,s=e.y+h+o;break;case"left":r=e.x-n-o,s=e.y+h/2-a/2;break;case"right":r=e.x+l+o,s=e.y+h/2-a/2}return[r,s]}function h(t,e,i,n,a,o,r){var h=r.getWidth(),u=r.getHeight(),c=o&&o.getBoundingRect().clone(); +if(o&&c.applyTransform(o.transform),"function"==typeof t&&(t=t([e,i],a,c)),f.isArray(t))e=m(t[0],h),i=m(t[1],u);else if("string"==typeof t&&o){var d=l(t,c,n.el);e=d[0],i=d[1]}else{var d=s(e,i,n.el,h,u);e=d[0],i=d[1]}n.moveTo(e,i)}function u(t){var e=t.coordinateSystem,i=t.get("tooltip.trigger",!0);return!(!e||"cartesian2d"!==e.type&&"polar"!==e.type&&"single"!==e.type||"item"===i)}var c=i(196),d=i(3),f=i(1),p=i(9),g=i(4),m=g.parsePercent,v=i(15);i(2).extendComponentView({type:"tooltip",_axisPointers:{},init:function(t,e){if(!v.node){var i=new c(e.getDom(),e);this._tooltipContent=i,e.on("showTip",this._manuallyShowTip,this),e.on("hideTip",this._manuallyHideTip,this)}},render:function(t,e,i){if(!v.node){this.group.removeAll(),this._axisPointers={},this._tooltipModel=t,this._ecModel=e,this._api=i,this._lastHover={};var n=this._tooltipContent;n.update(),n.enterable=t.get("enterable"),this._alwaysShowContent=t.get("alwaysShowContent"),this._seriesGroupByAxis=this._prepareAxisTriggerData(t,e);var a=this._crossText;if(a&&this.group.add(a),null!=this._lastX&&null!=this._lastY){var o=this;clearTimeout(this._refreshUpdateTimeout),this._refreshUpdateTimeout=setTimeout(function(){o._manuallyShowTip({x:o._lastX,y:o._lastY})})}var r=this._api.getZr(),s=this._tryShow;r.off("click",s),r.off("mousemove",s),r.off("mouseout",this._hide),"click"===t.get("triggerOn")?r.on("click",s,this):(r.on("mousemove",s,this),r.on("mouseout",this._hide,this))}},_manuallyShowTip:function(t){if(t.from!==this.uid){var e=this._ecModel,i=t.seriesIndex,n=t.dataIndex,a=e.getSeriesByIndex(i),o=this._api;if(null==t.x||null==t.y){if(a||e.eachSeries(function(t){u(t)&&!a&&(a=t)}),a){var r=a.getData();null==n&&(n=r.indexOfName(t.name));var s,l,h=r.getItemGraphicEl(n),c=a.coordinateSystem;if(c&&c.dataToPoint){var d=c.dataToPoint(r.getValues(c.dimensions,n,!0));s=d&&d[0],l=d&&d[1]}else if(h){var f=h.getBoundingRect().clone();f.applyTransform(h.transform),s=f.x+f.width/2,l=f.y+f.height/2}null!=s&&null!=l&&this._tryShow({offsetX:s,offsetY:l,target:h,event:{}})}}else{var h=o.getZr().handler.findHover(t.x,t.y);this._tryShow({offsetX:t.x,offsetY:t.y,target:h,event:{}})}}},_manuallyHideTip:function(t){t.from!==this.uid&&this._hide()},_prepareAxisTriggerData:function(t,e){var i={};return e.eachSeries(function(t){if(u(t)){var e,n,a=t.coordinateSystem;"cartesian2d"===a.type?(e=a.getBaseAxis(),n=e.dim+e.index):"single"===a.type?(e=a.getAxis(),n=e.dim+e.type):(e=a.getBaseAxis(),n=e.dim+a.name),i[n]=i[n]||{coordSys:[],series:[]},i[n].coordSys.push(a),i[n].series.push(t)}},this),i},_tryShow:function(t){var e=t.target,i=this._tooltipModel,n=i.get("trigger"),a=this._ecModel,o=this._api;if(i)if(this._lastX=t.offsetX,this._lastY=t.offsetY,e&&null!=e.dataIndex){var r=e.hostModel||a.getSeriesByIndex(e.seriesIndex),s=e.dataIndex,l=r.getData().getItemModel(s);"axis"===(l.get("tooltip.trigger")||n)?this._showAxisTooltip(i,a,t):(this._ticket="",this._hideAxisPointer(),this._resetLastHover(),this._showItemTooltipContent(r,s,t)),o.dispatchAction({type:"showTip",from:this.uid,dataIndex:e.dataIndex,seriesIndex:e.seriesIndex})}else"item"===n?this._hide():this._showAxisTooltip(i,a,t),"cross"===i.get("axisPointer.type")&&o.dispatchAction({type:"showTip",from:this.uid,x:t.offsetX,y:t.offsetY})},_showAxisTooltip:function(t,e,i){var a=t.getModel("axisPointer"),o=a.get("type");if("cross"===o){var r=i.target;if(r&&null!=r.dataIndex){var s=e.getSeriesByIndex(r.seriesIndex),l=r.dataIndex;this._showItemTooltipContent(s,l,i)}}this._showAxisPointer();var h=!0;f.each(this._seriesGroupByAxis,function(t){var e=t.coordSys,r=e[0],s=[i.offsetX,i.offsetY];if(!r.containPoint(s))return void this._hideAxisPointer(r.name);h=!1;var l=r.dimensions,u=r.pointToData(s,!0);s=r.dataToPoint(u);var c=r.getBaseAxis(),d=a.get("axis");"auto"===d&&(d=c.dim);var p=!1,g=this._lastHover;if("cross"===o)n(g.data,u)&&(p=!0),g.data=u;else{var m=f.indexOf(l,d);g.data===u[m]&&(p=!0),g.data=u[m]}"cartesian2d"!==r.type||p?"polar"!==r.type||p?"single"!==r.type||p||this._showSinglePointer(a,r,d,s):this._showPolarPointer(a,r,d,s):this._showCartesianPointer(a,r,d,s),"cross"!==o&&this._dispatchAndShowSeriesTooltipContent(r,t.series,s,u,p)},this),h&&this._hide()},_showCartesianPointer:function(t,e,i,n){function r(i,n,o){var r="x"===i?a(n[0],o[0],n[0],o[1]):a(o[0],n[1],o[1],n[1]),s=l._getPointerElement(e,t,i,r);u?d.updateProps(s,{shape:r},t):s.attr({shape:r})}function s(i,n,a){var r=e.getAxis(i),s=r.getBandWidth(),h=a[1]-a[0],c="x"===i?o(n[0]-s/2,a[0],s,h):o(a[0],n[1]-s/2,h,s),f=l._getPointerElement(e,t,i,c);u?d.updateProps(f,{shape:c},t):f.attr({shape:c})}var l=this,h=t.get("type"),u="cross"!==h;if("cross"===h)r("x",n,e.getAxis("y").getGlobalExtent()),r("y",n,e.getAxis("x").getGlobalExtent()),this._updateCrossText(e,n,t);else{var c=e.getAxis("x"===i?"y":"x"),f=c.getGlobalExtent();"cartesian2d"===e.type&&("line"===h?r:s)(i,n,f)}},_showSinglePointer:function(t,e,i,n){function o(i,n,o){var s=e.getAxis(),h=s.orient,u="horizontal"===h?a(n[0],o[0],n[0],o[1]):a(o[0],n[1],o[1],n[1]),c=r._getPointerElement(e,t,i,u);l?d.updateProps(c,{shape:u},t):c.attr({shape:u})}var r=this,s=t.get("type"),l="cross"!==s,h=e.getRect(),u=[h.y,h.y+h.height];o(i,n,u)},_showPolarPointer:function(t,e,i,n){function o(i,n,o){var r,s=e.pointToCoord(n);if("angle"===i){var h=e.coordToPoint([o[0],s[1]]),u=e.coordToPoint([o[1],s[1]]);r=a(h[0],h[1],u[0],u[1])}else r={cx:e.cx,cy:e.cy,r:s[0]};var c=l._getPointerElement(e,t,i,r);f?d.updateProps(c,{shape:r},t):c.attr({shape:r})}function s(i,n,a){var o,s=e.getAxis(i),h=s.getBandWidth(),u=e.pointToCoord(n),c=Math.PI/180;o="angle"===i?r(e.cx,e.cy,a[0],a[1],(-u[1]-h/2)*c,(-u[1]+h/2)*c):r(e.cx,e.cy,u[0]-h/2,u[0]+h/2,0,2*Math.PI);var p=l._getPointerElement(e,t,i,o);f?d.updateProps(p,{shape:o},t):p.attr({shape:o})}var l=this,h=t.get("type"),u=e.getAngleAxis(),c=e.getRadiusAxis(),f="cross"!==h;if("cross"===h)o("angle",n,c.getExtent()),o("radius",n,u.getExtent()),this._updateCrossText(e,n,t);else{var p=e.getAxis("radius"===i?"angle":"radius"),g=p.getExtent();("line"===h?o:s)(i,n,g)}},_updateCrossText:function(t,e,i){var n=i.getModel("crossStyle"),a=n.getModel("textStyle"),o=this._tooltipModel,r=this._crossText;r||(r=this._crossText=new d.Text({style:{textAlign:"left",textVerticalAlign:"bottom"}}),this.group.add(r));var s=t.pointToData(e),l=t.dimensions;s=f.map(s,function(e,i){var n=t.getAxis(l[i]);return e="category"===n.type||"time"===n.type?n.scale.getLabel(e):p.addCommas(e.toFixed(n.getPixelPrecision()))}),r.setStyle({fill:a.getTextColor()||n.get("color"),textFont:a.getFont(),text:s.join(", "),x:e[0]+5,y:e[1]-5}),r.z=o.get("z"),r.zlevel=o.get("zlevel")},_getPointerElement:function(t,e,i,n){var a=this._tooltipModel,o=a.get("z"),r=a.get("zlevel"),s=this._axisPointers,l=t.name;if(s[l]=s[l]||{},s[l][i])return s[l][i];var h=e.get("type"),u=e.getModel(h+"Style"),c="shadow"===h,f=u[c?"getAreaStyle":"getLineStyle"](),p="polar"===t.type?c?"Sector":"radius"===i?"Circle":"Line":c?"Rect":"Line";c?f.stroke=null:f.fill=null;var g=s[l][i]=new d[p]({style:f,z:o,zlevel:r,silent:!0,shape:n});return this.group.add(g),g},_dispatchAndShowSeriesTooltipContent:function(t,e,i,n,a){var o=this._tooltipModel,r=this._tooltipContent,s=t.getBaseAxis(),l=f.map(e,function(t){return{seriesIndex:t.seriesIndex,dataIndex:t.getAxisTooltipDataIndex?t.getAxisTooltipDataIndex(t.coordDimToDataDim(s.dim),n,s):t.getData().indexOfNearest(t.coordDimToDataDim(s.dim)[0],n["x"===s.dim||"radius"===s.dim?0:1])}}),u=this._lastHover,c=this._api;if(u.payloadBatch&&!a&&c.dispatchAction({type:"downplay",batch:u.payloadBatch}),a||(c.dispatchAction({type:"highlight",batch:l}),u.payloadBatch=l),c.dispatchAction({type:"showTip",dataIndex:l[0].dataIndex,seriesIndex:l[0].seriesIndex,from:this.uid}),s&&o.get("showContent")){var d,g=o.get("formatter"),m=o.get("position"),v=f.map(e,function(t,e){return t.getDataParams(l[e].dataIndex)});r.show(o);var y=l[0].dataIndex;if(!a){if(this._ticket="",g){if("string"==typeof g)d=p.formatTpl(g,v);else if("function"==typeof g){var x=this,_="axis_"+t.name+"_"+y,w=function(t,e){t===x._ticket&&(r.setContent(e),h(m,i[0],i[1],r,v,null,c))};x._ticket=_,d=g(v,_,w)}}else{var b=e[0].getData().getName(y);d=(b?b+"
":"")+f.map(e,function(t,e){return t.formatTooltip(l[e].dataIndex,!0)}).join("
")}r.setContent(d)}h(m,i[0],i[1],r,v,null,c)}},_showItemTooltipContent:function(t,e,i){var n=this._api,a=t.getData(),o=a.getItemModel(e),r=this._tooltipModel,s=this._tooltipContent,l=o.getModel("tooltip");if(l.parentModel?l.parentModel.parentModel=r:l.parentModel=this._tooltipModel,l.get("showContent")){var u,c=l.get("formatter"),d=l.get("position"),f=t.getDataParams(e);if(c){if("string"==typeof c)u=p.formatTpl(c,f);else if("function"==typeof c){var g=this,m="item_"+t.name+"_"+e,v=function(t,e){t===g._ticket&&(s.setContent(e),h(d,i.offsetX,i.offsetY,s,f,i.target,n))};g._ticket=m,u=c(f,m,v)}}else u=t.formatTooltip(e);s.show(l),s.setContent(u),h(d,i.offsetX,i.offsetY,s,f,i.target,n)}},_showAxisPointer:function(t){if(t){var e=this._axisPointers[t];e&&f.each(e,function(t){t.show()})}else this.group.eachChild(function(t){t.show()}),this.group.show()},_resetLastHover:function(){var t=this._lastHover;t.payloadBatch&&this._api.dispatchAction({type:"downplay",batch:t.payloadBatch}),this._lastHover={}},_hideAxisPointer:function(t){if(t){var e=this._axisPointers[t];e&&f.each(e,function(t){t.hide()})}else this.group.hide()},_hide:function(){this._hideAxisPointer(),this._resetLastHover(),this._alwaysShowContent||this._tooltipContent.hideLater(this._tooltipModel.get("hideDelay")),this._api.dispatchAction({type:"hideTip",from:this.uid})},dispose:function(t,e){if(!v.node){var i=e.getZr();this._tooltipContent.hide(),i.off("click",this._tryShow),i.off("mousemove",this._tryShow),i.off("mouseout",this._hide),e.off("showTip",this._manuallyShowTip),e.off("hideTip",this._manuallyHideTip)}}})},function(t,e,i){function n(t,e){var i=t.get("center"),n=t.get("radius"),a=e.getWidth(),o=e.getHeight(),r=s.parsePercent;this.cx=r(i[0],a),this.cy=r(i[1],o);var l=this.getRadiusAxis(),h=Math.min(a,o)/2;l.setExtent(0,r(n,h))}function a(t,e){var i=this,n=i.getAngleAxis(),a=i.getRadiusAxis();if(n.scale.setExtent(1/0,-(1/0)),a.scale.setExtent(1/0,-(1/0)),t.eachSeries(function(t){if(t.coordinateSystem===i){var e=t.getData();a.scale.unionExtent(e.getDataExtent("radius","category"!==a.type)),n.scale.unionExtent(e.getDataExtent("angle","category"!==n.type))}}),h(n,n.model),h(a,a.model),"category"===n.type&&!n.onBand){var o=n.getExtent(),r=360/n.scale.count();n.inverse?o[1]+=r:o[1]-=r,n.setExtent(o[0],o[1])}}function o(t,e){if(t.type=e.get("type"),t.scale=l.createScaleByModel(e),t.onBand=e.get("boundaryGap")&&"category"===t.type,"angleAxis"===e.mainType){var i=e.get("startAngle");t.inverse=e.get("inverse")^e.get("clockwise"),t.setExtent(i,i+(t.inverse?-360:360))}e.axis=t,t.model=e}var r=i(337),s=i(4),l=i(23),h=l.niceScaleExtent;i(338);var u={dimensions:r.prototype.dimensions,create:function(t,e){var i=[];return t.eachComponent("polar",function(t,s){var l=new r(s);l.resize=n,l.update=a;var h=l.getRadiusAxis(),u=l.getAngleAxis(),c=t.findAxisModel("radiusAxis"),d=t.findAxisModel("angleAxis");o(h,c),o(u,d),l.resize(t,e),i.push(l),t.coordinateSystem=l}),t.eachSeries(function(t){"polar"===t.get("coordinateSystem")&&(t.coordinateSystem=i[t.get("polarIndex")])}),i}};i(28).register("polar",u)},function(t,e){function i(){h=!1,r.length?l=r.concat(l):u=-1,l.length&&n()}function n(){if(!h){var t=setTimeout(i);h=!0;for(var e=l.length;e;){for(r=l,l=[];++u1)for(var i=1;i=0?parseFloat(t)/100*e:parseFloat(t):t},R=function(t,e,i){var n=r.parse(e);i=+i,isNaN(i)&&(i=1),n&&(t.color=D(n[0],n[1],n[2]),t.opacity=i*n[3])},O=function(t){var e=r.parse(t);return[D(e[0],e[1],e[2]),e[3]]},V=function(t,e,i){var n=e.fill;if(null!=n)if(n instanceof f){var a,o=0,r=[0,0],s=0,l=1,h=i.getBoundingRect(),u=h.width,c=h.height;if("linear"===n.type){a="gradient";var d=i.transform,p=[n.x*u,n.y*c],g=[n.x2*u,n.y2*c];d&&(w(p,p,d),w(g,g,d));var m=g[0]-p[0],v=g[1]-p[1];o=180*Math.atan2(m,v)/Math.PI,0>o&&(o+=360),1e-6>o&&(o=0)}else{a="gradientradial";var p=[n.x*u,n.y*c],d=i.transform,y=i.scale,x=u,b=c;r=[(p[0]-h.x)/x,(p[1]-h.y)/b],d&&w(p,p,d),x/=y[0]*M,b/=y[1]*M;var S=_(x,b);s=0/S,l=2*n.r/S-s}var A=n.colorStops.slice();A.sort(function(t,e){return t.offset-e.offset});for(var I=A.length,T=[],C=[],L=0;I>L;L++){var D=A[L],P=O(D.color);C.push(D.offset*l+s+" "+P[0]),0!==L&&L!==I-1||T.push(P)}if(I>=2){var k=T[0][0],z=T[1][0],E=T[0][1]*e.opacity,V=T[1][1]*e.opacity;t.type=a,t.method="none",t.focus="100%",t.angle=o,t.color=k,t.color2=z,t.colors=C.join(","),t.opacity=V,t.opacity2=E}"radial"===a&&(t.focusposition=r.join(","))}else R(t,n,e.opacity)},N=function(t,e){null!=e.lineJoin&&(t.joinstyle=e.lineJoin),null!=e.miterLimit&&(t.miterlimit=e.miterLimit*M),null!=e.lineCap&&(t.endcap=e.lineCap),null!=e.lineDash&&(t.dashstyle=e.lineDash.join(" ")),null==e.stroke||e.stroke instanceof f||R(t,e.stroke,e.opacity)},B=function(t,e,i,n){var a="fill"==e,o=t.getElementsByTagName(e)[0];null!=i[e]&&"none"!==i[e]&&(a||!a&&i.lineWidth)?(t[a?"filled":"stroked"]="true",i[e]instanceof f&&k(t,o),o||(o=p.createNode(e)),a?V(o,i,n):N(o,i),P(t,o)):(t[a?"filled":"stroked"]="false",k(t,o))},G=[[],[],[]],F=function(t,e){var i,n,a,r,s,l,h=o.M,u=o.C,c=o.L,d=o.A,f=o.Q,p=[];for(r=0;r0){p.push(n);for(var U=0;i>U;U++){var X=G[U];e&&w(X,X,e),p.push(g(X[0]*M-A),b,g(X[1]*M-A),i-1>U?b:"")}}}return p.join("")};d.prototype.brush=function(t){var e=this.style,i=this._vmlEl;i||(i=p.createNode("shape"),C(i),this._vmlEl=i),B(i,"fill",e,this),B(i,"stroke",e,this);var n=this.transform,a=null!=n,o=i.getElementsByTagName("stroke")[0];if(o){var r=e.lineWidth;if(a&&!e.strokeNoScale){var s=n[0]*n[3]-n[1]*n[2];r*=m(v(s))}o.weight=r+"px"}var l=this.path;this.__dirtyPath&&(l.beginPath(),this.buildPath(l,this.shape),this.__dirtyPath=!1),i.path=F(l.data,this.transform),i.style.zIndex=z(this.zlevel,this.z,this.z2),P(t,i),e.text&&this.drawRectText(t,this.getBoundingRect())},d.prototype.onRemoveFromStorage=function(t){k(t,this._vmlEl),this.removeRectText(t)},d.prototype.onAddToStorage=function(t){P(t,this._vmlEl),this.appendRectText(t)};var W=function(t){return"object"==typeof t&&t.tagName&&"IMG"===t.tagName.toUpperCase()};u.prototype.brush=function(t){var e,i,n=this.style,a=n.image;if(W(a)){var o=a.src;if(o===this._imageSrc)e=this._imageWidth,i=this._imageHeight;else{var r=a.runtimeStyle,s=r.width,l=r.height;r.width="auto",r.height="auto",e=a.width,i=a.height,r.width=s,r.height=l,this._imageSrc=o,this._imageWidth=e,this._imageHeight=i}a=o}else a===this._imageSrc&&(e=this._imageWidth,i=this._imageHeight);if(a){var h=n.x||0,u=n.y||0,c=n.width,d=n.height,f=n.sWidth,v=n.sHeight,y=n.sx||0,x=n.sy||0,M=f&&v,A=this._vmlEl;A||(A=p.doc.createElement("div"),C(A),this._vmlEl=A);var I,T=A.style,L=!1,D=1,k=1;if(this.transform&&(I=this.transform,D=m(I[0]*I[0]+I[1]*I[1]),k=m(I[2]*I[2]+I[3]*I[3]),L=I[1]||I[2]),L){var E=[h,u],R=[h+c,u],O=[h,u+d],V=[h+c,u+d];w(E,E,I),w(R,R,I),w(O,O,I),w(V,V,I);var N=_(E[0],R[0],O[0],V[0]),B=_(E[1],R[1],O[1],V[1]),G=[];G.push("M11=",I[0]/D,b,"M12=",I[2]/k,b,"M21=",I[1]/D,b,"M22=",I[3]/k,b,"Dx=",g(h*D+I[4]),b,"Dy=",g(u*k+I[5])),T.padding="0 "+g(N)+"px "+g(B)+"px 0",T.filter=S+".Matrix("+G.join("")+", SizingMethod=clip)"}else I&&(h=h*D+I[4],u=u*k+I[5]),T.filter="",T.left=g(h)+"px",T.top=g(u)+"px";var F=this._imageEl,H=this._cropEl;F||(F=p.doc.createElement("div"),this._imageEl=F);var Z=F.style;if(M){if(e&&i)Z.width=g(D*e*c/f)+"px",Z.height=g(k*i*d/v)+"px";else{var q=new Image,j=this;q.onload=function(){q.onload=null,e=q.width,i=q.height,Z.width=g(D*e*c/f)+"px",Z.height=g(k*i*d/v)+"px",j._imageWidth=e,j._imageHeight=i,j._imageSrc=a},q.src=a}H||(H=p.doc.createElement("div"),H.style.overflow="hidden",this._cropEl=H);var U=H.style;U.width=g((c+y*c/f)*D),U.height=g((d+x*d/v)*k),U.filter=S+".Matrix(Dx="+-y*c/f*D+",Dy="+-x*d/v*k+")",H.parentNode||A.appendChild(H),F.parentNode!=H&&H.appendChild(F)}else Z.width=g(D*c)+"px",Z.height=g(k*d)+"px",A.appendChild(F),H&&H.parentNode&&(A.removeChild(H),this._cropEl=null);var X="",Y=n.opacity;1>Y&&(X+=".Alpha(opacity="+g(100*Y)+") "),X+=S+".AlphaImageLoader(src="+a+", SizingMethod=scale)",Z.filter=X,A.style.zIndex=z(this.zlevel,this.z,this.z2),P(t,A),n.text&&this.drawRectText(t,this.getBoundingRect())}},u.prototype.onRemoveFromStorage=function(t){k(t,this._vmlEl),this._vmlEl=null,this._cropEl=null,this._imageEl=null,this.removeRectText(t)},u.prototype.onAddToStorage=function(t){P(t,this._vmlEl),this.appendRectText(t)};var H,Z="normal",q={},j=0,U=100,X=document.createElement("div"),Y=function(t){var e=q[t];if(!e){j>U&&(j=0,q={});var i,n=X.style;try{n.font=t,i=n.fontFamily.split(",")[0]}catch(a){}e={style:n.fontStyle||Z,variant:n.fontVariant||Z,weight:n.fontWeight||Z,size:0|parseFloat(n.fontSize||12),family:i||"Microsoft YaHei"},q[t]=e,j++}return e};s.measureText=function(t,e){var i=p.doc;H||(H=i.createElement("div"),H.style.cssText="position:absolute;top:-20000px;left:0;padding:0;margin:0;border:none;white-space:pre;",p.doc.body.appendChild(H));try{H.style.font=e}catch(n){}return H.innerHTML="",H.appendChild(i.createTextNode(t)),{width:H.offsetWidth}};for(var K=new a,Q=function(t,e,i,n){var a=this.style,o=a.text;if(o){var r,l,h=a.textAlign,u=Y(a.textFont),c=u.style+" "+u.variant+" "+u.weight+" "+u.size+'px "'+u.family+'"',d=a.textBaseline,f=a.textVerticalAlign;i=i||s.getBoundingRect(o,c,h,d);var m=this.transform;if(m&&!n&&(K.copy(e),K.applyTransform(m),e=K),n)r=e.x,l=e.y;else{var v=a.textPosition,y=a.textDistance;if(v instanceof Array)r=e.x+E(v[0],e.width),l=e.y+E(v[1],e.height),h=h||"left",d=d||"top";else{var x=s.adjustTextPositionOnRect(v,e,i,y);r=x.x,l=x.y,h=h||x.textAlign,d=d||x.textBaseline}}if(f){switch(f){case"middle":l-=i.height/2;break;case"bottom":l-=i.height}d="top"}var _=u.size;switch(d){case"hanging":case"top":l+=_/1.75;break;case"middle":break;default:l-=_/2.25}switch(h){case"left":break;case"center":r-=i.width/2;break;case"right":r-=i.width}var S,M,A,I=p.createNode,T=this._textVmlEl;T?(A=T.firstChild,S=A.nextSibling,M=S.nextSibling):(T=I("line"),S=I("path"),M=I("textpath"),A=I("skew"),M.style["v-text-align"]="left",C(T),S.textpathok=!0,M.on=!0,T.from="0 0",T.to="1000 0.05",P(T,A),P(T,S),P(T,M),this._textVmlEl=T);var D=[r,l],k=T.style;m&&n?(w(D,D,m),A.on=!0,A.matrix=m[0].toFixed(3)+b+m[2].toFixed(3)+b+m[1].toFixed(3)+b+m[3].toFixed(3)+",0,0",A.offset=(g(D[0])||0)+","+(g(D[1])||0),A.origin="0 0",k.left="0px",k.top="0px"):(A.on=!1,k.left=g(r)+"px",k.top=g(l)+"px"),M.string=L(o);try{M.style.font=c}catch(R){}B(T,"fill",{fill:n?a.fill:a.textFill,opacity:a.opacity},this),B(T,"stroke",{stroke:n?a.stroke:a.textStroke,opacity:a.opacity,lineDash:a.lineDash},this),T.style.zIndex=z(this.zlevel,this.z,this.z2),P(t,T)}},$=function(t){k(t,this._textVmlEl),this._textVmlEl=null},J=function(t){P(t,this._textVmlEl)},tt=[l,h,u,d,c],et=0;et0&&(e=[l,h]),t.setLayout([n,a,e])})}}},function(t,e){t.exports=function(t){var e=t.coordinateSystem;if(!e||"view"===e.type){var i=t.getGraph();i.eachNode(function(t){var e=t.getModel();t.setLayout([+e.get("x"),+e.get("y")])}),i.eachEdge(function(t){var e,i=t.getModel().get("lineStyle.normal.curveness")||0,n=t.node1.getLayout(),a=t.node2.getLayout();i>0&&(e=[(n[0]+a[0])/2-(n[1]-a[1])*i,(n[1]+a[1])/2-(a[0]-n[0])*i]),t.setLayout([n,a,e])})}}},function(t,e,i){var n=i(14),a=i(343),o=i(223),r=i(31),s=i(1);t.exports=function(t,e,i,l){for(var h=new a(l),u=0;u "+o[0]:o[0]+" - "+o[1]:o},resetTargetSeries:function(t,e){var i=this.option,n=this._autoSeriesIndex=null==(e?i:t).seriesIndex;i.seriesIndex=n?[]:r.normalizeToArray(i.seriesIndex),n&&this.ecModel.eachSeries(function(t,e){var n=t.getData();"list"===n.type&&i.seriesIndex.push(e)})},resetExtent:function(){var t=this.option,e=p([t.min,t.max]);this._dataExtent=e},getDataDimension:function(t){var e=this.option.dimension;return null!=e?e:t.dimensions.length-1},getExtent:function(){return this._dataExtent.slice()},resetVisual:function(t){function e(e,n){f(this.stateList,function(a){var o=n[a]||(n[a]={}),r=this.option[e][a]||{};f(r,function(e,n){if(l.isValidType(n)){var r={type:n,dataExtent:i,visual:e};t&&t.call(this,r,a),o[n]=new l(r)}},this)},this)}var i=this.getExtent();e.call(this,"controller",this.controllerVisuals),e.call(this,"target",this.targetVisuals)},completeVisualOption:function(){function t(t){d(a.color)&&!t.inRange&&(t.inRange={color:a.color.slice().reverse()}),f(this.stateList,function(e){ +var i=t[e];if(n.isString(i)){var a=s.get(i,"active",p);a?(t[e]={},t[e][i]=a):delete t[e]}},this)}function e(t,e,i){var n=t[e],a=t[i];n&&!a&&(a=t[i]={},f(n,function(t,e){var i=s.get(e,"inactive",p);l.isValidType(e)&&i&&(a[e]=i)}))}function i(t){var e=(t.inRange||{}).symbol||(t.outOfRange||{}).symbol,i=(t.inRange||{}).symbolSize||(t.outOfRange||{}).symbolSize,a=this.get("inactiveColor");f(this.stateList,function(o){var r=this.itemSize,s=t[o];s||(s=t[o]={color:p?a:[a]}),s.symbol||(s.symbol=e&&n.clone(e)||(p?"roundRect":["roundRect"])),s.symbolSize||(s.symbolSize=i&&n.clone(i)||(p?r[0]:[r[0],r[0]])),s.symbol=h(s.symbol,function(t){return"none"===t||"square"===t?"roundRect":t});var l=s.symbolSize;if(l){var c=-(1/0);u(l,function(t){t>c&&(c=t)}),s.symbolSize=h(l,function(t){return g(t,[0,c],[0,r[0]],!0)})}},this)}var a=this.option,o={inRange:a.inRange,outOfRange:a.outOfRange},r=a.target||(a.target={}),c=a.controller||(a.controller={});n.merge(r,o),n.merge(c,o);var p=this.isCategory();t.call(this,r),t.call(this,c),e.call(this,r,"inRange","outOfRange"),e.call(this,r,"outOfRange","inRange"),i.call(this,c)},eachTargetSeries:function(t,e){n.each(this.option.seriesIndex,function(i){t.call(e,this.ecModel.getSeriesByIndex(i))},this)},isCategory:function(){return!!this.option.categories},resetItemSize:function(){this.itemSize=[parseFloat(this.get("itemWidth")),parseFloat(this.get("itemHeight"))]},setSelected:n.noop,getValueState:n.noop});t.exports=m},function(t,e,i){var n=i(2),a=i(1),o=i(3),r=i(9),s=i(11),l=i(73);t.exports=n.extendComponentView({type:"visualMap",autoPositionValues:{left:1,right:1,top:1,bottom:1},init:function(t,e){this.ecModel=t,this.api=e,this.visualMapModel,this._updatableShapes={}},render:function(t,e,i,n){return this.visualMapModel=t,t.get("show")===!1?void this.group.removeAll():void this.doRender.apply(this,arguments)},renderBackground:function(t){var e=this.visualMapModel,i=r.normalizeCssArray(e.get("padding")||0),n=t.getBoundingRect();t.add(new o.Rect({z2:-1,silent:!0,shape:{x:n.x-i[3],y:n.y-i[0],width:n.width+i[3]+i[1],height:n.height+i[0]+i[2]},style:{fill:e.get("backgroundColor"),stroke:e.get("borderColor"),lineWidth:e.get("borderWidth")}}))},getControllerVisual:function(t,e,i){function n(t){return c[t]}function o(t,e){c[t]=e}var r=this.visualMapModel,s=a.isArray(t);if(s&&(!e||"color"!==i))throw new Error(t);var h=r.controllerVisuals[e||r.getValueState(t)],u=r.get("contentColor"),c={symbol:r.get("itemSymbol"),color:s?[{color:u,offset:0},{color:u,offset:1}]:u},d=l.prepareVisualTypes(h);return a.each(d,function(e){var a=h[e];i&&!l.isInVisualCluster(e,i)||a&&a.applyVisual(t,n,o)}),c},positionGroup:function(t){var e=this.visualMapModel,i=this.api;s.positionGroup(t,e.getBoxLayoutParams(),{width:i.getWidth(),height:i.getHeight()})},doRender:a.noop})},function(t,e,i){var n=i(11),a={getItemAlign:function(t,e,i){var a=t.option,o=a.align;if(null!=o&&"auto"!==o)return o;for(var r={width:e.getWidth(),height:e.getHeight()},s="horizontal"===a.orient?1:0,l=[["left","right","width"],["top","bottom","height"]],h=l[s],u=[0,null,10],c={},d=0;3>d;d++)c[l[1-s][d]]=u[d],c[h[d]]=2===d?i[0]:a[h[d]];var f=[["x","width",3],["y","height",0]][s],p=n.getLayoutRect(c,r,a.padding);return h[(p.margin[f[2]]||0)+p[f[0]]+.5*p[f[1]]<.5*r[f[1]]?0:1]}};t.exports=a},function(t,e,i){function n(t,e){return t&&t.hasOwnProperty&&t.hasOwnProperty(e)}var a=i(1),o=a.each;t.exports=function(t){var e=t&&t.visualMap;a.isArray(e)||(e=e?[e]:[]),o(e,function(t){if(t){n(t,"splitList")&&!n(t,"pieces")&&(t.pieces=t.splitList,delete t.splitList);var e=t.pieces;e&&a.isArray(e)&&o(e,function(t){a.isObject(t)&&(n(t,"start")&&!n(t,"min")&&(t.min=t.start),n(t,"end")&&!n(t,"max")&&(t.max=t.end))})}})}},function(t,e,i){i(10).registerSubTypeDefaulter("visualMap",function(t){return t.categories||(t.pieces?t.pieces.length>0:t.splitNumber>0)&&!t.calculable?"piecewise":"continuous"})},function(t,e,i){function n(t,e){var i=t.targetVisuals,n={};r.each(["inRange","outOfRange"],function(t){var e=o.prepareVisualTypes(i[t]);n[t]=e}),t.eachTargetSeries(function(e){function a(t){return s.getItemVisual(r,t)}function o(t,e){s.setItemVisual(r,t,e)}var r,s=e.getData(),l=t.getDataDimension(s);s.each([l],function(e,s){r=s;for(var l=t.getValueState(e),h=i[l],u=n[l],c=0,d=u.length;d>c;c++){var f=u[c];h[f]&&h[f].applyVisual(e,a,o)}})})}var a=i(2),o=i(73),r=i(1);a.registerVisualCoding("component",function(t){t.eachComponent("visualMap",function(e){n(e,t)})})},function(t,e,i){var n=i(2),a={type:"selectDataRange",event:"dataRangeSelected",update:"update"};n.registerAction(a,function(t,e){e.eachComponent({mainType:"visualMap",query:t},function(e){e.setSelected(t.selected)})})},function(t,e,i){function n(){s.call(this)}function a(t){this.name=t,s.call(this),this._roamTransform=new n,this._viewTransform=new n}var o=i(5),r=i(19),s=i(77),l=i(1),h=i(8),u=o.applyTransform;l.mixin(n,s),a.prototype={constructor:a,type:"view",dimensions:["x","y"],setBoundingRect:function(t,e,i,n){return this._rect=new h(t,e,i,n),this._rect},getBoundingRect:function(){return this._rect},setViewRect:function(t,e,i,n){this.transformTo(t,e,i,n),this._viewRect=new h(t,e,i,n)},transformTo:function(t,e,i,n){var a=this.getBoundingRect(),o=this._viewTransform;o.transform=a.calculateTransform(new h(t,e,i,n)),o.decomposeTransform(),this._updateTransform()},setPan:function(t,e){this._roamTransform.position=[t,e],this._updateTransform()},setZoom:function(t){this._roamTransform.scale=[t,t],this._updateTransform()},getRoamTransform:function(){return this._roamTransform.transform},_updateTransform:function(){var t=this._roamTransform,e=this._viewTransform;e.parent=t,t.updateTransform(),e.updateTransform(),e.transform&&r.copy(this.transform||(this.transform=[]),e.transform),this.decomposeTransform()},getViewRect:function(){return this._viewRect},dataToPoint:function(t){var e=this.transform;return e?u([],t,e):[t[0],t[1]]},pointToData:function(t){var e=this.invTransform;return e?u([],t,e):[t[0],t[1]]}},l.mixin(a,s),t.exports=a},function(t,e,i){function n(t,e,i){if(this.name=t,this.contours=e,i)i=[i[0],i[1]];else{var n=this.getBoundingRect();i=[n.x+n.width/2,n.y+n.height/2]}this.center=i}var a=i(348),o=i(8),r=i(64),s=i(5);n.prototype={constructor:n,getBoundingRect:function(){var t=this._rect;if(t)return t;for(var e=Number.MAX_VALUE,i=[e,e],n=[-e,-e],a=[],l=[],h=this.contours,u=0;un;n++)if(a.contain(i[n],t[0],t[1]))return!0;return!1},transformTo:function(t,e,i,n){var a=this.getBoundingRect(),r=a.width/a.height;i?n||(n=i/r):i=r*n;for(var l=new o(t,e,i,n),h=a.calculateTransform(l),u=this.contours,c=0;ca&&(a=i.length,i[a]=n,e[a]={axis:n,seriesModels:[]}),e[a].seriesModels.push(t)}),e}function a(t){var e,i,n=t.axis,a=t.seriesModels,o=a.length,s=t.boxWidthList=[],u=t.boxOffsetList=[],c=[];if("category"===n.type)i=n.getBandWidth();else{var d=0;h(a,function(t){d=Math.max(d,t.getData().count())}),e=n.getExtent(),Math.abs(e[1]-e[0])/d}h(a,function(t){var e=t.get("boxWidth");r.isArray(e)||(e=[e,e]),c.push([l(e[0],i)||0,l(e[1],i)||0])});var f=.8*i-2,p=f/o*.3,g=(f-p*(o-1))/o,m=g/2-f/2;h(a,function(t,e){u.push(m),m+=p+g,s.push(Math.min(Math.max(g,c[e][0]),c[e][1]))})}function o(t,e,i){var n=t.coordinateSystem,a=t.getData(),o=t.dimensions,r=t.get("layout"),s=i/2;a.each(o,function(){function t(t){var i=[];i[f]=c,i[p]=t;var a;return isNaN(c)||isNaN(t)?a=[NaN,NaN]:(a=n.dataToPoint(i),a[f]+=e),a}function i(t,e){var i=t.slice(),n=t.slice();i[f]+=s,n[f]-=s,e?x.push(i,n):x.push(n,i)}function l(t){var e=[t.slice(),t.slice()];e[0][f]-=s,e[1][f]+=s,y.push(e)}var h=arguments,u=o.length,c=h[0],d=h[u],f="horizontal"===r?0:1,p=1-f,g=t(h[3]),m=t(h[1]),v=t(h[5]),y=[[m,t(h[2])],[v,t(h[4])]];l(m),l(v),l(g);var x=[];i(y[0][1],0),i(y[1][1],1),a.setItemLayout(d,{chartLayout:r,initBaseline:g[p],median:g,bodyEnds:x,whiskerEnds:y})})}var r=i(1),s=i(4),l=s.parsePercent,h=r.each;t.exports=function(t,e){var i=n(t);h(i,function(t){var e=t.seriesModels;e.length&&(a(t),h(e,function(e,i){o(e,t.boxOffsetList[i],t.boxWidthList[i])}))})}},function(t,e){var i=["itemStyle","normal","borderColor"];t.exports=function(t,e){var n=t.get("color");t.eachRawSeriesByType("boxplot",function(e){var a=n[e.seriesIndex%n.length],o=e.getData();o.setVisual({legendSymbol:"roundRect",color:e.get(i)||a}),t.isSeriesFiltered(e)||o.each(function(t){var e=o.getItemModel(t);o.setItemVisual(t,{color:e.get(i,!0)})})})}},function(t,e,i){var n=i(2);i(230),i(231),n.registerPreprocessor(i(234)),n.registerVisualCoding("chart",i(233)),n.registerLayout(i(232))},function(t,e,i){"use strict";var n=i(1),a=i(13),o=i(158),r=i(9),s=r.encodeHTML,l=r.addCommas,h=a.extend({type:"series.candlestick",dependencies:["xAxis","yAxis","grid"],valueDimensions:["open","close","lowest","highest"],dimensions:null,defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,hoverAnimation:!0,xAxisIndex:0,yAxisIndex:0,layout:null,itemStyle:{normal:{color:"#c23531",color0:"#314656",borderWidth:1,borderColor:"#c23531",borderColor0:"#314656"},emphasis:{borderWidth:2}},animationUpdate:!1,animationEasing:"linear",animationDuration:300},getShadowDim:function(){return"open"},formatTooltip:function(t,e){var i=n.map(this.valueDimensions,function(e){return e+": "+l(this._data.get(e,t))},this);return s(this.name)+"
"+i.join("
")}});n.mixin(h,o.seriesModelMixin,!0),t.exports=h},function(t,e,i){"use strict";function n(t,e,i){var n=e.getItemModel(i),a=n.getModel(h),o=e.getItemVisual(i,"color"),s=e.getItemVisual(i,"borderColor"),l=a.getItemStyle(["color","color0","borderColor","borderColor0"]),c=t.childAt(t.whiskerIndex);c.style.set(l),c.style.stroke=s,c.dirty();var d=t.childAt(t.bodyIndex);d.style.set(l),d.style.fill=o,d.style.stroke=s,d.dirty();var f=n.getModel(u).getItemStyle();r.setHoverStyle(t,f)}var a=i(1),o=i(25),r=i(3),s=i(158),l=o.extend({type:"candlestick",getStyleUpdater:function(){return n}});a.mixin(l,s.viewMixin,!0);var h=["itemStyle","normal"],u=["itemStyle","emphasis"];t.exports=l},function(t,e){function i(t,e){var i,r=t.getBaseAxis(),s="category"===r.type?r.getBandWidth():(i=r.getExtent(),Math.abs(i[1]-i[0])/e.count());return s/2-2>a?s/2-2:s-a>o?a:Math.max(s-o,n)}var n=2,a=5,o=4;t.exports=function(t,e){t.eachSeriesByType("candlestick",function(t){var e=t.coordinateSystem,n=t.getData(),a=t.dimensions,o=t.get("layout"),r=i(t,n);n.each(a,function(){function t(t){var i=[];return i[c]=h,i[d]=t,isNaN(h)||isNaN(t)?[NaN,NaN]:e.dataToPoint(i)}function i(t,e){var i=t.slice(),n=t.slice();i[c]+=r/2,n[c]-=r/2,e?M.push(i,n):M.push(n,i)}var s=arguments,l=a.length,h=s[0],u=s[l],c="horizontal"===o?0:1,d=1-c,f=s[1],p=s[2],g=s[3],m=s[4],v=Math.min(f,p),y=Math.max(f,p),x=t(v),_=t(y),w=t(g),b=t(m),S=[[b,_],[w,x]],M=[];i(_,0),i(x,1),n.setItemLayout(u,{chartLayout:o,sign:f>p?-1:p>f?1:0,initBaseline:f>p?_[d]:x[d],bodyEnds:M,whiskerEnds:S})},!0)})}},function(t,e){var i=["itemStyle","normal","borderColor"],n=["itemStyle","normal","borderColor0"],a=["itemStyle","normal","color"],o=["itemStyle","normal","color0"];t.exports=function(t,e){t.eachRawSeriesByType("candlestick",function(e){var r=e.getData();r.setVisual({legendSymbol:"roundRect"}),t.isSeriesFiltered(e)||r.each(function(t){var e=r.getItemModel(t),s=r.getItemLayout(t).sign;r.setItemVisual(t,{color:e.get(s>0?a:o),borderColor:e.get(s>0?i:n)})})})}},function(t,e,i){var n=i(1);t.exports=function(t){t&&n.isArray(t.series)&&n.each(t.series,function(t){n.isObject(t)&&"k"===t.type&&(t.type="candlestick")})}},function(t,e,i){var n=i(1),a=i(2);i(236),i(237),a.registerVisualCoding("chart",n.curry(i(44),"effectScatter","circle",null)),a.registerLayout(n.curry(i(53),"effectScatter"))},function(t,e,i){"use strict";var n=i(36),a=i(13);t.exports=a.extend({type:"series.effectScatter",dependencies:["grid","polar"],getInitialData:function(t,e){var i=n(t.data,this,e);return i},defaultOption:{coordinateSystem:"cartesian2d",zlevel:0,z:2,legendHoverLink:!0,effectType:"ripple",showEffectOn:"render",rippleEffect:{period:4,scale:2.5,brushType:"fill"},xAxisIndex:0,yAxisIndex:0,polarIndex:0,geoIndex:0,symbolSize:10}})},function(t,e,i){var n=i(38),a=i(262);i(2).extendChartView({type:"effectScatter",init:function(){this._symbolDraw=new n(a)},render:function(t,e,i){var n=t.getData(),a=this._symbolDraw;a.updateData(n),this.group.add(a.group)},updateLayout:function(){this._symbolDraw.updateLayout()},remove:function(t,e){this._symbolDraw&&this._symbolDraw.remove(e)}})},function(t,e,i){var n=i(1),a=i(2);i(239),i(240),a.registerVisualCoding("chart",n.curry(i(63),"funnel")),a.registerLayout(i(241)),a.registerProcessor("filter",n.curry(i(62),"funnel"))},function(t,e,i){"use strict";var n=i(14),a=i(7),o=i(31),r=i(2).extendSeriesModel({type:"series.funnel",init:function(t){r.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._dataBeforeProcessed},this._defaultLabelLine(t)},getInitialData:function(t,e){var i=o(["value"],t.data),a=new n(i,this);return a.initData(t.data),a},_defaultLabelLine:function(t){a.defaultEmphasis(t.labelLine,["show"]);var e=t.labelLine.normal,i=t.labelLine.emphasis;e.show=e.show&&t.label.normal.show,i.show=i.show&&t.label.emphasis.show},defaultOption:{zlevel:0,z:2,legendHoverLink:!0,left:80,top:60,right:80,bottom:60,minSize:"0%",maxSize:"100%",sort:"descending",gap:0,funnelAlign:"center",label:{normal:{show:!0,position:"outer"},emphasis:{show:!0}},labelLine:{normal:{show:!0,length:20,lineStyle:{width:1,type:"solid"}},emphasis:{}},itemStyle:{normal:{borderColor:"#fff",borderWidth:1},emphasis:{}}}});t.exports=r},function(t,e,i){function n(t,e){function i(){r.ignore=r.hoverIgnore,s.ignore=s.hoverIgnore}function n(){r.ignore=r.normalIgnore,s.ignore=s.normalIgnore}o.Group.call(this);var a=new o.Polygon,r=new o.Polyline,s=new o.Text;this.add(a),this.add(r),this.add(s),this.updateData(t,e,!0),this.on("emphasis",i).on("normal",n).on("mouseover",i).on("mouseout",n)}function a(t,e,i,n){var a=n.getModel("textStyle"),o=n.get("position"),s="inside"===o||"inner"===o||"center"===o;return{fill:a.getTextColor()||(s?"#fff":t.getItemVisual(e,"color")),textFont:a.getFont(),text:r.retrieve(t.hostModel.getFormattedLabel(e,i),t.getName(e))}}var o=i(3),r=i(1),s=n.prototype,l=["itemStyle","normal","opacity"];s.updateData=function(t,e,i){var n=this.childAt(0),a=t.hostModel,s=t.getItemModel(e),h=t.getItemLayout(e),u=t.getItemModel(e).get(l);u=null==u?1:u,i?(n.setShape({points:h.points}),n.setStyle({opacity:0}),o.updateProps(n,{style:{opacity:u}},a)):o.initProps(n,{shape:{points:h.points}},a);var c=s.getModel("itemStyle"),d=t.getItemVisual(e,"color");n.setStyle(r.defaults({fill:d},c.getModel("normal").getItemStyle())),n.hoverStyle=c.getModel("emphasis").getItemStyle(),this._updateLabel(t,e),o.setHoverStyle(this)},s._updateLabel=function(t,e){var i=this.childAt(1),n=this.childAt(2),r=t.hostModel,s=t.getItemModel(e),l=t.getItemLayout(e),h=l.label,u=t.getItemVisual(e,"color");o.updateProps(i,{shape:{points:h.linePoints||h.linePoints}},r),o.updateProps(n,{style:{x:h.x,y:h.y}},r),n.attr({style:{textAlign:h.textAlign,textVerticalAlign:h.verticalAlign,textFont:h.font},rotation:h.rotation,origin:[h.x,h.y],z2:10});var c=s.getModel("label.normal"),d=s.getModel("label.emphasis"),f=s.getModel("labelLine.normal"),p=s.getModel("labelLine.emphasis");n.setStyle(a(t,e,"normal",c)),n.ignore=n.normalIgnore=!c.get("show"),n.hoverIgnore=!d.get("show"),i.ignore=i.normalIgnore=!f.get("show"),i.hoverIgnore=!p.get("show"),i.setStyle({stroke:u}),i.setStyle(f.getModel("lineStyle").getLineStyle()),n.hoverStyle=a(t,e,"emphasis",d),i.hoverStyle=p.getModel("lineStyle").getLineStyle()},r.inherits(n,o.Group);var h=i(25).extend({type:"funnel",render:function(t,e,i){var a=t.getData(),o=this._data,r=this.group;a.diff(o).add(function(t){var e=new n(a,t);a.setItemGraphicEl(t,e),r.add(e)}).update(function(t,e){var i=o.getItemGraphicEl(e);i.updateData(a,t),r.add(i),a.setItemGraphicEl(t,i)}).remove(function(t){var e=o.getItemGraphicEl(t);r.remove(e)}).execute(),this._data=a},remove:function(){this.group.removeAll(),this._data=null}});t.exports=h},function(t,e,i){function n(t,e){return r.getLayoutRect(t.getBoxLayoutParams(),{width:e.getWidth(),height:e.getHeight()})}function a(t,e){for(var i=t.mapArray("value",function(t){return t}),n=[],a="ascending"===e,o=0,r=t.count();r>o;o++)n[o]=o;return n.sort(function(t,e){return a?i[t]-i[e]:i[e]-i[t]}),n}function o(t){t.each(function(e){var i,n,a,o,r=t.getItemModel(e),s=r.getModel("label.normal"),l=s.get("position"),h=r.getModel("labelLine.normal"),u=t.getItemLayout(e),c=u.points,d="inner"===l||"inside"===l||"center"===l;if(d)n=(c[0][0]+c[1][0]+c[2][0]+c[3][0])/4,a=(c[0][1]+c[1][1]+c[2][1]+c[3][1])/4,i="center",o=[[n,a],[n,a]];else{var f,p,g,m=h.get("length");"left"===l?(f=(c[3][0]+c[0][0])/2,p=(c[3][1]+c[0][1])/2,g=f-m,n=g-5,i="right"):(f=(c[1][0]+c[2][0])/2,p=(c[1][1]+c[2][1])/2,g=f+m,n=g+5,i="left");var v=p;o=[[f,p],[g,v]],a=v}u.label={linePoints:o,x:n,y:a,verticalAlign:"middle",textAlign:i,inside:d}})}var r=i(11),s=i(4),l=s.parsePercent;t.exports=function(t,e){t.eachSeriesByType("funnel",function(t){var i=t.getData(),r=t.get("sort"),h=n(t,e),u=a(i,r),c=[l(t.get("minSize"),h.width),l(t.get("maxSize"),h.width)],d=i.getDataExtent("value"),f=t.get("min"),p=t.get("max");null==f&&(f=Math.min(d[0],0)),null==p&&(p=d[1]);var g=t.get("funnelAlign"),m=t.get("gap"),v=(h.height-m*(i.count()-1))/i.count(),y=h.y,x=function(t,e){var n,a=i.get("value",t)||0,o=s.linearMap(a,[f,p],c,!0);switch(g){case"left":n=h.x;break;case"center":n=h.x+(h.width-o)/2;break;case"right":n=h.x+h.width-o}return[[n,e],[n+o,e]]};"ascending"===r&&(v=-v,m=-m,y+=h.height,u=u.reverse());for(var _=0;_=t)return n[0][1];for(var e=0;e=t&&(0===e?0:n[e-1][0])=P;P++){var k=Math.cos(A),z=Math.sin(A);if(y.get("show")){var E=new r.Line({shape:{x1:k*g+f,y1:z*g+p,x2:k*(g-S)+f,y2:z*(g-S)+p},style:C,silent:!0});"auto"===C.stroke&&E.setStyle({stroke:n(P/w)}),d.add(E)}if(_.get("show")){var R=a(s.round(P/w*(v-m)+m),_.get("formatter")),O=new r.Text({style:{text:R,x:k*(g-S-5)+f,y:z*(g-S-5)+p,fill:D.getTextColor(),textFont:D.getFont(),textVerticalAlign:-.4>z?"top":z>.4?"bottom":"middle",textAlign:-.4>k?"left":k>.4?"right":"center"},silent:!0});"auto"===O.style.fill&&O.setStyle({fill:n(P/w)}),d.add(O)}if(x.get("show")&&P!==w){for(var V=0;b>=V;V++){var k=Math.cos(A),z=Math.sin(A),N=new r.Line({shape:{x1:k*g+f,y1:z*g+p,x2:k*(g-M)+f,y2:z*(g-M)+p},silent:!0,style:L});"auto"===L.stroke&&N.setStyle({stroke:n((P+V/b)/w)}),d.add(N),A+=T}A-=T}else A+=I}},_renderPointer:function(t,e,i,n,a,h,u,c){var d=s.linearMap,f=[+t.get("min"),+t.get("max")],p=[h,u];c||(p=p.reverse());var g=t.getData(),m=this._data,v=this.group;g.diff(m).add(function(e){var i=new o({shape:{angle:h}});r.updateProps(i,{shape:{angle:d(g.get("value",e),f,p)}},t),v.add(i),g.setItemGraphicEl(e,i)}).update(function(e,i){var n=m.getItemGraphicEl(i);r.updateProps(n,{shape:{angle:d(g.get("value",e),f,p)}},t),v.add(n),g.setItemGraphicEl(e,n)}).remove(function(t){var e=m.getItemGraphicEl(t);v.remove(e)}).execute(),g.eachItemGraphicEl(function(t,e){var i=g.getItemModel(e),o=i.getModel("pointer");t.attr({shape:{x:a.cx,y:a.cy,width:l(o.get("width"),a.r),r:l(o.get("length"),a.r)},style:i.getModel("itemStyle.normal").getItemStyle()}),"auto"===t.style.fill&&t.setStyle("fill",n((g.get("value",e)-f[0])/(f[1]-f[0]))),r.setHoverStyle(t,i.getModel("itemStyle.emphasis").getItemStyle())}),this._data=g},_renderTitle:function(t,e,i,n,a){var o=t.getModel("title");if(o.get("show")){var s=o.getModel("textStyle"),h=o.get("offsetCenter"),u=a.cx+l(h[0],a.r),c=a.cy+l(h[1],a.r),d=new r.Text({style:{x:u,y:c,text:t.getData().getName(0),fill:s.getTextColor(),textFont:s.getFont(),textAlign:"center",textVerticalAlign:"middle"}});this.group.add(d)}},_renderDetail:function(t,e,i,n,o){var s=t.getModel("detail"),h=t.get("min"),u=t.get("max");if(s.get("show")){var c=s.getModel("textStyle"),d=s.get("offsetCenter"),f=o.cx+l(d[0],o.r),p=o.cy+l(d[1],o.r),g=l(s.get("width"),o.r),m=l(s.get("height"),o.r),v=t.getData().get("value",0),y=new r.Rect({shape:{x:f-g/2,y:p-m/2,width:g,height:m},style:{text:a(v,s.get("formatter")),fill:s.get("backgroundColor"),textFill:c.getTextColor(),textFont:c.getFont()}});"auto"===y.style.textFill&&y.setStyle("textFill",n((v-h)/(u-h))),y.setStyle(s.getItemStyle(["color"])),this.group.add(y)}}});t.exports=u},function(t,e,i){t.exports=i(6).extend({type:"echartsGaugePointer",shape:{angle:0,width:10,r:10,x:0,y:0},buildPath:function(t,e){var i=Math.cos,n=Math.sin,a=e.r,o=e.width,r=e.angle,s=e.x-i(r)*o*(o>=a/3?1:2),l=e.y-n(r)*o*(o>=a/3?1:2);r=e.angle-Math.PI/2,t.moveTo(s,l),t.lineTo(e.x+i(r)*o,e.y+n(r)*o),t.lineTo(e.x+i(e.angle)*a,e.y+n(e.angle)*a),t.lineTo(e.x-i(r)*o,e.y-n(r)*o),t.lineTo(s,l)}})},function(t,e,i){var n=i(2),a=i(1);i(247),i(248),i(255),n.registerProcessor("filter",i(249)),n.registerVisualCoding("chart",a.curry(i(44),"graph","circle",null)),n.registerVisualCoding("chart",i(250)),n.registerLayout(i(256)),n.registerLayout(i(251)),n.registerLayout(i(254)),n.registerCoordinateSystem("graphView",{create:i(252)})},function(t,e,i){"use strict";var n=i(14),a=i(1),o=i(208),r=i(2).extendSeriesModel({type:"series.graph",init:function(t){r.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._categoriesData},this._updateCategoriesData()},mergeOption:function(t){r.superApply(this,"mergeOption",arguments),this._updateCategoriesData()},getInitialData:function(t,e){var i=t.edges||t.links,n=t.data||t.nodes;if(n&&i){var a=o(n,i,this,!0),r=a.data,s=this;return r.wrapMethod("getItemModel",function(t){var e=s._categoriesModels,i=t.getShallow("category"),n=e[i];return n&&(n.parentModel=t.parentModel,t.parentModel=n),t}),r}},restoreData:function(){r.superApply(this,"restoreData",arguments),this.getGraph().restoreData()},getGraph:function(){return this.getData().graph},getEdgeData:function(){return this.getGraph().edgeData},getCategoriesData:function(){return this._categoriesData},_updateCategoriesData:function(){var t=a.map(this.option.categories||[],function(t){return null!=t.value?t:a.extend({value:0},t)}),e=new n(["value"],this);e.initData(t),this._categoriesData=e,this._categoriesModels=e.mapArray(function(t){return e.getItemModel(t,!0)})},setRoamZoom:function(t){var e=this.option.roamDetail;e&&(e.zoom=t)},setRoamPan:function(t,e){var i=this.option.roamDetail;i&&(i.x=t,i.y=e)},defaultOption:{zlevel:0,z:2,color:["#61a0a8","#d14a61","#fd9c35","#675bba","#fec42c","#dd4444","#fd9c35","#cd4870"],coordinateSystem:"view",legendHoverLink:!0,hoverAnimation:!0,layout:null,force:{initLayout:null,repulsion:50,gravity:.1,edgeLength:30,layoutAnimation:!0},left:"center",top:"center",symbol:"circle",symbolSize:10,draggable:!1,roam:!1,roamDetail:{x:0,y:0,zoom:1},nodeScaleRatio:.6,label:{normal:{show:!1},emphasis:{show:!0}},itemStyle:{normal:{},emphasis:{}},lineStyle:{normal:{color:"#aaa",width:1,curveness:0,opacity:.5},emphasis:{}}}});t.exports=r},function(t,e,i){var n=i(38),a=i(84),o=i(70),r=i(7),s=i(3);i(2).extendChartView({type:"graph",init:function(t,e){var i=new n,r=new a,s=this.group,l=new o(e.getZr(),s);s.add(i.group),s.add(r.group),this._symbolDraw=i,this._lineDraw=r,this._controller=l,this._firstRender=!0},render:function(t,e,i){var n=t.coordinateSystem;if("geo"===n.type||"view"===n.type){var a=t.getData();this._model=t;var o=this._symbolDraw,l=this._lineDraw;o.updateData(a);var h=a.graph.edgeData,u=t.option,c=r.createDataFormatModel(t,h,u.edges||u.links);c.formatTooltip=function(t){var e=this.getDataParams(t),i=e.data,n=i.source+" > "+i.target;return e.value&&(n+=":"+e.value),n},l.updateData(h,null,null),h.eachItemGraphicEl(function(t){t.traverse(function(t){t.hostModel=c})}),a.graph.eachEdge(function(t){t.__lineWidth=t.getModel("lineStyle.normal").get("width")});var d=this.group,f={position:n.position,scale:n.scale};this._firstRender?d.attr(f):s.updateProps(d,f,t),this._nodeScaleRatio=t.get("nodeScaleRatio"),this._updateNodeAndLinkScale(),this._updateController(t,n,i),clearTimeout(this._layoutTimeout);var p=t.forceLayout,g=t.get("force.layoutAnimation");p&&this._startForceLayoutIteration(p,g),a.eachItemGraphicEl(function(t,e){var i=a.getItemModel(e).get("draggable");i&&p?t.on("drag",function(){p.warmUp(),!this._layouting&&this._startForceLayoutIteration(p,g),p.setFixed(e),a.setItemLayout(e,t.position)},this).on("dragend",function(){p.setUnfixed(e)},this):t.off("drag"),t.setDraggable(i)},this),this._firstRender=!1}},_startForceLayoutIteration:function(t,e){var i=this;!function n(){t.step(function(t){i.updateLayout(),(i._layouting=!t)&&(e?i._layoutTimeout=setTimeout(n,16):n())})}()},_updateController:function(t,e,i){var n=this._controller;n.rect=e.getViewRect(),n.enable(t.get("roam")),n.off("pan").off("zoom").on("pan",function(e,n){i.dispatchAction({seriesId:t.id,type:"graphRoam",dx:e,dy:n})}).on("zoom",function(e,n,a){i.dispatchAction({seriesId:t.id,type:"graphRoam",zoom:e,originX:n,originY:a})}).on("zoom",this._updateNodeAndLinkScale,this)},_updateNodeAndLinkScale:function(){ +var t=this._model,e=t.getData(),i=this.group,n=this._nodeScaleRatio,a=i.scale[0],o=(a-1)*n+1,r=[o/a,o/a];e.eachItemGraphicEl(function(t,e){t.attr("scale",r)})},updateLayout:function(t,e){this._symbolDraw.updateLayout(),this._lineDraw.updateLayout()},remove:function(t,e){this._symbolDraw&&this._symbolDraw.remove(),this._lineDraw&&this._lineDraw.remove()}})},function(t,e){t.exports=function(t){var e=t.findComponents({mainType:"legend"});e&&e.length&&t.eachSeriesByType("graph",function(t){var i=t.getCategoriesData(),n=t.getGraph(),a=n.data,o=i.mapArray(i.getName);a.filterSelf(function(t){var i=a.getItemModel(t),n=i.getShallow("category");if(null!=n){"number"==typeof n&&(n=o[n]);for(var r=0;rs;s++){var m=t[s];m.fixed||(n.sub(o,l,m.p),n.scaleAndAdd(m.p,m.p,o,h*d))}for(var s=0;r>s;s++)for(var c=t[s],v=s+1;r>v;v++){var f=t[v];n.sub(o,f.p,c.p);var p=n.len(o);0===p&&(n.set(o,Math.random()-.5,Math.random()-.5),p=1);var y=(c.rep+f.rep)/p/p;!c.fixed&&a(c.pp,c.pp,o,y),!f.fixed&&a(f.pp,f.pp,o,-y)}for(var x=[],s=0;r>s;s++){var m=t[s];m.fixed||(n.sub(x,m.p,m.pp),n.scaleAndAdd(m.p,m.p,x,d),n.copy(m.pp,m.p))}d=.992*d,i&&i(t,e,.01>d)}}}},function(t,e,i){var n=i(253),a=i(4),o=i(207),r=i(206),s=i(5);t.exports=function(t,e){t.eachSeriesByType("graph",function(t){if("force"===t.get("layout")){var e=t.preservedPoints||{},i=t.getGraph(),l=i.data,h=i.edgeData,u=t.getModel("force"),c=u.get("initLayout");t.preservedPoints?l.each(function(t){var i=l.getId(t);l.setItemLayout(t,e[i]||[NaN,NaN])}):c&&"none"!==c?"circular"===c&&r(t):o(t);var d=l.getDataExtent("value"),f=u.get("repulsion"),p=u.get("edgeLength"),g=l.mapArray("value",function(t,e){var i=l.getItemLayout(e),n=a.linearMap(t,d,[0,f])||f/2;return{w:n,rep:n,p:!i||isNaN(i[0])||isNaN(i[1])?null:i}}),m=h.mapArray("value",function(t,e){var n=i.getEdgeByIndex(e);return{n1:g[n.node1.dataIndex],n2:g[n.node2.dataIndex],d:p,curveness:n.getModel().get("lineStyle.normal.curveness")||0}}),v=t.coordinateSystem,y=v.getBoundingRect(),x=n(g,m,{rect:y,gravity:u.get("gravity")}),_=x.step;x.step=function(t){for(var n=0,a=g.length;a>n;n++)g[n].fixed&&s.copy(g[n].p,i.getNodeByIndex(n).getLayout());_(function(n,a,o){for(var r=0,s=n.length;s>r;r++)n[r].fixed||i.getNodeByIndex(r).setLayout(n[r].p),e[l.getId(r)]=n[r].p;for(var r=0,s=a.length;s>r;r++){var h=a[r],u=h.n1.p,c=h.n2.p,d=[u,c];h.curveness>0&&d.push([(u[0]+c[0])/2-(u[1]-c[1])*h.curveness,(u[1]+c[1])/2-(c[0]-u[0])*h.curveness]),i.getEdgeByIndex(r).setLayout(d)}t&&t(o)})},t.forceLayout=x,t.preservedPoints=e,x.step()}else t.forceLayout=null})}},function(t,e,i){var n=i(2),a=i(205),o={type:"graphRoam",event:"graphRoam",update:"none"};n.registerAction(o,function(t,e){e.eachComponent({mainType:"series",query:t},function(e){var i=e.coordinateSystem,n=e.getModel("roamDetail"),o=a.calcPanAndZoom(n,t);e.setRoamPan&&e.setRoamPan(o.x,o.y),e.setRoamZoom&&e.setRoamZoom(o.zoom),i&&i.setPan(o.x,o.y),i&&i.setZoom(o.zoom)})})},function(t,e,i){var n=i(207);t.exports=function(t,e){t.eachSeriesByType("graph",function(t){var e=t.get("layout");e&&"none"!==e||n(t)})}},function(t,e,i){i(259),i(260)},function(t,e,i){function n(){var t=o.createCanvas();this.canvas=t,this.blurSize=30,this.pointSize=20,this.opacity=1,this._gradientPixels={}}var a=256,o=i(1);n.prototype={update:function(t,e,i,n,o,r){var s=this._getBrush(),l=this._getGradient(t,o,"inRange"),h=this._getGradient(t,o,"outOfRange"),u=this.pointSize+this.blurSize,c=this.canvas,d=c.getContext("2d"),f=t.length;c.width=e,c.height=i;for(var p=0;f>p;++p){var g=t[p],m=g[0],v=g[1],y=g[2],x=n(y);d.globalAlpha=x,d.drawImage(s,m-u,v-u)}for(var _=d.getImageData(0,0,c.width,c.height),w=_.data,b=0,S=w.length;S>b;){var x=w[b+3]/256,M=4*Math.floor(x*(a-1));if(x>0){var A=r(x)?l:h;w[b++]=A[M],w[b++]=A[M+1],w[b++]=A[M+2],w[b++]*=this.opacity*A[M+3]}else b+=4}return d.putImageData(_,0,0),c},_getBrush:function(){var t=this._brushCanvas||(this._brushCanvas=o.createCanvas()),e=this.pointSize+this.blurSize,i=2*e;t.width=i,t.height=i;var n=t.getContext("2d");return n.clearRect(0,0,i,i),n.shadowOffsetX=i,n.shadowBlur=this.blurSize,n.shadowColor="#000",n.beginPath(),n.arc(-e,e,this.pointSize,0,2*Math.PI,!0),n.closePath(),n.fill(),t},_getGradient:function(t,e,i){for(var n=this._gradientPixels,a=n[i]||(n[i]=new Uint8ClampedArray(1024)),o=[],r=0,s=0;256>s;s++)e[i](s/255,!0,o),a[r++]=o[0],a[r++]=o[1],a[r++]=o[2],a[r++]=o[3];return a}},t.exports=n},function(t,e,i){var n=i(13),a=i(36);t.exports=n.extend({type:"series.heatmap",getInitialData:function(t,e){return a(t.data,this,e)},defaultOption:{coordinateSystem:"cartesian2d",zlevel:0,z:2,xAxisIndex:0,yAxisIndex:0,geoIndex:0,blurSize:30,pointSize:20}})},function(t,e,i){function n(t,e,i){var n=t[1]-t[0];e=l.map(e,function(e){return{interval:[(e.interval[0]-t[0])/n,(e.interval[1]-t[0])/n]}});var a=e.length,o=0;return function(t){for(var n=o;a>n;n++){var r=e[n].interval;if(r[0]<=t&&t<=r[1]){o=n;break}}if(n===a)for(var n=o-1;n>=0;n--){var r=e[n].interval;if(r[0]<=t&&t<=r[1]){o=n;break}}return n>=0&&a>n&&i[n]}}function a(t,e){var i=t[1]-t[0];return e=[(e[0]-t[0])/i,(e[1]-t[0])/i],function(t){return t>=e[0]&&t<=e[1]}}function o(t){var e=t.dimensions;return"lng"===e[0]&&"lat"===e[1]}var r=i(3),s=i(258),l=i(1);t.exports=i(2).extendChartView({type:"heatmap",render:function(t,e,i){var n;if(e.eachComponent("visualMap",function(e){e.eachTargetSeries(function(i){i===t&&(n=e)})}),!n)throw new Error("Heatmap must use with visualMap");this.group.removeAll();var a=t.coordinateSystem;"cartesian2d"===a.type?this._renderOnCartesian(a,t,i):o(a)&&this._renderOnGeo(a,t,n,i)},_renderOnCartesian:function(t,e,i){var n=t.getAxis("x"),a=t.getAxis("y"),o=this.group;if("category"!==n.type||"category"!==a.type)throw new Error("Heatmap on cartesian must have two category axes");if(!n.onBand||!a.onBand)throw new Error("Heatmap on cartesian must have two axes with boundaryGap true");var s=n.getBandWidth(),l=a.getBandWidth(),h=e.getData();h.each(["x","y","z"],function(i,n,a,u){var c=h.getItemModel(u),d=t.dataToPoint([i,n]);if(!isNaN(a)){var f=new r.Rect({shape:{x:d[0]-s/2,y:d[1]-l/2,width:s,height:l},style:{fill:h.getItemVisual(u,"color")}}),p=c.getModel("itemStyle.normal").getItemStyle(["color"]),g=c.getModel("itemStyle.emphasis").getItemStyle(),m=c.getModel("label.normal"),v=c.getModel("label.emphasis"),y=e.getRawValue(u),x="-";y&&null!=y[2]&&(x=y[2]),m.get("show")&&(r.setText(p,m),p.text=e.getFormattedLabel(u,"normal")||x),v.get("show")&&(r.setText(g,v),g.text=e.getFormattedLabel(u,"emphasis")||x),f.setStyle(p),r.setHoverStyle(f,g),o.add(f),h.setItemGraphicEl(u,f)}})},_renderOnGeo:function(t,e,i,o){var l=i.targetVisuals.inRange,h=i.targetVisuals.outOfRange,u=e.getData(),c=this._hmLayer||this._hmLayer||new s;c.blurSize=e.get("blurSize"),c.pointSize=e.get("pointSize");var d=t.getViewRect().clone(),f=t.getRoamTransform();d.applyTransform(f);var p=Math.max(d.x,0),g=Math.max(d.y,0),m=Math.min(d.width+d.x,o.getWidth()),v=Math.min(d.height+d.y,o.getHeight()),y=m-p,x=v-g,_=u.mapArray(["lng","lat","value"],function(e,i,n){var a=t.dataToPoint([e,i]);return a[0]-=p,a[1]-=g,a.push(n),a}),w=i.getExtent(),b="visualMap.continuous"===i.type?a(w,i.option.range):n(w,i.getPieceList(),i.option.selected);c.update(_,y,x,l.color.getNormalizer(),{inRange:l.color.getColorMapper(),outOfRange:h.color.getColorMapper()},b);var S=new r.Image({style:{width:y,height:x,x:p,y:g,image:c.canvas},silent:!0});this.group.add(S)}})},function(t,e,i){function n(t,e,i,n){r.Group.call(this);var a=new s(t,e,i,n);this.add(a),this._updateEffectSymbol(t,n)}function a(t,e){t.__p1=e[0],t.__p2=e[1],t.__cp1=e[2]||[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2]}function o(){var t=this.__p1,e=this.__p2,i=this.__cp1,n=this.__t,a=this.position,o=u.quadraticAt,r=u.quadraticDerivativeAt;a[0]=o(t[0],i[0],e[0],n),a[1]=o(t[1],i[1],e[1],n);var s=r(t[0],i[0],e[0],n),l=r(t[1],i[1],e[1],n);this.rotation=-Math.atan2(l,s)-Math.PI/2,this.ignore=!1}var r=i(3),s=i(83),l=i(1),h=i(24),u=i(18),c=n.prototype;c._updateEffectSymbol=function(t,e){var i=t.getItemModel(e),n=i.getModel("effect"),r=n.get("symbolSize"),s=n.get("symbol");l.isArray(r)||(r=[r,r]);var u=n.get("color")||t.getItemVisual(e,"color"),c=this.childAt(1),d=1e3*n.get("period");this._symbolType===s&&d===this._period||(c=h.createSymbol(s,-.5,-.5,1,1,u),c.ignore=!0,c.z2=100,this._symbolType=s,this._period=d,this.add(c),c.__t=0,c.animate("",!0).when(d,{__t:1}).delay(e/t.count()*d/2).during(l.bind(o,c)).start()),c.setStyle("shadowColor",u),c.setStyle(n.getItemStyle(["color"])),c.attr("scale",r);var f=t.getItemLayout(e);a(c,f),c.setColor(u),c.attr("scale",r)},c.updateData=function(t,e,i,n){this.childAt(0).updateData(t,e,i,n),this._updateEffectSymbol(t,n)},c.updateLayout=function(t,e,i,n){this.childAt(0).updateLayout(t,e,i,n);var o=this.childAt(1),r=t.getItemLayout(n);a(o,r)},l.inherits(n,r.Group),t.exports=n},function(t,e,i){function n(t){return o.isArray(t)||(t=[+t,+t]),t}function a(t,e){u.call(this);var i=new h(t,e),n=new u;this.add(i),this.add(n),n.beforeUpdate=function(){this.attr(i.getScale())},this.updateData(t,e)}var o=i(1),r=i(24),s=i(3),l=i(4),h=i(47),u=s.Group,c=3,d=a.prototype;d.stopEffectAnimation=function(){this.childAt(1).removeAll()},d.startEffectAnimation=function(t,e,i,n,a,o){for(var s=this._symbolType,l=this._color,h=this.childAt(1),u=0;c>u;u++){var d=r.createSymbol(s,-.5,-.5,1,1,l);d.attr({style:{stroke:"stroke"===e?l:null,fill:"fill"===e?l:null,strokeNoScale:!0},z2:99,silent:!0,scale:[1,1],z:a,zlevel:o});var f=-u/c*t+n;d.animate("",!0).when(t,{scale:[i,i]}).delay(f).start(),d.animateStyle(!0).when(t,{opacity:0}).delay(f).start(),h.add(d)}},d.highlight=function(){this.trigger("emphasis")},d.downplay=function(){this.trigger("normal")},d.updateData=function(t,e){function i(){w.trigger("emphasis"),"render"!==p&&this.startEffectAnimation(v,m,g,y,x,_)}function a(){w.trigger("normal"),"render"!==p&&this.stopEffectAnimation()}var o=t.hostModel;this.childAt(0).updateData(t,e);var r=this.childAt(1),s=t.getItemModel(e),h=t.getItemVisual(e,"symbol"),u=n(t.getItemVisual(e,"symbolSize")),c=t.getItemVisual(e,"color");r.attr("scale",u),r.traverse(function(t){t.attr({fill:c})});var d=s.getShallow("symbolOffset");if(d){var f=r.position;f[0]=l.parsePercent(d[0],u[0]),f[1]=l.parsePercent(d[1],u[1])}this._symbolType=h,this._color=c;var p=o.get("showEffectOn"),g=s.get("rippleEffect.scale"),m=s.get("rippleEffect.brushType"),v=1e3*s.get("rippleEffect.period"),y=e/t.count(),x=s.getShallow("z")||0,_=s.getShallow("zlevel")||0;this.stopEffectAnimation(),"render"===p&&this.startEffectAnimation(v,m,g,y,x,_);var w=this.childAt(0);this.on("mouseover",i,this).on("mouseout",a,this).on("emphasis",i,this).on("normal",a,this)},d.fadeOut=function(t){t&&t()},o.inherits(a,u),t.exports=a},function(t,e,i){function n(t,e,i,n){l.Group.call(this),this.bodyIndex,this.whiskerIndex,this.styleUpdater=i,this._createContent(t,e,n),this.updateData(t,e,n),this._seriesModel}function a(t,e,i){return s.map(t,function(t){return t=t.slice(),t[e]=i.initBaseline,t})}function o(t){var e={};return s.each(t,function(t,i){e["ends"+i]=t}),e}function r(t){this.group=new l.Group,this.styleUpdater=t}var s=i(1),l=i(3),h=i(6),u=h.extend({type:"whiskerInBox",shape:{},buildPath:function(t,e){for(var i in e)if(0===i.indexOf("ends")){var n=e[i];t.moveTo(n[0][0],n[0][1]),t.lineTo(n[1][0],n[1][1])}}}),c=n.prototype;c._createContent=function(t,e,i){var n=t.getItemLayout(e),r="horizontal"===n.chartLayout?1:0,h=0;this.add(new l.Polygon({shape:{points:i?a(n.bodyEnds,r,n):n.bodyEnds},style:{strokeNoScale:!0},z2:100})),this.bodyIndex=h++;var c=s.map(n.whiskerEnds,function(t){return i?a(t,r,n):t});this.add(new u({shape:o(c),style:{strokeNoScale:!0},z2:100})),this.whiskerIndex=h++},c.updateData=function(t,e,i){var n=this._seriesModel=t.hostModel,a=t.getItemLayout(e),r=l[i?"initProps":"updateProps"];r(this.childAt(this.bodyIndex),{shape:{points:a.bodyEnds}},n),r(this.childAt(this.whiskerIndex),{shape:o(a.whiskerEnds)},n),this.styleUpdater.call(null,this,t,e)},s.inherits(n,l.Group);var d=r.prototype;d.updateData=function(t){var e=this.group,i=this._data,a=this.styleUpdater;t.diff(i).add(function(i){if(t.hasValue(i)){var o=new n(t,i,a,!0);t.setItemGraphicEl(i,o),e.add(o)}}).update(function(o,r){var s=i.getItemGraphicEl(r);return t.hasValue(o)?(s?s.updateData(t,o):s=new n(t,o,a),e.add(s),void t.setItemGraphicEl(o,s)):void e.remove(s)}).remove(function(t){var n=i.getItemGraphicEl(t);n&&e.remove(n)}).execute(),this._data=t},d.remove=function(){var t=this.group,e=this._data;this._data=null,e&&e.eachItemGraphicEl(function(e){e&&t.remove(e)})},t.exports=r},function(t,e,i){i(265),i(266);var n=i(1),a=i(2);a.registerLayout(i(267)),a.registerVisualCoding("chart",n.curry(i(74),"lines","lineStyle"))},function(t,e,i){"use strict";var n=i(13),a=i(14),o=i(1),r=i(28);t.exports=n.extend({type:"series.lines",dependencies:["grid","polar"],getInitialData:function(t,e){function i(t,e,i,n){return t.coord&&t.coord[n]}var n=[],s=[],l=[];o.each(t.data,function(t){n.push(t[0]),s.push(t[1]),l.push(o.extend(o.extend({},o.isArray(t[0])?null:t[0]),o.isArray(t[1])?null:t[1]))});var h=r.get(t.coordinateSystem);if(!h)throw new Error("Invalid coordinate system");var u=h.dimensions,c=new a(u,this),d=new a(u,this),f=new a(["value"],this);return c.initData(n,null,i),d.initData(s,null,i),f.initData(l),this.fromData=c,this.toData=d,f},formatTooltip:function(t){var e=this.fromData.getName(t),i=this.toData.getName(t);return e+" > "+i},defaultOption:{coordinateSystem:"geo",zlevel:0,z:2,legendHoverLink:!0,hoverAnimation:!0,xAxisIndex:0,yAxisIndex:0,geoIndex:0,effect:{show:!1,period:4,symbol:"circle",symbolSize:3,trailLength:.2},large:!1,largeThreshold:2e3,label:{normal:{show:!1,position:"end"}},lineStyle:{normal:{opacity:.5}}}})},function(t,e,i){var n=i(84),a=i(261),o=i(83);i(2).extendChartView({type:"lines",init:function(){},render:function(t,e,i){var r=t.getData(),s=this._lineDraw,l=t.get("effect.show");l!==this._hasEffet&&(s&&s.remove(),s=this._lineDraw=new n(l?a:o),this._hasEffet=l);var h=t.get("zlevel"),u=t.get("effect.trailLength"),c=i.getZr();c.painter.getLayer(h).clear(!0),null!=this._lastZlevel&&c.configLayer(this._lastZlevel,{motionBlur:!1}),l&&u&&c.configLayer(h,{motionBlur:!0,lastFrameAlpha:Math.max(Math.min(u/10+.9,1),0)}),this.group.add(s.group),s.updateData(r),this._lastZlevel=h},updateLayout:function(t,e,i){this._lineDraw.updateLayout();var n=i.getZr();n.painter.getLayer(this._lastZlevel).clear(!0)},remove:function(t,e){this._lineDraw&&this._lineDraw.remove(e,!0)}})},function(t,e){t.exports=function(t){t.eachSeriesByType("lines",function(t){var e=t.coordinateSystem,i=t.fromData,n=t.toData,a=t.getData(),o=e.dimensions;i.each(o,function(t,n,a){i.setItemLayout(a,e.dataToPoint([t,n]))}),n.each(o,function(t,i,a){n.setItemLayout(a,e.dataToPoint([t,i]))}),a.each(function(t){var e,o=i.getItemLayout(t),r=n.getItemLayout(t),s=a.getItemModel(t).get("lineStyle.normal.curveness");s>0&&(e=[(o[0]+r[0])/2-(o[1]-r[1])*s,(o[1]+r[1])/2-(r[0]-o[0])*s]),a.setItemLayout(t,[o,r,e])})})}},function(t,e,i){var n=i(2);i(269),i(270),i(204),i(221),n.registerLayout(i(273)),n.registerVisualCoding("chart",i(274)),n.registerProcessor("statistic",i(272)),n.registerPreprocessor(i(271)),i(68)("map",[{type:"mapToggleSelect",event:"mapselectchanged",method:"toggleSelected"},{type:"mapSelect",event:"mapselected",method:"select"},{type:"mapUnSelect",event:"mapunselected",method:"unSelect"}])},function(t,e,i){function n(t,e){for(var i={},n=e.features,a=0;a"+n+" : "+i},defaultOption:{zlevel:0,z:2,coordinateSystem:"geo",map:"china",left:"center",top:"center",showLegendSymbol:!0,dataRangeHoverLink:!0,roamDetail:{x:0,y:0,zoom:1},label:{normal:{show:!1,textStyle:{color:"#000"}},emphasis:{show:!1,textStyle:{color:"#000"}}},itemStyle:{normal:{borderWidth:.5,borderColor:"#444",areaColor:"#eee"},emphasis:{areaColor:"rgba(255,215, 0, 0.8)"}}}});s.mixin(f,d),t.exports=f},function(t,e,i){var n=i(3),a=i(210);i(2).extendChartView({type:"map",render:function(t,e,i,n){if(!n||"mapToggleSelect"!==n.type||n.from!==this.uid){var o=this.group;if(o.removeAll(),n&&"geoRoam"===n.type&&"series"===n.component&&n.name===t.name){var r=this._mapDraw;r&&o.add(r.group)}else if(t.needsDrawMap){var r=this._mapDraw||new a(i,!0);o.add(r.group),r.draw(t,e,i,this),this._mapDraw=r}else this._mapDraw&&this._mapDraw.remove(),this._mapDraw=null;t.get("showLegendSymbol")&&e.getComponent("legend")&&this._renderSymbols(t,e,i)}},remove:function(){this._mapDraw&&this._mapDraw.remove(),this._mapDraw=null,this.group.removeAll()},_renderSymbols:function(t,e,i){var a=t.getData(),o=this.group;a.each("value",function(t,e){if(!isNaN(t)){var i=a.getItemLayout(e);if(i&&i.point){var r=i.point,s=i.offset,l=new n.Circle({style:{fill:a.getVisual("color")},shape:{cx:r[0]+9*s,cy:r[1],r:3},silent:!0,z2:10});if(!s){var h=a.getName(e),u=a.getItemModel(e),c=u.getModel("label.normal"),d=u.getModel("label.emphasis"),f=c.getModel("textStyle"),p=d.getModel("textStyle"),g=a.getItemGraphicEl(e);l.setStyle({textPosition:"bottom"});var m=function(){l.setStyle({text:d.get("show")?h:"",textFill:p.getTextColor(),textFont:p.getFont()})},v=function(){l.setStyle({text:c.get("show")?h:"",textFill:f.getTextColor(),textFont:f.getFont()})};g.on("mouseover",m).on("mouseout",v).on("emphasis",m).on("normal",v),v()}o.add(l)}}})}})},function(t,e,i){function n(t){var e={};return a.each(o,function(i){null!=t[i]&&(e[i]=t[i])}),e}var a=i(1),o=["x","y","x2","y2","width","height","map","roam","roamDetail","label","itemStyle"],r={};t.exports=function(t){var e=[];a.each(t.series,function(t){"map"===t.type&&e.push(t),a.extend(r,t.geoCoord)});var i={};a.each(e,function(e){if(e.map=e.map||e.mapType,a.defaults(e,e.mapLocation),e.markPoint){var o=e.markPoint;if(o.data=a.map(o.data,function(t){if(!a.isArray(t.value)){var e;t.geoCoord?e=t.geoCoord:t.name&&(e=r[t.name]);var i=e?[e[0],e[1]]:[NaN,NaN];null!=t.value&&i.push(t.value),t.value=i}return t}),!e.data||!e.data.length){t.geo||(t.geo=[]);var s=i[e.map];s||(s=i[e.map]=n(e),t.geo.push(s));var l=e.markPoint;l.type=t.effect&&t.effect.show?"effectScatter":"scatter",l.coordinateSystem="geo",l.geoIndex=a.indexOf(t.geo,s),l.name=e.name,t.series.splice(a.indexOf(t.series,e),1,l)}}})}},function(t,e,i){function n(t,e){for(var i={},n=["value"],a=0;au;u++)s=Math.min(s,i[o][u]),l=Math.max(l,i[o][u]),r+=i[o][u];var c;return c="min"===e?s:"max"===e?l:"average"===e?r/h:r,0===h?NaN:c})}var a=i(1);t.exports=function(t){var e={};t.eachSeriesByType("map",function(t){var i=t.get("map");e[i]=e[i]||[],e[i].push(t)}),a.each(e,function(t,e){var i=n(a.map(t,function(t){return t.getData()}),t[0].get("mapValueCalculation"));t[0].seriesGroup=[],t[0].setData(i);for(var o=0;o=0?e:NaN}})}var a=i(14),o=i(1),r=i(13);t.exports=r.extend({type:"series.parallel",dependencies:["parallel"],getInitialData:function(t,e){var i=e.getComponent("parallel",this.get("parallelIndex")),r=i.dimensions,s=i.parallelAxisIndex,l=t.data,h=o.map(r,function(t,i){var a=e.getComponent("parallelAxis",s[i]);return"category"===a.get("type")?(n(a,t,l),{name:t,type:"ordinal"}):t}),u=new a(h,this);return u.initData(l),u},defaultOption:{zlevel:0,z:2,coordinateSystem:"parallel",parallelIndex:0,label:{normal:{show:!1},emphasis:{show:!1}},inactiveOpacity:.05,activeOpacity:1,lineStyle:{normal:{width:2,opacity:.45,type:"solid"}},animationEasing:"linear"}})},function(t,e,i){function n(t,e,i){var n=t.model,a=t.getRect(),o=new s.Rect({shape:{x:a.x,y:a.y,width:a.width,height:a.height}}),r="horizontal"===n.get("layout")?"width":"height";return o.setShape(r,0),s.initProps(o,{shape:{width:a.width,height:a.height}},e,i),o}function a(t,e,i,n){for(var a=0,o=e.length-1;o>a;a++){var s=e[a],l=e[a+1],h=t[a],u=t[a+1];n(r(h,i.getAxis(s).type)||r(u,i.getAxis(l).type)?null:[i.dataToPoint(h,s),i.dataToPoint(u,l)],a)}}function o(t){return new s.Polyline({shape:{points:t},silent:!0})}function r(t,e){return"category"===e?null==t:null==t||isNaN(t)}var s=i(3),l=i(1),h=i(25).extend({type:"parallel",init:function(){this._dataGroup=new s.Group,this.group.add(this._dataGroup),this._data},render:function(t,e,i,r){function h(t){var e=f.getValues(m,t),i=new s.Group;d.add(i),a(e,m,g,function(t,e){t&&i.add(o(t))}),f.setItemGraphicEl(t,i)}function u(e,i){var n=f.getValues(m,e),r=p.getItemGraphicEl(i),l=[],h=0;a(n,m,g,function(e,i){var n=r.childAt(h++);e&&!n?l.push(o(e)):e&&s.updateProps(n,{shape:{points:e}},t)});for(var u=r.childCount()-1;u>=h;u--)r.remove(r.childAt(u));for(var u=0,c=l.length;c>u;u++)r.add(l[u]);f.setItemGraphicEl(e,r)}function c(t){var e=p.getItemGraphicEl(t);d.remove(e)}var d=this._dataGroup,f=t.getData(),p=this._data,g=t.coordinateSystem,m=g.dimensions;f.diff(p).add(h).update(u).remove(c).execute(),f.eachItemGraphicEl(function(t,e){var i=f.getItemModel(e),n=i.getModel("lineStyle.normal");t.eachChild(function(t){t.setStyle(l.extend(n.getLineStyle(),{stroke:f.getItemVisual(e,"color"),opacity:f.getItemVisual(e,"opacity")}))})}),this._data||d.setClipPath(n(g,t,function(){d.removeClipPath()})),this._data=f},remove:function(){this._dataGroup&&this._dataGroup.removeAll(),this._data=null}});t.exports=h},function(t,e){t.exports=function(t,e){t.eachSeriesByType("parallel",function(e){var i=e.getModel("itemStyle.normal"),n=t.get("color"),a=i.get("color")||n[e.seriesIndex%n.length],o=e.get("inactiveOpacity"),r=e.get("activeOpacity"),s=e.getModel("lineStyle.normal").getLineStyle(),l=e.coordinateSystem,h=e.getData(),u={normal:s.opacity,active:r,inactive:o};l.eachActiveState(h,function(t,e){h.setItemVisual(e,"opacity",u[t])}),h.setVisual("color",a)})}},function(t,e,i){var n=i(1),a=i(2);i(305),i(280),i(281),a.registerVisualCoding("chart",n.curry(i(63),"radar")),a.registerVisualCoding("chart",n.curry(i(44),"radar","circle",null)),a.registerLayout(i(283)),a.registerProcessor("filter",n.curry(i(62),"radar")),a.registerPreprocessor(i(282))},function(t,e,i){"use strict";var n=i(13),a=i(14),o=i(31),r=i(1),s=i(9),l=n.extend({type:"series.radar",dependencies:["radar"],init:function(t){l.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._dataBeforeProcessed}},getInitialData:function(t,e){var i=t.data||[],n=o([],i,[],"indicator_"),r=new a(n,this);return r.initData(i),r},formatTooltip:function(t){var e=this.getRawValue(t),i=this.coordinateSystem,n=i.getIndicatorAxes();return this._data.getName(t)+"
"+r.map(n,function(t,i){return t.name+" : "+e[i]}).join("
")},getFormattedLabel:function(t,e,i,n){e=e||"normal";var a=this.getData(),o=a.getItemModel(t),r=this.getDataParams(t);return null==i&&(i=o.get(["label",e,"formatter"])),r.value=r.value[n||0],"function"==typeof i?(r.status=e,i(r)):"string"==typeof i?s.formatTpl(i,r):void 0},defaultOption:{zlevel:0,z:2,coordinateSystem:"radar",legendHoverLink:!0,radarIndex:0,lineStyle:{normal:{width:2,type:"solid"}},label:{normal:{position:"top"}},symbol:"emptyCircle",symbolSize:4}});t.exports=l},function(t,e,i){function n(t){return o.isArray(t)||(t=[+t,+t]),t}var a=i(3),o=i(1),r=i(24);t.exports=i(2).extendChartView({type:"radar",render:function(t,e,i){function s(t,e){var i=t.getItemVisual(e,"symbol")||"circle",a=t.getItemVisual(e,"color");if("none"!==i){var o=r.createSymbol(i,-.5,-.5,1,1,a);return o.attr({style:{strokeNoScale:!0},z2:100,scale:n(t.getItemVisual(e,"symbolSize"))}),o}}function l(e,i,n,o,r,l){n.removeAll();for(var h=0;hh;h++){var c=n[h];c.setLayout({x:o},!0),c.setLayout({dx:e},!0);for(var d=0,f=c.outEdges.length;f>d;d++)a.push(c.outEdges[d].node2)}n=a,++o}s(t,o),r=(i-e)/(o-1),l(t,r)}function s(t,e){I.each(t,function(t){t.outEdges.length||t.setLayout({x:e-1},!0)})}function l(t,e){I.each(t,function(t){var i=t.getLayout().x*e;t.setLayout({x:i},!0)})}function h(t,e,i,n,a){var o=A().key(function(t){return t.getLayout().x}).sortKeys(b).entries(t).map(function(t){return t.values});u(t,o,e,i,n),c(o,n,i);for(var r=1;a>0;a--)r*=.99,d(o,r),c(o,n,i),p(o,r),c(o,n,i)}function u(t,e,i,n,a){var o=[];I.each(e,function(t){var e=t.length,i=0;I.each(t,function(t){i+=t.getLayout().value});var r=(n-(e-1)*a)/i;o.push(r)}),o.sort(function(t,e){return t-e});var r=o[0];I.each(e,function(t){I.each(t,function(t,e){t.setLayout({y:e},!0);var i=t.getLayout().value*r;t.setLayout({dy:i},!0)})}),I.each(i,function(t){var e=+t.getValue()*r;t.setLayout({dy:e},!0)})}function c(t,e,i){I.each(t,function(t){var n,a,o,r=0,s=t.length;for(t.sort(w),o=0;s>o;o++){if(n=t[o],a=r-n.getLayout().y,a>0){var l=n.getLayout().y+a;n.setLayout({y:l},!0)}r=n.getLayout().y+n.getLayout().dy+e}if(a=r-e-i,a>0){var l=n.getLayout().y-a;for(n.setLayout({y:l},!0),r=n.getLayout().y,o=s-2;o>=0;--o)n=t[o],a=n.getLayout().y+n.getLayout().dy+e-r,a>0&&(l=n.getLayout().y-a,n.setLayout({y:l},!0)),r=n.getLayout().y}})}function d(t,e){I.each(t.slice().reverse(),function(t){I.each(t,function(t){if(t.outEdges.length){var i=x(t.outEdges,f)/x(t.outEdges,S),n=t.getLayout().y+(i-_(t))*e;t.setLayout({y:n},!0)}})})}function f(t){return _(t.node2)*t.getValue()}function p(t,e){I.each(t,function(t){I.each(t,function(t){if(t.inEdges.length){var i=x(t.inEdges,g)/x(t.inEdges,S),n=t.getLayout().y+(i-_(t))*e;t.setLayout({y:n},!0)}})})}function g(t){return _(t.node1)*t.getValue()}function m(t){I.each(t,function(t){t.outEdges.sort(v),t.inEdges.sort(y)}),I.each(t,function(t){var e=0,i=0;I.each(t.outEdges,function(t){t.setLayout({sy:e},!0),e+=t.getLayout().dy}),I.each(t.inEdges,function(t){t.setLayout({ty:i},!0),i+=t.getLayout().dy})})}function v(t,e){return t.node2.getLayout().y-e.node2.getLayout().y}function y(t,e){return t.node1.getLayout().y-e.node1.getLayout().y}function x(t,e){var i,n=0,a=t.length,o=-1;if(1===arguments.length)for(;++ot?-1:t>e?1:t==e?0:NaN}function S(t){return t.getValue()}var M=i(11),A=i(346),I=i(1);t.exports=function(t,e){t.eachSeriesByType("sankey",function(t){var i=t.get("nodeWidth"),r=t.get("nodeGap"),s=n(t,e);t.layoutInfo=s;var l=s.width,h=s.height,u=t.getGraph(),c=u.nodes,d=u.edges;o(c);var f=c.filter(function(t){return 0===t.getLayout().value}),p=0!==f.length?0:t.get("layoutIterations");a(c,d,i,r,l,h,p)})}},function(t,e,i){var n=i(73);t.exports=function(t,e){t.eachSeriesByType("sankey",function(t){var e=t.getGraph(),i=e.nodes;i.sort(function(t,e){return t.getLayout().value-e.getLayout().value});var a=i[0].getLayout().value,o=i[i.length-1].getLayout().value;i.forEach(function(e){var i=new n({type:"color",mappingMethod:"linear",dataExtent:[a,o],visual:t.get("color")}),r=i.mapValueToVisual(e.getLayout().value);e.setVisual("color",r)})})}},function(t,e,i){var n=i(2);i(291),i(292),i(293),n.registerVisualCoding("chart",i(295)),n.registerLayout(i(294))},function(t,e,i){function n(t,e){this.group=new o.Group,t.add(this.group),this._onSelect=e||s.noop}function a(t,e,i,n,a,o){var r=[[a?t:t-u,e],[t+i,e],[t+i,e+n],[a?t:t-u,e+n]];return!o&&r.splice(2,0,[t+i+u,e+n/2]),!a&&r.push([t,e+n/2]),r}var o=i(3),r=i(11),s=i(1),l=8,h=8,u=5;n.prototype={constructor:n,render:function(t,e,i){var n=t.getModel("breadcrumb"),a=this.group;if(a.removeAll(),n.get("show")&&i){var o=n.getModel("itemStyle.normal"),s=o.getModel("textStyle"),l={pos:{left:n.get("left"),right:n.get("right"),top:n.get("top"),bottom:n.get("bottom")},box:{width:e.getWidth(),height:e.getHeight()},emptyItemWidth:n.get("emptyItemWidth"),totalWidth:0,renderList:[]};this._prepare(n,i,l,s),this._renderContent(n,i,l,o,s),r.positionGroup(a,l.pos,l.box)}},_prepare:function(t,e,i,n){for(var a=e;a;a=a.parentNode){var o=a.getModel().get("name"),r=n.getTextRect(o),s=Math.max(r.width+2*l,i.emptyItemWidth);i.totalWidth+=s+h,i.renderList.push({node:a,text:o,width:s})}},_renderContent:function(t,e,i,n,l){for(var u=0,c=i.emptyItemWidth,d=t.get("height"),f=r.getAvailableSize(i.pos,i.box),p=i.totalWidth,g=i.renderList,m=g.length-1;m>=0;m--){var v=g[m],y=v.width,x=v.text;p>f.width&&(p-=y-c,y=c,x=""),this.group.add(new o.Polygon({shape:{points:a(u,0,y,d,m===g.length-1,0===m)},style:s.defaults(n.getItemStyle(),{lineJoin:"bevel",text:x,textFill:l.getTextColor(),textFont:l.getFont()}),onclick:s.bind(this._onSelect,this,v.node)})),u+=y+h}},remove:function(){this.group.removeAll()}},t.exports=n},function(t,e,i){function n(t,e){var i=0;s.each(t.children,function(t){n(t,e);var a=t.value;s.isArray(a)&&(a=a[0]),i+=a});var a=t.value;e>=0&&(s.isArray(a)?a=a[0]:t.value=new Array(e)),(null==a||isNaN(a))&&(a=i),0>a&&(a=0),e>=0?t.value[0]=a:t.value=a}function a(t,e){var i=e.get("color");if(i){t=t||[];var n;if(s.each(t,function(t){var e=new l(t),i=e.get("color");(e.get("itemStyle.normal.color")||i&&"none"!==i)&&(n=!0)}),!n){var a=t[0]||(t[0]={});a.color=i.slice()}return t}}var o=i(13),r=i(344),s=i(1),l=i(12),h=i(9),u=h.encodeHTML,c=h.addCommas;t.exports=o.extend({type:"series.treemap",dependencies:["grid","polar"],defaultOption:{left:"center",top:"middle",right:null,bottom:null,width:"80%",height:"80%",sort:!0,clipWindow:"origin",squareRatio:.5*(1+Math.sqrt(5)),root:null,visualDimension:0,zoomToNodeRatio:.1024,roam:!0,nodeClick:"zoomToNode",animation:!0,animationDurationUpdate:1500,animationEasing:"quinticInOut",breadcrumb:{show:!0,height:22,left:"center",top:"bottom",emptyItemWidth:25,itemStyle:{normal:{color:"rgba(0,0,0,0.7)",borderColor:"rgba(255,255,255,0.7)",borderWidth:1,shadowColor:"rgba(150,150,150,1)",shadowBlur:3,shadowOffsetX:0,shadowOffsetY:0,textStyle:{color:"#fff"}},emphasis:{textStyle:{}}}},label:{normal:{show:!0,position:["50%","50%"],textStyle:{align:"center",baseline:"middle",color:"#fff",ellipsis:!0}}},itemStyle:{normal:{color:null,colorAlpha:null,colorSaturation:null,borderWidth:0,gapWidth:0,borderColor:"#fff",borderColorSaturation:null},emphasis:{}},color:"none",colorAlpha:null,colorSaturation:null,colorMappingBy:"index",visibleMin:10,childrenVisibleMin:null,levels:[]},getInitialData:function(t,e){var i=t.data||[],o=t.name;null==o&&(o=t.name);var l={name:o,children:t.data},h=(i[0]||{}).value;n(l,s.isArray(h)?h.length:-1);var u=t.levels||[];return u=t.levels=a(u,e),r.createTree(l,this,u).data},getViewRoot:function(){var t=this.option.root,e=this.getData().tree.root;return t&&e.getNodeById(t)||e},formatTooltip:function(t){var e=this.getData(),i=this.getRawValue(t),n=c(s.isArray(i)?i[0]:i),a=e.getName(t);return u(a)+": "+n},getDataParams:function(t){for(var e=o.prototype.getDataParams.apply(this,arguments),i=this.getData(),n=i.tree.getNodeByDataIndex(t),a=e.treePathInfo=[];n;){var r=n.dataIndex;a.push({name:n.name,dataIndex:r,value:this.getRawValue(r)}),n=n.parentNode}return a.reverse(),e},setLayoutInfo:function(t){this.layoutInfo=this.layoutInfo||{},s.extend(this.layoutInfo,t)},mapIdToIndex:function(t){var e=this._idIndexMap;e||(e=this._idIndexMap={},this._idIndexMapCount=0);var i=e[t];return null==i&&(e[t]=i=this._idIndexMapCount++),i}})},function(t,e,i){function n(){return{nodeGroup:[],background:[],content:[]}}var a=i(1),o=i(3),r=i(52),s=i(209),l=i(290),h=i(70),u=i(8),c=i(19),d=i(345),f=a.bind,p=o.Group,g=o.Rect,m=a.each,v=3;t.exports=i(2).extendChartView({type:"treemap",init:function(t,e){this._containerGroup,this._storage=n(),this._oldTree,this._breadcrumb,this._controller,this._state="ready",this._mayClick},render:function(t,e,i,n){var o=e.findComponents({mainType:"series",subType:"treemap",query:n});if(!(a.indexOf(o,t)<0)){this.seriesModel=t,this.api=i,this.ecModel=e;var r=n&&n.type,l=t.layoutInfo,h=!this._oldTree,u=this._giveContainerGroup(l),c=this._doRender(u,t);h||r&&"treemapZoomToNode"!==r?c.renderFinally():this._doAnimation(u,c,t),this._resetController(i);var d=s.retrieveTargetInfo(n,t);this._renderBreadcrumb(t,i,d)}},_giveContainerGroup:function(t){var e=this._containerGroup;return e||(e=this._containerGroup=new p,this._initEvents(e),this.group.add(e)),e.position=[t.x,t.y],e},_doRender:function(t,e){function i(t,e,n,o,s){function l(t){return t.getId()}function h(a,r){var l=null!=a?t[a]:null,h=null!=r?e[r]:null,u=s||l===x;u||(l=null);var c=y(l,h,n);c&&i(l&&l.viewChildren||[],h&&h.viewChildren||[],c,o,u)}o?(e=t,m(t,function(t,e){!t.isRemoved()&&h(e,e)})):new r(e,t,l,l).add(h).update(h).remove(a.curry(h,null)).execute()}function o(t){var e=n();return t&&m(t,function(t,i){var n=e[i];m(t,function(t){t&&(n.push(t),t.__tmWillDelete=i)})}),e}function s(){m(v,function(t){m(t,function(t){t.parent&&t.parent.remove(t)})}),m(p,function(t){t.invisible=!0}),m(g,function(t){t.invisible=!1,t.__tmWillVisible=!1,t.dirty()})}var l=e.getData().tree,h=this._oldTree,u=n(),c=n(),d=this._storage,p=[],g=[],v=[],y=f(this._renderNode,this,c,d,u,p,g),x=e.getViewRoot();i(l.root?[l.root]:[],h&&h.root?[h.root]:[],t,l===h||!h,x===l.root);var v=o(d);return this._oldTree=l,this._storage=c,{lastsForAnimation:u,willDeleteEls:v,renderFinally:s}},_renderNode:function(t,e,i,n,o,r,s,l){function h(n,a){var o=null!=m&&e[n][m],r=i[n];return o?(e[n][m]=null,u(r,o,n)):_||(o=new a,c(r,o,n)),t[n][f]=o}function u(t,e,i){var n=t[f]={};n.old="nodeGroup"===i?e.position.slice():a.extend({},e.shape)}function c(t,e,n){if("background"===n)e.invisible=!0,e.__tmWillVisible=!0,o.push(e);else{var a,s=r.parentNode,l=0,h=0;s&&(a=i.background[s.getRawIndex()])&&(l=a.old.width,h=a.old.height);var u=t[f]={};u.old="nodeGroup"===n?[l,h]:{x:l,y:h,width:0,height:0},u.fadein="nodeGroup"!==n}}function d(t,e){_?!t.invisible&&n.push(t):(t.setStyle(e),t.__tmWillVisible||(t.invisible=!1))}var f=r&&r.getRawIndex(),m=s&&s.getRawIndex();if(r){var v=r.getLayout(),y=v.width,x=v.height,_=v.invisible,w=h("nodeGroup",p);if(w){l.add(w),w.position=[v.x,v.y],w.__tmNodeWidth=y,w.__tmNodeHeight=x;var b=h("background",g);b&&(b.setShape({x:0,y:0,width:y,height:x}),d(b,{fill:r.getVisual("borderColor",!0)}),w.add(b));var S=r.viewChildren;if(!S||!S.length){var M=v.borderWidth,A=h("content",g);if(A){var I=Math.max(y-2*M,0),T=Math.max(x-2*M,0),C=r.getModel("label.normal"),L=r.getModel("label.normal.textStyle"),D=r.getModel().get("name"),P=L.getTextRect(D),k=C.get("show");!k||P.height>T?D="":P.width>I&&(D=L.get("ellipsis")?L.ellipsis(D,I):""),A.dataIndex=r.dataIndex,A.seriesIndex=this.seriesModel.seriesIndex,A.culling=!0,A.setShape({x:M,y:M,width:I,height:T}),d(A,{fill:r.getVisual("color",!0),text:D,textPosition:C.get("position"),textFill:L.getTextColor(),textAlign:L.get("align"),textVerticalAlign:L.get("baseline"),textFont:L.getFont()}),w.add(A)}}return w}}},_doAnimation:function(t,e,i){if(i.get("animation")){var n=i.get("animationDurationUpdate"),o=i.get("animationEasing"),r=d.createWrap(),s=this.seriesModel.getViewRoot(),l=this._storage.nodeGroup[s.getRawIndex()];l&&l.traverse(function(t){var e;if(!t.invisible&&(e=t.__tmWillDelete)){var i=0,a=0,s=t.parent;s.__tmWillDelete||(i=s.__tmNodeWidth,a=s.__tmNodeHeight);var l="nodeGroup"===e?{position:[i,a],style:{opacity:0}}:{shape:{x:i,y:a,width:0,height:0},style:{opacity:0}};r.add(t,l,n,o)}}),m(this._storage,function(t,i){m(t,function(t,s){var l,h=e.lastsForAnimation[i][s];h&&("nodeGroup"===i?(l={position:t.position.slice()},t.position=h.old):(l={shape:a.extend({},t.shape)},t.setShape(h.old),h.fadein?(t.setStyle("opacity",0),l.style={opacity:1}):1!==t.style.opacity&&(l.style={opacity:1})),r.add(t,l,n,o))})},this),this._state="animating",r.done(f(function(){this._state="ready",e.renderFinally()},this)).start()}},_resetController:function(t){var e=this._controller;e||(e=this._controller=new h(t.getZr()),e.enable(this.seriesModel.get("roam")),e.on("pan",f(this._onPan,this)),e.on("zoom",f(this._onZoom,this))),e.rect=new u(0,0,t.getWidth(),t.getHeight())},_clearController:function(){var t=this._controller;t&&(t.off("pan").off("zoom"),t=null)},_onPan:function(t,e){if(this._mayClick=!1,"animating"!==this._state&&(Math.abs(t)>v||Math.abs(e)>v)){var i=this.seriesModel.getViewRoot();if(!i)return;var n=i.getLayout();if(!n)return;this.api.dispatchAction({type:"treemapMove",from:this.uid,seriesId:this.seriesModel.id,rootRect:{x:n.x+t,y:n.y+e,width:n.width,height:n.height}})}},_onZoom:function(t,e,i){if(this._mayClick=!1,"animating"!==this._state){var n=this.seriesModel.getViewRoot();if(!n)return;var a=n.getLayout();if(!a)return;var o=new u(a.x,a.y,a.width,a.height),r=this.seriesModel.layoutInfo;e-=r.x,i-=r.y;var s=c.create();c.translate(s,s,[-e,-i]),c.scale(s,s,[t,t]),c.translate(s,s,[e,i]),o.applyTransform(s),this.api.dispatchAction({type:"treemapRender",from:this.uid,seriesId:this.seriesModel.id,rootRect:{x:o.x,y:o.y,width:o.width,height:o.height}})}},_initEvents:function(t){function e(t){var e=this.seriesModel.get("nodeClick",!0);if(e){var i=this.findTarget(t.offsetX,t.offsetY);if(i)if("zoomToNode"===e)this._zoomToNode(i);else if("link"===e){var n=i.node,a=n.hostTree.data.getItemModel(n.dataIndex),o=a.get("link",!0),r=a.get("target",!0)||"blank";o&&window.open(o,r)}}}t.on("mousedown",function(t){"ready"===this._state&&(this._mayClick=!0)},this),t.on("mouseup",function(t){this._mayClick&&(this._mayClick=!1,"ready"===this._state&&e.call(this,t))},this)},_renderBreadcrumb:function(t,e,i){function n(t){this._zoomToNode({node:t})}i||(i=this.findTarget(e.getWidth()/2,e.getHeight()/2),i||(i={node:t.getData().tree.root})),(this._breadcrumb||(this._breadcrumb=new l(this.group,f(n,this)))).render(t,e,i.node)},remove:function(){this._clearController(),this._containerGroup&&this._containerGroup.removeAll(),this._storage=n(),this._state="ready",this._breadcrumb&&this._breadcrumb.remove()},dispose:function(){this._clearController()},_zoomToNode:function(t){this.api.dispatchAction({type:"treemapZoomToNode",from:this.uid,seriesId:this.seriesModel.id,targetNode:t.node})},findTarget:function(t,e){var i,n=this.seriesModel.getViewRoot();return n.eachNode({attr:"viewChildren",order:"preorder"},function(n){var a=this._storage.background[n.getRawIndex()];if(a){var o=a.transformCoordToLocal(t,e),r=a.shape;if(!(r.x<=o[0]&&o[0]<=r.x+r.width&&r.y<=o[1]&&o[1]<=r.y+r.height))return!1;i={node:n,offsetX:o[0],offsetY:o[1]}}},this),i}})},function(t,e,i){var n=i(2),a=function(){};n.registerAction({type:"treemapZoomToNode",update:"updateView"},a),n.registerAction({type:"treemapRender",update:"updateView"},a),n.registerAction({type:"treemapMove",update:"updateView"},a)},function(t,e,i){function n(t,e,i){var n={mainType:"series",subType:"treemap",query:i};t.eachComponent(n,function(t){var n=e.getWidth(),o=e.getHeight(),r=t.get("size")||[],s=x(_(t.get("width"),r[0]),n),l=x(_(t.get("height"),r[1]),o),h=y.getLayoutRect(t.getBoxLayoutParams(),{width:e.getWidth(),height:e.getHeight()}),u=i&&i.type,p=b.retrieveTargetInfo(i,t),g="treemapRender"===u||"treemapMove"===u?i.rootRect:null,m=t.getViewRoot();if("treemapMove"!==u){var v="treemapZoomToNode"===u?c(t,p,s,l):g?[g.width,g.height]:[s,l],S=t.get("sort");S&&"asc"!==S&&"desc"!==S&&(S="desc");var M={squareRatio:t.get("squareRatio"),sort:S};m.setLayout({x:0,y:0,width:v[0],height:v[1],area:v[0]*v[1]}),a(m,M)}m.setLayout(d(h,g,p),!0),t.setLayoutInfo(h),f(m,new w(-h.x,-h.y,n,o))})}function a(t,e){var i,n;if(!t.isRemoved()){var r=t.getLayout();i=r.width,n=r.height;var s=t.getModel("itemStyle.normal"),l=s.get("borderWidth"),c=s.get("gapWidth")/2,d=l-c,f=t.getModel();t.setLayout({borderWidth:l},!0),i=p(i-2*d,0),n=p(n-2*d,0);var v=i*n,y=o(t,f,v,e);if(y.length){var x={x:d,y:d,width:i,height:n},_=g(i,n),w=1/0,b=[];b.area=0;for(var S=0,M=y.length;M>S;){var A=y[S];b.push(A),b.area+=A.getLayout().area;var I=h(b,_,e.squareRatio);w>=I?(S++,w=I):(b.area-=b.pop().getLayout().area,u(b,_,x,c,!1),_=g(x.width,x.height),b.length=b.area=0,w=1/0)}b.length&&u(b,_,x,c,!0);var T;if(!e.hideChildren){var C=f.get("childrenVisibleMin");null!=C&&C>v&&(T=!0)}for(var S=0,M=y.length;M>S;S++){var L=m.extend({hideChildren:T},e);a(y[S],L)}}}}function o(t,e,i,n){var a=t.children||[],o=n.sort;if("asc"!==o&&"desc"!==o&&(o=null),n.hideChildren)return t.viewChildren=[];a=m.filter(a,function(t){return!t.isRemoved()}),s(a,o);var h=l(e,a,o);if(0===h.sum)return t.viewChildren=[];if(h.sum=r(e,i,h.sum,o,a),0===h.sum)return t.viewChildren=[];for(var u=0,c=a.length;c>u;u++){var d=a[u].getValue()/h.sum*i;a[u].setLayout({area:d})}return t.viewChildren=a,t.setLayout({dataExtent:h.dataExtent},!0),a}function r(t,e,i,n,a){if(!n)return i;for(var o=t.get("visibleMin"),r=a.length,s=r,l=r-1;l>=0;l--){var h=a["asc"===n?r-l-1:l].getValue();o>h/i*e&&(s=l,i-=h)}return"asc"===n?a.splice(0,r-s):a.splice(s,r-s),i}function s(t,e){return e&&t.sort(function(t,i){return"asc"===e?t.getValue()-i.getValue():i.getValue()-t.getValue()}),t}function l(t,e,i){for(var n=0,a=0,o=e.length;o>a;a++)n+=e[a].getValue();var r,s=t.get("visualDimension");if(e&&e.length)if("value"===s&&i)r=[e[e.length-1].getValue(),e[0].getValue()],"asc"===i&&r.reverse();else{var r=[1/0,-(1/0)];m.each(e,function(t){var e=t.getValue(s);er[1]&&(r[1]=e)})}else r=[NaN,NaN];return{sum:n,dataExtent:r}}function h(t,e,i){for(var n,a=0,o=1/0,r=0,s=t.length;s>r;r++)n=t[r].getLayout().area,n&&(o>n&&(o=n),n>a&&(a=n));var l=t.area*t.area,h=e*e*i;return l?p(h*a/l,l/(h*o)):1/0}function u(t,e,i,n,a){var o=e===i.width?0:1,r=1-o,s=["x","y"],l=["width","height"],h=i[s[o]],u=e?t.area/e:0;(a||u>i[l[r]])&&(u=i[l[r]]);for(var c=0,d=t.length;d>c;c++){var f=t[c],m={},v=u?f.getLayout().area/u:0,y=m[l[r]]=p(u-2*n,0),x=i[s[o]]+i[l[o]]-h,_=c===d-1||v>x?x:v,w=m[l[o]]=p(_-2*n,0);m[s[r]]=i[s[r]]+g(n,y/2),m[s[o]]=h+g(n,w/2),h+=_,f.setLayout(m,!0)}i[s[r]]+=u,i[l[r]]-=u}function c(t,e,i,n){var a=(e||{}).node,o=[i,n];if(!a||a===t.getViewRoot())return o;for(var r,s=i*n,l=s*t.get("zoomToNodeRatio");r=a.parentNode;){for(var h=0,u=r.children,c=0,d=u.length;d>c;c++)h+=u[c].getValue();var f=a.getValue();if(0===f)return o;l*=h/f;var p=r.getModel("itemStyle.normal").get("borderWidth");isFinite(p)&&(l+=4*p*p+4*p*Math.pow(l,.5)),l>v.MAX_SAFE_INTEGER&&(l=v.MAX_SAFE_INTEGER),a=r}s>l&&(l=s);var g=Math.pow(l/s,.5);return[i*g,n*g]}function d(t,e,i){if(e)return{x:e.x,y:e.y};var n={x:0,y:0};if(!i)return n;var a=i.node,o=a.getLayout();if(!o)return n;for(var r=[o.width/2,o.height/2],s=a;s;){var l=s.getLayout();r[0]+=l.x,r[1]+=l.y,s=s.parentNode}return{x:t.width/2-r[0],y:t.height/2-r[1]}}function f(t,e){var i=t.getLayout();t.setLayout({invisible:!e.intersect(i)},!0);for(var n=t.viewChildren||[],a=0,o=n.length;o>a;a++){var r=new w(e.x-i.x,e.y-i.y,e.width,e.height);f(n[a],r)}}var p=Math.max,g=Math.min,m=i(1),v=i(4),y=i(11),x=v.parsePercent,_=m.retrieve,w=i(8),b=i(209);t.exports=n},function(t,e,i){function n(t,e,i,s,h,c){var d=t.getModel(),p=t.getLayout();if(!p.invisible){var m,v=t.getModel(g),y=i[t.depth],x=a(v,e,y,s),_=v.get("borderColor"),w=v.get("borderColorSaturation");null!=w&&(m=o(x,t),_=r(w,m)),t.setVisual("borderColor",_);var b=t.viewChildren;if(b&&b.length){var S=l(t,d,p,v,x,b);f.each(b,function(t,e){if(t.depth>=h.length||t===h[t.depth]){var a=u(d,x,t,e,S,c);n(t,a,i,s,h,c)}})}else m=o(x,t),t.setVisual("color",m)}}function a(t,e,i,n){var a=f.extend({},e);return f.each(["color","colorAlpha","colorSaturation"],function(o){var r=t.get(o,!0);null==r&&i&&(r=i[o]),null==r&&(r=e[o]),null==r&&(r=n.get(o)),null!=r&&(a[o]=r)}),a}function o(t){var e=s(t,"color");if(e){var i=s(t,"colorAlpha"),n=s(t,"colorSaturation");return n&&(e=d.modifyHSL(e,null,null,n)),i&&(e=d.modifyAlpha(e,i)),e}}function r(t,e){return null!=e?d.modifyHSL(e,null,null,t):null}function s(t,e){var i=t[e];return null!=i&&"none"!==i?i:void 0}function l(t,e,i,n,a,o){if(o&&o.length){var r=h(e,"color")||null!=a.color&&"none"!==a.color&&(h(e,"colorAlpha")||h(e,"colorSaturation"));if(r){var s=e.get("colorMappingBy"),l={type:r.name,dataExtent:i.dataExtent,visual:r.range};"color"!==l.type||"index"!==s&&"id"!==s?l.mappingMethod="linear":(l.mappingMethod="category",l.loop=!0);var u=new c(l);return u.__drColorMappingBy=s,u}}}function h(t,e){var i=t.get(e);return p(i)&&i.length?{name:e,range:i}:null}function u(t,e,i,n,a,o){var r=f.extend({},e);if(a){var s=a.type,l="color"===s&&a.__drColorMappingBy,h="index"===l?n:"id"===l?o.mapIdToIndex(i.getId()):i.getValue(t.get("visualDimension"));r[s]=a.mapValueToVisual(h)}return r}var c=i(73),d=i(22),f=i(1),p=f.isArray,g="itemStyle.normal";t.exports=function(t,e){var i={mainType:"series",subType:"treemap",query:e};t.eachComponent(i,function(t){var e=t.getData().tree,i=e.root,a=t.getModel(g);if(!i.isRemoved()){var o=f.map(e.levelModels,function(t){return t?t.get(g):null});n(i,{},o,a,t.getViewRoot().getAncestors(),t)}})}},function(t,e,i){"use strict";i(199),i(297)},function(t,e,i){"use strict";function n(t,e,i,n){var a=t.coordToPoint([e,n]),o=t.coordToPoint([i,n]);return{x1:a[0],y1:a[1],x2:o[0],y2:o[1]}}var a=i(1),o=i(3),r=i(12),s=["axisLine","axisLabel","axisTick","splitLine","splitArea"];i(2).extendComponentView({type:"angleAxis",render:function(t,e){if(this.group.removeAll(),t.get("show")){var i=e.getComponent("polar",t.get("polarIndex")),n=t.axis,o=i.coordinateSystem,r=o.getRadiusAxis().getExtent(),l=n.getTicksCoords();"category"!==n.type&&l.pop(),a.each(s,function(e){t.get(e+".show")&&this["_"+e](t,o,l,r)},this)}},_axisLine:function(t,e,i,n){var a=t.getModel("axisLine.lineStyle"),r=new o.Circle({shape:{cx:e.cx,cy:e.cy,r:n[1]},style:a.getLineStyle(),z2:1,silent:!0});r.style.fill=null,this.group.add(r)},_axisTick:function(t,e,i,r){var s=t.getModel("axisTick"),l=(s.get("inside")?-1:1)*s.get("length"),h=a.map(i,function(t){return new o.Line({shape:n(e,r[1],r[1]+l,t)})});this.group.add(o.mergePath(h,{style:s.getModel("lineStyle").getLineStyle()}))},_axisLabel:function(t,e,i,n){for(var a=t.axis,s=t.get("data"),l=t.getModel("axisLabel"),h=l.getModel("textStyle"),u=t.getFormattedLabels(),c=l.get("margin"),d=a.getLabelsCoords(),f=0;fm?"left":"right",x=Math.abs(g[1]-v)/p<.3?"middle":g[1]>v?"top":"bottom",_=h;s&&s[f]&&s[f].textStyle&&(_=new r(s[f].textStyle,h)),this.group.add(new o.Text({style:{x:g[0],y:g[1],fill:_.getTextColor(),text:u[f],textAlign:y,textVerticalAlign:x,textFont:_.getFont()},silent:!0}))}},_splitLine:function(t,e,i,r){var s=t.getModel("splitLine"),l=s.getModel("lineStyle"),h=l.get("color"),u=0;h=h instanceof Array?h:[h];for(var c=[],d=0;d0)},c),f=new o(t,d);a.each(s,f.add,f);var p=f.getGroup();this.group.add(p),this._buildSelectController(p,h,t,i)}},_buildSelectController:function(t,e,i,n){var o=i.axis,s=this._selectController;s||(s=this._selectController=new r("line",n.getZr(),e),s.on("selected",a.bind(this._onSelected,this))),s.enable(t);var l=a.map(i.activeIntervals,function(t){return[o.dataToCoord(t[0],!0),o.dataToCoord(t[1],!0)]});s.update(l)},_onSelected:function(t){var e=this.axisModel,i=e.axis,n=a.map(t,function(t){return[i.coordToData(t[0],!0),i.coordToData(t[1],!0)]});this.api.dispatchAction({type:"axisAreaSelect",parallelAxisId:e.id,intervals:n})},remove:function(){this._selectController&&this._selectController.disable()},dispose:function(){this._selectController&&(this._selectController.dispose(),this._selectController=null)}});t.exports=l},function(t,e,i){"use strict";function n(t,e,i){return{position:[t.cx,t.cy],rotation:i/180*Math.PI,labelDirection:-1,tickDirection:-1,nameDirection:1,labelRotation:e.getModel("axisLabel").get("rotate"),z2:1}}var a=i(1),o=i(3),r=i(48),s=["axisLine","axisLabel","axisTick","axisName"],l=["splitLine","splitArea"];i(2).extendComponentView({type:"radiusAxis",render:function(t,e){if(this.group.removeAll(),t.get("show")){var i=e.getComponent("polar",t.get("polarIndex")),o=i.coordinateSystem.getAngleAxis(),h=t.axis,u=i.coordinateSystem,c=h.getTicksCoords(),d=o.getExtent()[0],f=h.getExtent(),p=n(u,t,d),g=new r(t,p);a.each(s,g.add,g),this.group.add(g.getGroup()),a.each(l,function(e){t.get(e+".show")&&this["_"+e](t,u,d,f,c)},this)}},_splitLine:function(t,e,i,n,r){var s=t.getModel("splitLine"),l=s.getModel("lineStyle"),h=l.get("color"),u=0;h=h instanceof Array?h:[h];for(var c=[],d=0;d=w;w++){for(var A=[],I=0;I=0||"+"===i?"left":"right"},s={horizontal:i>=0||"+"===i?"top":"bottom",vertical:"middle"},l={horizontal:0,vertical:b/2},h="vertical"===a?o.height:o.width,u=t.getModel("controlStyle"),c=u.get("show"),d=c?u.get("itemSize"):0,f=c?u.get("itemGap"):0,p=d+f,g=t.get("label.normal.rotate")||0;g=g*b/180;var m,v,y,x,_=u.get("position",!0),c=u.get("show",!0),w=c&&u.get("showPlayBtn",!0),S=c&&u.get("showPrevBtn",!0),M=c&&u.get("showNextBtn",!0),A=0,I=h;return"left"===_||"bottom"===_?(w&&(m=[0,0],A+=p),S&&(v=[A,0],A+=p),M&&(y=[I-d,0],I-=p)):(w&&(m=[I-d,0],I-=p),S&&(v=[0,0],A+=p),M&&(y=[I-d,0],I-=p)),x=[A,I],t.get("inverse")&&x.reverse(),{viewRect:o,mainLength:h,orient:a,rotation:l[a],labelRotation:g,labelPosOpt:i,labelAlign:r[a],labelBaseline:s[a],playPosition:m,prevBtnPosition:v,nextBtnPosition:y,axisExtent:x,controlSize:d,controlGap:f}},_position:function(t,e){function i(t){var e=t.position;t.origin=[c[0][0]-e[0],c[1][0]-e[1]]}function n(t){return[[t.x,t.x+t.width],[t.y,t.y+t.height]]}function a(t,e,i,n,a){t[n]+=i[n][a]-e[n][a]}var o=this._mainGroup,r=this._labelGroup,s=t.viewRect;if("vertical"===t.orient){var l=g.create(),h=s.x,u=s.y+s.height;g.translate(l,l,[-h,-u]),g.rotate(l,l,-b/2),g.translate(l,l,[h,u]),s=s.clone(),s.applyTransform(l)}var c=n(s),d=n(o.getBoundingRect()),f=n(r.getBoundingRect()),p=o.position,m=r.position;m[0]=p[0]=c[0][0];var v=t.labelPosOpt;if(isNaN(v)){var y="+"===v?0:1;a(p,d,c,1,y),a(m,f,c,1,1-y)}else{var y=v>=0?0:1;a(p,d,c,1,y),m[1]=p[1]+v}o.position=p,r.position=m,o.rotation=r.rotation=t.rotation,i(o),i(r)},_createAxis:function(t,e){var i=e.getData(),n=e.get("axisType"),a=f.createScaleByModel(e,n),o=i.getDataExtent("value");a.setExtent(o[0],o[1]),this._customizeScale(a,i),a.niceTicks();var r=new c("value",a,t.axisExtent,n);return r.model=e,r},_customizeScale:function(t,e){t.getTicks=function(){return e.mapArray(["value"],function(t){return t})},t.getTicksLabels=function(){return s.map(this.getTicks(),t.getLabel,t)}},_createGroup:function(t){var e=this["_"+t]=new l.Group;return this.group.add(e),e},_renderAxisLine:function(t,e,i,n){var a=i.getExtent();n.get("lineStyle.show")&&e.add(new l.Line({shape:{x1:a[0],y1:0,x2:a[1],y2:0},style:s.extend({lineCap:"round"},n.getModel("lineStyle").getLineStyle()),silent:!0,z2:1}))},_renderAxisTick:function(t,e,i,n){var a=n.getData(),r=i.scale.getTicks(),s=this._prepareTooltipHostModel(a,n);w(r,function(t,n){var r=i.dataToCoord(t),h=a.getItemModel(n),u=h.getModel("itemStyle.normal"),c=h.getModel("itemStyle.emphasis"),d={position:[r,0],onclick:_(this._changeTimeline,this,n)},f=o(h,u,e,d);l.setHoverStyle(f,c.getItemStyle()),h.get("tooltip")?(f.dataIndex=n,f.hostModel=s):f.dataIndex=f.hostModel=null},this)},_prepareTooltipHostModel:function(t,e){var i=v.createDataFormatModel({},t,e.get("data")),n=this;return i.formatTooltip=function(t){return x(n._axis.scale.getLabel(t))},i},_renderAxisLabel:function(t,e,i,n){var a=n.getModel("label.normal");if(a.get("show")){var o=n.getData(),r=i.scale.getTicks(),s=f.getFormattedLabels(i,a.get("formatter")),h=i.getLabelInterval();w(r,function(n,a){if(!i.isLabelIgnored(a,h)){var r=o.getItemModel(a),u=r.getModel("label.normal.textStyle"),c=r.getModel("label.emphasis.textStyle"),d=i.dataToCoord(n),f=new l.Text({style:{text:s[a],textAlign:t.labelAlign,textVerticalAlign:t.labelBaseline,textFont:u.getFont(),fill:u.getTextColor()},position:[d,0],rotation:t.labelRotation-t.rotation,onclick:_(this._changeTimeline,this,a),silent:!1});e.add(f),l.setHoverStyle(f,c.getItemStyle())}},this)}},_renderControl:function(t,e,i,n){function o(t,i,o,d){if(t){var f={position:t,origin:[r/2,0],rotation:d?-s:0,rectHover:!0,style:h,onclick:o},p=a(n,i,c,f);e.add(p),l.setHoverStyle(p,u)}}var r=t.controlSize,s=t.rotation,h=n.getModel("controlStyle.normal").getItemStyle(),u=n.getModel("controlStyle.emphasis").getItemStyle(),c=[0,-r/2,r,r],d=n.getPlayState(),f=n.get("inverse",!0);o(t.nextBtnPosition,"controlStyle.nextIcon",_(this._changeTimeline,this,f?"-":"+")),o(t.prevBtnPosition,"controlStyle.prevIcon",_(this._changeTimeline,this,f?"+":"-")),o(t.playPosition,"controlStyle."+(d?"stopIcon":"playIcon"),_(this._handlePlayClick,this,!d),!0)},_renderCurrentPointer:function(t,e,i,n){var a=n.getData(),s=n.getCurrentIndex(),l=a.getItemModel(s).getModel("checkpointStyle"),h=this,u={onCreate:function(t){t.draggable=!0,t.drift=_(h._handlePointerDrag,h),t.ondragend=_(h._handlePointerDragend,h),r(t,s,i,n,!0)},onUpdate:function(t){r(t,s,i,n)}};this._currentPointer=o(l,l,this._mainGroup,{},this._currentPointer,u)},_handlePlayClick:function(t){this._clearTimer(),this.api.dispatchAction({type:"timelinePlayChange",playState:t,from:this.uid})},_handlePointerDrag:function(t,e,i){this._clearTimer(),this._pointerChangeTimeline([i.offsetX,i.offsetY])},_handlePointerDragend:function(t){this._pointerChangeTimeline([t.offsetX,t.offsetY],!0)},_pointerChangeTimeline:function(t,e){var i=this._toAxisCoord(t)[0],n=this._axis,a=m.asc(n.getExtent().slice());i>a[1]&&(i=a[1]),is&&(n=s,e=o)}),e},_clearTimer:function(){this._timer&&(clearTimeout(this._timer),this._timer=null)},_changeTimeline:function(t){var e=this.model.getCurrentIndex();"+"===t?t=e+1:"-"===t&&(t=e-1),this.api.dispatchAction({type:"timelineChange",currentIndex:t,from:this.uid})}})},function(t,e,i){var n=i(1),a=i(43),o=i(23),r=function(t,e,i,n){a.call(this,t,e,i),this.type=n||"value",this._autoLabelInterval,this.model=null};r.prototype={constructor:r,getLabelInterval:function(){var t=this.model,e=t.getModel("label.normal"),i=e.get("interval");if(null!=i&&"auto"!=i)return i;var i=this._autoLabelInterval;return i||(i=this._autoLabelInterval=o.getAxisLabelInterval(n.map(this.scale.getTicks(),this.dataToCoord,this),o.getFormattedLabels(this,e.get("formatter")),e.getModel("textStyle").getFont(),"horizontal"===t.get("orient"))),i},isLabelIgnored:function(t){if("category"===this.type){var e=this.getLabelInterval();return"function"==typeof e&&!e(t,this.scale.getLabel(t))||t%(e+1)}}},n.inherits(r,a),t.exports=r},function(t,e,i){var n=i(10),a=i(14),o=i(1),r=i(7),s=n.extend({type:"timeline",layoutMode:"box",defaultOption:{zlevel:0,z:4,show:!0,axisType:"time",realtime:!0,left:"20%",top:null,right:"20%",bottom:0,width:null,height:40,padding:5,controlPosition:"left",autoPlay:!1,rewind:!1,loop:!0,playInterval:2e3,currentIndex:0,itemStyle:{normal:{},emphasis:{}},label:{normal:{textStyle:{color:"#000"}},emphasis:{}},data:[]},init:function(t,e,i){this._data,this._names,this.mergeDefaultAndTheme(t,i),this._initData()},mergeOption:function(t){s.superApply(this,"mergeOption",arguments),this._initData()},setCurrentIndex:function(t){null==t&&(t=this.option.currentIndex);var e=this._data.count();this.option.loop?t=(t%e+e)%e:(t>=e&&(t=e-1),0>t&&(t=0)),this.option.currentIndex=t},getCurrentIndex:function(){return this.option.currentIndex},isIndexMax:function(){return this.getCurrentIndex()>=this._data.count()-1},setPlayState:function(t){this.option.autoPlay=!!t},getPlayState:function(){return!!this.option.autoPlay},_initData:function(){var t=this.option,e=t.data||[],i=t.axisType,n=this._names=[];if("category"===i){var s=[];o.each(e,function(t,e){var i,a=r.getDataItemValue(t);o.isObject(t)?(i=o.clone(t),i.value=e):i=e,s.push(i),o.isString(a)||null!=a&&!isNaN(a)||(a=""),n.push(a+"")}),e=s}var l={category:"ordinal",time:"time"}[i]||"number",h=this._data=new a([{name:"value",type:l}],this);h.initData(e,n)},getData:function(){return this._data},getCategories:function(){return"category"===this.get("axisType")?this._names.slice():void 0}});t.exports=s},function(t,e,i){var n=i(54);t.exports=n.extend({type:"timeline"})},function(t,e,i){function n(t){var e=t.type,i={number:"value",time:"time"};if(i[e]&&(t.axisType=i[e],delete t.type),a(t),o(t,"controlPosition")){var n=t.controlStyle||(t.controlStyle={});o(n,"position")||(n.position=t.controlPosition),"none"!==n.position||o(n,"show")||(n.show=!1,delete n.position),delete t.controlPosition}r.each(t.data||[],function(t){r.isObject(t)&&!r.isArray(t)&&(!o(t,"value")&&o(t,"name")&&(t.value=t.name),a(t))})}function a(t){var e=t.itemStyle||(t.itemStyle={}),i=e.emphasis||(e.emphasis={}),n=t.label||t.label||{},a=n.normal||(n.normal={}),s={normal:1,emphasis:1};r.each(n,function(t,e){s[e]||o(a,e)||(a[e]=t)}),i.label&&!o(n,"emphasis")&&(n.emphasis=i.label,delete i.label)}function o(t,e){return t.hasOwnProperty(e)}var r=i(1);t.exports=function(t){var e=t&&t.timeline;r.isArray(e)||(e=e?[e]:[]),r.each(e,function(t){t&&n(t)})}},function(t,e,i){var n=i(2);n.registerAction({type:"timelineChange",event:"timelineChanged",update:"prepareAndUpdate"},function(t,e){var i=e.getComponent("timeline");i&&null!=t.currentIndex&&(i.setCurrentIndex(t.currentIndex),!i.get("loop",!0)&&i.isIndexMax()&&i.setPlayState(!1)),e.resetOption("timeline")}),n.registerAction({type:"timelinePlayChange",event:"timelinePlayChanged",update:"update"},function(t,e){var i=e.getComponent("timeline");i&&null!=t.playState&&i.setPlayState(t.playState)})},function(t,e,i){i(10).registerSubTypeDefaulter("timeline",function(){return"slider"})},function(t,e,i){i(322),i(323)},function(t,e,i){var n=i(212),a=i(1),o=i(4),r=[20,140],s=n.extend({type:"visualMap.continuous",defaultOption:{handlePosition:"auto",calculable:!1,range:[-(1/0),1/0],hoverLink:!0,realtime:!0,itemWidth:null,itemHeight:null},doMergeOption:function(t,e){s.superApply(this,"doMergeOption",arguments),this.resetTargetSeries(t,e),this.resetExtent(),this.resetVisual(function(t){t.mappingMethod="linear"}),this._resetRange()},resetItemSize:function(){n.prototype.resetItemSize.apply(this,arguments);var t=this.itemSize;"horizontal"===this._orient&&t.reverse(),(null==t[0]||isNaN(t[0]))&&(t[0]=r[0]),(null==t[1]||isNaN(t[1]))&&(t[1]=r[1])},_resetRange:function(){var t=this.getExtent(),e=this.option.range;e[0]>e[1]&&e.reverse(),e[0]=Math.max(e[0],t[0]),e[1]=Math.min(e[1],t[1])},completeVisualOption:function(){n.prototype.completeVisualOption.apply(this,arguments),a.each(this.stateList,function(t){var e=this.option.controller[t].symbolSize;e&&e[0]!==e[1]&&(e[0]=0)},this)},setSelected:function(t){this.option.range=t.slice(),this._resetRange()},getSelected:function(){var t=this.getExtent(),e=o.asc((this.get("range")||[]).slice());return e[0]>t[1]&&(e[0]=t[1]),e[1]>t[1]&&(e[1]=t[1]),e[0]=i[1]||t<=e[1])?"inRange":"outOfRange"}});t.exports=s},function(t,e,i){function n(t,e,i){return new r.Polygon({shape:{points:t},draggable:!!e,cursor:i,drift:e})}function a(t,e){return 0===t?[[0,0],[e,0],[e,-e]]:[[0,0],[e,0],[e,e]]}var o=i(213),r=i(3),s=i(1),l=i(4),h=i(71),u=l.linearMap,c=i(76),d=i(214),f=s.each,p=o.extend({type:"visualMap.continuous",init:function(){o.prototype.init.apply(this,arguments),this._shapes={},this._dataInterval=[],this._handleEnds=[],this._orient,this._useHandle},doRender:function(t,e,i,n){n&&"selectDataRange"===n.type&&n.from===this.uid?this._updateView():this._buildView()},_buildView:function(){this.group.removeAll();var t=this.visualMapModel,e=this.group;this._orient=t.get("orient"),this._useHandle=t.get("calculable"),this._resetInterval(),this._renderBar(e);var i=t.get("text");this._renderEndsText(e,i,0),this._renderEndsText(e,i,1),this._updateView(!0),this.renderBackground(e),this._updateView(),this.positionGroup(e)},_renderEndsText:function(t,e,i){if(e){var n=e[1-i];n=null!=n?n+"":"";var a=this.visualMapModel,o=a.get("textGap"),s=a.itemSize,l=this._shapes.barGroup,h=this._applyTransform([s[0]/2,0===i?-o:s[1]+o],l),u=this._applyTransform(0===i?"bottom":"top",l),c=this._orient,d=this.visualMapModel.textStyleModel;this.group.add(new r.Text({style:{x:h[0],y:h[1],textVerticalAlign:"horizontal"===c?"middle":u,textAlign:"horizontal"===c?u:"center",text:n,textFont:d.getFont(),fill:d.getTextColor()}}))}},_renderBar:function(t){var e=this.visualMapModel,i=this._shapes,a=e.itemSize,o=this._orient,r=this._useHandle,l=d.getItemAlign(e,this.api,a),h=i.barGroup=this._createBarGroup(l);h.add(i.outOfRange=n()),h.add(i.inRange=n(null,s.bind(this._modifyHandle,this,"all"),r?"move":null));var u=e.textStyleModel.getTextRect("国"),c=Math.max(u.width,u.height);r&&(i.handleGroups=[],i.handleThumbs=[],i.handleLabels=[],i.handleLabelPoints=[],this._createHandle(h,0,a,c,o,l),this._createHandle(h,1,a,c,o,l)),t.add(h)},_createHandle:function(t,e,i,o,l){var h=new r.Group({position:[i[0],0]}),u=n(a(e,o),s.bind(this._modifyHandle,this,e),"move");h.add(u);var c={x:"horizontal"===l?o/2:1.5*o,y:"horizontal"===l?0===e?-(1.5*o):1.5*o:0===e?-o/2:o/2},d=this.visualMapModel.textStyleModel,f=new r.Text({silent:!0,style:{x:0,y:0,text:"",textVerticalAlign:"middle",textFont:d.getFont(),fill:d.getTextColor()}});this.group.add(f);var p=this._shapes;p.handleThumbs[e]=u,p.handleGroups[e]=h,p.handleLabelPoints[e]=c,p.handleLabels[e]=f,t.add(h)},_modifyHandle:function(t,e,i){if(this._useHandle){var n=this._applyTransform([e,i],this._shapes.barGroup,!0);this._updateInterval(t,n[1]),this.api.dispatchAction({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:this._dataInterval.slice()})}},_resetInterval:function(){var t=this.visualMapModel,e=this._dataInterval=t.getSelected(),i=t.getExtent(),n=[0,t.itemSize[1]];this._handleEnds=[u(e[0],i,n,!0),u(e[1],i,n,!0)]},_updateInterval:function(t,e){e=e||0;var i=this.visualMapModel,n=this._handleEnds;h(e,n,[0,i.itemSize[1]],"all"===t?"rigid":"push",t);var a=i.getExtent(),o=[0,i.itemSize[1]];this._dataInterval=[u(n[0],o,a,!0),u(n[1],o,a,!0)]},_updateView:function(t){var e=this.visualMapModel,i=e.getExtent(),n=this._shapes,a=this._dataInterval,o=[0,e.itemSize[1]],r=t?o:this._handleEnds,s=this._createBarVisual(a,i,r,"inRange"),l=this._createBarVisual(i,i,o,"outOfRange");n.inRange.setStyle("fill",s.barColor).setShape("points",s.barPoints),n.outOfRange.setStyle("fill",l.barColor).setShape("points",l.barPoints),this._useHandle&&f([0,1],function(t){n.handleThumbs[t].setStyle("fill",s.handlesColor[t]),n.handleLabels[t].setStyle({text:e.formatValueText(a[t]),textAlign:this._applyTransform("horizontal"===this._orient?0===t?"bottom":"top":"left",n.barGroup)})},this),this._updateHandlePosition(r)},_createBarVisual:function(t,e,i,n){var a=this.getControllerVisual(t,n,"color").color,o=[this.getControllerVisual(t[0],n,"symbolSize").symbolSize,this.getControllerVisual(t[1],n,"symbolSize").symbolSize],r=this._createBarPoints(i,o);return{barColor:new c(0,0,1,1,a),barPoints:r,handlesColor:[a[0].color,a[a.length-1].color]}},_createBarPoints:function(t,e){var i=this.visualMapModel.itemSize;return[[i[0]-e[0],t[0]],[i[0],t[0]],[i[0],t[1]],[i[0]-e[1],t[1]]]},_createBarGroup:function(t){var e=this._orient,i=this.visualMapModel.get("inverse");return new r.Group("horizontal"!==e||i?"horizontal"===e&&i?{scale:"bottom"===t?[-1,1]:[1,1],rotation:-Math.PI/2}:"vertical"!==e||i?{scale:"left"===t?[1,1]:[-1,1]}:{scale:"left"===t?[1,-1]:[-1,-1]}:{scale:"bottom"===t?[1,1]:[-1,1],rotation:Math.PI/2})},_updateHandlePosition:function(t){if(this._useHandle){var e=this._shapes;f([0,1],function(i){var n=e.handleGroups[i];n.position[1]=t[i];var a=e.handleLabelPoints[i],o=r.applyTransform([a.x,a.y],r.getTransform(n,this.group));e.handleLabels[i].setStyle({x:o[0],y:o[1]})},this)}},_applyTransform:function(t,e,i){var n=r.getTransform(e,this.group);return r[s.isArray(t)?"applyTransform":"transformDirection"](t,n,i)}});t.exports=p},function(t,e,i){function n(t,e){var i=t.inverse;("vertical"===t.orient?!i:i)&&e.reverse()}var a=i(212),o=i(1),r=i(73),s=a.extend({type:"visualMap.piecewise",defaultOption:{selected:null,align:"auto",itemWidth:20,itemHeight:14,itemSymbol:"roundRect",pieceList:null,categories:null,splitNumber:5,selectedMode:"multiple",itemGap:10},doMergeOption:function(t,e){s.superApply(this,"doMergeOption",arguments),this._pieceList=[],this.resetTargetSeries(t,e),this.resetExtent();var i=this._mode=this._decideMode();l[this._mode].call(this),this._resetSelected(t,e);var n=this.option.categories;this.resetVisual(function(t,e){"categories"===i?(t.mappingMethod="category",t.categories=o.clone(n)):(t.mappingMethod="piecewise",t.pieceList=o.map(this._pieceList,function(t){var t=o.clone(t);return"inRange"!==e&&(t.visual=null),t}))})},_resetSelected:function(t,e){var i=this.option,n=this._pieceList,a=(e?i:t).selected||{};if(i.selected=a,o.each(n,function(t,e){var i=this.getSelectedMapKey(t);i in a||(a[i]=!0)},this),"single"===i.selectedMode){var r=!1;o.each(n,function(t,e){var i=this.getSelectedMapKey(t);a[i]&&(r?a[i]=!1:r=!0)},this)}},getSelectedMapKey:function(t){return"categories"===this._mode?t.value+"":t.index+""},getPieceList:function(){return this._pieceList},_decideMode:function(){var t=this.option;return t.pieces&&t.pieces.length>0?"pieces":this.option.categories?"categories":"splitNumber"},setSelected:function(t){this.option.selected=o.clone(t)},getValueState:function(t){var e=this._pieceList,i=r.findPieceIndex(t,e);return null!=i&&this.option.selected[this.getSelectedMapKey(e[i])]?"inRange":"outOfRange"}}),l={splitNumber:function(){var t=this.option,e=t.precision,i=this.getExtent(),n=t.splitNumber;n=Math.max(parseInt(n,10),1),t.splitNumber=n;for(var a=(i[1]-i[0])/n;+a.toFixed(e)!==a&&5>e;)e++;t.precision=e,a=+a.toFixed(e);for(var o=0,r=i[0];n>o;o++,r+=a){var s=o===n-1?i[1]:r+a;this._pieceList.push({text:this.formatValueText([r,s]),index:o,interval:[r,s]})}},categories:function(){var t=this.option;o.each(t.categories,function(t){this._pieceList.push({text:this.formatValueText(t,!0),value:t})},this),n(t,this._pieceList)},pieces:function(){var t=this.option;o.each(t.pieces,function(t,e){o.isObject(t)||(t={value:t});var i,n={text:"",index:e};if(null!=t.label&&(n.text=t.label,i=!0),t.hasOwnProperty("value"))n.value=t.value,i||(n.text=this.formatValueText(n.value));else{var a=t.min,s=t.max;null==a&&(a=-(1/0)),null==s&&(s=1/0),a===s&&(n.value=a),n.interval=[a,s],i||(n.text=this.formatValueText([a,s]))}n.visual=r.retrieveVisuals(t),this._pieceList.push(n)},this),n(t,this._pieceList)}};t.exports=s},function(t,e,i){var n=i(213),a=i(1),o=i(3),r=i(24),s=i(11),l=i(214),h=n.extend({type:"visualMap.piecewise",doRender:function(){function t(t){var i=new o.Group;i.onclick=a.bind(this._onItemClick,this,t.piece),this._createItemSymbol(i,t.piece,[0,0,c[0],c[1]]),f&&i.add(new o.Text({style:{x:"right"===u?-n:c[0]+n,y:c[1]/2,text:t.piece.text,textVerticalAlign:"middle",textAlign:u,textFont:l,fill:h}})),e.add(i)}var e=this.group;e.removeAll();var i=this.visualMapModel,n=i.get("textGap"),r=i.textStyleModel,l=r.getFont(),h=r.getTextColor(),u=this._getItemAlign(),c=i.itemSize,d=this._getViewData(),f=!d.endsText,p=!f;p&&this._renderEndsText(e,d.endsText[0],c),a.each(d.pieceList,t,this),p&&this._renderEndsText(e,d.endsText[1],c),s.box(i.get("orient"),e,i.get("itemGap")),this.renderBackground(e),this.positionGroup(e)},_getItemAlign:function(){var t=this.visualMapModel,e=t.option;if("vertical"===e.orient)return l.getItemAlign(t,this.api,t.itemSize);var i=e.align;return i&&"auto"!==i||(i="left"),i},_renderEndsText:function(t,e,i){if(e){var n=new o.Group,a=this.visualMapModel.textStyleModel;n.add(new o.Text({style:{x:i[0]/2,y:i[1]/2,textVerticalAlign:"middle",textAlign:"center",text:e,textFont:a.getFont(),fill:a.getTextColor()}})),t.add(n)}},_getViewData:function(){var t=this.visualMapModel,e=a.map(t.getPieceList(),function(t,e){return{piece:t,index:e}}),i=t.get("text"),n=t.get("orient"),o=t.get("inverse");return("horizontal"===n?o:!o)?e.reverse():i&&(i=i.slice().reverse()),{pieceList:e,endsText:i}},_createItemSymbol:function(t,e,i){var n;if(this.visualMapModel.isCategory())n=e.value;else if(null!=e.value)n=e.value;else{var a=e.interval||[];n=(a[0]+a[1])/2}var o=this.getControllerVisual(n);t.add(r.createSymbol(o.symbol,i[0],i[1],i[2],i[3],o.color))},_onItemClick:function(t){var e=this.visualMapModel,i=e.option,n=a.clone(i.selected),o=e.getSelectedMapKey(t);"single"===i.selectedMode?(n[o]=!0,a.each(n,function(t,e){n[e]=e===o})):n[o]=!n[o],this.api.dispatchAction({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:n})}});t.exports=h},function(t,e,i){i(2).registerPreprocessor(i(215)),i(216),i(217),i(318),i(319),i(218)},function(t,e,i){i(2).registerPreprocessor(i(215)),i(216),i(217),i(320),i(321),i(218)},function(t,e,i){function n(t,e,i,n,a){s.call(this,t),this.map=e,this._nameCoordMap={},this.loadGeoJson(i,n,a)}var a=i(329),o=i(1),r=i(8),s=i(219),l=[i(327),i(328),i(326)];n.prototype={constructor:n,type:"geo",dimensions:["lng","lat"],loadGeoJson:function(t,e,i){try{this.regions=t?a(t):[]}catch(n){throw"Invalid geoJson format\n"+n}e=e||{},i=i||{};for(var r=this.regions,s={},h=0;h>1^-(1&r),s=s>>1^-(1&s),r+=n,s+=a,n=r,a=s,i.push([r/1024,s/1024])}return i}function o(t){for(var e=[],i=0;i=0;i--)l.asc(e[i])},getActiveState:function(t){var e=this.activeIntervals;if(!e.length)return"normal";if(null==t)return"inactive";for(var i=0,n=e.length;n>i;i++)if(e[i][0]<=t&&t<=e[i][1])return"active";return"inactive"}}),u={type:"value",dim:null,parallelIndex:null,areaSelectStyle:{width:20,borderWidth:1,borderColor:"rgba(160,197,232)",color:"rgba(160,197,232)",opacity:.3},z:10};o.merge(h.prototype,i(49)),s("parallel",h,n,u),t.exports=h},function(t,e,i){function n(t,e,i){this._axesMap={},this._axesLayout={},this.dimensions=t.dimensions,this._rect,this._model=t,this._init(t,e,i)}var a=i(11),o=i(23),r=i(1),s=i(332),l=i(19),h=i(5),u=r.each,c=Math.PI;n.prototype={type:"parallel",constructor:n,_init:function(t,e,i){var n=t.dimensions,a=t.parallelAxisIndex;u(n,function(t,i){var n=a[i],r=e.getComponent("parallelAxis",n),l=this._axesMap[t]=new s(t,o.createScaleByModel(r),[0,0],r.get("type"),n),h="category"===l.type;l.onBand=h&&r.get("boundaryGap"),l.inverse=r.get("inverse"),r.axis=l,l.model=r},this)},update:function(t,e){this._updateAxesFromSeries(this._model,t)},_updateAxesFromSeries:function(t,e){e.eachSeries(function(i){if(t.contains(i,e)){var n=i.getData();u(this.dimensions,function(t){var e=this._axesMap[t];e.scale.unionExtent(n.getDataExtent(t)),o.niceScaleExtent(e,e.model)},this)}},this)},resize:function(t,e){this._rect=a.getLayoutRect(t.getBoxLayoutParams(),{width:e.getWidth(),height:e.getHeight()}),this._layoutAxes(t)},getRect:function(){return this._rect},_layoutAxes:function(t){var e=this._rect,i=t.get("layout"),n=this._axesMap,a=this.dimensions,o=[e.width,e.height],r="horizontal"===i?0:1,s=o[r],h=o[1-r],d=[0,h];u(n,function(t){var e=t.inverse?1:0;t.setExtent(d[e],d[1-e])}),u(a,function(t,n){var o=s*n/(a.length-1),r={horizontal:{x:o,y:h},vertical:{x:0,y:o}},u={horizontal:c/2,vertical:0},d=[r[i].x+e.x,r[i].y+e.y],f=u[i],p=l.create();l.rotate(p,p,f), +l.translate(p,p,d),this._axesLayout[t]={position:d,rotation:f,transform:p,tickDirection:1,labelDirection:1}},this)},getAxis:function(t){return this._axesMap[t]},dataToPoint:function(t,e){return this.axisCoordToPoint(this._axesMap[e].dataToCoord(t),e)},eachActiveState:function(t,e,i){for(var n=this.dimensions,a=this._axesMap,o=!1,r=0,s=n.length;s>r;r++)"normal"!==a[n[r]].model.getActiveState()&&(o=!0);for(var l=0,h=t.count();h>l;l++){var u,c=t.getValues(n,l);if(o){u="active";for(var r=0,s=n.length;s>r;r++){var d=n[r],f=a[d].model.getActiveState(c[r],r);if("inactive"===f){u="inactive";break}}}else u="normal";e.call(i,u,l)}},axisCoordToPoint:function(t,e){var i=this._axesLayout[e],n=[t,0];return h.applyTransform(n,n,i.transform),n},getAxisLayout:function(t){return r.clone(this._axesLayout[t])}},t.exports=n},function(t,e,i){var n=i(1),a=i(43),o=function(t,e,i,n,o){a.call(this,t,e,i),this.type=n||"value",this.axisIndex=o};o.prototype={constructor:o,model:null},n.inherits(o,a),t.exports=o},function(t,e,i){var n=i(1),a=i(10);i(330),a.extend({type:"parallel",dependencies:["parallelAxis"],coordinateSystem:null,dimensions:null,parallelAxisIndex:null,defaultOption:{zlevel:0,z:0,left:80,top:60,right:80,bottom:60,layout:"horizontal",parallelAxisDefault:null},init:function(){a.prototype.init.apply(this,arguments),this.mergeOption({})},mergeOption:function(t){var e=this.option;t&&n.merge(e,t,!0),this._initDimensions()},contains:function(t,e){var i=t.get("parallelIndex");return null!=i&&e.getComponent("parallel",i)===this},_initDimensions:function(){var t=this.dimensions=[],e=this.parallelAxisIndex=[],i=n.filter(this.dependentModels.parallelAxis,function(t){return t.get("parallelIndex")===this.componentIndex});n.each(i,function(i){t.push("dim"+i.get("dim")),e.push(i.componentIndex)})}})},function(t,e,i){function n(t){if(!t.parallel){var e=!1;o.each(t.series,function(t){t&&"parallel"===t.type&&(e=!0)}),e&&(t.parallel=[{}])}}function a(t){var e=r.normalizeToArray(t.parallelAxis);o.each(e,function(e){if(o.isObject(e)){var i=e.parallelIndex||0,n=r.normalizeToArray(t.parallel)[i];n&&n.parallelAxisDefault&&o.merge(e,n.parallelAxisDefault,!1)}})}var o=i(1),r=i(7);t.exports=function(t){n(t),a(t)}},function(t,e,i){"use strict";function n(t,e){e=e||[0,360],o.call(this,"angle",t,e),this.type="category"}var a=i(1),o=i(43);n.prototype={constructor:n,dataToAngle:o.prototype.dataToCoord,angleToData:o.prototype.coordToData},a.inherits(n,o),t.exports=n},function(t,e,i){"use strict";function n(t,e){return e.type||(e.data?"category":"value")}var a=i(1),o=i(10),r=i(61),s=o.extend({type:"polarAxis",axis:null});a.merge(s.prototype,i(49));var l={angle:{polarIndex:0,startAngle:90,clockwise:!0,splitNumber:12,axisLabel:{rotate:!1}},radius:{polarIndex:0,splitNumber:5}};r("angle",s,n,l.angle),r("radius",s,n,l.radius)},function(t,e,i){"use strict";var n=i(339),a=i(335),o=function(t){this.name=t||"",this.cx=0,this.cy=0,this._radiusAxis=new n,this._angleAxis=new a};o.prototype={constructor:o,type:"polar",dimensions:["radius","angle"],containPoint:function(t){var e=this.pointToCoord(t);return this._radiusAxis.contain(e[0])&&this._angleAxis.contain(e[1])},containData:function(t){return this._radiusAxis.containData(t[0])&&this._angleAxis.containData(t[1])},getAxis:function(t){return this["_"+t+"Axis"]},getAxesByScale:function(t){var e=[],i=this._angleAxis,n=this._radiusAxis;return i.scale.type===t&&e.push(i),n.scale.type===t&&e.push(n),e},getAngleAxis:function(){return this._angleAxis},getRadiusAxis:function(){return this._radiusAxis},getOtherAxis:function(t){var e=this._angleAxis;return t===e?this._radiusAxis:e},getBaseAxis:function(){return this.getAxesByScale("ordinal")[0]||this.getAxesByScale("time")[0]||this.getAngleAxis()},dataToPoints:function(t){return t.mapArray(this.dimensions,function(t,e){return this.dataToPoint([t,e])},this)},dataToPoint:function(t,e){return this.coordToPoint([this._radiusAxis.dataToRadius(t[0],e),this._angleAxis.dataToAngle(t[1],e)])},pointToData:function(t,e){var i=this.pointToCoord(t);return[this._radiusAxis.radiusToData(i[0],e),this._angleAxis.angleToData(i[1],e)]},pointToCoord:function(t){var e=t[0]-this.cx,i=t[1]-this.cy,n=this.getAngleAxis(),a=n.getExtent(),o=Math.min(a[0],a[1]),r=Math.max(a[0],a[1]);n.inverse?o=r-360:r=o+360;var s=Math.sqrt(e*e+i*i);e/=s,i/=s;for(var l=Math.atan2(-i,e)/Math.PI*180,h=o>l?1:-1;o>l||l>r;)l+=360*h;return[s,l]},coordToPoint:function(t){var e=t[0],i=t[1]/180*Math.PI,n=Math.cos(i)*e+this.cx,a=-Math.sin(i)*e+this.cy;return[n,a]}},t.exports=o},function(t,e,i){"use strict";i(336),i(2).extendComponentModel({type:"polar",dependencies:["polarAxis","angleAxis"],coordinateSystem:null,findAxisModel:function(t){var e,i=this.ecModel;return i.eachComponent(t,function(t){i.getComponent("polar",t.getShallow("polarIndex"))===this&&(e=t)},this),e},defaultOption:{zlevel:0,z:0,center:["50%","50%"],radius:"80%"}})},function(t,e,i){"use strict";function n(t,e){o.call(this,"radius",t,e),this.type="category"}var a=i(1),o=i(43);n.prototype={constructor:n,dataToRadius:o.prototype.dataToCoord,radiusToData:o.prototype.coordToData},a.inherits(n,o),t.exports=n},function(t,e,i){function n(t,e,i){o.call(this,t,e,i),this.type="value",this.angle=0,this.name="",this.model}var a=i(1),o=i(43);a.inherits(n,o),t.exports=n},function(t,e,i){function n(t,e,i){this._model=t,this.dimensions=[],this._indicatorAxes=a.map(t.getIndicatorModels(),function(t,e){var i="indicator_"+e,n=new o(i,new r);return n.name=t.get("name"),n.model=t,t.axis=n,this.dimensions.push(i),n},this),this.resize(t,i),this.cx,this.cy,this.r,this.startAngle}var a=i(1),o=i(340),r=i(37),s=i(4),l=i(23);n.prototype.getIndicatorAxes=function(){return this._indicatorAxes},n.prototype.dataToPoint=function(t,e){var i=this._indicatorAxes[e];return this.coordToPoint(i.dataToCoord(t),e)},n.prototype.coordToPoint=function(t,e){var i=this._indicatorAxes[e],n=i.angle,a=this.cx+t*Math.cos(n),o=this.cy-t*Math.sin(n);return[a,o]},n.prototype.pointToData=function(t){var e=t[0]-this.cx,i=t[1]-this.cy,n=Math.sqrt(e*e+i*i);e/=n,i/=n;for(var a,o=Math.atan2(-i,e),r=1/0,s=-1,l=0;lu&&(a=h,s=l,r=u)}return[s,+(a&&a.coodToData(n))]},n.prototype.resize=function(t,e){var i=t.get("center"),n=e.getWidth(),o=e.getHeight(),r=Math.min(n,o)/2;this.cx=s.parsePercent(i[0],n),this.cy=s.parsePercent(i[1],o),this.startAngle=t.get("startAngle")*Math.PI/180,this.r=s.parsePercent(t.get("radius"),r),a.each(this._indicatorAxes,function(t,e){t.setExtent(0,this.r);var i=this.startAngle+e*Math.PI*2/this._indicatorAxes.length;i=Math.atan2(Math.sin(i),Math.cos(i)),t.angle=i},this)},n.prototype.update=function(t,e){function i(t){var e=Math.pow(10,Math.floor(Math.log(t)/Math.LN10)),i=t/e;return 2===i?i=5:i*=2,i*e}var n=this._indicatorAxes,o=this._model;a.each(n,function(t){t.scale.setExtent(1/0,-(1/0))}),t.eachSeriesByType("radar",function(e,i){if("radar"===e.get("coordinateSystem")&&t.getComponent("radar",e.get("radarIndex"))===o){var r=e.getData();a.each(n,function(t){t.scale.unionExtent(r.getDataExtent(t.dim))})}},this);var r=o.get("splitNumber");a.each(n,function(t,e){var n=l.getScaleExtent(t,t.model);l.niceScaleExtent(t,t.model);var a=t.model,o=t.scale,h=a.get("min"),u=a.get("max"),c=o.getInterval();if(null!=h&&null!=u)o.setInterval((u-h)/r);else if(null!=h){var d;do d=h+c*r,o.setExtent(+h,d),o.setInterval(c),c=i(c);while(dn[0]&&isFinite(f)&&isFinite(n[0]))}else{var p=o.getTicks().length-1;p>r&&(c=i(c));var g=Math.round((n[0]+n[1])/2/c)*c,m=Math.round(r/2);o.setExtent(s.round(g-m*c),s.round(g+(r-m)*c)),o.setInterval(c)}})},n.dimensions=[],n.create=function(t,e){var i=[];return t.eachComponent("radar",function(a){var o=new n(a,t,e);i.push(o),a.coordinateSystem=o}),t.eachSeriesByType("radar",function(t){"radar"===t.get("coordinateSystem")&&(t.coordinateSystem=i[t.get("radarIndex")||0])}),i},i(28).register("radar",n),t.exports=n},function(t,e,i){function n(t,e){return s.defaults({show:e},t)}var a=i(72),o=a.valueAxis,r=i(12),s=i(1),l=i(49),h=i(2).extendComponentModel({type:"radar",optionUpdated:function(){var t=this.get("boundaryGap"),e=this.get("splitNumber"),i=this.get("scale"),n=this.get("axisLine"),a=this.get("axisTick"),o=this.get("axisLabel"),h=this.get("name.textStyle"),u=this.get("name.show"),c=this.get("name.formatter"),d=this.get("nameGap"),f=s.map(this.get("indicator")||[],function(f){return null!=f.max&&f.max>0?f.min=0:null!=f.min&&f.min<0&&(f.max=0),f=s.extend({boundaryGap:t,splitNumber:e,scale:i,axisLine:n,axisTick:a,axisLabel:o,name:f.text,nameLocation:"end",nameGap:d,nameTextStyle:h},f),u||(f.name=""),"string"==typeof c?f.name=c.replace("{value}",f.name):"function"==typeof c&&(f.name=c(f.name,f)),s.extend(new r(f,null,this.ecModel),l)},this);this.getIndicatorModels=function(){return f}},defaultOption:{zlevel:0,z:0,center:["50%","50%"],radius:"75%",startAngle:90,name:{show:!0},boundaryGap:[0,0],splitNumber:5,nameGap:15,scale:!1,shape:"polygon",axisLine:s.merge({lineStyle:{color:"#bbb"}},o.axisLine),axisLabel:n(o.axisLabel,!1),axisTick:n(o.axisTick,!1),splitLine:n(o.splitLine,!0),splitArea:n(o.splitArea,!0),indicator:[]}});t.exports=h},function(t,e,i){"use strict";function n(t,e){this.id=null==t?"":t,this.inEdges=[],this.outEdges=[],this.edges=[],this.hostGraph,this.dataIndex=null==e?-1:e}function a(t,e,i){this.node1=t,this.node2=e,this.dataIndex=null==i?-1:i}var o=i(1),r=function(t){this._directed=t||!1,this.nodes=[],this.edges=[],this._nodesMap={},this._edgesMap={},this.data,this.edgeData},s=r.prototype;s.type="graph",s.isDirected=function(){return this._directed},s.addNode=function(t,e){var i=this._nodesMap;if(!i[t]){var a=new n(t,e);return a.hostGraph=this,this.nodes.push(a),i[t]=a,a}},s.getNodeByIndex=function(t){var e=this.data.getRawIndex(t);return this.nodes[e]},s.getNodeById=function(t){return this._nodesMap[t]},s.addEdge=function(t,e,i){var o=this._nodesMap,r=this._edgesMap;if(t instanceof n||(t=o[t]),e instanceof n||(e=o[e]),t&&e){var s=t.id+"-"+e.id;if(!r[s]){var l=new a(t,e,i);return l.hostGraph=this,this._directed&&(t.outEdges.push(l),e.inEdges.push(l)),t.edges.push(l),t!==e&&e.edges.push(l),this.edges.push(l),r[s]=l,l}}},s.getEdgeByIndex=function(t){var e=this.edgeData.getRawIndex(t);return this.edges[e]},s.getEdge=function(t,e){t instanceof n&&(t=t.id),e instanceof n&&(e=e.id);var i=this._edgesMap;return this._directed?i[t+"-"+e]:i[t+"-"+e]||i[e+"-"+t]},s.eachNode=function(t,e){for(var i=this.nodes,n=i.length,a=0;n>a;a++)i[a].dataIndex>=0&&t.call(e,i[a],a)},s.eachEdge=function(t,e){for(var i=this.edges,n=i.length,a=0;n>a;a++)i[a].dataIndex>=0&&i[a].node1.dataIndex>=0&&i[a].node2.dataIndex>=0&&t.call(e,i[a],a)},s.breadthFirstTraverse=function(t,e,i,a){if(e instanceof n||(e=this._nodesMap[e]),e){for(var o="out"===i?"outEdges":"in"===i?"inEdges":"edges",r=0;ra;a++)i[a].dataIndex=-1;for(var a=0,o=t.count();o>a;a++)i[t.getRawIndex(a)].dataIndex=a;e.filterSelf(function(t){var i=n[e.getRawIndex(t)];return i.node1.dataIndex>=0&&i.node2.dataIndex>=0});for(var a=0,o=n.length;o>a;a++)n[a].dataIndex=-1;for(var a=0,o=e.count();o>a;a++)n[e.getRawIndex(a)].dataIndex=a},s.setEdgeData=function(t){this.edgeData=t,this._edgeDataSaved=t.cloneShallow()},s.restoreData=function(){this.edgeData=this._edgeDataSaved.cloneShallow()},s.clone=function(){for(var t=new r(this._directed),e=this.nodes,i=this.edges,n=0;n=0&&this[t][e].setItemVisual(this.dataIndex,i,n)},getVisual:function(i,n){return this[t][e].getItemVisual(this.dataIndex,i,n)},setLayout:function(i,n){this.dataIndex>=0&&this[t][e].setItemLayout(this.dataIndex,i,n)},getLayout:function(){return this[t][e].getItemLayout(this.dataIndex)},getGraphicEl:function(){return this[t][e].getItemGraphicEl(this.dataIndex)},getRawIndex:function(){return this[t][e].getRawIndex(this.dataIndex)}}};o.mixin(n,l("hostGraph","data")),o.mixin(a,l("hostGraph","edgeData")),r.Node=n,r.Edge=a,t.exports=r},function(t,e,i){function n(t,e){this.root,this.data,this._nodes=[],this.hostModel=t,this.levelModels=o.map(e||[],function(e){return new r(e,t,t.ecModel)})}function a(t,e){var i=e.children;t.parentNode!==e&&(i.push(t),t.parentNode=e,e.hostTree._nodes.push(t))}var o=i(1),r=i(12),s=i(14),l=i(223),h=i(31),u=function(t,e,i){this.name=t||"",this.depth=0,this.height=0,this.parentNode=null,this.dataIndex=null==e?-1:e,this.children=[],this.viewChildren=[],this.hostTree=i};u.prototype={constructor:u,isRemoved:function(){return this.dataIndex<0},eachNode:function(t,e,i){"function"==typeof t&&(i=e,e=t,t=null),t=t||{},o.isString(t)&&(t={order:t});var n,a=t.order||"preorder",r=this[t.attr||"children"];"preorder"===a&&(n=e.call(i,this));for(var s=0;!n&&se&&(e=n.height)}this.height=e+1},getNodeById:function(t){if(this.getId()===t)return this;for(var e=0,i=this.children,n=i.length;n>e;e++){var a=i[e].getNodeById(t);if(a)return a}},contains:function(t){if(t===this)return!0;for(var e=0,i=this.children,n=i.length;n>e;e++){var a=i[e].contains(t);if(a)return a}},getAncestors:function(t){for(var e=[],i=t?this:this.parentNode;i;)e.push(i),i=i.parentNode;return e.reverse(),e},getValue:function(t){var e=this.hostTree.data;return e.get(e.getDimension(t||"value"),this.dataIndex)},setLayout:function(t,e){this.dataIndex>=0&&this.hostTree.data.setItemLayout(this.dataIndex,t,e)},getLayout:function(){return this.hostTree.data.getItemLayout(this.dataIndex)},getModel:function(t){if(!(this.dataIndex<0)){var e=this.hostTree,i=e.data.getItemModel(this.dataIndex),n=this.getLevelModel();return i.getModel(t,(n||e.hostModel).getModel(t))}},getLevelModel:function(){return(this.hostTree.levelModels||[])[this.depth]},setVisual:function(t,e){this.dataIndex>=0&&this.hostTree.data.setItemVisual(this.dataIndex,t,e)},getVisual:function(t,e){return this.hostTree.data.getItemVisual(this.dataIndex,t,e)},getRawIndex:function(){return this.hostTree.data.getRawIndex(this.dataIndex)},getId:function(){return this.hostTree.data.getId(this.dataIndex)}},n.prototype={constructor:n,type:"tree",eachNode:function(t,e,i){this.root.eachNode(t,e,i)},getNodeByDataIndex:function(t){var e=this.data.getRawIndex(t);return this._nodes[e]},getNodeByName:function(t){return this.root.getNodeByName(t)},update:function(){for(var t=this.data,e=this._nodes,i=0,n=e.length;n>i;i++)e[i].dataIndex=-1;for(var i=0,n=t.count();n>i;i++)e[t.getRawIndex(i)].dataIndex=i}},n.createTree=function(t,e,i){function o(t,e){c.push(t);var i=new u(t.name,c.length-1,r);e?a(i,e):r.root=i;var n=t.children;if(n)for(var s=0;so;o++){var s=e[o];s.el.animateTo(s.target,s.time,s.delay,s.easing,n)}return this}}}var a=i(1);t.exports={createWrap:n}},function(t,e,i){function n(){function t(e,n){if(n>=i.length)return e;for(var o=-1,r=e.length,s=i[n++],l={},h={};++o=i.length)return t;var r=[],s=n[o++];return a.each(t,function(t,i){r.push({key:i,values:e(t,o)})}),s?r.sort(function(t,e){return s(t.key,e.key)}):r}var i=[],n=[];return{key:function(t){return i.push(t),this},sortKeys:function(t){return n[i.length-1]=t,this},entries:function(i){return e(t(i,0),0)}}}var a=i(1);t.exports=n},function(t,e,i){var n=i(1),a={get:function(t,e,i){var a=n.clone((o[t]||{})[e]);return i&&n.isArray(a)?a[a.length-1]:a}},o={color:{active:["#006edd","#e0ffff"],inactive:["rgba(0,0,0,0)"]},colorHue:{active:[0,360],inactive:[0,0]},colorSaturation:{active:[.3,1],inactive:[0,0]},colorLightness:{active:[.9,.5],inactive:[0,0]},colorAlpha:{active:[.3,1],inactive:[0,0]},symbol:{active:["circle","roundRect","diamond"],inactive:["none"]},symbolSize:{active:[10,50],inactive:[0,0]}};t.exports=a},function(t,e,i){function n(t,e){return Math.abs(t-e)} colorStops - */ - var Gradient = function (colorStops) { - - this.colorStops = colorStops || []; - }; - - Gradient.prototype = { - - constructor: Gradient, - - addColorStop: function (offset, color) { - this.colorStops.push({ - - offset: offset, - - color: color - }); - } - }; - - return Gradient; -}); -/** - */ -define('zrender/core/util',['require','../graphic/Gradient'],function(require) { - var Gradient = require('../graphic/Gradient'); - // 用于处理merge时无法遍历Date等对象的问题 - var BUILTIN_OBJECT = { - '[object Function]': 1, - '[object RegExp]': 1, - '[object Date]': 1, - '[object Error]': 1, - '[object CanvasGradient]': 1 - }; - - var objToString = Object.prototype.toString; - - var arrayProto = Array.prototype; - var nativeForEach = arrayProto.forEach; - var nativeFilter = arrayProto.filter; - var nativeSlice = arrayProto.slice; - var nativeMap = arrayProto.map; - var nativeReduce = arrayProto.reduce; - - /** - * @param {*} source - * @return {*} 拷贝后的新对象 - */ - function clone(source) { - if (typeof source == 'object' && source !== null) { - var result = source; - if (source instanceof Array) { - result = []; - for (var i = 0, len = source.length; i < len; i++) { - result[i] = clone(source[i]); - } - } - else if ( - !isBuildInObject(source) - // 是否为 dom 对象 - && !isDom(source) - ) { - result = {}; - for (var key in source) { - if (source.hasOwnProperty(key)) { - result[key] = clone(source[key]); - } - } - } - - return result; - } - - return source; - } - - /** - * @param {*} target - * @param {*} source - * @param {boolean} [overwrite=false] - */ - function merge(target, source, overwrite) { - // We should escapse that source is string - // and enter for ... in ... - if (!isObject(source) || !isObject(target)) { - return overwrite ? clone(source) : target; - } - - for (var key in source) { - if (source.hasOwnProperty(key)) { - var targetProp = target[key]; - var sourceProp = source[key]; - - if (isObject(sourceProp) - && isObject(targetProp) - && !isArray(sourceProp) - && !isArray(targetProp) - && !isDom(sourceProp) - && !isDom(targetProp) - && !isBuildInObject(sourceProp) - && !isBuildInObject(targetProp) - ) { - // 如果需要递归覆盖,就递归调用merge - merge(targetProp, sourceProp, overwrite); - } - else if (overwrite || !(key in target)) { - // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况 - // NOTE,在 target[key] 不存在的时候也是直接覆盖 - target[key] = clone(source[key], true); - } - } - } - - return target; - } - - /** - * @param {Array} targetAndSources The first item is target, and the rests are source. - * @param {boolean} [overwrite=false] - * @return {*} target - */ - function mergeAll(targetAndSources, overwrite) { - var result = targetAndSources[0]; - for (var i = 1, len = targetAndSources.length; i < len; i++) { - result = merge(result, targetAndSources[i], overwrite); - } - return result; - } - - /** - * @param {*} target - * @param {*} source - */ - function extend(target, source) { - for (var key in source) { - if (source.hasOwnProperty(key)) { - target[key] = source[key]; - } - } - return target; - } - - /** - * @param {*} target - * @param {*} source - * @param {boolen} [overlay=false] - */ - function defaults(target, source, overlay) { - for (var key in source) { - if (source.hasOwnProperty(key) - && (overlay ? source[key] != null : target[key] == null) - ) { - target[key] = source[key]; - } - } - return target; - } - - function createCanvas() { - return document.createElement('canvas'); - } - // FIXME - var _ctx; - function getContext() { - if (!_ctx) { - // Use util.createCanvas instead of createCanvas - // because createCanvas may be overwritten in different environment - _ctx = util.createCanvas().getContext('2d'); - } - return _ctx; - } - - /** - * 查询数组中元素的index - */ - function indexOf(array, value) { - if (array) { - if (array.indexOf) { - return array.indexOf(value); - } - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] === value) { - return i; - } - } - } - return -1; - } - - /** - * 构造类继承关系 - * - * @param {Function} clazz 源类 - * @param {Function} baseClazz 基类 - */ - function inherits(clazz, baseClazz) { - var clazzPrototype = clazz.prototype; - function F() {} - F.prototype = baseClazz.prototype; - clazz.prototype = new F(); - - for (var prop in clazzPrototype) { - clazz.prototype[prop] = clazzPrototype[prop]; - } - clazz.prototype.constructor = clazz; - clazz.superClass = baseClazz; - } - - /** - * @param {Object|Function} target - * @param {Object|Function} sorce - * @param {boolean} overlay - */ - function mixin(target, source, overlay) { - target = 'prototype' in target ? target.prototype : target; - source = 'prototype' in source ? source.prototype : source; - - defaults(target, source, overlay); - } - - /** - * @param {Array|TypedArray} data - */ - function isArrayLike(data) { - if (! data) { - return; - } - if (typeof data == 'string') { - return false; - } - return typeof data.length == 'number'; - } - - /** - * 数组或对象遍历 - * @memberOf module:zrender/tool/util - * @param {Object|Array} obj - * @param {Function} cb - * @param {*} [context] - */ - function each(obj, cb, context) { - if (!(obj && cb)) { - return; - } - if (obj.forEach && obj.forEach === nativeForEach) { - obj.forEach(cb, context); - } - else if (obj.length === +obj.length) { - for (var i = 0, len = obj.length; i < len; i++) { - cb.call(context, obj[i], i, obj); - } - } - else { - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - cb.call(context, obj[key], key, obj); - } - } - } - } - - /** - * 数组映射 - * @memberOf module:zrender/tool/util - * @param {Array} obj - * @param {Function} cb - * @param {*} [context] - * @return {Array} - */ - function map(obj, cb, context) { - if (!(obj && cb)) { - return; - } - if (obj.map && obj.map === nativeMap) { - return obj.map(cb, context); - } - else { - var result = []; - for (var i = 0, len = obj.length; i < len; i++) { - result.push(cb.call(context, obj[i], i, obj)); - } - return result; - } - } - - /** - * @memberOf module:zrender/tool/util - * @param {Array} obj - * @param {Function} cb - * @param {Object} [memo] - * @param {*} [context] - * @return {Array} - */ - function reduce(obj, cb, memo, context) { - if (!(obj && cb)) { - return; - } - if (obj.reduce && obj.reduce === nativeReduce) { - return obj.reduce(cb, memo, context); - } - else { - for (var i = 0, len = obj.length; i < len; i++) { - memo = cb.call(context, memo, obj[i], i, obj); - } - return memo; - } - } - - /** - * 数组过滤 - * @memberOf module:zrender/tool/util - * @param {Array} obj - * @param {Function} cb - * @param {*} [context] - * @return {Array} - */ - function filter(obj, cb, context) { - if (!(obj && cb)) { - return; - } - if (obj.filter && obj.filter === nativeFilter) { - return obj.filter(cb, context); - } - else { - var result = []; - for (var i = 0, len = obj.length; i < len; i++) { - if (cb.call(context, obj[i], i, obj)) { - result.push(obj[i]); - } - } - return result; - } - } - - /** - * 数组项查找 - * @memberOf module:zrender/tool/util - * @param {Array} obj - * @param {Function} cb - * @param {*} [context] - * @return {Array} - */ - function find(obj, cb, context) { - if (!(obj && cb)) { - return; - } - for (var i = 0, len = obj.length; i < len; i++) { - if (cb.call(context, obj[i], i, obj)) { - return obj[i]; - } - } - } - - /** - * @memberOf module:zrender/tool/util - * @param {Function} func - * @param {*} context - * @return {Function} - */ - function bind(func, context) { - var args = nativeSlice.call(arguments, 2); - return function () { - return func.apply(context, args.concat(nativeSlice.call(arguments))); - }; - } - - /** - * @memberOf module:zrender/tool/util - * @param {Function} func - * @param {...} - * @return {Function} - */ - function curry(func) { - var args = nativeSlice.call(arguments, 1); - return function () { - return func.apply(this, args.concat(nativeSlice.call(arguments))); - }; - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isArray(value) { - return objToString.call(value) === '[object Array]'; - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isFunction(value) { - return typeof value === 'function'; - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isString(value) { - return objToString.call(value) === '[object String]'; - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isObject(value) { - // Avoid a V8 JIT bug in Chrome 19-20. - // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. - var type = typeof value; - return type === 'function' || (!!value && type == 'object'); - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isBuildInObject(value) { - return !!BUILTIN_OBJECT[objToString.call(value)] - || (value instanceof Gradient); - } - - /** - * @memberOf module:zrender/tool/util - * @param {*} value - * @return {boolean} - */ - function isDom(value) { - return value && value.nodeType === 1 - && typeof(value.nodeName) == 'string'; - } - - /** - * If value1 is not null, then return value1, otherwise judget rest of values. - * @param {*...} values - * @return {*} Final value - */ - function retrieve(values) { - for (var i = 0, len = arguments.length; i < len; i++) { - if (arguments[i] != null) { - return arguments[i]; - } - } - } - - /** - * @memberOf module:zrender/tool/util - * @param {Array} arr - * @param {number} startIndex - * @param {number} endIndex - * @return {Array} - */ - function slice() { - return Function.call.apply(nativeSlice, arguments); - } - - /** - * @param {boolean} condition - * @param {string} message - */ - function assert(condition, message) { - if (!condition) { - throw new Error(message); - } - } - - var util = { - inherits: inherits, - mixin: mixin, - clone: clone, - merge: merge, - mergeAll: mergeAll, - extend: extend, - defaults: defaults, - getContext: getContext, - createCanvas: createCanvas, - indexOf: indexOf, - slice: slice, - find: find, - isArrayLike: isArrayLike, - each: each, - map: map, - reduce: reduce, - filter: filter, - bind: bind, - curry: curry, - isArray: isArray, - isString: isString, - isObject: isObject, - isFunction: isFunction, - isBuildInObject: isBuildInObject, - isDom: isDom, - retrieve: retrieve, - assert: assert, - noop: function () {} - }; - return util; -}); +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["echarts"] = factory(); + else + root["echarts"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Export echarts as CommonJS module + */ + module.exports = __webpack_require__(1); + + __webpack_require__(91); + __webpack_require__(127); + __webpack_require__(132); + __webpack_require__(106); + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + /*! + * ECharts, a javascript interactive chart library. + * + * Copyright (c) 2015, Baidu Inc. + * All rights reserved. + * + * LICENSE + * https://github.com/ecomfe/echarts/blob/master/LICENSE.txt + */ + + /** + * @module echarts + */ + + + var GlobalModel = __webpack_require__(2); + var ExtensionAPI = __webpack_require__(24); + var CoordinateSystemManager = __webpack_require__(25); + var OptionManager = __webpack_require__(26); + + var ComponentModel = __webpack_require__(19); + var SeriesModel = __webpack_require__(27); + + var ComponentView = __webpack_require__(28); + var ChartView = __webpack_require__(41); + var graphic = __webpack_require__(42); + + var zrender = __webpack_require__(77); + var zrUtil = __webpack_require__(3); + var colorTool = __webpack_require__(38); + var env = __webpack_require__(78); + var Eventful = __webpack_require__(32); + + var each = zrUtil.each; + + var VISUAL_CODING_STAGES = ['echarts', 'chart', 'component']; + + // TODO Transform first or filter first + var PROCESSOR_STAGES = ['transform', 'filter', 'statistic']; + + function createRegisterEventWithLowercaseName(method) { + return function (eventName, handler, context) { + // Event name is all lowercase + eventName = eventName && eventName.toLowerCase(); + Eventful.prototype[method].call(this, eventName, handler, context); + }; + } + /** + * @module echarts~MessageCenter + */ + function MessageCenter() { + Eventful.call(this); + } + MessageCenter.prototype.on = createRegisterEventWithLowercaseName('on'); + MessageCenter.prototype.off = createRegisterEventWithLowercaseName('off'); + MessageCenter.prototype.one = createRegisterEventWithLowercaseName('one'); + zrUtil.mixin(MessageCenter, Eventful); + /** + * @module echarts~ECharts + */ + function ECharts (dom, theme, opts) { + opts = opts || {}; + + // Get theme by name + if (typeof theme === 'string') { + theme = themeStorage[theme]; + } + + if (theme) { + each(optionPreprocessorFuncs, function (preProcess) { + preProcess(theme); + }); + } + /** + * @type {string} + */ + this.id; + /** + * Group id + * @type {string} + */ + this.group; + /** + * @type {HTMLDomElement} + * @private + */ + this._dom = dom; + /** + * @type {module:zrender/ZRender} + * @private + */ + this._zr = zrender.init(dom, { + renderer: opts.renderer || 'canvas', + devicePixelRatio: opts.devicePixelRatio + }); + + /** + * @type {Object} + * @private + */ + this._theme = zrUtil.clone(theme); + + /** + * @type {Array.} + * @private + */ + this._chartsViews = []; + + /** + * @type {Object.} + * @private + */ + this._chartsMap = {}; + + /** + * @type {Array.} + * @private + */ + this._componentsViews = []; + + /** + * @type {Object.} + * @private + */ + this._componentsMap = {}; + + /** + * @type {module:echarts/ExtensionAPI} + * @private + */ + this._api = new ExtensionAPI(this); + + /** + * @type {module:echarts/CoordinateSystem} + * @private + */ + this._coordSysMgr = new CoordinateSystemManager(); + + Eventful.call(this); + + /** + * @type {module:echarts~MessageCenter} + * @private + */ + this._messageCenter = new MessageCenter(); + + // Init mouse events + this._initEvents(); + + // In case some people write `window.onresize = chart.resize` + this.resize = zrUtil.bind(this.resize, this); + } + + var echartsProto = ECharts.prototype; + + /** + * @return {HTMLDomElement} + */ + echartsProto.getDom = function () { + return this._dom; + }; + + /** + * @return {module:zrender~ZRender} + */ + echartsProto.getZr = function () { + return this._zr; + }; + + /** + * @param {Object} option + * @param {boolean} notMerge + * @param {boolean} [notRefreshImmediately=false] Useful when setOption frequently. + */ + echartsProto.setOption = function (option, notMerge, notRefreshImmediately) { + if (!this._model || notMerge) { + this._model = new GlobalModel( + null, null, this._theme, new OptionManager(this._api) + ); + } + + this._model.setOption(option, optionPreprocessorFuncs); + + updateMethods.prepareAndUpdate.call(this); + + !notRefreshImmediately && this._zr.refreshImmediately(); + }; + + /** + * @DEPRECATED + */ + echartsProto.setTheme = function () { + console.log('ECharts#setTheme() is DEPRECATED in ECharts 3.0'); + }; + + /** + * @return {module:echarts/model/Global} + */ + echartsProto.getModel = function () { + return this._model; + }; + + /** + * @return {Object} + */ + echartsProto.getOption = function () { + return this._model.getOption(); + }; + + /** + * @return {number} + */ + echartsProto.getWidth = function () { + return this._zr.getWidth(); + }; + + /** + * @return {number} + */ + echartsProto.getHeight = function () { + return this._zr.getHeight(); + }; + + /** + * Get canvas which has all thing rendered + * @param {Object} opts + * @param {string} [opts.backgroundColor] + */ + echartsProto.getRenderedCanvas = function (opts) { + if (!env.canvasSupported) { + return; + } + opts = opts || {}; + opts.pixelRatio = opts.pixelRatio || 1; + opts.backgroundColor = opts.backgroundColor + || this._model.get('backgroundColor'); + var zr = this._zr; + var list = zr.storage.getDisplayList(); + // Stop animations + zrUtil.each(list, function (el) { + el.stopAnimation(true); + }); + return zr.painter.getRenderedCanvas(opts); + }; + /** + * @return {string} + * @param {Object} opts + * @param {string} [opts.type='png'] + * @param {string} [opts.pixelRatio=1] + * @param {string} [opts.backgroundColor] + */ + echartsProto.getDataURL = function (opts) { + opts = opts || {}; + var excludeComponents = opts.excludeComponents; + var ecModel = this._model; + var excludesComponentViews = []; + var self = this; + + each(excludeComponents, function (componentType) { + ecModel.eachComponent({ + mainType: componentType + }, function (component) { + var view = self._componentsMap[component.__viewId]; + if (!view.group.ignore) { + excludesComponentViews.push(view); + view.group.ignore = true; + } + }); + }); + + var url = this.getRenderedCanvas(opts).toDataURL( + 'image/' + (opts && opts.type || 'png') + ); + + each(excludesComponentViews, function (view) { + view.group.ignore = false; + }); + return url; + }; + + + /** + * @return {string} + * @param {Object} opts + * @param {string} [opts.type='png'] + * @param {string} [opts.pixelRatio=1] + * @param {string} [opts.backgroundColor] + */ + echartsProto.getConnectedDataURL = function (opts) { + if (!env.canvasSupported) { + return; + } + var groupId = this.group; + var mathMin = Math.min; + var mathMax = Math.max; + var MAX_NUMBER = Infinity; + if (connectedGroups[groupId]) { + var left = MAX_NUMBER; + var top = MAX_NUMBER; + var right = -MAX_NUMBER; + var bottom = -MAX_NUMBER; + var canvasList = []; + var dpr = (opts && opts.pixelRatio) || 1; + for (var id in instances) { + var chart = instances[id]; + if (chart.group === groupId) { + var canvas = chart.getRenderedCanvas( + zrUtil.clone(opts) + ); + var boundingRect = chart.getDom().getBoundingClientRect(); + left = mathMin(boundingRect.left, left); + top = mathMin(boundingRect.top, top); + right = mathMax(boundingRect.right, right); + bottom = mathMax(boundingRect.bottom, bottom); + canvasList.push({ + dom: canvas, + left: boundingRect.left, + top: boundingRect.top + }); + } + } + + left *= dpr; + top *= dpr; + right *= dpr; + bottom *= dpr; + var width = right - left; + var height = bottom - top; + var targetCanvas = zrUtil.createCanvas(); + targetCanvas.width = width; + targetCanvas.height = height; + var zr = zrender.init(targetCanvas); + + each(canvasList, function (item) { + var img = new graphic.Image({ + style: { + x: item.left * dpr - left, + y: item.top * dpr - top, + image: item.dom + } + }); + zr.add(img); + }); + zr.refreshImmediately(); + + return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png')); + } + else { + return this.getDataURL(opts); + } + }; + + var updateMethods = { + + /** + * @param {Object} payload + * @private + */ + update: function (payload) { + // console.time && console.time('update'); + + var ecModel = this._model; + var api = this._api; + var coordSysMgr = this._coordSysMgr; + // update before setOption + if (!ecModel) { + return; + } + + ecModel.restoreData(); + + // TODO + // Save total ecModel here for undo/redo (after restoring data and before processing data). + // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call. + + // Create new coordinate system each update + // In LineView may save the old coordinate system and use it to get the orignal point + coordSysMgr.create(this._model, this._api); + + processData.call(this, ecModel, api); + + stackSeriesData.call(this, ecModel); + + coordSysMgr.update(ecModel, api); + + doLayout.call(this, ecModel, payload); + + doVisualCoding.call(this, ecModel, payload); + + doRender.call(this, ecModel, payload); + + // Set background + var backgroundColor = ecModel.get('backgroundColor') || 'transparent'; + + var painter = this._zr.painter; + // TODO all use clearColor ? + if (painter.isSingleCanvas && painter.isSingleCanvas()) { + this._zr.configLayer(0, { + clearColor: backgroundColor + }); + } + else { + // In IE8 + if (!env.canvasSupported) { + var colorArr = colorTool.parse(backgroundColor); + backgroundColor = colorTool.stringify(colorArr, 'rgb'); + if (colorArr[3] === 0) { + backgroundColor = 'transparent'; + } + } + backgroundColor = backgroundColor; + this._dom.style.backgroundColor = backgroundColor; + } + + // console.time && console.timeEnd('update'); + }, + + // PENDING + /** + * @param {Object} payload + * @private + */ + updateView: function (payload) { + var ecModel = this._model; + + // update before setOption + if (!ecModel) { + return; + } + + doLayout.call(this, ecModel, payload); + + doVisualCoding.call(this, ecModel, payload); + + invokeUpdateMethod.call(this, 'updateView', ecModel, payload); + }, + + /** + * @param {Object} payload + * @private + */ + updateVisual: function (payload) { + var ecModel = this._model; + + // update before setOption + if (!ecModel) { + return; + } + + doVisualCoding.call(this, ecModel, payload); + + invokeUpdateMethod.call(this, 'updateVisual', ecModel, payload); + }, + + /** + * @param {Object} payload + * @private + */ + updateLayout: function (payload) { + var ecModel = this._model; + + // update before setOption + if (!ecModel) { + return; + } + + doLayout.call(this, ecModel, payload); + + invokeUpdateMethod.call(this, 'updateLayout', ecModel, payload); + }, + + /** + * @param {Object} payload + * @private + */ + highlight: function (payload) { + toggleHighlight.call(this, 'highlight', payload); + }, + + /** + * @param {Object} payload + * @private + */ + downplay: function (payload) { + toggleHighlight.call(this, 'downplay', payload); + }, + + /** + * @param {Object} payload + * @private + */ + prepareAndUpdate: function (payload) { + var ecModel = this._model; + + prepareView.call(this, 'component', ecModel); + + prepareView.call(this, 'chart', ecModel); + + updateMethods.update.call(this, payload); + } + }; + + /** + * @param {Object} payload + * @private + */ + function toggleHighlight(method, payload) { + var ecModel = this._model; + + // dispatchAction before setOption + if (!ecModel) { + return; + } + + ecModel.eachComponent( + {mainType: 'series', query: payload}, + function (seriesModel, index) { + var chartView = this._chartsMap[seriesModel.__viewId]; + if (chartView && chartView.__alive) { + chartView[method]( + seriesModel, ecModel, this._api, payload + ); + } + }, + this + ); + } + + /** + * Resize the chart + */ + echartsProto.resize = function () { + this._zr.resize(); + + var optionChanged = this._model && this._model.resetOption('media'); + updateMethods[optionChanged ? 'prepareAndUpdate' : 'update'].call(this); + + // Resize loading effect + this._loadingFX && this._loadingFX.resize(); + }; + + var defaultLoadingEffect = __webpack_require__(87); + /** + * Show loading effect + * @param {string} [name='default'] + * @param {Object} [cfg] + */ + echartsProto.showLoading = function (name, cfg) { + if (zrUtil.isObject(name)) { + cfg = name; + name = 'default'; + } + var el = defaultLoadingEffect(this._api, cfg); + var zr = this._zr; + this._loadingFX = el; + + zr.add(el); + }; + + /** + * Hide loading effect + */ + echartsProto.hideLoading = function () { + this._loadingFX && this._zr.remove(this._loadingFX); + this._loadingFX = null; + }; + + /** + * @param {Object} eventObj + * @return {Object} + */ + echartsProto.makeActionFromEvent = function (eventObj) { + var payload = zrUtil.extend({}, eventObj); + payload.type = eventActionMap[eventObj.type]; + return payload; + }; + + /** + * @pubilc + * @param {Object} payload + * @param {string} [payload.type] Action type + * @param {boolean} [silent=false] Whether trigger event. + */ + echartsProto.dispatchAction = function (payload, silent) { + var actionWrap = actions[payload.type]; + if (actionWrap) { + var actionInfo = actionWrap.actionInfo; + var updateMethod = actionInfo.update || 'update'; + + var payloads = [payload]; + var batched = false; + // Batch action + if (payload.batch) { + batched = true; + payloads = zrUtil.map(payload.batch, function (item) { + item = zrUtil.defaults(zrUtil.extend({}, item), payload); + item.batch = null; + return item; + }); + } + + var eventObjBatch = []; + var eventObj; + var isHighlightOrDownplay = payload.type === 'highlight' || payload.type === 'downplay'; + for (var i = 0; i < payloads.length; i++) { + var batchItem = payloads[i]; + // Action can specify the event by return it. + eventObj = actionWrap.action(batchItem, this._model); + // Emit event outside + eventObj = eventObj || zrUtil.extend({}, batchItem); + // Convert type to eventType + eventObj.type = actionInfo.event || eventObj.type; + eventObjBatch.push(eventObj); + + // Highlight and downplay are special. + isHighlightOrDownplay && updateMethods[updateMethod].call(this, batchItem); + } + + (updateMethod !== 'none' && !isHighlightOrDownplay) + && updateMethods[updateMethod].call(this, payload); + if (!silent) { + // Follow the rule of action batch + if (batched) { + eventObj = { + type: eventObjBatch[0].type, + batch: eventObjBatch + }; + } + else { + eventObj = eventObjBatch[0]; + } + this._messageCenter.trigger(eventObj.type, eventObj); + } + } + }; + + /** + * Register event + * @method + */ + echartsProto.on = createRegisterEventWithLowercaseName('on'); + echartsProto.off = createRegisterEventWithLowercaseName('off'); + echartsProto.one = createRegisterEventWithLowercaseName('one'); + + /** + * @param {string} methodName + * @private + */ + function invokeUpdateMethod(methodName, ecModel, payload) { + var api = this._api; + + // Update all components + each(this._componentsViews, function (component) { + var componentModel = component.__model; + component[methodName](componentModel, ecModel, api, payload); + + updateZ(componentModel, component); + }, this); + + // Upate all charts + ecModel.eachSeries(function (seriesModel, idx) { + var chart = this._chartsMap[seriesModel.__viewId]; + chart[methodName](seriesModel, ecModel, api, payload); + + updateZ(seriesModel, chart); + }, this); + + } + + /** + * Prepare view instances of charts and components + * @param {module:echarts/model/Global} ecModel + * @private + */ + function prepareView(type, ecModel) { + var isComponent = type === 'component'; + var viewList = isComponent ? this._componentsViews : this._chartsViews; + var viewMap = isComponent ? this._componentsMap : this._chartsMap; + var zr = this._zr; + + for (var i = 0; i < viewList.length; i++) { + viewList[i].__alive = false; + } + + ecModel[isComponent ? 'eachComponent' : 'eachSeries'](function (componentType, model) { + if (isComponent) { + if (componentType === 'series') { + return; + } + } + else { + model = componentType; + } + + // Consider: id same and type changed. + var viewId = model.id + '_' + model.type; + var view = viewMap[viewId]; + if (!view) { + var classType = ComponentModel.parseClassType(model.type); + var Clazz = isComponent + ? ComponentView.getClass(classType.main, classType.sub) + : ChartView.getClass(classType.sub); + if (Clazz) { + view = new Clazz(); + view.init(ecModel, this._api); + viewMap[viewId] = view; + viewList.push(view); + zr.add(view.group); + } + else { + // Error + return; + } + } + + model.__viewId = viewId; + view.__alive = true; + view.__id = viewId; + view.__model = model; + }, this); + + for (var i = 0; i < viewList.length;) { + var view = viewList[i]; + if (!view.__alive) { + zr.remove(view.group); + view.dispose(ecModel, this._api); + viewList.splice(i, 1); + delete viewMap[view.__id]; + } + else { + i++; + } + } + } + + /** + * Processor data in each series + * + * @param {module:echarts/model/Global} ecModel + * @private + */ + function processData(ecModel, api) { + each(PROCESSOR_STAGES, function (stage) { + each(dataProcessorFuncs[stage] || [], function (process) { + process(ecModel, api); + }); + }); + } + + /** + * @private + */ + function stackSeriesData(ecModel) { + var stackedDataMap = {}; + ecModel.eachSeries(function (series) { + var stack = series.get('stack'); + var data = series.getData(); + if (stack && data.type === 'list') { + var previousStack = stackedDataMap[stack]; + if (previousStack) { + data.stackedOn = previousStack; + } + stackedDataMap[stack] = data; + } + }); + } + + /** + * Layout before each chart render there series, after visual coding and data processing + * + * @param {module:echarts/model/Global} ecModel + * @private + */ + function doLayout(ecModel, payload) { + var api = this._api; + each(layoutFuncs, function (layout) { + layout(ecModel, api, payload); + }); + } + + /** + * Code visual infomation from data after data processing + * + * @param {module:echarts/model/Global} ecModel + * @private + */ + function doVisualCoding(ecModel, payload) { + each(VISUAL_CODING_STAGES, function (stage) { + each(visualCodingFuncs[stage] || [], function (visualCoding) { + visualCoding(ecModel, payload); + }); + }); + } + + /** + * Render each chart and component + * @private + */ + function doRender(ecModel, payload) { + var api = this._api; + // Render all components + each(this._componentsViews, function (componentView) { + var componentModel = componentView.__model; + componentView.render(componentModel, ecModel, api, payload); + + updateZ(componentModel, componentView); + }, this); + + each(this._chartsViews, function (chart) { + chart.__alive = false; + }, this); + + // Render all charts + ecModel.eachSeries(function (seriesModel, idx) { + var chartView = this._chartsMap[seriesModel.__viewId]; + chartView.__alive = true; + chartView.render(seriesModel, ecModel, api, payload); + + updateZ(seriesModel, chartView); + }, this); + + // Remove groups of unrendered charts + each(this._chartsViews, function (chart) { + if (!chart.__alive) { + chart.remove(ecModel, api); + } + }, this); + } + + var MOUSE_EVENT_NAMES = [ + 'click', 'dblclick', 'mouseover', 'mouseout', 'globalout' + ]; + /** + * @private + */ + echartsProto._initEvents = function () { + var zr = this._zr; + each(MOUSE_EVENT_NAMES, function (eveName) { + zr.on(eveName, function (e) { + var ecModel = this.getModel(); + var el = e.target; + if (el && el.dataIndex != null) { + var hostModel = el.hostModel || ecModel.getSeriesByIndex(el.seriesIndex); + var params = hostModel && hostModel.getDataParams(el.dataIndex) || {}; + params.event = e; + params.type = eveName; + this.trigger(eveName, params); + } + }, this); + }, this); + + each(eventActionMap, function (actionType, eventType) { + this._messageCenter.on(eventType, function (event) { + this.trigger(eventType, event); + }, this); + }, this); + }; + + /** + * @return {boolean} + */ + echartsProto.isDisposed = function () { + return this._disposed; + }; + + /** + * Clear + */ + echartsProto.clear = function () { + this.setOption({}, true); + }; + /** + * Dispose instance + */ + echartsProto.dispose = function () { + this._disposed = true; + var api = this._api; + var ecModel = this._model; + + each(this._componentsViews, function (component) { + component.dispose(ecModel, api); + }); + each(this._chartsViews, function (chart) { + chart.dispose(ecModel, api); + }); + + this._zr.dispose(); + + instances[this.id] = null; + }; + + zrUtil.mixin(ECharts, Eventful); + + /** + * @param {module:echarts/model/Series|module:echarts/model/Component} model + * @param {module:echarts/view/Component|module:echarts/view/Chart} view + * @return {string} + */ + function updateZ(model, view) { + var z = model.get('z'); + var zlevel = model.get('zlevel'); + // Set z and zlevel + view.group.traverse(function (el) { + z != null && (el.z = z); + zlevel != null && (el.zlevel = zlevel); + }); + } + /** + * @type {Array.} + * @inner + */ + var actions = []; + + /** + * Map eventType to actionType + * @type {Object} + */ + var eventActionMap = {}; + + /** + * @type {Array.} + * @inner + */ + var layoutFuncs = []; + + /** + * Data processor functions of each stage + * @type {Array.>} + * @inner + */ + var dataProcessorFuncs = {}; + + /** + * @type {Array.} + * @inner + */ + var optionPreprocessorFuncs = []; + + /** + * Visual coding functions of each stage + * @type {Array.>} + * @inner + */ + var visualCodingFuncs = {}; + /** + * Theme storage + * @type {Object.} + */ + var themeStorage = {}; + + + var instances = {}; + var connectedGroups = {}; + + var idBase = new Date() - 0; + var groupIdBase = new Date() - 0; + var DOM_ATTRIBUTE_KEY = '_echarts_instance_'; + /** + * @alias module:echarts + */ + var echarts = { + /** + * @type {number} + */ + version: '3.1.3', + dependencies: { + zrender: '3.0.4' + } + }; + + function enableConnect(chart) { + + var STATUS_PENDING = 0; + var STATUS_UPDATING = 1; + var STATUS_UPDATED = 2; + var STATUS_KEY = '__connectUpdateStatus'; + function updateConnectedChartsStatus(charts, status) { + for (var i = 0; i < charts.length; i++) { + var otherChart = charts[i]; + otherChart[STATUS_KEY] = status; + } + } + zrUtil.each(eventActionMap, function (actionType, eventType) { + chart._messageCenter.on(eventType, function (event) { + if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) { + var action = chart.makeActionFromEvent(event); + var otherCharts = []; + for (var id in instances) { + var otherChart = instances[id]; + if (otherChart !== chart && otherChart.group === chart.group) { + otherCharts.push(otherChart); + } + } + updateConnectedChartsStatus(otherCharts, STATUS_PENDING); + each(otherCharts, function (otherChart) { + if (otherChart[STATUS_KEY] !== STATUS_UPDATING) { + otherChart.dispatchAction(action); + } + }); + updateConnectedChartsStatus(otherCharts, STATUS_UPDATED); + } + }); + }); + + } + /** + * @param {HTMLDomElement} dom + * @param {Object} [theme] + * @param {Object} opts + */ + echarts.init = function (dom, theme, opts) { + // Check version + if ((zrender.version.replace('.', '') - 0) < (echarts.dependencies.zrender.replace('.', '') - 0)) { + throw new Error( + 'ZRender ' + zrender.version + + ' is too old for ECharts ' + echarts.version + + '. Current version need ZRender ' + + echarts.dependencies.zrender + '+' + ); + } + if (!dom) { + throw new Error('Initialize failed: invalid dom.'); + } + + var chart = new ECharts(dom, theme, opts); + chart.id = 'ec_' + idBase++; + instances[chart.id] = chart; + + dom.setAttribute && + dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id); + + enableConnect(chart); + + return chart; + }; + + /** + * @return {string|Array.} groupId + */ + echarts.connect = function (groupId) { + // Is array of charts + if (zrUtil.isArray(groupId)) { + var charts = groupId; + groupId = null; + // If any chart has group + zrUtil.each(charts, function (chart) { + if (chart.group != null) { + groupId = chart.group; + } + }); + groupId = groupId || ('g_' + groupIdBase++); + zrUtil.each(charts, function (chart) { + chart.group = groupId; + }); + } + connectedGroups[groupId] = true; + return groupId; + }; + + /** + * @return {string} groupId + */ + echarts.disConnect = function (groupId) { + connectedGroups[groupId] = false; + }; + + /** + * Dispose a chart instance + * @param {module:echarts~ECharts|HTMLDomElement|string} chart + */ + echarts.dispose = function (chart) { + if (zrUtil.isDom(chart)) { + chart = echarts.getInstanceByDom(chart); + } + else if (typeof chart === 'string') { + chart = instances[chart]; + } + if ((chart instanceof ECharts) && !chart.isDisposed()) { + chart.dispose(); + } + }; + + /** + * @param {HTMLDomElement} dom + * @return {echarts~ECharts} + */ + echarts.getInstanceByDom = function (dom) { + var key = dom.getAttribute(DOM_ATTRIBUTE_KEY); + return instances[key]; + }; + /** + * @param {string} key + * @return {echarts~ECharts} + */ + echarts.getInstanceById = function (key) { + return instances[key]; + }; + + /** + * Register theme + */ + echarts.registerTheme = function (name, theme) { + themeStorage[name] = theme; + }; + + /** + * Register option preprocessor + * @param {Function} preprocessorFunc + */ + echarts.registerPreprocessor = function (preprocessorFunc) { + optionPreprocessorFuncs.push(preprocessorFunc); + }; + + /** + * @param {string} stage + * @param {Function} processorFunc + */ + echarts.registerProcessor = function (stage, processorFunc) { + if (zrUtil.indexOf(PROCESSOR_STAGES, stage) < 0) { + throw new Error('stage should be one of ' + PROCESSOR_STAGES); + } + var funcs = dataProcessorFuncs[stage] || (dataProcessorFuncs[stage] = []); + funcs.push(processorFunc); + }; + + /** + * Usage: + * registerAction('someAction', 'someEvent', function () { ... }); + * registerAction('someAction', function () { ... }); + * registerAction( + * {type: 'someAction', event: 'someEvent', update: 'updateView'}, + * function () { ... } + * ); + * + * @param {(string|Object)} actionInfo + * @param {string} actionInfo.type + * @param {string} [actionInfo.event] + * @param {string} [actionInfo.update] + * @param {string} [eventName] + * @param {Function} action + */ + echarts.registerAction = function (actionInfo, eventName, action) { + if (typeof eventName === 'function') { + action = eventName; + eventName = ''; + } + var actionType = zrUtil.isObject(actionInfo) + ? actionInfo.type + : ([actionInfo, actionInfo = { + event: eventName + }][0]); + + // Event name is all lowercase + actionInfo.event = (actionInfo.event || actionType).toLowerCase(); + eventName = actionInfo.event; + + if (!actions[actionType]) { + actions[actionType] = {action: action, actionInfo: actionInfo}; + } + eventActionMap[eventName] = actionType; + }; + + /** + * @param {string} type + * @param {*} CoordinateSystem + */ + echarts.registerCoordinateSystem = function (type, CoordinateSystem) { + CoordinateSystemManager.register(type, CoordinateSystem); + }; + + /** + * @param {*} layout + */ + echarts.registerLayout = function (layout) { + // PENDING All functions ? + if (zrUtil.indexOf(layoutFuncs, layout) < 0) { + layoutFuncs.push(layout); + } + }; + + /** + * @param {string} stage + * @param {Function} visualCodingFunc + */ + echarts.registerVisualCoding = function (stage, visualCodingFunc) { + if (zrUtil.indexOf(VISUAL_CODING_STAGES, stage) < 0) { + throw new Error('stage should be one of ' + VISUAL_CODING_STAGES); + } + var funcs = visualCodingFuncs[stage] || (visualCodingFuncs[stage] = []); + funcs.push(visualCodingFunc); + }; + + /** + * @param {Object} opts + */ + echarts.extendChartView = function (opts) { + return ChartView.extend(opts); + }; + + /** + * @param {Object} opts + */ + echarts.extendComponentModel = function (opts) { + return ComponentModel.extend(opts); + }; + + /** + * @param {Object} opts + */ + echarts.extendSeriesModel = function (opts) { + return SeriesModel.extend(opts); + }; + + /** + * @param {Object} opts + */ + echarts.extendComponentView = function (opts) { + return ComponentView.extend(opts); + }; + + /** + * ZRender need a canvas context to do measureText. + * But in node environment canvas may be created by node-canvas. + * So we need to specify how to create a canvas instead of using document.createElement('canvas') + * + * Be careful of using it in the browser. + * + * @param {Function} creator + * @example + * var Canvas = require('canvas'); + * var echarts = require('echarts'); + * echarts.setCanvasCreator(function () { + * // Small size is enough. + * return new Canvas(32, 32); + * }); + */ + echarts.setCanvasCreator = function (creator) { + zrUtil.createCanvas = creator; + }; + + echarts.registerVisualCoding('echarts', zrUtil.curry( + __webpack_require__(88), '', 'itemStyle' + )); + echarts.registerPreprocessor(__webpack_require__(89)); + + // Default action + echarts.registerAction({ + type: 'highlight', + event: 'highlight', + update: 'highlight' + }, zrUtil.noop); + echarts.registerAction({ + type: 'downplay', + event: 'downplay', + update: 'downplay' + }, zrUtil.noop); + + + // -------- + // Exports + // -------- + + echarts.graphic = __webpack_require__(42); + echarts.number = __webpack_require__(7); + echarts.format = __webpack_require__(6); + echarts.matrix = __webpack_require__(17); + echarts.vector = __webpack_require__(16); + + echarts.util = {}; + each([ + 'map', 'each', 'filter', 'indexOf', 'inherits', + 'reduce', 'filter', 'bind', 'curry', 'isArray', + 'isString', 'isObject', 'isFunction', 'extend' + ], + function (name) { + echarts.util[name] = zrUtil[name]; + } + ); + + module.exports = echarts; + + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * ECharts global model + * + * @module {echarts/model/Global} + * + */ + + + + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var Model = __webpack_require__(8); + var each = zrUtil.each; + var filter = zrUtil.filter; + var map = zrUtil.map; + var isArray = zrUtil.isArray; + var indexOf = zrUtil.indexOf; + var isObject = zrUtil.isObject; + + var ComponentModel = __webpack_require__(19); + + var globalDefault = __webpack_require__(23); + + var OPTION_INNER_KEY = '\0_ec_inner'; + + /** + * @alias module:echarts/model/Global + * + * @param {Object} option + * @param {module:echarts/model/Model} parentModel + * @param {Object} theme + */ + var GlobalModel = Model.extend({ + + constructor: GlobalModel, + + init: function (option, parentModel, theme, optionManager) { + theme = theme || {}; + + this.option = null; // Mark as not initialized. + + /** + * @type {module:echarts/model/Model} + * @private + */ + this._theme = new Model(theme); + + /** + * @type {module:echarts/model/OptionManager} + */ + this._optionManager = optionManager; + }, + + setOption: function (option, optionPreprocessorFuncs) { + zrUtil.assert( + !(OPTION_INNER_KEY in option), + 'please use chart.getOption()' + ); + + this._optionManager.setOption(option, optionPreprocessorFuncs); + + this.resetOption(); + }, + + /** + * @param {string} type null/undefined: reset all. + * 'recreate': force recreate all. + * 'timeline': only reset timeline option + * 'media': only reset media query option + * @return {boolean} Whether option changed. + */ + resetOption: function (type) { + var optionChanged = false; + var optionManager = this._optionManager; + + if (!type || type === 'recreate') { + var baseOption = optionManager.mountOption(type === 'recreate'); + + if (!this.option || type === 'recreate') { + initBase.call(this, baseOption); + } + else { + this.restoreData(); + this.mergeOption(baseOption); + } + optionChanged = true; + } + + if (type === 'timeline' || type === 'media') { + this.restoreData(); + } + + if (!type || type === 'recreate' || type === 'timeline') { + var timelineOption = optionManager.getTimelineOption(this); + timelineOption && (this.mergeOption(timelineOption), optionChanged = true); + } + + if (!type || type === 'recreate' || type === 'media') { + var mediaOptions = optionManager.getMediaOption(this, this._api); + if (mediaOptions.length) { + each(mediaOptions, function (mediaOption) { + this.mergeOption(mediaOption, optionChanged = true); + }, this); + } + } + + return optionChanged; + }, + + /** + * @protected + */ + mergeOption: function (newOption) { + var option = this.option; + var componentsMap = this._componentsMap; + var newCptTypes = []; + + // 如果不存在对应的 component model 则直接 merge + each(newOption, function (componentOption, mainType) { + if (componentOption == null) { + return; + } + + if (!ComponentModel.hasClass(mainType)) { + option[mainType] = option[mainType] == null + ? zrUtil.clone(componentOption) + : zrUtil.merge(option[mainType], componentOption, true); + } + else { + newCptTypes.push(mainType); + } + }); + + // FIXME OPTION 同步是否要改回原来的 + ComponentModel.topologicalTravel( + newCptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this + ); + + function visitComponent(mainType, dependencies) { + var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]); + + var mapResult = modelUtil.mappingToExists( + componentsMap[mainType], newCptOptionList + ); + + makeKeyInfo(mainType, mapResult); + + var dependentModels = getComponentsByTypes( + componentsMap, dependencies + ); + + option[mainType] = []; + componentsMap[mainType] = []; + + each(mapResult, function (resultItem, index) { + var componentModel = resultItem.exist; + var newCptOption = resultItem.option; + + zrUtil.assert( + isObject(newCptOption) || componentModel, + 'Empty component definition' + ); + + // Consider where is no new option and should be merged using {}, + // see removeEdgeAndAdd in topologicalTravel and + // ComponentModel.getAllClassMainTypes. + if (!newCptOption) { + componentModel.mergeOption({}, this); + componentModel.optionUpdated(this); + } + else { + var ComponentModelClass = ComponentModel.getClass( + mainType, resultItem.keyInfo.subType, true + ); + + if (componentModel && componentModel instanceof ComponentModelClass) { + componentModel.mergeOption(newCptOption, this); + componentModel.optionUpdated(this); + } + else { + // PENDING Global as parent ? + componentModel = new ComponentModelClass( + newCptOption, this, this, + zrUtil.extend( + { + dependentModels: dependentModels, + componentIndex: index + }, + resultItem.keyInfo + ) + ); + // Call optionUpdated after init + componentModel.optionUpdated(this); + } + } + + componentsMap[mainType][index] = componentModel; + option[mainType][index] = componentModel.option; + }, this); + + // Backup series for filtering. + if (mainType === 'series') { + this._seriesIndices = createSeriesIndices(componentsMap.series); + } + } + }, + + /** + * Get option for output (cloned option and inner info removed) + * @public + * @return {Object} + */ + getOption: function () { + var option = zrUtil.clone(this.option); + + each(option, function (opts, mainType) { + if (ComponentModel.hasClass(mainType)) { + var opts = modelUtil.normalizeToArray(opts); + for (var i = opts.length - 1; i >= 0; i--) { + // Remove options with inner id. + if (modelUtil.isIdInner(opts[i])) { + opts.splice(i, 1); + } + } + option[mainType] = opts; + } + }); + + delete option[OPTION_INNER_KEY]; + + return option; + }, + + /** + * @return {module:echarts/model/Model} + */ + getTheme: function () { + return this._theme; + }, + + /** + * @param {string} mainType + * @param {number} [idx=0] + * @return {module:echarts/model/Component} + */ + getComponent: function (mainType, idx) { + var list = this._componentsMap[mainType]; + if (list) { + return list[idx || 0]; + } + }, + + /** + * @param {Object} condition + * @param {string} condition.mainType + * @param {string} [condition.subType] If ignore, only query by mainType + * @param {number} [condition.index] Either input index or id or name. + * @param {string} [condition.id] Either input index or id or name. + * @param {string} [condition.name] Either input index or id or name. + * @return {Array.} + */ + queryComponents: function (condition) { + var mainType = condition.mainType; + if (!mainType) { + return []; + } + + var index = condition.index; + var id = condition.id; + var name = condition.name; + + var cpts = this._componentsMap[mainType]; + + if (!cpts || !cpts.length) { + return []; + } + + var result; + + if (index != null) { + if (!isArray(index)) { + index = [index]; + } + result = filter(map(index, function (idx) { + return cpts[idx]; + }), function (val) { + return !!val; + }); + } + else if (id != null) { + var isIdArray = isArray(id); + result = filter(cpts, function (cpt) { + return (isIdArray && indexOf(id, cpt.id) >= 0) + || (!isIdArray && cpt.id === id); + }); + } + else if (name != null) { + var isNameArray = isArray(name); + result = filter(cpts, function (cpt) { + return (isNameArray && indexOf(name, cpt.name) >= 0) + || (!isNameArray && cpt.name === name); + }); + } + + return filterBySubType(result, condition); + }, + + /** + * The interface is different from queryComponents, + * which is convenient for inner usage. + * + * @usage + * findComponents( + * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}, + * function (model, index) {...} + * ); + * + * findComponents( + * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}, + * function (model, index) {...} + * ); + * + * var result = findComponents( + * {mainType: 'series'}, + * function (model, index) {...} + * ); + * // result like [component0, componnet1, ...] + * + * @param {Object} condition + * @param {string} condition.mainType Mandatory. + * @param {string} [condition.subType] Optional. + * @param {Object} [condition.query] like {xxxIndex, xxxId, xxxName}, + * where xxx is mainType. + * If query attribute is null/undefined or has no index/id/name, + * do not filtering by query conditions, which is convenient for + * no-payload situations or when target of action is global. + * @param {Function} [condition.filter] parameter: component, return boolean. + * @return {Array.} + */ + findComponents: function (condition) { + var query = condition.query; + var mainType = condition.mainType; + + var queryCond = getQueryCond(query); + var result = queryCond + ? this.queryComponents(queryCond) + : this._componentsMap[mainType]; + + return doFilter(filterBySubType(result, condition)); + + function getQueryCond(q) { + var indexAttr = mainType + 'Index'; + var idAttr = mainType + 'Id'; + var nameAttr = mainType + 'Name'; + return q && ( + q.hasOwnProperty(indexAttr) + || q.hasOwnProperty(idAttr) + || q.hasOwnProperty(nameAttr) + ) + ? { + mainType: mainType, + // subType will be filtered finally. + index: q[indexAttr], + id: q[idAttr], + name: q[nameAttr] + } + : null; + } + + function doFilter(res) { + return condition.filter + ? filter(res, condition.filter) + : res; + } + }, + + /** + * @usage + * eachComponent('legend', function (legendModel, index) { + * ... + * }); + * eachComponent(function (componentType, model, index) { + * // componentType does not include subType + * // (componentType is 'xxx' but not 'xxx.aa') + * }); + * eachComponent( + * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}, + * function (model, index) {...} + * ); + * eachComponent( + * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}, + * function (model, index) {...} + * ); + * + * @param {string|Object=} mainType When mainType is object, the definition + * is the same as the method 'findComponents'. + * @param {Function} cb + * @param {*} context + */ + eachComponent: function (mainType, cb, context) { + var componentsMap = this._componentsMap; + + if (typeof mainType === 'function') { + context = cb; + cb = mainType; + each(componentsMap, function (components, componentType) { + each(components, function (component, index) { + cb.call(context, componentType, component, index); + }); + }); + } + else if (zrUtil.isString(mainType)) { + each(componentsMap[mainType], cb, context); + } + else if (isObject(mainType)) { + var queryResult = this.findComponents(mainType); + each(queryResult, cb, context); + } + }, + + /** + * @param {string} name + * @return {Array.} + */ + getSeriesByName: function (name) { + var series = this._componentsMap.series; + return filter(series, function (oneSeries) { + return oneSeries.name === name; + }); + }, + + /** + * @param {number} seriesIndex + * @return {module:echarts/model/Series} + */ + getSeriesByIndex: function (seriesIndex) { + return this._componentsMap.series[seriesIndex]; + }, + + /** + * @param {string} subType + * @return {Array.} + */ + getSeriesByType: function (subType) { + var series = this._componentsMap.series; + return filter(series, function (oneSeries) { + return oneSeries.subType === subType; + }); + }, + + /** + * @return {Array.} + */ + getSeries: function () { + return this._componentsMap.series.slice(); + }, + + /** + * After filtering, series may be different + * frome raw series. + * + * @param {Function} cb + * @param {*} context + */ + eachSeries: function (cb, context) { + assertSeriesInitialized(this); + each(this._seriesIndices, function (rawSeriesIndex) { + var series = this._componentsMap.series[rawSeriesIndex]; + cb.call(context, series, rawSeriesIndex); + }, this); + }, + + /** + * Iterate raw series before filtered. + * + * @param {Function} cb + * @param {*} context + */ + eachRawSeries: function (cb, context) { + each(this._componentsMap.series, cb, context); + }, + + /** + * After filtering, series may be different. + * frome raw series. + * + * @parma {string} subType + * @param {Function} cb + * @param {*} context + */ + eachSeriesByType: function (subType, cb, context) { + assertSeriesInitialized(this); + each(this._seriesIndices, function (rawSeriesIndex) { + var series = this._componentsMap.series[rawSeriesIndex]; + if (series.subType === subType) { + cb.call(context, series, rawSeriesIndex); + } + }, this); + }, + + /** + * Iterate raw series before filtered of given type. + * + * @parma {string} subType + * @param {Function} cb + * @param {*} context + */ + eachRawSeriesByType: function (subType, cb, context) { + return each(this.getSeriesByType(subType), cb, context); + }, + + /** + * @param {module:echarts/model/Series} seriesModel + */ + isSeriesFiltered: function (seriesModel) { + assertSeriesInitialized(this); + return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0; + }, + + /** + * @param {Function} cb + * @param {*} context + */ + filterSeries: function (cb, context) { + assertSeriesInitialized(this); + var filteredSeries = filter( + this._componentsMap.series, cb, context + ); + this._seriesIndices = createSeriesIndices(filteredSeries); + }, + + restoreData: function () { + var componentsMap = this._componentsMap; + + this._seriesIndices = createSeriesIndices(componentsMap.series); + + var componentTypes = []; + each(componentsMap, function (components, componentType) { + componentTypes.push(componentType); + }); + + ComponentModel.topologicalTravel( + componentTypes, + ComponentModel.getAllClassMainTypes(), + function (componentType, dependencies) { + each(componentsMap[componentType], function (component) { + component.restoreData(); + }); + } + ); + } + + }); + + /** + * @inner + */ + function mergeTheme(option, theme) { + for (var name in theme) { + // 如果有 component model 则把具体的 merge 逻辑交给该 model 处理 + if (!ComponentModel.hasClass(name)) { + if (typeof theme[name] === 'object') { + option[name] = !option[name] + ? zrUtil.clone(theme[name]) + : zrUtil.merge(option[name], theme[name], false); + } + else { + option[name] = theme[name]; + } + } + } + } + + function initBase(baseOption) { + baseOption = baseOption; + + // Using OPTION_INNER_KEY to mark that this option can not be used outside, + // i.e. `chart.setOption(chart.getModel().option);` is forbiden. + this.option = {}; + this.option[OPTION_INNER_KEY] = 1; + + /** + * @type {Object.>} + * @private + */ + this._componentsMap = {}; + + /** + * Mapping between filtered series list and raw series list. + * key: filtered series indices, value: raw series indices. + * @type {Array.} + * @private + */ + this._seriesIndices = null; + + mergeTheme(baseOption, this._theme.option); + + // TODO Needs clone when merging to the unexisted property + zrUtil.merge(baseOption, globalDefault, false); + + this.mergeOption(baseOption); + } + + /** + * @inner + * @param {Array.|string} types model types + * @return {Object} key: {string} type, value: {Array.} models + */ + function getComponentsByTypes(componentsMap, types) { + if (!zrUtil.isArray(types)) { + types = types ? [types] : []; + } + + var ret = {}; + each(types, function (type) { + ret[type] = (componentsMap[type] || []).slice(); + }); + + return ret; + } + + /** + * @inner + */ + function makeKeyInfo(mainType, mapResult) { + // We use this id to hash component models and view instances + // in echarts. id can be specified by user, or auto generated. + + // The id generation rule ensures new view instance are able + // to mapped to old instance when setOption are called in + // no-merge mode. So we generate model id by name and plus + // type in view id. + + // name can be duplicated among components, which is convenient + // to specify multi components (like series) by one name. + + // Ensure that each id is distinct. + var idMap = {}; + + each(mapResult, function (item, index) { + var existCpt = item.exist; + existCpt && (idMap[existCpt.id] = item); + }); + + each(mapResult, function (item, index) { + var opt = item.option; + + zrUtil.assert( + !opt || opt.id == null || !idMap[opt.id] || idMap[opt.id] === item, + 'id duplicates: ' + (opt && opt.id) + ); + + opt && opt.id != null && (idMap[opt.id] = item); + + // Complete subType + if (isObject(opt)) { + var subType = determineSubType(mainType, opt, item.exist); + item.keyInfo = {mainType: mainType, subType: subType}; + } + }); + + // Make name and id. + each(mapResult, function (item, index) { + var existCpt = item.exist; + var opt = item.option; + var keyInfo = item.keyInfo; + + if (!isObject(opt)) { + return; + } + + // name can be overwitten. Consider case: axis.name = '20km'. + // But id generated by name will not be changed, which affect + // only in that case: setOption with 'not merge mode' and view + // instance will be recreated, which can be accepted. + keyInfo.name = opt.name != null + ? opt.name + '' + : existCpt + ? existCpt.name + : '\0-'; + + if (existCpt) { + keyInfo.id = existCpt.id; + } + else if (opt.id != null) { + keyInfo.id = opt.id + ''; + } + else { + // Consider this situatoin: + // optionA: [{name: 'a'}, {name: 'a'}, {..}] + // optionB [{..}, {name: 'a'}, {name: 'a'}] + // Series with the same name between optionA and optionB + // should be mapped. + var idNum = 0; + do { + keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++; + } + while (idMap[keyInfo.id]); + } + + idMap[keyInfo.id] = item; + }); + } + + /** + * @inner + */ + function determineSubType(mainType, newCptOption, existComponent) { + var subType = newCptOption.type + ? newCptOption.type + : existComponent + ? existComponent.subType + // Use determineSubType only when there is no existComponent. + : ComponentModel.determineSubType(mainType, newCptOption); + + // tooltip, markline, markpoint may always has no subType + return subType; + } + + /** + * @inner + */ + function createSeriesIndices(seriesModels) { + return map(seriesModels, function (series) { + return series.componentIndex; + }) || []; + } + + /** + * @inner + */ + function filterBySubType(components, condition) { + // Using hasOwnProperty for restrict. Consider + // subType is undefined in user payload. + return condition.hasOwnProperty('subType') + ? filter(components, function (cpt) { + return cpt.subType === condition.subType; + }) + : components; + } + + /** + * @inner + */ + function assertSeriesInitialized(ecModel) { + // Components that use _seriesIndices should depends on series component, + // which make sure that their initialization is after series. + if (!ecModel._seriesIndices) { + // FIXME + // 验证和提示怎么写 + throw new Error('Series has not been initialized yet.'); + } + } + + module.exports = GlobalModel; + + +/***/ }, +/* 3 */ +/***/ function(module, exports, __webpack_require__) { + + /** + */ + + var Gradient = __webpack_require__(4); + // 用于处理merge时无法遍历Date等对象的问题 + var BUILTIN_OBJECT = { + '[object Function]': 1, + '[object RegExp]': 1, + '[object Date]': 1, + '[object Error]': 1, + '[object CanvasGradient]': 1 + }; + + var objToString = Object.prototype.toString; + + var arrayProto = Array.prototype; + var nativeForEach = arrayProto.forEach; + var nativeFilter = arrayProto.filter; + var nativeSlice = arrayProto.slice; + var nativeMap = arrayProto.map; + var nativeReduce = arrayProto.reduce; + + /** + * @param {*} source + * @return {*} 拷贝后的新对象 + */ + function clone(source) { + if (typeof source == 'object' && source !== null) { + var result = source; + if (source instanceof Array) { + result = []; + for (var i = 0, len = source.length; i < len; i++) { + result[i] = clone(source[i]); + } + } + else if ( + !isBuildInObject(source) + // 是否为 dom 对象 + && !isDom(source) + ) { + result = {}; + for (var key in source) { + if (source.hasOwnProperty(key)) { + result[key] = clone(source[key]); + } + } + } + + return result; + } + + return source; + } + + /** + * @param {*} target + * @param {*} source + * @param {boolean} [overwrite=false] + */ + function merge(target, source, overwrite) { + // We should escapse that source is string + // and enter for ... in ... + if (!isObject(source) || !isObject(target)) { + return overwrite ? clone(source) : target; + } + + for (var key in source) { + if (source.hasOwnProperty(key)) { + var targetProp = target[key]; + var sourceProp = source[key]; + + if (isObject(sourceProp) + && isObject(targetProp) + && !isArray(sourceProp) + && !isArray(targetProp) + && !isDom(sourceProp) + && !isDom(targetProp) + && !isBuildInObject(sourceProp) + && !isBuildInObject(targetProp) + ) { + // 如果需要递归覆盖,就递归调用merge + merge(targetProp, sourceProp, overwrite); + } + else if (overwrite || !(key in target)) { + // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况 + // NOTE,在 target[key] 不存在的时候也是直接覆盖 + target[key] = clone(source[key], true); + } + } + } + + return target; + } + + /** + * @param {Array} targetAndSources The first item is target, and the rests are source. + * @param {boolean} [overwrite=false] + * @return {*} target + */ + function mergeAll(targetAndSources, overwrite) { + var result = targetAndSources[0]; + for (var i = 1, len = targetAndSources.length; i < len; i++) { + result = merge(result, targetAndSources[i], overwrite); + } + return result; + } + + /** + * @param {*} target + * @param {*} source + */ + function extend(target, source) { + for (var key in source) { + if (source.hasOwnProperty(key)) { + target[key] = source[key]; + } + } + return target; + } + + /** + * @param {*} target + * @param {*} source + * @param {boolen} [overlay=false] + */ + function defaults(target, source, overlay) { + for (var key in source) { + if (source.hasOwnProperty(key) + && (overlay ? source[key] != null : target[key] == null) + ) { + target[key] = source[key]; + } + } + return target; + } + + function createCanvas() { + return document.createElement('canvas'); + } + // FIXME + var _ctx; + function getContext() { + if (!_ctx) { + // Use util.createCanvas instead of createCanvas + // because createCanvas may be overwritten in different environment + _ctx = util.createCanvas().getContext('2d'); + } + return _ctx; + } + + /** + * 查询数组中元素的index + */ + function indexOf(array, value) { + if (array) { + if (array.indexOf) { + return array.indexOf(value); + } + for (var i = 0, len = array.length; i < len; i++) { + if (array[i] === value) { + return i; + } + } + } + return -1; + } + + /** + * 构造类继承关系 + * + * @param {Function} clazz 源类 + * @param {Function} baseClazz 基类 + */ + function inherits(clazz, baseClazz) { + var clazzPrototype = clazz.prototype; + function F() {} + F.prototype = baseClazz.prototype; + clazz.prototype = new F(); + + for (var prop in clazzPrototype) { + clazz.prototype[prop] = clazzPrototype[prop]; + } + clazz.prototype.constructor = clazz; + clazz.superClass = baseClazz; + } + + /** + * @param {Object|Function} target + * @param {Object|Function} sorce + * @param {boolean} overlay + */ + function mixin(target, source, overlay) { + target = 'prototype' in target ? target.prototype : target; + source = 'prototype' in source ? source.prototype : source; + + defaults(target, source, overlay); + } + + /** + * @param {Array|TypedArray} data + */ + function isArrayLike(data) { + if (! data) { + return; + } + if (typeof data == 'string') { + return false; + } + return typeof data.length == 'number'; + } + + /** + * 数组或对象遍历 + * @memberOf module:zrender/tool/util + * @param {Object|Array} obj + * @param {Function} cb + * @param {*} [context] + */ + function each(obj, cb, context) { + if (!(obj && cb)) { + return; + } + if (obj.forEach && obj.forEach === nativeForEach) { + obj.forEach(cb, context); + } + else if (obj.length === +obj.length) { + for (var i = 0, len = obj.length; i < len; i++) { + cb.call(context, obj[i], i, obj); + } + } + else { + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + cb.call(context, obj[key], key, obj); + } + } + } + } + + /** + * 数组映射 + * @memberOf module:zrender/tool/util + * @param {Array} obj + * @param {Function} cb + * @param {*} [context] + * @return {Array} + */ + function map(obj, cb, context) { + if (!(obj && cb)) { + return; + } + if (obj.map && obj.map === nativeMap) { + return obj.map(cb, context); + } + else { + var result = []; + for (var i = 0, len = obj.length; i < len; i++) { + result.push(cb.call(context, obj[i], i, obj)); + } + return result; + } + } + + /** + * @memberOf module:zrender/tool/util + * @param {Array} obj + * @param {Function} cb + * @param {Object} [memo] + * @param {*} [context] + * @return {Array} + */ + function reduce(obj, cb, memo, context) { + if (!(obj && cb)) { + return; + } + if (obj.reduce && obj.reduce === nativeReduce) { + return obj.reduce(cb, memo, context); + } + else { + for (var i = 0, len = obj.length; i < len; i++) { + memo = cb.call(context, memo, obj[i], i, obj); + } + return memo; + } + } + + /** + * 数组过滤 + * @memberOf module:zrender/tool/util + * @param {Array} obj + * @param {Function} cb + * @param {*} [context] + * @return {Array} + */ + function filter(obj, cb, context) { + if (!(obj && cb)) { + return; + } + if (obj.filter && obj.filter === nativeFilter) { + return obj.filter(cb, context); + } + else { + var result = []; + for (var i = 0, len = obj.length; i < len; i++) { + if (cb.call(context, obj[i], i, obj)) { + result.push(obj[i]); + } + } + return result; + } + } + + /** + * 数组项查找 + * @memberOf module:zrender/tool/util + * @param {Array} obj + * @param {Function} cb + * @param {*} [context] + * @return {Array} + */ + function find(obj, cb, context) { + if (!(obj && cb)) { + return; + } + for (var i = 0, len = obj.length; i < len; i++) { + if (cb.call(context, obj[i], i, obj)) { + return obj[i]; + } + } + } + + /** + * @memberOf module:zrender/tool/util + * @param {Function} func + * @param {*} context + * @return {Function} + */ + function bind(func, context) { + var args = nativeSlice.call(arguments, 2); + return function () { + return func.apply(context, args.concat(nativeSlice.call(arguments))); + }; + } + + /** + * @memberOf module:zrender/tool/util + * @param {Function} func + * @param {...} + * @return {Function} + */ + function curry(func) { + var args = nativeSlice.call(arguments, 1); + return function () { + return func.apply(this, args.concat(nativeSlice.call(arguments))); + }; + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isArray(value) { + return objToString.call(value) === '[object Array]'; + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isFunction(value) { + return typeof value === 'function'; + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isString(value) { + return objToString.call(value) === '[object String]'; + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isObject(value) { + // Avoid a V8 JIT bug in Chrome 19-20. + // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. + var type = typeof value; + return type === 'function' || (!!value && type == 'object'); + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isBuildInObject(value) { + return !!BUILTIN_OBJECT[objToString.call(value)] + || (value instanceof Gradient); + } + + /** + * @memberOf module:zrender/tool/util + * @param {*} value + * @return {boolean} + */ + function isDom(value) { + return value && value.nodeType === 1 + && typeof(value.nodeName) == 'string'; + } + + /** + * If value1 is not null, then return value1, otherwise judget rest of values. + * @param {*...} values + * @return {*} Final value + */ + function retrieve(values) { + for (var i = 0, len = arguments.length; i < len; i++) { + if (arguments[i] != null) { + return arguments[i]; + } + } + } + + /** + * @memberOf module:zrender/tool/util + * @param {Array} arr + * @param {number} startIndex + * @param {number} endIndex + * @return {Array} + */ + function slice() { + return Function.call.apply(nativeSlice, arguments); + } + + /** + * @param {boolean} condition + * @param {string} message + */ + function assert(condition, message) { + if (!condition) { + throw new Error(message); + } + } + + var util = { + inherits: inherits, + mixin: mixin, + clone: clone, + merge: merge, + mergeAll: mergeAll, + extend: extend, + defaults: defaults, + getContext: getContext, + createCanvas: createCanvas, + indexOf: indexOf, + slice: slice, + find: find, + isArrayLike: isArrayLike, + each: each, + map: map, + reduce: reduce, + filter: filter, + bind: bind, + curry: curry, + isArray: isArray, + isString: isString, + isObject: isObject, + isFunction: isFunction, + isBuildInObject: isBuildInObject, + isDom: isDom, + retrieve: retrieve, + assert: assert, + noop: function () {} + }; + module.exports = util; + + + +/***/ }, +/* 4 */ +/***/ function(module, exports) { + + + + /** + * @param {Array.} colorStops + */ + var Gradient = function (colorStops) { + + this.colorStops = colorStops || []; + }; + + Gradient.prototype = { + + constructor: Gradient, + + addColorStop: function (offset, color) { + this.colorStops.push({ + + offset: offset, + + color: color + }); + } + }; + + module.exports = Gradient; + + +/***/ }, +/* 5 */ +/***/ function(module, exports, __webpack_require__) { + + + + var formatUtil = __webpack_require__(6); + var nubmerUtil = __webpack_require__(7); + var zrUtil = __webpack_require__(3); + + var Model = __webpack_require__(8); + + var AXIS_DIMS = ['x', 'y', 'z', 'radius', 'angle']; + + var modelUtil = {}; + + /** + * Create "each" method to iterate names. + * + * @pubilc + * @param {Array.} names + * @param {Array.=} attrs + * @return {Function} + */ + modelUtil.createNameEach = function (names, attrs) { + names = names.slice(); + var capitalNames = zrUtil.map(names, modelUtil.capitalFirst); + attrs = (attrs || []).slice(); + var capitalAttrs = zrUtil.map(attrs, modelUtil.capitalFirst); + + return function (callback, context) { + zrUtil.each(names, function (name, index) { + var nameObj = {name: name, capital: capitalNames[index]}; + + for (var j = 0; j < attrs.length; j++) { + nameObj[attrs[j]] = name + capitalAttrs[j]; + } + + callback.call(context, nameObj); + }); + }; + }; + + /** + * @public + */ + modelUtil.capitalFirst = function (str) { + return str ? str.charAt(0).toUpperCase() + str.substr(1) : str; + }; + + /** + * Iterate each dimension name. + * + * @public + * @param {Function} callback The parameter is like: + * { + * name: 'angle', + * capital: 'Angle', + * axis: 'angleAxis', + * axisIndex: 'angleAixs', + * index: 'angleIndex' + * } + * @param {Object} context + */ + modelUtil.eachAxisDim = modelUtil.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index']); + + /** + * If value is not array, then translate it to array. + * @param {*} value + * @return {Array} [value] or value + */ + modelUtil.normalizeToArray = function (value) { + return zrUtil.isArray(value) + ? value + : value == null + ? [] + : [value]; + }; + + /** + * If tow dataZoomModels has the same axis controlled, we say that they are 'linked'. + * dataZoomModels and 'links' make up one or more graphics. + * This function finds the graphic where the source dataZoomModel is in. + * + * @public + * @param {Function} forEachNode Node iterator. + * @param {Function} forEachEdgeType edgeType iterator + * @param {Function} edgeIdGetter Giving node and edgeType, return an array of edge id. + * @return {Function} Input: sourceNode, Output: Like {nodes: [], dims: {}} + */ + modelUtil.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) { + + return function (sourceNode) { + var result = { + nodes: [], + records: {} // key: edgeType.name, value: Object (key: edge id, value: boolean). + }; + + forEachEdgeType(function (edgeType) { + result.records[edgeType.name] = {}; + }); + + if (!sourceNode) { + return result; + } + + absorb(sourceNode, result); + + var existsLink; + do { + existsLink = false; + forEachNode(processSingleNode); + } + while (existsLink); + + function processSingleNode(node) { + if (!isNodeAbsorded(node, result) && isLinked(node, result)) { + absorb(node, result); + existsLink = true; + } + } + + return result; + }; + + function isNodeAbsorded(node, result) { + return zrUtil.indexOf(result.nodes, node) >= 0; + } + + function isLinked(node, result) { + var hasLink = false; + forEachEdgeType(function (edgeType) { + zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) { + result.records[edgeType.name][edgeId] && (hasLink = true); + }); + }); + return hasLink; + } + + function absorb(node, result) { + result.nodes.push(node); + forEachEdgeType(function (edgeType) { + zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) { + result.records[edgeType.name][edgeId] = true; + }); + }); + } + }; + + /** + * Sync default option between normal and emphasis like `position` and `show` + * In case some one will write code like + * label: { + * normal: { + * show: false, + * position: 'outside', + * textStyle: { + * fontSize: 18 + * } + * }, + * emphasis: { + * show: true + * } + * } + * @param {Object} opt + * @param {Array.} subOpts + */ + modelUtil.defaultEmphasis = function (opt, subOpts) { + if (opt) { + var emphasisOpt = opt.emphasis = opt.emphasis || {}; + var normalOpt = opt.normal = opt.normal || {}; + + // Default emphasis option from normal + zrUtil.each(subOpts, function (subOptName) { + var val = zrUtil.retrieve(emphasisOpt[subOptName], normalOpt[subOptName]); + if (val != null) { + emphasisOpt[subOptName] = val; + } + }); + } + }; + + /** + * Create a model proxy to be used in tooltip for edge data, markLine data, markPoint data. + * @param {Object} opt + * @param {string} [opt.seriesIndex] + * @param {Object} [opt.name] + * @param {module:echarts/data/List} data + * @param {Array.} rawData + */ + modelUtil.createDataFormatModel = function (opt, data, rawData) { + var model = new Model(); + zrUtil.mixin(model, modelUtil.dataFormatMixin); + model.seriesIndex = opt.seriesIndex; + model.name = opt.name || ''; + + model.getData = function () { + return data; + }; + model.getRawDataArray = function () { + return rawData; + }; + return model; + }; + + /** + * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}] + * This helper method retieves value from data. + * @param {string|number|Date|Array|Object} dataItem + * @return {number|string|Date|Array.} + */ + modelUtil.getDataItemValue = function (dataItem) { + // Performance sensitive. + return dataItem && (dataItem.value == null ? dataItem : dataItem.value); + }; + + /** + * This helper method convert value in data. + * @param {string|number|Date} value + * @param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'. + */ + modelUtil.converDataValue = function (value, dimInfo) { + // Performance sensitive. + var dimType = dimInfo && dimInfo.type; + if (dimType === 'ordinal') { + return value; + } + + if (dimType === 'time' && !isFinite(value) && value != null && value !== '-') { + value = +nubmerUtil.parseDate(value); + } + + // dimType defaults 'number'. + // If dimType is not ordinal and value is null or undefined or NaN or '-', + // parse to NaN. + return (value == null || value === '') + ? NaN : +value; // If string (like '-'), using '+' parse to NaN + }; + + modelUtil.dataFormatMixin = { + /** + * Get params for formatter + * @param {number} dataIndex + * @return {Object} + */ + getDataParams: function (dataIndex) { + var data = this.getData(); + + var seriesIndex = this.seriesIndex; + var seriesName = this.name; + + var rawValue = this.getRawValue(dataIndex); + var rawDataIndex = data.getRawIndex(dataIndex); + var name = data.getName(dataIndex, true); + + // Data may not exists in the option given by user + var rawDataArray = this.getRawDataArray(); + var itemOpt = rawDataArray && rawDataArray[rawDataIndex]; + + return { + seriesIndex: seriesIndex, + seriesName: seriesName, + name: name, + dataIndex: rawDataIndex, + data: itemOpt, + value: rawValue, + + // Param name list for mapping `a`, `b`, `c`, `d`, `e` + $vars: ['seriesName', 'name', 'value'] + }; + }, + + /** + * Format label + * @param {number} dataIndex + * @param {string} [status='normal'] 'normal' or 'emphasis' + * @param {Function|string} [formatter] Default use the `itemStyle[status].label.formatter` + * @return {string} + */ + getFormattedLabel: function (dataIndex, status, formatter) { + status = status || 'normal'; + var data = this.getData(); + var itemModel = data.getItemModel(dataIndex); + + var params = this.getDataParams(dataIndex); + if (formatter == null) { + formatter = itemModel.get(['label', status, 'formatter']); + } + + if (typeof formatter === 'function') { + params.status = status; + return formatter(params); + } + else if (typeof formatter === 'string') { + return formatUtil.formatTpl(formatter, params); + } + }, + + /** + * Get raw value in option + * @param {number} idx + * @return {Object} + */ + getRawValue: function (idx) { + var itemModel = this.getData().getItemModel(idx); + if (itemModel && itemModel.option != null) { + var dataItem = itemModel.option; + return (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem)) + ? dataItem.value : dataItem; + } + } + }; + + /** + * Mapping to exists for merge. + * + * @public + * @param {Array.|Array.} exists + * @param {Object|Array.} newCptOptions + * @return {Array.} Result, like [{exist: ..., option: ...}, {}], + * which order is the same as exists. + */ + modelUtil.mappingToExists = function (exists, newCptOptions) { + // Mapping by the order by original option (but not order of + // new option) in merge mode. Because we should ensure + // some specified index (like xAxisIndex) is consistent with + // original option, which is easy to understand, espatially in + // media query. And in most case, merge option is used to + // update partial option but not be expected to change order. + newCptOptions = (newCptOptions || []).slice(); + + var result = zrUtil.map(exists || [], function (obj, index) { + return {exist: obj}; + }); + + // Mapping by id or name if specified. + zrUtil.each(newCptOptions, function (cptOption, index) { + if (!zrUtil.isObject(cptOption)) { + return; + } + + for (var i = 0; i < result.length; i++) { + var exist = result[i].exist; + if (!result[i].option // Consider name: two map to one. + && ( + // id has highest priority. + (cptOption.id != null && exist.id === cptOption.id + '') + || (cptOption.name != null + && !modelUtil.isIdInner(cptOption) + && !modelUtil.isIdInner(exist) + && exist.name === cptOption.name + '' + ) + ) + ) { + result[i].option = cptOption; + newCptOptions[index] = null; + break; + } + } + }); + + // Otherwise mapping by index. + zrUtil.each(newCptOptions, function (cptOption, index) { + if (!zrUtil.isObject(cptOption)) { + return; + } + + var i = 0; + for (; i < result.length; i++) { + var exist = result[i].exist; + if (!result[i].option + && !modelUtil.isIdInner(exist) + // Caution: + // Do not overwrite id. But name can be overwritten, + // because axis use name as 'show label text'. + // 'exist' always has id and name and we dont + // need to check it. + && cptOption.id == null + ) { + result[i].option = cptOption; + break; + } + } + + if (i >= result.length) { + result.push({option: cptOption}); + } + }); + + return result; + }; + + /** + * @public + * @param {Object} cptOption + * @return {boolean} + */ + modelUtil.isIdInner = function (cptOption) { + return zrUtil.isObject(cptOption) + && cptOption.id + && (cptOption.id + '').indexOf('\0_ec_\0') === 0; + }; + + module.exports = modelUtil; + + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + + /** + * 每三位默认加,格式化 + * @type {string|number} x + */ + function addCommas(x) { + if (isNaN(x)) { + return '-'; + } + x = (x + '').split('.'); + return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,'$1,') + + (x.length > 1 ? ('.' + x[1]) : ''); + } + + /** + * @param {string} str + * @return {string} str + */ + function toCamelCase(str) { + return str.toLowerCase().replace(/-(.)/g, function(match, group1) { + return group1.toUpperCase(); + }); + } + + /** + * Normalize css liked array configuration + * e.g. + * 3 => [3, 3, 3, 3] + * [4, 2] => [4, 2, 4, 2] + * [4, 3, 2] => [4, 3, 2, 3] + * @param {number|Array.} val + */ + function normalizeCssArray(val) { + var len = val.length; + if (typeof (val) === 'number') { + return [val, val, val, val]; + } + else if (len === 2) { + // vertical | horizontal + return [val[0], val[1], val[0], val[1]]; + } + else if (len === 3) { + // top | horizontal | bottom + return [val[0], val[1], val[2], val[1]]; + } + return val; + } + + function encodeHTML(source) { + return String(source) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + } + + var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g']; + + function wrapVar(varName, seriesIdx) { + return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}'; + } + /** + * Template formatter + * @param {string} tpl + * @param {Array.|Object} paramsList + * @return {string} + */ + function formatTpl(tpl, paramsList) { + if (!zrUtil.isArray(paramsList)) { + paramsList = [paramsList]; + } + var seriesLen = paramsList.length; + if (!seriesLen) { + return ''; + } + + var $vars = paramsList[0].$vars; + for (var i = 0; i < $vars.length; i++) { + var alias = TPL_VAR_ALIAS[i]; + tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0)); + } + for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) { + for (var k = 0; k < $vars.length; k++) { + tpl = tpl.replace( + wrapVar(TPL_VAR_ALIAS[k], seriesIdx), + paramsList[seriesIdx][$vars[k]] + ); + } + } + + return tpl; + } + + /** + * ISO Date format + * @param {string} tpl + * @param {number} value + * @inner + */ + function formatTime(tpl, value) { + if (tpl === 'week' + || tpl === 'month' + || tpl === 'quarter' + || tpl === 'half-year' + || tpl === 'year' + ) { + tpl = 'MM-dd\nyyyy'; + } + + var date = numberUtil.parseDate(value); + var y = date.getFullYear(); + var M = date.getMonth() + 1; + var d = date.getDate(); + var h = date.getHours(); + var m = date.getMinutes(); + var s = date.getSeconds(); + + tpl = tpl.replace('MM', s2d(M)) + .toLowerCase() + .replace('yyyy', y) + .replace('yy', y % 100) + .replace('dd', s2d(d)) + .replace('d', d) + .replace('hh', s2d(h)) + .replace('h', h) + .replace('mm', s2d(m)) + .replace('m', m) + .replace('ss', s2d(s)) + .replace('s', s); + + return tpl; + } + + /** + * @param {string} str + * @return {string} + * @inner + */ + function s2d(str) { + return str < 10 ? ('0' + str) : str; + } + + module.exports = { + + normalizeCssArray: normalizeCssArray, + + addCommas: addCommas, + + toCamelCase: toCamelCase, + + encodeHTML: encodeHTML, + + formatTpl: formatTpl, + + formatTime: formatTime + }; + + +/***/ }, +/* 7 */ +/***/ function(module, exports) { + + /** + * 数值处理模块 + * @module echarts/util/number + */ + + + + var number = {}; + + var RADIAN_EPSILON = 1e-4; + + function _trim(str) { + return str.replace(/^\s+/, '').replace(/\s+$/, ''); + } + + /** + * Linear mapping a value from domain to range + * @memberOf module:echarts/util/number + * @param {(number|Array.)} val + * @param {Array.} domain Domain extent domain[0] can be bigger than domain[1] + * @param {Array.} range Range extent range[0] can be bigger than range[1] + * @param {boolean} clamp + * @return {(number|Array.} + */ + number.linearMap = function (val, domain, range, clamp) { + + var sub = domain[1] - domain[0]; + + if (sub === 0) { + return (range[0] + range[1]) / 2; + } + var t = (val - domain[0]) / sub; + + if (clamp) { + t = Math.min(Math.max(t, 0), 1); + } + + return t * (range[1] - range[0]) + range[0]; + }; + + /** + * Convert a percent string to absolute number. + * Returns NaN if percent is not a valid string or number + * @memberOf module:echarts/util/number + * @param {string|number} percent + * @param {number} all + * @return {number} + */ + number.parsePercent = function(percent, all) { + switch (percent) { + case 'center': + case 'middle': + percent = '50%'; + break; + case 'left': + case 'top': + percent = '0%'; + break; + case 'right': + case 'bottom': + percent = '100%'; + break; + } + if (typeof percent === 'string') { + if (_trim(percent).match(/%$/)) { + return parseFloat(percent) / 100 * all; + } + + return parseFloat(percent); + } + + return percent == null ? NaN : +percent; + }; + + /** + * Fix rounding error of float numbers + * @param {number} x + * @return {number} + */ + number.round = function (x) { + // PENDING + return +(+x).toFixed(12); + }; + + number.asc = function (arr) { + arr.sort(function (a, b) { + return a - b; + }); + return arr; + }; + + /** + * Get precision + * @param {number} val + */ + number.getPrecision = function (val) { + if (isNaN(val)) { + return 0; + } + // It is much faster than methods converting number to string as follows + // var tmp = val.toString(); + // return tmp.length - 1 - tmp.indexOf('.'); + // especially when precision is low + var e = 1; + var count = 0; + while (Math.round(val * e) / e !== val) { + e *= 10; + count++; + } + return count; + }; + + /** + * @param {Array.} dataExtent + * @param {Array.} pixelExtent + * @return {number} precision + */ + number.getPixelPrecision = function (dataExtent, pixelExtent) { + var log = Math.log; + var LN10 = Math.LN10; + var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10); + var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10); + return Math.max( + -dataQuantity + sizeQuantity, + 0 + ); + }; + + // Number.MAX_SAFE_INTEGER, ie do not support. + number.MAX_SAFE_INTEGER = 9007199254740991; + + /** + * To 0 - 2 * PI, considering negative radian. + * @param {number} radian + * @return {number} + */ + number.remRadian = function (radian) { + var pi2 = Math.PI * 2; + return (radian % pi2 + pi2) % pi2; + }; + + /** + * @param {type} radian + * @return {boolean} + */ + number.isRadianAroundZero = function (val) { + return val > -RADIAN_EPSILON && val < RADIAN_EPSILON; + }; + + /** + * @param {string|Date|number} value + * @return {number} timestamp + */ + number.parseDate = function (value) { + return value instanceof Date + ? value + : new Date( + typeof value === 'string' + ? value.replace(/-/g, '/') + : Math.round(value) + ); + }; + + // "Nice Numbers for Graph Labels" of Graphic Gems + /** + * find a “nice” number approximately equal to x. Round the number if round = true, take ceiling if round = false + * The primary observation is that the “nicest” numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers. + * @param {number} val + * @param {boolean} round + * @return {number} + */ + number.nice = function (val, round) { + var exp = Math.floor(Math.log(val) / Math.LN10); + var exp10 = Math.pow(10, exp); + var f = val / exp10; // between 1 and 10 + var nf; + if (round) { + if (f < 1.5) { nf = 1; } + else if (f < 2.5) { nf = 2; } + else if (f < 4) { nf = 3; } + else if (f < 7) { nf = 5; } + else { nf = 10; } + } + else { + if (f < 1) { nf = 1; } + else if (f < 2) { nf = 2; } + else if (f < 3) { nf = 3; } + else if (f < 5) { nf = 5; } + else { nf = 10; } + } + return nf * exp10; + }; + + module.exports = number; + + +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/model/Model + */ + + + var zrUtil = __webpack_require__(3); + var clazzUtil = __webpack_require__(9); + + /** + * @alias module:echarts/model/Model + * @constructor + * @param {Object} option + * @param {module:echarts/model/Model} parentModel + * @param {module:echarts/model/Global} ecModel + * @param {Object} extraOpt + */ + function Model(option, parentModel, ecModel, extraOpt) { + /** + * @type {module:echarts/model/Model} + * @readOnly + */ + this.parentModel = parentModel; + + /** + * @type {module:echarts/model/Global} + * @readOnly + */ + this.ecModel = ecModel; + + /** + * @type {Object} + * @protected + */ + this.option = option; + + // Simple optimization + if (this.init) { + if (arguments.length <= 4) { + this.init(option, parentModel, ecModel, extraOpt); + } + else { + this.init.apply(this, arguments); + } + } + } + + Model.prototype = { + + constructor: Model, + + /** + * Model 的初始化函数 + * @param {Object} option + */ + init: null, + + /** + * 从新的 Option merge + */ + mergeOption: function (option) { + zrUtil.merge(this.option, option, true); + }, + + /** + * @param {string} path + * @param {boolean} [ignoreParent=false] + * @return {*} + */ + get: function (path, ignoreParent) { + if (!path) { + return this.option; + } + + if (typeof path === 'string') { + path = path.split('.'); + } + + var obj = this.option; + var parentModel = this.parentModel; + for (var i = 0; i < path.length; i++) { + // obj could be number/string/... (like 0) + obj = (obj && typeof obj === 'object') ? obj[path[i]] : null; + if (obj == null) { + break; + } + } + if (obj == null && parentModel && !ignoreParent) { + obj = parentModel.get(path); + } + return obj; + }, + + /** + * @param {string} key + * @param {boolean} [ignoreParent=false] + * @return {*} + */ + getShallow: function (key, ignoreParent) { + var option = this.option; + var val = option && option[key]; + var parentModel = this.parentModel; + if (val == null && parentModel && !ignoreParent) { + val = parentModel.getShallow(key); + } + return val; + }, + + /** + * @param {string} path + * @param {module:echarts/model/Model} [parentModel] + * @return {module:echarts/model/Model} + */ + getModel: function (path, parentModel) { + var obj = this.get(path, true); + var thisParentModel = this.parentModel; + var model = new Model( + obj, parentModel || (thisParentModel && thisParentModel.getModel(path)), + this.ecModel + ); + return model; + }, + + /** + * If model has option + */ + isEmpty: function () { + return this.option == null; + }, + + restoreData: function () {}, + + // Pending + clone: function () { + var Ctor = this.constructor; + return new Ctor(zrUtil.clone(this.option)); + }, + + setReadOnly: function (properties) { + clazzUtil.setReadOnly(this, properties); + } + }; + + // Enable Model.extend. + clazzUtil.enableClassExtend(Model); + + var mixin = zrUtil.mixin; + mixin(Model, __webpack_require__(10)); + mixin(Model, __webpack_require__(12)); + mixin(Model, __webpack_require__(13)); + mixin(Model, __webpack_require__(18)); + + module.exports = Model; + + +/***/ }, +/* 9 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + var clazz = {}; + + var TYPE_DELIMITER = '.'; + var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___'; + /** + * @public + */ + var parseClassType = clazz.parseClassType = function (componentType) { + var ret = {main: '', sub: ''}; + if (componentType) { + componentType = componentType.split(TYPE_DELIMITER); + ret.main = componentType[0] || ''; + ret.sub = componentType[1] || ''; + } + return ret; + }; + /** + * @public + */ + clazz.enableClassExtend = function (RootClass, preConstruct) { + RootClass.extend = function (proto) { + var ExtendedClass = function () { + preConstruct && preConstruct.apply(this, arguments); + RootClass.apply(this, arguments); + }; + + zrUtil.extend(ExtendedClass.prototype, proto); + + ExtendedClass.extend = this.extend; + ExtendedClass.superCall = superCall; + ExtendedClass.superApply = superApply; + zrUtil.inherits(ExtendedClass, this); + ExtendedClass.superClass = this; + + return ExtendedClass; + }; + }; + + // superCall should have class info, which can not be fetch from 'this'. + // Consider this case: + // class A has method f, + // class B inherits class A, overrides method f, f call superApply('f'), + // class C inherits class B, do not overrides method f, + // then when method of class C is called, dead loop occured. + function superCall(context, methodName) { + var args = zrUtil.slice(arguments, 2); + return this.superClass.prototype[methodName].apply(context, args); + } + + function superApply(context, methodName, args) { + return this.superClass.prototype[methodName].apply(context, args); + } + + /** + * @param {Object} entity + * @param {Object} options + * @param {boolean} [options.registerWhenExtend] + * @public + */ + clazz.enableClassManagement = function (entity, options) { + options = options || {}; + + /** + * Component model classes + * key: componentType, + * value: + * componentClass, when componentType is 'xxx' + * or Object., when componentType is 'xxx.yy' + * @type {Object} + */ + var storage = {}; + + entity.registerClass = function (Clazz, componentType) { + if (componentType) { + componentType = parseClassType(componentType); + + if (!componentType.sub) { + if (storage[componentType.main]) { + throw new Error(componentType.main + 'exists'); + } + storage[componentType.main] = Clazz; + } + else if (componentType.sub !== IS_CONTAINER) { + var container = makeContainer(componentType); + container[componentType.sub] = Clazz; + } + } + return Clazz; + }; + + entity.getClass = function (componentTypeMain, subType, throwWhenNotFound) { + var Clazz = storage[componentTypeMain]; + + if (Clazz && Clazz[IS_CONTAINER]) { + Clazz = subType ? Clazz[subType] : null; + } + + if (throwWhenNotFound && !Clazz) { + throw new Error( + 'Component ' + componentTypeMain + '.' + (subType || '') + ' not exists' + ); + } + + return Clazz; + }; + + entity.getClassesByMainType = function (componentType) { + componentType = parseClassType(componentType); + + var result = []; + var obj = storage[componentType.main]; + + if (obj && obj[IS_CONTAINER]) { + zrUtil.each(obj, function (o, type) { + type !== IS_CONTAINER && result.push(o); + }); + } + else { + result.push(obj); + } + + return result; + }; + + entity.hasClass = function (componentType) { + // Just consider componentType.main. + componentType = parseClassType(componentType); + return !!storage[componentType.main]; + }; + + /** + * @return {Array.} Like ['aa', 'bb'], but can not be ['aa.xx'] + */ + entity.getAllClassMainTypes = function () { + var types = []; + zrUtil.each(storage, function (obj, type) { + types.push(type); + }); + return types; + }; + + /** + * If a main type is container and has sub types + * @param {string} mainType + * @return {boolean} + */ + entity.hasSubTypes = function (componentType) { + componentType = parseClassType(componentType); + var obj = storage[componentType.main]; + return obj && obj[IS_CONTAINER]; + }; + + entity.parseClassType = parseClassType; + + function makeContainer(componentType) { + var container = storage[componentType.main]; + if (!container || !container[IS_CONTAINER]) { + container = storage[componentType.main] = {}; + container[IS_CONTAINER] = true; + } + return container; + } + + if (options.registerWhenExtend) { + var originalExtend = entity.extend; + if (originalExtend) { + entity.extend = function (proto) { + var ExtendedClass = originalExtend.call(this, proto); + return entity.registerClass(ExtendedClass, proto.type); + }; + } + } + + return entity; + }; + + /** + * @param {string|Array.} properties + */ + clazz.setReadOnly = function (obj, properties) { + // FIXME It seems broken in IE8 simulation of IE11 + // if (!zrUtil.isArray(properties)) { + // properties = properties != null ? [properties] : []; + // } + // zrUtil.each(properties, function (prop) { + // var value = obj[prop]; + + // Object.defineProperty + // && Object.defineProperty(obj, prop, { + // value: value, writable: false + // }); + // zrUtil.isArray(obj[prop]) + // && Object.freeze + // && Object.freeze(obj[prop]); + // }); + }; + + module.exports = clazz; + + +/***/ }, +/* 10 */ +/***/ function(module, exports, __webpack_require__) { + + + var getLineStyle = __webpack_require__(11)( + [ + ['lineWidth', 'width'], + ['stroke', 'color'], + ['opacity'], + ['shadowBlur'], + ['shadowOffsetX'], + ['shadowOffsetY'], + ['shadowColor'] + ] + ); + module.exports = { + getLineStyle: function (excludes) { + var style = getLineStyle.call(this, excludes); + var lineDash = this.getLineDash(); + lineDash && (style.lineDash = lineDash); + return style; + }, + + getLineDash: function () { + var lineType = this.get('type'); + return (lineType === 'solid' || lineType == null) ? null + : (lineType === 'dashed' ? [5, 5] : [1, 1]); + } + }; + + +/***/ }, +/* 11 */ +/***/ function(module, exports, __webpack_require__) { + + // TODO Parse shadow style + // TODO Only shallow path support + + var zrUtil = __webpack_require__(3); + + module.exports = function (properties) { + // Normalize + for (var i = 0; i < properties.length; i++) { + if (!properties[i][1]) { + properties[i][1] = properties[i][0]; + } + } + return function (excludes) { + var style = {}; + for (var i = 0; i < properties.length; i++) { + var propName = properties[i][1]; + if (excludes && zrUtil.indexOf(excludes, propName) >= 0) { + continue; + } + var val = this.getShallow(propName); + if (val != null) { + style[properties[i][0]] = val; + } + } + return style; + }; + }; + + +/***/ }, +/* 12 */ +/***/ function(module, exports, __webpack_require__) { + + + module.exports = { + getAreaStyle: __webpack_require__(11)( + [ + ['fill', 'color'], + ['shadowBlur'], + ['shadowOffsetX'], + ['shadowOffsetY'], + ['opacity'], + ['shadowColor'] + ] + ) + }; + + +/***/ }, +/* 13 */ +/***/ function(module, exports, __webpack_require__) { + + + + var textContain = __webpack_require__(14); + + function getShallow(model, path) { + return model && model.getShallow(path); + } + + module.exports = { + /** + * Get color property or get color from option.textStyle.color + * @return {string} + */ + getTextColor: function () { + var ecModel = this.ecModel; + return this.getShallow('color') + || (ecModel && ecModel.get('textStyle.color')); + }, + + /** + * Create font string from fontStyle, fontWeight, fontSize, fontFamily + * @return {string} + */ + getFont: function () { + var ecModel = this.ecModel; + var gTextStyleModel = ecModel && ecModel.getModel('textStyle'); + return [ + // FIXME in node-canvas fontWeight is before fontStyle + this.getShallow('fontStyle') || getShallow(gTextStyleModel, 'fontStyle'), + this.getShallow('fontWeight') || getShallow(gTextStyleModel, 'fontWeight'), + (this.getShallow('fontSize') || getShallow(gTextStyleModel, 'fontSize') || 12) + 'px', + this.getShallow('fontFamily') || getShallow(gTextStyleModel, 'fontFamily') || 'sans-serif' + ].join(' '); + }, + + getTextRect: function (text) { + var textStyle = this.get('textStyle') || {}; + return textContain.getBoundingRect( + text, + this.getFont(), + textStyle.align, + textStyle.baseline + ); + }, + + ellipsis: function (text, containerWidth, options) { + return textContain.ellipsis( + text, this.getFont(), containerWidth, options + ); + } + }; + + +/***/ }, +/* 14 */ +/***/ function(module, exports, __webpack_require__) { + + + + var textWidthCache = {}; + var textWidthCacheCounter = 0; + var TEXT_CACHE_MAX = 5000; + + var util = __webpack_require__(3); + var BoundingRect = __webpack_require__(15); + + function getTextWidth(text, textFont) { + var key = text + ':' + textFont; + if (textWidthCache[key]) { + return textWidthCache[key]; + } + + var textLines = (text + '').split('\n'); + var width = 0; + + for (var i = 0, l = textLines.length; i < l; i++) { + // measureText 可以被覆盖以兼容不支持 Canvas 的环境 + width = Math.max(textContain.measureText(textLines[i], textFont).width, width); + } + + if (textWidthCacheCounter > TEXT_CACHE_MAX) { + textWidthCacheCounter = 0; + textWidthCache = {}; + } + textWidthCacheCounter++; + textWidthCache[key] = width; + + return width; + } + + function getTextRect(text, textFont, textAlign, textBaseline) { + var textLineLen = ((text || '') + '').split('\n').length; + + var width = getTextWidth(text, textFont); + // FIXME 高度计算比较粗暴 + var lineHeight = getTextWidth('国', textFont); + var height = textLineLen * lineHeight; + + var rect = new BoundingRect(0, 0, width, height); + // Text has a special line height property + rect.lineHeight = lineHeight; + + switch (textBaseline) { + case 'bottom': + case 'alphabetic': + rect.y -= lineHeight; + break; + case 'middle': + rect.y -= lineHeight / 2; + break; + // case 'hanging': + // case 'top': + } + + // FIXME Right to left language + switch (textAlign) { + case 'end': + case 'right': + rect.x -= rect.width; + break; + case 'center': + rect.x -= rect.width / 2; + break; + // case 'start': + // case 'left': + } + + return rect; + } + + function adjustTextPositionOnRect(textPosition, rect, textRect, distance) { + + var x = rect.x; + var y = rect.y; + + var height = rect.height; + var width = rect.width; + + var textHeight = textRect.height; + + var halfHeight = height / 2 - textHeight / 2; + + var textAlign = 'left'; + + switch (textPosition) { + case 'left': + x -= distance; + y += halfHeight; + textAlign = 'right'; + break; + case 'right': + x += distance + width; + y += halfHeight; + textAlign = 'left'; + break; + case 'top': + x += width / 2; + y -= distance + textHeight; + textAlign = 'center'; + break; + case 'bottom': + x += width / 2; + y += height + distance; + textAlign = 'center'; + break; + case 'inside': + x += width / 2; + y += halfHeight; + textAlign = 'center'; + break; + case 'insideLeft': + x += distance; + y += halfHeight; + textAlign = 'left'; + break; + case 'insideRight': + x += width - distance; + y += halfHeight; + textAlign = 'right'; + break; + case 'insideTop': + x += width / 2; + y += distance; + textAlign = 'center'; + break; + case 'insideBottom': + x += width / 2; + y += height - textHeight - distance; + textAlign = 'center'; + break; + case 'insideTopLeft': + x += distance; + y += distance; + textAlign = 'left'; + break; + case 'insideTopRight': + x += width - distance; + y += distance; + textAlign = 'right'; + break; + case 'insideBottomLeft': + x += distance; + y += height - textHeight - distance; + break; + case 'insideBottomRight': + x += width - distance; + y += height - textHeight - distance; + textAlign = 'right'; + break; + } + + return { + x: x, + y: y, + textAlign: textAlign, + textBaseline: 'top' + }; + } + + /** + * Show ellipsis if overflow. + * + * @param {string} text + * @param {string} textFont + * @param {string} containerWidth + * @param {Object} [options] + * @param {number} [options.ellipsis='...'] + * @param {number} [options.maxIterations=3] + * @param {number} [options.minCharacters=3] + * @return {string} + */ + function textEllipsis(text, textFont, containerWidth, options) { + if (!containerWidth) { + return ''; + } + + options = util.defaults({ + ellipsis: '...', + minCharacters: 3, + maxIterations: 3, + cnCharWidth: getTextWidth('国', textFont), + // FIXME + // 未考虑非等宽字体 + ascCharWidth: getTextWidth('a', textFont) + }, options, true); + + containerWidth -= getTextWidth(options.ellipsis); + + var textLines = (text + '').split('\n'); + + for (var i = 0, len = textLines.length; i < len; i++) { + textLines[i] = textLineTruncate( + textLines[i], textFont, containerWidth, options + ); + } + + return textLines.join('\n'); + } + + function textLineTruncate(text, textFont, containerWidth, options) { + // FIXME + // 粗糙得写的,尚未考虑性能和各种语言、字体的效果。 + for (var i = 0;; i++) { + var lineWidth = getTextWidth(text, textFont); + + if (lineWidth < containerWidth || i >= options.maxIterations) { + text += options.ellipsis; + break; + } + + var subLength = i === 0 + ? estimateLength(text, containerWidth, options) + : Math.floor(text.length * containerWidth / lineWidth); + + if (subLength < options.minCharacters) { + text = ''; + break; + } + + text = text.substr(0, subLength); + } + + return text; + } + + function estimateLength(text, containerWidth, options) { + var width = 0; + var i = 0; + for (var len = text.length; i < len && width < containerWidth; i++) { + var charCode = text.charCodeAt(i); + width += (0 <= charCode && charCode <= 127) + ? options.ascCharWidth : options.cnCharWidth; + } + return i; + } + + var textContain = { + + getWidth: getTextWidth, + + getBoundingRect: getTextRect, + + adjustTextPositionOnRect: adjustTextPositionOnRect, + + ellipsis: textEllipsis, + + measureText: function (text, textFont) { + var ctx = util.getContext(); + ctx.font = textFont; + return ctx.measureText(text); + } + }; + + module.exports = textContain; + + +/***/ }, +/* 15 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * @module echarts/core/BoundingRect + */ + + + var vec2 = __webpack_require__(16); + var matrix = __webpack_require__(17); + + var v2ApplyTransform = vec2.applyTransform; + var mathMin = Math.min; + var mathAbs = Math.abs; + var mathMax = Math.max; + /** + * @alias module:echarts/core/BoundingRect + */ + function BoundingRect(x, y, width, height) { + /** + * @type {number} + */ + this.x = x; + /** + * @type {number} + */ + this.y = y; + /** + * @type {number} + */ + this.width = width; + /** + * @type {number} + */ + this.height = height; + } + + BoundingRect.prototype = { + + constructor: BoundingRect, + + /** + * @param {module:echarts/core/BoundingRect} other + */ + union: function (other) { + var x = mathMin(other.x, this.x); + var y = mathMin(other.y, this.y); + + this.width = mathMax( + other.x + other.width, + this.x + this.width + ) - x; + this.height = mathMax( + other.y + other.height, + this.y + this.height + ) - y; + this.x = x; + this.y = y; + }, + + /** + * @param {Array.} m + * @methods + */ + applyTransform: (function () { + var min = []; + var max = []; + return function (m) { + // In case usage like this + // el.getBoundingRect().applyTransform(el.transform) + // And element has no transform + if (!m) { + return; + } + min[0] = this.x; + min[1] = this.y; + max[0] = this.x + this.width; + max[1] = this.y + this.height; + + v2ApplyTransform(min, min, m); + v2ApplyTransform(max, max, m); + + this.x = mathMin(min[0], max[0]); + this.y = mathMin(min[1], max[1]); + this.width = mathAbs(max[0] - min[0]); + this.height = mathAbs(max[1] - min[1]); + }; + })(), + + /** + * Calculate matrix of transforming from self to target rect + * @param {module:zrender/core/BoundingRect} b + * @return {Array.} + */ + calculateTransform: function (b) { + var a = this; + var sx = b.width / a.width; + var sy = b.height / a.height; + + var m = matrix.create(); + + // 矩阵右乘 + matrix.translate(m, m, [-a.x, -a.y]); + matrix.scale(m, m, [sx, sy]); + matrix.translate(m, m, [b.x, b.y]); + + return m; + }, + + /** + * @param {(module:echarts/core/BoundingRect|Object)} b + * @return {boolean} + */ + intersect: function (b) { + var a = this; + var ax0 = a.x; + var ax1 = a.x + a.width; + var ay0 = a.y; + var ay1 = a.y + a.height; + + var bx0 = b.x; + var bx1 = b.x + b.width; + var by0 = b.y; + var by1 = b.y + b.height; + + return ! (ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0); + }, + + contain: function (x, y) { + var rect = this; + return x >= rect.x + && x <= (rect.x + rect.width) + && y >= rect.y + && y <= (rect.y + rect.height); + }, + + /** + * @return {module:echarts/core/BoundingRect} + */ + clone: function () { + return new BoundingRect(this.x, this.y, this.width, this.height); + }, + + /** + * Copy from another rect + */ + copy: function (other) { + this.x = other.x; + this.y = other.y; + this.width = other.width; + this.height = other.height; + } + }; + + module.exports = BoundingRect; + + +/***/ }, +/* 16 */ +/***/ function(module, exports) { + + + var ArrayCtor = typeof Float32Array === 'undefined' + ? Array + : Float32Array; + + /** + * @typedef {Float32Array|Array.} Vector2 + */ + /** + * 二维向量类 + * @exports zrender/tool/vector + */ + var vector = { + /** + * 创建一个向量 + * @param {number} [x=0] + * @param {number} [y=0] + * @return {Vector2} + */ + create: function (x, y) { + var out = new ArrayCtor(2); + out[0] = x || 0; + out[1] = y || 0; + return out; + }, + + /** + * 复制向量数据 + * @param {Vector2} out + * @param {Vector2} v + * @return {Vector2} + */ + copy: function (out, v) { + out[0] = v[0]; + out[1] = v[1]; + return out; + }, + + /** + * 克隆一个向量 + * @param {Vector2} v + * @return {Vector2} + */ + clone: function (v) { + var out = new ArrayCtor(2); + out[0] = v[0]; + out[1] = v[1]; + return out; + }, + + /** + * 设置向量的两个项 + * @param {Vector2} out + * @param {number} a + * @param {number} b + * @return {Vector2} 结果 + */ + set: function (out, a, b) { + out[0] = a; + out[1] = b; + return out; + }, + + /** + * 向量相加 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + add: function (out, v1, v2) { + out[0] = v1[0] + v2[0]; + out[1] = v1[1] + v2[1]; + return out; + }, + + /** + * 向量缩放后相加 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + * @param {number} a + */ + scaleAndAdd: function (out, v1, v2, a) { + out[0] = v1[0] + v2[0] * a; + out[1] = v1[1] + v2[1] * a; + return out; + }, + + /** + * 向量相减 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + sub: function (out, v1, v2) { + out[0] = v1[0] - v2[0]; + out[1] = v1[1] - v2[1]; + return out; + }, + + /** + * 向量长度 + * @param {Vector2} v + * @return {number} + */ + len: function (v) { + return Math.sqrt(this.lenSquare(v)); + }, + + /** + * 向量长度平方 + * @param {Vector2} v + * @return {number} + */ + lenSquare: function (v) { + return v[0] * v[0] + v[1] * v[1]; + }, + + /** + * 向量乘法 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + mul: function (out, v1, v2) { + out[0] = v1[0] * v2[0]; + out[1] = v1[1] * v2[1]; + return out; + }, + + /** + * 向量除法 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + div: function (out, v1, v2) { + out[0] = v1[0] / v2[0]; + out[1] = v1[1] / v2[1]; + return out; + }, + + /** + * 向量点乘 + * @param {Vector2} v1 + * @param {Vector2} v2 + * @return {number} + */ + dot: function (v1, v2) { + return v1[0] * v2[0] + v1[1] * v2[1]; + }, + + /** + * 向量缩放 + * @param {Vector2} out + * @param {Vector2} v + * @param {number} s + */ + scale: function (out, v, s) { + out[0] = v[0] * s; + out[1] = v[1] * s; + return out; + }, + + /** + * 向量归一化 + * @param {Vector2} out + * @param {Vector2} v + */ + normalize: function (out, v) { + var d = vector.len(v); + if (d === 0) { + out[0] = 0; + out[1] = 0; + } + else { + out[0] = v[0] / d; + out[1] = v[1] / d; + } + return out; + }, + + /** + * 计算向量间距离 + * @param {Vector2} v1 + * @param {Vector2} v2 + * @return {number} + */ + distance: function (v1, v2) { + return Math.sqrt( + (v1[0] - v2[0]) * (v1[0] - v2[0]) + + (v1[1] - v2[1]) * (v1[1] - v2[1]) + ); + }, + + /** + * 向量距离平方 + * @param {Vector2} v1 + * @param {Vector2} v2 + * @return {number} + */ + distanceSquare: function (v1, v2) { + return (v1[0] - v2[0]) * (v1[0] - v2[0]) + + (v1[1] - v2[1]) * (v1[1] - v2[1]); + }, + + /** + * 求负向量 + * @param {Vector2} out + * @param {Vector2} v + */ + negate: function (out, v) { + out[0] = -v[0]; + out[1] = -v[1]; + return out; + }, + + /** + * 插值两个点 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + * @param {number} t + */ + lerp: function (out, v1, v2, t) { + out[0] = v1[0] + t * (v2[0] - v1[0]); + out[1] = v1[1] + t * (v2[1] - v1[1]); + return out; + }, + + /** + * 矩阵左乘向量 + * @param {Vector2} out + * @param {Vector2} v + * @param {Vector2} m + */ + applyTransform: function (out, v, m) { + var x = v[0]; + var y = v[1]; + out[0] = m[0] * x + m[2] * y + m[4]; + out[1] = m[1] * x + m[3] * y + m[5]; + return out; + }, + /** + * 求两个向量最小值 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + min: function (out, v1, v2) { + out[0] = Math.min(v1[0], v2[0]); + out[1] = Math.min(v1[1], v2[1]); + return out; + }, + /** + * 求两个向量最大值 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ + max: function (out, v1, v2) { + out[0] = Math.max(v1[0], v2[0]); + out[1] = Math.max(v1[1], v2[1]); + return out; + } + }; + + vector.length = vector.len; + vector.lengthSquare = vector.lenSquare; + vector.dist = vector.distance; + vector.distSquare = vector.distanceSquare; + + module.exports = vector; + + + +/***/ }, +/* 17 */ +/***/ function(module, exports) { + + + var ArrayCtor = typeof Float32Array === 'undefined' + ? Array + : Float32Array; + /** + * 3x2矩阵操作类 + * @exports zrender/tool/matrix + */ + var matrix = { + /** + * 创建一个单位矩阵 + * @return {Float32Array|Array.} + */ + create : function() { + var out = new ArrayCtor(6); + matrix.identity(out); + + return out; + }, + /** + * 设置矩阵为单位矩阵 + * @param {Float32Array|Array.} out + */ + identity : function(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = 0; + out[5] = 0; + return out; + }, + /** + * 复制矩阵 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} m + */ + copy: function(out, m) { + out[0] = m[0]; + out[1] = m[1]; + out[2] = m[2]; + out[3] = m[3]; + out[4] = m[4]; + out[5] = m[5]; + return out; + }, + /** + * 矩阵相乘 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} m1 + * @param {Float32Array|Array.} m2 + */ + mul : function (out, m1, m2) { + // Consider matrix.mul(m, m2, m); + // where out is the same as m2. + // So use temp variable to escape error. + var out0 = m1[0] * m2[0] + m1[2] * m2[1]; + var out1 = m1[1] * m2[0] + m1[3] * m2[1]; + var out2 = m1[0] * m2[2] + m1[2] * m2[3]; + var out3 = m1[1] * m2[2] + m1[3] * m2[3]; + var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4]; + var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5]; + out[0] = out0; + out[1] = out1; + out[2] = out2; + out[3] = out3; + out[4] = out4; + out[5] = out5; + return out; + }, + /** + * 平移变换 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + * @param {Float32Array|Array.} v + */ + translate : function(out, a, v) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4] + v[0]; + out[5] = a[5] + v[1]; + return out; + }, + /** + * 旋转变换 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + * @param {number} rad + */ + rotate : function(out, a, rad) { + var aa = a[0]; + var ac = a[2]; + var atx = a[4]; + var ab = a[1]; + var ad = a[3]; + var aty = a[5]; + var st = Math.sin(rad); + var ct = Math.cos(rad); + + out[0] = aa * ct + ab * st; + out[1] = -aa * st + ab * ct; + out[2] = ac * ct + ad * st; + out[3] = -ac * st + ct * ad; + out[4] = ct * atx + st * aty; + out[5] = ct * aty - st * atx; + return out; + }, + /** + * 缩放变换 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + * @param {Float32Array|Array.} v + */ + scale : function(out, a, v) { + var vx = v[0]; + var vy = v[1]; + out[0] = a[0] * vx; + out[1] = a[1] * vy; + out[2] = a[2] * vx; + out[3] = a[3] * vy; + out[4] = a[4] * vx; + out[5] = a[5] * vy; + return out; + }, + /** + * 求逆矩阵 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + */ + invert : function(out, a) { + + var aa = a[0]; + var ac = a[2]; + var atx = a[4]; + var ab = a[1]; + var ad = a[3]; + var aty = a[5]; + + var det = aa * ad - ab * ac; + if (!det) { + return null; + } + det = 1.0 / det; + + out[0] = ad * det; + out[1] = -ab * det; + out[2] = -ac * det; + out[3] = aa * det; + out[4] = (ac * aty - ad * atx) * det; + out[5] = (ab * atx - aa * aty) * det; + return out; + } + }; + + module.exports = matrix; + + + +/***/ }, +/* 18 */ +/***/ function(module, exports, __webpack_require__) { + + + module.exports = { + getItemStyle: __webpack_require__(11)( + [ + ['fill', 'color'], + ['stroke', 'borderColor'], + ['lineWidth', 'borderWidth'], + ['opacity'], + ['shadowBlur'], + ['shadowOffsetX'], + ['shadowOffsetY'], + ['shadowColor'] + ] + ) + }; + + +/***/ }, +/* 19 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Component model + * + * @module echarts/model/Component + */ + + + var Model = __webpack_require__(8); + var zrUtil = __webpack_require__(3); + var arrayPush = Array.prototype.push; + var componentUtil = __webpack_require__(20); + var clazzUtil = __webpack_require__(9); + var layout = __webpack_require__(21); + + /** + * @alias module:echarts/model/Component + * @constructor + * @param {Object} option + * @param {module:echarts/model/Model} parentModel + * @param {module:echarts/model/Model} ecModel + */ + var ComponentModel = Model.extend({ + + type: 'component', + + /** + * @readOnly + * @type {string} + */ + id: '', + + /** + * @readOnly + */ + name: '', + + /** + * @readOnly + * @type {string} + */ + mainType: '', + + /** + * @readOnly + * @type {string} + */ + subType: '', + + /** + * @readOnly + * @type {number} + */ + componentIndex: 0, + + /** + * @type {Object} + * @protected + */ + defaultOption: null, + + /** + * @type {module:echarts/model/Global} + * @readOnly + */ + ecModel: null, + + /** + * key: componentType + * value: Component model list, can not be null. + * @type {Object.>} + * @readOnly + */ + dependentModels: [], + + /** + * @type {string} + * @readOnly + */ + uid: null, + + /** + * Support merge layout params. + * Only support 'box' now (left/right/top/bottom/width/height). + * @type {string|Object} Object can be {ignoreSize: true} + * @readOnly + */ + layoutMode: null, + + + init: function (option, parentModel, ecModel, extraOpt) { + this.mergeDefaultAndTheme(this.option, this.ecModel); + }, + + mergeDefaultAndTheme: function (option, ecModel) { + var layoutMode = this.layoutMode; + var inputPositionParams = layoutMode + ? layout.getLayoutParams(option) : {}; + + var themeModel = ecModel.getTheme(); + zrUtil.merge(option, themeModel.get(this.mainType)); + zrUtil.merge(option, this.getDefaultOption()); + + if (layoutMode) { + layout.mergeLayoutParam(option, inputPositionParams, layoutMode); + } + }, + + mergeOption: function (option) { + zrUtil.merge(this.option, option, true); + + var layoutMode = this.layoutMode; + if (layoutMode) { + layout.mergeLayoutParam(this.option, option, layoutMode); + } + }, + + // Hooker after init or mergeOption + optionUpdated: function (ecModel) {}, + + getDefaultOption: function () { + if (!this.hasOwnProperty('__defaultOption')) { + var optList = []; + var Class = this.constructor; + while (Class) { + var opt = Class.prototype.defaultOption; + opt && optList.push(opt); + Class = Class.superClass; + } + + var defaultOption = {}; + for (var i = optList.length - 1; i >= 0; i--) { + defaultOption = zrUtil.merge(defaultOption, optList[i], true); + } + this.__defaultOption = defaultOption; + } + return this.__defaultOption; + } + + }); + + // Reset ComponentModel.extend, add preConstruct. + clazzUtil.enableClassExtend( + ComponentModel, + function (option, parentModel, ecModel, extraOpt) { + // Set dependentModels, componentIndex, name, id, mainType, subType. + zrUtil.extend(this, extraOpt); + + this.uid = componentUtil.getUID('componentModel'); + + this.setReadOnly([ + 'type', 'id', 'uid', 'name', 'mainType', 'subType', + 'dependentModels', 'componentIndex' + ]); + } + ); + + // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. + clazzUtil.enableClassManagement( + ComponentModel, {registerWhenExtend: true} + ); + componentUtil.enableSubTypeDefaulter(ComponentModel); + + // Add capability of ComponentModel.topologicalTravel. + componentUtil.enableTopologicalTravel(ComponentModel, getDependencies); + + function getDependencies(componentType) { + var deps = []; + zrUtil.each(ComponentModel.getClassesByMainType(componentType), function (Clazz) { + arrayPush.apply(deps, Clazz.prototype.dependencies || []); + }); + // Ensure main type + return zrUtil.map(deps, function (type) { + return clazzUtil.parseClassType(type).main; + }); + } + + zrUtil.mixin(ComponentModel, __webpack_require__(22)); + + module.exports = ComponentModel; + + +/***/ }, +/* 20 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var clazz = __webpack_require__(9); + + var parseClassType = clazz.parseClassType; + + var base = 0; + + var componentUtil = {}; + + var DELIMITER = '_'; + + /** + * @public + * @param {string} type + * @return {string} + */ + componentUtil.getUID = function (type) { + // Considering the case of crossing js context, + // use Math.random to make id as unique as possible. + return [(type || ''), base++, Math.random()].join(DELIMITER); + }; + + /** + * @inner + */ + componentUtil.enableSubTypeDefaulter = function (entity) { + + var subTypeDefaulters = {}; + + entity.registerSubTypeDefaulter = function (componentType, defaulter) { + componentType = parseClassType(componentType); + subTypeDefaulters[componentType.main] = defaulter; + }; + + entity.determineSubType = function (componentType, option) { + var type = option.type; + if (!type) { + var componentTypeMain = parseClassType(componentType).main; + if (entity.hasSubTypes(componentType) && subTypeDefaulters[componentTypeMain]) { + type = subTypeDefaulters[componentTypeMain](option); + } + } + return type; + }; + + return entity; + }; + + /** + * Topological travel on Activity Network (Activity On Vertices). + * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis']. + * + * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology. + * + * If there is circle dependencey, Error will be thrown. + * + */ + componentUtil.enableTopologicalTravel = function (entity, dependencyGetter) { + + /** + * @public + * @param {Array.} targetNameList Target Component type list. + * Can be ['aa', 'bb', 'aa.xx'] + * @param {Array.} fullNameList By which we can build dependency graph. + * @param {Function} callback Params: componentType, dependencies. + * @param {Object} context Scope of callback. + */ + entity.topologicalTravel = function (targetNameList, fullNameList, callback, context) { + if (!targetNameList.length) { + return; + } + + var result = makeDepndencyGraph(fullNameList); + var graph = result.graph; + var stack = result.noEntryList; + + var targetNameSet = {}; + zrUtil.each(targetNameList, function (name) { + targetNameSet[name] = true; + }); + + while (stack.length) { + var currComponentType = stack.pop(); + var currVertex = graph[currComponentType]; + var isInTargetNameSet = !!targetNameSet[currComponentType]; + if (isInTargetNameSet) { + callback.call(context, currComponentType, currVertex.originalDeps.slice()); + delete targetNameSet[currComponentType]; + } + zrUtil.each( + currVertex.successor, + isInTargetNameSet ? removeEdgeAndAdd : removeEdge + ); + } + + zrUtil.each(targetNameSet, function () { + throw new Error('Circle dependency may exists'); + }); + + function removeEdge(succComponentType) { + graph[succComponentType].entryCount--; + if (graph[succComponentType].entryCount === 0) { + stack.push(succComponentType); + } + } + + // Consider this case: legend depends on series, and we call + // chart.setOption({series: [...]}), where only series is in option. + // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will + // not be called, but only sereis.mergeOption is called. Thus legend + // have no chance to update its local record about series (like which + // name of series is available in legend). + function removeEdgeAndAdd(succComponentType) { + targetNameSet[succComponentType] = true; + removeEdge(succComponentType); + } + }; + + /** + * DepndencyGraph: {Object} + * key: conponentType, + * value: { + * successor: [conponentTypes...], + * originalDeps: [conponentTypes...], + * entryCount: {number} + * } + */ + function makeDepndencyGraph(fullNameList) { + var graph = {}; + var noEntryList = []; + + zrUtil.each(fullNameList, function (name) { + + var thisItem = createDependencyGraphItem(graph, name); + var originalDeps = thisItem.originalDeps = dependencyGetter(name); + + var availableDeps = getAvailableDependencies(originalDeps, fullNameList); + thisItem.entryCount = availableDeps.length; + if (thisItem.entryCount === 0) { + noEntryList.push(name); + } + + zrUtil.each(availableDeps, function (dependentName) { + if (zrUtil.indexOf(thisItem.predecessor, dependentName) < 0) { + thisItem.predecessor.push(dependentName); + } + var thatItem = createDependencyGraphItem(graph, dependentName); + if (zrUtil.indexOf(thatItem.successor, dependentName) < 0) { + thatItem.successor.push(name); + } + }); + }); + + return {graph: graph, noEntryList: noEntryList}; + } + + function createDependencyGraphItem(graph, name) { + if (!graph[name]) { + graph[name] = {predecessor: [], successor: []}; + } + return graph[name]; + } + + function getAvailableDependencies(originalDeps, fullNameList) { + var availableDeps = []; + zrUtil.each(originalDeps, function (dep) { + zrUtil.indexOf(fullNameList, dep) >= 0 && availableDeps.push(dep); + }); + return availableDeps; + } + }; + + module.exports = componentUtil; + + +/***/ }, +/* 21 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // Layout helpers for each component positioning + + + var zrUtil = __webpack_require__(3); + var BoundingRect = __webpack_require__(15); + var numberUtil = __webpack_require__(7); + var formatUtil = __webpack_require__(6); + var parsePercent = numberUtil.parsePercent; + var each = zrUtil.each; + + var layout = {}; + + var LOCATION_PARAMS = ['left', 'right', 'top', 'bottom', 'width', 'height']; + + function boxLayout(orient, group, gap, maxWidth, maxHeight) { + var x = 0; + var y = 0; + if (maxWidth == null) { + maxWidth = Infinity; + } + if (maxHeight == null) { + maxHeight = Infinity; + } + var currentLineMaxSize = 0; + group.eachChild(function (child, idx) { + var position = child.position; + var rect = child.getBoundingRect(); + var nextChild = group.childAt(idx + 1); + var nextChildRect = nextChild && nextChild.getBoundingRect(); + var nextX; + var nextY; + if (orient === 'horizontal') { + var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0); + nextX = x + moveX; + // Wrap when width exceeds maxWidth or meet a `newline` group + if (nextX > maxWidth || child.newline) { + x = 0; + nextX = moveX; + y += currentLineMaxSize + gap; + currentLineMaxSize = rect.height; + } + else { + currentLineMaxSize = Math.max(currentLineMaxSize, rect.height); + } + } + else { + var moveY = rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0); + nextY = y + moveY; + // Wrap when width exceeds maxHeight or meet a `newline` group + if (nextY > maxHeight || child.newline) { + x += currentLineMaxSize + gap; + y = 0; + nextY = moveY; + currentLineMaxSize = rect.width; + } + else { + currentLineMaxSize = Math.max(currentLineMaxSize, rect.width); + } + } + + if (child.newline) { + return; + } + + position[0] = x; + position[1] = y; + + orient === 'horizontal' + ? (x = nextX + gap) + : (y = nextY + gap); + }); + } + + /** + * VBox or HBox layouting + * @param {string} orient + * @param {module:zrender/container/Group} group + * @param {number} gap + * @param {number} [width=Infinity] + * @param {number} [height=Infinity] + */ + layout.box = boxLayout; + + /** + * VBox layouting + * @param {module:zrender/container/Group} group + * @param {number} gap + * @param {number} [width=Infinity] + * @param {number} [height=Infinity] + */ + layout.vbox = zrUtil.curry(boxLayout, 'vertical'); + + /** + * HBox layouting + * @param {module:zrender/container/Group} group + * @param {number} gap + * @param {number} [width=Infinity] + * @param {number} [height=Infinity] + */ + layout.hbox = zrUtil.curry(boxLayout, 'horizontal'); + + /** + * If x or x2 is not specified or 'center' 'left' 'right', + * the width would be as long as possible. + * If y or y2 is not specified or 'middle' 'top' 'bottom', + * the height would be as long as possible. + * + * @param {Object} positionInfo + * @param {number|string} [positionInfo.x] + * @param {number|string} [positionInfo.y] + * @param {number|string} [positionInfo.x2] + * @param {number|string} [positionInfo.y2] + * @param {Object} containerRect + * @param {string|number} margin + * @return {Object} {width, height} + */ + layout.getAvailableSize = function (positionInfo, containerRect, margin) { + var containerWidth = containerRect.width; + var containerHeight = containerRect.height; + + var x = parsePercent(positionInfo.x, containerWidth); + var y = parsePercent(positionInfo.y, containerHeight); + var x2 = parsePercent(positionInfo.x2, containerWidth); + var y2 = parsePercent(positionInfo.y2, containerHeight); + + (isNaN(x) || isNaN(parseFloat(positionInfo.x))) && (x = 0); + (isNaN(x2) || isNaN(parseFloat(positionInfo.x2))) && (x2 = containerWidth); + (isNaN(y) || isNaN(parseFloat(positionInfo.y))) && (y = 0); + (isNaN(y2) || isNaN(parseFloat(positionInfo.y2))) && (y2 = containerHeight); + + margin = formatUtil.normalizeCssArray(margin || 0); + + return { + width: Math.max(x2 - x - margin[1] - margin[3], 0), + height: Math.max(y2 - y - margin[0] - margin[2], 0) + }; + }; + + /** + * Parse position info. + * + * @param {Object} positionInfo + * @param {number|string} [positionInfo.left] + * @param {number|string} [positionInfo.top] + * @param {number|string} [positionInfo.right] + * @param {number|string} [positionInfo.bottom] + * @param {number|string} [positionInfo.width] + * @param {number|string} [positionInfo.height] + * @param {number|string} [positionInfo.aspect] Aspect is width / height + * @param {Object} containerRect + * @param {string|number} [margin] + * + * @return {module:zrender/core/BoundingRect} + */ + layout.getLayoutRect = function ( + positionInfo, containerRect, margin + ) { + margin = formatUtil.normalizeCssArray(margin || 0); + + var containerWidth = containerRect.width; + var containerHeight = containerRect.height; + + var left = parsePercent(positionInfo.left, containerWidth); + var top = parsePercent(positionInfo.top, containerHeight); + var right = parsePercent(positionInfo.right, containerWidth); + var bottom = parsePercent(positionInfo.bottom, containerHeight); + var width = parsePercent(positionInfo.width, containerWidth); + var height = parsePercent(positionInfo.height, containerHeight); + + var verticalMargin = margin[2] + margin[0]; + var horizontalMargin = margin[1] + margin[3]; + var aspect = positionInfo.aspect; + + // If width is not specified, calculate width from left and right + if (isNaN(width)) { + width = containerWidth - right - horizontalMargin - left; + } + if (isNaN(height)) { + height = containerHeight - bottom - verticalMargin - top; + } + + // If width and height are not given + // 1. Graph should not exceeds the container + // 2. Aspect must be keeped + // 3. Graph should take the space as more as possible + if (isNaN(width) && isNaN(height)) { + if (aspect > containerWidth / containerHeight) { + width = containerWidth * 0.8; + } + else { + height = containerHeight * 0.8; + } + } + + if (aspect != null) { + // Calculate width or height with given aspect + if (isNaN(width)) { + width = aspect * height; + } + if (isNaN(height)) { + height = width / aspect; + } + } + + // If left is not specified, calculate left from right and width + if (isNaN(left)) { + left = containerWidth - right - width - horizontalMargin; + } + if (isNaN(top)) { + top = containerHeight - bottom - height - verticalMargin; + } + + // Align left and top + switch (positionInfo.left || positionInfo.right) { + case 'center': + left = containerWidth / 2 - width / 2 - margin[3]; + break; + case 'right': + left = containerWidth - width - horizontalMargin; + break; + } + switch (positionInfo.top || positionInfo.bottom) { + case 'middle': + case 'center': + top = containerHeight / 2 - height / 2 - margin[0]; + break; + case 'bottom': + top = containerHeight - height - verticalMargin; + break; + } + // If something is wrong and left, top, width, height are calculated as NaN + left = left || 0; + top = top || 0; + if (isNaN(width)) { + // Width may be NaN if only one value is given except width + width = containerWidth - left - (right || 0); + } + if (isNaN(height)) { + // Height may be NaN if only one value is given except height + height = containerHeight - top - (bottom || 0); + } + + var rect = new BoundingRect(left + margin[3], top + margin[0], width, height); + rect.margin = margin; + return rect; + }; + + /** + * Position group of component in viewport + * Group position is specified by either + * {left, top}, {right, bottom} + * If all properties exists, right and bottom will be igonred. + * + * @param {module:zrender/container/Group} group + * @param {Object} positionInfo + * @param {number|string} [positionInfo.left] + * @param {number|string} [positionInfo.top] + * @param {number|string} [positionInfo.right] + * @param {number|string} [positionInfo.bottom] + * @param {Object} containerRect + * @param {string|number} margin + */ + layout.positionGroup = function ( + group, positionInfo, containerRect, margin + ) { + var groupRect = group.getBoundingRect(); + + positionInfo = zrUtil.extend(zrUtil.clone(positionInfo), { + width: groupRect.width, + height: groupRect.height + }); + + positionInfo = layout.getLayoutRect( + positionInfo, containerRect, margin + ); + + group.position = [ + positionInfo.x - groupRect.x, + positionInfo.y - groupRect.y + ]; + }; + + /** + * Consider Case: + * When defulat option has {left: 0, width: 100}, and we set {right: 0} + * through setOption or media query, using normal zrUtil.merge will cause + * {right: 0} does not take effect. + * + * @example + * ComponentModel.extend({ + * init: function () { + * ... + * var inputPositionParams = layout.getLayoutParams(option); + * this.mergeOption(inputPositionParams); + * }, + * mergeOption: function (newOption) { + * newOption && zrUtil.merge(thisOption, newOption, true); + * layout.mergeLayoutParam(thisOption, newOption); + * } + * }); + * + * @param {Object} targetOption + * @param {Object} newOption + * @param {Object|string} [opt] + * @param {boolean} [opt.ignoreSize=false] Some component must has width and height. + */ + layout.mergeLayoutParam = function (targetOption, newOption, opt) { + !zrUtil.isObject(opt) && (opt = {}); + var hNames = ['width', 'left', 'right']; // Order by priority. + var vNames = ['height', 'top', 'bottom']; // Order by priority. + var hResult = merge(hNames); + var vResult = merge(vNames); + + copy(hNames, targetOption, hResult); + copy(vNames, targetOption, vResult); + + function merge(names) { + var newParams = {}; + var newValueCount = 0; + var merged = {}; + var mergedValueCount = 0; + var enoughParamNumber = opt.ignoreSize ? 1 : 2; + + each(names, function (name) { + merged[name] = targetOption[name]; + }); + each(names, function (name) { + // Consider case: newOption.width is null, which is + // set by user for removing width setting. + hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]); + hasValue(newParams, name) && newValueCount++; + hasValue(merged, name) && mergedValueCount++; + }); + + // Case: newOption: {width: ..., right: ...}, + // or targetOption: {right: ...} and newOption: {width: ...}, + // There is no conflict when merged only has params count + // little than enoughParamNumber. + if (mergedValueCount === enoughParamNumber || !newValueCount) { + return merged; + } + // Case: newOption: {width: ..., right: ...}, + // Than we can make sure user only want those two, and ignore + // all origin params in targetOption. + else if (newValueCount >= enoughParamNumber) { + return newParams; + } + else { + // Chose another param from targetOption by priority. + // When 'ignoreSize', enoughParamNumber is 1 and those will not happen. + for (var i = 0; i < names.length; i++) { + var name = names[i]; + if (!hasProp(newParams, name) && hasProp(targetOption, name)) { + newParams[name] = targetOption[name]; + break; + } + } + return newParams; + } + } + + function hasProp(obj, name) { + return obj.hasOwnProperty(name); + } + + function hasValue(obj, name) { + return obj[name] != null && obj[name] !== 'auto'; + } + + function copy(names, target, source) { + each(names, function (name) { + target[name] = source[name]; + }); + } + }; + + /** + * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object. + * @param {Object} source + * @return {Object} Result contains those props. + */ + layout.getLayoutParams = function (source) { + return layout.copyLayoutParams({}, source); + }; + + /** + * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object. + * @param {Object} source + * @return {Object} Result contains those props. + */ + layout.copyLayoutParams = function (target, source) { + source && target && each(LOCATION_PARAMS, function (name) { + source.hasOwnProperty(name) && (target[name] = source[name]); + }); + return target; + }; + + module.exports = layout; + + +/***/ }, +/* 22 */ +/***/ function(module, exports) { + + + + module.exports = { + getBoxLayoutParams: function () { + return { + left: this.get('left'), + top: this.get('top'), + right: this.get('right'), + bottom: this.get('bottom'), + width: this.get('width'), + height: this.get('height') + }; + } + }; + + +/***/ }, +/* 23 */ +/***/ function(module, exports) { + + + var platform = ''; + // Navigator not exists in node + if (typeof navigator !== 'undefined') { + platform = navigator.platform || ''; + } + module.exports = { + // 全图默认背景 + // backgroundColor: 'rgba(0,0,0,0)', + + // https://dribbble.com/shots/1065960-Infographic-Pie-chart-visualization + // color: ['#5793f3', '#d14a61', '#fd9c35', '#675bba', '#fec42c', '#dd4444', '#d4df5a', '#cd4870'], + // 浅色 + // color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'], + // color: ['#cc5664', '#9bd6ec', '#ea946e', '#8acaaa', '#f1ec64', '#ee8686', '#a48dc1', '#5da6bc', '#b9dcae'], + // 深色 + color: ['#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83', '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'], + + // 默认需要 Grid 配置项 + grid: {}, + // 主题,主题 + textStyle: { + // color: '#000', + // decoration: 'none', + // PENDING + fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif', + // fontFamily: 'Arial, Verdana, sans-serif', + fontSize: 12, + fontStyle: 'normal', + fontWeight: 'normal' + }, + // 主题,默认标志图形类型列表 + // symbolList: [ + // 'circle', 'rectangle', 'triangle', 'diamond', + // 'emptyCircle', 'emptyRectangle', 'emptyTriangle', 'emptyDiamond' + // ], + animation: true, // 过渡动画是否开启 + animationThreshold: 2000, // 动画元素阀值,产生的图形原素超过2000不出动画 + animationDuration: 1000, // 过渡动画参数:进入 + animationDurationUpdate: 300, // 过渡动画参数:更新 + animationEasing: 'exponentialOut', //BounceOut + animationEasingUpdate: 'cubicOut' + }; + + +/***/ }, +/* 24 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + + var echartsAPIList = [ + 'getDom', 'getZr', 'getWidth', 'getHeight', 'dispatchAction', + 'on', 'off', 'getDataURL', 'getConnectedDataURL', 'getModel', 'getOption' + ]; + + function ExtensionAPI(chartInstance) { + zrUtil.each(echartsAPIList, function (name) { + this[name] = zrUtil.bind(chartInstance[name], chartInstance); + }, this); + } + + module.exports = ExtensionAPI; + + +/***/ }, +/* 25 */ +/***/ function(module, exports) { + + 'use strict'; + + + // var zrUtil = require('zrender/lib/core/util'); + var coordinateSystemCreators = {}; + + function CoordinateSystemManager() { + + this._coordinateSystems = []; + } + + CoordinateSystemManager.prototype = { + + constructor: CoordinateSystemManager, + + create: function (ecModel, api) { + var coordinateSystems = []; + for (var type in coordinateSystemCreators) { + var list = coordinateSystemCreators[type].create(ecModel, api); + list && (coordinateSystems = coordinateSystems.concat(list)); + } + + this._coordinateSystems = coordinateSystems; + }, + + update: function (ecModel, api) { + var coordinateSystems = this._coordinateSystems; + for (var i = 0; i < coordinateSystems.length; i++) { + // FIXME MUST have + coordinateSystems[i].update && coordinateSystems[i].update(ecModel, api); + } + } + }; + + CoordinateSystemManager.register = function (type, coordinateSystemCreator) { + coordinateSystemCreators[type] = coordinateSystemCreator; + }; + + CoordinateSystemManager.get = function (type) { + return coordinateSystemCreators[type]; + }; + + module.exports = CoordinateSystemManager; + + +/***/ }, +/* 26 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * ECharts option manager + * + * @module {echarts/model/OptionManager} + */ + + + + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var ComponentModel = __webpack_require__(19); + var each = zrUtil.each; + var clone = zrUtil.clone; + var map = zrUtil.map; + var merge = zrUtil.merge; + + var QUERY_REG = /^(min|max)?(.+)$/; + + /** + * TERM EXPLANATIONS: + * + * [option]: + * + * An object that contains definitions of components. For example: + * var option = { + * title: {...}, + * legend: {...}, + * visualMap: {...}, + * series: [ + * {data: [...]}, + * {data: [...]}, + * ... + * ] + * }; + * + * [rawOption]: + * + * An object input to echarts.setOption. 'rawOption' may be an + * 'option', or may be an object contains multi-options. For example: + * var option = { + * baseOption: { + * title: {...}, + * legend: {...}, + * series: [ + * {data: [...]}, + * {data: [...]}, + * ... + * ] + * }, + * timeline: {...}, + * options: [ + * {title: {...}, series: {data: [...]}}, + * {title: {...}, series: {data: [...]}}, + * ... + * ], + * media: [ + * { + * query: {maxWidth: 320}, + * option: {series: {x: 20}, visualMap: {show: false}} + * }, + * { + * query: {minWidth: 320, maxWidth: 720}, + * option: {series: {x: 500}, visualMap: {show: true}} + * }, + * { + * option: {series: {x: 1200}, visualMap: {show: true}} + * } + * ] + * }; + * + * @alias module:echarts/model/OptionManager + * @param {module:echarts/ExtensionAPI} api + */ + function OptionManager(api) { + + /** + * @private + * @type {module:echarts/ExtensionAPI} + */ + this._api = api; + + /** + * @private + * @type {Array.} + */ + this._timelineOptions = []; + + /** + * @private + * @type {Array.} + */ + this._mediaList = []; + + /** + * @private + * @type {Object} + */ + this._mediaDefault; + + /** + * -1, means default. + * empty means no media. + * @private + * @type {Array.} + */ + this._currentMediaIndices = []; + + /** + * @private + * @type {Object} + */ + this._optionBackup; + + /** + * @private + * @type {Object} + */ + this._newOptionBackup; + } + + // timeline.notMerge is not supported in ec3. Firstly there is rearly + // case that notMerge is needed. Secondly supporting 'notMerge' requires + // rawOption cloned and backuped when timeline changed, which does no + // good to performance. What's more, that both timeline and setOption + // method supply 'notMerge' brings complex and some problems. + // Consider this case: + // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false); + // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false); + + OptionManager.prototype = { + + constructor: OptionManager, + + /** + * @public + * @param {Object} rawOption Raw option. + * @param {module:echarts/model/Global} ecModel + * @param {Array.} optionPreprocessorFuncs + * @return {Object} Init option + */ + setOption: function (rawOption, optionPreprocessorFuncs) { + rawOption = clone(rawOption, true); + + // FIXME + // 如果 timeline options 或者 media 中设置了某个属性,而baseOption中没有设置,则进行警告。 + + var oldOptionBackup = this._optionBackup; + var newOptionBackup = this._newOptionBackup = parseRawOption.call( + this, rawOption, optionPreprocessorFuncs + ); + + // For setOption at second time (using merge mode); + if (oldOptionBackup) { + // Only baseOption can be merged. + mergeOption(oldOptionBackup.baseOption, newOptionBackup.baseOption); + + if (newOptionBackup.timelineOptions.length) { + oldOptionBackup.timelineOptions = newOptionBackup.timelineOptions; + } + if (newOptionBackup.mediaList.length) { + oldOptionBackup.mediaList = newOptionBackup.mediaList; + } + if (newOptionBackup.mediaDefault) { + oldOptionBackup.mediaDefault = newOptionBackup.mediaDefault; + } + } + else { + this._optionBackup = newOptionBackup; + } + }, + + /** + * @param {boolean} isRecreate + * @return {Object} + */ + mountOption: function (isRecreate) { + var optionBackup = isRecreate + // this._optionBackup can be only used when recreate. + // In other cases we use model.mergeOption to handle merge. + ? this._optionBackup : this._newOptionBackup; + + // FIXME + // 如果没有reset功能则不clone。 + + this._timelineOptions = map(optionBackup.timelineOptions, clone); + this._mediaList = map(optionBackup.mediaList, clone); + this._mediaDefault = clone(optionBackup.mediaDefault); + this._currentMediaIndices = []; + + return clone(optionBackup.baseOption); + }, + + /** + * @param {module:echarts/model/Global} ecModel + * @return {Object} + */ + getTimelineOption: function (ecModel) { + var option; + var timelineOptions = this._timelineOptions; + + if (timelineOptions.length) { + // getTimelineOption can only be called after ecModel inited, + // so we can get currentIndex from timelineModel. + var timelineModel = ecModel.getComponent('timeline'); + if (timelineModel) { + option = clone( + timelineOptions[timelineModel.getCurrentIndex()], + true + ); + } + } + + return option; + }, + + /** + * @param {module:echarts/model/Global} ecModel + * @return {Array.} + */ + getMediaOption: function (ecModel) { + var ecWidth = this._api.getWidth(); + var ecHeight = this._api.getHeight(); + var mediaList = this._mediaList; + var mediaDefault = this._mediaDefault; + var indices = []; + var result = []; + + // No media defined. + if (!mediaList.length && !mediaDefault) { + return result; + } + + // Multi media may be applied, the latter defined media has higher priority. + for (var i = 0, len = mediaList.length; i < len; i++) { + if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) { + indices.push(i); + } + } + + // FIXME + // 是否mediaDefault应该强制用户设置,否则可能修改不能回归。 + if (!indices.length && mediaDefault) { + indices = [-1]; + } + + if (indices.length && !indicesEquals(indices, this._currentMediaIndices)) { + result = map(indices, function (index) { + return clone( + index === -1 ? mediaDefault.option : mediaList[index].option + ); + }); + } + // Otherwise return nothing. + + this._currentMediaIndices = indices; + + return result; + } + }; + + function parseRawOption(rawOption, optionPreprocessorFuncs) { + var timelineOptions = []; + var mediaList = []; + var mediaDefault; + var baseOption; + + // Compatible with ec2. + var timelineOpt = rawOption.timeline; + + if (rawOption.baseOption) { + baseOption = rawOption.baseOption; + } + + // For timeline + if (timelineOpt || rawOption.options) { + baseOption = baseOption || {}; + timelineOptions = (rawOption.options || []).slice(); + } + // For media query + if (rawOption.media) { + baseOption = baseOption || {}; + var media = rawOption.media; + each(media, function (singleMedia) { + if (singleMedia && singleMedia.option) { + if (singleMedia.query) { + mediaList.push(singleMedia); + } + else if (!mediaDefault) { + // Use the first media default. + mediaDefault = singleMedia; + } + } + }); + } + + // For normal option + if (!baseOption) { + baseOption = rawOption; + } + + // Set timelineOpt to baseOption in ec3, + // which is convenient for merge option. + if (!baseOption.timeline) { + baseOption.timeline = timelineOpt; + } + + // Preprocess. + each([baseOption].concat(timelineOptions) + .concat(zrUtil.map(mediaList, function (media) { + return media.option; + })), + function (option) { + each(optionPreprocessorFuncs, function (preProcess) { + preProcess(option); + }); + } + ); + + return { + baseOption: baseOption, + timelineOptions: timelineOptions, + mediaDefault: mediaDefault, + mediaList: mediaList + }; + } + + /** + * @see + * Support: width, height, aspectRatio + * Can use max or min as prefix. + */ + function applyMediaQuery(query, ecWidth, ecHeight) { + var realMap = { + width: ecWidth, + height: ecHeight, + aspectratio: ecWidth / ecHeight // lowser case for convenientce. + }; + + var applicatable = true; + + zrUtil.each(query, function (value, attr) { + var matched = attr.match(QUERY_REG); + + if (!matched || !matched[1] || !matched[2]) { + return; + } + + var operator = matched[1]; + var realAttr = matched[2].toLowerCase(); + + if (!compare(realMap[realAttr], value, operator)) { + applicatable = false; + } + }); + + return applicatable; + } + + function compare(real, expect, operator) { + if (operator === 'min') { + return real >= expect; + } + else if (operator === 'max') { + return real <= expect; + } + else { // Equals + return real === expect; + } + } + + function indicesEquals(indices1, indices2) { + // indices is always order by asc and has only finite number. + return indices1.join(',') === indices2.join(','); + } + + /** + * Consider case: + * `chart.setOption(opt1);` + * Then user do some interaction like dataZoom, dataView changing. + * `chart.setOption(opt2);` + * Then user press 'reset button' in toolbox. + * + * After doing that all of the interaction effects should be reset, the + * chart should be the same as the result of invoke + * `chart.setOption(opt1); chart.setOption(opt2);`. + * + * Although it is not able ensure that + * `chart.setOption(opt1); chart.setOption(opt2);` is equivalents to + * `chart.setOption(merge(opt1, opt2));` exactly, + * this might be the only simple way to implement that feature. + * + * MEMO: We've considered some other approaches: + * 1. Each model handle its self restoration but not uniform treatment. + * (Too complex in logic and error-prone) + * 2. Use a shadow ecModel. (Performace expensive) + */ + function mergeOption(oldOption, newOption) { + newOption = newOption || {}; + + each(newOption, function (newCptOpt, mainType) { + if (newCptOpt == null) { + return; + } + + var oldCptOpt = oldOption[mainType]; + + if (!ComponentModel.hasClass(mainType)) { + oldOption[mainType] = merge(oldCptOpt, newCptOpt, true); + } + else { + newCptOpt = modelUtil.normalizeToArray(newCptOpt); + oldCptOpt = modelUtil.normalizeToArray(oldCptOpt); + + var mapResult = modelUtil.mappingToExists(oldCptOpt, newCptOpt); + + oldOption[mainType] = map(mapResult, function (item) { + return (item.option && item.exist) + ? merge(item.exist, item.option, true) + : (item.exist || item.option); + }); + } + }); + } + + module.exports = OptionManager; + + +/***/ }, +/* 27 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var formatUtil = __webpack_require__(6); + var modelUtil = __webpack_require__(5); + var ComponentModel = __webpack_require__(19); + + var encodeHTML = formatUtil.encodeHTML; + var addCommas = formatUtil.addCommas; + + var SeriesModel = ComponentModel.extend({ + + type: 'series', + + /** + * @readOnly + */ + seriesIndex: 0, + + // coodinateSystem will be injected in the echarts/CoordinateSystem + coordinateSystem: null, + + /** + * @type {Object} + * @protected + */ + defaultOption: null, + + /** + * Data provided for legend + * @type {Function} + */ + // PENDING + legendDataProvider: null, + + init: function (option, parentModel, ecModel, extraOpt) { + + /** + * @type {number} + * @readOnly + */ + this.seriesIndex = this.componentIndex; + + this.mergeDefaultAndTheme(option, ecModel); + + /** + * @type {module:echarts/data/List|module:echarts/data/Tree|module:echarts/data/Graph} + * @private + */ + this._dataBeforeProcessed = this.getInitialData(option, ecModel); + + // When using module:echarts/data/Tree or module:echarts/data/Graph, + // cloneShallow will cause this._data.graph.data pointing to new data list. + // Wo we make this._dataBeforeProcessed first, and then make this._data. + this._data = this._dataBeforeProcessed.cloneShallow(); + }, + + /** + * Util for merge default and theme to option + * @param {Object} option + * @param {module:echarts/model/Global} ecModel + */ + mergeDefaultAndTheme: function (option, ecModel) { + zrUtil.merge( + option, + ecModel.getTheme().get(this.subType) + ); + zrUtil.merge(option, this.getDefaultOption()); + + // Default label emphasis `position` and `show` + modelUtil.defaultEmphasis( + option.label, ['position', 'show', 'textStyle', 'distance', 'formatter'] + ); + + // Default data label emphasis `position` and `show` + // FIXME Tree structure data ? + var data = option.data || []; + for (var i = 0; i < data.length; i++) { + if (data[i] && data[i].label) { + modelUtil.defaultEmphasis( + data[i].label, ['position', 'show', 'textStyle', 'distance', 'formatter'] + ); + } + } + }, + + mergeOption: function (newSeriesOption, ecModel) { + newSeriesOption = zrUtil.merge(this.option, newSeriesOption, true); + + var data = this.getInitialData(newSeriesOption, ecModel); + // TODO Merge data? + if (data) { + this._data = data; + this._dataBeforeProcessed = data.cloneShallow(); + } + }, + + /** + * Init a data structure from data related option in series + * Must be overwritten + */ + getInitialData: function () {}, + + /** + * @return {module:echarts/data/List} + */ + getData: function () { + return this._data; + }, + + /** + * @param {module:echarts/data/List} data + */ + setData: function (data) { + this._data = data; + }, + + /** + * Get data before processed + * @return {module:echarts/data/List} + */ + getRawData: function () { + return this._dataBeforeProcessed; + }, + + /** + * Get raw data array given by user + * @return {Array.} + */ + getRawDataArray: function () { + return this.option.data; + }, + + /** + * Coord dimension to data dimension. + * + * By default the result is the same as dimensions of series data. + * But some series dimensions are different from coord dimensions (i.e. + * candlestick and boxplot). Override this method to handle those cases. + * + * Coord dimension to data dimension can be one-to-many + * + * @param {string} coordDim + * @return {Array.} dimensions on the axis. + */ + coordDimToDataDim: function (coordDim) { + return [coordDim]; + }, + + /** + * Convert data dimension to coord dimension. + * + * @param {string|number} dataDim + * @return {string} + */ + dataDimToCoordDim: function (dataDim) { + return dataDim; + }, + + /** + * Get base axis if has coordinate system and has axis. + * By default use coordSys.getBaseAxis(); + * Can be overrided for some chart. + * @return {type} description + */ + getBaseAxis: function () { + var coordSys = this.coordinateSystem; + return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis(); + }, + + // FIXME + /** + * Default tooltip formatter + * + * @param {number} dataIndex + * @param {boolean} [multipleSeries=false] + */ + formatTooltip: function (dataIndex, multipleSeries) { + var data = this._data; + var value = this.getRawValue(dataIndex); + var formattedValue = zrUtil.isArray(value) + ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); + var name = data.getName(dataIndex); + + return !multipleSeries + ? (encodeHTML(this.name) + '
' + + (name + ? encodeHTML(name) + ' : ' + formattedValue + : formattedValue) + ) + : (encodeHTML(this.name) + ' : ' + formattedValue); + }, + + restoreData: function () { + this._data = this._dataBeforeProcessed.cloneShallow(); + } + }); + + zrUtil.mixin(SeriesModel, modelUtil.dataFormatMixin); + + module.exports = SeriesModel; + + +/***/ }, +/* 28 */ +/***/ function(module, exports, __webpack_require__) { + + + + var Group = __webpack_require__(29); + var componentUtil = __webpack_require__(20); + var clazzUtil = __webpack_require__(9); + + var Component = function () { + /** + * @type {module:zrender/container/Group} + * @readOnly + */ + this.group = new Group(); + + /** + * @type {string} + * @readOnly + */ + this.uid = componentUtil.getUID('viewComponent'); + }; + + Component.prototype = { + + constructor: Component, + + init: function (ecModel, api) {}, + + render: function (componentModel, ecModel, api, payload) {}, + + dispose: function () {} + }; + + var componentProto = Component.prototype; + componentProto.updateView + = componentProto.updateLayout + = componentProto.updateVisual + = function (seriesModel, ecModel, api, payload) { + // Do nothing; + }; + // Enable Component.extend. + clazzUtil.enableClassExtend(Component); + + // Enable capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. + clazzUtil.enableClassManagement(Component, {registerWhenExtend: true}); + + module.exports = Component; + + +/***/ }, +/* 29 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上 + * @module zrender/graphic/Group + * @example + * var Group = require('zrender/lib/container/Group'); + * var Circle = require('zrender/lib/graphic/shape/Circle'); + * var g = new Group(); + * g.position[0] = 100; + * g.position[1] = 100; + * g.add(new Circle({ + * style: { + * x: 100, + * y: 100, + * r: 20, + * } + * })); + * zr.add(g); + */ + + + var zrUtil = __webpack_require__(3); + var Element = __webpack_require__(30); + var BoundingRect = __webpack_require__(15); + + /** + * @alias module:zrender/graphic/Group + * @constructor + * @extends module:zrender/mixin/Transformable + * @extends module:zrender/mixin/Eventful + */ + var Group = function (opts) { + + opts = opts || {}; + + Element.call(this, opts); + + for (var key in opts) { + this[key] = opts[key]; + } + + this._children = []; + + this.__storage = null; + + this.__dirty = true; + }; + + Group.prototype = { + + constructor: Group, + + /** + * @type {string} + */ + type: 'group', + + /** + * @return {Array.} + */ + children: function () { + return this._children.slice(); + }, + + /** + * 获取指定 index 的儿子节点 + * @param {number} idx + * @return {module:zrender/Element} + */ + childAt: function (idx) { + return this._children[idx]; + }, + + /** + * 获取指定名字的儿子节点 + * @param {string} name + * @return {module:zrender/Element} + */ + childOfName: function (name) { + var children = this._children; + for (var i = 0; i < children.length; i++) { + if (children[i].name === name) { + return children[i]; + } + } + }, + + /** + * @return {number} + */ + childCount: function () { + return this._children.length; + }, + + /** + * 添加子节点到最后 + * @param {module:zrender/Element} child + */ + add: function (child) { + if (child && child !== this && child.parent !== this) { + + this._children.push(child); + + this._doAdd(child); + } + + return this; + }, + + /** + * 添加子节点在 nextSibling 之前 + * @param {module:zrender/Element} child + * @param {module:zrender/Element} nextSibling + */ + addBefore: function (child, nextSibling) { + if (child && child !== this && child.parent !== this + && nextSibling && nextSibling.parent === this) { + + var children = this._children; + var idx = children.indexOf(nextSibling); + + if (idx >= 0) { + children.splice(idx, 0, child); + this._doAdd(child); + } + } + + return this; + }, + + _doAdd: function (child) { + if (child.parent) { + child.parent.remove(child); + } + + child.parent = this; + + var storage = this.__storage; + var zr = this.__zr; + if (storage && storage !== child.__storage) { + + storage.addToMap(child); + + if (child instanceof Group) { + child.addChildrenToStorage(storage); + } + } + + zr && zr.refresh(); + }, + + /** + * 移除子节点 + * @param {module:zrender/Element} child + */ + remove: function (child) { + var zr = this.__zr; + var storage = this.__storage; + var children = this._children; + + var idx = zrUtil.indexOf(children, child); + if (idx < 0) { + return this; + } + children.splice(idx, 1); + + child.parent = null; + + if (storage) { + + storage.delFromMap(child.id); + + if (child instanceof Group) { + child.delChildrenFromStorage(storage); + } + } + + zr && zr.refresh(); + + return this; + }, + + /** + * 移除所有子节点 + */ + removeAll: function () { + var children = this._children; + var storage = this.__storage; + var child; + var i; + for (i = 0; i < children.length; i++) { + child = children[i]; + if (storage) { + storage.delFromMap(child.id); + if (child instanceof Group) { + child.delChildrenFromStorage(storage); + } + } + child.parent = null; + } + children.length = 0; + + return this; + }, + + /** + * 遍历所有子节点 + * @param {Function} cb + * @param {} context + */ + eachChild: function (cb, context) { + var children = this._children; + for (var i = 0; i < children.length; i++) { + var child = children[i]; + cb.call(context, child, i); + } + return this; + }, + + /** + * 深度优先遍历所有子孙节点 + * @param {Function} cb + * @param {} context + */ + traverse: function (cb, context) { + for (var i = 0; i < this._children.length; i++) { + var child = this._children[i]; + cb.call(context, child); + + if (child.type === 'group') { + child.traverse(cb, context); + } + } + return this; + }, + + addChildrenToStorage: function (storage) { + for (var i = 0; i < this._children.length; i++) { + var child = this._children[i]; + storage.addToMap(child); + if (child instanceof Group) { + child.addChildrenToStorage(storage); + } + } + }, + + delChildrenFromStorage: function (storage) { + for (var i = 0; i < this._children.length; i++) { + var child = this._children[i]; + storage.delFromMap(child.id); + if (child instanceof Group) { + child.delChildrenFromStorage(storage); + } + } + }, + + dirty: function () { + this.__dirty = true; + this.__zr && this.__zr.refresh(); + return this; + }, + + /** + * @return {module:zrender/core/BoundingRect} + */ + getBoundingRect: function (includeChildren) { + // TODO Caching + // TODO Transform + var rect = null; + var tmpRect = new BoundingRect(0, 0, 0, 0); + var children = includeChildren || this._children; + var tmpMat = []; + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (child.ignore || child.invisible) { + continue; + } + + var childRect = child.getBoundingRect(); + var transform = child.getLocalTransform(tmpMat); + if (transform) { + tmpRect.copy(childRect); + tmpRect.applyTransform(transform); + rect = rect || tmpRect.clone(); + rect.union(tmpRect); + } + else { + rect = rect || childRect.clone(); + rect.union(childRect); + } + } + return rect || tmpRect; + } + }; + + zrUtil.inherits(Group, Element); + + module.exports = Group; + + +/***/ }, +/* 30 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * @module zrender/Element + */ + + + var guid = __webpack_require__(31); + var Eventful = __webpack_require__(32); + var Transformable = __webpack_require__(33); + var Animatable = __webpack_require__(34); + var zrUtil = __webpack_require__(3); + + /** + * @alias module:zrender/Element + * @constructor + * @extends {module:zrender/mixin/Animatable} + * @extends {module:zrender/mixin/Transformable} + * @extends {module:zrender/mixin/Eventful} + */ + var Element = function (opts) { + + Transformable.call(this, opts); + Eventful.call(this, opts); + Animatable.call(this, opts); + + /** + * 画布元素ID + * @type {string} + */ + this.id = opts.id || guid(); + }; + + Element.prototype = { + + /** + * 元素类型 + * Element type + * @type {string} + */ + type: 'element', + + /** + * 元素名字 + * Element name + * @type {string} + */ + name: '', + + /** + * ZRender 实例对象,会在 element 添加到 zrender 实例中后自动赋值 + * ZRender instance will be assigned when element is associated with zrender + * @name module:/zrender/Element#__zr + * @type {module:zrender/ZRender} + */ + __zr: null, + + /** + * 图形是否忽略,为true时忽略图形的绘制以及事件触发 + * If ignore drawing and events of the element object + * @name module:/zrender/Element#ignore + * @type {boolean} + * @default false + */ + ignore: false, + + /** + * 用于裁剪的路径(shape),所有 Group 内的路径在绘制时都会被这个路径裁剪 + * 该路径会继承被裁减对象的变换 + * @type {module:zrender/graphic/Path} + * @see http://www.w3.org/TR/2dcontext/#clipping-region + * @readOnly + */ + clipPath: null, + + /** + * Drift element + * @param {number} dx dx on the global space + * @param {number} dy dy on the global space + */ + drift: function (dx, dy) { + switch (this.draggable) { + case 'horizontal': + dy = 0; + break; + case 'vertical': + dx = 0; + break; + } + + var m = this.transform; + if (!m) { + m = this.transform = [1, 0, 0, 1, 0, 0]; + } + m[4] += dx; + m[5] += dy; + + this.decomposeTransform(); + this.dirty(); + }, + + /** + * Hook before update + */ + beforeUpdate: function () {}, + /** + * Hook after update + */ + afterUpdate: function () {}, + /** + * Update each frame + */ + update: function () { + this.updateTransform(); + }, + + /** + * @param {Function} cb + * @param {} context + */ + traverse: function (cb, context) {}, + + /** + * @protected + */ + attrKV: function (key, value) { + if (key === 'position' || key === 'scale' || key === 'origin') { + // Copy the array + if (value) { + var target = this[key]; + if (!target) { + target = this[key] = []; + } + target[0] = value[0]; + target[1] = value[1]; + } + } + else { + this[key] = value; + } + }, + + /** + * Hide the element + */ + hide: function () { + this.ignore = true; + this.__zr && this.__zr.refresh(); + }, + + /** + * Show the element + */ + show: function () { + this.ignore = false; + this.__zr && this.__zr.refresh(); + }, + + /** + * @param {string|Object} key + * @param {*} value + */ + attr: function (key, value) { + if (typeof key === 'string') { + this.attrKV(key, value); + } + else if (zrUtil.isObject(key)) { + for (var name in key) { + if (key.hasOwnProperty(name)) { + this.attrKV(name, key[name]); + } + } + } + this.dirty(); + + return this; + }, + + /** + * @param {module:zrender/graphic/Path} clipPath + */ + setClipPath: function (clipPath) { + var zr = this.__zr; + if (zr) { + clipPath.addSelfToZr(zr); + } + + // Remove previous clip path + if (this.clipPath && this.clipPath !== clipPath) { + this.removeClipPath(); + } + + this.clipPath = clipPath; + clipPath.__zr = zr; + clipPath.__clipTarget = this; + + this.dirty(); + }, + + /** + */ + removeClipPath: function () { + var clipPath = this.clipPath; + if (clipPath) { + if (clipPath.__zr) { + clipPath.removeSelfFromZr(clipPath.__zr); + } + + clipPath.__zr = null; + clipPath.__clipTarget = null; + this.clipPath = null; + + this.dirty(); + } + }, + + /** + * Add self from zrender instance. + * Not recursively because it will be invoked when element added to storage. + * @param {module:zrender/ZRender} zr + */ + addSelfToZr: function (zr) { + this.__zr = zr; + // 添加动画 + var animators = this.animators; + if (animators) { + for (var i = 0; i < animators.length; i++) { + zr.animation.addAnimator(animators[i]); + } + } + + if (this.clipPath) { + this.clipPath.addSelfToZr(zr); + } + }, + + /** + * Remove self from zrender instance. + * Not recursively because it will be invoked when element added to storage. + * @param {module:zrender/ZRender} zr + */ + removeSelfFromZr: function (zr) { + this.__zr = null; + // 移除动画 + var animators = this.animators; + if (animators) { + for (var i = 0; i < animators.length; i++) { + zr.animation.removeAnimator(animators[i]); + } + } + + if (this.clipPath) { + this.clipPath.removeSelfFromZr(zr); + } + } + }; + + zrUtil.mixin(Element, Animatable); + zrUtil.mixin(Element, Transformable); + zrUtil.mixin(Element, Eventful); + + module.exports = Element; + + +/***/ }, +/* 31 */ +/***/ function(module, exports) { + + /** + * zrender: 生成唯一id + * + * @author errorrik (errorrik@gmail.com) + */ + + + var idStart = 0x0907; + + module.exports = function () { + return 'zr_' + (idStart++); + }; + + + +/***/ }, +/* 32 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 事件扩展 + * @module zrender/mixin/Eventful + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + * pissang (https://www.github.com/pissang) + */ + + + var arrySlice = Array.prototype.slice; + var zrUtil = __webpack_require__(3); + var indexOf = zrUtil.indexOf; + + /** + * 事件分发器 + * @alias module:zrender/mixin/Eventful + * @constructor + */ + var Eventful = function () { + this._$handlers = {}; + }; + + Eventful.prototype = { + + constructor: Eventful, + + /** + * 单次触发绑定,trigger后销毁 + * + * @param {string} event 事件名 + * @param {Function} handler 响应函数 + * @param {Object} context + */ + one: function (event, handler, context) { + var _h = this._$handlers; + + if (!handler || !event) { + return this; + } + + if (!_h[event]) { + _h[event] = []; + } + + if (indexOf(_h[event], event) >= 0) { + return this; + } + + _h[event].push({ + h: handler, + one: true, + ctx: context || this + }); + + return this; + }, + + /** + * 绑定事件 + * @param {string} event 事件名 + * @param {Function} handler 事件处理函数 + * @param {Object} [context] + */ + on: function (event, handler, context) { + var _h = this._$handlers; + + if (!handler || !event) { + return this; + } + + if (!_h[event]) { + _h[event] = []; + } + + _h[event].push({ + h: handler, + one: false, + ctx: context || this + }); + + return this; + }, + + /** + * 是否绑定了事件 + * @param {string} event + * @return {boolean} + */ + isSilent: function (event) { + var _h = this._$handlers; + return _h[event] && _h[event].length; + }, + + /** + * 解绑事件 + * @param {string} event 事件名 + * @param {Function} [handler] 事件处理函数 + */ + off: function (event, handler) { + var _h = this._$handlers; + + if (!event) { + this._$handlers = {}; + return this; + } + + if (handler) { + if (_h[event]) { + var newList = []; + for (var i = 0, l = _h[event].length; i < l; i++) { + if (_h[event][i]['h'] != handler) { + newList.push(_h[event][i]); + } + } + _h[event] = newList; + } + + if (_h[event] && _h[event].length === 0) { + delete _h[event]; + } + } + else { + delete _h[event]; + } + + return this; + }, + + /** + * 事件分发 + * + * @param {string} type 事件类型 + */ + trigger: function (type) { + if (this._$handlers[type]) { + var args = arguments; + var argLen = args.length; + + if (argLen > 3) { + args = arrySlice.call(args, 1); + } + + var _h = this._$handlers[type]; + var len = _h.length; + for (var i = 0; i < len;) { + // Optimize advise from backbone + switch (argLen) { + case 1: + _h[i]['h'].call(_h[i]['ctx']); + break; + case 2: + _h[i]['h'].call(_h[i]['ctx'], args[1]); + break; + case 3: + _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]); + break; + default: + // have more than 2 given arguments + _h[i]['h'].apply(_h[i]['ctx'], args); + break; + } + + if (_h[i]['one']) { + _h.splice(i, 1); + len--; + } + else { + i++; + } + } + } + + return this; + }, + + /** + * 带有context的事件分发, 最后一个参数是事件回调的context + * @param {string} type 事件类型 + */ + triggerWithContext: function (type) { + if (this._$handlers[type]) { + var args = arguments; + var argLen = args.length; + + if (argLen > 4) { + args = arrySlice.call(args, 1, args.length - 1); + } + var ctx = args[args.length - 1]; + + var _h = this._$handlers[type]; + var len = _h.length; + for (var i = 0; i < len;) { + // Optimize advise from backbone + switch (argLen) { + case 1: + _h[i]['h'].call(ctx); + break; + case 2: + _h[i]['h'].call(ctx, args[1]); + break; + case 3: + _h[i]['h'].call(ctx, args[1], args[2]); + break; + default: + // have more than 2 given arguments + _h[i]['h'].apply(ctx, args); + break; + } + + if (_h[i]['one']) { + _h.splice(i, 1); + len--; + } + else { + i++; + } + } + } + + return this; + } + }; + + // 对象可以通过 onxxxx 绑定事件 + /** + * @event module:zrender/mixin/Eventful#onclick + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmouseover + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmouseout + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmousemove + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmousewheel + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmousedown + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#onmouseup + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragstart + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragend + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragenter + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragleave + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondragover + * @type {Function} + * @default null + */ + /** + * @event module:zrender/mixin/Eventful#ondrop + * @type {Function} + * @default null + */ + + module.exports = Eventful; + + + +/***/ }, +/* 33 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 提供变换扩展 + * @module zrender/mixin/Transformable + * @author pissang (https://www.github.com/pissang) + */ + + + var matrix = __webpack_require__(17); + var vector = __webpack_require__(16); + var mIdentity = matrix.identity; + + var EPSILON = 5e-5; + + function isNotAroundZero(val) { + return val > EPSILON || val < -EPSILON; + } + + /** + * @alias module:zrender/mixin/Transformable + * @constructor + */ + var Transformable = function (opts) { + opts = opts || {}; + // If there are no given position, rotation, scale + if (!opts.position) { + /** + * 平移 + * @type {Array.} + * @default [0, 0] + */ + this.position = [0, 0]; + } + if (opts.rotation == null) { + /** + * 旋转 + * @type {Array.} + * @default 0 + */ + this.rotation = 0; + } + if (!opts.scale) { + /** + * 缩放 + * @type {Array.} + * @default [1, 1] + */ + this.scale = [1, 1]; + } + /** + * 旋转和缩放的原点 + * @type {Array.} + * @default null + */ + this.origin = this.origin || null; + }; + + var transformableProto = Transformable.prototype; + transformableProto.transform = null; + + /** + * 判断是否需要有坐标变换 + * 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵 + */ + transformableProto.needLocalTransform = function () { + return isNotAroundZero(this.rotation) + || isNotAroundZero(this.position[0]) + || isNotAroundZero(this.position[1]) + || isNotAroundZero(this.scale[0] - 1) + || isNotAroundZero(this.scale[1] - 1); + }; + + transformableProto.updateTransform = function () { + var parent = this.parent; + var parentHasTransform = parent && parent.transform; + var needLocalTransform = this.needLocalTransform(); + + var m = this.transform; + if (!(needLocalTransform || parentHasTransform)) { + m && mIdentity(m); + return; + } + + m = m || matrix.create(); + + if (needLocalTransform) { + this.getLocalTransform(m); + } + else { + mIdentity(m); + } + + // 应用父节点变换 + if (parentHasTransform) { + if (needLocalTransform) { + matrix.mul(m, parent.transform, m); + } + else { + matrix.copy(m, parent.transform); + } + } + // 保存这个变换矩阵 + this.transform = m; + + this.invTransform = this.invTransform || matrix.create(); + matrix.invert(this.invTransform, m); + }; + + transformableProto.getLocalTransform = function (m) { + m = m || []; + mIdentity(m); + + var origin = this.origin; + + var scale = this.scale; + var rotation = this.rotation; + var position = this.position; + if (origin) { + // Translate to origin + m[4] -= origin[0]; + m[5] -= origin[1]; + } + matrix.scale(m, m, scale); + if (rotation) { + matrix.rotate(m, m, rotation); + } + if (origin) { + // Translate back from origin + m[4] += origin[0]; + m[5] += origin[1]; + } + + m[4] += position[0]; + m[5] += position[1]; + + return m; + }; + /** + * 将自己的transform应用到context上 + * @param {Context2D} ctx + */ + transformableProto.setTransform = function (ctx) { + var m = this.transform; + if (m) { + ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); + } + }; + + var tmpTransform = []; + + /** + * 分解`transform`矩阵到`position`, `rotation`, `scale` + */ + transformableProto.decomposeTransform = function () { + if (!this.transform) { + return; + } + var parent = this.parent; + var m = this.transform; + if (parent && parent.transform) { + // Get local transform and decompose them to position, scale, rotation + matrix.mul(tmpTransform, parent.invTransform, m); + m = tmpTransform; + } + var sx = m[0] * m[0] + m[1] * m[1]; + var sy = m[2] * m[2] + m[3] * m[3]; + var position = this.position; + var scale = this.scale; + if (isNotAroundZero(sx - 1)) { + sx = Math.sqrt(sx); + } + if (isNotAroundZero(sy - 1)) { + sy = Math.sqrt(sy); + } + if (m[0] < 0) { + sx = -sx; + } + if (m[3] < 0) { + sy = -sy; + } + position[0] = m[4]; + position[1] = m[5]; + scale[0] = sx; + scale[1] = sy; + this.rotation = Math.atan2(-m[1] / sy, m[0] / sx); + }; + + /** + * 变换坐标位置到 shape 的局部坐标空间 + * @method + * @param {number} x + * @param {number} y + * @return {Array.} + */ + transformableProto.transformCoordToLocal = function (x, y) { + var v2 = [x, y]; + var invTransform = this.invTransform; + if (invTransform) { + vector.applyTransform(v2, v2, invTransform); + } + return v2; + }; + + /** + * 变换局部坐标位置到全局坐标空间 + * @method + * @param {number} x + * @param {number} y + * @return {Array.} + */ + transformableProto.transformCoordToGlobal = function (x, y) { + var v2 = [x, y]; + var transform = this.transform; + if (transform) { + vector.applyTransform(v2, v2, transform); + } + return v2; + }; + + module.exports = Transformable; + + + +/***/ }, +/* 34 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * @module zrender/mixin/Animatable + */ + + + var Animator = __webpack_require__(35); + var util = __webpack_require__(3); + var isString = util.isString; + var isFunction = util.isFunction; + var isObject = util.isObject; + var log = __webpack_require__(39); + + /** + * @alias modue:zrender/mixin/Animatable + * @constructor + */ + var Animatable = function () { + + /** + * @type {Array.} + * @readOnly + */ + this.animators = []; + }; + + Animatable.prototype = { + + constructor: Animatable, + + /** + * 动画 + * + * @param {string} path 需要添加动画的属性获取路径,可以通过a.b.c来获取深层的属性 + * @param {boolean} [loop] 动画是否循环 + * @return {module:zrender/animation/Animator} + * @example: + * el.animate('style', false) + * .when(1000, {x: 10} ) + * .done(function(){ // Animation done }) + * .start() + */ + animate: function (path, loop) { + var target; + var animatingShape = false; + var el = this; + var zr = this.__zr; + if (path) { + var pathSplitted = path.split('.'); + var prop = el; + // If animating shape + animatingShape = pathSplitted[0] === 'shape'; + for (var i = 0, l = pathSplitted.length; i < l; i++) { + if (!prop) { + continue; + } + prop = prop[pathSplitted[i]]; + } + if (prop) { + target = prop; + } + } + else { + target = el; + } + + if (!target) { + log( + 'Property "' + + path + + '" is not existed in element ' + + el.id + ); + return; + } + + var animators = el.animators; + + var animator = new Animator(target, loop); + + animator.during(function (target) { + el.dirty(animatingShape); + }) + .done(function () { + // FIXME Animator will not be removed if use `Animator#stop` to stop animation + animators.splice(util.indexOf(animators, animator), 1); + }); + + animators.push(animator); + + // If animate after added to the zrender + if (zr) { + zr.animation.addAnimator(animator); + } + + return animator; + }, + + /** + * 停止动画 + * @param {boolean} forwardToLast If move to last frame before stop + */ + stopAnimation: function (forwardToLast) { + var animators = this.animators; + var len = animators.length; + for (var i = 0; i < len; i++) { + animators[i].stop(forwardToLast); + } + animators.length = 0; + + return this; + }, + + /** + * @param {Object} target + * @param {number} [time=500] Time in ms + * @param {string} [easing='linear'] + * @param {number} [delay=0] + * @param {Function} [callback] + * + * @example + * // Animate position + * el.animateTo({ + * position: [10, 10] + * }, function () { // done }) + * + * // Animate shape, style and position in 100ms, delayed 100ms, with cubicOut easing + * el.animateTo({ + * shape: { + * width: 500 + * }, + * style: { + * fill: 'red' + * } + * position: [10, 10] + * }, 100, 100, 'cubicOut', function () { // done }) + */ + // TODO Return animation key + animateTo: function (target, time, delay, easing, callback) { + // animateTo(target, time, easing, callback); + if (isString(delay)) { + callback = easing; + easing = delay; + delay = 0; + } + // animateTo(target, time, delay, callback); + else if (isFunction(easing)) { + callback = easing; + easing = 'linear'; + delay = 0; + } + // animateTo(target, time, callback); + else if (isFunction(delay)) { + callback = delay; + delay = 0; + } + // animateTo(target, callback) + else if (isFunction(time)) { + callback = time; + time = 500; + } + // animateTo(target) + else if (!time) { + time = 500; + } + // Stop all previous animations + this.stopAnimation(); + this._animateToShallow('', this, target, time, delay, easing, callback); + + // Animators may be removed immediately after start + // if there is nothing to animate + var animators = this.animators.slice(); + var count = animators.length; + function done() { + count--; + if (!count) { + callback && callback(); + } + } + + // No animators. This should be checked before animators[i].start(), + // because 'done' may be executed immediately if no need to animate. + if (!count) { + callback && callback(); + } + // Start after all animators created + // Incase any animator is done immediately when all animation properties are not changed + for (var i = 0; i < animators.length; i++) { + animators[i] + .done(done) + .start(easing); + } + }, + + /** + * @private + * @param {string} path='' + * @param {Object} source=this + * @param {Object} target + * @param {number} [time=500] + * @param {number} [delay=0] + * + * @example + * // Animate position + * el._animateToShallow({ + * position: [10, 10] + * }) + * + * // Animate shape, style and position in 100ms, delayed 100ms + * el._animateToShallow({ + * shape: { + * width: 500 + * }, + * style: { + * fill: 'red' + * } + * position: [10, 10] + * }, 100, 100) + */ + _animateToShallow: function (path, source, target, time, delay) { + var objShallow = {}; + var propertyCount = 0; + for (var name in target) { + if (source[name] != null) { + if (isObject(target[name]) && !util.isArrayLike(target[name])) { + this._animateToShallow( + path ? path + '.' + name : name, + source[name], + target[name], + time, + delay + ); + } + else { + objShallow[name] = target[name]; + propertyCount++; + } + } + else if (target[name] != null) { + // Attr directly if not has property + // FIXME, if some property not needed for element ? + if (!path) { + this.attr(name, target[name]); + } + else { // Shape or style + var props = {}; + props[path] = {}; + props[path][name] = target[name]; + this.attr(props); + } + } + } + + if (propertyCount > 0) { + this.animate(path, false) + .when(time == null ? 500 : time, objShallow) + .delay(delay || 0); + } + + return this; + } + }; + + module.exports = Animatable; + + +/***/ }, +/* 35 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/animation/Animator + */ + + + var Clip = __webpack_require__(36); + var color = __webpack_require__(38); + var util = __webpack_require__(3); + var isArrayLike = util.isArrayLike; + + var arraySlice = Array.prototype.slice; + + function defaultGetter(target, key) { + return target[key]; + } + + function defaultSetter(target, key, value) { + target[key] = value; + } + + /** + * @param {number} p0 + * @param {number} p1 + * @param {number} percent + * @return {number} + */ + function interpolateNumber(p0, p1, percent) { + return (p1 - p0) * percent + p0; + } + + /** + * @param {string} p0 + * @param {string} p1 + * @param {number} percent + * @return {string} + */ + function interpolateString(p0, p1, percent) { + return percent > 0.5 ? p1 : p0; + } + + /** + * @param {Array} p0 + * @param {Array} p1 + * @param {number} percent + * @param {Array} out + * @param {number} arrDim + */ + function interpolateArray(p0, p1, percent, out, arrDim) { + var len = p0.length; + if (arrDim == 1) { + for (var i = 0; i < len; i++) { + out[i] = interpolateNumber(p0[i], p1[i], percent); + } + } + else { + var len2 = p0[0].length; + for (var i = 0; i < len; i++) { + for (var j = 0; j < len2; j++) { + out[i][j] = interpolateNumber( + p0[i][j], p1[i][j], percent + ); + } + } + } + } + + function fillArr(arr0, arr1, arrDim) { + var arr0Len = arr0.length; + var arr1Len = arr1.length; + if (arr0Len === arr1Len) { + return; + } + // FIXME Not work for TypedArray + var isPreviousLarger = arr0Len > arr1Len; + if (isPreviousLarger) { + // Cut the previous + arr0.length = arr1Len; + } + else { + // Fill the previous + for (var i = arr0Len; i < arr1Len; i++) { + arr0.push( + arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i]) + ); + } + } + } + + /** + * @param {Array} arr0 + * @param {Array} arr1 + * @param {number} arrDim + * @return {boolean} + */ + function isArraySame(arr0, arr1, arrDim) { + if (arr0 === arr1) { + return true; + } + var len = arr0.length; + if (len !== arr1.length) { + return false; + } + if (arrDim === 1) { + for (var i = 0; i < len; i++) { + if (arr0[i] !== arr1[i]) { + return false; + } + } + } + else { + var len2 = arr0[0].length; + for (var i = 0; i < len; i++) { + for (var j = 0; j < len2; j++) { + if (arr0[i][j] !== arr1[i][j]) { + return false; + } + } + } + } + return true; + } + + /** + * Catmull Rom interpolate array + * @param {Array} p0 + * @param {Array} p1 + * @param {Array} p2 + * @param {Array} p3 + * @param {number} t + * @param {number} t2 + * @param {number} t3 + * @param {Array} out + * @param {number} arrDim + */ + function catmullRomInterpolateArray( + p0, p1, p2, p3, t, t2, t3, out, arrDim + ) { + var len = p0.length; + if (arrDim == 1) { + for (var i = 0; i < len; i++) { + out[i] = catmullRomInterpolate( + p0[i], p1[i], p2[i], p3[i], t, t2, t3 + ); + } + } + else { + var len2 = p0[0].length; + for (var i = 0; i < len; i++) { + for (var j = 0; j < len2; j++) { + out[i][j] = catmullRomInterpolate( + p0[i][j], p1[i][j], p2[i][j], p3[i][j], + t, t2, t3 + ); + } + } + } + } + + /** + * Catmull Rom interpolate number + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @param {number} t2 + * @param {number} t3 + * @return {number} + */ + function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) { + var v0 = (p2 - p0) * 0.5; + var v1 = (p3 - p1) * 0.5; + return (2 * (p1 - p2) + v0 + v1) * t3 + + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + + v0 * t + p1; + } + + function cloneValue(value) { + if (isArrayLike(value)) { + var len = value.length; + if (isArrayLike(value[0])) { + var ret = []; + for (var i = 0; i < len; i++) { + ret.push(arraySlice.call(value[i])); + } + return ret; + } + + return arraySlice.call(value); + } + + return value; + } + + function rgba2String(rgba) { + rgba[0] = Math.floor(rgba[0]); + rgba[1] = Math.floor(rgba[1]); + rgba[2] = Math.floor(rgba[2]); + + return 'rgba(' + rgba.join(',') + ')'; + } + + function createTrackClip (animator, easing, oneTrackDone, keyframes, propName) { + var getter = animator._getter; + var setter = animator._setter; + var useSpline = easing === 'spline'; + + var trackLen = keyframes.length; + if (!trackLen) { + return; + } + // Guess data type + var firstVal = keyframes[0].value; + var isValueArray = isArrayLike(firstVal); + var isValueColor = false; + var isValueString = false; + + // For vertices morphing + var arrDim = ( + isValueArray + && isArrayLike(firstVal[0]) + ) + ? 2 : 1; + var trackMaxTime; + // Sort keyframe as ascending + keyframes.sort(function(a, b) { + return a.time - b.time; + }); + + trackMaxTime = keyframes[trackLen - 1].time; + // Percents of each keyframe + var kfPercents = []; + // Value of each keyframe + var kfValues = []; + var prevValue = keyframes[0].value; + var isAllValueEqual = true; + for (var i = 0; i < trackLen; i++) { + kfPercents.push(keyframes[i].time / trackMaxTime); + // Assume value is a color when it is a string + var value = keyframes[i].value; + + // Check if value is equal, deep check if value is array + if (!((isValueArray && isArraySame(value, prevValue, arrDim)) + || (!isValueArray && value === prevValue))) { + isAllValueEqual = false; + } + prevValue = value; + + // Try converting a string to a color array + if (typeof value == 'string') { + var colorArray = color.parse(value); + if (colorArray) { + value = colorArray; + isValueColor = true; + } + else { + isValueString = true; + } + } + kfValues.push(value); + } + if (isAllValueEqual) { + return; + } + + if (isValueArray) { + var lastValue = kfValues[trackLen - 1]; + // Polyfill array + for (var i = 0; i < trackLen - 1; i++) { + fillArr(kfValues[i], lastValue, arrDim); + } + fillArr(getter(animator._target, propName), lastValue, arrDim); + } + + // Cache the key of last frame to speed up when + // animation playback is sequency + var lastFrame = 0; + var lastFramePercent = 0; + var start; + var w; + var p0; + var p1; + var p2; + var p3; + + if (isValueColor) { + var rgba = [0, 0, 0, 0]; + } + + var onframe = function (target, percent) { + // Find the range keyframes + // kf1-----kf2---------current--------kf3 + // find kf2 and kf3 and do interpolation + var frame; + if (percent < lastFramePercent) { + // Start from next key + start = Math.min(lastFrame + 1, trackLen - 1); + for (frame = start; frame >= 0; frame--) { + if (kfPercents[frame] <= percent) { + break; + } + } + frame = Math.min(frame, trackLen - 2); + } + else { + for (frame = lastFrame; frame < trackLen; frame++) { + if (kfPercents[frame] > percent) { + break; + } + } + frame = Math.min(frame - 1, trackLen - 2); + } + lastFrame = frame; + lastFramePercent = percent; + + var range = (kfPercents[frame + 1] - kfPercents[frame]); + if (range === 0) { + return; + } + else { + w = (percent - kfPercents[frame]) / range; + } + if (useSpline) { + p1 = kfValues[frame]; + p0 = kfValues[frame === 0 ? frame : frame - 1]; + p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1]; + p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2]; + if (isValueArray) { + catmullRomInterpolateArray( + p0, p1, p2, p3, w, w * w, w * w * w, + getter(target, propName), + arrDim + ); + } + else { + var value; + if (isValueColor) { + value = catmullRomInterpolateArray( + p0, p1, p2, p3, w, w * w, w * w * w, + rgba, 1 + ); + value = rgba2String(rgba); + } + else if (isValueString) { + // String is step(0.5) + return interpolateString(p1, p2, w); + } + else { + value = catmullRomInterpolate( + p0, p1, p2, p3, w, w * w, w * w * w + ); + } + setter( + target, + propName, + value + ); + } + } + else { + if (isValueArray) { + interpolateArray( + kfValues[frame], kfValues[frame + 1], w, + getter(target, propName), + arrDim + ); + } + else { + var value; + if (isValueColor) { + interpolateArray( + kfValues[frame], kfValues[frame + 1], w, + rgba, 1 + ); + value = rgba2String(rgba); + } + else if (isValueString) { + // String is step(0.5) + return interpolateString(kfValues[frame], kfValues[frame + 1], w); + } + else { + value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w); + } + setter( + target, + propName, + value + ); + } + } + }; + + var clip = new Clip({ + target: animator._target, + life: trackMaxTime, + loop: animator._loop, + delay: animator._delay, + onframe: onframe, + ondestroy: oneTrackDone + }); + + if (easing && easing !== 'spline') { + clip.easing = easing; + } + + return clip; + } + + /** + * @alias module:zrender/animation/Animator + * @constructor + * @param {Object} target + * @param {boolean} loop + * @param {Function} getter + * @param {Function} setter + */ + var Animator = function(target, loop, getter, setter) { + this._tracks = {}; + this._target = target; + + this._loop = loop || false; + + this._getter = getter || defaultGetter; + this._setter = setter || defaultSetter; + + this._clipCount = 0; + + this._delay = 0; + + this._doneList = []; + + this._onframeList = []; + + this._clipList = []; + }; + + Animator.prototype = { + /** + * 设置动画关键帧 + * @param {number} time 关键帧时间,单位是ms + * @param {Object} props 关键帧的属性值,key-value表示 + * @return {module:zrender/animation/Animator} + */ + when: function(time /* ms */, props) { + var tracks = this._tracks; + for (var propName in props) { + if (!tracks[propName]) { + tracks[propName] = []; + // Invalid value + var value = this._getter(this._target, propName); + if (value == null) { + // zrLog('Invalid property ' + propName); + continue; + } + // If time is 0 + // Then props is given initialize value + // Else + // Initialize value from current prop value + if (time !== 0) { + tracks[propName].push({ + time: 0, + value: cloneValue(value) + }); + } + } + tracks[propName].push({ + time: time, + value: props[propName] + }); + } + return this; + }, + /** + * 添加动画每一帧的回调函数 + * @param {Function} callback + * @return {module:zrender/animation/Animator} + */ + during: function (callback) { + this._onframeList.push(callback); + return this; + }, + + _doneCallback: function () { + // Clear all tracks + this._tracks = {}; + // Clear all clips + this._clipList.length = 0; + + var doneList = this._doneList; + var len = doneList.length; + for (var i = 0; i < len; i++) { + doneList[i].call(this); + } + }, + /** + * 开始执行动画 + * @param {string|Function} easing + * 动画缓动函数,详见{@link module:zrender/animation/easing} + * @return {module:zrender/animation/Animator} + */ + start: function (easing) { + + var self = this; + var clipCount = 0; + + var oneTrackDone = function() { + clipCount--; + if (!clipCount) { + self._doneCallback(); + } + }; + + var lastClip; + for (var propName in this._tracks) { + var clip = createTrackClip( + this, easing, oneTrackDone, + this._tracks[propName], propName + ); + if (clip) { + this._clipList.push(clip); + clipCount++; + + // If start after added to animation + if (this.animation) { + this.animation.addClip(clip); + } + + lastClip = clip; + } + } + + // Add during callback on the last clip + if (lastClip) { + var oldOnFrame = lastClip.onframe; + lastClip.onframe = function (target, percent) { + oldOnFrame(target, percent); + + for (var i = 0; i < self._onframeList.length; i++) { + self._onframeList[i](target, percent); + } + }; + } + + if (!clipCount) { + this._doneCallback(); + } + return this; + }, + /** + * 停止动画 + * @param {boolean} forwardToLast If move to last frame before stop + */ + stop: function (forwardToLast) { + var clipList = this._clipList; + var animation = this.animation; + for (var i = 0; i < clipList.length; i++) { + var clip = clipList[i]; + if (forwardToLast) { + // Move to last frame before stop + clip.onframe(this._target, 1); + } + animation && animation.removeClip(clip); + } + clipList.length = 0; + }, + /** + * 设置动画延迟开始的时间 + * @param {number} time 单位ms + * @return {module:zrender/animation/Animator} + */ + delay: function (time) { + this._delay = time; + return this; + }, + /** + * 添加动画结束的回调 + * @param {Function} cb + * @return {module:zrender/animation/Animator} + */ + done: function(cb) { + if (cb) { + this._doneList.push(cb); + } + return this; + }, + + /** + * @return {Array.} + */ + getClips: function () { + return this._clipList; + } + }; + + module.exports = Animator; + + +/***/ }, +/* 36 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 动画主控制器 + * @config target 动画对象,可以是数组,如果是数组的话会批量分发onframe等事件 + * @config life(1000) 动画时长 + * @config delay(0) 动画延迟时间 + * @config loop(true) + * @config gap(0) 循环的间隔时间 + * @config onframe + * @config easing(optional) + * @config ondestroy(optional) + * @config onrestart(optional) + * + * TODO pause + */ + + + var easingFuncs = __webpack_require__(37); + + function Clip(options) { + + this._target = options.target; + + // 生命周期 + this._life = options.life || 1000; + // 延时 + this._delay = options.delay || 0; + // 开始时间 + // this._startTime = new Date().getTime() + this._delay;// 单位毫秒 + this._initialized = false; + + // 是否循环 + this.loop = options.loop == null ? false : options.loop; + + this.gap = options.gap || 0; + + this.easing = options.easing || 'Linear'; + + this.onframe = options.onframe; + this.ondestroy = options.ondestroy; + this.onrestart = options.onrestart; + } + + Clip.prototype = { + + constructor: Clip, + + step: function (time) { + // Set startTime on first step, or _startTime may has milleseconds different between clips + // PENDING + if (!this._initialized) { + this._startTime = new Date().getTime() + this._delay; + this._initialized = true; + } + + var percent = (time - this._startTime) / this._life; + + // 还没开始 + if (percent < 0) { + return; + } + + percent = Math.min(percent, 1); + + var easing = this.easing; + var easingFunc = typeof easing == 'string' ? easingFuncs[easing] : easing; + var schedule = typeof easingFunc === 'function' + ? easingFunc(percent) + : percent; + + this.fire('frame', schedule); + + // 结束 + if (percent == 1) { + if (this.loop) { + this.restart(); + // 重新开始周期 + // 抛出而不是直接调用事件直到 stage.update 后再统一调用这些事件 + return 'restart'; + } + + // 动画完成将这个控制器标识为待删除 + // 在Animation.update中进行批量删除 + this._needsRemove = true; + return 'destroy'; + } + + return null; + }, + + restart: function() { + var time = new Date().getTime(); + var remainder = (time - this._startTime) % this._life; + this._startTime = new Date().getTime() - remainder + this.gap; + + this._needsRemove = false; + }, + + fire: function(eventType, arg) { + eventType = 'on' + eventType; + if (this[eventType]) { + this[eventType](this._target, arg); + } + } + }; + + module.exports = Clip; + + + +/***/ }, +/* 37 */ +/***/ function(module, exports) { + + /** + * 缓动代码来自 https://github.com/sole/tween.js/blob/master/src/Tween.js + * @see http://sole.github.io/tween.js/examples/03_graphs.html + * @exports zrender/animation/easing + */ + + var easing = { + /** + * @param {number} k + * @return {number} + */ + linear: function (k) { + return k; + }, + + /** + * @param {number} k + * @return {number} + */ + quadraticIn: function (k) { + return k * k; + }, + /** + * @param {number} k + * @return {number} + */ + quadraticOut: function (k) { + return k * (2 - k); + }, + /** + * @param {number} k + * @return {number} + */ + quadraticInOut: function (k) { + if ((k *= 2) < 1) { + return 0.5 * k * k; + } + return -0.5 * (--k * (k - 2) - 1); + }, + + // 三次方的缓动(t^3) + /** + * @param {number} k + * @return {number} + */ + cubicIn: function (k) { + return k * k * k; + }, + /** + * @param {number} k + * @return {number} + */ + cubicOut: function (k) { + return --k * k * k + 1; + }, + /** + * @param {number} k + * @return {number} + */ + cubicInOut: function (k) { + if ((k *= 2) < 1) { + return 0.5 * k * k * k; + } + return 0.5 * ((k -= 2) * k * k + 2); + }, + + // 四次方的缓动(t^4) + /** + * @param {number} k + * @return {number} + */ + quarticIn: function (k) { + return k * k * k * k; + }, + /** + * @param {number} k + * @return {number} + */ + quarticOut: function (k) { + return 1 - (--k * k * k * k); + }, + /** + * @param {number} k + * @return {number} + */ + quarticInOut: function (k) { + if ((k *= 2) < 1) { + return 0.5 * k * k * k * k; + } + return -0.5 * ((k -= 2) * k * k * k - 2); + }, + + // 五次方的缓动(t^5) + /** + * @param {number} k + * @return {number} + */ + quinticIn: function (k) { + return k * k * k * k * k; + }, + /** + * @param {number} k + * @return {number} + */ + quinticOut: function (k) { + return --k * k * k * k * k + 1; + }, + /** + * @param {number} k + * @return {number} + */ + quinticInOut: function (k) { + if ((k *= 2) < 1) { + return 0.5 * k * k * k * k * k; + } + return 0.5 * ((k -= 2) * k * k * k * k + 2); + }, + + // 正弦曲线的缓动(sin(t)) + /** + * @param {number} k + * @return {number} + */ + sinusoidalIn: function (k) { + return 1 - Math.cos(k * Math.PI / 2); + }, + /** + * @param {number} k + * @return {number} + */ + sinusoidalOut: function (k) { + return Math.sin(k * Math.PI / 2); + }, + /** + * @param {number} k + * @return {number} + */ + sinusoidalInOut: function (k) { + return 0.5 * (1 - Math.cos(Math.PI * k)); + }, + + // 指数曲线的缓动(2^t) + /** + * @param {number} k + * @return {number} + */ + exponentialIn: function (k) { + return k === 0 ? 0 : Math.pow(1024, k - 1); + }, + /** + * @param {number} k + * @return {number} + */ + exponentialOut: function (k) { + return k === 1 ? 1 : 1 - Math.pow(2, -10 * k); + }, + /** + * @param {number} k + * @return {number} + */ + exponentialInOut: function (k) { + if (k === 0) { + return 0; + } + if (k === 1) { + return 1; + } + if ((k *= 2) < 1) { + return 0.5 * Math.pow(1024, k - 1); + } + return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2); + }, + + // 圆形曲线的缓动(sqrt(1-t^2)) + /** + * @param {number} k + * @return {number} + */ + circularIn: function (k) { + return 1 - Math.sqrt(1 - k * k); + }, + /** + * @param {number} k + * @return {number} + */ + circularOut: function (k) { + return Math.sqrt(1 - (--k * k)); + }, + /** + * @param {number} k + * @return {number} + */ + circularInOut: function (k) { + if ((k *= 2) < 1) { + return -0.5 * (Math.sqrt(1 - k * k) - 1); + } + return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); + }, + + // 创建类似于弹簧在停止前来回振荡的动画 + /** + * @param {number} k + * @return {number} + */ + elasticIn: function (k) { + var s; + var a = 0.1; + var p = 0.4; + if (k === 0) { + return 0; + } + if (k === 1) { + return 1; + } + if (!a || a < 1) { + a = 1; s = p / 4; + } + else { + s = p * Math.asin(1 / a) / (2 * Math.PI); + } + return -(a * Math.pow(2, 10 * (k -= 1)) * + Math.sin((k - s) * (2 * Math.PI) / p)); + }, + /** + * @param {number} k + * @return {number} + */ + elasticOut: function (k) { + var s; + var a = 0.1; + var p = 0.4; + if (k === 0) { + return 0; + } + if (k === 1) { + return 1; + } + if (!a || a < 1) { + a = 1; s = p / 4; + } + else { + s = p * Math.asin(1 / a) / (2 * Math.PI); + } + return (a * Math.pow(2, -10 * k) * + Math.sin((k - s) * (2 * Math.PI) / p) + 1); + }, + /** + * @param {number} k + * @return {number} + */ + elasticInOut: function (k) { + var s; + var a = 0.1; + var p = 0.4; + if (k === 0) { + return 0; + } + if (k === 1) { + return 1; + } + if (!a || a < 1) { + a = 1; s = p / 4; + } + else { + s = p * Math.asin(1 / a) / (2 * Math.PI); + } + if ((k *= 2) < 1) { + return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) + * Math.sin((k - s) * (2 * Math.PI) / p)); + } + return a * Math.pow(2, -10 * (k -= 1)) + * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1; + + }, + + // 在某一动画开始沿指示的路径进行动画处理前稍稍收回该动画的移动 + /** + * @param {number} k + * @return {number} + */ + backIn: function (k) { + var s = 1.70158; + return k * k * ((s + 1) * k - s); + }, + /** + * @param {number} k + * @return {number} + */ + backOut: function (k) { + var s = 1.70158; + return --k * k * ((s + 1) * k + s) + 1; + }, + /** + * @param {number} k + * @return {number} + */ + backInOut: function (k) { + var s = 1.70158 * 1.525; + if ((k *= 2) < 1) { + return 0.5 * (k * k * ((s + 1) * k - s)); + } + return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); + }, + + // 创建弹跳效果 + /** + * @param {number} k + * @return {number} + */ + bounceIn: function (k) { + return 1 - easing.bounceOut(1 - k); + }, + /** + * @param {number} k + * @return {number} + */ + bounceOut: function (k) { + if (k < (1 / 2.75)) { + return 7.5625 * k * k; + } + else if (k < (2 / 2.75)) { + return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75; + } + else if (k < (2.5 / 2.75)) { + return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375; + } + else { + return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; + } + }, + /** + * @param {number} k + * @return {number} + */ + bounceInOut: function (k) { + if (k < 0.5) { + return easing.bounceIn(k * 2) * 0.5; + } + return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5; + } + }; + + module.exports = easing; + + + + +/***/ }, +/* 38 */ +/***/ function(module, exports) { + + /** + * @module zrender/tool/color + */ + + + var kCSSColorTable = { + 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1], + 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1], + 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1], + 'beige': [245,245,220,1], 'bisque': [255,228,196,1], + 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1], + 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1], + 'brown': [165,42,42,1], 'burlywood': [222,184,135,1], + 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1], + 'chocolate': [210,105,30,1], 'coral': [255,127,80,1], + 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1], + 'crimson': [220,20,60,1], 'cyan': [0,255,255,1], + 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1], + 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1], + 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1], + 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1], + 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1], + 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1], + 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1], + 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1], + 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1], + 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1], + 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1], + 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1], + 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1], + 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1], + 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1], + 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1], + 'gray': [128,128,128,1], 'green': [0,128,0,1], + 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1], + 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1], + 'indianred': [205,92,92,1], 'indigo': [75,0,130,1], + 'ivory': [255,255,240,1], 'khaki': [240,230,140,1], + 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1], + 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1], + 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1], + 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1], + 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1], + 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1], + 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1], + 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1], + 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1], + 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1], + 'limegreen': [50,205,50,1], 'linen': [250,240,230,1], + 'magenta': [255,0,255,1], 'maroon': [128,0,0,1], + 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1], + 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1], + 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1], + 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1], + 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1], + 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1], + 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1], + 'navy': [0,0,128,1], 'oldlace': [253,245,230,1], + 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1], + 'orange': [255,165,0,1], 'orangered': [255,69,0,1], + 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1], + 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1], + 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1], + 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1], + 'pink': [255,192,203,1], 'plum': [221,160,221,1], + 'powderblue': [176,224,230,1], 'purple': [128,0,128,1], + 'red': [255,0,0,1], 'rosybrown': [188,143,143,1], + 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1], + 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1], + 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1], + 'sienna': [160,82,45,1], 'silver': [192,192,192,1], + 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1], + 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1], + 'snow': [255,250,250,1], 'springgreen': [0,255,127,1], + 'steelblue': [70,130,180,1], 'tan': [210,180,140,1], + 'teal': [0,128,128,1], 'thistle': [216,191,216,1], + 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1], + 'violet': [238,130,238,1], 'wheat': [245,222,179,1], + 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1], + 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1] + }; + + function clampCssByte(i) { // Clamp to integer 0 .. 255. + i = Math.round(i); // Seems to be what Chrome does (vs truncation). + return i < 0 ? 0 : i > 255 ? 255 : i; + } + + function clampCssAngle(i) { // Clamp to integer 0 .. 360. + i = Math.round(i); // Seems to be what Chrome does (vs truncation). + return i < 0 ? 0 : i > 360 ? 360 : i; + } + + function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0. + return f < 0 ? 0 : f > 1 ? 1 : f; + } + + function parseCssInt(str) { // int or percentage. + if (str.length && str.charAt(str.length - 1) === '%') { + return clampCssByte(parseFloat(str) / 100 * 255); + } + return clampCssByte(parseInt(str, 10)); + } + + function parseCssFloat(str) { // float or percentage. + if (str.length && str.charAt(str.length - 1) === '%') { + return clampCssFloat(parseFloat(str) / 100); + } + return clampCssFloat(parseFloat(str)); + } + + function cssHueToRgb(m1, m2, h) { + if (h < 0) { + h += 1; + } + else if (h > 1) { + h -= 1; + } + + if (h * 6 < 1) { + return m1 + (m2 - m1) * h * 6; + } + if (h * 2 < 1) { + return m2; + } + if (h * 3 < 2) { + return m1 + (m2 - m1) * (2/3 - h) * 6; + } + return m1; + } + + function lerp(a, b, p) { + return a + (b - a) * p; + } + + /** + * @param {string} colorStr + * @return {Array.} + * @memberOf module:zrender/util/color + */ + function parse(colorStr) { + if (!colorStr) { + return; + } + // colorStr may be not string + colorStr = colorStr + ''; + // Remove all whitespace, not compliant, but should just be more accepting. + var str = colorStr.replace(/ /g, '').toLowerCase(); + + // Color keywords (and transparent) lookup. + if (str in kCSSColorTable) { + return kCSSColorTable[str].slice(); // dup. + } + + // #abc and #abc123 syntax. + if (str.charAt(0) === '#') { + if (str.length === 4) { + var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. + if (!(iv >= 0 && iv <= 0xfff)) { + return; // Covers NaN. + } + return [ + ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8), + (iv & 0xf0) | ((iv & 0xf0) >> 4), + (iv & 0xf) | ((iv & 0xf) << 4), + 1 + ]; + } + else if (str.length === 7) { + var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. + if (!(iv >= 0 && iv <= 0xffffff)) { + return; // Covers NaN. + } + return [ + (iv & 0xff0000) >> 16, + (iv & 0xff00) >> 8, + iv & 0xff, + 1 + ]; + } + + return; + } + var op = str.indexOf('('), ep = str.indexOf(')'); + if (op !== -1 && ep + 1 === str.length) { + var fname = str.substr(0, op); + var params = str.substr(op + 1, ep - (op + 1)).split(','); + var alpha = 1; // To allow case fallthrough. + switch (fname) { + case 'rgba': + if (params.length !== 4) { + return; + } + alpha = parseCssFloat(params.pop()); // jshint ignore:line + // Fall through. + case 'rgb': + if (params.length !== 3) { + return; + } + return [ + parseCssInt(params[0]), + parseCssInt(params[1]), + parseCssInt(params[2]), + alpha + ]; + case 'hsla': + if (params.length !== 4) { + return; + } + params[3] = parseCssFloat(params[3]); + return hsla2rgba(params); + case 'hsl': + if (params.length !== 3) { + return; + } + return hsla2rgba(params); + default: + return; + } + } + + return; + } + + /** + * @param {Array.} hsla + * @return {Array.} rgba + */ + function hsla2rgba(hsla) { + var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1 + // NOTE(deanm): According to the CSS spec s/l should only be + // percentages, but we don't bother and let float or percentage. + var s = parseCssFloat(hsla[1]); + var l = parseCssFloat(hsla[2]); + var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; + var m1 = l * 2 - m2; + + var rgba = [ + clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255), + clampCssByte(cssHueToRgb(m1, m2, h) * 255), + clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255) + ]; + + if (hsla.length === 4) { + rgba[3] = hsla[3]; + } + + return rgba; + } + + /** + * @param {Array.} rgba + * @return {Array.} hsla + */ + function rgba2hsla(rgba) { + if (!rgba) { + return; + } + + // RGB from 0 to 255 + var R = rgba[0] / 255; + var G = rgba[1] / 255; + var B = rgba[2] / 255; + + var vMin = Math.min(R, G, B); // Min. value of RGB + var vMax = Math.max(R, G, B); // Max. value of RGB + var delta = vMax - vMin; // Delta RGB value + + var L = (vMax + vMin) / 2; + var H; + var S; + // HSL results from 0 to 1 + if (delta === 0) { + H = 0; + S = 0; + } + else { + if (L < 0.5) { + S = delta / (vMax + vMin); + } + else { + S = delta / (2 - vMax - vMin); + } + + var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta; + var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta; + var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta; + + if (R === vMax) { + H = deltaB - deltaG; + } + else if (G === vMax) { + H = (1 / 3) + deltaR - deltaB; + } + else if (B === vMax) { + H = (2 / 3) + deltaG - deltaR; + } + + if (H < 0) { + H += 1; + } + + if (H > 1) { + H -= 1; + } + } + + var hsla = [H * 360, S, L]; + + if (rgba[3] != null) { + hsla.push(rgba[3]); + } + + return hsla; + } + + /** + * @param {string} color + * @param {number} level + * @return {string} + * @memberOf module:zrender/util/color + */ + function lift(color, level) { + var colorArr = parse(color); + if (colorArr) { + for (var i = 0; i < 3; i++) { + if (level < 0) { + colorArr[i] = colorArr[i] * (1 - level) | 0; + } + else { + colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0; + } + } + return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb'); + } + } + + /** + * @param {string} color + * @return {string} + * @memberOf module:zrender/util/color + */ + function toHex(color, level) { + var colorArr = parse(color); + if (colorArr) { + return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1); + } + } + + /** + * Map value to color. Faster than mapToColor methods because color is represented by rgba array + * @param {number} normalizedValue A float between 0 and 1. + * @param {Array.>} colors List of rgba color array + * @param {Array.} [out] Mapped gba color array + * @return {Array.} + */ + function fastMapToColor(normalizedValue, colors, out) { + if (!(colors && colors.length) + || !(normalizedValue >= 0 && normalizedValue <= 1) + ) { + return; + } + out = out || [0, 0, 0, 0]; + var value = normalizedValue * (colors.length - 1); + var leftIndex = Math.floor(value); + var rightIndex = Math.ceil(value); + var leftColor = colors[leftIndex]; + var rightColor = colors[rightIndex]; + var dv = value - leftIndex; + out[0] = clampCssByte(lerp(leftColor[0], rightColor[0], dv)); + out[1] = clampCssByte(lerp(leftColor[1], rightColor[1], dv)); + out[2] = clampCssByte(lerp(leftColor[2], rightColor[2], dv)); + out[3] = clampCssByte(lerp(leftColor[3], rightColor[3], dv)); + return out; + } + /** + * @param {number} normalizedValue A float between 0 and 1. + * @param {Array.} colors Color list. + * @param {boolean=} fullOutput Default false. + * @return {(string|Object)} Result color. If fullOutput, + * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...}, + * @memberOf module:zrender/util/color + */ + function mapToColor(normalizedValue, colors, fullOutput) { + if (!(colors && colors.length) + || !(normalizedValue >= 0 && normalizedValue <= 1) + ) { + return; + } + + var value = normalizedValue * (colors.length - 1); + var leftIndex = Math.floor(value); + var rightIndex = Math.ceil(value); + var leftColor = parse(colors[leftIndex]); + var rightColor = parse(colors[rightIndex]); + var dv = value - leftIndex; + + var color = stringify( + [ + clampCssByte(lerp(leftColor[0], rightColor[0], dv)), + clampCssByte(lerp(leftColor[1], rightColor[1], dv)), + clampCssByte(lerp(leftColor[2], rightColor[2], dv)), + clampCssFloat(lerp(leftColor[3], rightColor[3], dv)) + ], + 'rgba' + ); + + return fullOutput + ? { + color: color, + leftIndex: leftIndex, + rightIndex: rightIndex, + value: value + } + : color; + } + + /** + * @param {Array} interval Array length === 2, + * each item is normalized value ([0, 1]). + * @param {Array.} colors Color list. + * @return {Array.} colors corresponding to the interval, + * each item is {color: 'xxx', offset: ...} + * where offset is between 0 and 1. + * @memberOf module:zrender/util/color + */ + function mapIntervalToColor(interval, colors) { + if (interval.length !== 2 || interval[1] < interval[0]) { + return; + } + + var info0 = mapToColor(interval[0], colors, true); + var info1 = mapToColor(interval[1], colors, true); + + var result = [{color: info0.color, offset: 0}]; + + var during = info1.value - info0.value; + var start = Math.max(info0.value, info0.rightIndex); + var end = Math.min(info1.value, info1.leftIndex); + + for (var i = start; during > 0 && i <= end; i++) { + result.push({ + color: colors[i], + offset: (i - info0.value) / during + }); + } + result.push({color: info1.color, offset: 1}); + + return result; + } + + /** + * @param {string} color + * @param {number=} h 0 ~ 360, ignore when null. + * @param {number=} s 0 ~ 1, ignore when null. + * @param {number=} l 0 ~ 1, ignore when null. + * @return {string} Color string in rgba format. + * @memberOf module:zrender/util/color + */ + function modifyHSL(color, h, s, l) { + color = parse(color); + + if (color) { + color = rgba2hsla(color); + h != null && (color[0] = clampCssAngle(h)); + s != null && (color[1] = parseCssFloat(s)); + l != null && (color[2] = parseCssFloat(l)); + + return stringify(hsla2rgba(color), 'rgba'); + } + } + + /** + * @param {string} color + * @param {number=} alpha 0 ~ 1 + * @return {string} Color string in rgba format. + * @memberOf module:zrender/util/color + */ + function modifyAlpha(color, alpha) { + color = parse(color); + + if (color && alpha != null) { + color[3] = clampCssFloat(alpha); + return stringify(color, 'rgba'); + } + } + + /** + * @param {Array.} colors Color list. + * @param {string} type 'rgba', 'hsva', ... + * @return {string} Result color. + */ + function stringify(arrColor, type) { + if (type === 'rgb' || type === 'hsv' || type === 'hsl') { + arrColor = arrColor.slice(0, 3); + } + return type + '(' + arrColor.join(',') + ')'; + } + + module.exports = { + parse: parse, + lift: lift, + toHex: toHex, + fastMapToColor: fastMapToColor, + mapToColor: mapToColor, + mapIntervalToColor: mapIntervalToColor, + modifyHSL: modifyHSL, + modifyAlpha: modifyAlpha, + stringify: stringify + }; + + + + +/***/ }, +/* 39 */ +/***/ function(module, exports, __webpack_require__) { + + + var config = __webpack_require__(40); + + /** + * @exports zrender/tool/log + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + */ + module.exports = function() { + if (config.debugMode === 0) { + return; + } + else if (config.debugMode == 1) { + for (var k in arguments) { + throw new Error(arguments[k]); + } + } + else if (config.debugMode > 1) { + for (var k in arguments) { + console.log(arguments[k]); + } + } + }; + + /* for debug + return function(mes) { + document.getElementById('wrong-message').innerHTML = + mes + ' ' + (new Date() - 0) + + '
' + + document.getElementById('wrong-message').innerHTML; + }; + */ + + + +/***/ }, +/* 40 */ +/***/ function(module, exports) { + + + var dpr = 1; + // If in browser environment + if (typeof window !== 'undefined') { + dpr = Math.max(window.devicePixelRatio || 1, 1); + } + /** + * config默认配置项 + * @exports zrender/config + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + */ + var config = { + /** + * debug日志选项:catchBrushException为true下有效 + * 0 : 不生成debug数据,发布用 + * 1 : 异常抛出,调试用 + * 2 : 控制台输出,调试用 + */ + debugMode: 0, + + // retina 屏幕优化 + devicePixelRatio: dpr + }; + module.exports = config; + + + + +/***/ }, +/* 41 */ +/***/ function(module, exports, __webpack_require__) { + + + + var Group = __webpack_require__(29); + var componentUtil = __webpack_require__(20); + var clazzUtil = __webpack_require__(9); + + function Chart() { + + /** + * @type {module:zrender/container/Group} + * @readOnly + */ + this.group = new Group(); + + /** + * @type {string} + * @readOnly + */ + this.uid = componentUtil.getUID('viewChart'); + } + + Chart.prototype = { + + type: 'chart', + + /** + * Init the chart + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + */ + init: function (ecModel, api) {}, + + /** + * Render the chart + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + * @param {Object} payload + */ + render: function (seriesModel, ecModel, api, payload) {}, + + /** + * Highlight series or specified data item + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + * @param {Object} payload + */ + highlight: function (seriesModel, ecModel, api, payload) { + toggleHighlight(seriesModel.getData(), payload, 'emphasis'); + }, + + /** + * Downplay series or specified data item + * @param {module:echarts/model/Series} seriesModel + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + * @param {Object} payload + */ + downplay: function (seriesModel, ecModel, api, payload) { + toggleHighlight(seriesModel.getData(), payload, 'normal'); + }, + + /** + * Remove self + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + */ + remove: function (ecModel, api) { + this.group.removeAll(); + }, + + /** + * Dispose self + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + */ + dispose: function () {} + }; + + var chartProto = Chart.prototype; + chartProto.updateView + = chartProto.updateLayout + = chartProto.updateVisual + = function (seriesModel, ecModel, api, payload) { + this.render(seriesModel, ecModel, api, payload); + }; + + /** + * Set state of single element + * @param {module:zrender/Element} el + * @param {string} state + */ + function elSetState(el, state) { + if (el) { + el.trigger(state); + if (el.type === 'group') { + for (var i = 0; i < el.childCount(); i++) { + elSetState(el.childAt(i), state); + } + } + } + } + /** + * @param {module:echarts/data/List} data + * @param {Object} payload + * @param {string} state 'normal'|'emphasis' + * @inner + */ + function toggleHighlight(data, payload, state) { + if (payload.dataIndex != null) { + var el = data.getItemGraphicEl(payload.dataIndex); + elSetState(el, state); + } + else if (payload.name) { + var dataIndex = data.indexOfName(payload.name); + var el = data.getItemGraphicEl(dataIndex); + elSetState(el, state); + } + else { + data.eachItemGraphicEl(function (el) { + elSetState(el, state); + }); + } + } + + // Enable Chart.extend. + clazzUtil.enableClassExtend(Chart); + + // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. + clazzUtil.enableClassManagement(Chart, {registerWhenExtend: true}); + + module.exports = Chart; + + +/***/ }, +/* 42 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + + var pathTool = __webpack_require__(43); + var round = Math.round; + var Path = __webpack_require__(44); + var colorTool = __webpack_require__(38); + var matrix = __webpack_require__(17); + var vector = __webpack_require__(16); + var Gradient = __webpack_require__(4); + + var graphic = {}; + + graphic.Group = __webpack_require__(29); + + graphic.Image = __webpack_require__(59); + + graphic.Text = __webpack_require__(62); + + graphic.Circle = __webpack_require__(63); + + graphic.Sector = __webpack_require__(64); + + graphic.Ring = __webpack_require__(65); + + graphic.Polygon = __webpack_require__(66); + + graphic.Polyline = __webpack_require__(70); + + graphic.Rect = __webpack_require__(71); + + graphic.Line = __webpack_require__(72); + + graphic.BezierCurve = __webpack_require__(73); + + graphic.Arc = __webpack_require__(74); + + graphic.LinearGradient = __webpack_require__(75); + + graphic.RadialGradient = __webpack_require__(76); + + graphic.BoundingRect = __webpack_require__(15); + + /** + * Extend shape with parameters + */ + graphic.extendShape = function (opts) { + return Path.extend(opts); + }; + + /** + * Extend path + */ + graphic.extendPath = function (pathData, opts) { + return pathTool.extendFromString(pathData, opts); + }; + + /** + * Create a path element from path data string + * @param {string} pathData + * @param {Object} opts + * @param {module:zrender/core/BoundingRect} rect + * @param {string} [layout=cover] 'center' or 'cover' + */ + graphic.makePath = function (pathData, opts, rect, layout) { + var path = pathTool.createFromString(pathData, opts); + var boundingRect = path.getBoundingRect(); + if (rect) { + var aspect = boundingRect.width / boundingRect.height; + + if (layout === 'center') { + // Set rect to center, keep width / height ratio. + var width = rect.height * aspect; + var height; + if (width <= rect.width) { + height = rect.height; + } + else { + width = rect.width; + height = width / aspect; + } + var cx = rect.x + rect.width / 2; + var cy = rect.y + rect.height / 2; + + rect.x = cx - width / 2; + rect.y = cy - height / 2; + rect.width = width; + rect.height = height; + } + + this.resizePath(path, rect); + } + return path; + }; + + graphic.mergePath = pathTool.mergePath, + + /** + * Resize a path to fit the rect + * @param {module:zrender/graphic/Path} path + * @param {Object} rect + */ + graphic.resizePath = function (path, rect) { + if (!path.applyTransform) { + return; + } + + var pathRect = path.getBoundingRect(); + + var m = pathRect.calculateTransform(rect); + + path.applyTransform(m); + }; + + /** + * Sub pixel optimize line for canvas + * + * @param {Object} param + * @param {Object} [param.shape] + * @param {number} [param.shape.x1] + * @param {number} [param.shape.y1] + * @param {number} [param.shape.x2] + * @param {number} [param.shape.y2] + * @param {Object} [param.style] + * @param {number} [param.style.lineWidth] + * @return {Object} Modified param + */ + graphic.subPixelOptimizeLine = function (param) { + var subPixelOptimize = graphic.subPixelOptimize; + var shape = param.shape; + var lineWidth = param.style.lineWidth; + + if (round(shape.x1 * 2) === round(shape.x2 * 2)) { + shape.x1 = shape.x2 = subPixelOptimize(shape.x1, lineWidth, true); + } + if (round(shape.y1 * 2) === round(shape.y2 * 2)) { + shape.y1 = shape.y2 = subPixelOptimize(shape.y1, lineWidth, true); + } + return param; + }; + + /** + * Sub pixel optimize rect for canvas + * + * @param {Object} param + * @param {Object} [param.shape] + * @param {number} [param.shape.x] + * @param {number} [param.shape.y] + * @param {number} [param.shape.width] + * @param {number} [param.shape.height] + * @param {Object} [param.style] + * @param {number} [param.style.lineWidth] + * @return {Object} Modified param + */ + graphic.subPixelOptimizeRect = function (param) { + var subPixelOptimize = graphic.subPixelOptimize; + var shape = param.shape; + var lineWidth = param.style.lineWidth; + var originX = shape.x; + var originY = shape.y; + var originWidth = shape.width; + var originHeight = shape.height; + shape.x = subPixelOptimize(shape.x, lineWidth, true); + shape.y = subPixelOptimize(shape.y, lineWidth, true); + shape.width = Math.max( + subPixelOptimize(originX + originWidth, lineWidth, false) - shape.x, + originWidth === 0 ? 0 : 1 + ); + shape.height = Math.max( + subPixelOptimize(originY + originHeight, lineWidth, false) - shape.y, + originHeight === 0 ? 0 : 1 + ); + return param; + }; + + /** + * Sub pixel optimize for canvas + * + * @param {number} position Coordinate, such as x, y + * @param {number} lineWidth Should be nonnegative integer. + * @param {boolean=} positiveOrNegative Default false (negative). + * @return {number} Optimized position. + */ + graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) { + // Assure that (position + lineWidth / 2) is near integer edge, + // otherwise line will be fuzzy in canvas. + var doubledPosition = round(position * 2); + return (doubledPosition + round(lineWidth)) % 2 === 0 + ? doubledPosition / 2 + : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2; + }; + + /** + * @private + */ + function doSingleEnterHover(el) { + if (el.__isHover) { + return; + } + if (el.__hoverStlDirty) { + var stroke = el.style.stroke; + var fill = el.style.fill; + + // Create hoverStyle on mouseover + var hoverStyle = el.__hoverStl; + hoverStyle.fill = hoverStyle.fill + || (fill instanceof Gradient ? fill : colorTool.lift(fill, -0.1)); + hoverStyle.stroke = hoverStyle.stroke + || (stroke instanceof Gradient ? stroke : colorTool.lift(stroke, -0.1)); + + var normalStyle = {}; + for (var name in hoverStyle) { + if (hoverStyle.hasOwnProperty(name)) { + normalStyle[name] = el.style[name]; + } + } + + el.__normalStl = normalStyle; + + el.__hoverStlDirty = false; + } + el.setStyle(el.__hoverStl); + el.z2 += 1; + + el.__isHover = true; + } + + /** + * @inner + */ + function doSingleLeaveHover(el) { + if (!el.__isHover) { + return; + } + + var normalStl = el.__normalStl; + normalStl && el.setStyle(normalStl); + el.z2 -= 1; + + el.__isHover = false; + } + + /** + * @inner + */ + function doEnterHover(el) { + el.type === 'group' + ? el.traverse(function (child) { + if (child.type !== 'group') { + doSingleEnterHover(child); + } + }) + : doSingleEnterHover(el); + } + + function doLeaveHover(el) { + el.type === 'group' + ? el.traverse(function (child) { + if (child.type !== 'group') { + doSingleLeaveHover(child); + } + }) + : doSingleLeaveHover(el); + } + + /** + * @inner + */ + function setElementHoverStl(el, hoverStl) { + // If element has sepcified hoverStyle, then use it instead of given hoverStyle + // Often used when item group has a label element and it's hoverStyle is different + el.__hoverStl = el.hoverStyle || hoverStl; + el.__hoverStlDirty = true; + } + + /** + * @inner + */ + function onElementMouseOver() { + // Only if element is not in emphasis status + !this.__isEmphasis && doEnterHover(this); + } + + /** + * @inner + */ + function onElementMouseOut() { + // Only if element is not in emphasis status + !this.__isEmphasis && doLeaveHover(this); + } + + /** + * @inner + */ + function enterEmphasis() { + this.__isEmphasis = true; + doEnterHover(this); + } + + /** + * @inner + */ + function leaveEmphasis() { + this.__isEmphasis = false; + doLeaveHover(this); + } + + /** + * Set hover style of element + * @param {module:zrender/Element} el + * @param {Object} [hoverStyle] + */ + graphic.setHoverStyle = function (el, hoverStyle) { + hoverStyle = hoverStyle || {}; + el.type === 'group' + ? el.traverse(function (child) { + if (child.type !== 'group') { + setElementHoverStl(child, hoverStyle); + } + }) + : setElementHoverStl(el, hoverStyle); + // Remove previous bound handlers + el.on('mouseover', onElementMouseOver) + .on('mouseout', onElementMouseOut); + + // Emphasis, normal can be triggered manually + el.on('emphasis', enterEmphasis) + .on('normal', leaveEmphasis); + }; + + /** + * Set text option in the style + * @param {Object} textStyle + * @param {module:echarts/model/Model} labelModel + * @param {string} color + */ + graphic.setText = function (textStyle, labelModel, color) { + var labelPosition = labelModel.getShallow('position') || 'inside'; + var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color; + var textStyleModel = labelModel.getModel('textStyle'); + zrUtil.extend(textStyle, { + textDistance: labelModel.getShallow('distance') || 5, + textFont: textStyleModel.getFont(), + textPosition: labelPosition, + textFill: textStyleModel.getTextColor() || labelColor + }); + }; + + function animateOrSetProps(isUpdate, el, props, animatableModel, cb) { + var postfix = isUpdate ? 'Update' : ''; + var duration = animatableModel + && animatableModel.getShallow('animationDuration' + postfix); + var animationEasing = animatableModel + && animatableModel.getShallow('animationEasing' + postfix); + + animatableModel && animatableModel.getShallow('animation') + ? el.animateTo(props, duration, animationEasing, cb) + : (el.attr(props), cb && cb()); + } + /** + * Update graphic element properties with or without animation according to the configuration in series + * @param {module:zrender/Element} el + * @param {Object} props + * @param {module:echarts/model/Model} [animatableModel] + * @param {Function} cb + */ + graphic.updateProps = zrUtil.curry(animateOrSetProps, true); + + /** + * Init graphic element properties with or without animation according to the configuration in series + * @param {module:zrender/Element} el + * @param {Object} props + * @param {module:echarts/model/Model} [animatableModel] + * @param {Function} cb + */ + graphic.initProps = zrUtil.curry(animateOrSetProps, false); + + /** + * Get transform matrix of target (param target), + * in coordinate of its ancestor (param ancestor) + * + * @param {module:zrender/mixin/Transformable} target + * @param {module:zrender/mixin/Transformable} ancestor + */ + graphic.getTransform = function (target, ancestor) { + var mat = matrix.identity([]); + + while (target && target !== ancestor) { + matrix.mul(mat, target.getLocalTransform(), mat); + target = target.parent; + } + + return mat; + }; + + /** + * Apply transform to an vertex. + * @param {Array.} vertex [x, y] + * @param {Array.} transform Transform matrix: like [1, 0, 0, 1, 0, 0] + * @param {boolean=} invert Whether use invert matrix. + * @return {Array.} [x, y] + */ + graphic.applyTransform = function (vertex, transform, invert) { + if (invert) { + transform = matrix.invert([], transform); + } + return vector.applyTransform([], vertex, transform); + }; + + /** + * @param {string} direction 'left' 'right' 'top' 'bottom' + * @param {Array.} transform Transform matrix: like [1, 0, 0, 1, 0, 0] + * @param {boolean=} invert Whether use invert matrix. + * @return {string} Transformed direction. 'left' 'right' 'top' 'bottom' + */ + graphic.transformDirection = function (direction, transform, invert) { + + // Pick a base, ensure that transform result will not be (0, 0). + var hBase = (transform[4] === 0 || transform[5] === 0 || transform[0] === 0) + ? 1 : Math.abs(2 * transform[4] / transform[0]); + var vBase = (transform[4] === 0 || transform[5] === 0 || transform[2] === 0) + ? 1 : Math.abs(2 * transform[4] / transform[2]); + + var vertex = [ + direction === 'left' ? -hBase : direction === 'right' ? hBase : 0, + direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0 + ]; + + vertex = graphic.applyTransform(vertex, transform, invert); + + return Math.abs(vertex[0]) > Math.abs(vertex[1]) + ? (vertex[0] > 0 ? 'right' : 'left') + : (vertex[1] > 0 ? 'bottom' : 'top'); + }; + + module.exports = graphic; + + +/***/ }, +/* 43 */ +/***/ function(module, exports, __webpack_require__) { + + + + var Path = __webpack_require__(44); + var PathProxy = __webpack_require__(48); + var transformPath = __webpack_require__(58); + var matrix = __webpack_require__(17); + + // command chars + var cc = [ + 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z', + 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A' + ]; + + var mathSqrt = Math.sqrt; + var mathSin = Math.sin; + var mathCos = Math.cos; + var PI = Math.PI; + + var vMag = function(v) { + return Math.sqrt(v[0] * v[0] + v[1] * v[1]); + }; + var vRatio = function(u, v) { + return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v)); + }; + var vAngle = function(u, v) { + return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) + * Math.acos(vRatio(u, v)); + }; + + function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) { + var psi = psiDeg * (PI / 180.0); + var xp = mathCos(psi) * (x1 - x2) / 2.0 + + mathSin(psi) * (y1 - y2) / 2.0; + var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0 + + mathCos(psi) * (y1 - y2) / 2.0; + + var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry); + + if (lambda > 1) { + rx *= mathSqrt(lambda); + ry *= mathSqrt(lambda); + } + + var f = (fa === fs ? -1 : 1) + * mathSqrt((((rx * rx) * (ry * ry)) + - ((rx * rx) * (yp * yp)) + - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp) + + (ry * ry) * (xp * xp)) + ) || 0; + + var cxp = f * rx * yp / ry; + var cyp = f * -ry * xp / rx; + + var cx = (x1 + x2) / 2.0 + + mathCos(psi) * cxp + - mathSin(psi) * cyp; + var cy = (y1 + y2) / 2.0 + + mathSin(psi) * cxp + + mathCos(psi) * cyp; + + var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]); + var u = [ (xp - cxp) / rx, (yp - cyp) / ry ]; + var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ]; + var dTheta = vAngle(u, v); + + if (vRatio(u, v) <= -1) { + dTheta = PI; + } + if (vRatio(u, v) >= 1) { + dTheta = 0; + } + if (fs === 0 && dTheta > 0) { + dTheta = dTheta - 2 * PI; + } + if (fs === 1 && dTheta < 0) { + dTheta = dTheta + 2 * PI; + } + + path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs); + } + + function createPathProxyFromString(data) { + if (!data) { + return []; + } + + // command string + var cs = data.replace(/-/g, ' -') + .replace(/ /g, ' ') + .replace(/ /g, ',') + .replace(/,,/g, ','); + + var n; + // create pipes so that we can split the data + for (n = 0; n < cc.length; n++) { + cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]); + } + + // create array + var arr = cs.split('|'); + // init context point + var cpx = 0; + var cpy = 0; + + var path = new PathProxy(); + var CMD = PathProxy.CMD; + + var prevCmd; + for (n = 1; n < arr.length; n++) { + var str = arr[n]; + var c = str.charAt(0); + var off = 0; + var p = str.slice(1).replace(/e,-/g, 'e-').split(','); + var cmd; + + if (p.length > 0 && p[0] === '') { + p.shift(); + } + + for (var i = 0; i < p.length; i++) { + p[i] = parseFloat(p[i]); + } + while (off < p.length && !isNaN(p[off])) { + if (isNaN(p[0])) { + break; + } + var ctlPtx; + var ctlPty; + + var rx; + var ry; + var psi; + var fa; + var fs; + + var x1 = cpx; + var y1 = cpy; + + // convert l, H, h, V, and v to L + switch (c) { + case 'l': + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'L': + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'm': + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.M; + path.addData(cmd, cpx, cpy); + c = 'l'; + break; + case 'M': + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.M; + path.addData(cmd, cpx, cpy); + c = 'L'; + break; + case 'h': + cpx += p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'H': + cpx = p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'v': + cpy += p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'V': + cpy = p[off++]; + cmd = CMD.L; + path.addData(cmd, cpx, cpy); + break; + case 'C': + cmd = CMD.C; + path.addData( + cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++] + ); + cpx = p[off - 2]; + cpy = p[off - 1]; + break; + case 'c': + cmd = CMD.C; + path.addData( + cmd, + p[off++] + cpx, p[off++] + cpy, + p[off++] + cpx, p[off++] + cpy, + p[off++] + cpx, p[off++] + cpy + ); + cpx += p[off - 2]; + cpy += p[off - 1]; + break; + case 'S': + ctlPtx = cpx; + ctlPty = cpy; + var len = path.len(); + var pathData = path.data; + if (prevCmd === CMD.C) { + ctlPtx += cpx - pathData[len - 4]; + ctlPty += cpy - pathData[len - 3]; + } + cmd = CMD.C; + x1 = p[off++]; + y1 = p[off++]; + cpx = p[off++]; + cpy = p[off++]; + path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy); + break; + case 's': + ctlPtx = cpx; + ctlPty = cpy; + var len = path.len(); + var pathData = path.data; + if (prevCmd === CMD.C) { + ctlPtx += cpx - pathData[len - 4]; + ctlPty += cpy - pathData[len - 3]; + } + cmd = CMD.C; + x1 = cpx + p[off++]; + y1 = cpy + p[off++]; + cpx += p[off++]; + cpy += p[off++]; + path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy); + break; + case 'Q': + x1 = p[off++]; + y1 = p[off++]; + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.Q; + path.addData(cmd, x1, y1, cpx, cpy); + break; + case 'q': + x1 = p[off++] + cpx; + y1 = p[off++] + cpy; + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.Q; + path.addData(cmd, x1, y1, cpx, cpy); + break; + case 'T': + ctlPtx = cpx; + ctlPty = cpy; + var len = path.len(); + var pathData = path.data; + if (prevCmd === CMD.Q) { + ctlPtx += cpx - pathData[len - 4]; + ctlPty += cpy - pathData[len - 3]; + } + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.Q; + path.addData(cmd, ctlPtx, ctlPty, cpx, cpy); + break; + case 't': + ctlPtx = cpx; + ctlPty = cpy; + var len = path.len(); + var pathData = path.data; + if (prevCmd === CMD.Q) { + ctlPtx += cpx - pathData[len - 4]; + ctlPty += cpy - pathData[len - 3]; + } + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.Q; + path.addData(cmd, ctlPtx, ctlPty, cpx, cpy); + break; + case 'A': + rx = p[off++]; + ry = p[off++]; + psi = p[off++]; + fa = p[off++]; + fs = p[off++]; + + x1 = cpx, y1 = cpy; + cpx = p[off++]; + cpy = p[off++]; + cmd = CMD.A; + processArc( + x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path + ); + break; + case 'a': + rx = p[off++]; + ry = p[off++]; + psi = p[off++]; + fa = p[off++]; + fs = p[off++]; + + x1 = cpx, y1 = cpy; + cpx += p[off++]; + cpy += p[off++]; + cmd = CMD.A; + processArc( + x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path + ); + break; + } + } + + if (c === 'z' || c === 'Z') { + cmd = CMD.Z; + path.addData(cmd); + } + + prevCmd = cmd; + } + + path.toStatic(); + + return path; + } + + // TODO Optimize double memory cost problem + function createPathOptions(str, opts) { + var pathProxy = createPathProxyFromString(str); + var transform; + opts = opts || {}; + opts.buildPath = function (path) { + path.setData(pathProxy.data); + transform && transformPath(path, transform); + // Svg and vml renderer don't have context + var ctx = path.getContext(); + if (ctx) { + path.rebuildPath(ctx); + } + }; + + opts.applyTransform = function (m) { + if (!transform) { + transform = matrix.create(); + } + matrix.mul(transform, m, transform); + }; + + return opts; + } + + module.exports = { + /** + * Create a Path object from path string data + * http://www.w3.org/TR/SVG/paths.html#PathData + * @param {Object} opts Other options + */ + createFromString: function (str, opts) { + return new Path(createPathOptions(str, opts)); + }, + + /** + * Create a Path class from path string data + * @param {string} str + * @param {Object} opts Other options + */ + extendFromString: function (str, opts) { + return Path.extend(createPathOptions(str, opts)); + }, + + /** + * Merge multiple paths + */ + // TODO Apply transform + // TODO stroke dash + // TODO Optimize double memory cost problem + mergePath: function (pathEls, opts) { + var pathList = []; + var len = pathEls.length; + var pathEl; + var i; + for (i = 0; i < len; i++) { + pathEl = pathEls[i]; + if (pathEl.__dirty) { + pathEl.buildPath(pathEl.path, pathEl.shape); + } + pathList.push(pathEl.path); + } + + var pathBundle = new Path(opts); + pathBundle.buildPath = function (path) { + path.appendPath(pathList); + // Svg and vml renderer don't have context + var ctx = path.getContext(); + if (ctx) { + path.rebuildPath(ctx); + } + }; + + return pathBundle; + } + }; + + +/***/ }, +/* 44 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Path element + * @module zrender/graphic/Path + */ + + + + var Displayable = __webpack_require__(45); + var zrUtil = __webpack_require__(3); + var PathProxy = __webpack_require__(48); + var pathContain = __webpack_require__(51); + + var Gradient = __webpack_require__(4); + + function pathHasFill(style) { + var fill = style.fill; + return fill != null && fill !== 'none'; + } + + function pathHasStroke(style) { + var stroke = style.stroke; + return stroke != null && stroke !== 'none' && style.lineWidth > 0; + } + + var abs = Math.abs; + + /** + * @alias module:zrender/graphic/Path + * @extends module:zrender/graphic/Displayable + * @constructor + * @param {Object} opts + */ + function Path(opts) { + Displayable.call(this, opts); + + /** + * @type {module:zrender/core/PathProxy} + * @readOnly + */ + this.path = new PathProxy(); + } + + Path.prototype = { + + constructor: Path, + + type: 'path', + + __dirtyPath: true, + + strokeContainThreshold: 5, + + brush: function (ctx) { + ctx.save(); + + var style = this.style; + var path = this.path; + var hasStroke = pathHasStroke(style); + var hasFill = pathHasFill(style); + + if (this.__dirtyPath) { + // Update gradient because bounding rect may changed + if (hasFill && (style.fill instanceof Gradient)) { + style.fill.updateCanvasGradient(this, ctx); + } + if (hasStroke && (style.stroke instanceof Gradient)) { + style.stroke.updateCanvasGradient(this, ctx); + } + } + + style.bind(ctx, this); + this.setTransform(ctx); + + var lineDash = style.lineDash; + var lineDashOffset = style.lineDashOffset; + + var ctxLineDash = !!ctx.setLineDash; + + // Proxy context + // Rebuild path in following 2 cases + // 1. Path is dirty + // 2. Path needs javascript implemented lineDash stroking. + // In this case, lineDash information will not be saved in PathProxy + if (this.__dirtyPath || ( + lineDash && !ctxLineDash && hasStroke + )) { + path = this.path.beginPath(ctx); + + // Setting line dash before build path + if (lineDash && !ctxLineDash) { + path.setLineDash(lineDash); + path.setLineDashOffset(lineDashOffset); + } + + this.buildPath(path, this.shape); + + // Clear path dirty flag + this.__dirtyPath = false; + } + else { + // Replay path building + ctx.beginPath(); + this.path.rebuildPath(ctx); + } + + hasFill && path.fill(ctx); + + if (lineDash && ctxLineDash) { + ctx.setLineDash(lineDash); + ctx.lineDashOffset = lineDashOffset; + } + + hasStroke && path.stroke(ctx); + + // Draw rect text + if (style.text != null) { + // var rect = this.getBoundingRect(); + this.drawRectText(ctx, this.getBoundingRect()); + } + + ctx.restore(); + }, + + buildPath: function (ctx, shapeCfg) {}, + + getBoundingRect: function () { + var rect = this._rect; + var style = this.style; + if (!rect) { + var path = this.path; + if (this.__dirtyPath) { + path.beginPath(); + this.buildPath(path, this.shape); + } + rect = path.getBoundingRect(); + } + /** + * Needs update rect with stroke lineWidth when + * 1. Element changes scale or lineWidth + * 2. First create rect + */ + if (pathHasStroke(style) && (this.__dirty || !this._rect)) { + var rectWithStroke = this._rectWithStroke + || (this._rectWithStroke = rect.clone()); + rectWithStroke.copy(rect); + // FIXME Must after updateTransform + var w = style.lineWidth; + // PENDING, Min line width is needed when line is horizontal or vertical + var lineScale = style.strokeNoScale ? this.getLineScale() : 1; + + // Only add extra hover lineWidth when there are no fill + if (!pathHasFill(style)) { + w = Math.max(w, this.strokeContainThreshold); + } + // Consider line width + // Line scale can't be 0; + if (lineScale > 1e-10) { + rectWithStroke.width += w / lineScale; + rectWithStroke.height += w / lineScale; + rectWithStroke.x -= w / lineScale / 2; + rectWithStroke.y -= w / lineScale / 2; + } + return rectWithStroke; + } + this._rect = rect; + return rect; + }, + + contain: function (x, y) { + var localPos = this.transformCoordToLocal(x, y); + var rect = this.getBoundingRect(); + var style = this.style; + x = localPos[0]; + y = localPos[1]; + + if (rect.contain(x, y)) { + var pathData = this.path.data; + if (pathHasStroke(style)) { + var lineWidth = style.lineWidth; + var lineScale = style.strokeNoScale ? this.getLineScale() : 1; + // Line scale can't be 0; + if (lineScale > 1e-10) { + // Only add extra hover lineWidth when there are no fill + if (!pathHasFill(style)) { + lineWidth = Math.max(lineWidth, this.strokeContainThreshold); + } + if (pathContain.containStroke( + pathData, lineWidth / lineScale, x, y + )) { + return true; + } + } + } + if (pathHasFill(style)) { + return pathContain.contain(pathData, x, y); + } + } + return false; + }, + + /** + * @param {boolean} dirtyPath + */ + dirty: function (dirtyPath) { + if (arguments.length ===0) { + dirtyPath = true; + } + // Only mark dirty, not mark clean + if (dirtyPath) { + this.__dirtyPath = dirtyPath; + this._rect = null; + } + + this.__dirty = true; + + this.__zr && this.__zr.refresh(); + + // Used as a clipping path + if (this.__clipTarget) { + this.__clipTarget.dirty(); + } + }, + + /** + * Alias for animate('shape') + * @param {boolean} loop + */ + animateShape: function (loop) { + return this.animate('shape', loop); + }, + + // Overwrite attrKV + attrKV: function (key, value) { + // FIXME + if (key === 'shape') { + this.setShape(value); + } + else { + Displayable.prototype.attrKV.call(this, key, value); + } + }, + /** + * @param {Object|string} key + * @param {*} value + */ + setShape: function (key, value) { + var shape = this.shape; + // Path from string may not have shape + if (shape) { + if (zrUtil.isObject(key)) { + for (var name in key) { + shape[name] = key[name]; + } + } + else { + shape[key] = value; + } + this.dirty(true); + } + return this; + }, + + getLineScale: function () { + var m = this.transform; + // Get the line scale. + // Determinant of `m` means how much the area is enlarged by the + // transformation. So its square root can be used as a scale factor + // for width. + return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10 + ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1])) + : 1; + } + }; + + /** + * 扩展一个 Path element, 比如星形,圆等。 + * Extend a path element + * @param {Object} props + * @param {string} props.type Path type + * @param {Function} props.init Initialize + * @param {Function} props.buildPath Overwrite buildPath method + * @param {Object} [props.style] Extended default style config + * @param {Object} [props.shape] Extended default shape config + */ + Path.extend = function (defaults) { + var Sub = function (opts) { + Path.call(this, opts); + + if (defaults.style) { + // Extend default style + this.style.extendFrom(defaults.style, false); + } + + // Extend default shape + var defaultShape = defaults.shape; + if (defaultShape) { + this.shape = this.shape || {}; + var thisShape = this.shape; + for (var name in defaultShape) { + if ( + ! thisShape.hasOwnProperty(name) + && defaultShape.hasOwnProperty(name) + ) { + thisShape[name] = defaultShape[name]; + } + } + } + + defaults.init && defaults.init.call(this, opts); + }; + + zrUtil.inherits(Sub, Path); + + // FIXME 不能 extend position, rotation 等引用对象 + for (var name in defaults) { + // Extending prototype values and methods + if (name !== 'style' && name !== 'shape') { + Sub.prototype[name] = defaults[name]; + } + } + + return Sub; + }; + + zrUtil.inherits(Path, Displayable); + + module.exports = Path; + + +/***/ }, +/* 45 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 可绘制的图形基类 + * Base class of all displayable graphic objects + * @module zrender/graphic/Displayable + */ + + + + var zrUtil = __webpack_require__(3); + + var Style = __webpack_require__(46); + + var Element = __webpack_require__(30); + var RectText = __webpack_require__(47); + // var Stateful = require('./mixin/Stateful'); + + /** + * @alias module:zrender/graphic/Displayable + * @extends module:zrender/Element + * @extends module:zrender/graphic/mixin/RectText + */ + function Displayable(opts) { + + opts = opts || {}; + + Element.call(this, opts); + + // Extend properties + for (var name in opts) { + if ( + opts.hasOwnProperty(name) && + name !== 'style' + ) { + this[name] = opts[name]; + } + } + + /** + * @type {module:zrender/graphic/Style} + */ + this.style = new Style(opts.style); + + this._rect = null; + // Shapes for cascade clipping. + this.__clipPaths = []; + + // FIXME Stateful must be mixined after style is setted + // Stateful.call(this, opts); + } + + Displayable.prototype = { + + constructor: Displayable, + + type: 'displayable', + + /** + * Displayable 是否为脏,Painter 中会根据该标记判断是否需要是否需要重新绘制 + * Dirty flag. From which painter will determine if this displayable object needs brush + * @name module:zrender/graphic/Displayable#__dirty + * @type {boolean} + */ + __dirty: true, + + /** + * 图形是否可见,为true时不绘制图形,但是仍能触发鼠标事件 + * If ignore drawing of the displayable object. Mouse event will still be triggered + * @name module:/zrender/graphic/Displayable#invisible + * @type {boolean} + * @default false + */ + invisible: false, + + /** + * @name module:/zrender/graphic/Displayable#z + * @type {number} + * @default 0 + */ + z: 0, + + /** + * @name module:/zrender/graphic/Displayable#z + * @type {number} + * @default 0 + */ + z2: 0, + + /** + * z层level,决定绘画在哪层canvas中 + * @name module:/zrender/graphic/Displayable#zlevel + * @type {number} + * @default 0 + */ + zlevel: 0, + + /** + * 是否可拖拽 + * @name module:/zrender/graphic/Displayable#draggable + * @type {boolean} + * @default false + */ + draggable: false, + + /** + * 是否正在拖拽 + * @name module:/zrender/graphic/Displayable#draggable + * @type {boolean} + * @default false + */ + dragging: false, + + /** + * 是否相应鼠标事件 + * @name module:/zrender/graphic/Displayable#silent + * @type {boolean} + * @default false + */ + silent: false, + + /** + * If enable culling + * @type {boolean} + * @default false + */ + culling: false, + + /** + * Mouse cursor when hovered + * @name module:/zrender/graphic/Displayable#cursor + * @type {string} + */ + cursor: 'pointer', + + /** + * If hover area is bounding rect + * @name module:/zrender/graphic/Displayable#rectHover + * @type {string} + */ + rectHover: false, + + beforeBrush: function (ctx) {}, + + afterBrush: function (ctx) {}, + + /** + * 图形绘制方法 + * @param {Canvas2DRenderingContext} ctx + */ + // Interface + brush: function (ctx) {}, + + /** + * 获取最小包围盒 + * @return {module:zrender/core/BoundingRect} + */ + // Interface + getBoundingRect: function () {}, + + /** + * 判断坐标 x, y 是否在图形上 + * If displayable element contain coord x, y + * @param {number} x + * @param {number} y + * @return {boolean} + */ + contain: function (x, y) { + return this.rectContain(x, y); + }, + + /** + * @param {Function} cb + * @param {} context + */ + traverse: function (cb, context) { + cb.call(context, this); + }, + + /** + * 判断坐标 x, y 是否在图形的包围盒上 + * If bounding rect of element contain coord x, y + * @param {number} x + * @param {number} y + * @return {boolean} + */ + rectContain: function (x, y) { + var coord = this.transformCoordToLocal(x, y); + var rect = this.getBoundingRect(); + return rect.contain(coord[0], coord[1]); + }, + + /** + * 标记图形元素为脏,并且在下一帧重绘 + * Mark displayable element dirty and refresh next frame + */ + dirty: function () { + this.__dirty = true; + + this._rect = null; + + this.__zr && this.__zr.refresh(); + }, + + /** + * 图形是否会触发事件 + * If displayable object binded any event + * @return {boolean} + */ + // TODO, 通过 bind 绑定的事件 + // isSilent: function () { + // return !( + // this.hoverable || this.draggable + // || this.onmousemove || this.onmouseover || this.onmouseout + // || this.onmousedown || this.onmouseup || this.onclick + // || this.ondragenter || this.ondragover || this.ondragleave + // || this.ondrop + // ); + // }, + /** + * Alias for animate('style') + * @param {boolean} loop + */ + animateStyle: function (loop) { + return this.animate('style', loop); + }, + + attrKV: function (key, value) { + if (key !== 'style') { + Element.prototype.attrKV.call(this, key, value); + } + else { + this.style.set(value); + } + }, + + /** + * @param {Object|string} key + * @param {*} value + */ + setStyle: function (key, value) { + this.style.set(key, value); + this.dirty(); + return this; + } + }; + + zrUtil.inherits(Displayable, Element); + + zrUtil.mixin(Displayable, RectText); + // zrUtil.mixin(Displayable, Stateful); + + module.exports = Displayable; + + +/***/ }, +/* 46 */ +/***/ function(module, exports) { + + /** + * @module zrender/graphic/Style + */ + + + + var STYLE_LIST_COMMON = [ + 'lineCap', 'lineJoin', 'miterLimit', + 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'shadowColor' + ]; + + var Style = function (opts) { + this.extendFrom(opts); + }; + + Style.prototype = { + + constructor: Style, + + /** + * @type {string} + */ + fill: '#000000', + + /** + * @type {string} + */ + stroke: null, + + /** + * @type {number} + */ + opacity: 1, + + /** + * @type {Array.} + */ + lineDash: null, + + /** + * @type {number} + */ + lineDashOffset: 0, + + /** + * @type {number} + */ + shadowBlur: 0, + + /** + * @type {number} + */ + shadowOffsetX: 0, + + /** + * @type {number} + */ + shadowOffsetY: 0, + + /** + * @type {number} + */ + lineWidth: 1, + + /** + * If stroke ignore scale + * @type {Boolean} + */ + strokeNoScale: false, + + // Bounding rect text configuration + // Not affected by element transform + /** + * @type {string} + */ + text: null, + + /** + * @type {string} + */ + textFill: '#000', + + /** + * @type {string} + */ + textStroke: null, + + /** + * 'inside', 'left', 'right', 'top', 'bottom' + * [x, y] + * @type {string|Array.} + * @default 'inside' + */ + textPosition: 'inside', + + /** + * @type {string} + */ + textBaseline: null, + + /** + * @type {string} + */ + textAlign: null, + + /** + * @type {string} + */ + textVerticalAlign: null, + + /** + * @type {number} + */ + textDistance: 5, + + /** + * @type {number} + */ + textShadowBlur: 0, + + /** + * @type {number} + */ + textShadowOffsetX: 0, + + /** + * @type {number} + */ + textShadowOffsetY: 0, + + /** + * @param {CanvasRenderingContext2D} ctx + */ + bind: function (ctx, el) { + var fill = this.fill; + var stroke = this.stroke; + for (var i = 0; i < STYLE_LIST_COMMON.length; i++) { + var styleName = STYLE_LIST_COMMON[i]; + + if (this[styleName] != null) { + ctx[styleName] = this[styleName]; + } + } + if (stroke != null) { + var lineWidth = this.lineWidth; + ctx.lineWidth = lineWidth / ( + (this.strokeNoScale && el && el.getLineScale) ? el.getLineScale() : 1 + ); + } + if (fill != null) { + // Use canvas gradient if has + ctx.fillStyle = fill.canvasGradient ? fill.canvasGradient : fill; + } + if (stroke != null) { + // Use canvas gradient if has + ctx.strokeStyle = stroke.canvasGradient ? stroke.canvasGradient : stroke; + } + this.opacity != null && (ctx.globalAlpha = this.opacity); + }, + + /** + * Extend from other style + * @param {zrender/graphic/Style} otherStyle + * @param {boolean} overwrite + */ + extendFrom: function (otherStyle, overwrite) { + if (otherStyle) { + var target = this; + for (var name in otherStyle) { + if (otherStyle.hasOwnProperty(name) + && (overwrite || ! target.hasOwnProperty(name)) + ) { + target[name] = otherStyle[name]; + } + } + } + }, + + /** + * Batch setting style with a given object + * @param {Object|string} obj + * @param {*} [obj] + */ + set: function (obj, value) { + if (typeof obj === 'string') { + this[obj] = value; + } + else { + this.extendFrom(obj, true); + } + }, + + /** + * Clone + * @return {zrender/graphic/Style} [description] + */ + clone: function () { + var newStyle = new this.constructor(); + newStyle.extendFrom(this, true); + return newStyle; + } + }; + + var styleProto = Style.prototype; + var name; + var i; + for (i = 0; i < STYLE_LIST_COMMON.length; i++) { + name = STYLE_LIST_COMMON[i]; + if (!(name in styleProto)) { + styleProto[name] = null; + } + } + + module.exports = Style; + + +/***/ }, +/* 47 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Mixin for drawing text in a element bounding rect + * @module zrender/mixin/RectText + */ + + + + var textContain = __webpack_require__(14); + var BoundingRect = __webpack_require__(15); + + var tmpRect = new BoundingRect(); + + var RectText = function () {}; + + function parsePercent(value, maxValue) { + if (typeof value === 'string') { + if (value.lastIndexOf('%') >= 0) { + return parseFloat(value) / 100 * maxValue; + } + return parseFloat(value); + } + return value; + } + + function setTransform(ctx, m) { + ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); + } + + RectText.prototype = { + + constructor: RectText, + + /** + * Draw text in a rect with specified position. + * @param {CanvasRenderingContext} ctx + * @param {Object} rect Displayable rect + * @return {Object} textRect Alternative precalculated text bounding rect + */ + drawRectText: function (ctx, rect, textRect) { + var style = this.style; + var text = style.text; + // Convert to string + text != null && (text += ''); + if (!text) { + return; + } + var x; + var y; + var textPosition = style.textPosition; + var distance = style.textDistance; + var align = style.textAlign; + var font = style.textFont || style.font; + var baseline = style.textBaseline; + var verticalAlign = style.textVerticalAlign; + + textRect = textRect || textContain.getBoundingRect(text, font, align, baseline); + + // Transform rect to view space + var transform = this.transform; + var invTransform = this.invTransform; + if (transform) { + tmpRect.copy(rect); + tmpRect.applyTransform(transform); + rect = tmpRect; + // Transform back + setTransform(ctx, invTransform); + } + + // Text position represented by coord + if (textPosition instanceof Array) { + // Percent + x = rect.x + parsePercent(textPosition[0], rect.width); + y = rect.y + parsePercent(textPosition[1], rect.height); + align = align || 'left'; + baseline = baseline || 'top'; + } + else { + var res = textContain.adjustTextPositionOnRect( + textPosition, rect, textRect, distance + ); + x = res.x; + y = res.y; + // Default align and baseline when has textPosition + align = align || res.textAlign; + baseline = baseline || res.textBaseline; + } + + ctx.textAlign = align; + if (verticalAlign) { + switch (verticalAlign) { + case 'middle': + y -= textRect.height / 2; + break; + case 'bottom': + y -= textRect.height; + break; + // 'top' + } + // Ignore baseline + ctx.textBaseline = 'top'; + } + else { + ctx.textBaseline = baseline; + } + + var textFill = style.textFill; + var textStroke = style.textStroke; + textFill && (ctx.fillStyle = textFill); + textStroke && (ctx.strokeStyle = textStroke); + ctx.font = font; + + // Text shadow + ctx.shadowColor = style.textShadowColor; + ctx.shadowBlur = style.textShadowBlur; + ctx.shadowOffsetX = style.textShadowOffsetX; + ctx.shadowOffsetY = style.textShadowOffsetY; + + var textLines = text.split('\n'); + for (var i = 0; i < textLines.length; i++) { + textFill && ctx.fillText(textLines[i], x, y); + textStroke && ctx.strokeText(textLines[i], x, y); + y += textRect.lineHeight; + } + + // Transform again + transform && setTransform(ctx, transform); + } + }; + + module.exports = RectText; + + +/***/ }, +/* 48 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Path 代理,可以在`buildPath`中用于替代`ctx`, 会保存每个path操作的命令到pathCommands属性中 + * 可以用于 isInsidePath 判断以及获取boundingRect + * + * @module zrender/core/PathProxy + * @author Yi Shen (http://www.github.com/pissang) + */ + + // TODO getTotalLength, getPointAtLength + + + var curve = __webpack_require__(49); + var vec2 = __webpack_require__(16); + var bbox = __webpack_require__(50); + var BoundingRect = __webpack_require__(15); + + var CMD = { + M: 1, + L: 2, + C: 3, + Q: 4, + A: 5, + Z: 6, + // Rect + R: 7 + }; + + var min = []; + var max = []; + var min2 = []; + var max2 = []; + var mathMin = Math.min; + var mathMax = Math.max; + var mathCos = Math.cos; + var mathSin = Math.sin; + var mathSqrt = Math.sqrt; + + var hasTypedArray = typeof Float32Array != 'undefined'; + + /** + * @alias module:zrender/core/PathProxy + * @constructor + */ + var PathProxy = function () { + + /** + * Path data. Stored as flat array + * @type {Array.} + */ + this.data = []; + + this._len = 0; + + this._ctx = null; + + this._xi = 0; + this._yi = 0; + + this._x0 = 0; + this._y0 = 0; + }; + + /** + * 快速计算Path包围盒(并不是最小包围盒) + * @return {Object} + */ + PathProxy.prototype = { + + constructor: PathProxy, + + _lineDash: null, + + _dashOffset: 0, + + _dashIdx: 0, + + _dashSum: 0, + + getContext: function () { + return this._ctx; + }, + + /** + * @param {CanvasRenderingContext2D} ctx + * @return {module:zrender/core/PathProxy} + */ + beginPath: function (ctx) { + this._ctx = ctx; + + ctx && ctx.beginPath(); + + // Reset + this._len = 0; + + if (this._lineDash) { + this._lineDash = null; + + this._dashOffset = 0; + } + + return this; + }, + + /** + * @param {number} x + * @param {number} y + * @return {module:zrender/core/PathProxy} + */ + moveTo: function (x, y) { + this.addData(CMD.M, x, y); + this._ctx && this._ctx.moveTo(x, y); + + // x0, y0, xi, yi 是记录在 _dashedXXXXTo 方法中使用 + // xi, yi 记录当前点, x0, y0 在 closePath 的时候回到起始点。 + // 有可能在 beginPath 之后直接调用 lineTo,这时候 x0, y0 需要 + // 在 lineTo 方法中记录,这里先不考虑这种情况,dashed line 也只在 IE10- 中不支持 + this._x0 = x; + this._y0 = y; + + this._xi = x; + this._yi = y; + + return this; + }, + + /** + * @param {number} x + * @param {number} y + * @return {module:zrender/core/PathProxy} + */ + lineTo: function (x, y) { + this.addData(CMD.L, x, y); + if (this._ctx) { + this._needsDash() ? this._dashedLineTo(x, y) + : this._ctx.lineTo(x, y); + } + this._xi = x; + this._yi = y; + return this; + }, + + /** + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x3 + * @param {number} y3 + * @return {module:zrender/core/PathProxy} + */ + bezierCurveTo: function (x1, y1, x2, y2, x3, y3) { + this.addData(CMD.C, x1, y1, x2, y2, x3, y3); + if (this._ctx) { + this._needsDash() ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3) + : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3); + } + this._xi = x3; + this._yi = y3; + return this; + }, + + /** + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @return {module:zrender/core/PathProxy} + */ + quadraticCurveTo: function (x1, y1, x2, y2) { + this.addData(CMD.Q, x1, y1, x2, y2); + if (this._ctx) { + this._needsDash() ? this._dashedQuadraticTo(x1, y1, x2, y2) + : this._ctx.quadraticCurveTo(x1, y1, x2, y2); + } + this._xi = x2; + this._yi = y2; + return this; + }, + + /** + * @param {number} cx + * @param {number} cy + * @param {number} r + * @param {number} startAngle + * @param {number} endAngle + * @param {boolean} anticlockwise + * @return {module:zrender/core/PathProxy} + */ + arc: function (cx, cy, r, startAngle, endAngle, anticlockwise) { + this.addData( + CMD.A, cx, cy, r, r, startAngle, endAngle - startAngle, 0, anticlockwise ? 0 : 1 + ); + this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise); + + this._xi = mathCos(endAngle) * r + cx; + this._xi = mathSin(endAngle) * r + cx; + return this; + }, + + // TODO + arcTo: function (x1, y1, x2, y2, radius) { + if (this._ctx) { + this._ctx.arcTo(x1, y1, x2, y2, radius); + } + return this; + }, + + // TODO + rect: function (x, y, w, h) { + this._ctx && this._ctx.rect(x, y, w, h); + this.addData(CMD.R, x, y, w, h); + return this; + }, + + /** + * @return {module:zrender/core/PathProxy} + */ + closePath: function () { + this.addData(CMD.Z); + + var ctx = this._ctx; + var x0 = this._x0; + var y0 = this._y0; + if (ctx) { + this._needsDash() && this._dashedLineTo(x0, y0); + ctx.closePath(); + } + + this._xi = x0; + this._yi = y0; + return this; + }, + + /** + * Context 从外部传入,因为有可能是 rebuildPath 完之后再 fill。 + * stroke 同样 + * @param {CanvasRenderingContext2D} ctx + * @return {module:zrender/core/PathProxy} + */ + fill: function (ctx) { + ctx && ctx.fill(); + this.toStatic(); + }, + + /** + * @param {CanvasRenderingContext2D} ctx + * @return {module:zrender/core/PathProxy} + */ + stroke: function (ctx) { + ctx && ctx.stroke(); + this.toStatic(); + }, + + /** + * 必须在其它绘制命令前调用 + * Must be invoked before all other path drawing methods + * @return {module:zrender/core/PathProxy} + */ + setLineDash: function (lineDash) { + if (lineDash instanceof Array) { + this._lineDash = lineDash; + + this._dashIdx = 0; + + var lineDashSum = 0; + for (var i = 0; i < lineDash.length; i++) { + lineDashSum += lineDash[i]; + } + this._dashSum = lineDashSum; + } + return this; + }, + + /** + * 必须在其它绘制命令前调用 + * Must be invoked before all other path drawing methods + * @return {module:zrender/core/PathProxy} + */ + setLineDashOffset: function (offset) { + this._dashOffset = offset; + return this; + }, + + /** + * + * @return {boolean} + */ + len: function () { + return this._len; + }, + + /** + * 直接设置 Path 数据 + */ + setData: function (data) { + + var len = data.length; + + if (! (this.data && this.data.length == len) && hasTypedArray) { + this.data = new Float32Array(len); + } + + for (var i = 0; i < len; i++) { + this.data[i] = data[i]; + } + + this._len = len; + }, + + /** + * 添加子路径 + * @param {module:zrender/core/PathProxy|Array.} path + */ + appendPath: function (path) { + if (!(path instanceof Array)) { + path = [path]; + } + var len = path.length; + var appendSize = 0; + var offset = this._len; + for (var i = 0; i < len; i++) { + appendSize += path[i].len(); + } + if (hasTypedArray && (this.data instanceof Float32Array)) { + this.data = new Float32Array(offset + appendSize); + } + for (var i = 0; i < len; i++) { + var appendPathData = path[i].data; + for (var k = 0; k < appendPathData.length; k++) { + this.data[offset++] = appendPathData[k]; + } + } + this._len = offset; + }, + + /** + * 填充 Path 数据。 + * 尽量复用而不申明新的数组。大部分图形重绘的指令数据长度都是不变的。 + */ + addData: function (cmd) { + var data = this.data; + if (this._len + arguments.length > data.length) { + // 因为之前的数组已经转换成静态的 Float32Array + // 所以不够用时需要扩展一个新的动态数组 + this._expandData(); + data = this.data; + } + for (var i = 0; i < arguments.length; i++) { + data[this._len++] = arguments[i]; + } + + this._prevCmd = cmd; + }, + + _expandData: function () { + // Only if data is Float32Array + if (!(this.data instanceof Array)) { + var newData = []; + for (var i = 0; i < this._len; i++) { + newData[i] = this.data[i]; + } + this.data = newData; + } + }, + + /** + * If needs js implemented dashed line + * @return {boolean} + * @private + */ + _needsDash: function () { + return this._lineDash; + }, + + _dashedLineTo: function (x1, y1) { + var dashSum = this._dashSum; + var offset = this._dashOffset; + var lineDash = this._lineDash; + var ctx = this._ctx; + + var x0 = this._xi; + var y0 = this._yi; + var dx = x1 - x0; + var dy = y1 - y0; + var dist = mathSqrt(dx * dx + dy * dy); + var x = x0; + var y = y0; + var dash; + var nDash = lineDash.length; + var idx; + dx /= dist; + dy /= dist; + + if (offset < 0) { + // Convert to positive offset + offset = dashSum + offset; + } + offset %= dashSum; + x -= offset * dx; + y -= offset * dy; + + while ((dx >= 0 && x <= x1) || (dx < 0 && x > x1)) { + idx = this._dashIdx; + dash = lineDash[idx]; + x += dx * dash; + y += dy * dash; + this._dashIdx = (idx + 1) % nDash; + // Skip positive offset + if ((dx > 0 && x < x0) || (dx < 0 && x > x0)) { + continue; + } + ctx[idx % 2 ? 'moveTo' : 'lineTo']( + dx >= 0 ? mathMin(x, x1) : mathMax(x, x1), + dy >= 0 ? mathMin(y, y1) : mathMax(y, y1) + ); + } + // Offset for next lineTo + dx = x - x1; + dy = y - y1; + this._dashOffset = -mathSqrt(dx * dx + dy * dy); + }, + + // Not accurate dashed line to + _dashedBezierTo: function (x1, y1, x2, y2, x3, y3) { + var dashSum = this._dashSum; + var offset = this._dashOffset; + var lineDash = this._lineDash; + var ctx = this._ctx; + + var x0 = this._xi; + var y0 = this._yi; + var t; + var dx; + var dy; + var cubicAt = curve.cubicAt; + var bezierLen = 0; + var idx = this._dashIdx; + var nDash = lineDash.length; + + var x; + var y; + + var tmpLen = 0; + + if (offset < 0) { + // Convert to positive offset + offset = dashSum + offset; + } + offset %= dashSum; + // Bezier approx length + for (t = 0; t < 1; t += 0.1) { + dx = cubicAt(x0, x1, x2, x3, t + 0.1) + - cubicAt(x0, x1, x2, x3, t); + dy = cubicAt(y0, y1, y2, y3, t + 0.1) + - cubicAt(y0, y1, y2, y3, t); + bezierLen += mathSqrt(dx * dx + dy * dy); + } + + // Find idx after add offset + for (; idx < nDash; idx++) { + tmpLen += lineDash[idx]; + if (tmpLen > offset) { + break; + } + } + t = (tmpLen - offset) / bezierLen; + + while (t <= 1) { + + x = cubicAt(x0, x1, x2, x3, t); + y = cubicAt(y0, y1, y2, y3, t); + + // Use line to approximate dashed bezier + // Bad result if dash is long + idx % 2 ? ctx.moveTo(x, y) + : ctx.lineTo(x, y); + + t += lineDash[idx] / bezierLen; + + idx = (idx + 1) % nDash; + } + + // Finish the last segment and calculate the new offset + (idx % 2 !== 0) && ctx.lineTo(x3, y3); + dx = x3 - x; + dy = y3 - y; + this._dashOffset = -mathSqrt(dx * dx + dy * dy); + }, + + _dashedQuadraticTo: function (x1, y1, x2, y2) { + // Convert quadratic to cubic using degree elevation + var x3 = x2; + var y3 = y2; + x2 = (x2 + 2 * x1) / 3; + y2 = (y2 + 2 * y1) / 3; + x1 = (this._xi + 2 * x1) / 3; + y1 = (this._yi + 2 * y1) / 3; + + this._dashedBezierTo(x1, y1, x2, y2, x3, y3); + }, + + /** + * 转成静态的 Float32Array 减少堆内存占用 + * Convert dynamic array to static Float32Array + */ + toStatic: function () { + var data = this.data; + if (data instanceof Array) { + data.length = this._len; + if (hasTypedArray) { + this.data = new Float32Array(data); + } + } + }, + + /** + * @return {module:zrender/core/BoundingRect} + */ + getBoundingRect: function () { + min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE; + max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE; + + var data = this.data; + var xi = 0; + var yi = 0; + var x0 = 0; + var y0 = 0; + + for (var i = 0; i < data.length;) { + var cmd = data[i++]; + + if (i == 1) { + // 如果第一个命令是 L, C, Q + // 则 previous point 同绘制命令的第一个 point + // + // 第一个命令为 Arc 的情况下会在后面特殊处理 + xi = data[i]; + yi = data[i + 1]; + + x0 = xi; + y0 = yi; + } + + switch (cmd) { + case CMD.M: + // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点 + // 在 closePath 的时候使用 + x0 = data[i++]; + y0 = data[i++]; + xi = x0; + yi = y0; + min2[0] = x0; + min2[1] = y0; + max2[0] = x0; + max2[1] = y0; + break; + case CMD.L: + bbox.fromLine(xi, yi, data[i], data[i + 1], min2, max2); + xi = data[i++]; + yi = data[i++]; + break; + case CMD.C: + bbox.fromCubic( + xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], + min2, max2 + ); + xi = data[i++]; + yi = data[i++]; + break; + case CMD.Q: + bbox.fromQuadratic( + xi, yi, data[i++], data[i++], data[i], data[i + 1], + min2, max2 + ); + xi = data[i++]; + yi = data[i++]; + break; + case CMD.A: + // TODO Arc 判断的开销比较大 + var cx = data[i++]; + var cy = data[i++]; + var rx = data[i++]; + var ry = data[i++]; + var startAngle = data[i++]; + var endAngle = data[i++] + startAngle; + // TODO Arc 旋转 + var psi = data[i++]; + var anticlockwise = 1 - data[i++]; + + if (i == 1) { + // 直接使用 arc 命令 + // 第一个命令起点还未定义 + x0 = mathCos(startAngle) * rx + cx; + y0 = mathSin(startAngle) * ry + cy; + } + + bbox.fromArc( + cx, cy, rx, ry, startAngle, endAngle, + anticlockwise, min2, max2 + ); + + xi = mathCos(endAngle) * rx + cx; + yi = mathSin(endAngle) * ry + cy; + break; + case CMD.R: + x0 = xi = data[i++]; + y0 = yi = data[i++]; + var width = data[i++]; + var height = data[i++]; + // Use fromLine + bbox.fromLine(x0, y0, x0 + width, y0 + height, min2, max2); + break; + case CMD.Z: + xi = x0; + yi = y0; + break; + } + + // Union + vec2.min(min, min, min2); + vec2.max(max, max, max2); + } + + // No data + if (i === 0) { + min[0] = min[1] = max[0] = max[1] = 0; + } + + return new BoundingRect( + min[0], min[1], max[0] - min[0], max[1] - min[1] + ); + }, + + /** + * Rebuild path from current data + * Rebuild path will not consider javascript implemented line dash. + * @param {CanvasRenderingContext} ctx + */ + rebuildPath: function (ctx) { + var d = this.data; + for (var i = 0; i < this._len;) { + var cmd = d[i++]; + switch (cmd) { + case CMD.M: + ctx.moveTo(d[i++], d[i++]); + break; + case CMD.L: + ctx.lineTo(d[i++], d[i++]); + break; + case CMD.C: + ctx.bezierCurveTo( + d[i++], d[i++], d[i++], d[i++], d[i++], d[i++] + ); + break; + case CMD.Q: + ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]); + break; + case CMD.A: + var cx = d[i++]; + var cy = d[i++]; + var rx = d[i++]; + var ry = d[i++]; + var theta = d[i++]; + var dTheta = d[i++]; + var psi = d[i++]; + var fs = d[i++]; + var r = (rx > ry) ? rx : ry; + var scaleX = (rx > ry) ? 1 : rx / ry; + var scaleY = (rx > ry) ? ry / rx : 1; + var isEllipse = Math.abs(rx - ry) > 1e-3; + if (isEllipse) { + ctx.translate(cx, cy); + ctx.rotate(psi); + ctx.scale(scaleX, scaleY); + ctx.arc(0, 0, r, theta, theta + dTheta, 1 - fs); + ctx.scale(1 / scaleX, 1 / scaleY); + ctx.rotate(-psi); + ctx.translate(-cx, -cy); + } + else { + ctx.arc(cx, cy, r, theta, theta + dTheta, 1 - fs); + } + break; + case CMD.R: + ctx.rect(d[i++], d[i++], d[i++], d[i++]); + break; + case CMD.Z: + ctx.closePath(); + } + } + } + }; + + PathProxy.CMD = CMD; + + module.exports = PathProxy; + + +/***/ }, +/* 49 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 曲线辅助模块 + * @module zrender/core/curve + * @author pissang(https://www.github.com/pissang) + */ + + + var vec2 = __webpack_require__(16); + var v2Create = vec2.create; + var v2DistSquare = vec2.distSquare; + var mathPow = Math.pow; + var mathSqrt = Math.sqrt; + + var EPSILON = 1e-4; + + var THREE_SQRT = mathSqrt(3); + var ONE_THIRD = 1 / 3; + + // 临时变量 + var _v0 = v2Create(); + var _v1 = v2Create(); + var _v2 = v2Create(); + // var _v3 = vec2.create(); + + function isAroundZero(val) { + return val > -EPSILON && val < EPSILON; + } + function isNotAroundZero(val) { + return val > EPSILON || val < -EPSILON; + } + /** + * 计算三次贝塞尔值 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @return {number} + */ + function cubicAt(p0, p1, p2, p3, t) { + var onet = 1 - t; + return onet * onet * (onet * p0 + 3 * t * p1) + + t * t * (t * p3 + 3 * onet * p2); + } + + /** + * 计算三次贝塞尔导数值 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @return {number} + */ + function cubicDerivativeAt(p0, p1, p2, p3, t) { + var onet = 1 - t; + return 3 * ( + ((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet + + (p3 - p2) * t * t + ); + } + + /** + * 计算三次贝塞尔方程根,使用盛金公式 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} val + * @param {Array.} roots + * @return {number} 有效根数目 + */ + function cubicRootAt(p0, p1, p2, p3, val, roots) { + // Evaluate roots of cubic functions + var a = p3 + 3 * (p1 - p2) - p0; + var b = 3 * (p2 - p1 * 2 + p0); + var c = 3 * (p1 - p0); + var d = p0 - val; + + var A = b * b - 3 * a * c; + var B = b * c - 9 * a * d; + var C = c * c - 3 * b * d; + + var n = 0; + + if (isAroundZero(A) && isAroundZero(B)) { + if (isAroundZero(b)) { + roots[0] = 0; + } + else { + var t1 = -c / b; //t1, t2, t3, b is not zero + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + } + } + else { + var disc = B * B - 4 * A * C; + + if (isAroundZero(disc)) { + var K = B / A; + var t1 = -b / a + K; // t1, a is not zero + var t2 = -K / 2; // t2, t3 + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + if (t2 >= 0 && t2 <= 1) { + roots[n++] = t2; + } + } + else if (disc > 0) { + var discSqrt = mathSqrt(disc); + var Y1 = A * b + 1.5 * a * (-B + discSqrt); + var Y2 = A * b + 1.5 * a * (-B - discSqrt); + if (Y1 < 0) { + Y1 = -mathPow(-Y1, ONE_THIRD); + } + else { + Y1 = mathPow(Y1, ONE_THIRD); + } + if (Y2 < 0) { + Y2 = -mathPow(-Y2, ONE_THIRD); + } + else { + Y2 = mathPow(Y2, ONE_THIRD); + } + var t1 = (-b - (Y1 + Y2)) / (3 * a); + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + } + else { + var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt(A * A * A)); + var theta = Math.acos(T) / 3; + var ASqrt = mathSqrt(A); + var tmp = Math.cos(theta); + + var t1 = (-b - 2 * ASqrt * tmp) / (3 * a); + var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a); + var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a); + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + if (t2 >= 0 && t2 <= 1) { + roots[n++] = t2; + } + if (t3 >= 0 && t3 <= 1) { + roots[n++] = t3; + } + } + } + return n; + } + + /** + * 计算三次贝塞尔方程极限值的位置 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {Array.} extrema + * @return {number} 有效数目 + */ + function cubicExtrema(p0, p1, p2, p3, extrema) { + var b = 6 * p2 - 12 * p1 + 6 * p0; + var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2; + var c = 3 * p1 - 3 * p0; + + var n = 0; + if (isAroundZero(a)) { + if (isNotAroundZero(b)) { + var t1 = -c / b; + if (t1 >= 0 && t1 <=1) { + extrema[n++] = t1; + } + } + } + else { + var disc = b * b - 4 * a * c; + if (isAroundZero(disc)) { + extrema[0] = -b / (2 * a); + } + else if (disc > 0) { + var discSqrt = mathSqrt(disc); + var t1 = (-b + discSqrt) / (2 * a); + var t2 = (-b - discSqrt) / (2 * a); + if (t1 >= 0 && t1 <= 1) { + extrema[n++] = t1; + } + if (t2 >= 0 && t2 <= 1) { + extrema[n++] = t2; + } + } + } + return n; + } + + /** + * 细分三次贝塞尔曲线 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @param {Array.} out + */ + function cubicSubdivide(p0, p1, p2, p3, t, out) { + var p01 = (p1 - p0) * t + p0; + var p12 = (p2 - p1) * t + p1; + var p23 = (p3 - p2) * t + p2; + + var p012 = (p12 - p01) * t + p01; + var p123 = (p23 - p12) * t + p12; + + var p0123 = (p123 - p012) * t + p012; + // Seg0 + out[0] = p0; + out[1] = p01; + out[2] = p012; + out[3] = p0123; + // Seg1 + out[4] = p0123; + out[5] = p123; + out[6] = p23; + out[7] = p3; + } + + /** + * 投射点到三次贝塞尔曲线上,返回投射距离。 + * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x3 + * @param {number} y3 + * @param {number} x + * @param {number} y + * @param {Array.} [out] 投射点 + * @return {number} + */ + function cubicProjectPoint( + x0, y0, x1, y1, x2, y2, x3, y3, + x, y, out + ) { + // http://pomax.github.io/bezierinfo/#projections + var t; + var interval = 0.005; + var d = Infinity; + var prev; + var next; + var d1; + var d2; + + _v0[0] = x; + _v0[1] = y; + + // 先粗略估计一下可能的最小距离的 t 值 + // PENDING + for (var _t = 0; _t < 1; _t += 0.05) { + _v1[0] = cubicAt(x0, x1, x2, x3, _t); + _v1[1] = cubicAt(y0, y1, y2, y3, _t); + d1 = v2DistSquare(_v0, _v1); + if (d1 < d) { + t = _t; + d = d1; + } + } + d = Infinity; + + // At most 32 iteration + for (var i = 0; i < 32; i++) { + if (interval < EPSILON) { + break; + } + prev = t - interval; + next = t + interval; + // t - interval + _v1[0] = cubicAt(x0, x1, x2, x3, prev); + _v1[1] = cubicAt(y0, y1, y2, y3, prev); + + d1 = v2DistSquare(_v1, _v0); + + if (prev >= 0 && d1 < d) { + t = prev; + d = d1; + } + else { + // t + interval + _v2[0] = cubicAt(x0, x1, x2, x3, next); + _v2[1] = cubicAt(y0, y1, y2, y3, next); + d2 = v2DistSquare(_v2, _v0); + + if (next <= 1 && d2 < d) { + t = next; + d = d2; + } + else { + interval *= 0.5; + } + } + } + // t + if (out) { + out[0] = cubicAt(x0, x1, x2, x3, t); + out[1] = cubicAt(y0, y1, y2, y3, t); + } + // console.log(interval, i); + return mathSqrt(d); + } + + /** + * 计算二次方贝塞尔值 + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} t + * @return {number} + */ + function quadraticAt(p0, p1, p2, t) { + var onet = 1 - t; + return onet * (onet * p0 + 2 * t * p1) + t * t * p2; + } + + /** + * 计算二次方贝塞尔导数值 + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} t + * @return {number} + */ + function quadraticDerivativeAt(p0, p1, p2, t) { + return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1)); + } + + /** + * 计算二次方贝塞尔方程根 + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} t + * @param {Array.} roots + * @return {number} 有效根数目 + */ + function quadraticRootAt(p0, p1, p2, val, roots) { + var a = p0 - 2 * p1 + p2; + var b = 2 * (p1 - p0); + var c = p0 - val; + + var n = 0; + if (isAroundZero(a)) { + if (isNotAroundZero(b)) { + var t1 = -c / b; + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + } + } + else { + var disc = b * b - 4 * a * c; + if (isAroundZero(disc)) { + var t1 = -b / (2 * a); + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + } + else if (disc > 0) { + var discSqrt = mathSqrt(disc); + var t1 = (-b + discSqrt) / (2 * a); + var t2 = (-b - discSqrt) / (2 * a); + if (t1 >= 0 && t1 <= 1) { + roots[n++] = t1; + } + if (t2 >= 0 && t2 <= 1) { + roots[n++] = t2; + } + } + } + return n; + } + + /** + * 计算二次贝塞尔方程极限值 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @return {number} + */ + function quadraticExtremum(p0, p1, p2) { + var divider = p0 + p2 - 2 * p1; + if (divider === 0) { + // p1 is center of p0 and p2 + return 0.5; + } + else { + return (p0 - p1) / divider; + } + } + + /** + * 细分二次贝塞尔曲线 + * @memberOf module:zrender/core/curve + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} t + * @param {Array.} out + */ + function quadraticSubdivide(p0, p1, p2, t, out) { + var p01 = (p1 - p0) * t + p0; + var p12 = (p2 - p1) * t + p1; + var p012 = (p12 - p01) * t + p01; + + // Seg0 + out[0] = p0; + out[1] = p01; + out[2] = p012; + + // Seg1 + out[3] = p012; + out[4] = p12; + out[5] = p2; + } + + /** + * 投射点到二次贝塞尔曲线上,返回投射距离。 + * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x + * @param {number} y + * @param {Array.} out 投射点 + * @return {number} + */ + function quadraticProjectPoint( + x0, y0, x1, y1, x2, y2, + x, y, out + ) { + // http://pomax.github.io/bezierinfo/#projections + var t; + var interval = 0.005; + var d = Infinity; + + _v0[0] = x; + _v0[1] = y; + + // 先粗略估计一下可能的最小距离的 t 值 + // PENDING + for (var _t = 0; _t < 1; _t += 0.05) { + _v1[0] = quadraticAt(x0, x1, x2, _t); + _v1[1] = quadraticAt(y0, y1, y2, _t); + var d1 = v2DistSquare(_v0, _v1); + if (d1 < d) { + t = _t; + d = d1; + } + } + d = Infinity; + + // At most 32 iteration + for (var i = 0; i < 32; i++) { + if (interval < EPSILON) { + break; + } + var prev = t - interval; + var next = t + interval; + // t - interval + _v1[0] = quadraticAt(x0, x1, x2, prev); + _v1[1] = quadraticAt(y0, y1, y2, prev); + + var d1 = v2DistSquare(_v1, _v0); + + if (prev >= 0 && d1 < d) { + t = prev; + d = d1; + } + else { + // t + interval + _v2[0] = quadraticAt(x0, x1, x2, next); + _v2[1] = quadraticAt(y0, y1, y2, next); + var d2 = v2DistSquare(_v2, _v0); + if (next <= 1 && d2 < d) { + t = next; + d = d2; + } + else { + interval *= 0.5; + } + } + } + // t + if (out) { + out[0] = quadraticAt(x0, x1, x2, t); + out[1] = quadraticAt(y0, y1, y2, t); + } + // console.log(interval, i); + return mathSqrt(d); + } + + module.exports = { + + cubicAt: cubicAt, + + cubicDerivativeAt: cubicDerivativeAt, + + cubicRootAt: cubicRootAt, + + cubicExtrema: cubicExtrema, + + cubicSubdivide: cubicSubdivide, + + cubicProjectPoint: cubicProjectPoint, + + quadraticAt: quadraticAt, + + quadraticDerivativeAt: quadraticDerivativeAt, + + quadraticRootAt: quadraticRootAt, + + quadraticExtremum: quadraticExtremum, + + quadraticSubdivide: quadraticSubdivide, + + quadraticProjectPoint: quadraticProjectPoint + }; + + +/***/ }, +/* 50 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @author Yi Shen(https://github.com/pissang) + */ + + + var vec2 = __webpack_require__(16); + var curve = __webpack_require__(49); + + var bbox = {}; + var mathMin = Math.min; + var mathMax = Math.max; + var mathSin = Math.sin; + var mathCos = Math.cos; + + var start = vec2.create(); + var end = vec2.create(); + var extremity = vec2.create(); + + var PI2 = Math.PI * 2; + /** + * 从顶点数组中计算出最小包围盒,写入`min`和`max`中 + * @module zrender/core/bbox + * @param {Array} points 顶点数组 + * @param {number} min + * @param {number} max + */ + bbox.fromPoints = function(points, min, max) { + if (points.length === 0) { + return; + } + var p = points[0]; + var left = p[0]; + var right = p[0]; + var top = p[1]; + var bottom = p[1]; + var i; + + for (i = 1; i < points.length; i++) { + p = points[i]; + left = mathMin(left, p[0]); + right = mathMax(right, p[0]); + top = mathMin(top, p[1]); + bottom = mathMax(bottom, p[1]); + } + + min[0] = left; + min[1] = top; + max[0] = right; + max[1] = bottom; + }; + + /** + * @memberOf module:zrender/core/bbox + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {Array.} min + * @param {Array.} max + */ + bbox.fromLine = function (x0, y0, x1, y1, min, max) { + min[0] = mathMin(x0, x1); + min[1] = mathMin(y0, y1); + max[0] = mathMax(x0, x1); + max[1] = mathMax(y0, y1); + }; + + /** + * 从三阶贝塞尔曲线(p0, p1, p2, p3)中计算出最小包围盒,写入`min`和`max`中 + * @memberOf module:zrender/core/bbox + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x3 + * @param {number} y3 + * @param {Array.} min + * @param {Array.} max + */ + bbox.fromCubic = function( + x0, y0, x1, y1, x2, y2, x3, y3, min, max + ) { + var xDim = []; + var yDim = []; + var cubicExtrema = curve.cubicExtrema; + var cubicAt = curve.cubicAt; + var left, right, top, bottom; + var i; + var n = cubicExtrema(x0, x1, x2, x3, xDim); + + for (i = 0; i < n; i++) { + xDim[i] = cubicAt(x0, x1, x2, x3, xDim[i]); + } + n = cubicExtrema(y0, y1, y2, y3, yDim); + for (i = 0; i < n; i++) { + yDim[i] = cubicAt(y0, y1, y2, y3, yDim[i]); + } + + xDim.push(x0, x3); + yDim.push(y0, y3); + + left = mathMin.apply(null, xDim); + right = mathMax.apply(null, xDim); + top = mathMin.apply(null, yDim); + bottom = mathMax.apply(null, yDim); + + min[0] = left; + min[1] = top; + max[0] = right; + max[1] = bottom; + }; + + /** + * 从二阶贝塞尔曲线(p0, p1, p2)中计算出最小包围盒,写入`min`和`max`中 + * @memberOf module:zrender/core/bbox + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {Array.} min + * @param {Array.} max + */ + bbox.fromQuadratic = function(x0, y0, x1, y1, x2, y2, min, max) { + var quadraticExtremum = curve.quadraticExtremum; + var quadraticAt = curve.quadraticAt; + // Find extremities, where derivative in x dim or y dim is zero + var tx = + mathMax( + mathMin(quadraticExtremum(x0, x1, x2), 1), 0 + ); + var ty = + mathMax( + mathMin(quadraticExtremum(y0, y1, y2), 1), 0 + ); + + var x = quadraticAt(x0, x1, x2, tx); + var y = quadraticAt(y0, y1, y2, ty); + + min[0] = mathMin(x0, x2, x); + min[1] = mathMin(y0, y2, y); + max[0] = mathMax(x0, x2, x); + max[1] = mathMax(y0, y2, y); + }; + + /** + * 从圆弧中计算出最小包围盒,写入`min`和`max`中 + * @method + * @memberOf module:zrender/core/bbox + * @param {number} x + * @param {number} y + * @param {number} rx + * @param {number} ry + * @param {number} startAngle + * @param {number} endAngle + * @param {number} anticlockwise + * @param {Array.} min + * @param {Array.} max + */ + bbox.fromArc = function ( + x, y, rx, ry, startAngle, endAngle, anticlockwise, min, max + ) { + var vec2Min = vec2.min; + var vec2Max = vec2.max; + + var diff = Math.abs(startAngle - endAngle); + + + if (diff % PI2 < 1e-4 && diff > 1e-4) { + // Is a circle + min[0] = x - rx; + min[1] = y - ry; + max[0] = x + rx; + max[1] = y + ry; + return; + } + + start[0] = mathCos(startAngle) * rx + x; + start[1] = mathSin(startAngle) * ry + y; + + end[0] = mathCos(endAngle) * rx + x; + end[1] = mathSin(endAngle) * ry + y; + + vec2Min(min, start, end); + vec2Max(max, start, end); + + // Thresh to [0, Math.PI * 2] + startAngle = startAngle % (PI2); + if (startAngle < 0) { + startAngle = startAngle + PI2; + } + endAngle = endAngle % (PI2); + if (endAngle < 0) { + endAngle = endAngle + PI2; + } + + if (startAngle > endAngle && !anticlockwise) { + endAngle += PI2; + } + else if (startAngle < endAngle && anticlockwise) { + startAngle += PI2; + } + if (anticlockwise) { + var tmp = endAngle; + endAngle = startAngle; + startAngle = tmp; + } + + // var number = 0; + // var step = (anticlockwise ? -Math.PI : Math.PI) / 2; + for (var angle = 0; angle < endAngle; angle += Math.PI / 2) { + if (angle > startAngle) { + extremity[0] = mathCos(angle) * rx + x; + extremity[1] = mathSin(angle) * ry + y; + + vec2Min(min, extremity, min); + vec2Max(max, extremity, max); + } + } + }; + + module.exports = bbox; + + + +/***/ }, +/* 51 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var CMD = __webpack_require__(48).CMD; + var line = __webpack_require__(52); + var cubic = __webpack_require__(53); + var quadratic = __webpack_require__(54); + var arc = __webpack_require__(55); + var normalizeRadian = __webpack_require__(56).normalizeRadian; + var curve = __webpack_require__(49); + + var windingLine = __webpack_require__(57); + + var containStroke = line.containStroke; + + var PI2 = Math.PI * 2; + + var EPSILON = 1e-4; + + function isAroundEqual(a, b) { + return Math.abs(a - b) < EPSILON; + } + + // 临时数组 + var roots = [-1, -1, -1]; + var extrema = [-1, -1]; + + function swapExtrema() { + var tmp = extrema[0]; + extrema[0] = extrema[1]; + extrema[1] = tmp; + } + + function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) { + // Quick reject + if ( + (y > y0 && y > y1 && y > y2 && y > y3) + || (y < y0 && y < y1 && y < y2 && y < y3) + ) { + return 0; + } + var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots); + if (nRoots === 0) { + return 0; + } + else { + var w = 0; + var nExtrema = -1; + var y0_, y1_; + for (var i = 0; i < nRoots; i++) { + var t = roots[i]; + var x_ = curve.cubicAt(x0, x1, x2, x3, t); + if (x_ < x) { // Quick reject + continue; + } + if (nExtrema < 0) { + nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema); + if (extrema[1] < extrema[0] && nExtrema > 1) { + swapExtrema(); + } + y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]); + if (nExtrema > 1) { + y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]); + } + } + if (nExtrema == 2) { + // 分成三段单调函数 + if (t < extrema[0]) { + w += y0_ < y0 ? 1 : -1; + } + else if (t < extrema[1]) { + w += y1_ < y0_ ? 1 : -1; + } + else { + w += y3 < y1_ ? 1 : -1; + } + } + else { + // 分成两段单调函数 + if (t < extrema[0]) { + w += y0_ < y0 ? 1 : -1; + } + else { + w += y3 < y0_ ? 1 : -1; + } + } + } + return w; + } + } + + function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) { + // Quick reject + if ( + (y > y0 && y > y1 && y > y2) + || (y < y0 && y < y1 && y < y2) + ) { + return 0; + } + var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots); + if (nRoots === 0) { + return 0; + } + else { + var t = curve.quadraticExtremum(y0, y1, y2); + if (t >=0 && t <= 1) { + var w = 0; + var y_ = curve.quadraticAt(y0, y1, y2, t); + for (var i = 0; i < nRoots; i++) { + var x_ = curve.quadraticAt(x0, x1, x2, roots[i]); + if (x_ > x) { + continue; + } + if (roots[i] < t) { + w += y_ < y0 ? 1 : -1; + } + else { + w += y2 < y_ ? 1 : -1; + } + } + return w; + } + else { + var x_ = curve.quadraticAt(x0, x1, x2, roots[0]); + if (x_ > x) { + return 0; + } + return y2 < y0 ? 1 : -1; + } + } + } + + // TODO + // Arc 旋转 + function windingArc( + cx, cy, r, startAngle, endAngle, anticlockwise, x, y + ) { + y -= cy; + if (y > r || y < -r) { + return 0; + } + var tmp = Math.sqrt(r * r - y * y); + roots[0] = -tmp; + roots[1] = tmp; + + var diff = Math.abs(startAngle - endAngle); + if (diff < 1e-4) { + return 0; + } + if (diff % PI2 < 1e-4) { + // Is a circle + startAngle = 0; + endAngle = PI2; + var dir = anticlockwise ? 1 : -1; + if (x >= roots[0] + cx && x <= roots[1] + cx) { + return dir; + } else { + return 0; + } + } + + if (anticlockwise) { + var tmp = startAngle; + startAngle = normalizeRadian(endAngle); + endAngle = normalizeRadian(tmp); + } + else { + startAngle = normalizeRadian(startAngle); + endAngle = normalizeRadian(endAngle); + } + if (startAngle > endAngle) { + endAngle += PI2; + } + + var w = 0; + for (var i = 0; i < 2; i++) { + var x_ = roots[i]; + if (x_ + cx > x) { + var angle = Math.atan2(y, x_); + var dir = anticlockwise ? 1 : -1; + if (angle < 0) { + angle = PI2 + angle; + } + if ( + (angle >= startAngle && angle <= endAngle) + || (angle + PI2 >= startAngle && angle + PI2 <= endAngle) + ) { + if (angle > Math.PI / 2 && angle < Math.PI * 1.5) { + dir = -dir; + } + w += dir; + } + } + } + return w; + } + + function containPath(data, lineWidth, isStroke, x, y) { + var w = 0; + var xi = 0; + var yi = 0; + var x0 = 0; + var y0 = 0; + + for (var i = 0; i < data.length;) { + var cmd = data[i++]; + // Begin a new subpath + if (cmd === CMD.M && i > 1) { + // Close previous subpath + if (!isStroke) { + w += windingLine(xi, yi, x0, y0, x, y); + } + // 如果被任何一个 subpath 包含 + if (w !== 0) { + return true; + } + } + + if (i == 1) { + // 如果第一个命令是 L, C, Q + // 则 previous point 同绘制命令的第一个 point + // + // 第一个命令为 Arc 的情况下会在后面特殊处理 + xi = data[i]; + yi = data[i + 1]; + + x0 = xi; + y0 = yi; + } + + switch (cmd) { + case CMD.M: + // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点 + // 在 closePath 的时候使用 + x0 = data[i++]; + y0 = data[i++]; + xi = x0; + yi = y0; + break; + case CMD.L: + if (isStroke) { + if (containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) { + return true; + } + } + else { + // NOTE 在第一个命令为 L, C, Q 的时候会计算出 NaN + w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0; + } + xi = data[i++]; + yi = data[i++]; + break; + case CMD.C: + if (isStroke) { + if (cubic.containStroke(xi, yi, + data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], + lineWidth, x, y + )) { + return true; + } + } + else { + w += windingCubic( + xi, yi, + data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], + x, y + ) || 0; + } + xi = data[i++]; + yi = data[i++]; + break; + case CMD.Q: + if (isStroke) { + if (quadratic.containStroke(xi, yi, + data[i++], data[i++], data[i], data[i + 1], + lineWidth, x, y + )) { + return true; + } + } + else { + w += windingQuadratic( + xi, yi, + data[i++], data[i++], data[i], data[i + 1], + x, y + ) || 0; + } + xi = data[i++]; + yi = data[i++]; + break; + case CMD.A: + // TODO Arc 判断的开销比较大 + var cx = data[i++]; + var cy = data[i++]; + var rx = data[i++]; + var ry = data[i++]; + var theta = data[i++]; + var dTheta = data[i++]; + // TODO Arc 旋转 + var psi = data[i++]; + var anticlockwise = 1 - data[i++]; + var x1 = Math.cos(theta) * rx + cx; + var y1 = Math.sin(theta) * ry + cy; + // 不是直接使用 arc 命令 + if (i > 1) { + w += windingLine(xi, yi, x1, y1, x, y); + } + else { + // 第一个命令起点还未定义 + x0 = x1; + y0 = y1; + } + // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放 + var _x = (x - cx) * ry / rx + cx; + if (isStroke) { + if (arc.containStroke( + cx, cy, ry, theta, theta + dTheta, anticlockwise, + lineWidth, _x, y + )) { + return true; + } + } + else { + w += windingArc( + cx, cy, ry, theta, theta + dTheta, anticlockwise, + _x, y + ); + } + xi = Math.cos(theta + dTheta) * rx + cx; + yi = Math.sin(theta + dTheta) * ry + cy; + break; + case CMD.R: + x0 = xi = data[i++]; + y0 = yi = data[i++]; + var width = data[i++]; + var height = data[i++]; + var x1 = x0 + width; + var y1 = y0 + height; + if (isStroke) { + if (containStroke(x0, y0, x1, y0, lineWidth, x, y) + || containStroke(x1, y0, x1, y1, lineWidth, x, y) + || containStroke(x1, y1, x0, y1, lineWidth, x, y) + || containStroke(x0, y1, x1, y1, lineWidth, x, y) + ) { + return true; + } + } + else { + // FIXME Clockwise ? + w += windingLine(x1, y0, x1, y1, x, y); + w += windingLine(x0, y1, x0, y0, x, y); + } + break; + case CMD.Z: + if (isStroke) { + if (containStroke( + xi, yi, x0, y0, lineWidth, x, y + )) { + return true; + } + } + else { + // Close a subpath + w += windingLine(xi, yi, x0, y0, x, y); + // 如果被任何一个 subpath 包含 + if (w !== 0) { + return true; + } + } + xi = x0; + yi = y0; + break; + } + } + if (!isStroke && !isAroundEqual(yi, y0)) { + w += windingLine(xi, yi, x0, y0, x, y) || 0; + } + return w !== 0; + } + + module.exports = { + contain: function (pathData, x, y) { + return containPath(pathData, 0, false, x, y); + }, + + containStroke: function (pathData, lineWidth, x, y) { + return containPath(pathData, lineWidth, true, x, y); + } + }; + + +/***/ }, +/* 52 */ +/***/ function(module, exports) { + + + module.exports = { + /** + * 线段包含判断 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} lineWidth + * @param {number} x + * @param {number} y + * @return {boolean} + */ + containStroke: function (x0, y0, x1, y1, lineWidth, x, y) { + if (lineWidth === 0) { + return false; + } + var _l = lineWidth; + var _a = 0; + var _b = x0; + // Quick reject + 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) + ) { + return false; + } + + if (x0 !== x1) { + _a = (y0 - y1) / (x0 - x1); + _b = (x0 * y1 - x1 * y0) / (x0 - x1) ; + } + else { + return Math.abs(x - x0) <= _l / 2; + } + var tmp = _a * x - y + _b; + var _s = tmp * tmp / (_a * _a + 1); + return _s <= _l / 2 * _l / 2; + } + }; + + +/***/ }, +/* 53 */ +/***/ function(module, exports, __webpack_require__) { + + + + var curve = __webpack_require__(49); + + module.exports = { + /** + * 三次贝塞尔曲线描边包含判断 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} x3 + * @param {number} y3 + * @param {number} lineWidth + * @param {number} x + * @param {number} y + * @return {boolean} + */ + containStroke: function(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) { + if (lineWidth === 0) { + return false; + } + var _l = lineWidth; + // Quick reject + 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) + ) { + return false; + } + var d = curve.cubicProjectPoint( + x0, y0, x1, y1, x2, y2, x3, y3, + x, y, null + ); + return d <= _l / 2; + } + }; + + +/***/ }, +/* 54 */ +/***/ function(module, exports, __webpack_require__) { + + + + var curve = __webpack_require__(49); + + module.exports = { + /** + * 二次贝塞尔曲线描边包含判断 + * @param {number} x0 + * @param {number} y0 + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} lineWidth + * @param {number} x + * @param {number} y + * @return {boolean} + */ + containStroke: function (x0, y0, x1, y1, x2, y2, lineWidth, x, y) { + if (lineWidth === 0) { + return false; + } + var _l = lineWidth; + // Quick reject + 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) + ) { + return false; + } + var d = curve.quadraticProjectPoint( + x0, y0, x1, y1, x2, y2, + x, y, null + ); + return d <= _l / 2; + } + }; + + +/***/ }, +/* 55 */ +/***/ function(module, exports, __webpack_require__) { + + + + var normalizeRadian = __webpack_require__(56).normalizeRadian; + var PI2 = Math.PI * 2; + + module.exports = { + /** + * 圆弧描边包含判断 + * @param {number} cx + * @param {number} cy + * @param {number} r + * @param {number} startAngle + * @param {number} endAngle + * @param {boolean} anticlockwise + * @param {number} lineWidth + * @param {number} x + * @param {number} y + * @return {Boolean} + */ + containStroke: function ( + cx, cy, r, startAngle, endAngle, anticlockwise, + lineWidth, x, y + ) { + + if (lineWidth === 0) { + return false; + } + var _l = lineWidth; + + x -= cx; + y -= cy; + var d = Math.sqrt(x * x + y * y); + + if ((d - _l > r) || (d + _l < r)) { + return false; + } + if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) { + // Is a circle + return true; + } + if (anticlockwise) { + var tmp = startAngle; + startAngle = normalizeRadian(endAngle); + endAngle = normalizeRadian(tmp); + } else { + startAngle = normalizeRadian(startAngle); + endAngle = normalizeRadian(endAngle); + } + if (startAngle > endAngle) { + endAngle += PI2; + } + + var angle = Math.atan2(y, x); + if (angle < 0) { + angle += PI2; + } + return (angle >= startAngle && angle <= endAngle) + || (angle + PI2 >= startAngle && angle + PI2 <= endAngle); + } + }; + + +/***/ }, +/* 56 */ +/***/ function(module, exports) { + + + + var PI2 = Math.PI * 2; + module.exports = { + normalizeRadian: function(angle) { + angle %= PI2; + if (angle < 0) { + angle += PI2; + } + return angle; + } + }; + + +/***/ }, +/* 57 */ +/***/ function(module, exports) { + + + module.exports = function windingLine(x0, y0, x1, y1, x, y) { + if ((y > y0 && y > y1) || (y < y0 && y < y1)) { + return 0; + } + if (y1 === y0) { + return 0; + } + var dir = y1 < y0 ? 1 : -1; + var t = (y - y0) / (y1 - y0); + var x_ = t * (x1 - x0) + x0; + + return x_ > x ? dir : 0; + }; + + +/***/ }, +/* 58 */ +/***/ function(module, exports, __webpack_require__) { + + + + var CMD = __webpack_require__(48).CMD; + var vec2 = __webpack_require__(16); + var v2ApplyTransform = vec2.applyTransform; + + var points = [[], [], []]; + var mathSqrt = Math.sqrt; + var mathAtan2 = Math.atan2; + function transformPath(path, m) { + var data = path.data; + var cmd; + var nPoint; + var i; + var j; + var k; + var p; + + var M = CMD.M; + var C = CMD.C; + var L = CMD.L; + var R = CMD.R; + var A = CMD.A; + var Q = CMD.Q; + + for (i = 0, j = 0; i < data.length;) { + cmd = data[i++]; + j = i; + nPoint = 0; + + switch (cmd) { + case M: + nPoint = 1; + break; + case L: + nPoint = 1; + break; + case C: + nPoint = 3; + break; + case Q: + nPoint = 2; + break; + case A: + var x = m[4]; + var y = m[5]; + var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]); + var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]); + var angle = mathAtan2(-m[1] / sy, m[0] / sx); + // cx + data[i++] += x; + // cy + data[i++] += y; + // Scale rx and ry + // FIXME Assume psi is 0 here + data[i++] *= sx; + data[i++] *= sy; + + // Start angle + data[i++] += angle; + // end angle + data[i++] += angle; + // FIXME psi + i += 2; + j = i; + break; + case R: + // x0, y0 + p[0] = data[i++]; + p[1] = data[i++]; + v2ApplyTransform(p, p, m); + data[j++] = p[0]; + data[j++] = p[1]; + // x1, y1 + p[0] += data[i++]; + p[1] += data[i++]; + v2ApplyTransform(p, p, m); + data[j++] = p[0]; + data[j++] = p[1]; + } + + for (k = 0; k < nPoint; k++) { + var p = points[k]; + p[0] = data[i++]; + p[1] = data[i++]; + + v2ApplyTransform(p, p, m); + // Write back + data[j++] = p[0]; + data[j++] = p[1]; + } + } + } + + module.exports = transformPath; + + +/***/ }, +/* 59 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Image element + * @module zrender/graphic/Image + */ + + + + var Displayable = __webpack_require__(45); + var BoundingRect = __webpack_require__(15); + var zrUtil = __webpack_require__(3); + var roundRectHelper = __webpack_require__(60); + + var LRU = __webpack_require__(61); + var globalImageCache = new LRU(50); + /** + * @alias zrender/graphic/Image + * @extends module:zrender/graphic/Displayable + * @constructor + * @param {Object} opts + */ + var ZImage = function (opts) { + Displayable.call(this, opts); + }; + + ZImage.prototype = { + + constructor: ZImage, + + type: 'image', + + brush: function (ctx) { + var style = this.style; + var src = style.image; + var image; + // style.image is a url string + if (typeof src === 'string') { + image = this._image; + } + // style.image is an HTMLImageElement or HTMLCanvasElement or Canvas + else { + image = src; + } + // FIXME Case create many images with src + if (!image && src) { + // Try get from global image cache + var cachedImgObj = globalImageCache.get(src); + if (!cachedImgObj) { + // Create a new image + image = new Image(); + image.onload = function () { + image.onload = null; + for (var i = 0; i < cachedImgObj.pending.length; i++) { + cachedImgObj.pending[i].dirty(); + } + }; + cachedImgObj = { + image: image, + pending: [this] + }; + image.src = src; + globalImageCache.put(src, cachedImgObj); + this._image = image; + return; + } + else { + image = cachedImgObj.image; + this._image = image; + // Image is not complete finish, add to pending list + if (!image.width || !image.height) { + cachedImgObj.pending.push(this); + return; + } + } + } + + if (image) { + // 图片已经加载完成 + // if (image.nodeName.toUpperCase() == 'IMG') { + // if (!image.complete) { + // return; + // } + // } + // Else is canvas + + var width = style.width || image.width; + var height = style.height || image.height; + var x = style.x || 0; + var y = style.y || 0; + // 图片加载失败 + if (!image.width || !image.height) { + return; + } + + ctx.save(); + + style.bind(ctx); + + // 设置transform + this.setTransform(ctx); + + if (style.r) { + // Border radius clipping + // FIXME + ctx.beginPath(); + roundRectHelper.buildPath(ctx, style); + ctx.clip(); + } + + if (style.sWidth && style.sHeight) { + var sx = style.sx || 0; + var sy = style.sy || 0; + ctx.drawImage( + image, + sx, sy, style.sWidth, style.sHeight, + x, y, width, height + ); + } + else if (style.sx && style.sy) { + var sx = style.sx; + var sy = style.sy; + var sWidth = width - sx; + var sHeight = height - sy; + ctx.drawImage( + image, + sx, sy, sWidth, sHeight, + x, y, width, height + ); + } + else { + ctx.drawImage(image, x, y, width, height); + } + + // 如果没设置宽和高的话自动根据图片宽高设置 + if (style.width == null) { + style.width = width; + } + if (style.height == null) { + style.height = height; + } + + // Draw rect text + if (style.text != null) { + this.drawRectText(ctx, this.getBoundingRect()); + } + + ctx.restore(); + } + }, + + getBoundingRect: function () { + var style = this.style; + if (! this._rect) { + this._rect = new BoundingRect( + style.x || 0, style.y || 0, style.width || 0, style.height || 0 + ); + } + return this._rect; + } + }; + + zrUtil.inherits(ZImage, Displayable); + + module.exports = ZImage; + + +/***/ }, +/* 60 */ +/***/ function(module, exports) { + + + + module.exports = { + buildPath: function (ctx, shape) { + var x = shape.x; + var y = shape.y; + var width = shape.width; + var height = shape.height; + var r = shape.r; + var r1; + var r2; + var r3; + var r4; + + // Convert width and height to positive for better borderRadius + if (width < 0) { + x = x + width; + width = -width; + } + if (height < 0) { + y = y + height; + height = -height; + } + + if (typeof r === 'number') { + r1 = r2 = r3 = r4 = r; + } + else if (r instanceof Array) { + if (r.length === 1) { + r1 = r2 = r3 = r4 = r[0]; + } + else if (r.length === 2) { + r1 = r3 = r[0]; + r2 = r4 = r[1]; + } + else if (r.length === 3) { + r1 = r[0]; + r2 = r4 = r[1]; + r3 = r[2]; + } + else { + r1 = r[0]; + r2 = r[1]; + r3 = r[2]; + r4 = r[3]; + } + } + else { + r1 = r2 = r3 = r4 = 0; + } + + var total; + if (r1 + r2 > width) { + total = r1 + r2; + r1 *= width / total; + r2 *= width / total; + } + if (r3 + r4 > width) { + total = r3 + r4; + r3 *= width / total; + r4 *= width / total; + } + if (r2 + r3 > height) { + total = r2 + r3; + r2 *= height / total; + r3 *= height / total; + } + if (r1 + r4 > height) { + total = r1 + r4; + r1 *= height / total; + r4 *= height / total; + } + ctx.moveTo(x + r1, y); + ctx.lineTo(x + width - r2, y); + r2 !== 0 && ctx.quadraticCurveTo( + x + width, y, x + width, y + r2 + ); + ctx.lineTo(x + width, y + height - r3); + r3 !== 0 && ctx.quadraticCurveTo( + x + width, y + height, x + width - r3, y + height + ); + ctx.lineTo(x + r4, y + height); + r4 !== 0 && ctx.quadraticCurveTo( + x, y + height, x, y + height - r4 + ); + ctx.lineTo(x, y + r1); + r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y); + } + }; + + +/***/ }, +/* 61 */ +/***/ function(module, exports) { + + // Simple LRU cache use doubly linked list + // @module zrender/core/LRU + + + /** + * Simple double linked list. Compared with array, it has O(1) remove operation. + * @constructor + */ + var LinkedList = function() { + + /** + * @type {module:zrender/core/LRU~Entry} + */ + this.head = null; + + /** + * @type {module:zrender/core/LRU~Entry} + */ + this.tail = null; + + this._len = 0; + }; + + var linkedListProto = LinkedList.prototype; + /** + * Insert a new value at the tail + * @param {} val + * @return {module:zrender/core/LRU~Entry} + */ + linkedListProto.insert = function(val) { + var entry = new Entry(val); + this.insertEntry(entry); + return entry; + }; + + /** + * Insert an entry at the tail + * @param {module:zrender/core/LRU~Entry} entry + */ + linkedListProto.insertEntry = function(entry) { + if (!this.head) { + this.head = this.tail = entry; + } + else { + this.tail.next = entry; + entry.prev = this.tail; + this.tail = entry; + } + this._len++; + }; + + /** + * Remove entry. + * @param {module:zrender/core/LRU~Entry} entry + */ + linkedListProto.remove = function(entry) { + var prev = entry.prev; + var next = entry.next; + if (prev) { + prev.next = next; + } + else { + // Is head + this.head = next; + } + if (next) { + next.prev = prev; + } + else { + // Is tail + this.tail = prev; + } + entry.next = entry.prev = null; + this._len--; + }; + + /** + * @return {number} + */ + linkedListProto.len = function() { + return this._len; + }; + + /** + * @constructor + * @param {} val + */ + var Entry = function(val) { + /** + * @type {} + */ + this.value = val; + + /** + * @type {module:zrender/core/LRU~Entry} + */ + this.next; + + /** + * @type {module:zrender/core/LRU~Entry} + */ + this.prev; + }; + + /** + * LRU Cache + * @constructor + * @alias module:zrender/core/LRU + */ + var LRU = function(maxSize) { + + this._list = new LinkedList(); + + this._map = {}; + + this._maxSize = maxSize || 10; + }; + + var LRUProto = LRU.prototype; + + /** + * @param {string} key + * @param {} value + */ + LRUProto.put = function(key, value) { + var list = this._list; + var map = this._map; + if (map[key] == null) { + var len = list.len(); + if (len >= this._maxSize && len > 0) { + // Remove the least recently used + var leastUsedEntry = list.head; + list.remove(leastUsedEntry); + delete map[leastUsedEntry.key]; + } + + var entry = list.insert(value); + entry.key = key; + map[key] = entry; + } + }; + + /** + * @param {string} key + * @return {} + */ + LRUProto.get = function(key) { + var entry = this._map[key]; + var list = this._list; + if (entry != null) { + // Put the latest used entry in the tail + if (entry !== list.tail) { + list.remove(entry); + list.insertEntry(entry); + } + + return entry.value; + } + }; + + /** + * Clear the cache + */ + LRUProto.clear = function() { + this._list.clear(); + this._map = {}; + }; + + module.exports = LRU; + + +/***/ }, +/* 62 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Text element + * @module zrender/graphic/Text + * + * TODO Wrapping + */ + + + + var Displayable = __webpack_require__(45); + var zrUtil = __webpack_require__(3); + var textContain = __webpack_require__(14); + + /** + * @alias zrender/graphic/Text + * @extends module:zrender/graphic/Displayable + * @constructor + * @param {Object} opts + */ + var Text = function (opts) { + Displayable.call(this, opts); + }; + + Text.prototype = { + + constructor: Text, + + type: 'text', + + brush: function (ctx) { + var style = this.style; + var x = style.x || 0; + var y = style.y || 0; + // Convert to string + var text = style.text; + var textFill = style.fill; + var textStroke = style.stroke; + + // Convert to string + text != null && (text += ''); + + if (text) { + ctx.save(); + + this.style.bind(ctx); + this.setTransform(ctx); + + textFill && (ctx.fillStyle = textFill); + textStroke && (ctx.strokeStyle = textStroke); + + ctx.font = style.textFont || style.font; + ctx.textAlign = style.textAlign; + + if (style.textVerticalAlign) { + var rect = textContain.getBoundingRect( + text, ctx.font, style.textAlign, 'top' + ); + // Ignore textBaseline + ctx.textBaseline = 'top'; + switch (style.textVerticalAlign) { + case 'middle': + y -= rect.height / 2; + break; + case 'bottom': + y -= rect.height; + break; + // 'top' + } + } + else { + ctx.textBaseline = style.textBaseline; + } + var lineHeight = textContain.measureText('国', ctx.font).width; -/** - * 数值处理模块 - * @module echarts/util/number - */ - -define('echarts/util/number',['require'],function (require) { - - var number = {}; - - var RADIAN_EPSILON = 1e-4; - - function _trim(str) { - return str.replace(/^\s+/, '').replace(/\s+$/, ''); - } - - /** - * Linear mapping a value from domain to range - * @memberOf module:echarts/util/number - * @param {(number|Array.)} val - * @param {Array.} domain Domain extent domain[0] can be bigger than domain[1] - * @param {Array.} range Range extent range[0] can be bigger than range[1] - * @param {boolean} clamp - * @return {(number|Array.} - */ - number.linearMap = function (val, domain, range, clamp) { - - var sub = domain[1] - domain[0]; - - if (sub === 0) { - return (range[0] + range[1]) / 2; - } - var t = (val - domain[0]) / sub; - - if (clamp) { - t = Math.min(Math.max(t, 0), 1); - } - - return t * (range[1] - range[0]) + range[0]; - }; - - /** - * Convert a percent string to absolute number. - * Returns NaN if percent is not a valid string or number - * @memberOf module:echarts/util/number - * @param {string|number} percent - * @param {number} all - * @return {number} - */ - number.parsePercent = function(percent, all) { - switch (percent) { - case 'center': - case 'middle': - percent = '50%'; - break; - case 'left': - case 'top': - percent = '0%'; - break; - case 'right': - case 'bottom': - percent = '100%'; - break; - } - if (typeof percent === 'string') { - if (_trim(percent).match(/%$/)) { - return parseFloat(percent) / 100 * all; - } - - return parseFloat(percent); - } - - return percent == null ? NaN : +percent; - }; - - /** - * Fix rounding error of float numbers - * @param {number} x - * @return {number} - */ - number.round = function (x) { - // PENDING - return +(+x).toFixed(12); - }; - - number.asc = function (arr) { - arr.sort(function (a, b) { - return a - b; - }); - return arr; - }; - - /** - * Get precision - * @param {number} val - */ - number.getPrecision = function (val) { - // It is much faster than methods converting number to string as follows - // var tmp = val.toString(); - // return tmp.length - 1 - tmp.indexOf('.'); - // especially when precision is low - var e = 1; - var count = 0; - while (Math.round(val * e) / e !== val) { - e *= 10; - count++; - } - return count; - }; - - /** - * @param {Array.} dataExtent - * @param {Array.} pixelExtent - * @return {number} precision - */ - number.getPixelPrecision = function (dataExtent, pixelExtent) { - var log = Math.log; - var LN10 = Math.LN10; - var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10); - var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10); - return Math.max( - -dataQuantity + sizeQuantity, - 0 - ); - }; - - // Number.MAX_SAFE_INTEGER, ie do not support. - number.MAX_SAFE_INTEGER = 9007199254740991; - - /** - * To 0 - 2 * PI, considering negative radian. - * @param {number} radian - * @return {number} - */ - number.remRadian = function (radian) { - var pi2 = Math.PI * 2; - return (radian % pi2 + pi2) % pi2; - }; - - /** - * @param {type} radian - * @return {boolean} - */ - number.isRadianAroundZero = function (val) { - return val > -RADIAN_EPSILON && val < RADIAN_EPSILON; - }; - - /** - * @param {string|Date|number} value - * @return {number} timestamp - */ - number.parseDate = function (value) { - return value instanceof Date - ? value - : new Date( - typeof value === 'string' - ? value.replace(/-/g, '/') - : Math.round(value) - ); - }; - - return number; -}); -define('echarts/util/format',['require','zrender/core/util','./number'],function (require) { - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('./number'); - - /** - * 每三位默认加,格式化 - * @type {string|number} x - */ - function addCommas(x) { - if (isNaN(x)) { - return '-'; - } - x = (x + '').split('.'); - return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,'$1,') - + (x.length > 1 ? ('.' + x[1]) : ''); - } - - /** - * @param {string} str - * @return {string} str - */ - function toCamelCase(str) { - return str.toLowerCase().replace(/-(.)/g, function(match, group1) { - return group1.toUpperCase(); - }); - } - - /** - * Normalize css liked array configuration - * e.g. - * 3 => [3, 3, 3, 3] - * [4, 2] => [4, 2, 4, 2] - * [4, 3, 2] => [4, 3, 2, 3] - * @param {number|Array.} val - */ - function normalizeCssArray(val) { - var len = val.length; - if (typeof (val) === 'number') { - return [val, val, val, val]; - } - else if (len === 2) { - // vertical | horizontal - return [val[0], val[1], val[0], val[1]]; - } - else if (len === 3) { - // top | horizontal | bottom - return [val[0], val[1], val[2], val[1]]; - } - return val; - } - - function encodeHTML(source) { - return String(source) - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - } - - var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g']; - - function wrapVar(varName, seriesIdx) { - return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}'; - } - /** - * Template formatter - * @param {string} tpl - * @param {Array.|Object} paramsList - * @return {string} - */ - function formatTpl(tpl, paramsList) { - if (!zrUtil.isArray(paramsList)) { - paramsList = [paramsList]; - } - var seriesLen = paramsList.length; - if (!seriesLen) { - return ''; - } - - var $vars = paramsList[0].$vars; - for (var i = 0; i < $vars.length; i++) { - var alias = TPL_VAR_ALIAS[i]; - tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0)); - } - for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) { - for (var k = 0; k < $vars.length; k++) { - tpl = tpl.replace( - wrapVar(TPL_VAR_ALIAS[k], seriesIdx), - paramsList[seriesIdx][$vars[k]] - ); - } - } - - return tpl; - } - - /** - * ISO Date format - * @param {string} tpl - * @param {number} value - * @inner - */ - function formatTime(tpl, value) { - if (tpl === 'week' - || tpl === 'month' - || tpl === 'quarter' - || tpl === 'half-year' - || tpl === 'year' - ) { - tpl = 'MM-dd\nyyyy'; - } - - var date = numberUtil.parseDate(value); - var y = date.getFullYear(); - var M = date.getMonth() + 1; - var d = date.getDate(); - var h = date.getHours(); - var m = date.getMinutes(); - var s = date.getSeconds(); - - tpl = tpl.replace('MM', s2d(M)) - .toLowerCase() - .replace('yyyy', y) - .replace('yy', y % 100) - .replace('dd', s2d(d)) - .replace('d', d) - .replace('hh', s2d(h)) - .replace('h', h) - .replace('mm', s2d(m)) - .replace('m', m) - .replace('ss', s2d(s)) - .replace('s', s); - - return tpl; - } - - /** - * @param {string} str - * @return {string} - * @inner - */ - function s2d(str) { - return str < 10 ? ('0' + str) : str; - } - - return { - - normalizeCssArray: normalizeCssArray, - - addCommas: addCommas, - - toCamelCase: toCamelCase, - - encodeHTML: encodeHTML, - - formatTpl: formatTpl, - - formatTime: formatTime - }; -}); -define('echarts/util/clazz',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - var clazz = {}; - - var TYPE_DELIMITER = '.'; - var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___'; - /** - * @public - */ - var parseClassType = clazz.parseClassType = function (componentType) { - var ret = {main: '', sub: ''}; - if (componentType) { - componentType = componentType.split(TYPE_DELIMITER); - ret.main = componentType[0] || ''; - ret.sub = componentType[1] || ''; - } - return ret; - }; - /** - * @public - */ - clazz.enableClassExtend = function (RootClass, preConstruct) { - RootClass.extend = function (proto) { - var ExtendedClass = function () { - preConstruct && preConstruct.apply(this, arguments); - RootClass.apply(this, arguments); - }; - - zrUtil.extend(ExtendedClass.prototype, proto); - - ExtendedClass.extend = this.extend; - ExtendedClass.superCall = superCall; - ExtendedClass.superApply = superApply; - zrUtil.inherits(ExtendedClass, this); - ExtendedClass.superClass = this; - - return ExtendedClass; - }; - }; - - // superCall should have class info, which can not be fetch from 'this'. - // Consider this case: - // class A has method f, - // class B inherits class A, overrides method f, f call superApply('f'), - // class C inherits class B, do not overrides method f, - // then when method of class C is called, dead loop occured. - function superCall(context, methodName) { - var args = zrUtil.slice(arguments, 2); - return this.superClass.prototype[methodName].apply(context, args); - } - - function superApply(context, methodName, args) { - return this.superClass.prototype[methodName].apply(context, args); - } - - /** - * @param {Object} entity - * @param {Object} options - * @param {boolean} [options.registerWhenExtend] - * @public - */ - clazz.enableClassManagement = function (entity, options) { - options = options || {}; - - /** - * Component model classes - * key: componentType, - * value: - * componentClass, when componentType is 'xxx' - * or Object., when componentType is 'xxx.yy' - * @type {Object} - */ - var storage = {}; - - entity.registerClass = function (Clazz, componentType) { - if (componentType) { - componentType = parseClassType(componentType); - - if (!componentType.sub) { - if (storage[componentType.main]) { - throw new Error(componentType.main + 'exists'); - } - storage[componentType.main] = Clazz; - } - else if (componentType.sub !== IS_CONTAINER) { - var container = makeContainer(componentType); - container[componentType.sub] = Clazz; - } - } - return Clazz; - }; - - entity.getClass = function (componentTypeMain, subType, throwWhenNotFound) { - var Clazz = storage[componentTypeMain]; - - if (Clazz && Clazz[IS_CONTAINER]) { - Clazz = subType ? Clazz[subType] : null; - } - - if (throwWhenNotFound && !Clazz) { - throw new Error( - 'Component ' + componentTypeMain + '.' + (subType || '') + ' not exists' - ); - } - - return Clazz; - }; - - entity.getClassesByMainType = function (componentType) { - componentType = parseClassType(componentType); - - var result = []; - var obj = storage[componentType.main]; - - if (obj && obj[IS_CONTAINER]) { - zrUtil.each(obj, function (o, type) { - type !== IS_CONTAINER && result.push(o); - }); - } - else { - result.push(obj); - } - - return result; - }; - - entity.hasClass = function (componentType) { - // Just consider componentType.main. - componentType = parseClassType(componentType); - return !!storage[componentType.main]; - }; - - /** - * @return {Array.} Like ['aa', 'bb'], but can not be ['aa.xx'] - */ - entity.getAllClassMainTypes = function () { - var types = []; - zrUtil.each(storage, function (obj, type) { - types.push(type); - }); - return types; - }; - - /** - * If a main type is container and has sub types - * @param {string} mainType - * @return {boolean} - */ - entity.hasSubTypes = function (componentType) { - componentType = parseClassType(componentType); - var obj = storage[componentType.main]; - return obj && obj[IS_CONTAINER]; - }; - - entity.parseClassType = parseClassType; - - function makeContainer(componentType) { - var container = storage[componentType.main]; - if (!container || !container[IS_CONTAINER]) { - container = storage[componentType.main] = {}; - container[IS_CONTAINER] = true; - } - return container; - } - - if (options.registerWhenExtend) { - var originalExtend = entity.extend; - if (originalExtend) { - entity.extend = function (proto) { - var ExtendedClass = originalExtend.call(this, proto); - return entity.registerClass(ExtendedClass, proto.type); - }; - } - } - - return entity; - }; - - /** - * @param {string|Array.} properties - */ - clazz.setReadOnly = function (obj, properties) { - // FIXME It seems broken in IE8 simulation of IE11 - // if (!zrUtil.isArray(properties)) { - // properties = properties != null ? [properties] : []; - // } - // zrUtil.each(properties, function (prop) { - // var value = obj[prop]; - - // Object.defineProperty - // && Object.defineProperty(obj, prop, { - // value: value, writable: false - // }); - // zrUtil.isArray(obj[prop]) - // && Object.freeze - // && Object.freeze(obj[prop]); - // }); - }; - - return clazz; -}); -// TODO Parse shadow style -// TODO Only shallow path support -define('echarts/model/mixin/makeStyleMapper',['require','zrender/core/util'],function (require) { - var zrUtil = require('zrender/core/util'); - - return function (properties) { - // Normalize - for (var i = 0; i < properties.length; i++) { - if (!properties[i][1]) { - properties[i][1] = properties[i][0]; - } - } - return function (excludes) { - var style = {}; - for (var i = 0; i < properties.length; i++) { - var propName = properties[i][1]; - if (excludes && zrUtil.indexOf(excludes, propName) >= 0) { - continue; - } - var val = this.getShallow(propName); - if (val != null) { - style[properties[i][0]] = val; - } - } - return style; - }; - }; -}); -define('echarts/model/mixin/lineStyle',['require','./makeStyleMapper'],function (require) { - var getLineStyle = require('./makeStyleMapper')( - [ - ['lineWidth', 'width'], - ['stroke', 'color'], - ['opacity'], - ['shadowBlur'], - ['shadowOffsetX'], - ['shadowOffsetY'], - ['shadowColor'] - ] - ); - return { - getLineStyle: function (excludes) { - var style = getLineStyle.call(this, excludes); - var lineDash = this.getLineDash(); - lineDash && (style.lineDash = lineDash); - return style; - }, - - getLineDash: function () { - var lineType = this.get('type'); - return (lineType === 'solid' || lineType == null) ? null - : (lineType === 'dashed' ? [5, 5] : [1, 1]); - } - }; -}); -define('echarts/model/mixin/areaStyle',['require','./makeStyleMapper'],function (require) { - return { - getAreaStyle: require('./makeStyleMapper')( - [ - ['fill', 'color'], - ['shadowBlur'], - ['shadowOffsetX'], - ['shadowOffsetY'], - ['opacity'], - ['shadowColor'] - ] - ) - }; -}); -define('zrender/core/vector',[],function () { - var ArrayCtor = typeof Float32Array === 'undefined' - ? Array - : Float32Array; - - /** - * @typedef {Float32Array|Array.} Vector2 - */ - /** - * 二维向量类 - * @exports zrender/tool/vector - */ - var vector = { - /** - * 创建一个向量 - * @param {number} [x=0] - * @param {number} [y=0] - * @return {Vector2} - */ - create: function (x, y) { - var out = new ArrayCtor(2); - out[0] = x || 0; - out[1] = y || 0; - return out; - }, - - /** - * 复制向量数据 - * @param {Vector2} out - * @param {Vector2} v - * @return {Vector2} - */ - copy: function (out, v) { - out[0] = v[0]; - out[1] = v[1]; - return out; - }, - - /** - * 克隆一个向量 - * @param {Vector2} v - * @return {Vector2} - */ - clone: function (v) { - var out = new ArrayCtor(2); - out[0] = v[0]; - out[1] = v[1]; - return out; - }, - - /** - * 设置向量的两个项 - * @param {Vector2} out - * @param {number} a - * @param {number} b - * @return {Vector2} 结果 - */ - set: function (out, a, b) { - out[0] = a; - out[1] = b; - return out; - }, - - /** - * 向量相加 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - add: function (out, v1, v2) { - out[0] = v1[0] + v2[0]; - out[1] = v1[1] + v2[1]; - return out; - }, - - /** - * 向量缩放后相加 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - * @param {number} a - */ - scaleAndAdd: function (out, v1, v2, a) { - out[0] = v1[0] + v2[0] * a; - out[1] = v1[1] + v2[1] * a; - return out; - }, - - /** - * 向量相减 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - sub: function (out, v1, v2) { - out[0] = v1[0] - v2[0]; - out[1] = v1[1] - v2[1]; - return out; - }, - - /** - * 向量长度 - * @param {Vector2} v - * @return {number} - */ - len: function (v) { - return Math.sqrt(this.lenSquare(v)); - }, - - /** - * 向量长度平方 - * @param {Vector2} v - * @return {number} - */ - lenSquare: function (v) { - return v[0] * v[0] + v[1] * v[1]; - }, - - /** - * 向量乘法 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - mul: function (out, v1, v2) { - out[0] = v1[0] * v2[0]; - out[1] = v1[1] * v2[1]; - return out; - }, - - /** - * 向量除法 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - div: function (out, v1, v2) { - out[0] = v1[0] / v2[0]; - out[1] = v1[1] / v2[1]; - return out; - }, - - /** - * 向量点乘 - * @param {Vector2} v1 - * @param {Vector2} v2 - * @return {number} - */ - dot: function (v1, v2) { - return v1[0] * v2[0] + v1[1] * v2[1]; - }, - - /** - * 向量缩放 - * @param {Vector2} out - * @param {Vector2} v - * @param {number} s - */ - scale: function (out, v, s) { - out[0] = v[0] * s; - out[1] = v[1] * s; - return out; - }, - - /** - * 向量归一化 - * @param {Vector2} out - * @param {Vector2} v - */ - normalize: function (out, v) { - var d = vector.len(v); - if (d === 0) { - out[0] = 0; - out[1] = 0; - } - else { - out[0] = v[0] / d; - out[1] = v[1] / d; - } - return out; - }, - - /** - * 计算向量间距离 - * @param {Vector2} v1 - * @param {Vector2} v2 - * @return {number} - */ - distance: function (v1, v2) { - return Math.sqrt( - (v1[0] - v2[0]) * (v1[0] - v2[0]) - + (v1[1] - v2[1]) * (v1[1] - v2[1]) - ); - }, - - /** - * 向量距离平方 - * @param {Vector2} v1 - * @param {Vector2} v2 - * @return {number} - */ - distanceSquare: function (v1, v2) { - return (v1[0] - v2[0]) * (v1[0] - v2[0]) - + (v1[1] - v2[1]) * (v1[1] - v2[1]); - }, - - /** - * 求负向量 - * @param {Vector2} out - * @param {Vector2} v - */ - negate: function (out, v) { - out[0] = -v[0]; - out[1] = -v[1]; - return out; - }, - - /** - * 插值两个点 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - * @param {number} t - */ - lerp: function (out, v1, v2, t) { - out[0] = v1[0] + t * (v2[0] - v1[0]); - out[1] = v1[1] + t * (v2[1] - v1[1]); - return out; - }, - - /** - * 矩阵左乘向量 - * @param {Vector2} out - * @param {Vector2} v - * @param {Vector2} m - */ - applyTransform: function (out, v, m) { - var x = v[0]; - var y = v[1]; - out[0] = m[0] * x + m[2] * y + m[4]; - out[1] = m[1] * x + m[3] * y + m[5]; - return out; - }, - /** - * 求两个向量最小值 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - min: function (out, v1, v2) { - out[0] = Math.min(v1[0], v2[0]); - out[1] = Math.min(v1[1], v2[1]); - return out; - }, - /** - * 求两个向量最大值 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ - max: function (out, v1, v2) { - out[0] = Math.max(v1[0], v2[0]); - out[1] = Math.max(v1[1], v2[1]); - return out; - } - }; - - vector.length = vector.len; - vector.lengthSquare = vector.lenSquare; - vector.dist = vector.distance; - vector.distSquare = vector.distanceSquare; - - return vector; -}); + var textLines = text.split('\n'); + for (var i = 0; i < textLines.length; i++) { + textFill && ctx.fillText(textLines[i], x, y); + textStroke && ctx.strokeText(textLines[i], x, y); + y += lineHeight; + } -define('zrender/core/matrix',[],function () { - var ArrayCtor = typeof Float32Array === 'undefined' - ? Array - : Float32Array; - /** - * 3x2矩阵操作类 - * @exports zrender/tool/matrix - */ - var matrix = { - /** - * 创建一个单位矩阵 - * @return {Float32Array|Array.} - */ - create : function() { - var out = new ArrayCtor(6); - matrix.identity(out); - - return out; - }, - /** - * 设置矩阵为单位矩阵 - * @param {Float32Array|Array.} out - */ - identity : function(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = 0; - out[5] = 0; - return out; - }, - /** - * 复制矩阵 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} m - */ - copy: function(out, m) { - out[0] = m[0]; - out[1] = m[1]; - out[2] = m[2]; - out[3] = m[3]; - out[4] = m[4]; - out[5] = m[5]; - return out; - }, - /** - * 矩阵相乘 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} m1 - * @param {Float32Array|Array.} m2 - */ - mul : function (out, m1, m2) { - // Consider matrix.mul(m, m2, m); - // where out is the same as m2. - // So use temp variable to escape error. - var out0 = m1[0] * m2[0] + m1[2] * m2[1]; - var out1 = m1[1] * m2[0] + m1[3] * m2[1]; - var out2 = m1[0] * m2[2] + m1[2] * m2[3]; - var out3 = m1[1] * m2[2] + m1[3] * m2[3]; - var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4]; - var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5]; - out[0] = out0; - out[1] = out1; - out[2] = out2; - out[3] = out3; - out[4] = out4; - out[5] = out5; - return out; - }, - /** - * 平移变换 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - * @param {Float32Array|Array.} v - */ - translate : function(out, a, v) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4] + v[0]; - out[5] = a[5] + v[1]; - return out; - }, - /** - * 旋转变换 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - * @param {number} rad - */ - rotate : function(out, a, rad) { - var aa = a[0]; - var ac = a[2]; - var atx = a[4]; - var ab = a[1]; - var ad = a[3]; - var aty = a[5]; - var st = Math.sin(rad); - var ct = Math.cos(rad); - - out[0] = aa * ct + ab * st; - out[1] = -aa * st + ab * ct; - out[2] = ac * ct + ad * st; - out[3] = -ac * st + ct * ad; - out[4] = ct * atx + st * aty; - out[5] = ct * aty - st * atx; - return out; - }, - /** - * 缩放变换 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - * @param {Float32Array|Array.} v - */ - scale : function(out, a, v) { - var vx = v[0]; - var vy = v[1]; - out[0] = a[0] * vx; - out[1] = a[1] * vy; - out[2] = a[2] * vx; - out[3] = a[3] * vy; - out[4] = a[4] * vx; - out[5] = a[5] * vy; - return out; - }, - /** - * 求逆矩阵 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - */ - invert : function(out, a) { - - var aa = a[0]; - var ac = a[2]; - var atx = a[4]; - var ab = a[1]; - var ad = a[3]; - var aty = a[5]; - - var det = aa * ad - ab * ac; - if (!det) { - return null; - } - det = 1.0 / det; - - out[0] = ad * det; - out[1] = -ab * det; - out[2] = -ac * det; - out[3] = aa * det; - out[4] = (ac * aty - ad * atx) * det; - out[5] = (ab * atx - aa * aty) * det; - return out; - } - }; - - return matrix; -}); + ctx.restore(); + } + }, -/** - * @module echarts/core/BoundingRect - */ -define('zrender/core/BoundingRect',['require','./vector','./matrix'],function(require) { - - - var vec2 = require('./vector'); - var matrix = require('./matrix'); - - var v2ApplyTransform = vec2.applyTransform; - var mathMin = Math.min; - var mathAbs = Math.abs; - var mathMax = Math.max; - /** - * @alias module:echarts/core/BoundingRect - */ - function BoundingRect(x, y, width, height) { - /** - * @type {number} - */ - this.x = x; - /** - * @type {number} - */ - this.y = y; - /** - * @type {number} - */ - this.width = width; - /** - * @type {number} - */ - this.height = height; - } - - BoundingRect.prototype = { - - constructor: BoundingRect, - - /** - * @param {module:echarts/core/BoundingRect} other - */ - union: function (other) { - var x = mathMin(other.x, this.x); - var y = mathMin(other.y, this.y); - - this.width = mathMax( - other.x + other.width, - this.x + this.width - ) - x; - this.height = mathMax( - other.y + other.height, - this.y + this.height - ) - y; - this.x = x; - this.y = y; - }, - - /** - * @param {Array.} m - * @methods - */ - applyTransform: (function () { - var min = []; - var max = []; - return function (m) { - // In case usage like this - // el.getBoundingRect().applyTransform(el.transform) - // And element has no transform - if (!m) { - return; - } - min[0] = this.x; - min[1] = this.y; - max[0] = this.x + this.width; - max[1] = this.y + this.height; - - v2ApplyTransform(min, min, m); - v2ApplyTransform(max, max, m); - - this.x = mathMin(min[0], max[0]); - this.y = mathMin(min[1], max[1]); - this.width = mathAbs(max[0] - min[0]); - this.height = mathAbs(max[1] - min[1]); - }; - })(), - - /** - * Calculate matrix of transforming from self to target rect - * @param {module:zrender/core/BoundingRect} b - * @return {Array.} - */ - calculateTransform: function (b) { - var a = this; - var sx = b.width / a.width; - var sy = b.height / a.height; - - var m = matrix.create(); - - // 矩阵右乘 - matrix.translate(m, m, [-a.x, -a.y]); - matrix.scale(m, m, [sx, sy]); - matrix.translate(m, m, [b.x, b.y]); - - return m; - }, - - /** - * @param {(module:echarts/core/BoundingRect|Object)} b - * @return {boolean} - */ - intersect: function (b) { - var a = this; - var ax0 = a.x; - var ax1 = a.x + a.width; - var ay0 = a.y; - var ay1 = a.y + a.height; - - var bx0 = b.x; - var bx1 = b.x + b.width; - var by0 = b.y; - var by1 = b.y + b.height; - - return ! (ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0); - }, - - contain: function (x, y) { - var rect = this; - return x >= rect.x - && x <= (rect.x + rect.width) - && y >= rect.y - && y <= (rect.y + rect.height); - }, - - /** - * @return {module:echarts/core/BoundingRect} - */ - clone: function () { - return new BoundingRect(this.x, this.y, this.width, this.height); - }, - - /** - * Copy from another rect - */ - copy: function (other) { - this.x = other.x; - this.y = other.y; - this.width = other.width; - this.height = other.height; - } - }; - - return BoundingRect; -}); -define('zrender/contain/text',['require','../core/util','../core/BoundingRect'],function (require) { - - var textWidthCache = {}; - var textWidthCacheCounter = 0; - var TEXT_CACHE_MAX = 5000; - - var util = require('../core/util'); - var BoundingRect = require('../core/BoundingRect'); - - function getTextWidth(text, textFont) { - var key = text + ':' + textFont; - if (textWidthCache[key]) { - return textWidthCache[key]; - } - - var textLines = (text + '').split('\n'); - var width = 0; - - for (var i = 0, l = textLines.length; i < l; i++) { - // measureText 可以被覆盖以兼容不支持 Canvas 的环境 - width = Math.max(textContain.measureText(textLines[i], textFont).width, width); - } - - if (textWidthCacheCounter > TEXT_CACHE_MAX) { - textWidthCacheCounter = 0; - textWidthCache = {}; - } - textWidthCacheCounter++; - textWidthCache[key] = width; - - return width; - } - - function getTextRect(text, textFont, textAlign, textBaseline) { - var textLineLen = ((text || '') + '').split('\n').length; - - var width = getTextWidth(text, textFont); - // FIXME 高度计算比较粗暴 - var lineHeight = getTextWidth('国', textFont); - var height = textLineLen * lineHeight; - - var rect = new BoundingRect(0, 0, width, height); - // Text has a special line height property - rect.lineHeight = lineHeight; - - switch (textBaseline) { - case 'bottom': - case 'alphabetic': - rect.y -= lineHeight; - break; - case 'middle': - rect.y -= lineHeight / 2; - break; - // case 'hanging': - // case 'top': - } - - // FIXME Right to left language - switch (textAlign) { - case 'end': - case 'right': - rect.x -= rect.width; - break; - case 'center': - rect.x -= rect.width / 2; - break; - // case 'start': - // case 'left': - } - - return rect; - } - - function adjustTextPositionOnRect(textPosition, rect, textRect, distance) { - - var x = rect.x; - var y = rect.y; - - var height = rect.height; - var width = rect.width; - - var textHeight = textRect.height; - - var halfHeight = height / 2 - textHeight / 2; - - var textAlign = 'left'; - - switch (textPosition) { - case 'left': - x -= distance; - y += halfHeight; - textAlign = 'right'; - break; - case 'right': - x += distance + width; - y += halfHeight; - textAlign = 'left'; - break; - case 'top': - x += width / 2; - y -= distance + textHeight; - textAlign = 'center'; - break; - case 'bottom': - x += width / 2; - y += height + distance; - textAlign = 'center'; - break; - case 'inside': - x += width / 2; - y += halfHeight; - textAlign = 'center'; - break; - case 'insideLeft': - x += distance; - y += halfHeight; - textAlign = 'left'; - break; - case 'insideRight': - x += width - distance; - y += halfHeight; - textAlign = 'right'; - break; - case 'insideTop': - x += width / 2; - y += distance; - textAlign = 'center'; - break; - case 'insideBottom': - x += width / 2; - y += height - textHeight - distance; - textAlign = 'center'; - break; - case 'insideTopLeft': - x += distance; - y += distance; - textAlign = 'left'; - break; - case 'insideTopRight': - x += width - distance; - y += distance; - textAlign = 'right'; - break; - case 'insideBottomLeft': - x += distance; - y += height - textHeight - distance; - break; - case 'insideBottomRight': - x += width - distance; - y += height - textHeight - distance; - textAlign = 'right'; - break; - } - - return { - x: x, - y: y, - textAlign: textAlign, - textBaseline: 'top' - }; - } - - /** - * Show ellipsis if overflow. - * - * @param {string} text - * @param {string} textFont - * @param {string} containerWidth - * @param {Object} [options] - * @param {number} [options.ellipsis='...'] - * @param {number} [options.maxIterations=3] - * @param {number} [options.minCharacters=3] - * @return {string} - */ - function textEllipsis(text, textFont, containerWidth, options) { - if (!containerWidth) { - return ''; - } - - options = util.defaults({ - ellipsis: '...', - minCharacters: 3, - maxIterations: 3, - cnCharWidth: getTextWidth('国', textFont), - // FIXME - // 未考虑非等宽字体 - ascCharWidth: getTextWidth('a', textFont) - }, options, true); - - containerWidth -= getTextWidth(options.ellipsis); - - var textLines = (text + '').split('\n'); - - for (var i = 0, len = textLines.length; i < len; i++) { - textLines[i] = textLineTruncate( - textLines[i], textFont, containerWidth, options - ); - } - - return textLines.join('\n'); - } - - function textLineTruncate(text, textFont, containerWidth, options) { - // FIXME - // 粗糙得写的,尚未考虑性能和各种语言、字体的效果。 - for (var i = 0;; i++) { - var lineWidth = getTextWidth(text, textFont); - - if (lineWidth < containerWidth || i >= options.maxIterations) { - text += options.ellipsis; - break; - } - - var subLength = i === 0 - ? estimateLength(text, containerWidth, options) - : Math.floor(text.length * containerWidth / lineWidth); - - if (subLength < options.minCharacters) { - text = ''; - break; - } - - text = text.substr(0, subLength); - } - - return text; - } - - function estimateLength(text, containerWidth, options) { - var width = 0; - var i = 0; - for (var len = text.length; i < len && width < containerWidth; i++) { - var charCode = text.charCodeAt(i); - width += (0 <= charCode && charCode <= 127) - ? options.ascCharWidth : options.cnCharWidth; - } - return i; - } - - var textContain = { - - getWidth: getTextWidth, - - getBoundingRect: getTextRect, - - adjustTextPositionOnRect: adjustTextPositionOnRect, - - ellipsis: textEllipsis, - - measureText: function (text, textFont) { - var ctx = util.getContext(); - ctx.font = textFont; - return ctx.measureText(text); - } - }; - - return textContain; -}); -define('echarts/model/mixin/textStyle',['require','zrender/contain/text'],function (require) { - - var textContain = require('zrender/contain/text'); - - function getShallow(model, path) { - return model && model.getShallow(path); - } - - return { - /** - * Get color property or get color from option.textStyle.color - * @return {string} - */ - getTextColor: function () { - var ecModel = this.ecModel; - return this.getShallow('color') - || (ecModel && ecModel.get('textStyle.color')); - }, - - /** - * Create font string from fontStyle, fontWeight, fontSize, fontFamily - * @return {string} - */ - getFont: function () { - var ecModel = this.ecModel; - var gTextStyleModel = ecModel && ecModel.getModel('textStyle'); - return [ - // FIXME in node-canvas fontWeight is before fontStyle - this.getShallow('fontStyle') || getShallow(gTextStyleModel, 'fontStyle'), - this.getShallow('fontWeight') || getShallow(gTextStyleModel, 'fontWeight'), - (this.getShallow('fontSize') || getShallow(gTextStyleModel, 'fontSize') || 12) + 'px', - this.getShallow('fontFamily') || getShallow(gTextStyleModel, 'fontFamily') || 'sans-serif' - ].join(' '); - }, - - getTextRect: function (text) { - var textStyle = this.get('textStyle') || {}; - return textContain.getBoundingRect( - text, - this.getFont(), - textStyle.align, - textStyle.baseline - ); - }, - - ellipsis: function (text, containerWidth, options) { - return textContain.ellipsis( - text, this.getFont(), containerWidth, options - ); - } - }; -}); -define('echarts/model/mixin/itemStyle',['require','./makeStyleMapper'],function (require) { - return { - getItemStyle: require('./makeStyleMapper')( - [ - ['fill', 'color'], - ['stroke', 'borderColor'], - ['lineWidth', 'borderWidth'], - ['opacity'], - ['shadowBlur'], - ['shadowOffsetX'], - ['shadowOffsetY'], - ['shadowColor'] - ] - ) - }; -}); -/** - * @module echarts/model/Model - */ -define('echarts/model/Model',['require','zrender/core/util','../util/clazz','./mixin/lineStyle','./mixin/areaStyle','./mixin/textStyle','./mixin/itemStyle'],function (require) { - - var zrUtil = require('zrender/core/util'); - var clazzUtil = require('../util/clazz'); - - /** - * @alias module:echarts/model/Model - * @constructor - * @param {Object} option - * @param {module:echarts/model/Model} parentModel - * @param {module:echarts/model/Global} ecModel - * @param {Object} extraOpt - */ - function Model(option, parentModel, ecModel, extraOpt) { - /** - * @type {module:echarts/model/Model} - * @readOnly - */ - this.parentModel = parentModel; - - /** - * @type {module:echarts/model/Global} - * @readOnly - */ - this.ecModel = ecModel; - - /** - * @type {Object} - * @protected - */ - this.option = option; - - // Simple optimization - if (this.init) { - if (arguments.length <= 4) { - this.init(option, parentModel, ecModel, extraOpt); - } - else { - this.init.apply(this, arguments); - } - } - } - - Model.prototype = { - - constructor: Model, - - /** - * Model 的初始化函数 - * @param {Object} option - */ - init: null, - - /** - * 从新的 Option merge - */ - mergeOption: function (option) { - zrUtil.merge(this.option, option, true); - }, - - /** - * @param {string} path - * @param {boolean} [ignoreParent=false] - * @return {*} - */ - get: function (path, ignoreParent) { - if (!path) { - return this.option; - } - - if (typeof path === 'string') { - path = path.split('.'); - } - - var obj = this.option; - var parentModel = this.parentModel; - for (var i = 0; i < path.length; i++) { - // obj could be number/string/... (like 0) - obj = (obj && typeof obj === 'object') ? obj[path[i]] : null; - if (obj == null) { - break; - } - } - if (obj == null && parentModel && !ignoreParent) { - obj = parentModel.get(path); - } - return obj; - }, - - /** - * @param {string} key - * @param {boolean} [ignoreParent=false] - * @return {*} - */ - getShallow: function (key, ignoreParent) { - var option = this.option; - var val = option && option[key]; - var parentModel = this.parentModel; - if (val == null && parentModel && !ignoreParent) { - val = parentModel.getShallow(key); - } - return val; - }, - - /** - * @param {string} path - * @param {module:echarts/model/Model} [parentModel] - * @return {module:echarts/model/Model} - */ - getModel: function (path, parentModel) { - var obj = this.get(path, true); - var thisParentModel = this.parentModel; - var model = new Model( - obj, parentModel || (thisParentModel && thisParentModel.getModel(path)), - this.ecModel - ); - return model; - }, - - /** - * If model has option - */ - isEmpty: function () { - return this.option == null; - }, - - restoreData: function () {}, - - // Pending - clone: function () { - var Ctor = this.constructor; - return new Ctor(zrUtil.clone(this.option)); - }, - - setReadOnly: function (properties) { - clazzUtil.setReadOnly(this, properties); - } - }; - - // Enable Model.extend. - clazzUtil.enableClassExtend(Model); - - var mixin = zrUtil.mixin; - mixin(Model, require('./mixin/lineStyle')); - mixin(Model, require('./mixin/areaStyle')); - mixin(Model, require('./mixin/textStyle')); - mixin(Model, require('./mixin/itemStyle')); - - return Model; -}); -define('echarts/util/model',['require','./format','./number','zrender/core/util','../model/Model'],function(require) { - - var formatUtil = require('./format'); - var nubmerUtil = require('./number'); - var zrUtil = require('zrender/core/util'); - - var Model = require('../model/Model'); - - var AXIS_DIMS = ['x', 'y', 'z', 'radius', 'angle']; - - var modelUtil = {}; - - /** - * Create "each" method to iterate names. - * - * @pubilc - * @param {Array.} names - * @param {Array.=} attrs - * @return {Function} - */ - modelUtil.createNameEach = function (names, attrs) { - names = names.slice(); - var capitalNames = zrUtil.map(names, modelUtil.capitalFirst); - attrs = (attrs || []).slice(); - var capitalAttrs = zrUtil.map(attrs, modelUtil.capitalFirst); - - return function (callback, context) { - zrUtil.each(names, function (name, index) { - var nameObj = {name: name, capital: capitalNames[index]}; - - for (var j = 0; j < attrs.length; j++) { - nameObj[attrs[j]] = name + capitalAttrs[j]; - } - - callback.call(context, nameObj); - }); - }; - }; - - /** - * @public - */ - modelUtil.capitalFirst = function (str) { - return str ? str.charAt(0).toUpperCase() + str.substr(1) : str; - }; - - /** - * Iterate each dimension name. - * - * @public - * @param {Function} callback The parameter is like: - * { - * name: 'angle', - * capital: 'Angle', - * axis: 'angleAxis', - * axisIndex: 'angleAixs', - * index: 'angleIndex' - * } - * @param {Object} context - */ - modelUtil.eachAxisDim = modelUtil.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index']); - - /** - * If value is not array, then translate it to array. - * @param {*} value - * @return {Array} [value] or value - */ - modelUtil.normalizeToArray = function (value) { - return zrUtil.isArray(value) - ? value - : value == null - ? [] - : [value]; - }; - - /** - * If tow dataZoomModels has the same axis controlled, we say that they are 'linked'. - * dataZoomModels and 'links' make up one or more graphics. - * This function finds the graphic where the source dataZoomModel is in. - * - * @public - * @param {Function} forEachNode Node iterator. - * @param {Function} forEachEdgeType edgeType iterator - * @param {Function} edgeIdGetter Giving node and edgeType, return an array of edge id. - * @return {Function} Input: sourceNode, Output: Like {nodes: [], dims: {}} - */ - modelUtil.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) { - - return function (sourceNode) { - var result = { - nodes: [], - records: {} // key: edgeType.name, value: Object (key: edge id, value: boolean). - }; - - forEachEdgeType(function (edgeType) { - result.records[edgeType.name] = {}; - }); - - if (!sourceNode) { - return result; - } - - absorb(sourceNode, result); - - var existsLink; - do { - existsLink = false; - forEachNode(processSingleNode); - } - while (existsLink); - - function processSingleNode(node) { - if (!isNodeAbsorded(node, result) && isLinked(node, result)) { - absorb(node, result); - existsLink = true; - } - } - - return result; - }; - - function isNodeAbsorded(node, result) { - return zrUtil.indexOf(result.nodes, node) >= 0; - } - - function isLinked(node, result) { - var hasLink = false; - forEachEdgeType(function (edgeType) { - zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) { - result.records[edgeType.name][edgeId] && (hasLink = true); - }); - }); - return hasLink; - } - - function absorb(node, result) { - result.nodes.push(node); - forEachEdgeType(function (edgeType) { - zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) { - result.records[edgeType.name][edgeId] = true; - }); - }); - } - }; - - /** - * Sync default option between normal and emphasis like `position` and `show` - * In case some one will write code like - * label: { - * normal: { - * show: false, - * position: 'outside', - * textStyle: { - * fontSize: 18 - * } - * }, - * emphasis: { - * show: true - * } - * } - * @param {Object} opt - * @param {Array.} subOpts - */ - modelUtil.defaultEmphasis = function (opt, subOpts) { - if (opt) { - var emphasisOpt = opt.emphasis = opt.emphasis || {}; - var normalOpt = opt.normal = opt.normal || {}; - - // Default emphasis option from normal - zrUtil.each(subOpts, function (subOptName) { - var val = zrUtil.retrieve(emphasisOpt[subOptName], normalOpt[subOptName]); - if (val != null) { - emphasisOpt[subOptName] = val; - } - }); - } - }; - - /** - * Create a model proxy to be used in tooltip for edge data, markLine data, markPoint data. - * @param {Object} opt - * @param {string} [opt.seriesIndex] - * @param {Object} [opt.name] - * @param {module:echarts/data/List} data - * @param {Array.} rawData - */ - modelUtil.createDataFormatModel = function (opt, data, rawData) { - var model = new Model(); - zrUtil.mixin(model, modelUtil.dataFormatMixin); - model.seriesIndex = opt.seriesIndex; - model.name = opt.name || ''; - - model.getData = function () { - return data; - }; - model.getRawDataArray = function () { - return rawData; - }; - return model; - }; - - /** - * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}] - * This helper method retieves value from data. - * @param {string|number|Date|Array|Object} dataItem - * @return {number|string|Date|Array.} - */ - modelUtil.getDataItemValue = function (dataItem) { - // Performance sensitive. - return dataItem && (dataItem.value == null ? dataItem : dataItem.value); - }; - - /** - * This helper method convert value in data. - * @param {string|number|Date} value - * @param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'. - */ - modelUtil.converDataValue = function (value, dimInfo) { - // Performance sensitive. - var dimType = dimInfo && dimInfo.type; - if (dimType === 'ordinal') { - return value; - } - - if (dimType === 'time' && !isFinite(value) && value != null && value !== '-') { - value = +nubmerUtil.parseDate(value); - } - - // dimType defaults 'number'. - // If dimType is not ordinal and value is null or undefined or NaN or '-', - // parse to NaN. - return (value == null || value === '') - ? NaN : +value; // If string (like '-'), using '+' parse to NaN - }; - - modelUtil.dataFormatMixin = { - /** - * Get params for formatter - * @param {number} dataIndex - * @return {Object} - */ - getDataParams: function (dataIndex) { - var data = this.getData(); - - var seriesIndex = this.seriesIndex; - var seriesName = this.name; - - var rawValue = this.getRawValue(dataIndex); - var rawDataIndex = data.getRawIndex(dataIndex); - var name = data.getName(dataIndex, true); - - // Data may not exists in the option given by user - var rawDataArray = this.getRawDataArray(); - var itemOpt = rawDataArray && rawDataArray[rawDataIndex]; - - return { - seriesIndex: seriesIndex, - seriesName: seriesName, - name: name, - dataIndex: rawDataIndex, - data: itemOpt, - value: rawValue, - - // Param name list for mapping `a`, `b`, `c`, `d`, `e` - $vars: ['seriesName', 'name', 'value'] - }; - }, - - /** - * Format label - * @param {number} dataIndex - * @param {string} [status='normal'] 'normal' or 'emphasis' - * @param {Function|string} [formatter] Default use the `itemStyle[status].label.formatter` - * @return {string} - */ - getFormattedLabel: function (dataIndex, status, formatter) { - status = status || 'normal'; - var data = this.getData(); - var itemModel = data.getItemModel(dataIndex); - - var params = this.getDataParams(dataIndex); - if (formatter == null) { - formatter = itemModel.get(['label', status, 'formatter']); - } - - if (typeof formatter === 'function') { - params.status = status; - return formatter(params); - } - else if (typeof formatter === 'string') { - return formatUtil.formatTpl(formatter, params); - } - }, - - /** - * Get raw value in option - * @param {number} idx - * @return {Object} - */ - getRawValue: function (idx) { - var itemModel = this.getData().getItemModel(idx); - if (itemModel && itemModel.option != null) { - var dataItem = itemModel.option; - return (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem)) - ? dataItem.value : dataItem; - } - } - }; - - /** - * Mapping to exists for merge. - * - * @public - * @param {Array.|Array.} exists - * @param {Object|Array.} newCptOptions - * @return {Array.} Result, like [{exist: ..., option: ...}, {}], - * which order is the same as exists. - */ - modelUtil.mappingToExists = function (exists, newCptOptions) { - // Mapping by the order by original option (but not order of - // new option) in merge mode. Because we should ensure - // some specified index (like xAxisIndex) is consistent with - // original option, which is easy to understand, espatially in - // media query. And in most case, merge option is used to - // update partial option but not be expected to change order. - newCptOptions = (newCptOptions || []).slice(); - - var result = zrUtil.map(exists || [], function (obj, index) { - return {exist: obj}; - }); - - // Mapping by id or name if specified. - zrUtil.each(newCptOptions, function (cptOption, index) { - if (!zrUtil.isObject(cptOption)) { - return; - } - - for (var i = 0; i < result.length; i++) { - var exist = result[i].exist; - if (!result[i].option // Consider name: two map to one. - && ( - // id has highest priority. - (cptOption.id != null && exist.id === cptOption.id + '') - || (cptOption.name != null - && !modelUtil.isIdInner(cptOption) - && !modelUtil.isIdInner(exist) - && exist.name === cptOption.name + '' - ) - ) - ) { - result[i].option = cptOption; - newCptOptions[index] = null; - break; - } - } - }); - - // Otherwise mapping by index. - zrUtil.each(newCptOptions, function (cptOption, index) { - if (!zrUtil.isObject(cptOption)) { - return; - } - - var i = 0; - for (; i < result.length; i++) { - var exist = result[i].exist; - if (!result[i].option - && !modelUtil.isIdInner(exist) - // Caution: - // Do not overwrite id. But name can be overwritten, - // because axis use name as 'show label text'. - // 'exist' always has id and name and we dont - // need to check it. - && cptOption.id == null - ) { - result[i].option = cptOption; - break; - } - } - - if (i >= result.length) { - result.push({option: cptOption}); - } - }); - - return result; - }; - - /** - * @public - * @param {Object} cptOption - * @return {boolean} - */ - modelUtil.isIdInner = function (cptOption) { - return zrUtil.isObject(cptOption) - && cptOption.id - && (cptOption.id + '').indexOf('\0_ec_\0') === 0; - }; - - return modelUtil; -}); -define('echarts/util/component',['require','zrender/core/util','./clazz'],function(require) { - - var zrUtil = require('zrender/core/util'); - var clazz = require('./clazz'); - - var parseClassType = clazz.parseClassType; - - var base = 0; - - var componentUtil = {}; - - var DELIMITER = '_'; - - /** - * @public - * @param {string} type - * @return {string} - */ - componentUtil.getUID = function (type) { - // Considering the case of crossing js context, - // use Math.random to make id as unique as possible. - return [(type || ''), base++, Math.random()].join(DELIMITER); - }; - - /** - * @inner - */ - componentUtil.enableSubTypeDefaulter = function (entity) { - - var subTypeDefaulters = {}; - - entity.registerSubTypeDefaulter = function (componentType, defaulter) { - componentType = parseClassType(componentType); - subTypeDefaulters[componentType.main] = defaulter; - }; - - entity.determineSubType = function (componentType, option) { - var type = option.type; - if (!type) { - var componentTypeMain = parseClassType(componentType).main; - if (entity.hasSubTypes(componentType) && subTypeDefaulters[componentTypeMain]) { - type = subTypeDefaulters[componentTypeMain](option); - } - } - return type; - }; - - return entity; - }; - - /** - * Topological travel on Activity Network (Activity On Vertices). - * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis']. - * - * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology. - * - * If there is circle dependencey, Error will be thrown. - * - */ - componentUtil.enableTopologicalTravel = function (entity, dependencyGetter) { - - /** - * @public - * @param {Array.} targetNameList Target Component type list. - * Can be ['aa', 'bb', 'aa.xx'] - * @param {Array.} fullNameList By which we can build dependency graph. - * @param {Function} callback Params: componentType, dependencies. - * @param {Object} context Scope of callback. - */ - entity.topologicalTravel = function (targetNameList, fullNameList, callback, context) { - if (!targetNameList.length) { - return; - } - - var result = makeDepndencyGraph(fullNameList); - var graph = result.graph; - var stack = result.noEntryList; - - var targetNameSet = {}; - zrUtil.each(targetNameList, function (name) { - targetNameSet[name] = true; - }); - - while (stack.length) { - var currComponentType = stack.pop(); - var currVertex = graph[currComponentType]; - var isInTargetNameSet = !!targetNameSet[currComponentType]; - if (isInTargetNameSet) { - callback.call(context, currComponentType, currVertex.originalDeps.slice()); - delete targetNameSet[currComponentType]; - } - zrUtil.each( - currVertex.successor, - isInTargetNameSet ? removeEdgeAndAdd : removeEdge - ); - } - - zrUtil.each(targetNameSet, function () { - throw new Error('Circle dependency may exists'); - }); - - function removeEdge(succComponentType) { - graph[succComponentType].entryCount--; - if (graph[succComponentType].entryCount === 0) { - stack.push(succComponentType); - } - } - - // Consider this case: legend depends on series, and we call - // chart.setOption({series: [...]}), where only series is in option. - // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will - // not be called, but only sereis.mergeOption is called. Thus legend - // have no chance to update its local record about series (like which - // name of series is available in legend). - function removeEdgeAndAdd(succComponentType) { - targetNameSet[succComponentType] = true; - removeEdge(succComponentType); - } - }; - - /** - * DepndencyGraph: {Object} - * key: conponentType, - * value: { - * successor: [conponentTypes...], - * originalDeps: [conponentTypes...], - * entryCount: {number} - * } - */ - function makeDepndencyGraph(fullNameList) { - var graph = {}; - var noEntryList = []; - - zrUtil.each(fullNameList, function (name) { - - var thisItem = createDependencyGraphItem(graph, name); - var originalDeps = thisItem.originalDeps = dependencyGetter(name); - - var availableDeps = getAvailableDependencies(originalDeps, fullNameList); - thisItem.entryCount = availableDeps.length; - if (thisItem.entryCount === 0) { - noEntryList.push(name); - } - - zrUtil.each(availableDeps, function (dependentName) { - if (zrUtil.indexOf(thisItem.predecessor, dependentName) < 0) { - thisItem.predecessor.push(dependentName); - } - var thatItem = createDependencyGraphItem(graph, dependentName); - if (zrUtil.indexOf(thatItem.successor, dependentName) < 0) { - thatItem.successor.push(name); - } - }); - }); - - return {graph: graph, noEntryList: noEntryList}; - } - - function createDependencyGraphItem(graph, name) { - if (!graph[name]) { - graph[name] = {predecessor: [], successor: []}; - } - return graph[name]; - } - - function getAvailableDependencies(originalDeps, fullNameList) { - var availableDeps = []; - zrUtil.each(originalDeps, function (dep) { - zrUtil.indexOf(fullNameList, dep) >= 0 && availableDeps.push(dep); - }); - return availableDeps; - } - }; - - return componentUtil; -}); -// Layout helpers for each component positioning -define('echarts/util/layout',['require','zrender/core/util','zrender/core/BoundingRect','./number','./format'],function(require) { - - - var zrUtil = require('zrender/core/util'); - var BoundingRect = require('zrender/core/BoundingRect'); - var numberUtil = require('./number'); - var formatUtil = require('./format'); - var parsePercent = numberUtil.parsePercent; - var each = zrUtil.each; - - var layout = {}; - - var LOCATION_PARAMS = ['left', 'right', 'top', 'bottom', 'width', 'height']; - - function boxLayout(orient, group, gap, maxWidth, maxHeight) { - var x = 0; - var y = 0; - if (maxWidth == null) { - maxWidth = Infinity; - } - if (maxHeight == null) { - maxHeight = Infinity; - } - var currentLineMaxSize = 0; - group.eachChild(function (child, idx) { - var position = child.position; - var rect = child.getBoundingRect(); - var nextChild = group.childAt(idx + 1); - var nextChildRect = nextChild && nextChild.getBoundingRect(); - var nextX; - var nextY; - if (orient === 'horizontal') { - var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0); - nextX = x + moveX; - // Wrap when width exceeds maxWidth or meet a `newline` group - if (nextX > maxWidth || child.newline) { - x = 0; - nextX = moveX; - y += currentLineMaxSize + gap; - currentLineMaxSize = rect.height; - } - else { - currentLineMaxSize = Math.max(currentLineMaxSize, rect.height); - } - } - else { - var moveY = rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0); - nextY = y + moveY; - // Wrap when width exceeds maxHeight or meet a `newline` group - if (nextY > maxHeight || child.newline) { - x += currentLineMaxSize + gap; - y = 0; - nextY = moveY; - currentLineMaxSize = rect.width; - } - else { - currentLineMaxSize = Math.max(currentLineMaxSize, rect.width); - } - } - - if (child.newline) { - return; - } - - position[0] = x; - position[1] = y; - - orient === 'horizontal' - ? (x = nextX + gap) - : (y = nextY + gap); - }); - } - - /** - * VBox or HBox layouting - * @param {string} orient - * @param {module:zrender/container/Group} group - * @param {number} gap - * @param {number} [width=Infinity] - * @param {number} [height=Infinity] - */ - layout.box = boxLayout; - - /** - * VBox layouting - * @param {module:zrender/container/Group} group - * @param {number} gap - * @param {number} [width=Infinity] - * @param {number} [height=Infinity] - */ - layout.vbox = zrUtil.curry(boxLayout, 'vertical'); - - /** - * HBox layouting - * @param {module:zrender/container/Group} group - * @param {number} gap - * @param {number} [width=Infinity] - * @param {number} [height=Infinity] - */ - layout.hbox = zrUtil.curry(boxLayout, 'horizontal'); - - /** - * If x or x2 is not specified or 'center' 'left' 'right', - * the width would be as long as possible. - * If y or y2 is not specified or 'middle' 'top' 'bottom', - * the height would be as long as possible. - * - * @param {Object} positionInfo - * @param {number|string} [positionInfo.x] - * @param {number|string} [positionInfo.y] - * @param {number|string} [positionInfo.x2] - * @param {number|string} [positionInfo.y2] - * @param {Object} containerRect - * @param {string|number} margin - * @return {Object} {width, height} - */ - layout.getAvailableSize = function (positionInfo, containerRect, margin) { - var containerWidth = containerRect.width; - var containerHeight = containerRect.height; - - var x = parsePercent(positionInfo.x, containerWidth); - var y = parsePercent(positionInfo.y, containerHeight); - var x2 = parsePercent(positionInfo.x2, containerWidth); - var y2 = parsePercent(positionInfo.y2, containerHeight); - - (isNaN(x) || isNaN(parseFloat(positionInfo.x))) && (x = 0); - (isNaN(x2) || isNaN(parseFloat(positionInfo.x2))) && (x2 = containerWidth); - (isNaN(y) || isNaN(parseFloat(positionInfo.y))) && (y = 0); - (isNaN(y2) || isNaN(parseFloat(positionInfo.y2))) && (y2 = containerHeight); - - margin = formatUtil.normalizeCssArray(margin || 0); - - return { - width: Math.max(x2 - x - margin[1] - margin[3], 0), - height: Math.max(y2 - y - margin[0] - margin[2], 0) - }; - }; - - /** - * Parse position info. - * - * @param {Object} positionInfo - * @param {number|string} [positionInfo.left] - * @param {number|string} [positionInfo.top] - * @param {number|string} [positionInfo.right] - * @param {number|string} [positionInfo.bottom] - * @param {number|string} [positionInfo.width] - * @param {number|string} [positionInfo.height] - * @param {number|string} [positionInfo.aspect] Aspect is width / height - * @param {Object} containerRect - * @param {string|number} [margin] - * - * @return {module:zrender/core/BoundingRect} - */ - layout.getLayoutRect = function ( - positionInfo, containerRect, margin - ) { - margin = formatUtil.normalizeCssArray(margin || 0); - - var containerWidth = containerRect.width; - var containerHeight = containerRect.height; - - var left = parsePercent(positionInfo.left, containerWidth); - var top = parsePercent(positionInfo.top, containerHeight); - var right = parsePercent(positionInfo.right, containerWidth); - var bottom = parsePercent(positionInfo.bottom, containerHeight); - var width = parsePercent(positionInfo.width, containerWidth); - var height = parsePercent(positionInfo.height, containerHeight); - - var verticalMargin = margin[2] + margin[0]; - var horizontalMargin = margin[1] + margin[3]; - var aspect = positionInfo.aspect; - - // If width is not specified, calculate width from left and right - if (isNaN(width)) { - width = containerWidth - right - horizontalMargin - left; - } - if (isNaN(height)) { - height = containerHeight - bottom - verticalMargin - top; - } - - // If width and height are not given - // 1. Graph should not exceeds the container - // 2. Aspect must be keeped - // 3. Graph should take the space as more as possible - if (isNaN(width) && isNaN(height)) { - if (aspect > containerWidth / containerHeight) { - width = containerWidth * 0.8; - } - else { - height = containerHeight * 0.8; - } - } - - if (aspect != null) { - // Calculate width or height with given aspect - if (isNaN(width)) { - width = aspect * height; - } - if (isNaN(height)) { - height = width / aspect; - } - } - - // If left is not specified, calculate left from right and width - if (isNaN(left)) { - left = containerWidth - right - width - horizontalMargin; - } - if (isNaN(top)) { - top = containerHeight - bottom - height - verticalMargin; - } - - // Align left and top - switch (positionInfo.left || positionInfo.right) { - case 'center': - left = containerWidth / 2 - width / 2 - margin[3]; - break; - case 'right': - left = containerWidth - width - horizontalMargin; - break; - } - switch (positionInfo.top || positionInfo.bottom) { - case 'middle': - case 'center': - top = containerHeight / 2 - height / 2 - margin[0]; - break; - case 'bottom': - top = containerHeight - height - verticalMargin; - break; - } - // If something is wrong and left, top, width, height are calculated as NaN - left = left || 0; - top = top || 0; - if (isNaN(width)) { - // Width may be NaN if only one value is given except width - width = containerWidth - left - (right || 0); - } - if (isNaN(height)) { - // Height may be NaN if only one value is given except height - height = containerHeight - top - (bottom || 0); - } - - var rect = new BoundingRect(left + margin[3], top + margin[0], width, height); - rect.margin = margin; - return rect; - }; - - /** - * Position group of component in viewport - * Group position is specified by either - * {left, top}, {right, bottom} - * If all properties exists, right and bottom will be igonred. - * - * @param {module:zrender/container/Group} group - * @param {Object} positionInfo - * @param {number|string} [positionInfo.left] - * @param {number|string} [positionInfo.top] - * @param {number|string} [positionInfo.right] - * @param {number|string} [positionInfo.bottom] - * @param {Object} containerRect - * @param {string|number} margin - */ - layout.positionGroup = function ( - group, positionInfo, containerRect, margin - ) { - var groupRect = group.getBoundingRect(); - - positionInfo = zrUtil.extend(zrUtil.clone(positionInfo), { - width: groupRect.width, - height: groupRect.height - }); - - positionInfo = layout.getLayoutRect( - positionInfo, containerRect, margin - ); - - group.position = [ - positionInfo.x - groupRect.x, - positionInfo.y - groupRect.y - ]; - }; - - /** - * Consider Case: - * When defulat option has {left: 0, width: 100}, and we set {right: 0} - * through setOption or media query, using normal zrUtil.merge will cause - * {right: 0} does not take effect. - * - * @example - * ComponentModel.extend({ - * init: function () { - * ... - * var inputPositionParams = layout.getLayoutParams(option); - * this.mergeOption(inputPositionParams); - * }, - * mergeOption: function (newOption) { - * newOption && zrUtil.merge(thisOption, newOption, true); - * layout.mergeLayoutParam(thisOption, newOption); - * } - * }); - * - * @param {Object} targetOption - * @param {Object} newOption - * @param {Object|string} [opt] - * @param {boolean} [opt.ignoreSize=false] Some component must has width and height. - */ - layout.mergeLayoutParam = function (targetOption, newOption, opt) { - !zrUtil.isObject(opt) && (opt = {}); - var hNames = ['width', 'left', 'right']; // Order by priority. - var vNames = ['height', 'top', 'bottom']; // Order by priority. - var hResult = merge(hNames); - var vResult = merge(vNames); - - copy(hNames, targetOption, hResult); - copy(vNames, targetOption, vResult); - - function merge(names) { - var newParams = {}; - var newValueCount = 0; - var merged = {}; - var mergedValueCount = 0; - var enoughParamNumber = opt.ignoreSize ? 1 : 2; - - each(names, function (name) { - merged[name] = targetOption[name]; - }); - each(names, function (name) { - // Consider case: newOption.width is null, which is - // set by user for removing width setting. - hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]); - hasValue(newParams, name) && newValueCount++; - hasValue(merged, name) && mergedValueCount++; - }); - - // Case: newOption: {width: ..., right: ...}, - // or targetOption: {right: ...} and newOption: {width: ...}, - // There is no conflict when merged only has params count - // little than enoughParamNumber. - if (mergedValueCount === enoughParamNumber || !newValueCount) { - return merged; - } - // Case: newOption: {width: ..., right: ...}, - // Than we can make sure user only want those two, and ignore - // all origin params in targetOption. - else if (newValueCount >= enoughParamNumber) { - return newParams; - } - else { - // Chose another param from targetOption by priority. - // When 'ignoreSize', enoughParamNumber is 1 and those will not happen. - for (var i = 0; i < names.length; i++) { - var name = names[i]; - if (!hasProp(newParams, name) && hasProp(targetOption, name)) { - newParams[name] = targetOption[name]; - break; - } - } - return newParams; - } - } - - function hasProp(obj, name) { - return obj.hasOwnProperty(name); - } - - function hasValue(obj, name) { - return obj[name] != null && obj[name] !== 'auto'; - } - - function copy(names, target, source) { - each(names, function (name) { - target[name] = source[name]; - }); - } - }; - - /** - * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object. - * @param {Object} source - * @return {Object} Result contains those props. - */ - layout.getLayoutParams = function (source) { - return layout.copyLayoutParams({}, source); - }; - - /** - * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object. - * @param {Object} source - * @return {Object} Result contains those props. - */ - layout.copyLayoutParams = function (target, source) { - source && target && each(LOCATION_PARAMS, function (name) { - source.hasOwnProperty(name) && (target[name] = source[name]); - }); - return target; - }; - - return layout; -}); -define('echarts/model/mixin/boxLayout',['require'],function (require) { - - return { - getBoxLayoutParams: function () { - return { - left: this.get('left'), - top: this.get('top'), - right: this.get('right'), - bottom: this.get('bottom'), - width: this.get('width'), - height: this.get('height') - }; - } - }; -}); -/** - * Component model - * - * @module echarts/model/Component - */ -define('echarts/model/Component',['require','./Model','zrender/core/util','../util/component','../util/clazz','../util/layout','./mixin/boxLayout'],function(require) { - - var Model = require('./Model'); - var zrUtil = require('zrender/core/util'); - var arrayPush = Array.prototype.push; - var componentUtil = require('../util/component'); - var clazzUtil = require('../util/clazz'); - var layout = require('../util/layout'); - - /** - * @alias module:echarts/model/Component - * @constructor - * @param {Object} option - * @param {module:echarts/model/Model} parentModel - * @param {module:echarts/model/Model} ecModel - */ - var ComponentModel = Model.extend({ - - type: 'component', - - /** - * @readOnly - * @type {string} - */ - id: '', - - /** - * @readOnly - */ - name: '', - - /** - * @readOnly - * @type {string} - */ - mainType: '', - - /** - * @readOnly - * @type {string} - */ - subType: '', - - /** - * @readOnly - * @type {number} - */ - componentIndex: 0, - - /** - * @type {Object} - * @protected - */ - defaultOption: null, - - /** - * @type {module:echarts/model/Global} - * @readOnly - */ - ecModel: null, - - /** - * key: componentType - * value: Component model list, can not be null. - * @type {Object.>} - * @readOnly - */ - dependentModels: [], - - /** - * @type {string} - * @readOnly - */ - uid: null, - - /** - * Support merge layout params. - * Only support 'box' now (left/right/top/bottom/width/height). - * @type {string|Object} Object can be {ignoreSize: true} - * @readOnly - */ - layoutMode: null, - - - init: function (option, parentModel, ecModel, extraOpt) { - this.mergeDefaultAndTheme(this.option, this.ecModel); - }, - - mergeDefaultAndTheme: function (option, ecModel) { - var layoutMode = this.layoutMode; - var inputPositionParams = layoutMode - ? layout.getLayoutParams(option) : {}; - - var themeModel = ecModel.getTheme(); - zrUtil.merge(option, themeModel.get(this.mainType)); - zrUtil.merge(option, this.getDefaultOption()); - - if (layoutMode) { - layout.mergeLayoutParam(option, inputPositionParams, layoutMode); - } - }, - - mergeOption: function (option) { - zrUtil.merge(this.option, option, true); - - var layoutMode = this.layoutMode; - if (layoutMode) { - layout.mergeLayoutParam(this.option, option, layoutMode); - } - }, - - getDefaultOption: function () { - if (!this.hasOwnProperty('__defaultOption')) { - var optList = []; - var Class = this.constructor; - while (Class) { - var opt = Class.prototype.defaultOption; - opt && optList.push(opt); - Class = Class.superClass; - } - - var defaultOption = {}; - for (var i = optList.length - 1; i >= 0; i--) { - defaultOption = zrUtil.merge(defaultOption, optList[i], true); - } - this.__defaultOption = defaultOption; - } - return this.__defaultOption; - } - - }); - - // Reset ComponentModel.extend, add preConstruct. - clazzUtil.enableClassExtend( - ComponentModel, - function (option, parentModel, ecModel, extraOpt) { - // Set dependentModels, componentIndex, name, id, mainType, subType. - zrUtil.extend(this, extraOpt); - - this.uid = componentUtil.getUID('componentModel'); - - this.setReadOnly([ - 'type', 'id', 'uid', 'name', 'mainType', 'subType', - 'dependentModels', 'componentIndex' - ]); - } - ); - - // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. - clazzUtil.enableClassManagement( - ComponentModel, {registerWhenExtend: true} - ); - componentUtil.enableSubTypeDefaulter(ComponentModel); - - // Add capability of ComponentModel.topologicalTravel. - componentUtil.enableTopologicalTravel(ComponentModel, getDependencies); - - function getDependencies(componentType) { - var deps = []; - zrUtil.each(ComponentModel.getClassesByMainType(componentType), function (Clazz) { - arrayPush.apply(deps, Clazz.prototype.dependencies || []); - }); - // Ensure main type - return zrUtil.map(deps, function (type) { - return clazzUtil.parseClassType(type).main; - }); - } - - zrUtil.mixin(ComponentModel, require('./mixin/boxLayout')); - - return ComponentModel; -}); -define('echarts/model/globalDefault',[],function () { - var platform = ''; - // Navigator not exists in node - if (typeof navigator !== 'undefined') { - platform = navigator.platform || ''; - } - return { - // 全图默认背景 - // backgroundColor: 'rgba(0,0,0,0)', - - // https://dribbble.com/shots/1065960-Infographic-Pie-chart-visualization - // color: ['#5793f3', '#d14a61', '#fd9c35', '#675bba', '#fec42c', '#dd4444', '#d4df5a', '#cd4870'], - // 浅色 - // color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'], - // color: ['#cc5664', '#9bd6ec', '#ea946e', '#8acaaa', '#f1ec64', '#ee8686', '#a48dc1', '#5da6bc', '#b9dcae'], - // 深色 - color: ['#c23531', '#314656', '#61a0a8', '#dd8668', '#91c7ae', '#6e7074', '#ca8622', '#bda29a', '#44525d', '#c4ccd3'], - - // 默认需要 Grid 配置项 - grid: {}, - // 主题,主题 - textStyle: { - // color: '#000', - // decoration: 'none', - // PENDING - fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif', - // fontFamily: 'Arial, Verdana, sans-serif', - fontSize: 12, - fontStyle: 'normal', - fontWeight: 'normal' - }, - // 主题,默认标志图形类型列表 - // symbolList: [ - // 'circle', 'rectangle', 'triangle', 'diamond', - // 'emptyCircle', 'emptyRectangle', 'emptyTriangle', 'emptyDiamond' - // ], - animation: true, // 过渡动画是否开启 - animationThreshold: 2000, // 动画元素阀值,产生的图形原素超过2000不出动画 - animationDuration: 1000, // 过渡动画参数:进入 - animationDurationUpdate: 300, // 过渡动画参数:更新 - animationEasing: 'exponentialOut', //BounceOut - animationEasingUpdate: 'cubicOut' - }; -}); -/** - * ECharts global model - * - * @module {echarts/model/Global} - * - */ - -define('echarts/model/Global',['require','zrender/core/util','../util/model','./Model','./Component','./globalDefault'],function (require) { - - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../util/model'); - var Model = require('./Model'); - var each = zrUtil.each; - var filter = zrUtil.filter; - var map = zrUtil.map; - var isArray = zrUtil.isArray; - var indexOf = zrUtil.indexOf; - var isObject = zrUtil.isObject; - - var ComponentModel = require('./Component'); - - var globalDefault = require('./globalDefault'); - - var OPTION_INNER_KEY = '\0_ec_inner'; - - /** - * @alias module:echarts/model/Global - * - * @param {Object} option - * @param {module:echarts/model/Model} parentModel - * @param {Object} theme - */ - var GlobalModel = Model.extend({ - - constructor: GlobalModel, - - init: function (option, parentModel, theme, optionManager) { - theme = theme || {}; - - this.option = null; // Mark as not initialized. - - /** - * @type {module:echarts/model/Model} - * @private - */ - this._theme = new Model(theme); - - /** - * @type {module:echarts/model/OptionManager} - */ - this._optionManager = optionManager; - }, - - setOption: function (option, optionPreprocessorFuncs) { - zrUtil.assert( - !(OPTION_INNER_KEY in option), - 'please use chart.getOption()' - ); - - this._optionManager.setOption(option, optionPreprocessorFuncs); - - this.resetOption(); - }, - - /** - * @param {string} type null/undefined: reset all. - * 'recreate': force recreate all. - * 'timeline': only reset timeline option - * 'media': only reset media query option - * @return {boolean} Whether option changed. - */ - resetOption: function (type) { - var optionChanged = false; - var optionManager = this._optionManager; - - if (!type || type === 'recreate') { - var baseOption = optionManager.mountOption(type === 'recreate'); - - if (!this.option || type === 'recreate') { - initBase.call(this, baseOption); - } - else { - this.restoreData(); - this.mergeOption(baseOption); - } - optionChanged = true; - } - - if (type === 'timeline' || type === 'media') { - this.restoreData(); - } - - if (!type || type === 'recreate' || type === 'timeline') { - var timelineOption = optionManager.getTimelineOption(this); - timelineOption && (this.mergeOption(timelineOption), optionChanged = true); - } - - if (!type || type === 'recreate' || type === 'media') { - var mediaOptions = optionManager.getMediaOption(this, this._api); - if (mediaOptions.length) { - each(mediaOptions, function (mediaOption) { - this.mergeOption(mediaOption, optionChanged = true); - }, this); - } - } - - return optionChanged; - }, - - /** - * @protected - */ - mergeOption: function (newOption) { - var option = this.option; - var componentsMap = this._componentsMap; - var newCptTypes = []; - - // 如果不存在对应的 component model 则直接 merge - each(newOption, function (componentOption, mainType) { - if (componentOption == null) { - return; - } - - if (!ComponentModel.hasClass(mainType)) { - option[mainType] = option[mainType] == null - ? zrUtil.clone(componentOption) - : zrUtil.merge(option[mainType], componentOption, true); - } - else { - newCptTypes.push(mainType); - } - }); - - // FIXME OPTION 同步是否要改回原来的 - ComponentModel.topologicalTravel( - newCptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this - ); - - function visitComponent(mainType, dependencies) { - var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]); - - var mapResult = modelUtil.mappingToExists( - componentsMap[mainType], newCptOptionList - ); - - makeKeyInfo(mainType, mapResult); - - var dependentModels = getComponentsByTypes( - componentsMap, dependencies - ); - - option[mainType] = []; - componentsMap[mainType] = []; - - each(mapResult, function (resultItem, index) { - var componentModel = resultItem.exist; - var newCptOption = resultItem.option; - - zrUtil.assert( - isObject(newCptOption) || componentModel, - 'Empty component definition' - ); - - // Consider where is no new option and should be merged using {}, - // see removeEdgeAndAdd in topologicalTravel and - // ComponentModel.getAllClassMainTypes. - if (!newCptOption) { - componentModel.mergeOption({}, this); - } - else { - var ComponentModelClass = ComponentModel.getClass( - mainType, resultItem.keyInfo.subType, true - ); - - if (componentModel && componentModel instanceof ComponentModelClass) { - componentModel.mergeOption(newCptOption, this); - } - else { - // PENDING Global as parent ? - componentModel = new ComponentModelClass( - newCptOption, this, this, - zrUtil.extend( - { - dependentModels: dependentModels, - componentIndex: index - }, - resultItem.keyInfo - ) - ); - } - } - - componentsMap[mainType][index] = componentModel; - option[mainType][index] = componentModel.option; - }, this); - - // Backup series for filtering. - if (mainType === 'series') { - this._seriesIndices = createSeriesIndices(componentsMap.series); - } - } - }, - - /** - * Get option for output (cloned option and inner info removed) - * @public - * @return {Object} - */ - getOption: function () { - var option = zrUtil.clone(this.option); - - each(option, function (opts, mainType) { - if (ComponentModel.hasClass(mainType)) { - var opts = modelUtil.normalizeToArray(opts); - for (var i = opts.length - 1; i >= 0; i--) { - // Remove options with inner id. - if (modelUtil.isIdInner(opts[i])) { - opts.splice(i, 1); - } - } - option[mainType] = opts; - } - }); - - delete option[OPTION_INNER_KEY]; - - return option; - }, - - /** - * @return {module:echarts/model/Model} - */ - getTheme: function () { - return this._theme; - }, - - /** - * @param {string} mainType - * @param {number} [idx=0] - * @return {module:echarts/model/Component} - */ - getComponent: function (mainType, idx) { - var list = this._componentsMap[mainType]; - if (list) { - return list[idx || 0]; - } - }, - - /** - * @param {Object} condition - * @param {string} condition.mainType - * @param {string} [condition.subType] If ignore, only query by mainType - * @param {number} [condition.index] Either input index or id or name. - * @param {string} [condition.id] Either input index or id or name. - * @param {string} [condition.name] Either input index or id or name. - * @return {Array.} - */ - queryComponents: function (condition) { - var mainType = condition.mainType; - if (!mainType) { - return []; - } - - var index = condition.index; - var id = condition.id; - var name = condition.name; - - var cpts = this._componentsMap[mainType]; - - if (!cpts || !cpts.length) { - return []; - } - - var result; - - if (index != null) { - if (!isArray(index)) { - index = [index]; - } - result = filter(map(index, function (idx) { - return cpts[idx]; - }), function (val) { - return !!val; - }); - } - else if (id != null) { - var isIdArray = isArray(id); - result = filter(cpts, function (cpt) { - return (isIdArray && indexOf(id, cpt.id) >= 0) - || (!isIdArray && cpt.id === id); - }); - } - else if (name != null) { - var isNameArray = isArray(name); - result = filter(cpts, function (cpt) { - return (isNameArray && indexOf(name, cpt.name) >= 0) - || (!isNameArray && cpt.name === name); - }); - } - - return filterBySubType(result, condition); - }, - - /** - * The interface is different from queryComponents, - * which is convenient for inner usage. - * - * @usage - * findComponents( - * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}, - * function (model, index) {...} - * ); - * - * findComponents( - * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}, - * function (model, index) {...} - * ); - * - * var result = findComponents( - * {mainType: 'series'}, - * function (model, index) {...} - * ); - * // result like [component0, componnet1, ...] - * - * @param {Object} condition - * @param {string} condition.mainType Mandatory. - * @param {string} [condition.subType] Optional. - * @param {Object} [condition.query] like {xxxIndex, xxxId, xxxName}, - * where xxx is mainType. - * If query attribute is null/undefined or has no index/id/name, - * do not filtering by query conditions, which is convenient for - * no-payload situations or when target of action is global. - * @param {Function} [condition.filter] parameter: component, return boolean. - * @return {Array.} - */ - findComponents: function (condition) { - var query = condition.query; - var mainType = condition.mainType; - - var queryCond = getQueryCond(query); - var result = queryCond - ? this.queryComponents(queryCond) - : this._componentsMap[mainType]; - - return doFilter(filterBySubType(result, condition)); - - function getQueryCond(q) { - var indexAttr = mainType + 'Index'; - var idAttr = mainType + 'Id'; - var nameAttr = mainType + 'Name'; - return q && ( - q.hasOwnProperty(indexAttr) - || q.hasOwnProperty(idAttr) - || q.hasOwnProperty(nameAttr) - ) - ? { - mainType: mainType, - // subType will be filtered finally. - index: q[indexAttr], - id: q[idAttr], - name: q[nameAttr] - } - : null; - } - - function doFilter(res) { - return condition.filter - ? filter(res, condition.filter) - : res; - } - }, - - /** - * @usage - * eachComponent('legend', function (legendModel, index) { - * ... - * }); - * eachComponent(function (componentType, model, index) { - * // componentType does not include subType - * // (componentType is 'xxx' but not 'xxx.aa') - * }); - * eachComponent( - * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}, - * function (model, index) {...} - * ); - * eachComponent( - * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}, - * function (model, index) {...} - * ); - * - * @param {string|Object=} mainType When mainType is object, the definition - * is the same as the method 'findComponents'. - * @param {Function} cb - * @param {*} context - */ - eachComponent: function (mainType, cb, context) { - var componentsMap = this._componentsMap; - - if (typeof mainType === 'function') { - context = cb; - cb = mainType; - each(componentsMap, function (components, componentType) { - each(components, function (component, index) { - cb.call(context, componentType, component, index); - }); - }); - } - else if (zrUtil.isString(mainType)) { - each(componentsMap[mainType], cb, context); - } - else if (isObject(mainType)) { - var queryResult = this.findComponents(mainType); - each(queryResult, cb, context); - } - }, - - /** - * @param {string} name - * @return {Array.} - */ - getSeriesByName: function (name) { - var series = this._componentsMap.series; - return filter(series, function (oneSeries) { - return oneSeries.name === name; - }); - }, - - /** - * @param {number} seriesIndex - * @return {module:echarts/model/Series} - */ - getSeriesByIndex: function (seriesIndex) { - return this._componentsMap.series[seriesIndex]; - }, - - /** - * @param {string} subType - * @return {Array.} - */ - getSeriesByType: function (subType) { - var series = this._componentsMap.series; - return filter(series, function (oneSeries) { - return oneSeries.subType === subType; - }); - }, - - /** - * @return {Array.} - */ - getSeries: function () { - return this._componentsMap.series.slice(); - }, - - /** - * After filtering, series may be different - * frome raw series. - * - * @param {Function} cb - * @param {*} context - */ - eachSeries: function (cb, context) { - assertSeriesInitialized(this); - each(this._seriesIndices, function (rawSeriesIndex) { - var series = this._componentsMap.series[rawSeriesIndex]; - cb.call(context, series, rawSeriesIndex); - }, this); - }, - - /** - * Iterate raw series before filtered. - * - * @param {Function} cb - * @param {*} context - */ - eachRawSeries: function (cb, context) { - each(this._componentsMap.series, cb, context); - }, - - /** - * After filtering, series may be different. - * frome raw series. - * - * @parma {string} subType - * @param {Function} cb - * @param {*} context - */ - eachSeriesByType: function (subType, cb, context) { - assertSeriesInitialized(this); - each(this._seriesIndices, function (rawSeriesIndex) { - var series = this._componentsMap.series[rawSeriesIndex]; - if (series.subType === subType) { - cb.call(context, series, rawSeriesIndex); - } - }, this); - }, - - /** - * Iterate raw series before filtered of given type. - * - * @parma {string} subType - * @param {Function} cb - * @param {*} context - */ - eachRawSeriesByType: function (subType, cb, context) { - return each(this.getSeriesByType(subType), cb, context); - }, - - /** - * @param {module:echarts/model/Series} seriesModel - */ - isSeriesFiltered: function (seriesModel) { - assertSeriesInitialized(this); - return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0; - }, - - /** - * @param {Function} cb - * @param {*} context - */ - filterSeries: function (cb, context) { - assertSeriesInitialized(this); - var filteredSeries = filter( - this._componentsMap.series, cb, context - ); - this._seriesIndices = createSeriesIndices(filteredSeries); - }, - - restoreData: function () { - var componentsMap = this._componentsMap; - - this._seriesIndices = createSeriesIndices(componentsMap.series); - - var componentTypes = []; - each(componentsMap, function (components, componentType) { - componentTypes.push(componentType); - }); - - ComponentModel.topologicalTravel( - componentTypes, - ComponentModel.getAllClassMainTypes(), - function (componentType, dependencies) { - each(componentsMap[componentType], function (component) { - component.restoreData(); - }); - } - ); - } - - }); - - /** - * @inner - */ - function mergeTheme(option, theme) { - for (var name in theme) { - // 如果有 component model 则把具体的 merge 逻辑交给该 model 处理 - if (!ComponentModel.hasClass(name)) { - if (typeof theme[name] === 'object') { - option[name] = !option[name] - ? zrUtil.clone(theme[name]) - : zrUtil.merge(option[name], theme[name], false); - } - else { - option[name] = theme[name]; - } - } - } - } - - function initBase(baseOption) { - baseOption = baseOption; - - // Using OPTION_INNER_KEY to mark that this option can not be used outside, - // i.e. `chart.setOption(chart.getModel().option);` is forbiden. - this.option = {}; - this.option[OPTION_INNER_KEY] = 1; - - /** - * @type {Object.>} - * @private - */ - this._componentsMap = {}; - - /** - * Mapping between filtered series list and raw series list. - * key: filtered series indices, value: raw series indices. - * @type {Array.} - * @private - */ - this._seriesIndices = null; - - mergeTheme(baseOption, this._theme.option); - - // TODO Needs clone when merging to the unexisted property - zrUtil.merge(baseOption, globalDefault, false); - - this.mergeOption(baseOption); - } - - /** - * @inner - * @param {Array.|string} types model types - * @return {Object} key: {string} type, value: {Array.} models - */ - function getComponentsByTypes(componentsMap, types) { - if (!zrUtil.isArray(types)) { - types = types ? [types] : []; - } - - var ret = {}; - each(types, function (type) { - ret[type] = (componentsMap[type] || []).slice(); - }); - - return ret; - } - - /** - * @inner - */ - function makeKeyInfo(mainType, mapResult) { - // We use this id to hash component models and view instances - // in echarts. id can be specified by user, or auto generated. - - // The id generation rule ensures new view instance are able - // to mapped to old instance when setOption are called in - // no-merge mode. So we generate model id by name and plus - // type in view id. - - // name can be duplicated among components, which is convenient - // to specify multi components (like series) by one name. - - // Ensure that each id is distinct. - var idMap = {}; - - each(mapResult, function (item, index) { - var existCpt = item.exist; - existCpt && (idMap[existCpt.id] = item); - }); - - each(mapResult, function (item, index) { - var opt = item.option; - - zrUtil.assert( - !opt || opt.id == null || !idMap[opt.id] || idMap[opt.id] === item, - 'id duplicates: ' + (opt && opt.id) - ); - - opt && opt.id != null && (idMap[opt.id] = item); - - // Complete subType - if (isObject(opt)) { - var subType = determineSubType(mainType, opt, item.exist); - item.keyInfo = {mainType: mainType, subType: subType}; - } - }); - - // Make name and id. - each(mapResult, function (item, index) { - var existCpt = item.exist; - var opt = item.option; - var keyInfo = item.keyInfo; - - if (!isObject(opt)) { - return; - } - - // name can be overwitten. Consider case: axis.name = '20km'. - // But id generated by name will not be changed, which affect - // only in that case: setOption with 'not merge mode' and view - // instance will be recreated, which can be accepted. - keyInfo.name = opt.name != null - ? opt.name + '' - : existCpt - ? existCpt.name - : '\0-'; - - if (existCpt) { - keyInfo.id = existCpt.id; - } - else if (opt.id != null) { - keyInfo.id = opt.id + ''; - } - else { - // Consider this situatoin: - // optionA: [{name: 'a'}, {name: 'a'}, {..}] - // optionB [{..}, {name: 'a'}, {name: 'a'}] - // Series with the same name between optionA and optionB - // should be mapped. - var idNum = 0; - do { - keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++; - } - while (idMap[keyInfo.id]); - } - - idMap[keyInfo.id] = item; - }); - } - - /** - * @inner - */ - function determineSubType(mainType, newCptOption, existComponent) { - var subType = newCptOption.type - ? newCptOption.type - : existComponent - ? existComponent.subType - // Use determineSubType only when there is no existComponent. - : ComponentModel.determineSubType(mainType, newCptOption); - - // tooltip, markline, markpoint may always has no subType - return subType; - } - - /** - * @inner - */ - function createSeriesIndices(seriesModels) { - return map(seriesModels, function (series) { - return series.componentIndex; - }) || []; - } - - /** - * @inner - */ - function filterBySubType(components, condition) { - // Using hasOwnProperty for restrict. Consider - // subType is undefined in user payload. - return condition.hasOwnProperty('subType') - ? filter(components, function (cpt) { - return cpt.subType === condition.subType; - }) - : components; - } - - /** - * @inner - */ - function assertSeriesInitialized(ecModel) { - // Components that use _seriesIndices should depends on series component, - // which make sure that their initialization is after series. - if (!ecModel._seriesIndices) { - // FIXME - // 验证和提示怎么写 - throw new Error('Series is not initialized. Please depends sereis.'); - } - } - - return GlobalModel; -}); -define('echarts/ExtensionAPI',['require','zrender/core/util'],function(require) { + getBoundingRect: function () { + if (!this._rect) { + var style = this.style; + var rect = textContain.getBoundingRect( + style.text + '', style.textFont || style.font, style.textAlign, style.textBaseline + ); + rect.x += style.x || 0; + rect.y += style.y || 0; + this._rect = rect; + } + return this._rect; + } + }; - + zrUtil.inherits(Text, Displayable); - var zrUtil = require('zrender/core/util'); + module.exports = Text; - var echartsAPIList = [ - 'getDom', 'getZr', 'getWidth', 'getHeight', 'dispatchAction', - 'on', 'off', 'getDataURL', 'getConnectedDataURL', 'getModel', 'getOption' - ]; - function ExtensionAPI(chartInstance) { - zrUtil.each(echartsAPIList, function (name) { - this[name] = zrUtil.bind(chartInstance[name], chartInstance); - }, this); - } +/***/ }, +/* 63 */ +/***/ function(module, exports, __webpack_require__) { - return ExtensionAPI; -}); -define('echarts/CoordinateSystem',['require'],function(require) { + 'use strict'; + /** + * 圆形 + * @module zrender/shape/Circle + */ - - // var zrUtil = require('zrender/core/util'); - var coordinateSystemCreators = {}; - function CoordinateSystemManager() { + module.exports = __webpack_require__(44).extend({ + + type: 'circle', - this._coordinateSystems = []; - } + shape: { + cx: 0, + cy: 0, + r: 0 + }, - CoordinateSystemManager.prototype = { + buildPath : function (ctx, shape) { + // Better stroking in ShapeBundle + ctx.moveTo(shape.cx + shape.r, shape.cy); + ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true); + return; + } + }); - constructor: CoordinateSystemManager, - create: function (ecModel, api) { - var coordinateSystems = []; - for (var type in coordinateSystemCreators) { - var list = coordinateSystemCreators[type].create(ecModel, api); - list && (coordinateSystems = coordinateSystems.concat(list)); - } - this._coordinateSystems = coordinateSystems; - }, +/***/ }, +/* 64 */ +/***/ function(module, exports, __webpack_require__) { - update: function (ecModel, api) { - var coordinateSystems = this._coordinateSystems; - for (var i = 0; i < coordinateSystems.length; i++) { - // FIXME MUST have - coordinateSystems[i].update && coordinateSystems[i].update(ecModel, api); - } - } - }; + /** + * 扇形 + * @module zrender/graphic/shape/Sector + */ - CoordinateSystemManager.register = function (type, coordinateSystemCreator) { - coordinateSystemCreators[type] = coordinateSystemCreator; - }; + // FIXME clockwise seems wrong - CoordinateSystemManager.get = function (type) { - return coordinateSystemCreators[type]; - }; - return CoordinateSystemManager; -}); -/** - * ECharts option manager - * - * @module {echarts/model/OptionManager} - */ - -define('echarts/model/OptionManager',['require','zrender/core/util','../util/model','./Component'],function (require) { - - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../util/model'); - var ComponentModel = require('./Component'); - var each = zrUtil.each; - var clone = zrUtil.clone; - var map = zrUtil.map; - var merge = zrUtil.merge; - - var QUERY_REG = /^(min|max)?(.+)$/; - - /** - * TERM EXPLANATIONS: - * - * [option]: - * - * An object that contains definitions of components. For example: - * var option = { - * title: {...}, - * legend: {...}, - * visualMap: {...}, - * series: [ - * {data: [...]}, - * {data: [...]}, - * ... - * ] - * }; - * - * [rawOption]: - * - * An object input to echarts.setOption. 'rawOption' may be an - * 'option', or may be an object contains multi-options. For example: - * var option = { - * baseOption: { - * title: {...}, - * legend: {...}, - * series: [ - * {data: [...]}, - * {data: [...]}, - * ... - * ] - * }, - * timeline: {...}, - * options: [ - * {title: {...}, series: {data: [...]}}, - * {title: {...}, series: {data: [...]}}, - * ... - * ], - * media: [ - * { - * query: {maxWidth: 320}, - * option: {series: {x: 20}, visualMap: {show: false}} - * }, - * { - * query: {minWidth: 320, maxWidth: 720}, - * option: {series: {x: 500}, visualMap: {show: true}} - * }, - * { - * option: {series: {x: 1200}, visualMap: {show: true}} - * } - * ] - * }; - * - * @alias module:echarts/model/OptionManager - * @param {module:echarts/ExtensionAPI} api - */ - function OptionManager(api) { - - /** - * @private - * @type {module:echarts/ExtensionAPI} - */ - this._api = api; - - /** - * @private - * @type {Array.} - */ - this._timelineOptions = []; - - /** - * @private - * @type {Array.} - */ - this._mediaList = []; - - /** - * @private - * @type {Object} - */ - this._mediaDefault; - - /** - * -1, means default. - * empty means no media. - * @private - * @type {Array.} - */ - this._currentMediaIndices = []; - - /** - * @private - * @type {Object} - */ - this._optionBackup; - - /** - * @private - * @type {Object} - */ - this._newOptionBackup; - } - - // timeline.notMerge is not supported in ec3. Firstly there is rearly - // case that notMerge is needed. Secondly supporting 'notMerge' requires - // rawOption cloned and backuped when timeline changed, which does no - // good to performance. What's more, that both timeline and setOption - // method supply 'notMerge' brings complex and some problems. - // Consider this case: - // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false); - // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false); - - OptionManager.prototype = { - - constructor: OptionManager, - - /** - * @public - * @param {Object} rawOption Raw option. - * @param {module:echarts/model/Global} ecModel - * @param {Array.} optionPreprocessorFuncs - * @return {Object} Init option - */ - setOption: function (rawOption, optionPreprocessorFuncs) { - rawOption = clone(rawOption, true); - - // FIXME - // 如果 timeline options 或者 media 中设置了某个属性,而baseOption中没有设置,则进行警告。 - - var oldOptionBackup = this._optionBackup; - var newOptionBackup = this._newOptionBackup = parseRawOption.call( - this, rawOption, optionPreprocessorFuncs - ); - - // For setOption at second time (using merge mode); - if (oldOptionBackup) { - // Only baseOption can be merged. - mergeOption(oldOptionBackup.baseOption, newOptionBackup.baseOption); - - if (newOptionBackup.timelineOptions.length) { - oldOptionBackup.timelineOptions = newOptionBackup.timelineOptions; - } - if (newOptionBackup.mediaList.length) { - oldOptionBackup.mediaList = newOptionBackup.mediaList; - } - if (newOptionBackup.mediaDefault) { - oldOptionBackup.mediaDefault = newOptionBackup.mediaDefault; - } - } - else { - this._optionBackup = newOptionBackup; - } - }, - - /** - * @param {boolean} isRecreate - * @return {Object} - */ - mountOption: function (isRecreate) { - var optionBackup = isRecreate - // this._optionBackup can be only used when recreate. - // In other cases we use model.mergeOption to handle merge. - ? this._optionBackup : this._newOptionBackup; - - // FIXME - // 如果没有reset功能则不clone。 - - this._timelineOptions = map(optionBackup.timelineOptions, clone); - this._mediaList = map(optionBackup.mediaList, clone); - this._mediaDefault = clone(optionBackup.mediaDefault); - this._currentMediaIndices = []; - - return clone(optionBackup.baseOption); - }, - - /** - * @param {module:echarts/model/Global} ecModel - * @return {Object} - */ - getTimelineOption: function (ecModel) { - var option; - var timelineOptions = this._timelineOptions; - - if (timelineOptions.length) { - // getTimelineOption can only be called after ecModel inited, - // so we can get currentIndex from timelineModel. - var timelineModel = ecModel.getComponent('timeline'); - if (timelineModel) { - option = clone( - timelineOptions[timelineModel.getCurrentIndex()], - true - ); - } - } - - return option; - }, - - /** - * @param {module:echarts/model/Global} ecModel - * @return {Array.} - */ - getMediaOption: function (ecModel) { - var ecWidth = this._api.getWidth(); - var ecHeight = this._api.getHeight(); - var mediaList = this._mediaList; - var mediaDefault = this._mediaDefault; - var indices = []; - var result = []; - - // No media defined. - if (!mediaList.length && !mediaDefault) { - return result; - } - - // Multi media may be applied, the latter defined media has higher priority. - for (var i = 0, len = mediaList.length; i < len; i++) { - if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) { - indices.push(i); - } - } - - // FIXME - // 是否mediaDefault应该强制用户设置,否则可能修改不能回归。 - if (!indices.length && mediaDefault) { - indices = [-1]; - } - - if (indices.length && !indicesEquals(indices, this._currentMediaIndices)) { - result = map(indices, function (index) { - return clone( - index === -1 ? mediaDefault.option : mediaList[index].option - ); - }); - } - // Otherwise return nothing. - - this._currentMediaIndices = indices; - - return result; - } - }; - - function parseRawOption(rawOption, optionPreprocessorFuncs) { - var timelineOptions = []; - var mediaList = []; - var mediaDefault; - var baseOption; - - // Compatible with ec2. - var timelineOpt = rawOption.timeline; - - if (rawOption.baseOption) { - baseOption = rawOption.baseOption; - } - - // For timeline - if (timelineOpt || rawOption.options) { - baseOption = baseOption || {}; - timelineOptions = (rawOption.options || []).slice(); - } - // For media query - if (rawOption.media) { - baseOption = baseOption || {}; - var media = rawOption.media; - each(media, function (singleMedia) { - if (singleMedia && singleMedia.option) { - if (singleMedia.query) { - mediaList.push(singleMedia); - } - else if (!mediaDefault) { - // Use the first media default. - mediaDefault = singleMedia; - } - } - }); - } - - // For normal option - if (!baseOption) { - baseOption = rawOption; - } - - // Set timelineOpt to baseOption in ec3, - // which is convenient for merge option. - if (!baseOption.timeline) { - baseOption.timeline = timelineOpt; - } - - // Preprocess. - each([baseOption].concat(timelineOptions) - .concat(zrUtil.map(mediaList, function (media) { - return media.option; - })), - function (option) { - each(optionPreprocessorFuncs, function (preProcess) { - preProcess(option); - }); - } - ); - - return { - baseOption: baseOption, - timelineOptions: timelineOptions, - mediaDefault: mediaDefault, - mediaList: mediaList - }; - } - - /** - * @see - * Support: width, height, aspectRatio - * Can use max or min as prefix. - */ - function applyMediaQuery(query, ecWidth, ecHeight) { - var realMap = { - width: ecWidth, - height: ecHeight, - aspectratio: ecWidth / ecHeight // lowser case for convenientce. - }; - - var applicatable = true; - - zrUtil.each(query, function (value, attr) { - var matched = attr.match(QUERY_REG); - - if (!matched || !matched[1] || !matched[2]) { - return; - } - - var operator = matched[1]; - var realAttr = matched[2].toLowerCase(); - - if (!compare(realMap[realAttr], value, operator)) { - applicatable = false; - } - }); - - return applicatable; - } - - function compare(real, expect, operator) { - if (operator === 'min') { - return real >= expect; - } - else if (operator === 'max') { - return real <= expect; - } - else { // Equals - return real === expect; - } - } - - function indicesEquals(indices1, indices2) { - // indices is always order by asc and has only finite number. - return indices1.join(',') === indices2.join(','); - } - - /** - * Consider case: - * `chart.setOption(opt1);` - * Then user do some interaction like dataZoom, dataView changing. - * `chart.setOption(opt2);` - * Then user press 'reset button' in toolbox. - * - * After doing that all of the interaction effects should be reset, the - * chart should be the same as the result of invoke - * `chart.setOption(opt1); chart.setOption(opt2);`. - * - * Although it is not able ensure that - * `chart.setOption(opt1); chart.setOption(opt2);` is equivalents to - * `chart.setOption(merge(opt1, opt2));` exactly, - * this might be the only simple way to implement that feature. - * - * MEMO: We've considered some other approaches: - * 1. Each model handle its self restoration but not uniform treatment. - * (Too complex in logic and error-prone) - * 2. Use a shadow ecModel. (Performace expensive) - */ - function mergeOption(oldOption, newOption) { - newOption = newOption || {}; - - each(newOption, function (newCptOpt, mainType) { - if (newCptOpt == null) { - return; - } - - var oldCptOpt = oldOption[mainType]; - - if (!ComponentModel.hasClass(mainType)) { - oldOption[mainType] = merge(oldCptOpt, newCptOpt, true); - } - else { - newCptOpt = modelUtil.normalizeToArray(newCptOpt); - oldCptOpt = modelUtil.normalizeToArray(oldCptOpt); - - var mapResult = modelUtil.mappingToExists(oldCptOpt, newCptOpt); - - oldOption[mainType] = map(mapResult, function (item) { - return (item.option && item.exist) - ? merge(item.exist, item.option, true) - : (item.exist || item.option); - }); - } - }); - } - - return OptionManager; -}); -define('echarts/model/Series',['require','zrender/core/util','../util/format','../util/model','./Component'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var formatUtil = require('../util/format'); - var modelUtil = require('../util/model'); - var ComponentModel = require('./Component'); - - var encodeHTML = formatUtil.encodeHTML; - var addCommas = formatUtil.addCommas; - - var SeriesModel = ComponentModel.extend({ - - type: 'series', - - /** - * @readOnly - */ - seriesIndex: 0, - - // coodinateSystem will be injected in the echarts/CoordinateSystem - coordinateSystem: null, - - /** - * @type {Object} - * @protected - */ - defaultOption: null, - - /** - * Data provided for legend - * @type {Function} - */ - // PENDING - legendDataProvider: null, - - init: function (option, parentModel, ecModel, extraOpt) { - - /** - * @type {number} - * @readOnly - */ - this.seriesIndex = this.componentIndex; - - this.mergeDefaultAndTheme(option, ecModel); - - /** - * @type {module:echarts/data/List|module:echarts/data/Tree|module:echarts/data/Graph} - * @private - */ - this._dataBeforeProcessed = this.getInitialData(option, ecModel); - - // When using module:echarts/data/Tree or module:echarts/data/Graph, - // cloneShallow will cause this._data.graph.data pointing to new data list. - // Wo we make this._dataBeforeProcessed first, and then make this._data. - this._data = this._dataBeforeProcessed.cloneShallow(); - }, - - /** - * Util for merge default and theme to option - * @param {Object} option - * @param {module:echarts/model/Global} ecModel - */ - mergeDefaultAndTheme: function (option, ecModel) { - zrUtil.merge( - option, - ecModel.getTheme().get(this.subType) - ); - zrUtil.merge(option, this.getDefaultOption()); - - // Default label emphasis `position` and `show` - modelUtil.defaultEmphasis( - option.label, ['position', 'show', 'textStyle', 'distance', 'formatter'] - ); - }, - - mergeOption: function (newSeriesOption, ecModel) { - newSeriesOption = zrUtil.merge(this.option, newSeriesOption, true); - - var data = this.getInitialData(newSeriesOption, ecModel); - // TODO Merge data? - if (data) { - this._data = data; - this._dataBeforeProcessed = data.cloneShallow(); - } - }, - - /** - * Init a data structure from data related option in series - * Must be overwritten - */ - getInitialData: function () {}, - - /** - * @return {module:echarts/data/List} - */ - getData: function () { - return this._data; - }, - - /** - * @param {module:echarts/data/List} data - */ - setData: function (data) { - this._data = data; - }, - - /** - * Get data before processed - * @return {module:echarts/data/List} - */ - getRawData: function () { - return this._dataBeforeProcessed; - }, - - /** - * Get raw data array given by user - * @return {Array.} - */ - getRawDataArray: function () { - return this.option.data; - }, - - /** - * Coord dimension to data dimension. - * - * By default the result is the same as dimensions of series data. - * But some series dimensions are different from coord dimensions (i.e. - * candlestick and boxplot). Override this method to handle those cases. - * - * Coord dimension to data dimension can be one-to-many - * - * @param {string} coordDim - * @return {Array.} dimensions on the axis. - */ - coordDimToDataDim: function (coordDim) { - return [coordDim]; - }, - - /** - * Convert data dimension to coord dimension. - * - * @param {string|number} dataDim - * @return {string} - */ - dataDimToCoordDim: function (dataDim) { - return dataDim; - }, - - /** - * Get base axis if has coordinate system and has axis. - * By default use coordSys.getBaseAxis(); - * Can be overrided for some chart. - * @return {type} description - */ - getBaseAxis: function () { - var coordSys = this.coordinateSystem; - return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis(); - }, - - // FIXME - /** - * Default tooltip formatter - * - * @param {number} dataIndex - * @param {boolean} [mutipleSeries=false] - */ - formatTooltip: function (dataIndex, mutipleSeries) { - var data = this._data; - var value = this.getRawValue(dataIndex); - var formattedValue = zrUtil.isArray(value) - ? zrUtil.map(value, addCommas).join(', ') : addCommas(value); - var name = data.getName(dataIndex); - - return !mutipleSeries - ? (encodeHTML(this.name) + '
' - + (name - ? encodeHTML(name) + ' : ' + formattedValue - : formattedValue) - ) - : (encodeHTML(this.name) + ' : ' + formattedValue); - }, - - restoreData: function () { - this._data = this._dataBeforeProcessed.cloneShallow(); - } - }); - - zrUtil.mixin(SeriesModel, modelUtil.dataFormatMixin); - - return SeriesModel; -}); -/** - * zrender: 生成唯一id - * - * @author errorrik (errorrik@gmail.com) - */ - -define( - 'zrender/core/guid',[],function() { - var idStart = 0x0907; - - return function () { - return 'zr_' + (idStart++); - }; - } -); - -/** - * 事件扩展 - * @module zrender/mixin/Eventful - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - * pissang (https://www.github.com/pissang) - */ -define('zrender/mixin/Eventful',['require','../core/util'],function (require) { - - var arrySlice = Array.prototype.slice; - var zrUtil = require('../core/util'); - var indexOf = zrUtil.indexOf; - - /** - * 事件分发器 - * @alias module:zrender/mixin/Eventful - * @constructor - */ - var Eventful = function () { - this._$handlers = {}; - }; - - Eventful.prototype = { - - constructor: Eventful, - - /** - * 单次触发绑定,trigger后销毁 - * - * @param {string} event 事件名 - * @param {Function} handler 响应函数 - * @param {Object} context - */ - one: function (event, handler, context) { - var _h = this._$handlers; - - if (!handler || !event) { - return this; - } - - if (!_h[event]) { - _h[event] = []; - } - - if (indexOf(_h[event], event) >= 0) { - return this; - } - - _h[event].push({ - h: handler, - one: true, - ctx: context || this - }); - - return this; - }, - - /** - * 绑定事件 - * @param {string} event 事件名 - * @param {Function} handler 事件处理函数 - * @param {Object} [context] - */ - on: function (event, handler, context) { - var _h = this._$handlers; - - if (!handler || !event) { - return this; - } - - if (!_h[event]) { - _h[event] = []; - } - - _h[event].push({ - h: handler, - one: false, - ctx: context || this - }); - - return this; - }, - - /** - * 是否绑定了事件 - * @param {string} event - * @return {boolean} - */ - isSilent: function (event) { - var _h = this._$handlers; - return _h[event] && _h[event].length; - }, - - /** - * 解绑事件 - * @param {string} event 事件名 - * @param {Function} [handler] 事件处理函数 - */ - off: function (event, handler) { - var _h = this._$handlers; - - if (!event) { - this._$handlers = {}; - return this; - } - - if (handler) { - if (_h[event]) { - var newList = []; - for (var i = 0, l = _h[event].length; i < l; i++) { - if (_h[event][i]['h'] != handler) { - newList.push(_h[event][i]); - } - } - _h[event] = newList; - } - - if (_h[event] && _h[event].length === 0) { - delete _h[event]; - } - } - else { - delete _h[event]; - } - - return this; - }, - - /** - * 事件分发 - * - * @param {string} type 事件类型 - */ - trigger: function (type) { - if (this._$handlers[type]) { - var args = arguments; - var argLen = args.length; - - if (argLen > 3) { - args = arrySlice.call(args, 1); - } - - var _h = this._$handlers[type]; - var len = _h.length; - for (var i = 0; i < len;) { - // Optimize advise from backbone - switch (argLen) { - case 1: - _h[i]['h'].call(_h[i]['ctx']); - break; - case 2: - _h[i]['h'].call(_h[i]['ctx'], args[1]); - break; - case 3: - _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]); - break; - default: - // have more than 2 given arguments - _h[i]['h'].apply(_h[i]['ctx'], args); - break; - } - - if (_h[i]['one']) { - _h.splice(i, 1); - len--; - } - else { - i++; - } - } - } - - return this; - }, - - /** - * 带有context的事件分发, 最后一个参数是事件回调的context - * @param {string} type 事件类型 - */ - triggerWithContext: function (type) { - if (this._$handlers[type]) { - var args = arguments; - var argLen = args.length; - - if (argLen > 4) { - args = arrySlice.call(args, 1, args.length - 1); - } - var ctx = args[args.length - 1]; - - var _h = this._$handlers[type]; - var len = _h.length; - for (var i = 0; i < len;) { - // Optimize advise from backbone - switch (argLen) { - case 1: - _h[i]['h'].call(ctx); - break; - case 2: - _h[i]['h'].call(ctx, args[1]); - break; - case 3: - _h[i]['h'].call(ctx, args[1], args[2]); - break; - default: - // have more than 2 given arguments - _h[i]['h'].apply(ctx, args); - break; - } - - if (_h[i]['one']) { - _h.splice(i, 1); - len--; - } - else { - i++; - } - } - } - - return this; - } - }; - - // 对象可以通过 onxxxx 绑定事件 - /** - * @event module:zrender/mixin/Eventful#onclick - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmouseover - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmouseout - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmousemove - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmousewheel - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmousedown - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#onmouseup - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragstart - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragend - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragenter - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragleave - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondragover - * @type {Function} - * @default null - */ - /** - * @event module:zrender/mixin/Eventful#ondrop - * @type {Function} - * @default null - */ - - return Eventful; -}); + module.exports = __webpack_require__(44).extend({ -/** - * 提供变换扩展 - * @module zrender/mixin/Transformable - * @author pissang (https://www.github.com/pissang) - */ -define('zrender/mixin/Transformable',['require','../core/matrix','../core/vector'],function (require) { - - - - var matrix = require('../core/matrix'); - var vector = require('../core/vector'); - var mIdentity = matrix.identity; - - var EPSILON = 5e-5; - - function isNotAroundZero(val) { - return val > EPSILON || val < -EPSILON; - } - - /** - * @alias module:zrender/mixin/Transformable - * @constructor - */ - var Transformable = function (opts) { - opts = opts || {}; - // If there are no given position, rotation, scale - if (!opts.position) { - /** - * 平移 - * @type {Array.} - * @default [0, 0] - */ - this.position = [0, 0]; - } - if (opts.rotation == null) { - /** - * 旋转 - * @type {Array.} - * @default 0 - */ - this.rotation = 0; - } - if (!opts.scale) { - /** - * 缩放 - * @type {Array.} - * @default [1, 1] - */ - this.scale = [1, 1]; - } - /** - * 旋转和缩放的原点 - * @type {Array.} - * @default null - */ - this.origin = this.origin || null; - }; - - var transformableProto = Transformable.prototype; - transformableProto.transform = null; - - /** - * 判断是否需要有坐标变换 - * 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵 - */ - transformableProto.needLocalTransform = function () { - return isNotAroundZero(this.rotation) - || isNotAroundZero(this.position[0]) - || isNotAroundZero(this.position[1]) - || isNotAroundZero(this.scale[0] - 1) - || isNotAroundZero(this.scale[1] - 1); - }; - - transformableProto.updateTransform = function () { - var parent = this.parent; - var parentHasTransform = parent && parent.transform; - var needLocalTransform = this.needLocalTransform(); - - var m = this.transform; - if (!(needLocalTransform || parentHasTransform)) { - m && mIdentity(m); - return; - } - - m = m || matrix.create(); - - if (needLocalTransform) { - this.getLocalTransform(m); - } - else { - mIdentity(m); - } - - // 应用父节点变换 - if (parentHasTransform) { - if (needLocalTransform) { - matrix.mul(m, parent.transform, m); - } - else { - matrix.copy(m, parent.transform); - } - } - // 保存这个变换矩阵 - this.transform = m; - - this.invTransform = this.invTransform || matrix.create(); - matrix.invert(this.invTransform, m); - }; - - transformableProto.getLocalTransform = function (m) { - m = m || []; - mIdentity(m); - - var origin = this.origin; - - var scale = this.scale; - var rotation = this.rotation; - var position = this.position; - if (origin) { - // Translate to origin - m[4] -= origin[0]; - m[5] -= origin[1]; - } - matrix.scale(m, m, scale); - if (rotation) { - matrix.rotate(m, m, rotation); - } - if (origin) { - // Translate back from origin - m[4] += origin[0]; - m[5] += origin[1]; - } - - m[4] += position[0]; - m[5] += position[1]; - - return m; - }; - /** - * 将自己的transform应用到context上 - * @param {Context2D} ctx - */ - transformableProto.setTransform = function (ctx) { - var m = this.transform; - if (m) { - ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); - } - }; - - var tmpTransform = []; - - /** - * 分解`transform`矩阵到`position`, `rotation`, `scale` - */ - transformableProto.decomposeTransform = function () { - if (!this.transform) { - return; - } - var parent = this.parent; - var m = this.transform; - if (parent && parent.transform) { - // Get local transform and decompose them to position, scale, rotation - matrix.mul(tmpTransform, parent.invTransform, m); - m = tmpTransform; - } - var sx = m[0] * m[0] + m[1] * m[1]; - var sy = m[2] * m[2] + m[3] * m[3]; - var position = this.position; - var scale = this.scale; - if (isNotAroundZero(sx - 1)) { - sx = Math.sqrt(sx); - } - if (isNotAroundZero(sy - 1)) { - sy = Math.sqrt(sy); - } - if (m[0] < 0) { - sx = -sx; - } - if (m[3] < 0) { - sy = -sy; - } - position[0] = m[4]; - position[1] = m[5]; - scale[0] = sx; - scale[1] = sy; - this.rotation = Math.atan2(-m[1] / sy, m[0] / sx); - }; - - /** - * 变换坐标位置到 shape 的局部坐标空间 - * @method - * @param {number} x - * @param {number} y - * @return {Array.} - */ - transformableProto.transformCoordToLocal = function (x, y) { - var v2 = [x, y]; - var invTransform = this.invTransform; - if (invTransform) { - vector.applyTransform(v2, v2, invTransform); - } - return v2; - }; - - /** - * 变换局部坐标位置到全局坐标空间 - * @method - * @param {number} x - * @param {number} y - * @return {Array.} - */ - transformableProto.transformCoordToGlobal = function (x, y) { - var v2 = [x, y]; - var transform = this.transform; - if (transform) { - vector.applyTransform(v2, v2, transform); - } - return v2; - }; - - return Transformable; -}); + type: 'sector', -/** - * 缓动代码来自 https://github.com/sole/tween.js/blob/master/src/Tween.js - * @see http://sole.github.io/tween.js/examples/03_graphs.html - * @exports zrender/animation/easing - */ -define('zrender/animation/easing',[],function () { - var easing = { - /** - * @param {number} k - * @return {number} - */ - linear: function (k) { - return k; - }, - - /** - * @param {number} k - * @return {number} - */ - quadraticIn: function (k) { - return k * k; - }, - /** - * @param {number} k - * @return {number} - */ - quadraticOut: function (k) { - return k * (2 - k); - }, - /** - * @param {number} k - * @return {number} - */ - quadraticInOut: function (k) { - if ((k *= 2) < 1) { - return 0.5 * k * k; - } - return -0.5 * (--k * (k - 2) - 1); - }, - - // 三次方的缓动(t^3) - /** - * @param {number} k - * @return {number} - */ - cubicIn: function (k) { - return k * k * k; - }, - /** - * @param {number} k - * @return {number} - */ - cubicOut: function (k) { - return --k * k * k + 1; - }, - /** - * @param {number} k - * @return {number} - */ - cubicInOut: function (k) { - if ((k *= 2) < 1) { - return 0.5 * k * k * k; - } - return 0.5 * ((k -= 2) * k * k + 2); - }, - - // 四次方的缓动(t^4) - /** - * @param {number} k - * @return {number} - */ - quarticIn: function (k) { - return k * k * k * k; - }, - /** - * @param {number} k - * @return {number} - */ - quarticOut: function (k) { - return 1 - (--k * k * k * k); - }, - /** - * @param {number} k - * @return {number} - */ - quarticInOut: function (k) { - if ((k *= 2) < 1) { - return 0.5 * k * k * k * k; - } - return -0.5 * ((k -= 2) * k * k * k - 2); - }, - - // 五次方的缓动(t^5) - /** - * @param {number} k - * @return {number} - */ - quinticIn: function (k) { - return k * k * k * k * k; - }, - /** - * @param {number} k - * @return {number} - */ - quinticOut: function (k) { - return --k * k * k * k * k + 1; - }, - /** - * @param {number} k - * @return {number} - */ - quinticInOut: function (k) { - if ((k *= 2) < 1) { - return 0.5 * k * k * k * k * k; - } - return 0.5 * ((k -= 2) * k * k * k * k + 2); - }, - - // 正弦曲线的缓动(sin(t)) - /** - * @param {number} k - * @return {number} - */ - sinusoidalIn: function (k) { - return 1 - Math.cos(k * Math.PI / 2); - }, - /** - * @param {number} k - * @return {number} - */ - sinusoidalOut: function (k) { - return Math.sin(k * Math.PI / 2); - }, - /** - * @param {number} k - * @return {number} - */ - sinusoidalInOut: function (k) { - return 0.5 * (1 - Math.cos(Math.PI * k)); - }, - - // 指数曲线的缓动(2^t) - /** - * @param {number} k - * @return {number} - */ - exponentialIn: function (k) { - return k === 0 ? 0 : Math.pow(1024, k - 1); - }, - /** - * @param {number} k - * @return {number} - */ - exponentialOut: function (k) { - return k === 1 ? 1 : 1 - Math.pow(2, -10 * k); - }, - /** - * @param {number} k - * @return {number} - */ - exponentialInOut: function (k) { - if (k === 0) { - return 0; - } - if (k === 1) { - return 1; - } - if ((k *= 2) < 1) { - return 0.5 * Math.pow(1024, k - 1); - } - return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2); - }, - - // 圆形曲线的缓动(sqrt(1-t^2)) - /** - * @param {number} k - * @return {number} - */ - circularIn: function (k) { - return 1 - Math.sqrt(1 - k * k); - }, - /** - * @param {number} k - * @return {number} - */ - circularOut: function (k) { - return Math.sqrt(1 - (--k * k)); - }, - /** - * @param {number} k - * @return {number} - */ - circularInOut: function (k) { - if ((k *= 2) < 1) { - return -0.5 * (Math.sqrt(1 - k * k) - 1); - } - return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); - }, - - // 创建类似于弹簧在停止前来回振荡的动画 - /** - * @param {number} k - * @return {number} - */ - elasticIn: function (k) { - var s; - var a = 0.1; - var p = 0.4; - if (k === 0) { - return 0; - } - if (k === 1) { - return 1; - } - if (!a || a < 1) { - a = 1; s = p / 4; - } - else { - s = p * Math.asin(1 / a) / (2 * Math.PI); - } - return -(a * Math.pow(2, 10 * (k -= 1)) * - Math.sin((k - s) * (2 * Math.PI) / p)); - }, - /** - * @param {number} k - * @return {number} - */ - elasticOut: function (k) { - var s; - var a = 0.1; - var p = 0.4; - if (k === 0) { - return 0; - } - if (k === 1) { - return 1; - } - if (!a || a < 1) { - a = 1; s = p / 4; - } - else { - s = p * Math.asin(1 / a) / (2 * Math.PI); - } - return (a * Math.pow(2, -10 * k) * - Math.sin((k - s) * (2 * Math.PI) / p) + 1); - }, - /** - * @param {number} k - * @return {number} - */ - elasticInOut: function (k) { - var s; - var a = 0.1; - var p = 0.4; - if (k === 0) { - return 0; - } - if (k === 1) { - return 1; - } - if (!a || a < 1) { - a = 1; s = p / 4; - } - else { - s = p * Math.asin(1 / a) / (2 * Math.PI); - } - if ((k *= 2) < 1) { - return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) - * Math.sin((k - s) * (2 * Math.PI) / p)); - } - return a * Math.pow(2, -10 * (k -= 1)) - * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1; - - }, - - // 在某一动画开始沿指示的路径进行动画处理前稍稍收回该动画的移动 - /** - * @param {number} k - * @return {number} - */ - backIn: function (k) { - var s = 1.70158; - return k * k * ((s + 1) * k - s); - }, - /** - * @param {number} k - * @return {number} - */ - backOut: function (k) { - var s = 1.70158; - return --k * k * ((s + 1) * k + s) + 1; - }, - /** - * @param {number} k - * @return {number} - */ - backInOut: function (k) { - var s = 1.70158 * 1.525; - if ((k *= 2) < 1) { - return 0.5 * (k * k * ((s + 1) * k - s)); - } - return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); - }, - - // 创建弹跳效果 - /** - * @param {number} k - * @return {number} - */ - bounceIn: function (k) { - return 1 - easing.bounceOut(1 - k); - }, - /** - * @param {number} k - * @return {number} - */ - bounceOut: function (k) { - if (k < (1 / 2.75)) { - return 7.5625 * k * k; - } - else if (k < (2 / 2.75)) { - return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75; - } - else if (k < (2.5 / 2.75)) { - return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375; - } - else { - return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; - } - }, - /** - * @param {number} k - * @return {number} - */ - bounceInOut: function (k) { - if (k < 0.5) { - return easing.bounceIn(k * 2) * 0.5; - } - return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5; - } - }; - - return easing; -}); + shape: { + cx: 0, -/** - * 动画主控制器 - * @config target 动画对象,可以是数组,如果是数组的话会批量分发onframe等事件 - * @config life(1000) 动画时长 - * @config delay(0) 动画延迟时间 - * @config loop(true) - * @config gap(0) 循环的间隔时间 - * @config onframe - * @config easing(optional) - * @config ondestroy(optional) - * @config onrestart(optional) - * - * TODO pause - */ -define('zrender/animation/Clip',['require','./easing'],function(require) { - - var easingFuncs = require('./easing'); - - function Clip(options) { - - this._target = options.target; - - // 生命周期 - this._life = options.life || 1000; - // 延时 - this._delay = options.delay || 0; - // 开始时间 - // this._startTime = new Date().getTime() + this._delay;// 单位毫秒 - this._initialized = false; - - // 是否循环 - this.loop = options.loop == null ? false : options.loop; - - this.gap = options.gap || 0; - - this.easing = options.easing || 'Linear'; - - this.onframe = options.onframe; - this.ondestroy = options.ondestroy; - this.onrestart = options.onrestart; - } - - Clip.prototype = { - - constructor: Clip, - - step: function (time) { - // Set startTime on first step, or _startTime may has milleseconds different between clips - // PENDING - if (!this._initialized) { - this._startTime = new Date().getTime() + this._delay; - this._initialized = true; - } - - var percent = (time - this._startTime) / this._life; - - // 还没开始 - if (percent < 0) { - return; - } - - percent = Math.min(percent, 1); - - var easing = this.easing; - var easingFunc = typeof easing == 'string' ? easingFuncs[easing] : easing; - var schedule = typeof easingFunc === 'function' - ? easingFunc(percent) - : percent; - - this.fire('frame', schedule); - - // 结束 - if (percent == 1) { - if (this.loop) { - this.restart(); - // 重新开始周期 - // 抛出而不是直接调用事件直到 stage.update 后再统一调用这些事件 - return 'restart'; - } - - // 动画完成将这个控制器标识为待删除 - // 在Animation.update中进行批量删除 - this._needsRemove = true; - return 'destroy'; - } - - return null; - }, - - restart: function() { - var time = new Date().getTime(); - var remainder = (time - this._startTime) % this._life; - this._startTime = new Date().getTime() - remainder + this.gap; - - this._needsRemove = false; - }, - - fire: function(eventType, arg) { - eventType = 'on' + eventType; - if (this[eventType]) { - this[eventType](this._target, arg); - } - } - }; - - return Clip; -}); + cy: 0, -/** - * @module zrender/tool/color - */ -define('zrender/tool/color',['require'],function(require) { - - var kCSSColorTable = { - 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1], - 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1], - 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1], - 'beige': [245,245,220,1], 'bisque': [255,228,196,1], - 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1], - 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1], - 'brown': [165,42,42,1], 'burlywood': [222,184,135,1], - 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1], - 'chocolate': [210,105,30,1], 'coral': [255,127,80,1], - 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1], - 'crimson': [220,20,60,1], 'cyan': [0,255,255,1], - 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1], - 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1], - 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1], - 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1], - 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1], - 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1], - 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1], - 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1], - 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1], - 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1], - 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1], - 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1], - 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1], - 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1], - 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1], - 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1], - 'gray': [128,128,128,1], 'green': [0,128,0,1], - 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1], - 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1], - 'indianred': [205,92,92,1], 'indigo': [75,0,130,1], - 'ivory': [255,255,240,1], 'khaki': [240,230,140,1], - 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1], - 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1], - 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1], - 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1], - 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1], - 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1], - 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1], - 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1], - 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1], - 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1], - 'limegreen': [50,205,50,1], 'linen': [250,240,230,1], - 'magenta': [255,0,255,1], 'maroon': [128,0,0,1], - 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1], - 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1], - 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1], - 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1], - 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1], - 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1], - 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1], - 'navy': [0,0,128,1], 'oldlace': [253,245,230,1], - 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1], - 'orange': [255,165,0,1], 'orangered': [255,69,0,1], - 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1], - 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1], - 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1], - 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1], - 'pink': [255,192,203,1], 'plum': [221,160,221,1], - 'powderblue': [176,224,230,1], 'purple': [128,0,128,1], - 'red': [255,0,0,1], 'rosybrown': [188,143,143,1], - 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1], - 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1], - 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1], - 'sienna': [160,82,45,1], 'silver': [192,192,192,1], - 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1], - 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1], - 'snow': [255,250,250,1], 'springgreen': [0,255,127,1], - 'steelblue': [70,130,180,1], 'tan': [210,180,140,1], - 'teal': [0,128,128,1], 'thistle': [216,191,216,1], - 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1], - 'violet': [238,130,238,1], 'wheat': [245,222,179,1], - 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1], - 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1] - }; - - function clampCssByte(i) { // Clamp to integer 0 .. 255. - i = Math.round(i); // Seems to be what Chrome does (vs truncation). - return i < 0 ? 0 : i > 255 ? 255 : i; - } - - function clampCssAngle(i) { // Clamp to integer 0 .. 360. - i = Math.round(i); // Seems to be what Chrome does (vs truncation). - return i < 0 ? 0 : i > 360 ? 360 : i; - } - - function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0. - return f < 0 ? 0 : f > 1 ? 1 : f; - } - - function parseCssInt(str) { // int or percentage. - if (str.length && str.charAt(str.length - 1) === '%') { - return clampCssByte(parseFloat(str) / 100 * 255); - } - return clampCssByte(parseInt(str, 10)); - } - - function parseCssFloat(str) { // float or percentage. - if (str.length && str.charAt(str.length - 1) === '%') { - return clampCssFloat(parseFloat(str) / 100); - } - return clampCssFloat(parseFloat(str)); - } - - function cssHueToRgb(m1, m2, h) { - if (h < 0) { - h += 1; - } - else if (h > 1) { - h -= 1; - } - - if (h * 6 < 1) { - return m1 + (m2 - m1) * h * 6; - } - if (h * 2 < 1) { - return m2; - } - if (h * 3 < 2) { - return m1 + (m2 - m1) * (2/3 - h) * 6; - } - return m1; - } - - function lerp(a, b, p) { - return a + (b - a) * p; - } - - /** - * @param {string} colorStr - * @return {Array.} - * @memberOf module:zrender/util/color - */ - function parse(colorStr) { - if (!colorStr) { - return; - } - // colorStr may be not string - colorStr = colorStr + ''; - // Remove all whitespace, not compliant, but should just be more accepting. - var str = colorStr.replace(/ /g, '').toLowerCase(); - - // Color keywords (and transparent) lookup. - if (str in kCSSColorTable) { - return kCSSColorTable[str].slice(); // dup. - } - - // #abc and #abc123 syntax. - if (str.charAt(0) === '#') { - if (str.length === 4) { - var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. - if (!(iv >= 0 && iv <= 0xfff)) { - return; // Covers NaN. - } - return [ - ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8), - (iv & 0xf0) | ((iv & 0xf0) >> 4), - (iv & 0xf) | ((iv & 0xf) << 4), - 1 - ]; - } - else if (str.length === 7) { - var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. - if (!(iv >= 0 && iv <= 0xffffff)) { - return; // Covers NaN. - } - return [ - (iv & 0xff0000) >> 16, - (iv & 0xff00) >> 8, - iv & 0xff, - 1 - ]; - } - - return; - } - var op = str.indexOf('('), ep = str.indexOf(')'); - if (op !== -1 && ep + 1 === str.length) { - var fname = str.substr(0, op); - var params = str.substr(op + 1, ep - (op + 1)).split(','); - var alpha = 1; // To allow case fallthrough. - switch (fname) { - case 'rgba': - if (params.length !== 4) { - return; - } - alpha = parseCssFloat(params.pop()); // jshint ignore:line - // Fall through. - case 'rgb': - if (params.length !== 3) { - return; - } - return [ - parseCssInt(params[0]), - parseCssInt(params[1]), - parseCssInt(params[2]), - alpha - ]; - case 'hsla': - if (params.length !== 4) { - return; - } - params[3] = parseCssFloat(params[3]); - return hsla2rgba(params); - case 'hsl': - if (params.length !== 3) { - return; - } - return hsla2rgba(params); - default: - return; - } - } - - return; - } - - /** - * @param {Array.} hsla - * @return {Array.} rgba - */ - function hsla2rgba(hsla) { - var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1 - // NOTE(deanm): According to the CSS spec s/l should only be - // percentages, but we don't bother and let float or percentage. - var s = parseCssFloat(hsla[1]); - var l = parseCssFloat(hsla[2]); - var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; - var m1 = l * 2 - m2; - - var rgba = [ - clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255), - clampCssByte(cssHueToRgb(m1, m2, h) * 255), - clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255) - ]; - - if (hsla.length === 4) { - rgba[3] = hsla[3]; - } - - return rgba; - } - - /** - * @param {Array.} rgba - * @return {Array.} hsla - */ - function rgba2hsla(rgba) { - if (!rgba) { - return; - } - - // RGB from 0 to 255 - var R = rgba[0] / 255; - var G = rgba[1] / 255; - var B = rgba[2] / 255; - - var vMin = Math.min(R, G, B); // Min. value of RGB - var vMax = Math.max(R, G, B); // Max. value of RGB - var delta = vMax - vMin; // Delta RGB value - - var L = (vMax + vMin) / 2; - var H; - var S; - // HSL results from 0 to 1 - if (delta === 0) { - H = 0; - S = 0; - } - else { - if (L < 0.5) { - S = delta / (vMax + vMin); - } - else { - S = delta / (2 - vMax - vMin); - } - - var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta; - var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta; - var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta; - - if (R === vMax) { - H = deltaB - deltaG; - } - else if (G === vMax) { - H = (1 / 3) + deltaR - deltaB; - } - else if (B === vMax) { - H = (2 / 3) + deltaG - deltaR; - } - - if (H < 0) { - H += 1; - } - - if (H > 1) { - H -= 1; - } - } - - var hsla = [H * 360, S, L]; - - if (rgba[3] != null) { - hsla.push(rgba[3]); - } - - return hsla; - } - - /** - * @param {string} color - * @param {number} level - * @return {string} - * @memberOf module:zrender/util/color - */ - function lift(color, level) { - var colorArr = parse(color); - if (colorArr) { - for (var i = 0; i < 3; i++) { - if (level < 0) { - colorArr[i] = colorArr[i] * (1 - level) | 0; - } - else { - colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0; - } - } - return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb'); - } - } - - /** - * @param {string} color - * @return {string} - * @memberOf module:zrender/util/color - */ - function toHex(color, level) { - var colorArr = parse(color); - if (colorArr) { - return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1); - } - } - - /** - * Map value to color. Faster than mapToColor methods because color is represented by rgba array - * @param {number} normalizedValue A float between 0 and 1. - * @param {Array.>} colors List of rgba color array - * @param {Array.} [out] Mapped gba color array - * @return {Array.} - */ - function fastMapToColor(normalizedValue, colors, out) { - if (!(colors && colors.length) - || !(normalizedValue >= 0 && normalizedValue <= 1) - ) { - return; - } - out = out || [0, 0, 0, 0]; - var value = normalizedValue * (colors.length - 1); - var leftIndex = Math.floor(value); - var rightIndex = Math.ceil(value); - var leftColor = colors[leftIndex]; - var rightColor = colors[rightIndex]; - var dv = value - leftIndex; - out[0] = clampCssByte(lerp(leftColor[0], rightColor[0], dv)); - out[1] = clampCssByte(lerp(leftColor[1], rightColor[1], dv)); - out[2] = clampCssByte(lerp(leftColor[2], rightColor[2], dv)); - out[3] = clampCssByte(lerp(leftColor[3], rightColor[3], dv)); - return out; - } - /** - * @param {number} normalizedValue A float between 0 and 1. - * @param {Array.} colors Color list. - * @param {boolean=} fullOutput Default false. - * @return {(string|Object)} Result color. If fullOutput, - * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...}, - * @memberOf module:zrender/util/color - */ - function mapToColor(normalizedValue, colors, fullOutput) { - if (!(colors && colors.length) - || !(normalizedValue >= 0 && normalizedValue <= 1) - ) { - return; - } - - var value = normalizedValue * (colors.length - 1); - var leftIndex = Math.floor(value); - var rightIndex = Math.ceil(value); - var leftColor = parse(colors[leftIndex]); - var rightColor = parse(colors[rightIndex]); - var dv = value - leftIndex; - - var color = stringify( - [ - clampCssByte(lerp(leftColor[0], rightColor[0], dv)), - clampCssByte(lerp(leftColor[1], rightColor[1], dv)), - clampCssByte(lerp(leftColor[2], rightColor[2], dv)), - clampCssFloat(lerp(leftColor[3], rightColor[3], dv)) - ], - 'rgba' - ); - - return fullOutput - ? { - color: color, - leftIndex: leftIndex, - rightIndex: rightIndex, - value: value - } - : color; - } - - /** - * @param {Array} interval Array length === 2, - * each item is normalized value ([0, 1]). - * @param {Array.} colors Color list. - * @return {Array.} colors corresponding to the interval, - * each item is {color: 'xxx', offset: ...} - * where offset is between 0 and 1. - * @memberOf module:zrender/util/color - */ - function mapIntervalToColor(interval, colors) { - if (interval.length !== 2 || interval[1] < interval[0]) { - return; - } - - var info0 = mapToColor(interval[0], colors, true); - var info1 = mapToColor(interval[1], colors, true); - - var result = [{color: info0.color, offset: 0}]; - - var during = info1.value - info0.value; - var start = Math.max(info0.value, info0.rightIndex); - var end = Math.min(info1.value, info1.leftIndex); - - for (var i = start; during > 0 && i <= end; i++) { - result.push({ - color: colors[i], - offset: (i - info0.value) / during - }); - } - result.push({color: info1.color, offset: 1}); - - return result; - } - - /** - * @param {string} color - * @param {number=} h 0 ~ 360, ignore when null. - * @param {number=} s 0 ~ 1, ignore when null. - * @param {number=} l 0 ~ 1, ignore when null. - * @return {string} Color string in rgba format. - * @memberOf module:zrender/util/color - */ - function modifyHSL(color, h, s, l) { - color = parse(color); - - if (color) { - color = rgba2hsla(color); - h != null && (color[0] = clampCssAngle(h)); - s != null && (color[1] = parseCssFloat(s)); - l != null && (color[2] = parseCssFloat(l)); - - return stringify(hsla2rgba(color), 'rgba'); - } - } - - /** - * @param {string} color - * @param {number=} alpha 0 ~ 1 - * @return {string} Color string in rgba format. - * @memberOf module:zrender/util/color - */ - function modifyAlpha(color, alpha) { - color = parse(color); - - if (color && alpha != null) { - color[3] = clampCssFloat(alpha); - return stringify(color, 'rgba'); - } - } - - /** - * @param {Array.} colors Color list. - * @param {string} type 'rgba', 'hsva', ... - * @return {string} Result color. - */ - function stringify(arrColor, type) { - if (type === 'rgb' || type === 'hsv' || type === 'hsl') { - arrColor = arrColor.slice(0, 3); - } - return type + '(' + arrColor.join(',') + ')'; - } - - return { - parse: parse, - lift: lift, - toHex: toHex, - fastMapToColor: fastMapToColor, - mapToColor: mapToColor, - mapIntervalToColor: mapIntervalToColor, - modifyHSL: modifyHSL, - modifyAlpha: modifyAlpha, - stringify: stringify - }; -}); + r0: 0, + r: 0, -/** - * @module echarts/animation/Animator - */ -define('zrender/animation/Animator',['require','./Clip','../tool/color','../core/util'],function (require) { - - var Clip = require('./Clip'); - var color = require('../tool/color'); - var util = require('../core/util'); - var isArrayLike = util.isArrayLike; - - var arraySlice = Array.prototype.slice; - - function defaultGetter(target, key) { - return target[key]; - } - - function defaultSetter(target, key, value) { - target[key] = value; - } - - /** - * @param {number} p0 - * @param {number} p1 - * @param {number} percent - * @return {number} - */ - function interpolateNumber(p0, p1, percent) { - return (p1 - p0) * percent + p0; - } - - /** - * @param {string} p0 - * @param {string} p1 - * @param {number} percent - * @return {string} - */ - function interpolateString(p0, p1, percent) { - return percent > 0.5 ? p1 : p0; - } - - /** - * @param {Array} p0 - * @param {Array} p1 - * @param {number} percent - * @param {Array} out - * @param {number} arrDim - */ - function interpolateArray(p0, p1, percent, out, arrDim) { - var len = p0.length; - if (arrDim == 1) { - for (var i = 0; i < len; i++) { - out[i] = interpolateNumber(p0[i], p1[i], percent); - } - } - else { - var len2 = p0[0].length; - for (var i = 0; i < len; i++) { - for (var j = 0; j < len2; j++) { - out[i][j] = interpolateNumber( - p0[i][j], p1[i][j], percent - ); - } - } - } - } - - function fillArr(arr0, arr1, arrDim) { - var arr0Len = arr0.length; - var arr1Len = arr1.length; - if (arr0Len === arr1Len) { - return; - } - // FIXME Not work for TypedArray - var isPreviousLarger = arr0Len > arr1Len; - if (isPreviousLarger) { - // Cut the previous - arr0.length = arr1Len; - } - else { - // Fill the previous - for (var i = arr0Len; i < arr1Len; i++) { - arr0.push( - arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i]) - ); - } - } - } - - /** - * @param {Array} arr0 - * @param {Array} arr1 - * @param {number} arrDim - * @return {boolean} - */ - function isArraySame(arr0, arr1, arrDim) { - if (arr0 === arr1) { - return true; - } - var len = arr0.length; - if (len !== arr1.length) { - return false; - } - if (arrDim === 1) { - for (var i = 0; i < len; i++) { - if (arr0[i] !== arr1[i]) { - return false; - } - } - } - else { - var len2 = arr0[0].length; - for (var i = 0; i < len; i++) { - for (var j = 0; j < len2; j++) { - if (arr0[i][j] !== arr1[i][j]) { - return false; - } - } - } - } - return true; - } - - /** - * Catmull Rom interpolate array - * @param {Array} p0 - * @param {Array} p1 - * @param {Array} p2 - * @param {Array} p3 - * @param {number} t - * @param {number} t2 - * @param {number} t3 - * @param {Array} out - * @param {number} arrDim - */ - function catmullRomInterpolateArray( - p0, p1, p2, p3, t, t2, t3, out, arrDim - ) { - var len = p0.length; - if (arrDim == 1) { - for (var i = 0; i < len; i++) { - out[i] = catmullRomInterpolate( - p0[i], p1[i], p2[i], p3[i], t, t2, t3 - ); - } - } - else { - var len2 = p0[0].length; - for (var i = 0; i < len; i++) { - for (var j = 0; j < len2; j++) { - out[i][j] = catmullRomInterpolate( - p0[i][j], p1[i][j], p2[i][j], p3[i][j], - t, t2, t3 - ); - } - } - } - } - - /** - * Catmull Rom interpolate number - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} t - * @param {number} t2 - * @param {number} t3 - * @return {number} - */ - function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) { - var v0 = (p2 - p0) * 0.5; - var v1 = (p3 - p1) * 0.5; - return (2 * (p1 - p2) + v0 + v1) * t3 - + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 - + v0 * t + p1; - } - - function cloneValue(value) { - if (isArrayLike(value)) { - var len = value.length; - if (isArrayLike(value[0])) { - var ret = []; - for (var i = 0; i < len; i++) { - ret.push(arraySlice.call(value[i])); - } - return ret; - } - - return arraySlice.call(value); - } - - return value; - } - - function rgba2String(rgba) { - rgba[0] = Math.floor(rgba[0]); - rgba[1] = Math.floor(rgba[1]); - rgba[2] = Math.floor(rgba[2]); - - return 'rgba(' + rgba.join(',') + ')'; - } - - function createTrackClip (animator, easing, oneTrackDone, keyframes, propName) { - var getter = animator._getter; - var setter = animator._setter; - var useSpline = easing === 'spline'; - - var trackLen = keyframes.length; - if (!trackLen) { - return; - } - // Guess data type - var firstVal = keyframes[0].value; - var isValueArray = isArrayLike(firstVal); - var isValueColor = false; - var isValueString = false; - - // For vertices morphing - var arrDim = ( - isValueArray - && isArrayLike(firstVal[0]) - ) - ? 2 : 1; - var trackMaxTime; - // Sort keyframe as ascending - keyframes.sort(function(a, b) { - return a.time - b.time; - }); - - trackMaxTime = keyframes[trackLen - 1].time; - // Percents of each keyframe - var kfPercents = []; - // Value of each keyframe - var kfValues = []; - var prevValue = keyframes[0].value; - var isAllValueEqual = true; - for (var i = 0; i < trackLen; i++) { - kfPercents.push(keyframes[i].time / trackMaxTime); - // Assume value is a color when it is a string - var value = keyframes[i].value; - - // Check if value is equal, deep check if value is array - if (!((isValueArray && isArraySame(value, prevValue, arrDim)) - || (!isValueArray && value === prevValue))) { - isAllValueEqual = false; - } - prevValue = value; - - // Try converting a string to a color array - if (typeof value == 'string') { - var colorArray = color.parse(value); - if (colorArray) { - value = colorArray; - isValueColor = true; - } - else { - isValueString = true; - } - } - kfValues.push(value); - } - if (isAllValueEqual) { - return; - } - - if (isValueArray) { - var lastValue = kfValues[trackLen - 1]; - // Polyfill array - for (var i = 0; i < trackLen - 1; i++) { - fillArr(kfValues[i], lastValue, arrDim); - } - fillArr(getter(animator._target, propName), lastValue, arrDim); - } - - // Cache the key of last frame to speed up when - // animation playback is sequency - var lastFrame = 0; - var lastFramePercent = 0; - var start; - var w; - var p0; - var p1; - var p2; - var p3; - - if (isValueColor) { - var rgba = [0, 0, 0, 0]; - } - - var onframe = function (target, percent) { - // Find the range keyframes - // kf1-----kf2---------current--------kf3 - // find kf2 and kf3 and do interpolation - var frame; - if (percent < lastFramePercent) { - // Start from next key - start = Math.min(lastFrame + 1, trackLen - 1); - for (frame = start; frame >= 0; frame--) { - if (kfPercents[frame] <= percent) { - break; - } - } - frame = Math.min(frame, trackLen - 2); - } - else { - for (frame = lastFrame; frame < trackLen; frame++) { - if (kfPercents[frame] > percent) { - break; - } - } - frame = Math.min(frame - 1, trackLen - 2); - } - lastFrame = frame; - lastFramePercent = percent; - - var range = (kfPercents[frame + 1] - kfPercents[frame]); - if (range === 0) { - return; - } - else { - w = (percent - kfPercents[frame]) / range; - } - if (useSpline) { - p1 = kfValues[frame]; - p0 = kfValues[frame === 0 ? frame : frame - 1]; - p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1]; - p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2]; - if (isValueArray) { - catmullRomInterpolateArray( - p0, p1, p2, p3, w, w * w, w * w * w, - getter(target, propName), - arrDim - ); - } - else { - var value; - if (isValueColor) { - value = catmullRomInterpolateArray( - p0, p1, p2, p3, w, w * w, w * w * w, - rgba, 1 - ); - value = rgba2String(rgba); - } - else if (isValueString) { - // String is step(0.5) - return interpolateString(p1, p2, w); - } - else { - value = catmullRomInterpolate( - p0, p1, p2, p3, w, w * w, w * w * w - ); - } - setter( - target, - propName, - value - ); - } - } - else { - if (isValueArray) { - interpolateArray( - kfValues[frame], kfValues[frame + 1], w, - getter(target, propName), - arrDim - ); - } - else { - var value; - if (isValueColor) { - interpolateArray( - kfValues[frame], kfValues[frame + 1], w, - rgba, 1 - ); - value = rgba2String(rgba); - } - else if (isValueString) { - // String is step(0.5) - return interpolateString(kfValues[frame], kfValues[frame + 1], w); - } - else { - value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w); - } - setter( - target, - propName, - value - ); - } - } - }; - - var clip = new Clip({ - target: animator._target, - life: trackMaxTime, - loop: animator._loop, - delay: animator._delay, - onframe: onframe, - ondestroy: oneTrackDone - }); - - if (easing && easing !== 'spline') { - clip.easing = easing; - } - - return clip; - } - - /** - * @alias module:zrender/animation/Animator - * @constructor - * @param {Object} target - * @param {boolean} loop - * @param {Function} getter - * @param {Function} setter - */ - var Animator = function(target, loop, getter, setter) { - this._tracks = {}; - this._target = target; - - this._loop = loop || false; - - this._getter = getter || defaultGetter; - this._setter = setter || defaultSetter; - - this._clipCount = 0; - - this._delay = 0; - - this._doneList = []; - - this._onframeList = []; - - this._clipList = []; - }; - - Animator.prototype = { - /** - * 设置动画关键帧 - * @param {number} time 关键帧时间,单位是ms - * @param {Object} props 关键帧的属性值,key-value表示 - * @return {module:zrender/animation/Animator} - */ - when: function(time /* ms */, props) { - var tracks = this._tracks; - for (var propName in props) { - if (!tracks[propName]) { - tracks[propName] = []; - // Invalid value - var value = this._getter(this._target, propName); - if (value == null) { - // zrLog('Invalid property ' + propName); - continue; - } - // If time is 0 - // Then props is given initialize value - // Else - // Initialize value from current prop value - if (time !== 0) { - tracks[propName].push({ - time: 0, - value: cloneValue(value) - }); - } - } - tracks[propName].push({ - time: time, - value: props[propName] - }); - } - return this; - }, - /** - * 添加动画每一帧的回调函数 - * @param {Function} callback - * @return {module:zrender/animation/Animator} - */ - during: function (callback) { - this._onframeList.push(callback); - return this; - }, - - _doneCallback: function () { - // Clear all tracks - this._tracks = {}; - // Clear all clips - this._clipList.length = 0; - - var doneList = this._doneList; - var len = doneList.length; - for (var i = 0; i < len; i++) { - doneList[i].call(this); - } - }, - /** - * 开始执行动画 - * @param {string|Function} easing - * 动画缓动函数,详见{@link module:zrender/animation/easing} - * @return {module:zrender/animation/Animator} - */ - start: function (easing) { - - var self = this; - var clipCount = 0; - - var oneTrackDone = function() { - clipCount--; - if (!clipCount) { - self._doneCallback(); - } - }; - - var lastClip; - for (var propName in this._tracks) { - var clip = createTrackClip( - this, easing, oneTrackDone, - this._tracks[propName], propName - ); - if (clip) { - this._clipList.push(clip); - clipCount++; - - // If start after added to animation - if (this.animation) { - this.animation.addClip(clip); - } - - lastClip = clip; - } - } - - // Add during callback on the last clip - if (lastClip) { - var oldOnFrame = lastClip.onframe; - lastClip.onframe = function (target, percent) { - oldOnFrame(target, percent); - - for (var i = 0; i < self._onframeList.length; i++) { - self._onframeList[i](target, percent); - } - }; - } - - if (!clipCount) { - this._doneCallback(); - } - return this; - }, - /** - * 停止动画 - * @param {boolean} forwardToLast If move to last frame before stop - */ - stop: function (forwardToLast) { - var clipList = this._clipList; - var animation = this.animation; - for (var i = 0; i < clipList.length; i++) { - var clip = clipList[i]; - if (forwardToLast) { - // Move to last frame before stop - clip.onframe(this._target, 1); - } - animation && animation.removeClip(clip); - } - clipList.length = 0; - }, - /** - * 设置动画延迟开始的时间 - * @param {number} time 单位ms - * @return {module:zrender/animation/Animator} - */ - delay: function (time) { - this._delay = time; - return this; - }, - /** - * 添加动画结束的回调 - * @param {Function} cb - * @return {module:zrender/animation/Animator} - */ - done: function(cb) { - if (cb) { - this._doneList.push(cb); - } - return this; - }, - - /** - * @return {Array.} - */ - getClips: function () { - return this._clipList; - } - }; - - return Animator; -}); -define('zrender/config',[],function () { - var dpr = 1; - // If in browser environment - if (typeof window !== 'undefined') { - dpr = Math.max(window.devicePixelRatio || 1, 1); - } - /** - * config默认配置项 - * @exports zrender/config - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - */ - var config = { - /** - * debug日志选项:catchBrushException为true下有效 - * 0 : 不生成debug数据,发布用 - * 1 : 异常抛出,调试用 - * 2 : 控制台输出,调试用 - */ - debugMode: 0, - - // retina 屏幕优化 - devicePixelRatio: dpr - }; - return config; -}); + startAngle: 0, + endAngle: Math.PI * 2, -define( - 'zrender/core/log',['require','../config'],function (require) { - var config = require('../config'); - - /** - * @exports zrender/tool/log - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - */ - return function() { - if (config.debugMode === 0) { - return; - } - else if (config.debugMode == 1) { - for (var k in arguments) { - throw new Error(arguments[k]); - } - } - else if (config.debugMode > 1) { - for (var k in arguments) { - console.log(arguments[k]); - } - } - }; - - /* for debug - return function(mes) { - document.getElementById('wrong-message').innerHTML = - mes + ' ' + (new Date() - 0) - + '
' - + document.getElementById('wrong-message').innerHTML; - }; - */ - } -); - -/** - * @module zrender/mixin/Animatable - */ -define('zrender/mixin/Animatable',['require','../animation/Animator','../core/util','../core/log'],function(require) { - - - - var Animator = require('../animation/Animator'); - var util = require('../core/util'); - var isString = util.isString; - var isFunction = util.isFunction; - var isObject = util.isObject; - var log = require('../core/log'); - - /** - * @alias modue:zrender/mixin/Animatable - * @constructor - */ - var Animatable = function () { - - /** - * @type {Array.} - * @readOnly - */ - this.animators = []; - }; - - Animatable.prototype = { - - constructor: Animatable, - - /** - * 动画 - * - * @param {string} path 需要添加动画的属性获取路径,可以通过a.b.c来获取深层的属性 - * @param {boolean} [loop] 动画是否循环 - * @return {module:zrender/animation/Animator} - * @example: - * el.animate('style', false) - * .when(1000, {x: 10} ) - * .done(function(){ // Animation done }) - * .start() - */ - animate: function (path, loop) { - var target; - var animatingShape = false; - var el = this; - var zr = this.__zr; - if (path) { - var pathSplitted = path.split('.'); - var prop = el; - // If animating shape - animatingShape = pathSplitted[0] === 'shape'; - for (var i = 0, l = pathSplitted.length; i < l; i++) { - if (!prop) { - continue; - } - prop = prop[pathSplitted[i]]; - } - if (prop) { - target = prop; - } - } - else { - target = el; - } - - if (!target) { - log( - 'Property "' - + path - + '" is not existed in element ' - + el.id - ); - return; - } - - var animators = el.animators; - - var animator = new Animator(target, loop); - - animator.during(function (target) { - el.dirty(animatingShape); - }) - .done(function () { - // FIXME Animator will not be removed if use `Animator#stop` to stop animation - animators.splice(util.indexOf(animators, animator), 1); - }); - - animators.push(animator); - - // If animate after added to the zrender - if (zr) { - zr.animation.addAnimator(animator); - } - - return animator; - }, - - /** - * 停止动画 - * @param {boolean} forwardToLast If move to last frame before stop - */ - stopAnimation: function (forwardToLast) { - var animators = this.animators; - var len = animators.length; - for (var i = 0; i < len; i++) { - animators[i].stop(forwardToLast); - } - animators.length = 0; - - return this; - }, - - /** - * @param {Object} target - * @param {number} [time=500] Time in ms - * @param {string} [easing='linear'] - * @param {number} [delay=0] - * @param {Function} [callback] - * - * @example - * // Animate position - * el.animateTo({ - * position: [10, 10] - * }, function () { // done }) - * - * // Animate shape, style and position in 100ms, delayed 100ms, with cubicOut easing - * el.animateTo({ - * shape: { - * width: 500 - * }, - * style: { - * fill: 'red' - * } - * position: [10, 10] - * }, 100, 100, 'cubicOut', function () { // done }) - */ - // TODO Return animation key - animateTo: function (target, time, delay, easing, callback) { - // animateTo(target, time, easing, callback); - if (isString(delay)) { - callback = easing; - easing = delay; - delay = 0; - } - // animateTo(target, time, delay, callback); - else if (isFunction(easing)) { - callback = easing; - easing = 'linear'; - delay = 0; - } - // animateTo(target, time, callback); - else if (isFunction(delay)) { - callback = delay; - delay = 0; - } - // animateTo(target, callback) - else if (isFunction(time)) { - callback = time; - time = 500; - } - // animateTo(target) - else if (!time) { - time = 500; - } - // Stop all previous animations - this.stopAnimation(); - this._animateToShallow('', this, target, time, delay, easing, callback); - - // Animators may be removed immediately after start - // if there is nothing to animate - var animators = this.animators.slice(); - var count = animators.length; - function done() { - count--; - if (!count) { - callback && callback(); - } - } - - // No animators. This should be checked before animators[i].start(), - // because 'done' may be executed immediately if no need to animate. - if (!count) { - callback && callback(); - } - // Start after all animators created - // Incase any animator is done immediately when all animation properties are not changed - for (var i = 0; i < animators.length; i++) { - animators[i] - .done(done) - .start(easing); - } - }, - - /** - * @private - * @param {string} path='' - * @param {Object} source=this - * @param {Object} target - * @param {number} [time=500] - * @param {number} [delay=0] - * - * @example - * // Animate position - * el._animateToShallow({ - * position: [10, 10] - * }) - * - * // Animate shape, style and position in 100ms, delayed 100ms - * el._animateToShallow({ - * shape: { - * width: 500 - * }, - * style: { - * fill: 'red' - * } - * position: [10, 10] - * }, 100, 100) - */ - _animateToShallow: function (path, source, target, time, delay) { - var objShallow = {}; - var propertyCount = 0; - for (var name in target) { - if (source[name] != null) { - if (isObject(target[name]) && !util.isArrayLike(target[name])) { - this._animateToShallow( - path ? path + '.' + name : name, - source[name], - target[name], - time, - delay - ); - } - else { - objShallow[name] = target[name]; - propertyCount++; - } - } - else if (target[name] != null) { - // Attr directly if not has property - // FIXME, if some property not needed for element ? - if (!path) { - this.attr(name, target[name]); - } - else { // Shape or style - var props = {}; - props[path] = {}; - props[path][name] = target[name]; - this.attr(props); - } - } - } - - if (propertyCount > 0) { - this.animate(path, false) - .when(time == null ? 500 : time, objShallow) - .delay(delay || 0); - } - - return this; - } - }; - - return Animatable; -}); -/** - * @module zrender/Element - */ -define('zrender/Element',['require','./core/guid','./mixin/Eventful','./mixin/Transformable','./mixin/Animatable','./core/util'],function(require) { - - - var guid = require('./core/guid'); - var Eventful = require('./mixin/Eventful'); - var Transformable = require('./mixin/Transformable'); - var Animatable = require('./mixin/Animatable'); - var zrUtil = require('./core/util'); - - /** - * @alias module:zrender/Element - * @constructor - * @extends {module:zrender/mixin/Animatable} - * @extends {module:zrender/mixin/Transformable} - * @extends {module:zrender/mixin/Eventful} - */ - var Element = function (opts) { - - Transformable.call(this, opts); - Eventful.call(this, opts); - Animatable.call(this, opts); - - /** - * 画布元素ID - * @type {string} - */ - this.id = opts.id || guid(); - }; - - Element.prototype = { - - /** - * 元素类型 - * Element type - * @type {string} - */ - type: 'element', - - /** - * 元素名字 - * Element name - * @type {string} - */ - name: '', - - /** - * ZRender 实例对象,会在 element 添加到 zrender 实例中后自动赋值 - * ZRender instance will be assigned when element is associated with zrender - * @name module:/zrender/Element#__zr - * @type {module:zrender/ZRender} - */ - __zr: null, - - /** - * 图形是否忽略,为true时忽略图形的绘制以及事件触发 - * If ignore drawing and events of the element object - * @name module:/zrender/Element#ignore - * @type {boolean} - * @default false - */ - ignore: false, - - /** - * 用于裁剪的路径(shape),所有 Group 内的路径在绘制时都会被这个路径裁剪 - * 该路径会继承被裁减对象的变换 - * @type {module:zrender/graphic/Path} - * @see http://www.w3.org/TR/2dcontext/#clipping-region - * @readOnly - */ - clipPath: null, - - /** - * Drift element - * @param {number} dx dx on the global space - * @param {number} dy dy on the global space - */ - drift: function (dx, dy) { - switch (this.draggable) { - case 'horizontal': - dy = 0; - break; - case 'vertical': - dx = 0; - break; - } - - var m = this.transform; - if (!m) { - m = this.transform = [1, 0, 0, 1, 0, 0]; - } - m[4] += dx; - m[5] += dy; - - this.decomposeTransform(); - this.dirty(); - }, - - /** - * Hook before update - */ - beforeUpdate: function () {}, - /** - * Hook after update - */ - afterUpdate: function () {}, - /** - * Update each frame - */ - update: function () { - this.updateTransform(); - }, - - /** - * @param {Function} cb - * @param {} context - */ - traverse: function (cb, context) {}, - - /** - * @protected - */ - attrKV: function (key, value) { - if (key === 'position' || key === 'scale' || key === 'origin') { - // Copy the array - if (value) { - var target = this[key]; - if (!target) { - target = this[key] = []; - } - target[0] = value[0]; - target[1] = value[1]; - } - } - else { - this[key] = value; - } - }, - - /** - * Hide the element - */ - hide: function () { - this.ignore = true; - this.__zr && this.__zr.refresh(); - }, - - /** - * Show the element - */ - show: function () { - this.ignore = false; - this.__zr && this.__zr.refresh(); - }, - - /** - * @param {string|Object} key - * @param {*} value - */ - attr: function (key, value) { - if (typeof key === 'string') { - this.attrKV(key, value); - } - else if (zrUtil.isObject(key)) { - for (var name in key) { - if (key.hasOwnProperty(name)) { - this.attrKV(name, key[name]); - } - } - } - this.dirty(); - - return this; - }, - - /** - * @param {module:zrender/graphic/Path} clipPath - */ - setClipPath: function (clipPath) { - var zr = this.__zr; - if (zr) { - clipPath.addSelfToZr(zr); - } - - // Remove previous clip path - if (this.clipPath && this.clipPath !== clipPath) { - this.removeClipPath(); - } - - this.clipPath = clipPath; - clipPath.__zr = zr; - clipPath.__clipTarget = this; - - this.dirty(); - }, - - /** - */ - removeClipPath: function () { - var clipPath = this.clipPath; - if (clipPath) { - if (clipPath.__zr) { - clipPath.removeSelfFromZr(clipPath.__zr); - } - - clipPath.__zr = null; - clipPath.__clipTarget = null; - this.clipPath = null; - - this.dirty(); - } - }, - - /** - * Add self from zrender instance. - * Not recursively because it will be invoked when element added to storage. - * @param {module:zrender/ZRender} zr - */ - addSelfToZr: function (zr) { - this.__zr = zr; - // 添加动画 - var animators = this.animators; - if (animators) { - for (var i = 0; i < animators.length; i++) { - zr.animation.addAnimator(animators[i]); - } - } - - if (this.clipPath) { - this.clipPath.addSelfToZr(zr); - } - }, - - /** - * Remove self from zrender instance. - * Not recursively because it will be invoked when element added to storage. - * @param {module:zrender/ZRender} zr - */ - removeSelfFromZr: function (zr) { - this.__zr = null; - // 移除动画 - var animators = this.animators; - if (animators) { - for (var i = 0; i < animators.length; i++) { - zr.animation.removeAnimator(animators[i]); - } - } - - if (this.clipPath) { - this.clipPath.removeSelfFromZr(zr); - } - } - }; - - zrUtil.mixin(Element, Animatable); - zrUtil.mixin(Element, Transformable); - zrUtil.mixin(Element, Eventful); - - return Element; -}); -/** - * Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上 - * @module zrender/graphic/Group - * @example - * var Group = require('zrender/container/Group'); - * var Circle = require('zrender/graphic/shape/Circle'); - * var g = new Group(); - * g.position[0] = 100; - * g.position[1] = 100; - * g.add(new Circle({ - * style: { - * x: 100, - * y: 100, - * r: 20, - * } - * })); - * zr.add(g); - */ -define('zrender/container/Group',['require','../core/util','../Element','../core/BoundingRect'],function (require) { - - var zrUtil = require('../core/util'); - var Element = require('../Element'); - var BoundingRect = require('../core/BoundingRect'); - - /** - * @alias module:zrender/graphic/Group - * @constructor - * @extends module:zrender/mixin/Transformable - * @extends module:zrender/mixin/Eventful - */ - var Group = function (opts) { - - opts = opts || {}; - - Element.call(this, opts); - - for (var key in opts) { - this[key] = opts[key]; - } - - this._children = []; - - this.__storage = null; - - this.__dirty = true; - }; - - Group.prototype = { - - constructor: Group, - - /** - * @type {string} - */ - type: 'group', - - /** - * @return {Array.} - */ - children: function () { - return this._children.slice(); - }, - - /** - * 获取指定 index 的儿子节点 - * @param {number} idx - * @return {module:zrender/Element} - */ - childAt: function (idx) { - return this._children[idx]; - }, - - /** - * 获取指定名字的儿子节点 - * @param {string} name - * @return {module:zrender/Element} - */ - childOfName: function (name) { - var children = this._children; - for (var i = 0; i < children.length; i++) { - if (children[i].name === name) { - return children[i]; - } - } - }, - - /** - * @return {number} - */ - childCount: function () { - return this._children.length; - }, - - /** - * 添加子节点到最后 - * @param {module:zrender/Element} child - */ - add: function (child) { - if (child && child !== this && child.parent !== this) { - - this._children.push(child); - - this._doAdd(child); - } - - return this; - }, - - /** - * 添加子节点在 nextSibling 之前 - * @param {module:zrender/Element} child - * @param {module:zrender/Element} nextSibling - */ - addBefore: function (child, nextSibling) { - if (child && child !== this && child.parent !== this - && nextSibling && nextSibling.parent === this) { - - var children = this._children; - var idx = children.indexOf(nextSibling); - - if (idx >= 0) { - children.splice(idx, 0, child); - this._doAdd(child); - } - } - - return this; - }, - - _doAdd: function (child) { - if (child.parent) { - child.parent.remove(child); - } - - child.parent = this; - - var storage = this.__storage; - var zr = this.__zr; - if (storage && storage !== child.__storage) { - - storage.addToMap(child); - - if (child instanceof Group) { - child.addChildrenToStorage(storage); - } - } - - zr && zr.refresh(); - }, - - /** - * 移除子节点 - * @param {module:zrender/Element} child - */ - remove: function (child) { - var zr = this.__zr; - var storage = this.__storage; - var children = this._children; - - var idx = zrUtil.indexOf(children, child); - if (idx < 0) { - return this; - } - children.splice(idx, 1); - - child.parent = null; - - if (storage) { - - storage.delFromMap(child.id); - - if (child instanceof Group) { - child.delChildrenFromStorage(storage); - } - } - - zr && zr.refresh(); - - return this; - }, - - /** - * 移除所有子节点 - */ - removeAll: function () { - var children = this._children; - var storage = this.__storage; - var child; - var i; - for (i = 0; i < children.length; i++) { - child = children[i]; - if (storage) { - storage.delFromMap(child.id); - if (child instanceof Group) { - child.delChildrenFromStorage(storage); - } - } - child.parent = null; - } - children.length = 0; - - return this; - }, - - /** - * 遍历所有子节点 - * @param {Function} cb - * @param {} context - */ - eachChild: function (cb, context) { - var children = this._children; - for (var i = 0; i < children.length; i++) { - var child = children[i]; - cb.call(context, child, i); - } - return this; - }, - - /** - * 深度优先遍历所有子孙节点 - * @param {Function} cb - * @param {} context - */ - traverse: function (cb, context) { - for (var i = 0; i < this._children.length; i++) { - var child = this._children[i]; - cb.call(context, child); - - if (child.type === 'group') { - child.traverse(cb, context); - } - } - return this; - }, - - addChildrenToStorage: function (storage) { - for (var i = 0; i < this._children.length; i++) { - var child = this._children[i]; - storage.addToMap(child); - if (child instanceof Group) { - child.addChildrenToStorage(storage); - } - } - }, - - delChildrenFromStorage: function (storage) { - for (var i = 0; i < this._children.length; i++) { - var child = this._children[i]; - storage.delFromMap(child.id); - if (child instanceof Group) { - child.delChildrenFromStorage(storage); - } - } - }, - - dirty: function () { - this.__dirty = true; - this.__zr && this.__zr.refresh(); - return this; - }, - - /** - * @return {module:zrender/core/BoundingRect} - */ - getBoundingRect: function (includeChildren) { - // TODO Caching - // TODO Transform - var rect = null; - var tmpRect = new BoundingRect(0, 0, 0, 0); - var children = includeChildren || this._children; - var tmpMat = []; - - for (var i = 0; i < children.length; i++) { - var child = children[i]; - if (child.ignore || child.invisible) { - continue; - } - - var childRect = child.getBoundingRect(); - var transform = child.getLocalTransform(tmpMat); - if (transform) { - tmpRect.copy(childRect); - tmpRect.applyTransform(transform); - rect = rect || tmpRect.clone(); - rect.union(tmpRect); - } - else { - rect = rect || childRect.clone(); - rect.union(childRect); - } - } - return rect || tmpRect; - } - }; - - zrUtil.inherits(Group, Element); - - return Group; -}); -define('echarts/view/Component',['require','zrender/container/Group','../util/component','../util/clazz'],function (require) { + clockwise: true + }, - var Group = require('zrender/container/Group'); - var componentUtil = require('../util/component'); - var clazzUtil = require('../util/clazz'); + buildPath: function (ctx, shape) { - var Component = function () { - /** - * @type {module:zrender/container/Group} - * @readOnly - */ - this.group = new Group(); + var x = shape.cx; + var y = shape.cy; + var r0 = Math.max(shape.r0 || 0, 0); + var r = Math.max(shape.r, 0); + var startAngle = shape.startAngle; + var endAngle = shape.endAngle; + var clockwise = shape.clockwise; - /** - * @type {string} - * @readOnly - */ - this.uid = componentUtil.getUID('viewComponent'); - }; + var unitX = Math.cos(startAngle); + var unitY = Math.sin(startAngle); - Component.prototype = { + ctx.moveTo(unitX * r0 + x, unitY * r0 + y); - constructor: Component, + ctx.lineTo(unitX * r + x, unitY * r + y); - init: function (ecModel, api) {}, + ctx.arc(x, y, r, startAngle, endAngle, !clockwise); - render: function (componentModel, ecModel, api, payload) {}, + ctx.lineTo( + Math.cos(endAngle) * r0 + x, + Math.sin(endAngle) * r0 + y + ); - dispose: function () {} - }; + if (r0 !== 0) { + ctx.arc(x, y, r0, endAngle, startAngle, clockwise); + } - var componentProto = Component.prototype; - componentProto.updateView - = componentProto.updateLayout - = componentProto.updateVisual - = function (seriesModel, ecModel, api, payload) { - // Do nothing; - }; - // Enable Component.extend. - clazzUtil.enableClassExtend(Component); + ctx.closePath(); + } + }); - // Enable capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. - clazzUtil.enableClassManagement(Component, {registerWhenExtend: true}); - return Component; -}); -define('echarts/view/Chart',['require','zrender/container/Group','../util/component','../util/clazz'],function (require) { - - var Group = require('zrender/container/Group'); - var componentUtil = require('../util/component'); - var clazzUtil = require('../util/clazz'); - - function Chart() { - - /** - * @type {module:zrender/container/Group} - * @readOnly - */ - this.group = new Group(); - - /** - * @type {string} - * @readOnly - */ - this.uid = componentUtil.getUID('viewChart'); - } - - Chart.prototype = { - - type: 'chart', - - /** - * Init the chart - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - */ - init: function (ecModel, api) {}, - - /** - * Render the chart - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - * @param {Object} payload - */ - render: function (seriesModel, ecModel, api, payload) {}, - - /** - * Highlight series or specified data item - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - * @param {Object} payload - */ - highlight: function (seriesModel, ecModel, api, payload) { - toggleHighlight(seriesModel.getData(), payload, 'emphasis'); - }, - - /** - * Downplay series or specified data item - * @param {module:echarts/model/Series} seriesModel - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - * @param {Object} payload - */ - downplay: function (seriesModel, ecModel, api, payload) { - toggleHighlight(seriesModel.getData(), payload, 'normal'); - }, - - /** - * Remove self - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - */ - remove: function (ecModel, api) { - this.group.removeAll(); - }, - - /** - * Dispose self - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - */ - dispose: function () {} - }; - - var chartProto = Chart.prototype; - chartProto.updateView - = chartProto.updateLayout - = chartProto.updateVisual - = function (seriesModel, ecModel, api, payload) { - this.render(seriesModel, ecModel, api, payload); - }; - - /** - * Set state of single element - * @param {module:zrender/Element} el - * @param {string} state - */ - function elSetState(el, state) { - if (el) { - el.trigger(state); - if (el.type === 'group') { - for (var i = 0; i < el.childCount(); i++) { - elSetState(el.childAt(i), state); - } - } - } - } - /** - * @param {module:echarts/data/List} data - * @param {Object} payload - * @param {string} state 'normal'|'emphasis' - * @inner - */ - function toggleHighlight(data, payload, state) { - if (payload.dataIndex != null) { - var el = data.getItemGraphicEl(payload.dataIndex); - elSetState(el, state); - } - else if (payload.name) { - var dataIndex = data.indexOfName(payload.name); - var el = data.getItemGraphicEl(dataIndex); - elSetState(el, state); - } - else { - data.eachItemGraphicEl(function (el) { - elSetState(el, state); - }); - } - } - - // Enable Chart.extend. - clazzUtil.enableClassExtend(Chart); - - // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on. - clazzUtil.enableClassManagement(Chart, {registerWhenExtend: true}); - - return Chart; -}); -/** - * @module zrender/graphic/Style - */ - -define('zrender/graphic/Style',['require'],function (require) { - - var STYLE_LIST_COMMON = [ - 'lineCap', 'lineJoin', 'miterLimit', - 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'shadowColor' - ]; - - var Style = function (opts) { - this.extendFrom(opts); - }; - - Style.prototype = { - - constructor: Style, - - /** - * @type {string} - */ - fill: '#000000', - - /** - * @type {string} - */ - stroke: null, - - /** - * @type {number} - */ - opacity: 1, - - /** - * @type {Array.} - */ - lineDash: null, - - /** - * @type {number} - */ - lineDashOffset: 0, - - /** - * @type {number} - */ - shadowBlur: 0, - - /** - * @type {number} - */ - shadowOffsetX: 0, - - /** - * @type {number} - */ - shadowOffsetY: 0, - - /** - * @type {number} - */ - lineWidth: 1, - - /** - * If stroke ignore scale - * @type {Boolean} - */ - strokeNoScale: false, - - // Bounding rect text configuration - // Not affected by element transform - /** - * @type {string} - */ - text: null, - - /** - * @type {string} - */ - textFill: '#000', - - /** - * @type {string} - */ - textStroke: null, - - /** - * 'inside', 'left', 'right', 'top', 'bottom' - * [x, y] - * @type {string|Array.} - * @default 'inside' - */ - textPosition: 'inside', - - /** - * @type {string} - */ - textBaseline: null, - - /** - * @type {string} - */ - textAlign: null, - - /** - * @type {number} - */ - textDistance: 5, - - /** - * @type {number} - */ - textShadowBlur: 0, - - /** - * @type {number} - */ - textShadowOffsetX: 0, - - /** - * @type {number} - */ - textShadowOffsetY: 0, - - /** - * @param {CanvasRenderingContext2D} ctx - */ - bind: function (ctx, el) { - var fill = this.fill; - var stroke = this.stroke; - for (var i = 0; i < STYLE_LIST_COMMON.length; i++) { - var styleName = STYLE_LIST_COMMON[i]; - - if (this[styleName] != null) { - ctx[styleName] = this[styleName]; - } - } - if (stroke != null) { - var lineWidth = this.lineWidth; - ctx.lineWidth = lineWidth / ( - (this.strokeNoScale && el && el.getLineScale) ? el.getLineScale() : 1 - ); - } - if (fill != null) { - // Use canvas gradient if has - ctx.fillStyle = fill.canvasGradient ? fill.canvasGradient : fill; - } - if (stroke != null) { - // Use canvas gradient if has - ctx.strokeStyle = stroke.canvasGradient ? stroke.canvasGradient : stroke; - } - this.opacity != null && (ctx.globalAlpha = this.opacity); - }, - - /** - * Extend from other style - * @param {zrender/graphic/Style} otherStyle - * @param {boolean} overwrite - */ - extendFrom: function (otherStyle, overwrite) { - if (otherStyle) { - var target = this; - for (var name in otherStyle) { - if (otherStyle.hasOwnProperty(name) - && (overwrite || ! target.hasOwnProperty(name)) - ) { - target[name] = otherStyle[name]; - } - } - } - }, - - /** - * Batch setting style with a given object - * @param {Object|string} obj - * @param {*} [obj] - */ - set: function (obj, value) { - if (typeof obj === 'string') { - this[obj] = value; - } - else { - this.extendFrom(obj, true); - } - }, - - /** - * Clone - * @return {zrender/graphic/Style} [description] - */ - clone: function () { - var newStyle = new this.constructor(); - newStyle.extendFrom(this, true); - return newStyle; - } - }; - - var styleProto = Style.prototype; - var name; - var i; - for (i = 0; i < STYLE_LIST_COMMON.length; i++) { - name = STYLE_LIST_COMMON[i]; - if (!(name in styleProto)) { - styleProto[name] = null; - } - } - - return Style; -}); -/** - * Mixin for drawing text in a element bounding rect - * @module zrender/mixin/RectText - */ - -define('zrender/graphic/mixin/RectText',['require','../../contain/text','../../core/BoundingRect'],function (require) { - - var textContain = require('../../contain/text'); - var BoundingRect = require('../../core/BoundingRect'); - - var tmpRect = new BoundingRect(); - - var RectText = function () {}; - - function parsePercent(value, maxValue) { - if (typeof value === 'string') { - if (value.lastIndexOf('%') >= 0) { - return parseFloat(value) / 100 * maxValue; - } - return parseFloat(value); - } - return value; - } - - function setTransform(ctx, m) { - ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); - } - - RectText.prototype = { - - constructor: RectText, - - /** - * Draw text in a rect with specified position. - * @param {CanvasRenderingContext} ctx - * @param {Object} rect Displayable rect - * @return {Object} textRect Alternative precalculated text bounding rect - */ - drawRectText: function (ctx, rect, textRect) { - var style = this.style; - var text = style.text; - // Convert to string - text != null && (text += ''); - if (!text) { - return; - } - var x; - var y; - var textPosition = style.textPosition; - var distance = style.textDistance; - var align = style.textAlign; - var font = style.textFont || style.font; - var baseline = style.textBaseline; - - textRect = textRect || textContain.getBoundingRect(text, font, align, baseline); - - // Transform rect to view space - var transform = this.transform; - var invTransform = this.invTransform; - if (transform) { - tmpRect.copy(rect); - tmpRect.applyTransform(transform); - rect = tmpRect; - // Transform back - setTransform(ctx, invTransform); - } - - // Text position represented by coord - if (textPosition instanceof Array) { - // Percent - x = rect.x + parsePercent(textPosition[0], rect.width); - y = rect.y + parsePercent(textPosition[1], rect.height); - align = align || 'left'; - baseline = baseline || 'top'; - } - else { - var res = textContain.adjustTextPositionOnRect( - textPosition, rect, textRect, distance - ); - x = res.x; - y = res.y; - // Default align and baseline when has textPosition - align = align || res.textAlign; - baseline = baseline || res.textBaseline; - } - - ctx.textAlign = align; - ctx.textBaseline = baseline; - - var textFill = style.textFill; - var textStroke = style.textStroke; - textFill && (ctx.fillStyle = textFill); - textStroke && (ctx.strokeStyle = textStroke); - ctx.font = font; - - // Text shadow - ctx.shadowColor = style.textShadowColor; - ctx.shadowBlur = style.textShadowBlur; - ctx.shadowOffsetX = style.textShadowOffsetX; - ctx.shadowOffsetY = style.textShadowOffsetY; - - var textLines = text.split('\n'); - for (var i = 0; i < textLines.length; i++) { - textFill && ctx.fillText(textLines[i], x, y); - textStroke && ctx.strokeText(textLines[i], x, y); - y += textRect.lineHeight; - } - - // Transform again - transform && setTransform(ctx, transform); - } - }; - - return RectText; -}); -/** - * 可绘制的图形基类 - * Base class of all displayable graphic objects - * @module zrender/graphic/Displayable - */ - -define('zrender/graphic/Displayable',['require','../core/util','./Style','../Element','./mixin/RectText'],function (require) { - - var zrUtil = require('../core/util'); - - var Style = require('./Style'); - - var Element = require('../Element'); - var RectText = require('./mixin/RectText'); - // var Stateful = require('./mixin/Stateful'); - - /** - * @alias module:zrender/graphic/Displayable - * @extends module:zrender/Element - * @extends module:zrender/graphic/mixin/RectText - */ - function Displayable(opts) { - - opts = opts || {}; - - Element.call(this, opts); - - // Extend properties - for (var name in opts) { - if ( - opts.hasOwnProperty(name) && - name !== 'style' - ) { - this[name] = opts[name]; - } - } - - /** - * @type {module:zrender/graphic/Style} - */ - this.style = new Style(opts.style); - - this._rect = null; - // Shapes for cascade clipping. - this.__clipPaths = []; - - // FIXME Stateful must be mixined after style is setted - // Stateful.call(this, opts); - } - - Displayable.prototype = { - - constructor: Displayable, - - type: 'displayable', - - /** - * Displayable 是否为脏,Painter 中会根据该标记判断是否需要是否需要重新绘制 - * Dirty flag. From which painter will determine if this displayable object needs brush - * @name module:zrender/graphic/Displayable#__dirty - * @type {boolean} - */ - __dirty: true, - - /** - * 图形是否可见,为true时不绘制图形,但是仍能触发鼠标事件 - * If ignore drawing of the displayable object. Mouse event will still be triggered - * @name module:/zrender/graphic/Displayable#invisible - * @type {boolean} - * @default false - */ - invisible: false, - - /** - * @name module:/zrender/graphic/Displayable#z - * @type {number} - * @default 0 - */ - z: 0, - - /** - * @name module:/zrender/graphic/Displayable#z - * @type {number} - * @default 0 - */ - z2: 0, - - /** - * z层level,决定绘画在哪层canvas中 - * @name module:/zrender/graphic/Displayable#zlevel - * @type {number} - * @default 0 - */ - zlevel: 0, - - /** - * 是否可拖拽 - * @name module:/zrender/graphic/Displayable#draggable - * @type {boolean} - * @default false - */ - draggable: false, - - /** - * 是否正在拖拽 - * @name module:/zrender/graphic/Displayable#draggable - * @type {boolean} - * @default false - */ - dragging: false, - - /** - * 是否相应鼠标事件 - * @name module:/zrender/graphic/Displayable#silent - * @type {boolean} - * @default false - */ - silent: false, - - /** - * If enable culling - * @type {boolean} - * @default false - */ - culling: false, - - /** - * Mouse cursor when hovered - * @name module:/zrender/graphic/Displayable#cursor - * @type {string} - */ - cursor: 'pointer', - - /** - * If hover area is bounding rect - * @name module:/zrender/graphic/Displayable#rectHover - * @type {string} - */ - rectHover: false, - - beforeBrush: function (ctx) {}, - - afterBrush: function (ctx) {}, - - /** - * 图形绘制方法 - * @param {Canvas2DRenderingContext} ctx - */ - // Interface - brush: function (ctx) {}, - - /** - * 获取最小包围盒 - * @return {module:zrender/core/BoundingRect} - */ - // Interface - getBoundingRect: function () {}, - - /** - * 判断坐标 x, y 是否在图形上 - * If displayable element contain coord x, y - * @param {number} x - * @param {number} y - * @return {boolean} - */ - contain: function (x, y) { - return this.rectContain(x, y); - }, - - /** - * @param {Function} cb - * @param {} context - */ - traverse: function (cb, context) { - cb.call(context, this); - }, - - /** - * 判断坐标 x, y 是否在图形的包围盒上 - * If bounding rect of element contain coord x, y - * @param {number} x - * @param {number} y - * @return {boolean} - */ - rectContain: function (x, y) { - var coord = this.transformCoordToLocal(x, y); - var rect = this.getBoundingRect(); - return rect.contain(coord[0], coord[1]); - }, - - /** - * 标记图形元素为脏,并且在下一帧重绘 - * Mark displayable element dirty and refresh next frame - */ - dirty: function () { - this.__dirty = true; - - this._rect = null; - - this.__zr && this.__zr.refresh(); - }, - - /** - * 图形是否会触发事件 - * If displayable object binded any event - * @return {boolean} - */ - // TODO, 通过 bind 绑定的事件 - // isSilent: function () { - // return !( - // this.hoverable || this.draggable - // || this.onmousemove || this.onmouseover || this.onmouseout - // || this.onmousedown || this.onmouseup || this.onclick - // || this.ondragenter || this.ondragover || this.ondragleave - // || this.ondrop - // ); - // }, - /** - * Alias for animate('style') - * @param {boolean} loop - */ - animateStyle: function (loop) { - return this.animate('style', loop); - }, - - attrKV: function (key, value) { - if (key !== 'style') { - Element.prototype.attrKV.call(this, key, value); - } - else { - this.style.set(value); - } - }, - - /** - * @param {Object|string} key - * @param {*} value - */ - setStyle: function (key, value) { - this.style.set(key, value); - this.dirty(); - return this; - } - }; - - zrUtil.inherits(Displayable, Element); - - zrUtil.mixin(Displayable, RectText); - // zrUtil.mixin(Displayable, Stateful); - - return Displayable; -}); -/** - * 曲线辅助模块 - * @module zrender/core/curve - * @author pissang(https://www.github.com/pissang) - */ -define('zrender/core/curve',['require','./vector'],function(require) { - - - - var vec2 = require('./vector'); - var v2Create = vec2.create; - var v2DistSquare = vec2.distSquare; - var mathPow = Math.pow; - var mathSqrt = Math.sqrt; - - var EPSILON = 1e-4; - - var THREE_SQRT = mathSqrt(3); - var ONE_THIRD = 1 / 3; - - // 临时变量 - var _v0 = v2Create(); - var _v1 = v2Create(); - var _v2 = v2Create(); - // var _v3 = vec2.create(); - - function isAroundZero(val) { - return val > -EPSILON && val < EPSILON; - } - function isNotAroundZero(val) { - return val > EPSILON || val < -EPSILON; - } - /** - * 计算三次贝塞尔值 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} t - * @return {number} - */ - function cubicAt(p0, p1, p2, p3, t) { - var onet = 1 - t; - return onet * onet * (onet * p0 + 3 * t * p1) - + t * t * (t * p3 + 3 * onet * p2); - } - - /** - * 计算三次贝塞尔导数值 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} t - * @return {number} - */ - function cubicDerivativeAt(p0, p1, p2, p3, t) { - var onet = 1 - t; - return 3 * ( - ((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet - + (p3 - p2) * t * t - ); - } - - /** - * 计算三次贝塞尔方程根,使用盛金公式 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} val - * @param {Array.} roots - * @return {number} 有效根数目 - */ - function cubicRootAt(p0, p1, p2, p3, val, roots) { - // Evaluate roots of cubic functions - var a = p3 + 3 * (p1 - p2) - p0; - var b = 3 * (p2 - p1 * 2 + p0); - var c = 3 * (p1 - p0); - var d = p0 - val; - - var A = b * b - 3 * a * c; - var B = b * c - 9 * a * d; - var C = c * c - 3 * b * d; - - var n = 0; - - if (isAroundZero(A) && isAroundZero(B)) { - if (isAroundZero(b)) { - roots[0] = 0; - } - else { - var t1 = -c / b; //t1, t2, t3, b is not zero - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - } - } - else { - var disc = B * B - 4 * A * C; - - if (isAroundZero(disc)) { - var K = B / A; - var t1 = -b / a + K; // t1, a is not zero - var t2 = -K / 2; // t2, t3 - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - if (t2 >= 0 && t2 <= 1) { - roots[n++] = t2; - } - } - else if (disc > 0) { - var discSqrt = mathSqrt(disc); - var Y1 = A * b + 1.5 * a * (-B + discSqrt); - var Y2 = A * b + 1.5 * a * (-B - discSqrt); - if (Y1 < 0) { - Y1 = -mathPow(-Y1, ONE_THIRD); - } - else { - Y1 = mathPow(Y1, ONE_THIRD); - } - if (Y2 < 0) { - Y2 = -mathPow(-Y2, ONE_THIRD); - } - else { - Y2 = mathPow(Y2, ONE_THIRD); - } - var t1 = (-b - (Y1 + Y2)) / (3 * a); - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - } - else { - var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt(A * A * A)); - var theta = Math.acos(T) / 3; - var ASqrt = mathSqrt(A); - var tmp = Math.cos(theta); - - var t1 = (-b - 2 * ASqrt * tmp) / (3 * a); - var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a); - var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a); - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - if (t2 >= 0 && t2 <= 1) { - roots[n++] = t2; - } - if (t3 >= 0 && t3 <= 1) { - roots[n++] = t3; - } - } - } - return n; - } - - /** - * 计算三次贝塞尔方程极限值的位置 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {Array.} extrema - * @return {number} 有效数目 - */ - function cubicExtrema(p0, p1, p2, p3, extrema) { - var b = 6 * p2 - 12 * p1 + 6 * p0; - var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2; - var c = 3 * p1 - 3 * p0; - - var n = 0; - if (isAroundZero(a)) { - if (isNotAroundZero(b)) { - var t1 = -c / b; - if (t1 >= 0 && t1 <=1) { - extrema[n++] = t1; - } - } - } - else { - var disc = b * b - 4 * a * c; - if (isAroundZero(disc)) { - extrema[0] = -b / (2 * a); - } - else if (disc > 0) { - var discSqrt = mathSqrt(disc); - var t1 = (-b + discSqrt) / (2 * a); - var t2 = (-b - discSqrt) / (2 * a); - if (t1 >= 0 && t1 <= 1) { - extrema[n++] = t1; - } - if (t2 >= 0 && t2 <= 1) { - extrema[n++] = t2; - } - } - } - return n; - } - - /** - * 细分三次贝塞尔曲线 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} t - * @param {Array.} out - */ - function cubicSubdivide(p0, p1, p2, p3, t, out) { - var p01 = (p1 - p0) * t + p0; - var p12 = (p2 - p1) * t + p1; - var p23 = (p3 - p2) * t + p2; - - var p012 = (p12 - p01) * t + p01; - var p123 = (p23 - p12) * t + p12; - - var p0123 = (p123 - p012) * t + p012; - // Seg0 - out[0] = p0; - out[1] = p01; - out[2] = p012; - out[3] = p0123; - // Seg1 - out[4] = p0123; - out[5] = p123; - out[6] = p23; - out[7] = p3; - } - - /** - * 投射点到三次贝塞尔曲线上,返回投射距离。 - * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x3 - * @param {number} y3 - * @param {number} x - * @param {number} y - * @param {Array.} [out] 投射点 - * @return {number} - */ - function cubicProjectPoint( - x0, y0, x1, y1, x2, y2, x3, y3, - x, y, out - ) { - // http://pomax.github.io/bezierinfo/#projections - var t; - var interval = 0.005; - var d = Infinity; - var prev; - var next; - var d1; - var d2; - - _v0[0] = x; - _v0[1] = y; - - // 先粗略估计一下可能的最小距离的 t 值 - // PENDING - for (var _t = 0; _t < 1; _t += 0.05) { - _v1[0] = cubicAt(x0, x1, x2, x3, _t); - _v1[1] = cubicAt(y0, y1, y2, y3, _t); - d1 = v2DistSquare(_v0, _v1); - if (d1 < d) { - t = _t; - d = d1; - } - } - d = Infinity; - - // At most 32 iteration - for (var i = 0; i < 32; i++) { - if (interval < EPSILON) { - break; - } - prev = t - interval; - next = t + interval; - // t - interval - _v1[0] = cubicAt(x0, x1, x2, x3, prev); - _v1[1] = cubicAt(y0, y1, y2, y3, prev); - - d1 = v2DistSquare(_v1, _v0); - - if (prev >= 0 && d1 < d) { - t = prev; - d = d1; - } - else { - // t + interval - _v2[0] = cubicAt(x0, x1, x2, x3, next); - _v2[1] = cubicAt(y0, y1, y2, y3, next); - d2 = v2DistSquare(_v2, _v0); - - if (next <= 1 && d2 < d) { - t = next; - d = d2; - } - else { - interval *= 0.5; - } - } - } - // t - if (out) { - out[0] = cubicAt(x0, x1, x2, x3, t); - out[1] = cubicAt(y0, y1, y2, y3, t); - } - // console.log(interval, i); - return mathSqrt(d); - } - - /** - * 计算二次方贝塞尔值 - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} t - * @return {number} - */ - function quadraticAt(p0, p1, p2, t) { - var onet = 1 - t; - return onet * (onet * p0 + 2 * t * p1) + t * t * p2; - } - - /** - * 计算二次方贝塞尔导数值 - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} t - * @return {number} - */ - function quadraticDerivativeAt(p0, p1, p2, t) { - return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1)); - } - - /** - * 计算二次方贝塞尔方程根 - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} t - * @param {Array.} roots - * @return {number} 有效根数目 - */ - function quadraticRootAt(p0, p1, p2, val, roots) { - var a = p0 - 2 * p1 + p2; - var b = 2 * (p1 - p0); - var c = p0 - val; - - var n = 0; - if (isAroundZero(a)) { - if (isNotAroundZero(b)) { - var t1 = -c / b; - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - } - } - else { - var disc = b * b - 4 * a * c; - if (isAroundZero(disc)) { - var t1 = -b / (2 * a); - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - } - else if (disc > 0) { - var discSqrt = mathSqrt(disc); - var t1 = (-b + discSqrt) / (2 * a); - var t2 = (-b - discSqrt) / (2 * a); - if (t1 >= 0 && t1 <= 1) { - roots[n++] = t1; - } - if (t2 >= 0 && t2 <= 1) { - roots[n++] = t2; - } - } - } - return n; - } - - /** - * 计算二次贝塞尔方程极限值 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @return {number} - */ - function quadraticExtremum(p0, p1, p2) { - var divider = p0 + p2 - 2 * p1; - if (divider === 0) { - // p1 is center of p0 and p2 - return 0.5; - } - else { - return (p0 - p1) / divider; - } - } - - /** - * 细分二次贝塞尔曲线 - * @memberOf module:zrender/core/curve - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} t - * @param {Array.} out - */ - function quadraticSubdivide(p0, p1, p2, t, out) { - var p01 = (p1 - p0) * t + p0; - var p12 = (p2 - p1) * t + p1; - var p012 = (p12 - p01) * t + p01; - - // Seg0 - out[0] = p0; - out[1] = p01; - out[2] = p012; - - // Seg1 - out[3] = p012; - out[4] = p12; - out[5] = p2; - } - - /** - * 投射点到二次贝塞尔曲线上,返回投射距离。 - * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x - * @param {number} y - * @param {Array.} out 投射点 - * @return {number} - */ - function quadraticProjectPoint( - x0, y0, x1, y1, x2, y2, - x, y, out - ) { - // http://pomax.github.io/bezierinfo/#projections - var t; - var interval = 0.005; - var d = Infinity; - - _v0[0] = x; - _v0[1] = y; - - // 先粗略估计一下可能的最小距离的 t 值 - // PENDING - for (var _t = 0; _t < 1; _t += 0.05) { - _v1[0] = quadraticAt(x0, x1, x2, _t); - _v1[1] = quadraticAt(y0, y1, y2, _t); - var d1 = v2DistSquare(_v0, _v1); - if (d1 < d) { - t = _t; - d = d1; - } - } - d = Infinity; - - // At most 32 iteration - for (var i = 0; i < 32; i++) { - if (interval < EPSILON) { - break; - } - var prev = t - interval; - var next = t + interval; - // t - interval - _v1[0] = quadraticAt(x0, x1, x2, prev); - _v1[1] = quadraticAt(y0, y1, y2, prev); - - var d1 = v2DistSquare(_v1, _v0); - - if (prev >= 0 && d1 < d) { - t = prev; - d = d1; - } - else { - // t + interval - _v2[0] = quadraticAt(x0, x1, x2, next); - _v2[1] = quadraticAt(y0, y1, y2, next); - var d2 = v2DistSquare(_v2, _v0); - if (next <= 1 && d2 < d) { - t = next; - d = d2; - } - else { - interval *= 0.5; - } - } - } - // t - if (out) { - out[0] = quadraticAt(x0, x1, x2, t); - out[1] = quadraticAt(y0, y1, y2, t); - } - // console.log(interval, i); - return mathSqrt(d); - } - - return { - - cubicAt: cubicAt, - - cubicDerivativeAt: cubicDerivativeAt, - - cubicRootAt: cubicRootAt, - - cubicExtrema: cubicExtrema, - - cubicSubdivide: cubicSubdivide, - - cubicProjectPoint: cubicProjectPoint, - - quadraticAt: quadraticAt, - - quadraticDerivativeAt: quadraticDerivativeAt, - - quadraticRootAt: quadraticRootAt, - - quadraticExtremum: quadraticExtremum, - - quadraticSubdivide: quadraticSubdivide, - - quadraticProjectPoint: quadraticProjectPoint - }; -}); -/** - * @author Yi Shen(https://github.com/pissang) - */ -define('zrender/core/bbox',['require','./vector','./curve'],function (require) { - - var vec2 = require('./vector'); - var curve = require('./curve'); - - var bbox = {}; - var mathMin = Math.min; - var mathMax = Math.max; - var mathSin = Math.sin; - var mathCos = Math.cos; - - var start = vec2.create(); - var end = vec2.create(); - var extremity = vec2.create(); - - var PI2 = Math.PI * 2; - /** - * 从顶点数组中计算出最小包围盒,写入`min`和`max`中 - * @module zrender/core/bbox - * @param {Array} points 顶点数组 - * @param {number} min - * @param {number} max - */ - bbox.fromPoints = function(points, min, max) { - if (points.length === 0) { - return; - } - var p = points[0]; - var left = p[0]; - var right = p[0]; - var top = p[1]; - var bottom = p[1]; - var i; - - for (i = 1; i < points.length; i++) { - p = points[i]; - left = mathMin(left, p[0]); - right = mathMax(right, p[0]); - top = mathMin(top, p[1]); - bottom = mathMax(bottom, p[1]); - } - - min[0] = left; - min[1] = top; - max[0] = right; - max[1] = bottom; - }; - - /** - * @memberOf module:zrender/core/bbox - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {Array.} min - * @param {Array.} max - */ - bbox.fromLine = function (x0, y0, x1, y1, min, max) { - min[0] = mathMin(x0, x1); - min[1] = mathMin(y0, y1); - max[0] = mathMax(x0, x1); - max[1] = mathMax(y0, y1); - }; - - /** - * 从三阶贝塞尔曲线(p0, p1, p2, p3)中计算出最小包围盒,写入`min`和`max`中 - * @memberOf module:zrender/core/bbox - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x3 - * @param {number} y3 - * @param {Array.} min - * @param {Array.} max - */ - bbox.fromCubic = function( - x0, y0, x1, y1, x2, y2, x3, y3, min, max - ) { - var xDim = []; - var yDim = []; - var cubicExtrema = curve.cubicExtrema; - var cubicAt = curve.cubicAt; - var left, right, top, bottom; - var i; - var n = cubicExtrema(x0, x1, x2, x3, xDim); - - for (i = 0; i < n; i++) { - xDim[i] = cubicAt(x0, x1, x2, x3, xDim[i]); - } - n = cubicExtrema(y0, y1, y2, y3, yDim); - for (i = 0; i < n; i++) { - yDim[i] = cubicAt(y0, y1, y2, y3, yDim[i]); - } - - xDim.push(x0, x3); - yDim.push(y0, y3); - - left = mathMin.apply(null, xDim); - right = mathMax.apply(null, xDim); - top = mathMin.apply(null, yDim); - bottom = mathMax.apply(null, yDim); - - min[0] = left; - min[1] = top; - max[0] = right; - max[1] = bottom; - }; - - /** - * 从二阶贝塞尔曲线(p0, p1, p2)中计算出最小包围盒,写入`min`和`max`中 - * @memberOf module:zrender/core/bbox - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {Array.} min - * @param {Array.} max - */ - bbox.fromQuadratic = function(x0, y0, x1, y1, x2, y2, min, max) { - var quadraticExtremum = curve.quadraticExtremum; - var quadraticAt = curve.quadraticAt; - // Find extremities, where derivative in x dim or y dim is zero - var tx = - mathMax( - mathMin(quadraticExtremum(x0, x1, x2), 1), 0 - ); - var ty = - mathMax( - mathMin(quadraticExtremum(y0, y1, y2), 1), 0 - ); - - var x = quadraticAt(x0, x1, x2, tx); - var y = quadraticAt(y0, y1, y2, ty); - - min[0] = mathMin(x0, x2, x); - min[1] = mathMin(y0, y2, y); - max[0] = mathMax(x0, x2, x); - max[1] = mathMax(y0, y2, y); - }; - - /** - * 从圆弧中计算出最小包围盒,写入`min`和`max`中 - * @method - * @memberOf module:zrender/core/bbox - * @param {number} x - * @param {number} y - * @param {number} rx - * @param {number} ry - * @param {number} startAngle - * @param {number} endAngle - * @param {number} anticlockwise - * @param {Array.} min - * @param {Array.} max - */ - bbox.fromArc = function ( - x, y, rx, ry, startAngle, endAngle, anticlockwise, min, max - ) { - var vec2Min = vec2.min; - var vec2Max = vec2.max; - - var diff = Math.abs(startAngle - endAngle); - - - if (diff % PI2 < 1e-4 && diff > 1e-4) { - // Is a circle - min[0] = x - rx; - min[1] = y - ry; - max[0] = x + rx; - max[1] = y + ry; - return; - } - - start[0] = mathCos(startAngle) * rx + x; - start[1] = mathSin(startAngle) * ry + y; - - end[0] = mathCos(endAngle) * rx + x; - end[1] = mathSin(endAngle) * ry + y; - - vec2Min(min, start, end); - vec2Max(max, start, end); - - // Thresh to [0, Math.PI * 2] - startAngle = startAngle % (PI2); - if (startAngle < 0) { - startAngle = startAngle + PI2; - } - endAngle = endAngle % (PI2); - if (endAngle < 0) { - endAngle = endAngle + PI2; - } - - if (startAngle > endAngle && !anticlockwise) { - endAngle += PI2; - } - else if (startAngle < endAngle && anticlockwise) { - startAngle += PI2; - } - if (anticlockwise) { - var tmp = endAngle; - endAngle = startAngle; - startAngle = tmp; - } - - // var number = 0; - // var step = (anticlockwise ? -Math.PI : Math.PI) / 2; - for (var angle = 0; angle < endAngle; angle += Math.PI / 2) { - if (angle > startAngle) { - extremity[0] = mathCos(angle) * rx + x; - extremity[1] = mathSin(angle) * ry + y; - - vec2Min(min, extremity, min); - vec2Max(max, extremity, max); - } - } - }; - - return bbox; -}); -/** - * Path 代理,可以在`buildPath`中用于替代`ctx`, 会保存每个path操作的命令到pathCommands属性中 - * 可以用于 isInsidePath 判断以及获取boundingRect - * - * @module zrender/core/PathProxy - * @author Yi Shen (http://www.github.com/pissang) - */ - - // TODO getTotalLength, getPointAtLength -define('zrender/core/PathProxy',['require','./curve','./vector','./bbox','./BoundingRect'],function (require) { - - - var curve = require('./curve'); - var vec2 = require('./vector'); - var bbox = require('./bbox'); - var BoundingRect = require('./BoundingRect'); - - var CMD = { - M: 1, - L: 2, - C: 3, - Q: 4, - A: 5, - Z: 6, - // Rect - R: 7 - }; - - var min = []; - var max = []; - var min2 = []; - var max2 = []; - var mathMin = Math.min; - var mathMax = Math.max; - var mathCos = Math.cos; - var mathSin = Math.sin; - var mathSqrt = Math.sqrt; - - var hasTypedArray = typeof Float32Array != 'undefined'; - - /** - * @alias module:zrender/core/PathProxy - * @constructor - */ - var PathProxy = function () { - - /** - * Path data. Stored as flat array - * @type {Array.} - */ - this.data = []; - - this._len = 0; - - this._ctx = null; - - this._xi = 0; - this._yi = 0; - - this._x0 = 0; - this._y0 = 0; - }; - - /** - * 快速计算Path包围盒(并不是最小包围盒) - * @return {Object} - */ - PathProxy.prototype = { - - constructor: PathProxy, - - _lineDash: null, - - _dashOffset: 0, - - _dashIdx: 0, - - _dashSum: 0, - - getContext: function () { - return this._ctx; - }, - - /** - * @param {CanvasRenderingContext2D} ctx - * @return {module:zrender/core/PathProxy} - */ - beginPath: function (ctx) { - this._ctx = ctx; - - ctx && ctx.beginPath(); - - // Reset - this._len = 0; - - if (this._lineDash) { - this._lineDash = null; - - this._dashOffset = 0; - } - - return this; - }, - - /** - * @param {number} x - * @param {number} y - * @return {module:zrender/core/PathProxy} - */ - moveTo: function (x, y) { - this.addData(CMD.M, x, y); - this._ctx && this._ctx.moveTo(x, y); - - // x0, y0, xi, yi 是记录在 _dashedXXXXTo 方法中使用 - // xi, yi 记录当前点, x0, y0 在 closePath 的时候回到起始点。 - // 有可能在 beginPath 之后直接调用 lineTo,这时候 x0, y0 需要 - // 在 lineTo 方法中记录,这里先不考虑这种情况,dashed line 也只在 IE10- 中不支持 - this._x0 = x; - this._y0 = y; - - this._xi = x; - this._yi = y; - - return this; - }, - - /** - * @param {number} x - * @param {number} y - * @return {module:zrender/core/PathProxy} - */ - lineTo: function (x, y) { - this.addData(CMD.L, x, y); - if (this._ctx) { - this._needsDash() ? this._dashedLineTo(x, y) - : this._ctx.lineTo(x, y); - } - this._xi = x; - this._yi = y; - return this; - }, - - /** - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x3 - * @param {number} y3 - * @return {module:zrender/core/PathProxy} - */ - bezierCurveTo: function (x1, y1, x2, y2, x3, y3) { - this.addData(CMD.C, x1, y1, x2, y2, x3, y3); - if (this._ctx) { - this._needsDash() ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3) - : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3); - } - this._xi = x3; - this._yi = y3; - return this; - }, - - /** - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @return {module:zrender/core/PathProxy} - */ - quadraticCurveTo: function (x1, y1, x2, y2) { - this.addData(CMD.Q, x1, y1, x2, y2); - if (this._ctx) { - this._needsDash() ? this._dashedQuadraticTo(x1, y1, x2, y2) - : this._ctx.quadraticCurveTo(x1, y1, x2, y2); - } - this._xi = x2; - this._yi = y2; - return this; - }, - - /** - * @param {number} cx - * @param {number} cy - * @param {number} r - * @param {number} startAngle - * @param {number} endAngle - * @param {boolean} anticlockwise - * @return {module:zrender/core/PathProxy} - */ - arc: function (cx, cy, r, startAngle, endAngle, anticlockwise) { - this.addData( - CMD.A, cx, cy, r, r, startAngle, endAngle - startAngle, 0, anticlockwise ? 0 : 1 - ); - this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise); - - this._xi = mathCos(endAngle) * r + cx; - this._xi = mathSin(endAngle) * r + cx; - return this; - }, - - // TODO - arcTo: function (x1, y1, x2, y2, radius) { - if (this._ctx) { - this._ctx.arcTo(x1, y1, x2, y2, radius); - } - return this; - }, - - // TODO - rect: function (x, y, w, h) { - this._ctx && this._ctx.rect(x, y, w, h); - this.addData(CMD.R, x, y, w, h); - return this; - }, - - /** - * @return {module:zrender/core/PathProxy} - */ - closePath: function () { - this.addData(CMD.Z); - - var ctx = this._ctx; - var x0 = this._x0; - var y0 = this._y0; - if (ctx) { - this._needsDash() && this._dashedLineTo(x0, y0); - ctx.closePath(); - } - - this._xi = x0; - this._yi = y0; - return this; - }, - - /** - * Context 从外部传入,因为有可能是 rebuildPath 完之后再 fill。 - * stroke 同样 - * @param {CanvasRenderingContext2D} ctx - * @return {module:zrender/core/PathProxy} - */ - fill: function (ctx) { - ctx && ctx.fill(); - this.toStatic(); - }, - - /** - * @param {CanvasRenderingContext2D} ctx - * @return {module:zrender/core/PathProxy} - */ - stroke: function (ctx) { - ctx && ctx.stroke(); - this.toStatic(); - }, - - /** - * 必须在其它绘制命令前调用 - * Must be invoked before all other path drawing methods - * @return {module:zrender/core/PathProxy} - */ - setLineDash: function (lineDash) { - if (lineDash instanceof Array) { - this._lineDash = lineDash; - - this._dashIdx = 0; - - var lineDashSum = 0; - for (var i = 0; i < lineDash.length; i++) { - lineDashSum += lineDash[i]; - } - this._dashSum = lineDashSum; - } - return this; - }, - - /** - * 必须在其它绘制命令前调用 - * Must be invoked before all other path drawing methods - * @return {module:zrender/core/PathProxy} - */ - setLineDashOffset: function (offset) { - this._dashOffset = offset; - return this; - }, - - /** - * - * @return {boolean} - */ - len: function () { - return this._len; - }, - - /** - * 直接设置 Path 数据 - */ - setData: function (data) { - - var len = data.length; - - if (! (this.data && this.data.length == len) && hasTypedArray) { - this.data = new Float32Array(len); - } - - for (var i = 0; i < len; i++) { - this.data[i] = data[i]; - } - - this._len = len; - }, - - /** - * 添加子路径 - * @param {module:zrender/core/PathProxy|Array.} path - */ - appendPath: function (path) { - if (!(path instanceof Array)) { - path = [path]; - } - var len = path.length; - var appendSize = 0; - var offset = this._len; - for (var i = 0; i < len; i++) { - appendSize += path[i].len(); - } - if (hasTypedArray && (this.data instanceof Float32Array)) { - this.data = new Float32Array(offset + appendSize); - } - for (var i = 0; i < len; i++) { - var appendPathData = path[i].data; - for (var k = 0; k < appendPathData.length; k++) { - this.data[offset++] = appendPathData[k]; - } - } - this._len = offset; - }, - - /** - * 填充 Path 数据。 - * 尽量复用而不申明新的数组。大部分图形重绘的指令数据长度都是不变的。 - */ - addData: function (cmd) { - var data = this.data; - if (this._len + arguments.length > data.length) { - // 因为之前的数组已经转换成静态的 Float32Array - // 所以不够用时需要扩展一个新的动态数组 - this._expandData(); - data = this.data; - } - for (var i = 0; i < arguments.length; i++) { - data[this._len++] = arguments[i]; - } - - this._prevCmd = cmd; - }, - - _expandData: function () { - // Only if data is Float32Array - if (!(this.data instanceof Array)) { - var newData = []; - for (var i = 0; i < this._len; i++) { - newData[i] = this.data[i]; - } - this.data = newData; - } - }, - - /** - * If needs js implemented dashed line - * @return {boolean} - * @private - */ - _needsDash: function () { - return this._lineDash; - }, - - _dashedLineTo: function (x1, y1) { - var dashSum = this._dashSum; - var offset = this._dashOffset; - var lineDash = this._lineDash; - var ctx = this._ctx; - - var x0 = this._xi; - var y0 = this._yi; - var dx = x1 - x0; - var dy = y1 - y0; - var dist = mathSqrt(dx * dx + dy * dy); - var x = x0; - var y = y0; - var dash; - var nDash = lineDash.length; - var idx; - dx /= dist; - dy /= dist; - - if (offset < 0) { - // Convert to positive offset - offset = dashSum + offset; - } - offset %= dashSum; - x -= offset * dx; - y -= offset * dy; - - while ((dx >= 0 && x <= x1) || (dx < 0 && x > x1)) { - idx = this._dashIdx; - dash = lineDash[idx]; - x += dx * dash; - y += dy * dash; - this._dashIdx = (idx + 1) % nDash; - // Skip positive offset - if ((dx > 0 && x < x0) || (dx < 0 && x > x0)) { - continue; - } - ctx[idx % 2 ? 'moveTo' : 'lineTo']( - dx >= 0 ? mathMin(x, x1) : mathMax(x, x1), - dy >= 0 ? mathMin(y, y1) : mathMax(y, y1) - ); - } - // Offset for next lineTo - dx = x - x1; - dy = y - y1; - this._dashOffset = -mathSqrt(dx * dx + dy * dy); - }, - - // Not accurate dashed line to - _dashedBezierTo: function (x1, y1, x2, y2, x3, y3) { - var dashSum = this._dashSum; - var offset = this._dashOffset; - var lineDash = this._lineDash; - var ctx = this._ctx; - - var x0 = this._xi; - var y0 = this._yi; - var t; - var dx; - var dy; - var cubicAt = curve.cubicAt; - var bezierLen = 0; - var idx = this._dashIdx; - var nDash = lineDash.length; - - var x; - var y; - - var tmpLen = 0; - - if (offset < 0) { - // Convert to positive offset - offset = dashSum + offset; - } - offset %= dashSum; - // Bezier approx length - for (t = 0; t < 1; t += 0.1) { - dx = cubicAt(x0, x1, x2, x3, t + 0.1) - - cubicAt(x0, x1, x2, x3, t); - dy = cubicAt(y0, y1, y2, y3, t + 0.1) - - cubicAt(y0, y1, y2, y3, t); - bezierLen += mathSqrt(dx * dx + dy * dy); - } - - // Find idx after add offset - for (; idx < nDash; idx++) { - tmpLen += lineDash[idx]; - if (tmpLen > offset) { - break; - } - } - t = (tmpLen - offset) / bezierLen; - - while (t <= 1) { - - x = cubicAt(x0, x1, x2, x3, t); - y = cubicAt(y0, y1, y2, y3, t); - - // Use line to approximate dashed bezier - // Bad result if dash is long - idx % 2 ? ctx.moveTo(x, y) - : ctx.lineTo(x, y); - - t += lineDash[idx] / bezierLen; - - idx = (idx + 1) % nDash; - } - - // Finish the last segment and calculate the new offset - (idx % 2 !== 0) && ctx.lineTo(x3, y3); - dx = x3 - x; - dy = y3 - y; - this._dashOffset = -mathSqrt(dx * dx + dy * dy); - }, - - _dashedQuadraticTo: function (x1, y1, x2, y2) { - // Convert quadratic to cubic using degree elevation - var x3 = x2; - var y3 = y2; - x2 = (x2 + 2 * x1) / 3; - y2 = (y2 + 2 * y1) / 3; - x1 = (this._xi + 2 * x1) / 3; - y1 = (this._yi + 2 * y1) / 3; - - this._dashedBezierTo(x1, y1, x2, y2, x3, y3); - }, - - /** - * 转成静态的 Float32Array 减少堆内存占用 - * Convert dynamic array to static Float32Array - */ - toStatic: function () { - var data = this.data; - if (data instanceof Array) { - data.length = this._len; - if (hasTypedArray) { - this.data = new Float32Array(data); - } - } - }, - - /** - * @return {module:zrender/core/BoundingRect} - */ - getBoundingRect: function () { - min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE; - max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE; - - var data = this.data; - var xi = 0; - var yi = 0; - var x0 = 0; - var y0 = 0; - - for (var i = 0; i < data.length;) { - var cmd = data[i++]; - - if (i == 1) { - // 如果第一个命令是 L, C, Q - // 则 previous point 同绘制命令的第一个 point - // - // 第一个命令为 Arc 的情况下会在后面特殊处理 - xi = data[i]; - yi = data[i + 1]; - - x0 = xi; - y0 = yi; - } - - switch (cmd) { - case CMD.M: - // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点 - // 在 closePath 的时候使用 - x0 = data[i++]; - y0 = data[i++]; - xi = x0; - yi = y0; - min2[0] = x0; - min2[1] = y0; - max2[0] = x0; - max2[1] = y0; - break; - case CMD.L: - bbox.fromLine(xi, yi, data[i], data[i + 1], min2, max2); - xi = data[i++]; - yi = data[i++]; - break; - case CMD.C: - bbox.fromCubic( - xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], - min2, max2 - ); - xi = data[i++]; - yi = data[i++]; - break; - case CMD.Q: - bbox.fromQuadratic( - xi, yi, data[i++], data[i++], data[i], data[i + 1], - min2, max2 - ); - xi = data[i++]; - yi = data[i++]; - break; - case CMD.A: - // TODO Arc 判断的开销比较大 - var cx = data[i++]; - var cy = data[i++]; - var rx = data[i++]; - var ry = data[i++]; - var startAngle = data[i++]; - var endAngle = data[i++] + startAngle; - // TODO Arc 旋转 - var psi = data[i++]; - var anticlockwise = 1 - data[i++]; - - if (i == 1) { - // 直接使用 arc 命令 - // 第一个命令起点还未定义 - x0 = mathCos(startAngle) * rx + cx; - y0 = mathSin(startAngle) * ry + cy; - } - - bbox.fromArc( - cx, cy, rx, ry, startAngle, endAngle, - anticlockwise, min2, max2 - ); - - xi = mathCos(endAngle) * rx + cx; - yi = mathSin(endAngle) * ry + cy; - break; - case CMD.R: - x0 = xi = data[i++]; - y0 = yi = data[i++]; - var width = data[i++]; - var height = data[i++]; - // Use fromLine - bbox.fromLine(x0, y0, x0 + width, y0 + height, min2, max2); - break; - case CMD.Z: - xi = x0; - yi = y0; - break; - } - - // Union - vec2.min(min, min, min2); - vec2.max(max, max, max2); - } - - // No data - if (i === 0) { - min[0] = min[1] = max[0] = max[1] = 0; - } - - return new BoundingRect( - min[0], min[1], max[0] - min[0], max[1] - min[1] - ); - }, - - /** - * Rebuild path from current data - * Rebuild path will not consider javascript implemented line dash. - * @param {CanvasRenderingContext} ctx - */ - rebuildPath: function (ctx) { - var d = this.data; - for (var i = 0; i < this._len;) { - var cmd = d[i++]; - switch (cmd) { - case CMD.M: - ctx.moveTo(d[i++], d[i++]); - break; - case CMD.L: - ctx.lineTo(d[i++], d[i++]); - break; - case CMD.C: - ctx.bezierCurveTo( - d[i++], d[i++], d[i++], d[i++], d[i++], d[i++] - ); - break; - case CMD.Q: - ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]); - break; - case CMD.A: - var cx = d[i++]; - var cy = d[i++]; - var rx = d[i++]; - var ry = d[i++]; - var theta = d[i++]; - var dTheta = d[i++]; - var psi = d[i++]; - var fs = d[i++]; - var r = (rx > ry) ? rx : ry; - var scaleX = (rx > ry) ? 1 : rx / ry; - var scaleY = (rx > ry) ? ry / rx : 1; - var isEllipse = Math.abs(rx - ry) > 1e-3; - if (isEllipse) { - ctx.translate(cx, cy); - ctx.rotate(psi); - ctx.scale(scaleX, scaleY); - ctx.arc(0, 0, r, theta, theta + dTheta, 1 - fs); - ctx.scale(1 / scaleX, 1 / scaleY); - ctx.rotate(-psi); - ctx.translate(-cx, -cy); - } - else { - ctx.arc(cx, cy, r, theta, theta + dTheta, 1 - fs); - } - break; - case CMD.R: - ctx.rect(d[i++], d[i++], d[i++], d[i++]); - break; - case CMD.Z: - ctx.closePath(); - } - } - } - }; - - PathProxy.CMD = CMD; - - return PathProxy; -}); -define('zrender/contain/line',[],function () { - return { - /** - * 线段包含判断 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} lineWidth - * @param {number} x - * @param {number} y - * @return {boolean} - */ - containStroke: function (x0, y0, x1, y1, lineWidth, x, y) { - if (lineWidth === 0) { - return false; - } - var _l = lineWidth; - var _a = 0; - var _b = x0; - // Quick reject - 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) - ) { - return false; - } - - if (x0 !== x1) { - _a = (y0 - y1) / (x0 - x1); - _b = (x0 * y1 - x1 * y0) / (x0 - x1) ; - } - else { - return Math.abs(x - x0) <= _l / 2; - } - var tmp = _a * x - y + _b; - var _s = tmp * tmp / (_a * _a + 1); - return _s <= _l / 2 * _l / 2; - } - }; -}); -define('zrender/contain/cubic',['require','../core/curve'],function (require) { - - var curve = require('../core/curve'); - - return { - /** - * 三次贝塞尔曲线描边包含判断 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} x3 - * @param {number} y3 - * @param {number} lineWidth - * @param {number} x - * @param {number} y - * @return {boolean} - */ - containStroke: function(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) { - if (lineWidth === 0) { - return false; - } - var _l = lineWidth; - // Quick reject - 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) - ) { - return false; - } - var d = curve.cubicProjectPoint( - x0, y0, x1, y1, x2, y2, x3, y3, - x, y, null - ); - return d <= _l / 2; - } - }; -}); -define('zrender/contain/quadratic',['require','../core/curve'],function (require) { - - var curve = require('../core/curve'); - - return { - /** - * 二次贝塞尔曲线描边包含判断 - * @param {number} x0 - * @param {number} y0 - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} lineWidth - * @param {number} x - * @param {number} y - * @return {boolean} - */ - containStroke: function (x0, y0, x1, y1, x2, y2, lineWidth, x, y) { - if (lineWidth === 0) { - return false; - } - var _l = lineWidth; - // Quick reject - 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) - ) { - return false; - } - var d = curve.quadraticProjectPoint( - x0, y0, x1, y1, x2, y2, - x, y, null - ); - return d <= _l / 2; - } - }; -}); -define('zrender/contain/util',['require'],function (require) { - - var PI2 = Math.PI * 2; - return { - normalizeRadian: function(angle) { - angle %= PI2; - if (angle < 0) { - angle += PI2; - } - return angle; - } - }; -}); -define('zrender/contain/arc',['require','./util'],function (require) { - - var normalizeRadian = require('./util').normalizeRadian; - var PI2 = Math.PI * 2; - - return { - /** - * 圆弧描边包含判断 - * @param {number} cx - * @param {number} cy - * @param {number} r - * @param {number} startAngle - * @param {number} endAngle - * @param {boolean} anticlockwise - * @param {number} lineWidth - * @param {number} x - * @param {number} y - * @return {Boolean} - */ - containStroke: function ( - cx, cy, r, startAngle, endAngle, anticlockwise, - lineWidth, x, y - ) { - - if (lineWidth === 0) { - return false; - } - var _l = lineWidth; - - x -= cx; - y -= cy; - var d = Math.sqrt(x * x + y * y); - - if ((d - _l > r) || (d + _l < r)) { - return false; - } - if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) { - // Is a circle - return true; - } - if (anticlockwise) { - var tmp = startAngle; - startAngle = normalizeRadian(endAngle); - endAngle = normalizeRadian(tmp); - } else { - startAngle = normalizeRadian(startAngle); - endAngle = normalizeRadian(endAngle); - } - if (startAngle > endAngle) { - endAngle += PI2; - } - - var angle = Math.atan2(y, x); - if (angle < 0) { - angle += PI2; - } - return (angle >= startAngle && angle <= endAngle) - || (angle + PI2 >= startAngle && angle + PI2 <= endAngle); - } - }; -}); -define('zrender/contain/windingLine',[],function () { - return function windingLine(x0, y0, x1, y1, x, y) { - if ((y > y0 && y > y1) || (y < y0 && y < y1)) { - return 0; - } - if (y1 === y0) { - return 0; - } - var dir = y1 < y0 ? 1 : -1; - var t = (y - y0) / (y1 - y0); - var x_ = t * (x1 - x0) + x0; - - return x_ > x ? dir : 0; - }; -}); -define('zrender/contain/path',['require','../core/PathProxy','./line','./cubic','./quadratic','./arc','./util','../core/curve','./windingLine'],function (require) { - - - - var CMD = require('../core/PathProxy').CMD; - var line = require('./line'); - var cubic = require('./cubic'); - var quadratic = require('./quadratic'); - var arc = require('./arc'); - var normalizeRadian = require('./util').normalizeRadian; - var curve = require('../core/curve'); - - var windingLine = require('./windingLine'); - - var containStroke = line.containStroke; - - var PI2 = Math.PI * 2; - - var EPSILON = 1e-4; - - function isAroundEqual(a, b) { - return Math.abs(a - b) < EPSILON; - } - - // 临时数组 - var roots = [-1, -1, -1]; - var extrema = [-1, -1]; - - function swapExtrema() { - var tmp = extrema[0]; - extrema[0] = extrema[1]; - extrema[1] = tmp; - } - - function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) { - // Quick reject - if ( - (y > y0 && y > y1 && y > y2 && y > y3) - || (y < y0 && y < y1 && y < y2 && y < y3) - ) { - return 0; - } - var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots); - if (nRoots === 0) { - return 0; - } - else { - var w = 0; - var nExtrema = -1; - var y0_, y1_; - for (var i = 0; i < nRoots; i++) { - var t = roots[i]; - var x_ = curve.cubicAt(x0, x1, x2, x3, t); - if (x_ < x) { // Quick reject - continue; - } - if (nExtrema < 0) { - nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema); - if (extrema[1] < extrema[0] && nExtrema > 1) { - swapExtrema(); - } - y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]); - if (nExtrema > 1) { - y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]); - } - } - if (nExtrema == 2) { - // 分成三段单调函数 - if (t < extrema[0]) { - w += y0_ < y0 ? 1 : -1; - } - else if (t < extrema[1]) { - w += y1_ < y0_ ? 1 : -1; - } - else { - w += y3 < y1_ ? 1 : -1; - } - } - else { - // 分成两段单调函数 - if (t < extrema[0]) { - w += y0_ < y0 ? 1 : -1; - } - else { - w += y3 < y0_ ? 1 : -1; - } - } - } - return w; - } - } - - function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) { - // Quick reject - if ( - (y > y0 && y > y1 && y > y2) - || (y < y0 && y < y1 && y < y2) - ) { - return 0; - } - var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots); - if (nRoots === 0) { - return 0; - } - else { - var t = curve.quadraticExtremum(y0, y1, y2); - if (t >=0 && t <= 1) { - var w = 0; - var y_ = curve.quadraticAt(y0, y1, y2, t); - for (var i = 0; i < nRoots; i++) { - var x_ = curve.quadraticAt(x0, x1, x2, roots[i]); - if (x_ > x) { - continue; - } - if (roots[i] < t) { - w += y_ < y0 ? 1 : -1; - } - else { - w += y2 < y_ ? 1 : -1; - } - } - return w; - } - else { - var x_ = curve.quadraticAt(x0, x1, x2, roots[0]); - if (x_ > x) { - return 0; - } - return y2 < y0 ? 1 : -1; - } - } - } - - // TODO - // Arc 旋转 - function windingArc( - cx, cy, r, startAngle, endAngle, anticlockwise, x, y - ) { - y -= cy; - if (y > r || y < -r) { - return 0; - } - var tmp = Math.sqrt(r * r - y * y); - roots[0] = -tmp; - roots[1] = tmp; - - var diff = Math.abs(startAngle - endAngle); - if (diff < 1e-4) { - return 0; - } - if (diff % PI2 < 1e-4) { - // Is a circle - startAngle = 0; - endAngle = PI2; - var dir = anticlockwise ? 1 : -1; - if (x >= roots[0] + cx && x <= roots[1] + cx) { - return dir; - } else { - return 0; - } - } - - if (anticlockwise) { - var tmp = startAngle; - startAngle = normalizeRadian(endAngle); - endAngle = normalizeRadian(tmp); - } - else { - startAngle = normalizeRadian(startAngle); - endAngle = normalizeRadian(endAngle); - } - if (startAngle > endAngle) { - endAngle += PI2; - } - - var w = 0; - for (var i = 0; i < 2; i++) { - var x_ = roots[i]; - if (x_ + cx > x) { - var angle = Math.atan2(y, x_); - var dir = anticlockwise ? 1 : -1; - if (angle < 0) { - angle = PI2 + angle; - } - if ( - (angle >= startAngle && angle <= endAngle) - || (angle + PI2 >= startAngle && angle + PI2 <= endAngle) - ) { - if (angle > Math.PI / 2 && angle < Math.PI * 1.5) { - dir = -dir; - } - w += dir; - } - } - } - return w; - } - - function containPath(data, lineWidth, isStroke, x, y) { - var w = 0; - var xi = 0; - var yi = 0; - var x0 = 0; - var y0 = 0; - - for (var i = 0; i < data.length;) { - var cmd = data[i++]; - // Begin a new subpath - if (cmd === CMD.M && i > 1) { - // Close previous subpath - if (!isStroke) { - w += windingLine(xi, yi, x0, y0, x, y); - } - // 如果被任何一个 subpath 包含 - if (w !== 0) { - return true; - } - } - - if (i == 1) { - // 如果第一个命令是 L, C, Q - // 则 previous point 同绘制命令的第一个 point - // - // 第一个命令为 Arc 的情况下会在后面特殊处理 - xi = data[i]; - yi = data[i + 1]; - - x0 = xi; - y0 = yi; - } - - switch (cmd) { - case CMD.M: - // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点 - // 在 closePath 的时候使用 - x0 = data[i++]; - y0 = data[i++]; - xi = x0; - yi = y0; - break; - case CMD.L: - if (isStroke) { - if (containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) { - return true; - } - } - else { - // NOTE 在第一个命令为 L, C, Q 的时候会计算出 NaN - w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0; - } - xi = data[i++]; - yi = data[i++]; - break; - case CMD.C: - if (isStroke) { - if (cubic.containStroke(xi, yi, - data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], - lineWidth, x, y - )) { - return true; - } - } - else { - w += windingCubic( - xi, yi, - data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], - x, y - ) || 0; - } - xi = data[i++]; - yi = data[i++]; - break; - case CMD.Q: - if (isStroke) { - if (quadratic.containStroke(xi, yi, - data[i++], data[i++], data[i], data[i + 1], - lineWidth, x, y - )) { - return true; - } - } - else { - w += windingQuadratic( - xi, yi, - data[i++], data[i++], data[i], data[i + 1], - x, y - ) || 0; - } - xi = data[i++]; - yi = data[i++]; - break; - case CMD.A: - // TODO Arc 判断的开销比较大 - var cx = data[i++]; - var cy = data[i++]; - var rx = data[i++]; - var ry = data[i++]; - var theta = data[i++]; - var dTheta = data[i++]; - // TODO Arc 旋转 - var psi = data[i++]; - var anticlockwise = 1 - data[i++]; - var x1 = Math.cos(theta) * rx + cx; - var y1 = Math.sin(theta) * ry + cy; - // 不是直接使用 arc 命令 - if (i > 1) { - w += windingLine(xi, yi, x1, y1, x, y); - } - else { - // 第一个命令起点还未定义 - x0 = x1; - y0 = y1; - } - // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放 - var _x = (x - cx) * ry / rx + cx; - if (isStroke) { - if (arc.containStroke( - cx, cy, ry, theta, theta + dTheta, anticlockwise, - lineWidth, _x, y - )) { - return true; - } - } - else { - w += windingArc( - cx, cy, ry, theta, theta + dTheta, anticlockwise, - _x, y - ); - } - xi = Math.cos(theta + dTheta) * rx + cx; - yi = Math.sin(theta + dTheta) * ry + cy; - break; - case CMD.R: - x0 = xi = data[i++]; - y0 = yi = data[i++]; - var width = data[i++]; - var height = data[i++]; - var x1 = x0 + width; - var y1 = y0 + height; - if (isStroke) { - if (containStroke(x0, y0, x1, y0, lineWidth, x, y) - || containStroke(x1, y0, x1, y1, lineWidth, x, y) - || containStroke(x1, y1, x0, y1, lineWidth, x, y) - || containStroke(x0, y1, x1, y1, lineWidth, x, y) - ) { - return true; - } - } - else { - // FIXME Clockwise ? - w += windingLine(x1, y0, x1, y1, x, y); - w += windingLine(x0, y1, x0, y0, x, y); - } - break; - case CMD.Z: - if (isStroke) { - if (containStroke( - xi, yi, x0, y0, lineWidth, x, y - )) { - return true; - } - } - else { - // Close a subpath - w += windingLine(xi, yi, x0, y0, x, y); - // 如果被任何一个 subpath 包含 - if (w !== 0) { - return true; - } - } - xi = x0; - yi = y0; - break; - } - } - if (!isStroke && !isAroundEqual(yi, y0)) { - w += windingLine(xi, yi, x0, y0, x, y) || 0; - } - return w !== 0; - } - - return { - contain: function (pathData, x, y) { - return containPath(pathData, 0, false, x, y); - }, - - containStroke: function (pathData, lineWidth, x, y) { - return containPath(pathData, lineWidth, true, x, y); - } - }; -}); -/** - * Path element - * @module zrender/graphic/Path - */ - -define('zrender/graphic/Path',['require','./Displayable','../core/util','../core/PathProxy','../contain/path','./Gradient'],function (require) { - - var Displayable = require('./Displayable'); - var zrUtil = require('../core/util'); - var PathProxy = require('../core/PathProxy'); - var pathContain = require('../contain/path'); - - var Gradient = require('./Gradient'); - - function pathHasFill(style) { - var fill = style.fill; - return fill != null && fill !== 'none'; - } - - function pathHasStroke(style) { - var stroke = style.stroke; - return stroke != null && stroke !== 'none' && style.lineWidth > 0; - } - - var abs = Math.abs; - - /** - * @alias module:zrender/graphic/Path - * @extends module:zrender/graphic/Displayable - * @constructor - * @param {Object} opts - */ - function Path(opts) { - Displayable.call(this, opts); - - /** - * @type {module:zrender/core/PathProxy} - * @readOnly - */ - this.path = new PathProxy(); - } - - Path.prototype = { - - constructor: Path, - - type: 'path', - - __dirtyPath: true, - - strokeContainThreshold: 5, - - brush: function (ctx) { - ctx.save(); - - var style = this.style; - var path = this.path; - var hasStroke = pathHasStroke(style); - var hasFill = pathHasFill(style); - - if (this.__dirtyPath) { - // Update gradient because bounding rect may changed - if (hasFill && (style.fill instanceof Gradient)) { - style.fill.updateCanvasGradient(this, ctx); - } - if (hasStroke && (style.stroke instanceof Gradient)) { - style.stroke.updateCanvasGradient(this, ctx); - } - } - - style.bind(ctx, this); - this.setTransform(ctx); - - var lineDash = style.lineDash; - var lineDashOffset = style.lineDashOffset; - - var ctxLineDash = !!ctx.setLineDash; - - // Proxy context - // Rebuild path in following 2 cases - // 1. Path is dirty - // 2. Path needs javascript implemented lineDash stroking. - // In this case, lineDash information will not be saved in PathProxy - if (this.__dirtyPath || ( - lineDash && !ctxLineDash && hasStroke - )) { - path = this.path.beginPath(ctx); - - // Setting line dash before build path - if (lineDash && !ctxLineDash) { - path.setLineDash(lineDash); - path.setLineDashOffset(lineDashOffset); - } - - this.buildPath(path, this.shape); - - // Clear path dirty flag - this.__dirtyPath = false; - } - else { - // Replay path building - ctx.beginPath(); - this.path.rebuildPath(ctx); - } - - hasFill && path.fill(ctx); - - if (lineDash && ctxLineDash) { - ctx.setLineDash(lineDash); - ctx.lineDashOffset = lineDashOffset; - } - - hasStroke && path.stroke(ctx); - - // Draw rect text - if (style.text != null) { - // var rect = this.getBoundingRect(); - this.drawRectText(ctx, this.getBoundingRect()); - } - - ctx.restore(); - }, - - buildPath: function (ctx, shapeCfg) {}, - - getBoundingRect: function () { - var rect = this._rect; - var style = this.style; - if (!rect) { - var path = this.path; - if (this.__dirtyPath) { - path.beginPath(); - this.buildPath(path, this.shape); - } - rect = path.getBoundingRect(); - } - /** - * Needs update rect with stroke lineWidth when - * 1. Element changes scale or lineWidth - * 2. First create rect - */ - if (pathHasStroke(style) && (this.__dirty || !this._rect)) { - var rectWithStroke = this._rectWithStroke - || (this._rectWithStroke = rect.clone()); - rectWithStroke.copy(rect); - // FIXME Must after updateTransform - var w = style.lineWidth; - // PENDING, Min line width is needed when line is horizontal or vertical - var lineScale = style.strokeNoScale ? this.getLineScale() : 1; - - // Only add extra hover lineWidth when there are no fill - if (!pathHasFill(style)) { - w = Math.max(w, this.strokeContainThreshold); - } - // Consider line width - // Line scale can't be 0; - if (lineScale > 1e-10) { - rectWithStroke.width += w / lineScale; - rectWithStroke.height += w / lineScale; - rectWithStroke.x -= w / lineScale / 2; - rectWithStroke.y -= w / lineScale / 2; - } - return rectWithStroke; - } - this._rect = rect; - return rect; - }, - - contain: function (x, y) { - var localPos = this.transformCoordToLocal(x, y); - var rect = this.getBoundingRect(); - var style = this.style; - x = localPos[0]; - y = localPos[1]; - - if (rect.contain(x, y)) { - var pathData = this.path.data; - if (pathHasStroke(style)) { - var lineWidth = style.lineWidth; - var lineScale = style.strokeNoScale ? this.getLineScale() : 1; - // Line scale can't be 0; - if (lineScale > 1e-10) { - // Only add extra hover lineWidth when there are no fill - if (!pathHasFill(style)) { - lineWidth = Math.max(lineWidth, this.strokeContainThreshold); - } - if (pathContain.containStroke( - pathData, lineWidth / lineScale, x, y - )) { - return true; - } - } - } - if (pathHasFill(style)) { - return pathContain.contain(pathData, x, y); - } - } - return false; - }, - - /** - * @param {boolean} dirtyPath - */ - dirty: function (dirtyPath) { - if (arguments.length ===0) { - dirtyPath = true; - } - // Only mark dirty, not mark clean - if (dirtyPath) { - this.__dirtyPath = dirtyPath; - this._rect = null; - } - - this.__dirty = true; - - this.__zr && this.__zr.refresh(); - - // Used as a clipping path - if (this.__clipTarget) { - this.__clipTarget.dirty(); - } - }, - - /** - * Alias for animate('shape') - * @param {boolean} loop - */ - animateShape: function (loop) { - return this.animate('shape', loop); - }, - - // Overwrite attrKV - attrKV: function (key, value) { - // FIXME - if (key === 'shape') { - this.setShape(value); - } - else { - Displayable.prototype.attrKV.call(this, key, value); - } - }, - /** - * @param {Object|string} key - * @param {*} value - */ - setShape: function (key, value) { - var shape = this.shape; - // Path from string may not have shape - if (shape) { - if (zrUtil.isObject(key)) { - for (var name in key) { - shape[name] = key[name]; - } - } - else { - shape[key] = value; - } - this.dirty(true); - } - return this; - }, - - getLineScale: function () { - var m = this.transform; - // Get the line scale. - // Determinant of `m` means how much the area is enlarged by the - // transformation. So its square root can be used as a scale factor - // for width. - return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10 - ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1])) - : 1; - } - }; - - /** - * 扩展一个 Path element, 比如星形,圆等。 - * Extend a path element - * @param {Object} props - * @param {string} props.type Path type - * @param {Function} props.init Initialize - * @param {Function} props.buildPath Overwrite buildPath method - * @param {Object} [props.style] Extended default style config - * @param {Object} [props.shape] Extended default shape config - */ - Path.extend = function (defaults) { - var Sub = function (opts) { - Path.call(this, opts); - - if (defaults.style) { - // Extend default style - this.style.extendFrom(defaults.style, false); - } - - // Extend default shape - var defaultShape = defaults.shape; - if (defaultShape) { - this.shape = this.shape || {}; - var thisShape = this.shape; - for (var name in defaultShape) { - if ( - ! thisShape.hasOwnProperty(name) - && defaultShape.hasOwnProperty(name) - ) { - thisShape[name] = defaultShape[name]; - } - } - } - - defaults.init && defaults.init.call(this, opts); - }; - - zrUtil.inherits(Sub, Path); - - // FIXME 不能 extend position, rotation 等引用对象 - for (var name in defaults) { - // Extending prototype values and methods - if (name !== 'style' && name !== 'shape') { - Sub.prototype[name] = defaults[name]; - } - } - - return Sub; - }; - - zrUtil.inherits(Path, Displayable); - - return Path; -}); -define('zrender/tool/transformPath',['require','../core/PathProxy','../core/vector'],function (require) { - - var CMD = require('../core/PathProxy').CMD; - var vec2 = require('../core/vector'); - var v2ApplyTransform = vec2.applyTransform; - - var points = [[], [], []]; - var mathSqrt = Math.sqrt; - var mathAtan2 = Math.atan2; - function transformPath(path, m) { - var data = path.data; - var cmd; - var nPoint; - var i; - var j; - var k; - var p; - - var M = CMD.M; - var C = CMD.C; - var L = CMD.L; - var R = CMD.R; - var A = CMD.A; - var Q = CMD.Q; - - for (i = 0, j = 0; i < data.length;) { - cmd = data[i++]; - j = i; - nPoint = 0; - - switch (cmd) { - case M: - nPoint = 1; - break; - case L: - nPoint = 1; - break; - case C: - nPoint = 3; - break; - case Q: - nPoint = 2; - break; - case A: - var x = m[4]; - var y = m[5]; - var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]); - var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]); - var angle = mathAtan2(-m[1] / sy, m[0] / sx); - // cx - data[i++] += x; - // cy - data[i++] += y; - // Scale rx and ry - // FIXME Assume psi is 0 here - data[i++] *= sx; - data[i++] *= sy; - - // Start angle - data[i++] += angle; - // end angle - data[i++] += angle; - // FIXME psi - i += 2; - j = i; - break; - case R: - // x0, y0 - p[0] = data[i++]; - p[1] = data[i++]; - v2ApplyTransform(p, p, m); - data[j++] = p[0]; - data[j++] = p[1]; - // x1, y1 - p[0] += data[i++]; - p[1] += data[i++]; - v2ApplyTransform(p, p, m); - data[j++] = p[0]; - data[j++] = p[1]; - } - - for (k = 0; k < nPoint; k++) { - var p = points[k]; - p[0] = data[i++]; - p[1] = data[i++]; - - v2ApplyTransform(p, p, m); - // Write back - data[j++] = p[0]; - data[j++] = p[1]; - } - } - } - - return transformPath; -}); -define('zrender/tool/path',['require','../graphic/Path','../core/PathProxy','./transformPath','../core/matrix'],function (require) { - - var Path = require('../graphic/Path'); - var PathProxy = require('../core/PathProxy'); - var transformPath = require('./transformPath'); - var matrix = require('../core/matrix'); - - // command chars - var cc = [ - 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z', - 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A' - ]; - - var mathSqrt = Math.sqrt; - var mathSin = Math.sin; - var mathCos = Math.cos; - var PI = Math.PI; - - var vMag = function(v) { - return Math.sqrt(v[0] * v[0] + v[1] * v[1]); - }; - var vRatio = function(u, v) { - return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v)); - }; - var vAngle = function(u, v) { - return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) - * Math.acos(vRatio(u, v)); - }; - - function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) { - var psi = psiDeg * (PI / 180.0); - var xp = mathCos(psi) * (x1 - x2) / 2.0 - + mathSin(psi) * (y1 - y2) / 2.0; - var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0 - + mathCos(psi) * (y1 - y2) / 2.0; - - var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry); - - if (lambda > 1) { - rx *= mathSqrt(lambda); - ry *= mathSqrt(lambda); - } - - var f = (fa === fs ? -1 : 1) - * mathSqrt((((rx * rx) * (ry * ry)) - - ((rx * rx) * (yp * yp)) - - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp) - + (ry * ry) * (xp * xp)) - ) || 0; - - var cxp = f * rx * yp / ry; - var cyp = f * -ry * xp / rx; - - var cx = (x1 + x2) / 2.0 - + mathCos(psi) * cxp - - mathSin(psi) * cyp; - var cy = (y1 + y2) / 2.0 - + mathSin(psi) * cxp - + mathCos(psi) * cyp; - - var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]); - var u = [ (xp - cxp) / rx, (yp - cyp) / ry ]; - var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ]; - var dTheta = vAngle(u, v); - - if (vRatio(u, v) <= -1) { - dTheta = PI; - } - if (vRatio(u, v) >= 1) { - dTheta = 0; - } - if (fs === 0 && dTheta > 0) { - dTheta = dTheta - 2 * PI; - } - if (fs === 1 && dTheta < 0) { - dTheta = dTheta + 2 * PI; - } - - path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs); - } - - function createPathProxyFromString(data) { - if (!data) { - return []; - } - - // command string - var cs = data.replace(/-/g, ' -') - .replace(/ /g, ' ') - .replace(/ /g, ',') - .replace(/,,/g, ','); - - var n; - // create pipes so that we can split the data - for (n = 0; n < cc.length; n++) { - cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]); - } - - // create array - var arr = cs.split('|'); - // init context point - var cpx = 0; - var cpy = 0; - - var path = new PathProxy(); - var CMD = PathProxy.CMD; - - var prevCmd; - for (n = 1; n < arr.length; n++) { - var str = arr[n]; - var c = str.charAt(0); - var off = 0; - var p = str.slice(1).replace(/e,-/g, 'e-').split(','); - var cmd; - - if (p.length > 0 && p[0] === '') { - p.shift(); - } - - for (var i = 0; i < p.length; i++) { - p[i] = parseFloat(p[i]); - } - while (off < p.length && !isNaN(p[off])) { - if (isNaN(p[0])) { - break; - } - var ctlPtx; - var ctlPty; - - var rx; - var ry; - var psi; - var fa; - var fs; - - var x1 = cpx; - var y1 = cpy; - - // convert l, H, h, V, and v to L - switch (c) { - case 'l': - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'L': - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'm': - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.M; - path.addData(cmd, cpx, cpy); - c = 'l'; - break; - case 'M': - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.M; - path.addData(cmd, cpx, cpy); - c = 'L'; - break; - case 'h': - cpx += p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'H': - cpx = p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'v': - cpy += p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'V': - cpy = p[off++]; - cmd = CMD.L; - path.addData(cmd, cpx, cpy); - break; - case 'C': - cmd = CMD.C; - path.addData( - cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++] - ); - cpx = p[off - 2]; - cpy = p[off - 1]; - break; - case 'c': - cmd = CMD.C; - path.addData( - cmd, - p[off++] + cpx, p[off++] + cpy, - p[off++] + cpx, p[off++] + cpy, - p[off++] + cpx, p[off++] + cpy - ); - cpx += p[off - 2]; - cpy += p[off - 1]; - break; - case 'S': - ctlPtx = cpx; - ctlPty = cpy; - var len = path.len(); - var pathData = path.data; - if (prevCmd === CMD.C) { - ctlPtx += cpx - pathData[len - 4]; - ctlPty += cpy - pathData[len - 3]; - } - cmd = CMD.C; - x1 = p[off++]; - y1 = p[off++]; - cpx = p[off++]; - cpy = p[off++]; - path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy); - break; - case 's': - ctlPtx = cpx; - ctlPty = cpy; - var len = path.len(); - var pathData = path.data; - if (prevCmd === CMD.C) { - ctlPtx += cpx - pathData[len - 4]; - ctlPty += cpy - pathData[len - 3]; - } - cmd = CMD.C; - x1 = cpx + p[off++]; - y1 = cpy + p[off++]; - cpx += p[off++]; - cpy += p[off++]; - path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy); - break; - case 'Q': - x1 = p[off++]; - y1 = p[off++]; - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.Q; - path.addData(cmd, x1, y1, cpx, cpy); - break; - case 'q': - x1 = p[off++] + cpx; - y1 = p[off++] + cpy; - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.Q; - path.addData(cmd, x1, y1, cpx, cpy); - break; - case 'T': - ctlPtx = cpx; - ctlPty = cpy; - var len = path.len(); - var pathData = path.data; - if (prevCmd === CMD.Q) { - ctlPtx += cpx - pathData[len - 4]; - ctlPty += cpy - pathData[len - 3]; - } - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.Q; - path.addData(cmd, ctlPtx, ctlPty, cpx, cpy); - break; - case 't': - ctlPtx = cpx; - ctlPty = cpy; - var len = path.len(); - var pathData = path.data; - if (prevCmd === CMD.Q) { - ctlPtx += cpx - pathData[len - 4]; - ctlPty += cpy - pathData[len - 3]; - } - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.Q; - path.addData(cmd, ctlPtx, ctlPty, cpx, cpy); - break; - case 'A': - rx = p[off++]; - ry = p[off++]; - psi = p[off++]; - fa = p[off++]; - fs = p[off++]; - - x1 = cpx, y1 = cpy; - cpx = p[off++]; - cpy = p[off++]; - cmd = CMD.A; - processArc( - x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path - ); - break; - case 'a': - rx = p[off++]; - ry = p[off++]; - psi = p[off++]; - fa = p[off++]; - fs = p[off++]; - - x1 = cpx, y1 = cpy; - cpx += p[off++]; - cpy += p[off++]; - cmd = CMD.A; - processArc( - x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path - ); - break; - } - } - - if (c === 'z' || c === 'Z') { - cmd = CMD.Z; - path.addData(cmd); - } - - prevCmd = cmd; - } - - path.toStatic(); - - return path; - } - - // TODO Optimize double memory cost problem - function createPathOptions(str, opts) { - var pathProxy = createPathProxyFromString(str); - var transform; - opts = opts || {}; - opts.buildPath = function (path) { - path.setData(pathProxy.data); - transform && transformPath(path, transform); - // Svg and vml renderer don't have context - var ctx = path.getContext(); - if (ctx) { - path.rebuildPath(ctx); - } - }; - - opts.applyTransform = function (m) { - if (!transform) { - transform = matrix.create(); - } - matrix.mul(transform, m, transform); - }; - - return opts; - } - - return { - /** - * Create a Path object from path string data - * http://www.w3.org/TR/SVG/paths.html#PathData - * @param {Object} opts Other options - */ - createFromString: function (str, opts) { - return new Path(createPathOptions(str, opts)); - }, - - /** - * Create a Path class from path string data - * @param {string} str - * @param {Object} opts Other options - */ - extendFromString: function (str, opts) { - return Path.extend(createPathOptions(str, opts)); - }, - - /** - * Merge multiple paths - */ - // TODO Apply transform - // TODO stroke dash - // TODO Optimize double memory cost problem - mergePath: function (pathEls, opts) { - var pathList = []; - var len = pathEls.length; - var pathEl; - var i; - for (i = 0; i < len; i++) { - pathEl = pathEls[i]; - if (pathEl.__dirty) { - pathEl.buildPath(pathEl.path, pathEl.shape); - } - pathList.push(pathEl.path); - } - - var pathBundle = new Path(opts); - pathBundle.buildPath = function (path) { - path.appendPath(pathList); - // Svg and vml renderer don't have context - var ctx = path.getContext(); - if (ctx) { - path.rebuildPath(ctx); - } - }; - - return pathBundle; - } - }; -}); -define('zrender/graphic/helper/roundRect',['require'],function (require) { - - return { - buildPath: function (ctx, shape) { - var x = shape.x; - var y = shape.y; - var width = shape.width; - var height = shape.height; - var r = shape.r; - var r1; - var r2; - var r3; - var r4; - - // Convert width and height to positive for better borderRadius - if (width < 0) { - x = x + width; - width = -width; - } - if (height < 0) { - y = y + height; - height = -height; - } - - if (typeof r === 'number') { - r1 = r2 = r3 = r4 = r; - } - else if (r instanceof Array) { - if (r.length === 1) { - r1 = r2 = r3 = r4 = r[0]; - } - else if (r.length === 2) { - r1 = r3 = r[0]; - r2 = r4 = r[1]; - } - else if (r.length === 3) { - r1 = r[0]; - r2 = r4 = r[1]; - r3 = r[2]; - } - else { - r1 = r[0]; - r2 = r[1]; - r3 = r[2]; - r4 = r[3]; - } - } - else { - r1 = r2 = r3 = r4 = 0; - } - - var total; - if (r1 + r2 > width) { - total = r1 + r2; - r1 *= width / total; - r2 *= width / total; - } - if (r3 + r4 > width) { - total = r3 + r4; - r3 *= width / total; - r4 *= width / total; - } - if (r2 + r3 > height) { - total = r2 + r3; - r2 *= height / total; - r3 *= height / total; - } - if (r1 + r4 > height) { - total = r1 + r4; - r1 *= height / total; - r4 *= height / total; - } - ctx.moveTo(x + r1, y); - ctx.lineTo(x + width - r2, y); - r2 !== 0 && ctx.quadraticCurveTo( - x + width, y, x + width, y + r2 - ); - ctx.lineTo(x + width, y + height - r3); - r3 !== 0 && ctx.quadraticCurveTo( - x + width, y + height, x + width - r3, y + height - ); - ctx.lineTo(x + r4, y + height); - r4 !== 0 && ctx.quadraticCurveTo( - x, y + height, x, y + height - r4 - ); - ctx.lineTo(x, y + r1); - r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y); - } - }; -}); -// Simple LRU cache use doubly linked list -// @module zrender/core/LRU -define('zrender/core/LRU',['require'],function(require) { - - /** - * Simple double linked list. Compared with array, it has O(1) remove operation. - * @constructor - */ - var LinkedList = function() { - - /** - * @type {module:zrender/core/LRU~Entry} - */ - this.head = null; - - /** - * @type {module:zrender/core/LRU~Entry} - */ - this.tail = null; - - this._len = 0; - }; - - var linkedListProto = LinkedList.prototype; - /** - * Insert a new value at the tail - * @param {} val - * @return {module:zrender/core/LRU~Entry} - */ - linkedListProto.insert = function(val) { - var entry = new Entry(val); - this.insertEntry(entry); - return entry; - }; - - /** - * Insert an entry at the tail - * @param {module:zrender/core/LRU~Entry} entry - */ - linkedListProto.insertEntry = function(entry) { - if (!this.head) { - this.head = this.tail = entry; - } - else { - this.tail.next = entry; - entry.prev = this.tail; - this.tail = entry; - } - this._len++; - }; - - /** - * Remove entry. - * @param {module:zrender/core/LRU~Entry} entry - */ - linkedListProto.remove = function(entry) { - var prev = entry.prev; - var next = entry.next; - if (prev) { - prev.next = next; - } - else { - // Is head - this.head = next; - } - if (next) { - next.prev = prev; - } - else { - // Is tail - this.tail = prev; - } - entry.next = entry.prev = null; - this._len--; - }; - - /** - * @return {number} - */ - linkedListProto.len = function() { - return this._len; - }; - - /** - * @constructor - * @param {} val - */ - var Entry = function(val) { - /** - * @type {} - */ - this.value = val; - - /** - * @type {module:zrender/core/LRU~Entry} - */ - this.next; - - /** - * @type {module:zrender/core/LRU~Entry} - */ - this.prev; - }; - - /** - * LRU Cache - * @constructor - * @alias module:zrender/core/LRU - */ - var LRU = function(maxSize) { - - this._list = new LinkedList(); - - this._map = {}; - - this._maxSize = maxSize || 10; - }; - - var LRUProto = LRU.prototype; - - /** - * @param {string} key - * @param {} value - */ - LRUProto.put = function(key, value) { - var list = this._list; - var map = this._map; - if (map[key] == null) { - var len = list.len(); - if (len >= this._maxSize && len > 0) { - // Remove the least recently used - var leastUsedEntry = list.head; - list.remove(leastUsedEntry); - delete map[leastUsedEntry.key]; - } - - var entry = list.insert(value); - entry.key = key; - map[key] = entry; - } - }; - - /** - * @param {string} key - * @return {} - */ - LRUProto.get = function(key) { - var entry = this._map[key]; - var list = this._list; - if (entry != null) { - // Put the latest used entry in the tail - if (entry !== list.tail) { - list.remove(entry); - list.insertEntry(entry); - } - - return entry.value; - } - }; - - /** - * Clear the cache - */ - LRUProto.clear = function() { - this._list.clear(); - this._map = {}; - }; - - return LRU; -}); -/** - * Image element - * @module zrender/graphic/Image - */ - -define('zrender/graphic/Image',['require','./Displayable','../core/BoundingRect','../core/util','./helper/roundRect','../core/LRU'],function (require) { - - var Displayable = require('./Displayable'); - var BoundingRect = require('../core/BoundingRect'); - var zrUtil = require('../core/util'); - var roundRectHelper = require('./helper/roundRect'); - - var LRU = require('../core/LRU'); - var globalImageCache = new LRU(50); - /** - * @alias zrender/graphic/Image - * @extends module:zrender/graphic/Displayable - * @constructor - * @param {Object} opts - */ - var ZImage = function (opts) { - Displayable.call(this, opts); - }; - - ZImage.prototype = { - - constructor: ZImage, - - type: 'image', - - brush: function (ctx) { - var style = this.style; - var src = style.image; - var image; - // style.image is a url string - if (typeof src === 'string') { - image = this._image; - } - // style.image is an HTMLImageElement or HTMLCanvasElement or Canvas - else { - image = src; - } - // FIXME Case create many images with src - if (!image && src) { - // Try get from global image cache - var cachedImgObj = globalImageCache.get(src); - if (!cachedImgObj) { - // Create a new image - image = new Image(); - image.onload = function () { - image.onload = null; - for (var i = 0; i < cachedImgObj.pending.length; i++) { - cachedImgObj.pending[i].dirty(); - } - }; - cachedImgObj = { - image: image, - pending: [this] - }; - image.src = src; - globalImageCache.put(src, cachedImgObj); - this._image = image; - return; - } - else { - image = cachedImgObj.image; - this._image = image; - // Image is not complete finish, add to pending list - if (!image.width || !image.height) { - cachedImgObj.pending.push(this); - return; - } - } - } - - if (image) { - // 图片已经加载完成 - // if (image.nodeName.toUpperCase() == 'IMG') { - // if (!image.complete) { - // return; - // } - // } - // Else is canvas - - var width = style.width || image.width; - var height = style.height || image.height; - var x = style.x || 0; - var y = style.y || 0; - // 图片加载失败 - if (!image.width || !image.height) { - return; - } - - ctx.save(); - - style.bind(ctx); - - // 设置transform - this.setTransform(ctx); - - if (style.r) { - // Border radius clipping - // FIXME - ctx.beginPath(); - roundRectHelper.buildPath(ctx, style); - ctx.clip(); - } - - if (style.sWidth && style.sHeight) { - var sx = style.sx || 0; - var sy = style.sy || 0; - ctx.drawImage( - image, - sx, sy, style.sWidth, style.sHeight, - x, y, width, height - ); - } - else if (style.sx && style.sy) { - var sx = style.sx; - var sy = style.sy; - var sWidth = width - sx; - var sHeight = height - sy; - ctx.drawImage( - image, - sx, sy, sWidth, sHeight, - x, y, width, height - ); - } - else { - ctx.drawImage(image, x, y, width, height); - } - - // 如果没设置宽和高的话自动根据图片宽高设置 - if (style.width == null) { - style.width = width; - } - if (style.height == null) { - style.height = height; - } - - // Draw rect text - if (style.text != null) { - this.drawRectText(ctx, this.getBoundingRect()); - } - - ctx.restore(); - } - }, - - getBoundingRect: function () { - var style = this.style; - if (! this._rect) { - this._rect = new BoundingRect( - style.x || 0, style.y || 0, style.width || 0, style.height || 0 - ); - } - return this._rect; - } - }; - - zrUtil.inherits(ZImage, Displayable); - - return ZImage; -}); -/** - * Text element - * @module zrender/graphic/Text - * - * TODO Wrapping - */ - -define('zrender/graphic/Text',['require','./Displayable','../core/util','../contain/text'],function (require) { - - var Displayable = require('./Displayable'); - var zrUtil = require('../core/util'); - var textContain = require('../contain/text'); - - /** - * @alias zrender/graphic/Text - * @extends module:zrender/graphic/Displayable - * @constructor - * @param {Object} opts - */ - var Text = function (opts) { - Displayable.call(this, opts); - }; - - Text.prototype = { - - constructor: Text, - - type: 'text', - - brush: function (ctx) { - var style = this.style; - var x = style.x || 0; - var y = style.y || 0; - // Convert to string - var text = style.text; - var textFill = style.fill; - var textStroke = style.stroke; - - // Convert to string - text != null && (text += ''); - - if (text) { - ctx.save(); - - this.style.bind(ctx); - this.setTransform(ctx); - - textFill && (ctx.fillStyle = textFill); - textStroke && (ctx.strokeStyle = textStroke); - - ctx.font = style.textFont || style.font; - ctx.textAlign = style.textAlign; - ctx.textBaseline = style.textBaseline; - - var lineHeight = textContain.measureText('国', ctx.font).width; - - var textLines = text.split('\n'); - for (var i = 0; i < textLines.length; i++) { - textFill && ctx.fillText(textLines[i], x, y); - textStroke && ctx.strokeText(textLines[i], x, y); - y += lineHeight; - } - - ctx.restore(); - } - }, - - getBoundingRect: function () { - if (!this._rect) { - var style = this.style; - var rect = textContain.getBoundingRect( - style.text + '', style.textFont, style.textAlign, style.textBaseline - ); - rect.x += style.x || 0; - rect.y += style.y || 0; - this._rect = rect; - } - return this._rect; - } - }; - - zrUtil.inherits(Text, Displayable); - - return Text; -}); -/** - * 圆形 - * @module zrender/shape/Circle - */ - -define('zrender/graphic/shape/Circle',['require','../Path'],function (require) { - - - return require('../Path').extend({ - - type: 'circle', - - shape: { - cx: 0, - cy: 0, - r: 0 - }, - - buildPath : function (ctx, shape) { - // Better stroking in ShapeBundle - ctx.moveTo(shape.cx + shape.r, shape.cy); - ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true); - return; - } - }); -}); - -/** - * 扇形 - * @module zrender/graphic/shape/Sector - */ - -// FIXME clockwise seems wrong -define('zrender/graphic/shape/Sector',['require','../Path'],function (require) { - - return require('../Path').extend({ - - type: 'sector', - - shape: { - - cx: 0, - - cy: 0, - - r0: 0, - - r: 0, - - startAngle: 0, - - endAngle: Math.PI * 2, - - clockwise: true - }, - - buildPath: function (ctx, shape) { - - var x = shape.cx; - var y = shape.cy; - var r0 = Math.max(shape.r0 || 0, 0); - var r = Math.max(shape.r, 0); - var startAngle = shape.startAngle; - var endAngle = shape.endAngle; - var clockwise = shape.clockwise; - - var unitX = Math.cos(startAngle); - var unitY = Math.sin(startAngle); - - ctx.moveTo(unitX * r0 + x, unitY * r0 + y); - - ctx.lineTo(unitX * r + x, unitY * r + y); +/***/ }, +/* 65 */ +/***/ function(module, exports, __webpack_require__) { - ctx.arc(x, y, r, startAngle, endAngle, !clockwise); + /** + * 圆环 + * @module zrender/graphic/shape/Ring + */ - ctx.lineTo( - Math.cos(endAngle) * r0 + x, - Math.sin(endAngle) * r0 + y - ); - if (r0 !== 0) { - ctx.arc(x, y, r0, endAngle, startAngle, clockwise); - } + module.exports = __webpack_require__(44).extend({ - ctx.closePath(); - } - }); -}); + type: 'ring', -/** - * Catmull-Rom spline 插值折线 - * @module zrender/shape/util/smoothSpline - * @author pissang (https://www.github.com/pissang) - * Kener (@Kener-林峰, kener.linfeng@gmail.com) - * errorrik (errorrik@gmail.com) - */ -define('zrender/graphic/helper/smoothSpline',['require','../../core/vector'],function (require) { - var vec2 = require('../../core/vector'); - - /** - * @inner - */ - function interpolate(p0, p1, p2, p3, t, t2, t3) { - var v0 = (p2 - p0) * 0.5; - var v1 = (p3 - p1) * 0.5; - return (2 * (p1 - p2) + v0 + v1) * t3 - + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 - + v0 * t + p1; - } - - /** - * @alias module:zrender/shape/util/smoothSpline - * @param {Array} points 线段顶点数组 - * @param {boolean} isLoop - * @return {Array} - */ - return function (points, isLoop) { - var len = points.length; - var ret = []; - - var distance = 0; - for (var i = 1; i < len; i++) { - distance += vec2.distance(points[i - 1], points[i]); - } - - var segs = distance / 2; - segs = segs < len ? len : segs; - for (var i = 0; i < segs; i++) { - var pos = i / (segs - 1) * (isLoop ? len : len - 1); - var idx = Math.floor(pos); - - var w = pos - idx; - - var p0; - var p1 = points[idx % len]; - var p2; - var p3; - if (!isLoop) { - p0 = points[idx === 0 ? idx : idx - 1]; - p2 = points[idx > len - 2 ? len - 1 : idx + 1]; - p3 = points[idx > len - 3 ? len - 1 : idx + 2]; - } - else { - p0 = points[(idx - 1 + len) % len]; - p2 = points[(idx + 1) % len]; - p3 = points[(idx + 2) % len]; - } - - var w2 = w * w; - var w3 = w * w2; - - ret.push([ - interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3), - interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3) - ]); - } - return ret; - }; -}); + shape: { + cx: 0, + cy: 0, + r: 0, + r0: 0 + }, -/** - * 贝塞尔平滑曲线 - * @module zrender/shape/util/smoothBezier - * @author pissang (https://www.github.com/pissang) - * Kener (@Kener-林峰, kener.linfeng@gmail.com) - * errorrik (errorrik@gmail.com) - */ -define('zrender/graphic/helper/smoothBezier',['require','../../core/vector'],function (require) { - - var vec2 = require('../../core/vector'); - var v2Min = vec2.min; - var v2Max = vec2.max; - var v2Scale = vec2.scale; - var v2Distance = vec2.distance; - var v2Add = vec2.add; - - /** - * 贝塞尔平滑曲线 - * @alias module:zrender/shape/util/smoothBezier - * @param {Array} points 线段顶点数组 - * @param {number} smooth 平滑等级, 0-1 - * @param {boolean} isLoop - * @param {Array} constraint 将计算出来的控制点约束在一个包围盒内 - * 比如 [[0, 0], [100, 100]], 这个包围盒会与 - * 整个折线的包围盒做一个并集用来约束控制点。 - * @param {Array} 计算出来的控制点数组 - */ - return function (points, smooth, isLoop, constraint) { - var cps = []; - - var v = []; - var v1 = []; - var v2 = []; - var prevPoint; - var nextPoint; - - var min, max; - if (constraint) { - min = [Infinity, Infinity]; - max = [-Infinity, -Infinity]; - for (var i = 0, len = points.length; i < len; i++) { - v2Min(min, min, points[i]); - v2Max(max, max, points[i]); - } - // 与指定的包围盒做并集 - v2Min(min, min, constraint[0]); - v2Max(max, max, constraint[1]); - } - - for (var i = 0, len = points.length; i < len; i++) { - var point = points[i]; - - if (isLoop) { - prevPoint = points[i ? i - 1 : len - 1]; - nextPoint = points[(i + 1) % len]; - } - else { - if (i === 0 || i === len - 1) { - cps.push(vec2.clone(points[i])); - continue; - } - else { - prevPoint = points[i - 1]; - nextPoint = points[i + 1]; - } - } - - vec2.sub(v, nextPoint, prevPoint); - - // use degree to scale the handle length - v2Scale(v, v, smooth); - - var d0 = v2Distance(point, prevPoint); - var d1 = v2Distance(point, nextPoint); - var sum = d0 + d1; - if (sum !== 0) { - d0 /= sum; - d1 /= sum; - } - - v2Scale(v1, v, -d0); - v2Scale(v2, v, d1); - var cp0 = v2Add([], point, v1); - var cp1 = v2Add([], point, v2); - if (constraint) { - v2Max(cp0, cp0, min); - v2Min(cp0, cp0, max); - v2Max(cp1, cp1, min); - v2Min(cp1, cp1, max); - } - cps.push(cp0); - cps.push(cp1); - } - - if (isLoop) { - cps.push(cps.shift()); - } - - return cps; - }; -}); + buildPath: function (ctx, shape) { + var x = shape.cx; + var y = shape.cy; + var PI2 = Math.PI * 2; + ctx.moveTo(x + shape.r, y); + ctx.arc(x, y, shape.r, 0, PI2, false); + ctx.moveTo(x + shape.r0, y); + ctx.arc(x, y, shape.r0, 0, PI2, true); + } + }); -define('zrender/graphic/helper/poly',['require','./smoothSpline','./smoothBezier'],function (require) { - - var smoothSpline = require('./smoothSpline'); - var smoothBezier = require('./smoothBezier'); - - return { - buildPath: function (ctx, shape, closePath) { - var points = shape.points; - var smooth = shape.smooth; - if (points && points.length >= 2) { - if (smooth && smooth !== 'spline') { - var controlPoints = smoothBezier( - points, smooth, closePath, shape.smoothConstraint - ); - - ctx.moveTo(points[0][0], points[0][1]); - var len = points.length; - for (var i = 0; i < (closePath ? len : len - 1); i++) { - var cp1 = controlPoints[i * 2]; - var cp2 = controlPoints[i * 2 + 1]; - var p = points[(i + 1) % len]; - ctx.bezierCurveTo( - cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1] - ); - } - } - else { - if (smooth === 'spline') { - points = smoothSpline(points, closePath); - } - - ctx.moveTo(points[0][0], points[0][1]); - for (var i = 1, l = points.length; i < l; i++) { - ctx.lineTo(points[i][0], points[i][1]); - } - } - - closePath && ctx.closePath(); - } - } - }; -}); -/** - * 多边形 - * @module zrender/shape/Polygon - */ -define('zrender/graphic/shape/Polygon',['require','../helper/poly','../Path'],function (require) { - var polyHelper = require('../helper/poly'); - return require('../Path').extend({ - - type: 'polygon', +/***/ }, +/* 66 */ +/***/ function(module, exports, __webpack_require__) { - shape: { - points: null, + /** + * 多边形 + * @module zrender/shape/Polygon + */ - smooth: false, - smoothConstraint: null - }, + var polyHelper = __webpack_require__(67); - buildPath: function (ctx, shape) { - polyHelper.buildPath(ctx, shape, true); - } - }); -}); -/** - * @module zrender/graphic/shape/Polyline - */ -define('zrender/graphic/shape/Polyline',['require','../helper/poly','../Path'],function (require) { + module.exports = __webpack_require__(44).extend({ + + type: 'polygon', - var polyHelper = require('../helper/poly'); + shape: { + points: null, - return require('../Path').extend({ - - type: 'polyline', + smooth: false, - shape: { - points: null, + smoothConstraint: null + }, + + buildPath: function (ctx, shape) { + polyHelper.buildPath(ctx, shape, true); + } + }); + + +/***/ }, +/* 67 */ +/***/ function(module, exports, __webpack_require__) { + + + + var smoothSpline = __webpack_require__(68); + var smoothBezier = __webpack_require__(69); + + module.exports = { + buildPath: function (ctx, shape, closePath) { + var points = shape.points; + var smooth = shape.smooth; + if (points && points.length >= 2) { + if (smooth && smooth !== 'spline') { + var controlPoints = smoothBezier( + points, smooth, closePath, shape.smoothConstraint + ); + + ctx.moveTo(points[0][0], points[0][1]); + var len = points.length; + for (var i = 0; i < (closePath ? len : len - 1); i++) { + var cp1 = controlPoints[i * 2]; + var cp2 = controlPoints[i * 2 + 1]; + var p = points[(i + 1) % len]; + ctx.bezierCurveTo( + cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1] + ); + } + } + else { + if (smooth === 'spline') { + points = smoothSpline(points, closePath); + } + + ctx.moveTo(points[0][0], points[0][1]); + for (var i = 1, l = points.length; i < l; i++) { + ctx.lineTo(points[i][0], points[i][1]); + } + } + + closePath && ctx.closePath(); + } + } + }; + + +/***/ }, +/* 68 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Catmull-Rom spline 插值折线 + * @module zrender/shape/util/smoothSpline + * @author pissang (https://www.github.com/pissang) + * Kener (@Kener-林峰, kener.linfeng@gmail.com) + * errorrik (errorrik@gmail.com) + */ + + var vec2 = __webpack_require__(16); + + /** + * @inner + */ + function interpolate(p0, p1, p2, p3, t, t2, t3) { + var v0 = (p2 - p0) * 0.5; + var v1 = (p3 - p1) * 0.5; + return (2 * (p1 - p2) + v0 + v1) * t3 + + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + + v0 * t + p1; + } + + /** + * @alias module:zrender/shape/util/smoothSpline + * @param {Array} points 线段顶点数组 + * @param {boolean} isLoop + * @return {Array} + */ + module.exports = function (points, isLoop) { + var len = points.length; + var ret = []; + + var distance = 0; + for (var i = 1; i < len; i++) { + distance += vec2.distance(points[i - 1], points[i]); + } + + var segs = distance / 2; + segs = segs < len ? len : segs; + for (var i = 0; i < segs; i++) { + var pos = i / (segs - 1) * (isLoop ? len : len - 1); + var idx = Math.floor(pos); + + var w = pos - idx; + + var p0; + var p1 = points[idx % len]; + var p2; + var p3; + if (!isLoop) { + p0 = points[idx === 0 ? idx : idx - 1]; + p2 = points[idx > len - 2 ? len - 1 : idx + 1]; + p3 = points[idx > len - 3 ? len - 1 : idx + 2]; + } + else { + p0 = points[(idx - 1 + len) % len]; + p2 = points[(idx + 1) % len]; + p3 = points[(idx + 2) % len]; + } + + var w2 = w * w; + var w3 = w * w2; + + ret.push([ + interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3), + interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3) + ]); + } + return ret; + }; + + + +/***/ }, +/* 69 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 贝塞尔平滑曲线 + * @module zrender/shape/util/smoothBezier + * @author pissang (https://www.github.com/pissang) + * Kener (@Kener-林峰, kener.linfeng@gmail.com) + * errorrik (errorrik@gmail.com) + */ + + + var vec2 = __webpack_require__(16); + var v2Min = vec2.min; + var v2Max = vec2.max; + var v2Scale = vec2.scale; + var v2Distance = vec2.distance; + var v2Add = vec2.add; + + /** + * 贝塞尔平滑曲线 + * @alias module:zrender/shape/util/smoothBezier + * @param {Array} points 线段顶点数组 + * @param {number} smooth 平滑等级, 0-1 + * @param {boolean} isLoop + * @param {Array} constraint 将计算出来的控制点约束在一个包围盒内 + * 比如 [[0, 0], [100, 100]], 这个包围盒会与 + * 整个折线的包围盒做一个并集用来约束控制点。 + * @param {Array} 计算出来的控制点数组 + */ + module.exports = function (points, smooth, isLoop, constraint) { + var cps = []; + + var v = []; + var v1 = []; + var v2 = []; + var prevPoint; + var nextPoint; + + var min, max; + if (constraint) { + min = [Infinity, Infinity]; + max = [-Infinity, -Infinity]; + for (var i = 0, len = points.length; i < len; i++) { + v2Min(min, min, points[i]); + v2Max(max, max, points[i]); + } + // 与指定的包围盒做并集 + v2Min(min, min, constraint[0]); + v2Max(max, max, constraint[1]); + } + + for (var i = 0, len = points.length; i < len; i++) { + var point = points[i]; + + if (isLoop) { + prevPoint = points[i ? i - 1 : len - 1]; + nextPoint = points[(i + 1) % len]; + } + else { + if (i === 0 || i === len - 1) { + cps.push(vec2.clone(points[i])); + continue; + } + else { + prevPoint = points[i - 1]; + nextPoint = points[i + 1]; + } + } + + vec2.sub(v, nextPoint, prevPoint); + + // use degree to scale the handle length + v2Scale(v, v, smooth); + + var d0 = v2Distance(point, prevPoint); + var d1 = v2Distance(point, nextPoint); + var sum = d0 + d1; + if (sum !== 0) { + d0 /= sum; + d1 /= sum; + } + + v2Scale(v1, v, -d0); + v2Scale(v2, v, d1); + var cp0 = v2Add([], point, v1); + var cp1 = v2Add([], point, v2); + if (constraint) { + v2Max(cp0, cp0, min); + v2Min(cp0, cp0, max); + v2Max(cp1, cp1, min); + v2Min(cp1, cp1, max); + } + cps.push(cp0); + cps.push(cp1); + } + + if (isLoop) { + cps.push(cps.shift()); + } + + return cps; + }; + + + +/***/ }, +/* 70 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module zrender/graphic/shape/Polyline + */ + + + var polyHelper = __webpack_require__(67); + + module.exports = __webpack_require__(44).extend({ + + type: 'polyline', + + shape: { + points: null, + + smooth: false, + + smoothConstraint: null + }, + + style: { + stroke: '#000', + + fill: null + }, + + buildPath: function (ctx, shape) { + polyHelper.buildPath(ctx, shape, false); + } + }); + + +/***/ }, +/* 71 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 矩形 + * @module zrender/graphic/shape/Rect + */ + + + var roundRectHelper = __webpack_require__(60); + + module.exports = __webpack_require__(44).extend({ + + type: 'rect', + + shape: { + // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4 + // r缩写为1 相当于 [1, 1, 1, 1] + // r缩写为[1] 相当于 [1, 1, 1, 1] + // r缩写为[1, 2] 相当于 [1, 2, 1, 2] + // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2] + r: 0, + + x: 0, + y: 0, + width: 0, + height: 0 + }, + + buildPath: function (ctx, shape) { + var x = shape.x; + var y = shape.y; + var width = shape.width; + var height = shape.height; + if (!shape.r) { + ctx.rect(x, y, width, height); + } + else { + roundRectHelper.buildPath(ctx, shape); + } + ctx.closePath(); + return; + } + }); + + + +/***/ }, +/* 72 */ +/***/ function(module, exports, __webpack_require__) { - smooth: false, + /** + * 直线 + * @module zrender/graphic/shape/Line + */ - smoothConstraint: null - }, + module.exports = __webpack_require__(44).extend({ - style: { - stroke: '#000', + type: 'line', + + shape: { + // Start point + x1: 0, + y1: 0, + // End point + x2: 0, + y2: 0, + + percent: 1 + }, + + style: { + stroke: '#000', + fill: null + }, + + buildPath: function (ctx, shape) { + var x1 = shape.x1; + var y1 = shape.y1; + var x2 = shape.x2; + var y2 = shape.y2; + var percent = shape.percent; + + if (percent === 0) { + return; + } + + ctx.moveTo(x1, y1); + + if (percent < 1) { + x2 = x1 * (1 - percent) + x2 * percent; + y2 = y1 * (1 - percent) + y2 * percent; + } + ctx.lineTo(x2, y2); + }, + + /** + * Get point at percent + * @param {number} percent + * @return {Array.} + */ + pointAt: function (p) { + var shape = this.shape; + return [ + shape.x1 * (1 - p) + shape.x2 * p, + shape.y1 * (1 - p) + shape.y2 * p + ]; + } + }); + + + +/***/ }, +/* 73 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 贝塞尔曲线 + * @module zrender/shape/BezierCurve + */ + + + var curveTool = __webpack_require__(49); + var quadraticSubdivide = curveTool.quadraticSubdivide; + var cubicSubdivide = curveTool.cubicSubdivide; + var quadraticAt = curveTool.quadraticAt; + var cubicAt = curveTool.cubicAt; + + var out = []; + module.exports = __webpack_require__(44).extend({ + + type: 'bezier-curve', + + shape: { + x1: 0, + y1: 0, + x2: 0, + y2: 0, + cpx1: 0, + cpy1: 0, + // cpx2: 0, + // cpy2: 0 + + // Curve show percent, for animating + percent: 1 + }, + + style: { + stroke: '#000', + fill: null + }, + + buildPath: function (ctx, shape) { + var x1 = shape.x1; + var y1 = shape.y1; + var x2 = shape.x2; + var y2 = shape.y2; + var cpx1 = shape.cpx1; + var cpy1 = shape.cpy1; + var cpx2 = shape.cpx2; + var cpy2 = shape.cpy2; + var percent = shape.percent; + if (percent === 0) { + return; + } + + ctx.moveTo(x1, y1); + + if (cpx2 == null || cpy2 == null) { + if (percent < 1) { + quadraticSubdivide( + x1, cpx1, x2, percent, out + ); + cpx1 = out[1]; + x2 = out[2]; + quadraticSubdivide( + y1, cpy1, y2, percent, out + ); + cpy1 = out[1]; + y2 = out[2]; + } + + ctx.quadraticCurveTo( + cpx1, cpy1, + x2, y2 + ); + } + else { + if (percent < 1) { + cubicSubdivide( + x1, cpx1, cpx2, x2, percent, out + ); + cpx1 = out[1]; + cpx2 = out[2]; + x2 = out[3]; + cubicSubdivide( + y1, cpy1, cpy2, y2, percent, out + ); + cpy1 = out[1]; + cpy2 = out[2]; + y2 = out[3]; + } + ctx.bezierCurveTo( + cpx1, cpy1, + cpx2, cpy2, + x2, y2 + ); + } + }, + + /** + * Get point at percent + * @param {number} percent + * @return {Array.} + */ + pointAt: function (p) { + var shape = this.shape; + var cpx2 = shape.cpx2; + var cpy2 = shape.cpy2; + if (cpx2 === null || cpy2 === null) { + return [ + quadraticAt(shape.x1, shape.cpx1, shape.x2, p), + quadraticAt(shape.y1, shape.cpy1, shape.y2, p) + ]; + } + else { + return [ + cubicAt(shape.x1, shape.cpx1, shape.cpx1, shape.x2, p), + cubicAt(shape.y1, shape.cpy1, shape.cpy1, shape.y2, p) + ]; + } + } + }); + + + +/***/ }, +/* 74 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * 圆弧 + * @module zrender/graphic/shape/Arc + */ + + + module.exports = __webpack_require__(44).extend({ + + type: 'arc', + + shape: { + + cx: 0, + + cy: 0, + + r: 0, + + startAngle: 0, + + endAngle: Math.PI * 2, - fill: null - }, + clockwise: true + }, - buildPath: function (ctx, shape) { - polyHelper.buildPath(ctx, shape, false); - } - }); -}); -/** - * 矩形 - * @module zrender/graphic/shape/Rect - */ - -define('zrender/graphic/shape/Rect',['require','../helper/roundRect','../Path'],function (require) { - var roundRectHelper = require('../helper/roundRect'); - - return require('../Path').extend({ - - type: 'rect', - - shape: { - // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4 - // r缩写为1 相当于 [1, 1, 1, 1] - // r缩写为[1] 相当于 [1, 1, 1, 1] - // r缩写为[1, 2] 相当于 [1, 2, 1, 2] - // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2] - r: 0, - - x: 0, - y: 0, - width: 0, - height: 0 - }, - - buildPath: function (ctx, shape) { - var x = shape.x; - var y = shape.y; - var width = shape.width; - var height = shape.height; - if (!shape.r) { - ctx.rect(x, y, width, height); - } - else { - roundRectHelper.buildPath(ctx, shape); - } - ctx.closePath(); - return; - } - }); -}); + style: { -/** - * 直线 - * @module zrender/graphic/shape/Line - */ -define('zrender/graphic/shape/Line',['require','../Path'],function (require) { - return require('../Path').extend({ - - type: 'line', - - shape: { - // Start point - x1: 0, - y1: 0, - // End point - x2: 0, - y2: 0, - - percent: 1 - }, - - style: { - stroke: '#000', - fill: null - }, - - buildPath: function (ctx, shape) { - var x1 = shape.x1; - var y1 = shape.y1; - var x2 = shape.x2; - var y2 = shape.y2; - var percent = shape.percent; - - if (percent === 0) { - return; - } - - ctx.moveTo(x1, y1); - - if (percent < 1) { - x2 = x1 * (1 - percent) + x2 * percent; - y2 = y1 * (1 - percent) + y2 * percent; - } - ctx.lineTo(x2, y2); - }, - - /** - * Get point at percent - * @param {number} percent - * @return {Array.} - */ - pointAt: function (p) { - var shape = this.shape; - return [ - shape.x1 * (1 - p) + shape.x2 * p, - shape.y1 * (1 - p) + shape.y2 * p - ]; - } - }); -}); - -/** - * 贝塞尔曲线 - * @module zrender/shape/BezierCurve - */ -define('zrender/graphic/shape/BezierCurve',['require','../../core/curve','../Path'],function (require) { - - - var curveTool = require('../../core/curve'); - var quadraticSubdivide = curveTool.quadraticSubdivide; - var cubicSubdivide = curveTool.cubicSubdivide; - var quadraticAt = curveTool.quadraticAt; - var cubicAt = curveTool.cubicAt; - - var out = []; - return require('../Path').extend({ - - type: 'bezier-curve', - - shape: { - x1: 0, - y1: 0, - x2: 0, - y2: 0, - cpx1: 0, - cpy1: 0, - // cpx2: 0, - // cpy2: 0 - - // Curve show percent, for animating - percent: 1 - }, - - style: { - stroke: '#000', - fill: null - }, - - buildPath: function (ctx, shape) { - var x1 = shape.x1; - var y1 = shape.y1; - var x2 = shape.x2; - var y2 = shape.y2; - var cpx1 = shape.cpx1; - var cpy1 = shape.cpy1; - var cpx2 = shape.cpx2; - var cpy2 = shape.cpy2; - var percent = shape.percent; - if (percent === 0) { - return; - } - - ctx.moveTo(x1, y1); - - if (cpx2 == null || cpy2 == null) { - if (percent < 1) { - quadraticSubdivide( - x1, cpx1, x2, percent, out - ); - cpx1 = out[1]; - x2 = out[2]; - quadraticSubdivide( - y1, cpy1, y2, percent, out - ); - cpy1 = out[1]; - y2 = out[2]; - } - - ctx.quadraticCurveTo( - cpx1, cpy1, - x2, y2 - ); - } - else { - if (percent < 1) { - cubicSubdivide( - x1, cpx1, cpx2, x2, percent, out - ); - cpx1 = out[1]; - cpx2 = out[2]; - x2 = out[3]; - cubicSubdivide( - y1, cpy1, cpy2, y2, percent, out - ); - cpy1 = out[1]; - cpy2 = out[2]; - y2 = out[3]; - } - ctx.bezierCurveTo( - cpx1, cpy1, - cpx2, cpy2, - x2, y2 - ); - } - }, - - /** - * Get point at percent - * @param {number} percent - * @return {Array.} - */ - pointAt: function (p) { - var shape = this.shape; - var cpx2 = shape.cpx2; - var cpy2 = shape.cpy2; - if (cpx2 === null || cpy2 === null) { - return [ - quadraticAt(shape.x1, shape.cpx1, shape.x2, p), - quadraticAt(shape.y1, shape.cpy1, shape.y2, p) - ]; - } - else { - return [ - cubicAt(shape.x1, shape.cpx1, shape.cpx1, shape.x2, p), - cubicAt(shape.y1, shape.cpy1, shape.cpy1, shape.y2, p) - ]; - } - } - }); -}); + stroke: '#000', -/** - * 圆弧 - * @module zrender/graphic/shape/Arc - */ - define('zrender/graphic/shape/Arc',['require','../Path'],function (require) { + fill: null + }, - return require('../Path').extend({ + buildPath: function (ctx, shape) { - type: 'arc', + var x = shape.cx; + var y = shape.cy; + var r = Math.max(shape.r, 0); + var startAngle = shape.startAngle; + var endAngle = shape.endAngle; + var clockwise = shape.clockwise; - shape: { + var unitX = Math.cos(startAngle); + var unitY = Math.sin(startAngle); - cx: 0, + ctx.moveTo(unitX * r + x, unitY * r + y); + ctx.arc(x, y, r, startAngle, endAngle, !clockwise); + } + }); - cy: 0, - r: 0, +/***/ }, +/* 75 */ +/***/ function(module, exports, __webpack_require__) { - startAngle: 0, + 'use strict'; - endAngle: Math.PI * 2, - clockwise: true - }, + var zrUtil = __webpack_require__(3); - style: { + var Gradient = __webpack_require__(4); - stroke: '#000', + /** + * x, y, x2, y2 are all percent from 0 to 1 + * @param {number} [x=0] + * @param {number} [y=0] + * @param {number} [x2=1] + * @param {number} [y2=0] + * @param {Array.} colorStops + */ + var LinearGradient = function (x, y, x2, y2, colorStops) { + this.x = x == null ? 0 : x; - fill: null - }, + this.y = y == null ? 0 : y; - buildPath: function (ctx, shape) { + this.x2 = x2 == null ? 1 : x2; - var x = shape.cx; - var y = shape.cy; - var r = Math.max(shape.r, 0); - var startAngle = shape.startAngle; - var endAngle = shape.endAngle; - var clockwise = shape.clockwise; + this.y2 = y2 == null ? 0 : y2; - var unitX = Math.cos(startAngle); - var unitY = Math.sin(startAngle); + Gradient.call(this, colorStops); + }; - ctx.moveTo(unitX * r + x, unitY * r + y); - ctx.arc(x, y, r, startAngle, endAngle, !clockwise); - } - }); -}); -define('zrender/graphic/LinearGradient',['require','../core/util','./Gradient'],function(require) { - + LinearGradient.prototype = { - var zrUtil = require('../core/util'); + constructor: LinearGradient, - var Gradient = require('./Gradient'); + type: 'linear', - /** - * x, y, x2, y2 are all percent from 0 to 1 - * @param {number} [x=0] - * @param {number} [y=0] - * @param {number} [x2=1] - * @param {number} [y2=0] - * @param {Array.} colorStops - */ - var LinearGradient = function (x, y, x2, y2, colorStops) { - this.x = x == null ? 0 : x; + updateCanvasGradient: function (shape, ctx) { + var rect = shape.getBoundingRect(); + // var size = + var x = this.x * rect.width + rect.x; + var x2 = this.x2 * rect.width + rect.x; + var y = this.y * rect.height + rect.y; + var y2 = this.y2 * rect.height + rect.y; - this.y = y == null ? 0 : y; + var canvasGradient = ctx.createLinearGradient(x, y, x2, y2); - this.x2 = x2 == null ? 1 : x2; + var colorStops = this.colorStops; + for (var i = 0; i < colorStops.length; i++) { + canvasGradient.addColorStop( + colorStops[i].offset, colorStops[i].color + ); + } - this.y2 = y2 == null ? 0 : y2; + this.canvasGradient = canvasGradient; + } - Gradient.call(this, colorStops); - }; + }; - LinearGradient.prototype = { + zrUtil.inherits(LinearGradient, Gradient); - constructor: LinearGradient, + module.exports = LinearGradient; - type: 'linear', - updateCanvasGradient: function (shape, ctx) { - var rect = shape.getBoundingRect(); - // var size = - var x = this.x * rect.width + rect.x; - var x2 = this.x2 * rect.width + rect.x; - var y = this.y * rect.height + rect.y; - var y2 = this.y2 * rect.height + rect.y; +/***/ }, +/* 76 */ +/***/ function(module, exports, __webpack_require__) { - var canvasGradient = ctx.createLinearGradient(x, y, x2, y2); + 'use strict'; - var colorStops = this.colorStops; - for (var i = 0; i < colorStops.length; i++) { - canvasGradient.addColorStop( - colorStops[i].offset, colorStops[i].color - ); - } - this.canvasGradient = canvasGradient; - } + var zrUtil = __webpack_require__(3); - }; + var Gradient = __webpack_require__(4); - zrUtil.inherits(LinearGradient, Gradient); + /** + * x, y, r are all percent from 0 to 1 + * @param {number} [x=0.5] + * @param {number} [y=0.5] + * @param {number} [r=0.5] + * @param {Array.} [colorStops] + */ + var RadialGradient = function (x, y, r, colorStops) { + this.x = x == null ? 0.5 : x; - return LinearGradient; -}); -define('zrender/graphic/RadialGradient',['require','../core/util','./Gradient'],function(require) { - + this.y = y == null ? 0.5 : y; - var zrUtil = require('../core/util'); + this.r = r == null ? 0.5 : r; - var Gradient = require('./Gradient'); + Gradient.call(this, colorStops); + }; - /** - * x, y, r are all percent from 0 to 1 - * @param {number} [x=0.5] - * @param {number} [y=0.5] - * @param {number} [r=0.5] - * @param {Array.} [colorStops] - */ - var RadialGradient = function (x, y, r, colorStops) { - this.x = x == null ? 0.5 : x; + RadialGradient.prototype = { - this.y = y == null ? 0.5 : y; + constructor: RadialGradient, - this.r = r == null ? 0.5 : r; + type: 'radial', - Gradient.call(this, colorStops); - }; + updateCanvasGradient: function (shape, ctx) { + var rect = shape.getBoundingRect(); - RadialGradient.prototype = { + var width = rect.width; + var height = rect.height; + var min = Math.min(width, height); + // var max = Math.max(width, height); - constructor: RadialGradient, + var x = this.x * width + rect.x; + var y = this.y * height + rect.y; + var r = this.r * min; - type: 'radial', + var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r); - updateCanvasGradient: function (shape, ctx) { - var rect = shape.getBoundingRect(); + var colorStops = this.colorStops; + for (var i = 0; i < colorStops.length; i++) { + canvasGradient.addColorStop( + colorStops[i].offset, colorStops[i].color + ); + } - var width = rect.width; - var height = rect.height; - var min = Math.min(width, height); - // var max = Math.max(width, height); + this.canvasGradient = canvasGradient; + } + }; + + zrUtil.inherits(RadialGradient, Gradient); + + module.exports = RadialGradient; - var x = this.x * width + rect.x; - var y = this.y * height + rect.y; - var r = this.r * min; - var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r); +/***/ }, +/* 77 */ +/***/ function(module, exports, __webpack_require__) { + + /*! + * ZRender, a high performance 2d drawing library. + * + * Copyright (c) 2013, Baidu Inc. + * All rights reserved. + * + * LICENSE + * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt + */ + // Global defines + + var guid = __webpack_require__(31); + var env = __webpack_require__(78); + + var Handler = __webpack_require__(79); + var Storage = __webpack_require__(83); + var Animation = __webpack_require__(84); + + var useVML = !env.canvasSupported; + + var painterCtors = { + canvas: __webpack_require__(85) + }; + + var instances = {}; // ZRender实例map索引 + + var zrender = {}; + /** + * @type {string} + */ + zrender.version = '3.0.4'; + + /** + * @param {HTMLElement} dom + * @param {Object} opts + * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg' + * @param {number} [opts.devicePixelRatio] + * @return {module:zrender/ZRender} + */ + zrender.init = function(dom, opts) { + var zr = new ZRender(guid(), dom, opts); + instances[zr.id] = zr; + return zr; + }; + + /** + * Dispose zrender instance + * @param {module:zrender/ZRender} zr + */ + zrender.dispose = function (zr) { + if (zr) { + zr.dispose(); + } + else { + for (var key in instances) { + instances[key].dispose(); + } + instances = {}; + } + + return zrender; + }; + + /** + * 获取zrender实例 + * @param {string} id ZRender对象索引 + * @return {module:zrender/ZRender} + */ + zrender.getInstance = function (id) { + return instances[id]; + }; + + zrender.registerPainter = function (name, Ctor) { + painterCtors[name] = Ctor; + }; + + function delInstance(id) { + delete instances[id]; + } + + /** + * @module zrender/ZRender + */ + /** + * @constructor + * @alias module:zrender/ZRender + * @param {string} id + * @param {HTMLDomElement} dom + * @param {Object} opts + * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg' + * @param {number} [opts.devicePixelRatio] + */ + var ZRender = function(id, dom, opts) { + + opts = opts || {}; + + /** + * @type {HTMLDomElement} + */ + this.dom = dom; + + /** + * @type {string} + */ + this.id = id; + + var self = this; + var storage = new Storage(); + + var rendererType = opts.renderer; + if (useVML) { + if (!painterCtors.vml) { + throw new Error('You need to require \'zrender/vml/vml\' to support IE8'); + } + rendererType = 'vml'; + } + else if (!rendererType || !painterCtors[rendererType]) { + rendererType = 'canvas'; + } + var painter = new painterCtors[rendererType](dom, storage, opts); + + this.storage = storage; + this.painter = painter; + if (!env.node) { + this.handler = new Handler(painter.getViewportRoot(), storage, painter); + } + + /** + * @type {module:zrender/animation/Animation} + */ + this.animation = new Animation({ + stage: { + update: function () { + if (self._needsRefresh) { + self.refreshImmediately(); + } + } + } + }); + this.animation.start(); + + /** + * @type {boolean} + * @private + */ + this._needsRefresh; + + // 修改 storage.delFromMap, 每次删除元素之前删除动画 + // FIXME 有点ugly + var oldDelFromMap = storage.delFromMap; + var oldAddToMap = storage.addToMap; + + storage.delFromMap = function (elId) { + var el = storage.get(elId); + + oldDelFromMap.call(storage, elId); + + el && el.removeSelfFromZr(self); + }; + + storage.addToMap = function (el) { + oldAddToMap.call(storage, el); + + el.addSelfToZr(self); + }; + }; + + ZRender.prototype = { + + constructor: ZRender, + /** + * 获取实例唯一标识 + * @return {string} + */ + getId: function () { + return this.id; + }, + + /** + * 添加元素 + * @param {string|module:zrender/Element} el + */ + add: function (el) { + this.storage.addRoot(el); + this._needsRefresh = true; + }, + + /** + * 删除元素 + * @param {string|module:zrender/Element} el + */ + remove: function (el) { + this.storage.delRoot(el); + this._needsRefresh = true; + }, + + /** + * 修改指定zlevel的绘制配置项 + * + * @param {string} zLevel + * @param {Object} config 配置对象 + * @param {string} [config.clearColor=0] 每次清空画布的颜色 + * @param {string} [config.motionBlur=false] 是否开启动态模糊 + * @param {number} [config.lastFrameAlpha=0.7] + * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 + */ + configLayer: function (zLevel, config) { + this.painter.configLayer(zLevel, config); + this._needsRefresh = true; + }, + + /** + * 视图更新 + */ + refreshImmediately: function () { + // Clear needsRefresh ahead to avoid something wrong happens in refresh + // Or it will cause zrender refreshes again and again. + this._needsRefresh = false; + this.painter.refresh(); + /** + * Avoid trigger zr.refresh in Element#beforeUpdate hook + */ + this._needsRefresh = false; + }, + + /** + * 标记视图在浏览器下一帧需要绘制 + */ + refresh: function() { + this._needsRefresh = true; + }, + + /** + * 调整视图大小 + */ + resize: function() { + this.painter.resize(); + this.handler && this.handler.resize(); + }, + + /** + * 停止所有动画 + */ + clearAnimation: function () { + this.animation.clear(); + }, + + /** + * 获取视图宽度 + */ + getWidth: function() { + return this.painter.getWidth(); + }, + + /** + * 获取视图高度 + */ + getHeight: function() { + return this.painter.getHeight(); + }, + + /** + * 图像导出 + * @param {string} type + * @param {string} [backgroundColor='#fff'] 背景色 + * @return {string} 图片的Base64 url + */ + toDataURL: function(type, backgroundColor, args) { + return this.painter.toDataURL(type, backgroundColor, args); + }, + + /** + * 将常规shape转成image shape + * @param {module:zrender/graphic/Path} e + * @param {number} width + * @param {number} height + */ + pathToImage: function(e, width, height) { + var id = guid(); + return this.painter.pathToImage(id, e, width, height); + }, + + /** + * 设置默认的cursor style + * @param {string} cursorStyle 例如 crosshair + */ + setDefaultCursorStyle: function (cursorStyle) { + this.handler.setDefaultCursorStyle(cursorStyle); + }, + + /** + * 事件绑定 + * + * @param {string} eventName 事件名称 + * @param {Function} eventHandler 响应函数 + * @param {Object} [context] 响应函数 + */ + on: function(eventName, eventHandler, context) { + this.handler && this.handler.on(eventName, eventHandler, context); + }, + + /** + * 事件解绑定,参数为空则解绑所有自定义事件 + * + * @param {string} eventName 事件名称 + * @param {Function} eventHandler 响应函数 + */ + off: function(eventName, eventHandler) { + this.handler && this.handler.off(eventName, eventHandler); + }, + + /** + * 事件触发 + * + * @param {string} eventName 事件名称,resize,hover,drag,etc + * @param {event=} event event dom事件对象 + */ + trigger: function (eventName, event) { + this.handler && this.handler.trigger(eventName, event); + }, + + + /** + * 清除当前ZRender下所有类图的数据和显示,clear后MVC和已绑定事件均还存在在,ZRender可用 + */ + clear: function () { + this.storage.delRoot(); + this.painter.clear(); + }, + + /** + * 释放当前ZR实例(删除包括dom,数据、显示和事件绑定),dispose后ZR不可用 + */ + dispose: function () { + this.animation.stop(); + + this.clear(); + this.storage.dispose(); + this.painter.dispose(); + this.handler && this.handler.dispose(); + + this.animation = + this.storage = + this.painter = + this.handler = null; + + delInstance(this.id); + } + }; + + module.exports = zrender; + + + +/***/ }, +/* 78 */ +/***/ function(module, exports) { + + /** + * echarts设备环境识别 + * + * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。 + * @author firede[firede@firede.us] + * @desc thanks zepto. + */ + + var env = {}; + if (typeof navigator === 'undefined') { + // In node + env = { + browser: {}, + os: {}, + node: true, + // Assume canvas is supported + canvasSupported: true + }; + } + else { + env = detect(navigator.userAgent); + } + + module.exports = env; + + // Zepto.js + // (c) 2010-2013 Thomas Fuchs + // Zepto.js may be freely distributed under the MIT license. + + function detect(ua) { + var os = {}; + var browser = {}; + var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/); + var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); + var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); + var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); + var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/); + var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/); + var touchpad = webos && ua.match(/TouchPad/); + var kindle = ua.match(/Kindle\/([\d.]+)/); + var silk = ua.match(/Silk\/([\d._]+)/); + var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/); + var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/); + var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/); + var playbook = ua.match(/PlayBook/); + var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/); + var firefox = ua.match(/Firefox\/([\d.]+)/); + var safari = webkit && ua.match(/Mobile\//) && !chrome; + var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome; + var ie = ua.match(/MSIE\s([\d.]+)/) + // IE 11 Trident/7.0; rv:11.0 + || ua.match(/Trident\/.+?rv:(([\d.]+))/); + var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+ + + // Todo: clean this up with a better OS/browser seperation: + // - discern (more) between multiple browsers on android + // - decide if kindle fire in silk mode is android or not + // - Firefox on Android doesn't specify the Android version + // - possibly devide in os, device and browser hashes + + if (browser.webkit = !!webkit) browser.version = webkit[1]; + + if (android) os.android = true, os.version = android[2]; + if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.'); + if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.'); + if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null; + if (webos) os.webos = true, os.version = webos[2]; + if (touchpad) os.touchpad = true; + if (blackberry) os.blackberry = true, os.version = blackberry[2]; + if (bb10) os.bb10 = true, os.version = bb10[2]; + if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2]; + if (playbook) browser.playbook = true; + if (kindle) os.kindle = true, os.version = kindle[1]; + if (silk) browser.silk = true, browser.version = silk[1]; + if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true; + if (chrome) browser.chrome = true, browser.version = chrome[1]; + if (firefox) browser.firefox = true, browser.version = firefox[1]; + if (ie) browser.ie = true, browser.version = ie[1]; + if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true; + if (webview) browser.webview = true; + if (ie) browser.ie = true, browser.version = ie[1]; + if (edge) browser.edge = true, browser.version = edge[1]; + + os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) || + (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/))); + 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/)))); + + return { + browser: browser, + os: os, + node: false, + // 原生canvas支持,改极端点了 + // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9) + canvasSupported : document.createElement('canvas').getContext ? true : false, + // @see + // works on most browsers + // IE10/11 does not support touch event, and MS Edge supports them but not by + // default, so we dont check navigator.maxTouchPoints for them here. + touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge, + // . + pointerEventsSupported: 'onpointerdown' in window + // Firefox supports pointer but not by default, + // only MS browsers are reliable on pointer events currently. + && (browser.edge || (browser.ie && browser.version >= 10)) + }; + } + + +/***/ }, +/* 79 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Handler控制模块 + * @module zrender/Handler + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + * errorrik (errorrik@gmail.com) + * pissang (shenyi.914@gmail.com) + */ + + + var env = __webpack_require__(78); + var eventTool = __webpack_require__(80); + var util = __webpack_require__(3); + var Draggable = __webpack_require__(81); + var GestureMgr = __webpack_require__(82); + + var Eventful = __webpack_require__(32); + + var mouseHandlerNames = [ + 'click', 'dblclick', 'mousewheel', 'mouseout' + ]; + !usePointerEvent() && mouseHandlerNames.push( + 'mouseup', 'mousedown', 'mousemove' + ); + + var touchHandlerNames = [ + 'touchstart', 'touchend', 'touchmove' + ]; + + var pointerHandlerNames = [ + 'pointerdown', 'pointerup', 'pointermove' + ]; + + var TOUCH_CLICK_DELAY = 300; + + // touch指尖错觉的尝试偏移量配置 + // var MOBILE_TOUCH_OFFSETS = [ + // { x: 10 }, + // { x: -20 }, + // { x: 10, y: 10 }, + // { y: -20 } + // ]; + + var addEventListener = eventTool.addEventListener; + var removeEventListener = eventTool.removeEventListener; + var normalizeEvent = eventTool.normalizeEvent; + + function makeEventPacket(eveType, target, event) { + return { + type: eveType, + event: event, + target: target, + cancelBubble: false, + offsetX: event.zrX, + offsetY: event.zrY, + gestureEvent: event.gestureEvent, + pinchX: event.pinchX, + pinchY: event.pinchY, + pinchScale: event.pinchScale, + wheelDelta: event.zrDelta + }; + } + + var domHandlers = { + /** + * Mouse move handler + * @inner + * @param {Event} event + */ + mousemove: function (event) { + event = normalizeEvent(this.root, event); + + var x = event.zrX; + var y = event.zrY; + + var hovered = this.findHover(x, y, null); + var lastHovered = this._hovered; + + this._hovered = hovered; + + this.root.style.cursor = hovered ? hovered.cursor : this._defaultCursorStyle; + // Mouse out on previous hovered element + if (lastHovered && hovered !== lastHovered && lastHovered.__zr) { + this._dispatchProxy(lastHovered, 'mouseout', event); + } + + // Mouse moving on one element + this._dispatchProxy(hovered, 'mousemove', event); + + // Mouse over on a new element + if (hovered && hovered !== lastHovered) { + this._dispatchProxy(hovered, 'mouseover', event); + } + }, + + /** + * Mouse out handler + * @inner + * @param {Event} event + */ + mouseout: function (event) { + event = normalizeEvent(this.root, event); + + var element = event.toElement || event.relatedTarget; + if (element != this.root) { + while (element && element.nodeType != 9) { + // 忽略包含在root中的dom引起的mouseOut + if (element === this.root) { + return; + } + + element = element.parentNode; + } + } + + this._dispatchProxy(this._hovered, 'mouseout', event); + + this.trigger('globalout', { + event: event + }); + }, + + /** + * Touch开始响应函数 + * @inner + * @param {Event} event + */ + touchstart: function (event) { + // FIXME + // 移动端可能需要default行为,例如静态图表时。 + // eventTool.stop(event);// 阻止浏览器默认事件,重要 + event = normalizeEvent(this.root, event); + + this._lastTouchMoment = new Date(); + + processGesture(this, event, 'start'); + + // 平板补充一次findHover + // this._mobileFindFixed(event); + // Trigger mousemove and mousedown + domHandlers.mousemove.call(this, event); + + domHandlers.mousedown.call(this, event); + + setTouchTimer(this); + }, + + /** + * Touch移动响应函数 + * @inner + * @param {Event} event + */ + touchmove: function (event) { + // eventTool.stop(event);// 阻止浏览器默认事件,重要 + event = normalizeEvent(this.root, event); + + processGesture(this, event, 'change'); + + // Mouse move should always be triggered no matter whether + // there is gestrue event, because mouse move and pinch may + // be used at the same time. + domHandlers.mousemove.call(this, event); + + setTouchTimer(this); + }, + + /** + * Touch结束响应函数 + * @inner + * @param {Event} event + */ + touchend: function (event) { + // eventTool.stop(event);// 阻止浏览器默认事件,重要 + event = normalizeEvent(this.root, event); + + processGesture(this, event, 'end'); + + domHandlers.mouseup.call(this, event); + + // click event should always be triggered no matter whether + // there is gestrue event. System click can not be prevented. + if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) { + // this._mobileFindFixed(event); + domHandlers.click.call(this, event); + } + + setTouchTimer(this); + } + }; + + // Common handlers + util.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick'], function (name) { + domHandlers[name] = function (event) { + event = normalizeEvent(this.root, event); + // Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover + var hovered = this.findHover(event.zrX, event.zrY, null); + this._dispatchProxy(hovered, name, event); + }; + }); + + // Pointer event handlers + // util.each(['pointerdown', 'pointermove', 'pointerup'], function (name) { + // domHandlers[name] = function (event) { + // var mouseName = name.replace('pointer', 'mouse'); + // domHandlers[mouseName].call(this, event); + // }; + // }); + + function processGesture(zrHandler, event, stage) { + var gestureMgr = zrHandler._gestureMgr; + + stage === 'start' && gestureMgr.clear(); + + var gestureInfo = gestureMgr.recognize( + event, + zrHandler.findHover(event.zrX, event.zrY, null) + ); + + stage === 'end' && gestureMgr.clear(); + + if (gestureInfo) { + // eventTool.stop(event); + var type = gestureInfo.type; + event.gestureEvent = type; + + zrHandler._dispatchProxy(gestureInfo.target, type, gestureInfo.event); + } + } + + /** + * 为控制类实例初始化dom 事件处理函数 + * + * @inner + * @param {module:zrender/Handler} instance 控制类实例 + */ + function initDomHandler(instance) { + var handlerNames = touchHandlerNames.concat(pointerHandlerNames); + for (var i = 0; i < handlerNames.length; i++) { + var name = handlerNames[i]; + instance._handlers[name] = util.bind(domHandlers[name], instance); + } + + for (var i = 0; i < mouseHandlerNames.length; i++) { + var name = mouseHandlerNames[i]; + instance._handlers[name] = makeMouseHandler(domHandlers[name], instance); + } + + function makeMouseHandler(fn, instance) { + return function () { + if (instance._touching) { + return; + } + return fn.apply(instance, arguments); + }; + } + } + + /** + * @alias module:zrender/Handler + * @constructor + * @extends module:zrender/mixin/Eventful + * @param {HTMLElement} root Main HTML element for painting. + * @param {module:zrender/Storage} storage Storage instance. + * @param {module:zrender/Painter} painter Painter instance. + */ + var Handler = function(root, storage, painter) { + Eventful.call(this); + + this.root = root; + this.storage = storage; + this.painter = painter; + + /** + * @private + * @type {boolean} + */ + this._hovered; + + /** + * @private + * @type {Date} + */ + this._lastTouchMoment; + + /** + * @private + * @type {number} + */ + this._lastX; + + /** + * @private + * @type {number} + */ + this._lastY; + + /** + * @private + * @type {string} + */ + this._defaultCursorStyle = 'default'; + + /** + * @private + * @type {module:zrender/core/GestureMgr} + */ + this._gestureMgr = new GestureMgr(); + + /** + * @private + * @type {Array.} + */ + this._handlers = []; + + /** + * @private + * @type {boolean} + */ + this._touching = false; + + /** + * @private + * @type {number} + */ + this._touchTimer; + + initDomHandler(this); + + if (usePointerEvent()) { + mountHandlers(pointerHandlerNames, this); + } + else if (useTouchEvent()) { + mountHandlers(touchHandlerNames, this); + + // Handler of 'mouseout' event is needed in touch mode, which will be mounted below. + // addEventListener(root, 'mouseout', this._mouseoutHandler); + } + + // Considering some devices that both enable touch and mouse event (like MS Surface + // and lenovo X240, @see #2350), we make mouse event be always listened, otherwise + // mouse event can not be handle in those devices. + mountHandlers(mouseHandlerNames, this); + + Draggable.call(this); + + function mountHandlers(handlerNames, instance) { + util.each(handlerNames, function (name) { + addEventListener(root, eventNameFix(name), instance._handlers[name]); + }, instance); + } + }; + + Handler.prototype = { + + constructor: Handler, + + /** + * Resize + */ + resize: function (event) { + this._hovered = null; + }, + + /** + * Dispatch event + * @param {string} eventName + * @param {event=} eventArgs + */ + dispatch: function (eventName, eventArgs) { + var handler = this._handlers[eventName]; + handler && handler.call(this, eventArgs); + }, + + /** + * Dispose + */ + dispose: function () { + var root = this.root; + + var handlerNames = mouseHandlerNames.concat(touchHandlerNames); + + for (var i = 0; i < handlerNames.length; i++) { + var name = handlerNames[i]; + removeEventListener(root, eventNameFix(name), this._handlers[name]); + } + + this.root = + this.storage = + this.painter = null; + }, + + /** + * 设置默认的cursor style + * @param {string} cursorStyle 例如 crosshair + */ + setDefaultCursorStyle: function (cursorStyle) { + this._defaultCursorStyle = cursorStyle; + }, + + /** + * 事件分发代理 + * + * @private + * @param {Object} targetEl 目标图形元素 + * @param {string} eventName 事件名称 + * @param {Object} event 事件对象 + */ + _dispatchProxy: function (targetEl, eventName, event) { + var eventHandler = 'on' + eventName; + var eventPacket = makeEventPacket(eventName, targetEl, event); + + var el = targetEl; + + while (el) { + el[eventHandler] + && (eventPacket.cancelBubble = el[eventHandler].call(el, eventPacket)); + + el.trigger(eventName, eventPacket); + + el = el.parent; + + if (eventPacket.cancelBubble) { + break; + } + } + + if (!eventPacket.cancelBubble) { + // 冒泡到顶级 zrender 对象 + this.trigger(eventName, eventPacket); + // 分发事件到用户自定义层 + // 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在 + this.painter && this.painter.eachOtherLayer(function (layer) { + if (typeof(layer[eventHandler]) == 'function') { + layer[eventHandler].call(layer, eventPacket); + } + if (layer.trigger) { + layer.trigger(eventName, eventPacket); + } + }); + } + }, + + /** + * @private + * @param {number} x + * @param {number} y + * @param {module:zrender/graphic/Displayable} exclude + * @method + */ + findHover: function(x, y, exclude) { + var list = this.storage.getDisplayList(); + for (var i = list.length - 1; i >= 0 ; i--) { + if (!list[i].silent + && list[i] !== exclude + // getDisplayList may include ignored item in VML mode + && !list[i].ignore + && isHover(list[i], x, y)) { + return list[i]; + } + } + } + }; + + function isHover(displayable, x, y) { + if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) { + var p = displayable.parent; + while (p) { + if (p.clipPath && !p.clipPath.contain(x, y)) { + // Clipped by parents + return false; + } + p = p.parent; + } + return true; + } + + return false; + } + + /** + * Prevent mouse event from being dispatched after Touch Events action + * @see + * 1. Mobile browsers dispatch mouse events 300ms after touchend. + * 2. Chrome for Android dispatch mousedown for long-touch about 650ms + * Result: Blocking Mouse Events for 700ms. + */ + function setTouchTimer(instance) { + instance._touching = true; + clearTimeout(instance._touchTimer); + instance._touchTimer = setTimeout(function () { + instance._touching = false; + }, 700); + } + + /** + * Althought MS Surface support screen touch, IE10/11 do not support + * touch event and MS Edge supported them but not by default (but chrome + * and firefox do). Thus we use Pointer event on MS browsers to handle touch. + */ + function usePointerEvent() { + // TODO + // pointermove event dont trigger when using finger. + // We may figger it out latter. + return false; + // return env.pointerEventsSupported + // In no-touch device we dont use pointer evnets but just + // use mouse event for avoiding problems. + // && window.navigator.maxTouchPoints; + } + + function useTouchEvent() { + return env.touchEventsSupported; + } + + function eventNameFix(name) { + return (name === 'mousewheel' && env.browser.firefox) ? 'DOMMouseScroll' : name; + } + + util.mixin(Handler, Eventful); + util.mixin(Handler, Draggable); + + module.exports = Handler; + + +/***/ }, +/* 80 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 事件辅助类 + * @module zrender/core/event + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + */ + + + var Eventful = __webpack_require__(32); + + var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener; + + function getBoundingClientRect(el) { + // BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect + return el.getBoundingClientRect ? el.getBoundingClientRect() : { left: 0, top: 0}; + } + /** + * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标 + */ + function normalizeEvent(el, e) { + + e = e || window.event; + + if (e.zrX != null) { + return e; + } + + var eventType = e.type; + var isTouch = eventType && eventType.indexOf('touch') >= 0; + + if (!isTouch) { + var box = getBoundingClientRect(el); + e.zrX = e.clientX - box.left; + e.zrY = e.clientY - box.top; + e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3; + } + else { + var touch = eventType != 'touchend' + ? e.targetTouches[0] + : e.changedTouches[0]; + if (touch) { + var rBounding = getBoundingClientRect(el); + // touch事件坐标是全屏的~ + e.zrX = touch.clientX - rBounding.left; + e.zrY = touch.clientY - rBounding.top; + } + } + + return e; + } + + function addEventListener(el, name, handler) { + if (isDomLevel2) { + el.addEventListener(name, handler); + } + else { + el.attachEvent('on' + name, handler); + } + } + + function removeEventListener(el, name, handler) { + if (isDomLevel2) { + el.removeEventListener(name, handler); + } + else { + el.detachEvent('on' + name, handler); + } + } + + /** + * 停止冒泡和阻止默认行为 + * @memberOf module:zrender/core/event + * @method + * @param {Event} e : event对象 + */ + var stop = isDomLevel2 + ? function (e) { + e.preventDefault(); + e.stopPropagation(); + e.cancelBubble = true; + } + : function (e) { + e.returnValue = false; + e.cancelBubble = true; + }; + + module.exports = { + normalizeEvent: normalizeEvent, + addEventListener: addEventListener, + removeEventListener: removeEventListener, + + stop: stop, + // 做向上兼容 + Dispatcher: Eventful + }; + + + +/***/ }, +/* 81 */ +/***/ function(module, exports) { + + // TODO Draggable for group + // FIXME Draggable on element which has parent rotation or scale + + function Draggable() { + + this.on('mousedown', this._dragStart, this); + this.on('mousemove', this._drag, this); + this.on('mouseup', this._dragEnd, this); + this.on('globalout', this._dragEnd, this); + // this._dropTarget = null; + // this._draggingTarget = null; + + // this._x = 0; + // this._y = 0; + } + + Draggable.prototype = { + + constructor: Draggable, + + _dragStart: function (e) { + var draggingTarget = e.target; + if (draggingTarget && draggingTarget.draggable) { + this._draggingTarget = draggingTarget; + draggingTarget.dragging = true; + this._x = e.offsetX; + this._y = e.offsetY; + + this._dispatchProxy(draggingTarget, 'dragstart', e.event); + } + }, + + _drag: function (e) { + var draggingTarget = this._draggingTarget; + if (draggingTarget) { + + var x = e.offsetX; + var y = e.offsetY; + + var dx = x - this._x; + var dy = y - this._y; + this._x = x; + this._y = y; + + draggingTarget.drift(dx, dy, e); + this._dispatchProxy(draggingTarget, 'drag', e.event); + + var dropTarget = this.findHover(x, y, draggingTarget); + var lastDropTarget = this._dropTarget; + this._dropTarget = dropTarget; + + if (draggingTarget !== dropTarget) { + if (lastDropTarget && dropTarget !== lastDropTarget) { + this._dispatchProxy(lastDropTarget, 'dragleave', e.event); + } + if (dropTarget && dropTarget !== lastDropTarget) { + this._dispatchProxy(dropTarget, 'dragenter', e.event); + } + } + } + }, + + _dragEnd: function (e) { + var draggingTarget = this._draggingTarget; + + if (draggingTarget) { + draggingTarget.dragging = false; + } + + this._dispatchProxy(draggingTarget, 'dragend', e.event); + + if (this._dropTarget) { + this._dispatchProxy(this._dropTarget, 'drop', e.event); + } + + this._draggingTarget = null; + this._dropTarget = null; + } - var colorStops = this.colorStops; - for (var i = 0; i < colorStops.length; i++) { - canvasGradient.addColorStop( - colorStops[i].offset, colorStops[i].color - ); - } + }; - this.canvasGradient = canvasGradient; - } - }; + module.exports = Draggable; - zrUtil.inherits(RadialGradient, Gradient); - return RadialGradient; -}); -define('echarts/util/graphic',['require','zrender/core/util','zrender/tool/path','zrender/graphic/Path','zrender/tool/color','zrender/core/matrix','zrender/core/vector','zrender/graphic/Gradient','zrender/container/Group','zrender/graphic/Image','zrender/graphic/Text','zrender/graphic/shape/Circle','zrender/graphic/shape/Sector','zrender/graphic/shape/Polygon','zrender/graphic/shape/Polyline','zrender/graphic/shape/Rect','zrender/graphic/shape/Line','zrender/graphic/shape/BezierCurve','zrender/graphic/shape/Arc','zrender/graphic/LinearGradient','zrender/graphic/RadialGradient','zrender/core/BoundingRect'],function(require) { +/***/ }, +/* 82 */ +/***/ function(module, exports) { - + 'use strict'; + /** + * Only implements needed gestures for mobile. + */ - var zrUtil = require('zrender/core/util'); - var pathTool = require('zrender/tool/path'); - var round = Math.round; - var Path = require('zrender/graphic/Path'); - var colorTool = require('zrender/tool/color'); - var matrix = require('zrender/core/matrix'); - var vector = require('zrender/core/vector'); - var Gradient = require('zrender/graphic/Gradient'); + var GestureMgr = function () { + + /** + * @private + * @type {Array.} + */ + this._track = []; + }; + + GestureMgr.prototype = { + + constructor: GestureMgr, - var graphic = {}; + recognize: function (event, target) { + this._doTrack(event, target); + return this._recognize(event); + }, - graphic.Group = require('zrender/container/Group'); + clear: function () { + this._track.length = 0; + return this; + }, + + _doTrack: function (event, target) { + var touches = event.touches; + + if (!touches) { + return; + } - graphic.Image = require('zrender/graphic/Image'); + var trackItem = { + points: [], + touches: [], + target: target, + event: event + }; - graphic.Text = require('zrender/graphic/Text'); + for (var i = 0, len = touches.length; i < len; i++) { + var touch = touches[i]; + trackItem.points.push([touch.clientX, touch.clientY]); + trackItem.touches.push(touch); + } + + this._track.push(trackItem); + }, + + _recognize: function (event) { + for (var eventName in recognizers) { + if (recognizers.hasOwnProperty(eventName)) { + var gestureInfo = recognizers[eventName](this._track, event); + if (gestureInfo) { + return gestureInfo; + } + } + } + } + }; + + function dist(pointPair) { + var dx = pointPair[1][0] - pointPair[0][0]; + var dy = pointPair[1][1] - pointPair[0][1]; + + return Math.sqrt(dx * dx + dy * dy); + } - graphic.Circle = require('zrender/graphic/shape/Circle'); - - graphic.Sector = require('zrender/graphic/shape/Sector'); - - graphic.Polygon = require('zrender/graphic/shape/Polygon'); - - graphic.Polyline = require('zrender/graphic/shape/Polyline'); - - graphic.Rect = require('zrender/graphic/shape/Rect'); - - graphic.Line = require('zrender/graphic/shape/Line'); - - graphic.BezierCurve = require('zrender/graphic/shape/BezierCurve'); - - graphic.Arc = require('zrender/graphic/shape/Arc'); - - graphic.LinearGradient = require('zrender/graphic/LinearGradient'); - - graphic.RadialGradient = require('zrender/graphic/RadialGradient'); - - graphic.BoundingRect = require('zrender/core/BoundingRect'); - - /** - * Extend shape with parameters - */ - graphic.extendShape = function (opts) { - return Path.extend(opts); - }; - - /** - * Extend path - */ - graphic.extendPath = function (pathData, opts) { - return pathTool.extendFromString(pathData, opts); - }; - - /** - * Create a path element from path data string - * @param {string} pathData - * @param {Object} opts - * @param {module:zrender/core/BoundingRect} rect - * @param {string} [layout=cover] 'center' or 'cover' - */ - graphic.makePath = function (pathData, opts, rect, layout) { - var path = pathTool.createFromString(pathData, opts); - var boundingRect = path.getBoundingRect(); - if (rect) { - var aspect = boundingRect.width / boundingRect.height; - - if (layout === 'center') { - // Set rect to center, keep width / height ratio. - var width = rect.height * aspect; - var height; - if (width <= rect.width) { - height = rect.height; - } - else { - width = rect.width; - height = width / aspect; - } - var cx = rect.x + rect.width / 2; - var cy = rect.y + rect.height / 2; - - rect.x = cx - width / 2; - rect.y = cy - height / 2; - rect.width = width; - rect.height = height; - } - - this.resizePath(path, rect); - } - return path; - }; - - graphic.mergePath = pathTool.mergePath, - - /** - * Resize a path to fit the rect - * @param {module:zrender/graphic/Path} path - * @param {Object} rect - */ - graphic.resizePath = function (path, rect) { - if (!path.applyTransform) { - return; - } - - var pathRect = path.getBoundingRect(); - - var m = pathRect.calculateTransform(rect); - - path.applyTransform(m); - }; - - /** - * Sub pixel optimize line for canvas - * - * @param {Object} param - * @param {Object} [param.shape] - * @param {number} [param.shape.x1] - * @param {number} [param.shape.y1] - * @param {number} [param.shape.x2] - * @param {number} [param.shape.y2] - * @param {Object} [param.style] - * @param {number} [param.style.lineWidth] - * @return {Object} Modified param - */ - graphic.subPixelOptimizeLine = function (param) { - var subPixelOptimize = graphic.subPixelOptimize; - var shape = param.shape; - var lineWidth = param.style.lineWidth; - - if (round(shape.x1 * 2) === round(shape.x2 * 2)) { - shape.x1 = shape.x2 = subPixelOptimize(shape.x1, lineWidth, true); - } - if (round(shape.y1 * 2) === round(shape.y2 * 2)) { - shape.y1 = shape.y2 = subPixelOptimize(shape.y1, lineWidth, true); - } - return param; - }; - - /** - * Sub pixel optimize rect for canvas - * - * @param {Object} param - * @param {Object} [param.shape] - * @param {number} [param.shape.x] - * @param {number} [param.shape.y] - * @param {number} [param.shape.width] - * @param {number} [param.shape.height] - * @param {Object} [param.style] - * @param {number} [param.style.lineWidth] - * @return {Object} Modified param - */ - graphic.subPixelOptimizeRect = function (param) { - var subPixelOptimize = graphic.subPixelOptimize; - var shape = param.shape; - var lineWidth = param.style.lineWidth; - var originX = shape.x; - var originY = shape.y; - var originWidth = shape.width; - var originHeight = shape.height; - shape.x = subPixelOptimize(shape.x, lineWidth, true); - shape.y = subPixelOptimize(shape.y, lineWidth, true); - shape.width = Math.max( - subPixelOptimize(originX + originWidth, lineWidth, false) - shape.x, - originWidth === 0 ? 0 : 1 - ); - shape.height = Math.max( - subPixelOptimize(originY + originHeight, lineWidth, false) - shape.y, - originHeight === 0 ? 0 : 1 - ); - return param; - }; - - /** - * Sub pixel optimize for canvas - * - * @param {number} position Coordinate, such as x, y - * @param {number} lineWidth Should be nonnegative integer. - * @param {boolean=} positiveOrNegative Default false (negative). - * @return {number} Optimized position. - */ - graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) { - // Assure that (position + lineWidth / 2) is near integer edge, - // otherwise line will be fuzzy in canvas. - var doubledPosition = round(position * 2); - return (doubledPosition + round(lineWidth)) % 2 === 0 - ? doubledPosition / 2 - : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2; - }; - - /** - * @private - */ - function doSingleEnterHover(el) { - if (el.__isHover) { - return; - } - if (el.__hoverStlDirty) { - var stroke = el.style.stroke; - var fill = el.style.fill; - - // Create hoverStyle on mouseover - var hoverStyle = el.__hoverStl; - hoverStyle.fill = hoverStyle.fill - || (fill instanceof Gradient ? fill : colorTool.lift(fill, -0.1)); - hoverStyle.stroke = hoverStyle.stroke - || (stroke instanceof Gradient ? stroke : colorTool.lift(stroke, -0.1)); - - var normalStyle = {}; - for (var name in hoverStyle) { - if (hoverStyle.hasOwnProperty(name)) { - normalStyle[name] = el.style[name]; - } - } - - el.__normalStl = normalStyle; - - el.__hoverStlDirty = false; - } - el.setStyle(el.__hoverStl); - el.z2 += 1; - - el.__isHover = true; - } - - /** - * @inner - */ - function doSingleLeaveHover(el) { - if (!el.__isHover) { - return; - } - - var normalStl = el.__normalStl; - normalStl && el.setStyle(normalStl); - el.z2 -= 1; - - el.__isHover = false; - } - - /** - * @inner - */ - function doEnterHover(el) { - el.type === 'group' - ? el.traverse(function (child) { - if (child.type !== 'group') { - doSingleEnterHover(child); - } - }) - : doSingleEnterHover(el); - } - - function doLeaveHover(el) { - el.type === 'group' - ? el.traverse(function (child) { - if (child.type !== 'group') { - doSingleLeaveHover(child); - } - }) - : doSingleLeaveHover(el); - } - - /** - * @inner - */ - function setElementHoverStl(el, hoverStl) { - // If element has sepcified hoverStyle, then use it instead of given hoverStyle - // Often used when item group has a label element and it's hoverStyle is different - el.__hoverStl = el.hoverStyle || hoverStl; - el.__hoverStlDirty = true; - } - - /** - * @inner - */ - function onElementMouseOver() { - // Only if element is not in emphasis status - !this.__isEmphasis && doEnterHover(this); - } - - /** - * @inner - */ - function onElementMouseOut() { - // Only if element is not in emphasis status - !this.__isEmphasis && doLeaveHover(this); - } - - /** - * @inner - */ - function enterEmphasis() { - this.__isEmphasis = true; - doEnterHover(this); - } - - /** - * @inner - */ - function leaveEmphasis() { - this.__isEmphasis = false; - doLeaveHover(this); - } - - /** - * Set hover style of element - * @param {module:zrender/Element} el - * @param {Object} [hoverStyle] - */ - graphic.setHoverStyle = function (el, hoverStyle) { - hoverStyle = hoverStyle || {}; - el.type === 'group' - ? el.traverse(function (child) { - if (child.type !== 'group') { - setElementHoverStl(child, hoverStyle); - } - }) - : setElementHoverStl(el, hoverStyle); - // Remove previous bound handlers - el.on('mouseover', onElementMouseOver) - .on('mouseout', onElementMouseOut); - - // Emphasis, normal can be triggered manually - el.on('emphasis', enterEmphasis) - .on('normal', leaveEmphasis); - }; - - /** - * Set text option in the style - * @param {Object} textStyle - * @param {module:echarts/model/Model} labelModel - * @param {string} color - */ - graphic.setText = function (textStyle, labelModel, color) { - var labelPosition = labelModel.getShallow('position') || 'inside'; - var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color; - var textStyleModel = labelModel.getModel('textStyle'); - zrUtil.extend(textStyle, { - textDistance: labelModel.getShallow('distance') || 5, - textFont: textStyleModel.getFont(), - textPosition: labelPosition, - textFill: textStyleModel.getTextColor() || labelColor - }); - }; - - function animateOrSetProps(isUpdate, el, props, animatableModel, cb) { - var postfix = isUpdate ? 'Update' : ''; - var duration = animatableModel - && animatableModel.getShallow('animationDuration' + postfix); - var animationEasing = animatableModel - && animatableModel.getShallow('animationEasing' + postfix); - - animatableModel && animatableModel.getShallow('animation') - ? el.animateTo(props, duration, animationEasing, cb) - : (el.attr(props), cb && cb()); - } - /** - * Update graphic element properties with or without animation according to the configuration in series - * @param {module:zrender/Element} el - * @param {Object} props - * @param {module:echarts/model/Model} [animatableModel] - * @param {Function} cb - */ - graphic.updateProps = zrUtil.curry(animateOrSetProps, true); - - /** - * Init graphic element properties with or without animation according to the configuration in series - * @param {module:zrender/Element} el - * @param {Object} props - * @param {module:echarts/model/Model} [animatableModel] - * @param {Function} cb - */ - graphic.initProps = zrUtil.curry(animateOrSetProps, false); - - /** - * Get transform matrix of target (param target), - * in coordinate of its ancestor (param ancestor) - * - * @param {module:zrender/mixin/Transformable} target - * @param {module:zrender/mixin/Transformable} ancestor - */ - graphic.getTransform = function (target, ancestor) { - var mat = matrix.identity([]); - - while (target && target !== ancestor) { - matrix.mul(mat, target.getLocalTransform(), mat); - target = target.parent; - } - - return mat; - }; - - /** - * Apply transform to an vertex. - * @param {Array.} vertex [x, y] - * @param {Array.} transform Transform matrix: like [1, 0, 0, 1, 0, 0] - * @param {boolean=} invert Whether use invert matrix. - * @return {Array.} [x, y] - */ - graphic.applyTransform = function (vertex, transform, invert) { - if (invert) { - transform = matrix.invert([], transform); - } - return vector.applyTransform([], vertex, transform); - }; - - /** - * @param {string} direction 'left' 'right' 'top' 'bottom' - * @param {Array.} transform Transform matrix: like [1, 0, 0, 1, 0, 0] - * @param {boolean=} invert Whether use invert matrix. - * @return {string} Transformed direction. 'left' 'right' 'top' 'bottom' - */ - graphic.transformDirection = function (direction, transform, invert) { - - // Pick a base, ensure that transform result will not be (0, 0). - var hBase = (transform[4] === 0 || transform[5] === 0 || transform[0] === 0) - ? 1 : Math.abs(2 * transform[4] / transform[0]); - var vBase = (transform[4] === 0 || transform[5] === 0 || transform[2] === 0) - ? 1 : Math.abs(2 * transform[4] / transform[2]); - - var vertex = [ - direction === 'left' ? -hBase : direction === 'right' ? hBase : 0, - direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0 - ]; - - vertex = graphic.applyTransform(vertex, transform, invert); - - return Math.abs(vertex[0]) > Math.abs(vertex[1]) - ? (vertex[0] > 0 ? 'right' : 'left') - : (vertex[1] > 0 ? 'bottom' : 'top'); - }; - - return graphic; + function center(pointPair) { + return [ + (pointPair[0][0] + pointPair[1][0]) / 2, + (pointPair[0][1] + pointPair[1][1]) / 2 + ]; + } + + var recognizers = { + + pinch: function (track, event) { + var trackLen = track.length; + + if (!trackLen) { + return; + } + + var pinchEnd = (track[trackLen - 1] || {}).points; + var pinchPre = (track[trackLen - 2] || {}).points || pinchEnd; + + if (pinchPre + && pinchPre.length > 1 + && pinchEnd + && pinchEnd.length > 1 + ) { + var pinchScale = dist(pinchEnd) / dist(pinchPre); + !isFinite(pinchScale) && (pinchScale = 1); + + event.pinchScale = pinchScale; + + var pinchCenter = center(pinchEnd); + event.pinchX = pinchCenter[0]; + event.pinchY = pinchCenter[1]; + + return { + type: 'pinch', + target: track[0].target, + event: event + }; + } + } + + // Only pinch currently. + }; + + module.exports = GestureMgr; + + + +/***/ }, +/* 83 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Storage内容仓库模块 + * @module zrender/Storage + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + * @author errorrik (errorrik@gmail.com) + * @author pissang (https://github.com/pissang/) + */ + + + var util = __webpack_require__(3); + + var Group = __webpack_require__(29); + + function shapeCompareFunc(a, b) { + if (a.zlevel === b.zlevel) { + if (a.z === b.z) { + if (a.z2 === b.z2) { + return a.__renderidx - b.__renderidx; + } + return a.z2 - b.z2; + } + return a.z - b.z; + } + return a.zlevel - b.zlevel; + } + /** + * 内容仓库 (M) + * @alias module:zrender/Storage + * @constructor + */ + var Storage = function () { + // 所有常规形状,id索引的map + this._elements = {}; + + this._roots = []; + + this._displayList = []; + + this._displayListLen = 0; + }; + + Storage.prototype = { + + constructor: Storage, + + /** + * 返回所有图形的绘制队列 + * @param {boolean} [update=false] 是否在返回前更新该数组 + * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组, 在 update 为 true 的时候有效 + * + * 详见{@link module:zrender/graphic/Displayable.prototype.updateDisplayList} + * @return {Array.} + */ + getDisplayList: function (update, includeIgnore) { + includeIgnore = includeIgnore || false; + if (update) { + this.updateDisplayList(includeIgnore); + } + return this._displayList; + }, + + /** + * 更新图形的绘制队列。 + * 每次绘制前都会调用,该方法会先深度优先遍历整个树,更新所有Group和Shape的变换并且把所有可见的Shape保存到数组中, + * 最后根据绘制的优先级(zlevel > z > 插入顺序)排序得到绘制队列 + * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组 + */ + updateDisplayList: function (includeIgnore) { + this._displayListLen = 0; + var roots = this._roots; + var displayList = this._displayList; + for (var i = 0, len = roots.length; i < len; i++) { + this._updateAndAddDisplayable(roots[i], null, includeIgnore); + } + displayList.length = this._displayListLen; + + for (var i = 0, len = displayList.length; i < len; i++) { + displayList[i].__renderidx = i; + } + + displayList.sort(shapeCompareFunc); + }, + + _updateAndAddDisplayable: function (el, clipPaths, includeIgnore) { + + if (el.ignore && !includeIgnore) { + return; + } + + el.beforeUpdate(); + + el.update(); + + el.afterUpdate(); + + var clipPath = el.clipPath; + if (clipPath) { + // clipPath 的变换是基于 group 的变换 + clipPath.parent = el; + clipPath.updateTransform(); + + // FIXME 效率影响 + if (clipPaths) { + clipPaths = clipPaths.slice(); + clipPaths.push(clipPath); + } + else { + clipPaths = [clipPath]; + } + } + + if (el.type == 'group') { + var children = el._children; + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + + // Force to mark as dirty if group is dirty + // FIXME __dirtyPath ? + child.__dirty = el.__dirty || child.__dirty; + + this._updateAndAddDisplayable(child, clipPaths, includeIgnore); + } + + // Mark group clean here + el.__dirty = false; + + } + else { + el.__clipPaths = clipPaths; + + this._displayList[this._displayListLen++] = el; + } + }, + + /** + * 添加图形(Shape)或者组(Group)到根节点 + * @param {module:zrender/Element} el + */ + addRoot: function (el) { + // Element has been added + if (this._elements[el.id]) { + return; + } + + if (el instanceof Group) { + el.addChildrenToStorage(this); + } + + this.addToMap(el); + this._roots.push(el); + }, + + /** + * 删除指定的图形(Shape)或者组(Group) + * @param {string|Array.} [elId] 如果为空清空整个Storage + */ + delRoot: function (elId) { + if (elId == null) { + // 不指定elId清空 + for (var i = 0; i < this._roots.length; i++) { + var root = this._roots[i]; + if (root instanceof Group) { + root.delChildrenFromStorage(this); + } + } + + this._elements = {}; + this._roots = []; + this._displayList = []; + this._displayListLen = 0; + + return; + } + + if (elId instanceof Array) { + for (var i = 0, l = elId.length; i < l; i++) { + this.delRoot(elId[i]); + } + return; + } + + var el; + if (typeof(elId) == 'string') { + el = this._elements[elId]; + } + else { + el = elId; + } + + var idx = util.indexOf(this._roots, el); + if (idx >= 0) { + this.delFromMap(el.id); + this._roots.splice(idx, 1); + if (el instanceof Group) { + el.delChildrenFromStorage(this); + } + } + }, + + addToMap: function (el) { + if (el instanceof Group) { + el.__storage = this; + } + el.dirty(); + + this._elements[el.id] = el; + + return this; + }, + + get: function (elId) { + return this._elements[elId]; + }, + + delFromMap: function (elId) { + var elements = this._elements; + var el = elements[elId]; + if (el) { + delete elements[elId]; + if (el instanceof Group) { + el.__storage = null; + } + } + + return this; + }, + + /** + * 清空并且释放Storage + */ + dispose: function () { + this._elements = + this._renderList = + this._roots = null; + } + }; + + module.exports = Storage; + + + +/***/ }, +/* 84 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * 动画主类, 调度和管理所有动画控制器 + * + * @module zrender/animation/Animation + * @author pissang(https://github.com/pissang) + */ + // TODO Additive animation + // http://iosoteric.com/additive-animations-animatewithduration-in-ios-8/ + // https://developer.apple.com/videos/wwdc2014/#236 + + + var util = __webpack_require__(3); + var Dispatcher = __webpack_require__(80).Dispatcher; + + var requestAnimationFrame = (typeof window !== 'undefined' && + (window.requestAnimationFrame + || window.msRequestAnimationFrame + || window.mozRequestAnimationFrame + || window.webkitRequestAnimationFrame)) + || function (func) { + setTimeout(func, 16); + }; + + var Animator = __webpack_require__(35); + /** + * @typedef {Object} IZRenderStage + * @property {Function} update + */ + + /** + * @alias module:zrender/animation/Animation + * @constructor + * @param {Object} [options] + * @param {Function} [options.onframe] + * @param {IZRenderStage} [options.stage] + * @example + * var animation = new Animation(); + * var obj = { + * x: 100, + * y: 100 + * }; + * animation.animate(node.position) + * .when(1000, { + * x: 500, + * y: 500 + * }) + * .when(2000, { + * x: 100, + * y: 100 + * }) + * .start('spline'); + */ + var Animation = function (options) { + + options = options || {}; + + this.stage = options.stage || {}; + + this.onframe = options.onframe || function() {}; + + // private properties + this._clips = []; + + this._running = false; + + this._time = 0; + + Dispatcher.call(this); + }; + + Animation.prototype = { + + constructor: Animation, + /** + * 添加 clip + * @param {module:zrender/animation/Clip} clip + */ + addClip: function (clip) { + this._clips.push(clip); + }, + /** + * 添加 animator + * @param {module:zrender/animation/Animator} animator + */ + addAnimator: function (animator) { + animator.animation = this; + var clips = animator.getClips(); + for (var i = 0; i < clips.length; i++) { + this.addClip(clips[i]); + } + }, + /** + * 删除动画片段 + * @param {module:zrender/animation/Clip} clip + */ + removeClip: function(clip) { + var idx = util.indexOf(this._clips, clip); + if (idx >= 0) { + this._clips.splice(idx, 1); + } + }, + + /** + * 删除动画片段 + * @param {module:zrender/animation/Animator} animator + */ + removeAnimator: function (animator) { + var clips = animator.getClips(); + for (var i = 0; i < clips.length; i++) { + this.removeClip(clips[i]); + } + animator.animation = null; + }, + + _update: function() { + + var time = new Date().getTime(); + var delta = time - this._time; + var clips = this._clips; + var len = clips.length; + + var deferredEvents = []; + var deferredClips = []; + for (var i = 0; i < len; i++) { + var clip = clips[i]; + var e = clip.step(time); + // Throw out the events need to be called after + // stage.update, like destroy + if (e) { + deferredEvents.push(e); + deferredClips.push(clip); + } + } + + // Remove the finished clip + for (var i = 0; i < len;) { + if (clips[i]._needsRemove) { + clips[i] = clips[len - 1]; + clips.pop(); + len--; + } + else { + i++; + } + } + + len = deferredEvents.length; + for (var i = 0; i < len; i++) { + deferredClips[i].fire(deferredEvents[i]); + } + + this._time = time; + + this.onframe(delta); + + this.trigger('frame', delta); + + if (this.stage.update) { + this.stage.update(); + } + }, + /** + * 开始运行动画 + */ + start: function () { + var self = this; + + this._running = true; + + function step() { + if (self._running) { + + requestAnimationFrame(step); + + self._update(); + } + } + + this._time = new Date().getTime(); + requestAnimationFrame(step); + }, + /** + * 停止运行动画 + */ + stop: function () { + this._running = false; + }, + /** + * 清除所有动画片段 + */ + clear: function () { + this._clips = []; + }, + /** + * 对一个目标创建一个animator对象,可以指定目标中的属性使用动画 + * @param {Object} target + * @param {Object} options + * @param {boolean} [options.loop=false] 是否循环播放动画 + * @param {Function} [options.getter=null] + * 如果指定getter函数,会通过getter函数取属性值 + * @param {Function} [options.setter=null] + * 如果指定setter函数,会通过setter函数设置属性值 + * @return {module:zrender/animation/Animation~Animator} + */ + animate: function (target, options) { + options = options || {}; + var animator = new Animator( + target, + options.loop, + options.getter, + options.setter + ); + + return animator; + } + }; + + util.mixin(Animation, Dispatcher); + + module.exports = Animation; + + + +/***/ }, +/* 85 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Default canvas painter + * @module zrender/Painter + * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) + * errorrik (errorrik@gmail.com) + * pissang (https://www.github.com/pissang) + */ + + + var config = __webpack_require__(40); + var util = __webpack_require__(3); + var log = __webpack_require__(39); + var BoundingRect = __webpack_require__(15); + + var Layer = __webpack_require__(86); + + function parseInt10(val) { + return parseInt(val, 10); + } + + function isLayerValid(layer) { + if (!layer) { + return false; + } + + if (layer.isBuildin) { + return true; + } + + if (typeof(layer.resize) !== 'function' + || typeof(layer.refresh) !== 'function' + ) { + return false; + } + + return true; + } + + function preProcessLayer(layer) { + layer.__unusedCount++; + } + + function postProcessLayer(layer) { + layer.__dirty = false; + if (layer.__unusedCount == 1) { + layer.clear(); + } + } + + var tmpRect = new BoundingRect(0, 0, 0, 0); + var viewRect = new BoundingRect(0, 0, 0, 0); + function isDisplayableCulled(el, width, height) { + tmpRect.copy(el.getBoundingRect()); + if (el.transform) { + tmpRect.applyTransform(el.transform); + } + viewRect.width = width; + viewRect.height = height; + return !tmpRect.intersect(viewRect); + } + + function isClipPathChanged(clipPaths, prevClipPaths) { + if (!clipPaths || !prevClipPaths || (clipPaths.length !== prevClipPaths.length)) { + return true; + } + for (var i = 0; i < clipPaths.length; i++) { + if (clipPaths[i] !== prevClipPaths[i]) { + return true; + } + } + } + + function doClip(clipPaths, ctx) { + for (var i = 0; i < clipPaths.length; i++) { + var clipPath = clipPaths[i]; + var m; + if (clipPath.transform) { + m = clipPath.transform; + ctx.transform( + m[0], m[1], + m[2], m[3], + m[4], m[5] + ); + } + var path = clipPath.path; + path.beginPath(ctx); + clipPath.buildPath(path, clipPath.shape); + ctx.clip(); + // Transform back + if (clipPath.transform) { + m = clipPath.invTransform; + ctx.transform( + m[0], m[1], + m[2], m[3], + m[4], m[5] + ); + } + } + } + + /** + * @alias module:zrender/Painter + * @constructor + * @param {HTMLElement} root 绘图容器 + * @param {module:zrender/Storage} storage + * @param {Ojbect} opts + */ + var Painter = function (root, storage, opts) { + var singleCanvas = !root.nodeName // In node ? + || root.nodeName.toUpperCase() === 'CANVAS'; + + opts = opts || {}; + + /** + * @type {number} + */ + this.dpr = opts.devicePixelRatio || config.devicePixelRatio; + /** + * @type {boolean} + * @private + */ + this._singleCanvas = singleCanvas; + /** + * 绘图容器 + * @type {HTMLElement} + */ + this.root = root; + + var rootStyle = root.style; + + // In node environment using node-canvas + if (rootStyle) { + rootStyle['-webkit-tap-highlight-color'] = 'transparent'; + rootStyle['-webkit-user-select'] = 'none'; + rootStyle['user-select'] = 'none'; + rootStyle['-webkit-touch-callout'] = 'none'; + + root.innerHTML = ''; + } + + /** + * @type {module:zrender/Storage} + */ + this.storage = storage; + + if (!singleCanvas) { + var width = this._getWidth(); + var height = this._getHeight(); + this._width = width; + this._height = height; + + var domRoot = document.createElement('div'); + this._domRoot = domRoot; + var domRootStyle = domRoot.style; + + // domRoot.onselectstart = returnFalse; // 避免页面选中的尴尬 + domRootStyle.position = 'relative'; + domRootStyle.overflow = 'hidden'; + domRootStyle.width = this._width + 'px'; + domRootStyle.height = this._height + 'px'; + root.appendChild(domRoot); + + /** + * @type {Object.} + * @private + */ + this._layers = {}; + /** + * @type {Array.} + * @private + */ + this._zlevelList = []; + } + else { + // Use canvas width and height directly + var width = root.width; + var height = root.height; + this._width = width; + this._height = height; + + // Create layer if only one given canvas + // Device pixel ratio is fixed to 1 because given canvas has its specified width and height + var mainLayer = new Layer(root, this, 1); + mainLayer.initContext(); + // FIXME Use canvas width and height + // mainLayer.resize(width, height); + this._layers = { + 0: mainLayer + }; + this._zlevelList = [0]; + } + + this._layerConfig = {}; + + this.pathToImage = this._createPathToImage(); + }; + + Painter.prototype = { + + constructor: Painter, + + /** + * If painter use a single canvas + * @return {boolean} + */ + isSingleCanvas: function () { + return this._singleCanvas; + }, + /** + * @return {HTMLDivElement} + */ + getViewportRoot: function () { + return this._singleCanvas ? this._layers[0].dom : this._domRoot; + }, + + /** + * 刷新 + * @param {boolean} [paintAll=false] 强制绘制所有displayable + */ + refresh: function (paintAll) { + var list = this.storage.getDisplayList(true); + var zlevelList = this._zlevelList; + + this._paintList(list, paintAll); + + // Paint custum layers + for (var i = 0; i < zlevelList.length; i++) { + var z = zlevelList[i]; + var layer = this._layers[z]; + if (!layer.isBuildin && layer.refresh) { + layer.refresh(); + } + } + + return this; + }, + + _paintList: function (list, paintAll) { + + if (paintAll == null) { + paintAll = false; + } + + this._updateLayerStatus(list); + + var currentLayer; + var currentZLevel; + var ctx; + + var viewWidth = this._width; + var viewHeight = this._height; + + this.eachBuildinLayer(preProcessLayer); + + // var invTransform = []; + var prevElClipPaths = null; + + for (var i = 0, l = list.length; i < l; i++) { + var el = list[i]; + var elZLevel = this._singleCanvas ? 0 : el.zlevel; + // Change draw layer + if (currentZLevel !== elZLevel) { + // Only 0 zlevel if only has one canvas + currentZLevel = elZLevel; + currentLayer = this.getLayer(currentZLevel); + + if (!currentLayer.isBuildin) { + log( + 'ZLevel ' + currentZLevel + + ' has been used by unkown layer ' + currentLayer.id + ); + } + + ctx = currentLayer.ctx; + + // Reset the count + currentLayer.__unusedCount = 0; + + if (currentLayer.__dirty || paintAll) { + currentLayer.clear(); + } + } + + if ( + (currentLayer.__dirty || paintAll) + // Ignore invisible element + && !el.invisible + // Ignore transparent element + && el.style.opacity !== 0 + // Ignore scale 0 element, in some environment like node-canvas + // Draw a scale 0 element can cause all following draw wrong + && el.scale[0] && el.scale[1] + // Ignore culled element + && !(el.culling && isDisplayableCulled(el, viewWidth, viewHeight)) + ) { + var clipPaths = el.__clipPaths; + + // Optimize when clipping on group with several elements + if (isClipPathChanged(clipPaths, prevElClipPaths)) { + // If has previous clipping state, restore from it + if (prevElClipPaths) { + ctx.restore(); + } + // New clipping state + if (clipPaths) { + ctx.save(); + doClip(clipPaths, ctx); + } + prevElClipPaths = clipPaths; + } + // TODO Use events ? + el.beforeBrush && el.beforeBrush(ctx); + el.brush(ctx, false); + el.afterBrush && el.afterBrush(ctx); + } + + el.__dirty = false; + } + + // If still has clipping state + if (prevElClipPaths) { + ctx.restore(); + } + + this.eachBuildinLayer(postProcessLayer); + }, + + /** + * 获取 zlevel 所在层,如果不存在则会创建一个新的层 + * @param {number} zlevel + * @return {module:zrender/Layer} + */ + getLayer: function (zlevel) { + if (this._singleCanvas) { + return this._layers[0]; + } + + var layer = this._layers[zlevel]; + if (!layer) { + // Create a new layer + layer = new Layer('zr_' + zlevel, this, this.dpr); + layer.isBuildin = true; + + if (this._layerConfig[zlevel]) { + util.merge(layer, this._layerConfig[zlevel], true); + } + + this.insertLayer(zlevel, layer); + + // Context is created after dom inserted to document + // Or excanvas will get 0px clientWidth and clientHeight + layer.initContext(); + } + + return layer; + }, + + insertLayer: function (zlevel, layer) { + + var layersMap = this._layers; + var zlevelList = this._zlevelList; + var len = zlevelList.length; + var prevLayer = null; + var i = -1; + var domRoot = this._domRoot; + + if (layersMap[zlevel]) { + log('ZLevel ' + zlevel + ' has been used already'); + return; + } + // Check if is a valid layer + if (!isLayerValid(layer)) { + log('Layer of zlevel ' + zlevel + ' is not valid'); + return; + } + + if (len > 0 && zlevel > zlevelList[0]) { + for (i = 0; i < len - 1; i++) { + if ( + zlevelList[i] < zlevel + && zlevelList[i + 1] > zlevel + ) { + break; + } + } + prevLayer = layersMap[zlevelList[i]]; + } + zlevelList.splice(i + 1, 0, zlevel); + + if (prevLayer) { + var prevDom = prevLayer.dom; + if (prevDom.nextSibling) { + domRoot.insertBefore( + layer.dom, + prevDom.nextSibling + ); + } + else { + domRoot.appendChild(layer.dom); + } + } + else { + if (domRoot.firstChild) { + domRoot.insertBefore(layer.dom, domRoot.firstChild); + } + else { + domRoot.appendChild(layer.dom); + } + } + + layersMap[zlevel] = layer; + }, + + // Iterate each layer + eachLayer: function (cb, context) { + var zlevelList = this._zlevelList; + var z; + var i; + for (i = 0; i < zlevelList.length; i++) { + z = zlevelList[i]; + cb.call(context, this._layers[z], z); + } + }, + + // Iterate each buildin layer + eachBuildinLayer: function (cb, context) { + var zlevelList = this._zlevelList; + var layer; + var z; + var i; + for (i = 0; i < zlevelList.length; i++) { + z = zlevelList[i]; + layer = this._layers[z]; + if (layer.isBuildin) { + cb.call(context, layer, z); + } + } + }, + + // Iterate each other layer except buildin layer + eachOtherLayer: function (cb, context) { + var zlevelList = this._zlevelList; + var layer; + var z; + var i; + for (i = 0; i < zlevelList.length; i++) { + z = zlevelList[i]; + layer = this._layers[z]; + if (! layer.isBuildin) { + cb.call(context, layer, z); + } + } + }, + + /** + * 获取所有已创建的层 + * @param {Array.} [prevLayer] + */ + getLayers: function () { + return this._layers; + }, + + _updateLayerStatus: function (list) { + + var layers = this._layers; + + var elCounts = {}; + + this.eachBuildinLayer(function (layer, z) { + elCounts[z] = layer.elCount; + layer.elCount = 0; + }); + + for (var i = 0, l = list.length; i < l; i++) { + var el = list[i]; + var zlevel = this._singleCanvas ? 0 : el.zlevel; + var layer = layers[zlevel]; + if (layer) { + layer.elCount++; + // 已经被标记为需要刷新 + if (layer.__dirty) { + continue; + } + layer.__dirty = el.__dirty; + } + } + + // 层中的元素数量有发生变化 + this.eachBuildinLayer(function (layer, z) { + if (elCounts[z] !== layer.elCount) { + layer.__dirty = true; + } + }); + }, + + /** + * 清除hover层外所有内容 + */ + clear: function () { + this.eachBuildinLayer(this._clearLayer); + return this; + }, + + _clearLayer: function (layer) { + layer.clear(); + }, + + /** + * 修改指定zlevel的绘制参数 + * + * @param {string} zlevel + * @param {Object} config 配置对象 + * @param {string} [config.clearColor=0] 每次清空画布的颜色 + * @param {string} [config.motionBlur=false] 是否开启动态模糊 + * @param {number} [config.lastFrameAlpha=0.7] + * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 + */ + configLayer: function (zlevel, config) { + if (config) { + var layerConfig = this._layerConfig; + if (!layerConfig[zlevel]) { + layerConfig[zlevel] = config; + } + else { + util.merge(layerConfig[zlevel], config, true); + } + + var layer = this._layers[zlevel]; + + if (layer) { + util.merge(layer, layerConfig[zlevel], true); + } + } + }, + + /** + * 删除指定层 + * @param {number} zlevel 层所在的zlevel + */ + delLayer: function (zlevel) { + var layers = this._layers; + var zlevelList = this._zlevelList; + var layer = layers[zlevel]; + if (!layer) { + return; + } + layer.dom.parentNode.removeChild(layer.dom); + delete layers[zlevel]; + + zlevelList.splice(util.indexOf(zlevelList, zlevel), 1); + }, + + /** + * 区域大小变化后重绘 + */ + resize: function (width, height) { + var domRoot = this._domRoot; + // FIXME Why ? + domRoot.style.display = 'none'; + + width = width || this._getWidth(); + height = height || this._getHeight(); + + domRoot.style.display = ''; + + // 优化没有实际改变的resize + if (this._width != width || height != this._height) { + domRoot.style.width = width + 'px'; + domRoot.style.height = height + 'px'; + + for (var id in this._layers) { + this._layers[id].resize(width, height); + } + + this.refresh(true); + } + + this._width = width; + this._height = height; + + return this; + }, + + /** + * 清除单独的一个层 + * @param {number} zlevel + */ + clearLayer: function (zlevel) { + var layer = this._layers[zlevel]; + if (layer) { + layer.clear(); + } + }, + + /** + * 释放 + */ + dispose: function () { + this.root.innerHTML = ''; + + this.root = + this.storage = + + this._domRoot = + this._layers = null; + }, + + /** + * Get canvas which has all thing rendered + * @param {Object} opts + * @param {string} [opts.backgroundColor] + */ + getRenderedCanvas: function (opts) { + opts = opts || {}; + if (this._singleCanvas) { + return this._layers[0].dom; + } + + var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr); + imageLayer.initContext(); + + var ctx = imageLayer.ctx; + imageLayer.clearColor = opts.backgroundColor; + imageLayer.clear(); + + var displayList = this.storage.getDisplayList(true); + + for (var i = 0; i < displayList.length; i++) { + var el = displayList[i]; + if (!el.invisible) { + el.beforeBrush && el.beforeBrush(ctx); + // TODO Check image cross origin + el.brush(ctx, false); + el.afterBrush && el.afterBrush(ctx); + } + } + + return imageLayer.dom; + }, + /** + * 获取绘图区域宽度 + */ + getWidth: function () { + return this._width; + }, + + /** + * 获取绘图区域高度 + */ + getHeight: function () { + return this._height; + }, + + _getWidth: function () { + var root = this.root; + var stl = document.defaultView.getComputedStyle(root); + + // FIXME Better way to get the width and height when element has not been append to the document + return ((root.clientWidth || parseInt10(stl.width) || parseInt10(root.style.width)) + - (parseInt10(stl.paddingLeft) || 0) + - (parseInt10(stl.paddingRight) || 0)) | 0; + }, + + _getHeight: function () { + var root = this.root; + var stl = document.defaultView.getComputedStyle(root); + + return ((root.clientHeight || parseInt10(stl.height) || parseInt10(root.style.height)) + - (parseInt10(stl.paddingTop) || 0) + - (parseInt10(stl.paddingBottom) || 0)) | 0; + }, + + _pathToImage: function (id, path, width, height, dpr) { + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + + canvas.width = width * dpr; + canvas.height = height * dpr; + + ctx.clearRect(0, 0, width * dpr, height * dpr); + + var pathTransform = { + position: path.position, + rotation: path.rotation, + scale: path.scale + }; + path.position = [0, 0, 0]; + path.rotation = 0; + path.scale = [1, 1]; + if (path) { + path.brush(ctx); + } + + var ImageShape = __webpack_require__(59); + var imgShape = new ImageShape({ + id: id, + style: { + x: 0, + y: 0, + image: canvas + } + }); + + if (pathTransform.position != null) { + imgShape.position = path.position = pathTransform.position; + } + + if (pathTransform.rotation != null) { + imgShape.rotation = path.rotation = pathTransform.rotation; + } + + if (pathTransform.scale != null) { + imgShape.scale = path.scale = pathTransform.scale; + } + + return imgShape; + }, + + _createPathToImage: function () { + var me = this; + + return function (id, e, width, height) { + return me._pathToImage( + id, e, width, height, me.dpr + ); + }; + } + }; + + module.exports = Painter; + + + +/***/ }, +/* 86 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module zrender/Layer + * @author pissang(https://www.github.com/pissang) + */ + + + var util = __webpack_require__(3); + var config = __webpack_require__(40); + + function returnFalse() { + return false; + } + + /** + * 创建dom + * + * @inner + * @param {string} id dom id 待用 + * @param {string} type dom type,such as canvas, div etc. + * @param {Painter} painter painter instance + * @param {number} number + */ + function createDom(id, type, painter, dpr) { + var newDom = document.createElement(type); + var width = painter.getWidth(); + var height = painter.getHeight(); + + var newDomStyle = newDom.style; + // 没append呢,请原谅我这样写,清晰~ + newDomStyle.position = 'absolute'; + newDomStyle.left = 0; + newDomStyle.top = 0; + newDomStyle.width = width + 'px'; + newDomStyle.height = height + 'px'; + newDom.width = width * dpr; + newDom.height = height * dpr; + + // id不作为索引用,避免可能造成的重名,定义为私有属性 + newDom.setAttribute('data-zr-dom-id', id); + return newDom; + } + + /** + * @alias module:zrender/Layer + * @constructor + * @extends module:zrender/mixin/Transformable + * @param {string} id + * @param {module:zrender/Painter} painter + * @param {number} [dpr] + */ + var Layer = function(id, painter, dpr) { + var dom; + dpr = dpr || config.devicePixelRatio; + if (typeof id === 'string') { + dom = createDom(id, 'canvas', painter, dpr); + } + // Not using isDom because in node it will return false + else if (util.isObject(id)) { + dom = id; + id = dom.id; + } + this.id = id; + this.dom = dom; + + var domStyle = dom.style; + if (domStyle) { // Not in node + dom.onselectstart = returnFalse; // 避免页面选中的尴尬 + domStyle['-webkit-user-select'] = 'none'; + domStyle['user-select'] = 'none'; + domStyle['-webkit-touch-callout'] = 'none'; + domStyle['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)'; + } + + this.domBack = null; + this.ctxBack = null; + + this.painter = painter; + + this.config = null; + + // Configs + /** + * 每次清空画布的颜色 + * @type {string} + * @default 0 + */ + this.clearColor = 0; + /** + * 是否开启动态模糊 + * @type {boolean} + * @default false + */ + this.motionBlur = false; + /** + * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 + * @type {number} + * @default 0.7 + */ + this.lastFrameAlpha = 0.7; + + /** + * Layer dpr + * @type {number} + */ + this.dpr = dpr; + }; + + Layer.prototype = { + + constructor: Layer, + + elCount: 0, + + __dirty: true, + + initContext: function () { + this.ctx = this.dom.getContext('2d'); + + var dpr = this.dpr; + if (dpr != 1) { + this.ctx.scale(dpr, dpr); + } + }, + + createBackBuffer: function () { + var dpr = this.dpr; + + this.domBack = createDom('back-' + this.id, 'canvas', this.painter, dpr); + this.ctxBack = this.domBack.getContext('2d'); + + if (dpr != 1) { + this.ctxBack.scale(dpr, dpr); + } + }, + + /** + * @param {number} width + * @param {number} height + */ + resize: function (width, height) { + var dpr = this.dpr; + + var dom = this.dom; + var domStyle = dom.style; + var domBack = this.domBack; + + domStyle.width = width + 'px'; + domStyle.height = height + 'px'; + + dom.width = width * dpr; + dom.height = height * dpr; + + if (dpr != 1) { + this.ctx.scale(dpr, dpr); + } + + if (domBack) { + domBack.width = width * dpr; + domBack.height = height * dpr; + + if (dpr != 1) { + this.ctxBack.scale(dpr, dpr); + } + } + }, + + /** + * 清空该层画布 + * @param {boolean} clearAll Clear all with out motion blur + */ + clear: function (clearAll) { + var dom = this.dom; + var ctx = this.ctx; + var width = dom.width; + var height = dom.height; + + var haveClearColor = this.clearColor; + var haveMotionBLur = this.motionBlur && !clearAll; + var lastFrameAlpha = this.lastFrameAlpha; + + var dpr = this.dpr; + + if (haveMotionBLur) { + if (!this.domBack) { + this.createBackBuffer(); + } + + this.ctxBack.globalCompositeOperation = 'copy'; + this.ctxBack.drawImage( + dom, 0, 0, + width / dpr, + height / dpr + ); + } + + ctx.clearRect(0, 0, width / dpr, height / dpr); + if (haveClearColor) { + ctx.save(); + ctx.fillStyle = this.clearColor; + ctx.fillRect(0, 0, width / dpr, height / dpr); + ctx.restore(); + } + + if (haveMotionBLur) { + var domBack = this.domBack; + ctx.save(); + ctx.globalAlpha = lastFrameAlpha; + ctx.drawImage(domBack, 0, 0, width / dpr, height / dpr); + ctx.restore(); + } + } + }; + + module.exports = Layer; + + +/***/ }, +/* 87 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + var PI = Math.PI; + /** + * @param {module:echarts/ExtensionAPI} api + * @param {Object} [opts] + * @param {string} [opts.text] + * @param {string} [opts.color] + * @param {string} [opts.textColor] + * @return {module:zrender/Element} + */ + module.exports = function (api, opts) { + opts = opts || {}; + zrUtil.defaults(opts, { + text: 'loading', + color: '#c23531', + textColor: '#000', + maskColor: 'rgba(255, 255, 255, 0.8)', + zlevel: 0 + }); + var mask = new graphic.Rect({ + style: { + fill: opts.maskColor + }, + zlevel: opts.zlevel, + z: 10000 + }); + var arc = new graphic.Arc({ + shape: { + startAngle: -PI / 2, + endAngle: -PI / 2 + 0.1, + r: 10 + }, + style: { + stroke: opts.color, + lineCap: 'round', + lineWidth: 5 + }, + zlevel: opts.zlevel, + z: 10001 + }); + var labelRect = new graphic.Rect({ + style: { + fill: 'none', + text: opts.text, + textPosition: 'right', + textDistance: 10, + textFill: opts.textColor + }, + zlevel: opts.zlevel, + z: 10001 + }); + + arc.animateShape(true) + .when(1000, { + endAngle: PI * 3 / 2 + }) + .start('circularInOut'); + arc.animateShape(true) + .when(1000, { + startAngle: PI * 3 / 2 + }) + .delay(300) + .start('circularInOut'); + + var group = new graphic.Group(); + group.add(arc); + group.add(labelRect); + group.add(mask); + // Inject resize + group.resize = function () { + var cx = api.getWidth() / 2; + var cy = api.getHeight() / 2; + arc.setShape({ + cx: cx, + cy: cy + }); + var r = arc.shape.r; + labelRect.setShape({ + x: cx - r, + y: cy - r, + width: r * 2, + height: r * 2 + }); + + mask.setShape({ + x: 0, + y: 0, + width: api.getWidth(), + height: api.getHeight() + }); + }; + group.resize(); + return group; + }; + + +/***/ }, +/* 88 */ +/***/ function(module, exports, __webpack_require__) { + + + var Gradient = __webpack_require__(4); + module.exports = function (seriesType, styleType, ecModel) { + function encodeColor(seriesModel) { + var colorAccessPath = [styleType, 'normal', 'color']; + var colorList = ecModel.get('color'); + var data = seriesModel.getData(); + var color = seriesModel.get(colorAccessPath) // Set in itemStyle + || colorList[seriesModel.seriesIndex % colorList.length]; // Default color + + // FIXME Set color function or use the platte color + data.setVisual('color', color); + + // Only visible series has each data be visual encoded + if (!ecModel.isSeriesFiltered(seriesModel)) { + if (typeof color === 'function' && !(color instanceof Gradient)) { + data.each(function (idx) { + data.setItemVisual( + idx, 'color', color(seriesModel.getDataParams(idx)) + ); + }); + } + + data.each(function (idx) { + var itemModel = data.getItemModel(idx); + var color = itemModel.get(colorAccessPath, true); + if (color != null) { + data.setItemVisual(idx, 'color', color); + } + }); + } + } + seriesType ? ecModel.eachSeriesByType(seriesType, encodeColor) + : ecModel.eachSeries(encodeColor); + }; + + +/***/ }, +/* 89 */ +/***/ function(module, exports, __webpack_require__) { + + // Compatitable with 2.0 + + + var zrUtil = __webpack_require__(3); + var compatStyle = __webpack_require__(90); + + function get(opt, path) { + path = path.split(','); + var obj = opt; + for (var i = 0; i < path.length; i++) { + obj = obj && obj[path[i]]; + if (obj == null) { + break; + } + } + return obj; + } + + function set(opt, path, val, overwrite) { + path = path.split(','); + var obj = opt; + var key; + for (var i = 0; i < path.length - 1; i++) { + key = path[i]; + if (obj[key] == null) { + obj[key] = {}; + } + obj = obj[key]; + } + if (overwrite || obj[path[i]] == null) { + obj[path[i]] = val; + } + } + + function compatLayoutProperties(option) { + each(LAYOUT_PROPERTIES, function (prop) { + if (prop[0] in option && !(prop[1] in option)) { + option[prop[1]] = option[prop[0]]; + } + }); + } + + var LAYOUT_PROPERTIES = [ + ['x', 'left'], ['y', 'top'], ['x2', 'right'], ['y2', 'bottom'] + ]; + + var COMPATITABLE_COMPONENTS = [ + 'grid', 'geo', 'parallel', 'legend', 'toolbox', 'title', 'visualMap', 'dataZoom', 'timeline' + ]; + + var COMPATITABLE_SERIES = [ + 'bar', 'boxplot', 'candlestick', 'chord', 'effectScatter', + 'funnel', 'gauge', 'lines', 'graph', 'heatmap', 'line', 'map', 'parallel', + 'pie', 'radar', 'sankey', 'scatter', 'treemap' + ]; + + var each = zrUtil.each; + + module.exports = function (option) { + each(option.series, function (seriesOpt) { + if (!zrUtil.isObject(seriesOpt)) { + return; + } + + var seriesType = seriesOpt.type; + + compatStyle(seriesOpt); + + if (seriesType === 'pie' || seriesType === 'gauge') { + if (seriesOpt.clockWise != null) { + seriesOpt.clockwise = seriesOpt.clockWise; + } + } + if (seriesType === 'gauge') { + var pointerColor = get(seriesOpt, 'pointer.color'); + pointerColor != null + && set(seriesOpt, 'itemStyle.normal.color', pointerColor); + } + + for (var i = 0; i < COMPATITABLE_SERIES.length; i++) { + if (COMPATITABLE_SERIES[i] === seriesOpt.type) { + compatLayoutProperties(seriesOpt); + break; + } + } + }); + + // dataRange has changed to visualMap + if (option.dataRange) { + option.visualMap = option.dataRange; + } + + each(COMPATITABLE_COMPONENTS, function (componentName) { + var options = option[componentName]; + if (options) { + if (!zrUtil.isArray(options)) { + options = [options]; + } + each(options, function (option) { + compatLayoutProperties(option); + }); + } + }); + }; + + +/***/ }, +/* 90 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + var POSSIBLE_STYLES = [ + 'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle', + 'chordStyle', 'label', 'labelLine' + ]; + + function compatItemStyle(opt) { + var itemStyleOpt = opt && opt.itemStyle; + if (itemStyleOpt) { + zrUtil.each(POSSIBLE_STYLES, function (styleName) { + var normalItemStyleOpt = itemStyleOpt.normal; + var emphasisItemStyleOpt = itemStyleOpt.emphasis; + if (normalItemStyleOpt && normalItemStyleOpt[styleName]) { + opt[styleName] = opt[styleName] || {}; + if (!opt[styleName].normal) { + opt[styleName].normal = normalItemStyleOpt[styleName]; + } + else { + zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]); + } + normalItemStyleOpt[styleName] = null; + } + if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) { + opt[styleName] = opt[styleName] || {}; + if (!opt[styleName].emphasis) { + opt[styleName].emphasis = emphasisItemStyleOpt[styleName]; + } + else { + zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]); + } + emphasisItemStyleOpt[styleName] = null; + } + }); + } + } + + module.exports = function (seriesOpt) { + if (!seriesOpt) { + return; + } + compatItemStyle(seriesOpt); + compatItemStyle(seriesOpt.markPoint); + compatItemStyle(seriesOpt.markLine); + var data = seriesOpt.data; + if (data) { + for (var i = 0; i < data.length; i++) { + compatItemStyle(data[i]); + } + // mark point data + var markPoint = seriesOpt.markPoint; + if (markPoint && markPoint.data) { + var mpData = markPoint.data; + for (var i = 0; i < mpData.length; i++) { + compatItemStyle(mpData[i]); + } + } + // mark line data + var markLine = seriesOpt.markLine; + if (markLine && markLine.data) { + var mlData = markLine.data; + for (var i = 0; i < mlData.length; i++) { + if (zrUtil.isArray(mlData[i])) { + compatItemStyle(mlData[i][0]); + compatItemStyle(mlData[i][1]); + } + else { + compatItemStyle(mlData[i]); + } + } + } + } + }; + + +/***/ }, +/* 91 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var echarts = __webpack_require__(1); + + __webpack_require__(92); + __webpack_require__(97); + + echarts.registerVisualCoding('chart', zrUtil.curry( + __webpack_require__(103), 'line', 'circle', 'line' + )); + echarts.registerLayout(zrUtil.curry( + __webpack_require__(104), 'line' + )); + + // Down sample after filter + echarts.registerProcessor('statistic', zrUtil.curry( + __webpack_require__(105), 'line' + )); + + // In case developer forget to include grid component + __webpack_require__(106); + + +/***/ }, +/* 92 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var createListFromArray = __webpack_require__(93); + var SeriesModel = __webpack_require__(27); + + module.exports = SeriesModel.extend({ + + type: 'series.line', + + dependencies: ['grid', 'polar'], + + getInitialData: function (option, ecModel) { + return createListFromArray(option.data, this, ecModel); + }, + + defaultOption: { + zlevel: 0, // 一级层叠 + z: 2, // 二级层叠 + coordinateSystem: 'cartesian2d', + legendHoverLink: true, + + hoverAnimation: true, + // stack: null + xAxisIndex: 0, + yAxisIndex: 0, + + polarIndex: 0, + + // If clip the overflow value + clipOverflow: true, + + label: { + normal: { + // show: false, + position: 'top' + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 + // 'inside'|'left'|'right'|'top'|'bottom' + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + } + // emphasis: { + // show: false, + // position: 'top' + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 + // 'inside'|'left'|'right'|'top'|'bottom' + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + // } + }, + // itemStyle: { + // normal: { + // // color: 各异 + // }, + // emphasis: { + // // color: 各异, + // } + // }, + lineStyle: { + normal: { + width: 2, + type: 'solid' + } + }, + // areaStyle: { + // }, + // smooth: false, + // smoothMonotone: null, + // 拐点图形类型 + symbol: 'emptyCircle', + // 拐点图形大小 + symbolSize: 4, + // 拐点图形旋转控制 + // symbolRotate: null, + + // 是否显示 symbol, 只有在 tooltip hover 的时候显示 + showSymbol: true, + // 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略) + // showAllSymbol: false + // + // 大数据过滤,'average', 'max', 'min', 'sum' + // sampling: 'none' + + animationEasing: 'linear' + } + }); + + +/***/ }, +/* 93 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var List = __webpack_require__(94); + var completeDimensions = __webpack_require__(96); + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var CoordinateSystem = __webpack_require__(25); + var getDataItemValue = modelUtil.getDataItemValue; + var converDataValue = modelUtil.converDataValue; + + function firstDataNotNull(data) { + var i = 0; + while (i < data.length && data[i] == null) { + i++; + } + return data[i]; + } + function ifNeedCompleteOrdinalData(data) { + var sampleItem = firstDataNotNull(data); + return sampleItem != null + && !zrUtil.isArray(getDataItemValue(sampleItem)); + } + + /** + * Helper function to create a list from option data + */ + function createListFromArray(data, seriesModel, ecModel) { + // If data is undefined + data = data || []; + + var coordSysName = seriesModel.get('coordinateSystem'); + var creator = creators[coordSysName]; + var registeredCoordSys = CoordinateSystem.get(coordSysName); + // FIXME + var result = creator && creator(data, seriesModel, ecModel); + var dimensions = result && result.dimensions; + if (!dimensions) { + // Get dimensions from registered coordinate system + dimensions = (registeredCoordSys && registeredCoordSys.dimensions) || ['x', 'y']; + dimensions = completeDimensions(dimensions, data, dimensions.concat(['value'])); + } + var categoryAxisModel = result && result.categoryAxisModel; + + var categoryDimIndex = dimensions[0].type === 'ordinal' + ? 0 : (dimensions[1].type === 'ordinal' ? 1 : -1); + + var list = new List(dimensions, seriesModel); + + var nameList = createNameList(result, data); + + var dimValueGetter = (categoryAxisModel && ifNeedCompleteOrdinalData(data)) + ? function (itemOpt, dimName, dataIndex, dimIndex) { + // Use dataIndex as ordinal value in categoryAxis + return dimIndex === categoryDimIndex + ? dataIndex + : converDataValue(getDataItemValue(itemOpt), dimensions[dimIndex]); + } + : function (itemOpt, dimName, dataIndex, dimIndex) { + var val = getDataItemValue(itemOpt); + return converDataValue(val && val[dimIndex], dimensions[dimIndex]); + }; + + list.initData(data, nameList, dimValueGetter); + + return list; + } + + function isStackable(axisType) { + return axisType !== 'category' && axisType !== 'time'; + } + + function getDimTypeByAxis(axisType) { + return axisType === 'category' + ? 'ordinal' + : axisType === 'time' + ? 'time' + : 'float'; + } + + /** + * Creaters for each coord system. + * @return {Object} {dimensions, categoryAxisModel}; + */ + var creators = { + + cartesian2d: function (data, seriesModel, ecModel) { + var xAxisModel = ecModel.getComponent('xAxis', seriesModel.get('xAxisIndex')); + var yAxisModel = ecModel.getComponent('yAxis', seriesModel.get('yAxisIndex')); + var xAxisType = xAxisModel.get('type'); + var yAxisType = yAxisModel.get('type'); + + var dimensions = [ + { + name: 'x', + type: getDimTypeByAxis(xAxisType), + stackable: isStackable(xAxisType) + }, + { + name: 'y', + // If two category axes + type: getDimTypeByAxis(yAxisType), + stackable: isStackable(yAxisType) + } + ]; + + completeDimensions(dimensions, data, ['x', 'y', 'z']); + + return { + dimensions: dimensions, + categoryAxisModel: xAxisType === 'category' + ? xAxisModel + : (yAxisType === 'category' ? yAxisModel : null) + }; + }, + + polar: function (data, seriesModel, ecModel) { + var polarIndex = seriesModel.get('polarIndex') || 0; + + var axisFinder = function (axisModel) { + return axisModel.get('polarIndex') === polarIndex; + }; + + var angleAxisModel = ecModel.findComponents({ + mainType: 'angleAxis', filter: axisFinder + })[0]; + var radiusAxisModel = ecModel.findComponents({ + mainType: 'radiusAxis', filter: axisFinder + })[0]; + + var radiusAxisType = radiusAxisModel.get('type'); + var angleAxisType = angleAxisModel.get('type'); + + var dimensions = [ + { + name: 'radius', + type: getDimTypeByAxis(radiusAxisType), + stackable: isStackable(radiusAxisType) + }, + { + name: 'angle', + type: getDimTypeByAxis(angleAxisType), + stackable: isStackable(angleAxisType) + } + ]; + + completeDimensions(dimensions, data, ['radius', 'angle', 'value']); + + return { + dimensions: dimensions, + categoryAxisModel: angleAxisType === 'category' + ? angleAxisModel + : (radiusAxisType === 'category' ? radiusAxisModel : null) + }; + }, + + geo: function (data, seriesModel, ecModel) { + // TODO Region + // 多个散点图系列在同一个地区的时候 + return { + dimensions: completeDimensions([ + {name: 'lng'}, + {name: 'lat'} + ], data, ['lng', 'lat', 'value']) + }; + } + }; + + function createNameList(result, data) { + var nameList = []; + + if (result && result.categoryAxisModel) { + // FIXME Two category axis + var categories = result.categoryAxisModel.getCategories(); + if (categories) { + var dataLen = data.length; + // Ordered data is given explicitly like + // [[3, 0.2], [1, 0.3], [2, 0.15]] + // or given scatter data, + // pick the category + if (zrUtil.isArray(data[0]) && data[0].length > 1) { + nameList = []; + for (var i = 0; i < dataLen; i++) { + nameList[i] = categories[data[i][0]]; + } + } + else { + nameList = categories.slice(0); + } + } + } + + return nameList; + } + + module.exports = createListFromArray; + + + +/***/ }, +/* 94 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global) {/** + * List for data storage + * @module echarts/data/List + */ + + + var UNDEFINED = 'undefined'; + var globalObj = typeof window === 'undefined' ? global : window; + var Float64Array = typeof globalObj.Float64Array === UNDEFINED + ? Array : globalObj.Float64Array; + var Int32Array = typeof globalObj.Int32Array === UNDEFINED + ? Array : globalObj.Int32Array; + + var dataCtors = { + 'float': Float64Array, + 'int': Int32Array, + // Ordinal data type can be string or int + 'ordinal': Array, + 'number': Array, + 'time': Array + }; + + var Model = __webpack_require__(8); + var DataDiffer = __webpack_require__(95); + + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var isObject = zrUtil.isObject; + + var IMMUTABLE_PROPERTIES = [ + 'stackedOn', '_nameList', '_idList', '_rawData' + ]; + + var transferImmuProperties = function (a, b, wrappedMethod) { + zrUtil.each(IMMUTABLE_PROPERTIES.concat(wrappedMethod || []), function (propName) { + if (b.hasOwnProperty(propName)) { + a[propName] = b[propName]; + } + }); + }; + + /** + * @constructor + * @alias module:echarts/data/List + * + * @param {Array.} dimensions + * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius + * @param {module:echarts/model/Model} hostModel + */ + var List = function (dimensions, hostModel) { + + dimensions = dimensions || ['x', 'y']; + + var dimensionInfos = {}; + var dimensionNames = []; + for (var i = 0; i < dimensions.length; i++) { + var dimensionName; + var dimensionInfo = {}; + if (typeof dimensions[i] === 'string') { + dimensionName = dimensions[i]; + dimensionInfo = { + name: dimensionName, + stackable: false, + // Type can be 'float', 'int', 'number' + // Default is number, Precision of float may not enough + type: 'number' + }; + } + else { + dimensionInfo = dimensions[i]; + dimensionName = dimensionInfo.name; + dimensionInfo.type = dimensionInfo.type || 'number'; + } + dimensionNames.push(dimensionName); + dimensionInfos[dimensionName] = dimensionInfo; + } + /** + * @readOnly + * @type {Array.} + */ + this.dimensions = dimensionNames; + + /** + * Infomation of each data dimension, like data type. + * @type {Object} + */ + this._dimensionInfos = dimensionInfos; + + /** + * @type {module:echarts/model/Model} + */ + this.hostModel = hostModel; + + /** + * Indices stores the indices of data subset after filtered. + * This data subset will be used in chart. + * @type {Array.} + * @readOnly + */ + this.indices = []; + + /** + * Data storage + * @type {Object.} + * @private + */ + this._storage = {}; + + /** + * @type {Array.} + */ + this._nameList = []; + /** + * @type {Array.} + */ + this._idList = []; + /** + * Models of data option is stored sparse for optimizing memory cost + * @type {Array.} + * @private + */ + this._optionModels = []; + + /** + * @param {module:echarts/data/List} + */ + this.stackedOn = null; + + /** + * Global visual properties after visual coding + * @type {Object} + * @private + */ + this._visual = {}; + + /** + * Globel layout properties. + * @type {Object} + * @private + */ + this._layout = {}; + + /** + * Item visual properties after visual coding + * @type {Array.} + * @private + */ + this._itemVisuals = []; + + /** + * Item layout properties after layout + * @type {Array.} + * @private + */ + this._itemLayouts = []; + + /** + * Graphic elemnents + * @type {Array.} + * @private + */ + this._graphicEls = []; + + /** + * @type {Array.} + * @private + */ + this._rawData; + + /** + * @type {Object} + * @private + */ + this._extent; + }; + + var listProto = List.prototype; + + listProto.type = 'list'; + + /** + * Get dimension name + * @param {string|number} dim + * Dimension can be concrete names like x, y, z, lng, lat, angle, radius + * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius' + */ + listProto.getDimension = function (dim) { + if (!isNaN(dim)) { + dim = this.dimensions[dim] || dim; + } + return dim; + }; + /** + * Get type and stackable info of particular dimension + * @param {string|number} dim + * Dimension can be concrete names like x, y, z, lng, lat, angle, radius + * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius' + */ + listProto.getDimensionInfo = function (dim) { + return zrUtil.clone(this._dimensionInfos[this.getDimension(dim)]); + }; + + /** + * Initialize from data + * @param {Array.} data + * @param {Array.} [nameList] + * @param {Function} [dimValueGetter] (dataItem, dimName, dataIndex, dimIndex) => number + */ + listProto.initData = function (data, nameList, dimValueGetter) { + data = data || []; + + this._rawData = data; + + // Clear + var storage = this._storage = {}; + var indices = this.indices = []; + + var dimensions = this.dimensions; + var size = data.length; + var dimensionInfoMap = this._dimensionInfos; + + var idList = []; + var nameRepeatCount = {}; + + nameList = nameList || []; + + // Init storage + for (var i = 0; i < dimensions.length; i++) { + var dimInfo = dimensionInfoMap[dimensions[i]]; + var DataCtor = dataCtors[dimInfo.type]; + storage[dimensions[i]] = new DataCtor(size); + } + + // Default dim value getter + dimValueGetter = dimValueGetter || function (dataItem, dimName, dataIndex, dimIndex) { + var value = modelUtil.getDataItemValue(dataItem); + return modelUtil.converDataValue( + zrUtil.isArray(value) + ? value[dimIndex] + // If value is a single number or something else not array. + : value, + dimensionInfoMap[dimName] + ); + }; + + for (var idx = 0; idx < data.length; idx++) { + var dataItem = data[idx]; + // Each data item is value + // [1, 2] + // 2 + // Bar chart, line chart which uses category axis + // only gives the 'y' value. 'x' value is the indices of cateogry + // Use a tempValue to normalize the value to be a (x, y) value + + // Store the data by dimensions + for (var k = 0; k < dimensions.length; k++) { + var dim = dimensions[k]; + var dimStorage = storage[dim]; + // PENDING NULL is empty or zero + dimStorage[idx] = dimValueGetter(dataItem, dim, idx, k); + } + + indices.push(idx); + } + + // Use the name in option and create id + for (var i = 0; i < data.length; i++) { + var id = ''; + if (!nameList[i]) { + nameList[i] = data[i].name; + // Try using the id in option + id = data[i].id; + } + var name = nameList[i] || ''; + if (!id && name) { + // Use name as id and add counter to avoid same name + nameRepeatCount[name] = nameRepeatCount[name] || 0; + id = name; + if (nameRepeatCount[name] > 0) { + id += '__ec__' + nameRepeatCount[name]; + } + nameRepeatCount[name]++; + } + id && (idList[i] = id); + } + + this._nameList = nameList; + this._idList = idList; + }; + + /** + * @return {number} + */ + listProto.count = function () { + return this.indices.length; + }; + + /** + * Get value. Return NaN if idx is out of range. + * @param {string} dim Dim must be concrete name. + * @param {number} idx + * @param {boolean} stack + * @return {number} + */ + listProto.get = function (dim, idx, stack) { + var storage = this._storage; + var dataIndex = this.indices[idx]; + + // If value not exists + if (dataIndex == null) { + return NaN; + } + + var value = storage[dim] && storage[dim][dataIndex]; + // FIXME ordinal data type is not stackable + if (stack) { + var dimensionInfo = this._dimensionInfos[dim]; + if (dimensionInfo && dimensionInfo.stackable) { + var stackedOn = this.stackedOn; + while (stackedOn) { + // Get no stacked data of stacked on + var stackedValue = stackedOn.get(dim, idx); + // Considering positive stack, negative stack and empty data + if ((value >= 0 && stackedValue > 0) // Positive stack + || (value <= 0 && stackedValue < 0) // Negative stack + ) { + value += stackedValue; + } + stackedOn = stackedOn.stackedOn; + } + } + } + return value; + }; + + /** + * Get value for multi dimensions. + * @param {Array.} [dimensions] If ignored, using all dimensions. + * @param {number} idx + * @param {boolean} stack + * @return {number} + */ + listProto.getValues = function (dimensions, idx, stack) { + var values = []; + + if (!zrUtil.isArray(dimensions)) { + stack = idx; + idx = dimensions; + dimensions = this.dimensions; + } + + for (var i = 0, len = dimensions.length; i < len; i++) { + values.push(this.get(dimensions[i], idx, stack)); + } + + return values; + }; + + /** + * If value is NaN. Inlcuding '-' + * @param {string} dim + * @param {number} idx + * @return {number} + */ + listProto.hasValue = function (idx) { + var dimensions = this.dimensions; + var dimensionInfos = this._dimensionInfos; + for (var i = 0, len = dimensions.length; i < len; i++) { + if ( + // Ordinal type can be string or number + dimensionInfos[dimensions[i]].type !== 'ordinal' + && isNaN(this.get(dimensions[i], idx)) + ) { + return false; + } + } + return true; + }; + + /** + * Get extent of data in one dimension + * @param {string} dim + * @param {boolean} stack + */ + listProto.getDataExtent = function (dim, stack) { + var dimData = this._storage[dim]; + var dimInfo = this.getDimensionInfo(dim); + stack = (dimInfo && dimInfo.stackable) && stack; + var dimExtent = (this._extent || (this._extent = {}))[dim + (!!stack)]; + var value; + if (dimExtent) { + return dimExtent; + } + // var dimInfo = this._dimensionInfos[dim]; + if (dimData) { + var min = Infinity; + var max = -Infinity; + // var isOrdinal = dimInfo.type === 'ordinal'; + for (var i = 0, len = this.count(); i < len; i++) { + value = this.get(dim, i, stack); + // FIXME + // if (isOrdinal && typeof value === 'string') { + // value = zrUtil.indexOf(dimData, value); + // console.log(value); + // } + value < min && (min = value); + value > max && (max = value); + } + return (this._extent[dim + stack] = [min, max]); + } + else { + return [Infinity, -Infinity]; + } + }; + + /** + * Get sum of data in one dimension + * @param {string} dim + * @param {boolean} stack + */ + listProto.getSum = function (dim, stack) { + var dimData = this._storage[dim]; + var sum = 0; + if (dimData) { + for (var i = 0, len = this.count(); i < len; i++) { + var value = this.get(dim, i, stack); + if (!isNaN(value)) { + sum += value; + } + } + } + return sum; + }; + + /** + * Retreive the index with given value + * @param {number} idx + * @param {number} value + * @return {number} + */ + // FIXME Precision of float value + listProto.indexOf = function (dim, value) { + var storage = this._storage; + var dimData = storage[dim]; + var indices = this.indices; + + if (dimData) { + for (var i = 0, len = indices.length; i < len; i++) { + var rawIndex = indices[i]; + if (dimData[rawIndex] === value) { + return i; + } + } + } + return -1; + }; + + /** + * Retreive the index with given name + * @param {number} idx + * @param {number} name + * @return {number} + */ + listProto.indexOfName = function (name) { + var indices = this.indices; + var nameList = this._nameList; + + for (var i = 0, len = indices.length; i < len; i++) { + var rawIndex = indices[i]; + if (nameList[rawIndex] === name) { + return i; + } + } + + return -1; + }; + + /** + * Retreive the index of nearest value + * @param {string>} dim + * @param {number} value + * @param {boolean} stack If given value is after stacked + * @return {number} + */ + listProto.indexOfNearest = function (dim, value, stack) { + var storage = this._storage; + var dimData = storage[dim]; + + if (dimData) { + var minDist = Number.MAX_VALUE; + var nearestIdx = -1; + for (var i = 0, len = this.count(); i < len; i++) { + var dist = Math.abs(this.get(dim, i, stack) - value); + if (dist <= minDist) { + minDist = dist; + nearestIdx = i; + } + } + return nearestIdx; + } + return -1; + }; + + /** + * Get raw data index + * @param {number} idx + * @return {number} + */ + listProto.getRawIndex = function (idx) { + var rawIdx = this.indices[idx]; + return rawIdx == null ? -1 : rawIdx; + }; + + /** + * @param {number} idx + * @param {boolean} [notDefaultIdx=false] + * @return {string} + */ + listProto.getName = function (idx) { + return this._nameList[this.indices[idx]] || ''; + }; + + /** + * @param {number} idx + * @param {boolean} [notDefaultIdx=false] + * @return {string} + */ + listProto.getId = function (idx) { + return this._idList[this.indices[idx]] || (this.getRawIndex(idx) + ''); + }; + + + function normalizeDimensions(dimensions) { + if (!zrUtil.isArray(dimensions)) { + dimensions = [dimensions]; + } + return dimensions; + } + + /** + * Data iteration + * @param {string|Array.} + * @param {Function} cb + * @param {boolean} [stack=false] + * @param {*} [context=this] + * + * @example + * list.each('x', function (x, idx) {}); + * list.each(['x', 'y'], function (x, y, idx) {}); + * list.each(function (idx) {}) + */ + listProto.each = function (dimensions, cb, stack, context) { + if (typeof dimensions === 'function') { + context = stack; + stack = cb; + cb = dimensions; + dimensions = []; + } + + dimensions = zrUtil.map( + normalizeDimensions(dimensions), this.getDimension, this + ); + + var value = []; + var dimSize = dimensions.length; + var indices = this.indices; + + context = context || this; + + for (var i = 0; i < indices.length; i++) { + if (dimSize === 0) { + cb.call(context, i); + } + // Simple optimization + else if (dimSize === 1) { + cb.call(context, this.get(dimensions[0], i, stack), i); + } + else { + for (var k = 0; k < dimSize; k++) { + value[k] = this.get(dimensions[k], i, stack); + } + // Index + value[k] = i; + cb.apply(context, value); + } + } + }; + + /** + * Data filter + * @param {string|Array.} + * @param {Function} cb + * @param {boolean} [stack=false] + * @param {*} [context=this] + */ + listProto.filterSelf = function (dimensions, cb, stack, context) { + if (typeof dimensions === 'function') { + context = stack; + stack = cb; + cb = dimensions; + dimensions = []; + } + + dimensions = zrUtil.map( + normalizeDimensions(dimensions), this.getDimension, this + ); + + var newIndices = []; + var value = []; + var dimSize = dimensions.length; + var indices = this.indices; + + context = context || this; + + for (var i = 0; i < indices.length; i++) { + var keep; + // Simple optimization + if (dimSize === 1) { + keep = cb.call( + context, this.get(dimensions[0], i, stack), i + ); + } + else { + for (var k = 0; k < dimSize; k++) { + value[k] = this.get(dimensions[k], i, stack); + } + value[k] = i; + keep = cb.apply(context, value); + } + if (keep) { + newIndices.push(indices[i]); + } + } + + this.indices = newIndices; + + // Reset data extent + this._extent = {}; + + return this; + }; + + /** + * Data mapping to a plain array + * @param {string|Array.} [dimensions] + * @param {Function} cb + * @param {boolean} [stack=false] + * @param {*} [context=this] + * @return {Array} + */ + listProto.mapArray = function (dimensions, cb, stack, context) { + if (typeof dimensions === 'function') { + context = stack; + stack = cb; + cb = dimensions; + dimensions = []; + } + + var result = []; + this.each(dimensions, function () { + result.push(cb && cb.apply(this, arguments)); + }, stack, context); + return result; + }; + + function cloneListForMapAndSample(original, excludeDimensions) { + var allDimensions = original.dimensions; + var list = new List( + zrUtil.map(allDimensions, original.getDimensionInfo, original), + original.hostModel + ); + // FIXME If needs stackedOn, value may already been stacked + transferImmuProperties(list, original, original._wrappedMethods); + + var storage = list._storage = {}; + var originalStorage = original._storage; + // Init storage + for (var i = 0; i < allDimensions.length; i++) { + var dim = allDimensions[i]; + var dimStore = originalStorage[dim]; + if (zrUtil.indexOf(excludeDimensions, dim) >= 0) { + storage[dim] = new dimStore.constructor( + originalStorage[dim].length + ); + } + else { + // Direct reference for other dimensions + storage[dim] = originalStorage[dim]; + } + } + return list; + } + + /** + * Data mapping to a new List with given dimensions + * @param {string|Array.} dimensions + * @param {Function} cb + * @param {boolean} [stack=false] + * @param {*} [context=this] + * @return {Array} + */ + listProto.map = function (dimensions, cb, stack, context) { + dimensions = zrUtil.map( + normalizeDimensions(dimensions), this.getDimension, this + ); + + var list = cloneListForMapAndSample(this, dimensions); + // Following properties are all immutable. + // So we can reference to the same value + var indices = list.indices = this.indices; + + var storage = list._storage; + + var tmpRetValue = []; + this.each(dimensions, function () { + var idx = arguments[arguments.length - 1]; + var retValue = cb && cb.apply(this, arguments); + if (retValue != null) { + // a number + if (typeof retValue === 'number') { + tmpRetValue[0] = retValue; + retValue = tmpRetValue; + } + for (var i = 0; i < retValue.length; i++) { + var dim = dimensions[i]; + var dimStore = storage[dim]; + var rawIdx = indices[idx]; + if (dimStore) { + dimStore[rawIdx] = retValue[i]; + } + } + } + }, stack, context); + + return list; + }; + + /** + * Large data down sampling on given dimension + * @param {string} dimension + * @param {number} rate + * @param {Function} sampleValue + * @param {Function} sampleIndex Sample index for name and id + */ + listProto.downSample = function (dimension, rate, sampleValue, sampleIndex) { + var list = cloneListForMapAndSample(this, [dimension]); + var storage = this._storage; + var targetStorage = list._storage; + + var originalIndices = this.indices; + var indices = list.indices = []; + + var frameValues = []; + var frameIndices = []; + var frameSize = Math.floor(1 / rate); + + var dimStore = targetStorage[dimension]; + var len = this.count(); + // Copy data from original data + for (var i = 0; i < storage[dimension].length; i++) { + targetStorage[dimension][i] = storage[dimension][i]; + } + for (var i = 0; i < len; i += frameSize) { + // Last frame + if (frameSize > len - i) { + frameSize = len - i; + frameValues.length = frameSize; + } + for (var k = 0; k < frameSize; k++) { + var idx = originalIndices[i + k]; + frameValues[k] = dimStore[idx]; + frameIndices[k] = idx; + } + var value = sampleValue(frameValues); + var idx = frameIndices[sampleIndex(frameValues, value) || 0]; + // Only write value on the filtered data + dimStore[idx] = value; + indices.push(idx); + } + return list; + }; + + /** + * Get model of one data item. + * + * @param {number} idx + */ + // FIXME Model proxy ? + listProto.getItemModel = function (idx) { + var hostModel = this.hostModel; + idx = this.indices[idx]; + return new Model(this._rawData[idx], hostModel, hostModel.ecModel); + }; + + /** + * Create a data differ + * @param {module:echarts/data/List} otherList + * @return {module:echarts/data/DataDiffer} + */ + listProto.diff = function (otherList) { + var idList = this._idList; + var otherIdList = otherList && otherList._idList; + return new DataDiffer( + otherList ? otherList.indices : [], this.indices, function (idx) { + return otherIdList[idx] || (idx + ''); + }, function (idx) { + return idList[idx] || (idx + ''); + } + ); + }; + /** + * Get visual property. + * @param {string} key + */ + listProto.getVisual = function (key) { + var visual = this._visual; + return visual && visual[key]; + }; + + /** + * Set visual property + * @param {string|Object} key + * @param {*} [value] + * + * @example + * setVisual('color', color); + * setVisual({ + * 'color': color + * }); + */ + listProto.setVisual = function (key, val) { + if (isObject(key)) { + for (var name in key) { + if (key.hasOwnProperty(name)) { + this.setVisual(name, key[name]); + } + } + return; + } + this._visual = this._visual || {}; + this._visual[key] = val; + }; + + /** + * Set layout property. + * @param {string} key + * @param {*} [val] + */ + listProto.setLayout = function (key, val) { + if (isObject(key)) { + for (var name in key) { + if (key.hasOwnProperty(name)) { + this.setLayout(name, key[name]); + } + } + return; + } + this._layout[key] = val; + }; + + /** + * Get layout property. + * @param {string} key. + * @return {*} + */ + listProto.getLayout = function (key) { + return this._layout[key]; + }; + + /** + * Get layout of single data item + * @param {number} idx + */ + listProto.getItemLayout = function (idx) { + return this._itemLayouts[idx]; + }, + + /** + * Set layout of single data item + * @param {number} idx + * @param {Object} layout + * @param {boolean=} [merge=false] + */ + listProto.setItemLayout = function (idx, layout, merge) { + this._itemLayouts[idx] = merge + ? zrUtil.extend(this._itemLayouts[idx] || {}, layout) + : layout; + }, + + /** + * Get visual property of single data item + * @param {number} idx + * @param {string} key + * @param {boolean} ignoreParent + */ + listProto.getItemVisual = function (idx, key, ignoreParent) { + var itemVisual = this._itemVisuals[idx]; + var val = itemVisual && itemVisual[key]; + if (val == null && !ignoreParent) { + // Use global visual property + return this.getVisual(key); + } + return val; + }, + + /** + * Set visual property of single data item + * + * @param {number} idx + * @param {string|Object} key + * @param {*} [value] + * + * @example + * setItemVisual(0, 'color', color); + * setItemVisual(0, { + * 'color': color + * }); + */ + listProto.setItemVisual = function (idx, key, value) { + var itemVisual = this._itemVisuals[idx] || {}; + this._itemVisuals[idx] = itemVisual; + + if (isObject(key)) { + for (var name in key) { + if (key.hasOwnProperty(name)) { + itemVisual[name] = key[name]; + } + } + return; + } + itemVisual[key] = value; + }; + + var setItemDataAndSeriesIndex = function (child) { + child.seriesIndex = this.seriesIndex; + child.dataIndex = this.dataIndex; + }; + /** + * Set graphic element relative to data. It can be set as null + * @param {number} idx + * @param {module:zrender/Element} [el] + */ + listProto.setItemGraphicEl = function (idx, el) { + var hostModel = this.hostModel; + + if (el) { + // Add data index and series index for indexing the data by element + // Useful in tooltip + el.dataIndex = idx; + el.seriesIndex = hostModel && hostModel.seriesIndex; + if (el.type === 'group') { + el.traverse(setItemDataAndSeriesIndex, el); + } + } + + this._graphicEls[idx] = el; + }; + + /** + * @param {number} idx + * @return {module:zrender/Element} + */ + listProto.getItemGraphicEl = function (idx) { + return this._graphicEls[idx]; + }; + + /** + * @param {Function} cb + * @param {*} context + */ + listProto.eachItemGraphicEl = function (cb, context) { + zrUtil.each(this._graphicEls, function (el, idx) { + if (el) { + cb && cb.call(context, el, idx); + } + }); + }; + + /** + * Shallow clone a new list except visual and layout properties, and graph elements. + * New list only change the indices. + */ + listProto.cloneShallow = function () { + var dimensionInfoList = zrUtil.map(this.dimensions, this.getDimensionInfo, this); + var list = new List(dimensionInfoList, this.hostModel); + + // FIXME + list._storage = this._storage; + + transferImmuProperties(list, this, this._wrappedMethods); + + list.indices = this.indices.slice(); + + return list; + }; + + /** + * Wrap some method to add more feature + * @param {string} methodName + * @param {Function} injectFunction + */ + listProto.wrapMethod = function (methodName, injectFunction) { + var originalMethod = this[methodName]; + if (typeof originalMethod !== 'function') { + return; + } + this._wrappedMethods = this._wrappedMethods || []; + this._wrappedMethods.push(methodName); + this[methodName] = function () { + var res = originalMethod.apply(this, arguments); + return injectFunction.call(this, res); + }; + }; + + module.exports = List; + + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }, +/* 95 */ +/***/ function(module, exports) { + + 'use strict'; + + + function defaultKeyGetter(item) { + return item; + } + + function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter) { + this._old = oldArr; + this._new = newArr; + + this._oldKeyGetter = oldKeyGetter || defaultKeyGetter; + this._newKeyGetter = newKeyGetter || defaultKeyGetter; + } + + DataDiffer.prototype = { + + constructor: DataDiffer, + + /** + * Callback function when add a data + */ + add: function (func) { + this._add = func; + return this; + }, + + /** + * Callback function when update a data + */ + update: function (func) { + this._update = func; + return this; + }, + + /** + * Callback function when remove a data + */ + remove: function (func) { + this._remove = func; + return this; + }, + + execute: function () { + var oldArr = this._old; + var newArr = this._new; + var oldKeyGetter = this._oldKeyGetter; + var newKeyGetter = this._newKeyGetter; + + var oldDataIndexMap = {}; + var newDataIndexMap = {}; + var i; + + initIndexMap(oldArr, oldDataIndexMap, oldKeyGetter); + initIndexMap(newArr, newDataIndexMap, newKeyGetter); + + // Travel by inverted order to make sure order consistency + // when duplicate keys exists (consider newDataIndex.pop() below). + // For performance consideration, these code below do not look neat. + for (i = 0; i < oldArr.length; i++) { + var key = oldKeyGetter(oldArr[i]); + var idx = newDataIndexMap[key]; + + // idx can never be empty array here. see 'set null' logic below. + if (idx != null) { + // Consider there is duplicate key (for example, use dataItem.name as key). + // We should make sure every item in newArr and oldArr can be visited. + var len = idx.length; + if (len) { + len === 1 && (newDataIndexMap[key] = null); + idx = idx.unshift(); + } + else { + newDataIndexMap[key] = null; + } + this._update && this._update(idx, i); + } + else { + this._remove && this._remove(i); + } + } + + for (var key in newDataIndexMap) { + if (newDataIndexMap.hasOwnProperty(key)) { + var idx = newDataIndexMap[key]; + if (idx == null) { + continue; + } + // idx can never be empty array here. see 'set null' logic above. + if (!idx.length) { + this._add && this._add(idx); + } + else { + for (var i = 0, len = idx.length; i < len; i++) { + this._add && this._add(idx[i]); + } + } + } + } + } + }; + + function initIndexMap(arr, map, keyGetter) { + for (var i = 0; i < arr.length; i++) { + var key = keyGetter(arr[i]); + var existence = map[key]; + if (existence == null) { + map[key] = i; + } + else { + if (!existence.length) { + map[key] = existence = [existence]; + } + existence.push(i); + } + } + } + + module.exports = DataDiffer; + + +/***/ }, +/* 96 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Complete dimensions by data (guess dimension). + */ + + + var zrUtil = __webpack_require__(3); + + /** + * Complete the dimensions array guessed from the data structure. + * @param {Array.} dimensions Necessary dimensions, like ['x', 'y'] + * @param {Array} data Data list. [[1, 2, 3], [2, 3, 4]] + * @param {Array.} defaultNames Default names to fill not necessary dimensions, like ['value'] + * @param {string} extraPrefix Prefix of name when filling the left dimensions. + * @return {Array.} + */ + function completeDimensions(dimensions, data, defaultNames, extraPrefix) { + if (!data) { + return dimensions; + } + + var value0 = retrieveValue(data[0]); + var dimSize = zrUtil.isArray(value0) && value0.length || 1; + + defaultNames = defaultNames || []; + extraPrefix = extraPrefix || 'extra'; + for (var i = 0; i < dimSize; i++) { + if (!dimensions[i]) { + var name = defaultNames[i] || (extraPrefix + (i - defaultNames.length)); + dimensions[i] = guessOrdinal(data, i) + ? {type: 'ordinal', name: name} + : name; + } + } + + return dimensions; + } + + // The rule should not be complex, otherwise user might not + // be able to known where the data is wrong. + function guessOrdinal(data, dimIndex) { + for (var i = 0, len = data.length; i < len; i++) { + var value = retrieveValue(data[i]); + + if (!zrUtil.isArray(value)) { + return false; + } + + var value = value[dimIndex]; + if (value != null && isFinite(value)) { + return false; + } + else if (zrUtil.isString(value) && value !== '-') { + return true; + } + } + return false; + } + + function retrieveValue(o) { + return zrUtil.isArray(o) ? o : zrUtil.isObject(o) ? o.value: o; + } + + module.exports = completeDimensions; + + + +/***/ }, +/* 97 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var SymbolDraw = __webpack_require__(98); + var Symbol = __webpack_require__(99); + var lineAnimationDiff = __webpack_require__(101); + var graphic = __webpack_require__(42); + + var polyHelper = __webpack_require__(102); + + var ChartView = __webpack_require__(41); + + function isPointsSame(points1, points2) { + if (points1.length !== points2.length) { + return; + } + for (var i = 0; i < points1.length; i++) { + var p1 = points1[i]; + var p2 = points2[i]; + if (p1[0] !== p2[0] || p1[1] !== p2[1]) { + return; + } + } + return true; + } + + function getSmooth(smooth) { + return typeof (smooth) === 'number' ? smooth : (smooth ? 0.3 : 0); + } + + function getAxisExtentWithGap(axis) { + var extent = axis.getGlobalExtent(); + if (axis.onBand) { + // Remove extra 1px to avoid line miter in clipped edge + var halfBandWidth = axis.getBandWidth() / 2 - 1; + var dir = extent[1] > extent[0] ? 1 : -1; + extent[0] += dir * halfBandWidth; + extent[1] -= dir * halfBandWidth; + } + return extent; + } + + function sign(val) { + return val >= 0 ? 1 : -1; + } + /** + * @param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys + * @param {module:echarts/data/List} data + * @param {Array.>} points + * @private + */ + function getStackedOnPoints(coordSys, data) { + var baseAxis = coordSys.getBaseAxis(); + var valueAxis = coordSys.getOtherAxis(baseAxis); + var valueStart = baseAxis.onZero + ? 0 : valueAxis.scale.getExtent()[0]; + + var valueDim = valueAxis.dim; + + var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0; + + return data.mapArray([valueDim], function (val, idx) { + var stackedOnSameSign; + var stackedOn = data.stackedOn; + // Find first stacked value with same sign + while (stackedOn && + sign(stackedOn.get(valueDim, idx)) === sign(val) + ) { + stackedOnSameSign = stackedOn; + break; + } + var stackedData = []; + stackedData[baseDataOffset] = data.get(baseAxis.dim, idx); + stackedData[1 - baseDataOffset] = stackedOnSameSign + ? stackedOnSameSign.get(valueDim, idx, true) : valueStart; + + return coordSys.dataToPoint(stackedData); + }, true); + } + + function queryDataIndex(data, payload) { + if (payload.dataIndex != null) { + return payload.dataIndex; + } + else if (payload.name != null) { + return data.indexOfName(payload.name); + } + } + + function createGridClipShape(cartesian, hasAnimation, seriesModel) { + var xExtent = getAxisExtentWithGap(cartesian.getAxis('x')); + var yExtent = getAxisExtentWithGap(cartesian.getAxis('y')); + var isHorizontal = cartesian.getBaseAxis().isHorizontal(); + + var x = xExtent[0]; + var y = yExtent[0]; + var width = xExtent[1] - x; + var height = yExtent[1] - y; + // Expand clip shape to avoid line value exceeds axis + if (!seriesModel.get('clipOverflow')) { + if (isHorizontal) { + y -= height; + height *= 3; + } + else { + x -= width; + width *= 3; + } + } + var clipPath = new graphic.Rect({ + shape: { + x: x, + y: y, + width: width, + height: height + } + }); + + if (hasAnimation) { + clipPath.shape[isHorizontal ? 'width' : 'height'] = 0; + graphic.initProps(clipPath, { + shape: { + width: width, + height: height + } + }, seriesModel); + } + + return clipPath; + } + + function createPolarClipShape(polar, hasAnimation, seriesModel) { + var angleAxis = polar.getAngleAxis(); + var radiusAxis = polar.getRadiusAxis(); + + var radiusExtent = radiusAxis.getExtent(); + var angleExtent = angleAxis.getExtent(); + + var RADIAN = Math.PI / 180; + + var clipPath = new graphic.Sector({ + shape: { + cx: polar.cx, + cy: polar.cy, + r0: radiusExtent[0], + r: radiusExtent[1], + startAngle: -angleExtent[0] * RADIAN, + endAngle: -angleExtent[1] * RADIAN, + clockwise: angleAxis.inverse + } + }); + + if (hasAnimation) { + clipPath.shape.endAngle = -angleExtent[0] * RADIAN; + graphic.initProps(clipPath, { + shape: { + endAngle: -angleExtent[1] * RADIAN + } + }, seriesModel); + } + + return clipPath; + } + + function createClipShape(coordSys, hasAnimation, seriesModel) { + return coordSys.type === 'polar' + ? createPolarClipShape(coordSys, hasAnimation, seriesModel) + : createGridClipShape(coordSys, hasAnimation, seriesModel); + } + + module.exports = ChartView.extend({ + + type: 'line', + + init: function () { + var lineGroup = new graphic.Group(); + + var symbolDraw = new SymbolDraw(); + this.group.add(symbolDraw.group); + + this._symbolDraw = symbolDraw; + this._lineGroup = lineGroup; + }, + + render: function (seriesModel, ecModel, api) { + var coordSys = seriesModel.coordinateSystem; + var group = this.group; + var data = seriesModel.getData(); + var lineStyleModel = seriesModel.getModel('lineStyle.normal'); + var areaStyleModel = seriesModel.getModel('areaStyle.normal'); + + var points = data.mapArray(data.getItemLayout, true); + + var isCoordSysPolar = coordSys.type === 'polar'; + var prevCoordSys = this._coordSys; + + var symbolDraw = this._symbolDraw; + var polyline = this._polyline; + var polygon = this._polygon; + + var lineGroup = this._lineGroup; + + var hasAnimation = seriesModel.get('animation'); + + var isAreaChart = !areaStyleModel.isEmpty(); + var stackedOnPoints = getStackedOnPoints(coordSys, data); + + var showSymbol = seriesModel.get('showSymbol'); + + var isSymbolIgnore = showSymbol && !isCoordSysPolar && !seriesModel.get('showAllSymbol') + && this._getSymbolIgnoreFunc(data, coordSys); + + // Remove temporary symbols + var oldData = this._data; + oldData && oldData.eachItemGraphicEl(function (el, idx) { + if (el.__temp) { + group.remove(el); + oldData.setItemGraphicEl(idx, null); + } + }); + + // Remove previous created symbols if showSymbol changed to false + if (!showSymbol) { + symbolDraw.remove(); + } + + group.add(lineGroup); + + // Initialization animation or coordinate system changed + if ( + !(polyline && prevCoordSys.type === coordSys.type) + ) { + showSymbol && symbolDraw.updateData(data, isSymbolIgnore); + + polyline = this._newPolyline(points, coordSys, hasAnimation); + if (isAreaChart) { + polygon = this._newPolygon( + points, stackedOnPoints, + coordSys, hasAnimation + ); + } + lineGroup.setClipPath(createClipShape(coordSys, true, seriesModel)); + } + else { + if (isAreaChart && !polygon) { + // If areaStyle is added + polygon = this._newPolygon( + points, stackedOnPoints, + coordSys, hasAnimation + ); + } + else if (polygon && !isAreaChart) { + // If areaStyle is removed + lineGroup.remove(polygon); + polygon = this._polygon = null; + } + + // Update clipPath + lineGroup.setClipPath(createClipShape(coordSys, false, seriesModel)); + + // Always update, or it is wrong in the case turning on legend + // because points are not changed + showSymbol && symbolDraw.updateData(data, isSymbolIgnore); + + // Stop symbol animation and sync with line points + // FIXME performance? + data.eachItemGraphicEl(function (el) { + el.stopAnimation(true); + }); + + // In the case data zoom triggerred refreshing frequently + // Data may not change if line has a category axis. So it should animate nothing + if (!isPointsSame(this._stackedOnPoints, stackedOnPoints) + || !isPointsSame(this._points, points) + ) { + if (hasAnimation) { + this._updateAnimation( + data, stackedOnPoints, coordSys, api + ); + } + else { + polyline.setShape({ + points: points + }); + polygon && polygon.setShape({ + points: points, + stackedOnPoints: stackedOnPoints + }); + } + } + } + + polyline.setStyle(zrUtil.defaults( + // Use color in lineStyle first + lineStyleModel.getLineStyle(), + { + stroke: data.getVisual('color'), + lineJoin: 'bevel' + } + )); + + var smooth = seriesModel.get('smooth'); + smooth = getSmooth(seriesModel.get('smooth')); + polyline.setShape({ + smooth: smooth, + smoothMonotone: seriesModel.get('smoothMonotone') + }); + + if (polygon) { + var stackedOn = data.stackedOn; + var stackedOnSmooth = 0; + + polygon.style.opacity = 0.7; + polygon.setStyle(zrUtil.defaults( + areaStyleModel.getAreaStyle(), + { + fill: data.getVisual('color'), + lineJoin: 'bevel' + } + )); + + if (stackedOn) { + var stackedOnSeries = stackedOn.hostModel; + stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth')); + } + + polygon.setShape({ + smooth: smooth, + stackedOnSmooth: stackedOnSmooth, + smoothMonotone: seriesModel.get('smoothMonotone') + }); + } + + this._data = data; + // Save the coordinate system for transition animation when data changed + this._coordSys = coordSys; + this._stackedOnPoints = stackedOnPoints; + this._points = points; + }, + + highlight: function (seriesModel, ecModel, api, payload) { + var data = seriesModel.getData(); + var dataIndex = queryDataIndex(data, payload); + + if (dataIndex != null && dataIndex >= 0) { + var symbol = data.getItemGraphicEl(dataIndex); + if (!symbol) { + // Create a temporary symbol if it is not exists + var pt = data.getItemLayout(dataIndex); + symbol = new Symbol(data, dataIndex, api); + symbol.position = pt; + symbol.setZ( + seriesModel.get('zlevel'), + seriesModel.get('z') + ); + symbol.ignore = isNaN(pt[0]) || isNaN(pt[1]); + symbol.__temp = true; + data.setItemGraphicEl(dataIndex, symbol); + + // Stop scale animation + symbol.stopSymbolAnimation(true); + + this.group.add(symbol); + } + symbol.highlight(); + } + else { + // Highlight whole series + ChartView.prototype.highlight.call( + this, seriesModel, ecModel, api, payload + ); + } + }, + + downplay: function (seriesModel, ecModel, api, payload) { + var data = seriesModel.getData(); + var dataIndex = queryDataIndex(data, payload); + if (dataIndex != null && dataIndex >= 0) { + var symbol = data.getItemGraphicEl(dataIndex); + if (symbol) { + if (symbol.__temp) { + data.setItemGraphicEl(dataIndex, null); + this.group.remove(symbol); + } + else { + symbol.downplay(); + } + } + } + else { + // Downplay whole series + ChartView.prototype.downplay.call( + this, seriesModel, ecModel, api, payload + ); + } + }, + + /** + * @param {module:zrender/container/Group} group + * @param {Array.>} points + * @private + */ + _newPolyline: function (points) { + var polyline = this._polyline; + // Remove previous created polyline + if (polyline) { + this._lineGroup.remove(polyline); + } + + polyline = new polyHelper.Polyline({ + shape: { + points: points + }, + silent: true, + z2: 10 + }); + + this._lineGroup.add(polyline); + + this._polyline = polyline; + + return polyline; + }, + + /** + * @param {module:zrender/container/Group} group + * @param {Array.>} stackedOnPoints + * @param {Array.>} points + * @private + */ + _newPolygon: function (points, stackedOnPoints) { + var polygon = this._polygon; + // Remove previous created polygon + if (polygon) { + this._lineGroup.remove(polygon); + } + + polygon = new polyHelper.Polygon({ + shape: { + points: points, + stackedOnPoints: stackedOnPoints + }, + silent: true + }); + + this._lineGroup.add(polygon); + + this._polygon = polygon; + return polygon; + }, + /** + * @private + */ + _getSymbolIgnoreFunc: function (data, coordSys) { + var categoryAxis = coordSys.getAxesByScale('ordinal')[0]; + // `getLabelInterval` is provided by echarts/component/axis + if (categoryAxis && categoryAxis.isLabelIgnored) { + return zrUtil.bind(categoryAxis.isLabelIgnored, categoryAxis); + } + }, + + /** + * @private + */ + // FIXME Two value axis + _updateAnimation: function (data, stackedOnPoints, coordSys, api) { + var polyline = this._polyline; + var polygon = this._polygon; + var seriesModel = data.hostModel; + + var diff = lineAnimationDiff( + this._data, data, + this._stackedOnPoints, stackedOnPoints, + this._coordSys, coordSys + ); + polyline.shape.points = diff.current; + + graphic.updateProps(polyline, { + shape: { + points: diff.next + } + }, seriesModel); + + if (polygon) { + polygon.setShape({ + points: diff.current, + stackedOnPoints: diff.stackedOnCurrent + }); + graphic.updateProps(polygon, { + shape: { + points: diff.next, + stackedOnPoints: diff.stackedOnNext + } + }, seriesModel); + } + + var updatedDataInfo = []; + var diffStatus = diff.status; + + for (var i = 0; i < diffStatus.length; i++) { + var cmd = diffStatus[i].cmd; + if (cmd === '=') { + var el = data.getItemGraphicEl(diffStatus[i].idx1); + if (el) { + updatedDataInfo.push({ + el: el, + ptIdx: i // Index of points + }); + } + } + } + + if (polyline.animators && polyline.animators.length) { + polyline.animators[0].during(function () { + for (var i = 0; i < updatedDataInfo.length; i++) { + var el = updatedDataInfo[i].el; + el.attr('position', polyline.shape.points[updatedDataInfo[i].ptIdx]); + } + }); + } + }, + + remove: function (ecModel) { + var group = this.group; + var oldData = this._data; + this._lineGroup.removeAll(); + this._symbolDraw.remove(true); + // Remove temporary created elements when highlighting + oldData && oldData.eachItemGraphicEl(function (el, idx) { + if (el.__temp) { + group.remove(el); + oldData.setItemGraphicEl(idx, null); + } + }); + + this._polyline = + this._polygon = + this._coordSys = + this._points = + this._stackedOnPoints = + this._data = null; + } + }); + + +/***/ }, +/* 98 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/chart/helper/SymbolDraw + */ + + + var graphic = __webpack_require__(42); + var Symbol = __webpack_require__(99); + + /** + * @constructor + * @alias module:echarts/chart/helper/SymbolDraw + * @param {module:zrender/graphic/Group} [symbolCtor] + */ + function SymbolDraw(symbolCtor) { + this.group = new graphic.Group(); + + this._symbolCtor = symbolCtor || Symbol; + } + + var symbolDrawProto = SymbolDraw.prototype; + + function symbolNeedsDraw(data, idx, isIgnore) { + var point = data.getItemLayout(idx); + return point && !isNaN(point[0]) && !isNaN(point[1]) && !(isIgnore && isIgnore(idx)) + && data.getItemVisual(idx, 'symbol') !== 'none'; + } + /** + * Update symbols draw by new data + * @param {module:echarts/data/List} data + * @param {Array.} [isIgnore] + */ + symbolDrawProto.updateData = function (data, isIgnore) { + var group = this.group; + var seriesModel = data.hostModel; + var oldData = this._data; + + var SymbolCtor = this._symbolCtor; + + data.diff(oldData) + .add(function (newIdx) { + var point = data.getItemLayout(newIdx); + if (symbolNeedsDraw(data, newIdx, isIgnore)) { + var symbolEl = new SymbolCtor(data, newIdx); + symbolEl.attr('position', point); + data.setItemGraphicEl(newIdx, symbolEl); + group.add(symbolEl); + } + }) + .update(function (newIdx, oldIdx) { + var symbolEl = oldData.getItemGraphicEl(oldIdx); + var point = data.getItemLayout(newIdx); + if (!symbolNeedsDraw(data, newIdx, isIgnore)) { + group.remove(symbolEl); + return; + } + if (!symbolEl) { + symbolEl = new SymbolCtor(data, newIdx); + symbolEl.attr('position', point); + } + else { + symbolEl.updateData(data, newIdx); + graphic.updateProps(symbolEl, { + position: point + }, seriesModel); + } + + // Add back + group.add(symbolEl); + + data.setItemGraphicEl(newIdx, symbolEl); + }) + .remove(function (oldIdx) { + var el = oldData.getItemGraphicEl(oldIdx); + el && el.fadeOut(function () { + group.remove(el); + }); + }) + .execute(); + + this._data = data; + }; + + symbolDrawProto.updateLayout = function () { + var data = this._data; + if (data) { + // Not use animation + data.eachItemGraphicEl(function (el, idx) { + el.attr('position', data.getItemLayout(idx)); + }); + } + }; + + symbolDrawProto.remove = function (enableAnimation) { + var group = this.group; + var data = this._data; + if (data) { + if (enableAnimation) { + data.eachItemGraphicEl(function (el) { + el.fadeOut(function () { + group.remove(el); + }); + }); + } + else { + group.removeAll(); + } + } + }; + + module.exports = SymbolDraw; + + +/***/ }, +/* 99 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @module echarts/chart/helper/Symbol + */ + + + var zrUtil = __webpack_require__(3); + var symbolUtil = __webpack_require__(100); + var graphic = __webpack_require__(42); + var numberUtil = __webpack_require__(7); + + function normalizeSymbolSize(symbolSize) { + if (!zrUtil.isArray(symbolSize)) { + symbolSize = [+symbolSize, +symbolSize]; + } + return symbolSize; + } + + /** + * @constructor + * @alias {module:echarts/chart/helper/Symbol} + * @param {module:echarts/data/List} data + * @param {number} idx + * @extends {module:zrender/graphic/Group} + */ + function Symbol(data, idx) { + graphic.Group.call(this); + + this.updateData(data, idx); + } + + var symbolProto = Symbol.prototype; + + function driftSymbol(dx, dy) { + this.parent.drift(dx, dy); + } + + symbolProto._createSymbol = function (symbolType, data, idx) { + // Remove paths created before + this.removeAll(); + + var seriesModel = data.hostModel; + var color = data.getItemVisual(idx, 'color'); + + var symbolPath = symbolUtil.createSymbol( + symbolType, -0.5, -0.5, 1, 1, color + ); + + symbolPath.attr({ + style: { + strokeNoScale: true + }, + z2: 100, + culling: true, + scale: [0, 0] + }); + // Rewrite drift method + symbolPath.drift = driftSymbol; + + var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); + + graphic.initProps(symbolPath, { + scale: size + }, seriesModel); + + this._symbolType = symbolType; + + this.add(symbolPath); + }; + + /** + * Stop animation + * @param {boolean} toLastFrame + */ + symbolProto.stopSymbolAnimation = function (toLastFrame) { + this.childAt(0).stopAnimation(toLastFrame); + }; + + /** + * Get scale(aka, current symbol size). + * Including the change caused by animation + * @param {Array.} toLastFrame + */ + symbolProto.getScale = function () { + return this.childAt(0).scale; + }; + + /** + * Highlight symbol + */ + symbolProto.highlight = function () { + this.childAt(0).trigger('emphasis'); + }; + + /** + * Downplay symbol + */ + symbolProto.downplay = function () { + this.childAt(0).trigger('normal'); + }; + + /** + * @param {number} zlevel + * @param {number} z + */ + symbolProto.setZ = function (zlevel, z) { + var symbolPath = this.childAt(0); + symbolPath.zlevel = zlevel; + symbolPath.z = z; + }; + + symbolProto.setDraggable = function (draggable) { + var symbolPath = this.childAt(0); + symbolPath.draggable = draggable; + symbolPath.cursor = draggable ? 'move' : 'pointer'; + }; + /** + * Update symbol properties + * @param {module:echarts/data/List} data + * @param {number} idx + */ + symbolProto.updateData = function (data, idx) { + var symbolType = data.getItemVisual(idx, 'symbol') || 'circle'; + var seriesModel = data.hostModel; + var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); + if (symbolType !== this._symbolType) { + this._createSymbol(symbolType, data, idx); + } + else { + var symbolPath = this.childAt(0); + graphic.updateProps(symbolPath, { + scale: symbolSize + }, seriesModel); + } + this._updateCommon(data, idx, symbolSize); + + this._seriesModel = seriesModel; + }; + + // Update common properties + var normalStyleAccessPath = ['itemStyle', 'normal']; + var emphasisStyleAccessPath = ['itemStyle', 'emphasis']; + var normalLabelAccessPath = ['label', 'normal']; + var emphasisLabelAccessPath = ['label', 'emphasis']; + + symbolProto._updateCommon = function (data, idx, symbolSize) { + var symbolPath = this.childAt(0); + var seriesModel = data.hostModel; + var itemModel = data.getItemModel(idx); + var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath); + var color = data.getItemVisual(idx, 'color'); + + var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle(); + + symbolPath.rotation = itemModel.getShallow('symbolRotate') * Math.PI / 180 || 0; + + var symbolOffset = itemModel.getShallow('symbolOffset'); + if (symbolOffset) { + var pos = symbolPath.position; + pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]); + pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]); + } + + symbolPath.setColor(color); + + zrUtil.extend( + symbolPath.style, + // Color must be excluded. + // Because symbol provide setColor individually to set fill and stroke + normalItemStyleModel.getItemStyle(['color']) + ); + + var labelModel = itemModel.getModel(normalLabelAccessPath); + var hoverLabelModel = itemModel.getModel(emphasisLabelAccessPath); + + var elStyle = symbolPath.style; + + // Get last value dim + var dimensions = data.dimensions.slice(); + var valueDim = dimensions.pop(); + var dataType; + while ( + ((dataType = data.getDimensionInfo(valueDim).type) === 'ordinal') + || (dataType === 'time') + ) { + valueDim = dimensions.pop(); + } + + if (labelModel.get('show')) { + graphic.setText(elStyle, labelModel, color); + elStyle.text = zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'normal'), + data.get(valueDim, idx) + ); + } + else { + elStyle.text = ''; + } + + if (hoverLabelModel.getShallow('show')) { + graphic.setText(hoverStyle, hoverLabelModel, color); + hoverStyle.text = zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'emphasis'), + data.get(valueDim, idx) + ); + } + else { + hoverStyle.text = ''; + } + + var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); + + symbolPath.off('mouseover') + .off('mouseout') + .off('emphasis') + .off('normal'); + + graphic.setHoverStyle(symbolPath, hoverStyle); + + if (itemModel.getShallow('hoverAnimation')) { + var onEmphasis = function() { + var ratio = size[1] / size[0]; + this.animateTo({ + scale: [ + Math.max(size[0] * 1.1, size[0] + 3), + Math.max(size[1] * 1.1, size[1] + 3 * ratio) + ] + }, 400, 'elasticOut'); + }; + var onNormal = function() { + this.animateTo({ + scale: size + }, 400, 'elasticOut'); + }; + symbolPath.on('mouseover', onEmphasis) + .on('mouseout', onNormal) + .on('emphasis', onEmphasis) + .on('normal', onNormal); + } + }; + + symbolProto.fadeOut = function (cb) { + var symbolPath = this.childAt(0); + // Not show text when animating + symbolPath.style.text = ''; + graphic.updateProps(symbolPath, { + scale: [0, 0] + }, this._seriesModel, cb); + }; + + zrUtil.inherits(Symbol, graphic.Group); + + module.exports = Symbol; + + +/***/ }, +/* 100 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // Symbol factory + + + var graphic = __webpack_require__(42); + var BoundingRect = __webpack_require__(15); + + /** + * Triangle shape + * @inner + */ + var Triangle = graphic.extendShape({ + type: 'triangle', + shape: { + cx: 0, + cy: 0, + width: 0, + height: 0 + }, + buildPath: function (path, shape) { + var cx = shape.cx; + var cy = shape.cy; + var width = shape.width / 2; + var height = shape.height / 2; + path.moveTo(cx, cy - height); + path.lineTo(cx + width, cy + height); + path.lineTo(cx - width, cy + height); + path.closePath(); + } + }); + /** + * Diamond shape + * @inner + */ + var Diamond = graphic.extendShape({ + type: 'diamond', + shape: { + cx: 0, + cy: 0, + width: 0, + height: 0 + }, + buildPath: function (path, shape) { + var cx = shape.cx; + var cy = shape.cy; + var width = shape.width / 2; + var height = shape.height / 2; + path.moveTo(cx, cy - height); + path.lineTo(cx + width, cy); + path.lineTo(cx, cy + height); + path.lineTo(cx - width, cy); + path.closePath(); + } + }); + + /** + * Pin shape + * @inner + */ + var Pin = graphic.extendShape({ + type: 'pin', + shape: { + // x, y on the cusp + x: 0, + y: 0, + width: 0, + height: 0 + }, + + buildPath: function (path, shape) { + var x = shape.x; + var y = shape.y; + var w = shape.width / 5 * 3; + // Height must be larger than width + var h = Math.max(w, shape.height); + var r = w / 2; + + // Dist on y with tangent point and circle center + var dy = r * r / (h - r); + var cy = y - h + r + dy; + var angle = Math.asin(dy / r); + // Dist on x with tangent point and circle center + var dx = Math.cos(angle) * r; + + var tanX = Math.sin(angle); + var tanY = Math.cos(angle); + + path.arc( + x, cy, r, + Math.PI - angle, + Math.PI * 2 + angle + ); + + var cpLen = r * 0.6; + var cpLen2 = r * 0.7; + path.bezierCurveTo( + x + dx - tanX * cpLen, cy + dy + tanY * cpLen, + x, y - cpLen2, + x, y + ); + path.bezierCurveTo( + x, y - cpLen2, + x - dx + tanX * cpLen, cy + dy + tanY * cpLen, + x - dx, cy + dy + ); + path.closePath(); + } + }); + + /** + * Arrow shape + * @inner + */ + var Arrow = graphic.extendShape({ + + type: 'arrow', + + shape: { + x: 0, + y: 0, + width: 0, + height: 0 + }, + + buildPath: function (ctx, shape) { + var height = shape.height; + var width = shape.width; + var x = shape.x; + var y = shape.y; + var dx = width / 3 * 2; + ctx.moveTo(x, y); + ctx.lineTo(x + dx, y + height); + ctx.lineTo(x, y + height / 4 * 3); + ctx.lineTo(x - dx, y + height); + ctx.lineTo(x, y); + ctx.closePath(); + } + }); + + /** + * Map of path contructors + * @type {Object.} + */ + var symbolCtors = { + line: graphic.Line, + + rect: graphic.Rect, + + roundRect: graphic.Rect, + + square: graphic.Rect, + + circle: graphic.Circle, + + diamond: Diamond, + + pin: Pin, + + arrow: Arrow, + + triangle: Triangle + }; + + var symbolShapeMakers = { + + line: function (x, y, w, h, shape) { + // FIXME + shape.x1 = x; + shape.y1 = y + h / 2; + shape.x2 = x + w; + shape.y2 = y + h / 2; + }, + + rect: function (x, y, w, h, shape) { + shape.x = x; + shape.y = y; + shape.width = w; + shape.height = h; + }, + + roundRect: function (x, y, w, h, shape) { + shape.x = x; + shape.y = y; + shape.width = w; + shape.height = h; + shape.r = Math.min(w, h) / 4; + }, + + square: function (x, y, w, h, shape) { + var size = Math.min(w, h); + shape.x = x; + shape.y = y; + shape.width = size; + shape.height = size; + }, + + circle: function (x, y, w, h, shape) { + // Put circle in the center of square + shape.cx = x + w / 2; + shape.cy = y + h / 2; + shape.r = Math.min(w, h) / 2; + }, + + diamond: function (x, y, w, h, shape) { + shape.cx = x + w / 2; + shape.cy = y + h / 2; + shape.width = w; + shape.height = h; + }, + + pin: function (x, y, w, h, shape) { + shape.x = x + w / 2; + shape.y = y + h / 2; + shape.width = w; + shape.height = h; + }, + + arrow: function (x, y, w, h, shape) { + shape.x = x + w / 2; + shape.y = y + h / 2; + shape.width = w; + shape.height = h; + }, + + triangle: function (x, y, w, h, shape) { + shape.cx = x + w / 2; + shape.cy = y + h / 2; + shape.width = w; + shape.height = h; + } + }; + + var symbolBuildProxies = {}; + for (var name in symbolCtors) { + symbolBuildProxies[name] = new symbolCtors[name](); + } + + var Symbol = graphic.extendShape({ + + type: 'symbol', + + shape: { + symbolType: '', + x: 0, + y: 0, + width: 0, + height: 0 + }, + + beforeBrush: function () { + var style = this.style; + var shape = this.shape; + // FIXME + if (shape.symbolType === 'pin' && style.textPosition === 'inside') { + style.textPosition = ['50%', '40%']; + style.textAlign = 'center'; + style.textVerticalAlign = 'middle'; + } + }, + + buildPath: function (ctx, shape) { + var symbolType = shape.symbolType; + var proxySymbol = symbolBuildProxies[symbolType]; + if (shape.symbolType !== 'none') { + if (!proxySymbol) { + // Default rect + symbolType = 'rect'; + proxySymbol = symbolBuildProxies[symbolType]; + } + symbolShapeMakers[symbolType]( + shape.x, shape.y, shape.width, shape.height, proxySymbol.shape + ); + proxySymbol.buildPath(ctx, proxySymbol.shape); + } + } + }); + + // Provide setColor helper method to avoid determine if set the fill or stroke outside + var symbolPathSetColor = function (color) { + if (this.type !== 'image') { + var symbolStyle = this.style; + var symbolShape = this.shape; + if (symbolShape && symbolShape.symbolType === 'line') { + symbolStyle.stroke = color; + } + else if (this.__isEmptyBrush) { + symbolStyle.stroke = color; + symbolStyle.fill = '#fff'; + } + else { + // FIXME 判断图形默认是填充还是描边,使用 onlyStroke ? + symbolStyle.fill && (symbolStyle.fill = color); + symbolStyle.stroke && (symbolStyle.stroke = color); + } + this.dirty(); + } + }; + + var symbolUtil = { + /** + * Create a symbol element with given symbol configuration: shape, x, y, width, height, color + * @param {string} symbolType + * @param {number} x + * @param {number} y + * @param {number} w + * @param {number} h + * @param {string} color + */ + createSymbol: function (symbolType, x, y, w, h, color) { + var isEmpty = symbolType.indexOf('empty') === 0; + if (isEmpty) { + symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6); + } + var symbolPath; + + if (symbolType.indexOf('image://') === 0) { + symbolPath = new graphic.Image({ + style: { + image: symbolType.slice(8), + x: x, + y: y, + width: w, + height: h + } + }); + } + else if (symbolType.indexOf('path://') === 0) { + symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h)); + } + else { + symbolPath = new Symbol({ + shape: { + symbolType: symbolType, + x: x, + y: y, + width: w, + height: h + } + }); + } + + symbolPath.__isEmptyBrush = isEmpty; + + symbolPath.setColor = symbolPathSetColor; + + symbolPath.setColor(color); + + return symbolPath; + } + }; + + module.exports = symbolUtil; + + +/***/ }, +/* 101 */ +/***/ function(module, exports) { + + + + // var arrayDiff = require('zrender/lib/core/arrayDiff'); + // 'zrender/core/arrayDiff' has been used before, but it did + // not do well in performance when roam with fixed dataZoom window. + + function sign(val) { + return val >= 0 ? 1 : -1; + } + + function getStackedOnPoint(coordSys, data, idx) { + var baseAxis = coordSys.getBaseAxis(); + var valueAxis = coordSys.getOtherAxis(baseAxis); + var valueStart = baseAxis.onZero + ? 0 : valueAxis.scale.getExtent()[0]; + + var valueDim = valueAxis.dim; + var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0; + + var stackedOnSameSign; + var stackedOn = data.stackedOn; + var val = data.get(valueDim, idx); + // Find first stacked value with same sign + while (stackedOn && + sign(stackedOn.get(valueDim, idx)) === sign(val) + ) { + stackedOnSameSign = stackedOn; + break; + } + var stackedData = []; + stackedData[baseDataOffset] = data.get(baseAxis.dim, idx); + stackedData[1 - baseDataOffset] = stackedOnSameSign + ? stackedOnSameSign.get(valueDim, idx, true) : valueStart; + + return coordSys.dataToPoint(stackedData); + } + + // function convertToIntId(newIdList, oldIdList) { + // // Generate int id instead of string id. + // // Compare string maybe slow in score function of arrDiff + + // // Assume id in idList are all unique + // var idIndicesMap = {}; + // var idx = 0; + // for (var i = 0; i < newIdList.length; i++) { + // idIndicesMap[newIdList[i]] = idx; + // newIdList[i] = idx++; + // } + // for (var i = 0; i < oldIdList.length; i++) { + // var oldId = oldIdList[i]; + // // Same with newIdList + // if (idIndicesMap[oldId]) { + // oldIdList[i] = idIndicesMap[oldId]; + // } + // else { + // oldIdList[i] = idx++; + // } + // } + // } + + function diffData(oldData, newData) { + var diffResult = []; + + newData.diff(oldData) + .add(function (idx) { + diffResult.push({cmd: '+', idx: idx}); + }) + .update(function (newIdx, oldIdx) { + diffResult.push({cmd: '=', idx: oldIdx, idx1: newIdx}); + }) + .remove(function (idx) { + diffResult.push({cmd: '-', idx: idx}); + }) + .execute(); + + return diffResult; + } + + module.exports = function ( + oldData, newData, + oldStackedOnPoints, newStackedOnPoints, + oldCoordSys, newCoordSys + ) { + var diff = diffData(oldData, newData); + + // var newIdList = newData.mapArray(newData.getId); + // var oldIdList = oldData.mapArray(oldData.getId); + + // convertToIntId(newIdList, oldIdList); + + // // FIXME One data ? + // diff = arrayDiff(oldIdList, newIdList); + + var currPoints = []; + var nextPoints = []; + // Points for stacking base line + var currStackedPoints = []; + var nextStackedPoints = []; + + var status = []; + var sortedIndices = []; + var rawIndices = []; + var dims = newCoordSys.dimensions; + for (var i = 0; i < diff.length; i++) { + var diffItem = diff[i]; + var pointAdded = true; + + // FIXME, animation is not so perfect when dataZoom window moves fast + // Which is in case remvoing or add more than one data in the tail or head + switch (diffItem.cmd) { + case '=': + var currentPt = oldData.getItemLayout(diffItem.idx); + var nextPt = newData.getItemLayout(diffItem.idx1); + // If previous data is NaN, use next point directly + if (isNaN(currentPt[0]) || isNaN(currentPt[1])) { + currentPt = nextPt.slice(); + } + currPoints.push(currentPt); + nextPoints.push(nextPt); + + currStackedPoints.push(oldStackedOnPoints[diffItem.idx]); + nextStackedPoints.push(newStackedOnPoints[diffItem.idx1]); + + rawIndices.push(newData.getRawIndex(diffItem.idx1)); + break; + case '+': + var idx = diffItem.idx; + currPoints.push( + oldCoordSys.dataToPoint([ + newData.get(dims[0], idx, true), newData.get(dims[1], idx, true) + ]) + ); + + nextPoints.push(newData.getItemLayout(idx).slice()); + + currStackedPoints.push( + getStackedOnPoint(oldCoordSys, newData, idx) + ); + nextStackedPoints.push(newStackedOnPoints[idx]); + + rawIndices.push(newData.getRawIndex(idx)); + break; + case '-': + var idx = diffItem.idx; + var rawIndex = oldData.getRawIndex(idx); + // Data is replaced. In the case of dynamic data queue + // FIXME FIXME FIXME + if (rawIndex !== idx) { + currPoints.push(oldData.getItemLayout(idx)); + nextPoints.push(newCoordSys.dataToPoint([ + oldData.get(dims[0], idx, true), oldData.get(dims[1], idx, true) + ])); + + currStackedPoints.push(oldStackedOnPoints[idx]); + nextStackedPoints.push( + getStackedOnPoint( + newCoordSys, oldData, idx + ) + ); + + rawIndices.push(rawIndex); + } + else { + pointAdded = false; + } + } + + // Original indices + if (pointAdded) { + status.push(diffItem); + sortedIndices.push(sortedIndices.length); + } + } + + // Diff result may be crossed if all items are changed + // Sort by data index + sortedIndices.sort(function (a, b) { + return rawIndices[a] - rawIndices[b]; + }); + + var sortedCurrPoints = []; + var sortedNextPoints = []; + + var sortedCurrStackedPoints = []; + var sortedNextStackedPoints = []; + + var sortedStatus = []; + for (var i = 0; i < sortedIndices.length; i++) { + var idx = sortedIndices[i]; + sortedCurrPoints[i] = currPoints[idx]; + sortedNextPoints[i] = nextPoints[idx]; + + sortedCurrStackedPoints[i] = currStackedPoints[idx]; + sortedNextStackedPoints[i] = nextStackedPoints[idx]; + + sortedStatus[i] = status[idx]; + } + + return { + current: sortedCurrPoints, + next: sortedNextPoints, + + stackedOnCurrent: sortedCurrStackedPoints, + stackedOnNext: sortedNextStackedPoints, + + status: sortedStatus + }; + }; + + +/***/ }, +/* 102 */ +/***/ function(module, exports, __webpack_require__) { + + // Poly path support NaN point + + + var Path = __webpack_require__(44); + var vec2 = __webpack_require__(16); + + var vec2Min = vec2.min; + var vec2Max = vec2.max; + + var scaleAndAdd = vec2.scaleAndAdd; + var v2Copy = vec2.copy; + + // Temporary variable + var v = []; + var cp0 = []; + var cp1 = []; + + function drawSegment( + ctx, points, start, stop, len, + dir, smoothMin, smoothMax, smooth, smoothMonotone + ) { + var idx = start; + for (var k = 0; k < len; k++) { + var p = points[idx]; + if (idx >= stop || idx < 0 || isNaN(p[0]) || isNaN(p[1])) { + break; + } + + if (idx === start) { + ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]); + v2Copy(cp0, p); + } + else { + if (smooth > 0) { + var prevIdx = idx - dir; + var nextIdx = idx + dir; + + var ratioNextSeg = 0.5; + var prevP = points[prevIdx]; + var nextP = points[nextIdx]; + // Last point + if ((dir > 0 && (idx === len - 1 || isNaN(nextP[0]) || isNaN(nextP[1]))) + || (dir <= 0 && (idx === 0 || isNaN(nextP[0]) || isNaN(nextP[1]))) + ) { + v2Copy(cp1, p); + } + else { + // If next data is null + if (isNaN(nextP[0]) || isNaN(nextP[1])) { + nextP = p; + } + + vec2.sub(v, nextP, prevP); + + var lenPrevSeg; + var lenNextSeg; + if (smoothMonotone === 'x' || smoothMonotone === 'y') { + var dim = smoothMonotone === 'x' ? 0 : 1; + lenPrevSeg = Math.abs(p[dim] - prevP[dim]); + lenNextSeg = Math.abs(p[dim] - nextP[dim]); + } + else { + lenPrevSeg = vec2.dist(p, prevP); + lenNextSeg = vec2.dist(p, nextP); + } + + // Use ratio of seg length + ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg); + + scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg)); + } + // Smooth constraint + vec2Min(cp0, cp0, smoothMax); + vec2Max(cp0, cp0, smoothMin); + vec2Min(cp1, cp1, smoothMax); + vec2Max(cp1, cp1, smoothMin); + + ctx.bezierCurveTo( + cp0[0], cp0[1], + cp1[0], cp1[1], + p[0], p[1] + ); + // cp0 of next segment + scaleAndAdd(cp0, p, v, smooth * ratioNextSeg); + } + else { + ctx.lineTo(p[0], p[1]); + } + } + + idx += dir; + } + + return k; + } + + function getBoundingBox(points, smoothConstraint) { + var ptMin = [Infinity, Infinity]; + var ptMax = [-Infinity, -Infinity]; + if (smoothConstraint) { + for (var i = 0; i < points.length; i++) { + var pt = points[i]; + if (pt[0] < ptMin[0]) { ptMin[0] = pt[0]; } + if (pt[1] < ptMin[1]) { ptMin[1] = pt[1]; } + if (pt[0] > ptMax[0]) { ptMax[0] = pt[0]; } + if (pt[1] > ptMax[1]) { ptMax[1] = pt[1]; } + } + } + return { + min: smoothConstraint ? ptMin : ptMax, + max: smoothConstraint ? ptMax : ptMin + }; + } + + module.exports = { + + Polyline: Path.extend({ + + type: 'ec-polyline', + + shape: { + points: [], + + smooth: 0, + + smoothConstraint: true, + + smoothMonotone: null + }, + + style: { + fill: null, + + stroke: '#000' + }, + + buildPath: function (ctx, shape) { + var points = shape.points; + + var i = 0; + var len = points.length; + + var result = getBoundingBox(points, shape.smoothConstraint); + + while (i < len) { + i += drawSegment( + ctx, points, i, len, len, + 1, result.min, result.max, shape.smooth, + shape.smoothMonotone + ) + 1; + } + } + }), + + Polygon: Path.extend({ + + type: 'ec-polygon', + + shape: { + points: [], + + // Offset between stacked base points and points + stackedOnPoints: [], + + smooth: 0, + + stackedOnSmooth: 0, + + smoothConstraint: true, + + smoothMonotone: null + }, + + buildPath: function (ctx, shape) { + var points = shape.points; + var stackedOnPoints = shape.stackedOnPoints; + + var i = 0; + var len = points.length; + var smoothMonotone = shape.smoothMonotone; + var bbox = getBoundingBox(points, shape.smoothConstraint); + var stackedOnBBox = getBoundingBox(stackedOnPoints, shape.smoothConstraint); + while (i < len) { + var k = drawSegment( + ctx, points, i, len, len, + 1, bbox.min, bbox.max, shape.smooth, + smoothMonotone + ); + drawSegment( + ctx, stackedOnPoints, i + k - 1, len, k, + -1, stackedOnBBox.min, stackedOnBBox.max, shape.stackedOnSmooth, + smoothMonotone + ); + i += k + 1; + + ctx.closePath(); + } + } + }) + }; + + +/***/ }, +/* 103 */ +/***/ function(module, exports) { + + + + module.exports = function (seriesType, defaultSymbolType, legendSymbol, ecModel, api) { + + // Encoding visual for all series include which is filtered for legend drawing + ecModel.eachRawSeriesByType(seriesType, function (seriesModel) { + var data = seriesModel.getData(); + + var symbolType = seriesModel.get('symbol') || defaultSymbolType; + var symbolSize = seriesModel.get('symbolSize'); + + data.setVisual({ + legendSymbol: legendSymbol || symbolType, + symbol: symbolType, + symbolSize: symbolSize + }); + + // Only visible series has each data be visual encoded + if (!ecModel.isSeriesFiltered(seriesModel)) { + if (typeof symbolSize === 'function') { + data.each(function (idx) { + var rawValue = seriesModel.getRawValue(idx); + // FIXME + var params = seriesModel.getDataParams(idx); + data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params)); + }); + } + data.each(function (idx) { + var itemModel = data.getItemModel(idx); + var itemSymbolType = itemModel.get('symbol', true); + var itemSymbolSize = itemModel.get('symbolSize', true); + // If has item symbol + if (itemSymbolType != null) { + data.setItemVisual(idx, 'symbol', itemSymbolType); + } + if (itemSymbolSize != null) { + // PENDING Transform symbolSize ? + data.setItemVisual(idx, 'symbolSize', itemSymbolSize); + } + }); + } + }); + }; + + +/***/ }, +/* 104 */ +/***/ function(module, exports) { + + + + module.exports = function (seriesType, ecModel, api) { + ecModel.eachSeriesByType(seriesType, function (seriesModel) { + var data = seriesModel.getData(); + var coordSys = seriesModel.coordinateSystem; + + var dims = coordSys.dimensions; + data.each(dims, function (x, y, idx) { + var point; + if (!isNaN(x) && !isNaN(y)) { + point = coordSys.dataToPoint([x, y]); + } + else { + // Also {Array.}, not undefined to avoid if...else... statement + point = [NaN, NaN]; + } + + data.setItemLayout(idx, point); + }, true); + }); + }; + + +/***/ }, +/* 105 */ +/***/ function(module, exports) { + + + var samplers = { + average: function (frame) { + var sum = 0; + var count = 0; + for (var i = 0; i < frame.length; i++) { + if (!isNaN(frame[i])) { + sum += frame[i]; + count++; + } + } + // Return NaN if count is 0 + return count === 0 ? NaN : sum / count; + }, + sum: function (frame) { + var sum = 0; + for (var i = 0; i < frame.length; i++) { + // Ignore NaN + sum += frame[i] || 0; + } + return sum; + }, + max: function (frame) { + var max = -Infinity; + for (var i = 0; i < frame.length; i++) { + frame[i] > max && (max = frame[i]); + } + return max; + }, + min: function (frame) { + var min = Infinity; + for (var i = 0; i < frame.length; i++) { + frame[i] < min && (min = frame[i]); + } + return min; + } + }; + + var indexSampler = function (frame, value) { + return Math.round(frame.length / 2); + }; + module.exports = function (seriesType, ecModel, api) { + ecModel.eachSeriesByType(seriesType, function (seriesModel) { + var data = seriesModel.getData(); + var sampling = seriesModel.get('sampling'); + var coordSys = seriesModel.coordinateSystem; + // Only cartesian2d support down sampling + if (coordSys.type === 'cartesian2d' && sampling) { + var baseAxis = coordSys.getBaseAxis(); + var valueAxis = coordSys.getOtherAxis(baseAxis); + var extent = baseAxis.getExtent(); + // Coordinste system has been resized + var size = extent[1] - extent[0]; + var rate = Math.round(data.count() / size); + if (rate > 1) { + var sampler; + if (typeof sampling === 'string') { + sampler = samplers[sampling]; + } + else if (typeof sampling === 'function') { + sampler = sampling; + } + if (sampler) { + data = data.downSample( + valueAxis.dim, 1 / rate, sampler, indexSampler + ); + seriesModel.setData(data); + } + } + } + }, this); + }; + + +/***/ }, +/* 106 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + + __webpack_require__(107); + + __webpack_require__(124); + + // Grid view + __webpack_require__(1).extendComponentView({ + + type: 'grid', + + render: function (gridModel, ecModel) { + this.group.removeAll(); + if (gridModel.get('show')) { + this.group.add(new graphic.Rect({ + shape:gridModel.coordinateSystem.getRect(), + style: zrUtil.defaults({ + fill: gridModel.get('backgroundColor') + }, gridModel.getItemStyle()), + silent: true + })); + } + } + }); + + +/***/ }, +/* 107 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Grid is a region which contains at most 4 cartesian systems + * + * TODO Default cartesian + */ + var factory = exports; + + var layout = __webpack_require__(21); + var axisHelper = __webpack_require__(108); + + var zrUtil = __webpack_require__(3); + var Cartesian2D = __webpack_require__(114); + var Axis2D = __webpack_require__(116); + + var each = zrUtil.each; + + var ifAxisCrossZero = axisHelper.ifAxisCrossZero; + var niceScaleExtent = axisHelper.niceScaleExtent; + + // 依赖 GridModel, AxisModel 做预处理 + __webpack_require__(119); + + /** + * Check if the axis is used in the specified grid + * @inner + */ + function isAxisUsedInTheGrid(axisModel, gridModel, ecModel) { + return ecModel.getComponent('grid', axisModel.get('gridIndex')) === gridModel; + } + + function getLabelUnionRect(axis) { + var axisModel = axis.model; + var labels = axisModel.getFormattedLabels(); + var rect; + var step = 1; + var labelCount = labels.length; + if (labelCount > 40) { + // Simple optimization for large amount of labels + step = Math.ceil(labelCount / 40); + } + for (var i = 0; i < labelCount; i += step) { + if (!axis.isLabelIgnored(i)) { + var singleRect = axisModel.getTextRect(labels[i]); + // FIXME consider label rotate + rect ? rect.union(singleRect) : (rect = singleRect); + } + } + return rect; + } + + function Grid(gridModel, ecModel, api) { + /** + * @type {Object.} + * @private + */ + this._coordsMap = {}; + + /** + * @type {Array.} + * @private + */ + this._coordsList = []; + + /** + * @type {Object.} + * @private + */ + this._axesMap = {}; + + /** + * @type {Array.} + * @private + */ + this._axesList = []; + + this._initCartesian(gridModel, ecModel, api); + + this._model = gridModel; + } + + var gridProto = Grid.prototype; + + gridProto.type = 'grid'; + + gridProto.getRect = function () { + return this._rect; + }; + + gridProto.update = function (ecModel, api) { + + var axesMap = this._axesMap; + + this._updateScale(ecModel, this._model); + + function ifAxisCanNotOnZero(otherAxisDim) { + var axes = axesMap[otherAxisDim]; + for (var idx in axes) { + var axis = axes[idx]; + if (axis && (axis.type === 'category' || !ifAxisCrossZero(axis))) { + return true; + } + } + return false; + } + + each(axesMap.x, function (xAxis) { + niceScaleExtent(xAxis, xAxis.model); + }); + each(axesMap.y, function (yAxis) { + niceScaleExtent(yAxis, yAxis.model); + }); + // Fix configuration + each(axesMap.x, function (xAxis) { + // onZero can not be enabled in these two situations + // 1. When any other axis is a category axis + // 2. When any other axis not across 0 point + if (ifAxisCanNotOnZero('y')) { + xAxis.onZero = false; + } + }); + each(axesMap.y, function (yAxis) { + if (ifAxisCanNotOnZero('x')) { + yAxis.onZero = false; + } + }); + + // Resize again if containLabel is enabled + // FIXME It may cause getting wrong grid size in data processing stage + this.resize(this._model, api); + }; + + /** + * Resize the grid + * @param {module:echarts/coord/cartesian/GridModel} gridModel + * @param {module:echarts/ExtensionAPI} api + */ + gridProto.resize = function (gridModel, api) { + + var gridRect = layout.getLayoutRect( + gridModel.getBoxLayoutParams(), { + width: api.getWidth(), + height: api.getHeight() + }); + + this._rect = gridRect; + + var axesList = this._axesList; + + adjustAxes(); + + // Minus label size + if (gridModel.get('containLabel')) { + each(axesList, function (axis) { + if (!axis.model.get('axisLabel.inside')) { + var labelUnionRect = getLabelUnionRect(axis); + if (labelUnionRect) { + var dim = axis.isHorizontal() ? 'height' : 'width'; + var margin = axis.model.get('axisLabel.margin'); + gridRect[dim] -= labelUnionRect[dim] + margin; + if (axis.position === 'top') { + gridRect.y += labelUnionRect.height + margin; + } + else if (axis.position === 'left') { + gridRect.x += labelUnionRect.width + margin; + } + } + } + }); + + adjustAxes(); + } + + function adjustAxes() { + each(axesList, function (axis) { + var isHorizontal = axis.isHorizontal(); + var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height]; + var idx = axis.inverse ? 1 : 0; + axis.setExtent(extent[idx], extent[1 - idx]); + updateAxisTransfrom(axis, isHorizontal ? gridRect.x : gridRect.y); + }); + } + }; + + /** + * @param {string} axisType + * @param {ndumber} [axisIndex] + */ + gridProto.getAxis = function (axisType, axisIndex) { + var axesMapOnDim = this._axesMap[axisType]; + if (axesMapOnDim != null) { + if (axisIndex == null) { + // Find first axis + for (var name in axesMapOnDim) { + return axesMapOnDim[name]; + } + } + return axesMapOnDim[axisIndex]; + } + }; + + gridProto.getCartesian = function (xAxisIndex, yAxisIndex) { + var key = 'x' + xAxisIndex + 'y' + yAxisIndex; + return this._coordsMap[key]; + }; + + /** + * Initialize cartesian coordinate systems + * @private + */ + gridProto._initCartesian = function (gridModel, ecModel, api) { + var axisPositionUsed = { + left: false, + right: false, + top: false, + bottom: false + }; + + var axesMap = { + x: {}, + y: {} + }; + var axesCount = { + x: 0, + y: 0 + }; + + /// Create axis + ecModel.eachComponent('xAxis', createAxisCreator('x'), this); + ecModel.eachComponent('yAxis', createAxisCreator('y'), this); + + if (!axesCount.x || !axesCount.y) { + // Roll back when there no either x or y axis + this._axesMap = {}; + this._axesList = []; + return; + } + + this._axesMap = axesMap; + + /// Create cartesian2d + each(axesMap.x, function (xAxis, xAxisIndex) { + each(axesMap.y, function (yAxis, yAxisIndex) { + var key = 'x' + xAxisIndex + 'y' + yAxisIndex; + var cartesian = new Cartesian2D(key); + + cartesian.grid = this; + + this._coordsMap[key] = cartesian; + this._coordsList.push(cartesian); + + cartesian.addAxis(xAxis); + cartesian.addAxis(yAxis); + }, this); + }, this); + + function createAxisCreator(axisType) { + return function (axisModel, idx) { + if (!isAxisUsedInTheGrid(axisModel, gridModel, ecModel)) { + return; + } + + var axisPosition = axisModel.get('position'); + if (axisType === 'x') { + // Fix position + if (axisPosition !== 'top' && axisPosition !== 'bottom') { + // Default bottom of X + axisPosition = 'bottom'; + } + if (axisPositionUsed[axisPosition]) { + axisPosition = axisPosition === 'top' ? 'bottom' : 'top'; + } + } + else { + // Fix position + if (axisPosition !== 'left' && axisPosition !== 'right') { + // Default left of Y + axisPosition = 'left'; + } + if (axisPositionUsed[axisPosition]) { + axisPosition = axisPosition === 'left' ? 'right' : 'left'; + } + } + axisPositionUsed[axisPosition] = true; + + var axis = new Axis2D( + axisType, axisHelper.createScaleByModel(axisModel), + [0, 0], + axisModel.get('type'), + axisPosition + ); + + var isCategory = axis.type === 'category'; + axis.onBand = isCategory && axisModel.get('boundaryGap'); + axis.inverse = axisModel.get('inverse'); + + axis.onZero = axisModel.get('axisLine.onZero'); + + // Inject axis into axisModel + axisModel.axis = axis; + + // Inject axisModel into axis + axis.model = axisModel; + + // Index of axis, can be used as key + axis.index = idx; + + this._axesList.push(axis); + + axesMap[axisType][idx] = axis; + axesCount[axisType]++; + }; + } + }; + + /** + * Update cartesian properties from series + * @param {module:echarts/model/Option} option + * @private + */ + gridProto._updateScale = function (ecModel, gridModel) { + // Reset scale + zrUtil.each(this._axesList, function (axis) { + axis.scale.setExtent(Infinity, -Infinity); + }); + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.get('coordinateSystem') === 'cartesian2d') { + var xAxisIndex = seriesModel.get('xAxisIndex'); + var yAxisIndex = seriesModel.get('yAxisIndex'); + + var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex); + var yAxisModel = ecModel.getComponent('yAxis', yAxisIndex); + + if (!isAxisUsedInTheGrid(xAxisModel, gridModel, ecModel) + || !isAxisUsedInTheGrid(yAxisModel, gridModel, ecModel) + ) { + return; + } + + var cartesian = this.getCartesian(xAxisIndex, yAxisIndex); + var data = seriesModel.getData(); + var xAxis = cartesian.getAxis('x'); + var yAxis = cartesian.getAxis('y'); + + if (data.type === 'list') { + unionExtent(data, xAxis, seriesModel); + unionExtent(data, yAxis, seriesModel); + } + } + }, this); + + function unionExtent(data, axis, seriesModel) { + each(seriesModel.coordDimToDataDim(axis.dim), function (dim) { + axis.scale.unionExtent(data.getDataExtent( + dim, axis.scale.type !== 'ordinal' + )); + }); + } + }; + + /** + * @inner + */ + function updateAxisTransfrom(axis, coordBase) { + var axisExtent = axis.getExtent(); + var axisExtentSum = axisExtent[0] + axisExtent[1]; + + // Fast transform + axis.toGlobalCoord = axis.dim === 'x' + ? function (coord) { + return coord + coordBase; + } + : function (coord) { + return axisExtentSum - coord + coordBase; + }; + axis.toLocalCoord = axis.dim === 'x' + ? function (coord) { + return coord - coordBase; + } + : function (coord) { + return axisExtentSum - coord + coordBase; + }; + } + + Grid.create = function (ecModel, api) { + var grids = []; + ecModel.eachComponent('grid', function (gridModel, idx) { + var grid = new Grid(gridModel, ecModel, api); + grid.name = 'grid_' + idx; + grid.resize(gridModel, api); + + gridModel.coordinateSystem = grid; + + grids.push(grid); + }); + + // Inject the coordinateSystems into seriesModel + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.get('coordinateSystem') !== 'cartesian2d') { + return; + } + var xAxisIndex = seriesModel.get('xAxisIndex'); + // TODO Validate + var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex); + var grid = grids[xAxisModel.get('gridIndex')]; + seriesModel.coordinateSystem = grid.getCartesian( + xAxisIndex, seriesModel.get('yAxisIndex') + ); + }); + + return grids; + }; + + // For deciding which dimensions to use when creating list data + Grid.dimensions = Cartesian2D.prototype.dimensions; + + __webpack_require__(25).register('cartesian2d', Grid); + + module.exports = Grid; + + +/***/ }, +/* 108 */ +/***/ function(module, exports, __webpack_require__) { + + + + var OrdinalScale = __webpack_require__(109); + var IntervalScale = __webpack_require__(111); + __webpack_require__(112); + __webpack_require__(113); + var Scale = __webpack_require__(110); + + var numberUtil = __webpack_require__(7); + var zrUtil = __webpack_require__(3); + var textContain = __webpack_require__(14); + var axisHelper = {}; + + /** + * Get axis scale extent before niced. + */ + axisHelper.getScaleExtent = function (axis, model) { + var scale = axis.scale; + var originalExtent = scale.getExtent(); + var span = originalExtent[1] - originalExtent[0]; + if (scale.type === 'ordinal') { + // If series has no data, scale extent may be wrong + if (!isFinite(span)) { + return [0, 0]; + } + else { + return originalExtent; + } + } + var min = model.getMin ? model.getMin() : model.get('min'); + var max = model.getMax ? model.getMax() : model.get('max'); + var crossZero = model.getNeedCrossZero + ? model.getNeedCrossZero() : !model.get('scale'); + var boundaryGap = model.get('boundaryGap'); + if (!zrUtil.isArray(boundaryGap)) { + boundaryGap = [boundaryGap || 0, boundaryGap || 0]; + } + boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], 1); + boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], 1); + var fixMin = true; + var fixMax = true; + // Add boundary gap + if (min == null) { + min = originalExtent[0] - boundaryGap[0] * span; + fixMin = false; + } + if (max == null) { + max = originalExtent[1] + boundaryGap[1] * span; + fixMax = false; + } + // TODO Only one data + if (min === 'dataMin') { + min = originalExtent[0]; + } + if (max === 'dataMax') { + max = originalExtent[1]; + } + // Evaluate if axis needs cross zero + if (crossZero) { + // Axis is over zero and min is not set + if (min > 0 && max > 0 && !fixMin) { + min = 0; + } + // Axis is under zero and max is not set + if (min < 0 && max < 0 && !fixMax) { + max = 0; + } + } + return [min, max]; + }; + + axisHelper.niceScaleExtent = function (axis, model) { + var scale = axis.scale; + var extent = axisHelper.getScaleExtent(axis, model); + var fixMin = model.get('min') != null; + var fixMax = model.get('max') != null; + scale.setExtent(extent[0], extent[1]); + scale.niceExtent(model.get('splitNumber'), fixMin, fixMax); + + // If some one specified the min, max. And the default calculated interval + // is not good enough. He can specify the interval. It is often appeared + // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard + // to be 60. + // FIXME + var interval = model.get('interval'); + if (interval != null) { + scale.setInterval && scale.setInterval(interval); + } + }; + + /** + * @param {module:echarts/model/Model} model + * @param {string} [axisType] Default retrieve from model.type + * @return {module:echarts/scale/*} + */ + axisHelper.createScaleByModel = function(model, axisType) { + axisType = axisType || model.get('type'); + if (axisType) { + switch (axisType) { + // Buildin scale + case 'category': + return new OrdinalScale( + model.getCategories(), [Infinity, -Infinity] + ); + case 'value': + return new IntervalScale(); + // Extended scale, like time and log + default: + return (Scale.getClass(axisType) || IntervalScale).create(model); + } + } + }; + + /** + * Check if the axis corss 0 + */ + axisHelper.ifAxisCrossZero = function (axis) { + var dataExtent = axis.scale.getExtent(); + var min = dataExtent[0]; + var max = dataExtent[1]; + return !((min > 0 && max > 0) || (min < 0 && max < 0)); + }; + + /** + * @param {Array.} tickCoords In axis self coordinate. + * @param {Array.} labels + * @param {string} font + * @param {boolean} isAxisHorizontal + * @return {number} + */ + axisHelper.getAxisLabelInterval = function (tickCoords, labels, font, isAxisHorizontal) { + // FIXME + // 不同角的axis和label,不只是horizontal和vertical. + + var textSpaceTakenRect; + var autoLabelInterval = 0; + var accumulatedLabelInterval = 0; + + var step = 1; + if (labels.length > 40) { + // Simple optimization for large amount of labels + step = Math.round(labels.length / 40); + } + for (var i = 0; i < tickCoords.length; i += step) { + var tickCoord = tickCoords[i]; + var rect = textContain.getBoundingRect( + labels[i], font, 'center', 'top' + ); + rect[isAxisHorizontal ? 'x' : 'y'] += tickCoord; + rect[isAxisHorizontal ? 'width' : 'height'] *= 1.5; + if (!textSpaceTakenRect) { + textSpaceTakenRect = rect.clone(); + } + // There is no space for current label; + else if (textSpaceTakenRect.intersect(rect)) { + accumulatedLabelInterval++; + autoLabelInterval = Math.max(autoLabelInterval, accumulatedLabelInterval); + } + else { + textSpaceTakenRect.union(rect); + // Reset + accumulatedLabelInterval = 0; + } + } + if (autoLabelInterval === 0 && step > 1) { + return step; + } + return autoLabelInterval * step; + }; + + /** + * @param {Object} axis + * @param {Function} labelFormatter + * @return {Array.} + */ + axisHelper.getFormattedLabels = function (axis, labelFormatter) { + var scale = axis.scale; + var labels = scale.getTicksLabels(); + var ticks = scale.getTicks(); + if (typeof labelFormatter === 'string') { + labelFormatter = (function (tpl) { + return function (val) { + return tpl.replace('{value}', val); + }; + })(labelFormatter); + return zrUtil.map(labels, labelFormatter); + } + else if (typeof labelFormatter === 'function') { + return zrUtil.map(ticks, function (tick, idx) { + return labelFormatter( + axis.type === 'category' ? scale.getLabel(tick) : tick, + idx + ); + }, this); + } + else { + return labels; + } + }; + + module.exports = axisHelper; + + +/***/ }, +/* 109 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Linear continuous scale + * @module echarts/coord/scale/Ordinal + * + * http://en.wikipedia.org/wiki/Level_of_measurement + */ + + // FIXME only one data + + + var zrUtil = __webpack_require__(3); + var Scale = __webpack_require__(110); + + var scaleProto = Scale.prototype; + + var OrdinalScale = Scale.extend({ + + type: 'ordinal', + + init: function (data, extent) { + this._data = data; + this._extent = extent || [0, data.length - 1]; + }, + + parse: function (val) { + return typeof val === 'string' + ? zrUtil.indexOf(this._data, val) + // val might be float. + : Math.round(val); + }, + + contain: function (rank) { + rank = this.parse(rank); + return scaleProto.contain.call(this, rank) + && this._data[rank] != null; + }, + + /** + * Normalize given rank or name to linear [0, 1] + * @param {number|string} [val] + * @return {number} + */ + normalize: function (val) { + return scaleProto.normalize.call(this, this.parse(val)); + }, + + scale: function (val) { + return Math.round(scaleProto.scale.call(this, val)); + }, + + /** + * @return {Array} + */ + getTicks: function () { + var ticks = []; + var extent = this._extent; + var rank = extent[0]; + + while (rank <= extent[1]) { + ticks.push(rank); + rank++; + } + + return ticks; + }, + + /** + * Get item on rank n + * @param {number} n + * @return {string} + */ + getLabel: function (n) { + return this._data[n]; + }, + + /** + * @return {number} + */ + count: function () { + return this._extent[1] - this._extent[0] + 1; + }, + + niceTicks: zrUtil.noop, + niceExtent: zrUtil.noop + }); + + /** + * @return {module:echarts/scale/Time} + */ + OrdinalScale.create = function () { + return new OrdinalScale(); + }; + + module.exports = OrdinalScale; + + +/***/ }, +/* 110 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * // Scale class management + * @module echarts/scale/Scale + */ + + + var clazzUtil = __webpack_require__(9); + + function Scale() { + /** + * Extent + * @type {Array.} + * @protected + */ + this._extent = [Infinity, -Infinity]; + + /** + * Step is calculated in adjustExtent + * @type {Array.} + * @protected + */ + this._interval = 0; + + this.init && this.init.apply(this, arguments); + } + + var scaleProto = Scale.prototype; + + /** + * Parse input val to valid inner number. + * @param {*} val + * @return {number} + */ + scaleProto.parse = function (val) { + // Notice: This would be a trap here, If the implementation + // of this method depends on extent, and this method is used + // before extent set (like in dataZoom), it would be wrong. + // Nevertheless, parse does not depend on extent generally. + return val; + }; + + scaleProto.contain = function (val) { + var extent = this._extent; + return val >= extent[0] && val <= extent[1]; + }; + + /** + * Normalize value to linear [0, 1], return 0.5 if extent span is 0 + * @param {number} val + * @return {number} + */ + scaleProto.normalize = function (val) { + var extent = this._extent; + if (extent[1] === extent[0]) { + return 0.5; + } + return (val - extent[0]) / (extent[1] - extent[0]); + }; + + /** + * Scale normalized value + * @param {number} val + * @return {number} + */ + scaleProto.scale = function (val) { + var extent = this._extent; + return val * (extent[1] - extent[0]) + extent[0]; + }; + + /** + * Set extent from data + * @param {Array.} other + */ + scaleProto.unionExtent = function (other) { + var extent = this._extent; + other[0] < extent[0] && (extent[0] = other[0]); + other[1] > extent[1] && (extent[1] = other[1]); + // not setExtent because in log axis it may transformed to power + // this.setExtent(extent[0], extent[1]); + }; + + /** + * Get extent + * @return {Array.} + */ + scaleProto.getExtent = function () { + return this._extent.slice(); + }; + + /** + * Set extent + * @param {number} start + * @param {number} end + */ + scaleProto.setExtent = function (start, end) { + var thisExtent = this._extent; + if (!isNaN(start)) { + thisExtent[0] = start; + } + if (!isNaN(end)) { + thisExtent[1] = end; + } + }; + + /** + * @return {Array.} + */ + scaleProto.getTicksLabels = function () { + var labels = []; + var ticks = this.getTicks(); + for (var i = 0; i < ticks.length; i++) { + labels.push(this.getLabel(ticks[i])); + } + return labels; + }; + + clazzUtil.enableClassExtend(Scale); + clazzUtil.enableClassManagement(Scale, { + registerWhenExtend: true + }); + + module.exports = Scale; + + +/***/ }, +/* 111 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Interval scale + * @module echarts/scale/Interval + */ + + + + var numberUtil = __webpack_require__(7); + var formatUtil = __webpack_require__(6); + var Scale = __webpack_require__(110); + + var mathFloor = Math.floor; + var mathCeil = Math.ceil; + /** + * @alias module:echarts/coord/scale/Interval + * @constructor + */ + var IntervalScale = Scale.extend({ + + type: 'interval', + + _interval: 0, + + setExtent: function (start, end) { + var thisExtent = this._extent; + //start,end may be a Number like '25',so... + if (!isNaN(start)) { + thisExtent[0] = parseFloat(start); + } + if (!isNaN(end)) { + thisExtent[1] = parseFloat(end); + } + }, + + unionExtent: function (other) { + var extent = this._extent; + other[0] < extent[0] && (extent[0] = other[0]); + other[1] > extent[1] && (extent[1] = other[1]); + + // unionExtent may called by it's sub classes + IntervalScale.prototype.setExtent.call(this, extent[0], extent[1]); + }, + /** + * Get interval + */ + getInterval: function () { + if (!this._interval) { + this.niceTicks(); + } + return this._interval; + }, + + /** + * Set interval + */ + setInterval: function (interval) { + this._interval = interval; + // Dropped auto calculated niceExtent and use user setted extent + // We assume user wan't to set both interval, min, max to get a better result + this._niceExtent = this._extent.slice(); + }, + + /** + * @return {Array.} + */ + getTicks: function () { + if (!this._interval) { + this.niceTicks(); + } + var interval = this._interval; + var extent = this._extent; + var ticks = []; + + // Consider this case: using dataZoom toolbox, zoom and zoom. + var safeLimit = 10000; + + if (interval) { + var niceExtent = this._niceExtent; + if (extent[0] < niceExtent[0]) { + ticks.push(extent[0]); + } + var tick = niceExtent[0]; + while (tick <= niceExtent[1]) { + ticks.push(tick); + // Avoid rounding error + tick = numberUtil.round(tick + interval); + if (ticks.length > safeLimit) { + return []; + } + } + if (extent[1] > niceExtent[1]) { + ticks.push(extent[1]); + } + } + + return ticks; + }, + + /** + * @return {Array.} + */ + getTicksLabels: function () { + var labels = []; + var ticks = this.getTicks(); + for (var i = 0; i < ticks.length; i++) { + labels.push(this.getLabel(ticks[i])); + } + return labels; + }, + + /** + * @param {number} n + * @return {number} + */ + getLabel: function (data) { + return formatUtil.addCommas(data); + }, + + /** + * Update interval and extent of intervals for nice ticks + * + * @param {number} [splitNumber = 5] Desired number of ticks + */ + niceTicks: function (splitNumber) { + splitNumber = splitNumber || 5; + var extent = this._extent; + var span = extent[1] - extent[0]; + if (!isFinite(span)) { + return; + } + // User may set axis min 0 and data are all negative + // FIXME If it needs to reverse ? + if (span < 0) { + span = -span; + extent.reverse(); + } + + // From "Nice Numbers for Graph Labels" of Graphic Gems + // var niceSpan = numberUtil.nice(span, false); + var step = numberUtil.nice(span / splitNumber, true); + + // Niced extent inside original extent + var niceExtent = [ + numberUtil.round(mathCeil(extent[0] / step) * step), + numberUtil.round(mathFloor(extent[1] / step) * step) + ]; + + this._interval = step; + this._niceExtent = niceExtent; + }, + + /** + * Nice extent. + * @param {number} [splitNumber = 5] Given approx tick number + * @param {boolean} [fixMin=false] + * @param {boolean} [fixMax=false] + */ + niceExtent: function (splitNumber, fixMin, fixMax) { + var extent = this._extent; + // If extent start and end are same, expand them + if (extent[0] === extent[1]) { + if (extent[0] !== 0) { + // Expand extent + var expandSize = extent[0] / 2; + extent[0] -= expandSize; + extent[1] += expandSize; + } + else { + extent[1] = 1; + } + } + var span = extent[1] - extent[0]; + // If there are no data and extent are [Infinity, -Infinity] + if (!isFinite(span)) { + extent[0] = 0; + extent[1] = 1; + } + + this.niceTicks(splitNumber); + + // var extent = this._extent; + var interval = this._interval; + + if (!fixMin) { + extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval); + } + if (!fixMax) { + extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval); + } + } + }); + + /** + * @return {module:echarts/scale/Time} + */ + IntervalScale.create = function () { + return new IntervalScale(); + }; + + module.exports = IntervalScale; + + + +/***/ }, +/* 112 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Interval scale + * @module echarts/coord/scale/Time + */ + + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var formatUtil = __webpack_require__(6); + + var IntervalScale = __webpack_require__(111); + + var intervalScaleProto = IntervalScale.prototype; + + var mathCeil = Math.ceil; + var mathFloor = Math.floor; + var ONE_DAY = 3600000 * 24; + + // FIXME 公用? + var bisect = function (a, x, lo, hi) { + while (lo < hi) { + var mid = lo + hi >>> 1; + if (a[mid][2] < x) { + lo = mid + 1; + } + else { + hi = mid; + } + } + return lo; + }; + + /** + * @alias module:echarts/coord/scale/Time + * @constructor + */ + var TimeScale = IntervalScale.extend({ + type: 'time', + + // Overwrite + getLabel: function (val) { + var stepLvl = this._stepLvl; + + var date = new Date(val); + + return formatUtil.formatTime(stepLvl[0], date); + }, + + // Overwrite + niceExtent: function (approxTickNum, fixMin, fixMax) { + var extent = this._extent; + // If extent start and end are same, expand them + if (extent[0] === extent[1]) { + // Expand extent + extent[0] -= ONE_DAY; + extent[1] += ONE_DAY; + } + // If there are no data and extent are [Infinity, -Infinity] + if (extent[1] === -Infinity && extent[0] === Infinity) { + var d = new Date(); + extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate()); + extent[0] = extent[1] - ONE_DAY; + } + + this.niceTicks(approxTickNum, fixMin, fixMax); + + // var extent = this._extent; + var interval = this._interval; + + if (!fixMin) { + extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval); + } + if (!fixMax) { + extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval); + } + }, + + // Overwrite + niceTicks: function (approxTickNum) { + approxTickNum = approxTickNum || 10; + + var extent = this._extent; + var span = extent[1] - extent[0]; + var approxInterval = span / approxTickNum; + var scaleLevelsLen = scaleLevels.length; + var idx = bisect(scaleLevels, approxInterval, 0, scaleLevelsLen); + + var level = scaleLevels[Math.min(idx, scaleLevelsLen - 1)]; + var interval = level[2]; + // Same with interval scale if span is much larger than 1 year + if (level[0] === 'year') { + var yearSpan = span / interval; + + // From "Nice Numbers for Graph Labels" of Graphic Gems + // var niceYearSpan = numberUtil.nice(yearSpan, false); + var yearStep = numberUtil.nice(yearSpan / approxTickNum, true); + + interval *= yearStep; + } + + var niceExtent = [ + mathCeil(extent[0] / interval) * interval, + mathFloor(extent[1] / interval) * interval + ]; + + this._stepLvl = level; + // Interval will be used in getTicks + this._interval = interval; + this._niceExtent = niceExtent; + }, + + parse: function (val) { + // val might be float. + return +numberUtil.parseDate(val); + } + }); + + zrUtil.each(['contain', 'normalize'], function (methodName) { + TimeScale.prototype[methodName] = function (val) { + return intervalScaleProto[methodName].call(this, this.parse(val)); + }; + }); + + // Steps from d3 + var scaleLevels = [ + // Format step interval + ['hh:mm:ss', 1, 1000], // 1s + ['hh:mm:ss', 5, 1000 * 5], // 5s + ['hh:mm:ss', 10, 1000 * 10], // 10s + ['hh:mm:ss', 15, 1000 * 15], // 15s + ['hh:mm:ss', 30, 1000 * 30], // 30s + ['hh:mm\nMM-dd',1, 60000], // 1m + ['hh:mm\nMM-dd',5, 60000 * 5], // 5m + ['hh:mm\nMM-dd',10, 60000 * 10], // 10m + ['hh:mm\nMM-dd',15, 60000 * 15], // 15m + ['hh:mm\nMM-dd',30, 60000 * 30], // 30m + ['hh:mm\nMM-dd',1, 3600000], // 1h + ['hh:mm\nMM-dd',2, 3600000 * 2], // 2h + ['hh:mm\nMM-dd',6, 3600000 * 6], // 6h + ['hh:mm\nMM-dd',12, 3600000 * 12], // 12h + ['MM-dd\nyyyy', 1, ONE_DAY], // 1d + ['week', 7, ONE_DAY * 7], // 7d + ['month', 1, ONE_DAY * 31], // 1M + ['quarter', 3, ONE_DAY * 380 / 4], // 3M + ['half-year', 6, ONE_DAY * 380 / 2], // 6M + ['year', 1, ONE_DAY * 380] // 1Y + ]; + + /** + * @return {module:echarts/scale/Time} + */ + TimeScale.create = function () { + return new TimeScale(); + }; + + module.exports = TimeScale; + + +/***/ }, +/* 113 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Log scale + * @module echarts/scale/Log + */ + + + var zrUtil = __webpack_require__(3); + var Scale = __webpack_require__(110); + var numberUtil = __webpack_require__(7); + + // Use some method of IntervalScale + var IntervalScale = __webpack_require__(111); + + var scaleProto = Scale.prototype; + var intervalScaleProto = IntervalScale.prototype; + + var mathFloor = Math.floor; + var mathCeil = Math.ceil; + var mathPow = Math.pow; + + var LOG_BASE = 10; + var mathLog = Math.log; + + var LogScale = Scale.extend({ + + type: 'log', + + /** + * @return {Array.} + */ + getTicks: function () { + return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) { + return numberUtil.round(mathPow(LOG_BASE, val)); + }); + }, + + /** + * @param {number} val + * @return {string} + */ + getLabel: intervalScaleProto.getLabel, + + /** + * @param {number} val + * @return {number} + */ + scale: function (val) { + val = scaleProto.scale.call(this, val); + return mathPow(LOG_BASE, val); + }, + + /** + * @param {number} start + * @param {number} end + */ + setExtent: function (start, end) { + start = mathLog(start) / mathLog(LOG_BASE); + end = mathLog(end) / mathLog(LOG_BASE); + intervalScaleProto.setExtent.call(this, start, end); + }, + + /** + * @return {number} end + */ + getExtent: function () { + var extent = scaleProto.getExtent.call(this); + extent[0] = mathPow(LOG_BASE, extent[0]); + extent[1] = mathPow(LOG_BASE, extent[1]); + return extent; + }, + + /** + * @param {Array.} extent + */ + unionExtent: function (extent) { + extent[0] = mathLog(extent[0]) / mathLog(LOG_BASE); + extent[1] = mathLog(extent[1]) / mathLog(LOG_BASE); + scaleProto.unionExtent.call(this, extent); + }, + + /** + * Update interval and extent of intervals for nice ticks + * @param {number} [approxTickNum = 10] Given approx tick number + */ + niceTicks: function (approxTickNum) { + approxTickNum = approxTickNum || 10; + var extent = this._extent; + var span = extent[1] - extent[0]; + if (span === Infinity || span <= 0) { + return; + } + + var interval = mathPow(10, mathFloor(mathLog(span / approxTickNum) / Math.LN10)); + var err = approxTickNum / span * interval; + + // Filter ticks to get closer to the desired count. + if (err <= 0.5) { + interval *= 10; + } + var niceExtent = [ + numberUtil.round(mathCeil(extent[0] / interval) * interval), + numberUtil.round(mathFloor(extent[1] / interval) * interval) + ]; + + this._interval = interval; + this._niceExtent = niceExtent; + }, + + /** + * Nice extent. + * @param {number} [approxTickNum = 10] Given approx tick number + * @param {boolean} [fixMin=false] + * @param {boolean} [fixMax=false] + */ + niceExtent: intervalScaleProto.niceExtent + }); + + zrUtil.each(['contain', 'normalize'], function (methodName) { + LogScale.prototype[methodName] = function (val) { + val = mathLog(val) / mathLog(LOG_BASE); + return scaleProto[methodName].call(this, val); + }; + }); + + LogScale.create = function () { + return new LogScale(); + }; + + module.exports = LogScale; + + +/***/ }, +/* 114 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var Cartesian = __webpack_require__(115); + + function Cartesian2D(name) { + + Cartesian.call(this, name); + } + + Cartesian2D.prototype = { + + constructor: Cartesian2D, + + type: 'cartesian2d', + + /** + * @type {Array.} + * @readOnly + */ + dimensions: ['x', 'y'], + + /** + * Base axis will be used on stacking. + * + * @return {module:echarts/coord/cartesian/Axis2D} + */ + getBaseAxis: function () { + return this.getAxesByScale('ordinal')[0] + || this.getAxesByScale('time')[0] + || this.getAxis('x'); + }, + + /** + * If contain point + * @param {Array.} point + * @return {boolean} + */ + containPoint: function (point) { + var axisX = this.getAxis('x'); + var axisY = this.getAxis('y'); + return axisX.contain(axisX.toLocalCoord(point[0])) + && axisY.contain(axisY.toLocalCoord(point[1])); + }, + + /** + * If contain data + * @param {Array.} data + * @return {boolean} + */ + containData: function (data) { + return this.getAxis('x').containData(data[0]) + && this.getAxis('y').containData(data[1]); + }, + + /** + * Convert series data to an array of points + * @param {module:echarts/data/List} data + * @param {boolean} stack + * @return {Array} + * Return array of points. For example: + * `[[10, 10], [20, 20], [30, 30]]` + */ + dataToPoints: function (data, stack) { + return data.mapArray(['x', 'y'], function (x, y) { + return this.dataToPoint([x, y]); + }, stack, this); + }, + + /** + * @param {Array.} data + * @param {boolean} [clamp=false] + * @return {Array.} + */ + dataToPoint: function (data, clamp) { + var xAxis = this.getAxis('x'); + var yAxis = this.getAxis('y'); + return [ + xAxis.toGlobalCoord(xAxis.dataToCoord(data[0], clamp)), + yAxis.toGlobalCoord(yAxis.dataToCoord(data[1], clamp)) + ]; + }, + + /** + * @param {Array.} point + * @param {boolean} [clamp=false] + * @return {Array.} + */ + pointToData: function (point, clamp) { + var xAxis = this.getAxis('x'); + var yAxis = this.getAxis('y'); + return [ + xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp), + yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp) + ]; + }, + + /** + * Get other axis + * @param {module:echarts/coord/cartesian/Axis2D} axis + */ + getOtherAxis: function (axis) { + return this.getAxis(axis.dim === 'x' ? 'y' : 'x'); + } + }; + + zrUtil.inherits(Cartesian2D, Cartesian); + + module.exports = Cartesian2D; + + +/***/ }, +/* 115 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Cartesian coordinate system + * @module echarts/coord/Cartesian + * + */ + + + var zrUtil = __webpack_require__(3); + + function dimAxisMapper(dim) { + return this._axes[dim]; + } + + /** + * @alias module:echarts/coord/Cartesian + * @constructor + */ + var Cartesian = function (name) { + this._axes = {}; + + this._dimList = []; + + /** + * @type {string} + */ + this.name = name || ''; + }; + + Cartesian.prototype = { + + constructor: Cartesian, + + type: 'cartesian', + + /** + * Get axis + * @param {number|string} dim + * @return {module:echarts/coord/Cartesian~Axis} + */ + getAxis: function (dim) { + return this._axes[dim]; + }, + + /** + * Get axes list + * @return {Array.} + */ + getAxes: function () { + return zrUtil.map(this._dimList, dimAxisMapper, this); + }, + + /** + * Get axes list by given scale type + */ + getAxesByScale: function (scaleType) { + scaleType = scaleType.toLowerCase(); + return zrUtil.filter( + this.getAxes(), + function (axis) { + return axis.scale.type === scaleType; + } + ); + }, + + /** + * Add axis + * @param {module:echarts/coord/Cartesian.Axis} + */ + addAxis: function (axis) { + var dim = axis.dim; + + this._axes[dim] = axis; + + this._dimList.push(dim); + }, + + /** + * Convert data to coord in nd space + * @param {Array.|Object.} val + * @return {Array.|Object.} + */ + dataToCoord: function (val) { + return this._dataCoordConvert(val, 'dataToCoord'); + }, + + /** + * Convert coord in nd space to data + * @param {Array.|Object.} val + * @return {Array.|Object.} + */ + coordToData: function (val) { + return this._dataCoordConvert(val, 'coordToData'); + }, + + _dataCoordConvert: function (input, method) { + var dimList = this._dimList; + + var output = input instanceof Array ? [] : {}; + + for (var i = 0; i < dimList.length; i++) { + var dim = dimList[i]; + var axis = this._axes[dim]; + + output[dim] = axis[method](input[dim]); + } + + return output; + } + }; + + module.exports = Cartesian; + + +/***/ }, +/* 116 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var Axis = __webpack_require__(117); + var axisLabelInterval = __webpack_require__(118); + + /** + * Extend axis 2d + * @constructor module:echarts/coord/cartesian/Axis2D + * @extends {module:echarts/coord/cartesian/Axis} + * @param {string} dim + * @param {*} scale + * @param {Array.} coordExtent + * @param {string} axisType + * @param {string} position + */ + var Axis2D = function (dim, scale, coordExtent, axisType, position) { + Axis.call(this, dim, scale, coordExtent); + /** + * Axis type + * - 'category' + * - 'value' + * - 'time' + * - 'log' + * @type {string} + */ + this.type = axisType || 'value'; + + /** + * Axis position + * - 'top' + * - 'bottom' + * - 'left' + * - 'right' + */ + this.position = position || 'bottom'; + }; + + Axis2D.prototype = { + + constructor: Axis2D, + + /** + * Index of axis, can be used as key + */ + index: 0, + /** + * If axis is on the zero position of the other axis + * @type {boolean} + */ + onZero: false, + + /** + * Axis model + * @param {module:echarts/coord/cartesian/AxisModel} + */ + model: null, + + isHorizontal: function () { + var position = this.position; + return position === 'top' || position === 'bottom'; + }, + + getGlobalExtent: function () { + var ret = this.getExtent(); + ret[0] = this.toGlobalCoord(ret[0]); + ret[1] = this.toGlobalCoord(ret[1]); + return ret; + }, + + /** + * @return {number} + */ + getLabelInterval: function () { + var labelInterval = this._labelInterval; + if (!labelInterval) { + labelInterval = this._labelInterval = axisLabelInterval(this); + } + return labelInterval; + }, + + /** + * If label is ignored. + * Automatically used when axis is category and label can not be all shown + * @param {number} idx + * @return {boolean} + */ + isLabelIgnored: function (idx) { + if (this.type === 'category') { + var labelInterval = this.getLabelInterval(); + return ((typeof labelInterval === 'function') + && !labelInterval(idx, this.scale.getLabel(idx))) + || idx % (labelInterval + 1); + } + }, + + /** + * Transform global coord to local coord, + * i.e. var localCoord = axis.toLocalCoord(80); + * designate by module:echarts/coord/cartesian/Grid. + * @type {Function} + */ + toLocalCoord: null, + + /** + * Transform global coord to local coord, + * i.e. var globalCoord = axis.toLocalCoord(40); + * designate by module:echarts/coord/cartesian/Grid. + * @type {Function} + */ + toGlobalCoord: null + + }; + zrUtil.inherits(Axis2D, Axis); + + module.exports = Axis2D; + + +/***/ }, +/* 117 */ +/***/ function(module, exports, __webpack_require__) { + + + + var numberUtil = __webpack_require__(7); + var linearMap = numberUtil.linearMap; + var zrUtil = __webpack_require__(3); + + function fixExtentWithBands(extent, nTick) { + var size = extent[1] - extent[0]; + var len = nTick; + var margin = size / len / 2; + extent[0] += margin; + extent[1] -= margin; + } + + var normalizedExtent = [0, 1]; + /** + * @name module:echarts/coord/CartesianAxis + * @constructor + */ + var Axis = function (dim, scale, extent) { + + /** + * Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius' + * @type {string} + */ + this.dim = dim; + + /** + * Axis scale + * @type {module:echarts/coord/scale/*} + */ + this.scale = scale; + + /** + * @type {Array.} + * @private + */ + this._extent = extent || [0, 0]; + + /** + * @type {boolean} + */ + this.inverse = false; + + /** + * Usually true when axis has a ordinal scale + * @type {boolean} + */ + this.onBand = false; + }; + + Axis.prototype = { + + constructor: Axis, + + /** + * If axis extent contain given coord + * @param {number} coord + * @return {boolean} + */ + contain: function (coord) { + var extent = this._extent; + var min = Math.min(extent[0], extent[1]); + var max = Math.max(extent[0], extent[1]); + return coord >= min && coord <= max; + }, + + /** + * If axis extent contain given data + * @param {number} data + * @return {boolean} + */ + containData: function (data) { + return this.contain(this.dataToCoord(data)); + }, + + /** + * Get coord extent. + * @return {Array.} + */ + getExtent: function () { + var ret = this._extent.slice(); + return ret; + }, + + /** + * Get precision used for formatting + * @param {Array.} [dataExtent] + * @return {number} + */ + getPixelPrecision: function (dataExtent) { + return numberUtil.getPixelPrecision( + dataExtent || this.scale.getExtent(), + this._extent + ); + }, + + /** + * Set coord extent + * @param {number} start + * @param {number} end + */ + setExtent: function (start, end) { + var extent = this._extent; + extent[0] = start; + extent[1] = end; + }, + + /** + * Convert data to coord. Data is the rank if it has a ordinal scale + * @param {number} data + * @param {boolean} clamp + * @return {number} + */ + dataToCoord: function (data, clamp) { + var extent = this._extent; + var scale = this.scale; + data = scale.normalize(data); + + if (this.onBand && scale.type === 'ordinal') { + extent = extent.slice(); + fixExtentWithBands(extent, scale.count()); + } + + return linearMap(data, normalizedExtent, extent, clamp); + }, + + /** + * Convert coord to data. Data is the rank if it has a ordinal scale + * @param {number} coord + * @param {boolean} clamp + * @return {number} + */ + coordToData: function (coord, clamp) { + var extent = this._extent; + var scale = this.scale; + + if (this.onBand && scale.type === 'ordinal') { + extent = extent.slice(); + fixExtentWithBands(extent, scale.count()); + } + + var t = linearMap(coord, extent, normalizedExtent, clamp); + + return this.scale.scale(t); + }, + /** + * @return {Array.} + */ + getTicksCoords: function () { + if (this.onBand) { + var bands = this.getBands(); + var coords = []; + for (var i = 0; i < bands.length; i++) { + coords.push(bands[i][0]); + } + if (bands[i - 1]) { + coords.push(bands[i - 1][1]); + } + return coords; + } + else { + return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this); + } + }, + + /** + * Coords of labels are on the ticks or on the middle of bands + * @return {Array.} + */ + getLabelsCoords: function () { + if (this.onBand) { + var bands = this.getBands(); + var coords = []; + var band; + for (var i = 0; i < bands.length; i++) { + band = bands[i]; + coords.push((band[0] + band[1]) / 2); + } + return coords; + } + else { + return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this); + } + }, + + /** + * Get bands. + * + * If axis has labels [1, 2, 3, 4]. Bands on the axis are + * |---1---|---2---|---3---|---4---|. + * + * @return {Array} + */ + // FIXME Situation when labels is on ticks + getBands: function () { + var extent = this.getExtent(); + var bands = []; + var len = this.scale.count(); + var start = extent[0]; + var end = extent[1]; + var span = end - start; + + for (var i = 0; i < len; i++) { + bands.push([ + span * i / len + start, + span * (i + 1) / len + start + ]); + } + return bands; + }, + + /** + * Get width of band + * @return {number} + */ + getBandWidth: function () { + var axisExtent = this._extent; + var dataExtent = this.scale.getExtent(); + + var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0); + + var size = Math.abs(axisExtent[1] - axisExtent[0]); + + return Math.abs(size) / len; + } + }; + + module.exports = Axis; + + +/***/ }, +/* 118 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + /** + * Helper function for axisLabelInterval calculation + */ + + + + var zrUtil = __webpack_require__(3); + var axisHelper = __webpack_require__(108); + + module.exports = function (axis) { + var axisModel = axis.model; + var labelModel = axisModel.getModel('axisLabel'); + var labelInterval = labelModel.get('interval'); + if (!(axis.type === 'category' && labelInterval === 'auto')) { + return labelInterval === 'auto' ? 0 : labelInterval; + } + + return axisHelper.getAxisLabelInterval( + zrUtil.map(axis.scale.getTicks(), axis.dataToCoord, axis), + axisModel.getFormattedLabels(), + labelModel.getModel('textStyle').getFont(), + axis.isHorizontal() + ); + }; + + +/***/ }, +/* 119 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // Grid 是在有直角坐标系的时候必须要存在的 + // 所以这里也要被 Cartesian2D 依赖 + + + __webpack_require__(120); + var ComponentModel = __webpack_require__(19); + + module.exports = ComponentModel.extend({ + + type: 'grid', + + dependencies: ['xAxis', 'yAxis'], + + layoutMode: 'box', + + /** + * @type {module:echarts/coord/cartesian/Grid} + */ + coordinateSystem: null, + + defaultOption: { + show: false, + zlevel: 0, + z: 0, + left: '10%', + top: 60, + right: '10%', + bottom: 60, + // If grid size contain label + containLabel: false, + // width: {totalWidth} - left - right, + // height: {totalHeight} - top - bottom, + backgroundColor: 'rgba(0,0,0,0)', + borderWidth: 1, + borderColor: '#ccc' + } + }); + + +/***/ }, +/* 120 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var ComponentModel = __webpack_require__(19); + var zrUtil = __webpack_require__(3); + var axisModelCreator = __webpack_require__(121); + + var AxisModel = ComponentModel.extend({ + + type: 'cartesian2dAxis', + + /** + * @type {module:echarts/coord/cartesian/Axis2D} + */ + axis: null, + + /** + * @override + */ + init: function () { + AxisModel.superApply(this, 'init', arguments); + this._resetRange(); + }, + + /** + * @override + */ + mergeOption: function () { + AxisModel.superApply(this, 'mergeOption', arguments); + this._resetRange(); + }, + + /** + * @override + */ + restoreData: function () { + AxisModel.superApply(this, 'restoreData', arguments); + this._resetRange(); + }, + + /** + * @public + * @param {number} rangeStart + * @param {number} rangeEnd + */ + setRange: function (rangeStart, rangeEnd) { + this.option.rangeStart = rangeStart; + this.option.rangeEnd = rangeEnd; + }, + + /** + * @public + * @return {Array.} + */ + getMin: function () { + var option = this.option; + return option.rangeStart != null ? option.rangeStart : option.min; + }, + + /** + * @public + * @return {Array.} + */ + getMax: function () { + var option = this.option; + return option.rangeEnd != null ? option.rangeEnd : option.max; + }, + + /** + * @public + * @return {boolean} + */ + getNeedCrossZero: function () { + var option = this.option; + return (option.rangeStart != null || option.rangeEnd != null) + ? false : !option.scale; + }, + + /** + * @private + */ + _resetRange: function () { + // rangeStart and rangeEnd is readonly. + this.option.rangeStart = this.option.rangeEnd = null; + } + + }); + + function getAxisType(axisDim, option) { + // Default axis with data is category axis + return option.type || (option.data ? 'category' : 'value'); + } + + zrUtil.merge(AxisModel.prototype, __webpack_require__(123)); + + var extraOption = { + gridIndex: 0 + }; + + axisModelCreator('x', AxisModel, getAxisType, extraOption); + axisModelCreator('y', AxisModel, getAxisType, extraOption); + + module.exports = AxisModel; + + +/***/ }, +/* 121 */ +/***/ function(module, exports, __webpack_require__) { + + + + var axisDefault = __webpack_require__(122); + var zrUtil = __webpack_require__(3); + var ComponentModel = __webpack_require__(19); + var layout = __webpack_require__(21); + + // FIXME axisType is fixed ? + var AXIS_TYPES = ['value', 'category', 'time', 'log']; + + /** + * Generate sub axis model class + * @param {string} axisName 'x' 'y' 'radius' 'angle' 'parallel' + * @param {module:echarts/model/Component} BaseAxisModelClass + * @param {Function} axisTypeDefaulter + * @param {Object} [extraDefaultOption] + */ + module.exports = function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) { + + zrUtil.each(AXIS_TYPES, function (axisType) { + + BaseAxisModelClass.extend({ + + type: axisName + 'Axis.' + axisType, + + mergeDefaultAndTheme: function (option, ecModel) { + var layoutMode = this.layoutMode; + var inputPositionParams = layoutMode + ? layout.getLayoutParams(option) : {}; + + var themeModel = ecModel.getTheme(); + zrUtil.merge(option, themeModel.get(axisType + 'Axis')); + zrUtil.merge(option, this.getDefaultOption()); + + option.type = axisTypeDefaulter(axisName, option); + + if (layoutMode) { + layout.mergeLayoutParam(option, inputPositionParams, layoutMode); + } + }, + + defaultOption: zrUtil.mergeAll( + [ + {}, + axisDefault[axisType + 'Axis'], + extraDefaultOption + ], + true + ) + }); + }); + + ComponentModel.registerSubTypeDefaulter( + axisName + 'Axis', + zrUtil.curry(axisTypeDefaulter, axisName) + ); + }; + + +/***/ }, +/* 122 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + var defaultOption = { + show: true, + zlevel: 0, // 一级层叠 + z: 0, // 二级层叠 + // 反向坐标轴 + inverse: false, + // 坐标轴名字,默认为空 + name: '', + // 坐标轴名字位置,支持'start' | 'middle' | 'end' + nameLocation: 'end', + // 坐标轴文字样式,默认取全局样式 + nameTextStyle: {}, + // 文字与轴线距离 + nameGap: 15, + // 坐标轴线 + axisLine: { + // 默认显示,属性show控制显示与否 + show: true, + onZero: true, + // 属性lineStyle控制线条样式 + lineStyle: { + color: '#333', + width: 1, + type: 'solid' + } + }, + // 坐标轴小标记 + axisTick: { + // 属性show控制显示与否,默认显示 + show: true, + // 控制小标记是否在grid里 + inside: false, + // 属性length控制线长 + length: 5, + // 属性lineStyle控制线条样式 + lineStyle: { + color: '#333', + width: 1 + } + }, + // 坐标轴文本标签,详见axis.axisLabel + axisLabel: { + show: true, + // 控制文本标签是否在grid里 + inside: false, + rotate: 0, + margin: 8, + // formatter: null, + // 其余属性默认使用全局文本样式,详见TEXTSTYLE + textStyle: { + color: '#333', + fontSize: 12 + } + }, + // 分隔线 + splitLine: { + // 默认显示,属性show控制显示与否 + show: true, + // 属性lineStyle(详见lineStyle)控制线条样式 + lineStyle: { + color: ['#ccc'], + width: 1, + type: 'solid' + } + }, + // 分隔区域 + splitArea: { + // 默认不显示,属性show控制显示与否 + show: false, + // 属性areaStyle(详见areaStyle)控制区域样式 + areaStyle: { + color: ['rgba(250,250,250,0.3)','rgba(200,200,200,0.3)'] + } + } + }; + + var categoryAxis = zrUtil.merge({ + // 类目起始和结束两端空白策略 + boundaryGap: true, + // 坐标轴小标记 + axisTick: { + interval: 'auto' + }, + // 坐标轴文本标签,详见axis.axisLabel + axisLabel: { + interval: 'auto' + } + }, defaultOption); + + var valueAxis = zrUtil.defaults({ + // 数值起始和结束两端空白策略 + boundaryGap: [0, 0], + // 最小值, 设置成 'dataMin' 则从数据中计算最小值 + // min: null, + // 最大值,设置成 'dataMax' 则从数据中计算最大值 + // max: null, + // Readonly prop, specifies start value of the range when using data zoom. + // rangeStart: null + // Readonly prop, specifies end value of the range when using data zoom. + // rangeEnd: null + // 脱离0值比例,放大聚焦到最终_min,_max区间 + // scale: false, + // 分割段数,默认为5 + splitNumber: 5 + }, defaultOption); + + // FIXME + var timeAxis = zrUtil.defaults({ + scale: true, + min: 'dataMin', + max: 'dataMax' + }, valueAxis); + var logAxis = zrUtil.defaults({}, valueAxis); + logAxis.scale = true; + + module.exports = { + categoryAxis: categoryAxis, + valueAxis: valueAxis, + timeAxis: timeAxis, + logAxis: logAxis + }; + + +/***/ }, +/* 123 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var axisHelper = __webpack_require__(108); + + function getName(obj) { + if (zrUtil.isObject(obj) && obj.value != null) { + return obj.value; + } + else { + return obj; + } + } + /** + * Get categories + */ + function getCategories() { + return this.get('type') === 'category' + && zrUtil.map(this.get('data'), getName); + } + + /** + * Format labels + * @return {Array.} + */ + function getFormattedLabels() { + return axisHelper.getFormattedLabels( + this.axis, + this.get('axisLabel.formatter') + ); + } + + module.exports = { + + getFormattedLabels: getFormattedLabels, + + getCategories: getCategories + }; + + +/***/ }, +/* 124 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // TODO boundaryGap + + + __webpack_require__(120); + + __webpack_require__(125); + + +/***/ }, +/* 125 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var AxisBuilder = __webpack_require__(126); + var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick; + var getInterval = AxisBuilder.getInterval; + + var axisBuilderAttrs = [ + 'axisLine', 'axisLabel', 'axisTick', 'axisName' + ]; + var selfBuilderAttrs = [ + 'splitLine', 'splitArea' + ]; + + var AxisView = __webpack_require__(1).extendComponentView({ + + type: 'axis', + + render: function (axisModel, ecModel) { + + this.group.removeAll(); + + if (!axisModel.get('show')) { + return; + } + + var gridModel = ecModel.getComponent('grid', axisModel.get('gridIndex')); + + var layout = layoutAxis(gridModel, axisModel); + + var axisBuilder = new AxisBuilder(axisModel, layout); + + zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder); + + this.group.add(axisBuilder.getGroup()); + + zrUtil.each(selfBuilderAttrs, function (name) { + if (axisModel.get(name +'.show')) { + this['_' + name](axisModel, gridModel, layout.labelInterval); + } + }, this); + }, + + /** + * @param {module:echarts/coord/cartesian/AxisModel} axisModel + * @param {module:echarts/coord/cartesian/GridModel} gridModel + * @param {number|Function} labelInterval + * @private + */ + _splitLine: function (axisModel, gridModel, labelInterval) { + var axis = axisModel.axis; + + var splitLineModel = axisModel.getModel('splitLine'); + var lineStyleModel = splitLineModel.getModel('lineStyle'); + var lineWidth = lineStyleModel.get('width'); + var lineColors = lineStyleModel.get('color'); + + var lineInterval = getInterval(splitLineModel, labelInterval); + + lineColors = zrUtil.isArray(lineColors) ? lineColors : [lineColors]; + + var gridRect = gridModel.coordinateSystem.getRect(); + var isHorizontal = axis.isHorizontal(); + + var splitLines = []; + var lineCount = 0; + + var ticksCoords = axis.getTicksCoords(); + + var p1 = []; + var p2 = []; + for (var i = 0; i < ticksCoords.length; i++) { + if (ifIgnoreOnTick(axis, i, lineInterval)) { + continue; + } + + var tickCoord = axis.toGlobalCoord(ticksCoords[i]); + + if (isHorizontal) { + p1[0] = tickCoord; + p1[1] = gridRect.y; + p2[0] = tickCoord; + p2[1] = gridRect.y + gridRect.height; + } + else { + p1[0] = gridRect.x; + p1[1] = tickCoord; + p2[0] = gridRect.x + gridRect.width; + p2[1] = tickCoord; + } + + var colorIndex = (lineCount++) % lineColors.length; + splitLines[colorIndex] = splitLines[colorIndex] || []; + splitLines[colorIndex].push(new graphic.Line(graphic.subPixelOptimizeLine({ + shape: { + x1: p1[0], + y1: p1[1], + x2: p2[0], + y2: p2[1] + }, + style: { + lineWidth: lineWidth + }, + silent: true + }))); + } + + // Simple optimization + // Batching the lines if color are the same + var lineStyle = lineStyleModel.getLineStyle(); + for (var i = 0; i < splitLines.length; i++) { + this.group.add(graphic.mergePath(splitLines[i], { + style: zrUtil.defaults({ + stroke: lineColors[i % lineColors.length] + }, lineStyle), + silent: true + })); + } + }, + + /** + * @param {module:echarts/coord/cartesian/AxisModel} axisModel + * @param {module:echarts/coord/cartesian/GridModel} gridModel + * @param {number|Function} labelInterval + * @private + */ + _splitArea: function (axisModel, gridModel, labelInterval) { + var axis = axisModel.axis; + + var splitAreaModel = axisModel.getModel('splitArea'); + var areaStyleModel = splitAreaModel.getModel('areaStyle'); + var areaColors = areaStyleModel.get('color'); + + var gridRect = gridModel.coordinateSystem.getRect(); + var ticksCoords = axis.getTicksCoords(); + + var prevX = axis.toGlobalCoord(ticksCoords[0]); + var prevY = axis.toGlobalCoord(ticksCoords[0]); + + var splitAreaRects = []; + var count = 0; + + var areaInterval = getInterval(splitAreaModel, labelInterval); + + areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors]; + + for (var i = 1; i < ticksCoords.length; i++) { + if (ifIgnoreOnTick(axis, i, areaInterval)) { + continue; + } + + var tickCoord = axis.toGlobalCoord(ticksCoords[i]); + + var x; + var y; + var width; + var height; + if (axis.isHorizontal()) { + x = prevX; + y = gridRect.y; + width = tickCoord - x; + height = gridRect.height; + } + else { + x = gridRect.x; + y = prevY; + width = gridRect.width; + height = tickCoord - y; + } + + var colorIndex = (count++) % areaColors.length; + splitAreaRects[colorIndex] = splitAreaRects[colorIndex] || []; + splitAreaRects[colorIndex].push(new graphic.Rect({ + shape: { + x: x, + y: y, + width: width, + height: height + }, + silent: true + })); + + prevX = x + width; + prevY = y + height; + } + + // Simple optimization + // Batching the rects if color are the same + var areaStyle = areaStyleModel.getAreaStyle(); + for (var i = 0; i < splitAreaRects.length; i++) { + this.group.add(graphic.mergePath(splitAreaRects[i], { + style: zrUtil.defaults({ + fill: areaColors[i % areaColors.length] + }, areaStyle), + silent: true + })); + } + } + }); + + AxisView.extend({ + type: 'xAxis' + }); + AxisView.extend({ + type: 'yAxis' + }); + + /** + * @inner + */ + function layoutAxis(gridModel, axisModel) { + var grid = gridModel.coordinateSystem; + var axis = axisModel.axis; + var layout = {}; + + var rawAxisPosition = axis.position; + var axisPosition = axis.onZero ? 'onZero' : rawAxisPosition; + var axisDim = axis.dim; + + // [left, right, top, bottom] + var rect = grid.getRect(); + var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height]; + + var posMap = { + x: {top: rectBound[2], bottom: rectBound[3]}, + y: {left: rectBound[0], right: rectBound[1]} + }; + posMap.x.onZero = Math.max(Math.min(getZero('y'), posMap.x.bottom), posMap.x.top); + posMap.y.onZero = Math.max(Math.min(getZero('x'), posMap.y.right), posMap.y.left); + + function getZero(dim, val) { + var theAxis = grid.getAxis(dim); + return theAxis.toGlobalCoord(theAxis.dataToCoord(0)); + } + + // Axis position + layout.position = [ + axisDim === 'y' ? posMap.y[axisPosition] : rectBound[0], + axisDim === 'x' ? posMap.x[axisPosition] : rectBound[3] + ]; + + // Axis rotation + var r = {x: 0, y: 1}; + layout.rotation = Math.PI / 2 * r[axisDim]; + + // Tick and label direction, x y is axisDim + var dirMap = {top: -1, bottom: 1, left: -1, right: 1}; + + layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition]; + if (axis.onZero) { + layout.labelOffset = posMap[axisDim][rawAxisPosition] - posMap[axisDim].onZero; + } + + if (axisModel.getModel('axisTick').get('inside')) { + layout.tickDirection = -layout.tickDirection; + } + if (axisModel.getModel('axisLabel').get('inside')) { + layout.labelDirection = -layout.labelDirection; + } + + // Special label rotation + var labelRotation = axisModel.getModel('axisLabel').get('rotate'); + layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation; + + // label interval when auto mode. + layout.labelInterval = axis.getLabelInterval(); + + // Over splitLine and splitArea + layout.z2 = 1; + + return layout; + } + + +/***/ }, +/* 126 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + var Model = __webpack_require__(8); + var numberUtil = __webpack_require__(7); + var remRadian = numberUtil.remRadian; + var isRadianAroundZero = numberUtil.isRadianAroundZero; + + var PI = Math.PI; + + /** + * A final axis is translated and rotated from a "standard axis". + * So opt.position and opt.rotation is required. + * + * A standard axis is and axis from [0, 0] to [0, axisExtent[1]], + * for example: (0, 0) ------------> (0, 50) + * + * nameDirection or tickDirection or labelDirection is 1 means tick + * or label is below the standard axis, whereas is -1 means above + * the standard axis. labelOffset means offset between label and axis, + * which is useful when 'onZero', where axisLabel is in the grid and + * label in outside grid. + * + * Tips: like always, + * positive rotation represents anticlockwise, and negative rotation + * represents clockwise. + * The direction of position coordinate is the same as the direction + * of screen coordinate. + * + * Do not need to consider axis 'inverse', which is auto processed by + * axis extent. + * + * @param {module:zrender/container/Group} group + * @param {Object} axisModel + * @param {Object} opt Standard axis parameters. + * @param {Array.} opt.position [x, y] + * @param {number} opt.rotation by radian + * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'. + * @param {number} [opt.tickDirection=1] 1 or -1 + * @param {number} [opt.labelDirection=1] 1 or -1 + * @param {number} [opt.labelOffset=0] Usefull when onZero. + * @param {string} [opt.axisName] default get from axisModel. + * @param {number} [opt.labelRotation] by degree, default get from axisModel. + * @param {number} [opt.labelInterval] Default label interval when label + * interval from model is null or 'auto'. + * @param {number} [opt.strokeContainThreshold] Default label interval when label + * @param {number} [opt.silent=true] + */ + var AxisBuilder = function (axisModel, opt) { + + /** + * @readOnly + */ + this.opt = opt; + + /** + * @readOnly + */ + this.axisModel = axisModel; + + // Default value + zrUtil.defaults( + opt, + { + labelOffset: 0, + nameDirection: 1, + tickDirection: 1, + labelDirection: 1, + silent: true + } + ); + + /** + * @readOnly + */ + this.group = new graphic.Group({ + position: opt.position.slice(), + rotation: opt.rotation + }); + }; + + AxisBuilder.prototype = { + + constructor: AxisBuilder, + + hasBuilder: function (name) { + return !!builders[name]; + }, + + add: function (name) { + builders[name].call(this); + }, + + getGroup: function () { + return this.group; + } + + }; + + var builders = { + + /** + * @private + */ + axisLine: function () { + var opt = this.opt; + var axisModel = this.axisModel; + + if (!axisModel.get('axisLine.show')) { + return; + } + + var extent = this.axisModel.axis.getExtent(); + + this.group.add(new graphic.Line({ + shape: { + x1: extent[0], + y1: 0, + x2: extent[1], + y2: 0 + }, + style: zrUtil.extend( + {lineCap: 'round'}, + axisModel.getModel('axisLine.lineStyle').getLineStyle() + ), + strokeContainThreshold: opt.strokeContainThreshold, + silent: !!opt.silent, + z2: 1 + })); + }, + + /** + * @private + */ + axisTick: function () { + var axisModel = this.axisModel; + + if (!axisModel.get('axisTick.show')) { + return; + } + + var axis = axisModel.axis; + var tickModel = axisModel.getModel('axisTick'); + var opt = this.opt; + + var lineStyleModel = tickModel.getModel('lineStyle'); + var tickLen = tickModel.get('length'); + var tickInterval = getInterval(tickModel, opt.labelInterval); + var ticksCoords = axis.getTicksCoords(); + var tickLines = []; + + for (var i = 0; i < ticksCoords.length; i++) { + // Only ordinal scale support tick interval + if (ifIgnoreOnTick(axis, i, tickInterval)) { + continue; + } + + var tickCoord = ticksCoords[i]; + + // Tick line + tickLines.push(new graphic.Line(graphic.subPixelOptimizeLine({ + shape: { + x1: tickCoord, + y1: 0, + x2: tickCoord, + y2: opt.tickDirection * tickLen + }, + style: { + lineWidth: lineStyleModel.get('width') + }, + silent: true + }))); + } + + this.group.add(graphic.mergePath(tickLines, { + style: lineStyleModel.getLineStyle(), + z2: 2, + silent: true + })); + }, + + /** + * @param {module:echarts/coord/cartesian/AxisModel} axisModel + * @param {module:echarts/coord/cartesian/GridModel} gridModel + * @private + */ + axisLabel: function () { + var axisModel = this.axisModel; + + if (!axisModel.get('axisLabel.show')) { + return; + } + + var opt = this.opt; + var axis = axisModel.axis; + var labelModel = axisModel.getModel('axisLabel'); + var textStyleModel = labelModel.getModel('textStyle'); + var labelMargin = labelModel.get('margin'); + var ticks = axis.scale.getTicks(); + var labels = axisModel.getFormattedLabels(); + + // Special label rotate. + var labelRotation = opt.labelRotation; + if (labelRotation == null) { + labelRotation = labelModel.get('rotate') || 0; + } + // To radian. + labelRotation = labelRotation * PI / 180; + + var labelLayout = innerTextLayout(opt, labelRotation, opt.labelDirection); + var categoryData = axisModel.get('data'); + + var textEls = []; + for (var i = 0; i < ticks.length; i++) { + if (ifIgnoreOnTick(axis, i, opt.labelInterval)) { + continue; + } + + var itemTextStyleModel = textStyleModel; + if (categoryData && categoryData[i] && categoryData[i].textStyle) { + itemTextStyleModel = new Model( + categoryData[i].textStyle, textStyleModel, axisModel.ecModel + ); + } + + var tickCoord = axis.dataToCoord(ticks[i]); + var pos = [ + tickCoord, + opt.labelOffset + opt.labelDirection * labelMargin + ]; + + var textEl = new graphic.Text({ + style: { + text: labels[i], + textAlign: itemTextStyleModel.get('align', true) || labelLayout.textAlign, + textVerticalAlign: itemTextStyleModel.get('baseline', true) || labelLayout.verticalAlign, + textFont: itemTextStyleModel.getFont(), + fill: itemTextStyleModel.getTextColor() + }, + position: pos, + rotation: labelLayout.rotation, + silent: true, + z2: 10 + }); + textEls.push(textEl); + this.group.add(textEl); + } + + function isTwoLabelOverlapped(current, next) { + var firstRect = current && current.getBoundingRect().clone(); + var nextRect = next && next.getBoundingRect().clone(); + if (firstRect && nextRect) { + firstRect.applyTransform(current.getLocalTransform()); + nextRect.applyTransform(next.getLocalTransform()); + return firstRect.intersect(nextRect); + } + } + if (axis.type !== 'category') { + // If min or max are user set, we need to check + // If the tick on min(max) are overlap on their neighbour tick + // If they are overlapped, we need to hide the min(max) tick label + if (axisModel.getMin ? axisModel.getMin() : axisModel.get('min')) { + var firstLabel = textEls[0]; + var nextLabel = textEls[1]; + if (isTwoLabelOverlapped(firstLabel, nextLabel)) { + firstLabel.ignore = true; + } + } + if (axisModel.getMax ? axisModel.getMax() : axisModel.get('max')) { + var lastLabel = textEls[textEls.length - 1]; + var prevLabel = textEls[textEls.length - 2]; + if (isTwoLabelOverlapped(prevLabel, lastLabel)) { + lastLabel.ignore = true; + } + } + } + }, + + /** + * @private + */ + axisName: function () { + var opt = this.opt; + var axisModel = this.axisModel; + + var name = this.opt.axisName; + // If name is '', do not get name from axisMode. + if (name == null) { + name = axisModel.get('name'); + } + + if (!name) { + return; + } + + var nameLocation = axisModel.get('nameLocation'); + var nameDirection = opt.nameDirection; + var textStyleModel = axisModel.getModel('nameTextStyle'); + var gap = axisModel.get('nameGap') || 0; + + var extent = this.axisModel.axis.getExtent(); + var gapSignal = extent[0] > extent[1] ? -1 : 1; + var pos = [ + nameLocation === 'start' + ? extent[0] - gapSignal * gap + : nameLocation === 'end' + ? extent[1] + gapSignal * gap + : (extent[0] + extent[1]) / 2, // 'middle' + // Reuse labelOffset. + nameLocation === 'middle' ? opt.labelOffset + nameDirection * gap : 0 + ]; + + var labelLayout; + + if (nameLocation === 'middle') { + labelLayout = innerTextLayout(opt, opt.rotation, nameDirection); + } + else { + labelLayout = endTextLayout(opt, nameLocation, extent); + } + + this.group.add(new graphic.Text({ + style: { + text: name, + textFont: textStyleModel.getFont(), + fill: textStyleModel.getTextColor() + || axisModel.get('axisLine.lineStyle.color'), + textAlign: labelLayout.textAlign, + textVerticalAlign: labelLayout.verticalAlign + }, + position: pos, + rotation: labelLayout.rotation, + silent: true, + z2: 1 + })); + } + + }; + + /** + * @inner + */ + function innerTextLayout(opt, textRotation, direction) { + var rotationDiff = remRadian(textRotation - opt.rotation); + var textAlign; + var verticalAlign; + + if (isRadianAroundZero(rotationDiff)) { // Label is parallel with axis line. + verticalAlign = direction > 0 ? 'top' : 'bottom'; + textAlign = 'center'; + } + else if (isRadianAroundZero(rotationDiff - PI)) { // Label is inverse parallel with axis line. + verticalAlign = direction > 0 ? 'bottom' : 'top'; + textAlign = 'center'; + } + else { + verticalAlign = 'middle'; + + if (rotationDiff > 0 && rotationDiff < PI) { + textAlign = direction > 0 ? 'right' : 'left'; + } + else { + textAlign = direction > 0 ? 'left' : 'right'; + } + } + + return { + rotation: rotationDiff, + textAlign: textAlign, + verticalAlign: verticalAlign + }; + } + + /** + * @inner + */ + function endTextLayout(opt, textPosition, extent) { + var rotationDiff = remRadian(-opt.rotation); + var textAlign; + var verticalAlign; + var inverse = extent[0] > extent[1]; + var onLeft = (textPosition === 'start' && !inverse) + || (textPosition !== 'start' && inverse); + + if (isRadianAroundZero(rotationDiff - PI / 2)) { + verticalAlign = onLeft ? 'bottom' : 'top'; + textAlign = 'center'; + } + else if (isRadianAroundZero(rotationDiff - PI * 1.5)) { + verticalAlign = onLeft ? 'top' : 'bottom'; + textAlign = 'center'; + } + else { + verticalAlign = 'middle'; + if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) { + textAlign = onLeft ? 'left' : 'right'; + } + else { + textAlign = onLeft ? 'right' : 'left'; + } + } + + return { + rotation: rotationDiff, + textAlign: textAlign, + verticalAlign: verticalAlign + }; + } + + /** + * @static + */ + var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (axis, i, interval) { + var rawTick; + var scale = axis.scale; + return scale.type === 'ordinal' + && ( + typeof interval === 'function' + ? ( + rawTick = scale.getTicks()[i], + !interval(rawTick, scale.getLabel(rawTick)) + ) + : i % (interval + 1) + ); + }; + + /** + * @static + */ + var getInterval = AxisBuilder.getInterval = function (model, labelInterval) { + var interval = model.get('interval'); + if (interval == null || interval == 'auto') { + interval = labelInterval; + } + return interval; + }; + + module.exports = AxisBuilder; + + + +/***/ }, +/* 127 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + + __webpack_require__(107); + + __webpack_require__(128); + __webpack_require__(129); + + var barLayoutGrid = __webpack_require__(131); + var echarts = __webpack_require__(1); + + echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar')); + // Visual coding for legend + echarts.registerVisualCoding('chart', function (ecModel) { + ecModel.eachSeriesByType('bar', function (seriesModel) { + var data = seriesModel.getData(); + data.setVisual('legendSymbol', 'roundRect'); + }); + }); + + // In case developer forget to include grid component + __webpack_require__(106); + + +/***/ }, +/* 128 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var SeriesModel = __webpack_require__(27); + var createListFromArray = __webpack_require__(93); + + module.exports = SeriesModel.extend({ + + type: 'series.bar', + + dependencies: ['grid', 'polar'], + + getInitialData: function (option, ecModel) { + return createListFromArray(option.data, this, ecModel); + }, + + getMarkerPosition: function (value) { + var coordSys = this.coordinateSystem; + if (coordSys) { + var pt = coordSys.dataToPoint(value); + var data = this.getData(); + var offset = data.getLayout('offset'); + var size = data.getLayout('size'); + var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1; + pt[offsetIndex] += offset + size / 2; + return pt; + } + return [NaN, NaN]; + }, + + defaultOption: { + zlevel: 0, // 一级层叠 + z: 2, // 二级层叠 + coordinateSystem: 'cartesian2d', + legendHoverLink: true, + // stack: null + + // Cartesian coordinate system + xAxisIndex: 0, + yAxisIndex: 0, + + // 最小高度改为0 + barMinHeight: 0, + + // barMaxWidth: null, + // 默认自适应 + // barWidth: null, + // 柱间距离,默认为柱形宽度的30%,可设固定值 + // barGap: '30%', + // 类目间柱形距离,默认为类目间距的20%,可设固定值 + // barCategoryGap: '20%', + // label: { + // normal: { + // show: false + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + + // // 默认自适应,水平布局为'top',垂直布局为'right',可选为 + // // 'inside' | 'insideleft' | 'insideTop' | 'insideRight' | 'insideBottom' | + // // 'outside' |'left' | 'right'|'top'|'bottom' + // position: + + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + // } + // }, + itemStyle: { + normal: { + // color: '各异', + // 柱条边线 + barBorderColor: '#fff', + // 柱条边线线宽,单位px,默认为1 + barBorderWidth: 0 + }, + emphasis: { + // color: '各异', + // 柱条边线 + barBorderColor: '#fff', + // 柱条边线线宽,单位px,默认为1 + barBorderWidth: 0 + } + } + } + }); + + +/***/ }, +/* 129 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var graphic = __webpack_require__(42); + + zrUtil.extend(__webpack_require__(8).prototype, __webpack_require__(130)); + + function fixLayoutWithLineWidth(layout, lineWidth) { + var signX = layout.width > 0 ? 1 : -1; + var signY = layout.height > 0 ? 1 : -1; + // In case width or height are too small. + lineWidth = Math.min(lineWidth, Math.abs(layout.width), Math.abs(layout.height)); + layout.x += signX * lineWidth / 2; + layout.y += signY * lineWidth / 2; + layout.width -= signX * lineWidth; + layout.height -= signY * lineWidth; + } + + module.exports = __webpack_require__(1).extendChartView({ + + type: 'bar', + + render: function (seriesModel, ecModel, api) { + var coordinateSystemType = seriesModel.get('coordinateSystem'); + + if (coordinateSystemType === 'cartesian2d') { + this._renderOnCartesian(seriesModel, ecModel, api); + } + + return this.group; + }, + + _renderOnCartesian: function (seriesModel, ecModel, api) { + var group = this.group; + var data = seriesModel.getData(); + var oldData = this._data; + + var cartesian = seriesModel.coordinateSystem; + var baseAxis = cartesian.getBaseAxis(); + var isHorizontal = baseAxis.isHorizontal(); + + var enableAnimation = seriesModel.get('animation'); + + var barBorderWidthQuery = ['itemStyle', 'normal', 'barBorderWidth']; + + function createRect(dataIndex, isUpdate) { + var layout = data.getItemLayout(dataIndex); + var lineWidth = data.getItemModel(dataIndex).get(barBorderWidthQuery) || 0; + fixLayoutWithLineWidth(layout, lineWidth); + + var rect = new graphic.Rect({ + shape: zrUtil.extend({}, layout) + }); + // Animation + if (enableAnimation) { + var rectShape = rect.shape; + var animateProperty = isHorizontal ? 'height' : 'width'; + var animateTarget = {}; + rectShape[animateProperty] = 0; + animateTarget[animateProperty] = layout[animateProperty]; + graphic[isUpdate? 'updateProps' : 'initProps'](rect, { + shape: animateTarget + }, seriesModel); + } + return rect; + } + data.diff(oldData) + .add(function (dataIndex) { + // 空数据 + if (!data.hasValue(dataIndex)) { + return; + } + + var rect = createRect(dataIndex); + + data.setItemGraphicEl(dataIndex, rect); + + group.add(rect); + + }) + .update(function (newIndex, oldIndex) { + var rect = oldData.getItemGraphicEl(oldIndex); + // 空数据 + if (!data.hasValue(newIndex)) { + group.remove(rect); + return; + } + if (!rect) { + rect = createRect(newIndex, true); + } + + var layout = data.getItemLayout(newIndex); + var lineWidth = data.getItemModel(newIndex).get(barBorderWidthQuery) || 0; + fixLayoutWithLineWidth(layout, lineWidth); + + graphic.updateProps(rect, { + shape: layout + }, seriesModel); + + data.setItemGraphicEl(newIndex, rect); + + // Add back + group.add(rect); + }) + .remove(function (idx) { + var rect = oldData.getItemGraphicEl(idx); + if (rect) { + // Not show text when animating + rect.style.text = ''; + graphic.updateProps(rect, { + shape: { + width: 0 + } + }, seriesModel, function () { + group.remove(rect); + }); + } + }) + .execute(); + + this._updateStyle(seriesModel, data, isHorizontal); + + this._data = data; + }, + + _updateStyle: function (seriesModel, data, isHorizontal) { + function setLabel(style, model, color, labelText, labelPositionOutside) { + graphic.setText(style, model, color); + style.text = labelText; + if (style.textPosition === 'outside') { + style.textPosition = labelPositionOutside; + } + } + + data.eachItemGraphicEl(function (rect, idx) { + var itemModel = data.getItemModel(idx); + var color = data.getItemVisual(idx, 'color'); + var layout = data.getItemLayout(idx); + var itemStyleModel = itemModel.getModel('itemStyle.normal'); + + var hoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle(); + + rect.setShape('r', itemStyleModel.get('barBorderRadius') || 0); + + rect.setStyle(zrUtil.defaults( + { + fill: color + }, + itemStyleModel.getBarItemStyle() + )); + + var labelPositionOutside = isHorizontal + ? (layout.height > 0 ? 'bottom' : 'top') + : (layout.width > 0 ? 'left' : 'right'); + + var labelModel = itemModel.getModel('label.normal'); + var hoverLabelModel = itemModel.getModel('label.emphasis'); + var rectStyle = rect.style; + if (labelModel.get('show')) { + setLabel( + rectStyle, labelModel, color, + zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'normal'), + seriesModel.getRawValue(idx) + ), + labelPositionOutside + ); + } + else { + rectStyle.text = ''; + } + if (hoverLabelModel.get('show')) { + setLabel( + hoverStyle, hoverLabelModel, color, + zrUtil.retrieve( + seriesModel.getFormattedLabel(idx, 'emphasis'), + seriesModel.getRawValue(idx) + ), + labelPositionOutside + ); + } + else { + hoverStyle.text = ''; + } + graphic.setHoverStyle(rect, hoverStyle); + }); + }, + + remove: function (ecModel, api) { + var group = this.group; + if (ecModel.get('animation')) { + if (this._data) { + this._data.eachItemGraphicEl(function (el) { + // Not show text when animating + el.style.text = ''; + graphic.updateProps(el, { + shape: { + width: 0 + } + }, ecModel, function () { + group.remove(el); + }); + }); + } + } + else { + group.removeAll(); + } + } + }); + + +/***/ }, +/* 130 */ +/***/ function(module, exports, __webpack_require__) { + + + module.exports = { + getBarItemStyle: __webpack_require__(11)( + [ + ['fill', 'color'], + ['stroke', 'barBorderColor'], + ['lineWidth', 'barBorderWidth'], + ['opacity'], + ['shadowBlur'], + ['shadowOffsetX'], + ['shadowOffsetY'], + ['shadowColor'] + ] + ) + }; + + +/***/ }, +/* 131 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var zrUtil = __webpack_require__(3); + var numberUtil = __webpack_require__(7); + var parsePercent = numberUtil.parsePercent; + + function getSeriesStackId(seriesModel) { + return seriesModel.get('stack') || '__ec_stack_' + seriesModel.seriesIndex; + } + + function calBarWidthAndOffset(barSeries, api) { + // Columns info on each category axis. Key is cartesian name + var columnsMap = {}; + + zrUtil.each(barSeries, function (seriesModel, idx) { + var cartesian = seriesModel.coordinateSystem; + + var baseAxis = cartesian.getBaseAxis(); + + var columnsOnAxis = columnsMap[baseAxis.index] || { + remainedWidth: baseAxis.getBandWidth(), + autoWidthCount: 0, + categoryGap: '20%', + gap: '30%', + axis: baseAxis, + stacks: {} + }; + var stacks = columnsOnAxis.stacks; + columnsMap[baseAxis.index] = columnsOnAxis; + + var stackId = getSeriesStackId(seriesModel); + + if (!stacks[stackId]) { + columnsOnAxis.autoWidthCount++; + } + stacks[stackId] = stacks[stackId] || { + width: 0, + maxWidth: 0 + }; + + var barWidth = seriesModel.get('barWidth'); + var barMaxWidth = seriesModel.get('barMaxWidth'); + var barGap = seriesModel.get('barGap'); + var barCategoryGap = seriesModel.get('barCategoryGap'); + // TODO + if (barWidth && ! stacks[stackId].width) { + barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth); + stacks[stackId].width = barWidth; + columnsOnAxis.remainedWidth -= barWidth; + } + + barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth); + (barGap != null) && (columnsOnAxis.gap = barGap); + (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap); + }); + + var result = {}; + + zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) { + + result[coordSysName] = {}; + + var stacks = columnsOnAxis.stacks; + var baseAxis = columnsOnAxis.axis; + var bandWidth = baseAxis.getBandWidth(); + var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth); + var barGapPercent = parsePercent(columnsOnAxis.gap, 1); + + var remainedWidth = columnsOnAxis.remainedWidth; + var autoWidthCount = columnsOnAxis.autoWidthCount; + var autoWidth = (remainedWidth - categoryGap) + / (autoWidthCount + (autoWidthCount - 1) * barGapPercent); + autoWidth = Math.max(autoWidth, 0); + + // Find if any auto calculated bar exceeded maxBarWidth + zrUtil.each(stacks, function (column, stack) { + var maxWidth = column.maxWidth; + if (!column.width && maxWidth && maxWidth < autoWidth) { + maxWidth = Math.min(maxWidth, remainedWidth); + remainedWidth -= maxWidth; + column.width = maxWidth; + autoWidthCount--; + } + }); + + // Recalculate width again + autoWidth = (remainedWidth - categoryGap) + / (autoWidthCount + (autoWidthCount - 1) * barGapPercent); + autoWidth = Math.max(autoWidth, 0); + + var widthSum = 0; + var lastColumn; + zrUtil.each(stacks, function (column, idx) { + if (!column.width) { + column.width = autoWidth; + } + lastColumn = column; + widthSum += column.width * (1 + barGapPercent); + }); + if (lastColumn) { + widthSum -= lastColumn.width * barGapPercent; + } + + var offset = -widthSum / 2; + zrUtil.each(stacks, function (column, stackId) { + result[coordSysName][stackId] = result[coordSysName][stackId] || { + offset: offset, + width: column.width + }; + + offset += column.width * (1 + barGapPercent); + }); + }); + + return result; + } + + /** + * @param {string} seriesType + * @param {module:echarts/model/Global} ecModel + * @param {module:echarts/ExtensionAPI} api + */ + function barLayoutGrid(seriesType, ecModel, api) { + + var barWidthAndOffset = calBarWidthAndOffset( + zrUtil.filter( + ecModel.getSeriesByType(seriesType), + function (seriesModel) { + return !ecModel.isSeriesFiltered(seriesModel) + && seriesModel.coordinateSystem + && seriesModel.coordinateSystem.type === 'cartesian2d'; + } + ) + ); + + var lastStackCoords = {}; + + ecModel.eachSeriesByType(seriesType, function (seriesModel) { + + var data = seriesModel.getData(); + var cartesian = seriesModel.coordinateSystem; + var baseAxis = cartesian.getBaseAxis(); + + var stackId = getSeriesStackId(seriesModel); + var columnLayoutInfo = barWidthAndOffset[baseAxis.index][stackId]; + var columnOffset = columnLayoutInfo.offset; + var columnWidth = columnLayoutInfo.width; + var valueAxis = cartesian.getOtherAxis(baseAxis); + + var barMinHeight = seriesModel.get('barMinHeight') || 0; + + var valueAxisStart = baseAxis.onZero + ? valueAxis.toGlobalCoord(valueAxis.dataToCoord(0)) + : valueAxis.getGlobalExtent()[0]; + + var coords = cartesian.dataToPoints(data, true); + lastStackCoords[stackId] = lastStackCoords[stackId] || []; + + data.setLayout({ + offset: columnOffset, + size: columnWidth + }); + data.each(valueAxis.dim, function (value, idx) { + // 空数据 + if (isNaN(value)) { + return; + } + if (!lastStackCoords[stackId][idx]) { + lastStackCoords[stackId][idx] = { + // Positive stack + p: valueAxisStart, + // Negative stack + n: valueAxisStart + }; + } + var sign = value >= 0 ? 'p' : 'n'; + var coord = coords[idx]; + var lastCoord = lastStackCoords[stackId][idx][sign]; + var x, y, width, height; + if (valueAxis.isHorizontal()) { + x = lastCoord; + y = coord[1] + columnOffset; + width = coord[0] - lastCoord; + height = columnWidth; + + if (Math.abs(width) < barMinHeight) { + width = (width < 0 ? -1 : 1) * barMinHeight; + } + lastStackCoords[stackId][idx][sign] += width; + } + else { + x = coord[0] + columnOffset; + y = lastCoord; + width = columnWidth; + height = coord[1] - lastCoord; + if (Math.abs(height) < barMinHeight) { + // Include zero to has a positive bar + height = (height <= 0 ? -1 : 1) * barMinHeight; + } + lastStackCoords[stackId][idx][sign] += height; + } + + data.setItemLayout(idx, { + x: x, + y: y, + width: width, + height: height + }); + }, true); + + }, this); + } + + module.exports = barLayoutGrid; + + +/***/ }, +/* 132 */ +/***/ function(module, exports, __webpack_require__) { + + + + var zrUtil = __webpack_require__(3); + var echarts = __webpack_require__(1); + + __webpack_require__(133); + __webpack_require__(135); + + __webpack_require__(136)('pie', [{ + type: 'pieToggleSelect', + event: 'pieselectchanged', + method: 'toggleSelected' + }, { + type: 'pieSelect', + event: 'pieselected', + method: 'select' + }, { + type: 'pieUnSelect', + event: 'pieunselected', + method: 'unSelect' + }]); + + echarts.registerVisualCoding( + 'chart', zrUtil.curry(__webpack_require__(137), 'pie') + ); + + echarts.registerLayout(zrUtil.curry( + __webpack_require__(138), 'pie' + )); + + echarts.registerProcessor( + 'filter', zrUtil.curry(__webpack_require__(140), 'pie') + ); + + +/***/ }, +/* 133 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + var List = __webpack_require__(94); + var zrUtil = __webpack_require__(3); + var modelUtil = __webpack_require__(5); + var completeDimensions = __webpack_require__(96); + + var dataSelectableMixin = __webpack_require__(134); + + var PieSeries = __webpack_require__(1).extendSeriesModel({ + + type: 'series.pie', + + // Overwrite + init: function (option) { + PieSeries.superApply(this, 'init', arguments); + + // Enable legend selection for each data item + // Use a function instead of direct access because data reference may changed + this.legendDataProvider = function () { + return this._dataBeforeProcessed; + }; + + this.updateSelectedMap(); + + this._defaultLabelLine(option); + }, + + // Overwrite + mergeOption: function (newOption) { + PieSeries.superCall(this, 'mergeOption', newOption); + this.updateSelectedMap(); + }, + + getInitialData: function (option, ecModel) { + var dimensions = completeDimensions(['value'], option.data); + var list = new List(dimensions, this); + list.initData(option.data); + return list; + }, + + // Overwrite + getDataParams: function (dataIndex) { + var data = this._data; + var params = PieSeries.superCall(this, 'getDataParams', dataIndex); + var sum = data.getSum('value'); + // FIXME toFixed? + // + // Percent is 0 if sum is 0 + params.percent = !sum ? 0 : +(data.get('value', dataIndex) / sum * 100).toFixed(2); + + params.$vars.push('percent'); + return params; + }, + + _defaultLabelLine: function (option) { + // Extend labelLine emphasis + modelUtil.defaultEmphasis(option.labelLine, ['show']); + + var labelLineNormalOpt = option.labelLine.normal; + var labelLineEmphasisOpt = option.labelLine.emphasis; + // Not show label line if `label.normal.show = false` + labelLineNormalOpt.show = labelLineNormalOpt.show + && option.label.normal.show; + labelLineEmphasisOpt.show = labelLineEmphasisOpt.show + && option.label.emphasis.show; + }, + + defaultOption: { + zlevel: 0, + z: 2, + legendHoverLink: true, + + hoverAnimation: true, + // 默认全局居中 + center: ['50%', '50%'], + radius: [0, '75%'], + // 默认顺时针 + clockwise: true, + startAngle: 90, + // 最小角度改为0 + minAngle: 0, + // 选中是扇区偏移量 + selectedOffset: 10, + + // If use strategy to avoid label overlapping + avoidLabelOverlap: true, + // 选择模式,默认关闭,可选single,multiple + // selectedMode: false, + // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积) + // roseType: null, + + label: { + normal: { + // If rotate around circle + rotate: false, + show: true, + // 'outer', 'inside', 'center' + position: 'outer' + // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 + // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE + // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数 + }, + emphasis: {} + }, + // Enabled when label.normal.position is 'outer' + labelLine: { + normal: { + show: true, + // 引导线两段中的第一段长度 + length: 20, + // 引导线两段中的第二段长度 + length2: 5, + smooth: false, + lineStyle: { + // color: 各异, + width: 1, + type: 'solid' + } + } + }, + itemStyle: { + normal: { + // color: 各异, + borderColor: 'rgba(0,0,0,0)', + borderWidth: 1 + }, + emphasis: { + // color: 各异, + borderColor: 'rgba(0,0,0,0)', + borderWidth: 1 + } + }, + + animationEasing: 'cubicOut', + + data: [] + } + }); + + zrUtil.mixin(PieSeries, dataSelectableMixin); + + module.exports = PieSeries; + + +/***/ }, +/* 134 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Data selectable mixin for chart series. + * To eanble data select, option of series must have `selectedMode`. + * And each data item will use `selected` to toggle itself selected status + * + * @module echarts/chart/helper/DataSelectable + */ + + + var zrUtil = __webpack_require__(3); + + module.exports = { + + updateSelectedMap: function () { + var option = this.option; + this._dataOptMap = zrUtil.reduce(option.data, function (dataOptMap, dataOpt) { + dataOptMap[dataOpt.name] = dataOpt; + return dataOptMap; + }, {}); + }, + /** + * @param {string} name + */ + // PENGING If selectedMode is null ? + select: function (name) { + var dataOptMap = this._dataOptMap; + var dataOpt = dataOptMap[name]; + var selectedMode = this.get('selectedMode'); + if (selectedMode === 'single') { + zrUtil.each(dataOptMap, function (dataOpt) { + dataOpt.selected = false; + }); + } + dataOpt && (dataOpt.selected = true); + }, + + /** + * @param {string} name + */ + unSelect: function (name) { + var dataOpt = this._dataOptMap[name]; + // var selectedMode = this.get('selectedMode'); + // selectedMode !== 'single' && dataOpt && (dataOpt.selected = false); + dataOpt && (dataOpt.selected = false); + }, + + /** + * @param {string} name + */ + toggleSelected: function (name) { + var dataOpt = this._dataOptMap[name]; + if (dataOpt != null) { + this[dataOpt.selected ? 'unSelect' : 'select'](name); + return dataOpt.selected; + } + }, + + /** + * @param {string} name + */ + isSelected: function (name) { + var dataOpt = this._dataOptMap[name]; + return dataOpt && dataOpt.selected; + } + }; + + +/***/ }, +/* 135 */ +/***/ function(module, exports, __webpack_require__) { + + + + var graphic = __webpack_require__(42); + var zrUtil = __webpack_require__(3); + + /** + * @param {module:echarts/model/Series} seriesModel + * @param {boolean} hasAnimation + * @inner + */ + function updateDataSelected(uid, seriesModel, hasAnimation, api) { + var data = seriesModel.getData(); + var dataIndex = this.dataIndex; + var name = data.getName(dataIndex); + var selectedOffset = seriesModel.get('selectedOffset'); + + api.dispatchAction({ + type: 'pieToggleSelect', + from: uid, + name: name, + seriesId: seriesModel.id + }); + + data.each(function (idx) { + toggleItemSelected( + data.getItemGraphicEl(idx), + data.getItemLayout(idx), + seriesModel.isSelected(data.getName(idx)), + selectedOffset, + hasAnimation + ); + }); + } + + /** + * @param {module:zrender/graphic/Sector} el + * @param {Object} layout + * @param {boolean} isSelected + * @param {number} selectedOffset + * @param {boolean} hasAnimation + * @inner + */ + function toggleItemSelected(el, layout, isSelected, selectedOffset, hasAnimation) { + var midAngle = (layout.startAngle + layout.endAngle) / 2; + + var dx = Math.cos(midAngle); + var dy = Math.sin(midAngle); + + var offset = isSelected ? selectedOffset : 0; + var position = [dx * offset, dy * offset]; + + hasAnimation + // animateTo will stop revious animation like update transition + ? el.animate() + .when(200, { + position: position + }) + .start('bounceOut') + : el.attr('position', position); + } + + /** + * Piece of pie including Sector, Label, LabelLine + * @constructor + * @extends {module:zrender/graphic/Group} + */ + function PiePiece(data, idx) { + + graphic.Group.call(this); + + var sector = new graphic.Sector({ + z2: 2 + }); + var polyline = new graphic.Polyline(); + var text = new graphic.Text(); + this.add(sector); + this.add(polyline); + this.add(text); + + this.updateData(data, idx, true); + + // Hover to change label and labelLine + function onEmphasis() { + polyline.ignore = polyline.hoverIgnore; + text.ignore = text.hoverIgnore; + } + function onNormal() { + polyline.ignore = polyline.normalIgnore; + text.ignore = text.normalIgnore; + } + this.on('emphasis', onEmphasis) + .on('normal', onNormal) + .on('mouseover', onEmphasis) + .on('mouseout', onNormal); + } + + var piePieceProto = PiePiece.prototype; + + function getLabelStyle(data, idx, state, labelModel, labelPosition) { + var textStyleModel = labelModel.getModel('textStyle'); + var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner'; + return { + fill: textStyleModel.getTextColor() + || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')), + textFont: textStyleModel.getFont(), + text: zrUtil.retrieve( + data.hostModel.getFormattedLabel(idx, state), data.getName(idx) + ) + }; + } + + piePieceProto.updateData = function (data, idx, firstCreate) { + + var sector = this.childAt(0); + + var seriesModel = data.hostModel; + var itemModel = data.getItemModel(idx); + var layout = data.getItemLayout(idx); + var sectorShape = zrUtil.extend({}, layout); + sectorShape.label = null; + if (firstCreate) { + sector.setShape(sectorShape); + sector.shape.endAngle = layout.startAngle; + graphic.updateProps(sector, { + shape: { + endAngle: layout.endAngle + } + }, seriesModel); + } + else { + graphic.updateProps(sector, { + shape: sectorShape + }, seriesModel); + } + + // Update common style + var itemStyleModel = itemModel.getModel('itemStyle'); + var visualColor = data.getItemVisual(idx, 'color'); + + sector.setStyle( + zrUtil.defaults( + { + fill: visualColor + }, + itemStyleModel.getModel('normal').getItemStyle() + ) + ); + sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle(); + + // Toggle selected + toggleItemSelected( + this, + data.getItemLayout(idx), + itemModel.get('selected'), + seriesModel.get('selectedOffset'), + seriesModel.get('animation') + ); + + function onEmphasis() { + // Sector may has animation of updating data. Force to move to the last frame + // Or it may stopped on the wrong shape + sector.stopAnimation(true); + sector.animateTo({ + shape: { + r: layout.r + 10 + } + }, 300, 'elasticOut'); + } + function onNormal() { + sector.stopAnimation(true); + sector.animateTo({ + shape: { + r: layout.r + } + }, 300, 'elasticOut'); + } + sector.off('mouseover').off('mouseout').off('emphasis').off('normal'); + if (itemModel.get('hoverAnimation')) { + sector + .on('mouseover', onEmphasis) + .on('mouseout', onNormal) + .on('emphasis', onEmphasis) + .on('normal', onNormal); + } + + this._updateLabel(data, idx); + + graphic.setHoverStyle(this); + }; + + piePieceProto._updateLabel = function (data, idx) { + + var labelLine = this.childAt(1); + var labelText = this.childAt(2); + + var seriesModel = data.hostModel; + var itemModel = data.getItemModel(idx); + var layout = data.getItemLayout(idx); + var labelLayout = layout.label; + var visualColor = data.getItemVisual(idx, 'color'); + + graphic.updateProps(labelLine, { + shape: { + points: labelLayout.linePoints || [ + [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y] + ] + } + }, seriesModel); + + graphic.updateProps(labelText, { + style: { + x: labelLayout.x, + y: labelLayout.y + } + }, seriesModel); + labelText.attr({ + style: { + textVerticalAlign: labelLayout.verticalAlign, + textAlign: labelLayout.textAlign, + textFont: labelLayout.font + }, + rotation: labelLayout.rotation, + origin: [labelLayout.x, labelLayout.y], + z2: 10 + }); + + var labelModel = itemModel.getModel('label.normal'); + var labelHoverModel = itemModel.getModel('label.emphasis'); + var labelLineModel = itemModel.getModel('labelLine.normal'); + var labelLineHoverModel = itemModel.getModel('labelLine.emphasis'); + var labelPosition = labelModel.get('position') || labelHoverModel.get('position'); + + labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel, labelPosition)); + + labelText.ignore = labelText.normalIgnore = !labelModel.get('show'); + labelText.hoverIgnore = !labelHoverModel.get('show'); + + labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show'); + labelLine.hoverIgnore = !labelLineHoverModel.get('show'); + + // Default use item visual color + labelLine.setStyle({ + stroke: visualColor + }); + labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle()); + + labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel, labelPosition); + labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle(); + + var smooth = labelLineModel.get('smooth'); + if (smooth && smooth === true) { + smooth = 0.4; + } + labelLine.setShape({ + smooth: smooth + }); + }; + + zrUtil.inherits(PiePiece, graphic.Group); + + + // Pie view + var Pie = __webpack_require__(41).extend({ + + type: 'pie', + + init: function () { + var sectorGroup = new graphic.Group(); + this._sectorGroup = sectorGroup; + }, + + render: function (seriesModel, ecModel, api, payload) { + if (payload && (payload.from === this.uid)) { + return; + } + + var data = seriesModel.getData(); + var oldData = this._data; + var group = this.group; + + var hasAnimation = ecModel.get('animation'); + var isFirstRender = !oldData; + + var onSectorClick = zrUtil.curry( + updateDataSelected, this.uid, seriesModel, hasAnimation, api + ); + + var selectedMode = seriesModel.get('selectedMode'); + + data.diff(oldData) + .add(function (idx) { + var piePiece = new PiePiece(data, idx); + if (isFirstRender) { + piePiece.eachChild(function (child) { + child.stopAnimation(true); + }); + } + + selectedMode && piePiece.on('click', onSectorClick); + + data.setItemGraphicEl(idx, piePiece); + + group.add(piePiece); + }) + .update(function (newIdx, oldIdx) { + var piePiece = oldData.getItemGraphicEl(oldIdx); + + piePiece.updateData(data, newIdx); + + piePiece.off('click'); + selectedMode && piePiece.on('click', onSectorClick); + group.add(piePiece); + data.setItemGraphicEl(newIdx, piePiece); + }) + .remove(function (idx) { + var piePiece = oldData.getItemGraphicEl(idx); + group.remove(piePiece); + }) + .execute(); + + if (hasAnimation && isFirstRender && data.count() > 0) { + var shape = data.getItemLayout(0); + var r = Math.max(api.getWidth(), api.getHeight()) / 2; + + var removeClipPath = zrUtil.bind(group.removeClipPath, group); + group.setClipPath(this._createClipPath( + shape.cx, shape.cy, r, shape.startAngle, shape.clockwise, removeClipPath, seriesModel + )); + } + + this._data = data; + }, + + _createClipPath: function ( + cx, cy, r, startAngle, clockwise, cb, seriesModel + ) { + var clipPath = new graphic.Sector({ + shape: { + cx: cx, + cy: cy, + r0: 0, + r: r, + startAngle: startAngle, + endAngle: startAngle, + clockwise: clockwise + } + }); + + graphic.initProps(clipPath, { + shape: { + endAngle: startAngle + (clockwise ? 1 : -1) * Math.PI * 2 + } + }, seriesModel, cb); + + return clipPath; + } + }); + + module.exports = Pie; + + +/***/ }, +/* 136 */ +/***/ function(module, exports, __webpack_require__) { + + + var echarts = __webpack_require__(1); + var zrUtil = __webpack_require__(3); + module.exports = function (seriesType, actionInfos) { + zrUtil.each(actionInfos, function (actionInfo) { + actionInfo.update = 'updateView'; + /** + * @payload + * @property {string} seriesName + * @property {string} name + */ + echarts.registerAction(actionInfo, function (payload, ecModel) { + var selected = {}; + ecModel.eachComponent( + {mainType: 'series', subType: seriesType, query: payload}, + function (seriesModel) { + if (seriesModel[actionInfo.method]) { + seriesModel[actionInfo.method](payload.name); + } + var data = seriesModel.getData(); + // Create selected map + data.each(function (idx) { + var name = data.getName(idx); + selected[name] = seriesModel.isSelected(name) || false; + }); + } + ); + return { + name: payload.name, + selected: selected + }; + }); + }); + }; + + +/***/ }, +/* 137 */ +/***/ function(module, exports) { + + // Pick color from palette for each data item + + + module.exports = function (seriesType, ecModel) { + var globalColorList = ecModel.get('color'); + var offset = 0; + ecModel.eachRawSeriesByType(seriesType, function (seriesModel) { + var colorList = seriesModel.get('color', true); + var dataAll = seriesModel.getRawData(); + if (!ecModel.isSeriesFiltered(seriesModel)) { + var data = seriesModel.getData(); + data.each(function (idx) { + var itemModel = data.getItemModel(idx); + var rawIdx = data.getRawIndex(idx); + // If series.itemStyle.normal.color is a function. itemVisual may be encoded + var singleDataColor = data.getItemVisual(idx, 'color', true); + if (!singleDataColor) { + var paletteColor = colorList ? colorList[rawIdx % colorList.length] + : globalColorList[(rawIdx + offset) % globalColorList.length]; + var color = itemModel.get('itemStyle.normal.color') || paletteColor; + // Legend may use the visual info in data before processed + dataAll.setItemVisual(rawIdx, 'color', color); + data.setItemVisual(idx, 'color', color); + } + else { + // Set data all color for legend + dataAll.setItemVisual(rawIdx, 'color', singleDataColor); + } + }); + } + offset += dataAll.count(); + }); + }; + + +/***/ }, +/* 138 */ +/***/ function(module, exports, __webpack_require__) { + + // TODO minAngle + + + + var numberUtil = __webpack_require__(7); + var parsePercent = numberUtil.parsePercent; + var labelLayout = __webpack_require__(139); + var zrUtil = __webpack_require__(3); + + var PI2 = Math.PI * 2; + var RADIAN = Math.PI / 180; + + module.exports = function (seriesType, ecModel, api) { + ecModel.eachSeriesByType(seriesType, function (seriesModel) { + var center = seriesModel.get('center'); + var radius = seriesModel.get('radius'); + + if (!zrUtil.isArray(radius)) { + radius = [0, radius]; + } + if (!zrUtil.isArray(center)) { + center = [center, center]; + } + + var width = api.getWidth(); + var height = api.getHeight(); + var size = Math.min(width, height); + var cx = parsePercent(center[0], width); + var cy = parsePercent(center[1], height); + var r0 = parsePercent(radius[0], size / 2); + var r = parsePercent(radius[1], size / 2); + + var data = seriesModel.getData(); + + var startAngle = -seriesModel.get('startAngle') * RADIAN; + + var minAngle = seriesModel.get('minAngle') * RADIAN; + + var sum = data.getSum('value'); + // Sum may be 0 + var unitRadian = Math.PI / (sum || data.count()) * 2; + + var clockwise = seriesModel.get('clockwise'); + + var roseType = seriesModel.get('roseType'); + + // [0...max] + var extent = data.getDataExtent('value'); + extent[0] = 0; + + // In the case some sector angle is smaller than minAngle + var restAngle = PI2; + var valueSumLargerThanMinAngle = 0; + + var currentAngle = startAngle; + + var dir = clockwise ? 1 : -1; + data.each('value', function (value, idx) { + var angle; + // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样? + if (roseType !== 'area') { + angle = sum === 0 ? unitRadian : (value * unitRadian); + } + else { + angle = PI2 / (data.count() || 1); + } + + if (angle < minAngle) { + angle = minAngle; + restAngle -= minAngle; + } + else { + valueSumLargerThanMinAngle += value; + } + + var endAngle = currentAngle + dir * angle; + data.setItemLayout(idx, { + angle: angle, + startAngle: currentAngle, + endAngle: endAngle, + clockwise: clockwise, + cx: cx, + cy: cy, + r0: r0, + r: roseType + ? numberUtil.linearMap(value, extent, [r0, r]) + : r + }); + + currentAngle = endAngle; + }, true); + + // Some sector is constrained by minAngle + // Rest sectors needs recalculate angle + if (restAngle < PI2) { + // Average the angle if rest angle is not enough after all angles is + // Constrained by minAngle + if (restAngle <= 1e-3) { + var angle = PI2 / data.count(); + data.each(function (idx) { + var layout = data.getItemLayout(idx); + layout.startAngle = startAngle + dir * idx * angle; + layout.endAngle = startAngle + dir * (idx + 1) * angle; + }); + } + else { + unitRadian = restAngle / valueSumLargerThanMinAngle; + currentAngle = startAngle; + data.each('value', function (value, idx) { + var layout = data.getItemLayout(idx); + var angle = layout.angle === minAngle + ? minAngle : value * unitRadian; + layout.startAngle = currentAngle; + layout.endAngle = currentAngle + dir * angle; + currentAngle += angle; + }); + } + } + + labelLayout(seriesModel, r, width, height); + }); + }; + + +/***/ }, +/* 139 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + // FIXME emphasis label position is not same with normal label position + + + var textContain = __webpack_require__(14); + + function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) { + list.sort(function (a, b) { + return a.y - b.y; + }); + + // 压 + function shiftDown(start, end, delta, dir) { + for (var j = start; j < end; j++) { + list[j].y += delta; + if (j > start + && j + 1 < end + && list[j + 1].y > list[j].y + list[j].height + ) { + shiftUp(j, delta / 2); + return; + } + } + + shiftUp(end - 1, delta / 2); + } + + // 弹 + function shiftUp(end, delta) { + for (var j = end; j >= 0; j--) { + list[j].y -= delta; + if (j > 0 + && list[j].y > list[j - 1].y + list[j - 1].height + ) { + break; + } + } + } + + // function changeX(list, isDownList, cx, cy, r, dir) { + // var deltaX; + // var deltaY; + // var length; + // var lastDeltaX = dir > 0 + // ? isDownList // 右侧 + // ? Number.MAX_VALUE // 下 + // : 0 // 上 + // : isDownList // 左侧 + // ? Number.MAX_VALUE // 下 + // : 0; // 上 + + // for (var i = 0, l = list.length; i < l; i++) { + // deltaY = Math.abs(list[i].y - cy); + // length = list[i].length; + // deltaX = (deltaY < r + length) + // ? Math.sqrt( + // (r + length + 20) * (r + length + 20) + // - Math.pow(list[i].y - cy, 2) + // ) + // : Math.abs( + // list[i].x - cx + // ); + // if (isDownList && deltaX >= lastDeltaX) { + // // 右下,左下 + // deltaX = lastDeltaX - 10; + // } + // if (!isDownList && deltaX <= lastDeltaX) { + // // 右上,左上 + // deltaX = lastDeltaX + 10; + // } + + // list[i].x = cx + deltaX * dir; + // lastDeltaX = deltaX; + // } + // } + + var lastY = 0; + var delta; + var len = list.length; + var upList = []; + var downList = []; + for (var i = 0; i < len; i++) { + delta = list[i].y - lastY; + if (delta < 0) { + shiftDown(i, len, -delta, dir); + } + lastY = list[i].y + list[i].height; + } + if (viewHeight - lastY < 0) { + shiftUp(len - 1, lastY - viewHeight); + } + for (var i = 0; i < len; i++) { + if (list[i].y >= cy) { + downList.push(list[i]); + } + else { + upList.push(list[i]); + } + } + // changeX(downList, true, cx, cy, r, dir); + // changeX(upList, false, cx, cy, r, dir); + } + + function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) { + var leftList = []; + var rightList = []; + for (var i = 0; i < labelLayoutList.length; i++) { + if (labelLayoutList[i].x < cx) { + leftList.push(labelLayoutList[i]); + } + else { + rightList.push(labelLayoutList[i]); + } + } + + adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight); + adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight); + + for (var i = 0; i < labelLayoutList.length; i++) { + var linePoints = labelLayoutList[i].linePoints; + if (linePoints) { + if (labelLayoutList[i].x < cx) { + linePoints[2][0] = labelLayoutList[i].x + 3; + } + else { + linePoints[2][0] = labelLayoutList[i].x - 3; + } + linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y; + } + } + } + + module.exports = function (seriesModel, r, viewWidth, viewHeight) { + var data = seriesModel.getData(); + var labelLayoutList = []; + var cx; + var cy; + var hasLabelRotate = false; + + data.each(function (idx) { + var layout = data.getItemLayout(idx); + + var itemModel = data.getItemModel(idx); + var labelModel = itemModel.getModel('label.normal'); + // Use position in normal or emphasis + var labelPosition = labelModel.get('position') || itemModel.get('label.emphasis.position'); + + var labelLineModel = itemModel.getModel('labelLine.normal'); + var labelLineLen = labelLineModel.get('length'); + var labelLineLen2 = labelLineModel.get('length2'); + + var midAngle = (layout.startAngle + layout.endAngle) / 2; + var dx = Math.cos(midAngle); + var dy = Math.sin(midAngle); + + var textX; + var textY; + var linePoints; + var textAlign; + + cx = layout.cx; + cy = layout.cy; + + if (labelPosition === 'center') { + textX = layout.cx; + textY = layout.cy; + textAlign = 'center'; + } + else { + var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner'; + var x1 = (isLabelInside ? layout.r / 2 * dx : layout.r * dx) + cx; + var y1 = (isLabelInside ? layout.r / 2 * dy : layout.r * dy) + cy; + + // For roseType + labelLineLen += r - layout.r; + + textX = x1 + dx * 3; + textY = y1 + dy * 3; + + if (!isLabelInside) { + var x2 = x1 + dx * labelLineLen; + var y2 = y1 + dy * labelLineLen; + var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2); + var y3 = y2; + + textX = x3 + (dx < 0 ? -5 : 5); + textY = y3; + linePoints = [[x1, y1], [x2, y2], [x3, y3]]; + } + + textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right'); + } + var font = labelModel.getModel('textStyle').getFont(); + + var labelRotate = labelModel.get('rotate') + ? (dx < 0 ? -midAngle + Math.PI : -midAngle) : 0; + var text = seriesModel.getFormattedLabel(idx, 'normal') + || data.getName(idx); + var textRect = textContain.getBoundingRect( + text, font, textAlign, 'top' + ); + hasLabelRotate = !!labelRotate; + layout.label = { + x: textX, + y: textY, + height: textRect.height, + length: labelLineLen, + length2: labelLineLen2, + linePoints: linePoints, + textAlign: textAlign, + verticalAlign: 'middle', + font: font, + rotation: labelRotate + }; + + labelLayoutList.push(layout.label); + }); + if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) { + avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight); + } + }; + + +/***/ }, +/* 140 */ +/***/ function(module, exports) { + + + module.exports = function (seriesType, ecModel) { + var legendModels = ecModel.findComponents({ + mainType: 'legend' + }); + if (!legendModels || !legendModels.length) { + return; + } + ecModel.eachSeriesByType(seriesType, function (series) { + var data = series.getData(); + data.filterSelf(function (idx) { + var name = data.getName(idx); + // If in any legend component the status is not selected. + for (var i = 0; i < legendModels.length; i++) { + if (!legendModels[i].isSelected(name)) { + return false; + } + } + return true; + }, this); + }, this); + }; + + +/***/ } +/******/ ]) }); -/** - * echarts设备环境识别 - * - * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。 - * @author firede[firede@firede.us] - * @desc thanks zepto. - */ -define('zrender/core/env',[],function () { - var env = {}; - if (typeof navigator === 'undefined') { - // In node - env = { - browser: {}, - os: {}, - node: true, - // Assume canvas is supported - canvasSupported: true - }; - } - else { - env = detect(navigator.userAgent); - } - - return env; - - // Zepto.js - // (c) 2010-2013 Thomas Fuchs - // Zepto.js may be freely distributed under the MIT license. - - function detect(ua) { - var os = {}; - var browser = {}; - var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/); - var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); - var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); - var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); - var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/); - var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/); - var touchpad = webos && ua.match(/TouchPad/); - var kindle = ua.match(/Kindle\/([\d.]+)/); - var silk = ua.match(/Silk\/([\d._]+)/); - var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/); - var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/); - var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/); - var playbook = ua.match(/PlayBook/); - var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/); - var firefox = ua.match(/Firefox\/([\d.]+)/); - var safari = webkit && ua.match(/Mobile\//) && !chrome; - var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome; - var ie = ua.match(/MSIE\s([\d.]+)/) - // IE 11 Trident/7.0; rv:11.0 - || ua.match(/Trident\/.+?rv:(([\d.]+))/); - var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+ - - // Todo: clean this up with a better OS/browser seperation: - // - discern (more) between multiple browsers on android - // - decide if kindle fire in silk mode is android or not - // - Firefox on Android doesn't specify the Android version - // - possibly devide in os, device and browser hashes - - if (browser.webkit = !!webkit) browser.version = webkit[1]; - - if (android) os.android = true, os.version = android[2]; - if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.'); - if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.'); - if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null; - if (webos) os.webos = true, os.version = webos[2]; - if (touchpad) os.touchpad = true; - if (blackberry) os.blackberry = true, os.version = blackberry[2]; - if (bb10) os.bb10 = true, os.version = bb10[2]; - if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2]; - if (playbook) browser.playbook = true; - if (kindle) os.kindle = true, os.version = kindle[1]; - if (silk) browser.silk = true, browser.version = silk[1]; - if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true; - if (chrome) browser.chrome = true, browser.version = chrome[1]; - if (firefox) browser.firefox = true, browser.version = firefox[1]; - if (ie) browser.ie = true, browser.version = ie[1]; - if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true; - if (webview) browser.webview = true; - if (ie) browser.ie = true, browser.version = ie[1]; - if (edge) browser.edge = true, browser.version = edge[1]; - - os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) || - (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/))); - 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/)))); - - return { - browser: browser, - os: os, - node: false, - // 原生canvas支持,改极端点了 - // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9) - canvasSupported : document.createElement('canvas').getContext ? true : false, - // @see - // works on most browsers - // IE10/11 does not support touch event, and MS Edge supports them but not by - // default, so we dont check navigator.maxTouchPoints for them here. - touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge, - // . - pointerEventsSupported: 'onpointerdown' in window - // Firefox supports pointer but not by default, - // only MS browsers are reliable on pointer events currently. - && (browser.edge || (browser.ie && browser.version >= 10)) - }; - } -}); -/** - * 事件辅助类 - * @module zrender/core/event - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - */ -define('zrender/core/event',['require','../mixin/Eventful'],function(require) { - - - - var Eventful = require('../mixin/Eventful'); - - var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener; - - function getBoundingClientRect(el) { - // BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect - return el.getBoundingClientRect ? el.getBoundingClientRect() : { left: 0, top: 0}; - } - /** - * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标 - */ - function normalizeEvent(el, e) { - - e = e || window.event; - - if (e.zrX != null) { - return e; - } - - var eventType = e.type; - var isTouch = eventType && eventType.indexOf('touch') >= 0; - - if (!isTouch) { - var box = getBoundingClientRect(el); - e.zrX = e.clientX - box.left; - e.zrY = e.clientY - box.top; - e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3; - } - else { - var touch = eventType != 'touchend' - ? e.targetTouches[0] - : e.changedTouches[0]; - if (touch) { - var rBounding = getBoundingClientRect(el); - // touch事件坐标是全屏的~ - e.zrX = touch.clientX - rBounding.left; - e.zrY = touch.clientY - rBounding.top; - } - } - - return e; - } - - function addEventListener(el, name, handler) { - if (isDomLevel2) { - el.addEventListener(name, handler); - } - else { - el.attachEvent('on' + name, handler); - } - } - - function removeEventListener(el, name, handler) { - if (isDomLevel2) { - el.removeEventListener(name, handler); - } - else { - el.detachEvent('on' + name, handler); - } - } - - /** - * 停止冒泡和阻止默认行为 - * @memberOf module:zrender/core/event - * @method - * @param {Event} e : event对象 - */ - var stop = isDomLevel2 - ? function (e) { - e.preventDefault(); - e.stopPropagation(); - e.cancelBubble = true; - } - : function (e) { - e.returnValue = false; - e.cancelBubble = true; - }; - - return { - normalizeEvent: normalizeEvent, - addEventListener: addEventListener, - removeEventListener: removeEventListener, - - stop: stop, - // 做向上兼容 - Dispatcher: Eventful - }; -}); - -// TODO Draggable for group -// FIXME Draggable on element which has parent rotation or scale -define('zrender/mixin/Draggable',['require'],function (require) { - function Draggable() { - - this.on('mousedown', this._dragStart, this); - this.on('mousemove', this._drag, this); - this.on('mouseup', this._dragEnd, this); - this.on('globalout', this._dragEnd, this); - // this._dropTarget = null; - // this._draggingTarget = null; - - // this._x = 0; - // this._y = 0; - } - - Draggable.prototype = { - - constructor: Draggable, - - _dragStart: function (e) { - var draggingTarget = e.target; - if (draggingTarget && draggingTarget.draggable) { - this._draggingTarget = draggingTarget; - draggingTarget.dragging = true; - this._x = e.offsetX; - this._y = e.offsetY; - - this._dispatchProxy(draggingTarget, 'dragstart', e.event); - } - }, - - _drag: function (e) { - var draggingTarget = this._draggingTarget; - if (draggingTarget) { - - var x = e.offsetX; - var y = e.offsetY; - - var dx = x - this._x; - var dy = y - this._y; - this._x = x; - this._y = y; - - draggingTarget.drift(dx, dy, e); - this._dispatchProxy(draggingTarget, 'drag', e.event); - - var dropTarget = this.findHover(x, y, draggingTarget); - var lastDropTarget = this._dropTarget; - this._dropTarget = dropTarget; - - if (draggingTarget !== dropTarget) { - if (lastDropTarget && dropTarget !== lastDropTarget) { - this._dispatchProxy(lastDropTarget, 'dragleave', e.event); - } - if (dropTarget && dropTarget !== lastDropTarget) { - this._dispatchProxy(dropTarget, 'dragenter', e.event); - } - } - } - }, - - _dragEnd: function (e) { - var draggingTarget = this._draggingTarget; - - if (draggingTarget) { - draggingTarget.dragging = false; - } - - this._dispatchProxy(draggingTarget, 'dragend', e.event); - - if (this._dropTarget) { - this._dispatchProxy(this._dropTarget, 'drop', e.event); - } - - this._draggingTarget = null; - this._dropTarget = null; - } - - }; - - return Draggable; -}); -/** - * Only implements needed gestures for mobile. - */ -define('zrender/core/GestureMgr',['require'],function(require) { - - - - var GestureMgr = function () { - - /** - * @private - * @type {Array.} - */ - this._track = []; - }; - - GestureMgr.prototype = { - - constructor: GestureMgr, - - recognize: function (event, target) { - this._doTrack(event, target); - return this._recognize(event); - }, - - clear: function () { - this._track.length = 0; - return this; - }, - - _doTrack: function (event, target) { - var touches = event.touches; - - if (!touches) { - return; - } - - var trackItem = { - points: [], - touches: [], - target: target, - event: event - }; - - for (var i = 0, len = touches.length; i < len; i++) { - var touch = touches[i]; - trackItem.points.push([touch.clientX, touch.clientY]); - trackItem.touches.push(touch); - } - - this._track.push(trackItem); - }, - - _recognize: function (event) { - for (var eventName in recognizers) { - if (recognizers.hasOwnProperty(eventName)) { - var gestureInfo = recognizers[eventName](this._track, event); - if (gestureInfo) { - return gestureInfo; - } - } - } - } - }; - - function dist(pointPair) { - var dx = pointPair[1][0] - pointPair[0][0]; - var dy = pointPair[1][1] - pointPair[0][1]; - - return Math.sqrt(dx * dx + dy * dy); - } - - function center(pointPair) { - return [ - (pointPair[0][0] + pointPair[1][0]) / 2, - (pointPair[0][1] + pointPair[1][1]) / 2 - ]; - } - - var recognizers = { - - pinch: function (track, event) { - var trackLen = track.length; - - if (!trackLen) { - return; - } - - var pinchEnd = (track[trackLen - 1] || {}).points; - var pinchPre = (track[trackLen - 2] || {}).points || pinchEnd; - - if (pinchPre - && pinchPre.length > 1 - && pinchEnd - && pinchEnd.length > 1 - ) { - var pinchScale = dist(pinchEnd) / dist(pinchPre); - !isFinite(pinchScale) && (pinchScale = 1); - - event.pinchScale = pinchScale; - - var pinchCenter = center(pinchEnd); - event.pinchX = pinchCenter[0]; - event.pinchY = pinchCenter[1]; - - return { - type: 'pinch', - target: track[0].target, - event: event - }; - } - } - - // Only pinch currently. - }; - - return GestureMgr; -}); - -/** - * Handler控制模块 - * @module zrender/Handler - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - * errorrik (errorrik@gmail.com) - * pissang (shenyi.914@gmail.com) - */ -define('zrender/Handler',['require','./core/env','./core/event','./core/util','./mixin/Draggable','./core/GestureMgr','./mixin/Eventful'],function (require) { - - - - var env = require('./core/env'); - var eventTool = require('./core/event'); - var util = require('./core/util'); - var Draggable = require('./mixin/Draggable'); - var GestureMgr = require('./core/GestureMgr'); - - var Eventful = require('./mixin/Eventful'); - - var mouseHandlerNames = [ - 'click', 'dblclick', 'mousewheel', 'mouseout' - ]; - !usePointerEvent() && mouseHandlerNames.push( - 'mouseup', 'mousedown', 'mousemove' - ); - - var touchHandlerNames = [ - 'touchstart', 'touchend', 'touchmove' - ]; - - var pointerHandlerNames = [ - 'pointerdown', 'pointerup', 'pointermove' - ]; - - var TOUCH_CLICK_DELAY = 300; - - // touch指尖错觉的尝试偏移量配置 - // var MOBILE_TOUCH_OFFSETS = [ - // { x: 10 }, - // { x: -20 }, - // { x: 10, y: 10 }, - // { y: -20 } - // ]; - - var addEventListener = eventTool.addEventListener; - var removeEventListener = eventTool.removeEventListener; - var normalizeEvent = eventTool.normalizeEvent; - - function makeEventPacket(eveType, target, event) { - return { - type: eveType, - event: event, - target: target, - cancelBubble: false, - offsetX: event.zrX, - offsetY: event.zrY, - gestureEvent: event.gestureEvent, - pinchX: event.pinchX, - pinchY: event.pinchY, - pinchScale: event.pinchScale, - wheelDelta: event.zrDelta - }; - } - - var domHandlers = { - /** - * Mouse move handler - * @inner - * @param {Event} event - */ - mousemove: function (event) { - event = normalizeEvent(this.root, event); - - var x = event.zrX; - var y = event.zrY; - - var hovered = this.findHover(x, y, null); - var lastHovered = this._hovered; - - this._hovered = hovered; - - this.root.style.cursor = hovered ? hovered.cursor : this._defaultCursorStyle; - // Mouse out on previous hovered element - if (lastHovered && hovered !== lastHovered && lastHovered.__zr) { - this._dispatchProxy(lastHovered, 'mouseout', event); - } - - // Mouse moving on one element - this._dispatchProxy(hovered, 'mousemove', event); - - // Mouse over on a new element - if (hovered && hovered !== lastHovered) { - this._dispatchProxy(hovered, 'mouseover', event); - } - }, - - /** - * Mouse out handler - * @inner - * @param {Event} event - */ - mouseout: function (event) { - event = normalizeEvent(this.root, event); - - var element = event.toElement || event.relatedTarget; - if (element != this.root) { - while (element && element.nodeType != 9) { - // 忽略包含在root中的dom引起的mouseOut - if (element === this.root) { - return; - } - - element = element.parentNode; - } - } - - this._dispatchProxy(this._hovered, 'mouseout', event); - - this.trigger('globalout', { - event: event - }); - }, - - /** - * Touch开始响应函数 - * @inner - * @param {Event} event - */ - touchstart: function (event) { - // FIXME - // 移动端可能需要default行为,例如静态图表时。 - // eventTool.stop(event);// 阻止浏览器默认事件,重要 - event = normalizeEvent(this.root, event); - - this._lastTouchMoment = new Date(); - - processGesture(this, event, 'start'); - - // 平板补充一次findHover - // this._mobileFindFixed(event); - // Trigger mousemove and mousedown - domHandlers.mousemove.call(this, event); - - domHandlers.mousedown.call(this, event); - - setTouchTimer(this); - }, - - /** - * Touch移动响应函数 - * @inner - * @param {Event} event - */ - touchmove: function (event) { - // eventTool.stop(event);// 阻止浏览器默认事件,重要 - event = normalizeEvent(this.root, event); - - processGesture(this, event, 'change'); - - // Mouse move should always be triggered no matter whether - // there is gestrue event, because mouse move and pinch may - // be used at the same time. - domHandlers.mousemove.call(this, event); - - setTouchTimer(this); - }, - - /** - * Touch结束响应函数 - * @inner - * @param {Event} event - */ - touchend: function (event) { - // eventTool.stop(event);// 阻止浏览器默认事件,重要 - event = normalizeEvent(this.root, event); - - processGesture(this, event, 'end'); - - domHandlers.mouseup.call(this, event); - - // click event should always be triggered no matter whether - // there is gestrue event. System click can not be prevented. - if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) { - // this._mobileFindFixed(event); - domHandlers.click.call(this, event); - } - - setTouchTimer(this); - } - }; - - // Common handlers - util.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick'], function (name) { - domHandlers[name] = function (event) { - event = normalizeEvent(this.root, event); - // Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover - var hovered = this.findHover(event.zrX, event.zrY, null); - this._dispatchProxy(hovered, name, event); - }; - }); - - // Pointer event handlers - // util.each(['pointerdown', 'pointermove', 'pointerup'], function (name) { - // domHandlers[name] = function (event) { - // var mouseName = name.replace('pointer', 'mouse'); - // domHandlers[mouseName].call(this, event); - // }; - // }); - - function processGesture(zrHandler, event, stage) { - var gestureMgr = zrHandler._gestureMgr; - - stage === 'start' && gestureMgr.clear(); - - var gestureInfo = gestureMgr.recognize( - event, - zrHandler.findHover(event.zrX, event.zrY, null) - ); - - stage === 'end' && gestureMgr.clear(); - - if (gestureInfo) { - // eventTool.stop(event); - var type = gestureInfo.type; - event.gestureEvent = type; - - zrHandler._dispatchProxy(gestureInfo.target, type, gestureInfo.event); - } - } - - /** - * 为控制类实例初始化dom 事件处理函数 - * - * @inner - * @param {module:zrender/Handler} instance 控制类实例 - */ - function initDomHandler(instance) { - var handlerNames = touchHandlerNames.concat(pointerHandlerNames); - for (var i = 0; i < handlerNames.length; i++) { - var name = handlerNames[i]; - instance._handlers[name] = util.bind(domHandlers[name], instance); - } - - for (var i = 0; i < mouseHandlerNames.length; i++) { - var name = mouseHandlerNames[i]; - instance._handlers[name] = makeMouseHandler(domHandlers[name], instance); - } - - function makeMouseHandler(fn, instance) { - return function () { - if (instance._touching) { - return; - } - return fn.apply(instance, arguments); - }; - } - } - - /** - * @alias module:zrender/Handler - * @constructor - * @extends module:zrender/mixin/Eventful - * @param {HTMLElement} root Main HTML element for painting. - * @param {module:zrender/Storage} storage Storage instance. - * @param {module:zrender/Painter} painter Painter instance. - */ - var Handler = function(root, storage, painter) { - Eventful.call(this); - - this.root = root; - this.storage = storage; - this.painter = painter; - - /** - * @private - * @type {boolean} - */ - this._hovered; - - /** - * @private - * @type {Date} - */ - this._lastTouchMoment; - - /** - * @private - * @type {number} - */ - this._lastX; - - /** - * @private - * @type {number} - */ - this._lastY; - - /** - * @private - * @type {string} - */ - this._defaultCursorStyle = 'default'; - - /** - * @private - * @type {module:zrender/core/GestureMgr} - */ - this._gestureMgr = new GestureMgr(); - - /** - * @private - * @type {Array.} - */ - this._handlers = []; - - /** - * @private - * @type {boolean} - */ - this._touching = false; - - /** - * @private - * @type {number} - */ - this._touchTimer; - - initDomHandler(this); - - if (usePointerEvent()) { - mountHandlers(pointerHandlerNames, this); - } - else if (useTouchEvent()) { - mountHandlers(touchHandlerNames, this); - - // Handler of 'mouseout' event is needed in touch mode, which will be mounted below. - // addEventListener(root, 'mouseout', this._mouseoutHandler); - } - - // Considering some devices that both enable touch and mouse event (like MS Surface - // and lenovo X240, @see #2350), we make mouse event be always listened, otherwise - // mouse event can not be handle in those devices. - mountHandlers(mouseHandlerNames, this); - - Draggable.call(this); - - function mountHandlers(handlerNames, instance) { - util.each(handlerNames, function (name) { - addEventListener(root, eventNameFix(name), instance._handlers[name]); - }, instance); - } - }; - - Handler.prototype = { - - constructor: Handler, - - /** - * Resize - */ - resize: function (event) { - this._hovered = null; - }, - - /** - * Dispatch event - * @param {string} eventName - * @param {event=} eventArgs - */ - dispatch: function (eventName, eventArgs) { - var handler = this._handlers[eventName]; - handler && handler.call(this, eventArgs); - }, - - /** - * Dispose - */ - dispose: function () { - var root = this.root; - - var handlerNames = mouseHandlerNames.concat(touchHandlerNames); - - for (var i = 0; i < handlerNames.length; i++) { - var name = handlerNames[i]; - removeEventListener(root, eventNameFix(name), this._handlers[name]); - } - - this.root = - this.storage = - this.painter = null; - }, - - /** - * 设置默认的cursor style - * @param {string} cursorStyle 例如 crosshair - */ - setDefaultCursorStyle: function (cursorStyle) { - this._defaultCursorStyle = cursorStyle; - }, - - /** - * 事件分发代理 - * - * @private - * @param {Object} targetEl 目标图形元素 - * @param {string} eventName 事件名称 - * @param {Object} event 事件对象 - */ - _dispatchProxy: function (targetEl, eventName, event) { - var eventHandler = 'on' + eventName; - var eventPacket = makeEventPacket(eventName, targetEl, event); - - var el = targetEl; - - while (el) { - el[eventHandler] - && (eventPacket.cancelBubble = el[eventHandler].call(el, eventPacket)); - - el.trigger(eventName, eventPacket); - - el = el.parent; - - if (eventPacket.cancelBubble) { - break; - } - } - - if (!eventPacket.cancelBubble) { - // 冒泡到顶级 zrender 对象 - this.trigger(eventName, eventPacket); - // 分发事件到用户自定义层 - // 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在 - this.painter && this.painter.eachOtherLayer(function (layer) { - if (typeof(layer[eventHandler]) == 'function') { - layer[eventHandler].call(layer, eventPacket); - } - if (layer.trigger) { - layer.trigger(eventName, eventPacket); - } - }); - } - }, - - /** - * @private - * @param {number} x - * @param {number} y - * @param {module:zrender/graphic/Displayable} exclude - * @method - */ - findHover: function(x, y, exclude) { - var list = this.storage.getDisplayList(); - for (var i = list.length - 1; i >= 0 ; i--) { - if (!list[i].silent - && list[i] !== exclude - && isHover(list[i], x, y)) { - return list[i]; - } - } - } - }; - - function isHover(displayable, x, y) { - if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) { - var p = displayable.parent; - while (p) { - if (p.clipPath && !p.clipPath.contain(x, y)) { - // Clipped by parents - return false; - } - p = p.parent; - } - return true; - } - - return false; - } - - /** - * Prevent mouse event from being dispatched after Touch Events action - * @see - * 1. Mobile browsers dispatch mouse events 300ms after touchend. - * 2. Chrome for Android dispatch mousedown for long-touch about 650ms - * Result: Blocking Mouse Events for 700ms. - */ - function setTouchTimer(instance) { - instance._touching = true; - clearTimeout(instance._touchTimer); - instance._touchTimer = setTimeout(function () { - instance._touching = false; - }, 700); - } - - /** - * Althought MS Surface support screen touch, IE10/11 do not support - * touch event and MS Edge supported them but not by default (but chrome - * and firefox do). Thus we use Pointer event on MS browsers to handle touch. - */ - function usePointerEvent() { - // TODO - // pointermove event dont trigger when using finger. - // We may figger it out latter. - return false; - // return env.pointerEventsSupported - // In no-touch device we dont use pointer evnets but just - // use mouse event for avoiding problems. - // && window.navigator.maxTouchPoints; - } - - function useTouchEvent() { - return env.touchEventsSupported; - } - - function eventNameFix(name) { - return (name === 'mousewheel' && env.firefox) ? 'DOMMouseScroll' : name; - } - - util.mixin(Handler, Eventful); - util.mixin(Handler, Draggable); - - return Handler; -}); -/** - * Storage内容仓库模块 - * @module zrender/Storage - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - * @author errorrik (errorrik@gmail.com) - * @author pissang (https://github.com/pissang/) - */ -define('zrender/Storage',['require','./core/util','./container/Group'],function (require) { - - - - var util = require('./core/util'); - - var Group = require('./container/Group'); - - function shapeCompareFunc(a, b) { - if (a.zlevel === b.zlevel) { - if (a.z === b.z) { - if (a.z2 === b.z2) { - return a.__renderidx - b.__renderidx; - } - return a.z2 - b.z2; - } - return a.z - b.z; - } - return a.zlevel - b.zlevel; - } - /** - * 内容仓库 (M) - * @alias module:zrender/Storage - * @constructor - */ - var Storage = function () { - // 所有常规形状,id索引的map - this._elements = {}; - - this._roots = []; - - this._displayList = []; - - this._displayListLen = 0; - }; - - Storage.prototype = { - - constructor: Storage, - - /** - * 返回所有图形的绘制队列 - * @param {boolean} [update=false] 是否在返回前更新该数组 - * 详见{@link module:zrender/graphic/Displayable.prototype.updateDisplayList} - * @return {Array.} - */ - getDisplayList: function (update) { - if (update) { - this.updateDisplayList(); - } - return this._displayList; - }, - - /** - * 更新图形的绘制队列。 - * 每次绘制前都会调用,该方法会先深度优先遍历整个树,更新所有Group和Shape的变换并且把所有可见的Shape保存到数组中, - * 最后根据绘制的优先级(zlevel > z > 插入顺序)排序得到绘制队列 - */ - updateDisplayList: function () { - this._displayListLen = 0; - var roots = this._roots; - var displayList = this._displayList; - for (var i = 0, len = roots.length; i < len; i++) { - var root = roots[i]; - this._updateAndAddDisplayable(root); - } - displayList.length = this._displayListLen; - - for (var i = 0, len = displayList.length; i < len; i++) { - displayList[i].__renderidx = i; - } - - displayList.sort(shapeCompareFunc); - }, - - _updateAndAddDisplayable: function (el, clipPaths) { - - if (el.ignore) { - return; - } - - el.beforeUpdate(); - - el.update(); - - el.afterUpdate(); - - var clipPath = el.clipPath; - if (clipPath) { - // clipPath 的变换是基于 group 的变换 - clipPath.parent = el; - clipPath.updateTransform(); - - // FIXME 效率影响 - if (clipPaths) { - clipPaths = clipPaths.slice(); - clipPaths.push(clipPath); - } - else { - clipPaths = [clipPath]; - } - } - - if (el.type == 'group') { - var children = el._children; - - for (var i = 0; i < children.length; i++) { - var child = children[i]; - - // Force to mark as dirty if group is dirty - // FIXME __dirtyPath ? - child.__dirty = el.__dirty || child.__dirty; - - this._updateAndAddDisplayable(child, clipPaths); - } - - // Mark group clean here - el.__dirty = false; - - } - else { - el.__clipPaths = clipPaths; - - this._displayList[this._displayListLen++] = el; - } - }, - - /** - * 添加图形(Shape)或者组(Group)到根节点 - * @param {module:zrender/Element} el - */ - addRoot: function (el) { - // Element has been added - if (this._elements[el.id]) { - return; - } - - if (el instanceof Group) { - el.addChildrenToStorage(this); - } - - this.addToMap(el); - this._roots.push(el); - }, - - /** - * 删除指定的图形(Shape)或者组(Group) - * @param {string|Array.} [elId] 如果为空清空整个Storage - */ - delRoot: function (elId) { - if (elId == null) { - // 不指定elId清空 - for (var i = 0; i < this._roots.length; i++) { - var root = this._roots[i]; - if (root instanceof Group) { - root.delChildrenFromStorage(this); - } - } - - this._elements = {}; - this._roots = []; - this._displayList = []; - this._displayListLen = 0; - - return; - } - - if (elId instanceof Array) { - for (var i = 0, l = elId.length; i < l; i++) { - this.delRoot(elId[i]); - } - return; - } - - var el; - if (typeof(elId) == 'string') { - el = this._elements[elId]; - } - else { - el = elId; - } - - var idx = util.indexOf(this._roots, el); - if (idx >= 0) { - this.delFromMap(el.id); - this._roots.splice(idx, 1); - if (el instanceof Group) { - el.delChildrenFromStorage(this); - } - } - }, - - addToMap: function (el) { - if (el instanceof Group) { - el.__storage = this; - } - el.dirty(); - - this._elements[el.id] = el; - - return this; - }, - - get: function (elId) { - return this._elements[elId]; - }, - - delFromMap: function (elId) { - var elements = this._elements; - var el = elements[elId]; - if (el) { - delete elements[elId]; - if (el instanceof Group) { - el.__storage = null; - } - } - - return this; - }, - - /** - * 清空并且释放Storage - */ - dispose: function () { - this._elements = - this._renderList = - this._roots = null; - } - }; - - return Storage; -}); - -/** - * 动画主类, 调度和管理所有动画控制器 - * - * @module zrender/animation/Animation - * @author pissang(https://github.com/pissang) - */ -// TODO Additive animation -// http://iosoteric.com/additive-animations-animatewithduration-in-ios-8/ -// https://developer.apple.com/videos/wwdc2014/#236 -define('zrender/animation/Animation',['require','../core/util','../core/event','./Animator'],function(require) { - - - - var util = require('../core/util'); - var Dispatcher = require('../core/event').Dispatcher; - - var requestAnimationFrame = (typeof window !== 'undefined' && - (window.requestAnimationFrame - || window.msRequestAnimationFrame - || window.mozRequestAnimationFrame - || window.webkitRequestAnimationFrame)) - || function (func) { - setTimeout(func, 16); - }; - - var Animator = require('./Animator'); - /** - * @typedef {Object} IZRenderStage - * @property {Function} update - */ - - /** - * @alias module:zrender/animation/Animation - * @constructor - * @param {Object} [options] - * @param {Function} [options.onframe] - * @param {IZRenderStage} [options.stage] - * @example - * var animation = new Animation(); - * var obj = { - * x: 100, - * y: 100 - * }; - * animation.animate(node.position) - * .when(1000, { - * x: 500, - * y: 500 - * }) - * .when(2000, { - * x: 100, - * y: 100 - * }) - * .start('spline'); - */ - var Animation = function (options) { - - options = options || {}; - - this.stage = options.stage || {}; - - this.onframe = options.onframe || function() {}; - - // private properties - this._clips = []; - - this._running = false; - - this._time = 0; - - Dispatcher.call(this); - }; - - Animation.prototype = { - - constructor: Animation, - /** - * 添加 clip - * @param {module:zrender/animation/Clip} clip - */ - addClip: function (clip) { - this._clips.push(clip); - }, - /** - * 添加 animator - * @param {module:zrender/animation/Animator} animator - */ - addAnimator: function (animator) { - animator.animation = this; - var clips = animator.getClips(); - for (var i = 0; i < clips.length; i++) { - this.addClip(clips[i]); - } - }, - /** - * 删除动画片段 - * @param {module:zrender/animation/Clip} clip - */ - removeClip: function(clip) { - var idx = util.indexOf(this._clips, clip); - if (idx >= 0) { - this._clips.splice(idx, 1); - } - }, - - /** - * 删除动画片段 - * @param {module:zrender/animation/Animator} animator - */ - removeAnimator: function (animator) { - var clips = animator.getClips(); - for (var i = 0; i < clips.length; i++) { - this.removeClip(clips[i]); - } - animator.animation = null; - }, - - _update: function() { - - var time = new Date().getTime(); - var delta = time - this._time; - var clips = this._clips; - var len = clips.length; - - var deferredEvents = []; - var deferredClips = []; - for (var i = 0; i < len; i++) { - var clip = clips[i]; - var e = clip.step(time); - // Throw out the events need to be called after - // stage.update, like destroy - if (e) { - deferredEvents.push(e); - deferredClips.push(clip); - } - } - - // Remove the finished clip - for (var i = 0; i < len;) { - if (clips[i]._needsRemove) { - clips[i] = clips[len - 1]; - clips.pop(); - len--; - } - else { - i++; - } - } - - len = deferredEvents.length; - for (var i = 0; i < len; i++) { - deferredClips[i].fire(deferredEvents[i]); - } - - this._time = time; - - this.onframe(delta); - - this.trigger('frame', delta); - - if (this.stage.update) { - this.stage.update(); - } - }, - /** - * 开始运行动画 - */ - start: function () { - var self = this; - - this._running = true; - - function step() { - if (self._running) { - - requestAnimationFrame(step); - - self._update(); - } - } - - this._time = new Date().getTime(); - requestAnimationFrame(step); - }, - /** - * 停止运行动画 - */ - stop: function () { - this._running = false; - }, - /** - * 清除所有动画片段 - */ - clear: function () { - this._clips = []; - }, - /** - * 对一个目标创建一个animator对象,可以指定目标中的属性使用动画 - * @param {Object} target - * @param {Object} options - * @param {boolean} [options.loop=false] 是否循环播放动画 - * @param {Function} [options.getter=null] - * 如果指定getter函数,会通过getter函数取属性值 - * @param {Function} [options.setter=null] - * 如果指定setter函数,会通过setter函数设置属性值 - * @return {module:zrender/animation/Animation~Animator} - */ - animate: function (target, options) { - options = options || {}; - var animator = new Animator( - target, - options.loop, - options.getter, - options.setter - ); - - return animator; - } - }; - - util.mixin(Animation, Dispatcher); - - return Animation; -}); - -/** - * @module zrender/Layer - * @author pissang(https://www.github.com/pissang) - */ -define('zrender/Layer',['require','./core/util','./config'],function (require) { - - var util = require('./core/util'); - var config = require('./config'); - - function returnFalse() { - return false; - } - - /** - * 创建dom - * - * @inner - * @param {string} id dom id 待用 - * @param {string} type dom type,such as canvas, div etc. - * @param {Painter} painter painter instance - * @param {number} number - */ - function createDom(id, type, painter, dpr) { - var newDom = document.createElement(type); - var width = painter.getWidth(); - var height = painter.getHeight(); - - var newDomStyle = newDom.style; - // 没append呢,请原谅我这样写,清晰~ - newDomStyle.position = 'absolute'; - newDomStyle.left = 0; - newDomStyle.top = 0; - newDomStyle.width = width + 'px'; - newDomStyle.height = height + 'px'; - newDom.width = width * dpr; - newDom.height = height * dpr; - - // id不作为索引用,避免可能造成的重名,定义为私有属性 - newDom.setAttribute('data-zr-dom-id', id); - return newDom; - } - - /** - * @alias module:zrender/Layer - * @constructor - * @extends module:zrender/mixin/Transformable - * @param {string} id - * @param {module:zrender/Painter} painter - * @param {number} [dpr] - */ - var Layer = function(id, painter, dpr) { - var dom; - dpr = dpr || config.devicePixelRatio; - if (typeof id === 'string') { - dom = createDom(id, 'canvas', painter, dpr); - } - // Not using isDom because in node it will return false - else if (util.isObject(id)) { - dom = id; - id = dom.id; - } - this.id = id; - this.dom = dom; - - var domStyle = dom.style; - if (domStyle) { // Not in node - dom.onselectstart = returnFalse; // 避免页面选中的尴尬 - domStyle['-webkit-user-select'] = 'none'; - domStyle['user-select'] = 'none'; - domStyle['-webkit-touch-callout'] = 'none'; - domStyle['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)'; - } - - this.domBack = null; - this.ctxBack = null; - - this.painter = painter; - - this.config = null; - - // Configs - /** - * 每次清空画布的颜色 - * @type {string} - * @default 0 - */ - this.clearColor = 0; - /** - * 是否开启动态模糊 - * @type {boolean} - * @default false - */ - this.motionBlur = false; - /** - * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 - * @type {number} - * @default 0.7 - */ - this.lastFrameAlpha = 0.7; - - /** - * Layer dpr - * @type {number} - */ - this.dpr = dpr; - }; - - Layer.prototype = { - - constructor: Layer, - - elCount: 0, - - __dirty: true, - - initContext: function () { - this.ctx = this.dom.getContext('2d'); - - var dpr = this.dpr; - if (dpr != 1) { - this.ctx.scale(dpr, dpr); - } - }, - - createBackBuffer: function () { - var dpr = this.dpr; - - this.domBack = createDom('back-' + this.id, 'canvas', this.painter, dpr); - this.ctxBack = this.domBack.getContext('2d'); - - if (dpr != 1) { - this.ctxBack.scale(dpr, dpr); - } - }, - - /** - * @param {number} width - * @param {number} height - */ - resize: function (width, height) { - var dpr = this.dpr; - - var dom = this.dom; - var domStyle = dom.style; - var domBack = this.domBack; - - domStyle.width = width + 'px'; - domStyle.height = height + 'px'; - - dom.width = width * dpr; - dom.height = height * dpr; - - if (dpr != 1) { - this.ctx.scale(dpr, dpr); - } - - if (domBack) { - domBack.width = width * dpr; - domBack.height = height * dpr; - - if (dpr != 1) { - this.ctxBack.scale(dpr, dpr); - } - } - }, - - /** - * 清空该层画布 - * @param {boolean} clearAll Clear all with out motion blur - */ - clear: function (clearAll) { - var dom = this.dom; - var ctx = this.ctx; - var width = dom.width; - var height = dom.height; - - var haveClearColor = this.clearColor; - var haveMotionBLur = this.motionBlur && !clearAll; - var lastFrameAlpha = this.lastFrameAlpha; - - var dpr = this.dpr; - - if (haveMotionBLur) { - if (!this.domBack) { - this.createBackBuffer(); - } - - this.ctxBack.globalCompositeOperation = 'copy'; - this.ctxBack.drawImage( - dom, 0, 0, - width / dpr, - height / dpr - ); - } - - ctx.clearRect(0, 0, width / dpr, height / dpr); - if (haveClearColor) { - ctx.save(); - ctx.fillStyle = this.clearColor; - ctx.fillRect(0, 0, width / dpr, height / dpr); - ctx.restore(); - } - - if (haveMotionBLur) { - var domBack = this.domBack; - ctx.save(); - ctx.globalAlpha = lastFrameAlpha; - ctx.drawImage(domBack, 0, 0, width / dpr, height / dpr); - ctx.restore(); - } - } - }; - - return Layer; -}); -/** - * Default canvas painter - * @module zrender/Painter - * @author Kener (@Kener-林峰, kener.linfeng@gmail.com) - * errorrik (errorrik@gmail.com) - * pissang (https://www.github.com/pissang) - */ - define('zrender/Painter',['require','./config','./core/util','./core/log','./core/BoundingRect','./Layer','./graphic/Image'],function (require) { - - - var config = require('./config'); - var util = require('./core/util'); - var log = require('./core/log'); - var BoundingRect = require('./core/BoundingRect'); - - var Layer = require('./Layer'); - - function parseInt10(val) { - return parseInt(val, 10); - } - - function isLayerValid(layer) { - if (!layer) { - return false; - } - - if (layer.isBuildin) { - return true; - } - - if (typeof(layer.resize) !== 'function' - || typeof(layer.refresh) !== 'function' - ) { - return false; - } - - return true; - } - - function preProcessLayer(layer) { - layer.__unusedCount++; - } - - function postProcessLayer(layer) { - layer.__dirty = false; - if (layer.__unusedCount == 1) { - layer.clear(); - } - } - - var tmpRect = new BoundingRect(0, 0, 0, 0); - var viewRect = new BoundingRect(0, 0, 0, 0); - function isDisplayableCulled(el, width, height) { - tmpRect.copy(el.getBoundingRect()); - if (el.transform) { - tmpRect.applyTransform(el.transform); - } - viewRect.width = width; - viewRect.height = height; - return !tmpRect.intersect(viewRect); - } - - function isClipPathChanged(clipPaths, prevClipPaths) { - if (!clipPaths || !prevClipPaths || (clipPaths.length !== prevClipPaths.length)) { - return true; - } - for (var i = 0; i < clipPaths.length; i++) { - if (clipPaths[i] !== prevClipPaths[i]) { - return true; - } - } - } - - function doClip(clipPaths, ctx) { - for (var i = 0; i < clipPaths.length; i++) { - var clipPath = clipPaths[i]; - var m; - if (clipPath.transform) { - m = clipPath.transform; - ctx.transform( - m[0], m[1], - m[2], m[3], - m[4], m[5] - ); - } - var path = clipPath.path; - path.beginPath(ctx); - clipPath.buildPath(path, clipPath.shape); - ctx.clip(); - // Transform back - if (clipPath.transform) { - m = clipPath.invTransform; - ctx.transform( - m[0], m[1], - m[2], m[3], - m[4], m[5] - ); - } - } - } - - /** - * @alias module:zrender/Painter - * @constructor - * @param {HTMLElement} root 绘图容器 - * @param {module:zrender/Storage} storage - * @param {Ojbect} opts - */ - var Painter = function (root, storage, opts) { - var singleCanvas = !root.nodeName // In node ? - || root.nodeName.toUpperCase() === 'CANVAS'; - - opts = opts || {}; - - /** - * @type {number} - */ - this.dpr = opts.devicePixelRatio || config.devicePixelRatio; - /** - * @type {boolean} - * @private - */ - this._singleCanvas = singleCanvas; - /** - * 绘图容器 - * @type {HTMLElement} - */ - this.root = root; - - var rootStyle = root.style; - - // In node environment using node-canvas - if (rootStyle) { - rootStyle['-webkit-tap-highlight-color'] = 'transparent'; - rootStyle['-webkit-user-select'] = 'none'; - rootStyle['user-select'] = 'none'; - rootStyle['-webkit-touch-callout'] = 'none'; - - root.innerHTML = ''; - } - - /** - * @type {module:zrender/Storage} - */ - this.storage = storage; - - if (!singleCanvas) { - var width = this._getWidth(); - var height = this._getHeight(); - this._width = width; - this._height = height; - - var domRoot = document.createElement('div'); - this._domRoot = domRoot; - var domRootStyle = domRoot.style; - - // domRoot.onselectstart = returnFalse; // 避免页面选中的尴尬 - domRootStyle.position = 'relative'; - domRootStyle.overflow = 'hidden'; - domRootStyle.width = this._width + 'px'; - domRootStyle.height = this._height + 'px'; - root.appendChild(domRoot); - - /** - * @type {Object.} - * @private - */ - this._layers = {}; - /** - * @type {Array.} - * @private - */ - this._zlevelList = []; - } - else { - // Use canvas width and height directly - var width = root.width; - var height = root.height; - this._width = width; - this._height = height; - - // Create layer if only one given canvas - // Device pixel ratio is fixed to 1 because given canvas has its specified width and height - var mainLayer = new Layer(root, this, 1); - mainLayer.initContext(); - // FIXME Use canvas width and height - // mainLayer.resize(width, height); - this._layers = { - 0: mainLayer - }; - this._zlevelList = [0]; - } - - this._layerConfig = {}; - - this.pathToImage = this._createPathToImage(); - }; - - Painter.prototype = { - - constructor: Painter, - - /** - * If painter use a single canvas - * @return {boolean} - */ - isSingleCanvas: function () { - return this._singleCanvas; - }, - /** - * @return {HTMLDivElement} - */ - getViewportRoot: function () { - return this._singleCanvas ? this._layers[0].dom : this._domRoot; - }, - - /** - * 刷新 - * @param {boolean} [paintAll=false] 强制绘制所有displayable - */ - refresh: function (paintAll) { - var list = this.storage.getDisplayList(true); - var zlevelList = this._zlevelList; - - this._paintList(list, paintAll); - - // Paint custum layers - for (var i = 0; i < zlevelList.length; i++) { - var z = zlevelList[i]; - var layer = this._layers[z]; - if (!layer.isBuildin && layer.refresh) { - layer.refresh(); - } - } - - return this; - }, - - _paintList: function (list, paintAll) { - - if (paintAll == null) { - paintAll = false; - } - - this._updateLayerStatus(list); - - var currentLayer; - var currentZLevel; - var ctx; - - var viewWidth = this._width; - var viewHeight = this._height; - - this.eachBuildinLayer(preProcessLayer); - - // var invTransform = []; - var prevElClipPaths = null; - - for (var i = 0, l = list.length; i < l; i++) { - var el = list[i]; - var elZLevel = this._singleCanvas ? 0 : el.zlevel; - // Change draw layer - if (currentZLevel !== elZLevel) { - // Only 0 zlevel if only has one canvas - currentZLevel = elZLevel; - currentLayer = this.getLayer(currentZLevel); - - if (!currentLayer.isBuildin) { - log( - 'ZLevel ' + currentZLevel - + ' has been used by unkown layer ' + currentLayer.id - ); - } - - ctx = currentLayer.ctx; - - // Reset the count - currentLayer.__unusedCount = 0; - - if (currentLayer.__dirty || paintAll) { - currentLayer.clear(); - } - } - - if ( - (currentLayer.__dirty || paintAll) - // Ignore invisible element - && !el.invisible - // Ignore transparent element - && el.style.opacity !== 0 - // Ignore scale 0 element, in some environment like node-canvas - // Draw a scale 0 element can cause all following draw wrong - && el.scale[0] && el.scale[1] - // Ignore culled element - && !(el.culling && isDisplayableCulled(el, viewWidth, viewHeight)) - ) { - var clipPaths = el.__clipPaths; - - // Optimize when clipping on group with several elements - if (isClipPathChanged(clipPaths, prevElClipPaths)) { - // If has previous clipping state, restore from it - if (prevElClipPaths) { - ctx.restore(); - } - // New clipping state - if (clipPaths) { - ctx.save(); - doClip(clipPaths, ctx); - } - prevElClipPaths = clipPaths; - } - // TODO Use events ? - el.beforeBrush && el.beforeBrush(ctx); - el.brush(ctx, false); - el.afterBrush && el.afterBrush(ctx); - } - - el.__dirty = false; - } - - // If still has clipping state - if (prevElClipPaths) { - ctx.restore(); - } - - this.eachBuildinLayer(postProcessLayer); - }, - - /** - * 获取 zlevel 所在层,如果不存在则会创建一个新的层 - * @param {number} zlevel - * @return {module:zrender/Layer} - */ - getLayer: function (zlevel) { - if (this._singleCanvas) { - return this._layers[0]; - } - - var layer = this._layers[zlevel]; - if (!layer) { - // Create a new layer - layer = new Layer('zr_' + zlevel, this, this.dpr); - layer.isBuildin = true; - - if (this._layerConfig[zlevel]) { - util.merge(layer, this._layerConfig[zlevel], true); - } - - this.insertLayer(zlevel, layer); - - // Context is created after dom inserted to document - // Or excanvas will get 0px clientWidth and clientHeight - layer.initContext(); - } - - return layer; - }, - - insertLayer: function (zlevel, layer) { - - var layersMap = this._layers; - var zlevelList = this._zlevelList; - var len = zlevelList.length; - var prevLayer = null; - var i = -1; - var domRoot = this._domRoot; - - if (layersMap[zlevel]) { - log('ZLevel ' + zlevel + ' has been used already'); - return; - } - // Check if is a valid layer - if (!isLayerValid(layer)) { - log('Layer of zlevel ' + zlevel + ' is not valid'); - return; - } - - if (len > 0 && zlevel > zlevelList[0]) { - for (i = 0; i < len - 1; i++) { - if ( - zlevelList[i] < zlevel - && zlevelList[i + 1] > zlevel - ) { - break; - } - } - prevLayer = layersMap[zlevelList[i]]; - } - zlevelList.splice(i + 1, 0, zlevel); - - if (prevLayer) { - var prevDom = prevLayer.dom; - if (prevDom.nextSibling) { - domRoot.insertBefore( - layer.dom, - prevDom.nextSibling - ); - } - else { - domRoot.appendChild(layer.dom); - } - } - else { - if (domRoot.firstChild) { - domRoot.insertBefore(layer.dom, domRoot.firstChild); - } - else { - domRoot.appendChild(layer.dom); - } - } - - layersMap[zlevel] = layer; - }, - - // Iterate each layer - eachLayer: function (cb, context) { - var zlevelList = this._zlevelList; - var z; - var i; - for (i = 0; i < zlevelList.length; i++) { - z = zlevelList[i]; - cb.call(context, this._layers[z], z); - } - }, - - // Iterate each buildin layer - eachBuildinLayer: function (cb, context) { - var zlevelList = this._zlevelList; - var layer; - var z; - var i; - for (i = 0; i < zlevelList.length; i++) { - z = zlevelList[i]; - layer = this._layers[z]; - if (layer.isBuildin) { - cb.call(context, layer, z); - } - } - }, - - // Iterate each other layer except buildin layer - eachOtherLayer: function (cb, context) { - var zlevelList = this._zlevelList; - var layer; - var z; - var i; - for (i = 0; i < zlevelList.length; i++) { - z = zlevelList[i]; - layer = this._layers[z]; - if (! layer.isBuildin) { - cb.call(context, layer, z); - } - } - }, - - /** - * 获取所有已创建的层 - * @param {Array.} [prevLayer] - */ - getLayers: function () { - return this._layers; - }, - - _updateLayerStatus: function (list) { - - var layers = this._layers; - - var elCounts = {}; - - this.eachBuildinLayer(function (layer, z) { - elCounts[z] = layer.elCount; - layer.elCount = 0; - }); - - for (var i = 0, l = list.length; i < l; i++) { - var el = list[i]; - var zlevel = this._singleCanvas ? 0 : el.zlevel; - var layer = layers[zlevel]; - if (layer) { - layer.elCount++; - // 已经被标记为需要刷新 - if (layer.__dirty) { - continue; - } - layer.__dirty = el.__dirty; - } - } - - // 层中的元素数量有发生变化 - this.eachBuildinLayer(function (layer, z) { - if (elCounts[z] !== layer.elCount) { - layer.__dirty = true; - } - }); - }, - - /** - * 清除hover层外所有内容 - */ - clear: function () { - this.eachBuildinLayer(this._clearLayer); - return this; - }, - - _clearLayer: function (layer) { - layer.clear(); - }, - - /** - * 修改指定zlevel的绘制参数 - * - * @param {string} zlevel - * @param {Object} config 配置对象 - * @param {string} [config.clearColor=0] 每次清空画布的颜色 - * @param {string} [config.motionBlur=false] 是否开启动态模糊 - * @param {number} [config.lastFrameAlpha=0.7] - * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 - */ - configLayer: function (zlevel, config) { - if (config) { - var layerConfig = this._layerConfig; - if (!layerConfig[zlevel]) { - layerConfig[zlevel] = config; - } - else { - util.merge(layerConfig[zlevel], config, true); - } - - var layer = this._layers[zlevel]; - - if (layer) { - util.merge(layer, layerConfig[zlevel], true); - } - } - }, - - /** - * 删除指定层 - * @param {number} zlevel 层所在的zlevel - */ - delLayer: function (zlevel) { - var layers = this._layers; - var zlevelList = this._zlevelList; - var layer = layers[zlevel]; - if (!layer) { - return; - } - layer.dom.parentNode.removeChild(layer.dom); - delete layers[zlevel]; - - zlevelList.splice(util.indexOf(zlevelList, zlevel), 1); - }, - - /** - * 区域大小变化后重绘 - */ - resize: function (width, height) { - var domRoot = this._domRoot; - // FIXME Why ? - domRoot.style.display = 'none'; - - width = width || this._getWidth(); - height = height || this._getHeight(); - - domRoot.style.display = ''; - - // 优化没有实际改变的resize - if (this._width != width || height != this._height) { - domRoot.style.width = width + 'px'; - domRoot.style.height = height + 'px'; - - for (var id in this._layers) { - this._layers[id].resize(width, height); - } - - this.refresh(true); - } - - this._width = width; - this._height = height; - - return this; - }, - - /** - * 清除单独的一个层 - * @param {number} zlevel - */ - clearLayer: function (zlevel) { - var layer = this._layers[zlevel]; - if (layer) { - layer.clear(); - } - }, - - /** - * 释放 - */ - dispose: function () { - this.root.innerHTML = ''; - - this.root = - this.storage = - - this._domRoot = - this._layers = null; - }, - - /** - * Get canvas which has all thing rendered - * @param {Object} opts - * @param {string} [opts.backgroundColor] - */ - getRenderedCanvas: function (opts) { - opts = opts || {}; - if (this._singleCanvas) { - return this._layers[0].dom; - } - - var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr); - imageLayer.initContext(); - - var ctx = imageLayer.ctx; - imageLayer.clearColor = opts.backgroundColor; - imageLayer.clear(); - - var displayList = this.storage.getDisplayList(true); - - for (var i = 0; i < displayList.length; i++) { - var el = displayList[i]; - if (!el.invisible) { - el.beforeBrush && el.beforeBrush(ctx); - // TODO Check image cross origin - el.brush(ctx, false); - el.afterBrush && el.afterBrush(ctx); - } - } - - return imageLayer.dom; - }, - /** - * 获取绘图区域宽度 - */ - getWidth: function () { - return this._width; - }, - - /** - * 获取绘图区域高度 - */ - getHeight: function () { - return this._height; - }, - - _getWidth: function () { - var root = this.root; - var stl = document.defaultView.getComputedStyle(root); - - // FIXME Better way to get the width and height when element has not been append to the document - return ((root.clientWidth || parseInt10(stl.width) || parseInt10(root.style.width)) - - (parseInt10(stl.paddingLeft) || 0) - - (parseInt10(stl.paddingRight) || 0)) | 0; - }, - - _getHeight: function () { - var root = this.root; - var stl = document.defaultView.getComputedStyle(root); - - return ((root.clientHeight || parseInt10(stl.height) || parseInt10(root.style.height)) - - (parseInt10(stl.paddingTop) || 0) - - (parseInt10(stl.paddingBottom) || 0)) | 0; - }, - - _pathToImage: function (id, path, width, height, dpr) { - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - - canvas.width = width * dpr; - canvas.height = height * dpr; - - ctx.clearRect(0, 0, width * dpr, height * dpr); - - var pathTransform = { - position: path.position, - rotation: path.rotation, - scale: path.scale - }; - path.position = [0, 0, 0]; - path.rotation = 0; - path.scale = [1, 1]; - if (path) { - path.brush(ctx); - } - - var ImageShape = require('./graphic/Image'); - var imgShape = new ImageShape({ - id: id, - style: { - x: 0, - y: 0, - image: canvas - } - }); - - if (pathTransform.position != null) { - imgShape.position = path.position = pathTransform.position; - } - - if (pathTransform.rotation != null) { - imgShape.rotation = path.rotation = pathTransform.rotation; - } - - if (pathTransform.scale != null) { - imgShape.scale = path.scale = pathTransform.scale; - } - - return imgShape; - }, - - _createPathToImage: function () { - var me = this; - - return function (id, e, width, height) { - return me._pathToImage( - id, e, width, height, me.dpr - ); - }; - } - }; - - return Painter; -}); - -/*! - * ZRender, a high performance 2d drawing library. - * - * Copyright (c) 2013, Baidu Inc. - * All rights reserved. - * - * LICENSE - * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt - */ -// Global defines -define('zrender/zrender',['require','./core/guid','./core/env','./Handler','./Storage','./animation/Animation','./Painter'],function(require) { - var guid = require('./core/guid'); - var env = require('./core/env'); - - var Handler = require('./Handler'); - var Storage = require('./Storage'); - var Animation = require('./animation/Animation'); - - var useVML = !env.canvasSupported; - - var painterCtors = { - canvas: require('./Painter') - }; - - var instances = {}; // ZRender实例map索引 - - var zrender = {}; - /** - * @type {string} - */ - zrender.version = '3.0.3'; - - /** - * @param {HTMLElement} dom - * @param {Object} opts - * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg' - * @param {number} [opts.devicePixelRatio] - * @return {module:zrender/ZRender} - */ - zrender.init = function(dom, opts) { - var zr = new ZRender(guid(), dom, opts); - instances[zr.id] = zr; - return zr; - }; - - /** - * Dispose zrender instance - * @param {module:zrender/ZRender} zr - */ - zrender.dispose = function (zr) { - if (zr) { - zr.dispose(); - } - else { - for (var key in instances) { - instances[key].dispose(); - } - instances = {}; - } - - return zrender; - }; - - /** - * 获取zrender实例 - * @param {string} id ZRender对象索引 - * @return {module:zrender/ZRender} - */ - zrender.getInstance = function (id) { - return instances[id]; - }; - - zrender.registerPainter = function (name, Ctor) { - painterCtors[name] = Ctor; - }; - - function delInstance(id) { - delete instances[id]; - } - - /** - * @module zrender/ZRender - */ - /** - * @constructor - * @alias module:zrender/ZRender - * @param {string} id - * @param {HTMLDomElement} dom - * @param {Object} opts - * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg' - * @param {number} [opts.devicePixelRatio] - */ - var ZRender = function(id, dom, opts) { - - opts = opts || {}; - - /** - * @type {HTMLDomElement} - */ - this.dom = dom; - - /** - * @type {string} - */ - this.id = id; - - var self = this; - var storage = new Storage(); - - var rendererType = opts.renderer; - if (useVML) { - if (!painterCtors.vml) { - throw new Error('You need to require \'zrender/vml/vml\' to support IE8'); - } - rendererType = 'vml'; - } - else if (!rendererType || !painterCtors[rendererType]) { - rendererType = 'canvas'; - } - var painter = new painterCtors[rendererType](dom, storage, opts); - - this.storage = storage; - this.painter = painter; - if (!env.node) { - this.handler = new Handler(painter.getViewportRoot(), storage, painter); - } - - /** - * @type {module:zrender/animation/Animation} - */ - this.animation = new Animation({ - stage: { - update: function () { - if (self._needsRefresh) { - self.refreshImmediately(); - } - } - } - }); - this.animation.start(); - - /** - * @type {boolean} - * @private - */ - this._needsRefresh; - - // 修改 storage.delFromMap, 每次删除元素之前删除动画 - // FIXME 有点ugly - var oldDelFromMap = storage.delFromMap; - var oldAddToMap = storage.addToMap; - - storage.delFromMap = function (elId) { - var el = storage.get(elId); - - oldDelFromMap.call(storage, elId); - - el && el.removeSelfFromZr(self); - }; - - storage.addToMap = function (el) { - oldAddToMap.call(storage, el); - - el.addSelfToZr(self); - }; - }; - - ZRender.prototype = { - - constructor: ZRender, - /** - * 获取实例唯一标识 - * @return {string} - */ - getId: function () { - return this.id; - }, - - /** - * 添加元素 - * @param {string|module:zrender/Element} el - */ - add: function (el) { - this.storage.addRoot(el); - this._needsRefresh = true; - }, - - /** - * 删除元素 - * @param {string|module:zrender/Element} el - */ - remove: function (el) { - this.storage.delRoot(el); - this._needsRefresh = true; - }, - - /** - * 修改指定zlevel的绘制配置项 - * - * @param {string} zLevel - * @param {Object} config 配置对象 - * @param {string} [config.clearColor=0] 每次清空画布的颜色 - * @param {string} [config.motionBlur=false] 是否开启动态模糊 - * @param {number} [config.lastFrameAlpha=0.7] - * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显 - */ - configLayer: function (zLevel, config) { - this.painter.configLayer(zLevel, config); - this._needsRefresh = true; - }, - - /** - * 视图更新 - */ - refreshImmediately: function () { - // Clear needsRefresh ahead to avoid something wrong happens in refresh - // Or it will cause zrender refreshes again and again. - this._needsRefresh = false; - this.painter.refresh(); - /** - * Avoid trigger zr.refresh in Element#beforeUpdate hook - */ - this._needsRefresh = false; - }, - - /** - * 标记视图在浏览器下一帧需要绘制 - */ - refresh: function() { - this._needsRefresh = true; - }, - - /** - * 调整视图大小 - */ - resize: function() { - this.painter.resize(); - this.handler && this.handler.resize(); - }, - - /** - * 停止所有动画 - */ - clearAnimation: function () { - this.animation.clear(); - }, - - /** - * 获取视图宽度 - */ - getWidth: function() { - return this.painter.getWidth(); - }, - - /** - * 获取视图高度 - */ - getHeight: function() { - return this.painter.getHeight(); - }, - - /** - * 图像导出 - * @param {string} type - * @param {string} [backgroundColor='#fff'] 背景色 - * @return {string} 图片的Base64 url - */ - toDataURL: function(type, backgroundColor, args) { - return this.painter.toDataURL(type, backgroundColor, args); - }, - - /** - * 将常规shape转成image shape - * @param {module:zrender/graphic/Path} e - * @param {number} width - * @param {number} height - */ - pathToImage: function(e, width, height) { - var id = guid(); - return this.painter.pathToImage(id, e, width, height); - }, - - /** - * 设置默认的cursor style - * @param {string} cursorStyle 例如 crosshair - */ - setDefaultCursorStyle: function (cursorStyle) { - this.handler.setDefaultCursorStyle(cursorStyle); - }, - - /** - * 事件绑定 - * - * @param {string} eventName 事件名称 - * @param {Function} eventHandler 响应函数 - * @param {Object} [context] 响应函数 - */ - on: function(eventName, eventHandler, context) { - this.handler && this.handler.on(eventName, eventHandler, context); - }, - - /** - * 事件解绑定,参数为空则解绑所有自定义事件 - * - * @param {string} eventName 事件名称 - * @param {Function} eventHandler 响应函数 - */ - off: function(eventName, eventHandler) { - this.handler && this.handler.off(eventName, eventHandler); - }, - - /** - * 事件触发 - * - * @param {string} eventName 事件名称,resize,hover,drag,etc - * @param {event=} event event dom事件对象 - */ - trigger: function (eventName, event) { - this.handler && this.handler.trigger(eventName, event); - }, - - - /** - * 清除当前ZRender下所有类图的数据和显示,clear后MVC和已绑定事件均还存在在,ZRender可用 - */ - clear: function () { - this.storage.delRoot(); - this.painter.clear(); - }, - - /** - * 释放当前ZR实例(删除包括dom,数据、显示和事件绑定),dispose后ZR不可用 - */ - dispose: function () { - this.animation.stop(); - - this.clear(); - this.storage.dispose(); - this.painter.dispose(); - this.handler && this.handler.dispose(); - - this.animation = - this.storage = - this.painter = - this.handler = null; - - delInstance(this.id); - } - }; - - return zrender; -}); - -define('zrender', ['zrender/zrender'], function (main) { return main; }); - -define('echarts/loading/default',['require','../util/graphic','zrender/core/util'],function (require) { - - var graphic = require('../util/graphic'); - var zrUtil = require('zrender/core/util'); - var PI = Math.PI; - /** - * @param {module:echarts/ExtensionAPI} api - * @param {Object} [opts] - * @param {string} [opts.text] - * @param {string} [opts.color] - * @param {string} [opts.textColor] - * @return {module:zrender/Element} - */ - return function (api, opts) { - opts = opts || {}; - zrUtil.defaults(opts, { - text: 'loading', - color: '#c23531', - textColor: '#000', - maskColor: 'rgba(255, 255, 255, 0.8)', - zlevel: 0 - }); - var mask = new graphic.Rect({ - style: { - fill: opts.maskColor - }, - zlevel: opts.zlevel, - z: 10000 - }); - var arc = new graphic.Arc({ - shape: { - startAngle: -PI / 2, - endAngle: -PI / 2 + 0.1, - r: 10 - }, - style: { - stroke: opts.color, - lineCap: 'round', - lineWidth: 5 - }, - zlevel: opts.zlevel, - z: 10001 - }); - var labelRect = new graphic.Rect({ - style: { - fill: 'none', - text: opts.text, - textPosition: 'right', - textDistance: 10, - textFill: opts.textColor - }, - zlevel: opts.zlevel, - z: 10001 - }); - - arc.animateShape(true) - .when(1000, { - endAngle: PI * 3 / 2 - }) - .start('circularInOut'); - arc.animateShape(true) - .when(1000, { - startAngle: PI * 3 / 2 - }) - .delay(300) - .start('circularInOut'); - - var group = new graphic.Group(); - group.add(arc); - group.add(labelRect); - group.add(mask); - // Inject resize - group.resize = function () { - var cx = api.getWidth() / 2; - var cy = api.getHeight() / 2; - arc.setShape({ - cx: cx, - cy: cy - }); - var r = arc.shape.r; - labelRect.setShape({ - x: cx - r, - y: cy - r, - width: r * 2, - height: r * 2 - }); - - mask.setShape({ - x: 0, - y: 0, - width: api.getWidth(), - height: api.getHeight() - }); - }; - group.resize(); - return group; - }; -}); -define('echarts/visual/seriesColor',['require','zrender/graphic/Gradient'],function (require) { - var Gradient = require('zrender/graphic/Gradient'); - return function (seriesType, styleType, ecModel) { - function encodeColor(seriesModel) { - var colorAccessPath = [styleType, 'normal', 'color']; - var colorList = ecModel.get('color'); - var data = seriesModel.getData(); - var color = seriesModel.get(colorAccessPath) // Set in itemStyle - || colorList[seriesModel.seriesIndex % colorList.length]; // Default color - - // FIXME Set color function or use the platte color - data.setVisual('color', color); - - // Only visible series has each data be visual encoded - if (!ecModel.isSeriesFiltered(seriesModel)) { - if (typeof color === 'function' && !(color instanceof Gradient)) { - data.each(function (idx) { - data.setItemVisual( - idx, 'color', color(seriesModel.getDataParams(idx)) - ); - }); - } - - data.each(function (idx) { - var itemModel = data.getItemModel(idx); - var color = itemModel.get(colorAccessPath, true); - if (color != null) { - data.setItemVisual(idx, 'color', color); - } - }); - } - } - seriesType ? ecModel.eachSeriesByType(seriesType, encodeColor) - : ecModel.eachSeries(encodeColor); - }; -}); -define('echarts/preprocessor/helper/compatStyle',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - var POSSIBLE_STYLES = [ - 'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle', - 'chordStyle', 'label', 'labelLine' - ]; - - function compatItemStyle(opt) { - var itemStyleOpt = opt && opt.itemStyle; - if (itemStyleOpt) { - zrUtil.each(POSSIBLE_STYLES, function (styleName) { - var normalItemStyleOpt = itemStyleOpt.normal; - var emphasisItemStyleOpt = itemStyleOpt.emphasis; - if (normalItemStyleOpt && normalItemStyleOpt[styleName]) { - opt[styleName] = opt[styleName] || {}; - if (!opt[styleName].normal) { - opt[styleName].normal = normalItemStyleOpt[styleName]; - } - else { - zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]); - } - normalItemStyleOpt[styleName] = null; - } - if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) { - opt[styleName] = opt[styleName] || {}; - if (!opt[styleName].emphasis) { - opt[styleName].emphasis = emphasisItemStyleOpt[styleName]; - } - else { - zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]); - } - emphasisItemStyleOpt[styleName] = null; - } - }); - } - } - - return function (seriesOpt) { - compatItemStyle(seriesOpt); - var data = seriesOpt.data; - if (data) { - for (var i = 0; i < data.length; i++) { - compatItemStyle(data[i]); - } - // mark point data - var markPoint = seriesOpt.markPoint; - if (markPoint && markPoint.data) { - var mpData = markPoint.data; - for (var i = 0; i < mpData.length; i++) { - compatItemStyle(mpData[i]); - } - } - // mark line data - var markLine = seriesOpt.markLine; - if (markLine && markLine.data) { - var mlData = markLine.data; - for (var i = 0; i < mlData.length; i++) { - if (zrUtil.isArray(mlData[i])) { - compatItemStyle(mlData[i][0]); - compatItemStyle(mlData[i][1]); - } - else { - compatItemStyle(mlData[i]); - } - } - } - } - }; -}); -// Compatitable with 2.0 -define('echarts/preprocessor/backwardCompat',['require','zrender/core/util','./helper/compatStyle'],function (require) { - - var zrUtil = require('zrender/core/util'); - var compatStyle = require('./helper/compatStyle'); - - function get(opt, path) { - path = path.split(','); - var obj = opt; - for (var i = 0; i < path.length; i++) { - obj = obj && obj[path[i]]; - if (obj == null) { - break; - } - } - return obj; - } - - function set(opt, path, val, overwrite) { - path = path.split(','); - var obj = opt; - var key; - for (var i = 0; i < path.length - 1; i++) { - key = path[i]; - if (obj[key] == null) { - obj[key] = {}; - } - obj = obj[key]; - } - if (overwrite || obj[path[i]] == null) { - obj[path[i]] = val; - } - } - - function compatLayoutProperties(option) { - each(LAYOUT_PROPERTIES, function (prop) { - if (prop[0] in option && !(prop[1] in option)) { - option[prop[1]] = option[prop[0]]; - } - }); - } - - var LAYOUT_PROPERTIES = [ - ['x', 'left'], ['y', 'top'], ['x2', 'right'], ['y2', 'bottom'] - ]; - - var COMPATITABLE_COMPONENTS = [ - 'grid', 'geo', 'parallel', 'legend', 'toolbox', 'title', 'visualMap', 'dataZoom', 'timeline' - ]; - - var COMPATITABLE_SERIES = [ - 'bar', 'boxplot', 'candlestick', 'chord', 'effectScatter', - 'funnel', 'gauge', 'lines', 'graph', 'heatmap', 'line', 'map', 'parallel', - 'pie', 'radar', 'sankey', 'scatter', 'treemap' - ]; - - var each = zrUtil.each; - - return function (option) { - each(option.series, function (seriesOpt) { - if (!zrUtil.isObject(seriesOpt)) { - return; - } - - var seriesType = seriesOpt.type; - - compatStyle(seriesOpt); - - if (seriesType === 'pie' || seriesType === 'gauge') { - if (seriesOpt.clockWise != null) { - seriesOpt.clockwise = seriesOpt.clockWise; - } - } - if (seriesType === 'gauge') { - var pointerColor = get(seriesOpt, 'pointer.color'); - pointerColor != null - && set(seriesOpt, 'itemStyle.normal.color', pointerColor); - } - - for (var i = 0; i < COMPATITABLE_SERIES.length; i++) { - if (COMPATITABLE_SERIES[i] === seriesOpt.type) { - compatLayoutProperties(seriesOpt); - break; - } - } - }); - - // dataRange has changed to visualMap - if (option.dataRange) { - option.visualMap = option.dataRange; - } - - each(COMPATITABLE_COMPONENTS, function (componentName) { - var options = option[componentName]; - if (options) { - if (!zrUtil.isArray(options)) { - options = [options]; - } - each(options, function (option) { - compatLayoutProperties(option); - }); - } - }); - }; -}); -/*! - * ECharts, a javascript interactive chart library. - * - * Copyright (c) 2015, Baidu Inc. - * All rights reserved. - * - * LICENSE - * https://github.com/ecomfe/echarts/blob/master/LICENSE.txt - */ - -/** - * @module echarts - */ -define('echarts/echarts',['require','./model/Global','./ExtensionAPI','./CoordinateSystem','./model/OptionManager','./model/Component','./model/Series','./view/Component','./view/Chart','./util/graphic','zrender','zrender/core/util','zrender/tool/color','zrender/core/env','zrender/mixin/Eventful','./loading/default','./visual/seriesColor','./preprocessor/backwardCompat','./util/graphic','./util/number','./util/format','zrender/core/matrix','zrender/core/vector'],function (require) { - - var GlobalModel = require('./model/Global'); - var ExtensionAPI = require('./ExtensionAPI'); - var CoordinateSystemManager = require('./CoordinateSystem'); - var OptionManager = require('./model/OptionManager'); - - var ComponentModel = require('./model/Component'); - var SeriesModel = require('./model/Series'); - - var ComponentView = require('./view/Component'); - var ChartView = require('./view/Chart'); - var graphic = require('./util/graphic'); - - var zrender = require('zrender'); - var zrUtil = require('zrender/core/util'); - var colorTool = require('zrender/tool/color'); - var env = require('zrender/core/env'); - var Eventful = require('zrender/mixin/Eventful'); - - var each = zrUtil.each; - - var VISUAL_CODING_STAGES = ['echarts', 'chart', 'component']; - - // TODO Transform first or filter first - var PROCESSOR_STAGES = ['transform', 'filter', 'statistic']; - - function createRegisterEventWithLowercaseName(method) { - return function (eventName, handler, context) { - // Event name is all lowercase - eventName = eventName && eventName.toLowerCase(); - Eventful.prototype[method].call(this, eventName, handler, context); - }; - } - /** - * @module echarts~MessageCenter - */ - function MessageCenter() { - Eventful.call(this); - } - MessageCenter.prototype.on = createRegisterEventWithLowercaseName('on'); - MessageCenter.prototype.off = createRegisterEventWithLowercaseName('off'); - MessageCenter.prototype.one = createRegisterEventWithLowercaseName('one'); - zrUtil.mixin(MessageCenter, Eventful); - /** - * @module echarts~ECharts - */ - function ECharts (dom, theme, opts) { - opts = opts || {}; - - // Get theme by name - if (typeof theme === 'string') { - theme = themeStorage[theme]; - } - - if (theme) { - each(optionPreprocessorFuncs, function (preProcess) { - preProcess(theme); - }); - } - /** - * @type {string} - */ - this.id; - /** - * Group id - * @type {string} - */ - this.group; - /** - * @type {HTMLDomElement} - * @private - */ - this._dom = dom; - /** - * @type {module:zrender/ZRender} - * @private - */ - this._zr = zrender.init(dom, { - renderer: opts.renderer || 'canvas', - devicePixelRatio: opts.devicePixelRatio - }); - - /** - * @type {Object} - * @private - */ - this._theme = zrUtil.clone(theme); - - /** - * @type {Array.} - * @private - */ - this._chartsViews = []; - - /** - * @type {Object.} - * @private - */ - this._chartsMap = {}; - - /** - * @type {Array.} - * @private - */ - this._componentsViews = []; - - /** - * @type {Object.} - * @private - */ - this._componentsMap = {}; - - /** - * @type {module:echarts/ExtensionAPI} - * @private - */ - this._api = new ExtensionAPI(this); - - /** - * @type {module:echarts/CoordinateSystem} - * @private - */ - this._coordSysMgr = new CoordinateSystemManager(); - - Eventful.call(this); - - /** - * @type {module:echarts~MessageCenter} - * @private - */ - this._messageCenter = new MessageCenter(); - - // Init mouse events - this._initEvents(); - - // In case some people write `window.onresize = chart.resize` - this.resize = zrUtil.bind(this.resize, this); - } - - var echartsProto = ECharts.prototype; - - /** - * @return {HTMLDomElement} - */ - echartsProto.getDom = function () { - return this._dom; - }; - - /** - * @return {module:zrender~ZRender} - */ - echartsProto.getZr = function () { - return this._zr; - }; - - /** - * @param {Object} option - * @param {boolean} notMerge - * @param {boolean} [notRefreshImmediately=false] Useful when setOption frequently. - */ - echartsProto.setOption = function (option, notMerge, notRefreshImmediately) { - if (!this._model || notMerge) { - this._model = new GlobalModel( - null, null, this._theme, new OptionManager(this._api) - ); - } - - this._model.setOption(option, optionPreprocessorFuncs); - - updateMethods.prepareAndUpdate.call(this); - - !notRefreshImmediately && this._zr.refreshImmediately(); - }; - - /** - * @DEPRECATED - */ - echartsProto.setTheme = function () { - console.log('ECharts#setTheme() is DEPRECATED in ECharts 3.0'); - }; - - /** - * @return {module:echarts/model/Global} - */ - echartsProto.getModel = function () { - return this._model; - }; - - /** - * @return {Object} - */ - echartsProto.getOption = function () { - return this._model.getOption(); - }; - - /** - * @return {number} - */ - echartsProto.getWidth = function () { - return this._zr.getWidth(); - }; - - /** - * @return {number} - */ - echartsProto.getHeight = function () { - return this._zr.getHeight(); - }; - - /** - * Get canvas which has all thing rendered - * @param {Object} opts - * @param {string} [opts.backgroundColor] - */ - echartsProto.getRenderedCanvas = function (opts) { - if (!env.canvasSupported) { - return; - } - opts = opts || {}; - opts.pixelRatio = opts.pixelRatio || 1; - opts.backgroundColor = opts.backgroundColor - || this._model.get('backgroundColor'); - var zr = this._zr; - var list = zr.storage.getDisplayList(); - // Stop animations - zrUtil.each(list, function (el) { - el.stopAnimation(true); - }); - return zr.painter.getRenderedCanvas(opts); - }; - /** - * @return {string} - * @param {Object} opts - * @param {string} [opts.type='png'] - * @param {string} [opts.pixelRatio=1] - * @param {string} [opts.backgroundColor] - */ - echartsProto.getDataURL = function (opts) { - opts = opts || {}; - var excludeComponents = opts.excludeComponents; - var ecModel = this._model; - var excludesComponentViews = []; - var self = this; - - each(excludeComponents, function (componentType) { - ecModel.eachComponent({ - mainType: componentType - }, function (component) { - var view = self._componentsMap[component.__viewId]; - if (!view.group.ignore) { - excludesComponentViews.push(view); - view.group.ignore = true; - } - }); - }); - - var url = this.getRenderedCanvas(opts).toDataURL( - 'image/' + (opts && opts.type || 'png') - ); - - each(excludesComponentViews, function (view) { - view.group.ignore = false; - }); - return url; - }; - - - /** - * @return {string} - * @param {Object} opts - * @param {string} [opts.type='png'] - * @param {string} [opts.pixelRatio=1] - * @param {string} [opts.backgroundColor] - */ - echartsProto.getConnectedDataURL = function (opts) { - if (!env.canvasSupported) { - return; - } - var groupId = this.group; - var mathMin = Math.min; - var mathMax = Math.max; - var MAX_NUMBER = Infinity; - if (connectedGroups[groupId]) { - var left = MAX_NUMBER; - var top = MAX_NUMBER; - var right = -MAX_NUMBER; - var bottom = -MAX_NUMBER; - var canvasList = []; - var dpr = (opts && opts.pixelRatio) || 1; - for (var id in instances) { - var chart = instances[id]; - if (chart.group === groupId) { - var canvas = chart.getRenderedCanvas( - zrUtil.clone(opts) - ); - var boundingRect = chart.getDom().getBoundingClientRect(); - left = mathMin(boundingRect.left, left); - top = mathMin(boundingRect.top, top); - right = mathMax(boundingRect.right, right); - bottom = mathMax(boundingRect.bottom, bottom); - canvasList.push({ - dom: canvas, - left: boundingRect.left, - top: boundingRect.top - }); - } - } - - left *= dpr; - top *= dpr; - right *= dpr; - bottom *= dpr; - var width = right - left; - var height = bottom - top; - var targetCanvas = zrUtil.createCanvas(); - targetCanvas.width = width; - targetCanvas.height = height; - var zr = zrender.init(targetCanvas); - - each(canvasList, function (item) { - var img = new graphic.Image({ - style: { - x: item.left * dpr - left, - y: item.top * dpr - top, - image: item.dom - } - }); - zr.add(img); - }); - zr.refreshImmediately(); - - return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png')); - } - else { - return this.getDataURL(opts); - } - }; - - var updateMethods = { - - /** - * @param {Object} payload - * @private - */ - update: function (payload) { - // console.time && console.time('update'); - - var ecModel = this._model; - var api = this._api; - var coordSysMgr = this._coordSysMgr; - // update before setOption - if (!ecModel) { - return; - } - - ecModel.restoreData(); - - // TODO - // Save total ecModel here for undo/redo (after restoring data and before processing data). - // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call. - - // Create new coordinate system each update - // In LineView may save the old coordinate system and use it to get the orignal point - coordSysMgr.create(this._model, this._api); - - processData.call(this, ecModel, api); - - stackSeriesData.call(this, ecModel); - - coordSysMgr.update(ecModel, api); - - doLayout.call(this, ecModel, payload); - - doVisualCoding.call(this, ecModel, payload); - - doRender.call(this, ecModel, payload); - - // Set background - var backgroundColor = ecModel.get('backgroundColor') || 'transparent'; - - var painter = this._zr.painter; - // TODO all use clearColor ? - if (painter.isSingleCanvas && painter.isSingleCanvas()) { - this._zr.configLayer(0, { - clearColor: backgroundColor - }); - } - else { - // In IE8 - if (!env.canvasSupported) { - var colorArr = colorTool.parse(backgroundColor); - backgroundColor = colorTool.stringify(colorArr, 'rgb'); - if (colorArr[3] === 0) { - backgroundColor = 'transparent'; - } - } - backgroundColor = backgroundColor; - this._dom.style.backgroundColor = backgroundColor; - } - - // console.time && console.timeEnd('update'); - }, - - // PENDING - /** - * @param {Object} payload - * @private - */ - updateView: function (payload) { - var ecModel = this._model; - - // update before setOption - if (!ecModel) { - return; - } - - doLayout.call(this, ecModel, payload); - - doVisualCoding.call(this, ecModel, payload); - - invokeUpdateMethod.call(this, 'updateView', ecModel, payload); - }, - - /** - * @param {Object} payload - * @private - */ - updateVisual: function (payload) { - var ecModel = this._model; - - // update before setOption - if (!ecModel) { - return; - } - - doVisualCoding.call(this, ecModel, payload); - - invokeUpdateMethod.call(this, 'updateVisual', ecModel, payload); - }, - - /** - * @param {Object} payload - * @private - */ - updateLayout: function (payload) { - var ecModel = this._model; - - // update before setOption - if (!ecModel) { - return; - } - - doLayout.call(this, ecModel, payload); - - invokeUpdateMethod.call(this, 'updateLayout', ecModel, payload); - }, - - /** - * @param {Object} payload - * @private - */ - highlight: function (payload) { - toggleHighlight.call(this, 'highlight', payload); - }, - - /** - * @param {Object} payload - * @private - */ - downplay: function (payload) { - toggleHighlight.call(this, 'downplay', payload); - }, - - /** - * @param {Object} payload - * @private - */ - prepareAndUpdate: function (payload) { - var ecModel = this._model; - - prepareView.call(this, 'component', ecModel); - - prepareView.call(this, 'chart', ecModel); - - updateMethods.update.call(this, payload); - } - }; - - /** - * @param {Object} payload - * @private - */ - function toggleHighlight(method, payload) { - var ecModel = this._model; - - // dispatchAction before setOption - if (!ecModel) { - return; - } - - ecModel.eachComponent( - {mainType: 'series', query: payload}, - function (seriesModel, index) { - var chartView = this._chartsMap[seriesModel.__viewId]; - if (chartView && chartView.__alive) { - chartView[method]( - seriesModel, ecModel, this._api, payload - ); - } - }, - this - ); - } - - /** - * Resize the chart - */ - echartsProto.resize = function () { - this._zr.resize(); - - var optionChanged = this._model && this._model.resetOption('media'); - updateMethods[optionChanged ? 'prepareAndUpdate' : 'update'].call(this); - - // Resize loading effect - this._loadingFX && this._loadingFX.resize(); - }; - - var defaultLoadingEffect = require('./loading/default'); - /** - * Show loading effect - * @param {string} [name='default'] - * @param {Object} [cfg] - */ - echartsProto.showLoading = function (name, cfg) { - if (zrUtil.isObject(name)) { - cfg = name; - name = 'default'; - } - var el = defaultLoadingEffect(this._api, cfg); - var zr = this._zr; - this._loadingFX = el; - - zr.add(el); - }; - - /** - * Hide loading effect - */ - echartsProto.hideLoading = function () { - this._loadingFX && this._zr.remove(this._loadingFX); - this._loadingFX = null; - }; - - /** - * @param {Object} eventObj - * @return {Object} - */ - echartsProto.makeActionFromEvent = function (eventObj) { - var payload = zrUtil.extend({}, eventObj); - payload.type = eventActionMap[eventObj.type]; - return payload; - }; - - /** - * @pubilc - * @param {Object} payload - * @param {string} [payload.type] Action type - * @param {boolean} [silent=false] Whether trigger event. - */ - echartsProto.dispatchAction = function (payload, silent) { - var actionWrap = actions[payload.type]; - if (actionWrap) { - var actionInfo = actionWrap.actionInfo; - var updateMethod = actionInfo.update || 'update'; - - var payloads = [payload]; - var batched = false; - // Batch action - if (payload.batch) { - batched = true; - payloads = zrUtil.map(payload.batch, function (item) { - item = zrUtil.defaults(zrUtil.extend({}, item), payload); - item.batch = null; - return item; - }); - } - - var eventObjBatch = []; - var eventObj; - var isHighlightOrDownplay = payload.type === 'highlight' || payload.type === 'downplay'; - for (var i = 0; i < payloads.length; i++) { - var batchItem = payloads[i]; - // Action can specify the event by return it. - eventObj = actionWrap.action(batchItem, this._model); - // Emit event outside - eventObj = eventObj || zrUtil.extend({}, batchItem); - // Convert type to eventType - eventObj.type = actionInfo.event || eventObj.type; - eventObjBatch.push(eventObj); - - // Highlight and downplay are special. - isHighlightOrDownplay && updateMethods[updateMethod].call(this, batchItem); - } - - (updateMethod !== 'none' && !isHighlightOrDownplay) - && updateMethods[updateMethod].call(this, payload); - if (!silent) { - // Follow the rule of action batch - if (batched) { - eventObj = { - type: eventObjBatch[0].type, - batch: eventObjBatch - }; - } - else { - eventObj = eventObjBatch[0]; - } - this._messageCenter.trigger(eventObj.type, eventObj); - } - } - }; - - /** - * Register event - * @method - */ - echartsProto.on = createRegisterEventWithLowercaseName('on'); - echartsProto.off = createRegisterEventWithLowercaseName('off'); - echartsProto.one = createRegisterEventWithLowercaseName('one'); - - /** - * @param {string} methodName - * @private - */ - function invokeUpdateMethod(methodName, ecModel, payload) { - var api = this._api; - - // Update all components - each(this._componentsViews, function (component) { - var componentModel = component.__model; - component[methodName](componentModel, ecModel, api, payload); - - updateZ(componentModel, component); - }, this); - - // Upate all charts - ecModel.eachSeries(function (seriesModel, idx) { - var chart = this._chartsMap[seriesModel.__viewId]; - chart[methodName](seriesModel, ecModel, api, payload); - - updateZ(seriesModel, chart); - }, this); - - } - - /** - * Prepare view instances of charts and components - * @param {module:echarts/model/Global} ecModel - * @private - */ - function prepareView(type, ecModel) { - var isComponent = type === 'component'; - var viewList = isComponent ? this._componentsViews : this._chartsViews; - var viewMap = isComponent ? this._componentsMap : this._chartsMap; - var zr = this._zr; - - for (var i = 0; i < viewList.length; i++) { - viewList[i].__alive = false; - } - - ecModel[isComponent ? 'eachComponent' : 'eachSeries'](function (componentType, model) { - if (isComponent) { - if (componentType === 'series') { - return; - } - } - else { - model = componentType; - } - - // Consider: id same and type changed. - var viewId = model.id + '_' + model.type; - var view = viewMap[viewId]; - if (!view) { - var classType = ComponentModel.parseClassType(model.type); - var Clazz = isComponent - ? ComponentView.getClass(classType.main, classType.sub) - : ChartView.getClass(classType.sub); - if (Clazz) { - view = new Clazz(); - view.init(ecModel, this._api); - viewMap[viewId] = view; - viewList.push(view); - zr.add(view.group); - } - else { - // Error - return; - } - } - - model.__viewId = viewId; - view.__alive = true; - view.__id = viewId; - view.__model = model; - }, this); - - for (var i = 0; i < viewList.length;) { - var view = viewList[i]; - if (!view.__alive) { - zr.remove(view.group); - view.dispose(ecModel, this._api); - viewList.splice(i, 1); - delete viewMap[view.__id]; - } - else { - i++; - } - } - } - - /** - * Processor data in each series - * - * @param {module:echarts/model/Global} ecModel - * @private - */ - function processData(ecModel, api) { - each(PROCESSOR_STAGES, function (stage) { - each(dataProcessorFuncs[stage] || [], function (process) { - process(ecModel, api); - }); - }); - } - - /** - * @private - */ - function stackSeriesData(ecModel) { - var stackedDataMap = {}; - ecModel.eachSeries(function (series) { - var stack = series.get('stack'); - var data = series.getData(); - if (stack && data.type === 'list') { - var previousStack = stackedDataMap[stack]; - if (previousStack) { - data.stackedOn = previousStack; - } - stackedDataMap[stack] = data; - } - }); - } - - /** - * Layout before each chart render there series, after visual coding and data processing - * - * @param {module:echarts/model/Global} ecModel - * @private - */ - function doLayout(ecModel, payload) { - var api = this._api; - each(layoutFuncs, function (layout) { - layout(ecModel, api, payload); - }); - } - - /** - * Code visual infomation from data after data processing - * - * @param {module:echarts/model/Global} ecModel - * @private - */ - function doVisualCoding(ecModel, payload) { - each(VISUAL_CODING_STAGES, function (stage) { - each(visualCodingFuncs[stage] || [], function (visualCoding) { - visualCoding(ecModel, payload); - }); - }); - } - - /** - * Render each chart and component - * @private - */ - function doRender(ecModel, payload) { - var api = this._api; - // Render all components - each(this._componentsViews, function (componentView) { - var componentModel = componentView.__model; - componentView.render(componentModel, ecModel, api, payload); - - updateZ(componentModel, componentView); - }, this); - - each(this._chartsViews, function (chart) { - chart.__alive = false; - }, this); - - // Render all charts - ecModel.eachSeries(function (seriesModel, idx) { - var chartView = this._chartsMap[seriesModel.__viewId]; - chartView.__alive = true; - chartView.render(seriesModel, ecModel, api, payload); - - updateZ(seriesModel, chartView); - }, this); - - // Remove groups of unrendered charts - each(this._chartsViews, function (chart) { - if (!chart.__alive) { - chart.remove(ecModel, api); - } - }, this); - } - - var MOUSE_EVENT_NAMES = [ - 'click', 'dblclick', 'mouseover', 'mouseout', 'globalout' - ]; - /** - * @private - */ - echartsProto._initEvents = function () { - var zr = this._zr; - each(MOUSE_EVENT_NAMES, function (eveName) { - zr.on(eveName, function (e) { - var ecModel = this.getModel(); - var el = e.target; - if (el && el.dataIndex != null) { - var hostModel = el.hostModel || ecModel.getSeriesByIndex(el.seriesIndex); - var params = hostModel && hostModel.getDataParams(el.dataIndex) || {}; - params.event = e; - params.type = eveName; - this.trigger(eveName, params); - } - }, this); - }, this); - - each(eventActionMap, function (actionType, eventType) { - this._messageCenter.on(eventType, function (event) { - this.trigger(eventType, event); - }, this); - }, this); - }; - - /** - * @return {boolean} - */ - echartsProto.isDisposed = function () { - return this._disposed; - }; - - /** - * Clear - */ - echartsProto.clear = function () { - this.setOption({}, true); - }; - /** - * Dispose instance - */ - echartsProto.dispose = function () { - this._disposed = true; - var api = this._api; - var ecModel = this._model; - - each(this._componentsViews, function (component) { - component.dispose(ecModel, api); - }); - each(this._chartsViews, function (chart) { - chart.dispose(ecModel, api); - }); - - this._zr.dispose(); - - instances[this.id] = null; - }; - - zrUtil.mixin(ECharts, Eventful); - - /** - * @param {module:echarts/model/Series|module:echarts/model/Component} model - * @param {module:echarts/view/Component|module:echarts/view/Chart} view - * @return {string} - */ - function updateZ(model, view) { - var z = model.get('z'); - var zlevel = model.get('zlevel'); - // Set z and zlevel - view.group.traverse(function (el) { - z != null && (el.z = z); - zlevel != null && (el.zlevel = zlevel); - }); - } - /** - * @type {Array.} - * @inner - */ - var actions = []; - - /** - * Map eventType to actionType - * @type {Object} - */ - var eventActionMap = {}; - - /** - * @type {Array.} - * @inner - */ - var layoutFuncs = []; - - /** - * Data processor functions of each stage - * @type {Array.>} - * @inner - */ - var dataProcessorFuncs = {}; - - /** - * @type {Array.} - * @inner - */ - var optionPreprocessorFuncs = []; - - /** - * Visual coding functions of each stage - * @type {Array.>} - * @inner - */ - var visualCodingFuncs = {}; - /** - * Theme storage - * @type {Object.} - */ - var themeStorage = {}; - - - var instances = {}; - var connectedGroups = {}; - - var idBase = new Date() - 0; - var groupIdBase = new Date() - 0; - var DOM_ATTRIBUTE_KEY = '_echarts_instance_'; - /** - * @alias module:echarts - */ - var echarts = { - /** - * @type {number} - */ - version: '3.1.2', - dependencies: { - zrender: '3.0.3' - } - }; - - function enableConnect(chart) { - - var STATUS_PENDING = 0; - var STATUS_UPDATING = 1; - var STATUS_UPDATED = 2; - var STATUS_KEY = '__connectUpdateStatus'; - function updateConnectedChartsStatus(charts, status) { - for (var i = 0; i < charts.length; i++) { - var otherChart = charts[i]; - otherChart[STATUS_KEY] = status; - } - } - zrUtil.each(eventActionMap, function (actionType, eventType) { - chart._messageCenter.on(eventType, function (event) { - if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) { - var action = chart.makeActionFromEvent(event); - var otherCharts = []; - for (var id in instances) { - var otherChart = instances[id]; - if (otherChart !== chart && otherChart.group === chart.group) { - otherCharts.push(otherChart); - } - } - updateConnectedChartsStatus(otherCharts, STATUS_PENDING); - each(otherCharts, function (otherChart) { - if (otherChart[STATUS_KEY] !== STATUS_UPDATING) { - otherChart.dispatchAction(action); - } - }); - updateConnectedChartsStatus(otherCharts, STATUS_UPDATED); - } - }); - }); - - } - /** - * @param {HTMLDomElement} dom - * @param {Object} [theme] - * @param {Object} opts - */ - echarts.init = function (dom, theme, opts) { - // Check version - if ((zrender.version.replace('.', '') - 0) < (echarts.dependencies.zrender.replace('.', '') - 0)) { - throw new Error( - 'ZRender ' + zrender.version - + ' is too old for ECharts ' + echarts.version - + '. Current version need ZRender ' - + echarts.dependencies.zrender + '+' - ); - } - if (!dom) { - throw new Error('Initialize failed: invalid dom.'); - } - - var chart = new ECharts(dom, theme, opts); - chart.id = 'ec_' + idBase++; - instances[chart.id] = chart; - - dom.setAttribute && - dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id); - - enableConnect(chart); - - return chart; - }; - - /** - * @return {string|Array.} groupId - */ - echarts.connect = function (groupId) { - // Is array of charts - if (zrUtil.isArray(groupId)) { - var charts = groupId; - groupId = null; - // If any chart has group - zrUtil.each(charts, function (chart) { - if (chart.group != null) { - groupId = chart.group; - } - }); - groupId = groupId || ('g_' + groupIdBase++); - zrUtil.each(charts, function (chart) { - chart.group = groupId; - }); - } - connectedGroups[groupId] = true; - return groupId; - }; - - /** - * @return {string} groupId - */ - echarts.disConnect = function (groupId) { - connectedGroups[groupId] = false; - }; - - /** - * Dispose a chart instance - * @param {module:echarts~ECharts|HTMLDomElement|string} chart - */ - echarts.dispose = function (chart) { - if (zrUtil.isDom(chart)) { - chart = echarts.getInstanceByDom(chart); - } - else if (typeof chart === 'string') { - chart = instances[chart]; - } - if ((chart instanceof ECharts) && !chart.isDisposed()) { - chart.dispose(); - } - }; - - /** - * @param {HTMLDomElement} dom - * @return {echarts~ECharts} - */ - echarts.getInstanceByDom = function (dom) { - var key = dom.getAttribute(DOM_ATTRIBUTE_KEY); - return instances[key]; - }; - /** - * @param {string} key - * @return {echarts~ECharts} - */ - echarts.getInstanceById = function (key) { - return instances[key]; - }; - - /** - * Register theme - */ - echarts.registerTheme = function (name, theme) { - themeStorage[name] = theme; - }; - - /** - * Register option preprocessor - * @param {Function} preprocessorFunc - */ - echarts.registerPreprocessor = function (preprocessorFunc) { - optionPreprocessorFuncs.push(preprocessorFunc); - }; - - /** - * @param {string} stage - * @param {Function} processorFunc - */ - echarts.registerProcessor = function (stage, processorFunc) { - if (zrUtil.indexOf(PROCESSOR_STAGES, stage) < 0) { - throw new Error('stage should be one of ' + PROCESSOR_STAGES); - } - var funcs = dataProcessorFuncs[stage] || (dataProcessorFuncs[stage] = []); - funcs.push(processorFunc); - }; - - /** - * Usage: - * registerAction('someAction', 'someEvent', function () { ... }); - * registerAction('someAction', function () { ... }); - * registerAction( - * {type: 'someAction', event: 'someEvent', update: 'updateView'}, - * function () { ... } - * ); - * - * @param {(string|Object)} actionInfo - * @param {string} actionInfo.type - * @param {string} [actionInfo.event] - * @param {string} [actionInfo.update] - * @param {string} [eventName] - * @param {Function} action - */ - echarts.registerAction = function (actionInfo, eventName, action) { - if (typeof eventName === 'function') { - action = eventName; - eventName = ''; - } - var actionType = zrUtil.isObject(actionInfo) - ? actionInfo.type - : ([actionInfo, actionInfo = { - event: eventName - }][0]); - - // Event name is all lowercase - actionInfo.event = (actionInfo.event || actionType).toLowerCase(); - eventName = actionInfo.event; - - if (!actions[actionType]) { - actions[actionType] = {action: action, actionInfo: actionInfo}; - } - eventActionMap[eventName] = actionType; - }; - - /** - * @param {string} type - * @param {*} CoordinateSystem - */ - echarts.registerCoordinateSystem = function (type, CoordinateSystem) { - CoordinateSystemManager.register(type, CoordinateSystem); - }; - - /** - * @param {*} layout - */ - echarts.registerLayout = function (layout) { - // PENDING All functions ? - if (zrUtil.indexOf(layoutFuncs, layout) < 0) { - layoutFuncs.push(layout); - } - }; - - /** - * @param {string} stage - * @param {Function} visualCodingFunc - */ - echarts.registerVisualCoding = function (stage, visualCodingFunc) { - if (zrUtil.indexOf(VISUAL_CODING_STAGES, stage) < 0) { - throw new Error('stage should be one of ' + VISUAL_CODING_STAGES); - } - var funcs = visualCodingFuncs[stage] || (visualCodingFuncs[stage] = []); - funcs.push(visualCodingFunc); - }; - - /** - * @param {Object} opts - */ - echarts.extendChartView = function (opts) { - return ChartView.extend(opts); - }; - - /** - * @param {Object} opts - */ - echarts.extendComponentModel = function (opts) { - return ComponentModel.extend(opts); - }; - - /** - * @param {Object} opts - */ - echarts.extendSeriesModel = function (opts) { - return SeriesModel.extend(opts); - }; - - /** - * @param {Object} opts - */ - echarts.extendComponentView = function (opts) { - return ComponentView.extend(opts); - }; - - /** - * ZRender need a canvas context to do measureText. - * But in node environment canvas may be created by node-canvas. - * So we need to specify how to create a canvas instead of using document.createElement('canvas') - * - * Be careful of using it in the browser. - * - * @param {Function} creator - * @example - * var Canvas = require('canvas'); - * var echarts = require('echarts'); - * echarts.setCanvasCreator(function () { - * // Small size is enough. - * return new Canvas(32, 32); - * }); - */ - echarts.setCanvasCreator = function (creator) { - zrUtil.createCanvas = creator; - }; - - echarts.registerVisualCoding('echarts', zrUtil.curry( - require('./visual/seriesColor'), '', 'itemStyle' - )); - echarts.registerPreprocessor(require('./preprocessor/backwardCompat')); - - // Default action - echarts.registerAction({ - type: 'highlight', - event: 'highlight', - update: 'highlight' - }, zrUtil.noop); - echarts.registerAction({ - type: 'downplay', - event: 'downplay', - update: 'downplay' - }, zrUtil.noop); - - - // -------- - // Exports - // -------- - - echarts.graphic = require('./util/graphic'); - echarts.number = require('./util/number'); - echarts.format = require('./util/format'); - echarts.matrix = require('zrender/core/matrix'); - echarts.vector = require('zrender/core/vector'); - - echarts.util = {}; - each([ - 'map', 'each', 'filter', 'indexOf', 'inherits', - 'reduce', 'filter', 'bind', 'curry', 'isArray', - 'isString', 'isObject', 'isFunction', 'extend' - ], - function (name) { - echarts.util[name] = zrUtil[name]; - } - ); - - return echarts; -}); -define('echarts', ['echarts/echarts'], function (main) { return main; }); - -define('echarts/data/DataDiffer',['require'],function(require) { - - - function defaultKeyGetter(item) { - return item; - } - - function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter) { - this._old = oldArr; - this._new = newArr; - - this._oldKeyGetter = oldKeyGetter || defaultKeyGetter; - this._newKeyGetter = newKeyGetter || defaultKeyGetter; - } - - DataDiffer.prototype = { - - constructor: DataDiffer, - - /** - * Callback function when add a data - */ - add: function (func) { - this._add = func; - return this; - }, - - /** - * Callback function when update a data - */ - update: function (func) { - this._update = func; - return this; - }, - - /** - * Callback function when remove a data - */ - remove: function (func) { - this._remove = func; - return this; - }, - - execute: function () { - var oldArr = this._old; - var newArr = this._new; - var oldKeyGetter = this._oldKeyGetter; - var newKeyGetter = this._newKeyGetter; - - var oldDataIndexMap = {}; - var newDataIndexMap = {}; - var i; - - initIndexMap(oldArr, oldDataIndexMap, oldKeyGetter); - initIndexMap(newArr, newDataIndexMap, newKeyGetter); - - // Travel by inverted order to make sure order consistency - // when duplicate keys exists (consider newDataIndex.pop() below). - // For performance consideration, these code below do not look neat. - for (i = 0; i < oldArr.length; i++) { - var key = oldKeyGetter(oldArr[i]); - var idx = newDataIndexMap[key]; - - // idx can never be empty array here. see 'set null' logic below. - if (idx != null) { - // Consider there is duplicate key (for example, use dataItem.name as key). - // We should make sure every item in newArr and oldArr can be visited. - var len = idx.length; - if (len) { - len === 1 && (newDataIndexMap[key] = null); - idx = idx.unshift(); - } - else { - newDataIndexMap[key] = null; - } - this._update && this._update(idx, i); - } - else { - this._remove && this._remove(i); - } - } - - for (var key in newDataIndexMap) { - if (newDataIndexMap.hasOwnProperty(key)) { - var idx = newDataIndexMap[key]; - if (idx == null) { - continue; - } - // idx can never be empty array here. see 'set null' logic above. - if (!idx.length) { - this._add && this._add(idx); - } - else { - for (var i = 0, len = idx.length; i < len; i++) { - this._add && this._add(idx[i]); - } - } - } - } - } - }; - - function initIndexMap(arr, map, keyGetter) { - for (var i = 0; i < arr.length; i++) { - var key = keyGetter(arr[i]); - var existence = map[key]; - if (existence == null) { - map[key] = i; - } - else { - if (!existence.length) { - map[key] = existence = [existence]; - } - existence.push(i); - } - } - } - - return DataDiffer; -}); -/** - * List for data storage - * @module echarts/data/List - */ -define('echarts/data/List',['require','../model/Model','./DataDiffer','zrender/core/util','../util/model'],function (require) { - - var UNDEFINED = 'undefined'; - var globalObj = typeof window === 'undefined' ? global : window; - var Float64Array = typeof globalObj.Float64Array === UNDEFINED - ? Array : globalObj.Float64Array; - var Int32Array = typeof globalObj.Int32Array === UNDEFINED - ? Array : globalObj.Int32Array; - - var dataCtors = { - 'float': Float64Array, - 'int': Int32Array, - // Ordinal data type can be string or int - 'ordinal': Array, - 'number': Array, - 'time': Array - }; - - var Model = require('../model/Model'); - var DataDiffer = require('./DataDiffer'); - - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../util/model'); - var isObject = zrUtil.isObject; - - var IMMUTABLE_PROPERTIES = [ - 'stackedOn', '_nameList', '_idList', '_rawData' - ]; - - var transferImmuProperties = function (a, b, wrappedMethod) { - zrUtil.each(IMMUTABLE_PROPERTIES.concat(wrappedMethod || []), function (propName) { - if (b.hasOwnProperty(propName)) { - a[propName] = b[propName]; - } - }); - }; - - /** - * @constructor - * @alias module:echarts/data/List - * - * @param {Array.} dimensions - * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius - * @param {module:echarts/model/Model} hostModel - */ - var List = function (dimensions, hostModel) { - - dimensions = dimensions || ['x', 'y']; - - var dimensionInfos = {}; - var dimensionNames = []; - for (var i = 0; i < dimensions.length; i++) { - var dimensionName; - var dimensionInfo = {}; - if (typeof dimensions[i] === 'string') { - dimensionName = dimensions[i]; - dimensionInfo = { - name: dimensionName, - stackable: false, - // Type can be 'float', 'int', 'number' - // Default is number, Precision of float may not enough - type: 'number' - }; - } - else { - dimensionInfo = dimensions[i]; - dimensionName = dimensionInfo.name; - dimensionInfo.type = dimensionInfo.type || 'number'; - } - dimensionNames.push(dimensionName); - dimensionInfos[dimensionName] = dimensionInfo; - } - /** - * @readOnly - * @type {Array.} - */ - this.dimensions = dimensionNames; - - /** - * Infomation of each data dimension, like data type. - * @type {Object} - */ - this._dimensionInfos = dimensionInfos; - - /** - * @type {module:echarts/model/Model} - */ - this.hostModel = hostModel; - - /** - * Indices stores the indices of data subset after filtered. - * This data subset will be used in chart. - * @type {Array.} - * @readOnly - */ - this.indices = []; - - /** - * Data storage - * @type {Object.} - * @private - */ - this._storage = {}; - - /** - * @type {Array.} - */ - this._nameList = []; - /** - * @type {Array.} - */ - this._idList = []; - /** - * Models of data option is stored sparse for optimizing memory cost - * @type {Array.} - * @private - */ - this._optionModels = []; - - /** - * @param {module:echarts/data/List} - */ - this.stackedOn = null; - - /** - * Global visual properties after visual coding - * @type {Object} - * @private - */ - this._visual = {}; - - /** - * Globel layout properties. - * @type {Object} - * @private - */ - this._layout = {}; - - /** - * Item visual properties after visual coding - * @type {Array.} - * @private - */ - this._itemVisuals = []; - - /** - * Item layout properties after layout - * @type {Array.} - * @private - */ - this._itemLayouts = []; - - /** - * Graphic elemnents - * @type {Array.} - * @private - */ - this._graphicEls = []; - - /** - * @type {Array.} - * @private - */ - this._rawData; - - /** - * @type {Object} - * @private - */ - this._extent; - }; - - var listProto = List.prototype; - - listProto.type = 'list'; - - /** - * Get dimension name - * @param {string|number} dim - * Dimension can be concrete names like x, y, z, lng, lat, angle, radius - * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius' - */ - listProto.getDimension = function (dim) { - if (!isNaN(dim)) { - dim = this.dimensions[dim] || dim; - } - return dim; - }; - /** - * Get type and stackable info of particular dimension - * @param {string|number} dim - * Dimension can be concrete names like x, y, z, lng, lat, angle, radius - * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius' - */ - listProto.getDimensionInfo = function (dim) { - return zrUtil.clone(this._dimensionInfos[this.getDimension(dim)]); - }; - - /** - * Initialize from data - * @param {Array.} data - * @param {Array.} [nameList] - * @param {Function} [dimValueGetter] (dataItem, dimName, dataIndex, dimIndex) => number - */ - listProto.initData = function (data, nameList, dimValueGetter) { - data = data || []; - - this._rawData = data; - - // Clear - var storage = this._storage = {}; - var indices = this.indices = []; - - var dimensions = this.dimensions; - var size = data.length; - var dimensionInfoMap = this._dimensionInfos; - - var idList = []; - var nameRepeatCount = {}; - - nameList = nameList || []; - - // Init storage - for (var i = 0; i < dimensions.length; i++) { - var dimInfo = dimensionInfoMap[dimensions[i]]; - var DataCtor = dataCtors[dimInfo.type]; - storage[dimensions[i]] = new DataCtor(size); - } - - // Default dim value getter - dimValueGetter = dimValueGetter || function (dataItem, dimName, dataIndex, dimIndex) { - var value = modelUtil.getDataItemValue(dataItem); - return modelUtil.converDataValue( - zrUtil.isArray(value) - ? value[dimIndex] - // If value is a single number or something else not array. - : value, - dimensionInfoMap[dimName] - ); - }; - - for (var idx = 0; idx < data.length; idx++) { - var dataItem = data[idx]; - // Each data item is value - // [1, 2] - // 2 - // Bar chart, line chart which uses category axis - // only gives the 'y' value. 'x' value is the indices of cateogry - // Use a tempValue to normalize the value to be a (x, y) value - - // Store the data by dimensions - for (var k = 0; k < dimensions.length; k++) { - var dim = dimensions[k]; - var dimStorage = storage[dim]; - // PENDING NULL is empty or zero - dimStorage[idx] = dimValueGetter(dataItem, dim, idx, k); - } - - indices.push(idx); - } - - // Use the name in option and create id - for (var i = 0; i < data.length; i++) { - var id = ''; - if (!nameList[i]) { - nameList[i] = data[i].name; - // Try using the id in option - id = data[i].id; - } - var name = nameList[i] || ''; - if (!id && name) { - // Use name as id and add counter to avoid same name - nameRepeatCount[name] = nameRepeatCount[name] || 0; - id = name; - if (nameRepeatCount[name] > 0) { - id += '__ec__' + nameRepeatCount[name]; - } - nameRepeatCount[name]++; - } - id && (idList[i] = id); - } - - this._nameList = nameList; - this._idList = idList; - }; - - /** - * @return {number} - */ - listProto.count = function () { - return this.indices.length; - }; - - /** - * Get value - * @param {string} dim Dim must be concrete name. - * @param {number} idx - * @param {boolean} stack - * @return {number} - */ - listProto.get = function (dim, idx, stack) { - var storage = this._storage; - var dataIndex = this.indices[idx]; - - var value = storage[dim] && storage[dim][dataIndex]; - // FIXME ordinal data type is not stackable - if (stack) { - var dimensionInfo = this._dimensionInfos[dim]; - if (dimensionInfo && dimensionInfo.stackable) { - var stackedOn = this.stackedOn; - while (stackedOn) { - // Get no stacked data of stacked on - var stackedValue = stackedOn.get(dim, idx); - // Considering positive stack, negative stack and empty data - if ((value >= 0 && stackedValue > 0) // Positive stack - || (value <= 0 && stackedValue < 0) // Negative stack - ) { - value += stackedValue; - } - stackedOn = stackedOn.stackedOn; - } - } - } - return value; - }; - - /** - * Get value for multi dimensions. - * @param {Array.} [dimensions] If ignored, using all dimensions. - * @param {number} idx - * @param {boolean} stack - * @return {number} - */ - listProto.getValues = function (dimensions, idx, stack) { - var values = []; - - if (!zrUtil.isArray(dimensions)) { - stack = idx; - idx = dimensions; - dimensions = this.dimensions; - } - - for (var i = 0, len = dimensions.length; i < len; i++) { - values.push(this.get(dimensions[i], idx, stack)); - } - - return values; - }; - - /** - * If value is NaN. Inlcuding '-' - * @param {string} dim - * @param {number} idx - * @return {number} - */ - listProto.hasValue = function (idx) { - var dimensions = this.dimensions; - var dimensionInfos = this._dimensionInfos; - for (var i = 0, len = dimensions.length; i < len; i++) { - if ( - // Ordinal type can be string or number - dimensionInfos[dimensions[i]].type !== 'ordinal' - && isNaN(this.get(dimensions[i], idx)) - ) { - return false; - } - } - return true; - }; - - /** - * Get extent of data in one dimension - * @param {string} dim - * @param {boolean} stack - */ - listProto.getDataExtent = function (dim, stack) { - var dimData = this._storage[dim]; - var dimInfo = this.getDimensionInfo(dim); - stack = (dimInfo && dimInfo.stackable) && stack; - var dimExtent = (this._extent || (this._extent = {}))[dim + (!!stack)]; - var value; - if (dimExtent) { - return dimExtent; - } - // var dimInfo = this._dimensionInfos[dim]; - if (dimData) { - var min = Infinity; - var max = -Infinity; - // var isOrdinal = dimInfo.type === 'ordinal'; - for (var i = 0, len = this.count(); i < len; i++) { - value = this.get(dim, i, stack); - // FIXME - // if (isOrdinal && typeof value === 'string') { - // value = zrUtil.indexOf(dimData, value); - // console.log(value); - // } - value < min && (min = value); - value > max && (max = value); - } - return (this._extent[dim + stack] = [min, max]); - } - else { - return [Infinity, -Infinity]; - } - }; - - /** - * Get sum of data in one dimension - * @param {string} dim - * @param {boolean} stack - */ - listProto.getSum = function (dim, stack) { - var dimData = this._storage[dim]; - var sum = 0; - if (dimData) { - for (var i = 0, len = this.count(); i < len; i++) { - var value = this.get(dim, i, stack); - if (!isNaN(value)) { - sum += value; - } - } - } - return sum; - }; - - /** - * Retreive the index with given value - * @param {number} idx - * @param {number} value - * @return {number} - */ - // FIXME Precision of float value - listProto.indexOf = function (dim, value) { - var storage = this._storage; - var dimData = storage[dim]; - var indices = this.indices; - - if (dimData) { - for (var i = 0, len = indices.length; i < len; i++) { - var rawIndex = indices[i]; - if (dimData[rawIndex] === value) { - return i; - } - } - } - return -1; - }; - - /** - * Retreive the index with given name - * @param {number} idx - * @param {number} name - * @return {number} - */ - listProto.indexOfName = function (name) { - var indices = this.indices; - var nameList = this._nameList; - - for (var i = 0, len = indices.length; i < len; i++) { - var rawIndex = indices[i]; - if (nameList[rawIndex] === name) { - return i; - } - } - - return -1; - }; - - /** - * Retreive the index of nearest value - * @param {string>} dim - * @param {number} value - * @param {boolean} stack If given value is after stacked - * @return {number} - */ - listProto.indexOfNearest = function (dim, value, stack) { - var storage = this._storage; - var dimData = storage[dim]; - - if (dimData) { - var minDist = Number.MAX_VALUE; - var nearestIdx = -1; - for (var i = 0, len = this.count(); i < len; i++) { - var dist = Math.abs(this.get(dim, i, stack) - value); - if (dist <= minDist) { - minDist = dist; - nearestIdx = i; - } - } - return nearestIdx; - } - return -1; - }; - - /** - * Get raw data index - * @param {number} idx - * @return {number} - */ - listProto.getRawIndex = function (idx) { - var rawIdx = this.indices[idx]; - return rawIdx == null ? -1 : rawIdx; - }; - - /** - * @param {number} idx - * @param {boolean} [notDefaultIdx=false] - * @return {string} - */ - listProto.getName = function (idx) { - return this._nameList[this.indices[idx]] || ''; - }; - - /** - * @param {number} idx - * @param {boolean} [notDefaultIdx=false] - * @return {string} - */ - listProto.getId = function (idx) { - return this._idList[this.indices[idx]] || (this.getRawIndex(idx) + ''); - }; - - - function normalizeDimensions(dimensions) { - if (!zrUtil.isArray(dimensions)) { - dimensions = [dimensions]; - } - return dimensions; - } - - /** - * Data iteration - * @param {string|Array.} - * @param {Function} cb - * @param {boolean} [stack=false] - * @param {*} [context=this] - * - * @example - * list.each('x', function (x, idx) {}); - * list.each(['x', 'y'], function (x, y, idx) {}); - * list.each(function (idx) {}) - */ - listProto.each = function (dimensions, cb, stack, context) { - if (typeof dimensions === 'function') { - context = stack; - stack = cb; - cb = dimensions; - dimensions = []; - } - - dimensions = zrUtil.map( - normalizeDimensions(dimensions), this.getDimension, this - ); - - var value = []; - var dimSize = dimensions.length; - var indices = this.indices; - - context = context || this; - - for (var i = 0; i < indices.length; i++) { - if (dimSize === 0) { - cb.call(context, i); - } - // Simple optimization - else if (dimSize === 1) { - cb.call(context, this.get(dimensions[0], i, stack), i); - } - else { - for (var k = 0; k < dimSize; k++) { - value[k] = this.get(dimensions[k], i, stack); - } - // Index - value[k] = i; - cb.apply(context, value); - } - } - }; - - /** - * Data filter - * @param {string|Array.} - * @param {Function} cb - * @param {boolean} [stack=false] - * @param {*} [context=this] - */ - listProto.filterSelf = function (dimensions, cb, stack, context) { - if (typeof dimensions === 'function') { - context = stack; - stack = cb; - cb = dimensions; - dimensions = []; - } - - dimensions = zrUtil.map( - normalizeDimensions(dimensions), this.getDimension, this - ); - - var newIndices = []; - var value = []; - var dimSize = dimensions.length; - var indices = this.indices; - - context = context || this; - - for (var i = 0; i < indices.length; i++) { - var keep; - // Simple optimization - if (dimSize === 1) { - keep = cb.call( - context, this.get(dimensions[0], i, stack), i - ); - } - else { - for (var k = 0; k < dimSize; k++) { - value[k] = this.get(dimensions[k], i, stack); - } - value[k] = i; - keep = cb.apply(context, value); - } - if (keep) { - newIndices.push(indices[i]); - } - } - - this.indices = newIndices; - - // Reset data extent - this._extent = {}; - - return this; - }; - - /** - * Data mapping to a plain array - * @param {string|Array.} [dimensions] - * @param {Function} cb - * @param {boolean} [stack=false] - * @param {*} [context=this] - * @return {Array} - */ - listProto.mapArray = function (dimensions, cb, stack, context) { - if (typeof dimensions === 'function') { - context = stack; - stack = cb; - cb = dimensions; - dimensions = []; - } - - var result = []; - this.each(dimensions, function () { - result.push(cb && cb.apply(this, arguments)); - }, stack, context); - return result; - }; - - function cloneListForMapAndSample(original, excludeDimensions) { - var allDimensions = original.dimensions; - var list = new List( - zrUtil.map(allDimensions, original.getDimensionInfo, original), - original.hostModel - ); - // FIXME If needs stackedOn, value may already been stacked - transferImmuProperties(list, original, original._wrappedMethods); - - var storage = list._storage = {}; - var originalStorage = original._storage; - // Init storage - for (var i = 0; i < allDimensions.length; i++) { - var dim = allDimensions[i]; - var dimStore = originalStorage[dim]; - if (zrUtil.indexOf(excludeDimensions, dim) >= 0) { - storage[dim] = new dimStore.constructor( - originalStorage[dim].length - ); - } - else { - // Direct reference for other dimensions - storage[dim] = originalStorage[dim]; - } - } - return list; - } - - /** - * Data mapping to a new List with given dimensions - * @param {string|Array.} dimensions - * @param {Function} cb - * @param {boolean} [stack=false] - * @param {*} [context=this] - * @return {Array} - */ - listProto.map = function (dimensions, cb, stack, context) { - dimensions = zrUtil.map( - normalizeDimensions(dimensions), this.getDimension, this - ); - - var list = cloneListForMapAndSample(this, dimensions); - // Following properties are all immutable. - // So we can reference to the same value - var indices = list.indices = this.indices; - - var storage = list._storage; - - var tmpRetValue = []; - this.each(dimensions, function () { - var idx = arguments[arguments.length - 1]; - var retValue = cb && cb.apply(this, arguments); - if (retValue != null) { - // a number - if (typeof retValue === 'number') { - tmpRetValue[0] = retValue; - retValue = tmpRetValue; - } - for (var i = 0; i < retValue.length; i++) { - var dim = dimensions[i]; - var dimStore = storage[dim]; - var rawIdx = indices[idx]; - if (dimStore) { - dimStore[rawIdx] = retValue[i]; - } - } - } - }, stack, context); - - return list; - }; - - /** - * Large data down sampling on given dimension - * @param {string} dimension - * @param {number} rate - * @param {Function} sampleValue - * @param {Function} sampleIndex Sample index for name and id - */ - listProto.downSample = function (dimension, rate, sampleValue, sampleIndex) { - var list = cloneListForMapAndSample(this, [dimension]); - var storage = this._storage; - var targetStorage = list._storage; - - var originalIndices = this.indices; - var indices = list.indices = []; - - var frameValues = []; - var frameIndices = []; - var frameSize = Math.floor(1 / rate); - - var dimStore = targetStorage[dimension]; - var len = this.count(); - // Copy data from original data - for (var i = 0; i < storage[dimension].length; i++) { - targetStorage[dimension][i] = storage[dimension][i]; - } - for (var i = 0; i < len; i += frameSize) { - // Last frame - if (frameSize > len - i) { - frameSize = len - i; - frameValues.length = frameSize; - } - for (var k = 0; k < frameSize; k++) { - var idx = originalIndices[i + k]; - frameValues[k] = dimStore[idx]; - frameIndices[k] = idx; - } - var value = sampleValue(frameValues); - var idx = frameIndices[sampleIndex(frameValues, value) || 0]; - // Only write value on the filtered data - dimStore[idx] = value; - indices.push(idx); - } - return list; - }; - - /** - * Get model of one data item. - * - * @param {number} idx - */ - // FIXME Model proxy ? - listProto.getItemModel = function (idx) { - var hostModel = this.hostModel; - idx = this.indices[idx]; - return new Model(this._rawData[idx], hostModel, hostModel.ecModel); - }; - - /** - * Create a data differ - * @param {module:echarts/data/List} otherList - * @return {module:echarts/data/DataDiffer} - */ - listProto.diff = function (otherList) { - var idList = this._idList; - var otherIdList = otherList && otherList._idList; - return new DataDiffer( - otherList ? otherList.indices : [], this.indices, function (idx) { - return otherIdList[idx] || (idx + ''); - }, function (idx) { - return idList[idx] || (idx + ''); - } - ); - }; - /** - * Get visual property. - * @param {string} key - */ - listProto.getVisual = function (key) { - var visual = this._visual; - return visual && visual[key]; - }; - - /** - * Set visual property - * @param {string|Object} key - * @param {*} [value] - * - * @example - * setVisual('color', color); - * setVisual({ - * 'color': color - * }); - */ - listProto.setVisual = function (key, val) { - if (isObject(key)) { - for (var name in key) { - if (key.hasOwnProperty(name)) { - this.setVisual(name, key[name]); - } - } - return; - } - this._visual = this._visual || {}; - this._visual[key] = val; - }; - - /** - * Set layout property. - * @param {string} key - * @param {*} [val] - */ - listProto.setLayout = function (key, val) { - if (isObject(key)) { - for (var name in key) { - if (key.hasOwnProperty(name)) { - this.setLayout(name, key[name]); - } - } - return; - } - this._layout[key] = val; - }; - - /** - * Get layout property. - * @param {string} key. - * @return {*} - */ - listProto.getLayout = function (key) { - return this._layout[key]; - }; - - /** - * Get layout of single data item - * @param {number} idx - */ - listProto.getItemLayout = function (idx) { - return this._itemLayouts[idx]; - }, - - /** - * Set layout of single data item - * @param {number} idx - * @param {Object} layout - * @param {boolean=} [merge=false] - */ - listProto.setItemLayout = function (idx, layout, merge) { - this._itemLayouts[idx] = merge - ? zrUtil.extend(this._itemLayouts[idx] || {}, layout) - : layout; - }, - - /** - * Get visual property of single data item - * @param {number} idx - * @param {string} key - * @param {boolean} ignoreParent - */ - listProto.getItemVisual = function (idx, key, ignoreParent) { - var itemVisual = this._itemVisuals[idx]; - var val = itemVisual && itemVisual[key]; - if (val == null && !ignoreParent) { - // Use global visual property - return this.getVisual(key); - } - return val; - }, - - /** - * Set visual property of single data item - * - * @param {number} idx - * @param {string|Object} key - * @param {*} [value] - * - * @example - * setItemVisual(0, 'color', color); - * setItemVisual(0, { - * 'color': color - * }); - */ - listProto.setItemVisual = function (idx, key, value) { - var itemVisual = this._itemVisuals[idx] || {}; - this._itemVisuals[idx] = itemVisual; - - if (isObject(key)) { - for (var name in key) { - if (key.hasOwnProperty(name)) { - itemVisual[name] = key[name]; - } - } - return; - } - itemVisual[key] = value; - }; - - var setItemDataAndSeriesIndex = function (child) { - child.seriesIndex = this.seriesIndex; - child.dataIndex = this.dataIndex; - }; - /** - * Set graphic element relative to data. It can be set as null - * @param {number} idx - * @param {module:zrender/Element} [el] - */ - listProto.setItemGraphicEl = function (idx, el) { - var hostModel = this.hostModel; - - if (el) { - // Add data index and series index for indexing the data by element - // Useful in tooltip - el.dataIndex = idx; - el.seriesIndex = hostModel && hostModel.seriesIndex; - if (el.type === 'group') { - el.traverse(setItemDataAndSeriesIndex, el); - } - } - - this._graphicEls[idx] = el; - }; - - /** - * @param {number} idx - * @return {module:zrender/Element} - */ - listProto.getItemGraphicEl = function (idx) { - return this._graphicEls[idx]; - }; - - /** - * @param {Function} cb - * @param {*} context - */ - listProto.eachItemGraphicEl = function (cb, context) { - zrUtil.each(this._graphicEls, function (el, idx) { - if (el) { - cb && cb.call(context, el, idx); - } - }); - }; - - /** - * Shallow clone a new list except visual and layout properties, and graph elements. - * New list only change the indices. - */ - listProto.cloneShallow = function () { - var dimensionInfoList = zrUtil.map(this.dimensions, this.getDimensionInfo, this); - var list = new List(dimensionInfoList, this.hostModel); - - // FIXME - list._storage = this._storage; - - transferImmuProperties(list, this, this._wrappedMethods); - - list.indices = this.indices.slice(); - - return list; - }; - - /** - * Wrap some method to add more feature - * @param {string} methodName - * @param {Function} injectFunction - */ - listProto.wrapMethod = function (methodName, injectFunction) { - var originalMethod = this[methodName]; - if (typeof originalMethod !== 'function') { - return; - } - this._wrappedMethods = this._wrappedMethods || []; - this._wrappedMethods.push(methodName); - this[methodName] = function () { - var res = originalMethod.apply(this, arguments); - return injectFunction.call(this, res); - }; - }; - - return List; -}); -/** - * Complete dimensions by data (guess dimension). - */ -define('echarts/data/helper/completeDimensions',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - function completeDimensions(dimensions, data, defaultNames) { - if (!data) { - return dimensions; - } - - var value0 = retrieveValue(data[0]); - var dimSize = zrUtil.isArray(value0) && value0.length || 1; - - defaultNames = defaultNames || []; - for (var i = 0; i < dimSize; i++) { - if (!dimensions[i]) { - var name = defaultNames[i] || ('extra' + (i - defaultNames.length)); - dimensions[i] = guessOrdinal(data, i) - ? {type: 'ordinal', name: name} - : name; - } - } - - return dimensions; - } - - // The rule should not be complex, otherwise user might not - // be able to known where the data is wrong. - function guessOrdinal(data, dimIndex) { - for (var i = 0, len = data.length; i < len; i++) { - var value = retrieveValue(data[i]); - - if (!zrUtil.isArray(value)) { - return false; - } - - var value = value[dimIndex]; - if (value != null && isFinite(value)) { - return false; - } - else if (zrUtil.isString(value) && value !== '-') { - return true; - } - } - return false; - } - - function retrieveValue(o) { - return zrUtil.isArray(o) ? o : zrUtil.isObject(o) ? o.value: o; - } - - return completeDimensions; - -}); -define('echarts/chart/helper/createListFromArray',['require','../../data/List','../../data/helper/completeDimensions','zrender/core/util','../../util/model','../../CoordinateSystem'],function(require) { - - - var List = require('../../data/List'); - var completeDimensions = require('../../data/helper/completeDimensions'); - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../../util/model'); - var CoordinateSystem = require('../../CoordinateSystem'); - var getDataItemValue = modelUtil.getDataItemValue; - var converDataValue = modelUtil.converDataValue; - - function firstDataNotNull(data) { - var i = 0; - while (i < data.length && data[i] == null) { - i++; - } - return data[i]; - } - function ifNeedCompleteOrdinalData(data) { - var sampleItem = firstDataNotNull(data); - return sampleItem != null - && !zrUtil.isArray(getDataItemValue(sampleItem)); - } - - /** - * Helper function to create a list from option data - */ - function createListFromArray(data, seriesModel, ecModel) { - // If data is undefined - data = data || []; - - var coordSysName = seriesModel.get('coordinateSystem'); - var creator = creators[coordSysName]; - var registeredCoordSys = CoordinateSystem.get(coordSysName); - // FIXME - var result = creator && creator(data, seriesModel, ecModel); - var dimensions = result && result.dimensions; - if (!dimensions) { - // Get dimensions from registered coordinate system - dimensions = (registeredCoordSys && registeredCoordSys.dimensions) || ['x', 'y']; - dimensions = completeDimensions(dimensions, data, dimensions.concat(['value'])); - } - var categoryAxisModel = result && result.categoryAxisModel; - - var categoryDimIndex = dimensions[0].type === 'ordinal' - ? 0 : (dimensions[1].type === 'ordinal' ? 1 : -1); - - var list = new List(dimensions, seriesModel); - - var nameList = createNameList(result, data); - - var dimValueGetter = (categoryAxisModel && ifNeedCompleteOrdinalData(data)) - ? function (itemOpt, dimName, dataIndex, dimIndex) { - // Use dataIndex as ordinal value in categoryAxis - return dimIndex === categoryDimIndex - ? dataIndex - : converDataValue(getDataItemValue(itemOpt), dimensions[dimIndex]); - } - : function (itemOpt, dimName, dataIndex, dimIndex) { - var val = getDataItemValue(itemOpt); - return converDataValue(val && val[dimIndex], dimensions[dimIndex]); - }; - - list.initData(data, nameList, dimValueGetter); - - return list; - } - - function isStackable(axisType) { - return axisType !== 'category' && axisType !== 'time'; - } - - function getDimTypeByAxis(axisType) { - return axisType === 'category' - ? 'ordinal' - : axisType === 'time' - ? 'time' - : 'float'; - } - - /** - * Creaters for each coord system. - * @return {Object} {dimensions, categoryAxisModel}; - */ - var creators = { - - cartesian2d: function (data, seriesModel, ecModel) { - var xAxisModel = ecModel.getComponent('xAxis', seriesModel.get('xAxisIndex')); - var yAxisModel = ecModel.getComponent('yAxis', seriesModel.get('yAxisIndex')); - var xAxisType = xAxisModel.get('type'); - var yAxisType = yAxisModel.get('type'); - - var dimensions = [ - { - name: 'x', - type: getDimTypeByAxis(xAxisType), - stackable: isStackable(xAxisType) - }, - { - name: 'y', - // If two category axes - type: getDimTypeByAxis(yAxisType), - stackable: isStackable(yAxisType) - } - ]; - - completeDimensions(dimensions, data, ['x', 'y', 'z']); - - return { - dimensions: dimensions, - categoryAxisModel: xAxisType === 'category' - ? xAxisModel - : (yAxisType === 'category' ? yAxisModel : null) - }; - }, - - polar: function (data, seriesModel, ecModel) { - var polarIndex = seriesModel.get('polarIndex') || 0; - - var axisFinder = function (axisModel) { - return axisModel.get('polarIndex') === polarIndex; - }; - - var angleAxisModel = ecModel.findComponents({ - mainType: 'angleAxis', filter: axisFinder - })[0]; - var radiusAxisModel = ecModel.findComponents({ - mainType: 'radiusAxis', filter: axisFinder - })[0]; - - var radiusAxisType = radiusAxisModel.get('type'); - var angleAxisType = angleAxisModel.get('type'); - - var dimensions = [ - { - name: 'radius', - type: getDimTypeByAxis(radiusAxisType), - stackable: isStackable(radiusAxisType) - }, - { - name: 'angle', - type: getDimTypeByAxis(angleAxisType), - stackable: isStackable(angleAxisType) - } - ]; - - completeDimensions(dimensions, data, ['radius', 'angle', 'value']); - - return { - dimensions: dimensions, - categoryAxisModel: angleAxisType === 'category' - ? angleAxisModel - : (radiusAxisType === 'category' ? radiusAxisModel : null) - }; - }, - - geo: function (data, seriesModel, ecModel) { - // TODO Region - // 多个散点图系列在同一个地区的时候 - return { - dimensions: completeDimensions([ - {name: 'lng'}, - {name: 'lat'} - ], data, ['lng', 'lat', 'value']) - }; - } - }; - - function createNameList(result, data) { - var nameList = []; - - if (result && result.categoryAxisModel) { - // FIXME Two category axis - var categories = result.categoryAxisModel.getCategories(); - if (categories) { - var dataLen = data.length; - // Ordered data is given explicitly like - // [[3, 0.2], [1, 0.3], [2, 0.15]] - // or given scatter data, - // pick the category - if (zrUtil.isArray(data[0]) && data[0].length > 1) { - nameList = []; - for (var i = 0; i < dataLen; i++) { - nameList[i] = categories[data[i][0]]; - } - } - else { - nameList = categories.slice(0); - } - } - } - - return nameList; - } - - return createListFromArray; - -}); -define('echarts/chart/line/LineSeries',['require','../helper/createListFromArray','../../model/Series'],function(require) { - - - - var createListFromArray = require('../helper/createListFromArray'); - var SeriesModel = require('../../model/Series'); - - return SeriesModel.extend({ - - type: 'series.line', - - dependencies: ['grid', 'polar'], - - getInitialData: function (option, ecModel) { - return createListFromArray(option.data, this, ecModel); - }, - - defaultOption: { - zlevel: 0, // 一级层叠 - z: 2, // 二级层叠 - coordinateSystem: 'cartesian2d', - legendHoverLink: true, - - hoverAnimation: true, - // stack: null - xAxisIndex: 0, - yAxisIndex: 0, - - polarIndex: 0, - - // If clip the overflow value - clipOverflow: true, - - label: { - normal: { - // show: false, - position: 'top' - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 - // 'inside'|'left'|'right'|'top'|'bottom' - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - }, - emphasis: { - // show: false, - position: 'top' - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为 - // 'inside'|'left'|'right'|'top'|'bottom' - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - } - }, - // itemStyle: { - // normal: { - // // color: 各异 - // }, - // emphasis: { - // // color: 各异, - // } - // }, - lineStyle: { - normal: { - width: 2, - type: 'solid' - } - }, - // areaStyle: { - // }, - // smooth: false, - // smoothMonotone: null, - // 拐点图形类型 - symbol: 'emptyCircle', - // 拐点图形大小 - symbolSize: 4, - // 拐点图形旋转控制 - // symbolRotate: null, - - // 是否显示 symbol, 只有在 tooltip hover 的时候显示 - showSymbol: true, - // 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略) - // showAllSymbol: false - // - // 大数据过滤,'average', 'max', 'min', 'sum' - // sampling: 'none' - - animationEasing: 'linear' - } - }); -}); -// Symbol factory -define('echarts/util/symbol',['require','./graphic','zrender/core/BoundingRect'],function(require) { - - - - var graphic = require('./graphic'); - var BoundingRect = require('zrender/core/BoundingRect'); - - /** - * Triangle shape - * @inner - */ - var Triangle = graphic.extendShape({ - type: 'triangle', - shape: { - cx: 0, - cy: 0, - width: 0, - height: 0 - }, - buildPath: function (path, shape) { - var cx = shape.cx; - var cy = shape.cy; - var width = shape.width / 2; - var height = shape.height / 2; - path.moveTo(cx, cy - height); - path.lineTo(cx + width, cy + height); - path.lineTo(cx - width, cy + height); - path.closePath(); - } - }); - /** - * Diamond shape - * @inner - */ - var Diamond = graphic.extendShape({ - type: 'diamond', - shape: { - cx: 0, - cy: 0, - width: 0, - height: 0 - }, - buildPath: function (path, shape) { - var cx = shape.cx; - var cy = shape.cy; - var width = shape.width / 2; - var height = shape.height / 2; - path.moveTo(cx, cy - height); - path.lineTo(cx + width, cy); - path.lineTo(cx, cy + height); - path.lineTo(cx - width, cy); - path.closePath(); - } - }); - - /** - * Pin shape - * @inner - */ - var Pin = graphic.extendShape({ - type: 'pin', - shape: { - // x, y on the cusp - x: 0, - y: 0, - width: 0, - height: 0 - }, - - buildPath: function (path, shape) { - var x = shape.x; - var y = shape.y; - var w = shape.width / 5 * 3; - // Height must be larger than width - var h = Math.max(w, shape.height); - var r = w / 2; - - // Dist on y with tangent point and circle center - var dy = r * r / (h - r); - var cy = y - h + r + dy; - var angle = Math.asin(dy / r); - // Dist on x with tangent point and circle center - var dx = Math.cos(angle) * r; - - var tanX = Math.sin(angle); - var tanY = Math.cos(angle); - - path.arc( - x, cy, r, - Math.PI - angle, - Math.PI * 2 + angle - ); - - var cpLen = r * 0.6; - var cpLen2 = r * 0.7; - path.bezierCurveTo( - x + dx - tanX * cpLen, cy + dy + tanY * cpLen, - x, y - cpLen2, - x, y - ); - path.bezierCurveTo( - x, y - cpLen2, - x - dx + tanX * cpLen, cy + dy + tanY * cpLen, - x - dx, cy + dy - ); - path.closePath(); - } - }); - - /** - * Arrow shape - * @inner - */ - var Arrow = graphic.extendShape({ - - type: 'arrow', - - shape: { - x: 0, - y: 0, - width: 0, - height: 0 - }, - - buildPath: function (ctx, shape) { - var height = shape.height; - var width = shape.width; - var x = shape.x; - var y = shape.y; - var dx = width / 3 * 2; - ctx.moveTo(x, y); - ctx.lineTo(x + dx, y + height); - ctx.lineTo(x, y + height / 4 * 3); - ctx.lineTo(x - dx, y + height); - ctx.lineTo(x, y); - ctx.closePath(); - } - }); - - /** - * Map of path contructors - * @type {Object.} - */ - var symbolCtors = { - line: graphic.Line, - - rect: graphic.Rect, - - roundRect: graphic.Rect, - - square: graphic.Rect, - - circle: graphic.Circle, - - diamond: Diamond, - - pin: Pin, - - arrow: Arrow, - - triangle: Triangle - }; - - var symbolShapeMakers = { - - line: function (x, y, w, h, shape) { - // FIXME - shape.x1 = x; - shape.y1 = y + h / 2; - shape.x2 = x + w; - shape.y2 = y + h / 2; - }, - - rect: function (x, y, w, h, shape) { - shape.x = x; - shape.y = y; - shape.width = w; - shape.height = h; - }, - - roundRect: function (x, y, w, h, shape) { - shape.x = x; - shape.y = y; - shape.width = w; - shape.height = h; - shape.r = Math.min(w, h) / 4; - }, - - square: function (x, y, w, h, shape) { - var size = Math.min(w, h); - shape.x = x; - shape.y = y; - shape.width = size; - shape.height = size; - }, - - circle: function (x, y, w, h, shape) { - // Put circle in the center of square - shape.cx = x + w / 2; - shape.cy = y + h / 2; - shape.r = Math.min(w, h) / 2; - }, - - diamond: function (x, y, w, h, shape) { - shape.cx = x + w / 2; - shape.cy = y + h / 2; - shape.width = w; - shape.height = h; - }, - - pin: function (x, y, w, h, shape) { - shape.x = x + w / 2; - shape.y = y + h / 2; - shape.width = w; - shape.height = h; - }, - - arrow: function (x, y, w, h, shape) { - shape.x = x + w / 2; - shape.y = y + h / 2; - shape.width = w; - shape.height = h; - }, - - triangle: function (x, y, w, h, shape) { - shape.cx = x + w / 2; - shape.cy = y + h / 2; - shape.width = w; - shape.height = h; - } - }; - - var symbolBuildProxies = {}; - for (var name in symbolCtors) { - symbolBuildProxies[name] = new symbolCtors[name](); - } - - var Symbol = graphic.extendShape({ - - type: 'symbol', - - shape: { - symbolType: '', - x: 0, - y: 0, - width: 0, - height: 0 - }, - - beforeBrush: function () { - var style = this.style; - var shape = this.shape; - // FIXME - if (shape.symbolType === 'pin' && style.textPosition === 'inside') { - style.textPosition = ['50%', '40%']; - style.textAlign = 'center'; - style.textBaseline = 'middle'; - } - }, - - buildPath: function (ctx, shape) { - var symbolType = shape.symbolType; - var proxySymbol = symbolBuildProxies[symbolType]; - if (shape.symbolType !== 'none') { - if (!proxySymbol) { - // Default rect - symbolType = 'rect'; - proxySymbol = symbolBuildProxies[symbolType]; - } - symbolShapeMakers[symbolType]( - shape.x, shape.y, shape.width, shape.height, proxySymbol.shape - ); - proxySymbol.buildPath(ctx, proxySymbol.shape); - } - } - }); - - // Provide setColor helper method to avoid determine if set the fill or stroke outside - var symbolPathSetColor = function (color) { - if (this.type !== 'image') { - var symbolStyle = this.style; - var symbolShape = this.shape; - if (symbolShape && symbolShape.symbolType === 'line') { - symbolStyle.stroke = color; - } - else if (this.__isEmptyBrush) { - symbolStyle.stroke = color; - symbolStyle.fill = '#fff'; - } - else { - // FIXME 判断图形默认是填充还是描边,使用 onlyStroke ? - symbolStyle.fill && (symbolStyle.fill = color); - symbolStyle.stroke && (symbolStyle.stroke = color); - } - this.dirty(); - } - }; - - var symbolUtil = { - /** - * Create a symbol element with given symbol configuration: shape, x, y, width, height, color - * @param {string} symbolType - * @param {number} x - * @param {number} y - * @param {number} w - * @param {number} h - * @param {string} color - */ - createSymbol: function (symbolType, x, y, w, h, color) { - var isEmpty = symbolType.indexOf('empty') === 0; - if (isEmpty) { - symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6); - } - var symbolPath; - - if (symbolType.indexOf('image://') === 0) { - symbolPath = new graphic.Image({ - style: { - image: symbolType.slice(8), - x: x, - y: y, - width: w, - height: h - } - }); - } - else if (symbolType.indexOf('path://') === 0) { - symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h)); - } - else { - symbolPath = new Symbol({ - shape: { - symbolType: symbolType, - x: x, - y: y, - width: w, - height: h - } - }); - } - - symbolPath.__isEmptyBrush = isEmpty; - - symbolPath.setColor = symbolPathSetColor; - - symbolPath.setColor(color); - - return symbolPath; - } - }; - - return symbolUtil; -}); -/** - * @module echarts/chart/helper/Symbol - */ -define('echarts/chart/helper/Symbol',['require','zrender/core/util','../../util/symbol','../../util/graphic','../../util/number'],function (require) { - - var zrUtil = require('zrender/core/util'); - var symbolUtil = require('../../util/symbol'); - var graphic = require('../../util/graphic'); - var numberUtil = require('../../util/number'); - - function normalizeSymbolSize(symbolSize) { - if (!zrUtil.isArray(symbolSize)) { - symbolSize = [+symbolSize, +symbolSize]; - } - return symbolSize; - } - - /** - * @constructor - * @alias {module:echarts/chart/helper/Symbol} - * @param {module:echarts/data/List} data - * @param {number} idx - * @extends {module:zrender/graphic/Group} - */ - function Symbol(data, idx) { - graphic.Group.call(this); - - this.updateData(data, idx); - } - - var symbolProto = Symbol.prototype; - - function driftSymbol(dx, dy) { - this.parent.drift(dx, dy); - } - - symbolProto._createSymbol = function (symbolType, data, idx) { - // Remove paths created before - this.removeAll(); - - var seriesModel = data.hostModel; - var color = data.getItemVisual(idx, 'color'); - - var symbolPath = symbolUtil.createSymbol( - symbolType, -0.5, -0.5, 1, 1, color - ); - - symbolPath.attr({ - style: { - strokeNoScale: true - }, - z2: 100, - culling: true, - scale: [0, 0] - }); - // Rewrite drift method - symbolPath.drift = driftSymbol; - - var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); - - graphic.initProps(symbolPath, { - scale: size - }, seriesModel); - - this._symbolType = symbolType; - - this.add(symbolPath); - }; - - /** - * Stop animation - * @param {boolean} toLastFrame - */ - symbolProto.stopSymbolAnimation = function (toLastFrame) { - this.childAt(0).stopAnimation(toLastFrame); - }; - - /** - * Get scale(aka, current symbol size). - * Including the change caused by animation - * @param {Array.} toLastFrame - */ - symbolProto.getScale = function () { - return this.childAt(0).scale; - }; - - /** - * Highlight symbol - */ - symbolProto.highlight = function () { - this.childAt(0).trigger('emphasis'); - }; - - /** - * Downplay symbol - */ - symbolProto.downplay = function () { - this.childAt(0).trigger('normal'); - }; - - /** - * @param {number} zlevel - * @param {number} z - */ - symbolProto.setZ = function (zlevel, z) { - var symbolPath = this.childAt(0); - symbolPath.zlevel = zlevel; - symbolPath.z = z; - }; - - symbolProto.setDraggable = function (draggable) { - var symbolPath = this.childAt(0); - symbolPath.draggable = draggable; - symbolPath.cursor = draggable ? 'move' : 'pointer'; - }; - /** - * Update symbol properties - * @param {module:echarts/data/List} data - * @param {number} idx - */ - symbolProto.updateData = function (data, idx) { - var symbolType = data.getItemVisual(idx, 'symbol') || 'circle'; - var seriesModel = data.hostModel; - var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); - if (symbolType !== this._symbolType) { - this._createSymbol(symbolType, data, idx); - } - else { - var symbolPath = this.childAt(0); - graphic.updateProps(symbolPath, { - scale: symbolSize - }, seriesModel); - } - this._updateCommon(data, idx, symbolSize); - - this._seriesModel = seriesModel; - }; - - // Update common properties - var normalStyleAccessPath = ['itemStyle', 'normal']; - var emphasisStyleAccessPath = ['itemStyle', 'emphasis']; - var normalLabelAccessPath = ['label', 'normal']; - var emphasisLabelAccessPath = ['label', 'emphasis']; - - symbolProto._updateCommon = function (data, idx, symbolSize) { - var symbolPath = this.childAt(0); - var seriesModel = data.hostModel; - var itemModel = data.getItemModel(idx); - var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath); - var color = data.getItemVisual(idx, 'color'); - - var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle(); - - symbolPath.rotation = itemModel.getShallow('symbolRotate') * Math.PI / 180 || 0; - - var symbolOffset = itemModel.getShallow('symbolOffset'); - if (symbolOffset) { - var pos = symbolPath.position; - pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]); - pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]); - } - - symbolPath.setColor(color); - - zrUtil.extend( - symbolPath.style, - // Color must be excluded. - // Because symbol provide setColor individually to set fill and stroke - normalItemStyleModel.getItemStyle(['color']) - ); - - var labelModel = itemModel.getModel(normalLabelAccessPath); - var hoverLabelModel = itemModel.getModel(emphasisLabelAccessPath); - - var elStyle = symbolPath.style; - - // Get last value dim - var dimensions = data.dimensions.slice(); - var valueDim = dimensions.pop(); - var dataType; - while ( - ((dataType = data.getDimensionInfo(valueDim).type) === 'ordinal') - || (dataType === 'time') - ) { - valueDim = dimensions.pop(); - } - - if (labelModel.get('show')) { - graphic.setText(elStyle, labelModel, color); - elStyle.text = zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'normal'), - data.get(valueDim, idx) - ); - } - else { - elStyle.text = ''; - } - - if (hoverLabelModel.getShallow('show')) { - graphic.setText(hoverStyle, hoverLabelModel, color); - hoverStyle.text = zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'emphasis'), - data.get(valueDim, idx) - ); - } - else { - hoverStyle.text = ''; - } - - var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); - - symbolPath.off('mouseover') - .off('mouseout') - .off('emphasis') - .off('normal'); - - graphic.setHoverStyle(symbolPath, hoverStyle); - - if (itemModel.getShallow('hoverAnimation')) { - var onEmphasis = function() { - var ratio = size[1] / size[0]; - this.animateTo({ - scale: [ - Math.max(size[0] * 1.1, size[0] + 3), - Math.max(size[1] * 1.1, size[1] + 3 * ratio) - ] - }, 400, 'elasticOut'); - }; - var onNormal = function() { - this.animateTo({ - scale: size - }, 400, 'elasticOut'); - }; - symbolPath.on('mouseover', onEmphasis) - .on('mouseout', onNormal) - .on('emphasis', onEmphasis) - .on('normal', onNormal); - } - }; - - symbolProto.fadeOut = function (cb) { - var symbolPath = this.childAt(0); - // Not show text when animating - symbolPath.style.text = ''; - graphic.updateProps(symbolPath, { - scale: [0, 0] - }, this._seriesModel, cb); - }; - - zrUtil.inherits(Symbol, graphic.Group); - - return Symbol; -}); -/** - * @module echarts/chart/helper/SymbolDraw - */ -define('echarts/chart/helper/SymbolDraw',['require','../../util/graphic','./Symbol'],function (require) { - - var graphic = require('../../util/graphic'); - var Symbol = require('./Symbol'); - - /** - * @constructor - * @alias module:echarts/chart/helper/SymbolDraw - * @param {module:zrender/graphic/Group} [symbolCtor] - */ - function SymbolDraw(symbolCtor) { - this.group = new graphic.Group(); - - this._symbolCtor = symbolCtor || Symbol; - } - - var symbolDrawProto = SymbolDraw.prototype; - - function symbolNeedsDraw(data, idx, isIgnore) { - var point = data.getItemLayout(idx); - return point && !isNaN(point[0]) && !isNaN(point[1]) && !(isIgnore && isIgnore(idx)) - && data.getItemVisual(idx, 'symbol') !== 'none'; - } - /** - * Update symbols draw by new data - * @param {module:echarts/data/List} data - * @param {Array.} [isIgnore] - */ - symbolDrawProto.updateData = function (data, isIgnore) { - var group = this.group; - var seriesModel = data.hostModel; - var oldData = this._data; - - var SymbolCtor = this._symbolCtor; - - data.diff(oldData) - .add(function (newIdx) { - var point = data.getItemLayout(newIdx); - if (symbolNeedsDraw(data, newIdx, isIgnore)) { - var symbolEl = new SymbolCtor(data, newIdx); - symbolEl.attr('position', point); - data.setItemGraphicEl(newIdx, symbolEl); - group.add(symbolEl); - } - }) - .update(function (newIdx, oldIdx) { - var symbolEl = oldData.getItemGraphicEl(oldIdx); - var point = data.getItemLayout(newIdx); - if (!symbolNeedsDraw(data, newIdx, isIgnore)) { - group.remove(symbolEl); - return; - } - if (!symbolEl) { - symbolEl = new SymbolCtor(data, newIdx); - symbolEl.attr('position', point); - } - else { - symbolEl.updateData(data, newIdx); - graphic.updateProps(symbolEl, { - position: point - }, seriesModel); - } - - // Add back - group.add(symbolEl); - - data.setItemGraphicEl(newIdx, symbolEl); - }) - .remove(function (oldIdx) { - var el = oldData.getItemGraphicEl(oldIdx); - el && el.fadeOut(function () { - group.remove(el); - }); - }) - .execute(); - - this._data = data; - }; - - symbolDrawProto.updateLayout = function () { - var data = this._data; - if (data) { - // Not use animation - data.eachItemGraphicEl(function (el, idx) { - el.attr('position', data.getItemLayout(idx)); - }); - } - }; - - symbolDrawProto.remove = function (enableAnimation) { - var group = this.group; - var data = this._data; - if (data) { - if (enableAnimation) { - data.eachItemGraphicEl(function (el) { - el.fadeOut(function () { - group.remove(el); - }); - }); - } - else { - group.removeAll(); - } - } - }; - - return SymbolDraw; -}); -define('echarts/chart/line/lineAnimationDiff',['require'],function (require) { - - // var arrayDiff = require('zrender/core/arrayDiff'); - // 'zrender/core/arrayDiff' has been used before, but it did - // not do well in performance when roam with fixed dataZoom window. - - function sign(val) { - return val >= 0 ? 1 : -1; - } - - function getStackedOnPoint(coordSys, data, idx) { - var baseAxis = coordSys.getBaseAxis(); - var valueAxis = coordSys.getOtherAxis(baseAxis); - var valueStart = baseAxis.onZero - ? 0 : valueAxis.scale.getExtent()[0]; - - var valueDim = valueAxis.dim; - var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0; - - var stackedOnSameSign; - var stackedOn = data.stackedOn; - var val = data.get(valueDim, idx); - // Find first stacked value with same sign - while (stackedOn && - sign(stackedOn.get(valueDim, idx)) === sign(val) - ) { - stackedOnSameSign = stackedOn; - break; - } - var stackedData = []; - stackedData[baseDataOffset] = data.get(baseAxis.dim, idx); - stackedData[1 - baseDataOffset] = stackedOnSameSign - ? stackedOnSameSign.get(valueDim, idx, true) : valueStart; - - return coordSys.dataToPoint(stackedData); - } - - // function convertToIntId(newIdList, oldIdList) { - // // Generate int id instead of string id. - // // Compare string maybe slow in score function of arrDiff - - // // Assume id in idList are all unique - // var idIndicesMap = {}; - // var idx = 0; - // for (var i = 0; i < newIdList.length; i++) { - // idIndicesMap[newIdList[i]] = idx; - // newIdList[i] = idx++; - // } - // for (var i = 0; i < oldIdList.length; i++) { - // var oldId = oldIdList[i]; - // // Same with newIdList - // if (idIndicesMap[oldId]) { - // oldIdList[i] = idIndicesMap[oldId]; - // } - // else { - // oldIdList[i] = idx++; - // } - // } - // } - - function diffData(oldData, newData) { - var diffResult = []; - - newData.diff(oldData) - .add(function (idx) { - diffResult.push({cmd: '+', idx: idx}); - }) - .update(function (newIdx, oldIdx) { - diffResult.push({cmd: '=', idx: oldIdx, idx1: newIdx}); - }) - .remove(function (idx) { - diffResult.push({cmd: '-', idx: idx}); - }) - .execute(); - - return diffResult; - } - - return function ( - oldData, newData, - oldStackedOnPoints, newStackedOnPoints, - oldCoordSys, newCoordSys - ) { - var diff = diffData(oldData, newData); - - // var newIdList = newData.mapArray(newData.getId); - // var oldIdList = oldData.mapArray(oldData.getId); - - // convertToIntId(newIdList, oldIdList); - - // // FIXME One data ? - // diff = arrayDiff(oldIdList, newIdList); - - var currPoints = []; - var nextPoints = []; - // Points for stacking base line - var currStackedPoints = []; - var nextStackedPoints = []; - - var status = []; - var sortedIndices = []; - var rawIndices = []; - var dims = newCoordSys.dimensions; - for (var i = 0; i < diff.length; i++) { - var diffItem = diff[i]; - var pointAdded = true; - - // FIXME, animation is not so perfect when dataZoom window moves fast - // Which is in case remvoing or add more than one data in the tail or head - switch (diffItem.cmd) { - case '=': - var currentPt = oldData.getItemLayout(diffItem.idx); - var nextPt = newData.getItemLayout(diffItem.idx1); - // If previous data is NaN, use next point directly - if (isNaN(currentPt[0]) || isNaN(currentPt[1])) { - currentPt = nextPt.slice(); - } - currPoints.push(currentPt); - nextPoints.push(nextPt); - - currStackedPoints.push(oldStackedOnPoints[diffItem.idx]); - nextStackedPoints.push(newStackedOnPoints[diffItem.idx1]); - - rawIndices.push(newData.getRawIndex(diffItem.idx1)); - break; - case '+': - var idx = diffItem.idx; - currPoints.push( - oldCoordSys.dataToPoint([ - newData.get(dims[0], idx, true), newData.get(dims[1], idx, true) - ]) - ); - - nextPoints.push(newData.getItemLayout(idx).slice()); - - currStackedPoints.push( - getStackedOnPoint(oldCoordSys, newData, idx) - ); - nextStackedPoints.push(newStackedOnPoints[idx]); - - rawIndices.push(newData.getRawIndex(idx)); - break; - case '-': - var idx = diffItem.idx; - var rawIndex = oldData.getRawIndex(idx); - // Data is replaced. In the case of dynamic data queue - // FIXME FIXME FIXME - if (rawIndex !== idx) { - currPoints.push(oldData.getItemLayout(idx)); - nextPoints.push(newCoordSys.dataToPoint([ - oldData.get(dims[0], idx, true), oldData.get(dims[1], idx, true) - ])); - - currStackedPoints.push(oldStackedOnPoints[idx]); - nextStackedPoints.push( - getStackedOnPoint( - newCoordSys, oldData, idx - ) - ); - - rawIndices.push(rawIndex); - } - else { - pointAdded = false; - } - } - - // Original indices - if (pointAdded) { - status.push(diffItem); - sortedIndices.push(sortedIndices.length); - } - } - - // Diff result may be crossed if all items are changed - // Sort by data index - sortedIndices.sort(function (a, b) { - return rawIndices[a] - rawIndices[b]; - }); - - var sortedCurrPoints = []; - var sortedNextPoints = []; - - var sortedCurrStackedPoints = []; - var sortedNextStackedPoints = []; - - var sortedStatus = []; - for (var i = 0; i < sortedIndices.length; i++) { - var idx = sortedIndices[i]; - sortedCurrPoints[i] = currPoints[idx]; - sortedNextPoints[i] = nextPoints[idx]; - - sortedCurrStackedPoints[i] = currStackedPoints[idx]; - sortedNextStackedPoints[i] = nextStackedPoints[idx]; - - sortedStatus[i] = status[idx]; - } - - return { - current: sortedCurrPoints, - next: sortedNextPoints, - - stackedOnCurrent: sortedCurrStackedPoints, - stackedOnNext: sortedNextStackedPoints, - - status: sortedStatus - }; - }; -}); -// Poly path support NaN point -define('echarts/chart/line/poly',['require','zrender/graphic/Path','zrender/core/vector'],function (require) { - - var Path = require('zrender/graphic/Path'); - var vec2 = require('zrender/core/vector'); - - var vec2Min = vec2.min; - var vec2Max = vec2.max; - - var scaleAndAdd = vec2.scaleAndAdd; - var v2Copy = vec2.copy; - - // Temporary variable - var v = []; - var cp0 = []; - var cp1 = []; - - function drawSegment( - ctx, points, start, stop, len, - dir, smoothMin, smoothMax, smooth, smoothMonotone - ) { - var idx = start; - for (var k = 0; k < len; k++) { - var p = points[idx]; - if (idx >= stop || idx < 0 || isNaN(p[0]) || isNaN(p[1])) { - break; - } - - if (idx === start) { - ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]); - v2Copy(cp0, p); - } - else { - if (smooth > 0) { - var prevIdx = idx - dir; - var nextIdx = idx + dir; - - var ratioNextSeg = 0.5; - var prevP = points[prevIdx]; - var nextP = points[nextIdx]; - // Last point - if ((dir > 0 && (idx === len - 1 || isNaN(nextP[0]) || isNaN(nextP[1]))) - || (dir <= 0 && (idx === 0 || isNaN(nextP[0]) || isNaN(nextP[1]))) - ) { - v2Copy(cp1, p); - } - else { - // If next data is null - if (isNaN(nextP[0]) || isNaN(nextP[1])) { - nextP = p; - } - - vec2.sub(v, nextP, prevP); - - var lenPrevSeg; - var lenNextSeg; - if (smoothMonotone === 'x' || smoothMonotone === 'y') { - var dim = smoothMonotone === 'x' ? 0 : 1; - lenPrevSeg = Math.abs(p[dim] - prevP[dim]); - lenNextSeg = Math.abs(p[dim] - nextP[dim]); - } - else { - lenPrevSeg = vec2.dist(p, prevP); - lenNextSeg = vec2.dist(p, nextP); - } - - // Use ratio of seg length - ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg); - - scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg)); - } - // Smooth constraint - vec2Min(cp0, cp0, smoothMax); - vec2Max(cp0, cp0, smoothMin); - vec2Min(cp1, cp1, smoothMax); - vec2Max(cp1, cp1, smoothMin); - - ctx.bezierCurveTo( - cp0[0], cp0[1], - cp1[0], cp1[1], - p[0], p[1] - ); - // cp0 of next segment - scaleAndAdd(cp0, p, v, smooth * ratioNextSeg); - } - else { - ctx.lineTo(p[0], p[1]); - } - } - - idx += dir; - } - - return k; - } - - function getBoundingBox(points, smoothConstraint) { - var ptMin = [Infinity, Infinity]; - var ptMax = [-Infinity, -Infinity]; - if (smoothConstraint) { - for (var i = 0; i < points.length; i++) { - var pt = points[i]; - if (pt[0] < ptMin[0]) { ptMin[0] = pt[0]; } - if (pt[1] < ptMin[1]) { ptMin[1] = pt[1]; } - if (pt[0] > ptMax[0]) { ptMax[0] = pt[0]; } - if (pt[1] > ptMax[1]) { ptMax[1] = pt[1]; } - } - } - return { - min: smoothConstraint ? ptMin : ptMax, - max: smoothConstraint ? ptMax : ptMin - }; - } - - return { - - Polyline: Path.extend({ - - type: 'ec-polyline', - - shape: { - points: [], - - smooth: 0, - - smoothConstraint: true, - - smoothMonotone: null - }, - - style: { - fill: null, - - stroke: '#000' - }, - - buildPath: function (ctx, shape) { - var points = shape.points; - - var i = 0; - var len = points.length; - - var result = getBoundingBox(points, shape.smoothConstraint); - - while (i < len) { - i += drawSegment( - ctx, points, i, len, len, - 1, result.min, result.max, shape.smooth, - shape.smoothMonotone - ) + 1; - } - } - }), - - Polygon: Path.extend({ - - type: 'ec-polygon', - - shape: { - points: [], - - // Offset between stacked base points and points - stackedOnPoints: [], - - smooth: 0, - - stackedOnSmooth: 0, - - smoothConstraint: true, - - smoothMonotone: null - }, - - buildPath: function (ctx, shape) { - var points = shape.points; - var stackedOnPoints = shape.stackedOnPoints; - - var i = 0; - var len = points.length; - var smoothMonotone = shape.smoothMonotone; - var bbox = getBoundingBox(points, shape.smoothConstraint); - var stackedOnBBox = getBoundingBox(stackedOnPoints, shape.smoothConstraint); - while (i < len) { - var k = drawSegment( - ctx, points, i, len, len, - 1, bbox.min, bbox.max, shape.smooth, - smoothMonotone - ); - drawSegment( - ctx, stackedOnPoints, i + k - 1, len, k, - -1, stackedOnBBox.min, stackedOnBBox.max, shape.stackedOnSmooth, - smoothMonotone - ); - i += k + 1; - - ctx.closePath(); - } - } - }) - }; -}); -define('echarts/chart/line/LineView',['require','zrender/core/util','../helper/SymbolDraw','../helper/Symbol','./lineAnimationDiff','../../util/graphic','./poly','../../view/Chart'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var SymbolDraw = require('../helper/SymbolDraw'); - var Symbol = require('../helper/Symbol'); - var lineAnimationDiff = require('./lineAnimationDiff'); - var graphic = require('../../util/graphic'); - - var polyHelper = require('./poly'); - - var ChartView = require('../../view/Chart'); - - function isPointsSame(points1, points2) { - if (points1.length !== points2.length) { - return; - } - for (var i = 0; i < points1.length; i++) { - var p1 = points1[i]; - var p2 = points2[i]; - if (p1[0] !== p2[0] || p1[1] !== p2[1]) { - return; - } - } - return true; - } - - function getSmooth(smooth) { - return typeof (smooth) === 'number' ? smooth : (smooth ? 0.3 : 0); - } - - function getAxisExtentWithGap(axis) { - var extent = axis.getGlobalExtent(); - if (axis.onBand) { - // Remove extra 1px to avoid line miter in clipped edge - var halfBandWidth = axis.getBandWidth() / 2 - 1; - var dir = extent[1] > extent[0] ? 1 : -1; - extent[0] += dir * halfBandWidth; - extent[1] -= dir * halfBandWidth; - } - return extent; - } - - function sign(val) { - return val >= 0 ? 1 : -1; - } - /** - * @param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys - * @param {module:echarts/data/List} data - * @param {Array.>} points - * @private - */ - function getStackedOnPoints(coordSys, data) { - var baseAxis = coordSys.getBaseAxis(); - var valueAxis = coordSys.getOtherAxis(baseAxis); - var valueStart = baseAxis.onZero - ? 0 : valueAxis.scale.getExtent()[0]; - - var valueDim = valueAxis.dim; - - var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0; - - return data.mapArray([valueDim], function (val, idx) { - var stackedOnSameSign; - var stackedOn = data.stackedOn; - // Find first stacked value with same sign - while (stackedOn && - sign(stackedOn.get(valueDim, idx)) === sign(val) - ) { - stackedOnSameSign = stackedOn; - break; - } - var stackedData = []; - stackedData[baseDataOffset] = data.get(baseAxis.dim, idx); - stackedData[1 - baseDataOffset] = stackedOnSameSign - ? stackedOnSameSign.get(valueDim, idx, true) : valueStart; - - return coordSys.dataToPoint(stackedData); - }, true); - } - - function queryDataIndex(data, payload) { - if (payload.dataIndex != null) { - return payload.dataIndex; - } - else if (payload.name != null) { - return data.indexOfName(payload.name); - } - } - - function createGridClipShape(cartesian, hasAnimation, seriesModel) { - var xExtent = getAxisExtentWithGap(cartesian.getAxis('x')); - var yExtent = getAxisExtentWithGap(cartesian.getAxis('y')); - var isHorizontal = cartesian.getBaseAxis().isHorizontal(); - - var x = xExtent[0]; - var y = yExtent[0]; - var width = xExtent[1] - x; - var height = yExtent[1] - y; - // Expand clip shape to avoid line value exceeds axis - if (!seriesModel.get('clipOverflow')) { - if (isHorizontal) { - y -= height; - height *= 3; - } - else { - x -= width; - width *= 3; - } - } - var clipPath = new graphic.Rect({ - shape: { - x: x, - y: y, - width: width, - height: height - } - }); - - if (hasAnimation) { - clipPath.shape[isHorizontal ? 'width' : 'height'] = 0; - graphic.initProps(clipPath, { - shape: { - width: width, - height: height - } - }, seriesModel); - } - - return clipPath; - } - - function createPolarClipShape(polar, hasAnimation, seriesModel) { - var angleAxis = polar.getAngleAxis(); - var radiusAxis = polar.getRadiusAxis(); - - var radiusExtent = radiusAxis.getExtent(); - var angleExtent = angleAxis.getExtent(); - - var RADIAN = Math.PI / 180; - - var clipPath = new graphic.Sector({ - shape: { - cx: polar.cx, - cy: polar.cy, - r0: radiusExtent[0], - r: radiusExtent[1], - startAngle: -angleExtent[0] * RADIAN, - endAngle: -angleExtent[1] * RADIAN, - clockwise: angleAxis.inverse - } - }); - - if (hasAnimation) { - clipPath.shape.endAngle = -angleExtent[0] * RADIAN; - graphic.initProps(clipPath, { - shape: { - endAngle: -angleExtent[1] * RADIAN - } - }, seriesModel); - } - - return clipPath; - } - - function createClipShape(coordSys, hasAnimation, seriesModel) { - return coordSys.type === 'polar' - ? createPolarClipShape(coordSys, hasAnimation, seriesModel) - : createGridClipShape(coordSys, hasAnimation, seriesModel); - } - - return ChartView.extend({ - - type: 'line', - - init: function () { - var lineGroup = new graphic.Group(); - - var symbolDraw = new SymbolDraw(); - this.group.add(symbolDraw.group); - - this._symbolDraw = symbolDraw; - this._lineGroup = lineGroup; - }, - - render: function (seriesModel, ecModel, api) { - var coordSys = seriesModel.coordinateSystem; - var group = this.group; - var data = seriesModel.getData(); - var lineStyleModel = seriesModel.getModel('lineStyle.normal'); - var areaStyleModel = seriesModel.getModel('areaStyle.normal'); - - var points = data.mapArray(data.getItemLayout, true); - - var isCoordSysPolar = coordSys.type === 'polar'; - var prevCoordSys = this._coordSys; - - var symbolDraw = this._symbolDraw; - var polyline = this._polyline; - var polygon = this._polygon; - - var lineGroup = this._lineGroup; - - var hasAnimation = seriesModel.get('animation'); - - var isAreaChart = !areaStyleModel.isEmpty(); - var stackedOnPoints = getStackedOnPoints(coordSys, data); - - var showSymbol = seriesModel.get('showSymbol'); - - var isSymbolIgnore = showSymbol && !isCoordSysPolar && !seriesModel.get('showAllSymbol') - && this._getSymbolIgnoreFunc(data, coordSys); - - // Remove temporary symbols - var oldData = this._data; - oldData && oldData.eachItemGraphicEl(function (el, idx) { - if (el.__temp) { - group.remove(el); - oldData.setItemGraphicEl(idx, null); - } - }); - - // Remove previous created symbols if showSymbol changed to false - if (!showSymbol) { - symbolDraw.remove(); - } - - group.add(lineGroup); - - // Initialization animation or coordinate system changed - if ( - !(polyline && prevCoordSys.type === coordSys.type) - ) { - showSymbol && symbolDraw.updateData(data, isSymbolIgnore); - - polyline = this._newPolyline(points, coordSys, hasAnimation); - if (isAreaChart) { - polygon = this._newPolygon( - points, stackedOnPoints, - coordSys, hasAnimation - ); - } - lineGroup.setClipPath(createClipShape(coordSys, true, seriesModel)); - } - else { - if (isAreaChart && !polygon) { - // If areaStyle is added - polygon = this._newPolygon( - points, stackedOnPoints, - coordSys, hasAnimation - ); - } - else if (polygon && !isAreaChart) { - // If areaStyle is removed - lineGroup.remove(polygon); - polygon = this._polygon = null; - } - - // Update clipPath - lineGroup.setClipPath(createClipShape(coordSys, false, seriesModel)); - - // Always update, or it is wrong in the case turning on legend - // because points are not changed - showSymbol && symbolDraw.updateData(data, isSymbolIgnore); - - // Stop symbol animation and sync with line points - // FIXME performance? - data.eachItemGraphicEl(function (el) { - el.stopAnimation(true); - }); - - // In the case data zoom triggerred refreshing frequently - // Data may not change if line has a category axis. So it should animate nothing - if (!isPointsSame(this._stackedOnPoints, stackedOnPoints) - || !isPointsSame(this._points, points) - ) { - if (hasAnimation) { - this._updateAnimation( - data, stackedOnPoints, coordSys, api - ); - } - else { - polyline.setShape({ - points: points - }); - polygon && polygon.setShape({ - points: points, - stackedOnPoints: stackedOnPoints - }); - } - } - } - - polyline.setStyle(zrUtil.defaults( - // Use color in lineStyle first - lineStyleModel.getLineStyle(), - { - stroke: data.getVisual('color'), - lineJoin: 'bevel' - } - )); - - var smooth = seriesModel.get('smooth'); - smooth = getSmooth(seriesModel.get('smooth')); - polyline.setShape({ - smooth: smooth, - smoothMonotone: seriesModel.get('smoothMonotone') - }); - - if (polygon) { - var stackedOn = data.stackedOn; - var stackedOnSmooth = 0; - - polygon.style.opacity = 0.7; - polygon.setStyle(zrUtil.defaults( - areaStyleModel.getAreaStyle(), - { - fill: data.getVisual('color'), - lineJoin: 'bevel' - } - )); - - if (stackedOn) { - var stackedOnSeries = stackedOn.hostModel; - stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth')); - } - - polygon.setShape({ - smooth: smooth, - stackedOnSmooth: stackedOnSmooth, - smoothMonotone: seriesModel.get('smoothMonotone') - }); - } - - this._data = data; - // Save the coordinate system for transition animation when data changed - this._coordSys = coordSys; - this._stackedOnPoints = stackedOnPoints; - this._points = points; - }, - - highlight: function (seriesModel, ecModel, api, payload) { - var data = seriesModel.getData(); - var dataIndex = queryDataIndex(data, payload); - - if (dataIndex != null && dataIndex >= 0) { - var symbol = data.getItemGraphicEl(dataIndex); - if (!symbol) { - // Create a temporary symbol if it is not exists - var pt = data.getItemLayout(dataIndex); - symbol = new Symbol(data, dataIndex, api); - symbol.position = pt; - symbol.setZ( - seriesModel.get('zlevel'), - seriesModel.get('z') - ); - symbol.ignore = isNaN(pt[0]) || isNaN(pt[1]); - symbol.__temp = true; - data.setItemGraphicEl(dataIndex, symbol); - - // Stop scale animation - symbol.stopSymbolAnimation(true); - - this.group.add(symbol); - } - symbol.highlight(); - } - else { - // Highlight whole series - ChartView.prototype.highlight.call( - this, seriesModel, ecModel, api, payload - ); - } - }, - - downplay: function (seriesModel, ecModel, api, payload) { - var data = seriesModel.getData(); - var dataIndex = queryDataIndex(data, payload); - if (dataIndex != null && dataIndex >= 0) { - var symbol = data.getItemGraphicEl(dataIndex); - if (symbol) { - if (symbol.__temp) { - data.setItemGraphicEl(dataIndex, null); - this.group.remove(symbol); - } - else { - symbol.downplay(); - } - } - } - else { - // Downplay whole series - ChartView.prototype.downplay.call( - this, seriesModel, ecModel, api, payload - ); - } - }, - - /** - * @param {module:zrender/container/Group} group - * @param {Array.>} points - * @private - */ - _newPolyline: function (points) { - var polyline = this._polyline; - // Remove previous created polyline - if (polyline) { - this._lineGroup.remove(polyline); - } - - polyline = new polyHelper.Polyline({ - shape: { - points: points - }, - silent: true, - z2: 10 - }); - - this._lineGroup.add(polyline); - - this._polyline = polyline; - - return polyline; - }, - - /** - * @param {module:zrender/container/Group} group - * @param {Array.>} stackedOnPoints - * @param {Array.>} points - * @private - */ - _newPolygon: function (points, stackedOnPoints) { - var polygon = this._polygon; - // Remove previous created polygon - if (polygon) { - this._lineGroup.remove(polygon); - } - - polygon = new polyHelper.Polygon({ - shape: { - points: points, - stackedOnPoints: stackedOnPoints - }, - silent: true - }); - - this._lineGroup.add(polygon); - - this._polygon = polygon; - return polygon; - }, - /** - * @private - */ - _getSymbolIgnoreFunc: function (data, coordSys) { - var categoryAxis = coordSys.getAxesByScale('ordinal')[0]; - // `getLabelInterval` is provided by echarts/component/axis - if (categoryAxis && categoryAxis.isLabelIgnored) { - return zrUtil.bind(categoryAxis.isLabelIgnored, categoryAxis); - } - }, - - /** - * @private - */ - // FIXME Two value axis - _updateAnimation: function (data, stackedOnPoints, coordSys, api) { - var polyline = this._polyline; - var polygon = this._polygon; - var seriesModel = data.hostModel; - - var diff = lineAnimationDiff( - this._data, data, - this._stackedOnPoints, stackedOnPoints, - this._coordSys, coordSys - ); - polyline.shape.points = diff.current; - - graphic.updateProps(polyline, { - shape: { - points: diff.next - } - }, seriesModel); - - if (polygon) { - polygon.setShape({ - points: diff.current, - stackedOnPoints: diff.stackedOnCurrent - }); - graphic.updateProps(polygon, { - shape: { - points: diff.next, - stackedOnPoints: diff.stackedOnNext - } - }, seriesModel); - } - - var updatedDataInfo = []; - var diffStatus = diff.status; - - for (var i = 0; i < diffStatus.length; i++) { - var cmd = diffStatus[i].cmd; - if (cmd === '=') { - var el = data.getItemGraphicEl(diffStatus[i].idx1); - if (el) { - updatedDataInfo.push({ - el: el, - ptIdx: i // Index of points - }); - } - } - } - - if (polyline.animators && polyline.animators.length) { - polyline.animators[0].during(function () { - for (var i = 0; i < updatedDataInfo.length; i++) { - var el = updatedDataInfo[i].el; - el.attr('position', polyline.shape.points[updatedDataInfo[i].ptIdx]); - } - }); - } - }, - - remove: function (ecModel) { - this._lineGroup.removeAll(); - this._symbolDraw.remove(true); - - this._polyline = - this._polygon = - this._coordSys = - this._points = - this._stackedOnPoints = - this._data = null; - } - }); -}); -define('echarts/visual/symbol',['require'],function (require) { - - return function (seriesType, defaultSymbolType, legendSymbol, ecModel, api) { - - // Encoding visual for all series include which is filtered for legend drawing - ecModel.eachRawSeriesByType(seriesType, function (seriesModel) { - var data = seriesModel.getData(); - - var symbolType = seriesModel.get('symbol') || defaultSymbolType; - var symbolSize = seriesModel.get('symbolSize'); - - data.setVisual({ - legendSymbol: legendSymbol || symbolType, - symbol: symbolType, - symbolSize: symbolSize - }); - - // Only visible series has each data be visual encoded - if (!ecModel.isSeriesFiltered(seriesModel)) { - if (typeof symbolSize === 'function') { - data.each(function (idx) { - var rawValue = seriesModel.getRawValue(idx); - // FIXME - var params = seriesModel.getDataParams(idx); - data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params)); - }); - } - data.each(function (idx) { - var itemModel = data.getItemModel(idx); - var itemSymbolType = itemModel.get('symbol', true); - var itemSymbolSize = itemModel.get('symbolSize', true); - // If has item symbol - if (itemSymbolType != null) { - data.setItemVisual(idx, 'symbol', itemSymbolType); - } - if (itemSymbolSize != null) { - // PENDING Transform symbolSize ? - data.setItemVisual(idx, 'symbolSize', itemSymbolSize); - } - }); - } - }); - }; -}); -define('echarts/layout/points',['require'],function (require) { - - return function (seriesType, ecModel, api) { - ecModel.eachSeriesByType(seriesType, function (seriesModel) { - var data = seriesModel.getData(); - var coordSys = seriesModel.coordinateSystem; - - var dims = coordSys.dimensions; - data.each(dims, function (x, y, idx) { - var point; - if (!isNaN(x) && !isNaN(y)) { - point = coordSys.dataToPoint([x, y]); - } - else { - // Also {Array.}, not undefined to avoid if...else... statement - point = [NaN, NaN]; - } - - data.setItemLayout(idx, point); - }, true); - }); - }; -}); -define('echarts/processor/dataSample',[],function () { - var samplers = { - average: function (frame) { - var sum = 0; - var count = 0; - for (var i = 0; i < frame.length; i++) { - if (!isNaN(frame[i])) { - sum += frame[i]; - count++; - } - } - // Return NaN if count is 0 - return count === 0 ? NaN : sum / count; - }, - sum: function (frame) { - var sum = 0; - for (var i = 0; i < frame.length; i++) { - // Ignore NaN - sum += frame[i] || 0; - } - return sum; - }, - max: function (frame) { - var max = -Infinity; - for (var i = 0; i < frame.length; i++) { - frame[i] > max && (max = frame[i]); - } - return max; - }, - min: function (frame) { - var min = Infinity; - for (var i = 0; i < frame.length; i++) { - frame[i] < min && (min = frame[i]); - } - return min; - } - }; - - var indexSampler = function (frame, value) { - return Math.round(frame.length / 2); - }; - return function (seriesType, ecModel, api) { - ecModel.eachSeriesByType(seriesType, function (seriesModel) { - var data = seriesModel.getData(); - var sampling = seriesModel.get('sampling'); - var coordSys = seriesModel.coordinateSystem; - // Only cartesian2d support down sampling - if (coordSys.type === 'cartesian2d' && sampling) { - var baseAxis = coordSys.getBaseAxis(); - var valueAxis = coordSys.getOtherAxis(baseAxis); - var extent = baseAxis.getExtent(); - // Coordinste system has been resized - var size = extent[1] - extent[0]; - var rate = Math.round(data.count() / size); - if (rate > 1) { - var sampler; - if (typeof sampling === 'string') { - sampler = samplers[sampling]; - } - else if (typeof sampling === 'function') { - sampler = sampling; - } - if (sampler) { - data = data.downSample( - valueAxis.dim, 1 / rate, sampler, indexSampler - ); - seriesModel.setData(data); - } - } - } - }, this); - }; -}); -define('echarts/chart/line',['require','zrender/core/util','../echarts','./line/LineSeries','./line/LineView','../visual/symbol','../layout/points','../processor/dataSample'],function (require) { - - var zrUtil = require('zrender/core/util'); - var echarts = require('../echarts'); - - require('./line/LineSeries'); - require('./line/LineView'); - - echarts.registerVisualCoding('chart', zrUtil.curry( - require('../visual/symbol'), 'line', 'circle', 'line' - )); - echarts.registerLayout(zrUtil.curry( - require('../layout/points'), 'line' - )); - - // Down sample after filter - echarts.registerProcessor('statistic', zrUtil.curry( - require('../processor/dataSample'), 'line' - )); -}); -/** - * // Scale class management - * @module echarts/scale/Scale - */ -define('echarts/scale/Scale',['require','../util/clazz'],function (require) { - - var clazzUtil = require('../util/clazz'); - - function Scale() { - /** - * Extent - * @type {Array.} - * @protected - */ - this._extent = [Infinity, -Infinity]; - - /** - * Step is calculated in adjustExtent - * @type {Array.} - * @protected - */ - this._interval = 0; - - this.init && this.init.apply(this, arguments); - } - - var scaleProto = Scale.prototype; - - /** - * Parse input val to valid inner number. - * @param {*} val - * @return {number} - */ - scaleProto.parse = function (val) { - // Notice: This would be a trap here, If the implementation - // of this method depends on extent, and this method is used - // before extent set (like in dataZoom), it would be wrong. - // Nevertheless, parse does not depend on extent generally. - return val; - }; - - scaleProto.contain = function (val) { - var extent = this._extent; - return val >= extent[0] && val <= extent[1]; - }; - - /** - * Normalize value to linear [0, 1], return 0.5 if extent span is 0 - * @param {number} val - * @return {number} - */ - scaleProto.normalize = function (val) { - var extent = this._extent; - if (extent[1] === extent[0]) { - return 0.5; - } - return (val - extent[0]) / (extent[1] - extent[0]); - }; - - /** - * Scale normalized value - * @param {number} val - * @return {number} - */ - scaleProto.scale = function (val) { - var extent = this._extent; - return val * (extent[1] - extent[0]) + extent[0]; - }; - - /** - * Set extent from data - * @param {Array.} other - */ - scaleProto.unionExtent = function (other) { - var extent = this._extent; - other[0] < extent[0] && (extent[0] = other[0]); - other[1] > extent[1] && (extent[1] = other[1]); - // not setExtent because in log axis it may transformed to power - // this.setExtent(extent[0], extent[1]); - }; - - /** - * Get extent - * @return {Array.} - */ - scaleProto.getExtent = function () { - return this._extent.slice(); - }; - - /** - * Set extent - * @param {number} start - * @param {number} end - */ - scaleProto.setExtent = function (start, end) { - var thisExtent = this._extent; - if (!isNaN(start)) { - thisExtent[0] = start; - } - if (!isNaN(end)) { - thisExtent[1] = end; - } - }; - - /** - * @return {Array.} - */ - scaleProto.getTicksLabels = function () { - var labels = []; - var ticks = this.getTicks(); - for (var i = 0; i < ticks.length; i++) { - labels.push(this.getLabel(ticks[i])); - } - return labels; - }; - - clazzUtil.enableClassExtend(Scale); - clazzUtil.enableClassManagement(Scale, { - registerWhenExtend: true - }); - - return Scale; -}); -/** - * Linear continuous scale - * @module echarts/coord/scale/Ordinal - * - * http://en.wikipedia.org/wiki/Level_of_measurement - */ - -// FIXME only one data -define('echarts/scale/Ordinal',['require','zrender/core/util','./Scale'],function (require) { - - var zrUtil = require('zrender/core/util'); - var Scale = require('./Scale'); - - var scaleProto = Scale.prototype; - - var OrdinalScale = Scale.extend({ - - type: 'ordinal', - - init: function (data, extent) { - this._data = data; - this._extent = extent || [0, data.length - 1]; - }, - - parse: function (val) { - return typeof val === 'string' - ? zrUtil.indexOf(this._data, val) - // val might be float. - : Math.round(val); - }, - - contain: function (rank) { - rank = this.parse(rank); - return scaleProto.contain.call(this, rank) - && this._data[rank] != null; - }, - - /** - * Normalize given rank or name to linear [0, 1] - * @param {number|string} [val] - * @return {number} - */ - normalize: function (val) { - return scaleProto.normalize.call(this, this.parse(val)); - }, - - scale: function (val) { - return Math.round(scaleProto.scale.call(this, val)); - }, - - /** - * @return {Array} - */ - getTicks: function () { - var ticks = []; - var extent = this._extent; - var rank = extent[0]; - - while (rank <= extent[1]) { - ticks.push(rank); - rank++; - } - - return ticks; - }, - - /** - * Get item on rank n - * @param {number} n - * @return {string} - */ - getLabel: function (n) { - return this._data[n]; - }, - - /** - * @return {number} - */ - count: function () { - return this._extent[1] - this._extent[0] + 1; - }, - - niceTicks: zrUtil.noop, - niceExtent: zrUtil.noop - }); - - /** - * @return {module:echarts/scale/Time} - */ - OrdinalScale.create = function () { - return new OrdinalScale(); - }; - - return OrdinalScale; -}); -/** - * Interval scale - * @module echarts/scale/Interval - */ - -define('echarts/scale/Interval',['require','../util/number','../util/format','./Scale'],function (require) { - - var numberUtil = require('../util/number'); - var formatUtil = require('../util/format'); - var Scale = require('./Scale'); - - var mathFloor = Math.floor; - var mathCeil = Math.ceil; - /** - * @alias module:echarts/coord/scale/Interval - * @constructor - */ - var IntervalScale = Scale.extend({ - - type: 'interval', - - _interval: 0, - - setExtent: function (start, end) { - var thisExtent = this._extent; - //start,end may be a Number like '25',so... - if (!isNaN(start)) { - thisExtent[0] = parseFloat(start); - } - if (!isNaN(end)) { - thisExtent[1] = parseFloat(end); - } - }, - - unionExtent: function (other) { - var extent = this._extent; - other[0] < extent[0] && (extent[0] = other[0]); - other[1] > extent[1] && (extent[1] = other[1]); - - // unionExtent may called by it's sub classes - IntervalScale.prototype.setExtent.call(this, extent[0], extent[1]); - }, - /** - * Get interval - */ - getInterval: function () { - if (!this._interval) { - this.niceTicks(); - } - return this._interval; - }, - - /** - * Set interval - */ - setInterval: function (interval) { - this._interval = interval; - // Dropped auto calculated niceExtent and use user setted extent - // We assume user wan't to set both interval, min, max to get a better result - this._niceExtent = this._extent.slice(); - }, - - /** - * @return {Array.} - */ - getTicks: function () { - if (!this._interval) { - this.niceTicks(); - } - var interval = this._interval; - var extent = this._extent; - var ticks = []; - - // Consider this case: using dataZoom toolbox, zoom and zoom. - var safeLimit = 10000; - - if (interval) { - var niceExtent = this._niceExtent; - if (extent[0] < niceExtent[0]) { - ticks.push(extent[0]); - } - var tick = niceExtent[0]; - while (tick <= niceExtent[1]) { - ticks.push(tick); - // Avoid rounding error - tick = numberUtil.round(tick + interval); - if (ticks.length > safeLimit) { - return []; - } - } - if (extent[1] > niceExtent[1]) { - ticks.push(extent[1]); - } - } - - return ticks; - }, - - /** - * @return {Array.} - */ - getTicksLabels: function () { - var labels = []; - var ticks = this.getTicks(); - for (var i = 0; i < ticks.length; i++) { - labels.push(this.getLabel(ticks[i])); - } - return labels; - }, - - /** - * @param {number} n - * @return {number} - */ - getLabel: function (data) { - return formatUtil.addCommas(data); - }, - - /** - * Update interval and extent of intervals for nice ticks - * Algorithm from d3.js - * @param {number} [approxTickNum = 10] Given approx tick number - */ - niceTicks: function (approxTickNum) { - approxTickNum = approxTickNum || 10; - var extent = this._extent; - var span = extent[1] - extent[0]; - if (span === Infinity || span <= 0) { - return; - } - - // Figure out step quantity, for example 0.1, 1, 10, 100 - var interval = Math.pow(10, Math.floor(Math.log(span / approxTickNum) / Math.LN10)); - var err = approxTickNum / span * interval; - - // Filter ticks to get closer to the desired count. - if (err <= 0.15) { - interval *= 10; - } - else if (err <= 0.3) { - interval *= 5; - } - else if (err <= 0.45) { - interval *= 3; - } - else if (err <= 0.75) { - interval *= 2; - } - - var niceExtent = [ - numberUtil.round(mathCeil(extent[0] / interval) * interval), - numberUtil.round(mathFloor(extent[1] / interval) * interval) - ]; - - this._interval = interval; - this._niceExtent = niceExtent; - }, - - /** - * Nice extent. - * @param {number} [approxTickNum = 10] Given approx tick number - * @param {boolean} [fixMin=false] - * @param {boolean} [fixMax=false] - */ - niceExtent: function (approxTickNum, fixMin, fixMax) { - var extent = this._extent; - // If extent start and end are same, expand them - if (extent[0] === extent[1]) { - if (extent[0] !== 0) { - // Expand extent - var expandSize = extent[0] / 2; - extent[0] -= expandSize; - extent[1] += expandSize; - } - else { - extent[1] = 1; - } - } - // If there are no data and extent are [Infinity, -Infinity] - if (extent[1] === -Infinity && extent[0] === Infinity) { - extent[0] = 0; - extent[1] = 1; - } - - this.niceTicks(approxTickNum, fixMin, fixMax); - - // var extent = this._extent; - var interval = this._interval; - - if (!fixMin) { - extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval); - } - if (!fixMax) { - extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval); - } - } - }); - - /** - * @return {module:echarts/scale/Time} - */ - IntervalScale.create = function () { - return new IntervalScale(); - }; - - return IntervalScale; -}); - -/** - * Interval scale - * @module echarts/coord/scale/Time - */ - -define('echarts/scale/Time',['require','zrender/core/util','../util/number','../util/format','./Interval'],function (require) { - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../util/number'); - var formatUtil = require('../util/format'); - - var IntervalScale = require('./Interval'); - - var intervalScaleProto = IntervalScale.prototype; - - var mathCeil = Math.ceil; - var mathFloor = Math.floor; - var ONE_DAY = 3600000 * 24; - - // FIXME 公用? - var bisect = function (a, x, lo, hi) { - while (lo < hi) { - var mid = lo + hi >>> 1; - if (a[mid][2] < x) { - lo = mid + 1; - } - else { - hi = mid; - } - } - return lo; - }; - - /** - * @alias module:echarts/coord/scale/Time - * @constructor - */ - var TimeScale = IntervalScale.extend({ - type: 'time', - - // Overwrite - getLabel: function (val) { - var stepLvl = this._stepLvl; - - var date = new Date(val); - - return formatUtil.formatTime(stepLvl[0], date); - }, - - // Overwrite - niceExtent: function (approxTickNum, fixMin, fixMax) { - var extent = this._extent; - // If extent start and end are same, expand them - if (extent[0] === extent[1]) { - // Expand extent - extent[0] -= ONE_DAY; - extent[1] += ONE_DAY; - } - // If there are no data and extent are [Infinity, -Infinity] - if (extent[1] === -Infinity && extent[0] === Infinity) { - var d = new Date(); - extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate()); - extent[0] = extent[1] - ONE_DAY; - } - - this.niceTicks(approxTickNum, fixMin, fixMax); - - // var extent = this._extent; - var interval = this._interval; - - if (!fixMin) { - extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval); - } - if (!fixMax) { - extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval); - } - }, - - // Overwrite - niceTicks: function (approxTickNum) { - approxTickNum = approxTickNum || 10; - - var extent = this._extent; - var span = extent[1] - extent[0]; - var approxInterval = span / approxTickNum; - var scaleLevelsLen = scaleLevels.length; - var idx = bisect(scaleLevels, approxInterval, 0, scaleLevelsLen); - - var level = scaleLevels[Math.min(idx, scaleLevelsLen - 1)]; - var interval = level[2]; - // Same with interval scale if span is much larger than 1 year - if (level[0] === 'year') { - var year = span / interval; - var yearInterval = Math.pow(10, Math.floor(Math.log(year / approxTickNum) / Math.LN10)); - var err = approxTickNum / year * yearInterval; - // Filter ticks to get closer to the desired count. - if (err <= 0.15) { - yearInterval *= 10; - } - else if (err <= 0.3) { - yearInterval *= 5; - } - else if (err <= 0.75) { - yearInterval *= 2; - } - interval *= yearInterval; - } - - var niceExtent = [ - mathCeil(extent[0] / interval) * interval, - mathFloor(extent[1] / interval) * interval - ]; - - this._stepLvl = level; - // Interval will be used in getTicks - this._interval = interval; - this._niceExtent = niceExtent; - }, - - parse: function (val) { - // val might be float. - return +numberUtil.parseDate(val); - } - }); - - zrUtil.each(['contain', 'normalize'], function (methodName) { - TimeScale.prototype[methodName] = function (val) { - return intervalScaleProto[methodName].call(this, this.parse(val)); - }; - }); - - // Steps from d3 - var scaleLevels = [ - // Format step interval - ['hh:mm:ss', 1, 1000], // 1s - ['hh:mm:ss', 5, 1000 * 5], // 5s - ['hh:mm:ss', 10, 1000 * 10], // 10s - ['hh:mm:ss', 15, 1000 * 15], // 15s - ['hh:mm:ss', 30, 1000 * 30], // 30s - ['hh:mm\nMM-dd',1, 60000], // 1m - ['hh:mm\nMM-dd',5, 60000 * 5], // 5m - ['hh:mm\nMM-dd',10, 60000 * 10], // 10m - ['hh:mm\nMM-dd',15, 60000 * 15], // 15m - ['hh:mm\nMM-dd',30, 60000 * 30], // 30m - ['hh:mm\nMM-dd',1, 3600000], // 1h - ['hh:mm\nMM-dd',2, 3600000 * 2], // 2h - ['hh:mm\nMM-dd',6, 3600000 * 6], // 6h - ['hh:mm\nMM-dd',12, 3600000 * 12], // 12h - ['MM-dd\nyyyy', 1, ONE_DAY], // 1d - ['week', 7, ONE_DAY * 7], // 7d - ['month', 1, ONE_DAY * 31], // 1M - ['quarter', 3, ONE_DAY * 380 / 4], // 3M - ['half-year', 6, ONE_DAY * 380 / 2], // 6M - ['year', 1, ONE_DAY * 380] // 1Y - ]; - - /** - * @return {module:echarts/scale/Time} - */ - TimeScale.create = function () { - return new TimeScale(); - }; - - return TimeScale; -}); -/** - * Log scale - * @module echarts/scale/Log - */ -define('echarts/scale/Log',['require','zrender/core/util','./Scale','../util/number','./Interval'],function (require) { - - var zrUtil = require('zrender/core/util'); - var Scale = require('./Scale'); - var numberUtil = require('../util/number'); - - // Use some method of IntervalScale - var IntervalScale = require('./Interval'); - - var scaleProto = Scale.prototype; - var intervalScaleProto = IntervalScale.prototype; - - var mathFloor = Math.floor; - var mathCeil = Math.ceil; - var mathPow = Math.pow; - - var LOG_BASE = 10; - var mathLog = Math.log; - - var LogScale = Scale.extend({ - - type: 'log', - - /** - * @return {Array.} - */ - getTicks: function () { - return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) { - return numberUtil.round(mathPow(LOG_BASE, val)); - }); - }, - - /** - * @param {number} val - * @return {string} - */ - getLabel: intervalScaleProto.getLabel, - - /** - * @param {number} val - * @return {number} - */ - scale: function (val) { - val = scaleProto.scale.call(this, val); - return mathPow(LOG_BASE, val); - }, - - /** - * @param {number} start - * @param {number} end - */ - setExtent: function (start, end) { - start = mathLog(start) / mathLog(LOG_BASE); - end = mathLog(end) / mathLog(LOG_BASE); - intervalScaleProto.setExtent.call(this, start, end); - }, - - /** - * @return {number} end - */ - getExtent: function () { - var extent = scaleProto.getExtent.call(this); - extent[0] = mathPow(LOG_BASE, extent[0]); - extent[1] = mathPow(LOG_BASE, extent[1]); - return extent; - }, - - /** - * @param {Array.} extent - */ - unionExtent: function (extent) { - extent[0] = mathLog(extent[0]) / mathLog(LOG_BASE); - extent[1] = mathLog(extent[1]) / mathLog(LOG_BASE); - scaleProto.unionExtent.call(this, extent); - }, - - /** - * Update interval and extent of intervals for nice ticks - * @param {number} [approxTickNum = 10] Given approx tick number - */ - niceTicks: function (approxTickNum) { - approxTickNum = approxTickNum || 10; - var extent = this._extent; - var span = extent[1] - extent[0]; - if (span === Infinity || span <= 0) { - return; - } - - var interval = mathPow(10, mathFloor(mathLog(span / approxTickNum) / Math.LN10)); - var err = approxTickNum / span * interval; - - // Filter ticks to get closer to the desired count. - if (err <= 0.5) { - interval *= 10; - } - var niceExtent = [ - numberUtil.round(mathCeil(extent[0] / interval) * interval), - numberUtil.round(mathFloor(extent[1] / interval) * interval) - ]; - - this._interval = interval; - this._niceExtent = niceExtent; - }, - - /** - * Nice extent. - * @param {number} [approxTickNum = 10] Given approx tick number - * @param {boolean} [fixMin=false] - * @param {boolean} [fixMax=false] - */ - niceExtent: intervalScaleProto.niceExtent - }); - - zrUtil.each(['contain', 'normalize'], function (methodName) { - LogScale.prototype[methodName] = function (val) { - val = mathLog(val) / mathLog(LOG_BASE); - return scaleProto[methodName].call(this, val); - }; - }); - - LogScale.create = function () { - return new LogScale(); - }; - - return LogScale; -}); -define('echarts/coord/axisHelper',['require','../scale/Ordinal','../scale/Interval','../scale/Time','../scale/Log','../scale/Scale','../util/number','zrender/core/util','zrender/contain/text'],function (require) { - - var OrdinalScale = require('../scale/Ordinal'); - var IntervalScale = require('../scale/Interval'); - require('../scale/Time'); - require('../scale/Log'); - var Scale = require('../scale/Scale'); - - var numberUtil = require('../util/number'); - var zrUtil = require('zrender/core/util'); - var textContain = require('zrender/contain/text'); - var axisHelper = {}; - - axisHelper.niceScaleExtent = function (axis, model) { - var scale = axis.scale; - var originalExtent = scale.getExtent(); - var span = originalExtent[1] - originalExtent[0]; - if (scale.type === 'ordinal') { - // If series has no data, scale extent may be wrong - if (!isFinite(span)) { - scale.setExtent(0, 0); - } - return; - } - var min = model.get('min'); - var max = model.get('max'); - var crossZero = !model.get('scale'); - var boundaryGap = model.get('boundaryGap'); - if (!zrUtil.isArray(boundaryGap)) { - boundaryGap = [boundaryGap || 0, boundaryGap || 0]; - } - boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], 1); - boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], 1); - var fixMin = true; - var fixMax = true; - // Add boundary gap - if (min == null) { - min = originalExtent[0] - boundaryGap[0] * span; - fixMin = false; - } - if (max == null) { - max = originalExtent[1] + boundaryGap[1] * span; - fixMax = false; - } - // TODO Only one data - if (min === 'dataMin') { - min = originalExtent[0]; - } - if (max === 'dataMax') { - max = originalExtent[1]; - } - // Evaluate if axis needs cross zero - if (crossZero) { - // Axis is over zero and min is not set - if (min > 0 && max > 0 && !fixMin) { - min = 0; - } - // Axis is under zero and max is not set - if (min < 0 && max < 0 && !fixMax) { - max = 0; - } - } - scale.setExtent(min, max); - scale.niceExtent(model.get('splitNumber'), fixMin, fixMax); - - // If some one specified the min, max. And the default calculated interval - // is not good enough. He can specify the interval. It is often appeared - // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard - // to be 60. - // FIXME - var interval = model.get('interval'); - if (interval != null) { - scale.setInterval && scale.setInterval(interval); - } - }; - - /** - * @param {module:echarts/model/Model} model - * @param {string} [axisType] Default retrieve from model.type - * @return {module:echarts/scale/*} - */ - axisHelper.createScaleByModel = function(model, axisType) { - axisType = axisType || model.get('type'); - if (axisType) { - switch (axisType) { - // Buildin scale - case 'category': - return new OrdinalScale( - model.getCategories(), [Infinity, -Infinity] - ); - case 'value': - return new IntervalScale(); - // Extended scale, like time and log - default: - return (Scale.getClass(axisType) || IntervalScale).create(model); - } - } - }; - - /** - * Check if the axis corss 0 - */ - axisHelper.ifAxisCrossZero = function (axis) { - var dataExtent = axis.scale.getExtent(); - var min = dataExtent[0]; - var max = dataExtent[1]; - return !((min > 0 && max > 0) || (min < 0 && max < 0)); - }; - - /** - * @param {Array.} tickCoords In axis self coordinate. - * @param {Array.} labels - * @param {string} font - * @param {boolean} isAxisHorizontal - * @return {number} - */ - axisHelper.getAxisLabelInterval = function (tickCoords, labels, font, isAxisHorizontal) { - // FIXME - // 不同角的axis和label,不只是horizontal和vertical. - - var textSpaceTakenRect; - var autoLabelInterval = 0; - var accumulatedLabelInterval = 0; - - var step = 1; - if (labels.length > 40) { - // Simple optimization for large amount of labels - step = Math.round(labels.length / 40); - } - for (var i = 0; i < tickCoords.length; i += step) { - var tickCoord = tickCoords[i]; - var rect = textContain.getBoundingRect( - labels[i], font, 'center', 'top' - ); - rect[isAxisHorizontal ? 'x' : 'y'] += tickCoord; - rect[isAxisHorizontal ? 'width' : 'height'] *= 1.5; - if (!textSpaceTakenRect) { - textSpaceTakenRect = rect.clone(); - } - // There is no space for current label; - else if (textSpaceTakenRect.intersect(rect)) { - accumulatedLabelInterval++; - autoLabelInterval = Math.max(autoLabelInterval, accumulatedLabelInterval); - } - else { - textSpaceTakenRect.union(rect); - // Reset - accumulatedLabelInterval = 0; - } - } - if (autoLabelInterval === 0 && step > 1) { - return step; - } - return autoLabelInterval * step; - }; - - /** - * @param {Object} axis - * @param {Function} labelFormatter - * @return {Array.} - */ - axisHelper.getFormattedLabels = function (axis, labelFormatter) { - var scale = axis.scale; - var labels = scale.getTicksLabels(); - var ticks = scale.getTicks(); - if (typeof labelFormatter === 'string') { - labelFormatter = (function (tpl) { - return function (val) { - return tpl.replace('{value}', val); - }; - })(labelFormatter); - return zrUtil.map(labels, labelFormatter); - } - else if (typeof labelFormatter === 'function') { - return zrUtil.map(ticks, function (tick, idx) { - return labelFormatter( - axis.type === 'category' ? scale.getLabel(tick) : tick, - idx - ); - }, this); - } - else { - return labels; - } - }; - - return axisHelper; -}); -/** - * Cartesian coordinate system - * @module echarts/coord/Cartesian - * - */ -define('echarts/coord/cartesian/Cartesian',['require','zrender/core/util'],function (require) { - - - - var zrUtil = require('zrender/core/util'); - - function dimAxisMapper(dim) { - return this._axes[dim]; - } - - /** - * @alias module:echarts/coord/Cartesian - * @constructor - */ - var Cartesian = function (name) { - this._axes = {}; - - this._dimList = []; - - /** - * @type {string} - */ - this.name = name || ''; - }; - - Cartesian.prototype = { - - constructor: Cartesian, - - type: 'cartesian', - - /** - * Get axis - * @param {number|string} dim - * @return {module:echarts/coord/Cartesian~Axis} - */ - getAxis: function (dim) { - return this._axes[dim]; - }, - - /** - * Get axes list - * @return {Array.} - */ - getAxes: function () { - return zrUtil.map(this._dimList, dimAxisMapper, this); - }, - - /** - * Get axes list by given scale type - */ - getAxesByScale: function (scaleType) { - scaleType = scaleType.toLowerCase(); - return zrUtil.filter( - this.getAxes(), - function (axis) { - return axis.scale.type === scaleType; - } - ); - }, - - /** - * Add axis - * @param {module:echarts/coord/Cartesian.Axis} - */ - addAxis: function (axis) { - var dim = axis.dim; - - this._axes[dim] = axis; - - this._dimList.push(dim); - }, - - /** - * Convert data to coord in nd space - * @param {Array.|Object.} val - * @return {Array.|Object.} - */ - dataToCoord: function (val) { - return this._dataCoordConvert(val, 'dataToCoord'); - }, - - /** - * Convert coord in nd space to data - * @param {Array.|Object.} val - * @return {Array.|Object.} - */ - coordToData: function (val) { - return this._dataCoordConvert(val, 'coordToData'); - }, - - _dataCoordConvert: function (input, method) { - var dimList = this._dimList; - - var output = input instanceof Array ? [] : {}; - - for (var i = 0; i < dimList.length; i++) { - var dim = dimList[i]; - var axis = this._axes[dim]; - - output[dim] = axis[method](input[dim]); - } - - return output; - } - }; - - return Cartesian; -}); -define('echarts/coord/cartesian/Cartesian2D',['require','zrender/core/util','./Cartesian'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var Cartesian = require('./Cartesian'); - - function Cartesian2D(name) { - - Cartesian.call(this, name); - } - - Cartesian2D.prototype = { - - constructor: Cartesian2D, - - type: 'cartesian2d', - - /** - * @type {Array.} - * @readOnly - */ - dimensions: ['x', 'y'], - - /** - * Base axis will be used on stacking. - * - * @return {module:echarts/coord/cartesian/Axis2D} - */ - getBaseAxis: function () { - return this.getAxesByScale('ordinal')[0] - || this.getAxesByScale('time')[0] - || this.getAxis('x'); - }, - - /** - * If contain point - * @param {Array.} point - * @return {boolean} - */ - containPoint: function (point) { - var axisX = this.getAxis('x'); - var axisY = this.getAxis('y'); - return axisX.contain(axisX.toLocalCoord(point[0])) - && axisY.contain(axisY.toLocalCoord(point[1])); - }, - - /** - * If contain data - * @param {Array.} data - * @return {boolean} - */ - containData: function (data) { - return this.getAxis('x').containData(data[0]) - && this.getAxis('y').containData(data[1]); - }, - - /** - * Convert series data to an array of points - * @param {module:echarts/data/List} data - * @param {boolean} stack - * @return {Array} - * Return array of points. For example: - * `[[10, 10], [20, 20], [30, 30]]` - */ - dataToPoints: function (data, stack) { - return data.mapArray(['x', 'y'], function (x, y) { - return this.dataToPoint([x, y]); - }, stack, this); - }, - - /** - * @param {Array.} data - * @param {boolean} [clamp=false] - * @return {Array.} - */ - dataToPoint: function (data, clamp) { - var xAxis = this.getAxis('x'); - var yAxis = this.getAxis('y'); - return [ - xAxis.toGlobalCoord(xAxis.dataToCoord(data[0], clamp)), - yAxis.toGlobalCoord(yAxis.dataToCoord(data[1], clamp)) - ]; - }, - - /** - * @param {Array.} point - * @param {boolean} [clamp=false] - * @return {Array.} - */ - pointToData: function (point, clamp) { - var xAxis = this.getAxis('x'); - var yAxis = this.getAxis('y'); - return [ - xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp), - yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp) - ]; - }, - - /** - * Get other axis - * @param {module:echarts/coord/cartesian/Axis2D} axis - */ - getOtherAxis: function (axis) { - return this.getAxis(axis.dim === 'x' ? 'y' : 'x'); - } - }; - - zrUtil.inherits(Cartesian2D, Cartesian); - - return Cartesian2D; -}); -define('echarts/coord/Axis',['require','../util/number','zrender/core/util'],function (require) { - - var numberUtil = require('../util/number'); - var linearMap = numberUtil.linearMap; - var zrUtil = require('zrender/core/util'); - - function fixExtentWithBands(extent, nTick) { - var size = extent[1] - extent[0]; - var len = nTick; - var margin = size / len / 2; - extent[0] += margin; - extent[1] -= margin; - } - - var normalizedExtent = [0, 1]; - /** - * @name module:echarts/coord/CartesianAxis - * @constructor - */ - var Axis = function (dim, scale, extent) { - - /** - * Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius' - * @type {string} - */ - this.dim = dim; - - /** - * Axis scale - * @type {module:echarts/coord/scale/*} - */ - this.scale = scale; - - /** - * @type {Array.} - * @private - */ - this._extent = extent || [0, 0]; - - /** - * @type {boolean} - */ - this.inverse = false; - - /** - * Usually true when axis has a ordinal scale - * @type {boolean} - */ - this.onBand = false; - }; - - Axis.prototype = { - - constructor: Axis, - - /** - * If axis extent contain given coord - * @param {number} coord - * @return {boolean} - */ - contain: function (coord) { - var extent = this._extent; - var min = Math.min(extent[0], extent[1]); - var max = Math.max(extent[0], extent[1]); - return coord >= min && coord <= max; - }, - - /** - * If axis extent contain given data - * @param {number} data - * @return {boolean} - */ - containData: function (data) { - return this.contain(this.dataToCoord(data)); - }, - - /** - * Get coord extent. - * @return {Array.} - */ - getExtent: function () { - var ret = this._extent.slice(); - return ret; - }, - - /** - * Get precision used for formatting - * @param {Array.} [dataExtent] - * @return {number} - */ - getPixelPrecision: function (dataExtent) { - return numberUtil.getPixelPrecision( - dataExtent || this.scale.getExtent(), - this._extent - ); - }, - - /** - * Set coord extent - * @param {number} start - * @param {number} end - */ - setExtent: function (start, end) { - var extent = this._extent; - extent[0] = start; - extent[1] = end; - }, - - /** - * Convert data to coord. Data is the rank if it has a ordinal scale - * @param {number} data - * @param {boolean} clamp - * @return {number} - */ - dataToCoord: function (data, clamp) { - var extent = this._extent; - var scale = this.scale; - data = scale.normalize(data); - - if (this.onBand && scale.type === 'ordinal') { - extent = extent.slice(); - fixExtentWithBands(extent, scale.count()); - } - - return linearMap(data, normalizedExtent, extent, clamp); - }, - - /** - * Convert coord to data. Data is the rank if it has a ordinal scale - * @param {number} coord - * @param {boolean} clamp - * @return {number} - */ - coordToData: function (coord, clamp) { - var extent = this._extent; - var scale = this.scale; - - if (this.onBand && scale.type === 'ordinal') { - extent = extent.slice(); - fixExtentWithBands(extent, scale.count()); - } - - var t = linearMap(coord, extent, normalizedExtent, clamp); - - return this.scale.scale(t); - }, - /** - * @return {Array.} - */ - getTicksCoords: function () { - if (this.onBand) { - var bands = this.getBands(); - var coords = []; - for (var i = 0; i < bands.length; i++) { - coords.push(bands[i][0]); - } - if (bands[i - 1]) { - coords.push(bands[i - 1][1]); - } - return coords; - } - else { - return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this); - } - }, - - /** - * Coords of labels are on the ticks or on the middle of bands - * @return {Array.} - */ - getLabelsCoords: function () { - if (this.onBand) { - var bands = this.getBands(); - var coords = []; - var band; - for (var i = 0; i < bands.length; i++) { - band = bands[i]; - coords.push((band[0] + band[1]) / 2); - } - return coords; - } - else { - return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this); - } - }, - - /** - * Get bands. - * - * If axis has labels [1, 2, 3, 4]. Bands on the axis are - * |---1---|---2---|---3---|---4---|. - * - * @return {Array} - */ - // FIXME Situation when labels is on ticks - getBands: function () { - var extent = this.getExtent(); - var bands = []; - var len = this.scale.count(); - var start = extent[0]; - var end = extent[1]; - var span = end - start; - - for (var i = 0; i < len; i++) { - bands.push([ - span * i / len + start, - span * (i + 1) / len + start - ]); - } - return bands; - }, - - /** - * Get width of band - * @return {number} - */ - getBandWidth: function () { - var axisExtent = this._extent; - var dataExtent = this.scale.getExtent(); - - var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0); - - var size = Math.abs(axisExtent[1] - axisExtent[0]); - - return Math.abs(size) / len; - } - }; - - return Axis; -}); -/** - * Helper function for axisLabelInterval calculation - */ - -define('echarts/coord/cartesian/axisLabelInterval',['require','zrender/core/util','../axisHelper'],function(require) { - - - var zrUtil = require('zrender/core/util'); - var axisHelper = require('../axisHelper'); - - return function (axis) { - var axisModel = axis.model; - var labelModel = axisModel.getModel('axisLabel'); - var labelInterval = labelModel.get('interval'); - if (!(axis.type === 'category' && labelInterval === 'auto')) { - return labelInterval === 'auto' ? 0 : labelInterval; - } - - return axisHelper.getAxisLabelInterval( - zrUtil.map(axis.scale.getTicks(), axis.dataToCoord, axis), - axisModel.getFormattedLabels(), - labelModel.getModel('textStyle').getFont(), - axis.isHorizontal() - ); - }; -}); -define('echarts/coord/cartesian/Axis2D',['require','zrender/core/util','../Axis','./axisLabelInterval'],function (require) { - - var zrUtil = require('zrender/core/util'); - var Axis = require('../Axis'); - var axisLabelInterval = require('./axisLabelInterval'); - - /** - * Extend axis 2d - * @constructor module:echarts/coord/cartesian/Axis2D - * @extends {module:echarts/coord/cartesian/Axis} - * @param {string} dim - * @param {*} scale - * @param {Array.} coordExtent - * @param {string} axisType - * @param {string} position - */ - var Axis2D = function (dim, scale, coordExtent, axisType, position) { - Axis.call(this, dim, scale, coordExtent); - /** - * Axis type - * - 'category' - * - 'value' - * - 'time' - * - 'log' - * @type {string} - */ - this.type = axisType || 'value'; - - /** - * Axis position - * - 'top' - * - 'bottom' - * - 'left' - * - 'right' - */ - this.position = position || 'bottom'; - }; - - Axis2D.prototype = { - - constructor: Axis2D, - - /** - * Index of axis, can be used as key - */ - index: 0, - /** - * If axis is on the zero position of the other axis - * @type {boolean} - */ - onZero: false, - - /** - * Axis model - * @param {module:echarts/coord/cartesian/AxisModel} - */ - model: null, - - isHorizontal: function () { - var position = this.position; - return position === 'top' || position === 'bottom'; - }, - - getGlobalExtent: function () { - var ret = this.getExtent(); - ret[0] = this.toGlobalCoord(ret[0]); - ret[1] = this.toGlobalCoord(ret[1]); - return ret; - }, - - /** - * @return {number} - */ - getLabelInterval: function () { - var labelInterval = this._labelInterval; - if (!labelInterval) { - labelInterval = this._labelInterval = axisLabelInterval(this); - } - return labelInterval; - }, - - /** - * If label is ignored. - * Automatically used when axis is category and label can not be all shown - * @param {number} idx - * @return {boolean} - */ - isLabelIgnored: function (idx) { - if (this.type === 'category') { - var labelInterval = this.getLabelInterval(); - return ((typeof labelInterval === 'function') - && !labelInterval(idx, this.scale.getLabel(idx))) - || idx % (labelInterval + 1); - } - }, - - /** - * Transform global coord to local coord, - * i.e. var localCoord = axis.toLocalCoord(80); - * designate by module:echarts/coord/cartesian/Grid. - * @type {Function} - */ - toLocalCoord: null, - - /** - * Transform global coord to local coord, - * i.e. var globalCoord = axis.toLocalCoord(40); - * designate by module:echarts/coord/cartesian/Grid. - * @type {Function} - */ - toGlobalCoord: null - - }; - zrUtil.inherits(Axis2D, Axis); - - return Axis2D; -}); -define('echarts/coord/axisDefault',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - var defaultOption = { - show: true, - zlevel: 0, // 一级层叠 - z: 0, // 二级层叠 - // 反向坐标轴 - inverse: false, - // 坐标轴名字,默认为空 - name: '', - // 坐标轴名字位置,支持'start' | 'middle' | 'end' - nameLocation: 'end', - // 坐标轴文字样式,默认取全局样式 - nameTextStyle: {}, - // 文字与轴线距离 - nameGap: 15, - // 坐标轴线 - axisLine: { - // 默认显示,属性show控制显示与否 - show: true, - onZero: true, - // 属性lineStyle控制线条样式 - lineStyle: { - color: '#333', - width: 1, - type: 'solid' - } - }, - // 坐标轴小标记 - axisTick: { - // 属性show控制显示与否,默认显示 - show: true, - // 控制小标记是否在grid里 - inside: false, - // 属性length控制线长 - length: 5, - // 属性lineStyle控制线条样式 - lineStyle: { - color: '#333', - width: 1 - } - }, - // 坐标轴文本标签,详见axis.axisLabel - axisLabel: { - show: true, - // 控制文本标签是否在grid里 - inside: false, - rotate: 0, - margin: 8, - // formatter: null, - // 其余属性默认使用全局文本样式,详见TEXTSTYLE - textStyle: { - color: '#333', - fontSize: 12 - } - }, - // 分隔线 - splitLine: { - // 默认显示,属性show控制显示与否 - show: true, - // 属性lineStyle(详见lineStyle)控制线条样式 - lineStyle: { - color: ['#ccc'], - width: 1, - type: 'solid' - } - }, - // 分隔区域 - splitArea: { - // 默认不显示,属性show控制显示与否 - show: false, - // 属性areaStyle(详见areaStyle)控制区域样式 - areaStyle: { - color: ['rgba(250,250,250,0.3)','rgba(200,200,200,0.3)'] - } - } - }; - - var categoryAxis = zrUtil.merge({ - // 类目起始和结束两端空白策略 - boundaryGap: true, - // 坐标轴小标记 - axisTick: { - interval: 'auto' - }, - // 坐标轴文本标签,详见axis.axisLabel - axisLabel: { - interval: 'auto' - } - }, defaultOption); - - var valueAxis = zrUtil.defaults({ - // 数值起始和结束两端空白策略 - boundaryGap: [0, 0], - // 最小值, 设置成 'dataMin' 则从数据中计算最小值 - // min: null, - // 最大值,设置成 'dataMax' 则从数据中计算最大值 - // max: null, - // 脱离0值比例,放大聚焦到最终_min,_max区间 - // scale: false, - // 分割段数,默认为5 - splitNumber: 5 - }, defaultOption); - - // FIXME - var timeAxis = zrUtil.defaults({ - scale: true, - min: 'dataMin', - max: 'dataMax' - }, valueAxis); - var logAxis = zrUtil.defaults({}, valueAxis); - logAxis.scale = true; - - return { - categoryAxis: categoryAxis, - valueAxis: valueAxis, - timeAxis: timeAxis, - logAxis: logAxis - }; -}); -define('echarts/coord/axisModelCreator',['require','./axisDefault','zrender/core/util','../model/Component','../util/layout'],function (require) { - - var axisDefault = require('./axisDefault'); - var zrUtil = require('zrender/core/util'); - var ComponentModel = require('../model/Component'); - var layout = require('../util/layout'); - - // FIXME axisType is fixed ? - var AXIS_TYPES = ['value', 'category', 'time', 'log']; - - /** - * Generate sub axis model class - * @param {string} axisName 'x' 'y' 'radius' 'angle' 'parallel' - * @param {module:echarts/model/Component} BaseAxisModelClass - * @param {Function} axisTypeDefaulter - * @param {Object} [extraDefaultOption] - */ - return function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) { - - zrUtil.each(AXIS_TYPES, function (axisType) { - - BaseAxisModelClass.extend({ - - type: axisName + 'Axis.' + axisType, - - mergeDefaultAndTheme: function (option, ecModel) { - var layoutMode = this.layoutMode; - var inputPositionParams = layoutMode - ? layout.getLayoutParams(option) : {}; - - var themeModel = ecModel.getTheme(); - zrUtil.merge(option, themeModel.get(axisType + 'Axis')); - zrUtil.merge(option, this.getDefaultOption()); - - option.type = axisTypeDefaulter(axisName, option); - - if (layoutMode) { - layout.mergeLayoutParam(option, inputPositionParams, layoutMode); - } - }, - - defaultOption: zrUtil.mergeAll( - [ - {}, - axisDefault[axisType + 'Axis'], - extraDefaultOption - ], - true - ) - }); - }); - - ComponentModel.registerSubTypeDefaulter( - axisName + 'Axis', - zrUtil.curry(axisTypeDefaulter, axisName) - ); - }; -}); -define('echarts/coord/axisModelCommonMixin',['require','zrender/core/util','./axisHelper'],function (require) { - - var zrUtil = require('zrender/core/util'); - var axisHelper = require('./axisHelper'); - - function getName(obj) { - if (zrUtil.isObject(obj) && obj.value != null) { - return obj.value; - } - else { - return obj; - } - } - /** - * Get categories - */ - function getCategories() { - return this.get('type') === 'category' - && zrUtil.map(this.get('data'), getName); - } - - /** - * Format labels - * @return {Array.} - */ - function getFormattedLabels() { - return axisHelper.getFormattedLabels( - this.axis, - this.get('axisLabel.formatter') - ); - } - - return { - - getFormattedLabels: getFormattedLabels, - - getCategories: getCategories - }; -}); -define('echarts/coord/cartesian/AxisModel',['require','../../model/Component','zrender/core/util','../axisModelCreator','../axisModelCommonMixin'],function(require) { - - - - var ComponentModel = require('../../model/Component'); - var zrUtil = require('zrender/core/util'); - var axisModelCreator = require('../axisModelCreator'); - - var AxisModel = ComponentModel.extend({ - - type: 'cartesian2dAxis', - - /** - * @type {module:echarts/coord/cartesian/Axis2D} - */ - axis: null, - - /** - * @public - * @param {boolean} needs Whether axis needs cross zero. - */ - setNeedsCrossZero: function (needs) { - this.option.scale = !needs; - }, - - /** - * @public - * @param {number} min - */ - setMin: function (min) { - this.option.min = min; - }, - - /** - * @public - * @param {number} max - */ - setMax: function (max) { - this.option.max = max; - } - }); - - function getAxisType(axisDim, option) { - // Default axis with data is category axis - return option.type || (option.data ? 'category' : 'value'); - } - - zrUtil.merge(AxisModel.prototype, require('../axisModelCommonMixin')); - - var extraOption = { - gridIndex: 0 - }; - - axisModelCreator('x', AxisModel, getAxisType, extraOption); - axisModelCreator('y', AxisModel, getAxisType, extraOption); - - return AxisModel; -}); -// Grid 是在有直角坐标系的时候必须要存在的 -// 所以这里也要被 Cartesian2D 依赖 -define('echarts/coord/cartesian/GridModel',['require','./AxisModel','../../model/Component'],function(require) { - - - - require('./AxisModel'); - var ComponentModel = require('../../model/Component'); - - return ComponentModel.extend({ - - type: 'grid', - - dependencies: ['xAxis', 'yAxis'], - - layoutMode: 'box', - - /** - * @type {module:echarts/coord/cartesian/Grid} - */ - coordinateSystem: null, - - defaultOption: { - show: false, - zlevel: 0, - z: 0, - left: '10%', - top: 60, - right: '10%', - bottom: 60, - // If grid size contain label - containLabel: false, - // width: {totalWidth} - left - right, - // height: {totalHeight} - top - bottom, - backgroundColor: 'rgba(0,0,0,0)', - borderWidth: 1, - borderColor: '#ccc' - } - }); -}); -/** - * Grid is a region which contains at most 4 cartesian systems - * - * TODO Default cartesian - */ -define('echarts/coord/cartesian/Grid',['require','exports','module','../../util/layout','../../coord/axisHelper','zrender/core/util','./Cartesian2D','./Axis2D','./GridModel','../../CoordinateSystem'],function(require, factory) { - - var layout = require('../../util/layout'); - var axisHelper = require('../../coord/axisHelper'); - - var zrUtil = require('zrender/core/util'); - var Cartesian2D = require('./Cartesian2D'); - var Axis2D = require('./Axis2D'); - - var each = zrUtil.each; - - var ifAxisCrossZero = axisHelper.ifAxisCrossZero; - var niceScaleExtent = axisHelper.niceScaleExtent; - - // 依赖 GridModel, AxisModel 做预处理 - require('./GridModel'); - - /** - * Check if the axis is used in the specified grid - * @inner - */ - function isAxisUsedInTheGrid(axisModel, gridModel, ecModel) { - return ecModel.getComponent('grid', axisModel.get('gridIndex')) === gridModel; - } - - function getLabelUnionRect(axis) { - var axisModel = axis.model; - var labels = axisModel.getFormattedLabels(); - var rect; - var step = 1; - var labelCount = labels.length; - if (labelCount > 40) { - // Simple optimization for large amount of labels - step = Math.ceil(labelCount / 40); - } - for (var i = 0; i < labelCount; i += step) { - if (!axis.isLabelIgnored(i)) { - var singleRect = axisModel.getTextRect(labels[i]); - // FIXME consider label rotate - rect ? rect.union(singleRect) : (rect = singleRect); - } - } - return rect; - } - - function Grid(gridModel, ecModel, api) { - /** - * @type {Object.} - * @private - */ - this._coordsMap = {}; - - /** - * @type {Array.} - * @private - */ - this._coordsList = []; - - /** - * @type {Object.} - * @private - */ - this._axesMap = {}; - - /** - * @type {Array.} - * @private - */ - this._axesList = []; - - this._initCartesian(gridModel, ecModel, api); - - this._model = gridModel; - } - - var gridProto = Grid.prototype; - - gridProto.type = 'grid'; - - gridProto.getRect = function () { - return this._rect; - }; - - gridProto.update = function (ecModel, api) { - - var axesMap = this._axesMap; - - this._updateScale(ecModel, this._model); - - function ifAxisCanNotOnZero(otherAxisDim) { - var axes = axesMap[otherAxisDim]; - for (var idx in axes) { - var axis = axes[idx]; - if (axis && (axis.type === 'category' || !ifAxisCrossZero(axis))) { - return true; - } - } - return false; - } - - each(axesMap.x, function (xAxis) { - niceScaleExtent(xAxis, xAxis.model); - }); - each(axesMap.y, function (yAxis) { - niceScaleExtent(yAxis, yAxis.model); - }); - // Fix configuration - each(axesMap.x, function (xAxis) { - // onZero can not be enabled in these two situations - // 1. When any other axis is a category axis - // 2. When any other axis not across 0 point - if (ifAxisCanNotOnZero('y')) { - xAxis.onZero = false; - } - }); - each(axesMap.y, function (yAxis) { - if (ifAxisCanNotOnZero('x')) { - yAxis.onZero = false; - } - }); - - // Resize again if containLabel is enabled - // FIXME It may cause getting wrong grid size in data processing stage - this.resize(this._model, api); - }; - - /** - * Resize the grid - * @param {module:echarts/coord/cartesian/GridModel} gridModel - * @param {module:echarts/ExtensionAPI} api - */ - gridProto.resize = function (gridModel, api) { - - var gridRect = layout.getLayoutRect( - gridModel.getBoxLayoutParams(), { - width: api.getWidth(), - height: api.getHeight() - }); - - this._rect = gridRect; - - var axesList = this._axesList; - - adjustAxes(); - - // Minus label size - if (gridModel.get('containLabel')) { - each(axesList, function (axis) { - if (!axis.model.get('axisLabel.inside')) { - var labelUnionRect = getLabelUnionRect(axis); - if (labelUnionRect) { - var dim = axis.isHorizontal() ? 'height' : 'width'; - var margin = axis.model.get('axisLabel.margin'); - gridRect[dim] -= labelUnionRect[dim] + margin; - if (axis.position === 'top') { - gridRect.y += labelUnionRect.height + margin; - } - else if (axis.position === 'left') { - gridRect.x += labelUnionRect.width + margin; - } - } - } - }); - - adjustAxes(); - } - - function adjustAxes() { - each(axesList, function (axis) { - var isHorizontal = axis.isHorizontal(); - var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height]; - var idx = axis.inverse ? 1 : 0; - axis.setExtent(extent[idx], extent[1 - idx]); - updateAxisTransfrom(axis, isHorizontal ? gridRect.x : gridRect.y); - }); - } - }; - - /** - * @param {string} axisType - * @param {ndumber} [axisIndex] - */ - gridProto.getAxis = function (axisType, axisIndex) { - var axesMapOnDim = this._axesMap[axisType]; - if (axesMapOnDim != null) { - if (axisIndex == null) { - // Find first axis - for (var name in axesMapOnDim) { - return axesMapOnDim[name]; - } - } - return axesMapOnDim[axisIndex]; - } - }; - - gridProto.getCartesian = function (xAxisIndex, yAxisIndex) { - var key = 'x' + xAxisIndex + 'y' + yAxisIndex; - return this._coordsMap[key]; - }; - - /** - * Initialize cartesian coordinate systems - * @private - */ - gridProto._initCartesian = function (gridModel, ecModel, api) { - var axisPositionUsed = { - left: false, - right: false, - top: false, - bottom: false - }; - - var axesMap = { - x: {}, - y: {} - }; - var axesCount = { - x: 0, - y: 0 - }; - - /// Create axis - ecModel.eachComponent('xAxis', createAxisCreator('x'), this); - ecModel.eachComponent('yAxis', createAxisCreator('y'), this); - - if (!axesCount.x || !axesCount.y) { - // Roll back when there no either x or y axis - this._axesMap = {}; - this._axesList = []; - return; - } - - this._axesMap = axesMap; - - /// Create cartesian2d - each(axesMap.x, function (xAxis, xAxisIndex) { - each(axesMap.y, function (yAxis, yAxisIndex) { - var key = 'x' + xAxisIndex + 'y' + yAxisIndex; - var cartesian = new Cartesian2D(key); - - cartesian.grid = this; - - this._coordsMap[key] = cartesian; - this._coordsList.push(cartesian); - - cartesian.addAxis(xAxis); - cartesian.addAxis(yAxis); - }, this); - }, this); - - function createAxisCreator(axisType) { - return function (axisModel, idx) { - if (!isAxisUsedInTheGrid(axisModel, gridModel, ecModel)) { - return; - } - - var axisPosition = axisModel.get('position'); - if (axisType === 'x') { - // Fix position - if (axisPosition !== 'top' && axisPosition !== 'bottom') { - // Default bottom of X - axisPosition = 'bottom'; - } - if (axisPositionUsed[axisPosition]) { - axisPosition = axisPosition === 'top' ? 'bottom' : 'top'; - } - } - else { - // Fix position - if (axisPosition !== 'left' && axisPosition !== 'right') { - // Default left of Y - axisPosition = 'left'; - } - if (axisPositionUsed[axisPosition]) { - axisPosition = axisPosition === 'left' ? 'right' : 'left'; - } - } - axisPositionUsed[axisPosition] = true; - - var axis = new Axis2D( - axisType, axisHelper.createScaleByModel(axisModel), - [0, 0], - axisModel.get('type'), - axisPosition - ); - - var isCategory = axis.type === 'category'; - axis.onBand = isCategory && axisModel.get('boundaryGap'); - axis.inverse = axisModel.get('inverse'); - - axis.onZero = axisModel.get('axisLine.onZero'); - - // Inject axis into axisModel - axisModel.axis = axis; - - // Inject axisModel into axis - axis.model = axisModel; - - // Index of axis, can be used as key - axis.index = idx; - - this._axesList.push(axis); - - axesMap[axisType][idx] = axis; - axesCount[axisType]++; - }; - } - }; - - /** - * Update cartesian properties from series - * @param {module:echarts/model/Option} option - * @private - */ - gridProto._updateScale = function (ecModel, gridModel) { - // Reset scale - zrUtil.each(this._axesList, function (axis) { - axis.scale.setExtent(Infinity, -Infinity); - }); - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.get('coordinateSystem') === 'cartesian2d') { - var xAxisIndex = seriesModel.get('xAxisIndex'); - var yAxisIndex = seriesModel.get('yAxisIndex'); - - var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex); - var yAxisModel = ecModel.getComponent('yAxis', yAxisIndex); - - if (!isAxisUsedInTheGrid(xAxisModel, gridModel, ecModel) - || !isAxisUsedInTheGrid(yAxisModel, gridModel, ecModel) - ) { - return; - } - - var cartesian = this.getCartesian(xAxisIndex, yAxisIndex); - var data = seriesModel.getData(); - var xAxis = cartesian.getAxis('x'); - var yAxis = cartesian.getAxis('y'); - - if (data.type === 'list') { - unionExtent(data, xAxis, seriesModel); - unionExtent(data, yAxis, seriesModel); - } - } - }, this); - - function unionExtent(data, axis, seriesModel) { - each(seriesModel.coordDimToDataDim(axis.dim), function (dim) { - axis.scale.unionExtent(data.getDataExtent( - dim, axis.scale.type !== 'ordinal' - )); - }); - } - }; - - /** - * @inner - */ - function updateAxisTransfrom(axis, coordBase) { - var axisExtent = axis.getExtent(); - var axisExtentSum = axisExtent[0] + axisExtent[1]; - - // Fast transform - axis.toGlobalCoord = axis.dim === 'x' - ? function (coord) { - return coord + coordBase; - } - : function (coord) { - return axisExtentSum - coord + coordBase; - }; - axis.toLocalCoord = axis.dim === 'x' - ? function (coord) { - return coord - coordBase; - } - : function (coord) { - return axisExtentSum - coord + coordBase; - }; - } - - Grid.create = function (ecModel, api) { - var grids = []; - ecModel.eachComponent('grid', function (gridModel, idx) { - var grid = new Grid(gridModel, ecModel, api); - grid.name = 'grid_' + idx; - grid.resize(gridModel, api); - - gridModel.coordinateSystem = grid; - - grids.push(grid); - }); - - // Inject the coordinateSystems into seriesModel - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.get('coordinateSystem') !== 'cartesian2d') { - return; - } - var xAxisIndex = seriesModel.get('xAxisIndex'); - // TODO Validate - var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex); - var grid = grids[xAxisModel.get('gridIndex')]; - seriesModel.coordinateSystem = grid.getCartesian( - xAxisIndex, seriesModel.get('yAxisIndex') - ); - }); - - return grids; - }; - - // For deciding which dimensions to use when creating list data - Grid.dimensions = Cartesian2D.prototype.dimensions; - - require('../../CoordinateSystem').register('cartesian2d', Grid); - - return Grid; -}); -define('echarts/chart/bar/BarSeries',['require','../../model/Series','../helper/createListFromArray'],function(require) { - - - - var SeriesModel = require('../../model/Series'); - var createListFromArray = require('../helper/createListFromArray'); - - return SeriesModel.extend({ - - type: 'series.bar', - - dependencies: ['grid', 'polar'], - - getInitialData: function (option, ecModel) { - return createListFromArray(option.data, this, ecModel); - }, - - getMarkerPosition: function (value) { - var coordSys = this.coordinateSystem; - if (coordSys) { - var pt = coordSys.dataToPoint(value); - var data = this.getData(); - var offset = data.getLayout('offset'); - var size = data.getLayout('size'); - var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1; - pt[offsetIndex] += offset + size / 2; - return pt; - } - return [NaN, NaN]; - }, - - defaultOption: { - zlevel: 0, // 一级层叠 - z: 2, // 二级层叠 - coordinateSystem: 'cartesian2d', - legendHoverLink: true, - // stack: null - - // Cartesian coordinate system - xAxisIndex: 0, - yAxisIndex: 0, - - // 最小高度改为0 - barMinHeight: 0, - - // barMaxWidth: null, - // 默认自适应 - // barWidth: null, - // 柱间距离,默认为柱形宽度的30%,可设固定值 - // barGap: '30%', - // 类目间柱形距离,默认为类目间距的20%,可设固定值 - // barCategoryGap: '20%', - // label: { - // normal: { - // show: false - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - - // // 默认自适应,水平布局为'top',垂直布局为'right',可选为 - // // 'inside' | 'insideleft' | 'insideTop' | 'insideRight' | 'insideBottom' | - // // 'outside' |'left' | 'right'|'top'|'bottom' - // position: - - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - // } - // }, - itemStyle: { - normal: { - // color: '各异', - // 柱条边线 - barBorderColor: '#fff', - // 柱条边线线宽,单位px,默认为1 - barBorderWidth: 0 - }, - emphasis: { - // color: '各异', - // 柱条边线 - barBorderColor: '#fff', - // 柱条边线线宽,单位px,默认为1 - barBorderWidth: 0 - } - } - } - }); -}); -define('echarts/chart/bar/barItemStyle',['require','../../model/mixin/makeStyleMapper'],function (require) { - return { - getBarItemStyle: require('../../model/mixin/makeStyleMapper')( - [ - ['fill', 'color'], - ['stroke', 'barBorderColor'], - ['lineWidth', 'barBorderWidth'], - ['opacity'], - ['shadowBlur'], - ['shadowOffsetX'], - ['shadowOffsetY'], - ['shadowColor'] - ] - ) - }; -}); -define('echarts/chart/bar/BarView',['require','zrender/core/util','../../util/graphic','../../model/Model','./barItemStyle','../../echarts'],function (require) { - - - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - - zrUtil.extend(require('../../model/Model').prototype, require('./barItemStyle')); - - function fixLayoutWithLineWidth(layout, lineWidth) { - var signX = layout.width > 0 ? 1 : -1; - var signY = layout.height > 0 ? 1 : -1; - // In case width or height are too small. - lineWidth = Math.min(lineWidth, Math.abs(layout.width), Math.abs(layout.height)); - layout.x += signX * lineWidth / 2; - layout.y += signY * lineWidth / 2; - layout.width -= signX * lineWidth; - layout.height -= signY * lineWidth; - } - - return require('../../echarts').extendChartView({ - - type: 'bar', - - render: function (seriesModel, ecModel, api) { - var coordinateSystemType = seriesModel.get('coordinateSystem'); - - if (coordinateSystemType === 'cartesian2d') { - this._renderOnCartesian(seriesModel, ecModel, api); - } - - return this.group; - }, - - _renderOnCartesian: function (seriesModel, ecModel, api) { - var group = this.group; - var data = seriesModel.getData(); - var oldData = this._data; - - var cartesian = seriesModel.coordinateSystem; - var baseAxis = cartesian.getBaseAxis(); - var isHorizontal = baseAxis.isHorizontal(); - - var enableAnimation = seriesModel.get('animation'); - - var barBorderWidthQuery = ['itemStyle', 'normal', 'barBorderWidth']; - - function createRect(dataIndex, isUpdate) { - var layout = data.getItemLayout(dataIndex); - var lineWidth = data.getItemModel(dataIndex).get(barBorderWidthQuery) || 0; - fixLayoutWithLineWidth(layout, lineWidth); - - var rect = new graphic.Rect({ - shape: zrUtil.extend({}, layout) - }); - // Animation - if (enableAnimation) { - var rectShape = rect.shape; - var animateProperty = isHorizontal ? 'height' : 'width'; - var animateTarget = {}; - rectShape[animateProperty] = 0; - animateTarget[animateProperty] = layout[animateProperty]; - graphic[isUpdate? 'updateProps' : 'initProps'](rect, { - shape: animateTarget - }, seriesModel); - } - return rect; - } - data.diff(oldData) - .add(function (dataIndex) { - // 空数据 - if (!data.hasValue(dataIndex)) { - return; - } - - var rect = createRect(dataIndex); - - data.setItemGraphicEl(dataIndex, rect); - - group.add(rect); - - }) - .update(function (newIndex, oldIndex) { - var rect = oldData.getItemGraphicEl(oldIndex); - // 空数据 - if (!data.hasValue(newIndex)) { - group.remove(rect); - return; - } - if (!rect) { - rect = createRect(newIndex, true); - } - - var layout = data.getItemLayout(newIndex); - var lineWidth = data.getItemModel(newIndex).get(barBorderWidthQuery) || 0; - fixLayoutWithLineWidth(layout, lineWidth); - - graphic.updateProps(rect, { - shape: layout - }, seriesModel); - - data.setItemGraphicEl(newIndex, rect); - - // Add back - group.add(rect); - }) - .remove(function (idx) { - var rect = oldData.getItemGraphicEl(idx); - if (rect) { - // Not show text when animating - rect.style.text = ''; - graphic.updateProps(rect, { - shape: { - width: 0 - } - }, seriesModel, function () { - group.remove(rect); - }); - } - }) - .execute(); - - this._updateStyle(seriesModel, data, isHorizontal); - - this._data = data; - }, - - _updateStyle: function (seriesModel, data, isHorizontal) { - function setLabel(style, model, color, labelText, labelPositionOutside) { - graphic.setText(style, model, color); - style.text = labelText; - if (style.textPosition === 'outside') { - style.textPosition = labelPositionOutside; - } - } - - data.eachItemGraphicEl(function (rect, idx) { - var itemModel = data.getItemModel(idx); - var color = data.getItemVisual(idx, 'color'); - var layout = data.getItemLayout(idx); - var itemStyleModel = itemModel.getModel('itemStyle.normal'); - - var hoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle(); - - rect.setShape('r', itemStyleModel.get('barBorderRadius') || 0); - - rect.setStyle(zrUtil.defaults( - { - fill: color - }, - itemStyleModel.getBarItemStyle() - )); - - var labelPositionOutside = isHorizontal - ? (layout.height > 0 ? 'bottom' : 'top') - : (layout.width > 0 ? 'left' : 'right'); - - var labelModel = itemModel.getModel('label.normal'); - var hoverLabelModel = itemModel.getModel('label.emphasis'); - var rectStyle = rect.style; - if (labelModel.get('show')) { - setLabel( - rectStyle, labelModel, color, - zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'normal'), - seriesModel.getRawValue(idx) - ), - labelPositionOutside - ); - } - else { - rectStyle.text = ''; - } - if (hoverLabelModel.get('show')) { - setLabel( - hoverStyle, hoverLabelModel, color, - zrUtil.retrieve( - seriesModel.getFormattedLabel(idx, 'emphasis'), - seriesModel.getRawValue(idx) - ), - labelPositionOutside - ); - } - else { - hoverStyle.text = ''; - } - graphic.setHoverStyle(rect, hoverStyle); - }); - }, - - remove: function (ecModel, api) { - var group = this.group; - if (ecModel.get('animation')) { - if (this._data) { - this._data.eachItemGraphicEl(function (el) { - // Not show text when animating - el.style.text = ''; - graphic.updateProps(el, { - shape: { - width: 0 - } - }, ecModel, function () { - group.remove(el); - }); - }); - } - } - else { - group.removeAll(); - } - } - }); -}); -define('echarts/layout/barGrid',['require','zrender/core/util','../util/number'],function(require) { - - - - var zrUtil = require('zrender/core/util'); - var numberUtil = require('../util/number'); - var parsePercent = numberUtil.parsePercent; - - function getSeriesStackId(seriesModel) { - return seriesModel.get('stack') || '__ec_stack_' + seriesModel.seriesIndex; - } - - function calBarWidthAndOffset(barSeries, api) { - // Columns info on each category axis. Key is cartesian name - var columnsMap = {}; - - zrUtil.each(barSeries, function (seriesModel, idx) { - var cartesian = seriesModel.coordinateSystem; - - var baseAxis = cartesian.getBaseAxis(); - - var columnsOnAxis = columnsMap[baseAxis.index] || { - remainedWidth: baseAxis.getBandWidth(), - autoWidthCount: 0, - categoryGap: '20%', - gap: '30%', - axis: baseAxis, - stacks: {} - }; - var stacks = columnsOnAxis.stacks; - columnsMap[baseAxis.index] = columnsOnAxis; - - var stackId = getSeriesStackId(seriesModel); - - if (!stacks[stackId]) { - columnsOnAxis.autoWidthCount++; - } - stacks[stackId] = stacks[stackId] || { - width: 0, - maxWidth: 0 - }; - - var barWidth = seriesModel.get('barWidth'); - var barMaxWidth = seriesModel.get('barMaxWidth'); - var barGap = seriesModel.get('barGap'); - var barCategoryGap = seriesModel.get('barCategoryGap'); - // TODO - if (barWidth && ! stacks[stackId].width) { - barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth); - stacks[stackId].width = barWidth; - columnsOnAxis.remainedWidth -= barWidth; - } - - barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth); - (barGap != null) && (columnsOnAxis.gap = barGap); - (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap); - }); - - var result = {}; - - zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) { - - result[coordSysName] = {}; - - var stacks = columnsOnAxis.stacks; - var baseAxis = columnsOnAxis.axis; - var bandWidth = baseAxis.getBandWidth(); - var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth); - var barGapPercent = parsePercent(columnsOnAxis.gap, 1); - - var remainedWidth = columnsOnAxis.remainedWidth; - var autoWidthCount = columnsOnAxis.autoWidthCount; - var autoWidth = (remainedWidth - categoryGap) - / (autoWidthCount + (autoWidthCount - 1) * barGapPercent); - autoWidth = Math.max(autoWidth, 0); - - // Find if any auto calculated bar exceeded maxBarWidth - zrUtil.each(stacks, function (column, stack) { - var maxWidth = column.maxWidth; - if (!column.width && maxWidth && maxWidth < autoWidth) { - maxWidth = Math.min(maxWidth, remainedWidth); - remainedWidth -= maxWidth; - column.width = maxWidth; - autoWidthCount--; - } - }); - - // Recalculate width again - autoWidth = (remainedWidth - categoryGap) - / (autoWidthCount + (autoWidthCount - 1) * barGapPercent); - autoWidth = Math.max(autoWidth, 0); - - var widthSum = 0; - var lastColumn; - zrUtil.each(stacks, function (column, idx) { - if (!column.width) { - column.width = autoWidth; - } - lastColumn = column; - widthSum += column.width * (1 + barGapPercent); - }); - if (lastColumn) { - widthSum -= lastColumn.width * barGapPercent; - } - - var offset = -widthSum / 2; - zrUtil.each(stacks, function (column, stackId) { - result[coordSysName][stackId] = result[coordSysName][stackId] || { - offset: offset, - width: column.width - }; - - offset += column.width * (1 + barGapPercent); - }); - }); - - return result; - } - - /** - * @param {string} seriesType - * @param {module:echarts/model/Global} ecModel - * @param {module:echarts/ExtensionAPI} api - */ - function barLayoutGrid(seriesType, ecModel, api) { - - var barWidthAndOffset = calBarWidthAndOffset( - zrUtil.filter( - ecModel.getSeriesByType(seriesType), - function (seriesModel) { - return !ecModel.isSeriesFiltered(seriesModel) - && seriesModel.coordinateSystem - && seriesModel.coordinateSystem.type === 'cartesian2d'; - } - ) - ); - - var lastStackCoords = {}; - - ecModel.eachSeriesByType(seriesType, function (seriesModel) { - - var data = seriesModel.getData(); - var cartesian = seriesModel.coordinateSystem; - var baseAxis = cartesian.getBaseAxis(); - - var stackId = getSeriesStackId(seriesModel); - var columnLayoutInfo = barWidthAndOffset[baseAxis.index][stackId]; - var columnOffset = columnLayoutInfo.offset; - var columnWidth = columnLayoutInfo.width; - var valueAxis = cartesian.getOtherAxis(baseAxis); - - var barMinHeight = seriesModel.get('barMinHeight') || 0; - - var valueAxisStart = baseAxis.onZero - ? valueAxis.toGlobalCoord(valueAxis.dataToCoord(0)) - : valueAxis.getGlobalExtent()[0]; - - var coords = cartesian.dataToPoints(data, true); - lastStackCoords[stackId] = lastStackCoords[stackId] || []; - - data.setLayout({ - offset: columnOffset, - size: columnWidth - }); - data.each(valueAxis.dim, function (value, idx) { - // 空数据 - if (isNaN(value)) { - return; - } - if (!lastStackCoords[stackId][idx]) { - lastStackCoords[stackId][idx] = { - // Positive stack - p: valueAxisStart, - // Negative stack - n: valueAxisStart - }; - } - var sign = value >= 0 ? 'p' : 'n'; - var coord = coords[idx]; - var lastCoord = lastStackCoords[stackId][idx][sign]; - var x, y, width, height; - if (valueAxis.isHorizontal()) { - x = lastCoord; - y = coord[1] + columnOffset; - width = coord[0] - lastCoord; - height = columnWidth; - - if (Math.abs(width) < barMinHeight) { - width = (width < 0 ? -1 : 1) * barMinHeight; - } - lastStackCoords[stackId][idx][sign] += width; - } - else { - x = coord[0] + columnOffset; - y = lastCoord; - width = columnWidth; - height = coord[1] - lastCoord; - if (Math.abs(height) < barMinHeight) { - // Include zero to has a positive bar - height = (height <= 0 ? -1 : 1) * barMinHeight; - } - lastStackCoords[stackId][idx][sign] += height; - } - - data.setItemLayout(idx, { - x: x, - y: y, - width: width, - height: height - }); - }, true); - - }, this); - } - - return barLayoutGrid; -}); -define('echarts/chart/bar',['require','zrender/core/util','../coord/cartesian/Grid','./bar/BarSeries','./bar/BarView','../layout/barGrid','../echarts'],function (require) { - - var zrUtil = require('zrender/core/util'); - - require('../coord/cartesian/Grid'); - - require('./bar/BarSeries'); - require('./bar/BarView'); - - var barLayoutGrid = require('../layout/barGrid'); - var echarts = require('../echarts'); - - echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar')); - // Visual coding for legend - echarts.registerVisualCoding('chart', function (ecModel) { - ecModel.eachSeriesByType('bar', function (seriesModel) { - var data = seriesModel.getData(); - data.setVisual('legendSymbol', 'roundRect'); - }); - }); -}); -/** - * Data selectable mixin for chart series. - * To eanble data select, option of series must have `selectedMode`. - * And each data item will use `selected` to toggle itself selected status - * - * @module echarts/chart/helper/DataSelectable - */ -define('echarts/chart/helper/dataSelectableMixin',['require','zrender/core/util'],function (require) { - - var zrUtil = require('zrender/core/util'); - - return { - - updateSelectedMap: function () { - var option = this.option; - this._dataOptMap = zrUtil.reduce(option.data, function (dataOptMap, dataOpt) { - dataOptMap[dataOpt.name] = dataOpt; - return dataOptMap; - }, {}); - }, - /** - * @param {string} name - */ - // PENGING If selectedMode is null ? - select: function (name) { - var dataOptMap = this._dataOptMap; - var dataOpt = dataOptMap[name]; - var selectedMode = this.get('selectedMode'); - if (selectedMode === 'single') { - zrUtil.each(dataOptMap, function (dataOpt) { - dataOpt.selected = false; - }); - } - dataOpt && (dataOpt.selected = true); - }, - - /** - * @param {string} name - */ - unSelect: function (name) { - var dataOpt = this._dataOptMap[name]; - // var selectedMode = this.get('selectedMode'); - // selectedMode !== 'single' && dataOpt && (dataOpt.selected = false); - dataOpt && (dataOpt.selected = false); - }, - - /** - * @param {string} name - */ - toggleSelected: function (name) { - var dataOpt = this._dataOptMap[name]; - if (dataOpt != null) { - this[dataOpt.selected ? 'unSelect' : 'select'](name); - return dataOpt.selected; - } - }, - - /** - * @param {string} name - */ - isSelected: function (name) { - var dataOpt = this._dataOptMap[name]; - return dataOpt && dataOpt.selected; - } - }; -}); -define('echarts/chart/pie/PieSeries',['require','../../data/List','zrender/core/util','../../util/model','../../data/helper/completeDimensions','../helper/dataSelectableMixin','../../echarts'],function(require) { - - - - var List = require('../../data/List'); - var zrUtil = require('zrender/core/util'); - var modelUtil = require('../../util/model'); - var completeDimensions = require('../../data/helper/completeDimensions'); - - var dataSelectableMixin = require('../helper/dataSelectableMixin'); - - var PieSeries = require('../../echarts').extendSeriesModel({ - - type: 'series.pie', - - // Overwrite - init: function (option) { - PieSeries.superApply(this, 'init', arguments); - - // Enable legend selection for each data item - // Use a function instead of direct access because data reference may changed - this.legendDataProvider = function () { - return this._dataBeforeProcessed; - }; - - this.updateSelectedMap(); - - this._defaultLabelLine(option); - }, - - // Overwrite - mergeOption: function (newOption) { - PieSeries.superCall(this, 'mergeOption', newOption); - this.updateSelectedMap(); - }, - - getInitialData: function (option, ecModel) { - var dimensions = completeDimensions(['value'], option.data); - var list = new List(dimensions, this); - list.initData(option.data); - return list; - }, - - // Overwrite - getDataParams: function (dataIndex) { - var data = this._data; - var params = PieSeries.superCall(this, 'getDataParams', dataIndex); - var sum = data.getSum('value'); - // FIXME toFixed? - // - // Percent is 0 if sum is 0 - params.percent = !sum ? 0 : +(data.get('value', dataIndex) / sum * 100).toFixed(2); - - params.$vars.push('percent'); - return params; - }, - - _defaultLabelLine: function (option) { - // Extend labelLine emphasis - modelUtil.defaultEmphasis(option.labelLine, ['show']); - - var labelLineNormalOpt = option.labelLine.normal; - var labelLineEmphasisOpt = option.labelLine.emphasis; - // Not show label line if `label.normal.show = false` - labelLineNormalOpt.show = labelLineNormalOpt.show - && option.label.normal.show; - labelLineEmphasisOpt.show = labelLineEmphasisOpt.show - && option.label.emphasis.show; - }, - - defaultOption: { - zlevel: 0, - z: 2, - legendHoverLink: true, - - hoverAnimation: true, - // 默认全局居中 - center: ['50%', '50%'], - radius: [0, '75%'], - // 默认顺时针 - clockwise: true, - startAngle: 90, - // 最小角度改为0 - minAngle: 0, - // 选中是扇区偏移量 - selectedOffset: 10, - - // If use strategy to avoid label overlapping - avoidLabelOverlap: true, - // 选择模式,默认关闭,可选single,multiple - // selectedMode: false, - // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积) - // roseType: null, - - label: { - normal: { - // If rotate around circle - rotate: false, - show: true, - // 'outer', 'inside', 'center' - position: 'outer' - // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调 - // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE - // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数 - }, - emphasis: {} - }, - // Enabled when label.normal.position is 'outer' - labelLine: { - normal: { - show: true, - // 引导线两段中的第一段长度 - length: 20, - // 引导线两段中的第二段长度 - length2: 5, - smooth: false, - lineStyle: { - // color: 各异, - width: 1, - type: 'solid' - } - } - }, - itemStyle: { - normal: { - // color: 各异, - borderColor: 'rgba(0,0,0,0)', - borderWidth: 1 - }, - emphasis: { - // color: 各异, - borderColor: 'rgba(0,0,0,0)', - borderWidth: 1 - } - }, - - animationEasing: 'cubicOut', - - data: [] - } - }); - - zrUtil.mixin(PieSeries, dataSelectableMixin); - - return PieSeries; -}); -define('echarts/chart/pie/PieView',['require','../../util/graphic','zrender/core/util','../../view/Chart'],function (require) { - - var graphic = require('../../util/graphic'); - var zrUtil = require('zrender/core/util'); - - /** - * @param {module:echarts/model/Series} seriesModel - * @param {boolean} hasAnimation - * @inner - */ - function updateDataSelected(uid, seriesModel, hasAnimation, api) { - var data = seriesModel.getData(); - var dataIndex = this.dataIndex; - var name = data.getName(dataIndex); - var selectedOffset = seriesModel.get('selectedOffset'); - - api.dispatchAction({ - type: 'pieToggleSelect', - from: uid, - name: name, - seriesId: seriesModel.id - }); - - data.each(function (idx) { - toggleItemSelected( - data.getItemGraphicEl(idx), - data.getItemLayout(idx), - seriesModel.isSelected(data.getName(idx)), - selectedOffset, - hasAnimation - ); - }); - } - - /** - * @param {module:zrender/graphic/Sector} el - * @param {Object} layout - * @param {boolean} isSelected - * @param {number} selectedOffset - * @param {boolean} hasAnimation - * @inner - */ - function toggleItemSelected(el, layout, isSelected, selectedOffset, hasAnimation) { - var midAngle = (layout.startAngle + layout.endAngle) / 2; - - var dx = Math.cos(midAngle); - var dy = Math.sin(midAngle); - - var offset = isSelected ? selectedOffset : 0; - var position = [dx * offset, dy * offset]; - - hasAnimation - // animateTo will stop revious animation like update transition - ? el.animate() - .when(200, { - position: position - }) - .start('bounceOut') - : el.attr('position', position); - } - - /** - * Piece of pie including Sector, Label, LabelLine - * @constructor - * @extends {module:zrender/graphic/Group} - */ - function PiePiece(data, idx) { - - graphic.Group.call(this); - - var sector = new graphic.Sector({ - z2: 2 - }); - var polyline = new graphic.Polyline(); - var text = new graphic.Text(); - this.add(sector); - this.add(polyline); - this.add(text); - - this.updateData(data, idx, true); - - // Hover to change label and labelLine - function onEmphasis() { - polyline.ignore = polyline.hoverIgnore; - text.ignore = text.hoverIgnore; - } - function onNormal() { - polyline.ignore = polyline.normalIgnore; - text.ignore = text.normalIgnore; - } - this.on('emphasis', onEmphasis) - .on('normal', onNormal) - .on('mouseover', onEmphasis) - .on('mouseout', onNormal); - } - - var piePieceProto = PiePiece.prototype; - - function getLabelStyle(data, idx, state, labelModel) { - var textStyleModel = labelModel.getModel('textStyle'); - var position = labelModel.get('position'); - var isLabelInside = position === 'inside' || position === 'inner'; - return { - fill: textStyleModel.getTextColor() - || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')), - textFont: textStyleModel.getFont(), - text: zrUtil.retrieve( - data.hostModel.getFormattedLabel(idx, state), data.getName(idx) - ) - }; - } - - piePieceProto.updateData = function (data, idx, firstCreate) { - - var sector = this.childAt(0); - - var seriesModel = data.hostModel; - var itemModel = data.getItemModel(idx); - var layout = data.getItemLayout(idx); - var sectorShape = zrUtil.extend({}, layout); - sectorShape.label = null; - if (firstCreate) { - sector.setShape(sectorShape); - sector.shape.endAngle = layout.startAngle; - graphic.updateProps(sector, { - shape: { - endAngle: layout.endAngle - } - }, seriesModel); - } - else { - graphic.updateProps(sector, { - shape: sectorShape - }, seriesModel); - } - - // Update common style - var itemStyleModel = itemModel.getModel('itemStyle'); - var visualColor = data.getItemVisual(idx, 'color'); - - sector.setStyle( - zrUtil.defaults( - { - fill: visualColor - }, - itemStyleModel.getModel('normal').getItemStyle() - ) - ); - sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle(); - - // Toggle selected - toggleItemSelected( - this, - data.getItemLayout(idx), - itemModel.get('selected'), - seriesModel.get('selectedOffset'), - seriesModel.get('animation') - ); - - function onEmphasis() { - // Sector may has animation of updating data. Force to move to the last frame - // Or it may stopped on the wrong shape - sector.stopAnimation(true); - sector.animateTo({ - shape: { - r: layout.r + 10 - } - }, 300, 'elasticOut'); - } - function onNormal() { - sector.stopAnimation(true); - sector.animateTo({ - shape: { - r: layout.r - } - }, 300, 'elasticOut'); - } - sector.off('mouseover').off('mouseout').off('emphasis').off('normal'); - if (itemModel.get('hoverAnimation')) { - sector - .on('mouseover', onEmphasis) - .on('mouseout', onNormal) - .on('emphasis', onEmphasis) - .on('normal', onNormal); - } - - this._updateLabel(data, idx); - - graphic.setHoverStyle(this); - }; - - piePieceProto._updateLabel = function (data, idx) { - - var labelLine = this.childAt(1); - var labelText = this.childAt(2); - - var seriesModel = data.hostModel; - var itemModel = data.getItemModel(idx); - var layout = data.getItemLayout(idx); - var labelLayout = layout.label; - var visualColor = data.getItemVisual(idx, 'color'); - - graphic.updateProps(labelLine, { - shape: { - points: labelLayout.linePoints || [ - [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y] - ] - } - }, seriesModel); - - graphic.updateProps(labelText, { - style: { - x: labelLayout.x, - y: labelLayout.y - } - }, seriesModel); - labelText.attr({ - style: { - textAlign: labelLayout.textAlign, - textBaseline: labelLayout.textBaseline, - textFont: labelLayout.font - }, - rotation: labelLayout.rotation, - origin: [labelLayout.x, labelLayout.y], - z2: 10 - }); - - var labelModel = itemModel.getModel('label.normal'); - var labelHoverModel = itemModel.getModel('label.emphasis'); - var labelLineModel = itemModel.getModel('labelLine.normal'); - var labelLineHoverModel = itemModel.getModel('labelLine.emphasis'); - - labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel)); - - labelText.ignore = labelText.normalIgnore = !labelModel.get('show'); - labelText.hoverIgnore = !labelHoverModel.get('show'); - - labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show'); - labelLine.hoverIgnore = !labelLineHoverModel.get('show'); - - // Default use item visual color - labelLine.setStyle({ - stroke: visualColor - }); - labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle()); - - labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel); - labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle(); - - var smooth = labelLineModel.get('smooth'); - if (smooth && smooth === true) { - smooth = 0.4; - } - labelLine.setShape({ - smooth: smooth - }); - }; - - zrUtil.inherits(PiePiece, graphic.Group); - - - // Pie view - var Pie = require('../../view/Chart').extend({ - - type: 'pie', - - init: function () { - var sectorGroup = new graphic.Group(); - this._sectorGroup = sectorGroup; - }, - - render: function (seriesModel, ecModel, api, payload) { - if (payload && (payload.from === this.uid)) { - return; - } - - var data = seriesModel.getData(); - var oldData = this._data; - var group = this.group; - - var hasAnimation = ecModel.get('animation'); - var isFirstRender = !oldData; - - var onSectorClick = zrUtil.curry( - updateDataSelected, this.uid, seriesModel, hasAnimation, api - ); - - var selectedMode = seriesModel.get('selectedMode'); - - data.diff(oldData) - .add(function (idx) { - var piePiece = new PiePiece(data, idx); - if (isFirstRender) { - piePiece.eachChild(function (child) { - child.stopAnimation(true); - }); - } - - selectedMode && piePiece.on('click', onSectorClick); - - data.setItemGraphicEl(idx, piePiece); - - group.add(piePiece); - }) - .update(function (newIdx, oldIdx) { - var piePiece = oldData.getItemGraphicEl(oldIdx); - - piePiece.updateData(data, newIdx); - - piePiece.off('click'); - selectedMode && piePiece.on('click', onSectorClick); - group.add(piePiece); - data.setItemGraphicEl(newIdx, piePiece); - }) - .remove(function (idx) { - var piePiece = oldData.getItemGraphicEl(idx); - group.remove(piePiece); - }) - .execute(); - - if (hasAnimation && isFirstRender && data.count() > 0) { - var shape = data.getItemLayout(0); - var r = Math.max(api.getWidth(), api.getHeight()) / 2; - - var removeClipPath = zrUtil.bind(group.removeClipPath, group); - group.setClipPath(this._createClipPath( - shape.cx, shape.cy, r, shape.startAngle, shape.clockwise, removeClipPath, seriesModel - )); - } - - this._data = data; - }, - - _createClipPath: function ( - cx, cy, r, startAngle, clockwise, cb, seriesModel - ) { - var clipPath = new graphic.Sector({ - shape: { - cx: cx, - cy: cy, - r0: 0, - r: r, - startAngle: startAngle, - endAngle: startAngle, - clockwise: clockwise - } - }); - - graphic.initProps(clipPath, { - shape: { - endAngle: startAngle + (clockwise ? 1 : -1) * Math.PI * 2 - } - }, seriesModel, cb); - - return clipPath; - } - }); - - return Pie; -}); -define('echarts/action/createDataSelectAction',['require','../echarts','zrender/core/util'],function (require) { - var echarts = require('../echarts'); - var zrUtil = require('zrender/core/util'); - return function (seriesType, actionInfos) { - zrUtil.each(actionInfos, function (actionInfo) { - actionInfo.update = 'updateView'; - /** - * @payload - * @property {string} seriesName - * @property {string} name - */ - echarts.registerAction(actionInfo, function (payload, ecModel) { - var selected = {}; - ecModel.eachComponent( - {mainType: 'series', subType: seriesType, query: payload}, - function (seriesModel) { - if (seriesModel[actionInfo.method]) { - seriesModel[actionInfo.method](payload.name); - } - var data = seriesModel.getData(); - // Create selected map - data.each(function (idx) { - var name = data.getName(idx); - selected[name] = seriesModel.isSelected(name) || false; - }); - } - ); - return { - name: payload.name, - selected: selected - }; - }); - }); - }; -}); -// Pick color from palette for each data item -define('echarts/visual/dataColor',['require'],function (require) { - - return function (seriesType, ecModel) { - var globalColorList = ecModel.get('color'); - var offset = 0; - ecModel.eachRawSeriesByType(seriesType, function (seriesModel) { - var colorList = seriesModel.get('color', true); - var dataAll = seriesModel.getRawData(); - if (!ecModel.isSeriesFiltered(seriesModel)) { - var data = seriesModel.getData(); - data.each(function (idx) { - var itemModel = data.getItemModel(idx); - var rawIdx = data.getRawIndex(idx); - // If series.itemStyle.normal.color is a function. itemVisual may be encoded - var singleDataColor = data.getItemVisual(idx, 'color', true); - if (!singleDataColor) { - var paletteColor = colorList ? colorList[rawIdx % colorList.length] - : globalColorList[(rawIdx + offset) % globalColorList.length]; - var color = itemModel.get('itemStyle.normal.color') || paletteColor; - // Legend may use the visual info in data before processed - dataAll.setItemVisual(rawIdx, 'color', color); - data.setItemVisual(idx, 'color', color); - } - else { - // Set data all color for legend - dataAll.setItemVisual(rawIdx, 'color', singleDataColor); - } - }); - } - offset += dataAll.count(); - }); - }; -}); -// FIXME emphasis label position is not same with normal label position -define('echarts/chart/pie/labelLayout',['require','zrender/contain/text'],function (require) { - - - - var textContain = require('zrender/contain/text'); - - function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) { - list.sort(function (a, b) { - return a.y - b.y; - }); - - // 压 - function shiftDown(start, end, delta, dir) { - for (var j = start; j < end; j++) { - list[j].y += delta; - if (j > start - && j + 1 < end - && list[j + 1].y > list[j].y + list[j].height - ) { - shiftUp(j, delta / 2); - return; - } - } - - shiftUp(end - 1, delta / 2); - } - - // 弹 - function shiftUp(end, delta) { - for (var j = end; j >= 0; j--) { - list[j].y -= delta; - if (j > 0 - && list[j].y > list[j - 1].y + list[j - 1].height - ) { - break; - } - } - } - - // function changeX(list, isDownList, cx, cy, r, dir) { - // var deltaX; - // var deltaY; - // var length; - // var lastDeltaX = dir > 0 - // ? isDownList // 右侧 - // ? Number.MAX_VALUE // 下 - // : 0 // 上 - // : isDownList // 左侧 - // ? Number.MAX_VALUE // 下 - // : 0; // 上 - - // for (var i = 0, l = list.length; i < l; i++) { - // deltaY = Math.abs(list[i].y - cy); - // length = list[i].length; - // deltaX = (deltaY < r + length) - // ? Math.sqrt( - // (r + length + 20) * (r + length + 20) - // - Math.pow(list[i].y - cy, 2) - // ) - // : Math.abs( - // list[i].x - cx - // ); - // if (isDownList && deltaX >= lastDeltaX) { - // // 右下,左下 - // deltaX = lastDeltaX - 10; - // } - // if (!isDownList && deltaX <= lastDeltaX) { - // // 右上,左上 - // deltaX = lastDeltaX + 10; - // } - - // list[i].x = cx + deltaX * dir; - // lastDeltaX = deltaX; - // } - // } - - var lastY = 0; - var delta; - var len = list.length; - var upList = []; - var downList = []; - for (var i = 0; i < len; i++) { - delta = list[i].y - lastY; - if (delta < 0) { - shiftDown(i, len, -delta, dir); - } - lastY = list[i].y + list[i].height; - } - if (viewHeight - lastY < 0) { - shiftUp(len - 1, lastY - viewHeight); - } - for (var i = 0; i < len; i++) { - if (list[i].y >= cy) { - downList.push(list[i]); - } - else { - upList.push(list[i]); - } - } - // changeX(downList, true, cx, cy, r, dir); - // changeX(upList, false, cx, cy, r, dir); - } - - function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) { - var leftList = []; - var rightList = []; - for (var i = 0; i < labelLayoutList.length; i++) { - if (labelLayoutList[i].x < cx) { - leftList.push(labelLayoutList[i]); - } - else { - rightList.push(labelLayoutList[i]); - } - } - - adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight); - adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight); - - for (var i = 0; i < labelLayoutList.length; i++) { - var linePoints = labelLayoutList[i].linePoints; - if (linePoints) { - if (labelLayoutList[i].x < cx) { - linePoints[2][0] = labelLayoutList[i].x + 3; - } - else { - linePoints[2][0] = labelLayoutList[i].x - 3; - } - linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y; - } - } - } - - return function (seriesModel, r, viewWidth, viewHeight) { - var data = seriesModel.getData(); - var labelLayoutList = []; - var cx; - var cy; - var hasLabelRotate = false; - - data.each(function (idx) { - var layout = data.getItemLayout(idx); - - var itemModel = data.getItemModel(idx); - var labelModel = itemModel.getModel('label.normal'); - var labelPosition = labelModel.get('position'); - - var labelLineModel = itemModel.getModel('labelLine.normal'); - var labelLineLen = labelLineModel.get('length'); - var labelLineLen2 = labelLineModel.get('length2'); - - var midAngle = (layout.startAngle + layout.endAngle) / 2; - var dx = Math.cos(midAngle); - var dy = Math.sin(midAngle); - - var textX; - var textY; - var linePoints; - var textAlign; - - cx = layout.cx; - cy = layout.cy; - - if (labelPosition === 'center') { - textX = layout.cx; - textY = layout.cy; - textAlign = 'center'; - } - else { - var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner'; - var x1 = (isLabelInside ? layout.r / 2 * dx : layout.r * dx) + cx; - var y1 = (isLabelInside ? layout.r / 2 * dy : layout.r * dy) + cy; - - // For roseType - labelLineLen += r - layout.r; - - textX = x1 + dx * 3; - textY = y1 + dy * 3; - - if (!isLabelInside) { - var x2 = x1 + dx * labelLineLen; - var y2 = y1 + dy * labelLineLen; - var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2); - var y3 = y2; - - textX = x3 + (dx < 0 ? -5 : 5); - textY = y3; - linePoints = [[x1, y1], [x2, y2], [x3, y3]]; - } - - textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right'); - } - var textBaseline = 'middle'; - var font = labelModel.getModel('textStyle').getFont(); - - var labelRotate = labelModel.get('rotate') - ? (dx < 0 ? -midAngle + Math.PI : -midAngle) : 0; - var text = seriesModel.getFormattedLabel(idx, 'normal') - || data.getName(idx); - var textRect = textContain.getBoundingRect( - text, font, textAlign, textBaseline - ); - hasLabelRotate = !!labelRotate; - layout.label = { - x: textX, - y: textY, - height: textRect.height, - length: labelLineLen, - length2: labelLineLen2, - linePoints: linePoints, - textAlign: textAlign, - textBaseline: textBaseline, - font: font, - rotation: labelRotate - }; - - labelLayoutList.push(layout.label); - }); - if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) { - avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight); - } - }; -}); -// TODO minAngle - -define('echarts/chart/pie/pieLayout',['require','../../util/number','./labelLayout','zrender/core/util'],function (require) { - - var numberUtil = require('../../util/number'); - var parsePercent = numberUtil.parsePercent; - var labelLayout = require('./labelLayout'); - var zrUtil = require('zrender/core/util'); - - var PI2 = Math.PI * 2; - var RADIAN = Math.PI / 180; - - return function (seriesType, ecModel, api) { - ecModel.eachSeriesByType(seriesType, function (seriesModel) { - var center = seriesModel.get('center'); - var radius = seriesModel.get('radius'); - - if (!zrUtil.isArray(radius)) { - radius = [0, radius]; - } - if (!zrUtil.isArray(center)) { - center = [center, center]; - } - - var width = api.getWidth(); - var height = api.getHeight(); - var size = Math.min(width, height); - var cx = parsePercent(center[0], width); - var cy = parsePercent(center[1], height); - var r0 = parsePercent(radius[0], size / 2); - var r = parsePercent(radius[1], size / 2); - - var data = seriesModel.getData(); - - var startAngle = -seriesModel.get('startAngle') * RADIAN; - - var minAngle = seriesModel.get('minAngle') * RADIAN; - - var sum = data.getSum('value'); - // Sum may be 0 - var unitRadian = Math.PI / (sum || data.count()) * 2; - - var clockwise = seriesModel.get('clockwise'); - - var roseType = seriesModel.get('roseType'); - - // [0...max] - var extent = data.getDataExtent('value'); - extent[0] = 0; - - // In the case some sector angle is smaller than minAngle - var restAngle = PI2; - var valueSumLargerThanMinAngle = 0; - - var currentAngle = startAngle; - - var dir = clockwise ? 1 : -1; - data.each('value', function (value, idx) { - var angle; - // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样? - if (roseType !== 'area') { - angle = sum === 0 ? unitRadian : (value * unitRadian); - } - else { - angle = PI2 / (data.count() || 1); - } - - if (angle < minAngle) { - angle = minAngle; - restAngle -= minAngle; - } - else { - valueSumLargerThanMinAngle += value; - } - - var endAngle = currentAngle + dir * angle; - data.setItemLayout(idx, { - angle: angle, - startAngle: currentAngle, - endAngle: endAngle, - clockwise: clockwise, - cx: cx, - cy: cy, - r0: r0, - r: roseType - ? numberUtil.linearMap(value, extent, [r0, r]) - : r - }); - - currentAngle = endAngle; - }, true); - - // Some sector is constrained by minAngle - // Rest sectors needs recalculate angle - if (restAngle < PI2) { - // Average the angle if rest angle is not enough after all angles is - // Constrained by minAngle - if (restAngle <= 1e-3) { - var angle = PI2 / data.count(); - data.each(function (idx) { - var layout = data.getItemLayout(idx); - layout.startAngle = startAngle + dir * idx * angle; - layout.endAngle = startAngle + dir * (idx + 1) * angle; - }); - } - else { - unitRadian = restAngle / valueSumLargerThanMinAngle; - currentAngle = startAngle; - data.each('value', function (value, idx) { - var layout = data.getItemLayout(idx); - var angle = layout.angle === minAngle - ? minAngle : value * unitRadian; - layout.startAngle = currentAngle; - layout.endAngle = currentAngle + dir * angle; - currentAngle += angle; - }); - } - } - - labelLayout(seriesModel, r, width, height); - }); - }; -}); -define('echarts/processor/dataFilter',[],function () { - return function (seriesType, ecModel) { - var legendModels = ecModel.findComponents({ - mainType: 'legend' - }); - if (!legendModels || !legendModels.length) { - return; - } - ecModel.eachSeriesByType(seriesType, function (series) { - var data = series.getData(); - data.filterSelf(function (idx) { - var name = data.getName(idx); - // If in any legend component the status is not selected. - for (var i = 0; i < legendModels.length; i++) { - if (!legendModels[i].isSelected(name)) { - return false; - } - } - return true; - }, this); - }, this); - }; -}); -define('echarts/chart/pie',['require','zrender/core/util','../echarts','./pie/PieSeries','./pie/PieView','../action/createDataSelectAction','../visual/dataColor','./pie/pieLayout','../processor/dataFilter'],function (require) { - - var zrUtil = require('zrender/core/util'); - var echarts = require('../echarts'); - - require('./pie/PieSeries'); - require('./pie/PieView'); - - require('../action/createDataSelectAction')('pie', [{ - type: 'pieToggleSelect', - event: 'pieselectchanged', - method: 'toggleSelected' - }, { - type: 'pieSelect', - event: 'pieselected', - method: 'select' - }, { - type: 'pieUnSelect', - event: 'pieunselected', - method: 'unSelect' - }]); - - echarts.registerVisualCoding( - 'chart', zrUtil.curry(require('../visual/dataColor'), 'pie') - ); - - echarts.registerLayout(zrUtil.curry( - require('./pie/pieLayout'), 'pie' - )); - - echarts.registerProcessor( - 'filter', zrUtil.curry(require('../processor/dataFilter'), 'pie') - ); -}); -define('echarts/component/axis/AxisBuilder',['require','zrender/core/util','../../util/graphic','../../model/Model','../../util/number'],function (require) { - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var Model = require('../../model/Model'); - var numberUtil = require('../../util/number'); - var remRadian = numberUtil.remRadian; - var isRadianAroundZero = numberUtil.isRadianAroundZero; - - var PI = Math.PI; - - /** - * A final axis is translated and rotated from a "standard axis". - * So opt.position and opt.rotation is required. - * - * A standard axis is and axis from [0, 0] to [0, axisExtent[1]], - * for example: (0, 0) ------------> (0, 50) - * - * nameDirection or tickDirection or labelDirection is 1 means tick - * or label is below the standard axis, whereas is -1 means above - * the standard axis. labelOffset means offset between label and axis, - * which is useful when 'onZero', where axisLabel is in the grid and - * label in outside grid. - * - * Tips: like always, - * positive rotation represents anticlockwise, and negative rotation - * represents clockwise. - * The direction of position coordinate is the same as the direction - * of screen coordinate. - * - * Do not need to consider axis 'inverse', which is auto processed by - * axis extent. - * - * @param {module:zrender/container/Group} group - * @param {Object} axisModel - * @param {Object} opt Standard axis parameters. - * @param {Array.} opt.position [x, y] - * @param {number} opt.rotation by radian - * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'. - * @param {number} [opt.tickDirection=1] 1 or -1 - * @param {number} [opt.labelDirection=1] 1 or -1 - * @param {number} [opt.labelOffset=0] Usefull when onZero. - * @param {string} [opt.axisName] default get from axisModel. - * @param {number} [opt.labelRotation] by degree, default get from axisModel. - * @param {number} [opt.labelInterval] Default label interval when label - * interval from model is null or 'auto'. - * @param {number} [opt.strokeContainThreshold] Default label interval when label - * @param {number} [opt.silent=true] - */ - var AxisBuilder = function (axisModel, opt) { - - /** - * @readOnly - */ - this.opt = opt; - - /** - * @readOnly - */ - this.axisModel = axisModel; - - // Default value - zrUtil.defaults( - opt, - { - labelOffset: 0, - nameDirection: 1, - tickDirection: 1, - labelDirection: 1, - silent: true - } - ); - - /** - * @readOnly - */ - this.group = new graphic.Group({ - position: opt.position.slice(), - rotation: opt.rotation - }); - }; - - AxisBuilder.prototype = { - - constructor: AxisBuilder, - - hasBuilder: function (name) { - return !!builders[name]; - }, - - add: function (name) { - builders[name].call(this); - }, - - getGroup: function () { - return this.group; - } - - }; - - var builders = { - - /** - * @private - */ - axisLine: function () { - var opt = this.opt; - var axisModel = this.axisModel; - - if (!axisModel.get('axisLine.show')) { - return; - } - - var extent = this.axisModel.axis.getExtent(); - - this.group.add(new graphic.Line({ - shape: { - x1: extent[0], - y1: 0, - x2: extent[1], - y2: 0 - }, - style: zrUtil.extend( - {lineCap: 'round'}, - axisModel.getModel('axisLine.lineStyle').getLineStyle() - ), - strokeContainThreshold: opt.strokeContainThreshold, - silent: !!opt.silent, - z2: 1 - })); - }, - - /** - * @private - */ - axisTick: function () { - var axisModel = this.axisModel; - - if (!axisModel.get('axisTick.show')) { - return; - } - - var axis = axisModel.axis; - var tickModel = axisModel.getModel('axisTick'); - var opt = this.opt; - - var lineStyleModel = tickModel.getModel('lineStyle'); - var tickLen = tickModel.get('length'); - var tickInterval = getInterval(tickModel, opt.labelInterval); - var ticksCoords = axis.getTicksCoords(); - var tickLines = []; - - for (var i = 0; i < ticksCoords.length; i++) { - // Only ordinal scale support tick interval - if (ifIgnoreOnTick(axis, i, tickInterval)) { - continue; - } - - var tickCoord = ticksCoords[i]; - - // Tick line - tickLines.push(new graphic.Line(graphic.subPixelOptimizeLine({ - shape: { - x1: tickCoord, - y1: 0, - x2: tickCoord, - y2: opt.tickDirection * tickLen - }, - style: { - lineWidth: lineStyleModel.get('width') - }, - silent: true - }))); - } - - this.group.add(graphic.mergePath(tickLines, { - style: lineStyleModel.getLineStyle(), - silent: true - })); - }, - - /** - * @param {module:echarts/coord/cartesian/AxisModel} axisModel - * @param {module:echarts/coord/cartesian/GridModel} gridModel - * @private - */ - axisLabel: function () { - var axisModel = this.axisModel; - - if (!axisModel.get('axisLabel.show')) { - return; - } - - var opt = this.opt; - var axis = axisModel.axis; - var labelModel = axisModel.getModel('axisLabel'); - var textStyleModel = labelModel.getModel('textStyle'); - var labelMargin = labelModel.get('margin'); - var ticks = axis.scale.getTicks(); - var labels = axisModel.getFormattedLabels(); - - // Special label rotate. - var labelRotation = opt.labelRotation; - if (labelRotation == null) { - labelRotation = labelModel.get('rotate') || 0; - } - // To radian. - labelRotation = labelRotation * PI / 180; - - var labelLayout = innerTextLayout(opt, labelRotation, opt.labelDirection); - var categoryData = axisModel.get('data'); - - var textEls = []; - for (var i = 0; i < ticks.length; i++) { - if (ifIgnoreOnTick(axis, i, opt.labelInterval)) { - continue; - } - - var itemTextStyleModel = textStyleModel; - if (categoryData && categoryData[i] && categoryData[i].textStyle) { - itemTextStyleModel = new Model( - categoryData[i].textStyle, textStyleModel, axisModel.ecModel - ); - } - - var tickCoord = axis.dataToCoord(ticks[i]); - var pos = [ - tickCoord, - opt.labelOffset + opt.labelDirection * labelMargin - ]; - - var textEl = new graphic.Text({ - style: { - text: labels[i], - textAlign: itemTextStyleModel.get('align', true) || labelLayout.textAlign, - textBaseline: itemTextStyleModel.get('baseline', true) || labelLayout.textBaseline, - textFont: itemTextStyleModel.getFont(), - fill: itemTextStyleModel.getTextColor() - }, - position: pos, - rotation: labelLayout.rotation, - silent: true, - z2: 10 - }); - textEls.push(textEl); - this.group.add(textEl); - } - - function isTwoLabelOverlapped(current, next) { - var firstRect = current && current.getBoundingRect().clone(); - var nextRect = next && next.getBoundingRect().clone(); - if (firstRect && nextRect) { - firstRect.applyTransform(current.getLocalTransform()); - nextRect.applyTransform(next.getLocalTransform()); - return firstRect.intersect(nextRect); - } - } - if (axis.type !== 'category') { - // If min or max are user set, we need to check - // If the tick on min(max) are overlap on their neighbour tick - // If they are overlapped, we need to hide the min(max) tick label - if (axisModel.get('min')) { - var firstLabel = textEls[0]; - var nextLabel = textEls[1]; - if (isTwoLabelOverlapped(firstLabel, nextLabel)) { - firstLabel.ignore = true; - } - } - if (axisModel.get('max')) { - var lastLabel = textEls[textEls.length - 1]; - var prevLabel = textEls[textEls.length - 2]; - if (isTwoLabelOverlapped(prevLabel, lastLabel)) { - lastLabel.ignore = true; - } - } - } - }, - - /** - * @private - */ - axisName: function () { - var opt = this.opt; - var axisModel = this.axisModel; - - var name = this.opt.axisName; - // If name is '', do not get name from axisMode. - if (name == null) { - name = axisModel.get('name'); - } - - if (!name) { - return; - } - - var nameLocation = axisModel.get('nameLocation'); - var nameDirection = opt.nameDirection; - var textStyleModel = axisModel.getModel('nameTextStyle'); - var gap = axisModel.get('nameGap') || 0; - - var extent = this.axisModel.axis.getExtent(); - var gapSignal = extent[0] > extent[1] ? -1 : 1; - var pos = [ - nameLocation === 'start' - ? extent[0] - gapSignal * gap - : nameLocation === 'end' - ? extent[1] + gapSignal * gap - : (extent[0] + extent[1]) / 2, // 'middle' - // Reuse labelOffset. - nameLocation === 'middle' ? opt.labelOffset + nameDirection * gap : 0 - ]; - - var labelLayout; - - if (nameLocation === 'middle') { - labelLayout = innerTextLayout(opt, opt.rotation, nameDirection); - } - else { - labelLayout = endTextLayout(opt, nameLocation, extent); - } - - this.group.add(new graphic.Text({ - style: { - text: name, - textFont: textStyleModel.getFont(), - fill: textStyleModel.getTextColor() - || axisModel.get('axisLine.lineStyle.color'), - textAlign: labelLayout.textAlign, - textBaseline: labelLayout.textBaseline - }, - position: pos, - rotation: labelLayout.rotation, - silent: true, - z2: 1 - })); - } - - }; - - /** - * @inner - */ - function innerTextLayout(opt, textRotation, direction) { - var rotationDiff = remRadian(textRotation - opt.rotation); - var textAlign; - var textBaseline; - - if (isRadianAroundZero(rotationDiff)) { // Label is parallel with axis line. - textBaseline = direction > 0 ? 'top' : 'bottom'; - textAlign = 'center'; - } - else if (isRadianAroundZero(rotationDiff - PI)) { // Label is inverse parallel with axis line. - textBaseline = direction > 0 ? 'bottom' : 'top'; - textAlign = 'center'; - } - else { - textBaseline = 'middle'; - - if (rotationDiff > 0 && rotationDiff < PI) { - textAlign = direction > 0 ? 'right' : 'left'; - } - else { - textAlign = direction > 0 ? 'left' : 'right'; - } - } - - return { - rotation: rotationDiff, - textAlign: textAlign, - textBaseline: textBaseline - }; - } - - /** - * @inner - */ - function endTextLayout(opt, textPosition, extent) { - var rotationDiff = remRadian(-opt.rotation); - var textAlign; - var textBaseline; - var inverse = extent[0] > extent[1]; - var onLeft = (textPosition === 'start' && !inverse) - || (textPosition !== 'start' && inverse); - - if (isRadianAroundZero(rotationDiff - PI / 2)) { - textBaseline = onLeft ? 'bottom' : 'top'; - textAlign = 'center'; - } - else if (isRadianAroundZero(rotationDiff - PI * 1.5)) { - textBaseline = onLeft ? 'top' : 'bottom'; - textAlign = 'center'; - } - else { - textBaseline = 'middle'; - if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) { - textAlign = onLeft ? 'left' : 'right'; - } - else { - textAlign = onLeft ? 'right' : 'left'; - } - } - - return { - rotation: rotationDiff, - textAlign: textAlign, - textBaseline: textBaseline - }; - } - - /** - * @static - */ - var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (axis, i, interval) { - var rawTick; - var scale = axis.scale; - return scale.type === 'ordinal' - && ( - typeof interval === 'function' - ? ( - rawTick = scale.getTicks()[i], - !interval(rawTick, scale.getLabel(rawTick)) - ) - : i % (interval + 1) - ); - }; - - /** - * @static - */ - var getInterval = AxisBuilder.getInterval = function (model, labelInterval) { - var interval = model.get('interval'); - if (interval == null || interval == 'auto') { - interval = labelInterval; - } - return interval; - }; - - return AxisBuilder; - -}); -define('echarts/component/axis/AxisView',['require','zrender/core/util','../../util/graphic','./AxisBuilder','../../echarts'],function (require) { - - var zrUtil = require('zrender/core/util'); - var graphic = require('../../util/graphic'); - var AxisBuilder = require('./AxisBuilder'); - var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick; - var getInterval = AxisBuilder.getInterval; - - var axisBuilderAttrs = [ - 'axisLine', 'axisLabel', 'axisTick', 'axisName' - ]; - var selfBuilderAttrs = [ - 'splitLine', 'splitArea' - ]; - - var AxisView = require('../../echarts').extendComponentView({ - - type: 'axis', - - render: function (axisModel, ecModel) { - - this.group.removeAll(); - - if (!axisModel.get('show')) { - return; - } - - var gridModel = ecModel.getComponent('grid', axisModel.get('gridIndex')); - - var layout = layoutAxis(gridModel, axisModel); - - var axisBuilder = new AxisBuilder(axisModel, layout); - - zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder); - - this.group.add(axisBuilder.getGroup()); - - zrUtil.each(selfBuilderAttrs, function (name) { - if (axisModel.get(name +'.show')) { - this['_' + name](axisModel, gridModel, layout.labelInterval); - } - }, this); - }, - - /** - * @param {module:echarts/coord/cartesian/AxisModel} axisModel - * @param {module:echarts/coord/cartesian/GridModel} gridModel - * @param {number|Function} labelInterval - * @private - */ - _splitLine: function (axisModel, gridModel, labelInterval) { - var axis = axisModel.axis; - - var splitLineModel = axisModel.getModel('splitLine'); - var lineStyleModel = splitLineModel.getModel('lineStyle'); - var lineWidth = lineStyleModel.get('width'); - var lineColors = lineStyleModel.get('color'); - - var lineInterval = getInterval(splitLineModel, labelInterval); - - lineColors = lineColors instanceof Array ? lineColors : [lineColors]; - - var gridRect = gridModel.coordinateSystem.getRect(); - var isHorizontal = axis.isHorizontal(); - - var splitLines = []; - var lineCount = 0; - - var ticksCoords = axis.getTicksCoords(); - - var p1 = []; - var p2 = []; - for (var i = 0; i < ticksCoords.length; i++) { - if (ifIgnoreOnTick(axis, i, lineInterval)) { - continue; - } - - var tickCoord = axis.toGlobalCoord(ticksCoords[i]); - - if (isHorizontal) { - p1[0] = tickCoord; - p1[1] = gridRect.y; - p2[0] = tickCoord; - p2[1] = gridRect.y + gridRect.height; - } - else { - p1[0] = gridRect.x; - p1[1] = tickCoord; - p2[0] = gridRect.x + gridRect.width; - p2[1] = tickCoord; - } - - var colorIndex = (lineCount++) % lineColors.length; - splitLines[colorIndex] = splitLines[colorIndex] || []; - splitLines[colorIndex].push(new graphic.Line(graphic.subPixelOptimizeLine({ - shape: { - x1: p1[0], - y1: p1[1], - x2: p2[0], - y2: p2[1] - }, - style: { - lineWidth: lineWidth - }, - silent: true - }))); - } - - // Simple optimization - // Batching the lines if color are the same - for (var i = 0; i < splitLines.length; i++) { - this.group.add(graphic.mergePath(splitLines[i], { - style: { - stroke: lineColors[i % lineColors.length], - lineDash: lineStyleModel.getLineDash(), - lineWidth: lineWidth - }, - silent: true - })); - } - }, - - /** - * @param {module:echarts/coord/cartesian/AxisModel} axisModel - * @param {module:echarts/coord/cartesian/GridModel} gridModel - * @param {number|Function} labelInterval - * @private - */ - _splitArea: function (axisModel, gridModel, labelInterval) { - var axis = axisModel.axis; - - var splitAreaModel = axisModel.getModel('splitArea'); - var areaColors = splitAreaModel.get('areaStyle.color'); - - var gridRect = gridModel.coordinateSystem.getRect(); - var ticksCoords = axis.getTicksCoords(); - - var prevX = axis.toGlobalCoord(ticksCoords[0]); - var prevY = axis.toGlobalCoord(ticksCoords[0]); - - var splitAreaRects = []; - var count = 0; - - var areaInterval = getInterval(splitAreaModel, labelInterval); - - areaColors = areaColors instanceof Array ? areaColors : [areaColors]; - - for (var i = 1; i < ticksCoords.length; i++) { - if (ifIgnoreOnTick(axis, i, areaInterval)) { - continue; - } - - var tickCoord = axis.toGlobalCoord(ticksCoords[i]); - - var x; - var y; - var width; - var height; - if (axis.isHorizontal()) { - x = prevX; - y = gridRect.y; - width = tickCoord - x; - height = gridRect.height; - } - else { - x = gridRect.x; - y = prevY; - width = gridRect.width; - height = tickCoord - y; - } - - var colorIndex = (count++) % areaColors.length; - splitAreaRects[colorIndex] = splitAreaRects[colorIndex] || []; - splitAreaRects[colorIndex].push(new graphic.Rect({ - shape: { - x: x, - y: y, - width: width, - height: height - }, - silent: true - })); - - prevX = x + width; - prevY = y + height; - } - - // Simple optimization - // Batching the rects if color are the same - for (var i = 0; i < splitAreaRects.length; i++) { - this.group.add(graphic.mergePath(splitAreaRects[i], { - style: { - fill: areaColors[i % areaColors.length] - }, - silent: true - })); - } - } - }); - - AxisView.extend({ - type: 'xAxis' - }); - AxisView.extend({ - type: 'yAxis' - }); - - /** - * @inner - */ - function layoutAxis(gridModel, axisModel) { - var grid = gridModel.coordinateSystem; - var axis = axisModel.axis; - var layout = {}; - - var rawAxisPosition = axis.position; - var axisPosition = axis.onZero ? 'onZero' : rawAxisPosition; - var axisDim = axis.dim; - - // [left, right, top, bottom] - var rect = grid.getRect(); - var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height]; - - var posMap = { - x: {top: rectBound[2], bottom: rectBound[3]}, - y: {left: rectBound[0], right: rectBound[1]} - }; - posMap.x.onZero = Math.max(Math.min(getZero('y'), posMap.x.bottom), posMap.x.top); - posMap.y.onZero = Math.max(Math.min(getZero('x'), posMap.y.right), posMap.y.left); - - function getZero(dim, val) { - var theAxis = grid.getAxis(dim); - return theAxis.toGlobalCoord(theAxis.dataToCoord(0)); - } - - // Axis position - layout.position = [ - axisDim === 'y' ? posMap.y[axisPosition] : rectBound[0], - axisDim === 'x' ? posMap.x[axisPosition] : rectBound[3] - ]; - - // Axis rotation - var r = {x: 0, y: 1}; - layout.rotation = Math.PI / 2 * r[axisDim]; - - // Tick and label direction, x y is axisDim - var dirMap = {top: -1, bottom: 1, left: -1, right: 1}; - - layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition]; - if (axis.onZero) { - layout.labelOffset = posMap[axisDim][rawAxisPosition] - posMap[axisDim].onZero; - } - - if (axisModel.getModel('axisTick').get('inside')) { - layout.tickDirection = -layout.tickDirection; - } - if (axisModel.getModel('axisLabel').get('inside')) { - layout.labelDirection = -layout.labelDirection; - } - - // Special label rotation - var labelRotation = axisModel.getModel('axisLabel').get('rotate'); - layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation; - - // label interval when auto mode. - layout.labelInterval = axis.getLabelInterval(); - - // Over splitLine and splitArea - layout.z2 = 1; - - return layout; - } -}); -// TODO boundaryGap -define('echarts/component/axis',['require','../coord/cartesian/AxisModel','./axis/AxisView'],function(require) { - - - require('../coord/cartesian/AxisModel'); - - require('./axis/AxisView'); -}); -define('echarts/component/grid',['require','../util/graphic','zrender/core/util','../coord/cartesian/Grid','./axis','../echarts'],function(require) { - - - var graphic = require('../util/graphic'); - var zrUtil = require('zrender/core/util'); - - require('../coord/cartesian/Grid'); - - require('./axis'); - - // Grid view - require('../echarts').extendComponentView({ - - type: 'grid', - - render: function (gridModel, ecModel) { - this.group.removeAll(); - if (gridModel.get('show')) { - this.group.add(new graphic.Rect({ - shape:gridModel.coordinateSystem.getRect(), - style: zrUtil.defaults({ - fill: gridModel.get('backgroundColor') - }, gridModel.getItemStyle()), - silent: true - })); - } - } - }); -}); -var echarts = require('echarts'); - - -require("echarts/chart/line"); - -require("echarts/chart/bar"); - -require("echarts/chart/pie"); - -require("echarts/component/grid"); - - -return echarts; -})); +; \ No newline at end of file diff --git a/dist/echarts.simple.min.js b/dist/echarts.simple.min.js index 7dec0de519..676e746170 100644 --- a/dist/echarts.simple.min.js +++ b/dist/echarts.simple.min.js @@ -1,7 +1,24 @@ -!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():t.echarts=e()}(this,function(){var t,e;!function(){function i(t,e){if(!e)return t;if(0===t.indexOf(".")){var i=e.split("/"),n=t.split("/"),r=i.length-1,a=n.length,o=0,s=0;t:for(var u=0;a>u;u++)switch(n[u]){case"..":if(!(r>o))break t;o++,s++;break;case".":s++;break;default:break t}return i.length=r-o,n=n.slice(s),i.concat(n).join("/")}return t}function n(t){function e(e,o){if("string"==typeof e){var s=n[e];return s||(s=a(i(e,t)),n[e]=s),s}e instanceof Array&&(o=o||function(){},o.apply(this,r(e,o,t)))}var n={};return e}function r(e,n,r){for(var s=[],u=o[r],c=0,l=Math.min(e.length,n.length);l>c;c++){var h,f=i(e[c],r);switch(f){case"require":h=u&&u.require||t;break;case"exports":h=u.exports;break;case"module":h=u;break;default:h=a(f)}s.push(h)}return s}function a(t){var e=o[t];if(!e)throw new Error("No "+t);if(!e.defined){var i=e.factory,n=i.apply(this,r(e.deps||[],i,t));"undefined"!=typeof n&&(e.exports=n),e.defined=1}return e.exports}var o={};e=function(t,e,i){if(2===arguments.length&&(i=e,e=[],"function"!=typeof i)){var r=i;i=function(){return r}}o[t]={id:t,deps:e,factory:i,defined:0,exports:{},require:n(t)}},t=n("")}();var i="isHorizontal",n="getAxis",r="getExtent",a="category",o="getItemLayout",s="dimensions",u="registerVisualCoding",c="registerLayout",l="hostModel",h="itemStyle",f="eachSeriesByType",d="setItemVisual",p="setVisual",v="zlevel",m="updateProps",g="mouseout",y="mouseover",_="setShape",x="buildPath",b="closePath",w="moveTo",M="beginPath",S="contain",C="textBaseline",T="textAlign",L="eachItemGraphicEl",k="getItemGraphicEl",A="dataIndex",z="trigger",P="removeAll",D="traverse",I="remove",O="__dirty",B="refresh",R="ignore",E="animate",N="stopAnimation",F="animation",G="getLocalTransform",q="parent",V="transform",W="rotation",H="getBaseAxis",Z="coordinateSystem",X="getComponent",U="update",j="getHeight",Y="getWidth",Q="isString",$="splice",K="childAt",J="position",tt="isObject",et="getDataParams",it="getItemModel",nt="getName",rt="getRawIndex",at="getRawValue",ot="ordinal",st="getData",ut="seriesIndex",ct="normal",lt="emphasis",ht="radius",ft="option",dt="../util/clazz",pt="getFont",vt="getBoundingRect",mt="textStyle",gt="getModel",yt="ecModel",_t="defaults",xt="inside",bt="../core/util",wt="create",Mt="height",St="applyTransform",Ct="zrender/core/BoundingRect",Tt="zrender/core/matrix",Lt="undefined",kt="zrender/core/vector",At="opacity",zt="stroke",Pt="lineWidth",Dt="getShallow",It="getClass",Ot="enableClassManagement",Bt="inherits",Rt="extend",Et="enableClassExtend",Nt="isArray",Ft="toLowerCase",Gt="bottom",qt="middle",Vt="center",Wt="parsePercent",Ht="replace",Zt="function",Xt="concat",Ut="number",jt="string",Yt="indexOf",Qt="getContext",$t="canvas",Kt="length",Jt="filter",te="zrender/core/util",ee="prototype",ie="require";e("zrender/graphic/Gradient",[ie],function(t){var e=function(t){this.colorStops=t||[]};return e[ee]={constructor:e,addColorStop:function(t,e){this.colorStops.push({offset:t,color:e})}},e}),e(te,[ie,"../graphic/Gradient"],function(t){function e(t){if("object"==typeof t&&null!==t){var i=t;if(t instanceof Array){i=[];for(var n=0,r=t[Kt];r>n;n++)i[n]=e(t[n])}else if(!M(t)&&!S(t)){i={};for(var a in t)t.hasOwnProperty(a)&&(i[a]=e(t[a]))}return i}return t}function i(t,n,r){if(!w(n)||!w(t))return r?e(n):t;for(var a in n)if(n.hasOwnProperty(a)){var o=t[a],s=n[a];!w(s)||!w(o)||_(s)||_(o)||S(s)||S(o)||M(s)||M(o)?!r&&a in t||(t[a]=e(n[a],!0)):i(o,s,r)}return t}function n(t,e){for(var n=t[0],r=1,a=t[Kt];a>r;r++)n=i(n,t[r],e);return n}function r(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}function a(t,e,i){for(var n in e)e.hasOwnProperty(n)&&(i?null!=e[n]:null==t[n])&&(t[n]=e[n]);return t}function o(){return document.createElement($t)}function s(){return k||(k=N.createCanvas()[Qt]("2d")),k}function u(t,e){if(t){if(t[Yt])return t[Yt](e);for(var i=0,n=t[Kt];n>i;i++)if(t[i]===e)return i}return-1}function c(t,e){function i(){}var n=t[ee];i[ee]=e[ee],t[ee]=new i;for(var r in n)t[ee][r]=n[r];t[ee].constructor=t,t.superClass=e}function l(t,e,i){t=ee in t?t[ee]:t,e=ee in e?e[ee]:e,a(t,e,i)}function h(t){return t?typeof t==jt?!1:typeof t[Kt]==Ut:void 0}function f(t,e,i){if(t&&e)if(t.forEach&&t.forEach===I)t.forEach(e,i);else if(t[Kt]===+t[Kt])for(var n=0,r=t[Kt];r>n;n++)e.call(i,t[n],n,t);else for(var a in t)t.hasOwnProperty(a)&&e.call(i,t[a],a,t)}function d(t,e,i){if(t&&e){if(t.map&&t.map===R)return t.map(e,i);for(var n=[],r=0,a=t[Kt];a>r;r++)n.push(e.call(i,t[r],r,t));return n}}function p(t,e,i,n){if(t&&e){if(t.reduce&&t.reduce===E)return t.reduce(e,i,n);for(var r=0,a=t[Kt];a>r;r++)i=e.call(n,i,t[r],r,t);return i}}function v(t,e,i){if(t&&e){if(t[Jt]&&t[Jt]===O)return t[Jt](e,i);for(var n=[],r=0,a=t[Kt];a>r;r++)e.call(i,t[r],r,t)&&n.push(t[r]);return n}}function m(t,e,i){if(t&&e)for(var n=0,r=t[Kt];r>n;n++)if(e.call(i,t[n],n,t))return t[n]}function g(t,e){var i=B.call(arguments,2);return function(){return t.apply(e,i[Xt](B.call(arguments)))}}function y(t){var e=B.call(arguments,1);return function(){return t.apply(this,e[Xt](B.call(arguments)))}}function _(t){return"[object Array]"===P.call(t)}function x(t){return typeof t===Zt}function b(t){return"[object String]"===P.call(t)}function w(t){var e=typeof t;return e===Zt||!!t&&"object"==e}function M(t){return!!z[P.call(t)]||t instanceof A}function S(t){return t&&1===t.nodeType&&typeof t.nodeName==jt}function C(t){for(var e=0,i=arguments[Kt];i>e;e++)if(null!=arguments[e])return arguments[e]}function T(){return Function.call.apply(B,arguments)}function L(t,e){if(!t)throw new Error(e)}var k,A=t("../graphic/Gradient"),z={"[object Function]":1,"[object RegExp]":1,"[object Date]":1,"[object Error]":1,"[object CanvasGradient]":1},P=Object[ee].toString,D=Array[ee],I=D.forEach,O=D[Jt],B=D.slice,R=D.map,E=D.reduce,N={inherits:c,mixin:l,clone:e,merge:i,mergeAll:n,extend:r,defaults:a,getContext:s,createCanvas:o,indexOf:u,slice:T,find:m,isArrayLike:h,each:f,map:d,reduce:p,filter:v,bind:g,curry:y,isArray:_,isString:b,isObject:w,isFunction:x,isBuildInObject:M,isDom:S,retrieve:C,assert:L,noop:function(){}};return N}),e("echarts/util/number",[ie],function(t){function e(t){return t[Ht](/^\s+/,"")[Ht](/\s+$/,"")}var i={},n=1e-4;return i.linearMap=function(t,e,i,n){var r=e[1]-e[0];if(0===r)return(i[0]+i[1])/2;var a=(t-e[0])/r;return n&&(a=Math.min(Math.max(a,0),1)),a*(i[1]-i[0])+i[0]},i[Wt]=function(t,i){switch(t){case Vt:case qt:t="50%";break;case"left":case"top":t="0%";break;case"right":case Gt:t="100%"}return typeof t===jt?e(t).match(/%$/)?parseFloat(t)/100*i:parseFloat(t):null==t?NaN:+t},i.round=function(t){return+(+t).toFixed(12)},i.asc=function(t){return t.sort(function(t,e){return t-e}),t},i.getPrecision=function(t){for(var e=1,i=0;Math.round(t*e)/e!==t;)e*=10,i++;return i},i.getPixelPrecision=function(t,e){var i=Math.log,n=Math.LN10,r=Math.floor(i(t[1]-t[0])/n),a=Math.round(i(Math.abs(e[1]-e[0]))/n);return Math.max(-r+a,0)},i.MAX_SAFE_INTEGER=9007199254740991,i.remRadian=function(t){var e=2*Math.PI;return(t%e+e)%e},i.isRadianAroundZero=function(t){return t>-n&&n>t},i.parseDate=function(t){return t instanceof Date?t:new Date(typeof t===jt?t[Ht](/-/g,"/"):Math.round(t))},i}),e("echarts/util/format",[ie,te,"./number"],function(t){function e(t){return isNaN(t)?"-":(t=(t+"").split("."),t[0][Ht](/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,"$1,")+(t[Kt]>1?"."+t[1]:""))}function i(t){return t[Ft]()[Ht](/-(.)/g,function(t,e){return e.toUpperCase()})}function n(t){var e=t[Kt];return typeof t===Ut?[t,t,t,t]:2===e?[t[0],t[1],t[0],t[1]]:3===e?[t[0],t[1],t[2],t[1]]:t}function r(t){return String(t)[Ht](/&/g,"&")[Ht](//g,">")[Ht](/"/g,""")[Ht](/'/g,"'")}function a(t,e){return"{"+t+(null==e?"":e)+"}"}function o(t,e){c[Nt](e)||(e=[e]);var i=e[Kt];if(!i)return"";for(var n=e[0].$vars,r=0;rs;s++)for(var u=0;ut?"0"+t:t}var c=t(te),l=t("./number"),h=["a","b","c","d","e","f","g"];return{normalizeCssArray:n,addCommas:e,toCamelCase:i,encodeHTML:r,formatTpl:o,formatTime:s}}),e("echarts/util/clazz",[ie,te],function(t){function e(t,e){var i=n.slice(arguments,2);return this.superClass[ee][e].apply(t,i)}function i(t,e,i){return this.superClass[ee][e].apply(t,i)}var n=t(te),r={},a=".",o="___EC__COMPONENT__CONTAINER___",s=r.parseClassType=function(t){var e={main:"",sub:""};return t&&(t=t.split(a),e.main=t[0]||"",e.sub=t[1]||""),e};return r[Et]=function(t,r){t[Rt]=function(a){var o=function(){r&&r.apply(this,arguments),t.apply(this,arguments)};return n[Rt](o[ee],a),o[Rt]=this[Rt],o.superCall=e,o.superApply=i,n[Bt](o,this),o.superClass=this,o}},r[Ot]=function(t,e){function i(t){var e=r[t.main];return e&&e[o]||(e=r[t.main]={},e[o]=!0),e}e=e||{};var r={};if(t.registerClass=function(t,e){if(e)if(e=s(e),e.sub){if(e.sub!==o){var n=i(e);n[e.sub]=t}}else{if(r[e.main])throw new Error(e.main+"exists");r[e.main]=t}return t},t[It]=function(t,e,i){var n=r[t];if(n&&n[o]&&(n=e?n[e]:null),i&&!n)throw new Error("Component "+t+"."+(e||"")+" not exists");return n},t.getClassesByMainType=function(t){t=s(t);var e=[],i=r[t.main];return i&&i[o]?n.each(i,function(t,i){i!==o&&e.push(t)}):e.push(i),e},t.hasClass=function(t){return t=s(t),!!r[t.main]},t.getAllClassMainTypes=function(){var t=[];return n.each(r,function(e,i){t.push(i)}),t},t.hasSubTypes=function(t){t=s(t);var e=r[t.main];return e&&e[o]},t.parseClassType=s,e.registerWhenExtend){var a=t[Rt];a&&(t[Rt]=function(e){var i=a.call(this,e);return t.registerClass(i,e.type)})}return t},r.setReadOnly=function(t,e){},r}),e("echarts/model/mixin/makeStyleMapper",[ie,te],function(t){var e=t(te);return function(t){for(var i=0;i=0)){var o=this[Dt](a);null!=o&&(n[t[r][0]]=o)}}return n}}}),e("echarts/model/mixin/lineStyle",[ie,"./makeStyleMapper"],function(t){var e=t("./makeStyleMapper")([[Pt,"width"],[zt,"color"],[At],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]]);return{getLineStyle:function(t){var i=e.call(this,t),n=this.getLineDash();return n&&(i.lineDash=n),i},getLineDash:function(){var t=this.get("type");return"solid"===t||null==t?null:"dashed"===t?[5,5]:[1,1]}}}),e("echarts/model/mixin/areaStyle",[ie,"./makeStyleMapper"],function(t){return{getAreaStyle:t("./makeStyleMapper")([["fill","color"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],[At],["shadowColor"]])}}),e(kt,[],function(){var t=typeof Float32Array===Lt?Array:Float32Array,e={create:function(e,i){var n=new t(2);return n[0]=e||0,n[1]=i||0,n},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t},clone:function(e){var i=new t(2);return i[0]=e[0],i[1]=e[1],i},set:function(t,e,i){return t[0]=e,t[1]=i,t},add:function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t},scaleAndAdd:function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t},sub:function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t},len:function(t){return Math.sqrt(this.lenSquare(t))},lenSquare:function(t){return t[0]*t[0]+t[1]*t[1]},mul:function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t},div:function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},scale:function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},normalize:function(t,i){var n=e.len(i);return 0===n?(t[0]=0,t[1]=0):(t[0]=i[0]/n,t[1]=i[1]/n),t},distance:function(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))},distanceSquare:function(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])},negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},lerp:function(t,e,i,n){return t[0]=e[0]+n*(i[0]-e[0]),t[1]=e[1]+n*(i[1]-e[1]),t},applyTransform:function(t,e,i){var n=e[0],r=e[1];return t[0]=i[0]*n+i[2]*r+i[4],t[1]=i[1]*n+i[3]*r+i[5],t},min:function(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t},max:function(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t}};return e[Kt]=e.len,e.lengthSquare=e.lenSquare,e.dist=e.distance,e.distSquare=e.distanceSquare,e}),e(Tt,[],function(){var t=typeof Float32Array===Lt?Array:Float32Array,e={create:function(){var i=new t(6);return e.identity(i),i},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},mul:function(t,e,i){var n=e[0]*i[0]+e[2]*i[1],r=e[1]*i[0]+e[3]*i[1],a=e[0]*i[2]+e[2]*i[3],o=e[1]*i[2]+e[3]*i[3],s=e[0]*i[4]+e[2]*i[5]+e[4],u=e[1]*i[4]+e[3]*i[5]+e[5];return t[0]=n,t[1]=r,t[2]=a,t[3]=o,t[4]=s,t[5]=u,t},translate:function(t,e,i){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4]+i[0],t[5]=e[5]+i[1],t},rotate:function(t,e,i){var n=e[0],r=e[2],a=e[4],o=e[1],s=e[3],u=e[5],c=Math.sin(i),l=Math.cos(i);return t[0]=n*l+o*c,t[1]=-n*c+o*l,t[2]=r*l+s*c,t[3]=-r*c+l*s,t[4]=l*a+c*u,t[5]=l*u-c*a,t},scale:function(t,e,i){var n=i[0],r=i[1];return t[0]=e[0]*n,t[1]=e[1]*r,t[2]=e[2]*n,t[3]=e[3]*r,t[4]=e[4]*n,t[5]=e[5]*r,t},invert:function(t,e){var i=e[0],n=e[2],r=e[4],a=e[1],o=e[3],s=e[5],u=i*o-a*n;return u?(u=1/u,t[0]=o*u,t[1]=-a*u,t[2]=-n*u,t[3]=i*u,t[4]=(n*s-o*r)*u,t[5]=(a*r-i*s)*u,t):null}};return e}),e(Ct,[ie,"./vector","./matrix"],function(t){function e(t,e,i,n){this.x=t,this.y=e,this.width=i,this[Mt]=n}var i=t("./vector"),n=t("./matrix"),r=i[St],a=Math.min,o=Math.abs,s=Math.max;return e[ee]={constructor:e,union:function(t){var e=a(t.x,this.x),i=a(t.y,this.y);this.width=s(t.x+t.width,this.x+this.width)-e,this[Mt]=s(t.y+t[Mt],this.y+this[Mt])-i,this.x=e,this.y=i},applyTransform:function(){var t=[],e=[];return function(i){i&&(t[0]=this.x,t[1]=this.y,e[0]=this.x+this.width,e[1]=this.y+this[Mt],r(t,t,i),r(e,e,i),this.x=a(t[0],e[0]),this.y=a(t[1],e[1]),this.width=o(e[0]-t[0]),this[Mt]=o(e[1]-t[1]))}}(),calculateTransform:function(t){var e=this,i=t.width/e.width,r=t[Mt]/e[Mt],a=n[wt]();return n.translate(a,a,[-e.x,-e.y]),n.scale(a,a,[i,r]),n.translate(a,a,[t.x,t.y]),a},intersect:function(t){var e=this,i=e.x,n=e.x+e.width,r=e.y,a=e.y+e[Mt],o=t.x,s=t.x+t.width,u=t.y,c=t.y+t[Mt];return!(o>n||i>s||u>a||r>c)},contain:function(t,e){var i=this;return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i[Mt]},clone:function(){return new e(this.x,this.y,this.width,this[Mt])},copy:function(t){this.x=t.x,this.y=t.y,this.width=t.width,this[Mt]=t[Mt]}},e}),e("zrender/contain/text",[ie,bt,"../core/BoundingRect"],function(t){function e(t,e){var i=t+":"+e;if(s[i])return s[i];for(var n=(t+"").split("\n"),r=0,a=0,o=n[Kt];o>a;a++)r=Math.max(f.measureText(n[a],e).width,r);return u>c&&(u=0,s={}),u++,s[i]=r,r}function i(t,i,n,r){var a=((t||"")+"").split("\n")[Kt],o=e(t,i),s=e("国",i),u=a*s,c=new h(0,0,o,u);switch(c.lineHeight=s,r){case Gt:case"alphabetic":c.y-=s;break;case qt:c.y-=s/2}switch(n){case"end":case"right":c.x-=c.width;break;case Vt:c.x-=c.width/2}return c}function n(t,e,i,n){var r=e.x,a=e.y,o=e[Mt],s=e.width,u=i[Mt],c=o/2-u/2,l="left";switch(t){case"left":r-=n,a+=c,l="right";break;case"right":r+=n+s,a+=c,l="left";break;case"top":r+=s/2,a-=n+u,l=Vt;break;case Gt:r+=s/2,a+=o+n,l=Vt;break;case xt:r+=s/2,a+=c,l=Vt;break;case"insideLeft":r+=n,a+=c,l="left";break;case"insideRight":r+=s-n,a+=c,l="right";break;case"insideTop":r+=s/2,a+=n,l=Vt;break;case"insideBottom":r+=s/2,a+=o-u-n,l=Vt;break;case"insideTopLeft":r+=n,a+=n,l="left";break;case"insideTopRight":r+=s-n,a+=n,l="right";break;case"insideBottomLeft":r+=n,a+=o-u-n;break;case"insideBottomRight":r+=s-n,a+=o-u-n,l="right"}return{x:r,y:a,textAlign:l,textBaseline:"top"}}function r(t,i,n,r){if(!n)return"";r=l[_t]({ellipsis:"...",minCharacters:3,maxIterations:3,cnCharWidth:e("国",i),ascCharWidth:e("a",i)},r,!0),n-=e(r.ellipsis);for(var o=(t+"").split("\n"),s=0,u=o[Kt];u>s;s++)o[s]=a(o[s],i,n,r);return o.join("\n")}function a(t,i,n,r){for(var a=0;;a++){var s=e(t,i);if(n>s||a>=r.maxIterations){t+=r.ellipsis;break}var u=0===a?o(t,n,r):Math.floor(t[Kt]*n/s);if(ur&&e>n;r++){var o=t.charCodeAt(r);n+=o>=0&&127>=o?i.ascCharWidth:i.cnCharWidth}return r}var s={},u=0,c=5e3,l=t(bt),h=t("../core/BoundingRect"),f={getWidth:e,getBoundingRect:i,adjustTextPositionOnRect:n,ellipsis:r,measureText:function(t,e){var i=l[Qt]();return i.font=e,i.measureText(t)}};return f}),e("echarts/model/mixin/textStyle",[ie,"zrender/contain/text"],function(t){function e(t,e){return t&&t[Dt](e)}var i=t("zrender/contain/text");return{getTextColor:function(){var t=this[yt];return this[Dt]("color")||t&&t.get("textStyle.color")},getFont:function(){var t=this[yt],i=t&&t[gt](mt);return[this[Dt]("fontStyle")||e(i,"fontStyle"),this[Dt]("fontWeight")||e(i,"fontWeight"),(this[Dt]("fontSize")||e(i,"fontSize")||12)+"px",this[Dt]("fontFamily")||e(i,"fontFamily")||"sans-serif"].join(" ")},getTextRect:function(t){var e=this.get(mt)||{};return i[vt](t,this[pt](),e.align,e.baseline)},ellipsis:function(t,e,n){return i.ellipsis(t,this[pt](),e,n)}}}),e("echarts/model/mixin/itemStyle",[ie,"./makeStyleMapper"],function(t){return{getItemStyle:t("./makeStyleMapper")([["fill","color"],[zt,"borderColor"],[Pt,"borderWidth"],[At],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]])}}),e("echarts/model/Model",[ie,te,dt,"./mixin/lineStyle","./mixin/areaStyle","./mixin/textStyle","./mixin/itemStyle"],function(t){function e(t,e,i,n){this.parentModel=e,this[yt]=i,this[ft]=t,this.init&&(arguments[Kt]<=4?this.init(t,e,i,n):this.init.apply(this,arguments))}var i=t(te),n=t(dt);e[ee]={constructor:e,init:null,mergeOption:function(t){i.merge(this[ft],t,!0)},get:function(t,e){if(!t)return this[ft];typeof t===jt&&(t=t.split("."));for(var i=this[ft],n=this.parentModel,r=0;r=0}function a(t,r){var a=!1;return e(function(e){n.each(i(t,e)||[],function(t){r.records[e.name][t]&&(a=!0)})}),a}function o(t,r){r.nodes.push(t),e(function(e){n.each(i(t,e)||[],function(t){r.records[e.name][t]=!0})})}return function(i){function n(t){!r(t,s)&&a(t,s)&&(o(t,s),u=!0)}var s={nodes:[],records:{}};if(e(function(t){s.records[t.name]={}}),!i)return s;o(i,s);var u;do u=!1,t(n);while(u);return s}},o.defaultEmphasis=function(t,e){if(t){var i=t[lt]=t[lt]||{},r=t[ct]=t[ct]||{};n.each(e,function(t){var e=n.retrieve(i[t],r[t]);null!=e&&(i[t]=e)})}},o.createDataFormatModel=function(t,e,i){var a=new r;return n.mixin(a,o.dataFormatMixin),a[ut]=t[ut],a.name=t.name||"",a[st]=function(){return e},a.getRawDataArray=function(){return i},a},o.getDataItemValue=function(t){return t&&(null==t.value?t:t.value)},o.converDataValue=function(t,e){var n=e&&e.type;return n===ot?t:("time"!==n||isFinite(t)||null==t||"-"===t||(t=+i.parseDate(t)),null==t||""===t?NaN:+t)},o.dataFormatMixin={getDataParams:function(t){var e=this[st](),i=this[ut],n=this.name,r=this[at](t),a=e[rt](t),o=e[nt](t,!0),s=this.getRawDataArray(),u=s&&s[a];return{seriesIndex:i,seriesName:n,name:o,dataIndex:a,data:u,value:r,$vars:["seriesName","name","value"]}},getFormattedLabel:function(t,i,n){i=i||ct;var r=this[st](),a=r[it](t),o=this[et](t);return null==n&&(n=a.get(["label",i,"formatter"])),typeof n===Zt?(o.status=i,n(o)):typeof n===jt?e.formatTpl(n,o):void 0},getRawValue:function(t){var e=this[st]()[it](t);if(e&&null!=e[ft]){var i=e[ft];return n[tt](i)&&!n[Nt](i)?i.value:i}}},o.mappingToExists=function(t,e){e=(e||[]).slice();var i=n.map(t||[],function(t,e){return{exist:t}});return n.each(e,function(t,r){if(n[tt](t))for(var a=0;a=i[Kt]&&i.push({option:t})}}),i},o.isIdInner=function(t){return n[tt](t)&&t.id&&0===(t.id+"")[Yt]("\x00_ec_\x00")},o}),e("echarts/util/component",[ie,te,"./clazz"],function(t){var e=t(te),i=t("./clazz"),n=i.parseClassType,r=0,a={},o="_";return a.getUID=function(t){return[t||"",r++,Math.random()].join(o)},a.enableSubTypeDefaulter=function(t){var e={};return t.registerSubTypeDefaulter=function(t,i){t=n(t),e[t.main]=i},t.determineSubType=function(i,r){var a=r.type;if(!a){var o=n(i).main;t.hasSubTypes(i)&&e[o]&&(a=e[o](r))}return a},t},a.enableTopologicalTravel=function(t,i){function n(t){var n={},o=[];return e.each(t,function(s){var u=r(n,s),c=u.originalDeps=i(s),l=a(c,t);u.entryCount=l[Kt],0===u.entryCount&&o.push(s),e.each(l,function(t){e[Yt](u.predecessor,t)<0&&u.predecessor.push(t);var i=r(n,t);e[Yt](i.successor,t)<0&&i.successor.push(s)})}),{graph:n,noEntryList:o}}function r(t,e){return t[e]||(t[e]={predecessor:[],successor:[]}),t[e]}function a(t,i){var n=[];return e.each(t,function(t){e[Yt](i,t)>=0&&n.push(t)}),n}t.topologicalTravel=function(t,i,r,a){function o(t){c[t].entryCount--,0===c[t].entryCount&&l.push(t)}function s(t){h[t]=!0,o(t)}if(t[Kt]){var u=n(i),c=u.graph,l=u.noEntryList,h={};for(e.each(t,function(t){h[t]=!0});l[Kt];){var f=l.pop(),d=c[f],p=!!h[f];p&&(r.call(a,f,d.originalDeps.slice()),delete h[f]),e.each(d.successor,p?s:o)}e.each(h,function(){throw new Error("Circle dependency may exists")})}}},a}),e("echarts/util/layout",[ie,te,Ct,"./number","./format"],function(t){function e(t,e,i,n,r){var a=0,o=0;null==n&&(n=1/0),null==r&&(r=1/0);var s=0;e.eachChild(function(u,c){var l,h,f=u[J],d=u[vt](),p=e[K](c+1),v=p&&p[vt]();if("horizontal"===t){var m=d.width+(v?-v.x+d.x:0);l=a+m,l>n||u.newline?(a=0,l=m,o+=s+i,s=d[Mt]):s=Math.max(s,d[Mt])}else{var g=d[Mt]+(v?-v.y+d.y:0);h=o+g,h>r||u.newline?(a+=s+i,o=0,h=g,s=d.width):s=Math.max(s,d.width)}u.newline||(f[0]=a,f[1]=o,"horizontal"===t?a=l+i:o=h+i)})}var i=t(te),n=t(Ct),r=t("./number"),a=t("./format"),o=r[Wt],s=i.each,u={},c=["left","right","top",Gt,"width",Mt];return u.box=e,u.vbox=i.curry(e,"vertical"),u.hbox=i.curry(e,"horizontal"),u.getAvailableSize=function(t,e,i){var n=e.width,r=e[Mt],s=o(t.x,n),u=o(t.y,r),c=o(t.x2,n),l=o(t.y2,r);return(isNaN(s)||isNaN(parseFloat(t.x)))&&(s=0),(isNaN(c)||isNaN(parseFloat(t.x2)))&&(c=n),(isNaN(u)||isNaN(parseFloat(t.y)))&&(u=0),(isNaN(l)||isNaN(parseFloat(t.y2)))&&(l=r),i=a.normalizeCssArray(i||0),{width:Math.max(c-s-i[1]-i[3],0),height:Math.max(l-u-i[0]-i[2],0)}},u.getLayoutRect=function(t,e,i){i=a.normalizeCssArray(i||0);var r=e.width,s=e[Mt],u=o(t.left,r),c=o(t.top,s),l=o(t.right,r),h=o(t[Gt],s),f=o(t.width,r),d=o(t[Mt],s),p=i[2]+i[0],v=i[1]+i[3],m=t.aspect;switch(isNaN(f)&&(f=r-l-v-u),isNaN(d)&&(d=s-h-p-c),isNaN(f)&&isNaN(d)&&(m>r/s?f=.8*r:d=.8*s),null!=m&&(isNaN(f)&&(f=m*d),isNaN(d)&&(d=f/m)),isNaN(u)&&(u=r-l-f-v),isNaN(c)&&(c=s-h-d-p),t.left||t.right){case Vt:u=r/2-f/2-i[3];break;case"right":u=r-f-v}switch(t.top||t[Gt]){case qt:case Vt:c=s/2-d/2-i[0];break;case Gt:c=s-d-p}u=u||0,c=c||0,isNaN(f)&&(f=r-u-(l||0)),isNaN(d)&&(d=s-c-(h||0));var g=new n(u+i[3],c+i[0],f,d);return g.margin=i,g},u.positionGroup=function(t,e,n,r){var a=t[vt]();e=i[Rt](i.clone(e),{width:a.width,height:a[Mt]}),e=u.getLayoutRect(e,n,r),t[J]=[e.x-a.x,e.y-a.y]},u.mergeLayoutParam=function(t,e,n){function r(i){var r={},u=0,c={},l=0,h=n.ignoreSize?1:2;if(s(i,function(e){c[e]=t[e]}),s(i,function(t){a(e,t)&&(r[t]=c[t]=e[t]),o(r,t)&&u++,o(c,t)&&l++}),l!==h&&u){if(u>=h)return r;for(var f=0;f=0;a--)r=n.merge(r,t[a],!0);this.__defaultOption=r}return this.__defaultOption}});return o[Et](u,function(t,e,i,r){n[Rt](this,r),this.uid=a.getUID("componentModel"),this.setReadOnly(["type","id","uid","name","mainType","subType","dependentModels","componentIndex"])}),o[Ot](u,{registerWhenExtend:!0}),a.enableSubTypeDefaulter(u),a.enableTopologicalTravel(u,e),n.mixin(u,t("./mixin/boxLayout")),u}),e("echarts/model/globalDefault",[],function(){var t="";return typeof navigator!==Lt&&(t=navigator.platform||""),{color:["#c23531","#314656","#61a0a8","#dd8668","#91c7ae","#6e7074","#ca8622","#bda29a","#44525d","#c4ccd3"],grid:{},textStyle:{fontFamily:t.match(/^Win/)?"Microsoft YaHei":"sans-serif",fontSize:12,fontStyle:"normal",fontWeight:"normal"},animation:!0,animationThreshold:2e3,animationDuration:1e3,animationDurationUpdate:300,animationEasing:"exponentialOut",animationEasingUpdate:"cubicOut"}}),e("echarts/model/Global",[ie,te,"../util/model","./Model","./Component","./globalDefault"],function(t){function e(t,e){for(var i in e)y.hasClass(i)||("object"==typeof e[i]?t[i]=t[i]?c.merge(t[i],e[i],!1):c.clone(e[i]):t[i]=e[i])}function i(t){t=t,this[ft]={},this[ft][x]=1,this._componentsMap={},this._seriesIndices=null,e(t,this._theme[ft]),c.merge(t,_,!1),this.mergeOption(t)}function n(t,e){c[Nt](e)||(e=e?[e]:[]);var i={};return f(e,function(e){i[e]=(t[e]||[]).slice()}),i}function r(t,e){var i={};f(e,function(t,e){var n=t.exist;n&&(i[n.id]=t)}),f(e,function(e,n){var r=e[ft];if(c.assert(!r||null==r.id||!i[r.id]||i[r.id]===e,"id duplicates: "+(r&&r.id)),r&&null!=r.id&&(i[r.id]=e),g(r)){var o=a(t,r,e.exist);e.keyInfo={mainType:t,subType:o}}}),f(e,function(t,e){var n=t.exist,r=t[ft],a=t.keyInfo;if(g(r)){if(a.name=null!=r.name?r.name+"":n?n.name:"\x00-",n)a.id=n.id;else if(null!=r.id)a.id=r.id+"";else{var o=0;do a.id="\x00"+a.name+"\x00"+o++;while(i[a.id])}i[a.id]=t}})}function a(t,e,i){var n=e.type?e.type:i?i.subType:y.determineSubType(t,e);return n}function o(t){return p(t,function(t){return t.componentIndex})||[]}function s(t,e){return e.hasOwnProperty("subType")?d(t,function(t){return t.subType===e.subType}):t}function u(t){if(!t._seriesIndices)throw new Error("Series is not initialized. Please depends sereis.")}var c=t(te),l=t("../util/model"),h=t("./Model"),f=c.each,d=c[Jt],p=c.map,v=c[Nt],m=c[Yt],g=c[tt],y=t("./Component"),_=t("./globalDefault"),x="\x00_ec_inner",b=h[Rt]({constructor:b,init:function(t,e,i,n){i=i||{},this[ft]=null,this._theme=new h(i),this._optionManager=n},setOption:function(t,e){c.assert(!(x in t),"please use chart.getOption()"),this._optionManager.setOption(t,e),this.resetOption()},resetOption:function(t){var e=!1,n=this._optionManager;if(!t||"recreate"===t){var r=n.mountOption("recreate"===t);this[ft]&&"recreate"!==t?(this.restoreData(),this.mergeOption(r)):i.call(this,r),e=!0}if(("timeline"===t||"media"===t)&&this.restoreData(),!t||"recreate"===t||"timeline"===t){var a=n.getTimelineOption(this);a&&(this.mergeOption(a),e=!0)}if(!t||"recreate"===t||"media"===t){var o=n.getMediaOption(this,this._api);o[Kt]&&f(o,function(t){this.mergeOption(t,e=!0)},this)}return e},mergeOption:function(t){function e(e,s){var u=l.normalizeToArray(t[e]),h=l.mappingToExists(a[e],u);r(e,h);var d=n(a,s);i[e]=[],a[e]=[],f(h,function(t,n){var r=t.exist,o=t[ft];if(c.assert(g(o)||r,"Empty component definition"),o){var s=y[It](e,t.keyInfo.subType,!0);r&&r instanceof s?r.mergeOption(o,this):r=new s(o,this,this,c[Rt]({dependentModels:d,componentIndex:n},t.keyInfo))}else r.mergeOption({},this);a[e][n]=r,i[e][n]=r[ft]},this),"series"===e&&(this._seriesIndices=o(a.series))}var i=this[ft],a=this._componentsMap,s=[];f(t,function(t,e){null!=t&&(y.hasClass(e)?s.push(e):i[e]=null==i[e]?c.clone(t):c.merge(i[e],t,!0))}),y.topologicalTravel(s,y.getAllClassMainTypes(),e,this)},getOption:function(){var t=c.clone(this[ft]);return f(t,function(e,i){if(y.hasClass(i)){for(var e=l.normalizeToArray(e),n=e[Kt]-1;n>=0;n--)l.isIdInner(e[n])&&e[$](n,1);t[i]=e}}),delete t[x],t},getTheme:function(){return this._theme},getComponent:function(t,e){var i=this._componentsMap[t];return i?i[e||0]:void 0},queryComponents:function(t){var e=t.mainType;if(!e)return[];var i=t.index,n=t.id,r=t.name,a=this._componentsMap[e];if(!a||!a[Kt])return[];var o;if(null!=i)v(i)||(i=[i]),o=d(p(i,function(t){return a[t]}),function(t){return!!t});else if(null!=n){var u=v(n);o=d(a,function(t){return u&&m(n,t.id)>=0||!u&&t.id===n})}else if(null!=r){var c=v(r);o=d(a,function(t){return c&&m(r,t.name)>=0||!c&&t.name===r})}return s(o,t)},findComponents:function(t){function e(t){var e=r+"Index",i=r+"Id",n=r+"Name";return t&&(t.hasOwnProperty(e)||t.hasOwnProperty(i)||t.hasOwnProperty(n))?{mainType:r,index:t[e],id:t[i],name:t[n]}:null}function i(e){return t[Jt]?d(e,t[Jt]):e}var n=t.query,r=t.mainType,a=e(n),o=a?this.queryComponents(a):this._componentsMap[r];return i(s(o,t))},eachComponent:function(t,e,i){var n=this._componentsMap;if(typeof t===Zt)i=e,e=t,f(n,function(t,n){f(t,function(t,r){e.call(i,n,t,r)})});else if(c[Q](t))f(n[t],e,i);else if(g(t)){ -var r=this.findComponents(t);f(r,e,i)}},getSeriesByName:function(t){var e=this._componentsMap.series;return d(e,function(e){return e.name===t})},getSeriesByIndex:function(t){return this._componentsMap.series[t]},getSeriesByType:function(t){var e=this._componentsMap.series;return d(e,function(e){return e.subType===t})},getSeries:function(){return this._componentsMap.series.slice()},eachSeries:function(t,e){u(this),f(this._seriesIndices,function(i){var n=this._componentsMap.series[i];t.call(e,n,i)},this)},eachRawSeries:function(t,e){f(this._componentsMap.series,t,e)},eachSeriesByType:function(t,e,i){u(this),f(this._seriesIndices,function(n){var r=this._componentsMap.series[n];r.subType===t&&e.call(i,r,n)},this)},eachRawSeriesByType:function(t,e,i){return f(this.getSeriesByType(t),e,i)},isSeriesFiltered:function(t){return u(this),c[Yt](this._seriesIndices,t.componentIndex)<0},filterSeries:function(t,e){u(this);var i=d(this._componentsMap.series,t,e);this._seriesIndices=o(i)},restoreData:function(){var t=this._componentsMap;this._seriesIndices=o(t.series);var e=[];f(t,function(t,i){e.push(i)}),y.topologicalTravel(e,y.getAllClassMainTypes(),function(e,i){f(t[e],function(t){t.restoreData()})})}});return b}),e("echarts/ExtensionAPI",[ie,te],function(t){function e(t){i.each(n,function(e){this[e]=i.bind(t[e],t)},this)}var i=t(te),n=["getDom","getZr",Y,j,"dispatchAction","on","off","getDataURL","getConnectedDataURL",gt,"getOption"];return e}),e("echarts/CoordinateSystem",[ie],function(t){function e(){this._coordinateSystems=[]}var i={};return e[ee]={constructor:e,create:function(t,e){var n=[];for(var r in i){var a=i[r][wt](t,e);a&&(n=n[Xt](a))}this._coordinateSystems=n},update:function(t,e){for(var i=this._coordinateSystems,n=0;n=e:"max"===i?e>=t:t===e}function a(t,e){return t.join(",")===e.join(",")}function o(t,e){e=e||{},l(e,function(e,i){if(null!=e){var n=t[i];if(c.hasClass(i)){e=u.normalizeToArray(e),n=u.normalizeToArray(n);var r=u.mappingToExists(n,e);t[i]=f(r,function(t){return t[ft]&&t.exist?d(t.exist,t[ft],!0):t.exist||t[ft]})}else t[i]=d(n,e,!0)}})}var s=t(te),u=t("../util/model"),c=t("./Component"),l=s.each,h=s.clone,f=s.map,d=s.merge,p=/^(min|max)?(.+)$/;return e[ee]={constructor:e,setOption:function(t,e){t=h(t,!0);var n=this._optionBackup,r=this._newOptionBackup=i.call(this,t,e);n?(o(n.baseOption,r.baseOption),r.timelineOptions[Kt]&&(n.timelineOptions=r.timelineOptions),r.mediaList[Kt]&&(n.mediaList=r.mediaList),r.mediaDefault&&(n.mediaDefault=r.mediaDefault)):this._optionBackup=r},mountOption:function(t){var e=t?this._optionBackup:this._newOptionBackup;return this._timelineOptions=f(e.timelineOptions,h),this._mediaList=f(e.mediaList,h),this._mediaDefault=h(e.mediaDefault),this._currentMediaIndices=[],h(e.baseOption)},getTimelineOption:function(t){var e,i=this._timelineOptions;if(i[Kt]){var n=t[X]("timeline");n&&(e=h(i[n.getCurrentIndex()],!0))}return e},getMediaOption:function(t){var e=this._api[Y](),i=this._api[j](),r=this._mediaList,o=this._mediaDefault,s=[],u=[];if(!r[Kt]&&!o)return u;for(var c=0,l=r[Kt];l>c;c++)n(r[c].query,e,i)&&s.push(c);return!s[Kt]&&o&&(s=[-1]),s[Kt]&&!a(s,this._currentMediaIndices)&&(u=f(s,function(t){return h(-1===t?o[ft]:r[t][ft])})),this._currentMediaIndices=s,u}},e}),e("echarts/model/Series",[ie,te,"../util/format","../util/model","./Component"],function(t){var e=t(te),i=t("../util/format"),n=t("../util/model"),r=t("./Component"),a=i.encodeHTML,o=i.addCommas,s=r[Rt]({type:"series",seriesIndex:0,coordinateSystem:null,defaultOption:null,legendDataProvider:null,init:function(t,e,i,n){this[ut]=this.componentIndex,this.mergeDefaultAndTheme(t,i),this._dataBeforeProcessed=this.getInitialData(t,i),this._data=this._dataBeforeProcessed.cloneShallow()},mergeDefaultAndTheme:function(t,i){e.merge(t,i.getTheme().get(this.subType)),e.merge(t,this.getDefaultOption()),n.defaultEmphasis(t.label,[J,"show",mt,"distance","formatter"])},mergeOption:function(t,i){t=e.merge(this[ft],t,!0);var n=this.getInitialData(t,i);n&&(this._data=n,this._dataBeforeProcessed=n.cloneShallow())},getInitialData:function(){},getData:function(){return this._data},setData:function(t){this._data=t},getRawData:function(){return this._dataBeforeProcessed},getRawDataArray:function(){return this[ft].data},coordDimToDataDim:function(t){return[t]},dataDimToCoordDim:function(t){return t},getBaseAxis:function(){var t=this[Z];return t&&t[H]&&t[H]()},formatTooltip:function(t,i){var n=this._data,r=this[at](t),s=e[Nt](r)?e.map(r,o).join(", "):o(r),u=n[nt](t);return i?a(this.name)+" : "+s:a(this.name)+"
"+(u?a(u)+" : "+s:s)},restoreData:function(){this._data=this._dataBeforeProcessed.cloneShallow()}});return e.mixin(s,n.dataFormatMixin),s}),e("zrender/core/guid",[],function(){var t=2311;return function(){return"zr_"+t++}}),e("zrender/mixin/Eventful",[ie,bt],function(t){var e=Array[ee].slice,i=t(bt),n=i[Yt],r=function(){this._$handlers={}};return r[ee]={constructor:r,one:function(t,e,i){var r=this._$handlers;return e&&t?(r[t]||(r[t]=[]),n(r[t],t)>=0?this:(r[t].push({h:e,one:!0,ctx:i||this}),this)):this},on:function(t,e,i){var n=this._$handlers;return e&&t?(n[t]||(n[t]=[]),n[t].push({h:e,one:!1,ctx:i||this}),this):this},isSilent:function(t){var e=this._$handlers;return e[t]&&e[t][Kt]},off:function(t,e){var i=this._$handlers;if(!t)return this._$handlers={},this;if(e){if(i[t]){for(var n=[],r=0,a=i[t][Kt];a>r;r++)i[t][r].h!=e&&n.push(i[t][r]);i[t]=n}i[t]&&0===i[t][Kt]&&delete i[t]}else delete i[t];return this},trigger:function(t){if(this._$handlers[t]){var i=arguments,n=i[Kt];n>3&&(i=e.call(i,1));for(var r=this._$handlers[t],a=r[Kt],o=0;a>o;){switch(n){case 1:r[o].h.call(r[o].ctx);break;case 2:r[o].h.call(r[o].ctx,i[1]);break;case 3:r[o].h.call(r[o].ctx,i[1],i[2]);break;default:r[o].h.apply(r[o].ctx,i)}r[o].one?(r[$](o,1),a--):o++}}return this},triggerWithContext:function(t){if(this._$handlers[t]){var i=arguments,n=i[Kt];n>4&&(i=e.call(i,1,i[Kt]-1));for(var r=i[i[Kt]-1],a=this._$handlers[t],o=a[Kt],s=0;o>s;){switch(n){case 1:a[s].h.call(r);break;case 2:a[s].h.call(r,i[1]);break;case 3:a[s].h.call(r,i[1],i[2]);break;default:a[s].h.apply(r,i)}a[s].one?(a[$](s,1),o--):s++}}return this}},r}),e("zrender/mixin/Transformable",[ie,"../core/matrix","../core/vector"],function(t){function e(t){return t>a||-a>t}var i=t("../core/matrix"),n=t("../core/vector"),r=i.identity,a=5e-5,o=function(t){t=t||{},t[J]||(this[J]=[0,0]),null==t[W]&&(this[W]=0),t.scale||(this.scale=[1,1]),this.origin=this.origin||null},s=o[ee];s[V]=null,s.needLocalTransform=function(){return e(this[W])||e(this[J][0])||e(this[J][1])||e(this.scale[0]-1)||e(this.scale[1]-1)},s.updateTransform=function(){var t=this[q],e=t&&t[V],n=this.needLocalTransform(),a=this[V];return n||e?(a=a||i[wt](),n?this[G](a):r(a),e&&(n?i.mul(a,t[V],a):i.copy(a,t[V])),this[V]=a,this.invTransform=this.invTransform||i[wt](),void i.invert(this.invTransform,a)):void(a&&r(a))},s[G]=function(t){t=t||[],r(t);var e=this.origin,n=this.scale,a=this[W],o=this[J];return e&&(t[4]-=e[0],t[5]-=e[1]),i.scale(t,t,n),a&&i.rotate(t,t,a),e&&(t[4]+=e[0],t[5]+=e[1]),t[4]+=o[0],t[5]+=o[1],t},s.setTransform=function(t){var e=this[V];e&&t[V](e[0],e[1],e[2],e[3],e[4],e[5])};var u=[];return s.decomposeTransform=function(){if(this[V]){var t=this[q],n=this[V];t&&t[V]&&(i.mul(u,t.invTransform,n),n=u);var r=n[0]*n[0]+n[1]*n[1],a=n[2]*n[2]+n[3]*n[3],o=this[J],s=this.scale;e(r-1)&&(r=Math.sqrt(r)),e(a-1)&&(a=Math.sqrt(a)),n[0]<0&&(r=-r),n[3]<0&&(a=-a),o[0]=n[4],o[1]=n[5],s[0]=r,s[1]=a,this[W]=Math.atan2(-n[1]/a,n[0]/r)}},s.transformCoordToLocal=function(t,e){var i=[t,e],r=this.invTransform;return r&&n[St](i,i,r),i},s.transformCoordToGlobal=function(t,e){var i=[t,e],r=this[V];return r&&n[St](i,i,r),i},o}),e("zrender/animation/easing",[],function(){var t={linear:function(t){return t},quadraticIn:function(t){return t*t},quadraticOut:function(t){return t*(2-t)},quadraticInOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},cubicIn:function(t){return t*t*t},cubicOut:function(t){return--t*t*t+1},cubicInOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},quarticIn:function(t){return t*t*t*t},quarticOut:function(t){return 1- --t*t*t*t},quarticInOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},quinticIn:function(t){return t*t*t*t*t},quinticOut:function(t){return--t*t*t*t*t+1},quinticInOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},sinusoidalIn:function(t){return 1-Math.cos(t*Math.PI/2)},sinusoidalOut:function(t){return Math.sin(t*Math.PI/2)},sinusoidalInOut:function(t){return.5*(1-Math.cos(Math.PI*t))},exponentialIn:function(t){return 0===t?0:Math.pow(1024,t-1)},exponentialOut:function(t){return 1===t?1:1-Math.pow(2,-10*t)},exponentialInOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(2,-10*(t-1))+2)},circularIn:function(t){return 1-Math.sqrt(1-t*t)},circularOut:function(t){return Math.sqrt(1- --t*t)},circularInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},elasticIn:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),-(i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)))},elasticOut:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/n)+1)},elasticInOut:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||1>i?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),(t*=2)<1?-.5*(i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)):i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)*.5+1)},backIn:function(t){var e=1.70158;return t*t*((e+1)*t-e)},backOut:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},backInOut:function(t){var e=2.5949095;return(t*=2)<1?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+2)},bounceIn:function(e){return 1-t.bounceOut(1-e)},bounceOut:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},bounceInOut:function(e){return.5>e?.5*t.bounceIn(2*e):.5*t.bounceOut(2*e-1)+.5}};return t}),e("zrender/animation/Clip",[ie,"./easing"],function(t){function e(t){this._target=t.target,this._life=t.life||1e3,this._delay=t.delay||0,this._initialized=!1,this.loop=null==t.loop?!1:t.loop,this.gap=t.gap||0,this.easing=t.easing||"Linear",this.onframe=t.onframe,this.ondestroy=t.ondestroy,this.onrestart=t.onrestart}var i=t("./easing");return e[ee]={constructor:e,step:function(t){this._initialized||(this._startTime=(new Date).getTime()+this._delay,this._initialized=!0);var e=(t-this._startTime)/this._life;if(!(0>e)){e=Math.min(e,1);var n=this.easing,r=typeof n==jt?i[n]:n,a=typeof r===Zt?r(e):e;return this.fire("frame",a),1==e?this.loop?(this.restart(),"restart"):(this._needsRemove=!0,"destroy"):null}},restart:function(){var t=(new Date).getTime(),e=(t-this._startTime)%this._life;this._startTime=(new Date).getTime()-e+this.gap,this._needsRemove=!1},fire:function(t,e){t="on"+t,this[t]&&this[t](this._target,e)}},e}),e("zrender/tool/color",[ie],function(t){function e(t){return t=Math.round(t),0>t?0:t>255?255:t}function i(t){return t=Math.round(t),0>t?0:t>360?360:t}function n(t){return 0>t?0:t>1?1:t}function r(t){return e(t[Kt]&&"%"===t.charAt(t[Kt]-1)?parseFloat(t)/100*255:parseInt(t,10))}function a(t){return n(t[Kt]&&"%"===t.charAt(t[Kt]-1)?parseFloat(t)/100:parseFloat(t))}function o(t,e,i){return 0>i?i+=1:i>1&&(i-=1),1>6*i?t+(e-t)*i*6:1>2*i?e:2>3*i?t+(e-t)*(2/3-i)*6:t}function s(t,e,i){return t+(e-t)*i}function u(t){if(t){t+="";var e=t[Ht](/ /g,"")[Ft]();if(e in _)return _[e].slice();if("#"!==e.charAt(0)){var i=e[Yt]("("),n=e[Yt](")");if(-1!==i&&n+1===e[Kt]){var o=e.substr(0,i),s=e.substr(i+1,n-(i+1)).split(","),u=1;switch(o){case"rgba":if(4!==s[Kt])return;u=a(s.pop());case"rgb":if(3!==s[Kt])return;return[r(s[0]),r(s[1]),r(s[2]),u];case"hsla":if(4!==s[Kt])return;return s[3]=a(s[3]),c(s);case"hsl":if(3!==s[Kt])return;return c(s);default:return}}}else{if(4===e[Kt]){var l=parseInt(e.substr(1),16);if(!(l>=0&&4095>=l))return;return[(3840&l)>>4|(3840&l)>>8,240&l|(240&l)>>4,15&l|(15&l)<<4,1]}if(7===e[Kt]){var l=parseInt(e.substr(1),16);if(!(l>=0&&16777215>=l))return;return[(16711680&l)>>16,(65280&l)>>8,255&l,1]}}}}function c(t){var i=(parseFloat(t[0])%360+360)%360/360,n=a(t[1]),r=a(t[2]),s=.5>=r?r*(n+1):r+n-r*n,u=2*r-s,c=[e(255*o(u,s,i+1/3)),e(255*o(u,s,i)),e(255*o(u,s,i-1/3))];return 4===t[Kt]&&(c[3]=t[3]),c}function l(t){if(t){var e,i,n=t[0]/255,r=t[1]/255,a=t[2]/255,o=Math.min(n,r,a),s=Math.max(n,r,a),u=s-o,c=(s+o)/2;if(0===u)e=0,i=0;else{i=.5>c?u/(s+o):u/(2-s-o);var l=((s-n)/6+u/2)/u,h=((s-r)/6+u/2)/u,f=((s-a)/6+u/2)/u;n===s?e=f-h:r===s?e=1/3+l-f:a===s&&(e=2/3+h-l),0>e&&(e+=1),e>1&&(e-=1)}var d=[360*e,i,c];return null!=t[3]&&d.push(t[3]),d}}function h(t,e){var i=u(t);if(i){for(var n=0;3>n;n++)0>e?i[n]=i[n]*(1-e)|0:i[n]=(255-i[n])*e+i[n]|0;return y(i,4===i[Kt]?"rgba":"rgb")}}function f(t,e){var i=u(t);return i?((1<<24)+(i[0]<<16)+(i[1]<<8)+ +i[2]).toString(16).slice(1):void 0}function d(t,i,n){if(i&&i[Kt]&&t>=0&&1>=t){n=n||[0,0,0,0];var r=t*(i[Kt]-1),a=Math.floor(r),o=Math.ceil(r),u=i[a],c=i[o],l=r-a;return n[0]=e(s(u[0],c[0],l)),n[1]=e(s(u[1],c[1],l)),n[2]=e(s(u[2],c[2],l)),n[3]=e(s(u[3],c[3],l)),n}}function p(t,i,r){if(i&&i[Kt]&&t>=0&&1>=t){var a=t*(i[Kt]-1),o=Math.floor(a),c=Math.ceil(a),l=u(i[o]),h=u(i[c]),f=a-o,d=y([e(s(l[0],h[0],f)),e(s(l[1],h[1],f)),e(s(l[2],h[2],f)),n(s(l[3],h[3],f))],"rgba");return r?{color:d,leftIndex:o,rightIndex:c,value:a}:d}}function v(t,e){if(!(2!==t[Kt]||t[1]0&&s>=u;u++)r.push({color:e[u],offset:(u-i.value)/a});return r.push({color:n.color,offset:1}),r}}function m(t,e,n,r){return t=u(t),t?(t=l(t),null!=e&&(t[0]=i(e)),null!=n&&(t[1]=a(n)),null!=r&&(t[2]=a(r)),y(c(t),"rgba")):void 0}function g(t,e){return t=u(t),t&&null!=e?(t[3]=n(e),y(t,"rgba")):void 0}function y(t,e){return("rgb"===e||"hsv"===e||"hsl"===e)&&(t=t.slice(0,3)),e+"("+t.join(",")+")"}var _={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};return{parse:u,lift:h,toHex:f,fastMapToColor:d,mapToColor:p,mapIntervalToColor:v,modifyHSL:m,modifyAlpha:g,stringify:y}}),e("zrender/animation/Animator",[ie,"./Clip","../tool/color",bt],function(t){function e(t,e){return t[e]}function i(t,e,i){t[e]=i}function n(t,e,i){return(e-t)*i+t}function r(t,e,i){return i>.5?e:t}function a(t,e,i,r,a){var o=t[Kt];if(1==a)for(var s=0;o>s;s++)r[s]=n(t[s],e[s],i);else for(var u=t[0][Kt],s=0;o>s;s++)for(var c=0;u>c;c++)r[s][c]=n(t[s][c],e[s][c],i)}function o(t,e,i){var n=t[Kt],r=e[Kt];if(n!==r){var a=n>r;if(a)t[Kt]=r;else for(var o=n;r>o;o++)t.push(1===i?e[o]:g.call(e[o]))}}function s(t,e,i){if(t===e)return!0;var n=t[Kt];if(n!==e[Kt])return!1;if(1===i){for(var r=0;n>r;r++)if(t[r]!==e[r])return!1}else for(var a=t[0][Kt],r=0;n>r;r++)for(var o=0;a>o;o++)if(t[r][o]!==e[r][o])return!1;return!0}function u(t,e,i,n,r,a,o,s,u){var l=t[Kt];if(1==u)for(var h=0;l>h;h++)s[h]=c(t[h],e[h],i[h],n[h],r,a,o);else for(var f=t[0][Kt],h=0;l>h;h++)for(var d=0;f>d;d++)s[h][d]=c(t[h][d],e[h][d],i[h][d],n[h][d],r,a,o)}function c(t,e,i,n,r,a,o){var s=.5*(i-t),u=.5*(n-e);return(2*(e-i)+s+u)*o+(-3*(e-i)-2*s-u)*a+s*r+e}function l(t){if(m(t)){var e=t[Kt];if(m(t[0])){for(var i=[],n=0;e>n;n++)i.push(g.call(t[n]));return i}return g.call(t)}return t}function h(t){return t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.floor(t[2]),"rgba("+t.join(",")+")"}function f(t,e,i,l,f){var v=t._getter,g=t._setter,y="spline"===e,_=l[Kt];if(_){var x,b=l[0].value,w=m(b),M=!1,S=!1,C=w&&m(b[0])?2:1;l.sort(function(t,e){return t.time-e.time}),x=l[_-1].time;for(var T=[],L=[],k=l[0].value,A=!0,z=0;_>z;z++){T.push(l[z].time/x);var P=l[z].value;if(w&&s(P,k,C)||!w&&P===k||(A=!1),k=P,typeof P==jt){var D=p.parse(P);D?(P=D,M=!0):S=!0}L.push(P)}if(!A){if(w){for(var I=L[_-1],z=0;_-1>z;z++)o(L[z],I,C);o(v(t._target,f),I,C)}var O,B,R,E,N,F,G=0,q=0;if(M)var V=[0,0,0,0];var W=function(t,e){var i;if(q>e){for(O=Math.min(G+1,_-1),i=O;i>=0&&!(T[i]<=e);i--);i=Math.min(i,_-2)}else{for(i=G;_>i&&!(T[i]>e);i++);i=Math.min(i-1,_-2)}G=i,q=e;var o=T[i+1]-T[i];if(0!==o)if(B=(e-T[i])/o,y)if(E=L[i],R=L[0===i?i:i-1],N=L[i>_-2?_-1:i+1],F=L[i>_-3?_-1:i+2],w)u(R,E,N,F,B,B*B,B*B*B,v(t,f),C);else{var s;if(M)s=u(R,E,N,F,B,B*B,B*B*B,V,1),s=h(V);else{if(S)return r(E,N,B);s=c(R,E,N,F,B,B*B,B*B*B)}g(t,f,s)}else if(w)a(L[i],L[i+1],B,v(t,f),C);else{var s;if(M)a(L[i],L[i+1],B,V,1),s=h(V);else{if(S)return r(L[i],L[i+1],B);s=n(L[i],L[i+1],B)}g(t,f,s)}},H=new d({target:t._target,life:x,loop:t._loop,delay:t._delay,onframe:W,ondestroy:i});return e&&"spline"!==e&&(H.easing=e),H}}}var d=t("./Clip"),p=t("../tool/color"),v=t(bt),m=v.isArrayLike,g=Array[ee].slice,y=function(t,n,r,a){this._tracks={},this._target=t,this._loop=n||!1,this._getter=r||e,this._setter=a||i,this._clipCount=0,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]};return y[ee]={when:function(t,e){var i=this._tracks;for(var n in e){if(!i[n]){i[n]=[];var r=this._getter(this._target,n);if(null==r)continue;0!==t&&i[n].push({time:0,value:l(r)})}i[n].push({time:t,value:e[n]})}return this},during:function(t){return this._onframeList.push(t),this},_doneCallback:function(){this._tracks={},this._clipList[Kt]=0;for(var t=this._doneList,e=t[Kt],i=0;e>i;i++)t[i].call(this)},start:function(t){var e,i=this,n=0,r=function(){n--,n||i._doneCallback()};for(var a in this._tracks){var o=f(this,t,r,this._tracks[a],a);o&&(this._clipList.push(o),n++,this[F]&&this[F].addClip(o),e=o)}if(e){var s=e.onframe;e.onframe=function(t,e){s(t,e);for(var n=0;n1)for(var t in arguments)console.log(arguments[t])}}),e("zrender/mixin/Animatable",[ie,"../animation/Animator",bt,"../core/log"],function(t){var e=t("../animation/Animator"),i=t(bt),n=i[Q],r=i.isFunction,a=i[tt],o=t("../core/log"),s=function(){this.animators=[]};return s[ee]={constructor:s,animate:function(t,n){var r,a=!1,s=this,u=this.__zr;if(t){var c=t.split("."),l=s;a="shape"===c[0];for(var h=0,f=c[Kt];f>h;h++)l&&(l=l[c[h]]);l&&(r=l)}else r=s;if(!r)return void o('Property "'+t+'" is not existed in element '+s.id);var d=s.animators,p=new e(r,n);return p.during(function(t){s.dirty(a)}).done(function(){d[$](i[Yt](d,p),1)}),d.push(p),u&&u[F].addAnimator(p),p},stopAnimation:function(t){for(var e=this.animators,i=e[Kt],n=0;i>n;n++)e[n].stop(t);return e[Kt]=0,this},animateTo:function(t,e,i,a,o){function s(){c--,c||o&&o()}n(i)?(o=a,a=i,i=0):r(a)?(o=a,a="linear",i=0):r(i)?(o=i,i=0):r(e)?(o=e,e=500):e||(e=500),this[N](),this._animateToShallow("",this,t,e,i,a,o);var u=this.animators.slice(),c=u[Kt];c||o&&o();for(var l=0;l0&&this[E](t,!1).when(null==r?500:r,s).delay(o||0),this}},s}),e("zrender/Element",[ie,"./core/guid","./mixin/Eventful","./mixin/Transformable","./mixin/Animatable","./core/util"],function(t){var e=t("./core/guid"),i=t("./mixin/Eventful"),n=t("./mixin/Transformable"),r=t("./mixin/Animatable"),a=t("./core/util"),o=function(t){n.call(this,t),i.call(this,t),r.call(this,t),this.id=t.id||e()};return o[ee]={type:"element",name:"",__zr:null,ignore:!1,clipPath:null,drift:function(t,e){switch(this.draggable){case"horizontal":e=0;break;case"vertical":t=0}var i=this[V];i||(i=this[V]=[1,0,0,1,0,0]),i[4]+=t,i[5]+=e,this.decomposeTransform(),this.dirty()},beforeUpdate:function(){},afterUpdate:function(){},update:function(){this.updateTransform()},traverse:function(t,e){},attrKV:function(t,e){if(t===J||"scale"===t||"origin"===t){if(e){var i=this[t];i||(i=this[t]=[]),i[0]=e[0],i[1]=e[1]}}else this[t]=e},hide:function(){this[R]=!0,this.__zr&&this.__zr[B]()},show:function(){this[R]=!1,this.__zr&&this.__zr[B]()},attr:function(t,e){if(typeof t===jt)this.attrKV(t,e);else if(a[tt](t))for(var i in t)t.hasOwnProperty(i)&&this.attrKV(i,t[i]);return this.dirty(),this},setClipPath:function(t){var e=this.__zr;e&&t.addSelfToZr(e),this.clipPath&&this.clipPath!==t&&this.removeClipPath(),this.clipPath=t,t.__zr=e,t.__clipTarget=this,this.dirty()},removeClipPath:function(){var t=this.clipPath;t&&(t.__zr&&t.removeSelfFromZr(t.__zr),t.__zr=null,t.__clipTarget=null,this.clipPath=null,this.dirty())},addSelfToZr:function(t){this.__zr=t;var e=this.animators;if(e)for(var i=0;i=0&&(i[$](n,0,t),this._doAdd(t))}return this},_doAdd:function(t){t[q]&&t[q][I](t),t[q]=this;var e=this.__storage,i=this.__zr;e&&e!==t.__storage&&(e.addToMap(t),t instanceof r&&t.addChildrenToStorage(e)),i&&i[B]()},remove:function(t){var i=this.__zr,n=this.__storage,a=this._children,o=e[Yt](a,t);return 0>o?this:(a[$](o,1),t[q]=null,n&&(n.delFromMap(t.id),t instanceof r&&t.delChildrenFromStorage(n)),i&&i[B](),this)},removeAll:function(){var t,e,i=this._children,n=this.__storage;for(e=0;e=0?parseFloat(t)/100*e:parseFloat(t):t}function i(t,e){t[V](e[0],e[1],e[2],e[3],e[4],e[5])}var n=t("../../contain/text"),r=t("../../core/BoundingRect"),a=new r,o=function(){};return o[ee]={constructor:o,drawRectText:function(t,r,o){var s=this.style,u=s.text;if(null!=u&&(u+=""),u){var c,l,h=s.textPosition,f=s.textDistance,d=s[T],p=s.textFont||s.font,v=s[C];o=o||n[vt](u,p,d,v);var m=this[V],g=this.invTransform;if(m&&(a.copy(r),a[St](m),r=a,i(t,g)),h instanceof Array)c=r.x+e(h[0],r.width),l=r.y+e(h[1],r[Mt]),d=d||"left",v=v||"top";else{var y=n.adjustTextPositionOnRect(h,r,o,f);c=y.x,l=y.y,d=d||y[T],v=v||y[C]}t[T]=d,t[C]=v;var _=s.textFill,x=s.textStroke;_&&(t.fillStyle=_),x&&(t.strokeStyle=x),t.font=p,t.shadowColor=s.textShadowColor,t.shadowBlur=s.textShadowBlur,t.shadowOffsetX=s.textShadowOffsetX,t.shadowOffsetY=s.textShadowOffsetY;for(var b=u.split("\n"),w=0;w-x&&x>t}function i(t){return t>x||-x>t}function n(t,e,i,n,r){var a=1-r;return a*a*(a*t+3*r*e)+r*r*(r*n+3*a*i)}function r(t,e,i,n,r){var a=1-r;return 3*(((e-t)*a+2*(i-e)*r)*a+(n-i)*r*r)}function a(t,i,n,r,a,o){var s=r+3*(i-n)-t,u=3*(n-2*i+t),c=3*(i-t),l=t-a,h=u*u-3*s*c,f=u*c-9*s*l,d=c*c-3*u*l,p=0;if(e(h)&&e(f))if(e(u))o[0]=0;else{var v=-c/u;v>=0&&1>=v&&(o[p++]=v)}else{var m=f*f-4*h*d;if(e(m)){var g=f/h,v=-u/s+g,x=-g/2;v>=0&&1>=v&&(o[p++]=v),x>=0&&1>=x&&(o[p++]=x)}else if(m>0){var M=_(m),S=h*u+1.5*s*(-f+M),C=h*u+1.5*s*(-f-M);S=0>S?-y(-S,w):y(S,w),C=0>C?-y(-C,w):y(C,w);var v=(-u-(S+C))/(3*s);v>=0&&1>=v&&(o[p++]=v)}else{var T=(2*h*u-3*s*f)/(2*_(h*h*h)),L=Math.acos(T)/3,k=_(h),A=Math.cos(L),v=(-u-2*k*A)/(3*s),x=(-u+k*(A+b*Math.sin(L)))/(3*s),z=(-u+k*(A-b*Math.sin(L)))/(3*s);v>=0&&1>=v&&(o[p++]=v),x>=0&&1>=x&&(o[p++]=x),z>=0&&1>=z&&(o[p++]=z)}}return p}function o(t,n,r,a,o){var s=6*r-12*n+6*t,u=9*n+3*a-3*t-9*r,c=3*n-3*t,l=0;if(e(u)){if(i(s)){var h=-c/s;h>=0&&1>=h&&(o[l++]=h)}}else{var f=s*s-4*u*c;if(e(f))o[0]=-s/(2*u);else if(f>0){var d=_(f),h=(-s+d)/(2*u),p=(-s-d)/(2*u);h>=0&&1>=h&&(o[l++]=h),p>=0&&1>=p&&(o[l++]=p)}}return l}function s(t,e,i,n,r,a){var o=(e-t)*r+t,s=(i-e)*r+e,u=(n-i)*r+i,c=(s-o)*r+o,l=(u-s)*r+s,h=(l-c)*r+c;a[0]=t,a[1]=o,a[2]=c,a[3]=h,a[4]=h,a[5]=l,a[6]=u,a[7]=n}function u(t,e,i,r,a,o,s,u,c,l,h){var f,d,p,v,m,y=.005,b=1/0;M[0]=c,M[1]=l;for(var w=0;1>w;w+=.05)S[0]=n(t,i,a,s,w),S[1]=n(e,r,o,u,w),v=g(M,S),b>v&&(f=w,b=v);b=1/0;for(var T=0;32>T&&!(x>y);T++)d=f-y,p=f+y,S[0]=n(t,i,a,s,d),S[1]=n(e,r,o,u,d),v=g(S,M),d>=0&&b>v?(f=d,b=v):(C[0]=n(t,i,a,s,p),C[1]=n(e,r,o,u,p),m=g(C,M),1>=p&&b>m?(f=p,b=m):y*=.5);return h&&(h[0]=n(t,i,a,s,f),h[1]=n(e,r,o,u,f)),_(b)}function c(t,e,i,n){var r=1-n;return r*(r*t+2*n*e)+n*n*i}function l(t,e,i,n){return 2*((1-n)*(e-t)+n*(i-e))}function h(t,n,r,a,o){var s=t-2*n+r,u=2*(n-t),c=t-a,l=0;if(e(s)){if(i(u)){var h=-c/u;h>=0&&1>=h&&(o[l++]=h)}}else{var f=u*u-4*s*c;if(e(f)){var h=-u/(2*s);h>=0&&1>=h&&(o[l++]=h)}else if(f>0){var d=_(f),h=(-u+d)/(2*s),p=(-u-d)/(2*s);h>=0&&1>=h&&(o[l++]=h),p>=0&&1>=p&&(o[l++]=p)}}return l}function f(t,e,i){var n=t+i-2*e;return 0===n?.5:(t-e)/n}function d(t,e,i,n,r){var a=(e-t)*n+t,o=(i-e)*n+e,s=(o-a)*n+a;r[0]=t,r[1]=a,r[2]=s,r[3]=s,r[4]=o,r[5]=i}function p(t,e,i,n,r,a,o,s,u){var l,h=.005,f=1/0;M[0]=o,M[1]=s;for(var d=0;1>d;d+=.05){S[0]=c(t,i,r,d),S[1]=c(e,n,a,d);var p=g(M,S);f>p&&(l=d,f=p)}f=1/0;for(var v=0;32>v&&!(x>h);v++){var m=l-h,y=l+h;S[0]=c(t,i,r,m),S[1]=c(e,n,a,m);var p=g(S,M);if(m>=0&&f>p)l=m,f=p;else{C[0]=c(t,i,r,y),C[1]=c(e,n,a,y);var b=g(C,M);1>=y&&f>b?(l=y,f=b):h*=.5}}return u&&(u[0]=c(t,i,r,l),u[1]=c(e,n,a,l)),_(f)}var v=t("./vector"),m=v[wt],g=v.distSquare,y=Math.pow,_=Math.sqrt,x=1e-4,b=_(3),w=1/3,M=m(),S=m(),C=m();return{cubicAt:n,cubicDerivativeAt:r,cubicRootAt:a,cubicExtrema:o,cubicSubdivide:s,cubicProjectPoint:u,quadraticAt:c,quadraticDerivativeAt:l,quadraticRootAt:h,quadraticExtremum:f,quadraticSubdivide:d,quadraticProjectPoint:p}}),e("zrender/core/bbox",[ie,"./vector","./curve"],function(t){var e=t("./vector"),i=t("./curve"),n={},r=Math.min,a=Math.max,o=Math.sin,s=Math.cos,u=e[wt](),c=e[wt](),l=e[wt](),h=2*Math.PI;return n.fromPoints=function(t,e,i){if(0!==t[Kt]){var n,o=t[0],s=o[0],u=o[0],c=o[1],l=o[1];for(n=1;ng;g++)y[g]=b(t,n,s,c,y[g]);for(w=x(e,o,u,l,_),g=0;w>g;g++)_[g]=b(e,o,u,l,_[g]);y.push(t,c),_.push(e,l),d=r.apply(null,y),p=a.apply(null,y),v=r.apply(null,_),m=a.apply(null,_),h[0]=d,h[1]=v,f[0]=p,f[1]=m},n.fromQuadratic=function(t,e,n,o,s,u,c,l){var h=i.quadraticExtremum,f=i.quadraticAt,d=a(r(h(t,n,s),1),0),p=a(r(h(e,o,u),1),0),v=f(t,n,s,d),m=f(e,o,u,p);c[0]=r(t,s,v),c[1]=r(e,u,m),l[0]=a(t,s,v),l[1]=a(e,u,m)},n.fromArc=function(t,i,n,r,a,f,d,p,v){var m=e.min,g=e.max,y=Math.abs(a-f);if(1e-4>y%h&&y>1e-4)return p[0]=t-n,p[1]=i-r,v[0]=t+n,void(v[1]=i+r);if(u[0]=s(a)*n+t,u[1]=o(a)*r+i,c[0]=s(f)*n+t,c[1]=o(f)*r+i,m(p,u,c),g(v,u,c),a%=h,0>a&&(a+=h),f%=h,0>f&&(f+=h),a>f&&!d?f+=h:f>a&&d&&(a+=h),d){var _=f;f=a,a=_}for(var x=0;f>x;x+=Math.PI/2)x>a&&(l[0]=s(x)*n+t,l[1]=o(x)*r+i,m(p,l,p),g(v,l,v))},n}),e("zrender/core/PathProxy",[ie,"./curve","./vector","./bbox","./BoundingRect"],function(t){var e=t("./curve"),i=t("./vector"),n=t("./bbox"),r=t("./BoundingRect"),a={M:1,L:2,C:3,Q:4,A:5,Z:6,R:7},o=[],s=[],u=[],c=[],l=Math.min,h=Math.max,f=Math.cos,d=Math.sin,p=Math.sqrt,v=typeof Float32Array!=Lt,m=function(){this.data=[],this._len=0,this._ctx=null,this._xi=0,this._yi=0,this._x0=0,this._y0=0};return m[ee]={constructor:m,_lineDash:null,_dashOffset:0,_dashIdx:0,_dashSum:0,getContext:function(){return this._ctx},beginPath:function(t){return this._ctx=t,t&&t[M](),this._len=0,this._lineDash&&(this._lineDash=null,this._dashOffset=0),this},moveTo:function(t,e){return this.addData(a.M,t,e),this._ctx&&this._ctx[w](t,e),this._x0=t,this._y0=e,this._xi=t,this._yi=e,this},lineTo:function(t,e){return this.addData(a.L,t,e),this._ctx&&(this._needsDash()?this._dashedLineTo(t,e):this._ctx.lineTo(t,e)),this._xi=t,this._yi=e,this},bezierCurveTo:function(t,e,i,n,r,o){return this.addData(a.C,t,e,i,n,r,o),this._ctx&&(this._needsDash()?this._dashedBezierTo(t,e,i,n,r,o):this._ctx.bezierCurveTo(t,e,i,n,r,o)),this._xi=r,this._yi=o,this},quadraticCurveTo:function(t,e,i,n){return this.addData(a.Q,t,e,i,n),this._ctx&&(this._needsDash()?this._dashedQuadraticTo(t,e,i,n):this._ctx.quadraticCurveTo(t,e,i,n)),this._xi=i,this._yi=n,this},arc:function(t,e,i,n,r,o){return this.addData(a.A,t,e,i,i,n,r-n,0,o?0:1),this._ctx&&this._ctx.arc(t,e,i,n,r,o),this._xi=f(r)*i+t,this._xi=d(r)*i+t,this},arcTo:function(t,e,i,n,r){return this._ctx&&this._ctx.arcTo(t,e,i,n,r),this},rect:function(t,e,i,n){return this._ctx&&this._ctx.rect(t,e,i,n),this.addData(a.R,t,e,i,n),this},closePath:function(){this.addData(a.Z);var t=this._ctx,e=this._x0,i=this._y0;return t&&(this._needsDash()&&this._dashedLineTo(e,i),t[b]()),this._xi=e,this._yi=i,this},fill:function(t){t&&t.fill(),this.toStatic()},stroke:function(t){t&&t[zt](),this.toStatic()},setLineDash:function(t){if(t instanceof Array){this._lineDash=t,this._dashIdx=0;for(var e=0,i=0;ii;i++)this.data[i]=t[i];this._len=e},appendPath:function(t){t instanceof Array||(t=[t]);for(var e=t[Kt],i=0,n=this._len,r=0;e>r;r++)i+=t[r].len();v&&this.data instanceof Float32Array&&(this.data=new Float32Array(n+i));for(var r=0;e>r;r++)for(var a=t[r].data,o=0;oe[Kt]&&(this._expandData(),e=this.data);for(var i=0;ia&&(a=r+a),a%=r,m-=a*f,g-=a*d;f>=0&&t>=m||0>f&&m>t;)n=this._dashIdx,i=o[n],m+=f*i,g+=d*i,this._dashIdx=(n+1)%y,f>0&&u>m||0>f&&m>u||s[n%2?w:"lineTo"](f>=0?l(m,t):h(m,t),d>=0?l(g,e):h(g,e));f=m-t,d=g-e,this._dashOffset=-p(f*f+d*d)},_dashedBezierTo:function(t,i,n,r,a,o){var s,u,c,l,h,f=this._dashSum,d=this._dashOffset,v=this._lineDash,m=this._ctx,g=this._xi,y=this._yi,_=e.cubicAt,x=0,b=this._dashIdx,M=v[Kt],S=0;for(0>d&&(d=f+d),d%=f,s=0;1>s;s+=.1)u=_(g,t,n,a,s+.1)-_(g,t,n,a,s),c=_(y,i,r,o,s+.1)-_(y,i,r,o,s),x+=p(u*u+c*c);for(;M>b&&(S+=v[b],!(S>d));b++);for(s=(S-d)/x;1>=s;)l=_(g,t,n,a,s),h=_(y,i,r,o,s),b%2?m[w](l,h):m.lineTo(l,h),s+=v[b]/x,b=(b+1)%M;b%2!==0&&m.lineTo(a,o),u=a-l,c=o-h,this._dashOffset=-p(u*u+c*c)},_dashedQuadraticTo:function(t,e,i,n){var r=i,a=n;i=(i+2*t)/3,n=(n+2*e)/3,t=(this._xi+2*t)/3,e=(this._yi+2*e)/3,this._dashedBezierTo(t,e,i,n,r,a)},toStatic:function(){var t=this.data;t instanceof Array&&(t[Kt]=this._len,v&&(this.data=new Float32Array(t)))},getBoundingRect:function(){o[0]=o[1]=u[0]=u[1]=Number.MAX_VALUE,s[0]=s[1]=c[0]=c[1]=-Number.MAX_VALUE;for(var t=this.data,e=0,l=0,h=0,p=0,v=0;vu?s:u,p=s>u?1:s/u,v=s>u?u/s:1,m=Math.abs(s-u)>.001;m?(t.translate(r,o),t.rotate(h),t.scale(p,v),t.arc(0,0,d,c,c+l,1-f),t.scale(1/p,1/v),t.rotate(-h),t.translate(-r,-o)):t.arc(r,o,d,c,c+l,1-f);break;case a.R:t.rect(e[i++],e[i++],e[i++],e[i++]);break;case a.Z:t[b]()}}}},m.CMD=a,m}),e("zrender/contain/line",[],function(){return{containStroke:function(t,e,i,n,r,a,o){if(0===r)return!1;var s=r,u=0,c=t;if(o>e+s&&o>n+s||e-s>o&&n-s>o||a>t+s&&a>i+s||t-s>a&&i-s>a)return!1;if(t===i)return Math.abs(a-t)<=s/2;u=(e-n)/(t-i),c=(t*n-i*e)/(t-i);var l=u*a-o+c,h=l*l/(u*u+1);return s/2*s/2>=h}}}),e("zrender/contain/cubic",[ie,"../core/curve"],function(t){var e=t("../core/curve");return{containStroke:function(t,i,n,r,a,o,s,u,c,l,h){if(0===c)return!1;var f=c;if(h>i+f&&h>r+f&&h>o+f&&h>u+f||i-f>h&&r-f>h&&o-f>h&&u-f>h||l>t+f&&l>n+f&&l>a+f&&l>s+f||t-f>l&&n-f>l&&a-f>l&&s-f>l)return!1;var d=e.cubicProjectPoint(t,i,n,r,a,o,s,u,l,h,null);return f/2>=d}}}),e("zrender/contain/quadratic",[ie,"../core/curve"],function(t){var e=t("../core/curve");return{containStroke:function(t,i,n,r,a,o,s,u,c){if(0===s)return!1;var l=s;if(c>i+l&&c>r+l&&c>o+l||i-l>c&&r-l>c&&o-l>c||u>t+l&&u>n+l&&u>a+l||t-l>u&&n-l>u&&a-l>u)return!1;var h=e.quadraticProjectPoint(t,i,n,r,a,o,u,c,null);return l/2>=h}}}),e("zrender/contain/util",[ie],function(t){var e=2*Math.PI;return{normalizeRadian:function(t){return t%=e,0>t&&(t+=e),t}}}),e("zrender/contain/arc",[ie,"./util"],function(t){var e=t("./util").normalizeRadian,i=2*Math.PI;return{containStroke:function(t,n,r,a,o,s,u,c,l){if(0===u)return!1;var h=u;c-=t,l-=n;var f=Math.sqrt(c*c+l*l);if(f-h>r||r>f+h)return!1;if(Math.abs(a-o)%i<1e-4)return!0;if(s){var d=a;a=e(o),o=e(d)}else a=e(a),o=e(o);a>o&&(o+=i);var p=Math.atan2(l,c);return 0>p&&(p+=i),p>=a&&o>=p||p+i>=a&&o>=p+i}}}),e("zrender/contain/windingLine",[],function(){return function(t,e,i,n,r,a){if(a>e&&a>n||e>a&&n>a)return 0;if(n===e)return 0;var o=e>n?1:-1,s=(a-e)/(n-e),u=s*(i-t)+t;return u>r?o:0}}),e("zrender/contain/path",[ie,"../core/PathProxy","./line","./cubic","./quadratic","./arc","./util","../core/curve","./windingLine"],function(t){function e(t,e){return Math.abs(t-e)e&&l>r&&l>o&&l>u||e>l&&r>l&&o>l&&u>l)return 0;var h=d.cubicRootAt(e,r,o,u,l,y);if(0===h)return 0;for(var f,p,v=0,m=-1,g=0;h>g;g++){var x=y[g],b=d.cubicAt(t,n,a,s,x);c>b||(0>m&&(m=d.cubicExtrema(e,r,o,u,_),_[1]<_[0]&&m>1&&i(),f=d.cubicAt(e,r,o,u,_[0]),m>1&&(p=d.cubicAt(e,r,o,u,_[1]))),v+=2==m?x<_[0]?e>f?1:-1:x<_[1]?f>p?1:-1:p>u?1:-1:x<_[0]?e>f?1:-1:f>u?1:-1)}return v}function r(t,e,i,n,r,a,o,s){if(s>e&&s>n&&s>a||e>s&&n>s&&a>s)return 0;var u=d.quadraticRootAt(e,n,a,s,y);if(0===u)return 0;var c=d.quadraticExtremum(e,n,a);if(c>=0&&1>=c){for(var l=0,h=d.quadraticAt(e,n,a,c),f=0;u>f;f++){var p=d.quadraticAt(t,i,r,y[f]);p>o||(l+=y[f]h?1:-1:h>a?1:-1)}return l}var p=d.quadraticAt(t,i,r,y[0]);return p>o?0:e>a?1:-1}function a(t,e,i,n,r,a,o,s){if(s-=e,s>i||-i>s)return 0;var u=Math.sqrt(i*i-s*s);y[0]=-u,y[1]=u;var c=Math.abs(n-r);if(1e-4>c)return 0;if(1e-4>c%m){n=0,r=m;var l=a?1:-1;return o>=y[0]+t&&o<=y[1]+t?l:0}if(a){var u=n;n=f(r),r=f(u)}else n=f(n),r=f(r);n>r&&(r+=m);for(var h=0,d=0;2>d;d++){var p=y[d];if(p+t>o){var v=Math.atan2(s,p),l=a?1:-1;0>v&&(v=m+v),(v>=n&&r>=v||v+m>=n&&r>=v+m)&&(v>Math.PI/2&&v<1.5*Math.PI&&(l=-l),h+=l)}}return h}function o(t,i,o,u,f){for(var d=0,m=0,g=0,y=0,_=0,x=0;x1&&(o||(d+=p(m,g,y,_,u,f)),0!==d))return!0;switch(1==x&&(m=t[x],g=t[x+1],y=m,_=g),b){case s.M:y=t[x++],_=t[x++],m=y,g=_;break;case s.L:if(o){if(v(m,g,t[x],t[x+1],i,u,f))return!0}else d+=p(m,g,t[x],t[x+1],u,f)||0;m=t[x++],g=t[x++];break;case s.C:if(o){if(c.containStroke(m,g,t[x++],t[x++],t[x++],t[x++],t[x],t[x+1],i,u,f))return!0}else d+=n(m,g,t[x++],t[x++],t[x++],t[x++],t[x],t[x+1],u,f)||0;m=t[x++],g=t[x++];break;case s.Q:if(o){if(l.containStroke(m,g,t[x++],t[x++],t[x],t[x+1],i,u,f))return!0}else d+=r(m,g,t[x++],t[x++],t[x],t[x+1],u,f)||0;m=t[x++],g=t[x++];break;case s.A:var w=t[x++],M=t[x++],S=t[x++],C=t[x++],T=t[x++],L=t[x++],k=(t[x++],1-t[x++]),A=Math.cos(T)*S+w,z=Math.sin(T)*C+M;x>1?d+=p(m,g,A,z,u,f):(y=A,_=z);var P=(u-w)*C/S+w;if(o){if(h.containStroke(w,M,C,T,T+L,k,i,P,f))return!0}else d+=a(w,M,C,T,T+L,k,P,f);m=Math.cos(T+L)*S+w,g=Math.sin(T+L)*C+M;break;case s.R:y=m=t[x++],_=g=t[x++];var D=t[x++],I=t[x++],A=y+D,z=_+I;if(o){if(v(y,_,A,_,i,u,f)||v(A,_,A,z,i,u,f)||v(A,z,y,z,i,u,f)||v(y,z,A,z,i,u,f))return!0}else d+=p(A,_,A,z,u,f),d+=p(y,z,y,_,u,f);break;case s.Z:if(o){if(v(m,g,y,_,i,u,f))return!0}else if(d+=p(m,g,y,_,u,f),0!==d)return!0;m=y,g=_}}return o||e(g,_)||(d+=p(m,g,y,_,u,f)||0),0!==d}var s=t("../core/PathProxy").CMD,u=t("./line"),c=t("./cubic"),l=t("./quadratic"),h=t("./arc"),f=t("./util").normalizeRadian,d=t("../core/curve"),p=t("./windingLine"),v=u.containStroke,m=2*Math.PI,g=1e-4,y=[-1,-1,-1],_=[-1,-1];return{contain:function(t,e,i){return o(t,0,!1,e,i)},containStroke:function(t,e,i,n){return o(t,e,!0,i,n)}}}),e("zrender/graphic/Path",[ie,"./Displayable",bt,"../core/PathProxy","../contain/path","./Gradient"],function(t){function e(t){var e=t.fill;return null!=e&&"none"!==e}function i(t){var e=t[zt];return null!=e&&"none"!==e&&t[Pt]>0}function n(t){r.call(this,t),this.path=new o}var r=t("./Displayable"),a=t(bt),o=t("../core/PathProxy"),s=t("../contain/path"),u=t("./Gradient"),c=Math.abs;return n[ee]={constructor:n,type:"path",__dirtyPath:!0,strokeContainThreshold:5,brush:function(t){t.save();var n=this.style,r=this.path,a=i(n),o=e(n);this.__dirtyPath&&(o&&n.fill instanceof u&&n.fill.updateCanvasGradient(this,t),a&&n[zt]instanceof u&&n[zt].updateCanvasGradient(this,t)),n.bind(t,this),this.setTransform(t);var s=n.lineDash,c=n.lineDashOffset,l=!!t.setLineDash;this.__dirtyPath||s&&!l&&a?(r=this.path[M](t),s&&!l&&(r.setLineDash(s),r.setLineDashOffset(c)),this[x](r,this.shape),this.__dirtyPath=!1):(t[M](),this.path.rebuildPath(t)),o&&r.fill(t),s&&l&&(t.setLineDash(s),t.lineDashOffset=c),a&&r[zt](t),null!=n.text&&this.drawRectText(t,this[vt]()),t.restore()},buildPath:function(t,e){},getBoundingRect:function(){var t=this._rect,n=this.style;if(!t){var r=this.path;this.__dirtyPath&&(r[M](),this[x](r,this.shape)),t=r[vt]()}if(i(n)&&(this[O]||!this._rect)){var a=this._rectWithStroke||(this._rectWithStroke=t.clone());a.copy(t);var o=n[Pt],s=n.strokeNoScale?this.getLineScale():1;return e(n)||(o=Math.max(o,this.strokeContainThreshold)),s>1e-10&&(a.width+=o/s,a[Mt]+=o/s,a.x-=o/s/2,a.y-=o/s/2),a}return this._rect=t,t},contain:function(t,n){var r=this.transformCoordToLocal(t,n),a=this[vt](),o=this.style;if(t=r[0],n=r[1],a[S](t,n)){var u=this.path.data;if(i(o)){var c=o[Pt],l=o.strokeNoScale?this.getLineScale():1;if(l>1e-10&&(e(o)||(c=Math.max(c,this.strokeContainThreshold)),s.containStroke(u,c/l,t,n)))return!0}if(e(o))return s[S](u,t,n)}return!1},dirty:function(t){0===arguments[Kt]&&(t=!0),t&&(this.__dirtyPath=t,this._rect=null),this[O]=!0,this.__zr&&this.__zr[B](),this.__clipTarget&&this.__clipTarget.dirty()},animateShape:function(t){return this[E]("shape",t)},attrKV:function(t,e){"shape"===t?this[_](e):r[ee].attrKV.call(this,t,e)},setShape:function(t,e){var i=this.shape;if(i){if(a[tt](t))for(var n in t)i[n]=t[n];else i[t]=e;this.dirty(!0)}return this},getLineScale:function(){var t=this[V];return t&&c(t[0]-1)>1e-10&&c(t[3]-1)>1e-10?Math.sqrt(c(t[0]*t[3]-t[2]*t[1])):1}},n[Rt]=function(t){var e=function(e){n.call(this,e),t.style&&this.style.extendFrom(t.style,!1);var i=t.shape;if(i){this.shape=this.shape||{};var r=this.shape;for(var a in i)!r.hasOwnProperty(a)&&i.hasOwnProperty(a)&&(r[a]=i[a])}t.init&&t.init.call(this,e)};a[Bt](e,n);for(var i in t)"style"!==i&&"shape"!==i&&(e[ee][i]=t[i]);return e},a[Bt](n,r),n}),e("zrender/tool/transformPath",[ie,"../core/PathProxy","../core/vector"],function(t){function e(t,e){var n,u,c,l,h,f,d=t.data,p=i.M,v=i.C,m=i.L,g=i.R,y=i.A,_=i.Q;for(c=0,l=0;ch;h++){var f=a[h];f[0]=d[c++],f[1]=d[c++],r(f,f,e),d[l++]=f[0],d[l++]=f[1]}}}var i=t("../core/PathProxy").CMD,n=t("../core/vector"),r=n[St],a=[[],[],[]],o=Math.sqrt,s=Math.atan2;return e}),e("zrender/tool/path",[ie,"../graphic/Path","../core/PathProxy","./transformPath","../core/matrix"],function(t){function e(t,e,i,n,r,a,o,s,u,d,m){var g=u*(f/180),y=h(g)*(t-i)/2+l(g)*(e-n)/2,_=-1*l(g)*(t-i)/2+h(g)*(e-n)/2,x=y*y/(o*o)+_*_/(s*s);x>1&&(o*=c(x),s*=c(x));var b=(r===a?-1:1)*c((o*o*(s*s)-o*o*(_*_)-s*s*(y*y))/(o*o*(_*_)+s*s*(y*y)))||0,w=b*o*_/s,M=b*-s*y/o,S=(t+i)/2+h(g)*w-l(g)*M,C=(e+n)/2+l(g)*w+h(g)*M,T=v([1,0],[(y-w)/o,(_-M)/s]),L=[(y-w)/o,(_-M)/s],k=[(-1*y-w)/o,(-1*_-M)/s],A=v(L,k);p(L,k)<=-1&&(A=f),p(L,k)>=1&&(A=0),0===a&&A>0&&(A-=2*f),1===a&&0>A&&(A+=2*f),m.addData(d,S,C,o,s,T,A,g,a)}function i(t){if(!t)return[];var i,n=t[Ht](/-/g," -")[Ht](/ /g," ")[Ht](/ /g,",")[Ht](/,,/g,",");for(i=0;i0&&""===m[0]&&m.shift();for(var g=0;gn;n++)i=t[n],i[O]&&i[x](i.path,i.shape),a.push(i.path);var s=new r(e);return s[x]=function(t){t.appendPath(a);var e=t[Qt]();e&&t.rebuildPath(e)},s}}}),e("zrender/graphic/helper/roundRect",[ie],function(t){return{buildPath:function(t,e){var i,n,r,a,o=e.x,s=e.y,u=e.width,c=e[Mt],l=e.r;0>u&&(o+=u,u=-u),0>c&&(s+=c,c=-c),typeof l===Ut?i=n=r=a=l:l instanceof Array?1===l[Kt]?i=n=r=a=l[0]:2===l[Kt]?(i=r=l[0],n=a=l[1]):3===l[Kt]?(i=l[0],n=a=l[1],r=l[2]):(i=l[0],n=l[1],r=l[2],a=l[3]):i=n=r=a=0;var h;i+n>u&&(h=i+n,i*=u/h,n*=u/h),r+a>u&&(h=r+a,r*=u/h,a*=u/h),n+r>c&&(h=n+r,n*=c/h,r*=c/h),i+a>c&&(h=i+a,i*=c/h,a*=c/h),t[w](o+i,s),t.lineTo(o+u-n,s),0!==n&&t.quadraticCurveTo(o+u,s,o+u,s+n),t.lineTo(o+u,s+c-r),0!==r&&t.quadraticCurveTo(o+u,s+c,o+u-r,s+c),t.lineTo(o+a,s+c),0!==a&&t.quadraticCurveTo(o,s+c,o,s+c-a),t.lineTo(o,s+i),0!==i&&t.quadraticCurveTo(o,s,o+i,s)}}}),e("zrender/core/LRU",[ie],function(t){var e=function(){this.head=null,this.tail=null,this._len=0},i=e[ee];i.insert=function(t){var e=new n(t);return this.insertEntry(e),e},i.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,this.tail=t):this.head=this.tail=t,this._len++},i[I]=function(t){var e=t.prev,i=t.next;e?e.next=i:this.head=i,i?i.prev=e:this.tail=e,t.next=t.prev=null,this._len--},i.len=function(){return this._len};var n=function(t){this.value=t,this.next,this.prev},r=function(t){this._list=new e,this._map={},this._maxSize=t||10},a=r[ee];return a.put=function(t,e){var i=this._list,n=this._map;if(null==n[t]){var r=i.len();if(r>=this._maxSize&&r>0){var a=i.head;i[I](a),delete n[a.key]}var o=i.insert(e);o.key=t,n[t]=o}},a.get=function(t){var e=this._map[t],i=this._list;return null!=e?(e!==i.tail&&(i[I](e),i.insertEntry(e)),e.value):void 0},a.clear=function(){this._list.clear(),this._map={}},r}),e("zrender/graphic/Image",[ie,"./Displayable","../core/BoundingRect",bt,"./helper/roundRect","../core/LRU"],function(t){var e=t("./Displayable"),i=t("../core/BoundingRect"),n=t(bt),r=t("./helper/roundRect"),a=t("../core/LRU"),o=new a(50),s=function(t){e.call(this,t)};return s[ee]={constructor:s,type:"image",brush:function(t){var e,i=this.style,n=i.image;if(e=typeof n===jt?this._image:n,!e&&n){var a=o.get(n);if(!a)return e=new Image,e.onload=function(){e.onload=null;for(var t=0;ts;s++)o+=i.distance(t[s-1],t[s]);var u=o/2;u=r>u?r:u;for(var s=0;u>s;s++){var c,l,h,f=s/(u-1)*(n?r:r-1),d=Math.floor(f),p=f-d,v=t[d%r];n?(c=t[(d-1+r)%r],l=t[(d+1)%r],h=t[(d+2)%r]):(c=t[0===d?d:d-1],l=t[d>r-2?r-1:d+1],h=t[d>r-3?r-1:d+2]);var m=p*p,g=p*m;a.push([e(c[0],v[0],l[0],h[0],p,m,g),e(c[1],v[1],l[1],h[1],p,m,g)])}return a}}),e("zrender/graphic/helper/smoothBezier",[ie,"../../core/vector"],function(t){var e=t("../../core/vector"),i=e.min,n=e.max,r=e.scale,a=e.distance,o=e.add;return function(t,s,u,c){var l,h,f,d,p=[],v=[],m=[],g=[];if(c){f=[1/0,1/0],d=[-(1/0),-(1/0)];for(var y=0,_=t[Kt];_>y;y++)i(f,f,t[y]),n(d,d,t[y]);i(f,f,c[0]),n(d,d,c[1])}for(var y=0,_=t[Kt];_>y;y++){var x=t[y];if(u)l=t[y?y-1:_-1],h=t[(y+1)%_];else{if(0===y||y===_-1){p.push(e.clone(t[y]));continue}l=t[y-1],h=t[y+1]}e.sub(v,h,l),r(v,v,s);var b=a(x,l),w=a(x,h),M=b+w;0!==M&&(b/=M,w/=M),r(m,v,-b),r(g,v,w);var S=o([],x,m),C=o([],x,g);c&&(n(S,S,f),i(S,S,d),n(C,C,f),i(C,C,d)),p.push(S),p.push(C)}return u&&p.push(p.shift()),p}}),e("zrender/graphic/helper/poly",[ie,"./smoothSpline","./smoothBezier"],function(t){var e=t("./smoothSpline"),i=t("./smoothBezier");return{buildPath:function(t,n,r){var a=n.points,o=n.smooth;if(a&&a[Kt]>=2){if(o&&"spline"!==o){var s=i(a,o,r,n.smoothConstraint);t[w](a[0][0],a[0][1]);for(var u=a[Kt],c=0;(r?u:u-1)>c;c++){var l=s[2*c],h=s[2*c+1],f=a[(c+1)%u];t.bezierCurveTo(l[0],l[1],h[0],h[1],f[0],f[1])}}else{"spline"===o&&(a=e(a,r)),t[w](a[0][0],a[0][1]);for(var c=1,d=a[Kt];d>c;c++)t.lineTo(a[c][0],a[c][1])}r&&t[b]()}}}}),e("zrender/graphic/shape/Polygon",[ie,"../helper/poly","../Path"],function(t){var e=t("../helper/poly");return t("../Path")[Rt]({type:"polygon",shape:{points:null,smooth:!1,smoothConstraint:null},buildPath:function(t,i){e[x](t,i,!0)}})}),e("zrender/graphic/shape/Polyline",[ie,"../helper/poly","../Path"],function(t){var e=t("../helper/poly");return t("../Path")[Rt]({type:"polyline",shape:{points:null,smooth:!1,smoothConstraint:null},style:{stroke:"#000",fill:null},buildPath:function(t,i){e[x](t,i,!1)}})}),e("zrender/graphic/shape/Rect",[ie,"../helper/roundRect","../Path"],function(t){var e=t("../helper/roundRect");return t("../Path")[Rt]({type:"rect",shape:{r:0,x:0,y:0,width:0,height:0},buildPath:function(t,i){var n=i.x,r=i.y,a=i.width,o=i[Mt];i.r?e[x](t,i):t.rect(n,r,a,o),t[b]()}})}),e("zrender/graphic/shape/Line",[ie,"../Path"],function(t){return t("../Path")[Rt]({type:"line",shape:{x1:0,y1:0,x2:0,y2:0,percent:1},style:{stroke:"#000",fill:null},buildPath:function(t,e){var i=e.x1,n=e.y1,r=e.x2,a=e.y2,o=e.percent;0!==o&&(t[w](i,n),1>o&&(r=i*(1-o)+r*o,a=n*(1-o)+a*o),t.lineTo(r,a))},pointAt:function(t){var e=this.shape;return[e.x1*(1-t)+e.x2*t,e.y1*(1-t)+e.y2*t]}})}),e("zrender/graphic/shape/BezierCurve",[ie,"../../core/curve","../Path"],function(t){var e=t("../../core/curve"),i=e.quadraticSubdivide,n=e.cubicSubdivide,r=e.quadraticAt,a=e.cubicAt,o=[];return t("../Path")[Rt]({type:"bezier-curve",shape:{x1:0,y1:0,x2:0,y2:0,cpx1:0,cpy1:0,percent:1},style:{stroke:"#000",fill:null},buildPath:function(t,e){var r=e.x1,a=e.y1,s=e.x2,u=e.y2,c=e.cpx1,l=e.cpy1,h=e.cpx2,f=e.cpy2,d=e.percent;0!==d&&(t[w](r,a),null==h||null==f?(1>d&&(i(r,c,s,d,o),c=o[1],s=o[2],i(a,l,u,d,o),l=o[1],u=o[2]),t.quadraticCurveTo(c,l,s,u)):(1>d&&(n(r,c,h,s,d,o),c=o[1],h=o[2],s=o[3],n(a,l,f,u,d,o),l=o[1],f=o[2],u=o[3]),t.bezierCurveTo(c,l,h,f,s,u)))},pointAt:function(t){var e=this.shape,i=e.cpx2,n=e.cpy2;return null===i||null===n?[r(e.x1,e.cpx1,e.x2,t),r(e.y1,e.cpy1,e.y2,t)]:[a(e.x1,e.cpx1,e.cpx1,e.x2,t),a(e.y1,e.cpy1,e.cpy1,e.y2,t)]}})}),e("zrender/graphic/shape/Arc",[ie,"../Path"],function(t){return t("../Path")[Rt]({type:"arc",shape:{cx:0,cy:0,r:0,startAngle:0,endAngle:2*Math.PI,clockwise:!0},style:{stroke:"#000",fill:null},buildPath:function(t,e){var i=e.cx,n=e.cy,r=Math.max(e.r,0),a=e.startAngle,o=e.endAngle,s=e.clockwise,u=Math.cos(a),c=Math.sin(a);t[w](u*r+i,c*r+n),t.arc(i,n,r,a,o,!s)}})}),e("zrender/graphic/LinearGradient",[ie,bt,"./Gradient"],function(t){var e=t(bt),i=t("./Gradient"),n=function(t,e,n,r,a){this.x=null==t?0:t,this.y=null==e?0:e,this.x2=null==n?1:n,this.y2=null==r?0:r,i.call(this,a)};return n[ee]={constructor:n,type:"linear",updateCanvasGradient:function(t,e){for(var i=t[vt](),n=this.x*i.width+i.x,r=this.x2*i.width+i.x,a=this.y*i[Mt]+i.y,o=this.y2*i[Mt]+i.y,s=e.createLinearGradient(n,a,r,o),u=this.colorStops,c=0;c=0?"white":i,a=e[gt](mt);h[Rt](t,{textDistance:e[Dt]("distance")||5,textFont:a[pt](),textPosition:n,textFill:a.getTextColor()||r})},w[m]=h.curry(l,!0),w.initProps=h.curry(l,!1),w.getTransform=function(t,e){for(var i=_.identity([]);t&&t!==e;)_.mul(i,t[G](),i),t=t[q];return i},w[St]=function(t,e,i){return i&&(e=_.invert([],e)),x[St]([],t,e)},w.transformDirection=function(t,e,i){var n=0===e[4]||0===e[5]||0===e[0]?1:Math.abs(2*e[4]/e[0]),r=0===e[4]||0===e[5]||0===e[2]?1:Math.abs(2*e[4]/e[2]),a=["left"===t?-n:"right"===t?n:0,"top"===t?-r:t===Gt?r:0];return a=w[St](a,e,i),Math.abs(a[0])>Math.abs(a[1])?a[0]>0?"right":"left":a[1]>0?Gt:"top"},w}),e("zrender/core/env",[],function(){function t(t){var e={},i={},n=t.match(/Web[kK]it[\/]{0,1}([\d.]+)/),r=t.match(/(Android);?[\s\/]+([\d.]+)?/),a=t.match(/(iPad).*OS\s([\d_]+)/),o=t.match(/(iPod)(.*OS\s([\d_]+))?/),s=!a&&t.match(/(iPhone\sOS)\s([\d_]+)/),u=t.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),c=u&&t.match(/TouchPad/),l=t.match(/Kindle\/([\d.]+)/),h=t.match(/Silk\/([\d._]+)/),f=t.match(/(BlackBerry).*Version\/([\d.]+)/),d=t.match(/(BB10).*Version\/([\d.]+)/),p=t.match(/(RIM\sTablet\sOS)\s([\d.]+)/),v=t.match(/PlayBook/),m=t.match(/Chrome\/([\d.]+)/)||t.match(/CriOS\/([\d.]+)/),g=t.match(/Firefox\/([\d.]+)/),y=n&&t.match(/Mobile\//)&&!m,_=t.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/)&&!m,x=t.match(/MSIE\s([\d.]+)/)||t.match(/Trident\/.+?rv:(([\d.]+))/),b=t.match(/Edge\/([\d.]+)/);return(i.webkit=!!n)&&(i.version=n[1]),r&&(e.android=!0,e.version=r[2]),s&&!o&&(e.ios=e.iphone=!0,e.version=s[2][Ht](/_/g,".")),a&&(e.ios=e.ipad=!0,e.version=a[2][Ht](/_/g,".")),o&&(e.ios=e.ipod=!0,e.version=o[3]?o[3][Ht](/_/g,"."):null),u&&(e.webos=!0,e.version=u[2]),c&&(e.touchpad=!0),f&&(e.blackberry=!0,e.version=f[2]),d&&(e.bb10=!0,e.version=d[2]),p&&(e.rimtabletos=!0,e.version=p[2]),v&&(i.playbook=!0),l&&(e.kindle=!0,e.version=l[1]),h&&(i.silk=!0,i.version=h[1]),!h&&e.android&&t.match(/Kindle Fire/)&&(i.silk=!0),m&&(i.chrome=!0,i.version=m[1]),g&&(i.firefox=!0,i.version=g[1]),x&&(i.ie=!0,i.version=x[1]),y&&(t.match(/Safari/)||e.ios)&&(i.safari=!0),_&&(i.webview=!0),x&&(i.ie=!0,i.version=x[1]),b&&(i.edge=!0,i.version=b[1]),e.tablet=!!(a||v||r&&!t.match(/Mobile/)||g&&t.match(/Tablet/)||x&&!t.match(/Phone/)&&t.match(/Touch/)),e.phone=!(e.tablet||e.ipod||!(r||s||u||f||d||m&&t.match(/Android/)||m&&t.match(/CriOS\/([\d.]+)/)||g&&t.match(/Mobile/)||x&&t.match(/Touch/))),{browser:i,os:e,node:!1,canvasSupported:document.createElement($t)[Qt]?!0:!1,touchEventsSupported:"ontouchstart"in window&&!i.ie&&!i.edge,pointerEventsSupported:"onpointerdown"in window&&(i.edge||i.ie&&i.version>=10)}}var e={};return e=typeof navigator===Lt?{browser:{},os:{},node:!0,canvasSupported:!0}:t(navigator.userAgent)}),e("zrender/core/event",[ie,"../mixin/Eventful"],function(t){function e(t){return t.getBoundingClientRect?t.getBoundingClientRect():{left:0,top:0}}function i(t,i){if(i=i||window.event,null!=i.zrX)return i;var n=i.type,r=n&&n[Yt]("touch")>=0;if(r){var a="touchend"!=n?i.targetTouches[0]:i.changedTouches[0];if(a){var o=e(t);i.zrX=a.clientX-o.left,i.zrY=a.clientY-o.top}}else{var s=e(t);i.zrX=i.clientX-s.left,i.zrY=i.clientY-s.top,i.zrDelta=i.wheelDelta?i.wheelDelta/120:-(i.detail||0)/3}return i}function n(t,e,i){o?t.addEventListener(e,i):t.attachEvent("on"+e,i)}function r(t,e,i){o?t.removeEventListener(e,i):t.detachEvent("on"+e,i)}var a=t("../mixin/Eventful"),o=typeof window!==Lt&&!!window.addEventListener,s=o?function(t){t.preventDefault(),t.stopPropagation(),t.cancelBubble=!0}:function(t){t.returnValue=!1,t.cancelBubble=!0};return{normalizeEvent:i,addEventListener:n,removeEventListener:r,stop:s,Dispatcher:a}}),e("zrender/mixin/Draggable",[ie],function(t){function e(){this.on("mousedown",this._dragStart,this),this.on("mousemove",this._drag,this),this.on("mouseup",this._dragEnd,this),this.on("globalout",this._dragEnd,this)}return e[ee]={constructor:e,_dragStart:function(t){var e=t.target;e&&e.draggable&&(this._draggingTarget=e,e.dragging=!0,this._x=t.offsetX,this._y=t.offsetY,this._dispatchProxy(e,"dragstart",t.event))},_drag:function(t){var e=this._draggingTarget;if(e){var i=t.offsetX,n=t.offsetY,r=i-this._x,a=n-this._y;this._x=i,this._y=n,e.drift(r,a,t),this._dispatchProxy(e,"drag",t.event);var o=this.findHover(i,n,e),s=this._dropTarget;this._dropTarget=o,e!==o&&(s&&o!==s&&this._dispatchProxy(s,"dragleave",t.event),o&&o!==s&&this._dispatchProxy(o,"dragenter",t.event))}},_dragEnd:function(t){var e=this._draggingTarget;e&&(e.dragging=!1),this._dispatchProxy(e,"dragend",t.event),this._dropTarget&&this._dispatchProxy(this._dropTarget,"drop",t.event),this._draggingTarget=null,this._dropTarget=null}},e}),e("zrender/core/GestureMgr",[ie],function(t){function e(t){var e=t[1][0]-t[0][0],i=t[1][1]-t[0][1];return Math.sqrt(e*e+i*i)}function i(t){return[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2]}var n=function(){this._track=[]};n[ee]={constructor:n,recognize:function(t,e){return this._doTrack(t,e),this._recognize(t)},clear:function(){return this._track[Kt]=0,this},_doTrack:function(t,e){var i=t.touches;if(i){for(var n={points:[],touches:[],target:e,event:t},r=0,a=i[Kt];a>r;r++){var o=i[r];n.points.push([o.clientX,o.clientY]),n.touches.push(o)}this._track.push(n)}},_recognize:function(t){for(var e in r)if(r.hasOwnProperty(e)){var i=r[e](this._track,t);if(i)return i}}};var r={pinch:function(t,n){var r=t[Kt];if(r){var a=(t[r-1]||{}).points,o=(t[r-2]||{}).points||a;if(o&&o[Kt]>1&&a&&a[Kt]>1){var s=e(a)/e(o);!isFinite(s)&&(s=1),n.pinchScale=s;var u=i(a);return n.pinchX=u[0],n.pinchY=u[1],{type:"pinch",target:t[0].target,event:n}}}}};return n}),e("zrender/Handler",[ie,"./core/env","./core/event","./core/util","./mixin/Draggable","./core/GestureMgr","./mixin/Eventful"],function(t){function e(t,e,i){return{type:t,event:i,target:e,cancelBubble:!1,offsetX:i.zrX,offsetY:i.zrY,gestureEvent:i.gestureEvent,pinchX:i.pinchX,pinchY:i.pinchY,pinchScale:i.pinchScale,wheelDelta:i.zrDelta}}function i(t,e,i){var n=t._gestureMgr;"start"===i&&n.clear();var r=n.recognize(e,t.findHover(e.zrX,e.zrY,null));if("end"===i&&n.clear(),r){var a=r.type;e.gestureEvent=a,t._dispatchProxy(r.target,a,r.event)}}function n(t){function e(t,e){return function(){return e._touching?void 0:t.apply(e,arguments)}}for(var i=m[Xt](_),n=0;n=0;a--)if(!n[a].silent&&n[a]!==i&&r(n[a],t,e))return n[a]}},h.mixin(T,p),h.mixin(T,f),T}),e("zrender/Storage",[ie,"./core/util","./container/Group"],function(t){function e(t,e){return t[v]===e[v]?t.z===e.z?t.z2===e.z2?t.__renderidx-e.__renderidx:t.z2-e.z2:t.z-e.z:t[v]-e[v]}var i=t("./core/util"),n=t("./container/Group"),r=function(){this._elements={},this._roots=[],this._displayList=[],this._displayListLen=0};return r[ee]={constructor:r,getDisplayList:function(t){return t&&this.updateDisplayList(),this._displayList},updateDisplayList:function(){this._displayListLen=0;for(var t=this._roots,i=this._displayList,n=0,r=t[Kt];r>n;n++){var a=t[n];this._updateAndAddDisplayable(a)}i[Kt]=this._displayListLen;for(var n=0,r=i[Kt];r>n;n++)i[n].__renderidx=n;i.sort(e)},_updateAndAddDisplayable:function(t,e){if(!t[R]){t.beforeUpdate(),t[U](),t.afterUpdate();var i=t.clipPath;if(i&&(i[q]=t,i.updateTransform(),e?(e=e.slice(),e.push(i)):e=[i]),"group"==t.type){for(var n=t._children,r=0;re;e++)this.delRoot(t[e]);else{var o;o=typeof t==jt?this._elements[t]:t;var s=i[Yt](this._roots,o);s>=0&&(this.delFromMap(o.id),this._roots[$](s,1),o instanceof n&&o.delChildrenFromStorage(this))}},addToMap:function(t){return t instanceof n&&(t.__storage=this),t.dirty(),this._elements[t.id]=t,this},get:function(t){return this._elements[t]},delFromMap:function(t){var e=this._elements,i=e[t];return i&&(delete e[t],i instanceof n&&(i.__storage=null)),this},dispose:function(){this._elements=this._renderList=this._roots=null}},r}),e("zrender/animation/Animation",[ie,bt,"../core/event","./Animator"],function(t){var e=t(bt),i=t("../core/event").Dispatcher,n=typeof window!==Lt&&(window.requestAnimationFrame||window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(t){setTimeout(t,16)},r=t("./Animator"),a=function(t){t=t||{},this.stage=t.stage||{},this.onframe=t.onframe||function(){},this._clips=[],this._running=!1,this._time=0,i.call(this)};return a[ee]={constructor:a,addClip:function(t){this._clips.push(t)},addAnimator:function(t){t[F]=this;for(var e=t.getClips(),i=0;i=0&&this._clips[$](i,1)},removeAnimator:function(t){for(var e=t.getClips(),i=0;io;o++){var s=i[o],u=s.step(t);u&&(r.push(u),a.push(s))}for(var o=0;n>o;)i[o]._needsRemove?(i[o]=i[n-1],i.pop(),n--):o++;n=r[Kt];for(var o=0;n>o;o++)a[o].fire(r[o]);this._time=t,this.onframe(e),this[z]("frame",e),this.stage[U]&&this.stage[U]()},start:function(){function t(){e._running&&(n(t),e._update())}var e=this;this._running=!0,this._time=(new Date).getTime(),n(t)},stop:function(){this._running=!1},clear:function(){this._clips=[]},animate:function(t,e){e=e||{};var i=new r(t,e.loop,e.getter,e.setter);return i}},e.mixin(a,i),a}),e("zrender/Layer",[ie,"./core/util","./config"],function(t){function e(){return!1}function i(t,e,i,n){var r=document.createElement(e),a=i[Y](),o=i[j](),s=r.style;return s[J]="absolute",s.left=0,s.top=0,s.width=a+"px",s[Mt]=o+"px",r.width=a*n,r[Mt]=o*n,r.setAttribute("data-zr-dom-id",t),r}var n=t("./core/util"),r=t("./config"),a=function(t,a,o){var s;o=o||r.devicePixelRatio,typeof t===jt?s=i(t,$t,a,o):n[tt](t)&&(s=t,t=s.id),this.id=t,this.dom=s;var u=s.style;u&&(s.onselectstart=e,u["-webkit-user-select"]="none",u["user-select"]="none",u["-webkit-touch-callout"]="none",u["-webkit-tap-highlight-color"]="rgba(0,0,0,0)"),this.domBack=null,this.ctxBack=null,this.painter=a,this.config=null,this.clearColor=0,this.motionBlur=!1,this.lastFrameAlpha=.7,this.dpr=o};return a[ee]={constructor:a,elCount:0,__dirty:!0,initContext:function(){this.ctx=this.dom[Qt]("2d");var t=this.dpr;1!=t&&this.ctx.scale(t,t)},createBackBuffer:function(){var t=this.dpr;this.domBack=i("back-"+this.id,$t,this.painter,t),this.ctxBack=this.domBack[Qt]("2d"),1!=t&&this.ctxBack.scale(t,t)},resize:function(t,e){var i=this.dpr,n=this.dom,r=n.style,a=this.domBack;r.width=t+"px",r[Mt]=e+"px",n.width=t*i,n[Mt]=e*i,1!=i&&this.ctx.scale(i,i),a&&(a.width=t*i,a[Mt]=e*i,1!=i&&this.ctxBack.scale(i,i))},clear:function(t){var e=this.dom,i=this.ctx,n=e.width,r=e[Mt],a=this.clearColor,o=this.motionBlur&&!t,s=this.lastFrameAlpha,u=this.dpr;if(o&&(this.domBack||this.createBackBuffer(),this.ctxBack.globalCompositeOperation="copy",this.ctxBack.drawImage(e,0,0,n/u,r/u)),i.clearRect(0,0,n/u,r/u),a&&(i.save(),i.fillStyle=this.clearColor,i.fillRect(0,0,n/u,r/u),i.restore()),o){var c=this.domBack;i.save(),i.globalAlpha=s,i.drawImage(c,0,0,n/u,r/u),i.restore()}}},a}),e("zrender/Painter",[ie,"./config","./core/util","./core/log","./core/BoundingRect","./Layer","./graphic/Image"],function(t){function e(t){return parseInt(t,10)}function i(t){return t?t.isBuildin?!0:typeof t.resize!==Zt||typeof t[B]!==Zt?!1:!0:!1}function n(t){t.__unusedCount++}function r(t){t[O]=!1,1==t.__unusedCount&&t.clear()}function a(t,e,i){return d.copy(t[vt]()),t[V]&&d[St](t[V]),p.width=e,p[Mt]=i,!d.intersect(p)}function o(t,e){if(!t||!e||t[Kt]!==e[Kt])return!0;for(var i=0;ip;p++){var g=t[p],y=this._singleCanvas?0:g[v];if(u!==y&&(u=y,i=this.getLayer(u),i.isBuildin||l("ZLevel "+u+" has been used by unkown layer "+i.id),c=i.ctx,i.__unusedCount=0,(i[O]||e)&&i.clear()),(i[O]||e)&&!g.invisible&&0!==g.style[At]&&g.scale[0]&&g.scale[1]&&(!g.culling||!a(g,h,f))){var _=g.__clipPaths;o(_,d)&&(d&&c.restore(),_&&(c.save(),s(_,c)),d=_),g.beforeBrush&&g.beforeBrush(c),g.brush(c,!1),g.afterBrush&&g.afterBrush(c)}g[O]=!1}d&&c.restore(),this.eachBuildinLayer(r)},getLayer:function(t){if(this._singleCanvas)return this._layers[0];var e=this._layers[t];return e||(e=new f("zr_"+t,this,this.dpr),e.isBuildin=!0,this._layerConfig[t]&&c.merge(e,this._layerConfig[t],!0),this.insertLayer(t,e),e.initContext()),e},insertLayer:function(t,e){var n=this._layers,r=this._zlevelList,a=r[Kt],o=null,s=-1,u=this._domRoot;if(n[t])return void l("ZLevel "+t+" has been used already");if(!i(e))return void l("Layer of zlevel "+t+" is not valid");if(a>0&&t>r[0]){for(s=0;a-1>s&&!(r[s]t);s++);o=n[r[s]]}if(r[$](s+1,0,t),o){var c=o.dom;c.nextSibling?u.insertBefore(e.dom,c.nextSibling):u.appendChild(e.dom)}else u.firstChild?u.insertBefore(e.dom,u.firstChild):u.appendChild(e.dom);n[t]=e},eachLayer:function(t,e){var i,n,r=this._zlevelList;for(n=0;nn;n++){var a=t[n],o=this._singleCanvas?0:a[v],s=e[o];if(s){if(s.elCount++,s[O])continue;s[O]=a[O]}}this.eachBuildinLayer(function(t,e){i[e]!==t.elCount&&(t[O]=!0)})},clear:function(){return this.eachBuildinLayer(this._clearLayer),this},_clearLayer:function(t){t.clear()},configLayer:function(t,e){if(e){var i=this._layerConfig;i[t]?c.merge(i[t],e,!0):i[t]=e;var n=this._layers[t];n&&c.merge(n,i[t],!0)}},delLayer:function(t){var e=this._layers,i=this._zlevelList,n=e[t];n&&(n.dom.parentNode.removeChild(n.dom),delete e[t],i[$](c[Yt](i,t),1))},resize:function(t,e){var i=this._domRoot;if(i.style.display="none",t=t||this._getWidth(),e=e||this._getHeight(),i.style.display="",this._width!=t||e!=this._height){i.style.width=t+"px",i.style[Mt]=e+"px";for(var n in this._layers)this._layers[n].resize(t,e);this[B](!0)}return this._width=t,this._height=e,this},clearLayer:function(t){var e=this._layers[t];e&&e.clear()},dispose:function(){this.root.innerHTML="",this.root=this.storage=this._domRoot=this._layers=null},getRenderedCanvas:function(t){if(t=t||{},this._singleCanvas)return this._layers[0].dom;var e=new f("image",this,t.pixelRatio||this.dpr);e.initContext();var i=e.ctx;e.clearColor=t.backgroundColor,e.clear();for(var n=this.storage.getDisplayList(!0),r=0;rt;t++)this._add&&this._add(c[t]);else this._add&&this._add(c)}}},i}),e("echarts/data/List",[ie,"../model/Model","./DataDiffer",te,"../util/model"],function(t){function e(t){return v[Nt](t)||(t=[t]),t}function i(t,e){var i=t[s],n=new x(v.map(i,t.getDimensionInfo,t),t[l]);_(n,t,t._wrappedMethods);for(var r=n._storage={},a=t._storage,o=0;o=0?r[u]=new c.constructor(a[u][Kt]):r[u]=a[u]}return n}var n=Lt,r=typeof window===Lt?global:window,a=typeof r.Float64Array===n?Array:r.Float64Array,u=typeof r.Int32Array===n?Array:r.Int32Array,c={"float":a,"int":u,ordinal:Array,number:Array,time:Array},h=t("../model/Model"),f=t("./DataDiffer"),v=t(te),m=t("../util/model"),g=v[tt],y=["stackedOn","_nameList","_idList","_rawData"],_=function(t,e,i){v.each(y[Xt](i||[]),function(i){e.hasOwnProperty(i)&&(t[i]=e[i])})},x=function(t,e){t=t||["x","y"];for(var i={},n=[],r=0;r0&&(w+="__ec__"+h[M]),h[M]++),w&&(l[f]=w)}this._nameList=e,this._idList=l},b.count=function(){return this.indices[Kt]},b.get=function(t,e,i){var n=this._storage,r=this.indices[e],a=n[t]&&n[t][r];if(i){var o=this._dimensionInfos[t];if(o&&o.stackable)for(var s=this.stackedOn;s;){var u=s.get(t,e);(a>=0&&u>0||0>=a&&0>u)&&(a+=u),s=s.stackedOn}}return a},b.getValues=function(t,e,i){var n=[];v[Nt](t)||(i=e,e=t,t=this[s]);for(var r=0,a=t[Kt];a>r;r++)n.push(this.get(t[r],e,i));return n},b.hasValue=function(t){for(var e=this[s],i=this._dimensionInfos,n=0,r=e[Kt];r>n;n++)if(i[e[n]].type!==ot&&isNaN(this.get(e[n],t)))return!1;return!0},b.getDataExtent=function(t,e){var i=this._storage[t],n=this.getDimensionInfo(t);e=n&&n.stackable&&e;var r,a=(this._extent||(this._extent={}))[t+!!e];if(a)return a;if(i){for(var o=1/0,s=-(1/0),u=0,c=this.count();c>u;u++)r=this.get(t,u,e),o>r&&(o=r),r>s&&(s=r);return this._extent[t+e]=[o,s]}return[1/0,-(1/0)]},b.getSum=function(t,e){var i=this._storage[t],n=0;if(i)for(var r=0,a=this.count();a>r;r++){var o=this.get(t,r,e);isNaN(o)||(n+=o)}return n},b[Yt]=function(t,e){var i=this._storage,n=i[t],r=this.indices;if(n)for(var a=0,o=r[Kt];o>a;a++){var s=r[a];if(n[s]===e)return a}return-1},b.indexOfName=function(t){for(var e=this.indices,i=this._nameList,n=0,r=e[Kt];r>n;n++){var a=e[n];if(i[a]===t)return n}return-1},b.indexOfNearest=function(t,e,i){var n=this._storage,r=n[t];if(r){for(var a=Number.MAX_VALUE,o=-1,s=0,u=this.count();u>s;s++){var c=Math.abs(this.get(t,s,i)-e);a>=c&&(a=c,o=s)}return o}return-1},b[rt]=function(t){var e=this.indices[t];return null==e?-1:e},b[nt]=function(t){return this._nameList[this.indices[t]]||""},b.getId=function(t){return this._idList[this.indices[t]]||this[rt](t)+""},b.each=function(t,i,n,r){typeof t===Zt&&(r=n,n=i,i=t,t=[]),t=v.map(e(t),this.getDimension,this);var a=[],o=t[Kt],s=this.indices;r=r||this;for(var u=0;uc;c++)a[c]=this.get(t[c],u,n);a[c]=u,i.apply(r,a)}},b.filterSelf=function(t,i,n,r){typeof t===Zt&&(r=n,n=i,i=t,t=[]),t=v.map(e(t),this.getDimension,this);var a=[],o=[],s=t[Kt],u=this.indices;r=r||this;for(var c=0;ch;h++)o[h]=this.get(t[h],c,n);o[h]=c,l=i.apply(r,o)}l&&a.push(u[c])}return this.indices=a,this._extent={},this},b.mapArray=function(t,e,i,n){typeof t===Zt&&(n=i,i=e,e=t,t=[]);var r=[];return this.each(t,function(){r.push(e&&e.apply(this,arguments))},i,n),r},b.map=function(t,n,r,a){t=v.map(e(t),this.getDimension,this);var o=i(this,t),s=o.indices=this.indices,u=o._storage,c=[];return this.each(t,function(){var e=arguments[arguments[Kt]-1],i=n&&n.apply(this,arguments);if(null!=i){typeof i===Ut&&(c[0]=i,i=c);for(var r=0;rv;v+=f){f>p-v&&(f=p-v,l[Kt]=f);for(var m=0;f>m;m++){var g=u[v+m];l[m]=d[g],h[m]=g}var y=n(l),g=h[r(l,y)||0];d[g]=y,c.push(g)}return a},b[it]=function(t){var e=this[l];return t=this.indices[t],new h(this._rawData[t],e,e[yt])},b.diff=function(t){var e=this._idList,i=t&&t._idList;return new f(t?t.indices:[],this.indices,function(t){return i[t]||t+""},function(t){return e[t]||t+""})},b.getVisual=function(t){var e=this._visual;return e&&e[t]},b[p]=function(t,e){if(g(t))for(var i in t)t.hasOwnProperty(i)&&this[p](i,t[i]);else this._visual=this._visual||{},this._visual[t]=e},b.setLayout=function(t,e){if(g(t))for(var i in t)t.hasOwnProperty(i)&&this.setLayout(i,t[i]);else this._layout[t]=e},b.getLayout=function(t){return this._layout[t]},b[o]=function(t){return this._itemLayouts[t]},b.setItemLayout=function(t,e,i){this._itemLayouts[t]=i?v[Rt](this._itemLayouts[t]||{},e):e},b.getItemVisual=function(t,e,i){var n=this._itemVisuals[t],r=n&&n[e];return null!=r||i?r:this.getVisual(e)},b[d]=function(t,e,i){var n=this._itemVisuals[t]||{};if(this._itemVisuals[t]=n,g(e))for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);else n[e]=i};var w=function(t){t[ut]=this[ut],t[A]=this[A]};return b.setItemGraphicEl=function(t,e){var i=this[l];e&&(e[A]=t,e[ut]=i&&i[ut],"group"===e.type&&e[D](w,e)),this._graphicEls[t]=e},b[k]=function(t){return this._graphicEls[t]},b[L]=function(t,e){v.each(this._graphicEls,function(i,n){i&&t&&t.call(e,i,n)})},b.cloneShallow=function(){var t=v.map(this[s],this.getDimensionInfo,this),e=new x(t,this[l]);return e._storage=this._storage,_(e,this,this._wrappedMethods),e.indices=this.indices.slice(),e},b.wrapMethod=function(t,e){var i=this[t];typeof i===Zt&&(this._wrappedMethods=this._wrappedMethods||[],this._wrappedMethods.push(t),this[t]=function(){var t=i.apply(this,arguments);return e.call(this,t)})},x}),e("echarts/data/helper/completeDimensions",[ie,te],function(t){function e(t,e,a){if(!e)return t;var o=n(e[0]),s=r[Nt](o)&&o[Kt]||1;a=a||[];for(var u=0;s>u;u++)if(!t[u]){var c=a[u]||"extra"+(u-a[Kt]);t[u]=i(e,u)?{type:"ordinal",name:c}:c}return t}function i(t,e){for(var i=0,a=t[Kt];a>i;i++){var o=n(t[i]);if(!r[Nt](o))return!1;var o=o[e];if(null!=o&&isFinite(o))return!1;if(r[Q](o)&&"-"!==o)return!0}return!1}function n(t){return r[Nt](t)?t:r[tt](t)?t.value:t}var r=t(te);return e}),e("echarts/chart/helper/createListFromArray",[ie,"../../data/List","../../data/helper/completeDimensions",te,"../../util/model","../../CoordinateSystem"],function(t){function e(t){for(var e=0;e1){i=[];for(var a=0;r>a;a++)i[a]=n[e[a][0]]}else i=n.slice(0)}}return i}var c=t("../../data/List"),l=t("../../data/helper/completeDimensions"),h=t(te),f=t("../../util/model"),d=t("../../CoordinateSystem"),p=f.getDataItemValue,v=f.converDataValue,m={cartesian2d:function(t,e,i){var n=i[X]("xAxis",e.get("xAxisIndex")),s=i[X]("yAxis",e.get("yAxisIndex")),u=n.get("type"),c=s.get("type"),h=[{name:"x",type:o(u),stackable:r(u)},{name:"y",type:o(c),stackable:r(c)}];return l(h,t,["x","y","z"]),{dimensions:h,categoryAxisModel:u===a?n:c===a?s:null}},polar:function(t,e,i){var n=e.get("polarIndex")||0,s=function(t){return t.get("polarIndex")===n},u=i.findComponents({mainType:"angleAxis",filter:s})[0],c=i.findComponents({mainType:"radiusAxis",filter:s})[0],h=c.get("type"),f=u.get("type"),d=[{name:"radius",type:o(h),stackable:r(h)},{name:"angle",type:o(f),stackable:r(f)}];return l(d,t,[ht,"angle","value"]),{dimensions:d,categoryAxisModel:f===a?u:h===a?c:null}},geo:function(t,e,i){return{dimensions:l([{name:"lng"},{name:"lat"}],t,["lng","lat","value"])}}};return n}),e("echarts/chart/line/LineSeries",[ie,"../helper/createListFromArray","../../model/Series"],function(t){var e=t("../helper/createListFromArray"),i=t("../../model/Series");return i[Rt]({type:"series.line",dependencies:["grid","polar"],getInitialData:function(t,i){return e(t.data,this,i)},defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,hoverAnimation:!0,xAxisIndex:0,yAxisIndex:0,polarIndex:0,clipOverflow:!0,label:{normal:{position:"top"},emphasis:{position:"top"}},lineStyle:{normal:{width:2,type:"solid"}},symbol:"emptyCircle",symbolSize:4,showSymbol:!0,animationEasing:"linear"}})}),e("echarts/util/symbol",[ie,"./graphic",Ct],function(t){var e=t("./graphic"),i=t(Ct),n=e.extendShape({type:"triangle",shape:{cx:0,cy:0,width:0,height:0},buildPath:function(t,e){var i=e.cx,n=e.cy,r=e.width/2,a=e[Mt]/2;t[w](i,n-a),t.lineTo(i+r,n+a),t.lineTo(i-r,n+a),t[b]()}}),r=e.extendShape({type:"diamond",shape:{cx:0,cy:0,width:0,height:0},buildPath:function(t,e){var i=e.cx,n=e.cy,r=e.width/2,a=e[Mt]/2;t[w](i,n-a),t.lineTo(i+r,n),t.lineTo(i,n+a),t.lineTo(i-r,n),t[b]()}}),a=e.extendShape({type:"pin",shape:{x:0,y:0,width:0,height:0},buildPath:function(t,e){var i=e.x,n=e.y,r=e.width/5*3,a=Math.max(r,e[Mt]),o=r/2,s=o*o/(a-o),u=n-a+o+s,c=Math.asin(s/o),l=Math.cos(c)*o,h=Math.sin(c),f=Math.cos(c);t.arc(i,u,o,Math.PI-c,2*Math.PI+c);var d=.6*o,p=.7*o;t.bezierCurveTo(i+l-h*d,u+s+f*d,i,n-p,i,n),t.bezierCurveTo(i,n-p,i-l+h*d,u+s+f*d,i-l,u+s),t[b]()}}),o=e.extendShape({type:"arrow",shape:{x:0,y:0,width:0,height:0},buildPath:function(t,e){var i=e[Mt],n=e.width,r=e.x,a=e.y,o=n/3*2;t[w](r,a),t.lineTo(r+o,a+i),t.lineTo(r,a+i/4*3),t.lineTo(r-o,a+i),t.lineTo(r,a),t[b]()}}),s={line:e.Line,rect:e.Rect,roundRect:e.Rect,square:e.Rect,circle:e.Circle,diamond:r,pin:a,arrow:o,triangle:n},u={line:function(t,e,i,n,r){r.x1=t,r.y1=e+n/2,r.x2=t+i,r.y2=e+n/2},rect:function(t,e,i,n,r){r.x=t,r.y=e,r.width=i,r[Mt]=n},roundRect:function(t,e,i,n,r){r.x=t,r.y=e,r.width=i,r[Mt]=n,r.r=Math.min(i,n)/4},square:function(t,e,i,n,r){var a=Math.min(i,n);r.x=t,r.y=e,r.width=a,r[Mt]=a},circle:function(t,e,i,n,r){r.cx=t+i/2,r.cy=e+n/2,r.r=Math.min(i,n)/2},diamond:function(t,e,i,n,r){r.cx=t+i/2,r.cy=e+n/2,r.width=i,r[Mt]=n},pin:function(t,e,i,n,r){r.x=t+i/2,r.y=e+n/2,r.width=i,r[Mt]=n},arrow:function(t,e,i,n,r){r.x=t+i/2,r.y=e+n/2,r.width=i,r[Mt]=n},triangle:function(t,e,i,n,r){r.cx=t+i/2,r.cy=e+n/2,r.width=i,r[Mt]=n}},c={};for(var l in s)c[l]=new s[l];var h=e.extendShape({type:"symbol",shape:{symbolType:"",x:0,y:0,width:0,height:0},beforeBrush:function(){var t=this.style,e=this.shape;"pin"===e.symbolType&&t.textPosition===xt&&(t.textPosition=["50%","40%"],t[T]=Vt,t[C]=qt)},buildPath:function(t,e){var i=e.symbolType,n=c[i];"none"!==e.symbolType&&(n||(i="rect",n=c[i]),u[i](e.x,e.y,e.width,e[Mt],n.shape),n[x](t,n.shape))}}),f=function(t){if("image"!==this.type){var e=this.style,i=this.shape;i&&"line"===i.symbolType?e[zt]=t:this.__isEmptyBrush?(e[zt]=t,e.fill="#fff"):(e.fill&&(e.fill=t),e[zt]&&(e[zt]=t)),this.dirty()}},d={createSymbol:function(t,n,r,a,o,s){var u=0===t[Yt]("empty");u&&(t=t.substr(5,1)[Ft]()+t.substr(6));var c;return c=0===t[Yt]("image://")?new e.Image({style:{image:t.slice(8),x:n,y:r,width:a,height:o}}):0===t[Yt]("path://")?e.makePath(t.slice(7),{},new i(n,r,a,o)):new h({shape:{symbolType:t,x:n,y:r,width:a,height:o}}),c.__isEmptyBrush=u,c.setColor=f,c.setColor(s),c}};return d}),e("echarts/chart/helper/Symbol",[ie,te,"../../util/symbol","../../util/graphic","../../util/number"],function(t){function e(t){return r[Nt](t)||(t=[+t,+t]),t}function i(t,e){o.Group.call(this),this.updateData(t,e)}function n(t,e){this[q].drift(t,e)}var r=t(te),a=t("../../util/symbol"),o=t("../../util/graphic"),u=t("../../util/number"),c=i[ee];c._createSymbol=function(t,i,r){this[P]();var s=i[l],u=i.getItemVisual(r,"color"),c=a.createSymbol(t,-.5,-.5,1,1,u);c.attr({style:{strokeNoScale:!0},z2:100,culling:!0,scale:[0,0]}),c.drift=n;var h=e(i.getItemVisual(r,"symbolSize"));o.initProps(c,{scale:h},s),this._symbolType=t,this.add(c)},c.stopSymbolAnimation=function(t){this[K](0)[N](t)},c.getScale=function(){return this[K](0).scale},c.highlight=function(){this[K](0)[z](lt)},c.downplay=function(){this[K](0)[z](ct)},c.setZ=function(t,e){var i=this[K](0);i[v]=t,i.z=e},c.setDraggable=function(t){var e=this[K](0);e.draggable=t,e.cursor=t?"move":"pointer"},c.updateData=function(t,i){var n=t.getItemVisual(i,"symbol")||"circle",r=t[l],a=e(t.getItemVisual(i,"symbolSize"));if(n!==this._symbolType)this._createSymbol(n,t,i);else{var s=this[K](0);o[m](s,{scale:a},r)}this._updateCommon(t,i,a),this._seriesModel=r};var f=[h,ct],d=[h,lt],p=["label",ct],_=["label",lt];return c._updateCommon=function(t,i,n){var a=this[K](0),c=t[l],h=t[it](i),v=h[gt](f),m=t.getItemVisual(i,"color"),x=h[gt](d).getItemStyle();a[W]=h[Dt]("symbolRotate")*Math.PI/180||0;var b=h[Dt]("symbolOffset");if(b){var w=a[J];w[0]=u[Wt](b[0],n[0]),w[1]=u[Wt](b[1],n[1])}a.setColor(m),r[Rt](a.style,v.getItemStyle(["color"]));for(var M,S=h[gt](p),C=h[gt](_),T=a.style,L=t[s].slice(),k=L.pop();(M=t.getDimensionInfo(k).type)===ot||"time"===M;)k=L.pop();S.get("show")?(o.setText(T,S,m),T.text=r.retrieve(c.getFormattedLabel(i,ct),t.get(k,i))):T.text="",C[Dt]("show")?(o.setText(x,C,m),x.text=r.retrieve(c.getFormattedLabel(i,lt),t.get(k,i))):x.text="";var A=e(t.getItemVisual(i,"symbolSize"));if(a.off(y).off(g).off(lt).off(ct),o.setHoverStyle(a,x),h[Dt]("hoverAnimation")){var z=function(){var t=A[1]/A[0];this.animateTo({scale:[Math.max(1.1*A[0],A[0]+3),Math.max(1.1*A[1],A[1]+3*t)]},400,"elasticOut")},P=function(){this.animateTo({scale:A},400,"elasticOut")};a.on(y,z).on(g,P).on(lt,z).on(ct,P)}},c.fadeOut=function(t){var e=this[K](0);e.style.text="",o[m](e,{scale:[0,0]},this._seriesModel,t)},r[Bt](i,o.Group),i}),e("echarts/chart/helper/SymbolDraw",[ie,"../../util/graphic","./Symbol"],function(t){function e(t){this.group=new n.Group,this._symbolCtor=t||r}function i(t,e,i){var n=t[o](e);return n&&!isNaN(n[0])&&!isNaN(n[1])&&!(i&&i(e))&&"none"!==t.getItemVisual(e,"symbol")}var n=t("../../util/graphic"),r=t("./Symbol"),a=e[ee];return a.updateData=function(t,e){var r=this.group,a=t[l],s=this._data,u=this._symbolCtor;t.diff(s).add(function(n){var a=t[o](n);if(i(t,n,e)){var s=new u(t,n);s.attr(J,a),t.setItemGraphicEl(n,s),r.add(s)}})[U](function(c,l){var h=s[k](l),f=t[o](c);return i(t,c,e)?(h?(h.updateData(t,c),n[m](h,{position:f},a)):(h=new u(t,c),h.attr(J,f)),r.add(h),void t.setItemGraphicEl(c,h)):void r[I](h)})[I](function(t){var e=s[k](t);e&&e.fadeOut(function(){r[I](e)})}).execute(),this._data=t},a.updateLayout=function(){var t=this._data;t&&t[L](function(e,i){e.attr(J,t[o](i))})},a[I]=function(t){var e=this.group,i=this._data;i&&(t?i[L](function(t){t.fadeOut(function(){e[I](t)})}):e[P]())},e}),e("echarts/chart/line/lineAnimationDiff",[ie],function(t){function e(t){return t>=0?1:-1}function i(t,i,n){for(var a,o=t[H](),s=t.getOtherAxis(o),u=o.onZero?0:s.scale[r]()[0],c=s.dim,l="x"===c||c===ht?1:0,h=i.stackedOn,f=i.get(c,n);h&&e(h.get(c,n))===e(f);){a=h;break}var d=[];return d[l]=i.get(o.dim,n),d[1-l]=a?a.get(c,n,!0):u,t.dataToPoint(d)}function n(t,e){var i=[];return e.diff(t).add(function(t){i.push({cmd:"+",idx:t})})[U](function(t,e){i.push({cmd:"=",idx:e,idx1:t})})[I](function(t){i.push({cmd:"-",idx:t})}).execute(),i}return function(t,e,r,a,u,c){for(var l=n(t,e),h=[],f=[],d=[],p=[],v=[],m=[],g=[],y=c[s],_=0;__;_++){var x=e[y];if(y>=n||0>y||isNaN(x[0])||isNaN(x[1]))break;if(y===i)t[d>0?w:"lineTo"](x[0],x[1]),u(l,x);else if(m>0){var b=y-d,M=y+d,S=.5,C=e[b],T=e[M];if(d>0&&(y===f-1||isNaN(T[0])||isNaN(T[1]))||0>=d&&(0===y||isNaN(T[0])||isNaN(T[1])))u(h,x);else{(isNaN(T[0])||isNaN(T[1]))&&(T=x),r.sub(c,T,C);var L,k;if("x"===g||"y"===g){var A="x"===g?0:1;L=Math.abs(x[A]-C[A]),k=Math.abs(x[A]-T[A])}else L=r.dist(x,C),k=r.dist(x,T);S=k/(k+L),s(h,x,c,-m*(1-S))}a(l,l,v),o(l,l,p),a(h,h,v),o(h,h,p),t.bezierCurveTo(l[0],l[1],h[0],h[1],x[0],x[1]),s(l,x,c,m*S)}else t.lineTo(x[0],x[1]);y+=d}return _}function i(t,e){var i=[1/0,1/0],n=[-(1/0),-(1/0)];if(e)for(var r=0;rn[0]&&(n[0]=a[0]),a[1]>n[1]&&(n[1]=a[1])}return{min:e?i:n,max:e?n:i}}var n=t("zrender/graphic/Path"),r=t(kt),a=r.min,o=r.max,s=r.scaleAndAdd,u=r.copy,c=[],l=[],h=[];return{Polyline:n[Rt]({type:"ec-polyline",shape:{points:[],smooth:0,smoothConstraint:!0,smoothMonotone:null},style:{fill:null,stroke:"#000"},buildPath:function(t,n){for(var r=n.points,a=0,o=r[Kt],s=i(r,n.smoothConstraint);o>a;)a+=e(t,r,a,o,o,1,s.min,s.max,n.smooth,n.smoothMonotone)+1}}),Polygon:n[Rt]({type:"ec-polygon",shape:{points:[],stackedOnPoints:[],smooth:0,stackedOnSmooth:0,smoothConstraint:!0,smoothMonotone:null},buildPath:function(t,n){for(var r=n.points,a=n.stackedOnPoints,o=0,s=r[Kt],u=n.smoothMonotone,c=i(r,n.smoothConstraint),l=i(a,n.smoothConstraint);s>o;){var h=e(t,r,o,s,s,1,c.min,c.max,n.smooth,u);e(t,a,o+h-1,s,h,-1,l.min,l.max,n.stackedOnSmooth,u),o+=h+1,t[b]()}}})}}),e("echarts/chart/line/LineView",[ie,te,"../helper/SymbolDraw","../helper/Symbol","./lineAnimationDiff","../../util/graphic","./poly","../../view/Chart"],function(t){function e(t,e){if(t[Kt]===e[Kt]){for(var i=0;ie[0]?1:-1;e[0]+=n*i,e[1]-=n*i}return e}function u(t){return t>=0?1:-1}function c(t,e){var i=t[H](),n=t.getOtherAxis(i),a=i.onZero?0:n.scale[r]()[0],o=n.dim,s="x"===o||o===ht?1:0;return e.mapArray([o],function(n,r){for(var c,l=e.stackedOn;l&&u(l.get(o,r))===u(n);){c=l;break}var h=[];return h[s]=e.get(i.dim,r),h[1-s]=c?c.get(o,r,!0):a,t.dataToPoint(h)},!0)}function h(t,e){return null!=e[A]?e[A]:null!=e.name?t.indexOfName(e.name):void 0}function f(t,e,r){var a=s(t[n]("x")),o=s(t[n]("y")),u=t[H]()[i](),c=a[0],l=o[0],h=a[1]-c,f=o[1]-l;r.get("clipOverflow")||(u?(l-=f,f*=3):(c-=h,h*=3));var d=new w.Rect({shape:{x:c,y:l,width:h,height:f}});return e&&(d.shape[u?"width":Mt]=0,w.initProps(d,{shape:{width:h,height:f}},r)),d}function d(t,e,i){var n=t.getAngleAxis(),a=t.getRadiusAxis(),o=a[r](),s=n[r](),u=Math.PI/180,c=new w.Sector({shape:{cx:t.cx,cy:t.cy,r0:o[0],r:o[1],startAngle:-s[0]*u,endAngle:-s[1]*u,clockwise:n.inverse}});return e&&(c.shape.endAngle=-s[0]*u,w.initProps(c,{shape:{endAngle:-s[1]*u}},i)),c}function p(t,e,i){return"polar"===t.type?d(t,e,i):f(t,e,i)}var g=t(te),y=t("../helper/SymbolDraw"),x=t("../helper/Symbol"),b=t("./lineAnimationDiff"),w=t("../../util/graphic"),M=t("./poly"),S=t("../../view/Chart");return S[Rt]({type:"line",init:function(){var t=new w.Group,e=new y;this.group.add(e.group),this._symbolDraw=e,this._lineGroup=t},render:function(t,i,n){var r=t[Z],s=this.group,u=t[st](),h=t[gt]("lineStyle.normal"),f=t[gt]("areaStyle.normal"),d=u.mapArray(u[o],!0),v="polar"===r.type,m=this._coordSys,y=this._symbolDraw,x=this._polyline,b=this._polygon,w=this._lineGroup,M=t.get(F),S=!f.isEmpty(),C=c(r,u),T=t.get("showSymbol"),k=T&&!v&&!t.get("showAllSymbol")&&this._getSymbolIgnoreFunc(u,r),A=this._data;A&&A[L](function(t,e){t.__temp&&(s[I](t),A.setItemGraphicEl(e,null))}),T||y[I](),s.add(w),x&&m.type===r.type?(S&&!b?b=this._newPolygon(d,C,r,M):b&&!S&&(w[I](b),b=this._polygon=null),w.setClipPath(p(r,!1,t)),T&&y.updateData(u,k),u[L](function(t){t[N](!0)}),e(this._stackedOnPoints,C)&&e(this._points,d)||(M?this._updateAnimation(u,C,r,n):(x[_]({points:d}),b&&b[_]({points:d,stackedOnPoints:C})))):(T&&y.updateData(u,k),x=this._newPolyline(d,r,M),S&&(b=this._newPolygon(d,C,r,M)),w.setClipPath(p(r,!0,t))),x.setStyle(g[_t](h.getLineStyle(),{stroke:u.getVisual("color"),lineJoin:"bevel"}));var z=t.get("smooth");if(z=a(t.get("smooth")),x[_]({smooth:z,smoothMonotone:t.get("smoothMonotone")}),b){var P=u.stackedOn,D=0;if(b.style[At]=.7,b.setStyle(g[_t](f.getAreaStyle(),{fill:u.getVisual("color"), -lineJoin:"bevel"})),P){var O=P[l];D=a(O.get("smooth"))}b[_]({smooth:z,stackedOnSmooth:D,smoothMonotone:t.get("smoothMonotone")})}this._data=u,this._coordSys=r,this._stackedOnPoints=C,this._points=d},highlight:function(t,e,i,n){var r=t[st](),a=h(r,n);if(null!=a&&a>=0){var s=r[k](a);if(!s){var u=r[o](a);s=new x(r,a,i),s[J]=u,s.setZ(t.get(v),t.get("z")),s[R]=isNaN(u[0])||isNaN(u[1]),s.__temp=!0,r.setItemGraphicEl(a,s),s.stopSymbolAnimation(!0),this.group.add(s)}s.highlight()}else S[ee].highlight.call(this,t,e,i,n)},downplay:function(t,e,i,n){var r=t[st](),a=h(r,n);if(null!=a&&a>=0){var o=r[k](a);o&&(o.__temp?(r.setItemGraphicEl(a,null),this.group[I](o)):o.downplay())}else S[ee].downplay.call(this,t,e,i,n)},_newPolyline:function(t){var e=this._polyline;return e&&this._lineGroup[I](e),e=new M.Polyline({shape:{points:t},silent:!0,z2:10}),this._lineGroup.add(e),this._polyline=e,e},_newPolygon:function(t,e){var i=this._polygon;return i&&this._lineGroup[I](i),i=new M.Polygon({shape:{points:t,stackedOnPoints:e},silent:!0}),this._lineGroup.add(i),this._polygon=i,i},_getSymbolIgnoreFunc:function(t,e){var i=e.getAxesByScale(ot)[0];return i&&i.isLabelIgnored?g.bind(i.isLabelIgnored,i):void 0},_updateAnimation:function(t,e,i,n){var r=this._polyline,a=this._polygon,o=t[l],s=b(this._data,t,this._stackedOnPoints,e,this._coordSys,i);r.shape.points=s.current,w[m](r,{shape:{points:s.next}},o),a&&(a[_]({points:s.current,stackedOnPoints:s.stackedOnCurrent}),w[m](a,{shape:{points:s.next,stackedOnPoints:s.stackedOnNext}},o));for(var u=[],c=s.status,h=0;he&&(e=t[i]);return e},min:function(t){for(var e=1/0,i=0;i1){var f;typeof a===jt?f=t[a]:typeof a===Zt&&(f=a),f&&(n=n.downSample(u.dim,1/h,f,e),i.setData(n))}}},this)}}),e("echarts/chart/line",[ie,te,"../echarts","./line/LineSeries","./line/LineView","../visual/symbol","../layout/points","../processor/dataSample"],function(t){var e=t(te),i=t("../echarts");t("./line/LineSeries"),t("./line/LineView"),i[u]("chart",e.curry(t("../visual/symbol"),"line","circle","line")),i[c](e.curry(t("../layout/points"),"line")),i.registerProcessor("statistic",e.curry(t("../processor/dataSample"),"line"))}),e("echarts/scale/Scale",[ie,dt],function(t){function e(){this._extent=[1/0,-(1/0)],this._interval=0,this.init&&this.init.apply(this,arguments)}var i=t(dt),n=e[ee];return n.parse=function(t){return t},n[S]=function(t){var e=this._extent;return t>=e[0]&&t<=e[1]},n.normalize=function(t){var e=this._extent;return e[1]===e[0]?.5:(t-e[0])/(e[1]-e[0])},n.scale=function(t){var e=this._extent;return t*(e[1]-e[0])+e[0]},n.unionExtent=function(t){var e=this._extent;t[0]e[1]&&(e[1]=t[1])},n[r]=function(){return this._extent.slice()},n.setExtent=function(t,e){var i=this._extent;isNaN(t)||(i[0]=t),isNaN(e)||(i[1]=e)},n.getTicksLabels=function(){for(var t=[],e=this.getTicks(),i=0;ie[1]&&(e[1]=t[1]),o[ee].setExtent.call(this,e[0],e[1])},getInterval:function(){return this._interval||this.niceTicks(),this._interval},setInterval:function(t){this._interval=t,this._niceExtent=this._extent.slice()},getTicks:function(){this._interval||this.niceTicks();var t=this._interval,i=this._extent,n=[],r=1e4;if(t){var a=this._niceExtent;i[0]r)return[];i[1]>a[1]&&n.push(i[1])}return n},getTicksLabels:function(){for(var t=[],e=this.getTicks(),i=0;i=n)){var o=Math.pow(10,Math.floor(Math.log(n/t)/Math.LN10)),s=t/n*o;.15>=s?o*=10:.3>=s?o*=5:.45>=s?o*=3:.75>=s&&(o*=2);var u=[e.round(a(i[0]/o)*o),e.round(r(i[1]/o)*o)];this._interval=o,this._niceExtent=u}},niceExtent:function(t,i,n){var o=this._extent;if(o[0]===o[1])if(0!==o[0]){var s=o[0]/2;o[0]-=s,o[1]+=s}else o[1]=1;o[1]===-(1/0)&&o[0]===1/0&&(o[0]=0,o[1]=1),this.niceTicks(t,i,n);var u=this._interval;i||(o[0]=e.round(r(o[0]/u)*u)),n||(o[1]=e.round(a(o[1]/u)*u))}});return o[wt]=function(){return new o},o}),e("echarts/scale/Time",[ie,te,"../util/number","../util/format","./Interval"],function(t){var e=t(te),i=t("../util/number"),n=t("../util/format"),r=t("./Interval"),a=r[ee],o=Math.ceil,s=Math.floor,u=864e5,c=function(t,e,i,n){for(;n>i;){var r=i+n>>>1;t[r][2]=p?d*=10:.3>=p?d*=5:.75>=p&&(d*=2),l*=d}var v=[o(e[0]/l)*l,s(e[1]/l)*l];this._stepLvl=u,this._interval=l,this._niceExtent=v},parse:function(t){return+i.parseDate(t)}});e.each([S,"normalize"],function(t){l[ee][t]=function(e){return a[t].call(this,this.parse(e))}});var h=[["hh:mm:ss",1,1e3],["hh:mm:ss",5,5e3],["hh:mm:ss",10,1e4],["hh:mm:ss",15,15e3],["hh:mm:ss",30,3e4],["hh:mm\nMM-dd",1,6e4],["hh:mm\nMM-dd",5,3e5],["hh:mm\nMM-dd",10,6e5],["hh:mm\nMM-dd",15,9e5],["hh:mm\nMM-dd",30,18e5],["hh:mm\nMM-dd",1,36e5],["hh:mm\nMM-dd",2,72e5],["hh:mm\nMM-dd",6,216e5],["hh:mm\nMM-dd",12,432e5],["MM-dd\nyyyy",1,u],["week",7,7*u],["month",1,31*u],["quarter",3,380*u/4],["half-year",6,380*u/2],["year",1,380*u]];return l[wt]=function(){return new l},l}),e("echarts/scale/Log",[ie,te,"./Scale","../util/number","./Interval"],function(t){var e=t(te),i=t("./Scale"),n=t("../util/number"),a=t("./Interval"),o=i[ee],s=a[ee],u=Math.floor,c=Math.ceil,l=Math.pow,h=10,f=Math.log,d=i[Rt]({type:"log",getTicks:function(){return e.map(s.getTicks.call(this),function(t){return n.round(l(h,t))})},getLabel:s.getLabel,scale:function(t){return t=o.scale.call(this,t),l(h,t)},setExtent:function(t,e){t=f(t)/f(h),e=f(e)/f(h),s.setExtent.call(this,t,e)},getExtent:function(){var t=o[r].call(this);return t[0]=l(h,t[0]),t[1]=l(h,t[1]),t},unionExtent:function(t){t[0]=f(t[0])/f(h),t[1]=f(t[1])/f(h),o.unionExtent.call(this,t)},niceTicks:function(t){t=t||10;var e=this._extent,i=e[1]-e[0];if(!(i===1/0||0>=i)){var r=l(10,u(f(i/t)/Math.LN10)),a=t/i*r;.5>=a&&(r*=10);var o=[n.round(c(e[0]/r)*r),n.round(u(e[1]/r)*r)];this._interval=r,this._niceExtent=o}},niceExtent:s.niceExtent});return e.each([S,"normalize"],function(t){d[ee][t]=function(e){return e=f(e)/f(h),o[t].call(this,e)}}),d[wt]=function(){return new d},d}),e("echarts/coord/axisHelper",[ie,"../scale/Ordinal","../scale/Interval","../scale/Time","../scale/Log","../scale/Scale","../util/number",te,"zrender/contain/text"],function(t){var e=t("../scale/Ordinal"),i=t("../scale/Interval");t("../scale/Time"),t("../scale/Log");var n=t("../scale/Scale"),o=t("../util/number"),s=t(te),u=t("zrender/contain/text"),c={};return c.niceScaleExtent=function(t,e){var i=t.scale,n=i[r](),a=n[1]-n[0];if(i.type===ot)return void(isFinite(a)||i.setExtent(0,0));var u=e.get("min"),c=e.get("max"),l=!e.get("scale"),h=e.get("boundaryGap");s[Nt](h)||(h=[h||0,h||0]),h[0]=o[Wt](h[0],1),h[1]=o[Wt](h[1],1);var f=!0,d=!0;null==u&&(u=n[0]-h[0]*a,f=!1),null==c&&(c=n[1]+h[1]*a,d=!1),"dataMin"===u&&(u=n[0]),"dataMax"===c&&(c=n[1]),l&&(u>0&&c>0&&!f&&(u=0),0>u&&0>c&&!d&&(c=0)),i.setExtent(u,c),i.niceExtent(e.get("splitNumber"),f,d);var p=e.get("interval");null!=p&&i.setInterval&&i.setInterval(p)},c.createScaleByModel=function(t,r){if(r=r||t.get("type"))switch(r){case a:return new e(t.getCategories(),[1/0,-(1/0)]);case"value":return new i;default:return(n[It](r)||i)[wt](t)}},c.ifAxisCrossZero=function(t){var e=t.scale[r](),i=e[0],n=e[1];return!(i>0&&n>0||0>i&&0>n)},c.getAxisLabelInterval=function(t,e,i,n){var r,a=0,o=0,s=1;e[Kt]>40&&(s=Math.round(e[Kt]/40));for(var c=0;c1?s:a*s},c.getFormattedLabels=function(t,e){var i=t.scale,n=i.getTicksLabels(),r=i.getTicks();return typeof e===jt?(e=function(t){return function(e){return t[Ht]("{value}",e)}}(e),s.map(n,e)):typeof e===Zt?s.map(r,function(n,r){return e(t.type===a?i.getLabel(n):n,r)},this):n},c}),e("echarts/coord/cartesian/Cartesian",[ie,te],function(t){function e(t){return this._axes[t]}var i=t(te),n=function(t){this._axes={},this._dimList=[],this.name=t||""};return n[ee]={constructor:n,type:"cartesian",getAxis:function(t){return this._axes[t]},getAxes:function(){return i.map(this._dimList,e,this)},getAxesByScale:function(t){return t=t[Ft](),i[Jt](this.getAxes(),function(e){return e.scale.type===t})},addAxis:function(t){var e=t.dim;this._axes[e]=t,this._dimList.push(e)},dataToCoord:function(t){return this._dataCoordConvert(t,"dataToCoord")},coordToData:function(t){return this._dataCoordConvert(t,"coordToData")},_dataCoordConvert:function(t,e){for(var i=this._dimList,n=t instanceof Array?[]:{},r=0;r=i&&n>=t},containData:function(t){return this[S](this.dataToCoord(t))},getExtent:function(){var t=this._extent.slice();return t},getPixelPrecision:function(t){return i.getPixelPrecision(t||this.scale[r](),this._extent)},setExtent:function(t,e){var i=this._extent;i[0]=t,i[1]=e},dataToCoord:function(t,i){var r=this._extent,a=this.scale;return t=a.normalize(t),this.onBand&&a.type===ot&&(r=r.slice(),e(r,a.count())),n(t,o,r,i)},coordToData:function(t,i){var r=this._extent,a=this.scale;this.onBand&&a.type===ot&&(r=r.slice(),e(r,a.count()));var s=n(t,r,o,i);return this.scale.scale(s)},getTicksCoords:function(){if(this.onBand){for(var t=this.getBands(),e=[],i=0;is;s++)e.push([o*s/i+n,o*(s+1)/i+n]);return e},getBandWidth:function(){var t=this._extent,e=this.scale[r](),i=e[1]-e[0]+(this.onBand?1:0),n=Math.abs(t[1]-t[0]);return Math.abs(n)/i}},s}),e("echarts/coord/cartesian/axisLabelInterval",[ie,te,"../axisHelper"],function(t){var e=t(te),n=t("../axisHelper");return function(t){var r=t.model,o=r[gt]("axisLabel"),s=o.get("interval");return t.type!==a||"auto"!==s?"auto"===s?0:s:n.getAxisLabelInterval(e.map(t.scale.getTicks(),t.dataToCoord,t),r.getFormattedLabels(),o[gt](mt)[pt](),t[i]())}}),e("echarts/coord/cartesian/Axis2D",[ie,te,"../Axis","./axisLabelInterval"],function(t){var e=t(te),i=t("../Axis"),n=t("./axisLabelInterval"),o=function(t,e,n,r,a){i.call(this,t,e,n),this.type=r||"value",this[J]=a||Gt};return o[ee]={constructor:o,index:0,onZero:!1,model:null,isHorizontal:function(){var t=this[J];return"top"===t||t===Gt},getGlobalExtent:function(){var t=this[r]();return t[0]=this.toGlobalCoord(t[0]),t[1]=this.toGlobalCoord(t[1]),t},getLabelInterval:function(){var t=this._labelInterval;return t||(t=this._labelInterval=n(this)),t},isLabelIgnored:function(t){if(this.type===a){var e=this.getLabelInterval();return typeof e===Zt&&!e(t,this.scale.getLabel(t))||t%(e+1)}},toLocalCoord:null,toGlobalCoord:null},e[Bt](o,i),o}),e("echarts/coord/axisDefault",[ie,te],function(t){var e=t(te),i={show:!0,zlevel:0,z:0,inverse:!1,name:"",nameLocation:"end",nameTextStyle:{},nameGap:15,axisLine:{show:!0,onZero:!0,lineStyle:{color:"#333",width:1,type:"solid"}},axisTick:{show:!0,inside:!1,length:5,lineStyle:{color:"#333",width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{color:"#333",fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}}},n=e.merge({boundaryGap:!0,axisTick:{interval:"auto"},axisLabel:{interval:"auto"}},i),r=e[_t]({boundaryGap:[0,0],splitNumber:5},i),a=e[_t]({scale:!0,min:"dataMin",max:"dataMax"},r),o=e[_t]({},r);return o.scale=!0,{categoryAxis:n,valueAxis:r,timeAxis:a,logAxis:o}}),e("echarts/coord/axisModelCreator",[ie,"./axisDefault",te,"../model/Component","../util/layout"],function(t){var e=t("./axisDefault"),i=t(te),n=t("../model/Component"),r=t("../util/layout"),o=["value",a,"time","log"];return function(t,a,s,u){i.each(o,function(n){a[Rt]({type:t+"Axis."+n,mergeDefaultAndTheme:function(e,a){var o=this.layoutMode,u=o?r.getLayoutParams(e):{},c=a.getTheme();i.merge(e,c.get(n+"Axis")),i.merge(e,this.getDefaultOption()),e.type=s(t,e),o&&r.mergeLayoutParam(e,u,o)},defaultOption:i.mergeAll([{},e[n+"Axis"],u],!0)})}),n.registerSubTypeDefaulter(t+"Axis",i.curry(s,t))}}),e("echarts/coord/axisModelCommonMixin",[ie,te,"./axisHelper"],function(t){function e(t){return r[tt](t)&&null!=t.value?t.value:t}function i(){return this.get("type")===a&&r.map(this.get("data"),e)}function n(){return o.getFormattedLabels(this.axis,this.get("axisLabel.formatter"))}var r=t(te),o=t("./axisHelper");return{getFormattedLabels:n,getCategories:i}}),e("echarts/coord/cartesian/AxisModel",[ie,"../../model/Component",te,"../axisModelCreator","../axisModelCommonMixin"],function(t){function e(t,e){return e.type||(e.data?a:"value")}var i=t("../../model/Component"),n=t(te),r=t("../axisModelCreator"),o=i[Rt]({type:"cartesian2dAxis",axis:null,setNeedsCrossZero:function(t){this[ft].scale=!t},setMin:function(t){this[ft].min=t},setMax:function(t){this[ft].max=t}});n.merge(o[ee],t("../axisModelCommonMixin"));var s={gridIndex:0};return r("x",o,e,s),r("y",o,e,s),o}),e("echarts/coord/cartesian/GridModel",[ie,"./AxisModel","../../model/Component"],function(t){t("./AxisModel");var e=t("../../model/Component");return e[Rt]({type:"grid",dependencies:["xAxis","yAxis"],layoutMode:"box",coordinateSystem:null,defaultOption:{show:!1,zlevel:0,z:0,left:"10%",top:60,right:"10%",bottom:60,containLabel:!1,backgroundColor:"rgba(0,0,0,0)",borderWidth:1,borderColor:"#ccc"}})}),e("echarts/coord/cartesian/Grid",[ie,"exports","module","../../util/layout","../../coord/axisHelper",te,"./Cartesian2D","./Axis2D","./GridModel","../../CoordinateSystem"],function(t,e){function o(t,e,i){return i[X]("grid",t.get("gridIndex"))===e}function u(t){var e,i=t.model,n=i.getFormattedLabels(),r=1,a=n[Kt];a>40&&(r=Math.ceil(a/40));for(var o=0;a>o;o+=r)if(!t.isLabelIgnored(o)){var s=i.getTextRect(n[o]);e?e.union(s):e=s}return e}function c(t,e,i){this._coordsMap={},this._coordsList=[],this._axesMap={},this._axesList=[],this._initCartesian(t,e,i),this._model=t}function l(t,e){var i=t[r](),n=i[0]+i[1];t.toGlobalCoord="x"===t.dim?function(t){return t+e}:function(t){return n-t+e},t.toLocalCoord="x"===t.dim?function(t){return t-e}:function(t){return n-t+e}}var h=t("../../util/layout"),f=t("../../coord/axisHelper"),d=t(te),p=t("./Cartesian2D"),v=t("./Axis2D"),m=d.each,g=f.ifAxisCrossZero,y=f.niceScaleExtent;t("./GridModel");var _=c[ee];return _.type="grid",_.getRect=function(){return this._rect},_[U]=function(t,e){function i(t){var e=n[t];for(var i in e){var r=e[i];if(r&&(r.type===a||!g(r)))return!0}return!1}var n=this._axesMap;this._updateScale(t,this._model),m(n.x,function(t){y(t,t.model)}),m(n.y,function(t){y(t,t.model)}),m(n.x,function(t){i("y")&&(t.onZero=!1)}),m(n.y,function(t){i("x")&&(t.onZero=!1)}),this.resize(this._model,e)},_.resize=function(t,e){function n(){m(a,function(t){var e=t[i](),n=e?[0,r.width]:[0,r[Mt]],a=t.inverse?1:0;t.setExtent(n[a],n[1-a]),l(t,e?r.x:r.y)})}var r=h.getLayoutRect(t.getBoxLayoutParams(),{width:e[Y](),height:e[j]()});this._rect=r;var a=this._axesList;n(),t.get("containLabel")&&(m(a,function(t){if(!t.model.get("axisLabel.inside")){var e=u(t);if(e){var n=t[i]()?Mt:"width",a=t.model.get("axisLabel.margin");r[n]-=e[n]+a,"top"===t[J]?r.y+=e[Mt]+a:"left"===t[J]&&(r.x+=e.width+a)}}}),n())},_[n]=function(t,e){var i=this._axesMap[t];if(null!=i){if(null==e)for(var n in i)return i[n];return i[e]}},_.getCartesian=function(t,e){var i="x"+t+"y"+e;return this._coordsMap[i]},_._initCartesian=function(t,e,i){function n(i){return function(n,c){if(o(n,t,e)){var l=n.get(J);"x"===i?("top"!==l&&l!==Gt&&(l=Gt),r[l]&&(l="top"===l?Gt:"top")):("left"!==l&&"right"!==l&&(l="left"),r[l]&&(l="left"===l?"right":"left")),r[l]=!0;var h=new v(i,f.createScaleByModel(n),[0,0],n.get("type"),l),d=h.type===a;h.onBand=d&&n.get("boundaryGap"),h.inverse=n.get("inverse"),h.onZero=n.get("axisLine.onZero"),n.axis=h,h.model=n,h.index=c,this._axesList.push(h),s[i][c]=h,u[i]++}}}var r={left:!1,right:!1,top:!1,bottom:!1},s={x:{},y:{}},u={x:0,y:0};return e.eachComponent("xAxis",n("x"),this),e.eachComponent("yAxis",n("y"),this),u.x&&u.y?(this._axesMap=s,void m(s.x,function(t,e){m(s.y,function(i,n){var r="x"+e+"y"+n,a=new p(r);a.grid=this,this._coordsMap[r]=a,this._coordsList.push(a),a.addAxis(t),a.addAxis(i)},this)},this)):(this._axesMap={},void(this._axesList=[]))},_._updateScale=function(t,e){function i(t,e,i){m(i.coordDimToDataDim(e.dim),function(i){e.scale.unionExtent(t.getDataExtent(i,e.scale.type!==ot))})}d.each(this._axesList,function(t){t.scale.setExtent(1/0,-(1/0))}),t.eachSeries(function(r){if("cartesian2d"===r.get(Z)){var a=r.get("xAxisIndex"),s=r.get("yAxisIndex"),u=t[X]("xAxis",a),c=t[X]("yAxis",s);if(!o(u,e,t)||!o(c,e,t))return;var l=this.getCartesian(a,s),h=r[st](),f=l[n]("x"),d=l[n]("y");"list"===h.type&&(i(h,f,r),i(h,d,r))}},this)},c[wt]=function(t,e){var i=[];return t.eachComponent("grid",function(n,r){var a=new c(n,t,e);a.name="grid_"+r,a.resize(n,e),n[Z]=a,i.push(a)}),t.eachSeries(function(e){if("cartesian2d"===e.get(Z)){var n=e.get("xAxisIndex"),r=t[X]("xAxis",n),a=i[r.get("gridIndex")];e[Z]=a.getCartesian(n,e.get("yAxisIndex"))}}),i},c[s]=p[ee][s],t("../../CoordinateSystem").register("cartesian2d",c),c}),e("echarts/chart/bar/BarSeries",[ie,"../../model/Series","../helper/createListFromArray"],function(t){var e=t("../../model/Series"),n=t("../helper/createListFromArray");return e[Rt]({type:"series.bar",dependencies:["grid","polar"],getInitialData:function(t,e){return n(t.data,this,e)},getMarkerPosition:function(t){var e=this[Z];if(e){var n=e.dataToPoint(t),r=this[st](),a=r.getLayout("offset"),o=r.getLayout("size"),s=e[H]()[i]()?0:1;return n[s]+=a+o/2,n}return[NaN,NaN]},defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,xAxisIndex:0,yAxisIndex:0,barMinHeight:0,itemStyle:{normal:{barBorderColor:"#fff",barBorderWidth:0},emphasis:{barBorderColor:"#fff",barBorderWidth:0}}}})}),e("echarts/chart/bar/barItemStyle",[ie,"../../model/mixin/makeStyleMapper"],function(t){return{getBarItemStyle:t("../../model/mixin/makeStyleMapper")([["fill","color"],[zt,"barBorderColor"],[Pt,"barBorderWidth"],[At],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]])}}),e("echarts/chart/bar/BarView",[ie,te,"../../util/graphic","../../model/Model","./barItemStyle","../../echarts"],function(t){function e(t,e){var i=t.width>0?1:-1,n=t[Mt]>0?1:-1;e=Math.min(e,Math.abs(t.width),Math.abs(t[Mt])),t.x+=i*e/2,t.y+=n*e/2,t.width-=i*e,t[Mt]-=n*e}var n=t(te),r=t("../../util/graphic");return n[Rt](t("../../model/Model")[ee],t("./barItemStyle")),t("../../echarts").extendChartView({type:"bar",render:function(t,e,i){var n=t.get(Z);return"cartesian2d"===n&&this._renderOnCartesian(t,e,i),this.group},_renderOnCartesian:function(t,a,s){function u(i,a){var s=l[o](i),u=l[it](i).get(y)||0;e(s,u);var c=new r.Rect({shape:n[Rt]({},s)});if(g){var h=c.shape,f=v?Mt:"width",d={};h[f]=0,d[f]=s[f],r[a?m:"initProps"](c,{shape:d},t)}return c}var c=this.group,l=t[st](),f=this._data,d=t[Z],p=d[H](),v=p[i](),g=t.get(F),y=[h,ct,"barBorderWidth"];l.diff(f).add(function(t){if(l.hasValue(t)){var e=u(t);l.setItemGraphicEl(t,e),c.add(e)}})[U](function(i,n){var a=f[k](n);if(!l.hasValue(i))return void c[I](a);a||(a=u(i,!0));var s=l[o](i),h=l[it](i).get(y)||0;e(s,h),r[m](a,{shape:s},t),l.setItemGraphicEl(i,a),c.add(a)})[I](function(e){var i=f[k](e);i&&(i.style.text="",r[m](i,{shape:{width:0}},t,function(){c[I](i)}))}).execute(),this._updateStyle(t,l,v),this._data=l},_updateStyle:function(t,e,i){function a(t,e,i,n,a){r.setText(t,e,i),t.text=n,"outside"===t.textPosition&&(t.textPosition=a)}e[L](function(s,u){var c=e[it](u),l=e.getItemVisual(u,"color"),h=e[o](u),f=c[gt]("itemStyle.normal"),d=c[gt]("itemStyle.emphasis").getItemStyle();s[_]("r",f.get("barBorderRadius")||0),s.setStyle(n[_t]({fill:l},f.getBarItemStyle()));var p=i?h[Mt]>0?Gt:"top":h.width>0?"left":"right",v=c[gt]("label.normal"),m=c[gt]("label.emphasis"),g=s.style;v.get("show")?a(g,v,l,n.retrieve(t.getFormattedLabel(u,ct),t[at](u)),p):g.text="",m.get("show")?a(d,m,l,n.retrieve(t.getFormattedLabel(u,lt),t[at](u)),p):d.text="",r.setHoverStyle(s,d)})},remove:function(t,e){var i=this.group;t.get(F)?this._data&&this._data[L](function(e){e.style.text="",r[m](e,{shape:{width:0}},t,function(){i[I](e)})}):i[P]()}})}),e("echarts/layout/barGrid",[ie,te,"../util/number"],function(t){function e(t){return t.get("stack")||"__ec_stack_"+t[ut]}function n(t,i){var n={};a.each(t,function(t,i){var r=t[Z],a=r[H](),o=n[a.index]||{remainedWidth:a.getBandWidth(),autoWidthCount:0,categoryGap:"20%",gap:"30%",axis:a,stacks:{}},s=o.stacks;n[a.index]=o;var u=e(t);s[u]||o.autoWidthCount++,s[u]=s[u]||{width:0,maxWidth:0};var c=t.get("barWidth"),l=t.get("barMaxWidth"),h=t.get("barGap"),f=t.get("barCategoryGap");c&&!s[u].width&&(c=Math.min(o.remainedWidth,c),s[u].width=c,o.remainedWidth-=c),l&&(s[u].maxWidth=l),null!=h&&(o.gap=h),null!=f&&(o.categoryGap=f)});var r={};return a.each(n,function(t,e){r[e]={};var i=t.stacks,n=t.axis,o=n.getBandWidth(),u=s(t.categoryGap,o),c=s(t.gap,1),l=t.remainedWidth,h=t.autoWidthCount,f=(l-u)/(h+(h-1)*c);f=Math.max(f,0),a.each(i,function(t,e){var i=t.maxWidth;!t.width&&i&&f>i&&(i=Math.min(i,l),l-=i,t.width=i,h--)}),f=(l-u)/(h+(h-1)*c),f=Math.max(f,0);var d,p=0;a.each(i,function(t,e){t.width||(t.width=f),d=t,p+=t.width*(1+c)}),d&&(p-=d.width*c);var v=-p/2;a.each(i,function(t,i){r[e][i]=r[e][i]||{offset:v,width:t.width},v+=t.width*(1+c)})}),r}function r(t,r,o){var s=n(a[Jt](r.getSeriesByType(t),function(t){return!r.isSeriesFiltered(t)&&t[Z]&&"cartesian2d"===t[Z].type})),u={};r[f](t,function(t){var n=t[st](),r=t[Z],a=r[H](),o=e(t),c=s[a.index][o],l=c.offset,h=c.width,f=r.getOtherAxis(a),d=t.get("barMinHeight")||0,p=a.onZero?f.toGlobalCoord(f.dataToCoord(0)):f.getGlobalExtent()[0],v=r.dataToPoints(n,!0);u[o]=u[o]||[],n.setLayout({offset:l,size:h}),n.each(f.dim,function(t,e){if(!isNaN(t)){u[o][e]||(u[o][e]={p:p,n:p});var r,a,s,c,m=t>=0?"p":"n",g=v[e],y=u[o][e][m];f[i]()?(r=y,a=g[1]+l,s=g[0]-y,c=h,Math.abs(s)s?-1:1)*d),u[o][e][m]+=s):(r=g[0]+l,a=y,s=h,c=g[1]-y,Math.abs(c)=c?-1:1)*d),u[o][e][m]+=c),n.setItemLayout(e,{x:r,y:a,width:s,height:c})}},!0)},this)}var a=t(te),o=t("../util/number"),s=o[Wt];return r}),e("echarts/chart/bar",[ie,te,"../coord/cartesian/Grid","./bar/BarSeries","./bar/BarView","../layout/barGrid","../echarts"],function(t){var e=t(te);t("../coord/cartesian/Grid"),t("./bar/BarSeries"),t("./bar/BarView");var i=t("../layout/barGrid"),n=t("../echarts");n[c](e.curry(i,"bar")),n[u]("chart",function(t){t[f]("bar",function(t){var e=t[st]();e[p]("legendSymbol","roundRect")})})}),e("echarts/chart/helper/dataSelectableMixin",[ie,te],function(t){var e=t(te);return{updateSelectedMap:function(){var t=this[ft];this._dataOptMap=e.reduce(t.data,function(t,e){return t[e.name]=e,t},{})},select:function(t){var i=this._dataOptMap,n=i[t],r=this.get("selectedMode");"single"===r&&e.each(i,function(t){t.selected=!1}),n&&(n.selected=!0)},unSelect:function(t){var e=this._dataOptMap[t];e&&(e.selected=!1)},toggleSelected:function(t){var e=this._dataOptMap[t];return null!=e?(this[e.selected?"unSelect":"select"](t),e.selected):void 0},isSelected:function(t){var e=this._dataOptMap[t];return e&&e.selected}}}),e("echarts/chart/pie/PieSeries",[ie,"../../data/List",te,"../../util/model","../../data/helper/completeDimensions","../helper/dataSelectableMixin","../../echarts"],function(t){var e=t("../../data/List"),i=t(te),n=t("../../util/model"),r=t("../../data/helper/completeDimensions"),a=t("../helper/dataSelectableMixin"),o=t("../../echarts").extendSeriesModel({type:"series.pie",init:function(t){o.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._dataBeforeProcessed},this.updateSelectedMap(),this._defaultLabelLine(t)},mergeOption:function(t){o.superCall(this,"mergeOption",t),this.updateSelectedMap()},getInitialData:function(t,i){var n=r(["value"],t.data),a=new e(n,this);return a.initData(t.data),a},getDataParams:function(t){var e=this._data,i=o.superCall(this,et,t),n=e.getSum("value");return i.percent=n?+(e.get("value",t)/n*100).toFixed(2):0,i.$vars.push("percent"),i},_defaultLabelLine:function(t){n.defaultEmphasis(t.labelLine,["show"]);var e=t.labelLine[ct],i=t.labelLine[lt];e.show=e.show&&t.label[ct].show,i.show=i.show&&t.label[lt].show},defaultOption:{zlevel:0,z:2,legendHoverLink:!0,hoverAnimation:!0,center:["50%","50%"],radius:[0,"75%"],clockwise:!0,startAngle:90,minAngle:0,selectedOffset:10,avoidLabelOverlap:!0,label:{normal:{rotate:!1,show:!0,position:"outer"},emphasis:{}},labelLine:{normal:{show:!0,length:20,length2:5,smooth:!1,lineStyle:{width:1,type:"solid"}}},itemStyle:{normal:{borderColor:"rgba(0,0,0,0)",borderWidth:1},emphasis:{borderColor:"rgba(0,0,0,0)",borderWidth:1}},animationEasing:"cubicOut",data:[]}});return i.mixin(o,a),o}),e("echarts/chart/pie/PieView",[ie,"../../util/graphic",te,"../../view/Chart"],function(t){function e(t,e,n,r){var a=e[st](),s=this[A],u=a[nt](s),c=e.get("selectedOffset");r.dispatchAction({type:"pieToggleSelect",from:t,name:u,seriesId:e.id}),a.each(function(t){i(a[k](t),a[o](t),e.isSelected(a[nt](t)),c,n)})}function i(t,e,i,n,r){var a=(e.startAngle+e.endAngle)/2,o=Math.cos(a),s=Math.sin(a),u=i?n:0,c=[o*u,s*u];r?t[E]().when(200,{position:c}).start("bounceOut"):t.attr(J,c)}function n(t,e){function i(){o[R]=o.hoverIgnore,s[R]=s.hoverIgnore}function n(){o[R]=o.normalIgnore,s[R]=s.normalIgnore}a.Group.call(this);var r=new a.Sector({z2:2}),o=new a.Polyline,s=new a.Text;this.add(r),this.add(o),this.add(s),this.updateData(t,e,!0),this.on(lt,i).on(ct,n).on(y,i).on(g,n)}function r(t,e,i,n){var r=n[gt](mt),a=n.get(J),o=a===xt||"inner"===a;return{fill:r.getTextColor()||(o?"#fff":t.getItemVisual(e,"color")),textFont:r[pt](),text:s.retrieve(t[l].getFormattedLabel(e,i),t[nt](e))}}var a=t("../../util/graphic"),s=t(te),u=n[ee];u.updateData=function(t,e,n){function r(){c[N](!0),c.animateTo({shape:{r:p.r+10}},300,"elasticOut")}function u(){c[N](!0),c.animateTo({shape:{r:p.r}},300,"elasticOut")}var c=this[K](0),f=t[l],d=t[it](e),p=t[o](e),v=s[Rt]({},p);v.label=null,n?(c[_](v),c.shape.endAngle=p.startAngle,a[m](c,{shape:{endAngle:p.endAngle}},f)):a[m](c,{shape:v},f);var x=d[gt](h),b=t.getItemVisual(e,"color");c.setStyle(s[_t]({fill:b},x[gt](ct).getItemStyle())),c.hoverStyle=x[gt](lt).getItemStyle(),i(this,t[o](e),d.get("selected"),f.get("selectedOffset"),f.get(F)),c.off(y).off(g).off(lt).off(ct),d.get("hoverAnimation")&&c.on(y,r).on(g,u).on(lt,r).on(ct,u),this._updateLabel(t,e),a.setHoverStyle(this)},u._updateLabel=function(t,e){var i=this[K](1),n=this[K](2),s=t[l],u=t[it](e),c=t[o](e),h=c.label,f=t.getItemVisual(e,"color");a[m](i,{shape:{points:h.linePoints||[[h.x,h.y],[h.x,h.y],[h.x,h.y]]}},s),a[m](n,{style:{x:h.x,y:h.y}},s),n.attr({style:{textAlign:h[T],textBaseline:h[C],textFont:h.font},rotation:h[W],origin:[h.x,h.y], -z2:10});var d=u[gt]("label.normal"),p=u[gt]("label.emphasis"),v=u[gt]("labelLine.normal"),g=u[gt]("labelLine.emphasis");n.setStyle(r(t,e,ct,d)),n[R]=n.normalIgnore=!d.get("show"),n.hoverIgnore=!p.get("show"),i[R]=i.normalIgnore=!v.get("show"),i.hoverIgnore=!g.get("show"),i.setStyle({stroke:f}),i.setStyle(v[gt]("lineStyle").getLineStyle()),n.hoverStyle=r(t,e,lt,p),i.hoverStyle=g[gt]("lineStyle").getLineStyle();var y=v.get("smooth");y&&y===!0&&(y=.4),i[_]({smooth:y})},s[Bt](n,a.Group);var c=t("../../view/Chart")[Rt]({type:"pie",init:function(){var t=new a.Group;this._sectorGroup=t},render:function(t,i,r,a){if(!a||a.from!==this.uid){var u=t[st](),c=this._data,l=this.group,h=i.get(F),f=!c,d=s.curry(e,this.uid,t,h,r),p=t.get("selectedMode");if(u.diff(c).add(function(t){var e=new n(u,t);f&&e.eachChild(function(t){t[N](!0)}),p&&e.on("click",d),u.setItemGraphicEl(t,e),l.add(e)})[U](function(t,e){var i=c[k](e);i.updateData(u,t),i.off("click"),p&&i.on("click",d),l.add(i),u.setItemGraphicEl(t,i)})[I](function(t){var e=c[k](t);l[I](e)}).execute(),h&&f&&u.count()>0){var v=u[o](0),m=Math.max(r[Y](),r[j]())/2,g=s.bind(l.removeClipPath,l);l.setClipPath(this._createClipPath(v.cx,v.cy,m,v.startAngle,v.clockwise,g,t))}this._data=u}},_createClipPath:function(t,e,i,n,r,o,s){var u=new a.Sector({shape:{cx:t,cy:e,r0:0,r:i,startAngle:n,endAngle:n,clockwise:r}});return a.initProps(u,{shape:{endAngle:n+(r?1:-1)*Math.PI*2}},s,o),u}});return c}),e("echarts/action/createDataSelectAction",[ie,"../echarts",te],function(t){var e=t("../echarts"),i=t(te);return function(t,n){i.each(n,function(i){i[U]="updateView",e.registerAction(i,function(e,n){var r={};return n.eachComponent({mainType:"series",subType:t,query:e},function(t){t[i.method]&&t[i.method](e.name);var n=t[st]();n.each(function(e){var i=n[nt](e);r[i]=t.isSelected(i)||!1})}),{name:e.name,selected:r}})})}}),e("echarts/visual/dataColor",[ie],function(t){return function(t,e){var i=e.get("color"),n=0;e.eachRawSeriesByType(t,function(t){var r=t.get("color",!0),a=t.getRawData();if(!e.isSeriesFiltered(t)){var o=t[st]();o.each(function(t){var e=o[it](t),s=o[rt](t),u=o.getItemVisual(t,"color",!0);if(u)a[d](s,"color",u);else{var c=r?r[s%r[Kt]]:i[(s+n)%i[Kt]],l=e.get("itemStyle.normal.color")||c;a[d](s,"color",l),o[d](t,"color",l)}})}n+=a.count()})}}),e("echarts/chart/pie/labelLayout",[ie,"zrender/contain/text"],function(t){function e(t,e,i,n,r,a,o){function s(e,i,n,r){for(var a=e;i>a;a++)if(t[a].y+=n,a>e&&i>a+1&&t[a+1].y>t[a].y+t[a][Mt])return void u(a,n/2);u(i-1,n/2)}function u(e,i){for(var n=e;n>=0&&(t[n].y-=i,!(n>0&&t[n].y>t[n-1].y+t[n-1][Mt]));n--);}t.sort(function(t,e){return t.y-e.y});for(var c,l=0,h=t[Kt],f=[],d=[],p=0;h>p;p++)c=t[p].y-l,0>c&&s(p,h,-c,r),l=t[p].y+t[p][Mt];0>o-l&&u(h-1,l-o);for(var p=0;h>p;p++)t[p].y>=i?d.push(t[p]):f.push(t[p])}function i(t,i,n,r,a,o){for(var s=[],u=[],c=0;cw?-1:1)*x,z=k;r=A+(0>w?-5:5),a=z,f=[[C,T],[L,k],[A,z]]}d=S?Vt:w>0?"left":"right"}var P=qt,D=m[gt](mt)[pt](),I=m.get("rotate")?0>w?-b+Math.PI:-b:0,O=t.getFormattedLabel(i,ct)||c[nt](i),B=n[vt](O,D,d,P);h=!!I,p.label={x:r,y:a,height:B[Mt],length:_,length2:x,linePoints:f,textAlign:d,textBaseline:P,font:D,rotation:I},l.push(p.label)}),!h&&t.get("avoidLabelOverlap")&&i(l,s,u,e,r,a)}}),e("echarts/chart/pie/pieLayout",[ie,"../../util/number","./labelLayout",te],function(t){var e=t("../../util/number"),i=e[Wt],n=t("./labelLayout"),r=t(te),a=2*Math.PI,s=Math.PI/180;return function(t,u,c){u[f](t,function(t){var u=t.get(Vt),l=t.get(ht);r[Nt](l)||(l=[0,l]),r[Nt](u)||(u=[u,u]);var h=c[Y](),f=c[j](),d=Math.min(h,f),p=i(u[0],h),v=i(u[1],f),m=i(l[0],d/2),g=i(l[1],d/2),y=t[st](),_=-t.get("startAngle")*s,x=t.get("minAngle")*s,b=y.getSum("value"),w=Math.PI/(b||y.count())*2,M=t.get("clockwise"),S=t.get("roseType"),C=y.getDataExtent("value");C[0]=0;var T=a,L=0,k=_,A=M?1:-1;if(y.each("value",function(t,i){var n;n="area"!==S?0===b?w:t*w:a/(y.count()||1),x>n?(n=x,T-=x):L+=t;var r=k+A*n;y.setItemLayout(i,{angle:n,startAngle:k,endAngle:r,clockwise:M,cx:p,cy:v,r0:m,r:S?e.linearMap(t,C,[m,g]):g}),k=r},!0),a>T)if(.001>=T){var z=a/y.count();y.each(function(t){var e=y[o](t);e.startAngle=_+A*t*z,e.endAngle=_+A*(t+1)*z})}else w=T/L,k=_,y.each("value",function(t,e){var i=y[o](e),n=i.angle===x?x:t*w;i.startAngle=k,i.endAngle=k+A*n,k+=n});n(t,g,h,f)})}}),e("echarts/processor/dataFilter",[],function(){return function(t,e){var i=e.findComponents({mainType:"legend"});i&&i[Kt]&&e[f](t,function(t){var e=t[st]();e.filterSelf(function(t){for(var n=e[nt](t),r=0;r0?"top":Gt,n=Vt):l(a-h)?(r=i>0?Gt:"top",n=Vt):(r=qt,n=a>0&&h>a?i>0?"right":"left":i>0?"left":"right"),{rotation:a,textAlign:n,textBaseline:r}}function i(t,e,i){var n,r,a=c(-t[W]),o=i[0]>i[1],s="start"===e&&!o||"start"!==e&&o;return l(a-h/2)?(r=s?Gt:"top",n=Vt):l(a-1.5*h)?(r=s?"top":Gt,n=Vt):(r=qt,n=1.5*h>a&&a>h/2?s?"left":"right":s?"right":"left"),{rotation:a,textAlign:n,textBaseline:r}}var n=t(te),o=t("../../util/graphic"),s=t("../../model/Model"),u=t("../../util/number"),c=u.remRadian,l=u.isRadianAroundZero,h=Math.PI,f=function(t,e){this.opt=e,this.axisModel=t,n[_t](e,{labelOffset:0,nameDirection:1,tickDirection:1,labelDirection:1,silent:!0}),this.group=new o.Group({position:e[J].slice(),rotation:e[W]})};f[ee]={constructor:f,hasBuilder:function(t){return!!d[t]},add:function(t){d[t].call(this)},getGroup:function(){return this.group}};var d={axisLine:function(){var t=this.opt,e=this.axisModel;if(e.get("axisLine.show")){var i=this.axisModel.axis[r]();this.group.add(new o.Line({shape:{x1:i[0],y1:0,x2:i[1],y2:0},style:n[Rt]({lineCap:"round"},e[gt]("axisLine.lineStyle").getLineStyle()),strokeContainThreshold:t.strokeContainThreshold,silent:!!t.silent,z2:1}))}},axisTick:function(){var t=this.axisModel;if(t.get("axisTick.show")){for(var e=t.axis,i=t[gt]("axisTick"),n=this.opt,r=i[gt]("lineStyle"),a=i.get(Kt),s=v(i,n.labelInterval),u=e.getTicksCoords(),c=[],l=0;lf[1]?-1:1,p=["start"===u?f[0]-d*h:"end"===u?f[1]+d*h:(f[0]+f[1])/2,u===qt?t.labelOffset+c*h:0];s=u===qt?e(t,t[W],c):i(t,u,f),this.group.add(new o.Text({style:{text:a,textFont:l[pt](),fill:l.getTextColor()||n.get("axisLine.lineStyle.color"),textAlign:s[T],textBaseline:s[C]},position:p,rotation:s[W],silent:!0,z2:1}))}}},p=f.ifIgnoreOnTick=function(t,e,i){var n,r=t.scale;return r.type===ot&&(typeof i===Zt?(n=r.getTicks()[e],!i(n,r.getLabel(n))):e%(i+1))},v=f.getInterval=function(t,e){var i=t.get("interval");return(null==i||"auto"==i)&&(i=e),i};return f}),e("echarts/component/axis/AxisView",[ie,te,"../../util/graphic","./AxisBuilder","../../echarts"],function(t){function e(t,e){function i(t,e){var i=r[n](t);return i.toGlobalCoord(i.dataToCoord(0))}var r=t[Z],a=e.axis,o={},s=a[J],u=a.onZero?"onZero":s,c=a.dim,l=r.getRect(),h=[l.x,l.x+l.width,l.y,l.y+l[Mt]],f={x:{top:h[2],bottom:h[3]},y:{left:h[0],right:h[1]}};f.x.onZero=Math.max(Math.min(i("y"),f.x[Gt]),f.x.top),f.y.onZero=Math.max(Math.min(i("x"),f.y.right),f.y.left),o[J]=["y"===c?f.y[u]:h[0],"x"===c?f.x[u]:h[3]];var d={x:0,y:1};o[W]=Math.PI/2*d[c];var p={top:-1,bottom:1,left:-1,right:1};o.labelDirection=o.tickDirection=o.nameDirection=p[s],a.onZero&&(o.labelOffset=f[c][s]-f[c].onZero),e[gt]("axisTick").get(xt)&&(o.tickDirection=-o.tickDirection),e[gt]("axisLabel").get(xt)&&(o.labelDirection=-o.labelDirection);var v=e[gt]("axisLabel").get("rotate");return o.labelRotation="top"===u?-v:v,o.labelInterval=a.getLabelInterval(),o.z2=1,o}var r=t(te),a=t("../../util/graphic"),o=t("./AxisBuilder"),s=o.ifIgnoreOnTick,u=o.getInterval,c=["axisLine","axisLabel","axisTick","axisName"],l=["splitLine","splitArea"],h=t("../../echarts").extendComponentView({type:"axis",render:function(t,i){if(this.group[P](),t.get("show")){var n=i[X]("grid",t.get("gridIndex")),a=e(n,t),s=new o(t,a);r.each(c,s.add,s),this.group.add(s.getGroup()),r.each(l,function(e){t.get(e+".show")&&this["_"+e](t,n,a.labelInterval)},this)}},_splitLine:function(t,e,n){var r=t.axis,o=t[gt]("splitLine"),c=o[gt]("lineStyle"),l=c.get("width"),h=c.get("color"),f=u(o,n);h=h instanceof Array?h:[h];for(var d=e[Z].getRect(),p=r[i](),v=[],m=0,g=r.getTicksCoords(),y=[],_=[],x=0;xn;n++)e[n]=i(t[n])}else if(!C(t)&&!T(t)){e={};for(var a in t)t.hasOwnProperty(a)&&(e[a]=i(t[a]))}return e}return t}function r(t,e,n){if(!S(e)||!S(t))return n?i(e):t;for(var a in e)if(e.hasOwnProperty(a)){var o=t[a],s=e[a];!S(s)||!S(o)||b(s)||b(o)||T(s)||T(o)||C(s)||C(o)?!n&&a in t||(t[a]=i(e[a],!0)):r(o,s,n)}return t}function a(t,e){for(var n=t[0],i=1,a=t.length;a>i;i++)n=r(n,t[i],e);return n}function o(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function s(t,e,n){for(var i in e)e.hasOwnProperty(i)&&(n?null!=e[i]:null==t[i])&&(t[i]=e[i]);return t}function h(){return document.createElement("canvas")}function l(){return L||(L=V.createCanvas().getContext("2d")),L}function u(t,e){if(t){if(t.indexOf)return t.indexOf(e);for(var n=0,i=t.length;i>n;n++)if(t[n]===e)return n}return-1}function c(t,e){function n(){}var i=t.prototype;n.prototype=e.prototype,t.prototype=new n;for(var r in i)t.prototype[r]=i[r];t.prototype.constructor=t,t.superClass=e}function f(t,e,n){t="prototype"in t?t.prototype:t,e="prototype"in e?e.prototype:e,s(t,e,n)}function d(t){return t?"string"==typeof t?!1:"number"==typeof t.length:void 0}function p(t,e,n){if(t&&e)if(t.forEach&&t.forEach===E)t.forEach(e,n);else if(t.length===+t.length)for(var i=0,r=t.length;r>i;i++)e.call(n,t[i],i,t);else for(var a in t)t.hasOwnProperty(a)&&e.call(n,t[a],a,t)}function g(t,e,n){if(t&&e){if(t.map&&t.map===N)return t.map(e,n);for(var i=[],r=0,a=t.length;a>r;r++)i.push(e.call(n,t[r],r,t));return i}}function v(t,e,n,i){if(t&&e){if(t.reduce&&t.reduce===F)return t.reduce(e,n,i);for(var r=0,a=t.length;a>r;r++)n=e.call(i,n,t[r],r,t);return n}}function m(t,e,n){if(t&&e){if(t.filter&&t.filter===B)return t.filter(e,n);for(var i=[],r=0,a=t.length;a>r;r++)e.call(n,t[r],r,t)&&i.push(t[r]);return i}}function y(t,e,n){if(t&&e)for(var i=0,r=t.length;r>i;i++)if(e.call(n,t[i],i,t))return t[i]}function x(t,e){var n=R.call(arguments,2);return function(){return t.apply(e,n.concat(R.call(arguments)))}}function _(t){var e=R.call(arguments,1);return function(){return t.apply(this,e.concat(R.call(arguments)))}}function b(t){return"[object Array]"===O.call(t)}function w(t){return"function"==typeof t}function M(t){return"[object String]"===O.call(t)}function S(t){var e=typeof t;return"function"===e||!!t&&"object"==e}function C(t){return!!D[O.call(t)]||t instanceof P}function T(t){return t&&1===t.nodeType&&"string"==typeof t.nodeName}function A(t){for(var e=0,n=arguments.length;n>e;e++)if(null!=arguments[e])return arguments[e]}function I(){return Function.call.apply(R,arguments)}function k(t,e){if(!t)throw new Error(e)}var L,P=n(16),D={"[object Function]":1,"[object RegExp]":1,"[object Date]":1,"[object Error]":1,"[object CanvasGradient]":1},O=Object.prototype.toString,z=Array.prototype,E=z.forEach,B=z.filter,R=z.slice,N=z.map,F=z.reduce,V={inherits:c,mixin:f,clone:i,merge:r,mergeAll:a,extend:o,defaults:s,getContext:l,createCanvas:h,indexOf:u,slice:I,find:y,isArrayLike:d,each:p,map:g,reduce:v,filter:m,bind:x,curry:_,isArray:b,isString:M,isObject:S,isFunction:w,isBuildInObject:C,isDom:T,retrieve:A,assert:k,noop:function(){}};t.exports=V},function(t,e,n){function i(t){return function(e,n,i){e=e&&e.toLowerCase(),k.prototype[t].call(this,e,n,i)}}function r(){k.call(this)}function a(t,e,n){n=n||{},"string"==typeof e&&(e=W[e]),e&&L(G,function(t){t(e)}),this.id,this.group,this._dom=t,this._zr=C.init(t,{renderer:n.renderer||"canvas",devicePixelRatio:n.devicePixelRatio}),this._theme=T.clone(e),this._chartsViews=[],this._chartsMap={},this._componentsViews=[],this._componentsMap={},this._api=new m(this),this._coordSysMgr=new y,k.call(this),this._messageCenter=new r,this._initEvents(),this.resize=T.bind(this.resize,this)}function o(t,e){var n=this._model;n&&n.eachComponent({mainType:"series",query:e},function(i,r){var a=this._chartsMap[i.__viewId];a&&a.__alive&&a[t](i,n,this._api,e)},this)}function s(t,e,n){var i=this._api;L(this._componentsViews,function(r){var a=r.__model;r[t](a,e,i,n),p(a,r)},this),e.eachSeries(function(r,a){var o=this._chartsMap[r.__viewId];o[t](r,e,i,n),p(r,o)},this)}function h(t,e){for(var n="component"===t,i=n?this._componentsViews:this._chartsViews,r=n?this._componentsMap:this._chartsMap,a=this._zr,o=0;o=0?"white":n,a=e.getModel("textStyle");d.extend(t,{textDistance:e.getShallow("distance")||5,textFont:a.getFont(),textPosition:i,textFill:a.getTextColor()||r})},b.updateProps=d.curry(f,!0),b.initProps=d.curry(f,!1),b.getTransform=function(t,e){for(var n=y.identity([]);t&&t!==e;)y.mul(n,t.getLocalTransform(),n),t=t.parent;return n},b.applyTransform=function(t,e,n){return n&&(e=y.invert([],e)),x.applyTransform([],t,e)},b.transformDirection=function(t,e,n){var i=0===e[4]||0===e[5]||0===e[0]?1:Math.abs(2*e[4]/e[0]),r=0===e[4]||0===e[5]||0===e[2]?1:Math.abs(2*e[4]/e[2]),a=["left"===t?-i:"right"===t?i:0,"top"===t?-r:"bottom"===t?r:0];return a=b.applyTransform(a,e,n),Math.abs(a[0])>Math.abs(a[1])?a[0]>0?"right":"left":a[1]>0?"bottom":"top"},t.exports=b},function(t,e){function n(t){return t.replace(/^\s+/,"").replace(/\s+$/,"")}var i={},r=1e-4;i.linearMap=function(t,e,n,i){var r=e[1]-e[0];if(0===r)return(n[0]+n[1])/2;var a=(t-e[0])/r;return i&&(a=Math.min(Math.max(a,0),1)),a*(n[1]-n[0])+n[0]},i.parsePercent=function(t,e){switch(t){case"center":case"middle":t="50%";break;case"left":case"top":t="0%";break;case"right":case"bottom":t="100%"}return"string"==typeof t?n(t).match(/%$/)?parseFloat(t)/100*e:parseFloat(t):null==t?NaN:+t},i.round=function(t){return+(+t).toFixed(12)},i.asc=function(t){return t.sort(function(t,e){return t-e}),t},i.getPrecision=function(t){if(isNaN(t))return 0;for(var e=1,n=0;Math.round(t*e)/e!==t;)e*=10,n++;return n},i.getPixelPrecision=function(t,e){var n=Math.log,i=Math.LN10,r=Math.floor(n(t[1]-t[0])/i),a=Math.round(n(Math.abs(e[1]-e[0]))/i);return Math.max(-r+a,0)},i.MAX_SAFE_INTEGER=9007199254740991,i.remRadian=function(t){var e=2*Math.PI;return(t%e+e)%e},i.isRadianAroundZero=function(t){return t>-r&&r>t},i.parseDate=function(t){return t instanceof Date?t:new Date("string"==typeof t?t.replace(/-/g,"/"):Math.round(t))},i.nice=function(t,e){var n,i=Math.floor(Math.log(t)/Math.LN10),r=Math.pow(10,i),a=t/r;return n=e?1.5>a?1:2.5>a?2:4>a?3:7>a?5:10:1>a?1:2>a?2:3>a?3:5>a?5:10,n*r},t.exports=i},function(t,e){var n="undefined"==typeof Float32Array?Array:Float32Array,i={create:function(t,e){var i=new n(2);return i[0]=t||0,i[1]=e||0,i},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t},clone:function(t){var e=new n(2);return e[0]=t[0],e[1]=t[1],e},set:function(t,e,n){return t[0]=e,t[1]=n,t},add:function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t},scaleAndAdd:function(t,e,n,i){return t[0]=e[0]+n[0]*i,t[1]=e[1]+n[1]*i,t},sub:function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t},len:function(t){return Math.sqrt(this.lenSquare(t))},lenSquare:function(t){return t[0]*t[0]+t[1]*t[1]},mul:function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t},div:function(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},scale:function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t},normalize:function(t,e){var n=i.len(e);return 0===n?(t[0]=0,t[1]=0):(t[0]=e[0]/n,t[1]=e[1]/n),t},distance:function(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))},distanceSquare:function(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])},negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},lerp:function(t,e,n,i){return t[0]=e[0]+i*(n[0]-e[0]),t[1]=e[1]+i*(n[1]-e[1]),t},applyTransform:function(t,e,n){var i=e[0],r=e[1];return t[0]=n[0]*i+n[2]*r+n[4],t[1]=n[1]*i+n[3]*r+n[5],t},min:function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t},max:function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t}};i.length=i.len,i.lengthSquare=i.lenSquare,i.dist=i.distance,i.distSquare=i.distanceSquare,t.exports=i},function(t,e,n){function i(t){var e=t.fill;return null!=e&&"none"!==e}function r(t){var e=t.stroke;return null!=e&&"none"!==e&&t.lineWidth>0}function a(t){o.call(this,t),this.path=new h}var o=n(35),s=n(1),h=n(27),l=n(136),u=n(16),c=Math.abs;a.prototype={constructor:a,type:"path",__dirtyPath:!0,strokeContainThreshold:5,brush:function(t){t.save();var e=this.style,n=this.path,a=r(e),o=i(e);this.__dirtyPath&&(o&&e.fill instanceof u&&e.fill.updateCanvasGradient(this,t),a&&e.stroke instanceof u&&e.stroke.updateCanvasGradient(this,t)),e.bind(t,this),this.setTransform(t);var s=e.lineDash,h=e.lineDashOffset,l=!!t.setLineDash;this.__dirtyPath||s&&!l&&a?(n=this.path.beginPath(t),s&&!l&&(n.setLineDash(s),n.setLineDashOffset(h)),this.buildPath(n,this.shape),this.__dirtyPath=!1):(t.beginPath(),this.path.rebuildPath(t)),o&&n.fill(t),s&&l&&(t.setLineDash(s),t.lineDashOffset=h),a&&n.stroke(t),null!=e.text&&this.drawRectText(t,this.getBoundingRect()),t.restore()},buildPath:function(t,e){},getBoundingRect:function(){var t=this._rect,e=this.style;if(!t){var n=this.path;this.__dirtyPath&&(n.beginPath(),this.buildPath(n,this.shape)),t=n.getBoundingRect()}if(r(e)&&(this.__dirty||!this._rect)){var a=this._rectWithStroke||(this._rectWithStroke=t.clone());a.copy(t);var o=e.lineWidth,s=e.strokeNoScale?this.getLineScale():1;return i(e)||(o=Math.max(o,this.strokeContainThreshold)),s>1e-10&&(a.width+=o/s,a.height+=o/s,a.x-=o/s/2,a.y-=o/s/2),a}return this._rect=t,t},contain:function(t,e){var n=this.transformCoordToLocal(t,e),a=this.getBoundingRect(),o=this.style;if(t=n[0],e=n[1],a.contain(t,e)){var s=this.path.data;if(r(o)){var h=o.lineWidth,u=o.strokeNoScale?this.getLineScale():1;if(u>1e-10&&(i(o)||(h=Math.max(h,this.strokeContainThreshold)),l.containStroke(s,h/u,t,e)))return!0}if(i(o))return l.contain(s,t,e)}return!1},dirty:function(t){0===arguments.length&&(t=!0),t&&(this.__dirtyPath=t,this._rect=null),this.__dirty=!0,this.__zr&&this.__zr.refresh(),this.__clipTarget&&this.__clipTarget.dirty()},animateShape:function(t){return this.animate("shape",t)},attrKV:function(t,e){"shape"===t?this.setShape(e):o.prototype.attrKV.call(this,t,e)},setShape:function(t,e){var n=this.shape;if(n){if(s.isObject(t))for(var i in t)n[i]=t[i];else n[t]=e;this.dirty(!0)}return this},getLineScale:function(){var t=this.transform;return t&&c(t[0]-1)>1e-10&&c(t[3]-1)>1e-10?Math.sqrt(c(t[0]*t[3]-t[2]*t[1])):1}},a.extend=function(t){var e=function(e){a.call(this,e),t.style&&this.style.extendFrom(t.style,!1);var n=t.shape;if(n){this.shape=this.shape||{};var i=this.shape;for(var r in n)!i.hasOwnProperty(r)&&n.hasOwnProperty(r)&&(i[r]=n[r])}t.init&&t.init.call(this,e)};s.inherits(e,a);for(var n in t)"style"!==n&&"shape"!==n&&(e.prototype[n]=t[n]);return e},s.inherits(a,o),t.exports=a},function(t,e,n){var i=n(9),r=n(4),a=n(1),o=n(12),s=["x","y","z","radius","angle"],h={};h.createNameEach=function(t,e){t=t.slice();var n=a.map(t,h.capitalFirst);e=(e||[]).slice();var i=a.map(e,h.capitalFirst);return function(r,o){a.each(t,function(t,a){for(var s={name:t,capital:n[a]},h=0;h=0}function r(t,i){var r=!1;return e(function(e){a.each(n(t,e)||[],function(t){i.records[e.name][t]&&(r=!0)})}),r}function o(t,i){i.nodes.push(t),e(function(e){a.each(n(t,e)||[],function(t){i.records[e.name][t]=!0})})}return function(n){function a(t){!i(t,s)&&r(t,s)&&(o(t,s),h=!0)}var s={nodes:[],records:{}};if(e(function(t){s.records[t.name]={}}),!n)return s;o(n,s);var h;do h=!1,t(a);while(h);return s}},h.defaultEmphasis=function(t,e){if(t){var n=t.emphasis=t.emphasis||{},i=t.normal=t.normal||{};a.each(e,function(t){var e=a.retrieve(n[t],i[t]);null!=e&&(n[t]=e)})}},h.createDataFormatModel=function(t,e,n){var i=new o;return a.mixin(i,h.dataFormatMixin),i.seriesIndex=t.seriesIndex,i.name=t.name||"",i.getData=function(){return e},i.getRawDataArray=function(){return n},i},h.getDataItemValue=function(t){return t&&(null==t.value?t:t.value)},h.converDataValue=function(t,e){var n=e&&e.type;return"ordinal"===n?t:("time"!==n||isFinite(t)||null==t||"-"===t||(t=+r.parseDate(t)),null==t||""===t?NaN:+t)},h.dataFormatMixin={getDataParams:function(t){var e=this.getData(),n=this.seriesIndex,i=this.name,r=this.getRawValue(t),a=e.getRawIndex(t),o=e.getName(t,!0),s=this.getRawDataArray(),h=s&&s[a];return{seriesIndex:n,seriesName:i,name:o,dataIndex:a,data:h,value:r,$vars:["seriesName","name","value"]}},getFormattedLabel:function(t,e,n){e=e||"normal";var r=this.getData(),a=r.getItemModel(t),o=this.getDataParams(t);return null==n&&(n=a.get(["label",e,"formatter"])),"function"==typeof n?(o.status=e,n(o)):"string"==typeof n?i.formatTpl(n,o):void 0},getRawValue:function(t){var e=this.getData().getItemModel(t);if(e&&null!=e.option){var n=e.option;return a.isObject(n)&&!a.isArray(n)?n.value:n}}},h.mappingToExists=function(t,e){e=(e||[]).slice();var n=a.map(t||[],function(t,e){return{exist:t}});return a.each(e,function(t,i){if(a.isObject(t))for(var r=0;r=n.length&&n.push({option:t})}}),n},h.isIdInner=function(t){return a.isObject(t)&&t.id&&0===(t.id+"").indexOf("\x00_ec_\x00")},t.exports=h},function(t,e,n){"use strict";function i(t,e,n,i){this.x=t,this.y=e,this.width=n,this.height=i}var r=n(5),a=n(19),o=r.applyTransform,s=Math.min,h=Math.abs,l=Math.max;i.prototype={constructor:i,union:function(t){var e=s(t.x,this.x),n=s(t.y,this.y);this.width=l(t.x+t.width,this.x+this.width)-e,this.height=l(t.y+t.height,this.y+this.height)-n,this.x=e,this.y=n},applyTransform:function(){var t=[],e=[];return function(n){n&&(t[0]=this.x,t[1]=this.y,e[0]=this.x+this.width,e[1]=this.y+this.height,o(t,t,n),o(e,e,n),this.x=s(t[0],e[0]),this.y=s(t[1],e[1]),this.width=h(e[0]-t[0]),this.height=h(e[1]-t[1]))}}(),calculateTransform:function(t){var e=this,n=t.width/e.width,i=t.height/e.height,r=a.create();return a.translate(r,r,[-e.x,-e.y]),a.scale(r,r,[n,i]),a.translate(r,r,[t.x,t.y]),r},intersect:function(t){var e=this,n=e.x,i=e.x+e.width,r=e.y,a=e.y+e.height,o=t.x,s=t.x+t.width,h=t.y,l=t.y+t.height;return!(o>i||n>s||h>a||r>l)},contain:function(t,e){var n=this;return t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height},clone:function(){return new i(this.x,this.y,this.width,this.height)},copy:function(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}},t.exports=i},function(t,e,n){function i(t){return isNaN(t)?"-":(t=(t+"").split("."),t[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,"$1,")+(t.length>1?"."+t[1]:""))}function r(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function a(t){var e=t.length;return"number"==typeof t?[t,t,t,t]:2===e?[t[0],t[1],t[0],t[1]]:3===e?[t[0],t[1],t[2],t[1]]:t}function o(t){return String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function s(t,e){return"{"+t+(null==e?"":e)+"}"}function h(t,e){c.isArray(e)||(e=[e]);var n=e.length;if(!n)return"";for(var i=e[0].$vars,r=0;ro;o++)for(var h=0;ht?"0"+t:t}var c=n(1),f=n(4),d=["a","b","c","d","e","f","g"];t.exports={normalizeCssArray:a,addCommas:i,toCamelCase:r,encodeHTML:o,formatTpl:h,formatTime:l}},function(t,e,n){function i(t){var e=[];return a.each(u.getClassesByMainType(t),function(t){o.apply(e,t.prototype.dependencies||[])}),a.map(e,function(t){return h.parseClassType(t).main})}var r=n(12),a=n(1),o=Array.prototype.push,s=n(41),h=n(20),l=n(11),u=r.extend({type:"component",id:"",name:"",mainType:"",subType:"",componentIndex:0,defaultOption:null,ecModel:null,dependentModels:[],uid:null,layoutMode:null,init:function(t,e,n,i){this.mergeDefaultAndTheme(this.option,this.ecModel)},mergeDefaultAndTheme:function(t,e){var n=this.layoutMode,i=n?l.getLayoutParams(t):{},r=e.getTheme();a.merge(t,r.get(this.mainType)),a.merge(t,this.getDefaultOption()),n&&l.mergeLayoutParam(t,i,n)},mergeOption:function(t){a.merge(this.option,t,!0);var e=this.layoutMode;e&&l.mergeLayoutParam(this.option,t,e)},optionUpdated:function(t){},getDefaultOption:function(){if(!this.hasOwnProperty("__defaultOption")){for(var t=[],e=this.constructor;e;){var n=e.prototype.defaultOption;n&&t.push(n),e=e.superClass}for(var i={},r=t.length-1;r>=0;r--)i=a.merge(i,t[r],!0);this.__defaultOption=i}return this.__defaultOption}});h.enableClassExtend(u,function(t,e,n,i){a.extend(this,i),this.uid=s.getUID("componentModel"),this.setReadOnly(["type","id","uid","name","mainType","subType","dependentModels","componentIndex"])}),h.enableClassManagement(u,{registerWhenExtend:!0}),s.enableSubTypeDefaulter(u),s.enableTopologicalTravel(u,i),a.mixin(u,n(115)),t.exports=u},function(t,e,n){"use strict";function i(t,e,n,i,r){var a=0,o=0;null==i&&(i=1/0),null==r&&(r=1/0);var s=0;e.eachChild(function(h,l){var u,c,f=h.position,d=h.getBoundingRect(),p=e.childAt(l+1),g=p&&p.getBoundingRect();if("horizontal"===t){var v=d.width+(g?-g.x+d.x:0);u=a+v,u>i||h.newline?(a=0,u=v,o+=s+n,s=d.height):s=Math.max(s,d.height)}else{var m=d.height+(g?-g.y+d.y:0);c=o+m,c>r||h.newline?(a+=s+n,o=0,c=m,s=d.width):s=Math.max(s,d.width)}h.newline||(f[0]=a,f[1]=o,"horizontal"===t?a=u+n:o=c+n)})}var r=n(1),a=n(8),o=n(4),s=n(9),h=o.parsePercent,l=r.each,u={},c=["left","right","top","bottom","width","height"];u.box=i,u.vbox=r.curry(i,"vertical"),u.hbox=r.curry(i,"horizontal"),u.getAvailableSize=function(t,e,n){var i=e.width,r=e.height,a=h(t.x,i),o=h(t.y,r),l=h(t.x2,i),u=h(t.y2,r);return(isNaN(a)||isNaN(parseFloat(t.x)))&&(a=0),(isNaN(l)||isNaN(parseFloat(t.x2)))&&(l=i),(isNaN(o)||isNaN(parseFloat(t.y)))&&(o=0),(isNaN(u)||isNaN(parseFloat(t.y2)))&&(u=r),n=s.normalizeCssArray(n||0),{width:Math.max(l-a-n[1]-n[3],0),height:Math.max(u-o-n[0]-n[2],0)}},u.getLayoutRect=function(t,e,n){n=s.normalizeCssArray(n||0);var i=e.width,r=e.height,o=h(t.left,i),l=h(t.top,r),u=h(t.right,i),c=h(t.bottom,r),f=h(t.width,i),d=h(t.height,r),p=n[2]+n[0],g=n[1]+n[3],v=t.aspect;switch(isNaN(f)&&(f=i-u-g-o),isNaN(d)&&(d=r-c-p-l),isNaN(f)&&isNaN(d)&&(v>i/r?f=.8*i:d=.8*r),null!=v&&(isNaN(f)&&(f=v*d),isNaN(d)&&(d=f/v)),isNaN(o)&&(o=i-u-f-g),isNaN(l)&&(l=r-c-d-p),t.left||t.right){case"center":o=i/2-f/2-n[3];break;case"right":o=i-f-g}switch(t.top||t.bottom){case"middle":case"center":l=r/2-d/2-n[0];break;case"bottom":l=r-d-p}o=o||0,l=l||0,isNaN(f)&&(f=i-o-(u||0)),isNaN(d)&&(d=r-l-(c||0));var m=new a(o+n[3],l+n[0],f,d);return m.margin=n,m},u.positionGroup=function(t,e,n,i){var a=t.getBoundingRect();e=r.extend(r.clone(e),{width:a.width,height:a.height}),e=u.getLayoutRect(e,n,i),t.position=[e.x-a.x,e.y-a.y]},u.mergeLayoutParam=function(t,e,n){function i(i){var r={},s=0,h={},u=0,c=n.ignoreSize?1:2;if(l(i,function(e){h[e]=t[e]}),l(i,function(t){a(e,t)&&(r[t]=h[t]=e[t]),o(r,t)&&s++,o(h,t)&&u++}),u!==c&&s){if(s>=c)return r;for(var f=0;f"+(o?s(o)+" : "+a:a)},restoreData:function(){this._data=this._dataBeforeProcessed.cloneShallow()}});i.mixin(l,a.dataFormatMixin),t.exports=l},function(t,e,n){(function(e){function i(t){return f.isArray(t)||(t=[t]),t}function r(t,e){var n=t.dimensions,i=new m(f.map(n,t.getDimensionInfo,t),t.hostModel);v(i,t,t._wrappedMethods);for(var r=i._storage={},a=t._storage,o=0;o=0?r[s]=new h.constructor(a[s].length):r[s]=a[s]}return i}var a="undefined",o="undefined"==typeof window?e:window,s=typeof o.Float64Array===a?Array:o.Float64Array,h=typeof o.Int32Array===a?Array:o.Int32Array,l={"float":s,"int":h,ordinal:Array,number:Array,time:Array},u=n(12),c=n(52),f=n(1),d=n(7),p=f.isObject,g=["stackedOn","_nameList","_idList","_rawData"],v=function(t,e,n){f.each(g.concat(n||[]),function(n){e.hasOwnProperty(n)&&(t[n]=e[n])})},m=function(t,e){t=t||["x","y"];for(var n={},i=[],r=0;r0&&(b+="__ec__"+u[w]),u[w]++),b&&(h[c]=b)}this._nameList=e,this._idList=h},y.count=function(){return this.indices.length},y.get=function(t,e,n){var i=this._storage,r=this.indices[e];if(null==r)return NaN;var a=i[t]&&i[t][r];if(n){var o=this._dimensionInfos[t];if(o&&o.stackable)for(var s=this.stackedOn;s;){var h=s.get(t,e);(a>=0&&h>0||0>=a&&0>h)&&(a+=h),s=s.stackedOn}}return a},y.getValues=function(t,e,n){var i=[];f.isArray(t)||(n=e,e=t,t=this.dimensions);for(var r=0,a=t.length;a>r;r++)i.push(this.get(t[r],e,n));return i},y.hasValue=function(t){for(var e=this.dimensions,n=this._dimensionInfos,i=0,r=e.length;r>i;i++)if("ordinal"!==n[e[i]].type&&isNaN(this.get(e[i],t)))return!1;return!0},y.getDataExtent=function(t,e){var n=this._storage[t],i=this.getDimensionInfo(t);e=i&&i.stackable&&e;var r,a=(this._extent||(this._extent={}))[t+!!e];if(a)return a;if(n){for(var o=1/0,s=-(1/0),h=0,l=this.count();l>h;h++)r=this.get(t,h,e),o>r&&(o=r),r>s&&(s=r);return this._extent[t+e]=[o,s]}return[1/0,-(1/0)]},y.getSum=function(t,e){var n=this._storage[t],i=0;if(n)for(var r=0,a=this.count();a>r;r++){var o=this.get(t,r,e);isNaN(o)||(i+=o)}return i},y.indexOf=function(t,e){var n=this._storage,i=n[t],r=this.indices;if(i)for(var a=0,o=r.length;o>a;a++){var s=r[a];if(i[s]===e)return a; +}return-1},y.indexOfName=function(t){for(var e=this.indices,n=this._nameList,i=0,r=e.length;r>i;i++){var a=e[i];if(n[a]===t)return i}return-1},y.indexOfNearest=function(t,e,n){var i=this._storage,r=i[t];if(r){for(var a=Number.MAX_VALUE,o=-1,s=0,h=this.count();h>s;s++){var l=Math.abs(this.get(t,s,n)-e);a>=l&&(a=l,o=s)}return o}return-1},y.getRawIndex=function(t){var e=this.indices[t];return null==e?-1:e},y.getName=function(t){return this._nameList[this.indices[t]]||""},y.getId=function(t){return this._idList[this.indices[t]]||this.getRawIndex(t)+""},y.each=function(t,e,n,r){"function"==typeof t&&(r=n,n=e,e=t,t=[]),t=f.map(i(t),this.getDimension,this);var a=[],o=t.length,s=this.indices;r=r||this;for(var h=0;hl;l++)a[l]=this.get(t[l],h,n);a[l]=h,e.apply(r,a)}},y.filterSelf=function(t,e,n,r){"function"==typeof t&&(r=n,n=e,e=t,t=[]),t=f.map(i(t),this.getDimension,this);var a=[],o=[],s=t.length,h=this.indices;r=r||this;for(var l=0;lc;c++)o[c]=this.get(t[c],l,n);o[c]=l,u=e.apply(r,o)}u&&a.push(h[l])}return this.indices=a,this._extent={},this},y.mapArray=function(t,e,n,i){"function"==typeof t&&(i=n,n=e,e=t,t=[]);var r=[];return this.each(t,function(){r.push(e&&e.apply(this,arguments))},n,i),r},y.map=function(t,e,n,a){t=f.map(i(t),this.getDimension,this);var o=r(this,t),s=o.indices=this.indices,h=o._storage,l=[];return this.each(t,function(){var n=arguments[arguments.length-1],i=e&&e.apply(this,arguments);if(null!=i){"number"==typeof i&&(l[0]=i,i=l);for(var r=0;rg;g+=f){f>p-g&&(f=p-g,u.length=f);for(var v=0;f>v;v++){var m=h[g+v];u[v]=d[m],c[v]=m}var y=n(u),m=c[i(u,y)||0];d[m]=y,l.push(m)}return a},y.getItemModel=function(t){var e=this.hostModel;return t=this.indices[t],new u(this._rawData[t],e,e.ecModel)},y.diff=function(t){var e=this._idList,n=t&&t._idList;return new c(t?t.indices:[],this.indices,function(t){return n[t]||t+""},function(t){return e[t]||t+""})},y.getVisual=function(t){var e=this._visual;return e&&e[t]},y.setVisual=function(t,e){if(p(t))for(var n in t)t.hasOwnProperty(n)&&this.setVisual(n,t[n]);else this._visual=this._visual||{},this._visual[t]=e},y.setLayout=function(t,e){if(p(t))for(var n in t)t.hasOwnProperty(n)&&this.setLayout(n,t[n]);else this._layout[t]=e},y.getLayout=function(t){return this._layout[t]},y.getItemLayout=function(t){return this._itemLayouts[t]},y.setItemLayout=function(t,e,n){this._itemLayouts[t]=n?f.extend(this._itemLayouts[t]||{},e):e},y.getItemVisual=function(t,e,n){var i=this._itemVisuals[t],r=i&&i[e];return null!=r||n?r:this.getVisual(e)},y.setItemVisual=function(t,e,n){var i=this._itemVisuals[t]||{};if(this._itemVisuals[t]=i,p(e))for(var r in e)e.hasOwnProperty(r)&&(i[r]=e[r]);else i[e]=n};var x=function(t){t.seriesIndex=this.seriesIndex,t.dataIndex=this.dataIndex};y.setItemGraphicEl=function(t,e){var n=this.hostModel;e&&(e.dataIndex=t,e.seriesIndex=n&&n.seriesIndex,"group"===e.type&&e.traverse(x,e)),this._graphicEls[t]=e},y.getItemGraphicEl=function(t){return this._graphicEls[t]},y.eachItemGraphicEl=function(t,e){f.each(this._graphicEls,function(n,i){n&&t&&t.call(e,n,i)})},y.cloneShallow=function(){var t=f.map(this.dimensions,this.getDimensionInfo,this),e=new m(t,this.hostModel);return e._storage=this._storage,v(e,this,this._wrappedMethods),e.indices=this.indices.slice(),e},y.wrapMethod=function(t,e){var n=this[t];"function"==typeof n&&(this._wrappedMethods=this._wrappedMethods||[],this._wrappedMethods.push(t),this[t]=function(){var t=n.apply(this,arguments);return e.call(this,t)})},t.exports=m}).call(e,function(){return this}())},function(t,e){function n(t){var e={},n={},i=t.match(/Web[kK]it[\/]{0,1}([\d.]+)/),r=t.match(/(Android);?[\s\/]+([\d.]+)?/),a=t.match(/(iPad).*OS\s([\d_]+)/),o=t.match(/(iPod)(.*OS\s([\d_]+))?/),s=!a&&t.match(/(iPhone\sOS)\s([\d_]+)/),h=t.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),l=h&&t.match(/TouchPad/),u=t.match(/Kindle\/([\d.]+)/),c=t.match(/Silk\/([\d._]+)/),f=t.match(/(BlackBerry).*Version\/([\d.]+)/),d=t.match(/(BB10).*Version\/([\d.]+)/),p=t.match(/(RIM\sTablet\sOS)\s([\d.]+)/),g=t.match(/PlayBook/),v=t.match(/Chrome\/([\d.]+)/)||t.match(/CriOS\/([\d.]+)/),m=t.match(/Firefox\/([\d.]+)/),y=i&&t.match(/Mobile\//)&&!v,x=t.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/)&&!v,_=t.match(/MSIE\s([\d.]+)/)||t.match(/Trident\/.+?rv:(([\d.]+))/),b=t.match(/Edge\/([\d.]+)/);return(n.webkit=!!i)&&(n.version=i[1]),r&&(e.android=!0,e.version=r[2]),s&&!o&&(e.ios=e.iphone=!0,e.version=s[2].replace(/_/g,".")),a&&(e.ios=e.ipad=!0,e.version=a[2].replace(/_/g,".")),o&&(e.ios=e.ipod=!0,e.version=o[3]?o[3].replace(/_/g,"."):null),h&&(e.webos=!0,e.version=h[2]),l&&(e.touchpad=!0),f&&(e.blackberry=!0,e.version=f[2]),d&&(e.bb10=!0,e.version=d[2]),p&&(e.rimtabletos=!0,e.version=p[2]),g&&(n.playbook=!0),u&&(e.kindle=!0,e.version=u[1]),c&&(n.silk=!0,n.version=c[1]),!c&&e.android&&t.match(/Kindle Fire/)&&(n.silk=!0),v&&(n.chrome=!0,n.version=v[1]),m&&(n.firefox=!0,n.version=m[1]),_&&(n.ie=!0,n.version=_[1]),y&&(t.match(/Safari/)||e.ios)&&(n.safari=!0),x&&(n.webview=!0),_&&(n.ie=!0,n.version=_[1]),b&&(n.edge=!0,n.version=b[1]),e.tablet=!!(a||g||r&&!t.match(/Mobile/)||m&&t.match(/Tablet/)||_&&!t.match(/Phone/)&&t.match(/Touch/)),e.phone=!(e.tablet||e.ipod||!(r||s||h||f||d||v&&t.match(/Android/)||v&&t.match(/CriOS\/([\d.]+)/)||m&&t.match(/Mobile/)||_&&t.match(/Touch/))),{browser:n,os:e,node:!1,canvasSupported:!!document.createElement("canvas").getContext,touchEventsSupported:"ontouchstart"in window&&!n.ie&&!n.edge,pointerEventsSupported:"onpointerdown"in window&&(n.edge||n.ie&&n.version>=10)}}var i={};i="undefined"==typeof navigator?{browser:{},os:{},node:!0,canvasSupported:!0}:n(navigator.userAgent),t.exports=i},function(t,e){var n=function(t){this.colorStops=t||[]};n.prototype={constructor:n,addColorStop:function(t,e){this.colorStops.push({offset:t,color:e})}},t.exports=n},function(t,e,n){function i(t,e){var n=t+":"+e;if(l[n])return l[n];for(var i=(t+"").split("\n"),r=0,a=0,o=i.length;o>a;a++)r=Math.max(p.measureText(i[a],e).width,r);return u>c&&(u=0,l={}),u++,l[n]=r,r}function r(t,e,n,r){var a=((t||"")+"").split("\n").length,o=i(t,e),s=i("国",e),h=a*s,l=new d(0,0,o,h);switch(l.lineHeight=s,r){case"bottom":case"alphabetic":l.y-=s;break;case"middle":l.y-=s/2}switch(n){case"end":case"right":l.x-=l.width;break;case"center":l.x-=l.width/2}return l}function a(t,e,n,i){var r=e.x,a=e.y,o=e.height,s=e.width,h=n.height,l=o/2-h/2,u="left";switch(t){case"left":r-=i,a+=l,u="right";break;case"right":r+=i+s,a+=l,u="left";break;case"top":r+=s/2,a-=i+h,u="center";break;case"bottom":r+=s/2,a+=o+i,u="center";break;case"inside":r+=s/2,a+=l,u="center";break;case"insideLeft":r+=i,a+=l,u="left";break;case"insideRight":r+=s-i,a+=l,u="right";break;case"insideTop":r+=s/2,a+=i,u="center";break;case"insideBottom":r+=s/2,a+=o-h-i,u="center";break;case"insideTopLeft":r+=i,a+=i,u="left";break;case"insideTopRight":r+=s-i,a+=i,u="right";break;case"insideBottomLeft":r+=i,a+=o-h-i;break;case"insideBottomRight":r+=s-i,a+=o-h-i,u="right"}return{x:r,y:a,textAlign:u,textBaseline:"top"}}function o(t,e,n,r){if(!n)return"";r=f.defaults({ellipsis:"...",minCharacters:3,maxIterations:3,cnCharWidth:i("国",e),ascCharWidth:i("a",e)},r,!0),n-=i(r.ellipsis);for(var a=(t+"").split("\n"),o=0,h=a.length;h>o;o++)a[o]=s(a[o],e,n,r);return a.join("\n")}function s(t,e,n,r){for(var a=0;;a++){var o=i(t,e);if(n>o||a>=r.maxIterations){t+=r.ellipsis;break}var s=0===a?h(t,n,r):Math.floor(t.length*n/o);if(sr&&e>i;r++){var o=t.charCodeAt(r);i+=o>=0&&127>=o?n.ascCharWidth:n.cnCharWidth}return r}var l={},u=0,c=5e3,f=n(1),d=n(8),p={getWidth:i,getBoundingRect:r,adjustTextPositionOnRect:a,ellipsis:o,measureText:function(t,e){var n=f.getContext();return n.font=e,n.measureText(t)}};t.exports=p},function(t,e,n){"use strict";function i(t){return t>-w&&w>t}function r(t){return t>w||-w>t}function a(t,e,n,i,r){var a=1-r;return a*a*(a*t+3*r*e)+r*r*(r*i+3*a*n)}function o(t,e,n,i,r){var a=1-r;return 3*(((e-t)*a+2*(n-e)*r)*a+(i-n)*r*r)}function s(t,e,n,r,a,o){var s=r+3*(e-n)-t,h=3*(n-2*e+t),l=3*(e-t),u=t-a,c=h*h-3*s*l,f=h*l-9*s*u,d=l*l-3*h*u,p=0;if(i(c)&&i(f))if(i(h))o[0]=0;else{var g=-l/h;g>=0&&1>=g&&(o[p++]=g)}else{var v=f*f-4*c*d;if(i(v)){var m=f/c,g=-h/s+m,y=-m/2;g>=0&&1>=g&&(o[p++]=g),y>=0&&1>=y&&(o[p++]=y)}else if(v>0){var x=b(v),w=c*h+1.5*s*(-f+x),C=c*h+1.5*s*(-f-x);w=0>w?-_(-w,S):_(w,S),C=0>C?-_(-C,S):_(C,S);var g=(-h-(w+C))/(3*s);g>=0&&1>=g&&(o[p++]=g)}else{var T=(2*c*h-3*s*f)/(2*b(c*c*c)),A=Math.acos(T)/3,I=b(c),k=Math.cos(A),g=(-h-2*I*k)/(3*s),y=(-h+I*(k+M*Math.sin(A)))/(3*s),L=(-h+I*(k-M*Math.sin(A)))/(3*s);g>=0&&1>=g&&(o[p++]=g),y>=0&&1>=y&&(o[p++]=y),L>=0&&1>=L&&(o[p++]=L)}}return p}function h(t,e,n,a,o){var s=6*n-12*e+6*t,h=9*e+3*a-3*t-9*n,l=3*e-3*t,u=0;if(i(h)){if(r(s)){var c=-l/s;c>=0&&1>=c&&(o[u++]=c)}}else{var f=s*s-4*h*l;if(i(f))o[0]=-s/(2*h);else if(f>0){var d=b(f),c=(-s+d)/(2*h),p=(-s-d)/(2*h);c>=0&&1>=c&&(o[u++]=c),p>=0&&1>=p&&(o[u++]=p)}}return u}function l(t,e,n,i,r,a){var o=(e-t)*r+t,s=(n-e)*r+e,h=(i-n)*r+n,l=(s-o)*r+o,u=(h-s)*r+s,c=(u-l)*r+l;a[0]=t,a[1]=o,a[2]=l,a[3]=c,a[4]=c,a[5]=u,a[6]=h,a[7]=i}function u(t,e,n,i,r,o,s,h,l,u,c){var f,d,p,g,v,m=.005,y=1/0;C[0]=l,C[1]=u;for(var _=0;1>_;_+=.05)T[0]=a(t,n,r,s,_),T[1]=a(e,i,o,h,_),g=x(C,T),y>g&&(f=_,y=g);y=1/0;for(var M=0;32>M&&!(w>m);M++)d=f-m,p=f+m,T[0]=a(t,n,r,s,d),T[1]=a(e,i,o,h,d),g=x(T,C),d>=0&&y>g?(f=d,y=g):(A[0]=a(t,n,r,s,p),A[1]=a(e,i,o,h,p),v=x(A,C),1>=p&&y>v?(f=p,y=v):m*=.5);return c&&(c[0]=a(t,n,r,s,f),c[1]=a(e,i,o,h,f)),b(y)}function c(t,e,n,i){var r=1-i;return r*(r*t+2*i*e)+i*i*n}function f(t,e,n,i){return 2*((1-i)*(e-t)+i*(n-e))}function d(t,e,n,a,o){var s=t-2*e+n,h=2*(e-t),l=t-a,u=0;if(i(s)){if(r(h)){var c=-l/h;c>=0&&1>=c&&(o[u++]=c)}}else{var f=h*h-4*s*l;if(i(f)){var c=-h/(2*s);c>=0&&1>=c&&(o[u++]=c)}else if(f>0){var d=b(f),c=(-h+d)/(2*s),p=(-h-d)/(2*s);c>=0&&1>=c&&(o[u++]=c),p>=0&&1>=p&&(o[u++]=p)}}return u}function p(t,e,n){var i=t+n-2*e;return 0===i?.5:(t-e)/i}function g(t,e,n,i,r){var a=(e-t)*i+t,o=(n-e)*i+e,s=(o-a)*i+a;r[0]=t,r[1]=a,r[2]=s,r[3]=s,r[4]=o,r[5]=n}function v(t,e,n,i,r,a,o,s,h){var l,u=.005,f=1/0;C[0]=o,C[1]=s;for(var d=0;1>d;d+=.05){T[0]=c(t,n,r,d),T[1]=c(e,i,a,d);var p=x(C,T);f>p&&(l=d,f=p)}f=1/0;for(var g=0;32>g&&!(w>u);g++){var v=l-u,m=l+u;T[0]=c(t,n,r,v),T[1]=c(e,i,a,v);var p=x(T,C);if(v>=0&&f>p)l=v,f=p;else{A[0]=c(t,n,r,m),A[1]=c(e,i,a,m);var y=x(A,C);1>=m&&f>y?(l=m,f=y):u*=.5}}return h&&(h[0]=c(t,n,r,l),h[1]=c(e,i,a,l)),b(f)}var m=n(5),y=m.create,x=m.distSquare,_=Math.pow,b=Math.sqrt,w=1e-4,M=b(3),S=1/3,C=y(),T=y(),A=y();t.exports={cubicAt:a,cubicDerivativeAt:o,cubicRootAt:s,cubicExtrema:h,cubicSubdivide:l,cubicProjectPoint:u,quadraticAt:c,quadraticDerivativeAt:f,quadraticRootAt:d,quadraticExtremum:p,quadraticSubdivide:g,quadraticProjectPoint:v}},function(t,e){var n="undefined"==typeof Float32Array?Array:Float32Array,i={create:function(){var t=new n(6);return i.identity(t),t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},mul:function(t,e,n){var i=e[0]*n[0]+e[2]*n[1],r=e[1]*n[0]+e[3]*n[1],a=e[0]*n[2]+e[2]*n[3],o=e[1]*n[2]+e[3]*n[3],s=e[0]*n[4]+e[2]*n[5]+e[4],h=e[1]*n[4]+e[3]*n[5]+e[5];return t[0]=i,t[1]=r,t[2]=a,t[3]=o,t[4]=s,t[5]=h,t},translate:function(t,e,n){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4]+n[0],t[5]=e[5]+n[1],t},rotate:function(t,e,n){var i=e[0],r=e[2],a=e[4],o=e[1],s=e[3],h=e[5],l=Math.sin(n),u=Math.cos(n);return t[0]=i*u+o*l,t[1]=-i*l+o*u,t[2]=r*u+s*l,t[3]=-r*l+u*s,t[4]=u*a+l*h,t[5]=u*h-l*a,t},scale:function(t,e,n){var i=n[0],r=n[1];return t[0]=e[0]*i,t[1]=e[1]*r,t[2]=e[2]*i,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*r,t},invert:function(t,e){var n=e[0],i=e[2],r=e[4],a=e[1],o=e[3],s=e[5],h=n*o-a*i;return h?(h=1/h,t[0]=o*h,t[1]=-a*h,t[2]=-i*h,t[3]=n*h,t[4]=(i*s-o*r)*h,t[5]=(a*r-n*s)*h,t):null}};t.exports=i},function(t,e,n){function i(t,e){var n=a.slice(arguments,2);return this.superClass.prototype[e].apply(t,n)}function r(t,e,n){return this.superClass.prototype[e].apply(t,n)}var a=n(1),o={},s=".",h="___EC__COMPONENT__CONTAINER___",l=o.parseClassType=function(t){var e={main:"",sub:""};return t&&(t=t.split(s),e.main=t[0]||"",e.sub=t[1]||""),e};o.enableClassExtend=function(t,e){t.extend=function(n){var o=function(){e&&e.apply(this,arguments),t.apply(this,arguments)};return a.extend(o.prototype,n),o.extend=this.extend,o.superCall=i,o.superApply=r,a.inherits(o,this),o.superClass=this,o}},o.enableClassManagement=function(t,e){function n(t){var e=i[t.main];return e&&e[h]||(e=i[t.main]={},e[h]=!0),e}e=e||{};var i={};if(t.registerClass=function(t,e){if(e)if(e=l(e),e.sub){if(e.sub!==h){var r=n(e);r[e.sub]=t}}else{if(i[e.main])throw new Error(e.main+"exists");i[e.main]=t}return t},t.getClass=function(t,e,n){var r=i[t];if(r&&r[h]&&(r=e?r[e]:null),n&&!r)throw new Error("Component "+t+"."+(e||"")+" not exists");return r},t.getClassesByMainType=function(t){t=l(t);var e=[],n=i[t.main];return n&&n[h]?a.each(n,function(t,n){n!==h&&e.push(t)}):e.push(n),e},t.hasClass=function(t){return t=l(t),!!i[t.main]},t.getAllClassMainTypes=function(){var t=[];return a.each(i,function(e,n){t.push(n)}),t},t.hasSubTypes=function(t){t=l(t);var e=i[t.main];return e&&e[h]},t.parseClassType=l,e.registerWhenExtend){var r=t.extend;r&&(t.extend=function(e){var n=r.call(this,e);return t.registerClass(n,e.type)})}return t},o.setReadOnly=function(t,e){},t.exports=o},function(t,e,n){var i=Array.prototype.slice,r=n(1),a=r.indexOf,o=function(){this._$handlers={}};o.prototype={constructor:o,one:function(t,e,n){var i=this._$handlers;return e&&t?(i[t]||(i[t]=[]),a(i[t],t)>=0?this:(i[t].push({h:e,one:!0,ctx:n||this}),this)):this},on:function(t,e,n){var i=this._$handlers;return e&&t?(i[t]||(i[t]=[]),i[t].push({h:e,one:!1,ctx:n||this}),this):this},isSilent:function(t){var e=this._$handlers;return e[t]&&e[t].length},off:function(t,e){var n=this._$handlers;if(!t)return this._$handlers={},this;if(e){if(n[t]){for(var i=[],r=0,a=n[t].length;a>r;r++)n[t][r].h!=e&&i.push(n[t][r]);n[t]=i}n[t]&&0===n[t].length&&delete n[t]}else delete n[t];return this},trigger:function(t){if(this._$handlers[t]){var e=arguments,n=e.length;n>3&&(e=i.call(e,1));for(var r=this._$handlers[t],a=r.length,o=0;a>o;){switch(n){case 1:r[o].h.call(r[o].ctx);break;case 2:r[o].h.call(r[o].ctx,e[1]);break;case 3:r[o].h.call(r[o].ctx,e[1],e[2]);break;default:r[o].h.apply(r[o].ctx,e)}r[o].one?(r.splice(o,1),a--):o++}}return this},triggerWithContext:function(t){if(this._$handlers[t]){var e=arguments,n=e.length;n>4&&(e=i.call(e,1,e.length-1));for(var r=e[e.length-1],a=this._$handlers[t],o=a.length,s=0;o>s;){switch(n){case 1:a[s].h.call(r);break;case 2:a[s].h.call(r,e[1]);break;case 3:a[s].h.call(r,e[1],e[2]);break;default:a[s].h.apply(r,e)}a[s].one?(a.splice(s,1),o--):s++}}return this}},t.exports=o},function(t,e){function n(t){return t=Math.round(t),0>t?0:t>255?255:t}function i(t){return t=Math.round(t),0>t?0:t>360?360:t}function r(t){return 0>t?0:t>1?1:t}function a(t){return n(t.length&&"%"===t.charAt(t.length-1)?parseFloat(t)/100*255:parseInt(t,10))}function o(t){return r(t.length&&"%"===t.charAt(t.length-1)?parseFloat(t)/100:parseFloat(t))}function s(t,e,n){return 0>n?n+=1:n>1&&(n-=1),1>6*n?t+(e-t)*n*6:1>2*n?e:2>3*n?t+(e-t)*(2/3-n)*6:t}function h(t,e,n){return t+(e-t)*n}function l(t){if(t){t+="";var e=t.replace(/ /g,"").toLowerCase();if(e in _)return _[e].slice();if("#"!==e.charAt(0)){var n=e.indexOf("("),i=e.indexOf(")");if(-1!==n&&i+1===e.length){var r=e.substr(0,n),s=e.substr(n+1,i-(n+1)).split(","),h=1;switch(r){case"rgba":if(4!==s.length)return;h=o(s.pop());case"rgb":if(3!==s.length)return;return[a(s[0]),a(s[1]),a(s[2]),h];case"hsla":if(4!==s.length)return;return s[3]=o(s[3]),u(s);case"hsl":if(3!==s.length)return;return u(s);default:return}}}else{if(4===e.length){var l=parseInt(e.substr(1),16);if(!(l>=0&&4095>=l))return;return[(3840&l)>>4|(3840&l)>>8,240&l|(240&l)>>4,15&l|(15&l)<<4,1]}if(7===e.length){var l=parseInt(e.substr(1),16);if(!(l>=0&&16777215>=l))return;return[(16711680&l)>>16,(65280&l)>>8,255&l,1]}}}}function u(t){var e=(parseFloat(t[0])%360+360)%360/360,i=o(t[1]),r=o(t[2]),a=.5>=r?r*(i+1):r+i-r*i,h=2*r-a,l=[n(255*s(h,a,e+1/3)),n(255*s(h,a,e)),n(255*s(h,a,e-1/3))];return 4===t.length&&(l[3]=t[3]),l}function c(t){if(t){var e,n,i=t[0]/255,r=t[1]/255,a=t[2]/255,o=Math.min(i,r,a),s=Math.max(i,r,a),h=s-o,l=(s+o)/2;if(0===h)e=0,n=0;else{n=.5>l?h/(s+o):h/(2-s-o);var u=((s-i)/6+h/2)/h,c=((s-r)/6+h/2)/h,f=((s-a)/6+h/2)/h;i===s?e=f-c:r===s?e=1/3+u-f:a===s&&(e=2/3+c-u),0>e&&(e+=1),e>1&&(e-=1)}var d=[360*e,n,l];return null!=t[3]&&d.push(t[3]),d}}function f(t,e){var n=l(t);if(n){for(var i=0;3>i;i++)0>e?n[i]=n[i]*(1-e)|0:n[i]=(255-n[i])*e+n[i]|0;return x(n,4===n.length?"rgba":"rgb")}}function d(t,e){var n=l(t);return n?((1<<24)+(n[0]<<16)+(n[1]<<8)+ +n[2]).toString(16).slice(1):void 0}function p(t,e,i){if(e&&e.length&&t>=0&&1>=t){i=i||[0,0,0,0];var r=t*(e.length-1),a=Math.floor(r),o=Math.ceil(r),s=e[a],l=e[o],u=r-a;return i[0]=n(h(s[0],l[0],u)),i[1]=n(h(s[1],l[1],u)),i[2]=n(h(s[2],l[2],u)),i[3]=n(h(s[3],l[3],u)),i}}function g(t,e,i){if(e&&e.length&&t>=0&&1>=t){var a=t*(e.length-1),o=Math.floor(a),s=Math.ceil(a),u=l(e[o]),c=l(e[s]),f=a-o,d=x([n(h(u[0],c[0],f)),n(h(u[1],c[1],f)),n(h(u[2],c[2],f)),r(h(u[3],c[3],f))],"rgba");return i?{color:d,leftIndex:o,rightIndex:s,value:a}:d}}function v(t,e){if(!(2!==t.length||t[1]0&&s>=h;h++)r.push({color:e[h],offset:(h-n.value)/a});return r.push({color:i.color,offset:1}),r}}function m(t,e,n,r){return t=l(t),t?(t=c(t),null!=e&&(t[0]=i(e)),null!=n&&(t[1]=o(n)),null!=r&&(t[2]=o(r)),x(u(t),"rgba")):void 0}function y(t,e){return t=l(t),t&&null!=e?(t[3]=r(e),x(t,"rgba")):void 0}function x(t,e){return"rgb"!==e&&"hsv"!==e&&"hsl"!==e||(t=t.slice(0,3)),e+"("+t.join(",")+")"}var _={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};t.exports={parse:l,lift:f,toHex:d,fastMapToColor:p,mapToColor:g,mapIntervalToColor:v,modifyHSL:m,modifyAlpha:y,stringify:x}},function(t,e,n){var i=n(123),r=n(37);n(124),n(122);var a=n(32),o=n(4),s=n(1),h=n(17),l={};l.getScaleExtent=function(t,e){var n=t.scale,i=n.getExtent(),r=i[1]-i[0];if("ordinal"===n.type)return isFinite(r)?i:[0,0];var a=e.getMin?e.getMin():e.get("min"),h=e.getMax?e.getMax():e.get("max"),l=e.getNeedCrossZero?e.getNeedCrossZero():!e.get("scale"),u=e.get("boundaryGap");s.isArray(u)||(u=[u||0,u||0]),u[0]=o.parsePercent(u[0],1),u[1]=o.parsePercent(u[1],1);var c=!0,f=!0;return null==a&&(a=i[0]-u[0]*r,c=!1),null==h&&(h=i[1]+u[1]*r,f=!1),"dataMin"===a&&(a=i[0]),"dataMax"===h&&(h=i[1]),l&&(a>0&&h>0&&!c&&(a=0),0>a&&0>h&&!f&&(h=0)),[a,h]},l.niceScaleExtent=function(t,e){var n=t.scale,i=l.getScaleExtent(t,e),r=null!=e.get("min"),a=null!=e.get("max");n.setExtent(i[0],i[1]),n.niceExtent(e.get("splitNumber"),r,a);var o=e.get("interval");null!=o&&n.setInterval&&n.setInterval(o)},l.createScaleByModel=function(t,e){if(e=e||t.get("type"))switch(e){case"category":return new i(t.getCategories(),[1/0,-(1/0)]);case"value":return new r;default:return(a.getClass(e)||r).create(t)}},l.ifAxisCrossZero=function(t){var e=t.scale.getExtent(),n=e[0],i=e[1];return!(n>0&&i>0||0>n&&0>i)},l.getAxisLabelInterval=function(t,e,n,i){var r,a=0,o=0,s=1;e.length>40&&(s=Math.round(e.length/40));for(var l=0;l1?s:a*s},l.getFormattedLabels=function(t,e){var n=t.scale,i=n.getTicksLabels(),r=n.getTicks();return"string"==typeof e?(e=function(t){return function(e){return t.replace("{value}",e)}}(e),s.map(i,e)):"function"==typeof e?s.map(r,function(i,r){return e("category"===t.type?n.getLabel(i):i,r)},this):i},t.exports=l},function(t,e,n){"use strict";var i=n(3),r=n(8),a=i.extendShape({type:"triangle",shape:{cx:0,cy:0,width:0,height:0},buildPath:function(t,e){var n=e.cx,i=e.cy,r=e.width/2,a=e.height/2;t.moveTo(n,i-a),t.lineTo(n+r,i+a),t.lineTo(n-r,i+a),t.closePath()}}),o=i.extendShape({type:"diamond",shape:{cx:0,cy:0,width:0,height:0},buildPath:function(t,e){var n=e.cx,i=e.cy,r=e.width/2,a=e.height/2;t.moveTo(n,i-a),t.lineTo(n+r,i),t.lineTo(n,i+a),t.lineTo(n-r,i),t.closePath()}}),s=i.extendShape({type:"pin",shape:{x:0,y:0,width:0,height:0},buildPath:function(t,e){var n=e.x,i=e.y,r=e.width/5*3,a=Math.max(r,e.height),o=r/2,s=o*o/(a-o),h=i-a+o+s,l=Math.asin(s/o),u=Math.cos(l)*o,c=Math.sin(l),f=Math.cos(l);t.arc(n,h,o,Math.PI-l,2*Math.PI+l);var d=.6*o,p=.7*o;t.bezierCurveTo(n+u-c*d,h+s+f*d,n,i-p,n,i),t.bezierCurveTo(n,i-p,n-u+c*d,h+s+f*d,n-u,h+s),t.closePath()}}),h=i.extendShape({type:"arrow",shape:{x:0,y:0,width:0,height:0},buildPath:function(t,e){var n=e.height,i=e.width,r=e.x,a=e.y,o=i/3*2;t.moveTo(r,a),t.lineTo(r+o,a+n),t.lineTo(r,a+n/4*3),t.lineTo(r-o,a+n),t.lineTo(r,a),t.closePath()}}),l={line:i.Line,rect:i.Rect,roundRect:i.Rect,square:i.Rect,circle:i.Circle,diamond:o,pin:s,arrow:h,triangle:a},u={line:function(t,e,n,i,r){r.x1=t,r.y1=e+i/2,r.x2=t+n,r.y2=e+i/2},rect:function(t,e,n,i,r){r.x=t,r.y=e,r.width=n,r.height=i},roundRect:function(t,e,n,i,r){r.x=t,r.y=e,r.width=n,r.height=i,r.r=Math.min(n,i)/4},square:function(t,e,n,i,r){var a=Math.min(n,i);r.x=t,r.y=e,r.width=a,r.height=a},circle:function(t,e,n,i,r){r.cx=t+n/2,r.cy=e+i/2,r.r=Math.min(n,i)/2},diamond:function(t,e,n,i,r){r.cx=t+n/2,r.cy=e+i/2,r.width=n,r.height=i},pin:function(t,e,n,i,r){r.x=t+n/2,r.y=e+i/2,r.width=n,r.height=i},arrow:function(t,e,n,i,r){r.x=t+n/2,r.y=e+i/2,r.width=n,r.height=i},triangle:function(t,e,n,i,r){r.cx=t+n/2,r.cy=e+i/2,r.width=n,r.height=i}},c={};for(var f in l)c[f]=new l[f];var d=i.extendShape({type:"symbol",shape:{symbolType:"",x:0,y:0,width:0,height:0},beforeBrush:function(){var t=this.style,e=this.shape;"pin"===e.symbolType&&"inside"===t.textPosition&&(t.textPosition=["50%","40%"],t.textAlign="center",t.textVerticalAlign="middle")},buildPath:function(t,e){var n=e.symbolType,i=c[n];"none"!==e.symbolType&&(i||(n="rect",i=c[n]),u[n](e.x,e.y,e.width,e.height,i.shape),i.buildPath(t,i.shape))}}),p=function(t){if("image"!==this.type){var e=this.style,n=this.shape;n&&"line"===n.symbolType?e.stroke=t:this.__isEmptyBrush?(e.stroke=t,e.fill="#fff"):(e.fill&&(e.fill=t),e.stroke&&(e.stroke=t)),this.dirty()}},g={createSymbol:function(t,e,n,a,o,s){var h=0===t.indexOf("empty");h&&(t=t.substr(5,1).toLowerCase()+t.substr(6));var l;return l=0===t.indexOf("image://")?new i.Image({style:{image:t.slice(8),x:e,y:n,width:a,height:o}}):0===t.indexOf("path://")?i.makePath(t.slice(7),{},new r(e,n,a,o)):new d({shape:{symbolType:t,x:e,y:n,width:a,height:o}}),l.__isEmptyBrush=h,l.setColor=p,l.setColor(s),l}};t.exports=g},function(t,e,n){function i(){this.group=new o,this.uid=s.getUID("viewChart")}function r(t,e){if(t&&(t.trigger(e),"group"===t.type))for(var n=0;n=0&&(n.splice(i,0,t),this._doAdd(t))}return this},_doAdd:function(t){t.parent&&t.parent.remove(t),t.parent=this;var e=this.__storage,n=this.__zr;e&&e!==t.__storage&&(e.addToMap(t),t instanceof o&&t.addChildrenToStorage(e)),n&&n.refresh()},remove:function(t){var e=this.__zr,n=this.__storage,r=this._children,a=i.indexOf(r,t);return 0>a?this:(r.splice(a,1),t.parent=null,n&&(n.delFromMap(t.id),t instanceof o&&t.delChildrenFromStorage(n)),e&&e.refresh(),this)},removeAll:function(){var t,e,n=this._children,i=this.__storage;for(e=0;en;n++)this.data[n]=t[n];this._len=e},appendPath:function(t){t instanceof Array||(t=[t]);for(var e=t.length,n=0,i=this._len,r=0;e>r;r++)n+=t[r].len();m&&this.data instanceof Float32Array&&(this.data=new Float32Array(i+n));for(var r=0;e>r;r++)for(var a=t[r].data,o=0;oe.length&&(this._expandData(),e=this.data);for(var n=0;na&&(a=r+a),a%=r,g-=a*u,m-=a*c;u>=0&&t>=g||0>u&&g>t;)i=this._dashIdx,n=o[i],g+=u*n,m+=c*n,this._dashIdx=(i+1)%y,u>0&&h>g||0>u&&g>h||s[i%2?"moveTo":"lineTo"](u>=0?f(g,t):d(g,t),c>=0?f(m,e):d(m,e));u=g-t,c=m-e,this._dashOffset=-v(u*u+c*c)},_dashedBezierTo:function(t,e,n,r,a,o){var s,h,l,u,c,f=this._dashSum,d=this._dashOffset,p=this._lineDash,g=this._ctx,m=this._xi,y=this._yi,x=i.cubicAt,_=0,b=this._dashIdx,w=p.length,M=0;for(0>d&&(d=f+d),d%=f,s=0;1>s;s+=.1)h=x(m,t,n,a,s+.1)-x(m,t,n,a,s),l=x(y,e,r,o,s+.1)-x(y,e,r,o,s),_+=v(h*h+l*l);for(;w>b&&(M+=p[b],!(M>d));b++);for(s=(M-d)/_;1>=s;)u=x(m,t,n,a,s),c=x(y,e,r,o,s),b%2?g.moveTo(u,c):g.lineTo(u,c),s+=p[b]/_,b=(b+1)%w;b%2!==0&&g.lineTo(a,o),h=a-u,l=o-c,this._dashOffset=-v(h*h+l*l)},_dashedQuadraticTo:function(t,e,n,i){var r=n,a=i;n=(n+2*t)/3,i=(i+2*e)/3,t=(this._xi+2*t)/3,e=(this._yi+2*e)/3,this._dashedBezierTo(t,e,n,i,r,a)},toStatic:function(){var t=this.data;t instanceof Array&&(t.length=this._len,m&&(this.data=new Float32Array(t)))},getBoundingRect:function(){h[0]=h[1]=u[0]=u[1]=Number.MAX_VALUE,l[0]=l[1]=c[0]=c[1]=-Number.MAX_VALUE;for(var t=this.data,e=0,n=0,i=0,f=0,d=0;dh?o:h,p=o>h?1:o/h,g=o>h?h/o:1,v=Math.abs(o-h)>.001;v?(t.translate(r,a),t.rotate(c),t.scale(p,g),t.arc(0,0,d,l,l+u,1-f),t.scale(1/p,1/g),t.rotate(-c),t.translate(-r,-a)):t.arc(r,a,d,l,l+u,1-f);break;case s.R:t.rect(e[n++],e[n++],e[n++],e[n++]);break;case s.Z:t.closePath()}}}},y.CMD=s,t.exports=y},function(t,e){"use strict";function n(){this._coordinateSystems=[]}var i={};n.prototype={constructor:n,create:function(t,e){var n=[];for(var r in i){var a=i[r].create(t,e);a&&(n=n.concat(a))}this._coordinateSystems=n},update:function(t,e){for(var n=this._coordinateSystems,i=0;i=0)){var o=this.getShallow(a);null!=o&&(n[t[r][0]]=o)}}return n}}},function(t,e,n){function i(t,e,n,i){if(!e)return t;var s=a(e[0]),h=o.isArray(s)&&s.length||1;n=n||[],i=i||"extra";for(var l=0;h>l;l++)if(!t[l]){var u=n[l]||i+(l-n.length);t[l]=r(e,l)?{type:"ordinal",name:u}:u}return t}function r(t,e){for(var n=0,i=t.length;i>n;n++){var r=a(t[n]);if(!o.isArray(r))return!1;var r=r[e];if(null!=r&&isFinite(r))return!1;if(o.isString(r)&&"-"!==r)return!0}return!1}function a(t){return o.isArray(t)?t:o.isObject(t)?t.value:t}var o=n(1);t.exports=i},function(t,e,n){function i(){this._extent=[1/0,-(1/0)],this._interval=0,this.init&&this.init.apply(this,arguments)}var r=n(20),a=i.prototype;a.parse=function(t){return t},a.contain=function(t){var e=this._extent;return t>=e[0]&&t<=e[1]},a.normalize=function(t){var e=this._extent;return e[1]===e[0]?.5:(t-e[0])/(e[1]-e[0])},a.scale=function(t){var e=this._extent;return t*(e[1]-e[0])+e[0]},a.unionExtent=function(t){var e=this._extent;t[0]e[1]&&(e[1]=t[1])},a.getExtent=function(){return this._extent.slice()},a.setExtent=function(t,e){var n=this._extent;isNaN(t)||(n[0]=t),isNaN(e)||(n[1]=e)},a.getTicksLabels=function(){for(var t=[],e=this.getTicks(),n=0;n=0;if(r){var a="touchend"!=n?e.targetTouches[0]:e.changedTouches[0];if(a){var o=i(t);e.zrX=a.clientX-o.left,e.zrY=a.clientY-o.top}}else{var s=i(t);e.zrX=e.clientX-s.left,e.zrY=e.clientY-s.top,e.zrDelta=e.wheelDelta?e.wheelDelta/120:-(e.detail||0)/3}return e}function a(t,e,n){h?t.addEventListener(e,n):t.attachEvent("on"+e,n)}function o(t,e,n){h?t.removeEventListener(e,n):t.detachEvent("on"+e,n)}var s=n(21),h="undefined"!=typeof window&&!!window.addEventListener,l=h?function(t){t.preventDefault(),t.stopPropagation(),t.cancelBubble=!0}:function(t){t.returnValue=!1,t.cancelBubble=!0};t.exports={normalizeEvent:r,addEventListener:a,removeEventListener:o,stop:l,Dispatcher:s}},function(t,e,n){"use strict";var i=n(3),r=n(1);n(51),n(95),n(2).extendComponentView({type:"grid",render:function(t,e){this.group.removeAll(),t.get("show")&&this.group.add(new i.Rect({shape:t.coordinateSystem.getRect(),style:r.defaults({fill:t.get("backgroundColor")},t.getItemStyle()),silent:!0}))}})},function(t,e,n){function i(t){t=t||{},o.call(this,t);for(var e in t)t.hasOwnProperty(e)&&"style"!==e&&(this[e]=t[e]);this.style=new a(t.style),this._rect=null,this.__clipPaths=[]}var r=n(1),a=n(141),o=n(55),s=n(66);i.prototype={constructor:i,type:"displayable",__dirty:!0,invisible:!1,z:0,z2:0,zlevel:0,draggable:!1,dragging:!1,silent:!1,culling:!1,cursor:"pointer",rectHover:!1,beforeBrush:function(t){},afterBrush:function(t){},brush:function(t){},getBoundingRect:function(){},contain:function(t,e){return this.rectContain(t,e)},traverse:function(t,e){t.call(e,this)},rectContain:function(t,e){var n=this.transformCoordToLocal(t,e),i=this.getBoundingRect();return i.contain(n[0],n[1])},dirty:function(){this.__dirty=!0,this._rect=null,this.__zr&&this.__zr.refresh()},animateStyle:function(t){return this.animate("style",t)},attrKV:function(t,e){"style"!==t?o.prototype.attrKV.call(this,t,e):this.style.set(e)},setStyle:function(t,e){return this.style.set(t,e),this.dirty(),this}},r.inherits(i,o),r.mixin(i,s),t.exports=i},function(t,e,n){"use strict";function i(t){for(var e=0;e1){n=[];for(var a=0;r>a;a++)n[a]=i[e[a][0]]}else n=i.slice(0)}}return n}var l=n(14),u=n(31),c=n(1),f=n(7),d=n(28),p=f.getDataItemValue,g=f.converDataValue,v={cartesian2d:function(t,e,n){var i=n.getComponent("xAxis",e.get("xAxisIndex")),r=n.getComponent("yAxis",e.get("yAxisIndex")),a=i.get("type"),h=r.get("type"),l=[{name:"x",type:s(a),stackable:o(a)},{name:"y",type:s(h),stackable:o(h)}];return u(l,t,["x","y","z"]),{dimensions:l,categoryAxisModel:"category"===a?i:"category"===h?r:null}},polar:function(t,e,n){var i=e.get("polarIndex")||0,r=function(t){return t.get("polarIndex")===i},a=n.findComponents({mainType:"angleAxis",filter:r})[0],h=n.findComponents({mainType:"radiusAxis",filter:r})[0],l=h.get("type"),c=a.get("type"),f=[{name:"radius",type:s(l),stackable:o(l)},{name:"angle",type:s(c),stackable:o(c)}];return u(f,t,["radius","angle","value"]),{dimensions:f,categoryAxisModel:"category"===c?a:"category"===l?h:null}},geo:function(t,e,n){return{dimensions:u([{name:"lng"},{name:"lat"}],t,["lng","lat","value"])}}};t.exports=a},function(t,e,n){var i=n(4),r=n(9),a=n(32),o=Math.floor,s=Math.ceil,h=a.extend({type:"interval",_interval:0,setExtent:function(t,e){var n=this._extent;isNaN(t)||(n[0]=parseFloat(t)),isNaN(e)||(n[1]=parseFloat(e))},unionExtent:function(t){var e=this._extent;t[0]e[1]&&(e[1]=t[1]),h.prototype.setExtent.call(this,e[0],e[1])},getInterval:function(){return this._interval||this.niceTicks(),this._interval},setInterval:function(t){this._interval=t,this._niceExtent=this._extent.slice()},getTicks:function(){this._interval||this.niceTicks();var t=this._interval,e=this._extent,n=[],r=1e4;if(t){var a=this._niceExtent;e[0]r)return[];e[1]>a[1]&&n.push(e[1])}return n},getTicksLabels:function(){for(var t=[],e=this.getTicks(),n=0;nn&&(n=-n,e.reverse());var r=i.nice(n/t,!0),a=[i.round(s(e[0]/r)*r),i.round(o(e[1]/r)*r)];this._interval=r,this._niceExtent=a}},niceExtent:function(t,e,n){var r=this._extent;if(r[0]===r[1])if(0!==r[0]){var a=r[0]/2;r[0]-=a,r[1]+=a}else r[1]=1;var h=r[1]-r[0];isFinite(h)||(r[0]=0,r[1]=1),this.niceTicks(t);var l=this._interval;e||(r[0]=i.round(o(r[0]/l)*l)),n||(r[1]=i.round(s(r[1]/l)*l))}});h.create=function(){return new h},t.exports=h},function(t,e,n){function i(t){this.group=new a.Group,this._symbolCtor=t||o}function r(t,e,n){var i=t.getItemLayout(e);return i&&!isNaN(i[0])&&!isNaN(i[1])&&!(n&&n(e))&&"none"!==t.getItemVisual(e,"symbol")}var a=n(3),o=n(47),s=i.prototype;s.updateData=function(t,e){var n=this.group,i=t.hostModel,o=this._data,s=this._symbolCtor;t.diff(o).add(function(i){var a=t.getItemLayout(i);if(r(t,i,e)){var o=new s(t,i);o.attr("position",a),t.setItemGraphicEl(i,o),n.add(o)}}).update(function(h,l){var u=o.getItemGraphicEl(l),c=t.getItemLayout(h);return r(t,h,e)?(u?(u.updateData(t,h),a.updateProps(u,{position:c},i)):(u=new s(t,h),u.attr("position",c)),n.add(u),void t.setItemGraphicEl(h,u)):void n.remove(u)}).remove(function(t){var e=o.getItemGraphicEl(t);e&&e.fadeOut(function(){n.remove(e)})}).execute(),this._data=t},s.updateLayout=function(){var t=this._data;t&&t.eachItemGraphicEl(function(e,n){e.attr("position",t.getItemLayout(n))})},s.remove=function(t){var e=this.group,n=this._data;n&&(t?n.eachItemGraphicEl(function(t){t.fadeOut(function(){e.remove(t)})}):e.removeAll())},t.exports=i},,,function(t,e,n){var i=n(1),r=n(20),a=r.parseClassType,o=0,s={},h="_";s.getUID=function(t){return[t||"",o++,Math.random()].join(h)},s.enableSubTypeDefaulter=function(t){var e={};return t.registerSubTypeDefaulter=function(t,n){t=a(t),e[t.main]=n},t.determineSubType=function(n,i){var r=i.type;if(!r){var o=a(n).main;t.hasSubTypes(n)&&e[o]&&(r=e[o](i))}return r},t},s.enableTopologicalTravel=function(t,e){function n(t){var n={},o=[];return i.each(t,function(s){var h=r(n,s),l=h.originalDeps=e(s),u=a(l,t);h.entryCount=u.length,0===h.entryCount&&o.push(s),i.each(u,function(t){i.indexOf(h.predecessor,t)<0&&h.predecessor.push(t);var e=r(n,t);i.indexOf(e.successor,t)<0&&e.successor.push(s)})}),{graph:n,noEntryList:o}}function r(t,e){return t[e]||(t[e]={predecessor:[],successor:[]}),t[e]}function a(t,e){var n=[];return i.each(t,function(t){i.indexOf(e,t)>=0&&n.push(t)}),n}t.topologicalTravel=function(t,e,r,a){function o(t){l[t].entryCount--,0===l[t].entryCount&&u.push(t)}function s(t){c[t]=!0,o(t)}if(t.length){var h=n(e),l=h.graph,u=h.noEntryList,c={};for(i.each(t,function(t){c[t]=!0});u.length;){var f=u.pop(),d=l[f],p=!!c[f];p&&(r.call(a,f,d.originalDeps.slice()),delete c[f]),i.each(d.successor,p?s:o)}i.each(c,function(){throw new Error("Circle dependency may exists")})}}},t.exports=s},function(t,e){var n=1;"undefined"!=typeof window&&(n=Math.max(window.devicePixelRatio||1,1));var i={debugMode:0,devicePixelRatio:n};t.exports=i},function(t,e,n){function i(t,e){var n=t[1]-t[0],i=e,r=n/i/2;t[0]+=r,t[1]-=r}var r=n(4),a=r.linearMap,o=n(1),s=[0,1],h=function(t,e,n){this.dim=t,this.scale=e,this._extent=n||[0,0],this.inverse=!1,this.onBand=!1};h.prototype={constructor:h,contain:function(t){var e=this._extent,n=Math.min(e[0],e[1]),i=Math.max(e[0],e[1]);return t>=n&&i>=t},containData:function(t){return this.contain(this.dataToCoord(t))},getExtent:function(){var t=this._extent.slice();return t},getPixelPrecision:function(t){return r.getPixelPrecision(t||this.scale.getExtent(),this._extent)},setExtent:function(t,e){var n=this._extent;n[0]=t,n[1]=e},dataToCoord:function(t,e){var n=this._extent,r=this.scale;return t=r.normalize(t),this.onBand&&"ordinal"===r.type&&(n=n.slice(),i(n,r.count())),a(t,s,n,e)},coordToData:function(t,e){var n=this._extent,r=this.scale;this.onBand&&"ordinal"===r.type&&(n=n.slice(),i(n,r.count()));var o=a(t,n,s,e);return this.scale.scale(o)},getTicksCoords:function(){if(this.onBand){for(var t=this.getBands(),e=[],n=0;no;o++)e.push([a*o/n+i,a*(o+1)/n+i]);return e},getBandWidth:function(){var t=this._extent,e=this.scale.getExtent(),n=e[1]-e[0]+(this.onBand?1:0),i=Math.abs(t[1]-t[0]);return Math.abs(i)/n}},t.exports=h},function(t,e){t.exports=function(t,e,n,i,r){i.eachRawSeriesByType(t,function(t){var r=t.getData(),a=t.get("symbol")||e,o=t.get("symbolSize");r.setVisual({legendSymbol:n||a,symbol:a,symbolSize:o}),i.isSeriesFiltered(t)||("function"==typeof o&&r.each(function(e){var n=t.getRawValue(e),i=t.getDataParams(e);r.setItemVisual(e,"symbolSize",o(n,i))}),r.each(function(t){var e=r.getItemModel(t),n=e.get("symbol",!0),i=e.get("symbolSize",!0);null!=n&&r.setItemVisual(t,"symbol",n),null!=i&&r.setItemVisual(t,"symbolSize",i)}))})}},function(t,e,n){var i=n(42);t.exports=function(){if(0!==i.debugMode)if(1==i.debugMode)for(var t in arguments)throw new Error(arguments[t]);else if(i.debugMode>1)for(var t in arguments)console.log(arguments[t])}},function(t,e,n){var i=n(35),r=n(8),a=n(1),o=n(60),s=n(139),h=new s(50),l=function(t){i.call(this,t)};l.prototype={constructor:l,type:"image",brush:function(t){var e,n=this.style,i=n.image;if(e="string"==typeof i?this._image:i,!e&&i){var r=h.get(i);if(!r)return e=new Image,e.onload=function(){e.onload=null;for(var t=0;t0?"top":"bottom",i="center"):u(a-c)?(r=n>0?"bottom":"top",i="center"):(r="middle",i=a>0&&c>a?n>0?"right":"left":n>0?"left":"right"),{rotation:a,textAlign:i,verticalAlign:r}}function r(t,e,n){var i,r,a=l(-t.rotation),o=n[0]>n[1],s="start"===e&&!o||"start"!==e&&o;return u(a-c/2)?(r=s?"bottom":"top",i="center"):u(a-1.5*c)?(r=s?"top":"bottom",i="center"):(r="middle",i=1.5*c>a&&a>c/2?s?"left":"right":s?"right":"left"),{rotation:a,textAlign:i,verticalAlign:r}}var a=n(1),o=n(3),s=n(12),h=n(4),l=h.remRadian,u=h.isRadianAroundZero,c=Math.PI,f=function(t,e){this.opt=e,this.axisModel=t,a.defaults(e,{labelOffset:0,nameDirection:1,tickDirection:1,labelDirection:1,silent:!0}),this.group=new o.Group({position:e.position.slice(),rotation:e.rotation})};f.prototype={constructor:f,hasBuilder:function(t){return!!d[t]},add:function(t){d[t].call(this)},getGroup:function(){return this.group}};var d={axisLine:function(){var t=this.opt,e=this.axisModel;if(e.get("axisLine.show")){var n=this.axisModel.axis.getExtent();this.group.add(new o.Line({shape:{x1:n[0],y1:0,x2:n[1],y2:0},style:a.extend({lineCap:"round"},e.getModel("axisLine.lineStyle").getLineStyle()),strokeContainThreshold:t.strokeContainThreshold,silent:!!t.silent,z2:1}))}},axisTick:function(){var t=this.axisModel;if(t.get("axisTick.show")){for(var e=t.axis,n=t.getModel("axisTick"),i=this.opt,r=n.getModel("lineStyle"),a=n.get("length"),s=g(n,i.labelInterval),h=e.getTicksCoords(),l=[],u=0;uc[1]?-1:1,d=["start"===s?c[0]-f*u:"end"===s?c[1]+f*u:(c[0]+c[1])/2,"middle"===s?t.labelOffset+h*u:0];a="middle"===s?i(t,t.rotation,h):r(t,s,c),this.group.add(new o.Text({style:{text:n,textFont:l.getFont(),fill:l.getTextColor()||e.get("axisLine.lineStyle.color"),textAlign:a.textAlign,textVerticalAlign:a.verticalAlign},position:d,rotation:a.rotation,silent:!0,z2:1}))}}},p=f.ifIgnoreOnTick=function(t,e,n){var i,r=t.scale;return"ordinal"===r.type&&("function"==typeof n?(i=r.getTicks()[e],!n(i,r.getLabel(i))):e%(n+1))},g=f.getInterval=function(t,e){var n=t.get("interval");return null!=n&&"auto"!=n||(n=e),n};t.exports=f},function(t,e,n){function i(t){return o.isObject(t)&&null!=t.value?t.value:t}function r(){return"category"===this.get("type")&&o.map(this.get("data"),i)}function a(){return s.getFormattedLabels(this.axis,this.get("axisLabel.formatter"))}var o=n(1),s=n(23);t.exports={getFormattedLabels:a,getCategories:r}},function(t,e,n){"use strict";function i(t,e){return e.type||(e.data?"category":"value")}var r=n(10),a=n(1),o=n(61),s=r.extend({type:"cartesian2dAxis",axis:null,init:function(){s.superApply(this,"init",arguments),this._resetRange()},mergeOption:function(){s.superApply(this,"mergeOption",arguments),this._resetRange()},restoreData:function(){s.superApply(this,"restoreData",arguments),this._resetRange()},setRange:function(t,e){this.option.rangeStart=t,this.option.rangeEnd=e},getMin:function(){var t=this.option;return null!=t.rangeStart?t.rangeStart:t.min},getMax:function(){var t=this.option;return null!=t.rangeEnd?t.rangeEnd:t.max},getNeedCrossZero:function(){var t=this.option;return null!=t.rangeStart||null!=t.rangeEnd?!1:!t.scale},_resetRange:function(){this.option.rangeStart=this.option.rangeEnd=null}});a.merge(s.prototype,n(49));var h={gridIndex:0};o("x",s,i,h),o("y",s,i,h),t.exports=s},function(t,e,n){function i(t,e,n){return n.getComponent("grid",t.get("gridIndex"))===e}function r(t){var e,n=t.model,i=n.getFormattedLabels(),r=1,a=i.length;a>40&&(r=Math.ceil(a/40));for(var o=0;a>o;o+=r)if(!t.isLabelIgnored(o)){var s=n.getTextRect(i[o]);e?e.union(s):e=s}return e}function a(t,e,n){this._coordsMap={},this._coordsList=[],this._axesMap={},this._axesList=[],this._initCartesian(t,e,n),this._model=t}function o(t,e){var n=t.getExtent(),i=n[0]+n[1];t.toGlobalCoord="x"===t.dim?function(t){return t+e}:function(t){return i-t+e},t.toLocalCoord="x"===t.dim?function(t){return t-e}:function(t){return i-t+e}}var s=n(11),h=n(23),l=n(1),u=n(106),c=n(104),f=l.each,d=h.ifAxisCrossZero,p=h.niceScaleExtent;n(107);var g=a.prototype;g.type="grid",g.getRect=function(){return this._rect},g.update=function(t,e){function n(t){var e=i[t];for(var n in e){var r=e[n];if(r&&("category"===r.type||!d(r)))return!0}return!1}var i=this._axesMap;this._updateScale(t,this._model),f(i.x,function(t){p(t,t.model)}),f(i.y,function(t){p(t,t.model)}),f(i.x,function(t){n("y")&&(t.onZero=!1)}),f(i.y,function(t){n("x")&&(t.onZero=!1)}),this.resize(this._model,e)},g.resize=function(t,e){function n(){f(a,function(t){var e=t.isHorizontal(),n=e?[0,i.width]:[0,i.height],r=t.inverse?1:0;t.setExtent(n[r],n[1-r]),o(t,e?i.x:i.y)})}var i=s.getLayoutRect(t.getBoxLayoutParams(),{width:e.getWidth(),height:e.getHeight()});this._rect=i;var a=this._axesList;n(),t.get("containLabel")&&(f(a,function(t){if(!t.model.get("axisLabel.inside")){var e=r(t);if(e){var n=t.isHorizontal()?"height":"width",a=t.model.get("axisLabel.margin");i[n]-=e[n]+a,"top"===t.position?i.y+=e.height+a:"left"===t.position&&(i.x+=e.width+a)}}}),n())},g.getAxis=function(t,e){var n=this._axesMap[t];if(null!=n){if(null==e)for(var i in n)return n[i];return n[e]}},g.getCartesian=function(t,e){var n="x"+t+"y"+e;return this._coordsMap[n]},g._initCartesian=function(t,e,n){function r(n){return function(r,l){if(i(r,t,e)){var u=r.get("position");"x"===n?("top"!==u&&"bottom"!==u&&(u="bottom"),a[u]&&(u="top"===u?"bottom":"top")):("left"!==u&&"right"!==u&&(u="left"),a[u]&&(u="left"===u?"right":"left")),a[u]=!0;var f=new c(n,h.createScaleByModel(r),[0,0],r.get("type"),u),d="category"===f.type;f.onBand=d&&r.get("boundaryGap"),f.inverse=r.get("inverse"),f.onZero=r.get("axisLine.onZero"),r.axis=f,f.model=r,f.index=l,this._axesList.push(f),o[n][l]=f,s[n]++}}}var a={left:!1,right:!1,top:!1,bottom:!1},o={x:{},y:{}},s={x:0,y:0};return e.eachComponent("xAxis",r("x"),this),e.eachComponent("yAxis",r("y"),this),s.x&&s.y?(this._axesMap=o,void f(o.x,function(t,e){f(o.y,function(n,i){var r="x"+e+"y"+i,a=new u(r);a.grid=this,this._coordsMap[r]=a,this._coordsList.push(a),a.addAxis(t),a.addAxis(n)},this)},this)):(this._axesMap={},void(this._axesList=[]))},g._updateScale=function(t,e){function n(t,e,n){f(n.coordDimToDataDim(e.dim),function(n){e.scale.unionExtent(t.getDataExtent(n,"ordinal"!==e.scale.type))})}l.each(this._axesList,function(t){t.scale.setExtent(1/0,-(1/0))}),t.eachSeries(function(r){if("cartesian2d"===r.get("coordinateSystem")){var a=r.get("xAxisIndex"),o=r.get("yAxisIndex"),s=t.getComponent("xAxis",a),h=t.getComponent("yAxis",o);if(!i(s,e,t)||!i(h,e,t))return;var l=this.getCartesian(a,o),u=r.getData(),c=l.getAxis("x"),f=l.getAxis("y");"list"===u.type&&(n(u,c,r),n(u,f,r))}},this)},a.create=function(t,e){var n=[];return t.eachComponent("grid",function(i,r){var o=new a(i,t,e);o.name="grid_"+r,o.resize(i,e),i.coordinateSystem=o,n.push(o)}),t.eachSeries(function(e){if("cartesian2d"===e.get("coordinateSystem")){var i=e.get("xAxisIndex"),r=t.getComponent("xAxis",i),a=n[r.get("gridIndex")];e.coordinateSystem=a.getCartesian(i,e.get("yAxisIndex"))}}),n},a.dimensions=u.prototype.dimensions,n(28).register("cartesian2d",a),t.exports=a},function(t,e){"use strict";function n(t){return t}function i(t,e,i,r){this._old=t,this._new=e,this._oldKeyGetter=i||n,this._newKeyGetter=r||n}function r(t,e,n){for(var i=0;it;t++)this._add&&this._add(l[t]);else this._add&&this._add(l)}}},t.exports=i},function(t,e){t.exports=function(t,e,n){e.eachSeriesByType(t,function(t){var e=t.getData(),n=t.coordinateSystem,i=n.dimensions;e.each(i,function(t,i,r){var a;a=isNaN(t)||isNaN(i)?[NaN,NaN]:n.dataToPoint([t,i]),e.setItemLayout(r,a)},!0)})}},function(t,e,n){var i=n(26),r=n(41),a=n(20),o=function(){this.group=new i,this.uid=r.getUID("viewComponent")};o.prototype={constructor:o,init:function(t,e){},render:function(t,e,n,i){},dispose:function(){}};var s=o.prototype;s.updateView=s.updateLayout=s.updateVisual=function(t,e,n,i){},a.enableClassExtend(o),a.enableClassManagement(o,{registerWhenExtend:!0}),t.exports=o},function(t,e,n){"use strict";var i=n(58),r=n(21),a=n(77),o=n(153),s=n(1),h=function(t){a.call(this,t),r.call(this,t),o.call(this,t),this.id=t.id||i()};h.prototype={type:"element",name:"",__zr:null,ignore:!1,clipPath:null,drift:function(t,e){switch(this.draggable){case"horizontal":e=0;break;case"vertical":t=0}var n=this.transform;n||(n=this.transform=[1,0,0,1,0,0]),n[4]+=t,n[5]+=e,this.decomposeTransform(),this.dirty()},beforeUpdate:function(){},afterUpdate:function(){},update:function(){this.updateTransform()},traverse:function(t,e){},attrKV:function(t,e){if("position"===t||"scale"===t||"origin"===t){if(e){var n=this[t];n||(n=this[t]=[]),n[0]=e[0],n[1]=e[1]}}else this[t]=e},hide:function(){this.ignore=!0,this.__zr&&this.__zr.refresh()},show:function(){this.ignore=!1,this.__zr&&this.__zr.refresh()},attr:function(t,e){if("string"==typeof t)this.attrKV(t,e);else if(s.isObject(t))for(var n in t)t.hasOwnProperty(n)&&this.attrKV(n,t[n]);return this.dirty(),this},setClipPath:function(t){var e=this.__zr;e&&t.addSelfToZr(e),this.clipPath&&this.clipPath!==t&&this.removeClipPath(),this.clipPath=t,t.__zr=e,t.__clipTarget=this,this.dirty()},removeClipPath:function(){var t=this.clipPath;t&&(t.__zr&&t.removeSelfFromZr(t.__zr),t.__zr=null,t.__clipTarget=null,this.clipPath=null,this.dirty())},addSelfToZr:function(t){this.__zr=t;var e=this.animators;if(e)for(var n=0;n.5?e:t}function s(t,e,n,i,r){var o=t.length;if(1==r)for(var s=0;o>s;s++)i[s]=a(t[s],e[s],n);else for(var h=t[0].length,s=0;o>s;s++)for(var l=0;h>l;l++)i[s][l]=a(t[s][l],e[s][l],n)}function h(t,e,n){var i=t.length,r=e.length;if(i!==r){var a=i>r;if(a)t.length=r;else for(var o=i;r>o;o++)t.push(1===n?e[o]:x.call(e[o]))}}function l(t,e,n){if(t===e)return!0;var i=t.length;if(i!==e.length)return!1;if(1===n){for(var r=0;i>r;r++)if(t[r]!==e[r])return!1}else for(var a=t[0].length,r=0;i>r;r++)for(var o=0;a>o;o++)if(t[r][o]!==e[r][o])return!1;return!0}function u(t,e,n,i,r,a,o,s,h){var l=t.length;if(1==h)for(var u=0;l>u;u++)s[u]=c(t[u],e[u],n[u],i[u],r,a,o);else for(var f=t[0].length,u=0;l>u;u++)for(var d=0;f>d;d++)s[u][d]=c(t[u][d],e[u][d],n[u][d],i[u][d],r,a,o)}function c(t,e,n,i,r,a,o){var s=.5*(n-t),h=.5*(i-e);return(2*(e-n)+s+h)*o+(-3*(e-n)-2*s-h)*a+s*r+e}function f(t){if(y(t)){var e=t.length;if(y(t[0])){for(var n=[],i=0;e>i;i++)n.push(x.call(t[i]));return n}return x.call(t)}return t}function d(t){return t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.floor(t[2]),"rgba("+t.join(",")+")"}function p(t,e,n,i,r){var f=t._getter,p=t._setter,m="spline"===e,x=i.length;if(x){var _,b=i[0].value,w=y(b),M=!1,S=!1,C=w&&y(b[0])?2:1;i.sort(function(t,e){return t.time-e.time}),_=i[x-1].time;for(var T=[],A=[],I=i[0].value,k=!0,L=0;x>L;L++){T.push(i[L].time/_);var P=i[L].value;if(w&&l(P,I,C)||!w&&P===I||(k=!1),I=P,"string"==typeof P){var D=v.parse(P);D?(P=D,M=!0):S=!0}A.push(P)}if(!k){if(w){for(var O=A[x-1],L=0;x-1>L;L++)h(A[L],O,C);h(f(t._target,r),O,C)}var z,E,B,R,N,F,V=0,G=0;if(M)var q=[0,0,0,0];var W=function(t,e){var n;if(G>e){for(z=Math.min(V+1,x-1),n=z;n>=0&&!(T[n]<=e);n--);n=Math.min(n,x-2)}else{for(n=V;x>n&&!(T[n]>e);n++);n=Math.min(n-1,x-2)}V=n,G=e;var i=T[n+1]-T[n];if(0!==i)if(E=(e-T[n])/i,m)if(R=A[n],B=A[0===n?n:n-1],N=A[n>x-2?x-1:n+1],F=A[n>x-3?x-1:n+2],w)u(B,R,N,F,E,E*E,E*E*E,f(t,r),C);else{var h;if(M)h=u(B,R,N,F,E,E*E,E*E*E,q,1),h=d(q);else{if(S)return o(R,N,E);h=c(B,R,N,F,E,E*E,E*E*E)}p(t,r,h)}else if(w)s(A[n],A[n+1],E,f(t,r),C);else{var h;if(M)s(A[n],A[n+1],E,q,1),h=d(q);else{if(S)return o(A[n],A[n+1],E);h=a(A[n],A[n+1],E)}p(t,r,h)}},H=new g({target:t._target,life:_,loop:t._loop,delay:t._delay,onframe:W,ondestroy:n});return e&&"spline"!==e&&(H.easing=e),H}}}var g=n(131),v=n(22),m=n(1),y=m.isArrayLike,x=Array.prototype.slice,_=function(t,e,n,a){this._tracks={},this._target=t,this._loop=e||!1,this._getter=n||i,this._setter=a||r,this._clipCount=0,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]};_.prototype={when:function(t,e){var n=this._tracks;for(var i in e){if(!n[i]){n[i]=[];var r=this._getter(this._target,i);if(null==r)continue;0!==t&&n[i].push({time:0,value:f(r)})}n[i].push({time:t,value:e[i]})}return this},during:function(t){return this._onframeList.push(t),this},_doneCallback:function(){this._tracks={},this._clipList.length=0;for(var t=this._doneList,e=t.length,n=0;e>n;n++)t[n].call(this)},start:function(t){var e,n=this,i=0,r=function(){i--,i||n._doneCallback()};for(var a in this._tracks){var o=p(this,t,r,this._tracks[a],a);o&&(this._clipList.push(o),i++,this.animation&&this.animation.addClip(o),e=o)}if(e){var s=e.onframe;e.onframe=function(t,e){s(t,e);for(var i=0;it&&(t+=n),t}}},function(t,e){var n=2311;t.exports=function(){return"zr_"+n++}},function(t,e,n){var i=n(143),r=n(142);t.exports={buildPath:function(t,e,n){var a=e.points,o=e.smooth;if(a&&a.length>=2){if(o&&"spline"!==o){var s=r(a,o,n,e.smoothConstraint);t.moveTo(a[0][0],a[0][1]);for(var h=a.length,l=0;(n?h:h-1)>l;l++){var u=s[2*l],c=s[2*l+1],f=a[(l+1)%h];t.bezierCurveTo(u[0],u[1],c[0],c[1],f[0],f[1])}}else{"spline"===o&&(a=i(a,n)),t.moveTo(a[0][0],a[0][1]);for(var l=1,d=a.length;d>l;l++)t.lineTo(a[l][0],a[l][1])}n&&t.closePath()}}}},function(t,e){t.exports={buildPath:function(t,e){var n,i,r,a,o=e.x,s=e.y,h=e.width,l=e.height,u=e.r;0>h&&(o+=h,h=-h),0>l&&(s+=l,l=-l),"number"==typeof u?n=i=r=a=u:u instanceof Array?1===u.length?n=i=r=a=u[0]:2===u.length?(n=r=u[0],i=a=u[1]):3===u.length?(n=u[0],i=a=u[1],r=u[2]):(n=u[0],i=u[1],r=u[2],a=u[3]):n=i=r=a=0;var c;n+i>h&&(c=n+i,n*=h/c,i*=h/c),r+a>h&&(c=r+a,r*=h/c,a*=h/c),i+r>l&&(c=i+r,i*=l/c,r*=l/c),n+a>l&&(c=n+a,n*=l/c,a*=l/c),t.moveTo(o+n,s),t.lineTo(o+h-i,s),0!==i&&t.quadraticCurveTo(o+h,s,o+h,s+i),t.lineTo(o+h,s+l-r),0!==r&&t.quadraticCurveTo(o+h,s+l,o+h-r,s+l),t.lineTo(o+a,s+l),0!==a&&t.quadraticCurveTo(o,s+l,o,s+l-a),t.lineTo(o,s+n),0!==n&&t.quadraticCurveTo(o,s,o+n,s)}}},function(t,e,n){var i=n(72),r=n(1),a=n(10),o=n(11),s=["value","category","time","log"];t.exports=function(t,e,n,h){r.each(s,function(a){e.extend({type:t+"Axis."+a,mergeDefaultAndTheme:function(e,i){var s=this.layoutMode,h=s?o.getLayoutParams(e):{},l=i.getTheme();r.merge(e,l.get(a+"Axis")),r.merge(e,this.getDefaultOption()),e.type=n(t,e),s&&o.mergeLayoutParam(e,h,s)},defaultOption:r.mergeAll([{},i[a+"Axis"],h],!0)})}),a.registerSubTypeDefaulter(t+"Axis",r.curry(n,t))}},function(t,e){t.exports=function(t,e){var n=e.findComponents({mainType:"legend"});n&&n.length&&e.eachSeriesByType(t,function(t){var e=t.getData();e.filterSelf(function(t){for(var i=e.getName(t),r=0;rm;m++)y[m]=b(t,n,a,l,y[m]);for(w=_(e,i,h,u,x),m=0;w>m;m++)x[m]=b(e,i,h,u,x[m]);y.push(t,l),x.push(e,u),d=o.apply(null,y),p=s.apply(null,y),g=o.apply(null,x),v=s.apply(null,x),c[0]=d,c[1]=g,f[0]=p,f[1]=v},a.fromQuadratic=function(t,e,n,i,a,h,l,u){var c=r.quadraticExtremum,f=r.quadraticAt,d=s(o(c(t,n,a),1),0),p=s(o(c(e,i,h),1),0),g=f(t,n,a,d),v=f(e,i,h,p);l[0]=o(t,a,g),l[1]=o(e,h,v),u[0]=s(t,a,g),u[1]=s(e,h,v)},a.fromArc=function(t,e,n,r,a,o,s,p,g){var v=i.min,m=i.max,y=Math.abs(a-o);if(1e-4>y%d&&y>1e-4)return p[0]=t-n,p[1]=e-r,g[0]=t+n,void(g[1]=e+r);if(u[0]=l(a)*n+t,u[1]=h(a)*r+e,c[0]=l(o)*n+t,c[1]=h(o)*r+e,v(p,u,c),m(g,u,c),a%=d,0>a&&(a+=d),o%=d,0>o&&(o+=d),a>o&&!s?o+=d:o>a&&s&&(a+=d),s){var x=o;o=a,a=x}for(var _=0;o>_;_+=Math.PI/2)_>a&&(f[0]=l(_)*n+t,f[1]=h(_)*r+e,v(p,f,p),m(g,f,g))},t.exports=a},function(t,e,n){var i=n(35),r=n(1),a=n(17),o=function(t){i.call(this,t)};o.prototype={constructor:o,type:"text",brush:function(t){var e=this.style,n=e.x||0,i=e.y||0,r=e.text,o=e.fill,s=e.stroke;if(null!=r&&(r+=""),r){if(t.save(),this.style.bind(t),this.setTransform(t),o&&(t.fillStyle=o),s&&(t.strokeStyle=s),t.font=e.textFont||e.font,t.textAlign=e.textAlign,e.textVerticalAlign){var h=a.getBoundingRect(r,t.font,e.textAlign,"top");switch(t.textBaseline="top",e.textVerticalAlign){case"middle":i-=h.height/2;break;case"bottom":i-=h.height}}else t.textBaseline=e.textBaseline;for(var l=a.measureText("国",t.font).width,u=r.split("\n"),c=0;c=0?parseFloat(t)/100*e:parseFloat(t):t}function r(t,e){t.transform(e[0],e[1],e[2],e[3],e[4],e[5])}var a=n(17),o=n(8),s=new o,h=function(){};h.prototype={constructor:h,drawRectText:function(t,e,n){var o=this.style,h=o.text;if(null!=h&&(h+=""),h){var l,u,c=o.textPosition,f=o.textDistance,d=o.textAlign,p=o.textFont||o.font,g=o.textBaseline,v=o.textVerticalAlign;n=n||a.getBoundingRect(h,p,d,g);var m=this.transform,y=this.invTransform;if(m&&(s.copy(e),s.applyTransform(m),e=s,r(t,y)),c instanceof Array)l=e.x+i(c[0],e.width),u=e.y+i(c[1],e.height),d=d||"left",g=g||"top";else{var x=a.adjustTextPositionOnRect(c,e,n,f);l=x.x,u=x.y,d=d||x.textAlign,g=g||x.textBaseline}if(t.textAlign=d,v){switch(v){case"middle":u-=n.height/2;break;case"bottom":u-=n.height}t.textBaseline="top"}else t.textBaseline=g;var _=o.textFill,b=o.textStroke;_&&(t.fillStyle=_),b&&(t.strokeStyle=b),t.font=p,t.shadowColor=o.textShadowColor,t.shadowBlur=o.textShadowBlur,t.shadowOffsetX=o.textShadowOffsetX,t.shadowOffsetY=o.textShadowOffsetY;for(var w=h.split("\n"),M=0;Me&&a>i||e>a&&i>a)return 0;if(i===e)return 0;var o=e>i?1:-1,s=(a-e)/(i-e),h=s*(n-t)+t;return h>r?o:0}},function(t,e,n){"use strict";var i=n(1),r=n(16),a=function(t,e,n,i,a){this.x=null==t?0:t,this.y=null==e?0:e,this.x2=null==n?1:n,this.y2=null==i?0:i,r.call(this,a)};a.prototype={constructor:a,type:"linear",updateCanvasGradient:function(t,e){for(var n=t.getBoundingRect(),i=this.x*n.width+n.x,r=this.x2*n.width+n.x,a=this.y*n.height+n.y,o=this.y2*n.height+n.y,s=e.createLinearGradient(i,a,r,o),h=this.colorStops,l=0;ls||-s>t}var r=n(19),a=n(5),o=r.identity,s=5e-5,h=function(t){t=t||{},t.position||(this.position=[0,0]),null==t.rotation&&(this.rotation=0),t.scale||(this.scale=[1,1]),this.origin=this.origin||null},l=h.prototype;l.transform=null,l.needLocalTransform=function(){return i(this.rotation)||i(this.position[0])||i(this.position[1])||i(this.scale[0]-1)||i(this.scale[1]-1)},l.updateTransform=function(){var t=this.parent,e=t&&t.transform,n=this.needLocalTransform(),i=this.transform;return n||e?(i=i||r.create(),n?this.getLocalTransform(i):o(i),e&&(n?r.mul(i,t.transform,i):r.copy(i,t.transform)),this.transform=i,this.invTransform=this.invTransform||r.create(),void r.invert(this.invTransform,i)):void(i&&o(i))},l.getLocalTransform=function(t){t=t||[],o(t);var e=this.origin,n=this.scale,i=this.rotation,a=this.position;return e&&(t[4]-=e[0],t[5]-=e[1]),r.scale(t,t,n),i&&r.rotate(t,t,i),e&&(t[4]+=e[0],t[5]+=e[1]),t[4]+=a[0],t[5]+=a[1],t},l.setTransform=function(t){var e=this.transform;e&&t.transform(e[0],e[1],e[2],e[3],e[4],e[5])};var u=[];l.decomposeTransform=function(){if(this.transform){var t=this.parent,e=this.transform;t&&t.transform&&(r.mul(u,t.invTransform,e),e=u);var n=e[0]*e[0]+e[1]*e[1],a=e[2]*e[2]+e[3]*e[3],o=this.position,s=this.scale;i(n-1)&&(n=Math.sqrt(n)),i(a-1)&&(a=Math.sqrt(a)),e[0]<0&&(n=-n),e[3]<0&&(a=-a),o[0]=e[4],o[1]=e[5],s[0]=n,s[1]=a,this.rotation=Math.atan2(-e[1]/a,e[0]/n)}},l.transformCoordToLocal=function(t,e){var n=[t,e],i=this.invTransform;return i&&a.applyTransform(n,n,i),n},l.transformCoordToGlobal=function(t,e){var n=[t,e],i=this.transform;return i&&a.applyTransform(n,n,i),n},t.exports=h},function(t,e,n){"use strict";function i(t){r.each(a,function(e){this[e]=r.bind(t[e],t)},this)}var r=n(1),a=["getDom","getZr","getWidth","getHeight","dispatchAction","on","off","getDataURL","getConnectedDataURL","getModel","getOption"];t.exports=i},function(t,e,n){var i=n(1);n(51),n(80),n(81);var r=n(109),a=n(2);a.registerLayout(i.curry(r,"bar")),a.registerVisualCoding("chart",function(t){t.eachSeriesByType("bar",function(t){var e=t.getData();e.setVisual("legendSymbol","roundRect")})}),n(34)},function(t,e,n){"use strict";var i=n(13),r=n(36);t.exports=i.extend({type:"series.bar",dependencies:["grid","polar"],getInitialData:function(t,e){return r(t.data,this,e)},getMarkerPosition:function(t){var e=this.coordinateSystem;if(e){var n=e.dataToPoint(t),i=this.getData(),r=i.getLayout("offset"),a=i.getLayout("size"),o=e.getBaseAxis().isHorizontal()?0:1;return n[o]+=r+a/2,n}return[NaN,NaN]},defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,xAxisIndex:0,yAxisIndex:0,barMinHeight:0,itemStyle:{normal:{barBorderColor:"#fff",barBorderWidth:0},emphasis:{barBorderColor:"#fff",barBorderWidth:0}}}})},function(t,e,n){"use strict";function i(t,e){var n=t.width>0?1:-1,i=t.height>0?1:-1;e=Math.min(e,Math.abs(t.width),Math.abs(t.height)),t.x+=n*e/2,t.y+=i*e/2,t.width-=n*e,t.height-=i*e}var r=n(1),a=n(3);r.extend(n(12).prototype,n(82)),t.exports=n(2).extendChartView({type:"bar",render:function(t,e,n){var i=t.get("coordinateSystem");return"cartesian2d"===i&&this._renderOnCartesian(t,e,n),this.group},_renderOnCartesian:function(t,e,n){function o(e,n){var o=h.getItemLayout(e),s=h.getItemModel(e).get(p)||0;i(o,s);var l=new a.Rect({shape:r.extend({},o)});if(d){var u=l.shape,c=f?"height":"width",g={};u[c]=0,g[c]=o[c],a[n?"updateProps":"initProps"](l,{shape:g},t)}return l}var s=this.group,h=t.getData(),l=this._data,u=t.coordinateSystem,c=u.getBaseAxis(),f=c.isHorizontal(),d=t.get("animation"),p=["itemStyle","normal","barBorderWidth"];h.diff(l).add(function(t){if(h.hasValue(t)){var e=o(t);h.setItemGraphicEl(t,e),s.add(e)}}).update(function(e,n){var r=l.getItemGraphicEl(n);if(!h.hasValue(e))return void s.remove(r);r||(r=o(e,!0));var u=h.getItemLayout(e),c=h.getItemModel(e).get(p)||0;i(u,c),a.updateProps(r,{shape:u},t),h.setItemGraphicEl(e,r),s.add(r)}).remove(function(e){var n=l.getItemGraphicEl(e);n&&(n.style.text="",a.updateProps(n,{shape:{width:0}},t,function(){s.remove(n)}))}).execute(),this._updateStyle(t,h,f),this._data=h},_updateStyle:function(t,e,n){function i(t,e,n,i,r){a.setText(t,e,n),t.text=i,"outside"===t.textPosition&&(t.textPosition=r)}e.eachItemGraphicEl(function(o,s){var h=e.getItemModel(s),l=e.getItemVisual(s,"color"),u=e.getItemLayout(s),c=h.getModel("itemStyle.normal"),f=h.getModel("itemStyle.emphasis").getItemStyle();o.setShape("r",c.get("barBorderRadius")||0),o.setStyle(r.defaults({fill:l},c.getBarItemStyle()));var d=n?u.height>0?"bottom":"top":u.width>0?"left":"right",p=h.getModel("label.normal"),g=h.getModel("label.emphasis"),v=o.style;p.get("show")?i(v,p,l,r.retrieve(t.getFormattedLabel(s,"normal"),t.getRawValue(s)),d):v.text="",g.get("show")?i(f,g,l,r.retrieve(t.getFormattedLabel(s,"emphasis"),t.getRawValue(s)),d):f.text="",a.setHoverStyle(o,f)})},remove:function(t,e){var n=this.group;t.get("animation")?this._data&&this._data.eachItemGraphicEl(function(e){e.style.text="",a.updateProps(e,{shape:{width:0}},t,function(){n.remove(e)})}):n.removeAll()}})},function(t,e,n){t.exports={getBarItemStyle:n(30)([["fill","color"],["stroke","barBorderColor"],["lineWidth","barBorderWidth"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]])}},,,function(t,e,n){var i=n(1),r=n(2);n(86),n(87),r.registerVisualCoding("chart",i.curry(n(44),"line","circle","line")),r.registerLayout(i.curry(n(53),"line")),r.registerProcessor("statistic",i.curry(n(121),"line")),n(34)},function(t,e,n){"use strict";var i=n(36),r=n(13);t.exports=r.extend({type:"series.line",dependencies:["grid","polar"],getInitialData:function(t,e){return i(t.data,this,e)},defaultOption:{zlevel:0,z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,hoverAnimation:!0,xAxisIndex:0,yAxisIndex:0,polarIndex:0,clipOverflow:!0,label:{normal:{position:"top"}},lineStyle:{normal:{width:2,type:"solid"}},symbol:"emptyCircle",symbolSize:4,showSymbol:!0,animationEasing:"linear"}})},function(t,e,n){"use strict";function i(t,e){if(t.length===e.length){for(var n=0;ne[0]?1:-1;e[0]+=i*n,e[1]-=i*n}return e}function o(t){return t>=0?1:-1}function s(t,e){var n=t.getBaseAxis(),i=t.getOtherAxis(n),r=n.onZero?0:i.scale.getExtent()[0],a=i.dim,s="x"===a||"radius"===a?1:0;return e.mapArray([a],function(i,h){for(var l,u=e.stackedOn;u&&o(u.get(a,h))===o(i);){l=u;break}var c=[];return c[s]=e.get(n.dim,h),c[1-s]=l?l.get(a,h,!0):r,t.dataToPoint(c)},!0)}function h(t,e){return null!=e.dataIndex?e.dataIndex:null!=e.name?t.indexOfName(e.name):void 0}function l(t,e,n){var i=a(t.getAxis("x")),r=a(t.getAxis("y")),o=t.getBaseAxis().isHorizontal(),s=i[0],h=r[0],l=i[1]-s,u=r[1]-h;n.get("clipOverflow")||(o?(h-=u,u*=3):(s-=l,l*=3));var c=new v.Rect({shape:{x:s,y:h,width:l,height:u}});return e&&(c.shape[o?"width":"height"]=0,v.initProps(c,{shape:{width:l,height:u}},n)),c}function u(t,e,n){var i=t.getAngleAxis(),r=t.getRadiusAxis(),a=r.getExtent(),o=i.getExtent(),s=Math.PI/180,h=new v.Sector({shape:{cx:t.cx,cy:t.cy,r0:a[0],r:a[1],startAngle:-o[0]*s,endAngle:-o[1]*s,clockwise:i.inverse}});return e&&(h.shape.endAngle=-o[0]*s,v.initProps(h,{shape:{endAngle:-o[1]*s}},n)),h}function c(t,e,n){return"polar"===t.type?u(t,e,n):l(t,e,n)}var f=n(1),d=n(38),p=n(47),g=n(88),v=n(3),m=n(89),y=n(25);t.exports=y.extend({type:"line",init:function(){var t=new v.Group,e=new d;this.group.add(e.group),this._symbolDraw=e,this._lineGroup=t},render:function(t,e,n){var a=t.coordinateSystem,o=this.group,h=t.getData(),l=t.getModel("lineStyle.normal"),u=t.getModel("areaStyle.normal"),d=h.mapArray(h.getItemLayout,!0),p="polar"===a.type,g=this._coordSys,v=this._symbolDraw,m=this._polyline,y=this._polygon,x=this._lineGroup,_=t.get("animation"),b=!u.isEmpty(),w=s(a,h),M=t.get("showSymbol"),S=M&&!p&&!t.get("showAllSymbol")&&this._getSymbolIgnoreFunc(h,a),C=this._data;C&&C.eachItemGraphicEl(function(t,e){t.__temp&&(o.remove(t),C.setItemGraphicEl(e,null))}),M||v.remove(),o.add(x),m&&g.type===a.type?(b&&!y?y=this._newPolygon(d,w,a,_):y&&!b&&(x.remove(y),y=this._polygon=null),x.setClipPath(c(a,!1,t)),M&&v.updateData(h,S),h.eachItemGraphicEl(function(t){t.stopAnimation(!0)}),i(this._stackedOnPoints,w)&&i(this._points,d)||(_?this._updateAnimation(h,w,a,n):(m.setShape({points:d}),y&&y.setShape({points:d,stackedOnPoints:w})))):(M&&v.updateData(h,S),m=this._newPolyline(d,a,_),b&&(y=this._newPolygon(d,w,a,_)),x.setClipPath(c(a,!0,t))),m.setStyle(f.defaults(l.getLineStyle(),{stroke:h.getVisual("color"),lineJoin:"bevel"}));var T=t.get("smooth");if(T=r(t.get("smooth")),m.setShape({smooth:T,smoothMonotone:t.get("smoothMonotone")}),y){var A=h.stackedOn,I=0;if(y.style.opacity=.7,y.setStyle(f.defaults(u.getAreaStyle(),{fill:h.getVisual("color"),lineJoin:"bevel"})),A){var k=A.hostModel;I=r(k.get("smooth"))}y.setShape({smooth:T,stackedOnSmooth:I,smoothMonotone:t.get("smoothMonotone")})}this._data=h,this._coordSys=a,this._stackedOnPoints=w,this._points=d},highlight:function(t,e,n,i){var r=t.getData(),a=h(r,i);if(null!=a&&a>=0){var o=r.getItemGraphicEl(a);if(!o){var s=r.getItemLayout(a);o=new p(r,a,n),o.position=s,o.setZ(t.get("zlevel"),t.get("z")),o.ignore=isNaN(s[0])||isNaN(s[1]),o.__temp=!0,r.setItemGraphicEl(a,o),o.stopSymbolAnimation(!0),this.group.add(o)}o.highlight()}else y.prototype.highlight.call(this,t,e,n,i)},downplay:function(t,e,n,i){var r=t.getData(),a=h(r,i);if(null!=a&&a>=0){var o=r.getItemGraphicEl(a);o&&(o.__temp?(r.setItemGraphicEl(a,null),this.group.remove(o)):o.downplay())}else y.prototype.downplay.call(this,t,e,n,i)},_newPolyline:function(t){var e=this._polyline;return e&&this._lineGroup.remove(e),e=new m.Polyline({shape:{points:t},silent:!0,z2:10}),this._lineGroup.add(e),this._polyline=e,e},_newPolygon:function(t,e){var n=this._polygon;return n&&this._lineGroup.remove(n),n=new m.Polygon({shape:{points:t,stackedOnPoints:e},silent:!0}),this._lineGroup.add(n),this._polygon=n,n},_getSymbolIgnoreFunc:function(t,e){var n=e.getAxesByScale("ordinal")[0];return n&&n.isLabelIgnored?f.bind(n.isLabelIgnored,n):void 0},_updateAnimation:function(t,e,n,i){var r=this._polyline,a=this._polygon,o=t.hostModel,s=g(this._data,t,this._stackedOnPoints,e,this._coordSys,n);r.shape.points=s.current,v.updateProps(r,{shape:{points:s.next}},o),a&&(a.setShape({points:s.current,stackedOnPoints:s.stackedOnCurrent}),v.updateProps(a,{shape:{points:s.next,stackedOnPoints:s.stackedOnNext}},o));for(var h=[],l=s.status,u=0;u=0?1:-1}function i(t,e,i){for(var r,a=t.getBaseAxis(),o=t.getOtherAxis(a),s=a.onZero?0:o.scale.getExtent()[0],h=o.dim,l="x"===h||"radius"===h?1:0,u=e.stackedOn,c=e.get(h,i);u&&n(u.get(h,i))===n(c);){r=u;break}var f=[];return f[l]=e.get(a.dim,i),f[1-l]=r?r.get(h,i,!0):s,t.dataToPoint(f)}function r(t,e){var n=[];return e.diff(t).add(function(t){n.push({cmd:"+",idx:t})}).update(function(t,e){n.push({cmd:"=",idx:e,idx1:t})}).remove(function(t){n.push({cmd:"-",idx:t})}).execute(),n}t.exports=function(t,e,n,a,o,s){for(var h=r(t,e),l=[],u=[],c=[],f=[],d=[],p=[],g=[],v=s.dimensions,m=0;mx;x++){var _=e[y];if(y>=i||0>y||isNaN(_[0])||isNaN(_[1]))break;if(y===n)t[a>0?"moveTo":"lineTo"](_[0],_[1]),u(f,_);else if(v>0){var b=y-a,w=y+a,M=.5,S=e[b],C=e[w];if(a>0&&(y===r-1||isNaN(C[0])||isNaN(C[1]))||0>=a&&(0===y||isNaN(C[0])||isNaN(C[1])))u(d,_);else{(isNaN(C[0])||isNaN(C[1]))&&(C=_),o.sub(c,C,S);var T,A;if("x"===m||"y"===m){var I="x"===m?0:1;T=Math.abs(_[I]-S[I]),A=Math.abs(_[I]-C[I])}else T=o.dist(_,S),A=o.dist(_,C);M=A/(A+T),l(d,_,c,-v*(1-M))}s(f,f,g),h(f,f,p),s(d,d,g),h(d,d,p),t.bezierCurveTo(f[0],f[1],d[0],d[1],_[0],_[1]),l(f,_,c,v*M)}else t.lineTo(_[0],_[1]);y+=a}return x}function r(t,e){var n=[1/0,1/0],i=[-(1/0),-(1/0)];if(e)for(var r=0;ri[0]&&(i[0]=a[0]),a[1]>i[1]&&(i[1]=a[1])}return{min:e?n:i,max:e?i:n}}var a=n(6),o=n(5),s=o.min,h=o.max,l=o.scaleAndAdd,u=o.copy,c=[],f=[],d=[];t.exports={Polyline:a.extend({type:"ec-polyline",shape:{points:[],smooth:0,smoothConstraint:!0,smoothMonotone:null},style:{fill:null,stroke:"#000"},buildPath:function(t,e){for(var n=e.points,a=0,o=n.length,s=r(n,e.smoothConstraint);o>a;)a+=i(t,n,a,o,o,1,s.min,s.max,e.smooth,e.smoothMonotone)+1}}),Polygon:a.extend({type:"ec-polygon",shape:{points:[],stackedOnPoints:[],smooth:0,stackedOnSmooth:0,smoothConstraint:!0,smoothMonotone:null},buildPath:function(t,e){for(var n=e.points,a=e.stackedOnPoints,o=0,s=n.length,h=e.smoothMonotone,l=r(n,e.smoothConstraint),u=r(a,e.smoothConstraint);s>o;){var c=i(t,n,o,s,s,1,l.min,l.max,e.smooth,h);i(t,a,o+c-1,s,c,-1,u.min,u.max,e.stackedOnSmooth,h),o+=c+1,t.closePath()}}})}},function(t,e,n){var i=n(1),r=n(2);n(91),n(92),n(68)("pie",[{type:"pieToggleSelect",event:"pieselectchanged",method:"toggleSelected"},{type:"pieSelect",event:"pieselected",method:"select"},{type:"pieUnSelect",event:"pieunselected",method:"unSelect"}]),r.registerVisualCoding("chart",i.curry(n(63),"pie")),r.registerLayout(i.curry(n(94),"pie")),r.registerProcessor("filter",i.curry(n(62),"pie"))},function(t,e,n){"use strict";var i=n(14),r=n(1),a=n(7),o=n(31),s=n(69),h=n(2).extendSeriesModel({type:"series.pie",init:function(t){h.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._dataBeforeProcessed},this.updateSelectedMap(),this._defaultLabelLine(t)},mergeOption:function(t){h.superCall(this,"mergeOption",t),this.updateSelectedMap()},getInitialData:function(t,e){var n=o(["value"],t.data),r=new i(n,this);return r.initData(t.data),r},getDataParams:function(t){var e=this._data,n=h.superCall(this,"getDataParams",t),i=e.getSum("value");return n.percent=i?+(e.get("value",t)/i*100).toFixed(2):0,n.$vars.push("percent"),n},_defaultLabelLine:function(t){a.defaultEmphasis(t.labelLine,["show"]);var e=t.labelLine.normal,n=t.labelLine.emphasis;e.show=e.show&&t.label.normal.show,n.show=n.show&&t.label.emphasis.show},defaultOption:{zlevel:0,z:2,legendHoverLink:!0,hoverAnimation:!0,center:["50%","50%"],radius:[0,"75%"],clockwise:!0,startAngle:90,minAngle:0,selectedOffset:10,avoidLabelOverlap:!0,label:{normal:{rotate:!1,show:!0,position:"outer"},emphasis:{}},labelLine:{normal:{show:!0,length:20,length2:5,smooth:!1,lineStyle:{width:1,type:"solid"}}},itemStyle:{normal:{borderColor:"rgba(0,0,0,0)",borderWidth:1},emphasis:{borderColor:"rgba(0,0,0,0)",borderWidth:1}},animationEasing:"cubicOut",data:[]}});r.mixin(h,s),t.exports=h},function(t,e,n){function i(t,e,n,i){var a=e.getData(),o=this.dataIndex,s=a.getName(o),h=e.get("selectedOffset");i.dispatchAction({type:"pieToggleSelect",from:t,name:s,seriesId:e.id}),a.each(function(t){r(a.getItemGraphicEl(t),a.getItemLayout(t),e.isSelected(a.getName(t)),h,n)})}function r(t,e,n,i,r){var a=(e.startAngle+e.endAngle)/2,o=Math.cos(a),s=Math.sin(a),h=n?i:0,l=[o*h,s*h];r?t.animate().when(200,{position:l}).start("bounceOut"):t.attr("position",l)}function a(t,e){function n(){a.ignore=a.hoverIgnore,o.ignore=o.hoverIgnore}function i(){a.ignore=a.normalIgnore,o.ignore=o.normalIgnore}s.Group.call(this);var r=new s.Sector({z2:2}),a=new s.Polyline,o=new s.Text;this.add(r),this.add(a),this.add(o),this.updateData(t,e,!0),this.on("emphasis",n).on("normal",i).on("mouseover",n).on("mouseout",i)}function o(t,e,n,i,r){var a=i.getModel("textStyle"),o="inside"===r||"inner"===r;return{fill:a.getTextColor()||(o?"#fff":t.getItemVisual(e,"color")),textFont:a.getFont(),text:h.retrieve(t.hostModel.getFormattedLabel(e,n),t.getName(e))}}var s=n(3),h=n(1),l=a.prototype;l.updateData=function(t,e,n){function i(){o.stopAnimation(!0),o.animateTo({shape:{r:c.r+10}},300,"elasticOut")}function a(){o.stopAnimation(!0),o.animateTo({shape:{r:c.r}},300,"elasticOut")}var o=this.childAt(0),l=t.hostModel,u=t.getItemModel(e),c=t.getItemLayout(e),f=h.extend({},c);f.label=null,n?(o.setShape(f),o.shape.endAngle=c.startAngle,s.updateProps(o,{shape:{endAngle:c.endAngle}},l)):s.updateProps(o,{shape:f},l);var d=u.getModel("itemStyle"),p=t.getItemVisual(e,"color");o.setStyle(h.defaults({fill:p},d.getModel("normal").getItemStyle())),o.hoverStyle=d.getModel("emphasis").getItemStyle(),r(this,t.getItemLayout(e),u.get("selected"),l.get("selectedOffset"),l.get("animation")),o.off("mouseover").off("mouseout").off("emphasis").off("normal"),u.get("hoverAnimation")&&o.on("mouseover",i).on("mouseout",a).on("emphasis",i).on("normal",a),this._updateLabel(t,e),s.setHoverStyle(this)},l._updateLabel=function(t,e){var n=this.childAt(1),i=this.childAt(2),r=t.hostModel,a=t.getItemModel(e),h=t.getItemLayout(e),l=h.label,u=t.getItemVisual(e,"color");s.updateProps(n,{shape:{points:l.linePoints||[[l.x,l.y],[l.x,l.y],[l.x,l.y]]}},r),s.updateProps(i,{style:{x:l.x,y:l.y}},r),i.attr({style:{textVerticalAlign:l.verticalAlign,textAlign:l.textAlign,textFont:l.font},rotation:l.rotation,origin:[l.x,l.y],z2:10});var c=a.getModel("label.normal"),f=a.getModel("label.emphasis"),d=a.getModel("labelLine.normal"),p=a.getModel("labelLine.emphasis"),g=c.get("position")||f.get("position");i.setStyle(o(t,e,"normal",c,g)),i.ignore=i.normalIgnore=!c.get("show"),i.hoverIgnore=!f.get("show"),n.ignore=n.normalIgnore=!d.get("show"),n.hoverIgnore=!p.get("show"),n.setStyle({stroke:u}),n.setStyle(d.getModel("lineStyle").getLineStyle()),i.hoverStyle=o(t,e,"emphasis",f,g),n.hoverStyle=p.getModel("lineStyle").getLineStyle();var v=d.get("smooth");v&&v===!0&&(v=.4),n.setShape({smooth:v})},h.inherits(a,s.Group);var u=n(25).extend({type:"pie",init:function(){var t=new s.Group;this._sectorGroup=t},render:function(t,e,n,r){if(!r||r.from!==this.uid){var o=t.getData(),s=this._data,l=this.group,u=e.get("animation"),c=!s,f=h.curry(i,this.uid,t,u,n),d=t.get("selectedMode");if(o.diff(s).add(function(t){var e=new a(o,t);c&&e.eachChild(function(t){t.stopAnimation(!0)}),d&&e.on("click",f),o.setItemGraphicEl(t,e),l.add(e)}).update(function(t,e){var n=s.getItemGraphicEl(e);n.updateData(o,t),n.off("click"),d&&n.on("click",f),l.add(n),o.setItemGraphicEl(t,n)}).remove(function(t){var e=s.getItemGraphicEl(t);l.remove(e)}).execute(),u&&c&&o.count()>0){var p=o.getItemLayout(0),g=Math.max(n.getWidth(),n.getHeight())/2,v=h.bind(l.removeClipPath,l);l.setClipPath(this._createClipPath(p.cx,p.cy,g,p.startAngle,p.clockwise,v,t))}this._data=o}},_createClipPath:function(t,e,n,i,r,a,o){var h=new s.Sector({shape:{cx:t,cy:e,r0:0,r:n,startAngle:i,endAngle:i,clockwise:r}});return s.initProps(h,{shape:{endAngle:i+(r?1:-1)*Math.PI*2}},o,a),h}});t.exports=u},function(t,e,n){"use strict";function i(t,e,n,i,r,a,o){function s(e,n,i,r){for(var a=e;n>a;a++)if(t[a].y+=i,a>e&&n>a+1&&t[a+1].y>t[a].y+t[a].height)return void h(a,i/2);h(n-1,i/2)}function h(e,n){for(var i=e;i>=0&&(t[i].y-=n,!(i>0&&t[i].y>t[i-1].y+t[i-1].height));i--);}t.sort(function(t,e){return t.y-e.y});for(var l,u=0,c=t.length,f=[],d=[],p=0;c>p;p++)l=t[p].y-u,0>l&&s(p,c,-l,r),u=t[p].y+t[p].height;0>o-u&&h(c-1,u-o);for(var p=0;c>p;p++)t[p].y>=n?d.push(t[p]):f.push(t[p])}function r(t,e,n,r,a,o){for(var s=[],h=[],l=0;lb?-1:1)*x,k=A;i=I+(0>b?-5:5),r=k,c=[[S,C],[T,A],[I,k]]}f=M?"center":b>0?"left":"right"}var L=g.getModel("textStyle").getFont(),P=g.get("rotate")?0>b?-_+Math.PI:-_:0,D=t.getFormattedLabel(n,"normal")||h.getName(n),O=a.getBoundingRect(D,L,f,"top");u=!!P,d.label={x:i,y:r,height:O.height,length:y,length2:x,linePoints:c,textAlign:f,verticalAlign:"middle",font:L,rotation:P},l.push(d.label)}),!u&&t.get("avoidLabelOverlap")&&r(l,o,s,e,n,i)}},function(t,e,n){var i=n(4),r=i.parsePercent,a=n(93),o=n(1),s=2*Math.PI,h=Math.PI/180;t.exports=function(t,e,n){e.eachSeriesByType(t,function(t){var e=t.get("center"),l=t.get("radius");o.isArray(l)||(l=[0,l]),o.isArray(e)||(e=[e,e]);var u=n.getWidth(),c=n.getHeight(),f=Math.min(u,c),d=r(e[0],u),p=r(e[1],c),g=r(l[0],f/2),v=r(l[1],f/2),m=t.getData(),y=-t.get("startAngle")*h,x=t.get("minAngle")*h,_=m.getSum("value"),b=Math.PI/(_||m.count())*2,w=t.get("clockwise"),M=t.get("roseType"),S=m.getDataExtent("value");S[0]=0;var C=s,T=0,A=y,I=w?1:-1;if(m.each("value",function(t,e){var n;n="area"!==M?0===_?b:t*b:s/(m.count()||1),x>n?(n=x,C-=x):T+=t;var r=A+I*n;m.setItemLayout(e,{angle:n,startAngle:A,endAngle:r,clockwise:w,cx:d,cy:p,r0:g,r:M?i.linearMap(t,S,[g,v]):v}),A=r},!0),s>C)if(.001>=C){var k=s/m.count();m.each(function(t){var e=m.getItemLayout(t);e.startAngle=y+I*t*k,e.endAngle=y+I*(t+1)*k})}else b=C/T,A=y,m.each("value",function(t,e){var n=m.getItemLayout(e),i=n.angle===x?x:t*b;n.startAngle=A,n.endAngle=A+I*i,A+=i});a(t,v,u,c)})}},function(t,e,n){"use strict";n(50),n(96)},function(t,e,n){function i(t,e){function n(t,e){var n=i.getAxis(t);return n.toGlobalCoord(n.dataToCoord(0))}var i=t.coordinateSystem,r=e.axis,a={},o=r.position,s=r.onZero?"onZero":o,h=r.dim,l=i.getRect(),u=[l.x,l.x+l.width,l.y,l.y+l.height],c={x:{top:u[2],bottom:u[3]},y:{left:u[0],right:u[1]}};c.x.onZero=Math.max(Math.min(n("y"),c.x.bottom),c.x.top),c.y.onZero=Math.max(Math.min(n("x"),c.y.right),c.y.left),a.position=["y"===h?c.y[s]:u[0],"x"===h?c.x[s]:u[3]];var f={x:0,y:1};a.rotation=Math.PI/2*f[h];var d={top:-1,bottom:1,left:-1,right:1};a.labelDirection=a.tickDirection=a.nameDirection=d[o],r.onZero&&(a.labelOffset=c[h][o]-c[h].onZero),e.getModel("axisTick").get("inside")&&(a.tickDirection=-a.tickDirection),e.getModel("axisLabel").get("inside")&&(a.labelDirection=-a.labelDirection);var p=e.getModel("axisLabel").get("rotate");return a.labelRotation="top"===s?-p:p,a.labelInterval=r.getLabelInterval(),a.z2=1,a}var r=n(1),a=n(3),o=n(48),s=o.ifIgnoreOnTick,h=o.getInterval,l=["axisLine","axisLabel","axisTick","axisName"],u=["splitLine","splitArea"],c=n(2).extendComponentView({type:"axis",render:function(t,e){if(this.group.removeAll(),t.get("show")){var n=e.getComponent("grid",t.get("gridIndex")),a=i(n,t),s=new o(t,a);r.each(l,s.add,s),this.group.add(s.getGroup()),r.each(u,function(e){t.get(e+".show")&&this["_"+e](t,n,a.labelInterval)},this)}},_splitLine:function(t,e,n){var i=t.axis,o=t.getModel("splitLine"),l=o.getModel("lineStyle"),u=l.get("width"),c=l.get("color"),f=h(o,n);c=r.isArray(c)?c:[c];for(var d=e.coordinateSystem.getRect(),p=i.isHorizontal(),g=[],v=0,m=i.getTicksCoords(),y=[],x=[],_=0;_n&&(n=Math.min(n,u),u-=n,t.width=n,c--)}),f=(u-s)/(c+(c-1)*l),f=Math.max(f,0);var d,p=0;o.each(n,function(t,e){t.width||(t.width=f),d=t,p+=t.width*(1+l)}),d&&(p-=d.width*l);var g=-p/2;o.each(n,function(t,n){r[e][n]=r[e][n]||{offset:g,width:t.width},g+=t.width*(1+l)})}),r}function a(t,e,n){var a=r(o.filter(e.getSeriesByType(t),function(t){return!e.isSeriesFiltered(t)&&t.coordinateSystem&&"cartesian2d"===t.coordinateSystem.type})),s={};e.eachSeriesByType(t,function(t){var e=t.getData(),n=t.coordinateSystem,r=n.getBaseAxis(),o=i(t),h=a[r.index][o],l=h.offset,u=h.width,c=n.getOtherAxis(r),f=t.get("barMinHeight")||0,d=r.onZero?c.toGlobalCoord(c.dataToCoord(0)):c.getGlobalExtent()[0],p=n.dataToPoints(e,!0);s[o]=s[o]||[],e.setLayout({offset:l,size:u}),e.each(c.dim,function(t,n){if(!isNaN(t)){s[o][n]||(s[o][n]={p:d,n:d});var i,r,a,h,g=t>=0?"p":"n",v=p[n],m=s[o][n][g];c.isHorizontal()?(i=m,r=v[1]+l,a=v[0]-m,h=u,Math.abs(a)a?-1:1)*f),s[o][n][g]+=a):(i=v[0]+l,r=m,a=u,h=v[1]-m,Math.abs(h)=h?-1:1)*f),s[o][n][g]+=h),e.setItemLayout(n,{x:i,y:r,width:a,height:h})}},!0)},this)}var o=n(1),s=n(4),h=s.parsePercent;t.exports=a},function(t,e,n){var i=n(3),r=n(1),a=Math.PI;t.exports=function(t,e){e=e||{},r.defaults(e,{text:"loading",color:"#c23531",textColor:"#000",maskColor:"rgba(255, 255, 255, 0.8)",zlevel:0});var n=new i.Rect({style:{fill:e.maskColor},zlevel:e.zlevel,z:1e4}),o=new i.Arc({shape:{startAngle:-a/2,endAngle:-a/2+.1,r:10},style:{stroke:e.color,lineCap:"round",lineWidth:5},zlevel:e.zlevel,z:10001}),s=new i.Rect({style:{fill:"none",text:e.text,textPosition:"right",textDistance:10,textFill:e.textColor},zlevel:e.zlevel,z:10001});o.animateShape(!0).when(1e3,{endAngle:3*a/2}).start("circularInOut"),o.animateShape(!0).when(1e3,{startAngle:3*a/2}).delay(300).start("circularInOut");var h=new i.Group;return h.add(o),h.add(s),h.add(n),h.resize=function(){var e=t.getWidth()/2,i=t.getHeight()/2;o.setShape({cx:e,cy:i});var r=o.shape.r;s.setShape({x:e-r,y:i-r,width:2*r,height:2*r}),n.setShape({x:0,y:0,width:t.getWidth(),height:t.getHeight()})},h.resize(),h}},function(t,e,n){function i(t,e){for(var n in e)_.hasClass(n)||("object"==typeof e[n]?t[n]=t[n]?c.merge(t[n],e[n],!1):c.clone(e[n]):t[n]=e[n])}function r(t){t=t,this.option={},this.option[w]=1,this._componentsMap={},this._seriesIndices=null,i(t,this._theme.option),c.merge(t,b,!1),this.mergeOption(t)}function a(t,e){c.isArray(e)||(e=e?[e]:[]);var n={};return p(e,function(e){n[e]=(t[e]||[]).slice()}),n}function o(t,e){var n={};p(e,function(t,e){var i=t.exist;i&&(n[i.id]=t)}),p(e,function(e,i){var r=e.option;if(c.assert(!r||null==r.id||!n[r.id]||n[r.id]===e,"id duplicates: "+(r&&r.id)),r&&null!=r.id&&(n[r.id]=e),x(r)){var a=s(t,r,e.exist);e.keyInfo={mainType:t,subType:a}}}),p(e,function(t,e){var i=t.exist,r=t.option,a=t.keyInfo;if(x(r)){if(a.name=null!=r.name?r.name+"":i?i.name:"\x00-",i)a.id=i.id;else if(null!=r.id)a.id=r.id+"";else{var o=0;do a.id="\x00"+a.name+"\x00"+o++;while(n[a.id])}n[a.id]=t}})}function s(t,e,n){var i=e.type?e.type:n?n.subType:_.determineSubType(t,e);return i}function h(t){return v(t,function(t){return t.componentIndex})||[]}function l(t,e){return e.hasOwnProperty("subType")?g(t,function(t){return t.subType===e.subType}):t}function u(t){if(!t._seriesIndices)throw new Error("Series has not been initialized yet.")}var c=n(1),f=n(7),d=n(12),p=c.each,g=c.filter,v=c.map,m=c.isArray,y=c.indexOf,x=c.isObject,_=n(10),b=n(113),w="\x00_ec_inner",M=d.extend({constructor:M,init:function(t,e,n,i){n=n||{},this.option=null,this._theme=new d(n),this._optionManager=i},setOption:function(t,e){c.assert(!(w in t),"please use chart.getOption()"),this._optionManager.setOption(t,e),this.resetOption()},resetOption:function(t){var e=!1,n=this._optionManager;if(!t||"recreate"===t){var i=n.mountOption("recreate"===t);this.option&&"recreate"!==t?(this.restoreData(),this.mergeOption(i)):r.call(this,i),e=!0}if("timeline"!==t&&"media"!==t||this.restoreData(),!t||"recreate"===t||"timeline"===t){var a=n.getTimelineOption(this);a&&(this.mergeOption(a),e=!0)}if(!t||"recreate"===t||"media"===t){var o=n.getMediaOption(this,this._api);o.length&&p(o,function(t){this.mergeOption(t,e=!0)},this)}return e},mergeOption:function(t){function e(e,r){var s=f.normalizeToArray(t[e]),l=f.mappingToExists(i[e],s);o(e,l);var u=a(i,r);n[e]=[],i[e]=[],p(l,function(t,r){var a=t.exist,o=t.option;if(c.assert(x(o)||a,"Empty component definition"),o){var s=_.getClass(e,t.keyInfo.subType,!0);a&&a instanceof s?(a.mergeOption(o,this),a.optionUpdated(this)):(a=new s(o,this,this,c.extend({dependentModels:u,componentIndex:r},t.keyInfo)),a.optionUpdated(this))}else a.mergeOption({},this),a.optionUpdated(this);i[e][r]=a,n[e][r]=a.option},this),"series"===e&&(this._seriesIndices=h(i.series))}var n=this.option,i=this._componentsMap,r=[];p(t,function(t,e){null!=t&&(_.hasClass(e)?r.push(e):n[e]=null==n[e]?c.clone(t):c.merge(n[e],t,!0))}),_.topologicalTravel(r,_.getAllClassMainTypes(),e,this)},getOption:function(){var t=c.clone(this.option);return p(t,function(e,n){if(_.hasClass(n)){for(var e=f.normalizeToArray(e),i=e.length-1;i>=0;i--)f.isIdInner(e[i])&&e.splice(i,1);t[n]=e}}),delete t[w],t},getTheme:function(){return this._theme},getComponent:function(t,e){var n=this._componentsMap[t];return n?n[e||0]:void 0},queryComponents:function(t){var e=t.mainType;if(!e)return[];var n=t.index,i=t.id,r=t.name,a=this._componentsMap[e];if(!a||!a.length)return[];var o;if(null!=n)m(n)||(n=[n]),o=g(v(n,function(t){return a[t]}),function(t){return!!t});else if(null!=i){var s=m(i);o=g(a,function(t){return s&&y(i,t.id)>=0||!s&&t.id===i})}else if(null!=r){var h=m(r);o=g(a,function(t){return h&&y(r,t.name)>=0||!h&&t.name===r})}return l(o,t)},findComponents:function(t){function e(t){var e=r+"Index",n=r+"Id",i=r+"Name";return t&&(t.hasOwnProperty(e)||t.hasOwnProperty(n)||t.hasOwnProperty(i))?{mainType:r,index:t[e],id:t[n],name:t[i]}:null}function n(e){return t.filter?g(e,t.filter):e}var i=t.query,r=t.mainType,a=e(i),o=a?this.queryComponents(a):this._componentsMap[r];return n(l(o,t))},eachComponent:function(t,e,n){var i=this._componentsMap;if("function"==typeof t)n=e,e=t,p(i,function(t,i){p(t,function(t,r){e.call(n,i,t,r)})});else if(c.isString(t))p(i[t],e,n);else if(x(t)){var r=this.findComponents(t);p(r,e,n)}},getSeriesByName:function(t){var e=this._componentsMap.series;return g(e,function(e){return e.name===t})},getSeriesByIndex:function(t){return this._componentsMap.series[t]},getSeriesByType:function(t){var e=this._componentsMap.series;return g(e,function(e){return e.subType===t})},getSeries:function(){return this._componentsMap.series.slice()},eachSeries:function(t,e){u(this),p(this._seriesIndices,function(n){var i=this._componentsMap.series[n];t.call(e,i,n)},this)},eachRawSeries:function(t,e){p(this._componentsMap.series,t,e)},eachSeriesByType:function(t,e,n){u(this),p(this._seriesIndices,function(i){var r=this._componentsMap.series[i];r.subType===t&&e.call(n,r,i)},this)},eachRawSeriesByType:function(t,e,n){return p(this.getSeriesByType(t),e,n)},isSeriesFiltered:function(t){return u(this),c.indexOf(this._seriesIndices,t.componentIndex)<0},filterSeries:function(t,e){u(this);var n=g(this._componentsMap.series,t,e);this._seriesIndices=h(n)},restoreData:function(){var t=this._componentsMap;this._seriesIndices=h(t.series);var e=[];p(t,function(t,n){e.push(n)}),_.topologicalTravel(e,_.getAllClassMainTypes(),function(e,n){p(t[e],function(t){t.restoreData()})})}});t.exports=M},function(t,e,n){function i(t){this._api=t,this._timelineOptions=[],this._mediaList=[],this._mediaDefault,this._currentMediaIndices=[],this._optionBackup,this._newOptionBackup}function r(t,e){var n,i,r=[],a=[],o=t.timeline;if(t.baseOption&&(i=t.baseOption),(o||t.options)&&(i=i||{},r=(t.options||[]).slice()),t.media){i=i||{};var s=t.media;f(s,function(t){t&&t.option&&(t.query?a.push(t):n||(n=t))})}return i||(i=t),i.timeline||(i.timeline=o),f([i].concat(r).concat(l.map(a,function(t){return t.option})),function(t){f(e,function(e){e(t)})}),{baseOption:i,timelineOptions:r,mediaDefault:n,mediaList:a}}function a(t,e,n){var i={width:e,height:n,aspectratio:e/n},r=!0;return l.each(t,function(t,e){var n=e.match(v);if(n&&n[1]&&n[2]){var a=n[1],s=n[2].toLowerCase();o(i[s],t,a)||(r=!1)}}),r}function o(t,e,n){return"min"===n?t>=e:"max"===n?e>=t:t===e}function s(t,e){return t.join(",")===e.join(",")}function h(t,e){e=e||{},f(e,function(e,n){if(null!=e){var i=t[n];if(c.hasClass(n)){e=u.normalizeToArray(e),i=u.normalizeToArray(i);var r=u.mappingToExists(i,e);t[n]=p(r,function(t){return t.option&&t.exist?g(t.exist,t.option,!0):t.exist||t.option})}else t[n]=g(i,e,!0)}})}var l=n(1),u=n(7),c=n(10),f=l.each,d=l.clone,p=l.map,g=l.merge,v=/^(min|max)?(.+)$/;i.prototype={constructor:i,setOption:function(t,e){t=d(t,!0);var n=this._optionBackup,i=this._newOptionBackup=r.call(this,t,e);n?(h(n.baseOption,i.baseOption),i.timelineOptions.length&&(n.timelineOptions=i.timelineOptions),i.mediaList.length&&(n.mediaList=i.mediaList),i.mediaDefault&&(n.mediaDefault=i.mediaDefault)):this._optionBackup=i},mountOption:function(t){var e=t?this._optionBackup:this._newOptionBackup;return this._timelineOptions=p(e.timelineOptions,d),this._mediaList=p(e.mediaList,d),this._mediaDefault=d(e.mediaDefault),this._currentMediaIndices=[],d(e.baseOption)},getTimelineOption:function(t){var e,n=this._timelineOptions;if(n.length){var i=t.getComponent("timeline");i&&(e=d(n[i.getCurrentIndex()],!0))}return e},getMediaOption:function(t){var e=this._api.getWidth(),n=this._api.getHeight(),i=this._mediaList,r=this._mediaDefault,o=[],h=[];if(!i.length&&!r)return h;for(var l=0,u=i.length;u>l;l++)a(i[l].query,e,n)&&o.push(l);return!o.length&&r&&(o=[-1]),o.length&&!s(o,this._currentMediaIndices)&&(h=p(o,function(t){return d(-1===t?r.option:i[t].option)})),this._currentMediaIndices=o,h}},t.exports=i},function(t,e){var n="";"undefined"!=typeof navigator&&(n=navigator.platform||""),t.exports={color:["#c23531","#2f4554","#61a0a8","#d48265","#91c7ae","#749f83","#ca8622","#bda29a","#6e7074","#546570","#c4ccd3"],grid:{},textStyle:{fontFamily:n.match(/^Win/)?"Microsoft YaHei":"sans-serif",fontSize:12,fontStyle:"normal",fontWeight:"normal"},animation:!0,animationThreshold:2e3,animationDuration:1e3,animationDurationUpdate:300,animationEasing:"exponentialOut",animationEasingUpdate:"cubicOut"}},function(t,e,n){t.exports={getAreaStyle:n(30)([["fill","color"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["opacity"],["shadowColor"]])}},function(t,e){t.exports={getBoxLayoutParams:function(){return{left:this.get("left"),top:this.get("top"),right:this.get("right"),bottom:this.get("bottom"),width:this.get("width"),height:this.get("height")}}}},function(t,e,n){t.exports={getItemStyle:n(30)([["fill","color"],["stroke","borderColor"],["lineWidth","borderWidth"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]])}},function(t,e,n){var i=n(30)([["lineWidth","width"],["stroke","color"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]]);t.exports={getLineStyle:function(t){var e=i.call(this,t),n=this.getLineDash();return n&&(e.lineDash=n),e},getLineDash:function(){var t=this.get("type");return"solid"===t||null==t?null:"dashed"===t?[5,5]:[1,1]}}},function(t,e,n){function i(t,e){return t&&t.getShallow(e)}var r=n(17);t.exports={getTextColor:function(){var t=this.ecModel;return this.getShallow("color")||t&&t.get("textStyle.color")},getFont:function(){var t=this.ecModel,e=t&&t.getModel("textStyle");return[this.getShallow("fontStyle")||i(e,"fontStyle"),this.getShallow("fontWeight")||i(e,"fontWeight"),(this.getShallow("fontSize")||i(e,"fontSize")||12)+"px",this.getShallow("fontFamily")||i(e,"fontFamily")||"sans-serif"].join(" ")},getTextRect:function(t){var e=this.get("textStyle")||{};return r.getBoundingRect(t,this.getFont(),e.align,e.baseline)},ellipsis:function(t,e,n){return r.ellipsis(t,this.getFont(),e,n)}}},function(t,e,n){function i(t,e){e=e.split(",");for(var n=t,i=0;ie&&(e=t[n]);return e},min:function(t){for(var e=1/0,n=0;n1){var c;"string"==typeof r?c=n[r]:"function"==typeof r&&(c=r),c&&(e=e.downSample(s.dim,1/u,c,i),t.setData(e))}}},this)}},function(t,e,n){var i=n(1),r=n(32),a=n(4),o=n(37),s=r.prototype,h=o.prototype,l=Math.floor,u=Math.ceil,c=Math.pow,f=10,d=Math.log,p=r.extend({type:"log",getTicks:function(){return i.map(h.getTicks.call(this),function(t){return a.round(c(f,t))})},getLabel:h.getLabel,scale:function(t){return t=s.scale.call(this,t),c(f,t)},setExtent:function(t,e){t=d(t)/d(f),e=d(e)/d(f),h.setExtent.call(this,t,e)},getExtent:function(){var t=s.getExtent.call(this);return t[0]=c(f,t[0]),t[1]=c(f,t[1]),t},unionExtent:function(t){t[0]=d(t[0])/d(f),t[1]=d(t[1])/d(f),s.unionExtent.call(this,t)},niceTicks:function(t){t=t||10;var e=this._extent,n=e[1]-e[0];if(!(n===1/0||0>=n)){var i=c(10,l(d(n/t)/Math.LN10)),r=t/n*i;.5>=r&&(i*=10);var o=[a.round(u(e[0]/i)*i),a.round(l(e[1]/i)*i)];this._interval=i,this._niceExtent=o}},niceExtent:h.niceExtent});i.each(["contain","normalize"],function(t){p.prototype[t]=function(e){return e=d(e)/d(f),s[t].call(this,e)}}),p.create=function(){return new p},t.exports=p},function(t,e,n){var i=n(1),r=n(32),a=r.prototype,o=r.extend({type:"ordinal",init:function(t,e){this._data=t,this._extent=e||[0,t.length-1]},parse:function(t){return"string"==typeof t?i.indexOf(this._data,t):Math.round(t)},contain:function(t){return t=this.parse(t),a.contain.call(this,t)&&null!=this._data[t]},normalize:function(t){return a.normalize.call(this,this.parse(t))},scale:function(t){return Math.round(a.scale.call(this,t))},getTicks:function(){for(var t=[],e=this._extent,n=e[0];n<=e[1];)t.push(n),n++;return t},getLabel:function(t){return this._data[t]},count:function(){return this._extent[1]-this._extent[0]+1},niceTicks:i.noop,niceExtent:i.noop});o.create=function(){return new o},t.exports=o},function(t,e,n){var i=n(1),r=n(4),a=n(9),o=n(37),s=o.prototype,h=Math.ceil,l=Math.floor,u=864e5,c=function(t,e,n,i){for(;i>n;){var r=n+i>>>1;t[r][2]=0;r--)if(!i[r].silent&&i[r]!==n&&!i[r].ignore&&o(i[r],t,e))return i[r]}},d.mixin(C,v),d.mixin(C,p),t.exports=C},function(t,e,n){function i(){return!1}function r(t,e,n,i){var r=document.createElement(e),a=n.getWidth(),o=n.getHeight(),s=r.style;return s.position="absolute",s.left=0,s.top=0,s.width=a+"px",s.height=o+"px",r.width=a*i,r.height=o*i,r.setAttribute("data-zr-dom-id",t),r}var a=n(1),o=n(42),s=function(t,e,n){var s;n=n||o.devicePixelRatio,"string"==typeof t?s=r(t,"canvas",e,n):a.isObject(t)&&(s=t,t=s.id),this.id=t,this.dom=s;var h=s.style;h&&(s.onselectstart=i,h["-webkit-user-select"]="none",h["user-select"]="none",h["-webkit-touch-callout"]="none",h["-webkit-tap-highlight-color"]="rgba(0,0,0,0)"),this.domBack=null,this.ctxBack=null,this.painter=e,this.config=null,this.clearColor=0,this.motionBlur=!1,this.lastFrameAlpha=.7,this.dpr=n};s.prototype={constructor:s,elCount:0,__dirty:!0,initContext:function(){this.ctx=this.dom.getContext("2d");var t=this.dpr;1!=t&&this.ctx.scale(t,t)},createBackBuffer:function(){var t=this.dpr;this.domBack=r("back-"+this.id,"canvas",this.painter,t),this.ctxBack=this.domBack.getContext("2d"),1!=t&&this.ctxBack.scale(t,t)},resize:function(t,e){var n=this.dpr,i=this.dom,r=i.style,a=this.domBack;r.width=t+"px",r.height=e+"px",i.width=t*n,i.height=e*n,1!=n&&this.ctx.scale(n,n),a&&(a.width=t*n,a.height=e*n,1!=n&&this.ctxBack.scale(n,n))},clear:function(t){var e=this.dom,n=this.ctx,i=e.width,r=e.height,a=this.clearColor,o=this.motionBlur&&!t,s=this.lastFrameAlpha,h=this.dpr;if(o&&(this.domBack||this.createBackBuffer(),this.ctxBack.globalCompositeOperation="copy",this.ctxBack.drawImage(e,0,0,i/h,r/h)),n.clearRect(0,0,i/h,r/h),a&&(n.save(),n.fillStyle=this.clearColor,n.fillRect(0,0,i/h,r/h),n.restore()),o){var l=this.domBack;n.save(),n.globalAlpha=s,n.drawImage(l,0,0,i/h,r/h),n.restore()}}},t.exports=s},function(t,e,n){"use strict";function i(t){return parseInt(t,10)}function r(t){return t?t.isBuildin?!0:"function"==typeof t.resize&&"function"==typeof t.refresh:!1}function a(t){t.__unusedCount++}function o(t){t.__dirty=!1,1==t.__unusedCount&&t.clear()}function s(t,e,n){return g.copy(t.getBoundingRect()),t.transform&&g.applyTransform(t.transform),v.width=e,v.height=n,!g.intersect(v)}function h(t,e){if(!t||!e||t.length!==e.length)return!0;for(var n=0;np;p++){var v=t[p],m=this._singleCanvas?0:v.zlevel;if(i!==m&&(i=m,n=this.getLayer(i),n.isBuildin||f("ZLevel "+i+" has been used by unkown layer "+n.id),r=n.ctx,n.__unusedCount=0,(n.__dirty||e)&&n.clear()),(n.__dirty||e)&&!v.invisible&&0!==v.style.opacity&&v.scale[0]&&v.scale[1]&&(!v.culling||!s(v,u,c))){var y=v.__clipPaths;h(y,d)&&(d&&r.restore(),y&&(r.save(),l(y,r)),d=y),v.beforeBrush&&v.beforeBrush(r),v.brush(r,!1),v.afterBrush&&v.afterBrush(r)}v.__dirty=!1}d&&r.restore(),this.eachBuildinLayer(o)},getLayer:function(t){if(this._singleCanvas)return this._layers[0];var e=this._layers[t];return e||(e=new p("zr_"+t,this,this.dpr),e.isBuildin=!0,this._layerConfig[t]&&c.merge(e,this._layerConfig[t],!0),this.insertLayer(t,e),e.initContext()),e},insertLayer:function(t,e){var n=this._layers,i=this._zlevelList,a=i.length,o=null,s=-1,h=this._domRoot;if(n[t])return void f("ZLevel "+t+" has been used already");if(!r(e))return void f("Layer of zlevel "+t+" is not valid");if(a>0&&t>i[0]){for(s=0;a-1>s&&!(i[s]t);s++);o=n[i[s]]}if(i.splice(s+1,0,t),o){var l=o.dom;l.nextSibling?h.insertBefore(e.dom,l.nextSibling):h.appendChild(e.dom)}else h.firstChild?h.insertBefore(e.dom,h.firstChild):h.appendChild(e.dom);n[t]=e},eachLayer:function(t,e){var n,i,r=this._zlevelList;for(i=0;ii;i++){var a=t[i],o=this._singleCanvas?0:a.zlevel,s=e[o];if(s){if(s.elCount++,s.__dirty)continue;s.__dirty=a.__dirty}}this.eachBuildinLayer(function(t,e){n[e]!==t.elCount&&(t.__dirty=!0)})},clear:function(){return this.eachBuildinLayer(this._clearLayer),this},_clearLayer:function(t){t.clear()},configLayer:function(t,e){if(e){var n=this._layerConfig;n[t]?c.merge(n[t],e,!0):n[t]=e;var i=this._layers[t];i&&c.merge(i,n[t],!0)}},delLayer:function(t){var e=this._layers,n=this._zlevelList,i=e[t];i&&(i.dom.parentNode.removeChild(i.dom),delete e[t],n.splice(c.indexOf(n,t),1))},resize:function(t,e){var n=this._domRoot;if(n.style.display="none",t=t||this._getWidth(),e=e||this._getHeight(),n.style.display="",this._width!=t||e!=this._height){n.style.width=t+"px",n.style.height=e+"px";for(var i in this._layers)this._layers[i].resize(t,e);this.refresh(!0)}return this._width=t,this._height=e,this},clearLayer:function(t){var e=this._layers[t];e&&e.clear()},dispose:function(){this.root.innerHTML="",this.root=this.storage=this._domRoot=this._layers=null},getRenderedCanvas:function(t){if(t=t||{},this._singleCanvas)return this._layers[0].dom;var e=new p("image",this,t.pixelRatio||this.dpr);e.initContext();var n=e.ctx;e.clearColor=t.backgroundColor,e.clear();for(var i=this.storage.getDisplayList(!0),r=0;rr;r++)this._updateAndAddDisplayable(e[r],null,t);n.length=this._displayListLen;for(var r=0,a=n.length;a>r;r++)n[r].__renderidx=r;n.sort(i)},_updateAndAddDisplayable:function(t,e,n){if(!t.ignore||n){t.beforeUpdate(),t.update(),t.afterUpdate();var i=t.clipPath;if(i&&(i.parent=t,i.updateTransform(),e?(e=e.slice(),e.push(i)):e=[i]),"group"==t.type){for(var r=t._children,a=0;ae;e++)this.delRoot(t[e]);else{var o;o="string"==typeof t?this._elements[t]:t;var s=r.indexOf(this._roots,o);s>=0&&(this.delFromMap(o.id),this._roots.splice(s,1),o instanceof a&&o.delChildrenFromStorage(this))}},addToMap:function(t){return t instanceof a&&(t.__storage=this),t.dirty(),this._elements[t.id]=t,this},get:function(t){return this._elements[t]},delFromMap:function(t){var e=this._elements,n=e[t];return n&&(delete e[t],n instanceof a&&(n.__storage=null)),this},dispose:function(){this._elements=this._renderList=this._roots=null}},t.exports=o},function(t,e,n){"use strict";var i=n(1),r=n(33).Dispatcher,a="undefined"!=typeof window&&(window.requestAnimationFrame||window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(t){setTimeout(t,16)},o=n(56),s=function(t){t=t||{},this.stage=t.stage||{},this.onframe=t.onframe||function(){},this._clips=[],this._running=!1,this._time=0,r.call(this)};s.prototype={constructor:s,addClip:function(t){this._clips.push(t)},addAnimator:function(t){t.animation=this;for(var e=t.getClips(),n=0;n=0&&this._clips.splice(e,1)},removeAnimator:function(t){for(var e=t.getClips(),n=0;no;o++){var s=n[o],h=s.step(t);h&&(r.push(h),a.push(s))}for(var o=0;i>o;)n[o]._needsRemove?(n[o]=n[i-1],n.pop(),i--):o++;i=r.length;for(var o=0;i>o;o++)a[o].fire(r[o]);this._time=t,this.onframe(e),this.trigger("frame",e),this.stage.update&&this.stage.update()},start:function(){function t(){e._running&&(a(t),e._update())}var e=this;this._running=!0,this._time=(new Date).getTime(),a(t)},stop:function(){this._running=!1},clear:function(){this._clips=[]},animate:function(t,e){e=e||{};var n=new o(t,e.loop,e.getter,e.setter);return n}},i.mixin(s,r),t.exports=s},function(t,e,n){function i(t){this._target=t.target,this._life=t.life||1e3,this._delay=t.delay||0,this._initialized=!1,this.loop=null==t.loop?!1:t.loop,this.gap=t.gap||0,this.easing=t.easing||"Linear",this.onframe=t.onframe,this.ondestroy=t.ondestroy,this.onrestart=t.onrestart}var r=n(132);i.prototype={constructor:i,step:function(t){this._initialized||(this._startTime=(new Date).getTime()+this._delay,this._initialized=!0);var e=(t-this._startTime)/this._life;if(!(0>e)){e=Math.min(e,1);var n=this.easing,i="string"==typeof n?r[n]:n,a="function"==typeof i?i(e):e;return this.fire("frame",a),1==e?this.loop?(this.restart(),"restart"):(this._needsRemove=!0,"destroy"):null}},restart:function(){var t=(new Date).getTime(),e=(t-this._startTime)%this._life;this._startTime=(new Date).getTime()-e+this.gap,this._needsRemove=!1},fire:function(t,e){t="on"+t,this[t]&&this[t](this._target,e)}},t.exports=i},function(t,e){var n={linear:function(t){return t},quadraticIn:function(t){return t*t},quadraticOut:function(t){return t*(2-t)},quadraticInOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},cubicIn:function(t){return t*t*t},cubicOut:function(t){return--t*t*t+1},cubicInOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},quarticIn:function(t){return t*t*t*t},quarticOut:function(t){return 1- --t*t*t*t},quarticInOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},quinticIn:function(t){return t*t*t*t*t},quinticOut:function(t){return--t*t*t*t*t+1},quinticInOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},sinusoidalIn:function(t){return 1-Math.cos(t*Math.PI/2)},sinusoidalOut:function(t){return Math.sin(t*Math.PI/2)},sinusoidalInOut:function(t){return.5*(1-Math.cos(Math.PI*t))},exponentialIn:function(t){return 0===t?0:Math.pow(1024,t-1)},exponentialOut:function(t){return 1===t?1:1-Math.pow(2,-10*t)},exponentialInOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(2,-10*(t-1))+2)},circularIn:function(t){return 1-Math.sqrt(1-t*t)},circularOut:function(t){return Math.sqrt(1- --t*t)},circularInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},elasticIn:function(t){var e,n=.1,i=.4;return 0===t?0:1===t?1:(!n||1>n?(n=1,e=i/4):e=i*Math.asin(1/n)/(2*Math.PI),-(n*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i)))},elasticOut:function(t){var e,n=.1,i=.4;return 0===t?0:1===t?1:(!n||1>n?(n=1,e=i/4):e=i*Math.asin(1/n)/(2*Math.PI),n*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/i)+1)},elasticInOut:function(t){var e,n=.1,i=.4;return 0===t?0:1===t?1:(!n||1>n?(n=1,e=i/4):e=i*Math.asin(1/n)/(2*Math.PI),(t*=2)<1?-.5*(n*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i)):n*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i)*.5+1)},backIn:function(t){var e=1.70158;return t*t*((e+1)*t-e)},backOut:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},backInOut:function(t){var e=2.5949095;return(t*=2)<1?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+2)},bounceIn:function(t){return 1-n.bounceOut(1-t)},bounceOut:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},bounceInOut:function(t){return.5>t?.5*n.bounceIn(2*t):.5*n.bounceOut(2*t-1)+.5}};t.exports=n},function(t,e,n){var i=n(57).normalizeRadian,r=2*Math.PI;t.exports={containStroke:function(t,e,n,a,o,s,h,l,u){if(0===h)return!1;var c=h;l-=t,u-=e;var f=Math.sqrt(l*l+u*u);if(f-c>n||n>f+c)return!1;if(Math.abs(a-o)%r<1e-4)return!0;if(s){var d=a;a=i(o),o=i(d)}else a=i(a),o=i(o);a>o&&(o+=r);var p=Math.atan2(u,l);return 0>p&&(p+=r),p>=a&&o>=p||p+r>=a&&o>=p+r}}},function(t,e,n){var i=n(18);t.exports={containStroke:function(t,e,n,r,a,o,s,h,l,u,c){if(0===l)return!1;var f=l;if(c>e+f&&c>r+f&&c>o+f&&c>h+f||e-f>c&&r-f>c&&o-f>c&&h-f>c||u>t+f&&u>n+f&&u>a+f&&u>s+f||t-f>u&&n-f>u&&a-f>u&&s-f>u)return!1;var d=i.cubicProjectPoint(t,e,n,r,a,o,s,h,u,c,null);return f/2>=d}}},function(t,e){t.exports={containStroke:function(t,e,n,i,r,a,o){if(0===r)return!1;var s=r,h=0,l=t;if(o>e+s&&o>i+s||e-s>o&&i-s>o||a>t+s&&a>n+s||t-s>a&&n-s>a)return!1;if(t===n)return Math.abs(a-t)<=s/2;h=(e-i)/(t-n),l=(t*i-n*e)/(t-n);var u=h*a-o+l,c=u*u/(h*h+1);return s/2*s/2>=c}}},function(t,e,n){"use strict";function i(t,e){return Math.abs(t-e)e&&u>i&&u>o&&u>h||e>u&&i>u&&o>u&&h>u)return 0;var c=g.cubicRootAt(e,i,o,h,u,_);if(0===c)return 0;for(var f,d,p=0,v=-1,m=0;c>m;m++){var y=_[m],x=g.cubicAt(t,n,a,s,y);l>x||(0>v&&(v=g.cubicExtrema(e,i,o,h,b),b[1]1&&r(),f=g.cubicAt(e,i,o,h,b[0]),v>1&&(d=g.cubicAt(e,i,o,h,b[1]))),p+=2==v?yf?1:-1:yd?1:-1:d>h?1:-1:yf?1:-1:f>h?1:-1)}return p}function o(t,e,n,i,r,a,o,s){if(s>e&&s>i&&s>a||e>s&&i>s&&a>s)return 0;var h=g.quadraticRootAt(e,i,a,s,_);if(0===h)return 0;var l=g.quadraticExtremum(e,i,a);if(l>=0&&1>=l){for(var u=0,c=g.quadraticAt(e,i,a,l),f=0;h>f;f++){var d=g.quadraticAt(t,n,r,_[f]);d>o||(u+=_[f]c?1:-1:c>a?1:-1)}return u}var d=g.quadraticAt(t,n,r,_[0]);return d>o?0:e>a?1:-1}function s(t,e,n,i,r,a,o,s){if(s-=e,s>n||-n>s)return 0;var h=Math.sqrt(n*n-s*s);_[0]=-h,_[1]=h;var l=Math.abs(i-r);if(1e-4>l)return 0;if(1e-4>l%y){i=0,r=y;var u=a?1:-1;return o>=_[0]+t&&o<=_[1]+t?u:0}if(a){var h=i;i=p(r),r=p(h)}else i=p(i),r=p(r);i>r&&(r+=y);for(var c=0,f=0;2>f;f++){var d=_[f];if(d+t>o){var g=Math.atan2(s,d),u=a?1:-1;0>g&&(g=y+g),(g>=i&&r>=g||g+y>=i&&r>=g+y)&&(g>Math.PI/2&&g<1.5*Math.PI&&(u=-u),c+=u)}}return c}function h(t,e,n,r,h){for(var u=0,p=0,g=0,y=0,x=0,_=0;_1&&(n||(u+=v(p,g,y,x,r,h)),0!==u))return!0;switch(1==_&&(p=t[_],g=t[_+1],y=p,x=g),b){case l.M:y=t[_++],x=t[_++],p=y,g=x;break;case l.L:if(n){if(m(p,g,t[_],t[_+1],e,r,h))return!0}else u+=v(p,g,t[_],t[_+1],r,h)||0;p=t[_++],g=t[_++];break;case l.C:if(n){if(c.containStroke(p,g,t[_++],t[_++],t[_++],t[_++],t[_],t[_+1],e,r,h))return!0}else u+=a(p,g,t[_++],t[_++],t[_++],t[_++],t[_],t[_+1],r,h)||0;p=t[_++],g=t[_++];break;case l.Q:if(n){if(f.containStroke(p,g,t[_++],t[_++],t[_],t[_+1],e,r,h))return!0}else u+=o(p,g,t[_++],t[_++],t[_],t[_+1],r,h)||0;p=t[_++],g=t[_++];break;case l.A:var w=t[_++],M=t[_++],S=t[_++],C=t[_++],T=t[_++],A=t[_++],I=(t[_++],1-t[_++]),k=Math.cos(T)*S+w,L=Math.sin(T)*C+M;_>1?u+=v(p,g,k,L,r,h):(y=k,x=L);var P=(r-w)*C/S+w;if(n){if(d.containStroke(w,M,C,T,T+A,I,e,P,h))return!0}else u+=s(w,M,C,T,T+A,I,P,h);p=Math.cos(T+A)*S+w,g=Math.sin(T+A)*C+M;break;case l.R:y=p=t[_++],x=g=t[_++];var D=t[_++],O=t[_++],k=y+D,L=x+O;if(n){if(m(y,x,k,x,e,r,h)||m(k,x,k,L,e,r,h)||m(k,L,y,L,e,r,h)||m(y,L,k,L,e,r,h))return!0}else u+=v(k,x,k,L,r,h),u+=v(y,L,y,x,r,h);break;case l.Z:if(n){if(m(p,g,y,x,e,r,h))return!0}else if(u+=v(p,g,y,x,r,h),0!==u)return!0;p=y,g=x}}return n||i(g,x)||(u+=v(p,g,y,x,r,h)||0),0!==u}var l=n(27).CMD,u=n(135),c=n(134),f=n(137),d=n(133),p=n(57).normalizeRadian,g=n(18),v=n(75),m=u.containStroke,y=2*Math.PI,x=1e-4,_=[-1,-1,-1],b=[-1,-1];t.exports={contain:function(t,e,n){return h(t,0,!1,e,n)},containStroke:function(t,e,n,i){return h(t,e,!0,n,i)}}},function(t,e,n){var i=n(18);t.exports={containStroke:function(t,e,n,r,a,o,s,h,l){if(0===s)return!1;var u=s;if(l>e+u&&l>r+u&&l>o+u||e-u>l&&r-u>l&&o-u>l||h>t+u&&h>n+u&&h>a+u||t-u>h&&n-u>h&&a-u>h)return!1;var c=i.quadraticProjectPoint(t,e,n,r,a,o,h,l,null);return u/2>=c}}},function(t,e){"use strict";function n(t){var e=t[1][0]-t[0][0],n=t[1][1]-t[0][1];return Math.sqrt(e*e+n*n)}function i(t){return[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2]}var r=function(){this._track=[]};r.prototype={constructor:r,recognize:function(t,e){return this._doTrack(t,e),this._recognize(t)},clear:function(){return this._track.length=0,this},_doTrack:function(t,e){var n=t.touches;if(n){for(var i={points:[],touches:[],target:e,event:t},r=0,a=n.length;a>r;r++){var o=n[r];i.points.push([o.clientX,o.clientY]),i.touches.push(o)}this._track.push(i)}},_recognize:function(t){for(var e in a)if(a.hasOwnProperty(e)){var n=a[e](this._track,t);if(n)return n}}};var a={pinch:function(t,e){var r=t.length;if(r){var a=(t[r-1]||{}).points,o=(t[r-2]||{}).points||a;if(o&&o.length>1&&a&&a.length>1){var s=n(a)/n(o);!isFinite(s)&&(s=1),e.pinchScale=s;var h=i(a);return e.pinchX=h[0],e.pinchY=h[1],{type:"pinch",target:t[0].target,event:e}}}}};t.exports=r},function(t,e){var n=function(){this.head=null,this.tail=null,this._len=0},i=n.prototype;i.insert=function(t){var e=new r(t);return this.insertEntry(e),e},i.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,this.tail=t):this.head=this.tail=t,this._len++},i.remove=function(t){var e=t.prev,n=t.next;e?e.next=n:this.head=n,n?n.prev=e:this.tail=e,t.next=t.prev=null,this._len--},i.len=function(){return this._len};var r=function(t){this.value=t,this.next,this.prev},a=function(t){this._list=new n,this._map={},this._maxSize=t||10},o=a.prototype;o.put=function(t,e){var n=this._list,i=this._map;if(null==i[t]){var r=n.len();if(r>=this._maxSize&&r>0){var a=n.head;n.remove(a),delete i[a.key]}var o=n.insert(e);o.key=t,i[t]=o}},o.get=function(t){var e=this._map[t],n=this._list;return null!=e?(e!==n.tail&&(n.remove(e),n.insertEntry(e)),e.value):void 0},o.clear=function(){this._list.clear(),this._map={}},t.exports=a},function(t,e,n){"use strict";var i=n(1),r=n(16),a=function(t,e,n,i){this.x=null==t?.5:t,this.y=null==e?.5:e,this.r=null==n?.5:n,r.call(this,i)};a.prototype={constructor:a,type:"radial",updateCanvasGradient:function(t,e){for(var n=t.getBoundingRect(),i=n.width,r=n.height,a=Math.min(i,r),o=this.x*i+n.x,s=this.y*r+n.y,h=this.r*a,l=e.createRadialGradient(o,s,0,o,s,h),u=this.colorStops,c=0;cy;y++)r(f,f,t[y]),a(d,d,t[y]);r(f,f,l[0]),a(d,d,l[1])}for(var y=0,x=t.length;x>y;y++){var _=t[y];if(n)u=t[y?y-1:x-1],c=t[(y+1)%x];else{if(0===y||y===x-1){p.push(i.clone(t[y]));continue}u=t[y-1],c=t[y+1]}i.sub(g,c,u),o(g,g,e);var b=s(_,u),w=s(_,c),M=b+w;0!==M&&(b/=M,w/=M),o(v,g,-b),o(m,g,w);var S=h([],_,v),C=h([],_,m);l&&(a(S,S,f),r(S,S,d),a(C,C,f),r(C,C,d)),p.push(S),p.push(C)}return n&&p.push(p.shift()),p}},function(t,e,n){function i(t,e,n,i,r,a,o){var s=.5*(n-t),h=.5*(i-e);return(2*(e-n)+s+h)*o+(-3*(e-n)-2*s-h)*a+s*r+e}var r=n(5);t.exports=function(t,e){for(var n=t.length,a=[],o=0,s=1;n>s;s++)o+=r.distance(t[s-1],t[s]);var h=o/2;h=n>h?n:h;for(var s=0;h>s;s++){var l,u,c,f=s/(h-1)*(e?n:n-1),d=Math.floor(f),p=f-d,g=t[d%n];e?(l=t[(d-1+n)%n],u=t[(d+1)%n],c=t[(d+2)%n]):(l=t[0===d?d:d-1],u=t[d>n-2?n-1:d+1],c=t[d>n-3?n-1:d+2]);var v=p*p,m=p*v;a.push([i(l[0],g[0],u[0],c[0],p,v,m),i(l[1],g[1],u[1],c[1],p,v,m)])}return a}},function(t,e,n){t.exports=n(6).extend({type:"arc",shape:{cx:0,cy:0,r:0,startAngle:0,endAngle:2*Math.PI,clockwise:!0},style:{stroke:"#000",fill:null},buildPath:function(t,e){var n=e.cx,i=e.cy,r=Math.max(e.r,0),a=e.startAngle,o=e.endAngle,s=e.clockwise,h=Math.cos(a),l=Math.sin(a);t.moveTo(h*r+n,l*r+i),t.arc(n,i,r,a,o,!s)}})},function(t,e,n){"use strict";var i=n(18),r=i.quadraticSubdivide,a=i.cubicSubdivide,o=i.quadraticAt,s=i.cubicAt,h=[];t.exports=n(6).extend({type:"bezier-curve",shape:{x1:0,y1:0,x2:0,y2:0,cpx1:0,cpy1:0,percent:1},style:{stroke:"#000",fill:null},buildPath:function(t,e){var n=e.x1,i=e.y1,o=e.x2,s=e.y2,l=e.cpx1,u=e.cpy1,c=e.cpx2,f=e.cpy2,d=e.percent;0!==d&&(t.moveTo(n,i),null==c||null==f?(1>d&&(r(n,l,o,d,h),l=h[1],o=h[2],r(i,u,s,d,h),u=h[1],s=h[2]),t.quadraticCurveTo(l,u,o,s)):(1>d&&(a(n,l,c,o,d,h),l=h[1],c=h[2],o=h[3],a(i,u,f,s,d,h),u=h[1],f=h[2],s=h[3]),t.bezierCurveTo(l,u,c,f,o,s)))},pointAt:function(t){var e=this.shape,n=e.cpx2,i=e.cpy2;return null===n||null===i?[o(e.x1,e.cpx1,e.x2,t),o(e.y1,e.cpy1,e.y2,t)]:[s(e.x1,e.cpx1,e.cpx1,e.x2,t),s(e.y1,e.cpy1,e.cpy1,e.y2,t)]}})},function(t,e,n){"use strict";t.exports=n(6).extend({type:"circle",shape:{cx:0,cy:0,r:0},buildPath:function(t,e){t.moveTo(e.cx+e.r,e.cy),t.arc(e.cx,e.cy,e.r,0,2*Math.PI,!0)}})},function(t,e,n){t.exports=n(6).extend({type:"line",shape:{x1:0,y1:0,x2:0,y2:0,percent:1},style:{stroke:"#000",fill:null},buildPath:function(t,e){var n=e.x1,i=e.y1,r=e.x2,a=e.y2,o=e.percent;0!==o&&(t.moveTo(n,i),1>o&&(r=n*(1-o)+r*o,a=i*(1-o)+a*o),t.lineTo(r,a))},pointAt:function(t){var e=this.shape;return[e.x1*(1-t)+e.x2*t,e.y1*(1-t)+e.y2*t]}})},function(t,e,n){var i=n(59);t.exports=n(6).extend({type:"polygon",shape:{points:null,smooth:!1,smoothConstraint:null},buildPath:function(t,e){i.buildPath(t,e,!0)}})},function(t,e,n){var i=n(59);t.exports=n(6).extend({type:"polyline",shape:{points:null,smooth:!1,smoothConstraint:null},style:{stroke:"#000",fill:null},buildPath:function(t,e){i.buildPath(t,e,!1)}})},function(t,e,n){var i=n(60);t.exports=n(6).extend({type:"rect",shape:{r:0,x:0,y:0,width:0,height:0},buildPath:function(t,e){var n=e.x,r=e.y,a=e.width,o=e.height;e.r?i.buildPath(t,e):t.rect(n,r,a,o),t.closePath()}})},function(t,e,n){t.exports=n(6).extend({type:"ring",shape:{cx:0,cy:0,r:0,r0:0},buildPath:function(t,e){var n=e.cx,i=e.cy,r=2*Math.PI;t.moveTo(n+e.r,i),t.arc(n,i,e.r,0,r,!1),t.moveTo(n+e.r0,i),t.arc(n,i,e.r0,0,r,!0)}})},function(t,e,n){t.exports=n(6).extend({type:"sector",shape:{cx:0,cy:0,r0:0,r:0,startAngle:0,endAngle:2*Math.PI,clockwise:!0},buildPath:function(t,e){var n=e.cx,i=e.cy,r=Math.max(e.r0||0,0),a=Math.max(e.r,0),o=e.startAngle,s=e.endAngle,h=e.clockwise,l=Math.cos(o),u=Math.sin(o);t.moveTo(l*r+n,u*r+i),t.lineTo(l*a+n,u*a+i),t.arc(n,i,a,o,s,!h),t.lineTo(Math.cos(s)*r+n,Math.sin(s)*r+i),0!==r&&t.arc(n,i,r,s,o,h),t.closePath()}})},function(t,e,n){"use strict";var i=n(56),r=n(1),a=r.isString,o=r.isFunction,s=r.isObject,h=n(45),l=function(){this.animators=[]};l.prototype={constructor:l,animate:function(t,e){var n,a=!1,o=this,s=this.__zr;if(t){var l=t.split("."),u=o;a="shape"===l[0];for(var c=0,f=l.length;f>c;c++)u&&(u=u[l[c]]);u&&(n=u)}else n=o;if(!n)return void h('Property "'+t+'" is not existed in element '+o.id);var d=o.animators,p=new i(n,e);return p.during(function(t){o.dirty(a)}).done(function(){d.splice(r.indexOf(d,p),1)}),d.push(p),s&&s.animation.addAnimator(p),p},stopAnimation:function(t){for(var e=this.animators,n=e.length,i=0;n>i;i++)e[i].stop(t);return e.length=0,this},animateTo:function(t,e,n,i,r){function s(){l--,l||r&&r()}a(n)?(r=i,i=n,n=0):o(i)?(r=i,i="linear",n=0):o(n)?(r=n,n=0):o(e)?(r=e,e=500):e||(e=500),this.stopAnimation(),this._animateToShallow("",this,t,e,n,i,r);var h=this.animators.slice(),l=h.length;l||r&&r();for(var u=0;u0&&this.animate(t,!1).when(null==i?500:i,o).delay(a||0),this}},t.exports=l},function(t,e){function n(){this.on("mousedown",this._dragStart,this),this.on("mousemove",this._drag,this),this.on("mouseup",this._dragEnd,this),this.on("globalout",this._dragEnd,this)}n.prototype={constructor:n,_dragStart:function(t){var e=t.target;e&&e.draggable&&(this._draggingTarget=e,e.dragging=!0,this._x=t.offsetX,this._y=t.offsetY,this._dispatchProxy(e,"dragstart",t.event))},_drag:function(t){var e=this._draggingTarget;if(e){var n=t.offsetX,i=t.offsetY,r=n-this._x,a=i-this._y;this._x=n,this._y=i,e.drift(r,a,t),this._dispatchProxy(e,"drag",t.event);var o=this.findHover(n,i,e),s=this._dropTarget;this._dropTarget=o,e!==o&&(s&&o!==s&&this._dispatchProxy(s,"dragleave",t.event),o&&o!==s&&this._dispatchProxy(o,"dragenter",t.event))}},_dragEnd:function(t){var e=this._draggingTarget;e&&(e.dragging=!1),this._dispatchProxy(e,"dragend",t.event),this._dropTarget&&this._dispatchProxy(this._dropTarget,"drop",t.event),this._draggingTarget=null,this._dropTarget=null}},t.exports=n},function(t,e,n){function i(t,e,n,i,r,a,o,s,h,l,u){var g=h*(p/180),y=d(g)*(t-n)/2+f(g)*(e-i)/2,x=-1*f(g)*(t-n)/2+d(g)*(e-i)/2,_=y*y/(o*o)+x*x/(s*s);_>1&&(o*=c(_),s*=c(_));var b=(r===a?-1:1)*c((o*o*(s*s)-o*o*(x*x)-s*s*(y*y))/(o*o*(x*x)+s*s*(y*y)))||0,w=b*o*x/s,M=b*-s*y/o,S=(t+n)/2+d(g)*w-f(g)*M,C=(e+i)/2+f(g)*w+d(g)*M,T=m([1,0],[(y-w)/o,(x-M)/s]),A=[(y-w)/o,(x-M)/s],I=[(-1*y-w)/o,(-1*x-M)/s],k=m(A,I);v(A,I)<=-1&&(k=p),v(A,I)>=1&&(k=0),0===a&&k>0&&(k-=2*p),1===a&&0>k&&(k+=2*p),u.addData(l,S,C,o,s,T,k,g,a)}function r(t){if(!t)return[];var e,n=t.replace(/-/g," -").replace(/ /g," ").replace(/ /g,",").replace(/,,/g,",");for(e=0;e0&&""===v[0]&&v.shift();for(var m=0;mi;i++)n=t[i],n.__dirty&&n.buildPath(n.path,n.shape),r.push(n.path);var s=new o(e);return s.buildPath=function(t){t.appendPath(r);var e=t.getContext();e&&t.rebuildPath(e)},s}}},function(t,e,n){function i(t,e){var n,i,a,u,c,f,d=t.data,p=r.M,g=r.C,v=r.L,m=r.R,y=r.A,x=r.Q;for(a=0,u=0;ac;c++){var f=s[c];f[0]=d[a++],f[1]=d[a++],o(f,f,e),d[u++]=f[0],d[u++]=f[1]}}}var r=n(27).CMD,a=n(5),o=a.applyTransform,s=[[],[],[]],h=Math.sqrt,l=Math.atan2;t.exports=i}])}); \ No newline at end of file diff --git a/dist/extension/bmap.js b/dist/extension/bmap.js index 8b28ac2aa4..609accf972 100644 --- a/dist/extension/bmap.js +++ b/dist/extension/bmap.js @@ -1 +1,340 @@ -(function(e,t){typeof define=="function"&&define.amd?define(["exports","echarts"],t):typeof exports=="object"&&typeof exports.nodeName!="string"?t(exports,require("echarts")):t({},e.echarts)})(this,function(e,t){var n,r;(function(){function t(e,t){if(!t)return e;if(e.indexOf(".")===0){var n=t.split("/"),r=e.split("/"),i=n.length-1,s=r.length,o=0,u=0;e:for(var a=0;av){var y=[a,g];r.layout==="vertical"&&y.reverse(),s.push(y)}}}return{boxData:i,outliers:s,axisData:o}}}),r("extension/dataTool/gexf",["require","echarts"],function(e){function n(e){var t;if(typeof e=="string"){var n=new DOMParser;t=n.parseFromString(e,"text/xml")}else t=e;if(!t||t.getElementsByTagName("parsererror").length)return null;var o=u(t,"gexf");if(!o)return null;var a=u(o,"graph"),f=r(u(a,"attributes")),l={};for(var c=0;c} rawData like + * [ + * [12,232,443], (raw data set for the first box) + * [3843,5545,1232], (raw datat set for the second box) + * ... + * ] + * @param {Object} [opt] + * + * @param {(number|string)} [opt.boundIQR=1.5] Data less than min bound is outlier. + * default 1.5, means Q1 - 1.5 * (Q3 - Q1). + * If pass 'none', min bound will not be used. + * @param {(number|string)} [opt.layout='horizontal'] + * Box plot layout, can be 'horizontal' or 'vertical' + */ + return function (rawData, opt) { + opt = opt || []; + var boxData = []; + var outliers = []; + var axisData = []; + var boundIQR = opt.boundIQR; + + for (var i = 0; i < rawData.length; i++) { + axisData.push(i + ''); + var ascList = numberUtil.asc(rawData[i].slice()); + + var Q1 = quantile(ascList, 0.25); + var Q2 = quantile(ascList, 0.5); + var Q3 = quantile(ascList, 0.75); + var IQR = Q3 - Q1; + + var low = boundIQR === 'none' + ? ascList[0] + : Q1 - (boundIQR == null ? 1.5 : boundIQR) * IQR; + var high = boundIQR === 'none' + ? ascList[ascList.length - 1] + : Q3 + (boundIQR == null ? 1.5 : boundIQR) * IQR; + + boxData.push([low, Q1, Q2, Q3, high]); + + for (var j = 0; j < ascList.length; j++) { + var dataItem = ascList[j]; + if (dataItem < low || dataItem > high) { + var outlier = [i, dataItem]; + opt.layout === 'vertical' && outlier.reverse(); + outliers.push(outlier); + } + } + } + return { + boxData: boxData, + outliers: outliers, + axisData: axisData + }; + }; + + }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + +/***/ }, +/* 7 */ +/***/ function(module, exports, __webpack_require__) { + + var __WEBPACK_AMD_DEFINE_RESULT__;/** + * Copyright (c) 2010-2015, Michael Bostock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * The name Michael Bostock may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + !(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) { + + /** + * @see + * @see + * @param {Array.} ascArr + */ + return function(ascArr, p) { + var H = (ascArr.length - 1) * p + 1, + h = Math.floor(H), + v = +ascArr[h - 1], + e = H - h; + return e ? v + e * (ascArr[h] - v) : v; + }; + + }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + +/***/ } +/******/ ]) +}); +; \ No newline at end of file diff --git a/dist/extension/dataTool.min.js b/dist/extension/dataTool.min.js new file mode 100644 index 0000000000..bf5496a96b --- /dev/null +++ b/dist/extension/dataTool.min.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("echarts")):"function"==typeof define&&define.amd?define(["echarts"],t):"object"==typeof exports?exports.dataTool=t(require("echarts")):(e.echarts=e.echarts||{},e.echarts.dataTool=t(e.echarts))}(this,function(e){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){var o;o=function(e){var t=r(1);return t.dataTool={version:"1.0.0",gexf:r(5),prepareBoxplotData:r(6)},t.dataTool}.call(t,r,t,e),!(void 0!==o&&(e.exports=o))},function(t,r){t.exports=e},,,,function(e,t,r){var o;o=function(e){"use strict";function t(e){var t;if("string"==typeof e){var r=new DOMParser;t=r.parseFromString(e,"text/xml")}else t=e;if(!t||t.getElementsByTagName("parsererror").length)return null;var i=l(t,"gexf");if(!i)return null;for(var u=l(i,"graph"),s=o(l(u,"attributes")),c={},f=0;fb||b>g){var x=[u,b];"vertical"===r.layout&&x.reverse(),a.push(x)}}}return{boxData:n,outliers:a,axisData:i}}}.call(t,r,t,e),!(void 0!==o&&(e.exports=o))},function(e,t,r){var o;o=function(e){return function(e,t){var r=(e.length-1)*t+1,o=Math.floor(r),n=+e[o-1],a=r-o;return a?n+a*(e[o]-n):n}}.call(t,r,t,e),!(void 0!==o&&(e.exports=o))}])}); \ No newline at end of file diff --git a/package.json b/package.json index a1c8e577bf..8ad3b2f28e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "echarts", - "version": "3.1.2", + "version": "3.1.3", "description": "A powerful charting and visualization library for browser", "keywords": [ "visualization", @@ -35,13 +35,15 @@ "prepublish": "node build/amd2common.js" }, "dependencies": { - "zrender": "^3.0.3" + "zrender": "^3.0.4" }, "devDependencies": { + "escodegen": "^1.8.0", "esprima": "^2.7.2", + "estraverse": "^4.1.1", "fs-extra": "^0.26.5", "glob": "^7.0.0", "webpack": "^1.12.13", - "zrender": "^3.0.3" + "zrender": "^3.0.4" } } diff --git a/src/echarts.js b/src/echarts.js index 3ed1a4bae5..e8613127ef 100644 --- a/src/echarts.js +++ b/src/echarts.js @@ -962,9 +962,9 @@ define(function (require) { /** * @type {number} */ - version: '3.1.2', + version: '3.1.3', dependencies: { - zrender: '3.0.3' + zrender: '3.0.4' } };