javascript - How to rotate X-axis labels onto the bar in bar chart? -


I need to align the X-axis labels as shown in the snapshot below:

Enter image details here

I tried:

 < Code> .attr ("  

but it rotates the entire axis / scale.

How can I fix this?

< Strong> edit: I updated my code:

  svg.append ("g") .attr ("class", "x axis") .attr ("conversion "," Translation (0, "+ oh Style ("text-anchor" "end") .attr ("dx", "0em") .attr ("dy", "0em"). ") .attr (" transform ", function (d) {return" rotate (-90) "});   

Now the labels rotate to -90 degrees How do I get it on bars

I am not Translation Good to use but it works just fine.

The reason revolves around the entire axis / scale, because when the text is being created with the x and y position its origin point is (0,0) .

To rotate your text labels, you need to move those code, which is X and Y instead of translation .

I have added the code below, where the text labels are being rotated.

If you want to rotate it more often You can simply change the degree of rotation.

 svg.selectAll (".text"). Data () .endre (.append ("text") .attr ("transform", function (d, i) {"translation (" + (35 + x (DAG) + ", 250)" + "(+90)"}) .text (function (d) {return d.age;})  

Hope This is helpful for you.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -