单击图例时删除Highcharts图表Y轴标签

时间:2020-11-05 14:30:48

标签: javascript graph highcharts

我正在处理Highcharts示例(或使用多个Y轴的任何其他示例),并添加多个y轴。问题是当我单击“图例”以从图表中禁用/删除数据时,尽管轴信息已删除,但标题仍会出现。有人知道如何禁用它吗?

fiddle

  var options = {
    chart: {
    type: 'line'
  },
  yAxis: [{},{}],
  series: [{
    yAxis: 0,
    data: [1, 2, 3, 4]
  }, {
    yAxis: 0,
    data: [4, 3, 2, 1]
  }, {
    yAxis: 0,
    data: [6, 6, 6, 6]
  }, {
    yAxis: 1,
    data: [245, 523, 674, 734]
  }, {
    yAxis: 1,
    data: [200, 300, 400, 500]
  }]
}

var chart = Highcharts.chart('container',options);

Chart

1 个答案:

答案 0 :(得分:0)

您需要禁用showEmpty属性:

    yAxis: [{
        showEmpty: false
    }, {
        showEmpty: false
    }]

实时演示: https://jsfiddle.net/BlackLabel/2zk78mnu/

API参考: https://api.highcharts.com/highcharts/yAxis.showEmpty