Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!