JuliaPluto / PlutoUI.jl

https://featured.plutojl.org/basic/plutoui.jl
The Unlicense
301 stars 55 forks source link

Clock limit #45

Open IgorDouven opened 4 years ago

IgorDouven commented 4 years ago

I like the Clock feature a lot. But is there a possibility to set an end point? Now, when I let the clock run, it will eventually error, given that it tries to go on even when there are no more data to plot. Looping back would be an alternative.

fonsp commented 4 years ago

You can loop using mod1:

@bind i Clock()
let
    data_index = mod1(i, length(data))
    plot(data[data_index])
end

But a stopping feature would be nice.

IgorDouven commented 4 years ago

Thanks -- works perfectly!

Op wo 23 sep. 2020 om 11:42 schreef Fons van der Plas < notifications@github.com>:

You can loop using mod1:

@bind i Clock()

let data_index = mod1(i, length(data)) plot(data[data_index])end

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fonsp/PlutoUI.jl/issues/45#issuecomment-697254342, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIFACLG3GRMSVP24HNIOQ5LSHG7H5ANCNFSM4RWWH63A .

rmslp commented 3 years ago

This is a nice solution for now. However, mod1 throws an error until the clock is started, because the bound variable is nothing.

So for my animation in Pluto, I used something like

data_index = mod1( (i |> isnothing) ? 1 : i, length(data))

so that the first frame of the animation is displayed until "Start" is clicked.