Fix poll percentages when 0 votes

Fixes #177
This commit is contained in:
Zed 2020-06-04 22:56:14 +02:00
parent 42421e58de
commit 240a6f9fd3
1 changed files with 2 additions and 1 deletions

View File

@ -120,7 +120,8 @@ proc renderPoll(poll: Poll): VNode =
for i in 0 ..< poll.options.len:
let
leader = if poll.leader == i: " leader" else: ""
perc = poll.values[i] / poll.votes * 100
val = poll.values[i]
perc = if val > 0: val / poll.votes * 100 else: 0
percStr = (&"{perc:>3.0f}").strip(chars={'.'}) & '%'
tdiv(class=("poll-meter" & leader)):
span(class="poll-choice-bar", style={width: percStr})