Flot threshold value now supports array of values.
This commit is contained in:
parent
4cc7e7b373
commit
a311a6984f
@ -909,16 +909,22 @@ export class TbFlot {
|
|||||||
isLatest = false): TbFlotThresholdMarking[] {
|
isLatest = false): TbFlotThresholdMarking[] {
|
||||||
const thresholds: TbFlotThresholdMarking[] = [];
|
const thresholds: TbFlotThresholdMarking[] = [];
|
||||||
data.forEach((keyData) => {
|
data.forEach((keyData) => {
|
||||||
let skip = false;
|
const skip = isLatest && !keyData.dataKey.settings.useAsThreshold;
|
||||||
let latestSettings: TbFlotLatestKeySettings;
|
|
||||||
if (isLatest) {
|
|
||||||
latestSettings = keyData.dataKey.settings;
|
|
||||||
if (!latestSettings.useAsThreshold) {
|
|
||||||
skip = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!skip && keyData && keyData.data && keyData.data[0]) {
|
if (!skip && keyData && keyData.data && keyData.data[0]) {
|
||||||
const attrValue = keyData.data[0][1];
|
const value = keyData.data[0][1];
|
||||||
|
const values = Array.isArray(value) ? value : [value];
|
||||||
|
values.forEach(v => {
|
||||||
|
const threshold = this.processSingleDataValue(v, keyData, keyData.dataKey.settings, existingThresholds, isLatest);
|
||||||
|
if (threshold != null) {
|
||||||
|
thresholds.push(threshold);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return thresholds;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
@ -934,15 +940,10 @@ export class TbFlot {
|
|||||||
color = settings.color || keyData.dataKey.color;
|
color = settings.color || keyData.dataKey.color;
|
||||||
}
|
}
|
||||||
const colorIndex = this.subscription.data.length + existingThresholds.length;
|
const colorIndex = this.subscription.data.length + existingThresholds.length;
|
||||||
const threshold = this.generateThreshold(existingThresholds, yaxis, lineWidth, color, colorIndex, attrValue);
|
return this.generateThreshold(existingThresholds, yaxis, lineWidth, color, colorIndex, attrValue);
|
||||||
if (threshold != null) {
|
|
||||||
thresholds.push(threshold);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
return thresholds;
|
|
||||||
}
|
|
||||||
|
|
||||||
private generateThreshold(existingThresholds: TbFlotThresholdMarking[], yaxis: number, lineWidth: number,
|
private generateThreshold(existingThresholds: TbFlotThresholdMarking[], yaxis: number, lineWidth: number,
|
||||||
color: string, defaultColorIndex: number, thresholdValue: number): TbFlotThresholdMarking {
|
color: string, defaultColorIndex: number, thresholdValue: number): TbFlotThresholdMarking {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user