├── .gitignore ├── .bowerrc ├── bower.json ├── dist └── angular-gauge.min.js ├── package.json ├── Gruntfile.js ├── README.md ├── demo ├── index.html └── app.js ├── LICENSE └── src └── angular-gauge.js /.gitignore: -------------------------------------------------------------------------------- 1 | app 2 | *.swp 3 | components 4 | node_modules 5 | -------------------------------------------------------------------------------- /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "components", 3 | "json": "bower.json" 4 | } 5 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-gaugejs", 3 | "version": "0.1", 4 | "main": [ 5 | "angular-gaugejs.js" 6 | ], 7 | "ignore": [ 8 | "README.md" 9 | ], 10 | "dependencies": { 11 | "angular": "~1.2.9", 12 | "gauge.js": "latest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /dist/angular-gauge.min.js: -------------------------------------------------------------------------------- 1 | !function(a){"use strict";a.module("gaugejs",[]).directive("gaugejs",[function(){return{restrict:"AC",scope:{animationTime:"=",value:"=",options:"=",maxValue:"="},controller:function(a,b){a.gauge=new Gauge(b[0]),a.gauge.maxValue=a.maxValue,a.$watchCollection("[options, value]",function(b){a.gauge.setOptions(b[0]),a.gauge.set(b[1])})}}}])}(window.angular); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-gaugejs", 3 | "version": "0.0.1", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/schlunsen/angular-gaugejs" 7 | }, 8 | "dependencies": {}, 9 | "devDependencies": { 10 | "matchdep": "~0.3.0", 11 | "grunt": "~0.4.1", 12 | "grunt-contrib-uglify": "~0.3.0" 13 | }, 14 | "engines": { 15 | "node": ">=0.8.0" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /* License: MIT. 2 | * Copyright (C) 2014, Rasmus Schlünsen 3 | */ 4 | 5 | 'use strict'; 6 | 7 | module.exports = function (grunt) { 8 | // load all grunt tasks 9 | require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); 10 | 11 | grunt.initConfig({ 12 | uglify: { 13 | dist: { 14 | files: { 15 | 'dist/angular-gauge.min.js': 'src/angular-gauge.js' 16 | } 17 | } 18 | } 19 | }); 20 | 21 | grunt.registerTask('build', [ 22 | 'uglify' 23 | ]); 24 | 25 | grunt.registerTask('default', ['build']); 26 | }; 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # angular-gaugejs 2 | 3 | Angular directive to show a gauge (using [gauge.js](http://bernii.github.io/gauge.js/)) 4 | 5 | Copyright (C) 2014, Rasmus Schlünsen 6 | 7 | ## Usage 8 | 9 | Include both gauge.js and angular-gauge.js in your application. 10 | 11 | ```html 12 | 13 | 14 | ``` 15 | 16 | Add the module `gaugejs` as a dependency to your app module: 17 | 18 | ```js 19 | var myapp = angular.module('myapp', ['gaugejs']); 20 | ``` 21 | 22 | You can now start using the gaugejs directive to display an animated gauge. 23 | Currently the directive must be used on canvas tags 24 | 25 | ```html 26 | 27 | ``` 28 | 29 | 30 | [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/schlunsen/angular-gaugejs/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 31 | 32 | -------------------------------------------------------------------------------- /demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Angular-Gaugejs 13 | 14 | 15 |

Gauge.js for angular

16 |
17 | 18 |
19 | 20 |
21 | 22 | 23 |
24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2014 Rasmus Schlünsen, https://github.com/organizations/angular-ui/teams/291112 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/angular-gauge.js: -------------------------------------------------------------------------------- 1 | /*global window:false, angular:false, Gauge:false*/ 2 | /** 3 | * angular-gaugejs version 0.1 4 | * License: MIT. 5 | * Copyright (C) 2014, Rasmus Schlünsen 6 | */ 7 | 8 | (function(angular) { 9 | 'use strict'; 10 | 11 | angular.module('gaugejs', []) 12 | .directive('gaugejs', [function() { 13 | return { 14 | restrict: 'AC', 15 | scope: { 16 | 'animationTime': '=', 17 | 'value': '=', 18 | 'options': '=', 19 | 'maxValue': '=', 20 | 'gaugeType': '=' 21 | }, 22 | controller: function($scope, $element) { 23 | if ($scope.gaugeType === 'donut') { 24 | $scope.gauge = new Donut($element[0]); 25 | } else { 26 | $scope.gauge = new Gauge($element[0]); 27 | } 28 | $scope.gauge.maxValue = $scope.maxValue; 29 | $scope.$watchCollection('[options, value]', function(newValues){ 30 | $scope.gauge.setOptions(newValues[0]); 31 | if (!isNaN(newValues[1])){ 32 | $scope.gauge.set(newValues[1]); 33 | } 34 | }); 35 | }, 36 | }; 37 | }]); 38 | 39 | })(window.angular); 40 | -------------------------------------------------------------------------------- /demo/app.js: -------------------------------------------------------------------------------- 1 | var app = angular.module('gauge', ['gaugejs']); 2 | 3 | app.controller('test', ['$scope', '$timeout', function($scope, $timeout) { 4 | $scope.animationTime = 10; 5 | $scope.value = 3000; 6 | $scope.maxValue = 3000; 7 | $scope.gaugeType = 'donut'; 8 | 9 | $scope.gaugeOptions = { 10 | lines: 12, 11 | // The number of lines to draw 12 | angle: 0.15, 13 | // The length of each line 14 | lineWidth: 0.44, 15 | // The line thickness 16 | pointer: { 17 | length: 0.9, 18 | // The radius of the inner circle 19 | strokeWidth: 0.035, 20 | // The rotation offset 21 | color: '#000000' // Fill color 22 | }, 23 | limitMax: 'false', 24 | // If true, the pointer will not go past the end of the gauge 25 | colorStart: '#6FADCF', 26 | // Colors 27 | colorStop: '#8FC0DA', 28 | // just experiment with them 29 | strokeColor: '#E0E0E0', 30 | // to see which ones work best for you 31 | generateGradient: true 32 | }; 33 | 34 | $scope.donutGaugeOptions = { 35 | lines: 12, 36 | // The number of lines to draw 37 | angle: 0.15, 38 | // The length of each line 39 | lineWidth: 0.044, 40 | // The line thickness 41 | pointer: { 42 | length: 0.09, 43 | // The radius of the inner circle 44 | strokeWidth: 0.0035, 45 | // The rotation offset 46 | color: '#000000' // Fill color 47 | }, 48 | limitMax: 'false', 49 | // If true, the pointer will not go past the end of the gauge 50 | colorStart: '#6FADCF', 51 | // Colors 52 | colorStop: '#8FC0DA', 53 | // just experiment with them 54 | strokeColor: '#E0E0E0', 55 | // to see which ones work best for you 56 | generateGradient: true 57 | }; 58 | 59 | 60 | }]); 61 | 62 | --------------------------------------------------------------------------------