<!DOCTYPE html> <head> <meta charset="utf-8"> <title>ECharts</title> </head> <body> <!-- 为ECharts准备一个具有大小(宽高)的Dom --> <div id="main" style="height:400px"></div> <!-- ECharts单文件引入 --> <script src="http://echarts.baidu.com/build/dist/echarts.js"></script> <script type="text/javascript"> // 路径配置 require.config({ paths: { echarts: 'http://echarts.baidu.com/build/dist' } }); // 使用 require( [ 'echarts', 'echarts/chart/line', 'echarts/chart/pie', 'echarts/chart/bar' ], function (ec) { // 基于准备好的dom,初始化echarts图表 var myChart = ec.init(document.getElementById('main')); option = { tooltip : { show: true, formatter: "{a} <br/>{b} : {c} ({d}%)" }, legend: { orient : 'vertical', x : 'left', data:['组织生活正常化','凝聚力','战斗力'] }, toolbox: { show : true }, calculable : true, series : [ { name:'访问来源', type:'pie', startAngle: 90, center : ['75%', 200], radius : [80, 120], itemStyle : { normal : { label : { show : true }, labelLine : { show : true } }, emphasis : { color: (function (){ var zrColor = require('zrender/tool/color'); return zrColor.getRadialGradient( 650, 200, 80, 650, 200, 120, [[0, 'rgba(255,255,0,1)'],[1, 'rgba(255,0,0,1)']] ) })(), label : { show : true, position : 'center', formatter : "{d}%", textStyle : { color : 'red', fontSize : '30', fontFamily : '微软雅黑', fontWeight : 'bold' } } } }, data:[ {value:335, name:'组织生活正常化', itemStyle : { normal : { borderWidth: 4, borderColor: '#ffffff', } }}, { value:30, name:'正常化未完成', itemStyle : { normal : { borderWidth: 0, label : { show : false }, labelLine : { show : false }, color:'#2F4F4F' }, emphasis : { label : { show : true }, labelLine : { show : false }, color:'#2F4F4F' } } }, {value:310, name:'凝聚力', itemStyle : { normal : { borderWidth: 4, borderColor: '#ffffff', } }}, { value:50, name:'凝聚力未完成', itemStyle : { normal : { borderWidth: 0, label : { show : false }, labelLine : { show : false }, color:'#2F4F4F' }, emphasis : { label : { show : true }, labelLine : { show : false }, color:'#2F4F4F' } } }, {value:234, name:'战斗力', itemStyle : { normal : { borderWidth: 4, borderColor: '#ffffff', } }}, { value:40, name:'战斗力未完成', itemStyle : { normal : { borderWidth: 0, label : { show : false }, labelLine : { show : false }, color:'#2F4F4F' }, emphasis : { label : { show : true }, labelLine : { show : false }, color:'#2F4F4F' } } } ] } ] }; // 为echarts对象加载数据 myChart.setOption(option); } ); </script> </body>
访问效果以下:javascript