1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- define(function(require) {
- 'use strict';
- var zrUtil = require('zrender/core/util');
- /**
- * Interface of Coordinate System Class
- *
- * create:
- * @param {module:echarts/model/Global} ecModel
- * @param {module:echarts/ExtensionAPI} api
- * @return {Object} coordinate system instance
- *
- * update:
- * @param {module:echarts/model/Global} ecModel
- * @param {module:echarts/ExtensionAPI} api
- *
- * convertToPixel:
- * convertFromPixel:
- * These two methods is also responsible for determine whether this
- * coodinate system is applicable to the given `finder`.
- * Each coordinate system will be tried, util one returns none
- * null/undefined value.
- * @param {module:echarts/model/Global} ecModel
- * @param {Object} finder
- * @param {Array|number} value
- * @return {Array|number} convert result.
- *
- * containPoint:
- * @param {Array.<number>} point In pixel coordinate system.
- * @return {boolean}
- */
- var coordinateSystemCreators = {};
- function CoordinateSystemManager() {
- this._coordinateSystems = [];
- }
- CoordinateSystemManager.prototype = {
- constructor: CoordinateSystemManager,
- create: function (ecModel, api) {
- var coordinateSystems = [];
- zrUtil.each(coordinateSystemCreators, function (creater, type) {
- var list = creater.create(ecModel, api);
- coordinateSystems = coordinateSystems.concat(list || []);
- });
- this._coordinateSystems = coordinateSystems;
- },
- update: function (ecModel, api) {
- zrUtil.each(this._coordinateSystems, function (coordSys) {
- // FIXME MUST have
- coordSys.update && coordSys.update(ecModel, api);
- });
- },
- getCoordinateSystems: function () {
- return this._coordinateSystems.slice();
- }
- };
- CoordinateSystemManager.register = function (type, coordinateSystemCreator) {
- coordinateSystemCreators[type] = coordinateSystemCreator;
- };
- CoordinateSystemManager.get = function (type) {
- return coordinateSystemCreators[type];
- };
- return CoordinateSystemManager;
- });
|