nrw und kreis detail

This commit is contained in:
Walter Hupfeld 2023-10-11 13:13:53 +02:00
parent e8519b9fb0
commit 4d12345d96
9 changed files with 754 additions and 121 deletions

View File

@ -42,6 +42,7 @@
<title>Fahrrad-Unfallstatistik NRW</title> <title>Fahrrad-Unfallstatistik NRW</title>
<link rel="stylesheet" href="../css/bootstrap.min.css"/> <link rel="stylesheet" href="../css/bootstrap.min.css"/>
<script src="../js/jquery.min.js"></script> <script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/highcharts.js"></script> <script src="../js/highcharts.js"></script>
<style> <style>
.rechts {text-align:right;background-color:#eee;} .rechts {text-align:right;background-color:#eee;}
@ -50,34 +51,7 @@
</head> </head>
<body> <body>
<!-- Navbar --> <?php include("navbar.php"); ?>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Unfallkarte</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbars">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="../index.php">Karte</a>
</li>
</ul>
<div>
<ul class="navbar-nav mr-auto right">
<li class="nav-item active">
<a class="nav-link" href="index.php">Statistik <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../impressum.php">Impressum</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../datenschutz.php">Datenschutzerklärung</a>
</li>
</ul>
</div>
</nav>
<!-- Ende Navbar -->
<div class="container" style="margin-top:4em;"> <div class="container" style="margin-top:4em;">
@ -349,7 +323,7 @@ Highcharts.chart('c_unfallverlauf', {
}, },
legend: { legend: {
align: 'left', align: 'left',
x: 160, x: 400,
verticalAlign: 'top', verticalAlign: 'top',
y: 30, y: 30,
floating: true, floating: true,

View File

@ -9,6 +9,7 @@
<link rel="stylesheet" href="//cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css"> <link rel="stylesheet" href="//cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">
<script src="../js/jquery.min.js"></script> <script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="//cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script> <script src="//cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<style> <style>
.rechts {text-align:right;background-color:#eee;} .rechts {text-align:right;background-color:#eee;}
@ -17,34 +18,7 @@
</head> </head>
<body> <body>
<!-- Navbar --> <?php include("navbar.php"); ?>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Unfallkarte</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbars">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="../index.php">Karte</a>
</li>
</ul>
<div>
<ul class="navbar-nav mr-auto right">
<li class="nav-item active">
<a class="nav-link" href="index.php">Statistik <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../impressum.php">Impressum</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../datenschutz.php">Datenschutzerklärung</a>
</li>
</ul>
</div>
</nav>
<!-- Ende Navbar -->
<div class="container-fluid" style="margin-top:4em;"> <div class="container-fluid" style="margin-top:4em;">
@ -112,7 +86,7 @@ $result=$db->query($strSQL);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
echo "<tr>"; echo "<tr>";
echo "<td><a href='gemeinde_detail.php?regbez=".$row['UREGBEZ']."&kreis=".$row['UKREIS']."&gemeinde=".$row['UGEMEINDE']."'>".$row['Gemeinde']."</a></td>"; echo "<td><a href='gemeinde_details.php?regbez=".$row['UREGBEZ']."&kreis=".$row['UKREIS']."&gemeinde=".$row['UGEMEINDE']."'>".$row['Gemeinde']."</a></td>";
echo "<td class='l'>".$row['Jahr_2022']."</td>"; echo "<td class='l'>".$row['Jahr_2022']."</td>";
echo "<td>".$row['Jahr_2021']."</td>"; echo "<td>".$row['Jahr_2021']."</td>";
echo "<td>".$row['Jahr_2020']."</td>"; echo "<td>".$row['Jahr_2020']."</td>";

View File

@ -4,9 +4,7 @@ require_once ("../config.php");
$protocol = isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : 'http'; $protocol = isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : 'http';
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'www.localhost'; $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'www.localhost';
//$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/'; //$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
//$currentURL = $protocol . '://' . $host . $uri;
//echo "Die URL der aktuellen Seite ist: $currentURL";
$cacheFile = "gemeinden.html"; $cacheFile = "gemeinden.html";
$url = $protocol . '://' . $host . "/statistics/gemeinden.php"; $url = $protocol . '://' . $host . "/statistics/gemeinden.php";
//$cachetime = 3600; // Defined in config.php //$cachetime = 3600; // Defined in config.php
@ -15,9 +13,7 @@ if (file_exists($cacheFile) && (time() - filemtime($cacheFile) < $cachetime)) {
// Cache ist gültig, geben Sie den gecachten Inhalt aus // Cache ist gültig, geben Sie den gecachten Inhalt aus
include($cacheFile); include($cacheFile);
} else { } else {
// Erzeugen Sie die Seite dynamisch und speichern Sie sie im Cache
ob_start(); // Starten des Ausgabe-Puffers ob_start(); // Starten des Ausgabe-Puffers
// Hier generieren Sie Ihre Seite dynamisch
$content = file_get_contents($url); $content = file_get_contents($url);
if ($content === false) { if ($content === false) {
echo "Fehler beim Abrufen der Seite."; echo "Fehler beim Abrufen der Seite.";

View File

@ -13,42 +13,16 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Unfallstatistik</title> <title>Unfallstatistik</title>
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<link rel="stylesheet" href="../css/bootstrap.min.css" /> <link rel="stylesheet" href="../css/bootstrap.min.css" />
<link rel="stylesheet" href="../css/style.css" /> <link rel="stylesheet" href="../css/style.css" />
</head> </head>
<body> <body>
<!-- Navbar --> <?php include("./navbar.php"); ?>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Unfallkarte</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbars">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="../index.php">Karte</a>
</li>
</ul>
<div>
<ul class="navbar-nav mr-auto right">
<li class="nav-item active">
<a class="nav-link" href="index.php">Statistik <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../impressum.php">Impressum</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../datenschutz.php">Datenschutzerklärung</a>
</li>
</ul>
</div>
</nav>
<!-- Ende Navbar -->
<div class="container main"> <div class="container main">
<p>&nbsp;</p> <p>&nbsp;</p>
<div class="card"> <div class="card">
<div class="card-header"><h2>Statistik zu Unfällen in NRW</h2></div> <div class="card-header"><h2>Statistik zu Unfällen in NRW</h2></div>
@ -58,6 +32,7 @@
<ul> <ul>
<li><a href="kreise.php">Fahrradunfälle nach Kreisen und kreisfreien Städten</a></li> <li><a href="kreise.php">Fahrradunfälle nach Kreisen und kreisfreien Städten</a></li>
<li><a href="<?=$gemeinde_page?>">Fahrradunfälle nach Gemeinden</a></li> <li><a href="<?=$gemeinde_page?>">Fahrradunfälle nach Gemeinden</a></li>
<li><a href="nrw_details.php">Landeswerte</a></li>
</ul> </ul>
</div> </div>

View File

@ -0,0 +1,356 @@
<?php
require_once("../config.php");
require_once("../lib/attributes.php");
require_once("functions.php");
$numLand=5; // NRW
$numRegbez=(isset($_GET['regbez'])) ? (int)$_GET['regbez'] : 1;
$numKreis=(isset($_GET['kreis'])) ? (int)$_GET['kreis'] : 1;
$numJahr=$numLatestYear;
$strName = "xxxx";
// Name, Population und Fläche der Gemeinde
$result= $db->prepare("SELECT sum(Flaeche) as Flaeche, sum(Einwohner) as Einwohner, UREGBEZ, UKREIS
FROM community WHERE ULAND=:land AND UREGBEZ=:regbez AND UKREIS=:kreis");
$result->bindParam(":land",$numLand);
$result->bindParam(":regbez",$numRegbez);
$result->bindParam(":kreis",$numKreis);
$result->execute();
if ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$numFlaeche=round($row['Flaeche'],1);
$numPopulation=$row['Einwohner'];
$numRegbez=$row['UREGBEZ'];
$numKreis=$row['UKREIS'];
} else {exit;}
$result=$db->query("SELECT district,title FROM district WHERE UREGBEZ=$numRegbez AND UKREIS=$numKreis AND ULAND=$numLand");
if ($row = $result->fetch(PDO::FETCH_ASSOC)){
$strName=$row['title'];
$strDistrict=$row['district'];
}
$strLocation=" AND ULAND=$numLand AND UREGBEZ=$numRegbez AND UKREIS=$numKreis ";
$resultUnfallzahlen = get_unfallzahlen($numJahr,$strLocation);
$resultUnfallart = get_unfallart($numJahr,$strLocation);
$resultUnfalltyp = get_unfalltyp($numJahr,$strLocation);
$resultBeteiligte = get_beteiligte($numJahr,$strLocation);
$resultVerlauf = get_verlauf($strLocation);
$numGesamt=0;
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fahrrad-Unfallstatistik NRW</title>
<link rel="stylesheet" href="../css/bootstrap.min.css"/>
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/highcharts.js"></script>
<style>
.rechts {text-align:right;background-color:#eee;}
.l {border-left: 1px solid black; }
</style>
</head>
<body>
<?php include("navbar.php"); ?>
<div class="container" style="margin-top:4em;">
<h1>Fahrradunfälle in <?=$strName?></h2>
<p>Einwohnerzahl: <?=$numPopulation?>&nbsp;&nbsp; Fläche: <?=$numFlaeche?> km<sup>2</sup></p>
<p><a class='btn btn-primary' href="../index.php?d=<?=$strDistrict?>">Zur Unfallkarte</a></p>
<!-- Unfallverlauf -->
<div class="row">
<div class="col-5">
<h4>Unfallverlauf von <?=$numLatestYear?> bis <?=$numStartYear?></h4>
<table class='table table-sm'>
<tr><th></th><th>2022</th><th>2021</th><th>2020</th><th>2019</th></tr>
<tr><td><?= $arrCategory[1]?></td><?= get_row($resultVerlauf,1) ?></tr>
<tr><td><?= $arrCategory[2]?></td><?= get_row($resultVerlauf,2) ?></tr>
<tr><td><?= $arrCategory[3]?></td><?= get_row($resultVerlauf,3) ?></tr>
<tr><th>Gesamt</th><?= get_row($resultVerlauf,0) ?></tr>
</table>
</div>
<div class="col-7">
<div id="c_unfallverlauf"></div>
</div>
</div>
<!-- Unfallzahlen -->
<div class="row">
<div class="col-5">
<h4>Unfallzahlen <?=$numJahr?></h4>
<table class="table table-sm">
<?php
//DEBUG echo "<pre>"; print_r($resultUnfallzahlen);echo "</pre>";
$numGesamt=0;
foreach ($resultUnfallzahlen as $row) {
echo "<tr><td>".$arrCategory[$row['UKATEGORIE']]."</td><td>".$row['anz']."</td></tr>\n";
$numGesamt+=$row['anz'];
}
?>
<tr><th>Gesamt</th><td><strong><?=$numGesamt?></strong></td></tr>
</table>
<table class="table table-sm">
<tr><th>Quote pro Tausend Einwohner</th><td><?= round($numGesamt/$numPopulation*1000,2) ?></td></tr>
<tr><th>Quote pro Fläche</th><td><?= round($numGesamt/$numFlaeche,1) ?> /km<sup>2</sup></td></tr>
</table>
</div>
<div class="col-7">
<div id="c_unfallzahlen"></div>
</div>
</div>
<!-- Unfallbeteilgte -->
<div class="row">
<div class="col-5">
<h4>Unfallbeteiligte</h4>
<table class='table table-sm'>
<?php
// DEBUG: echo "<pre>"; print_r($resultBeteiligte);echo "</pre>";
foreach ($resultBeteiligte as $key => $numCount) {
echo "<tr><td>".$arrBeteiligte[$key]."</td><td>".$numCount."</td></tr>\n";
}
?>
</table>
</div>
<div class="col-7">
<div id="c_unfallbeteiligte"></div>
</div>
</div>
<!-- Unfalltyp -->
<div class="row">
<div class="col-5">
<h4>Unfalltyp</h4>
<table class='table table-sm'>
<?php
foreach ($resultUnfalltyp as $row) {
echo "<tr><td>".$arrUnfalltyp[$row['UTYP1']]."</td><td>".$row['anz']."</td></tr>\n";
}
?>
</table>
</div>
<div class="col-7">
<div id="c_unfalltyp"></div>
</div>
</div>
<!-- Unfallarten -->
<div class="row">
<div class="col-5">
<h4>Unfallart</h4>
<table class='table table-sm'>
<?php
foreach ($resultUnfallart as $row) {
echo "<tr><td>".$arrUnfallart[$row['UART']]."</td><td>".$row['anz']."</td></tr>\n";
}
?>
</table>
</div>
<div class="col-7">
<div id="c_unfallarten"></div>
</div>
</div>
</div>
</body>
<script>
Highcharts.chart('c_unfallzahlen', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Unfallzahlen',
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: 'Unfallzahlen',
colorByPoint: true,
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: 'Unfalltypen',
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") ?>
}]
});
Highcharts.chart('c_unfallbeteiligte', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Unfallbeteiligte',
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_beteiligte($resultBeteiligte,$arrBeteiligte) ?>
}]
});
Highcharts.chart('c_unfallverlauf', {
chart: {
type: 'column'
},
title: {
text: 'Verlauf der Fahrradunfälle',
align: 'center'
},
xAxis: {
categories: ['2022','2021','2020','2019']
},
yAxis: {
min: 0,
title: {
text: 'Jahr'
},
stackLabels: {
enabled: true
}
},
legend: {
align: 'left',
x: 400,
verticalAlign: 'top',
y: 30,
floating: true,
backgroundColor:
Highcharts.defaultOptions.legend.backgroundColor || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true
}
}
},
series: <?=get_series_verlauf($resultVerlauf,$arrCategory)?>
});
</script>
</html>

