private void SetUpModel()
        {
            plotModel.LegendTitle       = "Legend";
            plotModel.LegendOrientation = LegendOrientation.Horizontal;
            plotModel.LegendPlacement   = LegendPlacement.Outside;
            plotModel.LegendPosition    = LegendPosition.TopRight;
            plotModel.LegendBackground  = OxyColor.FromAColor(200, OxyColors.White);
            plotModel.LegendBorder      = OxyColors.Black;
            plotModel.Title             = "SensorThings API Sample Graph";
            var dtaxis = new OxyPlot.Axes.DateTimeAxis
            {
                Position          = AxisPosition.Bottom,
                Title             = "Date",
                TitleFormatString = "yy/mm/dd HH:mm"
            };

            plotModel.Axes.Add(dtaxis);
            var valueAxis = new OxyPlot.Axes.LinearAxis()
            {
                MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Value"
            };

            valueAxis.Position = AxisPosition.Left;
            plotModel.Axes.Add(valueAxis);
        }
Пример #2
0
        public void Update(ITerminal terminal)
        {
            var quote = terminal.GetQuote(Symbol);

            if (quote == null || quote.Bid == 0)
            {
                return;
            }

            var bid     = (double)quote.Bid;
            var barTime = quote.TimeStamp.ToMinutes();

            if (Candles.Count > 0)
            {
                var lastCandle = Candles.Last();

                var dateTime = DateTimeAxis.ToDateTime(lastCandle.X);

                if (dateTime.Equals(barTime))
                {
                    lastCandle.Low   = Math.Min(lastCandle.Low, bid);
                    lastCandle.High  = Math.Max(lastCandle.High, bid);
                    lastCandle.Close = bid;
                }
                else
                {
                    Candles.Add(new HighLowItem(
                                    x: DateTimeAxis.ToDouble(barTime),
                                    high: bid,
                                    low: bid,
                                    open: lastCandle.Close,
                                    close: bid));
                }
            }
            else
            {
                Candles.Add(new HighLowItem(
                                x: DateTimeAxis.ToDouble(barTime),
                                high: bid,
                                low: bid,
                                open: bid,
                                close: bid));
            }

            BidLineAnnotation.Text = bid.ToString(CultureInfo.InvariantCulture);
            BidLineAnnotation.Y    = bid;

            if (XAutoScroll)
            {
                var actualMax = XAxis.ActualMaximum;
                var newMaxX   = DateTimeAxis.ToDouble(barTime) + PeriodToX(TimeSpan.FromMinutes(30));

                var panDelta = XAxis.Transform(-(newMaxX - actualMax) + XAxis.Offset);

                XAxis.Pan(panDelta);
                XAxis.AbsoluteMaximum = newMaxX;
            }

            Model.InvalidatePlot(true);
        }
Пример #3
0
        private double PeriodToX(TimeSpan period)
        {
            var start = DateTime.Now;
            var end   = start + period;

            return(DateTimeAxis.ToDouble(end) - DateTimeAxis.ToDouble(start));
        }
Пример #4
0
        //private const int UPDATE_EVERY_X_HOUR = 4;
        private void _updateSeries(PerformanceTick t)
        {
            ////only update graph each x hours
            //if (//!t.IsBalanceUpdated &&
            //  (t.Time.Minute != 0 || t.Time.Hour % UPDATE_EVERY_X_HOUR != 0)) return;

            _addPoint(PlotModelPer, 0, t.Time, t.Balance);
            _addPoint(PlotModelPer, 1, t.Time, t.Equity);
            _addPoint(PlotModelTick, 0, t.Time, t.Last);

            if (t.IsPosClosed)
            {
                bool isProfit = t.CurrentSignal * (t.Last - t.CurrentPosOpenRate) > 0;
                int  index    = isProfit ? 1 : 2;

                var hls = PlotModelTick.Series[index] as HighLowSeries;
                if (hls != null)
                {
                    var dp = new HighLowItem(
                        DateTimeAxis.ToDouble(t.CurrentPosOpenTime),
                        Math.Max(t.Last, t.CurrentPosOpenRate.Value),
                        Math.Min(t.Last, t.CurrentPosOpenRate.Value),
                        t.CurrentPosOpenRate.Value, t.Last);
                    hls.Items.Add(dp);
                }
            }
        }
Пример #5
0
        private void RefreshZGraph()
        {
            _plot.Series.Clear();
            var lineSeries1 = new LineSeries
            {
                Title                 = string.Empty,
                MarkerFill            = OxyColor.FromRgb(255, 0, 0),
                MarkerSize            = 1,
                MarkerStroke          = OxyColor.FromRgb(255, 0, 0),
                MarkerStrokeThickness = 1.5,
                MarkerType            = MarkerType.Circle
            };

            _plot.Series.Add(lineSeries1);
            var prof = Presenter.ThisProfile.Datapoints;

            foreach (var tp1 in prof)
            {
                var x      = DateTimeAxis.ToDouble(tp1.DateAndTime);
                var y      = tp1.Value;
                var bottom = new DataPoint(x, y);
                lineSeries1.Points.Add(bottom);
            }
            foreach (var axis in _plot.Axes)
            {
                axis.Reset();
            }
            _plot.InvalidatePlot(true);
        }
Пример #6
0
        public PlotViewModel()
        {
            Model = new PlotModel {
                Title = "体温"
            };
            var line = new LineSeries();

            TemperatureSQLite database = new TemperatureSQLite();
            var _datas = new ObservableCollection <TemperatureTableEntity>();

            _datas = database.GetAllRecordsOrderByDatetime();

            line.Color = OxyColors.Red;

            foreach (var data in _datas)
            {
                line.Points.Add(new DataPoint(DateTimeAxis.ToDouble(data.Datetime), data.Temperature));
            }

            var Y_ax = new OxyPlot.Axes.LinearAxis {
                Position = OxyPlot.Axes.AxisPosition.Left, Minimum = 33.0, Maximum = 45.0
            };
            var X_ax = new OxyPlot.Axes.DateTimeAxis {
                Position = OxyPlot.Axes.AxisPosition.Bottom, StringFormat = "MM/dd hh:mm"
            };

            Model.Axes.Add(X_ax);
            Model.Axes.Add(Y_ax);

            Model.Series.Add(line);
        }
Пример #7
0
        private void _addPoint(PlotModel model, int index, DateTime time, double value)
        {
            var ls = model.Series[index] as LineSeries;

            if (ls != null)
            {
                var dp = new DataPoint(DateTimeAxis.ToDouble(time), value);
                ls.Points.Add(dp);
            }
        }
        public void Update(double bid, double ask, DateTime barTime)
        {
            if (Candles.Count > 0)
            {
                var lastCandle = Candles.Last();

                var dateTime = DateTimeAxis.ToDateTime(lastCandle.X);

                if (dateTime.Equals(barTime))
                {
                    lastCandle.Low   = Math.Min(lastCandle.Low, bid);
                    lastCandle.High  = Math.Max(lastCandle.High, bid);
                    lastCandle.Close = bid;
                }
                else
                {
                    Candles.Add(new HighLowItem(
                                    x: DateTimeAxis.ToDouble(barTime),
                                    high: bid,
                                    low: bid,
                                    open: lastCandle.Close,
                                    close: bid));
                }
            }
            else
            {
                Candles.Add(new HighLowItem(
                                x: DateTimeAxis.ToDouble(barTime),
                                high: bid,
                                low: bid,
                                open: bid,
                                close: bid));
            }

            BidLineAnnotation.Text = bid.ToString(CultureInfo.InvariantCulture);
            BidLineAnnotation.Y    = bid;

            AskLineAnnotation.Text = ask.ToString(CultureInfo.InvariantCulture);
            AskLineAnnotation.Y    = ask;

            if (XAutoScroll)
            {
                var actualMax = XAxis.ActualMaximum;
                var newMaxX   = DateTimeAxis.ToDouble(barTime) + PeriodToX(TimeSpan.FromMinutes(30));

                var panDelta = XAxis.Transform(-(newMaxX - actualMax) + XAxis.Offset);

                XAxis.Pan(panDelta);
                XAxis.AbsoluteMaximum = newMaxX;
            }

            Model.InvalidatePlot(true);
        }
Пример #9
0
        public static OxyPlot.Axes.Axis AddDateTimeAxis(this PlotModel model, string title, DateTimeIntervalType interval = DateTimeIntervalType.Auto)
        {
            var axis = new OxyPlot.Axes.DateTimeAxis
            {
                IntervalType  = interval,
                Position      = AxisPosition.Bottom,
                Title         = title,
                MajorTickSize = 3.0,
                MinorTickSize = 1.0
            };

            model.Axes.Add(axis);
            return(axis);
        }
        private void UserControl_Loaded([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e)
        {
            _plot         = new PlotModel();
            _dateTimeAxis = new DateTimeAxis {
                Position = AxisPosition.Bottom
            };
            _plot.Axes.Add(_dateTimeAxis);
            _linearAxis = new LinearAxis();
            _plot.Axes.Add(_linearAxis);
            var pv = new PlotView {
                Model = _plot
            };

            ChartGrid.Children.Add(pv);
            RefreshZGraph();
        }
Пример #11
0
        private void SetUpModel(double minValue, double maxValue, DateTime date1)
        {

            MyModel.LegendTitle = "Legend";
            MyModel.LegendOrientation = LegendOrientation.Horizontal;
            MyModel.LegendPlacement = LegendPlacement.Outside;
            MyModel.LegendPosition = LegendPosition.TopRight;
            MyModel.LegendBackground = OxyColor.FromAColor(100, OxyColors.White);
            MyModel.LegendBorder = OxyColors.Black;

            var dateAxis = new OxyPlot.Axes.DateTimeAxis(AxisPosition.Bottom, "Date", "dd/MM/yy HH:mm") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 80, Minimum = DateTimeAxis.ToDouble(date1) };

            MyModel.Axes.Add(dateAxis);

            var valueAxis = new OxyPlot.Axes.LinearAxis(AxisPosition.Left, minValue, maxValue) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Value" };
            MyModel.Axes.Add(valueAxis);
        }
