Commit 85e50db
Polish validation (#311)
* Improve errorbar validation
* Move segment validation from writer to geom layer
- Mark pos1end as Required in segment geom
- Leverage bidirectional validation to enforce "at least one of xend or yend"
- Remove validation logic from SegmentRenderer, keep only transformation
- Add 4 validation tests in segment.rs
- Simplify SegmentRenderer to use entry().or_insert() pattern
The bidirectional validation checks for either:
- Identity: pos1, pos2, pos1end (x, y, xend)
- Flipped: pos1, pos2, pos2end (y, x, yend)
This effectively enforces "at least one endpoint required" without custom logic.
* Add validate_aesthetics hook and move rule validation to geom layer
- Add GeomTrait::validate_aesthetics() method for custom validation
- Mark pos1 as Required in rule geom
- Implement validate_aesthetics() for Rule to enforce XOR (exactly one of x or y)
- Call geom.validate_aesthetics() from Layer::validate_mapping()
- Remove validation logic from RuleRenderer, keep only diagonal rendering
- Add 3 validation tests in rule.rs
Architecture improvement:
- Geoms can now implement custom validation logic beyond Required/Null
- Rule's XOR constraint (pos1 XOR pos2) enforced at geom layer
- Writer only handles rendering, not validation
* Centralize aesthetic-to-encoding channel mapping in writer
Move pos*min/pos*max to x/y/x2/y2 transformation from individual renderers
to the central map_position_to_vegalite() function. This eliminates ad-hoc
transformations scattered across ErrorBarRenderer, RibbonRenderer, and
RectRenderer.
Convention: min → primary channel (x/y), max → secondary channel (x2/y2)
Changes:
- Update map_position_to_vegalite() to map pos*min/pos*max directly to
Vega-Lite encoding channels (x/y/x2/y2)
- Remove entire RibbonRenderer (now uses DefaultRenderer)
- Remove vestigial modify_encoding() from ErrorBarRenderer and RectRenderer
- Remove 2 redundant tests (test_errorbar_encoding_transformation,
test_rect_continuous_both_axes)
- Update rect tests to reflect upstream transformation
Result: 155 lines removed, cleaner separation between domain (aesthetics)
and presentation (encoding channels).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* rename 'rect' to 'tile' (fix #264)
* appease 1.95.0 clippy
* Make GeomRenderers position-agnostic via RenderContext channels
Add coord_kind to RenderContext with a pre-computed PositionChannels
tuple (pos1, pos1_end, pos1_offset, pos2, pos2_end, pos2_offset) that
resolves to Vega-Lite channel names based on coordinate system. Replaces
hardcoded "x"/"y"/"x2"/"y2" in 8 renderers (Bar, Path, Segment, Rule,
Tile, Violin, ErrorBar, Boxplot) so they work with both Cartesian and
polar coordinates.
Also moves RenderContext from layer.rs to encoding.rs where it belongs,
and adds &RenderContext to the finalize() trait method.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix rect -> tile leftover bug
* Fix horizontal errorbar support and global mapping merge for bidirectional geoms
Add ErrorBar to geom_has_implicit_orientation so the orientation system
correctly detects and flips horizontal errorbars. Fix global mapping merge
to accept flipped position counterparts (e.g., pos2 into a geom declaring
pos1) using flip_position, enabling global aesthetics like `species AS y`
to reach bidirectional geoms.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* cargo fmt
* sneak in small correction
* fix inconsistency
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 1307388 commit 85e50db
23 files changed
Lines changed: 522 additions & 598 deletions
File tree
- doc
- gallery/examples
- syntax/layer/type
- ggsql-vscode/syntaxes
- ggsql-wasm/demo/src/quarto
- src
- execute
- parser
- plot
- layer
- geom
- writer/vegalite
- tree-sitter-ggsql
- queries
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
335 | | - | |
| 335 | + | |
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
| |||
1079 | 1079 | | |
1080 | 1080 | | |
1081 | 1081 | | |
1082 | | - | |
| 1082 | + | |
1083 | 1083 | | |
1084 | 1084 | | |
1085 | 1085 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
Lines changed: 10 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | | - | |
| 337 | + | |
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
595 | 595 | | |
596 | 596 | | |
597 | 597 | | |
598 | | - | |
| 598 | + | |
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
186 | 189 | | |
187 | 190 | | |
188 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
189 | 196 | | |
190 | 197 | | |
191 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
623 | 623 | | |
624 | 624 | | |
625 | 625 | | |
626 | | - | |
| 626 | + | |
627 | 627 | | |
628 | 628 | | |
629 | 629 | | |
| |||
0 commit comments