Chartjs-ChartJS, Multiple line in bar chart label

2👍

This can be achieved by passing the label as an array of strings where each element represents a line, e.g.:

let labels = [
  'A', // normal label.
  ['First line', 'Second line', '...'] // multi-line label.
];

A working example:

new Chart(document.getElementById("chart"), {
  type: 'bar',
  data: {
    labels: ['A', ['Water', 'Heating'], 'C'],
    datasets: [{
      data: [1, 1, 1]
    }]
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>
<canvas id="chart"></canvas>

Leave a comment