Skip to content

Commit

Permalink
Merge pull request #426 from imaNNeoFighT/hotfix/bar-chart-draw-min-y
Browse files Browse the repository at this point in the history
Fixed drawing BarChart rods with providing minY (for positive), maxY …
  • Loading branch information
imaNNeo authored Aug 29, 2020
2 parents 4afcdf2 + 4dc132e commit bbc2154
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## new version
* [Bugfix] Fixed drawing BarChart rods with providing minY (for positive), maxY (for negative) values bug, #404.

## 0.11.0
* [Bugfix] Prevent show ScatterSpot if show is false, #385.
* [Improvement] Set default centerSpaceRadius to double.infinity in [PieChartData](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/pie_chart.md#piechartdata), #384.
Expand Down
8 changes: 4 additions & 4 deletions lib/src/chart/bar_chart/bar_chart_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class BarChartPainter extends AxisChartPainter<BarChartData> with TouchHandler<B
if (barRod.backDrawRodData.show && barRod.backDrawRodData.y != 0) {
if (barRod.backDrawRodData.y > 0) {
// positive
final bottom = getPixelY(0, drawSize);
final bottom = getPixelY(max(data.minY, 0), drawSize);
final top = min(getPixelY(barRod.backDrawRodData.y, drawSize), bottom - cornerHeight);

barRRect = RRect.fromLTRBAndCorners(left, top, right, bottom,
Expand All @@ -216,7 +216,7 @@ class BarChartPainter extends AxisChartPainter<BarChartData> with TouchHandler<B
bottomRight: borderRadius.bottomRight);
} else {
// negative
final top = getPixelY(0, drawSize);
final top = getPixelY(min(data.maxY, 0), drawSize);
final bottom = max(getPixelY(barRod.backDrawRodData.y, drawSize), top + cornerHeight);

barRRect = RRect.fromLTRBAndCorners(left, top, right, bottom,
Expand All @@ -234,7 +234,7 @@ class BarChartPainter extends AxisChartPainter<BarChartData> with TouchHandler<B
if (barRod.y != 0) {
if (barRod.y > 0) {
// positive
final bottom = getPixelY(0, drawSize);
final bottom = getPixelY(max(data.minY, 0), drawSize);
final top = min(getPixelY(barRod.y, drawSize), bottom - cornerHeight);

barRRect = RRect.fromLTRBAndCorners(left, top, right, bottom,
Expand All @@ -244,7 +244,7 @@ class BarChartPainter extends AxisChartPainter<BarChartData> with TouchHandler<B
bottomRight: borderRadius.bottomRight);
} else {
// negative
final top = getPixelY(0, drawSize);
final top = getPixelY(min(data.maxY, 0), drawSize);
final bottom = max(getPixelY(barRod.y, drawSize), top + cornerHeight);

barRRect = RRect.fromLTRBAndCorners(left, top, right, bottom,
Expand Down

0 comments on commit bbc2154

Please sign in to comment.