Knowledgebase
Knowledgebase
How to Offset a Series
Posted by Andrew BT on 12 February 2019 10:51 AM

## Series Offsetting or Scaling

This gets asked a lot, so we created a short KB article on it.

There are two ways to do this with SciChart. The first one is to use the DataSeries API that allows to Insert or Update data points using appropriate methods. The second is to use the Filters API.

## What is the Filters API?

This is a rich API that provides a way to create derived data, filters, indicators or perform functions on data easily and simply. There is a number of filters available out-of-the-box:

and others. Also there is a bunch of extension methods for convenient use of built-in filters.

## Scale and Offset Filters

To offset a Data Series, use the following code:

```using SciChart.Charting.Model.Filters; // Required for extension method .Offset()

var dataSeries = new XyDataSeries<double,double>(); // Original Data
dataSeries.Append(0,1);
dataSeries.Append(2,2);

var offsetDataSeries = dataSeries.Offset(10d); // Offset data.

var lineRenderableSeries = new FastLineRenderableSeries()
{
DataSeries = offsetDataSeries, // Apply the Offset Data to a Line Series
}```

To scale (multiply by a scalar) a Data Series, use the following code:

```using SciChart.Charting.Model.Filters; // Required for extension method .Scale()

var dataSeries = new XyDataSeries<double,double>(); // Original Data
dataSeries.Append(0,1);
dataSeries.Append(2,2);

var scaledDataSeries = dataSeries.Scale(0.5d); // Scale data.

var lineRenderableSeries = new FastLineRenderableSeries()
{
DataSeries = scaledDataSeries, // Apply the Scale Data to a Line Series
}```

There is a couple of examples available in the SciChart Examples Suite at 2D Charts -> Filters API:

(0 vote(s))