0

I have data like that

const Power = [
    {
    "Week": [
      {"x": "Monday", "y": 11},
      {"x": "Tuseday", "y": 12},
      {"x": "Wednesday", "y": 17},
      {"x": "Thursday", "y": 18},
      {"x": "Friday", "y": 19},
      {"x": "Saturday", "y": 18},
      {"x": "Sunday", "y": 11}
    ],
    "Days": [
      {"x": "6:00 am", "y": 18},
      {"x": "10:00 am", "y": 13},
      {"x": "2:00 pm", "y": 16},
      {"x": "4:00 pm", "y": 14},
      {"x": "8:00 pm", "y": 19},
      {"x": "11:00 pm", "y": 13}
    ]
  }
]

I want to design the chart by different data by Days and Week so, I unable to fetch the data by week and Days individually. So, Please suggest some solutions to achieve this

krimo
  • 666
  • 2
  • 8
  • 27
Vijay Gehlot
  • 80
  • 1
  • 10

1 Answers1

0

try yo look on chartjs and react-chartjs-2(you need to download chartjs for this) you need to make array of the x and y axis and send it in a object

 {
  labels: string[];
  datasets: {
    label: string;
    backgroundColor?: string;
    borderColor: string;
    pointBackgroundColor?: string;
    data: number[]
  }[]
}

I keep the types from my typescript project so you can see how you can send it

TalOrlanczyk
  • 1,205
  • 7
  • 21