Skip to content

Commit

Permalink
use .toLocaleString() to return number with max and min signigicant d…
Browse files Browse the repository at this point in the history
…igits
  • Loading branch information
leexgh committed Jan 16, 2020
1 parent 69b8988 commit bcee2ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,14 @@ export default class GnomadFrequency extends React.Component<GnomadFrequencyProp
display = <span>0</span>;
} else {
// show frequency as number with 4 significant digits
var significantDigitsFormatter = new Intl.NumberFormat("en", {
minimumSignificantDigits: 1,
maximumSignificantDigits:4
});
display = <span>{significantDigitsFormatter.format(result['Total'].alleleFrequency)}</span>;
display = (
<span>
{result['Total'].alleleFrequency.toLocaleString(undefined, {
maximumSignificantDigits: 4,
minimumSignificantDigits: 1,
})}
</span>
);
}

overlay = () => <GnomadFrequencyTable data={sorted} gnomadUrl={gnomadUrl} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {GnomadSummary} from "../../model/GnomadSummary";
import ColumnHeader from "../column/ColumnHeader";

import "./gnomadFrequencyTable.scss";
import { significantDigits } from "../../util/FormatUtils";

export interface IGnomadFrequencyTableProps
{
Expand All @@ -21,7 +20,14 @@ export function frequencyOutput(frequency: number) {
}
else {
// show frequency as number with 4 significant digits
return <span>{significantDigits(frequency, 4)}</span>;
return (
<span>
{frequency.toLocaleString(undefined, {
maximumSignificantDigits: 4,
minimumSignificantDigits: 1,
})}
</span>
);
}
}

Expand Down

0 comments on commit bcee2ee

Please sign in to comment.