Skip to content

fix issue #252, support subgroup aesthetic in geom_polygon for holes#320

Open
Nishita-shah1 wants to merge 2 commits intoanimint:masterfrom
Nishita-shah1:fix/252-polygon-holes-subgroup
Open

fix issue #252, support subgroup aesthetic in geom_polygon for holes#320
Nishita-shah1 wants to merge 2 commits intoanimint:masterfrom
Nishita-shah1:fix/252-polygon-holes-subgroup

Conversation

@Nishita-shah1
Copy link
Copy Markdown

Fixes #252

Problem

animint2 rendered isoband hole polygons as two separate filled shapes
instead of one polygon with a transparent hole. The subgroup aesthetic
(added to ggplot2 in 2019) was completely unknown to animint2's compiler
and renderer.

Real-world use case: Hi-C genomic cluster contour visualization where
holes in contour polygons are scientifically meaningful.

After (fix)

Screenshot 2026-04-04 200117 Screenshot 2026-04-04 200133

Solution

Three-layer fix across the full pipeline:

R/geom-polygon.r - added subgroup = NULL to default_aes so
GeomPolygon accepts the aesthetic.

R/geom-.r -- when subgroup is present in polygon data:

  • sets g$data_has_subgroup <- TRUE (serialized into plot.json)
  • converts subgroup to character so it survives TSV write
  • adds it to g$types so JS type converter keeps it as string

inst/htmljs/animint.js - when data_has_subgroup is true, uses
d3.geo.path().projection(null) with GeoJSON Polygon format instead
of d3.svg.line(). GeoJSON coordinates map directly to subgroup
structure: [outerRing, holeRing1, ...]. SVG fill-rule: evenodd
ensures hole rings appear transparent.

Tests

17 tests, 0 failures covering:

  • compiler: subgroup in TSV, data_has_subgroup in plot.json,
    no flag without subgroup
  • renderer: SVG path used, multiple M commands in d attribute,
    evenodd fill-rule applied
  • interactive: clickID and path checks for all 3 polygon cases
    (hole_and_mid, only_hole, no_hole) as specified in the issue
Screenshot 2026-04-04 201101

@tdhock @suhaani-agarwal @Faye-yufan could you please review this, thank you! Fixes #252

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.

draw polygon / path with holes

1 participant