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.
- Mike Melancon asked 11 years ago
- You must login 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,
Andrew
- Andrew Burnett-Thompson answered 11 years ago
- You must login 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,
Andrew
- Andrew Burnett-Thompson answered 11 years ago
- You must login to post comments
Please login first to submit.