Changed logic for processing boundary values and change labels
This commit is contained in:
parent
75817a16f4
commit
bbea48215e
@ -466,9 +466,9 @@ export class CanvasDigitalGauge extends BaseGauge {
|
|||||||
const progress = (Drawings.normalizedValue(options).normal - options.minValue) /
|
const progress = (Drawings.normalizedValue(options).normal - options.minValue) /
|
||||||
(options.maxValue - options.minValue);
|
(options.maxValue - options.minValue);
|
||||||
if (options.neonGlowBrightness) {
|
if (options.neonGlowBrightness) {
|
||||||
color = getProgressColor(progress, options.neonColorsRange);
|
color = getProgressColor(progress, options.neonColorsRange, options.neonColorValue);
|
||||||
} else {
|
} else {
|
||||||
color = getProgressColor(progress, options.colorsRange);
|
color = getProgressColor(progress, options.colorsRange, options.neonColorValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
@ -814,14 +814,14 @@ function drawDigitalValue(context: DigitalGaugeCanvasRenderingContext2D, options
|
|||||||
drawText(context, options, 'Value', text, textX, textY);
|
drawText(context, options, 'Value', text, textX, textY);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProgressColor(progress: number, colorsRange: DigitalGaugeColorRange[]): string {
|
function getProgressColor(progress: number, colorsRange: DigitalGaugeColorRange[], defaultColor: string): string {
|
||||||
|
|
||||||
if (progress === 0 || colorsRange.length === 1) {
|
if (progress === 0 || colorsRange.length === 1) {
|
||||||
return colorsRange[0].rgbString;
|
return defaultColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let j = 0; j < colorsRange.length; j++) {
|
for (let j = 1; j < colorsRange.length; j += 2) {
|
||||||
if (progress <= colorsRange[j].pct) {
|
if (progress >= colorsRange[j - 1].pct && progress <= colorsRange[j].pct) {
|
||||||
const lower = colorsRange[j - 1];
|
const lower = colorsRange[j - 1];
|
||||||
const upper = colorsRange[j];
|
const upper = colorsRange[j];
|
||||||
const range = upper.pct - lower.pct;
|
const range = upper.pct - lower.pct;
|
||||||
@ -836,6 +836,7 @@ function getProgressColor(progress: number, colorsRange: DigitalGaugeColorRange[
|
|||||||
return color.toRgbString();
|
return color.toRgbString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return defaultColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawArcGlow(context: DigitalGaugeCanvasRenderingContext2D,
|
function drawArcGlow(context: DigitalGaugeCanvasRenderingContext2D,
|
||||||
@ -945,9 +946,9 @@ function drawProgress(context: DigitalGaugeCanvasRenderingContext2D,
|
|||||||
options: CanvasDigitalGaugeOptions, progress: number) {
|
options: CanvasDigitalGaugeOptions, progress: number) {
|
||||||
let neonColor;
|
let neonColor;
|
||||||
if (options.neonGlowBrightness) {
|
if (options.neonGlowBrightness) {
|
||||||
context.currentColor = neonColor = getProgressColor(progress, options.neonColorsRange);
|
context.currentColor = neonColor = getProgressColor(progress, options.neonColorsRange, options.neonColorValue);
|
||||||
} else {
|
} else {
|
||||||
context.currentColor = context.strokeStyle = getProgressColor(progress, options.colorsRange);
|
context.currentColor = context.strokeStyle = getProgressColor(progress, options.colorsRange, options.neonColorValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
const {barLeft, barRight, barTop, baseX, width, barBottom, Cx, Cy, Rm, Ro, Ri, strokeWidth} =
|
const {barLeft, barRight, barTop, baseX, width, barBottom, Cx, Cy, Rm, Ro, Ri, strokeWidth} =
|
||||||
|
|||||||
@ -190,7 +190,7 @@ export const digitalGaugeSettingsSchema: JsonSettingsSchema = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
fixedLevelColors: {
|
fixedLevelColors: {
|
||||||
title: 'The colors for the indicator using boundary values',
|
title: 'The colors for the indicator using boundary values in percents',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
items: {
|
items: {
|
||||||
title: 'levelColor',
|
title: 'levelColor',
|
||||||
@ -214,8 +214,9 @@ export const digitalGaugeSettingsSchema: JsonSettingsSchema = {
|
|||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
},
|
||||||
value: {
|
value: {
|
||||||
title: '[From] Value (if predefined value is selected)',
|
title: '[From] Value, % (if predefined value is selected)',
|
||||||
type: 'number'
|
type: 'number',
|
||||||
|
default: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -237,8 +238,9 @@ export const digitalGaugeSettingsSchema: JsonSettingsSchema = {
|
|||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
},
|
||||||
value: {
|
value: {
|
||||||
title: '[To] Value (if predefined value is selected)',
|
title: '[To] Value, % (if predefined value is selected)',
|
||||||
type: 'number'
|
type: 'number',
|
||||||
|
default: 100
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -246,7 +248,8 @@ export const digitalGaugeSettingsSchema: JsonSettingsSchema = {
|
|||||||
title: 'Color',
|
title: 'Color',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
required: ['color'],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
showTicks: {
|
showTicks: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user