Skip to content

Commit

Permalink
Allow to set zero value on PieChartSectionData (we remove zero sectio…
Browse files Browse the repository at this point in the history
…ns instead of crashing), imaNNeo#640.
  • Loading branch information
imaNNeo committed May 2, 2021
1 parent c6fbd1a commit 27a283f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## newVersion
* **IMPROVEMENT** Allow to set zero value on PieChartSectionData (we remove zero sections instead of crashing), #640.

## 0.36.0
* **BUGFIX** Fixed bug of lerping FlSpot.nullSpot, #487.
* **BUGFIX** Fixed showing tooltip problem when animating chart, #647.
Expand Down
14 changes: 1 addition & 13 deletions lib/src/chart/pie_chart/pie_chart_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ class PieChartData extends BaseChartData with EquatableMixin {
double? startDegreeOffset,
PieTouchData? pieTouchData,
FlBorderData? borderData,
}) : assert(
!_sectionsContainsZero(sections),
"section's value can't be zero",
),
sections = sections ?? const [],
}) : sections = sections?.where((section) => section.value != 0).toList() ?? const [],
centerSpaceRadius = centerSpaceRadius ?? double.infinity,
centerSpaceColor = centerSpaceColor ?? Colors.transparent,
sectionsSpace = sectionsSpace ?? 2,
Expand All @@ -68,14 +64,6 @@ class PieChartData extends BaseChartData with EquatableMixin {
touchData: pieTouchData ?? PieTouchData(),
);

/// Returns true if find any zero value in the list.
static bool _sectionsContainsZero(List<PieChartSectionData>? list) {
if (list == null) {
return false;
}
return list.any((element) => element.value == 0);
}

/// Copies current [PieChartData] to a new [PieChartData],
/// and replaces provided values.
PieChartData copyWith({
Expand Down

0 comments on commit 27a283f

Please sign in to comment.