1 | package charts.series.pies {
|
---|
2 |
|
---|
3 | import string.Utils;
|
---|
4 | import charts.series.has_tooltip;
|
---|
5 | import flash.text.TextField;
|
---|
6 | import flash.text.TextFormat;
|
---|
7 |
|
---|
8 | public class PieLabel extends TextField implements has_tooltip{
|
---|
9 | public var is_over:Boolean;
|
---|
10 | private static var TO_RADIANS:Number = Math.PI / 180;
|
---|
11 |
|
---|
12 | public function PieLabel( style:Object )
|
---|
13 | {
|
---|
14 |
|
---|
15 | this.text = style.label;
|
---|
16 | // legend_tf._rotation = 3.6*value.bar_bottom;
|
---|
17 |
|
---|
18 | var fmt:TextFormat = new TextFormat();
|
---|
19 | fmt.color = string.Utils.get_colour( style.colour );
|
---|
20 | fmt.font = "Verdana";
|
---|
21 | fmt.size = style['font-size'];
|
---|
22 | fmt.align = "center";
|
---|
23 | this.setTextFormat(fmt);
|
---|
24 | this.autoSize = "left";
|
---|
25 |
|
---|
26 | this.mouseEnabled = false;
|
---|
27 | }
|
---|
28 |
|
---|
29 | public function move_label( rad:Number, x:Number, y:Number, ang:Number ):Boolean {
|
---|
30 |
|
---|
31 | //text field position
|
---|
32 | var legend_x:Number = x+rad*Math.cos((ang)*TO_RADIANS);
|
---|
33 | var legend_y:Number = y+rad*Math.sin((ang)*TO_RADIANS);
|
---|
34 |
|
---|
35 | //if legend stands to the right side of the pie
|
---|
36 | if(legend_x<x)
|
---|
37 | legend_x -= this.width;
|
---|
38 |
|
---|
39 | //if legend stands on upper half of the pie
|
---|
40 | if(legend_y<y)
|
---|
41 | legend_y -= this.height;
|
---|
42 |
|
---|
43 | this.x = legend_x;
|
---|
44 | this.y = legend_y;
|
---|
45 |
|
---|
46 | // does the label fit onto the stage?
|
---|
47 | if( (this.x > 0) &&
|
---|
48 | (this.y > 0) &&
|
---|
49 | (this.y + this.height < this.stage.stageHeight ) &&
|
---|
50 | (this.x+this.width<this.stage.stageWidth) )
|
---|
51 | return true;
|
---|
52 | else
|
---|
53 | return false;
|
---|
54 | }
|
---|
55 |
|
---|
56 | public function get_tooltip():String {
|
---|
57 | tr.ace(( this.parent as has_tooltip ).get_tooltip());
|
---|
58 | return ( this.parent as has_tooltip ).get_tooltip();
|
---|
59 | }
|
---|
60 |
|
---|
61 | public function get_tip_pos():Object {
|
---|
62 | return ( this.parent as has_tooltip ).get_tip_pos();
|
---|
63 | }
|
---|
64 |
|
---|
65 | public function set_tip( b:Boolean ):void {
|
---|
66 | return ( this.parent as has_tooltip ).set_tip(b);
|
---|
67 | }
|
---|
68 |
|
---|
69 | public function resize( sc:ScreenCoords ): void {
|
---|
70 |
|
---|
71 | }
|
---|
72 | }
|
---|
73 | }
|
---|