Chart.js 折线图在顶部被截断?折线图、Chart、js

2023-09-07 11:33:16 作者:不甚了了

由于某种原因,所有图表都在最高值处被截断.我怎样才能解决这个问题?我不能使用固定的 y 轴

For some reasone all graphs are cut off at the highest value. How can i fix this? I can't use a fixed y-axis

推荐答案

编辑/更新: 正如评论中提到的,5px 值可以更准确地为您的线宽值的一半,我相信默认值为 2px,所以在这种情况下,您只需要填充:{ top: 1 }

Edit/Update: As mentioned in the comments, the 5px value can more accurately be just half of whatever your line width value is, I belive default is 2px so in that case you would just want padding: { top: 1 }

您可以在选项或全局中设置 layout.padding 属性.我遇到了同样的问题并设置了

There a layout.padding attribute you can set either in options or global. I had this same problem and set

options: {
  layout: {
    padding: {
      top: 5
    }
  },
  ...
}

对我来说很好,没有切断线路http://www.chartjs.org/docs/#chart-configuration-layout-配置

worked fine for me to not cut off the line http://www.chartjs.org/docs/#chart-configuration-layout-configuration

 
精彩推荐
图片推荐