vasturiano / force-graph

Force-directed graph rendered on HTML5 canvas
https://vasturiano.github.io/force-graph/example/directional-links-particles/
MIT License
1.55k stars 246 forks source link

Change highlighted links' z-index #163

Open smartsl opened 3 years ago

smartsl commented 3 years ago

Is your feature request related to a problem? Please describe. When there are a lot of links, some highlighted ones (often from the same node, whose color is darker, line is wider, etc.) are behind others. I'm expecting a more proper highlighting effect. Those links i choose should on top of others.

Describe the solution you'd like In linkColor() or linkWidth() accessor functions, call link.top(), can make this link suppresses others' z-index.

Describe alternatives you've considered Or I can specify every links' z-index, and change them at any time.

Additional context Above is all.

leoncvlt commented 3 years ago

Tricky because on the canvas, object are drawn in order and that's what controls the depth.

You could keep track of the highlighted nodes' links, store them in an array, then skipping them in linkCanvasObject and drawing them in onRenderFramePost instead.

Alexithemia commented 3 years ago

The only way currently to change the way they draw on the canvas is to change the order they exist in the graphdata link array. But I am not sure if they would redraw automatically.