Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <nav class="navbar navbar-expand-lg navbar-light bg-light">
  <a class="navbar-brand" href="#">Marni Duffy</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav ml-auto">
      <li class="nav-item">
        <a class="nav-link" href="#">Site/Resume</a>
<div class="container text-center">
  <div class="card" >
    <div class="card-body">
      <h2 class="card-title">Monthly Global Land-Surface Temperature</h2>
      <h3 class="card-text">1753-2015</h3>
      <p>Temperatures are in Celcius and reported as anomolies relative to the Jan 1951 - Dec 1980 average.</p><p>Estimated Jan 1951-Dec 1980 absolute temperature °C 8.66 +/- 0.07.</p>
      <div id="chart"></div>
      <div id="legend"></div>

              $teal: rgba(#65CCCC, 0.2);

svg rect.bordered {
  stroke: white;
  stroke-width: 0.5px;
body, .navbar {
  background-color: $teal; 
.card {
  width: 75rem;
  height: 75rem; 
text.label {
  font-size: 9pt;
  font-family: sans-serif;
  fill: #795548;

.yLabel, .xLabel, .legend {
  font-size: 1.1em; 
.card {
  margin-top: 20px; 
              var months = ["JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"];

var years = [];
function createYears(min,max){
  for(var i=min; i<=max; i++){
  return years; 

var colors = ['#F8F87C',

function drawMap() {
  var margin = { top: 30, right: 10, bottom: 30, left: 30 },
    width = $(".card").innerWidth(),
    gridSize = Math.floor(width/60),
    height = $('.card').innerHeight(),
    legendElementWidth = gridSize*2;
  var svg = d3.select("#chart").append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom)
    .append("g") // an svg "group", similar to an html "div"
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
  var monthLabels = svg.selectAll(".month")
        .text(function(d) { return d.substr(0,3); })
        .attr("x", -5)
        .attr("y", function(d,i){ return (i *3 * gridSize) +70 ; })
        .style("text-anchor", "end")
        .attr("transform", "translate(0," + gridSize   +")")
        .attr("class", "label");

  function(error, data) {
    if(error) { console.log(error)};
    data = data.monthlyVariance;
    var varianceExtent = d3.extent(data.map(function(each) { return each.variance; }));
    var colorRange = d3.scale.quantile().domain(varianceExtent).range(colors);
    var yearsExtent = d3.extent(data.map(function(each) { return each.year; }));
    createYears(yearsExtent[0], yearsExtent[1]); 
    var yearLabels = svg.selectAll(".year")
          .text(function (d) {
            if (d % 10 == 0 && d != 2010) {
              return d;
            } else { 
              return ''; 
            }  })
          .attr("x", function(d, i) { return i/4.25 * gridSize; })
          .attr("y", 50)
          .style("text-anchor", "middle")
          .attr("transform", "translate(" + gridSize / 2  + ", -6)")
          .attr("class", "label");
    var heatMap = svg.selectAll(".grid")
        .attr("width", gridSize )
        .attr("height", height/14)
         .attr("x", function(d, i){ return (i/(width/425)) })
        .attr("y", function(d) { return (d.month *3 ) * gridSize; })
        .style("fill", function(d) { return colorRange(d.variance); });

    heatMap.append("title") // append and format title element
        .text(function(d) {
          var title = d.month + '/' + d.year +   ' Variance: ' + d.variance;
          return title;
    //label axes:   
      .attr("class", "xLabel")
      .attr("text-anchor", "end")
      .attr("x", gridSize * 30)
      .attr("y", 9)
  var legend = svg.selectAll(".legend")
    .data([0].concat(colorRange.quantiles()), function(d){ return d; });
    .attr("class", "legend");
    .attr("x", function(d,i){ return (legendElementWidth * i) + 50;})
    .attr("y", 820)
    .attr("width", legendElementWidth)
    .attr("height", gridSize/2)
    .style("fill", function(d,i) { return colors[i]});
  var widthOfChart = '35rem'; 
    .attr("class", "mono")
    .text(function(d) { return "≥ " + Math.round(d); })
    .attr("x", function(d,i){ return ((legendElementWidth + 1.75 ) * i)  +50; })
    .attr("y", 835 + gridSize);
    .attr("x", 200)
    .attr("y", 805)
    .attr("class", "legend") 


🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.