Skip to content

Bar chart single point#454

Merged
abidlabs merged 4 commits into
mainfrom
bar-chart-single-point
Mar 26, 2026
Merged

Bar chart single point#454
abidlabs merged 4 commits into
mainfrom
bar-chart-single-point

Conversation

@abidlabs
Copy link
Copy Markdown
Member

@abidlabs abidlabs commented Mar 26, 2026

Renders single-value metrics as bar chart instead of line plots:

Screen.Recording.2026-03-25.at.7.21.30.PM.mov

@gradio-pr-bot
Copy link
Copy Markdown
Contributor

gradio-pr-bot commented Mar 26, 2026

🪼 branch checks and previews

Name Status URL
🦄 Changes detected! Details

@gradio-pr-bot
Copy link
Copy Markdown
Contributor

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
trackio minor

  • Bar chart single point

‼️ Changeset not approved. Ensure the version bump is appropriate for all packages before approving.

  • Maintainers can approve the changeset by checking this checkbox.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@abidlabs abidlabs requested review from Saba9 and znation March 26, 2026 02:21
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@abidlabs abidlabs requested a review from qgallouedec March 26, 2026 15:14
Copy link
Copy Markdown
Collaborator

@qgallouedec qgallouedec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I cannot really review the svelte code though 😅

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for rendering metrics that only contain a single logged value per run as bar charts, improving readability vs. line plots for single-point series.

Changes:

  • Add isSinglePoint() detection in Metrics page and switch rendering to BarPlot for those metrics.
  • Introduce new BarPlot.svelte Vega-Lite component with CSV/PNG export, fullscreen, and drag-reorder support.
  • Update Playwright UI test expectations and add a changeset for a minor release.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
trackio/frontend/src/pages/Metrics.svelte Detects single-point metrics and conditionally renders BarPlot instead of LinePlot.
trackio/frontend/src/components/BarPlot.svelte New bar chart component (Vega-Lite) for single-point metrics with toolbar + fullscreen support.
tests/ui/test_ui_display.py Extends UI test to include a single-point metric and asserts bar plot presence.
.changeset/stupid-lions-speak.md Declares a minor version bump for the new UI behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 286 to 287
{@const useBar = isSinglePoint(metric)}
{#if plotData.length > 0}
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isSinglePoint(metric) scans masterData (filter + per-run counting) and is invoked for every metric render. With many metrics/rows this becomes an O(metrics × rows) hot path on each reactive update. Consider precomputing a Map<metric, boolean> (or counts per metric/run) when masterData changes (e.g., in processFromCache or a $derived.by), and only evaluating it when plotData.length > 0 to avoid extra full scans for empty plots.

Suggested change
{@const useBar = isSinglePoint(metric)}
{#if plotData.length > 0}
{#if plotData.length > 0}
{@const useBar = isSinglePoint(metric)}

Copilot uses AI. Check for mistakes.
Comment on lines +148 to +157
function downloadCSV() {
const barData = getBarData();
if (barData.length === 0) return;
const header = "run," + y;
const rows = barData.map((row) => {
const run =
typeof row.run === "string" && (row.run.includes(",") || row.run.includes('"'))
? `"${row.run.replace(/"/g, '""')}"`
: row.run;
return `${run},${row.value}`;
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSV export builds the header as "run," + y without escaping/quoting y. If a metric name ever contains a comma or quote, the generated CSV will be malformed. Consider applying the same CSV escaping used for run names (and optionally values) to the header fields as well (or use fixed column names like run,value).

Suggested change
function downloadCSV() {
const barData = getBarData();
if (barData.length === 0) return;
const header = "run," + y;
const rows = barData.map((row) => {
const run =
typeof row.run === "string" && (row.run.includes(",") || row.run.includes('"'))
? `"${row.run.replace(/"/g, '""')}"`
: row.run;
return `${run},${row.value}`;
function csvEscape(value) {
if (value == null) return "";
const str = String(value);
return /[",\n]/.test(str) ? `"${str.replace(/"/g, '""')}"` : str;
}
function downloadCSV() {
const barData = getBarData();
if (barData.length === 0) return;
const header = `${csvEscape("run")},${csvEscape(y)}`;
const rows = barData.map((row) => {
return `${csvEscape(row.run)},${csvEscape(row.value)}`;

Copilot uses AI. Check for mistakes.
@abidlabs
Copy link
Copy Markdown
Member Author

Thanks so much for reviewing @qgallouedec! The Svelte should be fine, as it's more or less vendored in from Gradio. Fixed the issues that @copilot found as well, will merge once CI is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants