Chart.js pie tooltip getting cut

后端 未结 6 563
故里飘歌
故里飘歌 2020-12-29 03:35

I\'m using Chart.js pie chart with tooltips which being cut for some reason.

Screenshot attached, didn\'t found any attribute/option to take care of it..

Is

6条回答
  •  暖寄归人
    2020-12-29 04:20

    It seems like Chart.js can't figure out which direction to show the tooltip because it can't detect the size of the tooltip element when it extends beyond the canvas.

    In my scenario I fixed it by squeezing the text inside this particular tooltip closer with these options for the tooltip options object:

            tooltips.titleMarginBottom = 1;
            tooltips.bodySpacing = 1;
            tooltips.yPadding = 2;
    

    Wierdly enough Chart.js then correctly decides to show the tooltip to the left of the mouse and not below. Would be cool if you could choose which direction the tooltip appears compared to the mouse.

提交回复
热议问题