简体   繁体   中英

How to hide radar chart index labels (chart.js)

I'm trying to make a radar chart with a dark background. White index labels distract from the chart itself.

(my chart)

I found a thread that raised a question about customizing index labels, but the code in the answer only works with version 2.1.3 or mb close to it.

Is it possible in chart.js@3.5.1?

You need to set display to false in the ticks like so:

 const options = { type: 'radar', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ label: '# of Votes', data: [12, 19, 3, 5, 2, 3], borderColor: 'pink' }] }, options: { scales: { r: { angleLines: { display: false }, grid: { display: false }, ticks: { display: false } } } } } 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.1/chart.js"></script> </body>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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