Is there a way to build dependent sliders with PlutoUI.jl in which adjusting one will dynamically change the others?
Is there a way to build dependent sliders with PlutoUI?
452 Views Asked by Ali Rahmjoo At
2
There are 2 best solutions below
1
On
You can simply display the slider multiple times in different cells. These are the same sliders, thus adjusting it in one cell will adjust it also in all other cells.
Example:
# ╔═╡ 84fc2e80-141d-11ed-272a-13a267f5233a
using PlutoUI
# ╔═╡ 2538ee5d-6bd0-48f4-a5d3-fd0084a6a136
a = @bind x Slider(1:10)
# ╔═╡ 50e6b255-26c8-40c9-a5e5-0d95df73d3e6
a
# ╔═╡ 43ccffd4-e721-42b8-b9d3-8cbffcbedec3
x
This is useful when you need the same UI element at multiple places in your notebook for didactic / usability purposes.
Here is something that you can try:
What happens with this is that whenever you change slider
a, that causesbto be recreated (that's the way that Pluto works). The default setting is linked to the value ofaso movingacausesbto appear to move. You can still re-adjustbto anything you like.Note that you can't inter-link these two sliders because all cells in Pluto have an order of evaluation with no cycles.