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

前端 未结 7 1486
死守一世寂寞
死守一世寂寞 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条回答
  •  -上瘾入骨i
    2020-12-16 19:58

    I used hardcode, just wide draw area at top and bottom. This code based on original Chart.canvasHelpers.clipArea.

    const WIDE_CLIP = {top: 2, bottom: 4};
    
    Chart.canvasHelpers.clipArea = function(ctx, clipArea) {
        ctx.save();
        ctx.beginPath();
        ctx.rect(
          clipArea.left,
          clipArea.top - WIDE_CLIP.top,
          clipArea.right - clipArea.left,
          clipArea.bottom - clipArea.top + WIDE_CLIP.bottom
        );
        ctx.clip();
    };
    

提交回复
热议问题