Pre loader

Custom Data Series

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


To whom this may concern:

I would like to create a custom data series where I can manipulate the X-Values more efficiently for a ColumnRenderableSeries, where if I remove a column from the chart or there is a gap in the data, I won’t have any spaces between any of the columns in the chart. I also haven’t found any documentation on creating a custom data series.

My approach is to treat the X values like a stack.
– If a point is appended, a value is pushed to the X values stack and the Y values list.
– If a point is to be removed using RemoveAt(), it only removes the Y-Axis value from the index and pops the X values stack so the order and spacing of the x-values remain the same.

This is similar to Microsoft Excel, where removing a data row linked to a chart deletes the X-axis value instead of leaving a gap.

My thinking is making the following derivation of XYDataSeries (in C# pseudocode):

ColumnDataSeries<TY> : XyDataSeries<int, TY> where TY : IComparable
    Stack<IComparable> XValues { get; set; }
    IList<IComparable> YValues { get; set; }

    Append (T value) 
        XValues.Push (XMax + 1);
        YValues.Add (value);

    RemoveAt (int index) 
        XValues.Pop ();
        YValues.RemoveAt (index);

Can you please advise or provide any documentation for this?

Thank you, and best regards!

— Ari

Edit: Sorry if the code doesn’t look right, I don’t know how to properly wrap C# code on the forums.
Edit 2: Second attempt at posting code. Should see the generics now.

  • You must to post comments
Best Answer

Another idea for you based on your comment ‘any way to more efficiently Append() then Clear() memory’ is as follows.

Append & clear is pretty efficient, if you have say 100k – 1M points it will not be noticeable. However, if you want to try something experimental, try this:

Say you have an array of 10,000 points and you want to basically remove point at 5,000.

The DataSeries.XValues is just a list and you can access the inner array:

T[] xArray = ((ISciList<TX>)DataSeries.XValues).ItemsArray;

now you have access to the array, you can manipulate it very fast. For example:

    // This code has been pasted from inside scichart where we do a similar operation
    // and is untested. Try it out -- it gives an example only 
    void RemoveRange<T>(T[] itemsArray, int index, int count)
        int countAfter = itemsArray.Length - count;
        if (index < countAfter)
            Array.Copy(itemsArray, index + count, ItemsArray, index, countAfter - index);
        Array.Clear(itemsArray, countAfter, count);

The above code effectively left shifts an array by copying part of it to a lower part of the array.

Basically items 0,1,2,3,4,5,6,7,8,9,10, if you pass in index = 5 and count = 1, then the output array becomes 0,1,2,3,5,6,7,8,9,10,0

Try that. careful though, make sure that you have the exact same number of points in the XValues, YValues after your manipulations, that you do all operations inside a DataSeries.SuspendUpdates() block and you also call DataSeries.InvalidateParentSurface with hasDataChanged flag

  • Ari Sagiv
    Thank you, Andrew! I will give this a try and let you know how it turns out.
  • Ari Sagiv
    Yep, that did the trick. One thing (for future readers) is to also ensure the point metadata array is updated as well.
  • Andrew Burnett-Thompson
    Also re-reading your question, you know XyDataSeries has a RemoveAt method too? This basically does the above – it removes the Y value and left shifts the X-values.
  • You must to post comments

Hi Ari,

How many data-points are you dealing with here? If less than millions, I’d honestly recommend just wrapping our XyDataSeries with some extension methods to reset the X-Values after removing a value.

overriding XyDataSeries is not generally recommended because we do a lot of work internally to determine the distribution of your data, to choose the best/fastest and most accurate algorithms for drawing. If you override XValues,YValues you will need to ensure all of this internal (and not exposed) code is also updated …

Best regards,


  • Ari Sagiv
    Andrew — Completely understandable. I’m not dealing with millions of data points (it would be pretty difficult to see the individual columns anyway), so I’m OK with re-appending both the X- and Y-Values entirely if that’s the best way to do it. Is there a more efficent way than just dataSeries.Clear() followed by dataSeries.Append(IEnumerable XValues, IEnumerable YValues)? Thank you kindly for your response! — Ari
  • Andrew Burnett-Thompson
    yeah you could …. shift the memory. answer below in a minute
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.