コード例 #1
0
 public static PlotModel ColorMapBlackWhiteRed9TopLegend()
 {
     return(CreateRandomScatterSeriesWithColorAxisPlotModel(2500, OxyPalettes.BlackWhiteRed(9), MarkerType.Square, AxisPosition.Top));
 }
コード例 #2
0
 public static PlotModel ColorMapHot64Extreme()
 {
     return(CreateRandomScatterSeriesWithColorAxisPlotModel(2500, OxyPalettes.Hot(64), MarkerType.Square, AxisPosition.Right, OxyColors.Magenta, OxyColors.Green));
 }
コード例 #3
0
 public static PlotModel ColorMapHot16Big()
 {
     return(CreateRandomScatterSeriesWithColorAxisPlotModel(31000, OxyPalettes.Hot(16), MarkerType.Square, AxisPosition.Right, OxyColors.Undefined, OxyColors.Undefined));
 }
コード例 #4
0
 public static PlotModel ColorMapRainbow16()
 {
     return(CreateRandomScatterSeriesWithColorAxisPlotModel(2500, OxyPalettes.Rainbow(16), MarkerType.Square, AxisPosition.Right, OxyColors.Undefined, OxyColors.Undefined));
 }
コード例 #5
0
 public static PlotModel ColorMapHot64()
 {
     return(CreateRandomScatterSeriesWithColorAxisPlotModel(2500, OxyPalettes.Hot(64), MarkerType.Triangle, AxisPosition.Right, OxyColors.Undefined, OxyColors.Undefined));
 }
コード例 #6
0
        private void Plot_btn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var tmp = new PlotModel {
                    Title = "Contour Plot", Subtitle = "f(x1,x2)"
                };

                tmp.Axes.Add(new LinearColorAxis
                {
                    Position = OxyPlot.Axes.AxisPosition.Right,
                    //Palette = OxyPalettes.Jet(500)
                    Palette = OxyPalettes.Rainbow(100)
                });
                double[] PVBmax  = ParsePVB(PVBmax_TextBox.Text, ';');
                double[] PVBmin  = ParsePVB(PVBmin_TextBox.Text, ';');
                bool     errFlag = false;
                for (int i = 0; i < PVBmax.Length; i++)
                {
                    if (PVBmax[i] <= PVBmin[i])
                    {
                        errFlag = true;
                    }
                }
                String   fun_str = ObjFun_ComboBox.Text.ToString();
                Function fn      = new Function(fun_str);
                double   x1_min;
                double   x1_max;
                double   x2_min;
                double   x2_max;
                double   tmpMaxValue = Double.MinValue;

                if (PVBmin.GetLength(0) == 2 && !errFlag)
                {
                    x1_min = PVBmin[0];
                    x1_max = PVBmax[0];
                    x2_min = PVBmin[1];
                    x2_max = PVBmax[1];
                    var x1x1 = ArrayBuilder.CreateVector(x1_min, x1_max, 100);
                    var x2x2 = ArrayBuilder.CreateVector(x2_min, x2_max, 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] = HarmonyTool.EvaluateFun(fn, xy_tab);
                            if (peaksData[i, j] > tmpMaxValue)
                            {
                                tmpMaxValue = peaksData[i, j];
                            }
                        }
                    }


                    var heatMapSeries = new HeatMapSeries
                    {
                        X0           = x1_min,
                        X1           = x1_max,
                        Y0           = x2_min,
                        Y1           = x2_max,
                        Interpolate  = true,
                        RenderMethod = HeatMapRenderMethod.Bitmap,
                        Data         = peaksData
                    };
                    tmp.Series.Add(heatMapSeries);


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

                    if (solutionCheckBox.IsChecked == true)
                    {
                        var sc = new ScatterSeries
                        {
                            MarkerType = MarkerType.Circle
                        };
                        sc.BinSize               = 10;
                        sc.MarkerType            = MarkerType.Cross;
                        sc.MarkerStrokeThickness = 3;
                        sc.MarkerStroke          = OxyColors.Black;
                        double x1 = bestSolution[0];
                        double x2 = bestSolution[1];
                        sc.Points.Add(new OxyPlot.Series.ScatterPoint(x1, x2, 5, tmpMaxValue));
                        tmp.Series.Add(sc);
                    }
                    GetMainViewModel().MyModel = tmp;
                }
                else
                {
                    MessageBox.Show("Number of variables does not equal n = 2 or PVB not given correctly! Check forms", "Exception", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("A handled exception just occurred: " + ex.Message + "\n Check if forms are filled properly! Domain of function has to be set in PVB forms", "Exception", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
コード例 #7
0
        protected override FileProcessingResult MakeOnePlot(ResultFileEntry srcResultFileEntry)
        {
            string plotName = "Activity Percentages " + srcResultFileEntry.HouseholdKey + " " +
                              srcResultFileEntry.LoadTypeInformation?.Name;

            Profiler.StartPart(Utili.GetCurrentMethodAndClass());
            var consumption =
                new Dictionary <string, List <Tuple <string, double> > >();
            var lastname = string.Empty;

            if (srcResultFileEntry.FullFileName == null)
            {
                throw new LPGException("Srcfile was null");
            }
            using (var sr = new StreamReader(srcResultFileEntry.FullFileName)) {
                while (!sr.EndOfStream)
                {
                    var s = sr.ReadLine();
                    if (s == null)
                    {
                        throw new LPGException("Readline failed");
                    }

                    var cols = s.Split(Parameters.CSVCharacterArr, StringSplitOptions.None);
                    if (cols.Length == 1)
                    {
                        consumption.Add(cols[0], new List <Tuple <string, double> >());
                        lastname = cols[0];
                        sr.ReadLine();
                    }
                    else
                    {
                        var val = Convert.ToDouble(cols[1], CultureInfo.CurrentCulture);
                        consumption[lastname].Add(new Tuple <string, double>(cols[0], val));
                    }
                }
            }
            foreach (var pair in consumption)
            {
                var personname = pair.Key;

                var plotModel1 = new PlotModel
                {
                    LegendBorderThickness = 0,
                    LegendOrientation     = LegendOrientation.Horizontal,
                    LegendPlacement       = LegendPlacement.Outside,
                    LegendPosition        = LegendPosition.BottomCenter
                };
                if (Parameters.ShowTitle)
                {
                    plotModel1.Title = plotName + " " + personname;
                }

                var pieSeries1 = new PieSeries
                {
                    InsideLabelColor      = OxyColors.White,
                    InsideLabelPosition   = 0.8,
                    StrokeThickness       = 2,
                    AreInsideLabelsAngled = true
                };
                OxyPalette p;
                if (pair.Value.Count > 2)
                {
                    p = OxyPalettes.HueDistinct(pair.Value.Count);
                }
                else
                {
                    p = OxyPalettes.Hue64;
                }
                pieSeries1.InsideLabelColor = OxyColor.FromRgb(0, 0, 0);
                var i = 0;
                foreach (var tuple in pair.Value)
                {
                    var name = tuple.Item1.Trim();
                    if (name.Length > 30)
                    {
                        name = name.Substring(0, 20) + "...";
                    }
                    var slice = new PieSlice(name, tuple.Item2)
                    {
                        Fill = p.Colors[i++]
                    };
                    pieSeries1.Slices.Add(slice);
                }

                plotModel1.Series.Add(pieSeries1);
                Save(plotModel1, plotName, srcResultFileEntry.FullFileName + "." + personname, Parameters.BaseDirectory, CalcOption.ActivationFrequencies);
            }
            Profiler.StopPart(Utili.GetCurrentMethodAndClass());
            return(FileProcessingResult.ShouldCreateFiles);
        }
コード例 #8
0
 public static PlotModel Hot30()
 {
     return(HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Hot(30), false));
 }
コード例 #9
0
 public static PlotModel BlueWhiteRed40()
 {
     return(HeatMapSeriesExamples.CreatePeaks(OxyPalettes.BlueWhiteRed(40), false));
 }
コード例 #10
0
 public static PlotModel Jet20()
 {
     return(HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(20), false));
 }
コード例 #11
0
 public static PlotModel HueDistinctReverse200()
 {
     return(HeatMapSeriesExamples.CreatePeaks(OxyPalettes.HueDistinct(200).Reverse(), false));
 }
コード例 #12
0
 public static PlotModel Vertical_6()
 {
     return(HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(6), false));
 }
