showByPixel method

void showByPixel(
  1. double x,
  2. double y
)

Displays the tooltip at the specified x and y-positions.

  • x & y - logical pixel values to position the tooltip.

Implementation

void showByPixel(double x, double y) {
  assert(!x.isNaN);
  assert(!y.isNaN);
  final RenderBehaviorArea? parent = parentBox as RenderBehaviorArea?;
  if (parent == null) {
    return;
  }

  final Offset primaryLocalPosition = Offset(x, y);
  final Offset primaryPosition = parent.localToGlobal(primaryLocalPosition);
  RenderBox? child = parent.plotArea?.lastChild;
  while (child != null) {
    final StackParentData childParentData =
        child.parentData! as StackParentData;
    if (child is ChartSeriesRenderer) {
      final bool isHit = child.hitInsideSegment(primaryLocalPosition);
      if (isHit) {
        final TooltipInfo? info =
            child.tooltipInfo(position: primaryLocalPosition);
        if (info != null) {
          parent.raiseTooltip(info);
        }
        break;
      }
    }
    child = childParentData.previousSibling;
  }

  parent.raiseTooltip(TooltipInfo(
    primaryPosition: primaryPosition,
    secondaryPosition: primaryPosition,
  ));
}