html:
<div class="mapBg">
<div class="china_map" id="china_map"></div>
</div>
<!-- 全国地图 end -->
+++++++++++++++++++++++++
js:
var mapType = ['china', '广东', '青海', '四川', '海南', '陕西', '甘肃', '云南', '湖南', '湖北', '黑龙江', '贵州', '山东', '江西', '河南', '河北', '山西', '安徽', '福建', '浙江', '江苏', '吉林', '辽宁', '台湾', '新疆', '广西', '宁夏', '内蒙古', '西藏', '北京', '天津', '上海', '重庆', '香港', '澳门'];
var mapTypeD = 'china';
var chartData = new Array();
//var xx;//地图值域
$(function(){
require.config({
paths: {
echarts: 'html/data/js/dist'
}
});
require(['echarts', 'echarts/chart/map', ], query);
});
var lock = false;
function FunDraw0() {
var data = mapData;
myChart = echarts.init(document.getElementById('china_map'));
var series = [],d=[];
var min = 0,max = 0;
for (var i = 0; i < data.length; i++) {
var o = data[i];
if(o.datavalue<min){
min = o.datavalue;
}
if(o.datavalue>max){
max = o.datavalue;
}
var f = Math.round(o.datavalue*100)/100;
var s = f.toString();
var rs = s.indexOf('.');
if (rs < 0) {
rs = s.length;
s += '.';
}
while (s.length <= rs + 2) {
s += '0';
}
o.datavalue = s;
d.push({
name: o.areaName.replace("市","").replace("省","").replace("自治区","").replace("壮族","").replace("回族","").replace("维吾尔",""),
value: o.datavalue
});
}
series.push({
name: "",
selectedMode: 'single',
type: 'map',
mapType: 'china',
roam: false,
itemStyle:{
normal:{label:{show:true}},
emphasis:{label:{show:true}}
},
data: d
});
myChart.on('mapSelected',function(param) {
if(lock){
return;
}
if(param.target=="南海诸岛" || param.target=="台湾" || param.target=="香港" || param.target=="澳门"){
return;
}
prevBuy(function() {
lock = true;
$.ajax({
type: "post",
url: "data/newmap/addSys.do",
dataType: "json",
success: function(data) {
if(data){
window.location = $("#path").val()+"data/newmap/getQueryInfo.do?areaName="+encodeURI(param.target)+"&queryId="+data;
}else{
lock = false;
}
}
});
});
});
option = {
title: {
text: '',
subtext: ''
},
tooltip : {
trigger: 'item'
,formatter: function (data,ticket,callback) {
return data.data.value!=null && data.data.value!=undefined && data.data.value!="-"?data.data.value.toFixed(2):"暂无数据";
}
},
dataRange: {
show: false,
min: min,
max: max*2*series.length,
text: ['高', '低'],
calculable: true,
x: '40px',
y: '450px'
},
toolbox: {
show: false,
orient: 'vertical',
x: 'right',
y: 'center',
feature: {
mark: {
show: true
},
dataView: {
show: true,
readOnly: false
},
restore: {
show: true
},
saveAsImage: {
show: true
}
}
},
roamController: {
show: false,
x: 'right',
mapTypeControl: {
'china': true
}
},
series: series
};
myChart.setOption(option);
}