dosubot[bot] commented on issue #35221:
URL: https://github.com/apache/superset/issues/35221#issuecomment-3314887077

   <!-- Answer -->
   You can update a chart in Superset using a PUT request to the endpoint 
`/api/v1/chart/<chart_id>`. The payload must conform to the `ChartPutSchema`, 
where the `params` field is a JSON string that includes your chart 
configuration, such as metrics and groupby. For example:
   
   ```json
   PUT /api/v1/chart/123
   Content-Type: application/json
   
   {
     "slice_name": "Test Chart",
     "viz_type": "pie",
     "datasource_id": 123,
     "datasource_type": "table",
     "params": "{\"groupby\": [\"status\"], \"metrics\": [\"COUNT(*)\"]}"
   }
   ```
   
   You can also use more complex metric objects in the `metrics` array, 
following the ad-hoc metric schema (e.g., with `expressionType`, `label`, 
`sqlExpression`). The backend simply stores this string; the frontend 
interprets it when rendering the chart. Note that even after a successful 
update, the METRIC field in the UI may still require manual interaction due to 
frontend logic—this is a known limitation 
[cite](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/api.py)
 
[cite](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/schemas.py)
 
[cite](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/tests/integration_tests/charts/api_tests.py).
   
   If you want to update other fields (like dashboards, owners, etc.), include 
them in the payload as needed. The key part for metrics is always the `params` 
JSON string.
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/29de4279-18bf-4de7-9cc7-6ba3bce130bc?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/29de4279-18bf-4de7-9cc7-6ba3bce130bc?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/29de4279-18bf-4de7-9cc7-6ba3bce130bc?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/29de4279-18bf-4de7-9cc7-6ba3bce130bc?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/29de4279-18bf-4de7-9cc7-6ba3bce130bc?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/29de4279-18bf-4de7-9cc7-6ba3bce130bc?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/29de4279-18bf-4de7-9cc7-6ba3bce130bc?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat
 with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=githu
 b)&nbsp;[![Join 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/35221)


-- 
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: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to