View File

@ -9,6 +9,7 @@
<link rel="stylesheet" href="//cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css"> <link rel="stylesheet" href="//cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">
<script src="../js/jquery.min.js"></script> <script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="//cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script> <script src="//cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<style> <style>
.rechts {text-align:right;} .rechts {text-align:right;}
@ -17,34 +18,7 @@
</head> </head>
<body> <body>
<!-- Navbar --> <?php include("navbar.php"); ?>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Unfallkarte</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbars">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="../index.php">Karte</a>
</li>
</ul>
<div>
<ul class="navbar-nav mr-auto right">
<li class="nav-item active">
<a class="nav-link" href="index.php">Statistik <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../impressum.php">Impressum</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../datenschutz.php">Datenschutzerklärung</a>
</li>
</ul>
</div>
</nav>
<!-- Ende Navbar -->
<div class="container-fluid" style="margin-top:4em;"> <div class="container-fluid" style="margin-top:4em;">
@ -96,7 +70,10 @@ $strSQL="SELECT d.title as Kreis,
SUM(UJAHR=2020 AND UKATEGORIE=3) as Leichtverletzt_2020, SUM(UJAHR=2020 AND UKATEGORIE=3) as Leichtverletzt_2020,
SUM(UJAHR=2019 AND UKATEGORIE=3) as Leichtverletzt_2019, SUM(UJAHR=2019 AND UKATEGORIE=3) as Leichtverletzt_2019,
d.Population as Population, d.Population as Population,
SUM(UJAHR=2022)/d.Population*1000 as Quote_2022 SUM(UJAHR=2022)/d.Population*1000 as Quote_2022,
s.ULAND,
s.UREGBEZ ,
s.UKREIS
FROM data s, district d FROM data s, district d
WHERE IstRad=1 WHERE IstRad=1
AND d.ULAND=s.ULAND AND d.UREGBEZ=s.UREGBEZ AND d.UKREIS=s.UKREIS AND d.ULAND=s.ULAND AND d.UREGBEZ=s.UREGBEZ AND d.UKREIS=s.UKREIS
@ -107,7 +84,7 @@ $result=$db->query($strSQL);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
echo "<tr>"; echo "<tr>";
echo "<td><a href='../index.php?d=".$row['district'],"'>".$row['Kreis']."</a></td>"; echo "<td><a href='kreis_details.php?regbez=".$row['UREGBEZ']."&kreis=".$row['UKREIS']."'>".$row['Kreis']."</a></td>";
echo "<td class='l'>".$row['Jahr_2022']."</td>"; echo "<td class='l'>".$row['Jahr_2022']."</td>";
echo "<td>".$row['Jahr_2021']."</td>"; echo "<td>".$row['Jahr_2021']."</td>";
echo "<td>".$row['Jahr_2020']."</td>"; echo "<td>".$row['Jahr_2020']."</td>";

