Andrews' Pitchfork

Overview

The Andrews' Pitchfork annotation allows you to add an Andrews' pitchfork (an analysis tool developed by Alan Andrews) to a chart.

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

Next, use the xAnchor(), valueAnchor(), secondXAnchor(), secondValueAnchor(), thirdXAnchor() and thirdValueAnchor() methods to set 3 points that determine the position of the Andrews' pitchfork. 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 Andrews' Pitchfork annotation
controller.andrewsPitchfork({
    xAnchor: "2006-10-15",
    valueAnchor: 24.55,
    secondXAnchor: "2007-01-07",
    secondValueAnchor: 28.92,
    thirdXAnchor: "2007-05-20",
    thirdValueAnchor: 25.52
});

This is how it looks like:

Playground

Appearance

The appearance settings of an Andrews' Pitchfork 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 Andrews' Pitchfork annotations with some of the visual settings configured (by using an object in the first case and methods in the second):

// create the first Andrews' Pitchfork annotation and configure its visual settings
var andrewsPitchfork1 = controller.andrewsPitchfork({
    xAnchor: "2006-10-15",
    valueAnchor: 24.55,
    secondXAnchor: "2007-01-07",
    secondValueAnchor: 28.92,
    thirdXAnchor: "2007-05-20",
    thirdValueAnchor: 25.52,
    hovered: {stroke: "2 #ff0000"},
    selected: {stroke: "4 #ff0000"}
});

// create the second Andrews' Pitchfork annotation
var andrewsPitchfork2 = controller.andrewsPitchfork();

// set the position of the second annotation
andrewsPitchfork2.xAnchor("2007-12-16");
andrewsPitchfork2.valueAnchor(28.60);
andrewsPitchfork2.secondXAnchor("2008-08-10");
andrewsPitchfork2.secondValueAnchor(24.91);
andrewsPitchfork2.thirdXAnchor("2008-02-10");
andrewsPitchfork2.thirdValueAnchor(23.30);

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

Playground