Pre loader

Auto Scroll Time Axis MVVM non FIFO

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

1
0

Could you please tell me how I can get the chart to autoscroll as new data is added in realtime on a non FIFO Time Axis?

I have seen you example using a numeric axis in your examples using SciStockChart which has a XAxisVisibleRange that you bind onto

                if (XVisibleRange.Max > ds0.Count)
                {
                    var existingRange = _xVisibleRange;
                    var newRange = new IndexRange(existingRange.Min + 1, existingRange.Max + 1);
                    XVisibleRange = newRange;
                }

But I am not using a stock chart, and am using a time Axis

I thought it would have been sometthng like

           IRange range = XAxis.VisibleRange;
            if (endTime > (DateTime)XAxis.VisibleRange.Max)
            {
                TimeSpan ts = endTime - startTime;
                var existingRange = _xAxis.VisibleRange;

                var newRange = new IndexRange((DateTime)existingRange.Min + ts, (DateTime)existingRange.Max + ts);
                XVisibleRange = newRange;
            }

there is also a problem that it won’t let me get at XAxis.VisibleRange as it says it was created on different thread. I have tried using BeginInvoke etc but it still complains about it being on a different thread

  • You must to post comments
0
0

Update: Jan 2015

We’ve added another example ‘How to create a Scrolling Strip Chart in SciChart‘ which uses a similar technique to above to manipulate VisibleRange and achieve a scrolling StripChart effect that works with modifiers, and without FIFO DataSeries.

enter image description here

Hope this helps people looking for similar solutions!

Best regards,
Andrew

  • You must to post comments
0
0

Problem Solved I think

Ok I have sorted it myself, the problem was that I wasn’t using the right dispatcher, I needed to use the one from the application

   void UpdateXScaleForScroll()
    {
        DateTime VisMax = (DateTime)XAxis.VisibleRange.Max;
        DateTime ActMax = (DateTime)SeriesSource[0].DataSeries.XMax;
        if (ActMax > VisMax)
        {
            DateRange range = (DateRange)XAxis.VisibleRange;
            TimeSpan ts = ActMax - VisMax;
            DateRange existingRange = (DateRange)_xAxis.VisibleRange;
            DateRange newRange = new DateRange((DateTime)existingRange.Min + ts, (DateTime)existingRange.Max + ts);
            XAxis.VisibleRange = newRange;
        }
    }

Call in my timer event

 if (Application.Current != null)
                {
                    Application.Current.Dispatcher.Invoke(new Action(UpdateXScaleForScroll));
                }
  • Andrew Burnett-Thompson
    Glad you got this sorted. Yes - any DependencyProperty in SciChart must be called on the UI thread. The DataSeries are not DependencyObjects so feel free to Append on background threads! Best regards, Andrew
  • 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