Skip to content

Commit

Permalink
Fix pieChart drawing single section on iPhone, #1515
Browse files Browse the repository at this point in the history
  • Loading branch information
imaNNeo committed Dec 15, 2023
1 parent e9ab493 commit c5b3bf2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ScatterSpot(
),
```
* **BUGFIX** (by @imaNNeo) Fix barChart tooltip for values below or above the 0 point, #1462
* **BUGFIX** (by @imaNNeo) Fix pieChart drawing single section on iPhone, #1515

## 0.65.0
* **FEATURE** (by @Dartek12) Added gradient to [FlLine](https://github.com/imaNNeo/fl_chart/blob/master/repo_files/documentations/base_chart.md#FlLine), #1197
Expand Down
27 changes: 21 additions & 6 deletions lib/src/chart/pie_chart/pie_chart_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ class PieChartPainter extends BaseChartPainter<PieChartData> {
PieChartPainter() : super() {
_sectionPaint = Paint()..style = PaintingStyle.stroke;

_sectionSaveLayerPaint = Paint();

_sectionStrokePaint = Paint()..style = PaintingStyle.stroke;

_centerSpacePaint = Paint()..style = PaintingStyle.fill;
}

late Paint _sectionPaint;
late Paint _sectionSaveLayerPaint;
late Paint _sectionStrokePaint;
late Paint _centerSpacePaint;

Expand Down Expand Up @@ -100,13 +104,24 @@ class PieChartPainter extends BaseChartPainter<PieChartData> {
if (sectionDegree == 360) {
_sectionPaint
..color = section.color
..strokeWidth = section.radius
..style = PaintingStyle.stroke;
canvasWrapper.drawCircle(
center,
centerRadius + section.radius / 2,
_sectionPaint,
..style = PaintingStyle.fill;
final bounds = Rect.fromCircle(
center: center,
radius: centerRadius + section.radius,
);
canvasWrapper
..saveLayer(bounds, _sectionSaveLayerPaint)
..drawCircle(
center,
centerRadius + section.radius,
_sectionPaint..blendMode = BlendMode.srcOver,
)
..drawCircle(
center,
centerRadius,
_sectionPaint..blendMode = BlendMode.srcOut,
)
..restore();
if (section.borderSide.width != 0.0 &&
section.borderSide.color.opacity != 0.0) {
_sectionStrokePaint
Expand Down

0 comments on commit c5b3bf2

Please sign in to comment.