Skip to content

Commit 72e016e

Browse files
committed
add use_iframe to settings and fix docs
1 parent ed2bc3c commit 72e016e

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

docs/make.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using Documenter
22
using PlotlyLight
33

4+
PlotlyLight.settings.use_iframe = true
5+
46
makedocs(
57
sitename = "PlotlyLight",
68
modules = [PlotlyLight],

docs/src/settings.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
Occasionally the `PlotlyLight.preset`s aren't enough. Low level user-configurable settings are available in `PlotlyLight.settings`:
44

55
```julia
6-
PlotlyLight.settings.src::Cobweb.Node # plotly.js script loader
7-
PlotlyLight.settings.div::Cobweb.Node # The plot-div
8-
PlotlyLight.settings.layout::EasyConfig.Config # default `layout` for all plots
9-
PlotlyLight.settings.config::EasyConfig.Config # default `config` for all plots
10-
PlotlyLight.settings.reuse_preview::Bool # In the REPL, open plots in same page (true, the default) or different pages.
11-
PlotlyLight.settings.style::Dict{String,String} # CSS styles for the plot <div>
12-
PlotlyLight.settings.inject_head::Cobweb.Node # Code to inject at the bottom the <head>
6+
settings.src::Cobweb.Node # plotly.js script loader
7+
settings.div::Cobweb.Node # The plot-div
8+
settings.layout::EasyConfig.Config # default `layout` for all plots
9+
settings.config::EasyConfig.Config # default `config` for all plots
10+
settings.reuse_preview::Bool # In the REPL, open plots in same page (true, the default) or different pages.
11+
settings.page_css::Cobweb.Node # CSS to inject at the top of the page
12+
settings.use_iframe::Bool # Use an iframe to display the plot (default=false)
13+
settings.iframe_style::String # style attributes for the iframe
14+
settings.src_inject::Vector # Code (typically scripts) to inject into the html
1315
```
1416

15-
Check out e.g. `PlotlyLight.Settings().src` to examine default values.
17+
Check out e.g. `PlotlyLight.Settings()` to examine default values.

src/PlotlyLight.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Base.@kwdef mutable struct Settings
4444
config::Config = Config(responsive=true, displaylogo=false)
4545
reuse_preview::Bool = true
4646
page_css::Cobweb.Node = h.style("html, body { padding: 0px; margin: 0px; }")
47+
use_iframe::Bool = false
4748
iframe_style = "display:block; border:none; min-height:350px; min-width:350px; width:100%; height:100%"
4849
src_inject::Vector = []
4950
end
@@ -157,7 +158,7 @@ function html_iframe(o::Plot, id=rand_id(), kw...)
157158
end
158159

159160
function Base.show(io::IO, ::MIME"text/html", o::Plot)
160-
get(io, :jupyter, false) ?
161+
(get(io, :jupyter, false) || settings.use_iframe) ?
161162
show(io, MIME("text/html"), html_iframe(o)) :
162163
show(io, MIME("text/html"), html_div(o))
163164
end

0 commit comments

Comments
 (0)