일련의 직사각형이 d3.js
을 사용하여 100 개의 개체 배열을 가져 와서 그려졌습니다. console.log(data)
에 새 데이터가 검색되는 것으로 표시 되더라도 새 데이터 요소는 모든 직사각형을 추가하지 않는 것처럼 보입니다.d3.js 차트가 새 데이터로 업데이트되지 않았습니다.
.enter().append()
이 잘못 사용 되었습니까?
function init() {
var width = 800,
height = 400,
margin = 50;
chart = d3.select('#chart')
.append('svg:svg')
.attr('width', width)
.attr('height', height);
}
function do_update() {
data = fetch_latest_top100();
console.log(data)
chart.selectAll('rect')
.data(data)
.enter()
.append('svg:rect')
.attr('x', function(d) { return x(d.x); })
.attr('y', function(d) { return y(d.y); })
.attr('height', function(d) { return d.value; })
.attr('width', function(d) { return 3 });
}
jsfiddle : 당신의 업데이트 방법 http://jsfiddle.net/BU8cA/
(http://jsfiddle.net/) 또는 plunkr http://plnkr.co/edit/?p=catalogue 이슈를 실시간으로 보는데 도움이 될 것입니다. –
복사/붙여 넣기 문제인지는 모르겠지만 y 다음에 ")"가 누락되었습니다 (dy on the y attr이고 그 오류가 – tomtomtom
일 수 있습니다. @tomtomtom 복사 붙여 넣기 문제가 발생했습니다. 오타를 수정했습니다. – Nyxynyx