Chart.js レーダーチャート

レーダーチャートは、複数のデータポイントとその間の変化を表示する方法です。

レーダーチャートは、同じ点から始まる軸上に表された3つ以上の定量的変数を2次元チャートの形式で表示し、多変量データを視覚化するグラフ手法です。

軸の相対的な位置と角度は通常、情報を持ちません。

混合グラフtype属性はradar。

const config = {
  type: 'radar',
  data: data,
  options: {
    elements: {
      line: {
        borderWidth: 3 // 设置线条宽度
      }
    }
  },
};

次に、簡単なレーダーチャートを作成しましょう:

例

const ctx = document.getElementById('myChart');
const data = {
  labels: [
    'Eating',
    'Drinking',
    'Sleeping',
    'Designing',
    'Coding',
    'Cycling',
    'Running'
  ],
  datasets: [{
    label: '最初のデータセット',
    data: [65, 59, 90, 81, 56, 55, 40],
    fill: true,
    backgroundColor: 'rgba(255, 99, 132, 0.2)',
    borderColor: 'rgb(255, 99, 132)',
    pointBackgroundColor: 'rgb(255, 99, 132)',
    pointBorderColor: '#fff',
    pointHoverBackgroundColor: '#fff',
    pointHoverBorderColor: 'rgb(255, 99, 132)'
  }, {
    label: '2つ目のデータセット',
    data: [28, 48, 40, 19, 96, 27, 100],
    fill: true,
    backgroundColor: 'rgba(54, 162, 235, 0.2)',
    borderColor: 'rgb(54, 162, 235)',
    pointBackgroundColor: 'rgb(54, 162, 235)',
    pointBorderColor: '#fff',
    pointHoverBackgroundColor: '#fff',
    pointHoverBorderColor: 'rgb(54, 162, 235)'
  }]
};
const config = {
  type: 'radar',
  data: data,
  options: {
    responsive: true, // チャートをレスポンシブに設定し、画面のウィンドウに応じて変化させる
    maintainAspectRatio: false,// チャートの元の比率を維持する
    elements: {
      line: {
        borderWidth: 3 // 線の幅を設定する
      }
    }
  }
};
const myChart = new Chart(ctx, config);

試してみる »

上記の例の出力結果は次のとおりです:

その他の拡張