-
-
Notifications
You must be signed in to change notification settings - Fork 336
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
Drag and Drop for changing parent-child relationship #155
Comments
No, it does not currently support it, but it’s planned for the future |
Any update on when this will be available? |
I don't expect it to be implemented in the near future (at least for the next 4-6 months) |
Any Updates? |
@A7medMo7ammed20 there is a potential partnership opportunity for paying for the implementation of drag-drop functionality. So there is a chance (20-30%) that it might get implemented within the next 3 months |
@bumbeishvili I am able to contribute to this effort. |
Until they get this feature in place.. I am doing this.. You still have to handle hiding the children and the edges. But this is the beginning of getting a node to drag I do this right after I call chart.render() const state = this.chart.getChartState();
let dragStartX: number;
let dragStartY: number;
let newParent: GenNodeData | null;
const nodesSelection = state['nodesWrapper']
.selectAll('g.node')
.on('mouseover', (d: Event, n: GenNodeData) => {
newParent = n;
})
.on('mouseout', (d: Event, n: GenNodeData) => {
newParent = null;
})
.call(
d3
.drag()
.on('start', (d) => {
const width = d.subject.width;
const half = width / 2;
const x = d.x - half;
dragStartX = x;
dragStartY = parseFloat(d.y);
})
.on('drag', function (d) {
const g = d3.select(this);
dragStartX += parseFloat(d.dx);
dragStartY += parseFloat(d.dy);
g.attr('transform', 'translate(' + dragStartX + ',' + dragStartY + ')');
})
.on('end', (d) => {
console.log({ newParent });
})
); |
There is a #307 PR if you want to have a look and make it work. The work I plan to do with Drag & drop is not quick and it's quite substantial, so won't merge or add anything related to this meantime |
Here is my drag example.. I copied what I could from our production app. This has undo/redo/cancel built into it. I made a button to start the drag process.. otherwise there are all kinds of issues when trying to pan while dragging is enabled. @bumbeishvili Feel free to fork this and add it to the examples |
Nice, I'd implement it differently but good to have it implemented anyway |
What would you do differently I would love to know as we are using this in production |
First I am very much impressed that you implemented drag & drop without modifying source code (and I am also proud too because it's possible) • I'd try to overcome the need to have a drag functionality dependent on the button (and it's not an easy )
• I'd make it possible to drop over the node once it touches another node That said, again, your implementation is quite good since it is done without modifying anything in the core codebase and in theory will not interfere with future updates and in a way it's safe solution |
I need to implement the same thing in another interface in our app..
I could probably do (50% - nodeMargin)
|
Hi,
Does the current plugin support drag-and-drop feature where i could drag a node and drop it on another node and dragged node becomes the child?
I am looking for some pointers if this is already explored.
Thanks,
Chethan
The text was updated successfully, but these errors were encountered: