User Tools

Site Tools


gauges:dynamic_labels

Dynamic Labels in Gauges

Using dynamic labels you can make your gauges change the appearance based on data values. Those can be changed either by user request or normal data. It is possible to replace image-bands by dynamic labels, without any performance loss.
The extended Tag looks as follows:

<Element id="mybackground">
		<Label Font="LCDMono2" FontStyle="Bold" FontSize="48">
			<TextExpression>(T:IRACING/CAR/FUELLEVEL) 10 * % 10 /</TextExpression>
			<TextFormat HorizontalAlignment="Far">{0:F1}</TextFormat>
			<Position X="225" Y="383" />
			<Size X="230" Y="71" />			
			<Color Background="Transparent" Foreground="White" />
		</Label>
</Element>

When displaying the label on the gauge, SPAD.neXt will evaluate the expression (TextExpression) and format its result according to the TextFormat.

In the example the result will be evaluated as

 Truncate(FUELLEVEL * 10) / 10 

, formatted as floating point number with one decimal (Standard numeric format strings) and written right-aligned (HorizontalAlignment=“Far”) to the gauge using the LCDMono2-Font in a box (225,383,455,451). Everything that is not fitting into the box will be cut off.

As Font every installed font on the system as well as those defined in the gauge (see SPAD.neXt GaugeSettings) can be used. If the font is not found Tahoma will be used.

Possible Alignment Settings:

  • “Near” = Left-/Top-aligned
  • “Center” = Center aligned
  • “Far” = Right-/Bottom-aligned

TextFormat

The value of the TextExpression will be used as Parameter 0 for the format string.
It is possible to use all standard formatting rules according to Composite Formatting

Dynamic Colors

The <Color>-Tag can be expaned to contain dynamic expressions for the color.

<Color Background="Transparent" Foreground="White">
     <BackgroundValue></BackgroundValue>
     <ForegroundValue></ForegroundValue>
</Color>

If BackgroundValue/ForegroundValue tags are present the default values will be ignored and the given expressions will be evaluated. Expressions have to be in SPAD.neXt format (see custom expression) and will always be interpreted as a string.

To reference Gauge/Profile/Device scoped variables in the expression you can use the prefixes GAUGE: PROFILE: DEVICE:

Example:

<Color Background="Transparent" Foreground="White">
     <BackgroundValue>[GAUGE:MY_COOL_VARIABLE_NAME]</BackgroundValue>
     <ForegroundValue>[DEVICE:MY_EVEN_COOLER_VARIABLE_NAME]</ForegroundValue>
</Color>

The expression can eiter return a KnownColor or a hexadecimal value in form '#AARRGGBB' (ARGB32)

gauges/dynamic_labels.txt · Last modified: 2020/12/23 14:07 by c0nnex