Drag Group Test v4
Randomly positioned rectangles with "Close" labels demonstrate how D3 v4's drag behavior applies to SVG group elements. Each group contains one rectangle and its text label, which move together during dragging. The example uses `d3.drag()` with `start`, `drag`, and `end` event handlers to update both child elements' `x` and `y` attributes. Data is generated with `d3.range()` and `Math.random()`, while `d3.scaleOrdinal` with `schemeCategory20` assigns colors. The code highlights the challenge of selecting parent `g` elements for unified drag interactions.
AI-generated descriptionThis is an example set up to test the use of the d3.drag component.
The intention is to learn enough about d3.drag to integrate it into a sankey diagram for v4 similar to this example.
The start point was Mikes circle dragging examlpe [here] which I tried to integrate with the object+text drag implimentation here.
Tragically I can't quite work out how to grab the 'g' element and will therefore use this block as an example for a question on Stack Overflow.
EDIT: Spoiler Alert: Solved by Dragon_Slayer. Solution bl.ock here.