[frontend/components] Fix vote percentage calculations

This commit is contained in:
pancakes 2024-12-31 00:31:40 +10:00 committed by Lilian
parent e091eb01e9
commit 9dd04f3035
No known key found for this signature in database

View file

@ -34,11 +34,11 @@
@{ var total = Poll.Choices.Sum(p => p.Votes); }
@foreach (var choice in Poll.Choices)
{
<span class="poll-result @(choice.Voted ? "voted" : "")" style="--percentage: @(choice.Votes / total * 100)%;">
<span class="poll-result @(choice.Voted ? "voted" : "")" style="--percentage: @(choice.Votes / (double)total * 100)%;">
<span class="poll-value">
<MfmText Text="@choice.Value" Emoji="@Emoji" Simple="true"/>
</span>
<span class="poll-info"><span class="vote-count">@Loc["{0} votes", choice.Votes]</span><span class="vote-percentage">@(choice.Votes / total * 100)%</span></span>
<span class="poll-info"><span class="vote-count">@Loc["{0} votes", choice.Votes]</span><span class="vote-percentage">@(choice.Votes / (double)total * 100)%</span></span>
</span>
}
</div>