コード例 #1
0
ファイル: Extensions.cs プロジェクト: ICU-UCI/LiveCharts2
        public static PointF?GetPieTooltipLocation(
            this IEnumerable <TooltipPoint> foundPoints, TooltipPosition position, SizeF tooltipSize)
        {
            var placementContext = new TooltipPlacementContext();
            var found            = false;

            foreach (var foundPoint in foundPoints)
            {
                if (foundPoint.Point.PointContext.HoverArea == null)
                {
                    continue;
                }
                foundPoint.Point.PointContext.HoverArea.SuggestTooltipPlacement(placementContext);
                found = true;
                break; // we only care about the first one.
            }

            return(found ? new PointF(placementContext.PieX, placementContext.PieY) : null);
        }
コード例 #2
0
ファイル: Extensions.cs プロジェクト: ICU-UCI/LiveCharts2
        /// <summary>
        /// Returns the left, top coordinate of the tooltip based on the found points, the position and the tooltip size.
        /// </summary>
        /// <param name="foundPoints"></param>
        /// <param name="position"></param>
        /// <param name="tooltipSize"></param>
        /// <returns></returns>
        public static PointF?GetCartesianTooltipLocation(
            this IEnumerable <TooltipPoint> foundPoints, TooltipPosition position, SizeF tooltipSize)
        {
            float count = 0f;

            var placementContext = new TooltipPlacementContext();

            foreach (var point in foundPoints)
            {
                if (point.Point.PointContext.HoverArea == null)
                {
                    continue;
                }
                point.Point.PointContext.HoverArea.SuggestTooltipPlacement(placementContext);
                count++;
            }

            if (count == 0)
            {
                return(null);
            }

            var avrgX = ((placementContext.MostRight + placementContext.MostLeft) / 2f) - tooltipSize.Width * 0.5f;
            var avrgY = ((placementContext.MostTop + placementContext.MostBottom) / 2f) - tooltipSize.Height * 0.5f;

            switch (position)
            {
            case TooltipPosition.Top: return(new PointF(avrgX, placementContext.MostTop - tooltipSize.Height));

            case TooltipPosition.Bottom: return(new PointF(avrgX, placementContext.MostBottom));

            case TooltipPosition.Left: return(new PointF(placementContext.MostLeft - tooltipSize.Width, avrgY));

            case TooltipPosition.Right: return(new PointF(placementContext.MostRight, avrgY));

            case TooltipPosition.Center: return(new PointF(avrgX, avrgY));

            default: throw new NotImplementedException();
            }
        }
コード例 #3
0
ファイル: HoverArea.cs プロジェクト: chinanum1/LiveCharts2
 public abstract void SuggestTooltipPlacement(TooltipPlacementContext context);