diff --git a/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeries.vue b/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeries.vue index 2aa57c4ce..bf3a18d2a 100644 --- a/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeries.vue +++ b/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeries.vue @@ -61,14 +61,13 @@ import legend from '../legend' import chartMixin from '@/components/chart/chartMixin' import renderChart from '@/components/chart/renderChart' -import { chartLegendPlacement } from '@/components/common/js/constants' +import { chartLegendPlacement, stackIconSvg } from '@/components/common/js/constants' import { getChart, setChart, chartCache } from '@/components/common/js/common' import UPlot from 'uplot' import chartTimeSeriesMixin from '@/components/chart/chart/uplot/chartTimeSeriesMixin' import chartDataFormat from '@/components/chart/chartDataFormat' -import getStackedOpts from './stack' +import getStackedOpts, { stack } from './stack' import bus from '@/libs/bus' -import { stackIconSvg } from '@/components/common/js/constants' export default { name: 'chartTimeSeries', @@ -192,7 +191,6 @@ export default { const self = this const leftUnit = this.chartInfo.unit const leftUnitCompute = chartDataFormat.getUnit(leftUnit) - console.log(leftUnitCompute) const rightUnit = this.$lodash.get(this.chartInfo, 'param.rightYAxis.unit', 2) const rightUnitCompute = chartDataFormat.getUnit(rightUnit) const incrs = leftUnitCompute.ascii == 1024 ? this.incrs : undefined @@ -591,11 +589,32 @@ export default { this.$refs.legend.isGrey = arr } } + this.renderYaxis() this.clickout() }, + seriesDataChange (arr) { + const echarts = getChart(this.chartId) + const indexArr = [] + arr.forEach((item, index) => { + if (!item) { + indexArr.push(index) + } + }) + const data = this.seriesData.filter((item, j) => indexArr.indexOf(j) !== -1) + const stackData = stack(data, i => false) + const newData = this.$lodash.cloneDeep(this.seriesData) + indexArr.forEach((num, index) => { + newData[num] = stackData.data[index] + }) + echarts.setData(newData) + console.log(this.seriesData) + }, legendChange (isGrey) { this.isGrey = isGrey + if (this.isStack) { + this.seriesDataChange(isGrey) + } this.renderYaxis() }, resize () { diff --git a/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js b/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js index 00b56d21c..0223b3ce9 100644 --- a/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js +++ b/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js @@ -187,7 +187,6 @@ export default { const name = legend.name const alias = legend.alias const statistics = series.statistics - console.log(devicePixelRatio, this.lineOption.lineWidth) const obj = { name: name, label: alias, diff --git a/nezha-fronted/src/components/chart/chart/uplot/stack.js b/nezha-fronted/src/components/chart/chart/uplot/stack.js index 626ed5edc..5fe62ca6d 100644 --- a/nezha-fronted/src/components/chart/chart/uplot/stack.js +++ b/nezha-fronted/src/components/chart/chart/uplot/stack.js @@ -1,5 +1,5 @@ import uPlot from 'uplot' -function stack (data, omit) { +export function stack (data, omit) { const data2 = [] let bands = [] const d0Len = data[0].length