fix: chart time-axis rendering, auto-detection, and MCP ergonomic fixes#39
Merged
Merged
Conversation
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.
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
x_as_category: trueto opt out.x_as_category=true; the chart peeks at the first row and activates categorical mode automatically.validate_output_pathnow callscreate_dir_allbefore canonicalizing, so users don't need to pre-create/tmp/charts/etc..with_ansi(false)prevents raw[0mnoise on Windows.Changed files
hyperdb-mcp/src/chart.rshyperdb-mcp/src/attach.rsvalidate_output_pathcreates parent dirshyperdb-mcp/src/main.rs.with_ansi(false)on stderr layershyperdb-mcp/src/server.rshyperdb-mcp/src/readme.rshyperdb-mcp/tests/chart_tests.rshyperdb-mcp/CHANGELOG.mdhyperdb-mcp/README.md.github/workflows/release-please.ymlREADME.mdTest plan
cargo clippy --workspace --tests -- -D warningscleancargo test -p hyperdb-mcp— all 37 integration + 26 unit chart tests pass/tmp/new-dir/out.pngauto-creates the directory