Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

201
Vistas
rechart biaxial line chart not rendering

I am using function components with hooks and I am fetching 3 pieces of data related to covid-19 such as date, confirmed cases, and deaths and then storing this data in this component. I would like to plot biaxial line chart with X-axis represented by the date, and the two lines representing confirmed cases and deaths occurred in that specific date. After successfully storing the data I am transforming it into array and then passing it to chart component as an array of object. However, the data is shown on the screen but lines are not rendered.

import React, { useEffect, useState } from "react";
import { fetchDailyData } from "../../api";

import classes from './Chart.css';
import { BarChart, Bar, CartesianGrid, XAxis, YAxis,Tooltip,Legend } from 'recharts';
import {
  LineChart,
  Line,
} from "recharts";

const Chart = ({data:{confirmed,deaths,recovered},country}) => {

    const [dailyData,setDailyData]= useState([]);

    useEffect(()=> {
        const fetchApi = async() => {
            setDailyData(await fetchDailyData());
        }

        fetchApi();
    },[])

const data = [
  {
    name: dailyData.map(({ date }) => new Date(date).toLocaleDateString()),
    confirmed: dailyData.map((data) => data.confirmed),
    deaths:dailyData.map((data) => data.deaths)
  }
 
];


      
    return (
       <div className={classes.container}>
         <LineChart width={730} height={250} data={data}
                margin={{ top: 5, right: 30, left: 20, bottom: 5 }}>
                <CartesianGrid strokeDasharray="3 3" />
                <XAxis dataKey="name" />
                <YAxis />
                <Tooltip />
                <Legend />
                <Line type="monotone" dataKey="confirmed" stroke="#0095FF" />
                <Line type="monotone" dataKey="deaths" stroke="#0095FF" />
          </LineChart>
       </div>
    )
}
    
export default Chart;
about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda