first commit

This commit is contained in:
jefferyzhao
2025-07-31 17:44:12 +08:00
commit b9bdc8598b
42390 changed files with 4467935 additions and 0 deletions

218
node_modules/echarts/lib/coord/geo/Geo.js generated vendored Normal file
View File

@ -0,0 +1,218 @@
/*
* 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 zrUtil = require("zrender/lib/core/util");
var BoundingRect = require("zrender/lib/core/BoundingRect");
var View = require("../View");
var geoSourceManager = require("./geoSourceManager");
/*
* 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.
*/
/**
* [Geo description]
* For backward compatibility, the orginal interface:
* `name, map, geoJson, specialAreas, nameMap` is kept.
*
* @param {string|Object} name
* @param {string} map Map type
* Specify the positioned areas by left, top, width, height
* @param {Object.<string, string>} [nameMap]
* Specify name alias
* @param {boolean} [invertLongitute=true]
*/
function Geo(name, map, nameMap, invertLongitute) {
View.call(this, name);
/**
* Map type
* @type {string}
*/
this.map = map;
var source = geoSourceManager.load(map, nameMap);
this._nameCoordMap = source.nameCoordMap;
this._regionsMap = source.regionsMap;
this._invertLongitute = invertLongitute == null ? true : invertLongitute;
/**
* @readOnly
*/
this.regions = source.regions;
/**
* @type {module:zrender/src/core/BoundingRect}
*/
this._rect = source.boundingRect;
}
Geo.prototype = {
constructor: Geo,
type: 'geo',
/**
* @param {Array.<string>}
* @readOnly
*/
dimensions: ['lng', 'lat'],
/**
* If contain given lng,lat coord
* @param {Array.<number>}
* @readOnly
*/
containCoord: function (coord) {
var regions = this.regions;
for (var i = 0; i < regions.length; i++) {
if (regions[i].contain(coord)) {
return true;
}
}
return false;
},
/**
* @override
*/
transformTo: function (x, y, width, height) {
var rect = this.getBoundingRect();
var invertLongitute = this._invertLongitute;
rect = rect.clone();
if (invertLongitute) {
// Longitute is inverted
rect.y = -rect.y - rect.height;
}
var rawTransformable = this._rawTransformable;
rawTransformable.transform = rect.calculateTransform(new BoundingRect(x, y, width, height));
rawTransformable.decomposeTransform();
if (invertLongitute) {
var scale = rawTransformable.scale;
scale[1] = -scale[1];
}
rawTransformable.updateTransform();
this._updateTransform();
},
/**
* @param {string} name
* @return {module:echarts/coord/geo/Region}
*/
getRegion: function (name) {
return this._regionsMap.get(name);
},
getRegionByCoord: function (coord) {
var regions = this.regions;
for (var i = 0; i < regions.length; i++) {
if (regions[i].contain(coord)) {
return regions[i];
}
}
},
/**
* Add geoCoord for indexing by name
* @param {string} name
* @param {Array.<number>} geoCoord
*/
addGeoCoord: function (name, geoCoord) {
this._nameCoordMap.set(name, geoCoord);
},
/**
* Get geoCoord by name
* @param {string} name
* @return {Array.<number>}
*/
getGeoCoord: function (name) {
return this._nameCoordMap.get(name);
},
/**
* @override
*/
getBoundingRect: function () {
return this._rect;
},
/**
* @param {string|Array.<number>} data
* @param {boolean} noRoam
* @param {Array.<number>} [out]
* @return {Array.<number>}
*/
dataToPoint: function (data, noRoam, out) {
if (typeof data === 'string') {
// Map area name to geoCoord
data = this.getGeoCoord(data);
}
if (data) {
return View.prototype.dataToPoint.call(this, data, noRoam, out);
}
},
/**
* @override
*/
convertToPixel: zrUtil.curry(doConvert, 'dataToPoint'),
/**
* @override
*/
convertFromPixel: zrUtil.curry(doConvert, 'pointToData')
};
zrUtil.mixin(Geo, View);
function doConvert(methodName, ecModel, finder, value) {
var geoModel = finder.geoModel;
var seriesModel = finder.seriesModel;
var coordSys = geoModel ? geoModel.coordinateSystem : seriesModel ? seriesModel.coordinateSystem // For map.
|| (seriesModel.getReferringComponents('geo')[0] || {}).coordinateSystem : null;
return coordSys === this ? coordSys[methodName](value) : null;
}
var _default = Geo;
module.exports = _default;

169
node_modules/echarts/lib/coord/geo/GeoModel.js generated vendored Normal file
View File

