Packagecom.iwobanas.charts
Classpublic class ChartScroller
InheritanceChartScroller Inheritance flash.events.EventDispatcher

The ChartScroller class adds scrolling and zooming functionality to CartesianChart.

To scroll the chart user have to drag data series or axis renderer and move mouse. To zoom data (change scale) user should use mouse wheel over series or axis renderer. If chartMouseEnabled is set user can drag or use mouse wheel over any part of the chart.

Both scrolling and zooming are done by modifying minimum and maximum properties of chart axes. Currently LinearAxis and DateTimeAxis are supported.



Public Properties
 PropertyDefined by
  chart : CartesianChart
Chart which content should be scrolled/zoomed.
ChartScroller
  chartMouseEnabled : Boolean = true
If true whole area of the char can be dragged to scroll the chart along default axes and spinning mouse wheel over any part of the char causes zooming along default axes.
ChartScroller
  horizontalScrollEnabled : Boolean = true
Specifies whether chart should be scrolled horizontally.
ChartScroller
  horizontalZoomEnabled : Boolean = true
Specifies whether chart should be zoomed along horizontal axis when mouse wheel is supn.
ChartScroller
  valueCommitDeley : Number
Time after which valueCommit event is dispatched when users stops scrolling/zooming the chart.
ChartScroller
  verticalScrollEnabled : Boolean = false
Specifies whether chart should be scrolled vertically.
ChartScroller
  verticalZoomEnabled : Boolean = false
Specifies whether chart should be zoomed along vertical axis when mouse wheel is supn.
ChartScroller
  zoomSpeed : Number = 1
Speed of zooming the chart.
ChartScroller
Protected Properties
 PropertyDefined by
  commitTimer : Timer
Timer responsible for deleying valueCommit event.
ChartScroller
  dragStartDataPoint : Point
Point in data coordinates at which scrolling (drag) is started.
ChartScroller
  hAxis : IAxis
Currently zoomed/scrolled horizontal axis.
ChartScroller
  isDragging : Boolean = false
Indicate if user is dragging the chart.
ChartScroller
  isInitialized : Boolean
[read-only] Indicate if ChartScroller is initialized i.e.
ChartScroller
  series : Series
Chart data series used to transform mouse position to data coordinates.
ChartScroller
  vAxis : IAxis
Currently zoomed/scrolled vertical axis.
ChartScroller
Public Methods
 MethodDefined by
  
Constructor.
ChartScroller
Protected Methods
 MethodDefined by
  
chartMouseDownHandler(event:MouseEvent):void
Mouse down on the chart event hadler.
ChartScroller
  
chartMouseWheelHandler(event:MouseEvent):void
Mouse wheel over chart event handler.
ChartScroller
  
commitTimerCompleteHandler(event:TimerEvent):void
Commit timer complete event handler.
ChartScroller
  
deactivateHandler(event:Event):void
Deactivate event handler.
ChartScroller
  
endDrag():void
End chart scrolling using mouse by romoving mouse event listeners.
ChartScroller
  
getSeriesForAxes(hAxis:IAxis, vAxis:IAxis):Series
Get chart data series which is using specified horizontal and vertical axis.
ChartScroller
  
globalToData(point:Point):Point
Convert point in global (stage) coordinates to data coordinates.
ChartScroller
  
initializeForAxisRenderer(renderer:IAxisRenderer):void
Initialize zooming/scrolling for a given axis renderer.
ChartScroller
  
Initialize zooming/scrolling for a default axes of the chart.
ChartScroller
  
initializeForMouseEvent(event:MouseEvent):void
Initialize zooming/scrolling based on mouse event.
ChartScroller
  
initializeForSeries(s:Series):void
Initialize zooming/scrolling for a given series.
ChartScroller
  
mouseMoveHandler(event:MouseEvent):void
Mouse move event handler.
ChartScroller
  
mouseUpHandler(event:MouseEvent):void
Mouse up event handler.
ChartScroller
  
Dispatch change event and restart commitTimer.
ChartScroller
  
