高图。如何在一行中将yAxis标题和yAxis标签向右对齐?

时间:2019-05-22 12:19:00

标签: javascript highcharts

请帮助配置“ Highcharts”。我无法在一行的右侧对齐标题和标签。如果标签已在格式化程序中重新计算,则会被裁剪。

enter image description here

yAxis选项配置:

chart: {
   spacingLeft: 0
},
yAxis: {
   offset: 12,
   title: {
      rotation: 0,
      align: 'high',
      y: -21,
      textAlign: 'right',
      x: 0,
      margin: 0,
      offset: 0,
      text: 'ttl'
   },
   labels: {
      x: 0,
      align: 'right',
      formatter: function(e) {
         return e.value * 333;
      }
   }
}

1 个答案:

答案 0 :(得分:0)

您可以使用title.xlabels.x属性来设置空间。 x值包含在图表大小计算中:

yAxis: {
    title: {
        rotation: 0,
        align: 'high',
        y: -21,
        textAlign: 'right',
        x: -10,
        margin: 0,
        offset: 0,
        text: 'ttl'
    },
    labels: {
        x: -10,
        align: 'right',
        formatter: function(e) {
            return e.value * 333;
        }
    }
}

实时演示: http://jsfiddle.net/BlackLabel/67bv3nts/

API参考:

https://api.highcharts.com/highstock/yAxis.labels.x

https://api.highcharts.com/highstock/yAxis.title.x