Version

Sparkline Column

Please note that this control has been retired and is now obsolete to the XamDataGrid control, and as such, we recommend migrating to that control. It will not be receiving any new features, bug fixes, or support going forward. For help or questions on migrating your codebase to the XamDataGrid, please contact support.

Purpose

This topic introduces the Sparkline column type of the xamGrid™ control and demonstrates its use.

Required background

The following table lists the topics required as a prerequisite to understanding this topic.

Topic Purpose

This topic explains how to define and configure columns with the xamGrid control.

Introduction

Sparkline column summary

The Sparkline column type allows the display of a Sparkline chart in a grid cell by inserting the xamSparkline™ control. The xamSparkline is a light-weight charting control capable of displaying data markers for the highest and lowest values, first/last/negative values and markers for all data points. For more information see the xamSparkline Overview topic.

In order to create a sparkline column in the xamGrid control, you need to add the column to the grid using the <ig:SparklineColumn> tag. The column must have the Key property or the ItemsSourcePath property set. If the ItemsSourcePath property is set, the data for the sparkline column is retrieved from that property. If it is not set, then the data for the sparkline column will be retrieved from the Key property. For more information on defining columns, see the Define Column Layout topic.

Requirements

In order to add the Sparkline Column to the XamGrid control, you need to reference the following NuGet package:

  • Infragistics.WPF.Controls.Grids.SparklineColumn

For more information on setting up the NuGet feed and adding NuGet packages, you can take a look at the following documentation: NuGet Feeds.

Configuring a Sparkline Column – Conceptual Overview

Configuring a Sparkline column summary

To configure the Sparkline column, you need to set the data source of the column to a key from the ItemsSource property in the xamGrid . For more information on binding the xamGrid control to data, see the Data Binding topic. Every column in the grid must contain a unique Key from the data source.

To determine which values will be used as the Sparkline data points, you need specify a value from the data source to be used as the data points. This is done by setting the ValueMemberPath property to the desired value.

To display a label on the X axis, you need to specify a value from the data source to be used as label. This is done by setting the LabelMemberPath property to the desired value.

The ItemsSourcePath property allows you to set the data source for the Sparkline. The main advantage to use this property instead of the Key property for the column, is that you can bind more than one Sparkline to the same property.

Property settings

The following table maps the desired configuration/behaviors to property settings.

In order to: Use this property: And set it to:

Set a unique identifier for the column

Key

The column’s Key value. This value must be unique.

Set the data source

A key from the ItemsSource.

Identify the numeric property from the underlying data as the Sparkline data points

A key from the ItemsSource. It should be a non-null value, but can be empty.

Display the label on the X axis (when the horizontal axis is visible)

A key from the ItemsSource

Note
Note

To style the chart and set additional properties, create a Style to be applied to the Sparkline control. For more information on Sparkline chart properties, refer to the xamSparkline Property Reference topic.

Configuring a Sparkline Column – Code Example

Description

The code below demonstrates how to configure a Sparkline column in a xamGrid that visualizes orders on per-company bases.

Property settings

In the example, the Sparkline column is configured with the following settings:

Property Value

Key

Orders

Orders

Quantity

Freight

Preview

Following is a preview of the Sparkline column as generated by the code in this example.

Sparkline Column 1.png

Code

In XAML:

<ig:XamGrid x:Name="dataGrid" AutoGenerateColumns="False" ColumnWidth="*">
   <ig:XamGrid.Columns>
      <ig:TextColumn Key="Company">
         <ig:TextColumn.HeaderTemplate>
            <DataTemplate>
               <TextBlock Text="{Binding Path=XWG_Customers_Company, Source={StaticResource Strings}}" />
            </DataTemplate>
         </ig:TextColumn.HeaderTemplate>
      </ig:TextColumn>
      <ig:TextColumn Key="ContactName">
         <ig:TextColumn.HeaderTemplate>
            <DataTemplate>
               <TextBlock Text="{Binding Path=XWG_Customers_ContactName, Source={StaticResource Strings}}" />
            </DataTemplate>
         </ig:TextColumn.HeaderTemplate>
      </ig:TextColumn>
      <ig:TextColumn Key="Country">
         <ig:TextColumn.HeaderTemplate>
            <DataTemplate>
               <TextBlock Text="{Binding Path=XWG_Customers_Country, Source={StaticResource Strings}}" />
            </DataTemplate>
         </ig:TextColumn.HeaderTemplate>
      </ig:TextColumn>
      <ig:SparklineColumn Key="Orders" ItemsSourcePath="Orders" LabelMemberPath="Freight" ValueMemberPath="Quantity" >
         <ig:SparklineColumn.HeaderTemplate>
            <DataTemplate>
               <TextBlock Text="{Binding Path=XWG_OrderDetails_Quantity, Source={StaticResource Strings}}" />
            </DataTemplate>
         </ig:SparklineColumn.HeaderTemplate>
      </ig:SparklineColumn>
   </ig:XamGrid.Columns>
</ig:XamGrid>

In C#:

SparklineColumn Sparkline_Column = new SparklineColumn();
Sparkline_Column.Key = "Orders";
Sparkline_Column.LabelMemberPath = "Freight";
Sparkline_Column.ValueMemberPath = "Quantity";
Sparkline_Column.ItemsSourcePath = "Orders";
this.dataGrid.Columns.Add(Sparkline_Column);

In Visual Basic:

Dim Sparkline_Column As SparklineColumn = New SparklineColumn
Sparkline_Column.Key = "Orders"
Sparkline_Column.LabelMemberPath = "Freight"
Sparkline_Column.ValueMemberPath = "Quantity"
Sparkline_Column.ItemsSourcePath = "Orders"
Me.dataGrid.Columns.Add(Sparkline_Column)

Related Content

Topics

The following topics provide additional information related to this topic.

Topic Purpose

This section explains the types of Columns available in the xamGrid control.

This topic provides an overview of the xamSparkline control, its benefits, and the supported chart types.