제가 작업하고있는 d3 차트에 다소 신비한 문제가 있습니다.d3 목록 가운데에서 열거합니까?
다음은 내가 작업중인 두 가지 데이터 기반 차트의 코드입니다.
svg.selectAll("rect")
.data(nyb.features)
.enter()
.append("rect")
.attr({
"fill": "steelblue",
"width": bar_width,
"height": function(d) { return 250 - y(d.properties.distance) - 5; },
"x": function(d, i) { return ((bar_width + 1) * i) + 55; },
"y": function(d) { return y(d.properties.distance); }
});
svg.selectAll("text")
.data(nyb.features)
.enter()
.append("text")
.attr({
"fill": "red",
"x": function(d, i) { console.log(i); return ((bar_width + 1) * i) + 55; },
"y": function(d) { return y(d.properties.distance); }
})
.text("Hello World!");
내가이 술집의 집합 그 술집에 대한 텍스트 레이블 세트를 생성 할 것으로 예상 : 두 번째 레이블을 채 웁니다 동안 첫 번째는 막대 차트에서 막대를 채 웁니다.
:
콘솔을 확인, 이것은 단지 중간에 데이터를 열거하기 시작 D3에 의한 것으로 보인다 : 어떤 이유
이 대신 내 출력왜 그럴까요?
전체 시각화 코드는 [여기]입니다 (https://github.com/ResidentMario/mysite/blob/master/templates/visualizations/longest-streets. html). 사용되는 데이터는 [여기] (https://github.com/ResidentMario/mysite/blob/master/static/post_assets/nyc-addresses/streets.geojson)입니다. –