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

242
Visualizações
How to fill area under `recharts` `AreaChart` curve, when data has +ve and -ve values

I have a chart made with the javascript recharts library. How can I fill the area under the curve, down to the bottom of the visible area, not to zero?

Currently looking like this: enter image description here

But I would like the curve to fill to the bottom of the chart, and not down to/up to zero.

Code for this section is as follows:

  return (
    <ResponsiveContainer width="100%" height="100%">
      <AreaChart
        data={data}
        margin={{
          top: 5,
          right: 30,
          left: 20,
          bottom: 5,
        }}
      >
        <defs>
          <linearGradient id="fillGradient" x1="0" y1="-1" x2="0" y2="1">
            <stop offset="5%" stopColor="#3182ce" stopOpacity={1} />
            <stop offset="95%" stopColor="#FFFFFF" stopOpacity={1} />
          </linearGradient>
        </defs>
        <CartesianGrid strokeDasharray="3 0" opacity={0.2} />
        <XAxis dataKey="date" tickFormatter={parseTimeLabels} />
        <YAxis />
        <Tooltip />
        <Legend />
        <Area
          type="natural"
          dataKey="height"
          stroke="#8884d8"
          fillOpacity={1}
          fill="url(#fillGradient)"
          activeDot={{ scale: 10, onClick: (e, point) => onLineClick(point) }}
        />
      </AreaChart>
    </ResponsiveContainer>
  );
about 4 years ago · Santiago Gelvez
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