public CustomPointMarker() { InitializeComponent(); var count = 100; // Create a DataSeriesSet var dataSeries = new XyDataSeries <double, double>(); // Create a single data-series _dataSource = new RandomWalkGenerator(); var data = _dataSource.GetRandomWalkSeries(count); // Create a single metadata IList <IPointMetadata> metadata = new List <IPointMetadata>(); for (int i = 0; i < 100; ++i) { IPointMetadata pointMetadata = new SelectedPointMetadata(); if (i % 9 == 0) { pointMetadata.IsSelected = true; } metadata.Add(pointMetadata); } // Append data to series. dataSeries.Append(data.XData, data.YData, metadata); fastLineSeries.DataSeries = dataSeries; }
// Called when the AppendDataCommand is invoked via button click on the view private void AppendData() { var newData = _dataSource.GetRandomWalkSeries(50); _dataSeries0.Append(newData.XData, newData.YData); ViewportManager.ZoomExtents(); }
public void Execute(TestParameters testParameters, TimeSpan duration, Action <double> fpsResult) { int pointCount = testParameters.PointCount; int seriesCount = testParameters.PointCount; DataSeries = null; // Generate Data and mark time XyData[] xyData = new XyData[seriesCount]; var random = new Random(); for (int i = 0; i < seriesCount; i++) { var generator = new RandomWalkGenerator(random.Next(0, int.MaxValue)); xyData[i] = generator.GetRandomWalkSeries(pointCount); } // Append to SciChartSurface var allDataSeries = new IDataSeries[seriesCount]; for (int i = 0; i < seriesCount; i++) { var dataSeries = new XyDataSeries <double, double>(); dataSeries.Append(xyData[i].XData, xyData[i].YData); allDataSeries[i] = dataSeries; } DataSeries = allDataSeries; // Run test (just refresh) _testRunner = new DispatcherTimerRunner(duration, () => this.sciChart.InvalidateElement(), fpsResult); sciChart.Rendered += _testRunner.OnSciChartRendered; _testRunner.Run(); }
public CustomModifierSandboxViewModel() { // Generate some data var r = new RandomWalkGenerator(); var data = r.GetRandomWalkSeries(500); _bidDataSeries.Append(data.XData.Select(x => DateTime.Today.AddDays(x)), data.YData); r = new RandomWalkGenerator(); data = r.GetRandomWalkSeries(500); _offerDataSeries.Append(data.XData.Select(x => DateTime.Today.AddDays(x)), data.YData); }
public BindToDataSeriesSetViewModel() { ViewportManager = new DefaultViewportManager(); // Create a DataSeriesSet _dataSeries0 = new XyDataSeries <double, double>(); // Create a single data-series _dataSource = new RandomWalkGenerator(); var data = _dataSource.GetRandomWalkSeries(1000); // Append data to series. _dataSeries0.Append(data.XData, data.YData); }
public BindMultipleChartsGroupViewModel() { // Instantiate 9 ChartViewModels for (int i = 0; i < 9; i++) { // Create a ChartViewModel var chartViewModel = new ChartViewModel(); // Create the data-series var dataSeries = new XyDataSeries <double, double>(); // Create data var dummyXyData = _dataSource.GetRandomWalkSeries(1000); // Append X,Y data dataSeries.Append(dummyXyData.XData, dummyXyData.YData); // Set the DataSeries on the ChartViewModel chartViewModel.ChartData = dataSeries; _chartViewModels.Add(chartViewModel); } }
private void Initialize() { RenderableSeriesViewModels = new ObservableCollection <IRenderableSeriesViewModel>(); var random = new Random(); var generator = new RandomWalkGenerator(); for (int i = 0; i < SeriesCount; i++) { var dataSeries = new XyDataSeries <double, double>(); var someData = generator.GetRandomWalkSeries(PointCount); generator.Reset(); dataSeries.Append(someData.XData, someData.YData); var rgb = new byte[3]; random.NextBytes(rgb); RenderableSeriesViewModels.Add(new LineRenderableSeriesViewModel { DataSeries = dataSeries, AntiAliasing = false, Stroke = Color.FromArgb(255, rgb[0], rgb[1], rgb[2]), }); } }
private void OnRunExample() { Task.Factory.StartNew(() => { DataSeries = null; IsBusy = true; var stopwatch = Stopwatch.StartNew(); // Generate Data and mark time DoubleSeries[] xyData = new DoubleSeries[SeriesCount]; var generator = new RandomWalkGenerator(0d); for (int i = 0; i < SeriesCount; i++) { xyData[i] = generator.GetRandomWalkSeries(PointCount); generator.Reset(); } stopwatch.Stop(); IsBusy = false; // Append to SciChartSurface and mark time stopwatch = Stopwatch.StartNew(); var allDataSeries = new IDataSeries[SeriesCount]; for (int i = 0; i < SeriesCount; i++) { var dataSeries = new XyDataSeries <double, double>(); dataSeries.Append(xyData[i].XData, xyData[i].YData); allDataSeries[i] = dataSeries; } DataSeries = allDataSeries; stopwatch.Stop(); ViewportManager.AnimateZoomExtents(TimeSpan.FromMilliseconds(500)); }); }
public void LoadRandomData(int candlesCount, int ticksPerCandle) { _ticksPerCandle = ticksPerCandle; _data = null; var dataSource = new RandomWalkGenerator(); var ticksCount = (candlesCount + 1) * ticksPerCandle; _data = dataSource.GetRandomWalkSeries(ticksCount).YData.ToArray(); _index = 0; //var baseDate = DateTime.Now; for (int j = 0; j < candlesCount; j++) { var date = _baseTime.AddMinutes(j * 30); var volume = _random.Next(100); var bidOrAsk = _random.Next(2) == 0 ? BidOrAsk.Bid : BidOrAsk.Ask; var cumulativeVolume = default(double); var metaData = new CandlestickMetaData(); metaData.AddTick(new CandleTick { BidOrAsk = bidOrAsk, Price = _data[_index], Volume = volume, TimeStamp = date }); cumulativeVolume += bidOrAsk.Equals(BidOrAsk.Ask) ? volume : -volume; var high = cumulativeVolume > 0 ? cumulativeVolume : 0; var low = cumulativeVolume < 0 ? cumulativeVolume : 0; _dataSeries1.Append(date, cumulativeVolume, high, low, cumulativeVolume); _dataSeries0.Append(date, _data[_index], _data[_index], _data[_index], _data[_index], metaData); _candleCount = _dataSeries0.Count; for (int i = 0; i < ticksPerCandle; i++) { _index++; volume = _random.Next(100); bidOrAsk = _random.Next(2) == 0 ? BidOrAsk.Bid : BidOrAsk.Ask; //date = date; var newTick = _data[_index]; var open = _dataSeries0.OpenValues[_candleCount - 1]; high = _dataSeries0.HighValues[_candleCount - 1]; high = high > newTick ? high : newTick; low = _dataSeries0.LowValues[_candleCount - 1]; low = low < newTick ? low : newTick; var meta = (CandlestickMetaData)_dataSeries0.Metadata[_candleCount - 1]; meta.AddTick(new CandleTick { BidOrAsk = bidOrAsk, Price = newTick, Volume = volume, TimeStamp = date }); _dataSeries0.Update(_candleCount - 1, open, high, low, newTick); cumulativeVolume += bidOrAsk.Equals(BidOrAsk.Ask) ? volume : -volume; open = _dataSeries1.OpenValues[_candleCount - 1]; high = _dataSeries1.HighValues[_candleCount - 1]; high = high > cumulativeVolume ? high : cumulativeVolume; low = _dataSeries1.LowValues[_candleCount - 1]; low = low < cumulativeVolume ? low : cumulativeVolume; _dataSeries1.Update(_candleCount - 1, open, high, low, cumulativeVolume); } _filterDataSeries.Append(date, _movingAverage.Push(cumulativeVolume).Current); } }
public void Execute(TestParameters testParameters, TimeSpan duration, Action <double> fpsResult) { int pointCount = testParameters.PointCount; int seriesCount = testParameters.PointCount; DataSeries = null; using (sciChart.SuspendUpdates()) { // Generate Data and mark time XyData[] xyData = new XyData[seriesCount]; var random = new Random(); for (int i = 0; i < seriesCount; i++) { var generator = new RandomWalkGenerator(random.Next(0, int.MaxValue)); xyData[i] = generator.GetRandomWalkSeries(pointCount); } // Append to SciChartSurface var allDataSeries = new IDataSeries[seriesCount]; for (int i = 0; i < seriesCount; i++) { var dataSeries = new XyDataSeries <double, double>() { DataDistributionCalculator = d }; dataSeries.Append(xyData[i].XData, xyData[i].YData); allDataSeries[i] = dataSeries; } DataSeries = allDataSeries; LineSeriesSource.SetStrokeThickness(sciChart, testParameters.StrokeThickness); LineSeriesSource.SetAntiAliasing(sciChart, testParameters.AntiAliasing); LineSeriesSource.SetDataSeries(sciChart, allDataSeries); sciChart.ZoomExtents(); // Run test (just refresh) //int inc = 1; } System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Restart(); if (testParameters.TestRunner == TestRunnerType.Composition) { _testRunner = new CompositionTestRunner(duration, () => { // Make small changes to the YAxis Visible Range to trigger an update and cause some rescaling //var currentRange = this.sciChart.YAxis.VisibleRange.AsDoubleRange(); double dY = (double)sw.ElapsedMilliseconds / 1000.0; this.sciChart.YAxis.VisibleRange = new DoubleRange(-40 - dY, 40 + dY); //this.sciChart.YAxis.VisibleRange.SetMinMax(-1 - dY, 1 + dY); //inc = -inc; }, fpsResult); } else { _testRunner = new DispatcherTimerRunner(duration, () => { // Make small changes to the YAxis Visible Range to trigger an update and cause some rescaling //var currentRange = this.sciChart.YAxis.VisibleRange.AsDoubleRange(); //this.sciChart.YAxis.VisibleRange = new DoubleRange(currentRange.Min - RangeIncrement, currentRange.Max + RangeIncrement); //If not setting large scale enough, SciChart crashes randomly. (-30 ... 30) is not enough double dY = (double)sw.ElapsedMilliseconds / 1000.0; this.sciChart.YAxis.VisibleRange = new DoubleRange(-40 - dY, 40 + dY); //inc = -inc; }, fpsResult); } sciChart.Rendered += _testRunner.OnSciChartRendered; _testRunner.Run(); }