Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for decimal places to Steel Style gauge #433

Merged
merged 2 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@
}

<mat-form-field *ngIf="(widgetConfig.numInt !== undefined)">
<mat-label>Minimum Integer Places</mat-label>
<input type="number" min="0" max="5" matInput placeholder="Enter or select number..." name="numInt" formControlName="numInt">
<mat-label>Integer Places</mat-label>
<input type="number" min="1" max="5" matInput placeholder="Enter or select number..." name="numInt" formControlName="numInt" required>
</mat-form-field>
<mat-form-field *ngIf="(widgetConfig.numInt !== undefined)">
<mat-label>Maximum Decimal Places</mat-label>
<input type="number" min="0" max="5" matInput placeholder="Enter or select number..." name="numDecimal" formControlName="numDecimal">
<mat-form-field *ngIf="(widgetConfig.numDecimal !== undefined)" [class.options-grid-span2]="!widgetConfig.numInt">
<mat-label>Decimal Places</mat-label>
<input type="number" min="0" max="5" matInput placeholder="Enter or select number..." name="numDecimal" formControlName="numDecimal" required>
</mat-form-field>

<mat-checkbox *ngIf="(widgetConfig.showMin !== undefined)"
Expand Down
2 changes: 2 additions & 0 deletions src/app/widgets/gauge-steel/gauge-steel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class GaugeSteelComponent implements OnInit, OnChanges, OnDestroy {
@Input('frameColor') frameColor: string;
@Input('minValue') minValue: number;
@Input('maxValue') maxValue: number;
@Input('decimals') decimals?: number;
@Input('zones') zones: Array<any>;
@Input('title') title: string;
@Input('units') units: string;
Expand Down Expand Up @@ -92,6 +93,7 @@ export class GaugeSteelComponent implements OnInit, OnChanges, OnDestroy {
//minMax
this.gaugeOptions['minValue'] = this.minValue;
this.gaugeOptions['maxValue'] = this.maxValue;
this.gaugeOptions['lcdDecimals'] = this.decimals !== undefined && this.decimals !== null ? this.decimals : 2;

//labels
this.gaugeOptions['titleString'] = this.title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ export class WidgetGaugeNgLinearComponent extends BaseWidgetComponent implements
const defaultOptions = {
minValue: scale.min,
maxValue: scale.max,
valueInt: this.widgetProperties.config.numInt,
valueDec: this.widgetProperties.config.numDecimal,

valueInt: this.widgetProperties.config.numInt !== undefined && this.widgetProperties.config.numInt !== null ? this.widgetProperties.config.numInt : 1,
valueDec: this.widgetProperties.config.numDecimal !== undefined && this.widgetProperties.config.numDecimal !== null ? this.widgetProperties.config.numDecimal : 2,

title: this.widgetProperties.config.displayName,
fontTitleSize: 40,
Expand Down Expand Up @@ -227,8 +228,10 @@ export class WidgetGaugeNgLinearComponent extends BaseWidgetComponent implements
colorNeedleShadowDown: "black",

majorTicks: scale.majorTicks,
majorTicksInt: this.widgetProperties.config.numInt,
majorTicksDec: this.widgetProperties.config.numDecimal,


majorTicksInt: this.widgetProperties.config.numInt !== undefined && this.widgetProperties.config.numInt !== null ? this.widgetProperties.config.numInt : 1,
majorTicksDec: this.widgetProperties.config.numDecimal !== undefined && this.widgetProperties.config.numDecimal !== null ? this.widgetProperties.config.numDecimal : 2,
numberSide: "left",
fontNumbersSize: 25,
numbersMargin: isVertical ? 8 : 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ export class WidgetGaugeNgRadialComponent extends BaseWidgetComponent implements
this.gaugeOptions.fontNumbers="arial";
this.gaugeOptions.fontNumbersWeight="bold";

this.gaugeOptions.valueInt = this.widgetProperties.config.numInt;
this.gaugeOptions.valueDec = this.widgetProperties.config.numDecimal;
this.gaugeOptions.majorTicksInt = this.widgetProperties.config.numInt;
this.gaugeOptions.majorTicksDec = this.widgetProperties.config.numDecimal;
this.gaugeOptions.valueInt = this.widgetProperties.config.numInt !== undefined && this.widgetProperties.config.numInt !== null ? this.widgetProperties.config.numInt : 1;
this.gaugeOptions.valueDec = this.widgetProperties.config.numDecimal !== undefined && this.widgetProperties.config.numDecimal !== null ? this.widgetProperties.config.numDecimal : 2;
this.gaugeOptions.majorTicksInt = this.widgetProperties.config.numInt !== undefined && this.widgetProperties.config.numInt !== null ? this.widgetProperties.config.numInt : 1;
this.gaugeOptions.majorTicksDec = this.widgetProperties.config.numDecimal !== undefined && this.widgetProperties.config.numDecimal !== null ? this.widgetProperties.config.numDecimal : 2;
this.gaugeOptions.highlightsWidth = 0;

this.gaugeOptions.animation = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

[minValue]="widgetProperties.config.displayScale.lower"
[maxValue]="widgetProperties.config.displayScale.upper"
[decimals]="widgetProperties.config.numDecimal"

[zones]="this.zones"
[title]="widgetProperties.config.displayName"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class WidgetGaugeComponent extends BaseWidgetComponent implements OnInit,
digitalMeter: false,
},
// numInt: 1,
// numDecimal: 1,
numDecimal: 2,
enableTimeout: false,
dataTimeout: 5
};
Expand Down