[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
   [Expand]Product Information
   [Expand]Getting Started
   [Expand]Graphical User Interface
    Supported Formats
   [Expand]Developer Guidelines
   [Expand]Data Acquisition
   [Expand]Data Shaping
     How to: Bind a Report to an MDB Database (Runtime Sample)
     How to: Bind a Report to Multiple MDB Data Sources (Runtime Sample)
     How to: Bind a Report to a Dataset Populated from an XML File (Runtime Sample)
     How to: Bind a Report to Multiple List Data Sources (Runtime Sample)
     How to: Bind a Report to an MS SQL Server Database
     How to: Hide Data Tables in the Database Schema
     How to: Calculate a Summary Function
     How to: Create a Calculated Field
     How to: Limit the Data Supplied During Document Editing
     How to: Create a Snap Template (Runtime Sample)
     How to: Sort Data (Runtime Sample)
     How to: Group Data (Runtime Sample)
     How to: Filter Data (Runtime Sample)
     How to: Format Data
     How to: Pass Parameters to a Report
     How to: Pass Parameters to a Report (Runtime Sample)
     How to: Create a Master-Detail Report
     How to: Create a Multi-Column Report
     How to: Create a Side-by-Side Report
     How to: Create a Report with a Chart
     How to: Save, Load, or Export a Report
     How to: Add a Table of Contents to a Report
     How to: Customize the Data Source Wizard
     How to: Programmatically Mark the Data Source as Use for Mail Merge
     How to: Create a Snap Chart Programmatically
     How to: Bind a Report to an Object Data source (Runtime Sample)
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[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 a Snap Chart Programmatically

The following example demonstrates how to add a Chart to a Snap document using the document's ISnapFieldOwner.CreateSnChart method. This method returns the SnapChart object, which represents the newly created chart and provides properties used to populate the chart with data and fine-tune its layout and appearance settings.


Chart modifications at runtime must be wrapped in the SnapEntity.BeginUpdate and SnapEntity.EndUpdate method calls.

Use the SnapChart.DataSource property to assign a data source to the chart.

Choose one of the following approaches to create chart series and populate them with data:

  • Generate and populate series dynamically by setting the SnapChart.SeriesDataMember property to the name of the data field containing series names. Specify data fields that contain arguments and data values for series points using the SeriesBase.ArgumentDataMember and SeriesBase.ValueDataMembers properties of the SeriesBase object, which the SnapChart.SeriesTemplate property returns.


    If you bind the chart's arguments or data values to a detail table, the chart displays data for the current master record. The chart displays all records if its arguments or data values are bound to a master table.

  • Create chart series manually and supply them with data by adding new Series objects to the chart's SnapChart.Series collection and specify their argument and value data members.

Use the series' SeriesBase.View property or SeriesBase.ChangeView method to specify or modify the series view type.

After you finish creating the chart, call the FieldCollection.Update method to update the document fields and display the chart.

The following image shows the result of executing the code above:

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