Haushaltsbuch/diagramme.php
2025-12-13 17:30:14 +01:00

59 lines
1.2 KiB
PHP

<?php
require_once __DIR__ . '/includes/db_connect.php';
$labels = ["Jan", "Feb", "Mrz", "Apr"];
$reiheA = [10, 20, 15, 30];
$reiheB = [5, 12, 18, 25];
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<div class="header">
<h2 class="seitentitel">
Diagramme
</h2>
<a href="index.php"
class="konto_header"
id="konto_navigationRechts">
<img src="img\home.svg" alt="Home" class="menue">
</a>
</div>
<div id="chart" style="width:600px;height:300px;"></div>
<script>
const labels = <?php echo json_encode($labels); ?>;
const reiheA = <?php echo json_encode($reiheA); ?>;
const reiheB = <?php echo json_encode($reiheB); ?>;
const data = [
{
x: labels,
y: reiheA,
type: "scatter",
mode: "lines",
name: "Reihe A"
},
{
x: labels,
y: reiheB,
type: "scatter",
mode: "lines",
name: "Reihe B"
}
];
Plotly.newPlot("chart", data, {
margin: { t: 20 }
});
</script>
</body>
</html>