scrollChart(dx:Number, dy:Number):void
Scroll chart content by specified horizontal and vertical distance.
ChartScroller
  
zoomChart(ralativeTo:Point, zoom:Number):void
Zoom chart content relative to a given point in data coordinates.
ChartScroller
Events
 EventSummaryDefined by
   Dispatched when the user scrolls or zooms the chart.ChartScroller
   Dispatched specified time after user finished zooming or scrolling the chart.ChartScroller
Property detail
chartproperty
chart:CartesianChart  [read-write]

Chart which content should be scrolled/zoomed.

Implementation
    public function get chart():CartesianChart
    public function set chart(value:CartesianChart):void
chartMouseEnabledproperty 
public var chartMouseEnabled:Boolean = true

If true whole area of the char can be dragged to scroll the chart along default axes and spinning mouse wheel over any part of the char causes zooming along default axes. If false only data series and axes support scrolling/zooming.

This property can be used as the source for data binding.

commitTimerproperty 
protected var commitTimer:Timer

Timer responsible for deleying valueCommit event.

dragStartDataPointproperty 
protected var dragStartDataPoint:Point

Point in data coordinates at which scrolling (drag) is started.

hAxisproperty 
protected var hAxis:IAxis

Currently zoomed/scrolled horizontal axis.

horizontalScrollEnabledproperty 
public var horizontalScrollEnabled:Boolean = true

Specifies whether chart should be scrolled horizontally.

This property can be used as the source for data binding.

horizontalZoomEnabledproperty 
public var horizontalZoomEnabled:Boolean = true

Specifies whether chart should be zoomed along horizontal axis when mouse wheel is supn.

This property can be used as the source for data binding.

isDraggingproperty 
protected var isDragging:Boolean = false

Indicate if user is dragging the chart.

isInitializedproperty 
isInitialized:Boolean  [read-only]

Indicate if ChartScroller is initialized i.e. has series and at least one axis set.

Implementation
    protected function get isInitialized():Boolean
seriesproperty 
protected var series:Series

Chart data series used to transform mouse position to data coordinates. This property is set by initialization methods when users start zooming/scrolling the chart. Although zooming/scrolling affects all series using modified axis one series is used for coordinates transformation.

valueCommitDeleyproperty 
valueCommitDeley:Number  [read-write]

Time after which valueCommit event is dispatched when users stops scrolling/zooming the chart. If no scrolling/zooming occurs within valueCommitDeley we assume that user finished his/her action and dispatch commitValue event.

This property can be used as the source for data binding.

Implementation
    public function get valueCommitDeley():Number
    public function set valueCommitDeley(value:Number):void
vAxisproperty 
protected var vAxis:IAxis

Currently zoomed/scrolled vertical axis.

verticalScrollEnabledproperty 
public var verticalScrollEnabled:Boolean = false

Specifies whether chart should be scrolled vertically.

This property can be used as the source for data binding.

verticalZoomEnabledproperty 
public var verticalZoomEnabled:Boolean = false

Specifies whether chart should be zoomed along vertical axis when mouse wheel is supn.

This property can be used as the source for data binding.

zoomSpeedproperty 
public var zoomSpeed:Number = 1

Speed of zooming the chart. If zoomSpeed is negative zooming in/out occurs when spinning mouse wheel in different direction.

This property can be used as the source for data binding.

Constructor detail
ChartScroller()constructor
public function ChartScroller()

Constructor.

Method detail
chartMouseDownHandler()method
protected function chartMouseDownHandler(event:MouseEvent):void

Mouse down on the chart event hadler. Initialize scrolling using mouse.

Parameters
event:MouseEvent
chartMouseWheelHandler()method 
protected function chartMouseWheelHandler(event:MouseEvent):void

Mouse wheel over chart event handler. Initialize ChartScroller if needed and zoom chart depending on event.delta

Parameters
event:MouseEvent
commitTimerCompleteHandler()method 
protected function commitTimerCompleteHandler(event:TimerEvent):void

