Packagecom.amcharts.chartClasses
Classpublic class ChartCursor
InheritanceChartCursor Inheritance mx.core.UIComponent

ChartCursor is a class which displays a cursor which follows the mouse. For Serial chart it also shows value and category balloons. To add a cursor, add the following mxml to your chart:
    <amcharts:chartCursor>
      <amcharts:ChartCursor/>      
    </amcharts:chartCursor>
   

View the examples.



Public Properties
 PropertyDefined by
  bulletsEnabled : Boolean
Specifies if bullet for each graph will follow the cursor.
ChartCursor
  bulletSize : Number
Size of bullets, following the cursor.
ChartCursor
  categoryBalloon : AmBalloon
[read-only] Returns category balloon object.
ChartCursor
  categoryBalloonDateFormat : String
Category balloon date format (used only if category axis parses dates).
ChartCursor
  categoryBalloonEnabled : Boolean
Specifies whether category balloon is enabled.
ChartCursor
  crosshair : Boolean
If crosshair is set to true, a value line will also be displayed and will follow the mouse This affects serial chart only, as XY chart shows crosshair by default.
ChartCursor
  cursorPosition : String
Specifies where the cursor line should be placed - on the beginning of the period.
ChartCursor
  draw : Boolean
Specifies if drawing mode is enabled.
ChartCursor
  oneBalloonOnly : Boolean
If true, one balloon at a time will be displayed.
ChartCursor
  pan : Boolean
If this is set to true, the user will be able to pan the chart (Serial only) instead of zooming.
ChartCursor
  selectWithoutZooming : Boolean
Specifies if the user can select (mark) chart without zooming it.
ChartCursor
  showValueAxisValue : Boolean
Chart Cursor can also display value of Value axis (do not mix with value balloons - they display value of a graph).
ChartCursor
  showValueOfAxis : ValueAxis
Chart Cursor can also display value of Value axis (do not mix with value balloons - they display value of a graph).
ChartCursor
  valueBalloonsEnabled : Boolean
Specifies whether value balloons are enabled.
ChartCursor
  zoomable : Boolean
Specifies if the user can zoom-in the chart.
ChartCursor
  zooming : Boolean
Indicates if currently user is selecting some chart area to zoom-in.
ChartCursor
Public Methods
 MethodDefined by
  
Constructor.
ChartCursor
  
hideCursor(dispatch:Boolean = true):void
Hides cursor
ChartCursor
  
setPosition(position:Number, dispatch:Boolean = true):void
You can set position of the cursor.
ChartCursor
  
updateCursor(index:Number, dispatch:Boolean = true):void
Using this method you can update the cursor position programatically.
ChartCursor
Protected Methods
 MethodDefined by
  
ChartCursor
  
ChartCursor
  
ChartCursor
Events
 EventSummaryDefined by
   Dispatched when cursor position is changed.ChartCursor
   Dispatched when cursor is hidden.ChartCursor
   Dispatched when user selects some range with a cursor.ChartCursor
   Dispatched when user performs zoom with chart cursor.ChartCursor
Styles
 StyleDescriptionDefined by
  
categoryBalloonAlpha
Type: Number   CSS Inheritance: no
Opacity of the category balloon. The default value is 1.
ChartCursor
  
categoryBalloonColor
Type: uint   Format: Color   CSS Inheritance: no
Color of the category balloon. cursorColor is used if not set any. Category balloon is available with serial chart only. The default value is undefined.
ChartCursor
  
color
Type: uint   Format: Color   CSS Inheritance: yes
Color of text in the component, including the component label. The default value is 0x0B333C.
ChartCursor
  
cursorAlpha
Type: Number   CSS Inheritance: no
Opacity of the cursor line. The default value is 1.
ChartCursor
  
cursorColor
Type: uint   Format: Color   CSS Inheritance: no
Color of the cursor line. The default value is 0xcc0000.
ChartCursor
  
disabledColor
Type: uint   Format: Color   CSS Inheritance: yes
Color of text in the component if it is disabled. The default value is 0xAAB3B3.
ChartCursor
  
fontAntiAliasType
Type: String   CSS Inheritance: yes
Sets the antiAliasType property of internal TextFields. The possible values are "normal" (flash.text.AntiAliasType.NORMAL) and "advanced" (flash.text.AntiAliasType.ADVANCED).

The default value is "advanced", which enables advanced anti-aliasing for the font. Set to "normal" to disable the advanced anti-aliasing.

This style has no effect for system fonts.

This style applies to all the text in a TextField subcontrol; you cannot apply it to some characters and not others.

The default value is "advanced".
ChartCursor
  
fontFamily
Type: String   CSS Inheritance: yes
Name of the font to use. Unlike in a full CSS implementation, comma-separated lists are not supported. You can use any font family name. If you specify a generic font name, it is converted to an appropriate device font. The default value is "Verdana".
ChartCursor
  
fontGridFitType
Type: String   CSS Inheritance: yes
Sets the gridFitType property of internal TextFields that represent text in Flex controls. The possible values are "none" (flash.text.GridFitType.NONE), "pixel" (flash.text.GridFitType.PIXEL), and "subpixel" (flash.text.GridFitType.SUBPIXEL).

This property only applies when you are using an embedded font and the fontAntiAliasType property is set to "advanced".

This style has no effect for system fonts.

This style applies to all the text in a TextField subcontrol; you can't apply it to some characters and not others.

The default value is "pixel".
ChartCursor
  
fontSharpness
Type: Number   CSS Inheritance: yes
Sets the sharpness property of internal TextFields that represent text in Flex controls. This property specifies the sharpness of the glyph edges. The possible values are Numbers from -400 through 400.

This property only applies when you are using an embedded font and the fontAntiAliasType property is set to "advanced".

This style has no effect for system fonts.

This style applies to all the text in a TextField subcontrol; you can't apply it to some characters and not others.

The default value is 0.
ChartCursor
  
fontSize
Type: Number   Format: Length   CSS Inheritance: yes
Height of the text, in pixels. The default value is 10 for all controls except the ColorPicker control. For the ColorPicker control, the default value is 11.
ChartCursor
  
fontStyle
Type: String   CSS Inheritance: yes
Determines whether the text is italic font. Recognized values are "normal" and "italic". The default value is "normal".
ChartCursor
  
fontThickness
Type: Number   CSS Inheritance: yes
Sets the thickness property of internal TextFields that represent text in Flex controls. This property specifies the thickness of the glyph edges. The possible values are Numbers from -200 to 200.

This property only applies when you are using an embedded font and the fontAntiAliasType property is set to "advanced".

This style has no effect on system fonts.

This style applies to all the text in a TextField subcontrol; you can't apply it to some characters and not others.

The default value is 0.
ChartCursor
  
fontWeight
Type: String   CSS Inheritance: yes
Determines whether the text is boldface. Recognized values are normal and bold. The default value for Button controls is bold. The default value for all other controls is normal.
ChartCursor
  
kerning
Type: Boolean   CSS Inheritance: yes
A Boolean value that indicates whether kerning is enabled (true) or disabled (false). Kerning adjusts the gap between certain character pairs to improve readability, and should be used only when necessary, such as with headings in large fonts. Kerning is supported for embedded fonts only. Certain fonts, such as Verdana, and monospaced fonts, such as Courier New, do not support kerning. The default value is false.
ChartCursor
  
letterSpacing
Type: Number   CSS Inheritance: yes
The number of additional pixels to appear between each character. A positive value increases the character spacing beyond the normal spacing, while a negative value decreases it. The default value is 0.
ChartCursor
  
selectionAlpha
Type: Number   CSS Inheritance: yes
Opacity of the selection. The default value is 0.2.
ChartCursor
  
textAlign
Type: String   CSS Inheritance: yes
Alignment of text within a container. Possible values are "left", "right", or "center".

The default value for most components is "left". For the FormItem component, the default value is "right". For the Button, LinkButton, and AccordionHeader components, the default value is "center", and this property is only recognized when the labelPlacement property is set to "left" or "right". If labelPlacement is set to "top" or "bottom", the text and any icon are centered.

ChartCursor
  
textDecoration
Type: String   CSS Inheritance: yes
Determines whether the text is underlined. Possible values are "none" and "underline". The default value is "none".
ChartCursor
  
textIndent
Type: Number   Format: Length   CSS Inheritance: yes
Offset of first line of text from the left side of the container, in pixels. The default value is 0.
ChartCursor
  
valueAxisBalloonAlpha
Type: Number   CSS Inheritance: no
Opacity of the value axis balloon. The default value is 1.
ChartCursor
  
valueAxisBalloonColor
Type: uint   Format: Color   CSS Inheritance: no
Color of the value axis balloon. cursorColor is used if not set any. Value axis blloon is available with serial chart only. The default value is undefined.
ChartCursor
  
valueAxisBalloonTextColor
Type: uint   Format: Color   CSS Inheritance: no
Color of the value axis balloon text. The default value is 0xFFFFFF.
ChartCursor
Property detail
bulletsEnabledproperty
bulletsEnabled:Boolean  [read-write]

Specifies if bullet for each graph will follow the cursor.

The default value is false.

Implementation
    public function get bulletsEnabled():Boolean
    public function set bulletsEnabled(value:Boolean):void
bulletSizeproperty 
bulletSize:Number  [read-write]

Size of bullets, following the cursor.

The default value is 8.

Implementation
    public function get bulletSize():Number
    public function set bulletSize(value:Number):void
categoryBalloonproperty 
categoryBalloon:AmBalloon  [read-only]

Returns category balloon object.

Implementation
    public function get categoryBalloon():AmBalloon
categoryBalloonDateFormatproperty 
categoryBalloonDateFormat:String  [read-write]

Category balloon date format (used only if category axis parses dates).

The default value is MMM DD, YYYY.

Implementation
    public function get categoryBalloonDateFormat():String
    public function set categoryBalloonDateFormat(value:String):void
categoryBalloonEnabledproperty 
categoryBalloonEnabled:Boolean  [read-write]

Specifies whether category balloon is enabled.

The default value is true.

Implementation
    public function get categoryBalloonEnabled():Boolean
    public function set categoryBalloonEnabled(value:Boolean):void
crosshairproperty 
crosshair:Boolean  [read-write]

If crosshair is set to true, a value line will also be displayed and will follow the mouse This affects serial chart only, as XY chart shows crosshair by default. Vertical (value) zooming is not possible in Serial chart event crosshair is displayed.

The default value is false.

Implementation
    public function get crosshair():Boolean
    public function set crosshair(value:Boolean):void
cursorPositionproperty 
cursorPosition:String  [read-write]

Specifies where the cursor line should be placed - on the beginning of the period. (day, hour, etc) or in the middle (only when parseDates property of categoryAxis is set to true). If you want the cursor to follow mouse and not to glue to the nearest data point, set "mouse" here. Possible values are: start, middle, mouse

The default value is middle.

Implementation
    public function get cursorPosition():String
    public function set cursorPosition(value:String):void
drawproperty 
draw:Boolean  [read-write]

Specifies if drawing mode is enabled.

Implementation
    public function get draw():Boolean
    public function set draw(value:Boolean):void
oneBalloonOnlyproperty 
oneBalloonOnly:Boolean  [read-write]

If true, one balloon at a time will be displayed.

The default value is false.

Implementation
    public function get oneBalloonOnly():Boolean
    public function set oneBalloonOnly(value:Boolean):void
panproperty 
pan:Boolean  [read-write]

If this is set to true, the user will be able to pan the chart (Serial only) instead of zooming.

The default value is false.

Implementation
    public function get pan():Boolean
    public function set pan(value:Boolean):void
selectWithoutZoomingproperty 
selectWithoutZooming:Boolean  [read-write]

Specifies if the user can select (mark) chart without zooming it. zoomable should be set to true in order this to work.

The default value is false.

Implementation
    public function get selectWithoutZooming():Boolean
    public function set selectWithoutZooming(value:Boolean):void
showValueAxisValueproperty 
showValueAxisValue:Boolean  [read-write]

Chart Cursor can also display value of Value axis (do not mix with value balloons - they display value of a graph). If this is set to true, value of first value axis will be displayed for each panel.

The default value is false.

Implementation
    public function get showValueAxisValue():Boolean
    public function set showValueAxisValue(value:Boolean):void
showValueOfAxisproperty 
showValueOfAxis:ValueAxis  [read-write]

Chart Cursor can also display value of Value axis (do not mix with value balloons - they display value of a graph). You should set which value axis should display value balloon (only one is possible).

The default value is undefined.

Implementation
    public function get showValueOfAxis():ValueAxis
    public function set showValueOfAxis(value:ValueAxis):void
valueBalloonsEnabledproperty 
valueBalloonsEnabled:Boolean  [read-write]

Specifies whether value balloons are enabled. In case they are not, the balloons might be displayed anyway, when the user rolls-over the column or bullet.

The default value is true.

Implementation
    public function get valueBalloonsEnabled():Boolean
    public function set valueBalloonsEnabled(value:Boolean):void
zoomableproperty 
zoomable:Boolean  [read-write]

Specifies if the user can zoom-in the chart. If pan is set to true, zoomable is switched to false automatically.

The default value is true.

Implementation
    public function get zoomable():Boolean
    public function set zoomable(value:Boolean):void
zoomingproperty 
zooming:Boolean  [read-write]

Indicates if currently user is selecting some chart area to zoom-in.

Implementation
    public function get zooming():Boolean
    public function set zooming(value:Boolean):void
Constructor detail
ChartCursor()constructor
public function ChartCursor()

Constructor.

Method detail
balloonValueAxis()method
protected function balloonValueAxis():ValueAxis

Returns
ValueAxis
hideCursor()method 
public function hideCursor(dispatch:Boolean = true):void

Hides cursor

Parameters
dispatch:Boolean (default = true) — specifies whether CursorEvent.ON_HIDE_CURSOR should be dispatched
setPosition()method 
public function setPosition(position:Number, dispatch:Boolean = true):void

You can set position of the cursor.

Parameters
position:Number — is horizontal (or vertical) coordinate, in pixels. If position is not defined, mouse position is used.
 
dispatch:Boolean (default = true) — specifies whether an CursorEvent must be fired after the position is set
updateCursor()method 
public function updateCursor(index:Number, dispatch:Boolean = true):void

Using this method you can update the cursor position programatically. Note, setting cursorPosition="mouse" is not recommended if you use this method.

Parameters
index:Number — is the index of your category value.
 
dispatch:Boolean (default = true) — specifies whether CursorEvent must be dispatched after this update.
updateValueAxisBalloon()method 
protected function updateValueAxisBalloon():void
updateValueLine()method 
protected function updateValueLine():void
Event detail
changedevent 
Event object type: com.amcharts.events.CursorEvent

Dispatched when cursor position is changed.

onHideCursorevent  
Event object type: com.amcharts.events.CursorEvent

Dispatched when cursor is hidden.

selectedevent  
Event object type: com.amcharts.events.CursorEvent

Dispatched when user selects some range with a cursor. This is possible only when selectWithoutZooming is set to true and zoomable is also set to true. In this case zoom is not performed and zoomed event is not fired. I

zoomedevent  
Event object type: com.amcharts.events.CursorEvent

Dispatched when user performs zoom with chart cursor.

