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).

Typical XML settings for the labels are:

XML Syntax
Plain code
01 <labels enabled="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
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 Horizontal 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". In case of Horizontal Linear Gauges "Inside" means position of labels above the scale, "Center" - inside the scale and "Outside" - under the scale. 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. For "Center" and "Outside" states of align attribute positive values move the label downwards, and negative - upwards. For the "Inside" state positive - upwards, negative - downwards. Let's imagine we want to create a gauge with labels standing under the scale and that some distance should separate them. We use the following settings:

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

The result is as follows:

Live Sample:  Sample Horizontal 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="-90" />

So, we rotate our labels 90 degrees CCW:

Live Sample:  Sample Horizontal 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 "$", make label bold, set number of decimal signs after zero to 2, change label's opacity, color label's background in yellow and the label itself - in red:

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

 

Live Sample:  Sample Horizontal 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 Horizontal First-Last

to top