Exemple #1
0
        /// <summary>
        /// This function is called every frame to update the graph's values
        /// </summary>
        public override void Draw()
        {
            base.Draw();
            PlotModel.Title = "Memory Usage";
            CategoryAxis X = new CategoryAxis();
            CategoryAxis Y = new CategoryAxis(); // Create the X and Y axes

            X.Title = "Usage";
            PlotModel.Axes.Add(Y);
            PlotModel.Axes.Add(X); // Add them to the model
            ColumnSeries alloc = new ColumnSeries();

            alloc.Items.Add(new ColumnItem(256)); // create a column and set its value
            alloc.ColumnWidth = 25;
            alloc.FillColor   = Colors.CornflowerBlue.ToOxyColor();
            alloc.Title       = "Allocated";
            PlotModel.Series.Add(alloc);
            ColumnSeries free = new ColumnSeries();

            free.Items.Add(new ColumnItem(512));
            free.ColumnWidth = 25;
            free.FillColor   = Colors.GreenYellow.ToOxyColor();
            free.Title       = "Free";
            PlotModel.Series.Add(free);
            ColumnSeries swap = new ColumnSeries();

            swap.Items.Add(new ColumnItem(768));
            swap.ColumnWidth = 25;
            swap.FillColor   = Colors.Red.ToOxyColor();
            swap.Title       = "Swap";
            PlotModel.Series.Add(swap); // add the columns to the plot model
        }
Exemple #2
0
        private void MakeModels(long PK)
        {
            DataAccess db = new DataAccess();

            measurement = db.GetMeasurements(PK);

            var    fcvHistogram = Histogram.CreateEmpty(10, 80, 40);
            double count        = 0;

            foreach (var x in measurement)
            {
                if (x.FCV != 0)
                {
                    fcvHistogram.Increment((int)x.FCV);
                    count++;// add individual data points
                }
            }

            OxyPlot.Axes.CategoryAxis xaxis = new OxyPlot.Axes.CategoryAxis();
            xaxis.Title              = "FCV(m/s)";
            xaxis.TitleFontWeight    = 700;
            xaxis.Position           = AxisPosition.Bottom;
            xaxis.MajorGridlineStyle = LineStyle.Solid;
            xaxis.MinorGridlineStyle = LineStyle.Solid;


            OxyPlot.Axes.LinearAxis yaxis = new OxyPlot.Axes.LinearAxis();
            yaxis.Title              = "%";
            yaxis.TitleFontWeight    = 700;
            yaxis.Minimum            = 0;
            yaxis.Maximum            = 100;
            yaxis.Position           = AxisPosition.Left;
            yaxis.MajorGridlineStyle = LineStyle.Solid;
            yaxis.MinorGridlineStyle = LineStyle.Solid;

            OxyPlot.Series.ColumnSeries s1 = new OxyPlot.Series.ColumnSeries();
            s1.IsStacked   = true;
            s1.StrokeColor = OxyColors.Black;
            s1.FillColor   = OxyColors.Black;
            s1.Background  = OxyColors.Beige;
            count          = 100.0 / count;
            foreach (var x in fcvHistogram.BinsAndValues)
            {
                s1.Items.Add(new ColumnItem(x.Value * count));
                xaxis.Labels.Add(x.Key.ToString().Substring(0, 3));
            }

            var Model = new PlotModel();

            Model.Title      = "Conduction Velocities";
            Model.Background = OxyColors.GhostWhite;


            Model.Axes.Add(xaxis);
            Model.Axes.Add(yaxis);
            Model.Series.Add(s1);
            model.Add(Model);
        }
Exemple #3
0
        private static void MakeBarPlot([JetBrains.Annotations.NotNull] string outputPath, [ItemNotNull][JetBrains.Annotations.NotNull] List <Column> columns, int position, int day,
                                        int minutesToSum)
        {
            var plotModel2 = new PlotModel();
            var p          = OxyPalettes.HueDistinct(columns.Count);

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

            plotModel2.Axes.Add(categoryAxis);

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

            plotModel2.Axes.Add(linearAxis2);

            for (var i = 1; i < columns.Count; i++)
            {
                var columnSeries2 = new ColumnSeries
                {
                    IsStacked       = true,
                    StrokeThickness = 0,
                    Title           = columns[i].HHNumber
                };
                for (var j = position; j < position + 1440; j += minutesToSum)
                {
                    columnSeries2.Items.Add(new ColumnItem(columns[i].MakeSum(j, minutesToSum)));
                }
                columnSeries2.FillColor = p.Colors[i];
                plotModel2.Series.Add(columnSeries2);
            }
            var path2 = Path.Combine(outputPath, "Plot." + day + "." + minutesToSum + "min.bar.png");

            PngExporter.Export(plotModel2, path2, 3200, 1600, OxyColor.FromRgb(255, 255, 255), 100);
        }
        void Render(SprintData data)
        {
            var model = new PlotModel
            {
                Title = data.Name,
                Axes  =
                {
                    new CategoryAxis {
                        Title = "Day", Position = AxisPosition.Bottom
                    },
                    new LinearAxis
                    {
                        Title              = "Points",
                        Position           = AxisPosition.Left,
                        MinorGridlineStyle = LineStyle.Solid,
                        MajorGridlineStyle = LineStyle.Solid,
                        MinimumPadding     = 0.0,
                        MaximumPadding     = 0.1
                    }
                },
                IsLegendVisible = true,
                LegendPlacement = LegendPlacement.Outside
            };
            var sustain = new SprintCheckpoint
            {
                Done  = 0,
                Total = data.Checkpoints.Select(c => c.Total).LastOrDefault()
            };
            var days            = data.Checkpoints.Concat(Enumerable.Repeat(sustain, data.Duration - data.Checkpoints.Count));
            var completedSeries = new ColumnSeries {
                Title = "Done"
            };

            foreach (var day in days)
            {
                completedSeries.Items.Add(new ColumnItem(day.Done));
            }
            model.Series.Add(completedSeries);
            var totalSeries = new LineSeries {
                Title = "Scope"
            };
            var i = 0;

            foreach (var day in days)
            {
                totalSeries.Points.Add(new DataPoint(i++, day.Total));
            }
            model.Series.Add(totalSeries);
            this.plot.Model = model;
        }
        /// <summary>
        /// This function is called every frame to update the graph's values
        /// </summary>
        public override void Draw()
        {
            base.Draw();
            PlotModel.Title = "%CPU Utilisation";
            CategoryAxis X = new CategoryAxis();
            CategoryAxis Y = new CategoryAxis(); // Create the X and Y axes

            X.Title          = "% Utilised";
            Y.IntervalLength = 1.0;
            PlotModel.Axes.Add(Y);
            PlotModel.Axes.Add(X);                 // add them to the model
            ColumnSeries col = new ColumnSeries(); // create a column

            col.Items.Add(new ColumnItem(100));    // set the value of the column
            col.ColumnWidth = 25;
            col.FillColor   = Colors.CornflowerBlue.ToOxyColor();
            PlotModel.Series.Add(col); // add the column to the graph
        }
        private void InternalMakeBarChart([NotNull] string filename,
                                          [NotNull] string comparisonName,
                                          [NotNull][ItemNotNull] List <BarSeriesEntry> barseries,
                                          [NotNull][ItemNotNull] List <string> categorylabels,
                                          ExportType exportType)
        {
            if (exportType == ExportType.Png && barseries.Max(x => x.Values.Count) > 1000)
            {
                throw new FlaException("export over 1000 values for bar charts only  as svg due to performance");
            }

            try {
                var pm       = CreatePlottingCanvas();
                var min      = barseries.Select(x => x.Values.Min()).Min();
                var yasismin = Math.Min(min, 0);
                MakeCategoryXAxis(pm, categorylabels);
                MakeYAxis(pm, comparisonName, yasismin);

                foreach (var barSeriesEntry in barseries)
                {
                    var cs = new ColumnSeries {
                        Title           = barSeriesEntry.Name,
                        IsStacked       = true,
                        StrokeThickness = 0.0
                    };
                    for (var index = 0; index < barSeriesEntry.Values.Count; index++)
                    {
                        var value = barSeriesEntry.Values[index];
                        cs.Items.Add(new ColumnItem(value));
                    }

                    pm.Series.Add(cs);
                }

                Export(pm, filename, exportType);
            }
            catch (Exception ex) {
                Error("Exception while making a chart: " + ex.Message);
                throw;
            }
        }
Exemple #7
0
        private static void MakeBarPlot([JetBrains.Annotations.NotNull] string outputPath, [ItemNotNull][JetBrains.Annotations.NotNull] List <Column> columns, int position, int day)
        {
            var plotModel2 = new PlotModel();
            // filter significant columns
            var allColumns = new List <Tuple <string, double> >();

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

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

            plotModel2.Axes.Add(cate);

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

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

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

            PngExporter.Export(plotModel2, path2, 3200, 1600, OxyColor.FromRgb(255, 255, 255), 100);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ColumnSeries" /> class.
 /// </summary>
 public ColumnSeries()
 {
     InternalSeries = new OxyPlot.Series.ColumnSeries();
 }
Exemple #9
0
        private void DrawGraph(Artist artist)
        {
            StatModel.Series.Clear();
            StatModel.Axes.Clear();

            var categoryAxis = new OxyPlot.Axes.CategoryAxis
            {
                Position = AxisPosition.Bottom
            };
            var s1 = new OxyPlot.Series.ColumnSeries
            {
                Title       = $"Творчество художника ({artist.full_name})",
                StrokeColor = OxyColors.Black, StrokeThickness = 1
            };

            var paintings = context.Paintings.Where(x => x.artist_id == artist.id &&
                                                    x.year_of_creation != null)
                            .OrderBy(x => x.year_of_creation)
                            .ToArray();

            if (paintings.Any())
            {
                var min = artist.date_of_birth.Value.Year;
                var max = artist.date_of_death?.Year != null ?
                          artist.date_of_death.Value.Year :
                          artist.date_of_birth.Value.AddYears(120).Year;
                int currIndex = 0;
                for (int i = min; ; i += 5)
                {
                    var nextBound = i + 5;
                    if (nextBound > max)
                    {
                        nextBound = max;
                    }
                    int count = 0;
                    while (currIndex < paintings.Length &&
                           paintings[currIndex].year_of_creation <= nextBound)
                    {
                        count++;
                        currIndex++;
                    }
                    s1.Items.Add(new ColumnItem(count));
                    categoryAxis.Labels.Add(i + Environment.NewLine + nextBound);
                    if (nextBound == max)
                    {
                        break;
                    }
                }

                var valueAxis = new OxyPlot.Axes.LinearAxis
                {
                    Position        = AxisPosition.Left,
                    MinimumPadding  = 0,
                    MaximumPadding  = 0.06,
                    AbsoluteMinimum = 0
                };

                StatModel.Series.Add(s1);
                StatModel.Axes.Add(categoryAxis);
                StatModel.Axes.Add(valueAxis);
                StatModel.InvalidatePlot(true);
            }
        }