Commit 153ec029 authored by João Denis Rodrigues's avatar João Denis Rodrigues

Graficos da tela compara disciplina atualizados

parent f91cf52b
Pipeline #10789 passed with stage
......@@ -143,9 +143,10 @@ function calculate_max(values) {
var attributes = {
stepSize: 0,
max: 0,
}
}
for (var v in values) {
var max_temp = Math.max.apply(null, values[v]);
max_temp = Math.ceil(max_temp);
if (max_temp < 1) {
max.push({
max:1,
......@@ -351,6 +352,28 @@ function personalized_config(options, config) {
yAxes[y].ticks.max = maxAll;
yAxes[y].ticks.suggestedMax = maxAll;
}
break;
case 'stepSizeAll':
yAxes = config.options.scales.yAxes;
stepSize = options['stepSizeAll'];
for (y in yAxes) {
yAxes[y].ticks.stepSize = stepSize;
}
break;
case 'tooltipCallbackLabel':
tooltip_text = options["tooltipCallbackLabel"]["text"];
config.options.tooltips['callbacks'] = {'label': null};
config.options.tooltips.callbacks.label = function(tooltipItem, data) {
label = data.datasets[tooltipItem.datasetIndex].label;
if (options['tooltipCallbackLabel']['fixed']) {
value = tooltipItem.yLabel.toFixed(3);
}
else {
value = tooltipItem.yLabel;
}
return '' + label + ": " + value + tooltip_text;
};
break;
default:
// code
}
......
......@@ -26,44 +26,34 @@ function changeSelects(){
}
function handle_cache() {
var data = $('#info').data('data');
console.log(data);
for (d in disciplinas) {
console.log(disciplinas[d]);
index = getIndexOf(data, disciplinas[d]);
if (index < 0) continue;
dados = data[index];
if (d == 0) {
table = $('#disc-1 tr');
}
else {
table = $('#disc-2 tr');
}
console.log(dados);
$(table).each(function(i, row) {
var $row = $(row);
$children = $row.children();
if ($($children[0]).text() == "Nota Média") {
$($children[1]).html('<td>' + dados[1].nota.toFixed(2) + '</td>');
}
var data = $('#info').data('data');
for (d in disciplinas) {
index = getIndexOf(data, disciplinas[d]);
if (index < 0) continue;
dados = data[index];
if (d == 0) {
table = $('#disc-1 tr');
}
else {
table = $('#disc-2 tr');
}
$(table).each(function(i, row) {
var $row = $(row);
$children = $row.children();
if ($($children[0]).text() == "Nota Média") {
$($children[1]).html('<td>' + dados[1].nota[0].toFixed(2) + unescape('%B1') + dados[1].nota[1].toFixed(2) + '</td>');
}
else if ($($children[0]).text() == "Taxa Reprovação") {
$($children[1]).html('<td>' + dados[1].taxa_reprovacao_absoluta.toFixed(2) + '%</td>');
$($children[1]).html('<td>' + dados[1].taxa_reprovacao_absoluta.toFixed(2) + '%</td>');
}
else if ($($children[0]).text() == "Taxa Reprovação Frequência") {
$($children[1]).html('<td>' + dados[1].taxa_reprovacao_frequencia.toFixed(2) + '%</td>');
$($children[1]).html('<td>' + dados[1].taxa_reprovacao_frequencia.toFixed(2) + '%</td>');
}
else if ($($children[0]).text() == "Taxa Trancamento") {
$($children[1]).html('<td>' + dados[1].taxa_trancamento.toFixed(2) + '%</td>');
$($children[1]).html('<td>' + dados[1].taxa_trancamento.toFixed(2) + '%</td>');
}
/*$($row).each(function(j, data) {
var $data = $(data);
console.log(data);
});*/
});
//console.log(rows);
}
});
}
}
function getIndexOf(data, disciplina) {
......@@ -77,58 +67,33 @@ function getIndexOf(data, disciplina) {
function compara_disciplina(disciplinas) {
var data = $('#compara_disciplina').data('data');
var result = [];
var new_data = [];
var labels = [];
console.log("Compara Disciplina");
for (d in disciplinas) {
var disc = {
name: null,
values: [],
};
var v = []
index = getIndexOf(data, disciplinas[d]);
if (index < 0) continue;
disc.name = disciplinas[d];
for (val in data[index][1]) {
v.push(data[index][1][val][1].toFixed(2));
v = [];
v.push(data[index][1][val][0]);
new_data.push(v);
}
disc.values = v;
result.push(disc);
}
for (l in data[0][1]) {
labels.push(data[0][1][l][0]);
}
var compara_disc = {
datasets: []
}
compara_disc.labels = labels;
var max = 0;
for (r in result) {
compara_disc.datasets.push(setDataset("line", result[r].name, false, null, [color[r%8][0], color[r%8][1]]));
compara_disc.datasets[r].data = result[r].values;
max = Math.max.apply(null, result[r].values) > max ? Math.max.apply(null, result[r].values) : max;
if (new_data.length > 1) break;
}
max = Math.ceil(max);
var ticks = setTicks(true, 2, max, max, 0);
var scales = {
xAxes: [configAxes(true, null, true, null, null, true, null, true)],
yAxes: [],
for (d in disciplinas) {
index = getIndexOf(data, disciplinas[d]);
if (index < 0) continue;
labels.push(disciplinas[d]);
for (val in data[index][1]) {
if (new_data[val].length > 1) {
new_data[val][1][disciplinas[d]] = data[index][1][val][1];
} else {
disc = {}
disc[disciplinas[d]] = data[index][1][val][1];
new_data[val].push(disc);}
}
}
for (r in result) {
if (r == 0) {
scales.yAxes.push(configAxes(false, 'linear', true, 'left', null, true, ticks, false));
} else {
scales.yAxes.push(configAxes(false, 'linear', false, 'left', null, true, ticks, false));
}
}
var canvas = document.getElementById("compara_disciplina");
var ctx = document.getElementById("compara_disciplina").getContext("2d");
......@@ -137,69 +102,60 @@ function compara_disciplina(disciplinas) {
if (chart != null) {
chart.destroy();
}
config = chartConfig('line', compara_disc, scales, false);
config.options.tooltips['callbacks'] = {
'label': 1,
};
config.options.tooltips.callbacks.label = function(tooltipItem, data) {
return '' + data.datasets[tooltipItem.datasetIndex].label + ': ' + tooltipItem.yLabel + '%';
};
chart = new Chart(ctx, config);
var config = {
labels: labels,
data: new_data,
options: {
fill: false,
yAxisID: ['y-axis-0', 'y-axis-1'],
yAxesPosition: {
'y-axis-1': 'left',
},
maxAll: true,
yAxesDisplay: {
'y-axis-0': false,
},
stepSizeAll: 1,
tooltipCallbackLabel: {
text: '%',
fixed: true,
}
}
}
if (labels.length == 1) {
delete config.options['yAxesDisplay'];
}
chart = build_line_chart(ctx, config, ['blue', 'cyan']);
window.myComparaDisc = chart;
}
function compara_aprovacao_disciplina(disciplinas) {
var data = $('#compara_aprovacao_disciplina').data('data');
var new_data = []
var result = [];
var labels = [];
console.log("Compara Disciplina Aprovação");
for (d in disciplinas) {
var disc = {
name: null,
values: [],
};
var v = []
index = getIndexOf(data, disciplinas[d]);
if (index < 0) continue;
disc.name = disciplinas[d];
for (val in data[index][1]) {
v.push(data[index][1][val][1].toFixed(2));
if (disciplinas.length > 0) {
for (val in data[0][1]) {
v = [];
v.push(data[0][1][val][0]);
new_data.push(v);
}
disc.values = v;
result.push(disc);
}
for (l in data[0][1]) {
labels.push(data[0][1][l][0]);
}
var compara_disc = {
datasets: []
}
compara_disc.labels = labels;
var max = 0;
for (r in result) {
compara_disc.datasets.push(setDataset("line", result[r].name, false, null, [color[r%8][0], color[r%8][1]]));
compara_disc.datasets[r].data = result[r].values;
max = Math.max.apply(null, result[r].values) > max ? Math.max.apply(null, result[r].values) : max;
}
max = Math.ceil(max);
var ticks = setTicks(true, 10, 100, 100, 0);
var scales = {
xAxes: [configAxes(true, null, true, null, null, true, null, true)],
yAxes: [],
}
for (r in result) {
if (r == 0) {
scales.yAxes.push(configAxes(false, 'linear', true, 'left', null, true, ticks, false));
} else {
scales.yAxes.push(configAxes(false, 'linear', false, 'left', null, true, ticks, false));
}
for (d in disciplinas) {
index = getIndexOf(data, disciplinas[d]);
if (index < 0) continue;
labels.push(disciplinas[d]);
for (val in data[index][1]) {
if (new_data[val].length > 1) {
new_data[val][1][disciplinas[d]] = data[index][1][val][1];
} else {
disc = {}
disc[disciplinas[d]] = data[index][1][val][1];
new_data[val].push(disc);}
}
}
var canvas = document.getElementById("compara_aprovacao_disciplina");
......@@ -210,19 +166,34 @@ function compara_aprovacao_disciplina(disciplinas) {
if (chart2 != null) {
chart2.destroy();
}
config = chartConfig('line', compara_disc, scales, false);
config.options.tooltips['callbacks'] = {
'label': 1,
};
config.options.tooltips.callbacks.label = function(tooltipItem, data) {
return '' + data.datasets[tooltipItem.datasetIndex].label + ': ' + tooltipItem.yLabel + '%';
};
chart2 = new Chart(ctx, config);
var config = {
labels: labels,
data: new_data,
options: {
fill: false,
yAxisID: ['y-axis-0', 'y-axis-1'],
yAxesPosition: {
'y-axis-1': 'left',
},
yAxesDisplay: {
'y-axis-0': false,
},
tooltipCallbackLabel: {
text: '%',
fixed: true,
}
}
}
if (labels.length == 1) {
delete config.options['yAxesDisplay'];
}
chart2 = build_line_chart(ctx, config, ['blue', 'cyan']);
window.myComparaDisc = chart2;
}
var chart = null;
var chart2 = null;
compara_disciplina([]);
compara_aprovacao_disciplina([]);
\ No newline at end of file
compara_aprovacao_disciplina([]);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment