Back to Devexpress

SeriesLabelBase.ResolveOverlappingMode Property

corelibraries-devexpress-dot-xtracharts-dot-serieslabelbase.md

latest11.4 KB
Original Source

SeriesLabelBase.ResolveOverlappingMode Property

Gets or sets a value specifying the mode to resolve overlapping of series labels.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public ResolveOverlappingMode ResolveOverlappingMode { get; set; }
vb
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
Public Property ResolveOverlappingMode As ResolveOverlappingMode

Property Value

TypeDescription
ResolveOverlappingMode

A ResolveOverlappingMode enumeration value.

|

Available values:

NameDescription
None

The overlapping resolving algorithm is disabled.

| | Default |

The default algorithm to re-position labels in a random way, to avoid overlapping labels.

| | HideOverlapped |

If two or more labels overlap, some of them are automatically hidden, to avoid overlapping.

| | JustifyAroundPoint |

Only labels that are overlapping change their position. They are re-positioned in such a way, so that they are moved around the corresponding point’s center, but their indent from the point center is preserved.

| | JustifyAllAroundPoint |

All labels (both overlapping and non-overlapping) change their position. They are re-positioned in such a way, so that they are moved around the corresponding point’s center, but their indent from the point center is preserved.

|

Remarks

Use the ResolveOverlappingMode property to determine an overlapping resolving mode to be applied to series labels. The set of the available modes varies, depending on the view type of the series.

Note

To learn which view types support resolve overlapping, or to get more details on this feature, refer to Series Point Labels.

Example

The following example demonstrates how to create a ChartControl with a series of the DoughnutSeriesView type, set its general properties, and add this chart to a form at runtime. Before proceeding with this example, create a Windows Forms Application in Visual Studio, and add all required assemblies to the References list of your project.

Then, add the following code to the Form.Load event handler.

Note

A complete sample project is available at https://github.com/DevExpress-Examples/winforms-chart-create-a-doughnut-chart

csharp
using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;

namespace Series_DoughnutChart {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {
            // Create a new chart.
            ChartControl DoughnutChart = new ChartControl();

            // Create a doughnut series.
            Series series1 = new Series("Series 1", ViewType.Doughnut);

            // Populate the series with points.
            series1.Points.Add(new SeriesPoint("Russia", 17.0752));
            series1.Points.Add(new SeriesPoint("Canada", 9.98467));
            series1.Points.Add(new SeriesPoint("USA", 9.63142));
            series1.Points.Add(new SeriesPoint("China", 9.59696));
            series1.Points.Add(new SeriesPoint("Brazil", 8.511965));
            series1.Points.Add(new SeriesPoint("Australia", 7.68685));
            series1.Points.Add(new SeriesPoint("India", 3.28759));
            series1.Points.Add(new SeriesPoint("Others", 81.2));

            // Add the series to the chart.
            DoughnutChart.Series.Add(series1);

            // Specify the text pattern of series labels.
            series1.Label.TextPattern = "{A}: {VP:P0}";

            // Specify how series points are sorted.
            series1.SeriesPointsSorting = SortingMode.Ascending;
            series1.SeriesPointsSortingKey = SeriesPointKey.Argument;

            // Specify the behavior of series labels.
            ((DoughnutSeriesLabel)series1.Label).Position = PieSeriesLabelPosition.TwoColumns;
            ((DoughnutSeriesLabel)series1.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default;
            ((DoughnutSeriesLabel)series1.Label).ResolveOverlappingMinIndent = 5;

            // Adjust the view-type-specific options of the series.
            ((DoughnutSeriesView)series1.View).ExplodedPoints.Add(series1.Points[0]);
            ((DoughnutSeriesView)series1.View).ExplodedDistancePercentage = 30;

            // Access the diagram's options.
            ((SimpleDiagram)DoughnutChart.Diagram).Dimension = 2;

            // Add a title to the chart and hide the legend.
            ChartTitle chartTitle1 = new ChartTitle();
            chartTitle1.Text = "2D Doughnut Chart";
            DoughnutChart.Titles.Add(chartTitle1);
            DoughnutChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;

            // Add the chart to the form.
            DoughnutChart.Dock = DockStyle.Fill;
            this.Controls.Add(DoughnutChart);
        }

    }
}
vb
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts

Namespace Series_DoughnutChart
    Partial Public Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
            ' Create a new chart.
            Dim DoughnutChart As New ChartControl()

            ' Create a doughnut series.
            Dim series1 As New Series("Series 1", ViewType.Doughnut)

            ' Populate the series with points.
            series1.Points.Add(New SeriesPoint("Russia", 17.0752))
            series1.Points.Add(New SeriesPoint("Canada", 9.98467))
            series1.Points.Add(New SeriesPoint("USA", 9.63142))
            series1.Points.Add(New SeriesPoint("China", 9.59696))
            series1.Points.Add(New SeriesPoint("Brazil", 8.511965))
            series1.Points.Add(New SeriesPoint("Australia", 7.68685))
            series1.Points.Add(New SeriesPoint("India", 3.28759))
            series1.Points.Add(New SeriesPoint("Others", 81.2))

            ' Add the series to the chart.
            DoughnutChart.Series.Add(series1)

            ' Specify the text pattern of series labels.
            series1.Label.TextPattern = "{A}: {VP:P0}"

            ' Specify how series points are sorted.
            series1.SeriesPointsSorting = SortingMode.Ascending
            series1.SeriesPointsSortingKey = SeriesPointKey.Argument

            ' Specify the behavior of series labels.
            CType(series1.Label, DoughnutSeriesLabel).Position = PieSeriesLabelPosition.TwoColumns
            CType(series1.Label, DoughnutSeriesLabel).ResolveOverlappingMode = ResolveOverlappingMode.Default
            CType(series1.Label, DoughnutSeriesLabel).ResolveOverlappingMinIndent = 5

            ' Adjust the view-type-specific options of the series.
            CType(series1.View, DoughnutSeriesView).ExplodedPoints.Add(series1.Points(0))
            CType(series1.View, DoughnutSeriesView).ExplodedDistancePercentage = 30

            ' Access the diagram's options.
            CType(DoughnutChart.Diagram, SimpleDiagram).Dimension = 2

            ' Add a title to the chart and hide the legend.
            Dim chartTitle1 As New ChartTitle()
            chartTitle1.Text = "2D Doughnut Chart"
            DoughnutChart.Titles.Add(chartTitle1)
            DoughnutChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False

            ' Add the chart to the form.
            DoughnutChart.Dock = DockStyle.Fill
            Me.Controls.Add(DoughnutChart)
        End Sub

    End Class
End Namespace

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

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.

winforms-charts-create-model-for-custom-chart-element/CS/CustomChartElementModel/Form1.cs#L120

csharp
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
series.Label.ResolveOverlappingMode = ResolveOverlappingMode.HideOverlapped;
series.Label.TextPattern = "{V:.#}";

winforms-charts-create-model-for-custom-chart-element/VB/CustomChartElementModel/Form1.vb#L180

vb
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True
series.Label.ResolveOverlappingMode = ResolveOverlappingMode.HideOverlapped
series.Label.TextPattern = "{V:.#}"

winforms-chart-create-a-doughnut-chart/VB/Series_DoughnutChart/Form1.vb#L37

vb
CType(series1.Label, DoughnutSeriesLabel).Position = PieSeriesLabelPosition.TwoColumns
CType(series1.Label, DoughnutSeriesLabel).ResolveOverlappingMode = ResolveOverlappingMode.Default
CType(series1.Label, DoughnutSeriesLabel).ResolveOverlappingMinIndent = 5

See Also

ResolveOverlappingMinIndent

SeriesLabelBase Class

SeriesLabelBase Members

DevExpress.XtraCharts Namespace