-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from ICESI-PI1-2024A-G1/requests-filters-by-da…
…te-ranges REF: STATISTIC TO RANGE
- Loading branch information
Showing
7 changed files
with
145 additions
and
132 deletions.
There are no files selected for viewing
46 changes: 0 additions & 46 deletions
46
hiring_module/hiring_app/static/js/statistics/daily_requests_pie_chart.js
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
hiring_module/hiring_app/static/js/statistics/date_range_requests_pie_chart.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
var rangeRequestChart; | ||
|
||
function createOrUpdateDateRangeRequestChart() { | ||
var chartCanvas = document.getElementById("date_range_requests_pie_chart"); | ||
|
||
// Eliminar el gráfico anterior si existe | ||
if (rangeRequestChart) { | ||
rangeRequestChart.destroy(); | ||
} | ||
|
||
// Crear el nuevo gráfico | ||
var ctx = chartCanvas.getContext("2d"); | ||
rangeRequestChart = new Chart(ctx, { | ||
type: "doughnut", | ||
data: { | ||
labels: ["Solicitudes CEX", "Solicitudes Monitoria", "Solicitudes POS"], | ||
datasets: [ | ||
{ | ||
data: [ | ||
parseInt(document.getElementById("contratos_cex").innerText), | ||
parseInt(document.getElementById("contratos_monitoria").innerText), | ||
parseInt(document.getElementById("contratos_pos").innerText), | ||
], | ||
backgroundColor: ["#1cc88a", "#f6c23e", "#5a5c69"], | ||
hoverBackgroundColor: ["#188f64", "#c99f33", "#3c3e49"], | ||
hoverBorderColor: "rgba(234, 236, 244, 1)", | ||
}, | ||
], | ||
}, | ||
options: { | ||
maintainAspectRatio: false, | ||
tooltips: { | ||
backgroundColor: "rgb(255,255,255)", | ||
bodyFontColor: "#858796", | ||
borderColor: "#dddfeb", | ||
borderWidth: 1, | ||
xPadding: 15, | ||
yPadding: 15, | ||
displayColors: true, | ||
caretPadding: 10, | ||
}, | ||
legend: { | ||
display: true, | ||
}, | ||
cutoutPercentage: 80, | ||
}, | ||
}); | ||
} |
77 changes: 0 additions & 77 deletions
77
...odule/hiring_app/templates/statistical_registers/components/pie_chart_daily_requests.html
This file was deleted.
Oops, something went wrong.
87 changes: 87 additions & 0 deletions
87
.../hiring_app/templates/statistical_registers/components/pie_chart_date_range_requests.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{% load static %} | ||
<div class="col-xl-5 col-lg-5"> | ||
<div class="card shadow mb-4"> | ||
<div class="card-body"> | ||
<div class="form-group"> | ||
<label for="start_date">Seleccionar rango de fechas:</label> | ||
<input type="date" class="form-control" id="start_date" /> | ||
<label for="end_date">a</label> | ||
<input type="date" class="form-control" id="end_date" /> | ||
</div> | ||
|
||
<div class="chart-pie pt-4 pb-2"> | ||
<canvas id="date_range_requests_pie_chart"></canvas> | ||
</div> | ||
<div class="mt-4 text-center small" id="solicitudes_info"> | ||
<span class="mr-2"> | ||
<i class="fas fa-circle text-success"></i> Solicitudes CEX: | ||
<strong><span id="contratos_cex">0</span></strong> | ||
</span> | ||
<br /> | ||
<br /> | ||
<span class="mr-2"> | ||
<i class="fas fa-circle text-warning"></i> Solicitudes Monitorias: | ||
<strong><span id="contratos_monitoria">0</span></strong> | ||
</span> | ||
<br /> | ||
<br /> | ||
<span class="mr-2"> | ||
<i class="fas fa-circle text-gray-800"></i> Solicitudes Prestacion de | ||
Servicios: <strong><span id="contratos_pos">0</span></strong> | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<p hidden id="date_range_requests">{{ daily_requests }}</p> | ||
<script src="{% static 'vendor/chart.js/Chart.min.js' %}"></script> | ||
<script src="{% static 'js/statistics/date_range_requests_pie_chart.js' %}"></script> | ||
|
||
<script> | ||
var startDateInput = document.getElementById("start_date"); | ||
var endDateInput = document.getElementById("end_date"); | ||
|
||
startDateInput.addEventListener("change", updateDateRangeChart); | ||
endDateInput.addEventListener("change", updateDateRangeChart); | ||
|
||
function updateDateRangeChart() { | ||
var startDate = startDateInput.value.replace(/[\[\]']/g, "").split(","); | ||
var endDate = endDateInput.value.replace(/[\[\]']/g, "").split(","); | ||
|
||
var dateRangeRequests = document.getElementById( | ||
"date_range_requests" | ||
).innerText; | ||
dateRangeRequests = eval(dateRangeRequests); | ||
var selectedData = []; | ||
for (let i = 0; i < dateRangeRequests.length; i++) { | ||
if ( | ||
dateRangeRequests[i][0] >= startDate && | ||
dateRangeRequests[i][0] <= endDate | ||
) { | ||
selectedData.push(dateRangeRequests[i]); | ||
} | ||
} | ||
|
||
if (selectedData) { | ||
var sumContratosCex = 0; | ||
var sumContratosMonitoria = 0; | ||
var sumContratosPos = 0; | ||
|
||
for (let i = 0; i < selectedData.length; i++) { | ||
sumContratosCex += parseInt(selectedData[i][1]); | ||
sumContratosMonitoria += parseInt(selectedData[i][2]); | ||
sumContratosPos += parseInt(selectedData[i][3]); | ||
} | ||
|
||
document.getElementById("contratos_cex").innerText = sumContratosCex; | ||
document.getElementById("contratos_monitoria").innerText = sumContratosMonitoria; | ||
document.getElementById("contratos_pos").innerText = sumContratosPos; | ||
} else { | ||
document.getElementById("contratos_cex").innerText = 0; | ||
document.getElementById("contratos_monitoria").innerText = 0; | ||
document.getElementById("contratos_pos").innerText = 0; | ||
} | ||
createOrUpdateDateRangeRequestChart(); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters