<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Heat map - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Heat map - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Mon, 01 Jun 2026 05:28:52 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/heat-map/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Create an Interactive Heatmap Using JavaScript ]]>
                </title>
                <description>
                    <![CDATA[ By Shachee Swadia Data visualization is a powerful tool that helps us make sense of complex data. With it, we can spot patterns and trends that might take much more time to become obvious just by looking at raw numbers.  One particularly useful chart... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/interactive-heatmap-in-javascript/</link>
                <guid isPermaLink="false">66d460f633b83c4378a51841</guid>
                
                    <category>
                        <![CDATA[ data visualization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Heat map ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 16 May 2023 23:26:39 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/05/heatmapchartjs.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Shachee Swadia</p>
<p>Data visualization is a powerful tool that helps us make sense of complex data. With it, we can spot patterns and trends that might take much more time to become obvious just by looking at raw numbers. </p>
<p>One particularly useful chart type is the <strong>heatmap</strong>, and I’m excited to teach you how to create one with JavaScript in this tutorial.</p>
<h2 id="heading-what-is-a-heatmap">What is a Heatmap?</h2>
<p>A heatmap is a two-dimensional representation of the magnitude of a phenomenon through colors. It provides a <a target="_blank" href="https://datavizcatalogue.com/methods/heatmap.html">quick visual summary</a> of high and low values in the data. </p>
<p>For instance, did you know that an average of 108 people died per day in road accidents in the U.S. in 2021? Using a heatmap chart, we can analyze the days and times of fatal accidents. This will be the visualization we will be building during the tutorial.</p>
<p>So, grab your cup of coffee and let's dive into this step-by-step guide. By the end, you'll have the skills to easily create your own interactive JavaScript heatmaps.</p>
<h1 id="heading-the-heatmap-chart-well-build">The Heatmap Chart We'll Build</h1>
<p>Here is how the final JS-based heatmap chart will look:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/05/heatmapchart-006.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Ready to dive in? Let's go!</p>
<h1 id="heading-how-to-make-a-javascript-heatmap"><strong>How to Make a JavaScript Heatmap</strong></h1>
<p>Great, let's start creating a simple yet beautiful heatmap chart using JavaScript. With just four easy-to-follow steps, you'll have a stunning interactive heatmap in no time. </p>
<p>Don't worry about any complicated coding or overwhelming technicalities. We'll keep things straightforward and easy to understand.</p>
<h2 id="heading-1-create-an-html-page">1. Create an HTML Page</h2>
<p>First things first, we need to create a web page that'll hold our super-cool heatmap. We start by making a basic HTML page, complete with a <code>div</code> element to hold our chart. Let’s also specify the style of the <code>div</code> to make it stretch over the whole page. Don't worry, it’s easy-peasy:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Heatmap in JavaScript<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">style</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text/css"</span>&gt;</span><span class="css">      
      <span class="hljs-selector-tag">html</span>, <span class="hljs-selector-tag">body</span>, <span class="hljs-selector-id">#container</span> { 
        <span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>; <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>; <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>; 
      } 
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"container"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<h2 id="heading-2-include-the-required-javascript-files">2. Include the Required JavaScript Files</h2>
<p>Okay, let's be real: building a JS heatmap from scratch would be a real pain in the you-know-what. Instead, we're gonna take the easier route and use a JavaScript charting library. </p>
<p>There are a <a target="_blank" href="https://en.wikipedia.org/wiki/Comparison_of_JavaScript_charting_libraries">ton of various JS charting libraries</a> out there. For this project, we're gonna go with the <a target="_blank" href="https://www.anychart.com/">AnyChart JS library</a>, which supports heatmap charts and is free for personal and other non-profit purposes. </p>
<p>To make things work, we need to add a couple of scripts to our web page's <code>&lt;head&gt;</code> section. Specifically, we need to include the base and heatmap modules. Sounds easy, right?</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Heatmap in JavaScript<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
    <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.0/js/anychart-core.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
    <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.0/js/anychart-heatmap.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span> 
    <span class="hljs-tag">&lt;<span class="hljs-name">style</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text/css"</span>&gt;</span><span class="css">      
      <span class="hljs-selector-tag">html</span>, <span class="hljs-selector-tag">body</span>, <span class="hljs-selector-id">#container</span> { 
        <span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>; <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>; <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>; 
      } 
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>  
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"container"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
      <span class="hljs-comment">// All the code for the JS heatmap will come here</span>
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<h2 id="heading-3-add-the-data">3. Add the Data</h2>
<p>Each chart is complete with the data, right? We’re gonna grab our data from the <a target="_blank" href="https://injuryfacts.nsc.org/motor-vehicle/overview/crashes-by-time-of-day-and-day-of-week/">NSC website</a> and add it to our HTML file in the proper format.</p>
<p>For our heatmap, each data point needs to include an <code>x</code> value (day), a <code>y</code> value (hour), and a <code>heat</code> value (number of accidents). We'll wrap this data in a function that we'll call when we create the JS chart.</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getData</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> [
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">705</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">713</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">657</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">957</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1137</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">956</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">482</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">641</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">631</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">905</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1137</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">986</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">465</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">616</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">627</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">914</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1159</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1066</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">584</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">718</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">660</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">966</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1161</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1186</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">715</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">747</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">738</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1056</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1426</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1631</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1383</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">641</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">635</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1034</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1400</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1593</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1486</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">695</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">564</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">932</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1292</span>
    },
    {
      <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
      <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
      <span class="hljs-attr">heat</span>: <span class="hljs-number">1211</span>
    }
  ];
}
</code></pre>
<h2 id="heading-4-write-the-necessary-js-code-for-the-chart">4. Write the Necessary JS Code for the Chart</h2>
<p>Here's the fun part: it's time to write the JavaScript code that'll make our heatmap chart look amazing.</p>
<p>We'll enclose everything in a function to ensure the code only executes when the page is ready. We'll create the graph using the <code>heatmap()</code> function and add the data we created in the previous step.</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> chart = anychart.heatMap(getData());
</code></pre>
<p>Then, we'll give the chart a descriptive title:</p>
<pre><code class="lang-js">chart.title(<span class="hljs-string">"Fatal Car Crashes in U.S. in 2021 by Time of Day and Day of Week”);</span>
</code></pre>
<p>Finally, we'll set the container reference and draw the chart. Voilà!</p>
<pre><code class="lang-js">сhart.container(<span class="hljs-string">'container’);
chart.draw();</span>
</code></pre>
<p>And there you have it. With just a little bit of HTML and JavaScript, you can create a totally rad interactive heatmap. You can see the entire code of this JS-based heatmap below and check it out live <a target="_blank" href="https://playground.anychart.com/DEyz9Bjb">here</a>. After that, we'll learn how to customize our heatmap in all kinds of fun ways.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/05/heatmapchart-001.png" alt="Image" width="600" height="400" loading="lazy"></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Heatmap in JavaScript<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
    <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.0/js/anychart-core.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
    <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.0/js/anychart-heatmap.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span> 
    <span class="hljs-tag">&lt;<span class="hljs-name">style</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text/css"</span>&gt;</span><span class="css">      
      <span class="hljs-selector-tag">html</span>, <span class="hljs-selector-tag">body</span>, <span class="hljs-selector-id">#container</span> { 
        <span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>; <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>; <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>; 
      } 
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>  
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"container"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
      anychart.onDocumentReady(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
        <span class="hljs-comment">// create a heatmap</span>
        <span class="hljs-keyword">let</span> chart = anychart.heatMap(getData());
        <span class="hljs-comment">// name the heatmap</span>
        chart.title(<span class="hljs-string">"Fatal Car Crashes in U.S. in 2021 by Time of Day and Day of Week"</span>);
        <span class="hljs-comment">// set the container for the heatmap</span>
        chart.container(<span class="hljs-string">"container"</span>);
        <span class="hljs-comment">// draw the heatmap</span>
        chart.draw();
      });
      <span class="hljs-comment">// add the data</span>
      <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getData</span>(<span class="hljs-params"></span>) </span>{
        <span class="hljs-keyword">return</span> [
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">705</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">713</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">657</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">957</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1137</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">956</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">482</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">641</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">631</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">905</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1137</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">986</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">465</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">616</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">627</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">914</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1159</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1066</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">584</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">718</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">660</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">966</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1161</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1186</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">715</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">747</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">738</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1056</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1426</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1631</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1383</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">641</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">635</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1034</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1400</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1593</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1486</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">695</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">564</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">932</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1292</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1211</span>
          }
        ];
      }
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>This heatmap is both visually appealing and informative. Upon examining the chart, it becomes clear that there are certain times when the number of accidents is significantly higher. It is unsurprising to see that these peak times are during weekends and the darker hours of the day.</p>
<p>But there's a lot more we can do with our heatmap...</p>
<h1 id="heading-how-to-customize-a-js-heatmap"><strong>How to Customize a JS Heatmap</strong></h1>
<p>As we saw, having the basic chart ready was really simple and fast. But there is so much more we can do to enhance the heatmap. It's not so difficult, either. </p>
<h2 id="heading-how-to-change-the-color-palette">How to Change the Color Palette</h2>
<p>We can use a diverging colour palette to make our JavaScript heatmap more effective in highlighting the data. This type of color scheme helps to emphasize the difference between high and low values, with less being good and more being alarming. </p>
<p>We can define four colors and value ranges using an ordinal color scale and then set the chart colors to use that color scale. This way, we can create a heatmap that quickly draws the viewer's attention to the most significant data points.</p>
<p>Here's the code to do that:</p>
<pre><code><span class="hljs-keyword">let</span> colorScale = anychart.scales.ordinalColor();
colorScale.ranges([
  { <span class="hljs-attr">less</span>: <span class="hljs-number">500</span>, <span class="hljs-attr">color</span>: <span class="hljs-string">"#B0D8A4"</span> },
  { <span class="hljs-attr">from</span>: <span class="hljs-number">500</span>, <span class="hljs-attr">to</span>: <span class="hljs-number">900</span>, <span class="hljs-attr">color</span>: <span class="hljs-string">"#FEE191"</span> },
  { <span class="hljs-attr">from</span>: <span class="hljs-number">900</span>, <span class="hljs-attr">to</span>: <span class="hljs-number">1300</span>, <span class="hljs-attr">color</span>: <span class="hljs-string">"#FD8060"</span> },
  { <span class="hljs-attr">greater</span>: <span class="hljs-number">1300</span>, <span class="hljs-attr">color</span>: <span class="hljs-string">"#CC333F"</span> }
]);
chart.colorScale(colorScale);
</code></pre><p>And here's the result:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/05/heatmapchart-002.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-how-to-modify-the-hover-styling">How to Modify the Hover Styling</h2>
<p>When we change the color palette of our heatmap, we also need to modify the hover colors to match the base colors. This is simple to achieve with the <code>color.darken</code> function. </p>
<p>We can set the chart settings and hover chart settings to ensure that the hover colors match the base colors. This allows us to create a visually consistent and easy-to-read heatmap, making it more effective in communicating the underlying data.</p>
<pre><code>chart
  .hovered()
  .fill(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> anychart.color.darken(<span class="hljs-built_in">this</span>.sourceColor, <span class="hljs-number">0.25</span>);
  });
