diff --git a/content/2.reference/3.reactive-UI/2.plotting.md b/content/2.reference/3.reactive-UI/2.plotting.md index ea3f297..44e0ee1 100644 --- a/content/2.reference/3.reactive-UI/2.plotting.md +++ b/content/2.reference/3.reactive-UI/2.plotting.md @@ -66,7 +66,7 @@ or with the `plotly` tag in the HTML code ### Defining plots from Plots.jl It is also possible to obtain the `plotdata` from a plot defined with -[Plots.jl](https://docs.juliaplots.org/stable/) using the following function: +[Plots.jl](https://docs.juliaplots.org/stable/) using the PlotlyJS backend and the following function: ```julia import PlotlyBase function plotly_traces(plt::Plots.Plot) @@ -78,19 +78,29 @@ function plotly_traces(plt::Plots.Plot) return traces end ``` -Given a plot, say `plt`, create with the Plots.jl API: +The function can be used as follows: ```julia -import Plots -plt = Plots.plot(...) -``` -the function can be used as follows: -```julia -@out plotdata = plotly_traces(plt) +module App +using GenieFramework +import PlotlyBase,PlotlyJS, Plots +Plots.plotlyjs() + +p = Plots.plot([1, 2, 3], show=false) +@app begin + @out traces = plotly_traces(p) +end + +function ui() + plot(:traces) +end + +@page("/", ui) +end ``` ### Defining plots in HTML -It is also possible to define the plot entirely in the HTML code and just bind the data to Julia variables, +You can also define the plot entirely in the HTML code and just bind the data to Julia variables, ```julia module App