Gauge w/ fixed format display

Hi!
I can't find it:
Gauge gets a number, like 19.234 , 19.29 or just 19. I want to display 19.2 , 19.3 19.0 . I can round but then 19.0 is rendered as 19.
What's the simple trick I just do not see? This must be a common use case. This was different but easy in DB1.
Cheers, Uwe

The method (currently) is to use a "Change" node before the Gauge to format the msg.payload as it's sent in.

Appreciate this is not the most friendly developer experience though. I'll get a PR added. @Steve-Mcl FYI - I'm going to set this up using the TypedInput approach you had on that huge PR that we've never got round to fixing.

I started an experiment that changed the flawed approach to that PR.

It used the same syntax as DB1 (ala angular pipe & vue-2 filters) and did client side formatting e.g.: format: "value | number : '1.2-2'" or "value.title | titleCase"

But never got around to making anything more than a geeky demo of it.

The typed input would be the ideal but its a minefield. It becomes a 2 way (sometimes 3 way) struggle between the entered value, dynamic 'ui_update's and other factors. However, your more intimate knowledge of the DB2 mechanics and vue might make this fly (I can certainly assist once a pattern is formed)

Can you document on Supporting typedInputs and simplified dynamic property setup by Steve-Mcl · Pull Request #1237 · FlowFuse/node-red-dashboard · GitHub why that got blocked and what the issues were, just so it's recorded please

Almost 1 year ago :man_s_shoe: :brain:

I am certain I wrote up the thing that killed it. Will check slack and other places before attempting to parse it all back into the old grey matter and risk forgetting something important, like how to walk or program :wink:

I've opened UI Gauge - Add a TypedInput to support value formatting by joepavitt · Pull Request #1752 · FlowFuse/node-red-dashboard · GitHub which will add this as a new feature

The method (currently) is to use a "Change" node before the Gauge to format the msg.payload as it's sent in.

I don't get it. Documentation states

Values for the gauges can be set by sending a numerical value in msg.payload. The gauge will then update to reflect this value.

Yes, I round 19.011 to 1 digit, but the number 19.0 is then still rendered as '19', not '19.0' .

As far as my limited knowledge takes me, I can not achive what I want.

What really, really strucks me is that nobody disliked that behaviour so far. Migrating from DB1 to DB two this popped up at once and I really missed DB1 Value format {{value | number:1}}.

I can not follow the technical discussion below but providing a format string to render a number provided in msg.payload should be easy, shouldn't it?

I use JSONata $formatNumber(number, picture [, options]) elsewhere, but a String cannot be fed to a gauge ...

There have been several discussions about this, eg https://discourse.nodered.org/t/cloning-d1-nodes-with-value-format-was-easy-what-is-the-best-d2-approach/96638

Are you sure? It seems to work for me.


Alas, there are plenty of other reasons to shun the ui-gauge!

Strings def work with gauge

Once the PR I've linked has been reviewed, then we can do a release, and it'll be much easier. Possibly this afternoon, probably early next week.

[{"id":"e8353a7ab039d70c","type":"change","z":"aca56a30ae9c5750","name":"Number Format","rules":[{"t":"set","p":"payload","pt":"msg","to":"$formatNumber(payload, \"#,#0.0\")\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":760,"wires":[["b9c06c3fc983e0e0"]]}]

zero_in_gauge

My apologies ... I think I tried, now I tried again, et voilà. Strings can be sent to a gauge.