今天我们分享来自guage.js的超棒动画仪表板实现,这个类库使用html5画布来生成动态的自定义仪表板。不依赖于任何类库也不实用任何的css或者图片,完全使用画布生成。
拥有两套不同的ui,一个是仪表盘,一个类似原来我们介绍的jquery knob界面。支持ui元素自定义你可以生成自己需要的颜色格式。
主要特性:
1.无图片,css
2.无类库依赖(支持jquery,但是不是必须的)
3.高度可配置
4.分辨率独立
5.动画数值变化
6.支持主流浏览器
支持浏览器:
1.chrome
2.safari 3.2+
3.firefox 3.5+
4.ie 9
5.opera 10.6+
6.mobile safari (ios 3.2+)
7.android 2.3+
如何使用
var opts = {lines: 12, // the number of lines to drawangle: 0.21, // the length of each linelinewidth: 0.44, // the line thicknesspointer: {length: 0.9, // the radius of the inner circlestrokewidth: 0.108 // the rotation offset},colorstart: '#909090',?? // colorscolorstop: '#8fc0da',??? // just experiment with themstrokecolor: '#e0e0e0'?? // to see which ones work best for you};var target = document.getelementbyid('foo'); // your canvas elementvar gauge = new gauge(target).setoptions(opts); // create sexy gauge!gauge.maxvalue = 3000; // set max gauge valuegauge.animationspeed = 46; // set animation speed (32 is default value)gauge.set(650); // set actual value
如果你使用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;};
如果你希望方便快速的创建一个动态仪表,gauge.js肯定是一个不错的选择。
杭州到金湖物流专线引爆市场潜力,提升业务价值:海口网站建设兰州到湖州物流专线合肥到射洪物流专线南宁到朔州物流专线网站建设:网络推广的意义芜湖到梨树物流专线相关网站网页建设的一些细节问题