You may have seen my other post about getting a tank with a fill level, i settled on the progress bar as shown below on top of a svg for that, however i did not like the text inside it so I am using a text field, but I need the % to show after the number but when I use the format it takes my 32 to 3,200%, pictures below, any idea I need to do to get it to format to ##%, thank you.
The percent format is deliberately designed to take ratio values from 0.0 to 1.0 to show as 0% to 100%. You will need to use a plain numeric format.
what do you mean by a "plain numeric format" I see pattern integer number percent currency, am I missing something?
When using "pattern", you manually create the format. It is essentially the same behavior as the numberFormat() expression function, which also handles the percent sign with the 100x behavior. Unless you quote it in the pattern to avoid that. See the example in the linked documentation.
Expressions and scripts are not the same thing.
But you don't need either. Just put 0.0'%'
into the format transform's pattern. Note the single quotes around the percent sign to take away its special behavior.
For posterities sake,
The script transform errors because you do not have the correct indentation, nor are you actually using the value and returning it from the transform.
The correct script would look something like this:
def transform(self, value, quality, timestamp):
from java.text import DecimalFormat
df = DecimalFormat("#0.00'%'")
return df.format(value)
The expression transform errors because the entered text isn't a valid expression. You're also not using the value here. The correct expression would look something like:
numberFormat({value}, "#0.00'%'")
By far the better approach in this case is the one provided by Phil, but I thought I would point out why what you tried didn't work, when it will also work but is more complex and less performant.