Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Arc mark does not stack for quantitative definitions when different fields are used for theta and radius [draft] #9512

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

hydrosquall
Copy link
Member

@hydrosquall hydrosquall commented Jan 20, 2025

Motivation

Changes

  • Do not include groupBy field when the dimension field is using a quantitative scale. This ensures that stacking is applied correctly.
  • I've made this change only impact polar coordinate channels to keep the impact radius minimal since this customization may be specific to the arc mark.
  • Try the VL Spec from the original bug report

Testing

  • API design: does this approach make sense for how stacks should apply for arc marks?
  • See unit test suite : Let me know if additional cases should be added to either the image snapshots or the unit test suite.
  • Compare with similar cartesian plot

@hydrosquall hydrosquall changed the title [draft] [draft] Radial chart does not render as expected when different fields are used for theta and radius Jan 20, 2025
@hydrosquall hydrosquall changed the title [draft] Radial chart does not render as expected when different fields are used for theta and radius fix: Radial chart does not render as expected when different fields are used for theta and radius [draft] Jan 20, 2025
@hydrosquall hydrosquall force-pushed the cameron.yick/fix-compile-pie-stack branch 2 times, most recently from 0b7380a to 7f6ed6d Compare January 20, 2025 16:15
Copy link

cloudflare-workers-and-pages bot commented Jan 20, 2025

Deploying vega-lite with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2ebd1b1
Status: ✅  Deploy successful!
Preview URL: https://f81c430e.vega-lite.pages.dev
Branch Preview URL: https://cameron-yick-fix-compile-pie.vega-lite.pages.dev

View logs

@hydrosquall hydrosquall force-pushed the cameron.yick/fix-compile-pie-stack branch from 7f6ed6d to 3b1d979 Compare January 20, 2025 16:16
@hydrosquall hydrosquall changed the title fix: Radial chart does not render as expected when different fields are used for theta and radius [draft] fix: Radial mark does not render as expected when different fields used for theta and radius [draft] Jan 20, 2025
src/stack.ts Outdated
// avoid grouping by the stacked field
// TKTK: find out why
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this works here, we may need a similar change for the code block under dimensionOffsetChannel .

src/stack.ts Outdated
@@ -182,7 +182,7 @@ export function stack(m: Mark | MarkDef, encoding: Encoding<string>): StackPrope
// TBD: we should only enter this branch if there's also a "color" and maybe a group channel?
const isPolar = isPolarPositionChannel(fieldChannel) || isPolarPositionChannel(dimensionChannel);

if (!hasSameDimensionAndStackedField && (isPolar ? dimensionChannel === fieldChannel || encoding['color'] : true)) {
if (!hasSameDimensionAndStackedField && (isPolar ? dimensionChannel === fieldChannel : true)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before I removed the color encoding check, the graph rendered like this:

image

@hydrosquall hydrosquall force-pushed the cameron.yick/fix-compile-pie-stack branch 5 times, most recently from 89b647c to 369fa1e Compare January 26, 2025 02:31
@hydrosquall hydrosquall changed the title fix: Radial mark does not render as expected when different fields used for theta and radius [draft] fix: Radial mark does not stack for quantitative definitions when different fields are used for theta and radius [draft] Jan 26, 2025
@hydrosquall hydrosquall changed the title fix: Radial mark does not stack for quantitative definitions when different fields are used for theta and radius [draft] fix: Arc mark does not stack for quantitative definitions when different fields are used for theta and radius [draft] Jan 26, 2025
@hydrosquall hydrosquall force-pushed the cameron.yick/fix-compile-pie-stack branch from a21fed9 to 905e53c Compare January 26, 2025 02:55
@hydrosquall hydrosquall marked this pull request as ready for review January 26, 2025 03:23
@hydrosquall hydrosquall requested a review from a team as a code owner January 26, 2025 03:23
@hydrosquall hydrosquall force-pushed the cameron.yick/fix-compile-pie-stack branch from 905e53c to 6d37199 Compare January 30, 2025 05:02
const isPolar = isPolarPositionChannel(fieldChannel) || isPolarPositionChannel(dimensionChannel);
const shouldAddPolarGroupBy = !isUnbinnedQuantitative(dimensionDef);

if (isPolar ? shouldAddPolarGroupBy : !hasSameDimensionAndStackedField) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we really need isPolar ? shouldAddPolarGroupBy : clause? If we strictly check the field above, would that be sufficient?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By strictly check, do you mean we'd check if dimensionDef and stackedFieldDef have the same

  • field (the current check)
  • bin
  • aggregator
  • timeUnit

for both polar and cartesian graphs?

Currently if I just remove the isPolar ? shouldAddPolarGroupBy clause and use the existing check, we'd introduce this bug

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a PoC commit to see if this is what you had in mind

8b010a6

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'd introduce this bug

can't find this link

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it interesting to see how many of the visual tests break if I removed the check that only applies this change to polar encodings.

#9557

Copy link
Member

@kanitw kanitw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I think the test and regression case look good, but I wonder if the condition added can be more precise/simpler.

Verified

This commit was signed with the committer’s verified signature.
hydrosquall Cameron Yick
…el and stackChannel are same

Verified

This commit was signed with the committer’s verified signature.
hydrosquall Cameron Yick
…hannels are matching
hydrosquall and others added 4 commits March 2, 2025 20:13

Verified

This commit was signed with the committer’s verified signature.
hydrosquall Cameron Yick

Verified

This commit was signed with the committer’s verified signature.
hydrosquall Cameron Yick

Verified

This commit was signed with the committer’s verified signature.
hydrosquall Cameron Yick

Verified

This commit was signed with the committer’s verified signature.
hydrosquall Cameron Yick
@hydrosquall hydrosquall force-pushed the cameron.yick/fix-compile-pie-stack branch from ca62a23 to 2ebd1b1 Compare March 3, 2025 01:13
@hydrosquall
Copy link
Member Author

hydrosquall commented Mar 6, 2025

Shrinking the example down to see if how the issue looks in both coordinate systems on current prod editor (not this branch)

  • cartesian version of the “bug” (having a common x1) here (pic 1)
  • polar version of the bug (having a common theta1) here (pic 2)
Cartesian Polar
image image

Note that in the cartesian case, the stack transform did not get created at all when compiled to Vega (this is because Rect is not supported as a stackable mark?). Whereas in the polar case, the stack transform gets created, but has a groupBy assigned to value just like in the arc case.

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.

Radial chart radius field unexpectedly changes arc stack behavior
2 participants