${count}
`;
statusDistributionElem.appendChild(statusCard);
});
}
/**
* Generates a PDF of the dashboard content.
* Excludes non-essential UI elements like buttons and input forms.
*/
function generatePdf() {
// Create a temporary div to hold only the content for PDF
const pdfContentWrapper = document.createElement('div');
pdfContentWrapper.classList.add('pdf-content-wrapper'); // Apply PDF-specific styles
// Add title
const title = document.createElement('h2');
title.textContent = 'Story Point Dashboard Report';
title.classList.add('text-2xl', 'font-bold', 'mb-4');
pdfContentWrapper.appendChild(title);
// Add summary cards
const summarySection = document.createElement('div');
summarySection.classList.add('grid', 'grid-cols-4', 'gap-4', 'mb-6');
summarySection.innerHTML = `
Total Stories
${totalStoriesElem.textContent}
Total Story Points
${totalStoryPointsElem.textContent}
Completed Story Points
${completedStoryPointsElem.textContent}
Remaining Story Points
${remainingPointsElem.textContent}
`;
pdfContentWrapper.appendChild(summarySection);
// Add completion progress bar
const completionProgressSection = document.createElement('div');
completionProgressSection.innerHTML = `
Completion Progress
${completionProgressBar.textContent}
`;
pdfContentWrapper.appendChild(completionProgressSection);
// Add status distribution
const statusDistributionSection = document.createElement('div');
statusDistributionSection.innerHTML = `
Story Status Distribution
${statusDistributionElem.innerHTML}
`;
pdfContentWrapper.appendChild(statusDistributionSection);
// Add detailed story list table
const storyListSection = document.createElement('div');
storyListSection.innerHTML = `
Detailed Story List
| ID |
Story Name |
Story Points |
Status |
Assigned To |
${dashboardStoryTableBody.innerHTML}
`;
pdfContentWrapper.appendChild(storyListSection);
// Options for html2pdf
const options = {
margin: 10,
filename: 'Story_Point_Dashboard.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2, logging: true, dpi: 192, letterRendering: true },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
pagebreak: { mode: ['avoid-all', 'css', 'legacy'] }
};
// Generate PDF from the temporary content wrapper
html2pdf().from(pdfContentWrapper).set(options).save();
// Clean up the temporary div (optional, as it's not appended to the DOM)
pdfContentWrapper.remove();
}
/**
* Loads initial sample data for the dashboard.
* Relevant to USA context.
*/
function loadSampleData() {
stories = [
{ id: 'story_001', storyName: 'Implement User Authentication', storyPoints: 8, status: 'Done', assignedTo: 'Alice Johnson' },
{ id: 'story_002', storyName: 'Design Database Schema', storyPoints: 5, status: 'In Progress', assignedTo: 'Bob Williams' },
{ id: 'story_003', storyName: 'Develop Product Catalog Page', storyPoints: 13, status: 'To Do', assignedTo: 'Charlie Brown' },
{ id: 'story_004', storyName: 'Set up Payment Gateway Integration', storyPoints: 8, status: 'Blocked', assignedTo: 'Alice Johnson' },
{ id: 'story_005', storyName: 'Create Admin Dashboard', storyPoints: 21, status: 'In Progress', assignedTo: 'Bob Williams' },
{ id: 'story_006', storyName: 'Optimize Image Loading', storyPoints: 3, status: 'Done', assignedTo: 'Charlie Brown' },
{ id: 'story_007', storyName: 'User Profile Management', storyPoints: 5, status: 'To Do', assignedTo: 'Alice Johnson' }
];
}