GitHub user dosubot[bot] added a comment to the discussion: superset api

<!-- Answer -->
**No, backend-pivoted data won't render properly with the existing Table or 
Pivot Table charts.**

Here's why:
- The [Table chart 
plugin](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts#L210-L215)
 expects flat, un-pivoted data and has no logic to handle pivoted structures
- The [Pivot Table 
plugin](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts#L60-L85)
 is specifically designed to receive un-pivoted data and perform all pivoting 
on the frontend
- The backend pivot operation [returns flattened MultiIndex columns as 
space-separated 
strings](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/client_processing.py#L359-L369),
 which doesn't match what these plugins expect

**Your options:**

1. **Use the existing Pivot Table plugin as-is** – let the frontend do the 
pivoting (this is the designed workflow)

2. **Build a custom visualization plugin** – create your own frontend plugin 
that can parse and render backend-pivoted data

3. **Use the API for external consumption** – if you're calling the chart data 
API from your own application (not Superset's UI), you can handle the pivoted 
data however you want in your own frontend code

If you go with Option 2 from my previous response (custom API endpoint), you'll 
also need a custom frontend component to render that data properly.


<!-- 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/362a496e-1f6a-4e01-a81e-6883f3b64961?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/362a496e-1f6a-4e01-a81e-6883f3b64961?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/362a496e-1f6a-4e01-a81e-6883f3b64961?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/362a496e-1f6a-4e01-a81e-6883f3b64961?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/362a496e-1f6a-4e01-a81e-6883f3b64961?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/362a496e-1f6a-4e01-a81e-6883f3b64961?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/362a496e-1f6a-4e01-a81e-6883f3b64961?feedback_type=other)</sup>

[![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=%2A%2ANo%2C%20backend-pivoted%20data%20won%27t%20render%20properly%20with%20the%20existing%20Table%20or%20Pivot%20Table%20charts.%2A%2A%0A%0AHere%27s%20why%3A%0A-%20The%20%5BTable%20chart%20plugin%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts%23L210-L215%29%20expects%20flat%2C%20un-pivoted%20data%20and%20has%20no%20logic%20to%20handle%20pivoted%20structures%0A-%20The%20%5BPivot%20Table%20plugin%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts%23L60-L85%29%20is%20specifically%20designed%20to%20receive%20un-pivoted%20data%20and%2
 
0perform%20all%20pivoting%20on%20the%20frontend%0A-%20The%20backend%20pivot%20operation%20%5Breturns%20flattened%20MultiIndex%20columns%20as%20space-separated%20strings%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/client_processing.py%23L359-L369%29%2C%20which%20doesn%27t%20match%20what%20these%20plugins%20expect%0A%0A%2A%2AYour%20options%3A%2A%2A%0A%0A1.%20%2A%2AUse%20the%20existing%20Pivot%20Table%20plugin%20as-is%2A%2A%20%E2%80%93%20let%20the%20frontend%20do%20the%20pivoting%20%28this%20is%20the%20designed%20workflow%29%0A%0A2.%20%2A%2ABuild%20a%20custom%20visualization%20plugin%2A%2A%20%E2%80%93%20create%20your%20own%20frontend%20plugin%20that%20can%20parse%20and%20render%20backend-pivoted%20data%0A%0A3.%20%2A%2AUse%20the%20API%20for%20external%20consumption%2A%2A%20%E2%80%93%20if%20you%27re%20calling%20the%20chart%20data%20API%20from%20your%20own%20application%20%28not%20Superset%27s%20UI%29%2C%20you%20can%20handle%20th
 
e%20pivoted%20data%20however%20you%20want%20in%20your%20own%20frontend%20code%0A%0AIf%20you%20go%20with%20Option%202%20from%20my%20previous%20response%20%28custom%20API%20endpoint%29%2C%20you%27ll%20also%20need%20a%20custom%20frontend%20component%20to%20render%20that%20data%20properly.)&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/discussions/38231)

GitHub link: 
https://github.com/apache/superset/discussions/38231#discussioncomment-15918852

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to