Exemple #1
0
        public void ChangeYMemberSeriesViewWithFunctionAsDataSource()
        {
            var function = new Function();
            var Y        = new Variable <double>("Y");
            var Z        = new Variable <double>("Z");
            var n        = new Variable <double>("n");

            function.Arguments.Add(Y);
            function.Components.Add(Z);
            function.Components.Add(n);

            Y.SetValues(new[] { 0.0, 3.0, 5.0, 6.0, 7.0 });
            Z.SetValues(new[] { 0.0, 10.0, 15.0, 21.0, 15.0 });
            n.SetValues(new[] { 0.001, 0.001, 0.01, 0.01, 0.01 });

            var chartView = new ChartView();

            IChartSeries series = ChartSeriesFactory.CreateLineSeries();

            series.XValuesDataMember = Y.DisplayName;
            series.YValuesDataMember = Z.DisplayName;
            series.DataSource        = new FunctionBindingList(function)
            {
                SynchronizeInvoke = chartView
            };
            chartView.Chart.Series.Add(series);

            WindowsFormsTestHelper.ShowModal(chartView);
        }
Exemple #2
0
        public void RefreshShouldBeFastWhenFunctionDataSourceHasManyChanges()
        {
            IFunction function = new Function
            {
                Arguments  = { new Variable <int>("x") },
                Components = { new Variable <int>("f") }
            };

            var values = new int[1000];

            for (var i = 0; i < values.Length; i++)
            {
                values[i] = i;
            }

            var chartView = new ChartView();

            var lineSeries = ChartSeriesFactory.CreateLineSeries();

            var functionBindingList = new FunctionBindingList(function)
            {
                SynchronizeInvoke = chartView
            };

            lineSeries.DataSource = functionBindingList;

            lineSeries.XValuesDataMember = function.Arguments[0].DisplayName;
            lineSeries.YValuesDataMember = function.Components[0].DisplayName;
            chartView.Chart.Series.Add(lineSeries);
            lineSeries.PointerVisible = false;

            // now do the same when table view is shown
            Action <Form> onShown = delegate
            {
                var stopwatch = new Stopwatch();
                stopwatch.Reset();
                stopwatch.Start();
                SetFunctionValuesWrappedWithChartView(function, values);
                stopwatch.Stop();

                log.DebugFormat("Refreshing chart while inserting values into function took {0}ms", stopwatch.ElapsedMilliseconds);

                stopwatch.ElapsedMilliseconds.Should("Insert of 1k values should take < 100ms").Be.LessThan(300);
            };

            WindowsFormsTestHelper.ShowModal(chartView, onShown);
        }
Exemple #3
0
        public void RefreshShouldBeFastWhenFunctionDataSourceHasManyChanges()
        {
            var       random   = new Random();
            IFunction function = new Function
            {
                Arguments  = { new Variable <int>("x") },
                Components = { new Variable <int>("f") }
            };

            int count           = 1000;
            var componentvalues = Enumerable.Range(1, count).Select(i => random.Next(100)).ToArray();
            var argumentvalues  = Enumerable.Range(1, count).ToArray();

            var chartView = new ChartView();

            var lineSeries = ChartSeriesFactory.CreateLineSeries();

            var functionBindingList = new FunctionBindingList(function)
            {
                SynchronizeInvoke = chartView
            };

            lineSeries.DataSource = functionBindingList;
            //don't update on every change...
            lineSeries.UpdateASynchronously = true;
            lineSeries.XValuesDataMember    = function.Arguments[0].DisplayName;
            lineSeries.YValuesDataMember    = function.Components[0].DisplayName;
            chartView.Chart.Series.Add(lineSeries);
            lineSeries.PointerVisible = false;

            // call one time to make sure that internal HACK TypeUtils.CallGeneric is done, otherwise timing varies a lot
            function.SetValues(componentvalues, new VariableValueFilter <int>(function.Arguments[0], argumentvalues));
            function.Arguments[0].Clear();

            // now do the same when table view is shown
            Action <Form> onShown = delegate
            {
                //the slowdown of chart is absolute minimal
                TestHelper.AssertIsFasterThan(50, () =>
                                              function.SetValues(componentvalues, new VariableValueFilter <int>(function.Arguments[0], argumentvalues)));
            };

            WindowsFormsTestHelper.ShowModal(chartView, onShown);
        }