Widget support

I’m trying to take over the echarts gauge-grade and customize for Air Quality display like this

My problem is I can’t seem to get the syntax right for the “formatter” property

First case it’s executed as expected, second it fails to evaluate


Is it my mistake or is it a limitation?

Platform information:
    Hardware: i3 3.7GHz/8GB/SSD128GB
    OS: Windows 10 Pro
    Java Runtime Environment: zulu11
    openHAB version: 3.2.0

I suspect you have hit a limitation. {value} is specifically the echarts syntax, not the OH widget syntax, so your expression is not being parsed properly by the yaml expression parser (jsep). It is always returning the false value because as far as jsep is concerned the string literal {value} does not equal the string literal "50".

Echarts does have a syntax for complex formatter expressions, but you have to build a js function. I haven’t tried, but I don’t think there’s any way that OH is going to pass that properly to the echarts parser.

hmm… but in the first case, the {value} is evaluated as expected as you can see in the top part of the picture. isn’t it?

I did try the complex formatter expressions approach but that indeed is too much for OH to take.

Correct. The widget parser is just concatenating two string literals and passing that new resultant string literal along to the echart. The content of those string literals is irrelevant to it. And echarts can handle that sort of simple form as a string literal (presumably with basic string replacement).

I just don’t know if there’s a way in the widget yaml to create the function (... syntax necessary for the complex formatter that gets passed on in such a way that echarts will know to evaluate the function instead of just treating that as a string.