Skip to content

Commit

Permalink
Fix Negative BarChartRodStackItem are not drawn correctly bug, imaNNe…
Browse files Browse the repository at this point in the history
  • Loading branch information
imaNNeo authored and OlehSv committed May 14, 2024
1 parent f1e2b36 commit 3e83357
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## nextVersion
* **BUGFIX** (by @Anas35) Fix Tooltip not displaying when value from BackgroundBarChartRodData is less than zero. #1345.
* **BUGFIX** (by @imaNNeo) Fix Negative BarChartRodStackItem are not drawn correctly bug, #1347

## 0.63.0
* **BUGFIX** (by @imaNNeo) Fix PieChart crash on web-renderer html by ignoring `sectionsSpace` when `Path.combine()` does not work (it's flutter engine [issue](https://github.com/flutter/flutter/issues/44572)), #955
Expand Down
6 changes: 5 additions & 1 deletion lib/src/chart/bar_chart/bar_chart_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,14 @@ class BarChartPainter extends AxisChartPainter<BarChartData> {
final stackFromY = getPixelY(stackItem.fromY, viewSize, holder);
final stackToY = getPixelY(stackItem.toY, viewSize, holder);

final isNegative = stackItem.toY < stackItem.fromY;
_barPaint.color = stackItem.color;
final rect = isNegative
? Rect.fromLTRB(left, stackFromY, right, stackToY)
: Rect.fromLTRB(left, stackToY, right, stackFromY);
canvasWrapper
..save()
..clipRect(Rect.fromLTRB(left, stackToY, right, stackFromY))
..clipRect(rect)
..drawRRect(barRRect, _barPaint)
..restore();

Expand Down

0 comments on commit 3e83357

Please sign in to comment.