我正在使用Chart.JS V2,但找不到改变类别标签(演示中的动物,科学和文化)的字体大小的方法:

下面和JSFiddle中的代码和演示。

谢谢。



jQuery(document).ready(function($) {
  new Chart(document.getElementById("so"), {
    type: "radar",
    data: {
      labels: ["Animals", "Science", "Culture"],
      datasets: [{
        label: '',
        data: [46, 51, 29]
      }, {
        label: '',
        data: [0, 0, 0]
      }]
    },
    options: {
      scale: {
        ticks: {
          min: 0,
          max: 100,
          max: 100,
          stepSize: 20,
          beginAtZero: true
        },
      },
      legend: {
        display: false
      }
    }
  });
});

canvas {
  max-width: 400px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.js'></script>

<canvas id='so'></canvas>

最佳答案

这样做:

  new Chart(document.getElementById("so"), {
type: "radar",
data: {
  labels: ["Animals", "Science", "Culture"],
  datasets: [{
    label: '',
    data: [46, 51, 29]
  }, {
    label: '',
    data: [0, 0, 0]
  }]
},
options: {
  scale: {
    ticks: {
      min: 0,
      max: 100,
      max: 100,
      stepSize: 20,
      beginAtZero: true
    },
    pointLabels: { fontSize:18 }
  },
  legend: {
    display: false
  }
} });

07-28 06:16