1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
class YAxis
{
private var _width:Number=0;
private var ticks:YTicks;
private var grid_colour:Number;
private var axis_colour:Number;
//private var count:Number;
private var mc:MovieClip;
private var line_width:Number = 2;
private var min:Number;
private var max:Number;
private var steps:Number;
function YAxis( y_ticks:YTicks, lv:LoadVars, min:Number, max:Number, steps:Number, nr:Number )
{
// ticks: thin and wide ticks
this.ticks = y_ticks;
if( lv.y_grid_colour != undefined )
this.grid_colour = _root.get_colour( lv.y_grid_colour );
else
this.grid_colour = 0xF5E1AA;
if(nr != 2) {
if( lv.y_axis_colour != undefined )
this.axis_colour = _root.get_colour( lv.y_axis_colour );
else
this.axis_colour = 0x784016;
}else{
if( lv.y2_axis_colour != undefined )
this.axis_colour = _root.get_colour( lv.y2_axis_colour );
else
this.axis_colour = 0x784016;
}
//this.count = count;
this.min = min;
this.max = max;
this.steps = steps;
if(nr == 1)
this.mc = _root.createEmptyMovieClip( "y_axis", _root.getNextHighestDepth() );
else if(nr==2)
this.mc = _root.createEmptyMovieClip( "y_axis2", _root.getNextHighestDepth() );
this._width = this.line_width + Math.max( this.ticks.small, this.ticks.big );
}
function move( box:Box, nr:Number )
{
if( nr == 2 )
{
if( !_root.lv.show_y2 )
return;
// Create the new axel
this.mc.clear();
this.mc.lineStyle(this.line_width,this.axis_colour,100);
this.mc.moveTo( box.right, box.top );
this.mc.lineTo( box.right, box.bottom );
// create new ticks..
var every:Number = (this.max-this.min)/this.steps;
for( var i:Number=this.min; i<=this.max; i+=every )
{
// start at the bottom and work up:
var y:Number = box.getY(i);
this.mc.moveTo( box.right, y );
if( i % this.ticks.steps == 0 )
this.mc.lineTo( box.right+this.ticks.big, y );
else
this.mc.lineTo( box.right+this.ticks.small, y );
}
return;
}
// this should be an option:
this.mc.clear();
// Ticks
//var tick:Number = box.height/(this.count-1);
// Grid lines
this.mc.lineStyle(1,this.grid_colour,100);
// for( var i:Number=0; i < this.count; i++)
// {
// var y:Number = box.top+(i*tick);
// this.mc.moveTo( box.left, y );
// this.mc.lineTo( box.right, y );
// }
// y axel grid lines
var every:Number = (this.max-this.min)/this.steps;
// Set opacity for the first line to 0 (otherwise it overlaps the x-axel line)
//
// Bug? Does this work on graphs with minus values?
//
var i2:Number=0;
for( var i:Number=this.min; i<=this.max; i+=every )
{
var y:Number = box.getY(i);
if(i2 == 0)
this.mc.lineStyle(1,this.grid_colour,0);
this.mc.moveTo( box.left, y );
this.mc.lineTo( box.right, y );
if(i2 == 0)
this.mc.lineStyle(1,this.grid_colour,100);
i2 +=1;
}
this.mc.lineStyle(this.line_width,this.axis_colour,100);
this.mc.moveTo( box.left, box.top );
this.mc.lineTo( box.left, box.bottom );
// ticks..
var every:Number = (this.max-this.min)/this.steps;
for( var i:Number=this.min; i<=this.max; i+=every )
{
// start at the bottom and work up:
var y:Number = box.getY(i);
this.mc.moveTo( box.left, y );
if( i % this.ticks.steps == 0 )
this.mc.lineTo( box.left-this.ticks.big, y );
else
this.mc.lineTo( box.left-this.ticks.small, y );
}
}
function width()
{
return this._width;
}
}
|