Triangle Annotation

Overview

Triangle annotation allows to add a triangle to the chart, 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 a triangle 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.

to top

Adding annotation via settings

To add a triangle annotation to a chart you need to, as with any other annotation, add an annotation node, assign the id, set "Triangle" type and specify the chart id using chart attribute.

In triangle_annotation node you need anchors, which define three points on which triangle is based.

All this you can see in the basic XML/JSON snippet below:

XML/JSON Syntax
Plain code
01 <?xml version="1.0" encoding="UTF-8"?>
02 <stock xmlns="http://anychart.com/products/stock/schemas/1.9.0/schema.xsd">
03   <annotations>
04     <annotation_list>
05       <annotation id="Triangle_0856719161" type="Triangle" chart="idMainChart">
06         <triangle_annotation first_time_anchor="2009-04-26" first_value_anchor="29.55" second_time_anchor="2009-04-07" second_value_anchor="13.75" third_time_anchor="2009-01-22" third_value_anchor="24.17" />
07       </annotation>
08     </annotation_list>
09   </annotations>
10 </stock>
01{
02  annotations: {
03    annotationList: [
04      {
05        id: "Triangle_0856719161",
06        type: "Triangle",
07        chart: "idMainChart",
08        triangleAnnotation: {
09          firstTimeAnchor: "2009-04-26",
10          firstValueAnchor: 29.55,
11          secondTimeAnchor: "2009-04-07",
12          secondValueAnchor: 13.75,
13          thirdTimeAnchor: "2009-01-22",
14          thirdValueAnchor: 24.17
15        }
16      }
17    ]
18  }
19}

Live sample below shows a chart with this sample basic Triangle annotation:

Live Sample:  Adding Triangle Annotation

to top

Visual settings

You have a total control over the look of the triangle, to define visual settings you need to add settings node and then use border and fill 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 triangle in different states.

XML/JSON Syntax
Plain code
01 <?xml version="1.0" encoding="UTF-8"?>
02 <stock xmlns="http://anychart.com/products/stock/schemas/1.9.0/schema.xsd">
03   <annotations>
04     <annotation_list>
05       <annotation id="Triangle_0856719161" type="Triangle" chart="idMainChart">
06         <triangle_annotation color="#800080" first_time_anchor="2008-09-03" first_value_anchor="21.97" second_time_anchor="2008-10-20" second_value_anchor="16.73" third_time_anchor="2008-07-23" third_value_anchor="16.68">
07           <settings>
08             <border dashed="true" thickness="1" />
09             <fill opacity="0.4" />
10           </settings>
11         </triangle_annotation>
12       </annotation>
13     </annotation_list>
14   </annotations>
15 </stock>
01{
02  annotations: {
03    annotationList: [
04      {
05        id: "Triangle_0856719161",
06        type: "Triangle",
07        chart: "idMainChart",
08        triangleAnnotation: {
09          color: "#800080",
10          firstTimeAnchor: "2008-09-03",
11          firstValueAnchor: 21.97,
12          secondTimeAnchor: "2008-10-20",
13          secondValueAnchor: 16.73,
14          thirdTimeAnchor: "2008-07-23",
15          thirdValueAnchor: 16.68,
16          settings: {
17            border: {
18              dashed: true,
19              thickness: 1
20            },
21            fill: {
22              opacity: 0.4
23            }
24          }
25        }
26      }
27    ]
28  }
29}

Live sample below contains several Triangle annotations colored and configured in a different way:

Live Sample:  Triangle Annotation - Visual Settings

to top