public void Execute(TestParameters testParameters, TimeSpan duration, Action <double> fpsResult)
        {
            // Setup
            var dataset = new DataSeriesSet <double, double>();

            _xyDataSeries = new XyDataSeries <double, double>()
            {
                FifoCapacity = testParameters.PointCount
            };
            dataset.Add(_xyDataSeries);
            sciChart.DataSet = dataset;

            this.lineSeries.AntiAliasing = testParameters.AntiAliasing;
            ResamplingMode resamplingMode;

            if (!Enum.TryParse(testParameters.SamplingMode.ToString(), out resamplingMode))
            {
                resamplingMode = ResamplingMode.MinMax;
            }
            this.lineSeries.ResamplingMode = resamplingMode;

            _generator = new RandomLinesGenerator();
            var initialData = _generator.GetRandomLinesSeries(testParameters.PointCount);

            _xyDataSeries.Append(initialData.XData, initialData.YData);

            // Execute
            _testRunner        = new DispatcherTimerRunner(duration, OnAppendData, fpsResult);
            sciChart.Rendered += _testRunner.OnSciChartRendered;
            _testRunner.Run();
        }
        public void Execute(TestParameters testParameters, TimeSpan duration, Action <double> fpsResult)
        {
            // Setup
            var dataset = new DataSeriesSet <double, double>();

            _xyDataSeries = new XyDataSeries <double, double>();
            dataset.Add(_xyDataSeries);

            sciChart.DataSet = dataset;

            this.scatterSeries.AntiAliasing = testParameters.AntiAliasing;
            ResamplingMode resamplingMode; if (!Enum.TryParse(testParameters.SamplingMode.ToString(), out resamplingMode))

            {
                resamplingMode = ResamplingMode.None;
            }

            this.scatterSeries.ResamplingMode = resamplingMode;

            _generator = testParameters.DataDistribution == DataDistribution.Uniform ? (RandomPointsGenerator) new BrownianMotionPointsGenerator(0, 100, -50, 50) : new CorrelatedDataPointsGenerator(0, 100, -50, 50);

            sciChart.XAxis.VisibleRange = new DoubleRange(0, 100);
            sciChart.YAxis.VisibleRange = new DoubleRange(-50, 50);
            var initialData = _generator.GetRandomPoints(testParameters.PointCount);

            _xyDataSeries.Append(initialData.XData, initialData.YData);

            // Execute
            _testRunner        = new DispatcherTimerRunner(duration, () => OnAppendData(testParameters.PointCount), fpsResult);
            sciChart.Rendered += _testRunner.OnSciChartRendered;
            _testRunner.Run();
        }
Exemple #3
0
 /// <summary>
 /// Event called when window is loaded
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     _dataset           = new DataSeriesSet <DateTime, double>();
     StartDate          = new DateTime(2000, 1, 1);
     EndDate            = DateTime.Today;
     DJIA               = GetDJIAQuotes();
     stockChart.DataSet = _dataset;
 }
        private static void OnDataSeriesDependencyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var sciChartSurface = d as SciChartSurface;

            if (sciChartSurface == null)
            {
                return;
            }

            if (e.NewValue == null)
            {
                sciChartSurface.RenderableSeries.Clear();
                return;
            }

            using (sciChartSurface.SuspendUpdates())
            {
                sciChartSurface.RenderableSeries.Clear();

                var random       = new Random();
                var itr          = (IEnumerable <IDataSeries>)e.NewValue;
                var renderSeries = new List <IRenderableSeries>();

                // 1.7.2 specific
                var dataset = new DataSeriesSet <double, double>();

                foreach (var dataSeries in itr)
                {
                    if (dataSeries == null)
                    {
                        continue;
                    }

                    // 1.7.2 specific
                    dataset.Add(dataSeries);

                    var rgb = new byte[3];
                    random.NextBytes(rgb);
                    var renderableSeries = new FastLineRenderableSeries()
                    {
                        ResamplingMode = ResamplingMode.MinMax,
                        SeriesColor    = Color.FromArgb(255, rgb[0], rgb[1], rgb[2]),
                        DataSeries     = dataSeries,
                    };

                    renderSeries.Add(renderableSeries);
                }

                // 1.7.2 specific
                sciChartSurface.DataSet = dataset;

                sciChartSurface.RenderableSeries = new ObservableCollection <IRenderableSeries>(renderSeries);
            }
        }
Exemple #5
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            // Create a dataset of type X=double, Y=double
            var dataSeriesSet = new DataSeriesSet <double, double>();

            sciChart1.DataSet = dataSeriesSet;
            sciChart2.DataSet = dataSeriesSet;
            // Add a data series
            var series = dataSeriesSet.AddSeries();

            var data = DataManager.Instance.GetFourierSeries(1.0, 0.1);

            // Append data to series. SciChart automatically redraws
            series.Append(data.XData, data.YData);


            // Create a dataset of type X=double, Y=double
            var dataSeriesSet1 = new DataSeriesSet <double, double>();

            sciChart3.DataSet = dataSeriesSet1;

            // Add a data series
            var dataSeries0 = dataSeriesSet1.AddSeries();

            dataSeries0.SeriesName = "Curve A";
            var dataSeries1 = dataSeriesSet1.AddSeries();

            dataSeries1.SeriesName = "Curve B";
            var dataSeries2 = dataSeriesSet1.AddSeries();

            dataSeries2.SeriesName = "Curve C";

            var data1 = DataManager.Instance.GetExponentialCurve(0.4, 100);
            var data2 = DataManager.Instance.GetExponentialCurve(0.44, 100);
            var data3 = DataManager.Instance.GetExponentialCurve(0.49, 100);

            // Append data to series.
            dataSeries0.Append(data1.XData, data1.YData);
            dataSeries1.Append(data2.XData, data2.YData);
            dataSeries2.Append(data3.XData, data3.YData);

            // Zoom to extents of the data
            sciChart3.ZoomExtents();
        }
