Skip to content

fix: chart time-axis rendering, auto-detection, and MCP ergonomic fixes#39

Merged
StefanSteiner merged 7 commits into
tableau:mainfrom
StefanSteiner:ssteiner/cleanup
May 26, 2026
Merged

fix: chart time-axis rendering, auto-detection, and MCP ergonomic fixes#39
StefanSteiner merged 7 commits into
tableau:mainfrom
StefanSteiner:ssteiner/cleanup

Conversation

@StefanSteiner
Copy link
Copy Markdown
Contributor

Summary

  • Proportional time axis — Line/scatter charts now auto-detect DATE/TIMESTAMP/TIMESTAMPTZ x columns and render with real wall-clock spacing instead of even categorical ticks. Pass x_as_category: true to opt out.
  • Auto-detect categorical x — Non-numeric x values (DATE, TEXT, etc.) no longer require manually setting x_as_category=true; the chart peeks at the first row and activates categorical mode automatically.
  • Label shortening & tick thinning — Strips shared timezone suffixes, computes a target tick count from chart width and label size to prevent overlap. Fixes a regression where a 90-point hourly series could render with only 1 visible x-axis label.
  • Auto-create output directoriesvalidate_output_path now calls create_dir_all before canonicalizing, so users don't need to pre-create /tmp/charts/ etc.
  • Disable ANSI on stderr — MCP stdio transport stderr goes to log panes that don't render escape codes; .with_ansi(false) prevents raw [0m noise on Windows.
  • README stability note — Adds pre-1.0 vibe-engineering disclaimer.
  • Re-enable release-please — CI workflow re-enabled targeting v0.2.0.

Changed files

File What
hyperdb-mcp/src/chart.rs Proportional time axis, XMode enum, temporal parsing/formatting, tick-count budget, label shortening refactor
hyperdb-mcp/src/attach.rs validate_output_path creates parent dirs
hyperdb-mcp/src/main.rs .with_ansi(false) on stderr layers
hyperdb-mcp/src/server.rs Chart tool description improvements
hyperdb-mcp/src/readme.rs LLM-facing docs for time-axis auto-detect
hyperdb-mcp/tests/chart_tests.rs 17 new tests (16 unit + 1 integration)
hyperdb-mcp/CHANGELOG.md Two Fixed entries under [Unreleased]
hyperdb-mcp/README.md Stability note
.github/workflows/release-please.yml Re-enabled for v0.2.0
README.md Updated for v0.2.0

Test plan

  • cargo clippy --workspace --tests -- -D warnings clean
  • cargo test -p hyperdb-mcp — all 37 integration + 26 unit chart tests pass
  • Manual verification: line chart with TIMESTAMPTZ x renders proportional spacing, >=3 visible tick labels at 800px width
  • Manual verification: chart to /tmp/new-dir/out.png auto-creates the directory
  • Manual verification: stderr on Windows shows no raw ANSI sequences

StefanSteiner and others added 6 commits May 25, 2026 23:44
MCP servers communicate over stdio; their stderr goes to a client log
pane (e.g. Claude Code output panel) that doesn't render ANSI codes.
On Windows this produced raw escape sequences like [2m...[0m. Force
plain text on both the daemon and MCP stderr layers.

Also adds a pre-1.0 stability note to the README.
validate_output_path previously rejected paths whose parent directory
didn't exist. Now it creates the directory tree (create_dir_all) before
canonicalizing, so users don't need to pre-create output directories.

Also improves chart tool description to guide LLMs on:
- Long-format data requirement (one numeric y, use series for grouping)
- x_as_category=true requirement for DATE/TIMESTAMP x-axes
- UNION ALL reshaping for wide-format data
Line and scatter charts now peek at the first row's x value — if it's
not numeric (DATE, TIMESTAMP, TEXT, etc.), categorical mode activates
automatically. This eliminates the need to manually set
x_as_category=true for date-based time series.

The explicit x_as_category parameter still works as an override.
Categorical axis labels now go through a shortening pass:
1. Strip shared timezone offset (+00:00) when all labels end with it
2. Auto-thin: blank intermediate labels when they'd overlap based on
   estimated character width vs chart pixel width

This prevents label collision on charts with 12+ TIMESTAMPTZ ticks at
800px width. First and last labels are always preserved.
…fix tick thinning

Line and scatter charts now auto-detect DATE / TIMESTAMP / TIMESTAMPTZ
x columns and render with a proportional time axis: real wall-clock
gaps between data points are reflected on the chart's x-axis instead
of being flattened to even spacing. Tick labels are formatted via
chrono to match the input kind (%Y-%m-%d, %Y-%m-%d %H:%M:%S, or
%Y-%m-%d %H:%M:%S%:z), with the originating offset captured from the
first row preserved for TIMESTAMPTZ. Pass x_as_category: true to opt
out and force the previous categorical layout; TEXT x columns
continue to render categorically.

Also fixes a tick-label thinning regression in the categorical path.
The old shorten_labels blanked individual labels at non-step indices,
but plotters picks its own tick positions on the float axis and
rounds them to integer indices, so almost none of the chosen ticks
landed on a kept index - a 90-point hourly TIMESTAMP series at any
chart width rendered with only ONE visible x-axis label. The chart
layer now computes a target tick count from chart width and label
size, then passes it to plotters via .x_labels(N); every drawn tick
carries a real label.

Refactors:
- shorten_labels split into strip_shared_tz_suffix (cosmetic +HH:MM
  compaction) and auto_tick_count (no-overlap budget for plotters).
- group_series x_as_category: bool -> x_mode: XMode enum (Numeric /
  Categorical / Temporal(TemporalKind)).
- New parse_temporal, format_temporal_tick, detect_line_x_mode,
  tick_count_for_label_width helpers.

Tests: 16 new unit tests for the helpers (parse, format, detect,
tick math, NaN safety, offset capture); 1 new integration test
(line_chart_long_timestamp_series_renders_multiple_visible_labels)
asserts >=3 visible date labels in the rendered SVG, locking in the
regression fix. Total: 26 unit, 37 integration, all green; clippy
--all-targets -D warnings clean.

Docs: chart tool description in server.rs and LLM-facing readme.rs
updated to document the new auto-detect behavior; CHANGELOG.md
[Unreleased] gains two ### Fixed entries.
@salesforce-cla
Copy link
Copy Markdown

Thanks for the contribution! Unfortunately we can't verify the commit author(s): Stefan Steiner <s***@s***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, refresh the status of this Pull Request.

@StefanSteiner StefanSteiner merged commit e6d14d3 into tableau:main May 26, 2026
8 of 10 checks passed
@StefanSteiner StefanSteiner mentioned this pull request May 26, 2026
@StefanSteiner StefanSteiner mentioned this pull request May 27, 2026
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