let plotly config and use in same cell in case of config cell re-run or is deleted

This commit is contained in:
Jks Liu 2021-01-20 22:51:17 +08:00
parent 509a8cdc7e
commit 50a6dd9fb3
2 changed files with 13 additions and 18 deletions

View File

@ -907,7 +907,19 @@ function plotly_html_body(plt, style = nothing)
requirejs_prefix = ""
requirejs_suffix = ""
if isijulia()
requirejs_prefix = "require(['Plotly'], function (Plotly) {"
# require.js adds .js automatically
plotly_no_ext =
use_local_dependencies[] ? ("file:///" * plotly_local_file_path[]) : "https://cdn.plot.ly/$(_plotly_min_js_filename)"
plotly_no_ext = plotly_no_ext[1:end-3]
requirejs_prefix = """
requirejs.config({
paths: {
Plotly: '$(plotly_no_ext)'
}
});
require(['Plotly'], function (Plotly) {
"""
requirejs_suffix = "});"
end

View File

@ -89,23 +89,6 @@ function __init__()
use_local_dependencies[] = use_local_plotlyjs[]
if isijulia()
# require.js adds .js automatically
plotly_no_ext =
use_local_dependencies[] ? ("file:///" * plotly_local_file_path[]) : "https://cdn.plot.ly/$(_plotly_min_js_filename)"
plotly_no_ext = plotly_no_ext[1:end-3]
display("text/html", """
<script type="text/javascript">
requirejs.config({
paths: {
Plotly: '$(plotly_no_ext)'
}
});
</script>
""")
end
@require FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" begin
_show(io::IO, mime::MIME"image/png", plt::Plot{<:PDFBackends}) = _show_pdfbackends(io, mime, plt)