FIX: closed polls with no votes showed NaN as percentage and average

This commit is contained in:
Gerhard Schlager
2015-05-02 01:58:23 +02:00
parent 2ead293098
commit c9e4fd578d
2 changed files with 3 additions and 2 deletions

View File

@ -7,7 +7,7 @@ export default Em.Component.extend({
backgroundColor = this.get("poll.background");
this.get("poll.options").forEach(option => {
const percentage = Math.floor(100 * option.get("votes") / totalVotes),
const percentage = totalVotes == 0 ? 0 : Math.floor(100 * option.get("votes") / totalVotes),
styles = ["width: " + percentage + "%"];
if (backgroundColor) { styles.push("background: " + backgroundColor); }