4๐
โ
You can do 2 things, either supply an labels array with empty strings or use the tick callback to provide empty labels
scales: {
x: {
ticks: {
// Include a dollar sign in the ticks
callback: function(value, index, values) {
return '';
}
}
}
}
Example:
var options = {
type: 'line',
data: {
// option 1, provide empty strings for labels array
labels: ["", "", "", "", "", ""],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
borderWidth: 1
},
{
label: '# of Points',
data: [7, 11, 5, 8, 3, 7],
borderWidth: 1
}
]
},
options: {
scales: {
x: {
ticks: {
//option 2, use callback to change labels to empty string
callback: () => ('')
}
}
}
}
}
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.1.1/chart.js" integrity="sha512-aWx9jeVTj8X49UzUnUHGIlo6rNne1xNsCny/lL0QwUTQK2eilrHXpSk9xbRm4FJ4eLi2XBmnFlRkWPoChSx8bA==" crossorigin="anonymous"></script>
</body>
2๐
Simply disable the x axis labels by one flag like this:
options: {
scales: {
x: {
ticks: {
display: false
}
}
}
}
Source:stackexchange.com