I have a plunker here - https://plnkr.co/edit/JSB4FD1yOe6Xvii6FiRn?p=preview
Its a stacked bar chart in an Angular 4 component
I'm having problems with the x domain to create the x axis
At the moment the bars are taking up the width of the whole chart.
private drawChart(data:any){
this.layersBar = this.layersBarArea.selectAll('.layer')
.data(data)
.enter()
.append('g')
.classed('layer', true)
.style('fill', (d:any,i:any)=>{
return this.colors[i]
});
this.x.domain(data.map((d:any)=>{
//return d.date;
}));
this.y.domain([0, +d3.max(this.stackedSeries, function(d:any){
return d3.max(d, (d:any)=>{
return d[1]
})
})]);
this.layersBar.selectAll('rect')
.data((d:any)=>{
return d;
})
.enter()
.append('rect')
.attr('y', (d:any)=>{
return this.y(d[1])
})
.attr('x', (d:any, i:any)=>{
return this.x.date
})
.attr('width', this.x.bandwidth())
.attr('height', (d:any, i:any)=>{
return this.y(d[0]) - this.y(d[1]);
})
}