Replace all occurrences of totalVotes
This commit is contained in:
parent
86d7412f30
commit
409a367ab7
|
@ -3,11 +3,11 @@ export default Em.Component.extend({
|
||||||
classNames: ["results"],
|
classNames: ["results"],
|
||||||
|
|
||||||
options: function() {
|
options: function() {
|
||||||
const totalVotes = this.get("poll.voters"),
|
const voters = this.get("poll.voters"),
|
||||||
backgroundColor = this.get("poll.background");
|
backgroundColor = this.get("poll.background");
|
||||||
|
|
||||||
this.get("poll.options").forEach(option => {
|
this.get("poll.options").forEach(option => {
|
||||||
const percentage = totalVotes == 0 ? 0 : Math.floor(100 * option.get("votes") / totalVotes),
|
const percentage = voters === 0 ? 0 : Math.floor(100 * option.get("votes") / voters),
|
||||||
styles = ["width: " + percentage + "%"];
|
styles = ["width: " + percentage + "%"];
|
||||||
|
|
||||||
if (backgroundColor) { styles.push("background: " + backgroundColor); }
|
if (backgroundColor) { styles.push("background: " + backgroundColor); }
|
||||||
|
|
Loading…
Reference in New Issue