fixed issues in updating digital-value with progress-bar-animation

This commit is contained in:
Sergey Tarnavskiy 2018-06-14 16:02:03 +03:00
parent b922e070ae
commit 716762606e
2 changed files with 13 additions and 4 deletions

View File

@ -204,8 +204,13 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge {
} }
var valueChanged = false; var valueChanged = false;
if (!this.elementValueClone.initialized || angular.isDefined(this._value) && this.elementValueClone.renderedValue !== this._value || (options.showTimestamp && this.elementValueClone.renderedTimestamp !== this.timestamp)) {
if (!this.elementValueClone.initialized || this.elementValueClone.renderedValue !== this.value || (options.showTimestamp && this.elementValueClone.renderedTimestamp !== this.timestamp)) { if (angular.isDefined(this._value)) {
this.elementValueClone.renderedValue = this._value;
}
if (angular.isUndefined(this.elementValueClone.renderedValue)) {
this.elementValueClone.renderedValue = options.minValue;
}
let context = this.contextValueClone; let context = this.contextValueClone;
// clear the cache // clear the cache
context.clearRect(x, y, w, h); context.clearRect(x, y, w, h);
@ -214,7 +219,7 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge {
context.drawImage(canvas.elementClone, x, y, w, h); context.drawImage(canvas.elementClone, x, y, w, h);
context.save(); context.save();
drawDigitalValue(context, options, this.value); drawDigitalValue(context, options, this.elementValueClone.renderedValue);
if (options.showTimestamp) { if (options.showTimestamp) {
drawDigitalLabel(context, options); drawDigitalLabel(context, options);
@ -222,7 +227,6 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge {
} }
this.elementValueClone.initialized = true; this.elementValueClone.initialized = true;
this.elementValueClone.renderedValue = this.value;
valueChanged = true; valueChanged = true;
} }

View File

@ -70,6 +70,10 @@ export default class TbCanvasDigitalGauge {
(settings.title && settings.title.length > 0 ? (settings.title && settings.title.length > 0 ?
settings.title : dataKey.label) : ''); settings.title : dataKey.label) : '');
if (!this.localSettings.unitTitle && this.localSettings.showTimestamp) {
this.localSettings.unitTitle = ' ';
}
this.localSettings.titleFont = {}; this.localSettings.titleFont = {};
var settingsTitleFont = settings.titleFont; var settingsTitleFont = settings.titleFont;
if (!settingsTitleFont) { if (!settingsTitleFont) {
@ -206,6 +210,7 @@ export default class TbCanvasDigitalGauge {
var value = tvPair[1]; var value = tvPair[1];
if(value !== this.gauge.value) { if(value !== this.gauge.value) {
this.gauge.value = value; this.gauge.value = value;
this.gauge._value = value;
} else if (this.localSettings.showTimestamp && this.gauge.timestamp != timestamp) { } else if (this.localSettings.showTimestamp && this.gauge.timestamp != timestamp) {
this.gauge.timestamp = timestamp; this.gauge.timestamp = timestamp;
} }