Smart Healthy Productivity Insights

Smart Healthy Productivity Insights

New Daily Log

Sleep (Previous Night)

Well-being & Productivity (Today)

Recent Log Entries

DateSleep(H)Sleep(Q)StressMoodEnergy Activity(m)TasksProductivityFocusNotesDel

Note: Log data is stored in your browser's LocalStorage.

Dashboard Filters

Overall Averages (Selected Period)

  • No data in selected range.

Log daily data and select a date range to view the dashboard.

"Smart" Insights & Recommendations

  • No data to analyze.

Analysis Period: ${analysisStartDate} to ${analysisEndDate}

`; const avgSummaryContent = document.getElementById('shpi-average-summary-list').outerHTML; if(avgSummaryContent) pdfHTML += `

Overall Averages (Selected Period)

${avgSummaryContent}`; const chartsToInclude = [ {instance: shpiChartInstances['shpi-sleep-chart'], title: "Sleep Duration & Quality"}, {instance: shpiChartInstances['shpi-mood-chart'], title: "Mood Over Time"}, {instance: shpiChartInstances['shpi-stress-chart'], title: "Stress Level Over Time"}, {instance: shpiChartInstances['shpi-energy-chart'], title: "Energy Level Over Time"}, {instance: shpiChartInstances['shpi-productivity-chart'], title: "Productivity Rating Over Time"}, {instance: shpiChartInstances['shpi-focus-chart'], title: "Focus Level Over Time"}, {instance: shpiChartInstances['shpi-activity-chart'], title: "Physical Activity (min)"} ]; chartsToInclude.forEach(chartInfo => { if(chartInfo.instance){ try { // Adding a border to charts in PDF for better visual separation pdfHTML += `

${chartInfo.title}

`; } catch (e) { console.error("Error converting chart to image for PDF: ", chartInfo.title, e); } } }); const insightsContent = document.getElementById('shpi-insights-list').outerHTML; if(insightsContent) pdfHTML += `

"Smart" Insights & Recommendations

${insightsContent}
`; const filteredLogsForPDF = shpiSessionLogs.filter(log => { const logDateOnly = log.date.toISOString().split('T')[0]; return logDateOnly >= analysisStartDate && logDateOnly <= analysisEndDate; }); if (filteredLogsForPDF.length > 0 && confirm("Include detailed daily logs in PDF? This can make the PDF long.")) { pdfHTML += `

Detailed Logs (${analysisStartDate} to ${analysisEndDate})

`; pdfHTML += ``; filteredLogsForPDF.forEach(log => { pdfHTML += ``; }); pdfHTML += `
DateSleep(H)Sleep(Q)StressMoodEnergyActivity(m)TasksProductivityFocusNotes
${log.date.toLocaleDateString()}${log.sleepHours.toFixed(1)}${log.sleepQuality} ${log.stressLevel}${log.mood}${log.energyLevel}${log.physicalActivity} ${log.tasksCompleted}${log.productivity}${log.focus} ${log.notes.substring(0,50)}${log.notes.length > 50 ? '...' : ''}
`; } const pdfContainer = document.getElementById('shpi-report-content-for-pdf'); pdfContainer.innerHTML = pdfHTML; const opt = { margin: [0.5, 0.4, 0.5, 0.4], filename: `Healthy_Productivity_Insights_${analysisStartDate}_to_${analysisEndDate}.pdf`, image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true, logging: false, scrollX:0, scrollY: -window.scrollY, windowWidth: pdfContainer.scrollWidth + 100 }, jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }, pagebreak: { mode: ['avoid-all', 'css', 'legacy'] } }; html2pdf().from(pdfContainer).set(opt).save().then(() => { pdfContainer.innerHTML = ''; }).catch(err => { console.error("Error generating PDF:", err); pdfContainer.innerHTML = ''; alert("An error occurred while generating the PDF. Check console for details."); }); }
Scroll to Top