Beispiel #1
0
        public static PlotModel TornadoDiagram1()
        {
            // http://en.wikipedia.org/wiki/Tornado_diagram
            var model = new PlotModel {
                Title = "Tornado diagram 1", LegendPlacement = LegendPlacement.Outside
            };

            var s1 = new BarSeries
            {
                Title           = "High",
                IsStacked       = true,
                FillColor       = OxyColor.FromRgb(216, 82, 85),
                BaseValue       = 7,
                StrokeColor     = OxyColors.Black,
                StrokeThickness = 1
            };

            s1.Items.Add(new BarItem(1));
            s1.Items.Add(new BarItem(1));
            s1.Items.Add(new BarItem(4));
            s1.Items.Add(new BarItem(5));

            var s2 = new BarSeries
            {
                Title           = "Low",
                IsStacked       = true,
                FillColor       = OxyColor.FromRgb(84, 138, 209),
                BaseValue       = 7,
                StrokeColor     = OxyColors.Black,
                StrokeThickness = 1
            };

            s2.Items.Add(new BarItem(-1));
            s2.Items.Add(new BarItem(-3));
            s2.Items.Add(new BarItem(-2));
            s2.Items.Add(new BarItem(-3));

            var categoryAxis = new CategoryAxis {
                Position = AxisPosition.Left
            };

            categoryAxis.Labels.Add("F/X rate");
            categoryAxis.Labels.Add("Inflation");
            categoryAxis.Labels.Add("Price");
            categoryAxis.Labels.Add("Conversion");
            var valueAxis = new LinearAxis {
                Position = AxisPosition.Bottom, ExtraGridlines = new[] { 7.0 }
            };

            model.Series.Add(s1);
            model.Series.Add(s2);
            model.Axes.Add(categoryAxis);
            model.Axes.Add(valueAxis);
            return(model);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        public TremorDetectionWindow()
        {
            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.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
        }
Beispiel #3
0
        public ViewModelPlot(Func <double, double, double> xt, Func <double, double, double> yt, double gridSpan, int steps, int chunks, int arrows, double arrowSize, bool fromcenter)
        {
            PlotModel = new PlotModel
            {
                PlotAreaBorderColor = OxyColor.FromRgb(230, 230, 230),
            };
            _xt        = xt;
            _yt        = yt;
            _arrowSize = arrowSize;
            _chunks    = chunks;
            _arrows    = arrows;
            _gridSpan  = gridSpan;

            axisY = new LinearAxis
            {
                MajorGridlineStyle     = LineStyle.Solid,
                MajorGridlineThickness = 0.5,
                MinorGridlineStyle     = LineStyle.Dot,
                MinorGridlineColor     = OxyColor.FromRgb(240, 240, 240),
                MinimumPadding         = 0.05,
                MaximumPadding         = 0.05,
                Position = AxisPosition.Left,
                Title    = "y",
            };
            axisX = new LinearAxis
            {
                MajorGridlineStyle     = LineStyle.Solid,
                MajorGridlineThickness = 0.5,
                MinorGridlineStyle     = LineStyle.Dot,
                MinorGridlineColor     = OxyColor.FromRgb(240, 240, 240),
                MinimumPadding         = 0.05,
                MaximumPadding         = 0.05,
                Position = AxisPosition.Bottom,
                Title    = "x"
            };

            PlotModel.Axes.Add(axisX);
            PlotModel.Axes.Add(axisY);

            PlotModel.MouseDown += (s, e) =>
            {
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    var y = axisY.InverseTransform(e.Position.Y);
                    var x = axisX.InverseTransform(e.Position.X);

                    DrawLines(x, x, y, y);

                    PlotModel.RefreshPlot(false);
                    e.Handled = true;
                }
            };

            MakePlot(steps, fromcenter);
        }
        public OxyForm_ResultsView(JSModel model, string title)
        {
            InitializeComponent();

            //this.plotView1.Size = this.ClientSize;
            this.SizeChanged += Form1_SizeChanged;

            Model = new PlotModel {
                Title = title
            };
            JointModel = model;

            foreach (var bar in JointModel.Bars)
            {
                var series = new LineSeries();
                series.Points.Add(bar.StartPosition.ToDataPoint());
                series.Points.Add(bar.EndPosition.ToDataPoint());
                series.Title = $"Bar {bar.Number}: F={bar.ForceResult.ToString("F2")}";
                Model.Series.Add(series);

                var text = new TextAnnotation();
                text.TextPosition            = bar.MidPoint.ToDataPoint();
                text.TextVerticalAlignment   = OxyPlot.VerticalAlignment.Middle;
                text.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Center;
                text.Text       = bar.ForceResult.ToString("F2");
                text.Background = OxyColor.FromRgb(255, 255, 255);
                Model.Annotations.Add(text);
            }

            foreach (var node in JointModel.Nodes)
            {
                var text = new TextAnnotation();
                text.TextPosition            = node.Position.ToDataPoint();
                text.TextVerticalAlignment   = OxyPlot.VerticalAlignment.Top;
                text.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Left;

                var textString = $"Node {node.Number}\n";
                if (node.AppliedForces != Vector2d.Zero)
                {
                    textString += "F=" + node.AppliedForces + "\n";
                }
                if (node.ReactionResult != Vector2d.Zero)
                {
                    textString += "R=" + node.ReactionResult;
                }
                text.Text = textString;

                text.StrokeThickness = 0;
                Model.Annotations.Add(text);
            }


            this.plotView1.Model = Model;
        }
Beispiel #5
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value.GetType() != typeof(Color))
            {
                return(OxyColors.Black);
            }

            var color = (Color)value;

            return(OxyColor.FromRgb(color.R, color.G, color.B));
        }
        private Dictionary <int, OxyColor> GenerateColors(int N)
        {
            Random random = new Random();
            Dictionary <int, OxyColor> colors = new Dictionary <int, OxyColor>();

            for (var i = 0; i < N; i++)
            {
                colors.Add(i, OxyColor.FromRgb((byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255)));
            }
            return(colors);
        }
Beispiel #7
0
        /// Method Name     : ChartInvoiced
        /// Author          : Sanket Prajapati
        /// Creation Date   : 23 Jan 2018
        /// Purpose         : Use for binding chart status Invoiced
        /// Revision        :
        /// </summary>
        //4 InTransit
        public void ChartTransit(PieSeries seriesP1, PieSeries seriesP2)
        {
            //outer
            seriesP1.Slices.Add(new PieSlice("", 100)
            {
                Fill = OxyColor.FromRgb(236, 61, 98)
            });
            seriesP1.Slices.Add(new PieSlice("", 100)
            {
                Fill = OxyColor.FromRgb(50, 212, 212)
            });
            seriesP1.Slices.Add(new PieSlice("", 100)
            {
                Fill = OxyColor.FromRgb(22, 51, 99)
            });
            seriesP1.Slices.Add(new PieSlice("", 60)
            {
                Fill = OxyColor.FromRgb(242, 130, 116)
            });
            seriesP1.Slices.Add(new PieSlice("", 40)
            {
                Fill = OxyColor.FromRgb(248, 221, 211)
            });
            seriesP1.Slices.Add(new PieSlice("", 100)
            {
                Fill = OxyColor.FromRgb(225, 249, 255)
            });

            //inner
            seriesP2.Slices.Add(new PieSlice("", 100)
            {
                IsExploded = false, Fill = OxyColor.FromRgb(232, 144, 165)
            });
            seriesP2.Slices.Add(new PieSlice("", 100)
            {
                IsExploded = false, Fill = OxyColor.FromRgb(138, 219, 222)
            });
            seriesP2.Slices.Add(new PieSlice("", 100)
            {
                IsExploded = false, Fill = OxyColor.FromRgb(124, 139, 166)
            });
            seriesP2.Slices.Add(new PieSlice("", 60)
            {
                IsExploded = false, Fill = OxyColor.FromRgb(252, 238, 233)
            });
            seriesP2.Slices.Add(new PieSlice("", 40)
            {
                IsExploded = false, Fill = OxyColor.FromRgb(227, 227, 233)
            });
            seriesP2.Slices.Add(new PieSlice("", 100)
            {
                IsExploded = true, Fill = OxyColor.FromRgb(227, 227, 233)
            });
        }
Beispiel #8
0
        private OxyPlot.Series.Series CreateDvhSeries(Structure structure, DVHData dvh)
        {
            var series = new OxyPlot.Series.LineSeries {
                Tag = structure.Id, Title = structure.Id, Color = OxyColor.FromRgb(structure.Color.R, structure.Color.G, structure.Color.B)
            };
            var points = dvh.CurveData.Select(CreateDataPoint);

            series.Points.AddRange(points);
            series.TrackerFormatString = "{0} " + Environment.NewLine + "{1}: {2:0.000} " + Environment.NewLine + "{3}: {4:0.0} ";
            return(series);
        }
        public static unsafe void DrawScatterSeries1(IntPtr pointer, List <Point2> data, MarkerType mkty, double mksize, byte r, byte g, byte b)
        {
            GCHandle handle = GCHandle.FromIntPtr(pointer);

            if (handle.IsAllocated)
            {
                PlotModel model = handle.Target as PlotModel;
                if (model != null)
                {
                    List <double> ydata = new List <double>();
                    List <double> xdata = new List <double>();
                    for (int i = 0; i < data.Count; i++)
                    {
                        xdata.Add((double)data[i].X);
                        ydata.Add((double)data[i].Y);
                    }

                    List <double> txdata = new List <double>();
                    List <double> tydata = new List <double>();

                    txdata.Add(xdata[0]);
                    tydata.Add(ydata[0]);

                    for (int i = 1; i < data.Count; i++)
                    {
                        if (xdata[i] - xdata[i - 1] > 1.5)
                        {
                            if (txdata.Count > 0)
                            {
                                model.AddLineSeries(txdata, tydata, OxyColor.FromRgb(r, g, b), LineStyle.Dash);
                                txdata.Clear();
                                tydata.Clear();
                            }
                            txdata.Add(xdata[i]);
                            tydata.Add(ydata[i]);
                        }
                        else
                        {
                            txdata.Add(xdata[i]);
                            tydata.Add(ydata[i]);
                        }
                    }

                    if (txdata.Count > 0)
                    {
                        model.AddLineSeries(txdata, tydata, OxyColor.FromRgb(r, g, b), LineStyle.Dash);
                        txdata.Clear();
                        tydata.Clear();
                    }

                    model.AddScatterSeries(xdata, ydata, OxyColor.FromRgb(r, g, b), mkty, mksize);
                }
            }
        }
Beispiel #10
0
        public void Interpolate()
        {
            var palette = OxyPalette.Interpolate(5, OxyColors.Blue, OxyColors.White, OxyColors.Red);

            Assert.AreEqual(5, palette.Colors.Count);
            Assert.AreEqual(OxyColors.Blue, palette.Colors[0]);
            Assert.AreEqual(OxyColor.FromRgb(127, 127, 255), palette.Colors[1]);
            Assert.AreEqual(OxyColors.White, palette.Colors[2]);
            Assert.AreEqual(OxyColor.FromRgb(255, 127, 127), palette.Colors[3]);
            Assert.AreEqual(OxyColors.Red, palette.Colors[4]);
        }
Beispiel #11
0
        /// Method Name     : ChartPacked
        /// Author          : Sanket Prajapati
        /// Creation Date   : 23 Jan 2018
        /// Purpose         : Use for binding chart status Packed
        /// Revision        :
        /// </summary>
        //2 Packed
        public void ChartPacked(PieSeries seriesP1, PieSeries seriesP2)
        {
            //outer
            seriesP1.Slices.Add(new PieSlice("", 100)
            {
                Fill = OxyColor.FromRgb(236, 61, 98)
            });
            seriesP1.Slices.Add(new PieSlice("", 60)
            {
                Fill = OxyColor.FromRgb(50, 212, 212)
            });
            seriesP1.Slices.Add(new PieSlice("", 40)
            {
                Fill = OxyColor.FromRgb(138, 219, 222)
            });
            seriesP1.Slices.Add(new PieSlice("", 100)
            {
                Fill = OxyColor.FromRgb(202, 206, 221)
            });
            seriesP1.Slices.Add(new PieSlice("", 100)
            {
                Fill = OxyColor.FromRgb(252, 238, 233)
            });
            seriesP1.Slices.Add(new PieSlice("", 100)
            {
                Fill = OxyColor.FromRgb(225, 249, 255)
            });

            //inner
            seriesP2.Slices.Add(new PieSlice("", 100)
            {
                IsExploded = false, Fill = OxyColor.FromRgb(232, 144, 165)
            });
            seriesP2.Slices.Add(new PieSlice("", 60)
            {
                IsExploded = false, Fill = OxyColor.FromRgb(201, 225, 233)
            });
            seriesP2.Slices.Add(new PieSlice("", 40)
            {
                IsExploded = false, Fill = OxyColor.FromRgb(227, 227, 233)
            });
            seriesP2.Slices.Add(new PieSlice("", 100)
            {
                IsExploded = false, Fill = OxyColor.FromRgb(227, 227, 233)
            });
            seriesP2.Slices.Add(new PieSlice("", 100)
            {
                IsExploded = true, Fill = OxyColor.FromRgb(227, 227, 233)
            });
            seriesP2.Slices.Add(new PieSlice("", 100)
            {
                IsExploded = true, Fill = OxyColor.FromRgb(227, 227, 233)
            });
        }
Beispiel #12
0
 /// Forces r, g or b to be bright enough for darkmode
 public static OxyColor StringToColour(string name)
 {
     if (name.Contains("Heartbeat"))
     {
         return(OxyColor.FromRgb(238, 38, 59));
     }
     else
     {
         return(OxyColor.FromRgb(117, 64, 191));
     }
 }
Beispiel #13
0
        private BarItem CreateBarItem(int i)
        {
            var value = _random.NextDouble();
            var r     = (byte)_random.Next(0, 255);
            var g     = (byte)_random.Next(0, 255);
            var b     = (byte)_random.Next(0, 255);

            return(new BarItem(value, i)
            {
                Color = OxyColor.FromRgb(r, g, b)
            });
        }
Beispiel #14
0
        private void Setup()
        {
            var readings  = _config.MeterReadings;
            var plotModel = new PlotModel
            {
                Title = "Seneste forbrug",
                TitleHorizontalAlignment = TitleHorizontalAlignment.CenteredWithinView,
                PlotAreaBorderColor      = OxyColors.Transparent
            };

            //TODO Hardcoded color, since impossible to get the correct color from Resource Dictionary ¯\_(ツ)_/¯
            var green = OxyColor.FromRgb(51, 134, 113);

            var series = new ColumnSeries
            {
                StrokeThickness = 1.0
            };

            var dates = new List <string>();

            for (int i = readings.Count - 5; i < readings.Count; i++)
            {
                var r             = readings.ElementAt(i);
                var parsedReading = double.Parse(r.Consumption, new CultureInfo("da"));
                series.Items.Add(new ColumnItem {
                    Value = parsedReading, Color = green
                });
                dates.Add(FormatDate(r.ReadingDate));
            }

            plotModel.Axes.Add(new LinearAxis
            {
                Position      = AxisPosition.Left,
                IsPanEnabled  = false,
                IsZoomEnabled = false,
                Title         = "Forbrug (m\u00b3)",
                AxislineStyle = LineStyle.Solid
            });

            plotModel.Axes.Add(new CategoryAxis
            {
                Position      = AxisPosition.Bottom,
                IsPanEnabled  = false,
                IsZoomEnabled = false,
                Title         = "Dato",
                AxislineStyle = LineStyle.Solid,
                ItemsSource   = dates
            });

            plotModel.Series.Add(series);

            GraphData = plotModel;
        }
        public ScatterSeries GetNegativePointsSeriers()
        {
            var clusterPoints = new ScatterSeries {
                MarkerFill = OxyColor.Interpolate(Color, OxyColor.FromRgb(0, 0, 0), 0.5)
            };

            clusterPoints.Points.AddRange(
                Solution.Cluster.Points.Where(p => !p.Label).Select(
                    p => new ScatterPoint(p[XIndex], p[YIndex], 2)));

            return(clusterPoints);
        }
Beispiel #16
0
        public void pieChartSetting()
        {
            //People
            modelLineChart = new PlotModel {
                Title = "Car"
            };
            dynamic seriesP1 = new PieSeries {
                StrokeThickness = 2.0, InsideLabelPosition = 0.8, AngleSpan = 360, StartAngle = 0
            };

            String[] colorNames = { "Orange", "Yellow", "YelloGreen", "Green", "Cyan", "Blue", "Purple", "Red" };
            double[] Hue        = { 1.0, 3.0, 5.0, 8.0, 12.0, 15.0, 18.0, 22.0 };
            for (int i = 0; i < Hue.Length; i++)
            {
                seriesP1.Slices.Add(new PieSlice(colorNames[i], colorRatioCar[i])
                {
                    IsExploded = false, Fill = OxyColor.FromHsv(Hue[i] / 24, 0.7, 0.9)
                });
            }
            seriesP1.Slices.Add(new PieSlice("White", colorRatioCar[8])
            {
                IsExploded = false, Fill = OxyColors.Ivory
            });
            seriesP1.Slices.Add(new PieSlice("Black", colorRatioCar[9])
            {
                IsExploded = false, Fill = OxyColor.FromRgb(80, 80, 80)
            });
            modelLineChart.Series.Add(seriesP1);
            //Car
            modelPieChartPeople = new PlotModel {
                Title = "People"
            };
            dynamic seriesP2 = new PieSeries {
                StrokeThickness = 2.0, InsideLabelPosition = 0.8, AngleSpan = 360, StartAngle = 0
            };

            for (int i = 0; i < Hue.Length; i++)
            {
                seriesP2.Slices.Add(new PieSlice(colorNames[i], colorRatioPeople[i])
                {
                    IsExploded = false, Fill = OxyColor.FromHsv(Hue[i] / 24, 0.7, 0.9)
                });
            }
            seriesP2.Slices.Add(new PieSlice("White", colorRatioPeople[8])
            {
                IsExploded = false, Fill = OxyColors.Ivory
            });
            seriesP2.Slices.Add(new PieSlice("Black", colorRatioPeople[9])
            {
                IsExploded = false, Fill = OxyColor.FromRgb(80, 80, 80)
            });
            modelPieChartPeople.Series.Add(seriesP2);
        }
Beispiel #17
0
        private PlotModel CreateLinePlot()
        {
            var plotModel = new PlotModel {
                Title = "Line Plot"
            };

            plotModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom
            });
            plotModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Maximum = 20, Minimum = 0
            });

            var series1 = new LineSeries
            {
                MarkerType        = MarkerType.Circle,
                MarkerSize        = 4,
                MarkerStroke      = OxyColors.White,
                Color             = OxyColor.FromRgb(0, 255, 0),
                LineStyle         = LineStyle.DashDashDot,
                LabelFormatString = "{0:.00}"
            };

            series1.Points.Add(new DataPoint(0.0, 6.0));
            series1.Points.Add(new DataPoint(1.4, 2.1));
            series1.Points.Add(new DataPoint(2.0, 4.2));
            series1.Points.Add(new DataPoint(3.3, 2.3));
            series1.Points.Add(new DataPoint(4.7, 7.4));
            series1.Points.Add(new DataPoint(6.0, 6.2));
            series1.Points.Add(new DataPoint(8.9, 8.9));
            plotModel.Series.Add(series1);

            var series2 = new LineSeries
            {
                MarkerType   = MarkerType.Circle,
                MarkerSize   = 4,
                MarkerStroke = OxyColors.White,
                Color        = OxyColor.FromRgb(255, 0, 0),
                LineStyle    = LineStyle.Dash
            };

            series2.Points.Add(new DataPoint(0.0, 8.0));
            series2.Points.Add(new DataPoint(1, 7.1));
            series2.Points.Add(new DataPoint(2, 8.2));
            series2.Points.Add(new DataPoint(3, 9.3));
            series2.Points.Add(new DataPoint(4, 12.4));
            series2.Points.Add(new DataPoint(5, 6.2));
            series2.Points.Add(new DataPoint(9.5, 1.9));

            plotModel.Series.Add(series2);

            return(plotModel);
        }
Beispiel #18
0
        /// <summary>
        /// Create-method which handles all the logic to create a specific linechart.
        /// </summary>
        /// <returns>
        /// Plotmodel, containing the lineseries. Ready for use.
        /// </returns>

        public PlotModel GetProcessedData()
        {
            LineSeries lineSerie = new LineSeries()
            {
                DataFieldX = "Date",
                DataFieldY = "Amount",
                LineStyle  = LineStyle.Solid,
                Color      = OxyColor.FromRgb(255, 0, 0)
            };

            PlotModel model = new PlotModel()
            {
                Title = "Thefts per month"
            };

            // Defining the X-Axis as a DateTimeAxis.
            DateTimeAxis date_Axis = new DateTimeAxis()
            {
                StringFormat       = "MM/yyyy",
                Position           = AxisPosition.Bottom,
                IntervalLength     = 75,
                MinorIntervalType  = DateTimeIntervalType.Months,
                IntervalType       = DateTimeIntervalType.Months,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.None,
                IsPanEnabled       = false,
                IsZoomEnabled      = false
            };

            // Defining the Y-Axis.
            LinearAxis YAxis = new LinearAxis()
            {
                IsPanEnabled      = false,
                IsZoomEnabled     = false,
                AxislineThickness = 5
            };

            lineSerie.Smooth = true;
            AdaptedList <Month> Months = this.SortDateTimesByMonth();

            // Assigning datapoints to the lineseries.
            foreach (Month month in Months)
            {
                lineSerie.Points.Add(new DataPoint(DateTimeAxis.ToDouble(month.ThisMonth), month.EventsThisMonth));
            }

            // Adding axes to the plotmodel.
            model.Axes.Add(date_Axis);
            model.Axes.Add(YAxis);
            model.Series.Add(lineSerie);
            this.OnDataCompleted();
            return(model);
        }
