Skip to content

fix(histogram): SI prefix labels, step-based precision, correct percentage display#884

Open
paddymul wants to merge 2 commits into
mainfrom
fix/histogram-labels-and-percentage
Open

fix(histogram): SI prefix labels, step-based precision, correct percentage display#884
paddymul wants to merge 2 commits into
mainfrom
fix/histogram-labels-and-percentage

Conversation

@paddymul
Copy link
Copy Markdown
Collaborator

@paddymul paddymul commented Jun 1, 2026

Summary

  • Tooltip percentage: was displaying 0.10008342602028921023% (raw 0–1 fraction with % appended). Now multiplies by 100 and rounds to 1dp: 10.0%.
  • Bucket labels — xorq backend: was using .3g format, producing 1.99e+03–2e+03 for year ranges, 2.18e+03 for prices, etc. Replaced with fmt_bucket from histogram.py.
  • Bucket labels — pandas backend: was using {:.0f} (always 0 decimal places), dropping all precision for float columns like carat. Also replaced with fmt_bucket.
  • fmt_num / fmt_bucket helpers (new, in histogram.py): SI prefix (K/M/B/T) for values ≥ 1K; step-based decimal precision (D3-style: precision scales with bucket width, not absolute magnitude); <> separator when the high bound is negative to avoid the ambiguous double-dash (-100--80-100<>-80); strips trailing decimal zeros.
  • cat_pop → population key in xorq_stats_v2._numeric_histogram: numeric histogram bars were keyed as cat_pop, causing the frontend to render them with the categorical pink style instead of grey. Fixed.

Test plan

  • pytest tests/unit/test_xorq_stats_v2.py — updated cat_poppopulation assertions, all pass
  • pytest tests/unit/ (excluding unrelated contrib/file_cache collection errors) — 1097 passed, 1 pre-existing unrelated failure
  • Tooltip displays 10.0% style in browser
  • Price column shows 0.3K–2.2K style labels; year shows 1.99K–2.02K; carat shows 0.2–0.68

🤖 Generated with Claude Code

…ntage display

- Add fmt_num/fmt_bucket helpers to histogram.py: SI prefix (K/M/B/T)
  for large values, step-based decimal precision (D3-style), no scientific
  notation. Use <> separator when the high bound is negative to avoid the
  ambiguous double-dash (-100--80).
- Apply fmt_bucket in xorq_stats_v2._numeric_histogram (was using .3g,
  producing 1.99e+03 for year ranges etc.). Also fixes cat_pop → population
  key so numeric histograms render as grey bars, not categorical pink.
- Apply fmt_bucket in histogram.py numeric_histogram_labels and tail labels
  (was using fixed {:.0f} which dropped all decimal places for floats).
- Fix tooltip percentage in HistogramCell.tsx: value is a 0-1 fraction,
  multiply by 100 and toFixed(1) before appending %. Was showing
  0.10008342602028921023% instead of 10.0%.
- Update test_xorq_stats_v2 assertions from cat_pop to population key.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

📦 TestPyPI package published

pip install --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==0.14.10.dev26770660679

or with uv:

uv pip install --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==0.14.10.dev26770660679

MCP server for Claude Code

claude mcp add buckaroo-table -- uvx --from "buckaroo[mcp]==0.14.10.dev26770660679" --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo-table

📖 Docs preview

🎨 Storybook preview

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a952fad694

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}}
>
<p className="label">{`${name} : ${payload[0].value}%`}</p>
<p className="label">{`${name} : ${(payload[0].value * 100).toFixed(1)}%`}</p>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid re-scaling percent histogram values

When the tooltip is shown for the normal pandas/polars histogram paths, population/cat_pop values are already emitted as percent values (for example numeric_histogram stores np.round(pop * 100, 0), and the JS fixtures use values like 29.0). Multiplying every Recharts value by 100 here fixes the new xorq 0–1 numeric output but regresses existing histograms by displaying values such as 2900.0% instead of 29%; either keep a consistent unit upstream or only scale the 0–1 xorq values.

Useful? React with 👍 / 👎.

The JS tooltip was multiplying all values by 100 to fix xorq's 0-1
fractions, which doubled the pandas/polars values (already 0-100) to
2900% etc. Move the *100 to the Python side so all backends emit the
same unit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@paddymul
Copy link
Copy Markdown
Collaborator Author

paddymul commented Jun 1, 2026

Addressed the Codex inline comment (discussion_r3335904009) in 254743d.

Root cause: pandas/polars already emit population as 0–100 (np.round(pop * 100, 0)), but the xorq path was emitting 0–1 fractions. The JS * 100 fixed xorq but doubled the pandas/polars values to e.g. 2900%.

Fix: moved the * 100 to the Python side in xorq_stats_v2._numeric_histogram so all backends emit the same 0–100 unit. The JS tooltip now just calls .toFixed(1) and appends % directly — no scaling.

@paddymul paddymul deployed to testpypi June 1, 2026 17:25 — with GitHub Actions Active
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.

1 participant