</code></pre><p><img src="https://www.freecodecamp.org/news/content/images/2023/05/heatmapchart-003.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-how-to-change-the-labels">How to Change the Labels</h2>
<p>By default, the labels on our heatmap show the actual numbers. But we can customize the labels to provide greater flexibility and make the chart easier to read. </p>
<p>We can enable HTML for the labels to allow for greater formatting options. Then, we can configure the labels to display as 'low' to 'extreme' based on the value of the tile. We can also make the 'high' and 'extreme' values appear in bold to make them stand out.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// enable html for the labels</span>
chart.labels().useHtml(<span class="hljs-literal">true</span>);

<span class="hljs-comment">// configure the labels</span>
chart.labels().format(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">var</span> heat = <span class="hljs-built_in">this</span>.heat;
  <span class="hljs-keyword">if</span> (heat &lt; <span class="hljs-number">500</span>) <span class="hljs-keyword">return</span> <span class="hljs-string">"Low"</span>;
  <span class="hljs-keyword">if</span> (heat &lt; <span class="hljs-number">1000</span>) <span class="hljs-keyword">return</span> <span class="hljs-string">"Medium"</span>;
  <span class="hljs-keyword">if</span> (heat &lt; <span class="hljs-number">1500</span>) <span class="hljs-keyword">return</span> <span class="hljs-string">"&lt;span style='font-weight:bold'&gt;High&lt;/span&gt;"</span>;
  <span class="hljs-keyword">if</span> (heat &gt;= <span class="hljs-number">1500</span>) <span class="hljs-keyword">return</span> <span class="hljs-string">"&lt;span style='font-weight:bold'&gt;Extreme&lt;/span&gt;"</span>;
});
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/05/heatmapchart-004.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>In the final version, I decided to ultimately remove the labels since the colors are quite indicative of the values.</p>
<h2 id="heading-how-to-format-the-title-and-tooltip">How to Format the Title and Tooltip</h2>
<p>Now it's time to make our JS heatmap visualization even more exciting with some formatting tweaks. </p>
<p>First, we'll enable HTML for the tooltip, so we can customize it with some eye-catching formatting. We'll display the number of accidents in the heading and the day as well as the timing in the body of the tooltip. This will add more context and help the user to better understand the data.</p>
<pre><code class="lang-javascript">chart.tooltip().title().useHtml(<span class="hljs-literal">true</span>);
chart
  .tooltip()
  .useHtml(<span class="hljs-literal">true</span>)
  .titleFormat(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-string">"Accidents - "</span> + <span class="hljs-built_in">this</span>.heat;
  })
  .format(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> (
      <span class="hljs-string">'&lt;span style="color: #CECECE"&gt;Day: &lt;/span&gt;'</span> +
      <span class="hljs-built_in">this</span>.x +
      <span class="hljs-string">"&lt;br/&gt;"</span> +
      <span class="hljs-string">'&lt;span style="color: #CECECE"&gt;Time: &lt;/span&gt;'</span> +
      <span class="hljs-built_in">this</span>.y
    );
  });
