Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Commit

Permalink
add labelslidergrid docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrumbiegel committed Nov 2, 2020
1 parent 02f4da2 commit e3b5276
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions docs/src/makielayout/layoutables_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ A simple slider without a label. You can create a label using an `LText` object,
for example. You need to specify a range that constrains the slider's possible values.
You can then lift the `value` observable to make interactive plots.

To create a horizontal layout containing a label, a slider, and a value label, use the convenience function [`AbstractPlotting.MakieLayout.labelslider!`](@ref).

```@example
using AbstractPlotting
using AbstractPlotting.MakieLayout
Expand All @@ -30,6 +28,33 @@ save("example_lslider.svg", scene); nothing # hide

![example lslider](example_lslider.svg)

To create a horizontal layout containing a label, a slider, and a value label, use the convenience function [`AbstractPlotting.MakieLayout.labelslider!`](@ref), or, if you need multiple aligned rows of sliders, use [`AbstractPlotting.MakieLayout.labelslidergrid!`](@ref).

```@example
using AbstractPlotting
using AbstractPlotting.MakieLayout
scene, layout = layoutscene(resolution = (1200, 900))
ax = layout[1, 1] = LAxis(scene)
lsgrid = labelslidergrid!(scene,
["Voltage", "Current", "Resistance"],
Ref(LinRange(0:0.1:1000)); # same range for every slider via broadcast
formats = [x -> "$(round(x, digits = 1))$s" for s in ["V", "A", "Ω"]],
width = 350,
tellheight = false)
layout[1, 2] = lsgrid.layout
set_close_to!(lsgrid.sliders[1], 230.3)
set_close_to!(lsgrid.sliders[2], 628.4)
set_close_to!(lsgrid.sliders[3], 15.9)
save("example_labelslidergrid.svg", scene); nothing # hide
```

![example labelslidergrid](example_labelslidergrid.svg)

If you want to programmatically move the slider, use the function [`AbstractPlotting.MakieLayout.set_close_to!`](@ref).
Don't manipulate the `value` attribute directly, as there is no guarantee that
this value exists in the range underlying the slider, and the slider's displayed value would
Expand Down

0 comments on commit e3b5276

Please sign in to comment.