簡體   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