Commit ad6d6ce48694bed6eae7acf186b280d8f2461772

Authored by Igor Kulikov
Committed by GitHub
2 parents b0f9c8ff 29ac7237

Merge pull request #5275 from ArtemDzhereleiko/bug-fix/gauge/boundary-values

[3.3.2] UI: Fix digital gauge widget with using boundary values
@@ -276,7 +276,6 @@ export class CanvasDigitalGauge extends BaseGauge { @@ -276,7 +276,6 @@ export class CanvasDigitalGauge extends BaseGauge {
276 } 276 }
277 } 277 }
278 } 278 }
279 -  
280 options.ticksValue = []; 279 options.ticksValue = [];
281 for (const tick of options.ticks) { 280 for (const tick of options.ticks) {
282 if (tick !== null) { 281 if (tick !== null) {
@@ -820,7 +819,7 @@ function getProgressColor(progress: number, colorsRange: DigitalGaugeColorRange[ @@ -820,7 +819,7 @@ function getProgressColor(progress: number, colorsRange: DigitalGaugeColorRange[
820 return colorsRange[0].rgbString; 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 if (progress <= colorsRange[j].pct) { 823 if (progress <= colorsRange[j].pct) {
825 const lower = colorsRange[j - 1]; 824 const lower = colorsRange[j - 1];
826 const upper = colorsRange[j]; 825 const upper = colorsRange[j];
@@ -836,6 +835,7 @@ function getProgressColor(progress: number, colorsRange: DigitalGaugeColorRange[ @@ -836,6 +835,7 @@ function getProgressColor(progress: number, colorsRange: DigitalGaugeColorRange[
836 return color.toRgbString(); 835 return color.toRgbString();
837 } 836 }
838 } 837 }
  838 + return colorsRange[colorsRange.length - 1].rgbString;
839 } 839 }
840 840
841 function drawArcGlow(context: DigitalGaugeCanvasRenderingContext2D, 841 function drawArcGlow(context: DigitalGaugeCanvasRenderingContext2D,
@@ -246,7 +246,8 @@ export const digitalGaugeSettingsSchema: JsonSettingsSchema = { @@ -246,7 +246,8 @@ export const digitalGaugeSettingsSchema: JsonSettingsSchema = {
246 title: 'Color', 246 title: 'Color',
247 type: 'string' 247 type: 'string'
248 } 248 }
249 - } 249 + },
  250 + required: ['color'],
250 } 251 }
251 }, 252 },
252 showTicks: { 253 showTicks: {
@@ -266,7 +266,6 @@ export class TbCanvasDigitalGauge { @@ -266,7 +266,6 @@ export class TbCanvasDigitalGauge {
266 266
267 init() { 267 init() {
268 let updateSetting = false; 268 let updateSetting = false;
269 -  
270 if (this.localSettings.useFixedLevelColor && this.localSettings.fixedLevelColors?.length > 0) { 269 if (this.localSettings.useFixedLevelColor && this.localSettings.fixedLevelColors?.length > 0) {
271 this.localSettings.levelColors = this.settingLevelColorsSubscribe(this.localSettings.fixedLevelColors); 270 this.localSettings.levelColors = this.settingLevelColorsSubscribe(this.localSettings.fixedLevelColors);
272 updateSetting = true; 271 updateSetting = true;
@@ -285,6 +284,11 @@ export class TbCanvasDigitalGauge { @@ -285,6 +284,11 @@ export class TbCanvasDigitalGauge {
285 let levelColorsDatasource: Datasource[] = []; 284 let levelColorsDatasource: Datasource[] = [];
286 const predefineLevelColors: ColorLevelSetting[] = []; 285 const predefineLevelColors: ColorLevelSetting[] = [];
287 286
  287 + predefineLevelColors.push({
  288 + value: this.localSettings.minValue,
  289 + color: this.localSettings.gaugeColor
  290 + });
  291 +
288 function setLevelColor(levelSetting: AttributeSourceProperty, color: string) { 292 function setLevelColor(levelSetting: AttributeSourceProperty, color: string) {
289 if (levelSetting.valueSource === 'predefinedValue' && isFinite(levelSetting.value)) { 293 if (levelSetting.valueSource === 'predefinedValue' && isFinite(levelSetting.value)) {
290 predefineLevelColors.push({ 294 predefineLevelColors.push({