Conversation
src/marks/arrow.js
Outdated
| this.sweep == null | ||
| ? 1 | ||
| : this.sweep === "order-x" | ||
| ? descending(x1, x2) |
There was a problem hiding this comment.
This will return 0 when x1 == x2, which will result in a bend angle of 0 below, which I don’t think is correct?
There was a problem hiding this comment.
The use case I had in mind for order-x is when y is constant; in that case this test would be for links of length 0, and bending can be 0.
However I hadn't really given much thought to the fact that y can be variable. In that case, I don't really know what the user intent might be by specifying order-x (instead of order, which always “bends” unless the link has length 0). The current code, which makes a straight line when the order is a tie on x, doesn't look wrong and might even be useful (?):
Plot.arrow([-2, -1, 0, 1, 2], {
x1: Plot.identity,
x2: (d) => d * 1.1,
y1: 0,
y2: 1,
sweep: "order-x",
bend: -20
}).plot()
There was a problem hiding this comment.
I think it’s okay if you document it.
|
If you merge #1741, this looks good to me. (I also thought about renaming the tests to group the arc diagrams together, instead of making the dataset the primary aspect of the test name… but I’m not sure it matters. The test names should articulate what they are trying to achieve, and I think “arc diagram” is sufficient here. Though “arcs” would also suffice.) |
* functional sweep * ±[xy]
Co-authored-by: Mike Bostock <[email protected]>
* arrow sweep option; note that I also removed the arrow head if headLength is zero. * miserables.json * miserables arc diagram * the arrow head and insets computations depend on the flipped bend angle * darker initializer * functional sweep (#1741) * ±[xy] --------- Co-authored-by: Mike Bostock <[email protected]>
* arrow sweep option; note that I also removed the arrow head if headLength is zero. * miserables.json * miserables arc diagram * the arrow head and insets computations depend on the flipped bend angle * darker initializer * functional sweep (observablehq#1741) * ±[xy] --------- Co-authored-by: Mike Bostock <[email protected]>

Introduces the new sweep option for the arrow mark, that allows to ensure that all arrows bulge in the same direction.
Also ensures that no arrowhead is drawn if headLength = 0 (as indicated in the comment in src/marks/arrow).
TODO:
closes #1739