예제 #1
0
        static void createSinGraph()
        {
            var    s    = new FunctionSeries((x) => Math.Sin(x), 0, 10, 0.1);
            var    plot = FastPlot.ShowFuncGraph(s, out _);
            double a    = 1;
            var    sw   = System.Diagnostics.Stopwatch.StartNew();

            while (!((Plot)plot).IsDisposed)
            {
                Thread.Sleep(200);

                for (int i = 0; i < s.Points.Count; i++)
                {
                    var p = s.Points[i];
                    s.Points[i] = new OxyPlot.DataPoint(p.X, Math.Sin(p.X + sw.ElapsedMilliseconds));
                }
                s.Points.Add(new OxyPlot.DataPoint(s.Points.Last().X + a, a));


                //plot.Refresh(s, 0);
                plot.Refresh();

                a += 0.1;
            }
        }
예제 #2
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            double smaValue = SMA(slowPeriod)[0];
            double emaValue = EMA(fastPeriod)[0];

            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.
            FastPlot.Set(emaValue);
            SlowPlot.Set(smaValue);

            crossedAgo.Set(calcLastCross(EMA(fastPeriod), SMA(slowPeriod)));
            crossedDirection.Set(direction);
        }
예제 #3
0
        static void histogramVSkmean()
        {
            int n = 1000;
            //var randVector = RNG.DoubleDist(n);
            Func <double, double> f = (x) => Math.Sin(x);
            var randVector          = Enumerable.Range(0, n).Select(o => f(o / (n / (3 * Math.PI)))).ToArray();

            Histogram.ShowHist(randVector, 10);
            var kmeanPlot = (Plot)MovingAverage.ShowMovingAverage(randVector, n / 20);

            //FastPlot.ShowDynamicGraph(new FunctionSeries((x) => randVector[(int)(x)], 0.0, n-1, 1 - double.Epsilon));
            FastPlot.ShowConnectedDots(randVector);

            Histogram.PrintHist(randVector);
        }
예제 #4
0
파일: SliderTest.cs 프로젝트: Donaim/vutils
        static void sliderWithGraphTest()
        {
            double a = 1, b = 0;

            double func(double x) => Math.Sin(x * a + b);

            var plot = FastPlot.ShowFuncGraph(func, 0, 10, out var refrFunc);

            var slider = VSlider.RunAsync();

            slider.AddWatch <double>(act: a_set, current: 1.0, lower: -10.0, upper: 10.0, delta: 0.1, parser: double.TryParse);
            slider.AddWatch <double>(act: b_set, current: 0.0, lower: -10.0, upper: 10.0, delta: 0.1, parser: double.TryParse);
            slider.AddWatch <double>(act: b_set, current: 0.0, lower: -10.0, upper: 10.0, delta: 2.1, parser: double.TryParse);

            void a_set(double to)
            {
                a = to; refrFunc(func);
            }

            void b_set(double to)
            {
                b = to; refrFunc(func);
            }
        }