Added timestamps to grid
This commit is contained in:
parent
0c05a191c5
commit
7545dd8069
@ -33,6 +33,8 @@
|
||||
[yScaleMin]="0"
|
||||
[yScaleMax]="30"
|
||||
[yAxisTickFormatting]="voltFormat"
|
||||
[xAxis]="true"
|
||||
[xAxisTickFormatting]="dateFormat"
|
||||
[roundDomains]="true"
|
||||
></ngx-charts-area-chart>
|
||||
</div>
|
||||
|
@ -21,6 +21,16 @@ export class BatteryComponent implements OnInit {
|
||||
|
||||
ngOnInit() { }
|
||||
|
||||
dateFormat(date: Date) {
|
||||
let hours = date.getHours();
|
||||
if(hours > 12) hours -= 12;
|
||||
|
||||
let minutes: any = date.getMinutes();
|
||||
if(minutes < 10) minutes = '0' + minutes;
|
||||
|
||||
return `${hours}:${minutes} ${date.getHours() > 12 ? 'PM' : 'AM'}`;
|
||||
}
|
||||
|
||||
voltFormat(val) {
|
||||
return `${val} V`
|
||||
}
|
||||
|
@ -48,9 +48,10 @@ export class BatteryService {
|
||||
this.relayMode = data.config.relayMode ? data.config.relayMode.toString() : 'null';
|
||||
this.batteries = Object.keys(data.modules).map(key => {
|
||||
let last = data.modules[key].length - 1;
|
||||
console.log(data.modules[key][last]);
|
||||
return {
|
||||
charge: data.modules[key][last].charge,
|
||||
chargeHistory: data.modules[key].map((val, i) => ({name: i, value: val.charge})),
|
||||
chargeHistory: data.modules[key].map((val, i) => ({name: val.timestamp.toDate(), value: val.charge})),
|
||||
name: key,
|
||||
temp: data.modules[key][last].temp,
|
||||
tempHistory: data.modules[key].map((val, i) => ({name: i, value: val.temp}))
|
||||
|
Loading…
Reference in New Issue
Block a user