如何在ApexCharts的多个y轴中设置最小值

3
我一直在尝试自动定义并设置Apexchart y轴上的最小值。单个y轴正常工作,但是一旦添加第二个轴,最小值将设置为0。在下面的示例中,我在控制台中记录了最小和最大值。这可能是图表库中的错误,但我想知道是否有任何解决方法。如果手动设置最小值,则可以正常工作。 代码段: https://codepen.io/Kogelet/pen/rNmMgJE?editors=1111
console.clear();

var options = {
  chart: {
    height: 380,
    width: "100%",
    type: "line"
  },
  series: [
    {
      name: "Series 1",
      data: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
    },
    {
      name: "Series 1",
      data: [20, 30, 40, 50, 60, 70, 80, 90, 100, 110]
    }
  ],
  yaxis: [
    {
      opposite: false,
      min: (min) => {
        console.log('Min:', min);
        return min; 
      },
      max: (max) => {
        console.log('Max:', max);
        return max; 
      }
    },
    {
      opposite: true,
      min: (min) => {
        console.log('Min:', min);
        return min; 
      },
      max: (max) => {
        console.log('Max:', max);
        return max; 
      }
    }
  ]
};

var chart = new ApexCharts(document.querySelector("#chart"), options);

chart.render();

1个回答

3
我用自定义函数解决了这个问题。
min: (min) => {
        min = Math.min(...options["series"][0]["data"]);
        console.log("Min:", min);
        return min;
      }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接