ChartJS / react-chartjs-2 divide bar in to two data points

  Kiến thức lập trình

I am creating a barchart with ChartJS / react-chartjs-2.
The barchart is displaying allright so far, nothing special:

just a normal barchart

My data looks like this:

    {
      Name: "De Regenboog",
      Patients: "7546",
      Year1Total: "34",
      Year1Pos: "4",
      Year2Total: "51",
      Year2Pos: "1",
      Year3Total: "43",
      Year3Pos: "0",
    },
    {
      Name: "George Michael",
      Patients: "2644",
      Year1Total: "20",
      Year1Pos: "0",
      Year2Total: "18",
      Year2Pos: "0",
      Year3Total: "64",
      Year3Pos: "0",
    },
   etc
  ]

I want the positives to display as a part of the total bar of that year for that Name.
So for ‘De Regenboog’ in the year 2021 it would show the total bar to be 34 and 4 would be coloured in differently to be the positive tests that year. I am not sure what to search for or how to approach this. Would it be possible at all ? Maybe anyone has an idea?

LEAVE A COMMENT