Version

Configuring the Scale (XamLinearGauge)

Purpose

This topic explains, with examples, how to customize the scale of the XamLinearGauge™ control. This includes positioning the scale inside the control and configuring the scale tick marks and labels. (For the default settings, see the XamLinearGauge Overview topic.)

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic provides conceptual information about the XamLinearGauge control including its main features, minimum requirements, and user functionality.

This topic explains how to add the XamLinearGauge control to a WPF application.

Introduction

Scale configuration summary

The scale of the XamLinearGauge control is a logical entity formed by the tick marks and the (numbering) labels. The size and position of the tick marks is configured relative to the Graph area and the position of the numbering labels – relative to the inner edge of the control (the bottom edge at horizontal orientation).

The tick marks of the XamLinearGauge control identify equal intervals of measure along the graph. Two types of tick marks are supported – major and minor. Both can be positioned along the scale by adjusting the values of the respective extent-related properties which are measured against the Graph area. The tick marks’ exact count, position, look, and frequency of occurrence can be customized by property settings.

As far as the labels are concerned, various aspects of them can be configured such as position, text, format, etc..

Scale configuration summary chart

The following table explains briefly the configurable aspects of XamLinearGauge control’s scale and maps them to properties that configure them.

Configurable aspects Property Default value

Position

0.05

0.95

Min value

0

Max value

100

Major tick marks

Not set

0

0

0.02

0.2

Defined in the default theme

2.0

Minor tick marks

3.0

0.06

0.2

Defined in the default theme

1.0

Labels

0

Not set

0

0

Not set

Defined in the default theme

Configuring the Scale’s Size and Position

Overview

The scale’s size and position within the XamLinearGauge control in the along-the scale-dimension is determined relative the Graph area. This is done through a pair of properties ( ScaleStartExtent and ScaleEndExtent).

XamLinearGauge Overview 5.png

The positioning of the scale in the other (across-the-scale) dimension of the Graph area is not configurable by itself; instead, all elements comprising the scale are configured individually.

Note

Note
Note

The value of the LabelExtent property, which controls the positioning of the numbering labels, is measured relative to the height of the control when its orientation is horizontal and to its width otherwise. (For details, see Configuring Orientation and Direction.)

Property settings

The following table maps the desired behavior to its respective property settings. For an illustration of the configurable aspects, see the Example.

In order to configure: Details Use this property:.2 And set it to:

Dimension along the scale – starting position

The starting position of the scale relative to the left edge of the Graph area at horizontal orientation or to the bottom edge at vertical orientation. (When the direction of the scale is inverted, these become, respectively, the right edge at horizontal orientation and top edge at vertical orientation. For details, see Configuring Orientation and Direction.)

The desired value as a relative part the width/height of the control (depending on the orientation) presented as a fraction of 1 (e.g. 0.2 )

Dimension along the scale – ending position

The ending position of the scale relative to the left edge of the Graph area at horizontal orientation or to the bottom edge in vertical orientation. (When the direction of the scale is inverted, these become, respectively, the right edge at horizontal orientation and top edge at vertical orientation. For details, see Configuring Orientation and Direction.)

The desired value as a relative part the width/height of the control width/height (depending on the orientation) presented as a fraction of 1 (e.g. 0. 8 )

Example

The screenshot below demonstrates how the XamLinearGauge would look as a result of the following settings:

Property Value

ScaleStartExtent

0.2

ScaleEndExtent

0.9

XamLinearGauge Configuring the Scale 1 17 1.png

Following is the code that implements this example.

In XAML:

<ig:XamLinearGauge x:Name="linearGauge"
                 ScaleStartExtent="0.2"
                 ScaleEndExtent="0.9" />

In C#:

linearGauge.ScaleStartExtent = .2;
linearGauge.ScaleEndExtent = .9;

In Visual Basic:

linearGauge.ScaleStartExtent = ".2"
.ScaleEndExtent = ".9"

[[_Configuring_the_Scale’s]]

Configuring the Scale’s Range

Overview

The values of the scale are defined by specifying its value range, that is, its minimum and maximum values. This is done with the MinimumValue and MaximumValue properties.

Setting the minimum and maximum values implicitly defines all values within the scale; all values are meant as evenly distributed between the minimum and maximum values. However, only those values are displayed for which there is a numbering label, placed on the scale. (The scale’s values can be displayed only through the numbering labels. The labels display the respective values based on the label’s position on the scale, i.e. the labels’ values are configured through the positioning of the labels along the scale and not set explicitly.) There is no requirement to have labels at the positions of the minimum and maximum values which means that the minimum and maximum values may not be indicated visually on the scale and the scale can look something like this:

XamLinearGauge Configuring the Scale 2 17 1.png

