Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat: Make pie chart truly generic for LLM domain categories

LearningCircuitae97a0a2c7b7
diff --git a/src/local_deep_research/web/templates/pages/link_analytics.html b/src/local_deep_research/web/templates/pages/link_analytics.html
index b3aad95865..e2849dbb4b 100644
--- a/src/local_deep_research/web/templates/pages/link_analytics.html
+++ b/src/local_deep_research/web/templates/pages/link_analytics.html
@@ -662,19 +662,34 @@ async function loadLinkAnalytics(period = '30d') {
document.getElementById('avg-links').textContent = data.avg_links_per_research || 0;
document.getElementById('total-researches').textContent = data.total_researches || 0;
- // Update source type bars
- const sourceTypes = data.academic_vs_general || {};
- const total = sourceTypes.academic + sourceTypes.news + sourceTypes.reference + sourceTypes.general || 1;
-
- updateSourceTypeBar('academic', sourceTypes.academic || 0, total);
- updateSourceTypeBar('news', sourceTypes.news || 0, total);
- updateSourceTypeBar('reference', sourceTypes.reference || 0, total);
- updateSourceTypeBar('general', sourceTypes.general || 0, total);
+ // Update source type bars with generic categories
+ const domainCategories = data.domain_categories || {};
+ const categoryEntries = Object.entries(domainCategories);
+ const total = Object.values(domainCategories).reduce((sum, count) => sum + count, 0) || 1;
+
+ // Update only first 4 bars with actual categories (if they exist)
+ const barIds = ['academic', 'news', 'reference', 'general'];
+ barIds.forEach((barId, index) => {
+ if (categoryEntries[index]) {
+ const [categoryName, count] = categoryEntries[index];
+ updateSourceTypeBar(barId, count, total);
+ // Update bar label to show actual category name
+ const barElement = document.querySelector(`[data-bar="${barId}"]`);
+ if (barElement) {
+ const labelElement = barElement.querySelector('.category-label');
+ if (labelElement) {
+ labelElement.textContent = categoryName;
+ }
+ }
+ } else {
+ updateSourceTypeBar(barId, 0, total);
+ }
+ });
// Update charts
updateTopDomainsChart(data.top_domains || []);
updateDomainDistributionChart(data.domain_distribution || {});
- updateSourceTypeChart(sourceTypes);
+ updateSourceTypeChart(domainCategories);
updateTemporalTrendChart(data.temporal_trend || []);
// Update enhanced domain list with research info
@@ -806,36 +821,28 @@ function updateDomainDistributionChart(distribution) {
});
}
-function updateSourceTypeChart(sourceTypes) {
+function updateSourceTypeChart(domainCategories) {
const ctx = document.getElementById('source-type-chart').getContext('2d');
if (sourceTypeChart) {
sourceTypeChart.destroy();
}
+ // Generate dynamic labels and data from whatever categories the LLM provides
+ const labels = Object.keys(domainCategories);
+ const data = Object.values(domainCategories);
+
+ // Generate colors dynamically based on number of categories
+ const colors = generateChartColors(labels.length);
+
sourceTypeChart = new Chart(ctx, {
type: 'pie',
data: {
- labels: ['Academic', 'News', 'Reference', 'General'],
+ labels: labels,
datasets: [{
- data: [
- sourceTypes.academic || 0,
- sourceTypes.news || 0,
- sourceTypes.reference || 0,
- sourceTypes.general || 0
- ],
- backgroundColor: [
- 'rgba(107, 70, 193, 0.8)',
- 'rgba(245, 158, 11, 0.8)',
- 'rgba(59, 130, 246, 0.8)',
- 'rgba(16, 185, 129, 0.8)'
- ],
- borderColor: [
- 'rgba(107, 70, 193, 1)',
- 'rgba(245, 158, 11, 1)',
- 'rgba(59, 130, 246, 1)',
- 'rgba(16, 185, 129, 1)'
- ],
+ data: data,
+ backgroundColor: colors.background,
+ borderColor: colors.border,
borderWidth: 1
}]
},
@@ -851,6 +858,33 @@ function updateSourceTypeChart(sourceTypes) {
});
}
+// Helper function to generate colors for dynamic number of categories
+function generateChartColors(count) {
+ const baseColors = [
+ 'rgba(107, 70, 193, 0.8)', // Purple
+ 'rgba(245, 158, 11, 0.8)', // Orange
+ 'rgba(59, 130, 246, 0.8)', // Blue
+ 'rgba(16, 185, 129, 0.8)', // Green
+ 'rgba(239, 68, 68, 0.8)', // Red
+ 'rgba(139, 69, 19, 0.8)', // Brown
+ 'rgba(255, 192, 203, 0.8)', // Pink
+ 'rgba(128, 128, 128, 0.8)', // Gray
+ 'rgba(255, 165, 0, 0.8)', // Orange
+ 'rgba(75, 0, 130, 0.8)' // Indigo
+ ];
+
+ const background = [];
+ const border = [];
+
+ for (let i = 0; i < count; i++) {
+ const colorIndex = i % baseColors.length;
+ background.push(baseColors[colorIndex]);
+ border.push(baseColors[colorIndex].replace('0.8', '1'));
+ }
+
+ return { background, border };
+}
+
function updateTemporalTrendChart(trendData) {
const ctx = document.getElementById('temporal-trend-chart').getContext('2d');