Added test service

This commit is contained in:
2017-04-04 13:14:19 +02:00
parent 73f75dbfc9
commit 66ef158da0
14 changed files with 22918 additions and 4494 deletions
+15 -32
View File
@@ -1,37 +1,22 @@
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { DataService } from './data.service';
import { LineData } from './line-data';
@Component({
selector: 'line-chart',
templateUrl: './chart.component.html'
})
export class LineChartComponent {
export class LineChartComponent implements OnInit {
// lineChart
public lineChartData:Array<any> = [
{data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A'},
{data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B'},
{data: [18, 48, 77, 9, 100, 27, 40], label: 'Series C'}
{data: [0,0,0,0,0,0,0], label: 'Series A'}
];
public lineChartLabels:Array<any> = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
public lineChartOptions:any = {
responsive: true
};
public lineChartColors:Array<any> = [
{ // grey
backgroundColor: 'rgba(148,159,177,0.2)',
borderColor: 'rgba(148,159,177,1)',
pointBackgroundColor: 'rgba(148,159,177,1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(148,159,177,0.8)'
},
{ // dark grey
backgroundColor: 'rgba(77,83,96,0.2)',
borderColor: 'rgba(77,83,96,1)',
pointBackgroundColor: 'rgba(77,83,96,1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(77,83,96,1)'
},
{ // grey
backgroundColor: 'rgba(148,159,177,0.2)',
borderColor: 'rgba(148,159,177,1)',
@@ -44,17 +29,6 @@ export class LineChartComponent {
public lineChartLegend:boolean = true;
public lineChartType:string = 'line';
public randomize():void {
let _lineChartData:Array<any> = new Array(this.lineChartData.length);
for (let i = 0; i < this.lineChartData.length; i++) {
_lineChartData[i] = {data: new Array(this.lineChartData[i].data.length), label: this.lineChartData[i].label};
for (let j = 0; j < this.lineChartData[i].data.length; j++) {
_lineChartData[i].data[j] = Math.floor((Math.random() * 100) + 1);
}
}
this.lineChartData = _lineChartData;
}
// events
public chartClicked(e:any):void {
console.log(e);
@@ -63,4 +37,13 @@ export class LineChartComponent {
public chartHovered(e:any):void {
console.log(e);
}
constructor(private dataService: DataService) {}
ngOnInit(): void {
this.dataService
.get()
.subscribe(res => this.lineChartData[0].data = res.data);
}
}