股东会电饭锅 回复 股东会电饭锅(2018-12-29 06:59:49 )
对 #1版本 说:
var uploadedDataURL = "/asset/get/s/data-1482909818685-H17FOkZSl.json";
myChart.showLoading();
$.getJSON(uploadedDataURL, function(geoJson) {
echarts.registerMap('hunan', geoJson);
myChart.hideLoading();
var geoCoordMap = {
'长沙市': [113.21, 28.15],
'株洲市': [113.49, 26.83],
'湘潭市': [112.51, 27.57],
'岳阳市': [113.19, 29.00],
'常德市': [111.51, 29.02],
'娄底市': [111.59, 27.74],
'邵阳市': [111.08, 27.00],
'益阳市': [111.80, 28.36],
'衡阳市': [112.57, 26.53],
'张家界市': [110.59, 29.28],
'怀化市': [109.98, 27.43],
'永州市': [111.67, 25.90],
'郴州市': [113.22, 25.76],
'湘西土家族苗族自治州': [109.79, 28.58],
}
var data = [{
name: '长沙市',
value: 1
},
{
name: '株洲市',
value: 2
},
{
name: '湘潭市',
value: 3
},
{
name: '娄底市',
value: 4
},
{
name: '岳阳市',
value: 5
},
{
name: '邵阳市',
value: 6
},
{
name: '益阳市',
value: 7
},
{
name: '衡阳市',
value: 8
},
{
name: '常德市',
value: 9
},
{
name: '张家界市',
value: 10
},
{
name: '怀化市',
value: 11
},
{
name: '永州市',
value: 12
},
{
name: '郴州市',
value: 13
},
{
name: '湘西土家族苗族自治州',
value: 14
}
];
var convertData = function(data) {
var res = [];
for (var i = 0; i < data.length; i++) {
var geoCoord = geoCoordMap[data[i].name];
if (geoCoord) {
res.push({
name: data[i].name,
value: geoCoord.concat(data[i].value)
});
}
}
return res;
};
option = {
title: {
text: 'xxxxxxxxxx',
subtext: '',
x: 'center',
textStyle: {
color: '#ccc'
}
},
tooltip: {
trigger: 'item',
formatter: function(params) {
if (typeof(params.value)[2] == "undefined") {
return params.name + ' : ' + params.value;
} else {
return params.name + ' : ' + params.value[2];
}
}
},
geo: {
show: true,
map: 'hunan',
label: {
normal: {
show: false
},
emphasis: {
show: false,
}
},
roam: true,
itemStyle: {
normal: {
areaColor: '#031525',
borderColor: '#3B5077',
},
emphasis: {
areaColor: '#2B91B7',
}
}
},
series: [{
name: 'credit_pm2.5',
type: 'scatter',
coordinateSystem: 'geo',
data: convertData(data),
symbolSize: function(val) {
return val[2] / 10;
},
label: {
normal: {
formatter: '{b}',
position: 'right',
show: true
},
emphasis: {
show: true
}
},
itemStyle: {
normal: {
color: '#05C3F9'
}
}
},
{
type: 'map',
map: 'hunan',
geoIndex: 0,
aspectScale: 0.75, //长宽比
showLegendSymbol: false, // 存在legend时显示
label: {
normal: {
show: false
},
emphasis: {
show: false,
textStyle: {
color: '#fff'
}
}
},
roam: true,
itemStyle: {
normal: {
areaColor: '#031525',
borderColor: '#3B5077',
},
emphasis: {
areaColor: '#2B91B7'
}
},
animation: false,
data: data
},
{
name: '',
type: 'scatter',
coordinateSystem: 'geo',
symbol: 'pin',
symbolSize: 50,
label: {
normal: {
formatter: '{@[2]}',
show: true,
textStyle: {
color: '#fff',
fontSize: 12,
}
}
},
itemStyle: {
normal: {
color: '#F62157', //标志颜色
}
},
zlevel: 6,
data: convertData(data),
},
]
};
myChart.setOption(option);
});