Pre loader

Get data that is currently visible for a particular DataSeries

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


What would be the best way to get only the data that is currently visible for a particular DataSeries?

I have currently used the following:

var dataSeries = series.DataSeries as XyDataSeries;
var indexRange = series.DataSeries.GetIndicesRange(SciChart.XAxis.VisibleRange);
var count = indexRange.Max - indexRange.Min;
var newSeries = new XyDataSeries();
newSeries.Append(dataSeries.XValues.Skip(indexRange.Min).Take(count), dataSeries.YValues.Skip(indexRange.Min).Take(count));

however it feels like maybe there should be a more efficient way in the API to solve this.

If not, it would be nice to have an easy way to retrieve a cut down version of a data series based on a Range so we can pass the VisibleRange directly to the data series and a get a new data series with the data for that range.

  • You must to post comments

Hi Mike – related to your original question, I just found this in the source (forgot about it!)

// Inside SciChartSurface.cs
private void ZoomExtentsOnAxis(IAxis yAxis, IRange xRange, TimeSpan duration);

Take a look at the implementation there, it should show how to zoom extents on a single axis.

Kind regards,

  • You must to post comments

Hi Mike,

There is no API to get a subset of a DataSeries by XAxis Visible Range, however as mentioned here there are methods to get the indices into the data from an XAxis VisibleRange.

My advice would be to wrap the above into an extension method and use it. Also note the dataSeries.XValues are array indexable, so if you are prepared to create an intermediate copy you could do this:

int count = indexRange.Max - IndexRange.Min + 1;
double[] xValues = new double[count];
double[] yValues = new double[count];
for (int i = indexRange.Min; i <= indexRange.Max; i++)
    xValues[i] = dataSeries.XValues[i];
    yValues[i] = dataSeries.YValues[i];

var newSeries = new XyDataSeries<double, double>();
newSeries.Append(xValues, yValues);

Best regards,

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.