簡體   English   中英

Chart.js 刪除第一條垂直線

[英]Chart.js remove the first vertical line

有沒有辦法在不刪除值的情況下從圖表中刪除初始垂直線? chart.js 刪除垂直線

這是我的選項的樣子:

scales: {
        yAxes: [{
            ticks: {
                beginAtZero: true,
                maxTicksLimit: 5,
                suggestedMax: maxValue
            }
        }],
        xAxes : [{
            categoryPercentage: 1.0,
            display : false, // set this to false to hide the labels under the bars
            gridLines: {
                display: false
            }
        }]
    },

您要刪除的可能是圖表的邊框。 在 Chart.js v2 中,我能夠通過將網格線配置的drawBorder設置為false來刪除第一個垂直邊框:

options: {
    scales: {
        yAxes: [{
            gridLines: {
                drawBorder: false
            }
        }]
    }
}

在 Chart.js 文檔中,它在https://www.chartjs.org/docs/latest/axes/styling.html#grid-line-configuration 中進行了解釋。

嘗試使用圖表選項 scaleLineColor,並將顏色設置為 0 不透明度:

new Chart(ctx).Bar(data, {
scaleLineColor: 'rgba(0,0,0,0)'
});

http://jsfiddle.net/wb3kcunt/33/

如果您使用的是 chartjs v2,那么 scales.gridLines 中的 showBorder 選項應該可以解決問題:

options:{
   scales: {
    gridLines:{
      showBorder:false
        }
    }
}

查看文檔:

http://www.chartjs.org/docs/#scales

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM