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

Last change on this file since 7849 was 7849, checked in by dennisw, 15 years ago
File size: 2.9 KB
Line 
1package charts {
2
3 import charts.series.dots.scat;
4 import charts.series.Element;
5 import charts.series.dots.dot_factory;
6 import string.Utils;
7 import flash.geom.Point;
8 import flash.display.Sprite;
9 import charts.series.dots.DefaultDotProperties;
10
11 public class ScatterBase extends Base {
12
13 // TODO: move this into Base
14 protected var props:Properties;
15 protected var style:Object;
16 private var on_show:Properties;
17 private var dot_style:Properties;
18 //
19
20 protected var default_style:DefaultDotProperties;
21
22 public function ScatterBase(json:Object) {
23
24 //
25 // merge into Line.as and Base.as
26 //
27 var root:Properties = new Properties({
28 colour: '#3030d0',
29 text: '', // <-- default not display a key
30 'font-size': 12,
31 tip: '#val#',
32 axis: 'left'
33 });
34 //
35 this.props = new Properties(json, root);
36 //
37 this.dot_style = new DefaultDotProperties(json['dot-style'], this.props.get('colour'), this.props.get('axis'));
38 //
39 // LOOK for a scatter chart the default dot is NOT invisible!!
40 //
41 // this.dot_style.set('type', 'solid-dot');
42 //
43 // LOOK default animation for scatter is explode, no cascade
44 //
45 var on_show_root:Properties = new Properties( {
46 type: "explode",
47 cascade: 0,
48 delay: 0.3
49 });
50 this.on_show = new Properties(json['on-show'], on_show_root);
51 //this.on_show_start = true;
52 //
53 //
54 }
55
56 //
57 // called from the base object
58 //
59 protected override function get_element( index:Number, value:Object ): Element {
60 // we ignore the X value (index) passed to us,
61 // the user has provided their own x value
62
63 var default_style:Object = {
64 width: this.style.width, // stroke
65 colour: this.style.colour,
66 tip: this.style.tip,
67 'dot-size': 10
68 };
69
70 // Apply dot style defined at the plot level
71 object_helper.merge_2( this.style['dot-style'], default_style );
72 // Apply attributes defined at the value level
73 object_helper.merge_2( value, default_style );
74
75 // our parent colour is a number, but
76 // we may have our own colour:
77 if( default_style.colour is String )
78 default_style.colour = Utils.get_colour( default_style.colour );
79
80 //var tmp:Properties = new Properties( value, this.default_style);
81 var tmp:Properties = new Properties(value, this.dot_style);
82
83 // attach the animation bits:
84 tmp.set('on-show', this.on_show);
85
86 return dot_factory.make( index, tmp );
87 }
88
89 // Draw points...
90 public override function resize( sc:ScreenCoordsBase ): void {
91
92 var tmp:Sprite;
93 for ( var i:Number = 0; i < this.numChildren; i++ ) {
94 tmp = this.getChildAt(i) as Sprite;
95
96 //
97 // filter out the line masks
98 //
99 if( tmp is Element )
100 {
101 var e:Element = tmp as Element;
102 e.resize( sc );
103 }
104 }
105 }
106 }
107}
Note: See TracBrowser for help on using the repository browser.