Open
Conversation
Introduce RenderContext struct to pass scale information to renderers during layer preparation. This allows renderers to access resolved scale properties (such as input ranges/extents) when preparing data or building encoding/spec modifications. Changes: - Add RenderContext struct with scales field and helper methods: - new() - constructor - find_scale() - lookup scale by aesthetic name - get_extent() - extract numeric min/max from continuous scales - Update GeomRenderer trait signatures to accept RenderContext: - prepare_data() now takes context parameter - modify_encoding() now takes context parameter - modify_spec() now takes context parameter - Update all existing renderer implementations for new signatures (BarRenderer, PathRenderer, SegmentRenderer, RibbonRenderer, AreaRenderer, PolygonRenderer, ViolinRenderer, BoxplotRenderer) - Update call sites in mod.rs to create and pass context - Add unit test for RenderContext::get_extent() with 4 test cases Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add ABLineRenderer that draws lines based on slope and intercept parameters using a clipping-based approach: - Uses global x-axis extent from scales (not per-panel) - Creates calculate transforms for x_min, x_max, y_min, y_max - Relies on Vega-Lite clipping for faceted plots - Uses rule mark for independent line segments - Removes slope/intercept from encoding (used in transforms only) Key implementation details: - modify_spec(): Creates transforms for constant x extent and computed y values based on slope * x + intercept - modify_encoding(): Removes slope/intercept, adds x/x2/y/y2 encodings using x_min/x_max/y_min/y_max fields - geom_to_mark(): Uses "rule" mark for AbLine - get_renderer(): Dispatches AbLine to ABLineRenderer Naming convention: x_min, x_max, y_min, y_max (consistent underscores) Grammar update: Add 'slope' and 'intercept' as valid aesthetic names for ABLine geom support. Includes integration test with 3 lines of different slopes, verifying transforms, encodings, and stroke encoding for color. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
thomasp85
reviewed
Feb 27, 2026
Collaborator
thomasp85
left a comment
There was a problem hiding this comment.
A few general comments. I think it would be good to merge in the coord/project and handle conflicts in the layer PRs rather than the other way around so I'll give it another round when that is done
Collaborator
Author
|
A cute thing we could do once we get more serious about aggregations is to let hline/vline/rule have settings like |
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.
This PR advances #139.
Briefly, it adds segment, abline, hline and vline layers.
Most changes are straightforward.
The tricky bit was the abline layer, which required knowledge of the scale's x-limits to compute y. This is now captured in a
RendererContextstruct that carries a reference to the scales.Some examples are still a bit wonky because lines are repeated for every row in the data, but we can revisit these once #115 is implemented.