ChartCursor | JavaScript Stock Charts v. 3 | amCharts

Creates a cursor for the chart which follows the mouse movements. In case of AmSerialChart charts it shows the balloons of hovered data points.

### Example

    var chart = AmCharts.makeChart("chartdiv",{
      ...
      "chartCursor": {
        "oneBalloonOnly": true
      }
    });

### Properties

Property | Type | Default | Description
--- | --- | --- | ---
adjustment | Number | 0 | If you set adjustment to -1, the balloon will be shown near previous, if you set it to 1 - near next data point.
animationDuration | Number | 0.3 | Duration of animation of a line, in seconds.
avoidBalloonOverlapping | Boolean | true | Specifies if cursor should arrange balloons so they won't overlap. If chart is rotated, it might be good idea to turn this off.
balloonPointerOrientation | String | horizontal | defines if the balloon should be shown above the datapoint or sideways
bulletsEnabled | Boolean | false | Specifies if bullet for each graph will follow the cursor.
bulletSize | Number | 8 | Size of bullets, following the cursor.
categoryBalloonAlpha | Number | 1 | Opacity of the category balloon.
categoryBalloonColor | Color |  | Color of the category balloon. cursorColor is used if not set.
categoryBalloonDateFormat | String | MMM DD, YYYY | Category balloon date format (used only if category axis parses dates). Check this page for instructions on how to format dates.
categoryBalloonEnabled | Boolean | true | Specifies whether category balloon is enabled.
categoryBalloonFunction |  |  | Allows formatting any category balloon text you want. categoryBalloonFunction should return a string which will be displayed in a balloon. When categoryBalloonFunction is called, category value (or date) is passed as an argument.
categoryBalloonText | String | [[category]] | You can have [[category]] - [[toCategory]] tags in there and show category ranges this way.
color | Color | #FFFFFF | Text color.
cursorAlpha | Number | 1 | Opacity of the cursor line.
cursorColor | Color | #CC0000 | Color of the cursor line.
cursorPosition | String | middle | 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.
enabled | Boolean | true | Specifies whether cursor is enabled.
fullWidth | Boolean | false | If set to true, instead of a cursor line user will see a fill which width will always be equal to the width of one data item. We'd recommend setting cursorAlpha to 0.1 or some other small number if using this feature.
graphBulletAlpha | Number |  | If you make graph's bullets invisible by setting their opacity to 0 and will set graphBulletAlpha to 1, the bullets will only appear at the cursor's position.
graphBulletSize | Number | 1.7 | Size of a graph's bullet (if available) at the cursor position. If you don't want the bullet to change it's size, set this property to 1.
leaveAfterTouch | Boolean | true | This makes cursor and balloons to remain after user touches the chart.
leaveCursor | Boolean | false | Specifies if cursor should be left at it's last position. Useful for touch devices - user might want to see the balloons after he moves finger away.
limitToGraph | AmGraph |  | If set to an id or a reference to AmGraph object, CategoryAxis cursor line will be limited to this graph instead of being drawn through full height of plot area. Note, this works with serial chart only. Also, cursorPosition of ChartCursor must be set to middle.
listeners | Array[Object] |  | You can add listeners of events using this property. Example: listeners = [{"event":"changed", "method":handleEvent}];
oneBalloonOnly | Boolean | false | If this is set to true, only one balloon at a time will be displayed. Note, this is quite CPU consuming.
pan | Boolean | false | If this is set to true, the user will be able to pan the chart instead of zooming.
selectionAlpha | Number | 0.2 | Opacity of the selection.
selectWithoutZooming | Boolean | false | Specifies if cursor should only mark selected area but not zoom-in after user releases mouse button.
showNextAvailable | Boolean | false | If true, the graph will display balloon on next available data point if currently hovered item doesn't have value for this graph.
tabIndex | Number |  | In case you set it to some number, the chart will set focus on chart cursor (works only with serial chart) when user clicks tab key. When a focus is set user can move cursor using cursor keys. Note, not all browsers and readers support this.
valueBalloonsEnabled | Boolean | true | 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.
valueLineAlpha | Number |  | Opacity of value line. Will use cursorAlpha value if not set.
valueLineBalloonEnabled | Boolean | false | Specifies if value balloon next to value axes labels should be displayed.
valueLineEnabled | Boolean | false | Specifies if cursor of Serial chart should display horizontal (or vertical if chart is rotated) line. This line might help users to compare distant values of a chart. You can also enable value balloons on this line by setting valueLineBalloonEnabled to true.
valueZoomable | Boolean | false | Specifies if the user can zoom-in value axess of a serial chart.
zoomable | Boolean | true | Specifies if the user can zoom-in the chart. If pan is set to true, zoomable is switched to false automatically.
zooming | Boolean |  | Read-only. Indicates if currently user is selecting some chart area to zoom-in.

### Methods

Name | Parameters | Returns | Description
--- | --- | --- | ---
addListener(type, handler) | type - string like 'changed' (should be listed in 'events' section of this class or classes which extend this class). handler - function which is called when event happens |  | Adds event listener to the object.
clearSelection() |  |  | This method can be used when selectWithoutZooming is set to true and you need to clear the selection made by user.
hideCursor() |  |  | Hides cursor.
removeListener(obj, type, handler) |  |  | Removes event listener from the object.
showCursorAt(category) |  |  | You can force cursor to appear at specified cateogry or date.
syncWithCursor(cursor) |  |  | Allows to sync one serial chart’s cursor with another chart’s cursor. Important! This method will work correctly only if plot area of both charts is identically equal in width.

### Events

Name | Event object | Description
--- | --- | ---
changed | {type:"changed", index:Number, zooming:Boolean, mostCloseGraph:AmGraph, chart:AmChart, target:ChartCursor} | Dispatched when cursor position is changed. "index" is a series index over which chart cursors currently is. "zooming" specifies if user is currently zooming (is selecting) the chart. mostCloseGraph property is set only when oneBalloonOnly is set to true.
draw | {type: "draw", target: ChartCursor, chart: AmChart, initialX: Number, initialY: Number, finalX: Number, finalY: Number, target:ChartCursor} | Dispatched when user draws a trend line with mouse.
moved | {type:"moved", x:Number, y:Number, zooming:Boolean, chart:AmChart, target:ChartCursor} | Dispatched when mouse is moved over the chart. X and Y are coordinates of the mouse, relative to the plot area of the chart.
onHideCursor | {type:"onHideCursor", chart:AmChart, target:ChartCursor} | Dispatched when cursor is hidden.
onShowCursor | {type:"onShowCursor", chart:AmChart, target:ChartCursor} | Dispatched when cursor is shown.
panning | {type:"zoomStarted", x:Number, y:Number, index:Number, chart:AmChart, target:ChartCursor, index:Number, deltaX:Number, deltaY:Number, delta2X:Number, delta2Y:Number} | Dispatched when user pans the chart (also when user pinch-zooms the chart). deltaX, deltaY, delta2X, delta2Y are relative values. delta2X and delta2Y has values when pinching with two fingers.
selected | {type:"changed", start:Number, end:Number, chart:AmChart, target:ChartCursor} | Dispatched if selectWithoutZooming is set to true and when user selects some period. start and end are indices or time stamp (when categoryAxis.parseDates is true) of selection start/end.
zoomed | {type:"changed", start:Number, end:Number, chart:AmChart, target:ChartCursor} | Dispatched when user zooms to some period. start and end are indices or time stamp (when categoryAxis.parseDates is true) of selection start/end.
zoomStarted | {type:"zoomStarted", x:Number, y:Number, index:Number, chart:AmChart, target:ChartCursor} | Dispatched when user starts selecting chart area to zoom-in. x and y are relative values (0-1). Index is current category index (of Serial chart)