コード例 #13
0
 public static PlotModel Rainbow7()
 {
     return(HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Rainbow(7), false));
 }
コード例 #14
0
        private void DrawChart([JetBrains.Annotations.NotNull] HouseholdKeyEntry hhkey,
                               [JetBrains.Annotations.NotNull] Dictionary <string, List <double> > energyUsesPerPersonByAfforcance,
                               [ItemNotNull][JetBrains.Annotations.NotNull] List <string> persons,
                               [JetBrains.Annotations.NotNull] CalcLoadTypeDto lti)
        {
            string plotName   = "Affordance Energy Use Per Person " + hhkey.HHKey.Key + " " + lti.Name;
            var    plotModel1 = new PlotModel {
                // general
                LegendBorderThickness = 0,
                LegendOrientation     = LegendOrientation.Horizontal,
                LegendPlacement       = LegendPlacement.Outside,
                LegendPosition        = LegendPosition.BottomCenter,
                LegendMargin          = 10,
                LegendItemAlignment   = HorizontalAlignment.Left
            };
            var labelfontsize = 14;

            if (Config.MakePDFCharts)
            {
                plotModel1.DefaultFontSize = Parameters.PDFFontSize;
                plotModel1.LegendFontSize  = 16;
                labelfontsize = 18;
            }

            if (Parameters.ShowTitle)
            {
                plotModel1.Title = plotName;
            }

            // axes
            var categoryAxis1 = new CategoryAxis {
                MinorStep = 1,
                GapWidth  = 1,
                Position  = AxisPosition.Left
            };
            OxyPalette p;

            if (energyUsesPerPersonByAfforcance.Count > 1)
            {
                p = OxyPalettes.HueDistinct(energyUsesPerPersonByAfforcance.Count);
            }
            else
            {
                p = OxyPalettes.Hue64;
            }

            foreach (var personName in persons)
            {
                categoryAxis1.Labels.Add(ChartLocalizer.Get().GetTranslation(personName));
            }

            plotModel1.Axes.Add(categoryAxis1);
            string s2 = lti.Name + " in " + lti.UnitOfSum;

            var linearAxis1 = new LinearAxis {
                AbsoluteMinimum = 0,
                MaximumPadding  = 0.03,
                MinimumPadding  = 0,
                MinorTickSize   = 0,
                Position        = AxisPosition.Bottom,
                Title           = ChartLocalizer.Get().GetTranslation(s2)
            };

            plotModel1.Axes.Add(linearAxis1);
            // generate plot
            var count = 0;
            Dictionary <int, double> colSums2 = new Dictionary <int, double>();
            Dictionary <int, double> colSums  = new Dictionary <int, double>();

            for (int i = 0; i < persons.Count; i++)
            {
                colSums.Add(i, 0);
                colSums2.Add(i, 0);
            }

            foreach (var pair in energyUsesPerPersonByAfforcance)
            {
                // main columns
                var columnSeries2 = new BarSeries {
                    IsStacked       = true,
                    StackGroup      = "1",
                    StrokeThickness = 0.1,
                    StrokeColor     = OxyColors.White,
                    Title           = pair.Key, //affordance name
                    LabelPlacement  = LabelPlacement.Middle,
                    FillColor       = p.Colors[count++]
                };
                var col = 0;
                foreach (var d in pair.Value)
                {
                    //energy use values
                    var coli = new BarItem(d);
                    colSums2[col] += d;
                    columnSeries2.Items.Add(coli);
                    col++;
                }

                plotModel1.Series.Add(columnSeries2);
            }

            foreach (var pair in energyUsesPerPersonByAfforcance)
            {
                var col = 0;
                foreach (var d in pair.Value)
                {
                    if (d / colSums2[col] > 0.2)
                    {
                        {
                            var textAnnotation1 = new RectangleAnnotation();
                            var shortendName    = pair.Key;
                            if (shortendName.Length > 30)
                            {
                                shortendName = shortendName.Substring(0, 30) + "...";
                            }

                            textAnnotation1.Text     = shortendName;
                            textAnnotation1.MinimumX = colSums[col];
                            textAnnotation1.MaximumX = colSums[col] + d;
                            textAnnotation1.MinimumY = col + 0.35;
                            textAnnotation1.MaximumY = col + 0.45;
                            textAnnotation1.TextHorizontalAlignment = HorizontalAlignment.Left;
                            textAnnotation1.TextVerticalAlignment   = VerticalAlignment.Middle;
                            textAnnotation1.FontSize        = labelfontsize;
                            textAnnotation1.StrokeThickness = 0;
                            textAnnotation1.Fill            = OxyColors.White;
                            plotModel1.Annotations.Add(textAnnotation1);
                        }
                        {
                            var textAnnotation2 = new RectangleAnnotation {
                                Text = d.ToString("N1", CultureInfo.CurrentCulture) + " " + lti.UnitOfSum,
                                TextHorizontalAlignment = HorizontalAlignment.Left,
                                TextVerticalAlignment   = VerticalAlignment.Middle,
                                MinimumX        = colSums[col],
                                MaximumX        = colSums[col] + d,
                                MinimumY        = col + 0.25,
                                MaximumY        = col + 0.35,
                                Fill            = OxyColors.White,
                                FontSize        = labelfontsize,
                                StrokeThickness = 0
                            };

                            plotModel1.Annotations.Add(textAnnotation2);
                        }
                    }

                    colSums[col] += d;
                    col++;
                }
            }

            Save(plotModel1, plotName, "AffordanceEnergyUsePerPerson." + hhkey.HHKey + "." + lti.FileName + ".png", Parameters.BaseDirectory, CalcOption.AffordanceEnergyUse);
        }
コード例 #15
0
        private void InitializeChart()
        {
            // Create the plot model
            var mainModel = new PlotModel
            {
                DefaultColors   = OxyPalettes.HueDistinct(NumSeries).Colors,
                IsLegendVisible = true,
                Title           = "Draw on me!"
            };

            // Add a basic xAxis
            mainModel.Axes.Add(new LinearAxis
            {
                IsPanEnabled       = true,
                IsZoomEnabled      = true,
                Key                = "xAxis",
                Position           = AxisPosition.Bottom,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot,
                Title              = "X"
            });

            // And a basic yAxis
            mainModel.Axes.Add(new LinearAxis
            {
                IsPanEnabled       = true,
                IsZoomEnabled      = true,
                Key                = "yAxis",
                Position           = AxisPosition.Left,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot,
                Title              = "Y"
            });

            // And generate some interesting data on the chart to play with
            for (int s = 0; s < NumSeries; s++)
            {
                switch (s % 3)
                {
                case 0:
                    mainModel.Series.Add(new FunctionSeries(x => Math.Sin(x + s),
                                                            MinimumX,
                                                            MaximumX,
                                                            NumPoints)
                    {
                        YAxisKey = "yAxis"
                    });
                    break;

                case 1:
                    mainModel.Series.Add(new FunctionSeries(x => Math.Sin((x + s) / 4)
                                                            * Math.Acos(Math.Sin(x + s)),
                                                            MinimumX,
                                                            MaximumX,
                                                            NumPoints)
                    {
                        YAxisKey = "yAxis"
                    });
                    break;

                case 2:
                    mainModel.Series.Add(new FunctionSeries(
                                             x => Math.Sin(2 * Math.Cos(2
                                                                        * Math.Sin(2 * Math.Cos(x + s)))),
                                             MinimumX,
                                             MaximumX,
                                             NumPoints)
                    {
                        YAxisKey = "yAxis"
                    });
                    break;
                }
            }

            // Add the model to both the PlotView and the Drawing Toolbar
            uiPlotView.Model            = mainModel;
            uiDrawingToolbar.ChartModel = mainModel;

            // Add saving and printing events to the drawing toolbar
            uiDrawingToolbar.uiSaveButton.Click  += uiSaveButton_OnClick;
            uiDrawingToolbar.uiPrintButton.Click += uiPrintButton_OnClick;

            // And for fun, make it so you can copy the chart with Ctrl+C
            uiPlotView.ActualController.BindKeyDown(OxyKey.C,
                                                    OxyModifierKeys.Control,
                                                    new DelegatePlotCommand <OxyKeyEventArgs>(
                                                        CopyChart_OnKeyDown));
        }
コード例 #16
0
 public static PlotModel BlackWhiteRed3()
 {
     return(HeatMapSeriesExamples.CreatePeaks(OxyPalettes.BlackWhiteRed(3), false));
 }
コード例 #17
0
        private PlotModel SetupBooksAndPagesLastTenPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Last 10 Books Time vs Pages Plot"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "Last 10 Books Time vs Pages Plot");
            SetupPagesPerDayWithTimeVsTimeAxes(newPlot);

            // create series and add them to the plot
            ScatterSeries pointsSeries;

            OxyPlotUtilities.CreateScatterPointSeries(out pointsSeries,
                                                      ChartAxisKeys.DaysTakenKey, ChartAxisKeys.TotalPagesReadKey, "Time Taken Vs Pages");

            List <BooksDelta> deltasSet = new List <BooksDelta>();

            double minRate = 1e16;
            double maxRate = 0.0;

            foreach (var delta in _mainModel.BookDeltas)
            {
                deltasSet.Add(delta);
                if (deltasSet.Count < 10)
                {
                    continue;
                }

                BooksDelta end = deltasSet.Last();

                double daysTaken = end.LastTenTally.DaysInTally;
                double pagesRead = end.LastTenTally.TotalPages;
                if (daysTaken < 1.0)
                {
                    daysTaken = 1.0;
                }
                double       rate  = pagesRead / daysTaken;
                ScatterPoint point =
                    new ScatterPoint(daysTaken, pagesRead, 5, rate)
                {
                    Tag = end.Date.ToString("ddd d MMM yyy")
                };
                pointsSeries.Points.Add(point);

                if (minRate > rate)
                {
                    minRate = rate;
                }
                if (maxRate < rate)
                {
                    maxRate = rate;
                }

                deltasSet.RemoveAt(0);
            }
            pointsSeries.TrackerFormatString = "{Tag}\n{1}: {2:0.###}\n{3}: {4:0.###}";
            newPlot.Series.Add(pointsSeries);
            newPlot.Axes.Add(new LinearColorAxis {
                Position = AxisPosition.Right, Palette = OxyPalettes.Jet(200), Title = "Page Rate"
            });

            // finally update the model with the new plot
            return(newPlot);
        }
コード例 #18
0
 public static PlotModel Cool200()
 {
     return(HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Cool(200), false));
 }
コード例 #19
0
        public PlotView getScatteredPlot(string[,] dataArray, string title, int xColumn, int yColumn, int colorColumn, int regressionIndex, bool logX, bool logY)
        {
            string xTitle     = ucLoadFile.Instance.getCurrentColumnNames()[xColumn];
            string yTitle     = ucLoadFile.Instance.getCurrentColumnNames()[yColumn];
            string colorTitle = "No grouping selected";

            if (colorColumn != -1)
            {
                colorTitle = ucLoadFile.Instance.getCurrentColumnNames()[colorColumn];
            }
            // Getting unique group names when color grouping required and groups are strings
            ArrayList groupNames = getGroupNames(dataArray, colorColumn);

            //Populating scatter plot with data from selected columns
            var model = new PlotModel {
                Title = title
            };
            var scatterSeries = new ScatterSeries {
                MarkerType = MarkerType.Circle
            };

            for (int r = 0; r < dataArray.GetLength(0); r++)
            {   // x axis
                double xDouble   = 0;
                bool   isNumberX = double.TryParse(dataArray[r, xColumn], out xDouble);
                var    x         = xDouble;
                // y axis
                double yDouble   = 0;
                bool   isNumberY = double.TryParse(dataArray[r, yColumn], out yDouble);
                var    y         = yDouble;
                // color grouping
                double colorValue    = 0;
                bool   isNumberColor = true;
                if (colorColumn != -1)
                {
                    double colorDouble = 0;
                    isNumberColor = double.TryParse(dataArray[r, colorColumn], out colorDouble);
                    colorValue    = colorDouble;
                }
                var size = 3;
                if (!isNumberColor && !String.IsNullOrEmpty(dataArray[r, colorColumn]))
                {
                    scatterSeries.Points.Add(new ScatterPoint(x, y, size, groupNames.IndexOf(dataArray[r, colorColumn])));
                }
                else
                {
                    scatterSeries.Points.Add(new ScatterPoint(x, y, size, colorValue));
                }
            }
            // Handling of selection of axis scaling
            if (logX && !logY)
            {
                var logAxisX = new LogarithmicAxis()
                {
                    Position = AxisPosition.Bottom, Title = xTitle + ", Log(x)", UseSuperExponentialFormat = false, Base = 10, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray
                };
                var linearAxisY = new LinearAxis()
                {
                    Position = AxisPosition.Left, Title = yTitle, UseSuperExponentialFormat = false, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray
                };
                model.Axes.Add(logAxisX);
                model.Axes.Add(linearAxisY);
            }
            else if (!logX && logY)
            {
                var linearAxisX = new LinearAxis()
                {
                    Position = AxisPosition.Bottom, Title = xTitle, UseSuperExponentialFormat = false, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray
                };
                var logAxisY = new LogarithmicAxis()
                {
                    Position = AxisPosition.Left, Title = yTitle + ", Log(y)", UseSuperExponentialFormat = false, Base = 10, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray
                };
                model.Axes.Add(linearAxisX);
                model.Axes.Add(logAxisY);
            }
            else if (logX && logY)
            {
                var logAxisX = new LogarithmicAxis()
                {
                    Position = AxisPosition.Bottom, Title = xTitle + ", Log(x)", UseSuperExponentialFormat = false, Base = 10, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray
                };
                var logAxisY = new LogarithmicAxis()
                {
                    Position = AxisPosition.Left, Title = yTitle + ", Log(y)", UseSuperExponentialFormat = false, Base = 10, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray
                };
                model.Axes.Add(logAxisY);
                model.Axes.Add(logAxisX);
            }
            else
            {
                var linearAxisX = new LinearAxis()
                {
                    Position = AxisPosition.Bottom, Title = xTitle, UseSuperExponentialFormat = false, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray
                };
                var linearAxisY = new LinearAxis()
                {
                    Position = AxisPosition.Left, Title = yTitle, UseSuperExponentialFormat = false, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray
                };
                model.Axes.Add(linearAxisX);
                model.Axes.Add(linearAxisY);
            }

            model.Series.Clear();
            model.Annotations.Clear();
            model.Series.Add(scatterSeries);
            // Adding regression graph when selected
            if (regressionIndex == 1)
            {
                double[] xClmn                 = parseDataArrayToDouble(ucLoadFile.Instance.getDataColumn(xColumn, dataArray));
                Func <double, double> pwr      = getPowerRegression(dataArray, xColumn, yColumn);
                string         label           = "pwr rgssn y=" + Math.Round(a, 3).ToString() + "*" + "x pwr" + Math.Round(b, 3).ToString() + ", r=" + Math.Round(r, 2).ToString();
                FunctionSeries fsPwrRegression = new FunctionSeries(pwr, xClmn.Min() - 0.1, xClmn.Max(), 0.01, label);
                fsPwrRegression.Color = OxyColors.DeepSkyBlue;
                model.Series.Add(fsPwrRegression);
            }
            if (regressionIndex == 2)
            {
                double[] xClmn            = parseDataArrayToDouble(ucLoadFile.Instance.getDataColumn(xColumn, dataArray));
                Func <double, double> lnr = getLinearRegression(dataArray, xColumn, yColumn);
                string bstring            = Math.Round(b, 3).ToString();
                if (b <= 0.0009)
                {
                    bstring = Math.Round(b * 1000000, 3).ToString() + "m";
                }
                string         label = "lnr rgssn y=" + Math.Round(a, 3).ToString() + "+" + bstring + "*x, r=" + Math.Round(r, 2).ToString();
                FunctionSeries fsLinearRegression = new FunctionSeries(lnr, xClmn.Min() - 0.1, xClmn.Max(), 0.01, label);
                fsLinearRegression.Color = OxyColors.DeepSkyBlue;
                model.Series.Add(fsLinearRegression);
            }
            // Adding special axis for color coding
            model.Axes.Add(new LinearColorAxis
            {
                Position      = AxisPosition.Top,
                Palette       = OxyPalettes.Rainbow(200),
                Title         = colorTitle,
                TitlePosition = 0.2,
            });

            PlotView plotView = new PlotView();

            // Adding assembled model into plot view
            plotView.Model = model;

            return(plotView);
        }
コード例 #20
0
        private void bt_showmap_Click(object sender, EventArgs e)
        {
            bool   success = true;
            double Imax    = 0;

            success = success && double.TryParse(tb_Imax.Text, out Imax);
            double Umax = 0;

            success = success && double.TryParse(tb_Umax.Text, out Umax);
            double max_speed = 0;

            success = success && double.TryParse(tb_maxSpeed.Text, out max_speed);

            string config = string.Format("{0},{1},{2}", Imax, Umax, max_speed);

            MapType maptype = MapType.power;

            Enum.TryParse <MapType>(comboBox_maptype.Text, true, out maptype);

            if (!success)
            {
                MessageBox.Show("Error parse text to double");
                return;
            }

            var mtpa = buildTableMaxtorquePerAmple();

            int    n  = 100;
            double x0 = 0;
            double x1 = max_speed;
            double y0 = 0;
            double y1 = mtpa.GetMaxTorqueWithCurrentMagnitude(Imax);

            if (last_config != config)
            {
                effMap      = buildEfficiencyMap(50, 100, Imax, Umax, max_speed);
                last_config = config;
            }

            var    data  = effMap.power;
            string title = "Power (W)";

            switch (maptype)
            {
            case MapType.power:
                data  = effMap.power;
                title = "Power (W)";
                break;

            case MapType.efficiency:
                data  = effMap.efficiency;
                title = "Efficiency (%)";
                break;

            case MapType.windingloss:
                data  = effMap.windingloss;
                title = "Winding loss (W)";
                break;

            case MapType.rotor_coreloss:
                data  = effMap.rotor_coreloss;
                title = "Rotor core loss (W)";
                break;

            case MapType.stator_coreloss:
                data  = effMap.stator_coreloss;
                title = "Stator loss (W)";
                break;

            case MapType.coreloss:
                data  = effMap.coreloss;
                title = "Core loss (W)";
                break;

            case MapType.total_loss:
                data  = effMap.totalloss;
                title = "Total loss (W)";
                break;

            case MapType.voltage:
                data  = effMap.voltage;
                title = "Voltage (V)";
                break;

            case MapType.current:
                data  = effMap.current;
                title = "Current (A)";
                break;

            case MapType.beta:
                data  = effMap.beta;
                title = "Beta (degree)";
                break;

            case MapType.Ld:
                data  = effMap.Ld;
                title = "Ld (mH)";
                break;

            case MapType.Lq:
                data  = effMap.Lq;
                title = "Ld (mH)";
                break;

            default:
                break;
            }

            double fmin = double.MaxValue;

            for (int i = 0; i < data.GetLength(0); i++)
            {
                for (int j = 0; j < data.GetLength(1); j++)
                {
                    if (data[i, j] >= 0 && fmin > data[i, j])
                    {
                        fmin = data[i, j];
                    }
                }
            }

            var model = new PlotModel
            {
                Title = title,
            };

            model.Axes.Add(new LinearColorAxis
            {
                Position  = AxisPosition.Right,
                Palette   = OxyPalettes.Jet(500),
                HighColor = OxyColors.Gray,
                LowColor  = OxyColors.White,
                Minimum   = fmin,
                //Maximum = 100,
                Title = title
            });

            model.Axes.Add(new LinearAxis
            {
                Position = AxisPosition.Bottom,
                Title    = "Speed",
                //MajorGridlineStyle = LineStyle.Solid,
                //MinorGridlineStyle = LineStyle.Solid,
                //MajorGridlineColor = OxyColor.FromAColor(40, c),
                //MinorGridlineColor = OxyColor.FromAColor(20, c)
            });

            model.Axes.Add(new LinearAxis
            {
                Position = AxisPosition.Left,
                Title    = "Torque",
                //AbsoluteMinimum = 0,
                //Minimum = 0,
                //MajorGridlineStyle = LineStyle.Solid,
                //MinorGridlineStyle = LineStyle.Solid,
                //MajorGridlineColor = OxyColor.FromAColor(40, c),
                //MinorGridlineColor = OxyColor.FromAColor(20, c)
            });

            var hms = new HeatMapSeries
            {
                X0          = x0,
                X1          = x1,
                Y0          = y0,
                Y1          = y1,
                Data        = data,
                Interpolate = true,
            };

            model.Series.Add(hms);

            // contour
            var cs = new ContourSeries
            {
                //Color = OxyColors.Gray,
                //FontSize = 12,
                //ContourLevelStep = double.NaN,
                //LabelBackground = OxyColors.White,
                ColumnCoordinates = effMap.speed_points,
                RowCoordinates    = effMap.torque_points,
                Data = data,
            };

            if (cs.Data == effMap.efficiency)
            {
                cs.ContourLevels = new double[] { 0, 20, 40, 60, 80, 90, 91, 92, 93, 94, 95, 95.2, 95.4, 95.6, 95.8, 96, 96.2, 97, 98, 99 };
                model.Series.Add(cs);
            }

            // max-torque capability curve
            MaxtorqueCapabilityCurve mtcc = buildMaxtorqueCapabilityCurve(100, Imax, Umax, max_speed);
            var mtcc_series = new LineSeries()
            {
                LineStyle       = LineStyle.Solid,
                Color           = OxyColor.FromArgb(255, 0, 0, 0),
                StrokeThickness = 3,
            };

            for (int i = 0; i < mtcc.speeds.Count; i++)
            {
                mtcc_series.Points.Add(new OxyPlot.DataPoint(mtcc.speeds[i], mtcc.maxtorques[i]));
            }
            model.Series.Add(mtcc_series);

            // voltage limit curve 1
            VoltageLimitCurve vlc = buildVoltageLimitCurve(100, Imax, Umax, max_speed);
            var vlc_series        = new LineSeries()
            {
                LineStyle       = LineStyle.Dash,
                StrokeThickness = 1,
            };

            for (int i = 0; i < vlc.speeds.Count; i++)
            {
                vlc_series.Points.Add(new OxyPlot.DataPoint(vlc.speeds[i], vlc.torques[i]));
            }
            model.Series.Add(vlc_series);

            plot.Model = model;
        }
コード例 #21
0
ファイル: Form1.cs プロジェクト: bridgejohn/GPESolver
        /// <summary>
        /// Starts the calculation of the time development of the wavefunction under given parameters.
        /// As starting wave function it is either used the ground state wave function, if calculated before
        /// or a default one, or another one, if the double BEC checkbox is selected.
        /// </summary>
        private void button1_Click(object sender, EventArgs e)
        {
            getParams(); //read-out of the parameters
            // Initialization of the GPE solver, transferring the read-out parameters
            gpe = new GPESolver(mass, anzahl, sclength, wx, wr);

            double[] normedPsi = new double[gpe.psi.Length];   //Creation of the array for |Ψ|²

            //Plot of the trap potential, that is shown during the calculation of the time-evolution calculation

            plotV.Points.Clear(); // Deletes previous data points from the data series

            //Creation of the new data series for the plot of the potential
            for (int k = 0; k < gpe.psi.Length; k++)
            {
                plotV.Points.Add(new DataPoint(gpe.X[k], gpe.V[k]));
            }

            potModel.Series.Clear();     // Deletes previous data series from the plotmodel
            potModel.Series.Add(plotV);  // Adds new data series to the plotmodel
            this.plot1.Model = potModel; // Shows the potential plot

            // Preparation of the time-dependent plot

            // Creation of the data grid for the time-dependent plot of |Ψ|²
            heatPsi.X0 = gpe.X[0];              // set xmin
            heatPsi.X1 = gpe.X[gpe.xSteps - 1]; // set xmax
            heatPsi.Y0 = 0;
            heatPsi.Y1 = gpe.deltaT * tsteps;   //set the height of the plot

            heatPsi.Interpolate = true;         //switch on color gradient

            //Creation of two color scales, using the 'Jet-palette'
            LinearColorAxis cAxis = new LinearColorAxis();

            cAxis.Palette = OxyPalettes.Jet(100);
            LinearColorAxis cAxisC = new LinearColorAxis();

            cAxisC.Palette = OxyPalettes.Jet(100);



            ColorBarModelE.Series.Clear();
            this.ColorBar.Model = ColorBarModelE; //Prevents bug with colorbar if time evolution is selected before starting calculation. Reason unknown.



            timeModel.Axes.Add(cAxis);                                     // Adding the color axis
            ColorBarModel.Axes.Add(cAxisC);
            double[,] dataMap  = new double[gpe.psi.Length, tsteps / 100]; //Initializing data array for time-dependent plot
            double[,] ColorMap = new double[10, 10000];                    //Initializing data array for color bar



            Stopwatch Stopwatch1 = new Stopwatch(); // Initialisation of the stopwatch

            Stopwatch1.Start();                     // Start of the stopwatch

            //deciding which method to use for the time-development-calculation,
            //if there is no method chosen, Bit-Reverse is used
            string method;


            if (FFTCheckBox.Checked)
            {
                method = "CT";
            }
            else if (DFTCheckBox.Checked)
            {
                method = "DFT";
            }
            else if (bitReverse.Checked)
            {
                method = "BR";
            }
            else
            {
                method = "BR";
            }

            // The starting wave function is created, either using the default one (see GPESolver) or the ground state
            // is calculated, or the double BEC function is used with the offset chosen in the GUI
            ComplexNumber[] psiStart = (ComplexNumber[])gpe.psi.Clone();

            if (getgroundstate.Checked)
            {
                gpe.getGroundState();
            }
            else if (DBECCheckBox.Checked)
            {
                offsetDBEC = Convert.ToInt32(OffsetDBECTextBox.Text);
                gpe.getDPsi(offsetDBEC);
            }


            int writeOut = 0;

            for (int i = 0; i < tsteps; i++)
            {
                // Calculation of Ψ(t) using the split-step-fourier method using the chosen algorithm for the FFT
                gpe.splitStepFourier(method);


                // Writing every 100th calculated value into the plot array
                if (i == writeOut)
                {
                    for (int k = 0; k < gpe.psi.Length; k++)
                    {
                        dataMap[k, i / 100] = Math.Pow(gpe.psi[k].Norm(), 2);
                    }
                    writeOut += 100;
                }
            }

            Stopwatch1.Stop();                                                                                                                              // Stops the time after calculation
            LaufzeitTextBox.Text = Convert.ToString(Stopwatch1.ElapsedMilliseconds);                                                                        // Shows runtime in textbox
            listBox1.Items.Insert(0, method + "-FFT:" + " " + Convert.ToString(Stopwatch1.ElapsedMilliseconds) + "ms" + "  Timesteps" + tsteps.ToString()); // Adds runtime, used method and number of time steps to listbox

            maxColor = OxyPlot.ArrayExtensions.Max2D(dataMap);                                                                                              //@David ich weiß leider nicht so richtig was das macht
            for (int k = 0; k < 10000; k++)
            {
                for (int l = 0; l < 10; l++)
                {
                    ColorMap[l, k] = maxColor * k / 10000;
                }
            }
            // Creation of the data grid for the display of the colorbar
            ColorBarSeries.X0          = 0;    //set xmin
            ColorBarSeries.X1          = 10;   //set xmax
            ColorBarSeries.Y0          = 0;    //set height of the colorbar
            ColorBarSeries.Y1          = maxColor;
            ColorBarSeries.Interpolate = true; //switch on color gradient

            //Preparing Oxyplot
            heatPsi.Data        = dataMap;  // Write calculated data into plotarray
            ColorBarSeries.Data = ColorMap; // Write calculated data into plotarray
            timeModel.Series.Clear();
            timeModel.Series.Add(heatPsi);  // Add plotarray to plotmodel

            // Add the recent data series to the color bar model
            ColorBarModel.Series.Clear();
            ColorBarModel.Series.Add(ColorBarSeries);

            //Calculating |Ψ|² and |Ψstart|² and writing it into the plot arrays
            for (int k = 0; k < gpe.psi.Length; k++)
            {
                normedPsi[k] = Math.Pow(gpe.psi[k].Norm(), 2);
                plotPsi.Points.Add(new DataPoint(gpe.X[k], normedPsi[k]));
                normedPsi[k] = Math.Pow(psiStart[k].Norm(), 2);
                plotPsiStart.Points.Add(new DataPoint(gpe.X[k], normedPsi[k]));
            }

            // Deleting the old series and add the new ones
            myModel.Series.Clear();
            myModel.Series.Add(plotPsiStart);
            myModel.Series.Add(plotPsi); //


            this.plot1.Model      = timeModel;     // Show the time-dependent plot
            this.ColorBar.Model   = ColorBarModel; // Show the created color bar
            this.ColorBar.Visible = true;          // Make the color bar visible

            this.shiftPotButton.Enabled = true;    // The shift potential button is usable now

            //Energy = ETC.Hamilton(gpe.psi, gpe.V, gpe.deltaX, PhysConst.hbar, mass, gpe.g1D);
            //EnergieTextBox.Text = Convert.ToString(Energy); //Energie in TextBox
        }
        private static void MakeGeneralBarChart([ItemNotNull][JetBrains.Annotations.NotNull] List <AffordanceEntry> entries, [JetBrains.Annotations.NotNull] string dstDir)
        {
            var householdNames = entries.Select(x => x.HouseholdName.Trim()).Distinct().ToList();
            // make absolute values
            var plotModel1 = MakePlotmodel(householdNames,
                                           ChartLocalizer.Get().GetTranslation("Electricity") + " in kWh");
            var affNames = entries.Select(x => x.AffordanceName).Distinct().ToList();

            affNames.Sort((x, y) => string.Compare(x, y, StringComparison.Ordinal));
            OxyPalette p;

            if (affNames.Count < 2)
            {
                p = OxyPalettes.Hue64;
            }
            else
            {
                p = OxyPalettes.HueDistinct(affNames.Count);
            }
            for (var i = 0; i < affNames.Count; i++)
            {
                var tag           = affNames[i];
                var columnSeries2 = new ColumnSeries
                {
                    IsStacked       = true,
                    StackGroup      = "1",
                    StrokeThickness = 1,
                    StrokeColor     = OxyColors.White,
                    Title           = ChartLocalizer.Get().GetTranslation(tag),
                    LabelPlacement  = LabelPlacement.Middle,
                    FillColor       = p.Colors[i]
                };
                foreach (var householdName in householdNames)
                {
                    var te =
                        entries.FirstOrDefault(x => x.AffordanceName == tag && x.HouseholdName == householdName);
                    if (te != null)
                    {
                        columnSeries2.Items.Add(new ColumnItem(te.Value));
                    }
                    else
                    {
                        columnSeries2.Items.Add(new ColumnItem(0));
                    }
                }
                plotModel1.Series.Add(columnSeries2);
            }

            var fileName = Path.Combine(dstDir, "MergedAffordanceEnergyUse.pdf");

            OxyPDFCreator.Run(plotModel1, fileName);
            var hhSums     = new Dictionary <string, double>();
            var households = entries.Select(x => x.HouseholdName).Distinct().ToList();

            foreach (var household in households)
            {
                var sum = entries.Where(x => x.HouseholdName == household).Select(x => x.Value).Sum();
                hhSums.Add(household, sum);
            }
            foreach (var affordanceName in affNames)
            {
                var plotModel2 = MakePlotmodel(householdNames, "Anteil am Gesamtverbrauch in Prozent");
                plotModel2.LegendFontSize = Fontsize;
                var columnSeries2 = new ColumnSeries
                {
                    IsStacked       = true,
                    StackGroup      = "1",
                    StrokeThickness = 1,
                    Title           = ChartLocalizer.Get().GetTranslation(affordanceName),
                    LabelPlacement  = LabelPlacement.Middle,
                    FillColor       = OxyColors.LightBlue
                };
                var averageValue =
                    entries.Where(x => x.AffordanceName == affordanceName)
                    .Select(x => x.Value / hhSums[x.HouseholdName] * 100)
                    .Average();
                var ls = new LineSeries
                {
                    Color = OxyColors.Red,
                    Title = "Durchschnitt"
                };
                for (var i = 0; i < householdNames.Count; i++)
                {
                    var householdName = householdNames[i];
                    ls.Points.Add(new DataPoint(i, averageValue));
                    var te =
                        entries.FirstOrDefault(
                            x => x.AffordanceName == affordanceName && x.HouseholdName == householdName);

                    if (te != null)
                    {
                        columnSeries2.Items.Add(new ColumnItem(te.Value / hhSums[householdName] * 100));
                    }
                    else
                    {
                        columnSeries2.Items.Add(new ColumnItem(0));
                    }
                }
                plotModel2.Series.Add(columnSeries2);
                plotModel2.Series.Add(ls);
                var cleanTag    = AutomationUtili.CleanFileName(affordanceName);
                var relfileName = Path.Combine(dstDir, "MergedAffordanceTaggingEnergyUse." + cleanTag + ".pdf");
                OxyPDFCreator.Run(plotModel2, relfileName);
            }
        }
コード例 #23
0
 public static PlotModel ColorMapHue30()
 {
     return(CreateRandomScatterSeriesWithColorAxisPlotModel(2500, OxyPalettes.Hue(30), MarkerType.Star, AxisPosition.Right, OxyColors.Undefined, OxyColors.Undefined));
 }
コード例 #24
0
        private void MakeBarCharts([JetBrains.Annotations.NotNull] ResultFileEntry rfe, [JetBrains.Annotations.NotNull] string plotName, [JetBrains.Annotations.NotNull] DirectoryInfo basisPath,
                                   [JetBrains.Annotations.NotNull] Dictionary <string, List <TagEntry> > consumption)
        {
            Profiler.StartPart(Utili.GetCurrentMethodAndClass());
            foreach (var pair in consumption)
            {
                var hasReferenceValue = pair.Value.Any(x => x.ReferenceValues.Count > 0);
                if (!hasReferenceValue)
                {
                    continue;
                }
                var plotModel1 = new PlotModel();
                pair.Value.Sort((x, y) => x.Value.CompareTo(y.Value));
                plotModel1.LegendBorderThickness = 0;
                plotModel1.LegendOrientation     = LegendOrientation.Horizontal;
                plotModel1.LegendPlacement       = LegendPlacement.Outside;
                plotModel1.LegendPosition        = LegendPosition.BottomCenter;
                var labelFontSize = 12;
                if (Config.MakePDFCharts)
                {
                    plotModel1.DefaultFontSize = Parameters.PDFFontSize;
                    plotModel1.LegendFontSize  = Parameters.PDFFontSize;
                    labelFontSize = 16;
                }
                plotModel1.LegendSymbolMargin = 20;
                if (Parameters.ShowTitle)
                {
                    plotModel1.Title = plotName;
                }

                var categoryAxis1 = new CategoryAxis
                {
                    MinorStep = 1,
                    Minimum   = -0.5
                };
                categoryAxis1.Labels.Add(ChartLocalizer.Get().GetTranslation("Simulated"));
                var firstEntry     = pair.Value[0];
                var referenceCount = firstEntry.ReferenceHeaders.Count;
                for (var i = 0; i < referenceCount; i++)
                {
                    categoryAxis1.Labels.Add(ChartLocalizer.Get().GetTranslation(firstEntry.ReferenceHeaders[i]));
                }
                categoryAxis1.GapWidth       = 1;
                categoryAxis1.MaximumPadding = 0.02;
                categoryAxis1.Position       = AxisPosition.Left;
                plotModel1.Axes.Add(categoryAxis1);

                var sum1 = pair.Value.Select(x => x.Value).Sum();
                var sums = new List <double>();
                foreach (var entry in pair.Value)
                {
                    for (var i = 0; i < entry.ReferenceValues.Count; i++)
                    {
                        if (sums.Count < i + 1)
                        {
                            sums.Add(0);
                        }
                        sums[i] += entry.ReferenceValues[i];
                    }
                }
                var    sum2        = sums.Max();
                var    totalSum    = Math.Max(sum1, sum2);
                string s2          = rfe.LoadTypeInformation?.Name ?? "";
                var    linearAxis1 = new LinearAxis
                {
                    AbsoluteMinimum = 0,
                    MaximumPadding  = 0.02,
                    MinimumPadding  = 0,
                    MajorStep       = totalSum / 5,
                    MinorTickSize   = 0,
                    Position        = AxisPosition.Bottom,
                    Title           = ChartLocalizer.Get().GetTranslation(s2) + " in " + rfe.LoadTypeInformation?.UnitOfSum +
                                      string.Empty
                };
                plotModel1.Axes.Add(linearAxis1);
                OxyPalette p;
                if (pair.Value.Count > 1)
                {
                    p = OxyPalettes.HueDistinct(pair.Value.Count);
                }
                else
                {
                    p = OxyPalettes.Hue64;
                }
                var colSums = new Dictionary <int, double>
                {
                    { 0, 0 },
                    { 1, 0 }
                };
                var count = 0;
                foreach (var tagentry in pair.Value)
                {
                    var columnSeries2 = new BarSeries
                    {
                        FillColor = p.Colors[count]
                    };
                    count++;
                    columnSeries2.IsStacked       = true;
                    columnSeries2.StackGroup      = "1";
                    columnSeries2.StrokeThickness = 1;
                    columnSeries2.StrokeColor     = OxyColor.FromArgb(255, 255, 255, 255);
                    columnSeries2.StrokeThickness = 0.1;
                    columnSeries2.Title           = ChartLocalizer.Get().GetTranslation(tagentry.TagName);
                    columnSeries2.LabelPlacement  = LabelPlacement.Middle;
                    var coli = new BarItem(tagentry.Value);
                    columnSeries2.Items.Add(coli);
                    foreach (var referenceValue in tagentry.ReferenceValues)
                    {
                        var coli2 = new BarItem(referenceValue);
                        columnSeries2.Items.Add(coli2);
                    }
                    var col = 0;
                    if (tagentry.Value / sum1 > 0.2)
                    {
                        var d         = tagentry.Value;
                        var valuetext = d.ToString("N0", CultureInfo.CurrentCulture) + " " + rfe.LoadTypeInformation?.UnitOfSum + " (" +
                                        (d / sum1 * 100).ToString("N1", CultureInfo.CurrentCulture) + " %)";
                        SetRectangelAnnotation(col, colSums, plotModel1, valuetext, d, 0.25, 0.35, labelFontSize);
                        var shortendName = ChartLocalizer.Get().GetTranslation(tagentry.TagName).Trim();
                        if (shortendName.Length > 20)
                        {
                            shortendName = shortendName.Substring(0, 17) + "...";
                        }
                        SetRectangelAnnotation(col, colSums, plotModel1, shortendName, d, 0.35, 0.45, labelFontSize);
                    }
                    col++;
                    double refValue = 0;
                    if (tagentry.ReferenceValues.Count > 0)
                    {
                        refValue = tagentry.ReferenceValues[0];
                    }
                    if (refValue / sum2 > 0.15)
                    {
                        var valueText = refValue.ToString("N0", CultureInfo.CurrentCulture) + " " + rfe.LoadTypeInformation?.UnitOfSum +
                                        " (" + (refValue / sum2 * 100).ToString("N1", CultureInfo.CurrentCulture) +
                                        " %)";
                        SetRectangelAnnotation(col, colSums, plotModel1, valueText, refValue, 0.25, 0.35,
                                               labelFontSize);
                        var labelText = ChartLocalizer.Get().GetTranslation(tagentry.TagName);
                        SetRectangelAnnotation(col, colSums, plotModel1, labelText, refValue, 0.35, 0.45,
                                               labelFontSize);
                    }
                    colSums[0] += tagentry.Value;
                    if (tagentry.ReferenceValues.Count > 0)
                    {
                        colSums[1] += tagentry.ReferenceValues[0];
                    }
                    plotModel1.Series.Add(columnSeries2);
                }
                var fi           = new FileInfo(rfe.FullFileName);
                var modifiedName = fi.Name.Substring(0, fi.Name.Length - 3) + AutomationUtili.CleanFileName(pair.Key) +
                                   ".bars";
                if (fi.DirectoryName == null)
                {
                    throw new LPGException("File was not assigned to a directory");
                }

                var cleanedfullname = Path.Combine(fi.DirectoryName, modifiedName);
                Save(plotModel1, plotName, cleanedfullname, basisPath, CalcOption.HouseholdContents);
            }
            Profiler.StopPart(Utili.GetCurrentMethodAndClass());
        }
