代码115行,如果柱形图是颜色渐变,那么缩放功能将会报错
配置项如下
// Echart - bar & line
var axisY = {
axisLabel: {
show: false,
},
axisLine: {
show: false
},
axisTick: {
show: false
},
splitArea: {
show: false
},
splitLine: {
show: false
}
}
var axisX = {
axisLine: {
show: false,
},
axisTick: {
show: false
},
splitArea: {
show: false
},
splitLine: {
show: false
}
}
var barArr = [201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220];
var lineArr = getRandomm(20, 100);
var barArr_val = getRandomm(20, 10000);
var lineArr_val = getRandomm(20, 1000);
option = {
title: {},
xAxis: [{
type: 'category',
boundaryGap: true,
data: barArr
}
],
dataZoom: [{
show:false,
type: 'slider',
xAxisIndex: 0,
filterMode: 'empty',
start: 0,
end: 20
}, {
show:false,
type: 'inside',
xAxisIndex: 0,
filterMode: 'empty',
start: 20,
end: 50
}],
yAxis: [{
type: 'value',
scale: true,
},
{
type: 'value',
scale: true,
}
],
series: [{
name: '折线图',
type: 'line',
label: {
normal: {
show: true,
position: [-6, -24],
textStyle: {
color: "#ee5b16", //文字
fontSize: 12
}
}
},
itemStyle: {
normal: {
show: true,
borderWidth: 3,
color: "#f8be41" // 圆点
}
},
lineStyle: {
normal: {
color: "#f7bd42" // 线
}
},
data: barArr_val
}, {
name: '柱形图',
type: 'bar',
yAxisIndex: 1,
label: {
normal: {
show: true,
position: [0, -24],
textStyle: {
color: "#0095d1", //文字
fontSize: 12
}
}
},
barCategoryGap:"50%",
itemStyle: {
normal: {
color: '#71d6f5'
// color: new echarts.graphic.LinearGradient(
// 0, 0, 0, 1, [
// { offset: 0, color: '#71d6f5' },
// { offset: 1, color: '#b1f1fc' }
// ]
// )
}
},
data: lineArr_val
}]
};
// 随机数
function getRandomm(i, max) {
var arr = [];
while (i > 0) {
var num = Math.floor(Math.random() * max + 1);
arr.push(num);
i--;
}
return arr;
}