UI: Improvement parse threshold data
This commit is contained in:
parent
a311a6984f
commit
4d12e4a1e7
@ -911,8 +911,7 @@ export class TbFlot {
|
|||||||
data.forEach((keyData) => {
|
data.forEach((keyData) => {
|
||||||
const skip = isLatest && !keyData.dataKey.settings.useAsThreshold;
|
const skip = isLatest && !keyData.dataKey.settings.useAsThreshold;
|
||||||
if (!skip && keyData && keyData.data && keyData.data[0]) {
|
if (!skip && keyData && keyData.data && keyData.data[0]) {
|
||||||
const value = keyData.data[0][1];
|
const values = this.parsThresholdData(keyData.data[0][1]);
|
||||||
const values = Array.isArray(value) ? value : [value];
|
|
||||||
values.forEach(v => {
|
values.forEach(v => {
|
||||||
const threshold = this.processSingleDataValue(v, keyData, keyData.dataKey.settings, existingThresholds, isLatest);
|
const threshold = this.processSingleDataValue(v, keyData, keyData.dataKey.settings, existingThresholds, isLatest);
|
||||||
if (threshold != null) {
|
if (threshold != null) {
|
||||||
@ -924,7 +923,19 @@ export class TbFlot {
|
|||||||
return thresholds;
|
return thresholds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private processSingleDataValue(attrValue: number, keyData: DatasourceData, latestSettings: TbFlotLatestKeySettings, existingThresholds: TbFlotThresholdMarking[], isLatest = false) {
|
private parsThresholdData(value: any): Array<any> {
|
||||||
|
let values;
|
||||||
|
try {
|
||||||
|
const parseData = JSON.parse(value);
|
||||||
|
values = Array.isArray(parseData) ? parseData : [parseData];
|
||||||
|
} catch (e) {
|
||||||
|
values = [value];
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
private processSingleDataValue(attrValue: number, keyData: DatasourceData, latestSettings: TbFlotLatestKeySettings,
|
||||||
|
existingThresholds: TbFlotThresholdMarking[], isLatest = false) {
|
||||||
if (isNumeric(attrValue) && isFinite(attrValue)) {
|
if (isNumeric(attrValue) && isFinite(attrValue)) {
|
||||||
let yaxis: number;
|
let yaxis: number;
|
||||||
let lineWidth: number;
|
let lineWidth: number;
|
||||||
@ -941,7 +952,6 @@ export class TbFlot {
|
|||||||
}
|
}
|
||||||
const colorIndex = this.subscription.data.length + existingThresholds.length;
|
const colorIndex = this.subscription.data.length + existingThresholds.length;
|
||||||
return this.generateThreshold(existingThresholds, yaxis, lineWidth, color, colorIndex, attrValue);
|
return this.generateThreshold(existingThresholds, yaxis, lineWidth, color, colorIndex, attrValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user