Пример #1
0
        private void SetUpModel()
        {
            var dateAxis = new OxyPlot.Axes.DateTimeAxis()
            {
                MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 80
            };

            PlotModel.Axes.Add(dateAxis);
            var valueAxis = new OxyPlot.Axes.LinearAxis()
            {
                MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot
            };

            PlotModel.Axes.Add(valueAxis);


            var lineSerie = new OxyPlot.Series.LineSeries
            {
                StrokeThickness             = 2,
                MarkerSize                  = 3,
                CanTrackerInterpolatePoints = false,
                //Title = string.Format("Detector {0}", 0),
                Smooth = false,
            };

            lineSerie.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now), 1));
            PlotModel.Series.Add(lineSerie);
        }
Пример #2
0
        public void DateTimeAxis()
        {
            var s1 = new OxyPlot.Axes.DateTimeAxis();
            var s2 = new DateTimeAxis();

            OxyAssert.PropertiesAreEqual(s1, s2);
        }
        void LoadPlot()
        {
            PlotModel plot = new PlotModel()
            {
                LegendSymbolLength = 24.0,
                LegendOrientation = LegendOrientation.Horizontal,
                LegendPlacement = LegendPlacement.Inside,
                LegendPosition = LegendPosition.TopCenter,
                LegendBackground = OxyColor.FromAColor(200, OxyColors.White),
                LegendBorder = OxyColors.Black
            };

            var x_axis = new OxyPlot.Axes.DateTimeAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, MajorStep=50, Title = "Date", StringFormat = "yyyyMMdd", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot };
            x_axis.TextColor = OxyColors.White; x_axis.TitleColor = OxyColors.White;
            plot.Axes.Add(x_axis);
            var y_axis = new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Left, Title = "Price", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot };
            y_axis.TextColor = OxyColors.White; y_axis.TitleColor = OxyColors.White;
            plot.Axes.Add(y_axis);

            try
            {
                CharacterVector symbol = _engine.CreateCharacterVector(new[] {_symbol});
                CharacterVector from = _engine.CreateCharacterVector(new[] {_fromdate});
                CharacterVector to = _engine.CreateCharacterVector(new[] {_todate});
                _engine.SetSymbol("symbol",symbol);
                _engine.SetSymbol("from",from);
                _engine.SetSymbol("to", to);
                _engine.Evaluate("getSymbols(symbol, from=from, to=to)");

                NumericMatrix bars = _engine.GetSymbol(_symbol).AsNumericMatrix();
                // 1970-01-01 = 0
                DateTime rootdate = new DateTime(1970, 1, 1);
                IntegerVector dates = _engine.Evaluate("index(" + _symbol + ")").AsInteger();

                CandleStickSeries candleStickSeries = new CandleStickSeries
                {
                    Title = _symbol,
                    CandleWidth = 5,
                    Color = OxyColors.DarkGray,
                    IncreasingFill = OxyColors.DarkGreen,
                    DecreasingFill = OxyColors.Red,
                    TrackerFormatString = "Date: {1:yyyyMMdd}\nHigh: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}"
                };

                // add to bars
                for (int i = 0; i < dates.Count(); i++)
                {
                    DateTime d = rootdate.AddDays(dates[i]);
                    int dint = TradingBase.Util.ToIntDate(d);
                    candleStickSeries.Items.Add(new HighLowItem(OxyPlot.Axes.DateTimeAxis.ToDouble(d), bars[i, 1], bars[i, 2], bars[i, 0], bars[i, 3]));
                }

                plot.Series.Add(candleStickSeries);
                MyPlot = plot;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Пример #4
0
        public void UpdatePlotArea(string symbol)
        {
            if (_configmanager.RealTimePlot && _tickseriesdict.ContainsKey(symbol))
            {
                if (_currentsymbol != symbol)
                {
                    //string symbol = _tickseriesdict.Keys.ElementAt(selectedindex);
                    _tickplot.Axes.Clear();
                    var dateAxis = new OxyPlot.Axes.DateTimeAxis()
                    {
                        Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "Time", StringFormat = "HH:mm:ss", Minimum = OxyPlot.Axes.DateTimeAxis.ToDouble(_plotxaxisleft), Maximum = OxyPlot.Axes.DateTimeAxis.ToDouble(_plotxaxisright), MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 80
                    };
                    dateAxis.TextColor = OxyColors.White; dateAxis.TitleColor = OxyColors.White;
                    _tickplot.Axes.Add(dateAxis);
                    var priceAxis = new OxyPlot.Axes.LinearAxis()
                    {
                        Position = OxyPlot.Axes.AxisPosition.Left, Title = "Price", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot
                    };
                    priceAxis.TextColor = OxyColors.White; priceAxis.TitleColor = OxyColors.White;
                    _tickplot.Axes.Add(priceAxis);

                    _tickplot.Series.Clear();
                    _tickplot.Series.Add(_tickseriesdict[symbol]);
                    _currentsymbol = symbol;
                }
            }
        }
Пример #5
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   = "MMM/dd/yyyy", Title = "Date", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot
                , IntervalType = OxyPlot.Axes.DateTimeIntervalType.Months, MinorIntervalType = OxyPlot.Axes.DateTimeIntervalType.Days,
                IntervalLength = 80
            };

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

            PlotModel.Axes.Add(valueAxis);
        }
Пример #6
0
        private List <DataPoint> GetDataPoints(IEnumerable <IAttemptLog> attemptLogs)
        {
            var dataPoints = new List <DataPoint>();

            foreach (var attemptLog in attemptLogs)
            {
                var dataPoint = DateTimeAxis.CreateDataPoint(attemptLog.AttemptDate.GetValueOrDefault(),
                                                             Convert.ToDouble(attemptLog.LengthInMinutes));
                dataPoints.Add(dataPoint);
            }
            return(dataPoints);
        }
Пример #7
0
        private void CreatePLByStrategyChartModel()
        {
            var model = new PlotModel();

            var xAxis = new OxyPlot.Axes.DateTimeAxis
            {
                Position     = OxyPlot.Axes.AxisPosition.Bottom,
                StringFormat = "yyyy-MM-dd"
            };

            model.Axes.Add(xAxis);

            var yAxis = new OxyPlot.Axes.LinearAxis
            {
                Position           = OxyPlot.Axes.AxisPosition.Left,
                StringFormat       = "c0",
                MajorGridlineStyle = LineStyle.Dash
            };

            model.Axes.Add(yAxis);

            foreach (DataColumn column in Data.StrategyPLCurves.Columns)
            {
                if (column.ColumnName == "date")
                {
                    continue;
                }

                DataColumn column1 = column;
                var        series  = new OxyPlot.Series.LineSeries
                {
                    ItemsSource = Data.StrategyPLCurves.Select(x => new { X = x.date, Y = x.Field <double>(column1.ColumnName) }),
                    Title       = column.ColumnName,
                    CanTrackerInterpolatePoints = false,
                    TrackerFormatString         = "Strategy: " + column.ColumnName + @" Date: {2:yyyy-MM-dd} P/L: {4:c0}",
                    DataFieldX = "X",
                    DataFieldY = "Y",
                    MarkerType = MarkerType.None
                };
                model.Series.Add(series);
            }

            model.LegendPosition    = LegendPosition.BottomCenter;
            model.LegendOrientation = LegendOrientation.Horizontal;
            model.LegendPlacement   = LegendPlacement.Outside;

            PLByStrategyModel = model;
        }
