Commit 1aa7eb5c authored by leon's avatar leon

feat:dataZoom keep start and end

parent 9dc543b0
...@@ -225,19 +225,21 @@ ...@@ -225,19 +225,21 @@
const flag = Math.abs(lastCount - count) <= categories.length / 100 ? true : false const flag = Math.abs(lastCount - count) <= categories.length / 100 ? true : false
if(flag && event.end === 100 && this.index != this.elementData.dataList.datas.length - 1) { if(flag && event.end === 100 && this.index != this.elementData.dataList.datas.length - 1) {
this.index += 1 this.index += 1
this.setChartDatas() this.setChartDatas(event)
} }
if(flag && event.start === 0 && this.index != 0) { if(flag && event.start === 0 && this.index != 0) {
this.index -= 1 this.index -= 1
this.setChartDatas() this.setChartDatas(event)
} }
}, },
setChartDatas() { setChartDatas(event) {
const categories = this.elementData.dataList.datas[this.index].categories const categories = this.elementData.dataList.datas[this.index].categories
const series = this.elementData.dataList.datas[this.index].series const series = this.elementData.dataList.datas[this.index].series
const dealSeries = this.dealSeriesData(series) const dealSeries = this.dealSeriesData(series)
this.$set(this.ec.option, 'yAxis.data', categories) this.$set(this.ec.option, 'yAxis.data', categories)
this.$set(this.ec.option, 'series', dealSeries) this.$set(this.ec.option, 'series', dealSeries)
this.$set(this.ec.option, 'dataZoom.start', event.start)
this.$set(this.ec.option, 'dataZoom.end', event.end)
} }
} }
} }
......
...@@ -215,11 +215,11 @@ ...@@ -215,11 +215,11 @@
const flag = Math.abs(lastCount - count) <= categories.length / 100 ? true : false const flag = Math.abs(lastCount - count) <= categories.length / 100 ? true : false
if(flag && event.end === 100 && this.index != this.elementData.dataList.datas.length - 1) { if(flag && event.end === 100 && this.index != this.elementData.dataList.datas.length - 1) {
this.index += 1 this.index += 1
this.setChartDatas() this.setChartDatas(event)
} }
if(flag && event.start === 0 && this.index != 0) { if(flag && event.start === 0 && this.index != 0) {
this.index -= 1 this.index -= 1
this.setChartDatas() this.setChartDatas(event)
} }
}, },
setChartDatas() { setChartDatas() {
...@@ -228,6 +228,8 @@ ...@@ -228,6 +228,8 @@
const dealSeries = this.dealSeriesData(series) const dealSeries = this.dealSeriesData(series)
this.$set(this.ec.option, 'xAxis.data', categories) this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', dealSeries) this.$set(this.ec.option, 'series', dealSeries)
this.$set(this.ec.option, 'dataZoom.start', event.start)
this.$set(this.ec.option, 'dataZoom.end', event.end)
} }
} }
} }
......
...@@ -192,19 +192,21 @@ ...@@ -192,19 +192,21 @@
const flag = Math.abs(lastCount - count) <= categories.length / 100 ? true : false const flag = Math.abs(lastCount - count) <= categories.length / 100 ? true : false
if(flag && event.end === 100 && this.index != this.elementData.dataList.datas.length - 1) { if(flag && event.end === 100 && this.index != this.elementData.dataList.datas.length - 1) {
this.index += 1 this.index += 1
this.setChartDatas() this.setChartDatas(event)
} }
if(flag && event.start === 0 && this.index != 0) { if(flag && event.start === 0 && this.index != 0) {
this.index -= 1 this.index -= 1
this.setChartDatas() this.setChartDatas(event)
} }
}, },
setChartDatas() { setChartDatas(event) {
const categories = this.elementData.dataList.datas[this.index].categories const categories = this.elementData.dataList.datas[this.index].categories
const series = this.elementData.dataList.datas[this.index].series const series = this.elementData.dataList.datas[this.index].series
const dealSeries = this.dealSeriesData(series) const dealSeries = this.dealSeriesData(series)
this.$set(this.ec.option, 'xAxis.data', categories) this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', dealSeries) this.$set(this.ec.option, 'series', dealSeries)
this.$set(this.ec.option, 'dataZoom.start', event.start)
this.$set(this.ec.option, 'dataZoom.end', event.end)
} }
} }
} }
......
...@@ -194,19 +194,21 @@ ...@@ -194,19 +194,21 @@
const flag = Math.abs(lastCount - count) <= categories.length / 100 ? true : false const flag = Math.abs(lastCount - count) <= categories.length / 100 ? true : false
if(flag && event.end === 100 && this.index != this.elementData.dataList.datas.length - 1) { if(flag && event.end === 100 && this.index != this.elementData.dataList.datas.length - 1) {
this.index += 1 this.index += 1
this.setChartDatas() this.setChartDatas(event)
} }
if(flag && event.start === 0 && this.index != 0) { if(flag && event.start === 0 && this.index != 0) {
this.index -= 1 this.index -= 1
this.setChartDatas() this.setChartDatas(event)
} }
}, },
setChartDatas() { setChartDatas(event) {
const categories = this.elementData.dataList.datas[this.index].categories const categories = this.elementData.dataList.datas[this.index].categories
const series = this.elementData.dataList.datas[this.index].series const series = this.elementData.dataList.datas[this.index].series
const dealSeries = this.dealSeriesData(series) const dealSeries = this.dealSeriesData(series)
this.$set(this.ec.option, 'xAxis.data', categories) this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', dealSeries) this.$set(this.ec.option, 'series', dealSeries)
this.$set(this.ec.option, 'dataZoom.start', event.start)
this.$set(this.ec.option, 'dataZoom.end', event.end)
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment