source: code/Website/open-flash-chart/charts/HBar.as@ 7849

Last change on this file since 7849 was 7849, checked in by dennisw, 15 years ago
File size: 2.4 KB
Line 
1package charts {
2 import charts.series.Element;
3 import charts.series.bars.Horizontal;
4 import string.Utils;
5 import global.Global;
6
7 public class HBar extends Base {
8
9 protected var group:Number;
10 protected var style:Object;
11
12 public function HBar( json:Object ) {
13
14 this.style = {
15 values: [],
16 colour: '#3030d0',
17 text: '', // <-- default not display a key
18 'font-size': 12,
19 tip: '#val#'
20 };
21
22 object_helper.merge_2( json, style );
23
24 //this.alpha = Number( vals[0] );
25 this.colour = string.Utils.get_colour( style.colour );
26 this.key = json.text;
27 this.font_size = json['font-size'];
28
29 //
30 // bars are grouped, so 3 bar sets on one chart
31 // will arrange them selves next to each other
32 // at each value of X, this.group tell the bar
33 // where it is in that grouping
34 //
35 this.group = 0;
36
37 this.values = json['values'];
38
39 this.style['on-click'] = json['on-click'];
40
41 this.add_values();
42 }
43
44 //
45 // called from the base object, in this case the
46 // value is the X value of the bar and the index
47 // is the Y positiont
48 //
49 protected override function get_element( index:Number, value:Object ): Element {
50
51 var default_style:Object = {
52 colour: this.style.colour,
53 tip: this.style.tip,
54 'on-click': this.style['on-click']
55 };
56
57 if( value is Number )
58 default_style.top = value;
59 else
60 object_helper.merge_2( value, default_style );
61
62 // our parent colour is a number, but
63 // we may have our own colour:
64 if( default_style.colour is String )
65 default_style.colour = Utils.get_colour( default_style.colour );
66
67 return new Horizontal( index, default_style, this.group );
68 }
69
70 public override function resize( sc:ScreenCoordsBase ): void {
71
72 for ( var i:Number = 0; i < this.numChildren; i++ )
73 {
74 var p:Horizontal = this.getChildAt(i) as Horizontal;
75 p.resize( sc );
76 }
77 }
78
79 public override function get_max_x():Number {
80
81 var x:Number = 0;
82 //
83 // count the non-mask items:
84 //
85 for ( var i:Number = 0; i < this.numChildren; i++ )
86 if( this.getChildAt(i) is Horizontal ) {
87
88 var h:Horizontal = this.getChildAt(i) as Horizontal;
89 x = Math.max( x, h.get_max_x() );
90
91 }
92
93 return x;
94 }
95
96 public override function get_min_x():Number {
97 return 0;
98 }
99
100 }
101}
Note: See TracBrowser for help on using the repository browser.