Пример #8
0
        public QuotePlotViewModel()
        {
            this._quoteupdateservice          = ServiceLocator.Current.GetInstance <IQuoteUpdateService>() as QuoteUpdateService;
            _quoteupdateservice.PlotViewModel = this;
            this._configmanager = ServiceLocator.Current.GetInstance <IConfigManager>();


            // initialize tickplot model
            _tickplot = new PlotModel()
            {
                PlotMargins = new OxyThickness(50, 0, 0, 40),
                Background  = OxyColors.Transparent,
                //LegendTitle = "Legend",
                LegendTextColor   = OxyColors.White,
                LegendOrientation = LegendOrientation.Horizontal,
                LegendPlacement   = LegendPlacement.Outside,
                LegendPosition    = LegendPosition.TopRight,
                //LegendBackground = OxyColor.FromAColor(200, OxyColors.White),
                LegendBorder = OxyColors.Black
            };

            if (_configmanager.PlotRegularTradingHours)
            {
                _plotxaxisleft  = DateTime.Today.Add(new TimeSpan(9, 15, 0));
                _plotxaxisright = DateTime.Today.Add(new TimeSpan(16, 15, 0));
            }
            else
            {
                _plotxaxisleft  = DateTime.Today;
                _plotxaxisright = DateTime.Today.AddDays(1);
            }

            var dateAxis = new OxyPlot.Axes.DateTimeAxis()
            {
                Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "Time", StringFormat = "HH:mm:ss", Minimum = OxyPlot.Axes.DateTimeAxis.ToDouble(_plotxaxisleft), Maximum = OxyPlot.Axes.DateTimeAxis.ToDouble(_plotxaxisright), MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 80
            };

            dateAxis.TextColor = OxyColors.White; dateAxis.TitleColor = OxyColors.White;
            _tickplot.Axes.Add(dateAxis);
            var priceAxis = new OxyPlot.Axes.LinearAxis()
            {
                Position = OxyPlot.Axes.AxisPosition.Left, Title = "Price", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot
            };

            priceAxis.TextColor = OxyColors.White; priceAxis.TitleColor = OxyColors.White;
            _tickplot.Axes.Add(priceAxis);
        }
        public QuotePlotViewModel()
        {
            this._quoteupdateservice = ServiceLocator.Current.GetInstance<IQuoteUpdateService>() as QuoteUpdateService;
            _quoteupdateservice.PlotViewModel = this;
            this._configmanager = ServiceLocator.Current.GetInstance<IConfigManager>();
            

            // initialize tickplot model
            _tickplot = new PlotModel()
            {
                PlotMargins = new OxyThickness(50, 0, 0, 40),
                Background = OxyColors.Transparent,
                //LegendTitle = "Legend",
                LegendTextColor = OxyColors.White,
                LegendOrientation = LegendOrientation.Horizontal,
                LegendPlacement = LegendPlacement.Outside,
                LegendPosition = LegendPosition.TopRight,
                //LegendBackground = OxyColor.FromAColor(200, OxyColors.White),
                LegendBorder = OxyColors.Black
            };

            if (_configmanager.PlotRegularTradingHours)
            {
                _plotxaxisleft = DateTime.Today.Add(new TimeSpan(9, 15, 0));
                _plotxaxisright = DateTime.Today.Add(new TimeSpan(16, 15, 0));
            }
            else
            {
                _plotxaxisleft = DateTime.Today;
                _plotxaxisright = DateTime.Today.AddDays(1);
            }

            var dateAxis = new OxyPlot.Axes.DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "Time", StringFormat = "HH:mm:ss", Minimum = OxyPlot.Axes.DateTimeAxis.ToDouble(_plotxaxisleft), Maximum = OxyPlot.Axes.DateTimeAxis.ToDouble(_plotxaxisright), MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 80 };
            dateAxis.TextColor = OxyColors.White; dateAxis.TitleColor = OxyColors.White;
            _tickplot.Axes.Add(dateAxis);
            var priceAxis = new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Left, Title = "Price", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot };
            priceAxis.TextColor = OxyColors.White; priceAxis.TitleColor = OxyColors.White;
            _tickplot.Axes.Add(priceAxis);
        }
Пример #10
0
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;

            _plotModel.IsLegendVisible   = true;
            _plotModel.LegendPlacement   = LegendPlacement.Outside;
            _plotModel.LegendPosition    = LegendPosition.BottomCenter;
            _plotModel.LegendOrientation = LegendOrientation.Horizontal;

            OxyPlot.Axes.LinearAxis LAY = new OxyPlot.Axes.LinearAxis()
            {
                Position = OxyPlot.Axes.AxisPosition.Left,
                Title    = "Megabit per second",
            };
            OxyPlot.Axes.DateTimeAxis LAX = new OxyPlot.Axes.DateTimeAxis()
            {
                Position     = OxyPlot.Axes.AxisPosition.Bottom,
                MinorStep    = 5,
                StringFormat = "HH:mm:ss"
            };

            _plotModel.Axes.Add(LAY);
            _plotModel.Axes.Add(LAX);

            totalSeries.Title = "TOTAL";
            _plotModel.Series.Add(totalSeries);

            plotView.Model = PlotModel;
            _plotModel.InvalidatePlot(true);

            myC7 = new ArcherC7();

            backgroundWorker.DoWork               += backgroundWorker_DoWork;
            backgroundWorker.ProgressChanged      += backgroundWorker_ProgressChanged;
            backgroundWorker.WorkerReportsProgress = true;
        }
Пример #11
0
        private void Create_Graph()
        {
            var Model = new PlotModel
            {
                //Title = Workout_Names[0]
                Title = WTF[0].workout_name
            };

            //var start = DateTime.Now.AddDays(0);
            //var end = DateTime.Now.AddDays(15);
            var startDate = OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddDays(0));
            var endDate   = OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddDays(15));

            // axis definitions =======================================================
            var Xaxis = new OxyPlot.Axes.DateTimeAxis
            {
                Position = OxyPlot.Axes.AxisPosition.Bottom,
                //Minimum = OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddDays(0)),
                Minimum        = OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now),
                Maximum        = OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddDays(9)),
                IntervalType   = OxyPlot.Axes.DateTimeIntervalType.Days,
                IntervalLength = 50, // some arithmetic depending on how many workouts are currently graphed
                IsPanEnabled   = true,
                StringFormat   = "M/dd",
            };
            var Yaxis = new OxyPlot.Axes.LinearAxis()
            {
                Position           = OxyPlot.Axes.AxisPosition.Left,
                Minimum            = 5000,
                Maximum            = 9000,
                IntervalLength     = 100,
                MajorGridlineStyle = LineStyle.Automatic,
                MinorGridlineStyle = LineStyle.Dot,
                IsPanEnabled       = true,
            };

            // axis definitions end ===================================================

            Model.Axes.Add(Xaxis);
            Model.Axes.Add(Yaxis);


            var series1 = new OxyPlot.Series.LineSeries
            {
                MarkerType = MarkerType.Circle,
                MarkerFill = OxyColor.FromRgb(0, 73, 100),
                //MarkerFill = OxyColor.FromRgb(90, 200, 250),
                MarkerStroke          = OxyColor.FromRgb(90, 200, 250),
                MarkerSize            = 4,
                MarkerStrokeThickness = 1,
                Color = OxyPlot.OxyColor.FromRgb(90, 200, 250)
            };


            /*series1.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddDays(0)), 150.0));
            *  series1.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddDays(2)), 151.8));
            *  series1.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddDays(4)), 154.1));
            *  series1.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddDays(5)), 154.9));
            *  series1.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddDays(6)), 157.8));
            *  series1.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddDays(7)), 159.6));*/


            // =============================================

            // =============================================

            string[] weights;
            string[] reps;

            float Total_Weight = 0;

            for (int j = 0; j < WTF.Count; j++)
            {
                weights = WTF[j].weight.Split(',');
                reps    = WTF[j].reps.Split(',');

                for (int i = 0; i < weights.Length; i++)
                {
                    Total_Weight += float.Parse(weights[i], CultureInfo.InvariantCulture.NumberFormat) * float.Parse(reps[i], CultureInfo.InvariantCulture.NumberFormat);
                }
                series1.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Now.AddDays(j)), Total_Weight));
                Total_Weight = 0;
            }

            Model.Series.Add(series1);

            this.Content = new PlotView {
                Model = Model
            };
        }
Пример #12
0
        private void CreatePLByStrategyChartModel()
        {
            var model = new PlotModel();

            var xAxis = new OxyPlot.Axes.DateTimeAxis
            {
                Position = OxyPlot.Axes.AxisPosition.Bottom,
                StringFormat = "yyyy-MM-dd"
            };
            model.Axes.Add(xAxis);

            var yAxis = new OxyPlot.Axes.LinearAxis
            {
                Position = OxyPlot.Axes.AxisPosition.Left,
                StringFormat = "c0",
                MajorGridlineStyle = LineStyle.Dash
            };
            model.Axes.Add(yAxis);

            foreach (DataColumn column in Data.StrategyPLCurves.Columns)
            {
                if (column.ColumnName == "date") continue;

                DataColumn column1 = column;
                var series = new OxyPlot.Series.LineSeries
                {
                    ItemsSource = Data.StrategyPLCurves.Select(x => new { X = x.date, Y = x.Field<double>(column1.ColumnName) }),
                    Title = column.ColumnName,
                    CanTrackerInterpolatePoints = false,
                    TrackerFormatString = "Strategy: " + column.ColumnName + @" Date: {2:yyyy-MM-dd} P/L: {4:c0}",
                    DataFieldX = "X",
                    DataFieldY = "Y",
                    MarkerType = MarkerType.None
                };
                model.Series.Add(series);
            }

            model.LegendPosition = LegendPosition.BottomCenter;
            model.LegendOrientation = LegendOrientation.Horizontal;
            model.LegendPlacement = LegendPlacement.Outside;

            PLByStrategyModel = model;
        }
Пример #13
0
 public void DateTimeAxis()
 {
     var s1 = new OxyPlot.Axes.DateTimeAxis();
     var s2 = new DateTimeAxis();
     OxyAssert.PropertiesAreEqual(s1, s2);
 }
Пример #14
0
        void LoadPlot()
        {
            PlotModel plot = new PlotModel()
            {
                LegendSymbolLength = 24.0,
                LegendOrientation  = LegendOrientation.Horizontal,
                LegendPlacement    = LegendPlacement.Inside,
                LegendPosition     = LegendPosition.TopCenter,
                LegendBackground   = OxyColor.FromAColor(200, OxyColors.White),
                LegendBorder       = OxyColors.Black
            };

            var x_axis = new OxyPlot.Axes.DateTimeAxis {
                Position = OxyPlot.Axes.AxisPosition.Bottom, MajorStep = 50, Title = "Date", StringFormat = "yyyyMMdd", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot
            };

            x_axis.TextColor = OxyColors.White; x_axis.TitleColor = OxyColors.White;
            plot.Axes.Add(x_axis);
            var y_axis = new OxyPlot.Axes.LinearAxis {
                Position = OxyPlot.Axes.AxisPosition.Left, Title = "Price", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot
            };

            y_axis.TextColor = OxyColors.White; y_axis.TitleColor = OxyColors.White;
            plot.Axes.Add(y_axis);

            try
            {
                CharacterVector symbol = _engine.CreateCharacterVector(new[] { _symbol });
                CharacterVector from   = _engine.CreateCharacterVector(new[] { _fromdate });
                CharacterVector to     = _engine.CreateCharacterVector(new[] { _todate });
                _engine.SetSymbol("symbol", symbol);
                _engine.SetSymbol("from", from);
                _engine.SetSymbol("to", to);
                _engine.Evaluate("getSymbols(symbol, from=from, to=to)");

                NumericMatrix bars = _engine.GetSymbol(_symbol).AsNumericMatrix();
                // 1970-01-01 = 0
                DateTime      rootdate = new DateTime(1970, 1, 1);
                IntegerVector dates    = _engine.Evaluate("index(" + _symbol + ")").AsInteger();

                CandleStickSeries candleStickSeries = new CandleStickSeries
                {
                    Title               = _symbol,
                    CandleWidth         = 5,
                    Color               = OxyColors.DarkGray,
                    IncreasingFill      = OxyColors.DarkGreen,
                    DecreasingFill      = OxyColors.Red,
                    TrackerFormatString = "Date: {1:yyyyMMdd}\nHigh: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}"
                };

                // add to bars
                for (int i = 0; i < dates.Count(); i++)
                {
                    DateTime d    = rootdate.AddDays(dates[i]);
                    int      dint = TradingBase.Util.ToIntDate(d);
                    candleStickSeries.Items.Add(new HighLowItem(OxyPlot.Axes.DateTimeAxis.ToDouble(d), bars[i, 1], bars[i, 2], bars[i, 0], bars[i, 3]));
                }

                plot.Series.Add(candleStickSeries);
                MyPlot = plot;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        public void UpdatePlotArea(string symbol)
        {
            if (_configmanager.RealTimePlot && _tickseriesdict.ContainsKey(symbol))
            {
                if (_currentsymbol != symbol)
                {
                    //string symbol = _tickseriesdict.Keys.ElementAt(selectedindex);
                    _tickplot.Axes.Clear();
                    var dateAxis = new OxyPlot.Axes.DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "Time", StringFormat = "HH:mm:ss", Minimum = OxyPlot.Axes.DateTimeAxis.ToDouble(_plotxaxisleft), Maximum = OxyPlot.Axes.DateTimeAxis.ToDouble(_plotxaxisright), MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 80 };
                    dateAxis.TextColor = OxyColors.White; dateAxis.TitleColor = OxyColors.White;
                    _tickplot.Axes.Add(dateAxis);
                    var priceAxis = new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Left, Title = "Price", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot };
                    priceAxis.TextColor = OxyColors.White; priceAxis.TitleColor = OxyColors.White;
                    _tickplot.Axes.Add(priceAxis);

                    _tickplot.Series.Clear();
                    _tickplot.Series.Add(_tickseriesdict[symbol]);
                    _currentsymbol = symbol;
                }
            }
        }
        public EarthquakePage()
        {
            var earthquakeSeries = new LineSeries();

            var m = new PlotModel("Earthquakes");

            var magnitudeAxis = new OxyPlot.Axes.LinearAxis();

            magnitudeAxis.Minimum = 0;
            magnitudeAxis.Maximum = 10;
            m.Axes.Add(magnitudeAxis);

            var dateAxis = new OxyPlot.Axes.DateTimeAxis();

            dateAxis.IntervalType = OxyPlot.Axes.DateTimeIntervalType.Days;
            dateAxis.StringFormat = "MMMM-yy";
            m.Axes.Add(dateAxis);

            earthquakeSeries.ItemsSource = new List <DataPoint> ();            // empty to start
            m.Series.Add(earthquakeSeries);

            var opv = new OxyPlotView {
                WidthRequest    = 300, HeightRequest = 300,
                BackgroundColor = Color.Aqua
            };

            opv.Model = m;

            Insights.Track("SHOWGRAPH");


            var l = new Label {
                Text              = "Hello, Oxyplot!",
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };
            var b = new Button {
                Text = "Get Earthquake Data"
            };

            b.Clicked += async(sender, e) => {
                var sv = new GeoNamesWebService();
                var es = await sv.GetEarthquakesAsync();

                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => {
                    Debug.WriteLine("found " + es.Length + " earthquakes");
                    l.Text = es.Length + " earthquakes";

                    var eqlist = new List <Earthquake>(es);
                    eqlist.Sort((x, y) => string.Compare(x.datetime, y.datetime));

                    var pts = new List <DataPoint>();
                    foreach (var eq in eqlist)
                    {
                        pts.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Parse(eq.datetime)), eq.magnitude));
                    }

                    earthquakeSeries.ItemsSource = pts;
                    earthquakeSeries.XAxis.CoerceActualMaxMin();

                    Device.BeginInvokeOnMainThread(() => {
                        opv.InvalidateDisplay();
                    });
                });
            };


            Padding = new Thickness(0, 20, 0, 0);
            Content = new StackLayout {
                Children =
                {
                    opv,
                    b,
                    l
                }
            };
        }
Пример #17
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            //somehow an orientation change changes the language. Therefore we check and reset the language here depending on the stored preferences
            //check language preferences, if they are set apply them otherwise stay with the current language
            ISharedPreferences sharedPref = GetSharedPreferences("com.FSoft.are_u_ok.PREFERENCES",FileCreationMode.Private);
            String savedLanguage = sharedPref.GetString ("Language", "");
            //if there is a saved language (length > 0) and the current language is different from the saved one, then change
            Android.Content.Res.Configuration conf = Resources.Configuration;
            if ((savedLanguage.Length > 0) & (conf.Locale.Language != savedLanguage)){
                //set language and restart activity to see the effect
                conf.Locale = new Java.Util.Locale(savedLanguage);
                Android.Util.DisplayMetrics dm = this.Resources.DisplayMetrics;
                this.Resources.UpdateConfiguration (conf, dm);
            }

            // Create your application here
            SetContentView(Resource.Layout.PlotScreen);
            db = new MoodDatabase(this);

            Button Back = FindViewById<Button> (Resource.Id.button1);
            Back.Click += delegate {
                //create an intent to go back to the history screen
            //				Intent intent = new Intent(this, typeof(Home));
            //				intent.SetFlags(ActivityFlags.ClearTop); //remove the history and go back to home screen
            //				StartActivity(intent);
                OnBackPressed();
            };

            //Create Plot
            // http://blog.bartdemeyer.be/2013/03/creating-graphs-in-wpf-using-oxyplot/

            plotViewModel = FindViewById<PlotView>(Resource.Id.plotViewModel);

            //query database
            cursor = db.ReadableDatabase.RawQuery("SELECT date, time, mood FROM MoodData WHERE NOT mood = -1", null); // cursor query

            //read out date and time and convert back to DateTime item for plotting
            //			cursor.MoveToFirst();
            //			string date_temp = cursor.GetString(cursor.GetColumnIndex("date"));
            //			string time_temp = cursor.GetString(cursor.GetColumnIndex("time"));
            //			DateTime date_time_temp = DateTime.ParseExact (date_temp + " " + time_temp, "dd.MM.yy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
            //			//print for debug
            //			System.Console.WriteLine("Date Time: " + date_time_temp.ToString());

            //only continue if there is data, otherwise there will be an error
            if (cursor.Count > 0) {

                var lineSerie = new LineSeries ();

                for (int ii = 0; ii < cursor.Count; ii++) {
                    cursor.MoveToPosition (ii);
                    //read out date and time and convert back to DateTime item for plotting
                    string date_temp = cursor.GetString (cursor.GetColumnIndex ("date"));
                    string time_temp = cursor.GetString (cursor.GetColumnIndex ("time"));
                    DateTime date_time_temp = DateTime.ParseExact (date_temp + " " + time_temp, "dd.MM.yy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
                    //System.Console.WriteLine("Date Time: " + date_time_temp.ToString());
                    //add point (date_time, mood) to line series
                    lineSerie.Points.Add (new DataPoint (OxyPlot.Axes.DateTimeAxis.ToDouble (date_time_temp), (double)cursor.GetInt (cursor.GetColumnIndex ("mood"))));
                }

                PlotModel temp = new PlotModel ();
                //determine font size, either keep default or for small screens set it to a smaller size
                double dFontSize = temp.DefaultFontSize;
                double dMarkerSize = 8;
                if (Resources.DisplayMetrics.HeightPixels <= 320) {
                    dFontSize = 5;
                    dMarkerSize = 5;

                }
                //define axes
                var dateAxis = new OxyPlot.Axes.DateTimeAxis ();
                dateAxis.Position = OxyPlot.Axes.AxisPosition.Bottom;
                dateAxis.StringFormat = "dd/MM HH:mm";
                dateAxis.Title = Resources.GetString (Resource.String.Time);
                dateAxis.FontSize = dFontSize;
                temp.Axes.Add (dateAxis);
                var valueAxis = new OxyPlot.Axes.LinearAxis ();
                valueAxis.Position = OxyPlot.Axes.AxisPosition.Left;
                valueAxis.Title = Resources.GetString (Resource.String.Mood);
                valueAxis.FontSize = dFontSize;
                valueAxis.Maximum = 10;
                valueAxis.Minimum = 0;
                valueAxis.AbsoluteMinimum = 0;
                valueAxis.AbsoluteMaximum = 10;
                valueAxis.MajorTickSize = 2;
                valueAxis.IsZoomEnabled = false;
                valueAxis.StringFormat = "0";
                temp.Axes.Add (valueAxis);
                lineSerie.MarkerType = MarkerType.Square;
                lineSerie.MarkerSize = dMarkerSize;
                lineSerie.LabelFormatString = "{1}";  //http://discussion.oxyplot.org/topic/490066-trackerformatstring-question/
                lineSerie.FontSize = dFontSize;
                temp.Series.Add (lineSerie);
                MyModel = temp;

                plotViewModel.Model = MyModel;
            }
        }
