0👍
You will need to use a labels array and place all the multiline labels in an array where each entry is its own line:
const options = {
type: 'bar',
data: {
labels: [
['hello', 'world'],
['test', 'second line'], 'ff'
],
datasets: [{
label: '# of Votes',
data: [5, 3, 6],
borderWidth: 1
}, ]
},
options: {
indexAxis: 'y',
scales: {}
}
}
const ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.3.0/chart.umd.js"></script>
<body>
<canvas id="chartJSContainer" width="600" height="400"></canvas>
</body>
- Chartjs-Charts.js v2: always show custom (html) tooltips on chart
- Chartjs-Create IF to change chart.js bar color
Source:stackexchange.com