How to hide zero datalabel in pie using Blazor Charts?
This article explains how to hide the zero datalabels in the pie chart.
Hiding zero datalabel in pie chart
Blazor Charts provides an option to hide the zero datalabel value using ShowZero property in DataLabel.
This can be achieved by specifying ShowZero property of AccumulationDataLabelSettings as false. This will prevent data labels with a value of zero from being displayed.
The below code example demonstrates how to hide zero datalabel.
Index.razor
@using Syncfusion.Blazor.Charts
<SfAccumulationChart Title="Mobile Browser Statistics">
<AccumulationChartSeriesCollection>
<AccumulationChartSeries DataSource="@StatisticsDetails" XName="Browser" YName="Users"
Name="Browser">
<AccumulationDataLabelSettings Visible="true" ShowZero="false" ></AccumulationDataLabelSettings>
</AccumulationChartSeries>
</AccumulationChartSeriesCollection>
<AccumulationChartLegendSettings Visible="false"></AccumulationChartLegendSettings>
</SfAccumulationChart>
@code {
public class Statistics
{
public string Browser { get; set; }
public double Users { get; set; }
}
public List<Statistics> StatisticsDetails = new List<Statistics>
{
new Statistics { Browser = "Chrome", Users = 37 },
new Statistics { Browser = "UC Browser", Users = 17 },
new Statistics { Browser = "iPhone", Users = 0 },
new Statistics { Browser = "Others", Users = 4 },
new Statistics { Browser = "Opera", Users = 11 },
new Statistics { Browser = "Android", Users = 0 },
};
}
The following screenshot illustrates the output of the code snippet.
Output
Live Sample for Hiding Zero Datalabel
Conclusion
I hope you enjoyed learning how to hide zero datalabel in pie 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!