{"id":7734,"date":"2019-04-17T08:44:14","date_gmt":"2019-04-17T08:44:14","guid":{"rendered":"https:\/\/www.anychart.com\/blog\/?p=7734"},"modified":"2019-04-17T09:00:31","modified_gmt":"2019-04-17T09:00:31","slug":"code-js-column-chart-multi-level-x-axis","status":"publish","type":"post","link":"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/","title":{"rendered":"How to Code JS Column Chart with Multi-Level X-Axis \u2014 Challenge AnyChart!"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone size-full wp-image-7740\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart.png\" alt=\"How to code an interactive JS column chart with a wulti-level X-axis using the AnyChart JavaScript charting library, in the Challenge AnyChart! blog feature\" width=\"100%\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart.png 960w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart-300x200.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart-768x512.png 768w\" sizes=\"(max-width: 960px) 100vw, 960px\" \/>We continue to update the\u00a0<a href=\"https:\/\/www.anychart.com\/blog\/category\/challenge-anychart\/\">Challenge AnyChart!<\/a> section of our blog with new data visualization tutorials.\u00a0They nicely demonstrate how powerful our <a href=\"https:\/\/www.anychart.com\/\">JavaScript charting library<\/a> is,\u00a0which our\u00a0<a href=\"https:\/\/www.anychart.com\/support\/\">Support Team<\/a>\u00a0is always eager to prove to everyone. In one of the first challenges, we already told\u00a0you how to create a <a href=\"https:\/\/www.anychart.com\/blog\/2017\/11\/29\/multi-level-category-axis-challenge-anychart\/\">JS chart with nested axes<\/a>. Since our customers keep showing interest in such forms of data presentation, now we&#8217;ll show you how to\u00a0build another interesting chart with a different appearance but quite similar code \u2014 an interactive <strong>JS column chart with a multi-level X-axis<\/strong>.<\/p>\n<p><!--more--><\/p>\n<h2>Data Visualization Task<\/h2>\n<p>Here\u2019s the issue a customer asked us to solve:<\/p>\n<blockquote><p><em><strong>I want to display the data with subcategories in a <a href=\"https:\/\/www.anychart.com\/chartopedia\/chart-type\/column-chart\/\">column chart<\/a>, is it possible?<\/strong><\/em><\/p><\/blockquote>\n<p>To show how the nested axis should be placed, they attached the following picture:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7742\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-customer.jpg\" alt=\"Customer's chart with a multi-level X-axis\" width=\"361\" height=\"134\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-customer.jpg 361w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-customer-300x111.jpg 300w\" sizes=\"auto, (max-width: 361px) 100vw, 361px\" \/><\/p>\n<p>Typically, here is what&#8217;s needed to make a chart like the one in the picture:<\/p>\n<ul>\n<li>work with data using view and iterator objects,<\/li>\n<li>use extra axis,<\/li>\n<li>use custom scales, and<\/li>\n<li>use <a href=\"https:\/\/api.anychart.com\/anychart.scales.Ordinal#weights\" target=\"_blank\" rel=\"nofollow\">weights<\/a> of scale ticks.<\/li>\n<\/ul>\n<h2>Solution Overview<\/h2>\n<p>First of all, let\u2019s modify the source data and add empty values in it to visually separate data by category.<\/p>\n<p>Then, once the chart has been drawn and calculations for the scales and bounds completed, add an extra axis and set the ticks and labels in a preferred way.<\/p>\n<h2>Preprocessing<\/h2>\n<p>Before feeding the data to the chart, let\u2019s add empty values into the data, which will make visible where one category ends and another begins.<\/p>\n<p>To achieve this, add one empty value to the beginning of the array, one more to the end, and two empty items every time the category name changes.<\/p>\n<pre><code class=\"javascript\">function preprocessData(data){\r\n  if (data.length &gt; 0) {\r\n    data.unshift([data[0][0]]);\r\n    data.push([data[data.length - 1][0]]);\r\n    for (var i = 2; i &lt; data.length - 1; i++) {\r\n      var previous = data[i-1][0];\r\n      var current = data[i][0];\r\n      if (current!=previous) {\r\n        data.splice(i, 0, [previous], [current]);\r\n        i = i+2;\r\n      }\r\n      else {\r\n        data.splice(i, 0, [previous]);\r\n        i += 1;\r\n      }\r\n    }\r\n  }\r\n  return anychart.data.set(data);\r\n}<\/code><\/pre>\n<p>When it\u2019s done, add subcategory names to the meta using the\u00a0<a href=\"https:\/\/api.anychart.com\/anychart.data.Set#mapAs\" target=\"_blank\" rel=\"nofollow\">mapAs()<\/a> method to get a different view and use them as names of the X-axis ticks this way:<\/p>\n<pre><code class=\"javascript\">chart.column(data.mapAs({'year': 0, 'value': 2, 'sub-category': 1}));\r\nchart.xScale().names('sub-category');<\/code><\/pre>\n<p>Now the JS column chart itself can be drawn.<\/p>\n<h2>Extra Axis and Additional Scale on JS Column Chart<\/h2>\n<p>The time has come for adding an extra axis to the chart. To achieve this, create a function with the iterator object. It will be used for exploring the view and finding categories and subcategories.<\/p>\n<p>After that, draw ticks between the categories and set up the weights.\u00a0This will give the chart a better\u00a0look:<\/p>\n<pre><code class=\"javascript\">var iter = data.mapAs({'category': 0, 'sub-category': 1}).getIterator();\r\nwhile(iter.advance()) {\r\n  var name = iter.get('category');\r\n  var value = iter.get('sub-category');\r\n  names.push(name);\r\n  if (name &amp;&amp; names[names.length - 1] != names[names.length - 2])\r\n    ticks.push(iter.getIndex());\r\n  }\r\n  weights.push(value?0.5:0.2);\r\n}\r\n<\/code><\/pre>\n<p>Axes work with scales. To be more precise, the former visualize the latter. So in order to implement the idea, a custom scale containing data of categories and subcategories is needed. Then\u00a0let&#8217;s pass the values, names, and ticks to this scale:<\/p>\n<pre><code class=\"javascript\">var customScale = anychart.scales.ordinal();\r\ncustomScale.values(chart.xScale().values());\r\ncustomScale.names(names);\r\ncustomScale.ticks(ticks);<\/code><\/pre>\n<p>And build the new axis on it:<\/p>\n<pre><code class=\"javascript\">chart.xAxis(1)\r\n  .scale(customScale)\r\n  .orientation('top')\r\n  .ticks(true);<\/code><\/pre>\n<p>Finally, we synchronize the weights with the chart scale:<\/p>\n<pre><code class=\"javascript\">chart.xScale().weights(weights);<\/code><\/pre>\n<p>And disable the ticks on the main axis:<\/p>\n<pre><code class=\"javascript\">chart.xAxis(0).ticks(false);<\/code><\/pre>\n<p>As was said, everything is possible with AnyChart! Now the entire JS column chart with a multi-level X-axis, which has been created along the tutorial, is ready to be presented. Check it out right here below, and if you want, you\u00a0are welcome to view and modify this sample\u00a0on\u00a0<a href=\"https:\/\/playground.anychart.com\/ql9nu37c\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>.<\/p>\n<p><iframe loading=\"lazy\" class=\"anychart-embed anychart-embed-bXYPGvmO\" src=\"https:\/\/playground.anychart.com\/ql9nu37c\/iframe\" width=\"300\" height=\"150\" frameborder=\"0\" sandbox=\"allow-scripts allow-pointer-lock allow-same-origin allow-popups allow-modals allow-forms\" allowfullscreen=\"allowfullscreen\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-bXYPGvmO{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>The full code is placed below.\u00a0Take a look\u00a0through the lines to better understand the implementation:<\/p>\n<pre><code class=\"javascript\">anychart.onDocumentReady(function () {\r\n  var data = preprocessData([\r\n    ['2016', 'Rel 04', 18],\r\n    ['2016', 'Rel 06', 13],\r\n    ['2016', 'Rel 10', 17],\r\n    ['2017', 'Rel 02', 4],\r\n    ['2017', 'Rel 04', 13],\r\n    ['2017', 'Rel 06', 12],\r\n    ['2017', 'Rel 08', 6],\r\n    ['2017', 'Rel 10', 17],\r\n    ['2018', 'Rel 02', 12],\r\n    ['2018', 'Rel 06', 9],\r\n    ['2018', 'Rel 10', 15]\r\n  ]);\r\n\r\n  var chart = anychart.column();\r\n\r\n  \/\/ configure global settings for series labels\r\n  chart.labels({position:'top'});\r\n\r\n  \/\/ add subcategory names to the meta of one of the series\r\n  chart.column(data.mapAs({'year': 0, 'value': 2, 'sub-category': 1}));\r\n\r\n  \/\/ use subcategory names as names of X-axis ticks\r\n  chart.xScale().names('sub-category');\r\n\r\n  chart.xAxis().labels().rotation(90);\r\n  chart.xAxis().labels().anchor(\"center\");\r\n  chart.xAxis().overlapMode('allow-overlap');\r\n\r\n  \/\/ set a container and draw the chart\r\n  chart.container('container').draw();\r\n\r\n  \/\/ calculate an extra axis\r\n  createTwoLevelAxis(chart, data);\r\n});\r\n\r\nfunction preprocessData(data){\r\n  \/\/ to make beautiful spacing between categories, add\r\n  \/\/ several empty lines with the same category names to the data\r\n  if (data.length &gt; 0) {\r\n    \/\/ add one to the beginning of the array\r\n    data.unshift([data[0][0]]);\r\n    \/\/ add one more to the end of the data\r\n    data.push([data[data.length - 1][0]]);\r\n    \/\/ add two empty items every time the category name changes,\r\n    \/\/ to each category\r\n    for (var i = 2; i &lt; data.length - 1; i++) {\r\n      var previous = data[i-1][0];\r\n      var current = data[i][0];\r\n      if (current!=previous) {\r\n        data.splice(i, 0, [previous], [current]);\r\n        i = i+2;\r\n      } \r\n      else {\r\n        data.splice(i, 0, [previous]);\r\n        i += 1;\r\n      }\r\n    }\r\n  }\r\n  return anychart.data.set(data);\r\n}\r\n\r\nfunction createTwoLevelAxis(chart, data, padding){\r\n  \/\/ subcategory names\r\n  var names = [];\r\n  \/\/ ticks for axes based on main categories\r\n  var ticks = [];\r\n  \/\/ weights of ticks (to make spacing between categories by using\r\n  \/\/ the empty lines created in preprocessData)\r\n  var weights = [];\r\n  \/\/ the iterator feature allows you to go over data, so\r\n  \/\/ create an iterator for a new breakdown\r\n  var iter = data.mapAs({'category': 0, 'sub-category': 1}).getIterator();\r\n  while(iter.advance()) {\r\n    var name = iter.get('category');\r\n    var value = iter.get('sub-category');\r\n    \/\/ store category names\r\n    names.push(name);\r\n    \/\/ when the border between the categories is identified, create a tick\r\n    if (name &amp;&amp; names[names.length - 1] != names[names.length - 2]) \t\t\t\t\t{\r\n      ticks.push(iter.getIndex());\r\n    }\r\n    \/\/ assign weight to the tick\r\n    weights.push(value?0.5:0.2);\r\n  }\r\n\r\n  \/\/ create a custom scale\r\n  var customScale = anychart.scales.ordinal();\r\n  \/\/ supply values from the chart to the scale\r\n  customScale.values(chart.xScale().values());\r\n  \/\/ names and ticks of the main categories only\r\n  customScale.names(names);\r\n  customScale.ticks(ticks);\r\n\r\n  \/\/ synchronize weights with the chart scale\r\n  chart.xScale().weights(weights);\r\n\r\n  \/\/ disable ticks along the main axis\r\n  chart.xAxis(0).ticks(false);\r\n\r\n  \/\/ create an extra chart axis\r\n  chart.xAxis(1)\r\n    .scale(customScale)\r\n    .orientation('top')\r\n    .ticks(true);\r\n\r\n  chart.xAxis(1).ticks().length(60).position('center');\r\n  chart.xAxis(1).labels().offsetY(30);\r\n\r\n  chart.xGrid(0).scale(customScale);\r\n\r\n  chart.title('Year \/ Release');\r\n\r\n  \/\/ format the tooltip title\r\n  chart.tooltip().titleFormat(\"{%year}\");\r\n\r\n  \/\/ format the tooltip body\r\n  chart.tooltip().format(\"{%sub-category}: {%value}\");\r\n}<\/code><\/pre>\n<h2>Conclusion<\/h2>\n<p>Hoping you liked this article,\u00a0we invite you to check out more of the similar ones in the <a href=\"https:\/\/www.anychart.com\/blog\/category\/challenge-anychart\/\">Challenge AnyChart!<\/a> section of our blog. If you have any interesting data visualization questions that might be a good fit for a tutorial like this,\u00a0please\u00a0send an email to our Support Team at\u00a0<a href=\"mailto:support@anychart.com\" target=\"_blank\" rel=\"nofollow\">support@anychart.com<\/a> with \u201cChallenge\u201d in the subject line.<\/p>\n<p>We will be glad to keep showing you how to create cool, sophisticated data visualizations\u00a0using\u00a0<a href=\"https:\/\/www.anychart.com\">AnyChart JS Charts<\/a> and further demonstrate the vast capabilities of our JS charting library in action.<\/p>\n<p>Any feedback is always welcome. If you have something to say, please write a comment below.<\/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>We continue to update the\u00a0Challenge AnyChart! section of our blog with new data visualization tutorials.\u00a0They nicely demonstrate how powerful our JavaScript charting library is,\u00a0which our\u00a0Support Team\u00a0is always eager to prove to everyone. In one of the first challenges, we already told\u00a0you how to create a JS chart with nested axes. Since our customers keep showing [&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":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,280,23,13,4],"tags":[843,53,70,281,258,290,85,471,266,54,256,842,844,805,32,55,36,141,81,57,58,65,56,841,30,172,804],"class_list":["post-7734","post","type-post","status-publish","format-standard","hentry","category-anychart-charting-component","category-challenge-anychart","category-html5","category-javascript","category-tips-and-tricks","tag-advanced-data-visualization","tag-anychart","tag-bar-chart","tag-challenge","tag-charts","tag-column-chart","tag-column-charts","tag-data-analysis","tag-data-analytics","tag-data-visualization","tag-data-visualization-examples","tag-data-visualization-task","tag-data-visualization-tutorial","tag-front-end-development","tag-html5","tag-html5-charts","tag-javascript","tag-javascript-charting","tag-javascript-charting-library","tag-javascript-charts","tag-js-chart","tag-js-charting","tag-js-charts","tag-multi-level-axis","tag-tips-and-tricks","tag-tutorial","tag-web-development","wpautop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JS Column Chart with Multi-Level X-Axis Code \u2014 Challenge AnyChart!<\/title>\n<meta name=\"description\" content=\"Continuing to update &quot;Challenge AnyChart!&quot; with new data visualization tutorials, we&#039;ll show you how to create a JS column chart with a multi-level X-axis.\" \/>\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\/04\/17\/code-js-column-chart-multi-level-x-axis\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JS Column Chart with Multi-Level X-Axis Code \u2014 Challenge AnyChart!\" \/>\n<meta property=\"og:description\" content=\"Continuing to update &quot;Challenge AnyChart!&quot; with new data visualization tutorials, we&#039;ll show you how to create a JS column chart with a multi-level X-axis.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/\" \/>\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-04-17T08:44:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-04-17T09:00:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart.png\" \/>\n\t<meta property=\"og:image:width\" content=\"960\" \/>\n\t<meta property=\"og:image:height\" content=\"640\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Irina Maximova\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\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=\"Irina Maximova\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 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\/04\/17\/code-js-column-chart-multi-level-x-axis\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/\"},\"author\":{\"name\":\"Irina Maximova\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/c79061b5c43d09368b8d44b36842b058\"},\"headline\":\"How to Code JS Column Chart with Multi-Level X-Axis \u2014 Challenge AnyChart!\",\"datePublished\":\"2019-04-17T08:44:14+00:00\",\"dateModified\":\"2019-04-17T09:00:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/\"},\"wordCount\":641,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart.png\",\"keywords\":[\"advanced data visualization\",\"AnyChart\",\"bar chart\",\"challenge\",\"charts\",\"column chart\",\"column charts\",\"data analysis\",\"data analytics\",\"Data Visualization\",\"data visualization examples\",\"data visualization task\",\"data visualization tutorial\",\"front-end development\",\"HTML5\",\"html5 charts\",\"JavaScript\",\"javascript charting\",\"JavaScript charting library\",\"javascript charts\",\"js chart\",\"js charting\",\"js charts\",\"multi-level axis\",\"Tips and tricks\",\"tutorial\",\"web development\"],\"articleSection\":[\"AnyChart Charting Component\",\"Challenge AnyChart!\",\"HTML5\",\"JavaScript\",\"Tips and Tricks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/\",\"url\":\"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/\",\"name\":\"JS Column Chart with Multi-Level X-Axis Code \u2014 Challenge AnyChart!\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart.png\",\"datePublished\":\"2019-04-17T08:44:14+00:00\",\"dateModified\":\"2019-04-17T09:00:31+00:00\",\"author\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/c79061b5c43d09368b8d44b36842b058\"},\"description\":\"Continuing to update \\\"Challenge AnyChart!\\\" with new data visualization tutorials, we'll show you how to create a JS column chart with a multi-level X-axis.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#primaryimage\",\"url\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart.png\",\"contentUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart.png\",\"width\":960,\"height\":640},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.anychart.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Code JS Column Chart with Multi-Level X-Axis \u2014 Challenge AnyChart!\"}]},{\"@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\/c79061b5c43d09368b8d44b36842b058\",\"name\":\"Irina Maximova\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/023075cf0bac635343d009a289d4c3d32138b5a3890d10f09ed59755e59bc065?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/023075cf0bac635343d009a289d4c3d32138b5a3890d10f09ed59755e59bc065?s=96&r=g\",\"caption\":\"Irina Maximova\"},\"url\":\"https:\/\/www.anychart.com\/blog\/author\/irina-maximova\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JS Column Chart with Multi-Level X-Axis Code \u2014 Challenge AnyChart!","description":"Continuing to update \"Challenge AnyChart!\" with new data visualization tutorials, we'll show you how to create a JS column chart with a multi-level X-axis.","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\/04\/17\/code-js-column-chart-multi-level-x-axis\/","og_locale":"en_US","og_type":"article","og_title":"JS Column Chart with Multi-Level X-Axis Code \u2014 Challenge AnyChart!","og_description":"Continuing to update \"Challenge AnyChart!\" with new data visualization tutorials, we'll show you how to create a JS column chart with a multi-level X-axis.","og_url":"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/","og_site_name":"AnyChart News","article_publisher":"https:\/\/www.facebook.com\/AnyCharts","article_published_time":"2019-04-17T08:44:14+00:00","article_modified_time":"2019-04-17T09:00:31+00:00","og_image":[{"width":960,"height":640,"url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart.png","type":"image\/png"}],"author":"Irina Maximova","twitter_card":"summary_large_image","twitter_creator":"@AnyChart","twitter_site":"@AnyChart","twitter_misc":{"Written by":"Irina Maximova","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#article","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/"},"author":{"name":"Irina Maximova","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/c79061b5c43d09368b8d44b36842b058"},"headline":"How to Code JS Column Chart with Multi-Level X-Axis \u2014 Challenge AnyChart!","datePublished":"2019-04-17T08:44:14+00:00","dateModified":"2019-04-17T09:00:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/"},"wordCount":641,"commentCount":0,"image":{"@id":"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart.png","keywords":["advanced data visualization","AnyChart","bar chart","challenge","charts","column chart","column charts","data analysis","data analytics","Data Visualization","data visualization examples","data visualization task","data visualization tutorial","front-end development","HTML5","html5 charts","JavaScript","javascript charting","JavaScript charting library","javascript charts","js chart","js charting","js charts","multi-level axis","Tips and tricks","tutorial","web development"],"articleSection":["AnyChart Charting Component","Challenge AnyChart!","HTML5","JavaScript","Tips and Tricks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/","url":"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/","name":"JS Column Chart with Multi-Level X-Axis Code \u2014 Challenge AnyChart!","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#primaryimage"},"image":{"@id":"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart.png","datePublished":"2019-04-17T08:44:14+00:00","dateModified":"2019-04-17T09:00:31+00:00","author":{"@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/c79061b5c43d09368b8d44b36842b058"},"description":"Continuing to update \"Challenge AnyChart!\" with new data visualization tutorials, we'll show you how to create a JS column chart with a multi-level X-axis.","breadcrumb":{"@id":"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#primaryimage","url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart.png","contentUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2019\/04\/multi-level-x-axis-in-javascript-column-chart.png","width":960,"height":640},{"@type":"BreadcrumbList","@id":"https:\/\/www.anychart.com\/blog\/2019\/04\/17\/code-js-column-chart-multi-level-x-axis\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.anychart.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Code JS Column Chart with Multi-Level X-Axis \u2014 Challenge AnyChart!"}]},{"@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\/c79061b5c43d09368b8d44b36842b058","name":"Irina Maximova","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/023075cf0bac635343d009a289d4c3d32138b5a3890d10f09ed59755e59bc065?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/023075cf0bac635343d009a289d4c3d32138b5a3890d10f09ed59755e59bc065?s=96&r=g","caption":"Irina Maximova"},"url":"https:\/\/www.anychart.com\/blog\/author\/irina-maximova\/"}]}},"_links":{"self":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/7734","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\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/comments?post=7734"}],"version-history":[{"count":22,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/7734\/revisions"}],"predecessor-version":[{"id":7760,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/7734\/revisions\/7760"}],"wp:attachment":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/media?parent=7734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/categories?post=7734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/tags?post=7734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}