-
Notifications
You must be signed in to change notification settings - Fork 1
/
chartjs.ts
77 lines (61 loc) · 1.73 KB
/
chartjs.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
import { Component, OnInit, ViewChild } from '@angular/core';
import { Chart } from 'chart.js';
import { RestApiService } from '../../../services/rest-api.service';
import { Router, NavigationExtras } from '@angular/router';
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.page.html',
styleUrls: ['./dashboard.page.scss'],
})
export class DashboardPage implements OnInit {
@ViewChild('barChart') barChart;
bars:any;
colorArray:any;
CekLogin = JSON.parse(localStorage.getItem('userData'));
dataSurveys:any
constructor(public api: RestApiService, private router: Router) { }
ngOnInit() {
}
ionViewDidEnter() {
this.dataSurvey()
}
ionViewDidLeave() {
}
dataSurvey() {
this.api.get('product/getsurvey/'+this.CekLogin.data.id)
.subscribe((result:any) => {
this.dataSurveys = result.data
localStorage.setItem('tempdatasurvey', JSON.stringify(this.dataSurveys.detailProd));
if (this.dataSurveys) {
this.createBarChart()
}
})
}
createBarChart() {
this.bars = new Chart(this.barChart.nativeElement, {
type: 'pie',
data: {
labels: this.dataSurveys.prodName,
datasets: [{
data: this.dataSurveys.prodScore,
backgroundColor: this.dataSurveys.prodColor,
borderColor: 'rgb(38, 194, 129)',
borderWidth: 1
}]
},
options: {
onClick: this.handle,
title: {
display: false,
text: this.dataSurveys,
},
},
});
}
handle(pointer, event) {
const blabla = require('../../../../../node_modules/@angular/router');
console.log(blabla)
blabla.Router.navigate(['/timekeeping'])
console.log(event[0]._index, this)
}
}