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

376
Visualizações
Rechart xAxis label overflow bug

I am having an issue with recharts library, in this case BarChart component

What i want to achieve is to customize the label text in xAxis, i already created a custom component for tick, to make text too long having ellipsis or something like this, but seems i can't do anything for text overflow or decide any size. Here's my code so far:

function renderTicks(props) {
  console.log(props)
  const space = props.width / props.visibleTicksCount
  console.log(space)
  const stringLength = props.payload.value.length * 7
  console.log(stringLength)
  return (
    <text 
    style={{ fontSize: 10 }}
    width={70} verticalAnchor="start" textAnchor="middle" x={props.x} y={props.y}>{props.payload.value}</text>
  )
}

function BarChart({ config = {}, data = {} }) {
  console.log(data)
  return (
    <StyledChart width={450} height={450} data={data} >
      <XAxis
        tick={renderTicks}
        height={100}
        interval={0} dataKey="name" >
        <Label value="" content={<LabelCustom />} />
      </XAxis>
      <YAxis />
      <Tooltip />
      <Bar dataKey="value" fill={colorsChart[0]} />
    </StyledChart>
  );
}

Here is the current behaviour:

enter image description here

I found lot of problem like this browsering the problem but not valid solution, any tip is appreciated

about 4 years ago · Juan Pablo Isaza
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