38
statistics/navbar.php Normal file
View File

@ -0,0 +1,38 @@
<!-- Navbar -->
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Unfallkarte</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbars">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="../index.php">Karte</a>
</li>
</ul>
<div>
<ul class="navbar-nav mr-auto right">
<li class="nav-item active dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Statistik
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="nrw_details.php">NRW</a>
<a class="dropdown-item" href="kreise.php">Kreise</a>
<a class="dropdown-item" href="gemeinden.php">Gemeinden</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="../impressum.php">Impressum</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../datenschutz.php">Datenschutzerklärung</a>
</li>
</ul>
</div>
</nav>
<!-- Ende Navbar -->

343
statistics/nrw_details.php Normal file
View File

@ -0,0 +1,343 @@
<?php
require_once("../config.php");
require_once("../lib/attributes.php");
require_once("functions.php");
$numLand=5; // NRW
$strName="NRW";
$numJahr=$numLatestYear;
$strLocation=" AND ULAND=$numLand ";
// Name, Population und Fläche der Gemeinde
$result= $db->prepare("SELECT sum(Flaeche) as Flaeche, sum(Einwohner) as Einwohner FROM community WHERE ULAND=:land");
$result->bindParam(":land",$numLand);
$result->execute();
if ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$numFlaeche=round($row['Flaeche'],0);
$numPopulation=$row['Einwohner'];
} else {exit;}
$resultUnfallzahlen = get_unfallzahlen($numJahr,$strLocation);
$resultUnfallart = get_unfallart($numJahr,$strLocation);
$resultUnfalltyp = get_unfalltyp($numJahr,$strLocation);
$resultBeteiligte = get_beteiligte($numJahr,$strLocation);
$resultVerlauf = get_verlauf($strLocation);
$numGesamt=0;
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fahrrad-Unfallstatistik NRW</title>
<link rel="stylesheet" href="../css/bootstrap.min.css"/>
<script src="../js/jquery.min.js"></script>
<script src="../js/highcharts.js"></script>
<script src="../js/bootstrap.min.js"></script>
<style>
.rechts {text-align:right;background-color:#eee;}
.l {border-left: 1px solid black; }
</style>
</head>
<body>
<?php include("navbar.php"); ?>
<div class="container" style="margin-top:4em;">
<h1>Fahrradunfälle in <?=$strName?></h2>
<p>Einwohnerzahl: <?=$numPopulation?>&nbsp;&nbsp; Fläche: <?=$numFlaeche?> km<sup>2</sup></p>
<!-- Unfallverlauf -->
<div class="row">
<div class="col-5">
<h4>Unfallverlauf von <?=$numLatestYear?> bis <?=$numStartYear?></h4>
<table class='table table-sm'>
<tr><th></th><th>2022</th><th>2021</th><th>2020</th><th>2019</th></tr>
<tr><td><?= $arrCategory[1]?></td><?= get_row($resultVerlauf,1) ?></tr>
<tr><td><?= $arrCategory[2]?></td><?= get_row($resultVerlauf,2) ?></tr>
<tr><td><?= $arrCategory[3]?></td><?= get_row($resultVerlauf,3) ?></tr>
<tr><th>Gesamt</th><?= get_row($resultVerlauf,0) ?></tr>
</table>
</div>
<div class="col-7">
<div id="c_unfallverlauf"></div>
</div>
</div>
<!-- Unfallzahlen -->
<div class="row">
<div class="col-5">
<h4>Unfallzahlen <?=$numJahr?></h4>
<table class="table table-sm">
<?php
//DEBUG echo "<pre>"; print_r($resultUnfallzahlen);echo "</pre>";
$numGesamt=0;
foreach ($resultUnfallzahlen as $row) {
echo "<tr><td>".$arrCategory[$row['UKATEGORIE']]."</td><td>".$row['anz']."</td></tr>\n";
$numGesamt+=$row['anz'];
}
?>
<tr><th>Gesamt</th><td><strong><?=$numGesamt?></strong></td></tr>
</table>
<table class="table table-sm">
<tr><th>Quote pro Tausend Einwohner</th><td><?= round($numGesamt/$numPopulation*1000,2) ?></td></tr>
<tr><th>Quote pro Fläche</th><td><?= round($numGesamt/$numFlaeche,1) ?> /km<sup>2</sup></td></tr>
</table>
</div>
<div class="col-7">
<div id="c_unfallzahlen"></div>
</div>
</div>
<!-- Unfallbeteilgte -->
<div class="row">
<div class="col-5">
<h4>Unfallbeteiligte</h4>
<table class='table table-sm'>
<?php
// DEBUG: echo "<pre>"; print_r($resultBeteiligte);echo "</pre>";
foreach ($resultBeteiligte as $key => $numCount) {
echo "<tr><td>".$arrBeteiligte[$key]."</td><td>".$numCount."</td></tr>\n";
}
?>
</table>
</div>
<div class="col-7">
<div id="c_unfallbeteiligte"></div>
</div>
</div>
<!-- Unfalltyp -->
<div class="row">
<div class="col-5">
<h4>Unfalltyp</h4>
<table class='table table-sm'>
<?php
foreach ($resultUnfalltyp as $row) {
echo "<tr><td>".$arrUnfalltyp[$row['UTYP1']]."</td><td>".$row['anz']."</td></tr>\n";
}
?>
</table>
</div>
<div class="col-7">
<div id="c_unfalltyp"></div>
</div>
</div>
<!-- Unfallarten -->
<div class="row">
<div class="col-5">
<h4>Unfallart</h4>
<table class='table table-sm'>
<?php
foreach ($resultUnfallart as $row) {
echo "<tr><td>".$arrUnfallart[$row['UART']]."</td><td>".$row['anz']."</td></tr>\n";
}
?>
</table>
</div>
<div class="col-7">
<div id="c_unfallarten"></div>
</div>
</div>
</div>
</body>
<script>
Highcharts.chart('c_unfallzahlen', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Unfallzahlen',
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: 'Unfallzahlen',
colorByPoint: true,
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: 'Unfalltypen',
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") ?>
}]
});
Highcharts.chart('c_unfallbeteiligte', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Unfallbeteiligte',
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_beteiligte($resultBeteiligte,$arrBeteiligte) ?>
}]
});
Highcharts.chart('c_unfallverlauf', {
chart: {
type: 'column'
},
title: {
text: 'Verlauf der Fahrradunfälle',
align: 'center'
},
xAxis: {
categories: ['2022','2021','2020','2019']
},
yAxis: {
min: 0,
title: {
text: 'Jahr'
},
stackLabels: {
enabled: true
}
},
legend: {
align: 'left',
x: 400,
verticalAlign: 'top',
y: 30,
floating: true,
backgroundColor:
Highcharts.defaultOptions.legend.backgroundColor || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true
}
}
},
series: <?=get_series_verlauf($resultVerlauf,$arrCategory)?>
});
</script>
</html>