From 8b85bf51e2fd2988074fc773c55593f43db54116 Mon Sep 17 00:00:00 2001 From: Bluepr1nt Date: Wed, 5 Apr 2017 12:57:58 +0200 Subject: [PATCH] Get HOV, TOE1,TOE2,HT data --- mean-app/src/app/chart.component.ts | 2 +- mean-app/src/app/data.service.ts | 37 ++++++++++++++++++++++------- mean-app/src/app/graph-data.ts | 5 +++- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/mean-app/src/app/chart.component.ts b/mean-app/src/app/chart.component.ts index b8da890..0374dc8 100644 --- a/mean-app/src/app/chart.component.ts +++ b/mean-app/src/app/chart.component.ts @@ -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; diff --git a/mean-app/src/app/data.service.ts b/mean-app/src/app/data.service.ts index 91056cf..da1044b 100644 --- a/mean-app/src/app/data.service.ts +++ b/mean-app/src/app/data.service.ts @@ -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 = ({data: nums, label: "Energieverbruik"}); + let Toe1Line:LineData = ({data: TOE1S, label: "Totaal Energieverbruik tarief 1"}); + let Toe2Line:LineData = ({data: TOE2S, label: "Totaal Energieverbruik tarief 2"}); + let HovLine:LineData = ({data: HOV, label: "Huidig Energieverbruik"}); + let HtLine:LineData = ({data: HT, label: "Huidig Tarief"}); let label:LabelData = ({data: times}); - let graph:GraphData = ({lines:line,labels:label}); + let graph: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; -} \ No newline at end of file +} diff --git a/mean-app/src/app/graph-data.ts b/mean-app/src/app/graph-data.ts index 02397c0..3c88440 100644 --- a/mean-app/src/app/graph-data.ts +++ b/mean-app/src/app/graph-data.ts @@ -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; }