NEZ-2776 fix:Alert message 'History value' 图表缺少 threshold 线
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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, ''))
|
||||
}
|
||||
|
||||
@@ -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, ''))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user