Chart.js 折线图在顶部被截断? [英] Chart.js line chart is cut off at the top?

查看:13
本文介绍了Chart.js 折线图在顶部被截断?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,所有图表都在最高值处被截断.我怎样才能解决这个问题?我不能使用固定的 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

这篇关于Chart.js 折线图在顶部被截断?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