Ejemplo n.º 1
0
        private void VolumeCortado(int[] solucao)
        {
            var plotVolumeCortado = new OxyPlot.PlotModel();

            var xAxis = new CategoryAxis
            {
                Key      = "xAxis",
                Position = AxisPosition.Bottom,
                Title    = "Ano",
                Minimum  = -1,
                Maximum  = HeuristicsBase.h + 1
            };

            plotVolumeCortado.Axes.Add(new LinearAxis
            {
                Key            = "yAxis",
                Position       = AxisPosition.Left,
                Title          = "Volume (m³)",
                Minimum        = 0,
                MaximumPadding = 0.1
            });

            var serieVolumeCortado = new OxyPlot.Series.ColumnSeries {
                Title = "Volume cortado", StrokeThickness = 2, FillColor = OxyPlot.OxyColor.FromRgb(180, 180, 180)
            };
            var serieMinVolumeCortado = new OxyPlot.Series.LineSeries {
                Selectable = false, Title = "Mínimo", Color = OxyPlot.OxyColor.FromRgb(0, 0, 0), CanTrackerInterpolatePoints = false
            };
            var serieMaxVolumeCortado = new OxyPlot.Series.LineSeries {
                Title = "Máximo", Color = OxyPlot.OxyColor.FromRgb(0, 0, 0), CanTrackerInterpolatePoints = false
            };

            serieMinVolumeCortado.Points.Add(new OxyPlot.DataPoint(-1000, HeuristicsBase.volMin));
            serieMaxVolumeCortado.Points.Add(new OxyPlot.DataPoint(-1000, HeuristicsBase.volMax));
            serieMinVolumeCortado.Points.Add(new OxyPlot.DataPoint(1000, HeuristicsBase.volMin));
            serieMaxVolumeCortado.Points.Add(new OxyPlot.DataPoint(1000, HeuristicsBase.volMax));

            //Adicionando o volume médio ao gráfico
            xAxis.ActualLabels.Add("Md");
            serieVolumeCortado.Items.Add(new OxyPlot.Series.ColumnItem(HeuristicsBase.volumeMedio));
            serieVolumeCortado.Items[0].Color = OxyPlot.OxyColor.FromRgb(80, 80, 80);

            for (var i = 0; i < HeuristicsBase.h; i++)
            {
                //Adicionando o número do ano no eixo X do gráfico
                xAxis.ActualLabels.Add(i.ToString());
                serieVolumeCortado.Items.Add(new OxyPlot.Series.ColumnItem(solucao.Select((p, idx) => HeuristicsBase.mVolume[idx, p, i]).Sum()));
            }

            plotVolumeCortado.Axes.Add(xAxis);

            plotVolumeCortado.Series.Add(serieVolumeCortado);
            plotVolumeCortado.Series.Add(serieMinVolumeCortado);
            plotVolumeCortado.Series.Add(serieMaxVolumeCortado);

            plot_interface_2.Model = plotVolumeCortado;
        }
Ejemplo n.º 2
0
        private void RefreshPlot()
        {
            PlotModel m = new PlotModel();

            m.Title = Labels.WorldAlianceScore;

            //punktacja
            LinearAxis scoreY = new LinearAxis();

            scoreY.Key                = "score";
            scoreY.Title              = Labels.Score;
            scoreY.Position           = AxisPosition.Left;
            scoreY.MajorGridlineStyle = LineStyle.Solid;
            scoreY.MinorGridlineStyle = LineStyle.Dot;
            m.Axes.Add(scoreY);

            //kontynenty
            var continents = new CategoryAxis();

            continents.GapWidth = 0.1;
            continents.Position = AxisPosition.Bottom;
            continents.Title    = Labels.Continents;

            m.Axes.Add(continents);
            int categoryIx = -1;

            foreach (var aliance in AlianceRankings.GroupBy(x => x.AlianceName))
            {
                OxyPlot.Series.ColumnSeries cs = new OxyPlot.Series.ColumnSeries();
                cs.Title = aliance.Key;

                foreach (var continent in aliance.OrderBy(x => x.Continent))
                {
                    categoryIx = continents.Labels.IndexOf(continent.Continent.ToString());

                    if (categoryIx < 0)
                    {
                        continents.Labels.Add(continent.Continent.ToString());
                        categoryIx = continents.Labels.IndexOf(continent.Continent.ToString());
                    }

                    cs.Items.Add(new OxyPlot.Series.ColumnItem(continent.Score, categoryIx));
                }

                m.Series.Add(cs);
            }

            PlotM = m;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes all files created by the plot class to function.
        /// </summary>
        public void RemovePlot()
        {
            viewerChart  = null;
            columnSeries = null;
            var file = new FileInfo($"mopsdata//plots//{ID}barplot.json");

            file.Delete();
            var dir   = new DirectoryInfo("mopsdata//");
            var files = dir.GetFiles().Where(x => x.Extension.ToLower().Equals($"{ID}plot.pdf"));

            foreach (var f in files)
            {
                f.Delete();
            }
        }
Ejemplo n.º 4
0
        private void FlorestaRegulada(int[] solucao)
        {
            var plotFlorestaRegulada = new OxyPlot.PlotModel();

            plotFlorestaRegulada.Axes.Add(new CategoryAxis
            {
                Key      = "xAxis",
                Position = AxisPosition.Bottom,
                Title    = "Ano",
                Minimum  = -1,
                Maximum  = HeuristicsBase.r + 1
            });

            plotFlorestaRegulada.Axes.Add(new LinearAxis
            {
                Key            = "yAxis",
                Position       = AxisPosition.Left,
                Title          = "Area (ha)",
                Minimum        = 0,
                MaximumPadding = 0.1
            });

            var serieFlorestaRegulada = new OxyPlot.Series.ColumnSeries {
                Title = "Area de corte", StrokeThickness = 2, FillColor = OxyPlot.OxyColor.FromRgb(180, 180, 180)
            };
            var serieMinFlorestaRegulada = new OxyPlot.Series.LineSeries {
                Title = "Mínimo", Color = OxyPlot.OxyColor.FromRgb(0, 0, 0), CanTrackerInterpolatePoints = false
            };
            var serieMaxFlorestaRegulada = new OxyPlot.Series.LineSeries {
                Title = "Máximo", Color = OxyPlot.OxyColor.FromRgb(0, 0, 0), CanTrackerInterpolatePoints = false
            };

            serieMinFlorestaRegulada.Points.Add(new OxyPlot.DataPoint(-1000, HeuristicsBase.areaPorR_menosAlfaReg));
            serieMaxFlorestaRegulada.Points.Add(new OxyPlot.DataPoint(-1000, HeuristicsBase.areaPorR_maisAlfaReg));
            serieMinFlorestaRegulada.Points.Add(new OxyPlot.DataPoint(1000, HeuristicsBase.areaPorR_menosAlfaReg));
            serieMaxFlorestaRegulada.Points.Add(new OxyPlot.DataPoint(1000, HeuristicsBase.areaPorR_maisAlfaReg));

            for (var i = 0; i < HeuristicsBase.r; i++)
            {
                serieFlorestaRegulada.Items.Add(new OxyPlot.Series.ColumnItem(solucao.Select((p, idx) => HeuristicsBase.mRegArea[idx, p, i]).Sum()));
            }

            plotFlorestaRegulada.Series.Add(serieFlorestaRegulada);
            plotFlorestaRegulada.Series.Add(serieMinFlorestaRegulada);
            plotFlorestaRegulada.Series.Add(serieMaxFlorestaRegulada);

            plot_interface_1.Model = plotFlorestaRegulada;
        }
        private void BarButton_Click(object sender, EventArgs e)
        {
            // generate some random Y data
            int pointCount = 5;

            double[] ys1 = RandomWalk(pointCount);
            double[] ys2 = RandomWalk(pointCount);

            // create a series of bars and populate them with data
            var seriesA = new OxyPlot.Series.ColumnSeries()
            {
                Title           = "Series A",
                StrokeColor     = OxyPlot.OxyColors.Black,
                FillColor       = OxyPlot.OxyColors.Red,
                StrokeThickness = 1
            };

            var seriesB = new OxyPlot.Series.ColumnSeries()
            {
                Title           = "Series B",
                StrokeColor     = OxyPlot.OxyColors.Black,
                FillColor       = OxyPlot.OxyColors.Blue,
                StrokeThickness = 1
            };

            for (int i = 0; i < pointCount; i++)
            {
                seriesA.Items.Add(new OxyPlot.Series.ColumnItem(ys1[i], i));
                seriesB.Items.Add(new OxyPlot.Series.ColumnItem(ys2[i], i));
            }

            // create a model and add the bars into it
            var model = new OxyPlot.PlotModel
            {
                Title = "Bar Graph (Column Series)"
            };

            model.Axes.Add(new OxyPlot.Axes.CategoryAxis());
            model.Series.Add(seriesA);
            model.Series.Add(seriesB);

            // load the model into the user control
            plotView1.Model = model;
        }
Ejemplo n.º 6
0
        private void initPlot()
        {
            viewerChart           = new PlotModel();
            viewerChart.TextColor = OxyColor.FromRgb(175, 175, 175);
            viewerChart.PlotAreaBorderThickness = new OxyThickness(0);

            viewerChart.Axes.Add(new OxyPlot.Axes.CategoryAxis()
            {
                Key           = ID,
                ItemsSource   = Categories.Count > 10 ? Categories.Keys.Select(x => "") : Categories.Keys,
                FontSize      = 24,
                AxislineColor = OxyColor.FromRgb(125, 125, 155),
                TicklineColor = OxyColor.FromRgb(125, 125, 155)
            });

            viewerChart.Axes.Add(new OxyPlot.Axes.LinearAxis
            {
                Position      = OxyPlot.Axes.AxisPosition.Left,
                TicklineColor = OxyColor.FromRgb(125, 125, 155),
                Minimum       = 0,
                FontSize      = 24,
                AxislineStyle = LineStyle.Solid,
                AxislineColor = OxyColor.FromRgb(125, 125, 155)
            });

            viewerChart.LegendFontSize = 24;
            viewerChart.LegendPosition = LegendPosition.BottomCenter;

            columnSeries = new OxyPlot.Series.ColumnSeries()
            {
                ItemsSource       = new List <OxyPlot.Series.ColumnItem>(Categories.Values.Select(x => new OxyPlot.Series.ColumnItem(x))),
                LabelPlacement    = OxyPlot.Series.LabelPlacement.Outside,
                LabelMargin       = 0.1,
                FontSize          = 16,
                LabelFormatString = Categories.Count > 10 ? null : "{0:0.##}",
                FillColor         = OxyColor.FromRgb(190, 192, 187)
            };
            viewerChart.Series.Add(columnSeries);
        }
        private Series ConvertSeries(ChartSeriesViewModel series)
        {
            Series newSeries   = null;
            var    valueSeries = series.GetScaleForProperty(series.ValueMemberPath);
            var    labelSeries = series.GetScaleForProperty(series.LabelMemberPath);


            switch (series.SeriesType)
            {
            case (ChartSeriesType.Column):
            {
                newSeries = new ColumnSeries
                {
                    ValueField  = series.ValueMemberPath,
                    ItemsSource = series.DataSource.Data,
                    FillColor   = valueSeries.Color.ToOxyColor(),
                    StrokeColor = valueSeries.Color.ToOxyColor(),
                    YAxisKey    = valueSeries.Name,
                    XAxisKey    = labelSeries.Name,
                };

                break;
            }

            case (ChartSeriesType.Line):
            {
                newSeries = new LineSeries
                {
                    ItemsSource = series.DataSource.Data,
                    DataFieldX  = series.XMemberPath,
                    DataFieldY  = series.YMemberPath,
                    MarkerType  = MarkerType.Circle,
                    Color       = valueSeries.Color.ToOxyColor(),
                    MarkerFill  = valueSeries.Color.ToOxyColor(),
                    YAxisKey    = valueSeries.Name,
                    XAxisKey    = labelSeries.Name,
                };
                break;
            }

            case (ChartSeriesType.Spline):
            {
                newSeries = new LineSeries
                {
                    ItemsSource = series.DataSource.Data,
                    DataFieldX  = series.XMemberPath,
                    DataFieldY  = series.YMemberPath,
                    MarkerType  = MarkerType.Circle,
                    Color       = valueSeries.Color.ToOxyColor(),
                    MarkerFill  = valueSeries.Color.ToOxyColor(),
                    Smooth      = true,
                    YAxisKey    = valueSeries.Name,
                    XAxisKey    = labelSeries.Name,
                };
                break;
            }

            case (ChartSeriesType.Area):
            {
                newSeries = new AreaSeries
                {
                    ItemsSource = series.DataSource.Data,
                    DataFieldX  = series.XMemberPath,
                    DataFieldY  = series.YMemberPath,
                    Color       = valueSeries.Color.ToOxyColor(),
                    Fill        = valueSeries.Color.ToOxyColor(),
                    MarkerFill  = valueSeries.Color.ToOxyColor(),
                    YAxisKey    = valueSeries.Name,
                    XAxisKey    = labelSeries.Name,
                };
                break;
            }

            case (ChartSeriesType.SplineArea):
            {
                newSeries = new AreaSeries
                {
                    ItemsSource = series.DataSource.Data,
                    DataFieldX  = series.XMemberPath,
                    DataFieldY  = series.YMemberPath,
                    Color       = valueSeries.Color.ToOxyColor(),
                    Fill        = valueSeries.Color.ToOxyColor(),
                    MarkerFill  = valueSeries.Color.ToOxyColor(),
                    Smooth      = true,
                    YAxisKey    = valueSeries.Name,
                    XAxisKey    = labelSeries.Name,
                };
                break;
            }

            case (ChartSeriesType.Bubble):
            {
                newSeries = new ScatterSeries
                {
                    ItemsSource   = series.DataSource.Data,
                    DataFieldX    = series.XMemberPath,
                    DataFieldY    = series.YMemberPath,
                    DataFieldSize = series.RadiusMemberPath,
                    MarkerFill    = valueSeries.Color.ToOxyColor(),
                    MarkerType    = MarkerType.Circle,
                    YAxisKey      = valueSeries.Name,
                    XAxisKey      = labelSeries.Name,
                };
                break;
            }

            case (ChartSeriesType.StepLine):
            {
                newSeries = new StairStepSeries
                {
                    ItemsSource = series.DataSource.Data,
                    DataFieldX  = series.XMemberPath,
                    DataFieldY  = series.YMemberPath,
                    Color       = valueSeries.Color.ToOxyColor(),
                    YAxisKey    = valueSeries.Name,
                    XAxisKey    = labelSeries.Name,
                };
                break;
            }

            default:
            {
                return(null);
            }
            }

            newSeries.Title = series.Name;

            return(newSeries);
        }
Ejemplo n.º 8
0
        private void PlotOffRepBars(PlotModel m)
        {
            if (OffReputations == null)
            {
                return;
            }

            //daty
            if (m_XCatDates == null)
            {
                m_XCatDates          = new CategoryAxis();
                m_XCatDates.Title    = Labels.Date;
                m_XCatDates.Position = AxisPosition.Bottom;
                m_XCatDates.GapWidth = 0.1;
                m.Axes.Add(m_XCatDates);
            }

            long   lastScore  = -1;
            double scoreValue = 0;

            foreach (var empire in OffReputations.OrderBy(x => x.Key.OffReputation))
            {
                lastScore  = -1;
                scoreValue = 0;
                var s = new OxyPlot.Series.ColumnSeries();
                s.FontSize          = 9;
                s.LabelFormatString = "A: " + empire.Key.PlayerName;
                s.Title             = string.Format("A: {0} ({1})", empire.Key.PlayerName, empire.Key.AlianceName);
                s.YAxisKey          = "reputation";
                s.StackGroup        = empire.Key.PlayerName;
                s.IsStacked         = true;
                s.LabelPlacement    = OxyPlot.Series.LabelPlacement.Inside;
                int categoryIx = -1;

                foreach (var hr in empire.Value.OrderBy(x => x.CreateDT.Value))
                {
                    if (DiffDefReputation)
                    {
                        if (lastScore < 0)
                        {
                            //pierwszy wynik, zaczynam od zera
                            lastScore  = hr.Score;
                            scoreValue = 0;
                        }
                        else
                        {
                            scoreValue = hr.Score - lastScore;
                            lastScore  = hr.Score;
                        }
                    }
                    else
                    {
                        scoreValue = hr.Score;
                    }

                    if (scoreValue == 0)
                    {
                        continue;
                    }

                    var serverTime = hr.CreateDT.Value.AddHours(ServerTimeDiffH);

                    if (FromDate.HasValue && serverTime >= FromDate)
                    {
                        string catName = string.Format("{0} h:{1}", serverTime.ToString("yy.MM.dd"), serverTime.ToString("HH"));
                        categoryIx = m_XCatDates.Labels.IndexOf(catName);

                        if (categoryIx < 0)
                        {
                            m_XCatDates.Labels.Add(catName);
                            categoryIx = m_XCatDates.Labels.IndexOf(catName);
                        }

                        s.Items.Add(new OxyPlot.Series.ColumnItem(scoreValue, categoryIx));
                    }
                }

                m.Series.Add(s);
            }
        }
Ejemplo n.º 9
0
        private void PlotUnitKillsBar(PlotModel m)
        {
            if (EmpiresUnitKills == null)
            {
                return;
            }

            LinearAxis yAxis = new LinearAxis();

            yAxis.Title = Labels.KilledUnits;

            if (DiffKillsScore)
            {
                yAxis.Title += " " + Labels.Difference1;
            }

            yAxis.Key                = "units_kills";
            yAxis.Position           = AxisPosition.Left;
            yAxis.MajorGridlineStyle = LineStyle.Solid;
            yAxis.MinorGridlineStyle = LineStyle.Dot;
            m.Axes.Add(yAxis);

            //daty
            var categories = new CategoryAxis();

            categories.Title    = Labels.Date;
            categories.Position = AxisPosition.Bottom;
            categories.GapWidth = 0.1;
            m.Axes.Add(categories);

            long   lastKills  = -1;
            double killsValue = 0;

            foreach (var empire in EmpiresUnitKills.OrderBy(x => x.Key.UnitsKillsRank))
            {
                lastKills  = -1;
                killsValue = 0;
                OxyPlot.Series.ColumnSeries cs = new OxyPlot.Series.ColumnSeries();
                cs.LabelFormatString = "{0}";
                cs.Title             = string.Format("{0} ({1})", empire.Key.PlayerName, empire.Key.AlianceName);
                int categoryIx = -1;

                foreach (var hr in empire.Value.OrderBy(x => x.CreateDT.Value))
                {
                    if (DiffKillsScore)
                    {
                        if (lastKills < 0)
                        {
                            //pierwszy wynik, zaczynam od zera
                            lastKills  = hr.Score;
                            killsValue = 0;
                        }
                        else
                        {
                            killsValue = hr.Score - lastKills;
                            lastKills  = hr.Score;
                        }
                    }
                    else
                    {
                        killsValue = hr.Score;
                    }

                    var serverTime = hr.CreateDT.Value.AddHours(ServerTimeDiffH);

                    if (FromDate.HasValue && serverTime >= FromDate)
                    {
                        string catName = string.Format("{0} h:{1}", serverTime.ToString("yy.MM.dd"), serverTime.ToString("HH"));
                        categoryIx = categories.Labels.IndexOf(catName);

                        if (categoryIx < 0)
                        {
                            categories.Labels.Add(catName);
                            categoryIx = categories.Labels.IndexOf(catName);
                        }

                        cs.Items.Add(new OxyPlot.Series.ColumnItem(killsValue, categoryIx));
                    }
                }

                m.Series.Add(cs);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Generate the distribution plot
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            Range rgData = null, rgBins = null, rgOutput = null;
            bool  ok = false;

            Microsoft.Office.Interop.Excel.Application app = Globals.ThisAddIn.Application;

            try
            {
                //GetValues
                Utilities.GetRange(ref rgData, refedData.Text, ref ok);
                Utilities.GetRange(ref rgBins, refedBins.Text, ref ok);
                Utilities.GetRange(ref rgOutput, refedOutput.Text, ref ok);

                //Todo: Check ranges
                if (!IsValidBinRange(rgBins))
                {
                    MessageBox.Show("Select a valid bin range");
                    return;
                }
                //Plot the histogram
                long[] values = new long[rgBins.Rows.Count];
                String s      = String.Format("=FREQUENCY({0}, {1})", rgData.Address[false, false], rgBins.Address[false, false]);
                rgOutput[1, 1].Value  = "frequency";
                rgOutput              = rgOutput.Offset[1, 0];
                rgOutput              = rgOutput.Resize[rgBins.Rows.Count, 1];
                rgOutput.FormulaArray = s;

                // create a series of bars and populate them with data
                var seriesA = new OxyPlot.Series.ColumnSeries()
                {
                    Title           = txtLegend.Text,
                    StrokeColor     = OxyPlot.OxyColors.Black,
                    FillColor       = OxyPlot.OxyColors.Red,
                    StrokeThickness = 1
                };
                seriesA.ColumnWidth    = 1;
                seriesA.LabelPlacement = OxyPlot.Series.LabelPlacement.Outside;

                for (int i = 0; i < rgOutput.Rows.Count; i++)
                {
                    //values[i] = (long)(rgOutput.Cells[i + 1, 1].Value);
                    seriesA.Items.Add(new OxyPlot.Series.ColumnItem(rgOutput.Cells[i + 1, 1].Value, i));
                }

                //create a model and add the series to it
                var model = new OxyPlot.PlotModel
                {
                    Title = txtTitle.Text
                };

                if (chkOverlay.Checked)
                {
                    double alpha = 3, beta = 2;
                    EstimateWeibullDistParams(rgData, ref alpha, ref beta);
                    double value;

                    double scalefactor = rgData.Rows.Count * (rgBins[2, 1].Value - rgBins[1, 1].Value);

                    //line series overlay
                    var lsFit = new OxyPlot.Series.LineSeries()
                    {
                        Color = OxyPlot.OxyColors.Green
                    };

                    for (int i = 0; i < rgOutput.Rows.Count; i++)
                    {
                        value  = app.WorksheetFunction.Weibull_Dist(rgBins[i + 1, 1].Value, beta, alpha, false);
                        value *= scalefactor;
                        lsFit.Points.Add(new OxyPlot.DataPoint(i + 0.5, value));
                    }
                    model.Series.Add(lsFit);
                }


                // Add labels to the X-Axis
                String[] catLabels = new String[rgOutput.Rows.Count];
                double   dvalue;

                for (int i = 0; i < rgBins.Rows.Count; i++)
                {
                    if (i % m_XUnits == 0)
                    {
                        dvalue       = rgBins[i + 1, 1].Value;
                        catLabels[i] = String.Format("{0}", dvalue);
                    }
                }

                model.Axes.Add(new OxyPlot.Axes.CategoryAxis()
                {
                    ItemsSource = catLabels,
                    Angle       = 90
                });


                model.Series.Add(seriesA);


                plotView1.Model = model;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private Series ConvertSeries(ChartSeriesViewModel series)
        {
            Series newSeries = null;
            var valueSeries = series.GetScaleForProperty(series.ValueMemberPath);
            var labelSeries = series.GetScaleForProperty(series.LabelMemberPath);

            switch (series.SeriesType)
            {
                case( ChartSeriesType.Column):
                {
                    newSeries = new ColumnSeries
                    {
                        ValueField = series.ValueMemberPath,
                        ItemsSource = series.DataSource.Data,
                        FillColor = valueSeries.Color.ToOxyColor(),
                        StrokeColor = valueSeries.Color.ToOxyColor(),
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };

                    break;
                }
                case( ChartSeriesType.Line ):
                {
                    newSeries = new LineSeries
                    {
                        ItemsSource = series.DataSource.Data,
                        DataFieldX = series.XMemberPath,
                        DataFieldY = series.YMemberPath,
                        MarkerType = MarkerType.Circle,
                        Color = valueSeries.Color.ToOxyColor(),
                        MarkerFill = valueSeries.Color.ToOxyColor(),
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };
                    break;
                }
                case( ChartSeriesType.Spline):
                {
                    newSeries = new LineSeries
                    {
                        ItemsSource = series.DataSource.Data,
                        DataFieldX = series.XMemberPath,
                        DataFieldY = series.YMemberPath,
                        MarkerType = MarkerType.Circle,
                        Color = valueSeries.Color.ToOxyColor(),
                        MarkerFill = valueSeries.Color.ToOxyColor(),
                        Smooth = true,
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };
                    break;
                }
                case(ChartSeriesType.Area):
                {
                    newSeries = new AreaSeries
                    {
                        ItemsSource = series.DataSource.Data,
                        DataFieldX = series.XMemberPath,
                        DataFieldY = series.YMemberPath,
                        Color = valueSeries.Color.ToOxyColor(),
                        Fill = valueSeries.Color.ToOxyColor(),
                        MarkerFill = valueSeries.Color.ToOxyColor(),
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };
                    break;
                }
                case( ChartSeriesType.SplineArea):
                {
                    newSeries = new AreaSeries
                    {
                        ItemsSource = series.DataSource.Data,
                        DataFieldX = series.XMemberPath,
                        DataFieldY = series.YMemberPath,
                        Color = valueSeries.Color.ToOxyColor(),
                        Fill = valueSeries.Color.ToOxyColor(),
                        MarkerFill = valueSeries.Color.ToOxyColor(),
                        Smooth = true,
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };
                    break;
                }
                case(ChartSeriesType.Bubble):
                {
                    newSeries = new ScatterSeries
                    {
                        ItemsSource = series.DataSource.Data,
                        DataFieldX = series.XMemberPath,
                        DataFieldY = series.YMemberPath,
                        DataFieldSize = series.RadiusMemberPath,
                        MarkerFill = valueSeries.Color.ToOxyColor(),
                        MarkerType = MarkerType.Circle,
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };
                    break;
                }
                case( ChartSeriesType.StepLine):
                {
                    newSeries = new StairStepSeries
                    {
                        ItemsSource = series.DataSource.Data,
                        DataFieldX = series.XMemberPath,
                        DataFieldY = series.YMemberPath,
                        Color = valueSeries.Color.ToOxyColor(),
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };
                    break;
                }
                default:
                {
                    return null;
                }
            }

            newSeries.Title = series.Name;

            return newSeries;
        }
Ejemplo n.º 12
0
        private void Custos(int[] solucao)
        {
            var plotCustos = new OxyPlot.PlotModel();

            var xAxis = new CategoryAxis
            {
                Key      = "xAxis",
                Position = AxisPosition.Bottom,
                Title    = "Tipo de Custo",
                Minimum  = -1,
                Maximum  = 9
            };

            plotCustos.Axes.Add(new LinearAxis
            {
                Key            = "yAxis",
                Position       = AxisPosition.Left,
                Title          = "R$",
                Minimum        = 0,
                MaximumPadding = 0.1
            });

            var serieCustos = new OxyPlot.Series.ColumnSeries {
                Title = "Custos Totais", StrokeThickness = 2, FillColor = OxyPlot.OxyColor.FromRgb(180, 180, 180)
            };

            serieCustos.LabelPlacement    = OxyPlot.Series.LabelPlacement.Outside;
            serieCustos.LabelFormatString = "{0:.00}";


            double colheitaTotal     = 0;
            double baldeioTotal      = 0;
            double transporteTotal   = 0;
            double silviculturaTotal = 0;
            double implantacaoTotal  = 0;
            double anterioresTotal   = 0;
            double VPLTotal          = 0;
            double receitaTotal      = 0;
            double custoMedioTotal   = 0;

            for (int i = 0; i < HeuristicsBase.n; i++)
            {
                colheitaTotal     += HeuristicsBase.mColheita[i, solucao[i]] * HeuristicsBase.talhoes[i].area;
                baldeioTotal      += HeuristicsBase.mBaldeio[i, solucao[i]] * HeuristicsBase.talhoes[i].area;;
                transporteTotal   += HeuristicsBase.mTransporte[i, solucao[i]] * HeuristicsBase.talhoes[i].area;;
                silviculturaTotal += HeuristicsBase.mSilvicultura[i, solucao[i]] * HeuristicsBase.talhoes[i].area;;
                implantacaoTotal  += HeuristicsBase.mImplantacao[i, solucao[i]] * HeuristicsBase.talhoes[i].area;;
                anterioresTotal   += HeuristicsBase.mAnteriores[i, solucao[i]] * HeuristicsBase.talhoes[i].area;
                receitaTotal      += HeuristicsBase.mReceita[i, solucao[i]] * HeuristicsBase.talhoes[i].area;
                VPLTotal          += HeuristicsBase.mVPL[i, solucao[i]];
                custoMedioTotal   += HeuristicsBase.mCustosMedios[i, solucao[i]];
            }


            xAxis.ActualLabels.Add("Colheita\n(R$/10)");
            serieCustos.Items.Add(new OxyPlot.Series.ColumnItem(colheitaTotal / 10));
            xAxis.ActualLabels.Add("Baldeio");
            serieCustos.Items.Add(new OxyPlot.Series.ColumnItem(baldeioTotal));
            xAxis.ActualLabels.Add("Transporte");
            serieCustos.Items.Add(new OxyPlot.Series.ColumnItem(transporteTotal));
            xAxis.ActualLabels.Add("Silvicultura");
            serieCustos.Items.Add(new OxyPlot.Series.ColumnItem(silviculturaTotal));
            xAxis.ActualLabels.Add("Implantação");
            serieCustos.Items.Add(new OxyPlot.Series.ColumnItem(implantacaoTotal));
            xAxis.ActualLabels.Add("   Custos\nAnteriores");
            serieCustos.Items.Add(new OxyPlot.Series.ColumnItem(anterioresTotal));
            xAxis.ActualLabels.Add("Receita Total\n   (R$/10)");
            serieCustos.Items.Add(new OxyPlot.Series.ColumnItem(receitaTotal / 10));
            serieCustos.Items[6].Color = OxyPlot.OxyColor.FromRgb(30, 30, 30);
            xAxis.ActualLabels.Add("VPL");
            serieCustos.Items.Add(new OxyPlot.Series.ColumnItem(VPLTotal));
            serieCustos.Items[7].Color = OxyPlot.OxyColor.FromRgb(80, 80, 80);
            xAxis.ActualLabels.Add("Custo Médio \nde Produção");
            serieCustos.Items.Add(new OxyPlot.Series.ColumnItem(custoMedioTotal));
            serieCustos.Items[8].Color = OxyPlot.OxyColor.FromRgb(80, 80, 80);

            plotCustos.Axes.Add(xAxis);

            plotCustos.Series.Add(serieCustos);

            plot_interface_4.Model = plotCustos;
        }