Fixed division by zero.

This commit is contained in:
Madeorsk 2018-08-26 12:06:30 +02:00
parent 67efb77b0d
commit 1caad26fb9
2 changed files with 2 additions and 2 deletions

View File

@ -12,7 +12,7 @@ foreach ($poll->options as $option)
<tr>
<td class="number"><?= $option->votes ?></td>
<td style="color: <?= $chart_colors[$index%$chart_colors_number] ?>"><?= $option->label ?></td>
<td><?= round($option->votes / $total_votes, 3)*100 ?>%</td>
<td><?= $total_votes == 0 ? 0 : round($option->votes / $total_votes, 3)*100 ?>%</td>
</tr>
<?php endforeach; ?>
</table>

View File

@ -9,7 +9,7 @@ foreach ($poll->options as $option)
$options_percentages = [];
foreach ($poll->options as $option)
$options_percentages[] = $option->votes / $total_votes;
$options_percentages[] = ($total_votes == 0) ? 0 : $option->votes / $total_votes;
function percentage_pos_x($r, $percentage)
{ return round($r * sin(2 * M_PI * $percentage), 2); }