DevExtreme v24.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

JavaScript/jQuery Charts - Chart with Annotations

Annotations are containers for images, text blocks, and custom content that display additional information about the visualized data.

To create annotations, populate the Chart's annotations array. Each object in the array configures an individual annotation. To specify properties for all annotations, use the commonAnnotationSettings object. Individual settings take precedence over common settings.

https://www.wikipedia.org/
Backend API
$(() => { $('#chart').dxChart({ dataSource, title: { text: 'Apple Stock Price', subtitle: 'AAPL', }, series: { valueField: 'close', name: 'AAPL', argumentField: 'date', type: 'line', }, legend: { visible: false, }, argumentAxis: { argumentType: 'datetime', }, valueAxis: { position: 'right', }, commonAnnotationSettings: { series: 'AAPL', type: 'image', font: { size: 16, weight: 600, }, image: { width: 50.5, height: 105.75, }, customizeTooltip(e) { return { html: $("<div class='tooltip'>") .appendTo($('<div>')) .text(e.description) .parent() .html(), }; }, }, annotations: [ { argument: new Date(2016, 2, 31), image: { url: '../../../../images/Charts/Annotation/iphone-se.png', }, description: 'The iPhone SE (Special Edition) is a smartphone that was designed and marketed by Apple Inc. It is part of the ninth generation of the iPhone alongside the iPhone 6S. It was announced on March 21, 2016 at the Town Hall auditorium in the Apple Campus by Apple executive Greg Joswiak, with pre-orders beginning on March 24, and official release on March 31, 2016. It was re-released almost a year later on March 24, 2017 with larger storage capacities. The iPhone SE shares the same physical design and dimensions as the iPhone 5S, but has upgraded internal hardware, including the newer Apple A9 system-on-chip, greater battery capacity, and a 12-megapixel rear camera that can record 4K video. Along with the iPhone 6S and the iPhone X, the iPhone SE was discontinued by Apple on September 12, 2018', }, { argument: new Date(2017, 10, 3), offsetY: 110, image: { url: '../../../../images/Charts/Annotation/iphone-x.png', }, description: "iPhone X (Roman numeral 'X' pronounced 'ten') is a smartphone designed, developed, and marketed by Apple Inc. It was the eleventh generation of the iPhone. It was announced on September 12, 2017, alongside the iPhone 8 and iPhone 8 Plus, at the Steve Jobs Theater in the Apple Park campus. The phone was released on November 3, 2017, marking the iPhone series' tenth anniversary", }, { argument: new Date(2015, 3, 24), paddingTopBottom: 5, image: { url: '../../../../images/Charts/Annotation/apple-watch.png', }, description: 'Apple Watch is a line of smartwatches designed, developed, and marketed by Apple Inc. It incorporates fitness tracking and health-oriented capabilities with integration with iOS and other Apple products and services. The Apple Watch was released on April 24, 2015 and quickly became the best-selling wearable device with 4.2 million sold in the second quarter of the 2015 fiscal year', }, { argument: new Date(2017, 5, 5), type: 'text', text: 'WWDC 2017', description: 'The Apple Worldwide Developers Conference was held from June 5 to June 9, 2017 at the San Jose Convention Center in San Jose, California, which was the first time since 2002 that the conference took place in the city. Software announcements included iOS 11, watchOS 4, macOS High Sierra, and updates to tvOS. Hardware announcements included updates to iMac, MacBook and MacBook Pro, as well as the new iMac Pro, 10.5-inch iPad Pro and smart speaker HomePod. Fall Out Boy performed at the Bash held in Discovery Meadow on June 8', }, { argument: new Date(2019, 2, 25), type: 'text', text: 'Apple TV+ announced', description: 'Apple TV+ is an upcoming over-the-top ad-free subscription video on demand web television service announced by Apple Inc. in 2019 during their March 25 Apple Special Event held at Steve Jobs Theater', }, ], }); });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/24.1.6/css/dx.light.css" /> <script src="js/dx.all.js"></script> <script src="data.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="chart"></div> </div> </body> </html>
#chart { height: 440px; } .tooltip { width: 300px; }
const dataSource = [{ date: '2014-12-29', close: 109.330002, }, { date: '2015-01-05', close: 112.010002, }, { date: '2015-01-12', close: 105.989998, }, { date: '2015-01-19', close: 112.980003, }, { date: '2015-01-26', close: 117.160004, }, { date: '2015-02-02', close: 118.93, }, { date: '2015-02-09', close: 127.080002, }, { date: '2015-02-16', close: 129.5, }, { date: '2015-02-23', close: 128.460007, }, { date: '2015-03-02', close: 126.599998, }, { date: '2015-03-09', close: 123.589996, }, { date: '2015-03-16', close: 125.900002, }, { date: '2015-03-23', close: 123.25, }, { date: '2015-03-30', close: 125.32, }, { date: '2015-04-06', close: 127.099998, }, { date: '2015-04-13', close: 124.75, }, { date: '2015-04-20', close: 130.279999, }, { date: '2015-04-27', close: 128.949997, }, { date: '2015-05-04', close: 127.620003, }, { date: '2015-05-11', close: 128.770004, }, { date: '2015-05-18', close: 132.539993, }, { date: '2015-05-25', close: 130.279999, }, { date: '2015-06-01', close: 128.649994, }, { date: '2015-06-08', close: 127.169998, }, { date: '2015-06-15', close: 126.599998, }, { date: '2015-06-22', close: 126.75, }, { date: '2015-06-29', close: 126.440002, }, { date: '2015-07-06', close: 123.279999, }, { date: '2015-07-13', close: 129.619995, }, { date: '2015-07-20', close: 124.5, }, { date: '2015-07-27', close: 121.300003, }, { date: '2015-08-03', close: 115.519997, }, { date: '2015-08-10', close: 115.959999, }, { date: '2015-08-17', close: 105.760002, }, { date: '2015-08-24', close: 113.290001, }, { date: '2015-08-31', close: 109.269997, }, { date: '2015-09-07', close: 114.209999, }, { date: '2015-09-14', close: 113.449997, }, { date: '2015-09-21', close: 114.709999, }, { date: '2015-09-28', close: 110.379997, }, { date: '2015-10-05', close: 112.120003, }, { date: '2015-10-12', close: 111.040001, }, { date: '2015-10-19', close: 119.080002, }, { date: '2015-10-26', close: 119.5, }, { date: '2015-11-02', close: 121.059998, }, { date: '2015-11-09', close: 112.339996, }, { date: '2015-11-16', close: 119.300003, }, { date: '2015-11-23', close: 117.809998, }, { date: '2015-11-30', close: 119.029999, }, { date: '2015-12-07', close: 113.18, }, { date: '2015-12-14', close: 106.029999, }, { date: '2015-12-21', close: 108.029999, }, { date: '2015-12-28', close: 105.260002, }, { date: '2016-01-04', close: 96.959999, }, { date: '2016-01-11', close: 97.129997, }, { date: '2016-01-18', close: 101.419998, }, { date: '2016-01-25', close: 97.339996, }, { date: '2016-02-01', close: 94.019997, }, { date: '2016-02-08', close: 93.989998, }, { date: '2016-02-15', close: 96.040001, }, { date: '2016-02-22', close: 96.910004, }, { date: '2016-02-29', close: 103.010002, }, { date: '2016-03-07', close: 102.260002, }, { date: '2016-03-14', close: 105.919998, }, { date: '2016-03-21', close: 105.669998, }, { date: '2016-03-28', close: 109.989998, }, { date: '2016-04-04', close: 108.660004, }, { date: '2016-04-11', close: 109.849998, }, { date: '2016-04-18', close: 105.68, }, { date: '2016-04-25', close: 93.739998, }, { date: '2016-05-02', close: 92.720001, }, { date: '2016-05-09', close: 90.519997, }, { date: '2016-05-16', close: 95.220001, }, { date: '2016-05-23', close: 100.349998, }, { date: '2016-05-30', close: 97.919998, }, { date: '2016-06-06', close: 98.830002, }, { date: '2016-06-13', close: 95.330002, }, { date: '2016-06-20', close: 93.400002, }, { date: '2016-06-27', close: 95.889999, }, { date: '2016-07-04', close: 96.68, }, { date: '2016-07-11', close: 98.779999, }, { date: '2016-07-18', close: 98.660004, }, { date: '2016-07-25', close: 104.209999, }, { date: '2016-08-01', close: 107.480003, }, { date: '2016-08-08', close: 108.18, }, { date: '2016-08-15', close: 109.360001, }, { date: '2016-08-22', close: 106.940002, }, { date: '2016-08-29', close: 107.730003, }, { date: '2016-09-05', close: 103.129997, }, { date: '2016-09-12', close: 114.919998, }, { date: '2016-09-19', close: 112.709999, }, { date: '2016-09-26', close: 113.050003, }, { date: '2016-10-03', close: 114.059998, }, { date: '2016-10-10', close: 117.629997, }, { date: '2016-10-17', close: 116.599998, }, { date: '2016-10-24', close: 113.720001, }, { date: '2016-10-31', close: 108.839996, }, { date: '2016-11-07', close: 108.43, }, { date: '2016-11-14', close: 110.059998, }, { date: '2016-11-21', close: 111.790001, }, { date: '2016-11-28', close: 109.900002, }, { date: '2016-12-05', close: 113.949997, }, { date: '2016-12-12', close: 115.970001, }, { date: '2016-12-19', close: 116.519997, }, { date: '2016-12-26', close: 115.82, }, { date: '2017-01-02', close: 117.910004, }, { date: '2017-01-09', close: 119.040001, }, { date: '2017-01-16', close: 120, }, { date: '2017-01-23', close: 121.949997, }, { date: '2017-01-30', close: 129.080002, }, { date: '2017-02-06', close: 132.119995, }, { date: '2017-02-13', close: 135.720001, }, { date: '2017-02-20', close: 136.660004, }, { date: '2017-02-27', close: 139.779999, }, { date: '2017-03-06', close: 139.139999, }, { date: '2017-03-13', close: 139.990005, }, { date: '2017-03-20', close: 140.639999, }, { date: '2017-03-27', close: 143.660004, }, { date: '2017-04-03', close: 143.339996, }, { date: '2017-04-10', close: 141.050003, }, { date: '2017-04-17', close: 142.270004, }, { date: '2017-04-24', close: 143.649994, }, { date: '2017-05-01', close: 148.960007, }, { date: '2017-05-08', close: 156.100006, }, { date: '2017-05-15', close: 153.059998, }, { date: '2017-05-22', close: 153.610001, }, { date: '2017-05-29', close: 155.449997, }, { date: '2017-06-05', close: 148.979996, }, { date: '2017-06-12', close: 142.270004, }, { date: '2017-06-19', close: 146.279999, }, { date: '2017-06-26', close: 144.020004, }, { date: '2017-07-03', close: 144.179993, }, { date: '2017-07-10', close: 149.039993, }, { date: '2017-07-17', close: 150.270004, }, { date: '2017-07-24', close: 149.5, }, { date: '2017-07-31', close: 156.389999, }, { date: '2017-08-07', close: 157.479996, }, { date: '2017-08-14', close: 157.5, }, { date: '2017-08-21', close: 159.860001, }, { date: '2017-08-28', close: 164.050003, }, { date: '2017-09-04', close: 158.630005, }, { date: '2017-09-11', close: 159.880005, }, { date: '2017-09-18', close: 151.889999, }, { date: '2017-09-25', close: 154.119995, }, { date: '2017-10-02', close: 155.300003, }, { date: '2017-10-09', close: 156.990005, }, { date: '2017-10-16', close: 156.25, }, { date: '2017-10-23', close: 163.050003, }, { date: '2017-10-30', close: 172.5, }, { date: '2017-11-06', close: 174.669998, }, { date: '2017-11-13', close: 170.149994, }, { date: '2017-11-20', close: 174.970001, }, { date: '2017-11-27', close: 171.050003, }, { date: '2017-12-04', close: 169.369995, }, { date: '2017-12-11', close: 173.970001, }, { date: '2017-12-18', close: 175.009995, }, { date: '2017-12-25', close: 169.229996, }, { date: '2018-01-01', close: 175, }, { date: '2018-01-08', close: 177.089996, }, { date: '2018-01-15', close: 178.460007, }, { date: '2018-01-22', close: 171.509995, }, { date: '2018-01-29', close: 160.5, }, { date: '2018-02-05', close: 156.410004, }, { date: '2018-02-12', close: 172.429993, }, { date: '2018-02-19', close: 175.5, }, { date: '2018-02-26', close: 176.210007, }, { date: '2018-03-05', close: 179.979996, }, { date: '2018-03-12', close: 178.020004, }, { date: '2018-03-19', close: 164.940002, }, { date: '2018-03-26', close: 167.779999, }, { date: '2018-04-02', close: 168.380005, }, { date: '2018-04-09', close: 174.729996, }, { date: '2018-04-16', close: 165.720001, }, { date: '2018-04-23', close: 162.320007, }, { date: '2018-04-30', close: 183.830002, }, { date: '2018-05-07', close: 188.589996, }, { date: '2018-05-14', close: 186.309998, }, { date: '2018-05-21', close: 188.580002, }, { date: '2018-05-28', close: 190.240005, }, { date: '2018-06-04', close: 191.699997, }, { date: '2018-06-11', close: 188.839996, }, { date: '2018-06-18', close: 184.919998, }, { date: '2018-06-25', close: 185.110001, }, { date: '2018-07-02', close: 187.970001, }, { date: '2018-07-09', close: 191.330002, }, { date: '2018-07-16', close: 191.440002, }, { date: '2018-07-23', close: 190.979996, }, { date: '2018-07-30', close: 207.990005, }, { date: '2018-08-06', close: 207.529999, }, { date: '2018-08-13', close: 217.580002, }, { date: '2018-08-20', close: 216.160004, }, { date: '2018-08-27', close: 227.630005, }, { date: '2018-09-03', close: 221.300003, }, { date: '2018-09-10', close: 223.839996, }, { date: '2018-09-17', close: 217.660004, }, { date: '2018-09-24', close: 225.740005, }, { date: '2018-10-01', close: 224.289993, }, { date: '2018-10-08', close: 222.110001, }, { date: '2018-10-15', close: 219.309998, }, { date: '2018-10-22', close: 216.300003, }, { date: '2018-10-29', close: 207.479996, }, { date: '2018-11-05', close: 204.470001, }, { date: '2018-11-12', close: 193.529999, }, { date: '2018-11-19', close: 172.289993, }, { date: '2018-11-26', close: 178.580002, }, { date: '2018-12-03', close: 168.490005, }, { date: '2018-12-10', close: 165.479996, }, { date: '2018-12-17', close: 150.729996, }, { date: '2018-12-24', close: 156.229996, }, { date: '2018-12-31', close: 148.259995, }, { date: '2019-01-07', close: 152.289993, }, { date: '2019-01-14', close: 156.820007, }, { date: '2019-01-21', close: 157.759995, }, { date: '2019-01-28', close: 166.520004, }, { date: '2019-02-04', close: 170.410004, }, { date: '2019-02-11', close: 170.419998, }, { date: '2019-02-18', close: 172.970001, }, { date: '2019-02-25', close: 174.970001, }, { date: '2019-03-04', close: 172.910004, }, { date: '2019-03-11', close: 186.119995, }, { date: '2019-03-18', close: 191.050003, }, { date: '2019-03-25', close: 189.949997, }, { date: '2019-04-01', close: 197, }, { date: '2019-04-08', close: 198.869995, }, { date: '2019-04-15', close: 203.860001, }, { date: '2019-04-22', close: 205.279999, }];

You can set each annotation's type property to "text", "image", or "custom". Depending on the type, specify the text or image property. You can also add a description that will be displayed in a tooltip.

Annotations can be unattached or anchored to a chart element. In this demo, all annotations are anchored to series points via the argument and series properties. Refer to the annotations description for more information on how to position annotations.