flutter_heatmap_calendar icon indicating copy to clipboard operation
flutter_heatmap_calendar copied to clipboard

Heatmap gives error if all datapoints are 0

Open AkhileshManda opened this issue 3 years ago • 3 comments

image

AkhileshManda avatar Oct 25 '22 09:10 AkhileshManda

Does this issue persist or was this patched?

eterniter06 avatar Sep 06 '23 15:09 eterniter06

still an issue for me

johnshiver avatar Dec 17 '23 04:12 johnshiver

this is how I get around it

        // BUG: avoiding all 0 bug in flutter heatmap
        // https://github.com/devappmin/flutter_heatmap_calendar/issues/11
        bool allZero = records.values.every((value) => value == 0);
        Color color;
        if (allZero) {
          //  change all values to 1, because all zeros breaks
          //  we'll set color to white so it looks empty
          color = Colors.white;
          records = records.map((key, value) => MapEntry(key, 1));
        } else {
          // Otherwise, set the color to red
          color = Colors.red;
        }

johnshiver avatar Dec 18 '23 00:12 johnshiver