+ let choiceA = decision.choiceA;
+ let choiceB = decision.choiceB;
+ const maxChoiceLetters = Math.max(choiceA.length, choiceB.length);
+
+ let fullText = null;
+ if (maxChoiceLetters > 20) {
+ fullText = (
+ );
+ choiceA = choiceA.slice(0, 20) + "...";
+ choiceB = choiceB.slice(0, 20) + "...";
+ }
+
+ return (
+
@@ -190,15 +234,22 @@ class Options extends React.Component {
return {
choice: choice,
count: 0,
+ relativeCount: 0,
};
});
+ let totalCount = 0;
for (const i of this.state.decisionsMade) {
if (i !== -1) {
choices[i].count += 1;
+ totalCount += 1;
}
}
+ for (let c of choices) {
+ c.relativeCount = (c.count / totalCount) * 100;
+ }
+
choices.sort((a, b) => b.count - a.count);
let choicesToRender = choices.map((choice, index) => {
@@ -206,21 +257,45 @@ class Options extends React.Component {
-
{decision.choiceA}
+{choiceA}
-
{decision.choiceB}
+{choiceB}
+ {fullText}
+
);
}
@@ -146,9 +189,10 @@ class Options extends React.Component {
+
+
-
-
-
+
Choice | -Count | -
---|
+
);
}
+
+
+
+
+
+
+
+
Choice | +Count | ++ |
---|