Highcharts:多个Yax标签重叠

Highcharts:多个Yax标签重叠,highcharts,Highcharts,我有一个图表,其中有多个Yax和重叠的标签。我不能用不同的x值来实例化它们,因为我有一个UI,可以打开和关闭轴,这样会给其中一个标签留下奇怪的间距。我想使用formatter来检测标签是否不是第一个标签,然后更改x值,但我很难找到如何在formatter回调中更改该值。下面是我的代码 { title: 'Count', gridLineDashStyle: 'Dash', gridLineColor: '#e8ebef', show

我有一个图表,其中有多个Yax和重叠的标签。我不能用不同的x值来实例化它们,因为我有一个UI,可以打开和关闭轴,这样会给其中一个标签留下奇怪的间距。我想使用formatter来检测标签是否不是第一个标签,然后更改x值,但我很难找到如何在formatter回调中更改该值。下面是我的代码

{
        title: 'Count',
        gridLineDashStyle: 'Dash',
        gridLineColor: '#e8ebef',
        showFirstLabel: false,
        labels: {
          enabled: true,
          align: 'right',
          x: 5,
          y: 15,
          style: {
            fontFamily: fontFamily,
            fontSize: '10px',
            fontWeight: 'bold',
            color: '#8596a5'
          }
        },
        opposite: true,
        allowDecimals: true,
        min: 0,
        minRange: 2 // Ensures flat charts don't show line at the bottom
      },
      {
        title: 'Cost',
        gridLineDashStyle: 'Dash',
        gridLineColor: '#e8ebef',
        showFirstLabel: false,
        labels: {
          enabled: true,
          align: 'left',
          x: 5,
          y: 15,
          style: {
            fontFamily: fontFamily,
            fontSize: '10px',
            fontWeight: 'bold',
            color: '#8596a5'
          },
          formatter: function() {
          if ( this.isFirst ) { console.log("first") }
            this.attr({ x:44 })
          }
        },
        allowDecimals: true,
        min: 0,
        minRange: 2 // Ensures flat charts don't show line at the bottom
      },

有什么想法吗?

你的两个yAxis都应该有你想展示它们的顺序。yAxis需要堆叠起来。使用

yAxis:0, //for first series 
yAxis:1  //for second series

我将在几分钟内添加一个提琴。

请在jsfiddle.net上以实时演示的形式重新创建您的示例