Example #1
0
        public VBox BarPlotKategorija(DateTime odDatum, DateTime doDatum, string kategorija)
        {
            var items  = new List <ColumnItem>();
            var datums = new List <string>();
            var list   = Baza.getInstance.getGrupiraneTroskoveURazdoblju(odDatum, doDatum, KategorijaPresenter.getKategorija(kategorija));

            foreach (Trosak t in list)
            {
                var b = new ColumnItem(t.Cijena);
                items.Add(b);
                datums.Add(t.Datum.ToString("dd.MM.yyyy"));
            }

            if (list.Count > 1)
            {
                int i         = 0;
                var listaBoja = OxyPalettes.Cool(list.Count).Colors;
                foreach (ColumnItem cI in items)
                {
                    cI.Color = listaBoja[i];
                    i++;
                }
            }


            var barSeries = new ColumnSeries()
            {
                ItemsSource       = items,
                LabelPlacement    = LabelPlacement.Base,
                LabelFormatString = "{0:.00} kn"
            };


            var model = new PlotModel {
                Title = "Statistika za: " + kategorija + " " + odDatum.ToString("dd.MM.yyyy") + " - " + doDatum.ToString("dd.MM.yyyy")
            };


            model.Series.Add(barSeries);

            model.Axes.Add(new CategoryAxis
            {
                Position    = AxisPosition.Bottom,
                Key         = "Datum",
                ItemsSource = datums
            });

            model.Axes.Add(new LinearAxis
            {
                Position       = AxisPosition.Left,
                Minimum        = 0,
                LabelFormatter = StringManipulator.formatter
            });

            return(dodajOstalo(model, odDatum, doDatum, "Bar"));
        }
Example #2
0
        public VBox BarPlotMjeseceUGodini(int godina)
        {
            var items = new List <ColumnItem>();
            var kat   = new List <string>();
            var list  = Baza.getInstance.getTroskovePoKategorijamaUGodini(godina);

            foreach (KeyValuePair <int, double> t in list)
            {
                var b = new ColumnItem(t.Value);
                items.Add(b);
                kat.Add(StringManipulator.convertToMjesec(t.Key));
            }

            if (list.Count > 1)
            {
                int i         = 0;
                var listaBoja = OxyPalettes.Cool(list.Count).Colors;
                foreach (ColumnItem cI in items)
                {
                    cI.Color = listaBoja[i];
                    i++;
                }
            }


            var barSeries = new ColumnSeries()
            {
                ItemsSource       = items,
                LabelPlacement    = LabelPlacement.Base,
                LabelFormatString = "{0:.00} kn"
            };


            var model = new PlotModel {
                Title = "Statistika za godinu: " + godina
            };

            model.Series.Add(barSeries);

            model.Axes.Add(new CategoryAxis
            {
                Position    = AxisPosition.Bottom,
                Key         = "Datum",
                ItemsSource = kat
            });

            model.Axes.Add(new LinearAxis
            {
                Position       = AxisPosition.Left,
                Minimum        = 0,
                LabelFormatter = StringManipulator.formatter
            });

            return(dodajOstalo(model, new DateTime(godina, 1, 1), new DateTime(godina + 1, 1, 1), "GodisnjiBarChart"));
        }
Example #3
0
        public VBox BarPlotSveKategorije(DateTime odDatum, DateTime doDatum)
        {
            var items = new List <ColumnItem>();
            var kat   = new List <string>();
            var list  = Baza.getInstance.getSumiraneTroskoveURazdoblju(odDatum, doDatum);

            foreach (KeyValuePair <string, double> t in list)
            {
                var b = new ColumnItem(t.Value);
                items.Add(b);
                kat.Add(t.Key);
            }

            if (list.Count > 1)
            {
                int i         = 0;
                var listaBoja = OxyPalettes.Cool(list.Count).Colors;
                foreach (ColumnItem cI in items)
                {
                    cI.Color = listaBoja[i];
                    i++;
                }
            }


            var barSeries = new ColumnSeries()
            {
                ItemsSource       = items,
                LabelPlacement    = LabelPlacement.Base,
                LabelFormatString = "{0:.00} kn"
            };


            var model = new PlotModel {
                Title = "Statistika za razdoblje: " + odDatum.ToString("dd.MM.yyyy") + " - " + doDatum.ToString("dd.MM.yyyy")
            };

            model.Series.Add(barSeries);

            model.Axes.Add(new CategoryAxis
            {
                Position    = AxisPosition.Bottom,
                Key         = "Datum",
                ItemsSource = kat
            });

            model.Axes.Add(new LinearAxis
            {
                Position       = AxisPosition.Left,
                Minimum        = 0,
                LabelFormatter = StringManipulator.formatter
            });

            return(dodajOstalo(model, odDatum, doDatum, "BarChartKategorije"));
        }
Example #4
0
        public static void AssignDefaultColors(
            this PlotModel plotModel,
            bool isBaseDark,
            int nSeries
            )
        {
            var palette = isBaseDark
        ? OxyPalettes.Cool(nSeries)
        : OxyPalettes.Rainbow(nSeries);

            plotModel.DefaultColors = palette.Colors;
        }
        public static PlotView BarView(int mjesec, int godina)
        {
            var items = new List <ColumnItem>();
            var kat   = new List <string>();
            var list  = DBVozaci.ZaradaRadnika(mjesec, godina);

            foreach (KeyValuePair <string, long> t in list)
            {
                var b = new ColumnItem(t.Value);
                items.Add(b);
                kat.Add(t.Key);
            }

            if (list.Count > 1)
            {
                int i         = 0;
                var listaBoja = OxyPalettes.Cool(list.Count).Colors;
                foreach (ColumnItem cI in items)
                {
                    cI.Color = listaBoja[i];
                    i++;
                }
            }

            var barSeries = new ColumnSeries()
            {
                ItemsSource       = items,
                LabelPlacement    = LabelPlacement.Base,
                LabelFormatString = "{0:.00} kn"
            };

            var model = new PlotModel {
                Title = "Statistika: " + mjesec + ". mjesec " + godina + ". godine"
            };

            model.Series.Add(barSeries);

            model.Axes.Add(new CategoryAxis {
                Position    = AxisPosition.Bottom,
                Key         = "Datum",
                ItemsSource = kat
            });

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left,
            });

            var pv = new PlotView();

            pv.Model = model;
            return(pv);
        }
 /// <summary>
 /// Create the palette list.
 /// </summary>
 private void CreatePaletteList()
 {
     PaletteList = new BindingList <OxyPalette>();
     PaletteList.Add(OxyPalettes.BlackWhiteRed(64));
     PaletteList.Add(OxyPalettes.BlueWhiteRed(64));
     PaletteList.Add(OxyPalettes.BlueWhiteRed31);
     PaletteList.Add(OxyPalettes.Cool(64));
     PaletteList.Add(OxyPalettes.Gray(64));
     PaletteList.Add(OxyPalettes.Hot(64));
     PaletteList.Add(OxyPalettes.Hue64);
     PaletteList.Add(OxyPalettes.HueDistinct(64));
     PaletteList.Add(OxyPalettes.Jet(64));
     PaletteList.Add(OxyPalettes.Rainbow(64));
 }
Example #7
0
 public static PlotModel Cool200()
 {
     return(HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Cool(200), false));
 }
Example #8
0
 private OxyPalette GetPalette(int numberOfColors) =>
 _appSettings.IsBaseDark
 ? OxyPalettes.Cool(numberOfColors)
 : OxyPalettes.Rainbow(numberOfColors);
