public static IPlotModel GetPlotModel(MeasurementHistory historyData, SensorClass sensorClass, string sensorName) { var graphDataPoints = new List <GraphData>(); foreach (var item in historyData.Values.OrderBy(i => i.Timestamp)) { graphDataPoints.Add(new GraphData() { Y = double.Parse(item.Value, CultureInfo.InvariantCulture), X = item.Timestamp }); } var theme = (ColorThemeEnum)Preferences.Get(ColorTheme.ColorThemePreferenceName, 0); var plotModel = new ViewResolvingPlotModel() { Title = $"{sensorName} ({historyData.Unit})" }; var ls = new AreaSeries() { DataFieldX = "X", DataFieldY = "Y", ItemsSource = graphDataPoints }; plotModel.Series.Add(ls); // If values are all same, use custom min/max values to show graph var minValue = GetMinimumValue(graphDataPoints, sensorClass); var maxValue = GetMaximumValue(graphDataPoints, sensorClass); if (minValue == maxValue) { minValue = minValue - 5; maxValue = maxValue + 5; } plotModel.Axes.Add(GetLinearAxis(theme, AxisPosition.Left, minValue, maxValue, GetMajorStep(minValue, maxValue, sensorClass))); plotModel.Axes.Add(GetLinearAxis(theme, AxisPosition.Right, minValue, maxValue, GetMajorStep(minValue, maxValue, sensorClass))); plotModel.Axes.Add(GetDateTimeAxis(theme)); switch (theme) { default: case ColorThemeEnum.Gray: plotModel.TitleColor = OxyColors.WhiteSmoke; plotModel.PlotAreaBorderColor = OxyColors.DimGray; ((LineSeries)plotModel.Series[0]).Color = OxyColor.Parse("#FF9FA8DA"); break; case ColorThemeEnum.Light: plotModel.TitleColor = OxyColors.Black; plotModel.PlotAreaBorderColor = OxyColors.Black; ((LineSeries)plotModel.Series[0]).Color = OxyColor.Parse("#FF3F51B5"); break; } return(plotModel); }
public ViewResolvingPlotModel InitializeDefault(IEnumerable <MultiRoomInfo> collection, int code) { ViewResolvingPlotModel result = ViewResolvingPlotModel.CreateDefault(); var humidityLineSerie = result.GetLast(); var temperatureLineSerie = result.GetFirst(); List <DataPoint> humidityPoints = new List <DataPoint>(); List <DataPoint> temperaturePoints = new List <DataPoint>(); switch (code) { case 1: humidityPoints = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.Humidity)).ToList(); temperaturePoints = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.Temperature)).ToList(); break; case 2: humidityPoints = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.HumidityMiddle)).ToList(); temperaturePoints = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.TemperatureMiddle)).ToList(); break; case 3: humidityPoints = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.HumidityProcess)).ToList(); temperaturePoints = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.TemperatureNord)).ToList(); break; case 4: humidityPoints = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.HumidityProcess)).ToList(); temperaturePoints = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.TemperatureProcess)).ToList(); break; default: break; } result.FillCollection(temperatureLineSerie, temperaturePoints); result.FillCollection(humidityLineSerie, humidityPoints); result.SetLastNHours(6); result.AddAnnotationEveryDay(); // GraphInfo.GraphLineModelForDefault.InvalidatePlot(true); return(result); }
public override void OnDialogOpened(IDialogParameters parameters) { if (parameters != null) { GraphInfo = parameters.GetValue <RoomLineGraphInfo>("model"); TemperatureGraphInfo = RoomLineGraphInfo.CreateDefault(); TemperatureGraphInfo.GraphLineModel = ViewResolvingPlotModel.CreateDefault(18, 60); HumidityGraphInfo = RoomLineGraphInfo.CreateDefault(); HumidityGraphInfo.GraphLineModel = ViewResolvingPlotModel.CreateDefault(45, 75); TemperatureGraphInfo.GraphLineModel.GetLast().IsVisible = false; HumidityGraphInfo.GraphLineModel.GetFirst().IsVisible = false; GraphInfo.AddToCollectionEvent += Current_AddToCollectionEvent; Title = $"{GraphInfo?.ActiveDevice?.Nick} {GraphInfo?.ActiveDevice?.IPAddress}"; var points = _roomRepository.FilterRooms(GraphInfo.ActiveDevice.Id).GetAwaiter().GetResult(); FillTemperatureGraph(points); FillHumidityGraph(points); InitializeAnnotations(); SetSettings(); if (parameters.TryGetValue("dataType", out int value)) { if (value == 2) { TemperatureText += " Мид"; } if (value == 3) { TemperatureText += " Норд"; } if (value == 4) { TemperatureText += " Процесс"; } } } }
public PlotViewModel(int plotViewId = 0) { _plotViewId = plotViewId; _minYValue = MinY = 1E-9; _maxYValue = MaxY = 1.0; _minXValue = MinX = 1E-9; _maxXValue = MaxX = 1.0; _manualScaleX = false; _manualScaleY = false; RealLabels = new List <string>(); ImagLabels = new List <string>(); PhaseLabels = new List <string>(); AmplitudeLabels = new List <string>(); Labels = new List <string>(); PlotTitles = new List <string>(); DataSeriesCollection = new List <DataPointCollection>(); PlotSeriesCollection = new PlotPointCollection(); _IsComplexPlot = false; PlotModel = new ViewResolvingPlotModel { Title = "", LegendPlacement = LegendPlacement.Outside, DefaultColors = new List <OxyColor> { OxyColor.FromRgb(0x00, 0x80, 0x00), // Green OxyColor.FromRgb(0xD6, 0x89, 0x10), // Dark Orange OxyColor.FromRgb(0xDC, 0x14, 0x3C), // Crimson Red OxyColor.FromRgb(0x00, 0x00, 0xFF), // Blue OxyColor.FromRgb(0xC4, 0x15, 0xC4), // Dark Magenta OxyColor.FromRgb(0x00, 0xBF, 0xBF), // Turquoise OxyColor.FromRgb(0x4F, 0x4F, 0x4F), // Dark Grey OxyColor.FromRgb(0x33, 0x99, 0xFF), // Light Blue OxyColor.FromRgb(0x80, 0x00, 0x00), // Maroon OxyColor.FromRgb(0x00, 0x80, 0x80), // Teal OxyColor.FromRgb(0x00, 0x00, 0x80), // Navy Blue OxyColor.FromRgb(0x99, 0x99, 0x00), // Olive Green } }; PlotType = ReflectancePlotType.ForwardSolver; _HoldOn = true; _HideKey = false; _ShowInPlotView = true; _ShowAxes = false; _showComplexPlotToggle = false; _xAxisLog10 = false; _yAxisLog10 = false; PlotToggleTypeOptionVM = new OptionViewModel <PlotToggleType>("ToggleType_" + _plotViewId, false); PlotToggleTypeOptionVM.PropertyChanged += (sender, args) => UpdatePlotSeries(); PlotNormalizationTypeOptionVM = new OptionViewModel <PlotNormalizationType>("NormalizationType_" + _plotViewId, false); PlotNormalizationTypeOptionVM.PropertyChanged += (sender, args) => UpdatePlotSeries(); //Commands.Plot_PlotValues.Executed += Plot_Executed; //Commands.Plot_SetAxesLabels.Executed += Plot_SetAxesLabels_Executed; //PlotValues = new RelayCommand<Array>(Plot_Executed); PlotValuesCommand = new Command <Array>(async(x) => await ExecutePlotCommand(x)); //SetAxesLabels = new RelayCommand<object>(Plot_SetAxesLabels_Executed); //ClearPlotCommand = new RelayCommand(() => Plot_Cleared(null, null)); ClearPlotCommand = new Command(async() => await Plot_Cleared()); ClearPlotSingleCommand = new Command(async() => await Plot_ClearedSingle()); //ClearPlotSingleCommand = new RelayCommand(() => Plot_ClearedSingle(null, null)); //ExportDataToTextCommand = new RelayCommand(() => Plot_ExportDataToText_Executed(null, null)); //DuplicateWindowCommand = new RelayCommand(() => Plot_DuplicateWindow_Executed(null, null)); }
private void _plotInspectionAnalysisResult(InspectionAnalysisResults result) { var AsignalPlot = new ViewResolvingPlotModel() { PlotAreaBackground = OxyColors.WhiteSmoke }; //var legends = new ObservableCollection<Legend>(); LinearAxis xAxis = new LinearAxis() { Position = AxisPosition.Bottom, Title = result.Xlabel, MajorGridlineStyle = LineStyle.Dot, MinorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColor.FromRgb(44, 44, 44), TicklineColor = OxyColor.FromRgb(82, 82, 82), IsZoomEnabled = true, IsPanEnabled = true, }; //timeXAxis.AxisChanged += TimeXAxis_AxisChanged; AsignalPlot.Axes.Add(xAxis); LinearAxis yAxis = new LinearAxis() { Position = AxisPosition.Left, Title = result.Ylabel, //Unit = SelectedSignalToBeViewed.Unit, MajorGridlineStyle = LineStyle.Dot, MinorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColor.FromRgb(44, 44, 44), TicklineColor = OxyColor.FromRgb(82, 82, 82), IsZoomEnabled = true, IsPanEnabled = true }; AsignalPlot.Axes.Add(yAxis); for (int index = 0; index < result.Y.Count; index++) { var newSeries = new LineSeries() { LineStyle = LineStyle.Solid, StrokeThickness = 2 }; for (int i = 0; i < result.Y[index].Count; i++) { newSeries.Points.Add(new DataPoint(result.X[i], result.Y[index][i])); } newSeries.Title = result.Signalnames[index]; foreach (var item in SelectedSignalPlotPanel.Legends) { if (newSeries.Title == item.Name) { newSeries.Color = item.Color; } } AsignalPlot.Series.Add(newSeries); } AsignalPlot.LegendPlacement = LegendPlacement.Outside; AsignalPlot.LegendPosition = LegendPosition.RightMiddle; AsignalPlot.LegendPadding = 0.0; AsignalPlot.LegendSymbolMargin = 0.0; AsignalPlot.LegendMargin = 0; AsignalPlot.IsLegendVisible = false; SelectedSignalPlotPanel.SpectralInspectionPlotModel = AsignalPlot; }
private void _drawSignals() { var AsignalPlot = new ViewResolvingPlotModel() { PlotAreaBackground = OxyColors.WhiteSmoke }; var legends = new ObservableCollection <Legend>(); DateTimeAxis timeXAxis = new DateTimeAxis() { Position = AxisPosition.Bottom, MinorIntervalType = DateTimeIntervalType.Auto, MajorGridlineStyle = LineStyle.Dot, MinorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColor.FromRgb(44, 44, 44), TicklineColor = OxyColor.FromRgb(82, 82, 82), IsZoomEnabled = true, IsPanEnabled = true, }; timeXAxis.AxisChanged += TimeXAxis_AxisChanged; AsignalPlot.Axes.Add(timeXAxis); LinearAxis yAxis = new LinearAxis() { Position = AxisPosition.Left, Title = _getUnitFromSignals(SelectedSignalPlotPanel.Signals), //Unit = SelectedSignalToBeViewed.Unit, MajorGridlineStyle = LineStyle.Dot, MinorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColor.FromRgb(44, 44, 44), TicklineColor = OxyColor.FromRgb(82, 82, 82), IsZoomEnabled = true, IsPanEnabled = true }; AsignalPlot.Axes.Add(yAxis); var signalCounter = 0; foreach (var signal in SelectedSignalPlotPanel.Signals) { var newSeries = new LineSeries() { LineStyle = LineStyle.Solid, StrokeThickness = 2 }; for (int i = 0; i < signal.Data.Count; i++) { newSeries.Points.Add(new DataPoint(signal.TimeStampNumber[i], signal.Data[i])); } newSeries.Title = signal.SignalName; var c = string.Format("#{0:x6}", Color.FromName(Utility.SaturatedColors[signalCounter % 20]).ToArgb()); newSeries.Color = OxyColor.Parse(c); legends.Add(new Legend(signal.SignalName, newSeries.Color)); AsignalPlot.Series.Add(newSeries); signalCounter++; } AsignalPlot.LegendPlacement = LegendPlacement.Outside; AsignalPlot.LegendPosition = LegendPosition.RightMiddle; AsignalPlot.LegendPadding = 0.0; AsignalPlot.LegendSymbolMargin = 0.0; AsignalPlot.LegendMargin = 0; AsignalPlot.IsLegendVisible = false; foreach (var ax in SelectedSignalPlotPanel.SignalViewPlotModel.Axes) { if (ax.IsHorizontal()) { foreach (var nax in AsignalPlot.Axes) { if (nax.IsHorizontal() && (ax.ActualMaximum != nax.ActualMaximum || ax.ActualMinimum != nax.ActualMinimum)) { nax.Zoom(ax.ActualMinimum, ax.ActualMaximum); break; } } } if (ax.IsVertical()) { foreach (var nax in AsignalPlot.Axes) { if (nax.IsVertical() && (ax.ActualMaximum != nax.ActualMaximum || ax.ActualMinimum != nax.ActualMinimum)) { nax.Zoom(ax.ActualMinimum, ax.ActualMaximum); break; } } } } SelectedSignalPlotPanel.SignalViewPlotModel = AsignalPlot; SelectedSignalPlotPanel.Legends = legends; }
public SignalPlotPanel() { _signalViewPlotModel = new ViewResolvingPlotModel(); Signals = new ObservableCollection <SignalViewModel>(); _isPlotSelected = false; }
public PartialUtilityTabViewModel(PartialUtility partialUtility, Results results, Action calculateUtilities, Action restartCoefficientsAssessment) { _partialUtility = partialUtility; _calculateUtilities = calculateUtilities; _restartCoefficientsAssessment = restartCoefficientsAssessment; _results = results; _initialPointsValues = new List <PartialUtilityValues> { new PartialUtilityValues(PointsValues[0].X, PointsValues[0].Y), new PartialUtilityValues(PointsValues.Last().X, PointsValues.Last().Y) }; Name = $"{Criterion.Name} - Utility"; Title = $"{Criterion.Name} - Partial Utility Function"; IsMethodSet = Criterion.Method != Criterion.MethodOptionsList[0]; if (IsMethodSet) { DialogController = new DialogController(_partialUtility, Criterion.MethodOptionsList.IndexOf(Criterion.Method), Criterion.Probability ?? 0.5); } else { // choose first method as default, to prevent from not selecting any method at all in radio buttons Criterion.Method = Criterion.MethodOptionsList[1]; } const double verticalAxisExtraSpace = 0.0001; var horizontalAxisExtraSpace = (Criterion.MaxValue - Criterion.MinValue) * 0.0001; // plot initializer _line = new LineSeries { Color = _lineColor, StrokeThickness = 3, MarkerFill = _lineColor, MarkerType = MarkerType.Circle, MarkerSize = 6 }; _placeholderLine = new LineSeries { Color = _placeholderLineColor, StrokeThickness = 3, MarkerStroke = _placeholderMarkerColor, MarkerStrokeThickness = 2, MarkerFill = OxyColors.Transparent, MarkerType = MarkerType.Circle, MarkerSize = 9 }; PlotModel = new ViewResolvingPlotModel { Series = { _line, _placeholderLine }, DefaultFont = "Segoe UI", DefaultFontSize = 14, Padding = new OxyThickness(0, 0, 0, 0), PlotAreaBackground = OxyColors.White, Axes = { new LinearAxis { Position = AxisPosition.Left, Title = "Partial Utility", FontSize = 16, MajorGridlineStyle = LineStyle.Solid, MajorGridlineColor = _gridColor, AbsoluteMinimum = 0 - verticalAxisExtraSpace, AbsoluteMaximum = 1 + verticalAxisExtraSpace, Minimum = 0 - verticalAxisExtraSpace, Maximum = 1 + verticalAxisExtraSpace, MajorTickSize = 8, IntervalLength = 30, AxisTitleDistance = 12 }, new LinearAxis { Position = AxisPosition.Bottom, Title = "Criterion Value", FontSize = 16, MajorGridlineStyle = LineStyle.Solid, MajorGridlineColor = _gridColor, AbsoluteMinimum = Criterion.MinValue - horizontalAxisExtraSpace, AbsoluteMaximum = Criterion.MaxValue + horizontalAxisExtraSpace, Minimum = Criterion.MinValue - horizontalAxisExtraSpace, Maximum = Criterion.MaxValue + horizontalAxisExtraSpace, MajorTickSize = 8, AxisTitleDistance = 4 } } }; PlotModel.MouseDown += (sender, args) => { if (args.ChangedButton != OxyMouseButton.Left) { return; } DeselectRectangle(); }; InitializePlotIfMethodIsSet(); }