コード例 #25
0
 public static PlotModel ColorMapJet32()
 {
     return(CreateRandomScatterSeriesWithColorAxisPlotModel(2500, OxyPalettes.Jet(32), MarkerType.Plus, AxisPosition.Right, OxyColors.Undefined, OxyColors.Undefined));
 }
コード例 #26
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();
        }
コード例 #27
0
 public static PlotModel ColorMapHot64ExtremeTopLegend()
 {
     return(CreateRandomScatterSeriesWithColorAxisPlotModel(2500, OxyPalettes.Hot(64), MarkerType.Cross, AxisPosition.Top, OxyColors.Magenta, OxyColors.Green));
 }
コード例 #28
0
        public static PlotModel CategorizedHeatMap()
        {
            var model = new PlotModel {
                Title = "Cakes per Weekday"
            };

            // Weekday axis (horizontal)
            model.Axes.Add(new CategoryAxis
            {
                Position = AxisPosition.Bottom,

                // Key used for specifying this axis in the HeatMapSeries
                Key = "WeekdayAxis",

                // Array of Categories (see above), mapped to one of the coordinates of the 2D-data array
                ItemsSource = new[]
                {
                    "Monday",
                    "Tuesday",
                    "Wednesday",
                    "Thursday",
                    "Friday",
                    "Saturday",
                    "Sunday"
                }
            });

            // Cake type axis (vertical)
            model.Axes.Add(new CategoryAxis
            {
                Position    = AxisPosition.Left,
                Key         = "CakeAxis",
                ItemsSource = new[]
                {
                    "Apple cake",
                    "Baumkuchen",
                    "Bundt cake",
                    "Chocolate cake",
                    "Carrot cake"
                }
            });

            // Color axis
            model.Axes.Add(new LinearColorAxis
            {
                Palette = OxyPalettes.Hot(200)
            });

            var rand = new Random();
            var data = new double[7, 5];

            for (int x = 0; x < 5; ++x)
            {
                for (int y = 0; y < 7; ++y)
                {
                    data[y, x] = rand.Next(0, 200) * (0.13 * (y + 1));
                }
            }

            var heatMapSeries = new HeatMapSeries
            {
                X0            = 0,
                X1            = 6,
                Y0            = 0,
                Y1            = 4,
                XAxisKey      = "WeekdayAxis",
                YAxisKey      = "CakeAxis",
                RenderMethod  = HeatMapRenderMethod.Rectangles,
                LabelFontSize = 0.2, // neccessary to display the label
                Data          = data
            };

            model.Series.Add(heatMapSeries);
            return(model);
        }
コード例 #29
0
 public static PlotModel ColorMapBlackWhiteRed9()
 {
     return(CreateRandomScatterSeriesWithColorAxisPlotModel(2500, OxyPalettes.BlackWhiteRed(9), MarkerType.Square, AxisPosition.Right, OxyColors.Undefined, OxyColors.Undefined));
 }
コード例 #30
0
 public static PlotModel ColorMapBlackWhiteRed9()
 {
     return(CreateRandomScatterSeriesWithColorAxisPlotModel(2500, OxyPalettes.BlackWhiteRed(9)));
 }