Root Cause Analysis Dashboard

Open RCAs
0
Total Problems Logged
0

Potential Causes (comma-separated)

Conclusion

Select a problem to view its analysis.

'; return; } const problem = this.rcaData.find(d => d.id == problemId); this.renderFishboneDiagram(problem); }, renderFishboneDiagram(problem) { /* Renders the fishbone diagram */ }, renderKPIs() { /* Renders top-level KPI cards */ }, renderCategoryChart() { /* Renders bar chart of root cause categories */ }, openTab(tabName) { /* Standard tab logic */ }, navigateTabs(direction) { /* Standard nav logic */ }, updateNavButtons() { /* Standard nav button logic */ }, generatePDF() { /* Standard PDF logic */ } }; // Simplified & complete standard functions pRcaApp.addEventListeners = function() { document.querySelectorAll('.p-rca-tab-button').forEach(btn => btn.addEventListener('click', e => this.openTab(e.currentTarget.dataset.tab))); document.getElementById('p-rca-data-form').addEventListener('submit', e => { e.preventDefault(); this.handleAddOrUpdate(); }); document.getElementById('p-rca-problem-select').addEventListener('change', () => this.displayDashboardForSelectedProblem()); document.getElementById('p-rca-download-pdf').addEventListener('click', () => this.generatePDF()); document.getElementById('p-rca-nextBtn').addEventListener('click', () => this.navigateTabs(1)); document.getElementById('p-rca-prevBtn').addEventListener('click', () => this.navigateTabs(-1)); }; pRcaApp.handleAddOrUpdate = function() { const data = { problem: document.getElementById('p-rca-problem').value, status: 'Open', causes: {}, rootCause: document.getElementById('p-rca-root-cause').value, rootCauseCategory: document.getElementById('p-rca-root-cause-cat').value }; this.config.categories.forEach(cat => { const causesText = document.getElementById(`p-rca-cause-${cat.toLowerCase()}`).value; data.causes[cat] = causesText.split(',').map(c => c.trim()).filter(Boolean); }); data.id = Date.now(); this.rcaData.push(data); document.getElementById('p-rca-data-form').reset(); this.updateDashboard(); alert('Problem analysis added!'); }; pRcaApp.populateProblemFilter = function() { const select = document.getElementById('p-rca-problem-select'); const currentVal = select.value; select.innerHTML = ''; this.rcaData.forEach(p => select.add(new Option(p.problem, p.id))); select.value = this.rcaData.some(d => d.id == currentVal) ? currentVal : (this.rcaData[0]?.id || ''); }; pRcaApp.renderKPIs = function() { document.getElementById('p-rca-kpi-open').textContent = this.rcaData.filter(d => d.status !== 'Closed').length; document.getElementById('p-rca-kpi-total').textContent = this.rcaData.length; }; pRcaApp.renderFishboneDiagram = function(problem) { const container = document.getElementById('p-rca-fishbone-diagram'); const categories = this.config.categories; let html = '
'; categories.forEach((cat, i) => { const posClass = i < 3 ? `p-rca-cat-top-${i === 0 ? 'left' : i === 1 ? 'mid-left' : 'bot-left'}` : `p-rca-cat-top-${i === 3 ? 'right' : i === 4 ? 'mid-right' : 'bot-right'}`; const causesHtml = (problem.causes[cat] || []).map(c => `
  • ${c}
  • `).join(''); html += `

    ${cat}

      ${causesHtml}
    `; }); html += `
    ${problem.problem}
    `; container.innerHTML = html; }; pRcaApp.renderCategoryChart = function() { const id = 'p-rca-category-chart'; const ctx = document.getElementById(id); if (!ctx) return; const categoryCounts = this.config.categories.reduce((acc, cat) => { acc[cat] = this.rcaData.filter(d => d.rootCauseCategory === cat).length; return acc; }, {}); if (this.charts[id]) this.charts[id].destroy(); this.charts[id] = new Chart(ctx, { type: 'bar', data: { labels: Object.keys(categoryCounts), datasets: [{ data: Object.values(categoryCounts), backgroundColor: '#5c6bc0' }] }, options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false }, title: { display: true, text: 'Identified Root Cause by Category' } }, scales: { y: { beginAtZero: true, ticks: { stepSize: 1 } } } } }); }; pRcaApp.openTab = function(tabName) { this.currentTab = tabName; document.querySelectorAll('.p-rca-tab-content').forEach(c => c.classList.remove('active')); document.querySelectorAll('.p-rca-tab-button').forEach(b => b.classList.remove('active')); document.getElementById(`p-rca-${tabName}`).classList.add('active'); document.querySelector(`.p-rca-tab-button[data-tab='${tabName}']`).classList.add('active'); this.updateNavButtons(); }; pRcaApp.navigateTabs = function(direction) { const tabs = ['Dashboard', 'Config']; const nextIndex = tabs.indexOf(this.currentTab) + direction; if (nextIndex >= 0 && nextIndex < tabs.length) this.openTab(tabs[nextIndex]); }; pRcaApp.updateNavButtons = function() { const prevBtn = document.getElementById('p-rca-prevBtn'); const nextBtn = document.getElementById('p-rca-nextBtn'); prevBtn.style.visibility = (this.currentTab === 'Dashboard') ? 'hidden' : 'visible'; nextBtn.style.visibility = (this.currentTab === 'Config') ? 'hidden' : 'visible'; }; pRcaApp.generatePDF = function() { html2pdf().from(document.getElementById('p-rca-tool-content-for-pdf')).set({ margin: 0.5, filename: 'RCA_Dashboard.pdf', image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true }, jsPDF: { unit: 'in', format: 'letter', orientation: 'landscape' } }).save(); }; pRcaApp.init(); });
    Scroll to Top