【问题标题】:Highcharts legend index showing -1 on legend clickHighcharts 图例索引在图例点击时显示 -1
【发布时间】:2019-07-30 18:09:02
【问题描述】:

在这个 jsFiddle 中,当除系列 1 之外的所有系列都被取消选择时,它显示为“-1”。这是高图表中的错误还是我做错了什么?我尝试了几件事,例如弄乱偏移量,showEmpty,似乎没有任何效果。有什么想法吗?

http://jsfiddle.net/mhant47c/1/

 $('#container').highcharts({
    chart: {
      type: 'bar'
    },

    yAxis: [{
      width: '33.33%',
      showLastLabel: false,
      id: 'yA0'
    }, {
      left: '33.33%',
      width: '33.33%',
      offset: 0,
      showLastLabel: false,
      id: 'yA1'
    }, {
      left: '66.66%',
      width: '33.33%',
      offset: 0,
      id: 'yA2'
    }],
    plotOptions: {
      series: {
        stacking: 'normal'
      }
    },
    xAxis:{
    showEmpty:false,
    categories:['a','b','c','d']
},
    series: [{
      data: [1, 2, 3, 4]
    }, {
      data: [3, 2, 1, 6]
    },
    {
      yAxis: 1,
      data: [23, 43, 56,23, 43, 56]
    },{
      yAxis: 1,
      data: [23, 43, 56,23, 43, 56]
    }, {
      yAxis: 2,
      data: [123, 413, 516,23, 43, 56]
    }]
  });

【问题讨论】:

    标签: javascript debugging indexing highcharts


    【解决方案1】:

    图表尝试使列居中,从而添加一个额外的类别。为防止这种情况,请使用min 选项:

        xAxis: {
            min: 0,
            ...
        },
    

    现场演示:http://jsfiddle.net/BlackLabel/6p84vx53/

    API 参考:https://api.highcharts.com/highcharts/xAxis.min

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-30
      • 1970-01-01
      • 2016-01-16
      • 2014-11-30
      • 2022-08-10
      • 1970-01-01
      • 2012-05-23
      • 1970-01-01
      相关资源
      最近更新 更多