gauge.coffee gauge.min.js

Example

Variant selection

Options:














Features

Usage


var opts = {

  lines: 12, // The number of lines to draw

  angle: 7, // The length of each line

  lineWidth: 5, // The line thickness

  pointer: {

    length: 10, // The radius of the inner circle

    strokeWidth: 0, // The rotation offset

    color: '#000000' // Fill color

  },

  limitMax: 'false',   // If true, the pointer will not go past the end of the gauge

  colorStart: '0',   // Colors

  colorStop: '0',    // just experiment with them

  strokeColor: '0',   // to see which ones work best for you

  generateGradient: true

};

var target = document.getElementById('foo'); // your canvas element

var gauge = new Gauge(target).setOptions(opts); // create sexy gauge!

gauge.maxValue = 3000; // set max gauge value

gauge.animationSpeed = 3000; // set animation speed (32 is default value)

gauge.set(1500); // set actual value

The Gauge class handles drawing on canvas and starts the animation.

Advanced options

jQuery plugin

Gauge.js does not require jQuery. Anyway, if you use jQuery you may use the following plugin:


$.fn.gauge = function(opts) {

  this.each(function() {

    var $this = $(this),

        data = $this.data();



    if (data.gauge) {

      data.gauge.stop();

      delete data.gauge;

    }

    if (opts !== false) {

      data.gauge = new Gauge(this).setOptions(opts);

    }

  });

  return this;

};

Supported browsers

Gauge.js has been (not yet!) successfully tested in the following browsers:

Changes

Version 1.2.1 (9.03.2014)

Version 1.2 (16.08.2012)

Version 1.1 (15.08.2012)

Version 1.0 (27.6.2012)

Contact

If you encounter any problems, please use the GitHub issue tracker.
If you like gauge.js and use it in the wild, let me know.
If you want to contact me, drop me a message via email