Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda