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

I’m trying to merge xvalues of two data series (both must have equals xvalues).
First, i get a keys – collection of different keys, and want to insert this keys into second data series.

        using (ds.SuspendUpdates())
        {
                int keyIndex = 0;
                int dsIndex = ds.FindIndex(keys[0], SearchMode.RoundUp);

                while (dsIndex < ds.XValues.Count)
                {
                    if (keyIndex >= keys.Count) break;

                    if (ds.XValues[dsIndex] > keys[keyIndex])
                    {
                        ds.Insert(dsIndex, keys[keyIndex], Double.NaN);
                        keyIndex++;
                    }

                    dsIndex++;
                }
       }

But if ds.XValues.Count = 1200000 and keys’s count = 200000, that this method work to much time.
Complexity of this method is O(n), so i want to know what is performance (complexity) of data series insert method?

  • You must to post comments
1
0

Hi Arthur,

Insert performance will be roughly the same as List.Insert, where we have one list for each column. E.g. Date, Open, High, Low, Close are 5 lists.

Insert requires that the underlying list is resized, all elements after the Insert are copied (moved) and the new elements copied (inserted).

DataSeries.InsertRange is a faster and better way to insert than point-by-point insert.

Hope this helps,
Andrew

  • Ivan Zakharov
    Data to insert often don't point-by-point. Is there any way to create a data series with a parameter capacity (like new List(capacity))?
  • Andrew
    Not at this time, no. The append performance is very fast. Inserts require a resize, copy and move operation so are slower than appends. If you can, try to re-write your code to iterate over two series and only use Append in order.
  • Andrew
    Something else you can try is merging to a List List with pre-defined capacity then appending one block using DataSeries.Append(xVaues, yValues). It will use more memory but should be quicker!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.