Dashed gridlines in Chart.js version 4.x

huangapple go评论60阅读模式
英文:

Dashed gridlines in Chart.js version 4.x

问题

你想要在Chart.js中创建虚线网格线,我知道关于borderDash属性,但这对我不起作用,在文档中我找不到任何相关信息。

英文:

How can I make dashed gridlines in Chart.js? I know about the borderDash property, but this doesn't work for me, and in the documentation I don't find anything about this.

scales: {
   y: {
     grid: {
        drawTicks: false,
        borderDash:[5,5], //thid don't work
        display: true
     }
   }
}

答案1

得分: 3

自版本4以来,边框是轴的特定配置节点。

查看迁移指南:https://www.chartjs.org/docs/latest/migration/v4-migration.html#specific-changes

您的配置应该是:

scales: {
   y: {
     border: {
       dash: [5, 5],
       display: true
     } 
     grid: {
        drawTicks: false,
        display: true
     }
   }
}
英文:

Since version 4, the border is a specific config node of the axes.

See Migration guide: https://www.chartjs.org/docs/latest/migration/v4-migration.html#specific-changes

Your config should be:

scales: {
   y: {
     border: {
       dash: [5, 5],
       display: true
     } 
     grid: {
        drawTicks: false,
        display: true
     }
   }
}

huangapple
  • 本文由 发表于 2023年4月19日 21:39:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76055239.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定