Top
You are looking at an outdated 7.9.1 version of this document. Switch to the 7.14.3 version to see the up to date information.

class anychart.core.stock.Plot Improve this Doc

Extends: anychart.core.VisualBaseWithBounds

Stock Plot class.

Methods Overview

Axes and Scales
grid()Grid settings.
minorGrid()Minor grid settings.
xAxis()X-axis settings.
yAxis()Y-axis settings.
yScale()Y-scale settings.
Coloring
background()Background settings.
dateTimeHighlighter()Highlighter settings.
Events
listen()Adds an event listener.
listenOnce()Adds a single time event listener.
removeAllListeners()Removes all listeners.
unlisten()Removes the listener.
unlistenByKey()Removes the listener by the key.
Export
print()Prints all elements.
Interactivity
enabled()Element state (enabled or disabled).
Series
column()Addition of the column series.
getSeries()Gets series by its id.
line()Addition of the line series.
ohlc()Addition of the OHLC series.
Size and Position
bottom()Bottom bound setting.
bounds()Bounds settings.
getPixelBounds()Returns pixel bounds.
height()Height setting.
left()Left bound setting.
maxHeight()Maximum height.
maxWidth()Maximum width.
minHeight()Minimum height.
minWidth()Minimum width.
right()Right bound setting.
top()Top bound setting.
width()Width setting.
zIndex()Z-index of the element.
Specific Series Settings
addSeries()Add series to chart.
defaultSeriesType()Default series type.
ema()Creates EMA indicator on the chart.
getSeriesAt()Gets series by its index.
getSeriesCount()Returns series count.
macd()Creates MACD indicator on the chart.
removeAllSeries()Removes all series from chart.
removeSeries()Removes one of series from chart by its id.
removeSeriesAt()Removes one of series from chart by its index.
roc()Creates RoC indicator on the chart.
rsi()Creates RSI indicator on the chart.
sma()Creates SMA indicator on the chart.

Methods Description

addSeries

Add series to chart.

Params:

Name Type Description
var_args anychart.data.TableMapping Chart series data.

Returns:

Array.<anychart.core.stock.series.Base> - Array of created series.

Try it:

background

Getter for the current plot background.

Returns:

anychart.core.ui.Background - The current chart background.

Try it:

Setter for the plot background.

Params:

Name Type Description
value string | Object | null | boolean Background settings.

Returns:

anychart.core.stock.Plot - Self instance for method chaining.

bottom

Getter for element bottom bound setting.

Returns:

number string undefined - Current element's bottom bound setting.
Sets element bottom bound setting.

Params:

Name Type Default Description
value number | string | null
null
Bottom bound setting for the element.

Returns:

anychart.core.VisualBaseWithBounds - Returns self for method chaining.

Try it:

bounds

Getter for the element bounds settings.

Returns:

anychart.core.utils.Bounds - Current bounds of the element.
Sets bounds of the element using one parameter.

Params:

Name Type Description
value anychart.utils.RectObj | anychart.math.Rect | anychart.core.utils.Bounds Bounds of element.

Returns:

anychart.core.VisualBase - Self instance for method chaining.

Try it:

Setter for the element bounds settings.

Params:

Name Type Default Description
x number | string
null
X-coordinate.
y number | string
null
Y-coordinate.
width number | string
null
Width.
height number | string
null
Height.

Returns:

anychart.core.VisualBase - Self instance for method chaining.

Try it:

column

Creates and returns a new column series.

Params:

Name Type Description
data anychart.data.TableMapping | anychart.data.Table | Array.<Array.<*>> | string Value to set.
mappingSettings Object.<({column: number, type: anychart.enums.AggregationType, weights: number}|number)> An object where keys are field names and values are objects with fields: - 'column': number - Column index, that the field should get values from; - 'type': anychart.enums.AggregationType - How to group values for the field. Defaults to 'close'. - 'weights': number - Column to get weights from for 'weightedAverage' grouping type. Note: If type set to 'weightedAverage', but opt_weightsColumn is not passed - uses 'average' grouping instead. or numbers - just the column index to get values from. In this case the grouping type will be set to 'close'.
csvSettings Object CSV parser settings if the string is passed.

Returns:

anychart.core.stock.series.Base - An instance of class for method chaining.

dateTimeHighlighter

Getter for the current highlighter.

Returns:

anychart.graphics.vector.Stroke - The current highlighter.

Try it:

Setter for the highlighter.

Params:

Name Type Description
value anychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | null Stroke settings
thickness number Line thickness. If empty - set to 1.
dashpattern string Controls the pattern of dashes and gaps used to stroke paths.
lineJoin anychart.graphics.vector.StrokeLineJoin Line join style.
lineCap anychart.graphics.vector.StrokeLineCap Style of line cap.

Returns:

anychart.core.stock.Plot - Self instance for method chaining.

Try it:

defaultSeriesType

Getter for the default stock plot series type.

Returns:

string - Default series type.

Try it:

Setter for the stock plot defaultSeriesType.

Params:

Name Type Description
value string Default series type.

Returns:

anychart.core.stock.Plot - Self instance for method chaining

Try it:

ema

Creates EMA indicator on the chart.

Params:

Name Type Default Description
mapping anychart.data.TableMapping
Data mapping.
period number
20
Period.
seriesType string
"line"
Series type for EMA indicator (type as "line", "column", "ohlc").

Returns:

anychart.core.stock.indicators.EMA - An instance of class for method chaining.

Try it:

enabled

Getter for the current element state (enabled or disabled).

Returns:

boolean - The current element state.

Try it:

Setter for the element enabled state.

Params:

Name Type Default Description
value boolean
true
Value to set.

Returns:

anychart.core.VisualBase - Self instance for method chaining.
Example.
if (!element.enabled())
   element.enabled(true);

Try it:

getPixelBounds

Returns pixel bounds of the element due to parent bounds and self bounds settings.

Returns:

anychart.math.Rect - Pixel bounds of the element.

getSeries

Gets series by its id.

Params:

Name Type Default Description
id number | string
index
Id of the series.

Returns:

anychart.core.stock.series.Base - An instance of class for method chaining.

Try it:

getSeriesAt

Gets series by its index.

Params:

Name Type Description
index number Index of the series.

Returns:

anychart.core.stock.series.Base - An instance of class for method chaining.

Try it:

getSeriesCount

Returns series count.

Returns:

number - Number of series.

Try it:

grid

Getter for the current plot grid.

Params:

Name Type Description
index number Grid index.

Returns:

anychart.core.grids.Stock - Grid instance by index.

Try it:

Setter for the plot grid.

Params:

Name Type Description
value Object | boolean | null Grid settings to set.

Returns:

anychart.core.stock.Plot - Self instance for method chaining.
Setter for the plot grid by index.

Params:

Name Type Description
index number Grid index.
value Object | boolean | null Grid settings to set.

Returns:

anychart.core.stock.Plot - Self instance for method chaining.

height

Getter for element height setting.

Returns:

number string undefined - Current element's height setting.
Sets element height setting.

Params:

Name Type Default Description
value number | string | null
null
Height setting for the element.

Returns:

anychart.core.VisualBaseWithBounds - Returns self for method chaining.

Try it:

left

Getter for element left bound setting.

Returns:

number string undefined - Current element's left bound setting.
Sets element left bound setting.

Params:

Name Type Default Description
value number | string | null
null
Left bound setting for the element.

Returns:

anychart.core.VisualBaseWithBounds - Returns self for method chaining.

Try it:

line

Creates and returns a new line series.

Params:

Name Type Description
data anychart.data.TableMapping | anychart.data.Table | Array.<Array.<*>> | string Value to set.
mappingSettings Object.<({column: number, type: anychart.enums.AggregationType, weights: number}|number)> An object where keys are field names and values are objects with fields: - 'column': number - Column index, that the field should get values from; - 'type': anychart.enums.AggregationType - How to group values for the field. Defaults to 'close'. - 'weights': number - Column to get weights from for 'weightedAverage' grouping type. Note: If type set to 'weightedAverage', but opt_weightsColumn is not passed - uses 'average' grouping instead. or numbers - just the column index to get values from. In this case the grouping type will be set to 'close'.
csvSettings Object CSV parser settings if the string is passed.

Returns:

anychart.core.stock.series.Base - An instance of class for method chaining.

listen

Adds an event listener to an implementing object.

Params:

Name Type Description
type string The event type id.
listener function Callback method.
useCapture boolean Whether to fire in capture phase (defaults to false).
listenerScope scope Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

Try it:

listenOnce

Adds an event listener to an implementing object.

Params:

Name Type Description
type string The event type id.
listener function Callback method.
useCapture boolean Whether to fire in capture phase (defaults to false).
listenerScope scope Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

Try it:

macd

Creates MACD indicator on the chart.

Params:

Name Type Default Description
mapping anychart.data.TableMapping
Data mapping.
fastPeriod number
12
Fast period. Fast period must be greater than the slow period.
slowPeriod number
26
Slow period.
signalPeriod number
9
Signal period.
macdSeriesType string
"line"
Series type for MACD indicator (type as "line", "column", "ohlc").
signalSeriesType string
"line"
Series type for signal (type as "line", "column", "ohlc").
histogramSeriesType string
"column"
Series type for histogram (type as "line", "column", "ohlc").

Returns:

anychart.core.stock.indicators.MACD - An instance of class for method chaining.

Try it:

maxHeight

Getter for maximum height.

Returns:

number string null - Current element's maximum height.
Setter for maximum height.

Params:

Name Type Default Description
value number | string | null
null
Value to set.

Returns:

anychart.core.VisualBase - Self instance for method chaining.

Try it:

maxWidth

Getter for maximum width.

Returns:

number string null - Current element's maximum width.
Setter for maximum width.

Params:

Name Type Default Description
value number | string | null
null
Value to set.

Returns:

anychart.core.VisualBase - Self instance for method chaining.

Try it:

minHeight

Getter for minimum height.

Returns:

number string null - Current element's minimum height.
Setter for minimum height.

Params:

Name Type Default Description
value number | string | null
null
Value to set.

Returns:

anychart.core.VisualBase - Self instance for method chaining.

Try it:

minWidth

Getter for minimum width.

Returns:

number string null - Current element's minimum width.
Setter for minimum width.

Params:

Name Type Default Description
value number | string | null
null
Value to set.

Returns:

anychart.core.VisualBase - Self instance for method chaining.

Try it:

minorGrid

Getter for the current plot grid.

Params:

Name Type Description
index number Minor grid index.

Returns:

anychart.core.grids.Stock - Minor grid instance by index.

Try it:

Setter for the plot grid.

Params:

Name Type Description
value Object | boolean | null Minor grid settings to set.

Returns:

anychart.core.stock.Plot - Self instance for method chaining.
Setter for the plot grid by index.

Params:

Name Type Description
indexOrValue number Minor grid index.
value Object | boolean | null Minor grid settings to set.

Returns:

anychart.core.stock.Plot - Self instance for method chaining.

ohlc

Creates and returns a new ohlc series.

Params:

Name Type Description
data anychart.data.TableMapping | anychart.data.Table | Array.<Array.<*>> | string Value to set.
mappingSettings Object.<({column: number, type: anychart.enums.AggregationType, weights: number}|number)> An object where keys are field names and values are objects with fields: - 'column': number - Column index, that the field should get values from; - 'type': anychart.enums.AggregationType - How to group values for the field. Defaults to 'close'. - 'weights': number - Column to get weights from for 'weightedAverage' grouping type. Note: If type set to 'weightedAverage', but opt_weightsColumn is not passed - uses 'average' grouping instead. or numbers - just the column index to get values from. In this case the grouping type will be set to 'close'.
csvSettings Object CSV parser settings if the string is passed.

Returns:

anychart.core.stock.series.Base - An instance of class for method chaining.

print

Prints all elements on related stage.

Params:

Name Type Default Description
paperSize anychart.graphics.vector.PaperSize
Paper size.
landscape boolean
false
Flag of landscape.

Try it:

removeAllListeners

Removes all listeners from an object. You can also optionally remove listeners of some particular type.

Params:

Name Type Description
type string Type of event to remove, default is to remove all types.

Returns:

number - Number of listeners removed.

Try it:

removeAllSeries

Removes all series from chart.

Returns:

anychart.core.stock.Plot - Self instance for method chaining.

Try it:

removeSeries

Removes one of series from chart by its id.

Params:

Name Type Description
id number | string Series id.

Returns:

anychart.core.stock.Plot - Self instance for method chaining.

Try it:

