chart.js - 图表 : trying to rotate the y-Axis label

标签 chart.js

我尝试过诸如 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;
              }
            }
          }]
      }
  }
});

最佳答案

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

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

在这里摆弄:https://jsfiddle.net/acmfk5p8/

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

关于chart.js - 图表 : trying to rotate the y-Axis label,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45306604/

相关文章:

javascript - Chartjs 2.7.3 : Set Y data at the correct X position axis

javascript - 如何通过按下按钮(chart.js)来制作新图表?

chart.js - 带有 {x, y} 点数据的折线图仅显示 2 个值

javascript - 使用 ChartJS 在 y 轴上显示美元符号

javascript - Chart.js 未显示在第二个选项卡上

javascript - Chart.js 使用日期创建折线图

javascript - chart.js 中圆环图上的自定义数据位置

javascript - 单击按钮切换 chart.js 数据

Chart.js maxBarThickness 在角度 8 中已弃用

javascript - HTML 如何阻止元素不超过页脚等