Example #1
2
        /// <summary>
        /// 
        /// </summary>
        public TremorTool()
        {
            InitializeComponent();
            _syncContext = SynchronizationContext.Current;

            grid_advancedSettingsHolder.Visibility = Visibility.Hidden;
            grid_graphHolder.Visibility = Visibility.Hidden;

            combobox_nodeSelect.Items.Clear();
            Nodes.UpdateAvailableSensors();

            foreach (string sensor in Nodes.COM_Ports)
                combobox_nodeSelect.Items.Add(sensor);

            if (!combobox_nodeSelect.Items.IsEmpty)
                combobox_nodeSelect.SelectedIndex = 0;

            // Makes the plot.
            Plot = new OxyPlot.Wpf.PlotView();
            Plot.Model = new PlotModel();
            Plot.Model.PlotType = PlotType.XY;
            Plot.Model.Background = OxyColor.FromRgb(255, 255, 255);

            //Plot.Dock = DockStyle.Fill;
            groupBox_graph.Content = Plot;
            //Plot.Model.TextColor = OxyColor.FromRGB(0, 0, 0);

            //Our graph data is filled with zeros for now.
            for (int i = 0; i < 10; i++) 
            {
                graphData[0, i] = 0;
                fLine.Points.Add(new DataPoint(i, graphData[0, i]));
                graphData[1, i] = 0;
                aLine.Points.Add(new DataPoint(i, graphData[1, i]));
            }

            // add Series and Axis to plot model
            OxyPlot.Axes.LinearAxis fAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Left, 0.0, 15.0); //Makes the axes.
            OxyPlot.Axes.LinearAxis aAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Right, 0.0, 20.0);
            fAxis.Key = "Frequency"; //Sets the key for the and amplitude.
            aAxis.Key = "Amplitude";
            fAxis.Title = "Frequency (Hz)";
            aAxis.Title = "Amplitude (?)";
            fLine.YAxisKey = fAxis.Key; //Assigns the key to the series.
            aLine.YAxisKey = aAxis.Key;
            Plot.Model.Series.Add(fLine); //Adds the data for the frequency.
            Plot.Model.Series.Add(aLine); //Adds the data for the amplitude.
            Plot.Model.Axes.Add(new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Bottom, 0.0, 10.0)); //Adds the X axis.
            Plot.Model.Axes.Add(fAxis); //Adds the Y Axis for the frequency
            Plot.Model.Axes.Add(aAxis); //Adds the Y Axis for the amplitude
        }
        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);
            }
        }
Example #3
0
        public GraphForm(string graphTitle, string dependentTitle, string functionTitle)
        {
            InitializeComponent();

            PlotModel tmpPlot = new PlotModel(graphTitle);
            tmpPlot.PlotType = PlotType.XY;

            var yAxis = new OxyPlot.Axes.LinearAxis();
            yAxis.Title = dependentTitle;
            tmpPlot.Axes.Add(yAxis);

            PointsModel = tmpPlot;
        }
Example #4
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;
        }
Example #5
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);
        }
Example #6
0
        public void DrawPlot(double[] data, bool isOriginal)
        {
            var i           = 0;
            var chartPoints = data.Select(c => new DataPoint(i++, c)).ToList();
            var series      = new OxyPlot.Series.LineSeries()
            {
                Color = OxyColor.Parse("#673ab7"),
            };
            var xAxis = new OxyPlot.Axes.LinearAxis()
            {
                Position      = OxyPlot.Axes.AxisPosition.Bottom,
                TextColor     = OxyColor.Parse("#bdbdbd"),
                AxislineColor = OxyColor.Parse("#bdbdbd"),
                TicklineColor = OxyColor.Parse("#bdbdbd"),
            };

            var yAxis = new OxyPlot.Axes.LinearAxis()
            {
                Title         = isOriginal ? "Original" : "Equalized",
                TitleColor    = OxyColor.Parse("#bdbdbd"),
                Position      = OxyPlot.Axes.AxisPosition.Left,
                TextColor     = OxyColor.Parse("#bdbdbd"),
                AxislineColor = OxyColor.Parse("#bdbdbd"),
                TicklineColor = OxyColor.Parse("#bdbdbd"),
            };

            series.Points.AddRange(chartPoints);
            var model = new PlotModel()
            {
                PlotAreaBorderColor = OxyColor.Parse("#bdbdbd"),
            };

            model.Series.Add(series);
            model.Axes.Add(xAxis);
            model.Axes.Add(yAxis);

            if (isOriginal)
            {
                OriginalPlotModel = model;
            }
            else
            {
                EqualizedPlotModel = model;
            }
        }
Example #7
0
        PlotModel initModel()
        {
            PlotModel model = new PlotModel {
                Title = "Anomaly Graph"
            };

            model.LegendPosition    = LegendPosition.RightBottom;
            model.LegendPlacement   = LegendPlacement.Outside;
            model.LegendOrientation = LegendOrientation.Horizontal;
            var Yaxis = new OxyPlot.Axes.LinearAxis();
            var XAxis = new OxyPlot.Axes.LinearAxis {
                Position = OxyPlot.Axes.AxisPosition.Bottom
            };

            model.Axes.Add(Yaxis);
            model.Axes.Add(XAxis);
            return(model);
        }
        private void Initialize_EnergyScalePlot_Base(PlotModel energyscale_plot, OxyPlot.Series.ScatterSeries[] energyscale_data, State_Variables state, bool color_flag)
        {
            //scaletime_plot.PlotAreaBorderThickness = new OxyThickness(0.0);
            energyscale_plot.PlotMargins     = new OxyThickness(8.0);
            energyscale_plot.TitleFontWeight = 5;

            OxyPlot.Axes.LinearAxis x = new OxyPlot.Axes.LinearAxis();
            x.Maximum = State.Num_ScaleBins;
            x.Minimum = 0.0;
            x.PositionAtZeroCrossing = true;
            x.Position                = OxyPlot.Axes.AxisPosition.Bottom;
            x.AxislineThickness       = 0.5;
            x.AxislineColor           = OxyColors.Black;
            x.TickStyle               = OxyPlot.Axes.TickStyle.Crossing;
            x.AxisTickToLabelDistance = 0.0;
            x.FontSize                = 8.0;
            energyscale_plot.Axes.Add(x);

            OxyPlot.Axes.LinearAxis y = new OxyPlot.Axes.LinearAxis();
            y.PositionAtZeroCrossing = true;
            y.MajorGridlineStyle     = LineStyle.Solid;
            y.MinorGridlineStyle     = LineStyle.Dot;
            y.AxislineThickness      = 0.5;
            y.AxislineColor          = OxyColors.Black;
            y.TickStyle = OxyPlot.Axes.TickStyle.Crossing;
            y.AxisTickToLabelDistance = 0.0;
            y.FontSize = 8.0;
            energyscale_plot.Axes.Add(y);

            for (int i = 0; i < state.Num_Points; i++)
            {
                energyscale_data[i]            = new OxyPlot.Series.ScatterSeries();
                energyscale_data[i].MarkerType = MarkerType.Circle;
                energyscale_data[i].MarkerSize = 2;
                if (!color_flag)
                {
                    energyscale_data[i].MarkerFill = OxyColors.Black;
                }

                energyscale_plot.Series.Add(energyscale_data[i]);
            }

            //energyscale_plot.MouseLeave += EnergyScalePlot_MouseLeave;
        }
        private void InitializePlot()
        {
            //Set the borders of the plot
            PlotModelObject.PlotAreaBorderThickness = new OxyPlot.OxyThickness(0);
            PlotModelObject.PlotMargins             = new OxyPlot.OxyThickness(0);

            //Set the axes
            PlotModelObject.Axes.Clear();

            var x_axis = new OxyPlot.Axes.LinearAxis()
            {
                Position      = OxyPlot.Axes.AxisPosition.Bottom,
                IsPanEnabled  = false,
                IsZoomEnabled = false,
                Minimum       = 0,
                Maximum       = max_elements
            };

            var y_axis = new OxyPlot.Axes.LinearAxis()
            {
                Position      = OxyPlot.Axes.AxisPosition.Left,
                IsPanEnabled  = false,
                IsZoomEnabled = false,
                Minimum       = -1050,
                Maximum       = 1050
            };

            PlotModelObject.Axes.Add(x_axis);
            PlotModelObject.Axes.Add(y_axis);

            //Create 2 series, one for each load cell
            PlotModelObject.Series.Clear();

            var s = new OxyPlot.Series.LineSeries()
            {
                Color = OxyPlot.OxyColors.CornflowerBlue
            };

            PlotModelObject.Series.Add(s);

            //Update the plot
            PlotModelObject.InvalidatePlot(true);
        }
        public void SavePlot(string title, double[] data)
        {
            SaveFileDialog sfd = new SaveFileDialog
            {
                Filter           = "Image file ( *.png)| *.png",
                AddExtension     = true,
                OverwritePrompt  = true,
                RestoreDirectory = true,
                FileName         = title
            };

            if (sfd.ShowDialog() == true)
            {
                var i           = 0;
                var chartPoints = data.Select(c => new DataPoint(i++, c)).ToList();
                var series      = new OxyPlot.Series.LineSeries()
                {
                    Color = OxyColor.Parse("#673ab7"),
                };
                var xAxis = new OxyPlot.Axes.LinearAxis()
                {
                    Position = OxyPlot.Axes.AxisPosition.Bottom,
                };

                var yAxis = new OxyPlot.Axes.LinearAxis()
                {
                    Position = OxyPlot.Axes.AxisPosition.Left,
                };

                series.Points.AddRange(chartPoints);
                var model = new PlotModel();

                model.Series.Add(series);
                model.Axes.Add(xAxis);
                model.Axes.Add(yAxis);

                var pngExporter = new PngExporter {
                    Width = 1920, Height = 270, Background = OxyColors.White
                };
                pngExporter.ExportToFile(model, sfd.FileName);
            }
        }
        private void Initialize_PointsPlot(PlotModel points_plot, string name)
        {
            //points_plot.PlotAreaBorderThickness = new OxyThickness(10.0);
            points_plot.PlotMargins     = new OxyThickness(0.0);
            points_plot.Title           = name;
            points_plot.TitleFontWeight = 5;

            OxyPlot.Axes.LinearAxis x = new OxyPlot.Axes.LinearAxis();
            x.PositionAtZeroCrossing = true;
            x.Position  = OxyPlot.Axes.AxisPosition.Bottom;
            x.TickStyle = OxyPlot.Axes.TickStyle.Crossing;
            x.TextColor = OxyColors.Transparent;
            points_plot.Axes.Add(x);

            OxyPlot.Axes.LinearAxis y = new OxyPlot.Axes.LinearAxis();
            y.PositionAtZeroCrossing = true;
            y.TickStyle = OxyPlot.Axes.TickStyle.Crossing;
            y.TextColor = OxyColors.Transparent;
            points_plot.Axes.Add(y);
        }
Example #12
0
        /// <summary>
        /// 设置显示坐标
        /// </summary>
        private void InitChart()
        {
            DrawingChart.Model = new PlotModel();

            //x轴倒叙
            xAxs = new OxyPlot.Axes.LinearAxis()
            {
                Position = OxyPlot.Axes.AxisPosition.Bottom, StartPosition = 0, EndPosition = 1
            };
            DrawingChart.ActualModel.Axes.Add(xAxs);

            DrawingChart.Model.SelectionColor = OxyColor.FromArgb(255, 0, 0, 0);

            //DrawingChart.MouseDoubleClick += spectrumChart_MouseDoubleClick;
            //DrawingChart.Controller = myController;
            //myController.UnbindMouseDown(OxyMouseButton.Right);
            //myController.UnbindMouseDown(OxyMouseButton.Left);

            //spectrumChart.IsMouseCapturedChanged += spectrumChart_IsMouseCapturedChanged;
            //InitMouseDownEvent();
        }
        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 = "Transaction 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);
        }
