diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index 608009b27..a2c734f6b 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -436,11 +436,23 @@ export default { // const dot = maxValueCopies.dot const copies = maxValueCopies.copies const unit = maxValueCopies.unit - getChart(this.chartIndex).setOption({ + const option = { yAxis: { minInterval: chartDataFormat.Interval(maxValue, copies, unit.type, 'min'), maxInterval: chartDataFormat.Interval(maxValue, copies, unit.type, 'max') * Math.ceil(dataArg.length / 5) } + } + if (!maxValueCopies.copies) { + option.yAxis.min = 0 + option.yAxis.max = 1 + } + if (unit.type == 'Time' || option.yAxis.maxInterval === 1) { + delete option.yAxis.maxInterval + } + getChart(this.chartIndex).setOption({ + yAxis: { + ...option.yAxis + } }) } }, @@ -538,11 +550,23 @@ export default { // const dot = maxValueCopies.dot const copies = maxValueCopies.copies const unit = maxValueCopies.unit - echart.setOption({ + const option = { yAxis: { minInterval: chartDataFormat.Interval(maxValue, copies, unit.type, 'min'), maxInterval: chartDataFormat.Interval(maxValue, copies, unit.type, 'max') * Math.ceil(dataArg.length / 5) } + } + if (!maxValueCopies.copies) { + option.yAxis.min = 0 + option.yAxis.max = 1 + } + if (unit.type == 'Time' || option.yAxis.maxInterval === 1) { + delete option.yAxis.maxInterval + } + echart.setOption({ + yAxis: { + ...option.yAxis + } }) } }, @@ -659,6 +683,7 @@ export default { const copies = maxValueCopies.copies const unit = maxValueCopies.unit const oldDot = maxValueCopies.oldDot + console.log(maxValueCopies, chartDataFormat.Interval(maxValue, copies, unit.type, 'min'), chartDataFormat.Interval(maxValue, copies, unit.type, 'max') * Math.ceil(dataArg.length / 5)) let option = { title: { show: false @@ -1879,12 +1904,24 @@ export default { const copies = maxValueCopies.copies const unit = maxValueCopies.unit // const oldDot = maxValueCopies.oldDot - getChart(this.chartIndex).setOption({ - series: this.seriesItem, + const option = { yAxis: { minInterval: chartDataFormat.Interval(maxValue, copies, unit.type, 'min'), maxInterval: chartDataFormat.Interval(maxValue, copies, unit.type, 'max') * Math.ceil(dataArg.length / 5) } + } + if (!maxValueCopies.copies) { + option.yAxis.min = 0 + option.yAxis.max = 1 + } + if (unit.type == 'Time' || option.yAxis.maxInterval === 1) { + delete option.yAxis.maxInterval + } + getChart(this.chartIndex).setOption({ + series: this.seriesItem, + yAxis: { + ...option.yAxis + } }) if (this.hasLegendOptions) { this.computeLegendData(this.legendListMore, this.seriesItemArr, 'local') @@ -1912,12 +1949,24 @@ export default { const copies = maxValueCopies.copies const unit = maxValueCopies.unit // const oldDot = maxValueCopies.oldDot - this.echartModalStore.setOption({ - series: this.seriesItemScreen, + const option = { yAxis: { minInterval: chartDataFormat.Interval(maxValue, copies, unit.type, 'min'), maxInterval: chartDataFormat.Interval(maxValue, copies, unit.type, 'max') * Math.ceil(dataArg.length / 5) } + } + if (!maxValueCopies.copies) { + option.yAxis.min = 0 + option.yAxis.max = 1 + } + if (unit.type == 'Time' || option.yAxis.maxInterval === 1) { + delete option.yAxis.maxInterval + } + this.echartModalStore.setOption({ + series: this.seriesItemScreen, + yAxis: { + ...option.yAxis + } }) if (this.hasLegendOptions) { this.computeLegendData(this.screenLegendListMore, this.seriesItemArrScreen, 'screen')