getBarBounds method
Bounding box in pixels of the bar drawn for e. It is written into outputRect when one is given, which
avoids the allocation in hot code, and returned.
Returns the bounds, or a rectangle with Float.MIN_VALUE (Utils.FLOAT_EPSILON) on all sides when the
entry is not in the data.
Implementation
MutableRect getBarBounds(BarEntry e, [MutableRect? outputRect]) {
final bounds = outputRect ?? MutableRect();
final data = this.data;
final set = data?.getDataSetForEntry(e);
if (data == null || set == null) {
bounds.set(
Utils.FLOAT_EPSILON,
Utils.FLOAT_EPSILON,
Utils.FLOAT_EPSILON,
Utils.FLOAT_EPSILON,
);
return bounds;
}
final y = e.y;
final x = e.x;
final barWidth = data.barWidth;
final left = x - barWidth / 2;
final right = x + barWidth / 2;
final top = y >= 0 ? y : 0.0;
final bottom = y <= 0 ? y : 0.0;
bounds.set(left, top, right, bottom);
getTransformer(set.axisDependency).rectValueToPixel(bounds);
return bounds;
}