title: D3.js rotate axis labels around the middle point
body: <p>I am working with D3.js now and even though I found very similar cases I am not really able to put them together and move on.</p>
  
  <p>I have something similar as a radar chart and I would like to append to each ax I create (number of axes is not fixed could be 4, but also 40) text, which I already have, but rotate the text around center point and turn them as soon as they reach 180 degrees, actually 0 degrees. </p>
  
  <p>The result should look like this: </p>
  
  <p><a href="https://i.stack.imgur.com/4Hcw2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Hcw2.png" alt="enter image description here"></a></p>
  
  <p>What I have now is this:</p>
  
  <p><a href="https://i.stack.imgur.com/WD5ID.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WD5ID.png" alt="enter image description here"></a></p>
  
  <p>I only know how to reach this within <code>arc</code>, which is also nicely shown <a href="http://bl.ocks.org/vigorousnorth/7331bb51d4f0c2ae0314" rel="nofollow noreferrer">here</a>, but I did not really figure it out for my case.</p>
  
  <p>This is my code snippet, where I append those text criteria: </p>
  
  <pre><code>//Write criterias
        axis.append("text")
          .attr("class","labels")
          .attr("font-size","12px")
          .attr("font-family","Montserrat")
          .attr("text-anchor","middle") 
          .attr("fill","white")
          .attr("x",function (d, i) {
            return radius * Math.cos(angleSlice * i - Math.PI/2)*options.circles.labelFactor;
          })
          .attr("y",function (d, i) {
            return radius * Math.sin(angleSlice * i - Math.PI/2)*options.circles.labelFactor;
          })
          .text(function (d) {
            return d;
          });
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is my fiddle: <a href="https://jsfiddle.net/fsb47ndf/" rel="nofollow noreferrer">https://jsfiddle.net/fsb47ndf/</a></p>
  
  <p>Thank you for any advise</p>