public static PlotModel TwoColorLineSeries()
        {
            var model = new PlotModel { Title = "TwoColorLineSeries", LegendSymbolLength = 24 };
            var s1 = new TwoColorLineSeries
                         {
                             Title = "Temperature at Eidesmoen, December 1986.",
                             Color = OxyColors.Red,
                             Color2 = OxyColors.LightBlue,
                             StrokeThickness = 3,
                             Limit = 0,
                             Smooth = true,
                             MarkerType = MarkerType.Circle,
                             MarkerSize = 4,
                             MarkerStroke = OxyColors.Black,
                             MarkerStrokeThickness = 1.5
                         };
            var temperatures = new[] { 5, 0, 7, 7, 4, 3, 5, 5, 11, 4, 2, 3, 2, 1, 0, 2, -1, 0, 0, -3, -6, -13, -10, -10, 0, -4, -5, -4, 3, 0, -5 };

            for (int i = 0; i < temperatures.Length; i++)
            {
                s1.Points.Add(new DataPoint(i + 1, temperatures[i]));
            }

            model.Series.Add(s1);
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, ExtraGridlines = new[] { 0.0 } });

            return model;
        }
Esempio n. 2
1
 public static PlotModel ConstantBaselineItemsSource()
 {
     var plotModel1 = new PlotModel { Title = "AreaSeries with constant baseline", Subtitle = "ItemsSource and DataField2 not set, ConstantY2 = -20" };
     var areaSeries1 = new AreaSeries();
     var points = new[] { new DataPoint(0, 50), new DataPoint(10, 140), new DataPoint(20, 60) };
     areaSeries1.ItemsSource = points;
     areaSeries1.DataFieldX = "X";
     areaSeries1.DataFieldY = "Y";
     areaSeries1.ConstantY2 = -20;
     plotModel1.Series.Add(areaSeries1);
     return plotModel1;
 }
Esempio n. 3
0
 /// <summary>
 /// Synchronizes the properties.
 /// </summary>
 /// <param name="series">The series.</param>
 protected override void SynchronizeProperties(OxyPlot.Series.Series series)
 {
     base.SynchronizeProperties(series);
     var s = (OxyPlot.Series.StairStepSeries)series;
     s.VerticalLineStyle = this.VerticalLineStyle;
     s.VerticalStrokeThickness = this.VerticalStrokeThickness;
 }
 public static PlotModel UsingReflection()
 {
     var measurements = new[] { new MeasurementType3(0, 12), new MeasurementType3(10, 8), new MeasurementType3(15, 10) };
     var model = new PlotModel("Using reflection");
     model.Series.Add(new LineSeries { ItemsSource = measurements, DataFieldX = "Abscissa", DataFieldY = "Ordinate" });
     return model;
 }
Esempio n. 5
0
 /// <summary>
 /// Synchronizes the properties.
 /// </summary>
 /// <param name="series">The series.</param>
 protected override void SynchronizeProperties(OxyPlot.Series.Series series)
 {
     base.SynchronizeProperties(series);
     var s = (OxyPlot.Series.XYAxisSeries)series;
     s.XAxisKey = this.XAxisKey;
     s.YAxisKey = this.YAxisKey;
 }
 public static PlotModel UsingIDataPoint()
 {
     var measurements = new[] { new MeasurementType2(0, 8), new MeasurementType2(10, 10), new MeasurementType2(15, 12) };
     var model = new PlotModel("Using IDataPoint");
     model.Series.Add(new LineSeries { ItemsSource = measurements });
     return model;
 }
        public static PlotModel TwoColorAreaSeries1()
        {
            var model = new PlotModel { Title = "TwoColorAreaSeries", LegendSymbolLength = 24 };
            var s1 = new TwoColorAreaSeries
                         {
                             Title = "Temperature at Eidesmoen, December 1986.",
                             TrackerFormatString = "December {2:0}: {4:0.0} °C",
                             Color = OxyColors.Tomato,
                             Color2 = OxyColors.LightBlue,
                             MarkerFill = OxyColors.Tomato,
                             MarkerFill2 = OxyColors.LightBlue,
                             StrokeThickness = 2,
                             Limit = -1,
                             Smooth = false,
                             MarkerType = MarkerType.Circle,
                             MarkerSize = 3,
                         };
            var temperatures = new[] { 5, 0, 7, 7, 4, 3, 5, 5, 11, 4, 2, 3, 2, 1, 0, 2, -1, 0, 0, -3, -6, -13, -10, -10, 0, -4, -5, -4, 3, 0, -5 };

            for (int i = 0; i < temperatures.Length; i++)
            {
                s1.Points.Add(new DataPoint(i + 1, temperatures[i]));
            }

            model.Series.Add(s1);
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Temperature", Unit = "°C", MinorGridlineStyle = LineStyle.Solid, MajorGridlineStyle = LineStyle.Solid, MinorTickSize = 0 });
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "Date", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid });

            return model;
        }
 public static PlotModel UsingMappingProperty()
 {
     var measurements = new[] { new MeasurementType3(0, 12), new MeasurementType3(10, 8), new MeasurementType3(15, 10) };
     var model = new PlotModel("Using Mapping property");
     model.Series.Add(
         new LineSeries
             {
                 ItemsSource = measurements,
                 Mapping =
                     item => new DataPoint(((MeasurementType3)item).Abscissa, ((MeasurementType3)item).Ordinate)
             });
     return model;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TrackerHitResult"/> class.
 /// </summary>
 /// <param name="series">The series.</param>
 /// <param name="dp">The data point.</param>
 /// <param name="sp">The screen point.</param>
 /// <param name="item">The item.</param>
 /// <param name="index">The index.</param>
 /// <param name="text">The text.</param>
 public TrackerHitResult(OxyPlot.Series.Series series, IDataPoint dp, ScreenPoint sp, object item = null, double index = -1, string text = null)
 {
     this.DataPoint = dp;
     this.Position = sp;
     this.Item = item;
     this.Index = index;
     this.Series = series;
     this.Text = text;
     var ds = series as DataPointSeries;
     if (ds != null)
     {
         this.XAxis = ds.XAxis;
         this.YAxis = ds.YAxis;
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Tracker is calling to determine the nearest point.
        /// </summary>
        /// <param name="point">The point clicked</param>
        /// <param name="interpolate">A value indicating whether interpolation should be used.</param>
        /// <returns>The return hit result</returns>
        public override TrackerHitResult GetNearestPoint(OxyPlot.ScreenPoint point, bool interpolate)
        {
            TrackerHitResult hitResult = base.GetNearestPoint(point, interpolate);

            if (hitResult != null && OnHoverOverPoint != null)
            {
                HoverPointArgs e = new HoverPointArgs();
                e.SeriesName = Title;
                e.X = hitResult.DataPoint.X;
                e.Y = hitResult.DataPoint.Y;
                OnHoverOverPoint.Invoke(this, e);
                if (e.HoverText != null)
                {
                    hitResult.Series.TrackerFormatString = e.HoverText + "\n{1}: {2}\n{3}: {4}";
                }
            }

            return hitResult;
        }
Esempio n. 11
0
 /// <summary>
 /// Sets the cursor type.
 /// </summary>
 /// <param name="cursorType">The cursor type.</param>
 public void SetCursorType(OxyPlot.CursorType cursorType)
 {
     switch (cursorType)
     {
         case OxyPlot.CursorType.Pan:
             this.GdkWindow.Cursor = this.PanCursor;
             break;
         case OxyPlot.CursorType.ZoomRectangle:
             this.GdkWindow.Cursor = this.ZoomRectangleCursor;
             break;
         case OxyPlot.CursorType.ZoomHorizontal:
             this.GdkWindow.Cursor = this.ZoomHorizontalCursor;
             break;
         case OxyPlot.CursorType.ZoomVertical:
             this.GdkWindow.Cursor = this.ZoomVerticalCursor;
             break;
         default:
             this.GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Arrow);
             break;
     }
 }
Esempio n. 12
0
        private DataPoint? GetNearestPoint(OxyPlot.DataSeries s, System.Windows.Point pt, bool snap, bool pointsOnly)
        {
            if (s == null)
                return null;
            var dp = pc.InverseTransform(pt, s.XAxis, s.YAxis);

            if (snap || pointsOnly)
            {
                var dpn = s.GetNearestPoint(dp);
                if (dpn != null && snap)
                {
                    var spn = pc.Transform(dpn.Value, s.XAxis, s.YAxis);
                    if (spn.DistanceTo(pt) < 20)
                        return dpn;
                }
            }

            if (!pointsOnly)
                return s.GetNearestPointOnLine(dp);

            return null;
        }
Esempio n. 13
0
        /// <summary>
        /// Draws the multiple line segments defined by points (0,1) (2,3) (4,5) etc.
        /// This should have better performance than calling DrawLine for each segment.
        /// </summary>
        /// <param name="points">The points.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The stroke thickness.</param>
        /// <param name="dashArray">The dash array.</param>
        /// <param name="lineJoin">The line join type.</param>
        /// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
        public void DrawLineSegments(
            IList<ScreenPoint> points,
            OxyColor stroke,
            double thickness,
            double[] dashArray,
            OxyPlot.LineJoin lineJoin,
            bool aliased)
        {
            var path = new PathGeometry(this.d2dFactory);
            var sink = path.Open();
            for (int i = 0; i + 1 < points.Count; i += 2)
            {
                sink.BeginFigure(points[i].ToVector2(aliased), new FigureBegin());

                sink.AddLine(points[i + 1].ToVector2(aliased));
                sink.EndFigure(new FigureEnd());
            }

            sink.Close();
            sink.Dispose();

            var strokeStyle = this.GetStroke(dashArray, lineJoin);

            this.renderUnits.Add(new GeometryRenderUnit(path, this.GetBrush(stroke), null, (float)thickness, strokeStyle));
        }
Esempio n. 14
0
        /// <summary>
        /// The synchronize properties.
        /// </summary>
        /// <param name="series">
        /// The series.
        /// </param>
        protected override void SynchronizeProperties(OxyPlot.Series.Series series)
        {
            base.SynchronizeProperties(series);

            var s = (OxyPlot.Series.HeatMapSeries)series;
            s.Data = this.Data ?? new double[0, 0];
            s.X0 = this.X0;
            s.X1 = this.X1;
            s.Y0 = this.Y0;
            s.Y1 = this.Y1;
        }
Esempio n. 15
0
 public void ShowSlider(OxyPlot.DataSeries s, DataPoint dp)
 {
     slider.ContentTemplate = SliderTemplate;
     slider.SetPosition(dp, s);
 }
Esempio n. 16
0
 /// <summary>
 /// Synchronizes the properties.
 /// </summary>
 /// <param name="series">The series.</param>
 protected override void SynchronizeProperties(OxyPlot.Series.Series series)
 {
     base.SynchronizeProperties(series);
     var s = (OxyPlot.Series.BarSeriesBase)series;
     s.BaseValue = this.BaseValue;
     s.ColorField = this.ColorField;
     s.FillColor = this.FillColor.ToOxyColor();
     s.IsStacked = this.IsStacked;
     s.NegativeFillColor = this.NegativeFillColor.ToOxyColor();
     s.StrokeColor = this.StrokeColor.ToOxyColor();
     s.StrokeThickness = this.StrokeThickness;
     s.StackGroup = this.StackGroup;
     s.ValueField = this.ValueField;
     s.LabelFormatString = this.LabelFormatString;
     s.LabelMargin = this.LabelMargin;
     s.LabelPlacement = this.LabelPlacement;
 }
        /// <summary>
        /// The draw text.
        /// </summary>
        /// <param name="p">
        /// The p.
        /// </param>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="fill">
        /// The fill.
        /// </param>
        /// <param name="fontFamily">
        /// The font family.
        /// </param>
        /// <param name="fontSize">
        /// The font size.
        /// </param>
        /// <param name="fontWeight">
        /// The font weight.
        /// </param>
        /// <param name="rotate">
        /// The rotate.
        /// </param>
        /// <param name="halign">
        /// The horizontal alignment.
        /// </param>
        /// <param name="valign">
        /// The vertical alignment.
        /// </param>
        /// <param name="maxSize">
        /// The maximum size of the text.
        /// </param>
        public void DrawText(
            ScreenPoint p,
            string text,
            OxyColor fill,
            string fontFamily,
            double fontSize,
            double fontWeight,
            double rotate,
            OxyPlot.HorizontalAlignment halign,
            OxyPlot.VerticalAlignment valign,
            OxySize? maxSize)
        {
            var tb = new TextBlock { Text = text, Foreground = fill.ToBrush() };

            // tb.SetValue(TextOptions.TextHintingModeProperty, TextHintingMode.Animated);
            if (fontFamily != null)
            {
                tb.FontFamily = new FontFamily(fontFamily);
            }

            if (fontSize > 0)
            {
                tb.FontSize = fontSize;
            }

            tb.FontWeight = GetFontWeight(fontWeight);

            tb.Measure(new Size(1000, 1000));

            double dx = 0;
            if (halign == OxyPlot.HorizontalAlignment.Center)
            {
                dx = -tb.ActualWidth / 2;
            }

            if (halign == OxyPlot.HorizontalAlignment.Right)
            {
                dx = -tb.ActualWidth;
            }

            double dy = 0;
            if (valign == OxyPlot.VerticalAlignment.Middle)
            {
                dy = -tb.ActualHeight / 2;
            }

            if (valign == OxyPlot.VerticalAlignment.Bottom)
            {
                dy = -tb.ActualHeight;
            }

            var transform = new TransformGroup();
            transform.Children.Add(new TranslateTransform { X = (int)dx, Y = (int)dy });
            if (!rotate.Equals(0.0))
            {
                transform.Children.Add(new RotateTransform { Angle = rotate });
            }

            transform.Children.Add(new TranslateTransform { X = (int)p.X, Y = (int)p.Y });
            tb.RenderTransform = transform;

            if (this.clip.HasValue)
            {
                // add a clipping container that is not rotated
                var c = new Canvas();
                c.Children.Add(tb);
                this.Add(c);
            }
            else
            {
                this.Add(tb);
            }
        }
Esempio n. 18
0
 /// <summary>
 /// Synchronizes the properties.
 /// </summary>
 /// <param name="series">The series.</param>
 protected override void SynchronizeProperties(OxyPlot.Series.Series series)
 {
     base.SynchronizeProperties(series);
     var s = (OxyPlot.Series.LinearBarSeries)series;
     s.BarWidth = this.BarWidth;
     s.FillColor = this.FillColor.ToOxyColor();
     s.StrokeColor = this.StrokeColor.ToOxyColor();
     s.StrokeThickness = this.StrokeThickness;
     s.NegativeFillColor = this.NegativeFillColor.ToOxyColor();
     s.NegativeStrokeColor = this.NegativeStrokeColor.ToOxyColor();
 }
Esempio n. 19
0
        /// <summary>
        /// Gets the stroke.
        /// </summary>
        /// <param name="dashArray">The dashes array.</param>
        /// <param name="lineJoin">The line join type.</param>
        /// <returns>Returns stroke stroke style.</returns>
        private StrokeStyle GetStroke(double[] dashArray, OxyPlot.LineJoin lineJoin)
        {
            if (dashArray == null)
            {
                return new StrokeStyle(this.d2dFactory, new StrokeStyleProperties { LineJoin = lineJoin.ToDXLineJoin() });
            }

            return new StrokeStyle(this.d2dFactory, new StrokeStyleProperties { LineJoin = lineJoin.ToDXLineJoin(), DashStyle = DashStyle.Custom }, dashArray.Select(x => (float)x).ToArray());
        }
Esempio n. 20
0
        /// <summary>
        /// Draws a collection of polygons, where all polygons have the same stroke and fill.
        /// This performs better than calling DrawPolygon multiple times.
        /// </summary>
        /// <param name="polygons">The polygons.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The stroke thickness.</param>
        /// <param name="dashArray">The dash array.</param>
        /// <param name="lineJoin">The line join type.</param>
        /// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
        public void DrawPolygons(
            IList<IList<ScreenPoint>> polygons,
            OxyColor fill,
            OxyColor stroke,
            double thickness,
            double[] dashArray,
            OxyPlot.LineJoin lineJoin,
            bool aliased)
        {
            var path = new PathGeometry(this.d2dFactory);
            var sink = path.Open();
            foreach (var points in polygons)
            {
                sink.BeginFigure(points[0].ToVector2(aliased), new FigureBegin());

                sink.AddLines(points.Skip(1).Select(pt => (dx.Mathematics.Interop.RawVector2)pt.ToVector2(aliased)).ToArray());
                sink.EndFigure(new FigureEnd());
            }

            sink.Close();
            sink.Dispose();

            var strokeStyle = this.GetStroke(dashArray, lineJoin);
            this.renderUnits.Add(new GeometryRenderUnit(path, this.GetBrush(stroke), this.GetBrush(fill), (float)thickness, strokeStyle));
        }
Esempio n. 21
0
        /// <summary>
        /// Draws the text.
        /// </summary>
        /// <param name="p">The position.</param>
        /// <param name="text">The text.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="fontWeight">The font weight.</param>
        /// <param name="rotate">The rotation angle.</param>
        /// <param name="halign">The horizontal alignment.</param>
        /// <param name="valign">The vertical alignment.</param>
        /// <param name="maxSize">The maximum size of the text.</param>
        public void DrawText(
            ScreenPoint p,
            string text,
            OxyColor fill,
            string fontFamily,
            double fontSize,
            double fontWeight,
            double rotate,
            OxyPlot.HorizontalAlignment halign,
            OxyPlot.VerticalAlignment valign,
            OxySize? maxSize)
        {
            if (string.IsNullOrWhiteSpace(fontFamily))
            {
                fontFamily = "Arial";
            }

            if (text == null)
            {
                text = string.Empty;
            }

            var format = new TextFormat(this.dwtFactory, fontFamily, GetFontWeight(fontWeight), FontStyle.Normal, FontStretch.Normal, (float)fontSize);
            var maxWidth = 1000f;
            var maxHeight = 1000f;
            if (maxSize != null)
            {
                maxHeight = (float)maxSize.Value.Height;
                maxWidth = (float)maxSize.Value.Width;
            }

            var layout = new TextLayout(this.dwtFactory, text, format, maxWidth, maxHeight);

            var size = new Size2F(layout.Metrics.Width, layout.Metrics.Height);
            if (maxSize != null)
            {
                if (size.Width > maxSize.Value.Width)
                {
                    size.Width = (float)maxSize.Value.Width;
                }

                if (size.Height > maxSize.Value.Height)
                {
                    size.Height = (float)maxSize.Value.Height;
                }
            }

            float dx = 0;
            if (halign == OxyPlot.HorizontalAlignment.Center)
            {
                dx = -size.Width / 2;
            }

            if (halign == OxyPlot.HorizontalAlignment.Right)
            {
                dx = -size.Width;
            }

            float dy = 0;
            if (valign == OxyPlot.VerticalAlignment.Middle)
            {
                dy = -size.Height / 2;
            }

            if (valign == OxyPlot.VerticalAlignment.Bottom)
            {
                dy = -size.Height;
            }

            this.renderUnits.Add(new TextRenderUnit(layout, this.GetBrush(fill), Matrix3x2.Translation(dx, dy) * Matrix3x2.Rotation((float)rotate) * Matrix3x2.Translation(p.ToVector2())));
            format.Dispose();
        }
        /// <summary>
        /// Draws the polyline from the specified points.
        /// </summary>
        /// <param name="points">The points.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The stroke thickness.</param>
        /// <param name="dashArray">The dash array.</param>
        /// <param name="lineJoin">The line join type.</param>
        /// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
        public override void DrawLine(
            IList<ScreenPoint> points,
            OxyColor stroke,
            double thickness,
            double[] dashArray,
            OxyPlot.LineJoin lineJoin,
            bool aliased)
        {
            if (stroke.IsInvisible() || thickness <= 0 || points.Count < 2)
            {
                return;
            }

            this.g.SmoothingMode = aliased ? SmoothingMode.None : SmoothingMode.HighQuality;
            using (var pen = this.CreatePen(stroke, thickness, dashArray, lineJoin))
            {
                this.g.DrawLines(pen, this.ToPoints(points));
            }
        }
Esempio n. 23
0
 /// <summary>
 /// Synchronizes the properties.
 /// </summary>
 /// <param name="series">The series.</param>
 protected override void SynchronizeProperties(OxyPlot.Series.Series series)
 {
     base.SynchronizeProperties(series);
     var s = (OxyPlot.Series.DataPointSeries)series;
     s.ItemsSource = this.ItemsSource;
     s.DataFieldX = this.DataFieldX;
     s.DataFieldY = this.DataFieldY;
     s.CanTrackerInterpolatePoints = this.CanTrackerInterpolatePoints;
     s.Mapping = this.Mapping;
 }
        /// <summary>
        /// Draws the polygon from the specified points. The polygon can have stroke and/or fill.
        /// </summary>
        /// <param name="points">The points.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The stroke thickness.</param>
        /// <param name="dashArray">The dash array.</param>
        /// <param name="lineJoin">The line join type.</param>
        /// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
        public override void DrawPolygon(
            IList<ScreenPoint> points,
            OxyColor fill,
            OxyColor stroke,
            double thickness,
            double[] dashArray,
            OxyPlot.LineJoin lineJoin,
            bool aliased)
        {
            if (points.Count < 2)
            {
                return;
            }

            this.g.SmoothingMode = aliased ? SmoothingMode.None : SmoothingMode.HighQuality;

            var pts = this.ToPoints(points);
            if (fill.IsVisible())
            {
                this.g.FillPolygon(fill.ToBrush(), pts);
            }

            if (stroke.IsInvisible() || thickness <= 0)
            {
                return;
            }

            using (var pen = this.CreatePen(stroke, thickness))
            {
                if (dashArray != null)
                {
                    pen.DashPattern = this.ToFloatArray(dashArray);
                }

                switch (lineJoin)
                {
                    case OxyPlot.LineJoin.Round:
                        pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
                        break;
                    case OxyPlot.LineJoin.Bevel:
                        pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel;
                        break;

                    // The default LineJoin is Miter
                }

                this.g.DrawPolygon(pen, pts);
            }
        }
Esempio n. 25
0
 private void CutInsidePolygon(OxyPlot.Series.LineSeries lineSeries, OxyMouseDownEventArgs e)
 {
     DataPoint clickPoint = lineSeries.InverseTransform(e.Position);
     CuttingInsidePolygon.Instance.StartCutting(clickPoint);
     plotModel.InvalidatePlot(false);
 }
        /// <summary>
        /// Gets a cached pen.
        /// </summary>
        /// <param name="stroke">The stroke.</param>
        /// <param name="thickness">The thickness.</param>
        /// <param name="dashArray">The dash array.</param>
        /// <param name="lineJoin">The line join.</param>
        /// <returns>A <see cref="Pen" />.</returns>
        private Pen CreatePen(OxyColor stroke, double thickness, double[] dashArray = null, OxyPlot.LineJoin lineJoin = OxyPlot.LineJoin.Miter)
        {
            var pen = new Pen(stroke.ToColor(), (float)thickness);
            if (dashArray != null)
            {
                pen.DashPattern = this.ToFloatArray(dashArray);
            }

            switch (lineJoin)
            {
                case OxyPlot.LineJoin.Round:
                    pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
                    break;
                case OxyPlot.LineJoin.Bevel:
                    pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel;
                    break;
                //// The default LineJoin is Miter
            }

            return pen;
        }
Esempio n. 27
0
 /// <summary>
 /// The synchronize properties.
 /// </summary>
 /// <param name="series">
 /// The series.
 /// </param>
 protected override void SynchronizeProperties(OxyPlot.Series.Series series)
 {
     base.SynchronizeProperties(series);
     var s = series as OxyPlot.Series.ScatterSeries;
     if (s != null)
     {
         s.MarkerFill = this.MarkerFill.ToOxyColor();
         s.MarkerStroke = this.MarkerStroke.ToOxyColor();
         s.MarkerStrokeThickness = this.MarkerStrokeThickness;
         s.MarkerType = this.MarkerType;
         s.MarkerSize = this.MarkerSize;
         s.DataFieldX = this.DataFieldX;
         s.DataFieldY = this.DataFieldY;
         s.DataFieldSize = this.DataFieldSize;
         s.DataFieldValue = this.DataFieldValue;
         s.DataFieldTag = this.DataFieldTag;
         s.ItemsSource = this.ItemsSource;
         s.BinSize = this.BinSize;
         s.Mapping = this.Mapping;
         s.MarkerOutline = this.MarkerOutline;
         s.ColorAxisKey = this.ColorAxisKey;
     }
 }
Esempio n. 28
0
File: Model.cs Progetto: edems/Burn
        void plotModel_MouseDown(object sender, OxyPlot.OxyMouseEventArgs e)
        {
            if (addPointbool == false && removePointbool == false)
            {
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    Series series = PlotModel.GetSeriesFromPoint(e.Position, 10);
                    if (series != null)
                    {
                        OxyPlot.TrackerHitResult result = series.GetNearestPoint(e.Position, true);
                        if (result != null && result.DataPoint != null)
                        {
                            // data point nearest to the click
                            indexOfPointToMove = (int)Math.Round(result.Index);
                            kurbelwelle.LineStyle = LineStyle.DashDot;
                        }
                    }
                }

            }
            else if( addPointbool == true)
            {
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                        kurbelwelle.Points.Add(Axis.InverseTransform(e.Position, linearAxisX, linearAxisY));
                        if (kurbelwelle.Points.Count != 1)
                        {
                            if(kurbelwelle.Points[kurbelwelle.Points.Count-1].X < kurbelwelle.Points[kurbelwelle.Points.Count-2].X)
                            {
                                kurbelwelle.Points[kurbelwelle.Points.Count - 1].X = kurbelwelle.Points[kurbelwelle.Points.Count - 2].X + 1;
                            }
                        }
                }
                PlotModel.RefreshPlot(true);
            }
            else if (removePointbool == true)
            {
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    Series series = PlotModel.GetSeriesFromPoint(e.Position, 10);
                    if (series != null)
                    {
                        OxyPlot.TrackerHitResult result = series.GetNearestPoint(e.Position, true);
                        if (result != null && result.DataPoint != null)
                        {
                            // data point nearest to the click
                            indexOfPointToMove = (int)Math.Round(result.Index);
                            kurbelwelle.Points.RemoveAt(indexOfPointToMove);
                            PlotModel.RefreshPlot(true);

                        }
                    }
                }
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Format axis tick labels so that there is a leading zero on the tick
        /// labels when necessary.
        /// </summary>
        /// <param name="axis">The axis to format</param>
        private void FormatAxisTickLabels(OxyPlot.Axes.Axis axis)
        {
            axis.IntervalLength = 100;

            if (axis is DateTimeAxis)
            {
                DateTimeAxis dateAxis = axis as DateTimeAxis;

                int numDays = (largestDate - smallestDate).Days;
                if (numDays < 100)
                    dateAxis.IntervalType = DateTimeIntervalType.Days;
                else if (numDays <= 366)
                {
                    dateAxis.IntervalType = DateTimeIntervalType.Months;
                    dateAxis.StringFormat = "dd-MMM";
                }
                else
                    dateAxis.IntervalType = DateTimeIntervalType.Years;
            }

            if (axis is LinearAxis &&
                (axis.ActualStringFormat == null || !axis.ActualStringFormat.Contains("yyyy")))
            {
                // We want the axis labels to always have a leading 0 when displaying decimal places.
                // e.g. we want 0.5 rather than .5

                // Use the current culture to format the string.
                string st = axis.ActualMajorStep.ToString(System.Globalization.CultureInfo.InvariantCulture);

                // count the number of decimal places in the above string.
                int pos = st.IndexOfAny(".,".ToCharArray());
                if (pos != -1)
                {
                    int numDecimalPlaces = st.Length - pos - 1;
                    axis.StringFormat = "F" + numDecimalPlaces.ToString();
                }
            }
        }
Esempio n. 30
0
 /// <summary>
 /// The synchronize properties.
 /// </summary>
 /// <param name="series">
 /// The series.
 /// </param>
 protected override void SynchronizeProperties(OxyPlot.Series.Series series)
 {
     base.SynchronizeProperties(series);
     var s = series as OxyPlot.Series.AreaSeries;
     s.DataFieldX2 = this.DataFieldX2;
     s.DataFieldY2 = this.DataFieldY2;
     s.ConstantY2 = this.ConstantY2;
     s.Fill = this.Fill.ToOxyColor();
     s.Reverse2 = this.Reverse2;
 }