networkD3 icon indicating copy to clipboard operation
networkD3 copied to clipboard

Keep legend fixed when zooming/panning

Open sirallen opened this issue 8 years ago • 3 comments

This is a wonderful package.

Currently the legend (legend = TRUE) moves around and scales with a forceNetwork when the user pans and zooms, which--I think it's fair to say--is not ideal. Would be better if the legend were fixed in the top left of the plot area.

sirallen avatar May 03 '17 20:05 sirallen

I think this is a reasonable suggestion, even if not as easy to implement as it may sound. Would anyone miss the old behavior? Not sure it would be worth the hassle supporting both?

Iirc, everything is put in an SVG group that can pan and zoom, so it might be as easy as putting the legend in a different group.

cjyetman avatar May 04 '17 21:05 cjyetman

Continuing to support the non-fixed-location behaviour does seem strange.

christophergandrud avatar May 05 '17 12:05 christophergandrud

Hey, so I took a look at the htmlwidget for forceNetwork. Looks like a very simple change; just

var legend = d3.select(el).select('svg').selectAll('.legend')...

sirallen avatar May 26 '17 03:05 sirallen