getBarBounds method
Bounding box in pixels of the horizontal bar drawn for e: from 0 to its y value along the width and half
a bar width either side of its x value along the height. It is written into outputRect when one is given,
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
@override
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 top = x - barWidth / 2;
final bottom = x + barWidth / 2;
final left = y >= 0 ? y : 0.0;
final right = y <= 0 ? y : 0.0;
bounds.set(left, top, right, bottom);
getTransformer(set.axisDependency).rectValueToPixel(bounds);
return bounds;
}