Skip to content

Bring composite-legend system and weather docs to main#395

Open
jurjoroa wants to merge 8 commits into
mainfrom
Dev
Open

Bring composite-legend system and weather docs to main#395
jurjoroa wants to merge 8 commits into
mainfrom
Dev

Conversation

@jurjoroa

Copy link
Copy Markdown
Owner

Summary

Promotes the #393 composite-legend work from Dev to main: the opinionated
legend_composite() wrapper on top of the legend_canvas() primitives, the
default-centering fix, a width-agnostic base_width generalization, locked PNG
render snapshots, and the reworked pkgdown "Icon Legends" article. DESCRIPTION
stays at 1.8.0 on both sides - no version bump.

What changed

  • R/legend-canvas.R:
    • The composite-legend engine (legend_canvas, legend_box, legend_composite, legend_ratios).
    • Adds legend_composite() (one-call grid/group/symbol + fitted legend_box() border) and base_width scaling for identical proportions at any output width.
    • Centres legend_canvas() by default via a symmetric x_margin + align arg, and warns (ggpop_swatch_aspect_warning) when a small content_range stretches swatches into banners.
  • R/key_legend.R, R/legend-strip.R, R/marker_legend.R:
    • Supporting key/strip/marker helpers the composite path builds on.
    • Refinements to key dispatch, strip stacking, and marker layout to feed legend_composite().
  • DESCRIPTION, NAMESPACE, NEWS.md, _pkgdown.yml, man/*.Rd:
    • Package metadata, exports, changelog, and reference docs.
    • Exports legend_box/legend_composite/legend_ratios, adds their .Rd topics + pkgdown entries, records the changes in NEWS.md.
  • tests/testthat/test-13/15/16/17.R + _snaps/*.png:
    • Coverage for the new layout functions plus locked render snapshots.
    • Adds the gold-standard allmodels-frontier-compact-legend.png and strip composites, base-width scaling, enclosure, and swatch-aspect warning tests.
  • vignettes/articles/marker-legend.qmd:
    • The pkgdown "Icon Legends" article.
    • Documents legend_composite() and retopics Figures 4-6 to an 8-day weather forecast driven by Font Awesome icons and one shared df_legend.
  • CHANGELOG.md:
    • Legacy changelog present on main, absent on Dev.
    • Merging this PR removes it; the package now tracks changes in NEWS.md.

Notes

Merging removes CHANGELOG.md (81 lines) from main - Dev consolidated on
NEWS.md. Confirm that is intended before merging. This PR is create-only; the
merge and any release steps are deliberately left for a separate pass.


Project: ggpop Date: 15-July-2026 9:29 PM PT
Branch: Dev -> Base: main
Issue: #393 | Version: #381

jurjoroa added 8 commits July 13, 2026 19:45
Project: ggpop Date: 13-July-2026 7:45 PM PT
Branch: 393-center-legend-canvas
Version: #381

R/legend-canvas.R:
Core composite-legend builder plus legend_box/legend_ratios helpers.
Adds base_width scaling (sizes scale by width/base_width so any width reproduces the calibrated proportions), auto-encloses group/symbol blocks taller than the grid, and warns when a small content_range stretches swatches into banners.
Lets the template generalize to any figure width and topic without warping.

R/key_legend.R:
Renders group/symbol key entries.
label_fontface now flows to titles and entry labels.
Keeps composite legends visually consistent.

R/marker_legend.R:
Builds the icon grid section.
Title now honors label_fontface instead of hardcoded plain.

R/legend-strip.R:
Stacks a legend under a plot.
Handles patchwork mains via patchworkGrob so every panel renders.

DESCRIPTION:
Package metadata.
Adds patchwork to Suggests for the legend-strip patchwork path.

NAMESPACE:
Generated exports.
Exposes legend_box, legend_composite, legend_ratios.
Project: ggpop Date: 13-July-2026 7:45 PM PT
Branch: 393-center-legend-canvas
Version: #381

tests/testthat/test-15_legend-canvas.R:
Tests for the composite-legend builder.
Adds base_width scaling, auto-enclosure, swatch-aspect warning coverage, and a deterministic geometry snapshot of the AllModels compact legend as the gold standard; repairs the text_labels helper and a bind_rows case.
Fails if the reference legend layout ever drifts.

tests/testthat/_snaps/15_legend-canvas.md:
Recorded gold-standard geometry for the AllModels legend.
Portable (coordinates and sizes, not pixels) so it is stable across machines.

tests/testthat/test-16_key-legend.R:
key_legend tests.
Accounts for the label layer rendered alongside each key entry.

tests/testthat/test-17_legend-strip.R:
legend_strip tests.
Compares plot structure instead of brittle identical() on whole ggplots.

tests/testthat/test-13_marker-legend.R:
marker_legend tests.
Aligned with the label_fontface title change.
Project: ggpop Date: 13-July-2026 7:46 PM PT
Branch: 393-center-legend-canvas
Version: #381

NEWS.md:
User-facing changelog.
Adds bullets for base_width scaling, the section auto-enclosure, and the swatch-aspect warning.

man/legend_composite.Rd, man/legend_canvas.Rd, man/legend_box.Rd, man/legend_ratios.Rd, man/key_legend.Rd, man/legend_strip.Rd:
Regenerated roxygen docs.
Cover base_width, the ylim auto-enclosure, and the swatch-aspect warning.

_pkgdown.yml:
Reference index.
Lists legend_box, legend_composite, legend_ratios under Legends and icons.
Project: ggpop Date: 13-July-2026 8:36 PM PT
Branch: 393-center-legend-canvas
Version: #381

tests/testthat/test-15_legend-canvas.R:
Gold-standard test for the AllModels compact legend.
Switches it from a geometry value snapshot to a rendered PNG image snapshot, matching the repo convention (test-12/13/17); drops the now-unused geometry helper.
Locks the reference legend the same way as the other renders.

tests/testthat/_snaps/15_legend-canvas/allmodels-frontier-compact-legend.png:
Recorded golden of the AllModels compact legend (Modality tiles, age grid, frontier symbols, fitted border).

tests/testthat/_snaps/15_legend-canvas/legend-canvas-composite.png:
Recorded golden for the existing legend_canvas composite render test.
Project: ggpop Date: 13-July-2026 10:40 PM PT
Branch: 393-center-legend-canvas
Version: #381

tests/testthat/_snaps/17_legend-strip/legend-strip-composite.png:
Recorded golden for the legend_strip composite render test.
The test had no committed golden, so it recorded and never compared.
Committing it makes the test lock the render like the other snapshots.

tests/testthat/_snaps/17_legend-strip/legend-strip-simcrc-style.png:
Recorded golden for the SimCRC-style legend_strip render test.
Same reason - no golden meant no real comparison ran.
Locks the grouped icon-scatter plus composite legend strip.
Project: ggpop Date: 14-July-2026 7:23 AM PT
Branch: 393-center-legend-canvas
Version: #381

vignettes/articles/marker-legend.qmd:
The Icon Legends article on the pkgdown (GitHub Pages) site.
Adds a legend_composite() section - the one-call bordered composite legend, base_width width-scaling, the keep-compact-do-not-stretch guidance plus the swatch-aspect warning, and the Font Awesome + custom SVG icon mix.
Puts the new composite-legend capabilities on the documentation site.
Project: ggpop Date: 14-July-2026 5:12 PM PT
Branch: 393-center-legend-canvas
Version: #381

vignettes/articles/marker-legend.qmd:
The pkgdown "Icon Legends" article documenting legend_canvas/legend_composite/legend_strip.
The composite-legend figures used bundled SVG markers on a delivery topic; requested Font Awesome icons and a new topic.
Retopics Figures 4-6 to an 8-day weather forecast (sun/cloud-rain/wind/snowflake) driven by one shared df_legend; compact symbol labels keep the bordered composite from clipping right-edge text.
Add legend_composite wrapper and center legend_canvas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant