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>
</table>
</div>
<div class="col-1"></div>
<div class="col-6">
<div id="c_unfallzahlen"></div>
</div>
@ -126,7 +127,7 @@
</div>
</div>
<!-- Unfalltyp -->
<div class="row">
<div class="col-5">
<h4>Unfalltyp</h4>
@ -138,6 +139,9 @@
?>
</table>
</div>
<div class="col-7">
<div id="c_unfalltyp"></div>
</div>
</div>
<!-- Unfallarten -->
@ -152,9 +156,11 @@
?>
</table>
</div>
<div class="col-7">
<div id="c_unfallarten"></div>
</div>
</div>
</div>
<?= get_series($resultUnfallzahlen,$arrCategory) ?>
</body>
<script>
@ -167,7 +173,7 @@ Highcharts.chart('c_unfallzahlen', {
},
title: {
text: 'Unfallzahlen',
align: 'left'
align: 'center'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
@ -190,9 +196,82 @@ Highcharts.chart('c_unfallzahlen', {
series: [{
name: 'Unfallzahlen',
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>
</html>

View File

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