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

464
Visualizações
How to get equal spacing between the labels of the y-component of chart in recharts.js

I am using recharts.js in react.js with the functional component. The expected result is to get equal spacing between 20-50 , 50-80 , 80-100 percent as shown in the image below:

enter image description here

You might have noticed the spacing between each tick is equal. But in my case I am getting the output in my browser is like this one:

enter image description here

Please tell me how can I achieve the same thing.My code is here below:

activity.json file

[
    {
        "day" : "Sat",
        "level": 70
    },
    {
        "day" : "Sun",
        "level": 50
    },
    {
        "day" : "Mon",
        "level": 82
    },
    {
        "day" : "Tue",
        "level": 80
    },
    {
        "day" : "Wed",
        "level": 70
    },
    {
        "day" : "Thu",
        "level": 90
    },
    {
        "day" : "Fri",
        "level": 100
    }
]

chart.js file

import activity from "../../activity.json";

<ResponsiveContainer width="100%" height={170}>
  <AreaChart data={activity}>
     <defs>
       <linearGradient id="color" x1="0" x2="0" y1="0" y2="1">
         <stop offset="0%" stopColor="#4DC591" stopOpacity="0.4"></stop>
         <stop offset="90%" stopColor="#4DC591" stopOpacity="0.05"></stop>
       </linearGradient>
     </defs>
     <Area type="monotone" dataKey="level" stroke="#4DC591" fill="url(#color)" />
     <XAxis dataKey="day" axisLine={false} tickLine={false} minTickGap={20} />
     <YAxis dx={-17} dataKey="level" axisLine={false} tickLine={false} ticks={[20 , 50 , 80 , 100]}  tickFormatter={(number) => {return number + "%"}}  interval={0} domain={[20, 'dataMax']} />
     <Tooltip />
     <CartesianGrid vertical={false} opacity={0.4} strokeDasharray="3 3" />
  </AreaChart>
</ResponsiveContainer>
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