Version

Series Error Bars

This topic introduces the Error Bars feature of the XamDataChart™ control and explains, with code examples, how to display error bars on supported series.

Overview

The topic is organized as follows:

Introduction

Error bars are visual representation of the variability of data plotted in the Data Chart using Series objects. They are often used on charts to show an error or uncertainty in data. In general, they provide visualization of how accurate data measurements are or how far the true values could be from the measured values.

Requirements

In XamDataChart, the length of error bars is calculated using the Infragistics Math Calculators™ and the following NuGet packages must be added to a WPF project before error bars can be displayed on data points.

NuGet Package Description

Infragistics.WPF.Math.Calculators

Ultimate UI for WPF NuGet package containing mathematical calculators to compute error bars, correlation, mean, median, variance and many more mathematical values.

Infragistics.WPF.Math

Ultimate UI for WPF NuGet package containing standard mathematical constants and all-purpose mathematical functions designed to act on a variety of mathematical objects.

Infragistics.WPF.Charts

Ultimate UI for WPF NuGet package containing the XamDataChart control and various types of Series and Axes for plotting data.

Supported Types of Series

This section provides a list of series types that support error bars in the Data Chart control.

Table 1 – Supported Types of Series

Type of Series Supported Error Bars Preview
  • AreaSeries

  • ColumnSeries

  • LineSeries

  • SplineSeries

  • SplineAreaSeries

  • StepAreaSeries

  • StepLineSeries

Vertical Error Bars

xamDataChart Series Error Bars  01.png

Figure 1 – Category Series with Error Bars

  • ScatterSeries

  • ScatterLineSeries

  • ScatterSplineSeries

Horizontal Error Bars

Vertical Error Bars

xamDataChart Series Error Bars  02.png

Figure 2 – Scatter Series with Error Bars

Note
Note:

Error bars are not supported by stacked or range types of series in the group of the Category Series .

Types of Error Bars

The Data Chart supports a number of types of error bars that are listed in the Table 2 below. The length of error bars is calculated using the Infragistics Math Calculators that implements the IErrorBarCalculator interface.

Table 2 – Types of Error Bars

Type of Error Bars Description

Fixed Value Error Bars

The length of these error bars is equal to a fixed value bound to the Value property of the Infragistics Fixed Value Calculator.

Percentage Error Bars

The length of these error bars is equal a percentage value bound to the Value property of the Infragistics Percentage Calculator.

Standard Error Bars

The length of these error bars is calculated using the standard error of a set of data bound to the ItemsSource property of the Infragistics Standard Error Calculator.

Standard Deviation Error Bars

The length of these error bars is calculated using the standard deviation of a set of data bound to the ItemsSource property of the Infragistics Standard Deviation Calculator.

Custom Data Error Bars

The length of these error bars is provided by arbitrary or custom values in a set of data bound to the ItemsSource property of Infragistics Data Calculator.

Error Bars Properties

Category Error Bars Properties

The following table provides overview of properties relevant to error bars for all series in the Category Series group.

Property Name Property Type Description

CategorySeries. ErrorBarSettings

Gets or sets the settings of error bars on a Category Series.

CategoryErrorBarSettings. EnableErrorBars

Gets or sets the enumeration value that specifies the display type of the error bars:

Both – Displays both positive and negative error bars

Positive – Displays only positive error bars (above data points)

Negative – Displays only negative error bars(below data points)

None – Hides all error bars

CategoryErrorBarSettings. ErrorBarCapLength

Int

Gets or sets the cap length of the error bars.

CategoryErrorBarSettings. StrokeThickness

Double

Gets or sets the thickness of the error bars.

CategoryErrorBarSettings. Stroke

Brush

Gets or sets the stoke brush of the error bars.

CategoryErrorBarSettings. Calculator

Gets or sets a calculator used for calculating values of the error bars:

DataCalculator – Provides arbitrary or custom values for the error bars

FixedValueCalculator – Generates error bars with length equal to a fixed value bound to the Value property of the Calculator.

PercentageCalculator – Generates error bars with length equal to a percentage value bound to the Value property of the calculator.

StandardDeviationCalculator – Calculates error bars based on the standard deviation of all data items bound to the ItemsSource property of the calculator.

StandardErrorCalculator – Calculates error bars based on the standard error of a set of data bound to the ItemsSource property of the calculator.

Scatter Error Bars Properties

The following table provides overview of properties relevant to error bars for all series in the Scatter Series group.

Property Name Property Type Description

ScatterBase. ErrorBarSettings

Gets or sets the settings of horizontal error bars on a Scatter Series.

ScatterErrorBarSettings. EnableErrorBarsHorizontal

Gets or sets the enumeration value that specifies the display type of the horizontal error bars:

Both – Displays both positive and negative error bars

Negative –Displays only negative error bars (on the left side of data points)

Positive – Displays only positive error bars (on the right side of data points)

None – Hides all error bars

ScatterErrorBarSettings. HorizontalErrorBarCapLength

Int

Gets or sets the cap length of the horizontal error bars.

ScatterErrorBarSettings. HorizontalStrokeThickness

Double

Gets or sets the thickness of the horizontal error bars.

ScatterErrorBarSettings. HorizontalStroke

Brush

Gets or sets the stoke brush of the horizontal error bars.

ScatterErrorBarSettings. HorizontalCalculator

Gets or sets a calculator used for calculating values of the horizontal error bars:

DataCalculator – Provides arbitrary or custom values for the error bars

FixedValueCalculator – Generates error bars with length equal to a fixed value bound to the Value property of the Calculator.

PercentageCalculator – Generates error bars with length equal to a percentage value bound to the Value property of the calculator.

StandardDeviationCalculator – Calculates error bars based on the standard deviation of all data items bound to the ItemsSource property of the calculator.

StandardErrorCalculator – Calculates error bars based on the standard error of a set of data bound to the ItemsSource property of the calculator.

ScatterErrorBarSettings. HorizontalCalculatorReference

Gets or sets the enumeration value that specifies the reference value for the PercentageCalculator bound to the HorizontalCalculator property:

X – Specifies the X member as the reference value for calculation of horizontal error bars

Y – Specifies the Y member as the reference value for calculation of horizontal error bars

ScatterErrorBarSettings. HorizontalErrorBarStyle

Style

Gets or sets the style of the horizontal error bars

ScatterErrorBarSettings. EnableErrorBarsVertical

Gets or sets the enumeration value that specifies the display type of the vertical error bars:

Both – Displays both positive and negative error bars

Positive – Displays only positive error bars (above data points)

Negative – Displays only negative error bars (below data points)

None – Hides all error bars

ScatterErrorBarSettings. VerticalErrorBarCapLength

Int

Gets or sets the cap length of the vertical error bars

ScatterErrorBarSettings. VerticalStrokeThickness

Double

Gets or sets the thickness of the vertical error bars

ScatterErrorBarSettings. VerticalStroke

Brush

Gets or sets the stoke brush of the vertical error bars

ScatterErrorBarSettings. VerticalCalculator

Gets or sets a calculator used for calculating values of the vertical error bars:

DataCalculator – Provides arbitrary or custom values for the error bars

FixedValueCalculator – Generates error bars with length equal to a fixed value bound to the Value property of the calculator.

PercentageCalculator – Generates error bars with length equal to a percentage value bound to the Value property of the calculator.

StandardDeviationCalculator – Calculates error bars based on the standard deviation of all data items bound to the ItemsSource property of the calculator.

StandardErrorCalculator – Calculates error bars based on the standard error of a set of data bound to the ItemsSource property of the calculator.

ScatterErrorBarSettings. VerticalCalculatorReference

Gets or sets the enumeration value that specifies the reference value for the PercentageCalculator bound to the VerticalCalculator property:

X – Specifies the X member as the reference value for calculation of vertical error bars

Y – Specifies the Y member as the reference value for calculation of vertical error bars

ScatterErrorBarSettings. VerticalErrorBarStyle

Style

Gets or sets the style of the vertical error bars.

Examples

This section provides code examples for displaying various types of error bars on series in the Data Chart control.

