4

如何将 yAxis 上的 scaleLabel 显示顺时针旋转 90 度?不是刻度或标签,而是通常位于 yAxis 左侧的单个元素。在此示例中,包含字符串:labelString:'My Label'

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

var ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);

我的 jsfiddle:https ://jsfiddle.net/aq57fxjp/

4

1 回答 1

2

您可以通过注释掉该行来获得所需的效果

rotation = isLeft ? -0.5 * Math.PI : 0.5 * Math.PI;

在源代码中。

于 2018-05-25T12:42:23.113 回答