xxxxxxxxxx
<!DOCTYPE html>
<html>
<head>
<title>Pie Chart Example</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<canvas id="chart"></canvas>
<script>
// Get the canvas element
const canvas = document.getElementById('chart');
// Prepare the dataset for the pie chart
const data = {
labels: ['Red', 'Blue', 'Yellow'],
datasets: [{
data: [10, 20, 30],
backgroundColor: ['red', 'blue', 'yellow']
}]
};
// Create the pie chart
new Chart(canvas, {
type: 'pie',
data: data
});
</script>
</body>
</html>
xxxxxxxxxx
<!DOCTYPE html>
<html>
<head>
<title>Pie Chart using Chart.js</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<canvas id="myChart"></canvas>
<script>
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'pie',
data: {
labels: ['Red', 'Blue', 'Yellow'],
datasets: [{
data: [10, 20, 30],
backgroundColor: ['red', 'blue', 'yellow'],
}]
},
options: {}
});
</script>
</body>
</html>