added labels
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+24
-10
@@ -8,7 +8,7 @@ webpackJsonp([1,4],{
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_rxjs_add_operator_map__ = __webpack_require__(617);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_rxjs_add_operator_map___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_rxjs_add_operator_map__);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__angular_http__ = __webpack_require__(284);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__line_data__ = __webpack_require__(455);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__graph_data__ = __webpack_require__(455);
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return DataService; });
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
@@ -51,18 +51,26 @@ var DataService = (function () {
|
||||
var _a;
|
||||
}());
|
||||
function mapData(response) {
|
||||
console.log('Mapping data', __WEBPACK_IMPORTED_MODULE_3__line_data__["a" /* LineData */]);
|
||||
console.log('Mapping data', __WEBPACK_IMPORTED_MODULE_3__graph_data__["a" /* GraphData */]);
|
||||
var nums = response.json().map(toData);
|
||||
var times = response.json().map(timeToData);
|
||||
console.log(nums);
|
||||
var line = ({ data: nums, label: "Series A" });
|
||||
var label = ({ data: times });
|
||||
console.log(line);
|
||||
return line;
|
||||
var graph = ({ lines: line, labels: label });
|
||||
return graph;
|
||||
}
|
||||
function toData(r) {
|
||||
var num = r.TOE1;
|
||||
console.log('Parsed Data:', num);
|
||||
return num;
|
||||
}
|
||||
function timeToData(r) {
|
||||
var times = r.time;
|
||||
console.log('Parsed Time:', times);
|
||||
return times;
|
||||
}
|
||||
//# sourceMappingURL=C:/Users/martijn/Documents/GitHub/smarthome/mean-app/src/data.service.js.map
|
||||
|
||||
/***/ }),
|
||||
@@ -220,7 +228,12 @@ var LineChartComponent = (function () {
|
||||
];
|
||||
this.lineChartLabels = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
|
||||
this.lineChartOptions = {
|
||||
responsive: true
|
||||
responsive: true,
|
||||
title: {
|
||||
display: true,
|
||||
position: 'left',
|
||||
text: 'Watt'
|
||||
}
|
||||
};
|
||||
this.lineChartColors = [
|
||||
{
|
||||
@@ -249,9 +262,10 @@ var LineChartComponent = (function () {
|
||||
.subscribe(function (res) {
|
||||
console.log(res);
|
||||
var newDataSet = [];
|
||||
var newLine = { data: res.data, label: res.label };
|
||||
var newLine = { data: res.lines.data, label: res.lines.label };
|
||||
newDataSet.push(newLine);
|
||||
_this.lineChartData = newDataSet;
|
||||
_this.lineChartLabels = res.labels.data;
|
||||
});
|
||||
console.log("Init");
|
||||
};
|
||||
@@ -273,13 +287,13 @@ var LineChartComponent = (function () {
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return LineData; });
|
||||
var LineData = (function () {
|
||||
function LineData() {
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GraphData; });
|
||||
var GraphData = (function () {
|
||||
function GraphData() {
|
||||
}
|
||||
return LineData;
|
||||
return GraphData;
|
||||
}());
|
||||
//# sourceMappingURL=C:/Users/martijn/Documents/GitHub/smarthome/mean-app/src/line-data.js.map
|
||||
//# sourceMappingURL=C:/Users/martijn/Documents/GitHub/smarthome/mean-app/src/graph-data.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -14,7 +14,12 @@ export class LineChartComponent implements OnInit {
|
||||
];
|
||||
public lineChartLabels:Array<any> = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
|
||||
public lineChartOptions:any = {
|
||||
responsive: true
|
||||
responsive: true,
|
||||
title: {
|
||||
display: true,
|
||||
position: 'left',
|
||||
text: 'Watt'
|
||||
}
|
||||
};
|
||||
public lineChartColors:Array<any> = [
|
||||
{ // grey
|
||||
@@ -46,10 +51,13 @@ export class LineChartComponent implements OnInit {
|
||||
.get()
|
||||
.subscribe(res => {
|
||||
console.log(res);
|
||||
|
||||
const newDataSet = [];
|
||||
const newLine = {data: res.data, label: res.label};
|
||||
const newLine = {data: res.lines.data, label: res.lines.label};
|
||||
newDataSet.push(newLine);
|
||||
this.lineChartData = newDataSet;
|
||||
|
||||
this.lineChartLabels = res.labels.data;
|
||||
});
|
||||
|
||||
console.log("Init");
|
||||
|
||||
@@ -4,6 +4,8 @@ import 'rxjs/add/operator/map'
|
||||
import { Http, Response, Headers } from '@angular/http';
|
||||
|
||||
import { LineData } from './line-data';
|
||||
import { GraphData } from './graph-data';
|
||||
import { LabelData } from './label-data';
|
||||
|
||||
@Injectable()
|
||||
export class DataService {
|
||||
@@ -11,7 +13,7 @@ export class DataService {
|
||||
|
||||
constructor(private http : Http){}
|
||||
|
||||
get(): Observable<LineData> {
|
||||
get(): Observable<GraphData> {
|
||||
console.log('Getting data');
|
||||
let lineChartData$ =
|
||||
//<LineData>( {data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A'} );
|
||||
@@ -21,9 +23,7 @@ export class DataService {
|
||||
.map(mapData);
|
||||
|
||||
console.log(lineChartData$);
|
||||
|
||||
return lineChartData$;
|
||||
|
||||
}
|
||||
|
||||
private getHeaders(){
|
||||
@@ -33,15 +33,18 @@ export class DataService {
|
||||
}
|
||||
}
|
||||
|
||||
function mapData(response:Response): LineData {
|
||||
console.log('Mapping data', LineData);
|
||||
function mapData(response:Response): GraphData {
|
||||
console.log('Mapping data', GraphData);
|
||||
let nums = response.json().map(toData);
|
||||
let times = response.json().map(timeToData)
|
||||
|
||||
console.log(nums);
|
||||
|
||||
let line:LineData = <LineData>({data: nums, label: "Series A"});
|
||||
let label:LabelData = <LabelData>({data: times});
|
||||
console.log(line);
|
||||
return line;
|
||||
let graph:GraphData = <GraphData>({lines:line,labels:label});
|
||||
return graph;
|
||||
}
|
||||
|
||||
function toData(r:any){
|
||||
@@ -50,3 +53,9 @@ function toData(r:any){
|
||||
return num;
|
||||
}
|
||||
|
||||
function timeToData(r:any){
|
||||
let times = r.time;
|
||||
console.log('Parsed Time:', times);
|
||||
return times;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { LineData } from './line-data';
|
||||
import { LabelData } from './label-data';
|
||||
|
||||
export class GraphData {
|
||||
public lines: LineData;
|
||||
public labels: LabelData;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export class LabelData {
|
||||
public data: string[];
|
||||
}
|
||||
Reference in New Issue
Block a user