-
Notifications
You must be signed in to change notification settings - Fork 6
Enhance data visualization and UI for Analyze dashboard #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -298,7 +298,9 @@ function renderData(data) { | |
| labels = labels.slice(-n); | ||
| } | ||
|
|
||
| renderChartsAndTable({ ...data, feeds, labels }); | ||
| const slicedData = { ...data, feeds, labels }; | ||
| renderChartsAndTable(slicedData); | ||
| renderAIOverview(slicedData); | ||
| }; | ||
|
|
||
| document.querySelectorAll('input[name="slicer"]').forEach(radio => { | ||
|
|
@@ -654,4 +656,72 @@ Data: ${JSON.stringify(data || {})} | |
| function clearChat() { | ||
| const responseContainer = document.getElementById("response-container"); | ||
| responseContainer.innerHTML = ""; | ||
| } | ||
| } | ||
|
|
||
| function computeAIStats(data) { | ||
| return data.fields.map(field => { | ||
| const values = data.feeds | ||
| .map(f => Number(f[field.key])) | ||
| .filter(v => Number.isFinite(v)); | ||
|
|
||
| if (!values.length) { | ||
| return { label: field.label, avg: 0 }; | ||
| } | ||
|
|
||
| const avg = values.reduce((a, b) => a + b, 0) / values.length; | ||
|
|
||
| return { | ||
| label: field.label, | ||
| avg: Number(avg.toFixed(2)) | ||
| }; | ||
| }); | ||
|
Comment on lines
+661
to
+677
|
||
| } | ||
|
|
||
|
|
||
| function renderAIOverview(data) { | ||
| const canvas = document.getElementById("aiOverviewChart"); | ||
| if (!canvas) return; | ||
|
|
||
| const ctx = canvas.getContext("2d"); | ||
| const stats = computeAIStats(data); | ||
|
Comment on lines
+681
to
+686
|
||
|
|
||
| if (window.aiChart) window.aiChart.destroy(); | ||
|
|
||
| window.aiChart = new Chart(ctx, { | ||
|
Comment on lines
+688
to
+690
|
||
| type: "bar", | ||
| data: { | ||
| labels: stats.map(s => s.label), | ||
| datasets: [{ | ||
| label: "Average Value", | ||
| data: stats.map(s => s.avg), | ||
| backgroundColor: "rgba(0, 255, 255, 0.6)", | ||
| borderColor: "rgba(0, 255, 255, 1)", | ||
|
Comment on lines
+697
to
+698
|
||
| borderWidth: 1.5, | ||
| borderRadius: 6 | ||
| }] | ||
| }, | ||
| options: { | ||
| responsive: true, | ||
| plugins: { | ||
| legend: { | ||
| labels: { color: "#ddd" } | ||
| }, | ||
| tooltip: { | ||
| backgroundColor: "#111", | ||
| borderColor: "#00ffff", | ||
| borderWidth: 1 | ||
| } | ||
| }, | ||
| scales: { | ||
| x: { | ||
| ticks: { color: "#aaa" }, | ||
| grid: { display: false } | ||
| }, | ||
| y: { | ||
| ticks: { color: "#aaa" }, | ||
| grid: { color: "rgba(255,255,255,0.05)" } | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+703
to
+725
|
||
| }); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The computation returns an average of 0 for fields with no valid numeric values. While this prevents errors, it may be misleading to display fields with 0 average when they actually have no data. Consider either filtering out fields with no valid data or adding a visual indicator (like "N/A" or a different color) to distinguish between actual zero values and missing data.