Wijmo UI for the Web
AngularJS and wijradialgauge
Wijmo User Guide > AngularJS Directives > AngularJS and Gauge Widgets > AngularJS and wijradialgauge

In this Angular getting started guide, you'll learn how to use the wijradialgauge in an HTML project using HTML markup, jQuery script, and AngularJS directives.

For more complex samples that have the controller and model in separate files, see Wijmo Gauges in the AngularJS Directive Gallery on our web site.

  1. To create a new HTML page in your favorite text editor, add the following code and save the document with an .html extension. Notice that the <HTML> and <body> tags are different from our usual tags.
    • The <HTML> tag is marked as an Angular app with the ng-app directive, in our script, we will specify that it uses Wijmo.
    • The <body> tag is used to define the scope of the Angular controller that we create. You can use another tag such as a <div> for the scope, but for our purposes, we will use the entire body. The ng-controller directive specifies the controller to use within this scope.

    Drop down and copy markup

    Paste in your favorite text editor.
    Copy Code
    <!DOCTYPE HTML>
    <HTML ng-app="MyApp">
    <head>
    </head>
    <body ng-controller="MyController">
    </body>
    </HTML>
    
  2. Add links to the dependencies to your HTML page within the <head> tags. Find the latest dependencies in the content delivery network (CDN) file at wijmo cdn. Along with our usual references, we add two script references for Angular that must come after the jQuery references, so they are the last two lines:
    • One is for AngularJS itself.
    • The other is for Wijmo's Angular javascript integration library.

    Drop down and copy references to paste inside the head tags

    References
    Copy Code
    <!-- jQuery -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js" type="text/javascript"></script>
    
    <!--Theme-->
    <link href="http://cdn.wijmo.com/themes/aristo/jquery-wijmo.css" rel="stylesheet" type="text/css" />
    
    <!--Wijmo Widgets CSS-->
    <link href="http://cdn.wijmo.com/jquery.wijmo-pro.all.3.20183.140.min.css" rel="stylesheet" type="text/css" />
    
    <!-- Wijmo Scripts -->
    <script src="http://cdn.wijmo.com/jquery.wijmo-open.all.3.20183.140.min.js" type="text/javascript"></script>
    <script src="http://cdn.wijmo.com/jquery.wijmo-pro.all.3.20183.140.min.js" type="text/javascript"></script>
    
    <!-- Angular -->
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
    <script src="http://cdn.wijmo.com/interop/angular.wijmo.3.20183.140.min.js"></script>
                    
  3. Within the <head> tags, below the references, add the following script to set the app to use Wijmo, and to create a simple controller.
    • We use a $scope parameter on the controller to control data context.
    • We add an optional $locale parameter on the controller.
    • We set the value parameter that we use for wijradialgauge.
    Script
    Copy Code
    <script type="text/javascript">
        var app = angular.module("MyApp", ["wijmo"]);
        function MyController($scope) {
            $scope.value = 90;
        }
    </script>
  4. Add the following markup within the <body> tags to create the widget. To see how this is done in jQuery without Angular, see Provide Colorized Ranges.
    • We use a <wij-wijradialgauge> directive to create the widget, and set several options as attributes within the element:
      • We set the value option to specify the "value" from our controller.
      • We set the max and min options.
    • We use nested elements in the markup to fill the ranges option with an array of range elements, and set several options as attributes within each range:
      • We set the startValue attribute (start-value directive) to set where to start rendering the range.
      • We set the endValue attribute (end-value directive) to set where to finish rendering the range.
      • We set the startDistance attribute (start-distance directive) to set the percentage of the way from the center to the edge of the gauge face to draw the beginning of the range.
      • We set the endDistance attribute (end-distance directive) to set the percentage of the way from the center to the edge of the gauge face to draw the end of the range.
      • We set the startWidth attribute (start-width directive) to set how thick to render the beginning of the range.
      • We set the endWidth attribute (end-width directive) to set how thick to render the end of the range.
      • Inside each range directive, we nest a style directive to set the color and width of the range.
    Markup
    Copy Code
    <wij-radialgauge value="70" max="100" min="0">
        <ranges>
            <range start-value="0" end-value="100" start-distance="0.64" end-distance="0.64" start-width="10" end-width="10" >
                <style fill="Grey" stroke="none"></style>
            </range>
            <range start-value="40" end-value="60" start-distance="0.58" end-distance="0.58" start-width="10" end-width="10">
                <style fill="Yellow" stroke="Yellow" stroke-width="1.5"></style>
            </range>
            <range start-value="60" end-value="80" start-distance="0.58" end-distance="0.58" start-width="10" end-width="10">
                <style fill="Orange" stroke="Orange" stroke-width="1.5"></style>
            </range>
            <range start-value="80" end-value="100" start-distance="0.58" end-distance="0.58" start-width="10" end-width="10">
                <style fill="Red" stroke="Red" stroke-width="1.5"></style>
            </range>
        </ranges>
    </wij-radialgauge>
  5. Save your HTML file and open it in a browser. The widget appears like the following live widget.
    MISSING WIDGET TYPE: The "Live Widget" Widget Type could not be found. The "Live Widget" Widget Type may have been deleted since this Widget was created.
See Also

Reference

Widgets