Skip to content

Commit

Permalink
Merge pull request #415 from JuliaPlots/add_shape
Browse files Browse the repository at this point in the history
add_shape
  • Loading branch information
sglyon authored Aug 26, 2021
2 parents b8426a5 + 2dfbf27 commit f4539dc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PlotlyJS"
uuid = "f0f68f2c-4968-5e81-91da-67840de0976a"
authors = ["Spencer Lyon <[email protected]>"]
version = "0.18.5"
version = "0.18.6"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand All @@ -22,7 +22,7 @@ WebIO = "0f1e0344-ec1d-5b48-a673-e5cf874b6c29"
Blink = "0.12"
JSExpr = "0.5, 1"
JSON = "0.20, 0.21"
PlotlyBase = "0.8.9"
PlotlyBase = "0.8.15"
Reexport = "0.2, 1"
Requires = "1.0"
WebIO = "0.8"
Expand Down
4 changes: 2 additions & 2 deletions src/PlotlyJS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using Blink
using Pkg.Artifacts
using Requires

export plot, dataset, list_datasets, make_subplots, savefig
export plot, dataset, list_datasets, make_subplots, savefig, mgrid

# globals for this package
const _pkg_root = dirname(dirname(@__FILE__))
Expand Down Expand Up @@ -174,7 +174,7 @@ for (k, v) in vcat(PlotlyBase._layout_obj_updaters, PlotlyBase._layout_vector_up
end
end

for k in [:add_hrect!, :add_hline!, :add_vrect!, :add_vline!]
for k in [:add_hrect!, :add_hline!, :add_vrect!, :add_vline!, :add_shape!, :add_layout_image!]
@eval function PlotlyBase.$(k)(p::SyncPlot, args...;kwargs...)
$(k)(p.plot, args...; kwargs...)
send_command(p.scope, :react, p.plot.data, p.plot.layout)
Expand Down
4 changes: 2 additions & 2 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end
function Base.show(io::IO, mm::MIME"text/html", p::SyncPlot)
# if we are rendering docs -- short circuit and display html
if get_renderer() == DOCS
return show(io, mm, p.plot, full_html=false, include_plotlyjs="require-loaded")
return show(io, mm, p.plot, full_html=false, include_plotlyjs="require-loaded", include_mathjax=false)
end
show(io, mm, p.scope)
end
Expand Down Expand Up @@ -184,7 +184,7 @@ end

function add_trace!(p::SyncPlot, trace::GenericTrace; kw...)
add_trace!(p.plot, trace; kw...)
send_command(p.scope, :addTraces, trace)
send_command(p.scope, :react, p.plot.data, p.plot.layout)
end


Expand Down
15 changes: 15 additions & 0 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@ function PlotlyBase.add_recession_bands!(p::SyncPlot; kwargs...)
relayout!(p, shapes=new_shapes)
new_shapes
end

function mgrid(arrays...)
lengths = collect(length.(arrays))
uno = ones(Int, length(arrays))
out = []
for i in 1:length(arrays)
repeats = copy(lengths)
repeats[i] = 1

shape = copy(uno)
shape[i] = lengths[i]
push!(out, reshape(arrays[i], shape...) .* ones(repeats...))
end
out
end

2 comments on commit f4539dc

@sglyon
Copy link
Member Author

@sglyon sglyon commented on f4539dc Aug 26, 2021

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/43597

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.18.6 -m "<description of version>" f4539dc7b8fe906b7f42e63bbfc22deff60e98e3
git push origin v0.18.6

Please sign in to comment.