2016-05-03 14:33:28 +03:00
|
|
|
import {Component, ViewEncapsulation} from 'angular2/core';
|
|
|
|
|
import {BaCard} from '../../../../theme';
|
|
|
|
|
|
|
|
|
|
import {ChartJsService} from "./chartJs.service";
|
|
|
|
|
|
|
|
|
|
import {CHART_DIRECTIVES} from 'ng2-charts';
|
|
|
|
|
import {chartColors} from "../../../../theme/theme.constants";
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'chart-js',
|
|
|
|
|
pipes: [],
|
|
|
|
|
providers: [ChartJsService],
|
|
|
|
|
encapsulation: ViewEncapsulation.None,
|
|
|
|
|
styles: [require('./chartJs.scss')],
|
|
|
|
|
directives: [BaCard, CHART_DIRECTIVES],
|
|
|
|
|
template: require('./chartJs.html'),
|
|
|
|
|
})
|
|
|
|
|
export class ChartJs {
|
2016-05-03 14:58:57 +03:00
|
|
|
|
2016-05-03 17:10:49 +03:00
|
|
|
public labels = {
|
|
|
|
|
one: ["Sleeping", "Designing", "Coding", "Cycling"],
|
2016-05-03 18:32:59 +03:00
|
|
|
two: ["April", "May", "June", "Jule", "August", "September", "October", "November", "December"],
|
|
|
|
|
three: ["May", "June", "Jule", "August", "September", "October", "November"]
|
2016-05-03 17:10:49 +03:00
|
|
|
};
|
|
|
|
|
public data = {
|
|
|
|
|
one: [20, 40, 5, 35],
|
2016-05-03 18:32:59 +03:00
|
|
|
two: [[1, 9, 3, 4, 5, 6, 7, 8, 2].map((e) => {return Math.sin(e) * 25 + 25})],
|
|
|
|
|
three: [
|
|
|
|
|
[65, 59, 90, 81, 56, 55, 40],
|
|
|
|
|
[28, 48, 40, 19, 88, 27, 45]
|
|
|
|
|
]
|
2016-05-03 17:10:49 +03:00
|
|
|
};
|
2016-05-03 18:32:59 +03:00
|
|
|
public series = ['Product A', 'Product B'];
|
2016-05-03 14:58:57 +03:00
|
|
|
public colours = chartColors;
|
|
|
|
|
public options = {
|
|
|
|
|
scaleShowLabelBackdrop : false,
|
2016-05-03 14:33:28 +03:00
|
|
|
segmentShowStroke : false,
|
2016-05-03 19:07:25 +03:00
|
|
|
// TODO: produce an error
|
2016-05-03 14:33:28 +03:00
|
|
|
// responsive: true,
|
|
|
|
|
scaleFontColor: "rgba(255,255,255,.7)",
|
|
|
|
|
scaleLineColor: "rgba(255,255,255,.7)",
|
|
|
|
|
pointLabelFontColor: "rgba(255,255,255,.7)"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
constructor(private _chartJsService:ChartJsService) {
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-03 17:10:49 +03:00
|
|
|
ngOnInit() {
|
|
|
|
|
// var self = this;
|
|
|
|
|
// setInterval(() => {
|
|
|
|
|
//
|
|
|
|
|
// var temp = [...this.data.two];
|
|
|
|
|
// temp[0].unshift(temp[0].pop());
|
|
|
|
|
// this.data.two = temp;
|
|
|
|
|
//
|
|
|
|
|
// }, 300);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-03 14:58:57 +03:00
|
|
|
chartType(type) {
|
|
|
|
|
return type;
|
2016-05-03 14:33:28 +03:00
|
|
|
}
|
|
|
|
|
|
2016-05-03 14:58:57 +03:00
|
|
|
changeData ($event) {
|
2016-05-03 14:33:28 +03:00
|
|
|
let shuffle = (o) => {
|
|
|
|
|
for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x){}
|
|
|
|
|
return o;
|
|
|
|
|
};
|
|
|
|
|
|
2016-05-03 14:58:57 +03:00
|
|
|
this.data = shuffle(this.data);
|
2016-05-03 14:33:28 +03:00
|
|
|
}
|
|
|
|
|
}
|