File "chart_double.php"
Full Path: /home/analogde/www/MDPH/Json/chart_double.php
File size: 1.52 KB
MIME-type: text/html
Charset: utf-8
<!DOCTYPE html>
<html>
<head>
<title>Chart.js Example</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<canvas id="myChart" width="400" height="200"></canvas>
<script>
// Vos données
const x1 = [0, 23, 43, 49, 51, 98];
const x2 = [0, 12, 27, 48, 63, 89];
const y = [6, 5, 4, 3, 2, 1];
// Création du graphique
const ctx = document.getElementById('myChart').getContext('2d');
const myChart = new Chart(ctx, {
type: 'line',
data: {
datasets: [{
label: 'Courbe 1',
data: x1.map((value, index) => ({ x: value, y: y[index] })),
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1,
fill: false,
showLine: true
}, {
label: 'Courbe 2',
data: x2.map((value, index) => ({ x: value, y: y[index] })),
borderColor: 'rgba(153, 102, 255, 1)',
borderWidth: 1,
fill: false,
showLine: true
}]
},
options: {
scales: {
x: {
type: 'linear',
position: 'bottom'
},
y: {
beginAtZero: true
}
}
}
});
</script>
</body>
</html>