Skip to content

Commit 26fcfe0

Browse files
committed
Downloads chart: Avoid division by zero in percentage mode in the case of zero total downloads
1 parent 487cf60 commit 26fcfe0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ void drawChart(
355355
final List<(double, double)> lineCoordinates = <(double, double)>[];
356356
for (int week = 0; week < values.length; week++) {
357357
final value = displayMode == DisplayMode.percentage
358-
? values[week][versionRange] * 100 / totals[week]
358+
? (totals[week] == 0
359+
? 0 //Avoid division by zero, and return zero
360+
: values[week][versionRange] * 100 / totals[week])
359361
: values[week][versionRange];
360362

361363
if (displayMode == DisplayMode.unstacked) {

0 commit comments

Comments
 (0)