Skip to content

AmStockChart

Type class

AmStockChart is a main class Stock chart.

Sources

This information about AmStockChart is provided for reference only and is not available through exported packages and thus should not be imported or used on its own.

Inheritance

AmStockChart does not extend any other symbol.

AmStockChart is not extended by any other symbol.

Properties

addClassNames

Type booleanDefault false

Specifies, if class names should be added to chart elements.

amExport

Type AmExport

AmExport object.

autoResize

Type booleanDefault true

Set this to false if you don't want chart to resize itself whenever its parent container size changes.

balloon

Type AmBalloonDefault AmBalloon

Balloon object.

categoryAxesSettings

Type CategoryAxesSettingsDefault CategoryAxesSettings

Settings for category axes.

chartCursorSettings

Type ChartCursorSettingsDefault ChartCursorSettings

Chart cursor settings.

chartScrollbarSettings

Type ChartScrollbarSettingsDefault ChartScrollbarSettings

Chart scrollbar settings.

classNamePrefix

Type stringDefault amcharts

This prefix is added to all class names which are added to all visual elements of a chart in case addClassNames is set to true.

colors

Type color[]Default [ "#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.

dataDateFormat

Type string

Data provider of data set can have dates as Date Objects or as Strings. In case you use strings, you need to set data date format and the chart will parse dates to date objects. Check this page for date formatting strings.


Please note that two-digit years (YY) is NOT supported in this setting.

dataSets

Type DataSet[]

Array of DataSets.

dataSetSelector

Type DataSetSelector

DataSetSelector object. You can add it if you have more than one data set and want users to be able to select/compare them.

export

Type object

Export config. Specifies how export to image/data export/print/annotate menu will look and behave. You can find a lot of examples in amcharts/plugins/export folder. More details can be found here.

extendToFullPeriod

Type booleanDefault true

Specifies if the chart should always display full first and last data item when data is grouped to a longer period if the chart is zoomed from the beginning or end of the data.

firstDayOfWeek

Type numberDefault 1

Defines on which day week starts. 0 - Sunday, 1 - Monday...

glueToTheEnd

Type booleanDefault false

If set to true the scope of the data view will be set to the end after data update.

language

Type string

Allows changing language easily.

Note: you should include language js file from amcharts/lang or ammap/lang folder and then use variable name used in this file, like chart.language = "de".

legendSettings

Type LegendSettingsDefault LegendSettings

Legend settings.

listeners

Type object[]

You can add listeners of events using this property. Example: listeners = [{"event":"dataUpdated", "method":handleEvent}];

mouseWheelScrollEnabled

Type booleanDefault false

Specifies if scrolling of a chart with mouse wheel is enabled.

panels

Type StockPanel[]

Array of StockPanels (charts).

panelsSettings

Type PanelsSettingsDefault PanelsSettings

Settings for stock panels.

path

Type stringDefault amcharts/

Specifies absolute or relative path to amCharts files, i.e. "amcharts/". (where all .js files are located) If relative URLs are used, they will be relative to the current web page, displaying the chart.

You can also set path globally, using global JavaScript variable AmCharts_path. If this variable is set, and "path" is not set in chart config, the chart will assume the path from the global variable. This allows setting amCharts path globally. I.e.:

var AmCharts_path = "/libs/amcharts/";```

 "path" parameter will be used by the charts to locate it's files, like images, plugins or patterns.
pathToImages

Type string

Specifies path to the folder where images like resize grips, lens and similar are.

IMPORTANT: Since V3.4.12, you should use "path" to point to amCharts directory instead. The "pathToImages" will be automatically set and does not need to be in the chart config, unless you keep your images separately from other amCharts files.

periodSelector

Type PeriodSelector

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.

processTimeout

Type numberDefault 0

If you set it to 1 millisecond or some bigger value, chart will be built in chunks instead of all at once. This is useful if you work with a lot of data and the initial build of the chart takes a lot of time, which freezes the whole web application by not allowing other processes to do their job while the chart is busy.

stockEventsSettings

Type StockEventsSettingsDefault StockEventsSettings

Settings for stock events.

type

Type string

Read-only. Type of the chart.

valueAxesSettings

Type ValueAxesSettingsDefault ValueAxesSettings

Settings for value axes.

zoomOutOnDataSetChange

Type booleanDefault false

Specifies whether the chart should zoom-out when main data set is changed.

Methods

addListener()

Returns Adds event listener to the object.

type - string like 'dataUpdated' (should be listed in 'events' section of this class). handler - function which is called when event happens

addPanel()

Returns Adds panel to the stock chart. Requires stockChart.validateNow() method to be called after this action.

panel - StockPanel

addPanelAt()

Returns Adds panel to the stock chart at a specified index. Requires stockChart.validateNow() method to be called after this action.

panel - StockPanel, index - Number

clear()

Returns void

Destroys chart, all timeouts and listeners.

hideStockEvents()

Returns Hides event bullets.

removeListener()

Returns Removes event listener from the object.

removePanel()

Returns Removes panel from the stock chart. Requires stockChart.validateNow() method to be called after this action.

panel - StockPanel

showStockEvents()

Returns Shows event bullets.

validateData()

Returns Method which should be called after data was changed.

validateNow()

Returns Method which forces the stock chart to rebuild. Should be called after properties are changed.

This method should be called after you changed one or more properties of any class. The chart will redraw after this method is called.Both attributes, validateData and skipEvents are optional (false by default).

write()

Returns Chart instance

Adds chart to the specified DIV.

container - id of a DIV or DIV object which will hold the chart

zoom()

Returns Zooms chart to specified dates.

startDate, endDate - Date objects.

zoomOut()

Returns Zooms out the chart.

Events

buildStarted

Param { type: "buildStarted", target: AmStockChart } & {type:"buildStarted", chart:AmStockChart}

Fired just before the chart starts to build itself for the first time. Note: you might need to set processTimeout to > 0 value in order to register this event properly.

clickStockEvent

Param { type: "clickStockEvent", target: AmStockChart } & {type:"clickStockEvent", eventObject:eventObject, graph:graph, date:date, chart:AmStockChart}

Dispatched when the user clicks on the Stock event (bullet).

dataUpdated

Param { type: "dataUpdated", target: AmStockChart } & {type:"dataUpdated", chart:AmStockChart}

Dispatched when the chart was updated with new data.

init

Param { type: "init", target: AmStockChart } & {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

Param { type: "panelRemoved", target: AmStockChart } & {type:"panelRemoved", panel:panel, chart:AmStockChart}

Dispatched when the StockPanel is removed.

rendered

Param { type: "rendered", target: AmStockChart } & {type:"init", chart:AmStockChart}

Dispatched each when chart is rendered.

rollOutStockEvent

Param { type: "rollOutStockEvent", target: AmStockChart } & {type:"rollOutStockEvent", eventObject:eventObject, graph:graph, date:date, chart:AmStockChart}

Dispatched when the user rolls-out of the Stock event (bullet).

rollOverStockEvent

Param { type: "rollOverStockEvent", target: AmStockChart } & {type:"rollOverStockEvent", eventObject:eventObject, graph:graph, date:date, chart:AmStockChart}

Dispatched when the user rolls-over the Stock event (bullet).

zoomed

Param { type: "zoomed", target: AmStockChart } & {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).