@ -0,0 +1,169 @@
/*
* 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 zrUtil = require("zrender/lib/core/util");
var modelUtil = require("../../util/model");
var ComponentModel = require("../../model/Component");
var Model = require("../../model/Model");
var selectableMixin = require("../../component/helper/selectableMixin");
var geoCreator = require("./geoCreator");
/*
* 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 GeoModel = ComponentModel.extend({
type: 'geo',
/**
* @type {module:echarts/coord/geo/Geo}
*/
coordinateSystem: null,
layoutMode: 'box',
init: function (option) {
ComponentModel.prototype.init.apply(this, arguments); // Default label emphasis `show`
modelUtil.defaultEmphasis(option, 'label', ['show']);
},
optionUpdated: function () {
var option = this.option;
var self = this;
option.regions = geoCreator.getFilledRegions(option.regions, option.map, option.nameMap);
this._optionModelMap = zrUtil.reduce(option.regions || [], function (optionModelMap, regionOpt) {
if (regionOpt.name) {
optionModelMap.set(regionOpt.name, new Model(regionOpt, self));
}
return optionModelMap;
}, zrUtil.createHashMap());
this.updateSelectedMap(option.regions);
},
defaultOption: {
zlevel: 0,
z: 0,
show: true,
left: 'center',
top: 'center',
// width:,
// height:,
// right
// bottom
// Aspect is width / height. Inited to be geoJson bbox aspect
// This parameter is used for scale this aspect
// If svg used, aspectScale is 1 by default.
// aspectScale: 0.75,
aspectScale: null,
///// Layout with center and size
// If you wan't to put map in a fixed size box with right aspect ratio
// This two properties may more conveninet
// layoutCenter: [50%, 50%]
// layoutSize: 100
silent: false,
// Map type
map: '',
// Define left-top, right-bottom coords to control view
// For example, [ [180, 90], [-180, -90] ]
boundingCoords: null,
// Default on center of map
center: null,
zoom: 1,
scaleLimit: null,
// selectedMode: false
label: {
show: false,
color: '#000'
},
itemStyle: {
// color: 各异,
borderWidth: 0.5,
borderColor: '#444',
color: '#eee'
},
emphasis: {
label: {
show: true,
color: 'rgb(100,0,0)'
},
itemStyle: {
color: 'rgba(255,215,0,0.8)'
}
},
regions: []
},
/**
* Get model of region
* @param {string} name
* @return {module:echarts/model/Model}
*/
getRegionModel: function (name) {
return this._optionModelMap.get(name) || new Model(null, this, this.ecModel);
},
/**
* Format label
* @param {string} name Region name
* @param {string} [status='normal'] 'normal' or 'emphasis'
* @return {string}
*/
getFormattedLabel: function (name, status) {
status = status || 'normal';
var regionModel = this.getRegionModel(name);
var formatter = regionModel.get((status === 'normal' ? '' : status + '.') + 'label.formatter');
var params = {
name: name
};
if (typeof formatter === 'function') {
params.status = status;
return formatter(params);
} else if (typeof formatter === 'string') {
return formatter.replace('{a}', name != null ? name : '');
}
},
setZoom: function (zoom) {
this.option.zoom = zoom;
},
setCenter: function (center) {
this.option.center = center;
}
});
zrUtil.mixin(GeoModel, selectableMixin);
var _default = GeoModel;
module.exports = _default;

210
node_modules/echarts/lib/coord/geo/Region.js generated vendored Normal file
View File

