Commit ad6d6ce48694bed6eae7acf186b280d8f2461772
Committed by
GitHub
Merge pull request #5275 from ArtemDzhereleiko/bug-fix/gauge/boundary-values
[3.3.2] UI: Fix digital gauge widget with using boundary values
Showing
3 changed files
with
9 additions
and
4 deletions
... | ... | @@ -276,7 +276,6 @@ export class CanvasDigitalGauge extends BaseGauge { |
276 | 276 | } |
277 | 277 | } |
278 | 278 | } |
279 | - | |
280 | 279 | options.ticksValue = []; |
281 | 280 | for (const tick of options.ticks) { |
282 | 281 | if (tick !== null) { |
... | ... | @@ -820,7 +819,7 @@ function getProgressColor(progress: number, colorsRange: DigitalGaugeColorRange[ |
820 | 819 | return colorsRange[0].rgbString; |
821 | 820 | } |
822 | 821 | |
823 | - for (let j = 0; j < colorsRange.length; j++) { | |
822 | + for (let j = 1; j < colorsRange.length; j++) { | |
824 | 823 | if (progress <= colorsRange[j].pct) { |
825 | 824 | const lower = colorsRange[j - 1]; |
826 | 825 | const upper = colorsRange[j]; |
... | ... | @@ -836,6 +835,7 @@ function getProgressColor(progress: number, colorsRange: DigitalGaugeColorRange[ |
836 | 835 | return color.toRgbString(); |
837 | 836 | } |
838 | 837 | } |
838 | + return colorsRange[colorsRange.length - 1].rgbString; | |
839 | 839 | } |
840 | 840 | |
841 | 841 | function drawArcGlow(context: DigitalGaugeCanvasRenderingContext2D, | ... | ... |
... | ... | @@ -266,7 +266,6 @@ export class TbCanvasDigitalGauge { |
266 | 266 | |
267 | 267 | init() { |
268 | 268 | let updateSetting = false; |
269 | - | |
270 | 269 | if (this.localSettings.useFixedLevelColor && this.localSettings.fixedLevelColors?.length > 0) { |
271 | 270 | this.localSettings.levelColors = this.settingLevelColorsSubscribe(this.localSettings.fixedLevelColors); |
272 | 271 | updateSetting = true; |
... | ... | @@ -285,6 +284,11 @@ export class TbCanvasDigitalGauge { |
285 | 284 | let levelColorsDatasource: Datasource[] = []; |
286 | 285 | const predefineLevelColors: ColorLevelSetting[] = []; |
287 | 286 | |
287 | + predefineLevelColors.push({ | |
288 | + value: this.localSettings.minValue, | |
289 | + color: this.localSettings.gaugeColor | |
290 | + }); | |
291 | + | |
288 | 292 | function setLevelColor(levelSetting: AttributeSourceProperty, color: string) { |
289 | 293 | if (levelSetting.valueSource === 'predefinedValue' && isFinite(levelSetting.value)) { |
290 | 294 | predefineLevelColors.push({ | ... | ... |