Filling text! from observable Array


I’m using Makie and need to display a lot of text in a plot and have been using a number of observable vectors to improve performance. However, I ran into syncronization problems when the length of the vectors change. The documentation refers to a solution …

Often, you can avoid length change problems by using arrays of containers like Point2f or Vec3f instead of synchronizing two or three observables of single element vectors manually.

So, I have created a vector containing a tuple with all the data required.
Vector{Tuple{Tuple{Float64, Float64}, String, Symbol, Float64, Tuple{Symbol, Symbol}}}
so I end up with a vector called oTextInformation with hundreds of tuples. Now I would like to pull out the appropriate data for each parameter required for the text! function.

I’m having a hard time working out what the text!() call would look like. I tried lots of things including

text!(spr.axis, lift(d → d[1], oTextInformation), lift(d → d[2], oTextInformation),
color = lift(d → d[3], oTextInformation), textsize= lift(d → d[4], oTextInformation),
align = lift(d → d[5], oTextInformation))

but the index 1-5 is pointing to the vector element rather than the position in the tuple.

Can anyone point me in the right direction here, or perhaps a link to an example.


When you assign these lift things to the different arguments of text they are still triggering one after the other if oTextInformation changes, which leads to the async bugs. Usually what you can do is to modify all but one observable directly without triggering them, then triggering the last one (the positional arg usually).

So something like

positions = Observable(oTextInformation[][1]) # should be a vector of Point2
color = Observable(oTextInformation[][2])
# etc.

# then set the update up
on(oTextInformation) do (pos, col, ...)
    color.val = col
    # etc.
    positions[] = pos # trigger the positional arg, usually the attributes are
    # also read in again when this one fires

Thanks Jules,

That worked well except that if I change say the text but not the position the plot is not updated. So it seems the positions = pos line does not trigger the update unless the values in positions have changed. My work around is…

# then set the update up
on(oTextInformation) do (pos, col, ...)
    ocolor.val = color
    ofontsize.val = fontsize
    otext.val = text

This now trigger the pot update regardless of what parameter is changed but it seems a bit inefficient.
Is there any other way?