Available in the Full Version

Radial Gauge - API Usage

The buttons and api-viewer showcase some of igRadialGauge's needle methods.
API Explorer
Enter/Select Needle value: Set Needle Value
Get Current Needle Value: Get Needle Value
API Viewer

This sample is designed for a larger screen size.

On mobile, try rotating your screen, view full size, or email to another device.

You can change the value of the needle at runtime and obtain the current value of the needle by clicking the corresponding buttons.

Code View

Copy to Clipboard
<!DOCTYPE html>
<html>
<head>
    <title></title>

    <!-- Ignite UI for jQuery Required Combined CSS Files -->
    <link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
    <link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/structure/infragistics.css" rel="stylesheet" />

    <!-- Used to style the API Viewer and Explorer UI -->
    <link href="/css/apiviewer.css" rel="stylesheet" type="text/css" />

    <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>

    <!-- Ignite UI for jQuery Required Combined JavaScript Files -->
    <script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.core.js"></script>
    <script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.dv.js"></script>

    <!-- Used to add markup and provide logging 
        functionality for the API Explorer and API Viewer UI -->
    <script src="/js/apiviewer.js"></script>
</head>
<body>
    <style type="text/css">
       .apiButton {
          text-align: center;
          padding: 0px 0.5em 0px 0.5em;
          margin: 0.1em !important;
          display: inline-block;
          cursor: pointer;
          background: #f0f0f0;
          border: 1px solid #a0a0a0;
       }
       .apiButton:hover {
          background: #d0d0f0;
          border: 1px solid #505090;
       }
		 .apiInput {
          width: 3em;
          margin: 0.1em;
          border: 1px solid #a0a0a0;
		 }
    </style>

    <!-- Target element for the igRadialGauge -->
    <div id="radialGauge"></div>

    <div class="api-explorer">  
        <table style="width: 100%;">
	        <tr>
                <td><span>Enter/Select Needle value: </span></td>
                <td style="text-align: right;">
                    <input type="text" id="needleValue" name="format" value="" class="apiInput"/>
                    <span class="apiButton ui-corner-all" id="changeNeedleValue">Set Needle Value</span>
                </td>
            </tr>
            <tr style="height:10px"></tr>
            <tr>
                <td><span>Get Current Needle Value: </span></td>
                <td style="text-align: right;">
                    <span class="apiButton ui-corner-all" id="getNeedleValue">Get Needle Value</span>
                </td>
            </tr>
        </table>
    </div>

    <div class="api-viewer"></div>

    <script type="text/javascript">

        $(function () {

            // Used to show output in the API Viewer at runtime, 
            // defined in external script 'apiviewer.js'    
            var apiViewer = new $.ig.apiViewer();

            /*----------------- Method & Option Examples -------------------------*/
            
            // process events of buttons
            $("#changeNeedleValue").on({
                click: function (e) {
                    var needleValue = parseFloat($("#needleValue").val());
                    if (!needleValue || isNaN(needleValue)) {
                        needleValue = 0;
                    }
                    needleValue = Math.min(Math.max(needleValue, 0), 100);
                    $("#radialGauge").igRadialGauge("option", "value", needleValue);
                    $("#needleValue").val(needleValue);
                }
            });
                  
            var prevValue = null;
            $("#getNeedleValue").on({
                click: function (e) {
                    var needleValue = $("#radialGauge").igRadialGauge("option", "value");
                    if (prevValue == null || prevValue != needleValue) {
                        apiViewer.log("Current Needle Value: " + needleValue);
                        prevValue = needleValue;
                    }
                }
            });
                      
            /*----------------- Instantiation -------------------------*/

            $("#radialGauge").igRadialGauge({
                height: "500px",
                transitionDuration: "1500",
                width: "100%"                
            });

            function isAndroid() {
                return navigator.userAgent.match(/Android/i) ? true : false;
            }

            $("#radialGauge").igRadialGauge("option", "value", 0);
            $("#needleValue").val(0);
        });
    </script>
</body>
</html>