xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrchart-98b13bb1.md
Occurs before a stacked bar total label is painted.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public event CustomizeStackedBarTotalLabelEventHandler CustomizeStackedBarTotalLabel
Public Event CustomizeStackedBarTotalLabel As CustomizeStackedBarTotalLabelEventHandler
The CustomizeStackedBarTotalLabel event's data class is CustomizeStackedBarTotalLabelEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Argument | Returns a series point argument value. |
| 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 stacked bar total labels:
Tip
You can use this event to conditionally customize a stacked bar 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 stacked bar 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 OrderID field. Prepend the field name with the data member name.
chart.Parameters.Add(new XRControlParameter("ChartOrderID", null, "OrderedProducts.OrderID"));
// Create a chart series that displays products' discounted prices.
Series series1 = new Series("Series1", ViewType.StackedBar);
series1.ArgumentDataMember = "OrderedProducts.ProductName";
series1.ValueDataMembers.AddRange(new string[] { "Products.DiscountedPrice" });
// Display products from a specific order only.
series1.FilterString = "Products.OrderID = ?ChartOrderID";
// Create a chart series that displays products' full prices.
Series series2 = new Series("Series2", ViewType.StackedBar);
series2.ArgumentDataMember = "OrderedProducts.ProductName";
series2.ValueDataMembers.AddRange(new string[] { "Products.UnitPrice" });
// Apply the same filter as for the first series.
series2.FilterString = "Products.OrderID = ?ChartOrderID";
// Add the series to the chart.
chart.Series.AddRange(new Series[] {series1, series2});
// Make the total label visible.
((StackedBarSeriesView)series1.View).Pane.StackedBarTotalLabel.Visible = true;
// Add the CustomizeStackedBarTotalLabel event handler.
chart.CustomizeStackedBarTotalLabel += chart_CustomizeStackedBarTotalLabel;
// ...
private void chart_CustomizeStackedBarTotalLabel(object sender, CustomizeStackedBarTotalLabelEventArgs 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 OrderID field. Prepend the field name with the data member name.
chart.Parameters.Add(New XRControlParameter("ChartOrderID", Nothing, "OrderedProducts.OrderID"))
' Create a chart series that displays products' discounted prices.
Dim series1 As New Series("Series1", ViewType.StackedBar)
series1.ArgumentDataMember = "OrderedProducts.ProductName"
series1.ValueDataMembers.AddRange(New String() { "Products.DiscountedPrice" })
' Display products from a specific order only.
series1.FilterString = "Products.OrderID = ?ChartOrderID"
' Create a chart series that displays products' full prices.
Dim series2 As New Series("Series2", ViewType.StackedBar)
series2.ArgumentDataMember = "OrderedProducts.ProductName"
series2.ValueDataMembers.AddRange(New String() { "Products.UnitPrice" })
' Apply the same filter as for the first series.
series2.FilterString = "Products.OrderID = ?ChartOrderID"
' Add the series to the chart.
chart.Series.AddRange(New Series() {series1, series2})
' Make the total label visible.
CType(series1.View, StackedBarSeriesView).Pane.StackedBarTotalLabel.Visible = True
' Add the CustomizeStackedBarTotalLabel event handler.
AddHandler chart.CustomizeStackedBarTotalLabel, AddressOf chart_CustomizeStackedBarTotalLabel
' ...
Private Sub chart_CustomizeStackedBarTotalLabel(ByVal sender As Object, ByVal e As CustomizeStackedBarTotalLabelEventArgs)
' 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