{"id":15335,"date":"2022-08-04T13:12:28","date_gmt":"2022-08-04T13:12:28","guid":{"rendered":"https:\/\/www.anychart.com\/blog\/?p=15335"},"modified":"2022-08-13T11:13:43","modified_gmt":"2022-08-13T11:13:43","slug":"timeline-chart","status":"publish","type":"post","link":"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/","title":{"rendered":"How to Make Timeline Chart (in JavaScript)"},"content":{"rendered":"<p><a href=\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/\"><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.png\" alt=\"Timeline Chart Guide\" width=\"100%\" class=\"alignnone size-full wp-image-15347\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.png 1400w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline-300x158.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline-768x403.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline-1024x538.png 1024w\" sizes=\"(max-width: 1400px) 100vw, 1400px\" \/><\/a>A timeline chart is an excellent way to represent important events and periods in chronological order. Now, let me teach you how to easily create an elegant interactive visualization like that using JavaScript!<\/p>\n<p>To make this tutorial both helpful and entertaining, I decided to take real data. Join me as I visualize the life of Elon Musk in a JS timeline chart step by step, focusing on the most important events in his career as an entrepreneur and investor.<\/p>\n<p><!--more Read the JS charting tutorial \u00bb--><\/p>\n<h2>Timeline Chart Preview<\/h2>\n<p>Take a look at the beautiful JavaScript timeline chart that I will be creating along the tutorial, and keep reading to find out how!<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline-chart.png\" alt=\"A timeline chart built in JavaScript HTML5\" width=\"100%\" class=\"alignnone size-full wp-image-15345\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline-chart.png 1169w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline-chart-300x164.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline-chart-768x420.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline-chart-1024x561.png 1024w\" sizes=\"(max-width: 1169px) 100vw, 1169px\" \/><\/p>\n<h2>4 Steps to Build Basic JS Timeline Chart<\/h2>\n<p>Creating an interactive JavaScript-based timeline chart, even a basic one, may seem to be a daunting task. But right now, you\u2019ll see how to do it with ease.<\/p>\n<p>In this tutorial, the process of building a JS timeline chart is split into four steps: creating a web page, adding scripts, setting data, and configuring the visualization.<\/p>\n<p>A stunning basic timeline chart will be arranged in just a few lines of easy-to-comprehend code. Then I will show you how it can be customized (also without much complexity). Follow me!<\/p>\n<h3>1. Creating a web page<\/h3>\n<p>First, I make a simple web page with an HTML block element. That\u2019s where my JavaScript-based timeline chart will appear.<\/p>\n<p>I provide this element with an ID and set its height and weight as 100% so that the visualization takes the entire page.<\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n\u00a0\u00a0&lt;head&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;title&gt;JavaScript Timeline Chart&lt;\/title&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;style type=\"text\/css\"&gt;      \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0html, body, #container { \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0width: 100%; height: 100%; margin: 0; padding: 0; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} \r\n\u00a0\u00a0\u00a0\u00a0&lt;\/style&gt;\r\n\u00a0\u00a0&lt;\/head&gt;\r\n\u00a0\u00a0&lt;body&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n\u00a0\u00a0&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h3>2. Adding scripts<\/h3>\n<p>Second, I add all scripts I am going to build a timeline chart with to the <code>&lt;head&gt;<\/code> section of the HTML page.<\/p>\n<p>In this tutorial, I will be using <a href=\"https:\/\/www.anychart.com\/\">AnyChart JS Charts<\/a>, a robust JavaScript charting library with vast out-of-the-box capabilities that make it easy to quickly visualize data in <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Supported_Charts_Types\" target=\"_blank\" rel=\"nofollow\">dozens of chart types<\/a> including timelines.<\/p>\n<p>Here, I need the Core and Timeline <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Modules\" target=\"_blank\" rel=\"nofollow\">modules<\/a>.<\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n\u00a0\u00a0&lt;head&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;title&gt;JavaScript Timeline Chart&lt;\/title&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-timeline.min.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;style type=\"text\/css\"&gt;      \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0html, body, #container { \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0width: 100%; height: 100%; margin: 0; padding: 0; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} \r\n\u00a0\u00a0\u00a0\u00a0&lt;\/style&gt;\r\n\u00a0\u00a0&lt;\/head&gt;\r\n\u00a0\u00a0&lt;body&gt;  \r\n\u00a0\u00a0\u00a0\u00a0&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ All the JS code for the timeline chart will go here.\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/script&gt;\r\n\u00a0\u00a0&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h3>3. Setting data<\/h3>\n<p>Third, I set the data I want to visualize in a JS timeline chart.<\/p>\n<p>There will be two series of different types, range and moment. Each will be added through a separate function.<\/p>\n<p>The range series is for periods. Each data point has a name along with start and end dates.<\/p>\n<pre><code class=\"javascript\">function rangeData() {\r\n  return [\r\n    {\r\n      name: \"Childhood and Education\",\r\n      start: \"1971\/06\/28\",\r\n      end: \"1995\/09\/01\"\r\n    },\r\n    {\r\n      name: \"Entrepreneur Journey\",\r\n      start: \"1983\/06\/28\",\r\n      end: \"2002\/03\/13\"\r\n    },\r\n    {\r\n      name: \"Making of Tycoon\",\r\n      start: \"2002\/03\/14\",\r\n      end: \"2010\/06\/28\"\r\n    },\r\n    {\r\n      name: \"Rise of Tycoon\",\r\n      start: \"2010\/06\/29\",\r\n      end: \"2030\/01\/01\"\r\n    }\r\n  ];\r\n}<\/code><\/pre>\n<p>The moment series is for individual events. Each data point has a date and text.<\/p>\n<pre><code class=\"javascript\">function momentData() {\r\n  return [\r\n    [\"1971\/06\/28\", \"Elon Musk was born in South Africa\"],\r\n    [\"1981\/06\/28\", \"Began to learn computer programming on his own\"],\r\n    [\"1983\/06\/28\", \"Sold the code of his game Blastar for $500\"],\r\n    [\"1990\/09\/01\", \"Entered Queen's University in Kingston, Ontario\"],\r\n    [\"1992\/09\/01\", \"Transferred to the University of Pennsylvania\"],\r\n    [\"1995\/06\/01\", \"Received bachelor's degrees in physics and economics\"],\r\n    [\"1995\/09\/01\", \"Started a Ph.D. at Stanford (dropped out in 2 days\"],\r\n    [\"1995\/11\/06\", \"Founded Zip2 with his brother\"],\r\n    [\"1999\/02\/01\", \"Sold Zip2 to Compaq for $307M\"],\r\n    [\"1999\/03\/01\", \"Co-founded X.com\"],\r\n    [\"2000\/03\/01\", \"Merged X.com with Confinity to form PayPal\"],\r\n    [\"2001\/01\/01\", \"Started conceptualizing Mars Oasis\"],\r\n    [\"2002\/03\/14\", \"Founded SpaceX &amp; became its CEO\"],\r\n    [\"2002\/10\/03\", \"Received $175.8M from PayPal's sale to eBay for $1.5B\"],\r\n    [\"2004\/02\/01\", \"Invested $6.5M in Tesla and joined its board as chairman\"],\r\n    [\"2006\/01\/01\", \"SpaceX started to get NASA contracts\"],\r\n    [\"2008\/10\/01\", \"Became CEO at Tesla\"],\r\n    [\"2010\/06\/29\", \"Tesla's first IPO\"],\r\n    [\"2015\/12\/11\", \"Co-founded OpenAI\"],\r\n    [\"2016\/07\/01\", \"Co-founded Neuralink\"],\r\n    [\"2018\/02\/21\", \"Resigned his board seat at OpenAI\"],\r\n    [\"2021\/11\/06\", \"Started selling his Tesla stock (10% for $16.4B by year end)\"],\r\n    [\"2022\/04\/13\", \"Made an offer to buy Twitter\"],\r\n    [\"2022\/07\/08\", \"Withdrew his $44B bid to buy Twitter\"]\r\n  ];\r\n}<\/code><\/pre>\n<p>Alright! We\u2019ve got a page, scripts, and data ready. Now, it\u2019s time to add some JavaScript charting code to complete the intended interactive timeline chart visualization!<\/p>\n<h3>4. Configuring the visualization<\/h3>\n<p>To start with, we add the data from the previous step. Then we use a function to ensure that our subsequent code configuring the timeline chart is executed when the web page is already loaded.<\/p>\n<pre><code class=\"html\">&lt;script&gt;\r\n \r\n  \/\/ set the range series data\r\n  function rangeData() {\r\n    return [\r\n      {\r\n        name: \"Childhood and Education\",\r\n        start: \"1971\/06\/28\",\r\n        end: \"1995\/09\/01\"\r\n      },\r\n      {\r\n        name: \"Entrepreneur Journey\",\r\n        start: \"1983\/06\/28\",\r\n        end: \"2002\/03\/13\"\r\n      },\r\n      {\r\n        name: \"Making of Tycoon\",\r\n        start: \"2002\/03\/14\",\r\n        end: \"2010\/06\/28\"\r\n      },\r\n      {\r\n        name: \"Rise of Tycoon\",\r\n        start: \"2010\/06\/29\",\r\n        end: \"2030\/01\/01\"\r\n      }\r\n    ];\r\n  }\r\n \r\n  \/\/ set the moment series data\r\n  function momentData() {\r\n    return [\r\n      [\"1971\/06\/28\", \"Elon Musk was born in South Africa\"],\r\n      [\"1981\/06\/28\", \"Began to learn computer programming on his own\"],\r\n      [\"1983\/06\/28\", \"Sold the code of his game Blastar for $500\"],\r\n      [\"1990\/09\/01\", \"Entered Queen's University in Kingston, Ontario\"],\r\n      [\"1992\/09\/01\", \"Transferred to the University of Pennsylvania\"],\r\n      [\"1995\/06\/01\", \"Received bachelor's degrees in physics and economics\"],\r\n      [\"1995\/09\/01\", \"Started a Ph.D. at Stanford (dropped out in 2 days\"],\r\n      [\"1995\/11\/06\", \"Founded Zip2 with his brother\"],\r\n      [\"1999\/02\/01\", \"Sold Zip2 to Compaq for $307M\"],\r\n      [\"1999\/03\/01\", \"Co-founded X.com\"],\r\n      [\"2000\/03\/01\", \"Merged X.com with Confinity to form PayPal\"],\r\n      [\"2001\/01\/01\", \"Started conceptualizing Mars Oasis\"],\r\n      [\"2002\/03\/14\", \"Founded SpaceX &amp; became its CEO\"],\r\n      [\"2002\/10\/03\", \"Received $175.8M from PayPal's sale to eBay for $1.5B\"],\r\n      [\"2004\/02\/01\", \"Invested $6.5M in Tesla and joined its board as chairman\"],\r\n      [\"2006\/01\/01\", \"SpaceX started to get NASA contracts\"],\r\n      [\"2008\/10\/01\", \"Became CEO at Tesla\"],\r\n      [\"2010\/06\/29\", \"Tesla's first IPO\"],\r\n      [\"2015\/12\/11\", \"Co-founded OpenAI\"],\r\n      [\"2016\/07\/01\", \"Co-founded Neuralink\"],\r\n      [\"2018\/02\/21\", \"Resigned his board seat at OpenAI\"],\r\n      [\"2021\/11\/06\", \"Started selling his Tesla stock (10% for $16.4B by year end)\"],\r\n      [\"2022\/04\/13\", \"Made an offer to buy Twitter\"],\r\n      [\"2022\/07\/08\", \"Withdrew his $44B bid to buy Twitter\"]\r\n    ];\r\n  }\r\n \r\n  anychart.onDocumentReady(function() {\r\n    \/\/ The (following) timeline charting code lands here.\r\n  });\r\n \r\n&lt;\/script&gt;<\/code><\/pre>\n<p>Then, within the <code>anychart.onDocumentReady()<\/code> function, I create a timeline chart instance using the <code>timeline()<\/code> function, set both series, and make the range series labels display the <code>name<\/code> attribute.<\/p>\n<pre><code class=\"javascript\">\/\/ create a timeline chart\r\nlet chart = anychart.timeline();\r\n\r\n\/\/ create a range series\r\nlet rangeSeries = chart.range(rangeData());\r\n\r\n\/\/ create a moment series\r\nlet momentSeries = chart.moment(momentData());\r\n  \r\n\/\/ configure the range series label settings\r\nrangeSeries.labels().format(\"{%name}\");<\/code><\/pre>\n<p>Also right there, I add a few more lines to entitle the timeline chart, define a container for it, and finally, command to draw the resulting graphic.<\/p>\n<pre><code class=\"javascript\">\/\/ set the chart title\r\nchart.title(\"Timeline of Elon Musk\");\r\n\r\n\/\/ set the chart container id\r\nchart.container(\"container\");\r\n\r\n\/\/ draw the chart\r\nchart.draw();<\/code><\/pre>\n<h2>Result: Basic JS Timeline Chart<\/h2>\n<p>There you go! A cool interactive JavaScript timeline chart visualization is ready. And it has been far from difficult to build one, hasn\u2019t it?<\/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-PN5uw6p2\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/PN5uw6p2\/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-PN5uw6p2{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>Here\u2019s the complete code for this timeline chart. It is also available on <a href=\"https:\/\/playground.anychart.com\/PN5uw6p2\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>.<\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n\u00a0\u00a0&lt;head&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;title&gt;JavaScript Timeline Chart&lt;\/title&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-timeline.min.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;style type=\"text\/css\"&gt;      \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0html, body, #container { \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0width: 100%; height: 100%; margin: 0; padding: 0; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} \r\n\u00a0\u00a0\u00a0\u00a0&lt;\/style&gt;\r\n\u00a0\u00a0&lt;\/head&gt;\r\n\u00a0\u00a0&lt;body&gt;  \r\n\u00a0\u00a0\u00a0\u00a0&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0  \/\/ set the range series data\r\n\u00a0\u00a0\u00a0\u00a0  function rangeData() {\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0return [\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0{\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0name: \"Childhood and Education\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0start: \"1971\/06\/28\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0end: \"1995\/09\/01\"\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0},\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0name: \"Entrepreneur Journey\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0start: \"1983\/06\/28\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0end: \"2002\/03\/13\"\r\n\u00a0\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0},\r\n\u00a0\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0{\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0name: \"Making of Tycoon\",\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0start: \"2002\/03\/14\",\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0end: \"2010\/06\/28\"\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0},\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0{\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0name: \"Rise of Tycoon\",\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0start: \"2010\/06\/29\",\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0end: \"2030\/01\/01\"\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0}\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0];\r\n\u00a0\u00a0\u00a0\u00a0  }\r\n\r\n\u00a0\u00a0\u00a0\u00a0  \/\/ set the moment series data\r\n\u00a0\u00a0\u00a0\u00a0  function momentData() {\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0return [\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"1971\/06\/28\", \"Elon Musk was born in South Africa\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"1981\/06\/28\", \"Began to learn computer programming on his own\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"1983\/06\/28\", \"Sold the code of his game Blastar for $500\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"1990\/09\/01\", \"Entered Queen's University in Kingston, Ontario\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"1992\/09\/01\", \"Transferred to the University of Pennsylvania\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"1995\/06\/01\", \"Received bachelor's degrees in physics and economics\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"1995\/09\/01\", \"Started a Ph.D. at Stanford (dropped out in 2 days\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"1995\/11\/06\", \"Founded Zip2 with his brother\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"1999\/02\/01\", \"Sold Zip2 to Compaq for $307M\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"1999\/03\/01\", \"Co-founded X.com\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2000\/03\/01\", \"Merged X.com with Confinity to form PayPal\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2001\/01\/01\", \"Started conceptualizing Mars Oasis\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2002\/03\/14\", \"Founded SpaceX &amp; became its CEO\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2002\/10\/03\", \"Received $175.8M from PayPal's sale to eBay for $1.5B\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2004\/02\/01\", \"Invested $6.5M in Tesla and joined its board as chairman\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2006\/01\/01\", \"SpaceX started to get NASA contracts\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2008\/10\/01\", \"Became CEO at Tesla\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2010\/06\/29\", \"Tesla's first IPO\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2015\/12\/11\", \"Co-founded OpenAI\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2016\/07\/01\", \"Co-founded Neuralink\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2018\/02\/21\", \"Resigned his board seat at OpenAI\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2021\/11\/06\", \"Started selling his Tesla stock (10% for $16.4B by year end)\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2022\/04\/13\", \"Made an offer to buy Twitter\"],\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\u00a0\u00a0[\"2022\/07\/08\", \"Withdrew his $44B bid to buy Twitter\"]\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0];\r\n\u00a0\u00a0\u00a0\u00a0  }\r\n\r\n\u00a0\u00a0\u00a0\u00a0  anychart.onDocumentReady(function () {\r\n  \r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\/\/ create a timeline chart\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0let chart = anychart.timeline();\r\n\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\/\/ create a range series\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0let rangeSeries = chart.range(rangeData());\r\n\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\/\/ create a moment series\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0let momentSeries = chart.moment(momentData());\r\n\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\/\/ configure the range series label settings\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0rangeSeries.labels().format(\"{%name}\");\r\n\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\/\/ set the chart title\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0chart.title(\"Timeline of Elon Musk\");\r\n\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\/\/ set the chart container id\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0chart.container(\"container\");\r\n\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0\/\/ draw the chart\r\n\u00a0\u00a0\u00a0\u00a0  \u00a0\u00a0chart.draw();\r\n\r\n\u00a0\u00a0\u00a0\u00a0  });\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/script&gt;\r\n\u00a0\u00a0&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h2>Creating Custom JS Timeline Chart<\/h2>\n<p>The timeline looks engrossing as is. But there is always room for improvement! I will show you how some parts of such a JavaScript timeline chart can be nicely customized, again without much hassle.<\/p>\n<h3>1. Timeline chart colors<\/h3>\n<p>An easy and effective change when personalizing a chart is to modify colors.<\/p>\n<p>First, I add the attributes <code>fill<\/code> and <code>stroke<\/code> to the range series data, and the timeline chart will automatically apply the corresponding values from there:<\/p>\n<pre><code class=\"javascript\">function rangeData() {\r\n  return [\r\n    {\r\n      name: \"Childhood and Education\",\r\n      start: \"1971\/06\/28\",\r\n      end: \"1995\/09\/01\",\r\n      fill: \"#00a8e0 0.5\",\r\n      stroke: \"#00a8e0\"\r\n    },\r\n    {\r\n      name: \"Entrepreneur Journey\",\r\n      start: \"1983\/06\/28\",\r\n      end: \"2002\/03\/13\",\r\n      fill: \"#1c4598 0.5\",\r\n      stroke: \"#1c4598\"\r\n    },\r\n    {\r\n      name: \"Making of Tycoon\",\r\n      start: \"2002\/03\/14\",\r\n      end: \"2010\/06\/28\",\r\n      fill: \"#a05e9c 0.6\",\r\n      stroke: \"#a05e9c\"\r\n    },\r\n    {\r\n      name: \"Rise of Tycoon\",\r\n      start: \"2010\/06\/29\",\r\n      end: \"2030\/01\/01\",\r\n      fill: \"#6e4c82 0.65\",\r\n      stroke: \"#6e4c82\"\r\n    }\r\n  ];\r\n}<\/code><\/pre>\n<p>Second, I change the color of the moment series markers the following way:<\/p>\n<pre><code class=\"javascript\">momentSeries.normal().markers().fill(\"#ffdd0e\");\r\nmomentSeries.normal().markers().stroke(\"#e9ae0b\");<\/code><\/pre>\n<h3>2. Range series labels and height<\/h3>\n<p>Next, I want to provide the content of the range series labels with the start and end years of the corresponding periods. It\u2019s also easy to format the labels using HTML. Check it out.<\/p>\n<pre><code class=\"javascript\">rangeSeries\r\n  .labels()\r\n  .useHtml(true)\r\n  .fontColor(\"#fff\")\r\n  .format(\r\n    '{%name}&lt;br&gt;&lt;span style=\"font-size: 85%\"&gt;{%start}{dateTimeFormat:YYYY}\u2013{%end}{dateTimeFormat:YYYY}&lt;\/span&gt;'\r\n  );<\/code><\/pre>\n<p>Let me also increase the height of the range series so the newly added information could neatly fit in. This is done in just one line of code.<\/p>\n<pre><code class=\"javascript\">rangeSeries.height(50);<\/code><\/pre>\n<h3>3. Timeline chart title<\/h3>\n<p>To give more information about what the timeline shows, I customize the chart title using HTML.<\/p>\n<pre><code class=\"javascript\">chart\r\n  .title()\r\n  .enabled(true)\r\n  .useHtml(true)\r\n  .text(\r\n    '&lt;span style = \"color: #e12026; font-size:20px;\"&gt;Timeline of Elon Musk&lt;\/span&gt;' +\r\n    '&lt;br\/&gt;&lt;span style=\"font-size: 16px;\"&gt;Marking some of the most important professional milestones from 1971 to 2022&lt;\/span&gt;'\r\n  );<\/code><\/pre>\n<p>Now the JS-based timeline chart has a subtitle, and the entire title section is beautified.<\/p>\n<h3>4. Timeline chart tooltip<\/h3>\n<p>After that, I want to make a few tweaks to the timeline chart tooltip, for both range and moment series.<\/p>\n<p>For each series, I create an HTML-based format pattern for the tooltip text, enable HTML, and apply the configured format. For a crisp, finished look, I remove the tooltip titles and separators.<\/p>\n<pre><code class=\"javascript\">\/\/ format the range series tooltip\r\nlet rangeTooltipFormat =\r\n  \"&lt;span style='font-weight:600;font-size:10pt'&gt;\" +\r\n  \"{%name}&lt;\/span&gt;&lt;br&gt;&lt;br&gt;From \" +\r\n  \"{%start}{dateTimeFormat:YYYY} to \" +\r\n  \"{%end}{dateTimeFormat:YYYY}\";\r\nrangeSeries.tooltip().useHtml(true);\r\nrangeSeries.tooltip().format(rangeTooltipFormat);\r\nrangeSeries.tooltip().title().enabled(false);\r\nrangeSeries.tooltip().separator().enabled(false); \r\n\r\n\/\/ format the moment series tooltip\r\nlet momentTooltipFormat =\r\n  \"&lt;span&gt;{%x}{dateTimeFormat: MMMM YYYY}&lt;\/span&gt;\";\r\nmomentSeries.tooltip().useHtml(true);\r\nmomentSeries.tooltip().format(momentTooltipFormat);\r\nmomentSeries.tooltip().title().enabled(false);\r\nmomentSeries.tooltip().separator().enabled(false);<\/code><\/pre>\n<h3>5. Timeline scroller<\/h3>\n<p>Exploring timeline charts is easier when you can easily take a closer look at a certain period. Here, you can use the mouse wheel to zoom in and out. But it\u2019s also possible to add a scroller below the timeline, which requires only one quick line.<\/p>\n<pre><code class=\"javascript\">chart.scroller().enabled(true);<\/code><\/pre>\n<h3>6. Context menu and export<\/h3>\n<p>Finally, let me add one more cool thing, a context menu with options to save and share the timeline chart.<\/p>\n<p>I just reference these JS and CSS files along with the others already present in the <code>&lt;head&gt;<\/code> section of the web page, and the default settings of the charting library will take care of the rest.<\/p>\n<pre><code class=\"html\">&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-ui.min.js\"&gt;&lt;\/script&gt;\r\n\r\n&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-exports.min.js\"&gt;&lt;\/script&gt;\r\n\r\n&lt;link rel=\"stylesheet\" href=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/css\/anychart-ui.min.css\"&gt;\r\n\r\n&lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/fonts\/css\/anychart-font.min.css\"\/&gt;<\/code><\/pre>\n<h2>Result: Custom JS Timeline Chart<\/h2>\n<p>That\u2019s all. An elegant interactive JavaScript timeline chart is ready!<\/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-TB932Zei\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/TB932Zei\/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-TB932Zei{width:100%;height:700px;}\");\n})();<\/script><\/p>\n<p>Check out the code powering this timeline chart below. It is also available on <a href=\"https:\/\/playground.anychart.com\/TB932Zei\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a> where you can continue mastering JS timelines by further tweaking the visualization, adding your data, and so on.<\/p>\n<pre><code>&lt;html&gt;\r\n\u00a0\u00a0&lt;head&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;title&gt;JavaScript Timeline Chart&lt;\/title&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-timeline.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-ui.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-exports.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;link rel=\"stylesheet\" href=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/css\/anychart-ui.min.css\"&gt;\r\n    &lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/fonts\/css\/anychart-font.min.css\"\/&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;style type=\"text\/css\"&gt;      \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0html, body, #container { \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0width: 100%; height: 100%; margin: 0; padding: 0; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} \r\n\u00a0\u00a0\u00a0\u00a0&lt;\/style&gt;\r\n\u00a0\u00a0&lt;\/head&gt;\r\n\u00a0\u00a0&lt;body&gt;  \r\n\u00a0\u00a0\u00a0\u00a0&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script&gt;\r\n\r\n      \/\/ set the range series data\r\n      function rangeData() {\r\n        return [\r\n          {\r\n            name: \"Childhood and Education\",\r\n            start: \"1971\/06\/28\",\r\n            end: \"1995\/09\/01\",\r\n            fill: \"#00a8e0 0.5\",\r\n            stroke: \"#00a8e0\"\r\n          },\r\n          {\r\n            name: \"Entrepreneur Journey\",\r\n            start: \"1983\/06\/28\",\r\n            end: \"2002\/03\/13\",\r\n            fill: \"#1c4598 0.5\",\r\n            stroke: \"#1c4598\"\r\n          },\r\n          {\r\n            name: \"Making of Tycoon\",\r\n            start: \"2002\/03\/14\",\r\n            end: \"2010\/06\/28\",\r\n            fill: \"#a05e9c 0.6\",\r\n            stroke: \"#a05e9c\"\r\n          },\r\n          {\r\n            name: \"Rise of Tycoon\",\r\n            start: \"2010\/06\/29\",\r\n            end: \"2030\/01\/01\",\r\n            fill: \"#6e4c82 0.65\",\r\n            stroke: \"#6e4c82\"\r\n          }\r\n        ];\r\n      }\r\n\r\n      \/\/ set the moment series data\r\n      function momentData() {\r\n        return [\r\n          [\"1971\/06\/28\", \"Elon Musk was born in South Africa\"],\r\n          [\"1981\/06\/28\", \"Began to learn computer programming on his own\"],\r\n          [\"1983\/06\/28\", \"Sold the code of his game Blastar for $500\"],\r\n          [\"1990\/09\/01\", \"Entered Queen's University in Kingston, Ontario\"],\r\n          [\"1992\/09\/01\", \"Transferred to the University of Pennsylvania\"],\r\n          [\"1995\/06\/01\", \"Received bachelor's degrees in physics and economics\"],\r\n          [\"1995\/09\/01\", \"Started a Ph.D. at Stanford (dropped out in 2 days\"],\r\n          [\"1995\/11\/06\", \"Founded Zip2 with his brother\"],\r\n          [\"1999\/02\/01\", \"Sold Zip2 to Compaq for $307M\"],\r\n          [\"1999\/03\/01\", \"Co-founded X.com\"],\r\n          [\"2000\/03\/01\", \"Merged X.com with Confinity to form PayPal\"],\r\n          [\"2001\/01\/01\", \"Started conceptualizing Mars Oasis\"],\r\n          [\"2002\/03\/14\", \"Founded SpaceX &amp; became its CEO\"],\r\n          [\"2002\/10\/03\", \"Received $175.8M from PayPal's sale to eBay for $1.5B\"],\r\n          [\"2004\/02\/01\", \"Invested $6.5M in Tesla and joined its board as chairman\"],\r\n          [\"2006\/01\/01\", \"SpaceX started to get NASA contracts\"],\r\n          [\"2008\/10\/01\", \"Became CEO at Tesla\"],\r\n          [\"2010\/06\/29\", \"Tesla's first IPO\"],\r\n          [\"2015\/12\/11\", \"Co-founded OpenAI\"],\r\n          [\"2016\/07\/01\", \"Co-founded Neuralink\"],\r\n          [\"2018\/02\/21\", \"Resigned his board seat at OpenAI\"],\r\n          [\"2021\/11\/06\", \"Started selling his Tesla stock (10% for $16.4B by year end)\"],\r\n          [\"2022\/04\/13\", \"Made an offer to buy Twitter\"],\r\n          [\"2022\/07\/08\", \"Withdrew his $44B bid to buy Twitter\"]\r\n        ];\r\n      }\r\n\r\n      anychart.onDocumentReady(function () {\r\n  \r\n        \/\/ create a timeline chart\r\n        let chart = anychart.timeline();\r\n\r\n        \/\/ create a range series\r\n        let rangeSeries = chart.range(rangeData());\r\n  \r\n        \/\/ create a moment series\r\n        let momentSeries = chart.moment(momentData());\r\n\r\n        \/\/ configure the range series label settings\r\n        rangeSeries\r\n          .labels()\r\n          .useHtml(true)\r\n          .fontColor(\"#fff\")\r\n          .format(\r\n            '{%name}&lt;br&gt;&lt;span style=\"font-size: 85%\"&gt;{%start}{dateTimeFormat:YYYY}\u2013{%end}{dateTimeFormat:YYYY}&lt;\/span&gt;'\r\n          );\r\n  \r\n        \/\/ customize the moment series marker\r\n        momentSeries.normal().markers().fill(\"#ffdd0e\");\r\n        momentSeries.normal().markers().stroke(\"#e9ae0b\");\r\n\r\n        \/\/ set the range series bar height\r\n        rangeSeries.height(50);\r\n\r\n        \/\/ format the range series tooltip\r\n        let rangeTooltipFormat =\r\n          \"&lt;span style='font-weight:600;font-size:10pt'&gt;\" +\r\n          \"{%name}&lt;\/span&gt;&lt;br&gt;&lt;br&gt;From \" +\r\n          \"{%start}{dateTimeFormat:YYYY} to \" +\r\n          \"{%end}{dateTimeFormat:YYYY}\";\r\n        rangeSeries.tooltip().useHtml(true);\r\n        rangeSeries.tooltip().format(rangeTooltipFormat);\r\n        rangeSeries.tooltip().title().enabled(false);\r\n        rangeSeries.tooltip().separator().enabled(false);\r\n  \r\n        \/\/ format the moment series tooltip\r\n        let momentTooltipFormat =\r\n          \"&lt;span&gt;{%x}{dateTimeFormat: MMMM YYYY}&lt;\/span&gt;\";\r\n        momentSeries.tooltip().useHtml(true);\r\n        momentSeries.tooltip().format(momentTooltipFormat);\r\n        momentSeries.tooltip().title().enabled(false);\r\n        momentSeries.tooltip().separator().enabled(false);\r\n  \r\n        \/\/ set the chart title\r\n        chart\r\n          .title()\r\n          .enabled(true)\r\n          .useHtml(true)\r\n          .text(\r\n            '&lt;span style = \"color: #e12026; font-size:20px;\"&gt;Timeline of Elon Musk&lt;\/span&gt;&lt;br\/&gt;' +\r\n            '&lt;span style=\"font-size: 16px;\"&gt;Marking some of the most important professional milestones from 1971 to 2022&lt;\/span&gt;'\r\n          );\r\n  \r\n        \/\/ enable the scroller\r\n        chart.scroller().enabled(true);\r\n\r\n        \/\/ set the chart container id\r\n        chart.container(\"container\");\r\n\r\n        \/\/ draw the chart\r\n        chart.draw();\r\n  \r\n      });\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/script&gt;\r\n\u00a0\u00a0&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h2>Conclusion<\/h2>\n<p>Creating and customizing beautiful interactive timeline charts is pretty simple when you know how to use JavaScript for that. I hope I have properly explained and illustrated that in this tutorial. To learn more, look into the <a href=\"https:\/\/docs.anychart.com\/Basic_Charts\/Timeline_Chart\" target=\"_blank\" rel=\"nofollow\">timeline chart documentation<\/a>, and don\u2019t miss out on these cool <a href=\"https:\/\/www.anychart.com\/products\/anychart\/gallery\/Timeline_Chart\/\">timeline chart examples<\/a>.<\/p>\n<p>All in all, we don\u2019t need to be an Elon Musk to build stunning visualizations. So let\u2019s just go ahead and bring some data to life! Actually, there are numerous ways to visualize data and <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Supported_Charts_Types\" target=\"_blank\" rel=\"nofollow\">multiple chart types<\/a> to choose from.<\/p>\n<p>Feel free to ask questions here in the comments if anything needs to be clarified. Cheers.<\/p>\n<hr \/>\n<p><strong><em>We are thankful to Shachee Swadia for creating this fantastic timeline chart guide exclusively for our blog.<\/p>\n<p>We&#8217;ve got more cool <a href=\"https:\/\/www.anychart.com\/blog\/category\/javascript-chart-tutorials\/\">JavaScript charting tutorials<\/a> on our blog that you may well want to check out.<\/p>\n<p><a href=\"https:\/\/www.anychart.com\/support\/\">Drop us a line<\/a> if you&#8217;d like to write a guest post.<\/em><\/strong><\/p>\n<hr \/>\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>A timeline chart is an excellent way to represent important events and periods in chronological order. Now, let me teach you how to easily create an elegant interactive visualization like that using JavaScript! To make this tutorial both helpful and entertaining, I decided to take real data. Join me as I visualize the life of [&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,23,13,279,4],"tags":[53,3173,260,1758,3149,284,127,258,3412,471,266,620,1759,3352,509,2220,2838,54,1389,1760,2757,256,1111,350,844,130,165,313,1370,133,774,775,145,179,3369,3217,1047,1046,1498,805,3142,91,95,1762,2013,2014,32,55,3403,1335,144,2979,2016,167,146,433,152,2949,3405,151,36,907,141,249,81,57,169,170,1238,142,96,99,3404,58,65,56,101,2511,3416,3413,3408,3411,1197,3099,587,589,960,959,3414,30,172,570,3415,954,3100,2015,2816,1763,804,3406,3407,3410,3409],"class_list":["post-15335","post","type-post","status-publish","format-standard","hentry","category-anychart-charting-component","category-html5","category-javascript","category-javascript-chart-tutorials","category-tips-and-tricks","tag-anychart","tag-app-development","tag-best-data-visualization-examples","tag-chart-design","tag-chart-development","tag-chart-examples","tag-chart-types","tag-charts","tag-confinity","tag-data-analysis","tag-data-analytics","tag-data-analytics-examples","tag-data-design","tag-data-graphic","tag-data-graphics","tag-data-visual","tag-data-visualisation","tag-data-visualization","tag-data-visualization-best-pracices","tag-data-visualization-design","tag-data-visualization-development","tag-data-visualization-examples","tag-data-visualization-practice","tag-data-visualization-projects","tag-data-visualization-tutorial","tag-data-visualization-weekly","tag-data-visualizations","tag-data-visuals","tag-data-viz-examples","tag-dataviz","tag-dataviz-examples","tag-dataviz-projects","tag-dataviz-weekly","tag-design","tag-developers","tag-elon-musk","tag-entrepreneur","tag-entrepreneurship","tag-example","tag-front-end-development","tag-graphic","tag-graphics","tag-graphics-library","tag-guest-post","tag-html","tag-html-charts","tag-html5","tag-html5-charts","tag-html5-timeline","tag-infographic","tag-infographics","tag-information-graphics","tag-information-visualization","tag-interactive-charts","tag-interactive-data-visualization","tag-interactive-graphics","tag-interactive-infographic","tag-interactive-infographics","tag-interactive-timeline-chart","tag-interactive-visualizations","tag-javascript","tag-javascript-chart-tutorial","tag-javascript-charting","tag-javascript-charting-api","tag-javascript-charting-library","tag-javascript-charts","tag-javascript-drawing","tag-javascript-drawing-library","tag-javascript-graph","tag-javascript-graphics","tag-javascript-graphics-library","tag-javascript-library","tag-javascript-timeline","tag-js-chart","tag-js-charting","tag-js-charts","tag-js-graphics","tag-js-timeline","tag-life-timeline","tag-neuralink","tag-openai","tag-paypal","tag-spacex","tag-storytelling-examples","tag-tesla","tag-tesla-charts","tag-timeline","tag-timeline-chart","tag-timeline-graph","tag-tips-and-tricks","tag-tutorial","tag-twitter","tag-tycoon","tag-visual-data-analytics","tag-visual-storytelling-examples","tag-web-charts","tag-web-design","tag-web-developers","tag-web-development","tag-website","tag-website-development","tag-x-com","tag-zip2","wpautop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Timeline Chart: Learn How to Create One (in JavaScript)<\/title>\n<meta name=\"description\" content=\"Learn how to make an interactive Timeline Chart using JavaScript in a few easy steps while visualizing the life of Elon Musk as a businessman. The guide.\" \/>\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\/2022\/08\/04\/timeline-chart\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Make Timeline Chart (in JavaScript)\" \/>\n<meta property=\"og:description\" content=\"Learn how to create an interactive Timeline Chart using JS in a few easy steps while visualizing the life of Elon Musk as a businessman.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/\" \/>\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=\"2022-08-04T13:12:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-13T11:13:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.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 Make Timeline Chart (in JavaScript)\" \/>\n<meta name=\"twitter:description\" content=\"Learn how to create an interactive Timeline Chart using JS in a few easy steps while visualizing the life of Elon Musk as a businessman.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.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=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/\"},\"author\":{\"name\":\"Shachee Swadia\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\"},\"headline\":\"How to Make Timeline Chart (in JavaScript)\",\"datePublished\":\"2022-08-04T13:12:28+00:00\",\"dateModified\":\"2022-08-13T11:13:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/\"},\"wordCount\":1119,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.png\",\"keywords\":[\"AnyChart\",\"app development\",\"best data visualization examples\",\"chart design\",\"chart development\",\"chart examples\",\"chart types\",\"charts\",\"Confinity\",\"data analysis\",\"data analytics\",\"data analytics examples\",\"data design\",\"data graphic\",\"data graphics\",\"data visual\",\"data visualisation\",\"Data Visualization\",\"data visualization best practices\",\"data visualization design\",\"data visualization development\",\"data visualization examples\",\"data visualization practice\",\"data visualization projects\",\"data visualization tutorial\",\"data visualization weekly\",\"data visualizations\",\"data visuals\",\"data viz examples\",\"dataviz\",\"dataviz examples\",\"dataviz projects\",\"dataviz weekly\",\"design\",\"developers\",\"Elon Musk\",\"entrepreneur\",\"entrepreneurship\",\"example\",\"front-end development\",\"graphic\",\"graphics\",\"graphics library\",\"guest post\",\"HTML\",\"HTML charts\",\"HTML5\",\"html5 charts\",\"html5 timeline\",\"infographic\",\"infographics\",\"information graphics\",\"information visualization\",\"interactive charts\",\"interactive data visualization\",\"interactive graphics\",\"interactive infographic\",\"interactive infographics\",\"interactive timeline chart\",\"interactive visualizations\",\"JavaScript\",\"javascript chart tutorial\",\"javascript charting\",\"javascript charting api\",\"JavaScript charting library\",\"javascript charts\",\"javascript drawing\",\"javascript drawing library\",\"javascript graph\",\"javascript graphics\",\"JavaScript graphics library\",\"JavaScript library\",\"javascript timeline\",\"js chart\",\"js charting\",\"js charts\",\"JS graphics\",\"js timeline\",\"life timeline\",\"Neuralink\",\"OpenAI\",\"PayPal\",\"SpaceX\",\"storytelling examples\",\"Tesla\",\"Tesla charts\",\"timeline\",\"timeline chart\",\"timeline graph\",\"Tips and tricks\",\"tutorial\",\"Twitter\",\"tycoon\",\"visual data analytics\",\"visual storytelling examples\",\"web charts\",\"web design\",\"web developers\",\"web development\",\"website\",\"website development\",\"X.com\",\"Zip2\"],\"articleSection\":[\"AnyChart Charting Component\",\"HTML5\",\"JavaScript\",\"JavaScript Chart Tutorials\",\"Tips and Tricks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/\",\"url\":\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/\",\"name\":\"Timeline Chart: Learn How to Create One (in JavaScript)\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.png\",\"datePublished\":\"2022-08-04T13:12:28+00:00\",\"dateModified\":\"2022-08-13T11:13:43+00:00\",\"author\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\"},\"description\":\"Learn how to make an interactive Timeline Chart using JavaScript in a few easy steps while visualizing the life of Elon Musk as a businessman. The guide.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#primaryimage\",\"url\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.png\",\"contentUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.png\",\"width\":1400,\"height\":735},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.anychart.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Make Timeline Chart (in 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":"Timeline Chart: Learn How to Create One (in JavaScript)","description":"Learn how to make an interactive Timeline Chart using JavaScript in a few easy steps while visualizing the life of Elon Musk as a businessman. The guide.","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\/2022\/08\/04\/timeline-chart\/","og_locale":"en_US","og_type":"article","og_title":"How to Make Timeline Chart (in JavaScript)","og_description":"Learn how to create an interactive Timeline Chart using JS in a few easy steps while visualizing the life of Elon Musk as a businessman.","og_url":"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/","og_site_name":"AnyChart News","article_publisher":"https:\/\/www.facebook.com\/AnyCharts","article_published_time":"2022-08-04T13:12:28+00:00","article_modified_time":"2022-08-13T11:13:43+00:00","og_image":[{"url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.png","type":"","width":"","height":""}],"author":"Shachee Swadia","twitter_card":"summary_large_image","twitter_title":"How to Make Timeline Chart (in JavaScript)","twitter_description":"Learn how to create an interactive Timeline Chart using JS in a few easy steps while visualizing the life of Elon Musk as a businessman.","twitter_image":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.png","twitter_creator":"@AnyChart","twitter_site":"@AnyChart","twitter_misc":{"Written by":"Shachee Swadia","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#article","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/"},"author":{"name":"Shachee Swadia","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51"},"headline":"How to Make Timeline Chart (in JavaScript)","datePublished":"2022-08-04T13:12:28+00:00","dateModified":"2022-08-13T11:13:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/"},"wordCount":1119,"commentCount":0,"image":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.png","keywords":["AnyChart","app development","best data visualization examples","chart design","chart development","chart examples","chart types","charts","Confinity","data analysis","data analytics","data analytics examples","data design","data graphic","data graphics","data visual","data visualisation","Data Visualization","data visualization best practices","data visualization design","data visualization development","data visualization examples","data visualization practice","data visualization projects","data visualization tutorial","data visualization weekly","data visualizations","data visuals","data viz examples","dataviz","dataviz examples","dataviz projects","dataviz weekly","design","developers","Elon Musk","entrepreneur","entrepreneurship","example","front-end development","graphic","graphics","graphics library","guest post","HTML","HTML charts","HTML5","html5 charts","html5 timeline","infographic","infographics","information graphics","information visualization","interactive charts","interactive data visualization","interactive graphics","interactive infographic","interactive infographics","interactive timeline chart","interactive visualizations","JavaScript","javascript chart tutorial","javascript charting","javascript charting api","JavaScript charting library","javascript charts","javascript drawing","javascript drawing library","javascript graph","javascript graphics","JavaScript graphics library","JavaScript library","javascript timeline","js chart","js charting","js charts","JS graphics","js timeline","life timeline","Neuralink","OpenAI","PayPal","SpaceX","storytelling examples","Tesla","Tesla charts","timeline","timeline chart","timeline graph","Tips and tricks","tutorial","Twitter","tycoon","visual data analytics","visual storytelling examples","web charts","web design","web developers","web development","website","website development","X.com","Zip2"],"articleSection":["AnyChart Charting Component","HTML5","JavaScript","JavaScript Chart Tutorials","Tips and Tricks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/","url":"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/","name":"Timeline Chart: Learn How to Create One (in JavaScript)","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#primaryimage"},"image":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.png","datePublished":"2022-08-04T13:12:28+00:00","dateModified":"2022-08-13T11:13:43+00:00","author":{"@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51"},"description":"Learn how to make an interactive Timeline Chart using JavaScript in a few easy steps while visualizing the life of Elon Musk as a businessman. The guide.","breadcrumb":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#primaryimage","url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.png","contentUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/08\/timeline.png","width":1400,"height":735},{"@type":"BreadcrumbList","@id":"https:\/\/www.anychart.com\/blog\/2022\/08\/04\/timeline-chart\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.anychart.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Make Timeline Chart (in 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\/15335","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=15335"}],"version-history":[{"count":13,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/15335\/revisions"}],"predecessor-version":[{"id":15344,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/15335\/revisions\/15344"}],"wp:attachment":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/media?parent=15335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/categories?post=15335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/tags?post=15335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}