Search results

100% Stacked Column in Blazor Chart component

08 Apr 2021 / 2 minutes to read

100% Stacked

Shows the relative percentage of multiple data series in stacked columns. The cumulative proportion of each stacked column always totals 100%. To render a 100% stacked column series, use series Type as StackingColumn100.

stackedcolumn100.razor
Copied to clipboard
@using Syncfusion.Blazor.Charts

<SfChart>
    <ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category"/>
    <ChartSeriesCollection>
        <ChartSeries DataSource="@MedalDetails" XName="X" YName="YValue" Type="ChartSeriesType.StackingColumn100">
        </ChartSeries>
        <ChartSeries DataSource="@MedalDetails" XName="X" YName="YValue1" Type="ChartSeriesType.StackingColumn100">
        </ChartSeries>
    </ChartSeriesCollection>
</SfChart>

@code{
    public class ChartData
    {
        public string X { get; set; }
        public double YValue { get; set; }
        public double YValue1 { get; set; }
    }
    public List<ChartData> MedalDetails = new List<ChartData>
{
        new ChartData { X= "USA", YValue= 46, YValue1=56 },
        new ChartData { X= "GBR", YValue= 27, YValue1=17 },
        new ChartData { X= "CHN", YValue= 26, YValue1=36 },
        new ChartData { X= "UK", YValue= 56,  YValue1=16 },
        new ChartData { X= "AUS", YValue= 12, YValue1=46 },
        new ChartData { X= "IND", YValue= 26, YValue1=16 },
        new ChartData { X= "DEN", YValue= 26, YValue1=12 },
        new ChartData { X= "MEX", YValue= 34, YValue1=32},
    };
}

100% Stacked Column

Note: You can also explore our Blazor 100% Stacked Column Chart Example to knows how to render and configure the 100% stacking column type chart.

Stacking Group

You can use the StackingGroup property to group the stacked columns and 100% stacked columns. Columns with same group name are stacked on top of each other.

group.razor
Copied to clipboard
@using Syncfusion.Blazor.Charts

<SfChart>
    <ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category"></ChartPrimaryXAxis>

    <ChartSeriesCollection>
        <ChartSeries DataSource="@DataSource" StackingGroup="Asia" XName="X" YName="YValue" Type="ChartSeriesType.StackingColumn">
        </ChartSeries>
        <ChartSeries DataSource="@DataSource" StackingGroup="Asia" XName="X" YName="YValue" Type="ChartSeriesType.StackingColumn">
        </ChartSeries>
        <ChartSeries DataSource="@DataSource" StackingGroup="Europe" XName="X" YName="YValue1" Type="ChartSeriesType.StackingColumn">
        </ChartSeries>
    </ChartSeriesCollection>
</SfChart>
@code{
    public class ChartData
    {
        public string X { get; set; }
        public double YValue { get; set; }
        public double YValue1 { get; set; }
    }

    public List<ChartData> DataSource = new List<ChartData>
{
        new ChartData { X= "USA", YValue= 46, YValue1=56 },
        new ChartData { X= "GBR", YValue= 27, YValue1=17 },
        new ChartData { X= "CHN", YValue= 26, YValue1=36 },
        new ChartData { X= "UK", YValue= 56,  YValue1=16 },
        new ChartData { X= "AUS", YValue= 12, YValue1=46 },
        new ChartData { X= "IND", YValue= 26, YValue1=16 },
        new ChartData { X= "DEN", YValue= 26, YValue1=12 },
        new ChartData { X= "MEX", YValue= 34, YValue1=32},
    };
}

Customization

You can use the following properties to customize the 100% stacked column series.

  • Fill – used to change the color of the 100% stacked column.
  • Opacity – used to control the transparency of the chart series.
  • DashArray – used to render 100% stacked column series with dashes.
  • Border – used to render 100% stacked column with border.
Copied to clipboard
@using Syncfusion.Blazor.Charts

<SfChart>
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category"></ChartPrimaryXAxis>

<ChartSeriesCollection>
    <ChartSeries DataSource="@DataSource" StackingGroup="Asia" XName="X" DashArray="5,5" Fill="red" Opacity="0.7" YName="YValue" Type="ChartSeriesType.StackingColumn100">
    </ChartSeries>
    <ChartSeries DataSource="@DataSource" StackingGroup="Asia" XName="X" DashArray="5,5" Fill="blue" Opacity="0.7" YName="YValue" Type="ChartSeriesType.StackingColumn100">
    </ChartSeries>
</ChartSeriesCollection>
</SfChart>
@code{
public class ChartData
{
    public string X { get; set; }
    public double YValue { get; set; }
    public double YValue1 { get; set; }
}

public List<ChartData> DataSource = new List<ChartData>
{
    new ChartData { X= "USA", YValue= 46, YValue1=56 },
    new ChartData { X= "GBR", YValue= 27, YValue1=17 },
    new ChartData { X= "CHN", YValue= 26, YValue1=36 },
    new ChartData { X= "UK", YValue= 56,  YValue1=16 },
    new ChartData { X= "AUS", YValue= 12, YValue1=46 },
    new ChartData { X= "IND", YValue= 26, YValue1=16 },
    new ChartData { X= "DEN", YValue= 26, YValue1=12 },
    new ChartData { X= "MEX", YValue= 34, YValue1=32},
};
}

Custom 100% Stacked Column

Note: You can refer to our Blazor Charts feature tour page for its groundbreaking feature representations. You can also explore our Blazor Chart example to knows various chart types and how to represent time-dependent data, showing trends in data at equal intervals.

See Also