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 (#5484)
  • Loading branch information
rrodionov91 authored and Guch1g0v committed Oct 17, 2024
1 parent 8639a66 commit f8ecbbd
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 f8ecbbd

Please sign in to comment.