Line Segment Annotation

Overview

Line annotation allows to add a line segment 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 Line segment 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 Line annotation to a chart you need to, as with any other annotation, add an annotation node, assign the id, set "Line" type and specify the chart id using chart attribute.

In line_annotation node you need specify value and time anchors, which define start and end points of Line segment.

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="idLineAnnotation" type="Line" chart="idMainChart">
06         <line_annotation first_time_anchor="2008-08-20" first_value_anchor="24.92" second_time_anchor="2008-12-18" second_value_anchor="14.79" />
07       </annotation>
08     </annotation_list>
09   </annotations>
10 </stock>
01{
02  annotations: {
03    annotationList: [
04      {
05        id: "idLineAnnotation",
06        type: "Line",
07        chart: "idMainChart",
08        lineAnnotation: {
09          firstTimeAnchor: "2008-08-20",
10          firstValueAnchor: 24.92,
11          secondTimeAnchor: "2008-12-18",
12          secondValueAnchor: 14.79
13        }
14      }
15    ]
16  }
17}

Live sample below shows a chart with this sample basic Line segment annotation:

Live Sample:  Adding Line Annotation

to top

Visual settings

You have a total control over the look of the line, to define visual settings you need to add settings node and then use line node to set how it should look like. Sample XML/JSON snippet below shows this.

If you click on line node 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 line 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="Line_0799278193" type="Line" chart="idMainChart">
06         <line_annotation color="#33CCCC" first_time_anchor="2009-02-23 22:13:54.924" first_value_anchor="19.43" second_time_anchor="2009-05-09 13:54:55.497" second_value_anchor="25.68">
07           <settings>
08             <line dashed="true" thickness="4" opacity="0.7" />
09           </settings>
10         </line_annotation>
11       </annotation>
12     </annotation_list>
13   </annotations>
14 </stock>
01{
02  annotations: {
03    annotationList: [
04      {
05        id: "Line_0799278193",
06        type: "Line",
07        chart: "idMainChart",
08        lineAnnotation: {
09          color: "#33CCCC",
10          firstTimeAnchor: "2009-02-23 22:13:54.924",
11          firstValueAnchor: 19.43,
12          secondTimeAnchor: "2009-05-09 13:54:55.497",
13          secondValueAnchor: 25.68,
14          settings: {
15            line: {
16              dashed: true,
17              thickness: 4,
18              opacity: 0.7
19            }
20          }
21        }
22      }
23    ]
24  }
25}

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

Live Sample:  Line Annotation - Visual Settings

to top