1 | package charts {
|
---|
2 | import charts.Elements.Element;
|
---|
3 | import charts.Elements.PointBarCandle;
|
---|
4 | import string.Utils;
|
---|
5 |
|
---|
6 | public class BarCandle extends BarBase {
|
---|
7 | //private var line_width:Number;
|
---|
8 |
|
---|
9 | public function BarCandle( lv:Array, num:Number, group:Number ) {
|
---|
10 | super( lv, num, group, 'candle' );
|
---|
11 | }
|
---|
12 |
|
---|
13 | public override function parse_bar( val:Object ):void {
|
---|
14 | var vals:Array = val.split(",");
|
---|
15 |
|
---|
16 | //this.alpha = Number( vals[0] );
|
---|
17 | this.line_width = Number( vals[1] );
|
---|
18 | this.colour = Utils.get_colour(vals[2]);
|
---|
19 |
|
---|
20 | if( vals.length > 3 )
|
---|
21 | this.key = vals[3].replace('#comma#',',');
|
---|
22 |
|
---|
23 | if( vals.length > 4 )
|
---|
24 | this.font_size = Number( vals[4] );
|
---|
25 | }
|
---|
26 |
|
---|
27 | //
|
---|
28 | // the data looks like "[1,2,3,4],[2,3,4,5]"
|
---|
29 | // this returns an array of strings like '1,2,3,4','2,3,4,5'
|
---|
30 | // these are then parsed further in PointBarCandle
|
---|
31 | //
|
---|
32 | protected override function parse_list( values:String ):Array {
|
---|
33 | var groups:Array=new Array();
|
---|
34 | var tmp:String = '';
|
---|
35 | var start:Boolean = false;
|
---|
36 |
|
---|
37 | for( var i:Number=0; i<values.length; i++ )
|
---|
38 | {
|
---|
39 | switch( values.charAt(i) )
|
---|
40 | {
|
---|
41 | case '[':
|
---|
42 | start=true;
|
---|
43 | break;
|
---|
44 | case ']':
|
---|
45 | start = false;
|
---|
46 | groups.push( tmp );
|
---|
47 | tmp = '';
|
---|
48 | break;
|
---|
49 | default:
|
---|
50 | if( start )
|
---|
51 | tmp += values.charAt(i);
|
---|
52 | break;
|
---|
53 | }
|
---|
54 | }
|
---|
55 | return groups;
|
---|
56 | }
|
---|
57 |
|
---|
58 |
|
---|
59 | //
|
---|
60 | // called from the base object
|
---|
61 | //
|
---|
62 | protected override function get_element( x:Number, value:Object ): Element {
|
---|
63 | return new PointBarCandle( x, value, this.line_width, this.colour, this.group );
|
---|
64 | }
|
---|
65 | }
|
---|
66 | }
|
---|