| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 | 
/** Licensed to the Apache Software Foundation (ASF) under one* or more contributor license agreements.  See the NOTICE file* distributed with this work for additional information* regarding copyright ownership.  The ASF licenses this file* to you under the Apache License, Version 2.0 (the* "License"); you may not use this file except in compliance* with the License.  You may obtain a copy of the License at**   http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing,* software distributed under the License is distributed on an* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY* KIND, either express or implied.  See the License for the* specific language governing permissions and limitations* under the License.*/var _util = require("zrender/lib/core/util");var each = _util.each;var Group = require("zrender/lib/container/Group");var componentUtil = require("../util/component");var clazzUtil = require("../util/clazz");var modelUtil = require("../util/model");var graphicUtil = require("../util/graphic");var _task = require("../stream/task");var createTask = _task.createTask;var createRenderPlanner = require("../chart/helper/createRenderPlanner");/** Licensed to the Apache Software Foundation (ASF) under one* or more contributor license agreements.  See the NOTICE file* distributed with this work for additional information* regarding copyright ownership.  The ASF licenses this file* to you under the Apache License, Version 2.0 (the* "License"); you may not use this file except in compliance* with the License.  You may obtain a copy of the License at**   http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing,* software distributed under the License is distributed on an* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY* KIND, either express or implied.  See the License for the* specific language governing permissions and limitations* under the License.*/var inner = modelUtil.makeInner();var renderPlanner = createRenderPlanner();function Chart() {  /**   * @type {module:zrender/container/Group}   * @readOnly   */  this.group = new Group();  /**   * @type {string}   * @readOnly   */  this.uid = componentUtil.getUID('viewChart');  this.renderTask = createTask({    plan: renderTaskPlan,    reset: renderTaskReset  });  this.renderTask.context = {    view: this  };}Chart.prototype = {  type: 'chart',  /**   * Init the chart.   * @param  {module:echarts/model/Global} ecModel   * @param  {module:echarts/ExtensionAPI} api   */  init: function (ecModel, api) {},  /**   * Render the chart.   * @param  {module:echarts/model/Series} seriesModel   * @param  {module:echarts/model/Global} ecModel   * @param  {module:echarts/ExtensionAPI} api   * @param  {Object} payload   */  render: function (seriesModel, ecModel, api, payload) {},  /**   * Highlight series or specified data item.   * @param  {module:echarts/model/Series} seriesModel   * @param  {module:echarts/model/Global} ecModel   * @param  {module:echarts/ExtensionAPI} api   * @param  {Object} payload   */  highlight: function (seriesModel, ecModel, api, payload) {    toggleHighlight(seriesModel.getData(), payload, 'emphasis');  },  /**   * Downplay series or specified data item.   * @param  {module:echarts/model/Series} seriesModel   * @param  {module:echarts/model/Global} ecModel   * @param  {module:echarts/ExtensionAPI} api   * @param  {Object} payload   */  downplay: function (seriesModel, ecModel, api, payload) {    toggleHighlight(seriesModel.getData(), payload, 'normal');  },  /**   * Remove self.   * @param  {module:echarts/model/Global} ecModel   * @param  {module:echarts/ExtensionAPI} api   */  remove: function (ecModel, api) {    this.group.removeAll();  },  /**   * Dispose self.   * @param  {module:echarts/model/Global} ecModel   * @param  {module:echarts/ExtensionAPI} api   */  dispose: function () {},  /**   * Rendering preparation in progressive mode.   * @param  {module:echarts/model/Series} seriesModel   * @param  {module:echarts/model/Global} ecModel   * @param  {module:echarts/ExtensionAPI} api   * @param  {Object} payload   */  incrementalPrepareRender: null,  /**   * Render in progressive mode.   * @param  {Object} params See taskParams in `stream/task.js`   * @param  {module:echarts/model/Series} seriesModel   * @param  {module:echarts/model/Global} ecModel   * @param  {module:echarts/ExtensionAPI} api   * @param  {Object} payload   */  incrementalRender: null,  /**   * Update transform directly.   * @param  {module:echarts/model/Series} seriesModel   * @param  {module:echarts/model/Global} ecModel   * @param  {module:echarts/ExtensionAPI} api   * @param  {Object} payload   * @return {Object} {update: true}   */  updateTransform: null,  /**   * The view contains the given point.   * @interface   * @param {Array.<number>} point   * @return {boolean}   */  // containPoint: function () {}  /**   * @param {string} eventType   * @param {Object} query   * @param {module:zrender/Element} targetEl   * @param {Object} packedEvent   * @return {boolen} Pass only when return `true`.   */  filterForExposedEvent: null};var chartProto = Chart.prototype;chartProto.updateView = chartProto.updateLayout = chartProto.updateVisual = function (seriesModel, ecModel, api, payload) {  this.render(seriesModel, ecModel, api, payload);};/** * Set state of single element * @param {module:zrender/Element} el * @param {string} state 'normal'|'emphasis' * @param {number} highlightDigit */function elSetState(el, state, highlightDigit) {  if (el) {    el.trigger(state, highlightDigit);    if (el.isGroup // Simple optimize.    && !graphicUtil.isHighDownDispatcher(el)) {      for (var i = 0, len = el.childCount(); i < len; i++) {        elSetState(el.childAt(i), state, highlightDigit);      }    }  }}/** * @param {module:echarts/data/List} data * @param {Object} payload * @param {string} state 'normal'|'emphasis' */function toggleHighlight(data, payload, state) {  var dataIndex = modelUtil.queryDataIndex(data, payload);  var highlightDigit = payload && payload.highlightKey != null ? graphicUtil.getHighlightDigit(payload.highlightKey) : null;  if (dataIndex != null) {    each(modelUtil.normalizeToArray(dataIndex), function (dataIdx) {      elSetState(data.getItemGraphicEl(dataIdx), state, highlightDigit);    });  } else {    data.eachItemGraphicEl(function (el) {      elSetState(el, state, highlightDigit);    });  }} // Enable Chart.extend.clazzUtil.enableClassExtend(Chart, ['dispose']); // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.clazzUtil.enableClassManagement(Chart, {  registerWhenExtend: true});Chart.markUpdateMethod = function (payload, methodName) {  inner(payload).updateMethod = methodName;};function renderTaskPlan(context) {  return renderPlanner(context.model);}function renderTaskReset(context) {  var seriesModel = context.model;  var ecModel = context.ecModel;  var api = context.api;  var payload = context.payload; // ???! remove updateView updateVisual  var progressiveRender = seriesModel.pipelineContext.progressiveRender;  var view = context.view;  var updateMethod = payload && inner(payload).updateMethod;  var methodName = progressiveRender ? 'incrementalPrepareRender' : updateMethod && view[updateMethod] ? updateMethod // `appendData` is also supported when data amount  // is less than progressive threshold.  : 'render';  if (methodName !== 'render') {    view[methodName](seriesModel, ecModel, api, payload);  }  return progressMethodMap[methodName];}var progressMethodMap = {  incrementalPrepareRender: {    progress: function (params, context) {      context.view.incrementalRender(params, context.model, context.ecModel, context.api, context.payload);    }  },  render: {    // Put view.render in `progress` to support appendData. But in this case    // view.render should not be called in reset, otherwise it will be called    // twise. Use `forceFirstProgress` to make sure that view.render is called    // in any cases.    forceFirstProgress: true,    progress: function (params, context) {      context.view.render(context.model, context.ecModel, context.api, context.payload);    }  }};var _default = Chart;module.exports = _default;
 |