Skip to content

Commit

Permalink
add use_iframe to settings and fix docs
Browse files Browse the repository at this point in the history
joshday committed Dec 3, 2024
1 parent ed2bc3c commit 72e016e
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Documenter
using PlotlyLight

PlotlyLight.settings.use_iframe = true

makedocs(
sitename = "PlotlyLight",
modules = [PlotlyLight],
18 changes: 10 additions & 8 deletions docs/src/settings.md
Original file line number Diff line number Diff line change
@@ -3,13 +3,15 @@
Occasionally the `PlotlyLight.preset`s aren't enough. Low level user-configurable settings are available in `PlotlyLight.settings`:

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

Check out e.g. `PlotlyLight.Settings().src` to examine default values.
Check out e.g. `PlotlyLight.Settings()` to examine default values.
3 changes: 2 additions & 1 deletion src/PlotlyLight.jl
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ Base.@kwdef mutable struct Settings
config::Config = Config(responsive=true, displaylogo=false)
reuse_preview::Bool = true
page_css::Cobweb.Node = h.style("html, body { padding: 0px; margin: 0px; }")
use_iframe::Bool = false
iframe_style = "display:block; border:none; min-height:350px; min-width:350px; width:100%; height:100%"
src_inject::Vector = []
end
@@ -157,7 +158,7 @@ function html_iframe(o::Plot, id=rand_id(), kw...)
end

function Base.show(io::IO, ::MIME"text/html", o::Plot)
get(io, :jupyter, false) ?
(get(io, :jupyter, false) || settings.use_iframe) ?
show(io, MIME("text/html"), html_iframe(o)) :
show(io, MIME("text/html"), html_div(o))
end

2 comments on commit 72e016e

@joshday
Copy link
Member Author

@joshday joshday commented on 72e016e Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/120618

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.11.0 -m "<description of version>" 72e016e7142abeeff5c6fd0da989a85b75d4db36
git push origin v0.11.0

Please sign in to comment.