Chartjs-Multiple labels in chart js, i want to change the order of the labels

0👍

To change the order of the labels in the chart, you’ll need to modify the labels property of the data object in the chart configuration.

One approach would be to sort the $categories array in the desired order before generating the labels for the chart. For example, if you want to sort the categories based on the "position" field in ascending order:

$categories.sort(function(a, b) {
  return a.position - b.position;
});

labels: [
  @foreach($categories as $cat)
    @foreach($cat['verbatim'] as $verbatim)
      '{{ $verbatim }}',
    @endforeach
  @endforeach
],

Leave a comment