let option = {
tooltip: {
trigger: 'item',
axisPointer: {
type: 'cross',
},
label: {
backgroundColor: '#6a7985'
},
formatter: function(params) {
return params.name + '<br>' + '<span style="font-size: 14px; color: #000000;">销售值 ' + params.value + '</span>'
},
},
grid: {
left: '8%',
right: '8%',
bottom: '10%',
containLabel: true
},
xAxis: {
type: 'category',
boundaryGap: ['30%', '30%'],
axisLabel: {
show: true,
color: '#000000',
formatter: (val) => {
return this.dataDute(val);
}
},
axisLine: {
show: false,
lineStyle: {
color: '#C9C9C9',
length: 10
}
},
axisTick: {
show: true,
alignWithLabel: true,
interval: 0
},
data: ['2016-10-01','2016-10-02','2016-10-03','2016-10-04','2016-10-05','2016-10-06','2016-10-07','2016-10-08','2016-10-09','2016-10-10',
'2016-10-11','2016-10-12','2016-10-13','2016-10-14','2016-10-15','2016-10-16','2016-10-17','2016-10-18','2016-10-19','2016-10-20',
'2016-10-21','2016-10-22','2016-10-23','2016-10-24','2016-10-25','2016-10-26','2016-10-27','2016-10-28','2016-10-29','2016-10-30','2016-10-31'],
},
yAxis: {
type: 'value'
},
series: [
{
data: [820, 932, 901, 934, 1290, 1330, 1320,320, 332, 301, 334, 390, 330, 320,150, 232, 201, 154, 190, 330, 410,220, 182, 191, 234, 290, 330, 310,600,763,567],
type: 'line',
symbolSize: 6,
label: {
show: true,
position: 'top',
fontSize: 14,
color: '#000000',
distance: 10,
fontWeight: 400,
formatter: (params) => {
return params.dataIndex % 3 === 0 ? params.value : '';
}
},
emphasis: {
focus: 'series',
itemStyle: {
symbolSize: 8,
}
}
}
]
};
X轴展示日期处理
dataDute(value) {
let str = '';
let df = value.split('-')[0],
dy = df.substr(2),
monthDay = value.split('-')[1],
day = value.split('-')[2];
str = monthDay+'/'+day;
return str;
},