Get HOV, TOE1,TOE2,HT data

This commit is contained in:
Bluepr1nt
2017-04-05 12:58:10 +02:00
parent bd502b0677
commit 8b85bf51e2
3 changed files with 34 additions and 10 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ export class LineChartComponent implements OnInit {
console.log(this.lineChartLabels);
const newDataSet = [];
const newLine = {data: res.lines.data, label: res.lines.label};
const newLine = {data: res.TOE1.data, label: res.TOE1.label};
newDataSet.push(newLine);
this.lineChartData = newDataSet;
+29 -8
View File
@@ -47,18 +47,39 @@ export class DataService {
}
function mapData(response:Response): GraphData {
let nums = response.json().map(toData);
let times = response.json().map(timeToData)
let TOE1S = response.json().map(toe1ToData);
let TOE2S = response.json().map(toe2ToData);
let HOV = response.json().map(hovToData);
let HT = response.json().map(htToData);
let times = response.json().map(timeToData);
let line:LineData = <LineData>({data: nums, label: "Energieverbruik"});
let Toe1Line:LineData = <LineData>({data: TOE1S, label: "Totaal Energieverbruik tarief 1"});
let Toe2Line:LineData = <LineData>({data: TOE2S, label: "Totaal Energieverbruik tarief 2"});
let HovLine:LineData = <LineData>({data: HOV, label: "Huidig Energieverbruik"});
let HtLine:LineData = <LineData>({data: HT, label: "Huidig Tarief"});
let label:LabelData = <LabelData>({data: times});
let graph:GraphData = <GraphData>({lines:line,labels:label});
let graph:GraphData = <GraphData>({TOE1:Toe1Line,TOE2:Toe2Line,HOV:HovLine,HT:HtLine,labels:label});
return graph;
}
function toData(r:any){
let num = r.TOE1;
return num;
function toe1ToData(r:any){
let TOE1 = r.TOE1;
return TOE1;
}
function toe2ToData(r:any){
let TOE2 = r.TOE2;
return TOE2;
}
function hovToData(r:any){
let HOV = r.HOV;
return HOV;
}
function htToData(r:any){
let HT = r.HT;
return HT;
}
function timeToData(r:any){
@@ -81,4 +102,4 @@ function toDevice(r:any){
});
return device;
}
}
+4 -1
View File
@@ -2,6 +2,9 @@ import { LineData } from './line-data';
import { LabelData } from './label-data';
export class GraphData {
public lines: LineData;
public TOE1: LineData;
public TOE2: LineData;
public HOV: LineData;
public HT: LineData;
public labels: LabelData;
}