項目中使用echarts進行圖表的展示,當數(shù)據(jù)量很大的時候伞插,需要配置dataZoom進行圖表可滾動割粮,但是數(shù)據(jù)都擠在一起,嚴重影響了圖表的美觀性媚污,所以動態(tài)配置dataZoom的start 舀瓢、 end屬性
//設置可以滾動
dataZoom: [
{
type: 'inside',
start: this.startLength,
end: 100
},
{moveOnMouseWheel: false,}
],
在圖表option設置前,進行計算startLength的值
//判斷數(shù)據(jù)量耗美,進行不同滾動條的設置
if (this.chartAllData.Measures.length > 50) {
this.startLength = 100 - (25/this.chartAllData.Measures.length * 100)
} else {
this.startLength = 0;
}
這種設置京髓,在數(shù)據(jù)動態(tài)切換時,隨著this.startLength的變化商架,會出現(xiàn)折線圖發(fā)生部分連接錯亂問題堰怨,后發(fā)現(xiàn)解決方法如下:
//設置可以滾動
dataZoom: [
{
type: 'inside',
start: this.startLength,
end: 100,
filterMode: 'empty'
},
{moveOnMouseWheel: false,}
],
添加filterMode屬性為 empty即可解決該問題