cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

              <h1>Visualize Data with a Heat Map</h1>
<p><a href="https://youtu.be/w4jAkHd7qlE" target="_blank">Video tutorial</a></p>

<div class="graph">
  <svg id="heatmap"></svg>
  <div class="tooltip"></div>

<!-- Footer-->
<div class="row text-center">
			<div class="col-xs-12">
				<div class="tableFooter">
				  <!-- for footer -->
      <div class="col-xs-6">
      <h5><a href="http://www.eleftheriabatsou.com" target="_blank">Eleftheria</a> | <a href="https://codepen.io/EleftheriaBatsou" target="_blank">Projects</a> | <a href="https://www.youtube.com/channel/UCC-WwYv3DEW7Nkm_IP6VeQQ" target="_blank"> Coding videos </a></h5>
      <!-- social media -->
      <div class="col-xs-6 text-primary">
        <a href="https://twitter.com/BatsouElef" target="_blank">
     <img class="footerSvg"src="https://image.flaticon.com/icons/svg/60/60580.svg" 
      style="text-align:center" alt="twitter"> 
         <a href="https://github.com/EleftheriaBatsou" target="_blank">
     <img class="footerSvg" src="https://image.flaticon.com/icons/svg/25/25657.svg" 
      style="text-align:center" alt="github"> 
        <a href="https://www.youtube.com/channel/UCC-WwYv3DEW7Nkm_IP6VeQQ" target="_blank">
     <img class="footerSvg" src="https://image.flaticon.com/icons/svg/25/25312.svg" 
       style="text-align:center" alt="youtube"> 
    <!-- end footer -->
<!-- end of Footer -->
              body {
 text-align: center;
h1, h3, p{

.graph {
  margin: 0 auto;
  background-color: white; 

.tooltip {
  background-color: lightsalmon;
  border: 1px solid black;
  width: 100px;
  opacity: 0;
  color: black;
  position: absolute;

 * Footer
a:link    {color:orangered;  text-decoration:none}
a:visited {color:orangered; text-decoration:none}
a:hover   {color:red; text-decoration:underline}

  margin-top: 15px;
  width: 32px;
              var height = 500, width = 1000,
    margin = {
      left: 120, right: 20, top: 20, bottom: 70
    url = "https://raw.githubusercontent.com/FreeCodeCamp/ProjectReferenceData/master/global-temperature.json",
    months = ["January","February","March","April","May","June","July","August","September","October","November","December"],
    color = ["#ef5350","#EC407A","#AB47BC","#7E57C2","#5C6BC0","#42A5F5","#26C6DA","#26A69A","#D4E157","#FFEE58","#FFA726"];

var canvas = d3.select('svg').attr({
  height: height + margin.top + margin.bottom,
  width: width + margin.left + margin.right

var group = canvas.append('g').attr({
  transform: "translate(" + margin.left + "," + margin.top + ")"

var div = d3.select('.tooltip');
var xScale = d3.time.scale().range([0,width]);
var yScale = d3.scale.ordinal().domain(months).rangeBands([0,height]);
var colorScale = d3.scale.quantize().range(color);

//call the json with the url and a function
  data = data.monthlyVariance;
  //map the data
    d.month = months[d.month-1];
    d.year = d3.time.format("%Y").parse(d.year.toString());
  //declair the function xScale
    return data.year;
  //scale the colors
    return d.variance;
  var barWidth = width / (data.length / 12)
  var barHeight = height / 12;
  //scale the axis and set orientation
  var xAxis = d3.svg.axis().scale(xScale).orient("bottom");
  var yAxis = d3.svg.axis().scale(yScale).orient("left").ticks(12);
  //add a g element that provides a reference point for adding the axes.
  //append the axis according to the size and the position that we have set up with our width, height and margin’s.
    class: "xAxis",
    transform: "translate(0," + (height) + ")"
    class: "yAxis",
    transform: "translate(0,0)",
    transform: function(data){
      return "translate(" + xScale(data.year) + "," + yScale(data.month) +  ")";
    }).append('rect').attr({ //append the rectangulars and scale them in the graph
    width: barWidth,
    height: yScale.rangeBand()
  }).style({ //scale the colors
    fill: function(data){
     return colorScale(data.variance);
    //make the tooltip to follow the mouse
      left: d3.event.pageX + "px",
      top: d3.event.pageY + "px"
    //appear/disappear the tooltip on mouse hover
    //8.66 is a standard value
    div.html("<p>Year: " + d3.time.format("%Y")(d.year) + "</p></p>Value = " + (8.66 + d.variance).toFixed(2) + "</p><p>Month: " + d.month + "</p>" );

Loading ..................