Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Currency format is incorrect #83

Open
mtshane opened this issue Jul 25, 2021 · 0 comments
Open

Currency format is incorrect #83

mtshane opened this issue Jul 25, 2021 · 0 comments
Assignees

Comments

@mtshane
Copy link

mtshane commented Jul 25, 2021

minValue || minValue === 0 ? minValueDisplay = '$' + minValue.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') : ''

Current output

3.625485748.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
"3.625,485,748"

desired change

  • add currencyCode optional prop, default to 'USD'
  • add isoCode optional prop. default to 'en-US'
new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(3.625485748);
"$3.63"

code change:

case '$':
  // format range labels as $ currency
  const currencyFormatter = new Intl.NumberFormat(this.isoCode, { style: 'currency', currency: this.currencyCode });
  minValue || minValue === 0 ? minValueDisplay = currencyFormatter.format(minValue) : '';
  maxValue ? maxValueDisplay = currencyFormatter.format(maxValue) : '';
  break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants