Debian Codegraph @

dojox/dgauges/components/green/CircularLinearGauge.js

raw symbols SCIP
1 define([
2 "dojo/_base/lang",
3 "dojo/_base/declare",
4 "dojo/_base/Color",
5 "../utils",
6 "../../CircularGauge",
7 "../../LinearScaler",
8 "../../CircularScale",
9 "../../CircularValueIndicator",
10 "../../CircularRangeIndicator",
11 "../DefaultPropertiesMixin"
12 ],
13 function(lang, declare, Color, utils, CircularGauge, LinearScaler, CircularScale, CircularValueIndicator, CircularRangeIndicator, DefaultPropertiesMixin){
14 return declare("dojox.dgauges.components.green.CircularLinearGauge", [CircularGauge, DefaultPropertiesMixin], {
15 // summary:
16 // A circular gauge widget.
17
18 // borderColor: Object|Array|int
19 // The border color. Default is "#323232".
20 borderColor: [50,50,50],
21 // fillColor: Object|Array|int
22 // The fill color. Default is "#6DB713".
23 fillColor: [109,183,19],
24 // indicatorColor: Object|Array|int
25 // The indicator fill color. Default is "#000000".
26 indicatorColor: [0,0,0],
27 constructor: function(){
28 var scaler = new LinearScaler();
29 this.addElement("background", lang.hitch(this, this.drawBackground));
30 var scale = new CircularScale();
31 scale.set("scaler", scaler);
32 scale.set("originX", 132);
33 scale.set("originY", 133.5);
34 scale.set("radius", 100);
35 scale.set("startAngle", 120);
36 scale.set("endAngle", 60);
37 scale.set("orientation", "clockwise");
38 scale.set("labelGap", 6);
39 scale.set("font", {
40 family: "Helvetica",
41 weight: "bold",
42 size: "8pt"
43 });
44 this.addElement("scale", scale);
45 var indicator = new CircularValueIndicator();
46 indicator.set("interactionArea", "gauge");
47 indicator.set("value", scaler.minimum);
48 indicator.set("indicatorShapeFunc", lang.hitch(this, function(group, indicator){
49
50 var l = indicator.scale.radius - 2;
51 group.createPath().moveTo(-20, 0).lineTo(-20, -5).lineTo(l, 0).lineTo(-20, 5).closePath().setFill(this.indicatorColor);
52 return group;
53
54 }));
55 scale.addIndicator("indicator", indicator);
56 this.addElement("foreground", lang.hitch(this, this.drawForeground));
57 },
58
59 drawBackground: function(g){
60 // summary:
61 // Draws the background shape of the gauge.
62 // g: dojox/gfx/Group
63 // The group used to draw the background.
64 // tags:
65 // protected
66 var lighterFillColor = utils.brightness(new Color(this.fillColor), 100);
67 g.createEllipse({
68 cx: 132.2528,
69 cy: 133.617,
70 rx: 132.2528,
71 ry: 131.9046
72 }).setFill(this.borderColor);
73 g.createPath({
74 path: "M260.5056 133.617 C260.5188 179.3085 236.0769 221.5348 196.39 244.3844 C156.703 267.234 107.8027 267.234 68.1158 244.3844 C28.4287 221.5348 3.9866 179.3085 4 133.617 C3.9866 87.9255 28.4287 45.6992 68.1158 22.8496 C107.8027 0 156.703 0 196.39 22.8496 C236.0769 45.6992 260.5188 87.9255 260.5056 133.617 Z"
75 }).setFill({
76 type: "linear",
77 x1: 4.00002,
78 y1: 5.71243,
79 x2: 183.55392,
80 y2: 261.52156,
81 colors: [
82 {offset: 0, color: [226,226,221]},
83 {offset: 0.5, color: [239,239,236]},
84 {offset: 1, color: "white"}
85 ]
86 });
87 g.createPath({
88 path: "M132.2358 5.7124 C61.4417 5.7124 4 63.0164 4 133.617 C4 204.2176 61.4417 261.5216 132.2358 261.5216 C203.0297 261.5216 260.5056 204.2176 260.5056 133.617 C260.5056 63.0164 203.0297 5.7124 132.2358 5.7124 ZM132.2358 29.5811 C189.165 29.5811 235.3862 76.19 235.3862 133.617 C235.3862 191.0441 189.165 237.653 132.2358 237.653 C75.3064 237.653 29.1195 191.0441 29.1195 133.617 C29.1195 76.19 75.3064 29.5811 132.2358 29.5811 Z"
89 }).setFill({
90 type: "linear",
91 x1: 4.00003,
92 y1: 5.71235,
93 x2: 4.00003,
94 y2: 261.52154,
95 colors: [
96 {offset: 0, color: lighterFillColor},
97 {offset: 0.25, color: this.fillColor},
98 {offset: 0.5, color: this.fillColor},
99 {offset: 0.75, color: this.fillColor},
100 {offset: 1, color: lighterFillColor}
101 ]
102 });
103 g.createPath({
104 path: "M-389.2685 91.1524 C-389.2685 194.5704 -473.1053 278.4072 -576.5233 278.4072 C-679.9412 278.4072 -763.778 194.5704 -763.778 91.1524 C-763.778 -12.2655 -679.9412 -96.1024 -576.5233 -96.1024 C-473.1053 -96.1024 -389.2685 -12.2655 -389.2685 91.1524 Z"
105 }).setTransform({
106 xx: 0.1,
107 xy: 0.46404,
108 yx: -0.46637,
109 yy: 0.1005,
110 dx: 147.5,
111 dy: -144.5
112 }).setStroke({
113 color: "white",
114 width: 3.04506,
115 style: "Solid",
116 cap: "butt",
117 join: 4.0
118 });
119 },
120
121 drawForeground: function(g){
122 // summary:
123 // Draws the foreground shape of the gauge.
124 // g: dojox/gfx/Group
125 // The group used to draw the foreground.
126 // tags:
127 // protected
128 var g1 = g.createGroup();
129 g1.createEllipse({
130 cx: 132,
131 cy: 133.5,
132 rx: 18,
133 ry: 18
134 }).setFill(this.fillColor);
135 g1.createEllipse({
136 cx: 132,
137 cy: 133.5,
138 rx: 17,
139 ry: 17
140 }).setFill({
141 type: "linear",
142 x1: 116.09304,
143 y1: 118.09373,
144 x2: 116.09304,
145 y2: 149.2857,
146 colors: [
147 {offset: 0, color: [255,255,246]},
148 {offset: 0.17857, color: [252,251,236]},
149 {offset: 0.25755, color: [250,247,230]},
150 {offset: 0.77747, color: [246,243,224]},
151 {offset: 1, color: [227,209,184]}
152 ]
153 });
154 g.createPath({
155 path: "M235.494 63.7584 C235.494 87.4242 189.2719 51.6605 132.3194 51.6605 C75.367 51.6605 29.1447 87.4242 29.1447 63.7584 C29.1447 40.0927 75.367 2.531 132.3194 2.531 C189.2719 2.531 235.494 40.0927 235.494 63.7584 Z"
156 }).setFill([255,255,255,0.19608]);
157 }
158
159 });
160 }
161 );
162