getBarBounds method

Rect getBarBounds(
  1. BarEntry e
)

The passed outputRect will be assigned the values of the bounding box of the specified Entry in the specified DataSet. The rect will be assigned Float.MIN_VALUE in all locations if the Entry could not be found in the charts data.

@param e @return

Implementation

Rect getBarBounds(BarEntry e) {
  Rect bounds = Rect.zero;

  IBarDataSet? set = getBarData()!.getDataSetForEntry(e);

  if (set == null) {
    bounds = const Rect.fromLTRB(double.minPositive, double.minPositive,
        double.minPositive, double.minPositive);
    return bounds;
  }

  double y = e.y;
  double x = e.x;

  double barWidth = getBarData()!.barWidth;

  double left = x - barWidth / 2.0;
  double right = x + barWidth / 2.0;
  double top = y >= 0 ? y : 0;
  double bottom = y <= 0 ? y : 0;

  bounds = Rect.fromLTRB(left, top, right, bottom);

  return getTransformer(set.getAxisDependency())!.rectValueToPixel(bounds);
}