Skip to content
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

d3-org-chart if children are more than 5 then display next line/row. #431

Open
Vivekptl25 opened this issue Aug 30, 2024 · 2 comments
Open

Comments

@Vivekptl25
Copy link

Hi, I am using d3-org-chart library in my react project. I have 18 children under parent node and I want to split the children as 5 per row. I have tried multiple times but it is not working.

I tried using layoutBinding property but it is not rendering the chart itself.
.layoutBinding(function(d: any) {
// Custom layout logic
const childrenPerRow = 4; // Number of children per row
if (d.children) {
d.children.forEach((child, index) => {
const row = Math.floor(index / childrenPerRow);
const col = index % childrenPerRow;
child.x = d.x + col * 100; // Adjust x position
child.y = d.y + row * 100; // Adjust y position
});
}
return d;
})

onNodeClick it is not applying the new coordinates to chart.
chart.onNodeClick(function(d) {
const childrenPerRow = 4; // Set the number of children per row
if (d.children && d.children.length > childrenPerRow) {
d.children.forEach((child, index) => {
const row = Math.floor(index / childrenPerRow);
const col = index % childrenPerRow;
child.x = d.x + col * 100; // Adjust x position
child.y = d.y + row * 100; // Adjust y position
});
chart.update(d);
}
});

Attached the image for your reference.
OrgchartNodeIssue

@bumbeishvili
Copy link
Owner

This library does not support that kind of layout

@Vivekptl25
Copy link
Author

Vivekptl25 commented Aug 30, 2024

Thank @bumbeishvili for your response. Do you have any alternative suggestions for handling such scenarios? Appreciate your help on this because it is kind of show stopper for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants