Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Plots extension #73

Merged
merged 2 commits into from
Oct 11, 2024
Merged

add Plots extension #73

merged 2 commits into from
Oct 11, 2024

Conversation

hhaensel
Copy link
Member

@hhaensel hhaensel commented Oct 7, 2024

Referring to #13 I propose an additional extension that adds a render function for Plots. That way, we could also allow for

@app Example begin
    @out plot = Plots.plot(20:-1:1)
end

ui() = plotly(:plot)

@hhaensel
Copy link
Member Author

hhaensel commented Oct 10, 2024

Currently I moved the required Plots.plotly() to insure the Plotly backend is loaded to call to __init__().
Alternatively we could place it in the render function:

function Stipple.render(pl::Plots.Plot)
    if isdefined(Plots, :plotlybase_syncplot)
        current_backend = Plots.backend()
        Plots.plotly() === current_backend || Plots.backend(current_backend)
    end

    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

@essenciary what do you think?

@hhaensel hhaensel merged commit 6d4347e into main Oct 11, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant