source: Dev/branches/rest-dojo-ui/client/dojox/gauges/TextIndicator.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 1.8 KB
Line 
1define(["dojo/_base/declare","./_Indicator"],
2  function(declare, Indicator) {
3
4/*=====
5        Indicator = dojox.gauges._Indicator;
6=====*/
7
8return declare("dojox.gauges.TextIndicator", [Indicator], {
9        // summary:
10        //              A gauge indicator the simply draws its value as text.
11       
12       
13        // x: Number
14        //              The x coordinate of the indicator
15        x: 0,
16       
17        // y: Number
18        //              The y coordinate of the indicator
19        y: 0,
20       
21        // align: String
22        //              The horizontal alignment of the text, the value can be 'middle' (the default), 'left' or 'right'
23        align: 'middle',
24       
25        // fixedPrecision: Boolean
26        //              Indicates that the number is displayed in fixed precision or not (precision is defined by the 'precision' property (default is true).
27        fixedPrecision: true,
28       
29        // precision: Number
30        //              The number of tailing digits to display the value of the indicator when the 'fixedPrecision' property is set to true (default is 0).
31        precision: 0,
32       
33        draw: function(group, /*Boolean?*/ dontAnimate){
34                // summary:
35                //              Override of dojox.gauges._Indicator.draw
36                var v = this.value;
37               
38                if (v < this._gauge.min) {
39                        v = this._gauge.min;
40                }
41                if (v > this._gauge.max) {
42                        v = this._gauge.max;
43                }
44                var txt;
45                var NumberUtils = this._gauge ? this._gauge._getNumberModule() : null;
46                if (NumberUtils) {
47                        txt = this.fixedPrecision ? NumberUtils.format(v, {
48                                places: this.precision
49                        }) : NumberUtils.format(v);
50                } else {
51                        txt = this.fixedPrecision ? v.toFixed(this.precision) : v.toString();
52                }
53               
54                var x = this.x ? this.x : 0;
55                var y = this.y ? this.y : 0;
56                var align = this.align ? this.align : "middle";
57                if(!this.shape){
58                        this.shape = group.createText({
59                                x: x,
60                                y: y,
61                                text: txt,
62                                align: align
63                        });
64                }else{
65                        this.shape.setShape({
66                                x: x,
67                                y: y,
68                                text: txt,
69                                align: align
70                        });
71                }
72                this.shape.setFill(this.color);
73                if (this.font) this.shape.setFont(this.font);
74               
75        }
76       
77});
78});
Note: See TracBrowser for help on using the repository browser.