Problem dynamically render image in canvas

Hi all,

I'm new with canvas expression language, so probably my question is trivial: I'm trying to dinamically render an image in a canvas using switch statement, but I've got this error:

Immagine

Here my code:

 filters
    | essql query="SELECT value FROM \"dummydata\" as Value ORDER BY timestamp DESC LIMIT 1"
    | math "value" 
    | revealImage origin="bottom" image={asset 
    | switch 
    {case if={compare eq to=1} then="asset-408ac6c1-42d8-4ce5-87f3-7bf90bc26a6d"}
    {case if={compare eq to=0} then="asset-3812f249-cefe-4c90-9568-6d61477b7293"}
    default="asset-df5a0609-c5fa-4c3e-bc2e-d539b38749a8"
    }
     emptyImage={asset 

    | switch 
    {case if={compare eq to=1} then="asset-408ac6c1-42d8-4ce5-87f3-7bf90bc26a6d"}
    {case if={compare eq to=0} then="asset-3812f249-cefe-4c90-9568-6d61477b7293"}
    default="asset-df5a0609-c5fa-4c3e-bc2e-d539b38749a8"
    }
    | render

Any hint about the issue?

Thanks a lot in advance!

The asset in ...image={asset | switch... expects an id argument. Although I think you could just remove asset | and use image={switch ....

Hi @nickpeihl, thanks for the reply.
I found the problem...I've just substituted asset | with asset {....}, now it works fine:

| essql query="SELECT value FROM \"dummydata\" as Value ORDER BY timestamp DESC LIMIT 1"
| math "value" 
| revealImage origin="bottom" image={asset {
 switch 
{case if={compare eq to=1} then="asset-408ac6c1-42d8-4ce5-87f3-7bf90bc26a6d"}
{case if={compare eq to=0} then="asset-3812f249-cefe-4c90-9568-6d61477b7293"}
default="asset-df5a0609-c5fa-4c3e-bc2e-d539b38749a8"
}}
 emptyImage={asset {

switch 
{case if={compare eq to=1} then="asset-408ac6c1-42d8-4ce5-87f3-7bf90bc26a6d"}
{case if={compare eq to=0} then="asset-3812f249-cefe-4c90-9568-6d61477b7293"}
default="asset-df5a0609-c5fa-4c3e-bc2e-d539b38749a8"
}}
| render
2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.