Ellipse

Overview

The Ellipse annotation allows to add an ellipse or a circle to a chart.

This article explains how to add an Ellipse 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 an Ellipse annotation to a chart, call the ellipse() method of the annotations() object.

Next, use the xAnchor(), valueAnchor(), secondXAnchor(), and secondValueAnchor() methods to set 2 points that determine the position of the ellipse. 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 an Ellipse annotation
controller.ellipse({
    xAnchor: "2006-11-20",
    valueAnchor: 25.92,
    secondXAnchor: "2008-08-10",
    secondValueAnchor: 24.91,
});

This is how it looks like:

Playground

Visual Settings

You can also configure the visual settings of an Ellipse annotation:

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

// create the first Ellipse annotation and configure its visual settings
ellipse1 = controller.ellipse({
    xAnchor: "2006-11-20",
    valueAnchor: 25.92,
    secondXAnchor: "2007-02-24",
    secondValueAnchor: 31.92,
    hoverFill: "#398CAE 0.3",
    hoverStroke: "2 #FF0000",
    selectFill: "#398CAE 0.3",
    selectHatchFill: "brick",
    selectStroke: "5 #FF0000"
});

// create the second Ellipse annotation
ellipse2 = controller.ellipse();

// set the position of the second annotation
ellipse2.xAnchor("2005-11-20");
ellipse2.valueAnchor(15.55);
ellipse2.secondXAnchor("2007-02-25");
ellipse2.secondValueAnchor(23.30);
 
// configure the visual settings of the second annotation
ellipse2.stroke("#2196F3", 3, "10 2");
ellipse2.fill(null);

Playground

You are looking at an outdated v7 version of this document. Switch to the v8 version to see the up to date information.