Exemple #6
0
        public void Execute(TestParameters testParameters, TimeSpan duration, Action <double> fpsResult)
        {
            var testParams = testParameters as LineAppendTestParameters;

            ResamplingMode rMode;

            if (!Enum.TryParse(testParams.SamplingMode.ToString(), out rMode))
            {
                rMode = ResamplingMode.MinMax;
            }

            line0.AntiAliasing   = testParameters.AntiAliasing;
            line0.ResamplingMode = rMode;

            line1.AntiAliasing   = testParameters.AntiAliasing;
            line1.ResamplingMode = rMode;

            line2.AntiAliasing   = testParameters.AntiAliasing;
            line2.ResamplingMode = rMode;

            var dataset = new DataSeriesSet <double, double>();

            dataset.Add(_mainSeries);
            dataset.Add(_maLowSeries);
            dataset.Add(_maHighSeries);
            sciChart.DataSet = dataset;

            xBuffer      = new double[testParams.IncrementPoints];
            yBuffer      = new double[testParams.IncrementPoints];
            maLowBuffer  = new double[testParams.IncrementPoints];
            maHighBuffer = new double[testParams.IncrementPoints];

            // Execute
            //

            // Prime the chart with initial points
            using (sciChart.SuspendUpdates())
                AppendData(testParams.PointCount, testParams.Noisyness);

            // Start the test runner
            _testRunner        = new CompositionTestRunner(duration, () => OnAppendData(testParams.Noisyness), fpsResult);
            sciChart.Rendered += _testRunner.OnSciChartRendered;
            _testRunner.Run();
        }
 /// <summary>
 /// Event called when window is loaded
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     _dataset = new DataSeriesSet<DateTime, double>();
     StartDate = new DateTime(2000, 1, 1);
     EndDate = DateTime.Today;
     DJIA = GetDJIAQuotes();
     stockChart.DataSet = _dataset;
 }
        //Return relevant data set
        private DataSeriesSet<DateTime, double> ReadStockData(String sFileName)
        {
            //local variables and structures
            string sFile;
            int nRow = 0;
            string sStockFile = sLocation + "\\" + sFileName;

            DateTime xAxis;
            double dOpen, dHigh, dLow, dClose;
            int nVolume;
            List<Tuple<DateTime, double, double, double, double, int>> listStock = new List<Tuple<DateTime, double, double, double, double, int>>();

            //Data structure to return
            var dataSeriesSet = new DataSeriesSet<DateTime, double>();
            var series = dataSeriesSet.AddSeries<OhlcDataSeries<DateTime, double>>();
            var seriesLine = dataSeriesSet.AddSeries();
            seriesLine.SeriesName = "Volume";

            //reading stock file
            using (StreamReader sr = new StreamReader(sStockFile))
                sFile = sr.ReadToEnd();
            //parsing the file
            string[] rows = sFile.Split(('\n'));
            foreach (string row in rows)
            {
                if (row == "") continue;
                string[] columns = row.Split((','));
                if (nRow++ == 0) //(Sort of) Check of the data file structure
                {
                    if (!columns[0].Substring(0, 4).Equals("DATE", StringComparison.InvariantCultureIgnoreCase) ||
                    !columns[1].Substring(0, 4).Equals("OPEN", StringComparison.InvariantCultureIgnoreCase) ||
                    !columns[2].Substring(0, 4).Equals("HIGH", StringComparison.InvariantCultureIgnoreCase) ||
                    !columns[3].Substring(0, 3).Equals("LOW", StringComparison.InvariantCultureIgnoreCase) ||
                    !columns[4].Substring(0, 5).Equals("CLOSE", StringComparison.InvariantCultureIgnoreCase) ||
                    !columns[5].Substring(0, 6).Equals("VOLUME", StringComparison.InvariantCultureIgnoreCase))
                    {
                        MessageBoxResult result = MessageBox.Show("Your source data file doesn't have the required structure!\nPlease, re-check your file.\nAborting!", "Data structure error!");
                        dataSeriesSet = null;
                        break;
                    }
                    else continue;
                }
                try //Check of the source data types
                {
                    xAxis = DateTime.Parse(columns[0]);
                    dOpen = Convert.ToDouble(columns[1]);
                    dHigh = Convert.ToDouble(columns[2]);
                    dLow = Convert.ToDouble(columns[3]);
                    dClose = Convert.ToDouble(columns[4]);
                    nVolume = Convert.ToInt32(columns[5]);

                    //Add the row to the list
                    listStock.Add(new Tuple<DateTime, double, double, double, double, int>(xAxis, dOpen, dHigh, dLow, dClose, nVolume));
                }
                catch
                {
                    MessageBoxResult result = MessageBox.Show("Your source file contains some data which is not of the required data type!\nPlease, re-check your file.\nAborting!", "Data type error!");
                    dataSeriesSet = null;
                    break;
                }
            }
            listStock.Sort(Comparer<Tuple<DateTime, double, double, double, double, int>>.Default); //sort and set as source
            foreach(Tuple<DateTime, double, double, double, double, int> newLine in listStock)
            {
                series.Append(newLine.Item1, newLine.Item2, newLine.Item3, newLine.Item4, newLine.Item5);
                if (inMillions)
                {
                    seriesLine.Append(newLine.Item1, newLine.Item6 / 1000000);
                }
                else
                {
                    seriesLine.Append(newLine.Item1, newLine.Item6);
                }
            }
            return dataSeriesSet;
        }