diff --git a/nezha-fronted/src/components/chart/chart/chartStat.vue b/nezha-fronted/src/components/chart/chart/chartStat.vue index 5f8482bea..724853296 100644 --- a/nezha-fronted/src/components/chart/chart/chartStat.vue +++ b/nezha-fronted/src/components/chart/chart/chartStat.vue @@ -357,7 +357,7 @@ export default { } }) }) - }, 50) + }, 100) }, statMouseMove (e) { const windowWidth = window.innerWidth// 窗口宽度 diff --git a/nezha-fronted/src/components/chart/chartList.vue b/nezha-fronted/src/components/chart/chartList.vue index 896186f5e..1c071a09d 100644 --- a/nezha-fronted/src/components/chart/chartList.vue +++ b/nezha-fronted/src/components/chart/chartList.vue @@ -617,11 +617,13 @@ export default { const item = arr[index] const repeatVariable = this.$loadsh.get(item.param.repeat, 'variable') const repeatEnable = this.$loadsh.get(item.param.enable, 'repeat') - if (item.type === 'group' && repeatVariable && this.$loadsh.get(this.showHidden[item.id], 'visibility') !== 'hidden' && repeatEnable) { + const visibility = this.$loadsh.get(this.showHidden[item.id], 'visibility') !== 'hidden' + if (item.type === 'group' && repeatVariable && repeatEnable && visibility) { const itemPrev = arr[index - 1] const repeatPrevVariable = this.$loadsh.get(itemPrev.param.repeat, 'variable') const repeatPrevEnable = this.$loadsh.get(itemPrev.param.enable, 'repeat') - if (itemPrev && itemPrev.type === 'group' && repeatPrevVariable === repeatVariable && repeatPrevEnable) { + const itemVisibility = this.$loadsh.get(this.showHidden[itemPrev.id], 'visibility') !== 'hidden' + if (itemPrev && itemPrev.type === 'group' && repeatPrevVariable === repeatVariable && repeatPrevEnable && itemVisibility) { const arr = variablesRepeat[repeatVariable] arr[arr.length - 1].repeatArr.push(item) arr[arr.length - 1].lastGroup = item @@ -725,6 +727,9 @@ export default { if (!flag) { this.tempList.forEach(item => { if (!this.copyDataList.find(chart => chart.id === item.id)) { + delete item.repeatIndex + delete item.repeatVariable + delete item.repeatValue item.y -= 0.03 this.copyDataList.push(item) } diff --git a/nezha-fronted/src/components/common/js/constants.js b/nezha-fronted/src/components/common/js/constants.js index c37de65bf..8517ab29e 100644 --- a/nezha-fronted/src/components/common/js/constants.js +++ b/nezha-fronted/src/components/common/js/constants.js @@ -220,7 +220,9 @@ export const statisticsList = [ { value: 'max', label: i18n.t('dashboard.panel.chartForm.max') }, { value: 'avg', label: i18n.t('dashboard.panel.chartForm.statisticsVal.average') }, { value: 'total', label: i18n.t('dashboard.panel.chartTotal') }, + { value: 'first*', label: i18n.t('dashboard.panel.chartForm.statisticsVal.first*') }, { value: 'first', label: i18n.t('dashboard.panel.chartForm.statisticsVal.first') }, + { value: 'last*', label: i18n.t('dashboard.panel.chartForm.statisticsVal.last*') }, { value: 'last', label: i18n.t('dashboard.panel.chartForm.statisticsVal.last') }, { value: 'range', label: i18n.t('dashboard.panel.chartForm.valMapping.range') }, { value: 'different', label: i18n.t('dashboard.panel.chartForm.statisticsVal.different') } diff --git a/nezha-fronted/src/components/common/js/tools.js b/nezha-fronted/src/components/common/js/tools.js index f25720320..d0416ca9a 100644 --- a/nezha-fronted/src/components/common/js/tools.js +++ b/nezha-fronted/src/components/common/js/tools.js @@ -968,10 +968,35 @@ export function getMetricTypeValue (queryItem, type) { const last = copy.sort((x, y) => { return parseFloat(y[0]) - parseFloat(x[0]) })[0][1] return last } + case 'last*': { // 最后一个非空值 + copy.sort((x, y) => { return parseFloat(y[0]) - parseFloat(x[0]) }) + let last = copy[0][1] + for (let idx = 0; idx < copy.length; idx++) { + const v = copy[idx][1] + if (v) { + last = v + break + } + } + return last + } case 'first': { const first = copy.sort((x, y) => { return parseFloat(y[0]) - parseFloat(x[0]) })[copy.length - 1][1] return first } + case 'first*': { // 第一个非空值 + copy.sort((x, y) => { return parseFloat(y[0]) - parseFloat(x[0]) }) + let first = copy[copy.length - 1][1] + let idx = copy.length - 1 + while (idx >= 0) { + const v = copy[idx--][1] + if (v) { + first = v + break + } + } + return first + } case 'total': { copy = copy.map(t => { const t1 = isNaN(t[1]) && !t[1] ? 0 : t[1]