Package | com.iwobanas.charts |
Class | public class ChartScroller |
Inheritance | ChartScroller ![]() |
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.
Property | Defined 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 |
Property | Defined 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 |
Method | Defined by | ||
---|---|---|---|
Constructor.
| ChartScroller |
Method | Defined 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 | ||
initializeForChartAxes():void
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 | ||
processChange():void
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 |
Event | Summary | Defined by | ||
---|---|---|---|---|
Dispatched when the user scrolls or zooms the chart. | ChartScroller | |||
Dispatched specified time after user finished zooming or scrolling the chart. | ChartScroller |
chart | property |
chart:CartesianChart
[read-write]Chart which content should be scrolled/zoomed.
Implementation public function get chart():CartesianChart
public function set chart(value:CartesianChart):void
chartMouseEnabled | property |
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.
commitTimer | property |
protected var commitTimer:Timer
Timer responsible for deleying valueCommit event.
dragStartDataPoint | property |
protected var dragStartDataPoint:Point
Point in data coordinates at which scrolling (drag) is started.
hAxis | property |
protected var hAxis:IAxis
Currently zoomed/scrolled horizontal axis.
horizontalScrollEnabled | property |
public var horizontalScrollEnabled:Boolean = true
Specifies whether chart should be scrolled horizontally.
This property can be used as the source for data binding.
horizontalZoomEnabled | property |
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.
isDragging | property |
protected var isDragging:Boolean = false
Indicate if user is dragging the chart.
isInitialized | property |
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
series | property |
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.
valueCommitDeley | property |
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
vAxis | property |
protected var vAxis:IAxis
Currently zoomed/scrolled vertical axis.
verticalScrollEnabled | property |
public var verticalScrollEnabled:Boolean = false
Specifies whether chart should be scrolled vertically.
This property can be used as the source for data binding.
verticalZoomEnabled | property |
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.
zoomSpeed | property |
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.
ChartScroller | () | constructor |
public function ChartScroller()
Constructor.
chartMouseDownHandler | () | method |
protected function chartMouseDownHandler(event:MouseEvent):void
Mouse down on the chart event hadler. Initialize scrolling using mouse.
Parametersevent: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
Parametersevent:MouseEvent |
commitTimerCompleteHandler | () | method |
protected function commitTimerCompleteHandler(event:TimerEvent):void
Commit timer complete event handler.
Dispatch valueCommit
event.
event:TimerEvent |
deactivateHandler | () | method |
protected function deactivateHandler(event:Event):void
Deactivate event handler. Stop scrolling the chart.
Parametersevent: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.
hAxis:IAxis — horizontal axis
|
|
vAxis:IAxis — vertical axis
|
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.
Parameterspoint:Point — point in global (stage) coordinates
|
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.
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.
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.
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.
Parametersevent:MouseEvent |
mouseUpHandler | () | method |
protected function mouseUpHandler(event:MouseEvent):void
Mouse up event handler. Stop scrolling the chart.
Parametersevent: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).
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).
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.
|
change | event |
valueCommit | event |
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.