</code></pre>
<p>Let’s also add a bit of padding under the main title to make it more spaced out and visually appealing:</p>
<pre><code class="lang-javascript">chart
  .title()
  .enabled(<span class="hljs-literal">true</span>)
  .text(<span class="hljs-string">"Fatal Car Crashes in U.S. in 2021 by Time of Day and Day of Week"</span>)
  .padding([<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">20</span>, <span class="hljs-number">0</span>]);
</code></pre>
<p>Here's what those modifcations look like:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/05/heatmapchart-005.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-how-to-modify-the-axes">How to Modify the Axes</h2>
<p>For better readability, we can add padding between the axes labels and the chart tiles and remove the axes lines since the tiles form a boundary by themselves.</p>
<pre><code class="lang-javascript">chart.xAxis().stroke(<span class="hljs-literal">null</span>);
chart.yAxis().stroke(<span class="hljs-literal">null</span>);
chart.yAxis().labels().padding([<span class="hljs-number">0</span>, <span class="hljs-number">10</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]);
chart.xAxis().labels().padding([<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">10</span>, <span class="hljs-number">0</span>]);
</code></pre>
<p>And there you have it! With just a few aesthetic changes, we've transformed a simple heatmap into a stunning visualization that really drives home a powerful message. You can check it out below with the full source code, and you can take a closer look at the interactive version of the heatmap and play with the code live <a target="_blank" href="https://playground.anychart.com/UDF2ym4E">here</a>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/05/heatmapchart-006-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Heatmap in JavaScript<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
    <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.0/js/anychart-core.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
    <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.0/js/anychart-heatmap.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span> 
    <span class="hljs-tag">&lt;<span class="hljs-name">style</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text/css"</span>&gt;</span><span class="css">      
      <span class="hljs-selector-tag">html</span>, <span class="hljs-selector-tag">body</span>, <span class="hljs-selector-id">#container</span> { 
        <span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>; <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>; <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>; 
      } 
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>  
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"container"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
      anychart.onDocumentReady(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
        <span class="hljs-comment">// create a heatmap</span>
        <span class="hljs-keyword">var</span> chart = anychart.heatMap(getData());
        <span class="hljs-comment">// set a custom color scale</span>
        <span class="hljs-keyword">var</span> colorScale = anychart.scales.ordinalColor();
        colorScale.ranges([
          { <span class="hljs-attr">less</span>: <span class="hljs-number">500</span>, <span class="hljs-attr">color</span>: <span class="hljs-string">"#B0D8A4"</span> },
          { <span class="hljs-attr">from</span>: <span class="hljs-number">500</span>, <span class="hljs-attr">to</span>: <span class="hljs-number">900</span>, <span class="hljs-attr">color</span>: <span class="hljs-string">"#FEE191"</span> },
          { <span class="hljs-attr">from</span>: <span class="hljs-number">900</span>, <span class="hljs-attr">to</span>: <span class="hljs-number">1300</span>, <span class="hljs-attr">color</span>: <span class="hljs-string">"#FD8060"</span> },
          { <span class="hljs-attr">greater</span>: <span class="hljs-number">1300</span>, <span class="hljs-attr">color</span>: <span class="hljs-string">"#CC333F"</span> }
        ]);
        chart.colorScale(colorScale);
        <span class="hljs-comment">// style the coloring in the hovered state</span>
        chart
          .hovered()
          .fill(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
            <span class="hljs-keyword">return</span> anychart.color.darken(<span class="hljs-built_in">this</span>.sourceColor, <span class="hljs-number">0.25</span>);
          });
        <span class="hljs-comment">// hide the labels</span>
        chart.labels(<span class="hljs-literal">false</span>);
        <span class="hljs-comment">// customize the axes</span>
        chart.xAxis().stroke(<span class="hljs-literal">null</span>);
        chart.yAxis().stroke(<span class="hljs-literal">null</span>);
        chart.yAxis().labels().padding([<span class="hljs-number">0</span>, <span class="hljs-number">10</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]);
        chart.xAxis().labels().padding([<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">10</span>, <span class="hljs-number">0</span>]);
        <span class="hljs-comment">// set the tooltip</span>
        chart.tooltip().title().useHtml(<span class="hljs-literal">true</span>);
        chart
          .tooltip()
          .useHtml(<span class="hljs-literal">true</span>)
          .titleFormat(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
            <span class="hljs-keyword">return</span> <span class="hljs-string">"Accidents - "</span> + <span class="hljs-built_in">this</span>.heat;
          })
          .format(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
            <span class="hljs-keyword">return</span> (
              <span class="hljs-string">'&lt;span style="color: #CECECE"&gt;Day: &lt;/span&gt;'</span> +
              <span class="hljs-built_in">this</span>.x +
              <span class="hljs-string">"&lt;br/&gt;"</span> +
              <span class="hljs-string">'&lt;span style="color: #CECECE"&gt;Time: &lt;/span&gt;'</span> +
              <span class="hljs-built_in">this</span>.y
            );
          });
        <span class="hljs-comment">// name the heatmap</span>
        chart
          .title()
          .enabled(<span class="hljs-literal">true</span>)
          .text(<span class="hljs-string">"Fatal Car Crashes in U.S. in 2021 by Time of Day and Day of Week"</span>)
          .padding([<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">20</span>, <span class="hljs-number">0</span>]);
        <span class="hljs-comment">// set the container for the heatmap</span>
        chart.container(<span class="hljs-string">"container"</span>);
        <span class="hljs-comment">// draw the heatmap</span>
        chart.draw();
      });
      <span class="hljs-comment">// add the data</span>
      <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getData</span>(<span class="hljs-params"></span>) </span>{
        <span class="hljs-keyword">return</span> [
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">705</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">713</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">657</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">957</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1137</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Monday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">956</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">482</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">641</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">631</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">905</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1137</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Tuesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">986</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">465</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">616</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">627</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">914</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1159</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Wednesday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1066</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">584</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">718</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">660</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">966</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1161</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Thursday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1186</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">715</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">747</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">738</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1056</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1426</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Friday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1631</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1383</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">641</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">635</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1034</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1400</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Saturday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1593</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Midnight–3:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1486</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">695</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 a.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">564</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"Noon–3:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">932</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"4:00–7:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1292</span>
          },
          {
            <span class="hljs-attr">x</span>: <span class="hljs-string">"Sunday"</span>,
            <span class="hljs-attr">y</span>: <span class="hljs-string">"8:00–11:59 p.m."</span>,
            <span class="hljs-attr">heat</span>: <span class="hljs-number">1211</span>
          }
        ];
      }
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<h1 id="heading-conclusion">Conclusion</h1>
<p>In conclusion, data visualization is an incredibly powerful tool that can help us uncover important insights from our data. And with JavaScript, creating beautiful and impactful charts, such as a heatmap, can be a breeze. </p>
<p>So don't be afraid to experiment with different chart types, styles, and libraries to create your own hard-hitting visualizations. And above all, remember to stay safe out there on the roads!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Anyone Can Map! Inspiration and an introduction to the world of mapping ]]>
                </title>
                <description>
                    <![CDATA[ Chef Gusteau was a visionary who created food experiences for the world to enjoy. How can we take his lessons and apply them to the world of mapping? Taking inspiration from a culinary great If you’ve seen the Pixar movie Ratatouille, you should know... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/anyone-can-map-inspiration-and-an-introduction-to-the-world-of-mapping/</link>
                <guid isPermaLink="false">66b8e31e47c23b7ae1ad0bd3</guid>
                
                    <category>
                        <![CDATA[ Data Science ]]>
                    </category>
                
                    <category>
                        <![CDATA[ google maps ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Heat map ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Inspiration ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ leaflet ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Mapping ]]>
                    </category>
                
                    <category>
                        <![CDATA[ maps ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ react-leaflet ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Colby Fayock ]]>
                </dc:creator>
                <pubDate>Thu, 05 Mar 2020 14:51:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/03/anyone-can-map.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Chef Gusteau was a visionary who created food experiences for the world to enjoy. How can we take his lessons and apply them to the world of mapping?</p>
<h2 id="heading-taking-inspiration-from-a-culinary-great">Taking inspiration from a culinary great</h2>
<p>If you’ve seen the <a target="_blank" href="https://www.pixar.com/">Pixar</a> movie <a target="_blank" href="https://movies.disney.com/ratatouille">Ratatouille</a>, you should know who <a target="_blank" href="https://ratatouille.fandom.com/wiki/Auguste_Gusteau">Chef Gusteau</a> is. He helped our “little chef” <a target="_blank" href="https://pixar.fandom.com/wiki/Remy">Remy</a> the rat navigate the culinary world and become the top chef of Paris.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/ratatouille-remy-chef-gusteau-paris.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Remy from Ratatouille overlooking Gusteau's in Paris</em></p>
<p>Throughout the movie, we get a lot of great quotes on their journey. But the one we're interested in here is Gusteau’s motto, and the title of his book, “Anyone can cook!” So how can we apply this and the lessons to our own mapping journey?</p>
<p>I’ll admit, part of the fun here was translating some of the lessons learned from one of my favorite movies, but there’s a lot to take in here. I'm going to walk through some examples and types of maps that should get you motivated to get started with your own mapping application. So let’s dive in!</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/pQ_5PGv0YTA" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-get-inspired-by-learning-about-maps-and-the-impact-they-have-on-the-world">Get inspired by learning about maps and the impact they have on the world</h2>
<blockquote>
<p>Food always comes to those who love to cook. - Chef Gusteau</p>
</blockquote>
<p><a target="_blank" href="https://www.youtube.com/watch?v=a-1rcaQ-aSk&amp;list=PLeGxIOPLk9EKBu_B0WpBLYkkHQIGki2EZ&amp;index=3">Through my work</a>, I’ve found it easy to fall in love with working on maps. Every day, scientists use maps to visualize data that can assist them in making more effective decisions. This directly translates to benefitting people all around the world and saving lives.</p>
<p>With this inspiration, you'll be taken on a journey to learn more about the different types of maps in this world and how they’re being used. You even might stumble upon some interesting data that explores your own neighborhood!</p>
<h3 id="heading-active-fires-around-the-world">Active fires around the world</h3>
<p>Take for instance <a target="_blank" href="https://firms.modaps.eosdis.nasa.gov/map/">NASA’s FIRMS service</a>, which provides a realtime look at active fire data around the world.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/nasa-firms-active-fires-world.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Active fires around the world via <a target="_blank" href="https://earthdata.nasa.gov/earth-observation-data/near-real-time/firms">NASA FIRMS</a></em></p>
<p>Fires are a real-world example of disasters that we can learn from. This tool is used to help manage resources for stopping and preventing those fires by allowing scientists and those that are curious to analyze burn areas and model the data itself.</p>
<h3 id="heading-global-cases-of-covid-19">Global cases of COVID-19</h3>
<p>And something very current, cases of <a target="_blank" href="https://www.who.int/health-topics/coronavirus">COVID-19 (Coronavrius)</a> around the world by  <a target="_blank" href="https://systems.jhu.edu/">Johns Hopkins Center for Systems Science and Engineering</a>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/john-hopkins-coronavirus-map.jpg" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://www.arcgis.com/apps/opsdashboard/index.html#/bda7594740fd40299423467b48e9ecf6">Global cases of Coronavirus (COVID-19) from John Hopkins CSSE</a></em></p>
<p>This map tracks the spread of the virus in real time, allowing scientists to model it's coverage and produce study results to share with the global community.</p>
<p>Mapping tools like this provide an effective means of giving as much information as possible in a way that’s easy to understand to the people who can make a difference with the information.</p>
<h3 id="heading-increased-life-expectancy">Increased life expectancy</h3>
<p>On a more positive note, we can get a detailed look over time of <a target="_blank" href="https://ourworldindata.org/life-expectancy">how life expectancy is improving around the world</a>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/life-expectancy-map.jpg" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://ourworldindata.org/life-expectancy">Life expectancy in 2019 from Our World in Data</a></em></p>
<p>While it’s increased more in some areas than others, the global improvements are clear, and we get to see this rise in some countries from hundreds of years ago!</p>
<h2 id="heading-explore-the-beauty-of-maps-and-applying-data-to-them">Explore the beauty of maps and applying data to them</h2>
<blockquote>
<p>How can I describe it? Good food is like music you can taste, color you can smell. There is excellence all around you. You need only to be aware to stop and savor it. - Chef Gusteau</p>
</blockquote>
<p>There’s also a creative side and beauty to great maps. Thick datasets applied to a map (or any medium) can often become literal works of art.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/pentagram-the-room-of-change.jpg" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://www.pentagram.com/work/the-room-of-change?rel=discipline&amp;rel-id=16">The Room of Change from Pentagram</a></em></p>
<p>Whether showcased in an exhibit or <a target="_blank" href="https://www.etsy.com/search?q=map">one of the many options to purchase on Etsy</a>, presenting meaningful data in a beautiful way can be impactful not just from an informational perspective, but also a cultural one.</p>
<h3 id="heading-sometimes-the-interactions-can-be-fun">Sometimes the interactions can be fun</h3>
<p>Maps can also provide some interactivity that makes them fun to explore while you learn more about the dataset, like this globe that maps out global commodities from DailyFX.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/dailyfx-global-commodities.jpg" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://www.dailyfx.com/research/global-commodities/globe">Global Commodities interactive map from DailyFX</a></em></p>
<p>Though the data can frequently be thick and boring on its own, that doesn’t mean we can't find more interesting ways to present the data to interact with.</p>
<h3 id="heading-and-sometimes-maps-can-provide-a-listening-experience">And sometimes maps can provide a listening experience</h3>
<p>This map from at <a target="_blank" href="http://radiooooo.com/">radiooooo.com</a> allows you to travel around the world and through time.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/radiooooo-music-radio-map.jpg" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="http://radiooooo.com/">Music Radio from radiooooo.com</a></em></p>
<p>Their use of a map makes it easy to identify the part of the world the person wants to explore.</p>
<h3 id="heading-stop-and-appreciate-the-maps-around-you">Stop and appreciate the maps around you</h3>
<p>Whether you notice it or not when you’re browsing the web every day, you most likely run into visualizations of datasets that create powerful ways to present that data in a way that’s more easily understood.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/reddit-truck-driver-map-dataisbeautiful.jpg" alt="Image" width="600" height="400" loading="lazy">
_<a target="_blank" href="https://www.reddit.com/r/dataisbeautiful/comments/csl706/i_recorded_my_travels_as_a_professional_truck/">u/dancingchopstix's recordings of their truck driving travels</a>_</p>
<p>Luckily, we don’t have to work hard to find this inspiration, as we can visit aggregations of beautiful maps and general datasets like that of <a target="_blank" href="https://www.reddit.com/r/dataisbeautiful/">/r/dataisbeautiful</a>.</p>
<h2 id="heading-experiment-be-creative-explore-other-ways-to-visualize-data">Experiment, be creative, explore other ways to visualize data</h2>
<blockquote>
<p>You must be imaginative, strong-hearted. You must try things that may not work, and you must not let anyone define your limits because of where you come from. Your only limit is your soul. - Chef Gusteau</p>
</blockquote>
<p>Maps come in all shapes and sizes. While shaded geographic areas typically work well with election results, it might not work as well for showcasing your summer road trip.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/50-state-project-road-strip.jpg" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://www.the50statesproject.com/">50 State Project road trip map</a></em></p>
<h3 id="heading-exploring-common-map-types">Exploring common map types</h3>
<p>You’ve probably experienced more map types than you realize. Given it’s a powerful way to present data, maps are used frequently across the web.</p>
<p>A <a target="_blank" href="https://en.wikipedia.org/wiki/Choropleth_map"><strong>choropleth map</strong></a> is commonly seen for election results and regional datasets where a particular geographic location represents a point of reference.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/cnn-democratic-primary-2020.jpg" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://www.cnn.com/election/2020/primaries-and-caucuses">CNN Map of Democratic primary after Super Tuesday</a></em></p>
<p><strong><a target="_blank" href="https://en.wikipedia.org/wiki/Heat_map">Heat maps</a></strong> on the other hand allow you to reflect on the intensity of a data point over a given area. This is powerful when you want to represent both the area covered of a dataset but also range the data represents at the same time, such as population density.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/arcgis-population-heatmap-2015.jpg" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://www.arcgis.com/home/webmap/viewer.html?useExisting=1&amp;layers=90978c3a3a664c20b8da8fc21de6071b">ArcGIS GPW 2015 Population Density heat map from</a></em></p>
<h3 id="heading-learn-from-others-but-dont-be-afraid-to-create-a-new-path">Learn from others, but don’t be afraid to create a new path</h3>
<p>Explore and play around with different techniques to visualize data on a map. There’s frequently not one way to do it, meaning you can be creative and experiment with different ways of presenting your map.</p>
<p>But that also means you don’t need to be stuck working within the constraints of the common map types. Use the tools available or create new ones and break new ground. The most important thing is presenting the data in a way that will provide the most impact to those consuming it.</p>
<h2 id="heading-dont-give-up-learn-from-your-experiences">Don’t give up, learn from your experiences</h2>
<blockquote>
<p>What I say is true — anyone can cook... but only the fearless can be great. - Chef Gusteau</p>
</blockquote>
<p>While there may not always be a right way, there <a target="_blank" href="https://twitter.com/TerribleMaps">sometimes are wrong ways</a>.  But don’t let failure stop you!</p>
<div class="embed-wrapper">
        <blockquote class="twitter-tweet">
          <a href="https://twitter.com/TerribleMaps/status/1119336763762331649"></a>
        </blockquote>
        <script defer="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></div>
<p>Take these failures as a learning experience in your journey of creating interesting and effective maps. By being bold with your experimentation, you’ll find yourself discovering techniques or creating new ways that can ultimately help people better understand map data.</p>
<h2 id="heading-you-dont-have-to-be-a-cartographer-to-build-great-maps">You don’t have to be a cartographer to build great maps</h2>
<blockquote>
<p>Not everyone can become a great artist; but a great artist can come from anywhere. - Anton Ego</p>
</blockquote>
<p>Towards the end of Remy’s journey, the food critic Anton Ego who was once critical of Gusteau's claim that “anyone can cook” came to a realization of what our chef truly meant.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/anton-ego-realization.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Ratatouille critic Anton Ego's revelation</em></p>
<p>While it’s not reasonable to assume that every single one of us will be a great mapper, everyone has the opportunity to try and explore the medium.</p>
<p>And it certainly helps that we have plenty of tooling to help us get there. Whether building your own with <a target="_blank" href="https://leafletjs.com/">Leaflet</a> or <a target="_blank" href="https://www.google.com/maps/about/mymaps/">identifying a few locations on a Google Map</a>, the resources and community around mapping are endless.</p>
<h2 id="heading-jump-in-with-some-resources-to-get-started">Jump in with some resources to get started</h2>
<p>For the developers out there who are inspired to get started, here are a few resources to start off with mapping:</p>
<ul>
<li><a target="_blank" href="https://www.freecodecamp.org/news/easily-spin-up-a-mapping-app-in-react-with-leaflet/">How to build a mapping app in React the easy way with Leaflet</a></li>
<li><a target="_blank" href="https://www.freecodecamp.org/news/visualizing-air-pollution-folium-maps/">How to Visualize Air Pollution using Folium Maps - An In Depth Tutorial</a></li>
<li><a target="_blank" href="https://www.freecodecamp.org/news/how-to-integrate-maps-in-react-native-using-react-native-maps-5745490fe055/">How to integrate maps in React Native using react-native-maps</a></li>
<li><a target="_blank" href="https://www.colbyfayock.com/2020/03/how-to-create-a-coronavirus-covid-19-dashboard-map-app-with-gatsby-and-leaflet">How to create a Coronavirus (COVID-19) Dashboard &amp; Map App in React with Gatsby and Leaflet</a></li>
<li><a target="_blank" href="https://www.colbyfayock.com/2020/04/how-to-set-up-a-custom-mapbox-basemap-style-with-react-leaflet-and-leaflet-gatsby-starter/">How to set up a custom Mapbox basemap style with React Leaflet and Leaflet Gatsby Starter</a></li>
<li><a target="_blank" href="https://www.colbyfayock.com/2019/12/create-your-own-santa-tracker-with-gatsby-and-react-leaflet/">How to Create your own Santa Tracker with Gatsby and React Leaflet</a></li>
<li><a target="_blank" href="https://www.youtube.com/watch?v=a-1rcaQ-aSk&amp;list=PLeGxIOPLk9EKBu_B0WpBLYkkHQIGki2EZ&amp;index=3">Building Maps with Impact on React and the JAMstack</a> (Video)</li>
<li><a target="_blank" href="https://github.com/colbyfayock/gatsby-starter-leaflet">Gatsby Starter Leaflet</a></li>
<li><a target="_blank" href="https://leafletjs.com/">Leaflet</a></li>
<li><a target="_blank" href="https://openlayers.org/">OpenLayers</a></li>
<li><a target="_blank" href="https://www.google.com/maps/about/mymaps/">My Maps by Google</a></li>
</ul>
<h2 id="heading-whats-your-favorite-map-experience-or-tool">What’s your favorite map experience or tool?</h2>
<p><a target="_blank" href="https://twitter.com/colbyfayock">Share with me on Twitter!</a></p>
<div id="colbyfayock-author-card">
  <p>
    <a href="https://twitter.com/colbyfayock">
      <img src="https://res.cloudinary.com/fay/image/upload/w_2000,h_400,c_fill,q_auto,f_auto/w_1020,c_fit,co_rgb:007079,g_north_west,x_635,y_70,l_text:Source%20Sans%20Pro_64_line_spacing_-10_bold:Colby%20Fayock/w_1020,c_fit,co_rgb:383f43,g_west,x_635,y_6,l_text:Source%20Sans%20Pro_44_line_spacing_0_normal:Follow%20me%20for%20more%20JavaScript%252c%20UX%252c%20and%20other%20interesting%20things!/w_1020,c_fit,co_rgb:007079,g_south_west,x_635,y_70,l_text:Source%20Sans%20Pro_40_line_spacing_-10_semibold:colbyfayock.com/w_300,c_fit,co_rgb:7c848a,g_north_west,x_1725,y_68,l_text:Source%20Sans%20Pro_40_line_spacing_-10_normal:colbyfayock/w_300,c_fit,co_rgb:7c848a,g_north_west,x_1725,y_145,l_text:Source%20Sans%20Pro_40_line_spacing_-10_normal:colbyfayock/w_300,c_fit,co_rgb:7c848a,g_north_west,x_1725,y_222,l_text:Source%20Sans%20Pro_40_line_spacing_-10_normal:colbyfayock/w_300,c_fit,co_rgb:7c848a,g_north_west,x_1725,y_295,l_text:Source%20Sans%20Pro_40_line_spacing_-10_normal:colbyfayock/v1/social-footer-card" alt="Follow me for more Javascript, UX, and other interesting things!" width="2000" height="400" loading="lazy">
    </a>
  </p>
  <ul>
    <li>
      <a href="https://twitter.com/colbyfayock">? Follow Me On Twitter</a>
    </li>
    <li>
      <a href="https://youtube.com/colbyfayock">?️ Subscribe To My Youtube</a>
    </li>
    <li>
      <a href="https://www.colbyfayock.com/newsletter/">✉️ Sign Up For My Newsletter</a>
    </li>
  </ul>
</div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to construct a heat map in React ]]>
                </title>
                <description>
                    <![CDATA[ By Jeff M Lowery Heat maps are a great way of visualizing correlations among two data sets.  With colors and gradients, it is possible to see patterns in the data almost instantly. I went searching for a heat map implementation in npm, but was unable... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/a-heat-map-implementation-in-typescript/</link>
                <guid isPermaLink="false">66d45f6333b83c4378a517e0</guid>
                
                    <category>
                        <![CDATA[ data analysis ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Heat map ]]>
                    </category>
                
                    <category>
                        <![CDATA[ TypeScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 24 Aug 2019 16:06:58 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9ca0ad740569d1a4ca4a1a.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Jeff M Lowery</p>
<p>Heat maps are a great way of visualizing correlations among two data sets.  With colors and gradients, it is possible to see patterns in the data almost instantly.</p>
<p>I went searching for a heat map implementation in npm, but was unable to find one that I liked, so <a target="_blank" href="https://github.com/JeffML/jsheatmap">I wrote my own</a>. It is still a work in progress, but does provide basic functionality.</p>
<p>There are actually two parts to the implementation: <a target="_blank" href="https://github.com/JeffML/jsheatmap">jsheatmap</a> takes headings and row data to produce a JSON object where the raw input is scaled from 0.0 to 1.0 and then RGB colors are mapped to those scaled values.  I will confess that most of this was already worked out by Andrew Noske, who provided a <a target="_blank" href="http://www.andrewnoske.com/wiki/Code_-_heatmaps_and_color_gradients">partial C++ implementation</a> in his blog.  Transliterating C++ to TypeScript was relatively easy.</p>
<p>The second part is an HTML presentation of the JSON data returned by jsheatmap. This would typically be the responsibility of the user of jsheatmap module, but I did build a <a target="_blank" href="https://github.com/JeffML/sternomap">general-purpose React application</a> that demonstrates how HTML table cells can be used as a heat map representation.</p>
<h2 id="heading-the-basics">The basics</h2>
<p>First, install jsheatmap:</p>
<p><code>npm i -S jsheatmap</code></p>
<p>As mentioned, jsheatmap was written in TypeScript, but npm will install the generated JavaScript version of the TypeScript program, which is what your application will use.</p>
<p>Next, import the jsheatmap components.  </p>
<p><code>import HeatMap, { Style } from "jsheatmap"</code></p>
<p>The <code>Style</code> component is not strictly required.  As of this writing, there are only two Styles: SIMPLE and FANCY.  FANCY  is the default, which uses a 5-color gradient for the heat map RGB data.  SIMPLE uses a three-color gradient, which you might prefer for smaller data sets. The style is passed to the <code>getData()</code> method, as will be shown later.</p>
<p>Instantiate a HeatMap with headings (column names) and row data:<br><code>const heatMap = new HeatMap(headings, rows)</code></p>
<p>where headings is an array of strings (column headings) and rows is an array of labels and cell data.  For example:</p>
<pre><code class="lang-js"><span class="hljs-comment">// Days of rain in summer summer months, by year</span>
<span class="hljs-keyword">const</span> headings = [<span class="hljs-string">"June"</span>, <span class="hljs-string">"July"</span>, <span class="hljs-string">"August"</span>, <span class="hljs-string">"September"</span>]  <span class="hljs-comment">// the months</span>
<span class="hljs-keyword">const</span> rows = [[<span class="hljs-string">"2015"</span>, [<span class="hljs-number">9</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">8</span>]],   <span class="hljs-comment">// the years and rainy days by month</span>
   [<span class="hljs-string">"2016"</span>, [<span class="hljs-number">7</span>, <span class="hljs-number">5</span>, <span class="hljs-number">10</span>, <span class="hljs-number">7</span>]],
   [<span class="hljs-string">"2017"</span>, [<span class="hljs-number">7</span>, <span class="hljs-number">4</span>, <span class="hljs-number">3</span>, <span class="hljs-number">9</span>]],
   [<span class="hljs-string">"2018"</span>, [<span class="hljs-number">10</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">8</span>]],
   [<span class="hljs-string">"2019"</span>, [<span class="hljs-number">8</span>, <span class="hljs-number">9</span>, <span class="hljs-number">3</span>, <span class="hljs-number">1</span>]],]
</code></pre>
<h2 id="heading-converting-to-rgb">Converting to RGB</h2>
<p>Now is time to get the heat map data:</p>
<pre><code class="lang-js"><span class="hljs-comment">// const data = heatMap.getData({ style: Style.SIMPLE });</span>
<span class="hljs-keyword">const</span> data = heatMap.getData();
</code></pre>
<p>The default style is FANCY (five color gradient) whereas SIMPLE would use a three-color gradient for the RGB mapping.</p>
<p>Cell values are then scaled, relative to each other, with scale values determined by the high and low values of the input. Once all the inputs have been scaled from 0.0 to 1.0, they can be mapped to RGB color values. All of this data is returned by getData():</p>
<pre><code class="lang-json">{
  <span class="hljs-attr">"headings"</span>: [
    <span class="hljs-string">"Jun"</span>,
    <span class="hljs-string">"Jul"</span>,
    <span class="hljs-string">"Aug"</span>,
    <span class="hljs-string">"Sep"</span>
  ],
  <span class="hljs-attr">"high"</span>: <span class="hljs-number">9</span>,
  <span class="hljs-attr">"low"</span>: <span class="hljs-number">4</span>,
  <span class="hljs-attr">"rows"</span>: [
    {
      <span class="hljs-attr">"label"</span>: <span class="hljs-string">"2015"</span>,
      <span class="hljs-attr">"cells"</span>: {
        <span class="hljs-attr">"values"</span>: [
          <span class="hljs-number">7</span>,
          <span class="hljs-number">5</span>,
          <span class="hljs-number">6</span>,
          <span class="hljs-number">8</span>
        ],
        <span class="hljs-attr">"colors"</span>: [
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0.6249999999999998</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">0.588235294117647</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">1</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0.625</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">0.588235294117647</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0</span>
          }
        ],
        <span class="hljs-attr">"scales"</span>: [
          <span class="hljs-number">0.6</span>,
          <span class="hljs-number">0.2</span>,
          <span class="hljs-number">0.4</span>,
          <span class="hljs-number">0.8</span>
        ]
      }
    },
    {
      <span class="hljs-attr">"label"</span>: <span class="hljs-string">"2016"</span>,
      <span class="hljs-attr">"cells"</span>: {
        <span class="hljs-attr">"values"</span>: [
          <span class="hljs-number">7</span>,
          <span class="hljs-number">5</span>,
          <span class="hljs-number">5</span>,
          <span class="hljs-number">7</span>
        ],
        <span class="hljs-attr">"colors"</span>: [
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0.6249999999999998</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">0.588235294117647</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">1</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">0.588235294117647</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">1</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0.6249999999999998</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0</span>
          }
        ],
        <span class="hljs-attr">"scales"</span>: [
          <span class="hljs-number">0.6</span>,
          <span class="hljs-number">0.2</span>,
          <span class="hljs-number">0.2</span>,
          <span class="hljs-number">0.6</span>
        ]
      }
    },
    {
      <span class="hljs-attr">"label"</span>: <span class="hljs-string">"2017"</span>,
      <span class="hljs-attr">"cells"</span>: {
        <span class="hljs-attr">"values"</span>: [
          <span class="hljs-number">7</span>,
          <span class="hljs-number">4</span>,
          <span class="hljs-number">5</span>,
          <span class="hljs-number">9</span>
        ],
        <span class="hljs-attr">"colors"</span>: [
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0.6249999999999998</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">0</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">1</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">0.588235294117647</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">1</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">0</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0</span>
          }
        ],
        <span class="hljs-attr">"scales"</span>: [
          <span class="hljs-number">0.6</span>,
          <span class="hljs-number">0</span>,
          <span class="hljs-number">0.2</span>,
          <span class="hljs-number">1</span>
        ]
      }
    },
    {
      <span class="hljs-attr">"label"</span>: <span class="hljs-string">"2018"</span>,
      <span class="hljs-attr">"cells"</span>: {
        <span class="hljs-attr">"values"</span>: [
          <span class="hljs-number">6</span>,
          <span class="hljs-number">5</span>,
          <span class="hljs-number">7</span>,
          <span class="hljs-number">8</span>
        ],
        <span class="hljs-attr">"colors"</span>: [
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0.625</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">0.588235294117647</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">1</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0.6249999999999998</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">0.588235294117647</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0</span>
          }
        ],
        <span class="hljs-attr">"scales"</span>: [
          <span class="hljs-number">0.4</span>,
          <span class="hljs-number">0.2</span>,
          <span class="hljs-number">0.6</span>,
          <span class="hljs-number">0.8</span>
        ]
      }
    },
    {
      <span class="hljs-attr">"label"</span>: <span class="hljs-string">"2019"</span>,
      <span class="hljs-attr">"cells"</span>: {
        <span class="hljs-attr">"values"</span>: [
          <span class="hljs-number">8</span>,
          <span class="hljs-number">6</span>,
          <span class="hljs-number">6</span>,
          <span class="hljs-number">8</span>
        ],
        <span class="hljs-attr">"colors"</span>: [
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">0.588235294117647</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0.625</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">0</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0.625</span>
          },
          {
            <span class="hljs-attr">"red"</span>: <span class="hljs-number">1</span>,
            <span class="hljs-attr">"green"</span>: <span class="hljs-number">0.588235294117647</span>,
            <span class="hljs-attr">"blue"</span>: <span class="hljs-number">0</span>
          }
        ],
        <span class="hljs-attr">"scales"</span>: [
          <span class="hljs-number">0.8</span>,
          <span class="hljs-number">0.4</span>,
          <span class="hljs-number">0.4</span>,
          <span class="hljs-number">0.8</span>
        ]
      }
    }
  ]
}
</code></pre>
<p><a target="_blank" href="https://github.com/JeffML/sternomap">For the demonstration application</a>, I use React to generate a table with each  element's background styled as follows:  </p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> background = <span class="hljs-function">(<span class="hljs-params">rgb</span>) =&gt;</span> {    
    <span class="hljs-keyword">return</span> <span class="hljs-string">`rgb(<span class="hljs-subst">${rgb.red * <span class="hljs-number">100</span>}</span>%, <span class="hljs-subst">${rgb.green * <span class="hljs-number">100</span>}</span>%, <span class="hljs-subst">${rgb.blue * <span class="hljs-number">100</span>}</span>%)`</span>;
}
</code></pre>
<p>Where <code>rgb()</code> is the built-in CSS function for RGB colors, and the passed-in <code>rgb</code> parameter comes from the cell colors of the row generated by <code>getData()</code>.  To run the implementation, first clone the repository:</p>
<p><code>git clone [https://github.com/JeffML/sternomap.git](https://github.com/JeffML/sternomap.git)</code></p>
<p>then go to the sternomap folder and run:</p>
<p><code>npm install</code></p>
<p>finally:</p>
<p><code>npm run start</code></p>
<p>As an aside: the application was originally generated using <a target="_blank" href="https://create-react-app.dev/docs/getting-started">Create React App</a>, and the <a target="_blank" href="https://github.com/JeffML/sternomap">README.md</a> file explains all that in detail.  </p>
<h2 id="heading-the-output">The output</h2>
<p>Once the script has finished, it will load a page in your browser (I use Chrome). Here's a snapshot:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/08/rainy.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>This shows rainy days per month  in each cell, by year. From this you can see that the driest months are July and August, with the wettest being September. The number inside each cell is the scaled value of the raw input (rainy days), so the least rainy days were in July of 2017, and the most in September of that year.</p>
<h3 id="heading-a-rainbow-of-colors">A rainbow of colors</h3>
<p>I can generate a data set where the value of each cell is the sum of it's x + y coordinates.  For row labels, I use the npm module <a target="_blank" href="https://www.npmjs.com/package/casual">casual</a> to create them.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/08/bigdatamap.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-the-wrap-up">The wrap up</h2>
<p>I have some plans to use this heat map implementation in other projects, which I am sure will require changes to the API, but the basics should remain the same.  If you decide to try this and find it useful, let me know.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
