Пример #1
0
        private static Plot CreatePlot(Dashboard.PropertyMap pm)
        {
            var plot = new Plot
            {
                Margin = new Thickness(0, 40, 0, 0),
                //Title = pm.Property.Name,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                // Width = SystemParameters.PrimaryScreenWidth * 0.4,
                Style = Application.Current.FindResource("OxyLineStyle") as Style,
            };

            plot.SetResourceReference(BackgroundProperty, "BackgroundColor");
            plot.SetResourceReference(ForegroundProperty, "MainColor");
            var convertFromString = ColorConverter.ConvertFromString("#F62A00");

            if (convertFromString != null)
            {
                var lineserie = new LineSeries
                {
                    ItemsSource     = pm.Property.Changes,
                    DataFieldY      = "Value",
                    DataFieldX      = "Name",
                    StrokeThickness = 1,
                    MarkerSize      = 3,
                    LineStyle       = LineStyle.Solid,
                    MarkerType      = MarkerType.Cross,
                    Color           = (Color)convertFromString,
                };

                var dateAxis = new DateTimeAxis {
                    MajorGridlineStyle = LineStyle.None, MinorGridlineStyle = LineStyle.None, IntervalLength = 80, AbsoluteMinimum = pm.Property.Changes.Min(x => x.Name).ToOADate()
                };
                dateAxis.SetResourceReference(Axis.TitleProperty, "Viewid7");
                plot.Axes.Add(dateAxis);
                var valueAxis = new LinearAxis {
                    MajorGridlineStyle = LineStyle.None, MinorGridlineStyle = LineStyle.None
                };
                valueAxis.SetResourceReference(Axis.TitleProperty, "Viewid6");
                //lags
                //pm.Property.Changes.CollectionChanged += (s, e) =>
                //{
                //    valueAxis.AbsoluteMaximum = pm.Property.Changes.Max(x => x.Value);
                //    valueAxis.AbsoluteMinimum= pm.Property.Changes.Min(x => x.Value);
                //};
                if (pm.Property.Type == 3)
                {
                    valueAxis.AbsoluteMaximum = 1;
                    valueAxis.AbsoluteMinimum = 0;
                }
                plot.Axes.Add(valueAxis);



                plot.Series.Add(lineserie);
            }
            plot.UpdateLayout();
            return(plot);
        }