Skip to content

facet: false to prevent a mark from being faceted? #291

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

Closed
mbostock opened this issue Mar 31, 2021 · 3 comments
Closed

facet: false to prevent a mark from being faceted? #291

mbostock opened this issue Mar 31, 2021 · 3 comments
Labels
question Further information is needed

Comments

@mbostock
Copy link
Member

mbostock commented Mar 31, 2021

Currently we rely on the equality operator to determine whether to facet marks:

const markFacets = mark.data === this.data ? facetsIndex : undefined;

I wonder if in addition to this equality check, we could provide a generic facet option, which if set to false would disable faceting for the mark. (I don’t think you’d be able to set it to true if the data is different that the facet, but maybe that would be okay if it has the same cardinality?)

In other words, instead of

Plot.dot(penguins.slice(), {
  x: "culmen_depth_mm",
  y: "culmen_length_mm",
  r: 2,
  fill: "#ddd"
})

you’d say

Plot.dot(penguins, {
  facet: false,
  x: "culmen_depth_mm",
  y: "culmen_length_mm",
  r: 2,
  fill: "#ddd"
})

(Though, the former would still work…)

@mbostock mbostock added the question Further information is needed label Mar 31, 2021
@Fil
Copy link
Contributor

Fil commented Apr 1, 2021

The current API is nice in its simplicity, but it's not completely satisfying. For instance, it would be very useful to have a way to facet multiple sources—joining them in a single data array then filtering them again as I did in the SPLOM example is a bit "heavy".

@Fil
Copy link
Contributor

Fil commented Apr 9, 2021

(I don’t think you’d be able to set it to true if the data is different that the facet, but maybe that would be okay if it has the same cardinality?)

That would be the most pressing use-case for me, but it's true we can't guarantee that it won't surprise people if they do, for example, some kind of filtering on the data and receive an error instead of what the intuition says (^^).

I'd also like to pass the facet's value in the marks' render.

^^: intuition says that if I have facet {data: data} and Plot.mark(data.filter(filter), {facet: true…}), then Plot should somehow magically use indexOf to facet the mark. But that might be too prone to errors, and too slow.

@mbostock
Copy link
Member Author

Fixed in #450.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is needed
Projects
None yet
Development

No branches or pull requests

2 participants