1

我使用jsgauge插件创建了一个仪表

我不能做的是控制针的速度。它应该移动到比默认速度慢一点的分配值。针也应该从 0 开始。

这个的小提琴是http://jsfiddle.net/aryan7987/h45Tr/2/

Query(document).ready(function(){
        jQuery("#example")
          .gauge({
             min: 0,
             max: 100,
             label: 'EMPLOYEE',
             startangle: 0,
             bands: [{color: "#ff0000", from: 90, to: 100}]
           })
          .gauge('setValue', 59);
        });
4

2 回答 2

1

One of solutions is to use setInterval function and increase gauge value step by step with needed delay like this:

    jQuery(document).ready(function(){
            var g = jQuery("#example")
              .gauge({
                 min: 0,
                 max: 100,
                 label: 'RPM',
                 bands: [{color: "#ff0000", from: 90, to: 100}]
               });
              var m = 0;
              var timer = window.setInterval(function()
              {
                m++;
                g.gauge('setValue', m);
                if (m==58)
                {
                    clearInterval(timer);
                }
              }, 200);                   
});

The code is quite dirty but you should get a point. Also here working fiddle.

于 2012-11-20T09:00:10.033 回答
1

不幸的是,看起来速度是通过为每一帧定义增量来硬编码的。这是一个猴子补丁版本来改变速度看到这个jsfiddle

问题线是:

increment = Math.max(Math.abs( that.settings.pointerValue - pointerValue ) / 8, 3);
于 2012-11-20T09:03:48.603 回答