chartjs:尝试旋转y轴标签

问题描述 投票:3回答:1

我尝试过像maxRotaterotate这样的东西,把它们放在scaleLabel等等。我在文档中找不到任何内容,谷歌上的搜索结果也没什么帮助。

  var myChart = new Chart(ctx, {
  type: 'line',
  data: chartData,
  options: {
      elements: {
        point: {
          radius: 0
        }
      },
      scales: {
          yAxes: [{
              ticks: {
                  beginAtZero:true
              },
              scaleLabel: {
                display: true,
                labelString: 'MW',
              },
          }],
          xAxes: [
            {
              gridLines: {
              display: false ,
              color: "#FFFFFF"
            },
            ticks: {
              callback: function(tick, index, array) {
                return (index % 2) ? "" : tick;
              }
            }
          }]
      }
  }
});
chart.js
1个回答
0
投票

您可以使用tick属性在Chart.js 2.0中旋转Y轴。这里有一个链接。

yAxes: [{
  ticks : {
    minRotation : 90
  }
}]

在这里小提琴:https://jsfiddle.net/acmfk5p8/

有一个重复的问题here但它也没有答案。

© www.soinside.com 2019 - 2024. All rights reserved.