0👍
You can define gridLines.drawOnChartArea: false
on both axes.
From Chart.js documentation.
drawOnChartArea
: If true, draw lines on the chart area inside the axis lines. This is useful when there are multiple axes and you need to control which grid lines are drawn.
Please have a look on below runnable code snippet.
new Chart(document.getElementById('canvas'), {
type: 'horizontalBar',
data: {
labels: ['A', 'B', 'C', 'D'],
datasets: [{
label: 'data',
data: [15, 12, 8, 13],
backgroundColor: ['red', 'blue', 'green', 'orange']
}]
},
options: {
responsive: true,
legend: {
display: false
},
title: {
display: false
},
scales: {
yAxes: [{
gridLines: {
drawOnChartArea: false
}
}],
xAxes: [{
ticks: {
beginAtZero: true
},
gridLines: {
drawOnChartArea: false
}
}]
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>
<canvas id="canvas" height="90"></canvas>
- Chartjs-Opening json file to create chart in chart.js
- Chartjs-Chart.JS Chart top left corner is blocked by some visual nodejs
Source:stackexchange.com