UI: Fixed updated value in gauge widget in animation
This commit is contained in:
parent
7a749f0bcf
commit
f225870b52
@ -64,9 +64,13 @@ export interface AnalogueGaugeSettings {
|
||||
animationRule: AnimationRule;
|
||||
}
|
||||
|
||||
interface BaseGaugeModel extends BaseGauge {
|
||||
_value?: number;
|
||||
}
|
||||
|
||||
export abstract class TbBaseGauge<S, O extends GenericOptions> {
|
||||
|
||||
private gauge: BaseGauge;
|
||||
private gauge: BaseGaugeModel;
|
||||
|
||||
protected constructor(protected ctx: WidgetContext, canvasId: string) {
|
||||
const gaugeElement = $('#' + canvasId, ctx.$container)[0];
|
||||
@ -77,16 +81,20 @@ export abstract class TbBaseGauge<S, O extends GenericOptions> {
|
||||
|
||||
protected abstract createGaugeOptions(gaugeElement: HTMLElement, settings: S): O;
|
||||
|
||||
protected abstract createGauge(gaugeData: O): BaseGauge;
|
||||
protected abstract createGauge(gaugeData: O): BaseGaugeModel;
|
||||
|
||||
update() {
|
||||
if (this.ctx.data.length > 0) {
|
||||
const cellData = this.ctx.data[0];
|
||||
if (cellData.data.length > 0) {
|
||||
const tvPair = cellData.data[cellData.data.length -
|
||||
1];
|
||||
const tvPair = cellData.data[cellData.data.length - 1];
|
||||
const value = parseFloat(tvPair[1]);
|
||||
if (value !== this.gauge.value) {
|
||||
if (!this.gauge.options.animation) {
|
||||
this.gauge._value = value;
|
||||
} else {
|
||||
delete this.gauge._value;
|
||||
}
|
||||
this.gauge.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,6 @@ import { prepareFontSettings } from '@home/components/widget/lib/settings.models
|
||||
import { CanvasDigitalGauge, CanvasDigitalGaugeOptions } from '@home/components/widget/lib/canvas-digital-gauge';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { IWidgetSubscription } from '@core/api/widget-api.models';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { ColorProcessor, createValueSubscription, ValueSourceType } from '@shared/models/widget-settings.models';
|
||||
import GenericOptions = CanvasGauges.GenericOptions;
|
||||
|
||||
@ -260,6 +259,8 @@ export class TbCanvasDigitalGauge {
|
||||
if (value !== this.gauge.value) {
|
||||
if (!this.gauge.options.animation) {
|
||||
this.gauge._value = value;
|
||||
} else {
|
||||
delete this.gauge._value;
|
||||
}
|
||||
this.gauge.value = value;
|
||||
} else if (this.localSettings.showTimestamp && this.gauge.timestamp !== timestamp) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user