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!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

1
0

I am building a real time chart to display ECG data. I would like to, on the fly, be able to change the amount of time displayed on the x axis. In other words, the user can select the number of seconds of ECG data being displayed. The display sweeps across the time range then throws out old data after the sweep reaches the end of the time range then restarts at the beginning of the chart.

To do this, I am using a Fifo series and I am setting up the FifoCapacity to be just large enough to hold the desired number of seconds of data (sample rate x desired number of seconds). I also set the XVisibleRange to be equal to the desired time range. This works fine – the waveform sweeps to the end then restarts the trace. Now, when the user wants to change the time range (say from 6 seconds to 10 seconds of data for example) I think I need to do the following:

  1. create a new xyDataSeries with the FifoCapacity set at the new value of sample rate x desired number of seconds
  2. copy the data from the old series into the new series so it’s not lost from the chart
  3. bind the new series into the FastLineRenderableSeries DataSeries
  4. update the XVisibleRange to the new time range

Is this correct? If yes, how do I copy the data from the old series into the new series. I looked over the api documentation but it’s not clear to me. I see a clone() method but this is not what I want since I want a different FifoCapacity. Instead of creating a new series and copying old data into it, can I simply change the FifoCapacity property on the existing series?
Thanks for your help.

  • You must to post comments
1
0

Hi Gary,

You’re absolutely correct. If you change the FifoCapacity the data gets erased (unavoidable, we have internally a circular buffer), so you need to create a new series and perform a copy.

You can do this by accessing the XValues, YValues properties on the original dataseries, e.g.

    public XyDataSeries<TX, TY> ResizeFifoSeries<TX, TY>(XyDataSeries<TX, TY> original, int? fifoCapacity)
        where TX : IComparable
        where TY : IComparable
    {
        lock (original.SyncRoot)
        {
            var newDataSeries = new XyDataSeries<TX, TY>() {FifoCapacity = fifoCapacity};
            newDataSeries.Append(original.XValues, original.YValues);
            return newDataSeries;
        }
    }

Let me know if this helps,

Best regards,
Andrew

  • Gary Arnold
    Thanks for this method. Will it also work when shrinking the fifo size? In other words, when going from 10 seconds of data to 6 seconds of data? In this case, I would want to preserve the most recent data up to the new fifo size.
  • Andrew
    If you shrink the FIFO size it will attempt to append all but wrap around. E.g. if you Append 0 1 2 3 4 5 into a FIFO buffer of size 3, you will lose 0 1, but preserve 3 4 5. Does that make sense?
  • Gary Arnold
    Yes, that makes sense. And that's exactly the behavior I want. Thanks!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.