public PlotVM() { PlotsToShow = new ObservableCollection <PlotCheckItem>(); TypeRadioButtons = new ObservableCollection <TypeRadioButton> { new TypeRadioButton(DataPointListType.Module_dB, "Module [dB]", UpdateType, true), new TypeRadioButton(DataPointListType.Real, "Real", UpdateType, false), new TypeRadioButton(DataPointListType.Imaginary, "Imaginary", UpdateType, false), new TypeRadioButton(DataPointListType.Module, "Module", UpdateType, false), new TypeRadioButton(DataPointListType.Phase, "Phase", UpdateType, false), }; PlotModel.Axes.Add(new LinearAxis { Title = "Frequency [GHz]", Position = AxisPosition.Bottom }); _currentlySelectedTypeRadioButton = GetSelectedType(TypeRadioButtons); YAxis = new LinearAxis { Title = _currentlySelectedTypeRadioButton.Name, Position = AxisPosition.Left }; PlotModel.Axes.Add(YAxis); }
public PlotViewModel(string title, bool bRefresh = true) { name = title; m_plot = new PlotModel { Title = title }; var xAxis = new OxyPlot.Axes.LinearAxis(); xAxis.Position = AxisPosition.Bottom; xAxis.MajorGridlineStyle = LineStyle.Solid; xAxis.Minimum = 0.0; xAxis.Maximum = 1.0; m_plot.Axes.Add(xAxis); var yAxis = new OxyPlot.Axes.LinearAxis(); yAxis.Position = AxisPosition.Left; yAxis.MajorGridlineStyle = LineStyle.Solid; yAxis.Minimum = 0.0; yAxis.Maximum = 1.0; m_plot.Axes.Add(yAxis); if (bRefresh) { m_timer = new Timer(updatePlot); m_timer.Change(m_updateFreq, m_updateFreq); } }
private void SetUpAxes(String xAxisTitle, String yAxisTitle) { PlotModel.Axes.Clear(); var yAxis = new OxyPlot.Axes.LinearAxis() { Position = AxisPosition.Left, Title = yAxisTitle, TitlePosition = 0.5, TitleFontSize = 28, AxisTitleDistance = 12, FontSize = 20, StringFormat = "0.######", Maximum = 1 }; var xAxis = new OxyPlot.Axes.LinearAxis() { Position = AxisPosition.Bottom, Title = xAxisTitle, TitlePosition = 0.5, TitleFontSize = 28, FontSize = 20, StringFormat = "0.######" }; PlotModel.Axes.Add(xAxis); PlotModel.Axes.Add(yAxis); //PlotModel.PlotMargins = new OxyThickness(80, 60, 60, 60); PlotModel.LegendFontSize = 15; PlotModel.SubtitleFontSize = 15; }
private void SetUpModel() { plotModel.LegendTitle = "Legend"; plotModel.LegendOrientation = LegendOrientation.Horizontal; plotModel.LegendPlacement = LegendPlacement.Outside; plotModel.LegendPosition = LegendPosition.TopRight; plotModel.LegendBackground = OxyColor.FromAColor(200, OxyColors.White); plotModel.LegendBorder = OxyColors.Black; plotModel.Title = "SensorThings API Sample Graph"; var dtaxis = new OxyPlot.Axes.DateTimeAxis { Position = AxisPosition.Bottom, Title = "Date", TitleFormatString = "yy/mm/dd HH:mm" }; plotModel.Axes.Add(dtaxis); var valueAxis = new OxyPlot.Axes.LinearAxis() { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Value" }; valueAxis.Position = AxisPosition.Left; plotModel.Axes.Add(valueAxis); }
private void SetUpAxes(String xAxisTitle, String yAxisTitle) { PlotModel.Axes.Clear(); var yAxis = new OxyPlot.Axes.LinearAxis() { Position = AxisPosition.Left, Title = yAxisTitle, TitlePosition = 1, TitleFontSize = 20, StringFormat = "0.####" }; var xAxis = new OxyPlot.Axes.LinearAxis() { Position = AxisPosition.Bottom, Title = xAxisTitle, TitlePosition = 1, TitleFontSize = 20, StringFormat = "0.####" }; PlotModel.Axes.Add(xAxis); PlotModel.Axes.Add(yAxis); //PlotModel.Axes.Add(new LinearAxis(AxisPosition.Left, "X") { Title = xAxisTitle }); //PlotModel.Axes.Add(new LinearAxis(AxisPosition.Bottom, "Y") { Title = yAxisTitle }); PlotModel.PlotMargins = new OxyThickness(40, 40, 40, 40); }
private static void MakeTotalLinePlot([JetBrains.Annotations.NotNull] string outputPath, [JetBrains.Annotations.NotNull] List <double> sums) { var plotModel1 = new PlotModel { LegendPosition = LegendPosition.BottomCenter, LegendPlacement = LegendPlacement.Outside, LegendOrientation = LegendOrientation.Horizontal, Title = "Total" }; var linearAxis1 = new LinearAxis { Position = AxisPosition.Bottom }; plotModel1.Axes.Add(linearAxis1); var lineSeries1 = new LineSeries { Title = "Sum" }; for (var j = 0; j < sums.Count; j++) { lineSeries1.Points.Add(new DataPoint(j, sums[j])); } plotModel1.Series.Add(lineSeries1); var path = Path.Combine(outputPath, "Sum.line.png"); PngExporter.Export(plotModel1, path, 3200, 1600, OxyColor.FromRgb(255, 255, 255), 100); }
private void UserControl_Loaded([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e) { MyDeviceSelector.Simulator = Presenter.ApplicationPresenter.Simulator; MyDeviceSelector.OpenItem = Presenter.ApplicationPresenter.OpenItem; MyStandbySelector.Simulator = Presenter.ApplicationPresenter.Simulator; MyStandbySelector.OpenItem = Presenter.ApplicationPresenter.OpenItem; _plot = new PlotModel(); _dateTimeAxis = new LinearAxis { Position = AxisPosition.Bottom }; _plot.Axes.Add(_dateTimeAxis); _categoryAxis = new CategoryAxis { MinorStep = 1, Position = AxisPosition.Left, IsZoomEnabled = false, IsPanEnabled = false }; _dateTimeAxis.IsZoomEnabled = false; _dateTimeAxis.IsPanEnabled = false; _plot.Axes.Add(_categoryAxis); var pv = new PlotView { Model = _plot }; DeviceGrid.Children.Add(pv); Grid.SetRow(pv, 2); RefreshGraph(); }
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 SetUpModel() { PlotModel.PlotType = PlotType.XY; var axisX = new LinearAxis() { Title = "X", Position = AxisPosition.Bottom, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, TicklineColor = OxyColor.FromRgb(0, 0, 0), }; PlotModel.Axes.Add(axisX); var axisY = new LinearAxis() { Title = "Y", Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, }; PlotModel.Axes.Add(axisY); }
void InitPlot(string title, string xAxisName, string yAxisName) { var xAxis = new OxyPlot.Axes.LinearAxis(); xAxis.Position = AxisPosition.Bottom; xAxis.MajorGridlineStyle = LineStyle.Solid; Plot.Axes.Add(xAxis); var yAxis = new OxyPlot.Axes.LinearAxis(); yAxis.Position = AxisPosition.Left; yAxis.MajorGridlineStyle = LineStyle.Solid; Plot.Axes.Add(yAxis); ResetAxes(); //default properties Plot.LegendBorder = OxyColors.Black; Plot.LegendBackground = OxyColors.White; Properties.Title = Herd.Utils.OxyPlotMathNotation(title); Properties.XAxisName = Herd.Utils.OxyPlotMathNotation(xAxisName); Properties.YAxisName = Herd.Utils.OxyPlotMathNotation(yAxisName); UpdatePlotProperties(); //Add a listener to "PropertiesChanged" event from Properties Properties.PropertyChanged += PropertiesChanged; }
private static void MakeLinePlot([JetBrains.Annotations.NotNull] string outputPath, [ItemNotNull][JetBrains.Annotations.NotNull] List <Column> columns, int position, int day) { var p = OxyPalettes.HueDistinct(columns.Count); var plotModel1 = new PlotModel { LegendPosition = LegendPosition.BottomCenter, LegendPlacement = LegendPlacement.Outside, LegendOrientation = LegendOrientation.Horizontal, Title = "Day " + day }; var linearAxis1 = new LinearAxis { Position = AxisPosition.Bottom }; plotModel1.Axes.Add(linearAxis1); for (var i = 1; i < columns.Count; i++) { var lineSeries1 = new LineSeries { Title = columns[i].HHNumber, Color = p.Colors[i] }; for (var j = position; j < position + 1440; j++) { lineSeries1.Points.Add(new DataPoint(j, columns[i].Values[j])); } plotModel1.Series.Add(lineSeries1); } var path = Path.Combine(outputPath, "Plot." + day + ".line.png"); PngExporter.Export(plotModel1, path, 3200, 1600, OxyColor.FromRgb(255, 255, 255), 100); }
public void AddAxisTwice() { var model = new PlotModel(); var axis = new LinearAxis(); model.Axes.Add(axis); Assert.Throws<InvalidOperationException>(() => model.Axes.Add(axis)); }
public PlotViewModel() { Model = new PlotModel { Title = "体温" }; var line = new LineSeries(); TemperatureSQLite database = new TemperatureSQLite(); var _datas = new ObservableCollection <TemperatureTableEntity>(); _datas = database.GetAllRecordsOrderByDatetime(); line.Color = OxyColors.Red; foreach (var data in _datas) { line.Points.Add(new DataPoint(DateTimeAxis.ToDouble(data.Datetime), data.Temperature)); } var Y_ax = new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Left, Minimum = 33.0, Maximum = 45.0 }; var X_ax = new OxyPlot.Axes.DateTimeAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, StringFormat = "MM/dd hh:mm" }; Model.Axes.Add(X_ax); Model.Axes.Add(Y_ax); Model.Series.Add(line); }
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)); }
private void MakeModels(long PK) { DataAccess db = new DataAccess(); measurement = db.GetMeasurements(PK); var fcvHistogram = Histogram.CreateEmpty(10, 80, 40); double count = 0; foreach (var x in measurement) { if (x.FCV != 0) { fcvHistogram.Increment((int)x.FCV); count++;// add individual data points } } OxyPlot.Axes.CategoryAxis xaxis = new OxyPlot.Axes.CategoryAxis(); xaxis.Title = "FCV(m/s)"; xaxis.TitleFontWeight = 700; xaxis.Position = AxisPosition.Bottom; xaxis.MajorGridlineStyle = LineStyle.Solid; xaxis.MinorGridlineStyle = LineStyle.Solid; OxyPlot.Axes.LinearAxis yaxis = new OxyPlot.Axes.LinearAxis(); yaxis.Title = "%"; yaxis.TitleFontWeight = 700; yaxis.Minimum = 0; yaxis.Maximum = 100; yaxis.Position = AxisPosition.Left; yaxis.MajorGridlineStyle = LineStyle.Solid; yaxis.MinorGridlineStyle = LineStyle.Solid; OxyPlot.Series.ColumnSeries s1 = new OxyPlot.Series.ColumnSeries(); s1.IsStacked = true; s1.StrokeColor = OxyColors.Black; s1.FillColor = OxyColors.Black; s1.Background = OxyColors.Beige; count = 100.0 / count; foreach (var x in fcvHistogram.BinsAndValues) { s1.Items.Add(new ColumnItem(x.Value * count)); xaxis.Labels.Add(x.Key.ToString().Substring(0, 3)); } var Model = new PlotModel(); Model.Title = "Conduction Velocities"; Model.Background = OxyColors.GhostWhite; Model.Axes.Add(xaxis); Model.Axes.Add(yaxis); Model.Series.Add(s1); model.Add(Model); }
public void FormatAsFractionsZero() { var axis = new LinearAxis { FormatAsFractions = true, FractionUnit = Math.PI, FractionUnitSymbol = "π" }; Assert.AreEqual("0", axis.FormatValue(0)); }
public void FormatAsFractionsPiHalf() { var axis = new LinearAxis { FormatAsFractions = true, FractionUnit = Math.PI, FractionUnitSymbol = "π" }; Assert.AreEqual("π/2", axis.FormatValue(0.5 * Math.PI)); }
public PlotModel ScatterPlot(IReadOnlyCollection <IdentData> data, Func <object, ScatterPoint> mapping, string title, string xTitle, OxyColor markerColor) { //series1.Mapping = item => new DataPoint(((MyType)item).Time,((MyType)item).Value) var model = ModelBaseConfig(); model.Title = title; var s1 = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerStrokeThickness = 0, MarkerSize = 1.0, MarkerFill = markerColor, ItemsSource = data, Mapping = mapping }; var yAxis = new LinearAxis { Position = AxisPosition.Left, Title = "Mass Error (PPM)", MajorGridlineStyle = LineStyle.Solid, MajorStep = 10.0, MinorStep = 5.0, Minimum = -20.0, Maximum = 20.0, MinimumRange = 40.0, FilterMinValue = -20.0, FilterMaxValue = 20.0 }; var xAxis = new LinearAxis { Position = AxisPosition.Bottom, Title = xTitle //Minimum = 1000, //Maximum = 4600, }; var xAxisCenter = new LinearAxis { Position = AxisPosition.Top, // To let the other axis be locked to the bottom, and force this one to be horizontal PositionAtZeroCrossing = true, TickStyle = TickStyle.None, // To change to show a value, need to do axis synchronization AxislineStyle = LineStyle.Solid, AxislineThickness = 1.0, TextColor = OxyColors.Undefined // Force invisible labels }; model.Axes.Add(yAxis); model.Axes.Add(xAxis); model.Axes.Add(xAxisCenter); model.Series.Add(s1); return(model); }
public PlotModel ScatterPlot(IReadOnlyCollection <IdentData> data, string xDataField, string yDataField, string title, string xTitle, OxyColor markerColor) { var model = ModelBaseConfig(); model.Title = title; var s1 = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerStrokeThickness = 0, MarkerSize = 1.0, MarkerFill = markerColor, ItemsSource = data, //DataFieldX = xDataField, //DataFieldY = yDataField, Mapping = item => new ScatterPoint(Convert.ToDouble(typeof(IdentData).GetProperty(xDataField)?.GetValue(item)), Convert.ToDouble(typeof(IdentData).GetProperty(yDataField)?.GetValue(item))) }; var yAxis = new LinearAxis { Position = AxisPosition.Left, Title = "Mass Error (PPM)", MajorGridlineStyle = LineStyle.Solid, MajorStep = 10.0, MinorStep = 5.0, Minimum = -20.0, Maximum = 20.0, MinimumRange = 40.0, FilterMinValue = -20.0, FilterMaxValue = 20.0 }; var xAxis = new LinearAxis { Position = AxisPosition.Bottom, Title = xTitle }; var xAxisCenter = new LinearAxis { Position = AxisPosition.Top, // To let the other axis be locked to the bottom, and force this one to be horizontal PositionAtZeroCrossing = true, TickStyle = TickStyle.None, // To change to show a value, need to do axis synchronization AxislineStyle = LineStyle.Solid, AxislineThickness = 1.0, TextColor = OxyColors.Undefined // Force invisible labels }; model.Axes.Add(yAxis); model.Axes.Add(xAxis); model.Axes.Add(xAxisCenter); model.Series.Add(s1); return(model); }
private PlotModel CreatePlot() { var pm = new PlotModel { Title = "River Network" }; var linearAxisX = new LinearAxis { Minimum = 0, Maximum = 100, Position = AxisPosition.Bottom }; var linearAxisY = new LinearAxis { Minimum = 0, Maximum = 100, Position = AxisPosition.Left }; pm.PlotType = PlotType.Cartesian; pm.Axes.Add(linearAxisX); pm.Axes.Add(linearAxisY); foreach (var points in allPoints) { var ls = new LineSeries(); foreach (var point in points) { ls.Points.Add(point); } pm.Series.Add(ls); } //pm.MouseDown += (s, e) => //{ // if ((e.ChangedButton != OxyMouseButton.Left)) // { // return; // } // e.Handled = true; //}; pm.MouseUp += PlotModel_MouseUp; //PlotView plotView = new PlotView(); //plotView.Controller.UnbindAll(); //Grid.Children.Add(plotView); //plotView.Model = PlotModel; return(pm); }
public void PodajDaneDoWykresu2(List <double> X, List <List <double> > Y, List <Process> procesy)//Lista X i Y podana jako parametr metody { this.PlotModel = new OxyPlot.PlotModel(); //Usunięcie ustawionych parametrów z poprzedniego uruchomienia metody plotModel.Series = new System.Collections.ObjectModel.Collection <OxyPlot.Series.Series> { }; punktySeriiTab = new OxyPlot.Series.LineSeries[Y.Count()];//Ile jest List w zmiennej Y plotModel.Axes = new System.Collections.ObjectModel.Collection <OxyPlot.Axes.Axis> { }; Random random = new Random(); //Graficzne ustawienia wykresów for (int n = 0; n < Y.Count(); n++) { punktySeriiTab[n] = new OxyPlot.Series.LineSeries { MarkerType = ksztaltPunktowWykresu[n % 5], //oznaczenie punktów MarkerSize = 4, //wielkość punktów MarkerStroke = OxyPlot.OxyColor.FromUInt32((uint)random.Next(0, 16777215) + 4278190080), //Kolor obramowania punktów wykresu / kolory losowane funkcją random Title = procesy[n].ProcessName.ToString() //tytuł serii }; } //Uzupełnianie danych for (int i = 0; i < Y.Count(); i++) { for (int n = 0; n < Y[i].Count(); n++) //uzupełniam tylko dla włączonych { punktySeriiTab[i].Points.Add(new OxyPlot.DataPoint(X[n], Y[i][n])); //dodanie wszystkich serii do wykresu } } for (int i = 0; i < Y.Count(); i++) { plotModel.Series.Add(punktySeriiTab[i]); } //Opis i parametry osi wykresu var xAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Bottom, "czas [s]") { MajorGridlineStyle = OxyPlot.LineStyle.Solid, MinorGridlineStyle = OxyPlot.LineStyle.Dot }; plotModel.Axes.Add(xAxis); var yAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Left, "% udziału czasu") { MajorGridlineStyle = OxyPlot.LineStyle.Solid, MinorGridlineStyle = OxyPlot.LineStyle.Dot }; plotModel.Axes.Add(yAxis); }
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"); }
private static void MakeBarPlot([JetBrains.Annotations.NotNull] string outputPath, [ItemNotNull][JetBrains.Annotations.NotNull] List <Column> columns, int position, int day, int minutesToSum) { var plotModel2 = new PlotModel(); var p = OxyPalettes.HueDistinct(columns.Count); plotModel2.LegendPosition = LegendPosition.BottomCenter; plotModel2.LegendPlacement = LegendPlacement.Outside; plotModel2.LegendOrientation = LegendOrientation.Horizontal; plotModel2.Title = "Day " + day; // axes var categoryAxis = new CategoryAxis { AbsoluteMinimum = 0, MinimumPadding = 0, GapWidth = 0, MajorStep = 60, Title = "Energy" }; plotModel2.Axes.Add(categoryAxis); var linearAxis2 = new LinearAxis { AbsoluteMinimum = 0, MaximumPadding = 0.06, MinimumPadding = 0, Title = "Minutes" }; plotModel2.Axes.Add(linearAxis2); for (var i = 1; i < columns.Count; i++) { var columnSeries2 = new ColumnSeries { IsStacked = true, StrokeThickness = 0, Title = columns[i].HHNumber }; for (var j = position; j < position + 1440; j += minutesToSum) { columnSeries2.Items.Add(new ColumnItem(columns[i].MakeSum(j, minutesToSum))); } columnSeries2.FillColor = p.Colors[i]; plotModel2.Series.Add(columnSeries2); } var path2 = Path.Combine(outputPath, "Plot." + day + "." + minutesToSum + "min.bar.png"); PngExporter.Export(plotModel2, path2, 3200, 1600, OxyColor.FromRgb(255, 255, 255), 100); }
private void PlotGraph() { PlotData = new PlotModel(); var yAxis = new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Left, Title = "Fiber Attenuation", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.None }; var xAxis = new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Bottom, Title = "Wavelengths (nm)", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.None }; PlotData.Axes.Add(xAxis); PlotData.Axes.Add(yAxis); DataPoint[] linePoints = new DataPoint[loss.Count]; ScatterPoint[] markerPoints = new ScatterPoint[loss.Count]; for (int i = 0; i < loss.Count; i++) { if (markers.Contains(wavelengths[i])) { markerPoints[i] = new ScatterPoint((double)wavelengths[i], (double)loss[i]); } else { markerPoints[i] = new ScatterPoint((double)wavelengths[i], 0); } linePoints[i] = new DataPoint((double)wavelengths[i], (double)loss[i]); } var lineSeries = new OxyPlot.Series.LineSeries { StrokeThickness = 2, ItemsSource = linePoints }; var circleSeries = new OxyPlot.Series.ScatterSeries { MarkerSize = 3, MarkerType = MarkerType.Circle }; // W850 TO W1550 S10; circleSeries.Points.AddRange(markerPoints.Where(i => i.Y > 0)); PlotData.Series.Add(lineSeries); PlotData.Series.Add(circleSeries); PlotData.InvalidatePlot(true); }
private void UserControl_Loaded([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e) { _plot = new PlotModel(); _dateTimeAxis = new DateTimeAxis { Position = AxisPosition.Bottom }; _plot.Axes.Add(_dateTimeAxis); _linearAxis = new LinearAxis(); _plot.Axes.Add(_linearAxis); var pv = new PlotView { Model = _plot }; ChartGrid.Children.Add(pv); RefreshZGraph(); }
public LineSeriesControl() { InitializeComponent(); Plot.Model = new OxyPlot.PlotModel(); Plot.Dock = DockStyle.Fill; var linearAxis1 = new LinearAxis(); linearAxis1.MajorGridlineColor = OxyColor.FromArgb(40, 0, 0, 139); linearAxis1.MajorGridlineStyle = LineStyle.Solid; linearAxis1.MinorGridlineColor = OxyColor.FromArgb(20, 0, 0, 139); linearAxis1.MinorGridlineStyle = LineStyle.Solid; linearAxis1.Position = AxisPosition.Bottom; linearAxis1.Title = "Position"; linearAxis1.Unit = "mm"; Plot.Model.Axes.Add(linearAxis1); var linearAxis2 = new OxyPlot.Axes.LinearAxis(); linearAxis2.MajorGridlineColor = OxyColor.FromArgb(40, 0, 0, 139); linearAxis2.MajorGridlineStyle = LineStyle.Solid; linearAxis2.MinorGridlineColor = OxyColor.FromArgb(20, 0, 0, 139); linearAxis2.MinorGridlineStyle = LineStyle.Solid; linearAxis2.Title = "Intensity"; linearAxis2.Unit = YAxisUnits[YUnitsToUse.GetHashCode()]; Plot.Model.Axes.Add(linearAxis2); Plot.Model.Background = OxyColor.FromRgb(255, 255, 255); AddNewLockinDataSeries(); var cursorX = new LineAnnotation() { Type = LineAnnotationType.Vertical, Color = OxyColors.Green, ClipByYAxis = false, X = 0, StrokeThickness = 2 }; var cursorY = new LineAnnotation() { Type = LineAnnotationType.Horizontal, Color = OxyColors.Green, ClipByXAxis = false, Y = 0, StrokeThickness = 2, }; Plot.Model.Annotations.Add(cursorX); Plot.Model.Annotations.Add(cursorY); Plot.Model.Padding = new OxyThickness(2); Controls.Add(Plot); }
private void SetUpModel(double minValue, double maxValue, DateTime date1) { MyModel.LegendTitle = "Legend"; MyModel.LegendOrientation = LegendOrientation.Horizontal; MyModel.LegendPlacement = LegendPlacement.Outside; MyModel.LegendPosition = LegendPosition.TopRight; MyModel.LegendBackground = OxyColor.FromAColor(100, OxyColors.White); MyModel.LegendBorder = OxyColors.Black; var dateAxis = new OxyPlot.Axes.DateTimeAxis(AxisPosition.Bottom, "Date", "dd/MM/yy HH:mm") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 80, Minimum = DateTimeAxis.ToDouble(date1) }; MyModel.Axes.Add(dateAxis); var valueAxis = new OxyPlot.Axes.LinearAxis(AxisPosition.Left, minValue, maxValue) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Value" }; MyModel.Axes.Add(valueAxis); }
public static void RefreshModel(PlotView view) { view.Model = new PlotModel(); view.Model.Series.Add(new FunctionSeries(ThingSpeakLightConverter.Eval, 0, 1024, 1024, "monitor Brightness by light level")); OxyPlot.Axes.LinearAxis x = new OxyPlot.Axes.LinearAxis() { Position = AxisPosition.Bottom, Minimum = -1, Maximum = 1025 }; OxyPlot.Axes.LinearAxis y = new OxyPlot.Axes.LinearAxis() { Position = AxisPosition.Left, Minimum = -1, Maximum = 101 }; view.Model.Axes.Add(x); view.Model.Axes.Add(y); view.InvalidatePlot(); view.Controller.UnbindAll(); }
/// <summary> /// Constructor /// </summary> /// <param name="features">List of features</param> /// <param name="title">Plot title</param> /// <param name="minMass">Minimum mass</param> /// <param name="maxMass">Maximum mass</param> /// <param name="minTime">Minimum time (minutes)</param> /// <param name="maxTime">Maximum time (minutes)</param> public LcMsFeatureMap(IEnumerable <LcMsFeature> features, string title, double minMass, double maxMass, double minTime, double maxTime) { _features = features; // Initialize x and y axes. var yAxis = new LinearAxis { Position = AxisPosition.Left, Title = "Monoisotopic Mass [Da]", StringFormat = "0.###", FontSize = 20, Minimum = minMass, Maximum = maxMass }; var xAxis = new LinearAxis { Position = AxisPosition.Bottom, Title = "Elution Time [Minute]", StringFormat = "0.###", FontSize = 20, Minimum = minTime, Maximum = maxTime }; // Initialize feature map. _featureMap = new PlotModel { Title = title, TitleFontSize = 30 }; _featureMap.Axes.Add(xAxis); _featureMap.Axes.Add(yAxis); var txtX = minTime + (maxTime - minTime) * 0.2; var txtY = maxMass - (maxMass - minMass) * 0.1; var annotation = new TextAnnotation { TextPosition = new DataPoint(txtX, txtY), Text = string.Format("Number of LCMS features = {0}", _features.Count()), FontSize = 25, }; _featureMap.Annotations.Add(annotation); }
/// <summary> /// Constructor /// </summary> /// <param name="features">List of features</param> /// <param name="title">Plot title</param> /// <param name="minMass">Minimum mass</param> /// <param name="maxMass">Maximum mass</param> /// <param name="minTime">Minimum time (minutes)</param> /// <param name="maxTime">Maximum time (minutes)</param> public LcMsFeatureMap(IEnumerable<LcMsFeature> features, string title, double minMass, double maxMass, double minTime, double maxTime) { _features = features; // Initialize x and y axes. var yAxis = new LinearAxis { Position = AxisPosition.Left, Title = "Monoisotopic Mass [Da]", StringFormat = "0.###", FontSize = 20, Minimum = minMass, Maximum = maxMass }; var xAxis = new LinearAxis { Position = AxisPosition.Bottom, Title = "Elution Time [Minute]", StringFormat = "0.###", FontSize = 20, Minimum = minTime, Maximum = maxTime }; // Initialize feature map. _featureMap = new PlotModel { Title = title, TitleFontSize = 30 }; _featureMap.Axes.Add(xAxis); _featureMap.Axes.Add(yAxis); var txtX = minTime + (maxTime - minTime) * 0.2; var txtY = maxMass - (maxMass - minMass) * 0.1; var annotation = new TextAnnotation { TextPosition = new DataPoint(txtX, txtY), Text = string.Format("Number of LCMS features = {0}", _features.Count()), FontSize = 25, }; _featureMap.Annotations.Add(annotation); }
protected PlotSignalModel internalAddSignal(ISignalViewModel signal) { PluginFramework.Sample[] data = signal.GetData(); var lineSerie = new OxyPlot.Series.LineSeries { StrokeThickness = 1, CanTrackerInterpolatePoints = false, Title = signal.Title, Decimator = Decimator.Decimate, TrackerFormatString = "{1}: \t{2:HH:mm:ss}\n{3}: \t{4}" }; lineSerie.Points.Capacity = data.GetLength(0); for (int i = 0; i < data.GetLength(0); i++) { lineSerie.Points.Add(OxyPlot.Axes.DateTimeAxis.CreateDataPoint(data[i].Time, data[i].Value)); } // Create axis var valueAxis = new OxyPlot.Axes.LinearAxis() { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = signal.Title }; valueAxis.Key = signal.Title; valueAxis.Position = axisPosition; axisPosition = (axisPosition == AxisPosition.Left ? AxisPosition.Right : AxisPosition.Left); valueAxis.TextColor = lineSerie.MarkerStroke; valueAxis.PositionTier = PlotModel.Axes.Count; valueAxis.Unit = signal.Unit; PlotModel.Axes.Add(valueAxis); lineSerie.YAxisKey = signal.Title; PlotSignalModel ps = new PlotSignalModel() { Path = signal.GetPath() }; lineSerie.Tag = ps; //lineSerie.MouseDown += lineSerie_MouseDown; PlotModel.Series.Add(lineSerie); PlotModel.InvalidatePlot(true); return(ps); }
private PlotModel SetUpModel() { PlotModel plotModel1 = new PlotModel(); plotModel1.Title = "Fishing Net"; var linearAxis1 = new OxyPlot.Axes.LinearAxis(); linearAxis1.MajorGridlineStyle = LineStyle.Solid; linearAxis1.MinimumPadding = 0; linearAxis1.MinimumPadding = 0; //linearAxis1.MinorGridlineStyle = LineStyle.Dot; linearAxis1.Position = AxisPosition.Bottom; plotModel1.Axes.Add(linearAxis1); var linearAxis2 = new OxyPlot.Axes.LinearAxis(); linearAxis2.MajorGridlineStyle = LineStyle.Solid; linearAxis2.MaximumPadding = 0; linearAxis2.MinimumPadding = 0; //linearAxis2.MinorGridlineStyle = LineStyle.Dot; plotModel1.Axes.Add(linearAxis2); return plotModel1; }
/// <summary> /// Sets the x-axis and y-axis for the plot with corresponding titles /// </summary> private void SetAxes() { var xAxis = new LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, MajorGridlineStyle = LineStyle.Dash, Title = "Potential (V)" }; var yAxis = new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Left, MajorGridlineStyle = LineStyle.Dash, Title = "Current (uA)" }; //Set the x-axis and y-axis for the plot model plotModel.Axes.Add(xAxis); plotModel.Axes.Add(yAxis); }
private void ClearPlot() { OxyPlotModel.Series.Clear(); if (OxyPlotModel.Axes.Count > 0) { //should always have an X axis OxyPlotModel.Axes[0].AxisChanged -= _plotService.OnAxisChanged;// OnAxisChanged; } OxyPlotModel.Axes.Clear(); var xAxis = new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Bottom, Title = "Time", Unit = "sec" }; OxyPlotModel.Axes.Add(xAxis); OxyPlotModel.Axes[0].AxisChanged += _plotService.OnAxisChanged; //OnAxisChanged; OxyPlotModel.LegendOrientation = LegendOrientation.Horizontal; OxyPlotModel.LegendPlacement = LegendPlacement.Outside; OxyPlotModel.LegendPosition = LegendPosition.TopCenter; }
public void LoadPlotModel(HandType type) { string title = $"{Report.Spot.Action} {Report.Spot.AggPos}vs{Report.Spot.CllPos} {Report.Spot.BoardType} {Report.Spot.BoardSubtype} {type}"; PlotModel = new PlotModel { Title = title, TitleColor = ThemeModel.OxyForegroundColour, TextColor = ThemeModel.OxyForegroundColour, LegendTextColor = ThemeModel.OxyForegroundColour, PlotAreaBorderColor = ThemeModel.OxyForegroundColour }; OxyPlot.Axes.LinearAxis yAxis = new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Left, MajorStep = 10, MinorStep = 10, Minimum = 0, Maximum = 100, AxislineColor = ThemeModel.OxyForegroundColour, TextColor = ThemeModel.OxyForegroundColour }; OxyPlot.Axes.LinearAxis xAxis = new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Bottom, MajorStep = 1, MinorStep = 1, AxislineColor = ThemeModel.OxyForegroundColour, TextColor = ThemeModel.OxyForegroundColour }; // CategoryAxis catAxis = new CategoryAxis( {Position = AxisPosition.Bottom, MajorStep = 1, MinorStep = 1); xAxis.LabelFormatter = getXLabel; PlotModel.Axes.Add(xAxis); PlotModel.Axes.Add(yAxis); handGroup = Report.GetHandGroup(type); string[] frequencyLabels = handGroup.GetFrequencyLabels(); foreach (string frequencyLabel in frequencyLabels) { List <DataPoint> pointsList = new List <DataPoint>(); FrequencyValues freqValues = handGroup.GetFrequencyValues(frequencyLabel); foreach (int order in freqValues.GetHandStrengthOrders()) { pointsList.Add(new DataPoint(order, freqValues.GetFrequency(order))); } LineSeries series = new LineSeries() { InterpolationAlgorithm = InterpolationAlgorithms.CanonicalSpline, Title = frequencyLabel, ItemsSource = pointsList, MarkerSize = 5, MarkerType = MarkerType.Circle }; PlotModel.Series.Add(series); } }
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 RaisesCollectionChangedEvent() { var collection = new ElementCollection<Axis>(new PlotModel()); ElementCollectionChangedEventArgs<Axis> eventArgs = null; var raisedCount = 0; collection.CollectionChanged += (sender, e) => { eventArgs = e; raisedCount++; }; var axis = new LinearAxis(); collection.Add(axis); Assert.AreEqual(1, raisedCount); Assert.AreEqual(1, eventArgs.AddedItems.Count); Assert.IsTrue(ReferenceEquals(axis, eventArgs.AddedItems[0])); }
private static void MakeYAxis([NotNull] PlotModel pm, [NotNull] string title, double absoluteMinimum) { var yAxis = new LinearAxis { AbsoluteMinimum = absoluteMinimum, MaximumPadding = 0.06, //MinimumPadding = 0, MajorGridlineStyle = LineStyle.Solid, MajorGridlineColor = OxyColors.LightGray, //MajorStep = xAxisLabels.Count/5.0, MinorGridlineStyle = LineStyle.None, AxislineStyle = LineStyle.Solid, AxislineColor = OxyColors.Black, //MinorStep = 5, Title = title, //PositionAtZeroCrossing = true, Position = AxisPosition.Left }; pm.Axes.Add(yAxis); }
public void graph() { MyModel = new PlotModel { Title = "example" }; MyModel.LegendPosition = LegendPosition.RightBottom; MyModel.LegendPlacement = LegendPlacement.Outside; MyModel.LegendOrientation = LegendOrientation.Horizontal; MyModel.Series.Add(GetFunction()); var Yaxis = new OxyPlot.Axes.LinearAxis(); OxyPlot.Axes.LinearAxis XAxis = new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, Minimum = 0, Maximum = 100 }; XAxis.Title = "X"; Yaxis.Title = "10 * x * x + 11 * x*y*y + 12*x*y"; MyModel.Axes.Add(Yaxis); MyModel.Axes.Add(XAxis); this.plot.Model = MyModel; }
/// <summary> /// The update reference. /// </summary> /// <param name="uimfDataNew"> /// The new <see cref="UimfData"/> that is coming in. /// </param> public void UpdateReference(UimfData uimfDataNew) { this.uimfData = uimfDataNew; this.UimfLoaded = uimfDataNew != null; if (this.BpiPlotModel != null) { return; } this.BpiPlotModel = new PlotModel(); var linearAxis = new LinearAxis { Position = AxisPosition.Bottom, AbsoluteMinimum = 0, IsPanEnabled = false, IsZoomEnabled = false, Title = "Mobility Scan", Unit = "Scan Number", MinorTickSize = 0 }; this.BpiPlotModel.Axes.Add(linearAxis); var linearYAxis = new LinearAxis { IsZoomEnabled = false, AbsoluteMinimum = 0, MinimumPadding = 0.1, MaximumPadding = 0.1, IsPanEnabled = false, IsAxisVisible = false }; this.BpiPlotModel.Axes.Add(linearYAxis); var series = new LineSeries { Color = OxyColors.Black, }; this.BpiPlotModel.Series.Add(series); }
private void OnPlotConfigurationChanged() { ClearPlot(); if (PlotModel.PlotConfiguration == null) { return; } foreach (AxisDefinitionModel axis in PlotModel.PlotConfiguration.Axes) { var yAxis = new OxyPlot.Axes.LinearAxis { Position = ConvertAxisToOxyPlot(axis.AxisPosition), Title = axis.AxisTitle, Unit = axis.Unit, Key = axis.Key }; yAxis.Tag = axis; axis.OxyAxis = yAxis; yAxis.AxisChanged += _plotService.OnAxisChanged; OxyPlotModel.Axes.Add(yAxis); } StringBuilder logFormat = new StringBuilder(); foreach (SeriesDefinitionModel series in PlotModel.PlotConfiguration.Series) { var oxseries = new OxyPlot.Series.LineSeries { Title = series.SeriesTitle, Color = OxyColor.FromArgb(series.Color.A, series.Color.R, series.Color.G, series.Color.B), YAxisKey = series.YAxisKey }; oxseries.Tag = series; series.OxySeries = oxseries; OxyPlotModel.Series.Add(oxseries); //oxseries.Smooth;add option for this } AppendLogFormatFromSeries(logFormat, PlotModel.PlotConfiguration.Series); PlotModel.LogFormat = logFormat.ToString(); OnLogFormatChanged(); //string tmp = this.PrintfLogString; OxyPlotModel.Title = PlotModel.PlotConfiguration.PlotName; OxyPlotModel.InvalidatePlot(true); }
public DataMainViewModel() { HorizontalAxis = new TimeSpanAxis { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IsAxisVisible = true, IsPanEnabled = false, IsZoomEnabled = false, TextColor = OxyColor.Parse("#FFF6F6F6"), Position = AxisPosition.Bottom }; VerticalAxis = new LinearAxis { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Position = AxisPosition.Left }; Model.Axes.Add(HorizontalAxis); Model.Axes.Add(VerticalAxis); }
public PlotViewModel(string title, bool bRefresh=true) { name= title; m_plot = new PlotModel { Title=title}; var xAxis = new OxyPlot.Axes.LinearAxis(); xAxis.Position = AxisPosition.Bottom; xAxis.MajorGridlineStyle = LineStyle.Solid; xAxis.Minimum = 0.0; xAxis.Maximum = 1.0; m_plot.Axes.Add(xAxis); var yAxis = new OxyPlot.Axes.LinearAxis(); yAxis.Position = AxisPosition.Left; yAxis.MajorGridlineStyle = LineStyle.Solid; yAxis.Minimum = 0.0; yAxis.Maximum = 1.0; m_plot.Axes.Add(yAxis); if (bRefresh) { m_timer = new Timer(updatePlot); m_timer.Change(m_updateFreq, m_updateFreq); } }
private PlotModel createBaseModel(DoubleRange? range, string title, double[] x, double[] y, bool discrete) { var plotModel = new PlotModel(); plotModel.Series.Clear(); plotModel.Axes.Clear(); double ymin = y.FirstOrDefault(a => !Double.IsNaN(a) && !Double.IsInfinity(a)); double ymax = ymin; for (int i = 0; i < y.Length; i++) { if (Double.IsNaN(y[i]) || Double.IsInfinity(y[i])) continue; if (y[i] > ymax) ymax = y[i]; if (y[i] < ymin) ymin = y[i]; } double maxGrace = ymax * 0.1; double minGrace = ymin * 0.1; if (!discrete) { var xAxis = new OxyPlot.Axes.LinearAxis() { Position = AxisPosition.Bottom, Minimum = range.Value.Min, Maximum = range.Value.Max, Key = "xAxis", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 80 }; var yAxis = new LinearAxis() { Position = AxisPosition.Left, Minimum = ymin - minGrace, Maximum = ymax + maxGrace, Key = "yAxis", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = title }; plotModel.Axes.Add(xAxis); plotModel.Axes.Add(yAxis); var lineSeries = new LineSeries { YAxisKey = yAxis.Key, XAxisKey = xAxis.Key, StrokeThickness = 2, MarkerSize = 3, MarkerStroke = OxyColor.FromRgb(0, 0, 0), MarkerType = MarkerType.None, Smooth = true, }; for (int i = 0; i < x.Length; i++) { if (Double.IsNaN(y[i]) || Double.IsInfinity(y[i])) continue; lineSeries.Points.Add(new DataPoint(x[i], y[i])); } plotModel.Series.Add(lineSeries); } else { var xAxis = new OxyPlot.Axes.CategoryAxis() { Position = AxisPosition.Bottom, Key = "xAxis", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, }; var yAxis = new LinearAxis() { Position = AxisPosition.Left, Minimum = ymin - minGrace, Maximum = ymax + maxGrace, Key = "yAxis", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = title }; plotModel.Axes.Add(xAxis); plotModel.Axes.Add(yAxis); var boxSeries = new ColumnSeries { YAxisKey = yAxis.Key, XAxisKey = xAxis.Key, StrokeThickness = 2, ColumnWidth = 1, }; for (int i = 0; i < x.Length; i++) { xAxis.Labels.Add(x[i].ToString("G2")); var item = new ColumnItem(y[i]); boxSeries.Items.Add(item); } plotModel.Series.Add(boxSeries); } var formattable = instance as IFormattable; if (formattable != null) { plotModel.Title = formattable.ToString("G3", CultureInfo.CurrentUICulture); } else { plotModel.Title = instance.ToString(); } plotModel.TitlePadding = 2; plotModel.TitleFontSize = 15; plotModel.TitleFontWeight = 1; plotModel.TitlePadding = 2; return plotModel; }
private void LoadData2(double[] valPortef, double[] valBenchmark) { var tmp = new PlotModel { Title = "Rendements du portefeuille vs Benchmark" }; var series1 = new OxyPlot.Series.LineSeries { Title = "Portefeuille", MarkerType = MarkerType.None }; int j = 0; while (Date[j] != TDebut) { j++; } TimeSpan diff; for (int i = 0; i < valPortef.Length; i++) { diff = Date[j+i] - new DateTime(1899, 12, 31, 0, 0, 0); series1.Points.Add(new DataPoint(diff.TotalDays, valPortef[i])); } var series2 = new OxyPlot.Series.LineSeries { Title = "Benchmark", MarkerType = MarkerType.None }; for (int i = 0; i < valBenchmark.Length; i++) { diff = Date[j+i] - new DateTime(1899, 12, 31, 0, 0, 0); series2.Points.Add(new DataPoint(diff.TotalDays, valBenchmark[i])); } tmp.Series.Add(series1); tmp.Series.Add(series2); var dateAxis = new OxyPlot.Axes.DateTimeAxis(AxisPosition.Bottom, "Date", "dd/MM/yy") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot }; //dateAxis.Minimum = OxyPlot.Axes.DateTimeAxis.ToDouble(TDebut); //dateAxis.Maximum = OxyPlot.Axes.DateTimeAxis.ToDouble(TFin); dateAxis.IntervalType = DateTimeIntervalType.Months; tmp.Axes.Add(dateAxis); var valueAxis = new OxyPlot.Axes.LinearAxis(AxisPosition.Left) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Value", IntervalLength = 50 }; tmp.Axes.Add(valueAxis); this.PlotModel2 = tmp; }
private void SetUpModel() { PlotModel.LegendTitle = "Portefeuille vs Benchmark"; PlotModel.LegendOrientation = LegendOrientation.Horizontal; PlotModel.LegendPlacement = LegendPlacement.Outside; PlotModel.LegendPosition = LegendPosition.BottomLeft; PlotModel.LegendBackground = OxyColor.FromAColor(200, OxyColors.White); PlotModel.LegendBorder = OxyColors.Black; var dateAxis = new OxyPlot.Axes.DateTimeAxis(AxisPosition.Bottom, "Date", "dd/MM/yy") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot}; dateAxis.Minimum = OxyPlot.Axes.DateTimeAxis.ToDouble(TDebut); dateAxis.Maximum = OxyPlot.Axes.DateTimeAxis.ToDouble(TFin); dateAxis.IntervalType = DateTimeIntervalType.Months; PlotModel.Axes.Add(dateAxis); var valueAxis = new OxyPlot.Axes.LinearAxis(AxisPosition.Left) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Value" }; PlotModel.Axes.Add(valueAxis); PlotModel2.LegendTitle = "Portefeuille vs Benchmark"; PlotModel2.LegendOrientation = LegendOrientation.Horizontal; PlotModel2.LegendPlacement = LegendPlacement.Outside; PlotModel2.LegendPosition = LegendPosition.BottomLeft; PlotModel2.LegendBackground = OxyColor.FromAColor(200, OxyColors.White); PlotModel2.LegendBorder = OxyColors.Black; var dateAxis2 = new OxyPlot.Axes.DateTimeAxis(AxisPosition.Bottom, "Date", "dd/MM/yy") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot}; PlotModel2.Axes.Add(dateAxis2); var valueAxis2 = new OxyPlot.Axes.LinearAxis(AxisPosition.Left) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Value" }; PlotModel2.Axes.Add(valueAxis2); }
void SetupLinePlot(OxyPlot.Wpf.PlotView plot, string title) { plot.Model = new PlotModel { Title = title }; var series = new LineSeries(); series.Color = OxyColors.SteelBlue; series.ItemsSource = new List<DataPoint>(); plot.Model.Series.Add(series); var xaxis = new OxyPlot.Axes.LinearAxis() { Key = "XAxis", Position = OxyPlot.Axes.AxisPosition.Bottom, }; var yaxis = new LinearAxis() { Key = "YAxis", Position = OxyPlot.Axes.AxisPosition.Left, }; plot.Model.Axes.Add(xaxis); plot.Model.Axes.Add(yaxis); plot.ActualController.UnbindAll(); }
private Axis ConvertAxis(ChartAxisViewModel axis) { Axis newAxis = null; switch (axis.AxisType) { case (ChartAxisType.CategoryX): { newAxis = new CategoryAxis { LabelField = axis.ValueMemberPath, ItemsSource = axis.DataSource.Data }; break; } case (ChartAxisType.NumericX): case (ChartAxisType.NumericY): { newAxis = new LinearAxis { }; break; } case(ChartAxisType.CategoryDateTimeX): { var dtaxis = new DateTimeAxis { IntervalType = DateTimeIntervalType.Auto, }; var scale = axis.GetScaleForProperty(axis.ValueMemberPath); if (null != scale) { scale.PropertyChanged += (s, a) => { if( a.PropertyName != "Minimum" && a.PropertyName != "Maximum") { return; } var min = new DateTime((long)scale.Minimum); var max = new DateTime((long)scale.Maximum); var laxis = _plotModel.Axes.FirstOrDefault(x => x.Title == scale.Name) as DateTimeAxis; if( null == laxis ) { return; } var delta = max - min; var lmax = 0.0d; var lmin = 0.0d; if (TimeSpan.FromSeconds(1) > delta) { laxis.IntervalType = DateTimeIntervalType.Seconds; } else if (TimeSpan.FromMinutes(1) > delta) { laxis.IntervalType = DateTimeIntervalType.Minutes; } else if (TimeSpan.FromHours(1) > delta) { laxis.IntervalType = DateTimeIntervalType.Hours; } else if (TimeSpan.FromDays(1) > delta) { laxis.IntervalType = DateTimeIntervalType.Days; } else if (TimeSpan.FromDays(30) > delta) { laxis.IntervalType = DateTimeIntervalType.Months; } else { laxis.IntervalType = DateTimeIntervalType.Auto; } //TODO: remove laxis.IntervalType = DateTimeIntervalType.Seconds; //laxis.Minimum = scale.Minimum; //laxis.Maximum = scale.Maximum; OnPlotModelChanged(); }; } newAxis = dtaxis; break; } } if (null == newAxis) { return null; } switch (axis.AxisLocation) { case(AxisLocation.InsideBottom): case(AxisLocation.OutsideBottom): { newAxis.Position = AxisPosition.Bottom; break; } case (AxisLocation.InsideTop): case (AxisLocation.OutsideTop): { newAxis.Position = AxisPosition.Top; break; } case (AxisLocation.InsideLeft): case (AxisLocation.OutsideLeft): { newAxis.Position = AxisPosition.Left; break; } case (AxisLocation.InsideRight): case (AxisLocation.OutsideRight): { newAxis.Position = AxisPosition.Right; break; } default: { newAxis.Position = AxisPosition.None; break; } } newAxis.Title = axis.Name; var series = axis.AxisScaleDescriptors.FirstOrDefault(); if (null != series) { newAxis.Title = series.Scale.Name; } newAxis.Key = newAxis.Title; return newAxis; }
public void FormatAsFractionsThreeHalfPi() { var axis = new LinearAxis { FormatAsFractions = true, FractionUnit = Math.PI, FractionUnitSymbol = "π" }; Assert.AreEqual("3π/2", axis.FormatValue(3d / 2 * Math.PI)); }
public void FormatAsFractionsTwoPi() { var axis = new LinearAxis { FormatAsFractions = true, FractionUnit = Math.PI, FractionUnitSymbol = "π" }; Assert.AreEqual("2π", axis.FormatValue(2 * Math.PI)); }
private void InitializeGraph() { PlotModel plot = new PlotModel(); OxyPlot.Axes.LinearAxis costAxis = new OxyPlot.Axes.LinearAxis(AxisPosition.Left); costAxis.Key = "cost"; OxyPlot.Axes.LinearAxis progressionAxis = new OxyPlot.Axes.LinearAxis(AxisPosition.Right); progressionAxis.Key = "progression"; plot.Axes.Add(costAxis); plot.Axes.Add(progressionAxis); plot.Axes.Add(new OxyPlot.Axes.LinearAxis(AxisPosition.Bottom)); OxyPlot.Series.ScatterSeries costSeries = new OxyPlot.Series.ScatterSeries(); costSeries.YAxisKey = "cost"; OxyPlot.Series.StairStepSeries progressionSeries = new OxyPlot.Series.StairStepSeries(OxyColor.FromRgb(0, 255, 0), LINES_THICKNESS, "Poprawa"); progressionSeries.YAxisKey = "progression"; OxyPlot.Series.StairStepSeries regressionSeries = new OxyPlot.Series.StairStepSeries(OxyColor.FromRgb(255, 0, 0), LINES_THICKNESS, "Pogorszenie"); regressionSeries.YAxisKey = "progression"; plot.Series.Add(costSeries); plot.Series.Add(progressionSeries); plot.Series.Add(regressionSeries); VM.GraphPlotModel = plot; }
public TimeMainViewModel() { HorizontalAxis = new TimeSpanAxis { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, StringFormat = "hh:mm:ss", MajorStep = 1, MinorStep = 0.1, TextColor = OxyColors.Black, Position = AxisPosition.Bottom }; VerticalAxis = new LinearAxis { Position = AxisPosition.Left, IsAxisVisible = false }; Model.Axes.Add(HorizontalAxis); Model.Axes.Add(VerticalAxis); }
public void TwoEqualAxes() { var axis1 = new LinearAxis(); var axis2 = new LinearAxis(); Assert.IsTrue(axis1.GetHashCode() != axis2.GetHashCode()); }
public void FormatAsFractionsWithStringFormat() { var model = new PlotModel { Culture = CultureInfo.InvariantCulture }; var axis = new LinearAxis { FormatAsFractions = true, FractionUnit = Math.PI, FractionUnitSymbol = "π", StringFormat = "0.###" }; model.Axes.Add(axis); ((IPlotModel)model).Update(true); Assert.AreEqual("1.273π", axis.FormatValue(4)); }
public void Axis_VerticalAlignment_MinimumRange_AbsoluteMinimum() { var plot = new PlotModel(); var yaxis = new LinearAxis() { Position = AxisPosition.Left, MinimumRange = 1, AbsoluteMinimum = 10, }; plot.Axes.Add(yaxis); var series = new LineSeries(); series.Points.Add(new DataPoint(0, 10.1)); series.Points.Add(new DataPoint(1, 10.15)); series.Points.Add(new DataPoint(2, 10.3)); series.Points.Add(new DataPoint(3, 10.25)); plot.Series.Add(series); ((IPlotModel)plot).Update(true); // Center should be the between AbsoluteMinimum and the (AboluteMinimum + MinimumRange) Assert.AreEqual(yaxis.AbsoluteMinimum, plot.Axes[0].ActualMinimum, 0, "absolute minimum"); Assert.AreEqual(yaxis.AbsoluteMinimum + (yaxis.MinimumRange / 2), (plot.Axes[0].ActualMaximum + plot.Axes[0].ActualMinimum) / 2, 1e-5, "center"); Assert.AreEqual(yaxis.AbsoluteMinimum + yaxis.MinimumRange, plot.Axes[0].ActualMaximum, 1e-5, "maximum"); }
public void Axis_VerticalAlignment_MinimumRange() { var plot = new PlotModel(); var yaxis = new LinearAxis() { Position = AxisPosition.Left, MinimumRange = 1, }; plot.Axes.Add(yaxis); var series = new LineSeries(); series.Points.Add(new DataPoint(0, 10.1)); series.Points.Add(new DataPoint(1, 10.15)); series.Points.Add(new DataPoint(2, 10.3)); series.Points.Add(new DataPoint(3, 10.25)); plot.Series.Add(series); ((IPlotModel)plot).Update(true); double dataMin = 10.1; double dataMax = 10.3; double dataCenter = (dataMax + dataMin) / 2; // Center should be the between data min and max Assert.AreEqual(dataCenter, (plot.Axes[0].ActualMaximum + plot.Axes[0].ActualMinimum) / 2, 1e-5, "center"); Assert.AreEqual(dataCenter - 0.5, plot.Axes[0].ActualMinimum, 1e-5, "minimum"); Assert.AreEqual(dataCenter + 0.5, plot.Axes[0].ActualMaximum, 1e-5, "maximum"); }
public void Axis_DesiredSize() { var xaxis = new LinearAxis { Position = AxisPosition.Bottom, Title = "X-axis" }; var yaxis = new LinearAxis { Position = AxisPosition.Left, Title = "Y-axis" }; var plot = new PlotModel { Title = "Simple plot" }; plot.Axes.Add(xaxis); plot.Axes.Add(yaxis); 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); // initial setting plot.UpdateAndRenderToNull(800, 600); Assert.That(yaxis.DesiredSize.Width, Is.EqualTo(35.0).Within(0.5), "y-axis width"); Assert.That(yaxis.DesiredSize.Height, Is.EqualTo(0.0).Within(1e-6), "y-axis height"); Assert.That(xaxis.DesiredSize.Width, Is.EqualTo(0.0).Within(1e-6), "x-axis width"); Assert.That(xaxis.DesiredSize.Height, Is.EqualTo(35.0).Within(0.5), "x-axis height"); // larger numbers on axis -> larger desired size yaxis.Zoom(10000, 11000); plot.UpdateAndRenderToNull(800, 600); Assert.That(yaxis.DesiredSize.Width, Is.EqualTo(50.0).Within(0.5), "y-axis width"); Assert.That(yaxis.DesiredSize.Height, Is.EqualTo(0.0).Within(1e-6), "y-axis height"); }
void setupTrackPlot(OxyPlot.Wpf.PlotView plot) { var plotModel = new PlotModel { }; plot.Model = plotModel; var songPointsFull = new List<ScatterPoint>(); var songSeries = new ScatterSeries(); songSeries.ItemsSource = songPointsFull; songSeries.MarkerType = MarkerType.Square; songSeries.MarkerSize = 0.1; plotModel.Series.Add(songSeries); var x_axis = new OxyPlot.Axes.LinearAxis() { Key = "XAxis", Position = OxyPlot.Axes.AxisPosition.Bottom, IsAxisVisible = false, //AbsoluteMaximum = 1800, //AbsoluteMinimum = -1, //MinorStep = 10, }; var y_axis = new LinearColorAxis() { Key = "YAxis", Position = OxyPlot.Axes.AxisPosition.Left, Palette = OxyPalettes.Hue(12), Minimum = 0, Maximum = 12, IsAxisVisible = false }; plot.ActualController.UnbindAll(); plotModel.IsLegendVisible = false; plotModel.Axes.Add(x_axis); plotModel.Axes.Add(y_axis); }
/// <summary> /// The mobility fit FitLine plot. /// </summary> /// <param name="fitline"> /// The fitline. /// </param> /// <returns> /// The <see cref="PlotModel"/>. /// </returns> private PlotModel MobilityFitLinePlot(FitLine fitline) { IEnumerable<ContinuousXYPoint> fitPointList = fitline.FitPointCollection.Select(x => x.Point); IEnumerable<ContinuousXYPoint> outlierList = fitline.OutlierCollection.Select(x => x.Point); Func<object, ScatterPoint> fitPointMap = obj => { ContinuousXYPoint point = (ContinuousXYPoint)obj; double size = 5; double color = 0; ScatterPoint sp = new ScatterPoint(point.X, point.Y, size, color); return sp; }; Func<object, ScatterPoint> OutlierPointMap = obj => { ContinuousXYPoint point = (ContinuousXYPoint)obj; double size = 5; double color = 1; ScatterPoint sp = new ScatterPoint(point.X, point.Y, size, color); return sp; }; PlotModel model = new PlotModel(); model.TitlePadding = 0; model.Title = "Mobility Fit FitLine"; ScatterSeries fitPointSeries = new ScatterSeries { Mapping = fitPointMap, ItemsSource = fitPointList, }; ScatterSeries outlierSeries = new ScatterSeries { Mapping = OutlierPointMap, ItemsSource = outlierList, }; Func<object, DataPoint> lineMap = obj => { ContinuousXYPoint point = (ContinuousXYPoint)obj; double x = point.X; double y = fitline.ModelPredictX2Y(x); DataPoint sp = new DataPoint(x, y); return sp; }; LineSeries fitlineSeries = new LineSeries() { Mapping = lineMap, ItemsSource = fitPointList, Color = OxyColors.Purple }; var yAxis = new LinearAxis() { Title = "IMS scan time (milliseconds)", MajorGridlineStyle = LineStyle.Solid, Position = AxisPosition.Left, //MajorStep = 100.0, //MinorStep = 50.0, //Minimum = 0, //Maximum = 360, //FilterMinValue = 0, //FilterMaxValue = 360, }; var xAxis = new LinearAxis() { Title = "Pressure / (Temperature * Voltage) (1 / V))", Position = AxisPosition.Bottom, MajorGridlineStyle = LineStyle.Solid, //MajorStep = 100.0, //MinorStep = 50.0, //Minimum = 1000, //Maximum = 2000, //MinimumRange = 100.0, //FilterMinValue = 1000, //FilterMaxValue = 2000, }; model.Axes.Add(yAxis); model.Axes.Add(xAxis); model.Series.Add(fitPointSeries); model.Series.Add(outlierSeries); model.Series.Add(fitlineSeries); return model; }