fix(render): adapt axis ticks to available plot space - #2
Merged
Conversation
Centralize axis tick and margin calculation across screen, SVG, and EMF renderers. Thin labels according to the final plot rectangle, account for categorical and East Asian text widths, and drop ticks gracefully when the available space is insufficient. Keep canvas interaction geometry aligned with rendering, escape categorical labels in SVG output, and document the adaptive behavior in English and Simplified Chinese.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Axis tick counts were previously fixed at eight for x and five for y,
regardless of the final plot dimensions. Because PlotX uses absolute
publication-sized typography, shrinking a plot could cause adjacent tick
labels to overlap.
This change introduces a shared, size-aware axis layout used by the screen,
SVG, and EMF renderers. Tick density is derived from the final plot rectangle
after margins, projection bands, and aspect-ratio locking are applied.
Key changes:
dedicated render module.
AxisLayout, which computes margins and x/y tick sets together for therequested output dimensions.
assuming the requested target equals the resulting tick count.
the axis line.
layouts in page units.
editing so rendered and interactive plot rectangles stay aligned.
preventing later stride choices from increasing margins and invalidating
label-fit checks.
combining, and other Unicode characters.
Margins::for_figure.The intentionally conservative categorical first pass may reserve space for a
long category that is not ultimately labeled. This tradeoff ensures the final
plot rectangle never becomes smaller than the rectangle used to validate tick
spacing.
Validation
cargo test -p plotx-render— 48 tests passedcargo pr-check— all 7 checks passed, including:npm run buildfromdocs/— passedgit diff --check— passedRegression coverage includes: