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

108
Views
React how to create a data for chart?

I have a line chart react-google-charts. This chart accepts the data in the form of:

const data = [
        ["Date", "Realizado"],
        ["Jan 01", 4 ],
        ["Jan 07", 12],
        ["Jan 14", 20],
        ["Jan 28", 282],
      ];

And I get data from API. This data returns;

(8) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
  0: {period: '2021/09', value: 0.9256896545996849}
  1: {period: '2021/06', value: 0.9754303727212889}
  2: {period: '2021/03', value: 0.9791388246940228}
  3: {period: '2020/12', value: 1.015357654499295}
  4: {period: '2020/09', value: 0.9337976106510073}
  5: {period: '2020/06', value: 0.9930550362681277}
  6: {period: '2020/03', value: 1.064082963594007}
  7: {period: '2019/12', value: 1.095682769989701}
length: 8
[[Prototype]]: Array(0)

How can I fit this array as chart data?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Something like this may work:

const chartData = apiData.map(obj => [obj.preriod, obj.value])

PS. you may need to reformat your date

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!