AnyChart
API Reference
Still have questions?
Contact support
Top
You are looking at an outdated 7.14.0 version of this document. Switch to the 8.4.0 version to see the up to date information.

class anychart.core.annotations.PlotController Improve this Doc

Extends: anychart.core.VisualBase

Plot controller class.

Methods Overview

Specific settings
add()Adds annotation on the plot.
andrewsPitchfork()Creates and returns an Andrews Pitchfork annotation.
cancelDrawing()Cancels current annotation drawing.
ellipse()Creates and returns an Ellipse annotation.
enabled()Disable or enable plot controller.
fibonacciArc()Creates and returns a Fibonacci Arc annotation.
fibonacciFan()Creates and returns a Fibonacci Fan annotation.
fibonacciRetracement()Creates and returns a Fibonacci Retracement annotation.
fibonacciTimezones()Creates and returns a Fibonacci Timezones annotation.
getAnnotationAt()Returns annotation by index.
getAnnotationsCount()Returns annotations count.
getSelectedAnnotation()Returns currently selected annotation.
horizontalLine()Creates and returns a Horizontal Line annotation.
infiniteLine()Creates and returns an Infinite Line annotation.
line()Creates and returns a Line annotation.
marker()Creates and returns a Marker annotation.
ray()Creates and returns a Ray annotation.
rectangle()Creates and returns a Rectangle annotation.
removeAllAnnotations()Removes all annotations from a plot.
removeAnnotation()Removes an annotation from a plot by its instance.
removeAnnotationAt()Removes an annotation from a plot by its index.
startDrawing()Starts annotation drawing.
trendChannel()Creates and returns a Trend Channel annotation.
triangle()Creates and returns a Triangle annotation.
verticalLine()Creates and returns a Vertical Line annotation.
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
select()Selects annotation.
unselect()Unselects annotations.
Size and Position
zIndex()Z-index of the element.
XML/JSON
fromJson()Creates annotations list by JSON config.
fromXml()Creates annotations list by XML config.
toJson()Return plot annotations configuration as JSON object or string.
toXml()Return plot annotations configuration as XML string or XMLNode.

Methods Description

add

Adds annotation on the plot.

Params:

NameTypeDescription
annotationTypeOrConfiganychart.enums.AnnotationTypes | anychart.core.annotations.AnnotationJSONFormatAnnotation settings.

Returns:

anychart.core.annotations.Base - Annotation instance

andrewsPitchfork

Creates and returns an Andrews Pitchfork annotation.

Params:

NameTypeDescription
configObjectAndrews pitchfork settings

Returns:

anychart.core.annotations.AndrewsPitchfork - Andrews pitchfork annotation instance.

cancelDrawing

Cancels current annotation drawing.

ellipse

Creates and returns an Ellipse annotation.

Params:

NameTypeDescription
configObjectEllipse settings

Returns:

anychart.core.annotations.Ellipse - Ellipse annotation instance.

enabled

Getter for the enabled state.

Returns:

boolean - Enabled state.
Setter for the enabled state.

Params:

NameTypeDescription
valuebooleanValue to set.

Returns:

anychart.core.annotations.PlotController - Self instance for method chaining.

fibonacciArc

Creates and returns a Fibonacci Arc annotation.

Params:

NameTypeDescription
configObjectFibonacci arc settings

Returns:

anychart.core.annotations.FibonacciArc - Fibonacci arc annotation instance.

fibonacciFan

Creates and returns a Fibonacci Fan annotation.

Params:

NameTypeDescription
configObjectFibonacci fan settings

Returns:

anychart.core.annotations.FibonacciFan - Fibonacci fan annotation instance.

fibonacciRetracement

Creates and returns a Fibonacci Retracement annotation.

Params:

NameTypeDescription
configObjectFibonacci retracement settings

Returns:

anychart.core.annotations.FibonacciRetracement - Fibonacci retracement annotation instance.

fibonacciTimezones

Creates and returns a Fibonacci Timezones annotation.

Params:

NameTypeDescription
configObjectFibonacci timezones settings

Returns:

anychart.core.annotations.FibonacciTimezones - Fibonacci timezones annotation instance.

fromJson

Creates annotations list by JSON config.

Params:

NameTypeDescription
configObject | stringJSON configuration as object or string.

Returns:

anychart.core.annotations.PlotController - Self instance for method chaining.

fromXml

Creates annotations list by XML config.

Params:

NameTypeDescription
configstring | NodeConfiguration as XML string or XMLNode.

Returns:

anychart.core.annotations.PlotController - Self instance for method chaining.

getAnnotationAt

Returns annotation by index.

Params:

NameTypeDescription
indexnumberIndex of the annotation.

Returns:

anychart.core.annotations.Base - Annotation instance.

getAnnotationsCount

Returns annotations count.

Returns:

number - Number of annotations.

getSelectedAnnotation

Returns currently selected annotation.

Returns:

