public Window1() { InitializeComponent(); List <tabela> lista = new List <tabela>(); for (int i = 0; i < Global.procesy_nazwy.Count(); i++) { lista.Add(new tabela() { Id = Global.procesy[i], Lp = i + 1, Name = Global.procesy_nazwy[i].ProcessName.ToString(), Czas = Global.tab[i] / 1000 }); } dgUsers.ItemsSource = lista; //W konstruktorze oxyPlotModel = new OxyPlotModel(); //To pozwala połączyć kontrolki z polami klasy OxyPlotModel this.DataContext = oxyPlotModel; oxyPlotModel.PodajDaneDoWykresu2(Global.X, Global.Y, Global.procesy_nazwy); oxyPlotModel.SetUpLegend(); oxyPlotModel.PlotModel.RefreshPlot(true); }
private static OxyPlotModel CreateLinePlotModel() { var model = new OxyPlotModel(SerieTypes.Line, "Test", "legend"); // Create two line series (markers are hidden by default) var series1 = new LineSeries("Series 1"); // { MarkerType = MarkerType.Circle }; series1.Points.Add(new DataPoint(0, 0)); series1.Points.Add(new DataPoint(10, 18)); series1.Points.Add(new DataPoint(20, 12)); series1.Points.Add(new DataPoint(30, 8)); series1.Points.Add(new DataPoint(40, 15)); var series2 = new LineSeries("Series 2"); // { MarkerType = MarkerType.Square }; series2.Points.Add(new DataPoint(0, 4)); series2.Points.Add(new DataPoint(10, 12)); series2.Points.Add(new DataPoint(20, 16)); series2.Points.Add(new DataPoint(30, 25)); series2.Points.Add(new DataPoint(40, 5)); // Add the series to the plot model model.Series.Add(series1); model.Series.Add(series2); return(model); }
public MainPageViewModel(INavigationService navigationService, OxyPlotModel oxyPlotModel, AnimationModel animationModel) { this.BarChart = oxyPlotModel.Model; this.UpdateContentsCommand = new Command <double>(newValue => { oxyPlotModel.Update(newValue); animationModel.Update(newValue); }); }
/// <summary> /// Creates Oxyplot library plot model /// </summary> /// <returns></returns> private PlotModel CreateOxyPlotModel(XyPlot plot) { var tmp = new PlotModel { Title = plot.Name }; tmp.IsLegendVisible = ShowLegend; this.ShowLegendChanged += (o, e) => { tmp.IsLegendVisible = this.ShowLegend; OxyPlotModel.InvalidatePlot(false); }; for (var i = 0; i < plot.Series.Count; i++) { if (plot.Series[i].Points.Count > 1) { var series = new LineSeries { Title = plot.Series[i].Name, MarkerType = MarkerType.None, Color = OxyColor.FromRgb((byte)rand.Next(255), (byte)rand.Next(255), (byte)rand.Next(255)) }; Series[i].Brush = new SolidColorBrush(Color.FromRgb(series.Color.R, series.Color.G, series.Color.B)); tmp.Series.Add(series); for (var j = 0; j < plot.Series[i].Points.Count; j++) { var y = plot.Series[i].Points[j].Y; series.Points.Add(new DataPoint(plot.Series[i].Points[j].X, y)); } series.IsVisible = Series[i].Selected; Series[i].SelectedChanged += (o, e) => { series.IsVisible = ((SpiceSharpGUI.Windows.ViewModels.Series)o).Selected; OxyPlotModel.InvalidatePlot(false); }; } else { var scatterSeries = new ScatterSeries { Title = plot.Series[i].Name, MarkerSize = 3, SelectionMode = SelectionMode.Single, MarkerType = MarkerType.Circle, MarkerFill = OxyColor.FromRgb((byte)rand.Next(255), (byte)rand.Next(255), (byte)rand.Next(255)) }; Series[i].Brush = new SolidColorBrush(Color.FromRgb(scatterSeries.MarkerFill.R, scatterSeries.MarkerFill.G, scatterSeries.MarkerFill.B)); scatterSeries.Points.Add(new ScatterPoint(plot.Series[i].Points[0].X, plot.Series[i].Points[0].Y)); tmp.Series.Add(scatterSeries); scatterSeries.IsVisible = Series[i].Selected; Series[i].SelectedChanged += (o, e) => { scatterSeries.IsVisible = ((SpiceSharpGUI.Windows.ViewModels.Series)o).Selected; OxyPlotModel.InvalidatePlot(false); }; } } CreateAxis(plot, tmp); YScaleLogChanged += (o, e) => { CreateAxis(plot, tmp); OxyPlotModel.InvalidatePlot(false); }; XScaleLogChanged += (o, e) => { CreateAxis(plot, tmp); OxyPlotModel.InvalidatePlot(false); }; return(tmp); }
public void AddDVHs(List <DoseVolumeHistogram> dvhs) { OxyPlotModel.Series.Clear(); foreach (var dvh in dvhs) { OxyPlotModel.Series.Add(createLineSeries(dvh)); } OxyPlotModel.InvalidatePlot(true); }
/// <summary> /// Plots the specified plotModel model. /// </summary> /// <param name="plotModel">The plotModel.</param> /// <exception cref="ArgumentNullException">The <paramref name="plotModel"/> is <c>null</c>.</exception> public void Plot(OxyPlotModel plotModel) { Argument.IsNotNull("plotModel", plotModel); var orchestraService = GetService <IOrchestraService>(); var viewModel = new OxyPlotViewModel(plotModel); orchestraService.ShowDocument(viewModel); }
static Object Unbind(OxyPlotModel model) { var view = model.Model.PlotView as PlotView; if (view != null) { view.Model = null; } return(model); }
public SumericsOxyPlot(XYPlotValue plot) : base(plot) { _plot = plot; var model = new PlotModel(); _model = new OxyPlotModel { Model = model, CanEditSeries = true, CanToggleGrid = true }; }
private void button_Click(object sender, RoutedEventArgs e) { textBox.Text = (Global.czas1 / 1000).ToString() + "[s]"; try { Global.b = (Int32.Parse(TextBoxDo.Text)); Global.b = Global.b / (Global.interval / 1000); // Global.a = (Int32.Parse(TextBoxOd.Text)) * 1000; if (Global.b != 0) { List <tabela> lista = new List <tabela>(); for (int i = 0; i < Global.procesy.Count(); i++) { int suma = 0; for (int ii = 0; ii < Global.b; ii++) { if (Global.YY[i][ii] == 1) { suma = suma + 1; } else { suma = suma; } } double proc = (double)suma / (double)Global.b * 100; if (proc != 0) { lista.Add(new tabela() { Id = Global.procesy[i], Lp = i + 1, Name = Global.procesy_nazwy[i].ProcessName.ToString(), Czas = suma, Procent = proc }); } } dgUsers.ItemsSource = lista; //W konstruktorze oxyPlotModel = new OxyPlotModel(); //To pozwala połączyć kontrolki z polami klasy OxyPlotModel this.DataContext = oxyPlotModel; oxyPlotModel.PodajDaneDoWykresu(lista); oxyPlotModel.PlotModel.RefreshPlot(true); } } catch { MessageBox.Show("Wprowadz liczbe całkowita wieksza od zera lub odpowiednia ilość czasu dzialania apliakacji"); }; }
/// <summary> /// Method to invoke when the Edit command is executed. /// </summary> private async Task OnClearExecute() { lock (_lockObject) { Messages.Clear(); _dataLog.Clear(); foreach (OxyPlot.Series.LineSeries series in OxyPlotModel.Series) { series.Points.Clear(); } foreach (var ax in OxyPlotModel.Axes) { ax.Maximum = ax.Minimum = Double.NaN; } OxyPlotModel.ResetAllAxes(); OxyPlotModel.InvalidatePlot(true); ViewModelCommandManager.InvalidateCommands(true); } }
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); }
private void button_Click(object sender, RoutedEventArgs e) { textBox.Text = (Global.czas1 / 1000).ToString() + "[s] "; List <tabela> lista = new List <tabela>(); for (int i = 0; i < Global.procesy_nazwy.Count(); i++) { lista.Add(new tabela() { Id = Global.procesy[i], Lp = i + 1, Name = Global.procesy_nazwy[i].ProcessName.ToString(), Czas = Global.tab[i] / 1000 }); } dgUsers.ItemsSource = lista; //W konstruktorze oxyPlotModel = new OxyPlotModel(); //To pozwala połączyć kontrolki z polami klasy OxyPlotModel this.DataContext = oxyPlotModel; oxyPlotModel.PodajDaneDoWykresu2(Global.X, Global.Y, Global.procesy_nazwy); oxyPlotModel.SetUpLegend(); oxyPlotModel.PlotModel.RefreshPlot(true); }
public MainAppWindow() { oxyPlotModel = new OxyPlotModel(); this.DataContext = oxyPlotModel; InitializeComponent(); }
protected void UpdatePlotConfiguration() { // "PlotName" { OxyPlotModel.Title = PlotModel.PlotConfiguration.PlotName; } // "Axes" { //remove deleted Axes first var toRemoveAxis = new List <OxyPlot.Axes.LinearAxis>(); foreach (OxyPlot.Axes.LinearAxis oxaxis in OxyPlotModel.Axes) { if (oxaxis.Position != AxisPosition.Bottom) { var axis = PlotModel.PlotConfiguration.Axes.FirstOrDefault(x => x.OxyAxis == oxaxis);//don't remove xaxis if (axis == null) { toRemoveAxis.Add(oxaxis); } } } foreach (OxyPlot.Axes.LinearAxis oxaxis in toRemoveAxis) { OxyPlotModel.Axes.Remove(oxaxis); } foreach (AxisDefinitionModel axis in PlotModel.PlotConfiguration.Axes) { //can't use FirstOrDefault as OxyPlot sets default to first axis OxyPlot.Axes.LinearAxis oxaxis = null; foreach (OxyPlot.Axes.LinearAxis oa in OxyPlotModel.Axes) { if ((AxisDefinitionModel)oa.Tag == axis) { oxaxis = oa; break; } } //OxyPlot.Axes.LinearAxis oxaxis = OxyPlotModel.Axes.FirstOrDefault(x => x.Tag == axis) as OxyPlot.Axes.LinearAxis; if (oxaxis == null) { var yAxis = new OxyPlot.Axes.LinearAxis { Position = ConvertAxisToOxyPlot(axis.AxisPosition), Title = axis.AxisTitle, Unit = axis.Unit, Key = axis.Key }; yAxis.Tag = axis; OxyPlotModel.Axes.Add(yAxis); } else { //update oxaxis.Position = ConvertAxisToOxyPlot(axis.AxisPosition); oxaxis.Title = axis.AxisTitle; oxaxis.Unit = axis.Unit; oxaxis.Key = axis.Key; } } } //"Series" { //delete removed series first. var toRemoveSeries = new List <OxyPlot.Series.LineSeries>(); foreach (OxyPlot.Series.LineSeries oxseries in OxyPlotModel.Series) { { var series = PlotModel.PlotConfiguration.Series.FirstOrDefault(x => x.OxySeries == oxseries);//don't remove xaxis if (series == null) { toRemoveSeries.Add(oxseries); } } } foreach (OxyPlot.Series.LineSeries oxseries in toRemoveSeries) { OxyPlotModel.Series.Remove(oxseries); } foreach (SeriesDefinitionModel series in PlotModel.PlotConfiguration.Series) { //can't use FirstOrDefault as OxyPlot sets default to first axis OxyPlot.Series.LineSeries oxseries = null; foreach (OxyPlot.Series.LineSeries os in OxyPlotModel.Series) { if ((AxisDefinitionModel)os.Tag == series) { oxseries = os; break; } } //var oxseries = OxyPlotModel.Series.FirstOrDefault(x => x.Tag == series) as OxyPlot.Series.LineSeries; if (oxseries == null) { 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; OxyPlotModel.Series.Add(oxseries); } else { //update oxseries.Title = series.SeriesTitle; oxseries.Color = OxyColor.FromArgb(series.Color.A, series.Color.R, series.Color.G, series.Color.B); oxseries.YAxisKey = series.YAxisKey; } } StringBuilder logFormat = new StringBuilder();//always have time as first parameter AppendLogFormatFromSeries(logFormat, PlotModel.PlotConfiguration.Series); PlotModel.LogFormat = logFormat.ToString(); OnLogFormatChanged(); } OxyPlotModel.InvalidatePlot(true); }
private bool PlotMessages() { var seriespoints = new List <List <DataPoint> >(); foreach (SeriesDefinitionModel series in PlotModel.PlotConfiguration.Series) { seriespoints.Add(new List <DataPoint>()); } foreach (string[] msg in Messages) { //Typical log statement: //Sample,Time,Command,Position,Output //printf("@F,%g,%g,%g,%g\n",tickcurr,CHANNELTOTEST->Dest,CHANNELTOTEST->Position,CHANNELTOTEST->Output); //where @F is the log identifier, so msg[0] == "@F", which we ignore here, data starts at index 1, which //is always time //PlotDefinition.Series.ToList().Zip(OxyPlotModel.Series, (n, w) => new { Number = n, Word = w }); if (msg.Count() != _data.Format.LogDelimitCount) { string errmsg = string.Format("Invalid message for this plot, format length {0:D} does not equal message length {1:D}.", _data.Format.LogDelimitCount, msg.Count()); LogTo.Error(errmsg); Messages.Clear(); return(false); } double x, y1, y2; if (FromHex) { LongToDouble xh = new LongToDouble(0.0d); ulong.TryParse(msg[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out xh.ul); x = xh.d; //double dd = 0; //Double.TryParse(msg[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out dd); } else { Double.TryParse(msg[1], out x);//first param is always time, x axis } var zip = PlotModel.PlotConfiguration.Series.ToList().Zip(seriespoints, (n, w) => new { series = n, seriesPoints = w }); foreach (var defAndSeries in zip) //foreach (SeriesDefinitionModel series in PlotDefinition.Series) { if (FromHex) { LongToDouble y1h = new LongToDouble(0.0d); ulong.TryParse(msg[defAndSeries.series.ResultIndex1], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out y1h.ul); y1 = y1h.d; } else { Double.TryParse(msg[defAndSeries.series.ResultIndex1], out y1);//first param is always time, x axis } //Double.TryParse(msg[defAndSeries.series.ResultIndex1], out y1); DataPoint p = new DataPoint(x, y1); if (defAndSeries.series.ResultOperator != PlotAxisOperatorEnum.None) { if (FromHex) { LongToDouble y2h = new LongToDouble(0.0d); ulong.TryParse(msg[defAndSeries.series.ResultIndex2.Value], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out y2h.ul); y2 = y2h.d; } else { Double.TryParse(msg[defAndSeries.series.ResultIndex2.Value], out y2);//first param is always time, x axis } //Double.TryParse(msg[defAndSeries.series.ResultIndex2.Value], out y2); switch (defAndSeries.series.ResultOperator) { case PlotAxisOperatorEnum.Add: p = new DataPoint(x, y1 + y2); break; case PlotAxisOperatorEnum.Subtract: p = new DataPoint(x, y1 - y2); break; case PlotAxisOperatorEnum.Multiple: p = new DataPoint(x, y1 * y2); break; case PlotAxisOperatorEnum.Divide: p = new DataPoint(x, y1 / y2); break; default: LogTo.Error("This should never happen."); break; } } defAndSeries.seriesPoints.Add(p); } } _dataLog.AddRange(Messages); Messages.Clear(); if (seriespoints.Count > 0 && seriespoints[0] != null && seriespoints[0].Count > 0) { //Update the plot on the GUI thread _userInterfaceDispatcher.Invoke(() => { var zip = OxyPlotModel.Series.Zip(seriespoints, (n, w) => new { series = n, seriesPoints = w }); foreach (var seriesAndPoints in zip) { OxyPlot.Series.LineSeries ls = seriesAndPoints.series as OxyPlot.Series.LineSeries; if (ls.Points.Count >= MaxPlotPoints) { ls.Points.RemoveRange(0, seriesAndPoints.seriesPoints.Count); } ls.Points.AddRange(seriesAndPoints.seriesPoints); } OxyPlotModel.InvalidatePlot(true); }); } return(true); }