public ViewChart(Group current) { this.model = new PlotModel("Postęp nauki dla "+current.Name); LineSeries basicSerie = new LineSeries("Postęp nauki"); LinearAxis ax = new LinearAxis(); ax.Unit = "%"; ax.Title = "Poprawne odpowiedzi"; model.Axes.Add(ax); SqlAccess sql = new SqlAccess(); basicSerie.Smooth = true; List<double> list = sql.GetStatsForGroup(current); int i = 1; if(list.Count>0) basicSerie.Points.Add(new DataPoint(0.0,0)); basicSerie.MarkerType = MarkerType.Circle; basicSerie.MarkerSize = 3; basicSerie.SelectionMode = SelectionMode.Single; foreach (double d in list) { basicSerie.Points.Add(new DataPoint(i,d)); i++; } this.model.Series.Add(basicSerie); }
public static PlotModel LineSerieswithcustomTrackerFormatString() { var plotModel1 = new PlotModel(); plotModel1.Subtitle = "TrackerFormatString = \"X={2:0.0} Y={4:0.0}\""; plotModel1.Title = "LineSeries with custom TrackerFormatString"; var linearAxis1 = new LinearAxis(); linearAxis1.Position = AxisPosition.Bottom; plotModel1.Axes.Add(linearAxis1); var linearAxis2 = new LinearAxis(); plotModel1.Axes.Add(linearAxis2); var lineSeries1 = new LineSeries(); lineSeries1.TrackerFormatString = "X={2:0.0} Y={4:0.0}"; lineSeries1.Points.Add(new DataPoint(0, 20)); lineSeries1.Points.Add(new DataPoint(10, 21)); lineSeries1.Points.Add(new DataPoint(20, 24)); lineSeries1.Points.Add(new DataPoint(30, 22)); lineSeries1.Points.Add(new DataPoint(40, 17)); lineSeries1.Points.Add(new DataPoint(50, 21)); lineSeries1.Points.Add(new DataPoint(60, 23)); lineSeries1.Points.Add(new DataPoint(70, 27)); lineSeries1.Points.Add(new DataPoint(80, 27)); lineSeries1.Points.Add(new DataPoint(90, 22)); lineSeries1.Points.Add(new DataPoint(100, 25)); plotModel1.Series.Add(lineSeries1); return plotModel1; }
private void InitializeChart() { plotView = FindViewById<PlotView>(Resource.Id.plotView); normalPointsSeries = new LineSeries(); // Set up our graph plotView.Model = new PlotModel(); plotView.Model.Series.Add(normalPointsSeries); plotView.Model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 0, Maximum = 100, IsZoomEnabled = false, IsPanEnabled = false }); plotView.Model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, IsZoomEnabled = false, IsPanEnabled = false }); UpdateChart(); }
public GraphComponents(OxyColor color) { scatters = new ScatterSeries { BinSize = 8, MarkerFill = color, MarkerSize = 2.0, MarkerStroke = color, MarkerStrokeThickness = 1.0, MarkerType = MarkerType.Circle }; lines = new LineSeries { Color = color, LineStyle = LineStyle.Solid, StrokeThickness = 1.0, Smooth = true }; stems = new StemSeries { Color = color, StrokeThickness = 1.0, }; }
private LineSeries TargetProbabilityLine(Double target) { LineSeries result = new LineSeries(OxyColors.Red, title: "1/m"); result.Points.Add(new DataPoint(-1.0, target)); result.Points.Add(new DataPoint( 20.0, target)); return result; }
private RadCartesianChartView createChart(){ RadCartesianChartView chart = new RadCartesianChartView(this.Activity); CategoricalAxis horizontalAxis = new CategoricalAxis(); chart.HorizontalAxis = horizontalAxis; LinearAxis vertical1 = new LinearAxis(); vertical1.LabelFormat = "%.0f"; LinearAxis vertical2 = new LinearAxis(); vertical2.LabelFormat = "%.0f"; BarSeries series1 = new BarSeries(); ArrayList data = this.getData(); series1.ValueBinding = new ValueBinding1(); series1.CategoryBinding = new CategoryBinding(); series1.VerticalAxis = vertical1; series1.Data = data; chart.Series.Add(series1); LineSeries series2 = new LineSeries(); series2.ValueBinding = new ValueBinding2(); series2.CategoryBinding = new CategoryBinding(); series2.VerticalAxis = (vertical2); vertical2.HorizontalLocation = AxisHorizontalLocation.Right; series2.Data = data; chart.Series.Add(series2); return chart; }
public PointsGraphWindow() { InitializeComponent(); listBox.ItemsSource = lbxpts; GraphModel = new PlotModel(); var sr = new LineSeries(); sr.Color = OxyColors.Green; sr.MarkerType = MarkerType.Circle; sr.MarkerFill = OxyColors.SteelBlue; var sri = new LineSeries(); sri.Color = OxyColors.Red; sri.Smooth = true; sri.IsVisible = false; GraphModel.Series.Add(sr); GraphModel.Series.Add(sri); chartCanvas.InvalidatePlot(); GraphModel.Axes.Add(new LinearAxis { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MinorTickSize = 0, Title = "y" }); GraphModel.Axes.Add(new LinearAxis { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, MinorTickSize = 0, Position = AxisPosition.Bottom, Title = "x" }); txtX.ItemsSource = Funcs; txtY.ItemsSource = Funcs; }
protected override void ShowNearestSelectedPointCommands(AppIdentity identity, LineSeries lineSeries, OxyMouseDownEventArgs args) { GuiModelData.SelectedApplicationIdentity = identity; var requestId = getSelectedRequestId(args.HitTestResult.Index, lineSeries); showCommands(requestId); setSelectedPointInfo(lineSeries, args); }
public void Open(string file) { var doc = new CsvDocument(); doc.Load(file); var tmp = new PlotModel { Title = Path.GetFileNameWithoutExtension(file), LegendPosition = LegendPosition.RightTop, LegendPlacement = LegendPlacement.Outside, PlotMargins = new OxyThickness(50, 0, 0, 40) }; for (int i = 1; i < doc.Headers.Length; i++) { var ls = new LineSeries { Title = doc.Headers[i] }; foreach (var item in doc.Items) { double x = this.ParseDouble(item[0]); double y = this.ParseDouble(item[i]); ls.Points.Add(new DataPoint(x, y)); } tmp.Series.Add(ls); } tmp.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = doc.Headers[0] }); this.Model = tmp; }
private static int getSelectedRequestId(double index, LineSeries lineSeries) { var indexOfNearestPoint = (int)Math.Round(index); var point = lineSeries.Points[indexOfNearestPoint]; var requestId = (int)point.X; return requestId; }
public FullyResponsiveExample() { InitializeComponent(); MyValues = new ChartValues<ObservableValue> { new ObservableValue(5), new ObservableValue(7), new ObservableValue(8), new ObservableValue(3) }; var lineSeries = new LineSeries { Values = MyValues, StrokeThickness = 4, Fill = new SolidColorBrush(Windows.UI.Colors.Transparent), PointGeometrySize = 0, DataLabels = true }; SeriesCollection = new SeriesCollection { lineSeries }; DataContext = this; }
public static Chart WpfConstruct(Signal signal) { Chart chart = new Chart(); LineSeries series = new LineSeries(); series.DependentValuePath = "Value"; series.IndependentValuePath = "Key"; KeyValuePair<double, double>[] points = new KeyValuePair<double, double>[signal.T.Length]; for (int i = 0; i < signal.T.Length; ++i) points[i] = new KeyValuePair<double, double>(signal.T[i], signal.X[i]); series.ItemsSource = points; chart.Height = 300; //Axis t = new LinearAxis(); //t.Name = "Time"; //Axis v = new LinearAxis(); //v.Name = "Value"; //chart.Axes.Add(t); //chart.Axes.Add(v); chart.Series.Add(series); return chart; }
private static PlotModel CreatePlotModel(string title, string subtitle) { // Create the plot model var tmp = new PlotModel { Title = title, Subtitle = subtitle }; tmp.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom }); tmp.Axes.Add(new LinearAxis { Position = AxisPosition.Left }); // Create two line series (markers are hidden by default) var series1 = new LineSeries { Title = "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 { Title = "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 tmp.Series.Add(series1); tmp.Series.Add(series2); // Axes are created automatically if they are not defined return tmp; }
public static PlotModel LineLegendPositionAtEnd() { // http://www.perceptualedge.com/example2.php var model = new PlotModel { Title = "Average (Mean) monthly temperatures in 2003", PlotMargins = new OxyThickness(60, 4, 60, 40), PlotAreaBorderThickness = new OxyThickness(0), IsLegendVisible = false }; const string TrackerFormatString = "{0}: {4:0.0}ºF"; var phoenix = new LineSeries { Title = "Phoenix", LineLegendPosition = LineLegendPosition.End, TrackerFormatString = TrackerFormatString }; var raleigh = new LineSeries { Title = "Raleigh", LineLegendPosition = LineLegendPosition.End, TrackerFormatString = TrackerFormatString }; var minneapolis = new LineSeries { Title = "Minneapolis", LineLegendPosition = LineLegendPosition.End, TrackerFormatString = TrackerFormatString }; var phoenixTemps = new[] { 52.1, 55.1, 59.7, 67.7, 76.3, 84.6, 91.2, 89.1, 83.8, 72.2, 59.8, 52.5 }; var raleighTemps = new[] { 40.5, 42.2, 49.2, 59.5, 67.4, 74.4, 77.5, 76.5, 70.6, 60.2, 50.0, 41.2 }; var minneapolisTemps = new[] { 12.2, 16.5, 28.3, 45.1, 57.1, 66.9, 71.9, 70.2, 60.0, 50.0, 32.4, 18.6 }; for (int i = 0; i < 12; i++) { phoenix.Points.Add(new DataPoint(i, phoenixTemps[i])); raleigh.Points.Add(new DataPoint(i, raleighTemps[i])); minneapolis.Points.Add(new DataPoint(i, minneapolisTemps[i])); } model.Series.Add(phoenix); model.Series.Add(raleigh); model.Series.Add(minneapolis); var categoryAxis = new CategoryAxis { AxislineStyle = LineStyle.Solid }; categoryAxis.Labels.AddRange(new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }); model.Axes.Add(categoryAxis); model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Fahrenheit", AxislineStyle = LineStyle.Solid }); return model; }
public static PlotModel TimeSpanaxisPlotModel() { var start = new TimeSpan(0, 0, 0, 0); var end = new TimeSpan(0, 24, 0, 0); double increment = 3600; // Create a random data collection var r = new Random(7); var data = new Collection<TimeValue>(); var current = start; while (current <= end) { data.Add(new TimeValue { Time = current, Value = r.NextDouble() }); current = current.Add(new TimeSpan(0, 0, (int)increment)); } var plotModel1 = new PlotModel { Title = "TimeSpan axis" }; var timeSpanAxis1 = new TimeSpanAxis { Position = AxisPosition.Bottom, StringFormat = "h:mm" }; plotModel1.Axes.Add(timeSpanAxis1); var linearAxis1 = new LinearAxis { Position = AxisPosition.Left }; plotModel1.Axes.Add(linearAxis1); var lineSeries1 = new LineSeries { Color = OxyColor.FromArgb(255, 78, 154, 6), MarkerFill = OxyColor.FromArgb(255, 78, 154, 6), MarkerStroke = OxyColors.ForestGreen, MarkerType = MarkerType.Plus, StrokeThickness = 1, DataFieldX = "Time", DataFieldY = "Value", ItemsSource = data }; plotModel1.Series.Add(lineSeries1); return plotModel1; }
public Window1() { InitializeComponent(); wfd = new WFDLakesViewModel(); tabControl1.DataContext = wfd; tabControl1.SelectionChanged += new SelectionChangedEventHandler(tabControl1_SelectionChanged); LineSeries LS = new LineSeries(); LS.ItemsSource = wfd.Precipitation.Items; LS.DependentValuePath = "Value"; LS.IndependentValuePath = "EndTime"; LS.Title = wfd.Precipitation.Name; this.EvapPrecip.Series.Add(LS); LineSeries LS2 = new LineSeries(); LS2.ItemsSource = wfd.Evaporation.Items; LS2.DependentValuePath = "Value"; LS2.IndependentValuePath = "EndTime"; LS2.Title = wfd.Evaporation.Name; this.EvapPrecip.Series.Add(LS2); Datagrid1.SelectionMode = Microsoft.Windows.Controls.DataGridSelectionMode.Single; Datagrid1.SelectionChanged += new SelectionChangedEventHandler(Datagrid1_SelectionChanged); }
public static PlotModel MouseDownEventHitTestResult() { var model = new PlotModel { Title = "MouseDown HitTestResult", Subtitle = "Reports the index of the nearest point." }; var s1 = new LineSeries(); s1.Points.Add(new DataPoint(0, 10)); s1.Points.Add(new DataPoint(10, 40)); s1.Points.Add(new DataPoint(40, 20)); s1.Points.Add(new DataPoint(60, 30)); model.Series.Add(s1); s1.MouseDown += (s, e) => { model.Subtitle = "Index of nearest point in LineSeries: " + Math.Round(e.HitTestResult.Index); model.InvalidatePlot(false); }; var s2 = new ScatterSeries(); s2.Points.Add(new ScatterPoint(0, 15)); s2.Points.Add(new ScatterPoint(10, 45)); s2.Points.Add(new ScatterPoint(40, 25)); s2.Points.Add(new ScatterPoint(60, 35)); model.Series.Add(s2); s2.MouseDown += (s, e) => { model.Subtitle = "Index of nearest point in ScatterSeries: " + (int)e.HitTestResult.Index; model.InvalidatePlot(false); }; return model; }
/// <summary> /// Initializes a new instance of the <see cref="MainViewModel" /> class. /// </summary> public MainViewModel() { // Create the plot model var tmp = new PlotModel { Title = "Simple example", Subtitle = "using OxyPlot" }; // Create two line series (markers are hidden by default) var series1 = new LineSeries { Title = "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 { Title = "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 tmp.Series.Add(series1); tmp.Series.Add(series2); // Axes are created automatically if they are not defined // Set the Model property, the INotifyPropertyChanged event will make the WPF Plot control update its content this.Model = tmp; }
public void Redraw() { this.LabChart.Series.Clear(); IEnumerable<CheckBox> children = this.Checklist.FindVisualChildren<CheckBox>();; foreach (var item in children) { if (item.IsChecked.Value) { //Create a new line series var lineSeries = new LineSeries(); string contentPath = item.Content.ToString(); lineSeries.Title = contentPath; lineSeries.Name = contentPath; lineSeries.IndependentValuePath = independentPath; lineSeries.DependentValuePath = contentPath; //Only bind labs that aren't null, otherwise the graph shows zero for that day lineSeries.ItemsSource = Labs.Where(lab => lab.GetPropertyValue(contentPath) != null); //lineSeries.ItemsSource = Labs; this.LabChart.Series.Add(lineSeries); } } }
public CPlot() { plotModel = new PlotModel(); plotModel.Title = "Trigonometric functions"; plotModel.Subtitle = "Example using the FunctionSeries"; plotModel.PlotType = PlotType.XY;// Cartesian plotModel.Background = OxyColors.White; plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom }); plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left }); mCountNormalPackets = new LineSeries { MarkerType = MarkerType.Circle, MarkerSize = 4, MarkerStroke = OxyColors.White, }; mCountWarningPackets = new LineSeries(); mCountErrorPackets = new LineSeries(); plotModel.Series.Add(mCountNormalPackets); plotModel.Series.Add(mCountWarningPackets); plotModel.Series.Add(mCountErrorPackets); }
public static PlotModel DaylightSavingsBreak() { var m = new PlotModel(); var xa = new DateTimeAxis { Position = AxisPosition.Bottom }; #if PCL || SILVERLIGHT // TimeZone not available in PCL... #else xa.TimeZone = TimeZoneInfo.FindSystemTimeZoneById( "W. Europe Standard Time"); #endif m.Axes.Add(xa); m.Axes.Add(new LinearAxis { Position = AxisPosition.Left }); var ls = new LineSeries { MarkerType = MarkerType.Circle }; m.Series.Add(ls); // set the origin of the curve to 2013-03-31 00:00:00 (UTC) var o = new DateTime(2013, 3, 31, 0, 0, 0, DateTimeKind.Utc); // add points at 10min intervals // at 2am the clocks are turned forward 1 hour (W. Europe Standard Time) for (int i = 0; i < 400; i += 10) { var time = o.AddMinutes(i); ls.Points.Add(DateTimeAxis.CreateDataPoint(time, i)); } return m; }
private static LineSeries CreateLineSeries(CalculationViewModel newViewModel) { var newSeries = new LineSeries { DataContext = newViewModel, DependentValuePath = "Value", IndependentValuePath = "Date" }; BindingOperations.SetBinding(newSeries, Series.TitleProperty, new Binding("Title")); var filter = new CollectionSizeFilter(); BindingOperations.SetBinding(filter, CollectionSizeFilter.MaxItemCountProperty, new Binding("ActualWidth") { RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(Chart), 1), Converter = new DivisionConverter(), ConverterParameter = 25 } ); BindingOperations.SetBinding(filter, CollectionViewSource.SourceProperty, new Binding("ResultOverTime")); newSeries.Resources.Add("FilteredBalances", filter); BindingOperations.SetBinding(newSeries, DataPointSeries.ItemsSourceProperty, new Binding { Source = filter }); return newSeries; }
public GraphSalesRank() { model = new PlotModel(); model.Title = "SalesRank"; DateTimeAxis axisX = new DateTimeAxis(); axisX.Position = AxisPosition.Bottom; axisX.Title = "Date"; model.Axes.Add(axisX); LinearAxis axisY = new LinearAxis(); axisY.Position = AxisPosition.Left; axisY.Minimum = 0; axisY.Title = "SalesRank"; model.Axes.Add(axisY); series = new LineSeries(); series.Title = string.Format("ASIN: {0}", this.Asin); this.Asin = "0061670898"; model.Series.Add(series); InitializeComponent(); oxyPlotView.Model = model; }
// [Example("DateTime Minimum bug")] public static PlotModel Example1() { var tmp = new PlotModel("Test"); tmp.Axes.Add(new LinearAxis(AxisPosition.Left) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, TickStyle = TickStyle.Outside }); DateTime dt = new DateTime(2010, 1, 1); tmp.Axes.Add(new DateTimeAxis(AxisPosition.Bottom, dt, dt.AddDays(1), null, null, DateTimeIntervalType.Hours) { MajorGridlineStyle = LineStyle.Solid, Angle = 90, StringFormat = "HH:mm", MajorStep = 1.0 / 24 / 2, // 1/24 = 1 hour, 1/24/2 = 30 minutes IsZoomEnabled = true, MaximumPadding = 0, MinimumPadding = 0, TickStyle = TickStyle.None }); var ls = new LineSeries("Line1") { DataFieldX = "X", DataFieldY = "Y" }; List<Item> ii = new List<Item>(); for (int i = 0; i < 24; i++) ii.Add(new Item { X = dt.AddHours(i), Y = i * i }); ls.ItemsSource = ii; tmp.Series.Add(ls); return tmp; }
public static PlotModel LineSeries1WithMarkers() { var model = new PlotModel { Title = "LineSeries, 100k points", Subtitle = "MarkerType = Square" }; var s1 = new LineSeries { MarkerType = MarkerType.Square }; AddPoints(s1.Points, 100000); model.Series.Add(s1); return model; }
public static PlotModel LineSeriesDashedLines() { var model = new PlotModel { Title = "LineSeries, 100k points", Subtitle = "LineStyle = Dash" }; var s1 = new LineSeries { LineStyle = LineStyle.Dash }; AddPoints(s1.Points, 100000); model.Series.Add(s1); return model; }
public static PlotModel LineSeriesRoundLineJoins() { var model = new PlotModel { Title = "LineSeries, 100k points", Subtitle = "LineJoin = Round" }; var s1 = new LineSeries { LineJoin = LineJoin.Round }; AddPoints(s1.Points, 100000); model.Series.Add(s1); return model; }
public static PlotModel LineSeries1WithMarkersLowRes() { var model = new PlotModel { Title = "LineSeries, 100k points, markers, lower resolution", Subtitle = "MarkerType = Square, MarkerResolution = 3" }; var s1 = new LineSeries { MarkerType = MarkerType.Square, MarkerResolution = 3 }; AddPoints(s1.Points, 100000); model.Series.Add(s1); return model; }
public static PlotModel LineSeries() { var model = new PlotModel { Title = "LineSeries, 100k points" }; var s1 = new LineSeries(); AddPoints(s1.Points, 100000); model.Series.Add(s1); return model; }
public static PlotModel LineSeries1Round() { var model = new PlotModel("LineSeries, 100k points, round line joins"); var s1 = new LineSeries { LineJoin = OxyPenLineJoin.Round }; AddPoints(s1.Points, 100000); model.Series.Add(s1); return model; }
public void Redraw() { Plot = new PlotModel(); Plot.DefaultFontSize = Model.DefaultFontSize; Plot.LegendFontSize = Model.LegendFontSize; Plot.Title = Model.Title; if (Model.ShowLegend) { switch (Model.LegendPosition) { case OpenFMSL.Contracts.Infrastructure.Reporting.LegendPosition.TopRight: Plot.LegendPosition = OxyPlot.LegendPosition.RightTop; break; case OpenFMSL.Contracts.Infrastructure.Reporting.LegendPosition.TopLeft: Plot.LegendPosition = OxyPlot.LegendPosition.TopLeft; break; case OpenFMSL.Contracts.Infrastructure.Reporting.LegendPosition.BottomLeft: Plot.LegendPosition = OxyPlot.LegendPosition.BottomLeft; break; case OpenFMSL.Contracts.Infrastructure.Reporting.LegendPosition.BottomRight: Plot.LegendPosition = OxyPlot.LegendPosition.BottomRight; break; default: Plot.LegendPosition = OxyPlot.LegendPosition.RightTop; break; } Plot.IsLegendVisible = true; } Plot.Axes.Clear(); LinearAxis yAxis = new LinearAxis { Position = AxisPosition.Left, Title = Model.YAxisTitle, AxisTitleDistance = 10 }; if (Model.IsReversedYAxis) { yAxis.StartPosition = 1; yAxis.EndPosition = 0; } Plot.Axes.Add(yAxis); LinearAxis xAxis = new LinearAxis { Position = AxisPosition.Bottom, Title = Model.XAxisTitle, AxisTitleDistance = 10 }; Plot.Axes.Add(xAxis); if (!Model.AutoScaleX) { xAxis.Minimum = Model.XMin; xAxis.Maximum = Model.XMax; } if (!Model.AutoScaleY) { yAxis.Minimum = Model.YMin; yAxis.Maximum = Model.YMax; } Plot.Series.Clear(); foreach (var series in Model.Series) { switch (series.Type) { case SeriesType.StackedBar100: { var line = new BarSeries(); line.IsStacked = true; line.Title = series.Name; for (int i = 0; i < series.X.Count; i++) { var item = new BarItem(series.X[i]); line.Items.Add(item); } if (series.ShowInLegend) { line.RenderInLegend = true; } else { line.RenderInLegend = false; } Plot.Series.Add(line); break; } case SeriesType.Line: { var line = new LineSeries(); line.MarkerType = OxyPlot.MarkerType.Circle; line.Title = series.Name; line.StrokeThickness = series.Thickness; if (series.Color != "Auto") { var seriesColor = System.Drawing.Color.FromName(series.Color); line.Color = OxyColor.FromArgb(seriesColor.A, seriesColor.R, seriesColor.G, seriesColor.B); } switch (series.DashPattern) { case DashPattern.Dash: //line.BrokenLineStyle = LineStyle.Dash; line.LineStyle = LineStyle.Dash; //line.BrokenLineColor = OxyColors.Transparent; //line.BrokenLineThickness = series.Thickness; break; case DashPattern.AlternatingDash: //line.BrokenLineStyle = LineStyle.LongDash; //line.BrokenLineColor = OxyColors.Transparent; //line.BrokenLineThickness = series.Thickness; line.LineStyle = LineStyle.LongDashDot; break; case DashPattern.DashDot: //line.BrokenLineStyle = LineStyle.DashDot; //line.BrokenLineColor = OxyColors.Transparent; //line.BrokenLineThickness = series.Thickness; line.LineStyle = LineStyle.DashDot; break; case DashPattern.Dotted: //line.BrokenLineStyle = LineStyle.Dot; //line.BrokenLineColor = OxyColors.Transparent; //line.BrokenLineThickness = series.Thickness; line.LineStyle = LineStyle.Dot; break; default: line.LineStyle = LineStyle.Solid; //line.BrokenLineStyle = LineStyle.Solid; //line.BrokenLineThickness = 0; break; } for (int i = 0; i < series.X.Count; i++) { var item = new DataPoint(series.X[i], series.Y[i]); line.Points.Add(item); } if (series.ShowMarker) { line.MarkerSize = 2 * series.Thickness; line.MarkerFill = line.Color; } if (series.ShowInLegend) { line.RenderInLegend = true; } else { line.RenderInLegend = false; } Plot.Series.Add(line); break; } case SeriesType.Scatter: { var line = new ScatterSeries(); line.Title = series.Name; switch (series.Marker) { case OpenFMSL.Contracts.Infrastructure.Reporting.MarkerType.Circle: line.MarkerType = OxyPlot.MarkerType.Circle; break; case OpenFMSL.Contracts.Infrastructure.Reporting.MarkerType.Diamond: line.MarkerType = OxyPlot.MarkerType.Diamond; break; case OpenFMSL.Contracts.Infrastructure.Reporting.MarkerType.Square: line.MarkerType = OxyPlot.MarkerType.Square; break; default: line.MarkerType = OxyPlot.MarkerType.Cross; break; } if (series.Color != "Auto") { var seriesColor = System.Drawing.Color.FromName(series.Color); line.MarkerFill = OxyColor.FromArgb(seriesColor.A, seriesColor.R, seriesColor.G, seriesColor.B); } for (int i = 0; i < series.X.Count; i++) { var item = new ScatterPoint(series.X[i], series.Y[i]); line.Points.Add(item); } if (series.ShowInLegend) { line.RenderInLegend = true; } else { line.RenderInLegend = false; } Plot.Series.Add(line); break; } case SeriesType.JacobianStructure: { var line = new OxyPlot.Series.RectangleBarSeries(); LinearAxis XAxisReversed = new LinearAxis { Position = AxisPosition.Bottom, Title = "Variables", IntervalLength = 15, StartPosition = 0, EndPosition = 1 }; Plot.Axes.Add(XAxisReversed); // Y2 Axis LinearAxis YAxisReversed = new LinearAxis { Position = AxisPosition.Left, Title = "Equations", IntervalLength = 15, StartPosition = 1, EndPosition = 0 }; Plot.Axes.Add(YAxisReversed); double currentX = 0; double currentY = 0; line.Title = "Jacobian Structure"; //line.TrackerFormatString = "{0}\n{1}: {2} {3}\n{4}: {5} {6}"; for (int i = 0; i < series.X.Count; i++) { var item = new RectangleBarItem { X0 = currentX, X1 = currentX + series.X[i], Y0 = currentY, Y1 = currentY + series.Y[i] }; line.Items.Add(item); currentX += series.X[i]; currentY += series.Y[i]; if (series.X[i] != series.Y[i]) { item.Color = OxyColors.OrangeRed; } else { item.Color = OxyColors.DodgerBlue; } } Plot.Series.Add(line); } break; default: { var line = new LineSeries(); } break; } } }
/// <summary> /// Sets up the graph for live trending /// </summary> /// <returns>The plot model.</returns> public PlotModel CreatePlotModel() { var model = new PlotModel(); BAX = new LinearAxis() { Position = AxisPosition.Bottom, Minimum = DateTime.Now.AddSeconds(-30).ToFileTime() - 100000, Maximum = DateTime.Now.ToFileTime() - 100000, IsAxisVisible = true, IsZoomEnabled = false, IsPanEnabled = false, Key = "time", LabelFormatter = (arg) => { var d = DateTime.FromFileTime((long)arg); return(d.Hour.ToString("00") + ":" + d.Minute.ToString("00") + ":" + d.Second.ToString("00")); }, Font = model.DefaultFont, FontSize = 10, TextColor = OxyColors.Black, AxislineThickness = 0, AxislineStyle = LineStyle.None, MajorGridlineStyle = LineStyle.None, MinorGridlineStyle = LineStyle.None, AxisTickToLabelDistance = 0.0, TickStyle = TickStyle.None, }; //var baseUnit = record.manifold.primarySensor.unit.standardUnit; var baseUnit = record.sensor.unit.standardUnit; LAX = new LinearAxis() { Position = AxisPosition.Left, Minimum = 0, Maximum = 100, IsAxisVisible = false, IsZoomEnabled = false, IsPanEnabled = false, Key = "first", LabelFormatter = (arg) => { //var u = record.manifold.primarySensor.unit; var u = record.sensor.unit; var p = SensorUtils.ToFormattedString(u.standardUnit.OfScalar(arg).ConvertTo(u), true); return(p); }, Font = model.DefaultFont, FontSize = 15, TextColor = OxyColors.Black, AxislineThickness = 0, AxislineStyle = LineStyle.None, MajorGridlineStyle = LineStyle.None, MinorGridlineStyle = LineStyle.None, AxisTickToLabelDistance = 0.0, TickStyle = TickStyle.None, }; RAX = new LinearAxis() { Position = AxisPosition.Right, Minimum = 0, Maximum = 100, IsAxisVisible = false, IsZoomEnabled = false, IsPanEnabled = false, Key = "second", LabelFormatter = (arg) => { //if (record.manifold.secondarySensor != null){ if (record.sensor.linkedSensor != null) { //var u = record.manifold.secondarySensor.unit; var u = record.sensor.linkedSensor.unit; return(SensorUtils.ToFormattedString(u.standardUnit.OfScalar(arg).ConvertTo(u), true)); } else { return(""); } }, Font = model.DefaultFont, FontSize = 15, TextColor = OxyColors.Black, AxislineThickness = 0, AxislineStyle = LineStyle.None, MajorGridlineStyle = LineStyle.None, MinorGridlineStyle = LineStyle.None, AxisTickToLabelDistance = 0.0, TickStyle = TickStyle.None, }; primarySeries = new LineSeries() { StrokeThickness = 1, Color = primaryColor, MarkerType = MarkerType.None, MarkerSize = 0, MarkerStroke = OxyColors.Transparent, MarkerStrokeThickness = 0, YAxisKey = "first", }; secondarySeries = new LineSeries() { StrokeThickness = 1, Color = secondaryColor, MarkerType = MarkerType.None, MarkerSize = 0, MarkerStroke = OxyColors.Transparent, MarkerStrokeThickness = 0, YAxisKey = "second", }; model.Background = OxyColors.Transparent; model.PlotMargins = new OxyThickness(-7, -7, -7, -5); model.TitlePadding = 0.0; model.PlotType = PlotType.XY; model.Axes.Add(BAX); model.Axes.Add(LAX); model.Axes.Add(RAX); model.Series.Add(primarySeries); model.Series.Add(secondarySeries); model.PlotAreaBorderThickness = new OxyThickness(0); model.PlotAreaBorderColor = OxyColors.Transparent; return(model); }
public override View GetSampleContent(Context context) { chart = new SfChart(context); chart.Title.Text = "Population of India (2013 - 2016)"; chart.SetBackgroundColor(Color.White); chart.ColorModel.ColorPalette = ChartColorPalette.Natural; density = context.Resources.DisplayMetrics.Density; CategoryAxis categoryaxis = new CategoryAxis(); categoryaxis.ShowMajorGridLines = false; categoryaxis.EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift; categoryaxis.PlotOffset = 30; categoryaxis.AxisLineOffset = 30; chart.PrimaryAxis = categoryaxis; NumericalAxis numericalaxis = new NumericalAxis(); numericalaxis.Minimum = 900; numericalaxis.Maximum = 1300; numericalaxis.Interval = 80; numericalaxis.EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift; numericalaxis.Title.Text = "Population"; chart.SecondaryAxis = numericalaxis; lineSeries1 = new LineSeries(); lineSeries1.ItemsSource = MainPage.GetDataMarkerData1(); lineSeries1.XBindingPath = "XValue"; lineSeries1.YBindingPath = "YValue"; lineSeries1.EnableAnimation = true; lineSeries1.Label = "Male"; lineSeries1.DataMarker.ShowLabel = true; lineSeries1.DataMarkerLabelCreated += LineSeries1_DataMarkerLabelCreated; lineSeries1.DataMarker.LabelStyle.LabelPosition = DataMarkerLabelPosition.Center; lineSeries1.DataMarker.LabelStyle.OffsetY = -18; lineSeries1.DataMarker.ShowMarker = true; lineSeries1.DataMarker.MarkerColor = Color.White; lineSeries1.DataMarker.MarkerHeight = 6; lineSeries1.DataMarker.MarkerWidth = 6; lineSeries1.DataMarker.MarkerStrokeWidth = 2; lineSeries1.DataMarker.MarkerStrokeColor = Color.ParseColor("#00BDAE"); chart.Series.Add(lineSeries1); lineSeries2 = new LineSeries(); lineSeries2.ItemsSource = MainPage.GetDataMarkerData2(); lineSeries2.XBindingPath = "XValue"; lineSeries2.YBindingPath = "YValue"; lineSeries2.EnableAnimation = true; lineSeries2.Label = "Female"; lineSeries2.DataMarker.ShowLabel = true; lineSeries2.DataMarkerLabelCreated += LineSeries2_DataMarkerLabelCreated; lineSeries2.DataMarker.LabelStyle.LabelPosition = DataMarkerLabelPosition.Center; lineSeries2.DataMarker.LabelStyle.OffsetY = 18; lineSeries2.DataMarker.ShowMarker = true; lineSeries2.DataMarker.MarkerColor = Color.White; lineSeries2.DataMarker.MarkerHeight = 6; lineSeries2.DataMarker.MarkerWidth = 6; lineSeries2.DataMarker.MarkerStrokeWidth = 2; lineSeries2.DataMarker.MarkerStrokeColor = Color.ParseColor("#404041"); chart.Series.Add(lineSeries2); return(chart); }
public static PlotModel ScatterSeries() { var plotModel1 = new PlotModel { Title = "Scatterseries not rendered at specific plot sizes", 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); }
public override View GetSampleContent(Context context) { chart = new SfChart(context); chart.Title.Text = "Inflation - Consumer Price"; chart.Title.TextSize = 15; chart.SetBackgroundColor(Color.White); chart.ColorModel.ColorPalette = ChartColorPalette.Natural; chart.Legend.Visibility = Visibility.Visible; chart.Legend.DockPosition = ChartDock.Bottom; chart.Legend.IconHeight = 14; chart.Legend.IconWidth = 14; chart.Legend.ToggleSeriesVisibility = true; CategoryAxis categoryaxis = new CategoryAxis(); categoryaxis.LabelPlacement = LabelPlacement.BetweenTicks; categoryaxis.EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift; categoryaxis.ShowMajorGridLines = false; categoryaxis.AxisLineOffset = 10; categoryaxis.PlotOffset = 10; categoryaxis.MajorTickStyle.TickSize = 10; chart.PrimaryAxis = categoryaxis; NumericalAxis numericalaxis = new NumericalAxis(); numericalaxis.Minimum = 0; numericalaxis.Maximum = 100; numericalaxis.Interval = 20; numericalaxis.LineStyle.StrokeWidth = 0; numericalaxis.MajorTickStyle.TickSize = 0; numericalaxis.LabelStyle.LabelFormat = "#'%'"; chart.SecondaryAxis = numericalaxis; LineSeries lineSeries1 = new LineSeries(); lineSeries1.ItemsSource = MainPage.GetLineData1(); lineSeries1.XBindingPath = "XValue"; lineSeries1.YBindingPath = "YValue"; lineSeries1.DataMarker.ShowMarker = true; lineSeries1.DataMarker.MarkerColor = Color.White; lineSeries1.DataMarker.MarkerWidth = 10; lineSeries1.DataMarker.MarkerHeight = 10; lineSeries1.DataMarker.MarkerStrokeColor = Color.ParseColor("#00bdae"); lineSeries1.DataMarker.MarkerStrokeWidth = 2; lineSeries1.Label = "Germany"; lineSeries1.StrokeWidth = 3; lineSeries1.TooltipEnabled = true; LineSeries lineSeries2 = new LineSeries(); lineSeries2.ItemsSource = MainPage.GetLineData2(); lineSeries2.XBindingPath = "XValue"; lineSeries2.YBindingPath = "YValue"; lineSeries2.Label = "Japan"; lineSeries2.DataMarker.ShowMarker = true; lineSeries2.DataMarker.MarkerColor = Color.White; lineSeries2.DataMarker.MarkerWidth = 10; lineSeries2.DataMarker.MarkerHeight = 10; lineSeries2.DataMarker.MarkerStrokeColor = Color.ParseColor("#404041"); lineSeries2.DataMarker.MarkerStrokeWidth = 2; lineSeries2.StrokeWidth = 3; lineSeries2.TooltipEnabled = true; lineSeries1.EnableAnimation = true; lineSeries2.EnableAnimation = true; chart.Series.Add(lineSeries1); chart.Series.Add(lineSeries2); return(chart); }
private void DrawScope() { if (!Controls.Contains(Scope)) { Scope.Location = new Point(30, 180); Scope.Size = new Size(900, 470); Controls.Add(Scope); } PlotModel Model = new PlotModel { Title = "", DefaultFont = afont, DefaultFontSize = fontsize, LegendTitle = "", PlotType = PlotType.XY, TitleFont = afont, Culture = System.Globalization.CultureInfo.CurrentCulture, LegendSymbolLength = 24, Padding = new OxyThickness(0, 20, 30, 0) }; Model.InvalidatePlot(true); Scope.Model = Model; LinearAxis YAxis = new LinearAxis { Position = AxisPosition.Left, Minimum = -20, Maximum = 20, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Điện áp (V)", MajorStep = 4, Font = afont, FontSize = fontsize, LabelFormatter = _formatter }; LinearAxis XAxis = new LinearAxis { Position = AxisPosition.Bottom, Minimum = 0, Maximum = 400, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Thời gian (µs) ", MajorStep = 50, Font = afont, FontSize = fontsize, LabelFormatter = _time_formatter }; Scope.Model.Axes.Add(XAxis); Scope.Model.Axes.Add(YAxis); //Timer 32bit, 100MHz, 50 MIPS, 2*(10^-8) sec/step,2*(10^-8)*50 = 1 µs if (TimerValue > 0) { double TimeRange = TimerValue * Math.Pow(10, 6) * TimerStep; //Micro Second step = TimeRange / SampleCount; //Micro Second for (int dt = 0; dt < SampleCount; dt++) { try { ChannelAVoltage[dt] = CalculateVoltage(ChannelA[dt], CHAX, GainA, CHAOffset, ErrA); ChannelBVoltage[dt] = CalculateVoltage(ChannelB[dt], CHBX, GainB, CHBOffset, ErrB); } catch (Exception e) { TextBoxRawData.Text = e.Message + " Voltage\r\n"; } } double MaxA = ChannelAVoltage.Max(); double MinA = ChannelAVoltage.Min(); double MaxB = ChannelBVoltage.Max(); double MinB = ChannelBVoltage.Min(); double MidA = (MaxA + MinA) / 2; double MidB = (MaxB + MinB) / 2; if (ToggleA.Checked == true) { LabelMaxAV.Text = String.Format("{0:0.00}V", ChannelAVoltage.Max()); LabelMinAV.Text = String.Format("{0:0.00}V", ChannelAVoltage.Min()); } if (ToggleB.Checked == true) { LabelMaxBV.Text = String.Format("{0:0.00}V", ChannelBVoltage.Max()); LabelMinBV.Text = String.Format("{0:0.00}V", ChannelBVoltage.Min()); } double MaxY = Math.Max(MaxA, MaxB); if (MaxY == 0) { MaxY = 20; } MaxY = Math.Abs(Math.Min(MinA, MinB)) > MaxY?Math.Abs(Math.Min(MinA, MinB)) + Math.Abs(Math.Min(MinA, MinB)) : MaxY + MaxY; if (CheckBoxAUP.Checked || CheckBoxBUP.Checked) { MaxY = 3 * MaxY; } double MinY = -MaxY; CalculateFreqAndRMS(); double FmaxA = 0, FmaxB = 0; double Fmax = 0; double Fzmax = 0; if (ka == true) { double[] DemA = new double[inpA.Length]; for (int i = 0; i < inpA.Length; i++) { DemA[i] = Complex.Abs(inpA[i]) / 10; } FmaxA = DemA.Max(); } if (kb == true) { double[] DemB = new double[inpB.Length]; for (int i = 0; i < inpB.Length; i++) { DemB[i] = Complex.Abs(inpB[i]) / 10; } FmaxB = DemB.Max(); } if (FmaxA > FmaxB) { Fmax = FmaxA; } else { Fmax = FmaxB; } if (ka == true && kb == false) { Fzmax = FreqA; } else if (ka == false && kb == true) { Fzmax = FreqB; } else if (ka == true && kb == true) { if (FreqA > FreqB) { Fzmax = FreqA; } else { Fzmax = FreqB; } } if (Kaaaaa == true) { YAxis.Maximum = Fmax; YAxis.Minimum = 0; YAxis.MajorStep = Fmax / 5; YAxis.Title = "Biên Độ (V)"; XAxis.Minimum = 0; XAxis.Maximum = Fzmax; XAxis.MajorStep = Fzmax / 12; XAxis.Title = "Tầng Số (Hz)"; XAxis.LabelFormatter = _time_formatter1; } else { YAxis.Maximum = MaxY; YAxis.Minimum = MinY; YAxis.MajorStep = MaxY / 5; XAxis.Minimum = 0; XAxis.Maximum = TimeRange; XAxis.MajorStep = TimeRange / 12; } var CHA = new LineSeries { Color = OxyColors.Blue, MarkerType = MarkerType.None, MarkerSize = 1, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LineStyle = LineStyle.Solid, Smooth = false, StrokeThickness = 1, Title = "KÊNH A", TrackerFormatString = "{0}\n{1}: {2:0.00}\n{3}: {4:0.00}" }; var CHB = new LineSeries { Color = OxyColors.Red, MarkerType = MarkerType.None, MarkerSize = 1, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Teal, MarkerStrokeThickness = 1, LineStyle = LineStyle.Solid, Smooth = false, StrokeThickness = 1, Title = "KÊNH B", TrackerFormatString = "{0}\n{1}: {2:0.00}\n{3}: {4:0.00}" }; if (Kaaaaa == false) { for (int dt = 0; dt < SampleCount; dt++) { if ((MinA >= 0) && (CheckBoxGNDA.Checked == true)) { ChannelAVoltage[dt] = ChannelAVoltage[dt] - MinA; } if ((MinB >= 0) && (CheckBoxGNDB.Checked == true)) { ChannelBVoltage[dt] = ChannelBVoltage[dt] - MinB; } try { if (CheckBoxAUP.Checked) { CHA.Points.Add(new DataPoint(step * dt, ChannelAVoltage[dt] + 3 * MaxB)); CHB.Points.Add(new DataPoint(step * dt, ChannelBVoltage[dt])); } else if (CheckBoxBUP.Checked) { CHA.Points.Add(new DataPoint(step * dt, ChannelAVoltage[dt])); CHB.Points.Add(new DataPoint(step * dt, ChannelBVoltage[dt] + 3 * MaxA)); } else { CHA.Points.Add(new DataPoint(step * dt, ChannelAVoltage[dt])); CHB.Points.Add(new DataPoint(step * dt, ChannelBVoltage[dt])); } } catch (Exception e) { TextBoxRawData.AppendText(e.Message + "Points"); } } } else { if (ka == true) { for (int i = 0; i < inpA.Length; i++) { CHA.Points.Add(new DataPoint(FreqA * i / inpA.Length, Complex.Abs(inpA[i]) / 10)); } } if (kb == true) { for (int i = 0; i < inpB.Length; i++) { CHB.Points.Add(new DataPoint(FreqB * i / inpB.Length, Complex.Abs(inpB[i]) / 10)); } } } if (ToggleA.Checked == true) { Scope.Model.Series.Add(CHA); } if (ToggleB.Checked == true) { Scope.Model.Series.Add(CHB); } CalculateFreqAndRMS(); Scope.Update(); Scope.Refresh(); } }
public async Task ExecuteAsync(object parameter) { var threadId = ulong.Parse(model_view.ThreadID); if (model_view.LinesByThread.ContainsKey(threadId)) { var cancel = new CancellationTokenSource(); var values = new ChartValues <double>(); var next_time = new TimeSpan(); var empty_time = new TimeSpan(); var chart_element = new double(); var end_time = new TimeSpan(); if (model_view.Lines.Count > 0) { next_time = model_view.Lines[0].m_TimeStamp; end_time = model_view.Lines[model_view.Lines.Count - 1].m_TimeStamp; } int demesion = 1; parserlog.dotnet.core.interfaces.IOperationParse analyze_thread = new parserlog.dotnet.core.operations.OperationGetThreadLines(model_view.LinesByThread[ulong.Parse(model_view.ThreadID)], cancel.Token); OperationView operation_view = new OperationView(model_view.Operations, cancel); analyze_thread.OnStart += (sender, e) => { operation_view.Title = "Analyzing thread[" + threadId + "]..."; model_view.Series.Clear(); }; analyze_thread.OnProgress += (sender, e) => { operation_view.Progress = e.Progress; }; analyze_thread.OnParsedLine += (sender, e) => { var info = e.Info; if (info.m_TimeStamp > next_time) { var expl = info.m_TimeStamp - next_time; if (demesion < expl.TotalSeconds && next_time != empty_time) { var count = expl.TotalSeconds / demesion; while (count-- > 0) { values.Add(0); } } next_time = info.m_TimeStamp.Add(new TimeSpan(0, 0, demesion)); values.Add(chart_element); chart_element = 0; } ++chart_element; }; analyze_thread.OnError += (sender, e) => { operation_view.Complete = true; }; analyze_thread.OnComplete += (sender, e) => { if (chart_element > 0) { values.Add(chart_element); } if (next_time < end_time) { var expl = end_time - next_time; if (demesion < expl.TotalSeconds) { var count = expl.TotalSeconds / demesion; while (count-- > 0) { values.Add(0); } } } var series = new LineSeries { Values = values, StrokeThickness = .5, PointGeometry = null //use a null geometry when you have many series }; model_view.Series.Add(series); operation_view.Complete = true; }; await analyze_thread.ExecuteAsync(); } }
private ChartValues <DateTimePoint> GetData() { var values = new ChartValues <DateTimePoint>(); Int_DIGITAL_CURRENCY_DAILY digital_currency_daily = _connection.GetQueryObject_DIGITAL_CURRENCY_DAILY(); try { IAvapiResponse_DIGITAL_CURRENCY_DAILY digital_currency_dailyResponse = digital_currency_daily.QueryPrimitive(_args.Symbol, _args.DefaultCurrency); var data = digital_currency_dailyResponse.Data; if (data.Error && _args.DefaultCurrency == "USD") { MessageBox.Show("Failed to fetch data", "Error"); Read("\\" + _args.Symbol + ".csv"); try { return((ChartValues <DateTimePoint>)SeriesCollection[0].Values); } catch { } } else if (data.Error) { digital_currency_dailyResponse = digital_currency_daily.QueryPrimitive(_args.Symbol, "USD"); var data1 = digital_currency_dailyResponse.Data; if (data1.Error) { MessageBox.Show("Failed to fetch data", "Error"); values = Read("\\" + _args.Symbol + ".csv"); try { return((ChartValues <DateTimePoint>)SeriesCollection[0].Values); } catch (Exception) { } } else { try { Int_CURRENCY_EXCHANGE_RATE currency_exchange_rate = _connection.GetQueryObject_CURRENCY_EXCHANGE_RATE(); IAvapiResponse_CURRENCY_EXCHANGE_RATE currency_exchange_rateResponse = currency_exchange_rate.QueryPrimitive("USD", _args.DefaultCurrency); var data2 = currency_exchange_rateResponse.Data; if (data2.Error) { MessageBox.Show("Failed to fetch exchange rate data for " + _args, "Error"); } else { _exchangeRate = double.Parse(data2.ExchangeRate); DateTime offset = DateTime.Now.AddYears(-1); DateTime temp; foreach (var timeseries in data1.TimeSeries) { temp = DateTime.ParseExact(timeseries.DateTime, "yyyy-MM-dd", CultureInfo.InvariantCulture); if (temp > offset) { values.Add(new DateTimePoint(temp, double.Parse(timeseries.Close) * _exchangeRate)); } } Write("\\" + _args.Symbol + ".csv", values); } } catch (NullReferenceException) { MessageBox.Show("Failed to fetch currency exchange rate for " + _args.DefaultCurrency + " currency. Values will be show in USD", "Error"); DateTime offset = DateTime.Now.AddYears(-1); DateTime temp; _exchangeRate = 1; foreach (var timeseries in data1.TimeSeries) { temp = DateTime.ParseExact(timeseries.DateTime, "yyyy-MM-dd", CultureInfo.InvariantCulture); if (temp > offset) { values.Add(new DateTimePoint(temp, double.Parse(timeseries.Close))); } } YFormatter = val => "$" + val.ToString("0.##"); Write("\\" + _args.Symbol + ".csv", values); } } } else { DateTime offset = DateTime.Now.AddYears(-1); DateTime temp; _exchangeRate = 1; foreach (var timeseries in data.TimeSeries) { temp = DateTime.ParseExact(timeseries.DateTime, "yyyy-MM-dd", CultureInfo.InvariantCulture); if (temp > offset) { values.Add(new DateTimePoint(temp, double.Parse(timeseries.Close))); } } Write("\\" + _args.Symbol + ".csv", values); } } catch (Exception e) { Console.WriteLine(e.Message); values = Read("\\" + _args.Symbol + ".csv"); } //SeriesCollection[0].Title = data.MetaData.DigitalCurrencyName; return(values); }
public LineSeriesViewModel() { var pnls = new List <Pnl>(); var random = new Random(31); var dateTime = DateTime.Today.Add(TimeSpan.FromHours(9)); for (var pointIndex = 0; pointIndex < 50; pointIndex++) { pnls.Add(new Pnl { Time = dateTime, Value = -200 + random.Next(1000), }); dateTime = dateTime.AddMinutes(1); } var minimum = pnls.Min(x => x.Value); var maximum = pnls.Max(x => x.Value); var plotModel = this.PlotModel; plotModel.Title = "Line Series Animation Demo"; var series = new LineSeries { Title = "P & L", ItemsSource = pnls, DataFieldX = "Time", DataFieldY = "Value", Color = OxyColor.Parse("#4CAF50"), MarkerSize = 3, MarkerFill = OxyColor.Parse("#FFFFFFFF"), MarkerStroke = OxyColor.Parse("#4CAF50"), MarkerStrokeThickness = 1.5, MarkerType = MarkerType.Circle, StrokeThickness = 1, }; plotModel.Series.Add(series); var annotation = new LineAnnotation { Type = LineAnnotationType.Horizontal, Y = 0 }; plotModel.Annotations.Add(annotation); var dateTimeAxis = new DateTimeAxis { Position = AxisPosition.Bottom, IntervalType = DateTimeIntervalType.Hours, IntervalLength = 50 }; plotModel.Axes.Add(dateTimeAxis); var margin = (maximum - minimum) * 0.05; var valueAxis = new LinearAxis { Position = AxisPosition.Left, Minimum = minimum - margin, Maximum = maximum + margin, }; plotModel.Axes.Add(valueAxis); }
private void OxyPlotViewLineGraph() { // Create the plot model var tmp = new PlotModel { Title = "Simple example", Subtitle = "using OxyPlot" }; LinearAxis linearAxisBottom = new LinearAxis() { Position = AxisPosition.Bottom, Minimum = 0, Maximum = 50 }; //=================================================================================== //sin(x)/x,使用描点法 //Color = OxyColors.Goldenrod,有MarkerType就不能有颜色 var lineSeriesSinX = new LineSeries { Title = "Sin(x)/x", MarkerType = MarkerType.Circle }; int N = 100; double[] x = new double[N]; double[] y = new double[N]; x[0] = 0; y[0] = 0; x[1] = 100; y[1] = 50; for (int i = 1; i <= N - 1; i++) { x[i] = (double)i / 1; y[i] = Math.Sin(x[i]) / x[i]; lineSeriesSinX.Points.Add(new DataPoint(x[i], y[i])); } //=================================================================================== var lineSeriesRadom = new LineSeries { Title = "Cos(x)" }; //=================================================================================== //添加到ModelLineGraph tmp.Axes.Add(linearAxisBottom); tmp.Series.Add(lineSeriesSinX); tmp.Series.Add(new FunctionSeries(Math.Sin, 0, 100, 0.1, "sin(x)"));//sin(x),使用函数 //tmp.Series.Add(lineSeriesRadom); //=================================================================================== //应用 this.ModelLineGraph = tmp; //=================================================================================== //var rd = new Random(); //Task.Factory.StartNew(() => //{ // double x1 = 0; // double y1 = 0; // while (lineSeriesRadom.Points.Count < 400) // { // //var x1 = rd.NextDouble() * 1000 % 10; // //var y1 = rd.NextDouble() * 50 % 9; // y1 = Math.Cos(x1); // x1 += 0.25; // lineSeriesRadom.Points.Add(new DataPoint(x1, y1)); // if(x1>50) // { // linearAxisBottom.Minimum = x1 - 50; // linearAxisBottom.Maximum = x1; // } // ModelLineGraph.InvalidatePlot(true); // Thread.Sleep(50); // } //}); }
private void AVG_Click(object sender, RoutedEventArgs e) { var avg = new Statistics { TableName = "Avg_Data", StatisticsItems = new List <StatisticsItem>(), }; foreach (var table in statData) { if (table.TableName != "Sum_Data") { foreach (var point in table.StatisticsItems) { if (avg.StatisticsItems.Count(a => a.EndTime == point.EndTime) == 0) { avg.StatisticsItems.Add(new StatisticsItem { BeginTime = point.BeginTime, EndTime = point.EndTime, Value = point.Value / statData.Count, }); } else { var old = avg.StatisticsItems.SingleOrDefault(a => a.EndTime == point.EndTime); old.Value += point.Value; } } } } foreach (var item in avg.StatisticsItems) { item.Value = item.Value / statData.Count; } var data = statData.FirstOrDefault(s => s.TableName == "Avg_Data"); if (data != null) { statData.Remove(data); } else { statData.Add(avg); } Chart.Series.Clear(); for (int i = 0; i < statData.Count; i++) { var item = statData[i]; LineSeries ls = new LineSeries { Title = item.TableName, Tag = item.TableName, ItemsSource = item.StatisticsItems, IndependentValuePath = "EndTime", DependentValuePath = "Value", IsSelectionEnabled = true, }; //ls.SelectionChanged += new SelectionChangedEventHandler(ls_SelectionChanged); ls.MouseMove += new MouseEventHandler(ls_MouseMove); //点的样式 Style style = new Style(typeof(LineDataPoint)); style.Setters.Add(new Setter(LineDataPoint.BackgroundProperty, new SolidColorBrush(colorPool[i]))); style.Setters.Add(new Setter(LineDataPoint.BorderThicknessProperty, new Thickness(0))); style.Setters.Add(new Setter(LineDataPoint.CursorProperty, Cursors.Hand)); style.Setters.Add(new Setter(Polyline.TagProperty, ls.Tag)); style.Setters.Add(new Setter(LineDataPoint.TemplateProperty, Application.Current.Resources["LineNoTransitionAdd"] as ControlTemplate)); ls.DataPointStyle = style; //线条的样式 Style style2 = new Style(typeof(Polyline)); style2.Setters.Add(new Setter(Polyline.StrokeThicknessProperty, 1)); style2.Setters.Add(new Setter(Polyline.TagProperty, ls.Tag)); ls.PolylineStyle = style2; Chart.Series.Add(ls); } Chart.LegendItems.OfType <LegendItem>().ToList().ForEach(legendItem => { legendItem.MouseLeftButtonDown += new MouseButtonEventHandler(legendItem_MouseLeftButtonDown); }); //设置y轴的最大高度 var max = statData.SelectMany(r => r.StatisticsItems).Select(p => p.Value).Max(); var axes = Chart.Axes.ToList().OfType <LinearAxis>().Where(a => a.Orientation == AxisOrientation.Y).FirstOrDefault(); axes.Maximum = max + max * 0.1; }
private void service_GetStatisticsDataCompleted(object sender, GetStatisticsDataCompletedEventArgs e) { if (autoRefreshThread == null) { autoRefreshThread = new Thread(this.AutoRefreshAction) { IsBackground = true, }; autoRefreshThread.Start(); } Refresh.IsEnabled = true; this.Busy.IsBusy = false; if (e.Error != null) { e.Error.ShowError(); return; } if (e.Result != null) { statData = e.Result.ToList(); Chart.Title = string.Format("数据库: {0} 查询时间段:{1} - {2} 数据点总数:{3} 数据总条数:{4}", SearchCondition.DatabasePrefix, SearchCondition.BeginTime.ToString("yyyy/MM/dd HH:mm:ss"), SearchCondition.EndTime.ToString("yyyy/MM/dd HH:mm:ss"), statData.SelectMany(s => s.StatisticsItems).Count(), statData.SelectMany(s => s.StatisticsItems).Sum(s => s.Value)); //初始化时间轴的格式,不同的粒度选择不同的格式 DateTimeAxis dta = Chart.Axes.OfType <DateTimeAxis>().FirstOrDefault(); var span = (TimeSpanType.SelectedItem as ComboBoxItem).Tag.ToString(); Style dtaLabelStyle = new Style(typeof(DateTimeAxisLabel)); switch (span) { case "Second": case "Minute": { dtaLabelStyle.Setters.Add(new Setter(DateTimeAxisLabel.StringFormatProperty, "{0:HH:mm}")); break; } case "Hour": { dtaLabelStyle.Setters.Add(new Setter(DateTimeAxisLabel.StringFormatProperty, "{0:MM/dd HH.}")); break; } case "Day": case "Week": { dtaLabelStyle.Setters.Add(new Setter(DateTimeAxisLabel.StringFormatProperty, "{0:MM/dd}")); break; } case "Month": { dtaLabelStyle.Setters.Add(new Setter(DateTimeAxisLabel.StringFormatProperty, "{0:yyyy/MM/dd}")); break; } } dta.AxisLabelStyle = dtaLabelStyle; //第一次需要初始化图表 if (Chart.Series.Count == 0) { for (int i = 0; i < statData.Count; i++) { var item = statData[i]; LineSeries ls = new LineSeries { Title = item.TableName, Tag = item.TableName, ItemsSource = item.StatisticsItems, IndependentValuePath = "EndTime", DependentValuePath = "Value", IsSelectionEnabled = true, }; ls.SelectionChanged += new SelectionChangedEventHandler(ls_SelectionChanged); ls.MouseMove += new MouseEventHandler(ls_MouseMove); //点的样式 Style style = new Style(typeof(LineDataPoint)); style.Setters.Add(new Setter(LineDataPoint.BackgroundProperty, new SolidColorBrush(colorPool[i]))); style.Setters.Add(new Setter(LineDataPoint.BorderThicknessProperty, new Thickness(0))); style.Setters.Add(new Setter(LineDataPoint.CursorProperty, Cursors.Hand)); style.Setters.Add(new Setter(Polyline.TagProperty, ls.Tag)); style.Setters.Add(new Setter(LineDataPoint.TemplateProperty, Application.Current.Resources["LineNoTransition"] as ControlTemplate)); ls.DataPointStyle = style; //线条的样式 Style style2 = new Style(typeof(Polyline)); style2.Setters.Add(new Setter(Polyline.StrokeThicknessProperty, 1)); style2.Setters.Add(new Setter(Polyline.TagProperty, ls.Tag)); ls.PolylineStyle = style2; Chart.Series.Add(ls); } } else //重新设置数据源就可以了 { for (int i = 0; i < e.Result.Count; i++) { var item = e.Result[i]; var ls = Chart.Series.OfType <LineSeries>().FirstOrDefault(s => s.Title.ToString() == item.TableName); if (ls != null) { ls.ItemsSource = item.StatisticsItems; } } } Chart.LegendItems.OfType <LegendItem>().ToList().ForEach(legendItem => { legendItem.MouseLeftButtonDown += new MouseButtonEventHandler(legendItem_MouseLeftButtonDown); }); //设置y轴的最大高度 var max = statData.SelectMany(r => r.StatisticsItems).Select(p => p.Value).Max(); var axes = Chart.Axes.ToList().OfType <LinearAxis>().Where(a => a.Orientation == AxisOrientation.Y).FirstOrDefault(); axes.Maximum = max + max * 0.1; } }
private void _scope_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName.Equals("MostRecentStimulationTrain")) { //Record the new stim _trials.Add(_scope.MostRecentStimulationTrain); var most_recent_timestamp = DateTime.Now; var num_stims = _trials.Count; //Clear the plot BoothPlotModel.Series.Clear(); //Obtain indices of trials we want to display List <int> _trace_indices = new List <int>(); switch (_scope.ScopeSessionDisplayType) { case DisplayType.AllTraces: _trace_indices = Enumerable.Range(0, _trials.Count).ToList(); break; case DisplayType.MostRecentTenTraces: _trace_indices = Enumerable.Range(Math.Max(0, _trials.Count - 10), Math.Min(_trials.Count, 10)).ToList(); break; case DisplayType.MostRecentTrace: _trace_indices.Add(_trials.Count - 1); break; } //Grab data from each trial, transform it, and create a LineSeries object to display it for (int i = 0; i < _trace_indices.Count; i++) { //Grab the data from the stim train. Make sure to call ToList() to make a copy of it before we transform it var idx = _trace_indices[i]; var train_data = _trials[idx].Data.ToList(); //Calculate how many elements to display from the current trace int elements_to_take = train_data.Count; switch (_scope.ScopeTraceDisplayType) { case DisplayType_IndividualTrace.FirstHundredSamples: elements_to_take = Math.Min(100, train_data.Count); break; case DisplayType_IndividualTrace.FirstThousandSamples: elements_to_take = Math.Min(1000, train_data.Count); break; case DisplayType_IndividualTrace.FirstTenth: elements_to_take = Convert.ToInt32(0.1d * Convert.ToDouble(train_data.Count)); break; case DisplayType_IndividualTrace.FirstQuarter: elements_to_take = Convert.ToInt32(0.25d * Convert.ToDouble(train_data.Count)); break; } //Grab the elements we want to take and display train_data = train_data.Take(elements_to_take).ToList(); //Plot this data LineSeries new_line = new LineSeries(); for (int j = 0; j < train_data.Count; j++) { new_line.Points.Add(new DataPoint(j, train_data[j])); } BoothPlotModel.Series.Add(new_line); BoothPlotModel.InvalidatePlot(true); } //Add a message to the list of messages Messages = Messages + most_recent_timestamp.ToString("HH:mm:ss") + " - Stimulation detected (" + num_stims.ToString() + ")\n"; //Notify the GUI that the plot has changed NotifyPropertyChanged("BoothPlotModel"); } }
public void Update2DIDs(Column column) { LineSeries sp1 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "({0},{1})" }; sp1.Points.Add(new DataPoint(column.SelectedLoad.MEdx, column.SelectedLoad.MEdy)); MxMyID = new PlotModel() { Title = "Mx-My interaction diagram", Subtitle = "(N = " + Math.Round(column.SelectedLoad.P) + "kN)" }; MxMyID.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Title = "Mx", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); MxMyID.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Title = "My", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); LineSeries s1 = new LineSeries() { Color = OxyColors.Red, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in column.MxMyPts) { s1.Points.Add(new DataPoint(p.X, p.Y)); } MxMyID.Series.Add(s1); MxMyID.Series.Add(sp1); LineSeries sp2 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "({0},{1})" }; sp2.Points.Add(new DataPoint(column.SelectedLoad.MEdx, -column.SelectedLoad.P)); MxNID = new PlotModel() { Title = "Mx-N interaction diagram", Subtitle = "(My = " + Math.Round(column.SelectedLoad.MEdy) + "kN.m)" }; MxNID.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Title = "Mx", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); MxNID.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Title = "N", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); LineSeries s2 = new LineSeries() { Color = OxyColors.Blue, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in column.MxNPts) { s2.Points.Add(new DataPoint(p.X, p.Y)); } MxNID.Series.Add(s2); MxNID.Series.Add(sp2); LineSeries sp3 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "({0},{1})", }; sp3.Points.Add(new DataPoint(column.SelectedLoad.MEdy, -column.SelectedLoad.P)); MyNID = new PlotModel() { Title = "My-N interaction diagram", Subtitle = "(Mx = " + Math.Round(column.SelectedLoad.MEdx) + "kN.m)", }; MyNID.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Title = "My", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); MyNID.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Title = "N", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); LineSeries s3 = new LineSeries() { Color = OxyColors.Green, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in column.MyNPts) { s3.Points.Add(new DataPoint(p.X, p.Y)); } MyNID.Series.Add(s3); MyNID.Series.Add(sp3); if (column.FireDesignMethod == FDesignMethod.Advanced) { LineSeries spf1 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "fire ({0},{1})" }; spf1.Points.Add(new DataPoint(column.FireLoad.MEdx, column.FireLoad.MEdy)); LineSeries sf1 = new LineSeries() { Color = OxyColors.DarkRed, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in column.fireMxMyPts) { sf1.Points.Add(new DataPoint(p.X, p.Y)); } MxMyID.Series.Add(sf1); MxMyID.Series.Add(spf1); LineSeries spf2 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "fire ({0},{1})" }; spf2.Points.Add(new DataPoint(column.FireLoad.MEdx, -column.FireLoad.P)); LineSeries sf2 = new LineSeries() { Color = OxyColors.DarkBlue, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in column.fireMxNPts) { sf2.Points.Add(new DataPoint(p.X, p.Y)); } MxNID.Series.Add(sf2); MxNID.Series.Add(spf2); LineSeries spf3 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "fire ({0},{1})" }; spf3.Points.Add(new DataPoint(column.FireLoad.MEdy, -column.FireLoad.P)); LineSeries sf3 = new LineSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in column.fireMyNPts) { sf3.Points.Add(new DataPoint(p.X, p.Y)); } MyNID.Series.Add(sf3); MyNID.Series.Add(spf3); } MxMyID.InvalidatePlot(true); MxNID.InvalidatePlot(true); MyNID.InvalidatePlot(true); RaisePropertyChanged(nameof(MxMyID)); RaisePropertyChanged(nameof(MxNID)); RaisePropertyChanged(nameof(MyNID)); Print2DIDs(); }
public void SetSeries(List <WaterLevelData> list) { try { // Init axes Axes.Clear(); Axes.Add(new LinearAxis() { Title = "meters", Position = AxisPosition.Left, Minimum = MinLevel, Maximum = MaxLevel, IsPanEnabled = false, IsZoomEnabled = false, MajorGridlineColor = OxyColor.Parse("#dddddd"), MajorGridlineThickness = 2, MajorGridlineStyle = LineStyle.Solid, MinorGridlineColor = OxyColor.Parse("#dddddd"), MinorGridlineThickness = 1, MinorGridlineStyle = LineStyle.Solid }); Axes.Add(new DateTimeAxis() { Position = AxisPosition.Bottom, Minimum = GetMinDateInDouble(), Maximum = GetMaxDateInDouble(), IsPanEnabled = false, IsZoomEnabled = false, MajorGridlineColor = OxyColor.Parse("#dddddd"), MajorGridlineThickness = 2, MajorGridlineStyle = LineStyle.Solid, Angle = 90 }); // Set alert line AlertLine.Points.Clear(); AlertLine.Points.Add(new DataPoint(GetMinDateInDouble(), AlertLineValue)); AlertLine.Points.Add(new DataPoint(GetMaxDateInDouble(), AlertLineValue)); // Create series with new values list.Sort((x, y) => x.Timestamp.CompareTo(y.Timestamp)); LineSeries series = new LineSeries { Color = OxyColor.Parse("#0000ff") }; foreach (WaterLevelData data in list) { series.Points.Add(new DataPoint(DateTimeAxis.ToDouble(data.Timestamp), data.WaterLevel)); } // Update series Series.Clear(); Series.Add(series); Series.Add(AlertLine); } catch (Exception e) { Debug.WriteLine("Error: " + e.ToString()); } // Update graph UI try { InvalidatePlot(true); } catch (Exception e) { Debug.WriteLine(e.Message + "\nReinitializing model"); } }
public static void Generate2DIDs(Column col) { if (col.diagramVertices.Count == 0) { col.GetInteractionDiagram(); } if (col.MxMyPts.Count == 0) { col.Get2DMaps(); } LineSeries sp1 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "({0},{1})" }; sp1.Points.Add(new DataPoint(col.SelectedLoad.MEdx, col.SelectedLoad.MEdy)); PlotModel colMxMyID = new PlotModel() { Title = "Mx-My interaction diagram", Subtitle = "(N = " + Math.Round(col.SelectedLoad.P) + "kN)" }; colMxMyID.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Title = "Mx", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); colMxMyID.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Title = "My", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); LineSeries s1 = new LineSeries() { Color = OxyColors.Red, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in col.MxMyPts) { s1.Points.Add(new DataPoint(p.X, p.Y)); } colMxMyID.Series.Add(s1); colMxMyID.Series.Add(sp1); LineSeries sp2 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "({0},{1})" }; sp2.Points.Add(new DataPoint(col.SelectedLoad.MEdx, -col.SelectedLoad.P)); PlotModel colMxNID = new PlotModel() { Title = "Mx-N interaction diagram", Subtitle = "(My = " + Math.Round(col.SelectedLoad.MEdy) + "kN.m)" }; colMxNID.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Title = "Mx", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); colMxNID.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Title = "N", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); LineSeries s2 = new LineSeries() { Color = OxyColors.Blue, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in col.MxNPts) { s2.Points.Add(new DataPoint(p.X, p.Y)); } colMxNID.Series.Add(s2); colMxNID.Series.Add(sp2); LineSeries sp3 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "({0},{1})", }; sp3.Points.Add(new DataPoint(col.SelectedLoad.MEdy, -col.SelectedLoad.P)); PlotModel colMyNID = new PlotModel() { Title = "My-N interaction diagram", Subtitle = "(Mx = " + Math.Round(col.SelectedLoad.MEdx) + "kN.m)", }; colMyNID.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Title = "My", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); colMyNID.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Title = "N", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); LineSeries s3 = new LineSeries() { Color = OxyColors.Green, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in col.MyNPts) { s3.Points.Add(new DataPoint(p.X, p.Y)); } colMyNID.Series.Add(s3); colMyNID.Series.Add(sp3); if (col.FireDesignMethod == FDesignMethod.Advanced) { LineSeries spf1 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "fire ({0},{1})" }; spf1.Points.Add(new DataPoint(col.FireLoad.MEdx, col.FireLoad.MEdy)); LineSeries sf1 = new LineSeries() { Color = OxyColors.DarkRed, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in col.fireMxMyPts) { sf1.Points.Add(new DataPoint(p.X, p.Y)); } colMxMyID.Series.Add(sf1); colMxMyID.Series.Add(spf1); LineSeries spf2 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "fire ({0},{1})" }; spf2.Points.Add(new DataPoint(col.FireLoad.MEdx, -col.FireLoad.P)); LineSeries sf2 = new LineSeries() { Color = OxyColors.DarkBlue, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in col.fireMxNPts) { sf2.Points.Add(new DataPoint(p.X, p.Y)); } colMxNID.Series.Add(sf2); colMxNID.Series.Add(spf2); LineSeries spf3 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "fire ({0},{1})" }; spf3.Points.Add(new DataPoint(col.FireLoad.MEdy, -col.FireLoad.P)); LineSeries sf3 = new LineSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in col.fireMyNPts) { sf3.Points.Add(new DataPoint(p.X, p.Y)); } colMyNID.Series.Add(sf3); colMyNID.Series.Add(spf3); } PlotModel[] plots = new PlotModel[] { colMxMyID, colMxNID, colMyNID }; string[] plotNames = new string[] { "MxMy", "MxN", "MyN" }; for (int i = 0; i < plots.Length; i++) { var pngExporter = new OxyPlot.Wpf.PngExporter { Width = 600, Height = 400, Background = OxyColors.White }; var bitmap = pngExporter.ExportToBitmap(plots[i]); MemoryStream stream = new MemoryStream(); BitmapEncoder encoder = new BmpBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bitmap)); encoder.Save(stream); Bitmap bmp = new Bitmap(stream); ImageConverter converter = new ImageConverter(); byte[] output = (byte[])converter.ConvertTo(bmp, typeof(byte[])); string path = System.IO.Path.GetTempPath() + plotNames[i] + ".tmp"; File.WriteAllBytes(path, output); } }
public static PlotModel MouseDownEvent() { var model = new PlotModel { Title = "MouseDown", Subtitle = "Left click to edit or add points.", LegendSymbolLength = 40 }; // Add a line series var s1 = new LineSeries { Title = "LineSeries1", Color = OxyColors.SkyBlue, MarkerType = MarkerType.Circle, MarkerSize = 6, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.SkyBlue, MarkerStrokeThickness = 1.5 }; s1.Points.Add(new DataPoint(0, 10)); s1.Points.Add(new DataPoint(10, 40)); s1.Points.Add(new DataPoint(40, 20)); s1.Points.Add(new DataPoint(60, 30)); model.Series.Add(s1); int indexOfPointToMove = -1; // Subscribe to the mouse down event on the line series s1.MouseDown += (s, e) => { // only handle the left mouse button (right button can still be used to pan) if (e.ChangedButton == OxyMouseButton.Left) { int indexOfNearestPoint = (int)Math.Round(e.HitTestResult.Index); var nearestPoint = s1.Transform(s1.Points[indexOfNearestPoint]); // Check if we are near a point if ((nearestPoint - e.Position).Length < 10) { // Start editing this point indexOfPointToMove = indexOfNearestPoint; } else { // otherwise create a point on the current line segment int i = (int)e.HitTestResult.Index + 1; s1.Points.Insert(i, s1.InverseTransform(e.Position)); indexOfPointToMove = i; } // Change the linestyle while editing s1.LineStyle = LineStyle.DashDot; // Remember to refresh/invalidate of the plot model.InvalidatePlot(false); // Set the event arguments to handled - no other handlers will be called. e.Handled = true; } }; s1.MouseMove += (s, e) => { if (indexOfPointToMove >= 0) { // Move the point being edited. s1.Points[indexOfPointToMove] = s1.InverseTransform(e.Position); model.InvalidatePlot(false); e.Handled = true; } }; s1.MouseUp += (s, e) => { // Stop editing indexOfPointToMove = -1; s1.LineStyle = LineStyle.Solid; model.InvalidatePlot(false); e.Handled = true; }; model.MouseDown += (s, e) => { if (e.ChangedButton == OxyMouseButton.Left) { // Add a point to the line series. s1.Points.Add(s1.InverseTransform(e.Position)); indexOfPointToMove = s1.Points.Count - 1; model.InvalidatePlot(false); e.Handled = true; } }; return(model); }
private void HandleVolt(MsgOfVolt msg) { DateTime dt = new DateTime(msg.year, msg.month, msg.day, msg.hour, msg.minute, (int)msg.second); if (volt14Points.Count > 3600) { volt14Points.RemoveRange(0, 3600); volt14Model.Axes[0].Minimum = DateTimeAxis.ToDouble(DateTime.Now); volt14Model.Axes[0].Maximum = DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(60)); } if (volt12PPoints.Count > 3600) { volt12PPoints.RemoveRange(0, 3600); volt12PModel.Axes[0].Minimum = DateTimeAxis.ToDouble(DateTime.Now); volt12PModel.Axes[0].Maximum = DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(60)); } if (volt12NPoints.Count > 3600) { volt12NPoints.RemoveRange(0, 3600); volt12NModel.Axes[0].Minimum = DateTimeAxis.ToDouble(DateTime.Now); volt12NModel.Axes[0].Maximum = DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(60)); } if (volt5Points.Count > 3600) { volt5Points.RemoveRange(0, 3600); volt5Model.Axes[0].Minimum = DateTimeAxis.ToDouble(DateTime.Now); volt5Model.Axes[0].Maximum = DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(60)); } Volt14 = msg.lineVolt14; volt14Points.Add(new DataPoint(DateTimeAxis.ToDouble(dt), Volt14)); LineSeries volt14Serial = new LineSeries() { Title = "+14V母线电压" }; volt14Serial.Points.AddRange(volt14Points); Volt14Model.Series.Clear(); Volt14Model.Series.Add(volt14Serial); Volt14Model.InvalidatePlot(true); //刷新 Volt12P = msg.lineVolt12P; volt12PPoints.Add(new DataPoint(DateTimeAxis.ToDouble(dt), Volt12P)); LineSeries volt12PSerial = new LineSeries() { Title = "+12V供电电压" }; volt12PSerial.Points.AddRange(volt12PPoints); Volt12PModel.Series.Clear(); Volt12PModel.Series.Add(volt12PSerial); Volt12PModel.InvalidatePlot(true); //刷新 Volt12N = msg.lineVolt12N; volt12NPoints.Add(new DataPoint(DateTimeAxis.ToDouble(dt), Volt12N)); LineSeries volt12NSerial = new LineSeries() { Title = "-12V供电电压" }; volt12NSerial.Points.AddRange(volt12NPoints); Volt12NModel.Series.Clear(); Volt12NModel.Series.Add(volt12NSerial); Volt12NModel.InvalidatePlot(true); //刷新 Volt5 = msg.lineVolt5; volt5Points.Add(new DataPoint(DateTimeAxis.ToDouble(dt), Volt5)); LineSeries volt5Serial = new LineSeries() { Title = "+5V供电电压" }; volt5Serial.Points.AddRange(volt5Points); Volt5Model.Series.Clear(); Volt5Model.Series.Add(volt5Serial); Volt5Model.InvalidatePlot(true); //刷新 }
private void Plot(Dictionary <string, ChartValues <DataPoint> > theValues, DateTime requestTime, List <PlayerStats> selected = null, Predicate <object> filter = null) { LastFilter = filter; LastSelected = selected; string label; List <ChartValues <DataPoint> > sortedValues; if (selected == null || selected.Count == 0) { sortedValues = theValues.Values.Where(values => filter == null || filter(values.First())).OrderByDescending(values => values.Last().Total).Take(5).ToList(); label = sortedValues.Count > 0 ? "Top " + sortedValues.Count + " Player(s)" : Labels.NODATA; } else { List <string> names = selected.Select(stats => stats.OrigName).Take(10).ToList(); sortedValues = theValues.Values.Where(values => names.Contains(values.First().Name)).ToList(); label = sortedValues.Count > 0 ? "Selected Player(s)" : Labels.NODATA; } LastSortedValues = sortedValues = Smoothing(sortedValues); Dispatcher.InvokeAsync(() => { if (ChartModifiedTime < requestTime) { ChartValues = theValues; ChartModifiedTime = requestTime; Reset(); titleLabel.Content = label; SeriesCollection collection = new SeriesCollection(CurrentConfig); bool fixStillNeeded = true; foreach (var value in sortedValues) { var series = new LineSeries() { Title = value.First().Name, Values = value }; if (value.Count > 1) { series.PointGeometry = null; fixStillNeeded = false; } else if (value.Count == 1 && fixStillNeeded) // handles if everything is 1 point { if (!double.IsNaN(lvcChart.AxisX[0].MinValue)) { lvcChart.AxisX[0].MinValue = Math.Min(lvcChart.AxisX[0].MinValue, value[0].CurrentTime - 3.0); } else { lvcChart.AxisX[0].MinValue = value[0].CurrentTime - 3.0; } if (!double.IsNaN(lvcChart.AxisX[0].MaxValue)) { lvcChart.AxisX[0].MaxValue = Math.Max(lvcChart.AxisX[0].MaxValue, value[0].CurrentTime + 3.0); } else { lvcChart.AxisX[0].MaxValue = value[0].CurrentTime + 3.0; } } else { fixStillNeeded = false; } if (!fixStillNeeded) { lvcChart.AxisX[0].MinValue = double.NaN; lvcChart.AxisX[0].MaxValue = double.NaN; } collection.Add(series); } lvcChart.Series = collection; } }); }
private static void GetBooksAndPagesReadLineSeries(int colourIndex, List <OxyColor> colours, int year, out LineSeries booksReadSeries, out LineSeries pagesReadSeries) { var colour = colours[colourIndex]; OxyPlotUtilities.CreateLineSeries(out booksReadSeries, ChartAxisKeys.DayOfYearKey, ChartAxisKeys.BooksReadKey, "Total Books Read in " + year.ToString(), colourIndex); booksReadSeries.StrokeThickness++; booksReadSeries.Color = colour; OxyPlotUtilities.CreateLineSeries(out pagesReadSeries, ChartAxisKeys.DayOfYearKey, ChartAxisKeys.PagesReadKey, "Total Pages Read in " + year.ToString(), colourIndex); pagesReadSeries.LineStyle = LineStyle.Dash; pagesReadSeries.Color = colour; }
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 = LineJoin.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; }
public static PlotModel RichterMagnitudes() { // http://en.wikipedia.org/wiki/Richter_magnitude_scale var model = new PlotModel("The Richter magnitude scale") { PlotMargins = new OxyThickness(80, 0, 80, 40), LegendPlacement = LegendPlacement.Inside, LegendPosition = LegendPosition.TopCenter, LegendOrientation = LegendOrientation.Horizontal, LegendSymbolLength = 24 }; model.Axes.Add(new LinearAxis(AxisPosition.Bottom, "Richter magnitude scale") { MajorGridlineStyle = LineStyle.None, TickStyle = global::OxyPlot.Axes.TickStyle.None }); var frequencyCurve = new LineSeries("Frequency") { Color = OxyColor.FromUInt32(0xff3c6c9e), StrokeThickness = 3, MarkerStroke = OxyColor.FromUInt32(0xff3c6c9e), MarkerFill = OxyColors.White, MarkerType = MarkerType.Circle, MarkerSize = 4, MarkerStrokeThickness = 3 }; frequencyCurve.Points.Add(new DataPoint(1.5, 8000 * 365 * 100)); frequencyCurve.Points.Add(new DataPoint(2.5, 1000 * 365 * 100)); frequencyCurve.Points.Add(new DataPoint(3.5, 49000 * 100)); frequencyCurve.Points.Add(new DataPoint(4.5, 6200 * 100)); frequencyCurve.Points.Add(new DataPoint(5.5, 800 * 100)); frequencyCurve.Points.Add(new DataPoint(6.5, 120 * 100)); frequencyCurve.Points.Add(new DataPoint(7.5, 18 * 100)); frequencyCurve.Points.Add(new DataPoint(8.5, 1 * 100)); frequencyCurve.Points.Add(new DataPoint(9.5, 1.0 / 20 * 100)); model.Axes.Add(new LogarithmicAxis(AxisPosition.Left, "Frequency / 100 yr") { UseSuperExponentialFormat = true, MajorGridlineStyle = LineStyle.None, TickStyle = global::OxyPlot.Axes.TickStyle.Outside }); model.Series.Add(frequencyCurve); var energyCurve = new LineSeries("Energy") { Color = OxyColor.FromUInt32(0xff9e6c3c), StrokeThickness = 3, MarkerStroke = OxyColor.FromUInt32(0xff9e6c3c), MarkerFill = OxyColors.White, MarkerType = MarkerType.Circle, MarkerSize = 4, MarkerStrokeThickness = 3 }; energyCurve.Points.Add(new DataPoint(1.5, 11e6)); energyCurve.Points.Add(new DataPoint(2.5, 360e6)); energyCurve.Points.Add(new DataPoint(3.5, 11e9)); energyCurve.Points.Add(new DataPoint(4.5, 360e9)); energyCurve.Points.Add(new DataPoint(5.5, 11e12)); energyCurve.Points.Add(new DataPoint(6.5, 360e12)); energyCurve.Points.Add(new DataPoint(7.5, 11e15)); energyCurve.Points.Add(new DataPoint(8.5, 360e15)); energyCurve.Points.Add(new DataPoint(9.5, 11e18)); energyCurve.YAxisKey = "energyAxis"; model.Axes.Add(new LogarithmicAxis(AxisPosition.Right, "Energy / J") { Key = "energyAxis", UseSuperExponentialFormat = true, MajorGridlineStyle = LineStyle.None, TickStyle = global::OxyPlot.Axes.TickStyle.Outside }); model.Series.Add(energyCurve); return(model); }
private void CalculateBtn_Click(object sender, RoutedEventArgs e) { // actions lock calculateBtn.IsEnabled = false; writeToJornalBtn.IsEnabled = false; var startDate = analyticsCalendar.SelectedDates[0]; var endDate = analyticsCalendar.SelectedDates[analyticsCalendar.SelectedDates.Count - 1]; var dateList = analyticsCalendar.SelectedDates; List <DateTime> dates = new List <DateTime>(); List <int> values = new List <int>(); // Get demand of good for each day if (startDate > endDate) { dateList.Reverse(); } for (int i = 0; i < dateList.Count - 1; i++) { dates.Add(dateList[i]); values.Add(getSoldCountForPeriod(dateList[i], dateList[i + 1], AnalyticsComboBox.Text)); } // Calculate prognosis List <int> promValues = new List <int>(); foreach (var val in values) { promValues.Add(val); } while (promValues.Count > 2) { for (int i = 0; i < promValues.Count - 1; i++) { promValues[i] = (promValues[i] + promValues[i + 1]) / 2; } promValues.RemoveAt(promValues.Count - 1); } // Write calculations var delta = promValues[1] - promValues[0]; for (int i = 1; i <= 7; i++) { dates.Add(dates[dates.Count - 1].AddDays(1)); if (values[values.Count - 1] + delta < 0) { values.Add(0); } else { values.Add(values[values.Count - 1] + delta); } } // Make plot PlotModel PlotModel = new PlotModel { Title = "Прогноз для " + AnalyticsComboBox.Text }; var minValue = DateTimeAxis.ToDouble(dates[0].AddHours(-2)); var maxValue = DateTimeAxis.ToDouble(dates[dates.Count - 1].AddHours(1)); var sellSeries = new LineSeries { Title = "Оригинальный спрос", MarkerType = MarkerType.Circle, Color = OxyColor.FromRgb(57, 240, 172) }; var prognoseSeries = new LineSeries { Title = "Прогнозируемый спрос", MarkerType = MarkerType.Square, Color = OxyColor.FromRgb(240, 172, 57) }; // write demand and prognose series for (int i = 0; i < dateList.Count - 1; i++) { jornalLogs.Add(string.Format("+++ Demand +++ on {0} for good <<{1}>> is {2}", dates[i].ToString(), AnalyticsComboBox.Text, values[i])); sellSeries.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dates[i]), values[i])); } for (int i = dateList.Count - 2; i < dates.Count; i++) { jornalLogs.Add(string.Format("??? Prognose ??? on {0} for good <<{1}>> is {2}", dates[i].ToString(), AnalyticsComboBox.Text, values[i])); prognoseSeries.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dates[i]), values[i])); } // establish data axis PlotModel.Axes.Add(new DateTimeAxis { Position = AxisPosition.Bottom, Minimum = minValue, Maximum = maxValue, StringFormat = "MM/dd/yyyy" }); // draw plot PlotModel.Series.Add(sellSeries); PlotModel.Series.Add(prognoseSeries); PlotView.Model = PlotModel; // actions enable calculateBtn.IsEnabled = true; writeToJornalBtn.IsEnabled = true; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.ChartView); _deviceName = Intent.GetStringExtra("device") ?? "---"; var powerManager = (PowerManager)ApplicationContext.GetSystemService(Context.PowerService); wakeLock = powerManager.NewWakeLock(WakeLockFlags.Partial, "myNicolLock"); wakeLock.Acquire(); if (_plotModel == null) { _plotModel = new PlotModel(); _plotModel.PlotMargins = new OxyThickness(40, 40, 40, 40); _plotModel.Background = OxyColors.Black; _plotModel.TitleFontSize = 40; _plotModel.TitleColor = OxyColors.Green; _plotModel.SubtitleFontSize = 24; _plotModel.TextColor = OxyColors.White; var linearAxisLeft = new LinearAxis(); linearAxisLeft.MajorGridlineStyle = LineStyle.Solid; linearAxisLeft.MinorGridlineStyle = LineStyle.Dot; linearAxisLeft.Title = "HR"; linearAxisLeft.Key = "HR"; linearAxisLeft.Position = AxisPosition.Left; linearAxisLeft.Minimum = 10.0; linearAxisLeft.Maximum = 250.0; linearAxisLeft.AxislineColor = OxyColors.Magenta; linearAxisLeft.TextColor = OxyColors.Magenta; linearAxisLeft.TitleColor = OxyColors.Magenta; _plotModel.Axes.Add(linearAxisLeft); var linearAxisRight = new LinearAxis(); linearAxisRight.MajorGridlineStyle = LineStyle.Solid; linearAxisRight.MinorGridlineStyle = LineStyle.Dot; linearAxisRight.Position = AxisPosition.Right; linearAxisRight.Title = "%SpO2"; linearAxisRight.Key = "SP"; linearAxisRight.Minimum = 50.0; linearAxisRight.Maximum = 100.0; linearAxisRight.AxislineColor = OxyColors.Yellow; linearAxisRight.TitleColor = OxyColors.Yellow; linearAxisRight.TextColor = OxyColors.Yellow; _plotModel.Axes.Add(linearAxisRight); seriesHR = new LineSeries { Title = "Heart Rate (bpm)", Color = OxyColors.Magenta, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.Magenta, MarkerFill = OxyColors.Magenta, YAxisKey = "HR", MarkerStrokeThickness = 1.0, StrokeThickness = 5 }; _plotModel.Series.Add(seriesHR); seriesSP = new LineSeries() { Title = "Oxygen Saturation Level (%)", Color = OxyColors.Yellow, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.Yellow, MarkerFill = OxyColors.Yellow, YAxisKey = "SP", MarkerStrokeThickness = 1.0, StrokeThickness = 5 }; _plotModel.Series.Add(seriesSP); } plotView = FindViewById <PlotView>(Resource.Id.plotViewModel); if (plotView.Model == null) { plotView.Model = _plotModel; } Button_start_hr_Click(null, null); MyModel.InvalidatePlot(true); }
public UielementsExample() { InitializeComponent(); var lineSeries = new LineSeries { Values = new ChartValues <double> { 4, 6, 6, 3, 5 }, Fill = Brushes.Transparent, StrokeThickness = 4, PointGeometry = null }; var barSeries = new ColumnSeries { Values = new ChartValues <double> { 2, 6, 8, 9, 4 } }; cartesianChart1.Series.Add(lineSeries); cartesianChart1.Series.Add(barSeries); cartesianChart1.VisualElements.Add(new VisualElement { X = 0.5, Y = 7, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Top, UIElement = new TextBlock //notice this property must be a wpf control { Text = "Warning!", FontWeight = FontWeights.Bold, FontSize = 16, Opacity = 0.6 } }); var uri = new Uri("Cartesian/UielementsExample/warning.png", UriKind.Relative); cartesianChart1.VisualElements.Add(new VisualElement { X = 0.5, Y = 6.9, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Bottom, UIElement = new System.Windows.Controls.Image { Source = new BitmapImage(uri), Width = 24, Height = 24 } }); cartesianChart1.AxisY.Add(new Axis { IsMerged = true, Sections = new SectionsCollection { new AxisSection { FromValue = 7, ToValue = 7, Stroke = Brushes.YellowGreen, StrokeThickness = 3, StrokeDashArray = new DoubleCollection(new [] { 10d }) } } }); cartesianChart1.AxisX.Add(new Axis { Labels = new[] { "Jan", "Feb", "Mar", "Apr", "May" } }); Panel.SetZIndex(barSeries, 0); Panel.SetZIndex(lineSeries, 1); cartesianChart1.Base.MouseMove += BaseOnMouseMove; cartesianChart1.DataClick += cartesianChart1_DataClick; }
private async void createAccGraphModels() { for (int i = 0; i < TripIDs.Count; i++) { List <Ecolog> ecologs = null; List <DetailCompareSeriesDatum> data = null; String axisXString = null; await Task.Run(() => { ecologs = Ecolog.ExtractEcolog(TripIDs[i], SelectedSemanticLink); switch (CurrentAxisX) { case DetailCompareGraphType.Axes.Time: axisXString = "Time [s]"; data = DetailCompareSeriesDatum.CreateTimeAccData(ecologs); break; case DetailCompareGraphType.Axes.Distance: axisXString = "Distance [m]"; data = DetailCompareSeriesDatum.CreateDistanceAccData(ecologs); break; } }); PlotModel plotModel = new PlotModel(); LinearAxis axisX = new LinearAxis(); axisX.Position = AxisPosition.Bottom; axisX.Title = axisXString; LinearAxis axisY = new LinearAxis(); axisY.Title = "Acc [m/s^2]"; //plotModel.Axes.Add(axisX); plotModel.Axes.Add(axisY); LineSeries series = new LineSeries(); series.ItemsSource = data; series.DataFieldX = "X"; series.DataFieldY = "Y"; plotModel.Series.Add(series); switch (i) { case 0: LabelMinText = "Min trip: TripID = " + TripIDs[i] + ", StartTime = " + ecologs.Min(v => v.Jst); PlotModelMin = plotModel; break; case 1: LabelMedianText = "Median trip: TripID = " + TripIDs[i] + ", StartTime = " + ecologs.Min(v => v.Jst); PlotModelMedian = plotModel; break; case 2: LabelMaxText = "Max trip: TripID = " + TripIDs[i] + ", StartTime = " + ecologs.Min(v => v.Jst); PlotModelMax = plotModel; break; } } }
public void processCransData(Chart CurrentChart, List <int> Crans) { CurrentChart.Series.Clear(); DateTime min = DateTime.MaxValue; DateTime max = DateTime.MinValue; foreach (CranTaskInfo task in CurrentFilter.Data) { if (!task.Allowed) { if (task.NeedStartDate < min) { min = task.NeedStartDate; } if (task.NeedEndDate > max) { max = task.NeedEndDate; } } if (task.Allowed) { if (task.AllowDateStart < min) { min = task.AllowDateStart; } if (task.AllowDateEnd > max) { max = task.AllowDateEnd; } } if (task.Opened) { if (task.RealDateStart < min) { min = task.RealDateStart; } } if (task.Finished) { if (task.RealDateEnd > max) { max = task.RealDateEnd; } } } LineSeries nulSer = new LineSeries(); DataSeries <DateTime, double> nulP = new DataSeries <DateTime, double>(); nulP.Add(new DataPoint <DateTime, double>(min, 0.5)); nulP.Add(new DataPoint <DateTime, double>(max, 0.5)); nulSer.DataSeries = nulP; LineSeries ser15 = new LineSeries(); DataSeries <DateTime, double> p15 = new DataSeries <DateTime, double>(); p15.Add(new DataPoint <DateTime, double>(min, 1.5)); p15.Add(new DataPoint <DateTime, double>(max, 1.5)); ser15.DataSeries = p15; LineSeries ser3 = new LineSeries(); DataSeries <DateTime, double> p3 = new DataSeries <DateTime, double>(); p3.Add(new DataPoint <DateTime, double>(min, 2.5)); p3.Add(new DataPoint <DateTime, double>(max, 2.5)); ser3.DataSeries = p3; CurrentChart.Series.Add(nulSer); CurrentChart.Series.Add(ser15); CurrentChart.Series.Add(ser3); int i = 1; foreach (int cran in Crans) { processSingleCran(cran, CurrentChart, i); i++; } }
public void Init(List <Pollution> pollutions) { //pollutions = new List<Pollution>() //{ // new Pollution{Location="ALTON",LastUpdate=Convert.ToDateTime("11.10.2018"),Value=0.017}, // new Pollution{Location="ALTON",LastUpdate=Convert.ToDateTime("11.10.2018"),Value=0.011}, // new Pollution{Location="ALTON",LastUpdate=Convert.ToDateTime("11.10.2018"),Value=0.014}, // new Pollution{Location="ALTON",LastUpdate=Convert.ToDateTime("11.10.2018"),Value=0.015}, // new Pollution{Location="ALTON",LastUpdate=Convert.ToDateTime("11.10.2018"),Value=0.016}, // new Pollution{Location="ALTON",LastUpdate=Convert.ToDateTime("07.11.2016"),Value=0.046}, // new Pollution{Location="ALTON",LastUpdate=Convert.ToDateTime("20.07.2017"),Value=0.05}, // new Pollution{Location="ALTON",LastUpdate=Convert.ToDateTime("11.10.2018"),Value=0.013}, // new Pollution{Location="ALTON",LastUpdate=Convert.ToDateTime("11.10.2018"),Value=0.017}, // new Pollution{Location="ALTON",LastUpdate=Convert.ToDateTime("11.10.2018"),Value=0.018} //}; cartesianChart1.Series.Clear(); //pollutions = _pollutionContext.Pollutions.Where(p => p.City == "Tucson" && p.Location == "22nd Street & Craycr" && p.Parameter == "o3").ToList(); var map = Mappers.Xy <DataModel>().X(p => p.Number).Y(p => p.Value); var dates = pollutions.Select(p => p.LastUpdate.ToString("dd.MM.yyyy HH:mm:ss")).ToList(); dates = dates.Distinct().ToList(); dates.Sort(new ComparerDate()); foreach (var item in pollutions) { if (!cartesianChart1.Series.Any(p => p.Title == item.Location)) { Series series; if (pollutions.FindAll(p => p.Location == item.Location).Count > 1) { series = new LineSeries(map); } else { series = new LineSeries(map) { PointGeometrySize = 19 }; } series.Title = item.Location; series.Values = new ChartValues <DataModel>() { new DataModel { Value = item.Value, Number = dates.FindIndex(p => p == item.LastUpdate.ToString("dd.MM.yyyy HH:mm:ss")) } }; cartesianChart1.Series.Add(series); var checkBox = new CheckBox(); checkBox.Text = series.Title; checkBox.Checked = true; checkBox.Dock = DockStyle.Left; checkBox.CheckedChanged += CheckBox_CheckedChanged; panel2.Controls.Add(checkBox); } else { cartesianChart1.Series.FirstOrDefault(p => p.Title == item.Location).Values.Add( new DataModel { Value = item.Value, Number = dates.FindIndex(p => p == item.LastUpdate.ToString("dd.MM.yyyy HH:mm:ss")) }); } } cartesianChart1.AxisX.Clear(); cartesianChart1.AxisX.Add(new Axis { Labels = dates }); cartesianChart1.LegendLocation = LegendLocation.Right; }
public void processSingleCran(int cranNumber, Chart CurrentChart, double cranVal) { Dictionary <DateTime, CranTaskInfo> crans = new Dictionary <DateTime, CranTaskInfo>(); foreach (CranTaskInfo task in CurrentFilter.Data) { DateTime date = task.NeedEndDate; if (task.Allowed) { date = task.AllowDateEnd; } if (task.CranNumber == cranNumber) { while (crans.ContainsKey(date)) { date = date.AddMilliseconds(1); } crans.Add(date, task); } } IEnumerable <KeyValuePair <DateTime, CranTaskInfo> > sorted = crans.OrderBy(task => task.Value.NeedStartDate); double maxCntA = 0; double maxCntD = 0; double cntA = 0; double cntD = 0; CranTaskInfo prevTaskA = null; CranTaskInfo prevTaskD = null; foreach (KeyValuePair <DateTime, CranTaskInfo> de in sorted) { CranTaskInfo task = de.Value; if (task.TaskState == CranTaskState.reviewed && task.Allowed) { if (prevTaskA != null && task.AllowDateStart.AddMinutes(1) > prevTaskA.AllowDateEnd) { if (maxCntA < cntA) { maxCntA = cntA; } cntA = 0; } cntA++; prevTaskA = task; } else if (task.Denied) { if (prevTaskD != null && task.NeedStartDate.AddMinutes(1) > prevTaskD.NeedEndDate) { if (maxCntD < cntD) { maxCntD = cntD; } cntD = 0; } cntD++; prevTaskD = task; } else if (task.Cancelled) { if (prevTaskD != null && task.NeedStartDate.AddMinutes(1) > prevTaskD.NeedEndDate) { if (maxCntD < cntD) { maxCntD = cntD; } cntD = 0; } cntD++; prevTaskD = task; } else if (task.Finished || task.Opened) { if (prevTaskA != null && task.RealDateStart.AddMinutes(1) > prevTaskA.AllowDateEnd) { if (maxCntA < cntA) { maxCntA = cntA; } cntA = 0; } cntA++; prevTaskA = task; } else { if (prevTaskD != null && task.NeedStartDate.AddMinutes(1) > prevTaskD.NeedEndDate) { if (maxCntD < cntD) { maxCntD = cntD; } cntD = 0; } cntD++; prevTaskD = task; } } if (maxCntA < 2) { maxCntA = 2; } if (maxCntD < 2) { maxCntD = 2; } double stepA = 0.5 / (maxCntA + 1.5); double stepD = 0.5 / (maxCntD + 2.5); /*double stepA = 0.05; * double stepD = 0.05;*/ double diffA = 0; double diffD = stepD; prevTaskA = null; prevTaskD = null; foreach (KeyValuePair <DateTime, CranTaskInfo> de in sorted) { CranTaskInfo task = de.Value; LineSeries serie = new LineSeries(); DataSeries <DateTime, double> Points = new DataSeries <DateTime, double>(); serie.Name = String.Format("order_{0}", task.Number); serie.MouseLeftButtonUp += serie_MouseLeftButtonUp; serie.LineStrokeThickness = 3; serie.SelectionMode = Visiblox.Charts.SelectionMode.None; serie.PointShape = Visiblox.Charts.Primitives.ShapeType.Rectangle; serie.PointSize = 8; serie.ShowPoints = true; if (task.TaskState == CranTaskState.reviewed && task.Allowed) { if (prevTaskA != null && task.AllowDateStart.AddMinutes(1) >= prevTaskA.AllowDateEnd) { diffA = 0; } if (!task.Finished) { Points.Add(new DataPoint <DateTime, double>(task.AllowDateStart, cranVal + diffA)); Points.Add(new DataPoint <DateTime, double>(task.AllowDateEnd, cranVal + diffA)); } else { Points.Add(new DataPoint <DateTime, double>(task.RealDateStart, cranVal + diffA)); Points.Add(new DataPoint <DateTime, double>(task.RealDateEnd, cranVal + diffA)); } serie.LineStroke = new SolidColorBrush(!task.Finished ? Colors.Green : Colors.Blue); serie.PointFill = new SolidColorBrush(!task.Finished ? Colors.Green : Colors.Blue); diffA += stepA; prevTaskA = task; } else if (task.Denied) { if (prevTaskD != null && task.NeedStartDate.AddMinutes(1) >= prevTaskD.NeedEndDate) { diffD = stepD; } Points.Add(new DataPoint <DateTime, double>(task.NeedStartDate, cranVal - diffD)); Points.Add(new DataPoint <DateTime, double>(task.NeedEndDate, cranVal - diffD)); serie.LineStroke = new SolidColorBrush(Colors.Red); serie.PointFill = new SolidColorBrush(Colors.Red); diffD += stepD; prevTaskD = task; } else if (task.Cancelled) { if (prevTaskD != null && task.NeedStartDate.AddMinutes(1) >= prevTaskD.NeedEndDate) { diffD = stepD; } Points.Add(new DataPoint <DateTime, double>(task.NeedStartDate, cranVal - diffD)); Points.Add(new DataPoint <DateTime, double>(task.NeedEndDate, cranVal - diffD)); serie.LineStroke = new SolidColorBrush(Colors.LightGray); serie.PointFill = new SolidColorBrush(Colors.LightGray); diffD += stepD; prevTaskD = task; } else if (task.TaskState == CranTaskState.opened) { if (prevTaskA != null && task.RealDateStart.AddMinutes(1) >= prevTaskA.AllowDateEnd) { diffA = 0; } Points.Add(new DataPoint <DateTime, double>(task.RealDateStart, cranVal + diffA)); Points.Add(new DataPoint <DateTime, double>(task.AllowDateEnd, cranVal + diffA)); serie.LineStroke = new SolidColorBrush(Colors.Orange); serie.PointFill = new SolidColorBrush(Colors.Orange); diffA += stepA; prevTaskA = task; } else if (task.TaskState == CranTaskState.finished) { if (prevTaskA != null && task.RealDateStart.AddMinutes(1) >= prevTaskA.AllowDateEnd) { diffA = 0; } Points.Add(new DataPoint <DateTime, double>(task.RealDateStart, cranVal + diffA)); Points.Add(new DataPoint <DateTime, double>(task.RealDateEnd, cranVal + diffA)); serie.LineStroke = new SolidColorBrush(Colors.Blue); serie.PointFill = new SolidColorBrush(Colors.Blue); diffA += stepA; prevTaskA = task; } else { if (prevTaskD != null && task.NeedStartDate.AddMinutes(1) >= prevTaskD.NeedEndDate) { diffD = stepD; } Points.Add(new DataPoint <DateTime, double>(task.NeedStartDate, cranVal - diffD)); Points.Add(new DataPoint <DateTime, double>(task.NeedEndDate, cranVal - diffD)); serie.LineStroke = new SolidColorBrush(Colors.Gray); serie.PointFill = new SolidColorBrush(Colors.Gray); diffD += stepD; prevTaskD = task; } serie.DataSeries = Points; CurrentChart.Series.Add(serie); } }
/// <summary> /// /// </summary> public void Draw_TAB1() { chart_hops.Series.Clear(); chart_hops.Width = 700; chart_hops.Height = 226; numberOfExp = Convert.ToDouble(com_numberof_exp.Text); // clear: EnergyKeyValues.Clear(); DelayKeyValues.Clear(); HopsKeyvals.Clear(); RoutitngDistanceKeyVales.Clear(); AverageTransDistrancePerHopList.Clear(); TransDistanceEfficiencylist.Clear(); RoutingDistanceEffiecncyList.Clear(); RoutingEfficiencyList.Clear(); RelaysCountList.Clear(); HopsPerRelayList.Clear(); PathsSpreadList.Clear(); BalanceingEfficiencyList.Clear(); // double sumEnergy = 0; double sumRoutingDistance = 0; double sumHops = 0; double sumDelay = 0; foreach (Experment exp in expermentsList) { sumEnergy += exp.EnergyConsumed.Value; sumRoutingDistance += exp.RoutingDistance.Value; sumHops += exp.Hops.Value; sumDelay += exp.Delay.Value; LineSeries LineHops = new LineSeries(); LineHops.Title = exp.Title; // hops dist LineHops.DependentValuePath = "Value"; LineHops.IndependentValuePath = "Key"; LineHops.ItemsSource = exp.HopsDistributions; chart_hops.Series.Add(LineHops); // hops dis per exp * EnergyKeyValues.Add(exp.EnergyConsumed); // energy per exp * DelayKeyValues.Add(exp.Delay); // delay per exp * HopsKeyvals.Add(exp.Hops); // hops per exp * RoutitngDistanceKeyVales.Add(exp.RoutingDistance); // routing distance per exp * //: fig2: AverageTransDistrancePerHopList.Add(exp.AverageTransDistrancePerHop); // averag trans distance per exp * TransDistanceEfficiencylist.Add(exp.TransDistanceEfficiency); // trans effeicny per exp. * RoutingDistanceEffiecncyList.Add(exp.RoutingDistanceEffiecncy); // routing distance eff * RoutingEfficiencyList.Add(exp.RoutingEfficiency); // routing effecian. BalanceingEfficiencyList.Add(exp.BalanceingEfficiency); // blancing eff. // RelaysCountList.Add(exp.RelaysCount); HopsPerRelayList.Add(exp.HopsPerRelay); PathsSpreadList.Add(exp.PathsSpread); // path spread } cols_delay_distribution.DataContext = DelayKeyValues; cols_energy_distribution.DataContext = EnergyKeyValues; cols_hops.DataContext = HopsKeyvals; col_routingDistance.DataContext = RoutitngDistanceKeyVales; cols_hops.Title = (sumHops / numberOfExp).ToString("0.00"); cols_delay_distribution.Title = (sumDelay / numberOfExp).ToString("0.00"); col_routingDistance.Title = (sumRoutingDistance / numberOfExp).ToString("0.00"); cols_energy_distribution.Title = (sumEnergy / numberOfExp).ToString("0.00"); //: Fig2: col_averageroutingdistance.DataContext = AverageTransDistrancePerHopList; col_TransmissionDistanceEfficiency.DataContext = TransDistanceEfficiencylist; col_Routingefficiency.DataContext = RoutingEfficiencyList; col_routingdistanceefficiency.DataContext = RoutingDistanceEffiecncyList; // col_RDE, col_RE ,col_TDE col_RE.DataContext = RoutingEfficiencyList; col_RDE.DataContext = RoutingDistanceEffiecncyList; col_TDE.DataContext = TransDistanceEfficiencylist; // cols_Balanceing.DataContext = PathsSpreadList; cols_RelaysCount.DataContext = RelaysCountList; col_HopsPerRelay.DataContext = HopsPerRelayList; tab3_col_blancing.DataContext = PathsSpreadList; tab3_col_blancing_eff.DataContext = BalanceingEfficiencyList; tab3_col_routing_distance_eff.DataContext = RoutingDistanceEffiecncyList; tab3_col_transDistance_eff.DataContext = TransDistanceEfficiencylist; }