How to Display Various Symbols in Calculation Results Using Unicode

Very often it is useful to display some sort of symbol in the calculation results. The good news is that you are not limited only to traffic lights (see How to Use Traffic Lights in Data Tables).
It is possible to leverage symbols provided by the Unicode standard (those that are supported by font) and use them in the outputs of calculation logics.


In the example below, the requirement was to display the "red" or "green" status of a specific metric in the calculation results.

To achieve that, we use the Unicode symbol FISHEYE and the Pricefx feature "api.attributedResult(...).withTextColor(...)" to return the symbol in color:


Unicode Symbols

Useful links to find the right symbol:

Unicode in Groovy

The "escape syntax" for Unicode characters can be used when you need to use "special" Unicode characters in the Groovy source code (note that the same applies to Java).

The escape syntax is as follows:

"\u<hexacode>" or "\U<hexacode>"

So for example, when you need to show the below circle, you can use the Unicode symbol FISHEYE that has code "\u25C9", as you can see in the example below:


And this is the output, the way the symbol is displayed in Pricefx.

In the "classic" UI, in Table View:

In Unity UI - Table View:

In Unity UI - Tree View: