scale label

Specifies common options for scale labels.

Type: Object

Scale labels represent textual values for major scale ticks. The label object exposes properties that allow you to specify custom text for scale labels and properties to change the text font.

Show Example:
jQuery

In this example, the text of the scale labels is customized using the customizeText option. In addition, the color and size options of the scale label text are changed.

<div id="linearGaugeContainer" style="height:150px;max-width:700px;margin:0 auto"></div>
$(function () {
    $("#linearGaugeContainer").dxLinearGauge({
        rangeContainer: { backgroundColor: 'mediumturquoise' },
        valueIndicator: { color: 'lightgreen' },
        scale: {
            startValue: 0,
            endValue: 100,
            label: {
                customizeText: function (label) {
                    return label.valueText + ' mph';
                },
                font: {
                    color: 'dodgerblue',
                    size: 14
                }
            }
        },
        value: 32
    });
});

customizeText

Specifies a callback function that returns the text to be displayed in scale labels.

Type: function(scaleValue)
Function parameters:
scaleValue: Object
Defines a scale value.
Object structure:
value: Number
Specifies the scale value represented by a label.
valueText: String
Specifies the scale value with an applied format, if the format and precision (optional) properties are specified.
Return Value: String
The text to be displayed by a scale label.

When implementing a callback function for this property, use the scale value to be displayed in a label. This value can be accessed using the fields of the object that is passed as the function's parameter. Alternatively, you can use the this object within the function. This object has the same structure as the object passed as a parameter.

For general information on data formatting, refer to the Data Formatting topic.

Show Example:
jQuery

In this example, the text of the scale labels is customized using the customizeText option.

<div id="linearGaugeContainer" style="height:150px;max-width:700px;margin:0 auto"></div>
$(function () {
    $("#linearGaugeContainer").dxLinearGauge({
        rangeContainer: { backgroundColor: 'palegreen' },
        valueIndicator: { color: 'lightgreen' },
        scale: {
            startValue: 0,
            endValue: 100,
            label: {
                customizeText: function (label) {
                    return label.valueText + ' mph';
                }
            }
        },
        value: 64
    });
});

font

Specifies font options for the text displayed in the scale labels of the gauge.

Type: Object

Show Example:
jQuery

In this example, font options of the scale labels are changed.

<div id="linearGaugeContainer" style="height:150px;max-width:700px;margin:0 auto"></div>
$(function () {
    $("#linearGaugeContainer").dxLinearGauge({
        rangeContainer: { backgroundColor: 'turquoise' },
        valueIndicator: { color: 'lightblue' },
        scale: {
            startValue: 0,
            endValue: 100,
            label: {
                font: {
                    color: 'dodgerblue',
                    size: 14,
                    weight: 700,
                    family: 'Zapf-Chancery, cursive'
                }
            }
        },
        value: 13
    });
});

format

Specifies a format for the text displayed in scale labels.

Type: String
Default Value: ''
Accepted Values: 'currency' | 'fixedPoint' | 'percent' | 'decimal' | 'exponential' | 'largeNumber' | 'thousands' | 'millions' | 'billions' | 'trillions'

Labels display scale values. You can apply formatting to the label text using one of the numeric formats.

NOTE: You can set a precision for the label text using the precision option.

In addition to the predefined numeric formats, you can assign a custom format. Use format tokens from the Globalize JavaScript library to do this.

For details on formatting, refer to the Data Formatting topic.

Show Example:
jQuery

In this example, the text of the scale labels is displayed in a percent format.

<div id="linearGaugeContainer" style="height:150px;max-width:700px;margin:0 auto"></div>
$(function () {
    $("#linearGaugeContainer").dxLinearGauge({
        rangeContainer: { backgroundColor: 'steelblue' },
        valueIndicator: { color: 'mediumturquoise' },
        scale: {
            startValue: 0,
            endValue: 1,
            label: {
                format: 'percent'
            }
        },
        value: 0.86
    });
});

indentFromTick

Specifies the spacing between scale labels and ticks.

Type: Number
Default Value: -10

Show Example:
jQuery

In this example, the scale labels are indented from the scale ticks by 20 pixels.

<div id="linearGaugeContainer" style="height:150px;max-width:700px;margin:0 auto"></div>
$(function () {
    $("#linearGaugeContainer").dxLinearGauge({
        rangeContainer: { backgroundColor: 'cornflowerblue' },
        valueIndicator: { color: 'greenyellow' },
        scale: {
            startValue: 0,
            endValue: 100,
            label: {
                indentFromTick: -20
            }
        },
        value: 53
    });
});

precision

Specifies a precision for the formatted value displayed in the scale labels.

Type: Number
Default Value: 2

This field's value must be an integer indicating the number of digits to show in the scale values displayed in labels. This option can be applied only along with the format option. To learn how to set a format for scale values, refer to the format option description.

For general information on data formatting, refer to the Data Formatting topic.

Show Example:
jQuery

In this example, the text of the scale labels is displayed in a fixedPoint format with the precision set to 1.

<div id="linearGaugeContainer" style="height:150px;max-width:700px;margin:0 auto"></div>
$(function () {
    $("#linearGaugeContainer").dxLinearGauge({
        rangeContainer: { backgroundColor: 'steelblue' },
        valueIndicator: { color: 'powderblue' },
        scale: {
            startValue: 0,
            endValue: 1,
            label: {
                format: 'fixedPoint',
                precision: 2
            }
        },
        value: 0.43
    });
});

visible

Specifies whether scale labels are visible on the gauge.

Type: Boolean
Default Value: true
Accepted Values: true|false

Show Example:
jQuery

Change the visibility of the scale labels by toggling the check box under the gauge.

<div id="linearGaugeContainer" style="height:150px;max-width:700px;margin:0px auto"></div>
<div id="checkboxContainer" style="height:20px;width:300px;margin:0px auto;font-family:'Trebuchet MS',Arial,sans-serif;font-size:14px;text-align:center">
    <input type="checkbox" id="visibleScaleLabelsCheckbox" checked> Show Scale Labels
</div>

$(function () {
    $("#linearGaugeContainer").dxLinearGauge({
        rangeContainer: { backgroundColor: 'deepskyblue' },
        valueIndicator: { color: 'powderblue' },
        scale: {
            startValue: 0,
            endValue: 1,
            label: {
                visible: true
            }
        },
        value: 0.31
    });

    $('#visibleScaleLabelsCheckbox').change(function () {
        var gauge = $('#linearGaugeContainer').dxLinearGauge('instance');
        gauge.option({
            scale: {
                label: { visible: this.checked }
            }
        });
    });
});