SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy

We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

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

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
    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
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
Showing 2 results
Your Answer

Please first to submit.