条形图上的堆栈标签仅在调整窗口大小之后显示

时间:2018-06-19 15:12:46

标签: highcharts highstock

我在JSFiddle中有一个带有以下链接的图表:

https://jsfiddle.net/aditya14641/hLtj3wqb/286/

stackLabels: {
        enabled: true,
        formatter: function() {
          var sum = 0;
          var series = this.axis.series;
          for (var i in series) {
            sum += Math.abs(series[i].yData[this.x]);
          }
          if (sum < 0 && this.isNegative || sum >= 0 && !this.isNegative)
            return sum;
        }
      }

我看到,除非调整JSFiddle窗口的大小,否则在条形图的向下钻取中显示的堆栈标签是不可见的。另外,标签显示的位置不正确:

enter image description here

1 个答案:

答案 0 :(得分:0)

这似乎是错误。我在这里报告过:https://github.com/highcharts/highcharts/issues/8501

解决方法:

setCategories的第二个参数(重画)设置为false

chart.xAxis[0].setCategories(['20-30', '31-40', '41-50', '51-60']);

实时演示: https://jsfiddle.net/BlackLabel/zh7qfes1/