Debian Codegraph @

dojox/dgauges/components/green/HorizontalLinearGauge.js

raw symbols SCIP
1 define([
2 "dojo/_base/lang",
3 "dojo/_base/declare",
4 "dojo/_base/Color",
5 "../utils",
6 "../../RectangularGauge",
7 "../../LinearScaler",
8 "../../RectangularScale",
9 "../../RectangularValueIndicator",
10 "../DefaultPropertiesMixin"
11 ],
12 function(lang, declare, Color, utils, RectangularGauge, LinearScaler, RectangularScale, RectangularValueIndicator, DefaultPropertiesMixin){
13 return declare("dojox.dgauges.components.green.HorizontalLinearGauge", [RectangularGauge, DefaultPropertiesMixin], {
14 // summary:
15 // A horizontal gauge widget.
16
17 // borderColor: Object|Array|int
18 // The border color. Default is "#323232".
19 borderColor: [50,50,50],
20 // fillColor: Object|Array|int
21 // The background color. Default is "#6DB713".
22 fillColor: [109,183,19],
23 // indicatorColor: Object|Array|int
24 // The indicator fill color. Default is "#000000".
25 indicatorColor: [0,0,0],
26 constructor: function(){
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", "leading");
41 scale.set("paddingLeft", 30);
42 scale.set("paddingRight", 30);
43 scale.set("paddingTop", 28);
44 scale.set("labelGap", 2);
45 scale.set("font", {
46 family: "Helvetica",
47 weight: "bold",
48 size: "7pt"
49 });
50 this.addElement("scale", scale);
51
52 var indicator = new RectangularValueIndicator();
53 indicator.set("interactionArea", "gauge");
54 indicator.set("value", scaler.minimum);
55 indicator.set("paddingTop", 32);
56 indicator.set("indicatorShapeFunc", lang.hitch(this, function(group, indicator){
57
58 return group.createPolyline([0, 0, -10, -20, 10, -20, 0, 0]).setFill(this.indicatorColor);
59
60 }));
61 scale.addIndicator("indicator", indicator);
62 },
63
64 drawBackground: function(g, w, h){
65 // summary:
66 // Draws the background shape of the gauge.
67 // g: dojox/gfx/Group
68 // The group used to draw the background.
69 // w: Number
70 // The width of the gauge.
71 // h: Number
72 // The height of the gauge.
73 // tags:
74 // protected
75 var lighterFillColor = utils.brightness(new Color(this.fillColor), 100);
76 g.createRect({
77 x: 0,
78 y: 0,
79 width: w,
80 height: 50,
81 r: 10
82 }).setFill(this.borderColor);
83 g.createRect({
84 x: 3,
85 y: 3,
86 width: w - 6,
87 height: 44,
88 r: 7
89 }).setFill({
90 type: "linear",
91 x1: 0,
92 y1: 2,
93 x2: 0,
94 y2: 30,
95 colors: [
96 {offset: 0, color: lighterFillColor},
97 {offset: 1, color: this.fillColor}
98 ]
99 });
100 g.createRect({
101 x: 6,
102 y: 6,
103 width: w - 12,
104 height: 38,
105 r: 5
106 }).setFill({
107 type: "linear",
108 x1: 0,
109 y1: 6,
110 x2: 0,
111 y2: 38,
112 colors: [
113 {offset: 0, color: [226,226,221]},
114 {offset: 0.5, color: [239,239,236]},
115 {offset: 1, color: "white"}
116 ]
117 });
118 }
119 });
120 }
121 );
122