删除图表js

问题描述 投票:0回答:1

new Chart(stats, { type: 'line', data: { labels: ['', '', '2021', '2022', '2023', '2024', '', ''], datasets: [{ data: [, , 100, 300, 200, 450], borderWidth: 4, borderColor: '#7168BD', backgroundColor: 'rgba(241, 163, 60, 0.1)', pointRadius: 5, pointHoverRadius: 8, pointBackgroundColor: "#7168BD" }, { data: [, , 250, 200, 250, 400], borderWidth: 4, borderColor: '#B6A76E', backgroundColor: 'rgba(230, 57, 70, 0.1)', pointRadius: 5, pointHoverRadius: 8, pointBackgroundColor: "#B6A76E" }] }, options: { scales: { y: { grid: { color: '#B0B0B0', borderColor: 'transparent' } }, x: { grid: { color: '#B0B0B0', borderColor: 'transparent', } } }, plugins: { legend: { display: false, } }, responsive: true } });

<canvas id="stats"></canvas> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.9.1/chart.min.js"></script>

enter image description here转到有关如何使用Chartjs上删除X轴上多余的线的答案?grid Configuration

,您可以自定义Gridline,以免显示第一个和最后一个垂直线。
chart.js
1个回答
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.