Skip to content

Commit

Permalink
Downloads chart: Avoid division by zero in percentage mode in the cas…
Browse files Browse the repository at this point in the history
…e of zero total downloads
  • Loading branch information
szakarias committed Feb 26, 2025
1 parent 487cf60 commit 26fcfe0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/web_app/lib/src/widget/downloads_chart/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ void drawChart(
final List<(double, double)> lineCoordinates = <(double, double)>[];
for (int week = 0; week < values.length; week++) {
final value = displayMode == DisplayMode.percentage
? values[week][versionRange] * 100 / totals[week]
? (totals[week] == 0
? 0 //Avoid division by zero, and return zero
: values[week][versionRange] * 100 / totals[week])
: values[week][versionRange];

if (displayMode == DisplayMode.unstacked) {
Expand Down

0 comments on commit 26fcfe0

Please sign in to comment.