Chart.js and long labels

前端 未结 6 649
难免孤独
难免孤独 2020-12-30 22:45

I use Chart.js to display a Radar Chart. My problem is that some labels are very long : the chart can\'t be display or it appears very small.

So, is there a way to b

6条回答
  •  -上瘾入骨i
    2020-12-30 23:12

    To wrap the xAxes label, put the following code into optoins. (this will split from white space and wrap into multiple lines)

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

提交回复
热议问题