Incubator-superset: Issue with Currency format D3

Created on 2 Jan 2020  路  11Comments  路  Source: apache/incubator-superset

I'm trying to set up the currency format in superset charts but it is always displayed in the American format. ($ 1,234.56)

Tried the solution present in #3972 by @PeterCahn by changing the superset/assets/node_modules/d3-format/src/defaultLocale.js file to the desired one and didn't work for the currency problem.

  decimal: ",",
  thousands: ".",
  grouping: [3],
  currency: ["R$", ""],
  dateTime: "%d/%m/%Y %H:%M:%S",
  date: "%d/%m/%Y",
  time: "%H:%M:%S",
  periods: ["AM", "PM"],
  days: ["Domingo", "Segunda", "Ter莽a", "Quarta", "Quinta", "Sexta", "S谩bado"],
  shortDays: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "S谩b"],
  months: ["Janeiro", "Fevereiro", "Mar莽o", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
  shortMonths: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"]});

Expected results

Expected to see the currency as R$ 1.234,56

Actual results

$ 1,234.56

Screenshots

I highlighted the date because looks like the defaultLocale is working for date/time.
Foto

Environment

(please complete the following information):

  • superset version: 0.34.1rc1
  • python version: Python 3.6.9
  • node.js version: v10.16.3
  • npm version: 6.9.0

Checklist

Make sure these boxes are checked before submitting your issue - thank you!

  • [x] I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • [] I have reproduced the issue with at least the latest released version of superset.
  • [x] I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

I'm opening this new issue because the previus one was closed.

.pinned

All 11 comments

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

@SWoto does it work if you set the format in the chart meta? I've overcome some of the default formatting by setting it there when I want dollarized but no cents.

image

You can get there by clicking the "edit" button on the charts/list resource.

image

It "works" when I do it, just like when i change almost the same thing in the source code... The main problem is to change the decimal/thousands separator and the currency symbol to look like:

R$ 1.234,15
instead of
$ 1,234.15

We are having the same issue - getting this https://github.com/apache/incubator-superset/issues/3972#issuecomment-535037981 working in some way would be a dynamite upgrade for deploying across non-US countries.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

Holler if this is still an issue, and we can re-open it if needed.

Hi.
I have the same problem. How to fix?

@osandrolucas,
Changing d3 format made some differences, but most of the problem persisted.

I've tried some things but to no avail. The best solution at that time was use a query to change the currency to text and replace the points with commas.

Ok :(
Thanks for the support @SWoto

I have an suggestion:
concat('R$ ', format('%,.2f', value))

I recently answered a fairly similar question over on Stack Overflow, which points to some of the code that can be edited to create currency locales with custom currency symbols and separator (decimal/comma) placement/formatting.

https://stackoverflow.com/questions/63319902/customise-the-number-format-in-apache-superset/63385549#63385549

Great!

Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

XiaodiKong picture XiaodiKong  路  3Comments

ghost picture ghost  路  3Comments

deity-bram picture deity-bram  路  3Comments

fly-high-bj picture fly-high-bj  路  3Comments

eliab picture eliab  路  3Comments