Pre loader

Fixed extents Real-time Data Series with Zoom

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
0
0

I’ve been trying a few ways to get this to work now and I’m still struggling to get a catch-all solution.

My requirements are:
– self-scrolling real-time data series with a fixed-time range (regardless of the number of points)
– y axis should support either fixed or automatic visual range
– support rubber band zoom (and ideally mousewheel too) on both axes

The key problem is that the stock ticker example doesn’t have a fixed time width. The points are added to the chart, and the axis expands until it reaches capacity. It’s also relatively easy to use FifoCapacity (adding a lot of NaN points), but FifoCapacity works on number of points, which isn’t great when you have irregular updates. I’m happy with the chart not scrolling until a new update is received, but the range of the chart must be fixed (say, five minutes), regardless of the number of visible points on the chart.

My current solution involves deriving from XyDataSeries to duplicate the FifoCapacity behaviour for a fixed time:

   public class RealTimeXyDataSeries<T> : XyDataSeries<DateTime, T>
            where T : IComparable
{
    public TimeSpan _limit;

    public TimeSpan Limit
    {
        get { return _limit; }
        set
        {
            _limit = value;
            Update();
        }
    }

    public RealTimeXyDataSeries(TimeSpan limit)
    {
        Limit = limit;
    }

    public override void Append(DateTime x, T y)
    {
        base.Append(x, y);

        Update();
    }

    public void Update()
    {
        if ((DateTime)XMax == DateTime.MinValue) return;

        var c = 0;

        while (XValues[c] < (DateTime) XMax - Limit) c++;

        if (c <= 0) return;

        RemoveRange(0, c);
    }
}

That takes care of removing points, but doesn’t deal with the range issue. To deal with that, I have some code in my codebehind to set the XAxis VisibleRange on every update, which feels a bit nasty. I wanted to create a RealTimeDateTimeAxis, but none of the relevant functions are override/virtual.

I also took the implementation of RubberBandXyZoomModifierEx from the knowledge base, with some modifications to deal with Y-Axis zoom/reset based on it’s AutoRange setting. However, this involves setting the Y-Axis AutoRange state back to a saved value, and I keep seeing MouseModifierUp events after my DoubleClick events, which resets AutoRange back to Never.

It feels like I’m doing a lot of work in a lot of places to get this to work, and it’s resulting in complex code and buggy behaviours; I’m not comfortable handing this over to another engineer in the current state.

Is there a better way to do this?

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

Hi Rick

Have you also seen our tutorial (which is new!) Adding Realtime Updates.

This presents a way to have realtime + zoom working at the same time as autorange.

Also the final Tutorial Linking Multiple Charts shows how to put it all together with two charts, rollovers, annotations, realtime ranging and mouse-zooming.

Best regards,
Andrew

  • Rick C
    Brilliant!
  • You must to post comments
0
0
  • Rick C
    Okay so this sort of seems to handle some questions, but it doesn’t solve the duplicated mouse events issue. This issue also has ramifications for setting the ParentSurface.ZoomState property; it keeps being reset back to UserZooming.
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies