Skip to content

Commit

Permalink
MWE
Browse files Browse the repository at this point in the history
  • Loading branch information
PGimenez committed Aug 28, 2023
1 parent 3d3d263 commit d73e364
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions content/2.reference/3.reactive-UI/2.plotting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit d73e364

Please sign in to comment.