前幾天做的地圖,一直提示錯誤,索性就不做了,昨天突然在弄了一下,就出來,真是不可思議,加油,慢慢來
在echart官網上下載地圖的插件,引用
<script type="text/javascript" src="js/jquery-easyui-1.5/jquery.min.js"></script>
<script src="js/echarts.js"></script>
<script src="http://echarts.baidu.com/asset/map/js/china.js"></script>
<script src="js/echart.js"></script>
粘貼我自己寫的一個例子
$(document).ready(function () {
// 基於準備好的dom,初始化echarts實例
var myChart3 = echarts.init(document.getElementById('main'));
option = {
title : {
text: '各地區上交數據情況',
subtext: '實時統計',
x:'center'
},
tooltip : {
trigger: 'item'
},
legend: {
orient: 'vertical',
x:'left',
data:['上交不合格區縣數','上交合格區縣數','上交總區縣數']
},
dataRange: {
min: 0,
max: 50,
x: 'left',
y: 'bottom',
text:['高','低'], // 文本,默認爲數值文本
calculable : true
},
toolbox: {
show: true,
orient : 'vertical',
x: 'right',
y: 'center',
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
restore : {show: true},
saveAsImage : {show: true}
}
},
roamController: {
show: true,
x: 'right',
mapTypeControl: {
'china': true
}
},
series : [
{
name: '上交不合格區縣數',
type: 'map',
mapType: 'china',
roam: false,
itemStyle:{
normal:{label:{show:true}},
emphasis:{label:{show:true}}
},
data:[
{name: '河北',value: count3bh},
{name: '遼寧',value: count8bh},
{name: '黑龍江',value:count1bh},
{name: '湖南',value: count2bh},
{name: '甘肅',value: count5bh},
{name: '內蒙古',value: count7bh},
{name: '吉林',value: count4bh},
{name: '貴州',value:count6bh},
]
},
{
name: '上交合格區縣數',
type: 'map',
mapType: 'china',
itemStyle:{
normal:{label:{show:true}},
emphasis:{label:{show:true}}
},
data:[
{name: '河北',value: count3h},
{name: '遼寧',value: count8h},
{name: '黑龍江',value:count1h},
{name: '湖南',value: count2h},
{name: '甘肅',value: count5h},
{name: '內蒙古',value: count7h},
{name: '吉林',value: count4h},
{name: '貴州',value:count6h},
]
},
]
};
myChart3.setOption(option);
});