diff --git a/packages/react-mutation-mapper/src/component/gnomad/GnomadFrequency.tsx b/packages/react-mutation-mapper/src/component/gnomad/GnomadFrequency.tsx index cf615e45fda..c0478b1d93e 100644 --- a/packages/react-mutation-mapper/src/component/gnomad/GnomadFrequency.tsx +++ b/packages/react-mutation-mapper/src/component/gnomad/GnomadFrequency.tsx @@ -13,7 +13,6 @@ import * as React from "react"; import {GnomadSummary} from "../../model/GnomadSummary"; import GnomadFrequencyTable, {GnomadTableColumnName} from "./GnomadFrequencyTable"; -import { significantDigits } from "../../util/FormatUtils"; const GNOMAD_POPULATION_NAME: {[key:string]: string} = { "African" : "afr", @@ -146,7 +145,11 @@ export default class GnomadFrequency extends React.Component0; } else { // show frequency as number with 4 significant digits - display = {significantDigits(result['Total'].alleleFrequency, 4)}; + var significantDigitsFormatter = new Intl.NumberFormat("en", { + minimumSignificantDigits: 1, + maximumSignificantDigits:4 + }); + display = {significantDigitsFormatter.format(result['Total'].alleleFrequency)}; } overlay = () => ; diff --git a/packages/react-mutation-mapper/src/util/FormatUtils.ts b/packages/react-mutation-mapper/src/util/FormatUtils.ts index bf8c6db3c7b..cba94b03312 100644 --- a/packages/react-mutation-mapper/src/util/FormatUtils.ts +++ b/packages/react-mutation-mapper/src/util/FormatUtils.ts @@ -14,17 +14,4 @@ export function formatPercentValue(rate: number, fractionDigits: number = 1) export function numberOfLeadingDecimalZeros(value: number) { return -Math.floor( (Math.log10(value) / Math.log10(10)) + 1); -} - -export function significantDigits(data: number, length: number) { - // data: the original number, length: how many significant digits in return - // refer to: https://stackoverflow.com/questions/27220908 - if (data === 0) { - return data; - } - var numDigits = Math.ceil(Math.log10(Math.abs(data))); - var rounded = - Math.round(data * Math.pow(10, length - numDigits)) * - Math.pow(10, numDigits - length); - return rounded.toFixed(Math.max(length - numDigits, 0)); } \ No newline at end of file