Still have questions?
Contact support

# Fibonacci Arc

## Overview

The Fibonacci Arc annotation allows you to add a Fibonacci arc to a chart.

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

Next, use the xAnchor(), valueAnchor(), secondXAnchor(), and secondValueAnchor() methods to set 2 points that determine the position of the Fibonacci arc. 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 Fibonacci Arc annotation
controller.fibonacciArc({
xAnchor: "2006-07-30",
valueAnchor: 17.24,
secondXAnchor: "2007-01-07",
secondValueAnchor: 28.92
});
``````

This is how it looks like:

## Levels

You can set the levels of a Fibonacci Arc annotation by using the levels() method and passing an array of values as a parameter:

``````// create a Fibonacci Arc annotation
controller.fibonacciArc({
xAnchor: "2006-07-30",
valueAnchor: 17.24,
secondXAnchor: "2007-01-07",
secondValueAnchor: 28.92,
levels: [0, 0.2, 0.4, 0.7, 1]
});
``````

## Appearance

The appearance settings of a Fibonacci Arc annotation can be configured in three states: normal, hover, and selected. Use the following methods:

Combine them with these methods:

You can also use object notation to specify the settings.

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

``````// create the first Fibonacci Arc annotation and configure its visual settings
var fibonacciArc1 = controller.fibonacciArc({
xAnchor: "2006-07-30",
valueAnchor: 17.24,
secondXAnchor: "2007-01-07",
secondValueAnchor: 28.92,
normal: {
labels: {fontColor: "#ff0000"}
},
hovered: {
stroke: "2 #ff0000",
trend: "2 #0000ff",
labels: {fontColor: "#ff0000"}
},
selected: {
stroke: "4 #ff0000",
trend: "4 #0000ff",
labels: {fontColor: "#ff0000"}
}
});

// create the second Fibonacci Arc annotation
var fibonacciArc2 = controller.fibonacciArc();

// set the position of the second annotation
fibonacciArc2.xAnchor("2004-01-11");
fibonacciArc2.valueAnchor(29.13);
fibonacciArc2.secondXAnchor("2004-08-08");
fibonacciArc2.secondValueAnchor(17.86);

// configure the visual settings of the second annotation
fibonacciArc2.normal().labels().fontColor("#00b300");
fibonacciArc2.normal().stroke("#006600", 1, "10 2");
fibonacciArc2.hovered().stroke("#00b300", 2, "10 2");
fibonacciArc2.selected().stroke("#00b300", 4, "10 2");
``````

To configure the visual settings of a certain level, use the normal(), selected(), and hovered() methods combined with stroke() and a function as a parameter. In this function, get level values from the context:

``````// create a Fibonacci Arc annotation
controller.fibonacciArc({
xAnchor: "2006-07-30",
valueAnchor: 17.24,
secondXAnchor: "2007-01-07",
secondValueAnchor: 28.92,
normal: {stroke: colorLevels},
hovered: {stroke: colorLevels},
selected: {stroke: colorLevels}
});

function colorLevels(){
if (this.level!==undefined) {
switch (this.level) {
case 0.5:
return "red";
break;
case 0.618:
return {color: "blue", dash: "2 2"};
break;
default:
return "black";
}
}
};
``````

## Labels

You can change the text of Fibonacci Arc labels with the help of text formatters.

Combine the labels() and format() methods with the following tokens:

• `{%level}` (shown by default)
• `{%levelValue}`
``````// create a Fibonacci Arc annotation
var fibonacciArc = controller.fibonacciArc({
xAnchor: "2006-07-30",
valueAnchor: 17.24,
secondXAnchor: "2007-01-07",
secondValueAnchor: 28.92
});

// configure the annotation labels
fibonacciArc.labels().format("{%level} ({%levelValue})");
``````

Instead of tokens, you can also use formatting functions and the following fields:

• `level` (shown by default)
• `levelValue`
``````// configure the annotation labels
fibonacciArc.labels().format(function() {
var levelValue = this.levelValue.toFixed(1);
switch (this.level) {
case 1:
return this.level + " (" + levelValue + ")";
break;
default:
return this.level;
}
});
``````