Exemplo n.º 1
0
        void Render()
        {
            //if (AutoAxisCheckbox.IsChecked == true)
            // wpfPlot.plt.AxisAuto();
            var arr    = data.ToArray();
            var signal = wpfPlot.plt.PlotCandlestick(arr);

            if (arr.Length >= 100)
            {
                Task.Run(() => Statistics.Finance.Bollinger(arr))
                .ContinueWith(async a =>
                {
                    var(sma, bolL, bolU) = (await a);
                    double[] xs          = DataGen.Consecutive(arr.Length);
                    wpfPlot.plt.PlotScatter(xs, bolL, color: Color.Blue, markerSize: 0);
                    wpfPlot.plt.PlotScatter(xs, bolU, color: Color.Blue, markerSize: 0);
                    wpfPlot.plt.PlotScatter(xs, sma, color: Color.Blue, markerSize: 0, lineStyle: LineStyle.Dash);
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }

            double[] autoAxisLimits = wpfPlot.plt.AxisAuto(verticalMargin: .5);
            double   oldX2          = autoAxisLimits[1];

            wpfPlot.plt.Axis(x2: oldX2 + 10);

            wpfPlot.Render(skipIfCurrentlyRendering: true);
        }
Exemplo n.º 2
0
        void Render()
        {
            //if (AutoAxisCheckbox.IsChecked == true)
            // wpfPlot.plt.AxisAuto();

            double[] autoAxisLimits = wpfPlot.plt.AxisAuto(verticalMargin: .5);
            double   oldX2          = autoAxisLimits[1];

            wpfPlot.plt.Axis(x2: oldX2 + 100);

            wpfPlot.Render(skipIfCurrentlyRendering: true);
        }
Exemplo n.º 3
0
        private void OnTimerTick(object sender, ElapsedEventArgs e)
        {
            _timer.Enabled = false;

            _wpfPlot.Dispatcher.Invoke(() =>
            {
                PlotLatestData();
                _wpfPlot.Plot.SetAxisLimits(0, 15, 0, 2);
                _wpfPlot.Render();
            });

            _timer.Enabled = true;
        }
        public void RenderGraph(GraphData item)
        {
            PlotPanel.Children.Clear();
            WpfPlot plot = new WpfPlot();

            PlotPanel.Children.Add(plot);
            foreach (var signal in item.Data)
            {
                if (signal.Value.y.Length == 0)
                {
                    continue;
                }
                if (item.StartDate != null)
                {
                    plot.plt.PlotScatter(Array.ConvertAll(signal.Value.x, x => x + item.StartDate.GetValueOrDefault().ToOADate()), Array.ConvertAll(signal.Value.y, x => (double)x), label: signal.Key, markerSize: 0);
                }
                else
                {
                    plot.plt.PlotScatter(Array.ConvertAll(signal.Value.x, x => (double)x), Array.ConvertAll(signal.Value.y, x => (double)x), label: signal.Key, markerSize: 0);
                }
            }
            if (item.StartDate != null)
            {
                plot.plt.Ticks(dateTimeX: true);
            }
            plot.plt.Legend(true, location: legendLocation.upperLeft);
            plot.plt.XLabel(item.XAxisLabel, enable: true);
            plot.plt.YLabel(item.YAxisLabel, enable: true);
            plot.plt.Style(
                Helper.ConvertColor(brush: (SolidColorBrush)FindResource("BackgroundDark")),
                Helper.ConvertColor((SolidColorBrush)FindResource("Background")),
                ColorTranslator.FromHtml("#888"),
                Helper.ConvertColor((SolidColorBrush)FindResource("TextColor")),
                Helper.ConvertColor((SolidColorBrush)FindResource("TextColor")),
                Helper.ConvertColor((SolidColorBrush)FindResource("TextColor"))
                );
            plot.Render();
        }
Exemplo n.º 5
0
 private void Render(object sender, EventArgs e)
 {
     WpfPlot.Plot.AxisAuto(0);
     WpfPlot.Render();
 }
        public MainWindowViewModel()
        {
            Data = new ObservableCollection <Tuple <double, double> >();

            Series = new WpfPlot();
            Series.plt.Title("Potential Expansivess", bold: true, fontSize: 22);
            Series.plt.XLabel("Clay fraction of whole sample", bold: true);
            Series.plt.YLabel("PI of whole sample", bold: true);


            Series.plt.AxisBounds(0, _xMax, 0, _yMax);
            Series.Configure(lockHorizontalAxis: true, lockVerticalAxis: true);
            Series.plt.Grid(xSpacing: 10, ySpacing: 10, lineWidth: 2);
            // Series.plt.AxisZoom(0, 0, -20, -20);
            //Series.Width = 800;

            AddDataCommand = new DelegateCommand(() =>
            {
                Data.Add(new Tuple <double, double>(ClayFractionOfWholeSample, PiOfWholeSample));

                Series.plt.PlotPoint(ClayFractionOfWholeSample, PiOfWholeSample, GetColor(), 15);
                Series.plt.PlotText(_pointLabel, ClayFractionOfWholeSample - 0.5, PiOfWholeSample + 1, System.Drawing.Color.Black);

                Series.Render();
            });

            ClearDataCommand = new DelegateCommand(() =>
            {
                ClayFractionOfWholeSample = 0;
                PiOfWholeSample           = 0;

                Data.Clear();
                Series.plt.Clear();
                DrawAbaque();
                Series.plt.AxisBounds(0, _xMax, 0, _yMax);
                Series.Render();
            });

            ExportCommand = new DelegateCommand(() =>
            {
                var dialog    = new SaveFileDialog();
                dialog.Filter = "Excel file (*.xls)|*.xls";
                dialog.ShowDialog();
                ;

                var fileName = dialog.FileName;

                if (String.IsNullOrEmpty(fileName))
                {
                    return;
                }

                Series.plt.SaveFig($"{fileName}.png");

                var book = new BinBook();

                var id = book.addPicture(fileName + ".png");

                var sheet = book.addSheet("Chart");
                sheet.setPicture(10, 3, id);

                book.save(fileName);
            });

            DrawAbaque();
        }
Exemplo n.º 7
0
 public VisualizerViewModel(NaiveBaysModel baysModel)
 {
     _baysModel = baysModel;
     _plot.plt.PlotSignal(DataGen.RandomWalk(new Random(), 1000));
     _plot.Render();
 }