http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/f629d0f4/griffin-ui/bower_components/echarts/dist/echarts.js ---------------------------------------------------------------------- diff --git a/griffin-ui/bower_components/echarts/dist/echarts.js b/griffin-ui/bower_components/echarts/dist/echarts.js deleted file mode 100644 index 894d2b5..0000000 --- a/griffin-ui/bower_components/echarts/dist/echarts.js +++ /dev/null @@ -1,63245 +0,0 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else if(typeof exports === 'object') - exports["echarts"] = factory(); - else - root["echarts"] = factory(); -})(this, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; - -/******/ // The require function -/******/ function __webpack_require__(moduleId) { - -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; - -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false -/******/ }; - -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - -/******/ // Flag the module as loaded -/******/ module.loaded = true; - -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } - - -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; - -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; - -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; - -/******/ // Load entry module and return exports -/******/ return __webpack_require__(0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ function(module, exports, __webpack_require__) { - - /** - * Export echarts as CommonJS module - */ - module.exports = __webpack_require__(1); - - // Import all charts and components - __webpack_require__(99); - __webpack_require__(133); - __webpack_require__(138); - __webpack_require__(147); - __webpack_require__(151); - - __webpack_require__(161); - __webpack_require__(182); - __webpack_require__(194); - __webpack_require__(215); - __webpack_require__(219); - __webpack_require__(223); - __webpack_require__(238); - __webpack_require__(244); - __webpack_require__(251); - __webpack_require__(257); - __webpack_require__(261); - __webpack_require__(269); - - __webpack_require__(112); - __webpack_require__(273); - __webpack_require__(279); - __webpack_require__(283); - __webpack_require__(294); - __webpack_require__(224); - __webpack_require__(297); - __webpack_require__(303); - - __webpack_require__(315); - - __webpack_require__(316); - __webpack_require__(329); - - __webpack_require__(344); - __webpack_require__(350); - __webpack_require__(353); - - __webpack_require__(356); - __webpack_require__(365); - - __webpack_require__(378); - - -/***/ }, -/* 1 */ -/***/ function(module, exports, __webpack_require__) { - - // Enable DEV mode when using source code without build. which has no __DEV__ variable - // In build process 'typeof __DEV__' will be replace with 'boolean' - // So this code will be removed or disabled anyway after built. - if (false) { - // In browser - if (typeof window !== 'undefined') { - window.__DEV__ = true; - } - // In node - else if (typeof global !== 'undefined') { - global.__DEV__ = true; - } - } - - /*! - * ECharts, a javascript interactive chart library. - * - * Copyright (c) 2015, Baidu Inc. - * All rights reserved. - * - * LICENSE - * https://github.com/ecomfe/echarts/blob/master/LICENSE.txt - */ - - /** - * @module echarts - */ - - - var env = __webpack_require__(2); - - var GlobalModel = __webpack_require__(3); - var ExtensionAPI = __webpack_require__(25); - var CoordinateSystemManager = __webpack_require__(26); - var OptionManager = __webpack_require__(27); - - var ComponentModel = __webpack_require__(19); - var SeriesModel = __webpack_require__(28); - - var ComponentView = __webpack_require__(29); - var ChartView = __webpack_require__(42); - var graphic = __webpack_require__(43); - - var zrender = __webpack_require__(81); - var zrUtil = __webpack_require__(4); - var colorTool = __webpack_require__(39); - var Eventful = __webpack_require__(33); - var timsort = __webpack_require__(85); - - var each = zrUtil.each; - - var PRIORITY_PROCESSOR_FILTER = 1000; - var PRIORITY_PROCESSOR_STATISTIC = 5000; - - - var PRIORITY_VISUAL_LAYOUT = 1000; - var PRIORITY_VISUAL_GLOBAL = 2000; - var PRIORITY_VISUAL_CHART = 3000; - var PRIORITY_VISUAL_COMPONENT = 4000; - var PRIORITY_VISUAL_BRUSH = 5000; - - // Main process have three entries: `setOption`, `dispatchAction` and `resize`, - // where they must not be invoked nestedly, except the only case: invoke - // dispatchAction with updateMethod "none" in main process. - // This flag is used to carry out this rule. - // All events will be triggered out side main process (i.e. when !this[IN_MAIN_PROCESS]). - var IN_MAIN_PROCESS = '__flag_in_main_process'; - var HAS_GRADIENT_OR_PATTERN_BG = '_hasGradientOrPatternBg'; - - function createRegisterEventWithLowercaseName(method) { - return function (eventName, handler, context) { - // Event name is all lowercase - eventName = eventName && eventName.toLowerCase(); - Eventful.prototype[method].call(this, eventName, handler, context); - }; - } - /** - * @module echarts~MessageCenter - */ - function MessageCenter() { - Eventful.call(this); - } - MessageCenter.prototype.on = createRegisterEventWithLowercaseName('on'); - MessageCenter.prototype.off = createRegisterEventWithLowercaseName('off'); - MessageCenter.prototype.one = createRegisterEventWithLowercaseName('one'); - zrUtil.mixin(MessageCenter, Eventful); - /** - * @module echarts~ECharts - */ - function ECharts (dom, theme, opts) { - opts = opts || {}; - - // Get theme by name - if (typeof theme === 'string') { - theme = themeStorage[theme]; - } - - /** - * @type {string} - */ - this.id; - /** - * Group id - * @type {string} - */ - this.group; - /** - * @type {HTMLDomElement} - * @private - */ - this._dom = dom; - /** - * @type {module:zrender/ZRender} - * @private - */ - this._zr = zrender.init(dom, { - renderer: opts.renderer || 'canvas', - devicePixelRatio: opts.devicePixelRatio - }); - - /** - * @type {Object} - * @private - */ - this._theme = zrUtil.clone(theme); - - /** - * @type {Array.<module:echarts/view/Chart>} - * @private - */ - this._chartsViews = []; - - /** - * @type {Object.<string, module:echarts/view/Chart>} - * @private - */ - this._chartsMap = {}; - - /** - * @type {Array.<module:echarts/view/Component>} - * @private - */ - this._componentsViews = []; - - /** - * @type {Object.<string, module:echarts/view/Component>} - * @private - */ - this._componentsMap = {}; - - /** - * @type {module:echarts/ExtensionAPI} - * @private - */ - this._api = new ExtensionAPI(this); - - /** - * @type {module:echarts/CoordinateSystem} - * @private - */ - this._coordSysMgr = new CoordinateSystemManager(); - - Eventful.call(this); - - /** - * @type {module:echarts~MessageCenter} - * @private - */ - this._messageCenter = new MessageCenter(); - - // Init mouse events - this._initEvents(); - - // In case some people write `window.onresize = chart.resize` - this.resize = zrUtil.bind(this.resize, this); - - // Can't dispatch action during rendering procedure - this._pendingActions = []; - // Sort on demand - function prioritySortFunc(a, b) { - return a.prio - b.prio; - } - timsort(visualFuncs, prioritySortFunc); - timsort(dataProcessorFuncs, prioritySortFunc); - } - - var echartsProto = ECharts.prototype; - - /** - * @return {HTMLDomElement} - */ - echartsProto.getDom = function () { - return this._dom; - }; - - /** - * @return {module:zrender~ZRender} - */ - echartsProto.getZr = function () { - return this._zr; - }; - - /** - * @param {Object} option - * @param {boolean} notMerge - * @param {boolean} [notRefreshImmediately=false] Useful when setOption frequently. - */ - echartsProto.setOption = function (option, notMerge, notRefreshImmediately) { - if (true) { - zrUtil.assert(!this[IN_MAIN_PROCESS], '`setOption` should not be called during main process.'); - } - - this[IN_MAIN_PROCESS] = true; - - if (!this._model || notMerge) { - var optionManager = new OptionManager(this._api); - var theme = this._theme; - var ecModel = this._model = new GlobalModel(null, null, theme, optionManager); - ecModel.init(null, null, theme, optionManager); - } - - this._model.setOption(option, optionPreprocessorFuncs); - - updateMethods.prepareAndUpdate.call(this); - - this[IN_MAIN_PROCESS] = false; - - this._flushPendingActions(); - - !notRefreshImmediately && this._zr.refreshImmediately(); - }; - - /** - * @DEPRECATED - */ - echartsProto.setTheme = function () { - console.log('ECharts#setTheme() is DEPRECATED in ECharts 3.0'); - }; - - /** - * @return {module:echarts/model/Global} - */ - echartsProto.getModel = function () { - return this._model; - }; - - /** - * @return {Object} - */ - echartsProto.getOption = function () { - return this._model.getOption(); - }; - - /** - * @return {number} - */ - echartsProto.getWidth = function () { - return this._zr.getWidth(); - }; - - /** - * @return {number} - */ - echartsProto.getHeight = function () { - return this._zr.getHeight(); - }; - - /** - * Get canvas which has all thing rendered - * @param {Object} opts - * @param {string} [opts.backgroundColor] - */ - echartsProto.getRenderedCanvas = function (opts) { - if (!env.canvasSupported) { - return; - } - opts = opts || {}; - opts.pixelRatio = opts.pixelRatio || 1; - opts.backgroundColor = opts.backgroundColor - || this._model.get('backgroundColor'); - var zr = this._zr; - var list = zr.storage.getDisplayList(); - // Stop animations - zrUtil.each(list, function (el) { - el.stopAnimation(true); - }); - return zr.painter.getRenderedCanvas(opts); - }; - /** - * @return {string} - * @param {Object} opts - * @param {string} [opts.type='png'] - * @param {string} [opts.pixelRatio=1] - * @param {string} [opts.backgroundColor] - */ - echartsProto.getDataURL = function (opts) { - opts = opts || {}; - var excludeComponents = opts.excludeComponents; - var ecModel = this._model; - var excludesComponentViews = []; - var self = this; - - each(excludeComponents, function (componentType) { - ecModel.eachComponent({ - mainType: componentType - }, function (component) { - var view = self._componentsMap[component.__viewId]; - if (!view.group.ignore) { - excludesComponentViews.push(view); - view.group.ignore = true; - } - }); - }); - - var url = this.getRenderedCanvas(opts).toDataURL( - 'image/' + (opts && opts.type || 'png') - ); - - each(excludesComponentViews, function (view) { - view.group.ignore = false; - }); - return url; - }; - - - /** - * @return {string} - * @param {Object} opts - * @param {string} [opts.type='png'] - * @param {string} [opts.pixelRatio=1] - * @param {string} [opts.backgroundColor] - */ - echartsProto.getConnectedDataURL = function (opts) { - if (!env.canvasSupported) { - return; - } - var groupId = this.group; - var mathMin = Math.min; - var mathMax = Math.max; - var MAX_NUMBER = Infinity; - if (connectedGroups[groupId]) { - var left = MAX_NUMBER; - var top = MAX_NUMBER; - var right = -MAX_NUMBER; - var bottom = -MAX_NUMBER; - var canvasList = []; - var dpr = (opts && opts.pixelRatio) || 1; - for (var id in instances) { - var chart = instances[id]; - if (chart.group === groupId) { - var canvas = chart.getRenderedCanvas( - zrUtil.clone(opts) - ); - var boundingRect = chart.getDom().getBoundingClientRect(); - left = mathMin(boundingRect.left, left); - top = mathMin(boundingRect.top, top); - right = mathMax(boundingRect.right, right); - bottom = mathMax(boundingRect.bottom, bottom); - canvasList.push({ - dom: canvas, - left: boundingRect.left, - top: boundingRect.top - }); - } - } - - left *= dpr; - top *= dpr; - right *= dpr; - bottom *= dpr; - var width = right - left; - var height = bottom - top; - var targetCanvas = zrUtil.createCanvas(); - targetCanvas.width = width; - targetCanvas.height = height; - var zr = zrender.init(targetCanvas); - - each(canvasList, function (item) { - var img = new graphic.Image({ - style: { - x: item.left * dpr - left, - y: item.top * dpr - top, - image: item.dom - } - }); - zr.add(img); - }); - zr.refreshImmediately(); - - return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png')); - } - else { - return this.getDataURL(opts); - } - }; - - var updateMethods = { - - - /** - * @param {Object} payload - * @private - */ - update: function (payload) { - // console.time && console.time('update'); - - var ecModel = this._model; - var api = this._api; - var coordSysMgr = this._coordSysMgr; - var zr = this._zr; - // update before setOption - if (!ecModel) { - return; - } - - // Fixme First time update ? - ecModel.restoreData(); - - // TODO - // Save total ecModel here for undo/redo (after restoring data and before processing data). - // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call. - - // Create new coordinate system each update - // In LineView may save the old coordinate system and use it to get the orignal point - coordSysMgr.create(this._model, this._api); - - processData.call(this, ecModel, api); - - stackSeriesData.call(this, ecModel); - - coordSysMgr.update(ecModel, api); - - doVisualEncoding.call(this, ecModel, payload); - - doRender.call(this, ecModel, payload); - - // Set background - var backgroundColor = ecModel.get('backgroundColor') || 'transparent'; - - var painter = zr.painter; - // TODO all use clearColor ? - if (painter.isSingleCanvas && painter.isSingleCanvas()) { - zr.configLayer(0, { - clearColor: backgroundColor - }); - } - else { - // In IE8 - if (!env.canvasSupported) { - var colorArr = colorTool.parse(backgroundColor); - backgroundColor = colorTool.stringify(colorArr, 'rgb'); - if (colorArr[3] === 0) { - backgroundColor = 'transparent'; - } - } - if (backgroundColor.colorStops || backgroundColor.image) { - // Gradient background - // FIXME Fixed layerï¼ - zr.configLayer(0, { - clearColor: backgroundColor - }); - this[HAS_GRADIENT_OR_PATTERN_BG] = true; - - this._dom.style.background = 'transparent'; - } - else { - if (this[HAS_GRADIENT_OR_PATTERN_BG]) { - zr.configLayer(0, { - clearColor: null - }); - } - this[HAS_GRADIENT_OR_PATTERN_BG] = false; - - this._dom.style.background = backgroundColor; - } - } - - // console.time && console.timeEnd('update'); - }, - - // PENDING - /** - * @param {Object} payload - * @private - */ - updateView: function (payload) { - var ecModel = this._model; - - // update before setOption - if (!ecModel) { - return; - } - - ecModel.eachSeries(function (seriesModel) { - seriesModel.getData().clearAllVisual(); - }); - - doVisualEncoding.call(this, ecModel, payload); - - invokeUpdateMethod.call(this, 'updateView', ecModel, payload); - }, - - /** - * @param {Object} payload - * @private - */ - updateVisual: function (payload) { - var ecModel = this._model; - - // update before setOption - if (!ecModel) { - return; - } - - ecModel.eachSeries(function (seriesModel) { - seriesModel.getData().clearAllVisual(); - }); - - doVisualEncoding.call(this, ecModel, payload); - - invokeUpdateMethod.call(this, 'updateVisual', ecModel, payload); - }, - - /** - * @param {Object} payload - * @private - */ - updateLayout: function (payload) { - var ecModel = this._model; - - // update before setOption - if (!ecModel) { - return; - } - - doLayout.call(this, ecModel, payload); - - invokeUpdateMethod.call(this, 'updateLayout', ecModel, payload); - }, - - /** - * @param {Object} payload - * @private - */ - highlight: function (payload) { - toggleHighlight.call(this, 'highlight', payload); - }, - - /** - * @param {Object} payload - * @private - */ - downplay: function (payload) { - toggleHighlight.call(this, 'downplay', payload); - }, - - /** - * @param {Object} payload - * @private - */ - prepareAndUpdate: function (payload) { - var ecModel = this._model; - - prepareView.call(this, 'component', ecModel); - - prepareView.call(this, 'chart', ecModel); - - updateMethods.update.call(this, payload); - } - }; - - /** - * @param {Object} payload - * @private - */ - function toggleHighlight(method, payload) { - var ecModel = this._model; - - // dispatchAction before setOption - if (!ecModel) { - return; - } - - ecModel.eachComponent( - {mainType: 'series', query: payload}, - function (seriesModel, index) { - var chartView = this._chartsMap[seriesModel.__viewId]; - if (chartView && chartView.__alive) { - chartView[method]( - seriesModel, ecModel, this._api, payload - ); - } - }, - this - ); - } - - /** - * Resize the chart - */ - echartsProto.resize = function () { - if (true) { - zrUtil.assert(!this[IN_MAIN_PROCESS], '`resize` should not be called during main process.'); - } - - this[IN_MAIN_PROCESS] = true; - - this._zr.resize(); - - var optionChanged = this._model && this._model.resetOption('media'); - updateMethods[optionChanged ? 'prepareAndUpdate' : 'update'].call(this); - - // Resize loading effect - this._loadingFX && this._loadingFX.resize(); - - this[IN_MAIN_PROCESS] = false; - - this._flushPendingActions(); - }; - - var defaultLoadingEffect = __webpack_require__(93); - /** - * Show loading effect - * @param {string} [name='default'] - * @param {Object} [cfg] - */ - echartsProto.showLoading = function (name, cfg) { - if (zrUtil.isObject(name)) { - cfg = name; - name = 'default'; - } - this.hideLoading(); - var el = defaultLoadingEffect(this._api, cfg); - var zr = this._zr; - this._loadingFX = el; - - zr.add(el); - }; - - /** - * Hide loading effect - */ - echartsProto.hideLoading = function () { - this._loadingFX && this._zr.remove(this._loadingFX); - this._loadingFX = null; - }; - - /** - * @param {Object} eventObj - * @return {Object} - */ - echartsProto.makeActionFromEvent = function (eventObj) { - var payload = zrUtil.extend({}, eventObj); - payload.type = eventActionMap[eventObj.type]; - return payload; - }; - - /** - * @pubilc - * @param {Object} payload - * @param {string} [payload.type] Action type - * @param {boolean} [silent=false] Whether trigger event. - */ - echartsProto.dispatchAction = function (payload, silent) { - var actionWrap = actions[payload.type]; - if (!actionWrap) { - return; - } - - var actionInfo = actionWrap.actionInfo; - var updateMethod = actionInfo.update || 'update'; - - // if (__DEV__) { - // zrUtil.assert( - // !this[IN_MAIN_PROCESS], - // '`dispatchAction` should not be called during main process.' - // + 'unless updateMathod is "none".' - // ); - // } - - // May dispatchAction in rendering procedure - if (this[IN_MAIN_PROCESS]) { - this._pendingActions.push(payload); - return; - } - - this[IN_MAIN_PROCESS] = true; - - var payloads = [payload]; - var batched = false; - // Batch action - if (payload.batch) { - batched = true; - payloads = zrUtil.map(payload.batch, function (item) { - item = zrUtil.defaults(zrUtil.extend({}, item), payload); - item.batch = null; - return item; - }); - } - - var eventObjBatch = []; - var eventObj; - var isHighlightOrDownplay = payload.type === 'highlight' || payload.type === 'downplay'; - for (var i = 0; i < payloads.length; i++) { - var batchItem = payloads[i]; - // Action can specify the event by return it. - eventObj = actionWrap.action(batchItem, this._model); - // Emit event outside - eventObj = eventObj || zrUtil.extend({}, batchItem); - // Convert type to eventType - eventObj.type = actionInfo.event || eventObj.type; - eventObjBatch.push(eventObj); - - // Highlight and downplay are special. - isHighlightOrDownplay && updateMethods[updateMethod].call(this, batchItem); - } - - (updateMethod !== 'none' && !isHighlightOrDownplay) - && updateMethods[updateMethod].call(this, payload); - - // Follow the rule of action batch - if (batched) { - eventObj = { - type: actionInfo.event || payload.type, - batch: eventObjBatch - }; - } - else { - eventObj = eventObjBatch[0]; - } - - this[IN_MAIN_PROCESS] = false; - - !silent && this._messageCenter.trigger(eventObj.type, eventObj); - - this._flushPendingActions(); - - }; - - echartsProto._flushPendingActions = function () { - var pendingActions = this._pendingActions; - while (pendingActions.length) { - var payload = pendingActions.shift(); - this.dispatchAction(payload); - } - }; - - /** - * Register event - * @method - */ - echartsProto.on = createRegisterEventWithLowercaseName('on'); - echartsProto.off = createRegisterEventWithLowercaseName('off'); - echartsProto.one = createRegisterEventWithLowercaseName('one'); - - /** - * @param {string} methodName - * @private - */ - function invokeUpdateMethod(methodName, ecModel, payload) { - var api = this._api; - - // Update all components - each(this._componentsViews, function (component) { - var componentModel = component.__model; - component[methodName](componentModel, ecModel, api, payload); - - updateZ(componentModel, component); - }, this); - - // Upate all charts - ecModel.eachSeries(function (seriesModel, idx) { - var chart = this._chartsMap[seriesModel.__viewId]; - chart[methodName](seriesModel, ecModel, api, payload); - - updateZ(seriesModel, chart); - - updateProgressiveAndBlend(seriesModel, chart); - }, this); - - // If use hover layer - updateHoverLayerStatus(this._zr, ecModel); - } - - /** - * Prepare view instances of charts and components - * @param {module:echarts/model/Global} ecModel - * @private - */ - function prepareView(type, ecModel) { - var isComponent = type === 'component'; - var viewList = isComponent ? this._componentsViews : this._chartsViews; - var viewMap = isComponent ? this._componentsMap : this._chartsMap; - var zr = this._zr; - - for (var i = 0; i < viewList.length; i++) { - viewList[i].__alive = false; - } - - ecModel[isComponent ? 'eachComponent' : 'eachSeries'](function (componentType, model) { - if (isComponent) { - if (componentType === 'series') { - return; - } - } - else { - model = componentType; - } - - // Consider: id same and type changed. - var viewId = model.id + '_' + model.type; - var view = viewMap[viewId]; - if (!view) { - var classType = ComponentModel.parseClassType(model.type); - var Clazz = isComponent - ? ComponentView.getClass(classType.main, classType.sub) - : ChartView.getClass(classType.sub); - if (Clazz) { - view = new Clazz(); - view.init(ecModel, this._api); - viewMap[viewId] = view; - viewList.push(view); - zr.add(view.group); - } - else { - // Error - return; - } - } - - model.__viewId = viewId; - view.__alive = true; - view.__id = viewId; - view.__model = model; - }, this); - - for (var i = 0; i < viewList.length;) { - var view = viewList[i]; - if (!view.__alive) { - zr.remove(view.group); - view.dispose(ecModel, this._api); - viewList.splice(i, 1); - delete viewMap[view.__id]; - } - else { - i++; - } - } - } - - /** - * Processor data in each series - * - * @param {module:echarts/model/Global} ecModel - * @private - */ - function processData(ecModel, api) { - each(dataProcessorFuncs, function (process) { - process.func(ecModel, api); - }); - } - - /** - * @private - */ - function stackSeriesData(ecModel) { - var stackedDataMap = {}; - ecModel.eachSeries(function (series) { - var stack = series.get('stack'); - var data = series.getData(); - if (stack && data.type === 'list') { - var previousStack = stackedDataMap[stack]; - if (previousStack) { - data.stackedOn = previousStack; - } - stackedDataMap[stack] = data; - } - }); - } - - /** - * Layout before each chart render there series, special visual encoding stage - * - * @param {module:echarts/model/Global} ecModel - * @private - */ - function doLayout(ecModel, payload) { - var api = this._api; - each(visualFuncs, function (visual) { - if (visual.isLayout) { - visual.func(ecModel, api, payload); - } - }); - } - - /** - * Encode visual infomation from data after data processing - * - * @param {module:echarts/model/Global} ecModel - * @private - */ - function doVisualEncoding(ecModel, payload) { - var api = this._api; - ecModel.clearColorPalette(); - ecModel.eachSeries(function (seriesModel) { - seriesModel.clearColorPalette(); - }); - each(visualFuncs, function (visual) { - visual.func(ecModel, api, payload); - }); - } - - /** - * Render each chart and component - * @private - */ - function doRender(ecModel, payload) { - var api = this._api; - // Render all components - each(this._componentsViews, function (componentView) { - var componentModel = componentView.__model; - componentView.render(componentModel, ecModel, api, payload); - - updateZ(componentModel, componentView); - }, this); - - each(this._chartsViews, function (chart) { - chart.__alive = false; - }, this); - - // Render all charts - ecModel.eachSeries(function (seriesModel, idx) { - var chartView = this._chartsMap[seriesModel.__viewId]; - chartView.__alive = true; - chartView.render(seriesModel, ecModel, api, payload); - - chartView.group.silent = !!seriesModel.get('silent'); - - updateZ(seriesModel, chartView); - - updateProgressiveAndBlend(seriesModel, chartView); - - }, this); - - // If use hover layer - updateHoverLayerStatus(this._zr, ecModel); - - // Remove groups of unrendered charts - each(this._chartsViews, function (chart) { - if (!chart.__alive) { - chart.remove(ecModel, api); - } - }, this); - } - - var MOUSE_EVENT_NAMES = [ - 'click', 'dblclick', 'mouseover', 'mouseout', 'mousedown', 'mouseup', 'globalout' - ]; - /** - * @private - */ - echartsProto._initEvents = function () { - each(MOUSE_EVENT_NAMES, function (eveName) { - this._zr.on(eveName, function (e) { - var ecModel = this.getModel(); - var el = e.target; - if (el && el.dataIndex != null) { - var dataModel = el.dataModel || ecModel.getSeriesByIndex(el.seriesIndex); - var params = dataModel && dataModel.getDataParams(el.dataIndex, el.dataType) || {}; - params.event = e; - params.type = eveName; - this.trigger(eveName, params); - } - // If element has custom eventData of components - else if (el && el.eventData) { - this.trigger(eveName, el.eventData); - } - }, this); - }, this); - - each(eventActionMap, function (actionType, eventType) { - this._messageCenter.on(eventType, function (event) { - this.trigger(eventType, event); - }, this); - }, this); - }; - - /** - * @return {boolean} - */ - echartsProto.isDisposed = function () { - return this._disposed; - }; - - /** - * Clear - */ - echartsProto.clear = function () { - this.setOption({}, true); - }; - /** - * Dispose instance - */ - echartsProto.dispose = function () { - if (this._disposed) { - if (true) { - console.warn('Instance ' + this.id + ' has been disposed'); - } - return; - } - this._disposed = true; - - var api = this._api; - var ecModel = this._model; - - each(this._componentsViews, function (component) { - component.dispose(ecModel, api); - }); - each(this._chartsViews, function (chart) { - chart.dispose(ecModel, api); - }); - - // Dispose after all views disposed - this._zr.dispose(); - - delete instances[this.id]; - }; - - zrUtil.mixin(ECharts, Eventful); - - function updateHoverLayerStatus(zr, ecModel) { - var storage = zr.storage; - var elCount = 0; - storage.traverse(function (el) { - if (!el.isGroup) { - elCount++; - } - }); - if (elCount > ecModel.get('hoverLayerThreshold') && !env.node) { - storage.traverse(function (el) { - if (!el.isGroup) { - el.useHoverLayer = true; - } - }); - } - } - /** - * Update chart progressive and blend. - * @param {module:echarts/model/Series|module:echarts/model/Component} model - * @param {module:echarts/view/Component|module:echarts/view/Chart} view - */ - function updateProgressiveAndBlend(seriesModel, chartView) { - // Progressive configuration - var elCount = 0; - chartView.group.traverse(function (el) { - if (el.type !== 'group' && !el.ignore) { - elCount++; - } - }); - var frameDrawNum = +seriesModel.get('progressive'); - var needProgressive = elCount > seriesModel.get('progressiveThreshold') && frameDrawNum && !env.node; - if (needProgressive) { - chartView.group.traverse(function (el) { - // FIXME marker and other components - if (!el.isGroup) { - el.progressive = needProgressive ? - Math.floor(elCount++ / frameDrawNum) : -1; - if (needProgressive) { - el.stopAnimation(true); - } - } - }); - } - - // Blend configration - var blendMode = seriesModel.get('blendMode') || null; - if (true) { - if (!env.canvasSupported && blendMode && blendMode !== 'source-over') { - console.warn('Only canvas support blendMode'); - } - } - chartView.group.traverse(function (el) { - // FIXME marker and other components - if (!el.isGroup) { - el.setStyle('blend', blendMode); - } - }); - } - /** - * @param {module:echarts/model/Series|module:echarts/model/Component} model - * @param {module:echarts/view/Component|module:echarts/view/Chart} view - */ - function updateZ(model, view) { - var z = model.get('z'); - var zlevel = model.get('zlevel'); - // Set z and zlevel - view.group.traverse(function (el) { - if (el.type !== 'group') { - z != null && (el.z = z); - zlevel != null && (el.zlevel = zlevel); - } - }); - } - /** - * @type {Array.<Function>} - * @inner - */ - var actions = []; - - /** - * Map eventType to actionType - * @type {Object} - */ - var eventActionMap = {}; - - /** - * Data processor functions of each stage - * @type {Array.<Object.<string, Function>>} - * @inner - */ - var dataProcessorFuncs = []; - - /** - * @type {Array.<Function>} - * @inner - */ - var optionPreprocessorFuncs = []; - - /** - * Visual encoding functions of each stage - * @type {Array.<Object.<string, Function>>} - * @inner - */ - var visualFuncs = []; - /** - * Theme storage - * @type {Object.<key, Object>} - */ - var themeStorage = {}; - - - var instances = {}; - var connectedGroups = {}; - - var idBase = new Date() - 0; - var groupIdBase = new Date() - 0; - var DOM_ATTRIBUTE_KEY = '_echarts_instance_'; - /** - * @alias module:echarts - */ - var echarts = { - /** - * @type {number} - */ - version: '3.2.2', - dependencies: { - zrender: '3.1.2' - } - }; - - function enableConnect(chart) { - - var STATUS_PENDING = 0; - var STATUS_UPDATING = 1; - var STATUS_UPDATED = 2; - var STATUS_KEY = '__connectUpdateStatus'; - function updateConnectedChartsStatus(charts, status) { - for (var i = 0; i < charts.length; i++) { - var otherChart = charts[i]; - otherChart[STATUS_KEY] = status; - } - } - zrUtil.each(eventActionMap, function (actionType, eventType) { - chart._messageCenter.on(eventType, function (event) { - if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) { - var action = chart.makeActionFromEvent(event); - var otherCharts = []; - for (var id in instances) { - var otherChart = instances[id]; - if (otherChart !== chart && otherChart.group === chart.group) { - otherCharts.push(otherChart); - } - } - updateConnectedChartsStatus(otherCharts, STATUS_PENDING); - each(otherCharts, function (otherChart) { - if (otherChart[STATUS_KEY] !== STATUS_UPDATING) { - otherChart.dispatchAction(action); - } - }); - updateConnectedChartsStatus(otherCharts, STATUS_UPDATED); - } - }); - }); - - } - /** - * @param {HTMLDomElement} dom - * @param {Object} [theme] - * @param {Object} opts - */ - echarts.init = function (dom, theme, opts) { - if (true) { - // Check version - if ((zrender.version.replace('.', '') - 0) < (echarts.dependencies.zrender.replace('.', '') - 0)) { - throw new Error( - 'ZRender ' + zrender.version - + ' is too old for ECharts ' + echarts.version - + '. Current version need ZRender ' - + echarts.dependencies.zrender + '+' - ); - } - if (!dom) { - throw new Error('Initialize failed: invalid dom.'); - } - if (zrUtil.isDom(dom) && dom.nodeName.toUpperCase() !== 'CANVAS' && (!dom.clientWidth || !dom.clientHeight)) { - console.warn('Can\'t get dom width or height'); - } - } - - var chart = new ECharts(dom, theme, opts); - chart.id = 'ec_' + idBase++; - instances[chart.id] = chart; - - dom.setAttribute && - dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id); - - enableConnect(chart); - - return chart; - }; - - /** - * @return {string|Array.<module:echarts~ECharts>} groupId - */ - echarts.connect = function (groupId) { - // Is array of charts - if (zrUtil.isArray(groupId)) { - var charts = groupId; - groupId = null; - // If any chart has group - zrUtil.each(charts, function (chart) { - if (chart.group != null) { - groupId = chart.group; - } - }); - groupId = groupId || ('g_' + groupIdBase++); - zrUtil.each(charts, function (chart) { - chart.group = groupId; - }); - } - connectedGroups[groupId] = true; - return groupId; - }; - - /** - * @return {string} groupId - */ - echarts.disConnect = function (groupId) { - connectedGroups[groupId] = false; - }; - - /** - * Dispose a chart instance - * @param {module:echarts~ECharts|HTMLDomElement|string} chart - */ - echarts.dispose = function (chart) { - if (zrUtil.isDom(chart)) { - chart = echarts.getInstanceByDom(chart); - } - else if (typeof chart === 'string') { - chart = instances[chart]; - } - if ((chart instanceof ECharts) && !chart.isDisposed()) { - chart.dispose(); - } - }; - - /** - * @param {HTMLDomElement} dom - * @return {echarts~ECharts} - */ - echarts.getInstanceByDom = function (dom) { - var key = dom.getAttribute(DOM_ATTRIBUTE_KEY); - return instances[key]; - }; - /** - * @param {string} key - * @return {echarts~ECharts} - */ - echarts.getInstanceById = function (key) { - return instances[key]; - }; - - /** - * Register theme - */ - echarts.registerTheme = function (name, theme) { - themeStorage[name] = theme; - }; - - /** - * Register option preprocessor - * @param {Function} preprocessorFunc - */ - echarts.registerPreprocessor = function (preprocessorFunc) { - optionPreprocessorFuncs.push(preprocessorFunc); - }; - - /** - * @param {number} [priority=1000] - * @param {Function} processorFunc - */ - echarts.registerProcessor = function (priority, processorFunc) { - if (typeof priority === 'function') { - processorFunc = priority; - priority = PRIORITY_PROCESSOR_FILTER; - } - if (true) { - if (isNaN(priority)) { - throw new Error('Unkown processor priority'); - } - } - dataProcessorFuncs.push({ - prio: priority, - func: processorFunc - }); - }; - - /** - * Usage: - * registerAction('someAction', 'someEvent', function () { ... }); - * registerAction('someAction', function () { ... }); - * registerAction( - * {type: 'someAction', event: 'someEvent', update: 'updateView'}, - * function () { ... } - * ); - * - * @param {(string|Object)} actionInfo - * @param {string} actionInfo.type - * @param {string} [actionInfo.event] - * @param {string} [actionInfo.update] - * @param {string} [eventName] - * @param {Function} action - */ - echarts.registerAction = function (actionInfo, eventName, action) { - if (typeof eventName === 'function') { - action = eventName; - eventName = ''; - } - var actionType = zrUtil.isObject(actionInfo) - ? actionInfo.type - : ([actionInfo, actionInfo = { - event: eventName - }][0]); - - // Event name is all lowercase - actionInfo.event = (actionInfo.event || actionType).toLowerCase(); - eventName = actionInfo.event; - - if (!actions[actionType]) { - actions[actionType] = {action: action, actionInfo: actionInfo}; - } - eventActionMap[eventName] = actionType; - }; - - /** - * @param {string} type - * @param {*} CoordinateSystem - */ - echarts.registerCoordinateSystem = function (type, CoordinateSystem) { - CoordinateSystemManager.register(type, CoordinateSystem); - }; - - /** - * Layout is a special stage of visual encoding - * Most visual encoding like color are common for different chart - * But each chart has it's own layout algorithm - * - * @param {string} [priority=1000] - * @param {Function} layoutFunc - */ - echarts.registerLayout = function (priority, layoutFunc) { - if (typeof priority === 'function') { - layoutFunc = priority; - priority = PRIORITY_VISUAL_LAYOUT; - } - if (true) { - if (isNaN(priority)) { - throw new Error('Unkown layout priority'); - } - } - visualFuncs.push({ - prio: priority, - func: layoutFunc, - isLayout: true - }); - }; - - /** - * @param {string} [priority=3000] - * @param {Function} visualFunc - */ - echarts.registerVisual = function (priority, visualFunc) { - if (typeof priority === 'function') { - visualFunc = priority; - priority = PRIORITY_VISUAL_CHART; - } - if (true) { - if (isNaN(priority)) { - throw new Error('Unkown visual priority'); - } - } - visualFuncs.push({ - prio: priority, - func: visualFunc - }); - }; - - var parseClassType = ComponentModel.parseClassType; - /** - * @param {Object} opts - * @param {string} [superClass] - */ - echarts.extendComponentModel = function (opts, superClass) { - var Clazz = ComponentModel; - if (superClass) { - var classType = parseClassType(superClass); - Clazz = ComponentModel.getClass(classType.main, classType.sub, true); - } - return Clazz.extend(opts); - }; - - /** - * @param {Object} opts - * @param {string} [superClass] - */ - echarts.extendComponentView = function (opts, superClass) { - var Clazz = ComponentView; - if (superClass) { - var classType = parseClassType(superClass); - Clazz = ComponentView.getClass(classType.main, classType.sub, true); - } - return Clazz.extend(opts); - }; - - /** - * @param {Object} opts - * @param {string} [superClass] - */ - echarts.extendSeriesModel = function (opts, superClass) { - var Clazz = SeriesModel; - if (superClass) { - superClass = 'series.' + superClass.replace('series.', ''); - var classType = parseClassType(superClass); - Clazz = SeriesModel.getClass(classType.main, classType.sub, true); - } - return Clazz.extend(opts); - }; - - /** - * @param {Object} opts - * @param {string} [superClass] - */ - echarts.extendChartView = function (opts, superClass) { - var Clazz = ChartView; - if (superClass) { - superClass.replace('series.', ''); - var classType = parseClassType(superClass); - Clazz = ChartView.getClass(classType.main, true); - } - return ChartView.extend(opts); - }; - - /** - * ZRender need a canvas context to do measureText. - * But in node environment canvas may be created by node-canvas. - * So we need to specify how to create a canvas instead of using document.createElement('canvas') - * - * Be careful of using it in the browser. - * - * @param {Function} creator - * @example - * var Canvas = require('canvas'); - * var echarts = require('echarts'); - * echarts.setCanvasCreator(function () { - * // Small size is enough. - * return new Canvas(32, 32); - * }); - */ - echarts.setCanvasCreator = function (creator) { - zrUtil.createCanvas = creator; - }; - - echarts.registerVisual(PRIORITY_VISUAL_GLOBAL, __webpack_require__(94)); - echarts.registerPreprocessor(__webpack_require__(95)); - - // Default action - echarts.registerAction({ - type: 'highlight', - event: 'highlight', - update: 'highlight' - }, zrUtil.noop); - echarts.registerAction({ - type: 'downplay', - event: 'downplay', - update: 'downplay' - }, zrUtil.noop); - - - // -------- - // Exports - // -------- - // - echarts.List = __webpack_require__(97); - echarts.Model = __webpack_require__(12); - - echarts.graphic = __webpack_require__(43); - echarts.number = __webpack_require__(7); - echarts.format = __webpack_require__(6); - echarts.matrix = __webpack_require__(11); - echarts.vector = __webpack_require__(10); - echarts.color = __webpack_require__(39); - - echarts.util = {}; - each([ - 'map', 'each', 'filter', 'indexOf', 'inherits', - 'reduce', 'filter', 'bind', 'curry', 'isArray', - 'isString', 'isObject', 'isFunction', 'extend', 'defaults' - ], - function (name) { - echarts.util[name] = zrUtil[name]; - } - ); - - // PRIORITY - echarts.PRIORITY = { - PROCESSOR: { - FILTER: PRIORITY_PROCESSOR_FILTER, - STATISTIC: PRIORITY_PROCESSOR_STATISTIC - }, - VISUAL: { - LAYOUT: PRIORITY_VISUAL_LAYOUT, - GLOBAL: PRIORITY_VISUAL_GLOBAL, - CHART: PRIORITY_VISUAL_CHART, - COMPONENT: PRIORITY_VISUAL_COMPONENT, - BRUSH: PRIORITY_VISUAL_BRUSH - } - }; - - module.exports = echarts; - - -/***/ }, -/* 2 */ -/***/ function(module, exports) { - - /** - * echarts设å¤ç¯å¢è¯å« - * - * @desc echartsåºäºCanvasï¼çº¯Javascriptå¾è¡¨åºï¼æä¾ç´è§ï¼çå¨ï¼å¯äº¤äºï¼å¯ä¸ªæ§åå®å¶çæ°æ®ç»è®¡å¾è¡¨ã - * @author firede[[email protected]] - * @desc thanks zepto. - */ - - var env = {}; - if (typeof navigator === 'undefined') { - // In node - env = { - browser: {}, - os: {}, - node: true, - // Assume canvas is supported - canvasSupported: true - }; - } - else { - env = detect(navigator.userAgent); - } - - module.exports = env; - - // Zepto.js - // (c) 2010-2013 Thomas Fuchs - // Zepto.js may be freely distributed under the MIT license. - - function detect(ua) { - var os = {}; - var browser = {}; - // var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/); - // var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); - // var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); - // var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); - // var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/); - // var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/); - // var touchpad = webos && ua.match(/TouchPad/); - // var kindle = ua.match(/Kindle\/([\d.]+)/); - // var silk = ua.match(/Silk\/([\d._]+)/); - // var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/); - // var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/); - // var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/); - // var playbook = ua.match(/PlayBook/); - // var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/); - var firefox = ua.match(/Firefox\/([\d.]+)/); - // var safari = webkit && ua.match(/Mobile\//) && !chrome; - // var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome; - var ie = ua.match(/MSIE\s([\d.]+)/) - // IE 11 Trident/7.0; rv:11.0 - || ua.match(/Trident\/.+?rv:(([\d.]+))/); - var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+ - - // Todo: clean this up with a better OS/browser seperation: - // - discern (more) between multiple browsers on android - // - decide if kindle fire in silk mode is android or not - // - Firefox on Android doesn't specify the Android version - // - possibly devide in os, device and browser hashes - - // if (browser.webkit = !!webkit) browser.version = webkit[1]; - - // if (android) os.android = true, os.version = android[2]; - // if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.'); - // if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.'); - // if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null; - // if (webos) os.webos = true, os.version = webos[2]; - // if (touchpad) os.touchpad = true; - // if (blackberry) os.blackberry = true, os.version = blackberry[2]; - // if (bb10) os.bb10 = true, os.version = bb10[2]; - // if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2]; - // if (playbook) browser.playbook = true; - // if (kindle) os.kindle = true, os.version = kindle[1]; - // if (silk) browser.silk = true, browser.version = silk[1]; - // if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true; - // if (chrome) browser.chrome = true, browser.version = chrome[1]; - if (firefox) browser.firefox = true, browser.version = firefox[1]; - // if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true; - // if (webview) browser.webview = true; - if (ie) { - browser.ie = true; browser.version = ie[1]; - } - if (ie) { - browser.ie = true; - browser.version = ie[1]; - } - if (edge) { - browser.edge = true; - browser.version = edge[1]; - } - - // os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) || - // (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/))); - // os.phone = !!(!os.tablet && !os.ipod && (android || iphone || webos || - // (chrome && ua.match(/Android/)) || (chrome && ua.match(/CriOS\/([\d.]+)/)) || - // (firefox && ua.match(/Mobile/)) || (ie && ua.match(/Touch/)))); - - return { - browser: browser, - os: os, - node: false, - // åçcanvasæ¯æï¼æ¹æç«¯ç¹äº - // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9) - canvasSupported : document.createElement('canvas').getContext ? true : false, - // @see <http://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript> - // works on most browsers - // IE10/11 does not support touch event, and MS Edge supports them but not by - // default, so we dont check navigator.maxTouchPoints for them here. - touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge, - // <http://caniuse.com/#search=pointer%20event>. - pointerEventsSupported: 'onpointerdown' in window - // Firefox supports pointer but not by default, - // only MS browsers are reliable on pointer events currently. - && (browser.edge || (browser.ie && browser.version >= 10)) - }; - } - - -/***/ }, -/* 3 */ -/***/ function(module, exports, __webpack_require__) { - - /** - * ECharts global model - * - * @module {echarts/model/Global} - * - */ - - - - var zrUtil = __webpack_require__(4); - var modelUtil = __webpack_require__(5); - var Model = __webpack_require__(12); - var each = zrUtil.each; - var filter = zrUtil.filter; - var map = zrUtil.map; - var isArray = zrUtil.isArray; - var indexOf = zrUtil.indexOf; - var isObject = zrUtil.isObject; - - var ComponentModel = __webpack_require__(19); - - var globalDefault = __webpack_require__(23); - - var OPTION_INNER_KEY = '\0_ec_inner'; - - /** - * @alias module:echarts/model/Global - * - * @param {Object} option - * @param {module:echarts/model/Model} parentModel - * @param {Object} theme - */ - var GlobalModel = Model.extend({ - - constructor: GlobalModel, - - init: function (option, parentModel, theme, optionManager) { - theme = theme || {}; - - this.option = null; // Mark as not initialized. - - /** - * @type {module:echarts/model/Model} - * @private - */ - this._theme = new Model(theme); - - /** - * @type {module:echarts/model/OptionManager} - */ - this._optionManager = optionManager; - }, - - setOption: function (option, optionPreprocessorFuncs) { - zrUtil.assert( - !(OPTION_INNER_KEY in option), - 'please use chart.getOption()' - ); - - this._optionManager.setOption(option, optionPreprocessorFuncs); - - this.resetOption(); - }, - - /** - * @param {string} type null/undefined: reset all. - * 'recreate': force recreate all. - * 'timeline': only reset timeline option - * 'media': only reset media query option - * @return {boolean} Whether option changed. - */ - resetOption: function (type) { - var optionChanged = false; - var optionManager = this._optionManager; - - if (!type || type === 'recreate') { - var baseOption = optionManager.mountOption(type === 'recreate'); - - if (!this.option || type === 'recreate') { - initBase.call(this, baseOption); - } - else { - this.restoreData(); - this.mergeOption(baseOption); - } - optionChanged = true; - } - - if (type === 'timeline' || type === 'media') { - this.restoreData(); - } - - if (!type || type === 'recreate' || type === 'timeline') { - var timelineOption = optionManager.getTimelineOption(this); - timelineOption && (this.mergeOption(timelineOption), optionChanged = true); - } - - if (!type || type === 'recreate' || type === 'media') { - var mediaOptions = optionManager.getMediaOption(this, this._api); - if (mediaOptions.length) { - each(mediaOptions, function (mediaOption) { - this.mergeOption(mediaOption, optionChanged = true); - }, this); - } - } - - return optionChanged; - }, - - /** - * @protected - */ - mergeOption: function (newOption) { - var option = this.option; - var componentsMap = this._componentsMap; - var newCptTypes = []; - - // 妿ä¸åå¨å¯¹åºç component model åç´æ¥ merge - each(newOption, function (componentOption, mainType) { - if (componentOption == null) { - return; - } - - if (!ComponentModel.hasClass(mainType)) { - option[mainType] = option[mainType] == null - ? zrUtil.clone(componentOption) - : zrUtil.merge(option[mainType], componentOption, true); - } - else { - newCptTypes.push(mainType); - } - }); - - // FIXME OPTION 忥æ¯å¦è¦æ¹å忥ç - ComponentModel.topologicalTravel( - newCptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this - ); - - function visitComponent(mainType, dependencies) { - var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]); - - var mapResult = modelUtil.mappingToExists( - componentsMap[mainType], newCptOptionList - ); - - makeKeyInfo(mainType, mapResult); - - var dependentModels = getComponentsByTypes( - componentsMap, dependencies - ); - - option[mainType] = []; - componentsMap[mainType] = []; - - each(mapResult, function (resultItem, index) { - var componentModel = resultItem.exist; - var newCptOption = resultItem.option; - - zrUtil.assert( - isObject(newCptOption) || componentModel, - 'Empty component definition' - ); - - // Consider where is no new option and should be merged using {}, - // see removeEdgeAndAdd in topologicalTravel and - // ComponentModel.getAllClassMainTypes. - if (!newCptOption) { - componentModel.mergeOption({}, this); - componentModel.optionUpdated({}, false); - } - else { - var ComponentModelClass = ComponentModel.getClass( - mainType, resultItem.keyInfo.subType, true - ); - - if (componentModel && componentModel instanceof ComponentModelClass) { - componentModel.mergeOption(newCptOption, this); - componentModel.optionUpdated(newCptOption, false); - } - else { - // PENDING Global as parent ? - var extraOpt = zrUtil.extend( - { - dependentModels: dependentModels, - componentIndex: index - }, - resultItem.keyInfo - ); - componentModel = new ComponentModelClass( - newCptOption, this, this, extraOpt - ); - componentModel.init(newCptOption, this, this, extraOpt); - // Call optionUpdated after init. - // newCptOption has been used as componentModel.option - // and may be merged with theme and default, so pass null - // to avoid confusion. - componentModel.optionUpdated(null, true); - } - } - - componentsMap[mainType][index] = componentModel; - option[mainType][index] = componentModel.option; - }, this); - - // Backup series for filtering. - if (mainType === 'series') { - this._seriesIndices = createSeriesIndices(componentsMap.series); - } - } - }, - - /** - * Get option for output (cloned option and inner info removed) - * @public - * @return {Object} - */ - getOption: function () { - var option = zrUtil.clone(this.option); - - each(option, function (opts, mainType) { - if (ComponentModel.hasClass(mainType)) { - var opts = modelUtil.normalizeToArray(opts); - for (var i = opts.length - 1; i >= 0; i--) { - // Remove options with inner id. - if (modelUtil.isIdInner(opts[i])) { - opts.splice(i, 1); - } - } - option[mainType] = opts; - } - }); - - delete option[OPTION_INNER_KEY]; - - return option; - }, - - /** - * @return {module:echarts/model/Model} - */ - getTheme: function () { - return this._theme; - }, - - /** - * @param {string} mainType - * @param {number} [idx=0] - * @return {module:echarts/model/Component} - */ - getComponent: function (mainType, idx) { - var list = this._componentsMap[mainType]; - if (list) { - return list[idx || 0]; - } - }, - - /** - * @param {Object} condition - * @param {string} condition.mainType - * @param {string} [condition.subType] If ignore, only query by mainType - * @param {number} [condition.index] Either input index or id or name. - * @param {string} [condition.id] Either input index or id or name. - * @param {string} [condition.name] Either input index or id or name. - * @return {Array.<module:echarts/model/Component>} - */ - queryComponents: function (condition) { - var mainType = condition.mainType; - if (!mainType) { - return []; - } - - var index = condition.index; - var id = condition.id; - var name = condition.name; - - var cpts = this._componentsMap[mainType]; - - if (!cpts || !cpts.length) { - return []; - } - - var result; - - if (index != null) { - if (!isArray(index)) { - index = [index]; - } - result = filter(map(index, function (idx) { - return cpts[idx]; - }), function (val) { - return !!val; - }); - } - else if (id != null) { - var isIdArray = isArray(id); - result = filter(cpts, function (cpt) { - return (isIdArray && indexOf(id, cpt.id) >= 0) - || (!isIdArray && cpt.id === id); - }); - } - else if (name != null) { - var isNameArray = isArray(name); - result = filter(cpts, function (cpt) { - return (isNameArray && indexOf(name, cpt.name) >= 0) - || (!isNameArray && cpt.name === name); - }); - } - - return filterBySubType(result, condition); - }, - - /** - * The interface is different from queryComponents, - * which is convenient for inner usage. - * - * @usage - * var result = findComponents( - * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}} - * ); - * var result = findComponents( - * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}} - * ); - * var result = findComponents( - * {mainType: 'series'}, - * function (model, index) {...} - * ); - * // result like [component0, componnet1, ...] - * - * @param {Object} condition - * @param {string} condition.mainType Mandatory. - * @param {string} [condition.subType] Optional. - * @param {Object} [condition.query] like {xxxIndex, xxxId, xxxName}, - * where xxx is mainType. - * If query attribute is null/undefined or has no index/id/name, - * do not filtering by query conditions, which is convenient for - * no-payload situations or when target of action is global. - * @param {Function} [condition.filter] parameter: component, return boolean. - * @return {Array.<module:echarts/model/Component>} - */ - findComponents: function (condition) { - var query = condition.query; - var mainType = condition.mainType; - - var queryCond = getQueryCond(query); - var result = queryCond - ? this.queryComponents(queryCond) - : this._componentsMap[mainType]; - - return doFilter(filterBySubType(result, condition)); - - function getQueryCond(q) { - var indexAttr = mainType + 'Index'; - var idAttr = mainType + 'Id'; - var nameAttr = mainType + 'Name'; - return q && ( - q.hasOwnProperty(indexAttr) - || q.hasOwnProperty(idAttr) - || q.hasOwnProperty(nameAttr) - ) - ? { - mainType: mainType, - // subType will be filtered finally. - index: q[indexAttr], - id: q[idAttr], - name: q[nameAttr] - } - : null; - } - - function doFilter(res) { - return condition.filter - ? filter(res, condition.filter) - : res; - } - }, - - /** - * @usage - * eachComponent('legend', function (legendModel, index) { - * ... - * }); - * eachComponent(function (componentType, model, index) { - * // componentType does not include subType - * // (componentType is 'xxx' but not 'xxx.aa') - * }); - * eachComponent( - * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}, - * function (model, index) {...} - * ); - * eachComponent( - * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}, - * function (model, index) {...} - * ); - * - * @param {string|Object=} mainType When mainType is object, the definition - * is the same as the method 'findComponents'. - * @param {Function} cb - * @param {*} context - */ - eachComponent: function (mainType, cb, context) { - var componentsMap = this._componentsMap; - - if (typeof mainType === 'function') { - context = cb; - cb = mainType; - each(componentsMap, function (components, componentType) { - each(components, function (component, index) { - cb.call(context, componentType, component, index); - }); - }); - } - else if (zrUtil.isString(mainType)) { - each(componentsMap[mainType], cb, context); - } - else if (isObject(mainType)) { - var queryResult = this.findComponents(mainType); - each(queryResult, cb, context); - } - }, - - /** - * @param {string} name - * @return {Array.<module:echarts/model/Series>} - */ - getSeriesByName: function (name) { - var series = this._componentsMap.series; - return filter(series, function (oneSeries) { - return oneSeries.name === name; - }); - }, - - /** - * @param {number} seriesIndex - * @return {module:echarts/model/Series} - */ - getSeriesByIndex: function (seriesIndex) { - return this._componentsMap.series[seriesIndex]; - }, - - /** - * @param {string} subType - * @return {Array.<module:echarts/model/Series>} - */ - getSeriesByType: function (subType) { - var series = this._componentsMap.series; - return filter(series, function (oneSeries) { - return oneSeries.subType === subType; - }); - }, - - /** - * @return {Array.<module:echarts/model/Series>} - */ - getSeries: function () { - return this._componentsMap.series.slice(); - }, - - /** - * After filtering, series may be different - * frome raw series. - * - * @param {Function} cb - * @param {*} context - */ - eachSeries: function (cb, context) { - assertSeriesInitialized(this); - each(this._seriesIndices, function (rawSeriesIndex) { - var series = this._componentsMap.series[rawSeriesIndex]; - cb.call(context, series, rawSeriesIndex); - }, this); - }, - - /** - * Iterate raw series before filtered. - * - * @param {Function} cb - * @param {*} context - */ - eachRawSeries: function (cb, context) { - each(this._componentsMap.series, cb, context); - }, - - /** - * After filtering, series may be different. - * frome raw series. - * - * @parma {string} subType - * @param {Function} cb - * @param {*} context - */ - eachSeriesByType: function (subType, cb, context) { - assertSeriesInitialized(this); - each(this._seriesIndices, function (rawSeriesIndex) { - var series = this._componentsMap.series[rawSeriesIndex]; - if (series.subType === subType) { - cb.call(context, series, rawSeriesIndex); - } - }, this); - }, - - /** - * Iterate raw series before filtered of given type. - * - * @parma {string} subType - * @param {Function} cb - * @param {*} context - */ - eachRawSeriesByType: function (subType, cb, context) { - return each(this.getSeriesByType(subType), cb, context); - }, - - /** - * @param {module:echarts/model/Series} seriesModel - */ - isSeriesFiltered: function (seriesModel) { - assertSeriesInitialized(this); - return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0; - }, - - /** - * @param {Function} cb - * @param {*} context - */ - filterSeries: function (cb, context) { - assertSeriesInitialized(this); - var filteredSeries = filter( - this._componentsMap.series, cb, context - ); - this._seriesIndices = createSeriesIndices(filteredSeries); - }, - - restoreData: function () { - var componentsMap = this._componentsMap; - - this._seriesIndices = createSeriesIndices(componentsMap.series); - - var componentTypes = []; - each(componentsMap, function (components, componentType) { - componentTypes.push(componentType); - }); - - ComponentModel.topologicalTravel( - componentTypes, - ComponentModel.getAllClassMainTypes(), - function (componentType, dependencies) { - each(componentsMap[componentType], function (component) { - component.restoreData(); - }); - } - ); - } - - }); - - /** - * @inner - */ - function mergeTheme(option, theme) { - for (var name in theme) { - // 妿æ component model åæå ·ä½ç merge é»è¾äº¤ç»è¯¥ model å¤ç - if (!ComponentModel.hasClass(name)) { - if (typeof theme[name] === 'object') { - option[name] = !option[name] - ? zrUtil.clone(theme[name]) - : zrUtil.merge(option[name], theme[name], false); - } - else { - if (option[name] == null) { - option[name] = theme[name]; - } - } - } - } - } - - function initBase(baseOption) { - baseOption = baseOption; - - // Using OPTION_INNER_KEY to mark that this option can not be used outside, - // i.e. `chart.setOption(chart.getModel().option);` is forbiden. - this.option = {}; - this.option[OPTION_INNER_KEY] = 1; - - /** - * @type {Object.<string, Array.<module:echarts/model/Model>>} - * @private - */ - this._componentsMap = {}; - - /** - * Mapping between filtered series list and raw series list. - * key: filtered series indices, value: raw series indices. - * @type {Array.<nubmer>} - * @private - */ - this._seriesIndices = null; - - mergeTheme(baseOption, this._theme.option); - - // TODO Needs clone when merging to the unexisted property - zrUtil.merge(baseOption, globalDefault, false); - - this.mergeOption(baseOption); - } - - /** - * @inner - * @param {Array.<string>|string} types model types - * @return {Object} key: {string} type, value: {Array.<Object>} models - */ - function getComponentsByTypes(componentsMap, types) { - if (!zrUtil.isArray(types)) { - types = types ? [types] : []; - } - - var ret = {}; - each(types, function (type) { - ret[type] = (componentsMap[type] || []).slice(); - }); - - return ret; - } - - /** - * @inner - */ - function makeKeyInfo(mainType, mapResult) { - // We use this id to hash component models and view instances - // in echarts. id can be specified by user, or auto generated. - - // The id generation rule ensures new view instance are able - // to mapped to old instance when setOption are called in - // no-merge mode. So we generate model id by name and plus - // type in view id. - - // name can be duplicated among components, which is convenient - // to specify multi components (like series) by one name. - - // Ensure that each id is distinct. - var idMap = {}; - - each(mapResult, function (item, index) { - var existCpt = item.exist; - existCpt && (idMap[existCpt.id] = item); - }); - - each(mapResult, function (item, index) { - var opt = item.option; - - zrUtil.assert( - !opt || opt.id == null || !idMap[opt.id] || idMap[opt.id] === item, - 'id duplicates: ' + (opt && opt.id) - ); - - opt && opt.id != null && (idMap[opt.id] = item); - - // Complete subType - if (isObject(opt)) { - var subType = determineSubType(mainType, opt, item.exist); - item.keyInfo = {mainType: mainType, subType: subType}; - } - }); - - // Make name and id. - each(mapResult, function (item, index) { - var existCpt = item.exist; - var opt = item.option; - var keyInfo = item.keyInfo; - - if (!isObject(opt)) { - return; - } - - // name can be overwitten. Consider case: axis.name = '20km'. - // But id generated by name will not be changed, which affect - // only in that case: setOption with 'not merge mode' and view - // instance will be recreated, which can be accepted. - keyInfo.name = opt.name != null - ? opt.name + '' - : existCpt - ? existCpt.name - : '\0-'; - - if (existCpt) { - keyInfo.id = existCpt.id; - } - else if (opt.id != null) { - keyInfo.id = opt.id + ''; - } - else { - // Consider this situatoin: - // optionA: [{name: 'a'}, {name: 'a'}, {..}] - // optionB [{..}, {name: 'a'}, {name: 'a'}] - // Series with the same name between optionA and optionB - // should be mapped. - var idNum = 0; - do { - keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++; - } - while (idMap[keyInfo.id]); - } - - idMap[keyInfo.id] = item; - }); - } - - /** - * @inner - */ - function determineSubType(mainType, newCptOption, existComponent) { - var subType = newCptOption.type - ? newCptOption.type - : existComponent - ? existComponent.subType - // Use determineSubType only when there is no existComponent. - : ComponentModel.determineSubType(mainType, newCptOption); - - // tooltip, markline, markpoint may always has no subType - return subType; - } - - /** - * @inner - */ - function createSeriesIndices(seriesModels) { - return map(seriesModels, function (series) { - return series.componentIndex; - }) || []; - } - - /** - * @inner - */ - function filterBySubType(components, condition) { - // Using hasOwnProperty for restrict. Consider - // subType is undefined in user payload. - return condition.hasOwnProperty('subType') - ? filter(components, function (cpt) { - return cpt.subType === condition.subType; - }) - : components; - } - - /** - * @inner - */ - function assertSeriesInitialized(ecModel) { - // Components that use _seriesIndices should depends on series component, - // which make sure that their initialization is after series. - if (true) { - if (!ecModel._seriesIndices) { - throw new Error('Series has not been initialized yet.'); - } - } - } - - zrUtil.mixin(GlobalModel, __webpack_require__(24)); - - module.exports = GlobalModel; - - -/***/ }, -/* 4 */ -/***/ function(module, exports) { - - /** - * @module zrender/core/util - */ - - - // ç¨äºå¤çmergeæ¶æ æ³éåDateç对象çé®é¢ - var BUILTIN_OBJECT = { - '[object Function]': 1, - '[object RegExp]': 1, - '[object Date]': 1, - '[object Error]': 1, - '[object CanvasGradient]': 1, - '[object CanvasPattern]': 1, - // In node-canvas Image can be Canvas.Image - '[object Image]': 1 - }; - - var objToString = Object.prototype.toString; - - var arrayProto = Array.prototype; - var nativeForEach = arrayProto.forEach; - var nativeFilter = arrayProto.filter; - var nativeSlice = arrayProto.slice; - var nativeMap = arrayProto.map; - var nativeReduce = arrayProto.reduce; - - /** - * @param {*} source - * @return {*} æ·è´åçæ°å¯¹è±¡ - */ - function clone(source) { - if (typeof source == 'object' && source !== null) { - var result = source; - if (source instanceof Array) { - result = []; - for (var i = 0, len = source.length; i < len; i++) { - result[i] = clone(source[i]); - } - } - else if ( - !isBuildInObject(source) - // æ¯å¦ä¸º dom 对象 - && !isDom(source) - ) { - result = {}; - for (var key in source) { - if (source.hasOwnProperty(key)) { - result[key] = clone(source[key]); - } - } - } - - return result; - } - - return source; - } - - /** - * @memberOf module:zrender/core/util - * @param {*} target - * @param {*} source - * @param {boolean} [overwrite=false] - */ - function merge(target, source, overwrite) { - // We should escapse that source is string - // and enter for ... in ... - if (!isObject(source) || !isObject(target)) { - return overwrite ? clone(source) : target; - } - - for (var key in source) { - if (source.hasOwnProperty(key)) { - var targetProp = target[key]; - var sourceProp = source[key]; - - if (isObject(sourceProp) - && isObject(targetProp) - && !isArray(sourceProp) - && !isArray(targetProp) - && !isDom(sourceProp) - && !isDom(targetProp) - && !isBuildInObject(sourceProp) - && !isBuildInObject(targetProp) - ) { - // 妿éè¦éå½è¦çï¼å°±éå½è°ç¨merge - merge(targetProp, sourceProp, overwrite); - } - else if (overwrite || !(key in target)) { - // å¦ååªå¤çoverwrite为trueï¼æè å¨ç®æ å¯¹è±¡ä¸æ²¡ææ¤å±æ§çæ åµ - // NOTEï¼å¨ target[key] ä¸åå¨çæ¶å乿¯ç´æ¥è¦ç - target[key] = clone(source[key], true); - } - } - } - - return target; - } - - /** - * @param {Array} targetAndSources The first item is target, and the rests are source. - * @param {boolean} [overwrite=false] - * @return {*} target - */ - function mergeAll(targetAndSources, overwrite) { - var result = targetAndSources[0]; - for (var i = 1, len = targetAndSources.length; i < len; i++) { - result = merge(result, targetAndSources[i], overwrite); - } - return result; - } - - /** - * @param {*} target - * @param {*} source - * @memberOf module:zrender/core/util - */ - function extend(target, source) { - for (var key in source) { - if (source.hasOwnProperty(key)) { - target[key] = source[key]; - } - } - return target; - } - - /** - * @param {*} target - * @param {*} source - * @param {boolen} [overlay=false] - * @memberOf module:zrender/core/util -
<TRUNCATED>
