aminghadersohi commented on code in PR #37639:
URL: https://github.com/apache/superset/pull/37639#discussion_r2760142536
##########
superset/mcp_service/chart/preview_utils.py:
##########
@@ -64,12 +64,27 @@ def generate_preview_from_form_data(
# Create query context from form data using factory
from superset.common.query_context_factory import QueryContextFactory
+ # Build columns list: include x_axis and groupby for XY charts,
+ # fall back to form_data "columns" for table charts
+ x_axis_config = form_data.get("x_axis")
+ groupby_columns = form_data.get("groupby", [])
+ raw_columns = form_data.get("columns", [])
+
+ columns = raw_columns.copy() if raw_columns else groupby_columns.copy()
+ if x_axis_config and isinstance(x_axis_config, str):
+ if x_axis_config not in columns:
+ columns.insert(0, x_axis_config)
+ elif x_axis_config and isinstance(x_axis_config, dict):
+ col_name = x_axis_config.get("column_name")
Review Comment:
Not applicable here. In the MCP service, `x_axis` is always set as a string
by `map_xy_config()`. The dict handling is a defensive fallback matching the
existing `ASCIIPreviewStrategy` pattern. Adhoc/expression x-axes aren't part of
the MCP chart generation flow.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]