@ -0,0 +1,210 @@
/*
* 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 BoundingRect = require("zrender/lib/core/BoundingRect");
var bbox = require("zrender/lib/core/bbox");
var vec2 = require("zrender/lib/core/vector");
var polygonContain = require("zrender/lib/contain/polygon");
/*
* 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.
*/
/**
* @module echarts/coord/geo/Region
*/
/**
* @param {string|Region} name
* @param {Array} geometries
* @param {Array.<number>} cp
*/
function Region(name, geometries, cp) {
/**
* @type {string}
* @readOnly
*/
this.name = name;
/**
* @type {Array.<Array>}
* @readOnly
*/
this.geometries = geometries;
if (!cp) {
var rect = this.getBoundingRect();
cp = [rect.x + rect.width / 2, rect.y + rect.height / 2];
} else {
cp = [cp[0], cp[1]];
}
/**
* @type {Array.<number>}
*/
this.center = cp;
}
Region.prototype = {
constructor: Region,
properties: null,
/**
* @return {module:zrender/core/BoundingRect}
*/
getBoundingRect: function () {
var rect = this._rect;
if (rect) {
return rect;
}
var MAX_NUMBER = Number.MAX_VALUE;
var min = [MAX_NUMBER, MAX_NUMBER];
var max = [-MAX_NUMBER, -MAX_NUMBER];
var min2 = [];
var max2 = [];
var geometries = this.geometries;
for (var i = 0; i < geometries.length; i++) {
// Only support polygon
if (geometries[i].type !== 'polygon') {
continue;
} // Doesn't consider hole
var exterior = geometries[i].exterior;
bbox.fromPoints(exterior, min2, max2);
vec2.min(min, min, min2);
vec2.max(max, max, max2);
} // No data
if (i === 0) {
min[0] = min[1] = max[0] = max[1] = 0;
}
return this._rect = new BoundingRect(min[0], min[1], max[0] - min[0], max[1] - min[1]);
},
/**
* @param {<Array.<number>} coord
* @return {boolean}
*/
contain: function (coord) {
var rect = this.getBoundingRect();
var geometries = this.geometries;
if (!rect.contain(coord[0], coord[1])) {
return false;
}
loopGeo: for (var i = 0, len = geometries.length; i < len; i++) {
// Only support polygon.
if (geometries[i].type !== 'polygon') {
continue;
}
var exterior = geometries[i].exterior;
var interiors = geometries[i].interiors;
if (polygonContain.contain(exterior, coord[0], coord[1])) {
// Not in the region if point is in the hole.
for (var k = 0; k < (interiors ? interiors.length : 0); k++) {
if (polygonContain.contain(interiors[k])) {
continue loopGeo;
}
}
return true;
}
}
return false;
},
transformTo: function (x, y, width, height) {
var rect = this.getBoundingRect();
var aspect = rect.width / rect.height;
if (!width) {
width = aspect * height;
} else if (!height) {
height = width / aspect;
}
var target = new BoundingRect(x, y, width, height);
var transform = rect.calculateTransform(target);
var geometries = this.geometries;
for (var i = 0; i < geometries.length; i++) {
// Only support polygon.
if (geometries[i].type !== 'polygon') {
continue;
}
var exterior = geometries[i].exterior;
var interiors = geometries[i].interiors;
for (var p = 0; p < exterior.length; p++) {
vec2.applyTransform(exterior[p], exterior[p], transform);
}
for (var h = 0; h < (interiors ? interiors.length : 0); h++) {
for (var p = 0; p < interiors[h].length; p++) {
vec2.applyTransform(interiors[h][p], interiors[h][p], transform);
}
}
}
rect = this._rect;
rect.copy(target); // Update center
this.center = [rect.x + rect.width / 2, rect.y + rect.height / 2];
},
cloneShallow: function (name) {
name == null && (name = this.name);
var newRegion = new Region(name, this.geometries, this.center);
newRegion._rect = this._rect;
newRegion.transformTo = null; // Simply avoid to be called.
return newRegion;
}
};
var _default = Region;
module.exports = _default;

54
node_modules/echarts/lib/coord/geo/fix/diaoyuIsland.js generated vendored Normal file
View File

@ -0,0 +1,54 @@
/*
* 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.
*/
/*
* 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.
*/
// Fix for 钓鱼岛
// var Region = require('../Region');
// var zrUtil = require('zrender/src/core/util');
// var geoCoord = [126, 25];
var points = [[[123.45165252685547, 25.73527164402261], [123.49731445312499, 25.73527164402261], [123.49731445312499, 25.750734064600884], [123.45165252685547, 25.750734064600884], [123.45165252685547, 25.73527164402261]]];
function _default(mapType, region) {
if (mapType === 'china' && region.name === '台湾') {
region.geometries.push({
type: 'polygon',
exterior: points[0]
});
}
}
module.exports = _default;

57
node_modules/echarts/lib/coord/geo/fix/geoCoord.js generated vendored Normal file
View File

@ -0,0 +1,57 @@
/*
* 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.
*/
/*
* 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 geoCoordMap = {
'Russia': [100, 60],
'United States': [-99, 38],
'United States of America': [-99, 38]
};
function _default(mapType, region) {
if (mapType === 'world') {
var geoCoord = geoCoordMap[region.name];
if (geoCoord) {
var cp = region.center;
cp[0] = geoCoord[0];
cp[1] = geoCoord[1];
}
}
}
module.exports = _default;

67
node_modules/echarts/lib/coord/geo/fix/nanhai.js generated vendored Normal file
View File

@ -0,0 +1,67 @@
/*
* 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 zrUtil = require("zrender/lib/core/util");
var Region = require("../Region");
/*
* 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.
*/
// Fix for 南海诸岛
var geoCoord = [126, 25];
var points = [[[0, 3.5], [7, 11.2], [15, 11.9], [30, 7], [42, 0.7], [52, 0.7], [56, 7.7], [59, 0.7], [64, 0.7], [64, 0], [5, 0], [0, 3.5]], [[13, 16.1], [19, 14.7], [16, 21.7], [11, 23.1], [13, 16.1]], [[12, 32.2], [14, 38.5], [15, 38.5], [13, 32.2], [12, 32.2]], [[16, 47.6], [12, 53.2], [13, 53.2], [18, 47.6], [16, 47.6]], [[6, 64.4], [8, 70], [9, 70], [8, 64.4], [6, 64.4]], [[23, 82.6], [29, 79.8], [30, 79.8], [25, 82.6], [23, 82.6]], [[37, 70.7], [43, 62.3], [44, 62.3], [39, 70.7], [37, 70.7]], [[48, 51.1], [51, 45.5], [53, 45.5], [50, 51.1], [48, 51.1]], [[51, 35], [51, 28.7], [53, 28.7], [53, 35], [51, 35]], [[52, 22.4], [55, 17.5], [56, 17.5], [53, 22.4], [52, 22.4]], [[58, 12.6], [62, 7], [63, 7], [60, 12.6], [58, 12.6]], [[0, 3.5], [0, 93.1], [64, 93.1], [64, 0], [63, 0], [63, 92.4], [1, 92.4], [1, 3.5], [0, 3.5]]];
for (var i = 0; i < points.length; i++) {
for (var k = 0; k < points[i].length; k++) {
points[i][k][0] /= 10.5;
points[i][k][1] /= -10.5 / 0.75;
points[i][k][0] += geoCoord[0];
points[i][k][1] += geoCoord[1];
}
}
function _default(mapType, regions) {
if (mapType === 'china') {
regions.push(new Region('南海诸岛', zrUtil.map(points, function (exterior) {
return {
type: 'polygon',
exterior: exterior
};
}), geoCoord));
}
}
module.exports = _default;

