提交 7a3ba7d4 编写于 作者: S sushuang

Avoid inject.

上级 9e06beba
...@@ -8,8 +8,12 @@ export {gexf}; ...@@ -8,8 +8,12 @@ export {gexf};
export {prepareBoxplotData}; export {prepareBoxplotData};
echarts.$inject.dataTool({ // For backward compatibility, where the namespace `dataTool` will
version: version, // be mounted on `echarts` is the extension `dataTool` is imported.
gexf: gexf, // But the old version of echarts do not have `dataTool` namespace,
prepareBoxplotData: prepareBoxplotData // so check it before mounting.
}); if (echarts.dataTool) {
echarts.dataTool.version = version;
echarts.dataTool.gexf = gexf;
echarts.dataTool.prepareBoxplotData = prepareBoxplotData;
}
...@@ -4,19 +4,19 @@ ...@@ -4,19 +4,19 @@
// declaration is behind of the using position (for example in `Model.extent`, // declaration is behind of the using position (for example in `Model.extent`,
// And tools like rollup can not analysis the dependency if not import). // And tools like rollup can not analysis the dependency if not import).
var __DEV__; var dev;
// In browser // In browser
if (typeof window !== 'undefined') { if (typeof window !== 'undefined') {
__DEV__ = window.__DEV__; dev = window.__DEV__;
} }
// In node // In node
else if (typeof global !== 'undefined') { else if (typeof global !== 'undefined') {
__DEV__ = global.__DEV__; dev = global.__DEV__;
} }
if (typeof __DEV__ === 'undefined') { if (typeof dev === 'undefined') {
__DEV__ = true; dev = true;
} }
export {__DEV__}; export var __DEV__ = dev;
...@@ -4,16 +4,13 @@ import * as zrUtil from 'zrender/src/core/util'; ...@@ -4,16 +4,13 @@ import * as zrUtil from 'zrender/src/core/util';
import Geo from './Geo'; import Geo from './Geo';
import * as layout from '../../util/layout'; import * as layout from '../../util/layout';
import * as numberUtil from '../../util/number'; import * as numberUtil from '../../util/number';
import parseGeoJson from './parseGeoJson';
var mapDataStores = {};
/** /**
* Resize method bound to the geo * Resize method bound to the geo
* @param {module:echarts/coord/geo/GeoModel|module:echarts/chart/map/MapModel} geoModel * @param {module:echarts/coord/geo/GeoModel|module:echarts/chart/map/MapModel} geoModel
* @param {module:echarts/ExtensionAPI} api * @param {module:echarts/ExtensionAPI} api
*/ */
function resizeGeo (geoModel, api) { function resizeGeo(geoModel, api) {
var boundingCoords = geoModel.get('boundingCoords'); var boundingCoords = geoModel.get('boundingCoords');
if (boundingCoords != null) { if (boundingCoords != null) {
...@@ -123,7 +120,7 @@ var geoCreator = { ...@@ -123,7 +120,7 @@ var geoCreator = {
// FIXME Create each time may be slow // FIXME Create each time may be slow
ecModel.eachComponent('geo', function (geoModel, idx) { ecModel.eachComponent('geo', function (geoModel, idx) {
var name = geoModel.get('map'); var name = geoModel.get('map');
var mapData = mapDataStores[name]; var mapData = echarts.getMap(name);
if (__DEV__) { if (__DEV__) {
if (!mapData) { if (!mapData) {
mapNotExistsError(name); mapNotExistsError(name);
...@@ -168,7 +165,7 @@ var geoCreator = { ...@@ -168,7 +165,7 @@ var geoCreator = {
}); });
zrUtil.each(mapModelGroupBySeries, function (mapSeries, mapType) { zrUtil.each(mapModelGroupBySeries, function (mapSeries, mapType) {
var mapData = mapDataStores[mapType]; var mapData = echarts.getMap(mapType);
if (__DEV__) { if (__DEV__) {
if (!mapData) { if (!mapData) {
mapNotExistsError(mapSeries[0].get('map')); mapNotExistsError(mapSeries[0].get('map'));
...@@ -203,44 +200,6 @@ var geoCreator = { ...@@ -203,44 +200,6 @@ var geoCreator = {
return geoList; return geoList;
}, },
/**
* @param {string} mapName
* @param {Object|string} geoJson
* @param {Object} [specialAreas]
*
* @example
* $.get('USA.json', function (geoJson) {
* echarts.registerMap('USA', geoJson);
* // Or
* echarts.registerMap('USA', {
* geoJson: geoJson,
* specialAreas: {}
* })
* });
*/
registerMap: function (mapName, geoJson, specialAreas) {
if (geoJson.geoJson && !geoJson.features) {
specialAreas = geoJson.specialAreas;
geoJson = geoJson.geoJson;
}
if (typeof geoJson === 'string') {
geoJson = (typeof JSON !== 'undefined' && JSON.parse)
? JSON.parse(geoJson) : (new Function('return (' + geoJson + ');'))();
}
mapDataStores[mapName] = {
geoJson: geoJson,
specialAreas: specialAreas
};
},
/**
* @param {string} mapName
* @return {Object}
*/
getMap: function (mapName) {
return mapDataStores[mapName];
},
/** /**
* Fill given regions array * Fill given regions array
* @param {Array.<Object>} originRegionArr * @param {Array.<Object>} originRegionArr
...@@ -283,11 +242,6 @@ var geoCreator = { ...@@ -283,11 +242,6 @@ var geoCreator = {
} }
}; };
// Inject methods into echarts
echarts.$inject.registerMap(geoCreator.registerMap);
echarts.$inject.getMap(geoCreator.getMap);
echarts.$inject.parseGeoJSON(parseGeoJson);
echarts.registerCoordinateSystem('geo', geoCreator); echarts.registerCoordinateSystem('geo', geoCreator);
export default geoCreator; export default geoCreator;
\ No newline at end of file
...@@ -1544,7 +1544,6 @@ var themeStorage = {}; ...@@ -1544,7 +1544,6 @@ var themeStorage = {};
*/ */
var loadingEffects = {}; var loadingEffects = {};
var instances = {}; var instances = {};
var connectedGroups = {}; var connectedGroups = {};
...@@ -1552,6 +1551,8 @@ var idBase = new Date() - 0; ...@@ -1552,6 +1551,8 @@ var idBase = new Date() - 0;
var groupIdBase = new Date() - 0; var groupIdBase = new Date() - 0;
var DOM_ATTRIBUTE_KEY = '_echarts_instance_'; var DOM_ATTRIBUTE_KEY = '_echarts_instance_';
var mapDataStores = {};
function enableConnect(chart) { function enableConnect(chart) {
var STATUS_PENDING = 0; var STATUS_PENDING = 0;
var STATUS_UPDATING = 1; var STATUS_UPDATING = 1;
...@@ -1961,7 +1962,45 @@ export function extendChartView(opts/*, superClass*/) { ...@@ -1961,7 +1962,45 @@ export function extendChartView(opts/*, superClass*/) {
* }); * });
*/ */
export function setCanvasCreator(creator) { export function setCanvasCreator(creator) {
zrUtil.$inject.createCanvas(creator); zrUtil.$override('createCanvas', creator);
}
/**
* @param {string} mapName
* @param {Object|string} geoJson
* @param {Object} [specialAreas]
*
* @example
* $.get('USA.json', function (geoJson) {
* echarts.registerMap('USA', geoJson);
* // Or
* echarts.registerMap('USA', {
* geoJson: geoJson,
* specialAreas: {}
* })
* });
*/
export function registerMap(mapName, geoJson, specialAreas) {
if (geoJson.geoJson && !geoJson.features) {
specialAreas = geoJson.specialAreas;
geoJson = geoJson.geoJson;
}
if (typeof geoJson === 'string') {
geoJson = (typeof JSON !== 'undefined' && JSON.parse)
? JSON.parse(geoJson) : (new Function('return (' + geoJson + ');'))();
}
mapDataStores[mapName] = {
geoJson: geoJson,
specialAreas: specialAreas
};
}
/**
* @param {string} mapName
* @return {Object}
*/
export function getMap(mapName) {
return mapDataStores[mapName];
} }
registerVisual(PRIORITY_VISUAL_GLOBAL, seriesColor); registerVisual(PRIORITY_VISUAL_GLOBAL, seriesColor);
...@@ -1983,28 +2022,6 @@ registerAction({ ...@@ -1983,28 +2022,6 @@ registerAction({
}, zrUtil.noop); }, zrUtil.noop);
// -------- // For backward compatibility, where the namespace `dataTool` will
// Exports // be mounted on `echarts` is the extension `dataTool` is imported.
// -------- export var dataTool = {};
export var registerMap;
export var getMap;
export var parseGeoJSON;
export var dataTool;
// FIXME
export var $inject = {
registerMap: function (f) {
registerMap = f; /* ESM2CJS_REPLACE exports.registerMap = f; */
},
getMap: function (f) {
getMap = f; /* ESM2CJS_REPLACE exports.getMap = f; */
},
parseGeoJSON: function (f) {
parseGeoJSON = f; /* ESM2CJS_REPLACE exports.parseGeoJSON = f; */
},
dataTool: function (f) {
dataTool = f; /* ESM2CJS_REPLACE exports.dataTool = f; */
}
};
...@@ -27,6 +27,7 @@ export {matrix}; ...@@ -27,6 +27,7 @@ export {matrix};
export {vector}; export {vector};
export {colorTool as color}; export {colorTool as color};
export {default as env} from 'zrender/src/core/env'; export {default as env} from 'zrender/src/core/env';
export {default as parseGeoJson} from './coord/geo/parseGeoJson';
var ecUtil = {}; var ecUtil = {};
zrUtil.each([ zrUtil.each([
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册