Back to Devexpress

Total Label

aspnet-120743-components-chart-control-visual-elements-total-label.md

latest5.7 KB
Original Source

Total Label

  • Dec 29, 2020
  • 3 minutes to read

Total labels display several series points’ total value. A Series View type defines which series points are used to calculate the total value. Stacked Bar Total Labels show Stacked Bar series groups’ total values. The Pie Total Label displays Pie (Doughnut) series points’ total value.

The following sections describe the types of Total Labels :

Pie Total Label

The Pie Total Label displays the total value of all Pie (Doughnut) series points.

How to: Configure the Total Label at Design Time

Do the following to access the settings of a Pie Chart’s Total Label at design time:

  1. Select the Chart Control and click its smart tag to invoke the Chart Control Tasks list. Choose the Run Designer… command:

  2. Expand a series that should show the total label in the Designer’s chart structure tree. Select the total label element and click its eye icon ( ):

  3. Specify the total label’s TotalLabel.TextPattern.

  4. Close the designer to save the changes.

How to: Configure the Total Label at Runtime

The following example demonstrates how to customize the Pie Total Label at runtime:

csharp
Series landAreaSeries = chartControl.Series["Land Area"];
PieSeriesView pieView = landAreaSeries.View as PieSeriesView;
if (pieView == null) return;
pieView.TotalLabel.Visible = true;
pieView.TotalLabel.TextPattern = "Total World Population\r\n{TV:#,#}";
vb
Dim landAreaSeries As Series = chartControl.Series("Land Area")
Dim pieView As PieSeriesView = TryCast(landAreaSeries.View, PieSeriesView)
If (pieView Is Nothing) Then Return
With pieView.TotalLabel
    .Visible = True
    .TextPattern = "Total World Population\r\n{TV:#,#}"
End With

The code above uses the following classes and properties:

SymbolDescription
PieSeriesView.TotalLabelReturns settings that configure the Pie series’ total label.
PieTotalLabelThe pie’s total labels settings storage.
TotalLabel.VisibleGets or sets the value indicating whether total labels should be visible.
TotalLabel.TextPatternGets or sets the text pattern the Chart Control uses to generate the Total Label’s text.

Stacked Bar Total Labels

Stacked Bar Total Labels show the total values of Stacked Bar series groups.

How to: Configure the Total Label at Design Time

Do the following to access the Stacked Bar Total Label settings at design time:

  1. Select the Chart Control, click its smart tag to invoke the Chart Control Tasks list, and choose Run Designer… :

  2. Navigate to a pane’s Stacked Bar Total Label element in the Designer’s Chart Structure Tree, and click its eye icon ( ). Changes made to the total label object in one pane are not applied to all panes. You should navigate to a specific pane’s label object to modify/show it:

  3. Set the total label’s TotalLabel.TextPattern.

  4. Close the designer to save the changes.

How to: Configure the Total Label at Runtime

The following example customizes Stacked Bar Total Labels at runtime:

csharp
XYDiagram2D diagram = chartControl.Diagram as XYDiagram2D;
if (diagram == null) return;
StackedBarTotalLabel totalLabel = diagram.DefaultPane.StackedBarTotalLabel;
totalLabel.Visible = true;
totalLabel.TextPattern = "{TV:C0}";
vb
Dim diagram As XYDiagram2D = TryCast(chartControl.Diagram, XYDiagram2D)
If (diagram Is Nothing) Then Return
With diagram.DefaultPane.StackedBarTotalLabel
    .Visible = True
    .TextPattern = "{TV:C0}"
End With

The code above uses the following classes and properties:

SymbolDescription
XYDiagramPaneBase.StackedBarTotalLabelReturns the settings of total labels that belong to series groups within the pane.
StackedBarTotalLabelThe stacked bars’ total labels’ settings storage.
TotalLabel.VisibleGets or sets the value indicating whether total labels should be visible.
TotalLabel.TextPatternGets or sets the text pattern the Chart Control uses to generate the Total Label’s text.