简体   繁体   English

如何使用 ChartJS 自定义标题 position

[英]How to customize Title position with ChartJS

Is it possible with ChartJS to place the position of the Title, aside from the standard top , left , bottom , and right options exposed by ChartJS?除了 ChartJS 公开的标准topleftbottomright选项之外,ChartJS 是否可以放置标题的 position ?

I'd prefer the Title in the Top Left of the canvas. Can't find anything in the documentation indicating whether this is doable, or if it can be adjusted via callback or plugin我更喜欢 canvas 左上角的标题。在文档中找不到任何内容表明这是否可行,或者是否可以通过回调或插件进行调整

Thanks!谢谢!

According to documentation from chart.js documentation page 根据chart.js文档页面的文档

Only top,left,right and bottom are available. 只有顶部,左侧,右侧和底部可用。

you should set Align to (start or center or end) for title:你应该为标题设置 Align to (start or center or end):

 const options = {
  responsive: true,
  plugins: {
    title: {
      display: true,
      color:'#8b93a2',
      align:'start',
      position:'top',
      text: 'Chart title',
    },
  },
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM