Heat Map - can't figure out how to show cells

Stuck trying to show the cells. If someone could just please show me the basic recipe for getting any cell to show that would help kickstart things for me.

Thank you kindly!

This does not fix every thing but it gets you on the right path. I found three bugs that were causing you some trouble I made the comments on the code where it needs to be changed. Also forked it in codepen you can check it out there. Good luck. happy coding.

const SVG_CANVAS = d3.select('body')
                      .attr('width',SVG_WIDTH + MARGIN.right + MARGIN.left)
                      .attr('height',SVG_HEIGHT + MARGIN.top + MARGIN.bottom);
  let colorDomain = d3.extent(dataset.monthlyVariance, function(d){
      return d.variance;
   let colorScale = d3.scaleLinear()
  // moved up before it is called by "rectangles"
  let xScale = d3.scaleTime()
                .domain(d3.extent(dataset.monthlyVariance, function (d,i) {                       
                  return (new Date(d.year));  // change from dataset.monthlyVariance to d.year
  // moved up before it is called by "rectangles"
  let yScale = d3.scaleLinear()
  let rectangles = SVG_CANVAS.selectAll("rect")
  rectangles.attr("x", function(d){
      return xScale(d.year); // remove * 50
    .attr("y", function(d){
      return yScale(d.month); // remove * 50 
    .attr("width", 50)
    .attr("height", 50). 
    style("fill", function(d){
      return colorScale(d.variance); 

THANK YOU! I didn’t think about the ordering, for some reason I didn’t think that mattered. But that makes total sense now. You are a kind soul, sir.

1 Like