xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrchart-7c509c2b.md
Occurs before the pie total label is painted.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public event CustomizePieTotalLabelEventHandler CustomizePieTotalLabel
Public Event CustomizePieTotalLabel As CustomizePieTotalLabelEventHandler
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. |
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.
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);
}
Imports DevExpress.XtraCharts
' ...
Imports System.IO
Imports System.Drawing
Imports DevExpress.Data.Filtering
Imports DevExpress.XtraPrinting
' ...
' Create a chart instance.
Dim chart As 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", Nothing, "Products.CategoryID"))
' Create a chart series that displays products prices.
Dim series As 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.
CType(series.View, PieSeriesView).TotalLabel.Visible = True
' Add the CustomizePieTotalLabel event handler.
AddHandler chart.CustomizePieTotalLabel, AddressOf chart_CustomizePieTotalLabel
' ...
Private Sub chart_CustomizePieTotalLabel(ByVal sender As Object, ByVal e As CustomizePieTotalLabelEventArgs)
' 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)
End Sub
See Also