Skip to content

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 minimal, since this customization is 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
@cloudflare-workers-and-pages
Copy link

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

Deploying vega-lite with  Cloudflare Pages  Cloudflare Pages

Latest commit: dd36450
Status: ✅  Deploy successful!
Preview URL: https://93a330b1.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

if (!hasSameDimensionAndStackedField && (isPolar ? dimensionChannel === fieldChannel || encoding['color'] : true)) {
// 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
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.

@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 in the cartesian case, the stack transform did not get created when compiled to Vega (this is because Rect is not supported in the STACKABLE_MARKS constant).

Whereas in the polar case, the stack transform gets created, but has a groupBy of value .

@hydrosquall hydrosquall force-pushed the cameron.yick/fix-compile-pie-stack branch from d8b3ab4 to c5eae62 Compare May 1, 2025 13:40
@hydrosquall
Copy link
Member Author

I’ve been thinking more about why the polarCoordinates check was needed in this PR (and revisiting the grammar of graphics book) as I have tried a few variations on trying to get the intended behavior without checking for polar coordinates, and I noticed something that makes me feel more OK about having a special condition for polar.

  • We write that arc is analogous to rect
  • However, rect does not support stacking (even if forced), only bar does! (according to STACKABLE_MARKS)
  • Therefore, arc is more like bar than rect . If we want arc to have attributes of both rect and bar, we are going to have to add special logic for it in more places given that in cartesian coordinates, we aren't treating rect and bar the same way when it comes to stacking.

If we want stacking to be supported by arc that doesn’t have to care about whether we are in cartesian or polar, we have the choices of

  • Allow stacking to be forced in rect too (currently not supported)
  • Leave rect alone, and just allow forcing stacking via arc (as I do in the current PR) or
  • Introduce a new mark (radial_bar?) which is to arc as bar is to rect . We leave the current arc behavior alone, and we only give the new behavior of enabling force stacking to radial_bar.
  • Something else?

@domoritz
Copy link
Member

domoritz commented Jul 3, 2025

@kanitw @hydrosquall what's left here to merge this?

@hydrosquall
Copy link
Member Author

hydrosquall commented Jul 3, 2025 via email

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

4 participants