/初始化繪制全國地圖配置
var option = {
backgroundColor: '#000',
title: {
text: 'Echarts3 中國地圖農村金融',
subtext: '三級科技下鄉',
link: 'http://www.cnblogs.com/sxz2008/',
left: 'center',
textStyle: {
color: '#fff',
fontSize: 16,
fontWeight: 'normal',
fontFamily: "Microsoft YaHei"
},
subtextStyle: {
color: '#ccc',
fontSize: 13,
fontWeight: 'normal',
fontFamily: "Microsoft YaHei"
}
},
tooltip: { //顯示懸浮窗口
trigger: 'item',
//使用這個函數返回懸浮內容
formatter:function(params){
//定義一個res變量來保存最終返回的字符結果,並且先把地區名稱放到里面
// var res='隨機數字'+'<br />';
var res=params.name+':'+'隨機數字'+'<br />';
var myseries=provinces;//省市區
for(var i=0;i<myseries.length;i++){
if(myseries[i].name==params.name){
res+=myseries[i].name+':'+myseries[i].value+'<br />';
}
}
//市區
for(var j=0;j<city.length;j++){
if(city[j].name==params.name){
res+=city[j].name+':'+city[j].value+'<br />';
}
}
//縣區
for(var k=0;k<area.length;k++){
if(area[k].name==params.name){
res+=area[k].name+':'+area[k].value+'<br />';
}
}
return res;
},
},
toolbox: {
show: true,
orient: 'vertical',
left: 'right',
top: 'center',
feature: {
dataView: {
readOnly: false
},
restore: {},
saveAsImage: {}
},
iconStyle: {
normal: {
color: '#fff'
}
}
},
visualMap: {
type: 'continuous', // 連續型
min: 0, // 值域最小值,必須參數
max: 1200, // 值域最大值,必須參數
calculable: true, // 是否啟用值域漫游
inRange: {
color: ['#50a3ba', '#eac736', '#d94e5d']
// 指定數值從低到高時的顏色變化
},
textStyle: {
color: '#fff' // 值域控件的文本顏色
}
},
animationDuration: 1000,
animationEasing: 'cubicOut',
animationDurationUpdate: 1000
};
使用echarts.js 改造git項目能夠省市區顯示具體內容;主要是json數據和formatter函數返回的值
