Update reports view using chart.js
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
'app.reports',
|
'app.reports',
|
||||||
'app.section',
|
'app.section',
|
||||||
'app.student',
|
'app.student',
|
||||||
|
'chart.js',
|
||||||
'ngResource',
|
'ngResource',
|
||||||
'ui.router'
|
'ui.router'
|
||||||
])
|
])
|
||||||
|
@@ -11,12 +11,29 @@
|
|||||||
var vm = this;
|
var vm = this;
|
||||||
var user = authentication.currentUser();
|
var user = authentication.currentUser();
|
||||||
var professorid = user._id;
|
var professorid = user._id;
|
||||||
|
vm.asistance = 0;
|
||||||
vm.course = null;
|
vm.course = null;
|
||||||
|
vm.currentDay = 0;
|
||||||
|
vm.data = [];
|
||||||
|
vm.labels = [];
|
||||||
vm.lectures = 0;
|
vm.lectures = 0;
|
||||||
|
vm.negative = 0;
|
||||||
vm.percentage = 0;
|
vm.percentage = 0;
|
||||||
vm.positive = 0;
|
vm.positive = 0;
|
||||||
vm.professor = null;
|
vm.professor = null;
|
||||||
vm.negative = 0;
|
vm.series = [];
|
||||||
|
vm.semidata = [];
|
||||||
|
|
||||||
|
$scope.labels = ["January", "February", "March", "April", "May", "June", "July"];
|
||||||
|
$scope.series = ['Series A', 'Series B','Series C', 'Series D','Series E', 'Series F'];
|
||||||
|
$scope.data = [
|
||||||
|
[65, 59, 80, 81, 56, 55, 40],
|
||||||
|
[28, 48, 40, 19, 86, 27, 90],
|
||||||
|
[10, 59, 11, 71, 78, 44, 34],
|
||||||
|
[17, 28, 5, 19, 75, 75, 54],
|
||||||
|
[72, 14, 10, 61, 65, 36, 8],
|
||||||
|
[24, 3, 5, 19, 9, 5, 7]
|
||||||
|
];
|
||||||
|
|
||||||
professors.get({ id: professorid },
|
professors.get({ id: professorid },
|
||||||
function (successResult){
|
function (successResult){
|
||||||
@@ -31,18 +48,42 @@
|
|||||||
|
|
||||||
angular.forEach (vm.course.sections,
|
angular.forEach (vm.course.sections,
|
||||||
function (value){
|
function (value){
|
||||||
|
vm.semester = value.semester;
|
||||||
|
angular.forEach (value.students[0].assistanceTotal,
|
||||||
|
function (valued){
|
||||||
|
if(valued.day){
|
||||||
|
vm.currentDay++;
|
||||||
|
vm.labels.push('Día ' + vm.currentDay);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
vm.currentDay = 0;
|
||||||
|
vm.lectures = value.students[0].assistance;
|
||||||
angular.forEach (value.students,
|
angular.forEach (value.students,
|
||||||
function (valued){
|
function (valued){
|
||||||
vm.lectures = valued.assistance;
|
|
||||||
angular.forEach (valued.assistanceTotal,
|
angular.forEach (valued.assistanceTotal,
|
||||||
function (valueda){
|
function (valueda){
|
||||||
if (valueda.assistance) {
|
if (valueda.assistance) {
|
||||||
vm.positive++;
|
vm.positive++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
vm.negative++;
|
vm.negative++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
var st = value.students.length;
|
||||||
|
var ast = value.students[0].assistanceTotal.length;
|
||||||
|
for (var i = 0; i <= ast - 1; i++) {
|
||||||
|
for (var j = 0; j <= st - 1; j++) {
|
||||||
|
if (typeof value.students[j].assistanceTotal[i] != 'undefined'){
|
||||||
|
if (value.students[j].assistanceTotal[i].assistance) vm.asistance++;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
vm.semidata.push(vm.asistance);
|
||||||
|
vm.asistance = 0;
|
||||||
|
};
|
||||||
|
vm.data.push(vm.semidata);
|
||||||
|
vm.semidata = [];
|
||||||
|
vm.series.push(vm.semester);
|
||||||
});
|
});
|
||||||
vm.total = vm.positive + vm.negative;
|
vm.total = vm.positive + vm.negative;
|
||||||
vm.percentage = (vm.positive/vm.total)*100;
|
vm.percentage = (vm.positive/vm.total)*100;
|
||||||
|
@@ -13,4 +13,8 @@
|
|||||||
ng-click = "vm.back()">
|
ng-click = "vm.back()">
|
||||||
Regresar
|
Regresar
|
||||||
</button>
|
</button>
|
||||||
|
<canvas id="line" class="chart chart-line" chart-data="vm.data"
|
||||||
|
chart-labels="vm.labels" chart-legend="true" chart-series="vm.series">
|
||||||
|
</canvas>
|
||||||
|
|
||||||
</div>
|
</div>
|
@@ -33,10 +33,10 @@
|
|||||||
vm.section = value;
|
vm.section = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
vm.lectures = vm.section.students[0].assistance;
|
||||||
angular.forEach (vm.section.students,
|
angular.forEach (vm.section.students,
|
||||||
function (value){
|
function (value){
|
||||||
vm.lectures = value.assistance;
|
|
||||||
vm.subTotal = 0;
|
vm.subTotal = 0;
|
||||||
angular.forEach (value.assistanceTotal,
|
angular.forEach (value.assistanceTotal,
|
||||||
function (valued){
|
function (valued){
|
||||||
|
Reference in New Issue
Block a user