You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Swapping the dataset of a chart using the numeric metric of the original dataset to another dataset that has a numeric metric of the same name fails converts the metric datatype to text and loses the custom formatting.
How to reproduce the bug
Create dataset 1 with numeric metric "Metric1", sum(some numeric column), apply D3 formatting $,.2f
Create dataset 2 with the same metric name and formatting.
Create table chart1 from dataset1 add columns and metric1
Create chart and see formatting on metric column
Save Chart
Edit Chart
Swap dataset to dataset2
Click continue on Continue on message about controls will be retained.
View "Customize" tab, metric appears to be numeric
Click "Update Chart" - metric now switches to text and formatting is lost.
Screenshots/recordings
No response
Superset version
3.1.3
Python version
3.10
Node version
I don't know
Browser
Chrome
Additional context
No response
Checklist
I have searched Superset docs and Slack and didn't find a solution to my problem.
I have searched the GitHub issue tracker and didn't find a similar bug report.
I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
The text was updated successfully, but these errors were encountered:
Hey @rad-pat! I'm here to help you with the issue you've encountered. I'm a bot that can assist you with bug resolution, answer your questions, and guide you on becoming a contributor. Let's dive into solving this together!
To resolve the issue in Superset version 3.1.3 where swapping the dataset of a chart causes a numeric metric to incorrectly convert to text and lose its custom formatting, you can leverage the SHARED_COLUMN_CONFIG_PROPS and DEFAULT_CONFIG_FORM_LAYOUT constants from the superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx file. These constants define the configurable column formatting properties and their default layouts, ensuring that numeric metrics retain their formatting.
Here is how you can ensure the correct formatter is applied:
Use the SHARED_COLUMN_CONFIG_PROPS to define your column formatting properties:
constcolumnConfigProps={
...SHARED_COLUMN_CONFIG_PROPS,// Add any additional custom properties if needed};
Apply the DEFAULT_CONFIG_FORM_LAYOUT to ensure the correct layout and formatting:
constconfigFormLayout={
...DEFAULT_CONFIG_FORM_LAYOUT,// Customize the layout if necessary};
Ensure the correct formatter is applied to your numeric metrics:
constformatNumericMetric=(metricValue)=>{constformatter=columnConfigProps.d3NumberFormat;returnformatter(metricValue);};// Example usageconstformattedValue=formatNumericMetric(yourMetricValue);
By using the SHARED_COLUMN_CONFIG_PROPS and DEFAULT_CONFIG_FORM_LAYOUT, you can ensure that numeric metrics retain their custom formatting when swapping datasets, thus resolving the issue [1][2].
Bug description
Swapping the dataset of a chart using the numeric metric of the original dataset to another dataset that has a numeric metric of the same name fails converts the metric datatype to text and loses the custom formatting.
How to reproduce the bug
Create dataset 1 with numeric metric "Metric1", sum(some numeric column), apply D3 formatting
$,.2f
Create dataset 2 with the same metric name and formatting.
Create table chart1 from dataset1 add columns and metric1
Create chart and see formatting on metric column
Save Chart
Edit Chart
Swap dataset to dataset2
Click continue on Continue on message about controls will be retained.
View "Customize" tab, metric appears to be numeric
Click "Update Chart" - metric now switches to text and formatting is lost.
Screenshots/recordings
No response
Superset version
3.1.3
Python version
3.10
Node version
I don't know
Browser
Chrome
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: