繁体   English   中英

Chart.Js 雷达 - 隐藏 label 编号

[英]Chart.Js radar - hide label numbers

我想从库Chart.js (v3.7) 中删除雷达上显示的数字。

我已经尝试将legend选项设置为display:false

plugins: {
    legend: {
        display: false
    }
}

但它只隐藏了数据集 label。 如果有人对此有解决方案,我将不胜感激。

我假设当您在雷达上说数字时,您的意思是这些?

在此处输入图像描述

当您调用 new Chart() 时,您是否尝试过这样做?

var radarChart = new Chart(data, {
    type: "radar",
    data: data,
    options: {
        scale: {
            ticks: {
                display: false,
            },
        },
    },
});

如果上述方法有用,请在此处找到解决方案: https://stackoverflow.com/a/45725268/3593387

可以通过在options.scales.r.pointLabels.display中将 display 选项设置为 false 来移除外部的标签。 中间的刻度线可以通过在options.scales.r.ticks.display中设置显示选项为false来隐藏

 const options = { type: 'radar', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ label: '# of Votes', data: [12, 19, 3, 5, 2, 3], borderColor: 'orange' }, { label: '# of Points', data: [7, 11, 5, 8, 3, 7], borderColor: 'pink' } ] }, options: { scales: { r: { pointLabels: { display: false // Hides the labels around the radar chart }, ticks: { display: false // Hides the labels in the middel (numbers) } } } } } const ctx = document.getElementById('chartJSContainer').getContext('2d'); new Chart(ctx, options);
 <body> <canvas id="chartJSContainer" width="600" height="400"></canvas> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.js"></script> </body>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM