百度 echarts

中国各省份渐变色,源码主要来自echarts网站

echarts_chinamap.png

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ECharts</title>
</head>

<body>
<div id="mainMap" style="width:750px;height:530px;border:1px solid #ccc;padding:10px;"></div>
</body>

<script src="http://echarts.baidu.com/build/echarts-plain.js"></script>
<script src="http://echarts.baidu.com/build/echarts-plain-map.js"></script>
<script type="text/javascript">
var chart_id = 'mainMap';
var chart_opt = {
title : {
text: 'sometitle',
subtext: 'some subtitle',
x:'center'
},
tooltip : {
trigger: 'item'
},
legend: {
orient: 'vertical',
x:'left',
data:['somedata']
},
dataRange: {
min: 0.000000000001,
max: 1,
text:['优','差'],
color : ["#2fe589", "#f15501"],
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}
}
},
series : [
{
name: 'somedata',
type: 'map',
mapType: 'china',
itemStyle:{
normal:{label:{show:true}},
emphasis:{label:{show:true}}
},
data:[
{name: '北京',value: Math.round(Math.random()*1)},
{name: '天津',value: Math.round(Math.random()*1)},
{name: '上海',value: Math.round(Math.random()*1)},
{name: '重庆',value: Math.round(Math.random()*1)},
{name: '河北',value: Math.round(Math.random()*1)},
{name: '河南',value: Math.round(Math.random()*1)},
{name: '云南',value: Math.round(Math.random()*1)},
{name: '辽宁',value: Math.round(Math.random()*1)},
{name: '黑龙江',value: Math.round(Math.random()*1)},
{name: '湖南',value: Math.round(Math.random()*1)},
{name: '安徽',value: Math.round(Math.random()*1)},
{name: '山东',value: Math.round(Math.random()*1)},
{name: '新疆',value: Math.round(Math.random()*1)},
{name: '江苏',value: Math.round(Math.random()*1)},
{name: '浙江',value: Math.round(Math.random()*1)},
{name: '江西',value: Math.round(Math.random()*1)},
{name: '湖北',value: Math.round(Math.random()*1)},
{name: '广西',value: Math.round(Math.random()*1)},
{name: '甘肃',value: Math.round(Math.random()*1)},
{name: '山西',value: Math.round(Math.random()*1)},
{name: '内蒙古',value: Math.round(Math.random()*1)},
{name: '陕西',value: Math.round(Math.random()*1)},
{name: '吉林',value: Math.round(Math.random()*1)},
{name: '福建',value: Math.round(Math.random()*1)},
{name: '贵州',value: Math.round(Math.random()*1)},
{name: '广东',value: Math.round(Math.random()*1)},
{name: '青海',value: Math.round(Math.random()*1)},
{name: '西藏',value: Math.round(Math.random()*1)},
{name: '四川',value: Math.round(Math.random()*1)},
{name: '宁夏',value: Math.round(Math.random()*1)},
{name: '海南',value: Math.round(Math.random()*1)},
{name: '台湾',value: Math.round(Math.random()*1)},
{name: '香港',value: Math.round(Math.random()*1)},
{name: '澳门',value: Math.round(Math.random()*1)}
]
}
]
};
var myChart2 = echarts.init(document.getElementById(chart_id));
myChart2.setOption(chart_opt);
</script>
</html>

阿里 datavjs

example里的chinamap有几个中国地图的例子,很不错。

注意要放到web server下,通过url才能正常访问,直接文件夹解压不行。



blog comments powered by Disqus

Published

24 June 2013

Tags