Configuring two metrics causes SQL statements to appear in the echart legend configuration, while configuring one metric works normally. #34689
Replies: 1 comment 4 replies
-
This happens because Superset generates legend labels for echart visualizations by combining the metric display name (which defaults to the SQL expression or aggregate function if no custom label is set) with the groupby dimension value. When you use only one metric, the legend shows just the groupby value. With multiple metrics, the legend label includes both the metric and the dimension, so if your metric doesn't have a user-friendly label, you'll see the raw SQL expression in the legend. This is expected behavior, not a bug. To get cleaner legend labels, set a custom "label" or "verbose name" for each metric in your chart configuration. Superset will use these for legend labels instead of the SQL expression or aggregate function. For some chart types (like Mixed Timeseries), there's also a "Show query identifiers" checkbox—if you turn this off, legend labels will omit SQL expressions and show only the metric display name and dimension values. See code reference, Mixed Timeseries PR. So, to get the legend labels you expect, add custom labels to your metrics or check for relevant chart options in the control panel. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone, does anyone know why this situation occurs?
During chart configuration, if only one metric is configured, the configuration works normally. For example, if only "COUNT_DISTINCT(classification_name)" is configured, the legend will display each classification name from the table, which is [classification_name1, classification_name2.....] at this time.
However, if two metrics (COUNT_DISTINCT(classification_name) and COUNT_DISTINCT(custom_type)) are configured, as shown in the screenshot, the legend configuration of the entire echart will become ['COUNT_DISTINCT(custom_type) classification_name1', 'COUNT_DISTINCT(custom_type) classification_name2'], etc. Could this be a bug?
The expected result is that when two metrics are configured, the legend should be [custom_type1, classification_name2, custom_type2, classification_name2], without the SQL expressions included.
Thank you all for your help. I would be very grateful for your answers.
Beta Was this translation helpful? Give feedback.
All reactions