File size: 6,392 Bytes
31a0997 db3055f 31a0997 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
document.addEventListener('DOMContentLoaded', function() {
// Initialize tooltips
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
// Date display
const dateDisplay = document.getElementById('current-date');
if (dateDisplay) {
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
dateDisplay.textContent = new Date().toLocaleDateString('en-US', options);
}
// Load Chart.js
const script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/chart.js';
script.onload = initializeCharts;
document.head.appendChild(script);
function initializeCharts() {
// Check if we're on the demographics page
if (document.getElementById('programDistributionChart')) {
// Program Distribution Chart
const programDistCtx = document.getElementById('programDistributionChart').getContext('2d');
new Chart(programDistCtx, {
type: 'pie',
data: {
labels: ['CCS Program', 'SPS Program'],
datasets: [{
data: [782, 466],
backgroundColor: ['#4f46e5', '#7c3aed'],
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'right',
},
tooltip: {
callbacks: {
label: function(context) {
const label = context.label || '';
const value = context.raw || 0;
const total = context.dataset.data.reduce((a, b) => a + b, 0);
const percentage = Math.round((value / total) * 100);
return `${label}: ${value} (${percentage}%)`;
}
}
}
}
}
});
// County Breakdown Chart
const countyCtx = document.getElementById('countyBreakdownChart').getContext('2d');
new Chart(countyCtx, {
type: 'bar',
data: {
labels: ['Baltimore City', 'Montgomery', 'Prince George\'s', 'Baltimore County', 'Other Counties'],
datasets: [
{
label: 'CCS',
data: [245, 187, 156, 98, 96],
backgroundColor: '#4f46e5',
},
{
label: 'SPS',
data: [132, 98, 112, 64, 60],
backgroundColor: '#7c3aed',
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
x: {
stacked: true,
},
y: {
stacked: true,
beginAtZero: true
}
}
}
});
}
// Program Comparison Chart (for index page)
const programCtx = document.getElementById('programComparisonChart').getContext('2d');
new Chart(programCtx, {
type: 'pie',
data: {
labels: ['CCS Program', 'SPS Program'],
datasets: [{
data: [782, 466],
backgroundColor: ['#4f46e5', '#7c3aed'],
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'right',
},
tooltip: {
callbacks: {
label: function(context) {
const label = context.label || '';
const value = context.raw || 0;
const total = context.dataset.data.reduce((a, b) => a + b, 0);
const percentage = Math.round((value / total) * 100);
return `${label}: ${value} (${percentage}%)`;
}
}
}
}
}
});
// LTSS Eligibility Comparison Chart
const ltssCtx = document.getElementById('ltssComparisonChart').getContext('2d');
new Chart(ltssCtx, {
type: 'pie',
data: {
labels: ['Our Programs', 'Other LTSS-Eligible in MD'],
datasets: [{
data: [1248, 3200],
backgroundColor: ['#10b981', '#6b7280'],
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'right',
},
tooltip: {
callbacks: {
label: function(context) {
const label = context.label || '';
const value = context.raw || 0;
const total = context.dataset.data.reduce((a, b) => a + b, 0);
const percentage = Math.round((value / total) * 100);
return `${label}: ${value} (${percentage}%)`;
}
}
}
}
}
});
}
});
|