Example #14
0
        public MainWindow()
        {
            InitializeComponent();
            MyModel = new PlotModel {
                Title = "Резонансная кривая"
            };
            graph.Model = MyModel;

            MyModel.Axes.Clear();
            this.lineSeries1 = new LineSeries();
            _axisX           = new OxyPlot.Axes.LinearAxis()
            {
                Position = OxyPlot.Axes.AxisPosition.Bottom
            };
            _axisY = new OxyPlot.Axes.LinearAxis()
            {
                Position = OxyPlot.Axes.AxisPosition.Left
            };
            MyModel.Axes.Add(_axisX);
            MyModel.Axes.Add(_axisY);
            MyModel.InvalidatePlot(true);
        }
        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;

            var dateAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Bottom, "Dose")
            {
                MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 80
            };

            plotModel.Axes.Add(dateAxis);
            var valueAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Left, 0, 100, "Volume")
            {
                MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Volume"
            };

            plotModel.Axes.Add(valueAxis);
        }
        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 void plotData(double echelll, double echlleCM, double altmin, double altmax, double equidist, List <Point> points_intersections, List <double> altitude)
        {
            double     echelle    = echlleCM / echelll;
            var        model      = new PlotModel();
            LineSeries linePoints = new LineSeries()
            {
                StrokeThickness       = 2,
                MarkerSize            = 1.5,
                Color                 = OxyColors.Black,
                MarkerType            = MarkerType.Circle,
                MarkerStroke          = OxyColors.OrangeRed,
                Background            = OxyColors.WhiteSmoke,
                MarkerStrokeThickness = 3,
            };
            int i = 0;

            while (i < points_intersections.Count)
            {
                linePoints.Points.Add(new DataPoint(points_intersections[i].X * echelle, altitude[i]));
                i++;
            }
            var Xaxis = new OxyPlot.Axes.LinearAxis();

            Xaxis.MajorStep = echelle;
            Xaxis.Position  = OxyPlot.Axes.AxisPosition.Bottom;
            Xaxis.Title     = "Axe des Abscisses";
            model.Axes.Add(Xaxis);
            var Yaxis = new OxyPlot.Axes.LinearAxis();

            Yaxis.Minimum = altmin;
            Yaxis.Maximum = altmax;
            Yaxis.Title   = "Axe des altitudes";
            model.Axes.Add(Yaxis);
            // Add Each series to the
            model.Series.Add(linePoints);
            // Add the plot to the window
            plot.Model = model;
        }
Example #18
0
        static PlotModel CreateChartOnlyBars()
        {
            var splotModel = new PlotModel();


            splotModel.IsLegendVisible     = false;
            splotModel.Background          = OxyColor.FromArgb(0, 0, 0, 255);
            splotModel.TextColor           = OxyColor.FromArgb(0, 0, 0, 255);
            splotModel.PlotAreaBorderColor = OxyColor.FromArgb(0, 0, 0, 255);

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

            axis.IsPanEnabled = axis.IsAxisVisible = false;

            splotModel.Axes.Add(axis);

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

            dateAxis.IsPanEnabled = dateAxis.IsAxisVisible = false;
            splotModel.Axes.Add(dateAxis);

            return(splotModel);
        }
Example #19
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;
        }
        /// <summary>
        ///     Creates a plot for the given peaks list
        /// </summary>
        /// <param name="peaksX"></param>
        /// <param name="peaksY"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        private PlotModel CreatePlot(List<XYData> peaksX,
            List<XYData> peaksY,
            double tolerance)
        {
            var plotModel1 = new PlotModel();
            plotModel1.LegendBorderThickness = 0;
            plotModel1.LegendOrientation = LegendOrientation.Horizontal;
            plotModel1.LegendPlacement = LegendPlacement.Outside;
            plotModel1.LegendPosition = LegendPosition.BottomCenter;
            plotModel1.Title = "MS/MS Spectra";

            var categoryAxis1 = new LinearAxis();
            categoryAxis1.MinorStep = tolerance;
            plotModel1.Axes.Add(categoryAxis1);

            var linearAxis1 = new LinearAxis();
            linearAxis1.MaximumPadding = 0.06;
            linearAxis1.MinimumPadding = 0.06;
            plotModel1.Axes.Add(linearAxis1);

            var xseries = new StemSeries();
            for (var j = 0; j < peaksY.Count; j++)
            {
                var peakX = peaksX[j];
                var peakY = peaksY[j];

                double value = 0;
                if (peakX.Y > 0 && peakY.Y > 0)
                {
                    value = 1;
                }
                xseries.Points.Add(new DataPoint(peakX.X, value));
            }
            xseries.Color = OxyColors.Green;

            //plotModel1.Series.Add(xseries);

            var series = new StemSeries();
            series.Title = "Spectra X";
            double max = 0;
            foreach (var datum in peaksX)
            {
                max = Math.Max(max, datum.Y);
            }
            foreach (var datum in peaksX)
            {
                series.Points.Add(new DataPoint(datum.X, datum.Y/max));
            }
            plotModel1.Series.Add(series);

            foreach (var datum in peaksY)
            {
                max = Math.Max(max, datum.Y);
            }
            var series2 = new StemSeries();
            series2.Title = "Spectra Y";
            foreach (var datum in peaksY)
            {
                series2.Points.Add(new DataPoint(datum.X, (datum.Y*-1)/max));
            }
            plotModel1.Series.Add(series2);

            return plotModel1;
        }
        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;
                }
            }
        }
Example #22
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;
        }
