{"id":13543,"date":"2021-10-04T09:40:56","date_gmt":"2021-10-04T09:40:56","guid":{"rendered":"https:\/\/www.anychart.com\/blog\/?p=13543"},"modified":"2022-08-13T11:09:24","modified_gmt":"2022-08-13T11:09:24","slug":"javascript-word-tree-chart","status":"publish","type":"post","link":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/","title":{"rendered":"Building Word Tree Chart with JavaScript"},"content":{"rendered":"<p><a href=\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/\"><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js.png\" alt=\"Word Tree Chart built with JavaScript HTML5 on a screen\" width=\"100%\" class=\"alignnone size-full wp-image-13559\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js.png 1280w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js-300x169.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js-768x432.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js-1024x576.png 1024w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/a><a href=\"https:\/\/www.anychart.com\/blog\/2018\/11\/20\/data-visualization-definition-history-examples\/\">Data visualization<\/a> is not only useful for communicating insights but also helpful for data exploration. There are a whole lot of different chart types that are widely used for identifying patterns in data. One of the lesser-used chart types is <strong>Word Tree<\/strong>. It is a very interesting visualization form, quite effective in analyzing texts. And right now, I will teach you how to quickly create nice interactive word tree charts using JavaScript.<\/p>\n<p>Word trees display how a set of selected words are connected to other words in text data with a branching layout. These charts are similar to <a href=\"https:\/\/www.anychart.com\/chartopedia\/chart-type\/tag-cloud-chart\/\">word clouds<\/a> where words that occur more frequently are shown bigger. But they are different in the sense that word trees also show the connection between the words, which adds context and helps find patterns.<\/p>\n<p>In this tutorial, I will create a lovely word tree from the text of the very famous book <em><a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Little_Prince\" target=\"_blank\" rel=\"nofollow\">The Little Prince<\/a><\/em> by French aviator and writer Antoine de Saint-Exup\u00e9ry. Check out a demonstration of the final chart below and keep reading to learn how this and any other interactive JS word tree can be built with ease.<\/p>\n<p><!--more Read the JS charting tutorial \u00bb--><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js.gif\" alt=\"Animated demonstration of the complete interactive JS word tree chart data visualization\" width=\"100%\" class=\"alignnone size-full wp-image-13557\" \/><\/p>\n<h2>Making a Basic JavaScript Word Tree<\/h2>\n<p>An interactive JS word tree chart can look complicated. But follow along to learn how to build it in just four really simple steps.<\/p>\n<ul>\n<li>Create an HTML page.<\/li>\n<li>Include the required JavaScript files.<\/li>\n<li>Prepare the data.<\/li>\n<li>Add some JS code for the chart.<\/li>\n<\/ul>\n<h3>1. Create an HTML Page<\/h3>\n<p>The initial step is to create an HTML page that will hold the chart. In the page, add a <code>&lt;div&gt;<\/code> element with an id that will be referenced later.<\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n&nbsp;&nbsp;&lt;head&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;JavaScript Word Tree Chart&lt;\/title&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;style type=\"text\/css\"&gt;      \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;html, body, #container { \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 100%; height: 100%; margin: 0; padding: 0; \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} \r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/style&gt;\r\n&nbsp;&nbsp;&lt;\/head&gt;\r\n&nbsp;&nbsp;&lt;body&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n&nbsp;&nbsp;&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<p>To make the word tree occupy the whole page, specify the width and height parameters as 100%. This can be adjusted as per the requirements of your project.<\/p>\n<h3>2. Include the Required JavaScript Files<\/h3>\n<p>It is convenient to use a <a href=\"https:\/\/hackernoon.com\/10-javascript-charting-libraries-data-visualization-b77523d23372rd-tree-chart-with-javascript-xb9s35ur\" target=\"_blank\" rel=\"nofollow\">JavaScript charting library<\/a> to create the word trees. The best part of using such libraries is that out-of-the-box charts can be quickly made without advanced technical skills. In this tutorial, I am working with <a href=\"https:\/\/www.anychart.com\/\">AnyChart<\/a> based on its <a href=\"https:\/\/docs.anychart.com\/Basic_Charts\/Word_Tree\" target=\"_blank\" rel=\"nofollow\">word tree documentation<\/a>. It is free for non-commercial use, but anyway, it is only an example. The logic of data visualization remains quite similar for all JS charting libraries. So, basically, you can use this learning to create charts with others that have pre-built word trees, too.<\/p>\n<p>I will include the required JS files from the CDN of AnyChart in the <code>&lt;head&gt;<\/code> section of the HTML page. For the word tree chart, I need to add two scripts: the <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Modules#core\" target=\"_blank\" rel=\"nofollow\">core module<\/a> and the <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Modules#word_tree\" target=\"_blank\" rel=\"nofollow\">word tree module<\/a>.<\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n&nbsp;&nbsp;&lt;head&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;JavaScript Word Tree Chart&lt;\/title&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.10.0\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.10.0\/js\/anychart-wordtree.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;style type=\"text\/css\"&gt;      \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;html, body, #container { \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 100%; height: 100%; margin: 0; padding: 0; \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} \r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/style&gt;\r\n&nbsp;&nbsp;&lt;\/head&gt;\r\n&nbsp;&nbsp;&lt;body&gt;  \r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ All the code for the JS word tree chart will come here\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/script&gt;\r\n&nbsp;&nbsp;&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h3>3. Prepare the Data<\/h3>\n<p>I downloaded the text of the famous book <em>The Little Prince<\/em> by Antoine de Saint-Exup\u00e9ry from an <a href=\"https:\/\/books-library.net\/files\/books-library.online-12201041Ti6B3.pdf\" target=\"_blank\" rel=\"nofollow\">online library<\/a> and created the data file that you can download <a href=\"https:\/\/gist.githubusercontent.com\/shacheeswadia\/ccbccc482b1fb691405e07772c0fbfa0\/raw\/fb7b5972838b4212f4551c4cc9d5fc026fc2e8c3\/littleprince.txt\" target=\"_blank\" rel=\"nofollow\">here<\/a>.<\/p>\n<p>To access the data file, I need jQuery and therefore include its script in the code.<\/p>\n<pre><code class=\"html\">&lt;script src=\"https:\/\/code.jquery.com\/jquery-latest.min.js\"&gt;&lt;\/script&gt;<\/code><\/pre>\n<p>Now that all the preliminary steps are done, let\u2019s get to the main part. You are going to love how quickly a functional interactive word tree chart can be made with so few lines of JavaScript code.<\/p>\n<h3>4. Add Some JS Code for the Chart<\/h3>\n<p>Before writing any code, the first thing I do is add an enclosing function that executes the code inside it only after the page is ready and then loads the data file using Ajax.<\/p>\n<pre><code class=\"javascript\">anychart.onDocumentReady(function () {\r\n  $.ajax(\r\n\"https:\/\/gist.githubusercontent.com\/shacheeswadia\/ccbccc482b1fb691405e07772c0fbfa0\/raw\/fb7b5972838b4212f4551c4cc9d5fc026fc2e8c3\/littleprince.txt\"\r\n  ).done(function (text) {\r\n  });\r\n});<\/code><\/pre>\n<p>Next, I create the chart using the <code>wordtree()<\/code> function of the JS library.<\/p>\n<pre><code class=\"javascript\">var chart = anychart.wordtree(text);<\/code><\/pre>\n<p>In a word tree, an important part is defining the root words which branch out to various sentences in the text. Here, I define \u2018The\u2019 as the start of the root and drill down to \u2018prince\u2019 as the end of the root so the combined root words become \u2018the little prince\u2019.<\/p>\n<pre><code class=\"javascript\">\/\/ set the root word\r\nchart.word(\"The\");\r\n\r\n\/\/ drill down to the next word in the tree\r\nchart.drillTo(\"prince\");<\/code><\/pre>\n<p>Finally, I just need to set the container and draw the chart.<\/p>\n<pre><code class=\"javascript\">\/\/ set container id for the chart\r\nchart.container(\"container\");\r\n\r\n\/\/ initiate chart drawing\r\nchart.draw();<\/code><\/pre>\n<p>Voila, that\u2019s all I do to bring the interactive word tree to life on the web page!<\/p>\n<p><strong>You can check out this initial version of the JS word tree chart with the code below or on <a href=\"https:\/\/codepen.io\/shacheeswadia\/pen\/mdmpxeK\" target=\"_blank\" rel=\"nofollow\">CodePen<\/a> [or on <a href=\"https:\/\/playground.anychart.com\/8PmjouFW\/\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>].<\/strong><\/p>\n<p><iframe sandbox=\"allow-scripts allow-pointer-lock allow-same-origin\n                 allow-popups allow-modals allow-forms\" frameBorder=\"0\" class=\"anychart-embed anychart-embed-8PmjouFW\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/8PmjouFW\/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-8PmjouFW{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n&nbsp;&nbsp;&lt;head&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;JavaScript Word Tree Chart&lt;\/title&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.10.0\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.10.0\/js\/anychart-wordtree.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/code.jquery.com\/jquery-latest.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;style type=\"text\/css\"&gt;      \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;html, body, #container { \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 100%; height: 100%; margin: 0; padding: 0; \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} \r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/style&gt;\r\n&nbsp;&nbsp;&lt;\/head&gt;\r\n&nbsp;&nbsp;&lt;body&gt;  \r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;anychart.onDocumentReady(function () {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$.ajax(\r\n\"https:\/\/gist.githubusercontent.com\/shacheeswadia\/ccbccc482b1fb691405e07772c0fbfa0\/raw\/fb7b5972838b4212f4551c4cc9d5fc026fc2e8c3\/littleprince.txt\"\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;).done(function (text) {\r\n    \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ create word-tree chart\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var chart = anychart.wordtree(text);\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ set the root word\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.word(\"The\");\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ drill down to the next word in the tree\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.drillTo(\"prince\");\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ set container id for the chart\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.container(\"container\");\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ initiate chart drawing\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.draw();\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/script&gt;\r\n&nbsp;&nbsp;&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<p>This looks great but there is so much more that can be done to make the word tree look more polished and I will show you how to do that.<\/p>\n<h2>Customizing a JS Word Tree Chart<\/h2>\n<p>JS charting libraries are great to have a basic visual ready very fast and then a plethora of options to customize the chart. Let me show you how to make this word tree more beautiful and personalized.<\/p>\n<h3>1. Formatting the Connectors<\/h3>\n<p>The branches of our word tree look a bit squished so let&#8217;s modify them to make the tree appear more spaced out. There is an option to make straight line connectors which I will try and also change the stroke settings.<\/p>\n<pre><code class=\"javascript\">\/\/ configure the connectors\r\nvar connectors = chart.connectors();\r\nconnectors.length(100);\r\nconnectors.offset(10);\r\nconnectors.curveFactor(0);\r\nconnectors.stroke(\"0.5 #96a6a6\");<\/code><\/pre>\n<p>It\u2019s all quite straightforward and here is how our word tree looks with just these changes.<\/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-MegbT1wY\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/MegbT1wY\/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-MegbT1wY{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p><strong>The interactive version is available on <a href=\"https:\/\/codepen.io\/shacheeswadia\/pen\/KKmZoVP?ref=hackernoon.com\" target=\"_blank\" rel=\"nofollow\">CodePen<\/a> [and <a href=\"https:\/\/playground.anychart.com\/MegbT1wY\/\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>] where you can also find its full code.<\/strong><\/p>\n<p>To be honest, I like the curved connectors more, so going forward I restore them.<\/p>\n<h3>2. Configuring the Font Size and Color<\/h3>\n<p>I simply modify the font size and color to make the chart more individualized. Again, it&#8217;s quite simple and requires only a few lines of code.<\/p>\n<pre><code class=\"javascript\">\/\/ configure the font\r\nchart.fontColor(\"#1976d2\");\r\n\r\n\/\/ set chart's font size minimum and maximum\r\nchart.minFontSize(8);\r\nchart.maxFontSize(24);<\/code><\/pre>\n<h3>3. Adding Custom Drill-Down and Drill-Up Buttons<\/h3>\n<p>Did you notice how awesome the default drilling up and down is in the word tree? Just by clicking on a word, the chart automatically scales to that level.<\/p>\n<p>The inbuilt functionality is super but in case required, I will show you here how you can add a button to drill down to a specific word and also a button to drill up one level at a time.<\/p>\n<p>I create a container in HTML and add two buttons in it \u2014 one for drill down to my chosen word \u2018disappointed\u2019 and one for drill-up. You can of course choose any word that exists in the tree.<\/p>\n<pre><code class=\"html\">&lt;div id=\"buttons\"&gt;\r\n&nbsp;&nbsp;&lt;button onclick=\"drillToItem()\"&gt;Drill Down to \"disappointed\"&lt;\/button&gt;\r\n&nbsp;&nbsp;&lt;button onclick=\"drillUpALevel()\"&gt;Drill Up 1 Level&lt;\/button&gt;\r\n&lt;\/div&gt;<\/code><\/pre>\n<p>I also add the styling for the buttons.<\/p>\n<pre><code class=\"html\">&lt;style type=\"text\/css\"&gt;\r\n&nbsp;&nbsp;html,\r\n&nbsp;&nbsp;body,\r\n&nbsp;&nbsp;#container {\r\n&nbsp;&nbsp;&nbsp;&nbsp;width: 100%;\r\n&nbsp;&nbsp;&nbsp;&nbsp;height: 100%;\r\n&nbsp;&nbsp;&nbsp;&nbsp;margin: 0;\r\n&nbsp;&nbsp;&nbsp;&nbsp;padding: 0;\r\n&nbsp;&nbsp;}\r\n\r\n&nbsp;&nbsp;#buttons {\r\n&nbsp;&nbsp;&nbsp;&nbsp;display: flex;\r\n&nbsp;&nbsp;&nbsp;&nbsp;flex-direction: row;\r\n&nbsp;&nbsp;&nbsp;&nbsp;justify-content: flex-end;\r\n&nbsp;&nbsp;}\r\n\r\n&nbsp;&nbsp;button {\r\n&nbsp;&nbsp;&nbsp;&nbsp;width: 15vw;\r\n&nbsp;&nbsp;&nbsp;&nbsp;margin: 1rem;\r\n&nbsp;&nbsp;}\r\n&lt;\/style&gt;<\/code><\/pre>\n<p>Next, I add two functions, one that handles the drill down to the specified word and the other that drills up one level of the tree.<\/p>\n<pre><code class=\"javascript\">\/\/ drill down to a data item\r\nfunction drillToItem() {\r\n  \/\/ locate an item in the data tree and get it as an object\r\n  var item = chart.data().search(\"value\", \"disappointed\");\r\n  \/\/ drill down to the item\r\n  chart.drillTo(item);\r\n}\r\n\r\n\/\/ drill up a level\r\nfunction drillUpALevel() {\r\n  chart.drillUp();\r\n}<\/code><\/pre>\n<p><iframe sandbox=\"allow-scripts allow-pointer-lock allow-same-origin\n                 allow-popups allow-modals allow-forms\" frameBorder=\"0\" class=\"anychart-embed anychart-embed-CltVnYXE\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/CltVnYXE\/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-CltVnYXE{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p><strong>Have a look at the entire code of this awesome final JavaScript word tree chart here or on <a href=\"https:\/\/codepen.io\/shacheeswadia\/pen\/bGWaKBL\" target=\"_blank\" rel=\"nofollow\">CodePen<\/a> [or on <a href=\"https:\/\/playground.anychart.com\/CltVnYXE\/\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>].<\/strong><\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n&nbsp;&nbsp;&lt;head&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;JavaScript Word Tree Chart&lt;\/title&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.10.0\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.10.0\/js\/anychart-wordtree.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script src=\"https:\/\/code.jquery.com\/jquery-latest.min.js\"&gt;&lt;\/script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;style type=\"text\/css\"&gt;      \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;html, body, #container { \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 100%; height: 100%; margin: 0; padding: 0; \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#buttons{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display: flex;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flex-direction: row;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;justify-content: flex-end;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;button {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 15vw;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;margin: 1rem;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/style&gt;\r\n&nbsp;&nbsp;&lt;\/head&gt;\r\n&nbsp;&nbsp;&lt;body&gt;  \r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=\"buttons\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;button onclick=\"drillToItem()\"&gt;Drill Down to \"disappointed\"&lt;\/button&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;button onclick=\"drillUpALevel()\"&gt;Drill Up 1 Level&lt;\/button&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/div&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;script&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;anychart.onDocumentReady(function () {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$.ajax(\r\n\"https:\/\/gist.githubusercontent.com\/shacheeswadia\/ccbccc482b1fb691405e07772c0fbfa0\/raw\/fb7b5972838b4212f4551c4cc9d5fc026fc2e8c3\/littleprince.txt\"\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;).done(function (text) {\r\n    \r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ create word-tree chart\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var chart = anychart.wordtree(text);\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ set the root word\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.word(\"The\");\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ drill down to the next word in the tree\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.drillTo(\"prince\");\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ configure the connectors\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var connectors = chart.connectors();\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;connectors.length(100);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;connectors.offset(10);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;connectors.stroke(\"0.5 #96a6a6\");\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ configure the font\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.fontColor(\"#1976d2\");\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ set chart's font size minimum and maximum\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.minFontSize(8);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.maxFontSize(24);\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ set container id for the chart\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.container(\"container\");\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ initiate chart drawing\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.draw();\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var chart;\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ drill down to a data item\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function drillToItem() {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ locate an item in the data tree and get it as an object\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var item = chart.data().search(\"value\", \"disappointed\");\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ drill down to the item\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.drillTo(item);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ drill up a level\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function drillUpALevel() {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chart.drillUp();\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/script&gt;\r\n&nbsp;&nbsp;&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h2>Conclusion<\/h2>\n<p>So then, let\u2019s be honest. Wasn\u2019t this really easy and so cool to build?<\/p>\n<p>If you want to keep learning and playing with this visualization, see the <a href=\"https:\/\/docs.anychart.com\/Basic_Charts\/Word_Tree\" target=\"_blank\" rel=\"nofollow\">word tree documentation<\/a> and get some inspiration from these <a href=\"https:\/\/www.anychart.com\/products\/anychart\/gallery\/Word_Tree\/\">examples<\/a>. Or pick another <a href=\"https:\/\/en.wikipedia.org\/wiki\/Comparison_of_JavaScript_charting_libraries\" target=\"_blank\" rel=\"nofollow\">JS charting library<\/a> and try to go with it based on the same technique.<\/p>\n<p><em>The Little Prince<\/em> gives us profound wisdom. And JavaScript is great for creating interactive charts. So, let&#8217;s use both and make some stunning visualizations!<\/p>\n<hr \/>\n<p><strong><em>Published with the permission of Shachee Swadia. Originally appeared on <a href=\"https:\/\/hackernoon.com\/creating-an-interactive-word-tree-chart-with-javascript-xb9s35ur\" target=\"_blank\" rel=\"nofollow\">Hacker Noon<\/a> under the title &#8220;Creating an Interactive Word Tree Chart with JavaScript&#8221; on September 2, 2021.<\/em><\/strong><\/p>\n<hr \/>\n<p><strong><em>Find out more about word tree charts on <a href=\"https:\/\/www.anychart.com\/chartopedia\/chart-type\/word-tree\/\">Chartopedia<\/a> and\u00a0see other <a href=\"https:\/\/www.anychart.com\/blog\/category\/javascript-chart-tutorials\/\">JavaScript charting tutorials<\/a> on our blog.<\/em><\/strong><\/p>\n<hr \/>\n<p><strong><em>Got an awesome guest post idea?\u00a0<a href=\"https:\/\/www.anychart.com\/support\/\">Get in touch!<\/a><\/em><\/strong><\/p>\n<p><!-- SyntaxHighlighter --><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/default.min.css\"><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/atom-one-light.min.css\"><script src=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/highlight.min.js\"><\/script><script>hljs.initHighlightingOnLoad();<\/script><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Data visualization is not only useful for communicating insights but also helpful for data exploration. There are a whole lot of different chart types that are widely used for identifying patterns in data. One of the lesser-used chart types is Word Tree. It is a very interesting visualization form, quite effective in analyzing texts. And [&hellip;]<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,263,26,23,13,279,4],"tags":[843,1982,2840,53,260,265,42,254,1758,284,127,258,471,266,620,509,2220,2838,54,1389,1760,2757,256,1111,350,744,844,165,313,1370,133,774,2223,805,1762,1025,2013,2014,32,55,1335,144,2016,146,152,36,907,141,249,81,57,1238,142,96,99,573,58,65,56,101,459,908,909,1534,2839,30,2224,172,807,832,954,293,745,899,2816,1763,804,558],"class_list":["post-13543","post","type-post","status-publish","format-standard","hentry","category-anychart-charting-component","category-big-data","category-books","category-html5","category-javascript","category-javascript-chart-tutorials","category-tips-and-tricks","tag-advanced-data-visualization","tag-angular-charts","tag-antoine-de-saint-exupery","tag-anychart","tag-best-data-visualization-examples","tag-big-data","tag-books","tag-chart","tag-chart-design","tag-chart-examples","tag-chart-types","tag-charts","tag-data-analysis","tag-data-analytics","tag-data-analytics-examples","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-techniques","tag-data-visualization-tutorial","tag-data-visualizations","tag-data-visuals","tag-data-viz-examples","tag-dataviz","tag-dataviz-examples","tag-diagrams","tag-front-end-development","tag-guest-post","tag-hacker-noon","tag-html","tag-html-charts","tag-html5","tag-html5-charts","tag-infographic","tag-infographics","tag-information-visualization","tag-interactive-data-visualization","tag-interactive-infographic","tag-javascript","tag-javascript-chart-tutorial","tag-javascript-charting","tag-javascript-charting-api","tag-javascript-charting-library","tag-javascript-charts","tag-javascript-graph","tag-javascript-graphics","tag-javascript-graphics-library","tag-javascript-library","tag-javascript-word-tree-chart","tag-js-chart","tag-js-charting","tag-js-charts","tag-js-graphics","tag-statistics","tag-text-data","tag-text-data-visualization","tag-text-visualization","tag-the-little-prince","tag-tips-and-tricks","tag-tree-data","tag-tutorial","tag-visual-analysis","tag-visual-data","tag-visual-data-analytics","tag-visualization","tag-visualization-techniques","tag-visualizations","tag-web-design","tag-web-developers","tag-web-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>Building Interactive Word Tree Chart with JavaScript | The Little Prince<\/title>\n<meta name=\"description\" content=\"Learn how to create awesome word trees using JavaScript and check out a cool JS word tree chart visualizing the text of The Little Prince for illustration.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Build Word Tree Chart with JavaScript\" \/>\n<meta property=\"og:description\" content=\"Learn how to create JavaScript word trees and check out a cool JS word tree chart visualizing the text of The Little Prince.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-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=\"2021-10-04T09:40:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-13T11:09:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js-social.png\" \/>\n<meta name=\"author\" content=\"Shachee Swadia\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to Build Word Tree Chart with JavaScript\" \/>\n<meta name=\"twitter:description\" content=\"Learn how to create JavaScript word trees and check out a cool JS word tree chart visualizing the text of The Little Prince.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js-social.png\" \/>\n<meta name=\"twitter:creator\" content=\"@AnyChart\" \/>\n<meta name=\"twitter:site\" content=\"@AnyChart\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shachee Swadia\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/\"},\"author\":{\"name\":\"Shachee Swadia\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\"},\"headline\":\"Building Word Tree Chart with JavaScript\",\"datePublished\":\"2021-10-04T09:40:56+00:00\",\"dateModified\":\"2022-08-13T11:09:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/\"},\"wordCount\":1187,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js.png\",\"keywords\":[\"advanced data visualization\",\"Angular charts\",\"Antoine de Saint-Exup\u00e9ry\",\"AnyChart\",\"best data visualization examples\",\"big data\",\"Books\",\"chart\",\"chart design\",\"chart examples\",\"chart types\",\"charts\",\"data analysis\",\"data analytics\",\"data analytics examples\",\"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 techniques\",\"data visualization tutorial\",\"data visualizations\",\"data visuals\",\"data viz examples\",\"dataviz\",\"dataviz examples\",\"diagrams\",\"front-end development\",\"guest post\",\"Hacker Noon\",\"HTML\",\"HTML charts\",\"HTML5\",\"html5 charts\",\"infographic\",\"infographics\",\"information visualization\",\"interactive data visualization\",\"interactive infographic\",\"JavaScript\",\"javascript chart tutorial\",\"javascript charting\",\"javascript charting api\",\"JavaScript charting library\",\"javascript charts\",\"javascript graph\",\"javascript graphics\",\"JavaScript graphics library\",\"JavaScript library\",\"JavaScript Word Tree Chart\",\"js chart\",\"js charting\",\"js charts\",\"JS graphics\",\"statistics\",\"text data\",\"text data visualization\",\"text visualization\",\"The Little Prince\",\"Tips and tricks\",\"tree data\",\"tutorial\",\"visual analysis\",\"visual data\",\"visual data analytics\",\"visualization\",\"visualization techniques\",\"visualizations\",\"web design\",\"web developers\",\"web development\",\"Word Tree\"],\"articleSection\":[\"AnyChart Charting Component\",\"Big Data\",\"Books\",\"HTML5\",\"JavaScript\",\"JavaScript Chart Tutorials\",\"Tips and Tricks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/\",\"url\":\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/\",\"name\":\"Building Interactive Word Tree Chart with JavaScript | The Little Prince\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js.png\",\"datePublished\":\"2021-10-04T09:40:56+00:00\",\"dateModified\":\"2022-08-13T11:09:24+00:00\",\"author\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\"},\"description\":\"Learn how to create awesome word trees using JavaScript and check out a cool JS word tree chart visualizing the text of The Little Prince for illustration.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#primaryimage\",\"url\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js.png\",\"contentUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js.png\",\"width\":1280,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.anychart.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building Word Tree Chart with JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\",\"url\":\"https:\/\/www.anychart.com\/blog\/\",\"name\":\"AnyChart News\",\"description\":\"AnyChart JS Charts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.anychart.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\",\"name\":\"Shachee Swadia\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g\",\"caption\":\"Shachee Swadia\"},\"url\":\"https:\/\/www.anychart.com\/blog\/author\/shachee-swadia\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Building Interactive Word Tree Chart with JavaScript | The Little Prince","description":"Learn how to create awesome word trees using JavaScript and check out a cool JS word tree chart visualizing the text of The Little Prince for illustration.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/","og_locale":"en_US","og_type":"article","og_title":"How to Build Word Tree Chart with JavaScript","og_description":"Learn how to create JavaScript word trees and check out a cool JS word tree chart visualizing the text of The Little Prince.","og_url":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/","og_site_name":"AnyChart News","article_publisher":"https:\/\/www.facebook.com\/AnyCharts","article_published_time":"2021-10-04T09:40:56+00:00","article_modified_time":"2022-08-13T11:09:24+00:00","og_image":[{"url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js-social.png","type":"","width":"","height":""}],"author":"Shachee Swadia","twitter_card":"summary_large_image","twitter_title":"How to Build Word Tree Chart with JavaScript","twitter_description":"Learn how to create JavaScript word trees and check out a cool JS word tree chart visualizing the text of The Little Prince.","twitter_image":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js-social.png","twitter_creator":"@AnyChart","twitter_site":"@AnyChart","twitter_misc":{"Written by":"Shachee Swadia","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#article","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/"},"author":{"name":"Shachee Swadia","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51"},"headline":"Building Word Tree Chart with JavaScript","datePublished":"2021-10-04T09:40:56+00:00","dateModified":"2022-08-13T11:09:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/"},"wordCount":1187,"commentCount":0,"image":{"@id":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js.png","keywords":["advanced data visualization","Angular charts","Antoine de Saint-Exup\u00e9ry","AnyChart","best data visualization examples","big data","Books","chart","chart design","chart examples","chart types","charts","data analysis","data analytics","data analytics examples","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 techniques","data visualization tutorial","data visualizations","data visuals","data viz examples","dataviz","dataviz examples","diagrams","front-end development","guest post","Hacker Noon","HTML","HTML charts","HTML5","html5 charts","infographic","infographics","information visualization","interactive data visualization","interactive infographic","JavaScript","javascript chart tutorial","javascript charting","javascript charting api","JavaScript charting library","javascript charts","javascript graph","javascript graphics","JavaScript graphics library","JavaScript library","JavaScript Word Tree Chart","js chart","js charting","js charts","JS graphics","statistics","text data","text data visualization","text visualization","The Little Prince","Tips and tricks","tree data","tutorial","visual analysis","visual data","visual data analytics","visualization","visualization techniques","visualizations","web design","web developers","web development","Word Tree"],"articleSection":["AnyChart Charting Component","Big Data","Books","HTML5","JavaScript","JavaScript Chart Tutorials","Tips and Tricks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/","url":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/","name":"Building Interactive Word Tree Chart with JavaScript | The Little Prince","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#primaryimage"},"image":{"@id":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js.png","datePublished":"2021-10-04T09:40:56+00:00","dateModified":"2022-08-13T11:09:24+00:00","author":{"@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51"},"description":"Learn how to create awesome word trees using JavaScript and check out a cool JS word tree chart visualizing the text of The Little Prince for illustration.","breadcrumb":{"@id":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#primaryimage","url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js.png","contentUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2021\/09\/word-tree-chart-js.png","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/www.anychart.com\/blog\/2021\/10\/04\/javascript-word-tree-chart\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.anychart.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Building Word Tree Chart with JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/www.anychart.com\/blog\/#website","url":"https:\/\/www.anychart.com\/blog\/","name":"AnyChart News","description":"AnyChart JS Charts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.anychart.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51","name":"Shachee Swadia","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g","caption":"Shachee Swadia"},"url":"https:\/\/www.anychart.com\/blog\/author\/shachee-swadia\/"}]}},"_links":{"self":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/13543","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=13543"}],"version-history":[{"count":23,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/13543\/revisions"}],"predecessor-version":[{"id":15519,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/13543\/revisions\/15519"}],"wp:attachment":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/media?parent=13543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/categories?post=13543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/tags?post=13543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}