예제 #1
0
        public static IEnumerable <Point> GetSplinePointsConnectingAbsoluteFirstLastDataPoints(IList <DataPoint> dataPoints, double scaleFactor)
        {
            DataPoint firstPoint = dataPoints[0];
            DataPoint lastPoint  = dataPoints[dataPoints.Count - 1];

            if (firstPoint.isEmpty || double.IsNaN(firstPoint.CenterX()) || double.IsNaN(firstPoint.CenterY()) ||
                lastPoint.isEmpty || double.IsNaN(lastPoint.CenterX()) || double.IsNaN(lastPoint.CenterY()))
            {
                yield break;
            }

            double tolerance = DefaultTolerance;

            if (scaleFactor > 2)
            {
                tolerance *= (int)scaleFactor / 2;
            }

            DataPoint previousSignificantPointBeforeAbsoluteLast = FindPreviousNonEmptyPointBeforeAbsoluteLast(dataPoints);
            DataPoint nextSignificantPointAfterAbsoluteFirst     = FindNextNonEmptyPointAfterAbsoluteFirst(dataPoints);

            // return the first point since spline segmentation skips it
            yield return(lastPoint.Center());

            foreach (Point point in Segment(previousSignificantPointBeforeAbsoluteLast.Center(), lastPoint.Center(), firstPoint.Center(), nextSignificantPointAfterAbsoluteFirst.Center(), tolerance))
            {
                yield return(point);
            }
        }
        protected virtual void ConnectFirstLastDataPoints()
        {
            DataPoint firstPoint = this.renderPoints[0];
            DataPoint lastPoint  = this.renderPoints[this.renderPoints.Count - 1];

            if (firstPoint.isEmpty || lastPoint.isEmpty)
            {
                return;
            }

            PathFigure figure = new PathFigure();

            figure.StartPoint = lastPoint.Center();
            PolyLineSegment lineSegment = new PolyLineSegment();

            lineSegment.Points.Add(firstPoint.Center());

            figure.Segments.Add(lineSegment);
            this.shapeGeometry.Figures.Add(figure);
        }
예제 #3
0
        internal virtual double GetDistanceToPoint(DataPoint dataPoint, Point tapLocation, ChartPointDistanceCalculationMode pointDistanceMode)
        {
            var dataPointLocation = dataPoint.Center();

            if (pointDistanceMode == ChartPointDistanceCalculationMode.TwoDimensional)
            {
                ////TODO: Math.Sqrt could lead to potential performance issues with lost of points/series.
                return(RadMath.GetPointDistance(dataPointLocation.X, tapLocation.X, dataPointLocation.Y, tapLocation.Y));
            }
            else
            {
                AxisPlotDirection plotDirection = this.Model.GetTypedValue <AxisPlotDirection>(AxisModel.PlotDirectionPropertyKey, AxisPlotDirection.Vertical);

                if (plotDirection == AxisPlotDirection.Vertical)
                {
                    return(Math.Abs(tapLocation.X - dataPointLocation.X));
                }
                else
                {
                    return(Math.Abs(tapLocation.Y - dataPointLocation.Y));
                }
            }
        }