61
node_modules/echarts/lib/coord/geo/fix/textCoord.js generated vendored Normal file
View File

@ -0,0 +1,61 @@
/*
* 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.
*/
/*
* 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 coordsOffsetMap = {
'南海诸岛': [32, 80],
// 全国
'广东': [0, -10],
'香港': [10, 5],
'澳门': [-10, 10],
//'北京': [-10, 0],
'天津': [5, 5]
};
function _default(mapType, region) {
if (mapType === 'china') {
var coordFix = coordsOffsetMap[region.name];
if (coordFix) {
var cp = region.center;
cp[0] += coordFix[0] / 10.5;
cp[1] += -coordFix[1] / (10.5 / 0.75);
}
}
}
module.exports = _default;

233
node_modules/echarts/lib/coord/geo/geoCreator.js generated vendored Normal file
View File

@ -0,0 +1,233 @@
/*
* 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 _config = require("../../config");
var __DEV__ = _config.__DEV__;
var echarts = require("../../echarts");
var zrUtil = require("zrender/lib/core/util");
var Geo = require("./Geo");
var layout = require("../../util/layout");
var numberUtil = require("../../util/number");
var geoSourceManager = require("./geoSourceManager");
var mapDataStorage = require("./mapDataStorage");
/*
* 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.
*/
/**
* Resize method bound to the geo
* @param {module:echarts/coord/geo/GeoModel|module:echarts/chart/map/MapModel} geoModel
* @param {module:echarts/ExtensionAPI} api
*/
function resizeGeo(geoModel, api) {
var boundingCoords = geoModel.get('boundingCoords');
if (boundingCoords != null) {
var leftTop = boundingCoords[0];
var rightBottom = boundingCoords[1];
if (isNaN(leftTop[0]) || isNaN(leftTop[1]) || isNaN(rightBottom[0]) || isNaN(rightBottom[1])) {} else {
this.setBoundingRect(leftTop[0], leftTop[1], rightBottom[0] - leftTop[0], rightBottom[1] - leftTop[1]);
}
}
var rect = this.getBoundingRect();
var boxLayoutOption;
var center = geoModel.get('layoutCenter');
var size = geoModel.get('layoutSize');
var viewWidth = api.getWidth();
var viewHeight = api.getHeight();
var aspect = rect.width / rect.height * this.aspectScale;
var useCenterAndSize = false;
if (center && size) {
center = [numberUtil.parsePercent(center[0], viewWidth), numberUtil.parsePercent(center[1], viewHeight)];
size = numberUtil.parsePercent(size, Math.min(viewWidth, viewHeight));
if (!isNaN(center[0]) && !isNaN(center[1]) && !isNaN(size)) {
useCenterAndSize = true;
} else {}
}
var viewRect;
if (useCenterAndSize) {
var viewRect = {};
if (aspect > 1) {
// Width is same with size
viewRect.width = size;
viewRect.height = size / aspect;
} else {
viewRect.height = size;
viewRect.width = size * aspect;
}
viewRect.y = center[1] - viewRect.height / 2;
viewRect.x = center[0] - viewRect.width / 2;
} else {
// Use left/top/width/height
boxLayoutOption = geoModel.getBoxLayoutParams(); // 0.75 rate
boxLayoutOption.aspect = aspect;
viewRect = layout.getLayoutRect(boxLayoutOption, {
width: viewWidth,
height: viewHeight
});
}
this.setViewRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height);
this.setCenter(geoModel.get('center'));
this.setZoom(geoModel.get('zoom'));
}
/**
* @param {module:echarts/coord/Geo} geo
* @param {module:echarts/model/Model} model
* @inner
*/
function setGeoCoords(geo, model) {
zrUtil.each(model.get('geoCoord'), function (geoCoord, name) {
geo.addGeoCoord(name, geoCoord);
});
}
var geoCreator = {
// For deciding which dimensions to use when creating list data
dimensions: Geo.prototype.dimensions,
create: function (ecModel, api) {
var geoList = []; // FIXME Create each time may be slow
ecModel.eachComponent('geo', function (geoModel, idx) {
var name = geoModel.get('map');
var aspectScale = geoModel.get('aspectScale');
var invertLongitute = true;
var mapRecords = mapDataStorage.retrieveMap(name);
if (mapRecords && mapRecords[0] && mapRecords[0].type === 'svg') {
aspectScale == null && (aspectScale = 1);
invertLongitute = false;
} else {
aspectScale == null && (aspectScale = 0.75);
}
var geo = new Geo(name + idx, name, geoModel.get('nameMap'), invertLongitute);
geo.aspectScale = aspectScale;
geo.zoomLimit = geoModel.get('scaleLimit');
geoList.push(geo);
setGeoCoords(geo, geoModel);
geoModel.coordinateSystem = geo;
geo.model = geoModel; // Inject resize method
geo.resize = resizeGeo;
geo.resize(geoModel, api);
});
ecModel.eachSeries(function (seriesModel) {
var coordSys = seriesModel.get('coordinateSystem');
if (coordSys === 'geo') {
var geoIndex = seriesModel.get('geoIndex') || 0;
seriesModel.coordinateSystem = geoList[geoIndex];
}
}); // If has map series
var mapModelGroupBySeries = {};
ecModel.eachSeriesByType('map', function (seriesModel) {
if (!seriesModel.getHostGeoModel()) {
var mapType = seriesModel.getMapType();
mapModelGroupBySeries[mapType] = mapModelGroupBySeries[mapType] || [];
mapModelGroupBySeries[mapType].push(seriesModel);
}
});
zrUtil.each(mapModelGroupBySeries, function (mapSeries, mapType) {
var nameMapList = zrUtil.map(mapSeries, function (singleMapSeries) {
return singleMapSeries.get('nameMap');
});
var geo = new Geo(mapType, mapType, zrUtil.mergeAll(nameMapList));
geo.zoomLimit = zrUtil.retrieve.apply(null, zrUtil.map(mapSeries, function (singleMapSeries) {
return singleMapSeries.get('scaleLimit');
}));
geoList.push(geo); // Inject resize method
geo.resize = resizeGeo;
geo.aspectScale = mapSeries[0].get('aspectScale');
geo.resize(mapSeries[0], api);
zrUtil.each(mapSeries, function (singleMapSeries) {
singleMapSeries.coordinateSystem = geo;
setGeoCoords(geo, singleMapSeries);
});
});
return geoList;
},
/**
* Fill given regions array
* @param {Array.<Object>} originRegionArr
* @param {string} mapName
* @param {Object} [nameMap]
* @return {Array}
*/
getFilledRegions: function (originRegionArr, mapName, nameMap) {
// Not use the original
var regionsArr = (originRegionArr || []).slice();
var dataNameMap = zrUtil.createHashMap();
for (var i = 0; i < regionsArr.length; i++) {
dataNameMap.set(regionsArr[i].name, regionsArr[i]);
}
var source = geoSourceManager.load(mapName, nameMap);
zrUtil.each(source.regions, function (region) {
var name = region.name;
!dataNameMap.get(name) && regionsArr.push({
name: name
});
});
return regionsArr;
}
};
echarts.registerCoordinateSystem('geo', geoCreator);
var _default = geoCreator;
module.exports = _default;

116
node_modules/echarts/lib/coord/geo/geoJSONLoader.js generated vendored Normal file
View File

@ -0,0 +1,116 @@
/*
* 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 parseGeoJson = require("./parseGeoJson");
var _model = require("../../util/model");
var makeInner = _model.makeInner;
var fixNanhai = require("./fix/nanhai");
var fixTextCoord = require("./fix/textCoord");
var fixGeoCoord = require("./fix/geoCoord");
var fixDiaoyuIsland = require("./fix/diaoyuIsland");
/*
* 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.
*/
// Built-in GEO fixer.
var inner = makeInner();
var _default = {
/**
* @param {string} mapName
* @param {Object} mapRecord {specialAreas, geoJSON}
* @param {string} nameProperty
* @return {Object} {regions, boundingRect}
*/
load: function (mapName, mapRecord, nameProperty) {
var parsed = inner(mapRecord).parsed;
if (parsed) {
return parsed;
}
var specialAreas = mapRecord.specialAreas || {};
var geoJSON = mapRecord.geoJSON;
var regions; // https://jsperf.com/try-catch-performance-overhead
try {
regions = geoJSON ? parseGeoJson(geoJSON, nameProperty) : [];
} catch (e) {
throw new Error('Invalid geoJson format\n' + e.message);
}
fixNanhai(mapName, regions);
each(regions, function (region) {
var regionName = region.name;
fixTextCoord(mapName, region);
fixGeoCoord(mapName, region);
fixDiaoyuIsland(mapName, region); // Some area like Alaska in USA map needs to be tansformed
// to look better
var specialArea = specialAreas[regionName];
if (specialArea) {
region.transformTo(specialArea.left, specialArea.top, specialArea.width, specialArea.height);
}
});
return inner(mapRecord).parsed = {
regions: regions,
boundingRect: getBoundingRect(regions)
};
}
};
function getBoundingRect(regions) {
var rect;
for (var i = 0; i < regions.length; i++) {
var regionRect = regions[i].getBoundingRect();
rect = rect || regionRect.clone();
rect.union(regionRect);
}
return rect;
}
module.exports = _default;

168
node_modules/echarts/lib/coord/geo/geoSVGLoader.js generated vendored Normal file
View File

@ -0,0 +1,168 @@
/*
* 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 _parseSVG = require("zrender/lib/tool/parseSVG");
var parseSVG = _parseSVG.parseSVG;
var makeViewBoxTransform = _parseSVG.makeViewBoxTransform;
var Group = require("zrender/lib/container/Group");
var Rect = require("zrender/lib/graphic/shape/Rect");
var _util = require("zrender/lib/core/util");
var assert = _util.assert;
var createHashMap = _util.createHashMap;
var BoundingRect = require("zrender/lib/core/BoundingRect");
var _model = require("../../util/model");
var makeInner = _model.makeInner;
/*
* 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 = makeInner();
var _default = {
/**
* @param {string} mapName
* @param {Object} mapRecord {specialAreas, geoJSON}
* @return {Object} {root, boundingRect}
*/
load: function (mapName, mapRecord) {
var originRoot = inner(mapRecord).originRoot;
if (originRoot) {
return {
root: originRoot,
boundingRect: inner(mapRecord).boundingRect
};
}
var graphic = buildGraphic(mapRecord);
inner(mapRecord).originRoot = graphic.root;
inner(mapRecord).boundingRect = graphic.boundingRect;
return graphic;
},
makeGraphic: function (mapName, mapRecord, hostKey) {
// For performance consideration (in large SVG), graphic only maked
// when necessary and reuse them according to hostKey.
var field = inner(mapRecord);
var rootMap = field.rootMap || (field.rootMap = createHashMap());
var root = rootMap.get(hostKey);
if (root) {
return root;
}
var originRoot = field.originRoot;
var boundingRect = field.boundingRect; // For performance, if originRoot is not used by a view,
// assign it to a view, but not reproduce graphic elements.
if (!field.originRootHostKey) {
field.originRootHostKey = hostKey;
root = originRoot;
} else {
root = buildGraphic(mapRecord, boundingRect).root;
}
return rootMap.set(hostKey, root);
},
removeGraphic: function (mapName, mapRecord, hostKey) {
var field = inner(mapRecord);
var rootMap = field.rootMap;
rootMap && rootMap.removeKey(hostKey);
if (hostKey === field.originRootHostKey) {
field.originRootHostKey = null;
}
}
};
function buildGraphic(mapRecord, boundingRect) {
var svgXML = mapRecord.svgXML;
var result;
var root;
try {
result = svgXML && parseSVG(svgXML, {
ignoreViewBox: true,
ignoreRootClip: true
}) || {};
root = result.root;
assert(root != null);
} catch (e) {
throw new Error('Invalid svg format\n' + e.message);
}
var svgWidth = result.width;
var svgHeight = result.height;
var viewBoxRect = result.viewBoxRect;
if (!boundingRect) {
boundingRect = svgWidth == null || svgHeight == null ? // If svg width / height not specified, calculate
// bounding rect as the width / height
root.getBoundingRect() : new BoundingRect(0, 0, 0, 0);
if (svgWidth != null) {
boundingRect.width = svgWidth;
}
if (svgHeight != null) {
boundingRect.height = svgHeight;
}
}
if (viewBoxRect) {
var viewBoxTransform = makeViewBoxTransform(viewBoxRect, boundingRect.width, boundingRect.height);
var elRoot = root;
root = new Group();
root.add(elRoot);
elRoot.scale = viewBoxTransform.scale;
elRoot.position = viewBoxTransform.position;
}
root.setClipPath(new Rect({
shape: boundingRect.plain()
}));
return {
root: root,
boundingRect: boundingRect
};
}
module.exports = _default;

