diff --git a/docs/src/makielayout/layoutables_examples.md b/docs/src/makielayout/layoutables_examples.md index 8eba69b48..a26f0fb32 100755 --- a/docs/src/makielayout/layoutables_examples.md +++ b/docs/src/makielayout/layoutables_examples.md @@ -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 @@ -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