FlexChart for WinForms
カテゴリ別の軸グループ化
FlexChart > FlexChart の操作 > FlexChart の要素 > FlexChart の軸ラベル > 軸のグループ化 > カテゴリ別の軸グループ化

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. Moreover, FlexChart 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.

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";
            // データソースとグループ名を設定します
            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();
        
            // 系列を追加します
            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);            // 位置をAutoに設定します
            flexChart1.DataLabel.Position = LabelPosition.Auto;  
        }
    }