Commit f5b42f098f7ced3345b7ed5a5a83ac589877a586
1 parent
ac3e4429
Display timestamp option for digital gauges.
Showing
2 changed files
with
29 additions
and
1 deletions
... | ... | @@ -180,7 +180,9 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge { |
180 | 180 | |
181 | 181 | drawDigitalTitle(context, options); |
182 | 182 | |
183 | - drawDigitalLabel(context, options); | |
183 | + if (!options.showTimestamp) { | |
184 | + drawDigitalLabel(context, options); | |
185 | + } | |
184 | 186 | |
185 | 187 | drawDigitalMinMax(context, options); |
186 | 188 | |
... | ... | @@ -198,6 +200,10 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge { |
198 | 200 | |
199 | 201 | drawDigitalValue(context, options, this.value); |
200 | 202 | |
203 | + if (options.showTimestamp) { | |
204 | + drawDigitalLabel(context, options); | |
205 | + } | |
206 | + | |
201 | 207 | this.elementValueClone.initialized = true; |
202 | 208 | this.elementValueClone.renderedValue = this.value; |
203 | 209 | } | ... | ... |
... | ... | @@ -45,6 +45,9 @@ export default class TbCanvasDigitalGauge { |
45 | 45 | (settings.unitTitle && settings.unitTitle.length > 0 ? |
46 | 46 | settings.unitTitle : dataKey.label) : ''); |
47 | 47 | |
48 | + this.localSettings.showTimestamp = settings.showTimestamp == true ? true : false; | |
49 | + this.localSettings.timestampFormat = settings.timestampFormat && settings.timestampFormat.length ? settings.timestampFormat : 'yyyy-MM-dd HH:mm:ss'; | |
50 | + | |
48 | 51 | this.localSettings.gaugeWidthScale = settings.gaugeWidthScale || 0.75; |
49 | 52 | this.localSettings.gaugeColor = settings.gaugeColor || tinycolor(keyColor).setAlpha(0.2).toRgbString(); |
50 | 53 | |
... | ... | @@ -167,6 +170,7 @@ export default class TbCanvasDigitalGauge { |
167 | 170 | |
168 | 171 | symbol: this.localSettings.units, |
169 | 172 | label: this.localSettings.unitTitle, |
173 | + showTimestamp: this.localSettings.showTimestamp, | |
170 | 174 | hideValue: this.localSettings.hideValue, |
171 | 175 | hideMinMax: this.localSettings.hideMinMax, |
172 | 176 | |
... | ... | @@ -193,6 +197,12 @@ export default class TbCanvasDigitalGauge { |
193 | 197 | if (cellData.data.length > 0) { |
194 | 198 | var tvPair = cellData.data[cellData.data.length - |
195 | 199 | 1]; |
200 | + if (this.localSettings.showTimestamp) { | |
201 | + var timestamp = tvPair[0]; | |
202 | + var filter= this.ctx.$scope.$injector.get('$filter'); | |
203 | + var timestampDisplayValue = filter('date')(timestamp, this.localSettings.timestampFormat); | |
204 | + this.gauge.options.label = timestampDisplayValue; | |
205 | + } | |
196 | 206 | var value = tvPair[1]; |
197 | 207 | this.gauge.value = value; |
198 | 208 | } |
... | ... | @@ -269,6 +279,16 @@ export default class TbCanvasDigitalGauge { |
269 | 279 | "type": "boolean", |
270 | 280 | "default": false |
271 | 281 | }, |
282 | + "showTimestamp": { | |
283 | + "title": "Show value timestamp", | |
284 | + "type": "boolean", | |
285 | + "default": false | |
286 | + }, | |
287 | + "timestampFormat": { | |
288 | + "title": "Timestamp format", | |
289 | + "type": "string", | |
290 | + "default": "yyyy-MM-dd HH:mm:ss" | |
291 | + }, | |
272 | 292 | "showValue": { |
273 | 293 | "title": "Show value text", |
274 | 294 | "type": "boolean", |
... | ... | @@ -477,6 +497,8 @@ export default class TbCanvasDigitalGauge { |
477 | 497 | "showTitle", |
478 | 498 | "unitTitle", |
479 | 499 | "showUnitTitle", |
500 | + "showTimestamp", | |
501 | + "timestampFormat", | |
480 | 502 | "showValue", |
481 | 503 | "showMinMax", |
482 | 504 | "gaugeWidthScale", | ... | ... |