# Filling text! from observable Array

**URL:** https://discourse.julialang.org/t/filling-text-from-observable-array/100435
**Category:** General Usage
**Created:** [June 16, 2023, 7:22am UTC](https://discourse.julialang.org/t/filling-text-from-observable-array/100435 "2023-06-16T07:22:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sransome](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sransome/32/29810_2.png) [@sransome](https://discourse.julialang.org/u/sransome)
#### Post date: [June 16, 2023, 7:22am UTC](https://discourse.julialang.org/t/filling-text-from-observable-array/100435/1 "2023-06-16T07:22:09Z")

</div>

Hi,

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.

Thanks  
Steve

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [June 16, 2023, 9:38am UTC](https://discourse.julialang.org/t/filling-text-from-observable-array/100435/2 "2023-06-16T09:38:51Z")

</div>

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

```julia
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
end

```

---

<div class="post-metadata">

### Author: ![sransome](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sransome/32/29810_2.png) [@sransome](https://discourse.julialang.org/u/sransome)
#### Post date: [June 17, 2023, 2:46am UTC](https://discourse.julialang.org/t/filling-text-from-observable-array/100435/3 "2023-06-17T02:46:01Z")

</div>

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…

```julia
# then set the update up
on(oTextInformation) do (pos, col, ...)
    ocolor.val = color
    ofontsize.val = fontsize
    otext.val = text
    oposition[]=position
    ocolor[]=color
    ofontsize[]=fontsize
    otext[]=text

```

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

Thanks  
Steve
