[Expand]General Information
[Expand]WinForms Controls
[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
[Collapse]Office File API
  Demo Application
  Redistribution and Deployment
 [Collapse]Spreadsheet Document API
   Product Structure
   Getting Started
  [Expand]Spreadsheet Document
   Supported Formats
  [Expand]Cell Basics
  [Expand]Formulas
   Defined Names
   Data Binding
  [Expand]Pivot Tables
  [Expand]Charts and Graphics
  [Expand]Mail Merge
  [Collapse]Examples
   [Expand]Files
   [Expand]Workbooks
   [Expand]Worksheets
   [Expand]Rows and Columns
   [Expand]Cells
   [Expand]Formulas
   [Expand]Import and Export Data
   [Expand]Data Binding
    Sorting
   [Expand]Mail Merge
    Search
   [Expand]Shapes
   [Expand]Charts
   [Collapse]Sparklines
     How to: Create Sparklines
     How to: Group and Ungroup Sparklines
     How to: Customize the Sparkline Appearance
     How to: Specify Sparkline Axis Settings
     How to: Delete Sparklines
   [Expand]Formatting Cells
   [Expand]Conditional Formatting
   [Expand]Group Data
   [Expand]Filter Data
   [Expand]Tables
   [Expand]Pivot Tables
   [Expand]Printing
   [Expand]Pictures
   [Expand]Protection
 [Expand]Word Processing Document API
 [Expand]PDF Document API
 [Expand]Excel Export Library
 [Expand]Snap Report API
 [Expand]Zip Compression and Archive API
 [Expand]Barcode Generation API
 [Expand]Unit Conversion API
 [Expand]API Reference
[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: Create Sparklines

All sparklines in a worksheet are organized in groups. Each group can contain one or more sparklines of the same type that share identical formatting settings and axis scaling options. To create a new group of sparklines, get access to the worksheet's SparklineGroupCollection collection using the Worksheet.SparklineGroups property, and then call the SparklineGroupCollection.Add method. Pass the following parameters.

  • A Range object that specifies a range of cells where the sparkline group should be located. You can either use a continuous one dimensional range, or specify each cell individually by inserting commas between two or more cell references within the Worksheet.Range property.
  • A Range object that specifies the data source for the sparkline group. To add multiple sparklines at once, refer to multiple ranges within the Worksheet.Range property by inserting commas between two or more references, or use the IRangeProvider.Union method to combine multiple ranges into one complex range. Note that a data range for a single sparkline should be a continuous one-dimensional cell range (all cells of which are located in a single row or column). Also, the number of distinct ranges must be equal to the number of cells in the location range (defined by the SparklineGroup.Position property). If the specified cell range is insufficient for a sparkline group, an exception is thrown.
  • A SparklineGroupType enumeration value that specifies the sparkline group type. The table below lists the available types of sparkline groups.

    Sparkline Type

    Enumeration Value

    Description

    Example

    Line

    SparklineGroupType.Line

    Connects sparkline data points with a line.

    Column

    SparklineGroupType.Column

    Creates a series of columns, whose lengths are proportional to the data values they represent.

    Win/Loss

    SparklineGroupType.Stacked

    Creates a series of squares, each of which can occupy one of the following positions:

    • if the data value is positive, the square is displayed at the top of the cell (win);

    • if the value is negative, the square is displayed at the bottom of the cell (loss).

To add a new sparkline to the existing group, access the collection of all sparklines contained in this group by using the SparklineGroup.Sparklines property, and call the SparklineCollection.Add method. This method allows you to define a cell at the intersection of the specified row and column where the new sparkline should be located and the cell range containing the source data for this sparkline.

Expanded See Also

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