option = {
title: {
text: '折线图堆叠',
top: '10%',
left: 'center',
},
legend: { //展现了不同系列的图例(标记,颜色和名字)。可以通过点击图例控制哪些系列不显示。
data:['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
},
grid: { //图表在容器中的位置和大小
left: '5%',
right: '4%',
bottom: '3%',
width:'80%',
containLabel: true
},
tooltip: { //鼠标滑过数据项触发提示框
formatter: 'Group {b}: ({c})' //b为x轴数据,c为y轴数据
},
xAxis: {
show:true, //false:不显示x轴
type: 'category',
boundaryGap: true, //false:坐标轴两边不留边距
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] //X轴数据
},
yAxis: {
show:true, //false:不显示y轴
type: 'value',
splitLine: {show: false}, //图表不显示横线
},
series: [{
data: [820, 932, 901, 934, 1290, 1330, 1320], //y轴数值
showSymbol: true, //false:不显示折线图上的点
smooth: true, //折线图曲线平滑
type: 'bar', //bar为柱形图,line为折线图
//areaStyle: {}, 折线图填充背景色
barWidth: '40px',// 设置柱形宽度
itemStyle: {
normal: {
color: '#000', // 定义柱形折线的颜色
barBorderRadius: [0, 5, 5, 0], // 定义柱形的圆角
barGap: '-100%', //设置两个柱形重合
label: { //柱形折线上方显示的数值
show:true,
position: 'top', //位置
textStyle: {
color: '#333'
},
formatter: function(params) { //自定义数值格式
if(params.value){
return params.value + '%'
}else{
return ''
}
}
}
}
}
}]
}