Debian Codegraph @

dojox/dgauges/components/grey/HorizontalLinearGauge.js

raw symbols SCIP
1 define([
2 "dojo/_base/lang",
3 "dojo/_base/declare",
4 "dojo/_base/Color",
5 "../../RectangularGauge",
6 "../../LinearScaler",
7 "../../RectangularScale",
8 "../../RectangularValueIndicator",
9 "../DefaultPropertiesMixin"
10 ],
11 function(lang, declare, Color, RectangularGauge, LinearScaler, RectangularScale, RectangularValueIndicator, DefaultPropertiesMixin){
12 return declare("dojox.dgauges.components.grey.HorizontalLinearGauge", [RectangularGauge, DefaultPropertiesMixin], {
13 // summary:
14 // A horizontal gauge widget.
15
16 // borderColor: Object|Array|int
17 // The border color. Default is "#9498A1".
18 borderColor: [148,152,161],
19 // fillColor: Object|Array|int
20 // The background color. Default is "#9498A1".
21 fillColor: [148,152,161],
22 // indicatorColor: Object|Array|int
23 // The indicator fill color. Default is "#3F3F3F".
24 indicatorColor: [63,63,63],
25 constructor: function(){
26 // Base colors
27 this.borderColor = new Color(this.borderColor);
28 this.fillColor = new Color(this.fillColor);
29 this.indicatorColor = new Color(this.indicatorColor);
30
31 this.addElement("background", lang.hitch(this, this.drawBackground));
32
33 // Scaler
34 var scaler = new LinearScaler();
35
36 // Scale
37 var scale = new RectangularScale();
38 scale.set("scaler", scaler);
39 scale.set("labelPosition", "leading");
40 scale.set("paddingLeft", 30);
41 scale.set("paddingRight", 30);
42 scale.set("paddingTop", 28);
43 scale.set("labelGap", 8);
44 scale.set("font", {
45 family: "Helvetica",
46 weight: "bold",
47 size: "7pt"
48 });
49 this.addElement("scale", scale);
50
51 var indicator = new RectangularValueIndicator();
52 indicator.set("interactionArea", "gauge");
53 indicator.set("value", scaler.minimum);
54 indicator.set("paddingTop", 32);
55 indicator.set("indicatorShapeFunc", lang.hitch(this, function(group, indicator){
56
57 return group.createPolyline([0, 0, -10, -20, 10, -20, 0, 0]).setFill(this.indicatorColor).setStroke({
58 color: [70, 70, 70],
59 width: 1,
60 style: "Solid",
61 cap: "butt",
62 join: 20.0
63 });
64
65 }));
66 scale.addIndicator("indicator", indicator);
67 },
68
69 drawBackground: function(g, w, h){
70 // summary:
71 // Draws the background shape of the gauge.
72 // g: dojox/gfx/Group
73 // The group used to draw the background.
74 // w: Number
75 // The width of the gauge.
76 // h: Number
77 // The height of the gauge.
78 // tags:
79 // protected
80 g.createRect({
81 x: 0,
82 y: 0,
83 width: w,
84 height: 50,
85 r: 13.5
86 }).setFill(this.borderColor);
87 g.createRect({
88 x: 2,
89 y: 2,
90 width: w - 4,
91 height: 46,
92 r: 11.5
93 }).setFill({
94 type: "linear",
95 x1: 0,
96 y1: -2,
97 x2: 0,
98 y2: 60,
99 colors: [
100 {offset: 0, color: this.fillColor},
101 {offset: 1, color: "white"}
102 ]
103 });
104 g.createPath().moveTo(2, 25).vLineTo(12).smoothCurveTo(2, 2, 16, 2).hLineTo(w - 12).smoothCurveTo(w - 2, 2, w - 2, 16).closePath().setFill({
105 type: "linear",
106 x1: 0,
107 y1: -5,
108 x2: 0,
109 y2: 40,
110 colors: [
111 {offset: 0, color: "white"},
112 {offset: 1, color: this.fillColor}
113 ]
114 });
115 }
116 });
117 }
118 );
119