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

77
Views
Cómo obtener datos en Victory Native Charts

Estoy usando el gráfico nativo de la victoria para representar el gráfico de área y no sé cómo obtener datos de la API en el gráfico, lo que significa que x contendrá "usia" e y contendrá "indeks_massa". alguien buena gente me puede ayudar a solucionar esto? :(

este es mi código:

 const data = listHistory.map((usia, indeks_massa) => { return { x: usia, y: indeks_massa } }) <VictoryLine style={{ data: { stroke: "blue" }, }} data={data} />
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Bueno, deberá obtener los datos, establecer el estado con ellos y actualizar el componente con información adicional, al menos en función de su documentación . Si necesita manipular los datos, puede hacerlo antes de agregarlos al estado.

 const { useEffect, useState } = React; // Transforms the data function mappedData(data) { return data.map((el, index) => { return { x: el, y: index }; }); } function Example() { const [ data, setData ] = useState([]); // Run `getData` once (the empty dependency array // `[]` ensures that). `getData` fetches the JSON, // and parses it, and then `setData` adds the (now // transformed data to state. useEffect(() => { async function getData() { const response = await fetch(<endpoint>); const data = await response.json(); setData(mappedData(data)); } getData(); }, []); return ( <VictoryBar data={data} x="x" y="x" /> ); } ReactDOM.render( <Example />, document.getElementById('react') );
 <script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.production.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js"></script> <div id="react"></div>

about 4 years ago · Juan Pablo Isaza Report
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!