# Flat/Tabular Data FlexDiagram

## Content

**<span id="2e8f41b1-5e27-4e45-b8f4-78786dd732d6" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="2e8f41b1-5e27-4e45-b8f4-78786dd732d6" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Data-bound diagrams</span>**<span id="2e8f41b1-5e27-4e45-b8f4-78786dd732d6" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="2e8f41b1-5e27-4e45-b8f4-78786dd732d6" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation"> that use flat or tabular data allow </span>**<span id="2e8f41b1-5e27-4e45-b8f4-78786dd732d6" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="2e8f41b1-5e27-4e45-b8f4-78786dd732d6" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">FlexDiagram</span>**<span id="2e8f41b1-5e27-4e45-b8f4-78786dd732d6" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="2e8f41b1-5e27-4e45-b8f4-78786dd732d6" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation"> to create hierarchical diagrams from database tables or spreadsheet data. Each column represents a hierarchy level, and FlexDiagram automatically interprets these relationships.</span>
<span id="2e8f41b1-5e27-4e45-b8f4-78786dd732d6" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="2e8f41b1-5e27-4e45-b8f4-78786dd732d6" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">This method is useful for visualizing structured tabular data in a hierarchical and intuitive format.</span>
![](https://cdn.mescius.io/document-site-files/images/cf228eb8-1f57-4b26-8cf2-edbf0f1f38ee/tabular%20data.6bff0a.png?width=600)

### **Create Flat/Tabular Data FlexDiagram**

1. <span id="686bd74e-3c82-4ea2-a864-7569757f99ee" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="686bd74e-3c82-4ea2-a864-7569757f99ee" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Create a data table.</span>

```csharp
DataTable table = new DataTable();
table.Columns.Add("Field");
table.Columns.Add("Domain");
table.Columns.Add("Specialty");
table.Columns.Add("Skill");
```

2. <span id="7cc6c97f-ba42-4ce6-8ac6-13537446c08b" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="7cc6c97f-ba42-4ce6-8ac6-13537446c08b" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Bind the table to the diagram.</span>

```csharp
diagram.DataSource = table;
diagram.Binding = "Field,Domain,Specialty,Skill";
```

#### **Flat/Tabular <span id="0af5ac8e-983f-467e-83d4-f6f657c2d7c9" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="0af5ac8e-983f-467e-83d4-f6f657c2d7c9" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">FlexDiagram Sample</span>**

```csharp
using C1.Diagram;
using C1.Win.Diagram;
using System.Data;

namespace FlexDiagramPoC
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            InitializeDiagram();
        }

        private void InitializeDiagram()
        {
            // Create FlexDiagram instance
            var diagram = new FlexDiagram();
            diagram.Dock = DockStyle.Fill;
            this.Controls.Add(diagram);

            // Configure data binding
            // Get data table
            var table = CreateSkillsTable();

            // Set diagram data source
            diagram.DataSource = table;

            // Specify names of columns
            // 1st level, 2nd level, 3rd level, Node text
            diagram.Binding = "Field,Domain,Specialty,Skill";
            diagram.Direction = DiagramDirection.LeftRight;
        }

        DataTable CreateSkillsTable()
        {
            DataTable skillsTable = new DataTable("SkillsHierarchy");

            // Define columns in hierarchical order
            skillsTable.Columns.Add("Field", typeof(string));
            skillsTable.Columns.Add("Domain", typeof(string));
            skillsTable.Columns.Add("Specialty", typeof(string));
            skillsTable.Columns.Add("Skill", typeof(string));

            // Add data rows
            skillsTable.Rows.Add("Field", "Domain", "Specialty", "Skill");
            skillsTable.Rows.Add("Technology", "Frontend", "JavaScript Frameworks", "React Development");
            skillsTable.Rows.Add("Technology", "Data Science", "Artificial Intelligence", "Machine Learning");
            skillsTable.Rows.Add("Technology", "Database", "Query Performance", "SQL Optimization");
            skillsTable.Rows.Add("Technology", "Backend", "Programming Languages", "Python Programming");
            skillsTable.Rows.Add("Technology", "Infrastructure", "AWS Solutions", "Cloud Architecture");

            return skillsTable;
        }
    }
}
```