Exemple #1
0
        protected override void Render(DrawingContext dc, DataSeries series, Plot plot, Axis xAxis, Axis yAxis, IList <DataSeries> sources)
        {
            if (series == null || plot == null || plot.Points == null || xAxis == null || yAxis == null)
            {
                return;
            }

            // Curve point marker drawing.
            IPointMarker iPointMarker = series as IPointMarker;

            Debug.Assert(iPointMarker != null, "iPointMarker != null");

            var hlong = xAxis.Extent;
            var vlong = yAxis.Extent;

            var points = plot.Points;

            foreach (var pt in points)
            {
                double x, y; // coordinates in pixels
                bool   isPtInsideArea;
                try
                {
                    x = xAxis.ToPixels(pt.X);
                    y = yAxis.ToPixels(pt.Y);
                    isPtInsideArea = isInsideArea(x, y, hlong, vlong);
                }
                catch (ArgumentException)
                {
                    continue;
                }

                if (isPtInsideArea)
                {
                    Drawing pointMarker = iPointMarker.PointMarkerVisible ? iPointMarker.PointMarker : null;
                    pointMarker = pt.Emphasis ? iPointMarker.EmphasisPointMarker : pointMarker;
                    DrawPointsMarker(pointMarker, x, y);
                }
            }
        }
Exemple #2
0
        protected override void Render(DrawingContext dc, DataSeries series, Plot plot, Axis xAxis, Axis yAxis, IList <DataSeries> sources)
        {
            if (series == null || plot == null || plot.Points == null || xAxis == null || yAxis == null)
            {
                return;
            }

            // Curve point marker drawing.
            IPointMarker iPointMarker = series as IPointMarker;

            Debug.Assert(iPointMarker != null, "iPointMarker != null");

            var hlong = xAxis.Extent;
            var vlong = yAxis.Extent;

            Point?     startPoint     = null;
            IDataPoint startDataPoint = null;

            List <Point> linePoints = new List <Point>();
            var          points     = plot.Points;

            foreach (var pt in points)
            {
                double x, y; // coordinates in pixels
                bool   isPtInsideArea;
                try
                {
                    x = xAxis.ToPixels(pt.X);
                    y = yAxis.ToPixels(pt.Y);
                    isPtInsideArea = isInsideArea(x, y, hlong, vlong);
                }
                catch (ArgumentException)
                {
                    continue;
                }

                if (!startPoint.HasValue)
                {
                    startPoint     = new Point(x, y);
                    startDataPoint = pt;
                }
                else
                {
                    linePoints.Add(new Point(x, y));
                }

                if (isPtInsideArea)
                {
                    Drawing pointMarker = iPointMarker.PointMarkerVisible ? iPointMarker.PointMarker : null;
                    pointMarker = pt.Emphasis ? iPointMarker.EmphasisPointMarker : pointMarker;
                    DrawPointsMarker(pointMarker, x, y);
                }
            }

            if (!startPoint.HasValue)
            {
                return;
            }

            if (linePoints.Count == 0 && isInsideArea(startPoint.Value.X, startPoint.Value.Y, hlong, vlong))
            {
                Drawing pointMarker = iPointMarker.PointMarker;
                pointMarker = startDataPoint.Emphasis ? iPointMarker.EmphasisPointMarker : pointMarker;
                DrawPointsMarker(pointMarker, startPoint.Value.X, startPoint.Value.Y);
            }

            // Bezier points
            Point[] bezierPoints = BezierPoints(linePoints.ToArray());

            if (bezierPoints.Length == 0)
            {
                return; // Nothing to draw
            }

            var clipRect = PlotHelper.GetClipRect(plot.ClipSettings, xAxis, yAxis, hlong, vlong);
            var gCurve   = CreateCurve(startPoint.Value, linePoints);

            DrawCurve(dc, gCurve, series.Pen, clipRect);
        }
Exemple #3
0
 public SelectedSeriesStyle(PenStyle selectedStrokeStyle, IPointMarker selectedPointMarker)
 {
     _selectedStrokeStyle = selectedStrokeStyle;
     _selectedPointMarker = selectedPointMarker;
 }
        private XyScatterRenderableSeries GetScatterRenderableSeries(Context context, IPointMarker pointMarker, uint color, bool negative)
        {
            var seriesName = pointMarker is EllipsePointMarker ?
                             negative ? "Negative Ellipse" : "Positive Ellipse" :
                             negative ? "Negative" : "Positive";

            var dataSeries = new XyDataSeries <int, double> {
                SeriesName = seriesName
            };

            for (var i = 0; i < 200; i++)
            {
                var time = i < 100 ? GetRandom(_random, 0, i + 10) / 100 : GetRandom(_random, 0, 200 - i + 10) / 100;
                var y    = negative ? -time * time * time : time * time * time;

                dataSeries.Append(i, y);
            }

            pointMarker.SetSize(6.ToDip(context), 6.ToDip(context));
            pointMarker.StrokeStyle = new SolidPenStyle(Color.White, 0.1f.ToDip(context));
            pointMarker.FillStyle   = new SolidBrushStyle(color);

            return(new XyScatterRenderableSeries
            {
                DataSeries = dataSeries,
                StrokeStyle = new SolidPenStyle(color, 2f.ToDip(context)),
                PointMarker = pointMarker
            });
        }