[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
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
    Product Structure
   [Expand]Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
   [Expand]Pivot Table Overview
   [Expand]Charts and Graphics
    Operation Restrictions
    Find and Replace
   [Expand]Mail Merge
   [Expand]Visual Elements
    Themes and Templates
    [Expand]Rows and Columns
    [Expand]Data Binding
    [Expand]Formatting Cells
    [Expand]Conditional Formatting
    [Expand]Group Data
    [Expand]Filter Data
    [Expand]Pivot Tables
      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]Mail Merge
    [Expand]Cell Templates
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [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
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[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: Create and Modify a Chart

This topic demonstrates how to create a basic chart and change its settings.


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

To improve the control's performance by avoiding unnecessary render operations after each modification, enclose the chart modifications in the Workbook.BeginUpdate() - Workbook.EndUpdate() method pair.

Select the action you wish to perform.

Expanded Add and Position a Chart

All charts embedded in a worksheet are stored in the chart collection accessible using the Worksheet.Charts property. To create a chart, add it to the chart collection by utilizing the ChartCollection.Add method and pass the following parameters: the required chart type (ChartType) and the CellRange object containing data for the chart (this parameter is optional and can be omitted, so you can manually add data series to your chart). Refer to the Create and Modify a Chart Programmatically document for information on how to organize data in the source range to create a chart.

To position the created chart in a worksheet, use one of the following approaches.

You can also place a chart on a separate worksheet by creating a chart sheet (see How to: Create a Chart Sheet for details).

Expanded Add or Remove Data Series

If you did not specify the range containing chart data in the ChartCollection.Add method, you can define it later by using one of the following approaches.

  • Pass the required data range to the ChartObject.SelectData method. The method's direction parameter allows you to specify the data direction: whether the series values are arranged in columns (ChartDataDirection.Column) or rows (ChartDataDirection.Row).
  • Utilize the SeriesCollection.Add method to plot a data series on your chart. Using this method, you can fully control the number of series on your chart and explicitly specify data that should be plotted along the category (X) and value (Y) axes. Moreover, this method is extremely useful if you wish to plot data contained in noncontiguous ranges. For example, you can plot a data series with arguments from Column B and values from the Column D.

To remove an individual series from the chart, use the SeriesCollection.Remove or SeriesCollection.RemoveAt method.

Expanded Change Chart Data References

After you create a chart, you can change the cell range from which data for the series arguments and values is retrieved. To do this, perform the steps below.

  1. Use the ChartData.FromRange method to create the ChartData object containing new data for the series.
  2. Assign the created object to the Series.Arguments or Series.Values property.

Expanded Change the Order of Data Series

By default, if your chart has multiple data series, they are plotted on a chart in the order they appear on a worksheet (from left to right if data is arranged in columns, or from top to bottom if data is arranged in rows). However, you can change this default order. Utilize the Series.BringForward or Series.SendBackward method to move the specified series up or down in the plotting order, one position at a time. To place the series before or behind all other series on a chart, use the Series.BringToFront or Series.SendToBack method.

Expanded Change the Chart Type

After you created a chart, you may find that the chart you selected is not suitable and another chart type may better represent your data. In this case, there is no need to recreate the chart. Change the type of the entire chart using the ChartObject.ChangeType method. This method substitutes the existing chart with the chart you specified. If the operation cannot be completed, an exception is fired.

The following example demonstrates how to create a chart of the ChartType.PieExploded type. After that, the code attempts to change the chart type to ChartType.LineMarker. If you try to change the chart type to ChartType.StockHighLowClose (this line is commented), an exception will be thrown, because the data range is insufficient for this chart type, and the chart will be changed to ChartType.ColumnClustered.

Expanded Change the Chart Type of a Series (Combination Chart)

Besides changing a type of the entire chart you can also select a different chart type for an individual data series. This will automatically turn the chart into a combination chart. A combination chart is a complex chart that consists of two or more ChartView objects that consolidate series of the same chart type. To change the type of a single data series, call the Series.ChangeType method. If the series type you specified differs from the types of the existing ChartView objects (ChartView.ViewType), a new ChartView containing your series will be created, otherwise, the series will be added to the existing ChartView of the same type.


Not all chart types can be combined (for example, it is impossible to combine the 2-D and 3-D chart types). If you select a type that does not logically connect with the existing chart type, the resulting chart will contain only one ChartView of the most recently added type.

Compatible chart types are listed below.

Expanded See Also

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