Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

SimpleDiagram2D Class

Represents a diagram that is used to plot non-XY 2D series.

Namespace: DevExpress.Xpf.Charts

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

NuGet Package: DevExpress.Wpf.Charts

#Declaration

public class SimpleDiagram2D :
    Diagram2D,
    ISimpleDiagram,
    IDiagram,
    IHitTestableElement

#Remarks

After you set the ChartControl.Diagram property to the SimpleDiagram2D type, only a series of the PieSeries2D types can be added to the Diagram.Series collection.

For more information, refer to Diagram and Series Type Compatibility.

#Example

This example demonstrates how to create a 2D Pie chart.

Pie chart

Create a ChartControl and specify its ChartControl.Diagram property to a SimpleDiagram2D object.

Note

Note that the ChartControl.Diagram is a content property. You can declare a diagram in XAML directly after a chart control’s declaration without wrapping it in opening and closing ChartControl.Diagram tags.

Add a PieSeries2D object to the Diagram.Series collection.

Note

Note that the Diagram.Series is a content property. You can declare series in XAML directly after a diagram’s declaration without wrapping them in opening and closing Diagram.Series tags.

Use the following properties to bind the series to data:

The PieSeries2D.Model property allows you to change the series appearance using the built-in models. This example uses the GlarePie2DModel model.

Use the Series.LegendTextPattern property to specify how to format text that identifies series points in the legend.

Set the Series.LabelsVisibility property to true to display the series’s labels. The SeriesLabel.TextPattern property defines how to configure series labels’ text.

The PieTotalLabel.TextPattern property allows you to specify the center label’s content.

View Example

using System.Collections.ObjectModel;
using System.Windows;

namespace PieDonut2DChart {
    public partial class Window1 : Window {
        public Window1() {
            InitializeComponent();
        }
    }
    public class ChartViewModel {
        public Collection<DataPoint> Data { get; private set; }
        public ChartViewModel() {
            Data = new Collection<DataPoint> {
                        new DataPoint ("Bikes", 142345),
                        new DataPoint ("Accessories", 266344),
                        new DataPoint ("Components", 631359),
                        new DataPoint ("Clothing", 120007)
            };
        }
        public class DataPoint {
            public string Argument { get; private set; }
            public double Value { get; private set; }
            public DataPoint(string argument, double value) {
                Argument = argument;
                Value = value;
            }
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the SimpleDiagram2D class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also