title: How to draw some of the elements rotated on the Сanvas in Jetpack Compose?
body: <p>I'm drawing chart in Jetpack Compose, with x labels written using <code>drawIntoCanvas</code> method. Basically very simple block of code:</p>
  <pre class="lang-kotlin prettyprint-override"><code>data.forEachIndexed { index, point -&gt;
      drawIntoCanvas {
          it.nativeCanvas.drawText(
              &quot;${point.x}&quot;,
              chartCanvasStartX + index * intervalX,
              size.height + 4.dp.toPx(),
              textPaint
          )
      }
  }
  </code></pre>
  <p>Output is as expected:
  <a href="https://i.stack.imgur.com/qJqaN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qJqaN.png" alt="enter image description here" /></a></p>
  <p>However I would like to achieve those labels to be sloped at desired angle, to fit longer text. I've tried applying rotation to the canvas, but that produces output, where whole canvas is rotated, not the individual iterations of this forEach loop. Even using methods like <code>canvas.save()</code> and <code>canvas.restore()</code> between angle transformation didn't produce desired output. Maybe in Compose declarative world there is some simpler solution for drawing such a texts?</p>
  <p>Here is mockup for visualization of what I would like to achieve:
  <a href="https://i.stack.imgur.com/eRs2m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eRs2m.png" alt="enter image description here" /></a></p>
  <p>Note: Whole chart is written in single Compose <code>Canvas</code> method, because I want to have reference to every x value of chart to place label precisely at this point, so I don't want to place any <code>Column</code> with regular Compose <code>Text</code> with rotate modifier applied.</p>