{"id":8275,"date":"2019-08-01T12:21:08","date_gmt":"2019-08-01T12:21:08","guid":{"rendered":"https:\/\/www.anychart.com\/blog\/?p=8275"},"modified":"2022-08-13T10:57:41","modified_gmt":"2022-08-13T10:57:41","slug":"treemap-chart-create-javascript","status":"publish","type":"post","link":"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/","title":{"rendered":"Creating Treemap Chart Using JavaScript"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.png\" alt=\"Creating Treemap Chart Using JavaScript, a tutorial for web developers and data enthusiasts\" width=\"100%\" class=\"alignnone size-full wp-image-8298\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.png 1088w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-300x170.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-768x436.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-1024x581.png 1024w\" sizes=\"(max-width: 1088px) 100vw, 1088px\" \/><a href=\"https:\/\/www.anychart.com\/chartopedia\/chart-type\/treemap\/\">Treemap<\/a> is a popular chart type for hierarchical data visualization. I\u2019ll show you how to create a cool interactive treemap chart using JavaScript in four simple steps right now. Join me on this quick tutorial for front-end web developers and data viz enthusiasts to understand the core principles of the process. Basically, I am sure everyone at least a little familiar with coding in HTML5 will love the presented, easy way to make beautiful JavaScript treemap charts that are perfectly suitable to be embedded into any web page or app.<\/p>\n<p>In honor of World Wide Web Day celebrated today, August 1, I will develop a JS treemap visualizing data about the number of worldwide internet users as of January 2019, by region, available on <a href=\"https:\/\/www.statista.com\/statistics\/249562\/number-of-worldwide-internet-users-by-region\/\" target=\"_blank\" rel=\"nofollow\">Statista<\/a>.<\/p>\n<p><!--more Read the JS charting tutorial \u00bb--><\/p>\n<h2>How to Create JavaScript Treemap Chart<\/h2>\n<p>To start with, here&#8217;s a basic thing you should clearly understand and remember. When it comes to data visualization using JavaScript, charting generally takes four main steps:<\/p>\n<ol>\n<li>First, create an HTML page with a container for a chart.<\/li>\n<li>Second, connect all the scripts you need.<\/li>\n<li>Third, load the data you need to visualize.<\/li>\n<li>Finally, write the JS chart code.<\/li>\n<\/ol>\n<p>Now, let&#8217;s delve into each of these steps for streamlined, first-class JavaScript charting and build an awesome treemap.<\/p>\n<h3>Step 1: Create an HTML page<\/h3>\n<p>Before you actually begin to draw a treemap chart, create an HTML page on which your visualization will be placed.<\/p>\n<p>Below is a very basic example of how it can look.<\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;My First JavaScript Treemap Chart&lt;\/title&gt;\r\n    &lt;style&gt;\r\n      html, body, #container {\r\n        width: 100%;\r\n        height: 100%;\r\n        margin: 0;\r\n        padding: 0;\r\n      }\r\n    &lt;\/style&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n    &lt;div id=\"container\">&lt;\/div&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<p>The most important part here is, I&#8217;ve created a chart container in the <code>&lt;head&gt;<\/code> section of the HTML code. It is a block-level HTML element in which the chart will be drawn. You are welcome to configure the chart container parameters in the <code>&lt;style&gt;<\/code> script added to the <code>&lt;head&gt;<\/code> section to your liking. I want my treemap to occupy the entire page, so I&#8217;ve specified 100% in the width and height fields to make it happen just like that.<\/p>\n<p>You see I&#8217;ve also added a relevant web page title right away: &#8220;My First JavaScript Treemap Chart.&#8221;<\/p>\n<h3>Step 2: Connect scripts<\/h3>\n<p>Next, connect all the scripts that are necessary to create a treemap chart you want to get.<\/p>\n<p>I am using the <a href=\"https:\/\/www.anychart.com\">JavaScript charts library<\/a> by AnyChart, which is a powerful, flexible solution with comprehensive <a href=\"https:\/\/api.anychart.com\" target=\"_blank\" rel=\"nofollow\">API reference<\/a> and <a href=\"https:\/\/docs.anychart.com\" target=\"_blank\" rel=\"nofollow\">documentation<\/a>, free for non-profit use. It features a modular system that allows me to connect only those chart types and features I actually need, which helps to reduce the size of my JavaScript and speed up everything.<\/p>\n<p>To represent data on a treemap chart, the core and treemap modules are required. So I reference them in the <code>&lt;head&gt;<\/code> section, in separate <code>&lt;script&gt;<\/code> tags:<\/p>\n<pre><code class=\"html\">&lt;script&gt;https:\/\/cdn.anychart.com\/releases\/v8\/js\/anychart-core.min.js&lt;\/script&gt;\r\n&lt;script&gt;https:\/\/cdn.anychart.com\/releases\/v8\/js\/anychart-treemap.min.js&lt;\/script&gt;<\/code><\/pre>\n<p>If you prefer to launch these scripts locally instead of making use of the <a href=\"https:\/\/cdn.anychart.com\" target=\"_blank\" rel=\"nofollow\">AnyChart CDN<\/a>, you can <a href=\"https:\/\/www.anychart.com\/download\/\">download<\/a> them into a folder on your website and use your own URLs.<\/p>\n<p>AnyChart has no dependencies, so there is no need to connect anything else.<\/p>\n<p>The treemap chart&#8217;s JavaScript code will be written in the <code>&lt;script&gt;<\/code> tag inserted in the <code>&lt;body&gt;<\/code> section.<\/p>\n<p>Check out how the code framework looks as of now:<\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;My First JavaScript Treemap Chart&lt;\/title&gt;\r\n      &lt;script&gt;https:\/\/cdn.anychart.com\/releases\/v8\/js\/anychart-core.min.js&lt;\/script&gt;\r\n      &lt;script&gt;https:\/\/cdn.anychart.com\/releases\/v8\/js\/anychart-treemap.min.js&lt;\/script&gt;\r\n      &lt;style&gt;\r\n        html, body, #container {\r\n          width: 100%;\r\n          height: 100%;\r\n          margin: 0;\r\n          padding: 0;\r\n        }\r\n    &lt;\/style&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n    &lt;script&gt;\r\n\t&lt;!-- The treemap chart code will be written here --&gt;\r\n    &lt;\/script&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\n<h3>Step 3: Load data<\/h3>\n<p>Now that we&#8217;ve prepared a place for the treemap graph visualization (step 1) and referenced the JS charting library scripts (step 2), all is set to get to the essence \u2014 load data (step 3) and actually plot it on a treemap (step 4).<\/p>\n<p>The AnyChart JS library allows web developers to choose from a range of ways to work with data. To create treemap charts, it is necessary to apply the tree data model, organizing data as a tree, as a table, or as a CSV string.<\/p>\n<p>In this case, I\u2019ve decided to organize data as a tree, with every parent item provided with a children data field containing an array of child items:<\/p>\n<pre><code class=\"js\">var data = [\r\n  {name: \"World\", children: [\r\n    {name: \"Asia\", children: [\r\n      {name: \"East\", value: 1000},\r\n      {name: \"Southern\", value: 803},\r\n      {name: \"Southeast\", value: 415},\r\n      {name: \"Western\", value: 182},\r\n      {name: \"Central\", value: 36}\r\n    ]},\r\n    {name: \"America\", children: [\r\n      {name: \"North\", value: 346},\r\n      {name: \"South\", value: 316},\r\n      {name: \"Central\", value: 114},\r\n      {name: \"Caribbean\", value: 23}\r\n    ]},\r\n    {name: \"Europe\", children: [\r\n      {name: \"Eastern\", value: 233},\r\n      {name: \"Western\", value: 183},\r\n      {name: \"Southern\", value: 135},\r\n      {name: \"Northern\", value: 100}\r\n    ]},\r\n    {name: \"Africa\", children: [\r\n      {name: \"Western\", value: 158},\r\n      {name: \"Eastern\", value: 140},\r\n      {name: \"Northern\", value: 121},\r\n      {name: \"Southern\", value: 34},\r\n      {name: \"Middle\", value: 20}\r\n    ]},\r\n    {name: \"Oceania\", children: [\r\n      {name: \"Oceania\", value: 29}\r\n    ]}\r\n  ]}\r\n];<\/code><\/pre>\n<h3>Step 4: Code the JS treemap chart<\/h3>\n<p>Now, let&#8217;s code the visualization.<\/p>\n<p>The entire JS chart code must be included in the <code>anychart.onDocumentReady()<\/code> function within the <code>&lt;script&gt;<\/code> tag. So first, add the function:<\/p>\n<pre><code class=\"html,js\">&lt;script&gt;\r\n  anychart.onDocumentReady(function() {\r\n    \/\/ the entire code of the treemap chart will be here\r\n  });\r\n&lt;\/script&gt;<\/code><\/pre>\n<p>Second, add the data from step 3 and command to create a data tree:<\/p>\n<pre><code class=\"js\">anychart.onDocumentReady(function() {\r\n\r\n  \/\/ create data\r\n  var data = [\r\n    {name: \"World\", children: [\r\n      {name: \"Asia\", children: [\r\n        {name: \"East\", value: 1000},\r\n        {name: \"Southern\", value: 803},\r\n        {name: \"Southeast\", value: 415},\r\n        {name: \"Western\", value: 182},\r\n        {name: \"Central\", value: 36}\r\n      ]},\r\n      {name: \"America\", children: [\r\n        {name: \"North\", value: 346},\r\n        {name: \"South\", value: 316},\r\n        {name: \"Central\", value: 114},\r\n        {name: \"Caribbean\", value: 23}\r\n      ]},\r\n      {name: \"Europe\", children: [\r\n        {name: \"Eastern\", value: 233},\r\n        {name: \"Western\", value: 183},\r\n        {name: \"Southern\", value: 135},\r\n        {name: \"Northern\", value: 100}\r\n      ]},\r\n      {name: \"Africa\", children: [\r\n        {name: \"Western\", value: 158},\r\n        {name: \"Eastern\", value: 140},\r\n        {name: \"Northern\", value: 121},\r\n        {name: \"Southern\", value: 34},\r\n        {name: \"Middle\", value: 20}\r\n      ]},\r\n      {name: \"Oceania\", children: [\r\n        {name: \"Oceania\", value: 29}\r\n      ]}\r\n    ]}\r\n  ];\r\n\r\n  \/\/ create a data tree\r\n  treeData = anychart.data.tree(data, \"as-tree\");\r\n\r\n});<\/code><\/pre>\n<p>Third, add the following line to create a treemap chart based on the data tree:<\/p>\n<pre><code class=\"js\">var chart = anychart.treeMap(treeData);<\/code><\/pre>\n<p>Fourth, <a href=\"https:\/\/www.anychart.com\/blog\/2017\/04\/05\/chart-captions-title-graph-tips\/\">name the chart<\/a> to make it clear what is displayed on the graphics:<\/p>\n<pre><code class=\"js\">chart.title(\"Internet Audience Worldwide (in million users)\");<\/code><\/pre>\n<p>Finally, command to draw the treemap chart in the container:<\/p>\n<pre><code class=\"js\">\/\/ set the container id\r\nchart.container(\"container\");\r\n\r\n\/\/ draw the chart\r\nchart.draw();<\/code><\/pre>\n<p>There you go: Check out the interactive treemap chart just built with JavaScript!<\/p>\n<h3>Result: Treemap chart built with JavaScript<\/h3>\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-jCUyq1p2\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/jCUyq1p2\/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-jCUyq1p2{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>Note that the treemap chart comes with pre-determined visual design and interactivity settings by default. In particular, it features the awesome drill down behavior: When you click on a data point, you drill down to its child items. To return and drill up to a higher level, click on the header.<\/p>\n<p>You are welcome to check out this <a href=\"https:\/\/playground.anychart.com\/jCUyq1p2\/\" target=\"_blank\" rel=\"nofollow\">basic treemap chart example on the AnyChart Playground<\/a> and play with its code right there.<\/p>\n<p>For your convenience, here&#8217;s the full HTML code of this treemap:<\/p>\n<pre><code class=\"html,js\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;My First JavaScript Treemap Chart&lt;\/title&gt;\r\n    &lt;script&gt;https:\/\/cdn.anychart.com\/releases\/v8\/js\/anychart-core.min.js&lt;\/script&gt;\r\n    &lt;script&gt;https:\/\/cdn.anychart.com\/releases\/v8\/js\/anychart-treemap.min.js&lt;\/script&gt;\r\n    &lt;style&gt;\r\n      html, body, #container {\r\n        width: 100%;\r\n        height: 100%;\r\n        margin: 0;\r\n        padding: 0;\r\n      }\r\n    &lt;\/style&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n    &lt;script&gt;\r\n      anychart.onDocumentReady(function() {\r\n\r\n        \/\/ create data\r\n        var data = [\r\n          {name: \"World\", children: [\r\n            {name: \"Asia\", children: [\r\n              {name: \"East\", value: 1000},\r\n              {name: \"Southern\", value: 803},\r\n              {name: \"Southeast\", value: 415},\r\n              {name: \"Western\", value: 182},\r\n              {name: \"Central\", value: 36}\r\n            ]},\r\n            {name: \"America\", children: [\r\n              {name: \"North\", value: 346},\r\n              {name: \"South\", value: 316},\r\n              {name: \"Central\", value: 114},\r\n              {name: \"Caribbean\", value: 23}\r\n            ]},\r\n            {name: \"Europe\", children: [\r\n              {name: \"Eastern\", value: 233},\r\n              {name: \"Western\", value: 183},\r\n              {name: \"Southern\", value: 135},\r\n              {name: \"Northern\", value: 100}\r\n            ]},  \r\n            {name: \"Africa\", children: [\r\n              {name: \"Western\", value: 158},\r\n              {name: \"Eastern\", value: 140},\r\n              {name: \"Northern\", value: 121},\r\n              {name: \"Southern\", value: 34},\r\n              {name: \"Middle\", value: 20}\r\n            ]},  \r\n            {name: \"Oceania\", children: [\r\n              {name: \"Oceania\", value: 29}\r\n            ]}  \r\n          ]} \r\n        ];\r\n  \r\n        \/\/ create a data tree\r\n        var treeData = anychart.data.tree(data, \"as-tree\");\r\n\r\n        \/\/ create a treemap chart visualizing the data tree\r\n        var chart = anychart.treeMap(treeData);\r\n  \r\n        \/\/ add a title for the chart\r\n        chart.title(\"Internet Audience Worldwide (in million users)\");\r\n\r\n        \/\/ specify the container id\r\n        chart.container(\"container\");\r\n\r\n        \/\/ draw the chart\r\n        chart.draw();\r\n  \r\n      });\r\n    &lt;\/script&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h2>How to Customize JS Treemap Chart Design<\/h2>\n<p>So, the treemap chart built just above has basic visual features according to the default settings configured for this chart type in the AnyChart library. However, it is possible to customize everything real quick in compliance with your personal preferences or corporate (brand) requirements for design, if needed.<\/p>\n<p>I&#8217;ll show you some examples below so you can learn how to create an even better-looking treemap chart in a matter of minutes or seconds.<\/p>\n<h3>Add hints<\/h3>\n<p>By default, treemaps show data points that belong to the same hierarchy level only. But you have full control over what to display. For example, I want to outline the lower-level child items, keeping them slightly visible so anyone viewing the chart (e.g. a data analyst) can judge them as well on the big picture.<\/p>\n<p>To show such hints, I make use of the <code>hintDepth()<\/code> method with the value 1, meaning that I want the elements of one more level to be indicated on the treemap:<\/p>\n<pre><code class=\"js\">chart.hintDepth(1);<\/code><\/pre>\n<p>To avoid attracting too much attention to the lower-level elements when the higher-level elements are shown, I reduce the hint opacity:<\/p>\n<pre><code class=\"js\">chart.hintOpacity(0.7);<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints.png\" alt=\"Customized interactive JavaScript treemap chart with visible hints\" width=\"100%\" class=\"alignnone size-full wp-image-8277\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints.png 1240w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints-300x150.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints-768x383.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints-1024x510.png 1024w\" sizes=\"(max-width: 1240px) 100vw, 1240px\" \/><\/p>\n<h3>Change colors<\/h3>\n<p>Also, you can quickly change the treemap chart design in terms of coloring.<\/p>\n<p>For example, I want to change some of the appearance settings for the hovered, selected, and normal states by setting custom fill and stroke settings. To get such a new picture, I combine the <code>hovered()<\/code>, <code>selected()<\/code>, and <code>normal()<\/code> methods with the <code>fill()<\/code> \u2014 <code>hatchFill()<\/code> for the hatch fill type \u2014 and <code>stroke()<\/code> methods, specifying the colors and opacity parameters right there:<\/p>\n<pre><code class=\"js\">chart.hovered().fill(\"silver\", 0.2);\r\nchart.selected().fill(\"silver\", 0.6);\r\nchart.selected().hatchFill(\"backward-diagonal\", \"silver\", 2, 20);\r\nchart.normal().stroke(\"silver\");\r\nchart.hovered().stroke(\"gray\", 2);\r\nchart.selected().stroke(\"gray\", 2);<\/code><\/pre>\n<p>In addition, I\u2019ve decided to make a custom color scale, apply it to the treemap chart, and display the corresponding color range at the bottom. Follow me along the code to grasp the idea:<\/p>\n<pre><code class=\"js\">\/\/ create and configure a custom color scale\r\nvar customColorScale = anychart.scales.linearColor();\r\ncustomColorScale.colors([\"Yellow\", \"MediumPurple\"]);\r\n\r\n\/\/ apply the custom color scale to the treemap chart\r\nchart.colorScale(customColorScale);\r\n\r\n\/\/ add a color range\r\nchart.colorRange().enabled(true);\r\nchart.colorRange().length(\"100%\");<\/code><\/pre>\n<p>To see all supported web colors with their hexadecimal and RGB codes, refer to <a href=\"https:\/\/docs.anychart.com\/Appearance_Settings\/Colors_Table\" target=\"_blank\" rel=\"nofollow\">Color Table<\/a>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints-color.png\" alt=\"Customized interactive JavaScript treemap chart with visible hints and new colors\" width=\"100%\" class=\"alignnone size-full wp-image-8278\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints-color.png 1121w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints-color-300x165.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints-color-768x422.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints-color-1024x563.png 1024w\" sizes=\"(max-width: 1121px) 100vw, 1121px\" \/><\/p>\n<h3>Enable HTML in treemap elements<\/h3>\n<p>Last but not least, I&#8217;ll show you how to customize the tooltips, labels, and titles with the help of HTML. It&#8217;s very easy, too.<\/p>\n<p>Begin with enabling HTML for the corresponding parts of the chart by adding of the <code>useHtml()<\/code> method with the <code>true<\/code> value.<\/p>\n<p>Then, feel free to use HTML. For example:<\/p>\n<p>HTML in the treemap chart title:<\/p>\n<pre><code class=\"js\">\/\/ enable HTML in the chart title\r\nchart.title().useHtml(true);\r\n\/\/ configure the chart title\r\nchart.title(\r\n  \"&lt;span style='font-size:18; font-style:bold'&gt;Internet Audience Worldwide&lt;\/span&gt;&lt;br&gt;&lt;i&gt;&lt;span style='font-size:14; font-style:italic'&gt;In million users&lt;\/i&gt;\"\r\n);\r\n<\/code><\/pre>\n<p>HTML in treemap tooltips:<\/p>\n<pre><code class=\"js\">\/\/ enable HTML in the chart tooltips\r\nchart.tooltip().useHtml(true);\r\n\/\/ configure the chart tooltips\r\nchart.tooltip().format(\r\n  \"Internet audience: {%value} million users&lt;br&gt;&lt;i&gt;(As of January 2019.)&lt;\/i&gt;\"\r\n);\r\n<\/code><\/pre>\n<p>HTML in treemap labels:<\/p>\n<pre><code class=\"js\">\/\/ enable HTML in the chart labels\r\nchart.labels().useHtml(true);\r\n\/\/ configure the chart labels\r\nchart.labels().format(\r\n  \"&lt;span style='font-weight:bold'&gt;{%name}&lt;\/span&gt;&lt;br&gt;{%value}\"\r\n);\r\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints-color-html.png\" alt=\"Customized interactive JavaScript treemap chart with visible hints, new colors, and HTML in tooltips, labels, and titles\" width=\"100%\" class=\"alignnone size-full wp-image-8279\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints-color-html.png 1118w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints-color-html-300x166.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints-color-html-768x424.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial-basic-hints-color-html-1024x565.png 1024w\" sizes=\"(max-width: 1118px) 100vw, 1118px\" \/><\/p>\n<h3>Result: Custom treemap chart built with JavaScript<\/h3>\n<p>Below is the resulting, customized JavaScript (HTML5) treemap chart. Needless to say, there are a lot of other settings you can adjust to get the data visualization you want and you can actually modify everything. See the <a href=\"https:\/\/docs.anychart.com\/Basic_Charts\/Treemap_Chart\" target=\"_blank\" rel=\"nofollow\">Treemap Chart documentation<\/a> to delve into more details on exactly what is possible and how, with code samples and illustrations.<\/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-\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/Up2BCFGq\/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-{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>Take a look at this <a href=\"https:\/\/playground.anychart.com\/Up2BCFGq\/\" target=\"_blank\" rel=\"nofollow\">customized treemap chart on the AnyChart Playground<\/a>.<\/p>\n<p>Here&#8217;s the full HTML code of this treemap:<\/p>\n<pre><code class=\"html,js\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;My First JavaScript Treemap Chart&lt;\/title&gt;\r\n      &lt;script&gt;https:\/\/cdn.anychart.com\/releases\/v8\/js\/anychart-core.min.js&lt;\/script&gt;\r\n      &lt;script&gt;https:\/\/cdn.anychart.com\/releases\/v8\/js\/anychart-treemap.min.js&lt;\/script&gt;\r\n      &lt;style&gt;\r\n        html, body, #container {\r\n          width: 100%;\r\n          height: 100%;\r\n          margin: 0;\r\n          padding: 0;\r\n        }\r\n    &lt;\/style&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n    &lt;script&gt;\r\n      anychart.onDocumentReady(function() {\r\n\r\n        \/\/ create data\r\n        var data = [\r\n          {name: \"World\", children: [\r\n            {name: \"Asia\", children: [\r\n              {name: \"East\", value: 1000},\r\n              {name: \"Southern\", value: 803},\r\n              {name: \"Southeast\", value: 415},\r\n              {name: \"Western\", value: 182},\r\n              {name: \"Central\", value: 36}\r\n            ]},\r\n            {name: \"America\", children: [\r\n              {name: \"North\", value: 346},\r\n              {name: \"South\", value: 316},\r\n              {name: \"Central\", value: 114},\r\n              {name: \"Caribbean\", value: 23}\r\n            ]},\r\n            {name: \"Europe\", children: [\r\n              {name: \"Eastern\", value: 233},\r\n              {name: \"Western\", value: 183},\r\n              {name: \"Southern\", value: 135},\r\n              {name: \"Northern\", value: 100}\r\n            ]},  \r\n            {name: \"Africa\", children: [\r\n              {name: \"Western\", value: 158},\r\n              {name: \"Eastern\", value: 140},\r\n              {name: \"Northern\", value: 121},\r\n              {name: \"Southern\", value: 34},\r\n              {name: \"Middle\", value: 20}\r\n            ]},  \r\n            {name: \"Oceania\", children: [\r\n              {name: \"Oceania\", value: 29}\r\n            ]}  \r\n          ]} \r\n        ];\r\n  \r\n        \/\/ create a data tree\r\n        var treeData = anychart.data.tree(data, \"as-tree\");\r\n\r\n        \/\/ create a treemap chart visualizing the data tree\r\n        var chart = anychart.treeMap(treeData);\r\n  \r\n        \/\/ set the depth of hints\r\n        chart.hintDepth(1);\r\n        \/\/ set the opacity of hints\r\n        chart.hintOpacity(0.7);\r\n  \r\n        \/\/ configure the visual settings of the chart\r\n        chart.hovered().fill(\"silver\", 0.2);\r\n        chart.selected().fill(\"silver\", 0.6);\r\n        chart.selected().hatchFill(\"backward-diagonal\", \"silver\", 2, 20);\r\n        chart.normal().stroke(\"silver\");\r\n        chart.hovered().stroke(\"gray\", 2);\r\n        chart.selected().stroke(\"gray\", 2);\r\n  \r\n        \/\/ create and configure a custom color scale\r\n        var customColorScale = anychart.scales.linearColor();\r\n        customColorScale.colors([\"Yellow\", \"MediumPurple\"]);\r\n        \/\/ apply the custom color scale to the treemap chart\r\n        chart.colorScale(customColorScale);\r\n        \/\/ add the color range\r\n        chart.colorRange().enabled(true);\r\n        chart.colorRange().length(\"100%\");\r\n  \r\n        \/\/ enable HTML in the chart title\r\n        chart.title().useHtml(true);\r\n        \/\/ configure the chart title\r\n        chart.title(\r\n          \"&lt;span style='font-size:18; font-style:bold'&gt;Internet Audience Worldwide&lt;\/span&gt;&lt;br&gt;&lt;i&gt;&lt;span style='font-size:14; font-style:italic'&gt;In million users&lt;\/i&gt;\"\r\n        );\r\n\r\n        \/\/ enable HTML in the chart tooltips\r\n        chart.tooltip().useHtml(true);\r\n        \/\/ configure the chart tooltips\r\n        chart.tooltip().format(\r\n          \"Internet audience: {%value} million users&lt;br&gt;&lt;i&gt;(As of January 2019.)&lt;\/i&gt;\"\r\n        );\r\n\r\n        \/\/ enable HTML in the chart labels\r\n        chart.labels().useHtml(true);\r\n        \/\/ configure the chart labels\r\n        chart.labels().format(\r\n          \"&lt;span style='font-weight:bold'&gt;{%name}&lt;\/span&gt;&lt;br&gt;{%value}\"\r\n        );\r\n\r\n        \/\/ set the container id\r\n        chart.container(\"container\");\r\n\r\n        \/\/ draw the chart\r\n        chart.draw();\r\n\r\n      });\r\n    &lt;\/script&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h2>Wrapping Up<\/h2>\n<p>Developing awesome interactive treemap charts using JavaScript is far from rocket science. Even newbies in web development and data visualization with (almost) no coding experience can create these, and basically, <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Supported_Charts_Types\" target=\"_blank\" rel=\"nofollow\">any other JS charts<\/a>, plots, diagrams, and graphs.<\/p>\n<p>Now that you&#8217;ve read this JS chart tutorial, enjoy the new knowledge and make good use of it in practice when building simple or more complicated and advanced treemaps in JavaScript\/HTML5 \u2014 for the best possible, most efficient visualization of hierarchical data in your projects, whether it&#8217;s a website, a mobile application, or any software.<\/p>\n<p>Don\u2019t miss out on looking at more <a href=\"https:\/\/www.anychart.com\/products\/anychart\/gallery\/Tree_Map_Charts\/\">treemap chart examples<\/a> in a dedicated gallery of JavaScript (HTML5) data visualizations.<\/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>Treemap is a popular chart type for hierarchical data visualization. I\u2019ll show you how to create a cool interactive treemap chart using JavaScript in four simple steps right now. Join me on this quick tutorial for front-end web developers and data viz enthusiasts to understand the core principles of the process. Basically, I am sure [&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":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,23,13,279,4],"tags":[53,127,258,54,256,32,55,1222,36,141,81,57,58,65,56,1223,1224,459,30,1221,190,172],"class_list":["post-8275","post","type-post","status-publish","format-standard","hentry","category-anychart-charting-component","category-html5","category-javascript","category-javascript-chart-tutorials","category-tips-and-tricks","tag-anychart","tag-chart-types","tag-charts","tag-data-visualization","tag-data-visualization-examples","tag-html5","tag-html5-charts","tag-internet-statistics","tag-javascript","tag-javascript-charting","tag-javascript-charting-library","tag-javascript-charts","tag-js-chart","tag-js-charting","tag-js-charts","tag-statista","tag-statista-data-visualization","tag-statistics","tag-tips-and-tricks","tag-treemap","tag-treemap-chart","tag-tutorial","wpautop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Treemap Chart: How to Create and Customize It Using JavaScript<\/title>\n<meta name=\"description\" content=\"Treemap is a popular chart type for hierarchical data visualization. I\u2019ll show you how to create a cool interactive treemap chart using JavaScript.\" \/>\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\/2019\/08\/01\/treemap-chart-create-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating Treemap Chart Using JavaScript\" \/>\n<meta property=\"og:description\" content=\"Treemap is a popular chart type for hierarchical data visualization. I\u2019ll show you how to create a cool interactive treemap chart using JavaScript.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"AnyChart News\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/AnyCharts\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-01T12:21:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-13T10:57:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.png\" \/>\n<meta name=\"author\" content=\"Douglas &quot;Bugggster&quot; Baxter\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Creating Treemap Chart Using JavaScript\" \/>\n<meta name=\"twitter:description\" content=\"Treemap is a popular chart type for hierarchical data visualization. I\u2019ll show you how to create a cool interactive treemap chart using JavaScript.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.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=\"Douglas &quot;Bugggster&quot; Baxter\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/\"},\"author\":{\"name\":\"Douglas \\\"Bugggster\\\" Baxter\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/57fd21e4f24ac24dd593103251640126\"},\"headline\":\"Creating Treemap Chart Using JavaScript\",\"datePublished\":\"2019-08-01T12:21:08+00:00\",\"dateModified\":\"2022-08-13T10:57:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/\"},\"wordCount\":1400,\"commentCount\":2,\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.png\",\"keywords\":[\"AnyChart\",\"chart types\",\"charts\",\"Data Visualization\",\"data visualization examples\",\"HTML5\",\"html5 charts\",\"internet statistics\",\"JavaScript\",\"javascript charting\",\"JavaScript charting library\",\"javascript charts\",\"js chart\",\"js charting\",\"js charts\",\"Statista\",\"Statista data visualization\",\"statistics\",\"Tips and tricks\",\"treemap\",\"treemap chart\",\"tutorial\"],\"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\/2019\/08\/01\/treemap-chart-create-javascript\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/\",\"url\":\"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/\",\"name\":\"Treemap Chart: How to Create and Customize It Using JavaScript\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.png\",\"datePublished\":\"2019-08-01T12:21:08+00:00\",\"dateModified\":\"2022-08-13T10:57:41+00:00\",\"author\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/57fd21e4f24ac24dd593103251640126\"},\"description\":\"Treemap is a popular chart type for hierarchical data visualization. I\u2019ll show you how to create a cool interactive treemap chart using JavaScript.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#primaryimage\",\"url\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.png\",\"contentUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.png\",\"width\":1088,\"height\":617},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.anychart.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating Treemap Chart 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\/57fd21e4f24ac24dd593103251640126\",\"name\":\"Douglas \\\"Bugggster\\\" Baxter\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/88ed1172d212eef03d2a96b7aaf5d84edfd8bc998ffaa15ed20d7aba9d04e6de?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/88ed1172d212eef03d2a96b7aaf5d84edfd8bc998ffaa15ed20d7aba9d04e6de?s=96&r=g\",\"caption\":\"Douglas \\\"Bugggster\\\" Baxter\"},\"url\":\"https:\/\/www.anychart.com\/blog\/author\/bugggster\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Treemap Chart: How to Create and Customize It Using JavaScript","description":"Treemap is a popular chart type for hierarchical data visualization. I\u2019ll show you how to create a cool interactive treemap chart using JavaScript.","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\/2019\/08\/01\/treemap-chart-create-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Creating Treemap Chart Using JavaScript","og_description":"Treemap is a popular chart type for hierarchical data visualization. I\u2019ll show you how to create a cool interactive treemap chart using JavaScript.","og_url":"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/","og_site_name":"AnyChart News","article_publisher":"https:\/\/www.facebook.com\/AnyCharts","article_published_time":"2019-08-01T12:21:08+00:00","article_modified_time":"2022-08-13T10:57:41+00:00","og_image":[{"url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.png","type":"","width":"","height":""}],"author":"Douglas \"Bugggster\" Baxter","twitter_card":"summary_large_image","twitter_title":"Creating Treemap Chart Using JavaScript","twitter_description":"Treemap is a popular chart type for hierarchical data visualization. I\u2019ll show you how to create a cool interactive treemap chart using JavaScript.","twitter_image":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.png","twitter_creator":"@AnyChart","twitter_site":"@AnyChart","twitter_misc":{"Written by":"Douglas \"Bugggster\" Baxter","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#article","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/"},"author":{"name":"Douglas \"Bugggster\" Baxter","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/57fd21e4f24ac24dd593103251640126"},"headline":"Creating Treemap Chart Using JavaScript","datePublished":"2019-08-01T12:21:08+00:00","dateModified":"2022-08-13T10:57:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/"},"wordCount":1400,"commentCount":2,"image":{"@id":"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.png","keywords":["AnyChart","chart types","charts","Data Visualization","data visualization examples","HTML5","html5 charts","internet statistics","JavaScript","javascript charting","JavaScript charting library","javascript charts","js chart","js charting","js charts","Statista","Statista data visualization","statistics","Tips and tricks","treemap","treemap chart","tutorial"],"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\/2019\/08\/01\/treemap-chart-create-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/","url":"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/","name":"Treemap Chart: How to Create and Customize It Using JavaScript","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#primaryimage"},"image":{"@id":"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.png","datePublished":"2019-08-01T12:21:08+00:00","dateModified":"2022-08-13T10:57:41+00:00","author":{"@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/57fd21e4f24ac24dd593103251640126"},"description":"Treemap is a popular chart type for hierarchical data visualization. I\u2019ll show you how to create a cool interactive treemap chart using JavaScript.","breadcrumb":{"@id":"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#primaryimage","url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.png","contentUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/08\/treemap-tutorial.png","width":1088,"height":617},{"@type":"BreadcrumbList","@id":"https:\/\/www.anychart.com\/blog\/2019\/08\/01\/treemap-chart-create-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.anychart.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Creating Treemap Chart 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\/57fd21e4f24ac24dd593103251640126","name":"Douglas \"Bugggster\" Baxter","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/88ed1172d212eef03d2a96b7aaf5d84edfd8bc998ffaa15ed20d7aba9d04e6de?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/88ed1172d212eef03d2a96b7aaf5d84edfd8bc998ffaa15ed20d7aba9d04e6de?s=96&r=g","caption":"Douglas \"Bugggster\" Baxter"},"url":"https:\/\/www.anychart.com\/blog\/author\/bugggster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/8275","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\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/comments?post=8275"}],"version-history":[{"count":23,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/8275\/revisions"}],"predecessor-version":[{"id":15492,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/8275\/revisions\/15492"}],"wp:attachment":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/media?parent=8275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/categories?post=8275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/tags?post=8275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}