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 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.


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,

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

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

Please first to submit.