bumbeishvili / org-chart

Highly customizable org chart. Integrations available for Angular, React, Vue
https://stackblitz.com/edit/web-platform-o5t1ha
MIT License
915 stars 324 forks source link

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

Open Vivekptl25 opened 2 months ago

Vivekptl25 commented 2 months ago

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 commented 2 months ago

This library does not support that kind of layout

Vivekptl25 commented 2 months ago

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.