Example #23
0
        /// <summary>
        ///     Creates a plot for the given peaks list
        /// </summary>
        /// <param name="peaksX"></param>
        /// <param name="peaksY"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        private static PlotModel CreatePlot(IReadOnlyList <XYData> peaksX,
                                            IReadOnlyList <XYData> peaksY,
                                            double tolerance)
        {
            var plotModel1 = new PlotModel
            {
                LegendBorderThickness = 0,
                LegendOrientation     = LegendOrientation.Horizontal,
                LegendPlacement       = LegendPlacement.Outside,
                LegendPosition        = LegendPosition.BottomCenter,
                Title = "MS/MS Spectra"
            };

            var categoryAxis1 = new LinearAxis {
                MinorStep = tolerance
            };

            plotModel1.Axes.Add(categoryAxis1);

            var linearAxis1 = new LinearAxis {
                MaximumPadding = 0.06, MinimumPadding = 0.06
            };

            plotModel1.Axes.Add(linearAxis1);

            var xseries = new StemSeries();

            for (var j = 0; j < peaksY.Count; j++)
            {
                var peakX = peaksX[j];
                var peakY = peaksY[j];

                double value = 0;
                if (peakX.Y > 0 && peakY.Y > 0)
                {
                    value = 1;
                }

                xseries.Points.Add(new DataPoint(peakX.X, value));
            }
            xseries.Color = OxyColor.FromAColor(100, OxyColors.Green);

            //plotModel1.Series.Add(xseries);

            var series = new StemSeries {
                Title = "Spectra X"
            };
            var max = peaksX.Select(datum => datum.Y).Concat(new double[] { 0 }).Max();

            foreach (var datum in peaksX)
            {
                series.Points.Add(new DataPoint(datum.X, datum.Y / max));
            }
            plotModel1.Series.Add(series);

            max = peaksY.Select(datum => datum.Y).Concat(new[] { max }).Max();
            var series2 = new StemSeries {
                Title = "Spectra Y"
            };

            foreach (var datum in peaksY)
            {
                series2.Points.Add(new DataPoint(datum.X, (datum.Y * -1) / max));
            }
            plotModel1.Series.Add(series2);


            return(plotModel1);
        }
Example #24
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;
            }
        }
Example #25
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
				}
			};
		}
        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);
            }
        }
        OxyPlot.Series.LineSeries[] punktySerii = new OxyPlot.Series.LineSeries[(int)(Global.zakres_do - Global.zakres_od) + 2];  //zakres do - zakres od



        public void PodajDaneDoWykresu(List <double> X, List <double> Y)//Lista X i Y podana jako parametr metody
        {
            this.Plot1.Model = new OxyPlot.PlotModel();
            //Usunięcie ustawionych parametrów z poprzedniego uruchomienia metody
            this.Plot1.Model.Series = new System.Collections.ObjectModel.Collection <OxyPlot.Series.Series> {
            };
            this.Plot1.Model.Axes   = new System.Collections.ObjectModel.Collection <OxyPlot.Axes.Axis> {
            };

            punktySerii = new OxyPlot.Series.LineSeries[(int)(Global.zakres_do - Global.zakres_od) + 2];  //zakres do - zakres od

            //Graficzne ustawienia wykresów
            for (int i = 0; i < ((Global.zakres_do - Global.zakres_od) + 2); i++)
            {
                punktySerii[i] = new OxyPlot.Series.LineSeries
                {
                    MarkerType   = ksztaltPunktowWykresu[4],     //oznaczenie punktów - definicja poniżej
                    MarkerSize   = 4,                            //wielkość punktów
                    MarkerStroke = koloryWykresow[3],            //Kolor linii wykresu - definicja poniżej
                    Title        = "Seria nr: " + (i).ToString() //tytuł serii
                };
            }

            //Uzupełnianie danych

            // pierwszy
            {
                List <double> listaXX = new List <double>();

                List <double> listaYY = new List <double>();


                listaXX.Add(Global.listaX[0] - 1);
                listaXX.Add(Global.listaX[0]);

                listaYY.Add(0);
                listaYY.Add(0);

                for (int n = 0; n < listaXX.Count; n++)
                {
                    punktySerii[0].Points.Add(new OxyPlot.DataPoint(listaXX[n], listaYY[n]));//dodanie wszystkich serii do wykresu
                }
                this.Plot1.Model.Series.Add(punktySerii[0]);
            }

            for (int i = 0; i < ((Global.zakres_do - Global.zakres_od)); i++)
            {
                List <double> listaXX = new List <double>();

                List <double> listaYY = new List <double>();


                listaXX.Add(Global.listaX[i]);
                listaXX.Add(Global.listaX[i + 1]);

                listaYY.Add(Global.listaY[i]);
                listaYY.Add(Global.listaY[i]);



                for (int n = 0; n < listaXX.Count; n++)
                {
                    punktySerii[i + 1].Points.Add(new OxyPlot.DataPoint(listaXX[n], listaYY[n]));//dodanie wszystkich serii do wykresu
                }
                this.Plot1.Model.Series.Add(punktySerii[i + 1]);
            }



            // ostatni
            {
                List <double> listaXX = new List <double>();

                List <double> listaYY = new List <double>();



                listaXX.Add(Global.listaX[Global.listaX.Count - 1]);
                listaXX.Add(Global.listaX[Global.listaX.Count - 1] + 2);

                listaYY.Add(1);
                listaYY.Add(1);

                for (int n = 0; n < listaXX.Count; n++)
                {
                    punktySerii[punktySerii.Length - 1].Points.Add(new OxyPlot.DataPoint(listaXX[n], listaYY[n]));//dodanie wszystkich serii do wykresu
                }
                this.Plot1.Model.Series.Add(punktySerii[punktySerii.Length - 1]);
            }


            //Opis i parametry osi wykresu
            var xAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Bottom, "X")
            {
                MajorGridlineStyle = OxyPlot.LineStyle.Solid, MinorGridlineStyle = OxyPlot.LineStyle.Dot
            };

            this.Plot1.Model.Axes.Add(xAxis);
            var yAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Left, "Y")
            {
                MajorGridlineStyle = OxyPlot.LineStyle.Solid, MinorGridlineStyle = OxyPlot.LineStyle.Dot
            };

            this.Plot1.Model.Axes.Add(yAxis);
        }
