# Getting Started with the ArcGauge

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

You will initialize an ArcGauge component with different colors depending on the current value. Next, you will use the built-in client-side methods to update the ArcGauge options and change its value dynamically.

![Sample Telerik UI for ASP.NET MVC ArcGauge](https://www.telerik.com/aspnet-mvc/documentation/assets/b210a6db293e73de6a755d2314604c60/arcgauge-getting-started.png)

## Prerequisites

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

* To create a new pre-configured project for the Telerik UI for ASP.NET MVC components, you can [use a project template](https://www.telerik.com/aspnet-mvc/documentation/getting-started-mvc/first-steps).

* To manually configure an existing project by using NuGet, see the [Adding Telerik UI through NuGet](https://www.telerik.com/aspnet-mvc/documentation/getting-started/setup-with-nuget).

## 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:

  ```cshtml
  @using Kendo.Mvc.UI
  ```

Optionally, you can structure the View content by adding the desired HTML elements like headings, divs, paragraphs, and others.

```Razor HtmlHelper
    @using Kendo.Mvc.UI

    <div id="gauge-container">

    </div>
```

## 2. Initialize the ArcGauge

Use the ArcGauge 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 ArcGauge element.
* The `Scale()` option specifies the ArcGauge scale options, like labels, the lowest and highest value, and more.
* The `Value()` option sets the initial ArcGauge value.
* The `CenterTemplate()` specifies the label template displayed in the center of the arc.

```Razor HtmlHelper
    @using Kendo.Mvc.UI

    <div id="gauge-container">
        @(Html.Kendo().ArcGauge()
            .Name("gauge")
            .Value(50)
            .Scale(x => x.Min(0).Max(100))
            .CenterTemplate("<span>#: value #%</span>")
        )
    </div>
```

## 3. Configure the Color Ranges

The next step is to set up the color ranges of the ArcGauge and update the label template to display the current value in the respective color.

```Razor HtmlHelper
    @using Kendo.Mvc.UI

    <div id="gauge-container">
        @(Html.Kendo().ArcGauge()
            .Name("gauge")
            .Value(50)
            .Scale(x => x.Min(0).Max(100))
            .CenterTemplate("<span style='color: #: color #;'>#: value #%</span>")
            .Colors(colors =>
            {
                colors.Add().From(0).To(25).Color("#0058e9");
                colors.Add().From(25).To(50).Color("#37b400");
                colors.Add().From(50).To(75).Color("#ffc000");
                colors.Add().From(75).To(100).Color("#f31700");
            })
        )
    </div>
```

## 4. (Optional) Reference Existing ArcGauge Instances

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

1. Use the `id` attribute of the component instance to get its reference.

   ```JS script
       <script>
           $(document).ready(function() {
               var arcGaugeReference = $("#gauge").data("kendoArcGauge"); // arcGaugeReference is a reference to the existing ArcGauge instance of the helper.
           });
       </script>
   ```

2. Use the [ArcGauge client-side API](https://docs.telerik.com/kendo-ui/api/dataviz/ui/arcgauge#methods) to control the behavior of the component. In this example, you will use the `value()` method to change the ArcGauge value and the `setOptions()` method to update the background color (for example, when a button is clicked).

   ```Razor HtmlHelper
       @(Html.Kendo().Button()
           .Name("btn")
           .Content("Update value")
           .Events(ev => ev.Click("onBtnClick"))
       )
   ```

   ```JS scripts
       <script>
           function onBtnClick() {
               var arcGaugeReference = $("#gauge").data("kendoArcGauge");
               if(arcGaugeReference.value() < 80) {
                   arcGaugeReference.setOptions({gaugeArea: {background: "#FFD700"}});
                   arcGaugeReference.value(80);
               }
           }
       </script>
   ```

For more information on referencing specific helper instances, see the [Methods and Events](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/helper-basics/events-and-methods) article.

## Next Steps

* [Configuring the ArcGauge Scale](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/gauges/arcgauge/scale)
* [Setting the ArcGauge Colors](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/gauges/arcgauge/colors)

## See Also

* [Client-Side API of the ArcGauge](https://docs.telerik.com/kendo-ui/api/dataviz/ui/arcgauge)

* [Server-Side API of the ArcGauge HtmlHelper](https://www.telerik.com/aspnet-mvc/documentation/api/arcgauge)

* [Knowledge Base Section](https://www.telerik.com/aspnet-mvc/documentation/knowledge-base)
