Packageflare.vis.axis
Classpublic class Axis
InheritanceAxis Inheritance flash.display.Sprite
ImplementsIScaleMap

A metric data axis consisting of axis labels and gridlines.

Axis labels can be configured both in terms of text formatting, orientation, and position. Use the labelOffsetX or labelOffsetY property to adjust label positioning. For example, labelOffsetX = -10; places the anchor point for the label ten pixels to the left of the data bounds, whereas labelOffsetX = 10; will place the point 10 pixels to the right of the data bounds. One could simultaneously adjust the horizontalAnchor property to align the labels as desired.

Similarly, axis gridlines can also be configured. The lineCapX1, lineCapX2, lineCapY1, and lineCapY2 properties determine by how much the grid lines should exceed the data bounds. For example, lineCapX1 = 5 causes the grid line to extend an extra 5 pixels to the left. Each of these values should be greater than or equal to zero.



Public Properties
 PropertyDefined by
  axisScale : Scale
The Scale used to map values to this axis.
Axis
  fixLabelOverlap : Boolean = true
Flag indicating if labels should be removed in case of overlap.
Axis
  gridLines : Sprite
[read-only] Sprite containing the axis grid lines.
Axis
  horizontalAnchor : int
The horizontal anchor point for axis labels.
Axis
  labelAngle : Number
The angle (orientation) of axis label text.
Axis
  labelColor : uint
The color of axis label text.
Axis
  labelFormat : String
String formatting pattern used for axis labels, overwrites any formatting pattern used by the axisScale.
Axis
  labelOffsetX : Number = 0
X-dimension offset value for axis labels.
Axis
  labelOffsetY : Number = 0
Y-dimension offset value for axis labels.
Axis
  labels : Sprite
[read-only] Sprite containing the axis labels.
Axis
  labelTextFormat : TextFormat
TextFormat (font, size, style) for axis label text.
Axis
  labelTextMode : int
The text rendering mode to use for label TextSprites.
Axis
  lineCapX1 : Number = 0
X offset for axis gridlines at the lower end of the axis.
Axis
  lineCapX2 : Number = 0
X offset for axis gridlines at the upper end of the axis.
Axis
  lineCapY1 : Number = 0
Y offset for axis gridlines at the lower end of the axis.
Axis
  lineCapY2 : Number = 0
Y offset for axis gridlines at the upper end of the axis.
Axis
  lineColor : uint
The line color of axis grid lines.
Axis
  lineLengthX : Number = 0
X length of axis gridlines.
Axis
  lineLengthY : Number = 0
Y length of axis gridlines.
Axis
  lineWidth : Number
The line width of axis grid lines.
Axis
  numLabels : int
The number of labels and gridlines to generate by default.
Axis
  originX : Number
[read-only] The x-coordinate of the axis origin.
Axis
  originY : Number
[read-only] The y-coordinate of the axis origin.
Axis
  showLabels : Boolean = true
Flag indicating if axis labels should be shown.
Axis
  showLines : Boolean = true
Flag indicating if axis grid lines should be shown.
Axis
  verticalAnchor : int
The vertical anchor point for axis labels.
Axis
  x1 : Number
Returns the x-coordinate corresponding to the lower end of the scale.
Axis
  x2 : Number
Returns the x-coordinate corresponding to the upper end of the scale.
Axis
  y1 : Number
Returns the y-coordinate corresponding to the lower end of the scale.
Axis
  y2 : Number
Returns the y-coordinate corresponding to the upper end of the scale.
Axis
Public Methods
 MethodDefined by
  
Axis(axisScale:Scale = null)
Creates a new Axis.
Axis
  
Clears the previous axis scale used, if cached.
Axis
  
offsetX(value:Object):Number
Returns the horizontal offset along the axis for the input value.
Axis
  
offsetY(value:Object):Number
Returns the vertical offset along the axis for the input value.
Axis
  
Updates this axis, performing filtering and layout as needed.
Axis
  
value(x:Number, y:Number, stayInBounds:Boolean = true):Object
Returns the scale value corresponding to a given coordinate.
Axis
  
X(value:Object):Number
Returns the x-coordinate corresponding to the given scale value
Axis
  
Y(value:Object):Number
Returns the y-coordinate corresponding to the given scale value
Axis
Protected Methods
 MethodDefined by
  
Creates a new axis grid line.
Axis
  
createLabel(val:Object):AxisLabel
Creates a new axis label.
Axis
  
filter(trans:Transitioner):void
Performs filtering, determining which axis labels and grid lines should be visible.
Axis
  
findGridLine(val:Object, len:uint):int
Returns the index of a grid lines in the line's container sprite for a given data value.
Axis
  
findLabel(val:Object, len:uint):int
Returns the index of a label in the label's container sprite for a given data value.
Axis
  
Eliminates overlap between labels along an axis.
Axis
  
Initializes the child container sprites for labels and grid lines.
Axis
  
layout(trans:Transitioner):void
Performs layout, setting the position of labels and grid lines.
Axis
  
markRemovals(trans:Transitioner, keep:Array, con:Sprite):void
Marks all items slated for removal from this axis.
Axis
  
positionGridLine(gline:AxisGridLine, scale:Scale):Point
Computes the position of an axis grid line.
Axis
  
positionLabel(label:AxisLabel, scale:Scale):Point
Computes the position of an axis label.
Axis
  
Updates an axis grid line's settings
Axis
  
Updates all grid lines.
Axis
  
updateLabel(label:AxisLabel):void
Updates an axis label's settings
Axis
  
updateLabels():void
Updates all axis labels.
Axis
Property detail
axisScaleproperty
public var axisScale:Scale

The Scale used to map values to this axis.

fixLabelOverlapproperty 
public var fixLabelOverlap:Boolean = true

Flag indicating if labels should be removed in case of overlap.

gridLinesproperty 
gridLines:Sprite  [read-only]

Sprite containing the axis grid lines.

Implementation
    public function get gridLines():Sprite
horizontalAnchorproperty 
horizontalAnchor:int  [read-write]

The horizontal anchor point for axis labels.

Implementation
    public function get horizontalAnchor():int
    public function set horizontalAnchor(value:int):void

See also

flare.display.TextSprite.
labelAngleproperty 
labelAngle:Number  [read-write]

The angle (orientation) of axis label text.

Implementation
    public function get labelAngle():Number
    public function set labelAngle(value:Number):void
labelColorproperty 
labelColor:uint  [read-write]

The color of axis label text.

Implementation
    public function get labelColor():uint
    public function set labelColor(value:uint):void
labelFormatproperty 
labelFormat:String  [read-write]

String formatting pattern used for axis labels, overwrites any formatting pattern used by the axisScale. If null, the formatting pattern for the axisScale is used.

Implementation
    public function get labelFormat():String
    public function set labelFormat(value:String):void
labelOffsetXproperty 
public var labelOffsetX:Number = 0

X-dimension offset value for axis labels. If negative or zero, this value indicates how much to offset to the left of the data bounds. If positive, the offset is made to the right of the data bounds.

labelOffsetYproperty 
public var labelOffsetY:Number = 0

Y-dimension offset value for axis labels. If negative or zero, this value indicates how much to offset above the data bounds. If positive, the offset is made beneath the data bounds.

labelsproperty 
labels:Sprite  [read-only]

Sprite containing the axis labels.

Implementation
    public function get labels():Sprite
labelTextFormatproperty 
labelTextFormat:TextFormat  [read-write]

TextFormat (font, size, style) for axis label text.

Implementation
    public function get labelTextFormat():TextFormat
    public function set labelTextFormat(value:TextFormat):void
labelTextModeproperty 
labelTextMode:int  [read-write]

The text rendering mode to use for label TextSprites.

Implementation
    public function get labelTextMode():int
    public function set labelTextMode(value:int):void

See also

flare.display.TextSprite.
lineCapX1property 
public var lineCapX1:Number = 0

X offset for axis gridlines at the lower end of the axis.

lineCapX2property 
public var lineCapX2:Number = 0

X offset for axis gridlines at the upper end of the axis.

lineCapY1property 
public var lineCapY1:Number = 0

Y offset for axis gridlines at the lower end of the axis.

lineCapY2property 
public var lineCapY2:Number = 0

Y offset for axis gridlines at the upper end of the axis.

lineColorproperty 
lineColor:uint  [read-write]

The line color of axis grid lines.

Implementation
    public function get lineColor():uint
    public function set lineColor(value:uint):void
lineLengthXproperty 
public var lineLengthX:Number = 0

X length of axis gridlines.

lineLengthYproperty 
public var lineLengthY:Number = 0

Y length of axis gridlines.

lineWidthproperty 
lineWidth:Number  [read-write]

The line width of axis grid lines.

Implementation
    public function get lineWidth():Number
    public function set lineWidth(value:Number):void
numLabelsproperty 
numLabels:int  [read-write]

The number of labels and gridlines to generate by default. If this number is zero or less (default -1), the number of labels will be automatically determined from the current scale and size.

Implementation
    public function get numLabels():int
    public function set numLabels(value:int):void
originXproperty 
originX:Number  [read-only]

The x-coordinate of the axis origin.

Implementation
    public function get originX():Number
originYproperty 
originY:Number  [read-only]

The y-coordinate of the axis origin.

Implementation
    public function get originY():Number
showLabelsproperty 
public var showLabels:Boolean = true

Flag indicating if axis labels should be shown.

showLinesproperty 
public var showLines:Boolean = true

Flag indicating if axis grid lines should be shown.

verticalAnchorproperty 
verticalAnchor:int  [read-write]

The vertical anchor point for axis labels.

Implementation
    public function get verticalAnchor():int
    public function set verticalAnchor(value:int):void

See also

flare.display.TextSprite.
x1property 
x1:Number  [read-write]

Returns the x-coordinate corresponding to the lower end of the scale.

Implementation
    public function get x1():Number
    public function set x1(value:Number):void
x2property 
x2:Number  [read-write]

Returns the x-coordinate corresponding to the upper end of the scale.

Implementation
    public function get x2():Number
    public function set x2(value:Number):void
y1property 
y1:Number  [read-write]

Returns the y-coordinate corresponding to the lower end of the scale.

Implementation
    public function get y1():Number
    public function set y1(value:Number):void
y2property 
y2:Number  [read-write]

Returns the y-coordinate corresponding to the upper end of the scale.

Implementation
    public function get y2():Number
    public function set y2(value:Number):void
Constructor detail
Axis()constructor
public function Axis(axisScale:Scale = null)

Creates a new Axis.

Parameters
axisScale:Scale (default = null) — the axis scale to use. If null, a linear scale is assumed.
Method detail
clearPreviousScale()method
public function clearPreviousScale():void

Clears the previous axis scale used, if cached.

createGridLine()method 
protected function createGridLine(val:Object):AxisGridLine

Creates a new axis grid line.

Parameters
val:Object — the value to create the grid lines for

Returns
AxisGridLine — an AxisGridLine
createLabel()method 
protected function createLabel(val:Object):AxisLabel

Creates a new axis label.

Parameters
val:Object — the value to create the label for

Returns
AxisLabel — an AxisLabel
filter()method 
protected function filter(trans:Transitioner):void

Performs filtering, determining which axis labels and grid lines should be visible.

Parameters
trans:Transitioner — a Transitioner for collecting value updates.
findGridLine()method 
protected function findGridLine(val:Object, len:uint):int

Returns the index of a grid lines in the line's container sprite for a given data value.

Parameters
val:Object — the data value to find
 
len:uint — the number of grid lines to check

Returns
int — the index of a grid line with matching value, or -1 if no grid line was found
findLabel()method 
protected function findLabel(val:Object, len:uint):int

Returns the index of a label in the label's container sprite for a given data value.

Parameters
val:Object — the data value to find
 
len:uint — the number of labels to check

Returns
int — the index of a label with matching value, or -1 if no label was found
fixOverlap()method 
protected function fixOverlap(trans:Transitioner):void

Eliminates overlap between labels along an axis.

Parameters
trans:Transitioner — a transitioner, potentially storing label positions
initializeChildren()method 
protected function initializeChildren():void

Initializes the child container sprites for labels and grid lines.

layout()method 
protected function layout(trans:Transitioner):void

Performs layout, setting the position of labels and grid lines.

Parameters
trans:Transitioner — a Transitioner for collecting value updates.
markRemovals()method 
protected function markRemovals(trans:Transitioner, keep:Array, con:Sprite):void

Marks all items slated for removal from this axis.

Parameters
trans:Transitioner — a Transitioner for collecting value updates.
 
keep:Array — a Boolean array indicating which items to keep
 
con:Sprite — a container Sprite whose contents should be marked for removal
offsetX()method 
public function offsetX(value:Object):Number

Returns the horizontal offset along the axis for the input value.

Parameters
value:Object — an input data value

Returns
Number — the horizontal offset along the axis corresponding to the input value. This is the x-position minus x1.
offsetY()method 
public function offsetY(value:Object):Number

Returns the vertical offset along the axis for the input value.

Parameters
value:Object — an input data value

Returns
Number — the vertical offset along the axis corresponding to the input value. This is the y-position minus y1.
positionGridLine()method 
protected function positionGridLine(gline:AxisGridLine, scale:Scale):Point

Computes the position of an axis grid line.

Parameters
gline:AxisGridLine — the axis grid line to layout
 
scale:Scale — the scale used to map values to the axis

Returns
Point — a Point with x,y coordinates for the axis grid line
positionLabel()method 
protected function positionLabel(label:AxisLabel, scale:Scale):Point

Computes the position of an axis label.

Parameters
label:AxisLabel — the axis label to layout
 
scale:Scale — the scale used to map values to the axis

Returns
Point — a Point with x,y coordinates for the axis label
update()method 
public function update(trans:Transitioner):Transitioner

Updates this axis, performing filtering and layout as needed.

Parameters
trans:Transitioner — a Transitioner for collecting value updates

Returns
Transitioner — the input transitioner.
updateGridLine()method 
protected function updateGridLine(gline:AxisGridLine):void

Updates an axis grid line's settings

Parameters
gline:AxisGridLine — the grid line to update
updateGridLines()method 
protected function updateGridLines():void

Updates all grid lines.

updateLabel()method 
protected function updateLabel(label:AxisLabel):void

Updates an axis label's settings

Parameters
label:AxisLabel — the label to update
updateLabels()method 
protected function updateLabels():void

Updates all axis labels.

value()method 
public function value(x:Number, y:Number, stayInBounds:Boolean = true):Object

Returns the scale value corresponding to a given coordinate.

Parameters
x:Number — the x-coordinate
 
y:Number — the y-coordinate
 
stayInBounds:Boolean (default = true) — if true, x,y values outside the current layout bounds will be snapped to the bounds. If false, the value lookup will attempt to extrapolate beyond the scale bounds. This value is true be default.

Returns
Object — the scale value corresponding to the given coordinate.
X()method 
public function X(value:Object):Number

Returns the x-coordinate corresponding to the given scale value

Parameters
value:Object — the scale value to lookup

Returns
Number — the x-coordinate at which that scale value is placed
Y()method 
public function Y(value:Object):Number

Returns the y-coordinate corresponding to the given scale value

Parameters
value:Object — the scale value to lookup

Returns
Number — the y-coordinate at which that scale value is placed