Category Series with Fixed Value Error Bars

The following code listing demonstrates how to display the Fixed Value Error Bars on the LineSeries.

In XAML:

xmlns:ig="http://schemas.infragistics.com/xaml"
xmlns:igCalc=http://schemas.infragistics.com/xaml

In XAML:

<ig:LineSeries.ErrorBarSettings>
    <ig:ScatterErrorBarSettings EnableErrorBars="Both" >
        <ig:CategoryErrorBarSettings.Calculator>
            <igCalc:FixedValueCalculator Value="10" />
        </ig:CategoryErrorBarSettings.Calculator>
    </ig:ScatterErrorBarSettings>
</ig:LineSeries.ErrorBarSettings>

In Visual Basic:

Imports Infragistics.Controls.Charts
Imports Infragistics.Math.Calculators
'...
Dim barsSettings As New CategoryErrorBarSettings()
barsSettings.EnableErrorBars = EnableErrorBars.Both
barsSettings.Calculator = New FixedValueCalculator()
barsSettings.Calculator.Value = 10.0
'...
Dim series As New LineSeries()
'...
series.ErrorBarSettings = barsSettings

In C#:

using Infragistics.Controls.Charts;
using Infragistics.Math.Calculators;
//...
CategoryErrorBarSettings barsSettings = new CategoryErrorBarSettings();
barsSettings.EnableErrorBars = EnableErrorBars.Both;
barsSettings.Calculator = new FixedValueCalculator();
barsSettings.Calculator.Value = 10.0;
//...
LineSeries series = new LineSeries();
//...
series.ErrorBarSettings = barsSettings;
xamDataChart Series Error Bars  03.png

Figure 3 - Line Series with the Fixed Value Error Bars

Category Series with Percentage Error Bars

The following code listing demonstrates how to display the Percentage Error Bars on the LineSeries.

In XAML:

<ig:LineSeries.ErrorBarSettings>
    <ig:ScatterErrorBarSettings EnableErrorBars="Both" >
        <ig:CategoryErrorBarSettings.Calculator>
            <igCalc:PercentageCalculator Value="10" />
        </ig:CategoryErrorBarSettings.Calculator>
    </ig:ScatterErrorBarSettings>
</ig:LineSeries.ErrorBarSettings>

In Visual Basic:

Imports Infragistics.Controls.Charts
Imports Infragistics.Math.Calculators
'...
Dim barsSettings As New CategoryErrorBarSettings()
barsSettings.EnableErrorBars = EnableErrorBars.Both
barsSettings.Calculator = New PercentageCalculator()
barsSettings.Calculator.Value = 10.0
'...
Dim series As New LineSeries()
'...
series.ErrorBarSettings = barsSettings

In C#:

using Infragistics.Controls.Charts;
using Infragistics.Math.Calculators;
//...
CategoryErrorBarSettings barsSettings = new CategoryErrorBarSettings();
barsSettings.EnableErrorBars = EnableErrorBars.Both;
barsSettings.Calculator = new PercentageCalculator();
barsSettings.Calculator.Value = 10.0;
//...
LineSeries series = new LineSeries();
//...
series.ErrorBarSettings = barsSettings;
xamDataChart Series Error Bars  04.png

Figure 3 - Line Series with the Percentage Error Bars

Category Series with Standard Error Bars

The following code listing demonstrates how to display the Standard Error Bars on the LineSeries.

Note
Note:

The same dataset should be bound to the series object as well as to the StandardErrorCalculator using their ItemsSource properties in order to calculate error bars for all data points. You can download a sample set of data from the Category Data Sample resource.

In XAML:

<ig:LineSeries.ErrorBarSettings>
    <ig:ScatterErrorBarSettings EnableErrorBars="Both" >
        <ig:CategoryErrorBarSettings.Calculator>
            <igCalc:StandardErrorCalculator ItemsSource="{StaticResource CategoryData}" ValueMemberPath="Value" />
        </ig:CategoryErrorBarSettings.Calculator>
    </ig:ScatterErrorBarSettings>
</ig:LineSeries.ErrorBarSettings>

In Visual Basic:

