gauge.js仪表盘的特点
var opts = { lines: 12, // The number of lines to draw angle: 0.35, // The length of each line lineWidth: 0.1, // The line thickness pointer: { length: 0.7, // The radius of the inner circle strokeWidth: 0.04, // The rotation offset color: '#000000' // Fill color }, limitMax: 'false', // If true, the pointer will not go past the end of the gauge colorStart: '#6F6EA0', // Colors colorStop: '#C0C0DB', // just experiment with them strokeColor: '#EEEEEE', // to see which ones work best for you generateGradient: true }; var target = document.getElementById('foo'); // your canvas element var gauge = new Donut(target).setOptions(opts); // create sexy gauge! gauge.maxValue = 3000; // set max gauge value gauge.animationSpeed = 25; // set animation speed (32 is default value) gauge.set(1600); // set actual value
Gauge
类处理canvas的作图和使图像运动起来。
Gauge.js不依赖于jQuery,但如果你想用jQuery来运行它,你可以按下面的方法做:
$.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; };