Skip to content

Commit

Permalink
add Plots extension
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Oct 7, 2024
1 parent 208fdd2 commit eb0c626
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@ Stipple = "4acbeb90-81a0-11ea-1966-bdaff8155998"
DataFrames = "1"
Genie = "5.24.4"
PlotlyBase = "0.8.19"
Plots = "1.4"
Requires = "1"
Stipple = "0.29, 0.30"
julia = "1.6"

[extras]
PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[extensions]
StipplePlotlyPlotlyBaseExt = "PlotlyBase"
StipplePlotlyPlotsExt = ["Plots", "PlotlyBase"]

[targets]
test = ["Test", "PlotlyBase"]

[weakdeps]
PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
33 changes: 33 additions & 0 deletions ext/StipplePlotlyPlotsExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module StipplePlotlyPlotsExt

using StipplePlotly
using StipplePlotly.Stipple
using StipplePlotly.Charts
import Stipple: render, stipple_parse

if isdefined(Base, :get_extension)
using Plots
using PlotlyBase
else
using ..Plots
using ..PlotlyBase
end

function Stipple.render(pl::Plots.Plot)
pl = Plots.plotlybase_syncplot(pl)
delete!(pl.layout.fields, :height)
delete!(pl.layout.fields, :width)
pl.layout.fields[:margin] = Dict(:l => 50, :b => 50, :r => 50, :t => 60)

return pl
end

function __init__()
current_backend = Plots.backend()
if current_backend !== :plotly
Plots.plotly()
Plots.backend(current_backend)
end
end

end

0 comments on commit eb0c626

Please sign in to comment.