I am suing Apache superset. I want to add custom Y Axis Axis Format in number format. I have tried DEFAULT_METRIC_FORMATS and D3_FORMATS in superset config.Custom number format is not showing in Y Axis Axis Format in number format. Here is the image:
Here is my superset_config.py:
ROW_LIMIT = 5000
ENABLE_CORS = True
CORS_OPTIONS = {
'origins': ['http://localhost:3000', 'http://mywebsite.com'],
}
# ---------------------------------------------------
# Database config
# ---------------------------------------------------
SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://superset:superset@postgres:5432/superset'
# Redis configuration for caching
CACHE_CONFIG = {
'CACHE_TYPE': 'RedisCache',
'CACHE_DEFAULT_TIMEOUT': 300,
'CACHE_KEY_PREFIX': 'superset_',
'CACHE_REDIS_URL': 'redis://redis:6379/0',
}
FEATURE_FLAGS = {
"ALERT_REPORTS": True, # Enable alerts & reports
"DASHBOARD_NATIVE_FILTERS": True, # Native filters for dashboards
"ENABLE_TEMPLATE_PROCESSING": True, # Template processing for queries
"ENABLE_D3_FORMATS": True, # Enable D3 number formatting dropdown
"UX_BETA": True, # Optional: Enable beta UI features
}
# ---------------------------------------------------
# Security / Auth configuration
# ---------------------------------------------------
SECRET_KEY = '4rA5fxt3Y58tk30FsJ2XpEbg3xD4uPuOYBo5qJ9QlU0'
AUTH_USER_REGISTRATION = True
AUTH_USER_REGISTRATION_ROLE = "Gamma" # Default role for newly registered users
# ---------------------------------------------------
# Other configs
# ---------------------------------------------------
SUPERSET_WEBSERVER_PORT = 8088
# Celery configuration for task queuing
CELERY_CONFIG = {
'broker_url': 'redis://redis:6379/0',
'result_backend': 'redis://redis:6379/0',
}
# ---------------------------------------------------
# Logging config
# ---------------------------------------------------
LOG_LEVEL = 'INFO'
# ---------------------------------------------------
# Customization for branding (optional)
# ---------------------------------------------------
APP_NAME = "My Superset"
DEFAULT_METRIC_FORMATS = {
"crore": "TK ,.2f Cr", # Format for Crores (Bangladeshi currency)
"lakh": "TK ,.2f Lakh", # Format for Lakhs (Bangladeshi currency)
"tk_crore": "TK ,.2f Cr", # Format for Crores with TK prefix
"tk_lakh": "TK ,.2f Lakh", # Format for Lakhs with TK prefix
"usd": "$,.2f", # Format for US Dollars
"euro": "€,.2f", # Format for Euros
"billion": ",.2f Billion", # Format for billions
"default": ",.2f", # Default fallback format
}
EXTRA_CATEGORICAL_COLOR_SCHEMES = [
{
"id": "world_population_reporting_colors",
"label": "World Population Reporting Colors",
"description": "Custom color scheme for world population reporting",
"colors": [
"#004369", "#65D0E4", "#50BEF3", "#65D0E4", "#7D82EA",
"#AA5ECB", "#CE42A1", "#EC487D", "#FA6E67", "#FFA064",
"#EEDD55", "#9977BB", "#BBAA44", "#DDCCDD",
]
},
{
"id": "crore_lakh_colors",
"label": "Crore and Lakh test5",
"description": "Custom colors for crore and lakh number formats",
"colors": [
"#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd",
"#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"
],
},
{
"id": "crore_city_bank_colors",
"label": "City Bank Color",
"description": "Custom colors for crore and lakh number formats",
"colors": [
"#E20001", "#28a745", "#6dbe44", "#6610f2", "#fd7e14",
"#17a2b8", "#e377c2", "#7f7f7f", "#bcbd22", "#20c997 "
],
}
]
My EXTRA_CATEGORICAL_COLOR_SCHEMES is working fine. But DEFAULT_METRIC_FORMATS is not showing in my drop-drown.
What is wrong of my code?
2
Answers
Ok I just checked how we did it and checked the Apache Superset Slack.
As far as I am aware you can only change the default locals easily in the supserset-config.py.
We did this like this:
}
I checked on the Superset Slack if you can add number formats and I could not find a way to do it in the superset_config.py. It appears that you can only do this with changes to the codebase, because the number formats are hard coded. This is an answer I found from September of this year:
I also found this. So it appears you have to do changes in the codebase.
In my case, I done this:
Just paste as indicated and it should work
Where to place your code