Debian Codegraph @

dojox/dgauges/components/classic/CircularLinearGauge.js

raw symbols SCIP
1 define([
2 "dojo/_base/lang",
3 "dojo/_base/declare",
4 "dojo/_base/Color",
5 "../../CircularGauge",
6 "../../LinearScaler",
7 "../../CircularScale",
8 "../../CircularValueIndicator",
9 "../../CircularRangeIndicator",
10 "../DefaultPropertiesMixin"
11 ],
12 function(lang, declare, Color, CircularGauge, LinearScaler, CircularScale, CircularValueIndicator, CircularRangeIndicator, DefaultPropertiesMixin){
13 return declare("dojox.dgauges.components.classic.CircularLinearGauge", [CircularGauge, DefaultPropertiesMixin], {
14 // summary:
15 // A circular gauge widget.
16
17 // borderColor: Object|Array|int
18 // The border color. Default is "#797E86".
19 borderColor: [121,126,134],
20 // fillColor: Object|Array|int
21 // The background color. Default is "#9498A1".
22 fillColor: [148,152,161],
23 // indicatorColor: Object|Array|int
24 // The indicator fill color. Default is "#FFFFFF".
25 indicatorColor: "#FFFFFF",
26 constructor: function(){
27 this.borderColor = new Color(this.borderColor);
28 this.fillColor = new Color(this.fillColor);
29 this.indicatorColor = new Color(this.indicatorColor);
30
31 var scaler = new LinearScaler();
32 this.addElement("background", lang.hitch(this, this.drawBackground));
33 var scale = new CircularScale();
34 scale.set("scaler", scaler);
35 scale.set("originX", 81.94991);
36 scale.set("originY", 87.99015);
37 scale.set("radius", 66.34219);
38 scale.set("startAngle", 115.9);
39 scale.set("endAngle", 61.6);
40 scale.set("orientation", "clockwise");
41 scale.set("labelGap", 2);
42 scale.set("font", {
43 family: "Helvetica",
44 weight: "bold",
45 size: "6pt"
46 });
47 this.addElement("scale", scale);
48 var indicator = new CircularValueIndicator();
49 indicator.set("interactionArea", "gauge");
50 indicator.set("value", scaler.minimum);
51 indicator.set("indicatorShapeFunc", lang.hitch(this, function(group, indicator){
52
53 var l = indicator.scale.radius - 2;
54 return group.createPath().moveTo(0, 0).smoothCurveTo(l / 2, -10, l, 0).lineTo(l, 0).smoothCurveTo(l / 2, 10, 0, 0).closePath().setStroke({
55 color: this.borderColor,
56 width: 1,
57 join: 10
58 }).setFill({
59 type: "linear",
60 x1: 0,
61 y1: 0,
62 x2: l,
63 y2: 0,
64 colors: [
65 {offset: 0, color: [208,208,208]},
66 {offset: 1, color: this.indicatorColor}
67 ]
68 });
69
70 }));
71 scale.addIndicator("indicator", indicator);
72 this.addElement("foreground", lang.hitch(this, this.drawForeground));
73 },
74
75 drawBackground: function(g){
76 // summary:
77 // Draws the background shape of the gauge.
78 // g: dojox/gfx/Group
79 // The group used to draw the background.
80 // tags:
81 // protected
82 g.createPath({
83 path: "M81.9213 6.4012 C36.7458 6.4012 0 43.1469 0 88.3225 C0 133.498 36.7458 170.2438 81.9213 170.2438 C127.0968 170.2438 163.8426 133.498 163.8425 88.3225 C163.8425 43.147 127.0968 6.4012 81.9213 6.4012 ZM81.9213 14.6771 C122.6195 14.6771 155.5666 47.6241 155.5666 88.3225 C155.5667 129.0207 122.6195 161.9678 81.9213 161.9678 C41.223 161.9678 8.2759 129.0207 8.2759 88.3225 C8.2759 47.6242 41.223 14.6771 81.9213 14.6771 Z"
84 }).setFill(this.borderColor);
85 g.createPath({
86 path: "M131.7007 23.859 C123.1609 16.836 112.7669 11.9131 100.5479 9.0902 C61.2014 0 20.5795 20.6702 9.8522 55.1976 C9.3592 56.9339 12.7501 58.0358 13.6957 55.5238 C24.6274 24.4073 64.5764 6.1932 100.6316 14.523 C118.2575 18.5951 131.7906 27.3347 141.2184 40.7415 C143.0075 43.6629 146.9334 42.1265 145.2492 39.0652 C141.4153 33.222 136.9106 28.1434 131.7007 23.859 Z"
87 }).setFill({
88 type: "linear",
89 x1: 9.8035,
90 y1: 6.94738,
91 x2: 9.8035,
92 y2: 31.97231,
93 colors: [
94 {offset: 0, color: [235,235,235]},
95 {offset: 1, color: this.borderColor}
96 ]
97 });
98 g.createPath({
99 path: "M128.7453 148.5681 C120.6736 155.591 110.8493 160.5139 99.3 163.3368 C62.1102 172.427 23.715 151.7568 13.5757 117.2294 C13.1097 115.4931 16.3147 114.3912 17.2085 116.9032 C27.541 148.0197 65.3002 166.2338 99.3792 157.904 C116.0389 153.8319 128.8303 145.0923 137.7413 131.6855 C139.4323 128.7641 143.143 130.3005 141.5511 133.3618 C137.9274 139.205 133.6696 144.2836 128.7453 148.5681 Z"
100 }).setFill({
101 type: "linear",
102 x1: 13.52963,
103 y1: 165.47966,
104 x2: 13.52963,
105 y2: 140.45474,
106 colors: [
107 {offset: 0, color: [235,235,235]},
108 {offset: 1, color: this.borderColor}
109 ]
110 });
111 g.createPath({
112 path: "M155.481 88.3136 C155.481 129.2951 122.5479 162.5169 81.9228 162.5169 C41.2978 162.5169 8.3647 129.2951 8.3647 88.3136 C8.3647 47.3323 41.2978 14.1102 81.9228 14.1102 C122.5479 14.1102 155.481 47.3323 155.481 88.3136 Z"
113 }).setFill({
114 type: "linear",
115 x1: 8.3647,
116 y1: 14.11022,
117 x2: 155.48103,
118 y2: 162.51695,
119 colors: [
120 {offset: 0, color: "white"},
121 {offset: 1, color: this.fillColor}
122 ]
123 });
124 g.createPath({
125 path: "M81.9229 13.2351 C40.8398 13.2351 7.4925 46.8859 7.4925 88.3295 C7.4925 129.7729 40.8398 163.3921 81.9229 163.3921 C123.006 163.3921 156.3532 129.7729 156.3532 88.3295 C156.3532 46.8859 123.006 13.2351 81.9229 13.2351 ZM81.9229 14.7211 C122.1911 14.7211 154.8672 47.708 154.8672 88.3295 C154.8672 128.951 122.1911 161.906 81.9229 161.906 C41.6546 161.906 8.9786 128.951 8.9786 88.3295 C8.9786 47.708 41.6546 14.7211 81.9229 14.7211 Z"
126 }).setFill({
127 type: "linear",
128 x1: 7.4925,
129 y1: 13.23515,
130 x2: 7.4925,
131 y2: 163.39214,
132 colors: [
133 {offset: 0, color: "white"},
134 {offset: 1, color: [148,152,161]}
135 ]
136 });
137 },
138
139 drawForeground: function(g){
140 // summary:
141 // Draws the foreground shape of the gauge.
142 // g: dojox/gfx/Group
143 // The group used to draw the foreground.
144 // tags:
145 // protected
146 g.createEllipse({
147 cx: 81.85091,
148 cy: 87.72405,
149 rx: 9.25,
150 ry: 9.25
151 }).setFill({
152 type: "radial",
153 cx: 81.85093,
154 cy: 84.02408,
155 r: 18.5,
156 colors: [
157 {offset: 0, color: [149,149,149]},
158 {offset: 0.5, color: "black"},
159 {offset: 1, color: "black"}
160 ]
161 }).setStroke({
162 color: "black",
163 width: 0.1,
164 style: "Solid",
165 cap: "butt",
166 join: 4.0
167 });
168 }
169
170 });
171 }
172 );
173