Commit 01e19668 authored by João Denis Rodrigues's avatar João Denis Rodrigues

Merge branch 'develop' into visual

parents 5b8dde5f f1202b05
Pipeline #11126 passed with stage
in 1 minute and 55 seconds
Chart.defaults.symmetricErrorLine = Chart.defaults.line;
// I think the recommend using Chart.controllers.bubble.extend({ extensions here });
var custom = Chart.controllers.line.extend({
draw: function(ease) {
// Call super method first
Chart.controllers.line.prototype.draw.call(this, ease);
// Now we can do some custom drawing for this dataset. Here we'll draw a red box around the first point in each dataset
var meta = this.getMeta();
for (m in meta.data) {
var pt0 = meta.data[m];
var point = pt0._view
var chart = this.chart;
var height = chart.chartArea.bottom - chart.chartArea.top;
var ctx = this.chart.chart.ctx;
var datasets = chart.config.data.datasets[pt0._datasetIndex];
var error = datasets.error;
var values = datasets.data;
var p = height / pt0._yScale.max;
// var width = point.width / 4;
var width = pt0._yScale.maxWidth / 4;//chart.config.options.legend.labels.boxWidth / 2;
var true_error = p * error[pt0._index];
var smallest = point.y + true_error;
if (this.chart.config.options.scales.yAxes[0].ticks.beginAtZero) {
if (smallest >= chart.chartArea.bottom) {
var pt0 = meta.data[m];
var point = pt0._view
var chart = this.chart;
var height = chart.chartArea.bottom - chart.chartArea.top;
var ctx = this.chart.chart.ctx;
var datasets = chart.config.data.datasets[pt0._datasetIndex];
var error = datasets.error;
var values = datasets.data;
var p = height / pt0._yScale.max;
var width = pt0._yScale.maxWidth / 4;
var true_error = p * error[pt0._index];
var smallest = point.y + true_error;
if (this.chart.config.options.scales.yAxes[0].ticks.beginAtZero) {
if (smallest >= chart.chartArea.bottom) {
smallest = chart.chartArea.bottom;
}
}
var color = datasets.errorColor;
ctx.beginPath();
ctx.strokeStyle = color;
ctx.moveTo(point.x, point.y);
ctx.lineTo(point.x, smallest);
ctx.lineTo(point.x, point.y - true_error);
ctx.moveTo(point.x, point.y - true_error);
ctx.lineTo(point.x - width, point.y - true_error);
ctx.lineTo(point.x + width, point.y - true_error);
ctx.moveTo(point.x, smallest);
ctx.lineTo(point.x - width, smallest);
ctx.lineTo(point.x + width, smallest);
ctx.stroke();
}
var color = datasets.errorColor;
ctx.beginPath();
ctx.strokeStyle = color;
ctx.moveTo(point.x, point.y);
ctx.lineTo(point.x, smallest);
ctx.lineTo(point.x, point.y - true_error);
ctx.moveTo(point.x, point.y - true_error);
ctx.lineTo(point.x - width, point.y - true_error);
ctx.lineTo(point.x + width, point.y - true_error);
ctx.moveTo(point.x, smallest);
ctx.lineTo(point.x - width, smallest);
ctx.lineTo(point.x + width, smallest);
ctx.stroke();
}
}
}
});
// Stores the controller so that the chart initialization routine can look it up with
// Chart.controllers[type]
Chart.controllers.symmetricErrorLine = custom;
Chart.defaults.symmetricErrorBar = Chart.defaults.bar;
// I think the recommend using Chart.controllers.bubble.extend({ extensions here });
var custom2 = Chart.controllers.bar.extend({
draw: function(ease) {
// Call super method first
Chart.controllers.bar.prototype.draw.call(this, ease);
// Now we can do some custom drawing for this dataset. Here we'll draw a red box around the first point in each dataset
var meta = this.getMeta();
for (m in meta.data) {
var pt0 = meta.data[m];
var point = pt0._view
var chart = this.chart;
var height = chart.chartArea.bottom - chart.chartArea.top;
var ctx = this.chart.chart.ctx;
var datasets = chart.config.data.datasets[pt0._datasetIndex];
var error = datasets.error;
var values = datasets.data;
var p = height / pt0._yScale.max;
var width = point.width / 4;
var true_error = p * error[pt0._index];
var smallest = point.y + true_error;
if (this.chart.config.options.scales.yAxes[0].ticks.beginAtZero) {
if (smallest >= chart.chartArea.bottom) {
var pt0 = meta.data[m];
var point = pt0._view
var chart = this.chart;
var height = chart.chartArea.bottom - chart.chartArea.top;
var ctx = this.chart.chart.ctx;
var datasets = chart.config.data.datasets[pt0._datasetIndex];
var error = datasets.error;
var values = datasets.data;
var p = height / pt0._yScale.max;
var width = point.width / 4;
var true_error = p * error[pt0._index];
var smallest = point.y + true_error;
if (this.chart.config.options.scales.yAxes[0].ticks.beginAtZero) {
if (smallest >= chart.chartArea.bottom) {
smallest = chart.chartArea.bottom;
}
}
var color = datasets.errorColor;
ctx.beginPath();
ctx.strokeStyle = color;
ctx.moveTo(point.x, point.y);
ctx.lineTo(point.x, smallest);
ctx.lineTo(point.x, point.y - true_error);
ctx.moveTo(point.x, point.y - true_error);
ctx.lineTo(point.x - width, point.y - true_error);
ctx.lineTo(point.x + width, point.y - true_error);
ctx.moveTo(point.x, smallest);
ctx.lineTo(point.x - width, smallest);
ctx.lineTo(point.x + width, smallest);
ctx.stroke();
}
var color = datasets.errorColor;
ctx.beginPath();
ctx.strokeStyle = color;
ctx.moveTo(point.x, point.y);
ctx.lineTo(point.x, smallest);
ctx.lineTo(point.x, point.y - true_error);
ctx.moveTo(point.x, point.y - true_error);
ctx.lineTo(point.x - width, point.y - true_error);
ctx.lineTo(point.x + width, point.y - true_error);
ctx.moveTo(point.x, smallest);
ctx.lineTo(point.x - width, smallest);
ctx.lineTo(point.x + width, smallest);
ctx.stroke();
}
}
}
});
// Stores the controller so that the chart initialization routine can look it up with
// Chart.controllers[type]
Chart.controllers.symmetricErrorBar = custom2;
This diff is collapsed.
......@@ -6,9 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="{% static 'flatly_theme/bootstrap.css' %}">
<script src="{% static 'jquery-2.2.4/jquery.min.js' %}"></script>
<script src="{% static 'bootstrap-3.3.7/js/bootstrap.min.js' %}"></script>
<script src="{% static 'adega/script.js' %}"></script>
<link rel="stylesheet" href="{% static 'adega/style.css' %}">
{% block extra_css %}{% endblock extra_css %}
......@@ -55,6 +52,9 @@
</div>
</div>
</div>
<script src="{% static 'jquery-2.2.4/jquery.min.js' %}"></script>
<script src="{% static 'bootstrap-3.3.7/js/bootstrap.min.js' %}"></script>
<script src="{% static 'adega/script.js' %}"></script>
{% block extra_js %}{% endblock extra_js %}
</body>
</html>
$(document).ready(function () {
var color = [
['rgba(31, 110, 239, 1)', 'rgba(151,187,205, 0.2)'], //blue
['rgba(158, 22, 22, 1)', 'rgba(252, 22, 22, 0.1)'], //red
]
var ira_semestral = function () {
var ira_semestral = function () {
if($("#ira_semestral").length == 0)
return;
var data = $("#ira_semestral").data("data");
var labels = [];
var values = {
formatura: [],
sem_evasao: [],
geral: [],
};
for (var item in data) {
labels.push(data[item][0]);
values.formatura.push(data[item][1].formatura);
values.sem_evasao.push(data[item][1].sem_evasao);
values.geral.push(data[item][1].ira_medio);
}
var ira_semestralData = {
datasets: [setDataset("line", "Quantidade de Alunos", false, null, ['rgba(151,187,205,0.9)', 'rgba(151,187,205,0.5)']),
setDataset("line", "Quantidade Formandos", false, null, ['rgba(27,187,225,0.9)', 'rgba(27,187,225,0.5)']),
setDataset("line", "Quantidade Sem Evasão", false, null, ['rgba(180,97,205,0.9)', 'rgba(180,97,205,0.5)']),
]
var chart = {
labels: ["Quantidade Sem Evasão", "Quantidade Formandos", "Quantidade de Alunos"],
data: data,
options: {
stacked: {
yAxes: false,
},
fill: false,
yAxes: {},
}
}
var max1 = Math.max.apply(null, values.geral);
ira_semestralData.labels = labels;
ira_semestralData.datasets[0].data = values.geral;
ira_semestralData.datasets[1].data = values.formatura;
ira_semestralData.datasets[2].data = values.sem_evasao;
var ticks = setTicks(true, 15, max1, max1, 0);
var scales = {
xAxes: [configAxes(true, null, true, null, null, true, null, true)],
yAxes: [configAxes(false, 'linear', true, 'left', null, true, ticks, false)],
};
var ctx = document.getElementById("ira_semestral").getContext("2d");
window.myIRA = new Chart(ctx, chartConfig('line', ira_semestralData, scales, false));
window.myIRA = build_line_chart(ctx, chart);
}
var evasao_semestre = function () {
......@@ -55,40 +25,21 @@ var ira_semestral = function () {
return;
var data = $("#evasao_semestre").data("data");
var labels = [];
var values = {
taxa: [],
quantidade: [],
};
for (var item in data) {
labels.push(data[item][0]);
values.taxa.push(data[item][1].taxa);
values.quantidade.push(data[item][1].qtd);
}
var evasao_semestral = {
datasets: [setDataset("line", "Quantidade de Alunos", false, null, ['rgba(151,187,205,0.9)', 'rgba(151,187,205,0.5)']),
setDataset("line", "Taxa", false, null, ['rgba(27,187,225,0.9)', 'rgba(27,187,225,0.5)']),
]
}
var max1 = Math.max.apply(null, values.geral);
evasao_semestral.labels = labels;
evasao_semestral.datasets[0].data = values.quantidade;
evasao_semestral.datasets[1].data = values.taxa;
var ticks = setTicks(true, 1, max1, max1, 0);
var scales = {
xAxes: [configAxes(true, null, true, null, null, true, null, true)],
//yAxes: [configAxes(false, 'linear', true, 'left', null, true, ticks, false)],
};
var ctx = document.getElementById("evasao_semestre").getContext("2d");
window.myevasao = new Chart(ctx, chartConfig('line', evasao_semestral, scales, false));
var chart = {
labels: ['Taxas', "Quantidade Alunos"],
data: data,
options: {
stacked: {
yAxes: false,
},
fill: false,
yAxes: {},
}
}
window.myevasao = build_line_chart(ctx, chart);
}
ira_semestral();
ira_semestral();
evasao_semestre();
});
\ No newline at end of file
});
......@@ -391,3 +391,37 @@ def obter_qtd_alunos(disciplina):
quantidade[chave] = alunosTurma
return quantidade
def quantidade_cursada_ate_aprovacao(curso, disciplina, turmas):
alunos = Student.objects.filter(turma_ingresso__curso=curso)
cursadas = 0
aprovadas = 0
qtd_cursada = {
'1': 0,
'2': 0,
'3': 0,
'4': 0,
'5+': 0
}
for aluno in alunos:
alunoTurmas = AlunoTurma.objects.filter(turma__in = turmas, student = aluno)
for at in alunoTurmas:
if at.situacao in SITUACOES_APROVACAO:
cursada = alunoTurmas.count()
cursadas += cursada
aprovadas += 1
if cursada == 1:
qtd_cursada['1'] += 1
elif cursada == 2:
qtd_cursada['2'] += 1
elif cursada == 3:
qtd_cursada['3'] += 1
elif cursada == 4:
qtd_cursada['4'] += 1
elif cursada >= 5:
qtd_cursada['5+'] += 1
if aprovadas == 0:
return (-1, qtd_cursada)
return (cursadas/aprovadas, qtd_cursada)
var color = [
['rgba(31, 110, 239, 1)', 'rgba(151,187,205, 0.2)'], //blue
['rgba(158, 22, 22, 1)', 'rgba(252, 22, 22, 0.1)'], //red
['rgba(112, 4, 244, 1)', 'rgba(112, 4, 244, 0.2)'], //purple
['rgba(157, 249, 234, 1)', 'rgba(157, 249, 234, 0.2)'], //light blue
['rgba(28, 188, 47, 1)', 'rgba(28, 188, 47, 0.2)'], //green
['rgba(232, 138, 16, 1)', 'rgba(232, 138, 16, 0.2)'], //orange
['rgba(229, 237, 7, 1)', 'rgba(229, 237, 7, 0.2)'], //yellow
['rgba(168, 163, 163, 1)', 'rgba(168, 163, 163, 0.2)'], //gray
];
var disciplinas = [];
$(document).ready(function(){
......@@ -70,58 +59,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]);
if (new_data.length > 1) break;
}
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, 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");
......@@ -130,69 +94,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");
......@@ -203,19 +158,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([]);
$(document).ready(function () {
aprovacao_disciplina();
quantidade_cursada();
});
var colors = {
'red': 'rgba(158, 22, 22, 1)',
'blue': 'rgba(31, 110, 239, 1)'
}
var borders = {
'red': 'rgba(252, 22, 22, 1)',
'blue': 'rgba(151,187,205, 1)'
}
function aprovacao_disciplina() {
if($("#aprovacao_disciplina").length == 0)
return;
var data = $("#aprovacao_disciplina").data("data");
var labels = [];
var values = {
taxa: [],
quantidade: [],
};
console.log(data);
for (var item in data) {
labels.push(data[item][0]);
values.taxa.push(data[item][1][1]);
values.quantidade.push(data[item][1][0]);
}
var ctx = document.getElementById("aprovacao_disciplina").getContext("2d");
var ira_semestralData = {
datasets: [setDataset("line", "Aprovação %", false, 'y-axis-1', ['rgba(151,187,205,0.9)', 'rgba(151,187,205,0.5)']),
setDataset("line", "Quantidade de Alunos", false, 'y-axis-2', ['rgba(180,97,205,0.9)', 'rgba(180,97,205,0.5)']),
]
var chart = {
labels: ["Aprovação %", "Quantidade de Alunos"],
data: data,
options: {
fill: false,
stacked: {
yAxes: false,
},
yAxisID: ['y-axis-0', 'y-axis-1'],
displayGridlines: {
'y-axis-1': false,
},
}
}
var max1 = Math.max.apply(null, values.taxa);
ira_semestralData.labels = labels;
ira_semestralData.datasets[0].data = values.quantidade;
ira_semestralData.datasets[1].data = values.taxa;
console.log(max1);
var ticks = [
setTicks(true, 10, 100, 100, 0),
setTicks(true, Math.ceil(max1/10), max1, max1, 0),
];
var scales = {
xAxes: [configAxes(true, null, true, null, null, true, null, true)],
yAxes: [configAxes(false, 'linear', true, 'left', 'y-axis-1', false, ticks[0], true),
configAxes(false, 'linear', true, 'right', 'y-axis-2', true, ticks[1], true)
],
};
var ctx = document.getElementById("aprovacao_disciplina").getContext("2d");
window.myIRA = new Chart(ctx, chartConfig('line', ira_semestralData, scales, false));
window.myIRA = build_line_chart(ctx, chart);
}
function quantidade_cursada() {
if ($("#quantidade_cursada").length == 0)
return;
var data = $("#quantidade_cursada").data("data");
/* for (d in data) {
if (data[d][0] == 1) {
data[d][0] = "Cursada " + data[d][0] + " vez";