fix issue #252, support subgroup aesthetic in geom_polygon for holes#320
Open
Nishita-shah1 wants to merge 2 commits intoanimint:masterfrom
Open
fix issue #252, support subgroup aesthetic in geom_polygon for holes#320Nishita-shah1 wants to merge 2 commits intoanimint:masterfrom
Nishita-shah1 wants to merge 2 commits intoanimint:masterfrom
Conversation
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.
Fixes #252
Problem
animint2 rendered isoband hole polygons as two separate filled shapes
instead of one polygon with a transparent hole. The
subgroupaesthetic(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)
Solution
Three-layer fix across the full pipeline:
R/geom-polygon.r - added
subgroup = NULLtodefault_aessoGeomPolygon accepts the aesthetic.
R/geom-.r -- when
subgroupis present in polygon data:g$data_has_subgroup <- TRUE(serialized into plot.json)g$typesso JS type converter keeps it as stringinst/htmljs/animint.js - when
data_has_subgroupis true, usesd3.geo.path().projection(null)with GeoJSON Polygon format insteadof
d3.svg.line(). GeoJSON coordinates map directly to subgroupstructure:
[outerRing, holeRing1, ...]. SVGfill-rule: evenoddensures hole rings appear transparent.
Tests
17 tests, 0 failures covering:
no flag without subgroup
evenodd fill-rule applied
(hole_and_mid, only_hole, no_hole) as specified in the issue
@tdhock @suhaani-agarwal @Faye-yufan could you please review this, thank you! Fixes #252