NEZ-2562 feat:statistics 增加first*、last*
This commit is contained in:
@@ -357,7 +357,7 @@ export default {
|
||||
}
|
||||
})
|
||||
})
|
||||
}, 50)
|
||||
}, 100)
|
||||
},
|
||||
statMouseMove (e) {
|
||||
const windowWidth = window.innerWidth// 窗口宽度
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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') }
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user