You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
Not 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?
import plotly.offline as po
import plotly.graph_objs as go
import plotly.express as px
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5 import QtCore, QtWidgets
import sys
def show_qt(fig):
raw_html = '<html><head><meta charset="utf-8" />'
raw_html += '<script src="https://cdn.plot.ly/plotly-latest.min.js"></script></head>'
raw_html += '<body>'
raw_html += po.plot(fig, include_plotlyjs=False, output_type='div')
raw_html += '</body></html>'
fig_view = QWebEngineView()
# setHtml has a 2MB size limit, need to switch to setUrl on tmp file
# for large figures.
fig_view.setHtml(raw_html)
fig_view.show()
fig_view.raise_()
return fig_view
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
df = px.data.election()
geojson = px.data.election_geojson()
fig = px.choropleth(df, geojson=geojson, color="Bergeron",
locations="district", featureidkey="properties.district",
projection="mercator"
)
fig.update_geos(fitbounds="locations", visible=False)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig_view = show_qt(fig)
sys.exit(app.exec_())
The text was updated successfully, but these errors were encountered:
Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson
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:
Not 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?
The text was updated successfully, but these errors were encountered: