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

223
Views
No se pueden representar datos de una API usando object.entries en el gráfico usando la biblioteca Recharts

Tengo un problema con la visualización de datos provenientes de una API en el gráfico que proviene de la biblioteca de Recharts. Para lograr eso, estoy tratando de hacer uso de Object.entries. Esta es mi estructura de API: {"deviceId":"27ff89713e684bbd8f13820c53908e79","G1HNQ3":97,"BBPF0F":-220} Los valores de esas propiedades no son estáticos y siguen cambiando. Para cualquier consejo de solucionar este problema estaría muy agradecido,

Gracias

Por favor, eche un vistazo a mi código:

 import "./App.css"; import React, { Component } from "react"; import logo from "./Logo.jpg"; import axios from "axios"; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, } from "recharts"; class App extends Component { state = { data: [] }; componentDidMount() { const dataInterval = setInterval(this.getData, 1000); } componentDidUpdate() { console.log(this.state.data); } getData = async () => { await axios.get("/random-data").then((res) => { this.setState({ data: [ ...this.state.data, res.data, { currentDateTime: Date().toLocaleString() }, ], }); }); }; renderLine = () => { Object.entries(this.state.data).forEach(([key, value]) => { Object.entries(value).forEach(([key, value]) => { if (key === "deviceId" || key === typeof Number) { return; } return <Line type="monotone" dataKey={key} stroke="red" />; }); // }); }; render() { return ( <div className="App" style={{ display: "flex", flexDirection: "column", alignItems: "center", }} > <img src={logo} alt="BromleySat" /> <h1 style={{ color: "green" }}>BromleySat's Serial Plotter</h1> <LineChart width={1000} height={300} data={this.state.data}> <CartesianGrid></CartesianGrid> <XAxis dataKey="currentDateTime"></XAxis> <YAxis></YAxis> <Tooltip></Tooltip> <Legend></Legend> {this.renderLine()} </LineChart> </div> ); } } export default App;
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!