diff --git a/node_modules/tops-echarts/lib/core/echarts.js b/node_modules/tops-echarts/lib/core/echarts.js index 7cbb01f..defcfce 100644 --- a/node_modules/tops-echarts/lib/core/echarts.js +++ b/node_modules/tops-echarts/lib/core/echarts.js @@ -181,16 +181,16 @@ function toLowercaseNameAndCallEventful(host, method, args) { } var MessageCenter = -/** @class */ -function (_super) { - __extends(MessageCenter, _super); + /** @class */ + function (_super) { + __extends(MessageCenter, _super); - function MessageCenter() { - return _super !== null && _super.apply(this, arguments) || this; - } + function MessageCenter() { + return _super !== null && _super.apply(this, arguments) || this; + } - return MessageCenter; -}(Eventful); + return MessageCenter; + }(Eventful); var messageCenterProto = MessageCenter.prototype; messageCenterProto.on = createRegisterEventWithLowercaseMessageCenter('on'); @@ -219,103 +219,103 @@ var markStatusToUpdate; var applyChangedStates; var ECharts = -/** @class */ -function (_super) { - __extends(ECharts, _super); + /** @class */ + function (_super) { + __extends(ECharts, _super); - function ECharts(dom, // Theme name or themeOption. - theme, opts) { - var _this = _super.call(this, new ECEventProcessor()) || this; + function ECharts(dom, // Theme name or themeOption. + theme, opts) { + var _this = _super.call(this, new ECEventProcessor()) || this; - _this._chartsViews = []; - _this._chartsMap = {}; - _this._componentsViews = []; - _this._componentsMap = {}; // Can't dispatch action during rendering procedure + _this._chartsViews = []; + _this._chartsMap = {}; + _this._componentsViews = []; + _this._componentsMap = {}; // Can't dispatch action during rendering procedure - _this._pendingActions = []; - opts = opts || {}; // Get theme by name - - if (typeof theme === 'string') { - theme = themeStorage[theme]; - } + _this._pendingActions = []; + opts = opts || {}; // Get theme by name - _this._dom = dom; - var defaultRenderer = 'canvas'; - var defaultUseDirtyRect = false; + if (typeof theme === 'string') { + theme = themeStorage[theme]; + } - if (process.env.NODE_ENV !== 'production') { - var root = - /* eslint-disable-next-line */ - hasWindow ? window : global; - defaultRenderer = root.__ECHARTS__DEFAULT__RENDERER__ || defaultRenderer; - var devUseDirtyRect = root.__ECHARTS__DEFAULT__USE_DIRTY_RECT__; - defaultUseDirtyRect = devUseDirtyRect == null ? defaultUseDirtyRect : devUseDirtyRect; - } + _this._dom = dom; + var defaultRenderer = 'canvas'; + var defaultUseDirtyRect = false; - var zr = _this._zr = zrender.init(dom, { - renderer: opts.renderer || defaultRenderer, - devicePixelRatio: opts.devicePixelRatio, - width: opts.width, - height: opts.height, - useDirtyRect: opts.useDirtyRect == null ? defaultUseDirtyRect : opts.useDirtyRect - }); // Expect 60 fps. - - _this._throttledZrFlush = throttle(bind(zr.flush, zr), 17); - theme = clone(theme); - theme && backwardCompat(theme, true); - _this._theme = theme; - _this._locale = createLocaleObject(opts.locale || SYSTEM_LANG); - _this._coordSysMgr = new CoordinateSystemManager(); - var api = _this._api = createExtensionAPI(_this); // Sort on demand - - function prioritySortFunc(a, b) { - return a.__prio - b.__prio; - } + if (process.env.NODE_ENV !== 'production') { + var root = + /* eslint-disable-next-line */ + hasWindow ? window : global; + defaultRenderer = root.__ECHARTS__DEFAULT__RENDERER__ || defaultRenderer; + var devUseDirtyRect = root.__ECHARTS__DEFAULT__USE_DIRTY_RECT__; + defaultUseDirtyRect = devUseDirtyRect == null ? defaultUseDirtyRect : devUseDirtyRect; + } - timsort(visualFuncs, prioritySortFunc); - timsort(dataProcessorFuncs, prioritySortFunc); - _this._scheduler = new Scheduler(_this, api, dataProcessorFuncs, visualFuncs); - _this._messageCenter = new MessageCenter(); // Init mouse events + var zr = _this._zr = zrender.init(dom, { + renderer: opts.renderer || defaultRenderer, + devicePixelRatio: opts.devicePixelRatio, + width: opts.width, + height: opts.height, + useDirtyRect: opts.useDirtyRect == null ? defaultUseDirtyRect : opts.useDirtyRect + }); // Expect 60 fps. + + _this._throttledZrFlush = throttle(bind(zr.flush, zr), 17); + theme = clone(theme); + theme && backwardCompat(theme, true); + _this._theme = theme; + _this._locale = createLocaleObject(opts.locale || SYSTEM_LANG); + _this._coordSysMgr = new CoordinateSystemManager(); + var api = _this._api = createExtensionAPI(_this); // Sort on demand + + function prioritySortFunc(a, b) { + return a.__prio - b.__prio; + } - _this._initEvents(); // In case some people write `window.onresize = chart.resize` + timsort(visualFuncs, prioritySortFunc); + timsort(dataProcessorFuncs, prioritySortFunc); + _this._scheduler = new Scheduler(_this, api, dataProcessorFuncs, visualFuncs); + _this._messageCenter = new MessageCenter(); // Init mouse events + _this._initEvents(); // In case some people write `window.onresize = chart.resize` - _this.resize = bind(_this.resize, _this); - zr.animation.on('frame', _this._onframe, _this); - bindRenderedEvent(zr, _this); - bindMouseEvent(zr, _this); // ECharts instance can be used as value. - setAsPrimitive(_this); - return _this; - } + _this.resize = bind(_this.resize, _this); + zr.animation.on('frame', _this._onframe, _this); + bindRenderedEvent(zr, _this); + bindMouseEvent(zr, _this); // ECharts instance can be used as value. - ECharts.prototype._onframe = function () { - if (this._disposed) { - return; + setAsPrimitive(_this); + return _this; } - applyChangedStates(this); - var scheduler = this._scheduler; // Lazy update - - if (this[PENDING_UPDATE]) { - var silent = this[PENDING_UPDATE].silent; - this[IN_MAIN_PROCESS_KEY] = true; - prepare(this); - updateMethods.update.call(this, null, this[PENDING_UPDATE].updateParams); // At present, in each frame, zrender performs: - // (1) animation step forward. - // (2) trigger('frame') (where this `_onframe` is called) - // (3) zrender flush (render). - // If we do nothing here, since we use `setToFinal: true`, the step (3) above - // will render the final state of the elements before the real animation started. + ECharts.prototype._onframe = function () { + if (this._disposed) { + return; + } - this._zr.flush(); + applyChangedStates(this); + var scheduler = this._scheduler; // Lazy update - this[IN_MAIN_PROCESS_KEY] = false; - this[PENDING_UPDATE] = null; - flushPendingActions.call(this, silent); - triggerUpdatedEvent.call(this, silent); - } // Avoid do both lazy update and progress in one frame. - else if (scheduler.unfinished) { + if (this[PENDING_UPDATE]) { + var silent = this[PENDING_UPDATE].silent; + this[IN_MAIN_PROCESS_KEY] = true; + prepare(this); + updateMethods.update.call(this, null, this[PENDING_UPDATE].updateParams); // At present, in each frame, zrender performs: + // (1) animation step forward. + // (2) trigger('frame') (where this `_onframe` is called) + // (3) zrender flush (render). + // If we do nothing here, since we use `setToFinal: true`, the step (3) above + // will render the final state of the elements before the real animation started. + + this._zr.flush(); + + this[IN_MAIN_PROCESS_KEY] = false; + this[PENDING_UPDATE] = null; + flushPendingActions.call(this, silent); + triggerUpdatedEvent.call(this, silent); + } // Avoid do both lazy update and progress in one frame. + else if (scheduler.unfinished) { // Stream progress. var remainTime = TEST_FRAME_REMAIN_TIME; var ecModel = this._model; @@ -346,1737 +346,1737 @@ function (_super) { // because zr flushing is after onframe event. } - }; - - ECharts.prototype.getDom = function () { - return this._dom; - }; + }; - ECharts.prototype.getId = function () { - return this.id; - }; + ECharts.prototype.getDom = function () { + return this._dom; + }; - ECharts.prototype.getZr = function () { - return this._zr; - }; - /* eslint-disable-next-line */ + ECharts.prototype.getId = function () { + return this.id; + }; + ECharts.prototype.getZr = function () { + return this._zr; + }; + /* eslint-disable-next-line */ - ECharts.prototype.setOption = function (option, notMerge, lazyUpdate) { - if (process.env.NODE_ENV !== 'production') { - assert(!this[IN_MAIN_PROCESS_KEY], '`setOption` should not be called during main process.'); - } - if (this._disposed) { - disposedWarning(this.id); - return; - } + ECharts.prototype.setOption = function (option, notMerge, lazyUpdate) { + if (process.env.NODE_ENV !== 'production') { + assert(!this[IN_MAIN_PROCESS_KEY], '`setOption` should not be called during main process.'); + } - var silent; - var replaceMerge; - var transitionOpt; + if (this._disposed) { + disposedWarning(this.id); + return; + } - if (isObject(notMerge)) { - lazyUpdate = notMerge.lazyUpdate; - silent = notMerge.silent; - replaceMerge = notMerge.replaceMerge; - transitionOpt = notMerge.transition; - notMerge = notMerge.notMerge; - } + var silent; + var replaceMerge; + var transitionOpt; - this[IN_MAIN_PROCESS_KEY] = true; + if (isObject(notMerge)) { + lazyUpdate = notMerge.lazyUpdate; + silent = notMerge.silent; + replaceMerge = notMerge.replaceMerge; + transitionOpt = notMerge.transition; + notMerge = notMerge.notMerge; + } - if (!this._model || notMerge) { - var optionManager = new OptionManager(this._api); - var theme = this._theme; - var ecModel = this._model = new GlobalModel(); - ecModel.scheduler = this._scheduler; - ecModel.init(null, null, null, theme, this._locale, optionManager); - } + this[IN_MAIN_PROCESS_KEY] = true; - this._model.setOption(option, { - replaceMerge: replaceMerge - }, optionPreprocessorFuncs); + if (!this._model || notMerge) { + var optionManager = new OptionManager(this._api); + var theme = this._theme; + var ecModel = this._model = new GlobalModel(); + ecModel.scheduler = this._scheduler; + ecModel.init(null, null, null, theme, this._locale, optionManager); + } - var updateParams = { - seriesTransition: transitionOpt, - optionChanged: true - }; + this._model.setOption(option, { + replaceMerge: replaceMerge + }, optionPreprocessorFuncs); - if (lazyUpdate) { - this[PENDING_UPDATE] = { - silent: silent, - updateParams: updateParams + var updateParams = { + seriesTransition: transitionOpt, + optionChanged: true }; - this[IN_MAIN_PROCESS_KEY] = false; // `setOption(option, {lazyMode: true})` may be called when zrender has been slept. - // It should wake it up to make sure zrender start to render at the next frame. - - this.getZr().wakeUp(); - } else { - prepare(this); - updateMethods.update.call(this, null, updateParams); // Ensure zr refresh sychronously, and then pixel in canvas can be - // fetched after `setOption`. - this._zr.flush(); + if (lazyUpdate) { + this[PENDING_UPDATE] = { + silent: silent, + updateParams: updateParams + }; + this[IN_MAIN_PROCESS_KEY] = false; // `setOption(option, {lazyMode: true})` may be called when zrender has been slept. + // It should wake it up to make sure zrender start to render at the next frame. - this[PENDING_UPDATE] = null; - this[IN_MAIN_PROCESS_KEY] = false; - flushPendingActions.call(this, silent); - triggerUpdatedEvent.call(this, silent); - } - }; - /** - * @DEPRECATED - */ + this.getZr().wakeUp(); + } else { + prepare(this); + updateMethods.update.call(this, null, updateParams); // Ensure zr refresh sychronously, and then pixel in canvas can be + // fetched after `setOption`. + this._zr.flush(); - ECharts.prototype.setTheme = function () { - console.error('ECharts#setTheme() is DEPRECATED in ECharts 3.0'); - }; // We don't want developers to use getModel directly. + this[PENDING_UPDATE] = null; + this[IN_MAIN_PROCESS_KEY] = false; + flushPendingActions.call(this, silent); + triggerUpdatedEvent.call(this, silent); + } + }; + /** + * @DEPRECATED + */ - ECharts.prototype.getModel = function () { - return this._model; - }; + ECharts.prototype.setTheme = function () { + console.error('ECharts#setTheme() is DEPRECATED in ECharts 3.0'); + }; // We don't want developers to use getModel directly. - ECharts.prototype.getOption = function () { - return this._model && this._model.getOption(); - }; - ECharts.prototype.getWidth = function () { - return this._zr.getWidth(); - }; + ECharts.prototype.getModel = function () { + return this._model; + }; - ECharts.prototype.getHeight = function () { - return this._zr.getHeight(); - }; + ECharts.prototype.getOption = function () { + return this._model && this._model.getOption(); + }; - ECharts.prototype.getDevicePixelRatio = function () { - return this._zr.painter.dpr - /* eslint-disable-next-line */ - || hasWindow && window.devicePixelRatio || 1; - }; - /** - * Get canvas which has all thing rendered - */ + ECharts.prototype.getWidth = function () { + return this._zr.getWidth(); + }; + ECharts.prototype.getHeight = function () { + return this._zr.getHeight(); + }; - ECharts.prototype.getRenderedCanvas = function (opts) { - if (!env.canvasSupported) { - return; - } + ECharts.prototype.getDevicePixelRatio = function () { + return this._zr.painter.dpr + /* eslint-disable-next-line */ + || hasWindow && window.devicePixelRatio || 1; + }; + /** + * Get canvas which has all thing rendered + */ - opts = opts || {}; - return this._zr.painter.getRenderedCanvas({ - backgroundColor: opts.backgroundColor || this._model.get('backgroundColor'), - pixelRatio: opts.pixelRatio || this.getDevicePixelRatio() - }); - }; - /** - * Get svg data url - */ + ECharts.prototype.getRenderedCanvas = function (opts) { + if (!env.canvasSupported) { + return; + } - ECharts.prototype.getSvgDataURL = function () { - if (!env.svgSupported) { - return; - } + opts = opts || {}; + return this._zr.painter.getRenderedCanvas({ + backgroundColor: opts.backgroundColor || this._model.get('backgroundColor'), + pixelRatio: opts.pixelRatio || this.getDevicePixelRatio() + }); + }; + /** + * Get svg data url + */ - var zr = this._zr; - var list = zr.storage.getDisplayList(); // Stop animations - each(list, function (el) { - el.stopAnimation(null, true); - }); - return zr.painter.toDataURL(); - }; + ECharts.prototype.getSvgDataURL = function () { + if (!env.svgSupported) { + return; + } - ECharts.prototype.getDataURL = function (opts) { - if (this._disposed) { - disposedWarning(this.id); - return; - } + var zr = this._zr; + var list = zr.storage.getDisplayList(); // Stop animations - 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; - } + each(list, function (el) { + el.stopAnimation(null, true); }); - }); - var url = this._zr.painter.getType() === 'svg' ? this.getSvgDataURL() : this.getRenderedCanvas(opts).toDataURL('image/' + (opts && opts.type || 'png')); - each(excludesComponentViews, function (view) { - view.group.ignore = false; - }); - return url; - }; - - ECharts.prototype.getConnectedDataURL = function (opts) { - if (this._disposed) { - disposedWarning(this.id); - return; - } + return zr.painter.toDataURL(); + }; - if (!env.canvasSupported) { - return; - } + ECharts.prototype.getDataURL = function (opts) { + if (this._disposed) { + disposedWarning(this.id); + return; + } - var isSvg = opts.type === 'svg'; - var groupId = this.group; - var mathMin = Math.min; - var mathMax = Math.max; - var MAX_NUMBER = Infinity; - - if (connectedGroups[groupId]) { - var left_1 = MAX_NUMBER; - var top_1 = MAX_NUMBER; - var right_1 = -MAX_NUMBER; - var bottom_1 = -MAX_NUMBER; - var canvasList_1 = []; - var dpr_1 = opts && opts.pixelRatio || this.getDevicePixelRatio(); - each(instances, function (chart, id) { - if (chart.group === groupId) { - var canvas = isSvg ? chart.getZr().painter.getSvgDom().innerHTML : chart.getRenderedCanvas(clone(opts)); - var boundingRect = chart.getDom().getBoundingClientRect(); - left_1 = mathMin(boundingRect.left, left_1); - top_1 = mathMin(boundingRect.top, top_1); - right_1 = mathMax(boundingRect.right, right_1); - bottom_1 = mathMax(boundingRect.bottom, bottom_1); - canvasList_1.push({ - dom: canvas, - left: boundingRect.left, - top: boundingRect.top - }); - } - }); - left_1 *= dpr_1; - top_1 *= dpr_1; - right_1 *= dpr_1; - bottom_1 *= dpr_1; - var width = right_1 - left_1; - var height = bottom_1 - top_1; - var targetCanvas = createCanvas(); - var zr_1 = zrender.init(targetCanvas, { - renderer: isSvg ? 'svg' : 'canvas' + 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; + } + }); }); - zr_1.resize({ - width: width, - height: height + var url = this._zr.painter.getType() === 'svg' ? this.getSvgDataURL() : this.getRenderedCanvas(opts).toDataURL('image/' + (opts && opts.type || 'png')); + each(excludesComponentViews, function (view) { + view.group.ignore = false; }); + return url; + }; - if (isSvg) { - var content_1 = ''; - each(canvasList_1, function (item) { - var x = item.left - left_1; - var y = item.top - top_1; - content_1 += '' + item.dom + ''; - }); - zr_1.painter.getSvgRoot().innerHTML = content_1; + ECharts.prototype.getConnectedDataURL = function (opts) { + if (this._disposed) { + disposedWarning(this.id); + return; + } - if (opts.connectedBackgroundColor) { - zr_1.painter.setBackgroundColor(opts.connectedBackgroundColor); - } + if (!env.canvasSupported) { + return; + } - zr_1.refreshImmediately(); - return zr_1.painter.toDataURL(); - } else { - // Background between the charts - if (opts.connectedBackgroundColor) { - zr_1.add(new graphic.Rect({ - shape: { - x: 0, - y: 0, - width: width, - height: height - }, - style: { - fill: opts.connectedBackgroundColor - } - })); - } + var isSvg = opts.type === 'svg'; + var groupId = this.group; + var mathMin = Math.min; + var mathMax = Math.max; + var MAX_NUMBER = Infinity; + + if (connectedGroups[groupId]) { + var left_1 = MAX_NUMBER; + var top_1 = MAX_NUMBER; + var right_1 = -MAX_NUMBER; + var bottom_1 = -MAX_NUMBER; + var canvasList_1 = []; + var dpr_1 = opts && opts.pixelRatio || this.getDevicePixelRatio(); + each(instances, function (chart, id) { + if (chart.group === groupId) { + var canvas = isSvg ? chart.getZr().painter.getSvgDom().innerHTML : chart.getRenderedCanvas(clone(opts)); + var boundingRect = chart.getDom().getBoundingClientRect(); + left_1 = mathMin(boundingRect.left, left_1); + top_1 = mathMin(boundingRect.top, top_1); + right_1 = mathMax(boundingRect.right, right_1); + bottom_1 = mathMax(boundingRect.bottom, bottom_1); + canvasList_1.push({ + dom: canvas, + left: boundingRect.left, + top: boundingRect.top + }); + } + }); + left_1 *= dpr_1; + top_1 *= dpr_1; + right_1 *= dpr_1; + bottom_1 *= dpr_1; + var width = right_1 - left_1; + var height = bottom_1 - top_1; + var targetCanvas = createCanvas(); + var zr_1 = zrender.init(targetCanvas, { + renderer: isSvg ? 'svg' : 'canvas' + }); + zr_1.resize({ + width: width, + height: height + }); - each(canvasList_1, function (item) { - var img = new graphic.Image({ - style: { - x: item.left * dpr_1 - left_1, - y: item.top * dpr_1 - top_1, - image: item.dom - } + if (isSvg) { + var content_1 = ''; + each(canvasList_1, function (item) { + var x = item.left - left_1; + var y = item.top - top_1; + content_1 += '' + item.dom + ''; }); - zr_1.add(img); - }); - zr_1.refreshImmediately(); - return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png')); - } - } else { - return this.getDataURL(opts); - } - }; + zr_1.painter.getSvgRoot().innerHTML = content_1; - ECharts.prototype.convertToPixel = function (finder, value) { - return doConvertPixel(this, 'convertToPixel', finder, value); - }; + if (opts.connectedBackgroundColor) { + zr_1.painter.setBackgroundColor(opts.connectedBackgroundColor); + } - ECharts.prototype.convertFromPixel = function (finder, value) { - return doConvertPixel(this, 'convertFromPixel', finder, value); - }; - /** - * Is the specified coordinate systems or components contain the given pixel point. - * @param {Array|number} value - * @return {boolean} result - */ + zr_1.refreshImmediately(); + return zr_1.painter.toDataURL(); + } else { + // Background between the charts + if (opts.connectedBackgroundColor) { + zr_1.add(new graphic.Rect({ + shape: { + x: 0, + y: 0, + width: width, + height: height + }, + style: { + fill: opts.connectedBackgroundColor + } + })); + } + each(canvasList_1, function (item) { + var img = new graphic.Image({ + style: { + x: item.left * dpr_1 - left_1, + y: item.top * dpr_1 - top_1, + image: item.dom + } + }); + zr_1.add(img); + }); + zr_1.refreshImmediately(); + return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png')); + } + } else { + return this.getDataURL(opts); + } + }; - ECharts.prototype.containPixel = function (finder, value) { - if (this._disposed) { - disposedWarning(this.id); - return; - } + ECharts.prototype.convertToPixel = function (finder, value) { + return doConvertPixel(this, 'convertToPixel', finder, value); + }; + + ECharts.prototype.convertFromPixel = function (finder, value) { + return doConvertPixel(this, 'convertFromPixel', finder, value); + }; + /** + * Is the specified coordinate systems or components contain the given pixel point. + * @param {Array|number} value + * @return {boolean} result + */ - var ecModel = this._model; - var result; - var findResult = modelUtil.parseFinder(ecModel, finder); - each(findResult, function (models, key) { - key.indexOf('Models') >= 0 && each(models, function (model) { - var coordSys = model.coordinateSystem; - if (coordSys && coordSys.containPoint) { - result = result || !!coordSys.containPoint(value); - } else if (key === 'seriesModels') { - var view = this._chartsMap[model.__viewId]; + ECharts.prototype.containPixel = function (finder, value) { + if (this._disposed) { + disposedWarning(this.id); + return; + } - if (view && view.containPoint) { - result = result || view.containPoint(value, model); + var ecModel = this._model; + var result; + var findResult = modelUtil.parseFinder(ecModel, finder); + each(findResult, function (models, key) { + key.indexOf('Models') >= 0 && each(models, function (model) { + var coordSys = model.coordinateSystem; + + if (coordSys && coordSys.containPoint) { + result = result || !!coordSys.containPoint(value); + } else if (key === 'seriesModels') { + var view = this._chartsMap[model.__viewId]; + + if (view && view.containPoint) { + result = result || view.containPoint(value, model); + } else { + if (process.env.NODE_ENV !== 'production') { + console.warn(key + ': ' + (view ? 'The found component do not support containPoint.' : 'No view mapping to the found component.')); + } + } } else { if (process.env.NODE_ENV !== 'production') { - console.warn(key + ': ' + (view ? 'The found component do not support containPoint.' : 'No view mapping to the found component.')); + console.warn(key + ': containPoint is not supported'); } } - } else { - if (process.env.NODE_ENV !== 'production') { - console.warn(key + ': containPoint is not supported'); - } - } + }, this); }, this); - }, this); - return !!result; - }; - /** - * Get visual from series or data. - * @param finder - * If string, e.g., 'series', means {seriesIndex: 0}. - * If Object, could contain some of these properties below: - * { - * seriesIndex / seriesId / seriesName, - * dataIndex / dataIndexInside - * } - * If dataIndex is not specified, series visual will be fetched, - * but not data item visual. - * If all of seriesIndex, seriesId, seriesName are not specified, - * visual will be fetched from first series. - * @param visualType 'color', 'symbol', 'symbolSize' - */ - - - ECharts.prototype.getVisual = function (finder, visualType) { - var ecModel = this._model; - var parsedFinder = modelUtil.parseFinder(ecModel, finder, { - defaultMainType: 'series' - }); - var seriesModel = parsedFinder.seriesModel; + return !!result; + }; + /** + * Get visual from series or data. + * @param finder + * If string, e.g., 'series', means {seriesIndex: 0}. + * If Object, could contain some of these properties below: + * { + * seriesIndex / seriesId / seriesName, + * dataIndex / dataIndexInside + * } + * If dataIndex is not specified, series visual will be fetched, + * but not data item visual. + * If all of seriesIndex, seriesId, seriesName are not specified, + * visual will be fetched from first series. + * @param visualType 'color', 'symbol', 'symbolSize' + */ - if (process.env.NODE_ENV !== 'production') { - if (!seriesModel) { - console.warn('There is no specified seires model'); + + ECharts.prototype.getVisual = function (finder, visualType) { + var ecModel = this._model; + var parsedFinder = modelUtil.parseFinder(ecModel, finder, { + defaultMainType: 'series' + }); + var seriesModel = parsedFinder.seriesModel; + + if (process.env.NODE_ENV !== 'production') { + if (!seriesModel) { + console.warn('There is no specified seires model'); + } } - } - var data = seriesModel.getData(); - var dataIndexInside = parsedFinder.hasOwnProperty('dataIndexInside') ? parsedFinder.dataIndexInside : parsedFinder.hasOwnProperty('dataIndex') ? data.indexOfRawIndex(parsedFinder.dataIndex) : null; - return dataIndexInside != null ? getItemVisualFromData(data, dataIndexInside, visualType) : getVisualFromData(data, visualType); - }; - /** - * Get view of corresponding component model - */ + var data = seriesModel.getData(); + var dataIndexInside = parsedFinder.hasOwnProperty('dataIndexInside') ? parsedFinder.dataIndexInside : parsedFinder.hasOwnProperty('dataIndex') ? data.indexOfRawIndex(parsedFinder.dataIndex) : null; + return dataIndexInside != null ? getItemVisualFromData(data, dataIndexInside, visualType) : getVisualFromData(data, visualType); + }; + /** + * Get view of corresponding component model + */ - ECharts.prototype.getViewOfComponentModel = function (componentModel) { - return this._componentsMap[componentModel.__viewId]; - }; - /** - * Get view of corresponding series model - */ + ECharts.prototype.getViewOfComponentModel = function (componentModel) { + return this._componentsMap[componentModel.__viewId]; + }; + /** + * Get view of corresponding series model + */ - ECharts.prototype.getViewOfSeriesModel = function (seriesModel) { - return this._chartsMap[seriesModel.__viewId]; - }; + ECharts.prototype.getViewOfSeriesModel = function (seriesModel) { + return this._chartsMap[seriesModel.__viewId]; + }; - ECharts.prototype._initEvents = function () { - var _this = this; + ECharts.prototype._initEvents = function () { + var _this = this; - each(MOUSE_EVENT_NAMES, function (eveName) { - var handler = function (e) { - var ecModel = _this.getModel(); + each(MOUSE_EVENT_NAMES, function (eveName) { + var handler = function (e) { + var ecModel = _this.getModel(); - var el = e.target; - var params; - var isGlobalOut = eveName === 'globalout'; // no e.target when 'globalout'. + var el = e.target; + var params; + var isGlobalOut = eveName === 'globalout'; // no e.target when 'globalout'. - if (isGlobalOut) { - params = {}; - } else { - el && findEventDispatcher(el, function (parent) { - var ecData = getECData(parent); - - if (ecData && ecData.dataIndex != null) { - var dataModel = ecData.dataModel || ecModel.getSeriesByIndex(ecData.seriesIndex); - params = dataModel && dataModel.getDataParams(ecData.dataIndex, ecData.dataType) || {}; - return true; - } // If element has custom eventData of components - else if (ecData.eventData) { + if (isGlobalOut) { + params = {}; + } else { + el && findEventDispatcher(el, function (parent) { + var ecData = getECData(parent); + + if (ecData && ecData.dataIndex != null) { + var dataModel = ecData.dataModel || ecModel.getSeriesByIndex(ecData.seriesIndex); + params = dataModel && dataModel.getDataParams(ecData.dataIndex, ecData.dataType) || {}; + return true; + } // If element has custom eventData of components + else if (ecData.eventData) { params = extend({}, ecData.eventData); return true; } - }, true); - } // Contract: if params prepared in mouse event, - // these properties must be specified: - // { - // componentType: string (component main type) - // componentIndex: number - // } - // Otherwise event query can not work. - - - if (params) { - var componentType = params.componentType; - var componentIndex = params.componentIndex; // Special handling for historic reason: when trigger by - // markLine/markPoint/markArea, the componentType is - // 'markLine'/'markPoint'/'markArea', but we should better - // enable them to be queried by seriesIndex, since their - // option is set in each series. - - if (componentType === 'markLine' || componentType === 'markPoint' || componentType === 'markArea') { - componentType = 'series'; - componentIndex = params.seriesIndex; - } - - var model = componentType && componentIndex != null && ecModel.getComponent(componentType, componentIndex); - var view = model && _this[model.mainType === 'series' ? '_chartsMap' : '_componentsMap'][model.__viewId]; - - if (process.env.NODE_ENV !== 'production') { - // `event.componentType` and `event[componentTpype + 'Index']` must not - // be missed, otherwise there is no way to distinguish source component. - // See `dataFormat.getDataParams`. - if (!isGlobalOut && !(model && view)) { - console.warn('model or view can not be found by params'); + }, true); + } // Contract: if params prepared in mouse event, + // these properties must be specified: + // { + // componentType: string (component main type) + // componentIndex: number + // } + // Otherwise event query can not work. + + + if (params) { + var componentType = params.componentType; + var componentIndex = params.componentIndex; // Special handling for historic reason: when trigger by + // markLine/markPoint/markArea, the componentType is + // 'markLine'/'markPoint'/'markArea', but we should better + // enable them to be queried by seriesIndex, since their + // option is set in each series. + + if (componentType === 'markLine' || componentType === 'markPoint' || componentType === 'markArea') { + componentType = 'series'; + componentIndex = params.seriesIndex; } - } - params.event = e; - params.type = eveName; - _this._$eventProcessor.eventInfo = { - targetEl: el, - packedEvent: params, - model: model, - view: view - }; + var model = componentType && componentIndex != null && ecModel.getComponent(componentType, componentIndex); + var view = model && _this[model.mainType === 'series' ? '_chartsMap' : '_componentsMap'][model.__viewId]; - _this.trigger(eveName, params); - } - }; // Consider that some component (like tooltip, brush, ...) - // register zr event handler, but user event handler might - // do anything, such as call `setOption` or `dispatchAction`, - // which probably update any of the content and probably - // cause problem if it is called previous other inner handlers. + if (process.env.NODE_ENV !== 'production') { + // `event.componentType` and `event[componentTpype + 'Index']` must not + // be missed, otherwise there is no way to distinguish source component. + // See `dataFormat.getDataParams`. + if (!isGlobalOut && !(model && view)) { + console.warn('model or view can not be found by params'); + } + } + params.event = e; + params.type = eveName; + _this._$eventProcessor.eventInfo = { + targetEl: el, + packedEvent: params, + model: model, + view: view + }; - handler.zrEventfulCallAtLast = true; + _this.trigger(eveName, params); + } + }; // Consider that some component (like tooltip, brush, ...) + // register zr event handler, but user event handler might + // do anything, such as call `setOption` or `dispatchAction`, + // which probably update any of the content and probably + // cause problem if it is called previous other inner handlers. - _this._zr.on(eveName, handler, _this); - }); - each(eventActionMap, function (actionType, eventType) { - _this._messageCenter.on(eventType, function (event) { - this.trigger(eventType, event); - }, _this); - }); // Extra events - // TODO register? - - each(['selectchanged'], function (eventType) { - _this._messageCenter.on(eventType, function (event) { - this.trigger(eventType, event); - }, _this); - }); - handleLegacySelectEvents(this._messageCenter, this, this._api); - }; - ECharts.prototype.isDisposed = function () { - return this._disposed; - }; + handler.zrEventfulCallAtLast = true; - ECharts.prototype.clear = function () { - if (this._disposed) { - disposedWarning(this.id); - return; - } + _this._zr.on(eveName, handler, _this); + }); + each(eventActionMap, function (actionType, eventType) { + _this._messageCenter.on(eventType, function (event) { + this.trigger(eventType, event); + }, _this); + }); // Extra events + // TODO register? + + each(['selectchanged'], function (eventType) { + _this._messageCenter.on(eventType, function (event) { + this.trigger(eventType, event); + }, _this); + }); + handleLegacySelectEvents(this._messageCenter, this, this._api); + }; - this.setOption({ - series: [] - }, true); - }; + ECharts.prototype.isDisposed = function () { + return this._disposed; + }; - ECharts.prototype.dispose = function () { - if (this._disposed) { - disposedWarning(this.id); - return; - } + ECharts.prototype.clear = function () { + if (this._disposed) { + disposedWarning(this.id); + return; + } - this._disposed = true; - modelUtil.setAttribute(this.getDom(), DOM_ATTRIBUTE_KEY, ''); - var chart = this; - var api = chart._api; - var ecModel = chart._model; - each(chart._componentsViews, function (component) { - component.dispose(ecModel, api); - }); - each(chart._chartsViews, function (chart) { - chart.dispose(ecModel, api); - }); // Dispose after all views disposed + this.setOption({ + series: [] + }, true); + }; - chart._zr.dispose(); // Set properties to null. - // To reduce the memory cost in case the top code still holds this instance unexpectedly. + ECharts.prototype.dispose = function () { + if (this._disposed) { + disposedWarning(this.id); + return; + } + this._disposed = true; + modelUtil.setAttribute(this.getDom(), DOM_ATTRIBUTE_KEY, ''); + var chart = this; + var api = chart._api; + var ecModel = chart._model; + each(chart._componentsViews, function (component) { + component.dispose(ecModel, api); + }); + each(chart._chartsViews, function (chart) { + chart.dispose(ecModel, api); + }); // Dispose after all views disposed - chart._dom = chart._model = chart._chartsMap = chart._componentsMap = chart._chartsViews = chart._componentsViews = chart._scheduler = chart._api = chart._zr = chart._throttledZrFlush = chart._theme = chart._coordSysMgr = chart._messageCenter = null; - delete instances[chart.id]; - }; - /** - * Resize the chart - */ + chart._zr.dispose(); // Set properties to null. + // To reduce the memory cost in case the top code still holds this instance unexpectedly. - ECharts.prototype.resize = function (opts) { - if (process.env.NODE_ENV !== 'production') { - assert(!this[IN_MAIN_PROCESS_KEY], '`resize` should not be called during main process.'); - } + chart._dom = chart._model = chart._chartsMap = chart._componentsMap = chart._chartsViews = chart._componentsViews = chart._scheduler = chart._api = chart._zr = chart._throttledZrFlush = chart._theme = chart._coordSysMgr = chart._messageCenter = null; + delete instances[chart.id]; + }; + /** + * Resize the chart + */ - if (this._disposed) { - disposedWarning(this.id); - return; - } - this._zr.resize(opts); + ECharts.prototype.resize = function (opts) { + if (process.env.NODE_ENV !== 'production') { + assert(!this[IN_MAIN_PROCESS_KEY], '`resize` should not be called during main process.'); + } - var ecModel = this._model; // Resize loading effect + if (this._disposed) { + disposedWarning(this.id); + return; + } - this._loadingFX && this._loadingFX.resize(); + this._zr.resize(opts); - if (!ecModel) { - return; - } + var ecModel = this._model; // Resize loading effect - var needPrepare = ecModel.resetOption('media'); - var silent = opts && opts.silent; // There is some real cases that: - // chart.setOption(option, { lazyUpdate: true }); - // chart.resize(); + this._loadingFX && this._loadingFX.resize(); - if (this[PENDING_UPDATE]) { - if (silent == null) { - silent = this[PENDING_UPDATE].silent; + if (!ecModel) { + return; } - needPrepare = true; - this[PENDING_UPDATE] = null; - } + var needPrepare = ecModel.resetOption('media'); + var silent = opts && opts.silent; // There is some real cases that: + // chart.setOption(option, { lazyUpdate: true }); + // chart.resize(); - this[IN_MAIN_PROCESS_KEY] = true; - needPrepare && prepare(this); - updateMethods.update.call(this, { - type: 'resize', - animation: extend({ - // Disable animation - duration: 0 - }, opts && opts.animation) - }); - this[IN_MAIN_PROCESS_KEY] = false; - flushPendingActions.call(this, silent); - triggerUpdatedEvent.call(this, silent); - }; + if (this[PENDING_UPDATE]) { + if (silent == null) { + silent = this[PENDING_UPDATE].silent; + } - ECharts.prototype.showLoading = function (name, cfg) { - if (this._disposed) { - disposedWarning(this.id); - return; - } + needPrepare = true; + this[PENDING_UPDATE] = null; + } - if (isObject(name)) { - cfg = name; - name = ''; - } + this[IN_MAIN_PROCESS_KEY] = true; + needPrepare && prepare(this); + updateMethods.update.call(this, { + type: 'resize', + animation: extend({ + // Disable animation + duration: 0 + }, opts && opts.animation) + }); + this[IN_MAIN_PROCESS_KEY] = false; + flushPendingActions.call(this, silent); + triggerUpdatedEvent.call(this, silent); + }; - name = name || 'default'; - this.hideLoading(); + ECharts.prototype.showLoading = function (name, cfg) { + if (this._disposed) { + disposedWarning(this.id); + return; + } - if (!loadingEffects[name]) { - if (process.env.NODE_ENV !== 'production') { - console.warn('Loading effects ' + name + ' not exists.'); + if (isObject(name)) { + cfg = name; + name = ''; } - return; - } + name = name || 'default'; + this.hideLoading(); - var el = loadingEffects[name](this._api, cfg); - var zr = this._zr; - this._loadingFX = el; - zr.add(el); - }; - /** - * Hide loading effect - */ + if (!loadingEffects[name]) { + if (process.env.NODE_ENV !== 'production') { + console.warn('Loading effects ' + name + ' not exists.'); + } + return; + } - ECharts.prototype.hideLoading = function () { - if (this._disposed) { - disposedWarning(this.id); - return; - } + var el = loadingEffects[name](this._api, cfg); + var zr = this._zr; + this._loadingFX = el; + zr.add(el); + }; + /** + * Hide loading effect + */ - this._loadingFX && this._zr.remove(this._loadingFX); - this._loadingFX = null; - }; - ECharts.prototype.makeActionFromEvent = function (eventObj) { - var payload = extend({}, eventObj); - payload.type = eventActionMap[eventObj.type]; - return payload; - }; - /** - * @param opt If pass boolean, means opt.silent - * @param opt.silent Default `false`. Whether trigger events. - * @param opt.flush Default `undefined`. - * true: Flush immediately, and then pixel in canvas can be fetched - * immediately. Caution: it might affect performance. - * false: Not flush. - * undefined: Auto decide whether perform flush. - */ - - - ECharts.prototype.dispatchAction = function (payload, opt) { - if (this._disposed) { - disposedWarning(this.id); - return; - } + ECharts.prototype.hideLoading = function () { + if (this._disposed) { + disposedWarning(this.id); + return; + } - if (!isObject(opt)) { - opt = { - silent: !!opt - }; - } + this._loadingFX && this._zr.remove(this._loadingFX); + this._loadingFX = null; + }; - if (!actions[payload.type]) { - return; - } // Avoid dispatch action before setOption. Especially in `connect`. + ECharts.prototype.makeActionFromEvent = function (eventObj) { + var payload = extend({}, eventObj); + payload.type = eventActionMap[eventObj.type]; + return payload; + }; + /** + * @param opt If pass boolean, means opt.silent + * @param opt.silent Default `false`. Whether trigger events. + * @param opt.flush Default `undefined`. + * true: Flush immediately, and then pixel in canvas can be fetched + * immediately. Caution: it might affect performance. + * false: Not flush. + * undefined: Auto decide whether perform flush. + */ - if (!this._model) { - return; - } // May dispatchAction in rendering procedure + ECharts.prototype.dispatchAction = function (payload, opt) { + if (this._disposed) { + disposedWarning(this.id); + return; + } + if (!isObject(opt)) { + opt = { + silent: !!opt + }; + } - if (this[IN_MAIN_PROCESS_KEY]) { - this._pendingActions.push(payload); + if (!actions[payload.type]) { + return; + } // Avoid dispatch action before setOption. Especially in `connect`. - return; - } - var silent = opt.silent; - doDispatchAction.call(this, payload, silent); - var flush = opt.flush; - - if (flush) { - this._zr.flush(); - } else if (flush !== false && env.browser.weChat) { - // In WeChat embeded browser, `requestAnimationFrame` and `setInterval` - // hang when sliding page (on touch event), which cause that zr does not - // refresh util user interaction finished, which is not expected. - // But `dispatchAction` may be called too frequently when pan on touch - // screen, which impacts performance if do not throttle them. - this._throttledZrFlush(); - } + if (!this._model) { + return; + } // May dispatchAction in rendering procedure - flushPendingActions.call(this, silent); - triggerUpdatedEvent.call(this, silent); - }; - ECharts.prototype.updateLabelLayout = function () { - lifecycle.trigger('series:layoutlabels', this._model, this._api, { - // Not adding series labels. - // TODO - updatedSeries: [] - }); - }; + if (this[IN_MAIN_PROCESS_KEY]) { + this._pendingActions.push(payload); - ECharts.prototype.appendData = function (params) { - if (this._disposed) { - disposedWarning(this.id); - return; - } + return; + } - var seriesIndex = params.seriesIndex; - var ecModel = this.getModel(); - var seriesModel = ecModel.getSeriesByIndex(seriesIndex); + var silent = opt.silent; + doDispatchAction.call(this, payload, silent); + var flush = opt.flush; + + if (flush) { + this._zr.flush(); + } else if (flush !== false && env.browser.weChat) { + // In WeChat embeded browser, `requestAnimationFrame` and `setInterval` + // hang when sliding page (on touch event), which cause that zr does not + // refresh util user interaction finished, which is not expected. + // But `dispatchAction` may be called too frequently when pan on touch + // screen, which impacts performance if do not throttle them. + this._throttledZrFlush(); + } - if (process.env.NODE_ENV !== 'production') { - assert(params.data && seriesModel); - } + flushPendingActions.call(this, silent); + triggerUpdatedEvent.call(this, silent); + }; - seriesModel.appendData(params); // Note: `appendData` does not support that update extent of coordinate - // system, util some scenario require that. In the expected usage of - // `appendData`, the initial extent of coordinate system should better - // be fixed by axis `min`/`max` setting or initial data, otherwise if - // the extent changed while `appendData`, the location of the painted - // graphic elements have to be changed, which make the usage of - // `appendData` meaningless. - - this._scheduler.unfinished = true; - this.getZr().wakeUp(); - }; // A work around for no `internal` modifier in ts yet but - // need to strictly hide private methods to JS users. - - - ECharts.internalField = function () { - prepare = function (ecIns) { - var scheduler = ecIns._scheduler; - scheduler.restorePipelines(ecIns._model); - scheduler.prepareStageTasks(); - prepareView(ecIns, true); - prepareView(ecIns, false); - scheduler.plan(); + ECharts.prototype.updateLabelLayout = function () { + lifecycle.trigger('series:layoutlabels', this._model, this._api, { + // Not adding series labels. + // TODO + updatedSeries: [] + }); }; - /** - * Prepare view instances of charts and components - */ + ECharts.prototype.appendData = function (params) { + if (this._disposed) { + disposedWarning(this.id); + return; + } - prepareView = function (ecIns, isComponent) { - var ecModel = ecIns._model; - var scheduler = ecIns._scheduler; - var viewList = isComponent ? ecIns._componentsViews : ecIns._chartsViews; - var viewMap = isComponent ? ecIns._componentsMap : ecIns._chartsMap; - var zr = ecIns._zr; - var api = ecIns._api; + var seriesIndex = params.seriesIndex; + var ecModel = this.getModel(); + var seriesModel = ecModel.getSeriesByIndex(seriesIndex); - for (var i = 0; i < viewList.length; i++) { - viewList[i].__alive = false; + if (process.env.NODE_ENV !== 'production') { + assert(params.data && seriesModel); } - isComponent ? ecModel.eachComponent(function (componentType, model) { - componentType !== 'series' && doPrepare(model); - }) : ecModel.eachSeries(doPrepare); - - function doPrepare(model) { - // By defaut view will be reused if possible for the case that `setOption` with "notMerge" - // mode and need to enable transition animation. (Usually, when they have the same id, or - // especially no id but have the same type & name & index. See the `model.id` generation - // rule in `makeIdAndName` and `viewId` generation rule here). - // But in `replaceMerge` mode, this feature should be able to disabled when it is clear that - // the new model has nothing to do with the old model. - var requireNewView = model.__requireNewView; // This command should not work twice. - - model.__requireNewView = false; // Consider: id same and type changed. - - var viewId = '_ec_' + model.id + '_' + model.type; - var view = !requireNewView && viewMap[viewId]; - - if (!view) { - var classType = parseClassType(model.type); - var Clazz = isComponent ? ComponentView.getClass(classType.main, classType.sub) : // FIXME:TS - // (ChartView as ChartViewConstructor).getClass('series', classType.sub) - // For backward compat, still support a chart type declared as only subType - // like "liquidfill", but recommend "series.liquidfill" - // But need a base class to make a type series. - ChartView.getClass(classType.sub); - - if (process.env.NODE_ENV !== 'production') { - assert(Clazz, classType.sub + ' does not exist.'); - } + seriesModel.appendData(params); // Note: `appendData` does not support that update extent of coordinate + // system, util some scenario require that. In the expected usage of + // `appendData`, the initial extent of coordinate system should better + // be fixed by axis `min`/`max` setting or initial data, otherwise if + // the extent changed while `appendData`, the location of the painted + // graphic elements have to be changed, which make the usage of + // `appendData` meaningless. - view = new Clazz(); - view.init(ecModel, api); - viewMap[viewId] = view; - viewList.push(view); - zr.add(view.group); - } + this._scheduler.unfinished = true; + this.getZr().wakeUp(); + }; // A work around for no `internal` modifier in ts yet but + // need to strictly hide private methods to JS users. + + + ECharts.internalField = function () { + prepare = function (ecIns) { + var scheduler = ecIns._scheduler; + scheduler.restorePipelines(ecIns._model); + scheduler.prepareStageTasks(); + prepareView(ecIns, true); + prepareView(ecIns, false); + scheduler.plan(); + }; + /** + * Prepare view instances of charts and components + */ - model.__viewId = view.__id = viewId; - view.__alive = true; - view.__model = model; - view.group.__ecComponentInfo = { - mainType: model.mainType, - index: model.componentIndex - }; - !isComponent && scheduler.prepareView(view, model, ecModel, api); - } - for (var i = 0; i < viewList.length;) { - var view = viewList[i]; + prepareView = function (ecIns, isComponent) { + var ecModel = ecIns._model; + var scheduler = ecIns._scheduler; + var viewList = isComponent ? ecIns._componentsViews : ecIns._chartsViews; + var viewMap = isComponent ? ecIns._componentsMap : ecIns._chartsMap; + var zr = ecIns._zr; + var api = ecIns._api; + + for (var i = 0; i < viewList.length; i++) { + viewList[i].__alive = false; + } + + isComponent ? ecModel.eachComponent(function (componentType, model) { + componentType !== 'series' && doPrepare(model); + }) : ecModel.eachSeries(doPrepare); + + function doPrepare(model) { + // By defaut view will be reused if possible for the case that `setOption` with "notMerge" + // mode and need to enable transition animation. (Usually, when they have the same id, or + // especially no id but have the same type & name & index. See the `model.id` generation + // rule in `makeIdAndName` and `viewId` generation rule here). + // But in `replaceMerge` mode, this feature should be able to disabled when it is clear that + // the new model has nothing to do with the old model. + var requireNewView = model.__requireNewView; // This command should not work twice. + + model.__requireNewView = false; // Consider: id same and type changed. + + var viewId = '_ec_' + model.id + '_' + model.type; + var view = !requireNewView && viewMap[viewId]; + + if (!view) { + var classType = parseClassType(model.type); + var Clazz = isComponent ? ComponentView.getClass(classType.main, classType.sub) : // FIXME:TS + // (ChartView as ChartViewConstructor).getClass('series', classType.sub) + // For backward compat, still support a chart type declared as only subType + // like "liquidfill", but recommend "series.liquidfill" + // But need a base class to make a type series. + ChartView.getClass(classType.sub); - if (!view.__alive) { - !isComponent && view.renderTask.dispose(); - zr.remove(view.group); - view.dispose(ecModel, api); - viewList.splice(i, 1); + if (process.env.NODE_ENV !== 'production') { + assert(Clazz, classType.sub + ' does not exist.'); + } - if (viewMap[view.__id] === view) { - delete viewMap[view.__id]; + view = new Clazz(); + view.init(ecModel, api); + viewMap[viewId] = view; + viewList.push(view); + zr.add(view.group); } - view.__id = view.group.__ecComponentInfo = null; - } else { - i++; + model.__viewId = view.__id = viewId; + view.__alive = true; + view.__model = model; + view.group.__ecComponentInfo = { + mainType: model.mainType, + index: model.componentIndex + }; + !isComponent && scheduler.prepareView(view, model, ecModel, api); } - } - }; - updateDirectly = function (ecIns, method, payload, mainType, subType) { - var ecModel = ecIns._model; - ecModel.setUpdatePayload(payload); // broadcast + for (var i = 0; i < viewList.length;) { + var view = viewList[i]; - if (!mainType) { - // FIXME - // Chart will not be update directly here, except set dirty. - // But there is no such scenario now. - each([].concat(ecIns._componentsViews).concat(ecIns._chartsViews), callView); - return; - } + if (!view.__alive) { + !isComponent && view.renderTask.dispose(); + zr.remove(view.group); + view.dispose(ecModel, api); + viewList.splice(i, 1); - var query = {}; - query[mainType + 'Id'] = payload[mainType + 'Id']; - query[mainType + 'Index'] = payload[mainType + 'Index']; - query[mainType + 'Name'] = payload[mainType + 'Name']; - var condition = { - mainType: mainType, - query: query - }; - subType && (condition.subType = subType); // subType may be '' by parseClassType; + if (viewMap[view.__id] === view) { + delete viewMap[view.__id]; + } - var excludeSeriesId = payload.excludeSeriesId; - var excludeSeriesIdMap; + view.__id = view.group.__ecComponentInfo = null; + } else { + i++; + } + } + }; - if (excludeSeriesId != null) { - excludeSeriesIdMap = createHashMap(); - each(modelUtil.normalizeToArray(excludeSeriesId), function (id) { - var modelId = modelUtil.convertOptionIdName(id, null); + updateDirectly = function (ecIns, method, payload, mainType, subType) { + var ecModel = ecIns._model; + ecModel.setUpdatePayload(payload); // broadcast - if (modelId != null) { - excludeSeriesIdMap.set(modelId, true); - } - }); - } + if (!mainType) { + // FIXME + // Chart will not be update directly here, except set dirty. + // But there is no such scenario now. + each([].concat(ecIns._componentsViews).concat(ecIns._chartsViews), callView); + return; + } - if (isHighDownPayload(payload)) { - allLeaveBlur(ecIns._api); - } // If dispatchAction before setOption, do nothing. + var query = {}; + query[mainType + 'Id'] = payload[mainType + 'Id']; + query[mainType + 'Index'] = payload[mainType + 'Index']; + query[mainType + 'Name'] = payload[mainType + 'Name']; + var condition = { + mainType: mainType, + query: query + }; + subType && (condition.subType = subType); // subType may be '' by parseClassType; + var excludeSeriesId = payload.excludeSeriesId; + var excludeSeriesIdMap; - ecModel && ecModel.eachComponent(condition, function (model) { - var isExcluded = excludeSeriesIdMap && excludeSeriesIdMap.get(model.id) !== null; + if (excludeSeriesId != null) { + excludeSeriesIdMap = createHashMap(); + each(modelUtil.normalizeToArray(excludeSeriesId), function (id) { + var modelId = modelUtil.convertOptionIdName(id, null); - if (isExcluded) { - return; + if (modelId != null) { + excludeSeriesIdMap.set(modelId, true); + } + }); } - ; - if (isHighDownPayload(payload)) { - if (model instanceof SeriesModel) { - if (payload.type === HIGHLIGHT_ACTION_TYPE && !payload.notBlur) { - blurSeriesFromHighlightPayload(model, payload, ecIns._api); - } - } else { - var _a = findComponentHighDownDispatchers(model.mainType, model.componentIndex, payload.name, ecIns._api), - focusSelf = _a.focusSelf, - dispatchers = _a.dispatchers; + allLeaveBlur(ecIns._api); + } // If dispatchAction before setOption, do nothing. - if (payload.type === HIGHLIGHT_ACTION_TYPE && focusSelf && !payload.notBlur) { - blurComponent(model.mainType, model.componentIndex, ecIns._api); - } // PENDING: - // Whether to put this "enter emphasis" code in `ComponentView`, - // which will be the same as `ChartView` but might be not necessary - // and will be far from this logic. + ecModel && ecModel.eachComponent(condition, function (model) { + var isExcluded = excludeSeriesIdMap && excludeSeriesIdMap.get(model.id) !== null; - if (dispatchers) { - each(dispatchers, function (dispatcher) { - payload.type === HIGHLIGHT_ACTION_TYPE ? enterEmphasis(dispatcher) : leaveEmphasis(dispatcher); - }); - } - } - } else if (isSelectChangePayload(payload)) { - // TODO geo - if (model instanceof SeriesModel) { - toggleSelectionFromPayload(model, payload, ecIns._api); - updateSeriesElementSelection(model); - markStatusToUpdate(ecIns); + if (isExcluded) { + return; } - } - }, ecIns); - ecModel && ecModel.eachComponent(condition, function (model) { - var isExcluded = excludeSeriesIdMap && excludeSeriesIdMap.get(model.id) !== null; - - if (isExcluded) { - return; - } - ; - callView(ecIns[mainType === 'series' ? '_chartsMap' : '_componentsMap'][model.__viewId]); - }, ecIns); + ; - function callView(view) { - view && view.__alive && view[method] && view[method](view.__model, ecModel, ecIns._api, payload); - } - }; + if (isHighDownPayload(payload)) { + if (model instanceof SeriesModel) { + if (payload.type === HIGHLIGHT_ACTION_TYPE && !payload.notBlur) { + blurSeriesFromHighlightPayload(model, payload, ecIns._api); + } + } else { + var _a = findComponentHighDownDispatchers(model.mainType, model.componentIndex, payload.name, ecIns._api), + focusSelf = _a.focusSelf, + dispatchers = _a.dispatchers; - updateMethods = { - prepareAndUpdate: function (payload) { - prepare(this); - updateMethods.update.call(this, payload, { - // Needs to mark option changed if newOption is given. - // It's from MagicType. - // TODO If use a separate flag optionChanged in payload? - optionChanged: payload.newOption != null - }); - }, - update: function (payload, updateParams) { - var ecModel = this._model; - var api = this._api; - var zr = this._zr; - var coordSysMgr = this._coordSysMgr; - var scheduler = this._scheduler; // update before setOption + if (payload.type === HIGHLIGHT_ACTION_TYPE && focusSelf && !payload.notBlur) { + blurComponent(model.mainType, model.componentIndex, ecIns._api); + } // PENDING: + // Whether to put this "enter emphasis" code in `ComponentView`, + // which will be the same as `ChartView` but might be not necessary + // and will be far from this logic. - if (!ecModel) { - return; - } - ecModel.setUpdatePayload(payload); - scheduler.restoreData(ecModel, payload); - scheduler.performSeriesTasks(ecModel); // 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(ecModel, api); - scheduler.performDataProcessorTasks(ecModel, payload); // Current stream render is not supported in data process. So we can update - // stream modes after data processing, where the filtered data is used to - // deteming whether use progressive rendering. - - updateStreamModes(this, ecModel); // We update stream modes before coordinate system updated, then the modes info - // can be fetched when coord sys updating (consider the barGrid extent fix). But - // the drawback is the full coord info can not be fetched. Fortunately this full - // coord is not requied in stream mode updater currently. - - coordSysMgr.update(ecModel, api); - clearColorPalette(ecModel); - scheduler.performVisualTasks(ecModel, payload); - render(this, ecModel, api, payload, updateParams); // Set background - - var backgroundColor = ecModel.get('backgroundColor') || 'transparent'; - var darkMode = ecModel.get('darkMode'); // In IE8 - - if (!env.canvasSupported) { - var colorArr = colorTool.parse(backgroundColor); - backgroundColor = colorTool.stringify(colorArr, 'rgb'); - - if (colorArr[3] === 0) { - backgroundColor = 'transparent'; + if (dispatchers) { + each(dispatchers, function (dispatcher) { + payload.type === HIGHLIGHT_ACTION_TYPE ? enterEmphasis(dispatcher) : leaveEmphasis(dispatcher); + }); + } + } + } else if (isSelectChangePayload(payload)) { + // TODO geo + if (model instanceof SeriesModel) { + toggleSelectionFromPayload(model, payload, ecIns._api); + updateSeriesElementSelection(model); + markStatusToUpdate(ecIns); + } } - } else { - zr.setBackgroundColor(backgroundColor); // Force set dark mode. + }, ecIns); + ecModel && ecModel.eachComponent(condition, function (model) { + var isExcluded = excludeSeriesIdMap && excludeSeriesIdMap.get(model.id) !== null; - if (darkMode != null && darkMode !== 'auto') { - zr.setDarkMode(darkMode); + if (isExcluded) { + return; } - } - lifecycle.trigger('afterupdate', ecModel, api); - }, - updateTransform: function (payload) { - var _this = this; + ; + callView(ecIns[mainType === 'series' ? '_chartsMap' : '_componentsMap'][model.__viewId]); + }, ecIns); - var ecModel = this._model; - var api = this._api; // update before setOption - - if (!ecModel) { - return; + function callView(view) { + view && view.__alive && view[method] && view[method](view.__model, ecModel, ecIns._api, payload); } + }; - ecModel.setUpdatePayload(payload); // ChartView.markUpdateMethod(payload, 'updateTransform'); - - var componentDirtyList = []; - ecModel.eachComponent(function (componentType, componentModel) { - if (componentType === 'series') { + updateMethods = { + prepareAndUpdate: function (payload) { + prepare(this); + updateMethods.update.call(this, payload, { + // Needs to mark option changed if newOption is given. + // It's from MagicType. + // TODO If use a separate flag optionChanged in payload? + optionChanged: payload.newOption != null + }); + }, + update: function (payload, updateParams) { + var ecModel = this._model; + var api = this._api; + var zr = this._zr; + var coordSysMgr = this._coordSysMgr; + var scheduler = this._scheduler; // update before setOption + + if (!ecModel) { return; } - var componentView = _this.getViewOfComponentModel(componentModel); + ecModel.setUpdatePayload(payload); + scheduler.restoreData(ecModel, payload); + scheduler.performSeriesTasks(ecModel); // 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(ecModel, api); + scheduler.performDataProcessorTasks(ecModel, payload); // Current stream render is not supported in data process. So we can update + // stream modes after data processing, where the filtered data is used to + // deteming whether use progressive rendering. + + updateStreamModes(this, ecModel); // We update stream modes before coordinate system updated, then the modes info + // can be fetched when coord sys updating (consider the barGrid extent fix). But + // the drawback is the full coord info can not be fetched. Fortunately this full + // coord is not requied in stream mode updater currently. + + coordSysMgr.update(ecModel, api); + clearColorPalette(ecModel); + scheduler.performVisualTasks(ecModel, payload); + render(this, ecModel, api, payload, updateParams); // Set background + + var backgroundColor = ecModel.get('backgroundColor') || 'transparent'; + var darkMode = ecModel.get('darkMode'); // In IE8 + + if (!env.canvasSupported) { + var colorArr = colorTool.parse(backgroundColor); + backgroundColor = colorTool.stringify(colorArr, 'rgb'); + + if (colorArr[3] === 0) { + backgroundColor = 'transparent'; + } + } else { + zr.setBackgroundColor(backgroundColor); // Force set dark mode. - if (componentView && componentView.__alive) { - if (componentView.updateTransform) { - var result = componentView.updateTransform(componentModel, ecModel, api, payload); - result && result.update && componentDirtyList.push(componentView); - } else { - componentDirtyList.push(componentView); + if (darkMode != null && darkMode !== 'auto') { + zr.setDarkMode(darkMode); } } - }); - var seriesDirtyMap = createHashMap(); - ecModel.eachSeries(function (seriesModel) { - var chartView = _this._chartsMap[seriesModel.__viewId]; - if (chartView.updateTransform) { - var result = chartView.updateTransform(seriesModel, ecModel, api, payload); - result && result.update && seriesDirtyMap.set(seriesModel.uid, 1); - } else { - seriesDirtyMap.set(seriesModel.uid, 1); - } - }); - clearColorPalette(ecModel); // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline. - // this._scheduler.performVisualTasks(ecModel, payload, 'layout', true); + lifecycle.trigger('afterupdate', ecModel, api); + }, + updateTransform: function (payload) { + var _this = this; - this._scheduler.performVisualTasks(ecModel, payload, { - setDirty: true, - dirtyMap: seriesDirtyMap - }); // Currently, not call render of components. Geo render cost a lot. - // renderComponents(ecIns, ecModel, api, payload, componentDirtyList); + var ecModel = this._model; + var api = this._api; // update before setOption + if (!ecModel) { + return; + } - renderSeries(this, ecModel, api, payload, {}, seriesDirtyMap); - lifecycle.trigger('afterupdate', ecModel, api); - }, - updateView: function (payload) { - var ecModel = this._model; // update before setOption + ecModel.setUpdatePayload(payload); // ChartView.markUpdateMethod(payload, 'updateTransform'); - if (!ecModel) { - return; - } + var componentDirtyList = []; + ecModel.eachComponent(function (componentType, componentModel) { + if (componentType === 'series') { + return; + } - ecModel.setUpdatePayload(payload); - ChartView.markUpdateMethod(payload, 'updateView'); - clearColorPalette(ecModel); // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline. + var componentView = _this.getViewOfComponentModel(componentModel); - this._scheduler.performVisualTasks(ecModel, payload, { - setDirty: true - }); + if (componentView && componentView.__alive) { + if (componentView.updateTransform) { + var result = componentView.updateTransform(componentModel, ecModel, api, payload); + result && result.update && componentDirtyList.push(componentView); + } else { + componentDirtyList.push(componentView); + } + } + }); + var seriesDirtyMap = createHashMap(); + ecModel.eachSeries(function (seriesModel) { + var chartView = _this._chartsMap[seriesModel.__viewId]; - render(this, ecModel, this._api, payload, {}); - lifecycle.trigger('afterupdate', ecModel, this._api); - }, - updateVisual: function (payload) { - // updateMethods.update.call(this, payload); - var _this = this; + if (chartView.updateTransform) { + var result = chartView.updateTransform(seriesModel, ecModel, api, payload); + result && result.update && seriesDirtyMap.set(seriesModel.uid, 1); + } else { + seriesDirtyMap.set(seriesModel.uid, 1); + } + }); + clearColorPalette(ecModel); // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline. + // this._scheduler.performVisualTasks(ecModel, payload, 'layout', true); - var ecModel = this._model; // update before setOption + this._scheduler.performVisualTasks(ecModel, payload, { + setDirty: true, + dirtyMap: seriesDirtyMap + }); // Currently, not call render of components. Geo render cost a lot. + // renderComponents(ecIns, ecModel, api, payload, componentDirtyList); - if (!ecModel) { - return; - } - ecModel.setUpdatePayload(payload); // clear all visual + renderSeries(this, ecModel, api, payload, {}, seriesDirtyMap); + lifecycle.trigger('afterupdate', ecModel, api); + }, + updateView: function (payload) { + var ecModel = this._model; // update before setOption - ecModel.eachSeries(function (seriesModel) { - seriesModel.getData().clearAllVisual(); - }); // Perform visual + if (!ecModel) { + return; + } - ChartView.markUpdateMethod(payload, 'updateVisual'); - clearColorPalette(ecModel); // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline. + ecModel.setUpdatePayload(payload); + ChartView.markUpdateMethod(payload, 'updateView'); + clearColorPalette(ecModel); // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline. - this._scheduler.performVisualTasks(ecModel, payload, { - visualType: 'visual', - setDirty: true - }); + this._scheduler.performVisualTasks(ecModel, payload, { + setDirty: true + }); - ecModel.eachComponent(function (componentType, componentModel) { - if (componentType !== 'series') { - var componentView = _this.getViewOfComponentModel(componentModel); + render(this, ecModel, this._api, payload, {}); + lifecycle.trigger('afterupdate', ecModel, this._api); + }, + updateVisual: function (payload) { + // updateMethods.update.call(this, payload); + var _this = this; + + var ecModel = this._model; // update before setOption - componentView && componentView.__alive && componentView.updateVisual(componentModel, ecModel, _this._api, payload); + if (!ecModel) { + return; } - }); - ecModel.eachSeries(function (seriesModel) { - var chartView = _this._chartsMap[seriesModel.__viewId]; - chartView.updateVisual(seriesModel, ecModel, _this._api, payload); - }); - lifecycle.trigger('afterupdate', ecModel, this._api); - }, - updateLayout: function (payload) { - updateMethods.update.call(this, payload); - } - }; - doConvertPixel = function (ecIns, methodName, finder, value) { - if (ecIns._disposed) { - disposedWarning(ecIns.id); - return; - } + ecModel.setUpdatePayload(payload); // clear all visual - var ecModel = ecIns._model; + ecModel.eachSeries(function (seriesModel) { + seriesModel.getData().clearAllVisual(); + }); // Perform visual - var coordSysList = ecIns._coordSysMgr.getCoordinateSystems(); + ChartView.markUpdateMethod(payload, 'updateVisual'); + clearColorPalette(ecModel); // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline. - var result; - var parsedFinder = modelUtil.parseFinder(ecModel, finder); + this._scheduler.performVisualTasks(ecModel, payload, { + visualType: 'visual', + setDirty: true + }); - for (var i = 0; i < coordSysList.length; i++) { - var coordSys = coordSysList[i]; + ecModel.eachComponent(function (componentType, componentModel) { + if (componentType !== 'series') { + var componentView = _this.getViewOfComponentModel(componentModel); - if (coordSys[methodName] && (result = coordSys[methodName](ecModel, parsedFinder, value)) != null) { - return result; + componentView && componentView.__alive && componentView.updateVisual(componentModel, ecModel, _this._api, payload); + } + }); + ecModel.eachSeries(function (seriesModel) { + var chartView = _this._chartsMap[seriesModel.__viewId]; + chartView.updateVisual(seriesModel, ecModel, _this._api, payload); + }); + lifecycle.trigger('afterupdate', ecModel, this._api); + }, + updateLayout: function (payload) { + updateMethods.update.call(this, payload); } - } - - if (process.env.NODE_ENV !== 'production') { - console.warn('No coordinate system that supports ' + methodName + ' found by the given finder.'); - } - }; - - updateStreamModes = function (ecIns, ecModel) { - var chartsMap = ecIns._chartsMap; - var scheduler = ecIns._scheduler; - ecModel.eachSeries(function (seriesModel) { - scheduler.updateStreamModes(seriesModel, chartsMap[seriesModel.__viewId]); - }); - }; + }; - doDispatchAction = function (payload, silent) { - var _this = this; + doConvertPixel = function (ecIns, methodName, finder, value) { + if (ecIns._disposed) { + disposedWarning(ecIns.id); + return; + } - var ecModel = this.getModel(); - var payloadType = payload.type; - var escapeConnect = payload.escapeConnect; - var actionWrap = actions[payloadType]; - var actionInfo = actionWrap.actionInfo; - var cptTypeTmp = (actionInfo.update || 'update').split(':'); - var updateMethod = cptTypeTmp.pop(); - var cptType = cptTypeTmp[0] != null && parseClassType(cptTypeTmp[0]); - this[IN_MAIN_PROCESS_KEY] = true; - var payloads = [payload]; - var batched = false; // Batch action - - if (payload.batch) { - batched = true; - payloads = map(payload.batch, function (item) { - item = defaults(extend({}, item), payload); - item.batch = null; - return item; - }); - } + var ecModel = ecIns._model; - var eventObjBatch = []; - var eventObj; - var isSelectChange = isSelectChangePayload(payload); - var isHighDown = isHighDownPayload(payload); - each(payloads, function (batchItem) { - // Action can specify the event by return it. - eventObj = actionWrap.action(batchItem, _this._model, _this._api); // Emit event outside + var coordSysList = ecIns._coordSysMgr.getCoordinateSystems(); - eventObj = eventObj || extend({}, batchItem); // Convert type to eventType + var result; + var parsedFinder = modelUtil.parseFinder(ecModel, finder); - eventObj.type = actionInfo.event || eventObj.type; - eventObjBatch.push(eventObj); // light update does not perform data process, layout and visual. + for (var i = 0; i < coordSysList.length; i++) { + var coordSys = coordSysList[i]; - if (isHighDown) { - var _a = modelUtil.preParseFinder(payload), - queryOptionMap = _a.queryOptionMap, - mainTypeSpecified = _a.mainTypeSpecified; - - var componentMainType = mainTypeSpecified ? queryOptionMap.keys()[0] : 'series'; - updateDirectly(_this, updateMethod, batchItem, componentMainType); - markStatusToUpdate(_this); - } else if (isSelectChange) { - // At present `dispatchAction({ type: 'select', ... })` is not supported on components. - // geo still use 'geoselect'. - updateDirectly(_this, updateMethod, batchItem, 'series'); - markStatusToUpdate(_this); - } else if (cptType) { - updateDirectly(_this, updateMethod, batchItem, cptType.main, cptType.sub); + if (coordSys[methodName] && (result = coordSys[methodName](ecModel, parsedFinder, value)) != null) { + return result; + } } - }); - if (updateMethod !== 'none' && !isHighDown && !isSelectChange && !cptType) { - // Still dirty - if (this[PENDING_UPDATE]) { - prepare(this); - updateMethods.update.call(this, payload); - this[PENDING_UPDATE] = null; - } else { - updateMethods[updateMethod].call(this, payload); + if (process.env.NODE_ENV !== 'production') { + console.warn('No coordinate system that supports ' + methodName + ' found by the given finder.'); } - } // Follow the rule of action batch - - - if (batched) { - eventObj = { - type: actionInfo.event || payloadType, - escapeConnect: escapeConnect, - batch: eventObjBatch - }; - } else { - eventObj = eventObjBatch[0]; - } + }; - this[IN_MAIN_PROCESS_KEY] = false; + updateStreamModes = function (ecIns, ecModel) { + var chartsMap = ecIns._chartsMap; + var scheduler = ecIns._scheduler; + ecModel.eachSeries(function (seriesModel) { + scheduler.updateStreamModes(seriesModel, chartsMap[seriesModel.__viewId]); + }); + }; - if (!silent) { - var messageCenter = this._messageCenter; - messageCenter.trigger(eventObj.type, eventObj); // Extra triggered 'selectchanged' event + doDispatchAction = function (payload, silent) { + var _this = this; - if (isSelectChange) { - var newObj = { - type: 'selectchanged', - escapeConnect: escapeConnect, - selected: getAllSelectedIndices(ecModel), - isFromClick: payload.isFromClick || false, - fromAction: payload.type, - fromActionPayload: payload - }; - messageCenter.trigger(newObj.type, newObj); + var ecModel = this.getModel(); + var payloadType = payload.type; + var escapeConnect = payload.escapeConnect; + var actionWrap = actions[payloadType]; + var actionInfo = actionWrap.actionInfo; + var cptTypeTmp = (actionInfo.update || 'update').split(':'); + var updateMethod = cptTypeTmp.pop(); + var cptType = cptTypeTmp[0] != null && parseClassType(cptTypeTmp[0]); + this[IN_MAIN_PROCESS_KEY] = true; + var payloads = [payload]; + var batched = false; // Batch action + + if (payload.batch) { + batched = true; + payloads = map(payload.batch, function (item) { + item = defaults(extend({}, item), payload); + item.batch = null; + return item; + }); } - } - }; - flushPendingActions = function (silent) { - var pendingActions = this._pendingActions; + var eventObjBatch = []; + var eventObj; + var isSelectChange = isSelectChangePayload(payload); + var isHighDown = isHighDownPayload(payload); + each(payloads, function (batchItem) { + // Action can specify the event by return it. + eventObj = actionWrap.action(batchItem, _this._model, _this._api); // Emit event outside - while (pendingActions.length) { - var payload = pendingActions.shift(); - doDispatchAction.call(this, payload, silent); - } - }; + eventObj = eventObj || extend({}, batchItem); // Convert type to eventType - triggerUpdatedEvent = function (silent) { - !silent && this.trigger('updated'); - }; - /** - * Event `rendered` is triggered when zr - * rendered. It is useful for realtime - * snapshot (reflect animation). - * - * Event `finished` is triggered when: - * (1) zrender rendering finished. - * (2) initial animation finished. - * (3) progressive rendering finished. - * (4) no pending action. - * (5) no delayed setOption needs to be processed. - */ + eventObj.type = actionInfo.event || eventObj.type; + eventObjBatch.push(eventObj); // light update does not perform data process, layout and visual. + if (isHighDown) { + var _a = modelUtil.preParseFinder(payload), + queryOptionMap = _a.queryOptionMap, + mainTypeSpecified = _a.mainTypeSpecified; - bindRenderedEvent = function (zr, ecIns) { - zr.on('rendered', function (params) { - ecIns.trigger('rendered', params); // The `finished` event should not be triggered repeatly, - // so it should only be triggered when rendering indeed happend - // in zrender. (Consider the case that dipatchAction is keep - // triggering when mouse move). + var componentMainType = mainTypeSpecified ? queryOptionMap.keys()[0] : 'series'; + updateDirectly(_this, updateMethod, batchItem, componentMainType); + markStatusToUpdate(_this); + } else if (isSelectChange) { + // At present `dispatchAction({ type: 'select', ... })` is not supported on components. + // geo still use 'geoselect'. + updateDirectly(_this, updateMethod, batchItem, 'series'); + markStatusToUpdate(_this); + } else if (cptType) { + updateDirectly(_this, updateMethod, batchItem, cptType.main, cptType.sub); + } + }); - if ( // Although zr is dirty if initial animation is not finished - // and this checking is called on frame, we also check - // animation finished for robustness. - zr.animation.isFinished() && !ecIns[PENDING_UPDATE] && !ecIns._scheduler.unfinished && !ecIns._pendingActions.length) { - ecIns.trigger('finished'); - } - }); - }; + if (updateMethod !== 'none' && !isHighDown && !isSelectChange && !cptType) { + // Still dirty + if (this[PENDING_UPDATE]) { + prepare(this); + updateMethods.update.call(this, payload); + this[PENDING_UPDATE] = null; + } else { + updateMethods[updateMethod].call(this, payload); + } + } // Follow the rule of action batch - bindMouseEvent = function (zr, ecIns) { - zr.on('mouseover', function (e) { - var el = e.target; - var dispatcher = findEventDispatcher(el, isHighDownDispatcher); - if (dispatcher) { - handleGlobalMouseOverForHighDown(dispatcher, e, ecIns._api); - markStatusToUpdate(ecIns); + if (batched) { + eventObj = { + type: actionInfo.event || payloadType, + escapeConnect: escapeConnect, + batch: eventObjBatch + }; + } else { + eventObj = eventObjBatch[0]; } - }).on('mouseout', function (e) { - var el = e.target; - var dispatcher = findEventDispatcher(el, isHighDownDispatcher); - if (dispatcher) { - handleGlboalMouseOutForHighDown(dispatcher, e, ecIns._api); - markStatusToUpdate(ecIns); - } - }).on('click', function (e) { - var el = e.target; - var dispatcher = findEventDispatcher(el, function (target) { - return getECData(target).dataIndex != null; - }, true); - - if (dispatcher) { - var actionType = dispatcher.selected ? 'unselect' : 'select'; - var ecData = getECData(dispatcher); - - ecIns._api.dispatchAction({ - type: actionType, - dataType: ecData.dataType, - dataIndexInside: ecData.dataIndex, - seriesIndex: ecData.seriesIndex, - isFromClick: true - }); + this[IN_MAIN_PROCESS_KEY] = false; + + if (!silent) { + var messageCenter = this._messageCenter; + messageCenter.trigger(eventObj.type, eventObj); // Extra triggered 'selectchanged' event + + if (isSelectChange) { + var newObj = { + type: 'selectchanged', + escapeConnect: escapeConnect, + selected: getAllSelectedIndices(ecModel), + isFromClick: payload.isFromClick || false, + fromAction: payload.type, + fromActionPayload: payload + }; + messageCenter.trigger(newObj.type, newObj); + } } - }); - }; - - clearColorPalette = function (ecModel) { - ecModel.clearColorPalette(); - ecModel.eachSeries(function (seriesModel) { - seriesModel.clearColorPalette(); - }); - }; + }; - render = function (ecIns, ecModel, api, payload, updateParams) { - renderComponents(ecIns, ecModel, api, payload, updateParams); - each(ecIns._chartsViews, function (chart) { - chart.__alive = false; - }); - renderSeries(ecIns, ecModel, api, payload, updateParams); // Remove groups of unrendered charts + flushPendingActions = function (silent) { + var pendingActions = this._pendingActions; - each(ecIns._chartsViews, function (chart) { - if (!chart.__alive) { - chart.remove(ecModel, api); + while (pendingActions.length) { + var payload = pendingActions.shift(); + doDispatchAction.call(this, payload, silent); } - }); - }; - - renderComponents = function (ecIns, ecModel, api, payload, updateParams, dirtyList) { - each(dirtyList || ecIns._componentsViews, function (componentView) { - var componentModel = componentView.__model; - clearStates(componentModel, componentView); - componentView.render(componentModel, ecModel, api, payload); - updateZ(componentModel, componentView); - updateStates(componentModel, componentView); - }); - }; - /** - * Render each chart and component - */ + }; + triggerUpdatedEvent = function (silent) { + !silent && this.trigger('updated'); + }; + /** + * Event `rendered` is triggered when zr + * rendered. It is useful for realtime + * snapshot (reflect animation). + * + * Event `finished` is triggered when: + * (1) zrender rendering finished. + * (2) initial animation finished. + * (3) progressive rendering finished. + * (4) no pending action. + * (5) no delayed setOption needs to be processed. + */ + + + bindRenderedEvent = function (zr, ecIns) { + zr.on('rendered', function (params) { + ecIns.trigger('rendered', params); // The `finished` event should not be triggered repeatly, + // so it should only be triggered when rendering indeed happend + // in zrender. (Consider the case that dipatchAction is keep + // triggering when mouse move). + + if ( // Although zr is dirty if initial animation is not finished + // and this checking is called on frame, we also check + // animation finished for robustness. + zr.animation.isFinished() && !ecIns[PENDING_UPDATE] && !ecIns._scheduler.unfinished && !ecIns._pendingActions.length) { + ecIns.trigger('finished'); + } + }); + }; - renderSeries = function (ecIns, ecModel, api, payload, updateParams, dirtyMap) { - // Render all charts - var scheduler = ecIns._scheduler; - updateParams = extend(updateParams || {}, { - updatedSeries: ecModel.getSeries() - }); // TODO progressive? + bindMouseEvent = function (zr, ecIns) { + zr.on('mouseover', function (e) { + var el = e.target; + var dispatcher = findEventDispatcher(el, isHighDownDispatcher); - lifecycle.trigger('series:beforeupdate', ecModel, api, updateParams); - var unfinished = false; - ecModel.eachSeries(function (seriesModel) { - var chartView = ecIns._chartsMap[seriesModel.__viewId]; - chartView.__alive = true; - var renderTask = chartView.renderTask; - scheduler.updatePayload(renderTask, payload); // TODO states on marker. + if (dispatcher) { + handleGlobalMouseOverForHighDown(dispatcher, e, ecIns._api); + markStatusToUpdate(ecIns); + } + }).on('mouseout', function (e) { + var el = e.target; + var dispatcher = findEventDispatcher(el, isHighDownDispatcher); - clearStates(seriesModel, chartView); + if (dispatcher) { + handleGlboalMouseOutForHighDown(dispatcher, e, ecIns._api); + markStatusToUpdate(ecIns); + } + }).on('click', function (e) { + var el = e.target; + var dispatcher = findEventDispatcher(el, function (target) { + return getECData(target).dataIndex != null; + }, true); - if (dirtyMap && dirtyMap.get(seriesModel.uid)) { - renderTask.dirty(); - } + if (dispatcher) { + var actionType = dispatcher.selected ? 'unselect' : 'select'; + var ecData = getECData(dispatcher); - if (renderTask.perform(scheduler.getPerformArgs(renderTask))) { - unfinished = true; - } + ecIns._api.dispatchAction({ + type: actionType, + dataType: ecData.dataType, + dataIndexInside: ecData.dataIndex, + seriesIndex: ecData.seriesIndex, + isFromClick: true + }); + } + }); + }; - chartView.group.silent = !!seriesModel.get('silent'); // Should not call markRedraw on group, because it will disable zrender - // increamental render (alway render from the __startIndex each frame) - // chartView.group.markRedraw(); + clearColorPalette = function (ecModel) { + ecModel.clearColorPalette(); + ecModel.eachSeries(function (seriesModel) { + seriesModel.clearColorPalette(); + }); + }; - updateBlend(seriesModel, chartView); - updateSeriesElementSelection(seriesModel); - }); - scheduler.unfinished = unfinished || scheduler.unfinished; - lifecycle.trigger('series:layoutlabels', ecModel, api, updateParams); // transition after label is layouted. + render = function (ecIns, ecModel, api, payload, updateParams) { + renderComponents(ecIns, ecModel, api, payload, updateParams); + each(ecIns._chartsViews, function (chart) { + chart.__alive = false; + }); + renderSeries(ecIns, ecModel, api, payload, updateParams); // Remove groups of unrendered charts - lifecycle.trigger('series:transition', ecModel, api, updateParams); - ecModel.eachSeries(function (seriesModel) { - var chartView = ecIns._chartsMap[seriesModel.__viewId]; // Update Z after labels updated. Before applying states. + each(ecIns._chartsViews, function (chart) { + if (!chart.__alive) { + chart.remove(ecModel, api); + } + }); + }; - updateZ(seriesModel, chartView); // NOTE: Update states after label is updated. - // label should be in normal status when layouting. + renderComponents = function (ecIns, ecModel, api, payload, updateParams, dirtyList) { + each(dirtyList || ecIns._componentsViews, function (componentView) { + var componentModel = componentView.__model; + clearStates(componentModel, componentView); + componentView.render(componentModel, ecModel, api, payload); + updateZ(componentModel, componentView); + updateStates(componentModel, componentView); + }); + }; + /** + * Render each chart and component + */ - updateStates(seriesModel, chartView); - }); // If use hover layer - updateHoverLayerStatus(ecIns, ecModel); - lifecycle.trigger('series:afterupdate', ecModel, api, updateParams); - }; + renderSeries = function (ecIns, ecModel, api, payload, updateParams, dirtyMap) { + // Render all charts + var scheduler = ecIns._scheduler; + updateParams = extend(updateParams || {}, { + updatedSeries: ecModel.getSeries() + }); // TODO progressive? - markStatusToUpdate = function (ecIns) { - ecIns[STATUS_NEEDS_UPDATE_KEY] = true; // Wake up zrender if it's sleep. Let it update states in the next frame. + lifecycle.trigger('series:beforeupdate', ecModel, api, updateParams); + var unfinished = false; + ecModel.eachSeries(function (seriesModel) { + var chartView = ecIns._chartsMap[seriesModel.__viewId]; + chartView.__alive = true; + var renderTask = chartView.renderTask; + scheduler.updatePayload(renderTask, payload); // TODO states on marker. - ecIns.getZr().wakeUp(); - }; + clearStates(seriesModel, chartView); - applyChangedStates = function (ecIns) { - if (!ecIns[STATUS_NEEDS_UPDATE_KEY]) { - return; - } + if (dirtyMap && dirtyMap.get(seriesModel.uid)) { + renderTask.dirty(); + } - ecIns.getZr().storage.traverse(function (el) { - // Not applied on removed elements, it may still in fading. - if (graphic.isElementRemoved(el)) { - return; - } + if (renderTask.perform(scheduler.getPerformArgs(renderTask))) { + unfinished = true; + } - applyElementStates(el); - }); - ecIns[STATUS_NEEDS_UPDATE_KEY] = false; - }; + chartView.group.silent = !!seriesModel.get('silent'); // Should not call markRedraw on group, because it will disable zrender + // increamental render (alway render from the __startIndex each frame) + // chartView.group.markRedraw(); - function applyElementStates(el) { - var newStates = []; - var oldStates = el.currentStates; // Keep other states. + updateBlend(seriesModel, chartView); + updateSeriesElementSelection(seriesModel); + }); + scheduler.unfinished = unfinished || scheduler.unfinished; + lifecycle.trigger('series:layoutlabels', ecModel, api, updateParams); // transition after label is layouted. - for (var i = 0; i < oldStates.length; i++) { - var stateName = oldStates[i]; + lifecycle.trigger('series:transition', ecModel, api, updateParams); + ecModel.eachSeries(function (seriesModel) { + var chartView = ecIns._chartsMap[seriesModel.__viewId]; // Update Z after labels updated. Before applying states. - if (!(stateName === 'emphasis' || stateName === 'blur' || stateName === 'select')) { - newStates.push(stateName); - } - } // Only use states when it's exists. + updateZ(seriesModel, chartView); // NOTE: Update states after label is updated. + // label should be in normal status when layouting. + updateStates(seriesModel, chartView); + }); // If use hover layer - if (el.selected && el.states.select) { - newStates.push('select'); - } + updateHoverLayerStatus(ecIns, ecModel); + lifecycle.trigger('series:afterupdate', ecModel, api, updateParams); + }; - if (el.hoverState === HOVER_STATE_EMPHASIS && el.states.emphasis) { - newStates.push('emphasis'); - } else if (el.hoverState === HOVER_STATE_BLUR && el.states.blur) { - newStates.push('blur'); - } + markStatusToUpdate = function (ecIns) { + ecIns[STATUS_NEEDS_UPDATE_KEY] = true; // Wake up zrender if it's sleep. Let it update states in the next frame. - el.useStates(newStates); - } + ecIns.getZr().wakeUp(); + }; - function updateHoverLayerStatus(ecIns, ecModel) { - var zr = ecIns._zr; - var storage = zr.storage; - var elCount = 0; - storage.traverse(function (el) { - if (!el.isGroup) { - elCount++; + applyChangedStates = function (ecIns) { + if (!ecIns[STATUS_NEEDS_UPDATE_KEY]) { + return; } - }); - if (elCount > ecModel.get('hoverLayerThreshold') && !env.node && !env.worker) { - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.preventUsingHoverLayer) { + ecIns.getZr().storage.traverse(function (el) { + // Not applied on removed elements, it may still in fading. + if (graphic.isElementRemoved(el)) { return; } - var chartView = ecIns._chartsMap[seriesModel.__viewId]; - - if (chartView.__alive) { - chartView.group.traverse(function (el) { - if (el.states.emphasis) { - el.states.emphasis.hoverLayer = true; - } - }); - } + applyElementStates(el); }); - } - } + ecIns[STATUS_NEEDS_UPDATE_KEY] = false; + }; - ; - /** - * Update chart and blend. - */ + function applyElementStates(el) { + var newStates = []; + var oldStates = el.currentStates; // Keep other states. - function updateBlend(seriesModel, chartView) { - var blendMode = seriesModel.get('blendMode') || null; + for (var i = 0; i < oldStates.length; i++) { + var stateName = oldStates[i]; + + if (!(stateName === 'emphasis' || stateName === 'blur' || stateName === 'select')) { + newStates.push(stateName); + } + } // Only use states when it's exists. - if (process.env.NODE_ENV !== 'production') { - if (!env.canvasSupported && blendMode && blendMode !== 'source-over') { - console.warn('Only canvas support blendMode'); - } - } - chartView.group.traverse(function (el) { - // FIXME marker and other components - if (!el.isGroup) { - // DONT mark the element dirty. In case element is incremental and don't wan't to rerender. - el.style.blend = blendMode; + if (el.selected && el.states.select) { + newStates.push('select'); } - if (el.eachPendingDisplayable) { - el.eachPendingDisplayable(function (displayable) { - displayable.style.blend = blendMode; - }); + if (el.hoverState === HOVER_STATE_EMPHASIS && el.states.emphasis) { + newStates.push('emphasis'); + } else if (el.hoverState === HOVER_STATE_BLUR && el.states.blur) { + newStates.push('blur'); } - }); - } - ; + el.useStates(newStates); + } - function updateZ(model, view) { - if (model.preventAutoZ) { - return; - } // Set z and zlevel + function updateHoverLayerStatus(ecIns, ecModel) { + var zr = ecIns._zr; + var storage = zr.storage; + var elCount = 0; + storage.traverse(function (el) { + if (!el.isGroup) { + elCount++; + } + }); + if (elCount > ecModel.get('hoverLayerThreshold') && !env.node && !env.worker) { + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.preventUsingHoverLayer) { + return; + } - _updateZ(view.group, model.get('z') || 0, model.get('zlevel') || 0, -Infinity); - } + var chartView = ecIns._chartsMap[seriesModel.__viewId]; - ; + if (chartView.__alive) { + chartView.group.traverse(function (el) { + if (el.states.emphasis) { + el.states.emphasis.hoverLayer = true; + } + }); + } + }); + } + } - function _updateZ(el, z, zlevel, maxZ2) { - // Group may also have textContent - var label = el.getTextContent(); - var labelLine = el.getTextGuideLine(); - var isGroup = el.isGroup; + ; + /** + * Update chart and blend. + */ - if (isGroup) { - // set z & zlevel of children elements of Group - // el.traverse((childEl: Element) => _updateZ(childEl, z, zlevel)); - var children = el.childrenRef(); + function updateBlend(seriesModel, chartView) { + var blendMode = seriesModel.get('blendMode') || null; - for (var i = 0; i < children.length; i++) { - maxZ2 = Math.max(_updateZ(children[i], z, zlevel, maxZ2), maxZ2); + if (process.env.NODE_ENV !== 'production') { + if (!env.canvasSupported && blendMode && blendMode !== 'source-over') { + console.warn('Only canvas support blendMode'); + } } - } else { - // not Group - el.z = z; - el.zlevel = zlevel; - maxZ2 = Math.max(el.z2, maxZ2); - } // always set z and zlevel if label/labelLine exists + chartView.group.traverse(function (el) { + // FIXME marker and other components + if (!el.isGroup) { + // DONT mark the element dirty. In case element is incremental and don't wan't to rerender. + el.style.blend = blendMode; + } - if (label) { - label.z = z; - label.zlevel = zlevel; // lift z2 of text content - // TODO if el.emphasis.z2 is spcefied, what about textContent. - - isFinite(maxZ2) && (label.z2 = maxZ2 + 2); + if (el.eachPendingDisplayable) { + el.eachPendingDisplayable(function (displayable) { + displayable.style.blend = blendMode; + }); + } + }); } - if (labelLine) { - var textGuideLineConfig = el.textGuideLineConfig; - labelLine.z = z; - labelLine.zlevel = zlevel; - isFinite(maxZ2) && (labelLine.z2 = maxZ2 + (textGuideLineConfig && textGuideLineConfig.showAbove ? 1 : -1)); + ; + + function updateZ(model, view) { + if (model.preventAutoZ) { + return; + } // Set z and zlevel + + + _updateZ(view.group, model.get('z') || 0, model.get('zlevel') || 0, -Infinity); } - return maxZ2; - } // Clear states without animation. - // TODO States on component. + ; + function _updateZ(el, z, zlevel, maxZ2) { + // Group may also have textContent + var label = el.getTextContent(); + var labelLine = el.getTextGuideLine(); + var isGroup = el.isGroup; - function clearStates(model, view) { - view.group.traverse(function (el) { - // Not applied on removed elements, it may still in fading. - if (graphic.isElementRemoved(el)) { - return; - } + if (isGroup) { + // set z & zlevel of children elements of Group + // el.traverse((childEl: Element) => _updateZ(childEl, z, zlevel)); + var children = el.childrenRef(); - var textContent = el.getTextContent(); - var textGuide = el.getTextGuideLine(); + for (var i = 0; i < children.length; i++) { + maxZ2 = Math.max(_updateZ(children[i], z, zlevel, maxZ2), maxZ2); + } + } else { + // not Group + el.z = z; + el.zlevel = zlevel; + maxZ2 = Math.max(el.z2, maxZ2); + } // always set z and zlevel if label/labelLine exists - if (el.stateTransition) { - el.stateTransition = null; - } - if (textContent && textContent.stateTransition) { - textContent.stateTransition = null; + if (label) { + label.z = z; + label.zlevel = zlevel; // lift z2 of text content + // TODO if el.emphasis.z2 is spcefied, what about textContent. + + isFinite(maxZ2) && (label.z2 = maxZ2 + 2); } - if (textGuide && textGuide.stateTransition) { - textGuide.stateTransition = null; - } // TODO If el is incremental. + if (labelLine) { + var textGuideLineConfig = el.textGuideLineConfig; + labelLine.z = z; + labelLine.zlevel = zlevel; + isFinite(maxZ2) && (labelLine.z2 = maxZ2 + (textGuideLineConfig && textGuideLineConfig.showAbove ? 1 : -1)); + } + return maxZ2; + } // Clear states without animation. + // TODO States on component. - if (el.hasState()) { - el.prevStates = el.currentStates; - el.clearStates(); - } else if (el.prevStates) { - el.prevStates = null; - } - }); - } - function updateStates(model, view) { - var stateAnimationModel = model.getModel('stateAnimation'); - var enableAnimation = model.isAnimationEnabled(); - var duration = stateAnimationModel.get('duration'); - var stateTransition = duration > 0 ? { - duration: duration, - delay: stateAnimationModel.get('delay'), - easing: stateAnimationModel.get('easing') // additive: stateAnimationModel.get('additive') - - } : null; - view.group.traverse(function (el) { - if (el.states && el.states.emphasis) { + function clearStates(model, view) { + view.group.traverse(function (el) { // Not applied on removed elements, it may still in fading. if (graphic.isElementRemoved(el)) { return; } - if (el instanceof graphic.Path) { - savePathStates(el); - } // Only updated on changed element. In case element is incremental and don't wan't to rerender. - // TODO, a more proper way? + var textContent = el.getTextContent(); + var textGuide = el.getTextGuideLine(); + if (el.stateTransition) { + el.stateTransition = null; + } - if (el.__dirty) { - var prevStates = el.prevStates; // Restore states without animation + if (textContent && textContent.stateTransition) { + textContent.stateTransition = null; + } - if (prevStates) { - el.useStates(prevStates); - } - } // Update state transition and enable animation again. + if (textGuide && textGuide.stateTransition) { + textGuide.stateTransition = null; + } // TODO If el is incremental. - if (enableAnimation) { - el.stateTransition = stateTransition; - var textContent = el.getTextContent(); - var textGuide = el.getTextGuideLine(); // TODO Is it necessary to animate label? + if (el.hasState()) { + el.prevStates = el.currentStates; + el.clearStates(); + } else if (el.prevStates) { + el.prevStates = null; + } + }); + } - if (textContent) { - textContent.stateTransition = stateTransition; + function updateStates(model, view) { + var stateAnimationModel = model.getModel('stateAnimation'); + var enableAnimation = model.isAnimationEnabled(); + var duration = stateAnimationModel.get('duration'); + var stateTransition = duration > 0 ? { + duration: duration, + delay: stateAnimationModel.get('delay'), + easing: stateAnimationModel.get('easing') // additive: stateAnimationModel.get('additive') + + } : null; + view.group.traverse(function (el) { + if (el.states && el.states.emphasis) { + // Not applied on removed elements, it may still in fading. + if (graphic.isElementRemoved(el)) { + return; } - if (textGuide) { - textGuide.stateTransition = stateTransition; - } - } // The use higlighted and selected flag to toggle states. + if (el instanceof graphic.Path) { + savePathStates(el); + } // Only updated on changed element. In case element is incremental and don't wan't to rerender. + // TODO, a more proper way? - if (el.__dirty) { - applyElementStates(el); - } - } - }); - } + if (el.__dirty) { + var prevStates = el.prevStates; // Restore states without animation - ; + if (prevStates) { + el.useStates(prevStates); + } + } // Update state transition and enable animation again. - createExtensionAPI = function (ecIns) { - return new ( - /** @class */ - function (_super) { - __extends(class_1, _super); - function class_1() { - return _super !== null && _super.apply(this, arguments) || this; - } + if (enableAnimation) { + el.stateTransition = stateTransition; + var textContent = el.getTextContent(); + var textGuide = el.getTextGuideLine(); // TODO Is it necessary to animate label? - class_1.prototype.getCoordinateSystems = function () { - return ecIns._coordSysMgr.getCoordinateSystems(); - }; + if (textContent) { + textContent.stateTransition = stateTransition; + } - class_1.prototype.getComponentByElement = function (el) { - while (el) { - var modelInfo = el.__ecComponentInfo; + if (textGuide) { + textGuide.stateTransition = stateTransition; + } + } // The use higlighted and selected flag to toggle states. - if (modelInfo != null) { - return ecIns._model.getComponent(modelInfo.mainType, modelInfo.index); - } - el = el.parent; + if (el.__dirty) { + applyElementStates(el); + } } - }; - - class_1.prototype.enterEmphasis = function (el, highlightDigit) { - enterEmphasis(el, highlightDigit); - markStatusToUpdate(ecIns); - }; - - class_1.prototype.leaveEmphasis = function (el, highlightDigit) { - leaveEmphasis(el, highlightDigit); - markStatusToUpdate(ecIns); - }; - - class_1.prototype.enterBlur = function (el) { - enterBlur(el); - markStatusToUpdate(ecIns); - }; + }); + } - class_1.prototype.leaveBlur = function (el) { - leaveBlur(el); - markStatusToUpdate(ecIns); - }; + ; - class_1.prototype.enterSelect = function (el) { - enterSelect(el); - markStatusToUpdate(ecIns); - }; + createExtensionAPI = function (ecIns) { + return new ( + /** @class */ + function (_super) { + __extends(class_1, _super); - class_1.prototype.leaveSelect = function (el) { - leaveSelect(el); - markStatusToUpdate(ecIns); - }; + function class_1() { + return _super !== null && _super.apply(this, arguments) || this; + } - class_1.prototype.getModel = function () { - return ecIns.getModel(); - }; + class_1.prototype.getCoordinateSystems = function () { + return ecIns._coordSysMgr.getCoordinateSystems(); + }; - class_1.prototype.getViewOfComponentModel = function (componentModel) { - return ecIns.getViewOfComponentModel(componentModel); - }; + class_1.prototype.getComponentByElement = function (el) { + while (el) { + var modelInfo = el.__ecComponentInfo; - class_1.prototype.getViewOfSeriesModel = function (seriesModel) { - return ecIns.getViewOfSeriesModel(seriesModel); - }; + if (modelInfo != null) { + return ecIns._model.getComponent(modelInfo.mainType, modelInfo.index); + } - return class_1; - }(ExtensionAPI))(ecIns); - }; + el = el.parent; + } + }; + + class_1.prototype.enterEmphasis = function (el, highlightDigit) { + enterEmphasis(el, highlightDigit); + markStatusToUpdate(ecIns); + }; + + class_1.prototype.leaveEmphasis = function (el, highlightDigit) { + leaveEmphasis(el, highlightDigit); + markStatusToUpdate(ecIns); + }; + + class_1.prototype.enterBlur = function (el) { + enterBlur(el); + markStatusToUpdate(ecIns); + }; + + class_1.prototype.leaveBlur = function (el) { + leaveBlur(el); + markStatusToUpdate(ecIns); + }; + + class_1.prototype.enterSelect = function (el) { + enterSelect(el); + markStatusToUpdate(ecIns); + }; + + class_1.prototype.leaveSelect = function (el) { + leaveSelect(el); + markStatusToUpdate(ecIns); + }; + + class_1.prototype.getModel = function () { + return ecIns.getModel(); + }; + + class_1.prototype.getViewOfComponentModel = function (componentModel) { + return ecIns.getViewOfComponentModel(componentModel); + }; + + class_1.prototype.getViewOfSeriesModel = function (seriesModel) { + return ecIns.getViewOfSeriesModel(seriesModel); + }; + + return class_1; + }(ExtensionAPI))(ecIns); + }; - enableConnect = function (chart) { - function updateConnectedChartsStatus(charts, status) { - for (var i = 0; i < charts.length; i++) { - var otherChart = charts[i]; - otherChart[CONNECT_STATUS_KEY] = status; + enableConnect = function (chart) { + function updateConnectedChartsStatus(charts, status) { + for (var i = 0; i < charts.length; i++) { + var otherChart = charts[i]; + otherChart[CONNECT_STATUS_KEY] = status; + } } - } - - each(eventActionMap, function (actionType, eventType) { - chart._messageCenter.on(eventType, function (event) { - if (connectedGroups[chart.group] && chart[CONNECT_STATUS_KEY] !== CONNECT_STATUS_PENDING) { - if (event && event.escapeConnect) { - return; - } - var action_1 = chart.makeActionFromEvent(event); - var otherCharts_1 = []; - each(instances, function (otherChart) { - if (otherChart !== chart && otherChart.group === chart.group) { - otherCharts_1.push(otherChart); + each(eventActionMap, function (actionType, eventType) { + chart._messageCenter.on(eventType, function (event) { + if (connectedGroups[chart.group] && chart[CONNECT_STATUS_KEY] !== CONNECT_STATUS_PENDING) { + if (event && event.escapeConnect) { + return; } - }); - updateConnectedChartsStatus(otherCharts_1, CONNECT_STATUS_PENDING); - each(otherCharts_1, function (otherChart) { - if (otherChart[CONNECT_STATUS_KEY] !== CONNECT_STATUS_UPDATING) { - otherChart.dispatchAction(action_1); - } - }); - updateConnectedChartsStatus(otherCharts_1, CONNECT_STATUS_UPDATED); - } + + var action_1 = chart.makeActionFromEvent(event); + var otherCharts_1 = []; + each(instances, function (otherChart) { + if (otherChart !== chart && otherChart.group === chart.group) { + otherCharts_1.push(otherChart); + } + }); + updateConnectedChartsStatus(otherCharts_1, CONNECT_STATUS_PENDING); + each(otherCharts_1, function (otherChart) { + if (otherChart[CONNECT_STATUS_KEY] !== CONNECT_STATUS_UPDATING) { + otherChart.dispatchAction(action_1); + } + }); + updateConnectedChartsStatus(otherCharts_1, CONNECT_STATUS_UPDATED); + } + }); }); - }); - }; - }(); + }; + }(); - return ECharts; -}(Eventful); + return ECharts; + }(Eventful); var echartsProto = ECharts.prototype; echartsProto.on = createRegisterEventWithLowercaseECharts('on');