參考連接:echarts官網:http://echarts.baidu.com/
原型圖(效果圖):javascript
代碼:html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <!-- 折線統計圖 --> <div class="row"> <div id="main" style="width: 900px; height: 350px; margin-top:80px;"></div> </div> </body> <script src="js/echarts/echarts.min.js" type="text/javascript"></script> <script src="http://code.jquery.com/jquery-1.8.0.min.js"></script> <script type="text/javascript"> // 基於準備好的dom,初始化echarts實例 var myChart = echarts.init(document.getElementById('main')); // 指定圖表的配置項和數據 myChart.setOption({ title: { text: '堆疊區域圖' }, tooltip: { trigger: 'axis', axisPointer: { type: 'cross', label: { backgroundColor: '#6a7985' } } }, legend: { data: ['SA服務', '等號', '機修', '鈑金', '噴漆', '總檢', '洗車', '滯留'] }, toolbox: { feature: { saveAsImage: {} } }, grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, xAxis: [{ type: 'category', boundaryGap: false, data: ['10.1', '10.2', '10.3', '10.4', '10.5', '10.6', '10.7'] }], yAxis: [{ type: 'value' }], series: [{ name: 'SA服務', type: 'line', stack: '總量', areaStyle: { normal: {} }, data: [120, 132, 101, 134, 90, 230, 210] }, { name: '等號', type: 'line', stack: '總量', areaStyle: { normal: {} }, data: [220, 182, 191, 234, 290, 330, 310] }, { name: '機修', type: 'line', stack: '總量', areaStyle: { normal: {} }, data: [150, 232, 101, 154, 190, 330, 410] }, { name: '鈑金', type: 'line', stack: '總量', areaStyle: { normal: {} }, data: [320, 332, 301, 334, 190, 330, 320] }, { name: '噴漆', type: 'line', stack: '總量', areaStyle: { normal: {} }, data: [310, 312, 301, 334, 390, 330, 320] }, { name: '總檢', type: 'line', stack: '總量', areaStyle: { normal: {} }, data: [320, 332, 311, 334, 390, 330, 320] }, { name: '洗車', type: 'line', stack: '總量', areaStyle: { normal: {} }, data: [320, 332, 101, 334, 390, 310, 320] }, { name: '滯留', type: 'line', stack: '總量', label: { normal: { show: true, position: 'top' } }, areaStyle: { normal: {} }, data: [820, 932, 901, 934, 1290, 1330, 1320] } ] }); /* // 異步加載數據 $.get('data.json').done(function (data) { // 填入數據 myChart.setOption({ xAxis: { data: data.categories }, series: [{ // 根據名字對應到相應的系列 name: '銷量', data: data.data }] });});*/ </script> </html>
橫向柱狀圖:java
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <!-- 柱狀統計圖 --> <div class="row"> <div id="main" style="width: 900px; height: 350px; margin-top:80px;"></div> </div> </body> <script src="../../js/echarts/echarts.min.js" type="text/javascript"></script> <script src="http://code.jquery.com/jquery-1.8.0.min.js"></script> <script type="text/javascript"> // 基於準備好的dom,初始化echarts實例 var myChart = echarts.init(document.getElementById('main')); // 指定圖表的配置項和數據 myChart.setOption({ title: { text: '平均耗時(分鐘)', }, tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, legend: { /* data: [ '2012年']*/ }, grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, xAxis: { type: 'value', boundaryGap: [0, 0.01] }, yAxis: { type: 'category', data: ['SA服務', '洗車', '總檢', '噴漆', '鈑金', '機修', '等號'] }, series: [ { name: '2012年', type: 'bar', itemStyle: { normal: { color: '#a8bcd4' } }, data: [10, 20, 31, 14, 11, 67] } ] }); </script> </html>