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.grey.CircularLinearGauge", [CircularGauge, DefaultPropertiesMixin], { |
---|
15 | // summary: |
---|
16 | // A circular gauge widget. |
---|
17 | |
---|
18 | // borderColor: Object|Array|int |
---|
19 | // The border color. Default is "#9498A1". |
---|
20 | borderColor: [148,152,161], |
---|
21 | // fillColor: Object|Array|int |
---|
22 | // The background color. Default is "#9498A1". |
---|
23 | fillColor: [148,152,161], |
---|
24 | // indicatorColor: Object|Array|int |
---|
25 | // The indicator fill color. Default is "#3F3F3F". |
---|
26 | indicatorColor: [63,63,63], |
---|
27 | constructor: function(args, node){ |
---|
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", 73.4); |
---|
33 | scale.set("originY", 74.10297); |
---|
34 | scale.set("radius", 61.44239); |
---|
35 | scale.set("startAngle", 130.16044); |
---|
36 | scale.set("endAngle", 50.25444); |
---|
37 | scale.set("orientation", "clockwise"); |
---|
38 | scale.set("labelGap", 2); |
---|
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(0, 0).lineTo(0, -5).lineTo(l, 0).lineTo(0, 0).closePath().setFill(this.indicatorColor); |
---|
52 | var lighterColor = utils.brightness(new Color(this.indicatorColor), 70); |
---|
53 | group.createPath().moveTo(0, 0).lineTo(0, 5).lineTo(l, 0).lineTo(0, 0).closePath().setFill(lighterColor); |
---|
54 | return group; |
---|
55 | |
---|
56 | })); |
---|
57 | scale.addIndicator("indicator", indicator); |
---|
58 | this.addElement("foreground", lang.hitch(this, this.drawForeground)); |
---|
59 | }, |
---|
60 | |
---|
61 | drawBackground: function(g){ |
---|
62 | // summary: |
---|
63 | // Draws the background shape of the gauge. |
---|
64 | // g: dojox/gfx/Group |
---|
65 | // The group used to draw the background. |
---|
66 | // tags: |
---|
67 | // protected |
---|
68 | g.createEllipse({ |
---|
69 | cx: 73.5, |
---|
70 | cy: 73.75, |
---|
71 | rx: 73.5, |
---|
72 | ry: 73.75 |
---|
73 | }).setFill(this.borderColor); |
---|
74 | g.createEllipse({ |
---|
75 | cx: 73.5, |
---|
76 | cy: 73.75, |
---|
77 | rx: 71.5, |
---|
78 | ry: 71.75 |
---|
79 | }).setFill({ |
---|
80 | type: "linear", |
---|
81 | x1: 2, |
---|
82 | y1: 2, |
---|
83 | x2: 2, |
---|
84 | y2: 174.2, |
---|
85 | colors: [ |
---|
86 | {offset: 0, color: this.fillColor}, |
---|
87 | {offset: 1, color: "white"} |
---|
88 | ] |
---|
89 | }); |
---|
90 | g.createPath({ |
---|
91 | path: "M71.7134 2.3627 C35.3338 3.0547 6.0025 32.818 6.0025 69.3621 C6.0025 69.7225 5.9968 70.0836 6.0025 70.4427 C26.4442 78.2239 50.1913 82.6622 75.4956 82.6622 C98.7484 82.6622 120.6538 78.8779 139.918 72.2299 C139.9587 71.2717 140.0011 70.3303 140.0011 69.3621 C140.0011 32.3847 109.9791 2.3627 73.0018 2.3627 C72.5685 2.3627 72.1447 2.3545 71.7133 2.3627 Z" |
---|
92 | }).setFill({ |
---|
93 | type: "linear", |
---|
94 | x1: 6, |
---|
95 | y1: 2.3591, |
---|
96 | x2: 6, |
---|
97 | y2: 150, |
---|
98 | colors: [ |
---|
99 | {offset: 0, color: "white"}, |
---|
100 | {offset: 1, color: this.fillColor} |
---|
101 | ] |
---|
102 | }); |
---|
103 | }, |
---|
104 | |
---|
105 | drawForeground: function(g){ |
---|
106 | // summary: |
---|
107 | // Draws the foreground shape of the gauge. |
---|
108 | // g: dojox/gfx/Group |
---|
109 | // The group used to draw the foreground. |
---|
110 | // tags: |
---|
111 | // protected |
---|
112 | g.createEllipse({ |
---|
113 | cx: 73.3, |
---|
114 | cy: 73.8, |
---|
115 | rx: 9.25, |
---|
116 | ry: 9.25 |
---|
117 | }).setFill({ |
---|
118 | type: "radial", |
---|
119 | cx: 73.30003, |
---|
120 | cy: 70.10003, |
---|
121 | r: 18.5, |
---|
122 | colors: [ |
---|
123 | {offset: 0, color: [149,149,149]}, |
---|
124 | {offset: 0.5, color: "black"}, |
---|
125 | {offset: 1, color: "black"} |
---|
126 | ] |
---|
127 | }).setStroke({ |
---|
128 | color: "black", |
---|
129 | width: 0.1, |
---|
130 | style: "Solid", |
---|
131 | cap: "butt", |
---|
132 | join: 4.0 |
---|
133 | }); |
---|
134 | } |
---|
135 | |
---|
136 | }); |
---|
137 | } |
---|
138 | ); |
---|
139 | |
---|