Conversation
- Add box_fn_args parameter to boxGrob() forwarding extra args to the box drawing function. Default is list(r = unit(5, 'pt')) giving every roundrectGrob box a fixed 5 pt corner radius regardless of size, fixing the issue where larger boxes had visibly rounder corners. Args unsupported by the box_fn (e.g. custom shapes) are silently dropped via formals() inspection so existing code is unaffected. Override per-box or globally via options(boxGrobFnArgs = list(...)). - Add equalizeHeights() mirroring equalizeWidths(). Sets selected boxes to a shared height (defaults to the tallest among the selection) and supports the same subelement path syntax. - Add tests: test-boxGrob-corner-radius.R, test-equalizeHeights.R - Add visual tests: tests/visual_tests/corner_box.R, equal_heights.R - Export equalizeHeights() in NAMESPACE - Update NEWS.md
Adds initial SVG reference snapshots for boxGrob and connectGrob visual regression tests so CI no longer fails with "Adding new file snapshot". Also upgrades actions/checkout from v3 to v4 to fix Node.js 20 deprecation warning (forced to Node.js 24 from June 16th 2026). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add `vertical_axis` and `horizontal_axis` connector types - Preserve source x/y axes and clamp target landing points to box boundaries - Document how axis connectors differ from `vertical` / `horizontal` - Add examples, NEWS entry, and vignette coverage - Add tests for axis connector geometry, errors, and list behavior
There was a problem hiding this comment.
Pull request overview
This PR extends Gmisc’s grid-based flowchart/box layout utilities by adding new connector behaviors, improving box rendering consistency (fixed corner radii), and expanding box-list ergonomics (regex-based subelement selection, new equalizeHeights(), and deferred position() references).
Changes:
- Added axis-preserving connector types (
vertical_axis,horizontal_axis) plus richersideconnector controls for flowcharts. - Introduced fixed-radius box corners via
box_fn_args(defaulting tor = unit(5, "pt")) and addedequalizeHeights()alongsideequalizeWidths(). - Implemented regex selectors for
subelementacross spread/align/move/equalize, plus a newposition()helper for relative moves; updated docs/examples/tests accordingly.
Reviewed changes
Copilot reviewed 34 out of 46 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| vignettes/Grid-based_flowcharts.Rmd | Updates vignette examples to showcase dotted return arrows, equalizeHeights(), and axis-preserving connectors; makes vignette date dynamic. |
| tests/visual_tests/equal_heights.R | Adds a visual script demonstrating equalizeHeights() behavior. |
| tests/visual_tests/corner_box.R | Adds a visual script demonstrating fixed corner radii via box_fn_args. |
| tests/testthat/test-subelement-regex.R | Adds unit tests for regex-based subelement selection (and mixed selector inputs). |
| tests/testthat/test-flowchart-issue76-connectors.R | Adds regression tests for grouped side return arrows, regex selectors in S3 pipeline calls, and position() usage. |
| tests/testthat/test-equalizeHeights.R | Adds unit tests for equalizeHeights() behavior and invariants (center preservation). |
| tests/testthat/test-connectGrob-axis-connectors.R | Adds tests covering new vertical_axis/horizontal_axis connector geometry and edge cases. |
| tests/testthat/test-boxGrob-corner-radius.R | Adds tests for box_fn_args forwarding and option-based defaults. |
| tests/testthat/_snaps/vdiffr/basic-box.svg | Updates vdiffr snapshot affected by box rendering changes. |
| R/boxGrobs_subelement_select.R | Adds prResolveSubelementSelector() to normalize literal/list/regex selectors into canonical paths. |
| R/boxGrobs_spread.R | Extends subelement handling to support regex selectors via prResolveSubelementSelector(). |
| R/boxGrobs_s3_spread.R | Fixes S3 spread wrapper argument construction so x is passed correctly in do.call(). |
| R/boxGrobs_s3_connect.R | Enhances S3 connect() to accept regex selectors and grouped fan-in behavior for type = "side". |
| R/boxGrobs_position.R | Introduces position() S3 generic and deferred position references for move-time resolution. |
| R/boxGrobs_move.R | Adds regex subelement support and resolves deferred position() references during moves. |
| R/boxGrobs_equalizeWidths.R | Extends equalizeWidths() selector handling and adds new exported equalizeHeights(). |
| R/boxGrobs_coords.R | Expands coords() documentation and references the new position() helper. |
| R/boxGrobs_connect.R | Adds new connector types, side-connector params, and type aliases; updates docs. |
| R/boxGrobs_connect_strategies.R | Wires new connector types and side-connector args through the strategy dispatch. |
| R/boxGrobs_connect_pr_single_boxes.R | Implements vertical_axis/horizontal_axis and enhances side connector entry/exit behavior. |
| R/boxGrobs_connect_pr_helpers.R | Adds helper functions for clamping/projection and overlap detection for axis connectors. |
| R/boxGrobs_boxGrob.R | Adds box_fn_args (default fixed radius) and filters forwarded args based on the shape function signature. |
| R/boxGrobs_align.R | Extends subelement handling to support regex selectors via prResolveSubelementSelector(). |
| NEWS.md | Documents the new connectors, box_fn_args, equalizeHeights(), regex selectors, dotted arrows, and position(). |
| NAMESPACE | Exports equalizeHeights() and position() and registers position.* S3 methods. |
| man/spread.Rd | Documents regex selector support for subelement; links to new helpers. |
| man/position.Rd | Adds generated Rd documentation for the new position() generic/methods. |
| man/phaseLabel.Rd | Updates “See also” links to include new helpers. |
| man/moveBox.Rd | Documents regex selector support for subelement and links to new helpers. |
| man/move.Rd | Updates “See also” links to include new helpers. |
| man/insert.Rd | Updates “See also” links to include new helpers. |
| man/flowchart.Rd | Updates “See also” links to include new helpers. |
| man/equalizeWidths.Rd | Documents regex selector support for subelement; links to new helpers. |
| man/equalizeHeights.Rd | Adds generated Rd documentation for equalizeHeights(). |
| man/distance.Rd | Updates “See also” links to include new helpers. |
| man/coords.Rd | Expands coords documentation and links to position()/equalizeHeights(). |
| man/connect.Rd | Documents new connector types and new side arguments; expands examples. |
| man/boxShapes.Rd | Updates “See also” links to include new helpers. |
| man/boxPropGrob.Rd | Updates “See also” links to include new helpers. |
| man/boxHeaderGrob.Rd | Updates “See also” links to include new helpers. |
| man/box.Rd | Documents box_fn_args and updates “See also” links. |
| man/append.Rd | Updates “See also” links to include new helpers. |
| man/align.Rd | Documents regex selector support for subelement; updates “See also” links. |
| inst/examples/connectGrob_example.R | Adds example pages demonstrating vertical_axis/horizontal_axis behavior. |
| .Rbuildignore | Ignores generated README.html and Rplots.pdf. |
| .github/workflows/ci.yaml | Updates CI to use actions/checkout@v4. |
Files not reviewed (11)
- man/align.Rd: Generated file
- man/append.Rd: Generated file
- man/box.Rd: Generated file
- man/boxHeaderGrob.Rd: Generated file
- man/boxPropGrob.Rd: Generated file
- man/boxShapes.Rd: Generated file
- man/connect.Rd: Generated file
- man/coords.Rd: Generated file
- man/distance.Rd: Generated file
- man/equalizeHeights.Rd: Generated file
- man/equalizeWidths.Rd: Generated file
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 pull request introduces several new features and improvements to the flowchart and box layout system, with a focus on enhancing connector flexibility, box appearance consistency, and box selection ergonomics. The most significant changes include new axis-aligned connector types, a new way to set fixed corner radii for boxes, a new function for equalizing box heights, and improved subelement selection using regex. There are also updates to the documentation and CI configuration.
Flowchart connectors and box alignment improvements:
"vertical_axis"and"horizontal_axis"connector types toconnectGrob(), enabling strict axis-aligned connectors that preserve the source box's x- or y-axis and project it onto the target boundary, ensuring true 90-degree arrows between vertically or horizontally separated boxes. Helper functionsprClampUnit,prSpansOverlap,prVerticalAxisEdges, andprHorizontalAxisEdgeswere added to support this logic. (NEWS.md,R/boxGrobs_connect.R,R/boxGrobs_connect_pr_helpers.R,R/boxGrobs_connect_pr_single_boxes.R) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]"side"connectors withend_side,side_fan_in_route, andside_fan_in_offsetarguments for more control over entry/exit sides and routing of grouped connectors. (R/boxGrobs_connect.R,R/boxGrobs_connect_pr_single_boxes.R) [1] [2] [3] [4] [5] [6] [7]Box appearance and sizing:
box_fn_argsparameter toboxGrob(), defaulting to a fixed 5 pt corner radius for all boxes, ensuring consistent appearance regardless of box size. This can be overridden per box or globally. The implementation filters arguments to match the box function's accepted parameters. (NEWS.md,R/boxGrobs_boxGrob.R) [1] [2] [3] [4] [5]equalizeHeights()for box lists, mirroring the existingequalizeWidths()function, to set selected boxes to a shared height. Exported in the namespace. (NEWS.md,NAMESPACE) [1] [2]Box list selection and alignment:
subelementargument of alignment functions, allowing more flexible and expressive selection of boxes within lists for alignment operations. (R/boxGrobs_align.R) [1] [2] [3]Other updates:
position()S3 generic and methods for boxes and coordinates, and updated the.Rbuildignorefile and CI workflow to use the latestactions/checkout@v4. (NAMESPACE,.Rbuildignore,.github/workflows/ci.yaml) [1] [2] [3] [4]