Chartjs-Is there a way to change the dispaly of a date

2👍

You can use multiline labels for that by providing the labbels in an array like so:

var options = {
  type: 'line',
  data: {
    labels: [
      [
        "Red",
        "second line"
      ],
      [
        "Blue",
        "second line"
      ],
      [
        "Yellow",
        "second line"
      ],
      [
        "Green",
        "second line"
      ],
      [
        "Purple",
        "second line"
      ],
      [
        "Orange",
        "second line"
      ]
    ],
    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: {
      yAxes: [{
        ticks: {
          reverse: false
        }
      }]
    }
  }
}

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/2.9.4/Chart.js"></script>
</body>

Leave a comment