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

Add mosaic plots #365

Open
domoritz opened this issue Apr 17, 2024 · 2 comments
Open

Add mosaic plots #365

domoritz opened this issue Apr 17, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@domoritz
Copy link
Member

domoritz commented Apr 17, 2024

Add https://en.m.wikipedia.org/wiki/Mosaic_plot to vgplot. Maybe we can do it already with bars or rectangles.

@jheer
Copy link
Member

jheer commented Apr 17, 2024

It does seem fitting that a project named "Mosaic" should support mosaic plots :)

The DB query for this is easy (count aggregation, potentially with additional aggregates that could be assigned to color or opacity). The mark could determine a chart size (if not pre-specified) and layout could be computed easily on the client side, resulting in Plot rect marks for which we set the x1, x2, y1, and y2 channels.

I think the trickier part of shoe-horning this into Plot is the axes/labeling. Different rows/columns will have different spatial partitions. We could generate a compound mark that includes custom axisX and and axisY marks where we explicitly set the ticks values to align with the adjacent partitions and then use a tickFormat function that inversely maps quantitative values to category labels. However, I don't think we can support nested axes/labels this way, as the fx and fy scales for facets are always band scales and so we can not use quantitative axes here. Maybe a better alternative might be to use custom text marks instead?

@jheer jheer added the enhancement New feature or request label Apr 17, 2024
@jaanli
Copy link

jaanli commented Apr 17, 2024

Aside +1 use case: this would be amazing! Would help me eliminate the slider from this demo: https://jaanli.github.io/american-community-survey/new-york-area/income-by-race

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants