Chart.js pie tooltip getting cut

后端 未结 6 562
故里飘歌
故里飘歌 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:03

    In my case, I was able to work around this issue by reducing the amount of text in the tooltip. I did so using custom tooltip callbacks to specify the label text. My initialization looked like this:

    var chart = new Chart(canvas.getContext("2d"), {
        type: 'line',
        data: chartData,
        options: {
            responsive: true,
            tooltips: {
                callbacks: {
                    title: function(tooltipItems, data) {
                        return tooltipItems[0].xLabel;
                    },
                    label: function(tooltipItems, data) {
                        return tooltipItems.yLabel;
                    },
                }
            },
        },
    });
    

    There appears to be a fix available that hasn't yet been merged into the project: https://github.com/chartjs/Chart.js/pull/1064

提交回复
热议问题