[Chartjs]-Chart.js how to set cutoutPercentages for each dataset

4👍

This feature was added in v2.8 in 2019 (https://github.com/chartjs/Chart.js/pull/5951).

You can now use the weight property to assign relative widths of datasets.

// following Timo Hulzenboom's example
datasets: [
  {
    data: [50, 30, 20],
    backgroundColor: ['#64D28C', '#F49356', '#F45656']
    weight: 0.33, // will be half as thick
  },
  {
    data: [memoryUsageValue, leftoverMemory],
    backgroundColor: [PercentageColor, '#FFFFFF']
    weight: 0.67,
  }
]

Edit: additional documentation at https://www.chartjs.org/docs/latest/charts/doughnut.html#styling

0👍

I was also searching for this option havent found it yet.
For now I added an extra dataset with borderWidth: 42 so that the sides of ether the inner data or outdoor

datasets: [
  {
    data: [100],
    backgroundColor: ['#FFFFFF'],
    borderWidth: 42
  },
  {
    data: [50, 30, 20],
    backgroundColor: ['#64D28C', '#F49356', '#F45656']
  },
  {
    data: [memoryUsageValue, leftoverMemory],
    backgroundColor: [PercentageColor, '#FFFFFF']
  }
]

Colored borders to show how it works

Non colored border for result

-1👍

There is a weight: prob you can add yo your datasets

Leave a comment