I’m using Bonito with WGLMakie to visualise 2D slices of multi-dimensional data in heatmaps. I got a simple slider working together with heatmap (the slider value slices one variable dimension) for a 3D array data:
app = App() do
N = size(data)[end]
slice_idx = Slider(1:N)
slice = map(slice_idx) do idx
view(data, :, :, idx)
end
fig = Figure(size=(800,800))
ax = Axis(fig[1,1], aspect=1)
heat = heatmap!(ax, slice, colorrange=(0, 500))
return Bonito.DOM.div(slice_idx, fig)
end
I would like to have the option to animate this automatically with the press of a button (ie, the value of the slice_idx changing with time), but could not find examples with a timer option. I’ve seen something similar in PlutoUI: the Clock() button, but how to do this with Bonito and WGLMakie?
Thank you for the quick answer, this is exactly what I was looking for! And NDViewer looks awesome, has lots of the features I was looking into, so I will play with it for sure.
For completeness, here is your PlaySlider in my simple example from before:
Yeah let me know if you want to contribute to NDViewer as well, if you find any improvements
That’d be amazing, I don’t have time for it right now, but maybe next year and I’m happy to merge improvements!