Skip to content

Commit

Permalink
Fix section with zero value problem in PieChart (disabled animation o…
Browse files Browse the repository at this point in the history
…n changing value to zero and from zero), #817
  • Loading branch information
imaNNeo committed Dec 3, 2021
1 parent c6e3951 commit be045fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/src/chart/pie_chart/pie_chart_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class PieChartData extends BaseChartData with EquatableMixin {
double? startDegreeOffset,
PieTouchData? pieTouchData,
FlBorderData? borderData,
}) : sections = sections ?? const [],
}) : sections = sections?.where((element) => element.value != 0).toList() ??
const [],
centerSpaceRadius = centerSpaceRadius ?? double.infinity,
centerSpaceColor = centerSpaceColor ?? Colors.transparent,
sectionsSpace = sectionsSpace ?? 2,
Expand Down
6 changes: 0 additions & 6 deletions lib/src/chart/pie_chart/pie_chart_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ class PieChartPainter extends BaseChartPainter<PieChartData> {

for (var i = 0; i < data.sections.length; i++) {
final section = data.sections[i];
if (section.value == 0) {
continue;
}
final sectionDegree = sectionsAngle[i];

final sectionRadiusRect = Rect.fromCircle(
Expand Down Expand Up @@ -248,9 +245,6 @@ class PieChartPainter extends BaseChartPainter<PieChartData> {

for (var i = 0; i < data.sections.length; i++) {
final section = data.sections[i];
if (section.value == 0) {
continue;
}
final startAngle = tempAngle;
final sweepAngle = 360 * (section.value / data.sumValue);
final sectionCenterAngle = startAngle + (sweepAngle / 2);
Expand Down

0 comments on commit be045fb

Please sign in to comment.