Skip to content

Commit

Permalink
Handle special case in sparkline chart where all values are 0 (dart-l…
Browse files Browse the repository at this point in the history
  • Loading branch information
szakarias authored Nov 14, 2024
1 parent b8f3046 commit ca42f46
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/web_app/lib/src/widget/weekly_sparkline/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ void drawChart(Element svg, HTMLDivElement toolTip, HTMLDivElement chartSubText,
final firstDay = firstDate.copyWith(day: firstDate.day - 7);

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

final toolTipOffsetFromMouse = 15;

Expand Down

0 comments on commit ca42f46

Please sign in to comment.