calculateTrackerBounds method

void calculateTrackerBounds(
  1. num x,
  2. num y,
  3. BorderRadius borderRadius,
  4. double trackPadding,
  5. double trackBorderWidth,
  6. CartesianSeriesRenderer series,
)
inherited

Implementation

void calculateTrackerBounds(
  num x,
  num y,
  BorderRadius borderRadius,
  double trackPadding,
  double trackBorderWidth,
  CartesianSeriesRenderer series,
) {
  final PointToPixelCallback transformX = series.pointToPixelX;
  final PointToPixelCallback transformY = series.pointToPixelY;
  final bool isTransposed = series.isTransposed;
  final bool isInversed = series.xAxis!.isInversed;
  final num minimum = series.yAxis!.visibleRange!.minimum;
  final num maximum = series.yAxis!.visibleRange!.maximum;
  final double trackerPadding = trackBorderWidth + trackPadding;

  final num trackTop = max(maximum, minimum);
  final num trackBottom = min(maximum, minimum);
  double left = transformX(x, trackTop);
  double top = transformY(x, trackTop);
  double right = transformX(y, trackBottom);
  double bottom = transformY(y, trackBottom);

  // TODO(Natrayansf): Avoid isTransposed case checking.
  // And, calculate the tracker bounds within the plot area bounds.
  if (!isTransposed) {
    if (!isInversed) {
      left -= trackerPadding;
      right += trackerPadding;
    } else {
      left += trackerPadding;
      right -= trackerPadding;
    }
  } else {
    if (!isInversed) {
      top += trackerPadding;
      bottom -= trackerPadding;
    } else {
      top -= trackerPadding;
      bottom += trackerPadding;
    }
  }

  _trackerRect = toRRect(left, top, right, bottom, borderRadius);
}