[]
The quick start guides you through the steps of adding a LinearGauge control to your MVC web application and set its value. For information on how to add a control, See Adding controls.
To accomplish this, follow these steps:
Create a new MVC application using the ComponentOne or VisualStudio 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()
.From the Solution Explorer, expand the folder Views.
Double click Index.cshtml
to open it.2. Replace the default code of the Index.cshtml
file with the code given below to initialize a LinearGauge control and set the following properties:
@(Html.C1().LinearGauge()
.Width(500)
.Height(100)
.Value(35)
.Thickness(0.1)
.Min(0).Max(100)
.Direction(C1.Web.Mvc.GaugeDirection.Right)
// Create and Customize Ranges
.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))
)
)
type=note
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.