134
node_modules/echarts/lib/coord/geo/geoSourceManager.js generated vendored Normal file
View File

@ -0,0 +1,134 @@
/*
* 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 _config = require("../../config");
var __DEV__ = _config.__DEV__;
var _util = require("zrender/lib/core/util");
var each = _util.each;
var createHashMap = _util.createHashMap;
var mapDataStorage = require("./mapDataStorage");
var geoJSONLoader = require("./geoJSONLoader");
var geoSVGLoader = require("./geoSVGLoader");
var BoundingRect = require("zrender/lib/core/BoundingRect");
/*
* 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 loaders = {
geoJSON: geoJSONLoader,
svg: geoSVGLoader
};
var _default = {
/**
* @param {string} mapName
* @param {Object} nameMap
* @param {string} nameProperty
* @return {Object} source {regions, regionsMap, nameCoordMap, boundingRect}
*/
load: function (mapName, nameMap, nameProperty) {
var regions = [];
var regionsMap = createHashMap();
var nameCoordMap = createHashMap();
var boundingRect;
var mapRecords = retrieveMap(mapName);
each(mapRecords, function (record) {
var singleSource = loaders[record.type].load(mapName, record, nameProperty);
each(singleSource.regions, function (region) {
var regionName = region.name; // Try use the alias in geoNameMap
if (nameMap && nameMap.hasOwnProperty(regionName)) {
region = region.cloneShallow(regionName = nameMap[regionName]);
}
regions.push(region);
regionsMap.set(regionName, region);
nameCoordMap.set(regionName, region.center);
});
var rect = singleSource.boundingRect;
if (rect) {
boundingRect ? boundingRect.union(rect) : boundingRect = rect.clone();
}
});
return {
regions: regions,
regionsMap: regionsMap,
nameCoordMap: nameCoordMap,
// FIXME Always return new ?
boundingRect: boundingRect || new BoundingRect(0, 0, 0, 0)
};
},
/**
* @param {string} mapName
* @param {string} hostKey For cache.
* @return {Array.<module:zrender/Element>} Roots.
*/
makeGraphic: makeInvoker('makeGraphic'),
/**
* @param {string} mapName
* @param {string} hostKey For cache.
*/
removeGraphic: makeInvoker('removeGraphic')
};
function makeInvoker(methodName) {
return function (mapName, hostKey) {
var mapRecords = retrieveMap(mapName);
var results = [];
each(mapRecords, function (record) {
var method = loaders[record.type][methodName];
method && results.push(method(mapName, record, hostKey));
});
return results;
};
}
function mapNotExistsError(mapName) {}
function retrieveMap(mapName) {
var mapRecords = mapDataStorage.retrieveMap(mapName) || [];
return mapRecords;
}
module.exports = _default;

113
node_modules/echarts/lib/coord/geo/mapDataStorage.js generated vendored Normal file
View File

