AI-Powered Insights Dashboard

Source Data Editor

Change any value below to see the AI Insights automatically update.

${insight.text}

`; feed.appendChild(card); const chartConfig = insight.getChartData(sourceData); const ctx = document.getElementById(canvasId).getContext('2d'); const chartInstance = new Chart(ctx, { type: chartConfig.type, data: chartConfig.data, options: chartConfig.options || {} }); activeChartInstances.push(chartInstance); }); } function renderDataTable() { const table = document.getElementById('data-editor-table'); const headers = ['Data Series', ...sourceData.sales_labels]; let tableHtml = `${headers.map(h => `${h}`).join('')}`; for (const [seriesName, values] of Object.entries(sourceData.series)) { tableHtml += `${seriesName}`; values.forEach((value, index) => { tableHtml += ``; }); tableHtml += ``; } table.innerHTML = tableHtml + ``; } // --- EVENT LISTENERS & NAVIGATION --- function switchTab(tabId) { document.querySelectorAll('.ai-tab-button').forEach(btn => btn.classList.toggle('active', btn.dataset.tab === tabId)); document.querySelectorAll('.ai-tab-pane').forEach(pane => pane.classList.toggle('active', pane.id === `tab-pane-${tabId}`)); } function attachEventListeners() { document.querySelectorAll('.ai-tab-button').forEach(button => button.addEventListener('click', (e) => switchTab(e.currentTarget.dataset.tab))); document.getElementById('refresh-insights-btn').addEventListener('click', () => renderInsights(true)); const filterContainer = document.querySelector('.ai-filter-buttons'); filterContainer.addEventListener('click', (e) => { if (e.target.tagName === 'BUTTON') { const filter = e.target.dataset.filter; document.getElementById('insights-feed').className = `filter-${filter}`; filterContainer.querySelector('button.active').classList.remove('active'); e.target.classList.add('active'); } }); document.getElementById('data-editor-table').addEventListener('input', (e) => { if (e.target.classList.contains('data-input')) { const seriesName = e.target.dataset.series; const index = parseInt(e.target.dataset.index); const newValue = parseFloat(e.target.value); if (!isNaN(newValue)) { sourceData.series[seriesName][index] = newValue; renderInsights(false); // Re-render existing insights with new data } } }); document.getElementById('download-pdf-btn').addEventListener('click', () => { /* PDF Logic placeholder */ }); } // --- INITIALIZATION --- render(); attachEventListeners(); });
Scroll to Top