Commit 6057a5e990dc2ae564465c532a38abba51f61bd7
1 parent
1b525cfe
minor fix in digital-gauge widgets
Showing
2 changed files
with
20 additions
and
3 deletions
@@ -155,6 +155,15 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge { | @@ -155,6 +155,15 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge { | ||
155 | return result; | 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 | draw() { | 167 | draw() { |
159 | try { | 168 | try { |
160 | 169 | ||
@@ -195,7 +204,9 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge { | @@ -195,7 +204,9 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge { | ||
195 | canvas.elementClone.initialized = true; | 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 | let context = this.contextValueClone; | 210 | let context = this.contextValueClone; |
200 | // clear the cache | 211 | // clear the cache |
201 | context.clearRect(x, y, w, h); | 212 | context.clearRect(x, y, w, h); |
@@ -208,10 +219,13 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge { | @@ -208,10 +219,13 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge { | ||
208 | 219 | ||
209 | if (options.showTimestamp) { | 220 | if (options.showTimestamp) { |
210 | drawDigitalLabel(context, options); | 221 | drawDigitalLabel(context, options); |
222 | + this.elementValueClone.renderedTimestamp = this.timestamp; | ||
211 | } | 223 | } |
212 | 224 | ||
213 | this.elementValueClone.initialized = true; | 225 | this.elementValueClone.initialized = true; |
214 | this.elementValueClone.renderedValue = this.value; | 226 | this.elementValueClone.renderedValue = this.value; |
227 | + | ||
228 | + valueChanged = true; | ||
215 | } | 229 | } |
216 | 230 | ||
217 | var progress = (canvasGauges.drawings.normalizedValue(options).normal - options.minValue) / | 231 | var progress = (canvasGauges.drawings.normalizedValue(options).normal - options.minValue) / |
@@ -219,7 +233,7 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge { | @@ -219,7 +233,7 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge { | ||
219 | 233 | ||
220 | var fixedProgress = progress.toFixed(3); | 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 | let context = this.contextProgressClone; | 237 | let context = this.contextProgressClone; |
224 | // clear the cache | 238 | // clear the cache |
225 | context.clearRect(x, y, w, h); | 239 | context.clearRect(x, y, w, h); |
@@ -197,8 +197,9 @@ export default class TbCanvasDigitalGauge { | @@ -197,8 +197,9 @@ export default class TbCanvasDigitalGauge { | ||
197 | if (cellData.data.length > 0) { | 197 | if (cellData.data.length > 0) { |
198 | var tvPair = cellData.data[cellData.data.length - | 198 | var tvPair = cellData.data[cellData.data.length - |
199 | 1]; | 199 | 1]; |
200 | + var timestamp; | ||
200 | if (this.localSettings.showTimestamp) { | 201 | if (this.localSettings.showTimestamp) { |
201 | - var timestamp = tvPair[0]; | 202 | + timestamp = tvPair[0]; |
202 | var filter= this.ctx.$scope.$injector.get('$filter'); | 203 | var filter= this.ctx.$scope.$injector.get('$filter'); |
203 | var timestampDisplayValue = filter('date')(timestamp, this.localSettings.timestampFormat); | 204 | var timestampDisplayValue = filter('date')(timestamp, this.localSettings.timestampFormat); |
204 | this.gauge.options.label = timestampDisplayValue; | 205 | this.gauge.options.label = timestampDisplayValue; |
@@ -206,6 +207,8 @@ export default class TbCanvasDigitalGauge { | @@ -206,6 +207,8 @@ export default class TbCanvasDigitalGauge { | ||
206 | var value = tvPair[1]; | 207 | var value = tvPair[1]; |
207 | if(value !== this.gauge.value) { | 208 | if(value !== this.gauge.value) { |
208 | this.gauge.value = value; | 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 | } |