Pre loader

Two FastLineRenderableSeries displayed delayed

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
1
0

Hello everybody,

Having two FastLineRenderableSeries objects, how can I display them on the same chart, where the X axis represents the time, but the second one with a small time delay on the x-axis (shifted)? Thanks.

Version
6.0.357
  • You must to post comments
Best Answer
0
0

Hi Marius

This can be achieved with our Filters API.

We already have an Offset filter but this only offsets in the Y-direction.

Offsetting in the X-direction could be achieved by writing a custom filter. For example, try this:

/// To create a custom filter, inherit FilterBase and override FilterALl. For best performance, you can also override FilterOnAppend
/// </summary>
public class OffsetXFilter : FilterBase
{
    private readonly XyDataSeries<TimeSpan, double> _originalDataSeries;
    private readonly XyDataSeries<TimeSpan, double> _filteredDataSeries = new XyDataSeries<TimeSpan, double>();
    public OffsetXFilter(XyDataSeries<TimeSpan, double> originalDataSeries, TimeSpan offset) : base(originalDataSeries)
    {
        _originalDataSeries = originalDataSeries;
        // Store a reference in the base class to the FilteredDataSeries
        FilteredDataSeries = _filteredDataSeries;
        XOffset = offset;
        // Update the filter
        FilterAll();
    }

    public TimeSpan XOffset { get; set; }

    protected override void FilterOnAppend(int index)
    {
        // Override FilterOnAppend to update just the latest data-point in _filteredDataSeries for a more efficient filter
        base.FilterOnAppend(index);
    }
    protected override void FilterOnInsert(int startIndex, int count)
    {
        // Override FilterOnInsert to update just the inserted data-point in _filteredDataSeries for a more efficient filter
        base.FilterOnInsert(startIndex, count);
    }
    protected override void FilterOnRemove(int startIndex, int count)
    {
        // Override FilterOnRemove to update just the removed data-point in _filteredDataSeries for a more efficient filter
        base.FilterOnRemove(startIndex, count);
    }
    protected override void FilterOnUpdate(int index)
    {
        // Override FilterOnUpdate to update just the updated data-point in _filteredDataSeries for a more efficient filter
        base.FilterOnUpdate(index);
    }
    public override void FilterAll()
    {
        // When FilterAll is called, recreate the FilteredDataSeries and apply the filtering.
        _filteredDataSeries.Clear();

        for (int i = 0; i < _originalDataSeries.Count; i++)
        {
            _filteredDataSeries.Append(_originalDataSeries.XValues[i] + XOffset, _originalDataSeries.YValues[i]);
        }
    }
}

Note: The above is not the most performant solution, as it will update the entire Offset filtered dataseries on every change of the underlying series. For optimal results, consider overriding the other functions like filterOnAppend, filterOnRemove etc

Best regards
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.