Articles in this section
Category / Section

How to create a family tree structure in Blazor Diagram?

2 mins read

In Blazor Diagram, you can create a family tree structure and auto-arrange nodes using automatic layouts. The Complex Hierarchical Tree layout organizes nodes in a tree-like manner where a child node can have multiple parents, extending the traditional hierarchical tree layout.

Please refer to the following code example for creating a family tree structure with DataSource in Complex Hierarchical Layout

Code Snippet:


//Specifies a complex hierarchical tree layout
<Layout Type="LayoutType.ComplexHierarchicalTree" LinearArrangement="true" @bind-HorizontalSpacing="@HorizontalSpacing" @bind-VerticalSpacing="@VerticalSpacing">
 </Layout>
 
//Defines a collection of objects representing a complex hierarchical structure
public object DataSource = new List<object>()
   {
       new ComplexHierarchical() { Id= "1",RelationShip="Dad",ImagePath="/diagram/images/people-circle26.png" },
       new ComplexHierarchical() { Id= "2",RelationShip="Mom",ImagePath="/diagram/images/people-circle0.png"},
       new ComplexHierarchical() { Id= "3",RelationShip="Brother",ImagePath="/diagram/images/people-circle23.png", ReportingPerson=new List<string>() {"1","2" }},
       new ComplexHierarchical() { Id= "4",RelationShip="SisterInLaw",ImagePath="/diagram/images/people-circle21.png",ReportingPerson=new List<string>() {"1","2" }},
       new ComplexHierarchical() { Id= "5",RelationShip="Sister",ImagePath="/diagram/images/people-circle16.png", ReportingPerson=new List<string>() {"1","2" }},
       new ComplexHierarchical() { Id= "6",RelationShip="BrotherInLaw",ImagePath="/diagram/images/people-circle33.png",ReportingPerson=new List<string>() {"1","2" }},
       new ComplexHierarchical() { Id= "7",RelationShip="Sister",ImagePath="/diagram/images/people-circle11.png", ReportingPerson=new List<string>() {"1","2" }},
       new ComplexHierarchical() { Id= "8",RelationShip="BrotherInLaw",ImagePath="/diagram/images/people-circle31.png", ReportingPerson=new List<string>() {"1","2" }},
       new ComplexHierarchical() { Id= "9",RelationShip="Sister",ImagePath="/diagram/images/people-circle1.png", ReportingPerson=new List<string>() {"1","2" }},
       new ComplexHierarchical() { Id= "10",RelationShip="Nephew",ImagePath="/diagram/images/people-circle4.png", ReportingPerson=new List<string>() {"3","4" }},
       new ComplexHierarchical() { Id= "11",RelationShip="Niece",ImagePath="/diagram/images/people-circle4.png", ReportingPerson=new List<string>() {"5","6" }},
       new ComplexHierarchical() { Id= "12",RelationShip="Niece",ImagePath="/diagram/images/people-circle4.png", ReportingPerson=new List<string>() {"7","8" }},
   };

Screenshot:

FamilyStructure.png

You can download the complete working sample from here.

Conclusion

I hope you enjoyed learning about how to create a family tree structure in Blazor Diagram.

You can refer to our Blazor Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Blazor Diagram example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied