more charts

This commit is contained in:
Walter Hupfeld 2023-10-10 11:54:57 +02:00
parent 77aa04a01c
commit b0de883339
2 changed files with 85 additions and 6 deletions

View File

@ -106,6 +106,7 @@
<tr><th>Quote pro Fläche</th><td><?= round($numGesamt/$numFlaeche,1) ?> /km<sup>2</sup></td></tr> <tr><th>Quote pro Fläche</th><td><?= round($numGesamt/$numFlaeche,1) ?> /km<sup>2</sup></td></tr>
</table> </table>
</div> </div>
<div class="col-1"></div>
<div class="col-6"> <div class="col-6">
<div id="c_unfallzahlen"></div> <div id="c_unfallzahlen"></div>
</div> </div>
@ -126,7 +127,7 @@
</div> </div>
</div> </div>
<!-- Unfalltyp -->
<div class="row"> <div class="row">
<div class="col-5"> <div class="col-5">
<h4>Unfalltyp</h4> <h4>Unfalltyp</h4>
@ -138,6 +139,9 @@
?> ?>
</table> </table>
</div> </div>
<div class="col-7">
<div id="c_unfalltyp"></div>
</div>
</div> </div>
<!-- Unfallarten --> <!-- Unfallarten -->
@ -152,9 +156,11 @@
?> ?>
</table> </table>
</div> </div>
<div class="col-7">
<div id="c_unfallarten"></div>
</div>
</div> </div>
</div> </div>
<?= get_series($resultUnfallzahlen,$arrCategory) ?>
</body> </body>
<script> <script>
@ -167,7 +173,7 @@ Highcharts.chart('c_unfallzahlen', {
}, },
title: { title: {
text: 'Unfallzahlen', text: 'Unfallzahlen',
align: 'left' align: 'center'
}, },
tooltip: { tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
@ -190,9 +196,82 @@ Highcharts.chart('c_unfallzahlen', {
series: [{ series: [{
name: 'Unfallzahlen', name: 'Unfallzahlen',
colorByPoint: true, colorByPoint: true,
data: <?= get_series($resultUnfallzahlen,$arrCategory) ?> data: <?= get_series($resultUnfallzahlen,$arrCategory,"UKATEGORIE") ?>
}] }]
}); });
Highcharts.chart('c_unfallarten', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Unfallarten',
align: 'center'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
accessibility: {
point: {
valueSuffix: '%'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
}
}
},
series: [{
name: 'Unfallarten',
colorByPoint: true,
data: <?= get_series($resultUnfallart,$arrUnfallart,"UART") ?>
}]
});
Highcharts.chart('c_unfalltyp', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Unfalltyp',
align: 'center'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
accessibility: {
point: {
valueSuffix: '%'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
}
}
},
series: [{
name: 'Unfallarten',
colorByPoint: true,
data: <?= get_series($resultUnfalltyp,$arrUnfalltyp,"UTYP1") ?>
}]
});
</script> </script>
</html> </html>

View File

@ -53,10 +53,10 @@ function get_unfallart($numYear,$strLocation){
return $arrResult; return $arrResult;
} }
function get_series($arrData,$arrBezeichnung){ function get_series($arrData,$arrBezeichnung,$strIndex1,$strIndex2="anz"){
$result="["; $result="[";
foreach ($arrData as $row) { foreach ($arrData as $row) {
$result.= "{ name: '".$arrBezeichnung[$row['UKATEGORIE']] ."', y: ".$row['anz']."},"; $result.= "{ name: '".$arrBezeichnung[$row[$strIndex1]] ."', y: ".$row[$strIndex2]."},";
} }
$result.="]"; $result.="]";
return $result; return $result;