效果图如下:
refreshDraw()方法保证,数据改变后,重新绘制折线图,否则不会刷新数据
methods: {
getEchartData() {
let eChart = this.$echarts.init(document.getElementById('eChart'));
eChart.setOption({
legend: {show: true},
grid: {
show: false,
containLabel: false,
left: 0, //距离画布左侧距离,有默认值
right: 0,//同上
top: '25px',//同上
bottom: '5px',//同上
borderColor: '#E1E5EB',
tooltip: { //提示框的显隐
show: false
}
},
xAxis: { //横坐标配置
type: 'category',
scale: true,
splitLine: {
show: true,
},
axisLine: {
show: false,
},
boundaryGap: true,
},
yAxis: {//纵坐标配置
show: true,
type: 'value',
scale: false,
axisLine: {
show: false,
},
axisTick: {
show: false,
},
minorTick: {
show: false,
},
splitLine: {
show: true,
},
axisLabel: {
formatter: function () {
return '';
}
},
minInterval: 20,//最小值
interval: 20,
max: 100,//纵坐标最大值
},
series: [
{
data: this.LineList,//数据
type: 'line',
symbol: 'circle',
itemStyle: {
color: this.color,//动态配置折现颜色
},
symbolSize: 10,
label: {
show: true,
color: '#5E5A72',
fontSize: 8,
z: 3,
formatter: function (val) {
return val.value + '分';
}
}
},
]
})
},
refreshDraw() {
this.show = false;
let _this = this;
setTimeout(function () {
_this.show = true;
_this.$nextTick(() => {
_this.getEchartData();
});
},400)
}
}