Beispiel #19
0
        protected override void OnNextStepClicked()
        {
            NumberOfSteps++;
            var reproduceItems = ReproductionHelper.ReproduceReal(Function, RealItems);
            var newItems       =
                CrossingoverHelper.MakeRealCrossingover(reproduceItems, SolutionAccuracy, CrossingoverPossibility);

            MutationHelper.MutateReal(newItems, NumberOfSteps, MaxSteps, MutationPossibility);
            RealItems = newItems;

            var minItem = RealItems.Aggregate((i, j) =>
                                              Function(i.X1, i.X2) < Function(j.X1, j.X2)
                    ? i
                    : j);

            ItemValue = $"x1: {minItem.X1}\nx2: {minItem.X2}";
            var functionValue = Function(minItem.X1, minItem.X2);

            MaxItemValueFunction = functionValue.ToString();

            // ------------------------------------------------------

            for (var i = ChartModel.Series.Count - 1; i > 0; i--)
            {
                ChartModel.Series.RemoveAt(i);
            }

            var solutions = new ScatterSeries
            {
                MarkerType = MarkerType.Circle,
                MarkerFill = OxyColor.FromRgb(0, 0, 0xFF)
            };

            foreach (var p in RealItems)
            {
                var plotPoint = new ScatterPoint(p.X1, p.X2, 5);
                solutions.Points.Add(plotPoint);
            }

            ChartModel.Series.Add(solutions);

            var minValueSeries = new ScatterSeries
            {
                MarkerType = MarkerType.Circle,
                MarkerFill = OxyColor.FromRgb(0xFF, 0, 0)
            };

            minValueSeries.Points.Add(new ScatterPoint(minItem.X1, minItem.X2, 7, functionValue));
            ChartModel.Series.Add(minValueSeries);

            ChartModel.InvalidatePlot(true);
        }
        /// <summary>
        ///     Set a custom CashFlowModel with the set Start and Enddate
        /// </summary>
        public PlotModel GetCashFlowModel()
        {
            var cashFlow = cashFlowDataProvider.GetValues(StartDate, EndDate);

            var model = new PlotModel();

            var columnSeries = new ColumnSeries();
            var axe          = new CategoryAxis {
                AxislineColor = OxyColors.Black,
                TextColor     = OxyColors.Black,
                IsPanEnabled  = false,
                IsZoomEnabled = false,
                Angle         = 45
            };

            if (SettingsHelper.IsDarkThemeSelected)
            {
                axe.AxislineColor = OxyColors.White;
                axe.AxislineColor = OxyColors.White;

                model.Background = OxyColors.Black;
                model.TextColor  = OxyColors.White;
            }
            else
            {
                axe.AxislineColor = OxyColors.Black;
                axe.AxislineColor = OxyColors.Black;

                model.Background = OxyColors.White;
                model.TextColor  = OxyColors.Black;
            }

            columnSeries.Items.Add(new ColumnItem(cashFlow.Income.Value)
            {
                Color = OxyColors.LightGreen
            });
            axe.Labels.Add(cashFlow.Income.Label);
            columnSeries.Items.Add(new ColumnItem(cashFlow.Spending.Value)
            {
                Color = OxyColor.FromRgb(196, 54, 51)
            });
            axe.Labels.Add(cashFlow.Spending.Label);
            columnSeries.Items.Add(new ColumnItem(cashFlow.Revenue.Value)
            {
                Color = OxyColors.Cyan
            });
            axe.Labels.Add(cashFlow.Revenue.Label);

            model.Axes.Add(axe);
            model.Series.Add(columnSeries);
            return(model);
        }
Beispiel #21
0
        private void AssignColorValue()
        {
            switch (selectedColorTarget)
            {
            case ColorTarget.Line: Settings.PlotVisualParams.LineColor = OxyColor.FromRgb(R, G, B); break;

            case ColorTarget.Vector: Settings.PlotVisualParams.ArrowColor = OxyColor.FromRgb(R, G, B); break;

            case ColorTarget.BorderFill: Settings.PlotVisualParams.BorderFillColor = OxyColor.FromRgb(R, G, B); break;

            case ColorTarget.BorderStroke: Settings.PlotVisualParams.BorderStrokeColor = OxyColor.FromRgb(R, G, B); break;
            }
        }
        public static unsafe void AddLineMarkerXAt(IntPtr pointer, double x, double y, double miny, double maxy, double yoffset, byte r, byte g, byte b)
        {
            GCHandle handle = GCHandle.FromIntPtr(pointer);

            if (handle.IsAllocated)
            {
                PlotModel model = handle.Target as PlotModel;
                if (model != null)
                {
                    model.AddLineMarkerXAt(x, y, miny, maxy, yoffset, OxyColor.FromRgb(r, g, b));
                }
            }
        }
Beispiel #23
0
        private void displayData()
        {
            PlotModel     model = new PlotModel();
            ScatterSeries serie = new ScatterSeries();

            foreach (Node i in data)
            {
                serie.Points.Add(new ScatterPoint(i.xCoord, i.yCoord));
            }
            serie.MarkerFill = OxyColor.FromRgb(255, 0, 0);
            model.Series.Add(serie);
            plotView1.Model = model;
        }
        public static unsafe void AddLineAtX1(IntPtr pointer, double x, double thick, LineStyle sty, byte r, byte g, byte b)
        {
            GCHandle handle = GCHandle.FromIntPtr(pointer);

            if (handle.IsAllocated)
            {
                PlotModel model = handle.Target as PlotModel;
                if (model != null)
                {
                    model.AddLineAtX1(x, OxyColor.FromRgb(r, g, b), sty, thick);
                }
            }
        }
Beispiel #25
0
        //Grafování rozložení x,y
        public void AddToGraph(List <double> x, List <double> y, int ClusterNum, byte r, byte g, byte b)
        {
            var scatterSeries = new ScatterSeries {
                MarkerType = MarkerType.Cross, MarkerStroke = OxyColor.FromRgb(r, g, b)
            };

            for (int i = 0; i < x.Count; i++)
            {
                scatterSeries.Points.Add(new ScatterPoint(x[i], y[i]));
            }

            graf.Series.Add(scatterSeries);
        }
        private static void AddProducedAmountToPlot(CapacitatedLotsizingModel clspModel, PlotModel oxyPlot)
        {
            var currentProduction = clspModel.PeriodInformation.Select(pi => new ColumnItem(clspModel.x[pi].Value)).ToList();

            var productionSeries = new ColumnSeries()
            {
                Title     = "Current Production",
                FillColor = OxyColor.FromRgb(byte.Parse("165"), byte.Parse("185"), byte.Parse("79"))
            };

            productionSeries.Items.AddRange(currentProduction);
            oxyPlot.Series.Add(productionSeries);
        }
        private static void AddRemainStorageToPlot(CapacitatedLotsizingModel clspModel, PlotModel oxyPlot)
        {
            var dataPoints = clspModel.PeriodInformation.Select(pi => new ColumnItem(clspModel.s[pi].Value)).ToList();

            var series = new ColumnSeries()
            {
                Title     = "Remaining Inventory",
                FillColor = OxyColor.FromRgb(byte.Parse("82"), byte.Parse("35"), byte.Parse("152"))
            };

            series.Items.AddRange(dataPoints);
            oxyPlot.Series.Add(series);
        }
Beispiel #28
0
        public static PlotModel CreateModel(List <Line_StationAlarm_Model> list, string subtitle, string type)
        {
            List <IGrouping <string, Line_StationAlarm_Model> > group1;

            switch (type)
            {
            case "Type":
                group1 = list.GroupBy(n => n.Type.Trim()).ToList();
                break;

            case "Station":
                group1 = list.GroupBy(n => n.Station.Trim()).ToList();
                break;

            case "Describtion":
                group1 = list.GroupBy(n => n.Describtion.Trim()).ToList();
                break;

            default:
                group1 = null;
                break;
            }
            var model = new PlotModel
            {
                Title        = "Alarm ratio analysis",
                TitleFont    = "微软雅黑",
                Subtitle     = subtitle,
                TitlePadding = 30,
                Padding      = new OxyThickness(0, 0, 0, 10)
            };

            model.DefaultColors[0] = OxyColor.FromRgb(31, 120, 180);
            model.DefaultColors[3] = OxyColor.FromRgb(51, 160, 44);
            var ps = new PieSeries
            {
                StrokeThickness     = 2.0,
                InsideLabelPosition = 0.8,
                AngleSpan           = 360,
                StartAngle          = 0
            };

            foreach (var item in group1)
            {
                ps.Slices.Add(new PieSlice(item.Key, item.Count())
                {
                    IsExploded = true
                });
            }
            model.Series.Add(ps);
            return(model);
        }
Beispiel #29
0
        void Setup(View itemView)
        {
            CurrencyPairLabel        = itemView.FindViewById <TextView>(Resource.Id.SpotTileCurrencyPairTextView);
            BidButton                = itemView.FindViewById <PriceButton>(Resource.Id.SpotTileBidPriceButton);
            AskButton                = itemView.FindViewById <PriceButton>(Resource.Id.SpotTileAskPriceButton);
            SpreadLabel              = itemView.FindViewById <TextView>(Resource.Id.SpotTileSpreadTextView);
            UpArrow                  = itemView.FindViewById <DirectionArrow>(Resource.Id.SpotTileUpArrow);
            DownArrow                = itemView.FindViewById <DirectionArrow>(Resource.Id.SpotTileDownArrow);
            DealtCurrencyLabel       = itemView.FindViewById <TextView>(Resource.Id.SpotTileDealtCurrencyTextView);
            NotionalTextBox          = itemView.FindViewById <EditText>(Resource.Id.SpotTileNotionalEditText);
            SpotDateLabel            = itemView.FindViewById <TextView>(Resource.Id.SpotTileSpotDateTextView);
            Content                  = itemView.FindViewById <LinearLayout>(Resource.Id.SpotTileContent);
            CardView                 = itemView.FindViewById <CardView>(Resource.Id.CardView);
            ViewAnimator             = itemView.FindViewById <ViewAnimator>(Resource.Id.ViewAnimator);
            PlotView                 = itemView.FindViewById <PlotView>(Resource.Id.plotView);
            PriceNotAvailableOverlay = itemView.FindViewById <LinearLayout>(Resource.Id.PriceNotAvailableOverlay);

            CardView.PreventCornerOverlap = false;
            CardView.Radius = 5;
            NotionalTextBox.EditorAction += (sender, args) =>
            {
                if (args.ActionId == ImeAction.Done)
                {
                    NotionalTextBox.ClearFocus();
                    HideKeyboard(NotionalTextBox);
                }
            };

            _plotModel = new PlotModel
            {
                PlotAreaBorderThickness = new OxyThickness(0),
                PlotAreaBorderColor     = OxyColor.FromRgb(46, 59, 75)
            };
            _plotModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, IsAxisVisible = false, MaximumPadding = 0, MinimumPadding = 0, IsPanEnabled = false, IsZoomEnabled = false
            });
            _plotModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, IsAxisVisible = false, MaximumPadding = 0, MinimumPadding = 0, IsPanEnabled = false, IsZoomEnabled = false
            });

            _areaSeries = new AreaSeries {
                LineStyle = LineStyle.Solid, Color = OxyColor.FromRgb(46, 59, 75)
            };
            _plotModel.Series.Add(_areaSeries);
            _plotModel.Background               = OxyColor.FromRgb(33, 42, 53);
            PlotView.Model                      = _plotModel;
            PlotView.OverScrollMode             = OverScrollMode.Never;
            PlotView.ScrollBarSize              = 0;
            PlotView.HorizontalScrollBarEnabled = false;
            PlotView.VerticalScrollBarEnabled   = false;
        }
Beispiel #30
0
        //Метод создания гистограммы и добавления данных в неё
        private static void SetParamBriefDiagramm(PlotView pv)
        {
            Axis_X = new CategoryAxis()
            {
                Position           = AxisPosition.Bottom,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot,
                Title         = TitleX,
                AxisDistance  = 5,
                TitleFontSize = 14,
                IsZoomEnabled = false,
                IsPanEnabled  = false
            };

            BriefDiagramm = new ColumnSeries()
            {
                IsStacked = true
            };

            Axis_Y = new LinearAxis()
            {
                Position           = AxisPosition.Left,
                MajorGridlineStyle = LineStyle.Dot,
                Title         = TitleY,
                AxisDistance  = 10,
                IsZoomEnabled = false,
                IsPanEnabled  = false,
                TitleFontSize = 14
            };

            pv.Model = new PlotModel
            {
                Title = Title
            };

            pv.Model.DefaultColors = new List <OxyColor>
            {
                OxyColor.FromRgb(30, 144, 255)
            };

            pv.Model.Axes.Add(Axis_Y);
            pv.Model.Axes.Add(Axis_X);
            pv.Model.Series.Add(BriefDiagramm);

            for (int i = 0; i < dataBriefExports.Count; i++)
            {
                BriefDiagramm.Items.Add(new ColumnItem(dataBriefExports[i].Value));
                Axis_X.Labels.Add(dataBriefExports[i].Name);
            }
            SystemArgs.PrintLog("Создание диаграммы краткого отчета завершено успешно");
        }