You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi i want to change the x position of some nodes after chart render, i need to execute that after chart render because a calculate the nex position according to the old position of the node an another node
this is my function
function change_node_position(staticNodeId, changedNodeId, index) {
// After rendering, manually adjust the position of the two specific nodes
const staticNode = d3.select(`[data-nodeId="${staticNodeId}"]`); // Replace `node_id_1` with the actual node ID or class
const changedNode = d3.select(`[data-nodeId="${changedNodeId}"]`); // Replace `node_id_2` with the actual node ID or classc
if (staticNode.node() == null || changedNode.node() == null) {
return false;
}
// Get current positions (x and y) of the two nodes
const staticNodeCord = extract_cord(staticNode.attr('transform'))
const changedNodeCord = extract_cord(changedNode.attr('transform'))
// Adjust the margin by changing the x position of the second node
const customMargin = (treeConfiguration.nodeWidthSpouse + 25) + ((treeConfiguration.nodeWidth + 25) * (index - 1)) ; // Set a custom margin between these two nodes
changedNode.attr('transform', `translate(${staticNodeCord.x + customMargin}, ${changedNodeCord.y})`); // Adjust x position only
const newnode1cord = extract_cord(changedNode.attr('transform'))
/////////////////
const path = d3.select(`[data-from="${staticNodeId}"][data-to="${changedNodeId}"]`);
path.attr("d", update_path_position(path.attr("d"), newnode1cord.x));
}
i execute my function after chart.render(), but nothing happen, but when i execute the funtion when i click on a button its position nodes perfectly
The text was updated successfully, but these errors were encountered:
Hi i want to change the x position of some nodes after chart render, i need to execute that after chart render because a calculate the nex position according to the old position of the node an another node
this is my function
i execute my function after chart.render(), but nothing happen, but when i execute the funtion when i click on a button its position nodes perfectly
The text was updated successfully, but these errors were encountered: