Skycons

Skycons is a set of ten animated weather glyphs, procedurally generated by JavaScript using the HTML5 canvas tag.

They’re easy to use, and pretty lightweight, so they shouldn’t rain on your parade:

<canvas id="icon1" width="128" height="128"></canvas>
<canvas id="icon2" width="128" height="128"></canvas>

<script>
  var skycons = new Skycons({"color": "pink"});
  // on Android, a nasty hack is needed: {"resizeClear": true}

  // you can add a canvas by it's ID...
  skycons.add("icon1", Skycons.PARTLY_CLOUDY_DAY);

  // ...or by the canvas DOM element itself.
  skycons.add(document.getElementById("icon2"), Skycons.RAIN);

  // if you're using the Forecast API, you can also supply
  // strings: "partly-cloudy-day" or "rain".

  // start animation!
  skycons.play();

  // you can also halt animation with skycons.pause()

  // want to change the icon? no problem:
  skycons.set("icon1", Skycons.PARTLY_CLOUDY_NIGHT);

  // want to remove one altogether? no problem:
  skycons.remove("icon2");
</script>

Skycons were designed for Forecast by those wacky folks at The Dark Sky Company, and were heavily inspired by Adam Whitcroft’s excellent Climacons. The source code is available on Github, and has been released into the public domain, so please do with it as you see fit! ♡

="lit">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