[英]How to embede Apache Superset chart into React app
I want to embed my chart from Apache Superset into my React.js App.我想将 Apache Superset 中的图表嵌入到我的 React.js 应用程序中。 So far I know there is possibility to use like this:
到目前为止,我知道可以这样使用:
<iframe
id="myIFRAME"
width="1600"
height="1200"
seamless
frameBorder="10"
scrolling="no"
src="http://localhost:8080/r/3"
>
</iframe>
It works fine but I want to use only a chart with filter options without all the superset dashbord pane:它工作正常,但我只想使用带有过滤器选项的图表,而不使用所有超集仪表板窗格:
I was trying to use https://www.npmjs.com/package/@superset-ui/core but there is no good documentation how to use it and it require to downgrade react version to 16, while I think in my project will be better newer version.我试图使用https://www.npmjs.com/package/@superset-ui/core但没有很好的文档如何使用它并且它需要将反应版本降级到 16,而我认为在我的项目中会更好的新版本。
Currently I am trying to manipulate things inside iframe by catching things by目前我正在尝试通过以下方式捕捉东西来操纵 iframe 内部的东西
var iframe = document.getElementById("myIFRAME");
var elmnt = iframe.contentWindow.document.getElementsByClassName(
"dashboard-content css-185d7vi"
);
elmnt.style.display = "none";
But i think it's not a good way to do this and Im getting errors with CORS
and Consider adding an error boundary to your tree to customize error handling behavior.
但我认为这不是执行此操作的好方法,我收到
CORS
错误并Consider adding an error boundary to your tree to customize error handling behavior.
There is an option to add to iframe query attribute standalone=true..有一个选项可以添加到 iframe 查询属性 Standalone=true..
<iframe
id="myIFRAME"
width="1600"
height="1200"
seamless
frameBorder="10"
scrolling="no"
src="http://localhost:8080/superset/dashboard/world_health/?standalone=true"
></iframe>
I think this is helpful for your question.我认为这对您的问题有帮助。
https://superset.apache.org/docs/creating-charts-dashboards/creating-your-first-dashboard/#customizing-dashboard https://superset.apache.org/docs/creating-charts-dashboards/creating-your-first-dashboard/#customizing-dashboard
<iframe
width="1600"
height="1600"
seamless
frameBorder="0"
scrolling="yes"
src="http://127.0.0.1:8088/superset/dashboard/16?standalone=2"
>
</iframe>
Don't get the URL from ' Copy dashboard URL ' in superset.不要从超集中的“复制仪表板 URL ”中获取 URL。 Instead of that you can get the dashboard URL from the browser link address.
相反,您可以从浏览器链接地址获取仪表板 URL。 At the end of the URL simply add ' ?standalone=2 '
在 URL 的末尾只需添加 ' ?standalone=2 '
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.