I have a codepen here - https://codepen.io/anon/pen/yvgJKB I have a simple stacked bar chart. I want to make this into a component so I need to pass in the values to make it reusea
Solution 1:
let xAxisValue = 'date';
in line 1 to make the codepen sample working.
And then
let x = d3.scaleBand()
.domain(dataToStack.map(function(d){
letlink = d[xAxisValue];
returnlink;
//return d.date;
}))
.rangeRound([0,width])
.padding(0.05);
It works when I modify it in your codepen sample.
Share
Post a Comment
for "D3 - Passing Variable To X Scale"
Post a Comment for "D3 - Passing Variable To X Scale"