參考鏈接:echarts官網(wǎng):http://echarts.baidu.com/
原型圖(效果圖):
代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<!-- 折線統(tǒng)計圖 -->
<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">
// 基于準(zhǔn)備好的dom倡勇,初始化echarts實例
var myChart = echarts.init(document.getElementById('main'));
// 指定圖表的配置項和數(shù)據(jù)
myChart.setOption({
title: {
text: '堆疊區(qū)域圖'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
legend: {
data: ['SA服務(wù)', '等號', '機(jī)修', '鈑金', '噴漆', '總檢', '洗車', '滯留']
},
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服務(wù)',
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: '機(jī)修',
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]
}
]
});
/* // 異步加載數(shù)據(jù)
$.get('data.json').done(function (data) {
// 填入數(shù)據(jù)
myChart.setOption({ xAxis: { data: data.categories }, series: [{
// 根據(jù)名字對應(yīng)到相應(yīng)的系列
name: '銷量',
data: data.data
}]
});});*/
</script>
</html>
橫向柱狀圖:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<!-- 柱狀統(tǒng)計圖 -->
<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">
// 基于準(zhǔn)備好的dom吃溅,初始化echarts實例
var myChart = echarts.init(document.getElementById('main'));
// 指定圖表的配置項和數(shù)據(jù)
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服務(wù)', '洗車', '總檢', '噴漆', '鈑金', '機(jī)修', '等號']
},
series: [
{
name: '2012年',
type: 'bar',
itemStyle: {
normal: {
color: '#a8bcd4'
}
},
data: [10, 20, 31, 14, 11, 67]
}
]
});
</script>
</html>
原文作者:祈澈姑娘
原文鏈接:http://www.reibang.com/u/05f416aefbe1
創(chuàng)作不易市怎,轉(zhuǎn)載請告知
90后前端妹子犀填,愛編程,愛運營超升,愛折騰入宦。
堅持總結(jié)工作中遇到的技術(shù)問題,堅持記錄工作中所所思所見廓俭,歡迎大家一起探討交流云石。