Skip to main content

XRChart.CustomizePieTotalLabel Event

Occurs before the pie total label is painted.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v23.2.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

public event CustomizePieTotalLabelEventHandler CustomizePieTotalLabel

Event Data

The CustomizePieTotalLabel event's data class is CustomizePieTotalLabelEventArgs. The following properties provide information specific to this event:

Property Description
Series Returns a pie series whose total label is customized.
Text Gets or sets the total label text.
TextColor Gets or sets the total label’s text color.
TotalValue Returns the total label value.

Remarks

Handle this event to customize the text in the pie total label:

Tip

You can use this event to conditionally customize the pie chart total label’s text. See the code sample below for details.

Refer to the Total Labels topic for information on total labels.

Example

The code sample below creates a pie chart, shows total labels, and customizes the label text.

using DevExpress.XtraCharts;
// ...
using System.IO;
using System.Drawing;
using DevExpress.Data.Filtering;
using DevExpress.XtraPrinting;
// ...
// Create a chart instance.
XRChart chart = new XRChart();
// Create a chart parameter and bind it to the CategoryID field. Prepend the field name with the data member name.
chart.Parameters.Add(new XRControlParameter("ChartCategoryID", null, "Products.CategoryID"));
// Create a chart series that displays products prices.
Series series = new Series("Series1", ViewType.Pie);
series.ArgumentDataMember = "Products.ProductName";
series.ValueDataMembers.AddRange(new string[] { "Products.UnitPrice" });
// Display products from a specific category only.
series.FilterString = "Products.CategoryID = ?ChartCategoryID";
// Add the series to the chart.
chart.Series.Add(series);
// Make the total label visible.
((PieSeriesView)series.View).TotalLabel.Visible = true;
// Add the CustomizePieTotalLabel event handler.
chart.CustomizePieTotalLabel += chart_CustomizePieTotalLabel;
// ...
private void chart_CustomizePieTotalLabel(object sender, CustomizePieTotalLabelEventArgs e) {
    // Set the total label's text color to red.
    e.TextColor = Color.Red;
    // Apply the currency format to the label text.
    e.Text = string.Format("{0:c2}", e.TotalValue);
}
See Also