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

159
Visualizações
How to show data with no variation with Linear Gradient using Rechart?

I want to show data fetched from an API in line chart using rechart.But if there is no variation in the datapoint ('pv' in our case) then no graph line is visible when using linear gradient, but I want a single line in case of no variation in the data point. Assume data is fetched from an API and can be dynamic

import { LineChart, Line, Tooltip, XAxis } from "recharts";
import ReactDOM from "react-dom";
import React from "react";

const data = [
  { name: "Page A", uv: 4000, pv: 1000, amt: 2400 },
  { name: "Page B", uv: 3000, pv: 1000, amt: 2210 },
  { name: "Page C", uv: 2000, pv: 1000, amt: 2290 },
  { name: "Page D", uv: 2780, pv: 1000, amt: 2000 },
  { name: "Page E", uv: 1890, pv: 1000, amt: 2181 },
  { name: "Page F", uv: 2390, pv: 1000, amt: 2500 },
  { name: "Page G", uv: 3490, pv: 1000, amt: 2100 }
];

const App = () => {
  return (
    <LineChart width={500} height={500} data={data}>
      <defs>
        <linearGradient id="colorUv" x1="0%" y1="0" x2="100%" y2="0">
          <stop offset="0%" stopColor="blue" />
          <stop offset="50%" stopColor="red" />
          <stop offset="100%" stopColor="red" />
        </linearGradient>
      </defs>
      <Line
        type="monotone"
        dataKey="pv"
        stroke="url(#colorUv)"
        strokeWidth={3}
        dot={false}
        activeDot={false}
      />
      <XAxis />
      <Tooltip />
    </LineChart>
  );
};

ReactDOM.render(<App />, document.getElementById("root"));
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