Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
x-axis label overwritten in svg graph

I am working on a stacked barchart. Here is the codepen https://codepen.io/a166617/pen/NWvZGLd

As you can see in codepen, the x-axis label is overlapping each other and i am trying to make it at an angle so that they wont overlap each other. For e.g. this screenshot below

enter image description here

I tried to add transform: rotateX(90deg) as a style but it does not show properly. Here is the line of code where i added the above css

<text
  x={125 + rowIndex * 60}
  y={520}
  textAnchor="middle"
  style={{ fill: 'red',
           fontSize: '13px',
           transform: `rotateX(90deg)`
  }}
  >{entry.name}</text>

Can someone please let me know how to achieve this so that the x-axis label is clearly viewed.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Rotate transforms will rotate around the current origin. Which for SVGs defaults to the origin of the SVG. That is 0,0. Because your text is nowhere near (0, 0), your transform will rotate the text away from where you want it.

To avoid that you'll need to change the transform-origin before you rotate. Something like this:

<text
  x={125 + rowIndex * 60}
  y={520}
  textAnchor="end"
  style={{ fill: 'red',
    fontSize: '13px',
    transformOrigin: (125 + rowIndex * 60)+'px 520px',
    transform: 'rotateZ(-45deg)'
  }}
  >{entry.name}</text>

I did it a slighlty different way in my updated answer to your previous question. I used the special version of rotate (rotate(angle,cx,cy)) that only the SVG transform attribute accepts. It includes an X,Y centre of rotation. For CSS, you have to use transform-origin.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda