Commit 6057a5e990dc2ae564465c532a38abba51f61bd7

Authored by Sergey Tarnavskiy
1 parent 1b525cfe

minor fix in digital-gauge widgets

... ... @@ -155,6 +155,15 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge {
155 155 return result;
156 156 }
157 157
  158 + set timestamp(timestamp) {
  159 + this.options.timestamp = timestamp;
  160 + this.draw();
  161 + }
  162 +
  163 + get timestamp() {
  164 + return this.options.timestamp;
  165 + }
  166 +
158 167 draw() {
159 168 try {
160 169
... ... @@ -195,7 +204,9 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge {
195 204 canvas.elementClone.initialized = true;
196 205 }
197 206
198   - if (!this.elementValueClone.initialized || this.elementValueClone.renderedValue !== this.value) {
  207 + var valueChanged = false;
  208 +
  209 + if (!this.elementValueClone.initialized || this.elementValueClone.renderedValue !== this.value || (options.showTimestamp && this.elementValueClone.renderedTimestamp !== this.timestamp)) {
199 210 let context = this.contextValueClone;
200 211 // clear the cache
201 212 context.clearRect(x, y, w, h);
... ... @@ -208,10 +219,13 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge {
208 219
209 220 if (options.showTimestamp) {
210 221 drawDigitalLabel(context, options);
  222 + this.elementValueClone.renderedTimestamp = this.timestamp;
211 223 }
212 224
213 225 this.elementValueClone.initialized = true;
214 226 this.elementValueClone.renderedValue = this.value;
  227 +
  228 + valueChanged = true;
215 229 }
216 230
217 231 var progress = (canvasGauges.drawings.normalizedValue(options).normal - options.minValue) /
... ... @@ -219,7 +233,7 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge {
219 233
220 234 var fixedProgress = progress.toFixed(3);
221 235
222   - if (!this.elementProgressClone.initialized || this.elementProgressClone.renderedProgress !== fixedProgress) {
  236 + if (!this.elementProgressClone.initialized || this.elementProgressClone.renderedProgress !== fixedProgress || valueChanged) {
223 237 let context = this.contextProgressClone;
224 238 // clear the cache
225 239 context.clearRect(x, y, w, h);
... ...
... ... @@ -197,8 +197,9 @@ export default class TbCanvasDigitalGauge {
197 197 if (cellData.data.length > 0) {
198 198 var tvPair = cellData.data[cellData.data.length -
199 199 1];
  200 + var timestamp;
200 201 if (this.localSettings.showTimestamp) {
201   - var timestamp = tvPair[0];
  202 + timestamp = tvPair[0];
202 203 var filter= this.ctx.$scope.$injector.get('$filter');
203 204 var timestampDisplayValue = filter('date')(timestamp, this.localSettings.timestampFormat);
204 205 this.gauge.options.label = timestampDisplayValue;
... ... @@ -206,6 +207,8 @@ export default class TbCanvasDigitalGauge {
206 207 var value = tvPair[1];
207 208 if(value !== this.gauge.value) {
208 209 this.gauge.value = value;
  210 + } else if (this.localSettings.showTimestamp && this.gauge.timestamp != timestamp) {
  211 + this.gauge.timestamp = timestamp;
209 212 }
210 213 }
211 214 }
... ...