Examples
chartWithMultipleValueAxes
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                xmlns:amcharts="http://www.amcharts.com/com_internal"
                layout="absolute"
                backgroundColor="#FFFFFF"
                creationComplete="{generateChartData()}"
                width="100%"
                height="100%" viewSourceURL="srcview/index.html">
    
    <mx:Script>
        <![CDATA[
            import com.amcharts.chartClasses.AmGraph;
            import mx.collections.ArrayCollection;
            
            [Bindable]private var chartData:ArrayCollection = new ArrayCollection(); 
            // generate some random data, quite different range
            private function generateChartData():void{
                var firstDate:Date = new Date();
                firstDate.setDate(firstDate.getDate() - 100);
                
                for(var i:Number = 0; i < 100; i++){
                    var newDate:Date = new Date(firstDate);
                    newDate.setDate(newDate.getDate() + i);
                    
                    var visits:Number = Math.round(Math.random() * 40) + 100;
                    var hits:Number   = Math.round(Math.random() * 80) + 500;
                    var views:Number   = Math.round(Math.random() * 6000);
                    
                    chartData.addItem({date:newDate, visits:visits, hits:hits, views:views});
                }
            }
            
            private function zoom():void{
                chart.zoomToIndexes(0,20);
            }
            
            private var _newValueAxis:ValueAxis;
            
            private function addValueAxis():void{
                
                _newValueAxis = new ValueAxis();
                _newValueAxis.offset = 50;
                _newValueAxis.setStyle("gridAlpha", 0);
                _newValueAxis.setStyle("axisColor", 0xB0DE09);
                _newValueAxis.setStyle("axisThickness", 2);
                chart.addValueAxis(_newValueAxis);
                
                var graph:AmGraph = new AmGraph();
                graph.valueField = "views";
                graph.setStyle("bullet", "triangleUp");
                graph.setStyle("hideBulletsCount", 30);
                graph.type = "smoothedLine";
                graph.valueAxis = _newValueAxis;        
                chart.addGraph(graph);                
                
                addAxis.enabled = false;
                removeAxis.enabled = true;
            }
            
            private function removeValueAxis():void{
                chart.removeValueAxis(_newValueAxis);
                addAxis.enabled = true;
                removeAxis.enabled = false;            
            }
            
        ]]>
    </mx:Script>
    
    <mx:VBox width="100%" height="100%">
        <amcharts:AmSerialChart 
            dataUpdated="{zoom()}" 
            id="chart" 
            width="100%" 
            height="100%" 
            dataProvider="{chartData}" 
            categoryField="date">
            
            <amcharts:graphs>
                <!-- In case you have more then one value axis, you should set valueAxis for the graph -->
                <amcharts:AmGraph title="Visits" valueAxis="{v1}" valueField="visits" type="smoothedLine" bullet="round" hideBulletsCount="30"/>                        
                <amcharts:AmGraph title="Visits" valueAxis="{v2}" valueField="hits" type="smoothedLine"  bullet="square" hideBulletsCount="30"/>                        
            </amcharts:graphs>
            <!-- you can have any number of value axes. If you place value axes on the same side, you can move axis by setting "offset" property -->
            <amcharts:valueAxes>
                <amcharts:ValueAxis id="v1" axisColor="#FF6600" axisThickness="2"/>                    
                <amcharts:ValueAxis id="v2" position="right" axisColor="#FCD202" gridAlpha="0" axisThickness="2"/>                    
            </amcharts:valueAxes>
            
            <amcharts:categoryAxis>
                <amcharts:CategoryAxis parseDates="true" minPeriod="DD" gridCount="13"/>
            </amcharts:categoryAxis>
            
            <amcharts:chartCursor>
                <amcharts:ChartCursor cursorPosition="mouse"/>                        
            </amcharts:chartCursor>
            <amcharts:chartScrollbar>
                <amcharts:ChartScrollbar height="15"/>                        
            </amcharts:chartScrollbar>
        </amcharts:AmSerialChart>
        <mx:HBox>
            <mx:Spacer width="35"/>
            <mx:Button id="addAxis" label="add value axis" click="{addValueAxis()}"/>
            <mx:Button enabled="false" id="removeAxis" label="remove value axis" click="{removeValueAxis()}"/>
        </mx:HBox>
        <mx:Spacer height="15"/>
    </mx:VBox>    
</mx:Application>