I have a plunker here - https://plnkr.co/edit/7Eg34HyhXY6M3UJccAFq?p=preview
var data = [{
day: 'Mon',
apricots: 150,
blueberries: 20,
cherries: 15
}];
It's a simple stacked bar chart using the dat above
The stacked chart seem to display the data incorrectly
apricots seem to go to 150 blueberries looks like it could be 20 cherries that is the smallest at 15 is the biggest bar.
Have I done something wrong
A few minor errors, in the height section it should be:
.attr('height', (d) => {
return y(d[0]) - y(d[1]);
})
and in the y attr
.attr('y', (d) => {
return y(d[1]);
})
and the domain should be
y.domain([0, d3.max(stackedSeries, (d) => {
return d3.max(d, (d) => {
return d[1];
});
})])
Here's the edited: Plunker
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.