Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { formatDefaultLocale } from 'd3-format';
const germanNumberFormat = formatDefaultLocale({
decimal: ',',
thousands: '.',
grouping: [3],
currency: ['€', '']
});
export function numberFormat(num, decimals = 0) {
if (typeof num === 'undefined') {
return '';
}
return germanNumberFormat.format(`,.${decimals}f`)(num);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.