<!DOCTYPE html>
<html>
<head>
<title>Pie Chart Example</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<canvas id="myChart" width="400" height="400"></canvas>
<script>
// Sample data from Table A and Table B
let dataA = [10, 20, 30];
let dataB = [15, 25, 35];
// Calculate total count from both tables
let totalA = dataA.reduce((a, b) => a + b, 0);
let totalB = dataB.reduce((a, b) => a + b, 0);
// Combine the data for the pie chart
let data = [totalA, totalB];
// Create the pie chart
let ctx = document.getElementById('myChart').getContext('2d');
let myChart = new Chart(ctx, {
type: 'pie',
data: {
labels: ['Table A', 'Table B'],
datasets: [{
data: data,
backgroundColor: [
'rgba(255, 99, 132, 0.8)',
'rgba(54, 162, 235, 0.8)'
]
}]
}
});
</script>
</body>
</html>