You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
within a pieChart, when using:
pieTouchData: PieTouchData(
touchCallback: (FlTouchEvent event, pieTouchResponse) {
precursorCtl.checkTouchedIndex(event, pieTouchResponse);
},
If the pie section data/value are null/don't exist, it will throw an exception complaining about bad values.
replaced existing sumValue() in pie_chart_data.dart with this (very cautious) code, and seems to now work:
double get sumValue {
// Map the values
var values = sections.map((data) => data.value).toList();
// Print out the values to help with debugging
// print("Mapped values: $values");
// Handle case when list is empty or all values are null
if (values.isEmpty || values.every((v) => v == null)) {
// print("No valid values to sum, returning 0.0");
return 0.0;
}
// Filter out any null values just in case
var nonNullValues = values.where((value) => value != null).toList();
// Print non-null values to help debugging
// print("Non-null values: $nonNullValues");
// Check again for empty list after filtering out nulls
if (nonNullValues.isEmpty) {
// print("No non-null values, returning 0.0");
return 0.0;
}
// Safely sum the values using fold instead of reduce
return nonNullValues.fold(0.0, (sum, value) => sum + value!);
}
Screenshots
If applicable, add screenshots, or videoshots to help explain your problem.
Versions
Flutter 3.19.6
flCharts version 0.67
The text was updated successfully, but these errors were encountered:
Describe the bug
within a pieChart, when using:
pieTouchData: PieTouchData(
touchCallback: (FlTouchEvent event, pieTouchResponse) {
precursorCtl.checkTouchedIndex(event, pieTouchResponse);
},
If the pie section data/value are null/don't exist, it will throw an exception complaining about bad values.
replaced existing sumValue() in pie_chart_data.dart with this (very cautious) code, and seems to now work:
double get sumValue {
// Map the values
var values = sections.map((data) => data.value).toList();
}
Screenshots
If applicable, add screenshots, or videoshots to help explain your problem.
Versions
The text was updated successfully, but these errors were encountered: