[英]How can I make small grid lines above ChartJS labels?
我正在使用 Chart.js 來繪制一個簡單的折線圖。 如何在 xAxis 標簽上制作小網格線?
折線圖的文檔在這里: https://www.chartjs.org/docs/2.7.3/getting-started/?h=line ,但我找不到任何關於它的信息。
我刪除了 XAxis 和 YAxis 網格線。
這是所需的小網格線的示例:
提前致謝。
您可以將drawOnChartArea
設置為 false,而不是刪除網格線:
var options = { type: 'line', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ label: '# of Votes', data: [12, 19, 3, 5, 2, 3], borderColor: 'pink' }, { label: '# of Points', data: [7, 11, 5, 8, 3, 7], borderColor: 'orange' } ] }, options: { scales: { x: { grid: { drawOnChartArea: false } }, y: { grid: { drawOnChartArea: false } } } }, } var 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.6.2/chart.js"></script> </body>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.