ECharts餅圖實例

ECharts餅圖實例

1、引入jQuery的js文件

2、引入echarts的js文件

test.html頁面

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>AzzanTest</title>
<script src="jQuery/jquery-1.9.1.min.js"></script>
<script src="echarts/echarts.min.js"></script>
</head>
<body>
<div id="echartsPie" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
	var echartsPie;
	var json = [
	            {value:30,name:'高圓圓'},
	            {value:26,name:'趙麗穎'},
	            {value:24,name:'江萊'}
	            ];
	var option = {
		    title : {
		        text: '女神年齡分佈',
		        subtext: '獨家報道',
		        x:'center'
		    },
		    tooltip : {
		        trigger: 'item',
		        formatter: "{a} <br/>{b} : {c} 歲"
		    },
		    legend: {
		        orient : 'vertical',
		        x : 'left',
		        data:['高圓圓','趙麗穎','江萊']
		    },
		    toolbox: {
		        show : true,
		        feature : {
		            mark : {show: true},
		            dataView : {show: true, readOnly: false},
		            magicType : {
		                show: true, 
		                type: ['pie', 'funnel'],
		                option: {
		                    funnel: {
		                        x: '25%',
		                        width: '50%',
		                        funnelAlign: 'left',
		                        max: 1548
		                    }
		                }
		            },
		            restore : {show: true},
		            saveAsImage : {show: true}
		        }
		    },
		    calculable : true,
		    series : [
		        {
		            name:'女神',
		            type:'pie',
		            radius : '55%',//餅圖的半徑大小
		            center: ['50%', '60%'],//餅圖的位置
		            data:json
		        }
		    ]
		}; 
	
	echartsPie = echarts.init(document.getElementById('echartsPie'));
	$(function(){
		echartsPie.setOption(option);
		
	});	                    
</script>
</body>
</html>

效果圖:





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章