GitHub user dosubot[bot] added a comment to the discussion: How to control chart rendering via URL parameters when using Permalink?
<!-- Greeting --> Hi @yangrn2000-star! I'm [Dosu](https://go.dosu.dev/dosubot) and Iām helping the superset team. <!-- Answer --> Directly controlling the Tree Chart's root node via a URL parameter like `?root_node_id=1` isn't supported in Superset 4.1.1 or newer versions. The chart's root node is set using the `root_node_id` field in the chart's form data, which is serialized in permalinks and chart URLs. If you want to embed the same chart with different initial views, you have two main options: 1. **Use the `form_data` URL parameter**: You can pass a JSON-encoded payload to the `/explore/` endpoint, including the desired `root_node_id`. For example: ``` /superset/explore/?form_data={"slice_id":123,"root_node_id":"1"} ``` This lets you override the root node for the chart view, but is only available on the explore page, not dashboards. 2. **Generate different permalinks**: Each permalink saves the entire chart state, including `root_node_id`. To show different root nodes, create and use separate permalinks for each desired view. There is no built-in mechanism that watches for a `root_node_id` query string and injects it into the chart automatically. Changing the root node dynamically in an embedded iframe requires either updating the chart's form data or generating new permalinks with the desired configuration. See [Tree Chart control panel and rendering logic](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx#L78-L86) and [explore URL parameter handling](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/explore/exploreUtils/getParsedExploreURLParams.ts#L20-L141) for details. Let me know if you need a concrete example or have questions about generating permalinks or using the `form_data` parameter. <!-- 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/d130a7c0-69f0-4ad7-9012-8ce41a4ef056?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/d130a7c0-69f0-4ad7-9012-8ce41a4ef056?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/d130a7c0-69f0-4ad7-9012-8ce41a4ef056?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/d130a7c0-69f0-4ad7-9012-8ce41a4ef056?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/d130a7c0-69f0-4ad7-9012-8ce41a4ef056?feedback_type=hallucination) | [Report š](https://app.dosu.dev/response-feedback/d130a7c0-69f0-4ad7-9012-8ce41a4ef056?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/d130a7c0-69f0-4ad7-9012-8ce41a4ef056?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=Directly%20controlling%20the%20Tree%20Chart%27s%20root%20node%20via%20a%20URL%20parameter%20like%20%60%3Froot_node_id%3D1%60%20isn%27t%20supported%20in%20Superset%204.1.1%20or%20newer%20versions.%20The%20chart%27s%20root%20node%20is%20set%20using%20the%20%60root_node_id%60%20field%20in%20the%20chart%27s%20form%20data%2C%20which%20is%20serialized%20in%20permalinks%20and%20chart%20URLs.%0A%0AIf%20you%20want%20to%20embed%20the%20same%20chart%20with%20different%20initial%20views%2C%20you%20have%20two%20main%20options%3A%0A%0A1.%20%2A%2AUse%20the%20%60form_data%60%20URL%20parameter%2A%2A%3A%20You%20can%20pass%20a%20JSON-encoded%20payload%20to%20the%20%60/explore/%60%20endpoint%2C%20including%20the%20desired%20%60root_node_id%60.%20For%20example%3A%0A%20%20 %20%60%60%60%0A%20%20%20/superset/explore/%3Fform_data%3D%7B%22slice_id%22%3A123%2C%22root_node_id%22%3A%221%22%7D%0A%20%20%20%60%60%60%0A%20%20%20This%20lets%20you%20override%20the%20root%20node%20for%20the%20chart%20view%2C%20but%20is%20only%20available%20on%20the%20explore%20page%2C%20not%20dashboards.%0A%0A2.%20%2A%2AGenerate%20different%20permalinks%2A%2A%3A%20Each%20permalink%20saves%20the%20entire%20chart%20state%2C%20including%20%60root_node_id%60.%20To%20show%20different%20root%20nodes%2C%20create%20and%20use%20separate%20permalinks%20for%20each%20desired%20view.%0A%0AThere%20is%20no%20built-in%20mechanism%20that%20watches%20for%20a%20%60root_node_id%60%20query%20string%20and%20injects%20it%20into%20the%20chart%20automatically.%20Changing%20the%20root%20node%20dynamically%20in%20an%20embedded%20iframe%20requires%20either%20updating%20the%20chart%27s%20form%20data%20or%20generating%20new%20permalinks%20with%20the%20desired%20configuration.%20See%20%5BTree%20Chart%20control%2 0panel%20and%20rendering%20logic%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx%23L78-L86%29%20and%20%5Bexplore%20URL%20parameter%20handling%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/explore/exploreUtils/getParsedExploreURLParams.ts%23L20-L141%29%20for%20details.%0A%0ALet%20me%20know%20if%20you%20need%20a%20concrete%20example%20or%20have%20questions%20about%20generating%20permalinks%20or%20using%20the%20%60form_data%60%20parameter.) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/36675) GitHub link: https://github.com/apache/superset/discussions/36675#discussioncomment-15270648 ---- 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]
