-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plotly doesn't display because of Content Security Policy #368
Comments
cc/ @lgeiger How do you reckon? Should we wrap all the |
SVG can indeed contain JS. |
If we get it to work with webviews it would be great! We should do this directly in I don't think we need webviews for SVG though. |
I wanted to ask the same question. I never used webviews. |
That's a good argument 🎉 I did a quick test with webviews in hydrogen but javascript didn't work. I used this transformer. HTMLTransform = (mimetype, data, document) ->
webview = document.createElement('webview')
webview.src = 'data:text/html,' + data
return webview
HTMLTransform.mimetype = 'text/html'
transform = transformime.createTransform([HTMLTransform, MarkdownTransform]) Do you have an idea why this isn't working? |
Should that |
I tested again and found my assumption was a bit rash. Basic javascript works but plotly still doesn't 😞 |
@lgeiger Last time I looked into using Here's an example for testing purposes that works in the notebook and that I would expect it to work in webviews too: var output = [
"<div id='my-timer'",
" style='display:inline-block;padding:0.25em;border:1px dashed black;'",
">0</div>",
"",
"<script>",
"var div = document.getElementById('my-timer');",
"var counter = 0;",
"var id = setInterval(update, 1000);",
"function update() {",
" counter += 1;",
" div.innerHTML = '' + counter;",
" if (counter >= 10) clearInterval(id);",
"}",
"</script>",
].join("\n");
$$.html(output); This example is for IJavascript, but it can easily be adapted to IPython. |
Yes it works in webviews 👍. Thanks for the example. I tried using plotly in python. This works in the notebook but not in webviews: import plotly
from plotly.graph_objs import Scatter, Layout
plotly.offline.init_notebook_mode()
plotly.offline.iplot({
"data": [Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],
"layout": Layout(title="hello world")}) |
Hi there,
When running
I get the following error message in the dev console:
It works fine in IJavascript.
Cheer!
Jun
The text was updated successfully, but these errors were encountered: