mirror of
https://git.cant.at/Madeorsk/PollVerlaine
synced 2024-11-21 20:54:31 +01:00
Fixed division by zero.
This commit is contained in:
parent
67efb77b0d
commit
1caad26fb9
@ -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>
|
||||
|
@ -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); }
|
||||
|
Loading…
Reference in New Issue
Block a user