ASP .NET Core MVC Documentation

Getting Started

jqxGauge displays an indicator within a range of values. Gauges can be used in a table or matrix to show the relative value of a field in a range of values in the data region, for example, as a KPI. It supports SVG and VML rendering.

Every ASP .NET Core Mvc Tag Helper from jQWidgets toolkit needs its JavaScript files to be included in order to work properly.

jqxGauge requires the following files:

  • CSS

  • jqx.base.css
  • Javascript

  • jqxcore.js
  • jqxdraw.js
  • jqxgauge.js
The next step is to create html element within the body of the html document and add the initialization attributes.
<script src="~/jqwidgets/jqxgauge.js"></script>
@using jQWidgets.AspNetCore.Mvc.TagHelpers;
@{
List<GaugeRange> ranges = new List<GaugeRange>()
{
new GaugeRange() {StartValue = 0, EndValue = 55, StartWidth = 1, EndWidth = 5, Style = new GaugeStyle() {Fill = "#4bb648", Stroke = "#4bb648" }},
new GaugeRange() {StartValue = 55, EndValue = 110, StartWidth = 5, EndWidth = 10, Style = new GaugeStyle() {Fill = "#fbd109", Stroke = "#fbd109" }},
new GaugeRange() {StartValue = 110, EndValue = 165, StartWidth = 10, EndWidth = 13, Style = new GaugeStyle() {Fill = "#ff8000", Stroke = "#ff8000"} },
new GaugeRange() {StartValue = 165, EndValue = 220, StartWidth = 13, EndWidth = 16, Style = new GaugeStyle() {Fill = "#e02629", Stroke = "#e02629" } }
};
GaugeTicks ticksMinor = new GaugeTicks() { Interval = 5, Size = "5%" };
GaugeTicks ticksMajor = new GaugeTicks() { Interval = 10, Size = "9%" };
}
<jqx-gauge animation-duration="400"></jqx-gauge>
To call a function(method), you need to pass the method name and parameters(if any) in the UI component’s instance.
<script src="~/jqwidgets/jqxgauge.js"></script>
@using jQWidgets.AspNetCore.Mvc.TagHelpers;
@{
List<GaugeRange> ranges = new List<GaugeRange>()
{
new GaugeRange() {StartValue = 0, EndValue = 55, StartWidth = 1, EndWidth = 5, Style = new GaugeStyle() {Fill = "#4bb648", Stroke = "#4bb648" }},
new GaugeRange() {StartValue = 55, EndValue = 110, StartWidth = 5, EndWidth = 10, Style = new GaugeStyle() {Fill = "#fbd109", Stroke = "#fbd109" }},
new GaugeRange() {StartValue = 110, EndValue = 165, StartWidth = 10, EndWidth = 13, Style = new GaugeStyle() {Fill = "#ff8000", Stroke = "#ff8000"} },
new GaugeRange() {StartValue = 165, EndValue = 220, StartWidth = 13, EndWidth = 16, Style = new GaugeStyle() {Fill = "#e02629", Stroke = "#e02629" } }
};
GaugeTicks ticksMinor = new GaugeTicks() { Interval = 5, Size = "5%" };
GaugeTicks ticksMajor = new GaugeTicks() { Interval = 10, Size = "9%" };
}
<jqx-gauge instance="getInstance()"></jqx-gauge>
@section scripts {
<script type="text/javascript">
function getInstance(instance) {
instance["disable"]();
}
</script>
}
To bind to an event of a UI Component, you can use on-event-type syntax. The example code below demonstrates how to bind to an event.
<script src="~/jqwidgets/jqxgauge.js"></script>
@using jQWidgets.AspNetCore.Mvc.TagHelpers;
@{
List<GaugeRange> ranges = new List<GaugeRange>()
{
new GaugeRange() {StartValue = 0, EndValue = 55, StartWidth = 1, EndWidth = 5, Style = new GaugeStyle() {Fill = "#4bb648", Stroke = "#4bb648" }},
new GaugeRange() {StartValue = 55, EndValue = 110, StartWidth = 5, EndWidth = 10, Style = new GaugeStyle() {Fill = "#fbd109", Stroke = "#fbd109" }},
new GaugeRange() {StartValue = 110, EndValue = 165, StartWidth = 10, EndWidth = 13, Style = new GaugeStyle() {Fill = "#ff8000", Stroke = "#ff8000"} },
new GaugeRange() {StartValue = 165, EndValue = 220, StartWidth = 13, EndWidth = 16, Style = new GaugeStyle() {Fill = "#e02629", Stroke = "#e02629" } }
};
GaugeTicks ticksMinor = new GaugeTicks() { Interval = 5, Size = "5%" };
GaugeTicks ticksMajor = new GaugeTicks() { Interval = 10, Size = "9%" };
}
<jqx-gauge on-value-changing="eventHandler()"></jqx-gauge>
@section scripts {
<script type="text/javascript">
function eventHandler(event) {
}
</script>
}

Basic Sample