blob: f0b48a11bec7f8e625ab56469035f42e419c5d1b [file] [log] [blame]
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;
});