javascript - 如何在 Chart.js 中向垂直刻度(X 轴)添加填充?

标签 javascript chart.js padding chart.js2

根据 Chart.js 版本 2.3 的“Tick Configuration”,只能为 Y 轴 上的刻度设置填充(“< em>水平比例"):

padding | Number |10 | Padding between the tick label and the axis. Note: Only applicable to horizontal scales.

这就像一个魅力:

scales: {
    yAxes: [{
        ticks: {
            padding: 20,
        }
    }],
    xAxes: [{
        ticks: {
             // how to set padding here?
        }
    }]
}

但草案说,我还需要在 X 轴 上填充

enter image description here

如何使用 Chart.js 实现此目的?

也许可以使用插件?

最佳答案

这里的游戏晚了,但最新的 Chart.js 的解决方案是将其包含在您的 options 参数中:

{
  scales: {
    xAxes: [
      {
        ticks: {
          padding: 20
        }
      }
    ]
  }
}

关于javascript - 如何在 Chart.js 中向垂直刻度(X 轴)添加填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40516073/

相关文章:

javascript - 我想在 Chart.js 中显示一个折线栏,其中的数据自动从 mockapi 获取

Android TextView 可绘制,更改可绘制和文本之间的填充?

c# - 如何使用 Ruby/OpenSSL 解密/加密设置填充模式?

css - 带填充的固定定位

javascript - 创建在网络浏览器上运行的桌面应用程序

javascript - 打开选项时 JS select2 插件不滚动

javascript - Live Update Callback -> afterTitle with Array via JSON file

chart.js - Chart.js 中折线图的图例

javascript - 热重载如何工作?

javascript - 使用 async/await 和 try/catch 进行分层 api 调用