How to select the entire stacking series segment in Blazor Chart?
This KB article explains how to select the entire stacking series segment in the Blazor Chart Component.
Selecting entire stacking series in Blazor Chart
It has been achieved by setting the SelectionMode to Cluster. You can select entire stacking series segment in Blazor Chart by using this Cluster selection mode.
You can style the selection series by using the SelectionStyle property in ChartSeries, which accepts a CSS class for customization.
The following code example illustrates this.
Index.razor
@using Syncfusion.Blazor.Charts
<SfChart SelectionMode="SelectionMode.Cluster">
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category"></ChartPrimaryXAxis>
<ChartSeriesCollection>
<ChartSeries DataSource="@MedalDetails" XName="X" YName="YValue" Type="ChartSeriesType.StackingColumn" SelectionStyle="chartSelection">
</ChartSeries>
<ChartSeries DataSource="@MedalDetails" XName="X" YName="YValue1" Type="ChartSeriesType.StackingColumn" SelectionStyle="chartSelection">
</ChartSeries>
</ChartSeriesCollection>
</SfChart>
<style>
.chartSelection {
fill: red
}
</style>
@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},
};
}
The following screenshot illustrates the output of the above code snippet.
Output:
| Before Selection | After Selection |
|---|---|
Conclusion
I hope you enjoyed learning how to select the entire stacking series segment in Blazor Chart Component.
You can refer to our Blazor Chart 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 Chart 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, support portal, or feedback portal. We are always happy to assist you!