`;
feed.appendChild(card);
// Render chart
const ctx = document.getElementById(cardId).getContext('2d');
const chartConfig = {
type: insight.chartType,
data: { labels: insight.chartData.labels, datasets: [{
label: `${insight.chartData.y} vs ${insight.chartData.x}`,
data: insight.chartData.data,
backgroundColor: ['#6D28D9', '#10B981', '#F59E0B', '#EF4444', '#3B82F6']
}]},
options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false } } }
};
if(insight.chartType === 'scatter') chartConfig.options.scales = { x: { title: {display:true, text:insight.chartData.x} }, y: { title: {display:true, text:insight.chartData.y} } };
charts[cardId] = new Chart(ctx, chartConfig);
});
};
// --- EVENT LISTENERS ---
generateBtn.addEventListener('click', runAnalysis);
settings.corrThreshold.addEventListener('input', (e) => document.getElementById('corr-val').textContent = parseFloat(e.target.value).toFixed(2));
window.insSwitchTab = (evt, tabName) => {
document.querySelectorAll('#insights-dashboard-container .ins-tab-content').forEach(tc => tc.style.display = 'none');
document.querySelectorAll('#insights-dashboard-container .ins-tab-button').forEach(tl => tl.classList.remove('active'));
document.getElementById(tabName).style.display = 'block';
evt.currentTarget.classList.add('active');
};
// --- INITIALIZATION ---
loadSampleData();
runAnalysis();
});
