Version

Interpolating Unknown Values

Purpose

This topic explains, with code examples, how to implement interpolation of unknown values in XamSparkline™.

Required Background

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

Topic Purpose

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

This topic provides an overview of the possible ways to configure the XamSparkline control. Links to the detailed configurations (available in separate topics) are provided as well.

Interpolating Unknown Values – Conceptual Overview

Overview

With the Interpolating Unknown Values feature, XamSparkline can detect unknown values (Null or double.NaN`)` and render the space for the unknown values through a specified interpolation algorithm. If your data contains such values and you do not use this feature, meaning no Interpolation is specified, the unknown value will not be plotted.

If you have unknown values in your data set, the Interpolating Unknown Values feature provides you with the following options:

  • To interpolate the unknown values linearly connecting the data point before the null value point to the data point after the null value point.

  • Not to plot the unknown values – instead, a blank point will be inserted for any null value that exists in the data collection.

Note
Note:

For the linear interpolation option (the first one above) to work for a data point, the previous and next data points should both exist. If, for instance, the null value happens to be the first value in the collection there will be no previous point to connect to and, as a result, the null value will be presented as a blank point. The same is true if the last data point is null.

The Interpolating Unknown Values feature is both enabled and set (in terms of type of interpolation) by the UnknownValuePlotting property (See the Property settings block).

Data Requirements

Only Null or double.NaN values are considered unknown. The expected value types are the numeric values such as integer or double. Non-numeric values are not considered unknown.

Property settings

The following table maps the XamSparkline interpolation option to the UnknownValuePlotting property settings that deliver them.

Interpolation option UnknownValuePlotting property setting

Linear interpolation

LinearInterpolate

Not to plot the unknown values

DontPlot

Example

The screenshot below demonstrates a Sparkline rendered from the same data set but using different settings of the UnknownValuePlotting property:

Property Value

DontPlot

Sparkline Visual Elements 28.png
Property Value

LinearInterpolate

Interpolating Unknown Values 2.png

Interpolating Unknown Values – Code Example

Description

The code below demonstrates handling unknown values using the linear interpolation option.

Code

In XAML:

<ig:XamSparkline Name="XamSparkline1" UnknownValuePlotting="LinearInterpolate"/>

In C#:

this.XamSparkline1.UnknownValuePlotting = UnknownValuePlotting.LinearInterpolate;

In Visual Basic:

Me.XamSparkline1.UnknownValuePlotting = UnknownValuePlotting.LinearInterpolate

Related Content

The following topics provide additional information related to this topic.

Topic Purpose

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

This topic provides an overview of the possible ways to configure the XamSparkline control. Links to the detailed configurations (available in separate topics) are provided as well.

This topic explains the featured properties of the XamSparkline control.