NEZ-2776 fix:Alert message 'History value' 图表缺少 threshold 线

This commit is contained in:
zhangyu
2023-04-17 14:21:37 +08:00
parent c083d9c390
commit e29e1893d2
3 changed files with 52 additions and 20 deletions

View File

@@ -119,9 +119,20 @@ export default {
}
// Thresholds 只对左Y轴有效
if (s.yAxisIndex != 1) {
chartInfo.param.thresholds = chartInfo.param.thresholds.reverse()
s.markLine.data = chartInfo.param.thresholds.map(threshold => {
return {
yAxis: threshold.value || 0,
label: {
show: true,
formatter () {
if (threshold.label) {
return threshold.label
} else {
return threshold.value || 0
}
}
},
lineStyle: {
color: threshold.color,
width: 2,

View File

@@ -670,26 +670,36 @@ export default {
queryDate () {
this.chartLoading = true
let chartInfo = {}
const severityData = JSON.parse(localStorage.getItem('nz-severityDataWeight'))
const conditionArr = JSON.parse(this.currentMsg.alertRule.condition)
if (this.currentMsg.alertRule.type === 1 || this.currentMsg.alertRule.type === 3) {
chartInfo = lodash.cloneDeep(lineData)
chartInfo.elements = [{}]
if (!isNaN(this.currentMsg.alertRule.threshold)) {
if (conditionArr.length) {
chartInfo.param.enable.thresholds = true
chartInfo.param.thresholds = [{
value: this.currentMsg.alertRule.threshold,
color: '#d64f40'
}]
chartInfo.param.thresholds = conditionArr.map(item => {
const findItem = severityData.find(severity => severity.id === item.id)
if (findItem) {
item.color = findItem.color
item.label = findItem.name
}
return item
}).filter(item => item.value)
}
chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, ''))
} else if (this.currentMsg.alertRule.type === 2) {
chartInfo = lodash.cloneDeep(logData)
chartInfo.elements = [{}]
if (!isNaN(this.currentMsg.alertRule.threshold)) {
if (conditionArr.length) {
chartInfo.param.enable.thresholds = true
chartInfo.param.thresholds = [{
value: this.currentMsg.alertRule.threshold,
color: '#d64f40'
}]
chartInfo.param.thresholds = conditionArr.map(item => {
const findItem = severityData.find(severity => severity.id === item.id)
if (findItem) {
item.color = findItem.color
item.label = findItem.name
}
return item
}).filter(item => item.value)
}
chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\r|\n+/g, ''))
}

View File

@@ -718,26 +718,37 @@ export default {
queryDate () {
this.chartLoading = true
let chartInfo = {}
const severityData = JSON.parse(localStorage.getItem('nz-severityDataWeight'))
const conditionArr = JSON.parse(this.currentMsg.alertRule.condition)
console.log(this.currentMsg.alertRule.condition, this.severityData)
if (this.currentMsg.alertRule.type === 1 || this.currentMsg.alertRule.type === 3) {
chartInfo = lodash.cloneDeep(lineData)
chartInfo.elements = [{}]
if (!isNaN(this.currentMsg.alertRule.threshold)) {
if (conditionArr.length) {
chartInfo.param.enable.thresholds = true
chartInfo.param.thresholds = [{
value: this.currentMsg.alertRule.threshold,
color: '#d64f40'
}]
chartInfo.param.thresholds = conditionArr.map(item => {
const findItem = severityData.find(severity => severity.id === item.id)
if (findItem) {
item.color = findItem.color
item.label = findItem.name
}
return item
}).filter(item => item.value)
}
chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, ''))
} else if (this.currentMsg.alertRule.type === 2) {
chartInfo = lodash.cloneDeep(logData)
chartInfo.elements = [{}]
if (!isNaN(this.currentMsg.alertRule.threshold)) {
if (conditionArr.length) {
chartInfo.param.enable.thresholds = true
chartInfo.param.thresholds = [{
value: this.currentMsg.alertRule.threshold,
color: '#d64f40'
}]
chartInfo.param.thresholds = conditionArr.map(item => {
const findItem = severityData.find(severity => severity.id === item.id)
if (findItem) {
item.color = findItem.color
item.label = findItem.name
}
return item
}).filter(item => item.value)
}
chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\r|\n+/g, ''))
}