Fixed temperature graph

This commit is contained in:
Zakary Timson 2018-12-20 18:56:00 -05:00
parent 0869970839
commit 556146a415
2 changed files with 4 additions and 4 deletions

View File

@ -7,7 +7,7 @@
</h1> </h1>
<div class="w-100 mb-5" style="min-height: 400px"> <div class="w-100 mb-5" style="min-height: 400px">
<ngx-charts-area-chart #chart1 <ngx-charts-area-chart #chart1
[results]="batteryService.percentageData" [results]="batteryService.chargeData"
[scheme]="scheme" [scheme]="scheme"
[yAxis]="true" [yAxis]="true"
[yScaleMin]="0" [yScaleMin]="0"

View File

@ -9,7 +9,7 @@ export class BatteryService {
average = 0; average = 0;
temperatureData = []; temperatureData = [];
percentageData = []; chargeData = [];
batteries = []; batteries = [];
last: Date; last: Date;
@ -52,8 +52,8 @@ export class BatteryService {
this.batteries = Object.keys(data.modules).map(key => ({name: key, history: data.modules[key]})); this.batteries = Object.keys(data.modules).map(key => ({name: key, history: data.modules[key]}));
this.average = this.batteries.reduce((acc, battery) => acc + battery.history[0].charge, 0) / this.batteries.length; this.average = this.batteries.reduce((acc, battery) => acc + battery.history[0].charge, 0) / this.batteries.length;
this.percentageData = this.batteries.map(battery => ({name: battery.name, series: battery.history.map((history, i) => ({name: i, value: history.charge}))})); this.chargeData = this.batteries.map(battery => ({name: battery.name, series: battery.history.map((history, i) => ({name: i, value: history.charge}))}));
this.temperatureData = this.batteries.map(battery => ({name: battery.name, series: battery.history.map((history, i) => ({name: i, value: Math.round(history.temp * 10) / 10}))})); this.temperatureData = this.batteries.map(battery => ({name: battery.name, series: battery.history.map((history, i) => ({name: i, value: Math.round((history.temp || 0) * 10) / 10}))}));
}); });
} }
} }