Merge 4a3160da29bda4ffb62dcd54aabbc5ab38420a19 into 49eba0bf2f0684e8ff02965707a7a7375b1fe51c
This commit is contained in:
commit
980e1a3d10
@ -213,7 +213,6 @@ function plotly_layout(plt::Plot)
|
||||
plotattributes_out = KW()
|
||||
|
||||
w, h = plt[:size]
|
||||
plotattributes_out[:width], plotattributes_out[:height] = w, h
|
||||
plotattributes_out[:paper_bgcolor] = rgba_string(plt[:background_color_outside])
|
||||
plotattributes_out[:margin] = KW(:l=>0, :b=>20, :r=>0, :t=>20)
|
||||
|
||||
@ -910,28 +909,45 @@ function plotly_html_head(plt::Plot)
|
||||
end
|
||||
|
||||
function plotly_html_body(plt, style = nothing)
|
||||
if style === nothing
|
||||
w, h = plt[:size]
|
||||
style = "width:$(w)px;height:$(h)px;"
|
||||
if style == nothing
|
||||
style = "width:100%;height:100%;"
|
||||
end
|
||||
uuid = UUIDs.uuid4()
|
||||
html = """
|
||||
"""
|
||||
<div id=\"$(uuid)\" style=\"$(style)\"></div>
|
||||
<script>
|
||||
PLOT = document.getElementById('$(uuid)');
|
||||
Plotly.plot(PLOT, $(plotly_series_json(plt)), $(plotly_layout_json(plt)));
|
||||
$(js_body(plt, uuid))
|
||||
</script>
|
||||
"""
|
||||
html
|
||||
end
|
||||
|
||||
function js_body(plt::Plot, uuid)
|
||||
js = """
|
||||
PLOT = document.getElementById('$(uuid)');
|
||||
Plotly.plot(PLOT, $(plotly_series_json(plt)), $(plotly_layout_json(plt)));
|
||||
function js_body(plt::Plot, divid)
|
||||
"""
|
||||
gd = (function() {
|
||||
var WIDTH_IN_PERCENT_OF_PARENT = 100;
|
||||
var HEIGHT_IN_PERCENT_OF_PARENT = 100;
|
||||
var gd = Plotly.d3.select('body')
|
||||
.append('div').attr("id", "$(divid)")
|
||||
.style({
|
||||
width: WIDTH_IN_PERCENT_OF_PARENT + '%',
|
||||
'margin-left': (100 - WIDTH_IN_PERCENT_OF_PARENT) / 2 + '%',
|
||||
height: HEIGHT_IN_PERCENT_OF_PARENT + 'vh',
|
||||
'margin-top': (100 - HEIGHT_IN_PERCENT_OF_PARENT) / 2 + 'vh'
|
||||
})
|
||||
.node();
|
||||
var data = $(plotly_series_json(plt));
|
||||
var layout = $(plotly_layout_json(plt));
|
||||
Plotly.newPlot(gd, data, layout);
|
||||
window.onresize = function() {
|
||||
Plotly.Plots.resize(gd);
|
||||
};
|
||||
return gd;
|
||||
})();
|
||||
"""
|
||||
end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
function plotly_show_js(io::IO, plot::Plot)
|
||||
data = []
|
||||
for series in plot.series_list
|
||||
@ -958,3 +974,4 @@ end
|
||||
function _display(plt::Plot{PlotlyBackend})
|
||||
standalone_html_window(plt)
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user