0
이것은 d3.js를 사용하여 만든 차트입니다. 내 바가 틱 값을 중심으로 배치되기를 원합니다. 각 막대의 중간 막대 (3 개 막대)가 월 이름과 일치해야합니다. 이것을 우아하게 할 수있는 방법이 있습니까? 데이터 세트 또는 차트 기능에 대한 추가 정보가 필요한 경우 알려주십시오.d3js - 칼럼 그래프 - 데이터 포인트 정렬
일부 도움이 코드
this.container.selectAll('g.container')
.data(this.data)
.enter().append('g')
.attr('class', 'container')
.attr('transform', function(d, i){
console.log(d.dimension, this)
var x = self.margin.left + self.xScale(d.dimension.value);
var y = self.margin.top;
return 'translate('+ x + ',' + y +')'
});
this.bars = this.container.selectAll('g.container')
.selectAll('rect.bar')
.data(function(d){ return d; })
.enter()
.append('rect')
.attr('class', 'bar')
.attr('width', 3)
.attr('height', function(d){
console.log(d.y, d.key, this);
return availableHeight - self.yScale(d.y);
})
.attr('y', function(d){ return self.yScale(d.y); })
.attr('x', function(d, i){ return i * 5 });
이 차이점을 어떻게 파악합니까? 내 진드기가있는 값을 찾을 수 있다면 간단히 사용할 수 있습니다. –
두 개의 연속적인 'dimension.value'의 차이를 계산하면됩니다. 아마 이것은 JSON에있는 것입니까? –