Пример #18
0
        private void CreateRelativeCapitalUsageByStrategyChartModel()
        {
            var model = new PlotModel();

            var xAxis = new OxyPlot.Axes.DateTimeAxis
            {
                Position = OxyPlot.Axes.AxisPosition.Bottom,
                StringFormat = "yyyy-MM-dd"
            };
            model.Axes.Add(xAxis);

            var yAxis = new OxyPlot.Axes.LinearAxis
            {
                Position = OxyPlot.Axes.AxisPosition.Left,
                StringFormat = "p0",
                MajorGridlineStyle = LineStyle.Dash
            };
            model.Axes.Add(yAxis);

            var capUsageTmpSum = Enumerable.Range(0, Data.RelativeCapitalUsageByStrategy.Rows.Count).Select(x => 0.0).ToList();

            foreach (DataColumn column in Data.RelativeCapitalUsageByStrategy.Columns)
            {
                if (column.ColumnName == "date") continue;

                DataColumn column1 = column;
                List<double> sum = capUsageTmpSum;
                var series = new OxyPlot.Series.AreaSeries
                {
                    ItemsSource = Data
                    .RelativeCapitalUsageByStrategy
                    .Select((x, i) =>
                        new
                        {
                            X = x.date,
                            Y = sum[i],
                            Y2 = sum[i] + x.Field<double>(column1.ColumnName),
                        }),

                    Title = column.ColumnName,
                    CanTrackerInterpolatePoints = false,
                    TrackerFormatString = "Strategy: " + column.ColumnName + @" Date: {2:yyyy-MM-dd} Capital Usage: {4:p1}",
                    DataFieldX = "X",
                    DataFieldX2 = "X",
                    DataFieldY = "Y",
                    DataFieldY2 = "Y2",
                    MarkerType = MarkerType.None,
                    StrokeThickness = 1
                };

                capUsageTmpSum = Data.RelativeCapitalUsageByStrategy.Select((x, i) => x.Field<double>(column1.ColumnName) + capUsageTmpSum[i]).ToList();

                model.Series.Add(series);
            }

            model.LegendPosition = LegendPosition.BottomCenter;
            model.LegendOrientation = LegendOrientation.Horizontal;
            model.LegendPlacement = LegendPlacement.Outside;

            RelativeCapitalUsageByStrategyModel = model;
        }
		public EarthquakePage ()
		{
			var earthquakeSeries = new LineSeries ();

			var m = new PlotModel ("Earthquakes");

			var magnitudeAxis = new OxyPlot.Axes.LinearAxis ();
			magnitudeAxis.Minimum = 0;
			magnitudeAxis.Maximum = 10;
			m.Axes.Add (magnitudeAxis);

			var dateAxis = new OxyPlot.Axes.DateTimeAxis ();
			dateAxis.IntervalType = OxyPlot.Axes.DateTimeIntervalType.Days;
			dateAxis.StringFormat = "MMMM-yy";
			m.Axes.Add (dateAxis);

			earthquakeSeries.ItemsSource = new List<DataPoint> (); // empty to start
			m.Series.Add (earthquakeSeries);

			var opv = new OxyPlotView {
				WidthRequest = 300, HeightRequest = 300,
				BackgroundColor = Color.Aqua
			};
			opv.Model = m;

			Insights.Track ("SHOWGRAPH");


			var l = new Label {
				Text = "Hello, Oxyplot!",
				VerticalOptions = LayoutOptions.CenterAndExpand,
				HorizontalOptions = LayoutOptions.CenterAndExpand,
			};
			var b = new Button { Text = "Get Earthquake Data" };
			b.Clicked += async (sender, e) => {
				var sv = new GeoNamesWebService();
				var es = await sv.GetEarthquakesAsync();
				Xamarin.Forms.Device.BeginInvokeOnMainThread( () => {
					Debug.WriteLine("found " + es.Length + " earthquakes");
					l.Text = es.Length + " earthquakes";

					var eqlist = new List<Earthquake>(es);
					eqlist.Sort((x, y) => string.Compare(x.datetime, y.datetime));

					var pts = new List<DataPoint>();
					foreach (var eq in eqlist) {
						pts.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Parse(eq.datetime)), eq.magnitude));
					}

					earthquakeSeries.ItemsSource = pts;
					earthquakeSeries.XAxis.CoerceActualMaxMin();

					Device.BeginInvokeOnMainThread(() => {
						opv.InvalidateDisplay ();
					});
				});
			};


			Padding = new Thickness (0, 20, 0, 0);
			Content = new StackLayout {
				Children = {
					opv,
					b,
					l
				}
			};
		}
