{"id":16970,"date":"2023-11-02T08:56:30","date_gmt":"2023-11-02T08:56:30","guid":{"rendered":"https:\/\/www.anychart.com\/blog\/?p=16970"},"modified":"2023-11-03T13:44:06","modified_gmt":"2023-11-03T13:44:06","slug":"waterfall-charts-javascript","status":"publish","type":"post","link":"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/","title":{"rendered":"Building Waterfall Charts in JS"},"content":{"rendered":"<p><a href=\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/\"><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart.png\" alt=\"Waterfall Chart and How to Build it in JavaScript\" width=\"100%\" class=\"alignnone size-full wp-image-16986\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart.png 1366w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-300x169.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-768x432.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-1024x576.png 1024w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/a><strong>Data visualization<\/strong> is an essential tool for understanding complex data sets and effectively conveying insights. Among the various types of charts and graphs used for this purpose, the <strong>waterfall chart<\/strong> stands out as a powerful way to represent changes in financial data, such as revenue, expenses, and profits over a specific period.<\/p>\n<p>In this tutorial, we&#39;ll explore how to create a waterfall chart using <strong>JavaScript<\/strong>. To illustrate the process, we&#39;ll use the example of an income statement for a company, in this case, Twitter Inc.\u2019s latest (and last) one.<\/p>\n<p>Whether it\u2019s to analyze a company&#39;s financial performance, project budgets, or inventory fluctuations, this step-by-step guide will help you easily create a useful interactive JS-based waterfall chart.<\/p>\n<p><!--more Read the JS charting tutorial \u00bb--><\/p>\n<h2 id=\"waterfall-chart-that-will-be-created\">Waterfall Chart That Will Be Created<\/h2>\n<p>Here\u2019s the JavaScript-based waterfall chart that will be the final visualization of this tutorial. Take a quick look at it, and let\u2019s get started.<\/p>\n<p><a href=\"https:\/\/playground.anychart.com\/44uzsMSk\" target=\"_blank\" rel=\"nofollow\"><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-10.png\" width=\"100%\" alt=\"Final JS Waterfall Chart\"><\/a><\/p>\n<h2 id=\"a-creating-basic-js-waterfall-chart\">A. Creating Basic JS Waterfall Chart<\/h2>\n<p>If you&#39;re new to creating JS charts, don&#39;t worry; it&#39;s easier than you think! You can create stunning charts, including waterfall plots, following these four fundamental steps:<\/p>\n<ol>\n<li>Create a container<\/li>\n<li>Include the necessary JavaScript files<\/li>\n<li>Add data to visualize<\/li>\n<li>Write simple JS charting code<\/li>\n<\/ol>\n<h3 id=\"step-1-create-container\">Step 1: Create Container<\/h3>\n<p>Begin by setting up a container for your waterfall chart. This involves adding a block-level HTML element to your webpage, defining its id, and specifying its width and height.<\/p>\n<p>This is how your HTML structure could look:<\/p>\n<pre><code class=\"lang-html\"><span class=\"hljs-meta\">&lt;!DOCTYPE html&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span> <span class=\"hljs-attr\">lang<\/span>=<span class=\"hljs-string\">\"en\"<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">meta<\/span> <span class=\"hljs-attr\">charset<\/span>=<span class=\"hljs-string\">\"utf-8\"<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title<\/span>&gt;<\/span>JavaScript Waterfall Chart<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">title<\/span>&gt;<\/span>  \r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">style<\/span>&gt;<\/span><span class=\"css\">\r\n      <span class=\"hljs-selector-tag\">html<\/span>, <span class=\"hljs-selector-tag\">body<\/span>, <span class=\"hljs-selector-id\">#WaterfallContainer<\/span> {\r\n        <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">100%<\/span>;\r\n        <span class=\"hljs-attribute\">height<\/span>: <span class=\"hljs-number\">100%<\/span>;\r\n        <span class=\"hljs-attribute\">margin<\/span>: <span class=\"hljs-number\">0<\/span>;\r\n        <span class=\"hljs-attribute\">padding<\/span>: <span class=\"hljs-number\">0<\/span>;\r\n      }\r\n    <\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">style<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">head<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"WaterfallContainer\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">body<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">html<\/span>&gt;<\/span>\r\n<\/code><\/pre>\n<h3 id=\"step-2-include-necessary-javascript-files\">Step 2: Include Necessary JavaScript Files<\/h3>\n<p>Once the container is set up, include the necessary JavaScript files in the <code>&lt;head&gt;<\/code> section. This tutorial shows how you can use a JS charting library like <a href=\"https:\/\/www.anychart.com\">AnyChart<\/a>.<\/p>\n<p>Here\u2019s how your HTML might look with the necessary <code>&lt;script&gt;<\/code> tags included:<\/p>\n<pre><code class=\"lang-html\"><span class=\"hljs-meta\">&lt;!DOCTYPE html&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span> <span class=\"hljs-attr\">lang<\/span>=<span class=\"hljs-string\">\"en\"<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">meta<\/span> <span class=\"hljs-attr\">charset<\/span>=<span class=\"hljs-string\">\"utf-8\"<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title<\/span>&gt;<\/span>JavaScript Waterfall Chart<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">title<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">\"https:\/\/cdn.anychart.com\/releases\/8.11.1\/js\/anychart-core.min.js\"<\/span>&gt;<\/span><span class=\"undefined\"><\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">\"https:\/\/cdn.anychart.com\/releases\/8.11.1\/js\/anychart-waterfall.min.js\"<\/span>&gt;<\/span><span class=\"undefined\"><\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">style<\/span>&gt;<\/span><span class=\"css\">\r\n      <span class=\"hljs-selector-tag\">html<\/span>, <span class=\"hljs-selector-tag\">body<\/span>, <span class=\"hljs-selector-id\">#WaterfallContainer<\/span> {\r\n        <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">100%<\/span>;\r\n        <span class=\"hljs-attribute\">height<\/span>: <span class=\"hljs-number\">100%<\/span>;\r\n        <span class=\"hljs-attribute\">margin<\/span>: <span class=\"hljs-number\">0<\/span>;\r\n        <span class=\"hljs-attribute\">padding<\/span>: <span class=\"hljs-number\">0<\/span>;\r\n      }\r\n    <\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">style<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">head<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"WaterfallContainer\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span>&gt;<\/span><span class=\"actionscript\">\r\n      <span class=\"hljs-comment\">\/\/ All the code for the waterfall chart will come here.<\/span>\r\n    <\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">body<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">html<\/span>&gt;<\/span>\r\n<\/code><\/pre>\n<h3 id=\"step-3-add-data-to-visualize\">Step 3: Add Data to Visualize<\/h3>\n<p>Next, it&#39;s time to add data to visualize. The data for Twitter Inc.&#39;s last income statement (Twitter Inc. <a href=\"https:\/\/www.latimes.com\/business\/story\/2023-04-11\/elon-musk-merges-twitter-x-corp\" target=\"_blank\" rel=\"nofollow\">no longer exists<\/a>; the company is now a part of X Corp.) originates from <a href=\"https:\/\/www.stock-analysis-on.net\/NYSE\/Company\/Twitter-Inc\/Financial-Statement\/Income-Statement\" target=\"_blank\" rel=\"nofollow\">here<\/a>. For a waterfall chart, you can set the data in many ways; I will include it just like that directly in the code.<\/p>\n<p>Below is an example of a data set, where the data is structured as an array. Each item contains an &quot;x&quot; and &quot;value&quot; fields. The &quot;x&quot; field represents the name of the corresponding item of the income statement, while the &quot;value&quot; field signifies the magnitude of each data point.<\/p>\n<pre><code class=\"lang-javascript\">var data = [\r\n  { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Revenue\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">5077.482<\/span> },\r\n  { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Cost of revenue\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">-1797.510<\/span> },\r\n  { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Gross profit\"<\/span>, <span class=\"hljs-string\">isTotal:<\/span> <span class=\"hljs-literal\">true<\/span> },\r\n  { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Operating expenses\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">-3772.711<\/span> },\r\n  { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Income (loss) from operations\"<\/span>, <span class=\"hljs-string\">isTotal:<\/span> <span class=\"hljs-literal\">true<\/span> },\r\n  { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Interest expense\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">-51.186<\/span> },\r\n  { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Interest income\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">35.683<\/span> },\r\n  { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Other income (expense), net\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">97.129<\/span> },\r\n  { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Income (loss) before income taxes\"<\/span>, <span class=\"hljs-string\">isTotal:<\/span> <span class=\"hljs-literal\">true<\/span> },\r\n  { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"(Provision) benefit for income taxes\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">189.704<\/span> },\r\n  { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Net income (loss)\"<\/span>, <span class=\"hljs-string\">isTotal:<\/span> <span class=\"hljs-literal\">true<\/span> }\r\n];\r\n<\/code><\/pre>\n<h3 id=\"step-4-write-simple-js-charting-code\">Step 4: Write Simple JS Charting Code<\/h3>\n<p>Now, you can easily visualize the data with just a few lines of charting code.<\/p>\n<p>Start by ensuring your code executes only when the page has fully loaded by wrapping it up in a function like the one below.<\/p>\n<pre><code class=\"lang-javascript\">anychart.onDocumentReady(<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-params\">()<\/span> <\/span>{\r\n  <span class=\"hljs-comment\">\/\/ Your code goes here.<\/span>\r\n});\r\n<\/code><\/pre>\n<p>Now, it&#39;s time to define the data you want to visualize, taking it from the previous step.<\/p>\n<pre><code class=\"lang-javascript\">anychart.onDocumentReady(function () {\r\n\r\n  <span class=\"hljs-comment\">\/\/ set the data<\/span>\r\n  var data = [\r\n    { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Revenue\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">5077.482<\/span> },\r\n    { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Cost of revenue\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">-1797.510<\/span> },\r\n    { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Gross profit\"<\/span>, <span class=\"hljs-string\">isTotal:<\/span> <span class=\"hljs-literal\">true<\/span> },\r\n    { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Operating expenses\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">-3772.711<\/span> },\r\n    { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Income (loss) from operations\"<\/span>, <span class=\"hljs-string\">isTotal:<\/span> <span class=\"hljs-literal\">true<\/span> },\r\n    { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Interest expense\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">-51.186<\/span> },\r\n    { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Interest income\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">35.683<\/span> },\r\n    { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Other income (expense), net\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">97.129<\/span> },\r\n    { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Income (loss) before income taxes\"<\/span>, <span class=\"hljs-string\">isTotal:<\/span> <span class=\"hljs-literal\">true<\/span> },\r\n    { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"(Provision) benefit for income taxes\"<\/span>, <span class=\"hljs-string\">value:<\/span> <span class=\"hljs-number\">189.704<\/span> },\r\n    { <span class=\"hljs-string\">x:<\/span> <span class=\"hljs-string\">\"Net income (loss)\"<\/span>, <span class=\"hljs-string\">isTotal:<\/span> <span class=\"hljs-literal\">true<\/span> }\r\n  ];\r\n\r\n  <span class=\"hljs-comment\">\/\/ All the next code for the JS waterfall chart will come here.<\/span>\r\n\r\n});\r\n<\/code><\/pre>\n<p>Now that you have your data, create an instance of a waterfall chart. This chart instance will serve as the canvas upon which you&#39;ll visualize your data.<\/p>\n<pre><code class=\"lang-javascript\"><span class=\"hljs-selector-tag\">var<\/span> chart = anychart.waterfall()\r\n<\/code><\/pre>\n<p>To add your data to the waterfall chart, create a series object and assign your data to it. The series object is where you define how the data will be represented on the graphic. This step connects your data to the chart and tells it how to display each data point.<\/p>\n<pre><code class=\"lang-javascript\"><span class=\"hljs-attribute\">var series<\/span> = chart.waterfall(data);\r\n<\/code><\/pre>\n<p>You may choose to disable data point labels if your values are large and would otherwise clutter the view (all values can still be seen in the tooltip). We will return the labels and customize this and a few other things in the chart later in Section B.<\/p>\n<pre><code class=\"lang-javascript\">series.<span class=\"hljs-built_in\">labels<\/span>(<span class=\"hljs-literal\">false<\/span>);\r\n<\/code><\/pre>\n<p>You\u2019ve set up your JS waterfall chart, but now it needs a home. Set the ID of the container element in your HTML where the visual will be displayed. This makes your chart aware of where it should appear on your webpage.<\/p>\n<pre><code class=\"lang-javascript\">chart.container(<span class=\"hljs-string\">\"WaterfallContainer\"<\/span>)<span class=\"hljs-comment\">;<\/span>\r\n<\/code><\/pre>\n<p>Finally, with all the pieces in place, issue the command to draw the resulting waterfall chart.<\/p>\n<pre><code class=\"lang-javascript\">chart.draw()<span class=\"hljs-comment\">;<\/span>\r\n<\/code><\/pre>\n<h3 id=\"initial-waterfall-chart-result\">Initial Waterfall Chart Result<\/h3>\n<p>And there you have it! Your basic JavaScript waterfall chart comes to life. The complete code is provided below for your convenience. Feel free to explore the interactive version and play with the code on <a href=\"https:\/\/playground.anychart.com\/FHgJRRmV\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>, and let\u2019s proceed to customize this waterfall chart visualization in the next section of the tutorial!<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-1.png\" width=\"100%\" alt=\"Initial JS Waterfall Chart\"><\/p>\n<pre><code class=\"lang-html\"><span class=\"hljs-meta\">&lt;!DOCTYPE html&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span> <span class=\"hljs-attr\">lang<\/span>=<span class=\"hljs-string\">\"en\"<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">meta<\/span> <span class=\"hljs-attr\">charset<\/span>=<span class=\"hljs-string\">\"utf-8\"<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title<\/span>&gt;<\/span>JavaScript Waterfall Chart<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">title<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">\"https:\/\/cdn.anychart.com\/releases\/8.11.1\/js\/anychart-core.min.js\"<\/span>&gt;<\/span><span class=\"undefined\"><\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">\"https:\/\/cdn.anychart.com\/releases\/8.11.1\/js\/anychart-waterfall.min.js\"<\/span>&gt;<\/span><span class=\"undefined\"><\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">style<\/span>&gt;<\/span><span class=\"css\">\r\n      <span class=\"hljs-selector-tag\">html<\/span>, <span class=\"hljs-selector-tag\">body<\/span>, <span class=\"hljs-selector-id\">#WaterfallContainer<\/span> {\r\n        <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">100%<\/span>;\r\n        <span class=\"hljs-attribute\">height<\/span>: <span class=\"hljs-number\">100%<\/span>;\r\n        <span class=\"hljs-attribute\">margin<\/span>: <span class=\"hljs-number\">0<\/span>;\r\n        <span class=\"hljs-attribute\">padding<\/span>: <span class=\"hljs-number\">0<\/span>;\r\n      }\r\n    <\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">style<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">head<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"WaterfallContainer\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span>&gt;<\/span><span class=\"actionscript\">\r\n      anychart.onDocumentReady(<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-params\">()<\/span> <\/span>{\r\n        <span class=\"hljs-comment\">\/\/ set the data<\/span>\r\n        <span class=\"hljs-keyword\">var<\/span> data = [\r\n          { x: <span class=\"hljs-string\">\"Revenue\"<\/span>, value: <span class=\"hljs-number\">5077.482<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Cost of revenue\"<\/span>, value: <span class=\"hljs-number\">-1797.510<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Gross profit\"<\/span>, isTotal: <span class=\"hljs-literal\">true<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Operating expenses\"<\/span>, value: <span class=\"hljs-number\">-3772.711<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Income (loss) from operations\"<\/span>, isTotal: <span class=\"hljs-literal\">true<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Interest expense\"<\/span>, value: <span class=\"hljs-number\">-51.186<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Interest income\"<\/span>, value: <span class=\"hljs-number\">35.683<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Other income (expense), net\"<\/span>, value: <span class=\"hljs-number\">97.129<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Income (loss) before income taxes\"<\/span>, isTotal: <span class=\"hljs-literal\">true<\/span> },\r\n          { x: <span class=\"hljs-string\">\"(Provision) benefit for income taxes\"<\/span>, value: <span class=\"hljs-number\">189.704<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Net income (loss)\"<\/span>, isTotal: <span class=\"hljs-literal\">true<\/span> }\r\n];\r\n        <span class=\"hljs-comment\">\/\/ create a waterfall chart<\/span>\r\n        <span class=\"hljs-keyword\">var<\/span> chart = anychart.waterfall();\r\n        <span class=\"hljs-comment\">\/\/ create a series and set the data<\/span>\r\n        <span class=\"hljs-keyword\">var<\/span> series = chart.waterfall(data);\r\n        <span class=\"hljs-comment\">\/\/ hide the labels<\/span>\r\n        series.labels(<span class=\"hljs-literal\">false<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ set the container for the chart<\/span>\r\n        chart.container(<span class=\"hljs-string\">\"WaterfallContainer\"<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ draw the resulting chart<\/span>\r\n        chart.draw();\r\n      });\r\n    <\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">body<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">html<\/span>&gt;<\/span>\r\n<\/code><\/pre>\n<h2 id=\"b-customizing-js-waterfall-chart\">B. Customizing JS Waterfall Chart<\/h2>\n<p>Now, let\u2019s see how you can enhance the visual appeal of the waterfall chart by adding some customizations..<\/p>\n<h3 id=\"1-add-zero-line-marker\">1. Add Zero Line Marker<\/h3>\n<p>When working with negative values, it can be advantageous to include a zero line marker on the X axis. This zero line acts as a reference point, visually separating positive and negative values. You can achieve this by adding the following code.<\/p>\n<pre><code class=\"lang-javascript\"><span class=\"hljs-keyword\">var<\/span> line = chart.lineMarker().<span class=\"hljs-keyword\">value<\/span>(<span class=\"hljs-number\">0<\/span>);\r\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-2.png\" width=\"100%\" alt=\"Customized JS Waterfall Chart 1\"><\/p>\n<h3 id=\"2-rotate-chart\">2. Rotate Chart<\/h3>\n<p>In some cases where certain income statement items have lengthy names, you can improve the chart&#39;s appearance by rotating the X axis labels, or even the entire chart which is what you can see below. The following change in orientation to a vertical layout provides more space for accommodating extended item names.<\/p>\n<pre><code class=\"lang-javascript\">chart.isVertical(true)<span class=\"hljs-comment\">;<\/span>\r\n<\/code><\/pre>\n<p>Additionally, you can arrange the bars in reverse order to enhance the legibility of the waterfall chart.<\/p>\n<pre><code class=\"lang-javascript\"><span class=\"hljs-selector-tag\">chart<\/span><span class=\"hljs-selector-class\">.xScale<\/span>()<span class=\"hljs-selector-class\">.inverted<\/span>(<span class=\"hljs-selector-tag\">true<\/span>);\r\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-3.png\" width=\"100%\" alt=\"Customized JS Waterfall Chart 2\"><\/p>\n<h3 id=\"3-configure-labels\">3. Configure Labels<\/h3>\n<p>Labels play a crucial role in conveying information to viewers. By customizing labels, you can significantly enhance the chart&#39;s visual presentation and readability.<\/p>\n<p>To start, enable series labels by simply removing the <code>series.labels(false);<\/code> line. Labels are displayed by default unless specified otherwise.<\/p>\n<p>Next, for instance, customize the appearance of labels within the chart using HTML as shown below. The formatting logic applied within the corresponding function allows you to apply different styles depending on whether the label represents a total value or a non-total value. Total values are displayed in red with a lighter font weight, while non-total values are shown in gray. Additionally, rounded values (with zero decimal places) are displayed in both cases.<\/p>\n<pre><code class=\"lang-javascript\">chart.labels()\r\n  .useHtml(<span class=\"hljs-literal\">true<\/span>)\r\n  .format(function() {\r\n    <span class=\"hljs-keyword\">if<\/span> (<span class=\"hljs-keyword\">this<\/span>.isTotal)\r\n      <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">\"&lt;span style='color: #dd2c00; font-weight: 100; font-size: 11'&gt;\"<\/span> +\r\n        <span class=\"hljs-keyword\">this<\/span>.absolute.toFixed(<span class=\"hljs-number\">0<\/span>) + <span class=\"hljs-string\">\"M\"<\/span> + <span class=\"hljs-string\">\"&lt;\/span&gt;\"<\/span>;\r\n      <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">\"&lt;span style='color: gray; font-weight: 100; font-size: 11'&gt;\"<\/span> +\r\n        <span class=\"hljs-keyword\">this<\/span>.diff.toFixed(<span class=\"hljs-number\">0<\/span>) + <span class=\"hljs-string\">\"M\"<\/span> + <span class=\"hljs-string\">\"&lt;\/span&gt;\"<\/span>;\r\n  });\r\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-4.png\" width=\"100%\" alt=\"Customized JS Waterfall Chart 3\"><\/p>\n<h3 id=\"4-name-chart\">4. Name Chart<\/h3>\n<p>Providing a clear and informative title for your waterfall chart is essential to help users quickly understand what the graphic represents. Here\u2019s how you can name the chart, making it obvious at a glance that it displays the income statement for Twitter Inc. for the year 2021.<\/p>\n<pre><code class=\"lang-javascript\">chart.title(<span class=\"hljs-string\">\"Income Statement for Twitter Inc. (2021)\"<\/span>)<span class=\"hljs-comment\">;<\/span>\r\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-5.png\" width=\"100%\" alt=\"Customized JS Waterfall Chart 4\"><\/p>\n<h3 id=\"5-customize-value-axis\">5. Customize Value Axis<\/h3>\n<p>You can also improve the clarity of the chart by changing the format of the values represented on the value (Y) axis. Specifically, you can name the axis &quot;USD&quot; to denote the currency. Additionally, you can format the values to be more understandable, such as by showing values in billions of USD for larger values, like in this case.<\/p>\n<pre><code class=\"lang-javascript\"><span class=\"hljs-comment\">\/\/ customize the format of the y-axis labels<\/span>\r\n<span class=\"hljs-selector-tag\">chart<\/span><span class=\"hljs-selector-class\">.yAxis<\/span>()<span class=\"hljs-selector-class\">.labels<\/span>()<span class=\"hljs-selector-class\">.format<\/span>(<span class=\"hljs-string\">\"{%Value}{scale:(1000)(1)|(B)}\"<\/span>);\r\n\r\n<span class=\"hljs-comment\">\/\/ set the y-axis title<\/span>\r\n<span class=\"hljs-selector-tag\">chart<\/span><span class=\"hljs-selector-class\">.yAxis<\/span>()<span class=\"hljs-selector-class\">.title<\/span>(<span class=\"hljs-string\">\"USD\"<\/span>);\r\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-6.png\" width=\"100%\" alt=\"Customized JS Waterfall Chart 5\"><\/p>\n<h3 id=\"6-configure-tooltip\">6. Configure Tooltip<\/h3>\n<p>Tooltips provide valuable information to users when interacting with the chart. To make tooltips more direct and precise, you can customize them as you need. In this case, for example, the &quot;M USD&quot; in the tooltip title makes it obvious that values within the tooltip are displayed in millions of USD.<\/p>\n<pre><code class=\"lang-javascript\"><span class=\"hljs-selector-tag\">chart<\/span><span class=\"hljs-selector-class\">.tooltip<\/span>()<span class=\"hljs-selector-class\">.titleFormat<\/span>(<span class=\"hljs-string\">\"{%x}\"<\/span> + <span class=\"hljs-string\">\" (M USD)\"<\/span>);\r\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-7.png\" width=\"100%\" alt=\"Customized JS Waterfall Chart 6\"><\/p>\n<h3 id=\"7-configure-visual-appearance\">7. Configure Visual Appearance<\/h3>\n<p>You can also improve the visual appearance by customizing the coloring. For instance, the code below enriches the connectors\u2019 stroke with a vibrant red color and a dashed pattern, making it visually striking.<\/p>\n<pre><code class=\"lang-javascript\"><span class=\"hljs-selector-tag\">chart<\/span><span class=\"hljs-selector-class\">.connectorStroke<\/span>(<span class=\"hljs-string\">\"#ff6666\"<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-string\">\"2 2\"<\/span>, <span class=\"hljs-string\">\"round\"<\/span>);\r\n<\/code><\/pre>\n<p>Furthermore, you can configure the appearance of the bars in different states, including normal, hovered, and selected. Here\u2019s how you can specify distinct visual settings for falling and rising values, tailoring the chart&#39;s visual presentation according to your preferences and specific design requirements.<\/p>\n<pre><code class=\"lang-javascript\"><span class=\"hljs-comment\">\/\/ normal state<\/span>\r\n<span class=\"hljs-selector-tag\">series<\/span><span class=\"hljs-selector-class\">.normal<\/span>()\r\n  <span class=\"hljs-selector-class\">.fill<\/span>(<span class=\"hljs-string\">\"#8C8C8C\"<\/span>, <span class=\"hljs-number\">0.7<\/span>)\r\n  <span class=\"hljs-selector-class\">.hatchFill<\/span>(<span class=\"hljs-string\">\"forward-diagonal\"<\/span>, <span class=\"hljs-string\">\"#BEBEBE\"<\/span>, <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">10<\/span>)\r\n  <span class=\"hljs-selector-class\">.stroke<\/span>(<span class=\"hljs-string\">\"#8C8C8C\"<\/span>)\r\n  <span class=\"hljs-selector-class\">.fallingFill<\/span>(<span class=\"hljs-string\">\"#FC4E6F\"<\/span>, <span class=\"hljs-number\">0.8<\/span>)\r\n  <span class=\"hljs-selector-class\">.fallingStroke<\/span>(<span class=\"hljs-string\">\"#FC4E6F\"<\/span>, <span class=\"hljs-number\">1<\/span>, )\r\n  <span class=\"hljs-selector-class\">.risingFill<\/span>(<span class=\"hljs-string\">\"#44C882\"<\/span>, <span class=\"hljs-number\">0.8<\/span>)\r\n  <span class=\"hljs-selector-class\">.risingStroke<\/span>(<span class=\"hljs-string\">\"44C882\"<\/span>);\r\n<span class=\"hljs-comment\">\/\/ hovered state<\/span>\r\n<span class=\"hljs-selector-tag\">series<\/span><span class=\"hljs-selector-class\">.hovered<\/span>()\r\n  <span class=\"hljs-selector-class\">.fill<\/span>(<span class=\"hljs-string\">\"#8C8C8C\"<\/span>, <span class=\"hljs-number\">0.1<\/span>)\r\n  <span class=\"hljs-selector-class\">.hatchFill<\/span>(<span class=\"hljs-string\">\"forward-diagonal\"<\/span>, <span class=\"hljs-string\">\"#117A65\"<\/span>, <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">10<\/span>)\r\n  <span class=\"hljs-selector-class\">.stroke<\/span>(<span class=\"hljs-string\">\"#8C8C8C\"<\/span>, <span class=\"hljs-number\">2<\/span>)\r\n  <span class=\"hljs-selector-class\">.fallingFill<\/span>(<span class=\"hljs-string\">\"#FC4E6F\"<\/span>, <span class=\"hljs-number\">0.1<\/span>)\r\n  <span class=\"hljs-selector-class\">.fallingStroke<\/span>(<span class=\"hljs-string\">\"#FC4E6F\"<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-string\">\"10 5\"<\/span>, )\r\n  <span class=\"hljs-selector-class\">.risingFill<\/span>(<span class=\"hljs-string\">\"44C882\"<\/span>, <span class=\"hljs-number\">0.1<\/span>)\r\n  <span class=\"hljs-selector-class\">.risingStroke<\/span>(<span class=\"hljs-string\">\"44C882\"<\/span>, <span class=\"hljs-number\">2<\/span>);\r\n<span class=\"hljs-comment\">\/\/ selected state<\/span>\r\n<span class=\"hljs-selector-tag\">series<\/span><span class=\"hljs-selector-class\">.selected<\/span>()\r\n  <span class=\"hljs-selector-class\">.fill<\/span>(<span class=\"hljs-string\">\"#8C8C8C\"<\/span>, <span class=\"hljs-number\">0.5<\/span>)\r\n  <span class=\"hljs-selector-class\">.hatchFill<\/span>(<span class=\"hljs-string\">\"forward-diagonal\"<\/span>, <span class=\"hljs-string\">\"#8C8C8C\"<\/span>, <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">10<\/span>)\r\n  <span class=\"hljs-selector-class\">.stroke<\/span>(<span class=\"hljs-string\">\"#8C8C8C\"<\/span>, <span class=\"hljs-number\">4<\/span>)\r\n  <span class=\"hljs-selector-class\">.fallingFill<\/span>(<span class=\"hljs-string\">\"#922B21\"<\/span>, <span class=\"hljs-number\">0.5<\/span>)\r\n  <span class=\"hljs-selector-class\">.fallingStroke<\/span>(<span class=\"hljs-string\">\"#B03A2E\"<\/span>, <span class=\"hljs-number\">4<\/span>, )\r\n  <span class=\"hljs-selector-class\">.risingFill<\/span>(<span class=\"hljs-string\">\"#117864\"<\/span>, <span class=\"hljs-number\">0.5<\/span>)\r\n  <span class=\"hljs-selector-class\">.risingStroke<\/span>(<span class=\"hljs-string\">\"#148F77\"<\/span>, <span class=\"hljs-number\">1<\/span>);\r\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-9.png\" width=\"100%\" aidth=\"100%\" alt=\"Customized JS Waterfall Chart 7\"><\/p>\n<h3 id=\"8-add-arrow-to-visualize-total-change\">8. Add Arrow to Visualize Total Change<\/h3>\n<p>In the final step of this waterfall chart tutorial, I\u2019ll show you how to add an arrow to connect the initial and final values, providing a clear visual representation of the total change. Check it out.<\/p>\n<pre><code class=\"lang-javascript\"><span class=\"hljs-comment\">\/\/ add an arrow<\/span>\r\nvar totalChangeArrow = chart.addArrow({\r\n  <span class=\"hljs-keyword\">from<\/span>: <span class=\"hljs-string\">\"Revenue\"<\/span>,\r\n  <span class=\"hljs-keyword\">to<\/span>: <span class=\"hljs-string\">\"Net income (loss)\"<\/span>\r\n});\r\n\r\n<span class=\"hljs-comment\">\/\/ set arrow's label format<\/span>\r\ntotalChangeArrow.label().<span class=\"hljs-built_in\">format<\/span>(<span class=\"hljs-string\">\"{%Value}{numDecimals:0}\"<\/span> + <span class=\"hljs-string\">\"M\"<\/span>);\r\n<\/code><\/pre>\n<h3 id=\"final-result\">Final Result<\/h3>\n<p>After implementing these customizations one by one, I am excited to present the final version of the waterfall chart powered by JavaScript. Its sleek design and smooth interactivity make it an exceptional tool for data visualization.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-10.png\" width=\"100%\" alt=\"Final JS Waterfall Chart\"><\/p>\n<p>Feel free to access and modify the source code on <a href=\"https:\/\/playground.anychart.com\/44uzsMSk\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a> to suit your specific needs. Experiment with colors, interactions, and other features to create a chart that perfectly matches your unique style. For your convenience, I have included the entire code of this JS waterfall chart below.<\/p>\n<pre><code class=\"lang-html\"><span class=\"hljs-meta\">&lt;!DOCTYPE html&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span> <span class=\"hljs-attr\">lang<\/span>=<span class=\"hljs-string\">\"en\"<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">meta<\/span> <span class=\"hljs-attr\">charset<\/span>=<span class=\"hljs-string\">\"utf-8\"<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title<\/span>&gt;<\/span>JavaScript Waterfall Chart<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">title<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">\"https:\/\/cdn.anychart.com\/releases\/8.11.1\/js\/anychart-core.min.js\"<\/span>&gt;<\/span><span class=\"undefined\"><\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">\"https:\/\/cdn.anychart.com\/releases\/8.11.1\/js\/anychart-waterfall.min.js\"<\/span>&gt;<\/span><span class=\"undefined\"><\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">style<\/span>&gt;<\/span><span class=\"css\">\r\n      <span class=\"hljs-selector-tag\">html<\/span>, <span class=\"hljs-selector-tag\">body<\/span>, <span class=\"hljs-selector-id\">#WaterfallContainer<\/span> {\r\n        <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">100%<\/span>;\r\n        <span class=\"hljs-attribute\">height<\/span>: <span class=\"hljs-number\">100%<\/span>;\r\n        <span class=\"hljs-attribute\">margin<\/span>: <span class=\"hljs-number\">0<\/span>;\r\n        <span class=\"hljs-attribute\">padding<\/span>: <span class=\"hljs-number\">0<\/span>;\r\n      }\r\n    <\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">style<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">head<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"WaterfallContainer\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span>&gt;<\/span><span class=\"actionscript\">\r\n      anychart.onDocumentReady(<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-params\">()<\/span> <\/span>{\r\n        <span class=\"hljs-comment\">\/\/ set the data<\/span>\r\n        <span class=\"hljs-keyword\">var<\/span> data = [\r\n          { x: <span class=\"hljs-string\">\"Revenue\"<\/span>, value: <span class=\"hljs-number\">5077.482<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Cost of revenue\"<\/span>, value: <span class=\"hljs-number\">-1797.510<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Gross profit\"<\/span>, isTotal: <span class=\"hljs-literal\">true<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Operating expenses\"<\/span>, value: <span class=\"hljs-number\">-3772.711<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Income (loss) from operations\"<\/span>, isTotal: <span class=\"hljs-literal\">true<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Interest expense\"<\/span>, value: <span class=\"hljs-number\">-51.186<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Interest income\"<\/span>, value: <span class=\"hljs-number\">35.683<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Other income (expense), net\"<\/span>, value: <span class=\"hljs-number\">97.129<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Income (loss) before income taxes\"<\/span>, isTotal: <span class=\"hljs-literal\">true<\/span> },\r\n          { x: <span class=\"hljs-string\">\"(Provision) benefit for income taxes\"<\/span>, value: <span class=\"hljs-number\">189.704<\/span> },\r\n          { x: <span class=\"hljs-string\">\"Net income (loss)\"<\/span>, isTotal: <span class=\"hljs-literal\">true<\/span> }\r\n        ];\r\n        <span class=\"hljs-comment\">\/\/ create a waterfall chart<\/span>\r\n        <span class=\"hljs-keyword\">var<\/span> chart = anychart.waterfall();\r\n        <span class=\"hljs-comment\">\/\/ add the zero line<\/span>\r\n        <span class=\"hljs-keyword\">var<\/span> line = chart.lineMarker().value(<span class=\"hljs-number\">0<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ rotate the chart<\/span>\r\n        chart.isVertical(<span class=\"hljs-literal\">true<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ set the reverse order of the bars<\/span>\r\n        chart.xScale().inverted(<span class=\"hljs-literal\">true<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ customize the labels<\/span>\r\n        chart.labels()\r\n          .useHtml(<span class=\"hljs-literal\">true<\/span>)\r\n          .format(<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span><span class=\"hljs-params\">()<\/span> <\/span>{\r\n            <span class=\"hljs-keyword\">if<\/span> (<span class=\"hljs-keyword\">this<\/span>.isTotal)\r\n              <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">\"&lt;span style='color: #dd2c00; font-weight: 100; font-size: 11'&gt;\"<\/span> +\r\n                <span class=\"hljs-keyword\">this<\/span>.absolute.toFixed(<span class=\"hljs-number\">0<\/span>) + <span class=\"hljs-string\">\"M\"<\/span> + <span class=\"hljs-string\">\"&lt;\/span&gt;\"<\/span>;\r\n              <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">\"&lt;span style='color: gray; font-weight: 100; font-size: 11'&gt;\"<\/span> +\r\n                <span class=\"hljs-keyword\">this<\/span>.diff.toFixed(<span class=\"hljs-number\">0<\/span>) + <span class=\"hljs-string\">\"M\"<\/span> + <span class=\"hljs-string\">\"&lt;\/span&gt;\"<\/span>;\r\n          });\r\n        <span class=\"hljs-comment\">\/\/ set the chart title<\/span>\r\n        chart.title(<span class=\"hljs-string\">\"Income Statement for Twitter Inc. (2021)\"<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ add the usd caption on the y-axis labels<\/span>\r\n        chart.yAxis().labels().format(<span class=\"hljs-string\">\"{%Value}{scale:(1000)(1)|(B)}\"<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ set the y-axis title<\/span>\r\n        chart.yAxis().title(<span class=\"hljs-string\">\"USD\"<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ create a series and set the data<\/span>\r\n        <span class=\"hljs-keyword\">var<\/span> series = chart.waterfall(data);\r\n        <span class=\"hljs-comment\">\/\/ configure the tooltip title<\/span>\r\n        chart.tooltip().titleFormat(<span class=\"hljs-string\">\"{%x}\"<\/span> + <span class=\"hljs-string\">\" (M USD)\"<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ customize the connector stroke<\/span>\r\n        chart.connectorStroke(<span class=\"hljs-string\">\"#ff6666\"<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-string\">\"2 2\"<\/span>, <span class=\"hljs-string\">\"round\"<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ configure the visual settings of the series:<\/span>\r\n        <span class=\"hljs-comment\">\/\/ normal state<\/span>\r\n        series.normal()\r\n          .fill(<span class=\"hljs-string\">\"#8C8C8C\"<\/span>, <span class=\"hljs-number\">0.7<\/span>)\r\n          .hatchFill(<span class=\"hljs-string\">\"forward-diagonal\"<\/span>, <span class=\"hljs-string\">\"#BEBEBE\"<\/span>, <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">10<\/span>)\r\n          .stroke(<span class=\"hljs-string\">\"#8C8C8C\"<\/span>)\r\n          .fallingFill(<span class=\"hljs-string\">\"#FC4E6F\"<\/span>, <span class=\"hljs-number\">0.8<\/span>)\r\n          .fallingStroke(<span class=\"hljs-string\">\"#FC4E6F\"<\/span>, <span class=\"hljs-number\">1<\/span>, )\r\n          .risingFill(<span class=\"hljs-string\">\"#44C882\"<\/span>, <span class=\"hljs-number\">0.8<\/span>)\r\n          .risingStroke(<span class=\"hljs-string\">\"44C882\"<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ hovered state<\/span>\r\n        series.hovered()\r\n          .fill(<span class=\"hljs-string\">\"#8C8C8C\"<\/span>, <span class=\"hljs-number\">0.1<\/span>)\r\n          .hatchFill(<span class=\"hljs-string\">\"forward-diagonal\"<\/span>, <span class=\"hljs-string\">\"#117A65\"<\/span>, <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">10<\/span>)\r\n          .stroke(<span class=\"hljs-string\">\"#8C8C8C\"<\/span>, <span class=\"hljs-number\">2<\/span>)\r\n          .fallingFill(<span class=\"hljs-string\">\"#FC4E6F\"<\/span>, <span class=\"hljs-number\">0.1<\/span>)\r\n          .fallingStroke(<span class=\"hljs-string\">\"#FC4E6F\"<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-string\">\"10 5\"<\/span>, )\r\n          .risingFill(<span class=\"hljs-string\">\"44C882\"<\/span>, <span class=\"hljs-number\">0.1<\/span>)\r\n          .risingStroke(<span class=\"hljs-string\">\"44C882\"<\/span>, <span class=\"hljs-number\">2<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ selected state<\/span>\r\n        series.selected()\r\n          .fill(<span class=\"hljs-string\">\"#8C8C8C\"<\/span>, <span class=\"hljs-number\">0.5<\/span>)\r\n          .hatchFill(<span class=\"hljs-string\">\"forward-diagonal\"<\/span>, <span class=\"hljs-string\">\"#8C8C8C\"<\/span>, <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">10<\/span>)\r\n          .stroke(<span class=\"hljs-string\">\"#8C8C8C\"<\/span>, <span class=\"hljs-number\">4<\/span>)\r\n          .fallingFill(<span class=\"hljs-string\">\"#922B21\"<\/span>, <span class=\"hljs-number\">0.5<\/span>)\r\n          .fallingStroke(<span class=\"hljs-string\">\"#B03A2E\"<\/span>, <span class=\"hljs-number\">4<\/span>, )\r\n          .risingFill(<span class=\"hljs-string\">\"#117864\"<\/span>, <span class=\"hljs-number\">0.5<\/span>)\r\n          .risingStroke(<span class=\"hljs-string\">\"#148F77\"<\/span>, <span class=\"hljs-number\">1<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ add an arrow<\/span>\r\n        <span class=\"hljs-keyword\">var<\/span> totalChangeArrow = chart.addArrow({\r\n          from: <span class=\"hljs-string\">\"Revenue\"<\/span>,\r\n          to: <span class=\"hljs-string\">\"Net income (loss)\"<\/span>\r\n        });\r\n        <span class=\"hljs-comment\">\/\/ set arrow's label format<\/span>\r\n        totalChangeArrow.label().format(<span class=\"hljs-string\">\"{%Value}{numDecimals:0}\"<\/span> + <span class=\"hljs-string\">\"M\"<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ set the container id for the waterfall chart<\/span>\r\n        chart.container(<span class=\"hljs-string\">\"WaterfallContainer\"<\/span>);\r\n        <span class=\"hljs-comment\">\/\/ draw the resulting chart<\/span>\r\n        chart.draw();\r\n      });\r\n    <\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">body<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">html<\/span>&gt;<\/span>\r\n<\/code><\/pre>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>This tutorial was designed to be a comprehensive and user-friendly guide to ensure you can effortlessly create waterfall charts using JavaScript (HTML5). I hope we&#39;ve succeeded in that endeavor.<\/p>\n<p>If you have any questions or require further assistance, please don&#39;t hesitate to ask in the comments section. I&#39;m here to help and will do my best to address any doubts you may have. I&#39;m eagerly looking forward to the fantastic waterfall charts you&#39;ll create using this guide, so feel free to share your creative visualizations. For inspiration, you can take a look at this <a href=\"https:\/\/www.anychart.com\/products\/anychart\/gallery\/Waterfall_Charts\/\">waterfall chart gallery<\/a> and learn more in the <a href=\"https:\/\/docs.anychart.com\/Basic_Charts\/Waterfall_Chart\" target=\"_blank\" rel=\"nofollow\">waterfall chart documentation<\/a>. And your contributions can be a source of further inspiration for others, including myself.<\/p>\n<p>Happy charting!<\/p>\n<hr \/>\n<p><strong><em>Published with the permission of Awan Shrestha. Originally appeared on <a href=\"https:\/\/dev.to\/awanshrestha\/how-to-build-a-waterfall-chart-with-javascript-2a31\" target=\"_blank\" rel=\"nofollow\">DEV Community<\/a> under the title &#8220;How to Build a Waterfall Chart with JavaScript&#8221; on November 1, 2023.<\/p>\n<p>You might also be interested in reading the <a href=\"https:\/\/www.anychart.com\/blog\/2021\/03\/16\/waterfall-chart-js\/\">JavaScript Waterfall Chart Tutorial<\/a> specifically produced by Dilhani Withanage for our blog earlier, visualizing the 2020 income statement for Alphabet Inc. (GOOGL) step by step.<\/p>\n<p>Delve into other <a href=\"https:\/\/www.anychart.com\/blog\/category\/javascript-chart-tutorials\/\">JavaScript charting tutorials<\/a> and continue honing your skills in interactive data visualization.<\/p>\n<p>If you&#8217;re interested in contributing a guest post to our blog, please don&#8217;t hesitate to <a href=\"https:\/\/www.anychart.com\/support\/\">contact us<\/a>.<\/strong><\/em><\/p>\n<hr \/>\n<p><!-- SyntaxHighlighter --><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/default.min.css\"><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/atom-one-light.min.css\"><script src=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/highlight.min.js\"><\/script><script>hljs.initHighlightingOnLoad();<\/script><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Data visualization is an essential tool for understanding complex data sets and effectively conveying insights. Among the various types of charts and graphs used for this purpose, the waterfall chart stands out as a powerful way to represent changes in financial data, such as revenue, expenses, and profits over a specific period. In this tutorial, [&hellip;]<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":22,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,263,8,23,13,279,4],"tags":[619,618,53,254,3149,284,3612,258,471,266,620,1292,880,806,3352,509,2220,54,1389,2757,256,3377,1111,844,165,313,1370,774,2842,3613,1498,805,1762,2013,2014,32,55,878,2286,2287,2288,167,146,433,152,80,151,36,907,141,249,3111,81,57,1238,142,99,58,65,56,3526,3099,172,570,571,3100,243,2816,1763,804],"class_list":["post-16970","post","type-post","status-publish","format-standard","hentry","category-anychart-charting-component","category-big-data","category-business-intelligence","category-html5","category-javascript","category-javascript-chart-tutorials","category-tips-and-tricks","tag-analysis","tag-analytics","tag-anychart","tag-chart","tag-chart-development","tag-chart-examples","tag-chartins","tag-charts","tag-data-analysis","tag-data-analytics","tag-data-analytics-examples","tag-data-chart","tag-data-charting","tag-data-charts","tag-data-graphic","tag-data-graphics","tag-data-visual","tag-data-visualization","tag-data-visualization-best-pracices","tag-data-visualization-development","tag-data-visualization-examples","tag-data-visualization-guide","tag-data-visualization-practice","tag-data-visualization-tutorial","tag-data-visualizations","tag-data-visuals","tag-data-viz-examples","tag-dataviz-examples","tag-dev-community","tag-dev-to","tag-example","tag-front-end-development","tag-guest-post","tag-html","tag-html-charts","tag-html5","tag-html5-charts","tag-income-data","tag-income-statement","tag-income-statement-data","tag-income-statement-data-visualization","tag-interactive-charts","tag-interactive-data-visualization","tag-interactive-graphics","tag-interactive-infographic","tag-interactive-javascript-dashboard","tag-interactive-visualizations","tag-javascript","tag-javascript-chart-tutorial","tag-javascript-charting","tag-javascript-charting-api","tag-javascript-charting-features","tag-javascript-charting-library","tag-javascript-charts","tag-javascript-graph","tag-javascript-graphics","tag-javascript-library","tag-js-chart","tag-js-charting","tag-js-charts","tag-js-library","tag-storytelling-examples","tag-tutorial","tag-twitter","tag-twitter-data","tag-visual-storytelling-examples","tag-waterfall-chart","tag-web-design","tag-web-developers","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>Building Waterfall Charts in JavaScript (HTML5): Tutorial<\/title>\n<meta name=\"description\" content=\"Learn to make interactive waterfall charts in JavaScript with ease! Follow the visualization of Twitter&#039;s income statement step-by-step in the new tutorial.\" \/>\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\/2023\/11\/02\/waterfall-charts-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building Waterfall Charts in JS\" \/>\n<meta property=\"og:description\" content=\"Learn to make interactive waterfall charts in JavaScript with ease! Follow the visualization of Twitter&#039;s income statement step-by-step in the new tutorial.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-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=\"2023-11-02T08:56:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-03T13:44:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-js-social.png\" \/>\n<meta name=\"author\" content=\"Awan Shrestha\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Building Waterfall Charts in JS\" \/>\n<meta name=\"twitter:description\" content=\"Learn to make interactive waterfall charts in JavaScript with ease! Follow the visualization of Twitter&#039;s income statement step-by-step in the new tutorial.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-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=\"Awan Shrestha\" \/>\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\/2023\/11\/02\/waterfall-charts-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/\"},\"author\":{\"name\":\"Awan Shrestha\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/3f107fdcb3fe326a63cd52812f5287c1\"},\"headline\":\"Building Waterfall Charts in JS\",\"datePublished\":\"2023-11-02T08:56:30+00:00\",\"dateModified\":\"2023-11-03T13:44:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/\"},\"wordCount\":1578,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart.png\",\"keywords\":[\"analysis\",\"analytics\",\"AnyChart\",\"chart\",\"chart development\",\"chart examples\",\"chartins\",\"charts\",\"data analysis\",\"data analytics\",\"data analytics examples\",\"data chart\",\"data charting\",\"data charts\",\"data graphic\",\"data graphics\",\"data visual\",\"Data Visualization\",\"data visualization best practices\",\"data visualization development\",\"data visualization examples\",\"data visualization guide\",\"data visualization practice\",\"data visualization tutorial\",\"data visualizations\",\"data visuals\",\"data viz examples\",\"dataviz examples\",\"DEV Community\",\"DEV.to\",\"example\",\"front-end development\",\"guest post\",\"HTML\",\"HTML charts\",\"HTML5\",\"html5 charts\",\"income data\",\"income statement\",\"income statement data\",\"income statement data visualization\",\"interactive charts\",\"interactive data visualization\",\"interactive graphics\",\"interactive infographic\",\"interactive javascript dashboard\",\"interactive visualizations\",\"JavaScript\",\"javascript chart tutorial\",\"javascript charting\",\"javascript charting api\",\"JavaScript charting features\",\"JavaScript charting library\",\"javascript charts\",\"javascript graph\",\"javascript graphics\",\"JavaScript library\",\"js chart\",\"js charting\",\"js charts\",\"js library\",\"storytelling examples\",\"tutorial\",\"Twitter\",\"Twitter data\",\"visual storytelling examples\",\"waterfall chart\",\"web design\",\"web developers\",\"web development\"],\"articleSection\":[\"AnyChart Charting Component\",\"Big Data\",\"Business Intelligence\",\"HTML5\",\"JavaScript\",\"JavaScript Chart Tutorials\",\"Tips and Tricks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/\",\"url\":\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/\",\"name\":\"Building Waterfall Charts in JavaScript (HTML5): Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart.png\",\"datePublished\":\"2023-11-02T08:56:30+00:00\",\"dateModified\":\"2023-11-03T13:44:06+00:00\",\"author\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/3f107fdcb3fe326a63cd52812f5287c1\"},\"description\":\"Learn to make interactive waterfall charts in JavaScript with ease! Follow the visualization of Twitter's income statement step-by-step in the new tutorial.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#primaryimage\",\"url\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart.png\",\"contentUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart.png\",\"width\":1366,\"height\":768},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.anychart.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building Waterfall Charts in JS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\",\"url\":\"https:\/\/www.anychart.com\/blog\/\",\"name\":\"AnyChart News\",\"description\":\"AnyChart JS Charts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.anychart.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/3f107fdcb3fe326a63cd52812f5287c1\",\"name\":\"Awan Shrestha\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/02ebd18c927547ca82372246dddcc3aebfa98928cb91405eef1a63ece7f17518?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/02ebd18c927547ca82372246dddcc3aebfa98928cb91405eef1a63ece7f17518?s=96&r=g\",\"caption\":\"Awan Shrestha\"},\"url\":\"https:\/\/www.anychart.com\/blog\/author\/awan-shrestha\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Building Waterfall Charts in JavaScript (HTML5): Tutorial","description":"Learn to make interactive waterfall charts in JavaScript with ease! Follow the visualization of Twitter's income statement step-by-step in the new tutorial.","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\/2023\/11\/02\/waterfall-charts-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Building Waterfall Charts in JS","og_description":"Learn to make interactive waterfall charts in JavaScript with ease! Follow the visualization of Twitter's income statement step-by-step in the new tutorial.","og_url":"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/","og_site_name":"AnyChart News","article_publisher":"https:\/\/www.facebook.com\/AnyCharts","article_published_time":"2023-11-02T08:56:30+00:00","article_modified_time":"2023-11-03T13:44:06+00:00","og_image":[{"url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-js-social.png","type":"","width":"","height":""}],"author":"Awan Shrestha","twitter_card":"summary_large_image","twitter_title":"Building Waterfall Charts in JS","twitter_description":"Learn to make interactive waterfall charts in JavaScript with ease! Follow the visualization of Twitter's income statement step-by-step in the new tutorial.","twitter_image":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart-js-social.png","twitter_creator":"@AnyChart","twitter_site":"@AnyChart","twitter_misc":{"Written by":"Awan Shrestha","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#article","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/"},"author":{"name":"Awan Shrestha","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/3f107fdcb3fe326a63cd52812f5287c1"},"headline":"Building Waterfall Charts in JS","datePublished":"2023-11-02T08:56:30+00:00","dateModified":"2023-11-03T13:44:06+00:00","mainEntityOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/"},"wordCount":1578,"commentCount":0,"image":{"@id":"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart.png","keywords":["analysis","analytics","AnyChart","chart","chart development","chart examples","chartins","charts","data analysis","data analytics","data analytics examples","data chart","data charting","data charts","data graphic","data graphics","data visual","Data Visualization","data visualization best practices","data visualization development","data visualization examples","data visualization guide","data visualization practice","data visualization tutorial","data visualizations","data visuals","data viz examples","dataviz examples","DEV Community","DEV.to","example","front-end development","guest post","HTML","HTML charts","HTML5","html5 charts","income data","income statement","income statement data","income statement data visualization","interactive charts","interactive data visualization","interactive graphics","interactive infographic","interactive javascript dashboard","interactive visualizations","JavaScript","javascript chart tutorial","javascript charting","javascript charting api","JavaScript charting features","JavaScript charting library","javascript charts","javascript graph","javascript graphics","JavaScript library","js chart","js charting","js charts","js library","storytelling examples","tutorial","Twitter","Twitter data","visual storytelling examples","waterfall chart","web design","web developers","web development"],"articleSection":["AnyChart Charting Component","Big Data","Business Intelligence","HTML5","JavaScript","JavaScript Chart Tutorials","Tips and Tricks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/","url":"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/","name":"Building Waterfall Charts in JavaScript (HTML5): Tutorial","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#primaryimage"},"image":{"@id":"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart.png","datePublished":"2023-11-02T08:56:30+00:00","dateModified":"2023-11-03T13:44:06+00:00","author":{"@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/3f107fdcb3fe326a63cd52812f5287c1"},"description":"Learn to make interactive waterfall charts in JavaScript with ease! Follow the visualization of Twitter's income statement step-by-step in the new tutorial.","breadcrumb":{"@id":"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#primaryimage","url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart.png","contentUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/10\/waterfall-chart.png","width":1366,"height":768},{"@type":"BreadcrumbList","@id":"https:\/\/www.anychart.com\/blog\/2023\/11\/02\/waterfall-charts-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.anychart.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Building Waterfall Charts in JS"}]},{"@type":"WebSite","@id":"https:\/\/www.anychart.com\/blog\/#website","url":"https:\/\/www.anychart.com\/blog\/","name":"AnyChart News","description":"AnyChart JS Charts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.anychart.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/3f107fdcb3fe326a63cd52812f5287c1","name":"Awan Shrestha","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/02ebd18c927547ca82372246dddcc3aebfa98928cb91405eef1a63ece7f17518?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/02ebd18c927547ca82372246dddcc3aebfa98928cb91405eef1a63ece7f17518?s=96&r=g","caption":"Awan Shrestha"},"url":"https:\/\/www.anychart.com\/blog\/author\/awan-shrestha\/"}]}},"_links":{"self":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/16970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/comments?post=16970"}],"version-history":[{"count":12,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/16970\/revisions"}],"predecessor-version":[{"id":16973,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/16970\/revisions\/16973"}],"wp:attachment":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/media?parent=16970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/categories?post=16970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/tags?post=16970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}