New to Telerik UI for ASP.NET MVC? Download free 30-day trial

Getting Started with the Linear Gauge

This tutorial explains how to set up a basic Telerik UI for ASP.NET MVC Linear Gauge and highlights the major steps in the configuration of the component.

You will initialize a Linear Gauge and set up the Scale property, which configures the visualization of the gauge. Then, you will use JavaScript to update the value of the Linear Gauge using its client-side reference.

Sample Telerik UI for ASP.NET MVC Linear Gauge


To successfully complete the tutorial, you need a project that is already configured to use the Telerik UI for ASP.NET MVC components:

1. Prepare the CSHTML File

The first step is to add the required directives at the top of the .cshtml document:

  • To use the Telerik UI for ASP.NET MVC HtmlHelpers:

    @using Kendo.Mvc.UI

Optionally, you can structure the document by adding the desired HTML elements like headings, divs, and paragraphs. In this tutorial, you will also apply some styles to the gauge and its container.

    <h2>Tempretature scale of the Pasteurization Process</h2>
    <div class="legend">
        <div class="legend-item">
            <span class="color red"></span>
                Temperature is too high.
        <div class="legend-item">
            <span class="color yellow"></span>
                Temperature is right for pasteurization.
        <div class="legend-item">
            <span class="color blue"></span>
                Temperature is too low.
    <div id="gauge-container">
            <!-- Component Configuration -->
        #gauge-container {
            text-align: center;
            margin: 0 auto;
            background: transparent url("@Url.Content("~/shared/dataviz/gauge/linear-gauge-container.png")") no-repeat 50% 50%;
            background-size: contain;
            padding: 18px;
            width: 320px;
            height: 320px;

        #gauge {
            height: 100%;
            display: inline-block;
            zoom: 1;
            flex-direction: row;
            width: 15px;
            height: 15px;

2. Initialize the Linear Gauge

Use the Linear Gauge HtmlHelper to add the component to a page:

  • The Name() configuration method is mandatory as its value is used for the id and the name attributes of the Linear Gauge element.
  • Utilize the LinearGaugePointerBuilder's Value method to set an initial value for the Linear Gauge.
    @using Kendo.Mvc.UI

          .Pointer(pointer => pointer.Value(56))

3. Configure the Linear Gauge

Configure the Scale configuration method of the Linear Gauge. It exposes the LinearGaugeScaleSettingsBuilder which allows you to set up the Min, Max, MajorTicks, MinorTicks, Labels and Ranges properties.

The Ranges property exposes the following configuration methods that are responsible for the graphics rendering of the component:

  • From — The start position of the range in scale units.
  • To — The end position of the range in scale units.
  • Color — The color of the range. Any valid CSS color string will work here, including hex and rgb.
  • Opacity — The opacity of the range.

Finally, fine tune the size and the position of the component with the GaugeAreas's Height and Margin properties.

    @using Kendo.Mvc.UI

          .Pointer(pointer => pointer.Value(56))
          .Scale(scale => scale
              .Ranges(ranges =>

4. (Optional) Reference Existing Linear Gauge Instances

You can reference the Linear Gauge instances that you have created and build on top of their existing configuration:

  1. Use the id attribute of the component instance to establish a reference.

        $(document).ready( function (e) {
            var lineargaugeReference = $("#gauge").data("kendoLinearGauge"); // lineargaugeReference is a reference to the existing Linear Gauge instance of the helper.
  2. Use the Linear Gauge client-side API to control the behavior of the component. In this example, you will use the value method to change the value of the Linear Gauge every second to ensure that the visualized thermometer is exact.

            updateValue(temperatureSensor); // update the value of the Linear Gauge based on external input every second
        function updateValue(number) {
            var gauge = $("#gauge").data("kendoLinearGauge");

Next Steps

See Also

In this article