Пример #20
0
        private void CreateRelativeCapitalUsageByStrategyChartModel()
        {
            var model = new PlotModel();

            var xAxis = new OxyPlot.Axes.DateTimeAxis
            {
                Position     = OxyPlot.Axes.AxisPosition.Bottom,
                StringFormat = "yyyy-MM-dd"
            };

            model.Axes.Add(xAxis);

            var yAxis = new OxyPlot.Axes.LinearAxis
            {
                Position           = OxyPlot.Axes.AxisPosition.Left,
                StringFormat       = "p0",
                MajorGridlineStyle = LineStyle.Dash
            };

            model.Axes.Add(yAxis);

            var capUsageTmpSum = Enumerable.Range(0, Data.RelativeCapitalUsageByStrategy.Rows.Count).Select(x => 0.0).ToList();

            foreach (DataColumn column in Data.RelativeCapitalUsageByStrategy.Columns)
            {
                if (column.ColumnName == "date")
                {
                    continue;
                }

                DataColumn    column1 = column;
                List <double> sum     = capUsageTmpSum;
                var           series  = new OxyPlot.Series.AreaSeries
                {
                    ItemsSource = Data
                                  .RelativeCapitalUsageByStrategy
                                  .Select((x, i) =>
                                          new
                    {
                        X  = x.date,
                        Y  = sum[i],
                        Y2 = sum[i] + x.Field <double>(column1.ColumnName),
                    }),

                    Title = column.ColumnName,
                    CanTrackerInterpolatePoints = false,
                    TrackerFormatString         = "Strategy: " + column.ColumnName + @" Date: {2:yyyy-MM-dd} Capital Usage: {4:p1}",
                    DataFieldX      = "X",
                    DataFieldX2     = "X",
                    DataFieldY      = "Y",
                    DataFieldY2     = "Y2",
                    MarkerType      = MarkerType.None,
                    StrokeThickness = 1
                };

                capUsageTmpSum = Data.RelativeCapitalUsageByStrategy.Select((x, i) => x.Field <double>(column1.ColumnName) + capUsageTmpSum[i]).ToList();

                model.Series.Add(series);
            }

            model.LegendPosition    = LegendPosition.BottomCenter;
            model.LegendOrientation = LegendOrientation.Horizontal;
            model.LegendPlacement   = LegendPlacement.Outside;

            RelativeCapitalUsageByStrategyModel = model;
        }