Chart.js line chart is cut off at the top?

前端 未结 7 1496
死守一世寂寞
死守一世寂寞 2020-12-16 19:27

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

7条回答
  •  伪装坚强ぢ
    2020-12-16 19:47

    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 }

    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
        }
      },
      ...
    }
    

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

提交回复
热议问题