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