public SciChartColumnChartModel() { _data = new Dictionary <double, double>(); XList = new List <double>(); YList = new List <double>(); Series = new XyDataSeries <double, double>(); Series.AcceptsUnsortedData = true; for (double x = 0.0; x < 100.0; x += 0.1) { XList.Add(x); YList.Add(0.0); } Series.InsertRange(0, XList, YList); XAxis = new DoubleRange( Double.Parse(Series.XMin.ToString()), Double.Parse(Series.XMax.ToString())); YAxis = new DoubleRange( Double.Parse(Series.YMin.ToString()), Double.Parse(Series.YMax.ToString())); RenderableSeries = new ObservableCollection <IRenderableSeriesViewModel>(); CurrentSeries = new ColumnRenderableSeriesViewModel() { DataPointWidth = 1, Stroke = System.Windows.Media.Color.FromRgb(186, 187, 190), DataSeries = Series }; }
private WaterfallDataSeries3D <double> ResampleDataSeries(WaterfallDataSeries3D <double> dataSeries, double[] slicePositions) { var pointsPerSlice = dataSeries.XSize; var sliceCount = dataSeries.ZSize; var resamplerFactory = new PointResamplerFactory(); var resamplingParams = new ResamplingParams { IsSortedData = true, IsEvenlySpacedData = true, IsCategoryData = false, ContainsNaN = false, ZeroLineY = 0.0, PointRange = new IndexRange(0, pointsPerSlice - 1), VisibleRange = dataSeries.XRange, ViewportWidth = Width > 0.0 ? (int)Width : 640, ResamplingPrecision = 1 }; var resampledSeriesesArray = new IPointSeries[sliceCount]; var sliceAsXySeries = new XyDataSeries <double>(pointsPerSlice); var sliceAsXySeriesYValues = sliceAsXySeries.YValues as ISciList <double>; sliceAsXySeriesYValues.SetCount(pointsPerSlice); var xValues = new double[pointsPerSlice]; var xRangeMin = (double)dataSeries.XRange.Min; var stepX = dataSeries.StepX; for (int i = 0; i < pointsPerSlice; i++) { xValues[i] = xRangeMin + stepX * i; } // Init the XY series by first slice of the waterfall data series sliceAsXySeries.InsertRange(0, xValues, dataSeries.InternalArray[0]); resampledSeriesesArray[0] = sliceAsXySeries.ToPointSeries(resamplingParams, ResamplingMode.Auto, resamplerFactory, null); for (int i = 1; i < sliceCount; i++) { var curRow = dataSeries.GetRowAt(i); Array.Copy(curRow, sliceAsXySeriesYValues.ItemsArray, pointsPerSlice); resampledSeriesesArray[i] = sliceAsXySeries.ToPointSeries(resamplingParams, ResamplingMode.Auto, resamplerFactory, null); } var resampledPerPointsPerSlice = resampledSeriesesArray[0].Count; var resampledDataSeries = new WaterfallDataSeries3D <double>(resampledPerPointsPerSlice, slicePositions); resampledDataSeries.StartX = dataSeries.StartX; resampledDataSeries.StepX = dataSeries.StepX; for (int i = 0; i < sliceCount; i++) { resampledDataSeries.SetRowAt(i, resampledSeriesesArray[i].YValues.Items); } return(resampledDataSeries); }