首页 > 解决方案 > Highcharts 图例索引在图例点击时显示 -1

问题描述

在这个 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]
    }]
  });

标签: javascriptdebuggingindexinghighcharts

解决方案


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

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

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

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


推荐阅读