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

357
Views
How to change the order the of doughtnut segments in react-chartjs-2

I am making a doughnut chart in react-chartjs-2 and would like to change the order in which the segments of the doughnut appear. At the moment my chart looks like this: chart

I would like to preserve the order of the legend at the top while inverting the order of the segments in the doughnut chart. IE I want it to go LOW,MEDIUM,HIGH,CRITICAL from left to right

Bellow is my code:

const doughnutChartBackgroundColours = [
  LOW_COLOUR,
  MEDIUM_COLOUR,
  HIGH_COLOUR,
  CRITICAL_COLOUR
];

const doughnutChartLabels = [
  LOW,
  MEDIUM,
  HIGH,
  CRITICAL
];

const dummyData = {
  labels: doughnutChartLabels,
  datasets: [
    {
      id: 2,
      backgroundColor: doughnutChartBackgroundColours,
      label: 'Threats',
      data: [3, 2, 1, 5]
    }
  ]
};

In Render Method:

<Doughnut
  datasetIdKey='id'
  data={dummyData}
  />
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!