Code Monkey home page Code Monkey logo

Comments (5)

dosubot avatar dosubot commented on June 27, 2024 2

To change the number format to European in Apache Superset, modifying the superset_config.py file alone might not be sufficient. Instead, you should update the D3FormatConfig.ts file in the frontend code. Here’s how you can do it:

  1. Locate the D3FormatConfig.ts file in the frontend codebase:

    superset-frontend/packages/superset-ui-core/src/number-format/D3FormatConfig.ts
    
  2. Update the DEFAULT_D3_FORMAT parameter to use a European format locale definition. Here’s an example:

    import { FormatLocaleDefinition } from 'd3-format';
    
    export const DEFAULT_D3_FORMAT: FormatLocaleDefinition = {
      decimal: ',',
      thousands: '.',
      grouping: [3],
      currency: ['€', ''],
    };

This change will ensure that the number format is applied globally across your Superset instance [1].

Additionally, ensure that there are no overriding configurations in other files such as superset_config_docker.py or any other local configuration files that might affect the D3_FORMATS settings [2][3][4].

To continue talking to Dosu, mention @dosu.

from superset.

dosubot avatar dosubot commented on June 27, 2024 2

To ensure that your changes to D3FormatConfig.ts and config.py are applied correctly, follow these steps:

  1. Recompile the Frontend Code:
    After modifying D3FormatConfig.ts, you need to recompile the frontend assets. You can do this using Docker commands provided in the Superset repository:

    docker-compose up

    Alternatively, you can use the js_build.sh script located in the superset-frontend directory to rebuild the frontend assets:

    cd superset-frontend
    ./js_build.sh
  2. Ensure Configuration is Loaded:
    Make sure that your custom superset_config.py is recognized by setting the SUPERSET_CONFIG_PATH environment variable to the full path of your superset_config.py file. For example:

    export SUPERSET_CONFIG_PATH=/app/superset_config.py

    If you are using Docker, you can add your overrides as shown below:

    COPY --chown=superset superset_config.py /app/
    ENV SUPERSET_CONFIG_PATH /app/superset_config.py
  3. Restart Services in Correct Order:
    Restart the services in the following order to ensure that the configuration changes are applied correctly:

    docker-compose restart redis db superset superset-init superset-worker superset-worker-beat
  4. Clear Cache:
    Clear the cache to ensure that the new configuration is applied. You can do this by adding the following lines to your superset_config.py:

    from superset.utils.cache_manager import cache_manager
    
    cache_manager.cache.clear()
    cache_manager.data_cache.clear()
    cache_manager.thumbnail_cache.clear()
    cache_manager.filter_state_cache.clear()
    cache_manager.explore_form_data_cache.clear()

    Alternatively, you can clear the cache manually using the following methods:

    cache_manager.cache.clear()
    cache_manager.data_cache.clear()
    cache_manager.thumbnail_cache.clear()
    cache_manager.filter_state_cache.clear()
    cache_manager.explore_form_data_cache.clear()

By following these steps, you should be able to apply the changes to the number format configuration successfully [1][2][3][4].

To continue talking to Dosu, mention @dosu.

from superset.

rusackas avatar rusackas commented on June 27, 2024

D3_FORMATS isn't a thing, as far as I know. There is D3_FORMAT in config.py, but that takes the parameters for a single format, not an array or object of various formats like you seem to be using.

from superset.

fabgat avatar fabgat commented on June 27, 2024

Hi,
I've modified the D3FormatConfig.ts file, as per follow:
import { FormatLocaleDefinition } from 'd3-format';

export const DEFAULT_D3_FORMAT: FormatLocaleDefinition = {
decimal: ',',
thousands: '.',
grouping: [3],
currency: ['€', ''],
};

I've modified also the config.py:

class D3Format(TypedDict, total=False):
decimal: str
thousands: str
grouping: list[int]
currency: list[str]

#D3_FORMAT: D3Format = {}

D3_FORMAT: D3Format = {
"decimal": ",",
"thousands": ".",
"grouping": [3],
"currency": ["€", ""]
}

no changes into: superset_config.py

After those activities I've restarted the docker, but everything is the same, no changes.

Where I'm wrong?

Regards

from superset.

rusackas avatar rusackas commented on June 27, 2024

@dosu-bot

from superset.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.