diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index 440eb8108..d7951dc4a 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -1757,7 +1757,11 @@ export default { resize () { this.init() this.$nextTick(() => { - this.$parent.$parent.dateChange() + if (this.$parent.$parent.dateChange) { + this.$parent.$parent.dateChange() + } else { + this.$parent.dateChange() + } }) }, init () { diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index 8683e5727..c65df0484 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -939,7 +939,6 @@ export default { dot = 1 } dot = bus.countDecimals(value) - // console.log(dot,val) if (dot < self.chartDot) { dot = self.chartDot } @@ -972,6 +971,14 @@ export default { } else { option.xAxis.minInterval = 20 * 60 * 1000 } + } else { + if (this.$refs.resizeBox.offsetWidth < 200) { + option.xAxis.splitNumber = 1 + } else if (this.$refs.resizeBox.offsetWidth < 300) { + option.xAxis.splitNumber = 3 + } else if (this.$refs.resizeBox.offsetWidth < 500) { + option.xAxis.splitNumber = 5 + } } // params.series = dataArg; if (chartSite === 'local') { // 本地显示 @@ -1009,6 +1016,13 @@ export default { } else { self.noData = true option = chartConfig.getOptionNoData('noData') + if (self.$refs.resizeBox.offsetWidth < 200) { + option.xAxis.splitNumber = 1 + } else if (self.$refs.resizeBox.offsetWidth < 300) { + option.xAxis.splitNumber = 3 + } else if (self.$refs.resizeBox.offsetWidth < 500) { + option.xAxis.splitNumber = 5 + } getChart(self.chartIndex).clear() getChart(self.chartIndex).setOption(option)// 创建图表 }