Important version information!

You are browsing a class reference for deprecated Version 2 of the JavaScript Charts.

Documentation for other versions: amCharts 4 (current) or amCharts 3.

AmStockChart

AmStockChart is a main class Stock chart.

Properties

PropertyTypeDefaultDescription
animationPlayedBoolean Specifies if animation was already played. Animation is only played once, when chart is rendered for the first time. If you want the animation to be repeated, set this property to false.
balloonAmBallooninstance of AmBalloonBalloon object.
categoryAxesSettingsCategoryAxesSettings Settings for category axes.
chartCreatedBooleanIndicates if the chart is created.
chartCursorSettingsChartCursorSettings Chart cursor settings.
chartScrollbarSettingsChartScrollbarSettings Chart scrollbar settings.
colorsArray"#FF6600", "#FCD202", "#B0DE09", "#0D8ECF", "#2A0CD0", "#CD0D74", "#CC0000", "#00CC00", "#0000CC", "#DDDDDD", "#999999", "#333333", "#990000"Array of colors used by data sets if no color was set explicitly on data set itself.
comparedDataSetsArray Array of data sets selected for comparing.
dataSetsArray Array of DataSets.
dataSetSelectorDataSetSelector DataSetSelector object. You can add it if you have more than one data set and want users to be able to select/compare them.
endDateDate Current end date of the selected period, get only. To set start/end dates, use stockChart.zoom(startDate, endDate) method.
firstDayOfWeekNumber1Defines on which day week starts. 0 - Sunday, 1 - Monday...
glueToTheEndBooleanfalseIf set to true the scope of the data view will be set to the end after data update.
legendSettingsLegendSettings Legend settings.
mainDataSetDataSet Data set selected as main.
panelsArray Array of StockPanels (charts).
panelsSettingsPanelsSettings Settings for stock panels.
periodSelectorPeriodSelector Period selector object. You can add it if you want user's to be able to enter date ranges or zoom chart with predefined period buttons.
scrollbarChartAmSerialChartinstance of AmSerialChartScrollbar's chart object, get only.
startDateDate Current start date of the selected period, get only. To set start/end dates, use stockChart.zoom(startDate, endDate) method.
stockEventsSettingsStockEventsSettings Settings for stock events.
valueAxesSettingsValueAxesSettings Settings for value axes.
versionString read-only. Indicates current version of a script.
zoomOutOnDataSetChangeBooleanfalseSpecifies whether the chart should zoom-out when main data set is changed.

Methods

NameParametersReturnsDescription
addListener(type, handler)type - string like 'dataUpdated' (should be listed in 'events' section of this class). handler - function which is called when event happensAdds event listener to the object.
addPanel(panel)panel - [[StockPanel]]Adds panel to the stock chart. Requires stockChart.validateNow() method to be called after this action.
addPanelAt(panel, index)panel - [[StockPanel]], index - NumberAdds panel to the stock chart at a specified index. Requires stockChart.validateNow() method to be called after this action.
clear()Destroys chart, all timeouts and listeners.
hideStockEvents() Hides event bullets.
removeListener(obj, type, handler) Removes event listener from the object.
removePanel(panel)panel - [[StockPanel]]Removes panel from the stock chart. Requires stockChart.validateNow() method to be called after this action.
showStockEvents() Shows event bullets.
validateData() Method which should be called after data was changed.
validateNow() Method which forces the stock chart to rebuild. Should be called after properties are changed.
zoom(startDate, endDate)startDate, endDate - Date objects.Zooms chart to specified dates.
zoomOut() Zooms out the chart.

Events

NameEvent objectDescription
clickStockEvent{type:"clickStockEvent", eventObject:eventObject, graph:graph, date:date, chart:AmStockChart}Dispatched when the user clicks on the Stock event (bullet).
dataUpdated{type:"dataUpdated", chart:AmStockChart}Dispatched when the chart was updated with new data.
init{type:"init", chart:AmStockChart}Dispatched when the chart is initialized for the first time. In case you want it to fire again after validateNow() method is called, set chart.chartCreated = false.
panelRemoved{type:"panelRemoved", panel:panel, chart:AmStockChart}Dispatched when the StockPanel is removed.
rendered{type:"init", chart:AmStockChart}Dispatched each when chart is rendered.
rollOutStockEvent{type:"rollOutStockEvent", eventObject:eventObject, graph:graph, date:date, chart:AmStockChart}Dispatched when the user rolls-out of the Stock event (bullet).
rollOverStockEvent{type:"rollOverStockEvent", eventObject:eventObject, graph:graph, date:date, chart:AmStockChart}Dispatched when the user rolls-over the Stock event (bullet).
zoomed{type:"zoomed", startDate:startDate, endDate:endDate, period:period, chart:AmStockChart}Dispatched when the chart is zoomed (even for the first time, when chart is initialized).