Packageflare.analytics.optimization
Classpublic class AspectRatioBanker
InheritanceAspectRatioBanker Inheritance Operator

Computes an optimized aspect ratio for drawing a line chart. This operator will update the visualization's bounds to reflect the optimized aspect ratio. Place this operator in an OperatorList before the AxisLayout operator, and set the dataField property to be the same as the axis data field that should be banked. For example, in a time series chart with time on the x-axis, the data field for this operator should be the same as the data field used for the y-axis. By default this class assumes that the data field is being laid out on the y-axis. If this is not the case (e.g., you have a vertically oriented line chart), be sure to set the bankYAxis property to false.



Public Properties
 PropertyDefined by
  banker : Function
The banking function to use.
AspectRatioBanker
  bankYAxis : Boolean = true
Indicates if the data field is on the y-axis (default true).
AspectRatioBanker
  dataField : String
The data field of the values to bank.
AspectRatioBanker
 Inheritedenabled : Boolean
Indicates if the operator is enabled or disabled.
Operator
  maxHeight : Number = 500
The maximum height for the visualization bounds.
AspectRatioBanker
  maxWidth : Number = 500
The maximum width for the visualization bounds.
AspectRatioBanker
 Inheritedparameters : Object
Sets parameter values for this operator.
Operator
 Inheritedvisualization : Visualization
The visualization processed by this operator.
Operator
Public Methods
 MethodDefined by
  
AspectRatioBanker(dataField:String = null, bankYAxis:Boolean = true, maxWidth:Number = 500, maxHeight:Number = 500)
Creates a new AspectRatioBanker.
AspectRatioBanker
 Inherited
applyParameters(op:IOperator, params:Object):void
[static] Static method that applies parameter settings to an operator.
Operator
  
averageAbsoluteAngle(a:Array):Number
[static] Bank the average absolute orientation to 45 degrees.
AspectRatioBanker
  
medianAbsoluteSlope(a:Array):Number
[static] Bank the median absolute slope to 45 degrees.
AspectRatioBanker
  
operate(t:Transitioner = null):void
Performs an operation over the contents of a visualization.
AspectRatioBanker
 Inherited
setup():void
Setup method invoked whenever this operator's visualization property is set.
Operator
Property detail
bankerproperty
public var banker:Function

The banking function to use. This is a function that takes an array of Numbers as input and returns an aspect ratio. It is expected that this function will be one of the static functions of this class. The default is averageAbsoluteAngle.

bankYAxisproperty 
public var bankYAxis:Boolean = true

Indicates if the data field is on the y-axis (default true).

dataFieldproperty 
dataField:String  [read-write]

The data field of the values to bank.

Implementation
    public function get dataField():String
    public function set dataField(value:String):void
maxHeightproperty 
public var maxHeight:Number = 500

The maximum height for the visualization bounds.

maxWidthproperty 
public var maxWidth:Number = 500

The maximum width for the visualization bounds.

Constructor detail
AspectRatioBanker()constructor
public function AspectRatioBanker(dataField:String = null, bankYAxis:Boolean = true, maxWidth:Number = 500, maxHeight:Number = 500)

Creates a new AspectRatioBanker.

Parameters
dataField:String (default = null) — the data field from which pull numeric values from NodeSprites. These values are then used to determine the optimal aspect ratio.
 
bankYAxis:Boolean (default = true)
 
maxWidth:Number (default = 500)
 
maxHeight:Number (default = 500)
Method detail
averageAbsoluteAngle()method
public static function averageAbsoluteAngle(a:Array):Number

Bank the average absolute orientation to 45 degrees. "Slopeless" lines are culled before the banking is computed. Solved using Newton-Raphson iteration.

      a     = aspect ratio (as height / width)
      ci    = normalized slope = N abs(y_i+1 - y_i) / range(y)
      x     = a ci
      f(a)  = sum(atan(x)) / N - pi/4
      f'(a) = sum(ci/(1 + x^2)) / N
      

Parameters
a:Array — an array of data values to be banked. It is assumed that values on the opposite axis are evenly spaced.

Returns
Number — the optimized aspect ratio
medianAbsoluteSlope()method 
public static function medianAbsoluteSlope(a:Array):Number

Bank the median absolute slope to 45 degrees. "Slopeless" lines are culled before the banking is computed.

Parameters
a:Array — an array of data values to be banked. It is assumed that values on the opposite axis are evenly spaced.

Returns
Number — the optimized aspect ratio
operate()method 
public override function operate(t:Transitioner = null):void

Performs an operation over the contents of a visualization.

Parameters
t:Transitioner (default = null) — a Transitioner instance for collecting value updates.