| | |
| | | <template #footer> |
| | | <!-- 单页数据量--> |
| | | <SliderBar |
| | | @input="(e) => (progress = e)" |
| | | v-model:progress="progress" |
| | | @size-change="(e) => (pageSize = e)" |
| | | ></SliderBar> |
| | | </template> |
| | |
| | | |
| | | export default { |
| | | props: { |
| | | loading: Boolean, |
| | | factorDatas: { |
| | | type: FactorDatas |
| | | // default: () => new FactorDatas() |
| | |
| | | selectFactorType: { |
| | | type: Array, |
| | | default: () => ['1'] |
| | | } |
| | | }, |
| | | // 当前选中高亮的数据点索引 |
| | | locateIndex: Number |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | progress: 0 |
| | | }; |
| | | }, |
| | | emits: ['chartClick'], |
| | | watch: { |
| | | factorDatas: { |
| | | handler() { |
| | |
| | | this.changeChartRange(); |
| | | }, |
| | | pageSize() { |
| | | this.changeChartRange(); |
| | | }, |
| | | locateIndex(nV, oV) { |
| | | if (nV == oV) return; |
| | | // 1. 定位点应该展示在趋势图中间,因此定位百分比往前偏移当前_size的一半 |
| | | let i = nV - parseInt(this.pageSize / 2); |
| | | // 2. 确保索引不会超出范围 |
| | | i = i < 0 ? 0 : i; |
| | | // 3. 获取索引对应的进度百分比 |
| | | this.progress = (i / (this.allXAxis.length - this.pageSize)) * 100; |
| | | |
| | | for (const iterator of this.allSeries) { |
| | | // if (iterator.name == factorName || (iterator.name == 'TVOC' || factorName == 'VOC')) { |
| | | iterator.markLine = { |
| | | symbol: 'none', |
| | | data: [ |
| | | { |
| | | name: '选中', |
| | | xAxis: this.allXAxis[nV], |
| | | label: { |
| | | color: 'white' |
| | | }, |
| | | lineStyle: { |
| | | color: 'yellow' |
| | | } |
| | | } |
| | | ] |
| | | }; |
| | | } |
| | | this.changeChartRange(); |
| | | } |
| | | }, |
| | |
| | | } |
| | | // this.option.dataZoom[0].start = startPer; |
| | | // this.option.dataZoom[0].end = endPer; |
| | | this.lineChart.setOption(this.option); |
| | | this.lineChart.setOption(this.option, { notMerge: true }); |
| | | }, |
| | | getShowXAxis(sIndex, eIndex) { |
| | | return this.allXAxis.slice(sIndex, eIndex); |
| | | }, |
| | | getShowSeries(sIndex, eIndex) { |
| | | const res = this.allSeries.filter((s) => { |
| | | this.allSeries.forEach((s) => { |
| | | if (sIndex && eIndex) { |
| | | s.data = s.allData.slice(sIndex, eIndex); |
| | | } |
| | | }); |
| | | const res = this.allSeries.filter((s) => { |
| | | return this.selectFactorType.includes(s.key); |
| | | }); |
| | | return res; |
| | |
| | | }, |
| | | mounted() { |
| | | this.lineChart = echarts.init(this.$refs.lineChart); |
| | | this.lineChart.on('click', (e) => { |
| | | this.$emit('chartClick', e.dataIndex); |
| | | }); |
| | | } |
| | | }; |
| | | </script> |