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

356
Vistas
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
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