fix: inverted binary forecasts, fixes #76

This commit is contained in:
Vyacheslav Matyukhin 2022-04-29 00:17:46 +04:00
parent 6aef1bc437
commit 42f3160abe
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C

View File

@ -113,29 +113,30 @@ export const QuestionOptions: React.FC<{ options: Option[] }> = ({
options.length === 2 &&
(options[0].name === "Yes" || options[0].name === "No");
const optionsSorted = options.sort((a, b) => b.probability - a.probability);
const optionsMax5 = !!optionsSorted.slice ? optionsSorted.slice(0, 5) : []; // display max 5 options.
if (isBinary) {
const yesOption = options.find((o) => o.name === "Yes");
return (
<div className="space-x-2">
<span
className={`${primaryForecastColor(
options[0].probability
yesOption.probability
)} text-white w-16 rounded-md px-1.5 py-0.5 font-bold`}
>
{formatProbability(options[0].probability)}
{formatProbability(yesOption.probability)}
</span>
<span
className={`${textColor(
options[0].probability
yesOption.probability
)} text-gray-500 inline-block`}
>
{primaryEstimateAsText(options[0].probability)}
{primaryEstimateAsText(yesOption.probability)}
</span>
</div>
);
} else {
const optionsSorted = options.sort((a, b) => b.probability - a.probability);
const optionsMax5 = !!optionsSorted.slice ? optionsSorted.slice(0, 5) : []; // display max 5 options.
return (
<div className="space-y-2">
{optionsMax5.map((option, i) => (