Back to Devexpress

XRChart.CustomizeStackedBarTotalLabel Event

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrchart-98b13bb1.md

latest7.0 KB
Original Source

XRChart.CustomizeStackedBarTotalLabel Event

Occurs before a stacked bar total label is painted.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public event CustomizeStackedBarTotalLabelEventHandler CustomizeStackedBarTotalLabel
vb
Public Event CustomizeStackedBarTotalLabel As CustomizeStackedBarTotalLabelEventHandler

Event Data

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

PropertyDescription
ArgumentReturns a series point argument value.
TextGets or sets the total label text.
TextColorGets or sets the total label’s text color.
TotalValueReturns 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.

csharp
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);
}
vb
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

XRChart Class

XRChart Members

DevExpress.XtraReports.UI Namespace