Commit timer complete event handler. Dispatch valueCommit event.

Parameters
event:TimerEvent
deactivateHandler()method 
protected function deactivateHandler(event:Event):void

Deactivate event handler. Stop scrolling the chart.

Parameters
event:Event
endDrag()method 
protected function endDrag():void

End chart scrolling using mouse by romoving mouse event listeners.

getSeriesForAxes()method 
protected function getSeriesForAxes(hAxis:IAxis, vAxis:IAxis):Series

Get chart data series which is using specified horizontal and vertical axis. If passed axis is null it is ignored i.e. returned series can use any axis for this direction.

Parameters
hAxis:IAxis — horizontal axis
 
vAxis:IAxis — vertical axis

Returns
Series — chart series using passed horizontal and vertical axes
globalToData()method 
protected function globalToData(point:Point):Point

Convert point in global (stage) coordinates to data coordinates.

Parameters
point:Point — point in global (stage) coordinates

Returns
Point — point in data coordinates
initializeForAxisRenderer()method 
protected function initializeForAxisRenderer(renderer:IAxisRenderer):void

Initialize zooming/scrolling for a given axis renderer. This method assigns values to series, hAxis and vAxis based on passed axis renderer.

Parameters
renderer:IAxisRenderer
initializeForChartAxes()method 
protected function initializeForChartAxes():void

Initialize zooming/scrolling for a default axes of the chart. This method assigns values to series, hAxis and vAxis based on horizontalAxis and verticalAxis chart properties.

initializeForMouseEvent()method 
protected function initializeForMouseEvent(event:MouseEvent):void

Initialize zooming/scrolling based on mouse event. This method assigns values to series, hAxis and vAxis based on passed mouse event.

Parameters
event:MouseEvent
initializeForSeries()method 
protected function initializeForSeries(s:Series):void

Initialize zooming/scrolling for a given series. This method assigns values to series, hAxis and vAxis based on passed series.

Parameters
s:Series
mouseMoveHandler()method 
protected function mouseMoveHandler(event:MouseEvent):void

Mouse move event handler. Calculate distance in chart data coordinates between the current mouse position and drag start position and scroll (move) chart by this distance. This event listener is registered on mouse down and unregistered on mouse up or deactivate.

Parameters
event:MouseEvent
mouseUpHandler()method 
protected function mouseUpHandler(event:MouseEvent):void

Mouse up event handler. Stop scrolling the chart.

Parameters
event:MouseEvent
processChange()method 
protected function processChange():void

Dispatch change event and restart commitTimer. This function should be called after modifying axis minimum/maximum.

scrollChart()method 
protected function scrollChart(dx:Number, dy:Number):void

Scroll chart content by specified horizontal and vertical distance. Scrolling is done by modifying axis minimum and maximum values.

Note that call to this function takes effect only if ChartScroller is initialized (i.e. series and at least one of hAxis and vAxis are set) and scrolling is enabled (horizontalScrollEnabled/verticalScrollEnabled properties are set).

Parameters
dx:Number — distance to scroll horizontally in data coordinates
 
dy:Number — distance to scroll vertically in data coordinates
zoomChart()method 
protected function zoomChart(ralativeTo:Point, zoom:Number):void

Zoom chart content relative to a given point in data coordinates.

Note that call to this function takes effect only if ChartScroller is initialized (i.e. series and at least one of hAxis and vAxis are set) and zooming is enabled (horizontalZoomEnabled/verticalZoomEnabled properties are set).

Parameters
ralativeTo:Point — point in data coordinates
 
zoom:Number — indicate how much the content should be zoomed, if this value is greater than 1 content is zoomed in otherways content is zoomed out.
Event detail
changeevent 
Event object type: flash.events.Event

Dispatched when the user scrolls or zooms the chart.

valueCommitevent  
Event object type: mx.events.FlexEvent

Dispatched specified time after user finished zooming or scrolling the chart. This event can be used to initiate retrieve data from server because it is not dispatched as frequently as change event.