How to add a custom view to a hole in the Blazor doughnut charts?
This article explains how to add a custom view to a hole in Blazor doughnut chart.
Integrate Custom View in Doughnut Chart Hole for Blazor Chart
Blazor chart provide the support to add custom view to a hole in doughnut chart. This can be achieved by using Annotations.
Annotations are texts, shapes, or images that are used to highlight a specific region of interest in a chart. The AccumulationChartAnnotation property allows to add annotations to the chart. Specify the element that needs to be displayed in the accumulation chart area by using the Content property of the annotation.
The following code example illustrates how to add an image link into the hole of doughnut chart.
Index.razor
@using Syncfusion.Blazor.Charts
<SfAccumulationChart Title="Mobile Browser Statistics">
<AccumulationChartSeriesCollection>
<AccumulationChartSeries DataSource="@StatisticsDetails" XName="Browser" YName="Users" Name="Browser" InnerRadius="40%" Radius="200">
</AccumulationChartSeries>
</AccumulationChartSeriesCollection>
<AccumulationChartLegendSettings Visible="false"></AccumulationChartLegendSettings>
<AccumulationChartAnnotations>
<AccumulationChartAnnotation Region="Regions.Series" X="43%" Y="43%">
<ContentTemplate>
<div id="back" style="visibility:visible; cursor:pointer;padding:3px;width:30px; height:30px;">
<img src="https://i.pinimg.com/564x/9a/31/96/9a31966df8f450c8df5435c8a064274f.jpg" alt="Girl in a jacket" width="80" height="80">
</div>
</ContentTemplate>
</AccumulationChartAnnotation>
</AccumulationChartAnnotations>
</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 = 19 },
new Statistics { Browser = "Others", Users = 4 },
new Statistics { Browser = "Opera", Users = 11 },
new Statistics { Browser = "Android", Users = 12 },
};
}
The following screenshot illustrates the output of the above code snippet.
Output:
Conclusion
I hope you enjoyed learning how to add a custom view inside the hole of a doughnut chart using the 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!