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)); } } }
private static bool TryClipToContainerTop(ref RadLine line, RadRect container, double topIntersectionX, double dashPatternLength, double angle) { bool intersectsWithRect = false; if (container.X <= topIntersectionX && topIntersectionX <= container.Right) { if (line.Y1 < line.Y2 && line.Y1 < container.Y) { intersectsWithRect = true; var lengthToAdd = RadMath.GetPointDistance(topIntersectionX, line.X1, container.Y, line.Y1) % dashPatternLength; line.X1 = topIntersectionX + lengthToAdd * Math.Cos(angle); line.Y1 = container.Y - lengthToAdd * Math.Sin(angle); } else if (line.Y2 < line.Y1 && line.Y2 < container.Y) { intersectsWithRect = true; line.X2 = topIntersectionX; line.Y2 = container.Y; } } return(intersectsWithRect); }
private static bool TryClipToContainerBottom(ref RadLine line, RadRect container, double bottomIntersectionX, double dashPatternLength, double angle) { bool intersectsWithRect = false; if (container.X <= bottomIntersectionX && bottomIntersectionX <= container.Right) { if (line.Y1 < line.Y2 && line.Y2 > container.Bottom) { intersectsWithRect = true; line.X2 = bottomIntersectionX; line.Y2 = container.Bottom; } else if (line.Y2 < line.Y1 && line.Y1 > container.Bottom) { intersectsWithRect = true; var lengthToAdd = RadMath.GetPointDistance(bottomIntersectionX, line.X1, container.Bottom, line.Y1) % dashPatternLength; line.X1 = bottomIntersectionX - lengthToAdd * System.Math.Cos(angle); line.Y1 = container.Bottom + lengthToAdd * System.Math.Sin(angle); } } return(intersectsWithRect); }
private static bool TryClipToContainerLeft(ref RadLine line, RadRect container, double leftIntersectionY, double dashPatternLength, double angle) { bool intersectsWithRect = false; if (container.Y <= leftIntersectionY && leftIntersectionY <= container.Bottom) { if (line.X1 < line.X2 && line.X1 < container.X) { intersectsWithRect = true; var lengthToAdd = RadMath.GetPointDistance(container.X, line.X1, leftIntersectionY, line.Y1) % dashPatternLength; line.Y1 = leftIntersectionY + lengthToAdd * Math.Sin(angle); line.X1 = container.X - lengthToAdd * Math.Cos(angle); } else if (line.X2 < line.X1 && line.X2 < container.X) { intersectsWithRect = true; line.Y2 = leftIntersectionY; line.X2 = container.X; } } return(intersectsWithRect); }
private static bool TryClipToContainerRight(ref RadLine line, RadRect container, double rightIntersectionY, double dashPatternLength, double angle) { bool intersectsWithRect = false; if (container.Y <= rightIntersectionY && rightIntersectionY <= container.Bottom) { if (line.X1 < line.X2 && line.X2 > container.Right) { intersectsWithRect = true; line.Y2 = rightIntersectionY; line.X2 = container.Right; } else if (line.X2 < line.X1 && line.X1 > container.Right) { intersectsWithRect = true; var lengthToAdd = RadMath.GetPointDistance(container.Right, line.X1, rightIntersectionY, line.Y1) % dashPatternLength; line.Y1 = rightIntersectionY - lengthToAdd * Math.Sin(angle); line.X1 = container.Right + lengthToAdd * Math.Cos(angle); } } return(intersectsWithRect); }