0

I made timedate heatmap. I notice that it doesn't display first 4 lines in my data.

Here is example of data:

data = 
[ {attr1: 1568714400000, attr2: "reg-del", value: 1}
{attr1: 1568714400000, attr2: "reg-expired", value: 10}
{attr1: 1568714400000, attr2: "reg-new", value: 3}]

Here is part of my code, selectAll('rect').data(data) returns empty always for 4. Any idea why?

 Selection {_groups: Array(1), _parents: Array(1)}
 _groups: Array(1)
 0: (35) [empty × 4, rect, rect, rect, rect, rect, rect, rect, rect, rect, 
 rect, rect, rect, rect, rect, rect, rect, rect, rect, rect, rect, rect, 
 rect, rect, rect, rect, rect, rect, rect, rect, rect, rect]
 length: 1


   var rect = svg.selectAll('rect')
            .data(data)
            .enter().append('g').append('rect')
            .attr('class', 'cell')
            .attr('width',  (d,i) => data[i+1] ? xScale(data[i+1].attr1) -  
             xScale(d.attr1): 10)
            .attr('height', itemHeight)
            .attr('y', function(d) { return yScale(d.attr2); })
            .attr('x', function(d) { 
                 if (xScale(d.attr1) -cellSize/2 < 0) {
                    return -1000;
                }
                return xScale(d.attr1) -cellSize/2;
                })
13Akaren
  • 225
  • 3
  • 16
  • Hard to tell without seeing the rest of your code, but if I had to guess I'd say it's related to / a duplicate of [*"Why are the first two text labels of my bar chart not shown? "*](/questions/57908130). – altocumulus Sep 19 '19 at 10:34
  • Until now dataset is ok but just function itself `svg.selectAll('rect').data(data)` returns null for first four object in result. But it is not and should be null. – 13Akaren Sep 19 '19 at 10:53
  • Your comment slightly begs the question. Try setting up a [mcve] demonstrating the issue. – altocumulus Sep 19 '19 at 11:08

0 Answers0