Still have questions?
Contact support
You are looking at an outdated 7.12.0 version of this document. Switch to the 7.13.0 version to see the up to date information.



The Ray annotation allows to add a ray to a chart.

This article explains how to add a Ray and configure its basic and visual settings. You can find more settings and other useful information in the articles describing annotations in general:

Basic Settings

To add a Ray annotation to a chart, call the ray() method of the annotations() object.

Next, use the xAnchor(), valueAnchor(), secondXAnchor(), and secondValueAnchor() methods to set 2 points that determine the position of the ray. Usually, the most convenient way to do this is object notation:

// create a stock chart
chart = anychart.stock();

// create a plot on the chart
var plot = chart.plot(0);

// access the annotations() object of the plot to work with annotations
var controller = plot.annotations();

// create a Ray annotation
xAnchor: "2006-07-30",
valueAnchor: 17.24,
secondXAnchor: "2008-04-27",
secondValueAnchor: 26.75

This is how it looks like:

JsFiddle Playground

Visual Settings

You can also configure the visual settings of a Ray annotation:

In the sample below, there are two Ray annotations with some of the visual settings configured (by using an object in the first case and methods in the second):

// create the first Ray annotation and configure its visual settings
ray1 = controller.ray({
xAnchor: "2006-07-30",
valueAnchor: 17.24,
secondXAnchor: "2008-04-27",
secondValueAnchor: 26.75,
hoverStroke: "2 #FF0000",
selectStroke: "5 #FF0000"

// create the second Ray annotation
ray2 = controller.ray();

// set the position of the second annotation
// configure the visual settings of the second annotation
ray2.stroke("#2196F3", 3, "10 2");

JsFiddle Playground