| 1 |
define(["dojo/_base/declare","dojo/_base/fx","dojo/_base/connect","dojo/_base/lang","./BarLineIndicator"], |
| 2 |
function(declare, fx, connect, lang, BarLineIndicator) { |
| 3 |
|
| 4 |
return declare("dojox.gauges.BarIndicator",[BarLineIndicator],{ |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
_getShapes: function(group){ |
| 10 |
|
| 11 |
|
| 12 |
if(!this._gauge){ |
| 13 |
return null; |
| 14 |
} |
| 15 |
var v = this.value; |
| 16 |
if(v < this._gauge.min){v = this._gauge.min;} |
| 17 |
if(v > this._gauge.max){v = this._gauge.max;} |
| 18 |
var pos = this._gauge._getPosition(v); |
| 19 |
if(pos == this.dataX){pos = this.dataX+1;} |
| 20 |
var y = this._gauge.dataY + Math.floor((this._gauge.dataHeight - this.width)/2) + this.offset; |
| 21 |
|
| 22 |
var shapes = []; |
| 23 |
shapes[0] = group.createRect({x:this._gauge.dataX, y:y, width:pos - this._gauge.dataX, height:this.width}); |
| 24 |
shapes[0].setStroke({color: this.color}); |
| 25 |
shapes[0].setFill(this.color); |
| 26 |
shapes[1] = group.createLine({ x1:this._gauge.dataX, y1:y, x2:pos, y2:y }); |
| 27 |
shapes[1].setStroke({color: this.highlight}); |
| 28 |
if(this.highlight2){ |
| 29 |
y--; |
| 30 |
shapes[2] = group.createLine({ x1:this._gauge.dataX, y1:y, x2:pos, y2:y }); |
| 31 |
shapes[2].setStroke({color: this.highlight2}); |
| 32 |
} |
| 33 |
|
| 34 |
return shapes; |
| 35 |
}, |
| 36 |
_createShapes: function(val){ |
| 37 |
|
| 38 |
|
| 39 |
for(var i in this.shape.children){ |
| 40 |
i = this.shape.children[i]; |
| 41 |
var newShape = {}; |
| 42 |
for(var j in i){ |
| 43 |
newShape[j] = i[j]; |
| 44 |
} |
| 45 |
if(i.shape.type == "line"){ |
| 46 |
newShape.shape.x2 = val+newShape.shape.x1; |
| 47 |
}else if(i.shape.type == "rect"){ |
| 48 |
newShape.width = val; |
| 49 |
} |
| 50 |
i.setShape(newShape); |
| 51 |
} |
| 52 |
}, |
| 53 |
_move: function( dontAnimate){ |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
var c; |
| 58 |
var v = this.value ; |
| 59 |
if(v < this.min){v = this.min;} |
| 60 |
if(v > this.max){v = this.max;} |
| 61 |
c = this._gauge._getPosition(this.currentValue); |
| 62 |
this.currentValue = v; |
| 63 |
v = this._gauge._getPosition(v)-this._gauge.dataX; |
| 64 |
if(dontAnimate){ |
| 65 |
this._createShapes(v); |
| 66 |
}else{ |
| 67 |
if(c!=v){ |
| 68 |
var anim = new fx.Animation({curve: [c, v], duration: this.duration, easing: this.easing}); |
| 69 |
connect.connect(anim, "onAnimate", lang.hitch(this, this._createShapes)); |
| 70 |
anim.play(); |
| 71 |
} |
| 72 |
} |
| 73 |
} |
| 74 |
}); |
| 75 |
}); |