Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function (json: any) {
const geoJson = decode(json);
// @ts-ignore
const _features = echarts.util.map(
// @ts-ignore
echarts.util.filter(geoJson.features,
(featureObj: { geometry: { coordinates: { length: number } }; properties: any }) =>
// Output of mapshaper may have geometry null
featureObj.geometry && featureObj.properties && featureObj.geometry.coordinates.length > 0),
(featureObj: { properties: any; geometry: any }) => {
const properties = featureObj.properties;
const geo = featureObj.geometry;
const coordinates = geo.coordinates;
const geometries = [];
if (geo.type === 'Polygon') {
geometries.push(coordinates[0]);
}
if (geo.type === 'MultiPolygon') {
// @ts-ignore
echarts.util.each(coordinates, (item: any[]) => {
if (item[0]) {
geometries.push(item[0]);
(featureObj: { properties: any; geometry: any }) => {
const properties = featureObj.properties;
const geo = featureObj.geometry;
const coordinates = geo.coordinates;
const geometries = [];
if (geo.type === 'Polygon') {
geometries.push(coordinates[0]);
}
if (geo.type === 'MultiPolygon') {
// @ts-ignore
echarts.util.each(coordinates, (item: any[]) => {
if (item[0]) {
geometries.push(item[0]);
}
});
}
return {
properties,
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: geometries,
},
};
},
);
},
},
tooltip: {
trigger: 'axis',
},
};
const inflationStartIdx = 14;
const inflationYearCount = 6;
const inflationYearStart = '2006';
const xAxisCategory: any[] = [];
for (let i = 0; i < inflationYearCount; i++) {
xAxisCategory.push(`${+inflationYearStart + i}`);
}
// @ts-ignore
echarts.util.each(rawData, (dataItem: any, idx: number | string) => {
const coordinates = geoCoordMap[dataItem[0]];
idx += '';
const inflationData = [];
for (let k = 0; k < inflationYearCount; k++) {
inflationData.push(dataItem[inflationStartIdx + k]);
}
option.xAxis.push({
id: idx,
gridId: idx,
type: 'category',
name: dataItem[0],
nameStyle: {
color: '#ddd',
fontSize: 12,
align: {
options: {
left: 'left',
center: 'center',
right: 'right'
}
},
verticalAlign: {
options: {
top: 'top',
middle: 'middle',
bottom: 'bottom'
}
},
position: {
options: echarts.util.reduce(posList, (map, pos) => {
map[pos] = pos
return map
}, {})
},
distance: {
min: 0,
max: 100
}
},
config: {
rotate: 90,
align: 'left',
verticalAlign: 'middle',
position: 'insideBottom',
distance: 15
}
function formatGeoJSON (json) {
var geoJson = decode(json);
var _features = echarts.util.map(echarts.util.filter(geoJson.features, function (featureObj) {
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(coordinates[0]);
}
if (geo.type === 'MultiPolygon') {
echarts.util.each(coordinates, function (item) {
if (item[0]) {
geometries.push(item[0]);
}
});
}
}), function (featureObj) {
var properties = featureObj.properties;
var geo = featureObj.geometry;
var coordinates = geo.coordinates;
var geometries = [];
if (geo.type === 'Polygon') {
geometries.push(coordinates[0]);
}
if (geo.type === 'MultiPolygon') {
echarts.util.each(coordinates, function (item) {
if (item[0]) {
geometries.push(item[0]);
}
});
}
return {
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': geometries
},
'properties': properties
};
});
return {
function getPieSeries(scatterData, chart) {
return echarts.util.map(scatterData, function (item, index) {
var center = chart.convertToPixel('calendar', item);
return {
id: index + 'pie',
type: 'pie',
center: center,
label: {
normal: {
formatter: '{c}',
position: 'inside'
}
},
radius: pieRadius,
data: [
{name: '工作', value: Math.round(Math.random() * 24)},
{name: '娱乐', value: Math.round(Math.random() * 24)},
{name: '睡觉', value: Math.round(Math.random() * 24)}
function (featureObj) {
let properties = featureObj.properties;
let geo = featureObj.geometry;
let coordinates = geo.coordinates;
let geometries = [];
if (geo.type === 'Polygon') {
geometries.push(coordinates[0]);
}
if (geo.type === 'MultiPolygon') {
echarts.util.each(coordinates, function (item) {
if (item[0]) {
geometries.push(item[0]);
}
});
}
return {
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: geometries
},
properties: properties
};
}
);
graphic: echarts.util.map(this.option.series[0].data, (item, dataIndex) => {
const tmpPos = this.myChart.convertToPixel({ seriesIndex: 0 }, [item.x, item.y]);
return {
type: 'circle',
id: dataIndex,
position: tmpPos,
shape: {
cx: 0,
cy: 0,
r: 20,
},
invisible: true,
draggable: true,
ondrag: echarts.util.curry(this.onPointDragging(), dataIndex),
z: 100,
};
}),
});