Я сделал тепловую карту по времени.Я заметил, что он не отображает первые 4 строки в моих данных.
Вот пример данных:
data =
[ {attr1: 1568714400000, attr2: "reg-del", value: 1}
{attr1: 1568714400000, attr2: "reg-expired", value: 10}
{attr1: 1568714400000, attr2: "reg-new", value: 3}]
Вот часть моего кода, selectAll ('rect'). Data (data) всегда пусто для 4. Любая идея, почему?
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;
})