| 1 |
define([ |
| 2 |
"dojo/_base/lang", |
| 3 |
"dojo/_base/declare", |
| 4 |
"dojo/_base/Color", |
| 5 |
"../../RectangularGauge", |
| 6 |
"../../LinearScaler", |
| 7 |
"../../RectangularScale", |
| 8 |
"../../RectangularValueIndicator", |
| 9 |
"../DefaultPropertiesMixin" |
| 10 |
], |
| 11 |
function(lang, declare, Color, RectangularGauge, LinearScaler, RectangularScale, RectangularValueIndicator, DefaultPropertiesMixin){ |
| 12 |
return declare("dojox.dgauges.components.black.HorizontalLinearGauge", [RectangularGauge, DefaultPropertiesMixin], { |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
borderColor: "#000000", |
| 19 |
|
| 20 |
|
| 21 |
fillColor: "#000000", |
| 22 |
|
| 23 |
|
| 24 |
indicatorColor: "#A4A4A4", |
| 25 |
constructor: function(){ |
| 26 |
|
| 27 |
this.borderColor = new Color(this.borderColor); |
| 28 |
this.fillColor = new Color(this.fillColor); |
| 29 |
this.indicatorColor = new Color(this.indicatorColor); |
| 30 |
|
| 31 |
this.addElement("background", lang.hitch(this, this.drawBackground)); |
| 32 |
|
| 33 |
|
| 34 |
var scaler = new LinearScaler(); |
| 35 |
|
| 36 |
|
| 37 |
var scale = new RectangularScale(); |
| 38 |
scale.set("scaler", scaler); |
| 39 |
scale.set("labelPosition", "leading"); |
| 40 |
scale.set("paddingLeft", 30); |
| 41 |
scale.set("paddingRight", 30); |
| 42 |
scale.set("paddingTop", 34); |
| 43 |
scale.set("labelGap", 8); |
| 44 |
scale.set("font", { |
| 45 |
family: "Helvetica", |
| 46 |
weight: "bold", |
| 47 |
size: "7pt", |
| 48 |
color: "#CECECE" |
| 49 |
}); |
| 50 |
scale.set("tickShapeFunc", function(group, scale, tick){ |
| 51 |
return group.createCircle({ |
| 52 |
r: tick.isMinor ? 0.5 : 3 |
| 53 |
}).setFill("#CECECE"); |
| 54 |
}); |
| 55 |
this.addElement("scale", scale); |
| 56 |
|
| 57 |
var indicator = new RectangularValueIndicator(); |
| 58 |
indicator.set("interactionArea", "gauge"); |
| 59 |
indicator.set("value", scaler.minimum); |
| 60 |
indicator.set("paddingTop", 30); |
| 61 |
indicator.set("indicatorShapeFunc", lang.hitch(this, function(group, indicator){ |
| 62 |
return group.createPolyline([0, 0, -10, -20, 10, -20, 0, 0]).setFill(this.indicatorColor).setStroke({ |
| 63 |
color: [70, 70, 70], |
| 64 |
width: 1, |
| 65 |
style: "Solid", |
| 66 |
cap: "butt", |
| 67 |
join: 20.0 |
| 68 |
}); |
| 69 |
|
| 70 |
})); |
| 71 |
scale.addIndicator("indicator", indicator); |
| 72 |
}, |
| 73 |
|
| 74 |
drawBackground: function(g, w, h){ |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
g.createRect({ |
| 86 |
x: 0, |
| 87 |
y: 0, |
| 88 |
width: w, |
| 89 |
height: 50, |
| 90 |
r: 15 |
| 91 |
}).setFill(this.borderColor); |
| 92 |
g.createRect({ |
| 93 |
x: 4, |
| 94 |
y: 4, |
| 95 |
width: w - 8, |
| 96 |
height: 42, |
| 97 |
r: 12 |
| 98 |
}).setFill({ |
| 99 |
type: "linear", |
| 100 |
x1: 0, |
| 101 |
y1: 50, |
| 102 |
x2: 0, |
| 103 |
y2: 30, |
| 104 |
colors: [ |
| 105 |
{offset: 0, color: [100,100,100]}, |
| 106 |
{offset: 1, color: this.fillColor} |
| 107 |
] |
| 108 |
}); |
| 109 |
g.createPath().moveTo(4, 25).vLineTo(14).smoothCurveTo(4, 4, 18, 4).hLineTo(w - 16).smoothCurveTo(w - 4, 4, w - 4, 16).closePath().setFill({ |
| 110 |
type: "linear", |
| 111 |
x1: 0, |
| 112 |
y1: 0, |
| 113 |
x2: 0, |
| 114 |
y2: 20, |
| 115 |
colors: [ |
| 116 |
{offset: 0, color: [150,150,150]}, |
| 117 |
{offset: 1, color: this.fillColor} |
| 118 |
] |
| 119 |
}); |
| 120 |
g.createPath().moveTo(4, 25).vLineTo(14).smoothCurveTo(4, 4, 18, 4).hLineTo(w - 16).smoothCurveTo(w - 4, 4, w - 4, 16).closePath().setFill([255,255,255,0.05]); |
| 121 |
} |
| 122 |
}); |
| 123 |
} |
| 124 |
); |
| 125 |
|