remove trailing zeros in large numbers in UI

Added ~ option to d3Format which trims trailing zeros across format types.

Fixes #3741
This commit is contained in:
Sara Taha
2020-03-13 04:51:44 +02:00
parent 12d6ae4da0
commit 112fd5616b
2 changed files with 7 additions and 1 deletions

View File

@@ -10,6 +10,12 @@ describe('StringUtils', () => {
it('it should render 0', () => {
expect(f(0)).toBe('0.00');
});
it('it should render get rid of trailing zeros', () => {
expect(f(2104)).toBe('2.104k');
expect(f(21100)).toBe('21.1k');
expect(f(2120001)).toBe('2.12M');
});
});
describe('longestCommonPrefix', () => {

View File

@@ -5,7 +5,7 @@ import { isoFormat } from 'd3-time-format';
import LCP from 'lcp';
import moment from 'moment';
const formatLargeValue = d3Format('s');
const formatLargeValue = d3Format('~s');
function renderHtml(text, unit) {