GitHub user dosubot[bot] added a comment to the discussion: How to add  a new 
chart type in superset version 4.1.1?

<!-- Answer -->
To add a new chart type (visualization plugin) in Superset 4.1.1, the 
recommended workflow is:

1. **Scaffold your plugin**: Use the Yeoman generator 
(`@superset-ui/generator-superset`) to create a new visualization plugin as a 
standalone TypeScript/JavaScript package. This sets up all necessary files for 
your chart, including code, control panel, query logic, and tests. See the 
[how-to 
guide](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/docs/docs/contributing/howtos.mdx)
 and [generator 
README](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/packages/generator-superset/README.md).

2. **Build and install**: Build your plugin (`npm run build`), then install it 
into Superset’s `superset-frontend` directory (`npm i -S /path/to/your/plugin`).

3. **Register the plugin**: Import your chart plugin in 
`superset-frontend/src/visualizations/presets/MainPreset.js` and add it to the 
`plugins` array, e.g.:
   ```js
   import { SupersetPluginChartHelloWorld } from 
'superset-plugin-chart-hello-world';
   ...
   new SupersetPluginChartHelloWorld().configure({ key: 'ext-hello-world' }),
   ```
   [See example in 
MainPreset.js](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/visualizations/presets/MainPreset.js).

4. **Feature flags**: If your chart is experimental, you can conditionally 
include it based on the `CHART_PLUGINS_EXPERIMENTAL` feature flag. Enable this 
by adding `FEATURE_FLAGS = {"CHART_PLUGINS_EXPERIMENTAL": True}` to your config 
or setting the environment variable 
`SUPERSET_FEATURE_CHART_PLUGINS_EXPERIMENTAL=True` 
([details](https://github.com/apache/superset/discussions/31426)).

5. **Backend changes**: For most modern plugins, backend (Python) changes are 
not needed. If you require custom server-side data processing, subclass 
`BaseViz` in `superset/viz.py` and assign a unique `viz_type` 
([reference](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/viz.py)).
 Otherwise, focus on frontend development.

For more resources and community guides, check out the [Superset Community 
Resource 
Library](https://github.com/apache/superset/wiki/Community-Resource-Library#creating-custom-data-visualizations).

Let me know if you need more details on any step!


<!-- 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/da85870e-cd4a-4744-a51c-f8e189f0612d?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/da85870e-cd4a-4744-a51c-f8e189f0612d?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/da85870e-cd4a-4744-a51c-f8e189f0612d?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/da85870e-cd4a-4744-a51c-f8e189f0612d?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/da85870e-cd4a-4744-a51c-f8e189f0612d?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/da85870e-cd4a-4744-a51c-f8e189f0612d?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/da85870e-cd4a-4744-a51c-f8e189f0612d?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=github)&
 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/34817)

GitHub link: 
https://github.com/apache/superset/discussions/34817#discussioncomment-14188249

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: 
notifications-unsubscr...@superset.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