Back to Devexpress

NestedDonutSeries2D Class

wpf-devexpress-dot-xpf-dot-charts-dot-nesteddonutseries2d.md

latest8.7 KB
Original Source

NestedDonutSeries2D Class

Represents a series view of the Nested Donut type.

Namespace : DevExpress.Xpf.Charts

Assembly : DevExpress.Xpf.Charts.v25.2.dll

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
public class NestedDonutSeries2D :
    PieSeries2D,
    ISupportSeriesGroups,
    INestedDoughnutSeriesView
vb
Public Class NestedDonutSeries2D
    Inherits PieSeries2D
    Implements ISupportSeriesGroups,
               INestedDoughnutSeriesView

Remarks

The NestedDonutSeries2D class provides the functionality of a series view of the Nested Donut type within a chart control.

In addition to the common view settings inherited from the PieSeries class, the NestedDonutSeries2D class declares the Nested Donut type specific settings. The settings allow you to define an inner indent between nested donuts (NestedDonutSeries2D.InnerIndent), specify the specific weight for each nested donut series (NestedDonutSeries2D.Weight), and create groups for similar Nested Donut series (NestedDonutSeries2D.Group).

For more information on series views of the pie type, see the Nested Donut topic.

Example

The following example demonstrates how to create a Nested Donut chart.

To do this, it is necessary to assign the ChartControl.Diagram property to SimpleDiagram2D, and then add two NestedDonutSeries2D objects with points to the diagram’s Diagram.Series collection.

Also, this example shows how to change the color of each series point according to its values using the ChartControl.CustomDrawSeriesPoint event. As a result, segments of an outer donut representing kinds of products are colored with a specific product group color (an inner donut).

vb
Imports Microsoft.VisualBasic
Imports System.Windows
Imports DevExpress.Xpf.Charts
Imports System.Windows.Media

Namespace NestedDonutChart

    Partial Public Class MainWindow
        Inherits Window
        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub chartControl1_CustomDrawSeriesPoint(ByVal sender As Object, ByVal e As CustomDrawSeriesPointEventArgs)

            If e.SeriesPoint.Value <= 10 Then
                e.DrawOptions.Color = Color.FromArgb(&HFF, &H51, &H89, &H03)

            ElseIf (e.SeriesPoint.Value > 10) And (e.SeriesPoint.Value <= 20) Then
                e.DrawOptions.Color = Color.FromArgb(&HFF, &HF9, &HAA, &H0F)

            ElseIf e.SeriesPoint.Value > 20 Then
                e.DrawOptions.Color = Color.FromArgb(&HFF, &HC7, &H39, &H0C)
            End If
        End Sub
    End Class
End Namespace
csharp
using System.Windows;
using DevExpress.Xpf.Charts;
using System.Windows.Media;

namespace NestedDonutChart {

    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }

        private void chartControl1_CustomDrawSeriesPoint(object sender, CustomDrawSeriesPointEventArgs e) {

            if (e.SeriesPoint.Value <= 10) {
                e.DrawOptions.Color = Color.FromArgb(0xFF, 0x51, 0x89, 0x03);
            }

            else if ((e.SeriesPoint.Value > 10) & (e.SeriesPoint.Value <= 20)) {
                e.DrawOptions.Color = Color.FromArgb(0xFF, 0xF9, 0xAA, 0x0F);
            }

            else if (e.SeriesPoint.Value > 20) {
                e.DrawOptions.Color = Color.FromArgb(0xFF, 0xC7, 0x39, 0x0C);
            }
        }
    }
}
xaml
<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts" 
        x:Class="NestedDonutChart.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <dxc:ChartControl Name="chartControl1" ToolTipEnabled="True"
                          CustomDrawSeriesPoint="chartControl1_CustomDrawSeriesPoint">
            <dxc:ChartControl.Diagram>
                <dxc:SimpleDiagram2D>
                    <dxc:SimpleDiagram2D.Series>
                        <dxc:NestedDonutSeries2D DisplayName="Products" InnerIndent="5" 
                                                  ToolTipPointPattern="{} {A}: {VP:##.##%}"
                                                  HoleRadiusPercent="0" LegendTextPattern="{}{A}">
                            <dxc:NestedDonutSeries2D.Points>
                                <dxc:SeriesPoint Argument="Fish" Value="10" />
                                <dxc:SeriesPoint Argument="Meat" Value="20" />
                                <dxc:SeriesPoint Argument="Dairy Product" Value="30" />                                
                            </dxc:NestedDonutSeries2D.Points>
                        </dxc:NestedDonutSeries2D>
                        <dxc:NestedDonutSeries2D DisplayName="Kind of Products" ShowInLegend="False" 
                                                 ToolTipPointPattern="{} {A}: {VP:##.##%}" >
                            <dxc:NestedDonutSeries2D.Points>
                                <dxc:SeriesPoint Argument="Carp" Value="5"/>
                                <dxc:SeriesPoint Argument="Sauger" Value="10"/>
                                <dxc:SeriesPoint Argument="Bluegill" Value="9"/>
                                <dxc:SeriesPoint Argument="Beef" Value="14"/>
                                <dxc:SeriesPoint Argument="Chicken" Value="16"/>
                                <dxc:SeriesPoint Argument="Duck" Value="18"/>
                                <dxc:SeriesPoint Argument="Cottage cheese" Value="22"/>
                                <dxc:SeriesPoint Argument="Kumis" Value="24"/>
                                <dxc:SeriesPoint Argument="Ice Cream" Value="26"/>
                            </dxc:NestedDonutSeries2D.Points>
                        </dxc:NestedDonutSeries2D>
                    </dxc:SimpleDiagram2D.Series>
                </dxc:SimpleDiagram2D>
            </dxc:ChartControl.Diagram>
            <dxc:ChartControl.Legend>
                <dxc:Legend />
            </dxc:ChartControl.Legend>
            <dxc:ChartControl.Titles>
                <dxc:Title Dock="Top" HorizontalAlignment="Center" Content="Nested Donut"/>
            </dxc:ChartControl.Titles>
        </dxc:ChartControl>
    </Grid>
</Window>

Implements

ILegendVisible

Inheritance

Show 13 items

Object DispatcherObject DependencyObject Visual UIElement FrameworkElement Control ChartElementBase ChartElement Series PieSeries PieSeries2D NestedDonutSeries2D

See Also

NestedDonutSeries2D Members

DevExpress.Xpf.Charts Namespace