anychart.core.annotations.Base - Annotation instance.

horizontalLine

Creates and returns a Horizontal Line annotation.

Params:

NameTypeDescription
configObjectHorizontal line settings

Returns:

anychart.core.annotations.HorizontalLine - Horizontal line annotation instance.

infiniteLine

Creates and returns an Infinite Line annotation.

Params:

NameTypeDescription
configObjectInfinite line settings.

Returns:

anychart.core.annotations.InfiniteLine - Infinite line annotation instance.

line

Creates and returns a Line annotation.

Params:

NameTypeDescription
configObjectLine settings.

Returns:

anychart.core.annotations.Line - Line annotation instance.

listen

Adds an event listener to an implementing object.

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction
Callback method. Function that looks like function(event){ // event.actualTarget - actual event target // event.currentTarget - current event target // event.iterator - event iterator // event.originalEvent - original event // event.point - event point // event.pointIndex - event point index }.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

listenOnce

Adds an event listener to an implementing object.

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction
Callback method.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

marker

Creates and returns a Marker annotation.

Params:

NameTypeDescription
configObjectMarker settings

Returns:

anychart.core.annotations.Marker - Marker annotation instance.

print

Prints all elements on related stage.

Params:

NameTypeDefaultDescription
paperSizeOrOptionsanychart.graphics.vector.PaperSize | Object
Paper size or object with options.
landscapeboolean
false
Flag of landscape.

ray

Creates and returns a Ray annotation.

Params:

NameTypeDescription
configObjectRay settings.

Returns:

anychart.core.annotations.Ray - Ray annotation instance.

rectangle

Creates and returns a Rectangle annotation.

Params:

NameTypeDescription
configObjectRectangle settings

Returns:

anychart.core.annotations.Rectangle - Rectangle annotation instance.

removeAllAnnotations

Removes all annotations from a plot.

Returns:

anychart.core.annotations.PlotController - Self for method chaining.

removeAllListeners

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

Params:

NameTypeDescription
typestringType of event to remove, default is to remove all types.

Returns:

number - Number of listeners removed.

removeAnnotation

Removes an annotation from a plot by its instance.

Params:

NameTypeDescription
annotationanychart.core.annotations.BaseAnnotation instance

Returns:

anychart.core.annotations.PlotController - Self instance for method chaining.

removeAnnotationAt

Removes an annotation from a plot by its index.

Params:

NameTypeDescription
indexnumberAnnotations index.

Returns:

anychart.core.annotations.PlotController - Self instance for method chaining.

select

Selects annotation.

Params:

NameTypeDescription
annotationanychart.core.annotations.BaseAnnotation instance to set.

Returns:

anychart.core.annotations.PlotController - Self instance for method chaining.

startDrawing

Starts annotation drawing.
Note: Works only after anychart.charts.Cartesian#draw and anychart.charts.Stock#draw is called.

Params:

NameTypeDescription
annotationTypeOrConfiganychart.enums.AnnotationTypes | anychart.core.annotations.AnnotationJSONFormatAnnotation settings.

Returns:

anychart.core.annotations.Base - Annotation instance.

toJson

Return plot annotations configuration as JSON object or string.

Params:

NameTypeDefaultDescription
stringifyboolean
false
Returns JSON as string.
includeThemeboolean
false
If the current theme properties should be included into the result.

Returns:

Object | string - Plot annotations configuration

toXml

Return plot annotations configuration as XML string or XMLNode.

Params:

NameTypeDefaultDescription
asXmlNodeboolean
false
Return XML as XMLNode.
includeThemeboolean
false
If the current theme properties should be included into the result.

Returns:

string | Node - Plot annotations configuration.

trendChannel

Creates and returns a Trend Channel annotation.

Params:

NameTypeDescription
configObjectTrend channel settings

Returns:

anychart.core.annotations.TrendChannel - Trend channel annotation instance.

triangle

Creates and returns a Triangle annotation.

Params:

NameTypeDescription
configObjectTriangle settings

Returns:

anychart.core.annotations.Triangle - Triangle annotation instance.

unlisten

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

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction
Callback method.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

boolean - Whether any listener was removed.

unlistenByKey

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

Params:

NameTypeDescription
keyObjectThe key returned by listen() or listenOnce().

Returns:

boolean - Whether any listener was removed.

unselect

Unselects annotations.

Returns:

anychart.core.annotations.PlotController - Self instance for method chaining.

verticalLine

Creates and returns a Vertical Line annotation.

Params:

NameTypeDescription
configObjectVertical line settings

Returns:

anychart.core.annotations.VerticalLine - Vertical line annotation instance.

zIndex

Getter for the current Z-index of the element.

Returns:

number - The current zIndex.
Setter for the Z-index of the element.

Params:

NameTypeDefaultDescription
valuenumber
0
Value to set.

Returns:

anychart.core.annotations.PlotController - Self instance for method chaining.