Пример #12
0
        private static void AdjustYExtent(CandleStickAndVolumeSeries series, OxyPlot.Axes.DateTimeAxis xaxis, OxyPlot.Axes.LogarithmicAxis yaxis)
        {
            var xmin = xaxis.ActualMinimum;
            var xmax = xaxis.ActualMaximum;

            var istart = series.FindByX(xmin);
            var iend   = series.FindByX(xmax);

            var ymin = double.MaxValue;
            var ymax = double.MinValue;

            for (int i = istart; i < iend + 1; i++)
            {
                var bar = series.Items[i];
                ymin = Math.Min(ymin, bar.Low);
                ymax = Math.Max(ymax, bar.High);
            }

            yaxis.Zoom(ymin * (0.999), ymax * 1.001);
        }
Пример #13
0
        private void SetUpModelNew()
        {
            PlotModel.LegendTitle       = "Legend";
            PlotModel.LegendOrientation = LegendOrientation.Horizontal;
            PlotModel.LegendPlacement   = LegendPlacement.Outside;
            PlotModel.LegendPosition    = LegendPosition.TopRight;
            PlotModel.LegendBackground  = OxyColor.FromAColor(200, OxyColors.White);
            PlotModel.LegendBorder      = OxyColors.Black;
            // ; "Date", )
            var dateAxis = new OxyPlot.Axes.DateTimeAxis()
            {
                StringFormat = "dd/MM/yy", Title = "Sales Date", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 80
            };

            PlotModel.Axes.Add(dateAxis);
            var valueAxis = new OxyPlot.Axes.LinearAxis()
            {
                AxisDistance = 0, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Money In Rupee"
            };

            PlotModel.Axes.Add(valueAxis);
        }
Пример #14
0
        public MainWindowViewModel(IConfig config, ICore core)
        {
            dataWindow = new DataWindow(config.StabilizationInterval / config.QueryInterval, config.WarningLevel, config.StabilizationInterval)
            {
                Event = (sender, eventArgs) => MessageBox.Show($"{eventArgs} > {config.WarningLevel}", "CO2", MessageBoxButton.OK, MessageBoxImage.Exclamation)
            };
            Plot = new PlotModel {
                Title = "График концентрации углекислого газа"
            };

            Plot.Axes.Add(new DateTimeAxis {
                Minimum = DateTimeAxis.ToDouble(DateTime.Now),
                Title   = "Время",
                Maximum = DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(5))
            });
            Plot.Axes.Add(new LinearAxis {
                Title = "CO2, ppm", Minimum = 200, Maximum = 2000
            });

            Plot.Series.Add(new LineSeries {
                ItemsSource = Items
            });

            Start = ReactiveCommand.CreateAsyncObservable(_ =>
                                                          Observable.Interval(TimeSpan.FromSeconds(config.QueryInterval)).StartWith(0).Select(__ => core.SendCommandAndGetPpm())
                                                          .TakeUntil(Stop));
            Start.ThrownExceptions.Subscribe(e => Console.WriteLine(e.Message));

            Stop = ReactiveCommand.Create(Start.IsExecuting);

            _ppm = Start.ToProperty(this, m => m.Ppm);

            this.WhenAnyValue(m => m.Ppm).Where(v => v > 0).Subscribe(newValue =>
            {
                Items.Add(DateTimeAxis.CreateDataPoint(DateTime.Now, newValue));
                Plot.InvalidatePlot(true);
                dataWindow.Add(newValue);
            });
        }
Пример #15
0
        public void Log(ImmutableArray <CapitalGain> capitalGains)
        {
            var model = new PlotModel
            {
                Title = $"Capital Gain {_currentFiat.Name} {_taxMethodology}"
            };

            decimal previous = 0;
            var     serie1   = new LineSeries
            {
                ItemsSource = capitalGains
                              .GroupBy(t => t.SoldTimeReadable.Date)
                              .OrderBy(t => t.Key)
                              .Select(t =>
                {
                    var x     = DateTimeAxis.ToDouble(t.Key);
                    previous += t.Sum(t2 => t2.Gain);
                    return(new DataPoint(x, (double)previous));
                }).ToArray(),
                Title    = "Capital gain",
                YAxisKey = "PrimaryAxis"
            };

            var btcSeriePoints = GetBtcSerie(capitalGains[0].SoldTimeReadable, capitalGains[^ 1].SoldTimeReadable);
Пример #16
0
        public Graf()
        {
            DataPlot = new PlotModel();

            // vytvoreni serie vykreslovanych bodu
            DataPlot.Series.Add(new LineSeries()
            {
                MarkerType = MarkerType.Diamond, MarkerSize = 4, MarkerFill = OxyColors.YellowGreen, MarkerStroke = OxyColors.DarkGreen, MarkerStrokeThickness = .5, TrackerFormatString = "{2:HH:mm:ss}: {4:0.00} °C", Background = OxyColors.WhiteSmoke
            });
            DataPlot.Series.Add(new LineSeries()
            {
                MarkerType = MarkerType.Diamond, MarkerSize = 4, MarkerFill = OxyColors.YellowGreen, MarkerStroke = OxyColors.DarkGreen, MarkerStrokeThickness = .5, TrackerFormatString = "{2:HH:mm:ss}: {4:0.00} °C", Background = OxyColors.WhiteSmoke
            });
            DataPlot.Series.Add(new LineSeries()
            {
                MarkerType = MarkerType.Diamond, MarkerSize = 4, MarkerFill = OxyColors.YellowGreen, MarkerStroke = OxyColors.DarkGreen, MarkerStrokeThickness = .5, TrackerFormatString = "{2:HH:mm:ss}: {4:0.00} °C", Background = OxyColors.WhiteSmoke
            });

            // posun osy ... defaultne o 290 s (zobrazeni dat v grafu o delce 5 min)
            posunOsy = -300;

            DataPlot.Title      = "Průběh teploty (5 min)";
            DataPlot.TitleColor = OxyColors.WhiteSmoke;
            DataPlot.Background = OxyColors.Transparent;

            // osa x
            OxyPlot.Axes.DateTimeAxis datetimeAxis1 = new OxyPlot.Axes.DateTimeAxis()
            {
                Position          = AxisPosition.Bottom,
                StringFormat      = "HH:mm",//Constants.MarketData.DisplayDateFormat,
                Title             = "Čas  [hh:mm]",
                TitleColor        = OxyColors.WhiteSmoke,
                TickStyle         = TickStyle.Inside,
                TextColor         = OxyColors.WhiteSmoke,
                FontWeight        = OxyPlot.FontWeights.Bold,
                TitleFontWeight   = OxyPlot.FontWeights.Bold,
                AxisTitleDistance = 10,
                //IntervalLength = 60,
                //MinorIntervalType = OxyPlot.Axes.DateTimeIntervalType.Seconds,
                //IntervalType = OxyPlot.Axes.DateTimeIntervalType.Minutes,
                //IntervalType = OxyPlot.Axes.DateTimeIntervalType.Seconds,
                //MinorIntervalType = OxyPlot.Axes.DateTimeIntervalType.Milliseconds,

                //IntervalType = DateTimeIntervalType.Minutes,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Solid,
                MajorGridlineColor = OxyColors.Black,
                MinorGridlineColor = OxyColors.Red,
                Minimum            = OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now),
                Maximum            = OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(5)),
                //AbsoluteMinimum = OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(-1)), //DateTime.Now.AddHours(-1)),
                //AbsoluteMaximum = OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(10)),

                //MinimumRange = 1e-3//DateTimeAxis.ToDouble(new DateTime(2015,7,24,01,0,10))
                IsZoomEnabled = false,
                IsPanEnabled  = false,

                MaximumPadding = 0.05,
                MinimumPadding = 0.05
            };// DateTimeAxis()
              //datetimeAxis1.AxisChanged += datetimeAxis1_AxisChanged;

            DataPlot.Axes.Add(datetimeAxis1);

            // osa y
            var linearAxis2 = new OxyPlot.Axes.LinearAxis()
            {
                Title              = "Teplota [°C]",
                TitleColor         = OxyColors.WhiteSmoke,
                TickStyle          = TickStyle.Inside,
                TextColor          = OxyColors.WhiteSmoke,
                FontWeight         = OxyPlot.FontWeights.Bold,
                TitleFontWeight    = OxyPlot.FontWeights.Bold,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dash,
                MajorGridlineColor = OxyColors.Black,
                MinorStep          = 5,

                AxisTitleDistance = 8,
                IsPanEnabled      = false,
                IsZoomEnabled     = false,
                Selectable        = false,
                Minimum           = 10,
                Maximum           = 40,
                AbsoluteMinimum   = 0,
                AbsoluteMaximum   = 50
            };

            DataPlot.Axes.Add(linearAxis2);

            DateTime cas = DateTime.Now; cas = cas.AddMilliseconds(-cas.Millisecond).AddSeconds(-cas.Second);

            start5MinOsy  = cas.AddMinutes(-cas.Minute % 5);
            start1HodOsy  = cas.AddMinutes(-cas.Minute).AddSeconds(-cas.Second);
            start24HodOsy = Process.GetCurrentProcess().StartTime;
        }
Пример #17
0
        public void C02_DateTimeAxis_WithSomeUndefinedPoints()
        {
            var plot = new PlotModel("DateTime axis") { PlotMargins = new OxyThickness(100, 40, 20, 100) };
            var xaxis = new DateTimeAxis(AxisPosition.Bottom, "DateTime X", null, DateTimeIntervalType.Days) { Angle = -46, MajorStep = 1 };
            var yaxis = new DateTimeAxis(AxisPosition.Left, "DateTime Y", null, DateTimeIntervalType.Days) { Angle = -45, MajorStep = 1 };
            plot.Axes.Add(xaxis);
            plot.Axes.Add(yaxis);

            var ls = new LineSeries();
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 1), new DateTime(2011, 3, 1)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(double.NaN, new DateTime(2011, 3, 8)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 6), new DateTime(2011, 3, 12)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 10), double.NaN));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 19), new DateTime(2011, 3, 14)));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "C02");
        }
Пример #18
0
        public Example GenerateGraph(Stock Stck, Stock.Interval Period)
        {
            int    length    = 0;
            double startPost = 0;
            double endPOs    = 0;
            List <TradingPeriod> TradingList = new List <TradingPeriod>();

            switch (Period)
            {
            case Stock.Interval.Hour:
                length      = Stck.HourlyHist.Count;
                TradingList = Stck.HourlyHist;
                startPost   = length + 6;
                endPOs      = length - 50;
                break;

            case Stock.Interval.Day:
                length      = Stck.DailyHist.Count;
                TradingList = Stck.DailyHist;
                startPost   = length + 6;
                endPOs      = length - 110;
                break;

            case Stock.Interval.Week:
                length      = Stck.WeeklyHist.Count;
                TradingList = Stck.WeeklyHist;
                startPost   = length + 6;
                endPOs      = length - 80;
                break;

            case Stock.Interval.Month:
                length      = Stck.MonthlyHist.Count;
                TradingList = Stck.MonthlyHist;
                startPost   = length + 3;
                endPOs      = length - 48;
                break;
            }

            VolumeStyle style    = VolumeStyle.Combined;
            bool        naturalY = false;
            bool        naturalV = false;

            var pm = new PlotModel {
            };

            var series = new CandleStickAndVolumeSeries
            {
                PositiveColor      = OxyColors.DarkGreen,
                NegativeColor      = OxyColors.Red,
                PositiveHollow     = false,
                NegativeHollow     = false,
                SeparatorColor     = OxyColors.Gray,
                SeparatorLineStyle = LineStyle.Dash,
                VolumeStyle        = VolumeStyle.Combined
            };


            // create bars
            foreach (var v in TradingList)
            {
                OhlcvItem Temp = new OhlcvItem();
                Temp.BuyVolume = (v.Volume);
                Temp.Close     = v.Close;
                Temp.High      = v.High;
                Temp.Low       = v.Low;
                Temp.Open      = v.Open;
                Temp.X         = v.Index;

                series.Append(Temp);
            }

            // create visible window
            var Istart = length - 10;
            var Iend   = length - 1;
            var Ymin   = series.Items.Skip((int)endPOs).Take((int)startPost - (int)endPOs + 1).Select(x => x.Low).Min();
            var Ymax   = series.Items.Skip((int)endPOs).Take((int)startPost - (int)endPOs + 1).Select(x => x.High).Max();

            // setup axes
            var timeAxis = new OxyPlot.Axes.DateTimeAxis
            {
                Position = AxisPosition.Bottom,
                Minimum  = endPOs,
                Maximum  = startPost,

                //StartPosition = Xmax - TimeSpan.FromDays(180).Ticks,
                //EndPosition = Xmax,
            };

            var barAxis = new OxyPlot.Axes.LogarithmicAxis()
            {
                Position      = AxisPosition.Left,
                Key           = series.BarAxisKey,
                StartPosition = 0.15,
                EndPosition   = 1.0,
                Minimum       = naturalY ? double.NaN : Ymin,
                Maximum       = naturalY ? double.NaN : Ymax,
            };
            var volAxis = new OxyPlot.Axes.LinearAxis()
            {
                Position      = AxisPosition.Left,
                Key           = series.VolumeAxisKey,
                StartPosition = 0.0,
                EndPosition   = 0.15,
                Minimum       = naturalV ? double.NaN : 0,
                Maximum       = naturalV ? double.NaN : TradingList.Max(x => x.Volume)
            };

            switch (style)
            {
            case VolumeStyle.None:
                barAxis.Key           = null;
                barAxis.StartPosition = 0.0;
                pm.Axes.Add(timeAxis);
                pm.Axes.Add(barAxis);
                break;

            case VolumeStyle.Combined:
            case VolumeStyle.Stacked:
                pm.Axes.Add(timeAxis);
                pm.Axes.Add(barAxis);
                pm.Axes.Add(volAxis);
                break;

            case VolumeStyle.PositiveNegative:
                volAxis.Minimum = naturalV ? double.NaN : -5000;
                pm.Axes.Add(timeAxis);
                pm.Axes.Add(barAxis);
                pm.Axes.Add(volAxis);
                break;
            }

            pm.Series.Add(series);



            if (naturalY == false)
            {
                timeAxis.AxisChanged += (sender, e) => AdjustYExtent(series, timeAxis, barAxis);
                //timeAxis.AxisChanged += (sender, e) => AdjustYExtent(series, timeAxis, volAxis);
            }

            ///Adding Pivot Annotation
            ///
            Stck.GetPivots(Period);

            var ResistanceLines   = new List <OxyPlot.Annotations.LineAnnotation>();
            var FirstOrderPivots  = new List <OxyPlot.Annotations.PointAnnotation>();
            var SecondOrderPivots = new List <OxyPlot.Annotations.PointAnnotation>();
            var ThirdOrderPivots  = new List <OxyPlot.Annotations.PointAnnotation>();

            foreach (var f in TradingList)
            {
                if (f.IsPivotHigh[0])
                {
                    FirstOrderPivots.Add(new OxyPlot.Annotations.PointAnnotation()
                    {
                        Fill = OxyColors.LawnGreen, X = f.Index, Y = f.High
                    });
                }
                if (f.IsPivotHigh[1])
                {
                    SecondOrderPivots.Add(new OxyPlot.Annotations.PointAnnotation()
                    {
                        Fill = OxyColors.Green, X = f.Index, Y = f.High
                    });
                }
                if (f.IsPivotHigh[2])
                {
                    ThirdOrderPivots.Add(new OxyPlot.Annotations.PointAnnotation()
                    {
                        Fill = OxyColors.DarkGreen, X = f.Index, Y = f.High
                    });
                }
                if (f.IsPivotLow[0])
                {
                    FirstOrderPivots.Add(new OxyPlot.Annotations.PointAnnotation()
                    {
                        Fill = OxyColors.Pink, X = f.Index, Y = f.Low
                    });
                }
                if (f.IsPivotLow[1])
                {
                    SecondOrderPivots.Add(new OxyPlot.Annotations.PointAnnotation()
                    {
                        Fill = OxyColors.Red, X = f.Index, Y = f.Low
                    });
                }
                if (f.IsPivotLow[2])
                {
                    ThirdOrderPivots.Add(new OxyPlot.Annotations.PointAnnotation()
                    {
                        Fill = OxyColors.DarkRed, X = f.Index, Y = f.Low
                    });
                }
            }
            ResistanceLines = MarketStructure.DefineSupportResistanceZonesPivots(Stck, Period);

            GraphOverlays FOP   = new GraphOverlays();
            GraphOverlays SOP   = new GraphOverlays();
            GraphOverlays TOP   = new GraphOverlays();
            GraphOverlays Lines = new GraphOverlays();

            FOP.Name   = "First Order Pivot";
            SOP.Name   = "Second Order Pivot";
            TOP.Name   = "Third Order Pivot";
            Lines.Name = "Resistance Lines";

            FOP.Overlay   = FirstOrderPivots;
            SOP.Overlay   = SecondOrderPivots;
            TOP.Overlay   = ThirdOrderPivots;
            Lines.Overlay = ResistanceLines;

            FOP.Period   = Period;
            SOP.Period   = Period;
            TOP.Period   = Period;
            Lines.Period = Period;

            CurrentOverlays.Add(FOP);
            CurrentOverlays.Add(SOP);
            CurrentOverlays.Add(TOP);
            CurrentOverlays.Add(Lines);
            ///Adding line annotation...


            var la = new OxyPlot.Annotations.LineAnnotation {
                Type = LineAnnotationType.Horizontal, Y = TradingList.Last().Close
            };

            la.MouseDown += (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }

                la.StrokeThickness *= 5;
                pm.InvalidatePlot(false);
                e.Handled = true;
            };

            // Handle mouse movements (note: this is only called when the mousedown event was handled)
            la.MouseMove += (s, e) =>
            {
                la.Y    = la.InverseTransform(e.Position).Y;
                la.Text = string.Format("{0:0.###}", la.Y);
                pm.InvalidatePlot(false);
                e.Handled = true;
            };
            la.MouseUp += (s, e) =>
            {
                la.StrokeThickness /= 5;
                pm.InvalidatePlot(false);
                e.Handled = true;
            };
            pm.Annotations.Add(la);

            OxyPlot.Annotations.ArrowAnnotation tmp = null;

            pm.MouseDown += (s, e) =>
            {
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    // Create a new arrow annotation
                    tmp            = new OxyPlot.Annotations.ArrowAnnotation();
                    tmp.HeadLength = 0;
                    tmp.StartPoint = tmp.EndPoint = timeAxis.InverseTransform(e.Position.X, e.Position.Y, barAxis);
                    pm.Annotations.Add(tmp);
                    e.Handled = true;
                }
                if (e.ChangedButton == OxyMouseButton.Middle)
                {
                    //delete old arrow annotation
                    if (e.HitTestResult != null)
                    {
                        if (e.HitTestResult.Element.GetType() == typeof(OxyPlot.Annotations.ArrowAnnotation))
                        {
                            tmp = (OxyPlot.Annotations.ArrowAnnotation)e.HitTestResult.Element;
                            pm.Annotations.Remove(tmp);
                            e.Handled = true;
                        }
                    }
                }
            };

            // Handle mouse movements (note: this is only called when the mousedown event was handled)
            pm.MouseMove += (s, e) =>
            {
                if (tmp != null)
                {
                    // Modify the end point
                    tmp.EndPoint   = timeAxis.InverseTransform(e.Position.X, e.Position.Y, barAxis);
                    tmp.FontWeight = FontWeights.Bold;
                    tmp.Text       = string.Format("{0:0.##}%", ((tmp.StartPoint.Y - tmp.EndPoint.Y) * -100) / tmp.StartPoint.Y);

                    // Redraw the plot
                    pm.InvalidatePlot(false);
                    e.Handled = true;
                }
            };

            pm.MouseUp += (s, e) =>
            {
                if (tmp != null)
                {
                    tmp       = null;
                    e.Handled = true;
                }
            };
            pm.Title = Stck.StockName;

            var controller = new PlotController();

            //controller.UnbindAll();
            //controller.BindMouseDown(OxyMouseButton.Middle, PlotCommands);
            //controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            //controller.BindMouseDown(OxyMouseButton.Middle,  );

            return(new Example(pm, controller));
        }
Пример #19
0
        public void C01_DateTimeAxis()
        {
            var plot = new PlotModel { Title = "DateTime axis", PlotMargins = new OxyThickness(100, 40, 20, 100) };
            var xaxis = new DateTimeAxis
            {
                Position = AxisPosition.Bottom,
                Title = "DateTime X",
                IntervalType = DateTimeIntervalType.Days,
                Angle = -46,
                MajorStep = 1
            };
            var yaxis = new DateTimeAxis
            {
                Position = AxisPosition.Left,
                Title = "DateTime Y",
                IntervalType = DateTimeIntervalType.Days,
                Angle = -45,
                MajorStep = 1
            };
            plot.Axes.Add(xaxis);
            plot.Axes.Add(yaxis);

            var ls = new LineSeries();
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 1), new DateTime(2011, 3, 1)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 4), new DateTime(2011, 3, 8)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 6), new DateTime(2011, 3, 12)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 10), new DateTime(2011, 3, 13)));
            ls.Points.Add(DateTimeAxis.CreateDataPoint(new DateTime(2011, 1, 19), new DateTime(2011, 3, 14)));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "C01");
        }
Пример #20
0
        public void C03_DateTimeAxis_WithAllUndefinedPoints()
        {
            var plot = new PlotModel { Title = "DateTime axis", PlotMargins = new OxyThickness(100, 40, 20, 100) };
            var xaxis = new DateTimeAxis
            {
                Position = AxisPosition.Bottom,
                Title = "DateTime X",
                IntervalType = DateTimeIntervalType.Days,
                Angle = -46,
                MajorStep = 1
            };
            var yaxis = new DateTimeAxis
            {
                Position = AxisPosition.Left,
                Title = "DateTime Y",
                IntervalType = DateTimeIntervalType.Days,
                Angle = -45,
                MajorStep = 1
            };
            plot.Axes.Add(xaxis);
            plot.Axes.Add(yaxis);

            var ls = new LineSeries();
            ls.Points.Add(new DataPoint(double.NaN, double.NaN));
            ls.Points.Add(new DataPoint(double.NaN, double.NaN));
            plot.Series.Add(ls);

            OxyAssert.AreEqual(plot, "C03");
        }
Пример #21
0
        public static PlotModel LoadChartData(WhlSKU paraSku)
        {
            if (paraSku != null)
            {
                var plotArea   = new PlotModel();
                var endDate    = DateTime.Now.ToOADate();
                var startDate  = DateTime.Now.AddMonths(-6).ToOADate();
                var bottomAxis =
                    new OxyPlot.Axes.DateTimeAxis
                {
                    Position          = AxisPosition.Bottom,
                    Maximum           = Convert.ToDouble(endDate),
                    AbsoluteMaximum   = Convert.ToDouble(endDate),
                    Title             = "Date",
                    StringFormat      = "dd/M",
                    MinorIntervalType = DateTimeIntervalType.Days
                };


                var leftAxis = new OxyPlot.Axes.LinearAxis
                {
                    Position        = AxisPosition.Left,
                    Minimum         = 0,
                    AbsoluteMinimum = 0,
                    Title           = "Sales"
                };
                var rightAxis = new OxyPlot.Axes.LinearAxis
                {
                    Position        = AxisPosition.Right,
                    Minimum         = 0,
                    AbsoluteMinimum = 0,
                    Maximum         = 5000,
                    Title           = "Stock"
                };


                var query     = @"SELECT a.shortSku, a.stockDate, a.Stocklevel, a.StockMinimum, b.maintotal 
                          FROM whldata.stock_history as a
                            LEFT JOIN(SELECT top (999999999999) a.orderdate, a.shortsku, sum(a.total)as ""maintotal"" FROM
                            (SELECT top (999999999999) orderdate, sku, SUBSTRING(sku, 0, 8) as ""shortsku"", sum(salequantity) as ""sales"", CAST(SUBSTRING(sku, 8, 4) as /*unsigned*/ int) as ""packsize"", sum(salequantity * CAST(SUBSTRING(sku, 8, 4) as /*unsigned*/ int)) as 'total'
                             FROM whldata.newsales_raw
                             WHERE sku LIKE '" + paraSku.ShortSku + @"%'
                             group by sku, orderDate
                             order by orderdate) as a
                            GROUP BY orderdate, shortsku
                            ORDER BY orderDate) as b
                            on b.shortsku = SUBSTRING(a.shortSku, 0, 8) AND b.orderDate = a.stockDate
                            WHERE a.shortsku = '" + paraSku.SKU + @"'
                            ORDER BY StockDate ASC";
                var queryDict = SQLServer.MSSelectDataDictionary(query);
                if (queryDict == null)
                {
                    throw new NullReferenceException();
                }

                var stockHistoryPoints     = new List <DataPoint>();
                var salesHistoryPoints     = new List <DataPoint>();
                var stockHistoryFillPoints = new List <DataPoint>();
                var salesHistoryFillPoints = new List <DataPoint>();


                var salesSeries = new LineSeries();
                var stockSeries = new LineSeries();

                OxyPlot.Series.AreaSeries stockAreaSeries = new OxyPlot.Series.AreaSeries();
                OxyPlot.Series.AreaSeries salesAreaSeries = new OxyPlot.Series.AreaSeries();
                var maxStock = 0;
                var maxSales = 0;
                if (queryDict.Count != 0)
                {
                    try
                    {
                        bottomAxis.AbsoluteMinimum =
                            Convert.ToDouble(DateTime.Parse((queryDict[0])["stockDate"].ToString()).ToOADate());
                        bottomAxis.Minimum =
                            Convert.ToDouble(DateTime.Parse((queryDict[0])["stockDate"].ToString()).ToOADate());
                    }
                    catch (Exception)
                    {
                        bottomAxis.AbsoluteMinimum = Convert.ToDouble(startDate);
                        bottomAxis.Minimum         = Convert.ToDouble(startDate);
                    }

                    foreach (var result in queryDict)
                    {
                        var    stockTotal = Convert.ToDouble(int.Parse(result["Stocklevel"].ToString()));
                        double salesTotal;

                        try
                        {
                            if (maxStock < int.Parse(result["Stocklevel"].ToString()) + int.Parse(result["StockMinimum"].ToString()))
                            {
                                maxStock = int.Parse(result["Stocklevel"].ToString()) + int.Parse(result["StockMinimum"].ToString());
                            }
                            if (DBNull.Value != result["maintotal"])
                            {
                                if (maxSales < int.Parse(result["maintotal"].ToString()))
                                {
                                    maxSales = int.Parse(result["maintotal"].ToString());
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }
                        salesTotal = Convert.ToDouble(result["maintotal"] == DBNull.Value ? 0 : int.Parse(result["maintotal"].ToString()));


                        var date = Convert.ToDouble(DateTime.Parse(result["stockDate"].ToString()).ToOADate());
                        var stockHistoryPoint  = new DataPoint(date, stockTotal);
                        var saleHistoryPoint   = new DataPoint(date, salesTotal);
                        var stockHistoryPoint2 = new DataPoint(date, 0);
                        salesHistoryPoints.Add(saleHistoryPoint);
                        stockHistoryPoints.Add(stockHistoryPoint);

                        salesHistoryFillPoints.Add(stockHistoryPoint2);
                        stockHistoryFillPoints.Add(stockHistoryPoint2);
                    }
                }
                else
                {
                    var queryDict2 = SQLServer.MSSelectData(
                        "SELECT StockLevel,StockMinimum,StockDate from whldata.stock_history WHERE sku="
                        + paraSku.ShortSku + "';") as ArrayList;
                    if (queryDict2 != null)
                    {
                        foreach (ArrayList result in queryDict2)
                        {
                            if (maxStock < int.Parse(result[0].ToString()) + int.Parse(result[1].ToString()))
                            {
                                maxStock = int.Parse(result[0].ToString()) + int.Parse(result[1].ToString());
                            }

                            var stockLevel         = Convert.ToDouble(int.Parse(result[0].ToString()));
                            var date               = Convert.ToDouble(DateTime.Parse(result[2].ToString()).ToOADate());
                            var stockHistoryPoint  = new DataPoint(date, stockLevel);
                            var stockHistoryPoint2 = new DataPoint(date, 0);
                            stockHistoryPoints.Add(stockHistoryPoint);
                            stockHistoryFillPoints.Add(stockHistoryPoint2);
                        }
                    }
                }

                salesSeries.Points.AddRange(salesHistoryPoints);
                stockSeries.Points.AddRange(stockHistoryPoints);


                rightAxis.Key        = "StockKey";
                salesSeries.YAxisKey = leftAxis.Key;
                salesSeries.CanTrackerInterpolatePoints = false;
                salesSeries.Color    = OxyColor.FromRgb(237, 125, 49);
                salesSeries.Title    = "Sales History";
                stockSeries.YAxisKey = rightAxis.Key;
                stockSeries.CanTrackerInterpolatePoints = false;

                stockAreaSeries.Points.AddRange(stockHistoryPoints);
                stockAreaSeries.YAxisKey = rightAxis.Key;
                stockAreaSeries.CanTrackerInterpolatePoints = false;
                stockAreaSeries.Fill   = OxyColor.FromRgb(176, 195, 230);
                stockAreaSeries.Color  = OxyColor.FromRgb(138, 167, 218);
                stockAreaSeries.Color2 = OxyColor.FromRgb(138, 167, 218);
                stockAreaSeries.Points2.AddRange(stockHistoryFillPoints);

                stockAreaSeries.Title = "Stock History Area";

                salesAreaSeries.Points.AddRange(salesHistoryPoints);
                salesAreaSeries.CanTrackerInterpolatePoints = false;
                salesAreaSeries.Fill   = OxyColor.FromArgb(140, 237, 125, 49);
                salesAreaSeries.Color  = OxyColor.FromArgb(255, 138, 167, 218);
                salesAreaSeries.Color2 = OxyColor.FromRgb(138, 167, 218);
                salesAreaSeries.Points2.AddRange(stockHistoryFillPoints);

                salesAreaSeries.Title = "Sales History Area";


                plotArea.Series.Add(stockAreaSeries);
                plotArea.Series.Add(salesAreaSeries);


                if (maxSales == 0)
                {
                    leftAxis.AbsoluteMaximum   = 1;
                    rightAxis.AbsoluteMaximum += 10;
                    leftAxis.Title             = "No sales";
                }
                if (maxSales > 0)
                {
                    leftAxis.AbsoluteMaximum  = (maxSales * 1.15) + 10;
                    leftAxis.Maximum          = (maxSales * 1.1) + 10;
                    rightAxis.Maximum         = maxStock * 1.1;
                    rightAxis.AbsoluteMaximum = maxStock * 1.15;
                }

                rightAxis.AbsoluteMaximum = maxStock;
                plotArea.Axes.Add(bottomAxis);
                plotArea.Axes.Add(leftAxis);
                plotArea.Axes.Add(rightAxis);

                plotArea.Title = paraSku.ShortSku + " Sales/Stock History";

                return(plotArea);
            }
            else
            {
                return(null);
            }
        }
Пример #22
0
        public WindowArchiveChart(List <string> colSelect, List <string> colTableName)
        {
            InitializeComponent();

            AppWPF app = (AppWPF)Application.Current;

            MainWindow window = (MainWindow)Application.Current.MainWindow;

            if (app.ConfigProgramBin.UseDatabase)
            {
                //SqlConnectionStringBuilder Sqlbuilder = new SqlConnectionStringBuilder();
                //Sqlbuilder.DataSource = app.ConfigProgramBin.SQLServerName;
                //Sqlbuilder.InitialCatalog = app.ConfigProgramBin.SQLDatabaseName;

                //if (((AppWPF)Application.Current).ConfigProgramBin.SQLSecuritySSPI)
                //{
                //    Sqlbuilder.IntegratedSecurity = true;
                //}
                //else
                //{
                //    Sqlbuilder.UserID = app.ConfigProgramBin.SQLUserName;
                //    Sqlbuilder.Password = app.ConfigProgramBin.SQLPassword;
                //}

                string connstring = String.Format("Server={0};Port={1};" +
                                                  "User Id={2};Password={3};Database={4};",
                                                  app.ConfigProgramBin.SQLServerName, 5432, app.ConfigProgramBin.SQLUserName,
                                                  app.ConfigProgramBin.SQLPassword, app.ConfigProgramBin.SQLDatabaseName);


                Npgsql.NpgsqlConnection conn = new Npgsql.NpgsqlConnection(connstring);

                try
                {
                    conn.Open();

                    PlotModel plotModel = new PlotModel();

                    if (colSelect.Count >= 2)
                    {
                        int count = 0;

                        while (true)
                        {
                            DataTable dataTable = new DataTable();

                            Npgsql.NpgsqlDataAdapter adapter = new Npgsql.NpgsqlDataAdapter(colSelect[count], conn);
                            adapter.Fill(dataTable);

                            adapter.Dispose();

                            OxyPlot.Series.LineSeries line = new OxyPlot.Series.LineSeries()
                            {
                                CanTrackerInterpolatePoints = false,
                                Title  = string.Format(colTableName[count]),
                                Smooth = false,
                                TrackerFormatString = "{0}" + Environment.NewLine + "{3} {4}" + Environment.NewLine + "{1} {2:dd/MM/yyyy HH:mm:ss}"
                            };

                            DataView data = dataTable.DefaultView;

                            foreach (DataRowView rowView in data)
                            {
                                DataRow row = rowView.Row;

                                DateTime dt = (DateTime)row.ItemArray[1];

                                double d = Convert.ToDouble(row.ItemArray[0]);

                                line.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(dt), d));
                            }

                            plotModel.Series.Add(line);

                            count++;

                            if (count == colSelect.Count)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        DataTable dataTable = new DataTable();

                        Npgsql.NpgsqlDataAdapter adapter = new Npgsql.NpgsqlDataAdapter(colSelect[0], conn);
                        adapter.Fill(dataTable);

                        adapter.Dispose();

                        OxyPlot.Series.LineSeries line = new OxyPlot.Series.LineSeries()
                        {
                            CanTrackerInterpolatePoints = false,
                            Title  = string.Format(colTableName[0]),
                            Smooth = false,
                            TrackerFormatString = "{0}" + Environment.NewLine + "{3} {4}" + Environment.NewLine + "{1} {2:dd/MM/yyyy HH:mm:ss}"
                        };

                        DataView data = dataTable.DefaultView;

                        foreach (DataRowView rowView in data)
                        {
                            DataRow row = rowView.Row;

                            DateTime dt = (DateTime)row.ItemArray[1];

                            double d = Convert.ToDouble(row.ItemArray[0]);

                            line.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(dt), d));
                        }

                        plotModel.Series.Add(line);
                    }

                    plotModel.LegendTitle       = "Легенда";
                    plotModel.LegendOrientation = LegendOrientation.Horizontal;
                    plotModel.LegendPlacement   = LegendPlacement.Outside;
                    plotModel.LegendPosition    = LegendPosition.TopRight;
                    plotModel.LegendBackground  = OxyColor.FromAColor(200, OxyColors.White);
                    plotModel.LegendBorder      = OxyColors.Black;

                    var dateAxis = new OxyPlot.Axes.DateTimeAxis(OxyPlot.Axes.AxisPosition.Bottom, "Дата", "dd/MM HH:mm")
                    {
                        MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, IntervalLength = 65
                    };
                    plotModel.Axes.Add(dateAxis);
                    var valueAxis = new OxyPlot.Axes.LinearAxis(AxisPosition.Left)
                    {
                        MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, Title = "Значение"
                    };
                    valueAxis.MaximumPadding = 0.3;
                    valueAxis.MinimumPadding = 0.3;
                    plotModel.Axes.Add(valueAxis);

                    Plot = new Plot();
                    Plot.SetValue(Grid.RowProperty, 1);
                    Plot.Model     = plotModel;
                    Plot.MinHeight = 100;
                    Plot.MinWidth  = 100;

                    GridMain.Children.Add(Plot);
                }
                catch (SystemException ex)
                {
                    if (window.CollectionMessage.Count > 300)
                    {
                        window.CollectionMessage.RemoveAt(0);

                        window.CollectionMessage.Insert(298, "Сообщение " + " : " + "Ошибка в окне Архива " + ex.Message + "  " + DateTime.Now);
                    }
                    else
                    {
                        window.CollectionMessage.Add("Сообщение " + " : " + "Ошибка в окне Архива " + ex.Message + "  " + DateTime.Now);
                    }

                    //if (ex is SqlException)
                    //{
                    //    SqlException sqlex = ex as SqlException;

                    //    foreach (SqlError er in sqlex.Errors)
                    //    {
                    //        if (window.WindowErrorMessages.LBMessageError.Text.Length > 0)
                    //        {
                    //            window.CountLineTextMessage++;
                    //            window.WindowErrorMessages.LBMessageError.Text += "\n" + "Сообщение " + window.CountLineTextMessage.ToString() + " : " + "Ошибка в окне Архива " + er.Message + "  " + DateTime.Now;
                    //        }
                    //        else
                    //        {
                    //            window.CountLineTextMessage++;
                    //            window.WindowErrorMessages.LBMessageError.Text = "Сообщение " + window.CountLineTextMessage.ToString() + " : " + "Ошибка в окне Архива " + er.Message + "  " + DateTime.Now;
                    //        }
                    //    }
                    //}
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }
Пример #23
0
        private void SetUpModel()
        {
            PlotModel.LegendTitle = "Portefeuille vs Benchmark";
            PlotModel.LegendOrientation = LegendOrientation.Horizontal;
            PlotModel.LegendPlacement = LegendPlacement.Outside;
            PlotModel.LegendPosition = LegendPosition.BottomLeft;
            PlotModel.LegendBackground = OxyColor.FromAColor(200, OxyColors.White);
            PlotModel.LegendBorder = OxyColors.Black;

            var dateAxis = new OxyPlot.Axes.DateTimeAxis(AxisPosition.Bottom, "Date", "dd/MM/yy") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot};
            dateAxis.Minimum = OxyPlot.Axes.DateTimeAxis.ToDouble(TDebut);
            dateAxis.Maximum = OxyPlot.Axes.DateTimeAxis.ToDouble(TFin);
            dateAxis.IntervalType = DateTimeIntervalType.Months;
            PlotModel.Axes.Add(dateAxis);
            var valueAxis = new OxyPlot.Axes.LinearAxis(AxisPosition.Left) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Value" };
            PlotModel.Axes.Add(valueAxis);

            PlotModel2.LegendTitle = "Portefeuille vs Benchmark";
            PlotModel2.LegendOrientation = LegendOrientation.Horizontal;
            PlotModel2.LegendPlacement = LegendPlacement.Outside;
            PlotModel2.LegendPosition = LegendPosition.BottomLeft;
            PlotModel2.LegendBackground = OxyColor.FromAColor(200, OxyColors.White);
            PlotModel2.LegendBorder = OxyColors.Black;

            var dateAxis2 = new OxyPlot.Axes.DateTimeAxis(AxisPosition.Bottom, "Date", "dd/MM/yy") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot};
            PlotModel2.Axes.Add(dateAxis2);
            var valueAxis2 = new OxyPlot.Axes.LinearAxis(AxisPosition.Left) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Value" };
            PlotModel2.Axes.Add(valueAxis2);
        }
Пример #24
0
        public void InitPlot(string xAxis = "Time", string yAxis = "Viewers", string format = "HH:mm", bool relative = true)
        {
            if (RelativeTime == null)
            {
                RelativeTime = relative;
            }
            if (xName == null)
            {
                xName = xAxis;
            }
            if (yName == null)
            {
                yName = yAxis;
            }
            if (this.format == null)
            {
                this.format = format;
            }

            if (PlotDataPoints == null)
            {
                PlotDataPoints = new List <KeyValuePair <string, KeyValuePair <double, double> > >();
            }

            viewerChart           = new PlotModel();
            viewerChart.TextColor = OxyColor.FromRgb(175, 175, 175);
            viewerChart.PlotAreaBorderThickness = new OxyThickness(0);
            var valueAxisY = new OxyPlot.Axes.LinearAxis
            {
                Position               = OxyPlot.Axes.AxisPosition.Left,
                TicklineColor          = OxyColor.FromRgb(125, 125, 155),
                Title                  = yName,
                FontSize               = 26,
                TitleFontSize          = 26,
                AxislineThickness      = 3,
                MinorGridlineThickness = 5,
                MajorGridlineThickness = 5,
                MajorGridlineStyle     = LineStyle.Solid,
                FontWeight             = 700,
                TitleFontWeight        = 700,
                AxislineStyle          = LineStyle.Solid,
                AxislineColor          = OxyColor.FromRgb(125, 125, 155)
            };

            if (relative)
            {
                valueAxisY.Minimum = 0;
            }

            var valueAxisX = new OxyPlot.Axes.DateTimeAxis
            {
                Position               = OxyPlot.Axes.AxisPosition.Bottom,
                TicklineColor          = OxyColor.FromRgb(125, 125, 155),
                Title                  = xName,
                FontSize               = 26,
                TitleFontSize          = 26,
                AxislineThickness      = 3,
                MinorGridlineThickness = 5,
                MajorGridlineThickness = 5,
                MajorGridlineStyle     = LineStyle.Solid,
                FontWeight             = 700,
                TitleFontWeight        = 700,
                AxislineStyle          = LineStyle.Solid,
                AxislineColor          = OxyColor.FromRgb(125, 125, 155),
                StringFormat           = this.format
            };

            viewerChart.Axes.Add(valueAxisY);
            viewerChart.Axes.Add(valueAxisX);
            viewerChart.LegendFontSize   = 24;
            viewerChart.LegendPosition   = LegendPosition.BottomCenter;
            viewerChart.LegendBorder     = OxyColor.FromRgb(125, 125, 155);
            viewerChart.LegendBackground = OxyColor.FromArgb(200, 46, 49, 54);
            viewerChart.LegendTextColor  = OxyColor.FromRgb(175, 175, 175);

            areaSeries = new List <OxyPlot.Series.AreaSeries>();

            /*foreach (var plotPoint in PlotPoints)
             * {
             *  AddValue(plotPoint.Key, plotPoint.Value, false);
             * }*/

            if (PlotDataPoints.Count > 0)
            {
                PlotDataPoints = PlotDataPoints.Skip(Math.Max(0, PlotDataPoints.Count - 2000)).ToList();
                StartTime      = DateTimeAxis.ToDateTime(PlotDataPoints.First().Value.Key);
                foreach (var dataPoint in PlotDataPoints)
                {
                    if (!MultipleLines)
                    {
                        AddValue(dataPoint.Key, dataPoint.Value.Value, DateTimeAxis.ToDateTime(dataPoint.Value.Key), false);
                    }
                    else
                    {
                        AddValueSeperate(dataPoint.Key, dataPoint.Value.Value, DateTimeAxis.ToDateTime(dataPoint.Value.Key), false);
                    }
                }
            }
        }
Пример #25
0
        public static void ActivityGraph(string filename, List <double> dailyMoney, ISocketMessageChannel ch)
        {
            TimeSpan        interval  = new TimeSpan(1, 0, 0, 0, 0);
            List <DateTime> gridMarks = new List <DateTime>();

            LineSeries s = new LineSeries
            {
                StrokeThickness = 5,
                Color           = OxyColors.White
            };

            for (int i = 0; i <= dailyMoney.Count; i++)
            {
                gridMarks.Add(DateTime.Now.Subtract(new TimeSpan(7 * i, 0, 0, 0, 0)));
                if (i != dailyMoney.Count)
                {
                    s.Points.Add(new DataPoint(DateTimeAxis.ToDouble(DateTime.Now.Subtract(new TimeSpan(7 * i, 0, 0, 0, 0))), dailyMoney[i]));
                }
            }
            PlotModel plot = new PlotModel
            {
                PlotAreaBorderColor     = OxyColors.White,
                PlotAreaBorderThickness = new OxyThickness(2)
            };

            plot.Axes.Add(new DateTimeAxis
            {
                Position               = AxisPosition.Bottom,
                Title                  = "Time",
                MajorStep              = DateTimeAxis.ToDouble(interval),
                ExtraGridlines         = gridMarks.Select(d => DateTimeAxis.ToDouble(d)).ToArray(),
                ExtraGridlineColor     = OxyColor.FromArgb(120, 76, 255, 0),
                ExtraGridlineThickness = 1.5,
                AxislineColor          = OxyColors.White,
                TitleColor             = OxyColors.White,
                TicklineColor          = OxyColors.White
            });
            LinearAxis l = new LinearAxis()
            {
                Position               = AxisPosition.Left,
                Title                  = "M O N E Y",
                ExtraGridlineColor     = OxyColor.FromArgb(120, 76, 255, 0),
                ExtraGridlineThickness = 1.5,
                TitleColor             = OxyColors.White,
                AxislineColor          = OxyColors.White,
                TicklineColor          = OxyColors.White
            };

            Console.WriteLine(dailyMoney.Max());
            if (dailyMoney.Max() <= int.MaxValue / 1000 && (int)dailyMoney.Max() <= int.MaxValue / 10000)
            {
                l.ExtraGridlines = Enumerable.Range(1, (int)dailyMoney.Max()).Select(i => (double)i * 10000).ToArray();
            }
            else
            {
                l.ExtraGridlines = Enumerable.Range(1, int.MaxValue / 10000).Select(i => (double)i * 10000).ToArray();
            }
            plot.Axes.Add(l);
            plot.Series.Add(s);

            Thread thr = new Thread(new ThreadStart(delegate {
                try {
                    PngExporter.Export(plot, filename + ".png", 2000, 750, OxyColors.Black);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
                }
            }));

            thr.SetApartmentState(ApartmentState.STA);
            thr.Start();
            while (thr.IsAlive)
            {
                Thread.Sleep(100);
            }
        }
        public SymbolTabItem(Symbol symbol)
        {
            Symbol = symbol ?? throw new ArgumentNullException(nameof(symbol));

            Model = new PlotModel();

            XAxis = new DateTimeAxis
            {
                TextColor          = TextColor,
                StringFormat       = XAxisFormat,
                TicklineColor      = TickLineColor,
                AxislineColor      = AxisLineColor,
                AxislineStyle      = LineStyle.Solid,
                MajorGridlineColor = MajorGridLineColor,
                MajorGridlineStyle = LineStyle.Dash,
                MajorStep          = PeriodToX(TimeSpan.FromMinutes(10)),
                Position           = AxisPosition.Bottom,
                IsZoomEnabled      = false,
                MaximumRange       = PeriodToX(TimeSpan.FromHours(1.5)),
                MinimumRange       = PeriodToX(TimeSpan.FromHours(1))
            };

            Model.Axes.Add(XAxis);

            var yAxis = new LinearAxis
            {
                TextColor          = TextColor,
                TicklineColor      = TickLineColor,
                AxislineColor      = AxisLineColor,
                AxislineStyle      = LineStyle.Solid,
                MajorGridlineColor = MajorGridLineColor,
                MajorGridlineStyle = LineStyle.Dash,
                Position           = AxisPosition.Right
            };

            Model.Axes.Add(yAxis);

            Model.PlotAreaBorderThickness = new OxyThickness(thickness: 0);
            Model.PlotAreaBorderColor     = PlotAreaBorderColor;

            CandleStickSeries = new CandleStickSeries
            {
                IncreasingColor = IncreasingColor,
                DecreasingColor = DecreasingColor,
                ItemsSource     = Candles,
                CandleWidth     = PeriodToX(TimeSpan.FromMinutes(1))
            };

            XAxis.AxisChanged += (sender, args) => { AdjustYExtent(CandleStickSeries, XAxis, yAxis); };

            Model.Series.Add(CandleStickSeries);

            BidLineAnnotation = new LineAnnotation
            {
                StrokeThickness  = 1,
                Color            = BidLineColor,
                Type             = LineAnnotationType.Horizontal,
                Text             = 0.0m.ToString(CultureInfo.InvariantCulture),
                TextLinePosition = 1,
                TextColor        = BidLineColor,
                X = 0,
                Y = 0
            };

            AskLineAnnotation = new LineAnnotation
            {
                StrokeThickness       = 1,
                Color                 = AskLineColor,
                Type                  = LineAnnotationType.Horizontal,
                Text                  = 0.0m.ToString(CultureInfo.InvariantCulture),
                TextLinePosition      = 1,
                TextVerticalAlignment = OxyPlot.VerticalAlignment.Bottom,
                TextColor             = AskLineColor,
                X = 0,
                Y = 0
            };

            Model.Annotations.Add(BidLineAnnotation);
            Model.Annotations.Add(AskLineAnnotation);
            Model.Updated += async(sender, args) =>
            {
                await Application.Current.Dispatcher.InvokeAsync(() =>
                {
                    if (Model.PlotView != null)
                    {
                        Model.PlotView?.ActualController.Unbind(PlotCommands.ZoomRectangle);
                    }
                }, DispatcherPriority.Background);
            };
        }
        private void RefreshZGraph()
        {
            _plot.Series.Clear();
            // Build the Chart
            // Get a reference to the GraphPane
            var lineSeries1 = new LineSeries {
                Title                 = string.Empty,
                MarkerFill            = OxyColor.FromRgb(255, 0, 0),
                MarkerSize            = 5,
                MarkerStroke          = OxyColor.FromRgb(255, 0, 0),
                MarkerStrokeThickness = 1.5,
                MarkerType            = MarkerType.Circle
            };

            _plot.Series.Add(lineSeries1);
            var prof = Presenter.ThisProfile;

            for (var j = 0; j < prof.DatapointsCount; j++)
            {
                var tp1 = prof.ObservableDatapoints[j];
                var dt  = new DateTime(2000, 1, 1).Add(tp1.Time);
                var x   = DateTimeAxis.ToDouble(dt);

                var y      = tp1.Value;
                var bottom = new DataPoint(x, y);
                lineSeries1.Points.Add(bottom);
                if (j < prof.DatapointsCount - 1)
                {
                    var tp2     = prof.ObservableDatapoints[j + 1];
                    var dt2     = new DateTime(2000, 1, 1).Add(tp2.Time).AddMilliseconds(-1);
                    var x2      = DateTimeAxis.ToDouble(dt2);
                    var y2      = tp1.Value;
                    var bottom2 = new DataPoint(x2, y2);
                    lineSeries1.Points.Add(bottom2);
                }
            }

            foreach (var axis in _plot.Axes)
            {
                axis.Reset();
            }

            if (prof.ObservableDatapoints.Count > 0)
            {
                var first   = prof.ObservableDatapoints[0];
                var firstdt = new DateTime(2000, 1, 1).Add(first.Time).AddSeconds(-30);
                var minTime = DateTimeAxis.ToDouble(firstdt);
                _dateTimeAxis.Minimum = minTime;
                _linearAxis.Minimum   = prof.ObservableDatapoints.Select(x => x.Value).Min() * 0.90;
                if (Math.Abs(_linearAxis.Minimum) < 0.0000001)
                {
                    _linearAxis.Minimum = -0.1;
                }

                var last    = prof.ObservableDatapoints.Last();
                var lastdt  = new DateTime(2000, 1, 1).Add(last.Time).AddSeconds(30);
                var maxTime = DateTimeAxis.ToDouble(lastdt);
                _dateTimeAxis.Maximum = maxTime;
                _linearAxis.Maximum   = prof.ObservableDatapoints.Select(x => x.Value).Max() * 1.10;
            }

            _plot.InvalidatePlot(true);
        }
        private Axis ConvertAxis(ChartAxisViewModel axis)
        {
            Axis newAxis = null;

            switch (axis.AxisType)
            {
            case (ChartAxisType.CategoryX):
            {
                newAxis = new CategoryAxis
                {
                    LabelField  = axis.ValueMemberPath,
                    ItemsSource = axis.DataSource.Data
                };
                break;
            }

            case (ChartAxisType.NumericX):
            case (ChartAxisType.NumericY):
            {
                newAxis = new LinearAxis
                {
                };
                break;
            }

            case (ChartAxisType.CategoryDateTimeX):
            {
                var dtaxis = new DateTimeAxis
                {
                    IntervalType = DateTimeIntervalType.Auto,
                };

                var scale = axis.GetScaleForProperty(axis.ValueMemberPath);
                if (null != scale)
                {
                    scale.PropertyChanged += (s, a) =>
                    {
                        if (a.PropertyName != "Minimum" && a.PropertyName != "Maximum")
                        {
                            return;
                        }

                        var min = new DateTime((long)scale.Minimum);
                        var max = new DateTime((long)scale.Maximum);

                        var laxis = _plotModel.Axes.FirstOrDefault(x => x.Title == scale.Name) as DateTimeAxis;
                        if (null == laxis)
                        {
                            return;
                        }

                        var delta = max - min;

                        var lmax = 0.0d;
                        var lmin = 0.0d;

                        if (TimeSpan.FromSeconds(1) > delta)
                        {
                            laxis.IntervalType = DateTimeIntervalType.Seconds;
                        }
                        else if (TimeSpan.FromMinutes(1) > delta)
                        {
                            laxis.IntervalType = DateTimeIntervalType.Minutes;
                        }
                        else if (TimeSpan.FromHours(1) > delta)
                        {
                            laxis.IntervalType = DateTimeIntervalType.Hours;
                        }
                        else if (TimeSpan.FromDays(1) > delta)
                        {
                            laxis.IntervalType = DateTimeIntervalType.Days;
                        }
                        else if (TimeSpan.FromDays(30) > delta)
                        {
                            laxis.IntervalType = DateTimeIntervalType.Months;
                        }
                        else
                        {
                            laxis.IntervalType = DateTimeIntervalType.Auto;
                        }

                        //TODO: remove
                        laxis.IntervalType = DateTimeIntervalType.Seconds;

                        //laxis.Minimum = scale.Minimum;
                        //laxis.Maximum = scale.Maximum;

                        OnPlotModelChanged();
                    };
                }
                newAxis = dtaxis;
                break;
            }
            }

            if (null == newAxis)
            {
                return(null);
            }

            switch (axis.AxisLocation)
            {
            case (AxisLocation.InsideBottom):
            case (AxisLocation.OutsideBottom):
            {
                newAxis.Position = AxisPosition.Bottom;
                break;
            }

            case (AxisLocation.InsideTop):
            case (AxisLocation.OutsideTop):
            {
                newAxis.Position = AxisPosition.Top;
                break;
            }

            case (AxisLocation.InsideLeft):
            case (AxisLocation.OutsideLeft):
            {
                newAxis.Position = AxisPosition.Left;
                break;
            }

            case (AxisLocation.InsideRight):
            case (AxisLocation.OutsideRight):
            {
                newAxis.Position = AxisPosition.Right;
                break;
            }

            default:
            {
                newAxis.Position = AxisPosition.None;
                break;
            }
            }

            newAxis.Title = axis.Name;

            var series = axis.AxisScaleDescriptors.FirstOrDefault();

            if (null != series)
            {
                newAxis.Title = series.Scale.Name;
            }

            newAxis.Key = newAxis.Title;

            return(newAxis);
        }
        private Axis ConvertAxis(ChartAxisViewModel axis)
        {
            Axis newAxis = null;

            switch (axis.AxisType)
            {
                case (ChartAxisType.CategoryX):
                {
                    newAxis = new CategoryAxis
                    {
                        LabelField = axis.ValueMemberPath,
                        ItemsSource = axis.DataSource.Data
                    };
                    break;
                }
                case (ChartAxisType.NumericX):
                case (ChartAxisType.NumericY):
                {
                    newAxis = new LinearAxis
                    {
                    };
                    break;
                }
                case(ChartAxisType.CategoryDateTimeX):
                {
                    var dtaxis = new DateTimeAxis
                    {
                        IntervalType = DateTimeIntervalType.Auto,
                    };

                    var scale = axis.GetScaleForProperty(axis.ValueMemberPath);
                    if (null != scale)
                    {
                        scale.PropertyChanged += (s, a) =>
                        {
                            if( a.PropertyName != "Minimum" && a.PropertyName != "Maximum")
                            {
                                return;
                            }

                            var min = new DateTime((long)scale.Minimum);
                            var max = new DateTime((long)scale.Maximum);

                            var laxis = _plotModel.Axes.FirstOrDefault(x =>  x.Title == scale.Name) as DateTimeAxis;
                            if( null == laxis )
                            {
                                return;
                            }

                            var delta = max - min;

                            var lmax = 0.0d;
                            var lmin = 0.0d;

                            if (TimeSpan.FromSeconds(1) > delta)
                            {
                                laxis.IntervalType = DateTimeIntervalType.Seconds;
                            }
                            else if (TimeSpan.FromMinutes(1) > delta)
                            {
                                laxis.IntervalType = DateTimeIntervalType.Minutes;
                            }
                            else if (TimeSpan.FromHours(1) > delta)
                            {
                                laxis.IntervalType = DateTimeIntervalType.Hours;
                            }
                            else if (TimeSpan.FromDays(1) > delta)
                            {
                                laxis.IntervalType = DateTimeIntervalType.Days;
                            }
                            else if (TimeSpan.FromDays(30) > delta)
                            {
                                laxis.IntervalType = DateTimeIntervalType.Months;
                            }
                            else
                            {
                                laxis.IntervalType = DateTimeIntervalType.Auto;
                            }

                            //TODO: remove
                            laxis.IntervalType = DateTimeIntervalType.Seconds;

                            //laxis.Minimum = scale.Minimum;
                            //laxis.Maximum = scale.Maximum;

                            OnPlotModelChanged();
                        };
                    }
                    newAxis = dtaxis;
                    break;
                }
            }

            if (null == newAxis)
            {
                return null;
            }

            switch (axis.AxisLocation)
            {
                case(AxisLocation.InsideBottom):
                case(AxisLocation.OutsideBottom):
                {
                    newAxis.Position = AxisPosition.Bottom;
                    break;
                }
                case (AxisLocation.InsideTop):
                case (AxisLocation.OutsideTop):
                {
                    newAxis.Position = AxisPosition.Top;
                    break;
                }
                case (AxisLocation.InsideLeft):
                case (AxisLocation.OutsideLeft):
                {
                    newAxis.Position = AxisPosition.Left;
                    break;
                }
                case (AxisLocation.InsideRight):
                case (AxisLocation.OutsideRight):
                {
                    newAxis.Position = AxisPosition.Right;
                    break;
                }
                default:
                {
                    newAxis.Position = AxisPosition.None;
                    break;
                }
            }

            newAxis.Title = axis.Name;

            var series = axis.AxisScaleDescriptors.FirstOrDefault();
            if (null != series)
            {
                newAxis.Title = series.Scale.Name;
            }

            newAxis.Key = newAxis.Title;

            return newAxis;
        }
Пример #30
0
        public SymbolTabItem(Symbol symbol)
        {
            Symbol = symbol ?? throw new ArgumentNullException(nameof(symbol));

            Model = new PlotModel();

            XAxis = new DateTimeAxis
            {
                TextColor          = TextColor,
                StringFormat       = XAxisFormat,
                TicklineColor      = TickLineColor,
                AxislineColor      = AxisLineColor,
                AxislineStyle      = LineStyle.Solid,
                MajorGridlineColor = MajorGridLineColor,
                MajorGridlineStyle = LineStyle.Dash,
                MajorStep          = PeriodToX(TimeSpan.FromMinutes(10)),
                Position           = AxisPosition.Bottom,
                IsZoomEnabled      = false,
                MaximumRange       = PeriodToX(TimeSpan.FromHours(1.5)),

                //MinimumRange = PeriodToX(TimeSpan.FromHours(1))
            };

            Model.Axes.Add(XAxis);

            var yAxis = new LinearAxis
            {
                TextColor          = TextColor,
                TicklineColor      = TickLineColor,
                AxislineColor      = AxisLineColor,
                AxislineStyle      = LineStyle.Solid,
                MajorGridlineColor = MajorGridLineColor,
                MajorGridlineStyle = LineStyle.Dash,
                Position           = AxisPosition.Right
            };

            Model.Axes.Add(yAxis);

            Model.PlotAreaBorderThickness = new OxyThickness(thickness: 0);
            Model.PlotAreaBorderColor     = PlotAreaBorderColor;

            CandleStickSeries = new CandleStickSeries
            {
                IncreasingColor = IncreasingColor,
                DecreasingColor = DecreasingColor,
                ItemsSource     = Candles,
                CandleWidth     = PeriodToX(TimeSpan.FromMinutes(1))
            };

            XAxis.AxisChanged += (sender, args) => { AdjustYExtent(CandleStickSeries, XAxis, yAxis); };

            Model.Series.Add(CandleStickSeries);

            BidLineAnnotation = new LineAnnotation
            {
                StrokeThickness = 1,
                Color           = BidLineColor,
                Type            = LineAnnotationType.Horizontal,
                Text            = (0.0m).ToString(CultureInfo.InvariantCulture),
                //TextLinePosition = 1,
                TextColor = DecreasingColor,
                X         = 0,
                Y         = 0
            };

            Model.Annotations.Add(BidLineAnnotation);
        }
Пример #31
0
        private void LoadData2(double[] valPortef, double[] valBenchmark)
        {
            var tmp = new PlotModel { Title = "Rendements du portefeuille vs Benchmark" };

            var series1 = new OxyPlot.Series.LineSeries { Title = "Portefeuille", MarkerType = MarkerType.None };
            int j = 0;
            while (Date[j] != TDebut)
            {
                j++;
            }
            TimeSpan diff;
            for (int i = 0; i < valPortef.Length; i++)
            {
                diff = Date[j+i] - new DateTime(1899, 12, 31, 0, 0, 0);
                series1.Points.Add(new DataPoint(diff.TotalDays, valPortef[i]));
            }

            var series2 = new OxyPlot.Series.LineSeries { Title = "Benchmark", MarkerType = MarkerType.None };
            for (int i = 0; i < valBenchmark.Length; i++)
            {
                diff = Date[j+i] - new DateTime(1899, 12, 31, 0, 0, 0);
                series2.Points.Add(new DataPoint(diff.TotalDays, valBenchmark[i]));
            }

            tmp.Series.Add(series1);
            tmp.Series.Add(series2);

            var dateAxis = new OxyPlot.Axes.DateTimeAxis(AxisPosition.Bottom, "Date", "dd/MM/yy") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot };
            //dateAxis.Minimum = OxyPlot.Axes.DateTimeAxis.ToDouble(TDebut);
            //dateAxis.Maximum = OxyPlot.Axes.DateTimeAxis.ToDouble(TFin);
            dateAxis.IntervalType = DateTimeIntervalType.Months;
            tmp.Axes.Add(dateAxis);
            var valueAxis = new OxyPlot.Axes.LinearAxis(AxisPosition.Left) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Value", IntervalLength = 50 };
            tmp.Axes.Add(valueAxis);
            this.PlotModel2 = tmp;
        }