File "chart001.php"
Full Path: /home/analogde/www/MDPH/Json/chart001.php
File size: 1.55 KB
MIME-type: text/html
Charset: utf-8
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Graphique avec Chart.js</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<h1>Graphique des valeurs</h1>
<canvas id="myChart" width="400" height="200"></canvas>
<script>
// Données JSON
const data = [
{"value": 0},
{"value": 6},
{"value": 37},
{"value": 46},
{"value": 57},
{"value": 81},
{"value": 98}
];
// Extraire les valeurs pour le graphique
const values = data.map(item => item.value);
const labels = values.map((_, index) => `Point ${index + 1}`);
// Configuration du graphique
const ctx = document.getElementById('myChart').getContext('2d');
const myChart = new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [{
label: 'Valeurs',
data: values,
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1,
fill: false
}]
},
options: {
scales: {
x: {
beginAtZero: true
},
y: {
beginAtZero: true
}
}
}
});
</script>
</body>
</html>