@ -0,0 +1,113 @@
/*
* 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 _config = require("../../config");
var __DEV__ = _config.__DEV__;
var _util = require("zrender/lib/core/util");
var createHashMap = _util.createHashMap;
var isString = _util.isString;
var isArray = _util.isArray;
var each = _util.each;
var assert = _util.assert;
var _parseSVG = require("zrender/lib/tool/parseSVG");
var parseXML = _parseSVG.parseXML;
/*
* 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 storage = createHashMap(); // For minimize the code size of common echarts package,
// do not put too much logic in this module.
var _default = {
// The format of record: see `echarts.registerMap`.
// Compatible with previous `echarts.registerMap`.
registerMap: function (mapName, rawGeoJson, rawSpecialAreas) {
var records;
if (isArray(rawGeoJson)) {
records = rawGeoJson;
} else if (rawGeoJson.svg) {
records = [{
type: 'svg',
source: rawGeoJson.svg,
specialAreas: rawGeoJson.specialAreas
}];
} else {
// Backward compatibility.
if (rawGeoJson.geoJson && !rawGeoJson.features) {
rawSpecialAreas = rawGeoJson.specialAreas;
rawGeoJson = rawGeoJson.geoJson;
}
records = [{
type: 'geoJSON',
source: rawGeoJson,
specialAreas: rawSpecialAreas
}];
}
each(records, function (record) {
var type = record.type;
type === 'geoJson' && (type = record.type = 'geoJSON');
var parse = parsers[type];
parse(record);
});
return storage.set(mapName, records);
},
retrieveMap: function (mapName) {
return storage.get(mapName);
}
};
var parsers = {
geoJSON: function (record) {
var source = record.source;
record.geoJSON = !isString(source) ? source : typeof JSON !== 'undefined' && JSON.parse ? JSON.parse(source) : new Function('return (' + source + ');')();
},
// Only perform parse to XML object here, which might be time
// consiming for large SVG.
// Although convert XML to zrender element is also time consiming,
// if we do it here, the clone of zrender elements has to be
// required. So we do it once for each geo instance, util real
// performance issues call for optimizing it.
svg: function (record) {
record.svgXML = parseXML(record.source);
}
};
module.exports = _default;

155
node_modules/echarts/lib/coord/geo/parseGeoJson.js generated vendored Normal file
View File

@ -0,0 +1,155 @@
/*
* 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 zrUtil = require("zrender/lib/core/util");
var Region = require("./Region");
/*
* 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.
*/
/**
* Parse and decode geo json
* @module echarts/coord/geo/parseGeoJson
*/
function decode(json) {
if (!json.UTF8Encoding) {
return json;
}
var encodeScale = json.UTF8Scale;
if (encodeScale == null) {
encodeScale = 1024;
}
var features = json.features;
for (var f = 0; f < features.length; f++) {
var feature = features[f];
var geometry = feature.geometry;
var coordinates = geometry.coordinates;
var encodeOffsets = geometry.encodeOffsets;
for (var c = 0; c < coordinates.length; c++) {
var coordinate = coordinates[c];
if (geometry.type === 'Polygon') {
coordinates[c] = decodePolygon(coordinate, encodeOffsets[c], encodeScale);
} else if (geometry.type === 'MultiPolygon') {
for (var c2 = 0; c2 < coordinate.length; c2++) {
var polygon = coordinate[c2];
coordinate[c2] = decodePolygon(polygon, encodeOffsets[c][c2], encodeScale);
}
}
}
} // Has been decoded
json.UTF8Encoding = false;
return json;
}
function decodePolygon(coordinate, encodeOffsets, encodeScale) {
var result = [];
var prevX = encodeOffsets[0];
var prevY = encodeOffsets[1];
for (var i = 0; i < coordinate.length; i += 2) {
var x = coordinate.charCodeAt(i) - 64;
var y = coordinate.charCodeAt(i + 1) - 64; // ZigZag decoding
x = x >> 1 ^ -(x & 1);
y = y >> 1 ^ -(y & 1); // Delta deocding
x += prevX;
y += prevY;
prevX = x;
prevY = y; // Dequantize
result.push([x / encodeScale, y / encodeScale]);
}
return result;
}
/**
* @alias module:echarts/coord/geo/parseGeoJson
* @param {Object} geoJson
* @param {string} nameProperty
* @return {module:zrender/container/Group}
*/
function _default(geoJson, nameProperty) {
decode(geoJson);
return zrUtil.map(zrUtil.filter(geoJson.features, function (featureObj) {
// Output of mapshaper may have geometry null
return featureObj.geometry && featureObj.properties && featureObj.geometry.coordinates.length > 0;
}), function (featureObj) {
var properties = featureObj.properties;
var geo = featureObj.geometry;
var coordinates = geo.coordinates;
var geometries = [];
if (geo.type === 'Polygon') {
geometries.push({
type: 'polygon',
// According to the GeoJSON specification.
// First must be exterior, and the rest are all interior(holes).
exterior: coordinates[0],
interiors: coordinates.slice(1)
});
}
if (geo.type === 'MultiPolygon') {
zrUtil.each(coordinates, function (item) {
if (item[0]) {
geometries.push({
type: 'polygon',
exterior: item[0],
interiors: item.slice(1)
});
}
});
}
var region = new Region(properties[nameProperty || 'name'], geometries, properties.cp);
region.properties = properties;
return region;
});
}
module.exports = _default;

78
node_modules/echarts/lib/coord/geo/prepareCustom.js generated vendored Normal file
View File

@ -0,0 +1,78 @@
/*
* 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 zrUtil = require("zrender/lib/core/util");
/*
* 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.
*/
function dataToCoordSize(dataSize, dataItem) {
dataItem = dataItem || [0, 0];
return zrUtil.map([0, 1], function (dimIdx) {
var val = dataItem[dimIdx];
var halfSize = dataSize[dimIdx] / 2;
var p1 = [];
var p2 = [];
p1[dimIdx] = val - halfSize;
p2[dimIdx] = val + halfSize;
p1[1 - dimIdx] = p2[1 - dimIdx] = dataItem[1 - dimIdx];
return Math.abs(this.dataToPoint(p1)[dimIdx] - this.dataToPoint(p2)[dimIdx]);
}, this);
}
function _default(coordSys) {
var rect = coordSys.getBoundingRect();
return {
coordSys: {
type: 'geo',
x: rect.x,
y: rect.y,
width: rect.width,
height: rect.height,
zoom: coordSys.getZoom()
},
api: {
coord: function (data) {
// do not provide "out" and noRoam param,
// Compatible with this usage:
// echarts.util.map(item.points, api.coord)
return coordSys.dataToPoint(data);
},
size: zrUtil.bind(dataToCoordSize, coordSys)
}
};
}
module.exports = _default;