Title: Tainted canvases may not be exported · Issue #2785 · plotly/plotly.py · GitHub
Open Graph Title: Tainted canvases may not be exported · Issue #2785 · plotly/plotly.py
X Title: Tainted canvases may not be exported · Issue #2785 · plotly/plotly.py
Description: I'm embedding some plotly graphs into a pyqt application using the QWebEngineView. Everything seems to work well except for when I click on the "Download plot as a png" button in the toolbar. I get the error: js: Uncaught SecurityError: ...
Open Graph Description: I'm embedding some plotly graphs into a pyqt application using the QWebEngineView. Everything seems to work well except for when I click on the "Download plot as a png" button in the toolbar. I get...
X Description: I'm embedding some plotly graphs into a pyqt application using the QWebEngineView. Everything seems to work well except for when I click on the "Download plot as a png" button in the ...
Opengraph URL: https://github.com/plotly/plotly.py/issues/2785
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Tainted canvases may not be exported","articleBody":"I'm embedding some plotly graphs into a pyqt application using the QWebEngineView. Everything seems to work well except for when I click on the \"Download plot as a png\" button in the toolbar. I get the error:\r\n\r\n\u003e js: Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.\r\n\r\nNot sure if this is a bug (it seems like it should work), or a feature request (I'd like to be able to do this). Maybe there's a way around the error?\r\n\r\n```\r\nimport plotly.offline as po\r\nimport plotly.graph_objs as go\r\nimport plotly.express as px\r\n\r\nfrom PyQt5.QtWebEngineWidgets import QWebEngineView\r\nfrom PyQt5 import QtCore, QtWidgets\r\nimport sys\r\n\r\ndef show_qt(fig):\r\n raw_html = '\u003chtml\u003e\u003chead\u003e\u003cmeta charset=\"utf-8\" /\u003e'\r\n raw_html += '\u003cscript src=\"https://cdn.plot.ly/plotly-latest.min.js\"\u003e\u003c/script\u003e\u003c/head\u003e'\r\n raw_html += '\u003cbody\u003e'\r\n raw_html += po.plot(fig, include_plotlyjs=False, output_type='div')\r\n raw_html += '\u003c/body\u003e\u003c/html\u003e'\r\n\r\n fig_view = QWebEngineView()\r\n # setHtml has a 2MB size limit, need to switch to setUrl on tmp file\r\n # for large figures.\r\n fig_view.setHtml(raw_html)\r\n fig_view.show()\r\n fig_view.raise_()\r\n return fig_view\r\n\r\n\r\nif __name__ == '__main__':\r\n app = QtWidgets.QApplication(sys.argv)\r\n\r\n df = px.data.election()\r\n geojson = px.data.election_geojson()\r\n\r\n fig = px.choropleth(df, geojson=geojson, color=\"Bergeron\",\r\n locations=\"district\", featureidkey=\"properties.district\",\r\n projection=\"mercator\"\r\n )\r\n fig.update_geos(fitbounds=\"locations\", visible=False)\r\n fig.update_layout(margin={\"r\":0,\"t\":0,\"l\":0,\"b\":0})\r\n fig_view = show_qt(fig)\r\n sys.exit(app.exec_())\r\n```\r\n","author":{"url":"https://github.com/jwebster-LANL","@type":"Person","name":"jwebster-LANL"},"datePublished":"2020-09-22T18:43:46.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2785/plotly.py/issues/2785"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d0f6e634-64b2-ef47-49a6-35f65922217d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE2A:BE119:1C369:2653A:6A57694A |
| html-safe-nonce | 54c1da7632806dfad4138d687d3d4b776144bbfa3b29c02417b3190a597b3dae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTJBOkJFMTE5OjFDMzY5OjI2NTNBOjZBNTc2OTRBIiwidmlzaXRvcl9pZCI6IjMyNzk2NTYzNTYzNjI1NDU0ODIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | edf97f1500d926ddbaf9b590069c4bfcbb92b5158722b607ab376d1d54abf162 |
| hovercard-subject-tag | issue:706609877 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/plotly/plotly.py/2785/issue_layout |
| twitter:image | https://opengraph.githubassets.com/01fde5d2f29782b5615abc406dd23b71aea28d289f32a3905eb0a4b3442ff88c/plotly/plotly.py/issues/2785 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/01fde5d2f29782b5615abc406dd23b71aea28d289f32a3905eb0a4b3442ff88c/plotly/plotly.py/issues/2785 |
| og:image:alt | I'm embedding some plotly graphs into a pyqt application using the QWebEngineView. Everything seems to work well except for when I click on the "Download plot as a png" button in the toolbar. I get... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jwebster-LANL |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98 |
| turbo-cache-control | no-preview |
| go-import | github.com/plotly/plotly.py git https://github.com/plotly/plotly.py.git |
| octolytics-dimension-user_id | 5997976 |
| octolytics-dimension-user_login | plotly |
| octolytics-dimension-repository_id | 14579099 |
| octolytics-dimension-repository_nwo | plotly/plotly.py |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14579099 |
| octolytics-dimension-repository_network_root_nwo | plotly/plotly.py |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1b5a9c55f39dd27607a574cdc272552f20236b44 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width