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

Radial gauge inaccurate for larger numbers #366

Merged
merged 2 commits into from
Apr 5, 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
21 changes: 19 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@angular/platform-browser": "17.2.1",
"@angular/platform-browser-dynamic": "17.2.1",
"@angular/router": "17.2.1",
"@robloche/chartjs-plugin-streaming": "^3.1.0",
"@types/canvas-gauges": "^2.1.2",
"@types/hammerjs": "^2.0.45",
"@types/howler": "^2.2.10",
Expand All @@ -69,11 +70,10 @@
"@types/node": "^20.8.6",
"angular-resize-event": "git+https://git@github.com/dereekb/angular-resize-event#00ef5139ccd6a02f0afd7639ae1bd365ac8b13f9",
"angular-split": "^17.2.0",
"canvas-gauges": "^2.1.7",
"@biacsics/ng-canvas-gauges": "^6.0.14",
"chart.js": "^4.4.2",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-plugin-annotation": "^3.0.1",
"@robloche/chartjs-plugin-streaming": "^3.1.0",
"codelyzer": "^6.0.0",
"compare-versions": "^5.0.1",
"core-js": "^3.13.1",
Expand Down Expand Up @@ -101,5 +101,7 @@
"tslint": "^6.1.3",
"typescript": "^5.3.3",
"zone.js": "~0.14.4"
},
"dependencies": {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@

animation="true"
[attr.animation-duration]="this.gaugeOptions.animationDuration"
[attr.animate-value]="this.gaugeOptions.animatedValue"
animation-rule="linear"
animated-value="false"
animate-on-init="false"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ViewChild, ElementRef, Component, OnInit, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
import { Subscription, sampleTime } from 'rxjs';
import { Subscription } from 'rxjs';
import { ResizedEvent, AngularResizeEventModule } from 'angular-resize-event';

import { IZone, IZoneState } from '../../core/interfaces/app-settings.interfaces';
import { IDataHighlight } from '../../core/interfaces/widgets-interface';
import { LinearGauge, LinearGaugeOptions } from '../../gauges-module/linear-gauge';
import { LinearGaugeOptions, LinearGauge, GaugesModule } from '@biacsics/ng-canvas-gauges';
import { BaseWidgetComponent } from '../../base-widget/base-widget.component';
import { AppSettingsService } from '../../core/services/app-settings.service';
import { JsonPipe } from '@angular/common';
Expand All @@ -14,12 +14,12 @@ import { JsonPipe } from '@angular/common';
templateUrl: './widget-gauge-ng-linear.component.html',
styleUrls: ['./widget-gauge-ng-linear.component.scss'],
standalone: true,
imports: [AngularResizeEventModule, LinearGauge, JsonPipe]
imports: [AngularResizeEventModule, GaugesModule, JsonPipe]
})

export class WidgetGaugeNgLinearComponent extends BaseWidgetComponent implements OnInit, OnDestroy, OnChanges {
@ViewChild('linearWrapperDiv', {static: true, read: ElementRef}) private wrapper: ElementRef;
@ViewChild('linearGauge', {static: true, read: ElementRef}) protected linearGauge: ElementRef;
@ViewChild('linearGauge', {static: true, read: LinearGauge}) protected linearGauge: LinearGauge;

// main gauge value variable
public dataValue = 0;
Expand Down Expand Up @@ -177,14 +177,14 @@ export class WidgetGaugeNgLinearComponent extends BaseWidgetComponent implements
let upper = zone.upper || this.widgetProperties.config.maxValue;
let color: string;
switch (zone.state) {
case 1:
case IZoneState.warning:
color = this.theme.warn;
break;
case IZoneState.alarm:
color = this.theme.warnDark;
break;
default:
color = this.theme.primary;
color = "rgba(0,0,0,0)";
}
myZones.push({from: lower, to: upper, color: color});
}
Expand All @@ -202,6 +202,8 @@ export class WidgetGaugeNgLinearComponent extends BaseWidgetComponent implements
this.gaugeOptions.majorTicksInt = this.widgetProperties.config.numInt;
this.gaugeOptions.majorTicksDec = this.widgetProperties.config.numDecimal;

this.gaugeOptions.animateOnInit = false;
this.gaugeOptions.animatedValue = false;
this.gaugeOptions.animationDuration = this.widgetProperties.config.paths['gaugePath'].sampleTime - 25; // prevent data/amnimation collisions

if (this.widgetProperties.config.gaugeTicks) {
Expand Down Expand Up @@ -248,7 +250,7 @@ export class WidgetGaugeNgLinearComponent extends BaseWidgetComponent implements
this.gaugeOptions.minorTicks = 10;
this.gaugeOptions.ticksWidthMinor = 4;

this.gaugeOptions.highlightsWidth = 15;
this.gaugeOptions.highlightsWidth = 6;
}
else {
// Vertical No ticks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,107 +1,24 @@
<div class="ngRadialWrapper" #ngRadialWrapperDiv (resized)="onResized($event)">
<radial-gauge class="radialGauge" id="{{widgetProperties.uuid}}" #radialGauge
[attr.width]="gaugeOptions.width"
[attr.height]="gaugeOptions.height"
[options]="gaugeOptions"
[value]="dataValue"

[attr.title]="widgetProperties.config.displayName"
font-title="arial"
[attr.font-title-size]="gaugeOptions.fontTitleSize"
font-title-weight="bold"
[attr.color-title]="gaugeOptions.colorTitle"

[attr.units]="unitName"
[value]="dataValue"
[attr.min-value]="widgetProperties.config.minValue"
[attr.max-value]="widgetProperties.config.maxValue"
font-Units="arial"
font-Units-size="25"
font-Units-weight=""
[attr.color-units]="gaugeOptions.colorUnits"

[attr.borders]="gaugeOptions.borders"
[attr.border-outer-width]="gaugeOptions.borderOuterWidth"
[attr.border-middle-width]="gaugeOptions.borderMiddleWidth"
[attr.border-inner-width]="gaugeOptions.borderInnerWidth"
[attr.border-shadow-width]="gaugeOptions.borderShadowWidth"
color-border-outer="red"
color-border-outer-end="green"
[attr.color-border-middle]="gaugeOptions.colorBarProgress"
[attr.color-border-middle-end]="gaugeOptions.colorBarProgress"
[attr.color-border-inner]="gaugeOptions.colorPlate"
[attr.color-border-inner-end]="gaugeOptions.colorPlate"


[attr.color-plate]="gaugeOptions.colorPlate"
[attr.color-plate-end]="gaugeOptions.colorPlate"

[attr.bar-progress]="gaugeOptions.barProgress"
[attr.bar-width]="gaugeOptions.barWidth"
bar-stroke-width="0"
bar-shadow="0"
[attr.color-bar]="gaugeOptions.colorBar"
[attr.color-bar-progress]="gaugeOptions.colorBarProgress"
color-bar-stroke=""

[attr.value-box]="gaugeOptions.valueBox"
[attr.value-box-stroke]="gaugeOptions.valueBoxStroke"
[attr.color-value-box-rect]="gaugeOptions.colorValueBoxRect"
[attr.color-value-box-rect-end]="gaugeOptions.colorValueBoxRectEnd"
[attr.value-box-width]="gaugeOptions.valueBoxWidth"
[attr.value-box-border-radius]="gaugeOptions.valueBoxBorderRadius"
[attr.color-value-box-background]="gaugeOptions.colorValueBoxBackground"
value-text=""
[attr.value-int]="gaugeOptions.valueInt"
[attr.value-dec]="gaugeOptions.valueDec"
font-value="arial"
[attr.font-value-size]="gaugeOptions.fontValueSize"
font-value-weight="bold"
[attr.color-value-text]="gaugeOptions.colorValueText"
value-text-shadow="false"
color-value-box-shadow=""

[attr.ticks-angle]="gaugeOptions.ticksAngle"
[attr.start-angle]="gaugeOptions.startAngle"
[attr.exact-ticks]="gaugeOptions.exactTicks"
[attr.stroke-ticks]="gaugeOptions.strokeTicks"
[attr.color-stroke-ticks]="this.colorStrokeTicks"
[attr.major-ticks]="gaugeOptions.majorTicks"
[attr.major-ticks-int]="gaugeOptions.majorTicksInt"
[attr.major-ticks-dec]="gaugeOptions.majorTicksDec"
[attr.color-major-ticks]="gaugeOptions.colorMajorTicks"
[attr.minor-ticks]="gaugeOptions.minorTicks"
[attr.color-minor-ticks]="gaugeOptions.colorMinorTicks"
[attr.numbers-margin]="gaugeOptions.numbersMargin"
font-numbers="arial"
[attr.font-numbers-size]="gaugeOptions.fontNumbersSize"
font-numbers-weight="bold"
[attr.color-numbers]="gaugeOptions.colorNumbers"
[attr.highlights]="gaugeOptions.highlights|json"
[attr.highlights-width]="gaugeOptions.highlightsWidth"

animation="true"
[attr.animation-duration]="gaugeOptions.animationDuration"
animation-rule="linear"
animated-value="false"
animate-on-init="false"
[attr.animation-target]="gaugeOptions.animationTarget"
[attr.use-min-path]="gaugeOptions.useMinPath"

[attr.needle]="gaugeOptions.needle"
[attr.needle-end]="gaugeOptions.needleEnd"
[attr.needle-start]="gaugeOptions.needleStart"
[attr.needle-shadow]="gaugeOptions.needleShadow"
[attr.needle-width]="gaugeOptions.needleWidth"
[attr.needle-type]="gaugeOptions.needleType"
[attr.needle-circle-size]="gaugeOptions.needleCircleSize"
[attr.needle-circle-inner]="gaugeOptions.needleCircleInner"
[attr.needle-circle-outer]="gaugeOptions.needleCircleOuter"
[attr.color-needle]="gaugeOptions.colorNeedle"
[attr.color-needle-end]="gaugeOptions.colorNeedleEnd"
[attr.color-needle-shadow-up]="gaugeOptions.colorNeedleShadowUp"
[attr.color-needle-shadow-down]="gaugeOptions.colorNeedleShadowDown"
[attr.color-needle-circle-inner]="gaugeOptions.colorNeedleCircleInner"
[attr.color-needle-circle-inner-end]="gaugeOptions.colorNeedleCircleInnerEnd"
[attr.color-needle-circle-outer]="gaugeOptions.colorNeedleCircleOuter"
[attr.color-needle-circle-outer-end]="gaugeOptions.colorNeedleCircleOuterEnd"
></radial-gauge>
</div>
Loading