最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to add font family to Chart.js V3.7.0 - Stack Overflow

programmeradmin2浏览0评论

I tried both this:

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

and this:

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

Pieces of code to add Lato font family to my chart, but both cases didn't work.

Any better suggestions? Note that the version I use is 3.7.0. Thanks in advance!

I tried both this:

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

and this:

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

Pieces of code to add Lato font family to my chart, but both cases didn't work.

Any better suggestions? Note that the version I use is 3.7.0. Thanks in advance!

Share Improve this question edited Jan 19, 2022 at 11:12 code 6,3394 gold badges20 silver badges46 bronze badges asked Jan 19, 2022 at 0:41 Jameu Lukasli1Jameu Lukasli1 5075 silver badges22 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 11

For global use: Chart.defaults.font.family = "Lato".
Details here.

The correct way to specify would be like this (in options):

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

评论列表(0)

  1. 暂无评论