{"id":15772,"date":"2022-10-14T12:25:41","date_gmt":"2022-10-14T12:25:41","guid":{"rendered":"https:\/\/www.anychart.com\/blog\/?p=15772"},"modified":"2022-10-14T13:07:17","modified_gmt":"2022-10-14T13:07:17","slug":"word-tree-js","status":"publish","type":"post","link":"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/","title":{"rendered":"How to Create Word Tree Using JavaScript"},"content":{"rendered":"<p><a href=\"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/\"><img decoding=\"async\" class=\"alignnone size-full wp-image-15789\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree.png\" alt=\"A word tree chart in JavaScript\" width=\"100%\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree.png 1366w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree-300x169.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree-768x432.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree-1024x576.png 1024w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/a>It\u00a0is\u00a0a\u00a0pure\u00a0fact\u00a0that\u00a0a graphical or pictorial representation of data,\u00a0known\u00a0as\u00a0a\u00a0<a href=\"https:\/\/www.anychart.com\/blog\/2018\/11\/20\/data-visualization-definition-history-examples\/\">data\u00a0visualization<\/a>, conveys information faster than\u00a0raw data\u00a0in arrays, spreadsheets,\u00a0or\u00a0dense reports.\u00a0Charts\u00a0make\u00a0data easier\u00a0to\u00a0understand,\u00a0which further helps\u00a0to\u00a0quickly develop valuable insights. Interesting, right? Now, let\u2019s have a look at one chart type called a <strong>word tree<\/strong> and see how to build it with ease.<\/p>\n<p>A word tree is a data visualization form designed to show multiple parallel sequences of words (or phrases) as they appear in a text. Analyzing texts becomes easier with word trees as they display, by means of a branching structure, how selected words are connected to others.<\/p>\n<p>In this tutorial, I will walk you through the process of creating a beautiful word tree chart with JavaScript (HTML5). The text being visualized will be the famous speech <strong>\u201cI Have a Dream\u201d<\/strong> by minister and civil rights activist Martin Luther King Jr. Each step will be explained in detail, and you&#8217;ll see everything is pretty simple. Sit tight and enjoy the learning!<\/p>\n<p><!--more Read the JS charting tutorial \u00bb--><\/p>\n<h2>Word Tree Chart That Will Be Created<\/h2>\n<p>Here is how the final word tree chart will look. Keep reading to find out how\u00a0a visualization like this can be created real quick using JavaScript.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-15794\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree-chart.png\" alt=\"A look at the final JavaScript Word Tree chart that will be built along the tutorial\" width=\"100%\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree-chart.png 1115w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree-chart-300x174.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree-chart-768x446.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree-chart-1024x594.png 1024w\" sizes=\"(max-width: 1115px) 100vw, 1115px\" \/><\/p>\n<h2>Building Basic Word Tree\u00a0with\u00a0JavaScript<\/h2>\n<p>You might have found the concept\u00a0of\u00a0a\u00a0word tree a little\u00a0complicated.\u00a0But I assure you that it is no great deal to create\u00a0such\u00a0a\u00a0chart.\u00a0Here\u00a0are\u00a0four\u00a0basic\u00a0steps:<\/p>\n<ol>\n<li>Create an HTML page.<\/li>\n<li>Include JavaScript files.<\/li>\n<li>Load the data.<\/li>\n<li>Add some JS code for the chart.<\/li>\n<\/ol>\n<p>Now,\u00a0we&#8217;ll\u00a0go\u00a0through each of these steps.<\/p>\n<h3>1. Create an HTML\u00a0page<\/h3>\n<p>The first step\u00a0is\u00a0to\u00a0get\u00a0a\u00a0web\u00a0page\u00a0for\u00a0the chart.<\/p>\n<p>Create\u00a0a\u00a0basic\u00a0HTML page.\u00a0Add a <code>&lt;div&gt;<\/code> element\u00a0\u2014\u00a0it&#8217;s\u00a0where the\u00a0word\u00a0tree\u00a0will\u00a0be\u00a0placed.\u00a0Give\u00a0it\u00a0an\u00a0ID.<\/p>\n<p>Set the <code>width<\/code> and <code>height<\/code> parameters to 100% in order\u00a0to\u00a0display\u00a0the chart on the entire screen.\u00a0Or configure\u00a0that\u00a0as\u00a0per your requirements.<\/p>\n<p>Feel free to add your special touch to the structure.<\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n\u00a0\u00a0&lt;head&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;meta charset=\"utf-8\"&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;title&gt;JavaScript Word Tree 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%; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0height: 100%; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0margin: 0; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0padding: 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. Include JavaScript files<\/h3>\n<p>Creating word trees can be very easy when you use a good JavaScript charting library\u00a0that supports this chart type out of the box. In this tutorial, the process will\u00a0be demonstrated using <a href=\"https:\/\/www.anychart.com\/\">AnyChart<\/a>\u00a0based on the <a href=\"https:\/\/docs.anychart.com\/Basic_Charts\/Word_Tree\" target=\"_blank\" rel=\"nofollow\">word tree documentation.<\/a><\/p>\n<p>Let&#8217;s include the required JS files\u00a0from the AnyChart <a href=\"https:\/\/cdn.anychart.com\" target=\"_blank\" rel=\"nofollow\">CDN<\/a>\u00a0(alternatively, you can download them). The <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Modules#core\" target=\"_blank\" rel=\"nofollow\">core module<\/a> and <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Modules#word_tree\" target=\"_blank\" rel=\"nofollow\">word tree module<\/a> are the scripts\u00a0needed to create the word tree chart.\u00a0<a href=\"https:\/\/code.jquery.com\/jquery-latest.min.js\" target=\"_blank\" rel=\"nofollow\">jQuery<\/a> will be used to query a text file.<\/p>\n<p>The scripts need to be referenced in the <code>&lt;head&gt;<\/code> section. The JS code will be placed in the JavaScript tag script that can be put anywhere in the <code>&lt;head&gt;<\/code> or <code>&lt;body&gt;<\/code> sections. So our\u00a0HTML would now look something like this:<\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n\u00a0\u00a0&lt;head&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;meta charset=\"utf-8\"&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;title&gt;JavaScript Word Tree 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-wordtree.min.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/code.jquery.com\/jquery-latest.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%; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0height: 100%; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0margin: 0; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0padding: 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\/\/ The JS Word Tree chart\u2019s code will be written 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. Load the data<\/h3>\n<p>Now, it&#8217;s time to set the data. I have downloaded the speech \u201cI Have A Dream\u201d by Dr. Martin Luther King, Jr. from <a href=\"https:\/\/www.marshall.edu\/onemarshallu\/i-have-a-dream\/\" target=\"_blank\" rel=\"nofollow\">Marshall University<\/a>&#8216;s website and created a <a href=\"https:\/\/gist.githubusercontent.com\/awanshrestha\/0033cf6344bcda10c242b64fe1d8c2f7\/raw\/115a11507a1d672fbf651f1bd413963318501010\/i-have-a-dream-speech.txt\" target=\"_blank\" rel=\"nofollow\">data file<\/a>.<\/p>\n<p>To load the data into\u00a0the\u00a0JS chart, we will use the jQuery <code>ajax()<\/code> function as shown in the next step.<\/p>\n<h3>4. Add some JS code for the\u00a0chart<\/h3>\n<p>Now, a few lines of JavaScript code\u00a0are needed to make\u00a0a functional word tree chart.<\/p>\n<p>First, add the <code>anychart.onDocumentReady()<\/code> function which wraps up the entire chart code, making sure that the charting\u00a0will be executed only after the page has loaded completely.<\/p>\n<pre><code class=\"html\">&lt;script&gt;\r\n\u00a0\u00a0anychart.onDocumentReady(function () {\r\n\u00a0\u00a0\u00a0\u00a0\/\/ The main part of the word tree code will go here.\r\n\u00a0\u00a0}\r\n&lt;\/script&gt;<\/code><\/pre>\n<p>Then, load the data\u00a0as preliminarily explained in the third step.<\/p>\n<pre><code class=\"javascript\">anychart.onDocumentReady(function () {\r\n\u00a0\u00a0$.ajax(\"https:\/\/gist.githubusercontent.com\/awanshrestha\/0033cf6344bcda10c242b64fe1d8c2f7\/raw\/115a11507a1d672fbf651f1bd413963318501010\/i-have-a-dream-speech.txt\").done(function (text) {\r\n    \/\/ The rest of the word tree code will go here.\r\n  });\r\n});<\/code><\/pre>\n<p>After that, create a word tree chart\u00a0instance using the <code>wordtree()<\/code> function of the JS\u00a0library\u00a0and pass the text data to it.<\/p>\n<pre><code class=\"javascript\">var chart = anychart.wordtree(text);<\/code><\/pre>\n<p>Defining the root word is a significant part of a word tree chart, as it is this root word that branches out to various sentences in the text. For this example, let&#8217;s set &#8220;I&#8221; as the root word.<\/p>\n<pre><code class=\"javascript\">chart.word(\"I\");<\/code><\/pre>\n<p>In the end, we give the chart a title, define the\u00a0container, and display the result.<\/p>\n<pre><code class=\"javascript\">chart.title(\"Word Tree of \\\"I Have a Dream\\\" Speech by Martin Luther King\");\r\nchart.container(\"container\");\r\nchart.draw();<\/code><\/pre>\n<p>Hurray, it&#8217;s done! This is all that is required to create an interactive\u00a0word tree chart using JavaScript. Such visualization can be embedded into any web page or app and work in any browser.<\/p>\n<p><iframe loading=\"lazy\" class=\"anychart-embed anychart-embed-0pENd508\" src=\"https:\/\/playground.anychart.com\/0pENd508\/iframe\" width=\"300\" height=\"150\" frameborder=\"0\" sandbox=\"allow-scripts allow-pointer-lock allow-same-origin allow-popups allow-modals allow-forms\" allowfullscreen=\"allowfullscreen\"><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-0pENd508{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>This JavaScript word tree chart is available on <a href=\"https:\/\/playground.anychart.com\/0pENd508\/\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground <\/a>with the full code. Feel free to experiment with it\u00a0right there. The complete word tree\u00a0code\u00a0is also placed below, for your convenience.<\/p>\n<pre><code class=\"html\">&lt;html lang=\"en\"&gt;\r\n\u00a0\u00a0&lt;head&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;meta charset=\"utf-8\"&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;title&gt;JavaScript Word Tree 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  &lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-wordtree.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;script src=\"https:\/\/code.jquery.com\/jquery-latest.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%; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0height: 100%; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0margin: 0; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0padding: 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      anychart.onDocumentReady(function () {\r\n \r\n        $.ajax(\"https:\/\/gist.githubusercontent.com\/awanshrestha\/0033cf6344bcda10c242b64fe1d8c2f7\/raw\/115a11507a1d672fbf651f1bd413963318501010\/i-have-a-dream-speech.txt\"\r\n        ).done(function (text) {\r\n \r\n          \/\/ create a word tree chart\r\n          var chart = anychart.wordtree(text);\r\n\r\n          \/\/ set the root word\r\n          chart.word('I');\r\n \r\n          \/\/ set the chart title\r\n          chart.title(\"Word Tree of \\\"I Have a Dream\\\" Speech by Martin Luther King\");\r\n\r\n          \/\/ set the container id\r\n          chart.container(\"container\");\r\n\r\n          \/\/ initiate the drawing of the word tree chart\r\n          chart.draw();\r\n \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<p>This\u00a0JS-based word tree already looks beautiful. But there is always room for improvement. Using AnyChart, it is easy\u00a0to modify\u00a0any aspect\u00a0of the chart according\u00a0to your personal preferences. Let&#8217;s proceed with\u00a0customization!<\/p>\n<h2>Customizing\u00a0JavaScript Word Tree Chart<\/h2>\n<p>Below, I want to show you\u00a0how to make some quick changes and improvements to the\u00a0JS word tree chart:<\/p>\n<ol type=\"A\">\n<li>Customize the fonts.<\/li>\n<li>Modify the connectors.<\/li>\n<li>Change the\u00a0root\u00a0word.<\/li>\n<\/ol>\n<h3>A. Customize the fonts<\/h3>\n<p>Enhancing\u00a0the way\u00a0a text\u00a0looks is easy with the help of HTML, which can be enabled using the <code>useHtml()<\/code> function. Let&#8217;s\u00a0customize the\u00a0word tree&#8217;s title like this:<\/p>\n<pre><code class=\"javascript\">chart\r\n  .title()\r\n  .enabled(true)\r\n  .useHtml(true)\r\n  .text('&lt;span style = \"color: #2b2b2b; font-size:20px;\"&gt;Word Tree: I Have a Dream Speech&lt;\/span&gt;');<\/code><\/pre>\n<p>It&#8217;s also possible to modify the font settings for the\u00a0word tree itself using several handy functions:<\/p>\n<pre><code class=\"javascript\">chart.fontColor(\"#0daf8d\");\r\nchart.fontWeight(500);\r\nchart.fontStyle('italic');\r\nchart.minFontSize(8);\r\nchart.maxFontSize(16);<\/code><\/pre>\n<p>This is how\u00a0the word tree\u00a0looks after the font\u00a0reconfiguration.<\/p>\n<p><iframe loading=\"lazy\" class=\"anychart-embed anychart-embed-2dAoVwAp\" src=\"https:\/\/playground.anychart.com\/2dAoVwAp\/iframe\" width=\"300\" height=\"150\" frameborder=\"0\" sandbox=\"allow-scripts allow-pointer-lock allow-same-origin allow-popups allow-modals allow-forms\" allowfullscreen=\"allowfullscreen\"><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-2dAoVwAp{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>See this\u00a0JS word tree version on\u00a0<a href=\"https:\/\/playground.anychart.com\/2dAoVwAp\/\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>.<\/p>\n<h3>B. Modify the\u00a0connectors<\/h3>\n<p>The branches that connect one word to another in a word tree chart can\u00a0also be easily modified according\u00a0to your preference. I feel the chart looks more organized with straight line connectors. So, why not try them?<\/p>\n<p>Let&#8217;s change the shape of the connectors using the <code>curveFactor()<\/code> function\u00a0and their length with the <code>length()<\/code> function. Similarly, its offset and\u00a0stroke can be customized.<\/p>\n<pre><code class=\"javascript\">var connectors = chart.connectors();\r\nconnectors.curveFactor(0);\r\nconnectors.length(100);\r\nconnectors.offset(5);\r\nconnectors.stroke(\"1.5 #1976d2\");<\/code><\/pre>\n<p><iframe loading=\"lazy\" class=\"anychart-embed anychart-embed-TxpcwrWz\" src=\"https:\/\/playground.anychart.com\/TxpcwrWz\/iframe\" width=\"300\" height=\"150\" frameborder=\"0\" sandbox=\"allow-scripts allow-pointer-lock allow-same-origin allow-popups allow-modals allow-forms\" allowfullscreen=\"allowfullscreen\"><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-TxpcwrWz{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>I have changed it to straight lines, however, if you are good with just changing its curve by a bit, feel free to do that.<\/p>\n<p>You can find\u00a0this\u00a0JS word tree version\u00a0on\u00a0<a href=\"https:\/\/playground.anychart.com\/TxpcwrWz\/\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>.<\/p>\n<h3>C. Change the\u00a0root\u00a0word<\/h3>\n<p>What if you wish to change the root word? Yeah, you could just\u00a0set a new one in this part of the JS code:<\/p>\n<pre><code class=\"javascript\">chart.word(\"I\");<\/code><\/pre>\n<p>What\u00a0if you want to change it dynamically from the chart itself? Will\u00a0it require a complicated\u00a0code? Not at all! I will show you how to change the root word dynamically in a few simple steps.<\/p>\n<p>Let&#8217;s add\u00a0two buttons. Clicking on them\u00a0will change the root word\u00a0to &#8220;I&#8221; or &#8220;This,&#8221; respectively. Here&#8217;s what goes to the HTML section for that. Add a <code>&lt;div&gt;<\/code> for\u00a0the buttons and add\u00a0the two buttons there. In the buttons, add an <code>onclick<\/code> attribute, so that when the user\u00a0clicks on a button, the <code>switchRoot()<\/code> function gets called\u00a0(which will be defined\u00a0in the JS section). Then, pass the\u00a0desired root word as a parameter to this function.<\/p>\n<pre><code class=\"html\">&lt;div class=\"button-container\"&gt;\r\n  &lt;span&gt;Root word: &lt;\/span&gt;\r\n  &lt;button onclick=\"switchRoot('I')\"&gt;I&lt;\/button&gt;\r\n  &lt;button onclick=\"switchRoot('This')\"&gt;This&lt;\/button&gt;\r\n&lt;\/div&gt;<\/code><\/pre>\n<p>You can fine-tune the appearance of the buttons\u00a0using the CSS. For example:<\/p>\n<pre><code>.button-container{\r\n  padding: 20px 0 0 20px;\r\n  font-family: 'Arial'\r\n}\r\n\r\nbutton{\r\n  border: 1px solid #222222;\r\n  border-radius: 8px;\r\n  color: #222222;\r\n  font-size: 16px;\r\n  font-weight: 600;\r\n  padding: 4px 18px;\r\n  margin-right: 10px;\r\n  cursor: pointer;\r\n}<\/code><\/pre>\n<p>Now, in the\u00a0JavaScript part, we create a variable\u00a0and copy the instance\u00a0of the word tree chart\u00a0to it.<\/p>\n<pre><code>let theChart;\r\n\r\nanychart.onDocumentReady(function () {\r\n$.ajax( \"https:\/\/gist.githubusercontent.com\/awanshrestha\/0033cf6344bcda10c242b64fe1d8c2f7\/raw\/115a11507a1d672fbf651f1bd413963318501010\/i-have-a-dream-speech.txt\").done(function (text) {\r\n      \r\n  var chart = anychart.wordtree(text);\r\n  theChart = chart;<\/code><\/pre>\n<p>Finally, define the\u00a0<code>switchRoot()<\/code>\u00a0function. Pass the root word parameter\u00a0to it and change the root word inside it using the <code>word()<\/code> function.<\/p>\n<pre><code>function switchRoot(newWord){\r\n  theChart.word(newWord);\r\n};<\/code><\/pre>\n<p>Now\u00a0you see two buttons above\u00a0the chart, and by clicking on them, you can\u00a0switch between the root words.<\/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-9F9snZ6H\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/9F9snZ6H\/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-9F9snZ6H{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>The complete source code for this final version of the JavaScript word tree chart is available below, as well as on <a href=\"https:\/\/playground.anychart.com\/9F9snZ6H\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>.<\/p>\n<pre><code>&lt;html lang=\"en\"&gt;\r\n\u00a0\u00a0&lt;head&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;meta charset=\"utf-8\"&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;title&gt;JavaScript Word Tree 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  &lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-wordtree.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;script src=\"https:\/\/code.jquery.com\/jquery-latest.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%; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0height: 100%; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0margin: 0; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0padding: 0; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.button-container{\r\n\u00a0\u00a0\u00a0\u00a0    padding: 20px 0 0 20px;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0  font-family: 'Arial'\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0button{\r\n\u00a0\u00a0\u00a0     border: 1px solid #222222;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0  border-radius: 8px;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0  color: #222222;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0   font-size: 16px;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0   font-weight: 600;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0   padding: 4px 18px;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0   margin-right: 10px;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0   cursor: pointer;\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    &lt;div class=\"button-container\"&gt;\r\n\u00a0\u00a0\u00a0\u00a0  &lt;span&gt;Change Root Word to: &lt;\/span&gt;\r\n\u00a0\u00a0\u00a0   &lt;button onclick=\"switchRoot('I')\"&gt;I&lt;\/button&gt;\r\n\u00a0\u00a0\u00a0\u00a0  &lt;button onclick=\"switchRoot('This')\"&gt;This&lt;\/button&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/div&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      let theChart;\r\n\r\n      anychart.onDocumentReady(function () {\r\n \r\n        $.ajax( 'https:\/\/gist.githubusercontent.com\/awanshrestha\/0033cf6344bcda10c242b64fe1d8c2f7\/raw\/115a11507a1d672fbf651f1bd413963318501010\/i-have-a-dream-speech.txt'\r\n        ).done(function (text) {\r\n \r\n          \/\/ create a word tree chart\r\n          var chart = anychart.wordtree(text);\r\n          theChart = chart;\r\n\r\n          \/\/ set the root word\r\n          chart.word('I');\r\n \r\n          \/\/ configure the chart title\r\n          chart\r\n            .title()\r\n            .enabled(true)\r\n            .useHtml(true)\r\n            .text('&lt;span style = \"color: #2b2b2b; font-size:20px;\"&gt;Word Tree of \\\"I Have a Dream\\\" Speech by Martin Luther King&lt;\/span&gt;');\r\n\r\n          \/\/ configure the font size and color\r\n          chart.fontColor(\"#0daf8d\");\r\n          chart.fontWeight(500);\r\n          chart.fontStyle('italic');\r\n          chart.minFontSize(8);\r\n          chart.maxFontSize(16);\r\n \r\n          \/\/ configure the connectors\r\n          var connectors = chart.connectors();\r\n          connectors.curveFactor(0);\r\n          connectors.length(100);\r\n          connectors.offset(5);\r\n          connectors.stroke(\"1.5 #1976d2\");\r\n \r\n          \/\/ set the container id\r\n          chart.container(\"container\");\r\n\r\n          \/\/ initiate the drawing of the word tree chart\r\n          chart.draw();\r\n \r\n        }); \r\n\r\n      });\r\n\r\n      \/\/ a function to set the root word\r\n      function switchRoot(type) {\r\n        theChart.word(type);\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>Bravo! You have made it to the end of this tutorial by creating this beautiful\u00a0interactive word tree chart\u00a0with JavaScript. I can\u2019t wait to see you creating another word tree\u00a0following this tutorial and adding your personal touch to it.<\/p>\n<p>Also, have a look at the varieties of <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Supported_Charts_Types\" target=\"_blank\" rel=\"nofollow\">chart types<\/a> available in AnyChart, and try to implement them for data visualization. I am sure it will be fascinating.<\/p>\n<p>Moreover, in case of any queries, please don\u2019t hesitate to reach out to me and drop any questions you have, I will\u00a0do my best to answer them all. Hope you have a great time creating your\u00a0own word tree charts!<\/p>\n<hr \/>\n<p><strong><em>We want to thank Awan Shrestha for this awesome <strong>Word Tree<\/strong> tutorial!<\/p>\n<p>Check out other awesome <a href=\"https:\/\/www.anychart.com\/blog\/category\/javascript-chart-tutorials\/\">JavaScript charting tutorials<\/a> on our blog.<\/p>\n<p>If you have an idea for a guest post, just <a href=\"https:\/\/www.anychart.com\/support\/\">contact us<\/a><\/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>It\u00a0is\u00a0a\u00a0pure\u00a0fact\u00a0that\u00a0a graphical or pictorial representation of data,\u00a0known\u00a0as\u00a0a\u00a0data\u00a0visualization, conveys information faster than\u00a0raw data\u00a0in arrays, spreadsheets,\u00a0or\u00a0dense reports.\u00a0Charts\u00a0make\u00a0data easier\u00a0to\u00a0understand,\u00a0which further helps\u00a0to\u00a0quickly develop valuable insights. Interesting, right? Now, let\u2019s have a look at one chart type called a word tree and see how to build it with ease. A word tree is a data visualization form designed to show [&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":22,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,23,13,279,4],"tags":[619,618,53,3173,260,845,2000,847,265,268,254,1758,284,127,166,258,471,266,620,1292,880,806,1759,3352,509,54,1389,1760,2757,256,3377,1111,350,744,1379,844,165,313,1370,774,775,3369,2032,805,95,2013,2014,32,55,3455,1335,144,167,146,433,152,2949,151,247,36,907,141,249,3111,81,57,169,170,1238,142,96,99,134,573,2332,58,65,56,101,237,3457,3454,1965,131,834,459,3456,908,909,252,1534,30,848,846,172,807,808,954,293,745,899,2015,2816,1763,804,3406,3407,558],"class_list":["post-15772","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-analysis","tag-analytics","tag-anychart","tag-app-development","tag-best-data-visualization-examples","tag-best-data-visualization-software","tag-best-data-visualization-tool","tag-best-data-visualization-tools","tag-big-data","tag-big-data-tools","tag-chart","tag-chart-design","tag-chart-examples","tag-chart-types","tag-charting","tag-charts","tag-data-analysis","tag-data-analytics","tag-data-analytics-examples","tag-data-chart","tag-data-charting","tag-data-charts","tag-data-design","tag-data-graphic","tag-data-graphics","tag-data-visualization","tag-data-visualization-best-pracices","tag-data-visualization-design","tag-data-visualization-development","tag-data-visualization-examples","tag-data-visualization-guide","tag-data-visualization-practice","tag-data-visualization-projects","tag-data-visualization-techniques","tag-data-visualization-tool","tag-data-visualization-tutorial","tag-data-visualizations","tag-data-visuals","tag-data-viz-examples","tag-dataviz-examples","tag-dataviz-projects","tag-developers","tag-drawing-tools","tag-front-end-development","tag-graphics-library","tag-html","tag-html-charts","tag-html5","tag-html5-charts","tag-i-have-a-dream","tag-infographic","tag-infographics","tag-interactive-charts","tag-interactive-data-visualization","tag-interactive-graphics","tag-interactive-infographic","tag-interactive-infographics","tag-interactive-visualizations","tag-interactivity","tag-javascript","tag-javascript-chart-tutorial","tag-javascript-charting","tag-javascript-charting-api","tag-javascript-charting-features","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-technologies","tag-javascript-word-tree-chart","tag-jquery","tag-js-chart","tag-js-charting","tag-js-charts","tag-js-graphics","tag-maps","tag-marshall-university","tag-martin-luther-king","tag-mobile-app-development","tag-recap-of-the-week","tag-statistical-analysis","tag-statistics","tag-text-analysis","tag-text-data","tag-text-data-visualization","tag-text-formatting","tag-text-visualization","tag-tips-and-tricks","tag-top-data-visualization-software","tag-top-data-visualization-tools","tag-tutorial","tag-visual-analysis","tag-visual-analytics","tag-visual-data-analytics","tag-visualization","tag-visualization-techniques","tag-visualizations","tag-web-charts","tag-web-design","tag-web-developers","tag-web-development","tag-website","tag-website-development","tag-word-tree","wpautop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Word Tree: How to Create This Chart Using JavaScript (HTML5)<\/title>\n<meta name=\"description\" content=\"A word tree chart shows how selected words are connected to others in a text. Learn how to easily make it in JS while visualizing the I Have a Dream speech.\" \/>\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\/10\/14\/word-tree-js\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create a Word Tree Using JavaScript\" \/>\n<meta property=\"og:description\" content=\"Learn how to quickly make cool interactive word tree charts in JS while visualizing Martin Luther King&#039;s I Have a Dream speech.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/\" \/>\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-10-14T12:25:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-14T13:07:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree-social.png\" \/>\n<meta name=\"author\" content=\"Awan Shrestha\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to Create a Word Tree Using JavaScript\" \/>\n<meta name=\"twitter:description\" content=\"Learn how to quickly make cool interactive word tree charts in JS while visualizing Martin Luther King&#039;s I Have a Dream speech.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree-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=\"Awan Shrestha\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 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\/10\/14\/word-tree-js\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/\"},\"author\":{\"name\":\"Awan Shrestha\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/3f107fdcb3fe326a63cd52812f5287c1\"},\"headline\":\"How to Create Word Tree Using JavaScript\",\"datePublished\":\"2022-10-14T12:25:41+00:00\",\"dateModified\":\"2022-10-14T13:07:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/\"},\"wordCount\":1373,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree.png\",\"keywords\":[\"analysis\",\"analytics\",\"AnyChart\",\"app development\",\"best data visualization examples\",\"best data visualization software\",\"best data visualization tool\",\"best data visualization tools\",\"big data\",\"big data tools\",\"chart\",\"chart design\",\"chart examples\",\"chart types\",\"charting\",\"charts\",\"data analysis\",\"data analytics\",\"data analytics examples\",\"data chart\",\"data charting\",\"data charts\",\"data design\",\"data graphic\",\"data graphics\",\"Data Visualization\",\"data visualization best practices\",\"data visualization design\",\"data visualization development\",\"data visualization examples\",\"data visualization guide\",\"data visualization practice\",\"data visualization projects\",\"data visualization techniques\",\"data visualization tool\",\"data visualization tutorial\",\"data visualizations\",\"data visuals\",\"data viz examples\",\"dataviz examples\",\"dataviz projects\",\"developers\",\"drawing tools\",\"front-end development\",\"graphics library\",\"HTML\",\"HTML charts\",\"HTML5\",\"html5 charts\",\"I Have a Dream\",\"infographic\",\"infographics\",\"interactive charts\",\"interactive data visualization\",\"interactive graphics\",\"interactive infographic\",\"interactive infographics\",\"interactive visualizations\",\"interactivity\",\"JavaScript\",\"javascript chart tutorial\",\"javascript charting\",\"javascript charting api\",\"JavaScript charting features\",\"JavaScript charting library\",\"javascript charts\",\"javascript drawing\",\"javascript drawing library\",\"javascript graph\",\"javascript graphics\",\"JavaScript graphics library\",\"JavaScript library\",\"javascript technologies\",\"JavaScript Word Tree Chart\",\"jQuery\",\"js chart\",\"js charting\",\"js charts\",\"JS graphics\",\"maps\",\"Marshall University\",\"Martin Luther King\",\"mobile app development\",\"recap of the week\",\"statistical analysis\",\"statistics\",\"text analysis\",\"text data\",\"text data visualization\",\"text formatting\",\"text visualization\",\"Tips and tricks\",\"top data visualization software\",\"top data visualization tools\",\"tutorial\",\"visual analysis\",\"visual analytics\",\"visual data analytics\",\"visualization\",\"visualization techniques\",\"visualizations\",\"web charts\",\"web design\",\"web developers\",\"web development\",\"website\",\"website development\",\"Word Tree\"],\"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\/10\/14\/word-tree-js\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/\",\"url\":\"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/\",\"name\":\"Word Tree: How to Create This Chart Using JavaScript (HTML5)\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree.png\",\"datePublished\":\"2022-10-14T12:25:41+00:00\",\"dateModified\":\"2022-10-14T13:07:17+00:00\",\"author\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/3f107fdcb3fe326a63cd52812f5287c1\"},\"description\":\"A word tree chart shows how selected words are connected to others in a text. Learn how to easily make it in JS while visualizing the I Have a Dream speech.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/#primaryimage\",\"url\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree.png\",\"contentUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree.png\",\"width\":1366,\"height\":768},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.anychart.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create Word Tree Using 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\/3f107fdcb3fe326a63cd52812f5287c1\",\"name\":\"Awan Shrestha\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/02ebd18c927547ca82372246dddcc3aebfa98928cb91405eef1a63ece7f17518?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/02ebd18c927547ca82372246dddcc3aebfa98928cb91405eef1a63ece7f17518?s=96&r=g\",\"caption\":\"Awan Shrestha\"},\"url\":\"https:\/\/www.anychart.com\/blog\/author\/awan-shrestha\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Word Tree: How to Create This Chart Using JavaScript (HTML5)","description":"A word tree chart shows how selected words are connected to others in a text. Learn how to easily make it in JS while visualizing the I Have a Dream speech.","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\/10\/14\/word-tree-js\/","og_locale":"en_US","og_type":"article","og_title":"How to Create a Word Tree Using JavaScript","og_description":"Learn how to quickly make cool interactive word tree charts in JS while visualizing Martin Luther King's I Have a Dream speech.","og_url":"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/","og_site_name":"AnyChart News","article_publisher":"https:\/\/www.facebook.com\/AnyCharts","article_published_time":"2022-10-14T12:25:41+00:00","article_modified_time":"2022-10-14T13:07:17+00:00","og_image":[{"url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree-social.png","type":"","width":"","height":""}],"author":"Awan Shrestha","twitter_card":"summary_large_image","twitter_title":"How to Create a Word Tree Using JavaScript","twitter_description":"Learn how to quickly make cool interactive word tree charts in JS while visualizing Martin Luther King's I Have a Dream speech.","twitter_image":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree-social.png","twitter_creator":"@AnyChart","twitter_site":"@AnyChart","twitter_misc":{"Written by":"Awan Shrestha","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/#article","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/"},"author":{"name":"Awan Shrestha","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/3f107fdcb3fe326a63cd52812f5287c1"},"headline":"How to Create Word Tree Using JavaScript","datePublished":"2022-10-14T12:25:41+00:00","dateModified":"2022-10-14T13:07:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/"},"wordCount":1373,"commentCount":0,"image":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree.png","keywords":["analysis","analytics","AnyChart","app development","best data visualization examples","best data visualization software","best data visualization tool","best data visualization tools","big data","big data tools","chart","chart design","chart examples","chart types","charting","charts","data analysis","data analytics","data analytics examples","data chart","data charting","data charts","data design","data graphic","data graphics","Data Visualization","data visualization best practices","data visualization design","data visualization development","data visualization examples","data visualization guide","data visualization practice","data visualization projects","data visualization techniques","data visualization tool","data visualization tutorial","data visualizations","data visuals","data viz examples","dataviz examples","dataviz projects","developers","drawing tools","front-end development","graphics library","HTML","HTML charts","HTML5","html5 charts","I Have a Dream","infographic","infographics","interactive charts","interactive data visualization","interactive graphics","interactive infographic","interactive infographics","interactive visualizations","interactivity","JavaScript","javascript chart tutorial","javascript charting","javascript charting api","JavaScript charting features","JavaScript charting library","javascript charts","javascript drawing","javascript drawing library","javascript graph","javascript graphics","JavaScript graphics library","JavaScript library","javascript technologies","JavaScript Word Tree Chart","jQuery","js chart","js charting","js charts","JS graphics","maps","Marshall University","Martin Luther King","mobile app development","recap of the week","statistical analysis","statistics","text analysis","text data","text data visualization","text formatting","text visualization","Tips and tricks","top data visualization software","top data visualization tools","tutorial","visual analysis","visual analytics","visual data analytics","visualization","visualization techniques","visualizations","web charts","web design","web developers","web development","website","website development","Word Tree"],"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\/10\/14\/word-tree-js\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/","url":"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/","name":"Word Tree: How to Create This Chart Using JavaScript (HTML5)","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/#primaryimage"},"image":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree.png","datePublished":"2022-10-14T12:25:41+00:00","dateModified":"2022-10-14T13:07:17+00:00","author":{"@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/3f107fdcb3fe326a63cd52812f5287c1"},"description":"A word tree chart shows how selected words are connected to others in a text. Learn how to easily make it in JS while visualizing the I Have a Dream speech.","breadcrumb":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/#primaryimage","url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree.png","contentUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/10\/word-tree.png","width":1366,"height":768},{"@type":"BreadcrumbList","@id":"https:\/\/www.anychart.com\/blog\/2022\/10\/14\/word-tree-js\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.anychart.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Create Word Tree Using 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\/3f107fdcb3fe326a63cd52812f5287c1","name":"Awan Shrestha","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/02ebd18c927547ca82372246dddcc3aebfa98928cb91405eef1a63ece7f17518?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/02ebd18c927547ca82372246dddcc3aebfa98928cb91405eef1a63ece7f17518?s=96&r=g","caption":"Awan Shrestha"},"url":"https:\/\/www.anychart.com\/blog\/author\/awan-shrestha\/"}]}},"_links":{"self":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/15772","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\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/comments?post=15772"}],"version-history":[{"count":29,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/15772\/revisions"}],"predecessor-version":[{"id":15809,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/15772\/revisions\/15809"}],"wp:attachment":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/media?parent=15772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/categories?post=15772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/tags?post=15772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}