aminghadersohi opened a new pull request, #38390:
URL: https://github.com/apache/superset/pull/38390
### SUMMARY
Add an `orientation` parameter to `XYChartConfig` in the MCP
`generate_chart` API, enabling MCP clients to create horizontal bar charts.
- **Schema**: Added `orientation: Literal["vertical", "horizontal"] | None`
field to `XYChartConfig` in `schemas.py`. Defaults to `None` (Superset's
default vertical bars). Only applies when `kind="bar"`.
- **Mapping**: Extracted `add_orientation_config()` helper in
`chart_utils.py` that passes orientation through to Superset's `form_data` when
the chart kind is `"bar"`. Non-bar chart types ignore the parameter.
- **Resource**: Added a `horizontal_bar` example to the `chart://configs`
resource and updated best practices with an orientation tip.
- **Tests**: Added schema validation tests (accepted values, default,
invalid values, non-bar charts) and form_data mapping tests (horizontal,
vertical, omitted, ignored for line charts, combined with stacked + group_by).
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - Backend-only change to MCP API schema.
### TESTING INSTRUCTIONS
1. Run MCP chart unit tests:
```bash
python -m pytest tests/unit_tests/mcp_service/chart/ -x -q
```
2. Verify the new `orientation` field appears in the `XYChartConfig` JSON
schema.
3. Test via MCP client:
```json
{
"chart_type": "xy",
"kind": "bar",
"orientation": "horizontal",
"x": {"name": "department"},
"y": [{"name": "headcount", "aggregate": "SUM"}]
}
```
Confirm the resulting form_data includes `"orientation": "horizontal"`.
### ADDITIONAL INFORMATION
- [x] Introduces new feature or API
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]