{"id":12943,"date":"2021-06-17T16:34:58","date_gmt":"2021-06-17T16:34:58","guid":{"rendered":"https:\/\/www.anychart.com\/blog\/?p=12943"},"modified":"2022-08-13T11:06:07","modified_gmt":"2022-08-13T11:06:07","slug":"timeline-chart-javascript","status":"publish","type":"post","link":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/","title":{"rendered":"How to Create Interactive Timeline Chart with JavaScript"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js.png\" alt=\"A laptop screen with an interactive JavaScript Timeline Chart of COVID-19 vaccine development built along this JS charting tutorial\" width=\"100%\" class=\"alignnone size-full wp-image-12954\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js.png 1500w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js-300x160.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js-768x410.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js-1024x546.png 1024w\" sizes=\"(max-width: 1500px) 100vw, 1500px\" \/>I think all of us have come across <a href=\"https:\/\/www.targetprocess.com\/blog\/42-timelines-is-the-answer\/\" target=\"_blank\" rel=\"nofollow\">timelines<\/a> somewhere or the other; as a means of conveying chronological information, the classic timeline is unmatched, both in the depth of information conveyed and the \u201ccool\u201d factor, when done with a deft creative touch. So, with that said, would you like to learn how to build a timeline chart using JavaScript that both looks great and is simple to create? (Of course, you do!) Follow along with me as I take you through the step-by-step breakdown for developing your own JS timeline with a practical example.<\/p>\n<p>As the world continues to battle with COVID-19, the long-awaited good news is the development of vaccines across the globe. Here, I decided to build an interactive timeline that showcases the phases of Pfizer-BioNTech vaccine development in the United States. To add more contextual information, I also wanted to show approvals from other countries and some related facts, including the dates for the development of the 3 other vaccines approved for usage in the US.<\/p>\n<p><!--more Read the JS charting tutorial \u00bb--><\/p>\n<p>Ultimately, this is what the finished product turns out as:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js-final.png\" alt=\"An interactive JS-based timeline chart of COVID-19 vaccine development to be created\" width=\"100%\" class=\"alignnone size-full wp-image-12957\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js-final.png 1010w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js-final-300x171.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js-final-768x437.png 768w\" sizes=\"(max-width: 1010px) 100vw, 1010px\" \/><\/p>\n<h2>Building a Basic JavaScript Timeline Chart in 4 Steps<\/h2>\n<p>It\u2019s actually quite easy to create charts and visualize data even without much technical knowledge. Of course, if you have skills with technologies like HTML and JavaScript, it is easier to grasp what is happening and you can arrange a wider range of customizations quicker. Nonetheless, data visualization with one of the available <a href=\"https:\/\/en.wikipedia.org\/wiki\/Comparison_of_JavaScript_charting_libraries\" target=\"_blank\" rel=\"nofollow\">JS charting libraries<\/a> is fairly straightforward. So, without worrying about any bugs (well, unfortunately, we do have to worry about the viruses), let\u2019s take our first attempt at creating a timeline with JavaScript.<\/p>\n<p>The first thing to understand is that not all JavaScript charting libraries support timeline charts. So logically, the first thing to do is to find one that does. In this tutorial, I decided to use <a href=\"https:\/\/www.anychart.com\/\">AnyChart<\/a> as it supports timelines out of the box and is also lightweight, flexible, and easy-to-use, providing extensive <a href=\"https:\/\/docs.anychart.com\/\" target=\"_blank\" rel=\"nofollow\">documentation<\/a> and a dedicated <a href=\"https:\/\/playground.anychart.com\/\" target=\"_blank\" rel=\"nofollow\">playground<\/a> that\u2019s helpful for practising with code. All of this should help you understand the basics of the process, which tend to be quite similar regardless of which specific library you choose.<\/p>\n<p>There are 4 fundamental steps to creating any JS chart, including a JS timeline chart. They are:<\/p>\n<ul>\n<li>Make a basic HTML page.<\/li>\n<li>Reference all necessary scripts.<\/li>\n<li>Add the data.<\/li>\n<li>Write some JS code to configure the timeline chart.<\/li>\n<\/ul>\n<h3>1. Make a basic HTML page<\/h3>\n<p>First of all, we have to set up a basic HTML page. This includes developing a framework for the visualization as well as adding the necessary CSS rules.<\/p>\n<p>A basic HTML template is enclosed in <code>html<\/code> tag and contains 2 portions \u2014 a <code>head<\/code> and a <code>body<\/code>. The title of the page along with CSS links and JS scripts go in the <code>head<\/code> part. The body part defines the various components of the <code>html<\/code> page. One of the fundamental ways to define a section of the page is using the <code>div<\/code> tag in HTML.<\/p>\n<p>Here, I create a <code>div<\/code> to contain the timeline chart and give it an id that will identify this specific container. I have set \u201c100%\u201d in both width and height parameters to make the timeline visualization occupy the entire page.<\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&nbsp;&nbsp;&lt;head&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;JavaScript Timeline Chart&lt;\/title&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;style type=\"text\/css\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;html,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;body,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#container {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 100%;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;height: 100%;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;margin: 0;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;padding: 0;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/style&gt;\r\n&nbsp;&nbsp;&lt;\/head&gt;\r\n&nbsp;&nbsp;&lt;body&gt;  \r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n&nbsp;&nbsp;&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h3>2. Reference all necessary scripts<\/h3>\n<p>Second, all necessary JS scripts need to be referenced in the <code>&lt;head&gt;<\/code> section. For this tutorial, since I am using the AnyChart library, I will include the corresponding files from its <a href=\"https:\/\/www.anychart.com\/download\/cdn\/\">CDN<\/a> (Content Delivery Network).<\/p>\n<p>To create a timeline chart, I will need to add references to the <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Modules#core\" target=\"_blank\" rel=\"nofollow\">core library module<\/a> from AnyChart that is necessary for all types of charts as well as the special <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Modules#timeline\" target=\"_blank\" rel=\"nofollow\">timeline module<\/a>.<\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&nbsp;&nbsp;&lt;head&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;JavaScript Timeline Chart&lt;\/title&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.9.0\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.9.0\/js\/anychart-timeline.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;style type=\"text\/css\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;html,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;body,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#container {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 100%;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;height: 100%;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;margin: 0;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;padding: 0;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/style&gt;\r\n&nbsp;&nbsp;&lt;\/head&gt;\r\n&nbsp;&nbsp;&lt;body&gt;  \r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ All the JS code for the timeline chart will come here.\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/script&gt;\r\n&nbsp;&nbsp;&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h3>3. Add the data<\/h3>\n<p>Third, let\u2019s add the data. I created a dataset for this timeline chart tutorial manually by compiling what I wanted from various news sources, two of the main ones being <a href=\"https:\/\/www.nytimes.com\/interactive\/2020\/science\/coronavirus-vaccine-tracker.html\" target=\"_blank\" rel=\"nofollow\">NYT<\/a> and <a href=\"https:\/\/www.bloomberg.com\/graphics\/covid-vaccine-tracker-global-distribution\/\" target=\"_blank\" rel=\"nofollow\">Bloomberg<\/a>. My JSON data file is <a href=\"https:\/\/gist.githubusercontent.com\/shacheeswadia\/c65106bb00db4236140b4f6052fde55a\/raw\/c6e3a1b4398d39d30dd9e61e8b5c180af28f8400\/pfizer-comparison-timeline\" target=\"_blank\" rel=\"nofollow\">here<\/a> in case you are interested.<\/p>\n<p>Loading the JSON file in AnyChart can be done with the help of the <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Modules#data_adapter\" target=\"_blank\" rel=\"nofollow\">Data Adapter<\/a> module, which I add along with all the JS scripts in the <code>&lt;head&gt;<\/code>. Next, I use the <code>loadJsonFile<\/code> method inside the <code>&lt;script&gt;<\/code> tag in the body of the HTML page to load the data file.<\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&nbsp;&nbsp;&lt;head&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;JavaScript Timeline Chart&lt;\/title&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.9.0\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.9.0\/js\/anychart-timeline.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.9.0\/js\/anychart-data-adapter.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;style type=\"text\/css\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;html,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;body,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#container {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 100%;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;height: 100%;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;margin: 0;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;padding: 0;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/style&gt;\r\n&nbsp;&nbsp;&lt;\/head&gt;\r\n&nbsp;&nbsp;&lt;body&gt;  \r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;anychart.data.loadJsonFile('{JSON data file location}',\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function (data) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Timeline chart's JS code will come here.\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/script&gt;\r\n&nbsp;&nbsp;&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<p>Now that all the prep is done, get ready to add the code which will create the interactive JS timeline chart in no time!<\/p>\n<h3>4. Write some JS code to configure the timeline chart<\/h3>\n<p>The first basic step to create any chart this way is to add a function enclosing all the code, which makes sure that the entire code inside of it will only execute once the page is ready.<\/p>\n<p>The timeline chart that I create here consists of 3 parts:<\/p>\n<ul>\n<li>the central timeline that shows the Pfizer-BioNTech vaccine development phases for the US as time intervals,<\/li>\n<li>the temporal ranges above the timeline that indicates events related to the Pfizer-BioNTech vaccine in general as milestones, and<\/li>\n<li>the markers below the timeline that represent the dates of development phases for other vaccines approved in the US as milestones.<\/li>\n<\/ul>\n<p>Creating the central timeline is very straightforward, but it could get slightly overwhelming when dealing with the points above and below the timeline. Do not worry though, as all the code is commented, and I will walk you through each of the code snippets.<\/p>\n<p>For the central part, all I need to do is initialize the timeline chart object with the inbuilt functionality and set the points to the range series.<\/p>\n<pre><code class=\"javascript\">\/\/ create a timeline chart\r\nvar chart = anychart.timeline();\r\n\r\n\/\/ create main timeline data points\r\nfor (var i = 0; i &lt; data.pfizerTimeline.length; i++) { \r\n\r\n  \/\/ create a range series\r\n  var series = chart.range([\r\n    [\r\n      data.pfizerTimeline[i].title,\r\n      data.pfizerTimeline[i].start,\r\n      data.pfizerTimeline[i].end\r\n    ]\r\n  ]);\r\n  \r\n}<\/code><\/pre>\n<p>To plot the above and below the timeline points, I initialize datasets, define the mapping for the points, and set both series with the moment series functionality.<\/p>\n<pre><code class=\"javascript\">\/\/ create a data set for the top data points\r\nvar pfizerDataSet = anychart.data.set(data.pfizerFacts);\r\n\r\n\/\/ map the top data points\r\nvar pfizerMapping = pfizerDataSet.mapAs({\r\n  x: 'date',\r\n  value: 'title'\r\n});\r\n\r\n\/\/ create the top series with moments\r\nvar pfizerMappingSeries = chart.moment(pfizerMapping);\r\n\r\n\/\/ create a data set for the bottom data points\r\nvar otherVaccinesDataset = anychart.data.set(data.otherVaccines);\r\n\r\n\/\/ map the bottom data set\r\nvar otherVaccinesDatasetMapping = otherVaccinesDataset.mapAs({\r\n  x: 'date',\r\n  value: 'title'\r\n});\r\n\r\n\/\/ create the bottom series with moments\r\nvar otherVaccinesSeries = chart.moment(otherVaccinesDatasetMapping);<\/code><\/pre>\n<p>Now I just need to set the scale of the timeline to 1 month and add a scroll bar that will allow seeing specific sections of the timeline.<\/p>\n<pre><code class=\"javascript\">\/\/ set the chart scale levels\r\nchart.scale().zoomLevels([\r\n  [\r\n    { unit: 'month', count: 1 }\r\n  ]\r\n]);\r\n\r\n\/\/ enable the chart scroller\r\nchart.scroller().enabled(true);<\/code><\/pre>\n<p>To wrap it up, I add a title to the chart, set the container defined for the chart, and draw the actual timeline.<\/p>\n<pre><code class=\"javascript\">\/\/ set the chart's title\r\nchart.title('Pfizer\/BioNTech Vaccine Timeline');\r\n\r\n\/\/ set the container id for the chart\r\nchart.container('container');\r\n\r\n\/\/ initiate the chart drawing\r\nchart.draw();<\/code><\/pre>\n<p>That\u2019s it! A fully functional, interactive timeline chart is all set up!<\/p>\n<p><iframe sandbox=\"allow-scripts allow-pointer-lock allow-same-origin\n                 allow-popups allow-modals allow-forms\" frameBorder=\"0\" class=\"anychart-embed anychart-embed-xb2m4nSc\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/xb2m4nSc\/iframe\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-xb2m4nSc{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p><strong>You\u2019re welcome to see and play with this initial version of the interactive timeline chart with the full JS\/CSS\/HTML code on <a href=\"https:\/\/codepen.io\/shacheeswadia\/pen\/BapOrKZ\" target=\"_blank\" rel=\"nofollow\">CodePen<\/a> [or on <a href=\"https:\/\/playground.anychart.com\/xb2m4nSc\/\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>].<\/strong><\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&nbsp;&nbsp;&lt;head&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;JavaScript Timeline Chart&lt;\/title&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.9.0\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.9.0\/js\/anychart-timeline.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.9.0\/js\/anychart-data-adapter.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;style type=\"text\/css\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;html,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;body,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#container {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 100%;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;height: 100%;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;margin: 0;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;padding: 0;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/style&gt;\r\n&nbsp;&nbsp;&lt;\/head&gt;\r\n&nbsp;&nbsp;&lt;body&gt;  \r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;anychart.onDocumentReady(function () {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;anychart.data.loadJsonFile(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'https:\/\/gist.githubusercontent.com\/shacheeswadia\/c65106bb00db4236140b4f6052fde55a\/raw\/9ec2af927a8bb81433f2236b41c161260aa4950d\/pfizer-comparison-timeline',   \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function (data) {\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ create a timeline chart\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var chart = anychart.timeline();\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ create main timeline data points\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (var i = 0; i &lt; data.pfizerTimeline.length; i++) {    \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ create a range series\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var series = chart.range([\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data.pfizerTimeline[i].title,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data.pfizerTimeline[i].start,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data.pfizerTimeline[i].end\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ create a data set for the top data points\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var pfizerDataSet = anychart.data.set(data.pfizerFacts);\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ map the top data points\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var pfizerMapping = pfizerDataSet.mapAs({\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x: 'date',\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value: 'title'\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ create the top series with moments\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var pfizerMappingSeries = chart.moment(pfizerMapping);\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ create a data set for the bottom data points\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var otherVaccinesDataset = anychart.data.set(data.otherVaccines);\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ map the bottom data set\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var otherVaccinesDatasetMapping = otherVaccinesDataset.mapAs({\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x: 'date',\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value: 'title'\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ create the bottom series with moments\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var otherVaccinesSeries = chart.moment(otherVaccinesDatasetMapping);\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ set the chart scale levels\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.scale().zoomLevels([\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ unit: 'month', count: 1 }\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]);\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ enable the chart scroller\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.scroller().enabled(true);\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ set the chart's title\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.title('PFizer\/BioNTech Vaccine Timeline');\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ set the container id for the chart\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.container('container');\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ initiate the chart drawing\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.draw();\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/script&gt;\r\n&nbsp;&nbsp;&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h2>Customizing the JS Timeline Chart<\/h2>\n<p>JavaScript libraries like AnyChart not only simplify the process of creating the base visualization but also provide the option for easy customizations. With a few code tweaks (or slightly more), if you want, you can make some quick and effective changes to the chart.<\/p>\n<h3>Colors and markers for the timeline<\/h3>\n<p>Simple customization that makes the chart look personalized is changing colors. Since the development phases include trials, review and approval, I used a color spectrum of red to green \u2014 traffic signal colors. I also change the marker color for the top series and use Pfizer\u2019s signature blue for it.<\/p>\n<pre><code class=\"javascript\">\/\/ create main timeline data points\r\nfor (var i = 0; i &lt; data.pfizerTimeline.length; i++) {\r\n\r\n  \/\/ create a range series\r\n  var series = chart.range([\r\n    [\r\n      data.pfizerTimeline[i].title,\r\n      data.pfizerTimeline[i].start,\r\n      data.pfizerTimeline[i].end\r\n    ]\r\n  ])\r\n  \/\/ using function and if conditions to color the timeline parts according to the phase\r\n  .fill(function(d){\r\n    \/\/ red color for the trial phase\r\n    if(d.name == \"Pfizer\/BioNTech Trial\"){\r\n      return \"#FD8060\"\r\n    }else if(d.name == \"Review\"){ \/\/ yellow color for the review phase\r\n      return \"#FEE191\"\r\n    }\r\n    return \"#B0D8A4\" \/\/ green color for the approval phase\r\n  })\r\n  .stroke(\"none\");\r\n}\r\n\r\n...\r\n\r\n\/\/ customize the markers\r\npfizerMappingSeries.normal().markers().fill(\"#007cc2\");<\/code><\/pre>\n<p>As the bottom series contains information for three separate vaccines, I create a different series for all three of them, which in turn automatically assigns a different marker for each of the series.<\/p>\n<p><strong>Check out how the variation now looks. You can find the interactive version of this JS timeline chart iteration with the complete code <a href=\"https:\/\/codepen.io\/shacheeswadia\/pen\/jOyerqY\" target=\"_blank\" rel=\"nofollow\">here<\/a> [or on <a href=\"https:\/\/playground.anychart.com\/pLU9Zn5E\/\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>].<\/strong><\/p>\n<p><iframe sandbox=\"allow-scripts allow-pointer-lock allow-same-origin\n                 allow-popups allow-modals allow-forms\" frameBorder=\"0\" class=\"anychart-embed anychart-embed-pLU9Zn5E\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/pLU9Zn5E\/iframe\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-pLU9Zn5E{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<h3>Tooltip customization<\/h3>\n<p>Additionally, I want to show some more information for each of the data points in the timeline, so I add that to the chart tooltip as an interactive feature, including some customization to the appearance.<\/p>\n<pre><code class=\"javascript\">\/\/ set the tooltip settings for the main timeline series\r\nseries\r\n  .tooltip()\r\n  .useHtml(true)\r\n  .titleFormat('{%x}') \/\/ the event title\r\n  .format(\r\n    \/\/ the description field in the data contains additonal information\r\n    data.pfizerTimeline[i].description\r\n    \/\/ using breakline (&lt;br&gt;) tag to add space, bold (&lt;b&gt;) tag to emphasize \r\n    \/\/ indicating the start and end of each timeline phase with start and end data fields\r\n    + '&lt;br\/&gt;&lt;br\/&gt;Start: &lt;b&gt;{%start}{type:date}&lt;\/b&gt;&lt;br\/&gt;End: &lt;b&gt;{%end}{type:date}&lt;\/b&gt;'\r\n  );<\/code><\/pre>\n<h3>Text markers and title<\/h3>\n<p>The timeline looks just about ready, so it\u2019s time for the finishing touches. I\u2019ll format the title and add a subtitle to make it look better. I will then add text markers for the different series above and below the central timeline so that the events are more explanatory.<\/p>\n<pre><code class=\"javascript\">\/\/ set the chart's title\r\nchart\r\n  .title()\r\n  .enabled(true)\r\n  .useHtml(true)\r\n  .text(\r\n    '&lt;span style = \"color: #007cc2; font-size:20px;\"&gt;PFizer\/BioNTech Vaccine Timeline&lt;\/span&gt;' +\r\n    '&lt;br\/&gt;&lt;span style=\"font-size: 16px;\"&gt;(Comparing with other vaccines approved in USA)&lt;\/span&gt;'\r\n  );\r\n\r\n...\r\n\r\n\/\/ create two text markers\r\nvar textMarker1 = chart.textMarker(0);\r\nvar textMarker2 = chart.textMarker(1);\r\n\r\n\/\/ set the values of the markers\r\ntextMarker1.value(data.pfizerTimeline[0].start);\r\ntextMarker2.value(data.pfizerTimeline[0].start);\r\n\r\n\/\/ set the text of the markers\r\ntextMarker1.useHtml(true);\r\ntextMarker1.text(\r\n  \"Facts about Pfizer\");\r\ntextMarker2.text(\r\n  \"Facts about other vaccines in USA\");\r\n\r\n\/\/ configure the position of the markers\r\ntextMarker1.anchor(\"leftcenter\");\r\ntextMarker2.anchor(\"leftcenter\");\r\ntextMarker1.rotation(0);\r\ntextMarker1.offsetY(160);\r\ntextMarker2.rotation(0);\r\ntextMarker2.offsetY(300);\r\n\r\n\/\/ configure the font of the markers\r\ntextMarker1.fontColor(\"#007cc2\");\r\ntextMarker1.fontWeight(600);\r\ntextMarker2.fontWeight(600);<\/code><\/pre>\n<p><iframe sandbox=\"allow-scripts allow-pointer-lock allow-same-origin\n                 allow-popups allow-modals allow-forms\" frameBorder=\"0\" class=\"anychart-embed anychart-embed-3IQOpAhp\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/3IQOpAhp\/iframe\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-3IQOpAhp{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p><strong>That\u2019s it! You can find the interactive version of this JavaScript timeline chart on <a href=\"https:\/\/codepen.io\/shacheeswadia\/pen\/WNRajYo\" target=\"_blank\" rel=\"nofollow\">CodePen<\/a> or <a href=\"https:\/\/gist.github.com\/shacheeswadia\/811b2817071c194249c350c701c2eb6f\" target=\"_blank\" rel=\"nofollow\">GitHub<\/a> [or on <a href=\"https:\/\/playground.anychart.com\/3IQOpAhp\/\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>].<\/strong><\/p>\n<p>In this step-by-step tutorial, I have shown just how easy it is to get a JS timeline chart not just up and running, but also how to bring it to life. There are a lot of customization options for timelines, and you can continue your exploration with the documentation <a href=\"https:\/\/docs.anychart.com\/Basic_Charts\/Timeline_Chart\" target=\"_blank\" rel=\"nofollow\">here<\/a>. Creating versatile and interactive JavaScript charts is easy with the aid of a good JS library. You can check out various <a href=\"https:\/\/www.anychart.com\/products\/anychart\/gallery\/\">other chart options<\/a> or try your hand at <a href=\"https:\/\/en.wikipedia.org\/wiki\/Comparison_of_JavaScript_charting_libraries\" target=\"_blank\" rel=\"nofollow\">other JavaScript charting libraries<\/a> for your data visualization needs.<\/p>\n<p>Please feel free to ask me any questions or let me know how your own JS timeline turned out. Stay safe and get your shots in time to fight this pandemic!<\/p>\n<hr \/>\n<p><strong><em>Published with permission of Shachee Swadia. Originally appeared on <a href=\"https:\/\/medium.com\/nightingale\/creating-interactive-timelines-with-javascript-b70b7ded3d13\" target=\"_blank\" rel=\"nofollow\">Nightingale<\/a>, the journal of the Data Visualization Society, under the title &#8220;Creating Interactive Timelines with JavaScript: A step-by-step guide to visualizing the development of COVID-19 vaccines&#8221; on May 18, 2021.<\/em><\/strong><\/p>\n<hr \/>\n<p><strong><em>Learn more about timeline charts on <a href=\"https:\/\/www.anychart.com\/chartopedia\/chart-type\/timeline-chart\/\">Chartopedia<\/a>. Check out other <a href=\"https:\/\/www.anychart.com\/blog\/category\/javascript-chart-tutorials\/\">JavaScript charting tutorials<\/a>.<\/em><\/strong><\/p>\n<hr \/>\n<p><strong><em>If you want to create a cool guest post for our blog, feel free to\u00a0<a href=\"https:\/\/www.anychart.com\/support\/\">contact us<\/a>.<\/em><\/strong><\/p>\n<p><!-- SyntaxHighlighter --><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/default.min.css\"><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/atom-one-light.min.css\"><script src=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/highlight.min.js\"><\/script><script>hljs.initHighlightingOnLoad();<\/script><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>I think all of us have come across timelines somewhere or the other; as a means of conveying chronological information, the classic timeline is unmatched, both in the depth of information conveyed and the \u201ccool\u201d factor, when done with a deft creative touch. So, with that said, would you like to learn how to build [&hellip;]<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,263,22,23,13,279,4],"tags":[843,53,260,561,265,2507,310,2019,284,127,258,44,1766,1823,1773,1771,1772,1819,1800,1801,1803,1804,1925,2139,1769,1975,1936,1954,1824,1974,1935,1948,282,471,266,620,1292,880,806,1759,509,1098,294,257,2171,54,1760,256,1111,350,2510,744,844,165,2263,2013,2014,32,55,144,167,146,152,151,247,36,907,141,249,81,57,1238,142,96,134,2508,58,65,56,101,2511,1937,2335,1938,2506,543,2509,2512,1768,1817,1601,2505,2265,2264,131,326,960,959,30,172,309,2250,1947,293,745,899,1939,1767],"class_list":["post-12943","post","type-post","status-publish","format-standard","hentry","category-anychart-charting-component","category-big-data","category-charts-and-art","category-html5","category-javascript","category-javascript-chart-tutorials","category-tips-and-tricks","tag-advanced-data-visualization","tag-anychart","tag-best-data-visualization-examples","tag-best-data-visualizations","tag-big-data","tag-biontech","tag-bloomberg","tag-bloomberg-news","tag-chart-examples","tag-chart-types","tag-charts","tag-charts-and-art","tag-coronavirus","tag-coronavirus-cases","tag-coronavirus-charts","tag-coronavirus-data","tag-coronavirus-data-visualization","tag-coronavirus-outbreak","tag-coronavirus-pandemic","tag-coronavirus-pandemic-charts","tag-coronavirus-pandemic-data","tag-coronavirus-pandemic-data-visualization","tag-covid","tag-covid-crisis","tag-covid-19","tag-covid-19-analytics","tag-covid-19-cases","tag-covid-19-charts","tag-covid-19-deaths","tag-covid-19-outbreak","tag-covid-19-statistics","tag-covid-19-vaccine","tag-data","tag-data-analysis","tag-data-analytics","tag-data-analytics-examples","tag-data-chart","tag-data-charting","tag-data-charts","tag-data-design","tag-data-graphics","tag-data-is-beautiful","tag-data-science","tag-data-stories","tag-data-vis","tag-data-visualization","tag-data-visualization-design","tag-data-visualization-examples","tag-data-visualization-practice","tag-data-visualization-projects","tag-data-visualization-society","tag-data-visualization-techniques","tag-data-visualization-tutorial","tag-data-visualizations","tag-drug-development","tag-html","tag-html-charts","tag-html5","tag-html5-charts","tag-infographics","tag-interactive-charts","tag-interactive-data-visualization","tag-interactive-infographic","tag-interactive-visualizations","tag-interactivity","tag-javascript","tag-javascript-chart-tutorial","tag-javascript-charting","tag-javascript-charting-api","tag-javascript-charting-library","tag-javascript-charts","tag-javascript-graph","tag-javascript-graphics","tag-javascript-graphics-library","tag-javascript-technologies","tag-johnson-johnson","tag-js-chart","tag-js-charting","tag-js-charts","tag-js-graphics","tag-js-timeline","tag-json","tag-json-charts","tag-json-data-visualization","tag-moderna","tag-new-york-times","tag-nightingale","tag-novavax","tag-novel-coronavirus","tag-pandemic","tag-pandemics","tag-pfizer","tag-pharma","tag-pharmaceutical","tag-recap-of-the-week","tag-the-new-york-times","tag-timeline","tag-timeline-chart","tag-tips-and-tricks","tag-tutorial","tag-united-states","tag-vaccination","tag-vaccine","tag-visualization","tag-visualization-techniques","tag-visualizations","tag-visualizing-json-data","tag-wuhan-coronavirus","wpautop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Create Interactive Timeline Chart with JavaScript<\/title>\n<meta name=\"description\" content=\"A step-by-step guide to making an interactive JavaScript timeline chart. Based on the practical example of visualizing the development of COVID-19 vaccines.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create Interactive Timeline Chart with JavaScript\" \/>\n<meta property=\"og:description\" content=\"A step-by-step guide to making an interactive JavaScript timeline chart. Visualizing the development of COVID-19 vaccines.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"AnyChart News\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/AnyCharts\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-17T16:34:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-13T11:06:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js-social.png\" \/>\n<meta name=\"author\" content=\"Shachee Swadia\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to Create Interactive Timeline Chart with JavaScript\" \/>\n<meta name=\"twitter:description\" content=\"A step-by-step guide to making an interactive JavaScript timeline chart. Visualizing the development of COVID-19 vaccines.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js-social.png\" \/>\n<meta name=\"twitter:creator\" content=\"@AnyChart\" \/>\n<meta name=\"twitter:site\" content=\"@AnyChart\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shachee Swadia\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"18 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/\"},\"author\":{\"name\":\"Shachee Swadia\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\"},\"headline\":\"How to Create Interactive Timeline Chart with JavaScript\",\"datePublished\":\"2021-06-17T16:34:58+00:00\",\"dateModified\":\"2022-08-13T11:06:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/\"},\"wordCount\":1498,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js.png\",\"keywords\":[\"advanced data visualization\",\"AnyChart\",\"best data visualization examples\",\"best data visualizations\",\"big data\",\"BioNTech\",\"bloomberg\",\"Bloomberg News\",\"chart examples\",\"chart types\",\"charts\",\"Charts and Art\",\"coronavirus\",\"coronavirus cases\",\"coronavirus charts\",\"coronavirus data\",\"coronavirus data visualization\",\"coronavirus outbreak\",\"coronavirus pandemic\",\"coronavirus pandemic charts\",\"coronavirus pandemic data\",\"coronavirus pandemic data visualization\",\"covid\",\"COVID crisis\",\"COVID-19\",\"COVID-19 analytics\",\"COVID-19 cases\",\"COVID-19 charts\",\"COVID-19 deaths\",\"COVID-19 outbreak\",\"COVID-19 statistics\",\"COVID-19 vaccine\",\"data\",\"data analysis\",\"data analytics\",\"data analytics examples\",\"data chart\",\"data charting\",\"data charts\",\"data design\",\"data graphics\",\"data is beautiful\",\"data science\",\"data stories\",\"data vis\",\"Data Visualization\",\"data visualization design\",\"data visualization examples\",\"data visualization practice\",\"data visualization projects\",\"Data Visualization Society\",\"data visualization techniques\",\"data visualization tutorial\",\"data visualizations\",\"drug development\",\"HTML\",\"HTML charts\",\"HTML5\",\"html5 charts\",\"infographics\",\"interactive charts\",\"interactive data visualization\",\"interactive infographic\",\"interactive visualizations\",\"interactivity\",\"JavaScript\",\"javascript chart tutorial\",\"javascript charting\",\"javascript charting api\",\"JavaScript charting library\",\"javascript charts\",\"javascript graph\",\"javascript graphics\",\"JavaScript graphics library\",\"javascript technologies\",\"Johnson &amp; Johnson\",\"js chart\",\"js charting\",\"js charts\",\"JS graphics\",\"js timeline\",\"JSON\",\"JSON charts\",\"JSON data visualization\",\"Moderna\",\"New York Times\",\"Nightingale\",\"Novavax\",\"novel coronavirus\",\"pandemic\",\"pandemics\",\"Pfizer\",\"pharma\",\"pharmaceutical\",\"recap of the week\",\"the new york times\",\"timeline\",\"timeline chart\",\"Tips and tricks\",\"tutorial\",\"united states\",\"vaccination\",\"vaccine\",\"visualization\",\"visualization techniques\",\"visualizations\",\"visualizing JSON data\",\"Wuhan coronavirus\"],\"articleSection\":[\"AnyChart Charting Component\",\"Big Data\",\"Charts and Art\",\"HTML5\",\"JavaScript\",\"JavaScript Chart Tutorials\",\"Tips and Tricks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/\",\"url\":\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/\",\"name\":\"How to Create Interactive Timeline Chart with JavaScript\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js.png\",\"datePublished\":\"2021-06-17T16:34:58+00:00\",\"dateModified\":\"2022-08-13T11:06:07+00:00\",\"author\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\"},\"description\":\"A step-by-step guide to making an interactive JavaScript timeline chart. Based on the practical example of visualizing the development of COVID-19 vaccines.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#primaryimage\",\"url\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js.png\",\"contentUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js.png\",\"width\":1500,\"height\":800},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.anychart.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create Interactive Timeline Chart with JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\",\"url\":\"https:\/\/www.anychart.com\/blog\/\",\"name\":\"AnyChart News\",\"description\":\"AnyChart JS Charts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.anychart.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\",\"name\":\"Shachee Swadia\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g\",\"caption\":\"Shachee Swadia\"},\"url\":\"https:\/\/www.anychart.com\/blog\/author\/shachee-swadia\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create Interactive Timeline Chart with JavaScript","description":"A step-by-step guide to making an interactive JavaScript timeline chart. Based on the practical example of visualizing the development of COVID-19 vaccines.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/","og_locale":"en_US","og_type":"article","og_title":"How to Create Interactive Timeline Chart with JavaScript","og_description":"A step-by-step guide to making an interactive JavaScript timeline chart. Visualizing the development of COVID-19 vaccines.","og_url":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/","og_site_name":"AnyChart News","article_publisher":"https:\/\/www.facebook.com\/AnyCharts","article_published_time":"2021-06-17T16:34:58+00:00","article_modified_time":"2022-08-13T11:06:07+00:00","og_image":[{"url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js-social.png","type":"","width":"","height":""}],"author":"Shachee Swadia","twitter_card":"summary_large_image","twitter_title":"How to Create Interactive Timeline Chart with JavaScript","twitter_description":"A step-by-step guide to making an interactive JavaScript timeline chart. Visualizing the development of COVID-19 vaccines.","twitter_image":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js-social.png","twitter_creator":"@AnyChart","twitter_site":"@AnyChart","twitter_misc":{"Written by":"Shachee Swadia","Est. reading time":"18 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#article","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/"},"author":{"name":"Shachee Swadia","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51"},"headline":"How to Create Interactive Timeline Chart with JavaScript","datePublished":"2021-06-17T16:34:58+00:00","dateModified":"2022-08-13T11:06:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/"},"wordCount":1498,"commentCount":0,"image":{"@id":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js.png","keywords":["advanced data visualization","AnyChart","best data visualization examples","best data visualizations","big data","BioNTech","bloomberg","Bloomberg News","chart examples","chart types","charts","Charts and Art","coronavirus","coronavirus cases","coronavirus charts","coronavirus data","coronavirus data visualization","coronavirus outbreak","coronavirus pandemic","coronavirus pandemic charts","coronavirus pandemic data","coronavirus pandemic data visualization","covid","COVID crisis","COVID-19","COVID-19 analytics","COVID-19 cases","COVID-19 charts","COVID-19 deaths","COVID-19 outbreak","COVID-19 statistics","COVID-19 vaccine","data","data analysis","data analytics","data analytics examples","data chart","data charting","data charts","data design","data graphics","data is beautiful","data science","data stories","data vis","Data Visualization","data visualization design","data visualization examples","data visualization practice","data visualization projects","Data Visualization Society","data visualization techniques","data visualization tutorial","data visualizations","drug development","HTML","HTML charts","HTML5","html5 charts","infographics","interactive charts","interactive data visualization","interactive infographic","interactive visualizations","interactivity","JavaScript","javascript chart tutorial","javascript charting","javascript charting api","JavaScript charting library","javascript charts","javascript graph","javascript graphics","JavaScript graphics library","javascript technologies","Johnson &amp; Johnson","js chart","js charting","js charts","JS graphics","js timeline","JSON","JSON charts","JSON data visualization","Moderna","New York Times","Nightingale","Novavax","novel coronavirus","pandemic","pandemics","Pfizer","pharma","pharmaceutical","recap of the week","the new york times","timeline","timeline chart","Tips and tricks","tutorial","united states","vaccination","vaccine","visualization","visualization techniques","visualizations","visualizing JSON data","Wuhan coronavirus"],"articleSection":["AnyChart Charting Component","Big Data","Charts and Art","HTML5","JavaScript","JavaScript Chart Tutorials","Tips and Tricks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/","url":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/","name":"How to Create Interactive Timeline Chart with JavaScript","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#primaryimage"},"image":{"@id":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js.png","datePublished":"2021-06-17T16:34:58+00:00","dateModified":"2022-08-13T11:06:07+00:00","author":{"@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51"},"description":"A step-by-step guide to making an interactive JavaScript timeline chart. Based on the practical example of visualizing the development of COVID-19 vaccines.","breadcrumb":{"@id":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#primaryimage","url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js.png","contentUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/06\/vaccine-timeline-chart-js.png","width":1500,"height":800},{"@type":"BreadcrumbList","@id":"https:\/\/www.anychart.com\/blog\/2021\/06\/17\/timeline-chart-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.anychart.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Create Interactive Timeline Chart with JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/www.anychart.com\/blog\/#website","url":"https:\/\/www.anychart.com\/blog\/","name":"AnyChart News","description":"AnyChart JS Charts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.anychart.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51","name":"Shachee Swadia","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g","caption":"Shachee Swadia"},"url":"https:\/\/www.anychart.com\/blog\/author\/shachee-swadia\/"}]}},"_links":{"self":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/12943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/comments?post=12943"}],"version-history":[{"count":20,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/12943\/revisions"}],"predecessor-version":[{"id":15510,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/12943\/revisions\/15510"}],"wp:attachment":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/media?parent=12943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/categories?post=12943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/tags?post=12943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}