| 1 |
define(["dojo/_base/lang", "dojo/_base/declare", "dojox/dgauges/RectangularGauge", "dojox/dgauges/LinearScaler", |
| 2 |
"dojox/dgauges/RectangularScale", "dojox/dgauges/RectangularValueIndicator", |
| 3 |
"dojox/dgauges/RectangularRangeIndicator", "dojox/dgauges/TextIndicator"], |
| 4 |
function(lang, declare, RectangularGauge, LinearScaler, RectangularScale, RectangularValueIndicator, |
| 5 |
RectangularRangeIndicator, TextIndicator){ |
| 6 |
return declare("dojox.dgauges.tests.gauges.SimpleRectangularGauge", RectangularGauge, { |
| 7 |
constructor: function(){ |
| 8 |
|
| 9 |
this.addElement("background", function(g, w){ |
| 10 |
return g.createRect({ |
| 11 |
x: 1, |
| 12 |
y: 1, |
| 13 |
width: w - 2, |
| 14 |
height: 50, |
| 15 |
r: 3 |
| 16 |
}).setFill("#CBCBCB").setStroke({ |
| 17 |
color: "black", |
| 18 |
width: 2 |
| 19 |
}); |
| 20 |
}); |
| 21 |
|
| 22 |
this.addElement("leadingArea", function(g, w){ |
| 23 |
return g.createRect({ |
| 24 |
x: 1, |
| 25 |
y: 1, |
| 26 |
width: 60, |
| 27 |
height: 50, |
| 28 |
r: 3 |
| 29 |
}).setFill("#ABABAB").setStroke({ |
| 30 |
color: "black", |
| 31 |
width: 2 |
| 32 |
}); |
| 33 |
}, "leading"); |
| 34 |
|
| 35 |
this.addElement("trailingArea", function(g, w){ |
| 36 |
|
| 37 |
g.createLine({ |
| 38 |
x2: 62 |
| 39 |
}); |
| 40 |
return g.createRect({ |
| 41 |
x: 1, |
| 42 |
y: 1, |
| 43 |
width: 60, |
| 44 |
height: 50, |
| 45 |
r: 3 |
| 46 |
}).setFill("#ABABAB").setStroke({ |
| 47 |
color: "black", |
| 48 |
width: 2 |
| 49 |
}); |
| 50 |
}, "trailing"); |
| 51 |
|
| 52 |
|
| 53 |
var scale = new RectangularScale({ |
| 54 |
scaler: new LinearScaler({ |
| 55 |
minimum: -100 |
| 56 |
}), |
| 57 |
labelPosition: "trailing", |
| 58 |
paddingTop: 15 |
| 59 |
|
| 60 |
}); |
| 61 |
this.addElement("scale", scale); |
| 62 |
|
| 63 |
|
| 64 |
var indicator = new RectangularValueIndicator(); |
| 65 |
indicator.indicatorShapeFunc = lang.hitch(this, function(group){ |
| 66 |
group.createPolyline([-5, 0, 5, 0, 0, 10, -5, 0]).setFill("black"); |
| 67 |
return group; |
| 68 |
}); |
| 69 |
indicator.set("paddingTop", 5); |
| 70 |
indicator.set("interactionArea", "gauge"); |
| 71 |
scale.addIndicator("indicator", indicator); |
| 72 |
|
| 73 |
|
| 74 |
var trailingText = new TextIndicator({ |
| 75 |
x: 30, |
| 76 |
y: 30, |
| 77 |
indicator: indicator, |
| 78 |
labelFunc: function(v){ |
| 79 |
return v + " °C" |
| 80 |
} |
| 81 |
}); |
| 82 |
|
| 83 |
this.addElement("trailingText", trailingText, "trailing"); |
| 84 |
var leadingText = new TextIndicator({ |
| 85 |
x: 30, |
| 86 |
y: 30, |
| 87 |
indicator: indicator, |
| 88 |
labelFunc: function(v){ |
| 89 |
return ((9 / 5) * v + 32).toFixed() + " °F" |
| 90 |
} |
| 91 |
}); |
| 92 |
this.addElement("leadingText", leadingText, "leading"); |
| 93 |
|
| 94 |
scale.addIndicator("gradientIndicator", new RectangularRangeIndicator({ |
| 95 |
start: -100, |
| 96 |
value: 100, |
| 97 |
paddingTop: 15, |
| 98 |
stroke: null, |
| 99 |
fill: { |
| 100 |
type: "linear", |
| 101 |
x1: 0, |
| 102 |
y1: 0, |
| 103 |
x2: 1, |
| 104 |
y2: 0, |
| 105 |
colors: [{ |
| 106 |
color: "#7FB2F0", |
| 107 |
offset: 0 |
| 108 |
}, { |
| 109 |
color: "#FFFFFF", |
| 110 |
offset: .5 |
| 111 |
}, { |
| 112 |
color: "#F03221", |
| 113 |
offset: 1 |
| 114 |
}] |
| 115 |
} |
| 116 |
}), true); |
| 117 |
|
| 118 |
} |
| 119 |
}); |
| 120 |
}); |