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

Arrow sweep strategy #1739

Closed
Fil opened this issue Jul 8, 2023 · 2 comments · Fixed by #1740
Closed

Arrow sweep strategy #1739

Fil opened this issue Jul 8, 2023 · 2 comments · Fixed by #1740
Labels
enhancement New feature or request

Comments

@Fil
Copy link
Contributor

Fil commented Jul 8, 2023

To make an arc diagram such as https://observablehq.com/@d3/arc-diagram, I want to use the arrow mark with a bend angle of 90°, to draw the half-circles connecting a source to a target in the graph.

However currently this always draws the arc in a “clockwise”[1] manner from the first point (x1, y1) to the second point (x2, y2), which means that in most cases the arrow will go either to the left or to the right, depending on whether y1 > y2.

[1] clockwise, becomes counter-clockwise when bend is < 0.

Visually, what I get is the image on the left; what I want is the image on the right:
Capture d’écran 2023-07-08 à 16 30 37

To reach this goal, I can:

  1. check how the source and target are ordered in the y domain, and reverse them as needed. This implies that the channels now depend on the scale (not good);
  2. draw both source-target and target-source arrows, and clip them to the frame—provided the main axis is the left edge of the frame (also not very good);
  3. write a render transform that reverses the sweep-flag on the generated path (it works, but… 😵‍💫).

PR #1740 introduces a new option sweep that allows to control this at render time.

@Fil Fil added the enhancement New feature or request label Jul 8, 2023
@mbostock
Copy link
Member

mbostock commented Jul 8, 2023

Could this be done as an initializer that swaps the source and target based on the y position?

Could this be done as an option on the arrow mark that computes the sweep flag based on the y position of the source and target? (And similarly for the x position?)

Again, I don’t think we want to use a render transform here. The render transform is the “big hammer” that we probably only want to use for animation and interaction.

@Fil Fil mentioned this issue Jul 8, 2023
4 tasks
@Fil
Copy link
Contributor Author

Fil commented Jul 8, 2023

#1740 adds a sweep option on the arrow mark to control the "sweep order", and flip the sweep flag as necessary.

@Fil Fil closed this as completed in #1740 Jul 9, 2023
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

Successfully merging a pull request may close this issue.

2 participants