[Chartjs]-How to wrap X axis labels to multi-lines (X axis label formatting) in ng2-Charts?

19👍

Some workaround only if you want to wrap labels by spliting by space (” “).

scales: {         
      xAxes: [
        {
          ticks: {
            callback: function(label, index, labels) {
              if (/\s/.test(label)) {
                return label.split(" ");
              }else{
                return label;
              }              
            }
          }
        }
      ]
    }

Chart looks like this now.
enter image description here

Leave a comment