I am working with a D3 stack bar chart.
The fiddle is here
When I am clicking on the Month button, the chart appears with a messy x axis label
I want to rotate the x-axis label's conditionally in case of a good amount of data (In the fiddle, for months data)
My first step is to rotate the label. I am appending the below part.
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.selectAll("text")
.style("text-anchor", "end")
.attr("dx", "-.8em")
.attr("dy", ".15em")
.attr("transform", "rotate(-65)" );
I am not sure, why it is not working. Whats the problem here?
question from:
https://stackoverflow.com/questions/65920124/x-axis-text-labels-are-not-rotating-in-d3 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…