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

102
Visualizações
Rechart multiple line depending on api

I have a ReChart based program, this program consumes an API that gives some information about indicators, each indicator is one Line element in my chart, the problem here is that I don't know how many indicators comes in API response, maybe 1, maybe 2, maybe x indicators. I can't set up the number of Line elements since code, I need to set the number of lines after my API call. Is there any solution to this issue?

This is my code:

 return (
<div className="flex-row-reverse">
  <div className="w-1/4 bg-gray-600">
    Aqui iria el select o algo por el estilo
  </div>
  <div className="w/3/4">
    <ResponsiveContainer id="container" width={"100%"} height={400}>
      <LineChart
        data={data}
        margin={{ top: 30, right: 30, left: 30, bottom: 30 }}
      >
        <CartesianGrid />
        <XAxis type="number" dataKey="time" domain={["dataMin", "dataMax"]}>
          <Label
            value={"Time"}
            position="bottom"
            style={{ textAnchor: "middle" }}
          />
        </XAxis>
        <YAxis>
          <Label
            value={"Indicadores"}
            position="left"
            angle={-90}
            style={{ textAnchor: "middle" }}
          />
        </YAxis>
        <Tooltip />
        <Line
          dataKey="AguaCo2"
          name="AguaCo2"
          unit={"L"}
          dot={false}
          type={"natural"}
        />
        <Line
          dataKey="Co2O3"
          name="Co2O3"
          unit={"L"}
          dot={false}
          type={"natural"}
        />
      </LineChart>
    </ResponsiveContainer>
  </div>
</div>

);

This code has two Line elements, but I need that Lines goes adding from de API response.

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