I’m trying to update a text value to reflect a change in one or more Observable. I’ve tried to do this a couple of ways.
If the Observable is
obs = Observable(1.0)
I’ve tried putting it in a Label
Label(fig, "$(obs)")
using a few different ways of getting the value. If you use to_value(obs), this eliminates the Observable reference, I think, so the value will not update again. I’ve also tried to lift() the value.
I’ve also tried to put it directly on the plot using text!(). There was a time when I got that to work several months ago, but I can’t remember what I did and Makie has changed a lot since then.
I know that Slider has a built-in label, but having text that reflects Observable changes is more powerful. In the example below, there are two sine wave, and their parameters can change with sliders. I want to calculate the difference in the frequencies of the two sine waves and display it.
Is there a way to do this, or have I just not found it yet?
Or going off of this syntax (which doesn’t work because you’re trying to interpolate an Observable into a string) you can do Label(fig, @lift "$($obs)"). The first $ is the normal string interpolation syntax, the second $ means “use an observable’s value here”.
By the way, I’m working on some examples of interactivity with GLMakie. There are only a couple right now, but I’ll make a separate post when I have enough that I think they will be more broadly useful.