d3 / d3-force

Force-directed graph layout using velocity Verlet integration.
https://d3js.org/d3-force
ISC License
1.82k stars 377 forks source link

Update beeswarm link #154

Closed 1wheel closed 4 years ago

1wheel commented 4 years ago

changed the link to original gist; the observable redirect doesn't use d3.force

curran commented 4 years ago

Thank you @1wheel this is great! I can't tell you how many times I've wanted to find this original beeswarm, only to be redirected to something totally different. +1 for this change!

mbostock commented 4 years ago

It was an intentional decision to not use the force layout for the beeswarm plot. A force layout compromises the meaningful position of the dot (x in the linked example) to avoid collision. The new algorithm does not; it guarantees an exact position based on data and only adjusts the free dimension (y) to avoid collision. (That said, the new algorithm could still be optimized. See also d3-beeswarm.)

I could remove the beeswarm example from the README, but if people are looking to make a beeswarm plot, I think it’s better to point them to the right algorithm (even if it’s not d3-force), rather than continuing to advocate an approach that produces misleading visualizations.

Secondly, you’re serving my examples on your bl.ocks.org clone and not respecting my intent to redirect to the new examples on Observable that I actively maintain. I could take down my gists from GitHub to avoid this, but then the old source would not be accessible. I’d prefer for the source to still be accessible on GitHub for those that seek it actively, but I don’t want my old examples to be served live, as I’d rather direct people to my new examples that are actively maintained and up-to-date. Can I ask you to respect the redirect in the .block configuration if present?

1wheel commented 4 years ago

The dodge method is so tentacle-ly! I'm usually willing to give up a little accuracy for compactness.

Wasn't aware of the redirect property until now (I'd assumed that list was hard coded server side). Would you be okay with a banner linking to the new example?

I'm also happy to redirect /mbostock/* to observablehq.com if you'd prefer. I cloned bl.ocks.org because I missed using it as a sketchpad; I didn't intend to rudely rehost anything.

mbostock commented 4 years ago

My preference is to redirect to the specific link in the .block file, if present. A top-level redirect is too general: you’d have to then search again on Observable to re-find the example you were looking for, and I’ve already gone to the trouble to specify the exact mapping in the .block file.

As for the tentacles 🐙, I believe the dodge algorithm could be improved to produce a better layout. (It’s possible to have vertical gaps.) I’d welcome contributions! And I know that the performance could be improved, too. And probably it could be extended to have some tolerance if you want to sacrifice accuracy for aesthetics.

But I still think recommending the force layout for beeswarms is dangerous, especially because when it gives no visible indication of inaccuracy. So unless you know the gotcha, you will probably be unaware, and that inaccuracy will extend to your readers.

1wheel commented 4 years ago

Added a redirect: https://blocks.roadtolarissa.com/mbostock/6526445e2b44303eebf21da3b6627320

I'm not totally convinced there are many use cases for a dodge beeswarm over snapping to a grid and drawing a histogram, but I'll think on it. I guess it avoids misrepresentations from bucketing?

mbostock commented 4 years ago

Thanks, Adam! Much appreciated.

If the histogram draws each bucket as a single bar, then the beeswarm is still nice for showing points separately, allowing for more detailed interaction or additional encodings such as color. But a beeswarm snapped to a grid could be considered a histogram, too. Or you could just use a regular histogram.

Another thing to mention is that the dodge algorithm is highly sensitive to input order. The tentacles are most pronounced when the input is sorted along x (the position encoding). If you shuffle the input first, you often get better results. The dodge algorithm could often produce a more compact, organic layout if it didn’t try to preserve order. (Though sometimes you want to preserve order…)