web-dev-qa-db-ja.com

ChartJsを使用してドーナツチャートの太さを変える方法は?

ChartJs を使用してドーナツチャートの厚さを変更する方法

22
batman

バージョン2以降、フィールドの名前はcutoutPercentageに変更されました。

カットアウト
数値50-ドーナツの場合、0-パイの場合
中央から切り取られたチャートの割合。

詳細はこちら http://www.chartjs.org/docs/#doughnut-pie-chart-chart-options

48
tetchen9
var options = {        
     cutoutPercentage: 70
};
23

percentageInnerCutout を使用:

var options = {        
    percentageInnerCutout: 40
};
myNewChart = new Chart(ct).Doughnut(data, options);

デモ:: jsFiddle

16

Angular via ng2-charts でchart.jsを使用している場合、component.htmlファイルで次のようなことを行います。

// component.html file

<canvas baseChart [options]='chartOptions'>
</canvas>

// Do note that other required directives are missing in this example, but that I chose to highlight the 'options' directive

そして、component.tsファイルで次のようなことを行います。

//component.ts file

chartOptions = {
  cutoutPercentage: 80
};

役立つ情報源: 使用可能なチャートディレクティブ および [options]ディレクティブの構成オプション

1
Tim Dobbins