Skip to content

Commit ca42f46

Browse files
authored
Handle special case in sparkline chart where all values are 0 (#8287)
1 parent b8f3046 commit ca42f46

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/web_app/lib/src/widget/weekly_sparkline/widget.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ void drawChart(Element svg, HTMLDivElement toolTip, HTMLDivElement chartSubText,
5353
final firstDay = firstDate.copyWith(day: firstDate.day - 7);
5454

5555
final xAxisSpan = lastDate.difference(firstDate);
56-
final maxDownloads = data.fold<int>(0, (a, b) => max<int>(a, b.downloads));
56+
// We start with 1 as initial value. In the special case where all downloads
57+
// are 0 we want a straight line in the bottom of the chart.
58+
final maxDownloads = data.fold<int>(1, (a, b) => max<int>(a, b.downloads));
5759

5860
final toolTipOffsetFromMouse = 15;
5961

0 commit comments

Comments
 (0)