forked from apiman/apiman
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dashboard.component.ts
156 lines (142 loc) · 4.45 KB
/
dashboard.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import {Component, OnInit} from 'angular2/core';
import {AppState} from '../app.service';
import {Title} from './title';
import {XLarge} from './x-large';
declare var c3:any;
declare var $:any;
@Component({
// The selector is what angular internally uses
// for `document.querySelectorAll(selector)` in our index.html
selector: 'dashboard',
// We need to tell Angular's Dependency Injection which providers are in our app.
providers: [
Title
],
// We need to tell Angular's compiler which directives are in our template.
// Doing so will allow Angular to attach our behavior to an element
directives: [
XLarge
],
// We need to tell Angular's compiler which custom pipes are in our template.
pipes: [],
// Our list of styles in our component. We may add more to compose many styles together
styles: [require('./dashboard.scss')],
// Every Angular template is first compiled by the browser before Angular runs it's compiler
template: require('./dashboard.html')
})
export class Dashboard implements OnInit {
// Set our default values
localState = '';
pageTitle: string = 'Dashboard';
// TypeScript public modifiers
constructor(public appState:AppState, public title:Title) {
}
ngOnInit() {
console.log('Loaded `Dashboard` component');
// this.title.getData().subscribe(data => this.data = data);
c3.generate({
axis: {
x: {
tick: {
format: '%m-%d',
outer: false
},
type: 'timeseries'
},
y: {
tick: {
format: function(d) { return d + '%'; },
outer: false
}
}
},
bindto: '#chart',
//color: '',
data: {
columns: [
['x', '2015-04-01', '2015-04-02', '2015-04-03', '2015-04-04', '2015-04-05', '2015-04-06', '2015-04-07'],
['data1', 16, 44, 33, 88, 50, 76, 21]
],
x: 'x'
},
grid: {
y: {
show: true
}
},
legend: {
hide: true
},
point: {
r: 4
},
size: {
height: 220
}
});
var donutChartConfig: any = {};
donutChartConfig.bindto = '#chart2';
donutChartConfig.tooltip = {show: true};
donutChartConfig.data = {
/*
colors: {
Cloud: '#006e9c',
Virtual: '#00a8e1',
Baremetal: '#969696'
},
*/
columns: [
['Cloud', 4,828],
['Virtual', 13,258],
['Baremetal', 11,1124]
],
type : 'donut',
onclick: function (d, i) { console.log('onclick', d, i); },
onmouseover: function (d, i) { console.log('onmouseover', d, i); },
onmouseout: function (d, i) { console.log('onmouseout', d, i); }
};
c3.generate(donutChartConfig);
c3.generate({
axis: {
rotated: true,
x: {
categories: ['Location 1', 'Location 2', 'Location 3', 'Location 4'],
tick: {
outer: false
},
type: 'category'
},
y: {
tick: {
format: function(d) { return d + '%'; },
outer: false
}
}
},
bindto: '#chart4',
//color: '',
data: {
columns: [
['Virtual Resources', 25, 35, 18, 78],
['Physical Resources', 60, 40, 48, 8]
],
groups: [
['Virtual Resources', 'Physical Resources']
],
type: 'bar'
},
grid: {
y: {
show: true
}
},
size: {
height: 200
}
});
}
submitState(value) {
console.log('submitState', value);
this.appState.set('value', value);
}
}