Having the scales’ range defined also enables the positioning of the other value-based visual elements on the scale, namely the comparative ranges and the needle. Note that because these elements are value-based, when the scale’s range changes (i.e. when either its minimum or maximum value (or both) changes), these visual elements are re-positioned spatially together with the scale’s values keeping their position on the scale.

Property settings

The following table maps the desired behavior to its respective property settings. For an illustration of the configurable aspects, see the Example.

In order to configure: Details Use this property: And set it to:

The minimum value of the scale

The value at which the scale starts.

The desired value in the measures of the scale

The maximum value of the scale

The value at which the scale ends.

The desired value in the measures of the scale

Example

The screenshot below demonstrates how the XamLinearGauge would look as a result of the following settings:

Property Value

MinimumValue

60

MaximumValue

70

XamLinearGauge Configuring the Scale 3 17 1.png

Following is the code that implements this example.

In XAML:

<ig:XamLinearGauge x:Name="linearGauge"
                     MinimumValue="60"
                     MaximumValue="70" />

In C#:

linearGauge.MaximumValue = 70;
linearGauge.MinimumValue = 60;

In Visual Basic:

linearGauge.MinimumValue = "60"
.MaximumValue = "70"

Configuring the Scale’s Major Tick Marks

Overview

The major tick marks of the XamLinearGauge control can be customized in terms of position and interval at which they occur. The height, thickness, and color of the line segments that forms the major tick marks are configurable as well.

Configuring the position along the scale, count, and spacing

The major tick marks are defined in terms of starting and ending points (the positions of the first and the last tick marks relative to the edges of the Graph area and the interval (the distance from each other) at which they occur. (This is done through the TicksPostInitial, TicksPreTerminal, and Interval properties.) This way, defining the starting and ending points of the major tick marks essentially defines the position and length of the scale.

XamLinearGauge Overview 7.png

Configuring the position across the scale and the length of the segments

In the across-the-scale dimension, the length and position of the line segments that form the major tick marks is configured relative to the edges of the Graph area. (This is done through the TickStartExtent and TickEndExtent properties.)

XamLinearGauge Overview 8.png

Property settings

The following table maps the desired behavior to its respective property settings. For an illustration of the configurable aspects, see the Example.

In order to configure: Details Use this property:.2 And set it to:

Position along the scale, count, and spacing - starting point

The distance at which the major tick marks begin relative to the starting position of the scale

The desired distance (in the measures of the scale) from scale start position

Position along the scale, count, and spacing - ending point

The distance at which the major tick marks end relative to the ending position of the scale

The desired distance (in the measures of the scale) from the scale end position

Position along the scale, count, and spacing - interval

The interval at which to place the major tick marks (Interval is the distance – in the measures of the scale – between two adjacent major tick marks.)

The desired value in measures of the scale

Position across the scale and length of the segments - starting point

The starting point of the line segments that form the major tick marks. (The starting point is defined relative to the bottom of the Graph area in horizontal orientation or to the left edge of the Graph area in vertical orientation.) Negative values are supported as well, indicating positions beneath/ on the left of the Graph area.

The desired value (in the measures of the scale) as a relative part the height/width of the Graph area (depending on the orientation) presented as a fraction of 1 (e.g. 0.2 )

Position across the scale and length of the segments - ending point

The ending point of the line segments that form major tick marks relative to the bottom of the Graph area in horizontal orientation or to the left border of the Graph area in vertical orientation. Negative values are supported as well, indicating positions beneath/ on the left of the Graph area. (The difference between the starting and the ending points forms the length of the marks’ line segments.)

The desired value as a relative part the height/width of the Graph area (depending on the orientation) presented as a fraction of 1 (e.g. 0. 8

Thickness

The thickness of the major tick marks’ line segments.

The desired value in pixels

Color

The color of the major tick marks

The desired color

Example

The screenshot below demonstrates how the XamLinearGauge looks as a result of the following settings:

XamLinearGauge Configuring the Scale 4 17 1.png

Following is the code that implements this example.

In XAML:

<ig:XamLinearGauge x:Name="linearGauge"
                     Interval="30"
                     TickBrush="Lime"
                     TickEndExtent="0.9"
                     TicksPostInitial="30"
                     TicksPreTerminal="10"
                     TickStartExtent="0.5"
                     TickStrokeThickness="3" />

In C#:

linearGauge.Interval = 30;
linearGauge.TickBrush = new SolidColorBrush(Color.FromRgb(128, 255, 0));
linearGauge.TickEndExtent = .9;
linearGauge.TicksPostInitial = 30;
linearGauge.TicksPreTerminal = 10;
linearGauge.TickStartExtent = .5;
linearGauge.TickStrokeThickness = 3;

In Visual Basic:

linearGauge.Interval = "30"
linearGauge.TickBrush = New SolidColorBrush(Color.FromRgb(51, 255, 51))
linearGauge.TickEndExtent = ".9"
linearGauge.TicksPostInitial = "30"
linearGauge.TicksPreTerminal = "10"
linearGauge.TickStartExtent = ".5"
linearGauge.TickStrokeThickness = "3"

Configuring the Scale’s Minor Tick Marks

Overview

The minor tick marks of the XamLinearGauge control can be explicitly disabled or customized in terms of number (between two major tick marks), positioning, size, and color.

Configuring the position along the scale, count, and spacing

The minor tick marks are defined as a count (the number of minor tick marks between two adjacent major tick marks). (This is done through the MinorTickCount property; setting this property to 0 disables (hides) the minor tick marks.) When the count is set, the specified number of minor tick marks is placed evenly between every two adjacent major tick marks, from the first one, to the last.

Configuring the position across the scale and the length of the segments

In the across-the-scale dimension, the minor tick marks length and position is configured relative to the edges of the Graph area.

XamLinearGauge Overview 9.png

Property settings

The following table maps the desired behavior to its respective property settings. For an illustration of the configurable aspects, see the Example.

In order to configure: Details Use this property: And set it to:

Number and spacing

The number of minor tick marks between two adjacent major tick marks.

The desired number; setting of 0 hides the minor tick marks

Starting point

The starting point of the line segments that form the minor tick marks. (The starting point is defined relative to the bottom of the Graph area in horizontal orientation or to the left edge of the Graph area in vertical orientation.) Negative values are supported as well, indicating positions beneath/ on the left of the Graph area.

The desired value as a relative part the height/width of the control height/width (depending on the orientation) presented as a fraction of 1 (e.g. 0.2 )

Ending point

The ending point of the line segments that form minor tick marks relative to the bottom of the Graph area in horizontal orientation or to the left border of the Graph area in vertical orientation. Negative values are supported as well, indicating positions beneath/ on the left of the Graph area. (The difference between the starting and the ending points forms the length of the marks’ line segments.)

The desired value as a relative part the height/width of the control height/width (depending on the orientation) presented as a fraction of 1 (e.g. 0.2 5 )

Thickness

The thickness of the minor tick marks

The desired value in pixels

Color

The color of the minor tick marks

The desired color

Example

The screenshot below demonstrates how the XamLinearGauge looks as a result of the following settings:

XamLinearGauge Configuring the Scale 5 17 1.png

Following is the code that implements this example.

In XAML:

<ig:XamLinearGauge x:Name="linearGauge"
                     MinorTickBrush="Purple"
                     MinorTickCount="4"
                     MinorTickEndExtent="0.1"
                     MinorTickStartExtent="0.05"
                     MinorTickStrokeThickness="2"
                     Interval="20" />

In C#:

linearGauge.MinorTickBrush = new SolidColorBrush(Color.FromRgb(153, 0 , 153));
linearGauge.MinorTickCount = 4;
linearGauge.MinorTickEndExtent = .1;
linearGauge.MinorTickStartExtent = .05;
linearGauge.MinorTickStrokeThickness = 2;
linearGauge.Interval = 20;

In Visual Basic:

linearGauge.MinorTickBrush = New SolidColorBrush(Color.FromRgb(102, 0, 102))
linearGauge.MinorTickCount = "4"
linearGauge.MinorTickEndExtent = ".1"
linearGauge.MinorTickStartExtent = ".05"
linearGauge.MinorTickStrokeThickness = "2"
linearGauge.Interval = "20"

Configuring the Scale’s Labeling

Overview

By default, the labels indicating the scale’s measures are enabled. The labels are defined in terms of the following factors:

  • Starting and ending points – the positions of the first and the last label relative to the edges of the scale

  • Breadth of the label row – relative to the height/width of the control, depending on the orientation (vertical/horizontal). The breadth can be controlled only indirectly by the font settings in the applied style template.

  • The interval (the distance from each other) at which they occur. (This is done through the LabelsPostInitial, LabelsPreTerminal and LabelInterval properties.)

  • The position of the label row in the across-the-scale dimension – the default is at the bottom / on the left of the control (for horizontal or vertical orientation, respectively); the entire row can be shifted vertically at horizontal scale orientation or horizontally at vertical scale orientation. (This is done through the LabelExtent property.)

XamLinearGauge Overview 6.png

The value that each label displays is defined by the value represented by its position on the scale (This requires configuring the scale’s value range.) A string format can be applied to the labels so that their look is additionally customized. By default, a numeric label is displayed for each of the major tick marks and the labels are positioned beneath / on the left of the scale depending on the scale’s orientation (horizontal/vertical, respectively).

If you customize the labels and the major tick marks, you will more likely need to make sure they align to each other; to achieve alignment, set the same value for the tick marks interval ( Interval property) and the label interval (LabelInterval property). (By default, they are aligned because the LabelInterval property is not set and uses the value set for Interval.)

Event handling

The labels of XamLinearGauge can be additionally formatted and aligned on handling the corresponding events.

The following table maps the desired behavior to its respective event.

In order to: Handle this event:

Format the labels

Align the labels

Property settings

The following table maps the desired behavior to its respective property settings. For an illustration of the configurable aspects, see Example – horizontal orientation.

In order to configure: Details Use this property:.2 And set it to:

Position

The positioning of the label row relative to bottom/left edge of the control (depending on the orientation – vertical/horizontal).

The desired value presented as a relative part the height/width of the control (depending on the orientation – vertical/horizontal) presented as a fraction of 1 (e.g. 0. 8 ).

Starting point

Position (in the measures of the scale) of the first label along the scale

The value (in the measures of the scale) at which the first label of the scale is to be displayed

Ending point

Position (in the measures of the scale) of the last label along the scale

The value (in the measures of the scale) at which the last label of the scale is to be displayed

Interval

The interval at which to place the labels (Interval is the distance between two adjacent labels in the measures of the scale.)

The desired value in the measure of the scale

String format

The string format of the labels (e.g. numeric, time, composite, etc.)

The desired string format (e.g. {0:c} for displaying currency values)

Font color

Font color of the labels

The desired color

Example – horizontal orientation

The screenshot below demonstrates how the XamLinearGauge looks as a result of the following settings with the default horizontal scale orientation:

XamLinearGauge Configuring the Scale 6 17 1.png

Following is the code that implements this example.

In XAML:

<ig:XamLinearGauge x:Name="linearGauge"
                 LabelExtent="0.8"
                 LabelInterval="30"
                 LabelsPostInitial="20"
                 LabelsPreTerminal="20"
                 FontBrush="Green"  />

In C#:

linearGauge.LabelExtent = .8;
linearGauge.LabelInterval = 30;
linearGauge.LabelsPostInitial = 20;
linearGauge.LabelsPreTerminal = 20;
linearGauge.FontBrush = new SolidColorBrush(Color.FromRgb(0, 153, 0));

In Visual Basic:

linearGauge.LabelExtent = ".8"
linearGauge.LabelInterval = "30"
linearGauge.LabelsPostInitial = "20"
linearGauge.LabelsPreTerminal = "20"
linearGauge.FontBrush = New SolidColorBrush(Color.FromRgb(0, 255, 0))

Example – vertical orientation

The screenshot below demonstrates how the XamLinearGauge looks as a result of the following property settings (same as in Example – horizontal orientation) and vertical orientation:

XamLinearGauge Configuring the Scale 7 17 1.png

Following is the code that implements this example.

In XAML:

<ig:XamLinearGauge x:Name="linearGauge"
                 Orientation="Vertical"
                 LabelExtent="0.8"
                 LabelInterval="30"
                 LabelsPostInitial="20"
                 LabelsPreTerminal="20"
                 FontBrush="Green" />

In C#:

linearGauge.Orientation = LinearScaleOrientation.Vertical;
linearGauge.LabelExtent = .8;
linearGauge.LabelInterval = 30;
linearGauge.LabelsPostInitial = 20;
linearGauge.LabelsPreTerminal = 20;
linearGauge.FontBrush = new SolidColorBrush(Color.FromRgb(0, 153, 0));

In Visual Basic:

linearGauge.Orientation = LinearScaleOrientation.Vertical;
linearGauge.LabelExtent = ".8"
linearGauge.LabelInterval = "30"
linearGauge.LabelsPostInitial = "20"
linearGauge.LabelsPreTerminal = "20"
linearGauge.FontBrush = New SolidColorBrush(Color.FromRgb(0, 255, 0))

Related Content

The following topics provide additional information related to this topic.

Topic Purpose

This topic explains how to configure the XamLinearGauge control with vertical scale and/or inverted scale direction.

This topic explains, with code examples, how to configure the title and subtitle of the XamLinearGauge control. This includes the title area width the start position of the text and the title/subtitle text itself.

This topic explains, with examples, how to configure the needle of the XamLinearGauge control. This includes the value it indicates, its width, position, and formatting.

This topic explains, with code examples, how to configure ranges in the XamLinearGauge control. This includes the number of ranges and their positions, lengths, widths, and formatting.

This topic explains, with code examples, how to configure a background for the linear gauge. This includes setting the background’s size, position, color, and border.

This topic explains, with code examples, how to enable the tooltips in the XamLinearGauge control and configure the delay with which they are displayed.

Resources

The following material (available outside the Infragistics family of content) provides additional information related to this topic.

Title Purpose

An MSDN overview article on formatting types with sub-articles on the specific string formats.