Skip to main content

XRChart.CustomizeStackedBarTotalLabel Event

Occurs before a stacked bar total label is painted.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v24.2.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

public event CustomizeStackedBarTotalLabelEventHandler CustomizeStackedBarTotalLabel

Event Data

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.

Remarks

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.

Example

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);
}
See Also