| 1 | package charts {
|
|---|
| 2 | import charts.series.Element;
|
|---|
| 3 | import charts.series.dots.PointDotBase;
|
|---|
| 4 | import charts.series.dots.Point;
|
|---|
| 5 | import string.Utils;
|
|---|
| 6 | import flash.display.BlendMode;
|
|---|
| 7 | import flash.geom.Point;
|
|---|
| 8 | import flash.display.Sprite;
|
|---|
| 9 | import charts.series.dots.DefaultDotProperties;
|
|---|
| 10 |
|
|---|
| 11 | public class Area extends Line {
|
|---|
| 12 | private var fill_colour:Number;
|
|---|
| 13 | private var area_base:Number;
|
|---|
| 14 |
|
|---|
| 15 | public function Area( json:Object ) {
|
|---|
| 16 | super(json);
|
|---|
| 17 |
|
|---|
| 18 | var fill:String;
|
|---|
| 19 | if (json.fill)
|
|---|
| 20 | fill = json.fill;
|
|---|
| 21 | else
|
|---|
| 22 | fill = json.colour;
|
|---|
| 23 |
|
|---|
| 24 | this.fill_colour = string.Utils.get_colour(fill);
|
|---|
| 25 |
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 | public override function resize( sc:ScreenCoordsBase ): void {
|
|---|
| 30 |
|
|---|
| 31 | var right_axis:Boolean = false;
|
|---|
| 32 |
|
|---|
| 33 | if ( props.has('axis') )
|
|---|
| 34 | if ( props.get('axis') == 'right' )
|
|---|
| 35 | right_axis = true;
|
|---|
| 36 |
|
|---|
| 37 | // save this position
|
|---|
| 38 | this.area_base = sc.get_y_bottom(right_axis);
|
|---|
| 39 |
|
|---|
| 40 | // let line deal with the resize
|
|---|
| 41 | super.resize(sc);
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | //
|
|---|
| 45 | // this is called from both resize and the animation manager,
|
|---|
| 46 | //
|
|---|
| 47 | protected override function draw(): void {
|
|---|
| 48 | this.graphics.clear();
|
|---|
| 49 | this.fill_area();
|
|---|
| 50 | // draw the line on top of the area (z axis)
|
|---|
| 51 | this.draw_line();
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | private function fill_area():void {
|
|---|
| 55 |
|
|---|
| 56 | var last:Element;
|
|---|
| 57 | var first:Boolean = true;
|
|---|
| 58 | var tmp:Sprite;
|
|---|
| 59 |
|
|---|
| 60 | for ( var i:Number = 0; i < this.numChildren; i++ ) {
|
|---|
| 61 |
|
|---|
| 62 | tmp = this.getChildAt(i) as Sprite;
|
|---|
| 63 |
|
|---|
| 64 | // filter out the masks
|
|---|
| 65 | if( tmp is Element ) {
|
|---|
| 66 |
|
|---|
| 67 | var e:Element = tmp as Element;
|
|---|
| 68 |
|
|---|
| 69 | if( first )
|
|---|
| 70 | {
|
|---|
| 71 |
|
|---|
| 72 | first = false;
|
|---|
| 73 |
|
|---|
| 74 | if (this.props.get('loop'))
|
|---|
| 75 | {
|
|---|
| 76 | // assume we are in a radar chart
|
|---|
| 77 | this.graphics.moveTo( e.x, e.y );
|
|---|
| 78 | }
|
|---|
| 79 | else
|
|---|
| 80 | {
|
|---|
| 81 | // draw line from Y=0 up to Y pos
|
|---|
| 82 | this.graphics.moveTo( e.x, this.area_base );
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | //
|
|---|
| 86 | // TO FIX BUG: you must do a graphics.moveTo before
|
|---|
| 87 | // starting a fill:
|
|---|
| 88 | //
|
|---|
| 89 | this.graphics.lineStyle(0,0,0);
|
|---|
| 90 | this.graphics.beginFill( this.fill_colour, this.props.get('fill-alpha') );
|
|---|
| 91 |
|
|---|
| 92 | if (!this.props.get('loop'))
|
|---|
| 93 | this.graphics.lineTo( e.x, e.y );
|
|---|
| 94 |
|
|---|
| 95 | }
|
|---|
| 96 | else
|
|---|
| 97 | {
|
|---|
| 98 | this.graphics.lineTo( e.x, e.y );
|
|---|
| 99 | last = e;
|
|---|
| 100 | }
|
|---|
| 101 | }
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | if ( last != null ) {
|
|---|
| 105 | if ( !this.props.get('loop')) {
|
|---|
| 106 | this.graphics.lineTo( last.x, this.area_base );
|
|---|
| 107 | }
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 | this.graphics.endFill();
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | }
|
|---|
| 115 | }
|
|---|