Skip to content

Commit

Permalink
Fix statistics layout page
Browse files Browse the repository at this point in the history
  • Loading branch information
anas-araid committed Nov 12, 2018
1 parent 6819c79 commit 2f7809e
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 91 deletions.
1 change: 0 additions & 1 deletion core/exportCSV.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
fwrite($csv, "Compilatore");
for ($i=0; $i<count($report); $i++){
$currentReport = $report[$i];
print_r($currentReport);
fwrite($csv, "\n");
fwrite($csv, $currentReport['ID'].",");
fwrite($csv, $currentReport['ID_Rapporto'].",");
Expand Down
181 changes: 91 additions & 90 deletions stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
</section>


<section class="mdl-cell mdl-cell--middle mdl-cell--9-col" style="max-height:650px;overflow:auto">
<div class="mdl-card mdl-shadow--8dp style-card" style="width:100%;text-align:center">
<div>
<section class="mdl-cell mdl-cell--middle mdl-cell--9-col" >
<div class="mdl-card mdl-shadow--8dp style-card" style="width:100%">
<div style="max-height:650px;overflow:auto;text-align:center">
<h3 style="text-align:center" class="style-gradient-text">Statistiche</h3>
<br>
<button class="mdl-button mdl-js-button mdl-button--raised style-gradient style-button"
Expand All @@ -83,100 +83,101 @@
// conversione da array php a qullo javscript
$chartLabel = json_encode($chartLabel);
$chartData = json_encode($chartData);
?>
?>


<!-- ### GRAFICO INTERVENTI FREQUENTI ### -->
<canvas id="chartInterventiFrequenti" style="max-height:300px;max-width:300px"></canvas>
<script>
// lista colori
chartColors = {
1: '#e74c3c',
2: '#e67e22',
3: '#2ecc71',
4: '#f1c40f',
5: '#3498db',
6: '#9b59b6',
7: '#34495e'
};
var colors = Array();
for (var i=0; i < <?php echo $chartData ?>.length;i++){
colors[i]= chartColors[i+1];
}
var ctx = document.getElementById("chartInterventiFrequenti").getContext('2d');
var data = {
labels: <?php echo $chartLabel ?>,
datasets: [{
data: <?php echo $chartData ?>,
backgroundColor: colors,
}],
}
var chartFrequenti = new Chart(ctx, {
type: 'doughnut',
data: data,
options: {
responsive: true
}
});
</script>

<!-- ### GRAFICO INTERVENTI ANNUALI ### -->

<?php
$anno = getInterventiAnnuali(2018, $db_conn);
$chartMese = array();
$chartInterventi = array();
// creo due array contenenti uno il nome dell'intervento, e l'altro il numero
for ($i=0; $i<count($anno);$i++){
$chartMese[$i] = $anno[$i][0];
$chartInterventi[$i] = $anno[$i][1];
}
// conversione da array php a qullo javscript
$maxInterventiAlMese = max($chartInterventi);
$chartMese = json_encode($chartMese);
$chartInterventi = json_encode($chartInterventi);
?>

<canvas id="chartInterventiAnnuali" style="max-height:auto;max-width:100%"></canvas>
<script>
var ctx = document.getElementById("chartInterventiAnnuali").getContext('2d');
var chartAnnuali = new Chart(ctx, {
type: 'line',
data: {
datasets: [{
label: 'Interventi: ',
data: <?php echo $chartInterventi ?>,
backgroundColor: "rgba(231, 77, 60, 0.49)",
borderColor: "#e74c3c",
}],
labels: <?php echo $chartMese ?>
},
<!-- ### GRAFICO INTERVENTI FREQUENTI ### -->
<div style="text-align:center">
<h5 class="style-gradient-text" style="text-align:left">Interventi più frequenti:</h5>
<canvas id="chartInterventiFrequenti" style="max-height:300px;max-width:300px;display:unset"></canvas>
</div>
<script>
// lista colori
chartColors = {
1: '#e74c3c',
2: '#e67e22',
3: '#2ecc71',
4: '#f1c40f',
5: '#3498db',
6: '#9b59b6',
7: '#34495e'
};
var colors = Array();
for (var i=0; i < <?php echo $chartData ?>.length;i++){
colors[i]= chartColors[i+1];
}
var ctx = document.getElementById("chartInterventiFrequenti").getContext('2d');
var data = {
labels: <?php echo $chartLabel ?>,
datasets: [{
data: <?php echo $chartData ?>,
backgroundColor: colors,
}],
}
var chartFrequenti = new Chart(ctx, {
type: 'doughnut',
data: data,
options: {
scales: {
yAxes: [{
ticks: {
suggestedMin: 0,
suggestedMax: <?php echo $maxInterventiAlMese ?>
}
}]
}
}
responsive: true
}
});
</script>

</script>
<!-- ### GRAFICO INTERVENTI ANNUALI ### -->

<?php
$anno = getInterventiAnnuali(2018, $db_conn);
$chartMese = array();
$chartInterventi = array();
// creo due array contenenti uno il nome dell'intervento, e l'altro il numero
for ($i=0; $i<count($anno);$i++){
$chartMese[$i] = $anno[$i][0];
$chartInterventi[$i] = $anno[$i][1];
}
// conversione da array php a qullo javscript
$maxInterventiAlMese = max($chartInterventi);
$chartMese = json_encode($chartMese);
$chartInterventi = json_encode($chartInterventi);
?>
<h5 class="style-gradient-text" style="text-align:left">Numeri di interventi nell'anno:</h5>

</div>
<br>
<div class="mdl-cell mdl-cell--middle mdl-cell--12-col mdl-cell--hide-desktop" style="100%">
<button class="mdl-button mdl-js-button mdl-button--raised style-gradient style-button"
style="width:100%;height:35px;color:white;border:none;border-radius:20px;;text-align:center;margin-bottom:15px"
type="reset"
onclick="location.href='index.php?back=true'">
Indietro
<i class="material-icons">cancel</i>
</button>
</div>
<canvas id="chartInterventiAnnuali" style="max-height:auto;max-width:100%"></canvas>
<script>
var ctx = document.getElementById("chartInterventiAnnuali").getContext('2d');
var chartAnnuali = new Chart(ctx, {
type: 'line',
data: {
datasets: [{
label: 'Interventi: ',
data: <?php echo $chartInterventi ?>,
backgroundColor: "rgba(231, 77, 60, 0.49)",
borderColor: "#e74c3c",
}],
labels: <?php echo $chartMese ?>
},
options: {
scales: {
yAxes: [{
ticks: {
suggestedMin: 0,
suggestedMax: <?php echo $maxInterventiAlMese ?>
}
}]
}
}
});
</script>
</div>
<br>
<div class="mdl-cell mdl-cell--middle mdl-cell--12-col mdl-cell--hide-desktop" style="100%">
<button class="mdl-button mdl-js-button mdl-button--raised style-gradient style-button"
style="width:100%;height:35px;color:white;border:none;border-radius:20px;;text-align:center;margin-bottom:15px"
type="reset"
onclick="location.href='index.php?back=true'">
Indietro
<i class="material-icons">cancel</i>
</button>
</div>
</div>
</section>
</div>
Expand Down

0 comments on commit 2f7809e

Please sign in to comment.