Overview
StockChart is the main class for creating interactive financial charts in amCharts 5. It provides a complete solution for displaying stock data with multiple panels, technical indicators, comparison series, and drawing tools.Class Reference
Creating a StockChart
Settings
Main value series used for calculations, indicators, and annotations.Learn more about setting main series
Main volume series for the chart.Learn more about setting main series
When
true, the chart automatically switches to percent scale when comparison series are added, and exits when all comparisons are removed.Learn more about percent modeSettings applied to the main value series when the chart is in percent scale mode.Learn more about configuring percent mode
Settings applied to the ValueAxis of the main series when the chart is in percent scale mode.Learn more about configuring percent mode
Color for columns/candles on the main value series where the open value is lower than or equal to the close value.Learn more about positive/negative colors
Color for columns/candles on the main value series where the open value is higher than the close value.Learn more about positive/negative colors
Color for volume columns where the close value is higher than or equal to the open value.Learn more about positive/negative colors
Color for volume columns where the close value is lower than the open value.Learn more about positive/negative colors
When
true, all drawings are selectable and can be moved, rotated, or deleted.When
true, clicking on drawings deletes them.When
true, drawing grips are hidden when the StockChart is not in drawing mode.When
true, panel controls automatically hide when the mouse is not over the chart.Properties
A Container at the top of the chart, suitable for additional tools like Scrollbar.
A Container where all stock panels are placed.
An array of all StockControls created for this chart.@since 5.7.0
Instance of SpriteResizer used for various drawing tools.@since 5.7.0
Methods
setPercentScale()
Enables or disables percent scale mode.Whether to enable percent scale mode. If not set, automatically determined based on compared series.
percentScaleSeriesSettings and percentScaleValueAxisSettings are applied to the main series and its Y axis.
addComparingSeries()
Adds a comparison series to the chart.The series to add for comparison.
The same series that was added.
removeComparingSeries()
Removes a comparison series from the chart.The series to remove.
getVolumeColor()
Returns a color for volume based on current and previous close values.Target data item.
Color to use when close is lower than previous close (defaults to
volumeNegativeColor).Color to use when close is greater than or equal to previous close (defaults to
volumePositiveColor).The calculated volume color.
getControl()
Returns the first StockControl of a specific type.Control name (e.g., “IndicatorControl”, “DrawingControl”).
The control instance, or undefined if not found.
Drawing Management
selectDrawing()
Selects a drawing by its ID.Drawing ID.
Whether to keep existing selections.
unselectDrawing()
Unselects a drawing by its ID.Drawing ID.
unselectDrawings()
Unselects all currently selected drawings.Number of drawings that were unselected.
deleteDrawing()
Deletes a drawing by its ID.Drawing ID.
deleteSelectedDrawings()
Deletes all currently selected drawings.cancelDrawing()
Cancels the current drawing operation and deletes the drawing being drawn.toggleDrawing()
Toggles drawing mode on or off.Whether drawing mode should be enabled.
drawingsInteractive()
Enables or disables interactivity of drawings.Whether drawings should be interactive.
Optional drawing series to exclude from the change.
Utility Methods
markDirtyDrawings()
Forces redrawing of all annotations (drawings).markDirtyIndicators()
Forces redrawing of all indicators.Events
Triggered when drawings change.
Triggered when indicators change.
Triggered when a drawing is added.@since 5.9.0
Triggered when a drawing is removed.@since 5.9.0
Triggered when a drawing is selected.@since 5.9.0
Triggered when a drawing is unselected.@since 5.9.0
Helper Function
registerClass()
Registers a custom class for serialization and restoration.Class name.
Class reference.