XRChart.CustomizePieTotalLabel Event
Occurs before the pie total label is painted.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.1.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
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:
- Use the CustomizePieTotalLabelEventArgs.Series property to access the series to which the painted label belongs.
- Specify the label text in the CustomizePieTotalLabelEventArgs.Text property.
A label displays the point value (the CustomizePieTotalLabelEventArgs.TotalValue) by default. Changes to the Text property value do not affect the TotalValue. - Specify the text color in the CustomizePieTotalLabelEventArgs.TextColor property.
- Use the CustomizePieTotalLabelEventArgs.TotalValue property to obtain the point value.
A label displays this value if you do not change the Text property value.
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);
}