Example #29
0
        /// <summary>
        ///     Creates a plot for the given peaks list
        /// </summary>
        /// <param name="peaksX"></param>
        /// <param name="peaksY"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        private static PlotModel CreatePlot(IReadOnlyList<XYData> peaksX,
            IReadOnlyList<XYData> peaksY,
            double tolerance)
        {
            var plotModel1 = new PlotModel
            {
                LegendBorderThickness = 0,
                LegendOrientation = LegendOrientation.Horizontal,
                LegendPlacement = LegendPlacement.Outside,
                LegendPosition = LegendPosition.BottomCenter,
                Title = "MS/MS Spectra"
            };

            var categoryAxis1 = new LinearAxis {MinorStep = tolerance};
            plotModel1.Axes.Add(categoryAxis1);

            var linearAxis1 = new LinearAxis {MaximumPadding = 0.06, MinimumPadding = 0.06};
            plotModel1.Axes.Add(linearAxis1);

            var xseries = new StemSeries();
            for (var j = 0; j < peaksY.Count; j++)
            {
                var peakX = peaksX[j];
                var peakY = peaksY[j];

                double value = 0;
                if (peakX.Y > 0 && peakY.Y > 0)
                    value = 1;

                xseries.Points.Add(new DataPoint(peakX.X, value));
            }
            xseries.Color = OxyColor.FromAColor(100, OxyColors.Green);

            //plotModel1.Series.Add(xseries);

            var series = new StemSeries {Title = "Spectra X"};
            var max = peaksX.Select(datum => datum.Y).Concat(new double[] {0}).Max();
            foreach (var datum in peaksX)
            {
                series.Points.Add(new DataPoint(datum.X, datum.Y/max));
            }
            plotModel1.Series.Add(series);

            max = peaksY.Select(datum => datum.Y).Concat(new[] {max}).Max();
            var series2 = new StemSeries {Title = "Spectra Y"};
            foreach (var datum in peaksY)
            {
                series2.Points.Add(new DataPoint(datum.X, (datum.Y*-1)/max));
            }
            plotModel1.Series.Add(series2);

            return plotModel1;
        }
Example #30
0
        private static void MakeBarPlot([JetBrains.Annotations.NotNull] string outputPath, [ItemNotNull][JetBrains.Annotations.NotNull] List <Column> columns, int position, int day)
        {
            var plotModel2 = new PlotModel();
            // filter significant columns
            var allColumns = new List <Tuple <string, double> >();

            for (var i = 1; i < columns.Count; i++)
            {
                allColumns.Add(new Tuple <string, double>(columns[i].Name, columns[i].MakeSum(position, 1440)));
            }
            allColumns.Sort((x, y) => y.Item2.CompareTo(x.Item2));
            var topCols = allColumns.Select(x => x.Item1).Take(20).ToList();
            var p       = OxyPalettes.HueDistinct(topCols.Count);
            var oxc     = OxyColor.FromArgb(255, 50, 50, 50);

            plotModel2.LegendPosition    = LegendPosition.BottomCenter;
            plotModel2.LegendPlacement   = LegendPlacement.Outside;
            plotModel2.LegendOrientation = LegendOrientation.Horizontal;
            plotModel2.Title             = "Day " + day;
            // axes
            var cate = new CategoryAxis
            {
                AbsoluteMinimum = 0,
                MinimumPadding  = 0,
                GapWidth        = 0,
                MajorStep       = 60,
                Title           = "Activities"
            };

            plotModel2.Axes.Add(cate);

            var linearAxis2 = new LinearAxis
            {
                AbsoluteMinimum = 0,
                MaximumPadding  = 0.06,
                MinimumPadding  = 0,
                Title           = "Minutes"
            };

            plotModel2.Axes.Add(linearAxis2);
            const int minutesToSum = 15;

            for (var i = 1; i < columns.Count; i++)
            {
                if (columns[i].MakeSum(position, 1440) > 0)
                {
                    var columnSeries2 = new ColumnSeries
                    {
                        IsStacked       = true,
                        StrokeThickness = 0,
                        Title           = columns[i].Name
                    };
                    for (var j = position; j < position + 1440; j += minutesToSum)
                    {
                        columnSeries2.Items.Add(new ColumnItem(columns[i].MakeSum(j, minutesToSum) / minutesToSum));
                    }
                    if (topCols.Contains(columns[i].Name))
                    {
                        var coloridx = topCols.IndexOf(columns[i].Name);
                        columnSeries2.FillColor = p.Colors[coloridx];
                    }
                    else
                    {
                        columnSeries2.FillColor = oxc;
                    }
                    plotModel2.Series.Add(columnSeries2);
                }
            }
            var path2 = Path.Combine(outputPath, "ActivityPlot." + day + ".bar.png");

            PngExporter.Export(plotModel2, path2, 3200, 1600, OxyColor.FromRgb(255, 255, 255), 100);
        }
Example #31
0
        private void CreateMdsChartModel()
        {
            var model = new PlotModel();

            var xAxis = new OxyPlot.Axes.LinearAxis
            {
                Position = OxyPlot.Axes.AxisPosition.Bottom,
                MajorGridlineStyle = LineStyle.None
            };
            model.Axes.Add(xAxis);

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

            var series = new OxyPlot.Series.ScatterSeries
            {
                ItemsSource = (Data.MdsCoords.Rows.Cast<filterReportDS.MdsCoordsRow>()
                    .Select(dr => new DataPoint(dr.X, dr.Y))),
                DataFieldX = "X",
                DataFieldY = "Y",
                MarkerType = MarkerType.Circle,
                MarkerSize = 2,
                MarkerFill = OxyColor.FromRgb(79, 129, 189)
            };

            model.Series.Add(series);

            foreach(filterReportDS.MdsCoordsRow dr in Data.MdsCoords.Rows)
            {
                var annotation = new OxyPlot.Annotations.TextAnnotation
                {
                    Text = dr.StrategyName,
                    TextPosition = new DataPoint(dr.X, dr.Y),
                    TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Center,
                    TextVerticalAlignment = OxyPlot.VerticalAlignment.Top,
                    Font = "Segoe UI",
                    TextColor = OxyColor.FromRgb(0, 0, 0),
                    StrokeThickness = 0
                };

                model.Annotations.Add(annotation);
            }

            MdsChartModel = model;
        }
        private void SetUpModel()
        {
            PlotModel.IsLegendVisible = false;
             PlotModel.LegendOrientation = LegendOrientation.Horizontal;
             PlotModel.LegendPlacement = LegendPlacement.Outside;
             PlotModel.LegendPosition = LegendPosition.TopRight;
             PlotModel.LegendBackground = OxyColors.Transparent;
             PlotModel.LegendBorder = OxyColors.Transparent;
             PlotModel.LegendTextColor = OxyColors.White;

             //Axes
             xAxis = new OxyPlot.Axes.LinearAxis();
             xAxis.Position = OxyPlot.Axes.AxisPosition.Bottom;
             xAxis.AxislineColor = OxyColors.Black;
             xAxis.TickStyle = OxyPlot.Axes.TickStyle.Outside;
             xAxis.TicklineColor = OxyColors.Black;
             xAxis.TextColor = OxyColors.Black;

             yAxis = new OxyPlot.Axes.LinearAxis();
             yAxis.Position = OxyPlot.Axes.AxisPosition.Left;
             yAxis.AxislineColor = OxyColors.Black;
             yAxis.TickStyle = OxyPlot.Axes.TickStyle.Outside;
             yAxis.TicklineColor = OxyColors.Black;
             yAxis.TextColor = OxyColors.Black;

             PlotModel.Axes.Add(xAxis);
             PlotModel.Axes.Add(yAxis);
        }
Example #33
0
		static PlotModel CreateChartOnlyBars ()
		{
			var splotModel = new PlotModel ();


			splotModel.IsLegendVisible = false;
			splotModel.Background = OxyColor.FromArgb (0, 0, 0, 255);
			splotModel.TextColor = OxyColor.FromArgb (0, 0, 0, 255);
			splotModel.PlotAreaBorderColor = OxyColor.FromArgb (0, 0, 0, 255);

			var axis = new OxyPlot.Axes.LinearAxis ();
			axis.IsPanEnabled =  axis.IsAxisVisible = false;

			splotModel.Axes.Add (axis);

			var dateAxis = new OxyPlot.Axes.CategoryAxis ();
			dateAxis.IsPanEnabled =   dateAxis.IsAxisVisible = false;
			splotModel.Axes.Add (dateAxis);

			return splotModel;
		}
Example #34
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;
        }
Example #35
0
        /// <summary>
        ///     Creates a plot for the given peaks list
        /// </summary>
        /// <param name="peaksX"></param>
        /// <param name="peaksY"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        private PlotModel CreatePlot(List <XYData> peaksX,
                                     List <XYData> peaksY,
                                     double tolerance)
        {
            var plotModel1 = new PlotModel();

            plotModel1.LegendBorderThickness = 0;
            plotModel1.LegendOrientation     = LegendOrientation.Horizontal;
            plotModel1.LegendPlacement       = LegendPlacement.Outside;
            plotModel1.LegendPosition        = LegendPosition.BottomCenter;
            plotModel1.Title = "MS/MS Spectra";

            var categoryAxis1 = new LinearAxis();

            categoryAxis1.MinorStep = tolerance;
            plotModel1.Axes.Add(categoryAxis1);

            var linearAxis1 = new LinearAxis();

            linearAxis1.MaximumPadding = 0.06;
            linearAxis1.MinimumPadding = 0.06;
            plotModel1.Axes.Add(linearAxis1);

            var xseries = new StemSeries();

            for (var j = 0; j < peaksY.Count; j++)
            {
                var peakX = peaksX[j];
                var peakY = peaksY[j];

                double value = 0;
                if (peakX.Y > 0 && peakY.Y > 0)
                {
                    value = 1;
                }
                xseries.Points.Add(new DataPoint(peakX.X, value));
            }
            xseries.Color = OxyColors.Green;

            //plotModel1.Series.Add(xseries);

            var series = new StemSeries();

            series.Title = "Spectra X";
            double max = 0;

            foreach (var datum in peaksX)
            {
                max = Math.Max(max, datum.Y);
            }
            foreach (var datum in peaksX)
            {
                series.Points.Add(new DataPoint(datum.X, datum.Y / max));
            }
            plotModel1.Series.Add(series);

            foreach (var datum in peaksY)
            {
                max = Math.Max(max, datum.Y);
            }
            var series2 = new StemSeries();

            series2.Title = "Spectra Y";
            foreach (var datum in peaksY)
            {
                series2.Points.Add(new DataPoint(datum.X, (datum.Y * -1) / max));
            }
            plotModel1.Series.Add(series2);


            return(plotModel1);
        }
Example #36
0
        public void PodajDaneDoWykresu()//Lista X i Y podana jako parametr metody
        {
            this.Plot1.Model = new OxyPlot.PlotModel();
            //Usunięcie ustawionych parametrów z poprzedniego uruchomienia metody
            this.Plot1.Model.Series = new System.Collections.ObjectModel.Collection <OxyPlot.Series.Series> {
            };
            this.Plot1.Model.Axes   = new System.Collections.ObjectModel.Collection <OxyPlot.Axes.Axis> {
            };

            punktySerii = new OxyPlot.Series.LineSeries[1];  //zakres do - zakres od

            //Graficzne ustawienia wykresów
            for (int i = 0; i < (1); i++)
            {
                punktySerii[i] = new OxyPlot.Series.LineSeries
                {
                    MarkerType   = ksztaltPunktowWykresu[4],     //oznaczenie punktów - definicja poniżej
                    MarkerSize   = 4,                            //wielkość punktów
                    MarkerStroke = koloryWykresow[3],            //Kolor linii wykresu - definicja poniżej
                    Title        = "Seria nr: " + (i).ToString() //tytuł serii
                };
            }

            //Uzupełnianie danych

            // pierwszy
            {
                List <double> listaXX = new List <double>();

                List <double> listaYY = new List <double>();

                if (dysty)
                {
                    for (int i = 0; i < Dystrybuanta.Rows.Count; i++)
                    {
                        listaXX.Add(int.Parse(Dystrybuanta.Rows[i]["Wylosowana"].ToString()));
                        listaYY.Add(int.Parse(Dystrybuanta.Rows[i]["Ile"].ToString()));
                    }
                }
                else
                {
                    var b = 0.1;
                    listaYY.Add(values[0]);
                    listaXX.Add(0);
                    for (int i = 0; i < values.Length - 1; i++)
                    {
                        listaYY.Add(values[i]);
                        listaXX.Add(b);
                        listaYY.Add(values[i + 1]);
                        listaXX.Add(b);
                        b += 0.1;
                    }
                    listaYY.Add(values[9]);
                    listaXX.Add(1);
                }



                for (int n = 0; n < listaXX.Count; n++)
                {
                    punktySerii[0].Points.Add(new OxyPlot.DataPoint(listaXX[n], listaYY[n]));//dodanie wszystkich serii do wykresu
                }
                this.Plot1.Model.Series.Add(punktySerii[0]);
            }



            //Opis i parametry osi wykresu
            var xAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Bottom, "X")
            {
                MajorGridlineStyle = OxyPlot.LineStyle.Solid, MinorGridlineStyle = OxyPlot.LineStyle.Dot
            };

            this.Plot1.Model.Axes.Add(xAxis);
            var yAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Left, "Y")
            {
                MajorGridlineStyle = OxyPlot.LineStyle.Solid, MinorGridlineStyle = OxyPlot.LineStyle.Dot
            };

            this.Plot1.Model.Axes.Add(yAxis);
        }
