Chart.js V3.7.0 如何添加字体系列

How to add font family to Chart.js V3.7.0

这两个我都试过了:

plugin: {
  label: {
    font: {
      family: "Lato"
    }
  }
}

还有这个:

myChart.defaults.global.defaultFontFamily = "Lato";

Lato 字体系列添加到我的图表的代码片段,但这两种情况都不起作用。

有更好的建议吗?请注意,我使用的版本是 3.7.0。 提前致谢!

正确的指定方式是这样的(在 options 中):

plugins: { // not plugin
  legend: { // extra layer: legend
    labels: { // with an "s"
      font: {
        family: "Lato" // right here
      }
    }
  }
}

全球使用:Chart.defaults.font.family = "Lato".
详情 here.