Drawing Tools and Annotations: Arrow
Overview
Arrow annotation allows to add arrows to the chart, which can be used to display buy/sell
signals or mark any other significant point, as any other annotation it can
be drawn by user or added to the chart via XML or JSON settings. In this article you can learn how
to add an arrow via XML or JSON settings and what visual settings can be done.
To learn about basic settings, that can be done with an annotation please refer to: Drawing Tools and Annotations: General Settings.
Adding annotation via settings
To add an Arrow annotation to a chart you need to, as with any other annotation, add an annotation node, assign
the id, set "Arrow" type and specify the chart id using chart attribute.
In arrow_annotation node you need an anchor, which define where arrow is placed.
All this you can see in the basic XML/JSON snippet below:
01 |
<?xml version="1.0" encoding="UTF-8"?> |
02 |
< stock xmlns = "http://anychart.com/products/stock/schemas/1.9.0/schema.xsd" > |
05 | id: "idArrowAnnotation1" , |
Live sample below shows a chart with this sample basic Arrow annotation:
Live Sample: Adding Arrow Annotation
Direction
Important option of Arrow annotation is direction attribute, which sets the rotation of an arrow.
Direction can be: "Up", "Down", "Left" and "Right" and it is set as follows:
01 |
<?xml version="1.0" encoding="UTF-8"?> |
02 |
< stock xmlns = "http://anychart.com/products/stock/schemas/1.9.0/schema.xsd" > |
05 | id: "idArrowAnnotation1" , |
Live sample below shows all possible directions:
Live Sample: Arrow Annotation - Set direction
And in this sample you see how arrows can be used to show Buy/Sell signals:
Live Sample: Arrow Annotation - Buy-Sell Signals
Value alignment anchor
Value alignment anchor sets where exactly arrow is placed relative to to value, it is set in anchor attribute and can be "Beginning", "Center" or "Ending":
01 |
<?xml version="1.0" encoding="UTF-8"?> |
02 |
< stock xmlns = "http://anychart.com/products/stock/schemas/1.9.0/schema.xsd" > |
05 | id: "idArrowAnnotation1" , |
For example, with the same value_anchor and different anchor arrow is placed differently:
In the live sample below all six arrows has value_anchor="25", but different direction and anchor:
Live Sample: Arrow Annotation - Value Anchor
Shape and size
You can control the size and shape of an arrow using width, length,
tail_length_ratio and tail_width_ratio attributes of arrow_annotation node:
01 |
<?xml version="1.0" encoding="UTF-8"?> |
02 |
< stock xmlns = "http://anychart.com/products/stock/schemas/1.9.0/schema.xsd" > |
05 | id: "Arrow_0352730616" , |
width and length attributes set the size, and ratios define proportions of an arrow.
Sample below shows different shapes of arrows:
Live Sample: Arrow Annotation - Size and Proportions
Visual settings
You have a total control over the look of Arrows, to define visual settings you
need to add settings node and then use fill and border
nodes to set how it should look like. Sample XML/JSON snippet below shows this.
If you click on nodes in the snippet, XML or JSON reference
will be opened and you will be able to browse all possible settings, including the look of the arrow in
different states.
01 |
<?xml version="1.0" encoding="UTF-8"?> |
02 |
< stock xmlns = "http://anychart.com/products/stock/schemas/1.9.0/schema.xsd" > |
05 | id: "idArrowAnnotation1" , |
Live sample below contains several Arrow annotations colored and configured in a different way:
Live Sample: Arrow Annotation - Visual Settings