Example #37
0
 public void LinearAxis()
 {
     var s1 = new OxyPlot.Axes.LinearAxis();
     var s2 = new LinearAxis();
     OxyAssert.PropertiesAreEqual(s1, s2);
 }
		public WeatherObservationPage ()
		{
			var weatherSeries = new LineSeries ();

			var m = new PlotModel ("Weather");

			var magnitudeAxis = new OxyPlot.Axes.LinearAxis ();
			magnitudeAxis.Minimum = 0;
			magnitudeAxis.Maximum = 40;
			magnitudeAxis.Title = "Temperature";
			m.Axes.Add (magnitudeAxis);

			var dateAxis = new OxyPlot.Axes.CategoryAxis ();
			dateAxis.Labels.Add("Station");
			m.Axes.Add (dateAxis);

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

			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 Weather Data" };
			b.Clicked += async (sender, e) => {
				var sv = new GeoNamesWebService();
				var we = await sv.GetWeatherObservationsAsync();
				Xamarin.Forms.Device.BeginInvokeOnMainThread( () => {
					Debug.WriteLine("found " + we.Length + " weather observations");
					l.Text = we.Length + " weather observations";

					var eqlist = new List<WeatherObservation>(we);
//					eqlist.Sort((x, y) => string.Compare(x.datetime, y.datetime));


					var columSeries = new ColumnSeries();


					foreach (var eq in eqlist) {
						double t = 0.0;
						Double.TryParse(eq.temperature, out t);
						columSeries.Items.Add(new ColumnItem(t, 0));
						//pts.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Parse(eq.datetime)), Double.Parse(eq.temperature)));
					}
					opv.Model.Series.Clear();
					opv.Model.Series.Add(columSeries);

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


			Padding = new Thickness (0, 20, 0, 0);
			Content = new StackLayout {
				Children = {
					opv,
					b,
					l
				}
			};
		}
Example #39
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
            };
        }
Example #40
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.PlotDoubleScreen);
            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(History));
            //				intent.SetFlags(ActivityFlags.ClearTop); //remove the history and go back to home screen
            //				StartActivity(intent);
                OnBackPressed();
            };

            //CREATE HISTOGRAM FOR PEOPLE CONTEXT ON THE LEFT
            plotViewModelLeft = FindViewById<PlotView>(Resource.Id.plotViewModelLeft);

            //select all mood values for which people was 0 (alone)
            cursor = db.ReadableDatabase.RawQuery("SELECT mood FROM MoodData WHERE people = 0 AND NOT mood = -1", null); // cursor query

            if (cursor.Count > 0) {

                //initialize with 9 zero entries
                int[] histArray = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                //go through each entry and create the histogram count
                for (int ii = 0; ii < cursor.Count; ii++) {
                    cursor.MoveToPosition (ii);
                    int mood_temp = cursor.GetInt (0); //get mood from database
                    histArray [mood_temp] += 1; //increase histogram frequency by one
                    //System.Console.WriteLine("Mood: " + mood_temp.ToString() + " Freq: " + histArray [mood_temp].ToString());
                }

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

                //define axes

                //we need 9 categories for the histogram since we score the mood between 0 and 8
                var categoryAxis1 = new OxyPlot.Axes.CategoryAxis ();
            //			categoryAxis1.GapWidth = 0;
                categoryAxis1.LabelField = "Label";
            //			categoryAxis1.MinorStep = 1;
                categoryAxis1.Position = OxyPlot.Axes.AxisPosition.Bottom;
                categoryAxis1.ActualLabels.Add ("0");
                categoryAxis1.ActualLabels.Add ("1");
                categoryAxis1.ActualLabels.Add ("2");
                categoryAxis1.ActualLabels.Add ("3");
                categoryAxis1.ActualLabels.Add ("4");
                categoryAxis1.ActualLabels.Add ("5");
                categoryAxis1.ActualLabels.Add ("6");
                categoryAxis1.ActualLabels.Add ("7");
                categoryAxis1.ActualLabels.Add ("8");

            //			categoryAxis1.AbsoluteMaximum = 10;
            //			categoryAxis1.Maximum = 10;
                categoryAxis1.StringFormat = "0";
                categoryAxis1.IsPanEnabled = false;
                categoryAxis1.IsZoomEnabled = false;
                categoryAxis1.FontSize = dFontSize;
                categoryAxis1.Title = Resources.GetString (Resource.String.Mood);
                temp.Axes.Add (categoryAxis1);

                var linearAxis1 = new OxyPlot.Axes.LinearAxis ();
                linearAxis1.AbsoluteMinimum = 0;
                linearAxis1.AbsoluteMaximum = histArray.Max () * 1.2; //this has to be a bit higher than the highest frequency of the histogram
                linearAxis1.Minimum = 0;
                linearAxis1.Maximum = histArray.Max () * 1.2;
            //			linearAxis1.MaximumPadding = 0.1;
            //			linearAxis1.MinimumPadding = 0;
                linearAxis1.Position = OxyPlot.Axes.AxisPosition.Left;
                linearAxis1.FontSize = dFontSize;
                linearAxis1.IsZoomEnabled = false;
                linearAxis1.StringFormat = "0.0";
                linearAxis1.Title = Resources.GetString (Resource.String.Frequency);
                temp.Axes.Add (linearAxis1);

                var columnSeries1 = new ColumnSeries ();
                //http://forums.xamarin.com/discussion/20809/is-there-no-plotview-which-is-in-oxyplot-compent-in-xamarin-android
                //add data
                foreach (int i in histArray) {
                    columnSeries1.Items.Add (new ColumnItem (i, -1));
                }
                columnSeries1.LabelFormatString = "{0}";
                columnSeries1.FontSize = dFontSize;
                temp.Series.Add (columnSeries1);

                temp.Title = Resources.GetString (Resource.String.Alone);
                temp.TitleFontSize = dFontSize;
                MyModelLeft = temp;

                plotViewModelLeft.Model = MyModelLeft;
            }

            //CREATE HISTOGRAM FOR PEOPLE CONTEXT ON THE RIGHT
            plotViewModelRight = FindViewById<PlotView>(Resource.Id.plotViewModelRight);

            //select all mood values for which people was 0 (alone)
            cursor = db.ReadableDatabase.RawQuery("SELECT mood FROM MoodData WHERE NOT people = 0 AND NOT mood = -1", null); // cursor query

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

                //initialize with 9 zero entries
                int[] histArrayRight = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                //go through each entry and create the histogram count
                for (int ii = 0; ii < cursor.Count; ii++) {
                    cursor.MoveToPosition (ii);
                    int mood_temp = cursor.GetInt (0); //get mood from database
                    histArrayRight [mood_temp] += 1; //increase histogram frequency by one
                    //System.Console.WriteLine("Mood: " + mood_temp.ToString() + " Freq: " + histArray [mood_temp].ToString());
                }

                PlotModel tempRight = new PlotModel ();
                double dFontSize = tempRight.DefaultFontSize;
                if (Resources.DisplayMetrics.HeightPixels <= 320)
                    dFontSize = 5;

                //define axes

                //we need 9 categories for the histogram since we score the mood between 0 and 8
                var categoryAxisRight = new OxyPlot.Axes.CategoryAxis ();
                //categoryAxisRight.LabelField = "Label";
                categoryAxisRight.Position = OxyPlot.Axes.AxisPosition.Bottom;
                categoryAxisRight.ActualLabels.Add ("0");
                categoryAxisRight.ActualLabels.Add ("1");
                categoryAxisRight.ActualLabels.Add ("2");
                categoryAxisRight.ActualLabels.Add ("3");
                categoryAxisRight.ActualLabels.Add ("4");
                categoryAxisRight.ActualLabels.Add ("5");
                categoryAxisRight.ActualLabels.Add ("6");
                categoryAxisRight.ActualLabels.Add ("7");
                categoryAxisRight.ActualLabels.Add ("8");
                categoryAxisRight.StringFormat = "0";
                categoryAxisRight.IsPanEnabled = false;
                categoryAxisRight.IsZoomEnabled = false;
                categoryAxisRight.FontSize = dFontSize;
                categoryAxisRight.Title = Resources.GetString (Resource.String.Mood);
                tempRight.Axes.Add (categoryAxisRight);

                var linearAxisRight = new OxyPlot.Axes.LinearAxis ();
                linearAxisRight.AbsoluteMinimum = 0;
                linearAxisRight.AbsoluteMaximum = histArrayRight.Max () * 1.2; //this has to be a bit higher than the highest frequency of the histogram
                linearAxisRight.Minimum = 0;
                linearAxisRight.Maximum = histArrayRight.Max () * 1.2;
                linearAxisRight.Position = OxyPlot.Axes.AxisPosition.Left;
                linearAxisRight.FontSize = dFontSize;
                linearAxisRight.IsZoomEnabled = false;
                linearAxisRight.StringFormat = "0.0";
                linearAxisRight.Title = Resources.GetString (Resource.String.Frequency);
                tempRight.Axes.Add (linearAxisRight);

                var columnSeriesRight = new ColumnSeries ();
                //http://forums.xamarin.com/discussion/20809/is-there-no-plotview-which-is-in-oxyplot-compent-in-xamarin-android
                //add data
                foreach (int i in histArrayRight) {
                    columnSeriesRight.Items.Add (new ColumnItem (i, -1));
                }
                columnSeriesRight.LabelFormatString = "{0}";
                columnSeriesRight.FontSize = dFontSize;
                tempRight.Series.Add (columnSeriesRight);

                tempRight.Title = Resources.GetString (Resource.String.WithPeople);
                tempRight.TitleFontSize = dFontSize;
                MyModelRight = tempRight;

                plotViewModelRight.Model = MyModelRight;
            }
        }
        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
                }
            };
        }
        public WeatherObservationPage()
        {
            var weatherSeries = new LineSeries();

            var m = new PlotModel("Weather");

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

            magnitudeAxis.Minimum = 0;
            magnitudeAxis.Maximum = 40;
            magnitudeAxis.Title   = "Temperature";
            m.Axes.Add(magnitudeAxis);

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

            dateAxis.Labels.Add("Station");
            m.Axes.Add(dateAxis);

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

            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 Weather Data"
            };

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

                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => {
                    Debug.WriteLine("found " + we.Length + " weather observations");
                    l.Text = we.Length + " weather observations";

                    var eqlist = new List <WeatherObservation>(we);
//					eqlist.Sort((x, y) => string.Compare(x.datetime, y.datetime));


                    var columSeries = new ColumnSeries();


                    foreach (var eq in eqlist)
                    {
                        double t = 0.0;
                        Double.TryParse(eq.temperature, out t);
                        columSeries.Items.Add(new ColumnItem(t, 0));
                        //pts.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Parse(eq.datetime)), Double.Parse(eq.temperature)));
                    }
                    opv.Model.Series.Clear();
                    opv.Model.Series.Add(columSeries);

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


            Padding = new Thickness(0, 20, 0, 0);
            Content = new StackLayout {
                Children =
                {
                    opv,
                    b,
                    l
                }
            };
        }