Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 自定义工具提示或自定义标签(chart.js 2)?_Javascript_Tooltip_Chart.js_Labels - Fatal编程技术网

Javascript 自定义工具提示或自定义标签(chart.js 2)?

Javascript 自定义工具提示或自定义标签(chart.js 2)?,javascript,tooltip,chart.js,labels,Javascript,Tooltip,Chart.js,Labels,我需要一张这样的图表,但我不知道如何得到它 我尝试过自定义工具提示,但我需要同时显示所有工具提示。我也尝试过,但是标签在画布内,看起来像是切割的 我是否需要为每个数据创建html工具提示 有什么想法吗 更新: 这是我的密码: options: { responsive: true, maintainAspectRatio: true, legend: { display: false }, animation: { ani

我需要一张这样的图表,但我不知道如何得到它

我尝试过自定义工具提示,但我需要同时显示所有工具提示。我也尝试过,但是标签在画布内,看起来像是切割的

我是否需要为每个数据创建html工具提示

有什么想法吗

更新:

这是我的密码:

options: {
    responsive: true,
    maintainAspectRatio: true,
    legend: {
        display: false
    },
    animation: {
        animateScale: true,
        animateRotate: true
    },
    cutoutPercentage: 60,
    circumference: 2 * Math.PI,
    showAllTooltips: true,
    tooltips: {
        enabled: false
    },
    plugins: {
        datalabels: {
            backgroundColor: function(context) {
                return context.dataset.backgroundColor;
            },
            borderColor: 'white',
            borderRadius: 50,
            borderWidth: 1,
            anchor: 'end',
            align: 'end',
            color: 'white',
            padding: 10,
            font: {
                weight: 'normal',
                size: '10'
            },
            formatter: function(value, context) {
                var percentageNum = context.chart.data.datasets[0].data[context.dataIndex]
                return percentageNum + '\n  %';
            }
        }
    }
}
这就是我得到的:


您可以粘贴您试图呈现此图表的js代码吗?datalabels正是您想要的。要么让画布变大,要么让图表变小。