ASP.NET MVC Controls > Controls > Gauge > Quick Start: Add and Configure > RadialGauge Quick Start |
This section describes how to add a RadialGauge control to your MVC webform and set its value. For information on how to add a control, See Adding controls.
This topic comprises of three steps:
The following image shows how the RadialGauge appears, after completing the steps above:
Create a new MVC application using the ComponentOne templates. For more information about creating an MVC application, see Configuring your MVC Application topic.
Add a new Controller:
Default1Controller
).Add a View for the controller:
Default1Controller
) to open it.Index()
.Add a Model
Models are required to fetch data for the controls. See MVC Basics for more information.
Class1.cs
).Index.cshtml
to open it.Index.cshtml
file with the code given below to initialize a RadialGauge and set the following properties:
Value
to 35. The Value
property denotes the gauge's current value.Max
properties to 0 and 100 respectively. The Min and Max
properties specify the range of the gauge. You can add multiple ranges to a single gauge.isReadOnly
property to False. The isReadOnly specifies whether a user can edit the gauge's Value
using a keyboard or a mouse.Razor |
Copy Code
|
---|---|
@(Html.C1().RadialGauge()
.Value(35)
.Width(500)
.Height(200)
.Min(0).Max(100)
.StartAngle(-20)
.SweepAngle(220)
.ShowText(ShowText.None)
.AutoScale(true)
.Ranges(items => items
.Add(item => item.Min(0).Max(40).Color(System.Drawing.Color.Red))
.Add(item => item.Min(40).Max(80).Color(System.Drawing.Color.Yellow))
.Add(item => item.Min(80).Max(100).Color(System.Drawing.Color.Green))
)
)
|
HTML |
Copy Code
|
---|---|
<c1-radial-gauge min=0 max=100 value=35 start-angle=-20 sweep-angle=220 show-text=C1.Web.Mvc.ShowText.None width="300px" height="180px" auto-scale="true"> <c1-gauge-range min="0" max="40" color="red"></c1-gauge-range> <c1-gauge-range min="40" max=80 color="yellow"></c1-gauge-range> <c1-gauge-range min="80" max="100" color="green"></c1-gauge-range> </c1-radial-gauge> |
Append the folder name and view name to the generated URL (for example: http://localhost:1234/Default1/index) in the address bar of the browser to see the view. Or link the view to the home page. |