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,7 +180,9 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge { | ||
180 | 180 | ||
181 | drawDigitalTitle(context, options); | 181 | drawDigitalTitle(context, options); |
182 | 182 | ||
183 | - drawDigitalLabel(context, options); | 183 | + if (!options.showTimestamp) { |
184 | + drawDigitalLabel(context, options); | ||
185 | + } | ||
184 | 186 | ||
185 | drawDigitalMinMax(context, options); | 187 | drawDigitalMinMax(context, options); |
186 | 188 | ||
@@ -198,6 +200,10 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge { | @@ -198,6 +200,10 @@ export default class CanvasDigitalGauge extends canvasGauges.BaseGauge { | ||
198 | 200 | ||
199 | drawDigitalValue(context, options, this.value); | 201 | drawDigitalValue(context, options, this.value); |
200 | 202 | ||
203 | + if (options.showTimestamp) { | ||
204 | + drawDigitalLabel(context, options); | ||
205 | + } | ||
206 | + | ||
201 | this.elementValueClone.initialized = true; | 207 | this.elementValueClone.initialized = true; |
202 | this.elementValueClone.renderedValue = this.value; | 208 | this.elementValueClone.renderedValue = this.value; |
203 | } | 209 | } |
@@ -45,6 +45,9 @@ export default class TbCanvasDigitalGauge { | @@ -45,6 +45,9 @@ export default class TbCanvasDigitalGauge { | ||
45 | (settings.unitTitle && settings.unitTitle.length > 0 ? | 45 | (settings.unitTitle && settings.unitTitle.length > 0 ? |
46 | settings.unitTitle : dataKey.label) : ''); | 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 | this.localSettings.gaugeWidthScale = settings.gaugeWidthScale || 0.75; | 51 | this.localSettings.gaugeWidthScale = settings.gaugeWidthScale || 0.75; |
49 | this.localSettings.gaugeColor = settings.gaugeColor || tinycolor(keyColor).setAlpha(0.2).toRgbString(); | 52 | this.localSettings.gaugeColor = settings.gaugeColor || tinycolor(keyColor).setAlpha(0.2).toRgbString(); |
50 | 53 | ||
@@ -167,6 +170,7 @@ export default class TbCanvasDigitalGauge { | @@ -167,6 +170,7 @@ export default class TbCanvasDigitalGauge { | ||
167 | 170 | ||
168 | symbol: this.localSettings.units, | 171 | symbol: this.localSettings.units, |
169 | label: this.localSettings.unitTitle, | 172 | label: this.localSettings.unitTitle, |
173 | + showTimestamp: this.localSettings.showTimestamp, | ||
170 | hideValue: this.localSettings.hideValue, | 174 | hideValue: this.localSettings.hideValue, |
171 | hideMinMax: this.localSettings.hideMinMax, | 175 | hideMinMax: this.localSettings.hideMinMax, |
172 | 176 | ||
@@ -193,6 +197,12 @@ export default class TbCanvasDigitalGauge { | @@ -193,6 +197,12 @@ export default class TbCanvasDigitalGauge { | ||
193 | if (cellData.data.length > 0) { | 197 | if (cellData.data.length > 0) { |
194 | var tvPair = cellData.data[cellData.data.length - | 198 | var tvPair = cellData.data[cellData.data.length - |
195 | 1]; | 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 | var value = tvPair[1]; | 206 | var value = tvPair[1]; |
197 | this.gauge.value = value; | 207 | this.gauge.value = value; |
198 | } | 208 | } |
@@ -269,6 +279,16 @@ export default class TbCanvasDigitalGauge { | @@ -269,6 +279,16 @@ export default class TbCanvasDigitalGauge { | ||
269 | "type": "boolean", | 279 | "type": "boolean", |
270 | "default": false | 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 | "showValue": { | 292 | "showValue": { |
273 | "title": "Show value text", | 293 | "title": "Show value text", |
274 | "type": "boolean", | 294 | "type": "boolean", |
@@ -477,6 +497,8 @@ export default class TbCanvasDigitalGauge { | @@ -477,6 +497,8 @@ export default class TbCanvasDigitalGauge { | ||
477 | "showTitle", | 497 | "showTitle", |
478 | "unitTitle", | 498 | "unitTitle", |
479 | "showUnitTitle", | 499 | "showUnitTitle", |
500 | + "showTimestamp", | ||
501 | + "timestampFormat", | ||
480 | "showValue", | 502 | "showValue", |
481 | "showMinMax", | 503 | "showMinMax", |
482 | "gaugeWidthScale", | 504 | "gaugeWidthScale", |