[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Collapse]Spreadsheet
    Product Structure
   [Expand]Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
   [Expand]Formulas
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
   [Expand]Pivot Table Overview
   [Expand]Charts and Graphics
    Printing
    Events
    Protection
    Operation Restrictions
    Find and Replace
   [Expand]Mail Merge
   [Expand]Visual Elements
    Services
    Themes and Templates
   [Expand]Shortcuts
   [Collapse]Examples
    [Expand]Files
    [Expand]Workbooks
    [Expand]Worksheet
    [Expand]Rows and Columns
    [Expand]Cells
    [Expand]Formulas
    [Expand]Data Binding
    [Expand]Formatting Cells
    [Expand]Conditional Formatting
    [Expand]Group Data
    [Expand]Filter Data
    [Expand]Tables
    [Expand]Pivot Tables
    [Expand]Printing
    [Expand]Pictures
    [Expand]Shapes
    [Collapse]Charts
      How to: Create and Modify a Chart
      How to: Create a Stock Chart
      How to: Format Chart Elements
      How to: Change the Color of Series Points
      How to: Display the Chart Title
      How to: Display and Format Data Labels
      How to: Show or Hide the Chart Legend
      How to: Change the Display of Chart Axes
      How to: Protect a Chart
      How to: Create a Chart Sheet
      How to: Move a Chart to a Chart Sheet
      How to: Specify Chart Sheet Print Options
      How to: Remove a Chart Sheet
      How to: Protect a Chart Sheet
    [Expand]Sparklines
    [Expand]Protection
    [Expand]Mail Merge
    [Expand]Cell Templates
    [Expand]Commands
    [Expand]Customization
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Display and Format Data Labels

After you create a chart, you can add a data label to each data point in the chart to identify its actual value. By default, data labels are linked to data that the chart uses. When data changes, information in the data labels is updated automatically. If required, you can also display custom information in a label.

Select the action you wish to perform.

Expanded Add Data Labels to the Chart

Basic settings that specify the contents, position and appearance of data labels in the chart are defined by the DataLabelOptions object, accessed by the ChartView.DataLabels property. Use the object's properties to display data labels for all series in the current chart view and specify what information should appear in each label. The following options are available:

  • Value. Value labels identify the underlying value of each data point. To display value labels, set the DataLabelBase.ShowValue property of the DataLabelOptions object to true.
  • Series name. Series labels identify data series to which the data points in the chart belong. Most series include multiple data points, so the same name will be repeated for all data points in the series, which is probably overkill. However, if you wish to display series name labels, utilize the DataLabelBase.ShowSeriesName property of the DataLabelOptions object.
  • Category name. Category labels repeat information of the category axis labels. This option can be useful if you wish to display the category names for charts that do not have a category axis, like a pie or doughnut chart. To display the category labels, use the DataLabelBase.ShowCategoryName property.
  • Percentage. Percentage labels are available for the pie and doughnut chart types only. They display a percentage calculated by using the basic formula that divides the data point value by the total of all values in the series. To add the percentage labels, utilize the DataLabelBase.ShowPercent property.
  • Bubble size. Bubble size labels display the bubble size value in a bubble chart. Since the bubble size is a third dimension that does not correspond to any axis and is shown as a filled shape of a particular size, you can identify its value by displaying the bubble size labels at each data point. To do this, use the DataLabelBase.ShowBubbleSize property.
  • Legend key. Legend key adds a sample of the color and fill pattern used to draw the corresponding series in a chart. To display the legend key next to each data label, utilize DataLabelBase.ShowLegendKey property.

If you use a combination of data label entries, you can specify a character to separate different items in a label by using the DataLabelBase.Separator property. The most frequently used separators are comma, semicolon, period, new line and space. However, you can specify a custom separator.

Note

The complete sample project is available in the DevExpress-Examples/wpf-spreadsheet-chart-api-t113198 repository on GitHub.

Expanded Specify the Position of Data Labels

When there are many data points in a series or the label text is too long, the data labels may overlap, making the chart unreadable. To avoid this, you can adjust the positions of data labels by using the DataLabelBase.LabelPosition property. Depending on the chart type, assign one of the DataLabelPosition enumeration values to the LabelPosition property to specify the placement of data labels relative to their data markers.

Note

The complete sample project is available in the DevExpress-Examples/wpf-spreadsheet-chart-api-t113198 repository on GitHub.

Expanded Apply Number Format to Data Labels

You can specify how to display numeric values in data labels by applying number formats. A number in a data label can appear as a percentage, decimal, currency, scientific, fraction, text, accounting, date, time, or custom value. To apply a number format to data labels, utilize the DataLabelBase.NumberFormat property, which provides access to the NumberFormatOptions object containing format options for displaying numbers in different chart elements. Next, assign the corresponding number format code to the NumberFormatOptions.FormatCode property. Set the NumberFormatOptions.IsSourceLinked property to false to indicate that the applied format differs from the number format of the worksheet cell containing the data point value.

Note

The complete sample project is available in the DevExpress-Examples/wpf-spreadsheet-chart-api-t113198 repository on GitHub.

Expanded Create a Custom Label Entry

Displaying labels for all data series in the current view can make the chart overcrowded. However, you can avoid this by displaying labels for a particular series or individual data points. An individual data label is defined by the DataLabel object that is stored in the collection of customized data labels. To display data labels for a specific series, access the DataLabelCollection by using the Series.CustomDataLabels property, then use the collection's properties to show and modify the data labels. To indicate that custom data labels are used, set the Series.UseCustomDataLabels property to true.

To display an individual data label, add a DataLabel instance to the DataLabelCollection collection with the index set to the index of the selected data point. Next, set the label's DataLabelBase.ShowValue property (or any other DataLabelBase.Show* property depending on the information you wish to display in the label) to true. You can also specify the custom text for a data label by using the DataLabel.Text property, which provides access to the ChartText object. Use the ChartText.SetValue method to specify a new text for a data label, or utilize the ChartText.SetReference method to retrieve the text for a label from the worksheet cell.

Note

The complete sample project is available in the DevExpress-Examples/wpf-spreadsheet-chart-api-t113198 repository on GitHub.

Expanded See Also

Is this topic helpful?​​​​​​​