Horizontal Gauge Labels Configuration

Overview

Axis Labels are labels that are drawn near major tickmarks. You can adjust their font size, font color, a wide range of other attributes and define their font family. Also you may choose from what side should the labels be displayed (align) and how far they should stand from the tickmarks (padding). It's your desire to decide whether labels will be rotated along the scale and define this rotation.

Typical XML settings for the labels are:

XML Syntax
Plain code
01 <labels enabled="true" rotate_circular="true" auto_orientation="true" align="Outside" padding="0" text_align="Near" rotation="0" show_first="true" show_last="false" />

Labels Parameters

The following attributes can be set for labels:

Attribute Values Default Description
enabled true | false false Sets whether labels are enabled or not
show_first true | false True Whether the label of first tickmark is shown
rotate_circular true | false False Defines whether labels are rotated along the scale.
auto_orientation true | false True Determines whether labels can be rotated more than 90 degrees (or, in other words, whether they can be displayed upside down).
show_last true | false True Whether the label of last tickmark is shown
padding Number Auto The padding of labels
align Inside | Outside | Center Center Sets the position of labels
text_align Near | Center | Far Center Defines the distance between gauge and label text
rotation Number 0 Sets the angle of label's rotation

to top

Enabling/Disabling labels

By default labels are enabled, but you can disable them this way:

XML Syntax
Plain code
01 <labels enabled="false" />

The result is as follows:

Live Sample:  Sample Circular Disabling labels

to top

Positioning Labels

There are four nodes responsible for text positioning. They are: align, text_align, padding and rotation. Let's look at some samples demonstrating the practical usage of these nodes.

In this sample we will use align and padding attributes. Align attribute has three states: "Inside", "Outside" and "Center". Padding attribute is set in percents and defines how far from the scale we move the text. Padding can be represented in positive or negative values, which affects the direction of text's movement. Let's use the following settings for labels:

XML Syntax
Plain code
01 <labels enabled="true" align="Outside" padding="10" />

The result is as follows:

Live Sample:  Sample Circular Positioning 1

to top

The rotation attribute affects on the text rotation angle and is set in degrees:

XML Syntax
Plain code
01 <labels enabled="true" rotation="-45" />

So, we rotate our labels 45 degrees CCW:

Live Sample:  Sample Circular Positioning 2

Formatting Labels

The labels can be formatted using subnodes of label node: Font, Format and Background. Let's change the label format: add a postfix "mph" and add label background:

XML Syntax
Plain code
01 <labels enabled="true" align="Inside" width="30" text_align="Center">
02   <format><![CDATA[{%Value}{numDecimals:0} mph]]></format>
03   <background enabled="true">
04     <fill enabled="True" />
05     <border enabled="True" />
06   </background>
07 </labels>

 

Live Sample:  Sample Circular Formatting

to top

Showing first and last Labels

You can choose whether to show first/last label value or not. This is done in a simple way, by setting true or false to show_first/show_last attribute:

XML Syntax
Plain code
01 <labels enabled="true" align="Inside" show_first="false" show_last="false" />

In this example we have disabled showing both first and last labels:

Live Sample:  Sample Circular First-Last

to top

Rotating labels along the Scale

You can decide whether your labels will be rotated along the axis scale. auto_orientation attribute is responsible for it. By default it is off. Let's turn it on. We also enable auto_orientation to prevent labels to be shown upside down when they indicate values that are set to more than 180 degrees.

That's what we get:

Live Sample:  Sample Circular Auto Orientation

to top