echarts多條折線圖和柱狀圖實現
阿新 • • 發佈:2019-01-06
// 基於準備好的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
}]
});});*/