Chart annotations in JavaScript Chart control

18 Nov 20181 minute to read

Chart annotations allow highlighting specific areas of the chart using text, shapes, images, or custom HTML elements. Annotations can be used to emphasize trends, mark thresholds, show custom notes, or display additional information directly inside the chart area.

Annotations are added using the annotations option. Set the content property to reference the element that should be rendered within the chart.

Note: To use the annotation feature, inject ChartAnnotation using Chart.Inject(ChartAnnotation) method.

Region

Annotations can be positioned relative to either the overall Chart area or a specific Series. When placed relative to the chart, the annotation uses the chart’s coordinate system. When placed relative to a series, the annotation aligns with that series’ data points. By default, annotations are placed with respect to the chart.

Co-ordinate units

Use the coordinateUnits property to define how annotation coordinates are interpreted. Choose between:

  • Pixel – The annotation is positioned using fixed pixel values within the chart area.
  • Point – The annotation is positioned based on chart data points (x and y values).

Alignment

Annotation provides verticalAlignment and horizontalAlignment. The verticalAlignment can be customized via Top, Bottom or Middle and the horizontalAlignment can be customized via Near, Far or Center.

Adding y-axis sub title through on annotation

By setting text div in the content option of annotation object you can add sub title to chart y-axis. Specified the coordinate value as pixel and customize x and y location of the text.

See also