ComponentOne FlexChart for WinForms
Categorical Axis Grouping
FlexChart > Working with FlexChart > FlexChart Elements > Axis Labels > Axis Grouping > Categorical Axis Grouping

Categorical axis grouping is applicable in scenarios where the data displayed on the axis is categorical in nature. Categorical data can either be flat or hierarchical. In case you are using flat data, use the GroupNames property to apply axis grouping. And, in case you are using hierarchical data, use the GroupNames and GroupItemsPath property to apply axis grouping. FlexChart also allows you to set the group separator using the GroupSeparator property.

As FlexChart grouping is possible at different hierarchical levels, the control also allows you to expand or collapse these groups. This can be implemented using the GroupVisibilityLevel property which takes an integer value.

The following image shows how FlexChart appears after setting the categorical axis grouping using flat data.

Axis Grouping

Add the following code in Form1.cs file.

Partial Public Class Form1
    Inherits Form
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        flexChart1.BindingX = "Country"
        flexChart1.ToolTip.Content = "{x}" & vbCr & "{seriesName}" & vbCr & "{y}"
        flexChart1.Header.Content = "World GDP Ranking"
        flexChart1.DataSource = CountryGDP.Countries()
        flexChart1.AxisX.GroupNames = "Continent"
        flexChart1.AxisX.GroupSeparator = AxisGroupSeparator.Grid
        flexChart1.AxisX.GroupVisibilityLevel = -2
        flexChart1.AxisY.Title = "GDP (billion USD)"
        flexChart1.ChartType = ChartType.Column
        flexChart1.Series.Clear()
        Dim serCP As Series = New Series()
        serCP.Binding = "CurrentPrices"
        serCP.Name = "GDP, current prices"
        flexChart1.Series.Add(serCP)
        Dim serPPP As Series = New Series()
        serPPP.Binding = "PPPValuation"
        serPPP.Name = "GDP based on PPP valuation"
        flexChart1.Series.Add(serPPP)
        flexChart1.DataLabel.Position = LabelPosition.Auto
    End Sub
End Class
public partial class Form1 : Form
    {
        private void Form1_Load(object sender, EventArgs e)
        {
            flexChart1.BindingX = "Country";
            flexChart1.ToolTip.Content = "{x}\r{seriesName}\r{y}";
            flexChart1.Header.Content = "World GDP Ranking";
            // Set the data source and group names
            flexChart1.DataSource = CountryGDP.Countries();
            flexChart1.AxisX.GroupNames = "Continent";
            flexChart1.AxisX.GroupSeparator = AxisGroupSeparator.Grid;
            flexChart1.AxisX.GroupVisibilityLevel = -2;
        
            //Set the chart type and axis title
            flexChart1.AxisY.Title = "GDP (billion USD)";
            flexChart1.ChartType = ChartType.Column;
            flexChart1.Series.Clear();
        
            // Add series
            Series serCP = new Series();
            serCP.Binding = "CurrentPrices";
            serCP.Name = "GDP, current prices";
            flexChart1.Series.Add(serCP);

            Series serPPP = new Series();
            serPPP.Binding = "PPPValuation";
            serPPP.Name = "GDP based on PPP valuation";
            flexChart1.Series.Add(serPPP);            // Set position to auto
            flexChart1.DataLabel.Position = LabelPosition.Auto;  
        }
    }