Skip to content

Commit

Permalink
#5427 - Preview tooltip for mixture ambiguous monomer shows wrong per…
Browse files Browse the repository at this point in the history
…centages
  • Loading branch information
rrodionov91 committed Sep 9, 2024
1 parent 2b64668 commit 89633d0
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ const UnstyledAmbiguousMonomerPreview = ({ className, preview }: Props) => {
return b.ratio - a.ratio;
}
});
if (!isAlternatives) {
const overallRatio = sortedData.reduce(
(acc, item) => acc + (item.ratio || 1),
0,
);

sortedData.forEach((entry) => {
entry.ratio = Math.round(((entry.ratio || 1) / overallRatio) * 100);
});
}

return sortedData.slice(0, 5);
}, [previewData, isAlternatives]);
Expand Down

0 comments on commit 89633d0

Please sign in to comment.