/// <summary> /// Exports the specified plot model to a xaml file. /// </summary> /// <param name="model">The model.</param> /// <param name="fileName">Name of the file.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="background">The background.</param> public static void Export(PlotModel model, string fileName, double width, double height, OxyColor background) { using (var w = new StreamWriter(fileName)) { w.Write(ExportToString(model, width, height, background)); } }
/// <summary> /// Asserts that a plot is equal to the plot stored in the "baseline" folder. /// 1. Renders the plot to file.svg /// 2. If the baseline does not exist, the current plot is copied to the baseline folder. /// 3. Checks that the svg file is equal to a baseline svg. /// </summary> /// <param name="plot">The plot.</param> /// <param name="name">The name of the baseline file.</param> public static void AreEqual(PlotModel plot, string name) { // string name = new System.Diagnostics.StackFrame(1).GetMethod().Name; string path = name + ".svg"; string baseline = @"baseline\" + path; using (var s = File.Create(path)) { var rc = new ShapesRenderContext(null); SvgExporter.Export(plot, s, 800, 500, false, rc); } if (!Directory.Exists("baseline")) { Directory.CreateDirectory("baseline"); } if (!File.Exists(baseline)) { File.Copy(path, baseline); return; } var baselineSvg = File.ReadAllText(baseline); var actualSvg = File.ReadAllText(path); Assert.IsTrue(string.Equals(baselineSvg, actualSvg), "Actual svg is not equal to baseline (" + Path.GetFullPath(baseline) + ")"); }
/// <summary> /// Exports the specified plot model to a file. /// </summary> /// <param name="model">The model to export.</param> /// <param name="fileName">The file name.</param> /// <param name="width">The width of the output bitmap.</param> /// <param name="height">The height of the output bitmap.</param> /// <param name="background">The background color. The default value is <c>null</c>.</param> /// <param name="resolution">The resolution (resolution). The default value is 96.</param> public static void Export(PlotModel model, string fileName, int width, int height, OxyColor background, int resolution = 96) { using (var s = File.Create(fileName)) { Export(model, s, width, height, background, resolution); } }
/// <summary> /// Exports the specified model to a file. /// </summary> /// <param name="model"> /// The model. /// </param> /// <param name="path"> /// The path. /// </param> /// <param name="width"> /// The width (points). /// </param> /// <param name="height"> /// The height (points). /// </param> public static void Export(PlotModel model, string path, double width, double height) { using (FileStream s = File.Create(path)) { Export(model, s, width, height); } }
/// <summary> /// Export the specified plot model to an xaml string. /// </summary> /// <param name="model">The model.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="background">The background.</param> /// <returns>A xaml string.</returns> public static string ExportToString(PlotModel model, double width, double height, OxyColor background = null) { var g = new Grid(); if (background != null) { g.Background = background.ToBrush(); } var c = new Canvas(); g.Children.Add(c); var size = new Size(width, height); g.Measure(size); g.Arrange(new Rect(0, 0, width, height)); g.UpdateLayout(); var rc = new ShapesRenderContext(c) { UseStreamGeometry = false }; model.Update(); model.Render(rc, width, height); var sb = new StringBuilder(); using (var sw = new StringWriter(sb)) { var xw = XmlWriter.Create(sw, new XmlWriterSettings { Indent = true }); XamlWriter.Save(c, xw); } return sb.ToString(); }
public void ExportToString_TestPlot_ValidSvgString() { var plotModel = new PlotModel { Title = "Test plot" }; plotModel.Series.Add(new FunctionSeries(Math.Sin, 0, Math.PI * 8, 200, "Math.Sin")); var svg = SvgExporter.ExportToString(plotModel, 800, 500, false); SvgAssert.IsValidElement(svg); }
/// <summary> /// Renders the polygon annotation. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The plot model.</param> public override void Render(IRenderContext rc, PlotModel model) { base.Render(rc, model); this.screenRectangle = new OxyRect(this.Transform(this.X - (this.Width / 2), this.Y - (this.Height / 2)), this.Transform(this.X + (this.Width / 2), this.Y + (this.Height / 2))); // clip to the area defined by the axes var clippingRectangle = this.GetClippingRect(); rc.DrawClippedEllipse( clippingRectangle, this.screenRectangle, this.GetSelectableFillColor(this.Fill), this.GetSelectableColor(this.Stroke), this.StrokeThickness); if (!string.IsNullOrEmpty(this.Text)) { var textPosition = this.GetActualTextPosition(() => this.screenRectangle.Center); rc.DrawClippedText( clippingRectangle, textPosition, this.Text, this.ActualTextColor, this.ActualFont, this.ActualFontSize, this.ActualFontWeight, this.TextRotation, this.TextHorizontalAlignment, this.TextVerticalAlignment); } }
public void AddAxisTwice() { var model = new PlotModel(); var axis = new LinearAxis(); model.Axes.Add(axis); Assert.Throws<InvalidOperationException>(() => model.Axes.Add(axis)); }
/// <summary> /// Renders the polygon annotation. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The plot model.</param> public override void Render(IRenderContext rc, PlotModel model) { base.Render(rc, model); this.screenPosition = this.Transform(this.X, this.Y); // clip to the area defined by the axes var clippingRectangle = this.GetClippingRect(); rc.DrawMarker(clippingRectangle, this.screenPosition, this.Shape, this.CustomOutline, this.Size, this.Fill, this.Stroke, this.StrokeThickness); if (!string.IsNullOrEmpty(this.Text)) { var dx = -(int)this.TextHorizontalAlignment * (this.Size + this.TextMargin); var dy = -(int)this.TextVerticalAlignment * (this.Size + this.TextMargin); var textPosition = this.screenPosition + new ScreenVector(dx, dy); rc.DrawClippedText( clippingRectangle, textPosition, this.Text, this.ActualTextColor, this.ActualFont, this.ActualFontSize, this.ActualFontWeight, this.TextRotation, this.TextHorizontalAlignment, this.TextVerticalAlignment); } }
/// <summary> /// Prints the specified plot model. /// </summary> /// <param name="model">The model.</param> /// <param name="width">The width (using the actual media width if not specified).</param> /// <param name="height">The height (using the actual media height if not specified).</param> public static void Print(PlotModel model, double width = double.NaN, double height = double.NaN) { PrintDocumentImageableArea area = null; var xpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(ref area); if (xpsDocumentWriter != null) { if (double.IsNaN(width)) { width = area.MediaSizeWidth; } if (double.IsNaN(height)) { height = area.MediaSizeHeight; } var canvas = new Canvas { Width = width, Height = height }; canvas.Measure(new Size(width, height)); canvas.Arrange(new Rect(0, 0, width, height)); var rc = new ShapesRenderContext(canvas); model.Update(); model.Render(rc, width, height); canvas.UpdateLayout(); xpsDocumentWriter.Write(canvas); } }
public static void Save(PlotModel model, string path, double width, double height) { using (var s = File.OpenWrite(path)) { Save(model, s, width, height); } }
public void B11_Backgrounds() { var plot = new PlotModel("Backgrounds"); plot.Axes.Add(new LinearAxis(AxisPosition.Bottom, "X-axis")); var yaxis1 = new LinearAxis(AxisPosition.Left, "Y1") { Key = "Y1", StartPosition = 0, EndPosition = 0.5 }; var yaxis2 = new LinearAxis(AxisPosition.Left, "Y2") { Key = "Y2", StartPosition = 0.5, EndPosition = 1 }; plot.Axes.Add(yaxis1); plot.Axes.Add(yaxis2); Action<LineSeries> addExamplePoints = ls => { ls.Points.Add(new DataPoint(3, 13)); ls.Points.Add(new DataPoint(10, 47)); ls.Points.Add(new DataPoint(30, 23)); ls.Points.Add(new DataPoint(40, 65)); ls.Points.Add(new DataPoint(80, 10)); }; var ls1 = new LineSeries { Background = OxyColors.LightSeaGreen, YAxisKey = "Y1" }; addExamplePoints(ls1); plot.Series.Add(ls1); var ls2 = new LineSeries { Background = OxyColors.LightSkyBlue, YAxisKey = "Y2" }; addExamplePoints(ls2); plot.Series.Add(ls2); // OxyAssert.AreEqual(plot, "B11"); }
public void AddAxisToDifferentModels() { var model1 = new PlotModel(); var model2 = new PlotModel(); var axis = new LinearAxis(); model1.Axes.Add(axis); Assert.Throws<InvalidOperationException>(() => model2.Axes.Add(axis)); }
/// <summary> /// Exports the specified plot model to a xaml file. /// </summary> /// <param name="model">The model.</param> /// <param name="fileName">Name of the file.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="background">The background.</param> public static void Export(PlotModel model, string fileName, double width, double height, OxyColor background) { using (var sw = new StreamWriter(fileName)) { var xw = XmlWriter.Create(sw, new XmlWriterSettings { Indent = true }); Export(model, xw, width, height, background); } }
public void ExportToString_TestPlot_ValidSvgString() { var plotModel = new PlotModel("Test plot"); plotModel.Series.Add(new FunctionSeries(Math.Sin, 0, Math.PI * 8, 200, "Math.Sin")); var rc = new ShapesRenderContext(null); var svg = SvgExporter.ExportToString(plotModel, 800, 500, false, rc); SvgAssert.IsValidElement(svg); }
public void GetFromOtherThread() { var model = new PlotModel(); var plotView = new PlotView { Model = model }; PlotModel actualModel = null; Task.Factory.StartNew(() => actualModel = plotView.ActualModel).Wait(); Assert.AreEqual(model, actualModel); }
/// <summary> /// Exports the specified plot model to a stream. /// </summary> /// <param name="model">The model.</param> /// <param name="stream">The stream.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="background">The background.</param> /// <param name="resolution">The resolution.</param> public static void Export(PlotModel model, Stream stream, int width, int height, OxyColor background = null, int resolution = 96) { var bmp = ExportToBitmap(model, width, height, background); var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); encoder.Save(stream); }
/// <summary> /// Exports the specified model to a stream. /// </summary> /// <param name="model"> /// The model. /// </param> /// <param name="s"> /// The stream. /// </param> /// <param name="width"> /// The width (points). /// </param> /// <param name="height"> /// The height (points). /// </param> public static void Export(PlotModel model, Stream s, double width, double height) { using (var rc = new PdfRenderContext(width, height, model.Background)) { model.Update(); model.Render(rc, width, height); rc.Save(s); } }
public void Export_Unicode() { var model = new PlotModel { Title = "Unicode support ☺", DefaultFont = "Arial" }; model.Axes.Add(new LinearAxis { Title = "λ", Position = AxisPosition.Bottom }); model.Axes.Add(new LinearAxis { Title = "Ж", Position = AxisPosition.Left }); var exporter = new PdfExporter { Width = 400, Height = 400 }; using (var stream = File.OpenWrite("Unicode.pdf")) { exporter.Export(model, stream); } }
public void Export_TestPlot_ValidSvgString() { var plotModel = new PlotModel { Title = "Test plot" }; const string FileName = "SvgExporterTests_Plot1.svg"; plotModel.Series.Add(new FunctionSeries(Math.Sin, 0, Math.PI * 8, 200, "Math.Sin")); using (var s = File.Create(FileName)) { SvgExporter.Export(plotModel, s, 800, 500, true); } SvgAssert.IsValidFile(FileName); }
public void Export_TestPlot_ValidSvgString() { var plotModel = new PlotModel("Test plot"); const string FileName = "SvgExporterTests_Plot1.svg"; plotModel.Series.Add(new FunctionSeries(Math.Sin, 0, Math.PI * 8, 200, "Math.Sin")); using (var s = File.Create(FileName)) { var rc = new ShapesRenderContext(null); SvgExporter.Export(plotModel, s, 800, 500, true, rc); } SvgAssert.IsValidFile(FileName); }
public void AutoPlotMargins() { var plot = new PlotModel { Title = "Auto PlotMargins" }; var verticalAxis = new LinearAxis { Position = AxisPosition.Left }; var horizontalAxis = new LinearAxis { Position = AxisPosition.Bottom }; plot.Axes.Add(verticalAxis); plot.Axes.Add(horizontalAxis); plot.UpdateAndRenderToNull(800, 600); Assert.That(plot.ActualPlotMargins.Left, Is.EqualTo(26).Within(1), "left"); Assert.That(plot.ActualPlotMargins.Top, Is.EqualTo(0).Within(1), "top"); Assert.That(plot.ActualPlotMargins.Right, Is.EqualTo(0).Within(1), "right"); Assert.That(plot.ActualPlotMargins.Bottom, Is.EqualTo(21).Within(1), "bottom"); }
public void PlotControl_CollectedPlotControl_ReferenceShouldNotBeAlive() { var plot = Substitute.For<IPlotView>(); var pm = new PlotModel(); ((IPlotModel)pm).AttachPlotView(plot); Assert.IsNotNull(pm.PlotView); // ReSharper disable once RedundantAssignment plot = null; GC.Collect(); // Verify that the reference is lost Assert.IsNull(pm.PlotView); }
/// <summary> /// Initializes a new instance of the <see cref="Plot" /> class. /// </summary> public Plot() { this.series = new ObservableCollection<Series>(); this.axes = new ObservableCollection<Axis>(); this.annotations = new ObservableCollection<Annotation>(); this.series.CollectionChanged += this.OnSeriesChanged; this.axes.CollectionChanged += this.OnAxesChanged; this.annotations.CollectionChanged += this.OnAnnotationsChanged; this.defaultController = new PlotController(); this.internalModel = new PlotModel(); ((IPlotModel)this.internalModel).AttachPlotView(this); }
public void A00_NoAxesDefined() { var plot = new PlotModel { Title = "Simple plot without axes defined" }; var ls = new LineSeries(); ls.Points.Add(new DataPoint(3, 13)); ls.Points.Add(new DataPoint(10, 47)); ls.Points.Add(new DataPoint(30, 23)); ls.Points.Add(new DataPoint(40, 65)); ls.Points.Add(new DataPoint(80, 10)); plot.Series.Add(ls); OxyAssert.AreEqual(plot, "A00"); }
public void A11_SmallRangeAxis() { var plot = new PlotModel { Title = "Small range axis", PlotMargins = new OxyThickness(80, 60, 50, 50) }; plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis" }); plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis" }); var ls = new LineSeries(); ls.Points.Add(new DataPoint(1e-40, 1e-38)); ls.Points.Add(new DataPoint(1.2e-40, 1.9e-38)); ls.Points.Add(new DataPoint(1.4e-40, 3.3e-38)); ls.Points.Add(new DataPoint(1.6e-40, 2.5e-38)); plot.Series.Add(ls); OxyAssert.AreEqual(plot, "A11"); }
public void A01_SimpleAxes() { var plot = new PlotModel { Title = "Simple plot" }; plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis" }); plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis" }); var ls = new LineSeries(); ls.Points.Add(new DataPoint(3, 13)); ls.Points.Add(new DataPoint(10, 47)); ls.Points.Add(new DataPoint(30, 23)); ls.Points.Add(new DataPoint(40, 65)); ls.Points.Add(new DataPoint(80, 10)); plot.Series.Add(ls); OxyAssert.AreEqual(plot, "A01"); }
public void A02_ReversedAxes() { var plot = new PlotModel { Title = "Reversed axes" }; plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis", StartPosition = 1, EndPosition = 0 }); plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis", StartPosition = 1, EndPosition = 0 }); var ls = new LineSeries(); ls.Points.Add(new DataPoint(0, 13)); ls.Points.Add(new DataPoint(10, 47)); ls.Points.Add(new DataPoint(30, 23)); ls.Points.Add(new DataPoint(40, 65)); ls.Points.Add(new DataPoint(80, 10)); plot.Series.Add(ls); OxyAssert.AreEqual(plot, "A02"); }
/// <summary> /// Renders the polygon annotation. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The plot model.</param> public override void Render(IRenderContext rc, PlotModel model) { base.Render(rc, model); if (this.Points == null) { return; } // transform to screen coordinates this.screenPoints = this.Points.Select(this.Transform).ToList(); if (this.screenPoints.Count == 0) { return; } // clip to the area defined by the axes var clippingRectangle = this.GetClippingRect(); const double MinimumSegmentLength = 4; rc.DrawClippedPolygon( clippingRectangle, this.screenPoints, MinimumSegmentLength * MinimumSegmentLength, this.GetSelectableFillColor(this.Fill), this.GetSelectableColor(this.Stroke), this.StrokeThickness, this.LineStyle, this.LineJoin); if (!string.IsNullOrEmpty(this.Text)) { var textPosition = this.GetActualTextPosition(() => ScreenPointHelper.GetCentroid(this.screenPoints)); rc.DrawClippedText( clippingRectangle, textPosition, this.Text, this.ActualTextColor, this.ActualFont, this.ActualFontSize, this.ActualFontWeight, this.TextRotation, this.TextHorizontalAlignment, this.TextVerticalAlignment); } }
/// <summary> /// Renders the polygon annotation. /// </summary> /// <param name="rc">The render context.</param> /// <param name="model">The plot model.</param> public override void Render(IRenderContext rc, PlotModel model) { base.Render(rc, model); double x0 = double.IsNaN(this.MinimumX) || this.MinimumX.Equals(double.MinValue) ? this.XAxis.ActualMinimum : this.MinimumX; double x1 = double.IsNaN(this.MaximumX) || this.MaximumX.Equals(double.MaxValue) ? this.XAxis.ActualMaximum : this.MaximumX; double y0 = double.IsNaN(this.MinimumY) || this.MinimumY.Equals(double.MinValue) ? this.YAxis.ActualMinimum : this.MinimumY; double y1 = double.IsNaN(this.MaximumY) || this.MaximumY.Equals(double.MaxValue) ? this.YAxis.ActualMaximum : this.MaximumY; this.screenRectangle = new OxyRect(this.Transform(x0, y0), this.Transform(x1, y1)); // clip to the area defined by the axes var clippingRectangle = this.GetClippingRect(); rc.DrawClippedRectangle( clippingRectangle, this.screenRectangle, this.GetSelectableFillColor(this.Fill), this.GetSelectableColor(this.Stroke), this.StrokeThickness); if (!string.IsNullOrEmpty(this.Text)) { var textPosition = this.GetActualTextPosition(() => this.screenRectangle.Center); rc.DrawClippedText( clippingRectangle, textPosition, this.Text, this.ActualTextColor, this.ActualFont, this.ActualFontSize, this.ActualFontWeight, this.TextRotation, HorizontalAlignment.Center, VerticalAlignment.Middle); } }
public void InitSimulateBatchTab() { SimulateBatchMeanFreePathPlotModel = new PlotModel { Title = "Зависимость средней длины свободного пробега до рассеяния от количества итераций", //LegendTitle = "Legend", //LegendOrientation = LegendOrientation.Vertical, //LegendPlacement = LegendPlacement.Inside, //LegendBackground = OxyColor.FromAColor(200, OxyColors.White), //LegendBorder = OxyColors.Black, Axes = { new LinearAxis { Position = AxisPosition.Bottom, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Количество судеб нейтронов, ед" }, new LinearAxis { Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Средняя длина свободного\nпробега до рассеяния, см" } } }; SimulateBatchMeanPathPlotModel = new PlotModel { Title = "Зависимость средней длины свободного пробега до поглощения от количества итераций", //LegendTitle = "Legend", //LegendOrientation = LegendOrientation.Vertical, //LegendPlacement = LegendPlacement.Inside, //LegendBackground = OxyColor.FromAColor(200, OxyColors.White), //LegendBorder = OxyColors.Black, Axes = { new LinearAxis { Position = AxisPosition.Bottom, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Количество итераций, ед" }, new LinearAxis { Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Средняя длина свободного\nпробега до поглощения, см" } } }; SimulateBatchDistributionPlotModel = new PlotModel { Title = "Распределение плотности\nпотока нейтронов", Axes = { new LinearAxis { Position = AxisPosition.Bottom, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Плотность потока нейтронов,\nед/(см^2*с)" }, new CategoryAxis { Position = AxisPosition.Left, Title = "Растояние от точечного источника, см" } } }; }
private PlotModel SetupTotalPagesReadByLanguagePlot() { // Create the plot model var newPlot = new PlotModel { Title = "Total Pages Read by Language With Time Plot" }; OxyPlotUtilities.SetupPlotLegend(newPlot, "Total Pages Read by Language With Time Plot"); SetupTotalPagesReadKeyVsTimeAxes(newPlot); // get the languages (in order) BooksDelta.DeltaTally latestTally = _mainModel.BookDeltas.Last().OverallTally; List <string> languages = (from item in latestTally.LanguageTotals orderby item.Item2 descending select item.Item1).ToList(); // create the series for the languages List <KeyValuePair <string, LineSeries> > languagesLineSeries = new List <KeyValuePair <string, LineSeries> >(); for (int i = 0; i < languages.Count; i++) { LineSeries languageLineSeries; OxyPlotUtilities.CreateLongLineSeries(out languageLineSeries, ChartAxisKeys.DateKey, ChartAxisKeys.TotalBooksReadKey, languages[i], i, 128); languagesLineSeries.Add( new KeyValuePair <string, LineSeries>(languages[i], languageLineSeries)); //if (i > 1) break; } // loop through the deltas adding points for each of the items to the lines foreach (var delta in _mainModel.BookDeltas) { var date = DateTimeAxis.ToDouble(delta.Date); foreach (var languageLine in languagesLineSeries) { double ttl = 0.0; foreach (var langTotal in delta.OverallTally.LanguageTotals) { if (langTotal.Item1 == languageLine.Key) { ttl = langTotal.Item4; } } languageLine.Value.Points.Add(new DataPoint(date, ttl)); } } IList <LineSeries> lineSeriesSet = (from item in languagesLineSeries select item.Value).ToList(); var stackSeries = OxyPlotUtilities.StackLineSeries(lineSeriesSet); // add them to the plot foreach (var languageItems in stackSeries) { newPlot.Series.Add(languageItems); } // finally update the model with the new plot return(newPlot); }
public AnalysisViewModel() { this.plotModelGood = new PlotModel { Title = "A" }; //良かったこと var xaxis = new CategoryAxis(); xaxis.Position = AxisPosition.Bottom; xaxis.MajorGridlineStyle = LineStyle.Solid; xaxis.MinorGridlineStyle = LineStyle.Dot; xaxis.Labels.Add("10/06"); xaxis.Labels.Add("10/07"); xaxis.Labels.Add("10/08"); xaxis.Labels.Add("10/09"); xaxis.Labels.Add("10/10"); xaxis.Labels.Add("10/11"); xaxis.Labels.Add("10/12"); xaxis.FontSize = 8.0; var yaxis = new LinearAxis(); yaxis.Position = AxisPosition.Left; yaxis.MajorGridlineStyle = LineStyle.Dot; yaxis.MinorGridlineStyle = LineStyle.Dot; yaxis.FontSize = 8.0; var columnSeriesGood = new ColumnSeries(); columnSeriesGood.Items.Add(new ColumnItem(5)); columnSeriesGood.Items.Add(new ColumnItem(8)); columnSeriesGood.Items.Add(new ColumnItem(2)); columnSeriesGood.Items.Add(new ColumnItem(12)); columnSeriesGood.Items.Add(new ColumnItem(4)); columnSeriesGood.Items.Add(new ColumnItem(1)); columnSeriesGood.Items.Add(new ColumnItem(9)); plotModelGood.Axes.Add(xaxis); plotModelGood.Axes.Add(yaxis); plotModelGood.Series.Add(columnSeriesGood); plotModel = new PlotModel { Title = "B" }; //気分 var xaxisLine = new CategoryAxis(); xaxisLine.Position = AxisPosition.Bottom; xaxisLine.MajorGridlineStyle = LineStyle.Solid; xaxisLine.MinorGridlineStyle = LineStyle.Dot; xaxisLine.Labels.Add("10/06"); xaxisLine.Labels.Add("10/07"); xaxisLine.Labels.Add("10/08"); xaxisLine.Labels.Add("10/09"); xaxisLine.Labels.Add("10/10"); xaxisLine.Labels.Add("10/11"); xaxisLine.Labels.Add("10/12"); xaxisLine.FontSize = 8.0; var yaxisLine = new LinearAxis(); yaxisLine.Position = AxisPosition.Left; yaxisLine.MajorGridlineStyle = LineStyle.Dot; yaxisLine.MinorGridlineStyle = LineStyle.Dot; yaxisLine.FontSize = 8.0; plotModel.Axes.Add(xaxisLine); plotModel.Axes.Add(yaxisLine); plotModel.Series.Add(new LineSeries { Points = { new DataPoint(0, 2.5), new DataPoint(1, 3.0), new DataPoint(2, 4.8), new DataPoint(3, 2.2), new DataPoint(4, 3.4), new DataPoint(5, 5.0), new DataPoint(6, 1.2), } }); plotModelComposite = new PlotModel { Title = "C" }; // 複合 var xaxisComposite = new CategoryAxis(); xaxisComposite.Position = AxisPosition.Bottom; xaxisComposite.MajorGridlineStyle = LineStyle.Solid; xaxisComposite.MinorGridlineStyle = LineStyle.Dot; xaxisComposite.Labels.Add("10/06"); xaxisComposite.Labels.Add("10/07"); xaxisComposite.Labels.Add("10/08"); xaxisComposite.Labels.Add("10/09"); xaxisComposite.Labels.Add("10/10"); xaxisComposite.Labels.Add("10/11"); xaxisComposite.Labels.Add("10/12"); xaxisComposite.FontSize = 8.0; var yaxisComposite1 = new LinearAxis(); yaxisComposite1.Position = AxisPosition.Left; yaxisComposite1.MajorGridlineStyle = LineStyle.None; yaxisComposite1.MinorGridlineStyle = LineStyle.None; yaxisComposite1.Key = "1"; yaxisComposite1.FontSize = 8.0; var yaxisComposite2 = new LinearAxis(); yaxisComposite2.Position = AxisPosition.Right; yaxisComposite2.Maximum = 5; yaxisComposite2.Minimum = 0; yaxisComposite2.MajorGridlineStyle = LineStyle.None; yaxisComposite2.MinorGridlineStyle = LineStyle.None; yaxisComposite2.Key = "2"; yaxisComposite2.FontSize = 8.0; var columnSeriesComposite = new ColumnSeries(); columnSeriesComposite.Items.Add(new ColumnItem(5)); columnSeriesComposite.Items.Add(new ColumnItem(8)); columnSeriesComposite.Items.Add(new ColumnItem(2)); columnSeriesComposite.Items.Add(new ColumnItem(12)); columnSeriesComposite.Items.Add(new ColumnItem(4)); columnSeriesComposite.Items.Add(new ColumnItem(1)); columnSeriesComposite.Items.Add(new ColumnItem(9)); plotModelComposite.Axes.Add(xaxisComposite); plotModelComposite.Axes.Add(yaxisComposite1); plotModelComposite.Axes.Add(yaxisComposite2); columnSeriesComposite.YAxisKey = "1"; plotModelComposite.Series.Add(columnSeriesComposite); plotModelComposite.Series.Add(new LineSeries { Points = { new DataPoint(0, 2.5), new DataPoint(1, 3.0), new DataPoint(2, 4.8), new DataPoint(3, 2.2), new DataPoint(4, 3.4), new DataPoint(5, 5.0), new DataPoint(6, 1.2), }, YAxisKey = "2" }); }
private void showButton_Click(object sender, EventArgs e) { if (originalObject == null) { MessageBox.Show("Объект не был сгенерирован", "Ошибка"); return; } double x1, x2, delta; int n; try { n = Convert.ToInt32(nTextBox.Text); x1 = Convert.ToDouble(x1TextBox.Text); x2 = Convert.ToDouble(x2TextBox.Text); } catch (FormatException) { MessageBox.Show("Введены некорректные данные.", "Ошибка ввода"); return; } delta = Math.Abs(x1 - x2) / n; FunctionSeries reg = null; ScatterSeries orObj = new ScatterSeries() { Title = "Объект с помехой", MarkerType = MarkerType.Circle }; foreach (var v in originalObject) { orObj.Points.Add(new ScatterPoint(v.Key, v.Value, 1.8)); } FunctionSeries f = new FunctionSeries(T => { return(function(T)); }, x1, x2, delta) { Title = "Объект" }; PlotModel plot = new PlotModel() { Title = "График" }; PlotView view = new PlotView() { Dock = DockStyle.Fill, BackColor = Color.White, Model = plot }; plot.Series.Add(orObj); plot.Series.Add(f); results.Controls.Add(view); if (models != null) { string typeName = ""; for (int i = 0; i < types.Count; i++) { switch (types.ElementAt(i)) { case ModelBuilding.CoreType.Recatangle: typeName = rectCheckBox.Text; break; case ModelBuilding.CoreType.Triangle: typeName = triCheckBox.Text; break; case ModelBuilding.CoreType.Parabola: typeName = parCheckBox.Text; break; case ModelBuilding.CoreType.Cube: typeName = cubeCheckBox.Text; break; } reg = new FunctionSeries() { Title = "Регрессия (" + typeName + ")" }; for (int j = 0; j < models[i].Count; j++) { reg.Points.Add(new DataPoint(models[i].ElementAt(j).Key, models[i].ElementAt(j).Value)); } plot.Series.Add(reg); } } results.Refresh(); results.ShowDialog(); results.Controls.Clear(); }
private void DisplayPage(int pageNo) { if (_pdfDocumentModel == null) { return; } var page = _pdfDocumentModel.GetPage(pageNo); var pageInfoModel = page.GetPageInfo(); // Plot height distrib HeightHistoPlotModel = pageInfoModel.HeightDistribution.GetPlotModel("Letters height distribution"); WidthHistoPlotModel = pageInfoModel.WidthDistribution.GetPlotModel("Letters width distribution"); // Plot page var pagePlotModel = new PlotModel { IsLegendVisible = false }; pagePlotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 0, Maximum = page.Height }); pagePlotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = 0, Maximum = page.Width }); switch (BboxLevel) { case "Words": foreach (var word in page.GetWords()) { var series1 = new LineSeries { Title = GetShorterText(word.Text), LineStyle = LineStyle.Solid, Color = OxyColors.Red }; var bbox = word.BoundingBox; series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomRight)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopRight)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopLeft)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft)); pagePlotModel.Series.Add(series1); } break; case "Lines": foreach (var line in page.GetTextBlocks().SelectMany(b => b.TextLines)) { var series1 = new LineSeries { Title = GetShorterText(line.Text), LineStyle = LineStyle.Solid, Color = OxyColors.Red }; var bbox = line.BoundingBox; series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomRight)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopRight)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopLeft)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft)); pagePlotModel.Series.Add(series1); } break; case "Paragraphs": foreach (var block in page.GetTextBlocks()) { var series1 = new LineSeries { Title = GetShorterText(block.Text), LineStyle = LineStyle.Solid, Color = OxyColors.Red }; var bbox = block.BoundingBox; series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomRight)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopRight)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopLeft)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft)); pagePlotModel.Series.Add(series1); } break; default: foreach (var letter in page.GetLetters()) { var series1 = new LineSeries { Title = letter.Value, LineStyle = LineStyle.Solid, Color = OxyColors.Red }; var bbox = letter.GlyphRectangle; series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomRight)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopRight)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopLeft)); series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft)); pagePlotModel.Series.Add(series1); } break; } // Add background image try { using (var stream = _pdfImageConverter.GetPageStream(pageNo, 2)) { PageImage = new OxyImage(stream); } pagePlotModel.Annotations.Add(new ImageAnnotation { ImageSource = PageImage, Opacity = 0.5, X = new PlotLength(0, PlotLengthUnit.Data), Y = new PlotLength(0, PlotLengthUnit.Data), Width = new PlotLength(page.Width, PlotLengthUnit.Data), Height = new PlotLength(page.Height, PlotLengthUnit.Data), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom }); } catch (Exception) { throw; } this.PagePlotModel = pagePlotModel; }
public static void RemoveAxis(this PlotModel model) { if (model.Axes.Count == 0) { model.Axes.Add(new LinearAxis() { TicklineColor = OxyColors.Transparent, MajorTickSize = 0.0, MinorTickSize = 0.0, TickStyle = TickStyle.None, TextColor = OxyColors.Transparent, Position = AxisPosition.Bottom, IsAxisVisible = false }); model.Axes.Add(new LinearAxis() { TicklineColor = OxyColors.Transparent, MajorTickSize = 0.0, MinorTickSize = 0.0, TickStyle = TickStyle.None, TextColor = OxyColors.Transparent, Position = AxisPosition.Left, IsAxisVisible = false }); } else if (model.Axes.Count == 1) { if (model.Axes[0].Position == AxisPosition.Bottom) { model.Axes.Add(new LinearAxis() { TicklineColor = OxyColors.Transparent, MajorTickSize = 0.0, MinorTickSize = 0.0, TickStyle = TickStyle.None, TextColor = OxyColors.Transparent, Position = AxisPosition.Left, IsAxisVisible = false }); } else if (model.Axes[0].Position == AxisPosition.Left) { model.Axes.Add(new LinearAxis() { TicklineColor = OxyColors.Transparent, MajorTickSize = 0.0, MinorTickSize = 0.0, TickStyle = TickStyle.None, TextColor = OxyColors.Transparent, Position = AxisPosition.Bottom, IsAxisVisible = false }); } foreach (var axis in model.Axes) { axis.TicklineColor = OxyColors.Transparent; axis.MajorTickSize = 0.0; axis.MinorTickSize = 0.0; axis.TickStyle = TickStyle.None; axis.TextColor = OxyColors.Transparent; axis.IsAxisVisible = false; } } else { foreach (var axis in model.Axes) { axis.TicklineColor = OxyColors.Transparent; axis.MajorTickSize = 0.0; axis.MinorTickSize = 0.0; axis.TickStyle = TickStyle.None; axis.TextColor = OxyColors.Transparent; axis.IsAxisVisible = false; } } model.PlotAreaBorderColor = OxyColors.Transparent; }
private static PlotModel CreateModelWithNegativeValues(bool stacked, string title) { var model = new PlotModel { Title = title, LegendPlacement = LegendPlacement.Outside, LegendPosition = LegendPosition.BottomCenter, LegendOrientation = LegendOrientation.Horizontal, LegendBorderThickness = 0 }; var s1 = new TSeries { Title = "Series 1", IsStacked = stacked, StrokeColor = OxyColors.Black, StrokeThickness = 1 }; s1.Items.Add(new TItem { Value = 25 }); s1.Items.Add(new TItem { Value = 137 }); s1.Items.Add(new TItem { Value = 18 }); s1.Items.Add(new TItem { Value = 40 }); var s2 = new TSeries { Title = "Series 2", IsStacked = stacked, StrokeColor = OxyColors.Black, StrokeThickness = 1 }; s2.Items.Add(new TItem { Value = -12 }); s2.Items.Add(new TItem { Value = -14 }); s2.Items.Add(new TItem { Value = -120 }); s2.Items.Add(new TItem { Value = -26 }); var s3 = new TSeries { Title = "Series 3", IsStacked = stacked, StrokeColor = OxyColors.Black, StrokeThickness = 1 }; s3.Items.Add(new TItem { Value = 21 }); s3.Items.Add(new TItem { Value = 8 }); s3.Items.Add(new TItem { Value = 48 }); s3.Items.Add(new TItem { Value = 3 }); var s4 = new TSeries { Title = "Series 4", IsStacked = stacked, StrokeColor = OxyColors.Black, StrokeThickness = 1 }; s4.Items.Add(new TItem { Value = -8 }); s4.Items.Add(new TItem { Value = -21 }); s4.Items.Add(new TItem { Value = -3 }); s4.Items.Add(new TItem { Value = -48 }); var categoryAxis = new CategoryAxis { Position = CategoryAxisPosition() }; categoryAxis.Labels.Add("Category A"); categoryAxis.Labels.Add("Category B"); categoryAxis.Labels.Add("Category C"); categoryAxis.Labels.Add("Category D"); var valueAxis = new LinearAxis { Position = ValueAxisPosition(), MinimumPadding = 0.06, MaximumPadding = 0.06, ExtraGridlines = new[] { 0.0 }, ExtraGridlineStyle = LineStyle.Solid, ExtraGridlineColor = OxyColors.Black, ExtraGridlineThickness = 1 }; model.Series.Add(s1); model.Series.Add(s2); model.Series.Add(s3); model.Series.Add(s4); model.Axes.Add(categoryAxis); model.Axes.Add(valueAxis); return(model); }
public static void Plot3SeriaKolumnowy(string xTitle, string yTitle, OxyColor color1, OxyColor color2, OxyColor color3, int[,] histogramValues, string label1, string label2, string label3, PlotModel histogramModel, bool chkR, bool chkG, bool chkB) { histogramModel.Series.Clear(); histogramModel.Axes.Clear(); var l = histogramValues.Length / 3; var categoryAxisRGB = new CategoryAxis { GapWidth = 0, IsAxisVisible = false, IsZoomEnabled = false, MinorStep = 1 }; var s1 = new ColumnSeries { Title = label1, StrokeColor = color1, FillColor = color1, StrokeThickness = 1 }; for (int i = 0; i < l; i++) { int y_val = histogramValues[i, 0]; categoryAxisRGB.Labels.Add(i.ToString()); s1.Items.Add(new ColumnItem { Value = y_val, Color = color1 }); } var s2 = new ColumnSeries { Title = label2, StrokeColor = color2, FillColor = color2, StrokeThickness = 1 }; for (int i = 0; i < l; i++) { int y_val = histogramValues[i, 1]; s2.Items.Add(new ColumnItem { Value = y_val, Color = color2 }); } var s3 = new ColumnSeries { Title = label3, StrokeColor = color3, FillColor = color3, StrokeThickness = 1 }; for (int i = 0; i < l; i++) { int y_val = histogramValues[i, 2]; s3.Items.Add(new ColumnItem { Value = y_val, Color = color3 }); } var linearAxisRGB1 = new LinearAxis { Maximum = l, Minimum = 0, IsZoomEnabled = false, Position = AxisPosition.Bottom, Title = xTitle }; var linearAxisRGB2 = new LinearAxis { AbsoluteMinimum = 0, MinimumPadding = 0, IsZoomEnabled = false, Title = yTitle }; histogramModel.Axes.Add(categoryAxisRGB); histogramModel.Axes.Add(linearAxisRGB1); histogramModel.Axes.Add(linearAxisRGB2); if (chkR) { histogramModel.Series.Add(s1); } if (chkG) { histogramModel.Series.Add(s2); } if (chkB) { histogramModel.Series.Add(s3); } histogramModel.InvalidatePlot(true); }
public static void Plot3Serie(string xTitle, string yTitle, OxyColor color1, OxyColor color2, OxyColor color3, string label1, string label2, string label3, PlotModel plotModel, int[,] histogramValues) { plotModel.Series.Clear(); plotModel.Axes.Clear(); plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = xTitle }); plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = yTitle }); var l = histogramValues.Length / 3; var plotR_Series = new LineSeries { Title = label1, StrokeThickness = 2, MarkerSize = 2, Color = color1 }; for (int i = 0; i < l; i++) { int y_val = histogramValues[i, 0]; plotR_Series.Points.Add(new DataPoint(i, y_val)); } plotModel.Series.Add(plotR_Series); var plotG_Series = new LineSeries { Title = label2, StrokeThickness = 2, MarkerSize = 2, Color = color2 }; for (int i = 0; i < l; i++) { int y_val = histogramValues[i, 1]; plotG_Series.Points.Add(new DataPoint(i, y_val)); } plotModel.Series.Add(plotG_Series); var plotB_Series = new LineSeries { Title = label3, StrokeThickness = 2, MarkerSize = 2, Color = color3 }; for (int i = 0; i < l; i++) { int y_val = histogramValues[i, 2]; plotB_Series.Points.Add(new DataPoint(i, y_val)); } plotModel.Series.Add(plotB_Series); plotModel.InvalidatePlot(true); }
public MemoryStream KayraKuva(Window win) { if (win.Name == "kiviohjelma") { Kiviohjelma _kivi = (Kiviohjelma)win; List <SeulakirjastoIndex> selist = new List <SeulakirjastoIndex>(); //Seulat joita on käytetty laskennassa, eli X-arvot. List <SeulaLapPros> tulist = new List <SeulaLapPros>(); //Läpäisyprosenttitulokset, eli Y-arvot List <Seulakirjasto> selistALL = new List <Seulakirjasto>(); //Kaikki seulat mitä on valittuna. Tehdään täysi X-akseli tällä. List <SeulaLapPros> sisOhjeAla = new List <SeulaLapPros>(); //Sisempi ohjealue, alempi ohje% List <SeulaLapPros> sisOhjeYla = new List <SeulaLapPros>(); //Sisempi ohjealue, ylempi ohje% List <SeulaLapPros> uloOhjeAla = new List <SeulaLapPros>(); //Ulompi ohjealue, alempi ohje% List <SeulaLapPros> uloOhjeYla = new List <SeulaLapPros>(); //Ulompi ohjealue, ylempi ohje% //Lukee tarvittavat prosenttiarvot ja lisää ne tulist-listaan //Ottaa valitut seulat ohjelmasta, ottaa talteen niiden sijainnin järjestyslukuna ja laittaa ne selist-listaan //Tuloksissa saattaa olla välejä (kaikkeja rivejä ei täytetty) joten koodi tarkistaa sen myös if (_kivi.lapaisypros1.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 0, tulos = Convert.ToDouble(_kivi.lapaisypros1.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula1.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 17, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros2.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 1, tulos = Convert.ToDouble(_kivi.lapaisypros2.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula2.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 16, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros3.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 2, tulos = Convert.ToDouble(_kivi.lapaisypros3.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula3.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 15, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros4.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 3, tulos = Convert.ToDouble(_kivi.lapaisypros4.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula4.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 14, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros5.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 4, tulos = Convert.ToDouble(_kivi.lapaisypros5.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula5.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 13, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros6.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 5, tulos = Convert.ToDouble(_kivi.lapaisypros6.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula6.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 12, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros7.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 6, tulos = Convert.ToDouble(_kivi.lapaisypros7.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula7.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 11, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros8.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 7, tulos = Convert.ToDouble(_kivi.lapaisypros8.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula8.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 10, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros9.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 8, tulos = Convert.ToDouble(_kivi.lapaisypros9.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula9.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 9, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros10.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 9, tulos = Convert.ToDouble(_kivi.lapaisypros10.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula10.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 8, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros11.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 10, tulos = Convert.ToDouble(_kivi.lapaisypros11.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula11.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 7, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros12.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 11, tulos = Convert.ToDouble(_kivi.lapaisypros12.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula12.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 6, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros13.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 12, tulos = Convert.ToDouble(_kivi.lapaisypros13.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula13.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 5, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros14.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 13, tulos = Convert.ToDouble(_kivi.lapaisypros14.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula14.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 4, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros15.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 14, tulos = Convert.ToDouble(_kivi.lapaisypros15.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula15.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 3, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros16.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 15, tulos = Convert.ToDouble(_kivi.lapaisypros16.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula16.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 2, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros17.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 16, tulos = Convert.ToDouble(_kivi.lapaisypros17.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula17.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 1, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros18.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 17, tulos = Convert.ToDouble(_kivi.lapaisypros18.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula18.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 0, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } foreach (Control c in _kivi.seulaArvot.Children) //Kaikille esineille seulaArvot-canvasissa. Tarkoituksena ottaa kaikki valitut seulat dropdown-valikoista talteen { if (c.GetType() == typeof(ComboBox)) //jos esineen tyyppi on combobox { //Console.WriteLine("Combobox text: " + ((ComboBox)c).Text+", tag: "+ ((ComboBox)c).Tag); if (((ComboBox)c).Tag.ToString() != null) //Jos comboboxin tagi on tyhjä { if (((ComboBox)c).Tag.ToString() == "seula") //jos comboboxin tagi on "seula", eli kaikki seuladropdown-valikot { //Console.WriteLine(((ComboBox)c).Text); string seulatxt = ((ComboBox)c).Text; seulatxt = seulatxt.Replace(".", ","); Seulakirjasto ke = new Seulakirjasto { seula = Convert.ToDouble(seulatxt) }; selistALL.Add(ke); } } } } for (int i = 0; i < 4; i++)//Otetaan ohjealueet talteen yksi kolumni kerrallaan { switch (i) { case 0: int o = 17; foreach (Control c in _kivi.ohjeArvot.Children) { if (c.GetType() == typeof(TextBox)) { if (((TextBox)c).Tag.ToString() != null) { if (((TextBox)c).Tag.ToString() == "sisAla") { if (((TextBox)c).Text != String.Empty) { string seulatxt = ((TextBox)c).Text; seulatxt = seulatxt.Replace(".", ","); SeulaLapPros ohj = new SeulaLapPros { index = o, tulos = Convert.ToDouble(seulatxt) }; sisOhjeAla.Add(ohj); } o--; } } } } break; case 1: int k = 17; foreach (Control c in _kivi.ohjeArvot.Children) { if (c.GetType() == typeof(TextBox)) { if (((TextBox)c).Tag.ToString() != null) { if (((TextBox)c).Tag.ToString() == "sisYla") { if (((TextBox)c).Text != String.Empty) { string seulatxt = ((TextBox)c).Text; seulatxt = seulatxt.Replace(".", ","); SeulaLapPros ohj = new SeulaLapPros { index = k, tulos = Convert.ToDouble(seulatxt) }; sisOhjeYla.Add(ohj); } k--; } } } } break; case 2: int l = 17; foreach (Control c in _kivi.ohjeArvot.Children) { if (c.GetType() == typeof(TextBox)) { if (((TextBox)c).Tag.ToString() != null) { if (((TextBox)c).Tag.ToString() == "uloAla") { if (((TextBox)c).Text != String.Empty) { string seulatxt = ((TextBox)c).Text; seulatxt = seulatxt.Replace(".", ","); SeulaLapPros ohj = new SeulaLapPros { index = l, tulos = Convert.ToDouble(seulatxt) }; uloOhjeAla.Add(ohj); } l--; } } } } break; case 3: int m = 17; foreach (Control c in _kivi.ohjeArvot.Children) { if (c.GetType() == typeof(TextBox)) { if (((TextBox)c).Tag.ToString() != null) { if (((TextBox)c).Tag.ToString() == "uloYla") { if (((TextBox)c).Text != String.Empty) { string seulatxt = ((TextBox)c).Text; seulatxt = seulatxt.Replace(".", ","); SeulaLapPros ohj = new SeulaLapPros { index = m, tulos = Convert.ToDouble(seulatxt) }; uloOhjeYla.Add(ohj); } m--; } } } } break; default: break; } } //---------------------------------------------------------------------- //Luodaan listoista käyrä ja otetaan kuva //---------------------------------------------------------------------- PlotModel plotModel = new PlotModel(); plotModel.PlotType = PlotType.XY; plotModel.IsLegendVisible = false; plotModel.PlotMargins = new OxyThickness(15, 15, 15, 15); //asetetaan legendan asetukset //plotModel.LegendPosition = LegendPosition.TopRight; //plotModel.LegendOrientation = LegendOrientation.Horizontal; //plotModel.LegendPlacement = LegendPlacement.Outside; //Tehdään kokoelma, jossa on kaikki käytössä olevat seulat. Nämä sidotaan X-akseliin /*Collection<Item> items = new Collection<Item>(); * for (int i = selistALL.Count - 1; i >= 0; i--) * { * items.Add(new Item(selistALL[i].seula.ToString(), selistALL[i].seula)); * }*/ //Luodaan Y-akseli LinearAxis yaxis = new LinearAxis //Y-akseli { Maximum = 100, Minimum = 0, //Title = "Prosentti", TickStyle = TickStyle.Inside, MinorStep = 5, MinorGridlineStyle = LineStyle.Dot, Position = AxisPosition.Left, //AbsoluteMaximum = 100, //AbsoluteMinimum = 0, MajorStep = 10, //MinorStep = 5, MajorGridlineStyle = LineStyle.Dash, //MinorGridlineStyle = LineStyle.Dash, IsZoomEnabled = false, IsPanEnabled = false }; //------------------------------Logaritmiakseli------------------------- LogarithmicAxis xaxis = new LogarithmicAxis(); //X-akseli /* double yhteensa = 0; * foreach (Seulakirjasto value in selistALL) * { * yhteensa += value.seula; * }*/ //double keskimaara = yhteensa / kaikkiseulat.Count; //double logbase = 1.0 / Math.Log(Math.E, keskimaara); if (selist == null || tulist == null || selist.Count == 0 || tulist.Count == 0) { //xaxis.Title = "Seula"; xaxis.TickStyle = TickStyle.Inside; xaxis.Position = AxisPosition.Bottom; xaxis.MajorGridlineStyle = LineStyle.Solid; //xaxis.Base = logbase; //xaxis.MajorStep = 2; //xaxis.MinorGridlineStyle = LineStyle.Dash; //xaxis.Maximum = seulat[0].seula; //xaxis.Minimum = seulat[(seulat.Count - 1)].seula; xaxis.IsZoomEnabled = false; xaxis.IsPanEnabled = false; } else { //xaxis.Title = "Seula"; xaxis.TickStyle = TickStyle.Inside; xaxis.Position = AxisPosition.Bottom; xaxis.MajorGridlineStyle = LineStyle.Solid; //xaxis.Base = logbase; //xaxis.MajorStep = //xaxis.MinorGridlineStyle = LineStyle.Dash; xaxis.Maximum = selistALL[0].seula; xaxis.Minimum = selistALL[(selistALL.Count - 1)].seula; xaxis.IsZoomEnabled = false; xaxis.IsPanEnabled = false; } //------------------------------------------------------------------- //Luodaan X-akseli /*CategoryAxis caxis = new CategoryAxis();//X-akseli * * if (selist == null || tulist == null || selist.Count == 0 || tulist.Count == 0) //Jos jokin lista on tyhjä, luodaan tyhjä perusakseli * { * caxis.Title = "Seula"; * caxis.TickStyle = TickStyle.Inside; * caxis.Position = AxisPosition.Bottom; * caxis.IsTickCentered = true; * caxis.MajorGridlineStyle = LineStyle.Solid; * caxis.MajorGridlineColor = OxyColors.DarkSlateGray; * caxis.MajorTickSize = 7; * //caxis.Maximum = seulat[0].seula; * //caxis.Minimum = seulat[(seulat.Count - 1)].seula; * caxis.IsZoomEnabled = false; * caxis.IsPanEnabled = false; * caxis.MinorStep = 0.5; * caxis.MajorStep = 1; * caxis.ItemsSource = items; * caxis.LabelField = "Label"; * } * else * { * caxis.Title = "Seula"; * caxis.TickStyle = TickStyle.Inside; * caxis.Position = AxisPosition.Bottom; * caxis.IsTickCentered = true; * caxis.MajorGridlineStyle = LineStyle.Solid; * caxis.MajorGridlineColor = OxyColors.DarkSlateGray; * caxis.MajorTickSize = 7; * //caxis.Maximum = seulat[0].seula; * //caxis.Minimum = seulat[(seulat.Count-1)].seula; * caxis.IsZoomEnabled = false; * caxis.IsPanEnabled = false; * caxis.MinorStep = 0.5; * caxis.MajorStep = 1; * caxis.ItemsSource = items; * caxis.LabelField = "Label"; * } * for (int i = selistALL.Count - 1; i >= 0; i--) //Laittaa Y-akselille otsikot, eli seulat jotka on käytössä tällä hetkellä * { * caxis.ActualLabels.Add(selistALL[i].seula.ToString()); * }*/ LineSeries l1 = new LineSeries //Tuloskäyrä/viiva { Title = "Rakeisuuskäyrä", MarkerType = MarkerType.Circle, CanTrackerInterpolatePoints = false, MarkerSize = 3 //LabelFormatString = "Läp%: {1:0.0} %" }; //Luodaan itse viivat LineSeries ohje1 = new LineSeries { MarkerType = MarkerType.None, CanTrackerInterpolatePoints = false, MarkerSize = 1, Color = OxyColors.CadetBlue }; LineSeries ohje2 = new LineSeries { MarkerType = MarkerType.None, CanTrackerInterpolatePoints = false, MarkerSize = 0, Color = OxyColors.CadetBlue }; LineSeries ohje3 = new LineSeries { MarkerType = MarkerType.None, CanTrackerInterpolatePoints = false, MarkerSize = 0, Color = OxyColors.Indigo }; LineSeries ohje4 = new LineSeries { MarkerType = MarkerType.None, CanTrackerInterpolatePoints = false, MarkerSize = 0, Color = OxyColors.Indigo }; //selist.Reverse(); //Luodaan listat joihin tulee viivojen pisteet List <Pisteet> la = new List <Pisteet>(); //Pääviiva List <Pisteet> o1 = new List <Pisteet>(); List <Pisteet> o2 = new List <Pisteet>(); List <Pisteet> o3 = new List <Pisteet>(); List <Pisteet> o4 = new List <Pisteet>(); //------------------Käytetään CategoryAxisin kanssa-------------------- /*int j = 0; * for (int i = tulist.Count - 1; i >= 0; i--) * { * //Syötetään yhden pisteen koordinaatit listaan esineeksi * Pisteet l = new Pisteet(); * l.X = selist[i].index; * l.Y = tulist[j].tulos; * la.Add(l); * j++; * }//--------------------------------------------------------------------*/ //---------------Käytetään LogarithmAxisin kanssa--------------------- for (int i = 0; i < tulist.Count; i++) { Pisteet l = new Pisteet(); l.X = selist[i].seula;//seulat[i].seula kun käytetään LogarithmAxisia l.Y = tulist[i].tulos; la.Add(l); }//--------------------------------------------------------------------*/ for (int i = sisOhjeAla.Count - 1; i >= 0; i--) { Pisteet l = new Pisteet(); l.X = sisOhjeAla[i].index; l.Y = sisOhjeAla[i].tulos; o1.Add(l); } for (int i = sisOhjeYla.Count - 1; i >= 0; i--) { Pisteet l = new Pisteet(); l.X = sisOhjeYla[i].index; l.Y = sisOhjeYla[i].tulos; o2.Add(l); } for (int i = uloOhjeAla.Count - 1; i >= 0; i--) { Pisteet l = new Pisteet(); l.X = uloOhjeAla[i].index; l.Y = uloOhjeAla[i].tulos; o3.Add(l); } for (int i = uloOhjeYla.Count - 1; i >= 0; i--) { Pisteet l = new Pisteet(); l.X = uloOhjeYla[i].index; l.Y = uloOhjeYla[i].tulos; o4.Add(l); } //Laitetaan luodut pistelistat viivoihinsa foreach (Pisteet e in la) { l1.Points.Add(new DataPoint(e.X, e.Y)); } foreach (Pisteet e in o1) { ohje1.Points.Add(new DataPoint(e.X, e.Y)); } foreach (Pisteet e in o2) { ohje2.Points.Add(new DataPoint(e.X, e.Y)); } foreach (Pisteet e in o3) { ohje3.Points.Add(new DataPoint(e.X, e.Y)); } foreach (Pisteet e in o4) { ohje4.Points.Add(new DataPoint(e.X, e.Y)); } //----------------------Kovakoodatut arvot, testitapaus----------------------------- /*double[] ar = new double[] { 0.063, 0.125, 0.25, 0.5, 1, 2, 4, 6, 8, 12, 16, 18, 20, 25, 30, 64, 100, 200 }; * double[] er = new double[] { 1.8, 3, 4.5, 5.6, 6.5, 8.3, 9.0, 9.9, 13.8, 15.6, 16.5, 17.4, 18.6, 20.4, 30.8, 31.4, 50.5, 62.7 }; * List<Pisteet> la = new List<Pisteet>(); * for (int i = 0; i < ar.Length; i++)//prosentit.Count * { * Pisteet l = new Pisteet(); * l.X = ar[i]; * l.Y = er[i]; * la.Add(l); * } * foreach (Pisteet e in la) * { * l1.Points.Add(new DataPoint(e.X, e.Y)); * }*///----------------------------------------------------------------------------------- //Syötetään kaikki luodut viivat ja akselit kaavioon plotModel.Axes.Add(yaxis); plotModel.Axes.Add(xaxis); //plotModel.Axes.Add(caxis); plotModel.Series.Add(l1); plotModel.Series.Add(ohje1); plotModel.Series.Add(ohje2); plotModel.Series.Add(ohje3); plotModel.Series.Add(ohje4); //Palautetaan kuva viivakaaviosta var kuvastream = new MemoryStream(); var pngExporter = new OxyPlot.Wpf.PngExporter { Width = 750, Height = 500, Background = OxyColors.White }; pngExporter.Export(plotModel, kuvastream); return(kuvastream); } else { return(null); } }
/// <summary> /// Initializes a new instance of the <see cref="Window2DPlot" /> class. /// </summary> /// <param name="title">The title.</param> private Window2DPlot(string title) { Title = title; Model = new PlotModel(); }
private void btnDrawGraph_Click(object sender, RoutedEventArgs e) { timerEmul.Stop(); if (IsEmul) { switch (cbSpeed.SelectedIndex) { case 0: timerEmul.Interval = 1000 / 1.0; break; case 1: timerEmul.Interval = 1000 / 2.0; break; case 2: timerEmul.Interval = 1000 / 4.0; break; case 3: timerEmul.Interval = 1000 / 8.0; break; case 4: timerEmul.Interval = 1000 / 25.0; break; } } model = new PlotModel(); DateTimeAxis axisX = new DateTimeAxis() { Title = "Время", Position = AxisPosition.Bottom, StringFormat = "HH:mm:ss\ndd/MM/yy", }; DateTime start = dtpStart.Value.Value; DateTime finish = dtpFinish.Value.Value; if (!IsEmul) { axisX.Minimum = start.ToOADate(); axisX.Maximum = finish.ToOADate(); } axisX.MajorGridlineStyle = LineStyle.Solid; axisX.MajorGridlineThickness = 1; model.Axes.Add(axisX); for (int i = 0; i < selectedParam.Count; i++) { LinearAxis axeY = new LinearAxis() { Title = selectedParam[i].Title + ", " + selectedParam[i].Unit, Key = selectedParam[i].Title, Position = AxisPosition.Left, PositionTier = i, }; if (i == 0) { axeY.AxisChanged += AxeY_AxisChanged; axeY.MajorGridlineStyle = LineStyle.Solid; axeY.MajorGridlineThickness = 1; } model.Axes.Add(axeY); LineSeries series = new LineSeries() { Title = selectedParam[i].Title, YAxisKey = selectedParam[i].Title }; model.Series.Add(series); int sample = Convert.ToInt32(cbSample.SelectionBoxItem); if (!IsEmul) { for (int point = 0; point < selectedParam[i].Points.Count; point += sample) { if ((selectedParam[i].Points[point].X > start) && (selectedParam[i].Points[point].X < finish)) { series.Points.Add(new DataPoint(DateTimeAxis.ToDouble(selectedParam[i].Points[point].X), selectedParam[i].Points[point].Y)); } } } } plotter.Model = model; for (int i = 1; i < model.Axes.Count; i++) { if (model.Axes[i].ActualMaximum > Math.Abs(model.Axes[i].ActualMinimum)) { model.Axes[i].Minimum = -1 * model.Axes[i].ActualMaximum; selectedParam[i - 1].MinY = model.Axes[i].Minimum; selectedParam[i - 1].MaxY = model.Axes[i].ActualMaximum; } else { model.Axes[i].Maximum = -1 * model.Axes[i].ActualMinimum; selectedParam[i - 1].MinY = model.Axes[i].ActualMinimum; selectedParam[i - 1].MaxY = model.Axes[i].Maximum; } } if (IsEmul) { timerEmul.Start(); } ContextMenu cm = new ContextMenu(); MenuItem reset = new MenuItem() { Header = "Масштаб по умолчанию" }; reset.Click += Reset_Click; cm.Items.Add(reset); MenuItem setting = new MenuItem() { Header = "Настройки" }; setting.Click += Setting_Click; cm.Items.Add(setting); MenuItem saveAsPic = new MenuItem() { Header = "Сохранить как картинку" }; saveAsPic.Click += SaveAsPic_Click; cm.Items.Add(saveAsPic); MenuItem exportManyPic = new MenuItem() { Header = "Выгрузить несколько картинок" }; exportManyPic.Click += ExportManyPic_Click; cm.Items.Add(exportManyPic); plotter.ContextMenu = cm; InitGraphSetting(); }
/// <summary> /// Renders the series on the specified render context. /// </summary> /// <param name="rc">The rendering context.</param> /// <param name="model">The model.</param> public abstract void Render(IRenderContext rc, PlotModel model);
// [Example("All in one")] public static PlotModel AllInOne() { var model = new PlotModel { Title = "All in one", LegendPlacement = LegendPlacement.Outside, LegendPosition = LegendPosition.BottomCenter, LegendOrientation = LegendOrientation.Horizontal, LegendBorderThickness = 0 }; var categoryAxis = new CategoryAxis { Position = CategoryAxisPosition(), GapWidth = 0.01 }; categoryAxis.Labels.Add("Category A"); categoryAxis.Labels.Add("Category B"); categoryAxis.Labels.Add("Category C"); categoryAxis.Labels.Add("Category D"); var valueAxis = new LinearAxis { Position = ValueAxisPosition(), MinimumPadding = 0.06, MaximumPadding = 0.06, ExtraGridlines = new[] { 0.0 }, ExtraGridlineStyle = LineStyle.Solid, ExtraGridlineColor = OxyColors.Black, ExtraGridlineThickness = 1 }; var categoryA = 0; var categoryB = 1; var categoryC = 2; var categoryD = 3; var s1 = new TSeries { Title = "Series 1", IsStacked = true, StrokeColor = OxyColors.Black, StrokeThickness = 1, StackGroup = "3" }; s1.Items.Add(new TItem { Value = 25 }); s1.Items.Add(new TItem { Value = 137 }); s1.Items.Add(new TItem { Value = 18 }); s1.Items.Add(new TItem { Value = 40 }); var s2 = new TSeries { Title = "Series 2", IsStacked = true, StrokeColor = OxyColors.Black, StrokeThickness = 1, StackGroup = "3" }; s2.Items.Add(new TItem { Value = -12 }); s2.Items.Add(new TItem { Value = -14 }); s2.Items.Add(new TItem { Value = -120 }); s2.Items.Add(new TItem { Value = -26 }); var s3 = new TSeries { Title = "Series 3", IsStacked = true, StrokeColor = OxyColors.Black, StrokeThickness = 1, StackGroup = "5" }; s3.Items.Add(new TItem { Value = 21 }); s3.Items.Add(new TItem { Value = 8 }); s3.Items.Add(new TItem { Value = 48 }); s3.Items.Add(new TItem { Value = 3 }); var s4 = new TSeries { Title = "Series 4", IsStacked = true, StrokeColor = OxyColors.Black, StrokeThickness = 1, StackGroup = "5", LabelFormatString = "{0:0}", LabelPlacement = LabelPlacement.Middle }; s4.Items.Add(new TItem { Value = -8, CategoryIndex = categoryA }); s4.Items.Add(new TItem { Value = -8, CategoryIndex = categoryA }); s4.Items.Add(new TItem { Value = -8, CategoryIndex = categoryA }); s4.Items.Add(new TItem { Value = -21, CategoryIndex = categoryB }); s4.Items.Add(new TItem { Value = -3, CategoryIndex = categoryC }); s4.Items.Add(new TItem { Value = -48, CategoryIndex = categoryD }); s4.Items.Add(new TItem { Value = 8, CategoryIndex = categoryA }); s4.Items.Add(new TItem { Value = 21, CategoryIndex = categoryB }); s4.Items.Add(new TItem { Value = 3, CategoryIndex = categoryC }); s4.Items.Add(new TItem { Value = 48, CategoryIndex = categoryD }); var s5 = new TSeries { Title = "Series 5", IsStacked = false, StrokeColor = OxyColors.Black, StrokeThickness = 1 }; s5.Items.Add(new TItem { Value = 17, CategoryIndex = categoryA }); s5.Items.Add(new TItem { Value = 179, CategoryIndex = categoryB }); s5.Items.Add(new TItem { Value = 45, CategoryIndex = categoryC }); s5.Items.Add(new TItem { Value = 65, CategoryIndex = categoryD }); s5.Items.Add(new TItem { Value = 97, CategoryIndex = categoryA }); s5.Items.Add(new TItem { Value = 21, CategoryIndex = categoryD }); var s6 = new TSeries { Title = "Series 6", IsStacked = false, StrokeColor = OxyColors.Black, StrokeThickness = 1, LabelFormatString = "{0:0}", LabelPlacement = LabelPlacement.Base }; s6.Items.Add(new TItem { Value = 7 }); s6.Items.Add(new TItem { Value = 54 }); s6.Items.Add(new TItem { Value = 68 }); s6.Items.Add(new TItem { Value = 12 }); model.Series.Add(s1); model.Series.Add(s2); model.Series.Add(s3); model.Series.Add(s4); model.Series.Add(s5); model.Series.Add(s6); model.Axes.Add(categoryAxis); model.Axes.Add(valueAxis); return(model); }
private static PlotModel CreateSimpleModel(bool stacked, string title) { var model = new PlotModel { Title = title, LegendPlacement = LegendPlacement.Outside, LegendPosition = LegendPosition.BottomCenter, LegendOrientation = LegendOrientation.Horizontal, LegendBorderThickness = 0 }; var s1 = new TSeries { Title = "Series 1", IsStacked = stacked, StrokeColor = OxyColors.Black, StrokeThickness = 1 }; s1.Items.Add(new TItem { Value = 25 }); s1.Items.Add(new TItem { Value = 137 }); s1.Items.Add(new TItem { Value = 18 }); s1.Items.Add(new TItem { Value = 40 }); var s2 = new TSeries { Title = "Series 2", IsStacked = stacked, StrokeColor = OxyColors.Black, StrokeThickness = 1 }; s2.Items.Add(new TItem { Value = 12 }); s2.Items.Add(new TItem { Value = 14 }); s2.Items.Add(new TItem { Value = 120 }); s2.Items.Add(new TItem { Value = 26 }); var categoryAxis = new CategoryAxis { Position = CategoryAxisPosition() }; categoryAxis.Labels.Add("Category A"); categoryAxis.Labels.Add("Category B"); categoryAxis.Labels.Add("Category C"); categoryAxis.Labels.Add("Category D"); var valueAxis = new LinearAxis { Position = ValueAxisPosition(), MinimumPadding = 0, MaximumPadding = 0.06, AbsoluteMinimum = 0 }; model.Series.Add(s1); model.Series.Add(s2); model.Axes.Add(categoryAxis); model.Axes.Add(valueAxis); return(model); }
private PlotModel CreatePlotModelChorale() { var plotModel = new PlotModel { Subtitle = $"Semanantic Link: {SemanticLinkCurrent.SemanticLinkId}, Direction: {Direction}" }; var colorAxis = new LinearColorAxis { HighColor = OxyColors.Gray, LowColor = OxyColors.Black, Position = AxisPosition.Right }; plotModel.Axes.Add(colorAxis); var xAxis = new LinearAxis { Title = "Transit Time", Unit = "s", Position = AxisPosition.Bottom }; plotModel.Axes.Add(xAxis); var yAxis = new LinearAxis { Title = "Lost Energy", Unit = "kWh" }; plotModel.Axes.Add(yAxis); var heatMapSeries = new HeatMapSeries { LabelFormatString = "0", X0 = ChoraleModel.MinTransitTime, X1 = ChoraleModel.MaxTransitTime, Y0 = ChoraleModel.MinLostEnegry, Y1 = ChoraleModel.MaxLostEnergy, LabelFontSize = 0.2, Data = ChoraleModel.Data }; plotModel.Series.Add(heatMapSeries); var scatterSeries = new ScatterSeries { MarkerFill = OxyColors.Black, MarkerType = MarkerType.Circle, MarkerSize = 30 }; var lostEnergy = Calculator.LostEnergyList.Sum(); var transitTime = (int)(Calculator.PositionCollection.Last().Timestamp - Calculator.PositionCollection.First().Timestamp).TotalSeconds; scatterSeries.Points.Add(new ScatterPoint(transitTime, lostEnergy) { Value = 0 }); plotModel.Series.Add(scatterSeries); return(plotModel); }
public override void Render(IRenderContext rc, PlotModel model1) { PlotModel model = this.PlotModel; if (Theme != null) { OxyColor color = Convertor.ConvertColorToOxyColor(Theme.GetThemeColor()); this.FillColor = color; } //base.Render(rc, model); UpdateValidData(); this.ActualBarRectangles = new List <OxyRect>(); if (this.ValidItems == null || this.ValidItems.Count == 0) { return; } var clippingRect = this.GetClippingRect(); var categoryAxis = this.GetCategoryAxis(); var actualBarWidth = this.GetActualBarWidth(); var stackIndex = this.IsStacked ? categoryAxis.GetStackIndex(this.StackGroup) : 0; for (var i = 0; i < this.ValidItems.Count; i++) { var item = this.ValidItems[i]; var categoryIndex = this.ValidItems[i].CategoryIndex; if (categoryIndex < 0) { continue; } var value = item.Value; // Get base- and topValue var baseValue = double.NaN; if (this.IsStacked) { baseValue = categoryAxis.GetCurrentBaseValue(stackIndex, categoryIndex, value < 0); } if (double.IsNaN(baseValue)) { baseValue = this.BaseValue; } var topValue = this.IsStacked ? baseValue + value : value; // Calculate offset double categoryValue; if (this.IsStacked) { categoryValue = categoryAxis.GetCategoryValue(categoryIndex, stackIndex, actualBarWidth); } else { categoryValue = categoryIndex - 0.5 + categoryAxis.GetCurrentBarOffset(categoryIndex); } if (this.IsStacked) { categoryAxis.SetCurrentBaseValue(stackIndex, categoryIndex, value < 0, topValue); } var rect = this.GetRectangle(baseValue, topValue, categoryValue, categoryValue + actualBarWidth); this.ActualBarRectangles.Add(rect); this.RenderItem(rc, clippingRect, topValue, categoryValue, actualBarWidth, item, rect); if (this.LabelFormatString != null) { this.RenderLabel(rc, clippingRect, rect, value, i); } if (!this.IsStacked) { categoryAxis.IncreaseCurrentBarOffset(categoryIndex, actualBarWidth); } } }
private PlotModel CreatePlotModelEnergyStack() { var model = new PlotModel(); var axisX = new CategoryAxis { ItemsSource = EnergyStackModelList, LabelField = "Category", Position = AxisPosition.Bottom }; model.Axes.Add(axisX); var axisY = new LinearAxis { Title = "Energy", Unit = "kWh", Position = AxisPosition.Left }; model.Axes.Add(axisY); foreach (var propertyInfo in typeof(EnergyStackModel).GetRuntimeProperties()) { if (propertyInfo.Name == "Category") { continue; } var series = new ColumnSeries { ItemsSource = EnergyStackModelList, ValueField = propertyInfo.Name, IsStacked = true }; if (propertyInfo.Name.Contains("Blank")) { series.FillColor = OxyColors.White; } else if (propertyInfo.Name.Contains("Defeat")) { series.FillColor = OxyColors.Black; } else if (propertyInfo.Name.Contains("Air")) { series.FillColor = OxyColors.Yellow; } else if (propertyInfo.Name.Contains("Rolling")) { series.FillColor = OxyColors.Orange; } else if (propertyInfo.Name.Contains("Regene")) { series.FillColor = OxyColors.DeepPink; } else if (propertyInfo.Name.Contains("ConvertLoss")) { series.FillColor = OxyColors.Red; } model.Series.Add(series); } return(model); }
//MainView model, contains declarations of charts and buttons, their attributes and assigned functions public MainViewModel() { DataTable = new ObservableCollection <TablesViewModel>(); ChartTemp = new PlotModel { Title = "Temperature" }; ChartPress = new PlotModel { Title = "Pressure" }; ChartHumid = new PlotModel { Title = "Humidity" }; ChartRPY = new PlotModel { Title = "Roll, Pitch, Yaw angles" }; ChartJOY = new PlotModel { Title = "Joystick" }; ChartTemp.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Minimum = 0, Maximum = config.XAxisMax, Key = "Horizontal", Unit = "sec", Title = "Time" }); ChartTemp.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Minimum = 30, Maximum = -20, Key = "Vertical", Unit = "C", Title = "Temperature" }); ChartPress.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Minimum = 0, Maximum = config.XAxisMax, Key = "Horizontal", Unit = "sec", Title = "Time" }); ChartPress.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Minimum = 0, Maximum = 1200, Key = "Vertical", Unit = "mbar", Title = "Pressure" }); ChartHumid.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Minimum = 0, Maximum = config.XAxisMax, Key = "Horizontal", Unit = "sec", Title = "Time" }); ChartHumid.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Minimum = 0, Maximum = 100, Key = "Vertical", Unit = "%", Title = "Humidity" }); ChartRPY.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Minimum = 0, Maximum = config.XAxisMax, Key = "Horizontal", Unit = "s", Title = "Time" }); ChartRPY.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Minimum = 0, Maximum = 360, Key = "Vertical", Unit = "Degrees", Title = "Angle value" }); ChartJOY.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Minimum = -30, Maximum = 30, Key = "Horizontal", Unit = "x", }); ChartJOY.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Minimum = -30, Maximum = 30, Key = "Vertical", Unit = "y", }); ChartHumid.Series.Add(new LineSeries() { Title = "Humidity", Color = OxyColor.Parse("#FFFF0000") }); ChartPress.Series.Add(new LineSeries() { Title = "Pressure", Color = OxyColor.Parse("#FFFF0000") }); ChartTemp.Series.Add(new LineSeries() { Title = "Temperature", Color = OxyColor.Parse("#FFFF0000") }); ChartRPY.Series.Add(new LineSeries() { Title = "Roll", Color = OxyColor.Parse("#FFFF0000") }); ChartRPY.Series.Add(new LineSeries() { Title = "Pitch", Color = OxyColor.Parse("#0000FF") }); ChartRPY.Series.Add(new LineSeries() { Title = "Yaw", Color = OxyColor.Parse("#ffff00") }); ChartJOY.Series.Add(new LineSeries() { Title = "Point placement", Color = OxyColor.Parse("#FFFF0000"), MarkerFill = OxyColors.Blue, MarkerStroke = OxyColors.Red, MarkerType = MarkerType.Circle, StrokeThickness = 0, MarkerSize = 4, }); StartButton = new ButtonCommand(StartTimer); StopButton = new ButtonCommand(StopTimer); UpdateConfigButton = new ButtonCommand(UpdateConfig); DefaultConfigButton = new ButtonCommand(DefaultConfig); SendLed = new ButtonCommand(SendLedData); ClearLed = new ButtonCommand(ClearLedData); ipAddress = config.IpAddress; sampleTime = config.SampleTime; maxSampleNumber = config.MaxSampleNumber; Server = new IoTServer(IpAddress); }
private PlotModel CreateModel() { //Decide which day of the week was selected and create a matching string string daystring = ""; switch (dayIndex) { case 0: daystring = "Monday"; break; case 1: daystring = "Tuesday"; break; case 2: daystring = "Wednesday"; break; case 3: daystring = "Thursday"; break; case 4: daystring = "Friday"; break; } //Setup objects to populate the statistics plot TimeSpan[] times = new TimeSpan[48]; TimeSpan half = TimeSpan.FromMinutes(30); //Create an array for times to display on bottom of plot for (int i = 0; i < times.Length; i++) { times[i] = TimeSpan.FromMinutes(30 * i); } //Create new model with title var plotModel = new PlotModel { Title = (string)theLot[0] + " Lot Capacity: " + daystring }; //Add axes to the plot plotModel.Axes.Add(new TimeSpanAxis { Position = AxisPosition.Bottom, Maximum = TimeSpanAxis.ToDouble(times[47]), Minimum = TimeSpanAxis.ToDouble(times[0]) }); plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Maximum = 1, Minimum = 0 }); //Create a line var series1 = new LineSeries { MarkerType = MarkerType.Circle, MarkerSize = 4, MarkerStroke = OxyColors.White }; //Add points to line for (int i = 0; i < stats.Length; i++) { series1.Points.Add(new DataPoint(TimeSpanAxis.ToDouble(times[i]), stats[i])); } //Add line to plot plotModel.Series.Add(series1); //Return completed plot return(plotModel); }
private void FillPlot(BaseUtils.SortedListDoubleDuplicate <ISystem> csl, ISystem currentSystem) { SetControlText("2D Plot of systems in range from " + currentSystem.Name); var pointSize = 4; // initializing the plot var modelTop = new PlotModel { }; var modelFront = new PlotModel { }; var modelSide = new PlotModel { }; this.plotViewTop.Model = modelTop; this.plotViewFront.Model = modelFront; this.plotViewSide.Model = modelSide; modelTop.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, TicklineColor = OxyColors.BlueViolet }); modelTop.Axes.Add(new LinearAxis { Position = AxisPosition.Left, TicklineColor = OxyColors.BlueViolet }); modelFront.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, TicklineColor = OxyColors.BlueViolet }); modelFront.Axes.Add(new LinearAxis { Position = AxisPosition.Left, TicklineColor = OxyColors.BlueViolet }); modelSide.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, TicklineColor = OxyColors.BlueViolet }); modelSide.Axes.Add(new LinearAxis { Position = AxisPosition.Left, TicklineColor = OxyColors.BlueViolet }); // Define defaults properties of the series for the Top view var currentSeriesTop = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Red }; var lastoneSeriesTop = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Purple }; var inrangeSeriesTop = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Yellow }; var visitedSeriesTop = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Cyan }; // Define defaults properties of the series for the Front view var currentSeriesFront = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Red }; var lastoneSeriesFront = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Purple }; var inrangeSeriesFront = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Yellow }; var visitedSeriesFront = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Cyan }; // Define defaults properties of the series for the Side view var currentSeriesSide = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Red }; var lastoneSeriesSide = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Purple }; var inrangeSeriesSide = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Yellow }; var visitedSeriesSide = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Cyan }; // Add the series modelTop.Series.Add(currentSeriesTop); modelTop.Series.Add(lastoneSeriesTop); modelTop.Series.Add(visitedSeriesTop); modelTop.Series.Add(inrangeSeriesTop); // Add the series modelFront.Series.Add(currentSeriesFront); modelFront.Series.Add(lastoneSeriesFront); modelFront.Series.Add(visitedSeriesFront); modelFront.Series.Add(inrangeSeriesFront); // Add the series modelSide.Series.Add(currentSeriesSide); modelSide.Series.Add(lastoneSeriesSide); modelSide.Series.Add(visitedSeriesSide); modelSide.Series.Add(inrangeSeriesSide); // titles modelTop.Title = "Plot around " + currentSystemName + ", viewed from the top"; modelFront.Title = "Plot around " + currentSystemName + ", viewed from the front"; modelSide.Title = "Plot around " + currentSystemName + ", viewed from the side"; // Title of the report reportView.Text += ("\nSystems around " + currentSystemName + ", from " + textMinRadius.Value.ToString() + " to " + textMaxRadius.Value.ToString() + "Ly: " + csl.Count.ToString() + "\n"); // Fill with some information for the report //reportView.AppendText("\nText " + currentSystem.some_value_interesting_to_report); reportView.Text += ("\nVisits: " + discoveryform.history.GetVisitsCount(currentSystem.Name, currentSystem.EDSMID)); reportView.Text += ("\nNotes: " + currentSystem.SystemNote + "\n"); // If the are any system inside the defined range... if (csl.Count() > 0) { // ...then iterate through each system in the list: foreach (KeyValuePair <double, ISystem> tvp in csl) { // calculate the average distance; var distFromCurrentSys = Math.Round(Math.Sqrt(tvp.Key), 2, MidpointRounding.AwayFromZero); // count the total visits for each system; int visits = discoveryform.history.GetVisitsCount(tvp.Value.Name, tvp.Value.EDSMID); // Then, populate the Grid with the systems in range if (distFromCurrentSys >= textMinRadius.Value && distFromCurrentSys <= textMaxRadius.Value && tvp.Value.Name != currentSystemName) { // get the coordinates of each system in range; var sysX = tvp.Value.X; var sysY = tvp.Value.Y; var sysZ = tvp.Value.Z; // print information on each member of the list; reportView.Text += ("\n" + tvp.Value.Name.ToString() + ", distant " + distFromCurrentSys + "Ly "); reportView.Text += ("\n" + "Visits: " + visits.ToString()); reportView.Text += ("\nCoordinates: " + "X:" + sysX + ", Y:" + sysY + ", Z:" + sysZ); // Create the list, with each system's name, distances by x, y and z coordinates and number of visits object[] plotobj = { tvp.Value.Name, $"{sysX:0.00}", $"{sysY:0.00}", $"{sysZ:0.00}", $"{visits:n0}" }; int rowindex = dataGridList.Rows.Add(plotobj); dataGridList.Rows[rowindex].Tag = tvp.Value; var seriesTop = inrangeSeriesTop; var seriesFront = inrangeSeriesFront; var seriesSide = inrangeSeriesSide; // Assign each system to the correct color and series, depending of its state: // visited; lastone; inrange (not visited). if (visits > 0) { // is visited if (tvp.Value.Name != previousSystemName) { seriesTop = visitedSeriesTop; seriesFront = visitedSeriesFront; seriesSide = visitedSeriesSide; } // is visited, and is the last visited system else if (tvp.Value.Name == previousSystemName) { seriesTop = lastoneSeriesTop; seriesFront = lastoneSeriesFront; seriesSide = lastoneSeriesSide; } } else // is not visited yet { seriesTop = inrangeSeriesTop; seriesFront = inrangeSeriesFront; seriesSide = inrangeSeriesSide; } // // Draw each point in the Plot seriesTop.Points.Add(new ScatterPoint(Convert.ToDouble(plotobj[1]), Convert.ToDouble(plotobj[2]), pointSize, Convert.ToDouble(plotobj[3]), plotobj[0])); seriesFront.Points.Add(new ScatterPoint(Convert.ToDouble(plotobj[1]), Convert.ToDouble(plotobj[3]), pointSize, Convert.ToDouble(plotobj[2]), plotobj[0])); seriesSide.Points.Add(new ScatterPoint(Convert.ToDouble(plotobj[2]), Convert.ToDouble(plotobj[3]), pointSize, Convert.ToDouble(plotobj[1]), plotobj[0])); // Create a tracker which shows the name of the system and its coordinates string TrackerTop = "{Tag}\n" + "X: {2:0.###}; Y: {4:0.###}; Z: {6:0.###}"; string TrackerFront = "{Tag}\n" + "X: {2:0.###}; Z: {4:0.###}; Y: {6:0.###}"; string TrackerSide = "{Tag}\n" + "Y: {2:0.###}; Z: {4:0.###}; X: {6:0.###}"; seriesTop.TrackerFormatString = TrackerTop; seriesFront.TrackerFormatString = TrackerFront; seriesSide.TrackerFormatString = TrackerSide; } currentSeriesTop.Points.Add(new ScatterPoint(currentSystem.X, currentSystem.Y, pointSize, currentSystem.Z, currentSystemName)); currentSeriesFront.Points.Add(new ScatterPoint(currentSystem.X, currentSystem.Z, pointSize, currentSystem.Y, currentSystemName)); currentSeriesSide.Points.Add(new ScatterPoint(currentSystem.Y, currentSystem.Z, pointSize, currentSystem.X, currentSystemName)); string currentTracker = "{Tag}"; currentSeriesTop.TrackerFormatString = currentTracker; currentSeriesFront.TrackerFormatString = currentTracker; currentSeriesSide.TrackerFormatString = currentTracker; // End of the systems list reportView.Text += ("\n"); } // End of the Report reportView.Text += ("\n\nReport created on " + DateTime.Now.ToString()); } }
public static PlotModel ScatterSeries10225() { var plotModel1 = new PlotModel { Title = "Issue 10225", PlotMargins = new OxyThickness(50, 5, 5, 50), Padding = new OxyThickness(0), PlotAreaBorderThickness = new OxyThickness(1, 1, 1, 1), PlotAreaBorderColor = OxyColors.Black, TextColor = OxyColors.Black, LegendOrientation = LegendOrientation.Horizontal, LegendPosition = LegendPosition.TopRight, LegendMargin = 0 }; plotModel1.Axes.Add(new LinearAxis { IsAxisVisible = true, Title = "X", Position = AxisPosition.Bottom, TickStyle = TickStyle.Outside, TicklineColor = OxyColors.Black, Minimum = 0, MaximumPadding = 0.05 }); plotModel1.Axes.Add(new LogarithmicAxis { MinimumPadding = 0.05, MaximumPadding = 0.1, Title = "Y", Position = AxisPosition.Left, TickStyle = TickStyle.Outside, TicklineColor = OxyColors.Black, MajorGridlineColor = OxyColors.Black, MajorGridlineStyle = LineStyle.Solid }); var referenceCurve = new LineSeries { Title = "Reference", Smooth = true, Color = OxyColor.FromArgb(255, 89, 128, 168) }; var upperBoundary = new LineSeries { LineStyle = LineStyle.Dot, Color = OxyColors.LightGray, Smooth = true, Title = string.Empty }; var lowerBoundary = new LineSeries { LineStyle = LineStyle.Dot, Color = OxyColors.LightGray, Smooth = true, Title = "+/- 15 %" }; // Series that holds and formats points inside of the boundary var inBoundaryResultLine = new ScatterSeries { Title = "actual", MarkerFill = OxyColors.Black, MarkerSize = 4, MarkerStroke = OxyColors.White, MarkerType = MarkerType.Circle }; // Series that holds and formats points outside of the boundary var outBoundaryResultLine = new ScatterSeries { Title = "not permissible deviation", MarkerFill = OxyColors.Red, MarkerSize = 4, MarkerStroke = OxyColors.White, MarkerType = MarkerType.Circle }; // Just some random data to fill the series: var referenceValues = new[] { double.NaN, 0.985567558024852, 0.731704530257957, 0.591109071735532, 0.503627816316065, 0.444980686815776, 0.403576666032678, 0.373234299823915, 0.350375591667333, 0.332795027566349, 0.319063666439909, 0.30821748743148, 0.299583943726489, 0.292680371378706, 0.287151885046283, 0.282732008216725, 0.279216923371711, 0.276557880999918 }; var actualValues = new[] { double.NaN, 0.33378346040897, 1.09868427497967, 0.970771068054048, 0.739778217457323, 0.582112938330166, 0.456962500853806, 0.37488740614826, 0.330272509496142, 0.334461549522006, 0.30989175806678, 0.286944862053553, 0.255895385950234, 0.231850970296068, 0.217579897050944, 0.217113227224437, 0.164759946945322, 0.0459134254747994 }; for (var index = 0; index <= 17; index++) { var referenceValue = referenceValues[index]; var lowerBound = referenceValue - (referenceValue * 0.15); var upperBound = referenceValue + (referenceValue * 0.15); referenceCurve.Points.Add(new DataPoint(index, referenceValue)); lowerBoundary.Points.Add(new DataPoint(index, lowerBound)); upperBoundary.Points.Add(new DataPoint(index, upperBound)); var actualValue = actualValues[index]; if (actualValue > lowerBound && actualValue < upperBound) { inBoundaryResultLine.Points.Add(new ScatterPoint(index, actualValue)); } else { outBoundaryResultLine.Points.Add(new ScatterPoint(index, actualValue)); } } plotModel1.Series.Add(referenceCurve); plotModel1.Series.Add(lowerBoundary); plotModel1.Series.Add(upperBoundary); plotModel1.Series.Add(outBoundaryResultLine); plotModel1.Series.Add(inBoundaryResultLine); return(plotModel1); }
private void CreateRelativeCapitalUsageByStrategyChartModel() { var model = new PlotModel(); var xAxis = new OxyPlot.Axes.DateTimeAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, StringFormat = "yyyy-MM-dd" }; model.Axes.Add(xAxis); var yAxis = new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Left, StringFormat = "p0", MajorGridlineStyle = LineStyle.Dash }; model.Axes.Add(yAxis); var capUsageTmpSum = Enumerable.Range(0, Data.RelativeCapitalUsageByStrategy.Rows.Count).Select(x => 0.0).ToList(); foreach (DataColumn column in Data.RelativeCapitalUsageByStrategy.Columns) { if (column.ColumnName == "date") { continue; } DataColumn column1 = column; List <double> sum = capUsageTmpSum; var series = new OxyPlot.Series.AreaSeries { ItemsSource = Data .RelativeCapitalUsageByStrategy .Select((x, i) => new { X = x.date, Y = sum[i], Y2 = sum[i] + x.Field <double>(column1.ColumnName), }), Title = column.ColumnName, CanTrackerInterpolatePoints = false, TrackerFormatString = "Strategy: " + column.ColumnName + @" Date: {2:yyyy-MM-dd} Capital Usage: {4:p1}", DataFieldX = "X", DataFieldX2 = "X", DataFieldY = "Y", DataFieldY2 = "Y2", MarkerType = MarkerType.None, StrokeThickness = 1 }; capUsageTmpSum = Data.RelativeCapitalUsageByStrategy.Select((x, i) => x.Field <double>(column1.ColumnName) + capUsageTmpSum[i]).ToList(); model.Series.Add(series); } model.LegendPosition = LegendPosition.BottomCenter; model.LegendOrientation = LegendOrientation.Horizontal; model.LegendPlacement = LegendPlacement.Outside; RelativeCapitalUsageByStrategyModel = model; }
public ComHistgramOxyPlot() { m_pModel = new PlotModel(); }
public async Task <PlotModel> Generate() { var responses = metrics.ToDictionary(x => x, x => cloudWatch.GetMetricStatisticsAsync(new GetMetricStatisticsRequest { Namespace = x.Namespace, MetricName = x.Name, Period = (int)x.Period.TotalSeconds, StartTime = metricStartTime, Dimensions = x.Dimensions, EndTime = metricEndTime, Statistics = x.StatisticType.GetRequestStatistics(), ExtendedStatistics = x.StatisticType.GetRequestExtendedStatistics() })); await Task.WhenAll(responses.Select(x => x.Value)); var model = new PlotModel { Title = title, Subtitle = subtitle, Padding = new OxyThickness(20d), LegendPlacement = LegendPlacement.Outside, LegendPosition = LegendPosition.BottomLeft, LegendOrientation = LegendOrientation.Horizontal, DefaultColors = GraphConstants.Colors, PlotAreaBorderThickness = new OxyThickness(0d, 0d, 0d, 1d), PlotAreaBorderColor = OxyColor.FromRgb(204, 204, 204) }; var dataRanges = new List <Tuple <StandardUnit, double> >(); foreach (var response in responses.Where(x => x.Value.Result.Datapoints.Any())) { IEnumerable <Datapoint> orderedData = response.Value.Result.Datapoints.OrderByDescending(i => i.StatisticTypeValue(response.Key.StatisticType)); Datapoint highestDataPoint = orderedData.First(); Datapoint lowestDataPoint = orderedData.Last(); dataRanges.Add(Tuple.Create(highestDataPoint.Unit, highestDataPoint.StatisticTypeValue(response.Key.StatisticType))); dataRanges.Add(Tuple.Create(lowestDataPoint.Unit, lowestDataPoint.StatisticTypeValue(response.Key.StatisticType))); Series series = seriesBuilder.BuildSeries(response.Key, response.Value.Result.Datapoints); model.Series.Add(series); } var aAxis = new DateTimeAxis { Position = AxisPosition.Bottom, TicklineColor = OxyColor.FromRgb(238, 238, 238), Minimum = DateTimeAxis.ToDouble(metricStartTime), Maximum = DateTimeAxis.ToDouble(metricEndTime) }; if (metrics.All(x => x.GraphType != GraphType.Total)) { model.Axes.Add(InferYAxis(dataRanges)); model.Axes.Add(aAxis); } return(model); }
private void UpdatePlot() { var pm = new PlotModel { Title = this.year.ToString(), Subtitle = "data from gapminder.org", LegendPosition = LegendPosition.RightBottom }; var ss = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerFill = OxyColors.Transparent, MarkerStroke = OxyColors.Blue, MarkerStrokeThickness = 1 }; var piX = typeof(Statistics).GetProperty("GdpPerCapitaPpp"); var piY = typeof(Statistics).GetProperty("LifeExpectancyAtBirth"); var piSize = typeof(Statistics).GetProperty("Population"); var piColor = typeof(Statistics).GetProperty("GeographicRegion"); foreach (var kvp in Countries) { Country country = kvp.Value; double x = country.FindValue(year, piX); double y = country.FindValue(year, piY); double size = country.FindValue(year, piSize); if (double.IsNaN(x) || double.IsNaN(y)) { continue; } ss.Points.Add(new ScatterPoint(x, y, double.NaN, double.NaN, country.Name)); //double radius = 4; //if (!double.IsNaN(size)) // radius = Math.Sqrt(size)*0.1; //if (radius < 4) radius = 4; //if (radius > 40) radius = 40; //ss.MarkerSizes.Add(radius); // Debug.WriteLine(countryName+": "+stats.Population); } pm.Series.Add(ss); if (SelectedCountry != null) { var ls = new LineSeries { Title = SelectedCountry.Name }; ls.LineJoin = OxyPenLineJoin.Bevel; foreach (var p in SelectedCountry.Statistics) { if (double.IsNaN(p.GdpPerCapitaPpp) || double.IsNaN(p.LifeExpectancyAtBirth)) { continue; } ls.Points.Add(new DataPoint(p.GdpPerCapitaPpp, p.LifeExpectancyAtBirth)); } pm.Series.Add(ls); var ss2 = new ScatterSeries(); double x = SelectedCountry.FindValue(year, piX); double y = SelectedCountry.FindValue(year, piY); ss2.Points.Add(new ScatterPoint(x, y, 10)); ss2.MarkerFill = OxyColor.FromAColor(120, OxyColors.Red); ss2.MarkerType = MarkerType.Circle; pm.Series.Add(ss2); } pm.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 19, Maximum = 87, Title = "Life expectancy (years)" }); pm.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Bottom, Title = "Income per person (GDP/capita, PPP$ inflation-adjusted)", Minimum = 200, Maximum = 90000 }); PlotModel = pm; }
//Create a plot model. private static PlotModel CreatePlotModel(int size, int height, List <int> requestList, int count) { var plotModel = new PlotModel { PlotAreaBorderColor = OxyColors.Transparent, Background = OxyColors.Transparent, PlotAreaBackground = OxyColors.Transparent }; plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, AbsoluteMaximum = height + 1, AbsoluteMinimum = 0, Maximum = height + 1, Minimum = 0, MajorTickSize = 0, MinorTickSize = 0, TextColor = OxyColors.Transparent, AxislineColor = OxyColors.Black }); plotModel.Axes.Add(new CategoryAxis { Position = AxisPosition.Top, AbsoluteMaximum = size - 0.5, AbsoluteMinimum = -1, Maximum = size - 0.5, Minimum = -1, Title = "Requests", Labels = { requestList[0].ToString(), requestList[1].ToString(), requestList[2].ToString(), requestList[3].ToString(), requestList[4].ToString(), requestList[5].ToString(), requestList[6].ToString(), requestList[7].ToString(), requestList[8].ToString(), requestList[9].ToString(), requestList[10].ToString(), requestList[11].ToString(), requestList[12].ToString(), requestList[13].ToString(), requestList[14].ToString(), requestList[15].ToString(), requestList[16].ToString(), requestList[17].ToString(), requestList[18].ToString(), requestList[19].ToString(), requestList[20].ToString(), requestList[21].ToString(), requestList[22].ToString(), requestList[23].ToString(), requestList[24].ToString(), requestList[25].ToString(), requestList[26].ToString(), requestList[27].ToString(), requestList[28].ToString(), requestList[29].ToString(), requestList[30].ToString(), requestList[31].ToString(), requestList[32].ToString(), requestList[33].ToString(), requestList[34].ToString(), requestList[35].ToString(), requestList[36].ToString(), requestList[37].ToString(), requestList[38].ToString(), requestList[39].ToString(), requestList[40].ToString(), requestList[41].ToString(), requestList[42].ToString(), requestList[43].ToString(), requestList[44].ToString(), requestList[45].ToString(), requestList[46].ToString(), requestList[47].ToString(), requestList[48].ToString(), requestList[49].ToString(), requestList[50].ToString(), requestList[51].ToString(), requestList[52].ToString(), requestList[53].ToString(), requestList[54].ToString(), requestList[55].ToString(), requestList[56].ToString(), requestList[57].ToString(), requestList[58].ToString(), requestList[59].ToString() }, MajorTickSize = 0 }); return(plotModel); }
private void buttonShow_Click(object sender, EventArgs e) { Signal signal = new Signal(); double duration, fill, bandwidth; if (double.TryParse(textBoxDuration.Text, out duration)) { duration = duration * 1e-6; } else { duration = 1e-5; } if (double.TryParse(textBoxBandwidth.Text, out bandwidth)) { bandwidth = bandwidth * 1e6; } else { bandwidth = 1e7; } if (double.TryParse(textBoxFill.Text, out fill)) { if (fill > 100) { fill = 1; } else if (fill < 0) { fill = 0; } else { fill = fill / 100; } } else { fill = 0.5; } switch (comboBoxSignal.Text) { case "ЛЧМ": signal = Signal.CreateChirp(0, bandwidth, duration, fill); break; default: signal = Signal.CreateChirp(0, 1e7, 1e-5); break; } var myModel = new PlotModel { Title = "Example 1" }; OxyPlot.Series.LineSeries ls = new OxyPlot.Series.LineSeries(); switch (comboBoxOutput.Text) { case "Сигнал": for (int i = 0; i < signal.N; i++) { ls.Points.Add(new DataPoint(i, (signal.Value[i]).Real)); } break; case "Спектр": MathNet.Numerics.IntegralTransforms.Fourier.Forward(signal.Value); for (int i = 0; i < signal.N; i++) { ls.Points.Add(new DataPoint(i, (signal.Value[i]).Real)); } break; case "Модуль сигнала": for (int i = 0; i < signal.N; i++) { ls.Points.Add(new DataPoint(i, (signal.Value[i]).Magnitude)); } break; case "Модуль спектра": MathNet.Numerics.IntegralTransforms.Fourier.Forward(signal.Value); for (int i = 0; i < signal.N; i++) { ls.Points.Add(new DataPoint(i, (signal.Value[i]).Magnitude)); } break; } myModel.Series.Add(ls); this.plot1.Model = myModel; }
/// <summary> /// Sets the default values (colors, line style etc.) from the plot model. /// </summary> /// <param name="model">A plot model.</param> protected internal abstract void SetDefaultValues(PlotModel model);
public GraphViewModel() { plotModel = new PlotModel(); plotModel.Series.Add(new LineSeries()); }