配置项如下
const dataAxis = ["2014.5", "2014.6", "2014.7", "2014.8", "2014.9", "2014.10", "2014.11", "2014.12", "2015.1", "2015.2", "2015.3", "2015.4", "2015.5", "2015.6", "2015.7", "2015.8", "2015.9", "2015.10", "2015.11", "2015.12", "2016.1", "2016.2", "2016.3", "2016.4", "2016.5", "2016.6", "2016.7", "2016.8", "2016.9", "2016.10", "2016.11", "2016.12", "2017.1", "2017.2", "2017.3", "2017.4"]
const dataBar = [38, 95, 69, 70, 72, 90, 54, 50, 77, 62, 69, 71, 85, 77, 69, 56, 74, 67, 74, 61, 85, 98, 98, 78, 94, 116, 77, 61, 80, 120, 104, 89, 95, 109, 160, 0]
option = {
tooltip: {
position: 'left',
formatter: 'Date:{b}<br />Article:{c}',
},
grid: {
left: 0,
right: 0,
top: 0,
bottom: this.isxAxis ? 40 : 20,
},
xAxis: {
data: dataAxis,
axisLabel: {
show: false,
textStyle: {
color: '#414b56',
},
},
axisTick: {
show: false,
},
axisLine: {
show: true,
lineStyle: {
color: 'rgba(121, 128, 135, 0.8)',
type: 'dashed',
},
},
splitLine: {
show: false,
},
splitArea: {
show: true,
interval: (function() {
var lastYear;
return (index, value) => {
if (value) {
const year = value.split('.', 1)[0];
var ignore = year === lastYear;
lastYear = year;
return !ignore;
} else {
return false
}
}
})()
},
z: 10,
},
yAxis: {
splitLine: {
show: false,
},
axisLine: {
show: false,
},
axisTick: {
show: false,
},
axisLabel: {
show: false,
},
},
series: [{
type: 'bar',
itemStyle: {
normal: {
color: '#99c868',
barBorderRadius: [3, 3, 0, 0],
},
emphasis: {
color: '#dce5d1',
barBorderRadius: [3, 3, 0, 0],
},
},
data: dataBar,
}, ],
};