Chart.js折线图在顶部被截断? [英] Chart.js line chart is cut off at the top?
问题描述
对于某些原因,所有图表都以最高值被截断。
我该如何解决这个问题?我不能使用固定的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值可以更准确地只是你的线宽值的一半,我belive默认值是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 }
你可以在options或global中设置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-configuration
worked fine for me to not cut off the line http://www.chartjs.org/docs/#chart-configuration-layout-configuration
这篇关于Chart.js折线图在顶部被截断?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!