AnyChart
API Reference
Still have questions?
Contact support
Top

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 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 selected annotation.
horizontalLine()Creates and returns a Horizontal Line annotation.
infiniteLine()Creates and returns an Infinite Line annotation.
label()Creates and returns a Label 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
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 | string | anychart.core.annotations.AnnotationJSONFormatAnnotation settings.

Returns:

anychart.core.annotations.Base - Annotation instance

andrewsPitchfork

Creates and returns an Andrews Pitchfork annotation.

Params:

NameTypeDescription
settingsObjectAndrews pitchfork settings

Returns:

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

cancelDrawing

Cancels annotation drawing.

ellipse

Creates and returns an Ellipse annotation.

Params:

NameTypeDescription
settingsObjectEllipse 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
enabledbooleanValue to set.

Returns:

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

fibonacciArc

Creates and returns a Fibonacci Arc annotation.

Params:

NameTypeDescription
settingsObjectFibonacci arc settings

Returns:

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

fibonacciFan

Creates and returns a Fibonacci Fan annotation.

Params:

NameTypeDescription
settingsObjectFibonacci fan settings

Returns:

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

fibonacciRetracement

Creates and returns a Fibonacci Retracement annotation.

Params:

NameTypeDescription
settingsObjectFibonacci retracement settings

Returns:

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

fibonacciTimezones

Creates and returns a Fibonacci Timezones annotation.

Params:

NameTypeDescription
settingsObjectFibonacci 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 selected annotation.

Returns:

anychart.core.annotations.Base - Annotation instance.

horizontalLine

Creates and returns a Horizontal Line annotation.

Params:

NameTypeDescription
settingsObjectHorizontal line settings

Returns:

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

infiniteLine

Creates and returns an Infinite Line annotation.

Params:

NameTypeDescription
settingsObjectInfinite line settings.

Returns:

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

label

Creates and returns a Label annotation.

Params:

NameTypeDescription
settingsObjectLabel annotation settings.

Returns:

anychart.core.annotations.Label - Label annotation instance.

line

Creates and returns a Line annotation.

Params:

NameTypeDescription
settingsObjectLine 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(e:Object)
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(e:Object)
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
settingsObjectMarker 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
settingsObjectRay settings.

Returns:

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

rectangle

Creates and returns a Rectangle annotation.

Params:

NameTypeDescription
settingsObjectRectangle 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.

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 | string | 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.

Returns:

Object | string - Plot annotations configuration

toXml

Return plot annotations configuration as XML string or XMLNode.

Params:

NameTypeDefaultDescription
asXmlNodeboolean
false
Return XML as XMLNode.

Returns:

string | Node - Plot annotations configuration.

trendChannel

Creates and returns a Trend Channel annotation.

Params:

NameTypeDescription
settingsObjectTrend channel settings

Returns:

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

triangle

Creates and returns a Triangle annotation.

Params:

NameTypeDescription
settingsObjectTriangle 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(e:Object):boolean|undefined
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
settingsObjectVertical line settings

Returns:

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

zIndex

Getter for the Z-index of the element.

Returns:

number - Z-index.
Setter for the Z-index of the element.

Params:

NameTypeDefaultDescription
zIndexnumber
0
Value to set.

Returns:

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