Example #9
0
        public static OxyPaletteMap CreateFromName(string name)
        {
            OxyPalette palette   = null;
            var        numPoints = 2;

            switch (name)
            {
            case "BlackWhiteRed":
            {
                numPoints = 3;
                palette   = OxyPalettes.BlackWhiteRed(NUM_COLORS);
                break;
            }

            case "BlueWhiteRed":
            {
                numPoints = 3;
                palette   = OxyPalettes.BlueWhiteRed(NUM_COLORS);
                break;
            }

            case "Cool":
            {
                numPoints = 3;
                palette   = OxyPalettes.Cool(NUM_COLORS);
                break;
            }

            case "Gray":
            {
                numPoints = 2;
                palette   = OxyPalettes.Gray(NUM_COLORS);
                break;
            }

            case "Hot":
            {
                numPoints = 5;
                palette   = OxyPalettes.Hot(NUM_COLORS);
                break;
            }

            case "Hue":
            {
                numPoints = 7;
                palette   = OxyPalettes.Hue(NUM_COLORS);
                break;
            }

            case "Jet":
            {
                numPoints = 5;
                palette   = OxyPalettes.Jet(NUM_COLORS);
                break;
            }

            case "Rainbow":
            {
                numPoints = 7;
                palette   = OxyPalettes.Rainbow(NUM_COLORS);
                break;
            }

            default:
            {
                return(null);

                break;
            }
            }
            var colorPoints = new Color[7];
            var brush       = new LinearGradientBrush();

            brush.StartPoint = new Point(0, 0.5);
            brush.EndPoint   = new Point(1, 0.5);
            var division = (NUM_COLORS / (numPoints - 1)) - 1;

            for (int i = 0; i < numPoints; i++)
            {
                var oxyColor = palette.Colors[(division * i)];
                colorPoints[i] = Color.FromArgb(oxyColor.A, oxyColor.R, oxyColor.G, oxyColor.B);
                brush.GradientStops.Add(new GradientStop(colorPoints[i], ((double)i / (numPoints - 1))));
            }

            return(new OxyPaletteMap(name, brush, palette));
        }
 public static PlotModel ColorMapCool32()
 {
     return(CreateRandomScatterSeriesWithColorAxisPlotModel(2500, OxyPalettes.Cool(32), MarkerType.Circle, AxisPosition.Right, OxyColors.Undefined, OxyColors.Undefined));
 }
Example #11
0
 public static PlotModel ColorMapCool32()
 {
     return(CreateRandomScatterSeriesWithColorAxisPlotModel(2500, OxyPalettes.Cool(32), MarkerType.Circle));
 }
Example #12
0
        public void barPlot(DateTime odDatum, DateTime doDatum)
        {
            var items = new List <ColumnItem>();
            var kat   = new List <string>();
            var list  = Baza.getInstance.getSumiraneTroskoveURazdoblju(odDatum, doDatum);

            foreach (KeyValuePair <string, double> t in list)
            {
                var b = new ColumnItem(t.Value);
                items.Add(b);
                kat.Add(t.Key);
            }

            if (list.Count > 1)
            {
                int i         = 0;
                var listaBoja = OxyPalettes.Cool(list.Count).Colors;
                foreach (ColumnItem cI in items)
                {
                    cI.Color = listaBoja[i];
                    i++;
                }
            }


            var barSeries = new ColumnSeries()
            {
                ItemsSource       = items,
                LabelPlacement    = LabelPlacement.Base,
                LabelFormatString = "{0:.00} kn"
            };



            var model = new PlotModel {
                Title = "Statistika za razdoblje: " + odDatum.ToShortDateString() + " - " + doDatum.ToShortDateString()
            };

            this.SetSizeRequest(800, 600);
            var pv = new PlotView();

            model.Series.Add(barSeries);



            model.Axes.Add(new CategoryAxis
            {
                Position    = AxisPosition.Bottom,
                Key         = "Datum",
                ItemsSource = kat
            });

            model.Axes.Add(new LinearAxis
            {
                Position       = AxisPosition.Left,
                Minimum        = 0,
                LabelFormatter = StringManipulator.formatter
            });

            pv.Model = model;
            var v = new VBox();

            v.Add(pv);
            var save = new Button(ImageButton.imageButton("gtk-save"));

            save.Clicked += (sender, e) =>
            {
                PlotSaver.saveToFile(this, "BarChart_" + odDatum.ToShortDateString() + "_-_" + doDatum.ToShortDateString() + ".png", model);
            };

            v.PackStart(save, false, false, 10);
            this.Add(v);
            this.ShowAll();
        }
Example #13
0
        private void DoSearchHarmonyOnClick(object sender, RoutedEventArgs e)
        {
            int nrOfIterations = 10; //tu zmiana jesli wiecej wypisać iteracji

            result.Text = string.Empty;

            AmelioratedHarmonySearch ahs = new AmelioratedHarmonySearch(values, expression, decisionVariableQty,
                                                                        xL, xU, hmcr, parMIN, parMAX, bwMIN,
                                                                        bwMAX, NI, HMS);

            ahs.ImprovedHarmonySearch();
            List <double[]> listPoints = ahs.GetFirstAndLastIterationResults();

            if (NI > 2 * nrOfIterations)
            {
                WriteToResultTextBlock($"FIRST ITERATIONS: {Environment.NewLine}");
                for (int i = 1; i < nrOfIterations + 1; i++)
                {
                    WriteToResultTextBlock($"Result for iteration nr {i}");
                    WriteResultForAllVector(listPoints[i]);
                    WriteToResultTextBlock($"{Environment.NewLine}");
                }

                WriteToResultTextBlock($"LAST ITERATIONS: {Environment.NewLine}");
                for (int i = nrOfIterations + 1; i < 2 * nrOfIterations + 1; i++)
                {
                    WriteToResultTextBlock($"Result for iteration nr {NI - 2 * nrOfIterations + i}");
                    WriteResultForAllVector(listPoints[i]);
                    WriteToResultTextBlock($"{Environment.NewLine}");
                }
            }

            WriteToResultTextBlock($"First solution: ");
            WriteResultForAllVector(listPoints.First());
            WriteToResultTextBlock($"{Environment.NewLine}");


            WriteToResultTextBlock($"Optimal solution: ");
            WriteResultForAllVector(listPoints.Last());
            WriteToResultTextBlock($"{Environment.NewLine}");


            if (decisionVariableQty == 2)
            {
                var tmp = new PlotModel();

                tmp.Axes.Add(new LinearColorAxis
                {
                    Position = AxisPosition.Right,
                    Palette  = OxyPalettes.Cool(200)
                });

                double tmpMaxValue = Double.MinValue;

                var x1x1 = ArrayBuilder.CreateVector(xL[0], xU[0], 100);
                var x2x2 = ArrayBuilder.CreateVector(xL[1], xU[1], 100);
                double[,] peaksData = new double[x1x1.GetLength(0), x2x2.GetLength(0)];
                double[] xy_tab = new double[2];

                for (int i = 0; i < x1x1.GetLength(0); i++)
                {
                    for (int j = 0; j < x2x2.GetLength(0); j++)
                    {
                        xy_tab[0]       = x1x1[i];
                        xy_tab[1]       = x2x2[j];
                        peaksData[i, j] = function.calculate(xy_tab);
                        if (peaksData[i, j] > tmpMaxValue)
                        {
                            tmpMaxValue = peaksData[i, j];
                        }
                    }
                }

                var heatMapSeries = new HeatMapSeries
                {
                    X0           = xL[0],
                    X1           = xU[0],
                    Y0           = xL[1],
                    Y1           = xU[1],
                    Interpolate  = true,
                    RenderMethod = HeatMapRenderMethod.Bitmap,
                    Data         = peaksData
                };
                tmp.Series.Add(heatMapSeries);

                var cs = new ContourSeries
                {
                    Color             = OxyColors.BlueViolet,
                    LabelBackground   = OxyColors.Transparent,
                    ColumnCoordinates = x1x1,
                    RowCoordinates    = x2x2,
                    Data = peaksData
                };
                tmp.Series.Add(cs);

                var path = new LineSeries
                {
                    ItemsSource     = ahs.GetDataPoints(),
                    Color           = OxyColors.Black,
                    StrokeThickness = 2
                };
                tmp.Series.Add(path);

                var sc = new ScatterSeries
                {
                    BinSize               = 10,
                    MarkerType            = MarkerType.Cross,
                    MarkerStrokeThickness = 3,
                };
                sc.Points.Add(new ScatterPoint(ahs.GetBestX1(), ahs.GetBestX2(), 5, tmpMaxValue));
                tmp.Series.Add(sc);

                GetMainViewModel().MyModel = tmp;
            }

            CountBtn.IsEnabled = false;
        }