Donut Chart

Similar to pie charts, donut charts are great for showing proportional data. It offers the same customization options as for pie charts, but with a custom sized inner cutout to turn your pies into donuts.

donut

The chart from the image above is created with the following code:

<shield:ShieldChart ID="ShieldChart1" Width="580px" Height="400px" runat="server" 
    OnTakeDataSource="ShieldChart1_TakeDataSource"
    CssClass="chart">
    <PrimaryHeader Text="Browsers Popularity amongst Users"></PrimaryHeader>
    <ExportOptions AllowExportToImage="false" AllowPrint="false" />
    <TooltipSettings CustomPointText="{point.collectionAlias}:{point.y}"></TooltipSettings>
    <DataSeries>
        <shield:ChartDonutSeries EnableValueXSorting="false" DataFieldY="Value" DataFieldX="Browser" CollectionAlias="Usage">
            <Settings EnablePointSelection="true"></Settings>
        </shield:ChartDonutSeries>
    </DataSeries>
</shield:ShieldChart>
protected void ShieldChart1_TakeDataSource(object sender, Shield.Web.UI.ChartTakeDataSourceEventArgs e)
{
    List datasource = new List() 
    { 
        new Helper() { Browser = "Firefox", Value= 44.2 },
        new Helper() { Browser = "IE7", Value= 26.6 },
        new Helper() { Browser = "IE6", Value= 20 },
        new Helper() { Browser = "Chrome", Value= 3.1 },
        new Helper() { Browser = "Other", Value= 5.4 },
    };

    ShieldChart1.DataSource = datasource;
}

private class Helper
{
    public string Browser { get; set; }
    public double Value { get; set; }
}     
  • When the chart is bound to collection of objects the X values are got by the field which name is set into the DataFieldX property of the ChartDonutSeries. The Y values are got by the field which name is set into the DataFieldY property.
  • The name that is shown in the legend is chosen via the CollectionAlias property of the ChartDonutSeries.
  • By default all X values are sorted in order donut chart to be shown appropriately, however this behavior is controlled by the EnableValueXSorting property of the ChartDonutSeries.
  • The inner size of the donut series type is controlled by the Settings.InnerSize property.
  • The center of the donut series type chart can be changed by Settings.CenterX and Settings.CenterY properties which correspond to the x and y coordinates.
  • DataStart and DataStep properties control the start value of the x axis and explicit value for the interval between a data series member values.
  • Each part of the donut chart can be showed as sliced by setting EnablePointSelection and SlicedOffset property.
  • All points from the ChartDonutSeries are represented with ChartSeriesItem which belongs to the ChartDonutSeries.Items collection.
    • The ChartDonutSeries.Items can be added declarative without data binding.
    • The data binding and declarative approach can be mixed. However in order declarative items to be appended to the items created from the datasource the ShieldChart.AppendDataBoundItems property need to be set to "true".
  • All setting related to ChartDonutSeries are contained into the ChartDonutSeries.Settings object.
    • The series color can be set via Color property.
    • If the AddToLegend is set to false the series is not added into the legend.
    • The animation of the series can be controlled by ChartDonutSeries.Settings.EnableAnimation and ChartDonutSeries.Settings.AnimationDuration properties.
    • Each point from the series can be selected if the EnablePointSelection property is set to true.
    • All selected points can be customized by Settings.PointMark.ActiveSettings.PointSelectedState object properties.
    • From the Settings.PointMark.ActiveSettings.PointHoveredState object properties you can change the appearance of each part when the user hovers it.
    • Each series has related tooltip which can be customized via the Settings.Tooltip object.
    • Each point from the series can have related text, which appearance is controlled by Settings.DataPointText property. You can changeBackgroundColor, BorderColor, Color, Padding, and TextAngle of the corresponding data point text.