| Package | com.amcharts.chartClasses |
| Class | public class ChartCursor |
| Inheritance | ChartCursor mx.core.UIComponent |
<amcharts:chartCursor>
<amcharts:ChartCursor/>
</amcharts:chartCursor>
| Property | Defined 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 | ||
| Method | Defined 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 | ||
| Method | Defined by | ||
|---|---|---|---|
| ChartCursor | |||
|
updateValueAxisBalloon():void
| ChartCursor | ||
|
updateValueLine():void
| ChartCursor | ||
| Event | Summary | Defined 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 | |||
| bulletsEnabled | property |
bulletsEnabled:Boolean [read-write]Specifies if bullet for each graph will follow the cursor.
The default value is false.
public function get bulletsEnabled():Boolean
public function set bulletsEnabled(value:Boolean):void
| bulletSize | property |
bulletSize:Number [read-write]Size of bullets, following the cursor.
The default value is 8.
public function get bulletSize():Number
public function set bulletSize(value:Number):void
| categoryBalloon | property |
categoryBalloon:AmBalloon [read-only]Returns category balloon object.
Implementation public function get categoryBalloon():AmBalloon
| categoryBalloonDateFormat | property |
categoryBalloonDateFormat:String [read-write]Category balloon date format (used only if category axis parses dates).
The default value is MMM DD, YYYY.
public function get categoryBalloonDateFormat():String
public function set categoryBalloonDateFormat(value:String):void
| categoryBalloonEnabled | property |
categoryBalloonEnabled:Boolean [read-write]Specifies whether category balloon is enabled.
The default value is true.
public function get categoryBalloonEnabled():Boolean
public function set categoryBalloonEnabled(value:Boolean):void
| crosshair | property |
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.
public function get crosshair():Boolean
public function set crosshair(value:Boolean):void
| cursorPosition | property |
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.
public function get cursorPosition():String
public function set cursorPosition(value:String):void
| draw | property |
draw:Boolean [read-write]Specifies if drawing mode is enabled.
Implementation public function get draw():Boolean
public function set draw(value:Boolean):void
| oneBalloonOnly | property |
oneBalloonOnly:Boolean [read-write]If true, one balloon at a time will be displayed.
The default value is false.
public function get oneBalloonOnly():Boolean
public function set oneBalloonOnly(value:Boolean):void
| pan | property |
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.
public function get pan():Boolean
public function set pan(value:Boolean):void
| selectWithoutZooming | property |
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.
public function get selectWithoutZooming():Boolean
public function set selectWithoutZooming(value:Boolean):void
| showValueAxisValue | property |
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.
public function get showValueAxisValue():Boolean
public function set showValueAxisValue(value:Boolean):void
| showValueOfAxis | property |
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.
public function get showValueOfAxis():ValueAxis
public function set showValueOfAxis(value:ValueAxis):void
| valueBalloonsEnabled | property |
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.
public function get valueBalloonsEnabled():Boolean
public function set valueBalloonsEnabled(value:Boolean):void
| zoomable | property |
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.
public function get zoomable():Boolean
public function set zoomable(value:Boolean):void
| zooming | property |
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
| ChartCursor | () | constructor |
public function ChartCursor()Constructor.
| balloonValueAxis | () | method |
| hideCursor | () | method |
public function hideCursor(dispatch:Boolean = true):voidHides cursor
Parametersdispatch:Boolean (default = true) — specifies whether CursorEvent.ON_HIDE_CURSOR should be dispatched
|
| setPosition | () | method |
public function setPosition(position:Number, dispatch:Boolean = true):voidYou can set position of the cursor.
Parametersposition: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):voidUsing this method you can update the cursor position programatically. Note, setting cursorPosition="mouse" is not recommended if you use this method.
Parametersindex: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
| changed | event |
| onHideCursor | event |
| selected | event |
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
| zoomed | event |
com.amcharts.events.CursorEvent
Dispatched when user performs zoom with chart cursor.
<?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>