removeSeriesAt

Removes one of series from chart by its index.

Params:

Name Type Description
index number Series index.

Returns:

anychart.core.stock.Plot - Self instance for method chaining.

Try it:

Getter for element right bound setting.

Returns:

number string undefined - Current element's right bound setting.
Sets element right bound setting.

Params:

Name Type Default Description
value number | string | null
null
Right bound setting for the element.

Returns:

anychart.core.VisualBaseWithBounds - Returns self for method chaining.

Try it:

roc

Creates RoC indicator on the chart.

Params:

Name Type Default Description
mapping anychart.data.TableMapping
Data mapping.
period number
20
Period.
seriesType string
"line"
Series type for RoC indicator (type as "line", "column", "ohlc").

Returns:

anychart.core.stock.indicators.RoC - An instance of class for method chaining.

Try it:

rsi

Creates RSI indicator on the chart.

Params:

Name Type Default Description
mapping anychart.data.TableMapping
Data mapping.
period number
14
Period.
seriesType string
"line"
Series type for RSI indicator (type as "line", "column", "ohlc").

Returns:

anychart.core.stock.indicators.RSI - An instance of class for method chaining.

Try it:

sma

Creates SMA indicator on the chart.

Params:

Name Type Default Description
mapping anychart.data.TableMapping
Data mapping.
period number
20
Period.
seriesType string
"line"
Series type for SMA indicator (type as "line", "column", "ohlc").

Returns:

anychart.core.stock.indicators.SMA - An instance of class for method chaining.

Try it:

top

Getter for element top bound setting.

Returns:

number string undefined - Current element's top bound setting.
Sets element top bound setting.

Params:

Name Type Default Description
value number | string | null
null
Top bound setting for the element.

Returns:

anychart.core.VisualBaseWithBounds - Returns self for method chaining.

Try it:

unlisten

Removes a listener added using listen() or listenOnce() methods.

Params:

Name Type Description
type string The event type id.
listener function Callback method.
useCapture boolean Whether to fire in capture phase (defaults to false).
listenerScope scope Object in whose scope to call the listener.

Returns:

boolean - Whether any listener was removed.

Try it:

unlistenByKey

Removes an event listener which was added with listen() by the key returned by listen() or listenOnce().

Params:

Name Type Description
key Object The key returned by listen() or listenOnce().

Returns:

boolean - Whether any listener was removed.

Try it:

width

Getter for element width setting.

Returns:

number string undefined - Current element's width setting.
Sets element width setting.

Params:

Name Type Default Description
value number | string | null
null
Width setting for the element.

Returns:

anychart.core.VisualBaseWithBounds - Returns self for method chaining.

Try it:

xAxis

Getter for the current X-axis.

Returns:

anychart.core.axes.StockDateTime - Axis instance.

Try it:

Setter for the X-axis.

Params:

Name Type Description
value Object | boolean | null Chart axis settings to set.

Returns:

anychart.core.stock.Plot - Self instance for method chaining.

yAxis

Getter for the current plot Y-axis.

Params:

Name Type Description
index number Axis index.

Returns:

anychart.core.axes.Linear - Axis instance by index.

Try it:

Setter for the plot Y-axis.

Params:

Name Type Description
value Object | boolean | null Chart axis settings to set.

Returns:

anychart.core.stock.Plot - Self instance for method chaining.
Setter for the Y-axis by index.

Params:

Name Type Description
index number Axis index.
value Object | boolean | null Chart axis settings to set.

Returns:

anychart.core.stock.Plot - Self instance for method chaining.

yScale

Getter for the default plot Y-scale.

Returns:

anychart.scales.ScatterBase - Default chart scale value.
See listing
var myPlot = chart.plot();
myPlot.yScale();
Setter for the plot Y-scale.

Params:

Name Type Description
value anychart.enums.ScatterScaleTypes | anychart.scales.ScatterBase Y-scale to set.

Returns:

anychart.core.stock.Plot - Self instance for method chaining.

Try it:

zIndex

Getter for the current Z-index of the element.

Returns:

number - The current zIndex.

Try it:

Setter for the Z-index of the element.

Params:

Name Type Default Description
value number
0
Value to set.

Returns:

anychart.core.VisualBase - Self instance for method chaining.

Try it: