如何在Chart.JS V2中修改类别标签字体大小?

时间:2017-01-26 06:55:23

标签: javascript chart.js

我使用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>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

这样做:

  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
  }
} });