Imports Infragistics.Controls.Charts
Imports Infragistics.Math.Calculators
'...
Dim series As New LineSeries()
'...
Dim barsSettings As New CategoryErrorBarSettings()
barsSettings.EnableErrorBars = EnableErrorBars.Both
barsSettings.Calculator = New StandardErrorCalculator()
barsSettings.Calculator.ItemsSource = series.ItemsSource
barsSettings.Calculator.ValueMemberPath = "Value"
'...
series.ErrorBarSettings = barsSettings

In C#:

using Infragistics.Controls.Charts;
using Infragistics.Math.Calculators;
//...
LineSeries series = new LineSeries();
//...
CategoryErrorBarSettings barsSettings = new CategoryErrorBarSettings();
barsSettings.EnableErrorBars = EnableErrorBars.Both;
barsSettings.Calculator = new StandardErrorCalculator();
barsSettings.Calculator.ItemsSource = series.ItemsSource;
barsSettings.Calculator.ValueMemberPath = "Value";
//...
series.ErrorBarSettings = barsSettings;
xamDataChart Series Error Bars  05.png

Figure 3 - Line Series with the Standard Error Bars

Category Series with Standard Deviation Error Bars

The following code listing demonstrates how to display the Standard Deviation Error Bars on the LineSeries.

Note
Note:

The same dataset should be bound to the series object as well as to the StandardDeviationCalculator using their ItemsSource properties in order to calculate error bars for all data points. You can download a sample set of data from the Category Data Sample resource.

In XAML:

<ig:LineSeries.ErrorBarSettings>
    <ig:ScatterErrorBarSettings EnableErrorBars="Both" >
        <ig:CategoryErrorBarSettings.Calculator>
            <igCalc:StandardDeviationCalculator ItemsSource="{StaticResource CategoryData}" ValueMemberPath="Value" />
        </ig:CategoryErrorBarSettings.Calculator>
    </ig:ScatterErrorBarSettings>
</ig:LineSeries.ErrorBarSettings>

In Visual Basic:

Imports Infragistics.Controls.Charts
Imports Infragistics.Math.Calculators
'...
Dim series As New LineSeries()
'...
Dim barsSettings As New CategoryErrorBarSettings()
barsSettings.EnableErrorBars = EnableErrorBars.Both
barsSettings.Calculator = New StandardDeviationCalculator()
barsSettings.Calculator.ItemsSource = series.ItemsSource
barsSettings.Calculator.ValueMemberPath = "Value"
'...
series.ErrorBarSettings = barsSettings

In C#:

using Infragistics.Controls.Charts;
using Infragistics.Math.Calculators;
//...
LineSeries series = new LineSeries();
//...
CategoryErrorBarSettings barsSettings = new CategoryErrorBarSettings();
barsSettings.EnableErrorBars = EnableErrorBars.Both;
barsSettings.Calculator = new StandardDeviationCalculator();
barsSettings.Calculator.ItemsSource = series.ItemsSource;
barsSettings.Calculator.ValueMemberPath = "Value";
//...
series.ErrorBarSettings = barsSettings;
xamDataChart Series Error Bars  06.png

Figure 3 - Line Series with the Standard Deviation Error Bars

Category Series with Custom Data Error Bars

The following code listing demonstrates how to display Custom Data Error Bars on the LineSeries. Values for the Custom Data Error Bars are provided by a set of data bound to the ItemsSource property of the DataCalculator.

Note
Note:

The following code provides sample logic for generating values for Custom Data Error Bars. You need to add it to your project or provide your own values for data error bars.

In Visual Basic:

Imports System.Collections.ObjectModel
'...
Public Class ErrorBarDataSample
    Inherits ErrorBarDataCollection
    Public Sub New()
        Me.New(0.1, 100)
    End Sub
    Public Sub New(variable As Double, items As Integer)
        Dim value As Double = 0
        For i As Integer = 0 To items - 2
            Dim dataPoint As New ErrorBarDataPoint()
            dataPoint.Value = value
            Me.Add(dataPoint)
            If i < (items / 2) Then
                value += variable
            Else
                value -= variable
            End If
        Next
    End Sub
End Class
Public Class ErrorBarDataCollection
    Inherits ObservableCollection(Of ErrorBarDataPoint)
End Class
Public Class ErrorBarDataPoint
    Public Property Value() As Double
        Get
            Return value
        End Get
        Set
            _value = Value
        End Set
    End Property
    Private value As Double
End Class

In C#:

using System.Collections.ObjectModel;
//...
public class ErrorBarDataSample : ErrorBarDataCollection
{
    public ErrorBarDataSample(): this(0.1, 100)
    { }
    public ErrorBarDataSample(double variable, int items)
    {
        double value = 0;
        for (int i = 0; i < items - 1; i++)
        {
            ErrorBarDataPoint dataPoint = new ErrorBarDataPoint();
            dataPoint.Value = value;
              this.Add(dataPoint);
              if (i < (items / 2)) value += variable; else value -= variable;
        }
    }
}
public class ErrorBarDataCollection : ObservableCollection<ErrorBarDataPoint>
{ }
public class ErrorBarDataPoint
{
    public double Value { get; set; }
}

In XAML:

<ig:LineSeries.ErrorBarSettings>
    <ig:ScatterErrorBarSettings EnableErrorBars="Both" >
        <ig:CategoryErrorBarSettings.Calculator>
            <igCalc:DataCalculator ItemsSource="{StaticResource ErrorBarData}" ValueMemberPath="Value" />
        </ig:CategoryErrorBarSettings.Calculator>
    </ig:ScatterErrorBarSettings>
</ig:LineSeries.ErrorBarSettings>

In Visual Basic:

Imports Infragistics.Controls.Charts
Imports Infragistics.Math.Calculators
'...
Dim series As New LineSeries()
'...
Dim errorBarsData As New ErrorBarDataSample()
Dim barsSettings As New CategoryErrorBarSettings()
barsSettings.EnableErrorBars = EnableErrorBars.Both
barsSettings.Calculator = New DataCalculator()
barsSettings.Calculator.ItemsSource = errorBarsData
barsSettings.Calculator.ValueMemberPath = "Value"
'...
series.ErrorBarSettings = barsSettings

In C#:

using Infragistics.Controls.Charts;
using Infragistics.Math.Calculators;
//...
LineSeries series = new LineSeries();
//...
ErrorBarDataSample errorBarsData = new ErrorBarDataSample();
CategoryErrorBarSettings barsSettings = new CategoryErrorBarSettings();
barsSettings.EnableErrorBars = EnableErrorBars.Both;
barsSettings.Calculator = new DataCalculator();
barsSettings.Calculator.ItemsSource = errorBarsData
barsSettings.Calculator.ValueMemberPath = "Value"
//...
series.ErrorBarSettings = barsSettings;
xamDataChart Series Error Bars  07.png

Figure 3 - Line Series with the Custom Data Error Bars

Scatter Series with Fixed Value Error Bars

The following code listing demonstrates how to display the Fixed Value Error Bars on the ScatterSeries.

In XAML:

<ig:ScatterSeries.ErrorBarSettings>
    <ig:ScatterErrorBarSettings EnableErrorBarsHorizontal="Both"
                                EnableErrorBarsVertical="Both" >
        <ig:ScatterErrorBarSettings.HorizontalCalculator>
            <igCalc:FixedValueCalculator Value="2" />
        </ig:ScatterErrorBarSettings.HorizontalCalculator>
        <ig:ScatterErrorBarSettings.VerticalCalculator>
            <igCalc:FixedValueCalculator Value="20" />
        </ig:ScatterErrorBarSettings.VerticalCalculator>
    </ig:ScatterErrorBarSettings>
</ig:ScatterSeries.ErrorBarSettings>

In Visual Basic:

Imports Infragistics.Controls.Charts
Imports Infragistics.Math.Calculators
'...
Dim barsSettings As New ScatterErrorBarSettings()
barsSettings.EnableErrorBarsHorizontal = EnableErrorBars.Both
barsSettings.HorizontalCalculator = New FixedValueCalculator()
barsSettings.HorizontalCalculator.Value = 2.0
'...
barsSettings.EnableErrorBarsVertical = EnableErrorBars.Both
barsSettings.VerticalCalculator = New FixedValueCalculator()
barsSettings.VerticalCalculator.Value = 20.0
'...
Dim series As New ScatterSeries()
'...
series.ErrorBarSettings = barsSettings

In C#:

using Infragistics.Controls.Charts;
using Infragistics.Math.Calculators;
//...
ScatterErrorBarSettings barsSettings = new ScatterErrorBarSettings();
barsSettings.EnableErrorBarsHorizontal = EnableErrorBars.Both;
barsSettings.HorizontalCalculator = new FixedValueCalculator();
barsSettings.HorizontalCalculator.Value = 2.0;
//...
barsSettings.EnableErrorBarsVertical = EnableErrorBars.Both;
barsSettings.VerticalCalculator = new FixedValueCalculator();
barsSettings.VerticalCalculator.Value = 20.0;
//...
ScatterSeries series = new ScatterSeries();
//...
series.ErrorBarSettings = barsSettings;
xamDataChart Series Error Bars  08.png

Figure 3 - Scatter Series with the Fixed Value Error Bars

Scatter Series with Percentage Error Bars

The following code listing demonstrates how to display the Percentage Error Bars on the ScatterSeries.

In XAML:

<ig:ScatterSeries.ErrorBarSettings>
    <ig:ScatterErrorBarSettings EnableErrorBarsHorizontal="Both"
                                EnableErrorBarsVertical="Both" >
        <ig:ScatterErrorBarSettings.HorizontalCalculator>
            <igCalc:PercentageCalculator Value="5" />
        </ig:ScatterErrorBarSettings.HorizontalCalculator>
        <ig:ScatterErrorBarSettings.VerticalCalculator>
            <igCalc:PercentageCalculator Value="10" />
        </ig:ScatterErrorBarSettings.VerticalCalculator>
    </ig:ScatterErrorBarSettings>
</ig:ScatterSeries.ErrorBarSettings>

In Visual Basic:

Imports Infragistics.Controls.Charts
Imports Infragistics.Math.Calculators
'...
Dim barsSettings As New ScatterErrorBarSettings()
barsSettings.EnableErrorBarsHorizontal = EnableErrorBars.Both
barsSettings.HorizontalCalculatorReference = ErrorBarCalculatorReference.X
barsSettings.HorizontalCalculator = New PercentageCalculator()
barsSettings.HorizontalCalculator.Value = 5.0
'...
barsSettings.EnableErrorBarsVertical = EnableErrorBars.Both
barsSettings.VerticalCalculatorReference = ErrorBarCalculatorReference.Y
barsSettings.VerticalCalculator = New PercentageCalculator()
barsSettings.HorizontalCalculator.Value = 10.0
'...
Dim series As New ScatterSeries()
'...
series.ErrorBarSettings = barsSettings

In C#:

using Infragistics.Controls.Charts;
using Infragistics.Math.Calculators;
//...
ScatterErrorBarSettings barsSettings = new ScatterErrorBarSettings();
barsSettings.EnableErrorBarsHorizontal = EnableErrorBars.Both;
barsSettings.HorizontalCalculatorReference = ErrorBarCalculatorReference.X;
barsSettings.HorizontalCalculator = new PercentageCalculator();
barsSettings.HorizontalCalculator.Value = 5.0;
//...
barsSettings.EnableErrorBarsVertical = EnableErrorBars.Both;
barsSettings.VerticalCalculatorReference = ErrorBarCalculatorReference.Y;
barsSettings.VerticalCalculator = new PercentageCalculator();
barsSettings.HorizontalCalculator.Value = 10.0;
//...
ScatterSeries series = new ScatterSeries();
//...
series.ErrorBarSettings = barsSettings;
xamDataChart Series Error Bars  09.png

Figure 4 - Scatter Series with the Percentage Error Bars

Scatter Series with Standard Error Bars

The following code listing demonstrates how to display the Standard Error Bars on the ScatterSeries.

Note
Note:

The same dataset should be bound to the Series as well as to the StandardErrorCalculator using their ItemsSource properties in order to calculate error bars for all data points. You can download a sample set of data from the Scatter Data Sample resource.

In XAML:

<ig:ScatterSeries.ErrorBarSettings>
    <ig:ScatterErrorBarSettings EnableErrorBarsHorizontal="Both" >
        <ig:ScatterErrorBarSettings.HorizontalCalculator>
            <igCalc:StandardErrorCalculator ItemsSource="{StaticResource ScatterData}" ValueMemberPath="X" />
        </ig:ScatterErrorBarSettings.HorizontalCalculator>
    </ig:ScatterErrorBarSettings>
</ig:ScatterSeries.ErrorBarSettings>

In Visual Basic:

Imports Infragistics.Controls.Charts
Imports Infragistics.Math.Calculators
'...
Dim series As New ScatterSeries()
'...
Dim barsSettings As New ScatterErrorBarSettings()
barsSettings.EnableErrorBarsHorizontal = EnableErrorBars.Both
barsSettings.HorizontalCalculator = New StandardErrorCalculator()
barsSettings.HorizontalCalculator.ItemsSource = series.ItemsSource
barsSettings.HorizontalCalculator.ValueMemberPath = "X"
'...
series.ErrorBarSettings = barsSettings

In C#:

using Infragistics.Controls.Charts;
using Infragistics.Math.Calculators;
//...
ScatterSeries series = new ScatterSeries();
//...
ScatterErrorBarSettings barsSettings = new ScatterErrorBarSettings();
barsSettings.EnableErrorBarsHorizontal = EnableErrorBars.Both;
barsSettings.HorizontalCalculator = new StandardErrorCalculator();
barsSettings.HorizontalCalculator.ItemsSource = series.ItemsSource;
barsSettings.HorizontalCalculator.ValueMemberPath = "X";
 //...
series.ErrorBarSettings = barsSettings;
xamDataChart Series Error Bars  10.png

Figure 4 - Scatter Series with the Standard Error Bars

Scatter Series with Standard Deviation Error Bars

The following code listing demonstrates how to display the Standard Deviation Error Bars on the ScatterSeries.

Note
Note:

The same dataset should be bound to the Series as well as to the StandardDeviationCalculator using their ItemsSource properties in order to calculate error bars for all data points. You can download a sample set of data from the Scatter Data Sample resource.

In XAML:

<ig:ScatterSeries.ErrorBarSettings>
    <ig:ScatterErrorBarSettings EnableErrorBarsVertical="Both" >
        <ig:ScatterErrorBarSettings.VerticalCalculator>
            <igCalc:StandardDeviationCalculator ItemsSource="{StaticResource ScatterData}" ValueMemberPath="Y" />
        </ig:ScatterErrorBarSettings.VerticalCalculator>
    </ig:ScatterErrorBarSettings>
</ig:ScatterSeries.ErrorBarSettings>

In Visual Basic:

Imports Infragistics.Controls.Charts
Imports Infragistics.Math.Calculators
'...
Dim series As New ScatterSeries()
'...
Dim barsSettings As New ScatterErrorBarSettings()
barsSettings.EnableErrorBarsVertical = EnableErrorBars.Both
barsSettings.VerticalCalculator = New StandardDeviationCalculator()
barsSettings.VerticalCalculator.ItemsSource = series.ItemsSource
barsSettings.VerticalCalculator.ValueMemberPath = "Y"
'...
series.ErrorBarSettings = barsSettings

In C#:

using Infragistics.Controls.Charts;
using Infragistics.Math.Calculators;
//...
ScatterSeries series = new ScatterSeries();
//...
ScatterErrorBarSettings barsSettings = new ScatterErrorBarSettings();
barsSettings.EnableErrorBarsVertical = EnableErrorBars.Both;
barsSettings.VerticalCalculator = new StandardDeviationCalculator();
barsSettings.VerticalCalculator.ItemsSource = series.ItemsSource;
barsSettings.VerticalCalculator.ValueMemberPath = "Y";
//...
series.ErrorBarSettings = barsSettings;
xamDataChart Series Error Bars  11.png

Figure 5 - Scatter Series with the Standard Deviation Error Bars

Scatter Series with Custom Data Error Bars

The following code listing demonstrates how to display Custom Data Error Bars on the ScatterSeries. Values for the Custom Data Error Bars are provided by a data set bound to the ItemsSource property of the DataCalculator.

Note
Note:

The following code provides sample logic for generating values for Custom Data Error Bars. You need to add it your project or provide your own values for data error bars.

In Visual Basic:

Imports System.Collections.ObjectModel
'...
Public Class ErrorBarDataSample
    Inherits ErrorBarDataCollection
    Public Sub New()
        Me.New(0.1, 100)
    End Sub
    Public Sub New(variable As Double, items As Integer)
        Dim value As Double = 0
        For i As Integer = 0 To items – 2
            Dim dataPoint As New ErrorBarDataPoint()
            dataPoint.Value = value
            Me.Add(dataPoint)
            If i < (items / 2) Then
                value += variable
            Else
                value -= variable
            End If
        Next
    End Sub
End Class
Public Class ErrorBarDataCollection
    Inherits ObservableCollection(Of ErrorBarDataPoint)
End Class
Public Class ErrorBarDataPoint
    Public Property Value() As Double
        Get
            Return value
        End Get
        Set
            _value = Value
        End Set
    End Property
    Private value As Double
End Class

In C#:

using System.Collections.ObjectModel;
//...
public class ErrorBarDataSample : ErrorBarDataCollection
{
    public ErrorBarDataSample(): this(0.1, 100)
    { }
    public ErrorBarDataSample(double variable, int items)
    {
        double value = 0;
        for (int i = 0; i < items - 1; i++)
        {
            ErrorBarDataPoint dataPoint = new ErrorBarDataPoint();
            dataPoint.Value = value;
              this.Add(dataPoint);
            if (i < (items / 2)) value += variable; else value -= variable;
        }
    }
}
public class ErrorBarDataCollection : ObservableCollection<ErrorBarDataPoint>
{ }
public class ErrorBarDataPoint
{
    public double Value { get; set; }
}

In XAML:

<ig:ScatterSeries.ErrorBarSettings>
    <ig:ScatterErrorBarSettings EnableErrorBarsVertical="Both" >
        <ig:ScatterErrorBarSettings.VerticalCalculator>
            <igCalc:DataCalculator ItemsSource="{StaticResource ErrorBarData}" ValueMemberPath="Value" />
        </ig:ScatterErrorBarSettings.VerticalCalculator>
    </ig:ScatterErrorBarSettings>
</ig:ScatterSeries.ErrorBarSettings>

In Visual Basic:

Imports Infragistics.Controls.Charts
Imports Infragistics.Math.Calculators
'...
Dim series As New ScatterSeries()
'...
Dim errorBarsData As New ErrorBarDataSample(1.5, 100)
Dim barsSettings As New ScatterErrorBarSettings()
barsSettings.EnableErrorBarsVertical = EnableErrorBars.Both
barsSettings.VerticalCalculator = New DataCalculator()
barsSettings.VerticalCalculator.ItemsSource = errorBarsData
barsSettings.VerticalCalculator.ValueMemberPath = "Value"
'...
series.ErrorBarSettings = barsSettings

In C#:

using Infragistics.Controls.Charts;
using Infragistics.Math.Calculators;
//...
ScatterSeries series = new ScatterSeries();
//...
ErrorBarDataSample errorBarsData = new ErrorBarDataSample(1.5, 100);
ScatterErrorBarSettings barsSettings = new ScatterErrorBarSettings();
barsSettings.EnableErrorBarsVertical = EnableErrorBars.Both;
barsSettings.VerticalCalculator = new DataCalculator();
barsSettings.VerticalCalculator.ItemsSource = errorBarsData;
barsSettings.VerticalCalculator.ValueMemberPath = "Value";
//...
series.ErrorBarSettings = barsSettings;
xamDataChart Series Error Bars  12.png

Figure 6 - Scatter Series with Custom Data Error Bars