;\n\n var markupFragment;\n\n if (zrUtil.isObject(result)) {\n if (result.type) {\n markupFragment = result;\n } else {\n if (process.env.NODE_ENV !== 'production') {\n console.warn('The return type of `formatTooltip` is not supported: ' + makePrintable(result));\n }\n } // else {\n // markupText = (result as TooltipFormatResultLegacyObject).html;\n // markers = (result as TooltipFormatResultLegacyObject).markers;\n // if (markersExisting) {\n // markers = zrUtil.merge(markersExisting, markers);\n // }\n // }\n\n } else {\n markupText = result;\n }\n\n return {\n markupText: markupText,\n // markers: markers || markersExisting,\n markupFragment: markupFragment\n };\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { assert, isArray } from 'zrender/lib/core/util';\n;\n/**\n * @param {Object} define\n * @return See the return of `createTask`.\n */\n\nexport function createTask(define) {\n return new Task(define);\n}\n\nvar Task =\n/** @class */\nfunction () {\n function Task(define) {\n define = define || {};\n this._reset = define.reset;\n this._plan = define.plan;\n this._count = define.count;\n this._onDirty = define.onDirty;\n this._dirty = true;\n }\n /**\n * @param step Specified step.\n * @param skip Skip customer perform call.\n * @param modBy Sampling window size.\n * @param modDataCount Sampling count.\n * @return whether unfinished.\n */\n\n\n Task.prototype.perform = function (performArgs) {\n var upTask = this._upstream;\n var skip = performArgs && performArgs.skip; // TODO some refactor.\n // Pull data. Must pull data each time, because context.data\n // may be updated by Series.setData.\n\n if (this._dirty && upTask) {\n var context = this.context;\n context.data = context.outputData = upTask.context.outputData;\n }\n\n if (this.__pipeline) {\n this.__pipeline.currentTask = this;\n }\n\n var planResult;\n\n if (this._plan && !skip) {\n planResult = this._plan(this.context);\n } // Support sharding by mod, which changes the render sequence and makes the rendered graphic\n // elements uniformed distributed when progress, especially when moving or zooming.\n\n\n var lastModBy = normalizeModBy(this._modBy);\n var lastModDataCount = this._modDataCount || 0;\n var modBy = normalizeModBy(performArgs && performArgs.modBy);\n var modDataCount = performArgs && performArgs.modDataCount || 0;\n\n if (lastModBy !== modBy || lastModDataCount !== modDataCount) {\n planResult = 'reset';\n }\n\n function normalizeModBy(val) {\n !(val >= 1) && (val = 1); // jshint ignore:line\n\n return val;\n }\n\n var forceFirstProgress;\n\n if (this._dirty || planResult === 'reset') {\n this._dirty = false;\n forceFirstProgress = this._doReset(skip);\n }\n\n this._modBy = modBy;\n this._modDataCount = modDataCount;\n var step = performArgs && performArgs.step;\n\n if (upTask) {\n if (process.env.NODE_ENV !== 'production') {\n assert(upTask._outputDueEnd != null);\n }\n\n this._dueEnd = upTask._outputDueEnd;\n } // DataTask or overallTask\n else {\n if (process.env.NODE_ENV !== 'production') {\n assert(!this._progress || this._count);\n }\n\n this._dueEnd = this._count ? this._count(this.context) : Infinity;\n } // Note: Stubs, that its host overall task let it has progress, has progress.\n // If no progress, pass index from upstream to downstream each time plan called.\n\n\n if (this._progress) {\n var start = this._dueIndex;\n var end = Math.min(step != null ? this._dueIndex + step : Infinity, this._dueEnd);\n\n if (!skip && (forceFirstProgress || start < end)) {\n var progress = this._progress;\n\n if (isArray(progress)) {\n for (var i = 0; i < progress.length; i++) {\n this._doProgress(progress[i], start, end, modBy, modDataCount);\n }\n } else {\n this._doProgress(progress, start, end, modBy, modDataCount);\n }\n }\n\n this._dueIndex = end; // If no `outputDueEnd`, assume that output data and\n // input data is the same, so use `dueIndex` as `outputDueEnd`.\n\n var outputDueEnd = this._settedOutputEnd != null ? this._settedOutputEnd : end;\n\n if (process.env.NODE_ENV !== 'production') {\n // ??? Can not rollback.\n assert(outputDueEnd >= this._outputDueEnd);\n }\n\n this._outputDueEnd = outputDueEnd;\n } else {\n // (1) Some overall task has no progress.\n // (2) Stubs, that its host overall task do not let it has progress, has no progress.\n // This should always be performed so it can be passed to downstream.\n this._dueIndex = this._outputDueEnd = this._settedOutputEnd != null ? this._settedOutputEnd : this._dueEnd;\n }\n\n return this.unfinished();\n };\n\n Task.prototype.dirty = function () {\n this._dirty = true;\n this._onDirty && this._onDirty(this.context);\n };\n\n Task.prototype._doProgress = function (progress, start, end, modBy, modDataCount) {\n iterator.reset(start, end, modBy, modDataCount);\n this._callingProgress = progress;\n\n this._callingProgress({\n start: start,\n end: end,\n count: end - start,\n next: iterator.next\n }, this.context);\n };\n\n Task.prototype._doReset = function (skip) {\n this._dueIndex = this._outputDueEnd = this._dueEnd = 0;\n this._settedOutputEnd = null;\n var progress;\n var forceFirstProgress;\n\n if (!skip && this._reset) {\n progress = this._reset(this.context);\n\n if (progress && progress.progress) {\n forceFirstProgress = progress.forceFirstProgress;\n progress = progress.progress;\n } // To simplify no progress checking, array must has item.\n\n\n if (isArray(progress) && !progress.length) {\n progress = null;\n }\n }\n\n this._progress = progress;\n this._modBy = this._modDataCount = null;\n var downstream = this._downstream;\n downstream && downstream.dirty();\n return forceFirstProgress;\n };\n\n Task.prototype.unfinished = function () {\n return this._progress && this._dueIndex < this._dueEnd;\n };\n /**\n * @param downTask The downstream task.\n * @return The downstream task.\n */\n\n\n Task.prototype.pipe = function (downTask) {\n if (process.env.NODE_ENV !== 'production') {\n assert(downTask && !downTask._disposed && downTask !== this);\n } // If already downstream, do not dirty downTask.\n\n\n if (this._downstream !== downTask || this._dirty) {\n this._downstream = downTask;\n downTask._upstream = this;\n downTask.dirty();\n }\n };\n\n Task.prototype.dispose = function () {\n if (this._disposed) {\n return;\n }\n\n this._upstream && (this._upstream._downstream = null);\n this._downstream && (this._downstream._upstream = null);\n this._dirty = false;\n this._disposed = true;\n };\n\n Task.prototype.getUpstream = function () {\n return this._upstream;\n };\n\n Task.prototype.getDownstream = function () {\n return this._downstream;\n };\n\n Task.prototype.setOutputEnd = function (end) {\n // This only happend in dataTask, dataZoom, map, currently.\n // where dataZoom do not set end each time, but only set\n // when reset. So we should record the setted end, in case\n // that the stub of dataZoom perform again and earse the\n // setted end by upstream.\n this._outputDueEnd = this._settedOutputEnd = end;\n };\n\n return Task;\n}();\n\nexport { Task };\n\nvar iterator = function () {\n var end;\n var current;\n var modBy;\n var modDataCount;\n var winCount;\n var it = {\n reset: function (s, e, sStep, sCount) {\n current = s;\n end = e;\n modBy = sStep;\n modDataCount = sCount;\n winCount = Math.ceil(modDataCount / modBy);\n it.next = modBy > 1 && modDataCount > 0 ? modNext : sequentialNext;\n }\n };\n return it;\n\n function sequentialNext() {\n return current < end ? current++ : null;\n }\n\n function modNext() {\n var dataIndex = current % winCount * modBy + Math.ceil(current / winCount);\n var result = current >= end ? null : dataIndex < modDataCount ? dataIndex // If modDataCount is smaller than data.count() (consider `appendData` case),\n // Use normal linear rendering mode.\n : current;\n current++;\n return result;\n }\n}(); ///////////////////////////////////////////////////////////\n// For stream debug (Should be commented out after used!)\n// @usage: printTask(this, 'begin');\n// @usage: printTask(this, null, {someExtraProp});\n// @usage: Use `__idxInPipeline` as conditional breakpiont.\n//\n// window.printTask = function (task: any, prefix: string, extra: { [key: string]: unknown }): void {\n// window.ecTaskUID == null && (window.ecTaskUID = 0);\n// task.uidDebug == null && (task.uidDebug = `task_${window.ecTaskUID++}`);\n// task.agent && task.agent.uidDebug == null && (task.agent.uidDebug = `task_${window.ecTaskUID++}`);\n// let props = [];\n// if (task.__pipeline) {\n// let val = `${task.__idxInPipeline}/${task.__pipeline.tail.__idxInPipeline} ${task.agent ? '(stub)' : ''}`;\n// props.push({text: '__idxInPipeline/total', value: val});\n// } else {\n// let stubCount = 0;\n// task.agentStubMap.each(() => stubCount++);\n// props.push({text: 'idx', value: `overall (stubs: ${stubCount})`});\n// }\n// props.push({text: 'uid', value: task.uidDebug});\n// if (task.__pipeline) {\n// props.push({text: 'pipelineId', value: task.__pipeline.id});\n// task.agent && props.push(\n// {text: 'stubFor', value: task.agent.uidDebug}\n// );\n// }\n// props.push(\n// {text: 'dirty', value: task._dirty},\n// {text: 'dueIndex', value: task._dueIndex},\n// {text: 'dueEnd', value: task._dueEnd},\n// {text: 'outputDueEnd', value: task._outputDueEnd}\n// );\n// if (extra) {\n// Object.keys(extra).forEach(key => {\n// props.push({text: key, value: extra[key]});\n// });\n// }\n// let args = ['color: blue'];\n// let msg = `%c[${prefix || 'T'}] %c` + props.map(item => (\n// args.push('color: green', 'color: red'),\n// `${item.text}: %c${item.value}`\n// )).join('%c, ');\n// console.log.apply(console, [msg].concat(args));\n// // console.log(this);\n// };\n// window.printPipeline = function (task: any, prefix: string) {\n// const pipeline = task.__pipeline;\n// let currTask = pipeline.head;\n// while (currTask) {\n// window.printTask(currTask, prefix);\n// currTask = currTask._downstream;\n// }\n// };\n// window.showChain = function (chainHeadTask) {\n// var chain = [];\n// var task = chainHeadTask;\n// while (task) {\n// chain.push({\n// task: task,\n// up: task._upstream,\n// down: task._downstream,\n// idxInPipeline: task.__idxInPipeline\n// });\n// task = task._downstream;\n// }\n// return chain;\n// };\n// window.findTaskInChain = function (task, chainHeadTask) {\n// let chain = window.showChain(chainHeadTask);\n// let result = [];\n// for (let i = 0; i < chain.length; i++) {\n// let chainItem = chain[i];\n// if (chainItem.task === task) {\n// result.push(i);\n// }\n// }\n// return result;\n// };\n// window.printChainAEachInChainB = function (chainHeadTaskA, chainHeadTaskB) {\n// let chainA = window.showChain(chainHeadTaskA);\n// for (let i = 0; i < chainA.length; i++) {\n// console.log('chainAIdx:', i, 'inChainB:', window.findTaskInChain(chainA[i].task, chainHeadTaskB));\n// }\n// };","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { parseDate, numericToNumber } from '../../util/number';\nimport { createHashMap, trim, hasOwn } from 'zrender/lib/core/util';\nimport { throwError } from '../../util/log';\n/**\n * Convert raw the value in to inner value in List.\n *\n * [Performance sensitive]\n *\n * [Caution]: this is the key logic of user value parser.\n * For backward compatibiliy, do not modify it until have to!\n */\n\nexport function parseDataValue(value, // For high performance, do not omit the second param.\nopt) {\n // Performance sensitive.\n var dimType = opt && opt.type;\n\n if (dimType === 'ordinal') {\n // If given value is a category string\n var ordinalMeta = opt && opt.ordinalMeta;\n return ordinalMeta ? ordinalMeta.parseAndCollect(value) : value;\n }\n\n if (dimType === 'time' // spead up when using timestamp\n && typeof value !== 'number' && value != null && value !== '-') {\n value = +parseDate(value);\n } // dimType defaults 'number'.\n // If dimType is not ordinal and value is null or undefined or NaN or '-',\n // parse to NaN.\n // number-like string (like ' 123 ') can be converted to a number.\n // where null/undefined or other string will be converted to NaN.\n\n\n return value == null || value === '' ? NaN // If string (like '-'), using '+' parse to NaN\n // If object, also parse to NaN\n : +value;\n}\n;\nvar valueParserMap = createHashMap({\n 'number': function (val) {\n // Do not use `numericToNumber` here. We have by defualt `numericToNumber`.\n // Here the number parser can have loose rule:\n // enable to cut suffix: \"120px\" => 120, \"14%\" => 14.\n return parseFloat(val);\n },\n 'time': function (val) {\n // return timestamp.\n return +parseDate(val);\n },\n 'trim': function (val) {\n return typeof val === 'string' ? trim(val) : val;\n }\n});\nexport function getRawValueParser(type) {\n return valueParserMap.get(type);\n}\nvar ORDER_COMPARISON_OP_MAP = {\n lt: function (lval, rval) {\n return lval < rval;\n },\n lte: function (lval, rval) {\n return lval <= rval;\n },\n gt: function (lval, rval) {\n return lval > rval;\n },\n gte: function (lval, rval) {\n return lval >= rval;\n }\n};\n\nvar FilterOrderComparator =\n/** @class */\nfunction () {\n function FilterOrderComparator(op, rval) {\n if (typeof rval !== 'number') {\n var errMsg = '';\n\n if (process.env.NODE_ENV !== 'production') {\n errMsg = 'rvalue of \"<\", \">\", \"<=\", \">=\" can only be number in filter.';\n }\n\n throwError(errMsg);\n }\n\n this._opFn = ORDER_COMPARISON_OP_MAP[op];\n this._rvalFloat = numericToNumber(rval);\n } // Performance sensitive.\n\n\n FilterOrderComparator.prototype.evaluate = function (lval) {\n // Most cases is 'number', and typeof maybe 10 times faseter than parseFloat.\n return typeof lval === 'number' ? this._opFn(lval, this._rvalFloat) : this._opFn(numericToNumber(lval), this._rvalFloat);\n };\n\n return FilterOrderComparator;\n}();\n\nvar SortOrderComparator =\n/** @class */\nfunction () {\n /**\n * @param order by defualt: 'asc'\n * @param incomparable by defualt: Always on the tail.\n * That is, if 'asc' => 'max', if 'desc' => 'min'\n * See the definition of \"incomparable\" in [SORT_COMPARISON_RULE]\n */\n function SortOrderComparator(order, incomparable) {\n var isDesc = order === 'desc';\n this._resultLT = isDesc ? 1 : -1;\n\n if (incomparable == null) {\n incomparable = isDesc ? 'min' : 'max';\n }\n\n this._incomparable = incomparable === 'min' ? -Infinity : Infinity;\n } // See [SORT_COMPARISON_RULE].\n // Performance sensitive.\n\n\n SortOrderComparator.prototype.evaluate = function (lval, rval) {\n // Most cases is 'number', and typeof maybe 10 times faseter than parseFloat.\n var lvalTypeof = typeof lval;\n var rvalTypeof = typeof rval;\n var lvalFloat = lvalTypeof === 'number' ? lval : numericToNumber(lval);\n var rvalFloat = rvalTypeof === 'number' ? rval : numericToNumber(rval);\n var lvalNotNumeric = isNaN(lvalFloat);\n var rvalNotNumeric = isNaN(rvalFloat);\n\n if (lvalNotNumeric) {\n lvalFloat = this._incomparable;\n }\n\n if (rvalNotNumeric) {\n rvalFloat = this._incomparable;\n }\n\n if (lvalNotNumeric && rvalNotNumeric) {\n var lvalIsStr = lvalTypeof === 'string';\n var rvalIsStr = rvalTypeof === 'string';\n\n if (lvalIsStr) {\n lvalFloat = rvalIsStr ? lval : 0;\n }\n\n if (rvalIsStr) {\n rvalFloat = lvalIsStr ? rval : 0;\n }\n }\n\n return lvalFloat < rvalFloat ? this._resultLT : lvalFloat > rvalFloat ? -this._resultLT : 0;\n };\n\n return SortOrderComparator;\n}();\n\nexport { SortOrderComparator };\n\nvar FilterEqualityComparator =\n/** @class */\nfunction () {\n function FilterEqualityComparator(isEq, rval) {\n this._rval = rval;\n this._isEQ = isEq;\n this._rvalTypeof = typeof rval;\n this._rvalFloat = numericToNumber(rval);\n } // Performance sensitive.\n\n\n FilterEqualityComparator.prototype.evaluate = function (lval) {\n var eqResult = lval === this._rval;\n\n if (!eqResult) {\n var lvalTypeof = typeof lval;\n\n if (lvalTypeof !== this._rvalTypeof && (lvalTypeof === 'number' || this._rvalTypeof === 'number')) {\n eqResult = numericToNumber(lval) === this._rvalFloat;\n }\n }\n\n return this._isEQ ? eqResult : !eqResult;\n };\n\n return FilterEqualityComparator;\n}();\n/**\n * [FILTER_COMPARISON_RULE]\n * `lt`|`lte`|`gt`|`gte`:\n * + rval must be a number. And lval will be converted to number (`numericToNumber`) to compare.\n * `eq`:\n * + If same type, compare with `===`.\n * + If there is one number, convert to number (`numericToNumber`) to compare.\n * + Else return `false`.\n * `ne`:\n * + Not `eq`.\n *\n *\n * [SORT_COMPARISON_RULE]\n * All the values are grouped into three categories:\n * + \"numeric\" (number and numeric string)\n * + \"non-numeric-string\" (string that excluding numeric string)\n * + \"others\"\n * \"numeric\" vs \"numeric\": values are ordered by number order.\n * \"non-numeric-string\" vs \"non-numeric-string\": values are ordered by ES spec (#sec-abstract-relational-comparison).\n * \"others\" vs \"others\": do not change order (always return 0).\n * \"numeric\" vs \"non-numeric-string\": \"non-numeric-string\" is treated as \"incomparable\".\n * \"number\" vs \"others\": \"others\" is treated as \"incomparable\".\n * \"non-numeric-string\" vs \"others\": \"others\" is treated as \"incomparable\".\n * \"incomparable\" will be seen as -Infinity or Infinity (depends on the settings).\n * MEMO:\n * non-numeric string sort make sence when need to put the items with the same tag together.\n * But if we support string sort, we still need to avoid the misleading like `'2' > '12'`,\n * So we treat \"numeric-string\" sorted by number order rather than string comparison.\n *\n *\n * [CHECK_LIST_OF_THE_RULE_DESIGN]\n * + Do not support string comparison until required. And also need to\n * void the misleading of \"2\" > \"12\".\n * + Should avoid the misleading case:\n * `\" 22 \" gte \"22\"` is `true` but `\" 22 \" eq \"22\"` is `false`.\n * + JS bad case should be avoided: null <= 0, [] <= 0, ' ' <= 0, ...\n * + Only \"numeric\" can be converted to comparable number, otherwise converted to NaN.\n * See `util/number.ts#numericToNumber`.\n *\n * @return If `op` is not `RelationalOperator`, return null;\n */\n\n\nexport function createFilterComparator(op, rval) {\n return op === 'eq' || op === 'ne' ? new FilterEqualityComparator(op === 'eq', rval) : hasOwn(ORDER_COMPARISON_OP_MAP, op) ? new FilterOrderComparator(op, rval) : null;\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { SERIES_LAYOUT_BY_COLUMN, SOURCE_FORMAT_OBJECT_ROWS, SOURCE_FORMAT_ARRAY_ROWS } from '../../util/types';\nimport { normalizeToArray } from '../../util/model';\nimport { createHashMap, bind, each, hasOwn, map, clone, isObject, extend } from 'zrender/lib/core/util';\nimport { getRawSourceItemGetter, getRawSourceDataCounter, getRawSourceValueGetter } from './dataProvider';\nimport { parseDataValue } from './dataValueHelper';\nimport { consoleLog, makePrintable, throwError } from '../../util/log';\nimport { createSource, detectSourceFormat } from '../Source';\n/**\n * TODO: disable writable.\n * This structure will be exposed to users.\n */\n\nvar ExternalSource =\n/** @class */\nfunction () {\n function ExternalSource() {}\n\n ExternalSource.prototype.getRawData = function () {\n // Only built-in transform available.\n throw new Error('not supported');\n };\n\n ExternalSource.prototype.getRawDataItem = function (dataIndex) {\n // Only built-in transform available.\n throw new Error('not supported');\n };\n\n ExternalSource.prototype.cloneRawData = function () {\n return;\n };\n /**\n * @return If dimension not found, return null/undefined.\n */\n\n\n ExternalSource.prototype.getDimensionInfo = function (dim) {\n return;\n };\n /**\n * dimensions defined if and only if either:\n * (a) dataset.dimensions are declared.\n * (b) dataset data include dimensions definitions in data (detected or via specified `sourceHeader`).\n * If dimensions are defined, `dimensionInfoAll` is corresponding to\n * the defined dimensions.\n * Otherwise, `dimensionInfoAll` is determined by data columns.\n * @return Always return an array (even empty array).\n */\n\n\n ExternalSource.prototype.cloneAllDimensionInfo = function () {\n return;\n };\n\n ExternalSource.prototype.count = function () {\n return;\n };\n /**\n * Only support by dimension index.\n * No need to support by dimension name in transform function,\n * becuase transform function is not case-specific, no need to use name literally.\n */\n\n\n ExternalSource.prototype.retrieveValue = function (dataIndex, dimIndex) {\n return;\n };\n\n ExternalSource.prototype.retrieveValueFromItem = function (dataItem, dimIndex) {\n return;\n };\n\n ExternalSource.prototype.convertValue = function (rawVal, dimInfo) {\n return parseDataValue(rawVal, dimInfo);\n };\n\n return ExternalSource;\n}();\n\nexport { ExternalSource };\n\nfunction createExternalSource(internalSource, externalTransform) {\n var extSource = new ExternalSource();\n var data = internalSource.data;\n var sourceFormat = extSource.sourceFormat = internalSource.sourceFormat;\n var sourceHeaderCount = internalSource.startIndex;\n var errMsg = '';\n\n if (internalSource.seriesLayoutBy !== SERIES_LAYOUT_BY_COLUMN) {\n // For the logic simplicity in transformer, only 'culumn' is\n // supported in data transform. Otherwise, the `dimensionsDefine`\n // might be detected by 'row', which probably confuses users.\n if (process.env.NODE_ENV !== 'production') {\n errMsg = '`seriesLayoutBy` of upstream dataset can only be \"column\" in data transform.';\n }\n\n throwError(errMsg);\n } // [MEMO]\n // Create a new dimensions structure for exposing.\n // Do not expose all dimension info to users directly.\n // Becuase the dimension is probably auto detected from data and not might reliable.\n // Should not lead the transformers to think that is relialbe and return it.\n // See [DIMENSION_INHERIT_RULE] in `sourceManager.ts`.\n\n\n var dimensions = [];\n var dimsByName = {};\n var dimsDef = internalSource.dimensionsDefine;\n\n if (dimsDef) {\n each(dimsDef, function (dimDef, idx) {\n var name = dimDef.name;\n var dimDefExt = {\n index: idx,\n name: name,\n displayName: dimDef.displayName\n };\n dimensions.push(dimDefExt); // Users probably not sepcify dimension name. For simplicity, data transform\n // do not generate dimension name.\n\n if (name != null) {\n // Dimension name should not be duplicated.\n // For simplicity, data transform forbid name duplication, do not generate\n // new name like module `completeDimensions.ts` did, but just tell users.\n var errMsg_1 = '';\n\n if (hasOwn(dimsByName, name)) {\n if (process.env.NODE_ENV !== 'production') {\n errMsg_1 = 'dimension name \"' + name + '\" duplicated.';\n }\n\n throwError(errMsg_1);\n }\n\n dimsByName[name] = dimDefExt;\n }\n });\n } // If dimension definitions are not defined and can not be detected.\n // e.g., pure data `[[11, 22], ...]`.\n else {\n for (var i = 0; i < internalSource.dimensionsDetectedCount || 0; i++) {\n // Do not generete name or anything others. The consequence process in\n // `transform` or `series` probably have there own name generation strategry.\n dimensions.push({\n index: i\n });\n }\n } // Implement public methods:\n\n\n var rawItemGetter = getRawSourceItemGetter(sourceFormat, SERIES_LAYOUT_BY_COLUMN);\n\n if (externalTransform.__isBuiltIn) {\n extSource.getRawDataItem = function (dataIndex) {\n return rawItemGetter(data, sourceHeaderCount, dimensions, dataIndex);\n };\n\n extSource.getRawData = bind(getRawData, null, internalSource);\n }\n\n extSource.cloneRawData = bind(cloneRawData, null, internalSource);\n var rawCounter = getRawSourceDataCounter(sourceFormat, SERIES_LAYOUT_BY_COLUMN);\n extSource.count = bind(rawCounter, null, data, sourceHeaderCount, dimensions);\n var rawValueGetter = getRawSourceValueGetter(sourceFormat);\n\n extSource.retrieveValue = function (dataIndex, dimIndex) {\n var rawItem = rawItemGetter(data, sourceHeaderCount, dimensions, dataIndex);\n return retrieveValueFromItem(rawItem, dimIndex);\n };\n\n var retrieveValueFromItem = extSource.retrieveValueFromItem = function (dataItem, dimIndex) {\n if (dataItem == null) {\n return;\n }\n\n var dimDef = dimensions[dimIndex]; // When `dimIndex` is `null`, `rawValueGetter` return the whole item.\n\n if (dimDef) {\n return rawValueGetter(dataItem, dimIndex, dimDef.name);\n }\n };\n\n extSource.getDimensionInfo = bind(getDimensionInfo, null, dimensions, dimsByName);\n extSource.cloneAllDimensionInfo = bind(cloneAllDimensionInfo, null, dimensions);\n return extSource;\n}\n\nfunction getRawData(upstream) {\n var sourceFormat = upstream.sourceFormat;\n\n if (!isSupportedSourceFormat(sourceFormat)) {\n var errMsg = '';\n\n if (process.env.NODE_ENV !== 'production') {\n errMsg = '`getRawData` is not supported in source format ' + sourceFormat;\n }\n\n throwError(errMsg);\n }\n\n return upstream.data;\n}\n\nfunction cloneRawData(upstream) {\n var sourceFormat = upstream.sourceFormat;\n var data = upstream.data;\n\n if (!isSupportedSourceFormat(sourceFormat)) {\n var errMsg = '';\n\n if (process.env.NODE_ENV !== 'production') {\n errMsg = '`cloneRawData` is not supported in source format ' + sourceFormat;\n }\n\n throwError(errMsg);\n }\n\n if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {\n var result = [];\n\n for (var i = 0, len = data.length; i < len; i++) {\n // Not strictly clone for performance\n result.push(data[i].slice());\n }\n\n return result;\n } else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {\n var result = [];\n\n for (var i = 0, len = data.length; i < len; i++) {\n // Not strictly clone for performance\n result.push(extend({}, data[i]));\n }\n\n return result;\n }\n}\n\nfunction getDimensionInfo(dimensions, dimsByName, dim) {\n if (dim == null) {\n return;\n } // Keep the same logic as `List::getDimension` did.\n\n\n if (typeof dim === 'number' // If being a number-like string but not being defined a dimension name.\n || !isNaN(dim) && !hasOwn(dimsByName, dim)) {\n return dimensions[dim];\n } else if (hasOwn(dimsByName, dim)) {\n return dimsByName[dim];\n }\n}\n\nfunction cloneAllDimensionInfo(dimensions) {\n return clone(dimensions);\n}\n\nvar externalTransformMap = createHashMap();\nexport function registerExternalTransform(externalTransform) {\n externalTransform = clone(externalTransform);\n var type = externalTransform.type;\n var errMsg = '';\n\n if (!type) {\n if (process.env.NODE_ENV !== 'production') {\n errMsg = 'Must have a `type` when `registerTransform`.';\n }\n\n throwError(errMsg);\n }\n\n var typeParsed = type.split(':');\n\n if (typeParsed.length !== 2) {\n if (process.env.NODE_ENV !== 'production') {\n errMsg = 'Name must include namespace like \"ns:regression\".';\n }\n\n throwError(errMsg);\n } // Namespace 'echarts:xxx' is official namespace, where the transforms should\n // be called directly via 'xxx' rather than 'echarts:xxx'.\n\n\n var isBuiltIn = false;\n\n if (typeParsed[0] === 'echarts') {\n type = typeParsed[1];\n isBuiltIn = true;\n }\n\n externalTransform.__isBuiltIn = isBuiltIn;\n externalTransformMap.set(type, externalTransform);\n}\nexport function applyDataTransform(rawTransOption, sourceList, infoForPrint) {\n var pipedTransOption = normalizeToArray(rawTransOption);\n var pipeLen = pipedTransOption.length;\n var errMsg = '';\n\n if (!pipeLen) {\n if (process.env.NODE_ENV !== 'production') {\n errMsg = 'If `transform` declared, it should at least contain one transform.';\n }\n\n throwError(errMsg);\n }\n\n for (var i = 0, len = pipeLen; i < len; i++) {\n var transOption = pipedTransOption[i];\n sourceList = applySingleDataTransform(transOption, sourceList, infoForPrint, pipeLen === 1 ? null : i); // piped transform only support single input, except the fist one.\n // piped transform only support single output, except the last one.\n\n if (i !== len - 1) {\n sourceList.length = Math.max(sourceList.length, 1);\n }\n }\n\n return sourceList;\n}\n\nfunction applySingleDataTransform(transOption, upSourceList, infoForPrint, // If `pipeIndex` is null/undefined, no piped transform.\npipeIndex) {\n var errMsg = '';\n\n if (!upSourceList.length) {\n if (process.env.NODE_ENV !== 'production') {\n errMsg = 'Must have at least one upstream dataset.';\n }\n\n throwError(errMsg);\n }\n\n if (!isObject(transOption)) {\n if (process.env.NODE_ENV !== 'production') {\n errMsg = 'transform declaration must be an object rather than ' + typeof transOption + '.';\n }\n\n throwError(errMsg);\n }\n\n var transType = transOption.type;\n var externalTransform = externalTransformMap.get(transType);\n\n if (!externalTransform) {\n if (process.env.NODE_ENV !== 'production') {\n errMsg = 'Can not find transform on type \"' + transType + '\".';\n }\n\n throwError(errMsg);\n } // Prepare source\n\n\n var extUpSourceList = map(upSourceList, function (upSource) {\n return createExternalSource(upSource, externalTransform);\n });\n var resultList = normalizeToArray(externalTransform.transform({\n upstream: extUpSourceList[0],\n upstreamList: extUpSourceList,\n config: clone(transOption.config)\n }));\n\n if (process.env.NODE_ENV !== 'production') {\n if (transOption.print) {\n var printStrArr = map(resultList, function (extSource) {\n var pipeIndexStr = pipeIndex != null ? ' === pipe index: ' + pipeIndex : '';\n return ['=== dataset index: ' + infoForPrint.datasetIndex + pipeIndexStr + ' ===', '- transform result data:', makePrintable(extSource.data), '- transform result dimensions:', makePrintable(extSource.dimensions)].join('\\n');\n }).join('\\n');\n consoleLog(printStrArr);\n }\n }\n\n return map(resultList, function (result, resultIndex) {\n var errMsg = '';\n\n if (!isObject(result)) {\n if (process.env.NODE_ENV !== 'production') {\n errMsg = 'A transform should not return some empty results.';\n }\n\n throwError(errMsg);\n }\n\n if (!result.data) {\n if (process.env.NODE_ENV !== 'production') {\n errMsg = 'Transform result data should be not be null or undefined';\n }\n\n throwError(errMsg);\n }\n\n var sourceFormat = detectSourceFormat(result.data);\n\n if (!isSupportedSourceFormat(sourceFormat)) {\n if (process.env.NODE_ENV !== 'production') {\n errMsg = 'Transform result data should be array rows or object rows.';\n }\n\n throwError(errMsg);\n }\n\n var resultMetaRawOption;\n var firstUpSource = upSourceList[0];\n /**\n * Intuitively, the end users known the content of the original `dataset.source`,\n * calucating the transform result in mind.\n * Suppose the original `dataset.source` is:\n * ```js\n * [\n * ['product', '2012', '2013', '2014', '2015'],\n * ['AAA', 41.1, 30.4, 65.1, 53.3],\n * ['BBB', 86.5, 92.1, 85.7, 83.1],\n * ['CCC', 24.1, 67.2, 79.5, 86.4]\n * ]\n * ```\n * The dimension info have to be detected from the source data.\n * Some of the transformers (like filter, sort) will follow the dimension info\n * of upstream, while others use new dimensions (like aggregate).\n * Transformer can output a field `dimensions` to define the its own output dimensions.\n * We also allow transformers to ignore the output `dimensions` field, and\n * inherit the upstream dimensions definition. It can reduce the burden of handling\n * dimensions in transformers.\n *\n * See also [DIMENSION_INHERIT_RULE] in `sourceManager.ts`.\n */\n\n if (firstUpSource && resultIndex === 0 // If transformer returns `dimensions`, it means that the transformer has different\n // dimensions definitions. We do not inherit anything from upstream.\n && !result.dimensions) {\n var startIndex = firstUpSource.startIndex; // We copy the header of upstream to the result becuase:\n // (1) The returned data always does not contain header line and can not be used\n // as dimension-detection. In this case we can not use \"detected dimensions\" of\n // upstream directly, because it might be detected based on different `seriesLayoutBy`.\n // (2) We should support that the series read the upstream source in `seriesLayoutBy: 'row'`.\n // So the original detected header should be add to the result, otherwise they can not be read.\n\n if (startIndex) {\n result.data = firstUpSource.data.slice(0, startIndex).concat(result.data);\n }\n\n resultMetaRawOption = {\n seriesLayoutBy: SERIES_LAYOUT_BY_COLUMN,\n sourceHeader: startIndex,\n dimensions: firstUpSource.metaRawOption.dimensions\n };\n } else {\n resultMetaRawOption = {\n seriesLayoutBy: SERIES_LAYOUT_BY_COLUMN,\n sourceHeader: 0,\n dimensions: result.dimensions\n };\n }\n\n return createSource(result.data, resultMetaRawOption, null, null);\n });\n}\n\nfunction isSupportedSourceFormat(sourceFormat) {\n return sourceFormat === SOURCE_FORMAT_ARRAY_ROWS || sourceFormat === SOURCE_FORMAT_OBJECT_ROWS;\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { setAsPrimitive, map, isTypedArray, assert, each, retrieve2 } from 'zrender/lib/core/util';\nimport { createSource, cloneSourceShallow } from '../Source';\nimport { SOURCE_FORMAT_TYPED_ARRAY, SOURCE_FORMAT_ORIGINAL } from '../../util/types';\nimport { querySeriesUpstreamDatasetModel, queryDatasetUpstreamDatasetModels } from './sourceHelper';\nimport { applyDataTransform } from './transform';\n/**\n * [REQUIREMENT_MEMO]:\n * (0) `metaRawOption` means `dimensions`/`sourceHeader`/`seriesLayoutBy` in raw option.\n * (1) Keep support the feature: `metaRawOption` can be specified both on `series` and\n * `root-dataset`. Them on `series` has higher priority.\n * (2) Do not support to set `metaRawOption` on a `non-root-dataset`, because it might\n * confuse users: whether those props indicate how to visit the upstream source or visit\n * the transform result source, and some transforms has nothing to do with these props,\n * and some transforms might have multiple upstream.\n * (3) Transforms should specify `metaRawOption` in each output, just like they can be\n * declared in `root-dataset`.\n * (4) At present only support visit source in `SERIES_LAYOUT_BY_COLUMN` in transforms.\n * That is for reducing complexity in transfroms.\n * PENDING: Whether to provide transposition transform?\n *\n * [IMPLEMENTAION_MEMO]:\n * \"sourceVisitConfig\" are calculated from `metaRawOption` and `data`.\n * They will not be calculated until `source` is about to be visited (to prevent from\n * duplicate calcuation). `source` is visited only in series and input to transforms.\n *\n * [DIMENSION_INHERIT_RULE]:\n * By default the dimensions are inherited from ancestors, unless a transform return\n * a new dimensions definition.\n * Consider the case:\n * ```js\n * dataset: [{\n * source: [ ['Product', 'Sales', 'Prise'], ['Cookies', 321, 44.21], ...]\n * }, {\n * transform: { type: 'filter', ... }\n * }]\n * dataset: [{\n * dimension: ['Product', 'Sales', 'Prise'],\n * source: [ ['Cookies', 321, 44.21], ...]\n * }, {\n * transform: { type: 'filter', ... }\n * }]\n * ```\n * The two types of option should have the same behavior after transform.\n *\n *\n * [SCENARIO]:\n * (1) Provide source data directly:\n * ```js\n * series: {\n * encode: {...},\n * dimensions: [...]\n * seriesLayoutBy: 'row',\n * data: [[...]]\n * }\n * ```\n * (2) Series refer to dataset.\n * ```js\n * series: [{\n * encode: {...}\n * // Ignore datasetIndex means `datasetIndex: 0`\n * // and the dimensions defination in dataset is used\n * }, {\n * encode: {...},\n * seriesLayoutBy: 'column',\n * datasetIndex: 1\n * }]\n * ```\n * (3) dataset transform\n * ```js\n * dataset: [{\n * source: [...]\n * }, {\n * source: [...]\n * }, {\n * // By default from 0.\n * transform: { type: 'filter', config: {...} }\n * }, {\n * // Piped.\n * transform: [\n * { type: 'filter', config: {...} },\n * { type: 'sort', config: {...} }\n * ]\n * }, {\n * id: 'regressionData',\n * fromDatasetIndex: 1,\n * // Third-party transform\n * transform: { type: 'ecStat:regression', config: {...} }\n * }, {\n * // retrieve the extra result.\n * id: 'regressionFormula',\n * fromDatasetId: 'regressionData',\n * fromTransformResult: 1\n * }]\n * ```\n */\n\nvar SourceManager =\n/** @class */\nfunction () {\n function SourceManager(sourceHost) {\n // Cached source. Do not repeat calculating if not dirty.\n this._sourceList = []; // version sign of each upstream source manager.\n\n this._upstreamSignList = [];\n this._versionSignBase = 0;\n this._sourceHost = sourceHost;\n }\n /**\n * Mark dirty.\n */\n\n\n SourceManager.prototype.dirty = function () {\n this._setLocalSource([], []);\n };\n\n SourceManager.prototype._setLocalSource = function (sourceList, upstreamSignList) {\n this._sourceList = sourceList;\n this._upstreamSignList = upstreamSignList;\n this._versionSignBase++;\n\n if (this._versionSignBase > 9e10) {\n this._versionSignBase = 0;\n }\n };\n /**\n * For detecting whether the upstream source is dirty, so that\n * the local cached source (in `_sourceList`) should be discarded.\n */\n\n\n SourceManager.prototype._getVersionSign = function () {\n return this._sourceHost.uid + '_' + this._versionSignBase;\n };\n /**\n * Always return a source instance. Otherwise throw error.\n */\n\n\n SourceManager.prototype.prepareSource = function () {\n // For the case that call `setOption` multiple time but no data changed,\n // cache the result source to prevent from repeating transform.\n if (this._isDirty()) {\n this._createSource();\n }\n };\n\n SourceManager.prototype._createSource = function () {\n this._setLocalSource([], []);\n\n var sourceHost = this._sourceHost;\n\n var upSourceMgrList = this._getUpstreamSourceManagers();\n\n var hasUpstream = !!upSourceMgrList.length;\n var resultSourceList;\n var upstreamSignList;\n\n if (isSeries(sourceHost)) {\n var seriesModel = sourceHost;\n var data = void 0;\n var sourceFormat = void 0;\n var upSource = void 0; // Has upstream dataset\n\n if (hasUpstream) {\n var upSourceMgr = upSourceMgrList[0];\n upSourceMgr.prepareSource();\n upSource = upSourceMgr.getSource();\n data = upSource.data;\n sourceFormat = upSource.sourceFormat;\n upstreamSignList = [upSourceMgr._getVersionSign()];\n } // Series data is from own.\n else {\n data = seriesModel.get('data', true);\n sourceFormat = isTypedArray(data) ? SOURCE_FORMAT_TYPED_ARRAY : SOURCE_FORMAT_ORIGINAL;\n upstreamSignList = [];\n } // See [REQUIREMENT_MEMO], merge settings on series and parent dataset if it is root.\n\n\n var newMetaRawOption = this._getSourceMetaRawOption();\n\n var upMetaRawOption = upSource ? upSource.metaRawOption : null;\n var seriesLayoutBy = retrieve2(newMetaRawOption.seriesLayoutBy, upMetaRawOption ? upMetaRawOption.seriesLayoutBy : null);\n var sourceHeader = retrieve2(newMetaRawOption.sourceHeader, upMetaRawOption ? upMetaRawOption.sourceHeader : null); // Note here we should not use `upSource.dimensionsDefine`. Consider the case:\n // `upSource.dimensionsDefine` is detected by `seriesLayoutBy: 'column'`,\n // but series need `seriesLayoutBy: 'row'`.\n\n var dimensions = retrieve2(newMetaRawOption.dimensions, upMetaRawOption ? upMetaRawOption.dimensions : null);\n resultSourceList = [createSource(data, {\n seriesLayoutBy: seriesLayoutBy,\n sourceHeader: sourceHeader,\n dimensions: dimensions\n }, sourceFormat, seriesModel.get('encode', true))];\n } else {\n var datasetModel = sourceHost; // Has upstream dataset.\n\n if (hasUpstream) {\n var result = this._applyTransform(upSourceMgrList);\n\n resultSourceList = result.sourceList;\n upstreamSignList = result.upstreamSignList;\n } // Is root dataset.\n else {\n var sourceData = datasetModel.get('source', true);\n resultSourceList = [createSource(sourceData, this._getSourceMetaRawOption(), null, // Note: dataset option does not have `encode`.\n null)];\n upstreamSignList = [];\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert(resultSourceList && upstreamSignList);\n }\n\n this._setLocalSource(resultSourceList, upstreamSignList);\n };\n\n SourceManager.prototype._applyTransform = function (upMgrList) {\n var datasetModel = this._sourceHost;\n var transformOption = datasetModel.get('transform', true);\n var fromTransformResult = datasetModel.get('fromTransformResult', true);\n\n if (process.env.NODE_ENV !== 'production') {\n assert(fromTransformResult != null || transformOption != null);\n }\n\n if (fromTransformResult != null) {\n var errMsg = '';\n\n if (upMgrList.length !== 1) {\n if (process.env.NODE_ENV !== 'production') {\n errMsg = 'When using `fromTransformResult`, there should be only one upstream dataset';\n }\n\n doThrow(errMsg);\n }\n }\n\n var sourceList;\n var upSourceList = [];\n var upstreamSignList = [];\n each(upMgrList, function (upMgr) {\n upMgr.prepareSource();\n var upSource = upMgr.getSource(fromTransformResult || 0);\n var errMsg = '';\n\n if (fromTransformResult != null && !upSource) {\n if (process.env.NODE_ENV !== 'production') {\n errMsg = 'Can not retrieve result by `fromTransformResult`: ' + fromTransformResult;\n }\n\n doThrow(errMsg);\n }\n\n upSourceList.push(upSource);\n upstreamSignList.push(upMgr._getVersionSign());\n });\n\n if (transformOption) {\n sourceList = applyDataTransform(transformOption, upSourceList, {\n datasetIndex: datasetModel.componentIndex\n });\n } else if (fromTransformResult != null) {\n sourceList = [cloneSourceShallow(upSourceList[0])];\n }\n\n return {\n sourceList: sourceList,\n upstreamSignList: upstreamSignList\n };\n };\n\n SourceManager.prototype._isDirty = function () {\n var sourceList = this._sourceList;\n\n if (!sourceList.length) {\n return true;\n } // All sourceList is from the some upsteam.\n\n\n var upSourceMgrList = this._getUpstreamSourceManagers();\n\n for (var i = 0; i < upSourceMgrList.length; i++) {\n var upSrcMgr = upSourceMgrList[i];\n\n if ( // Consider the case that there is ancestor diry, call it recursively.\n // The performance is probably not an issue because usually the chain is not long.\n upSrcMgr._isDirty() || this._upstreamSignList[i] !== upSrcMgr._getVersionSign()) {\n return true;\n }\n }\n };\n /**\n * @param sourceIndex By defualt 0, means \"main source\".\n * Most cases there is only one source.\n */\n\n\n SourceManager.prototype.getSource = function (sourceIndex) {\n return this._sourceList[sourceIndex || 0];\n };\n /**\n * PEDING: Is it fast enough?\n * If no upstream, return empty array.\n */\n\n\n SourceManager.prototype._getUpstreamSourceManagers = function () {\n // Always get the relationship from the raw option.\n // Do not cache the link of the dependency graph, so that\n // no need to update them when change happen.\n var sourceHost = this._sourceHost;\n\n if (isSeries(sourceHost)) {\n var datasetModel = querySeriesUpstreamDatasetModel(sourceHost);\n return !datasetModel ? [] : [datasetModel.getSourceManager()];\n } else {\n return map(queryDatasetUpstreamDatasetModels(sourceHost), function (datasetModel) {\n return datasetModel.getSourceManager();\n });\n }\n };\n\n SourceManager.prototype._getSourceMetaRawOption = function () {\n var sourceHost = this._sourceHost;\n var seriesLayoutBy;\n var sourceHeader;\n var dimensions;\n\n if (isSeries(sourceHost)) {\n seriesLayoutBy = sourceHost.get('seriesLayoutBy', true);\n sourceHeader = sourceHost.get('sourceHeader', true);\n dimensions = sourceHost.get('dimensions', true);\n } // See [REQUIREMENT_MEMO], `non-root-dataset` do not support them.\n else if (!this._getUpstreamSourceManagers().length) {\n var model = sourceHost;\n seriesLayoutBy = model.get('seriesLayoutBy', true);\n sourceHeader = model.get('sourceHeader', true);\n dimensions = model.get('dimensions', true);\n }\n\n return {\n seriesLayoutBy: seriesLayoutBy,\n sourceHeader: sourceHeader,\n dimensions: dimensions\n };\n };\n\n return SourceManager;\n}();\n\nexport { SourceManager }; // Call this method after `super.init` and `super.mergeOption` to\n// disable the transform merge, but do not disable transfrom clone from rawOption.\n\nexport function disableTransformOptionMerge(datasetModel) {\n var transformOption = datasetModel.option.transform;\n transformOption && setAsPrimitive(datasetModel.option.transform);\n}\n\nfunction isSeries(sourceHost) {\n // Avoid circular dependency with Series.ts\n return sourceHost.mainType === 'series';\n}\n\nfunction doThrow(errMsg) {\n throw new Error(errMsg);\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { getTooltipMarker, encodeHTML, makeValueReadable, convertToColorString } from '../../util/format';\nimport { isString, each, hasOwn, isArray, map, assert, extend } from 'zrender/lib/core/util';\nimport { SortOrderComparator } from '../../data/helper/dataValueHelper';\nimport { getRandomIdBase } from '../../util/number';\nvar TOOLTIP_LINE_HEIGHT_CSS = 'line-height:1'; // TODO: more textStyle option\n\nfunction getTooltipTextStyle(textStyle, renderMode) {\n var nameFontColor = textStyle.color || '#6e7079';\n var nameFontSize = textStyle.fontSize || 12;\n var nameFontWeight = textStyle.fontWeight || '400';\n var valueFontColor = textStyle.color || '#464646';\n var valueFontSize = textStyle.fontSize || 14;\n var valueFontWeight = textStyle.fontWeight || '900';\n\n if (renderMode === 'html') {\n // `textStyle` is probably from user input, should be encoded to reduce security risk.\n return {\n // eslint-disable-next-line max-len\n nameStyle: \"font-size:\" + encodeHTML(nameFontSize + '') + \"px;color:\" + encodeHTML(nameFontColor) + \";font-weight:\" + encodeHTML(nameFontWeight + ''),\n // eslint-disable-next-line max-len\n valueStyle: \"font-size:\" + encodeHTML(valueFontSize + '') + \"px;color:\" + encodeHTML(valueFontColor) + \";font-weight:\" + encodeHTML(valueFontWeight + '')\n };\n } else {\n return {\n nameStyle: {\n fontSize: nameFontSize,\n fill: nameFontColor,\n fontWeight: nameFontWeight\n },\n valueStyle: {\n fontSize: valueFontSize,\n fill: valueFontColor,\n fontWeight: valueFontWeight\n }\n };\n }\n} // See `TooltipMarkupLayoutIntent['innerGapLevel']`.\n// (value from UI design)\n\n\nvar HTML_GAPS = [0, 10, 20, 30];\nvar RICH_TEXT_GAPS = ['', '\\n', '\\n\\n', '\\n\\n\\n']; // eslint-disable-next-line max-len\n\nexport function createTooltipMarkup(type, option) {\n option.type = type;\n return option;\n}\n\nfunction getBuilder(fragment) {\n return hasOwn(builderMap, fragment.type) && builderMap[fragment.type];\n}\n\nvar builderMap = {\n /**\n * A `section` block is like:\n * ```\n * header\n * subBlock\n * subBlock\n * ...\n * ```\n */\n section: {\n planLayout: function (fragment) {\n var subBlockLen = fragment.blocks.length;\n var thisBlockHasInnerGap = subBlockLen > 1 || subBlockLen > 0 && !fragment.noHeader;\n var thisGapLevelBetweenSubBlocks = 0;\n each(fragment.blocks, function (subBlock) {\n getBuilder(subBlock).planLayout(subBlock);\n var subGapLevel = subBlock.__gapLevelBetweenSubBlocks; // If the some of the sub-blocks have some gaps (like 10px) inside, this block\n // should use a larger gap (like 20px) to distinguish those sub-blocks.\n\n if (subGapLevel >= thisGapLevelBetweenSubBlocks) {\n thisGapLevelBetweenSubBlocks = subGapLevel + (thisBlockHasInnerGap && ( // 0 always can not be readable gap level.\n !subGapLevel // If no header, always keep the sub gap level. Otherwise\n // look weird in case `multipleSeries`.\n || subBlock.type === 'section' && !subBlock.noHeader) ? 1 : 0);\n }\n });\n fragment.__gapLevelBetweenSubBlocks = thisGapLevelBetweenSubBlocks;\n },\n build: function (ctx, fragment, topMarginForOuterGap, toolTipTextStyle) {\n var noHeader = fragment.noHeader;\n var gaps = getGap(fragment);\n var subMarkupText = buildSubBlocks(ctx, fragment, noHeader ? topMarginForOuterGap : gaps.html, toolTipTextStyle);\n\n if (noHeader) {\n return subMarkupText;\n }\n\n var displayableHeader = makeValueReadable(fragment.header, 'ordinal', ctx.useUTC);\n var nameStyle = getTooltipTextStyle(toolTipTextStyle, ctx.renderMode).nameStyle;\n\n if (ctx.renderMode === 'richText') {\n return wrapInlineNameRichText(ctx, displayableHeader, nameStyle) + gaps.richText + subMarkupText;\n } else {\n return wrapBlockHTML(\"\" + encodeHTML(displayableHeader) + '
' + subMarkupText, topMarginForOuterGap);\n }\n }\n },\n\n /**\n * A `nameValue` block is like:\n * ```\n * marker name value\n * ```\n */\n nameValue: {\n planLayout: function (fragment) {\n fragment.__gapLevelBetweenSubBlocks = 0;\n },\n build: function (ctx, fragment, topMarginForOuterGap, toolTipTextStyle) {\n var renderMode = ctx.renderMode;\n var noName = fragment.noName;\n var noValue = fragment.noValue;\n var noMarker = !fragment.markerType;\n var name = fragment.name;\n var value = fragment.value;\n var useUTC = ctx.useUTC;\n\n if (noName && noValue) {\n return;\n }\n\n var markerStr = noMarker ? '' : ctx.markupStyleCreator.makeTooltipMarker(fragment.markerType, fragment.markerColor || '#333', renderMode);\n var readableName = noName ? '' : makeValueReadable(name, 'ordinal', useUTC);\n var valueTypeOption = fragment.valueType;\n var readableValueList = noValue ? [] : isArray(value) ? map(value, function (val, idx) {\n return makeValueReadable(val, isArray(valueTypeOption) ? valueTypeOption[idx] : valueTypeOption, useUTC);\n }) : [makeValueReadable(value, isArray(valueTypeOption) ? valueTypeOption[0] : valueTypeOption, useUTC)];\n var valueAlignRight = !noMarker || !noName; // It little weird if only value next to marker but far from marker.\n\n var valueCloseToMarker = !noMarker && noName;\n\n var _a = getTooltipTextStyle(toolTipTextStyle, renderMode),\n nameStyle = _a.nameStyle,\n valueStyle = _a.valueStyle;\n\n return renderMode === 'richText' ? (noMarker ? '' : markerStr) + (noName ? '' : wrapInlineNameRichText(ctx, readableName, nameStyle)) // Value has commas inside, so use ' ' as delimiter for multiple values.\n + (noValue ? '' : wrapInlineValueRichText(ctx, readableValueList, valueAlignRight, valueCloseToMarker, valueStyle)) : wrapBlockHTML((noMarker ? '' : markerStr) + (noName ? '' : wrapInlineNameHTML(readableName, !noMarker, nameStyle)) + (noValue ? '' : wrapInlineValueHTML(readableValueList, valueAlignRight, valueCloseToMarker, valueStyle)), topMarginForOuterGap);\n }\n }\n};\n\nfunction buildSubBlocks(ctx, fragment, topMarginForOuterGap, tooltipTextStyle) {\n var subMarkupTextList = [];\n var subBlocks = fragment.blocks || [];\n assert(!subBlocks || isArray(subBlocks));\n subBlocks = subBlocks || [];\n var orderMode = ctx.orderMode;\n\n if (fragment.sortBlocks && orderMode) {\n subBlocks = subBlocks.slice();\n var orderMap = {\n valueAsc: 'asc',\n valueDesc: 'desc'\n };\n\n if (hasOwn(orderMap, orderMode)) {\n var comparator_1 = new SortOrderComparator(orderMap[orderMode], null);\n subBlocks.sort(function (a, b) {\n return comparator_1.evaluate(a.sortParam, b.sortParam);\n });\n } // FIXME 'seriesDesc' necessary?\n else if (orderMode === 'seriesDesc') {\n subBlocks.reverse();\n }\n }\n\n var gaps = getGap(fragment);\n each(subBlocks, function (subBlock, idx) {\n var subMarkupText = getBuilder(subBlock).build(ctx, subBlock, idx > 0 ? gaps.html : 0, tooltipTextStyle);\n subMarkupText != null && subMarkupTextList.push(subMarkupText);\n });\n\n if (!subMarkupTextList.length) {\n return;\n }\n\n return ctx.renderMode === 'richText' ? subMarkupTextList.join(gaps.richText) : wrapBlockHTML(subMarkupTextList.join(''), topMarginForOuterGap);\n}\n/**\n * @return markupText. null/undefined means no content.\n */\n\n\nexport function buildTooltipMarkup(fragment, markupStyleCreator, renderMode, orderMode, useUTC, toolTipTextStyle) {\n if (!fragment) {\n return;\n }\n\n var builder = getBuilder(fragment);\n builder.planLayout(fragment);\n var ctx = {\n useUTC: useUTC,\n renderMode: renderMode,\n orderMode: orderMode,\n markupStyleCreator: markupStyleCreator\n };\n return builder.build(ctx, fragment, 0, toolTipTextStyle);\n}\n\nfunction getGap(fragment) {\n var gapLevelBetweenSubBlocks = fragment.__gapLevelBetweenSubBlocks;\n return {\n html: HTML_GAPS[gapLevelBetweenSubBlocks],\n richText: RICH_TEXT_GAPS[gapLevelBetweenSubBlocks]\n };\n}\n\nfunction wrapBlockHTML(encodedContent, topGap) {\n var clearfix = '';\n var marginCSS = \"margin: \" + topGap + \"px 0 0\";\n return \"\" + encodedContent + clearfix + '
';\n}\n\nfunction wrapInlineNameHTML(name, leftHasMarker, style) {\n var marginCss = leftHasMarker ? 'margin-left:2px' : '';\n return \"\" + encodeHTML(name) + '';\n}\n\nfunction wrapInlineValueHTML(valueList, alignRight, valueCloseToMarker, style) {\n // Do not too close to marker, considering there are multiple values separated by spaces.\n var paddingStr = valueCloseToMarker ? '10px' : '20px';\n var alignCSS = alignRight ? \"float:right;margin-left:\" + paddingStr : '';\n return \"\" // Value has commas inside, so use ' ' as delimiter for multiple values.\n + map(valueList, function (value) {\n return encodeHTML(value);\n }).join(' ') + '';\n}\n\nfunction wrapInlineNameRichText(ctx, name, style) {\n return ctx.markupStyleCreator.wrapRichTextStyle(name, style);\n}\n\nfunction wrapInlineValueRichText(ctx, valueList, alignRight, valueCloseToMarker, style) {\n var styles = [style];\n var paddingLeft = valueCloseToMarker ? 10 : 20;\n alignRight && styles.push({\n padding: [0, 0, 0, paddingLeft],\n align: 'right'\n }); // Value has commas inside, so use ' ' as delimiter for multiple values.\n\n return ctx.markupStyleCreator.wrapRichTextStyle(valueList.join(' '), styles);\n}\n\nexport function retrieveVisualColorForTooltipMarker(series, dataIndex) {\n var style = series.getData().getItemVisual(dataIndex, 'style');\n var color = style[series.visualDrawType];\n return convertToColorString(color);\n}\nexport function getPaddingFromTooltipModel(model, renderMode) {\n var padding = model.get('padding');\n return padding != null ? padding // We give slightly different to look pretty.\n : renderMode === 'richText' ? [8, 10] : 10;\n}\n/**\n * The major feature is generate styles for `renderMode: 'richText'`.\n * But it also serves `renderMode: 'html'` to provide\n * \"renderMode-independent\" API.\n */\n\nvar TooltipMarkupStyleCreator =\n/** @class */\nfunction () {\n function TooltipMarkupStyleCreator() {\n this.richTextStyles = {}; // Notice that \"generate a style name\" usuall happens repeatly when mouse moving and\n // displaying a tooltip. So we put the `_nextStyleNameId` as a member of each creator\n // rather than static shared by all creators (which will cause it increase to fast).\n\n this._nextStyleNameId = getRandomIdBase();\n }\n\n TooltipMarkupStyleCreator.prototype._generateStyleName = function () {\n return '__EC_aUTo_' + this._nextStyleNameId++;\n };\n\n TooltipMarkupStyleCreator.prototype.makeTooltipMarker = function (markerType, colorStr, renderMode) {\n var markerId = renderMode === 'richText' ? this._generateStyleName() : null;\n var marker = getTooltipMarker({\n color: colorStr,\n type: markerType,\n renderMode: renderMode,\n markerId: markerId\n });\n\n if (isString(marker)) {\n return marker;\n } else {\n if (process.env.NODE_ENV !== 'production') {\n assert(markerId);\n }\n\n this.richTextStyles[markerId] = marker.style;\n return marker.content;\n }\n };\n /**\n * @usage\n * ```ts\n * const styledText = markupStyleCreator.wrapRichTextStyle([\n * // The styles will be auto merged.\n * {\n * fontSize: 12,\n * color: 'blue'\n * },\n * {\n * padding: 20\n * }\n * ]);\n * ```\n */\n\n\n TooltipMarkupStyleCreator.prototype.wrapRichTextStyle = function (text, styles) {\n var finalStl = {};\n\n if (isArray(styles)) {\n each(styles, function (stl) {\n return extend(finalStl, stl);\n });\n } else {\n extend(finalStl, styles);\n }\n\n var styleName = this._generateStyleName();\n\n this.richTextStyles[styleName] = finalStl;\n return \"{\" + styleName + \"|\" + text + \"}\";\n };\n\n return TooltipMarkupStyleCreator;\n}();\n\nexport { TooltipMarkupStyleCreator };","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { trim, isArray, each, reduce } from 'zrender/lib/core/util';\nimport { retrieveVisualColorForTooltipMarker, createTooltipMarkup } from './tooltipMarkup';\nimport { retrieveRawValue } from '../../data/helper/dataProvider';\nimport { isNameSpecified } from '../../util/model';\nexport function defaultSeriesFormatTooltip(opt) {\n var series = opt.series;\n var dataIndex = opt.dataIndex;\n var multipleSeries = opt.multipleSeries;\n var data = series.getData();\n var tooltipDims = data.mapDimensionsAll('defaultedTooltip');\n var tooltipDimLen = tooltipDims.length;\n var value = series.getRawValue(dataIndex);\n var isValueArr = isArray(value);\n var markerColor = retrieveVisualColorForTooltipMarker(series, dataIndex); // Complicated rule for pretty tooltip.\n\n var inlineValue;\n var inlineValueType;\n var subBlocks;\n var sortParam;\n\n if (tooltipDimLen > 1 || isValueArr && !tooltipDimLen) {\n var formatArrResult = formatTooltipArrayValue(value, series, dataIndex, tooltipDims, markerColor);\n inlineValue = formatArrResult.inlineValues;\n inlineValueType = formatArrResult.inlineValueTypes;\n subBlocks = formatArrResult.blocks; // Only support tooltip sort by the first inline value. It's enough in most cases.\n\n sortParam = formatArrResult.inlineValues[0];\n } else if (tooltipDimLen) {\n var dimInfo = data.getDimensionInfo(tooltipDims[0]);\n sortParam = inlineValue = retrieveRawValue(data, dataIndex, tooltipDims[0]);\n inlineValueType = dimInfo.type;\n } else {\n sortParam = inlineValue = isValueArr ? value[0] : value;\n } // Do not show generated series name. It might not be readable.\n\n\n var seriesNameSpecified = isNameSpecified(series);\n var seriesName = seriesNameSpecified && series.name || '';\n var itemName = data.getName(dataIndex);\n var inlineName = multipleSeries ? seriesName : itemName;\n return createTooltipMarkup('section', {\n header: seriesName,\n // When series name not specified, do not show a header line with only '-'.\n // This case alway happen in tooltip.trigger: 'item'.\n noHeader: multipleSeries || !seriesNameSpecified,\n sortParam: sortParam,\n blocks: [createTooltipMarkup('nameValue', {\n markerType: 'item',\n markerColor: markerColor,\n // Do not mix display seriesName and itemName in one tooltip,\n // which might confuses users.\n name: inlineName,\n // name dimension might be auto assigned, where the name might\n // be not readable. So we check trim here.\n noName: !trim(inlineName),\n value: inlineValue,\n valueType: inlineValueType\n })].concat(subBlocks || [])\n });\n}\n\nfunction formatTooltipArrayValue(value, series, dataIndex, tooltipDims, colorStr) {\n // check: category-no-encode-has-axis-data in dataset.html\n var data = series.getData();\n var isValueMultipleLine = reduce(value, function (isValueMultipleLine, val, idx) {\n var dimItem = data.getDimensionInfo(idx);\n return isValueMultipleLine = isValueMultipleLine || dimItem && dimItem.tooltip !== false && dimItem.displayName != null;\n }, false);\n var inlineValues = [];\n var inlineValueTypes = [];\n var blocks = [];\n tooltipDims.length ? each(tooltipDims, function (dim) {\n setEachItem(retrieveRawValue(data, dataIndex, dim), dim);\n }) // By default, all dims is used on tooltip.\n : each(value, setEachItem);\n\n function setEachItem(val, dim) {\n var dimInfo = data.getDimensionInfo(dim); // If `dimInfo.tooltip` is not set, show tooltip.\n\n if (!dimInfo || dimInfo.otherDims.tooltip === false) {\n return;\n }\n\n if (isValueMultipleLine) {\n blocks.push(createTooltipMarkup('nameValue', {\n markerType: 'subItem',\n markerColor: colorStr,\n name: dimInfo.displayName,\n value: val,\n valueType: dimInfo.type\n }));\n } else {\n inlineValues.push(val);\n inlineValueTypes.push(dimInfo.type);\n }\n }\n\n return {\n inlineValues: inlineValues,\n inlineValueTypes: inlineValueTypes,\n blocks: blocks\n };\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { __extends, __spreadArrays } from \"tslib\";\nimport * as zrUtil from 'zrender/lib/core/util';\nimport env from 'zrender/lib/core/env';\nimport * as modelUtil from '../util/model';\nimport ComponentModel from './Component';\nimport { PaletteMixin } from './mixin/palette';\nimport { DataFormatMixin } from '../model/mixin/dataFormat';\nimport { getLayoutParams, mergeLayoutParam, fetchLayoutMode } from '../util/layout';\nimport { createTask } from '../core/task';\nimport { mountExtend } from '../util/clazz';\nimport { SourceManager } from '../data/helper/sourceManager';\nimport { defaultSeriesFormatTooltip } from '../component/tooltip/seriesFormatTooltip';\nvar inner = modelUtil.makeInner();\n\nfunction getSelectionKey(data, dataIndex) {\n return data.getName(dataIndex) || data.getId(dataIndex);\n}\n\nvar SeriesModel =\n/** @class */\nfunction (_super) {\n __extends(SeriesModel, _super);\n\n function SeriesModel() {\n // [Caution]: Becuase this class or desecendants can be used as `XXX.extend(subProto)`,\n // the class members must not be initialized in constructor or declaration place.\n // Otherwise there is bad case:\n // class A {xxx = 1;}\n // enableClassExtend(A);\n // class B extends A {}\n // var C = B.extend({xxx: 5});\n // var c = new C();\n // console.log(c.xxx); // expect 5 but always 1.\n var _this = _super !== null && _super.apply(this, arguments) || this; // ---------------------------------------\n // Props about data selection\n // ---------------------------------------\n\n\n _this._selectedDataIndicesMap = {};\n return _this;\n }\n\n SeriesModel.prototype.init = function (option, parentModel, ecModel) {\n this.seriesIndex = this.componentIndex;\n this.dataTask = createTask({\n count: dataTaskCount,\n reset: dataTaskReset\n });\n this.dataTask.context = {\n model: this\n };\n this.mergeDefaultAndTheme(option, ecModel);\n var sourceManager = inner(this).sourceManager = new SourceManager(this);\n sourceManager.prepareSource();\n var data = this.getInitialData(option, ecModel);\n wrapData(data, this);\n this.dataTask.context.data = data;\n\n if (process.env.NODE_ENV !== 'production') {\n zrUtil.assert(data, 'getInitialData returned invalid data.');\n }\n\n inner(this).dataBeforeProcessed = data; // If we reverse the order (make data firstly, and then make\n // dataBeforeProcessed by cloneShallow), cloneShallow will\n // cause data.graph.data !== data when using\n // module:echarts/data/Graph or module:echarts/data/Tree.\n // See module:echarts/data/helper/linkList\n // Theoretically, it is unreasonable to call `seriesModel.getData()` in the model\n // init or merge stage, because the data can be restored. So we do not `restoreData`\n // and `setData` here, which forbids calling `seriesModel.getData()` in this stage.\n // Call `seriesModel.getRawData()` instead.\n // this.restoreData();\n\n autoSeriesName(this);\n\n this._initSelectedMapFromData(data);\n };\n /**\n * Util for merge default and theme to option\n */\n\n\n SeriesModel.prototype.mergeDefaultAndTheme = function (option, ecModel) {\n var layoutMode = fetchLayoutMode(this);\n var inputPositionParams = layoutMode ? getLayoutParams(option) : {}; // Backward compat: using subType on theme.\n // But if name duplicate between series subType\n // (for example: parallel) add component mainType,\n // add suffix 'Series'.\n\n var themeSubType = this.subType;\n\n if (ComponentModel.hasClass(themeSubType)) {\n themeSubType += 'Series';\n }\n\n zrUtil.merge(option, ecModel.getTheme().get(this.subType));\n zrUtil.merge(option, this.getDefaultOption()); // Default label emphasis `show`\n\n modelUtil.defaultEmphasis(option, 'label', ['show']);\n this.fillDataTextStyle(option.data);\n\n if (layoutMode) {\n mergeLayoutParam(option, inputPositionParams, layoutMode);\n }\n };\n\n SeriesModel.prototype.mergeOption = function (newSeriesOption, ecModel) {\n // this.settingTask.dirty();\n newSeriesOption = zrUtil.merge(this.option, newSeriesOption, true);\n this.fillDataTextStyle(newSeriesOption.data);\n var layoutMode = fetchLayoutMode(this);\n\n if (layoutMode) {\n mergeLayoutParam(this.option, newSeriesOption, layoutMode);\n }\n\n var sourceManager = inner(this).sourceManager;\n sourceManager.dirty();\n sourceManager.prepareSource();\n var data = this.getInitialData(newSeriesOption, ecModel);\n wrapData(data, this);\n this.dataTask.dirty();\n this.dataTask.context.data = data;\n inner(this).dataBeforeProcessed = data;\n autoSeriesName(this);\n\n this._initSelectedMapFromData(data);\n };\n\n SeriesModel.prototype.fillDataTextStyle = function (data) {\n // Default data label emphasis `show`\n // FIXME Tree structure data ?\n // FIXME Performance ?\n if (data && !zrUtil.isTypedArray(data)) {\n var props = ['show'];\n\n for (var i = 0; i < data.length; i++) {\n if (data[i] && data[i].label) {\n modelUtil.defaultEmphasis(data[i], 'label', props);\n }\n }\n }\n };\n /**\n * Init a data structure from data related option in series\n * Must be overriden.\n */\n\n\n SeriesModel.prototype.getInitialData = function (option, ecModel) {\n return;\n };\n /**\n * Append data to list\n */\n\n\n SeriesModel.prototype.appendData = function (params) {\n // FIXME ???\n // (1) If data from dataset, forbidden append.\n // (2) support append data of dataset.\n var data = this.getRawData();\n data.appendData(params.data);\n };\n /**\n * Consider some method like `filter`, `map` need make new data,\n * We should make sure that `seriesModel.getData()` get correct\n * data in the stream procedure. So we fetch data from upstream\n * each time `task.perform` called.\n */\n\n\n SeriesModel.prototype.getData = function (dataType) {\n var task = getCurrentTask(this);\n\n if (task) {\n var data = task.context.data;\n return dataType == null ? data : data.getLinkedData(dataType);\n } else {\n // When series is not alive (that may happen when click toolbox\n // restore or setOption with not merge mode), series data may\n // be still need to judge animation or something when graphic\n // elements want to know whether fade out.\n return inner(this).data;\n }\n };\n\n SeriesModel.prototype.getAllData = function () {\n var mainData = this.getData();\n return mainData && mainData.getLinkedDataAll ? mainData.getLinkedDataAll() : [{\n data: mainData\n }];\n };\n\n SeriesModel.prototype.setData = function (data) {\n var task = getCurrentTask(this);\n\n if (task) {\n var context = task.context; // Consider case: filter, data sample.\n // FIXME:TS never used, so comment it\n // if (context.data !== data && task.modifyOutputEnd) {\n // task.setOutputEnd(data.count());\n // }\n\n context.outputData = data; // Caution: setData should update context.data,\n // Because getData may be called multiply in a\n // single stage and expect to get the data just\n // set. (For example, AxisProxy, x y both call\n // getData and setDate sequentially).\n // So the context.data should be fetched from\n // upstream each time when a stage starts to be\n // performed.\n\n if (task !== this.dataTask) {\n context.data = data;\n }\n }\n\n inner(this).data = data;\n };\n\n SeriesModel.prototype.getSource = function () {\n return inner(this).sourceManager.getSource();\n };\n /**\n * Get data before processed\n */\n\n\n SeriesModel.prototype.getRawData = function () {\n return inner(this).dataBeforeProcessed;\n };\n /**\n * Get base axis if has coordinate system and has axis.\n * By default use coordSys.getBaseAxis();\n * Can be overrided for some chart.\n * @return {type} description\n */\n\n\n SeriesModel.prototype.getBaseAxis = function () {\n var coordSys = this.coordinateSystem; // @ts-ignore\n\n return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis();\n };\n /**\n * Default tooltip formatter\n *\n * @param dataIndex\n * @param multipleSeries\n * @param dataType\n * @param renderMode valid values: 'html'(by default) and 'richText'.\n * 'html' is used for rendering tooltip in extra DOM form, and the result\n * string is used as DOM HTML content.\n * 'richText' is used for rendering tooltip in rich text form, for those where\n * DOM operation is not supported.\n * @return formatted tooltip with `html` and `markers`\n * Notice: The override method can also return string\n */\n\n\n SeriesModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {\n return defaultSeriesFormatTooltip({\n series: this,\n dataIndex: dataIndex,\n multipleSeries: multipleSeries\n });\n };\n\n SeriesModel.prototype.isAnimationEnabled = function () {\n if (env.node) {\n return false;\n }\n\n var animationEnabled = this.getShallow('animation');\n\n if (animationEnabled) {\n if (this.getData().count() > this.getShallow('animationThreshold')) {\n animationEnabled = false;\n }\n }\n\n return !!animationEnabled;\n };\n\n SeriesModel.prototype.restoreData = function () {\n this.dataTask.dirty();\n };\n\n SeriesModel.prototype.getColorFromPalette = function (name, scope, requestColorNum) {\n var ecModel = this.ecModel; // PENDING\n\n var color = PaletteMixin.prototype.getColorFromPalette.call(this, name, scope, requestColorNum);\n\n if (!color) {\n color = ecModel.getColorFromPalette(name, scope, requestColorNum);\n }\n\n return color;\n };\n /**\n * Use `data.mapDimensionsAll(coordDim)` instead.\n * @deprecated\n */\n\n\n SeriesModel.prototype.coordDimToDataDim = function (coordDim) {\n return this.getRawData().mapDimensionsAll(coordDim);\n };\n /**\n * Get progressive rendering count each step\n */\n\n\n SeriesModel.prototype.getProgressive = function () {\n return this.get('progressive');\n };\n /**\n * Get progressive rendering count each step\n */\n\n\n SeriesModel.prototype.getProgressiveThreshold = function () {\n return this.get('progressiveThreshold');\n }; // PENGING If selectedMode is null ?\n\n\n SeriesModel.prototype.select = function (innerDataIndices, dataType) {\n this._innerSelect(this.getData(dataType), innerDataIndices);\n };\n\n SeriesModel.prototype.unselect = function (innerDataIndices, dataType) {\n var selectedMap = this.option.selectedMap;\n\n if (!selectedMap) {\n return;\n }\n\n var data = this.getData(dataType);\n\n for (var i = 0; i < innerDataIndices.length; i++) {\n var dataIndex = innerDataIndices[i];\n var nameOrId = getSelectionKey(data, dataIndex);\n selectedMap[nameOrId] = false;\n this._selectedDataIndicesMap[nameOrId] = -1;\n }\n };\n\n SeriesModel.prototype.toggleSelect = function (innerDataIndices, dataType) {\n var tmpArr = [];\n\n for (var i = 0; i < innerDataIndices.length; i++) {\n tmpArr[0] = innerDataIndices[i];\n this.isSelected(innerDataIndices[i], dataType) ? this.unselect(tmpArr, dataType) : this.select(tmpArr, dataType);\n }\n };\n\n SeriesModel.prototype.getSelectedDataIndices = function () {\n var selectedDataIndicesMap = this._selectedDataIndicesMap;\n var nameOrIds = zrUtil.keys(selectedDataIndicesMap);\n var dataIndices = [];\n\n for (var i = 0; i < nameOrIds.length; i++) {\n var dataIndex = selectedDataIndicesMap[nameOrIds[i]];\n\n if (dataIndex >= 0) {\n dataIndices.push(dataIndex);\n }\n }\n\n return dataIndices;\n };\n\n SeriesModel.prototype.isSelected = function (dataIndex, dataType) {\n var selectedMap = this.option.selectedMap;\n\n if (!selectedMap) {\n return false;\n }\n\n var data = this.getData(dataType);\n var nameOrId = getSelectionKey(data, dataIndex);\n return selectedMap[nameOrId] || false;\n };\n\n SeriesModel.prototype._innerSelect = function (data, innerDataIndices) {\n var _a, _b;\n\n var selectedMode = this.option.selectedMode;\n var len = innerDataIndices.length;\n\n if (!selectedMode || !len) {\n return;\n }\n\n if (selectedMode === 'multiple') {\n var selectedMap = this.option.selectedMap || (this.option.selectedMap = {});\n\n for (var i = 0; i < len; i++) {\n var dataIndex = innerDataIndices[i]; // TODO diffrent types of data share same object.\n\n var nameOrId = getSelectionKey(data, dataIndex);\n selectedMap[nameOrId] = true;\n this._selectedDataIndicesMap[nameOrId] = data.getRawIndex(dataIndex);\n }\n } else if (selectedMode === 'single' || selectedMode === true) {\n var lastDataIndex = innerDataIndices[len - 1];\n var nameOrId = getSelectionKey(data, lastDataIndex);\n this.option.selectedMap = (_a = {}, _a[nameOrId] = true, _a);\n this._selectedDataIndicesMap = (_b = {}, _b[nameOrId] = data.getRawIndex(lastDataIndex), _b);\n }\n };\n\n SeriesModel.prototype._initSelectedMapFromData = function (data) {\n // Ignore select info in data if selectedMap exists.\n // NOTE It's only for legacy usage. edge data is not supported.\n if (this.option.selectedMap) {\n return;\n }\n\n var dataIndices = [];\n\n if (data.hasItemOption) {\n data.each(function (idx) {\n var rawItem = data.getRawDataItem(idx);\n\n if (typeof rawItem === 'object' && rawItem.selected) {\n dataIndices.push(idx);\n }\n });\n }\n\n if (dataIndices.length > 0) {\n this._innerSelect(data, dataIndices);\n }\n }; // /**\n // * @see {module:echarts/stream/Scheduler}\n // */\n // abstract pipeTask: null\n\n\n SeriesModel.registerClass = function (clz) {\n return ComponentModel.registerClass(clz);\n };\n\n SeriesModel.protoInitialize = function () {\n var proto = SeriesModel.prototype;\n proto.type = 'series.__base__';\n proto.seriesIndex = 0;\n proto.useColorPaletteOnData = false;\n proto.ignoreStyleOnData = false;\n proto.hasSymbolVisual = false;\n proto.defaultSymbol = 'circle'; // Make sure the values can be accessed!\n\n proto.visualStyleAccessPath = 'itemStyle';\n proto.visualDrawType = 'fill';\n }();\n\n return SeriesModel;\n}(ComponentModel);\n\nzrUtil.mixin(SeriesModel, DataFormatMixin);\nzrUtil.mixin(SeriesModel, PaletteMixin);\nmountExtend(SeriesModel, ComponentModel);\n/**\n * MUST be called after `prepareSource` called\n * Here we need to make auto series, especially for auto legend. But we\n * do not modify series.name in option to avoid side effects.\n */\n\nfunction autoSeriesName(seriesModel) {\n // User specified name has higher priority, otherwise it may cause\n // series can not be queried unexpectedly.\n var name = seriesModel.name;\n\n if (!modelUtil.isNameSpecified(seriesModel)) {\n seriesModel.name = getSeriesAutoName(seriesModel) || name;\n }\n}\n\nfunction getSeriesAutoName(seriesModel) {\n var data = seriesModel.getRawData();\n var dataDims = data.mapDimensionsAll('seriesName');\n var nameArr = [];\n zrUtil.each(dataDims, function (dataDim) {\n var dimInfo = data.getDimensionInfo(dataDim);\n dimInfo.displayName && nameArr.push(dimInfo.displayName);\n });\n return nameArr.join(' ');\n}\n\nfunction dataTaskCount(context) {\n return context.model.getRawData().count();\n}\n\nfunction dataTaskReset(context) {\n var seriesModel = context.model;\n seriesModel.setData(seriesModel.getRawData().cloneShallow());\n return dataTaskProgress;\n}\n\nfunction dataTaskProgress(param, context) {\n // Avoid repead cloneShallow when data just created in reset.\n if (context.outputData && param.end > context.outputData.count()) {\n context.model.getRawData().cloneShallow(context.outputData);\n }\n} // TODO refactor\n\n\nfunction wrapData(data, seriesModel) {\n zrUtil.each(__spreadArrays(data.CHANGABLE_METHODS, data.DOWNSAMPLE_METHODS), function (methodName) {\n data.wrapMethod(methodName, zrUtil.curry(onDataChange, seriesModel));\n });\n}\n\nfunction onDataChange(seriesModel, newList) {\n var task = getCurrentTask(seriesModel);\n\n if (task) {\n // Consider case: filter, selectRange\n task.setOutputEnd((newList || this).count());\n }\n\n return newList;\n}\n\nfunction getCurrentTask(seriesModel) {\n var scheduler = (seriesModel.ecModel || {}).scheduler;\n var pipeline = scheduler && scheduler.getPipeline(seriesModel.uid);\n\n if (pipeline) {\n // When pipline finished, the currrentTask keep the last\n // task (renderTask).\n var task = pipeline.currentTask;\n\n if (task) {\n var agentStubMap = task.agentStubMap;\n\n if (agentStubMap) {\n task = agentStubMap.get(seriesModel.uid);\n }\n }\n\n return task;\n }\n}\n\nexport default SeriesModel;","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport Group from 'zrender/lib/graphic/Group';\nimport * as componentUtil from '../util/component';\nimport * as clazzUtil from '../util/clazz';\n\nvar ComponentView =\n/** @class */\nfunction () {\n function ComponentView() {\n this.group = new Group();\n this.uid = componentUtil.getUID('viewComponent');\n }\n\n ComponentView.prototype.init = function (ecModel, api) {};\n\n ComponentView.prototype.render = function (model, ecModel, api, payload) {};\n\n ComponentView.prototype.dispose = function (ecModel, api) {};\n\n ComponentView.prototype.updateView = function (model, ecModel, api, payload) {// Do nothing;\n };\n\n ComponentView.prototype.updateLayout = function (model, ecModel, api, payload) {// Do nothing;\n };\n\n ComponentView.prototype.updateVisual = function (model, ecModel, api, payload) {// Do nothing;\n };\n /**\n * Hook for blur target series.\n * Can be used in marker for blur the markers\n */\n\n\n ComponentView.prototype.blurSeries = function (seriesModels, ecModel) {// Do nothing;\n };\n\n return ComponentView;\n}();\n\n;\nclazzUtil.enableClassExtend(ComponentView);\nclazzUtil.enableClassManagement(ComponentView);\nexport default ComponentView;","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { makeInner } from '../../util/model';\n/**\n * @return {string} If large mode changed, return string 'reset';\n */\n\nexport default function createRenderPlanner() {\n var inner = makeInner();\n return function (seriesModel) {\n var fields = inner(seriesModel);\n var pipelineContext = seriesModel.pipelineContext;\n var originalLarge = !!fields.large;\n var originalProgressive = !!fields.progressiveRender; // FIXME: if the planner works on a filtered series, `pipelineContext` does not\n // exists. See #11611 . Probably we need to modify this structure, see the comment\n // on `performRawSeries` in `Schedular.js`.\n\n var large = fields.large = !!(pipelineContext && pipelineContext.large);\n var progressive = fields.progressiveRender = !!(pipelineContext && pipelineContext.progressiveRender);\n return !!(originalLarge !== large || originalProgressive !== progressive) && 'reset';\n };\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { each } from 'zrender/lib/core/util';\nimport Group from 'zrender/lib/graphic/Group';\nimport * as componentUtil from '../util/component';\nimport * as clazzUtil from '../util/clazz';\nimport * as modelUtil from '../util/model';\nimport { enterEmphasis, leaveEmphasis, getHighlightDigit } from '../util/states';\nimport { createTask } from '../core/task';\nimport createRenderPlanner from '../chart/helper/createRenderPlanner';\nvar inner = modelUtil.makeInner();\nvar renderPlanner = createRenderPlanner();\n\nvar ChartView =\n/** @class */\nfunction () {\n function ChartView() {\n this.group = new Group();\n this.uid = componentUtil.getUID('viewChart');\n this.renderTask = createTask({\n plan: renderTaskPlan,\n reset: renderTaskReset\n });\n this.renderTask.context = {\n view: this\n };\n }\n\n ChartView.prototype.init = function (ecModel, api) {};\n\n ChartView.prototype.render = function (seriesModel, ecModel, api, payload) {};\n /**\n * Highlight series or specified data item.\n */\n\n\n ChartView.prototype.highlight = function (seriesModel, ecModel, api, payload) {\n toggleHighlight(seriesModel.getData(), payload, 'emphasis');\n };\n /**\n * Downplay series or specified data item.\n */\n\n\n ChartView.prototype.downplay = function (seriesModel, ecModel, api, payload) {\n toggleHighlight(seriesModel.getData(), payload, 'normal');\n };\n /**\n * Remove self.\n */\n\n\n ChartView.prototype.remove = function (ecModel, api) {\n this.group.removeAll();\n };\n /**\n * Dispose self.\n */\n\n\n ChartView.prototype.dispose = function (ecModel, api) {};\n\n ChartView.prototype.updateView = function (seriesModel, ecModel, api, payload) {\n this.render(seriesModel, ecModel, api, payload);\n }; // FIXME never used?\n\n\n ChartView.prototype.updateLayout = function (seriesModel, ecModel, api, payload) {\n this.render(seriesModel, ecModel, api, payload);\n }; // FIXME never used?\n\n\n ChartView.prototype.updateVisual = function (seriesModel, ecModel, api, payload) {\n this.render(seriesModel, ecModel, api, payload);\n };\n\n ChartView.markUpdateMethod = function (payload, methodName) {\n inner(payload).updateMethod = methodName;\n };\n\n ChartView.protoInitialize = function () {\n var proto = ChartView.prototype;\n proto.type = 'chart';\n }();\n\n return ChartView;\n}();\n\n;\n/**\n * Set state of single element\n */\n\nfunction elSetState(el, state, highlightDigit) {\n if (el) {\n (state === 'emphasis' ? enterEmphasis : leaveEmphasis)(el, highlightDigit);\n }\n}\n\nfunction toggleHighlight(data, payload, state) {\n var dataIndex = modelUtil.queryDataIndex(data, payload);\n var highlightDigit = payload && payload.highlightKey != null ? getHighlightDigit(payload.highlightKey) : null;\n\n if (dataIndex != null) {\n each(modelUtil.normalizeToArray(dataIndex), function (dataIdx) {\n elSetState(data.getItemGraphicEl(dataIdx), state, highlightDigit);\n });\n } else {\n data.eachItemGraphicEl(function (el) {\n elSetState(el, state, highlightDigit);\n });\n }\n}\n\nclazzUtil.enableClassExtend(ChartView, ['dispose']);\nclazzUtil.enableClassManagement(ChartView);\n\nfunction renderTaskPlan(context) {\n return renderPlanner(context.model);\n}\n\nfunction renderTaskReset(context) {\n var seriesModel = context.model;\n var ecModel = context.ecModel;\n var api = context.api;\n var payload = context.payload; // FIXME: remove updateView updateVisual\n\n var progressiveRender = seriesModel.pipelineContext.progressiveRender;\n var view = context.view;\n var updateMethod = payload && inner(payload).updateMethod;\n var methodName = progressiveRender ? 'incrementalPrepareRender' : updateMethod && view[updateMethod] ? updateMethod // `appendData` is also supported when data amount\n // is less than progressive threshold.\n : 'render';\n\n if (methodName !== 'render') {\n view[methodName](seriesModel, ecModel, api, payload);\n }\n\n return progressMethodMap[methodName];\n}\n\nvar progressMethodMap = {\n incrementalPrepareRender: {\n progress: function (params, context) {\n context.view.incrementalRender(params, context.model, context.ecModel, context.api, context.payload);\n }\n },\n render: {\n // Put view.render in `progress` to support appendData. But in this case\n // view.render should not be called in reset, otherwise it will be called\n // twise. Use `forceFirstProgress` to make sure that view.render is called\n // in any cases.\n forceFirstProgress: true,\n progress: function (params, context) {\n context.view.render(context.model, context.ecModel, context.api, context.payload);\n }\n }\n};\nexport default ChartView;","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nvar ORIGIN_METHOD = '\\0__throttleOriginMethod';\nvar RATE = '\\0__throttleRate';\nvar THROTTLE_TYPE = '\\0__throttleType';\n;\n/**\n * @public\n * @param {(Function)} fn\n * @param {number} [delay=0] Unit: ms.\n * @param {boolean} [debounce=false]\n * true: If call interval less than `delay`, only the last call works.\n * false: If call interval less than `delay, call works on fixed rate.\n * @return {(Function)} throttled fn.\n */\n\nexport function throttle(fn, delay, debounce) {\n var currCall;\n var lastCall = 0;\n var lastExec = 0;\n var timer = null;\n var diff;\n var scope;\n var args;\n var debounceNextCall;\n delay = delay || 0;\n\n function exec() {\n lastExec = new Date().getTime();\n timer = null;\n fn.apply(scope, args || []);\n }\n\n var cb = function () {\n var cbArgs = [];\n\n for (var _i = 0; _i < arguments.length; _i++) {\n cbArgs[_i] = arguments[_i];\n }\n\n currCall = new Date().getTime();\n scope = this;\n args = cbArgs;\n var thisDelay = debounceNextCall || delay;\n var thisDebounce = debounceNextCall || debounce;\n debounceNextCall = null;\n diff = currCall - (thisDebounce ? lastCall : lastExec) - thisDelay;\n clearTimeout(timer); // Here we should make sure that: the `exec` SHOULD NOT be called later\n // than a new call of `cb`, that is, preserving the command order. Consider\n // calculating \"scale rate\" when roaming as an example. When a call of `cb`\n // happens, either the `exec` is called dierectly, or the call is delayed.\n // But the delayed call should never be later than next call of `cb`. Under\n // this assurance, we can simply update view state each time `dispatchAction`\n // triggered by user roaming, but not need to add extra code to avoid the\n // state being \"rolled-back\".\n\n if (thisDebounce) {\n timer = setTimeout(exec, thisDelay);\n } else {\n if (diff >= 0) {\n exec();\n } else {\n timer = setTimeout(exec, -diff);\n }\n }\n\n lastCall = currCall;\n };\n /**\n * Clear throttle.\n * @public\n */\n\n\n cb.clear = function () {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n };\n /**\n * Enable debounce once.\n */\n\n\n cb.debounceNextCall = function (debounceDelay) {\n debounceNextCall = debounceDelay;\n };\n\n return cb;\n}\n/**\n * Create throttle method or update throttle rate.\n *\n * @example\n * ComponentView.prototype.render = function () {\n * ...\n * throttle.createOrUpdate(\n * this,\n * '_dispatchAction',\n * this.model.get('throttle'),\n * 'fixRate'\n * );\n * };\n * ComponentView.prototype.remove = function () {\n * throttle.clear(this, '_dispatchAction');\n * };\n * ComponentView.prototype.dispose = function () {\n * throttle.clear(this, '_dispatchAction');\n * };\n *\n */\n\nexport function createOrUpdate(obj, fnAttr, rate, throttleType) {\n var fn = obj[fnAttr];\n\n if (!fn) {\n return;\n }\n\n var originFn = fn[ORIGIN_METHOD] || fn;\n var lastThrottleType = fn[THROTTLE_TYPE];\n var lastRate = fn[RATE];\n\n if (lastRate !== rate || lastThrottleType !== throttleType) {\n if (rate == null || !throttleType) {\n return obj[fnAttr] = originFn;\n }\n\n fn = obj[fnAttr] = throttle(originFn, rate, throttleType === 'debounce');\n fn[ORIGIN_METHOD] = originFn;\n fn[THROTTLE_TYPE] = throttleType;\n fn[RATE] = rate;\n }\n\n return fn;\n}\n/**\n * Clear throttle. Example see throttle.createOrUpdate.\n */\n\nexport function clear(obj, fnAttr) {\n var fn = obj[fnAttr];\n\n if (fn && fn[ORIGIN_METHOD]) {\n obj[fnAttr] = fn[ORIGIN_METHOD];\n }\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { isFunction, extend, createHashMap } from 'zrender/lib/core/util';\nimport makeStyleMapper from '../model/mixin/makeStyleMapper';\nimport { ITEM_STYLE_KEY_MAP } from '../model/mixin/itemStyle';\nimport { LINE_STYLE_KEY_MAP } from '../model/mixin/lineStyle';\nimport Model from '../model/Model';\nimport { makeInner } from '../util/model';\nvar inner = makeInner();\nvar defaultStyleMappers = {\n itemStyle: makeStyleMapper(ITEM_STYLE_KEY_MAP, true),\n lineStyle: makeStyleMapper(LINE_STYLE_KEY_MAP, true)\n};\nvar defaultColorKey = {\n lineStyle: 'stroke',\n itemStyle: 'fill'\n};\n\nfunction getStyleMapper(seriesModel, stylePath) {\n var styleMapper = seriesModel.visualStyleMapper || defaultStyleMappers[stylePath];\n\n if (!styleMapper) {\n console.warn(\"Unkown style type '\" + stylePath + \"'.\");\n return defaultStyleMappers.itemStyle;\n }\n\n return styleMapper;\n}\n\nfunction getDefaultColorKey(seriesModel, stylePath) {\n // return defaultColorKey[stylePath] ||\n var colorKey = seriesModel.visualDrawType || defaultColorKey[stylePath];\n\n if (!colorKey) {\n console.warn(\"Unkown style type '\" + stylePath + \"'.\");\n return 'fill';\n }\n\n return colorKey;\n}\n\nvar seriesStyleTask = {\n createOnAllSeries: true,\n performRawSeries: true,\n reset: function (seriesModel, ecModel) {\n var data = seriesModel.getData();\n var stylePath = seriesModel.visualStyleAccessPath || 'itemStyle'; // Set in itemStyle\n\n var styleModel = seriesModel.getModel(stylePath);\n var getStyle = getStyleMapper(seriesModel, stylePath);\n var globalStyle = getStyle(styleModel);\n var decalOption = styleModel.getShallow('decal');\n\n if (decalOption) {\n data.setVisual('decal', decalOption);\n decalOption.dirty = true;\n } // TODO\n\n\n var colorKey = getDefaultColorKey(seriesModel, stylePath);\n var color = globalStyle[colorKey]; // TODO style callback\n\n var colorCallback = isFunction(color) ? color : null; // Get from color palette by default.\n\n if (!globalStyle[colorKey] || colorCallback) {\n // Note: if some series has color specified (e.g., by itemStyle.color), we DO NOT\n // make it effect palette. Bacause some scenarios users need to make some series\n // transparent or as background, which should better not effect the palette.\n globalStyle[colorKey] = seriesModel.getColorFromPalette( // TODO series count changed.\n seriesModel.name, null, ecModel.getSeriesCount());\n data.setVisual('colorFromPalette', true);\n }\n\n data.setVisual('style', globalStyle);\n data.setVisual('drawType', colorKey); // Only visible series has each data be visual encoded\n\n if (!ecModel.isSeriesFiltered(seriesModel) && colorCallback) {\n data.setVisual('colorFromPalette', false);\n return {\n dataEach: function (data, idx) {\n var dataParams = seriesModel.getDataParams(idx);\n var itemStyle = extend({}, globalStyle);\n itemStyle[colorKey] = colorCallback(dataParams);\n data.setItemVisual(idx, 'style', itemStyle);\n }\n };\n }\n }\n};\nvar sharedModel = new Model();\nvar dataStyleTask = {\n createOnAllSeries: true,\n performRawSeries: true,\n reset: function (seriesModel, ecModel) {\n if (seriesModel.ignoreStyleOnData || ecModel.isSeriesFiltered(seriesModel)) {\n return;\n }\n\n var data = seriesModel.getData();\n var stylePath = seriesModel.visualStyleAccessPath || 'itemStyle'; // Set in itemStyle\n\n var getStyle = getStyleMapper(seriesModel, stylePath);\n var colorKey = data.getVisual('drawType');\n return {\n dataEach: data.hasItemOption ? function (data, idx) {\n // Not use getItemModel for performance considuration\n var rawItem = data.getRawDataItem(idx);\n\n if (rawItem && rawItem[stylePath]) {\n sharedModel.option = rawItem[stylePath];\n var style = getStyle(sharedModel);\n var existsStyle = data.ensureUniqueItemVisual(idx, 'style');\n extend(existsStyle, style);\n\n if (sharedModel.option.decal) {\n data.setItemVisual(idx, 'decal', sharedModel.option.decal);\n sharedModel.option.decal.dirty = true;\n }\n\n if (colorKey in style) {\n data.setItemVisual(idx, 'colorFromPalette', false);\n }\n }\n } : null\n };\n }\n}; // Pick color from palette for the data which has not been set with color yet.\n// Note: do not support stream rendering. No such cases yet.\n\nvar dataColorPaletteTask = {\n performRawSeries: true,\n overallReset: function (ecModel) {\n // Each type of series use one scope.\n // Pie and funnel are using diferrent scopes\n var paletteScopeGroupByType = createHashMap();\n ecModel.eachSeries(function (seriesModel) {\n if (!seriesModel.useColorPaletteOnData) {\n return;\n }\n\n var colorScope = paletteScopeGroupByType.get(seriesModel.type);\n\n if (!colorScope) {\n colorScope = {};\n paletteScopeGroupByType.set(seriesModel.type, colorScope);\n }\n\n inner(seriesModel).scope = colorScope;\n });\n ecModel.eachSeries(function (seriesModel) {\n if (!seriesModel.useColorPaletteOnData || ecModel.isSeriesFiltered(seriesModel)) {\n return;\n }\n\n var dataAll = seriesModel.getRawData();\n var idxMap = {};\n var data = seriesModel.getData();\n var colorScope = inner(seriesModel).scope;\n var stylePath = seriesModel.visualStyleAccessPath || 'itemStyle';\n var colorKey = getDefaultColorKey(seriesModel, stylePath);\n data.each(function (idx) {\n var rawIdx = data.getRawIndex(idx);\n idxMap[rawIdx] = idx;\n }); // Iterate on data before filtered. To make sure color from palette can be\n // Consistent when toggling legend.\n\n dataAll.each(function (rawIdx) {\n var idx = idxMap[rawIdx];\n var fromPalette = data.getItemVisual(idx, 'colorFromPalette'); // Get color from palette for each data only when the color is inherited from series color, which is\n // also picked from color palette. So following situation is not in the case:\n // 1. series.itemStyle.color is set\n // 2. color is encoded by visualMap\n\n if (fromPalette) {\n var itemStyle = data.ensureUniqueItemVisual(idx, 'style');\n var name_1 = dataAll.getName(rawIdx) || rawIdx + '';\n var dataCount = dataAll.count();\n itemStyle[colorKey] = seriesModel.getColorFromPalette(name_1, colorScope, dataCount);\n }\n });\n });\n }\n};\nexport { seriesStyleTask, dataStyleTask, dataColorPaletteTask };","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport * as zrUtil from 'zrender/lib/core/util';\nimport * as graphic from '../util/graphic';\nvar PI = Math.PI;\n/**\n * @param {module:echarts/ExtensionAPI} api\n * @param {Object} [opts]\n * @param {string} [opts.text]\n * @param {string} [opts.color]\n * @param {string} [opts.textColor]\n * @return {module:zrender/Element}\n */\n\nexport default function defaultLoading(api, opts) {\n opts = opts || {};\n zrUtil.defaults(opts, {\n text: 'loading',\n textColor: '#000',\n fontSize: 12,\n fontWeight: 'normal',\n fontStyle: 'normal',\n fontFamily: 'sans-serif',\n maskColor: 'rgba(255, 255, 255, 0.8)',\n showSpinner: true,\n color: '#5470c6',\n spinnerRadius: 10,\n lineWidth: 5,\n zlevel: 0\n });\n var group = new graphic.Group();\n var mask = new graphic.Rect({\n style: {\n fill: opts.maskColor\n },\n zlevel: opts.zlevel,\n z: 10000\n });\n group.add(mask);\n var textContent = new graphic.Text({\n style: {\n text: opts.text,\n fill: opts.textColor,\n fontSize: opts.fontSize,\n fontWeight: opts.fontWeight,\n fontStyle: opts.fontStyle,\n fontFamily: opts.fontFamily\n }\n });\n var labelRect = new graphic.Rect({\n style: {\n fill: 'none'\n },\n textContent: textContent,\n textConfig: {\n position: 'right',\n distance: 10\n },\n zlevel: opts.zlevel,\n z: 10001\n });\n group.add(labelRect);\n var arc;\n\n if (opts.showSpinner) {\n arc = new graphic.Arc({\n shape: {\n startAngle: -PI / 2,\n endAngle: -PI / 2 + 0.1,\n r: opts.spinnerRadius\n },\n style: {\n stroke: opts.color,\n lineCap: 'round',\n lineWidth: opts.lineWidth\n },\n zlevel: opts.zlevel,\n z: 10001\n });\n arc.animateShape(true).when(1000, {\n endAngle: PI * 3 / 2\n }).start('circularInOut');\n arc.animateShape(true).when(1000, {\n startAngle: PI * 3 / 2\n }).delay(300).start('circularInOut');\n group.add(arc);\n } // Inject resize\n\n\n group.resize = function () {\n var textWidth = textContent.getBoundingRect().width;\n var r = opts.showSpinner ? opts.spinnerRadius : 0; // cx = (containerWidth - arcDiameter - textDistance - textWidth) / 2\n // textDistance needs to be calculated when both animation and text exist\n\n var cx = (api.getWidth() - r * 2 - (opts.showSpinner && textWidth ? 10 : 0) - textWidth) / 2 - (opts.showSpinner && textWidth ? 0 : 5 + textWidth / 2) // only show the text\n + (opts.showSpinner ? 0 : textWidth / 2) // only show the spinner\n + (textWidth ? 0 : r);\n var cy = api.getHeight() / 2;\n opts.showSpinner && arc.setShape({\n cx: cx,\n cy: cy\n });\n labelRect.setShape({\n x: cx - r,\n y: cy - r,\n width: r * 2,\n height: r * 2\n });\n mask.setShape({\n x: 0,\n y: 0,\n width: api.getWidth(),\n height: api.getHeight()\n });\n };\n\n group.resize();\n return group;\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { each, map, isFunction, createHashMap, noop, assert } from 'zrender/lib/core/util';\nimport { createTask } from './task';\nimport { getUID } from '../util/component';\nimport GlobalModel from '../model/Global';\nimport ExtensionAPI from './ExtensionAPI';\nimport { normalizeToArray } from '../util/model';\n;\n\nvar Scheduler =\n/** @class */\nfunction () {\n function Scheduler(ecInstance, api, dataProcessorHandlers, visualHandlers) {\n // key: handlerUID\n this._stageTaskMap = createHashMap();\n this.ecInstance = ecInstance;\n this.api = api; // Fix current processors in case that in some rear cases that\n // processors might be registered after echarts instance created.\n // Register processors incrementally for a echarts instance is\n // not supported by this stream architecture.\n\n dataProcessorHandlers = this._dataProcessorHandlers = dataProcessorHandlers.slice();\n visualHandlers = this._visualHandlers = visualHandlers.slice();\n this._allHandlers = dataProcessorHandlers.concat(visualHandlers);\n }\n\n Scheduler.prototype.restoreData = function (ecModel, payload) {\n // TODO: Only restore needed series and components, but not all components.\n // Currently `restoreData` of all of the series and component will be called.\n // But some independent components like `title`, `legend`, `graphic`, `toolbox`,\n // `tooltip`, `axisPointer`, etc, do not need series refresh when `setOption`,\n // and some components like coordinate system, axes, dataZoom, visualMap only\n // need their target series refresh.\n // (1) If we are implementing this feature some day, we should consider these cases:\n // if a data processor depends on a component (e.g., dataZoomProcessor depends\n // on the settings of `dataZoom`), it should be re-performed if the component\n // is modified by `setOption`.\n // (2) If a processor depends on sevral series, speicified by its `getTargetSeries`,\n // it should be re-performed when the result array of `getTargetSeries` changed.\n // We use `dependencies` to cover these issues.\n // (3) How to update target series when coordinate system related components modified.\n // TODO: simply the dirty mechanism? Check whether only the case here can set tasks dirty,\n // and this case all of the tasks will be set as dirty.\n ecModel.restoreData(payload); // Theoretically an overall task not only depends on each of its target series, but also\n // depends on all of the series.\n // The overall task is not in pipeline, and `ecModel.restoreData` only set pipeline tasks\n // dirty. If `getTargetSeries` of an overall task returns nothing, we should also ensure\n // that the overall task is set as dirty and to be performed, otherwise it probably cause\n // state chaos. So we have to set dirty of all of the overall tasks manually, otherwise it\n // probably cause state chaos (consider `dataZoomProcessor`).\n\n this._stageTaskMap.each(function (taskRecord) {\n var overallTask = taskRecord.overallTask;\n overallTask && overallTask.dirty();\n });\n }; // If seriesModel provided, incremental threshold is check by series data.\n\n\n Scheduler.prototype.getPerformArgs = function (task, isBlock) {\n // For overall task\n if (!task.__pipeline) {\n return;\n }\n\n var pipeline = this._pipelineMap.get(task.__pipeline.id);\n\n var pCtx = pipeline.context;\n var incremental = !isBlock && pipeline.progressiveEnabled && (!pCtx || pCtx.progressiveRender) && task.__idxInPipeline > pipeline.blockIndex;\n var step = incremental ? pipeline.step : null;\n var modDataCount = pCtx && pCtx.modDataCount;\n var modBy = modDataCount != null ? Math.ceil(modDataCount / step) : null;\n return {\n step: step,\n modBy: modBy,\n modDataCount: modDataCount\n };\n };\n\n Scheduler.prototype.getPipeline = function (pipelineId) {\n return this._pipelineMap.get(pipelineId);\n };\n /**\n * Current, progressive rendering starts from visual and layout.\n * Always detect render mode in the same stage, avoiding that incorrect\n * detection caused by data filtering.\n * Caution:\n * `updateStreamModes` use `seriesModel.getData()`.\n */\n\n\n Scheduler.prototype.updateStreamModes = function (seriesModel, view) {\n var pipeline = this._pipelineMap.get(seriesModel.uid);\n\n var data = seriesModel.getData();\n var dataLen = data.count(); // `progressiveRender` means that can render progressively in each\n // animation frame. Note that some types of series do not provide\n // `view.incrementalPrepareRender` but support `chart.appendData`. We\n // use the term `incremental` but not `progressive` to describe the\n // case that `chart.appendData`.\n\n var progressiveRender = pipeline.progressiveEnabled && view.incrementalPrepareRender && dataLen >= pipeline.threshold;\n var large = seriesModel.get('large') && dataLen >= seriesModel.get('largeThreshold'); // TODO: modDataCount should not updated if `appendData`, otherwise cause whole repaint.\n // see `test/candlestick-large3.html`\n\n var modDataCount = seriesModel.get('progressiveChunkMode') === 'mod' ? dataLen : null;\n seriesModel.pipelineContext = pipeline.context = {\n progressiveRender: progressiveRender,\n modDataCount: modDataCount,\n large: large\n };\n };\n\n Scheduler.prototype.restorePipelines = function (ecModel) {\n var scheduler = this;\n var pipelineMap = scheduler._pipelineMap = createHashMap();\n ecModel.eachSeries(function (seriesModel) {\n var progressive = seriesModel.getProgressive();\n var pipelineId = seriesModel.uid;\n pipelineMap.set(pipelineId, {\n id: pipelineId,\n head: null,\n tail: null,\n threshold: seriesModel.getProgressiveThreshold(),\n progressiveEnabled: progressive && !(seriesModel.preventIncremental && seriesModel.preventIncremental()),\n blockIndex: -1,\n step: Math.round(progressive || 700),\n count: 0\n });\n\n scheduler._pipe(seriesModel, seriesModel.dataTask);\n });\n };\n\n Scheduler.prototype.prepareStageTasks = function () {\n var stageTaskMap = this._stageTaskMap;\n var ecModel = this.api.getModel();\n var api = this.api;\n each(this._allHandlers, function (handler) {\n var record = stageTaskMap.get(handler.uid) || stageTaskMap.set(handler.uid, {});\n var errMsg = '';\n\n if (process.env.NODE_ENV !== 'production') {\n // Currently do not need to support to sepecify them both.\n errMsg = '\"reset\" and \"overallReset\" must not be both specified.';\n }\n\n assert(!(handler.reset && handler.overallReset), errMsg);\n handler.reset && this._createSeriesStageTask(handler, record, ecModel, api);\n handler.overallReset && this._createOverallStageTask(handler, record, ecModel, api);\n }, this);\n };\n\n Scheduler.prototype.prepareView = function (view, model, ecModel, api) {\n var renderTask = view.renderTask;\n var context = renderTask.context;\n context.model = model;\n context.ecModel = ecModel;\n context.api = api;\n renderTask.__block = !view.incrementalPrepareRender;\n\n this._pipe(model, renderTask);\n };\n\n Scheduler.prototype.performDataProcessorTasks = function (ecModel, payload) {\n // If we do not use `block` here, it should be considered when to update modes.\n this._performStageTasks(this._dataProcessorHandlers, ecModel, payload, {\n block: true\n });\n };\n\n Scheduler.prototype.performVisualTasks = function (ecModel, payload, opt) {\n this._performStageTasks(this._visualHandlers, ecModel, payload, opt);\n };\n\n Scheduler.prototype._performStageTasks = function (stageHandlers, ecModel, payload, opt) {\n opt = opt || {};\n var unfinished = false;\n var scheduler = this;\n each(stageHandlers, function (stageHandler, idx) {\n if (opt.visualType && opt.visualType !== stageHandler.visualType) {\n return;\n }\n\n var stageHandlerRecord = scheduler._stageTaskMap.get(stageHandler.uid);\n\n var seriesTaskMap = stageHandlerRecord.seriesTaskMap;\n var overallTask = stageHandlerRecord.overallTask;\n\n if (overallTask) {\n var overallNeedDirty_1;\n var agentStubMap = overallTask.agentStubMap;\n agentStubMap.each(function (stub) {\n if (needSetDirty(opt, stub)) {\n stub.dirty();\n overallNeedDirty_1 = true;\n }\n });\n overallNeedDirty_1 && overallTask.dirty();\n scheduler.updatePayload(overallTask, payload);\n var performArgs_1 = scheduler.getPerformArgs(overallTask, opt.block); // Execute stubs firstly, which may set the overall task dirty,\n // then execute the overall task. And stub will call seriesModel.setData,\n // which ensures that in the overallTask seriesModel.getData() will not\n // return incorrect data.\n\n agentStubMap.each(function (stub) {\n stub.perform(performArgs_1);\n });\n\n if (overallTask.perform(performArgs_1)) {\n unfinished = true;\n }\n } else if (seriesTaskMap) {\n seriesTaskMap.each(function (task, pipelineId) {\n if (needSetDirty(opt, task)) {\n task.dirty();\n }\n\n var performArgs = scheduler.getPerformArgs(task, opt.block); // FIXME\n // if intending to decalare `performRawSeries` in handlers, only\n // stream-independent (specifically, data item independent) operations can be\n // performed. Because is a series is filtered, most of the tasks will not\n // be performed. A stream-dependent operation probably cause wrong biz logic.\n // Perhaps we should not provide a separate callback for this case instead\n // of providing the config `performRawSeries`. The stream-dependent operaions\n // and stream-independent operations should better not be mixed.\n\n performArgs.skip = !stageHandler.performRawSeries && ecModel.isSeriesFiltered(task.context.model);\n scheduler.updatePayload(task, payload);\n\n if (task.perform(performArgs)) {\n unfinished = true;\n }\n });\n }\n });\n\n function needSetDirty(opt, task) {\n return opt.setDirty && (!opt.dirtyMap || opt.dirtyMap.get(task.__pipeline.id));\n }\n\n this.unfinished = unfinished || this.unfinished;\n };\n\n Scheduler.prototype.performSeriesTasks = function (ecModel) {\n var unfinished;\n ecModel.eachSeries(function (seriesModel) {\n // Progress to the end for dataInit and dataRestore.\n unfinished = seriesModel.dataTask.perform() || unfinished;\n });\n this.unfinished = unfinished || this.unfinished;\n };\n\n Scheduler.prototype.plan = function () {\n // Travel pipelines, check block.\n this._pipelineMap.each(function (pipeline) {\n var task = pipeline.tail;\n\n do {\n if (task.__block) {\n pipeline.blockIndex = task.__idxInPipeline;\n break;\n }\n\n task = task.getUpstream();\n } while (task);\n });\n };\n\n Scheduler.prototype.updatePayload = function (task, payload) {\n payload !== 'remain' && (task.context.payload = payload);\n };\n\n Scheduler.prototype._createSeriesStageTask = function (stageHandler, stageHandlerRecord, ecModel, api) {\n var scheduler = this;\n var oldSeriesTaskMap = stageHandlerRecord.seriesTaskMap; // The count of stages are totally about only several dozen, so\n // do not need to reuse the map.\n\n var newSeriesTaskMap = stageHandlerRecord.seriesTaskMap = createHashMap();\n var seriesType = stageHandler.seriesType;\n var getTargetSeries = stageHandler.getTargetSeries; // If a stageHandler should cover all series, `createOnAllSeries` should be declared mandatorily,\n // to avoid some typo or abuse. Otherwise if an extension do not specify a `seriesType`,\n // it works but it may cause other irrelevant charts blocked.\n\n if (stageHandler.createOnAllSeries) {\n ecModel.eachRawSeries(create);\n } else if (seriesType) {\n ecModel.eachRawSeriesByType(seriesType, create);\n } else if (getTargetSeries) {\n getTargetSeries(ecModel, api).each(create);\n }\n\n function create(seriesModel) {\n var pipelineId = seriesModel.uid; // Init tasks for each seriesModel only once.\n // Reuse original task instance.\n\n var task = newSeriesTaskMap.set(pipelineId, oldSeriesTaskMap && oldSeriesTaskMap.get(pipelineId) || createTask({\n plan: seriesTaskPlan,\n reset: seriesTaskReset,\n count: seriesTaskCount\n }));\n task.context = {\n model: seriesModel,\n ecModel: ecModel,\n api: api,\n // PENDING: `useClearVisual` not used?\n useClearVisual: stageHandler.isVisual && !stageHandler.isLayout,\n plan: stageHandler.plan,\n reset: stageHandler.reset,\n scheduler: scheduler\n };\n\n scheduler._pipe(seriesModel, task);\n }\n };\n\n Scheduler.prototype._createOverallStageTask = function (stageHandler, stageHandlerRecord, ecModel, api) {\n var scheduler = this;\n var overallTask = stageHandlerRecord.overallTask = stageHandlerRecord.overallTask // For overall task, the function only be called on reset stage.\n || createTask({\n reset: overallTaskReset\n });\n overallTask.context = {\n ecModel: ecModel,\n api: api,\n overallReset: stageHandler.overallReset,\n scheduler: scheduler\n };\n var oldAgentStubMap = overallTask.agentStubMap; // The count of stages are totally about only several dozen, so\n // do not need to reuse the map.\n\n var newAgentStubMap = overallTask.agentStubMap = createHashMap();\n var seriesType = stageHandler.seriesType;\n var getTargetSeries = stageHandler.getTargetSeries;\n var overallProgress = true;\n var shouldOverallTaskDirty = false; // FIXME:TS never used, so comment it\n // let modifyOutputEnd = stageHandler.modifyOutputEnd;\n // An overall task with seriesType detected or has `getTargetSeries`, we add\n // stub in each pipelines, it will set the overall task dirty when the pipeline\n // progress. Moreover, to avoid call the overall task each frame (too frequent),\n // we set the pipeline block.\n\n var errMsg = '';\n\n if (process.env.NODE_ENV !== 'production') {\n errMsg = '\"createOnAllSeries\" do not supported for \"overallReset\", ' + 'becuase it will block all streams.';\n }\n\n assert(!stageHandler.createOnAllSeries, errMsg);\n\n if (seriesType) {\n ecModel.eachRawSeriesByType(seriesType, createStub);\n } else if (getTargetSeries) {\n getTargetSeries(ecModel, api).each(createStub);\n } // Otherwise, (usually it is legancy case), the overall task will only be\n // executed when upstream dirty. Otherwise the progressive rendering of all\n // pipelines will be disabled unexpectedly. But it still needs stubs to receive\n // dirty info from upsteam.\n else {\n overallProgress = false;\n each(ecModel.getSeries(), createStub);\n }\n\n function createStub(seriesModel) {\n var pipelineId = seriesModel.uid;\n var stub = newAgentStubMap.set(pipelineId, oldAgentStubMap && oldAgentStubMap.get(pipelineId) || ( // When the result of `getTargetSeries` changed, the overallTask\n // should be set as dirty and re-performed.\n shouldOverallTaskDirty = true, createTask({\n reset: stubReset,\n onDirty: stubOnDirty\n })));\n stub.context = {\n model: seriesModel,\n overallProgress: overallProgress // FIXME:TS never used, so comment it\n // modifyOutputEnd: modifyOutputEnd\n\n };\n stub.agent = overallTask;\n stub.__block = overallProgress;\n\n scheduler._pipe(seriesModel, stub);\n }\n\n if (shouldOverallTaskDirty) {\n overallTask.dirty();\n }\n };\n\n Scheduler.prototype._pipe = function (seriesModel, task) {\n var pipelineId = seriesModel.uid;\n\n var pipeline = this._pipelineMap.get(pipelineId);\n\n !pipeline.head && (pipeline.head = task);\n pipeline.tail && pipeline.tail.pipe(task);\n pipeline.tail = task;\n task.__idxInPipeline = pipeline.count++;\n task.__pipeline = pipeline;\n };\n\n Scheduler.wrapStageHandler = function (stageHandler, visualType) {\n if (isFunction(stageHandler)) {\n stageHandler = {\n overallReset: stageHandler,\n seriesType: detectSeriseType(stageHandler)\n };\n }\n\n stageHandler.uid = getUID('stageHandler');\n visualType && (stageHandler.visualType = visualType);\n return stageHandler;\n };\n\n ;\n return Scheduler;\n}();\n\nfunction overallTaskReset(context) {\n context.overallReset(context.ecModel, context.api, context.payload);\n}\n\nfunction stubReset(context) {\n return context.overallProgress && stubProgress;\n}\n\nfunction stubProgress() {\n this.agent.dirty();\n this.getDownstream().dirty();\n}\n\nfunction stubOnDirty() {\n this.agent && this.agent.dirty();\n}\n\nfunction seriesTaskPlan(context) {\n return context.plan ? context.plan(context.model, context.ecModel, context.api, context.payload) : null;\n}\n\nfunction seriesTaskReset(context) {\n if (context.useClearVisual) {\n context.data.clearAllVisual();\n }\n\n var resetDefines = context.resetDefines = normalizeToArray(context.reset(context.model, context.ecModel, context.api, context.payload));\n return resetDefines.length > 1 ? map(resetDefines, function (v, idx) {\n return makeSeriesTaskProgress(idx);\n }) : singleSeriesTaskProgress;\n}\n\nvar singleSeriesTaskProgress = makeSeriesTaskProgress(0);\n\nfunction makeSeriesTaskProgress(resetDefineIdx) {\n return function (params, context) {\n var data = context.data;\n var resetDefine = context.resetDefines[resetDefineIdx];\n\n if (resetDefine && resetDefine.dataEach) {\n for (var i = params.start; i < params.end; i++) {\n resetDefine.dataEach(data, i);\n }\n } else if (resetDefine && resetDefine.progress) {\n resetDefine.progress(params, data);\n }\n };\n}\n\nfunction seriesTaskCount(context) {\n return context.data.count();\n}\n/**\n * Only some legacy stage handlers (usually in echarts extensions) are pure function.\n * To ensure that they can work normally, they should work in block mode, that is,\n * they should not be started util the previous tasks finished. So they cause the\n * progressive rendering disabled. We try to detect the series type, to narrow down\n * the block range to only the series type they concern, but not all series.\n */\n\n\nfunction detectSeriseType(legacyFunc) {\n seriesType = null;\n\n try {\n // Assume there is no async when calling `eachSeriesByType`.\n legacyFunc(ecModelMock, apiMock);\n } catch (e) {}\n\n return seriesType;\n}\n\nvar ecModelMock = {};\nvar apiMock = {};\nvar seriesType;\nmockMethods(ecModelMock, GlobalModel);\nmockMethods(apiMock, ExtensionAPI);\n\necModelMock.eachSeriesByType = ecModelMock.eachRawSeriesByType = function (type) {\n seriesType = type;\n};\n\necModelMock.eachComponent = function (cond) {\n if (cond.mainType === 'series' && cond.subType) {\n seriesType = cond.subType;\n }\n};\n\nfunction mockMethods(target, Clz) {\n /* eslint-disable */\n for (var name_1 in Clz.prototype) {\n // Do not use hasOwnProperty\n target[name_1] = noop;\n }\n /* eslint-enable */\n\n}\n\nexport default Scheduler;","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nvar colorAll = ['#37A2DA', '#32C5E9', '#67E0E3', '#9FE6B8', '#FFDB5C', '#ff9f7f', '#fb7293', '#E062AE', '#E690D1', '#e7bcf3', '#9d96f5', '#8378EA', '#96BFFF'];\nexport default {\n color: colorAll,\n colorLayer: [['#37A2DA', '#ffd85c', '#fd7b5f'], ['#37A2DA', '#67E0E3', '#FFDB5C', '#ff9f7f', '#E062AE', '#9d96f5'], ['#37A2DA', '#32C5E9', '#9FE6B8', '#FFDB5C', '#ff9f7f', '#fb7293', '#e7bcf3', '#8378EA', '#96BFFF'], colorAll]\n};","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nvar contrastColor = '#B9B8CE';\nvar backgroundColor = '#100C2A';\n\nvar axisCommon = function () {\n return {\n axisLine: {\n lineStyle: {\n color: contrastColor\n }\n },\n splitLine: {\n lineStyle: {\n color: '#484753'\n }\n },\n splitArea: {\n areaStyle: {\n color: ['rgba(255,255,255,0.02)', 'rgba(255,255,255,0.05)']\n }\n },\n minorSplitLine: {\n lineStyle: {\n color: '#20203B'\n }\n }\n };\n};\n\nvar colorPalette = ['#4992ff', '#7cffb2', '#fddd60', '#ff6e76', '#58d9f9', '#05c091', '#ff8a45', '#8d48e3', '#dd79ff'];\nvar theme = {\n darkMode: true,\n color: colorPalette,\n backgroundColor: backgroundColor,\n axisPointer: {\n lineStyle: {\n color: '#817f91'\n },\n crossStyle: {\n color: '#817f91'\n },\n label: {\n // TODO Contrast of label backgorundColor\n color: '#fff'\n }\n },\n legend: {\n textStyle: {\n color: contrastColor\n }\n },\n textStyle: {\n color: contrastColor\n },\n title: {\n textStyle: {\n color: '#EEF1FA'\n },\n subtextStyle: {\n color: '#B9B8CE'\n }\n },\n toolbox: {\n iconStyle: {\n borderColor: contrastColor\n }\n },\n dataZoom: {\n borderColor: '#71708A',\n textStyle: {\n color: contrastColor\n },\n brushStyle: {\n color: 'rgba(135,163,206,0.3)'\n },\n handleStyle: {\n color: '#353450',\n borderColor: '#C5CBE3'\n },\n moveHandleStyle: {\n color: '#B0B6C3',\n opacity: 0.3\n },\n fillerColor: 'rgba(135,163,206,0.2)',\n emphasis: {\n handleStyle: {\n borderColor: '#91B7F2',\n color: '#4D587D'\n },\n moveHandleStyle: {\n color: '#636D9A',\n opacity: 0.7\n }\n },\n dataBackground: {\n lineStyle: {\n color: '#71708A',\n width: 1\n },\n areaStyle: {\n color: '#71708A'\n }\n },\n selectedDataBackground: {\n lineStyle: {\n color: '#87A3CE'\n },\n areaStyle: {\n color: '#87A3CE'\n }\n }\n },\n visualMap: {\n textStyle: {\n color: contrastColor\n }\n },\n timeline: {\n lineStyle: {\n color: contrastColor\n },\n label: {\n color: contrastColor\n },\n controlStyle: {\n color: contrastColor,\n borderColor: contrastColor\n }\n },\n calendar: {\n itemStyle: {\n color: backgroundColor\n },\n dayLabel: {\n color: contrastColor\n },\n monthLabel: {\n color: contrastColor\n },\n yearLabel: {\n color: contrastColor\n }\n },\n timeAxis: axisCommon(),\n logAxis: axisCommon(),\n valueAxis: axisCommon(),\n categoryAxis: axisCommon(),\n line: {\n symbol: 'circle'\n },\n graph: {\n color: colorPalette\n },\n gauge: {\n title: {\n color: contrastColor\n },\n axisLine: {\n lineStyle: {\n color: [[1, 'rgba(207,212,219,0.2)']]\n }\n },\n axisLabel: {\n color: contrastColor\n },\n detail: {\n color: '#EEF1FA'\n }\n },\n candlestick: {\n itemStyle: {\n color: '#f64e56',\n color0: '#54ea92',\n borderColor: '#f64e56',\n borderColor0: '#54ea92' // borderColor: '#ca2824',\n // borderColor0: '#09a443'\n\n }\n }\n};\ntheme.categoryAxis.splitLine.show = false;\nexport default theme;","import { isString } from '../core/util';\nexport function parseXML(svg) {\n if (isString(svg)) {\n var parser = new DOMParser();\n svg = parser.parseFromString(svg, 'text/xml');\n }\n var svgNode = svg;\n if (svgNode.nodeType === 9) {\n svgNode = svgNode.firstChild;\n }\n while (svgNode.nodeName.toLowerCase() !== 'svg' || svgNode.nodeType !== 1) {\n svgNode = svgNode.nextSibling;\n }\n return svgNode;\n}\n","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { createHashMap, isString, isArray, each, assert } from 'zrender/lib/core/util';\nimport { parseXML } from 'zrender/lib/tool/parseXML';\nvar storage = createHashMap();\nexport default {\n /**\n * Compatible with previous `echarts.registerMap`.\n * @usage\n * ```js\n * $.get('USA.json', function (geoJson) {\n * echarts.registerMap('USA', geoJson);\n * // Or\n * echarts.registerMap('USA', {\n * geoJson: geoJson,\n * specialAreas: {}\n * })\n * });\n *\n * $.get('airport.svg', function (svg) {\n * echarts.registerMap('airport', {\n * svg: svg\n * }\n * });\n *\n * echarts.registerMap('eu', [\n * {svg: eu-topographic.svg},\n * {geoJSON: eu.json}\n * ])\n * ```\n */\n registerMap: function (mapName, rawDef, rawSpecialAreas) {\n var records;\n\n if (isArray(rawDef)) {\n records = rawDef;\n } else if (rawDef.svg) {\n records = [{\n type: 'svg',\n source: rawDef.svg,\n specialAreas: rawDef.specialAreas\n }];\n } else {\n // Backward compatibility.\n var geoSource = rawDef.geoJson || rawDef.geoJSON;\n\n if (geoSource && !rawDef.features) {\n rawSpecialAreas = rawDef.specialAreas;\n rawDef = geoSource;\n }\n\n records = [{\n type: 'geoJSON',\n source: rawDef,\n specialAreas: rawSpecialAreas\n }];\n }\n\n each(records, function (record) {\n var type = record.type;\n type === 'geoJson' && (type = record.type = 'geoJSON');\n var parse = parsers[type];\n\n if (process.env.NODE_ENV !== 'production') {\n assert(parse, 'Illegal map type: ' + type);\n }\n\n parse(record);\n });\n return storage.set(mapName, records);\n },\n retrieveMap: function (mapName) {\n return storage.get(mapName);\n }\n};\nvar parsers = {\n geoJSON: function (record) {\n var source = record.source;\n record.geoJSON = !isString(source) ? source : typeof JSON !== 'undefined' && JSON.parse ? JSON.parse(source) : new Function('return (' + source + ');')();\n },\n // Only perform parse to XML object here, which might be time\n // consiming for large SVG.\n // Although convert XML to zrender element is also time consiming,\n // if we do it here, the clone of zrender elements has to be\n // required. So we do it once for each geo instance, util real\n // performance issues call for optimizing it.\n svg: function (record) {\n record.svgXML = parseXML(record.source);\n }\n};","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport * as zrUtil from 'zrender/lib/core/util';\nimport { parseClassType } from './clazz';\n/**\n * Usage of query:\n * `chart.on('click', query, handler);`\n * The `query` can be:\n * + The component type query string, only `mainType` or `mainType.subType`,\n * like: 'xAxis', 'series', 'xAxis.category' or 'series.line'.\n * + The component query object, like:\n * `{seriesIndex: 2}`, `{seriesName: 'xx'}`, `{seriesId: 'some'}`,\n * `{xAxisIndex: 2}`, `{xAxisName: 'xx'}`, `{xAxisId: 'some'}`.\n * + The data query object, like:\n * `{dataIndex: 123}`, `{dataType: 'link'}`, `{name: 'some'}`.\n * + The other query object (cmponent customized query), like:\n * `{element: 'some'}` (only available in custom series).\n *\n * Caveat: If a prop in the `query` object is `null/undefined`, it is the\n * same as there is no such prop in the `query` object.\n */\n\nvar ECEventProcessor =\n/** @class */\nfunction () {\n function ECEventProcessor() {}\n\n ECEventProcessor.prototype.normalizeQuery = function (query) {\n var cptQuery = {};\n var dataQuery = {};\n var otherQuery = {}; // `query` is `mainType` or `mainType.subType` of component.\n\n if (zrUtil.isString(query)) {\n var condCptType = parseClassType(query); // `.main` and `.sub` may be ''.\n\n cptQuery.mainType = condCptType.main || null;\n cptQuery.subType = condCptType.sub || null;\n } // `query` is an object, convert to {mainType, index, name, id}.\n else {\n // `xxxIndex`, `xxxName`, `xxxId`, `name`, `dataIndex`, `dataType` is reserved,\n // can not be used in `compomentModel.filterForExposedEvent`.\n var suffixes_1 = ['Index', 'Name', 'Id'];\n var dataKeys_1 = {\n name: 1,\n dataIndex: 1,\n dataType: 1\n };\n zrUtil.each(query, function (val, key) {\n var reserved = false;\n\n for (var i = 0; i < suffixes_1.length; i++) {\n var propSuffix = suffixes_1[i];\n var suffixPos = key.lastIndexOf(propSuffix);\n\n if (suffixPos > 0 && suffixPos === key.length - propSuffix.length) {\n var mainType = key.slice(0, suffixPos); // Consider `dataIndex`.\n\n if (mainType !== 'data') {\n cptQuery.mainType = mainType;\n cptQuery[propSuffix.toLowerCase()] = val;\n reserved = true;\n }\n }\n }\n\n if (dataKeys_1.hasOwnProperty(key)) {\n dataQuery[key] = val;\n reserved = true;\n }\n\n if (!reserved) {\n otherQuery[key] = val;\n }\n });\n }\n\n return {\n cptQuery: cptQuery,\n dataQuery: dataQuery,\n otherQuery: otherQuery\n };\n };\n\n ECEventProcessor.prototype.filter = function (eventType, query) {\n // They should be assigned before each trigger call.\n var eventInfo = this.eventInfo;\n\n if (!eventInfo) {\n return true;\n }\n\n var targetEl = eventInfo.targetEl;\n var packedEvent = eventInfo.packedEvent;\n var model = eventInfo.model;\n var view = eventInfo.view; // For event like 'globalout'.\n\n if (!model || !view) {\n return true;\n }\n\n var cptQuery = query.cptQuery;\n var dataQuery = query.dataQuery;\n return check(cptQuery, model, 'mainType') && check(cptQuery, model, 'subType') && check(cptQuery, model, 'index', 'componentIndex') && check(cptQuery, model, 'name') && check(cptQuery, model, 'id') && check(dataQuery, packedEvent, 'name') && check(dataQuery, packedEvent, 'dataIndex') && check(dataQuery, packedEvent, 'dataType') && (!view.filterForExposedEvent || view.filterForExposedEvent(eventType, query.otherQuery, targetEl, packedEvent));\n\n function check(query, host, prop, propOnHost) {\n return query[prop] == null || host[propOnHost || prop] === query[prop];\n }\n };\n\n ECEventProcessor.prototype.afterTrigger = function () {\n // Make sure the eventInfo wont be used in next trigger.\n this.eventInfo = null;\n };\n\n return ECEventProcessor;\n}();\n\nexport { ECEventProcessor };\n;","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { isFunction } from 'zrender/lib/core/util'; // Encoding visual for all series include which is filtered for legend drawing\n\nvar seriesSymbolTask = {\n createOnAllSeries: true,\n // For legend.\n performRawSeries: true,\n reset: function (seriesModel, ecModel) {\n var data = seriesModel.getData();\n\n if (seriesModel.legendSymbol) {\n data.setVisual('legendSymbol', seriesModel.legendSymbol);\n }\n\n if (!seriesModel.hasSymbolVisual) {\n return;\n }\n\n var symbolType = seriesModel.get('symbol');\n var symbolSize = seriesModel.get('symbolSize');\n var keepAspect = seriesModel.get('symbolKeepAspect');\n var symbolRotate = seriesModel.get('symbolRotate');\n var hasSymbolTypeCallback = isFunction(symbolType);\n var hasSymbolSizeCallback = isFunction(symbolSize);\n var hasSymbolRotateCallback = isFunction(symbolRotate);\n var hasCallback = hasSymbolTypeCallback || hasSymbolSizeCallback || hasSymbolRotateCallback;\n var seriesSymbol = !hasSymbolTypeCallback && symbolType ? symbolType : seriesModel.defaultSymbol;\n var seriesSymbolSize = !hasSymbolSizeCallback ? symbolSize : null;\n var seriesSymbolRotate = !hasSymbolRotateCallback ? symbolRotate : null;\n data.setVisual({\n legendSymbol: seriesModel.legendSymbol || seriesSymbol,\n // If seting callback functions on `symbol` or `symbolSize`, for simplicity and avoiding\n // to bring trouble, we do not pick a reuslt from one of its calling on data item here,\n // but just use the default value. Callback on `symbol` or `symbolSize` is convenient in\n // some cases but generally it is not recommanded.\n symbol: seriesSymbol,\n symbolSize: seriesSymbolSize,\n symbolKeepAspect: keepAspect,\n symbolRotate: seriesSymbolRotate\n }); // Only visible series has each data be visual encoded\n\n if (ecModel.isSeriesFiltered(seriesModel)) {\n return;\n }\n\n function dataEach(data, idx) {\n var rawValue = seriesModel.getRawValue(idx);\n var params = seriesModel.getDataParams(idx);\n hasSymbolTypeCallback && data.setItemVisual(idx, 'symbol', symbolType(rawValue, params));\n hasSymbolSizeCallback && data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params));\n hasSymbolRotateCallback && data.setItemVisual(idx, 'symbolRotate', symbolRotate(rawValue, params));\n }\n\n return {\n dataEach: hasCallback ? dataEach : null\n };\n }\n};\nvar dataSymbolTask = {\n createOnAllSeries: true,\n // For legend.\n performRawSeries: true,\n reset: function (seriesModel, ecModel) {\n if (!seriesModel.hasSymbolVisual) {\n return;\n } // Only visible series has each data be visual encoded\n\n\n if (ecModel.isSeriesFiltered(seriesModel)) {\n return;\n }\n\n var data = seriesModel.getData();\n\n function dataEach(data, idx) {\n var itemModel = data.getItemModel(idx);\n var itemSymbolType = itemModel.getShallow('symbol', true);\n var itemSymbolSize = itemModel.getShallow('symbolSize', true);\n var itemSymbolRotate = itemModel.getShallow('symbolRotate', true);\n var itemSymbolKeepAspect = itemModel.getShallow('symbolKeepAspect', true); // If has item symbol\n\n if (itemSymbolType != null) {\n data.setItemVisual(idx, 'symbol', itemSymbolType);\n }\n\n if (itemSymbolSize != null) {\n // PENDING Transform symbolSize ?\n data.setItemVisual(idx, 'symbolSize', itemSymbolSize);\n }\n\n if (itemSymbolRotate != null) {\n data.setItemVisual(idx, 'symbolRotate', itemSymbolRotate);\n }\n\n if (itemSymbolKeepAspect != null) {\n data.setItemVisual(idx, 'symbolKeepAspect', itemSymbolKeepAspect);\n }\n }\n\n return {\n dataEach: data.hasItemOption ? dataEach : null\n };\n }\n};\nexport { seriesSymbolTask, dataSymbolTask };","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nexport function getItemVisualFromData(data, dataIndex, key) {\n switch (key) {\n case 'color':\n var style = data.getItemVisual(dataIndex, 'style');\n return style[data.getVisual('drawType')];\n\n case 'opacity':\n return data.getItemVisual(dataIndex, 'style').opacity;\n\n case 'symbol':\n case 'symbolSize':\n case 'liftZ':\n return data.getItemVisual(dataIndex, key);\n\n default:\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\"Unknown visual type \" + key);\n }\n\n }\n}\nexport function getVisualFromData(data, key) {\n switch (key) {\n case 'color':\n var style = data.getVisual('style');\n return style[data.getVisual('drawType')];\n\n case 'opacity':\n return data.getVisual('style').opacity;\n\n case 'symbol':\n case 'symbolSize':\n case 'liftZ':\n return data.getVisual(key);\n\n default:\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\"Unknown visual type \" + key);\n }\n\n }\n}\nexport function setItemVisualFromData(data, dataIndex, key, value) {\n switch (key) {\n case 'color':\n // Make sure not sharing style object.\n var style = data.ensureUniqueItemVisual(dataIndex, 'style');\n style[data.getVisual('drawType')] = value; // Mark the color has been changed, not from palette anymore\n\n data.setItemVisual(dataIndex, 'colorFromPalette', false);\n break;\n\n case 'opacity':\n data.ensureUniqueItemVisual(dataIndex, 'style').opacity = value;\n break;\n\n case 'symbol':\n case 'symbolSize':\n case 'liftZ':\n data.setItemVisual(dataIndex, key, value);\n break;\n\n default:\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\"Unknown visual type \" + key);\n }\n\n }\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { Point, Path, Polyline } from '../util/graphic';\nimport PathProxy from 'zrender/lib/core/PathProxy';\nimport { normalizeRadian } from 'zrender/lib/contain/util';\nimport { cubicProjectPoint, quadraticProjectPoint } from 'zrender/lib/core/curve';\nimport { defaults, retrieve2 } from 'zrender/lib/core/util';\nimport { invert } from 'zrender/lib/core/matrix';\nimport * as vector from 'zrender/lib/core/vector';\nimport { DISPLAY_STATES, SPECIAL_STATES } from '../util/states';\nvar PI2 = Math.PI * 2;\nvar CMD = PathProxy.CMD;\nvar DEFAULT_SEARCH_SPACE = ['top', 'right', 'bottom', 'left'];\n\nfunction getCandidateAnchor(pos, distance, rect, outPt, outDir) {\n var width = rect.width;\n var height = rect.height;\n\n switch (pos) {\n case 'top':\n outPt.set(rect.x + width / 2, rect.y - distance);\n outDir.set(0, -1);\n break;\n\n case 'bottom':\n outPt.set(rect.x + width / 2, rect.y + height + distance);\n outDir.set(0, 1);\n break;\n\n case 'left':\n outPt.set(rect.x - distance, rect.y + height / 2);\n outDir.set(-1, 0);\n break;\n\n case 'right':\n outPt.set(rect.x + width + distance, rect.y + height / 2);\n outDir.set(1, 0);\n break;\n }\n}\n\nfunction projectPointToArc(cx, cy, r, startAngle, endAngle, anticlockwise, x, y, out) {\n x -= cx;\n y -= cy;\n var d = Math.sqrt(x * x + y * y);\n x /= d;\n y /= d; // Intersect point.\n\n var ox = x * r + cx;\n var oy = y * r + cy;\n\n if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) {\n // Is a circle\n out[0] = ox;\n out[1] = oy;\n return d - r;\n }\n\n if (anticlockwise) {\n var tmp = startAngle;\n startAngle = normalizeRadian(endAngle);\n endAngle = normalizeRadian(tmp);\n } else {\n startAngle = normalizeRadian(startAngle);\n endAngle = normalizeRadian(endAngle);\n }\n\n if (startAngle > endAngle) {\n endAngle += PI2;\n }\n\n var angle = Math.atan2(y, x);\n\n if (angle < 0) {\n angle += PI2;\n }\n\n if (angle >= startAngle && angle <= endAngle || angle + PI2 >= startAngle && angle + PI2 <= endAngle) {\n // Project point is on the arc.\n out[0] = ox;\n out[1] = oy;\n return d - r;\n }\n\n var x1 = r * Math.cos(startAngle) + cx;\n var y1 = r * Math.sin(startAngle) + cy;\n var x2 = r * Math.cos(endAngle) + cx;\n var y2 = r * Math.sin(endAngle) + cy;\n var d1 = (x1 - x) * (x1 - x) + (y1 - y) * (y1 - y);\n var d2 = (x2 - x) * (x2 - x) + (y2 - y) * (y2 - y);\n\n if (d1 < d2) {\n out[0] = x1;\n out[1] = y1;\n return Math.sqrt(d1);\n } else {\n out[0] = x2;\n out[1] = y2;\n return Math.sqrt(d2);\n }\n}\n\nfunction projectPointToLine(x1, y1, x2, y2, x, y, out, limitToEnds) {\n var dx = x - x1;\n var dy = y - y1;\n var dx1 = x2 - x1;\n var dy1 = y2 - y1;\n var lineLen = Math.sqrt(dx1 * dx1 + dy1 * dy1);\n dx1 /= lineLen;\n dy1 /= lineLen; // dot product\n\n var projectedLen = dx * dx1 + dy * dy1;\n var t = projectedLen / lineLen;\n\n if (limitToEnds) {\n t = Math.min(Math.max(t, 0), 1);\n }\n\n t *= lineLen;\n var ox = out[0] = x1 + t * dx1;\n var oy = out[1] = y1 + t * dy1;\n return Math.sqrt((ox - x) * (ox - x) + (oy - y) * (oy - y));\n}\n\nfunction projectPointToRect(x1, y1, width, height, x, y, out) {\n if (width < 0) {\n x1 = x1 + width;\n width = -width;\n }\n\n if (height < 0) {\n y1 = y1 + height;\n height = -height;\n }\n\n var x2 = x1 + width;\n var y2 = y1 + height;\n var ox = out[0] = Math.min(Math.max(x, x1), x2);\n var oy = out[1] = Math.min(Math.max(y, y1), y2);\n return Math.sqrt((ox - x) * (ox - x) + (oy - y) * (oy - y));\n}\n\nvar tmpPt = [];\n\nfunction nearestPointOnRect(pt, rect, out) {\n var dist = projectPointToRect(rect.x, rect.y, rect.width, rect.height, pt.x, pt.y, tmpPt);\n out.set(tmpPt[0], tmpPt[1]);\n return dist;\n}\n/**\n * Calculate min distance corresponding point.\n * This method won't evaluate if point is in the path.\n */\n\n\nfunction nearestPointOnPath(pt, path, out) {\n var xi = 0;\n var yi = 0;\n var x0 = 0;\n var y0 = 0;\n var x1;\n var y1;\n var minDist = Infinity;\n var data = path.data;\n var x = pt.x;\n var y = pt.y;\n\n for (var i = 0; i < data.length;) {\n var cmd = data[i++];\n\n if (i === 1) {\n xi = data[i];\n yi = data[i + 1];\n x0 = xi;\n y0 = yi;\n }\n\n var d = minDist;\n\n switch (cmd) {\n case CMD.M:\n // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点\n // 在 closePath 的时候使用\n x0 = data[i++];\n y0 = data[i++];\n xi = x0;\n yi = y0;\n break;\n\n case CMD.L:\n d = projectPointToLine(xi, yi, data[i], data[i + 1], x, y, tmpPt, true);\n xi = data[i++];\n yi = data[i++];\n break;\n\n case CMD.C:\n d = cubicProjectPoint(xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], x, y, tmpPt);\n xi = data[i++];\n yi = data[i++];\n break;\n\n case CMD.Q:\n d = quadraticProjectPoint(xi, yi, data[i++], data[i++], data[i], data[i + 1], x, y, tmpPt);\n xi = data[i++];\n yi = data[i++];\n break;\n\n case CMD.A:\n // TODO Arc 判断的开销比较大\n var cx = data[i++];\n var cy = data[i++];\n var rx = data[i++];\n var ry = data[i++];\n var theta = data[i++];\n var dTheta = data[i++]; // TODO Arc 旋转\n\n i += 1;\n var anticlockwise = !!(1 - data[i++]);\n x1 = Math.cos(theta) * rx + cx;\n y1 = Math.sin(theta) * ry + cy; // 不是直接使用 arc 命令\n\n if (i <= 1) {\n // 第一个命令起点还未定义\n x0 = x1;\n y0 = y1;\n } // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放\n\n\n var _x = (x - cx) * ry / rx + cx;\n\n d = projectPointToArc(cx, cy, ry, theta, theta + dTheta, anticlockwise, _x, y, tmpPt);\n xi = Math.cos(theta + dTheta) * rx + cx;\n yi = Math.sin(theta + dTheta) * ry + cy;\n break;\n\n case CMD.R:\n x0 = xi = data[i++];\n y0 = yi = data[i++];\n var width = data[i++];\n var height = data[i++];\n d = projectPointToRect(x0, y0, width, height, x, y, tmpPt);\n break;\n\n case CMD.Z:\n d = projectPointToLine(xi, yi, x0, y0, x, y, tmpPt, true);\n xi = x0;\n yi = y0;\n break;\n }\n\n if (d < minDist) {\n minDist = d;\n out.set(tmpPt[0], tmpPt[1]);\n }\n }\n\n return minDist;\n} // Temporal varible for intermediate usage.\n\n\nvar pt0 = new Point();\nvar pt1 = new Point();\nvar pt2 = new Point();\nvar dir = new Point();\nvar dir2 = new Point();\n/**\n * Calculate a proper guide line based on the label position and graphic element definition\n * @param label\n * @param labelRect\n * @param target\n * @param targetRect\n */\n\nexport function updateLabelLinePoints(target, labelLineModel) {\n if (!target) {\n return;\n }\n\n var labelLine = target.getTextGuideLine();\n var label = target.getTextContent(); // Needs to create text guide in each charts.\n\n if (!(label && labelLine)) {\n return;\n }\n\n var labelGuideConfig = target.textGuideLineConfig || {};\n var points = [[0, 0], [0, 0], [0, 0]];\n var searchSpace = labelGuideConfig.candidates || DEFAULT_SEARCH_SPACE;\n var labelRect = label.getBoundingRect().clone();\n labelRect.applyTransform(label.getComputedTransform());\n var minDist = Infinity;\n var anchorPoint = labelGuideConfig.anchor;\n var targetTransform = target.getComputedTransform();\n var targetInversedTransform = targetTransform && invert([], targetTransform);\n var len = labelLineModel.get('length2') || 0;\n\n if (anchorPoint) {\n pt2.copy(anchorPoint);\n }\n\n for (var i = 0; i < searchSpace.length; i++) {\n var candidate = searchSpace[i];\n getCandidateAnchor(candidate, 0, labelRect, pt0, dir);\n Point.scaleAndAdd(pt1, pt0, dir, len); // Transform to target coord space.\n\n pt1.transform(targetInversedTransform); // Note: getBoundingRect will ensure the `path` being created.\n\n var boundingRect = target.getBoundingRect();\n var dist = anchorPoint ? anchorPoint.distance(pt1) : target instanceof Path ? nearestPointOnPath(pt1, target.path, pt2) : nearestPointOnRect(pt1, boundingRect, pt2); // TODO pt2 is in the path\n\n if (dist < minDist) {\n minDist = dist; // Transform back to global space.\n\n pt1.transform(targetTransform);\n pt2.transform(targetTransform);\n pt2.toArray(points[0]);\n pt1.toArray(points[1]);\n pt0.toArray(points[2]);\n }\n }\n\n limitTurnAngle(points, labelLineModel.get('minTurnAngle'));\n labelLine.setShape({\n points: points\n });\n} // Temporal variable for the limitTurnAngle function\n\nvar tmpArr = [];\nvar tmpProjPoint = new Point();\n/**\n * Reduce the line segment attached to the label to limit the turn angle between two segments.\n * @param linePoints\n * @param minTurnAngle Radian of minimum turn angle. 0 - 180\n */\n\nexport function limitTurnAngle(linePoints, minTurnAngle) {\n if (!(minTurnAngle <= 180 && minTurnAngle > 0)) {\n return;\n }\n\n minTurnAngle = minTurnAngle / 180 * Math.PI; // The line points can be\n // /pt1----pt2 (label)\n // /\n // pt0/\n\n pt0.fromArray(linePoints[0]);\n pt1.fromArray(linePoints[1]);\n pt2.fromArray(linePoints[2]);\n Point.sub(dir, pt0, pt1);\n Point.sub(dir2, pt2, pt1);\n var len1 = dir.len();\n var len2 = dir2.len();\n\n if (len1 < 1e-3 || len2 < 1e-3) {\n return;\n }\n\n dir.scale(1 / len1);\n dir2.scale(1 / len2);\n var angleCos = dir.dot(dir2);\n var minTurnAngleCos = Math.cos(minTurnAngle);\n\n if (minTurnAngleCos < angleCos) {\n // Smaller than minTurnAngle\n // Calculate project point of pt0 on pt1-pt2\n var d = projectPointToLine(pt1.x, pt1.y, pt2.x, pt2.y, pt0.x, pt0.y, tmpArr, false);\n tmpProjPoint.fromArray(tmpArr); // Calculate new projected length with limited minTurnAngle and get the new connect point\n\n tmpProjPoint.scaleAndAdd(dir2, d / Math.tan(Math.PI - minTurnAngle)); // Limit the new calculated connect point between pt1 and pt2.\n\n var t = pt2.x !== pt1.x ? (tmpProjPoint.x - pt1.x) / (pt2.x - pt1.x) : (tmpProjPoint.y - pt1.y) / (pt2.y - pt1.y);\n\n if (isNaN(t)) {\n return;\n }\n\n if (t < 0) {\n Point.copy(tmpProjPoint, pt1);\n } else if (t > 1) {\n Point.copy(tmpProjPoint, pt2);\n }\n\n tmpProjPoint.toArray(linePoints[1]);\n }\n}\n/**\n * Limit the angle of line and the surface\n * @param maxSurfaceAngle Radian of minimum turn angle. 0 - 180. 0 is same direction to normal. 180 is opposite\n */\n\nexport function limitSurfaceAngle(linePoints, surfaceNormal, maxSurfaceAngle) {\n if (!(maxSurfaceAngle <= 180 && maxSurfaceAngle > 0)) {\n return;\n }\n\n maxSurfaceAngle = maxSurfaceAngle / 180 * Math.PI;\n pt0.fromArray(linePoints[0]);\n pt1.fromArray(linePoints[1]);\n pt2.fromArray(linePoints[2]);\n Point.sub(dir, pt1, pt0);\n Point.sub(dir2, pt2, pt1);\n var len1 = dir.len();\n var len2 = dir2.len();\n\n if (len1 < 1e-3 || len2 < 1e-3) {\n return;\n }\n\n dir.scale(1 / len1);\n dir2.scale(1 / len2);\n var angleCos = dir.dot(surfaceNormal);\n var maxSurfaceAngleCos = Math.cos(maxSurfaceAngle);\n\n if (angleCos < maxSurfaceAngleCos) {\n // Calculate project point of pt0 on pt1-pt2\n var d = projectPointToLine(pt1.x, pt1.y, pt2.x, pt2.y, pt0.x, pt0.y, tmpArr, false);\n tmpProjPoint.fromArray(tmpArr);\n var HALF_PI = Math.PI / 2;\n var angle2 = Math.acos(dir2.dot(surfaceNormal));\n var newAngle = HALF_PI + angle2 - maxSurfaceAngle;\n\n if (newAngle >= HALF_PI) {\n // parallel\n Point.copy(tmpProjPoint, pt2);\n } else {\n // Calculate new projected length with limited minTurnAngle and get the new connect point\n tmpProjPoint.scaleAndAdd(dir2, d / Math.tan(Math.PI / 2 - newAngle)); // Limit the new calculated connect point between pt1 and pt2.\n\n var t = pt2.x !== pt1.x ? (tmpProjPoint.x - pt1.x) / (pt2.x - pt1.x) : (tmpProjPoint.y - pt1.y) / (pt2.y - pt1.y);\n\n if (isNaN(t)) {\n return;\n }\n\n if (t < 0) {\n Point.copy(tmpProjPoint, pt1);\n } else if (t > 1) {\n Point.copy(tmpProjPoint, pt2);\n }\n }\n\n tmpProjPoint.toArray(linePoints[1]);\n }\n}\n\nfunction setLabelLineState(labelLine, ignore, stateName, stateModel) {\n var isNormal = stateName === 'normal';\n var stateObj = isNormal ? labelLine : labelLine.ensureState(stateName); // Make sure display.\n\n stateObj.ignore = ignore; // Set smooth\n\n var smooth = stateModel.get('smooth');\n\n if (smooth && smooth === true) {\n smooth = 0.3;\n }\n\n stateObj.shape = stateObj.shape || {};\n\n if (smooth > 0) {\n stateObj.shape.smooth = smooth;\n }\n\n var styleObj = stateModel.getModel('lineStyle').getLineStyle();\n isNormal ? labelLine.useStyle(styleObj) : stateObj.style = styleObj;\n}\n\nfunction buildLabelLinePath(path, shape) {\n var smooth = shape.smooth;\n var points = shape.points;\n\n if (!points) {\n return;\n }\n\n path.moveTo(points[0][0], points[0][1]);\n\n if (smooth > 0 && points.length >= 3) {\n var len1 = vector.dist(points[0], points[1]);\n var len2 = vector.dist(points[1], points[2]);\n\n if (!len1 || !len2) {\n path.lineTo(points[1][0], points[1][1]);\n path.lineTo(points[2][0], points[2][1]);\n return;\n }\n\n var moveLen = Math.min(len1, len2) * smooth;\n var midPoint0 = vector.lerp([], points[1], points[0], moveLen / len1);\n var midPoint2 = vector.lerp([], points[1], points[2], moveLen / len2);\n var midPoint1 = vector.lerp([], midPoint0, midPoint2, 0.5);\n path.bezierCurveTo(midPoint0[0], midPoint0[1], midPoint0[0], midPoint0[1], midPoint1[0], midPoint1[1]);\n path.bezierCurveTo(midPoint2[0], midPoint2[1], midPoint2[0], midPoint2[1], points[2][0], points[2][1]);\n } else {\n for (var i = 1; i < points.length; i++) {\n path.lineTo(points[i][0], points[i][1]);\n }\n }\n}\n/**\n * Create a label line if necessary and set it's style.\n */\n\n\nexport function setLabelLineStyle(targetEl, statesModels, defaultStyle) {\n var labelLine = targetEl.getTextGuideLine();\n var label = targetEl.getTextContent();\n\n if (!label) {\n // Not show label line if there is no label.\n if (labelLine) {\n targetEl.removeTextGuideLine();\n }\n\n return;\n }\n\n var normalModel = statesModels.normal;\n var showNormal = normalModel.get('show');\n var labelIgnoreNormal = label.ignore;\n\n for (var i = 0; i < DISPLAY_STATES.length; i++) {\n var stateName = DISPLAY_STATES[i];\n var stateModel = statesModels[stateName];\n var isNormal = stateName === 'normal';\n\n if (stateModel) {\n var stateShow = stateModel.get('show');\n var isLabelIgnored = isNormal ? labelIgnoreNormal : retrieve2(label.states[stateName] && label.states[stateName].ignore, labelIgnoreNormal);\n\n if (isLabelIgnored // Not show when label is not shown in this state.\n || !retrieve2(stateShow, showNormal) // Use normal state by default if not set.\n ) {\n var stateObj = isNormal ? labelLine : labelLine && labelLine.states.normal;\n\n if (stateObj) {\n stateObj.ignore = true;\n }\n\n continue;\n } // Create labelLine if not exists\n\n\n if (!labelLine) {\n labelLine = new Polyline();\n targetEl.setTextGuideLine(labelLine); // Reset state of normal because it's new created.\n // NOTE: NORMAL should always been the first!\n\n if (!isNormal && (labelIgnoreNormal || !showNormal)) {\n setLabelLineState(labelLine, true, 'normal', statesModels.normal);\n } // Use same state proxy.\n\n\n if (targetEl.stateProxy) {\n labelLine.stateProxy = targetEl.stateProxy;\n }\n }\n\n setLabelLineState(labelLine, false, stateName, stateModel);\n }\n }\n\n if (labelLine) {\n defaults(labelLine.style, defaultStyle); // Not fill.\n\n labelLine.style.fill = null;\n var showAbove = normalModel.get('showAbove');\n var labelLineConfig = targetEl.textGuideLineConfig = targetEl.textGuideLineConfig || {};\n labelLineConfig.showAbove = showAbove || false; // Custom the buildPath.\n\n labelLine.buildPath = buildLabelLinePath;\n }\n}\nexport function getLabelLineStatesModels(itemModel, labelLineName) {\n labelLineName = labelLineName || 'labelLine';\n var statesModels = {\n normal: itemModel.getModel(labelLineName)\n };\n\n for (var i = 0; i < SPECIAL_STATES.length; i++) {\n var stateName = SPECIAL_STATES[i];\n statesModels[stateName] = itemModel.getModel([stateName, labelLineName]);\n }\n\n return statesModels;\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { BoundingRect, OrientedBoundingRect } from '../util/graphic';\nexport function prepareLayoutList(input) {\n var list = [];\n\n for (var i = 0; i < input.length; i++) {\n var rawItem = input[i];\n\n if (rawItem.defaultAttr.ignore) {\n continue;\n }\n\n var label = rawItem.label;\n var transform = label.getComputedTransform(); // NOTE: Get bounding rect after getComputedTransform, or label may not been updated by the host el.\n\n var localRect = label.getBoundingRect();\n var isAxisAligned = !transform || transform[1] < 1e-5 && transform[2] < 1e-5;\n var minMargin = label.style.margin || 0;\n var globalRect = localRect.clone();\n globalRect.applyTransform(transform);\n globalRect.x -= minMargin / 2;\n globalRect.y -= minMargin / 2;\n globalRect.width += minMargin;\n globalRect.height += minMargin;\n var obb = isAxisAligned ? new OrientedBoundingRect(localRect, transform) : null;\n list.push({\n label: label,\n labelLine: rawItem.labelLine,\n rect: globalRect,\n localRect: localRect,\n obb: obb,\n priority: rawItem.priority,\n defaultAttr: rawItem.defaultAttr,\n layoutOption: rawItem.computedLayoutOption,\n axisAligned: isAxisAligned,\n transform: transform\n });\n }\n\n return list;\n}\n\nfunction shiftLayout(list, xyDim, sizeDim, minBound, maxBound, balanceShift) {\n var len = list.length;\n\n if (len < 2) {\n return;\n }\n\n list.sort(function (a, b) {\n return a.rect[xyDim] - b.rect[xyDim];\n });\n var lastPos = 0;\n var delta;\n var adjusted = false;\n var shifts = [];\n var totalShifts = 0;\n\n for (var i = 0; i < len; i++) {\n var item = list[i];\n var rect = item.rect;\n delta = rect[xyDim] - lastPos;\n\n if (delta < 0) {\n // shiftForward(i, len, -delta);\n rect[xyDim] -= delta;\n item.label[xyDim] -= delta;\n adjusted = true;\n }\n\n var shift = Math.max(-delta, 0);\n shifts.push(shift);\n totalShifts += shift;\n lastPos = rect[xyDim] + rect[sizeDim];\n }\n\n if (totalShifts > 0 && balanceShift) {\n // Shift back to make the distribution more equally.\n shiftList(-totalShifts / len, 0, len);\n } // TODO bleedMargin?\n\n\n var first = list[0];\n var last = list[len - 1];\n var minGap;\n var maxGap;\n updateMinMaxGap(); // If ends exceed two bounds, squeeze at most 80%, then take the gap of two bounds.\n\n minGap < 0 && squeezeGaps(-minGap, 0.8);\n maxGap < 0 && squeezeGaps(maxGap, 0.8);\n updateMinMaxGap();\n takeBoundsGap(minGap, maxGap, 1);\n takeBoundsGap(maxGap, minGap, -1); // Handle bailout when there is not enough space.\n\n updateMinMaxGap();\n\n if (minGap < 0) {\n squeezeWhenBailout(-minGap);\n }\n\n if (maxGap < 0) {\n squeezeWhenBailout(maxGap);\n }\n\n function updateMinMaxGap() {\n minGap = first.rect[xyDim] - minBound;\n maxGap = maxBound - last.rect[xyDim] - last.rect[sizeDim];\n }\n\n function takeBoundsGap(gapThisBound, gapOtherBound, moveDir) {\n if (gapThisBound < 0) {\n // Move from other gap if can.\n var moveFromMaxGap = Math.min(gapOtherBound, -gapThisBound);\n\n if (moveFromMaxGap > 0) {\n shiftList(moveFromMaxGap * moveDir, 0, len);\n var remained = moveFromMaxGap + gapThisBound;\n\n if (remained < 0) {\n squeezeGaps(-remained * moveDir, 1);\n }\n } else {\n squeezeGaps(-gapThisBound * moveDir, 1);\n }\n }\n }\n\n function shiftList(delta, start, end) {\n if (delta !== 0) {\n adjusted = true;\n }\n\n for (var i = start; i < end; i++) {\n var item = list[i];\n var rect = item.rect;\n rect[xyDim] += delta;\n item.label[xyDim] += delta;\n }\n } // Squeeze gaps if the labels exceed margin.\n\n\n function squeezeGaps(delta, maxSqeezePercent) {\n var gaps = [];\n var totalGaps = 0;\n\n for (var i = 1; i < len; i++) {\n var prevItemRect = list[i - 1].rect;\n var gap = Math.max(list[i].rect[xyDim] - prevItemRect[xyDim] - prevItemRect[sizeDim], 0);\n gaps.push(gap);\n totalGaps += gap;\n }\n\n if (!totalGaps) {\n return;\n }\n\n var squeezePercent = Math.min(Math.abs(delta) / totalGaps, maxSqeezePercent);\n\n if (delta > 0) {\n for (var i = 0; i < len - 1; i++) {\n // Distribute the shift delta to all gaps.\n var movement = gaps[i] * squeezePercent; // Forward\n\n shiftList(movement, 0, i + 1);\n }\n } else {\n // Backward\n for (var i = len - 1; i > 0; i--) {\n // Distribute the shift delta to all gaps.\n var movement = gaps[i - 1] * squeezePercent;\n shiftList(-movement, i, len);\n }\n }\n }\n /**\n * Squeeze to allow overlap if there is no more space available.\n * Let other overlapping strategy like hideOverlap do the job instead of keep exceeding the bounds.\n */\n\n\n function squeezeWhenBailout(delta) {\n var dir = delta < 0 ? -1 : 1;\n delta = Math.abs(delta);\n var moveForEachLabel = Math.ceil(delta / (len - 1));\n\n for (var i = 0; i < len - 1; i++) {\n if (dir > 0) {\n // Forward\n shiftList(moveForEachLabel, 0, i + 1);\n } else {\n // Backward\n shiftList(-moveForEachLabel, len - i - 1, len);\n }\n\n delta -= moveForEachLabel;\n\n if (delta <= 0) {\n return;\n }\n }\n }\n\n return adjusted;\n}\n/**\n * Adjust labels on x direction to avoid overlap.\n */\n\n\nexport function shiftLayoutOnX(list, leftBound, rightBound, // If average the shifts on all labels and add them to 0\n// TODO: Not sure if should enable it.\n// Pros: The angle of lines will distribute more equally\n// Cons: In some layout. It may not what user wanted. like in pie. the label of last sector is usually changed unexpectedly.\nbalanceShift) {\n return shiftLayout(list, 'x', 'width', leftBound, rightBound, balanceShift);\n}\n/**\n * Adjust labels on y direction to avoid overlap.\n */\n\nexport function shiftLayoutOnY(list, topBound, bottomBound, // If average the shifts on all labels and add them to 0\nbalanceShift) {\n return shiftLayout(list, 'y', 'height', topBound, bottomBound, balanceShift);\n}\nexport function hideOverlap(labelList) {\n var displayedLabels = []; // TODO, render overflow visible first, put in the displayedLabels.\n\n labelList.sort(function (a, b) {\n return b.priority - a.priority;\n });\n var globalRect = new BoundingRect(0, 0, 0, 0);\n\n function hideEl(el) {\n if (!el.ignore) {\n // Show on emphasis.\n var emphasisState = el.ensureState('emphasis');\n\n if (emphasisState.ignore == null) {\n emphasisState.ignore = false;\n }\n }\n\n el.ignore = true;\n }\n\n for (var i = 0; i < labelList.length; i++) {\n var labelItem = labelList[i];\n var isAxisAligned = labelItem.axisAligned;\n var localRect = labelItem.localRect;\n var transform = labelItem.transform;\n var label = labelItem.label;\n var labelLine = labelItem.labelLine;\n globalRect.copy(labelItem.rect); // Add a threshold because layout may be aligned precisely.\n\n globalRect.width -= 0.1;\n globalRect.height -= 0.1;\n globalRect.x += 0.05;\n globalRect.y += 0.05;\n var obb = labelItem.obb;\n var overlapped = false;\n\n for (var j = 0; j < displayedLabels.length; j++) {\n var existsTextCfg = displayedLabels[j]; // Fast rejection.\n\n if (!globalRect.intersect(existsTextCfg.rect)) {\n continue;\n }\n\n if (isAxisAligned && existsTextCfg.axisAligned) {\n // Is overlapped\n overlapped = true;\n break;\n }\n\n if (!existsTextCfg.obb) {\n // If self is not axis aligned. But other is.\n existsTextCfg.obb = new OrientedBoundingRect(existsTextCfg.localRect, existsTextCfg.transform);\n }\n\n if (!obb) {\n // If self is axis aligned. But other is not.\n obb = new OrientedBoundingRect(localRect, transform);\n }\n\n if (obb.intersect(existsTextCfg.obb)) {\n overlapped = true;\n break;\n }\n } // TODO Callback to determine if this overlap should be handled?\n\n\n if (overlapped) {\n hideEl(label);\n labelLine && hideEl(labelLine);\n } else {\n label.attr('ignore', labelItem.defaultAttr.ignore);\n labelLine && labelLine.attr('ignore', labelItem.defaultAttr.labelGuideIgnore);\n displayedLabels.push(labelItem);\n }\n }\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n// TODO: move labels out of viewport.\nimport { BoundingRect, updateProps, initProps, isElementRemoved } from '../util/graphic';\nimport { getECData } from '../util/innerStore';\nimport { parsePercent } from '../util/number';\nimport Transformable from 'zrender/lib/core/Transformable';\nimport { updateLabelLinePoints, setLabelLineStyle, getLabelLineStatesModels } from './labelGuideHelper';\nimport { makeInner } from '../util/model';\nimport { retrieve2, each, keys, isFunction, filter, indexOf } from 'zrender/lib/core/util';\nimport { prepareLayoutList, hideOverlap, shiftLayoutOnX, shiftLayoutOnY } from './labelLayoutHelper';\nimport { labelInner, animateLabelValue } from './labelStyle';\n\nfunction cloneArr(points) {\n if (points) {\n var newPoints = [];\n\n for (var i = 0; i < points.length; i++) {\n newPoints.push(points[i].slice());\n }\n\n return newPoints;\n }\n}\n\nfunction prepareLayoutCallbackParams(labelItem, hostEl) {\n var label = labelItem.label;\n var labelLine = hostEl && hostEl.getTextGuideLine();\n return {\n dataIndex: labelItem.dataIndex,\n dataType: labelItem.dataType,\n seriesIndex: labelItem.seriesModel.seriesIndex,\n text: labelItem.label.style.text,\n rect: labelItem.hostRect,\n labelRect: labelItem.rect,\n // x: labelAttr.x,\n // y: labelAttr.y,\n align: label.style.align,\n verticalAlign: label.style.verticalAlign,\n labelLinePoints: cloneArr(labelLine && labelLine.shape.points)\n };\n}\n\nvar LABEL_OPTION_TO_STYLE_KEYS = ['align', 'verticalAlign', 'width', 'height', 'fontSize'];\nvar dummyTransformable = new Transformable();\nvar labelLayoutInnerStore = makeInner();\nvar labelLineAnimationStore = makeInner();\n\nfunction extendWithKeys(target, source, keys) {\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n\n if (source[key] != null) {\n target[key] = source[key];\n }\n }\n}\n\nvar LABEL_LAYOUT_PROPS = ['x', 'y', 'rotation'];\n\nvar LabelManager =\n/** @class */\nfunction () {\n function LabelManager() {\n this._labelList = [];\n this._chartViewList = [];\n }\n\n LabelManager.prototype.clearLabels = function () {\n this._labelList = [];\n this._chartViewList = [];\n };\n /**\n * Add label to manager\n */\n\n\n LabelManager.prototype._addLabel = function (dataIndex, dataType, seriesModel, label, layoutOption) {\n var labelStyle = label.style;\n var hostEl = label.__hostTarget;\n var textConfig = hostEl.textConfig || {}; // TODO: If label is in other state.\n\n var labelTransform = label.getComputedTransform();\n var labelRect = label.getBoundingRect().plain();\n BoundingRect.applyTransform(labelRect, labelRect, labelTransform);\n\n if (labelTransform) {\n dummyTransformable.setLocalTransform(labelTransform);\n } else {\n // Identity transform.\n dummyTransformable.x = dummyTransformable.y = dummyTransformable.rotation = dummyTransformable.originX = dummyTransformable.originY = 0;\n dummyTransformable.scaleX = dummyTransformable.scaleY = 1;\n }\n\n var host = label.__hostTarget;\n var hostRect;\n\n if (host) {\n hostRect = host.getBoundingRect().plain();\n var transform = host.getComputedTransform();\n BoundingRect.applyTransform(hostRect, hostRect, transform);\n }\n\n var labelGuide = hostRect && host.getTextGuideLine();\n\n this._labelList.push({\n label: label,\n labelLine: labelGuide,\n seriesModel: seriesModel,\n dataIndex: dataIndex,\n dataType: dataType,\n layoutOption: layoutOption,\n computedLayoutOption: null,\n rect: labelRect,\n hostRect: hostRect,\n // Label with lower priority will be hidden when overlapped\n // Use rect size as default priority\n priority: hostRect ? hostRect.width * hostRect.height : 0,\n // Save default label attributes.\n // For restore if developers want get back to default value in callback.\n defaultAttr: {\n ignore: label.ignore,\n labelGuideIgnore: labelGuide && labelGuide.ignore,\n x: dummyTransformable.x,\n y: dummyTransformable.y,\n rotation: dummyTransformable.rotation,\n style: {\n x: labelStyle.x,\n y: labelStyle.y,\n align: labelStyle.align,\n verticalAlign: labelStyle.verticalAlign,\n width: labelStyle.width,\n height: labelStyle.height,\n fontSize: labelStyle.fontSize\n },\n cursor: label.cursor,\n attachedPos: textConfig.position,\n attachedRot: textConfig.rotation\n }\n });\n };\n\n LabelManager.prototype.addLabelsOfSeries = function (chartView) {\n var _this = this;\n\n this._chartViewList.push(chartView);\n\n var seriesModel = chartView.__model;\n var layoutOption = seriesModel.get('labelLayout');\n /**\n * Ignore layouting if it's not specified anything.\n */\n\n if (!(isFunction(layoutOption) || keys(layoutOption).length)) {\n return;\n }\n\n chartView.group.traverse(function (child) {\n if (child.ignore) {\n return true; // Stop traverse descendants.\n } // Only support label being hosted on graphic elements.\n\n\n var textEl = child.getTextContent();\n var ecData = getECData(child); // Can only attach the text on the element with dataIndex\n\n if (textEl && !textEl.disableLabelLayout) {\n _this._addLabel(ecData.dataIndex, ecData.dataType, seriesModel, textEl, layoutOption);\n }\n });\n };\n\n LabelManager.prototype.updateLayoutConfig = function (api) {\n var width = api.getWidth();\n var height = api.getHeight();\n\n function createDragHandler(el, labelLineModel) {\n return function () {\n updateLabelLinePoints(el, labelLineModel);\n };\n }\n\n for (var i = 0; i < this._labelList.length; i++) {\n var labelItem = this._labelList[i];\n var label = labelItem.label;\n var hostEl = label.__hostTarget;\n var defaultLabelAttr = labelItem.defaultAttr;\n var layoutOption = void 0; // TODO A global layout option?\n\n if (typeof labelItem.layoutOption === 'function') {\n layoutOption = labelItem.layoutOption(prepareLayoutCallbackParams(labelItem, hostEl));\n } else {\n layoutOption = labelItem.layoutOption;\n }\n\n layoutOption = layoutOption || {};\n labelItem.computedLayoutOption = layoutOption;\n var degreeToRadian = Math.PI / 180;\n\n if (hostEl) {\n hostEl.setTextConfig({\n // Force to set local false.\n local: false,\n // Ignore position and rotation config on the host el if x or y is changed.\n position: layoutOption.x != null || layoutOption.y != null ? null : defaultLabelAttr.attachedPos,\n // Ignore rotation config on the host el if rotation is changed.\n rotation: layoutOption.rotate != null ? layoutOption.rotate * degreeToRadian : defaultLabelAttr.attachedRot,\n offset: [layoutOption.dx || 0, layoutOption.dy || 0]\n });\n }\n\n var needsUpdateLabelLine = false;\n\n if (layoutOption.x != null) {\n // TODO width of chart view.\n label.x = parsePercent(layoutOption.x, width);\n label.setStyle('x', 0); // Ignore movement in style. TODO: origin.\n\n needsUpdateLabelLine = true;\n } else {\n label.x = defaultLabelAttr.x;\n label.setStyle('x', defaultLabelAttr.style.x);\n }\n\n if (layoutOption.y != null) {\n // TODO height of chart view.\n label.y = parsePercent(layoutOption.y, height);\n label.setStyle('y', 0); // Ignore movement in style.\n\n needsUpdateLabelLine = true;\n } else {\n label.y = defaultLabelAttr.y;\n label.setStyle('y', defaultLabelAttr.style.y);\n }\n\n if (layoutOption.labelLinePoints) {\n var guideLine = hostEl.getTextGuideLine();\n\n if (guideLine) {\n guideLine.setShape({\n points: layoutOption.labelLinePoints\n }); // Not update\n\n needsUpdateLabelLine = false;\n }\n }\n\n var labelLayoutStore = labelLayoutInnerStore(label);\n labelLayoutStore.needsUpdateLabelLine = needsUpdateLabelLine;\n label.rotation = layoutOption.rotate != null ? layoutOption.rotate * degreeToRadian : defaultLabelAttr.rotation;\n\n for (var k = 0; k < LABEL_OPTION_TO_STYLE_KEYS.length; k++) {\n var key = LABEL_OPTION_TO_STYLE_KEYS[k];\n label.setStyle(key, layoutOption[key] != null ? layoutOption[key] : defaultLabelAttr.style[key]);\n }\n\n if (layoutOption.draggable) {\n label.draggable = true;\n label.cursor = 'move';\n\n if (hostEl) {\n var hostModel = labelItem.seriesModel;\n\n if (labelItem.dataIndex != null) {\n var data = labelItem.seriesModel.getData(labelItem.dataType);\n hostModel = data.getItemModel(labelItem.dataIndex);\n }\n\n label.on('drag', createDragHandler(hostEl, hostModel.getModel('labelLine')));\n }\n } else {\n // TODO Other drag functions?\n label.off('drag');\n label.cursor = defaultLabelAttr.cursor;\n }\n }\n };\n\n LabelManager.prototype.layout = function (api) {\n var width = api.getWidth();\n var height = api.getHeight();\n var labelList = prepareLayoutList(this._labelList);\n var labelsNeedsAdjustOnX = filter(labelList, function (item) {\n return item.layoutOption.moveOverlap === 'shiftX';\n });\n var labelsNeedsAdjustOnY = filter(labelList, function (item) {\n return item.layoutOption.moveOverlap === 'shiftY';\n });\n shiftLayoutOnX(labelsNeedsAdjustOnX, 0, width);\n shiftLayoutOnY(labelsNeedsAdjustOnY, 0, height);\n var labelsNeedsHideOverlap = filter(labelList, function (item) {\n return item.layoutOption.hideOverlap;\n });\n hideOverlap(labelsNeedsHideOverlap);\n };\n /**\n * Process all labels. Not only labels with layoutOption.\n */\n\n\n LabelManager.prototype.processLabelsOverall = function () {\n var _this = this;\n\n each(this._chartViewList, function (chartView) {\n var seriesModel = chartView.__model;\n var ignoreLabelLineUpdate = chartView.ignoreLabelLineUpdate;\n var animationEnabled = seriesModel.isAnimationEnabled();\n chartView.group.traverse(function (child) {\n if (child.ignore) {\n return true; // Stop traverse descendants.\n }\n\n var needsUpdateLabelLine = !ignoreLabelLineUpdate;\n var label = child.getTextContent();\n\n if (!needsUpdateLabelLine && label) {\n needsUpdateLabelLine = labelLayoutInnerStore(label).needsUpdateLabelLine;\n }\n\n if (needsUpdateLabelLine) {\n _this._updateLabelLine(child, seriesModel);\n }\n\n if (animationEnabled) {\n _this._animateLabels(child, seriesModel);\n }\n });\n });\n };\n\n LabelManager.prototype._updateLabelLine = function (el, seriesModel) {\n // Only support label being hosted on graphic elements.\n var textEl = el.getTextContent(); // Update label line style.\n\n var ecData = getECData(el);\n var dataIndex = ecData.dataIndex; // Only support labelLine on the labels represent data.\n\n if (textEl && dataIndex != null) {\n var data = seriesModel.getData(ecData.dataType);\n var itemModel = data.getItemModel(dataIndex);\n var defaultStyle = {};\n var visualStyle = data.getItemVisual(dataIndex, 'style');\n var visualType = data.getVisual('drawType'); // Default to be same with main color\n\n defaultStyle.stroke = visualStyle[visualType];\n var labelLineModel = itemModel.getModel('labelLine');\n setLabelLineStyle(el, getLabelLineStatesModels(itemModel), defaultStyle);\n updateLabelLinePoints(el, labelLineModel);\n }\n };\n\n LabelManager.prototype._animateLabels = function (el, seriesModel) {\n var textEl = el.getTextContent();\n var guideLine = el.getTextGuideLine(); // Animate\n\n if (textEl && !textEl.ignore && !textEl.invisible && !el.disableLabelAnimation && !isElementRemoved(el)) {\n var layoutStore = labelLayoutInnerStore(textEl);\n var oldLayout = layoutStore.oldLayout;\n var ecData = getECData(el);\n var dataIndex = ecData.dataIndex;\n var newProps = {\n x: textEl.x,\n y: textEl.y,\n rotation: textEl.rotation\n };\n var data = seriesModel.getData(ecData.dataType);\n\n if (!oldLayout) {\n textEl.attr(newProps); // Disable fade in animation if value animation is enabled.\n\n if (!labelInner(textEl).valueAnimation) {\n var oldOpacity = retrieve2(textEl.style.opacity, 1); // Fade in animation\n\n textEl.style.opacity = 0;\n initProps(textEl, {\n style: {\n opacity: oldOpacity\n }\n }, seriesModel, dataIndex);\n }\n } else {\n textEl.attr(oldLayout); // Make sure the animation from is in the right status.\n\n var prevStates = el.prevStates;\n\n if (prevStates) {\n if (indexOf(prevStates, 'select') >= 0) {\n textEl.attr(layoutStore.oldLayoutSelect);\n }\n\n if (indexOf(prevStates, 'emphasis') >= 0) {\n textEl.attr(layoutStore.oldLayoutEmphasis);\n }\n }\n\n updateProps(textEl, newProps, seriesModel, dataIndex);\n }\n\n layoutStore.oldLayout = newProps;\n\n if (textEl.states.select) {\n var layoutSelect = layoutStore.oldLayoutSelect = {};\n extendWithKeys(layoutSelect, newProps, LABEL_LAYOUT_PROPS);\n extendWithKeys(layoutSelect, textEl.states.select, LABEL_LAYOUT_PROPS);\n }\n\n if (textEl.states.emphasis) {\n var layoutEmphasis = layoutStore.oldLayoutEmphasis = {};\n extendWithKeys(layoutEmphasis, newProps, LABEL_LAYOUT_PROPS);\n extendWithKeys(layoutEmphasis, textEl.states.emphasis, LABEL_LAYOUT_PROPS);\n }\n\n animateLabelValue(textEl, dataIndex, data, seriesModel, seriesModel);\n }\n\n if (guideLine && !guideLine.ignore && !guideLine.invisible) {\n var layoutStore = labelLineAnimationStore(guideLine);\n var oldLayout = layoutStore.oldLayout;\n var newLayout = {\n points: guideLine.shape.points\n };\n\n if (!oldLayout) {\n guideLine.setShape(newLayout);\n guideLine.style.strokePercent = 0;\n initProps(guideLine, {\n style: {\n strokePercent: 1\n }\n }, seriesModel);\n } else {\n guideLine.attr({\n shape: oldLayout\n });\n updateProps(guideLine, {\n shape: newLayout\n }, seriesModel);\n }\n\n layoutStore.oldLayout = newLayout;\n }\n };\n\n return LabelManager;\n}();\n\nexport default LabelManager;","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { extend, each, isArray } from 'zrender/lib/core/util';\nimport { deprecateReplaceLog, deprecateLog } from '../util/log';\nimport { queryDataIndex } from '../util/model'; // Legacy data selection action.\n// Inlucdes: pieSelect, pieUnSelect, pieToggleSelect, mapSelect, mapUnSelect, mapToggleSelect\n\nexport function createLegacyDataSelectAction(seriesType, ecRegisterAction) {\n function getSeriesIndices(ecModel, payload) {\n var seriesIndices = [];\n ecModel.eachComponent({\n mainType: 'series',\n subType: seriesType,\n query: payload\n }, function (seriesModel) {\n seriesIndices.push(seriesModel.seriesIndex);\n });\n return seriesIndices;\n }\n\n each([[seriesType + 'ToggleSelect', 'toggleSelect'], [seriesType + 'Select', 'select'], [seriesType + 'UnSelect', 'unselect']], function (eventsMap) {\n ecRegisterAction(eventsMap[0], function (payload, ecModel, api) {\n payload = extend({}, payload);\n\n if (process.env.NODE_ENV !== 'production') {\n deprecateReplaceLog(payload.type, eventsMap[1]);\n }\n\n api.dispatchAction(extend(payload, {\n type: eventsMap[1],\n seriesIndex: getSeriesIndices(ecModel, payload)\n }));\n });\n });\n}\n\nfunction handleSeriesLegacySelectEvents(type, eventPostfix, ecIns, ecModel, payload) {\n var legacyEventName = type + eventPostfix;\n\n if (!ecIns.isSilent(legacyEventName)) {\n if (process.env.NODE_ENV !== 'production') {\n deprecateLog(\"event \" + legacyEventName + \" is deprecated.\");\n }\n\n ecModel.eachComponent({\n mainType: 'series',\n subType: 'pie'\n }, function (seriesModel) {\n var seriesIndex = seriesModel.seriesIndex;\n var selected = payload.selected;\n\n for (var i = 0; i < selected.length; i++) {\n if (selected[i].seriesIndex === seriesIndex) {\n var data = seriesModel.getData();\n var dataIndex = queryDataIndex(data, payload.fromActionPayload);\n ecIns.trigger(legacyEventName, {\n type: legacyEventName,\n seriesId: seriesModel.id,\n name: isArray(dataIndex) ? data.getName(dataIndex[0]) : data.getName(dataIndex),\n selected: extend({}, seriesModel.option.selectedMap)\n });\n }\n }\n });\n }\n}\n\nexport function handleLegacySelectEvents(messageCenter, ecIns, api) {\n messageCenter.on('selectchanged', function (params) {\n var ecModel = api.getModel();\n\n if (params.isFromClick) {\n handleSeriesLegacySelectEvents('map', 'selectchanged', ecIns, ecModel, params);\n handleSeriesLegacySelectEvents('pie', 'selectchanged', ecIns, ecModel, params);\n } else if (params.fromAction === 'select') {\n handleSeriesLegacySelectEvents('map', 'selected', ecIns, ecModel, params);\n handleSeriesLegacySelectEvents('pie', 'selected', ecIns, ecModel, params);\n } else if (params.fromAction === 'unselect') {\n handleSeriesLegacySelectEvents('map', 'unselected', ecIns, ecModel, params);\n handleSeriesLegacySelectEvents('pie', 'unselected', ecIns, ecModel, params);\n }\n });\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nexport function findEventDispatcher(target, det, returnFirstMatch) {\n var found;\n\n while (target) {\n if (det(target)) {\n found = target;\n\n if (returnFirstMatch) {\n break;\n }\n }\n\n target = target.__hostTarget || target.parent;\n }\n\n return found;\n}","var wmUniqueIndex = Math.round(Math.random() * 9);\nvar WeakMap = (function () {\n function WeakMap() {\n this._id = '__ec_inner_' + wmUniqueIndex++;\n }\n WeakMap.prototype.get = function (key) {\n return this._guard(key)[this._id];\n };\n WeakMap.prototype.set = function (key, value) {\n var target = this._guard(key);\n if (typeof Object.defineProperty === 'function') {\n Object.defineProperty(target, this._id, {\n value: value,\n enumerable: false,\n configurable: true\n });\n }\n else {\n target[this._id] = value;\n }\n return this;\n };\n WeakMap.prototype[\"delete\"] = function (key) {\n if (this.has(key)) {\n delete this._guard(key)[this._id];\n return true;\n }\n return false;\n };\n WeakMap.prototype.has = function (key) {\n return !!this._guard(key)[this._id];\n };\n WeakMap.prototype._guard = function (key) {\n if (key !== Object(key)) {\n throw TypeError('Value of WeakMap is not a non-null object.');\n }\n return key;\n };\n return WeakMap;\n}());\nexport default WeakMap;\n","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n// Symbol factory\nimport * as zrUtil from 'zrender/lib/core/util';\nimport * as graphic from './graphic';\nimport BoundingRect from 'zrender/lib/core/BoundingRect';\nimport { calculateTextPosition } from 'zrender/lib/contain/text';\n/**\n * Triangle shape\n * @inner\n */\n\nvar Triangle = graphic.Path.extend({\n type: 'triangle',\n shape: {\n cx: 0,\n cy: 0,\n width: 0,\n height: 0\n },\n buildPath: function (path, shape) {\n var cx = shape.cx;\n var cy = shape.cy;\n var width = shape.width / 2;\n var height = shape.height / 2;\n path.moveTo(cx, cy - height);\n path.lineTo(cx + width, cy + height);\n path.lineTo(cx - width, cy + height);\n path.closePath();\n }\n});\n/**\n * Diamond shape\n * @inner\n */\n\nvar Diamond = graphic.Path.extend({\n type: 'diamond',\n shape: {\n cx: 0,\n cy: 0,\n width: 0,\n height: 0\n },\n buildPath: function (path, shape) {\n var cx = shape.cx;\n var cy = shape.cy;\n var width = shape.width / 2;\n var height = shape.height / 2;\n path.moveTo(cx, cy - height);\n path.lineTo(cx + width, cy);\n path.lineTo(cx, cy + height);\n path.lineTo(cx - width, cy);\n path.closePath();\n }\n});\n/**\n * Pin shape\n * @inner\n */\n\nvar Pin = graphic.Path.extend({\n type: 'pin',\n shape: {\n // x, y on the cusp\n x: 0,\n y: 0,\n width: 0,\n height: 0\n },\n buildPath: function (path, shape) {\n var x = shape.x;\n var y = shape.y;\n var w = shape.width / 5 * 3; // Height must be larger than width\n\n var h = Math.max(w, shape.height);\n var r = w / 2; // Dist on y with tangent point and circle center\n\n var dy = r * r / (h - r);\n var cy = y - h + r + dy;\n var angle = Math.asin(dy / r); // Dist on x with tangent point and circle center\n\n var dx = Math.cos(angle) * r;\n var tanX = Math.sin(angle);\n var tanY = Math.cos(angle);\n var cpLen = r * 0.6;\n var cpLen2 = r * 0.7;\n path.moveTo(x - dx, cy + dy);\n path.arc(x, cy, r, Math.PI - angle, Math.PI * 2 + angle);\n path.bezierCurveTo(x + dx - tanX * cpLen, cy + dy + tanY * cpLen, x, y - cpLen2, x, y);\n path.bezierCurveTo(x, y - cpLen2, x - dx + tanX * cpLen, cy + dy + tanY * cpLen, x - dx, cy + dy);\n path.closePath();\n }\n});\n/**\n * Arrow shape\n * @inner\n */\n\nvar Arrow = graphic.Path.extend({\n type: 'arrow',\n shape: {\n x: 0,\n y: 0,\n width: 0,\n height: 0\n },\n buildPath: function (ctx, shape) {\n var height = shape.height;\n var width = shape.width;\n var x = shape.x;\n var y = shape.y;\n var dx = width / 3 * 2;\n ctx.moveTo(x, y);\n ctx.lineTo(x + dx, y + height);\n ctx.lineTo(x, y + height / 4 * 3);\n ctx.lineTo(x - dx, y + height);\n ctx.lineTo(x, y);\n ctx.closePath();\n }\n});\n/**\n * Map of path contructors\n */\n// TODO Use function to build symbol path.\n\nvar symbolCtors = {\n // Use small height rect to simulate line.\n // Avoid using stroke.\n line: graphic.Rect,\n rect: graphic.Rect,\n roundRect: graphic.Rect,\n square: graphic.Rect,\n circle: graphic.Circle,\n diamond: Diamond,\n pin: Pin,\n arrow: Arrow,\n triangle: Triangle\n}; // NOTICE Only use fill. No line!\n\nvar symbolShapeMakers = {\n line: function (x, y, w, h, shape) {\n var thickness = 2; // A thin line\n\n shape.x = x;\n shape.y = y + h / 2 - thickness / 2;\n shape.width = w;\n shape.height = thickness;\n },\n rect: function (x, y, w, h, shape) {\n shape.x = x;\n shape.y = y;\n shape.width = w;\n shape.height = h;\n },\n roundRect: function (x, y, w, h, shape) {\n shape.x = x;\n shape.y = y;\n shape.width = w;\n shape.height = h;\n shape.r = Math.min(w, h) / 4;\n },\n square: function (x, y, w, h, shape) {\n var size = Math.min(w, h);\n shape.x = x;\n shape.y = y;\n shape.width = size;\n shape.height = size;\n },\n circle: function (x, y, w, h, shape) {\n // Put circle in the center of square\n shape.cx = x + w / 2;\n shape.cy = y + h / 2;\n shape.r = Math.min(w, h) / 2;\n },\n diamond: function (x, y, w, h, shape) {\n shape.cx = x + w / 2;\n shape.cy = y + h / 2;\n shape.width = w;\n shape.height = h;\n },\n pin: function (x, y, w, h, shape) {\n shape.x = x + w / 2;\n shape.y = y + h / 2;\n shape.width = w;\n shape.height = h;\n },\n arrow: function (x, y, w, h, shape) {\n shape.x = x + w / 2;\n shape.y = y + h / 2;\n shape.width = w;\n shape.height = h;\n },\n triangle: function (x, y, w, h, shape) {\n shape.cx = x + w / 2;\n shape.cy = y + h / 2;\n shape.width = w;\n shape.height = h;\n }\n};\nexport var symbolBuildProxies = {};\nzrUtil.each(symbolCtors, function (Ctor, name) {\n symbolBuildProxies[name] = new Ctor();\n});\nvar SymbolClz = graphic.Path.extend({\n type: 'symbol',\n shape: {\n symbolType: '',\n x: 0,\n y: 0,\n width: 0,\n height: 0\n },\n calculateTextPosition: function (out, config, rect) {\n var res = calculateTextPosition(out, config, rect);\n var shape = this.shape;\n\n if (shape && shape.symbolType === 'pin' && config.position === 'inside') {\n res.y = rect.y + rect.height * 0.4;\n }\n\n return res;\n },\n buildPath: function (ctx, shape, inBundle) {\n var symbolType = shape.symbolType;\n\n if (symbolType !== 'none') {\n var proxySymbol = symbolBuildProxies[symbolType];\n\n if (!proxySymbol) {\n // Default rect\n symbolType = 'rect';\n proxySymbol = symbolBuildProxies[symbolType];\n }\n\n symbolShapeMakers[symbolType](shape.x, shape.y, shape.width, shape.height, proxySymbol.shape);\n proxySymbol.buildPath(ctx, proxySymbol.shape, inBundle);\n }\n }\n}); // Provide setColor helper method to avoid determine if set the fill or stroke outside\n\nfunction symbolPathSetColor(color, innerColor) {\n if (this.type !== 'image') {\n var symbolStyle = this.style;\n\n if (this.__isEmptyBrush) {\n symbolStyle.stroke = color;\n symbolStyle.fill = innerColor || '#fff'; // TODO Same width with lineStyle in LineView.\n\n symbolStyle.lineWidth = 2;\n } else {\n symbolStyle.fill = color;\n }\n\n this.markRedraw();\n }\n}\n/**\n * Create a symbol element with given symbol configuration: shape, x, y, width, height, color\n */\n\n\nexport function createSymbol(symbolType, x, y, w, h, color, // whether to keep the ratio of w/h,\nkeepAspect) {\n // TODO Support image object, DynamicImage.\n var isEmpty = symbolType.indexOf('empty') === 0;\n\n if (isEmpty) {\n symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6);\n }\n\n var symbolPath;\n\n if (symbolType.indexOf('image://') === 0) {\n symbolPath = graphic.makeImage(symbolType.slice(8), new BoundingRect(x, y, w, h), keepAspect ? 'center' : 'cover');\n } else if (symbolType.indexOf('path://') === 0) {\n symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h), keepAspect ? 'center' : 'cover');\n } else {\n symbolPath = new SymbolClz({\n shape: {\n symbolType: symbolType,\n x: x,\n y: y,\n width: w,\n height: h\n }\n });\n }\n\n symbolPath.__isEmptyBrush = isEmpty; // TODO Should deprecate setColor\n\n symbolPath.setColor = symbolPathSetColor;\n\n if (color) {\n symbolPath.setColor(color);\n }\n\n return symbolPath;\n}","export function createLinearGradient(ctx, obj, rect) {\n var x = obj.x == null ? 0 : obj.x;\n var x2 = obj.x2 == null ? 1 : obj.x2;\n var y = obj.y == null ? 0 : obj.y;\n var y2 = obj.y2 == null ? 0 : obj.y2;\n if (!obj.global) {\n x = x * rect.width + rect.x;\n x2 = x2 * rect.width + rect.x;\n y = y * rect.height + rect.y;\n y2 = y2 * rect.height + rect.y;\n }\n x = isNaN(x) ? 0 : x;\n x2 = isNaN(x2) ? 1 : x2;\n y = isNaN(y) ? 0 : y;\n y2 = isNaN(y2) ? 0 : y2;\n var canvasGradient = ctx.createLinearGradient(x, y, x2, y2);\n return canvasGradient;\n}\nexport function createRadialGradient(ctx, obj, rect) {\n var width = rect.width;\n var height = rect.height;\n var min = Math.min(width, height);\n var x = obj.x == null ? 0.5 : obj.x;\n var y = obj.y == null ? 0.5 : obj.y;\n var r = obj.r == null ? 0.5 : obj.r;\n if (!obj.global) {\n x = x * width + rect.x;\n y = y * height + rect.y;\n r = r * min;\n }\n var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r);\n return canvasGradient;\n}\nexport function getCanvasGradient(ctx, obj, rect) {\n var canvasGradient = obj.type === 'radial'\n ? createRadialGradient(ctx, obj, rect)\n : createLinearGradient(ctx, obj, rect);\n var colorStops = obj.colorStops;\n for (var i = 0; i < colorStops.length; i++) {\n canvasGradient.addColorStop(colorStops[i].offset, colorStops[i].color);\n }\n return canvasGradient;\n}\nexport function isClipPathChanged(clipPaths, prevClipPaths) {\n if (clipPaths === prevClipPaths || (!clipPaths && !prevClipPaths)) {\n return false;\n }\n if (!clipPaths || !prevClipPaths || (clipPaths.length !== prevClipPaths.length)) {\n return true;\n }\n for (var i = 0; i < clipPaths.length; i++) {\n if (clipPaths[i] !== prevClipPaths[i]) {\n return true;\n }\n }\n return false;\n}\n","import { isArray, isNumber } from '../../core/util';\nexport function normalizeLineDash(lineType, lineWidth) {\n if (!lineType || lineType === 'solid' || !(lineWidth > 0)) {\n return null;\n }\n lineWidth = lineWidth || 1;\n return lineType === 'dashed'\n ? [4 * lineWidth, 2 * lineWidth]\n : lineType === 'dotted'\n ? [lineWidth]\n : isNumber(lineType)\n ? [lineType] : isArray(lineType) ? lineType : null;\n}\n","import { DEFAULT_COMMON_STYLE } from '../graphic/Displayable';\nimport PathProxy from '../core/PathProxy';\nimport { createOrUpdateImage, isImageReady } from '../graphic/helper/image';\nimport { getCanvasGradient, isClipPathChanged } from './helper';\nimport Path from '../graphic/Path';\nimport ZRImage from '../graphic/Image';\nimport TSpan from '../graphic/TSpan';\nimport { DEFAULT_FONT } from '../contain/text';\nimport { map } from '../core/util';\nimport { normalizeLineDash } from '../graphic/helper/dashStyle';\nimport Element from '../Element';\nimport IncrementalDisplayable from '../graphic/IncrementalDisplayable';\nvar pathProxyForDraw = new PathProxy(true);\nfunction styleHasStroke(style) {\n var stroke = style.stroke;\n return !(stroke == null || stroke === 'none' || !(style.lineWidth > 0));\n}\nfunction styleHasFill(style) {\n var fill = style.fill;\n return fill != null && fill !== 'none';\n}\nfunction doFillPath(ctx, style) {\n if (style.fillOpacity != null && style.fillOpacity !== 1) {\n var originalGlobalAlpha = ctx.globalAlpha;\n ctx.globalAlpha = style.fillOpacity * style.opacity;\n ctx.fill();\n ctx.globalAlpha = originalGlobalAlpha;\n }\n else {\n ctx.fill();\n }\n}\nfunction doStrokePath(ctx, style) {\n if (style.strokeOpacity != null && style.strokeOpacity !== 1) {\n var originalGlobalAlpha = ctx.globalAlpha;\n ctx.globalAlpha = style.strokeOpacity * style.opacity;\n ctx.stroke();\n ctx.globalAlpha = originalGlobalAlpha;\n }\n else {\n ctx.stroke();\n }\n}\nexport function createCanvasPattern(ctx, pattern, el) {\n var image = createOrUpdateImage(pattern.image, pattern.__image, el);\n if (isImageReady(image)) {\n var canvasPattern = ctx.createPattern(image, pattern.repeat || 'repeat');\n if (typeof DOMMatrix === 'function') {\n var matrix = new DOMMatrix();\n matrix.rotateSelf(0, 0, (pattern.rotation || 0) / Math.PI * 180);\n matrix.scaleSelf((pattern.scaleX || 1), (pattern.scaleY || 1));\n matrix.translateSelf((pattern.x || 0), (pattern.y || 0));\n canvasPattern.setTransform(matrix);\n }\n return canvasPattern;\n }\n}\nfunction brushPath(ctx, el, style, inBatch) {\n var hasStroke = styleHasStroke(style);\n var hasFill = styleHasFill(style);\n var strokePercent = style.strokePercent;\n var strokePart = strokePercent < 1;\n var firstDraw = !el.path;\n if ((!el.silent || strokePart) && firstDraw) {\n el.createPathProxy();\n }\n var path = el.path || pathProxyForDraw;\n if (!inBatch) {\n var fill = style.fill;\n var stroke = style.stroke;\n var hasFillGradient = hasFill && !!fill.colorStops;\n var hasStrokeGradient = hasStroke && !!stroke.colorStops;\n var hasFillPattern = hasFill && !!fill.image;\n var hasStrokePattern = hasStroke && !!stroke.image;\n var fillGradient = void 0;\n var strokeGradient = void 0;\n var fillPattern = void 0;\n var strokePattern = void 0;\n var rect = void 0;\n if (hasFillGradient || hasStrokeGradient) {\n rect = el.getBoundingRect();\n }\n if (hasFillGradient) {\n fillGradient = el.__dirty\n ? getCanvasGradient(ctx, fill, rect)\n : el.__canvasFillGradient;\n el.__canvasFillGradient = fillGradient;\n }\n if (hasStrokeGradient) {\n strokeGradient = el.__dirty\n ? getCanvasGradient(ctx, stroke, rect)\n : el.__canvasStrokeGradient;\n el.__canvasStrokeGradient = strokeGradient;\n }\n if (hasFillPattern) {\n fillPattern = (el.__dirty || !el.__canvasFillPattern)\n ? createCanvasPattern(ctx, fill, el)\n : el.__canvasFillPattern;\n el.__canvasFillPattern = fillPattern;\n }\n if (hasStrokePattern) {\n strokePattern = (el.__dirty || !el.__canvasStrokePattern)\n ? createCanvasPattern(ctx, stroke, el)\n : el.__canvasStrokePattern;\n el.__canvasStrokePattern = fillPattern;\n }\n if (hasFillGradient) {\n ctx.fillStyle = fillGradient;\n }\n else if (hasFillPattern) {\n if (fillPattern) {\n ctx.fillStyle = fillPattern;\n }\n else {\n hasFill = false;\n }\n }\n if (hasStrokeGradient) {\n ctx.strokeStyle = strokeGradient;\n }\n else if (hasStrokePattern) {\n if (strokePattern) {\n ctx.strokeStyle = strokePattern;\n }\n else {\n hasStroke = false;\n }\n }\n }\n var lineDash = style.lineDash && style.lineWidth > 0 && normalizeLineDash(style.lineDash, style.lineWidth);\n var lineDashOffset = style.lineDashOffset;\n var ctxLineDash = !!ctx.setLineDash;\n var scale = el.getGlobalScale();\n path.setScale(scale[0], scale[1], el.segmentIgnoreThreshold);\n if (lineDash) {\n var lineScale_1 = (style.strokeNoScale && el.getLineScale) ? el.getLineScale() : 1;\n if (lineScale_1 && lineScale_1 !== 1) {\n lineDash = map(lineDash, function (rawVal) {\n return rawVal / lineScale_1;\n });\n lineDashOffset /= lineScale_1;\n }\n }\n var needsRebuild = true;\n if (firstDraw || (el.__dirty & Path.SHAPE_CHANGED_BIT)\n || (lineDash && !ctxLineDash && hasStroke)) {\n path.setDPR(ctx.dpr);\n if (strokePart) {\n path.setContext(null);\n }\n else {\n path.setContext(ctx);\n needsRebuild = false;\n }\n path.reset();\n if (lineDash && !ctxLineDash) {\n path.setLineDash(lineDash);\n path.setLineDashOffset(lineDashOffset);\n }\n el.buildPath(path, el.shape, inBatch);\n path.toStatic();\n el.pathUpdated();\n }\n if (needsRebuild) {\n path.rebuildPath(ctx, strokePart ? strokePercent : 1);\n }\n if (lineDash && ctxLineDash) {\n ctx.setLineDash(lineDash);\n ctx.lineDashOffset = lineDashOffset;\n }\n if (!inBatch) {\n if (style.strokeFirst) {\n if (hasStroke) {\n doStrokePath(ctx, style);\n }\n if (hasFill) {\n doFillPath(ctx, style);\n }\n }\n else {\n if (hasFill) {\n doFillPath(ctx, style);\n }\n if (hasStroke) {\n doStrokePath(ctx, style);\n }\n }\n }\n if (lineDash && ctxLineDash) {\n ctx.setLineDash([]);\n }\n}\nfunction brushImage(ctx, el, style) {\n var image = el.__image = createOrUpdateImage(style.image, el.__image, el, el.onload);\n if (!image || !isImageReady(image)) {\n return;\n }\n var x = style.x || 0;\n var y = style.y || 0;\n var width = el.getWidth();\n var height = el.getHeight();\n var aspect = image.width / image.height;\n if (width == null && height != null) {\n width = height * aspect;\n }\n else if (height == null && width != null) {\n height = width / aspect;\n }\n else if (width == null && height == null) {\n width = image.width;\n height = image.height;\n }\n if (style.sWidth && style.sHeight) {\n var sx = style.sx || 0;\n var sy = style.sy || 0;\n ctx.drawImage(image, sx, sy, style.sWidth, style.sHeight, x, y, width, height);\n }\n else if (style.sx && style.sy) {\n var sx = style.sx;\n var sy = style.sy;\n var sWidth = width - sx;\n var sHeight = height - sy;\n ctx.drawImage(image, sx, sy, sWidth, sHeight, x, y, width, height);\n }\n else {\n ctx.drawImage(image, x, y, width, height);\n }\n}\nfunction brushText(ctx, el, style) {\n var text = style.text;\n text != null && (text += '');\n if (text) {\n ctx.font = style.font || DEFAULT_FONT;\n ctx.textAlign = style.textAlign;\n ctx.textBaseline = style.textBaseline;\n var hasLineDash = void 0;\n if (ctx.setLineDash) {\n var lineDash = style.lineDash && style.lineWidth > 0 && normalizeLineDash(style.lineDash, style.lineWidth);\n var lineDashOffset = style.lineDashOffset;\n if (lineDash) {\n var lineScale_2 = (style.strokeNoScale && el.getLineScale) ? el.getLineScale() : 1;\n if (lineScale_2 && lineScale_2 !== 1) {\n lineDash = map(lineDash, function (rawVal) {\n return rawVal / lineScale_2;\n });\n lineDashOffset /= lineScale_2;\n }\n ctx.setLineDash(lineDash);\n ctx.lineDashOffset = lineDashOffset;\n hasLineDash = true;\n }\n }\n if (style.strokeFirst) {\n if (styleHasStroke(style)) {\n ctx.strokeText(text, style.x, style.y);\n }\n if (styleHasFill(style)) {\n ctx.fillText(text, style.x, style.y);\n }\n }\n else {\n if (styleHasFill(style)) {\n ctx.fillText(text, style.x, style.y);\n }\n if (styleHasStroke(style)) {\n ctx.strokeText(text, style.x, style.y);\n }\n }\n if (hasLineDash) {\n ctx.setLineDash([]);\n }\n }\n}\nvar SHADOW_NUMBER_PROPS = ['shadowBlur', 'shadowOffsetX', 'shadowOffsetY'];\nvar STROKE_PROPS = [\n ['lineCap', 'butt'], ['lineJoin', 'miter'], ['miterLimit', 10]\n];\nfunction bindCommonProps(ctx, style, prevStyle, forceSetAll, scope) {\n var styleChanged = false;\n if (!forceSetAll) {\n prevStyle = prevStyle || {};\n if (style === prevStyle) {\n return false;\n }\n }\n if (forceSetAll || style.opacity !== prevStyle.opacity) {\n if (!styleChanged) {\n flushPathDrawn(ctx, scope);\n styleChanged = true;\n }\n ctx.globalAlpha = style.opacity == null ? DEFAULT_COMMON_STYLE.opacity : style.opacity;\n }\n if (forceSetAll || style.blend !== prevStyle.blend) {\n if (!styleChanged) {\n flushPathDrawn(ctx, scope);\n styleChanged = true;\n }\n ctx.globalCompositeOperation = style.blend || DEFAULT_COMMON_STYLE.blend;\n }\n for (var i = 0; i < SHADOW_NUMBER_PROPS.length; i++) {\n var propName = SHADOW_NUMBER_PROPS[i];\n if (forceSetAll || style[propName] !== prevStyle[propName]) {\n if (!styleChanged) {\n flushPathDrawn(ctx, scope);\n styleChanged = true;\n }\n ctx[propName] = ctx.dpr * (style[propName] || 0);\n }\n }\n if (forceSetAll || style.shadowColor !== prevStyle.shadowColor) {\n if (!styleChanged) {\n flushPathDrawn(ctx, scope);\n styleChanged = true;\n }\n ctx.shadowColor = style.shadowColor || DEFAULT_COMMON_STYLE.shadowColor;\n }\n return styleChanged;\n}\nfunction bindPathAndTextCommonStyle(ctx, el, prevEl, forceSetAll, scope) {\n var style = getStyle(el, scope.inHover);\n var prevStyle = forceSetAll\n ? null\n : (prevEl && getStyle(prevEl, scope.inHover) || {});\n if (style === prevStyle) {\n return false;\n }\n var styleChanged = bindCommonProps(ctx, style, prevStyle, forceSetAll, scope);\n if (forceSetAll || style.fill !== prevStyle.fill) {\n if (!styleChanged) {\n flushPathDrawn(ctx, scope);\n styleChanged = true;\n }\n ctx.fillStyle = style.fill;\n }\n if (forceSetAll || style.stroke !== prevStyle.stroke) {\n if (!styleChanged) {\n flushPathDrawn(ctx, scope);\n styleChanged = true;\n }\n ctx.strokeStyle = style.stroke;\n }\n if (forceSetAll || style.opacity !== prevStyle.opacity) {\n if (!styleChanged) {\n flushPathDrawn(ctx, scope);\n styleChanged = true;\n }\n ctx.globalAlpha = style.opacity == null ? 1 : style.opacity;\n }\n if (el.hasStroke()) {\n var lineWidth = style.lineWidth;\n var newLineWidth = lineWidth / ((style.strokeNoScale && el && el.getLineScale) ? el.getLineScale() : 1);\n if (ctx.lineWidth !== newLineWidth) {\n if (!styleChanged) {\n flushPathDrawn(ctx, scope);\n styleChanged = true;\n }\n ctx.lineWidth = newLineWidth;\n }\n }\n for (var i = 0; i < STROKE_PROPS.length; i++) {\n var prop = STROKE_PROPS[i];\n var propName = prop[0];\n if (forceSetAll || style[propName] !== prevStyle[propName]) {\n if (!styleChanged) {\n flushPathDrawn(ctx, scope);\n styleChanged = true;\n }\n ctx[propName] = style[propName] || prop[1];\n }\n }\n return styleChanged;\n}\nfunction bindImageStyle(ctx, el, prevEl, forceSetAll, scope) {\n return bindCommonProps(ctx, getStyle(el, scope.inHover), prevEl && getStyle(prevEl, scope.inHover), forceSetAll, scope);\n}\nfunction setContextTransform(ctx, el) {\n var m = el.transform;\n var dpr = ctx.dpr || 1;\n if (m) {\n ctx.setTransform(dpr * m[0], dpr * m[1], dpr * m[2], dpr * m[3], dpr * m[4], dpr * m[5]);\n }\n else {\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n }\n}\nfunction updateClipStatus(clipPaths, ctx, scope) {\n var allClipped = false;\n for (var i = 0; i < clipPaths.length; i++) {\n var clipPath = clipPaths[i];\n allClipped = allClipped || clipPath.isZeroArea();\n setContextTransform(ctx, clipPath);\n ctx.beginPath();\n clipPath.buildPath(ctx, clipPath.shape);\n ctx.clip();\n }\n scope.allClipped = allClipped;\n}\nfunction isTransformChanged(m0, m1) {\n if (m0 && m1) {\n return m0[0] !== m1[0]\n || m0[1] !== m1[1]\n || m0[2] !== m1[2]\n || m0[3] !== m1[3]\n || m0[4] !== m1[4]\n || m0[5] !== m1[5];\n }\n else if (!m0 && !m1) {\n return false;\n }\n return true;\n}\nvar DRAW_TYPE_PATH = 1;\nvar DRAW_TYPE_IMAGE = 2;\nvar DRAW_TYPE_TEXT = 3;\nvar DRAW_TYPE_INCREMENTAL = 4;\nfunction canPathBatch(style) {\n var hasFill = styleHasFill(style);\n var hasStroke = styleHasStroke(style);\n return !(style.lineDash\n || !(+hasFill ^ +hasStroke)\n || (hasFill && typeof style.fill !== 'string')\n || (hasStroke && typeof style.stroke !== 'string')\n || style.strokePercent < 1\n || style.strokeOpacity < 1\n || style.fillOpacity < 1);\n}\nfunction flushPathDrawn(ctx, scope) {\n scope.batchFill && ctx.fill();\n scope.batchStroke && ctx.stroke();\n scope.batchFill = '';\n scope.batchStroke = '';\n}\nfunction getStyle(el, inHover) {\n return inHover ? (el.__hoverStyle || el.style) : el.style;\n}\nexport function brushSingle(ctx, el) {\n brush(ctx, el, { inHover: false, viewWidth: 0, viewHeight: 0 }, true);\n}\nexport function brush(ctx, el, scope, isLast) {\n var m = el.transform;\n if (!el.shouldBePainted(scope.viewWidth, scope.viewHeight, false, false)) {\n el.__dirty &= ~Element.REDARAW_BIT;\n el.__isRendered = false;\n return;\n }\n var clipPaths = el.__clipPaths;\n var prevElClipPaths = scope.prevElClipPaths;\n var forceSetTransform = false;\n var forceSetStyle = false;\n if (!prevElClipPaths || isClipPathChanged(clipPaths, prevElClipPaths)) {\n if (prevElClipPaths && prevElClipPaths.length) {\n flushPathDrawn(ctx, scope);\n ctx.restore();\n forceSetStyle = forceSetTransform = true;\n scope.prevElClipPaths = null;\n scope.allClipped = false;\n scope.prevEl = null;\n }\n if (clipPaths && clipPaths.length) {\n flushPathDrawn(ctx, scope);\n ctx.save();\n updateClipStatus(clipPaths, ctx, scope);\n forceSetTransform = true;\n }\n scope.prevElClipPaths = clipPaths;\n }\n if (scope.allClipped) {\n el.__isRendered = false;\n return;\n }\n el.beforeBrush && el.beforeBrush();\n el.innerBeforeBrush();\n var prevEl = scope.prevEl;\n if (!prevEl) {\n forceSetStyle = forceSetTransform = true;\n }\n var canBatchPath = el instanceof Path\n && el.autoBatch\n && canPathBatch(el.style);\n if (forceSetTransform || isTransformChanged(m, prevEl.transform)) {\n flushPathDrawn(ctx, scope);\n setContextTransform(ctx, el);\n }\n else if (!canBatchPath) {\n flushPathDrawn(ctx, scope);\n }\n var style = getStyle(el, scope.inHover);\n if (el instanceof Path) {\n if (scope.lastDrawType !== DRAW_TYPE_PATH) {\n forceSetStyle = true;\n scope.lastDrawType = DRAW_TYPE_PATH;\n }\n bindPathAndTextCommonStyle(ctx, el, prevEl, forceSetStyle, scope);\n if (!canBatchPath || (!scope.batchFill && !scope.batchStroke)) {\n ctx.beginPath();\n }\n brushPath(ctx, el, style, canBatchPath);\n if (canBatchPath) {\n scope.batchFill = style.fill || '';\n scope.batchStroke = style.stroke || '';\n }\n }\n else {\n if (el instanceof TSpan) {\n if (scope.lastDrawType !== DRAW_TYPE_TEXT) {\n forceSetStyle = true;\n scope.lastDrawType = DRAW_TYPE_TEXT;\n }\n bindPathAndTextCommonStyle(ctx, el, prevEl, forceSetStyle, scope);\n brushText(ctx, el, style);\n }\n else if (el instanceof ZRImage) {\n if (scope.lastDrawType !== DRAW_TYPE_IMAGE) {\n forceSetStyle = true;\n scope.lastDrawType = DRAW_TYPE_IMAGE;\n }\n bindImageStyle(ctx, el, prevEl, forceSetStyle, scope);\n brushImage(ctx, el, style);\n }\n else if (el instanceof IncrementalDisplayable) {\n if (scope.lastDrawType !== DRAW_TYPE_INCREMENTAL) {\n forceSetStyle = true;\n scope.lastDrawType = DRAW_TYPE_INCREMENTAL;\n }\n brushIncremental(ctx, el, scope);\n }\n }\n if (canBatchPath && isLast) {\n flushPathDrawn(ctx, scope);\n }\n el.innerAfterBrush();\n el.afterBrush && el.afterBrush();\n scope.prevEl = el;\n el.__dirty = 0;\n el.__isRendered = true;\n}\nfunction brushIncremental(ctx, el, scope) {\n var displayables = el.getDisplayables();\n var temporalDisplayables = el.getTemporalDisplayables();\n ctx.save();\n var innerScope = {\n prevElClipPaths: null,\n prevEl: null,\n allClipped: false,\n viewWidth: scope.viewWidth,\n viewHeight: scope.viewHeight,\n inHover: scope.inHover\n };\n var i;\n var len;\n for (i = el.getCursor(), len = displayables.length; i < len; i++) {\n var displayable = displayables[i];\n displayable.beforeBrush && displayable.beforeBrush();\n displayable.innerBeforeBrush();\n brush(ctx, displayable, innerScope, i === len - 1);\n displayable.innerAfterBrush();\n displayable.afterBrush && displayable.afterBrush();\n innerScope.prevEl = displayable;\n }\n for (var i_1 = 0, len_1 = temporalDisplayables.length; i_1 < len_1; i_1++) {\n var displayable = temporalDisplayables[i_1];\n displayable.beforeBrush && displayable.beforeBrush();\n displayable.innerBeforeBrush();\n brush(ctx, displayable, innerScope, i_1 === len_1 - 1);\n displayable.innerAfterBrush();\n displayable.afterBrush && displayable.afterBrush();\n innerScope.prevEl = displayable;\n }\n el.clearTemporalDisplayables();\n el.notClear = true;\n ctx.restore();\n}\n","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport WeakMap from 'zrender/lib/core/WeakMap';\nimport LRU from 'zrender/lib/core/LRU';\nimport { defaults, createCanvas, map, isArray } from 'zrender/lib/core/util';\nimport { getLeastCommonMultiple } from './number';\nimport { createSymbol } from './symbol';\nimport { brushSingle } from 'zrender/lib/canvas/graphic';\nvar decalMap = new WeakMap();\nvar decalCache = new LRU(100);\nvar decalKeys = ['symbol', 'symbolSize', 'symbolKeepAspect', 'color', 'backgroundColor', 'dashArrayX', 'dashArrayY', 'maxTileWidth', 'maxTileHeight'];\n/**\n * Create or update pattern image from decal options\n *\n * @param {InnerDecalObject | 'none'} decalObject decal options, 'none' if no decal\n * @return {Pattern} pattern with generated image, null if no decal\n */\n\nexport function createOrUpdatePatternFromDecal(decalObject, api) {\n if (decalObject === 'none') {\n return null;\n }\n\n var dpr = api.getDevicePixelRatio();\n var zr = api.getZr();\n var isSVG = zr.painter.type === 'svg';\n\n if (decalObject.dirty) {\n decalMap[\"delete\"](decalObject);\n }\n\n var oldPattern = decalMap.get(decalObject);\n\n if (oldPattern) {\n return oldPattern;\n }\n\n var decalOpt = defaults(decalObject, {\n symbol: 'rect',\n symbolSize: 1,\n symbolKeepAspect: true,\n color: 'rgba(0, 0, 0, 0.2)',\n backgroundColor: null,\n dashArrayX: 5,\n dashArrayY: 5,\n rotation: 0,\n maxTileWidth: 512,\n maxTileHeight: 512\n });\n\n if (decalOpt.backgroundColor === 'none') {\n decalOpt.backgroundColor = null;\n }\n\n var pattern = {\n repeat: 'repeat'\n };\n setPatternnSource(pattern);\n pattern.rotation = decalOpt.rotation;\n pattern.scaleX = pattern.scaleY = isSVG ? 1 : 1 / dpr;\n decalMap.set(decalObject, pattern);\n decalObject.dirty = false;\n return pattern;\n\n function setPatternnSource(pattern) {\n var keys = [dpr];\n var isValidKey = true;\n\n for (var i = 0; i < decalKeys.length; ++i) {\n var value = decalOpt[decalKeys[i]];\n var valueType = typeof value;\n\n if (value != null && !isArray(value) && valueType !== 'string' && valueType !== 'number' && valueType !== 'boolean') {\n isValidKey = false;\n break;\n }\n\n keys.push(value);\n }\n\n var cacheKey;\n\n if (isValidKey) {\n cacheKey = keys.join(',') + (isSVG ? '-svg' : '');\n var cache = decalCache.get(cacheKey);\n\n if (cache) {\n isSVG ? pattern.svgElement = cache : pattern.image = cache;\n }\n }\n\n var dashArrayX = normalizeDashArrayX(decalOpt.dashArrayX);\n var dashArrayY = normalizeDashArrayY(decalOpt.dashArrayY);\n var symbolArray = normalizeSymbolArray(decalOpt.symbol);\n var lineBlockLengthsX = getLineBlockLengthX(dashArrayX);\n var lineBlockLengthY = getLineBlockLengthY(dashArrayY);\n var canvas = !isSVG && createCanvas();\n var svgRoot = isSVG && zr.painter.createSVGElement('g');\n var pSize = getPatternSize();\n var ctx;\n\n if (canvas) {\n canvas.width = pSize.width * dpr;\n canvas.height = pSize.height * dpr;\n ctx = canvas.getContext('2d');\n }\n\n brushDecal();\n\n if (isValidKey) {\n decalCache.put(cacheKey, canvas || svgRoot);\n }\n\n pattern.image = canvas;\n pattern.svgElement = svgRoot;\n pattern.svgWidth = pSize.width;\n pattern.svgHeight = pSize.height;\n /**\n * Get minumum length that can make a repeatable pattern.\n *\n * @return {Object} pattern width and height\n */\n\n function getPatternSize() {\n /**\n * For example, if dash is [[3, 2], [2, 1]] for X, it looks like\n * |--- --- --- --- --- ...\n * |-- -- -- -- -- -- -- -- ...\n * |--- --- --- --- --- ...\n * |-- -- -- -- -- -- -- -- ...\n * So the minumum length of X is 15,\n * which is the least common multiple of `3 + 2` and `2 + 1`\n * |--- --- --- |--- --- ...\n * |-- -- -- -- -- |-- -- -- ...\n */\n var width = 1;\n\n for (var i = 0, xlen = lineBlockLengthsX.length; i < xlen; ++i) {\n width = getLeastCommonMultiple(width, lineBlockLengthsX[i]);\n }\n\n var symbolRepeats = 1;\n\n for (var i = 0, xlen = symbolArray.length; i < xlen; ++i) {\n symbolRepeats = getLeastCommonMultiple(symbolRepeats, symbolArray[i].length);\n }\n\n width *= symbolRepeats;\n var height = lineBlockLengthY * lineBlockLengthsX.length * symbolArray.length;\n\n if (process.env.NODE_ENV !== 'production') {\n var warn = function (attrName) {\n /* eslint-disable-next-line */\n console.warn(\"Calculated decal size is greater than \" + attrName + \" due to decal option settings so \" + attrName + \" is used for the decal size. Please consider changing the decal option to make a smaller decal or set \" + attrName + \" to be larger to avoid incontinuity.\");\n };\n\n if (width > decalOpt.maxTileWidth) {\n warn('maxTileWidth');\n }\n\n if (height > decalOpt.maxTileHeight) {\n warn('maxTileHeight');\n }\n }\n\n return {\n width: Math.max(1, Math.min(width, decalOpt.maxTileWidth)),\n height: Math.max(1, Math.min(height, decalOpt.maxTileHeight))\n };\n }\n\n function brushDecal() {\n if (ctx) {\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n\n if (decalOpt.backgroundColor) {\n ctx.fillStyle = decalOpt.backgroundColor;\n ctx.fillRect(0, 0, canvas.width, canvas.height);\n }\n }\n\n var ySum = 0;\n\n for (var i = 0; i < dashArrayY.length; ++i) {\n ySum += dashArrayY[i];\n }\n\n if (ySum <= 0) {\n // dashArrayY is 0, draw nothing\n return;\n }\n\n var y = -lineBlockLengthY;\n var yId = 0;\n var yIdTotal = 0;\n var xId0 = 0;\n\n while (y < pSize.height) {\n if (yId % 2 === 0) {\n var symbolYId = yIdTotal / 2 % symbolArray.length;\n var x = 0;\n var xId1 = 0;\n var xId1Total = 0;\n\n while (x < pSize.width * 2) {\n var xSum = 0;\n\n for (var i = 0; i < dashArrayX[xId0].length; ++i) {\n xSum += dashArrayX[xId0][i];\n }\n\n if (xSum <= 0) {\n // Skip empty line\n break;\n } // E.g., [15, 5, 20, 5] draws only for 15 and 20\n\n\n if (xId1 % 2 === 0) {\n var size = (1 - decalOpt.symbolSize) * 0.5;\n var left = x + dashArrayX[xId0][xId1] * size;\n var top_1 = y + dashArrayY[yId] * size;\n var width = dashArrayX[xId0][xId1] * decalOpt.symbolSize;\n var height = dashArrayY[yId] * decalOpt.symbolSize;\n var symbolXId = xId1Total / 2 % symbolArray[symbolYId].length;\n brushSymbol(left, top_1, width, height, symbolArray[symbolYId][symbolXId]);\n }\n\n x += dashArrayX[xId0][xId1];\n ++xId1Total;\n ++xId1;\n\n if (xId1 === dashArrayX[xId0].length) {\n xId1 = 0;\n }\n }\n\n ++xId0;\n\n if (xId0 === dashArrayX.length) {\n xId0 = 0;\n }\n }\n\n y += dashArrayY[yId];\n ++yIdTotal;\n ++yId;\n\n if (yId === dashArrayY.length) {\n yId = 0;\n }\n }\n\n function brushSymbol(x, y, width, height, symbolType) {\n var scale = isSVG ? 1 : dpr;\n var symbol = createSymbol(symbolType, x * scale, y * scale, width * scale, height * scale, decalOpt.color, decalOpt.symbolKeepAspect);\n\n if (isSVG) {\n svgRoot.appendChild(zr.painter.paintOne(symbol));\n } else {\n // Paint to canvas for all other renderers.\n brushSingle(ctx, symbol);\n }\n }\n }\n }\n}\n/**\n * Convert symbol array into normalized array\n *\n * @param {string | (string | string[])[]} symbol symbol input\n * @return {string[][]} normolized symbol array\n */\n\nfunction normalizeSymbolArray(symbol) {\n if (!symbol || symbol.length === 0) {\n return [['rect']];\n }\n\n if (typeof symbol === 'string') {\n return [[symbol]];\n }\n\n var isAllString = true;\n\n for (var i = 0; i < symbol.length; ++i) {\n if (typeof symbol[i] !== 'string') {\n isAllString = false;\n break;\n }\n }\n\n if (isAllString) {\n return normalizeSymbolArray([symbol]);\n }\n\n var result = [];\n\n for (var i = 0; i < symbol.length; ++i) {\n if (typeof symbol[i] === 'string') {\n result.push([symbol[i]]);\n } else {\n result.push(symbol[i]);\n }\n }\n\n return result;\n}\n/**\n * Convert dash input into dashArray\n *\n * @param {DecalDashArrayX} dash dash input\n * @return {number[][]} normolized dash array\n */\n\n\nfunction normalizeDashArrayX(dash) {\n if (!dash || dash.length === 0) {\n return [[0, 0]];\n }\n\n if (typeof dash === 'number') {\n var dashValue = Math.ceil(dash);\n return [[dashValue, dashValue]];\n }\n /**\n * [20, 5] should be normalized into [[20, 5]],\n * while [20, [5, 10]] should be normalized into [[20, 20], [5, 10]]\n */\n\n\n var isAllNumber = true;\n\n for (var i = 0; i < dash.length; ++i) {\n if (typeof dash[i] !== 'number') {\n isAllNumber = false;\n break;\n }\n }\n\n if (isAllNumber) {\n return normalizeDashArrayX([dash]);\n }\n\n var result = [];\n\n for (var i = 0; i < dash.length; ++i) {\n if (typeof dash[i] === 'number') {\n var dashValue = Math.ceil(dash[i]);\n result.push([dashValue, dashValue]);\n } else {\n var dashValue = map(dash[i], function (n) {\n return Math.ceil(n);\n });\n\n if (dashValue.length % 2 === 1) {\n // [4, 2, 1] means |---- - -- |---- - -- |\n // so normalize it to be [4, 2, 1, 4, 2, 1]\n result.push(dashValue.concat(dashValue));\n } else {\n result.push(dashValue);\n }\n }\n }\n\n return result;\n}\n/**\n * Convert dash input into dashArray\n *\n * @param {DecalDashArrayY} dash dash input\n * @return {number[]} normolized dash array\n */\n\n\nfunction normalizeDashArrayY(dash) {\n if (!dash || typeof dash === 'object' && dash.length === 0) {\n return [0, 0];\n }\n\n if (typeof dash === 'number') {\n var dashValue_1 = Math.ceil(dash);\n return [dashValue_1, dashValue_1];\n }\n\n var dashValue = map(dash, function (n) {\n return Math.ceil(n);\n });\n return dash.length % 2 ? dashValue.concat(dashValue) : dashValue;\n}\n/**\n * Get block length of each line. A block is the length of dash line and space.\n * For example, a line with [4, 1] has a dash line of 4 and a space of 1 after\n * that, so the block length of this line is 5.\n *\n * @param {number[][]} dash dash arrary of X or Y\n * @return {number[]} block length of each line\n */\n\n\nfunction getLineBlockLengthX(dash) {\n return map(dash, function (line) {\n return getLineBlockLengthY(line);\n });\n}\n\nfunction getLineBlockLengthY(dash) {\n var blockLength = 0;\n\n for (var i = 0; i < dash.length; ++i) {\n blockLength += dash[i];\n }\n\n if (dash.length % 2 === 1) {\n // [4, 2, 1] means |---- - -- |---- - -- |\n // So total length is (4 + 2 + 1) * 2\n return blockLength * 2;\n }\n\n return blockLength;\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { createOrUpdatePatternFromDecal } from '../util/decal';\nexport default function decalVisual(ecModel, api) {\n ecModel.eachRawSeries(function (seriesModel) {\n if (ecModel.isSeriesFiltered(seriesModel)) {\n return;\n }\n\n var data = seriesModel.getData();\n\n if (data.hasItemVisual()) {\n data.each(function (idx) {\n var decal = data.getItemVisual(idx, 'decal');\n\n if (decal) {\n var itemStyle = data.ensureUniqueItemVisual(idx, 'style');\n itemStyle.decal = createOrUpdatePatternFromDecal(decal, api);\n }\n });\n }\n\n var decal = data.getVisual('decal');\n\n if (decal) {\n var style = data.getVisual('style');\n style.decal = createOrUpdatePatternFromDecal(decal, api);\n }\n });\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\nimport { __extends } from \"tslib\";\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\nimport * as zrender from 'zrender/lib/zrender';\nimport * as zrUtil from 'zrender/lib/core/util';\nimport * as colorTool from 'zrender/lib/tool/color';\nimport env from 'zrender/lib/core/env';\nimport timsort from 'zrender/lib/core/timsort';\nimport Eventful from 'zrender/lib/core/Eventful';\nimport GlobalModel from '../model/Global';\nimport ExtensionAPI from './ExtensionAPI';\nimport CoordinateSystemManager from './CoordinateSystem';\nimport OptionManager from '../model/OptionManager';\nimport backwardCompat from '../preprocessor/backwardCompat';\nimport dataStack from '../processor/dataStack';\nimport SeriesModel from '../model/Series';\nimport ComponentView from '../view/Component';\nimport ChartView from '../view/Chart';\nimport * as graphic from '../util/graphic';\nimport { getECData } from '../util/innerStore';\nimport { enterEmphasisWhenMouseOver, leaveEmphasisWhenMouseOut, isHighDownDispatcher, HOVER_STATE_EMPHASIS, HOVER_STATE_BLUR, toggleSeriesBlurState, toggleSeriesBlurStateFromPayload, toggleSelectionFromPayload, updateSeriesElementSelection, getAllSelectedIndices, isSelectChangePayload, isHighDownPayload, HIGHLIGHT_ACTION_TYPE, DOWNPLAY_ACTION_TYPE, SELECT_ACTION_TYPE, UNSELECT_ACTION_TYPE, TOGGLE_SELECT_ACTION_TYPE, savePathStates, enterEmphasis, leaveEmphasis, leaveBlur, enterSelect, leaveSelect, enterBlur } from '../util/states';\nimport * as modelUtil from '../util/model';\nimport { throttle } from '../util/throttle';\nimport { seriesStyleTask, dataStyleTask, dataColorPaletteTask } from '../visual/style';\nimport loadingDefault from '../loading/default';\nimport Scheduler from './Scheduler';\nimport lightTheme from '../theme/light';\nimport darkTheme from '../theme/dark';\nimport mapDataStorage from '../coord/geo/mapDataStorage';\nimport { parseClassType } from '../util/clazz';\nimport { ECEventProcessor } from '../util/ECEventProcessor';\nimport { seriesSymbolTask, dataSymbolTask } from '../visual/symbol';\nimport { getVisualFromData, getItemVisualFromData } from '../visual/helper';\nimport LabelManager from '../label/LabelManager';\nimport { deprecateLog, throwError } from '../util/log';\nimport { handleLegacySelectEvents } from '../legacy/dataSelectAction';\nimport { registerExternalTransform } from '../data/helper/transform';\nimport { createLocaleObject, SYSTEM_LANG } from './locale';\nimport { findEventDispatcher } from '../util/event';\nimport decal from '../visual/decal';\nvar assert = zrUtil.assert;\nvar each = zrUtil.each;\nvar isFunction = zrUtil.isFunction;\nvar isObject = zrUtil.isObject;\nvar indexOf = zrUtil.indexOf;\nvar hasWindow = typeof window !== 'undefined';\nexport var version = '5.0.2';\nexport var dependencies = {\n zrender: '5.0.4'\n};\nvar TEST_FRAME_REMAIN_TIME = 1;\nvar PRIORITY_PROCESSOR_SERIES_FILTER = 800; // Some data processors depends on the stack result dimension (to calculate data extent).\n// So data stack stage should be in front of data processing stage.\n\nvar PRIORITY_PROCESSOR_DATASTACK = 900; // \"Data filter\" will block the stream, so it should be\n// put at the begining of data processing.\n\nvar PRIORITY_PROCESSOR_FILTER = 1000;\nvar PRIORITY_PROCESSOR_DEFAULT = 2000;\nvar PRIORITY_PROCESSOR_STATISTIC = 5000;\nvar PRIORITY_VISUAL_LAYOUT = 1000;\nvar PRIORITY_VISUAL_PROGRESSIVE_LAYOUT = 1100;\nvar PRIORITY_VISUAL_GLOBAL = 2000;\nvar PRIORITY_VISUAL_CHART = 3000;\nvar PRIORITY_VISUAL_COMPONENT = 4000; // Visual property in data. Greater than `PRIORITY_VISUAL_COMPONENT` to enable to\n// overwrite the viusal result of component (like `visualMap`)\n// using data item specific setting (like itemStyle.xxx on data item)\n\nvar PRIORITY_VISUAL_CHART_DATA_CUSTOM = 4500; // Greater than `PRIORITY_VISUAL_CHART_DATA_CUSTOM` to enable to layout based on\n// visual result like `symbolSize`.\n\nvar PRIORITY_VISUAL_POST_CHART_LAYOUT = 4600;\nvar PRIORITY_VISUAL_BRUSH = 5000;\nvar PRIORITY_VISUAL_ARIA = 6000;\nvar PRIORITY_VISUAL_DECAL = 7000;\nexport var PRIORITY = {\n PROCESSOR: {\n FILTER: PRIORITY_PROCESSOR_FILTER,\n SERIES_FILTER: PRIORITY_PROCESSOR_SERIES_FILTER,\n STATISTIC: PRIORITY_PROCESSOR_STATISTIC\n },\n VISUAL: {\n LAYOUT: PRIORITY_VISUAL_LAYOUT,\n PROGRESSIVE_LAYOUT: PRIORITY_VISUAL_PROGRESSIVE_LAYOUT,\n GLOBAL: PRIORITY_VISUAL_GLOBAL,\n CHART: PRIORITY_VISUAL_CHART,\n POST_CHART_LAYOUT: PRIORITY_VISUAL_POST_CHART_LAYOUT,\n COMPONENT: PRIORITY_VISUAL_COMPONENT,\n BRUSH: PRIORITY_VISUAL_BRUSH,\n CHART_ITEM: PRIORITY_VISUAL_CHART_DATA_CUSTOM,\n ARIA: PRIORITY_VISUAL_ARIA,\n DECAL: PRIORITY_VISUAL_DECAL\n }\n}; // Main process have three entries: `setOption`, `dispatchAction` and `resize`,\n// where they must not be invoked nestedly, except the only case: invoke\n// dispatchAction with updateMethod \"none\" in main process.\n// This flag is used to carry out this rule.\n// All events will be triggered out side main process (i.e. when !this[IN_MAIN_PROCESS]).\n\nvar IN_MAIN_PROCESS_KEY = '__flagInMainProcess';\nvar OPTION_UPDATED_KEY = '__optionUpdated';\nvar STATUS_NEEDS_UPDATE_KEY = '__needsUpdateStatus';\nvar ACTION_REG = /^[a-zA-Z0-9_]+$/;\nvar CONNECT_STATUS_KEY = '__connectUpdateStatus';\nvar CONNECT_STATUS_PENDING = 0;\nvar CONNECT_STATUS_UPDATING = 1;\nvar CONNECT_STATUS_UPDATED = 2;\n;\n\nfunction createRegisterEventWithLowercaseECharts(method) {\n return function () {\n var args = [];\n\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n\n if (this.isDisposed()) {\n disposedWarning(this.id);\n return;\n }\n\n return toLowercaseNameAndCallEventful(this, method, args);\n };\n}\n\nfunction createRegisterEventWithLowercaseMessageCenter(method) {\n return function () {\n var args = [];\n\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n\n return toLowercaseNameAndCallEventful(this, method, args);\n };\n}\n\nfunction toLowercaseNameAndCallEventful(host, method, args) {\n // `args[0]` is event name. Event name is all lowercase.\n args[0] = args[0] && args[0].toLowerCase();\n return Eventful.prototype[method].apply(host, args);\n}\n\nvar MessageCenter =\n/** @class */\nfunction (_super) {\n __extends(MessageCenter, _super);\n\n function MessageCenter() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n\n return MessageCenter;\n}(Eventful);\n\nvar messageCenterProto = MessageCenter.prototype;\nmessageCenterProto.on = createRegisterEventWithLowercaseMessageCenter('on');\nmessageCenterProto.off = createRegisterEventWithLowercaseMessageCenter('off'); // ---------------------------------------\n// Internal method names for class ECharts\n// ---------------------------------------\n\nvar prepare;\nvar prepareView;\nvar updateDirectly;\nvar updateMethods;\nvar doConvertPixel;\nvar updateStreamModes;\nvar doDispatchAction;\nvar flushPendingActions;\nvar triggerUpdatedEvent;\nvar bindRenderedEvent;\nvar bindMouseEvent;\nvar clearColorPalette;\nvar render;\nvar renderComponents;\nvar renderSeries;\nvar performPostUpdateFuncs;\nvar createExtensionAPI;\nvar enableConnect;\nvar setTransitionOpt;\nvar markStatusToUpdate;\nvar applyChangedStates;\n\nvar ECharts =\n/** @class */\nfunction (_super) {\n __extends(ECharts, _super);\n\n function ECharts(dom, // Theme name or themeOption.\n theme, opts) {\n var _this = _super.call(this, new ECEventProcessor()) || this;\n\n _this._chartsViews = [];\n _this._chartsMap = {};\n _this._componentsViews = [];\n _this._componentsMap = {}; // Can't dispatch action during rendering procedure\n\n _this._pendingActions = [];\n opts = opts || {}; // Get theme by name\n\n if (typeof theme === 'string') {\n theme = themeStorage[theme];\n }\n\n _this._dom = dom;\n var defaultRenderer = 'canvas';\n var defaultUseDirtyRect = false;\n\n if (process.env.NODE_ENV !== 'production') {\n var root =\n /* eslint-disable-next-line */\n hasWindow ? window : global;\n defaultRenderer = root.__ECHARTS__DEFAULT__RENDERER__ || defaultRenderer;\n var devUseDirtyRect = root.__ECHARTS__DEFAULT__USE_DIRTY_RECT__;\n defaultUseDirtyRect = devUseDirtyRect == null ? defaultUseDirtyRect : devUseDirtyRect;\n }\n\n var zr = _this._zr = zrender.init(dom, {\n renderer: opts.renderer || defaultRenderer,\n devicePixelRatio: opts.devicePixelRatio,\n width: opts.width,\n height: opts.height,\n useDirtyRect: opts.useDirtyRect == null ? defaultUseDirtyRect : opts.useDirtyRect\n }); // Expect 60 fps.\n\n _this._throttledZrFlush = throttle(zrUtil.bind(zr.flush, zr), 17);\n theme = zrUtil.clone(theme);\n theme && backwardCompat(theme, true);\n _this._theme = theme;\n _this._locale = createLocaleObject(opts.locale || SYSTEM_LANG);\n _this._coordSysMgr = new CoordinateSystemManager();\n var api = _this._api = createExtensionAPI(_this); // Sort on demand\n\n function prioritySortFunc(a, b) {\n return a.__prio - b.__prio;\n }\n\n timsort(visualFuncs, prioritySortFunc);\n timsort(dataProcessorFuncs, prioritySortFunc);\n _this._scheduler = new Scheduler(_this, api, dataProcessorFuncs, visualFuncs);\n _this._messageCenter = new MessageCenter();\n _this._labelManager = new LabelManager(); // Init mouse events\n\n _this._initEvents(); // In case some people write `window.onresize = chart.resize`\n\n\n _this.resize = zrUtil.bind(_this.resize, _this);\n zr.animation.on('frame', _this._onframe, _this);\n bindRenderedEvent(zr, _this);\n bindMouseEvent(zr, _this); // ECharts instance can be used as value.\n\n zrUtil.setAsPrimitive(_this);\n return _this;\n }\n\n ECharts.prototype._onframe = function () {\n if (this._disposed) {\n return;\n }\n\n applyChangedStates(this);\n var scheduler = this._scheduler; // Lazy update\n\n if (this[OPTION_UPDATED_KEY]) {\n var silent = this[OPTION_UPDATED_KEY].silent;\n this[IN_MAIN_PROCESS_KEY] = true;\n prepare(this);\n updateMethods.update.call(this); // At present, in each frame, zrender performs:\n // (1) animation step forward.\n // (2) trigger('frame') (where this `_onframe` is called)\n // (3) zrender flush (render).\n // If we do nothing here, since we use `setToFinal: true`, the step (3) above\n // will render the final state of the elements before the real animation started.\n\n this._zr.flush();\n\n this[IN_MAIN_PROCESS_KEY] = false;\n this[OPTION_UPDATED_KEY] = false;\n flushPendingActions.call(this, silent);\n triggerUpdatedEvent.call(this, silent);\n } // Avoid do both lazy update and progress in one frame.\n else if (scheduler.unfinished) {\n // Stream progress.\n var remainTime = TEST_FRAME_REMAIN_TIME;\n var ecModel = this._model;\n var api = this._api;\n scheduler.unfinished = false;\n\n do {\n var startTime = +new Date();\n scheduler.performSeriesTasks(ecModel); // Currently dataProcessorFuncs do not check threshold.\n\n scheduler.performDataProcessorTasks(ecModel);\n updateStreamModes(this, ecModel); // Do not update coordinate system here. Because that coord system update in\n // each frame is not a good user experience. So we follow the rule that\n // the extent of the coordinate system is determin in the first frame (the\n // frame is executed immedietely after task reset.\n // this._coordSysMgr.update(ecModel, api);\n // console.log('--- ec frame visual ---', remainTime);\n\n scheduler.performVisualTasks(ecModel);\n renderSeries(this, this._model, api, 'remain');\n remainTime -= +new Date() - startTime;\n } while (remainTime > 0 && scheduler.unfinished); // Call flush explicitly for trigger finished event.\n\n\n if (!scheduler.unfinished) {\n this._zr.flush();\n } // Else, zr flushing be ensue within the same frame,\n // because zr flushing is after onframe event.\n\n }\n };\n\n ECharts.prototype.getDom = function () {\n return this._dom;\n };\n\n ECharts.prototype.getId = function () {\n return this.id;\n };\n\n ECharts.prototype.getZr = function () {\n return this._zr;\n };\n /* eslint-disable-next-line */\n\n\n ECharts.prototype.setOption = function (option, notMerge, lazyUpdate) {\n if (process.env.NODE_ENV !== 'production') {\n assert(!this[IN_MAIN_PROCESS_KEY], '`setOption` should not be called during main process.');\n }\n\n if (this._disposed) {\n disposedWarning(this.id);\n return;\n }\n\n var silent;\n var replaceMerge;\n var transitionOpt;\n\n if (isObject(notMerge)) {\n lazyUpdate = notMerge.lazyUpdate;\n silent = notMerge.silent;\n replaceMerge = notMerge.replaceMerge;\n transitionOpt = notMerge.transition;\n notMerge = notMerge.notMerge;\n }\n\n this[IN_MAIN_PROCESS_KEY] = true;\n\n if (!this._model || notMerge) {\n var optionManager = new OptionManager(this._api);\n var theme = this._theme;\n var ecModel = this._model = new GlobalModel();\n ecModel.scheduler = this._scheduler;\n ecModel.init(null, null, null, theme, this._locale, optionManager);\n }\n\n this._model.setOption(option, {\n replaceMerge: replaceMerge\n }, optionPreprocessorFuncs);\n\n setTransitionOpt(this, transitionOpt);\n\n if (lazyUpdate) {\n this[OPTION_UPDATED_KEY] = {\n silent: silent\n };\n this[IN_MAIN_PROCESS_KEY] = false; // `setOption(option, {lazyMode: true})` may be called when zrender has been slept.\n // It should wake it up to make sure zrender start to render at the next frame.\n\n this.getZr().wakeUp();\n } else {\n prepare(this);\n updateMethods.update.call(this); // Ensure zr refresh sychronously, and then pixel in canvas can be\n // fetched after `setOption`.\n\n this._zr.flush();\n\n this[OPTION_UPDATED_KEY] = false;\n this[IN_MAIN_PROCESS_KEY] = false;\n flushPendingActions.call(this, silent);\n triggerUpdatedEvent.call(this, silent);\n }\n };\n /**\n * @DEPRECATED\n */\n\n\n ECharts.prototype.setTheme = function () {\n console.error('ECharts#setTheme() is DEPRECATED in ECharts 3.0');\n }; // We don't want developers to use getModel directly.\n\n\n ECharts.prototype.getModel = function () {\n return this._model;\n };\n\n ECharts.prototype.getOption = function () {\n return this._model && this._model.getOption();\n };\n\n ECharts.prototype.getWidth = function () {\n return this._zr.getWidth();\n };\n\n ECharts.prototype.getHeight = function () {\n return this._zr.getHeight();\n };\n\n ECharts.prototype.getDevicePixelRatio = function () {\n return this._zr.painter.dpr\n /* eslint-disable-next-line */\n || hasWindow && window.devicePixelRatio || 1;\n };\n /**\n * Get canvas which has all thing rendered\n */\n\n\n ECharts.prototype.getRenderedCanvas = function (opts) {\n if (!env.canvasSupported) {\n return;\n }\n\n opts = zrUtil.extend({}, opts || {});\n opts.pixelRatio = opts.pixelRatio || this.getDevicePixelRatio();\n opts.backgroundColor = opts.backgroundColor || this._model.get('backgroundColor');\n var zr = this._zr; // let list = zr.storage.getDisplayList();\n // Stop animations\n // Never works before in init animation, so remove it.\n // zrUtil.each(list, function (el) {\n // el.stopAnimation(true);\n // });\n\n return zr.painter.getRenderedCanvas(opts);\n };\n /**\n * Get svg data url\n */\n\n\n ECharts.prototype.getSvgDataURL = function () {\n if (!env.svgSupported) {\n return;\n }\n\n var zr = this._zr;\n var list = zr.storage.getDisplayList(); // Stop animations\n\n zrUtil.each(list, function (el) {\n el.stopAnimation(null, true);\n });\n return zr.painter.toDataURL();\n };\n\n ECharts.prototype.getDataURL = function (opts) {\n if (this._disposed) {\n disposedWarning(this.id);\n return;\n }\n\n opts = opts || {};\n var excludeComponents = opts.excludeComponents;\n var ecModel = this._model;\n var excludesComponentViews = [];\n var self = this;\n each(excludeComponents, function (componentType) {\n ecModel.eachComponent({\n mainType: componentType\n }, function (component) {\n var view = self._componentsMap[component.__viewId];\n\n if (!view.group.ignore) {\n excludesComponentViews.push(view);\n view.group.ignore = true;\n }\n });\n });\n var url = this._zr.painter.getType() === 'svg' ? this.getSvgDataURL() : this.getRenderedCanvas(opts).toDataURL('image/' + (opts && opts.type || 'png'));\n each(excludesComponentViews, function (view) {\n view.group.ignore = false;\n });\n return url;\n };\n\n ECharts.prototype.getConnectedDataURL = function (opts) {\n if (this._disposed) {\n disposedWarning(this.id);\n return;\n }\n\n if (!env.canvasSupported) {\n return;\n }\n\n var isSvg = opts.type === 'svg';\n var groupId = this.group;\n var mathMin = Math.min;\n var mathMax = Math.max;\n var MAX_NUMBER = Infinity;\n\n if (connectedGroups[groupId]) {\n var left_1 = MAX_NUMBER;\n var top_1 = MAX_NUMBER;\n var right_1 = -MAX_NUMBER;\n var bottom_1 = -MAX_NUMBER;\n var canvasList_1 = [];\n var dpr_1 = opts && opts.pixelRatio || this.getDevicePixelRatio();\n zrUtil.each(instances, function (chart, id) {\n if (chart.group === groupId) {\n var canvas = isSvg ? chart.getZr().painter.getSvgDom().innerHTML : chart.getRenderedCanvas(zrUtil.clone(opts));\n var boundingRect = chart.getDom().getBoundingClientRect();\n left_1 = mathMin(boundingRect.left, left_1);\n top_1 = mathMin(boundingRect.top, top_1);\n right_1 = mathMax(boundingRect.right, right_1);\n bottom_1 = mathMax(boundingRect.bottom, bottom_1);\n canvasList_1.push({\n dom: canvas,\n left: boundingRect.left,\n top: boundingRect.top\n });\n }\n });\n left_1 *= dpr_1;\n top_1 *= dpr_1;\n right_1 *= dpr_1;\n bottom_1 *= dpr_1;\n var width = right_1 - left_1;\n var height = bottom_1 - top_1;\n var targetCanvas = zrUtil.createCanvas();\n var zr_1 = zrender.init(targetCanvas, {\n renderer: isSvg ? 'svg' : 'canvas'\n });\n zr_1.resize({\n width: width,\n height: height\n });\n\n if (isSvg) {\n var content_1 = '';\n each(canvasList_1, function (item) {\n var x = item.left - left_1;\n var y = item.top - top_1;\n content_1 += '' + item.dom + '';\n });\n zr_1.painter.getSvgRoot().innerHTML = content_1;\n\n if (opts.connectedBackgroundColor) {\n zr_1.painter.setBackgroundColor(opts.connectedBackgroundColor);\n }\n\n zr_1.refreshImmediately();\n return zr_1.painter.toDataURL();\n } else {\n // Background between the charts\n if (opts.connectedBackgroundColor) {\n zr_1.add(new graphic.Rect({\n shape: {\n x: 0,\n y: 0,\n width: width,\n height: height\n },\n style: {\n fill: opts.connectedBackgroundColor\n }\n }));\n }\n\n each(canvasList_1, function (item) {\n var img = new graphic.Image({\n style: {\n x: item.left * dpr_1 - left_1,\n y: item.top * dpr_1 - top_1,\n image: item.dom\n }\n });\n zr_1.add(img);\n });\n zr_1.refreshImmediately();\n return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png'));\n }\n } else {\n return this.getDataURL(opts);\n }\n };\n\n ECharts.prototype.convertToPixel = function (finder, value) {\n return doConvertPixel(this, 'convertToPixel', finder, value);\n };\n\n ECharts.prototype.convertFromPixel = function (finder, value) {\n return doConvertPixel(this, 'convertFromPixel', finder, value);\n };\n /**\n * Is the specified coordinate systems or components contain the given pixel point.\n * @param {Array|number} value\n * @return {boolean} result\n */\n\n\n ECharts.prototype.containPixel = function (finder, value) {\n if (this._disposed) {\n disposedWarning(this.id);\n return;\n }\n\n var ecModel = this._model;\n var result;\n var findResult = modelUtil.parseFinder(ecModel, finder);\n zrUtil.each(findResult, function (models, key) {\n key.indexOf('Models') >= 0 && zrUtil.each(models, function (model) {\n var coordSys = model.coordinateSystem;\n\n if (coordSys && coordSys.containPoint) {\n result = result || !!coordSys.containPoint(value);\n } else if (key === 'seriesModels') {\n var view = this._chartsMap[model.__viewId];\n\n if (view && view.containPoint) {\n result = result || view.containPoint(value, model);\n } else {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(key + ': ' + (view ? 'The found component do not support containPoint.' : 'No view mapping to the found component.'));\n }\n }\n } else {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(key + ': containPoint is not supported');\n }\n }\n }, this);\n }, this);\n return !!result;\n };\n /**\n * Get visual from series or data.\n * @param finder\n * If string, e.g., 'series', means {seriesIndex: 0}.\n * If Object, could contain some of these properties below:\n * {\n * seriesIndex / seriesId / seriesName,\n * dataIndex / dataIndexInside\n * }\n * If dataIndex is not specified, series visual will be fetched,\n * but not data item visual.\n * If all of seriesIndex, seriesId, seriesName are not specified,\n * visual will be fetched from first series.\n * @param visualType 'color', 'symbol', 'symbolSize'\n */\n\n\n ECharts.prototype.getVisual = function (finder, visualType) {\n var ecModel = this._model;\n var parsedFinder = modelUtil.parseFinder(ecModel, finder, {\n defaultMainType: 'series'\n });\n var seriesModel = parsedFinder.seriesModel;\n\n if (process.env.NODE_ENV !== 'production') {\n if (!seriesModel) {\n console.warn('There is no specified seires model');\n }\n }\n\n var data = seriesModel.getData();\n var dataIndexInside = parsedFinder.hasOwnProperty('dataIndexInside') ? parsedFinder.dataIndexInside : parsedFinder.hasOwnProperty('dataIndex') ? data.indexOfRawIndex(parsedFinder.dataIndex) : null;\n return dataIndexInside != null ? getItemVisualFromData(data, dataIndexInside, visualType) : getVisualFromData(data, visualType);\n };\n /**\n * Get view of corresponding component model\n */\n\n\n ECharts.prototype.getViewOfComponentModel = function (componentModel) {\n return this._componentsMap[componentModel.__viewId];\n };\n /**\n * Get view of corresponding series model\n */\n\n\n ECharts.prototype.getViewOfSeriesModel = function (seriesModel) {\n return this._chartsMap[seriesModel.__viewId];\n };\n\n ECharts.prototype._initEvents = function () {\n var _this = this;\n\n each(MOUSE_EVENT_NAMES, function (eveName) {\n var handler = function (e) {\n var ecModel = _this.getModel();\n\n var el = e.target;\n var params;\n var isGlobalOut = eveName === 'globalout'; // no e.target when 'globalout'.\n\n if (isGlobalOut) {\n params = {};\n } else {\n el && findEventDispatcher(el, function (parent) {\n var ecData = getECData(parent);\n\n if (ecData && ecData.dataIndex != null) {\n var dataModel = ecData.dataModel || ecModel.getSeriesByIndex(ecData.seriesIndex);\n params = dataModel && dataModel.getDataParams(ecData.dataIndex, ecData.dataType) || {};\n return true;\n } // If element has custom eventData of components\n else if (ecData.eventData) {\n params = zrUtil.extend({}, ecData.eventData);\n return true;\n }\n }, true);\n } // Contract: if params prepared in mouse event,\n // these properties must be specified:\n // {\n // componentType: string (component main type)\n // componentIndex: number\n // }\n // Otherwise event query can not work.\n\n\n if (params) {\n var componentType = params.componentType;\n var componentIndex = params.componentIndex; // Special handling for historic reason: when trigger by\n // markLine/markPoint/markArea, the componentType is\n // 'markLine'/'markPoint'/'markArea', but we should better\n // enable them to be queried by seriesIndex, since their\n // option is set in each series.\n\n if (componentType === 'markLine' || componentType === 'markPoint' || componentType === 'markArea') {\n componentType = 'series';\n componentIndex = params.seriesIndex;\n }\n\n var model = componentType && componentIndex != null && ecModel.getComponent(componentType, componentIndex);\n var view = model && _this[model.mainType === 'series' ? '_chartsMap' : '_componentsMap'][model.__viewId];\n\n if (process.env.NODE_ENV !== 'production') {\n // `event.componentType` and `event[componentTpype + 'Index']` must not\n // be missed, otherwise there is no way to distinguish source component.\n // See `dataFormat.getDataParams`.\n if (!isGlobalOut && !(model && view)) {\n console.warn('model or view can not be found by params');\n }\n }\n\n params.event = e;\n params.type = eveName;\n _this._$eventProcessor.eventInfo = {\n targetEl: el,\n packedEvent: params,\n model: model,\n view: view\n };\n\n _this.trigger(eveName, params);\n }\n }; // Consider that some component (like tooltip, brush, ...)\n // register zr event handler, but user event handler might\n // do anything, such as call `setOption` or `dispatchAction`,\n // which probably update any of the content and probably\n // cause problem if it is called previous other inner handlers.\n\n\n handler.zrEventfulCallAtLast = true;\n\n _this._zr.on(eveName, handler, _this);\n });\n each(eventActionMap, function (actionType, eventType) {\n _this._messageCenter.on(eventType, function (event) {\n this.trigger(eventType, event);\n }, _this);\n }); // Extra events\n // TODO register?\n\n each(['selectchanged'], function (eventType) {\n _this._messageCenter.on(eventType, function (event) {\n this.trigger(eventType, event);\n }, _this);\n });\n handleLegacySelectEvents(this._messageCenter, this, this._api);\n };\n\n ECharts.prototype.isDisposed = function () {\n return this._disposed;\n };\n\n ECharts.prototype.clear = function () {\n if (this._disposed) {\n disposedWarning(this.id);\n return;\n }\n\n this.setOption({\n series: []\n }, true);\n };\n\n ECharts.prototype.dispose = function () {\n if (this._disposed) {\n disposedWarning(this.id);\n return;\n }\n\n this._disposed = true;\n modelUtil.setAttribute(this.getDom(), DOM_ATTRIBUTE_KEY, '');\n var api = this._api;\n var ecModel = this._model;\n each(this._componentsViews, function (component) {\n component.dispose(ecModel, api);\n });\n each(this._chartsViews, function (chart) {\n chart.dispose(ecModel, api);\n }); // Dispose after all views disposed\n\n this._zr.dispose();\n\n delete instances[this.id];\n };\n /**\n * Resize the chart\n */\n\n\n ECharts.prototype.resize = function (opts) {\n if (process.env.NODE_ENV !== 'production') {\n assert(!this[IN_MAIN_PROCESS_KEY], '`resize` should not be called during main process.');\n }\n\n if (this._disposed) {\n disposedWarning(this.id);\n return;\n }\n\n this._zr.resize(opts);\n\n var ecModel = this._model; // Resize loading effect\n\n this._loadingFX && this._loadingFX.resize();\n\n if (!ecModel) {\n return;\n }\n\n var optionChanged = ecModel.resetOption('media');\n var silent = opts && opts.silent;\n this[IN_MAIN_PROCESS_KEY] = true;\n optionChanged && prepare(this);\n updateMethods.update.call(this, {\n type: 'resize',\n animation: {\n // Disable animation\n duration: 0\n }\n });\n this[IN_MAIN_PROCESS_KEY] = false;\n flushPendingActions.call(this, silent);\n triggerUpdatedEvent.call(this, silent);\n };\n\n ECharts.prototype.showLoading = function (name, cfg) {\n if (this._disposed) {\n disposedWarning(this.id);\n return;\n }\n\n if (isObject(name)) {\n cfg = name;\n name = '';\n }\n\n name = name || 'default';\n this.hideLoading();\n\n if (!loadingEffects[name]) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn('Loading effects ' + name + ' not exists.');\n }\n\n return;\n }\n\n var el = loadingEffects[name](this._api, cfg);\n var zr = this._zr;\n this._loadingFX = el;\n zr.add(el);\n };\n /**\n * Hide loading effect\n */\n\n\n ECharts.prototype.hideLoading = function () {\n if (this._disposed) {\n disposedWarning(this.id);\n return;\n }\n\n this._loadingFX && this._zr.remove(this._loadingFX);\n this._loadingFX = null;\n };\n\n ECharts.prototype.makeActionFromEvent = function (eventObj) {\n var payload = zrUtil.extend({}, eventObj);\n payload.type = eventActionMap[eventObj.type];\n return payload;\n };\n /**\n * @param opt If pass boolean, means opt.silent\n * @param opt.silent Default `false`. Whether trigger events.\n * @param opt.flush Default `undefined`.\n * true: Flush immediately, and then pixel in canvas can be fetched\n * immediately. Caution: it might affect performance.\n * false: Not flush.\n * undefined: Auto decide whether perform flush.\n */\n\n\n ECharts.prototype.dispatchAction = function (payload, opt) {\n if (this._disposed) {\n disposedWarning(this.id);\n return;\n }\n\n if (!isObject(opt)) {\n opt = {\n silent: !!opt\n };\n }\n\n if (!actions[payload.type]) {\n return;\n } // Avoid dispatch action before setOption. Especially in `connect`.\n\n\n if (!this._model) {\n return;\n } // May dispatchAction in rendering procedure\n\n\n if (this[IN_MAIN_PROCESS_KEY]) {\n this._pendingActions.push(payload);\n\n return;\n }\n\n var silent = opt.silent;\n doDispatchAction.call(this, payload, silent);\n var flush = opt.flush;\n\n if (flush) {\n this._zr.flush();\n } else if (flush !== false && env.browser.weChat) {\n // In WeChat embeded browser, `requestAnimationFrame` and `setInterval`\n // hang when sliding page (on touch event), which cause that zr does not\n // refresh util user interaction finished, which is not expected.\n // But `dispatchAction` may be called too frequently when pan on touch\n // screen, which impacts performance if do not throttle them.\n this._throttledZrFlush();\n }\n\n flushPendingActions.call(this, silent);\n triggerUpdatedEvent.call(this, silent);\n };\n\n ECharts.prototype.updateLabelLayout = function () {\n var labelManager = this._labelManager;\n labelManager.updateLayoutConfig(this._api);\n labelManager.layout(this._api);\n labelManager.processLabelsOverall();\n };\n\n ECharts.prototype.appendData = function (params) {\n if (this._disposed) {\n disposedWarning(this.id);\n return;\n }\n\n var seriesIndex = params.seriesIndex;\n var ecModel = this.getModel();\n var seriesModel = ecModel.getSeriesByIndex(seriesIndex);\n\n if (process.env.NODE_ENV !== 'production') {\n assert(params.data && seriesModel);\n }\n\n seriesModel.appendData(params); // Note: `appendData` does not support that update extent of coordinate\n // system, util some scenario require that. In the expected usage of\n // `appendData`, the initial extent of coordinate system should better\n // be fixed by axis `min`/`max` setting or initial data, otherwise if\n // the extent changed while `appendData`, the location of the painted\n // graphic elements have to be changed, which make the usage of\n // `appendData` meaningless.\n\n this._scheduler.unfinished = true;\n this.getZr().wakeUp();\n }; // A work around for no `internal` modifier in ts yet but\n // need to strictly hide private methods to JS users.\n\n\n ECharts.internalField = function () {\n prepare = function (ecIns) {\n var scheduler = ecIns._scheduler;\n scheduler.restorePipelines(ecIns._model);\n scheduler.prepareStageTasks();\n prepareView(ecIns, true);\n prepareView(ecIns, false);\n scheduler.plan();\n };\n /**\n * Prepare view instances of charts and components\n */\n\n\n prepareView = function (ecIns, isComponent) {\n var ecModel = ecIns._model;\n var scheduler = ecIns._scheduler;\n var viewList = isComponent ? ecIns._componentsViews : ecIns._chartsViews;\n var viewMap = isComponent ? ecIns._componentsMap : ecIns._chartsMap;\n var zr = ecIns._zr;\n var api = ecIns._api;\n\n for (var i = 0; i < viewList.length; i++) {\n viewList[i].__alive = false;\n }\n\n isComponent ? ecModel.eachComponent(function (componentType, model) {\n componentType !== 'series' && doPrepare(model);\n }) : ecModel.eachSeries(doPrepare);\n\n function doPrepare(model) {\n // By defaut view will be reused if possible for the case that `setOption` with \"notMerge\"\n // mode and need to enable transition animation. (Usually, when they have the same id, or\n // especially no id but have the same type & name & index. See the `model.id` generation\n // rule in `makeIdAndName` and `viewId` generation rule here).\n // But in `replaceMerge` mode, this feature should be able to disabled when it is clear that\n // the new model has nothing to do with the old model.\n var requireNewView = model.__requireNewView; // This command should not work twice.\n\n model.__requireNewView = false; // Consider: id same and type changed.\n\n var viewId = '_ec_' + model.id + '_' + model.type;\n var view = !requireNewView && viewMap[viewId];\n\n if (!view) {\n var classType = parseClassType(model.type);\n var Clazz = isComponent ? ComponentView.getClass(classType.main, classType.sub) : // FIXME:TS\n // (ChartView as ChartViewConstructor).getClass('series', classType.sub)\n // For backward compat, still support a chart type declared as only subType\n // like \"liquidfill\", but recommend \"series.liquidfill\"\n // But need a base class to make a type series.\n ChartView.getClass(classType.sub);\n\n if (process.env.NODE_ENV !== 'production') {\n assert(Clazz, classType.sub + ' does not exist.');\n }\n\n view = new Clazz();\n view.init(ecModel, api);\n viewMap[viewId] = view;\n viewList.push(view);\n zr.add(view.group);\n }\n\n model.__viewId = view.__id = viewId;\n view.__alive = true;\n view.__model = model;\n view.group.__ecComponentInfo = {\n mainType: model.mainType,\n index: model.componentIndex\n };\n !isComponent && scheduler.prepareView(view, model, ecModel, api);\n }\n\n for (var i = 0; i < viewList.length;) {\n var view = viewList[i];\n\n if (!view.__alive) {\n !isComponent && view.renderTask.dispose();\n zr.remove(view.group);\n view.dispose(ecModel, api);\n viewList.splice(i, 1);\n\n if (viewMap[view.__id] === view) {\n delete viewMap[view.__id];\n }\n\n view.__id = view.group.__ecComponentInfo = null;\n } else {\n i++;\n }\n }\n };\n\n updateDirectly = function (ecIns, method, payload, mainType, subType) {\n var ecModel = ecIns._model;\n ecModel.setUpdatePayload(payload); // broadcast\n\n if (!mainType) {\n // FIXME\n // Chart will not be update directly here, except set dirty.\n // But there is no such scenario now.\n each([].concat(ecIns._componentsViews).concat(ecIns._chartsViews), callView);\n return;\n }\n\n var query = {};\n query[mainType + 'Id'] = payload[mainType + 'Id'];\n query[mainType + 'Index'] = payload[mainType + 'Index'];\n query[mainType + 'Name'] = payload[mainType + 'Name'];\n var condition = {\n mainType: mainType,\n query: query\n };\n subType && (condition.subType = subType); // subType may be '' by parseClassType;\n\n var excludeSeriesId = payload.excludeSeriesId;\n var excludeSeriesIdMap;\n\n if (excludeSeriesId != null) {\n excludeSeriesIdMap = zrUtil.createHashMap();\n each(modelUtil.normalizeToArray(excludeSeriesId), function (id) {\n var modelId = modelUtil.convertOptionIdName(id, null);\n\n if (modelId != null) {\n excludeSeriesIdMap.set(modelId, true);\n }\n });\n } // If dispatchAction before setOption, do nothing.\n\n\n ecModel && ecModel.eachComponent(condition, function (model) {\n if (!excludeSeriesIdMap || excludeSeriesIdMap.get(model.id) == null) {\n if (isHighDownPayload(payload) && !payload.notBlur) {\n if (model instanceof SeriesModel) {\n toggleSeriesBlurStateFromPayload(model, payload, ecIns._api);\n }\n } else if (isSelectChangePayload(payload)) {\n // TODO geo\n if (model instanceof SeriesModel) {\n toggleSelectionFromPayload(model, payload, ecIns._api);\n updateSeriesElementSelection(model);\n markStatusToUpdate(ecIns);\n }\n }\n\n callView(ecIns[mainType === 'series' ? '_chartsMap' : '_componentsMap'][model.__viewId]);\n }\n }, ecIns);\n\n function callView(view) {\n view && view.__alive && view[method] && view[method](view.__model, ecModel, ecIns._api, payload);\n }\n };\n\n updateMethods = {\n prepareAndUpdate: function (payload) {\n prepare(this);\n updateMethods.update.call(this, payload);\n },\n update: function (payload) {\n // console.profile && console.profile('update');\n var ecModel = this._model;\n var api = this._api;\n var zr = this._zr;\n var coordSysMgr = this._coordSysMgr;\n var scheduler = this._scheduler; // update before setOption\n\n if (!ecModel) {\n return;\n }\n\n ecModel.setUpdatePayload(payload);\n scheduler.restoreData(ecModel, payload);\n scheduler.performSeriesTasks(ecModel); // TODO\n // Save total ecModel here for undo/redo (after restoring data and before processing data).\n // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call.\n // Create new coordinate system each update\n // In LineView may save the old coordinate system and use it to get the orignal point\n\n coordSysMgr.create(ecModel, api);\n scheduler.performDataProcessorTasks(ecModel, payload); // Current stream render is not supported in data process. So we can update\n // stream modes after data processing, where the filtered data is used to\n // deteming whether use progressive rendering.\n\n updateStreamModes(this, ecModel); // We update stream modes before coordinate system updated, then the modes info\n // can be fetched when coord sys updating (consider the barGrid extent fix). But\n // the drawback is the full coord info can not be fetched. Fortunately this full\n // coord is not requied in stream mode updater currently.\n\n coordSysMgr.update(ecModel, api);\n clearColorPalette(ecModel);\n scheduler.performVisualTasks(ecModel, payload);\n render(this, ecModel, api, payload); // Set background\n\n var backgroundColor = ecModel.get('backgroundColor') || 'transparent';\n var darkMode = ecModel.get('darkMode'); // In IE8\n\n if (!env.canvasSupported) {\n var colorArr = colorTool.parse(backgroundColor);\n backgroundColor = colorTool.stringify(colorArr, 'rgb');\n\n if (colorArr[3] === 0) {\n backgroundColor = 'transparent';\n }\n } else {\n zr.setBackgroundColor(backgroundColor); // Force set dark mode.\n\n if (darkMode != null && darkMode !== 'auto') {\n zr.setDarkMode(darkMode);\n }\n }\n\n performPostUpdateFuncs(ecModel, api); // console.profile && console.profileEnd('update');\n },\n updateTransform: function (payload) {\n var _this = this;\n\n var ecModel = this._model;\n var api = this._api; // update before setOption\n\n if (!ecModel) {\n return;\n }\n\n ecModel.setUpdatePayload(payload); // ChartView.markUpdateMethod(payload, 'updateTransform');\n\n var componentDirtyList = [];\n ecModel.eachComponent(function (componentType, componentModel) {\n if (componentType === 'series') {\n return;\n }\n\n var componentView = _this.getViewOfComponentModel(componentModel);\n\n if (componentView && componentView.__alive) {\n if (componentView.updateTransform) {\n var result = componentView.updateTransform(componentModel, ecModel, api, payload);\n result && result.update && componentDirtyList.push(componentView);\n } else {\n componentDirtyList.push(componentView);\n }\n }\n });\n var seriesDirtyMap = zrUtil.createHashMap();\n ecModel.eachSeries(function (seriesModel) {\n var chartView = _this._chartsMap[seriesModel.__viewId];\n\n if (chartView.updateTransform) {\n var result = chartView.updateTransform(seriesModel, ecModel, api, payload);\n result && result.update && seriesDirtyMap.set(seriesModel.uid, 1);\n } else {\n seriesDirtyMap.set(seriesModel.uid, 1);\n }\n });\n clearColorPalette(ecModel); // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline.\n // this._scheduler.performVisualTasks(ecModel, payload, 'layout', true);\n\n this._scheduler.performVisualTasks(ecModel, payload, {\n setDirty: true,\n dirtyMap: seriesDirtyMap\n }); // Currently, not call render of components. Geo render cost a lot.\n // renderComponents(ecIns, ecModel, api, payload, componentDirtyList);\n\n\n renderSeries(this, ecModel, api, payload, seriesDirtyMap);\n performPostUpdateFuncs(ecModel, this._api);\n },\n updateView: function (payload) {\n var ecModel = this._model; // update before setOption\n\n if (!ecModel) {\n return;\n }\n\n ecModel.setUpdatePayload(payload);\n ChartView.markUpdateMethod(payload, 'updateView');\n clearColorPalette(ecModel); // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline.\n\n this._scheduler.performVisualTasks(ecModel, payload, {\n setDirty: true\n });\n\n render(this, this._model, this._api, payload);\n performPostUpdateFuncs(ecModel, this._api);\n },\n updateVisual: function (payload) {\n // updateMethods.update.call(this, payload);\n var _this = this;\n\n var ecModel = this._model; // update before setOption\n\n if (!ecModel) {\n return;\n }\n\n ecModel.setUpdatePayload(payload); // clear all visual\n\n ecModel.eachSeries(function (seriesModel) {\n seriesModel.getData().clearAllVisual();\n }); // Perform visual\n\n ChartView.markUpdateMethod(payload, 'updateVisual');\n clearColorPalette(ecModel); // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline.\n\n this._scheduler.performVisualTasks(ecModel, payload, {\n visualType: 'visual',\n setDirty: true\n });\n\n ecModel.eachComponent(function (componentType, componentModel) {\n if (componentType !== 'series') {\n var componentView = _this.getViewOfComponentModel(componentModel);\n\n componentView && componentView.__alive && componentView.updateVisual(componentModel, ecModel, _this._api, payload);\n }\n });\n ecModel.eachSeries(function (seriesModel) {\n var chartView = _this._chartsMap[seriesModel.__viewId];\n chartView.updateVisual(seriesModel, ecModel, _this._api, payload);\n });\n performPostUpdateFuncs(ecModel, this._api);\n },\n updateLayout: function (payload) {\n updateMethods.update.call(this, payload);\n }\n };\n\n doConvertPixel = function (ecIns, methodName, finder, value) {\n if (ecIns._disposed) {\n disposedWarning(ecIns.id);\n return;\n }\n\n var ecModel = ecIns._model;\n\n var coordSysList = ecIns._coordSysMgr.getCoordinateSystems();\n\n var result;\n var parsedFinder = modelUtil.parseFinder(ecModel, finder);\n\n for (var i = 0; i < coordSysList.length; i++) {\n var coordSys = coordSysList[i];\n\n if (coordSys[methodName] && (result = coordSys[methodName](ecModel, parsedFinder, value)) != null) {\n return result;\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n console.warn('No coordinate system that supports ' + methodName + ' found by the given finder.');\n }\n };\n\n updateStreamModes = function (ecIns, ecModel) {\n var chartsMap = ecIns._chartsMap;\n var scheduler = ecIns._scheduler;\n ecModel.eachSeries(function (seriesModel) {\n scheduler.updateStreamModes(seriesModel, chartsMap[seriesModel.__viewId]);\n });\n };\n\n doDispatchAction = function (payload, silent) {\n var _this = this;\n\n var ecModel = this.getModel();\n var payloadType = payload.type;\n var escapeConnect = payload.escapeConnect;\n var actionWrap = actions[payloadType];\n var actionInfo = actionWrap.actionInfo;\n var cptTypeTmp = (actionInfo.update || 'update').split(':');\n var updateMethod = cptTypeTmp.pop();\n var cptType = cptTypeTmp[0] != null && parseClassType(cptTypeTmp[0]);\n this[IN_MAIN_PROCESS_KEY] = true;\n var payloads = [payload];\n var batched = false; // Batch action\n\n if (payload.batch) {\n batched = true;\n payloads = zrUtil.map(payload.batch, function (item) {\n item = zrUtil.defaults(zrUtil.extend({}, item), payload);\n item.batch = null;\n return item;\n });\n }\n\n var eventObjBatch = [];\n var eventObj;\n var isSelectChange = isSelectChangePayload(payload);\n var isStatusChange = isHighDownPayload(payload) || isSelectChange;\n each(payloads, function (batchItem) {\n // Action can specify the event by return it.\n eventObj = actionWrap.action(batchItem, _this._model, _this._api); // Emit event outside\n\n eventObj = eventObj || zrUtil.extend({}, batchItem); // Convert type to eventType\n\n eventObj.type = actionInfo.event || eventObj.type;\n eventObjBatch.push(eventObj); // light update does not perform data process, layout and visual.\n\n if (isStatusChange) {\n // method, payload, mainType, subType\n updateDirectly(_this, updateMethod, batchItem, 'series'); // Mark status to update\n\n markStatusToUpdate(_this);\n } else if (cptType) {\n updateDirectly(_this, updateMethod, batchItem, cptType.main, cptType.sub);\n }\n });\n\n if (updateMethod !== 'none' && !isStatusChange && !cptType) {\n // Still dirty\n if (this[OPTION_UPDATED_KEY]) {\n prepare(this);\n updateMethods.update.call(this, payload);\n this[OPTION_UPDATED_KEY] = false;\n } else {\n updateMethods[updateMethod].call(this, payload);\n }\n } // Follow the rule of action batch\n\n\n if (batched) {\n eventObj = {\n type: actionInfo.event || payloadType,\n escapeConnect: escapeConnect,\n batch: eventObjBatch\n };\n } else {\n eventObj = eventObjBatch[0];\n }\n\n this[IN_MAIN_PROCESS_KEY] = false;\n\n if (!silent) {\n var messageCenter = this._messageCenter;\n messageCenter.trigger(eventObj.type, eventObj); // Extra triggered 'selectchanged' event\n\n if (isSelectChange) {\n var newObj = {\n type: 'selectchanged',\n escapeConnect: escapeConnect,\n selected: getAllSelectedIndices(ecModel),\n isFromClick: payload.isFromClick || false,\n fromAction: payload.type,\n fromActionPayload: payload\n };\n messageCenter.trigger(newObj.type, newObj);\n }\n }\n };\n\n flushPendingActions = function (silent) {\n var pendingActions = this._pendingActions;\n\n while (pendingActions.length) {\n var payload = pendingActions.shift();\n doDispatchAction.call(this, payload, silent);\n }\n };\n\n triggerUpdatedEvent = function (silent) {\n !silent && this.trigger('updated');\n };\n /**\n * Event `rendered` is triggered when zr\n * rendered. It is useful for realtime\n * snapshot (reflect animation).\n *\n * Event `finished` is triggered when:\n * (1) zrender rendering finished.\n * (2) initial animation finished.\n * (3) progressive rendering finished.\n * (4) no pending action.\n * (5) no delayed setOption needs to be processed.\n */\n\n\n bindRenderedEvent = function (zr, ecIns) {\n zr.on('rendered', function (params) {\n ecIns.trigger('rendered', params); // The `finished` event should not be triggered repeatly,\n // so it should only be triggered when rendering indeed happend\n // in zrender. (Consider the case that dipatchAction is keep\n // triggering when mouse move).\n\n if ( // Although zr is dirty if initial animation is not finished\n // and this checking is called on frame, we also check\n // animation finished for robustness.\n zr.animation.isFinished() && !ecIns[OPTION_UPDATED_KEY] && !ecIns._scheduler.unfinished && !ecIns._pendingActions.length) {\n ecIns.trigger('finished');\n }\n });\n };\n\n bindMouseEvent = function (zr, ecIns) {\n zr.on('mouseover', function (e) {\n var el = e.target;\n var dispatcher = findEventDispatcher(el, isHighDownDispatcher);\n\n if (dispatcher) {\n var ecData = getECData(dispatcher); // Try blur all in the related series. Then emphasis the hoverred.\n // TODO. progressive mode.\n\n toggleSeriesBlurState(ecData.seriesIndex, ecData.focus, ecData.blurScope, ecIns._api, true);\n enterEmphasisWhenMouseOver(dispatcher, e);\n markStatusToUpdate(ecIns);\n }\n }).on('mouseout', function (e) {\n var el = e.target;\n var dispatcher = findEventDispatcher(el, isHighDownDispatcher);\n\n if (dispatcher) {\n var ecData = getECData(dispatcher);\n toggleSeriesBlurState(ecData.seriesIndex, ecData.focus, ecData.blurScope, ecIns._api, false);\n leaveEmphasisWhenMouseOut(dispatcher, e);\n markStatusToUpdate(ecIns);\n }\n }).on('click', function (e) {\n var el = e.target;\n var dispatcher = findEventDispatcher(el, function (target) {\n return getECData(target).dataIndex != null;\n }, true);\n\n if (dispatcher) {\n var actionType = dispatcher.selected ? 'unselect' : 'select';\n var ecData = getECData(dispatcher);\n\n ecIns._api.dispatchAction({\n type: actionType,\n dataType: ecData.dataType,\n dataIndexInside: ecData.dataIndex,\n seriesIndex: ecData.seriesIndex,\n isFromClick: true\n });\n }\n });\n };\n\n clearColorPalette = function (ecModel) {\n ecModel.clearColorPalette();\n ecModel.eachSeries(function (seriesModel) {\n seriesModel.clearColorPalette();\n });\n };\n\n render = function (ecIns, ecModel, api, payload) {\n renderComponents(ecIns, ecModel, api, payload);\n each(ecIns._chartsViews, function (chart) {\n chart.__alive = false;\n });\n renderSeries(ecIns, ecModel, api, payload); // Remove groups of unrendered charts\n\n each(ecIns._chartsViews, function (chart) {\n if (!chart.__alive) {\n chart.remove(ecModel, api);\n }\n });\n };\n\n renderComponents = function (ecIns, ecModel, api, payload, dirtyList) {\n each(dirtyList || ecIns._componentsViews, function (componentView) {\n var componentModel = componentView.__model;\n clearStates(componentModel, componentView);\n componentView.render(componentModel, ecModel, api, payload);\n updateZ(componentModel, componentView);\n updateStates(componentModel, componentView);\n });\n };\n /**\n * Render each chart and component\n */\n\n\n renderSeries = function (ecIns, ecModel, api, payload, dirtyMap) {\n // Render all charts\n var scheduler = ecIns._scheduler;\n var labelManager = ecIns._labelManager;\n labelManager.clearLabels();\n var unfinished = false;\n ecModel.eachSeries(function (seriesModel) {\n var chartView = ecIns._chartsMap[seriesModel.__viewId];\n chartView.__alive = true;\n var renderTask = chartView.renderTask;\n scheduler.updatePayload(renderTask, payload); // TODO states on marker.\n\n clearStates(seriesModel, chartView);\n\n if (dirtyMap && dirtyMap.get(seriesModel.uid)) {\n renderTask.dirty();\n }\n\n if (renderTask.perform(scheduler.getPerformArgs(renderTask))) {\n unfinished = true;\n }\n\n seriesModel.__transientTransitionOpt = null;\n chartView.group.silent = !!seriesModel.get('silent'); // Should not call markRedraw on group, because it will disable zrender\n // increamental render (alway render from the __startIndex each frame)\n // chartView.group.markRedraw();\n\n updateBlend(seriesModel, chartView);\n updateSeriesElementSelection(seriesModel); // Add labels.\n\n labelManager.addLabelsOfSeries(chartView);\n });\n scheduler.unfinished = unfinished || scheduler.unfinished;\n labelManager.updateLayoutConfig(api);\n labelManager.layout(api);\n labelManager.processLabelsOverall();\n ecModel.eachSeries(function (seriesModel) {\n var chartView = ecIns._chartsMap[seriesModel.__viewId]; // Update Z after labels updated. Before applying states.\n\n updateZ(seriesModel, chartView); // NOTE: Update states after label is updated.\n // label should be in normal status when layouting.\n\n updateStates(seriesModel, chartView);\n }); // If use hover layer\n\n updateHoverLayerStatus(ecIns, ecModel);\n };\n\n performPostUpdateFuncs = function (ecModel, api) {\n each(postUpdateFuncs, function (func) {\n func(ecModel, api);\n });\n };\n\n markStatusToUpdate = function (ecIns) {\n ecIns[STATUS_NEEDS_UPDATE_KEY] = true; // Wake up zrender if it's sleep. Let it update states in the next frame.\n\n ecIns.getZr().wakeUp();\n };\n\n applyChangedStates = function (ecIns) {\n if (!ecIns[STATUS_NEEDS_UPDATE_KEY]) {\n return;\n }\n\n ecIns.getZr().storage.traverse(function (el) {\n // Not applied on removed elements, it may still in fading.\n if (graphic.isElementRemoved(el)) {\n return;\n }\n\n applyElementStates(el);\n });\n ecIns[STATUS_NEEDS_UPDATE_KEY] = false;\n };\n\n function applyElementStates(el) {\n var newStates = [];\n var oldStates = el.currentStates; // Keep other states.\n\n for (var i = 0; i < oldStates.length; i++) {\n var stateName = oldStates[i];\n\n if (!(stateName === 'emphasis' || stateName === 'blur' || stateName === 'select')) {\n newStates.push(stateName);\n }\n } // Only use states when it's exists.\n\n\n if (el.selected && el.states.select) {\n newStates.push('select');\n }\n\n if (el.hoverState === HOVER_STATE_EMPHASIS && el.states.emphasis) {\n newStates.push('emphasis');\n } else if (el.hoverState === HOVER_STATE_BLUR && el.states.blur) {\n newStates.push('blur');\n }\n\n el.useStates(newStates);\n }\n\n function updateHoverLayerStatus(ecIns, ecModel) {\n var zr = ecIns._zr;\n var storage = zr.storage;\n var elCount = 0;\n storage.traverse(function (el) {\n if (!el.isGroup) {\n elCount++;\n }\n });\n\n if (elCount > ecModel.get('hoverLayerThreshold') && !env.node && !env.worker) {\n ecModel.eachSeries(function (seriesModel) {\n if (seriesModel.preventUsingHoverLayer) {\n return;\n }\n\n var chartView = ecIns._chartsMap[seriesModel.__viewId];\n\n if (chartView.__alive) {\n chartView.group.traverse(function (el) {\n if (el.states.emphasis) {\n el.states.emphasis.hoverLayer = true;\n }\n });\n }\n });\n }\n }\n\n ;\n /**\n * Update chart and blend.\n */\n\n function updateBlend(seriesModel, chartView) {\n var blendMode = seriesModel.get('blendMode') || null;\n\n if (process.env.NODE_ENV !== 'production') {\n if (!env.canvasSupported && blendMode && blendMode !== 'source-over') {\n console.warn('Only canvas support blendMode');\n }\n }\n\n chartView.group.traverse(function (el) {\n // FIXME marker and other components\n if (!el.isGroup) {\n // DONT mark the element dirty. In case element is incremental and don't wan't to rerender.\n el.style.blend = blendMode;\n }\n\n if (el.eachPendingDisplayable) {\n el.eachPendingDisplayable(function (displayable) {\n displayable.style.blend = blendMode;\n });\n }\n });\n }\n\n ;\n\n function updateZ(model, view) {\n if (model.preventAutoZ) {\n return;\n }\n\n var z = model.get('z');\n var zlevel = model.get('zlevel'); // Set z and zlevel\n\n view.group.traverse(function (el) {\n if (!el.isGroup) {\n z != null && (el.z = z);\n zlevel != null && (el.zlevel = zlevel); // TODO if textContent is on group.\n\n var label = el.getTextContent();\n var labelLine = el.getTextGuideLine();\n\n if (label) {\n label.z = el.z;\n label.zlevel = el.zlevel; // lift z2 of text content\n // TODO if el.emphasis.z2 is spcefied, what about textContent.\n\n label.z2 = el.z2 + 2;\n }\n\n if (labelLine) {\n var showAbove = el.textGuideLineConfig && el.textGuideLineConfig.showAbove;\n labelLine.z = el.z;\n labelLine.zlevel = el.zlevel;\n labelLine.z2 = el.z2 + (showAbove ? 1 : -1);\n }\n }\n });\n }\n\n ; // Clear states without animation.\n // TODO States on component.\n\n function clearStates(model, view) {\n view.group.traverse(function (el) {\n // Not applied on removed elements, it may still in fading.\n if (graphic.isElementRemoved(el)) {\n return;\n }\n\n var textContent = el.getTextContent();\n var textGuide = el.getTextGuideLine();\n\n if (el.stateTransition) {\n el.stateTransition = null;\n }\n\n if (textContent && textContent.stateTransition) {\n textContent.stateTransition = null;\n }\n\n if (textGuide && textGuide.stateTransition) {\n textGuide.stateTransition = null;\n } // TODO If el is incremental.\n\n\n if (el.hasState()) {\n el.prevStates = el.currentStates;\n el.clearStates();\n } else if (el.prevStates) {\n el.prevStates = null;\n }\n });\n }\n\n function updateStates(model, view) {\n var stateAnimationModel = model.getModel('stateAnimation');\n var enableAnimation = model.isAnimationEnabled();\n var duration = stateAnimationModel.get('duration');\n var stateTransition = duration > 0 ? {\n duration: duration,\n delay: stateAnimationModel.get('delay'),\n easing: stateAnimationModel.get('easing') // additive: stateAnimationModel.get('additive')\n\n } : null;\n view.group.traverse(function (el) {\n if (el.states && el.states.emphasis) {\n // Not applied on removed elements, it may still in fading.\n if (graphic.isElementRemoved(el)) {\n return;\n }\n\n if (el instanceof graphic.Path) {\n savePathStates(el);\n } // Only updated on changed element. In case element is incremental and don't wan't to rerender.\n // TODO, a more proper way?\n\n\n if (el.__dirty) {\n var prevStates = el.prevStates; // Restore states without animation\n\n if (prevStates) {\n el.useStates(prevStates);\n }\n } // Update state transition and enable animation again.\n\n\n if (enableAnimation) {\n el.stateTransition = stateTransition;\n var textContent = el.getTextContent();\n var textGuide = el.getTextGuideLine(); // TODO Is it necessary to animate label?\n\n if (textContent) {\n textContent.stateTransition = stateTransition;\n }\n\n if (textGuide) {\n textGuide.stateTransition = stateTransition;\n }\n } // The use higlighted and selected flag to toggle states.\n\n\n if (el.__dirty) {\n applyElementStates(el);\n }\n }\n });\n }\n\n ;\n\n createExtensionAPI = function (ecIns) {\n return new (\n /** @class */\n function (_super) {\n __extends(class_1, _super);\n\n function class_1() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n\n class_1.prototype.getCoordinateSystems = function () {\n return ecIns._coordSysMgr.getCoordinateSystems();\n };\n\n class_1.prototype.getComponentByElement = function (el) {\n while (el) {\n var modelInfo = el.__ecComponentInfo;\n\n if (modelInfo != null) {\n return ecIns._model.getComponent(modelInfo.mainType, modelInfo.index);\n }\n\n el = el.parent;\n }\n };\n\n class_1.prototype.enterEmphasis = function (el, highlightDigit) {\n enterEmphasis(el, highlightDigit);\n markStatusToUpdate(ecIns);\n };\n\n class_1.prototype.leaveEmphasis = function (el, highlightDigit) {\n leaveEmphasis(el, highlightDigit);\n markStatusToUpdate(ecIns);\n };\n\n class_1.prototype.enterBlur = function (el) {\n enterBlur(el);\n markStatusToUpdate(ecIns);\n };\n\n class_1.prototype.leaveBlur = function (el) {\n leaveBlur(el);\n markStatusToUpdate(ecIns);\n };\n\n class_1.prototype.enterSelect = function (el) {\n enterSelect(el);\n markStatusToUpdate(ecIns);\n };\n\n class_1.prototype.leaveSelect = function (el) {\n leaveSelect(el);\n markStatusToUpdate(ecIns);\n };\n\n class_1.prototype.getModel = function () {\n return ecIns.getModel();\n };\n\n class_1.prototype.getViewOfComponentModel = function (componentModel) {\n return ecIns.getViewOfComponentModel(componentModel);\n };\n\n class_1.prototype.getViewOfSeriesModel = function (seriesModel) {\n return ecIns.getViewOfSeriesModel(seriesModel);\n };\n\n return class_1;\n }(ExtensionAPI))(ecIns);\n };\n\n enableConnect = function (chart) {\n function updateConnectedChartsStatus(charts, status) {\n for (var i = 0; i < charts.length; i++) {\n var otherChart = charts[i];\n otherChart[CONNECT_STATUS_KEY] = status;\n }\n }\n\n each(eventActionMap, function (actionType, eventType) {\n chart._messageCenter.on(eventType, function (event) {\n if (connectedGroups[chart.group] && chart[CONNECT_STATUS_KEY] !== CONNECT_STATUS_PENDING) {\n if (event && event.escapeConnect) {\n return;\n }\n\n var action_1 = chart.makeActionFromEvent(event);\n var otherCharts_1 = [];\n each(instances, function (otherChart) {\n if (otherChart !== chart && otherChart.group === chart.group) {\n otherCharts_1.push(otherChart);\n }\n });\n updateConnectedChartsStatus(otherCharts_1, CONNECT_STATUS_PENDING);\n each(otherCharts_1, function (otherChart) {\n if (otherChart[CONNECT_STATUS_KEY] !== CONNECT_STATUS_UPDATING) {\n otherChart.dispatchAction(action_1);\n }\n });\n updateConnectedChartsStatus(otherCharts_1, CONNECT_STATUS_UPDATED);\n }\n });\n });\n };\n\n setTransitionOpt = function (chart, transitionOpt) {\n var ecModel = chart._model;\n zrUtil.each(modelUtil.normalizeToArray(transitionOpt), function (transOpt) {\n var errMsg;\n var fromOpt = transOpt.from;\n var toOpt = transOpt.to;\n\n if (toOpt == null) {\n if (process.env.NODE_ENV !== 'production') {\n errMsg = '`transition.to` must be specified.';\n }\n\n throwError(errMsg);\n }\n\n var finderOpt = {\n includeMainTypes: ['series'],\n enableAll: false,\n enableNone: false\n };\n var fromResult = fromOpt ? modelUtil.parseFinder(ecModel, fromOpt, finderOpt) : null;\n var toResult = modelUtil.parseFinder(ecModel, toOpt, finderOpt);\n var toSeries = toResult.seriesModel;\n\n if (toSeries == null) {\n errMsg = '';\n\n if (process.env.NODE_ENV !== 'production') {\n errMsg = '`transition` is only supported on series.';\n }\n }\n\n if (fromResult && fromResult.seriesModel !== toSeries) {\n errMsg = '';\n\n if (process.env.NODE_ENV !== 'production') {\n errMsg = '`transition.from` and `transition.to` must be specified to the same series.';\n }\n }\n\n if (errMsg != null) {\n throwError(errMsg);\n } // Just a temp solution: mount them on series.\n\n\n toSeries.__transientTransitionOpt = {\n from: fromOpt ? fromOpt.dimension : null,\n to: toOpt.dimension,\n dividingMethod: transOpt.dividingMethod\n };\n });\n };\n }();\n\n return ECharts;\n}(Eventful);\n\nvar echartsProto = ECharts.prototype;\nechartsProto.on = createRegisterEventWithLowercaseECharts('on');\nechartsProto.off = createRegisterEventWithLowercaseECharts('off');\n/**\n * @deprecated\n */\n// @ts-ignore\n\nechartsProto.one = function (eventName, cb, ctx) {\n var self = this;\n deprecateLog('ECharts#one is deprecated.');\n\n function wrapped() {\n var args2 = [];\n\n for (var _i = 0; _i < arguments.length; _i++) {\n args2[_i] = arguments[_i];\n }\n\n cb && cb.apply && cb.apply(this, args2); // @ts-ignore\n\n self.off(eventName, wrapped);\n }\n\n ; // @ts-ignore\n\n this.on.call(this, eventName, wrapped, ctx);\n}; // /**\n// * Encode visual infomation from data after data processing\n// *\n// * @param {module:echarts/model/Global} ecModel\n// * @param {object} layout\n// * @param {boolean} [layoutFilter] `true`: only layout,\n// * `false`: only not layout,\n// * `null`/`undefined`: all.\n// * @param {string} taskBaseTag\n// * @private\n// */\n// function startVisualEncoding(ecIns, ecModel, api, payload, layoutFilter) {\n// each(visualFuncs, function (visual, index) {\n// let isLayout = visual.isLayout;\n// if (layoutFilter == null\n// || (layoutFilter === false && !isLayout)\n// || (layoutFilter === true && isLayout)\n// ) {\n// visual.func(ecModel, api, payload);\n// }\n// });\n// }\n\n\nvar MOUSE_EVENT_NAMES = ['click', 'dblclick', 'mouseover', 'mouseout', 'mousemove', 'mousedown', 'mouseup', 'globalout', 'contextmenu'];\n\nfunction disposedWarning(id) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn('Instance ' + id + ' has been disposed');\n }\n}\n\nvar actions = {};\n/**\n * Map eventType to actionType\n */\n\nvar eventActionMap = {};\nvar dataProcessorFuncs = [];\nvar optionPreprocessorFuncs = [];\nvar postInitFuncs = [];\nvar postUpdateFuncs = [];\nvar visualFuncs = [];\nvar themeStorage = {};\nvar loadingEffects = {};\nvar instances = {};\nvar connectedGroups = {};\nvar idBase = +new Date() - 0;\nvar groupIdBase = +new Date() - 0;\nvar DOM_ATTRIBUTE_KEY = '_echarts_instance_';\n/**\n * @param opts.devicePixelRatio Use window.devicePixelRatio by default\n * @param opts.renderer Can choose 'canvas' or 'svg' to render the chart.\n * @param opts.width Use clientWidth of the input `dom` by default.\n * Can be 'auto' (the same as null/undefined)\n * @param opts.height Use clientHeight of the input `dom` by default.\n * Can be 'auto' (the same as null/undefined)\n */\n\nexport function init(dom, theme, opts) {\n if (process.env.NODE_ENV !== 'production') {\n if (!dom) {\n throw new Error('Initialize failed: invalid dom.');\n }\n }\n\n var existInstance = getInstanceByDom(dom);\n\n if (existInstance) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn('There is a chart instance already initialized on the dom.');\n }\n\n return existInstance;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (zrUtil.isDom(dom) && dom.nodeName.toUpperCase() !== 'CANVAS' && (!dom.clientWidth && (!opts || opts.width == null) || !dom.clientHeight && (!opts || opts.height == null))) {\n console.warn('Can\\'t get DOM width or height. Please check ' + 'dom.clientWidth and dom.clientHeight. They should not be 0.' + 'For example, you may need to call this in the callback ' + 'of window.onload.');\n }\n }\n\n var chart = new ECharts(dom, theme, opts);\n chart.id = 'ec_' + idBase++;\n instances[chart.id] = chart;\n modelUtil.setAttribute(dom, DOM_ATTRIBUTE_KEY, chart.id);\n enableConnect(chart);\n each(postInitFuncs, function (postInitFunc) {\n postInitFunc(chart);\n });\n return chart;\n}\n/**\n * @usage\n * (A)\n * ```js\n * let chart1 = echarts.init(dom1);\n * let chart2 = echarts.init(dom2);\n * chart1.group = 'xxx';\n * chart2.group = 'xxx';\n * echarts.connect('xxx');\n * ```\n * (B)\n * ```js\n * let chart1 = echarts.init(dom1);\n * let chart2 = echarts.init(dom2);\n * echarts.connect('xxx', [chart1, chart2]);\n * ```\n */\n\nexport function connect(groupId) {\n // Is array of charts\n if (zrUtil.isArray(groupId)) {\n var charts = groupId;\n groupId = null; // If any chart has group\n\n each(charts, function (chart) {\n if (chart.group != null) {\n groupId = chart.group;\n }\n });\n groupId = groupId || 'g_' + groupIdBase++;\n each(charts, function (chart) {\n chart.group = groupId;\n });\n }\n\n connectedGroups[groupId] = true;\n return groupId;\n}\n/**\n * @deprecated\n */\n\nexport function disConnect(groupId) {\n connectedGroups[groupId] = false;\n}\n/**\n * Alias and backword compat\n */\n\nexport var disconnect = disConnect;\n/**\n * Dispose a chart instance\n */\n\nexport function dispose(chart) {\n if (typeof chart === 'string') {\n chart = instances[chart];\n } else if (!(chart instanceof ECharts)) {\n // Try to treat as dom\n chart = getInstanceByDom(chart);\n }\n\n if (chart instanceof ECharts && !chart.isDisposed()) {\n chart.dispose();\n }\n}\nexport function getInstanceByDom(dom) {\n return instances[modelUtil.getAttribute(dom, DOM_ATTRIBUTE_KEY)];\n}\nexport function getInstanceById(key) {\n return instances[key];\n}\n/**\n * Register theme\n */\n\nexport function registerTheme(name, theme) {\n themeStorage[name] = theme;\n}\n/**\n * Register option preprocessor\n */\n\nexport function registerPreprocessor(preprocessorFunc) {\n if (indexOf(optionPreprocessorFuncs, preprocessorFunc) < 0) {\n optionPreprocessorFuncs.push(preprocessorFunc);\n }\n}\nexport function registerProcessor(priority, processor) {\n normalizeRegister(dataProcessorFuncs, priority, processor, PRIORITY_PROCESSOR_DEFAULT);\n}\n/**\n * Register postIniter\n * @param {Function} postInitFunc\n */\n\nexport function registerPostInit(postInitFunc) {\n if (indexOf(postInitFuncs, postInitFunc) < 0) {\n postInitFunc && postInitFuncs.push(postInitFunc);\n }\n}\n/**\n * Register postUpdater\n * @param {Function} postUpdateFunc\n */\n\nexport function registerPostUpdate(postUpdateFunc) {\n if (indexOf(postUpdateFuncs, postUpdateFunc) < 0) {\n postUpdateFunc && postUpdateFuncs.push(postUpdateFunc);\n }\n}\nexport function registerAction(actionInfo, eventName, action) {\n if (typeof eventName === 'function') {\n action = eventName;\n eventName = '';\n }\n\n var actionType = isObject(actionInfo) ? actionInfo.type : [actionInfo, actionInfo = {\n event: eventName\n }][0]; // Event name is all lowercase\n\n actionInfo.event = (actionInfo.event || actionType).toLowerCase();\n eventName = actionInfo.event;\n\n if (eventActionMap[eventName]) {\n // Already registered.\n return;\n } // Validate action type and event name.\n\n\n assert(ACTION_REG.test(actionType) && ACTION_REG.test(eventName));\n\n if (!actions[actionType]) {\n actions[actionType] = {\n action: action,\n actionInfo: actionInfo\n };\n }\n\n eventActionMap[eventName] = actionType;\n}\nexport function registerCoordinateSystem(type, coordSysCreator) {\n CoordinateSystemManager.register(type, coordSysCreator);\n}\n/**\n * Get dimensions of specified coordinate system.\n * @param {string} type\n * @return {Array.}\n */\n\nexport function getCoordinateSystemDimensions(type) {\n var coordSysCreator = CoordinateSystemManager.get(type);\n\n if (coordSysCreator) {\n return coordSysCreator.getDimensionsInfo ? coordSysCreator.getDimensionsInfo() : coordSysCreator.dimensions.slice();\n }\n}\nexport { registerLocale } from './locale';\n\nfunction registerLayout(priority, layoutTask) {\n normalizeRegister(visualFuncs, priority, layoutTask, PRIORITY_VISUAL_LAYOUT, 'layout');\n}\n\nfunction registerVisual(priority, visualTask) {\n normalizeRegister(visualFuncs, priority, visualTask, PRIORITY_VISUAL_CHART, 'visual');\n}\n\nexport { registerLayout, registerVisual };\nvar registeredTasks = [];\n\nfunction normalizeRegister(targetList, priority, fn, defaultPriority, visualType) {\n if (isFunction(priority) || isObject(priority)) {\n fn = priority;\n priority = defaultPriority;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (isNaN(priority) || priority == null) {\n throw new Error('Illegal priority');\n } // Check duplicate\n\n\n each(targetList, function (wrap) {\n assert(wrap.__raw !== fn);\n });\n } // Already registered\n\n\n if (indexOf(registeredTasks, fn) >= 0) {\n return;\n }\n\n registeredTasks.push(fn);\n var stageHandler = Scheduler.wrapStageHandler(fn, visualType);\n stageHandler.__prio = priority;\n stageHandler.__raw = fn;\n targetList.push(stageHandler);\n}\n\nexport function registerLoading(name, loadingFx) {\n loadingEffects[name] = loadingFx;\n}\n/**\n * ZRender need a canvas context to do measureText.\n * But in node environment canvas may be created by node-canvas.\n * So we need to specify how to create a canvas instead of using document.createElement('canvas')\n *\n * Be careful of using it in the browser.\n *\n * @example\n * let Canvas = require('canvas');\n * let echarts = require('echarts');\n * echarts.setCanvasCreator(function () {\n * // Small size is enough.\n * return new Canvas(32, 32);\n * });\n */\n\nexport function setCanvasCreator(creator) {\n zrUtil.$override('createCanvas', creator);\n}\n/**\n * The parameters and usage: see `mapDataStorage.registerMap`.\n * Compatible with previous `echarts.registerMap`.\n */\n\nexport function registerMap(mapName, geoJson, specialAreas) {\n mapDataStorage.registerMap(mapName, geoJson, specialAreas);\n}\nexport function getMap(mapName) {\n // For backward compatibility, only return the first one.\n var records = mapDataStorage.retrieveMap(mapName); // FIXME support SVG, where return not only records[0].\n\n return records && records[0] && {\n // @ts-ignore\n geoJson: records[0].geoJSON,\n specialAreas: records[0].specialAreas\n };\n}\nexport var registerTransform = registerExternalTransform;\n/**\n * Globa dispatchAction to a specified chart instance.\n */\n// export function dispatchAction(payload: { chartId: string } & Payload, opt?: Parameters[1]) {\n// if (!payload || !payload.chartId) {\n// // Must have chartId to find chart\n// return;\n// }\n// const chart = instances[payload.chartId];\n// if (chart) {\n// chart.dispatchAction(payload, opt);\n// }\n// }\n// Buitlin global visual\n\nregisterVisual(PRIORITY_VISUAL_GLOBAL, seriesStyleTask);\nregisterVisual(PRIORITY_VISUAL_CHART_DATA_CUSTOM, dataStyleTask);\nregisterVisual(PRIORITY_VISUAL_CHART_DATA_CUSTOM, dataColorPaletteTask);\nregisterVisual(PRIORITY_VISUAL_GLOBAL, seriesSymbolTask);\nregisterVisual(PRIORITY_VISUAL_CHART_DATA_CUSTOM, dataSymbolTask);\nregisterVisual(PRIORITY_VISUAL_DECAL, decal);\nregisterPreprocessor(backwardCompat);\nregisterProcessor(PRIORITY_PROCESSOR_DATASTACK, dataStack);\nregisterLoading('default', loadingDefault); // Default actions\n\nregisterAction({\n type: HIGHLIGHT_ACTION_TYPE,\n event: HIGHLIGHT_ACTION_TYPE,\n update: HIGHLIGHT_ACTION_TYPE\n}, zrUtil.noop);\nregisterAction({\n type: DOWNPLAY_ACTION_TYPE,\n event: DOWNPLAY_ACTION_TYPE,\n update: DOWNPLAY_ACTION_TYPE\n}, zrUtil.noop);\nregisterAction({\n type: SELECT_ACTION_TYPE,\n event: SELECT_ACTION_TYPE,\n update: SELECT_ACTION_TYPE\n}, zrUtil.noop);\nregisterAction({\n type: UNSELECT_ACTION_TYPE,\n event: UNSELECT_ACTION_TYPE,\n update: UNSELECT_ACTION_TYPE\n}, zrUtil.noop);\nregisterAction({\n type: TOGGLE_SELECT_ACTION_TYPE,\n event: TOGGLE_SELECT_ACTION_TYPE,\n update: TOGGLE_SELECT_ACTION_TYPE\n}, zrUtil.noop); // Default theme\n\nregisterTheme('light', lightTheme);\nregisterTheme('dark', darkTheme); // For backward compatibility, where the namespace `dataTool` will\n// be mounted on `echarts` is the extension `dataTool` is imported.\n\nexport var dataTool = {};","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { registerPreprocessor, registerProcessor, registerPostInit, registerPostUpdate, registerAction, registerCoordinateSystem, registerLayout, registerVisual, registerTransform, registerLoading, registerMap, PRIORITY } from './core/echarts';\nimport ComponentView from './view/Component';\nimport ChartView from './view/Chart';\nimport ComponentModel from './model/Component';\nimport SeriesModel from './model/Series';\nimport { isFunction, indexOf, isArray, each } from 'zrender/lib/core/util';\nimport { registerPainter } from 'zrender/lib/zrender';\nvar extensions = [];\nvar extensionRegisters = {\n registerPreprocessor: registerPreprocessor,\n registerProcessor: registerProcessor,\n registerPostInit: registerPostInit,\n registerPostUpdate: registerPostUpdate,\n registerAction: registerAction,\n registerCoordinateSystem: registerCoordinateSystem,\n registerLayout: registerLayout,\n registerVisual: registerVisual,\n registerTransform: registerTransform,\n registerLoading: registerLoading,\n registerMap: registerMap,\n PRIORITY: PRIORITY,\n ComponentModel: ComponentModel,\n ComponentView: ComponentView,\n SeriesModel: SeriesModel,\n ChartView: ChartView,\n // TODO Use ComponentModel and SeriesModel instead of Constructor\n registerComponentModel: function (ComponentModelClass) {\n ComponentModel.registerClass(ComponentModelClass);\n },\n registerComponentView: function (ComponentViewClass) {\n ComponentView.registerClass(ComponentViewClass);\n },\n registerSeriesModel: function (SeriesModelClass) {\n SeriesModel.registerClass(SeriesModelClass);\n },\n registerChartView: function (ChartViewClass) {\n ChartView.registerClass(ChartViewClass);\n },\n registerSubTypeDefaulter: function (componentType, defaulter) {\n ComponentModel.registerSubTypeDefaulter(componentType, defaulter);\n },\n registerPainter: function (painterType, PainterCtor) {\n registerPainter(painterType, PainterCtor);\n }\n};\nexport function use(ext) {\n if (isArray(ext)) {\n // use([ChartLine, ChartBar]);\n each(ext, function (singleExt) {\n use(singleExt);\n });\n return;\n }\n\n if (indexOf(extensions, ext) >= 0) {\n return;\n }\n\n extensions.push(ext);\n\n if (isFunction(ext)) {\n ext = {\n install: ext\n };\n }\n\n ext.install(extensionRegisters);\n}","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nfunction dataIndexMapValueLength(valNumOrArrLengthMoreThan2) {\n return valNumOrArrLengthMoreThan2 == null ? 0 : valNumOrArrLengthMoreThan2.length || 1;\n}\n\nfunction defaultKeyGetter(item) {\n return item;\n}\n\nvar DataDiffer =\n/** @class */\nfunction () {\n /**\n * @param context Can be visited by this.context in callback.\n */\n function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter, context, // By default: 'oneToOne'.\n diffMode) {\n this._old = oldArr;\n this._new = newArr;\n this._oldKeyGetter = oldKeyGetter || defaultKeyGetter;\n this._newKeyGetter = newKeyGetter || defaultKeyGetter; // Visible in callback via `this.context`;\n\n this.context = context;\n this._diffModeMultiple = diffMode === 'multiple';\n }\n /**\n * Callback function when add a data\n */\n\n\n DataDiffer.prototype.add = function (func) {\n this._add = func;\n return this;\n };\n /**\n * Callback function when update a data\n */\n\n\n DataDiffer.prototype.update = function (func) {\n this._update = func;\n return this;\n };\n /**\n * Callback function when update a data and only work in `cbMode: 'byKey'`.\n */\n\n\n DataDiffer.prototype.updateManyToOne = function (func) {\n this._updateManyToOne = func;\n return this;\n };\n /**\n * Callback function when update a data and only work in `cbMode: 'byKey'`.\n */\n\n\n DataDiffer.prototype.updateOneToMany = function (func) {\n this._updateOneToMany = func;\n return this;\n };\n /**\n * Callback function when remove a data\n */\n\n\n DataDiffer.prototype.remove = function (func) {\n this._remove = func;\n return this;\n };\n\n DataDiffer.prototype.execute = function () {\n this[this._diffModeMultiple ? '_executeMultiple' : '_executeOneToOne']();\n };\n\n DataDiffer.prototype._executeOneToOne = function () {\n var oldArr = this._old;\n var newArr = this._new;\n var newDataIndexMap = {};\n var oldDataKeyArr = new Array(oldArr.length);\n var newDataKeyArr = new Array(newArr.length);\n\n this._initIndexMap(oldArr, null, oldDataKeyArr, '_oldKeyGetter');\n\n this._initIndexMap(newArr, newDataIndexMap, newDataKeyArr, '_newKeyGetter');\n\n for (var i = 0; i < oldArr.length; i++) {\n var oldKey = oldDataKeyArr[i];\n var newIdxMapVal = newDataIndexMap[oldKey];\n var newIdxMapValLen = dataIndexMapValueLength(newIdxMapVal); // idx can never be empty array here. see 'set null' logic below.\n\n if (newIdxMapValLen > 1) {\n // Consider there is duplicate key (for example, use dataItem.name as key).\n // We should make sure every item in newArr and oldArr can be visited.\n var newIdx = newIdxMapVal.shift();\n\n if (newIdxMapVal.length === 1) {\n newDataIndexMap[oldKey] = newIdxMapVal[0];\n }\n\n this._update && this._update(newIdx, i);\n } else if (newIdxMapValLen === 1) {\n newDataIndexMap[oldKey] = null;\n this._update && this._update(newIdxMapVal, i);\n } else {\n this._remove && this._remove(i);\n }\n }\n\n this._performRestAdd(newDataKeyArr, newDataIndexMap);\n };\n /**\n * For example, consider the case:\n * oldData: [o0, o1, o2, o3, o4, o5, o6, o7],\n * newData: [n0, n1, n2, n3, n4, n5, n6, n7, n8],\n * Where:\n * o0, o1, n0 has key 'a' (many to one)\n * o5, n4, n5, n6 has key 'b' (one to many)\n * o2, n1 has key 'c' (one to one)\n * n2, n3 has key 'd' (add)\n * o3, o4 has key 'e' (remove)\n * o6, o7, n7, n8 has key 'f' (many to many, treated as add and remove)\n * Then:\n * (The order of the following directives are not ensured.)\n * this._updateManyToOne(n0, [o0, o1]);\n * this._updateOneToMany([n4, n5, n6], o5);\n * this._update(n1, o2);\n * this._remove(o3);\n * this._remove(o4);\n * this._remove(o6);\n * this._remove(o7);\n * this._add(n2);\n * this._add(n3);\n * this._add(n7);\n * this._add(n8);\n */\n\n\n DataDiffer.prototype._executeMultiple = function () {\n var oldArr = this._old;\n var newArr = this._new;\n var oldDataIndexMap = {};\n var newDataIndexMap = {};\n var oldDataKeyArr = [];\n var newDataKeyArr = [];\n\n this._initIndexMap(oldArr, oldDataIndexMap, oldDataKeyArr, '_oldKeyGetter');\n\n this._initIndexMap(newArr, newDataIndexMap, newDataKeyArr, '_newKeyGetter');\n\n for (var i = 0; i < oldDataKeyArr.length; i++) {\n var oldKey = oldDataKeyArr[i];\n var oldIdxMapVal = oldDataIndexMap[oldKey];\n var newIdxMapVal = newDataIndexMap[oldKey];\n var oldIdxMapValLen = dataIndexMapValueLength(oldIdxMapVal);\n var newIdxMapValLen = dataIndexMapValueLength(newIdxMapVal);\n\n if (oldIdxMapValLen > 1 && newIdxMapValLen === 1) {\n this._updateManyToOne && this._updateManyToOne(newIdxMapVal, oldIdxMapVal);\n newDataIndexMap[oldKey] = null;\n } else if (oldIdxMapValLen === 1 && newIdxMapValLen > 1) {\n this._updateOneToMany && this._updateOneToMany(newIdxMapVal, oldIdxMapVal);\n newDataIndexMap[oldKey] = null;\n } else if (oldIdxMapValLen === 1 && newIdxMapValLen === 1) {\n this._update && this._update(newIdxMapVal, oldIdxMapVal);\n newDataIndexMap[oldKey] = null;\n } else if (oldIdxMapValLen > 1) {\n for (var i_1 = 0; i_1 < oldIdxMapValLen; i_1++) {\n this._remove && this._remove(oldIdxMapVal[i_1]);\n }\n } else {\n this._remove && this._remove(oldIdxMapVal);\n }\n }\n\n this._performRestAdd(newDataKeyArr, newDataIndexMap);\n };\n\n DataDiffer.prototype._performRestAdd = function (newDataKeyArr, newDataIndexMap) {\n for (var i = 0; i < newDataKeyArr.length; i++) {\n var newKey = newDataKeyArr[i];\n var newIdxMapVal = newDataIndexMap[newKey];\n var idxMapValLen = dataIndexMapValueLength(newIdxMapVal);\n\n if (idxMapValLen > 1) {\n for (var j = 0; j < idxMapValLen; j++) {\n this._add && this._add(newIdxMapVal[j]);\n }\n } else if (idxMapValLen === 1) {\n this._add && this._add(newIdxMapVal);\n } // Support both `newDataKeyArr` are duplication removed or not removed.\n\n\n newDataIndexMap[newKey] = null;\n }\n };\n\n DataDiffer.prototype._initIndexMap = function (arr, // Can be null.\n map, // In 'byKey', the output `keyArr` is duplication removed.\n // In 'byIndex', the output `keyArr` is not duplication removed and\n // its indices are accurately corresponding to `arr`.\n keyArr, keyGetterName) {\n var cbModeMultiple = this._diffModeMultiple;\n\n for (var i = 0; i < arr.length; i++) {\n // Add prefix to avoid conflict with Object.prototype.\n var key = '_ec_' + this[keyGetterName](arr[i], i);\n\n if (!cbModeMultiple) {\n keyArr[i] = key;\n }\n\n if (!map) {\n continue;\n }\n\n var idxMapVal = map[key];\n var idxMapValLen = dataIndexMapValueLength(idxMapVal);\n\n if (idxMapValLen === 0) {\n // Simple optimize: in most cases, one index has one key,\n // do not need array.\n map[key] = i;\n\n if (cbModeMultiple) {\n keyArr.push(key);\n }\n } else if (idxMapValLen === 1) {\n map[key] = [idxMapVal, i];\n } else {\n idxMapVal.push(i);\n }\n }\n };\n\n return DataDiffer;\n}();\n\nexport default DataDiffer;","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { each, createHashMap, assert } from 'zrender/lib/core/util';\nimport { VISUAL_DIMENSIONS } from '../../util/types';\nexport function summarizeDimensions(data) {\n var summary = {};\n var encode = summary.encode = {};\n var notExtraCoordDimMap = createHashMap();\n var defaultedLabel = [];\n var defaultedTooltip = []; // See the comment of `List.js#userOutput`.\n\n var userOutput = summary.userOutput = {\n dimensionNames: data.dimensions.slice(),\n encode: {}\n };\n each(data.dimensions, function (dimName) {\n var dimItem = data.getDimensionInfo(dimName);\n var coordDim = dimItem.coordDim;\n\n if (coordDim) {\n if (process.env.NODE_ENV !== 'production') {\n assert(VISUAL_DIMENSIONS.get(coordDim) == null);\n }\n\n var coordDimIndex = dimItem.coordDimIndex;\n getOrCreateEncodeArr(encode, coordDim)[coordDimIndex] = dimName;\n\n if (!dimItem.isExtraCoord) {\n notExtraCoordDimMap.set(coordDim, 1); // Use the last coord dim (and label friendly) as default label,\n // because when dataset is used, it is hard to guess which dimension\n // can be value dimension. If both show x, y on label is not look good,\n // and conventionally y axis is focused more.\n\n if (mayLabelDimType(dimItem.type)) {\n defaultedLabel[0] = dimName;\n } // User output encode do not contain generated coords.\n // And it only has index. User can use index to retrieve value from the raw item array.\n\n\n getOrCreateEncodeArr(userOutput.encode, coordDim)[coordDimIndex] = dimItem.index;\n }\n\n if (dimItem.defaultTooltip) {\n defaultedTooltip.push(dimName);\n }\n }\n\n VISUAL_DIMENSIONS.each(function (v, otherDim) {\n var encodeArr = getOrCreateEncodeArr(encode, otherDim);\n var dimIndex = dimItem.otherDims[otherDim];\n\n if (dimIndex != null && dimIndex !== false) {\n encodeArr[dimIndex] = dimItem.name;\n }\n });\n });\n var dataDimsOnCoord = [];\n var encodeFirstDimNotExtra = {};\n notExtraCoordDimMap.each(function (v, coordDim) {\n var dimArr = encode[coordDim];\n encodeFirstDimNotExtra[coordDim] = dimArr[0]; // Not necessary to remove duplicate, because a data\n // dim canot on more than one coordDim.\n\n dataDimsOnCoord = dataDimsOnCoord.concat(dimArr);\n });\n summary.dataDimsOnCoord = dataDimsOnCoord;\n summary.encodeFirstDimNotExtra = encodeFirstDimNotExtra;\n var encodeLabel = encode.label; // FIXME `encode.label` is not recommanded, because formatter can not be set\n // in this way. Use label.formatter instead. May be remove this approach someday.\n\n if (encodeLabel && encodeLabel.length) {\n defaultedLabel = encodeLabel.slice();\n }\n\n var encodeTooltip = encode.tooltip;\n\n if (encodeTooltip && encodeTooltip.length) {\n defaultedTooltip = encodeTooltip.slice();\n } else if (!defaultedTooltip.length) {\n defaultedTooltip = defaultedLabel.slice();\n }\n\n encode.defaultedLabel = defaultedLabel;\n encode.defaultedTooltip = defaultedTooltip;\n return summary;\n}\n\nfunction getOrCreateEncodeArr(encode, dim) {\n if (!encode.hasOwnProperty(dim)) {\n encode[dim] = [];\n }\n\n return encode[dim];\n} // FIXME:TS should be type `AxisType`\n\n\nexport function getDimensionTypeByAxis(axisType) {\n return axisType === 'category' ? 'ordinal' : axisType === 'time' ? 'time' : 'float';\n}\n\nfunction mayLabelDimType(dimType) {\n // In most cases, ordinal and time do not suitable for label.\n // Ordinal info can be displayed on axis. Time is too long.\n return !(dimType === 'ordinal' || dimType === 'time');\n} // function findTheLastDimMayLabel(data) {\n// // Get last value dim\n// let dimensions = data.dimensions.slice();\n// let valueType;\n// let valueDim;\n// while (dimensions.length && (\n// valueDim = dimensions.pop(),\n// valueType = data.getDimensionInfo(valueDim).type,\n// valueType === 'ordinal' || valueType === 'time'\n// )) {} // jshint ignore:line\n// return valueDim;\n// }","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport * as zrUtil from 'zrender/lib/core/util';\n\nvar DataDimensionInfo =\n/** @class */\nfunction () {\n /**\n * @param opt All of the fields will be shallow copied.\n */\n function DataDimensionInfo(opt) {\n /**\n * The format of `otherDims` is:\n * ```js\n * {\n * tooltip: number optional,\n * label: number optional,\n * itemName: number optional,\n * seriesName: number optional,\n * }\n * ```\n *\n * A `series.encode` can specified these fields:\n * ```js\n * encode: {\n * // \"3, 1, 5\" is the index of data dimension.\n * tooltip: [3, 1, 5],\n * label: [0, 3],\n * ...\n * }\n * ```\n * `otherDims` is the parse result of the `series.encode` above, like:\n * ```js\n * // Suppose the index of this data dimension is `3`.\n * this.otherDims = {\n * // `3` is at the index `0` of the `encode.tooltip`\n * tooltip: 0,\n * // `3` is at the index `1` of the `encode.tooltip`\n * label: 1\n * };\n * ```\n *\n * This prop should never be `null`/`undefined` after initialized.\n */\n this.otherDims = {};\n\n if (opt != null) {\n zrUtil.extend(this, opt);\n }\n }\n\n return DataDimensionInfo;\n}();\n\n;\nexport default DataDimensionInfo;","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n/* global Float64Array, Int32Array, Uint32Array, Uint16Array */\n\n/**\n * List for data storage\n */\nimport * as zrUtil from 'zrender/lib/core/util';\nimport Model from '../model/Model';\nimport DataDiffer from './DataDiffer';\nimport { DefaultDataProvider } from './helper/dataProvider';\nimport { summarizeDimensions } from './helper/dimensionHelper';\nimport DataDimensionInfo from './DataDimensionInfo';\nimport { SOURCE_FORMAT_TYPED_ARRAY, SOURCE_FORMAT_ORIGINAL } from '../util/types';\nimport { isDataItemOption, convertOptionIdName } from '../util/model';\nimport { getECData } from '../util/innerStore';\nimport { parseDataValue } from './helper/dataValueHelper';\nimport { isSourceInstance } from './Source';\nvar mathFloor = Math.floor;\nvar isObject = zrUtil.isObject;\nvar map = zrUtil.map;\nvar UNDEFINED = 'undefined';\nvar INDEX_NOT_FOUND = -1; // Use prefix to avoid index to be the same as otherIdList[idx],\n// which will cause weird udpate animation.\n\nvar ID_PREFIX = 'e\\0\\0';\nvar dataCtors = {\n 'float': typeof Float64Array === UNDEFINED ? Array : Float64Array,\n 'int': typeof Int32Array === UNDEFINED ? Array : Int32Array,\n // Ordinal data type can be string or int\n 'ordinal': Array,\n 'number': Array,\n 'time': Array\n}; // Caution: MUST not use `new CtorUint32Array(arr, 0, len)`, because the Ctor of array is\n// different from the Ctor of typed array.\n\nvar CtorUint32Array = typeof Uint32Array === UNDEFINED ? Array : Uint32Array;\nvar CtorInt32Array = typeof Int32Array === UNDEFINED ? Array : Int32Array;\nvar CtorUint16Array = typeof Uint16Array === UNDEFINED ? Array : Uint16Array;\nvar TRANSFERABLE_PROPERTIES = ['hasItemOption', '_nameList', '_idList', '_invertedIndicesMap', '_rawData', '_dimValueGetter', '_count', '_rawCount', '_nameDimIdx', '_idDimIdx', '_nameRepeatCount'];\nvar CLONE_PROPERTIES = ['_extent', '_approximateExtent', '_rawExtent']; // -----------------------------\n// Internal method declarations:\n// -----------------------------\n\nvar defaultDimValueGetters;\nvar prepareInvertedIndex;\nvar getIndicesCtor;\nvar prepareStorage;\nvar getRawIndexWithoutIndices;\nvar getRawIndexWithIndices;\nvar getId;\nvar getIdNameFromStore;\nvar makeIdFromName;\nvar normalizeDimensions;\nvar validateDimensions;\nvar cloneListForMapAndSample;\nvar getInitialExtent;\nvar setItemDataAndSeriesIndex;\nvar transferProperties;\n\nvar List =\n/** @class */\nfunction () {\n /**\n * @param dimensions\n * For example, ['someDimName', {name: 'someDimName', type: 'someDimType'}, ...].\n * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius\n */\n function List(dimensions, hostModel) {\n this.type = 'list';\n this._count = 0;\n this._rawCount = 0;\n this._storage = {}; // We have an extra array store here. It's faster to be acessed than KV structured `_storage`.\n // We profile the code `storage[dim]` and it seems to be KeyedLoadIC_Megamorphic instead of fast property access.\n // Not sure why this happens. But using an extra array seems leads to faster `initData`\n // See https://github.com/apache/incubator-echarts/pull/13314 for more explanation.\n\n this._storageArr = [];\n this._nameList = [];\n this._idList = []; // Models of data option is stored sparse for optimizing memory cost\n // Never used yet (not used yet).\n // private _optionModels: Model[] = [];\n // Global visual properties after visual coding\n\n this._visual = {}; // Globel layout properties.\n\n this._layout = {}; // Item visual properties after visual coding\n\n this._itemVisuals = []; // Item layout properties after layout\n\n this._itemLayouts = []; // Graphic elemnents\n\n this._graphicEls = []; // Raw extent will not be cloned, but only transfered.\n // It will not be calculated util needed.\n\n this._rawExtent = {};\n this._extent = {}; // key: dim, value: extent\n\n this._approximateExtent = {};\n this._calculationInfo = {}; // Having detected that there is data item is non primitive type\n // (in type `OptionDataItemObject`).\n // Like `data: [ { value: xx, itemStyle: {...} }, ...]`\n // At present it only happen in `SOURCE_FORMAT_ORIGINAL`.\n\n this.hasItemOption = true; // Methods that create a new list based on this list should be listed here.\n // Notice that those method should `RETURN` the new list.\n\n this.TRANSFERABLE_METHODS = ['cloneShallow', 'downSample', 'lttbDownSample', 'map']; // Methods that change indices of this list should be listed here.\n\n this.CHANGABLE_METHODS = ['filterSelf', 'selectRange'];\n this.DOWNSAMPLE_METHODS = ['downSample', 'lttbDownSample'];\n /**\n * Get raw data index.\n * Do not initialize.\n * Default `getRawIndex`. And it can be changed.\n */\n\n this.getRawIndex = getRawIndexWithoutIndices;\n dimensions = dimensions || ['x', 'y'];\n var dimensionInfos = {};\n var dimensionNames = [];\n var invertedIndicesMap = {};\n\n for (var i = 0; i < dimensions.length; i++) {\n // Use the original dimensions[i], where other flag props may exists.\n var dimInfoInput = dimensions[i];\n var dimensionInfo = zrUtil.isString(dimInfoInput) ? new DataDimensionInfo({\n name: dimInfoInput\n }) : !(dimInfoInput instanceof DataDimensionInfo) ? new DataDimensionInfo(dimInfoInput) : dimInfoInput;\n var dimensionName = dimensionInfo.name;\n dimensionInfo.type = dimensionInfo.type || 'float';\n\n if (!dimensionInfo.coordDim) {\n dimensionInfo.coordDim = dimensionName;\n dimensionInfo.coordDimIndex = 0;\n }\n\n var otherDims = dimensionInfo.otherDims = dimensionInfo.otherDims || {};\n dimensionNames.push(dimensionName);\n dimensionInfos[dimensionName] = dimensionInfo;\n dimensionInfo.index = i;\n\n if (dimensionInfo.createInvertedIndices) {\n invertedIndicesMap[dimensionName] = [];\n }\n\n if (otherDims.itemName === 0) {\n this._nameDimIdx = i;\n this._nameOrdinalMeta = dimensionInfo.ordinalMeta;\n }\n\n if (otherDims.itemId === 0) {\n this._idDimIdx = i;\n this._idOrdinalMeta = dimensionInfo.ordinalMeta;\n }\n }\n\n this.dimensions = dimensionNames;\n this._dimensionInfos = dimensionInfos;\n this.hostModel = hostModel; // Cache summary info for fast visit. See \"dimensionHelper\".\n\n this._dimensionsSummary = summarizeDimensions(this);\n this._invertedIndicesMap = invertedIndicesMap;\n this.userOutput = this._dimensionsSummary.userOutput;\n }\n /**\n * The meanings of the input parameter `dim`:\n *\n * + If dim is a number (e.g., `1`), it means the index of the dimension.\n * For example, `getDimension(0)` will return 'x' or 'lng' or 'radius'.\n * + If dim is a number-like string (e.g., `\"1\"`):\n * + If there is the same concrete dim name defined in `this.dimensions`, it means that concrete name.\n * + If not, it will be converted to a number, which means the index of the dimension.\n * (why? because of the backward compatbility. We have been tolerating number-like string in\n * dimension setting, although now it seems that it is not a good idea.)\n * For example, `visualMap[i].dimension: \"1\"` is the same meaning as `visualMap[i].dimension: 1`,\n * if no dimension name is defined as `\"1\"`.\n * + If dim is a not-number-like string, it means the concrete dim name.\n * For example, it can be be default name `\"x\"`, `\"y\"`, `\"z\"`, `\"lng\"`, `\"lat\"`, `\"angle\"`, `\"radius\"`,\n * or customized in `dimensions` property of option like `\"age\"`.\n *\n * Get dimension name\n * @param dim See above.\n * @return Concrete dim name.\n */\n\n\n List.prototype.getDimension = function (dim) {\n if (typeof dim === 'number' // If being a number-like string but not being defined a dimension name.\n || !isNaN(dim) && !this._dimensionInfos.hasOwnProperty(dim)) {\n dim = this.dimensions[dim];\n }\n\n return dim;\n };\n /**\n * Get type and calculation info of particular dimension\n * @param dim\n * Dimension can be concrete names like x, y, z, lng, lat, angle, radius\n * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'\n */\n\n\n List.prototype.getDimensionInfo = function (dim) {\n // Do not clone, because there may be categories in dimInfo.\n return this._dimensionInfos[this.getDimension(dim)];\n };\n /**\n * concrete dimension name list on coord.\n */\n\n\n List.prototype.getDimensionsOnCoord = function () {\n return this._dimensionsSummary.dataDimsOnCoord.slice();\n };\n\n List.prototype.mapDimension = function (coordDim, idx) {\n var dimensionsSummary = this._dimensionsSummary;\n\n if (idx == null) {\n return dimensionsSummary.encodeFirstDimNotExtra[coordDim];\n }\n\n var dims = dimensionsSummary.encode[coordDim];\n return dims ? dims[idx] : null;\n };\n\n List.prototype.mapDimensionsAll = function (coordDim) {\n var dimensionsSummary = this._dimensionsSummary;\n var dims = dimensionsSummary.encode[coordDim];\n return (dims || []).slice();\n };\n /**\n * Initialize from data\n * @param data source or data or data provider.\n * @param nameList The name of a datum is used on data diff and\n * default label/tooltip.\n * A name can be specified in encode.itemName,\n * or dataItem.name (only for series option data),\n * or provided in nameList from outside.\n */\n\n\n List.prototype.initData = function (data, nameList, dimValueGetter) {\n var notProvider = isSourceInstance(data) || zrUtil.isArrayLike(data);\n var provider = notProvider ? new DefaultDataProvider(data, this.dimensions.length) : data;\n\n if (process.env.NODE_ENV !== 'production') {\n zrUtil.assert(notProvider || zrUtil.isFunction(provider.getItem) && zrUtil.isFunction(provider.count), 'Inavlid data provider.');\n }\n\n this._rawData = provider;\n var sourceFormat = provider.getSource().sourceFormat; // Clear\n\n this._storage = {};\n this._indices = null;\n this._dontMakeIdFromName = this._idDimIdx != null || sourceFormat === SOURCE_FORMAT_TYPED_ARRAY // Cosndier performance.\n || !!provider.fillStorage;\n this._nameList = (nameList || []).slice();\n this._idList = [];\n this._nameRepeatCount = {};\n\n if (!dimValueGetter) {\n this.hasItemOption = false;\n }\n\n this.defaultDimValueGetter = defaultDimValueGetters[sourceFormat]; // Default dim value getter\n\n this._dimValueGetter = dimValueGetter = dimValueGetter || this.defaultDimValueGetter;\n this._dimValueGetterArrayRows = defaultDimValueGetters.arrayRows; // Reset raw extent.\n\n this._rawExtent = {};\n\n this._initDataFromProvider(0, provider.count()); // If data has no item option.\n\n\n if (provider.pure) {\n this.hasItemOption = false;\n }\n };\n\n List.prototype.getProvider = function () {\n return this._rawData;\n };\n /**\n * Caution: Can be only called on raw data (before `this._indices` created).\n */\n\n\n List.prototype.appendData = function (data) {\n if (process.env.NODE_ENV !== 'production') {\n zrUtil.assert(!this._indices, 'appendData can only be called on raw data.');\n }\n\n var rawData = this._rawData;\n var start = this.count();\n rawData.appendData(data);\n var end = rawData.count();\n\n if (!rawData.persistent) {\n end += start;\n }\n\n this._initDataFromProvider(start, end, true);\n };\n /**\n * Caution: Can be only called on raw data (before `this._indices` created).\n * This method does not modify `rawData` (`dataProvider`), but only\n * add values to storage.\n *\n * The final count will be increased by `Math.max(values.length, names.length)`.\n *\n * @param values That is the SourceType: 'arrayRows', like\n * [\n * [12, 33, 44],\n * [NaN, 43, 1],\n * ['-', 'asdf', 0]\n * ]\n * Each item is exaclty cooresponding to a dimension.\n */\n\n\n List.prototype.appendValues = function (values, names) {\n var storage = this._storage;\n var dimensions = this.dimensions;\n var dimLen = dimensions.length;\n var rawExtent = this._rawExtent;\n var start = this.count();\n var end = start + Math.max(values.length, names ? names.length : 0);\n\n for (var i = 0; i < dimLen; i++) {\n var dim = dimensions[i];\n\n if (!rawExtent[dim]) {\n rawExtent[dim] = getInitialExtent();\n }\n\n prepareStorage(storage, this._dimensionInfos[dim], end, true);\n }\n\n var rawExtentArr = map(dimensions, function (dim) {\n return rawExtent[dim];\n });\n var storageArr = this._storageArr = map(dimensions, function (dim) {\n return storage[dim];\n });\n var emptyDataItem = [];\n\n for (var idx = start; idx < end; idx++) {\n var sourceIdx = idx - start; // Store the data by dimensions\n\n for (var dimIdx = 0; dimIdx < dimLen; dimIdx++) {\n var dim = dimensions[dimIdx];\n\n var val = this._dimValueGetterArrayRows(values[sourceIdx] || emptyDataItem, dim, sourceIdx, dimIdx);\n\n storageArr[dimIdx][idx] = val;\n var dimRawExtent = rawExtentArr[dimIdx];\n val < dimRawExtent[0] && (dimRawExtent[0] = val);\n val > dimRawExtent[1] && (dimRawExtent[1] = val);\n }\n\n if (names) {\n this._nameList[idx] = names[sourceIdx];\n\n if (!this._dontMakeIdFromName) {\n makeIdFromName(this, idx);\n }\n }\n }\n\n this._rawCount = this._count = end; // Reset data extent\n\n this._extent = {};\n prepareInvertedIndex(this);\n };\n\n List.prototype._initDataFromProvider = function (start, end, append) {\n if (start >= end) {\n return;\n }\n\n var rawData = this._rawData;\n var storage = this._storage;\n var dimensions = this.dimensions;\n var dimLen = dimensions.length;\n var dimensionInfoMap = this._dimensionInfos;\n var nameList = this._nameList;\n var idList = this._idList;\n var rawExtent = this._rawExtent;\n var sourceFormat = rawData.getSource().sourceFormat;\n var isFormatOriginal = sourceFormat === SOURCE_FORMAT_ORIGINAL;\n\n for (var i = 0; i < dimLen; i++) {\n var dim = dimensions[i];\n\n if (!rawExtent[dim]) {\n rawExtent[dim] = getInitialExtent();\n }\n\n prepareStorage(storage, dimensionInfoMap[dim], end, append);\n }\n\n var storageArr = this._storageArr = map(dimensions, function (dim) {\n return storage[dim];\n });\n var rawExtentArr = map(dimensions, function (dim) {\n return rawExtent[dim];\n });\n\n if (rawData.fillStorage) {\n rawData.fillStorage(start, end, storageArr, rawExtentArr);\n } else {\n var dataItem = [];\n\n for (var idx = start; idx < end; idx++) {\n // NOTICE: Try not to write things into dataItem\n dataItem = rawData.getItem(idx, dataItem); // Each data item is value\n // [1, 2]\n // 2\n // Bar chart, line chart which uses category axis\n // only gives the 'y' value. 'x' value is the indices of category\n // Use a tempValue to normalize the value to be a (x, y) value\n // Store the data by dimensions\n\n for (var dimIdx = 0; dimIdx < dimLen; dimIdx++) {\n var dim = dimensions[dimIdx];\n var dimStorage = storageArr[dimIdx]; // PENDING NULL is empty or zero\n\n var val = this._dimValueGetter(dataItem, dim, idx, dimIdx);\n\n dimStorage[idx] = val;\n var dimRawExtent = rawExtentArr[dimIdx];\n val < dimRawExtent[0] && (dimRawExtent[0] = val);\n val > dimRawExtent[1] && (dimRawExtent[1] = val);\n } // If dataItem is {name: ...} or {id: ...}, it has highest priority.\n // This kind of ids and names are always stored `_nameList` and `_idList`.\n\n\n if (isFormatOriginal && !rawData.pure && dataItem) {\n var itemName = dataItem.name;\n\n if (nameList[idx] == null && itemName != null) {\n nameList[idx] = convertOptionIdName(itemName, null);\n }\n\n var itemId = dataItem.id;\n\n if (idList[idx] == null && itemId != null) {\n idList[idx] = convertOptionIdName(itemId, null);\n }\n }\n\n if (!this._dontMakeIdFromName) {\n makeIdFromName(this, idx);\n }\n }\n }\n\n if (!rawData.persistent && rawData.clean) {\n // Clean unused data if data source is typed array.\n rawData.clean();\n }\n\n this._rawCount = this._count = end; // Reset data extent\n\n this._extent = {};\n prepareInvertedIndex(this);\n };\n\n List.prototype.count = function () {\n return this._count;\n };\n\n List.prototype.getIndices = function () {\n var newIndices;\n var indices = this._indices;\n\n if (indices) {\n var Ctor = indices.constructor;\n var thisCount = this._count; // `new Array(a, b, c)` is different from `new Uint32Array(a, b, c)`.\n\n if (Ctor === Array) {\n newIndices = new Ctor(thisCount);\n\n for (var i = 0; i < thisCount; i++) {\n newIndices[i] = indices[i];\n }\n } else {\n newIndices = new Ctor(indices.buffer, 0, thisCount);\n }\n } else {\n var Ctor = getIndicesCtor(this);\n newIndices = new Ctor(this.count());\n\n for (var i = 0; i < newIndices.length; i++) {\n newIndices[i] = i;\n }\n }\n\n return newIndices;\n }; // Get data by index of dimension.\n // Because in v8 access array by number variable is faster than access object by string variable\n // Not sure why but the optimization just works.\n\n\n List.prototype.getByDimIdx = function (dimIdx, idx) {\n if (!(idx >= 0 && idx < this._count)) {\n return NaN;\n }\n\n var dimStore = this._storageArr[dimIdx];\n return dimStore ? dimStore[this.getRawIndex(idx)] : NaN;\n };\n /**\n * Get value. Return NaN if idx is out of range.\n * @param dim Dim must be concrete name.\n */\n\n\n List.prototype.get = function (dim, idx) {\n if (!(idx >= 0 && idx < this._count)) {\n return NaN;\n }\n\n var dimStore = this._storage[dim];\n return dimStore ? dimStore[this.getRawIndex(idx)] : NaN;\n };\n /**\n * @param dim concrete dim\n */\n\n\n List.prototype.getByRawIndex = function (dim, rawIdx) {\n if (!(rawIdx >= 0 && rawIdx < this._rawCount)) {\n return NaN;\n }\n\n var dimStore = this._storage[dim];\n return dimStore ? dimStore[rawIdx] : NaN;\n };\n\n List.prototype.getValues = function (dimensions, idx) {\n var values = [];\n\n if (!zrUtil.isArray(dimensions)) {\n // stack = idx;\n idx = dimensions;\n dimensions = this.dimensions;\n }\n\n for (var i = 0, len = dimensions.length; i < len; i++) {\n values.push(this.get(dimensions[i], idx\n /*, stack */\n ));\n }\n\n return values;\n };\n /**\n * If value is NaN. Inlcuding '-'\n * Only check the coord dimensions.\n */\n\n\n List.prototype.hasValue = function (idx) {\n var dataDimsOnCoord = this._dimensionsSummary.dataDimsOnCoord;\n\n for (var i = 0, len = dataDimsOnCoord.length; i < len; i++) {\n // Ordinal type originally can be string or number.\n // But when an ordinal type is used on coord, it can\n // not be string but only number. So we can also use isNaN.\n if (isNaN(this.get(dataDimsOnCoord[i], idx))) {\n return false;\n }\n }\n\n return true;\n };\n /**\n * Get extent of data in one dimension\n */\n\n\n List.prototype.getDataExtent = function (dim) {\n // Make sure use concrete dim as cache name.\n dim = this.getDimension(dim);\n var dimData = this._storage[dim];\n var initialExtent = getInitialExtent(); // stack = !!((stack || false) && this.getCalculationInfo(dim));\n\n if (!dimData) {\n return initialExtent;\n } // Make more strict checkings to ensure hitting cache.\n\n\n var currEnd = this.count(); // let cacheName = [dim, !!stack].join('_');\n // let cacheName = dim;\n // Consider the most cases when using data zoom, `getDataExtent`\n // happened before filtering. We cache raw extent, which is not\n // necessary to be cleared and recalculated when restore data.\n\n var useRaw = !this._indices; // && !stack;\n\n var dimExtent;\n\n if (useRaw) {\n return this._rawExtent[dim].slice();\n }\n\n dimExtent = this._extent[dim];\n\n if (dimExtent) {\n return dimExtent.slice();\n }\n\n dimExtent = initialExtent;\n var min = dimExtent[0];\n var max = dimExtent[1];\n\n for (var i = 0; i < currEnd; i++) {\n var rawIdx = this.getRawIndex(i);\n var value = dimData[rawIdx];\n value < min && (min = value);\n value > max && (max = value);\n }\n\n dimExtent = [min, max];\n this._extent[dim] = dimExtent;\n return dimExtent;\n };\n /**\n * PENDING: In fact currently this function is only used to short-circuit\n * the calling of `scale.unionExtentFromData` when data have been filtered by modules\n * like \"dataZoom\". `scale.unionExtentFromData` is used to calculate data extent for series on\n * an axis, but if a \"axis related data filter module\" is used, the extent of the axis have\n * been fixed and no need to calling `scale.unionExtentFromData` actually.\n * But if we add \"custom data filter\" in future, which is not \"axis related\", this method may\n * be still needed.\n *\n * Optimize for the scenario that data is filtered by a given extent.\n * Consider that if data amount is more than hundreds of thousand,\n * extent calculation will cost more than 10ms and the cache will\n * be erased because of the filtering.\n */\n\n\n List.prototype.getApproximateExtent = function (dim) {\n dim = this.getDimension(dim);\n return this._approximateExtent[dim] || this.getDataExtent(dim);\n };\n /**\n * Calculate extent on a filtered data might be time consuming.\n * Approximate extent is only used for: calculte extent of filtered data outside.\n */\n\n\n List.prototype.setApproximateExtent = function (extent, dim) {\n dim = this.getDimension(dim);\n this._approximateExtent[dim] = extent.slice();\n };\n\n List.prototype.getCalculationInfo = function (key) {\n return this._calculationInfo[key];\n };\n\n List.prototype.setCalculationInfo = function (key, value) {\n isObject(key) ? zrUtil.extend(this._calculationInfo, key) : this._calculationInfo[key] = value;\n };\n /**\n * Get sum of data in one dimension\n */\n\n\n List.prototype.getSum = function (dim) {\n var dimData = this._storage[dim];\n var sum = 0;\n\n if (dimData) {\n for (var i = 0, len = this.count(); i < len; i++) {\n var value = this.get(dim, i);\n\n if (!isNaN(value)) {\n sum += value;\n }\n }\n }\n\n return sum;\n };\n /**\n * Get median of data in one dimension\n */\n\n\n List.prototype.getMedian = function (dim) {\n var dimDataArray = []; // map all data of one dimension\n\n this.each(dim, function (val) {\n if (!isNaN(val)) {\n dimDataArray.push(val);\n }\n }); // TODO\n // Use quick select?\n\n var sortedDimDataArray = dimDataArray.sort(function (a, b) {\n return a - b;\n });\n var len = this.count(); // calculate median\n\n return len === 0 ? 0 : len % 2 === 1 ? sortedDimDataArray[(len - 1) / 2] : (sortedDimDataArray[len / 2] + sortedDimDataArray[len / 2 - 1]) / 2;\n }; // /**\n // * Retreive the index with given value\n // * @param {string} dim Concrete dimension.\n // * @param {number} value\n // * @return {number}\n // */\n // Currently incorrect: should return dataIndex but not rawIndex.\n // Do not fix it until this method is to be used somewhere.\n // FIXME Precision of float value\n // indexOf(dim, value) {\n // let storage = this._storage;\n // let dimData = storage[dim];\n // let chunkSize = this._chunkSize;\n // if (dimData) {\n // for (let i = 0, len = this.count(); i < len; i++) {\n // let chunkIndex = mathFloor(i / chunkSize);\n // let chunkOffset = i % chunkSize;\n // if (dimData[chunkIndex][chunkOffset] === value) {\n // return i;\n // }\n // }\n // }\n // return -1;\n // }\n\n /**\n * Only support the dimension which inverted index created.\n * Do not support other cases until required.\n * @param dim concrete dim\n * @param value ordinal index\n * @return rawIndex\n */\n\n\n List.prototype.rawIndexOf = function (dim, value) {\n var invertedIndices = dim && this._invertedIndicesMap[dim];\n\n if (process.env.NODE_ENV !== 'production') {\n if (!invertedIndices) {\n throw new Error('Do not supported yet');\n }\n }\n\n var rawIndex = invertedIndices[value];\n\n if (rawIndex == null || isNaN(rawIndex)) {\n return INDEX_NOT_FOUND;\n }\n\n return rawIndex;\n };\n /**\n * Retreive the index with given name\n */\n\n\n List.prototype.indexOfName = function (name) {\n for (var i = 0, len = this.count(); i < len; i++) {\n if (this.getName(i) === name) {\n return i;\n }\n }\n\n return -1;\n };\n /**\n * Retreive the index with given raw data index\n */\n\n\n List.prototype.indexOfRawIndex = function (rawIndex) {\n if (rawIndex >= this._rawCount || rawIndex < 0) {\n return -1;\n }\n\n if (!this._indices) {\n return rawIndex;\n } // Indices are ascending\n\n\n var indices = this._indices; // If rawIndex === dataIndex\n\n var rawDataIndex = indices[rawIndex];\n\n if (rawDataIndex != null && rawDataIndex < this._count && rawDataIndex === rawIndex) {\n return rawIndex;\n }\n\n var left = 0;\n var right = this._count - 1;\n\n while (left <= right) {\n var mid = (left + right) / 2 | 0;\n\n if (indices[mid] < rawIndex) {\n left = mid + 1;\n } else if (indices[mid] > rawIndex) {\n right = mid - 1;\n } else {\n return mid;\n }\n }\n\n return -1;\n };\n /**\n * Retreive the index of nearest value\n * @param dim\n * @param value\n * @param [maxDistance=Infinity]\n * @return If and only if multiple indices has\n * the same value, they are put to the result.\n */\n\n\n List.prototype.indicesOfNearest = function (dim, value, maxDistance) {\n var storage = this._storage;\n var dimData = storage[dim];\n var nearestIndices = [];\n\n if (!dimData) {\n return nearestIndices;\n }\n\n if (maxDistance == null) {\n maxDistance = Infinity;\n }\n\n var minDist = Infinity;\n var minDiff = -1;\n var nearestIndicesLen = 0; // Check the test case of `test/ut/spec/data/List.js`.\n\n for (var i = 0, len = this.count(); i < len; i++) {\n var dataIndex = this.getRawIndex(i);\n var diff = value - dimData[dataIndex];\n var dist = Math.abs(diff);\n\n if (dist <= maxDistance) {\n // When the `value` is at the middle of `this.get(dim, i)` and `this.get(dim, i+1)`,\n // we'd better not push both of them to `nearestIndices`, otherwise it is easy to\n // get more than one item in `nearestIndices` (more specifically, in `tooltip`).\n // So we chose the one that `diff >= 0` in this csae.\n // But if `this.get(dim, i)` and `this.get(dim, j)` get the same value, both of them\n // should be push to `nearestIndices`.\n if (dist < minDist || dist === minDist && diff >= 0 && minDiff < 0) {\n minDist = dist;\n minDiff = diff;\n nearestIndicesLen = 0;\n }\n\n if (diff === minDiff) {\n nearestIndices[nearestIndicesLen++] = i;\n }\n }\n }\n\n nearestIndices.length = nearestIndicesLen;\n return nearestIndices;\n };\n /**\n * Get raw data item\n */\n\n\n List.prototype.getRawDataItem = function (idx) {\n if (!this._rawData.persistent) {\n var val = [];\n\n for (var i = 0; i < this.dimensions.length; i++) {\n var dim = this.dimensions[i];\n val.push(this.get(dim, idx));\n }\n\n return val;\n } else {\n return this._rawData.getItem(this.getRawIndex(idx));\n }\n };\n /**\n * @return Never be null/undefined. `number` will be converted to string. Becuase:\n * In most cases, name is used in display, where returning a string is more convenient.\n * In other cases, name is used in query (see `indexOfName`), where we can keep the\n * rule that name `2` equals to name `'2'`.\n */\n\n\n List.prototype.getName = function (idx) {\n var rawIndex = this.getRawIndex(idx);\n var name = this._nameList[rawIndex];\n\n if (name == null && this._nameDimIdx != null) {\n name = getIdNameFromStore(this, this._nameDimIdx, this._nameOrdinalMeta, rawIndex);\n }\n\n if (name == null) {\n name = '';\n }\n\n return name;\n };\n /**\n * @return Never null/undefined. `number` will be converted to string. Becuase:\n * In all cases having encountered at present, id is used in making diff comparison, which\n * are usually based on hash map. We can keep the rule that the internal id are always string\n * (treat `2` is the same as `'2'`) to make the related logic simple.\n */\n\n\n List.prototype.getId = function (idx) {\n return getId(this, this.getRawIndex(idx));\n };\n\n List.prototype.each = function (dims, cb, ctx, ctxCompat) {\n 'use strict';\n\n var _this = this;\n\n if (!this._count) {\n return;\n }\n\n if (typeof dims === 'function') {\n ctxCompat = ctx;\n ctx = cb;\n cb = dims;\n dims = [];\n } // ctxCompat just for compat echarts3\n\n\n var fCtx = ctx || ctxCompat || this;\n var dimNames = map(normalizeDimensions(dims), this.getDimension, this);\n\n if (process.env.NODE_ENV !== 'production') {\n validateDimensions(this, dimNames);\n }\n\n var dimSize = dimNames.length;\n var dimIndices = map(dimNames, function (dimName) {\n return _this._dimensionInfos[dimName].index;\n });\n var storageArr = this._storageArr;\n\n for (var i = 0, len = this.count(); i < len; i++) {\n var rawIdx = this.getRawIndex(i); // Simple optimization\n\n switch (dimSize) {\n case 0:\n cb.call(fCtx, i);\n break;\n\n case 1:\n cb.call(fCtx, storageArr[dimIndices[0]][rawIdx], i);\n break;\n\n case 2:\n cb.call(fCtx, storageArr[dimIndices[0]][rawIdx], storageArr[dimIndices[1]][rawIdx], i);\n break;\n\n default:\n var k = 0;\n var value = [];\n\n for (; k < dimSize; k++) {\n value[k] = storageArr[dimIndices[k]][rawIdx];\n } // Index\n\n\n value[k] = i;\n cb.apply(fCtx, value);\n }\n }\n };\n\n List.prototype.filterSelf = function (dims, cb, ctx, ctxCompat) {\n 'use strict';\n\n var _this = this;\n\n if (!this._count) {\n return;\n }\n\n if (typeof dims === 'function') {\n ctxCompat = ctx;\n ctx = cb;\n cb = dims;\n dims = [];\n } // ctxCompat just for compat echarts3\n\n\n var fCtx = ctx || ctxCompat || this;\n var dimNames = map(normalizeDimensions(dims), this.getDimension, this);\n\n if (process.env.NODE_ENV !== 'production') {\n validateDimensions(this, dimNames);\n }\n\n var count = this.count();\n var Ctor = getIndicesCtor(this);\n var newIndices = new Ctor(count);\n var value = [];\n var dimSize = dimNames.length;\n var offset = 0;\n var dimIndices = map(dimNames, function (dimName) {\n return _this._dimensionInfos[dimName].index;\n });\n var dim0 = dimIndices[0];\n var storageArr = this._storageArr;\n\n for (var i = 0; i < count; i++) {\n var keep = void 0;\n var rawIdx = this.getRawIndex(i); // Simple optimization\n\n if (dimSize === 0) {\n keep = cb.call(fCtx, i);\n } else if (dimSize === 1) {\n var val = storageArr[dim0][rawIdx];\n keep = cb.call(fCtx, val, i);\n } else {\n var k = 0;\n\n for (; k < dimSize; k++) {\n value[k] = storageArr[dimIndices[k]][rawIdx];\n }\n\n value[k] = i;\n keep = cb.apply(fCtx, value);\n }\n\n if (keep) {\n newIndices[offset++] = rawIdx;\n }\n } // Set indices after filtered.\n\n\n if (offset < count) {\n this._indices = newIndices;\n }\n\n this._count = offset; // Reset data extent\n\n this._extent = {};\n this.getRawIndex = this._indices ? getRawIndexWithIndices : getRawIndexWithoutIndices;\n return this;\n };\n /**\n * Select data in range. (For optimization of filter)\n * (Manually inline code, support 5 million data filtering in data zoom.)\n */\n\n\n List.prototype.selectRange = function (range) {\n 'use strict';\n\n var _this = this;\n\n var len = this._count;\n\n if (!len) {\n return;\n }\n\n var dimensions = [];\n\n for (var dim in range) {\n if (range.hasOwnProperty(dim)) {\n dimensions.push(dim);\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n validateDimensions(this, dimensions);\n }\n\n var dimSize = dimensions.length;\n\n if (!dimSize) {\n return;\n }\n\n var originalCount = this.count();\n var Ctor = getIndicesCtor(this);\n var newIndices = new Ctor(originalCount);\n var offset = 0;\n var dim0 = dimensions[0];\n var dimIndices = map(dimensions, function (dimName) {\n return _this._dimensionInfos[dimName].index;\n });\n var min = range[dim0][0];\n var max = range[dim0][1];\n var storageArr = this._storageArr;\n var quickFinished = false;\n\n if (!this._indices) {\n // Extreme optimization for common case. About 2x faster in chrome.\n var idx = 0;\n\n if (dimSize === 1) {\n var dimStorage = storageArr[dimIndices[0]];\n\n for (var i = 0; i < len; i++) {\n var val = dimStorage[i]; // NaN will not be filtered. Consider the case, in line chart, empty\n // value indicates the line should be broken. But for the case like\n // scatter plot, a data item with empty value will not be rendered,\n // but the axis extent may be effected if some other dim of the data\n // item has value. Fortunately it is not a significant negative effect.\n\n if (val >= min && val <= max || isNaN(val)) {\n newIndices[offset++] = idx;\n }\n\n idx++;\n }\n\n quickFinished = true;\n } else if (dimSize === 2) {\n var dimStorage = storageArr[dimIndices[0]];\n var dimStorage2 = storageArr[dimIndices[1]];\n var min2 = range[dimensions[1]][0];\n var max2 = range[dimensions[1]][1];\n\n for (var i = 0; i < len; i++) {\n var val = dimStorage[i];\n var val2 = dimStorage2[i]; // Do not filter NaN, see comment above.\n\n if ((val >= min && val <= max || isNaN(val)) && (val2 >= min2 && val2 <= max2 || isNaN(val2))) {\n newIndices[offset++] = idx;\n }\n\n idx++;\n }\n\n quickFinished = true;\n }\n }\n\n if (!quickFinished) {\n if (dimSize === 1) {\n for (var i = 0; i < originalCount; i++) {\n var rawIndex = this.getRawIndex(i);\n var val = storageArr[dimIndices[0]][rawIndex]; // Do not filter NaN, see comment above.\n\n if (val >= min && val <= max || isNaN(val)) {\n newIndices[offset++] = rawIndex;\n }\n }\n } else {\n for (var i = 0; i < originalCount; i++) {\n var keep = true;\n var rawIndex = this.getRawIndex(i);\n\n for (var k = 0; k < dimSize; k++) {\n var dimk = dimensions[k];\n var val = storageArr[dimIndices[k]][rawIndex]; // Do not filter NaN, see comment above.\n\n if (val < range[dimk][0] || val > range[dimk][1]) {\n keep = false;\n }\n }\n\n if (keep) {\n newIndices[offset++] = this.getRawIndex(i);\n }\n }\n }\n } // Set indices after filtered.\n\n\n if (offset < originalCount) {\n this._indices = newIndices;\n }\n\n this._count = offset; // Reset data extent\n\n this._extent = {};\n this.getRawIndex = this._indices ? getRawIndexWithIndices : getRawIndexWithoutIndices;\n return this;\n };\n /* eslint-enable */\n\n\n List.prototype.mapArray = function (dims, cb, ctx, ctxCompat) {\n 'use strict';\n\n if (typeof dims === 'function') {\n ctxCompat = ctx;\n ctx = cb;\n cb = dims;\n dims = [];\n } // ctxCompat just for compat echarts3\n\n\n ctx = ctx || ctxCompat || this;\n var result = [];\n this.each(dims, function () {\n result.push(cb && cb.apply(this, arguments));\n }, ctx);\n return result;\n };\n\n List.prototype.map = function (dims, cb, ctx, ctxCompat) {\n 'use strict'; // ctxCompat just for compat echarts3\n\n var fCtx = ctx || ctxCompat || this;\n var dimNames = map(normalizeDimensions(dims), this.getDimension, this);\n\n if (process.env.NODE_ENV !== 'production') {\n validateDimensions(this, dimNames);\n }\n\n var list = cloneListForMapAndSample(this, dimNames);\n var storage = list._storage; // Following properties are all immutable.\n // So we can reference to the same value\n\n list._indices = this._indices;\n list.getRawIndex = list._indices ? getRawIndexWithIndices : getRawIndexWithoutIndices;\n var tmpRetValue = [];\n var dimSize = dimNames.length;\n var dataCount = this.count();\n var values = [];\n var rawExtent = list._rawExtent;\n\n for (var dataIndex = 0; dataIndex < dataCount; dataIndex++) {\n for (var dimIndex = 0; dimIndex < dimSize; dimIndex++) {\n values[dimIndex] = this.get(dimNames[dimIndex], dataIndex);\n }\n\n values[dimSize] = dataIndex;\n var retValue = cb && cb.apply(fCtx, values);\n\n if (retValue != null) {\n // a number or string (in oridinal dimension)?\n if (typeof retValue !== 'object') {\n tmpRetValue[0] = retValue;\n retValue = tmpRetValue;\n }\n\n var rawIndex = this.getRawIndex(dataIndex);\n\n for (var i = 0; i < retValue.length; i++) {\n var dim = dimNames[i];\n var val = retValue[i];\n var rawExtentOnDim = rawExtent[dim];\n var dimStore = storage[dim];\n\n if (dimStore) {\n dimStore[rawIndex] = val;\n }\n\n if (val < rawExtentOnDim[0]) {\n rawExtentOnDim[0] = val;\n }\n\n if (val > rawExtentOnDim[1]) {\n rawExtentOnDim[1] = val;\n }\n }\n }\n }\n\n return list;\n };\n /**\n * Large data down sampling on given dimension\n * @param sampleIndex Sample index for name and id\n */\n\n\n List.prototype.downSample = function (dimension, rate, sampleValue, sampleIndex) {\n var list = cloneListForMapAndSample(this, [dimension]);\n var targetStorage = list._storage;\n var frameValues = [];\n var frameSize = mathFloor(1 / rate);\n var dimStore = targetStorage[dimension];\n var len = this.count();\n var rawExtentOnDim = list._rawExtent[dimension];\n var newIndices = new (getIndicesCtor(this))(len);\n var offset = 0;\n\n for (var i = 0; i < len; i += frameSize) {\n // Last frame\n if (frameSize > len - i) {\n frameSize = len - i;\n frameValues.length = frameSize;\n }\n\n for (var k = 0; k < frameSize; k++) {\n var dataIdx = this.getRawIndex(i + k);\n frameValues[k] = dimStore[dataIdx];\n }\n\n var value = sampleValue(frameValues);\n var sampleFrameIdx = this.getRawIndex(Math.min(i + sampleIndex(frameValues, value) || 0, len - 1)); // Only write value on the filtered data\n\n dimStore[sampleFrameIdx] = value;\n\n if (value < rawExtentOnDim[0]) {\n rawExtentOnDim[0] = value;\n }\n\n if (value > rawExtentOnDim[1]) {\n rawExtentOnDim[1] = value;\n }\n\n newIndices[offset++] = sampleFrameIdx;\n }\n\n list._count = offset;\n list._indices = newIndices;\n list.getRawIndex = getRawIndexWithIndices;\n return list;\n };\n /**\n * Large data down sampling using largest-triangle-three-buckets\n * @param {string} valueDimension\n * @param {number} targetCount\n */\n\n\n List.prototype.lttbDownSample = function (valueDimension, rate) {\n var list = cloneListForMapAndSample(this, []);\n var targetStorage = list._storage;\n var dimStore = targetStorage[valueDimension];\n var len = this.count();\n var newIndices = new (getIndicesCtor(this))(len);\n var sampledIndex = 0;\n var frameSize = mathFloor(1 / rate);\n var currentRawIndex = this.getRawIndex(0);\n var maxArea;\n var area;\n var nextRawIndex; // First frame use the first data.\n\n newIndices[sampledIndex++] = currentRawIndex;\n\n for (var i = 1; i < len - 1; i += frameSize) {\n var nextFrameStart = Math.min(i + frameSize, len - 1);\n var nextFrameEnd = Math.min(i + frameSize * 2, len);\n var avgX = (nextFrameEnd + nextFrameStart) / 2;\n var avgY = 0;\n\n for (var idx = nextFrameStart; idx < nextFrameEnd; idx++) {\n var rawIndex = this.getRawIndex(idx);\n var y = dimStore[rawIndex];\n\n if (isNaN(y)) {\n continue;\n }\n\n avgY += y;\n }\n\n avgY /= nextFrameEnd - nextFrameStart;\n var frameStart = i;\n var frameEnd = Math.min(i + frameSize, len);\n var pointAX = i - 1;\n var pointAY = dimStore[currentRawIndex];\n maxArea = -1;\n nextRawIndex = frameStart; // Find a point from current frame that construct a triangel with largest area with previous selected point\n // And the average of next frame.\n\n for (var idx = frameStart; idx < frameEnd; idx++) {\n var rawIndex = this.getRawIndex(idx);\n var y = dimStore[rawIndex];\n\n if (isNaN(y)) {\n continue;\n } // Calculate triangle area over three buckets\n\n\n area = Math.abs((pointAX - avgX) * (y - pointAY) - (pointAX - idx) * (avgY - pointAY));\n\n if (area > maxArea) {\n maxArea = area;\n nextRawIndex = rawIndex; // Next a is this b\n }\n }\n\n newIndices[sampledIndex++] = nextRawIndex;\n currentRawIndex = nextRawIndex; // This a is the next a (chosen b)\n } // First frame use the last data.\n\n\n newIndices[sampledIndex++] = this.getRawIndex(len - 1);\n list._count = sampledIndex;\n list._indices = newIndices;\n list.getRawIndex = getRawIndexWithIndices;\n return list;\n };\n /**\n * Get model of one data item.\n */\n // TODO: Type of data item\n\n\n List.prototype.getItemModel = function (idx) {\n var hostModel = this.hostModel;\n var dataItem = this.getRawDataItem(idx);\n return new Model(dataItem, hostModel, hostModel && hostModel.ecModel);\n };\n /**\n * Create a data differ\n */\n\n\n List.prototype.diff = function (otherList) {\n var thisList = this;\n return new DataDiffer(otherList ? otherList.getIndices() : [], this.getIndices(), function (idx) {\n return getId(otherList, idx);\n }, function (idx) {\n return getId(thisList, idx);\n });\n };\n /**\n * Get visual property.\n */\n\n\n List.prototype.getVisual = function (key) {\n var visual = this._visual;\n return visual && visual[key];\n };\n\n List.prototype.setVisual = function (kvObj, val) {\n this._visual = this._visual || {};\n\n if (isObject(kvObj)) {\n zrUtil.extend(this._visual, kvObj);\n } else {\n this._visual[kvObj] = val;\n }\n };\n /**\n * Get visual property of single data item\n */\n // eslint-disable-next-line\n\n\n List.prototype.getItemVisual = function (idx, key) {\n var itemVisual = this._itemVisuals[idx];\n var val = itemVisual && itemVisual[key];\n\n if (val == null) {\n // Use global visual property\n return this.getVisual(key);\n }\n\n return val;\n };\n /**\n * If exists visual property of single data item\n */\n\n\n List.prototype.hasItemVisual = function () {\n return this._itemVisuals.length > 0;\n };\n /**\n * Make sure itemVisual property is unique\n */\n // TODO: use key to save visual to reduce memory.\n\n\n List.prototype.ensureUniqueItemVisual = function (idx, key) {\n var itemVisuals = this._itemVisuals;\n var itemVisual = itemVisuals[idx];\n\n if (!itemVisual) {\n itemVisual = itemVisuals[idx] = {};\n }\n\n var val = itemVisual[key];\n\n if (val == null) {\n val = this.getVisual(key); // TODO Performance?\n\n if (zrUtil.isArray(val)) {\n val = val.slice();\n } else if (isObject(val)) {\n val = zrUtil.extend({}, val);\n }\n\n itemVisual[key] = val;\n }\n\n return val;\n }; // eslint-disable-next-line\n\n\n List.prototype.setItemVisual = function (idx, key, value) {\n var itemVisual = this._itemVisuals[idx] || {};\n this._itemVisuals[idx] = itemVisual;\n\n if (isObject(key)) {\n zrUtil.extend(itemVisual, key);\n } else {\n itemVisual[key] = value;\n }\n };\n /**\n * Clear itemVisuals and list visual.\n */\n\n\n List.prototype.clearAllVisual = function () {\n this._visual = {};\n this._itemVisuals = [];\n };\n\n List.prototype.setLayout = function (key, val) {\n if (isObject(key)) {\n for (var name_1 in key) {\n if (key.hasOwnProperty(name_1)) {\n this.setLayout(name_1, key[name_1]);\n }\n }\n\n return;\n }\n\n this._layout[key] = val;\n };\n /**\n * Get layout property.\n */\n\n\n List.prototype.getLayout = function (key) {\n return this._layout[key];\n };\n /**\n * Get layout of single data item\n */\n\n\n List.prototype.getItemLayout = function (idx) {\n return this._itemLayouts[idx];\n };\n /**\n * Set layout of single data item\n */\n\n\n List.prototype.setItemLayout = function (idx, layout, merge) {\n this._itemLayouts[idx] = merge ? zrUtil.extend(this._itemLayouts[idx] || {}, layout) : layout;\n };\n /**\n * Clear all layout of single data item\n */\n\n\n List.prototype.clearItemLayouts = function () {\n this._itemLayouts.length = 0;\n };\n /**\n * Set graphic element relative to data. It can be set as null\n */\n\n\n List.prototype.setItemGraphicEl = function (idx, el) {\n var hostModel = this.hostModel;\n\n if (el) {\n var ecData = getECData(el); // Add data index and series index for indexing the data by element\n // Useful in tooltip\n\n ecData.dataIndex = idx;\n ecData.dataType = this.dataType;\n ecData.seriesIndex = hostModel && hostModel.seriesIndex; // TODO: not store dataIndex on children.\n\n if (el.type === 'group') {\n el.traverse(setItemDataAndSeriesIndex, el);\n }\n }\n\n this._graphicEls[idx] = el;\n };\n\n List.prototype.getItemGraphicEl = function (idx) {\n return this._graphicEls[idx];\n };\n\n List.prototype.eachItemGraphicEl = function (cb, context) {\n zrUtil.each(this._graphicEls, function (el, idx) {\n if (el) {\n cb && cb.call(context, el, idx);\n }\n });\n };\n /**\n * Shallow clone a new list except visual and layout properties, and graph elements.\n * New list only change the indices.\n */\n\n\n List.prototype.cloneShallow = function (list) {\n if (!list) {\n var dimensionInfoList = map(this.dimensions, this.getDimensionInfo, this);\n list = new List(dimensionInfoList, this.hostModel);\n } // FIXME\n\n\n list._storage = this._storage;\n list._storageArr = this._storageArr;\n transferProperties(list, this); // Clone will not change the data extent and indices\n\n if (this._indices) {\n var Ctor = this._indices.constructor;\n\n if (Ctor === Array) {\n var thisCount = this._indices.length;\n list._indices = new Ctor(thisCount);\n\n for (var i = 0; i < thisCount; i++) {\n list._indices[i] = this._indices[i];\n }\n } else {\n list._indices = new Ctor(this._indices);\n }\n } else {\n list._indices = null;\n }\n\n list.getRawIndex = list._indices ? getRawIndexWithIndices : getRawIndexWithoutIndices;\n return list;\n };\n /**\n * Wrap some method to add more feature\n */\n\n\n List.prototype.wrapMethod = function (methodName, injectFunction) {\n var originalMethod = this[methodName];\n\n if (typeof originalMethod !== 'function') {\n return;\n }\n\n this.__wrappedMethods = this.__wrappedMethods || [];\n\n this.__wrappedMethods.push(methodName);\n\n this[methodName] = function () {\n var res = originalMethod.apply(this, arguments);\n return injectFunction.apply(this, [res].concat(zrUtil.slice(arguments)));\n };\n }; // ----------------------------------------------------------\n // A work around for internal method visiting private member.\n // ----------------------------------------------------------\n\n\n List.internalField = function () {\n defaultDimValueGetters = {\n arrayRows: getDimValueSimply,\n objectRows: function (dataItem, dimName, dataIndex, dimIndex) {\n return parseDataValue(dataItem[dimName], this._dimensionInfos[dimName]);\n },\n keyedColumns: getDimValueSimply,\n original: function (dataItem, dimName, dataIndex, dimIndex) {\n // Performance sensitive, do not use modelUtil.getDataItemValue.\n // If dataItem is an plain object with no value field, the let `value`\n // will be assigned with the object, but it will be tread correctly\n // in the `convertValue`.\n var value = dataItem && (dataItem.value == null ? dataItem : dataItem.value); // If any dataItem is like { value: 10 }\n\n if (!this._rawData.pure && isDataItemOption(dataItem)) {\n this.hasItemOption = true;\n }\n\n return parseDataValue(value instanceof Array ? value[dimIndex] // If value is a single number or something else not array.\n : value, this._dimensionInfos[dimName]);\n },\n typedArray: function (dataItem, dimName, dataIndex, dimIndex) {\n return dataItem[dimIndex];\n }\n };\n\n function getDimValueSimply(dataItem, dimName, dataIndex, dimIndex) {\n return parseDataValue(dataItem[dimIndex], this._dimensionInfos[dimName]);\n }\n\n prepareInvertedIndex = function (list) {\n var invertedIndicesMap = list._invertedIndicesMap;\n zrUtil.each(invertedIndicesMap, function (invertedIndices, dim) {\n var dimInfo = list._dimensionInfos[dim]; // Currently, only dimensions that has ordinalMeta can create inverted indices.\n\n var ordinalMeta = dimInfo.ordinalMeta;\n\n if (ordinalMeta) {\n invertedIndices = invertedIndicesMap[dim] = new CtorInt32Array(ordinalMeta.categories.length); // The default value of TypedArray is 0. To avoid miss\n // mapping to 0, we should set it as INDEX_NOT_FOUND.\n\n for (var i = 0; i < invertedIndices.length; i++) {\n invertedIndices[i] = INDEX_NOT_FOUND;\n }\n\n for (var i = 0; i < list._count; i++) {\n // Only support the case that all values are distinct.\n invertedIndices[list.get(dim, i)] = i;\n }\n }\n });\n };\n\n getIdNameFromStore = function (list, dimIdx, ordinalMeta, rawIndex) {\n var val;\n var chunk = list._storageArr[dimIdx];\n\n if (chunk) {\n val = chunk[rawIndex];\n\n if (ordinalMeta && ordinalMeta.categories.length) {\n val = ordinalMeta.categories[val];\n }\n }\n\n return convertOptionIdName(val, null);\n };\n\n getIndicesCtor = function (list) {\n // The possible max value in this._indicies is always this._rawCount despite of filtering.\n return list._rawCount > 65535 ? CtorUint32Array : CtorUint16Array;\n };\n\n prepareStorage = function (storage, dimInfo, end, append) {\n var DataCtor = dataCtors[dimInfo.type];\n var dim = dimInfo.name;\n\n if (append) {\n var oldStore = storage[dim];\n var oldLen = oldStore && oldStore.length;\n\n if (!(oldLen === end)) {\n var newStore = new DataCtor(end); // The cost of the copy is probably inconsiderable\n // within the initial chunkSize.\n\n for (var j = 0; j < oldLen; j++) {\n newStore[j] = oldStore[j];\n }\n\n storage[dim] = newStore;\n }\n } else {\n storage[dim] = new DataCtor(end);\n }\n };\n\n getRawIndexWithoutIndices = function (idx) {\n return idx;\n };\n\n getRawIndexWithIndices = function (idx) {\n if (idx < this._count && idx >= 0) {\n return this._indices[idx];\n }\n\n return -1;\n };\n /**\n * @see the comment of `List['getId']`.\n */\n\n\n getId = function (list, rawIndex) {\n var id = list._idList[rawIndex];\n\n if (id == null && list._idDimIdx != null) {\n id = getIdNameFromStore(list, list._idDimIdx, list._idOrdinalMeta, rawIndex);\n }\n\n if (id == null) {\n id = ID_PREFIX + rawIndex;\n }\n\n return id;\n };\n\n normalizeDimensions = function (dimensions) {\n if (!zrUtil.isArray(dimensions)) {\n dimensions = dimensions != null ? [dimensions] : [];\n }\n\n return dimensions;\n };\n\n validateDimensions = function (list, dims) {\n for (var i = 0; i < dims.length; i++) {\n // stroage may be empty when no data, so use\n // dimensionInfos to check.\n if (!list._dimensionInfos[dims[i]]) {\n console.error('Unkown dimension ' + dims[i]);\n }\n }\n }; // Data in excludeDimensions is copied, otherwise transfered.\n\n\n cloneListForMapAndSample = function (original, excludeDimensions) {\n var allDimensions = original.dimensions;\n var list = new List(map(allDimensions, original.getDimensionInfo, original), original.hostModel); // FIXME If needs stackedOn, value may already been stacked\n\n transferProperties(list, original);\n var storage = list._storage = {};\n var originalStorage = original._storage;\n var storageArr = list._storageArr = []; // Init storage\n\n for (var i = 0; i < allDimensions.length; i++) {\n var dim = allDimensions[i];\n\n if (originalStorage[dim]) {\n // Notice that we do not reset invertedIndicesMap here, becuase\n // there is no scenario of mapping or sampling ordinal dimension.\n if (zrUtil.indexOf(excludeDimensions, dim) >= 0) {\n storage[dim] = cloneChunk(originalStorage[dim]);\n list._rawExtent[dim] = getInitialExtent();\n list._extent[dim] = null;\n } else {\n // Direct reference for other dimensions\n storage[dim] = originalStorage[dim];\n }\n\n storageArr.push(storage[dim]);\n }\n }\n\n return list;\n };\n\n function cloneChunk(originalChunk) {\n var Ctor = originalChunk.constructor; // Only shallow clone is enough when Array.\n\n return Ctor === Array ? originalChunk.slice() : new Ctor(originalChunk);\n }\n\n getInitialExtent = function () {\n return [Infinity, -Infinity];\n };\n\n setItemDataAndSeriesIndex = function (child) {\n var childECData = getECData(child);\n var thisECData = getECData(this);\n childECData.seriesIndex = thisECData.seriesIndex;\n childECData.dataIndex = thisECData.dataIndex;\n childECData.dataType = thisECData.dataType;\n };\n\n transferProperties = function (target, source) {\n zrUtil.each(TRANSFERABLE_PROPERTIES.concat(source.__wrappedMethods || []), function (propName) {\n if (source.hasOwnProperty(propName)) {\n target[propName] = source[propName];\n }\n });\n target.__wrappedMethods = source.__wrappedMethods;\n zrUtil.each(CLONE_PROPERTIES, function (propName) {\n target[propName] = zrUtil.clone(source[propName]);\n });\n target._calculationInfo = zrUtil.extend({}, source._calculationInfo);\n };\n\n makeIdFromName = function (list, idx) {\n var nameList = list._nameList;\n var idList = list._idList;\n var nameDimIdx = list._nameDimIdx;\n var idDimIdx = list._idDimIdx;\n var name = nameList[idx];\n var id = idList[idx];\n\n if (name == null && nameDimIdx != null) {\n nameList[idx] = name = getIdNameFromStore(list, nameDimIdx, list._nameOrdinalMeta, idx);\n }\n\n if (id == null && idDimIdx != null) {\n idList[idx] = id = getIdNameFromStore(list, idDimIdx, list._idOrdinalMeta, idx);\n }\n\n if (id == null && name != null) {\n var nameRepeatCount = list._nameRepeatCount;\n var nmCnt = nameRepeatCount[name] = (nameRepeatCount[name] || 0) + 1;\n id = name;\n\n if (nmCnt > 1) {\n id += '__ec__' + nmCnt;\n }\n\n idList[idx] = id;\n }\n };\n }();\n\n return List;\n}();\n\nexport default List;","\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n/**\n * @deprecated\n * Use `echarts/data/helper/createDimensions` instead.\n */\nimport { createHashMap, each, isString, defaults, extend, isObject, clone } from 'zrender/lib/core/util';\nimport { normalizeToArray } from '../../util/model';\nimport { guessOrdinal, BE_ORDINAL } from './sourceHelper';\nimport { createSourceFromSeriesDataOption, isSourceInstance } from '../Source';\nimport { VISUAL_DIMENSIONS } from '../../util/types';\nimport DataDimensionInfo from '../DataDimensionInfo';\n/**\n * @see {module:echarts/test/ut/spec/data/completeDimensions}\n *\n * This method builds the relationship between:\n * + \"what the coord sys or series requires (see `sysDims`)\",\n * + \"what the user defines (in `encode` and `dimensions`, see `opt.dimsDef` and `opt.encodeDef`)\"\n * + \"what the data source provids (see `source`)\".\n *\n * Some guess strategy will be adapted if user does not define something.\n * If no 'value' dimension specified, the first no-named dimension will be\n * named as 'value'.\n *\n * @param {Array.} sysDims Necessary dimensions, like ['x', 'y'], which\n * provides not only dim template, but also default order.\n * properties: 'name', 'type', 'displayName'.\n * `name` of each item provides default coord name.\n * [{dimsDef: [string|Object, ...]}, ...] dimsDef of sysDim item provides default dim name, and\n * provide dims count that the sysDim required.\n * [{ordinalMeta}] can be specified.\n * @param {module:echarts/data/Source|Array|Object} source or data (for compatibal with pervious)\n * @param {Object} [opt]\n * @param {Array.