Debian Codegraph @

dojox/dgauges/components/classic/VerticalLinearGauge.js

raw symbols SCIP
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.classic.VerticalLinearGauge", [RectangularGauge, DefaultPropertiesMixin], {
13 // summary:
14 // A vertical gauge widget.
15
16 // borderColor: Object|Array|int
17 // The border color. Default is "#797E86".
18 borderColor: [121,126,134],
19 // fillColor: Object|Array|int
20 // The background color. Default is "#9498A1".
21 fillColor: [148,152,161],
22 // indicatorColor: Object|Array|int
23 // The indicator fill color. Default is "#FFFFFF".
24 indicatorColor: "#FFFFFF",
25 constructor: function(){
26 this.orientation = "vertical";
27 // Base colors
28 this.borderColor = new Color(this.borderColor);
29 this.fillColor = new Color(this.fillColor);
30 this.indicatorColor = new Color(this.indicatorColor);
31
32 this.addElement("background", lang.hitch(this, this.drawBackground));
33
34 // Scaler
35 var scaler = new LinearScaler();
36
37 // Scale
38 var scale = new RectangularScale();
39 scale.set("scaler", scaler);
40 scale.set("labelPosition", "trailing");
41 scale.set("paddingTop", 30);
42 scale.set("paddingBottom", 30);
43 scale.set("paddingLeft", 17);
44 scale.set("font", {
45 family: "Helvetica",
46 weight: "bold",
47 size: "7pt"
48 });
49 scale.set("tickShapeFunc", function(group, scale, tick){
50 return group.createCircle({
51 r: tick.isMinor ? 0.5 : 2
52 }).setFill("black");
53 });
54 this.addElement("scale", scale);
55
56 var indicator = new RectangularValueIndicator();
57 indicator.set("interactionArea", "gauge");
58 indicator.set("value", scaler.minimum);
59 indicator.set("paddingLeft", 18);
60 indicator.set("indicatorShapeFunc", lang.hitch(this, function(group){
61
62 return group.createPolyline([0, 0, -10, -20, 10, -20, 0, 0]).setFill(this.indicatorColor).setStroke({
63 color: [121,126,134],
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 // summary:
76 // Draws the background shape of the gauge.
77 // g: dojox/gfx/Group
78 // The group used to draw the background.
79 // w: Number
80 // The width of the gauge.
81 // h: Number
82 // The height of the gauge.
83 // tags:
84 // protected
85 g.createRect({
86 x: 0,
87 y: 0,
88 width: 50,
89 height: h,
90 r: 8
91 }).setFill(this.borderColor);
92 g.createRect({
93 x: 2,
94 y: 2,
95 width: 46,
96 height: h / 2,
97 r: 6
98 }).setFill({
99 type: "linear",
100 x1: 0,
101 y1: 2,
102 x2: 0,
103 y2: h / 2,
104 colors: [
105 {offset: 0, color: [235,235,235]},
106 {offset: 1, color: this.borderColor}
107 ]
108 });
109 g.createRect({
110 x: 6,
111 y: 6,
112 width: 38,
113 height: h - 12,
114 r: 5
115 }).setFill({
116 type: "linear",
117 x1: 6,
118 y1: 0,
119 x2: 38,
120 y2: 0,
121 colors: [
122 {offset: 0, color: this.fillColor},
123 {offset: 1, color: [220,220,220]}
124 ]
125 });
126 g.createRect({
127 x: 7,
128 y: 7,
129 width: 36,
130 height: h - 14,
131 r: 3
132 }).setFill({
133 type: "linear",
134 x1: 7,
135 y1: 0,
136 x2: 36,
137 y2: 0,
138 colors: [
139 {offset: 0, color: [220,220,220]},
140 {offset: 1, color: this.fillColor}
141 ]
142 });
143 }
144
145 });
146 }
147 );
148