Debian Codegraph @

dojox/dgauges/components/green/VerticalLinearGauge.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.VerticalLinearGauge", [RectangularGauge, DefaultPropertiesMixin], {
14 // summary:
15 // A vertical 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 this.orientation = "vertical";
28 // Base colors
29 this.borderColor = new Color(this.borderColor);
30 this.fillColor = new Color(this.fillColor);
31 this.indicatorColor = new Color(this.indicatorColor);
32
33 this.addElement("background", lang.hitch(this, this.drawBackground));
34
35 // Scaler
36 var scaler = new LinearScaler();
37
38 // Scale
39 var scale = new RectangularScale();
40 scale.set("scaler", scaler);
41 scale.set("labelPosition", "trailing");
42 scale.set("paddingTop", 30);
43 scale.set("paddingBottom", 30);
44 scale.set("paddingLeft", 15);
45 scale.set("labelGap", 2);
46 scale.set("font", {
47 family: "Helvetica",
48 weight: "bold",
49 size: "7pt"
50 });
51 this.addElement("scale", scale);
52
53 var indicator = new RectangularValueIndicator();
54 indicator.set("interactionArea", "gauge");
55 indicator.set("value", scaler.minimum);
56 indicator.set("paddingLeft", 18);
57 indicator.set("indicatorShapeFunc", lang.hitch(this, function(group){
58
59 return group.createPolyline([0, 0, -10, -20, 10, -20, 0, 0]).setFill(this.indicatorColor);
60
61 }));
62 scale.addIndicator("indicator", indicator);
63 },
64
65 drawBackground: function(g, w, h){
66 // summary:
67 // Draws the background shape of the gauge.
68 // g: dojox/gfx/Group
69 // The group used to draw the background.
70 // w: Number
71 // The width of the gauge.
72 // h: Number
73 // The height of the gauge.
74 // tags:
75 // protected
76 var lighterFillColor = utils.brightness(new Color(this.fillColor), 100);
77 g.createRect({
78 x: 0,
79 y: 0,
80 width: 50,
81 height: h,
82 r: 10
83 }).setFill(this.borderColor);
84 g.createRect({
85 x: 3,
86 y: 3,
87 width: 44,
88 height: h - 6,
89 r: 7
90 }).setFill({
91 type: "linear",
92 x1: 6,
93 y1: 0,
94 x2: 38,
95 y2: 0,
96 colors: [
97 {offset: 0, color: lighterFillColor},
98 {offset: 1, color: this.fillColor}
99 ]
100 });
101 g.createRect({
102 x: 6,
103 y: 6,
104 width: 38,
105 height: h - 12,
106 r: 6
107 }).setFill({
108 type: "linear",
109 x1: 7,
110 y1: 0,
111 x2: 36,
112 y2: 0,
113 colors: [
114 {offset: 0, color: [226,226,221]},
115 {offset: 0.5, color: [239,239,236]},
116 {offset: 1, color: "white"}
117 ]
118 });
119 }
120
121 });
122 }
123 );
124