2014-09-26 33 views
0

我有一個堆疊的背部圖表,其中我添加了一個無形欄到最高欄的高度。所以當一列包含 一個很小的值時,該列仍然是可點擊的。在這種情況下,如果沒有隱形堆棧,值爲1的列幾乎不可點擊。位置dataLabel高於某一列Highcharts

但是,我在對齊每列上面的標籤時遇到問題。我知道我可以使用一些像:

dataLabels: { 
    enabled: true, 
    color: blue, 
    y: -100, 
} 

但這並沒有真正的工作,你可以在圖像中看到。最後一欄的值顯示在欄中,這使其不可見。

enter image description here

這將是最好的,如果我能得到一間酒吧在一定的意甲頂級,(注:第二個在我的情況),並一點點定位dataLabel它上面。像堆棧標籤。

我想這樣的事情,但沒有更迭:

$.each(chart.series[1], function (pointIndex, point) { 
      if (point !== undefined) { 
       var elem = point.graphic.element.getBBox(); 
       point.dataLabel.attr({ y: elem + 20 }); 
      } 
     }); 

回答

0

解決的辦法是比我想象的要簡單很多,最後我做了以下內容:

var chart = $('#target').highcharts(); 
var points = chart.series[1].points; 


$.each(points, function (pointIndex, point) { 
      text = chart.renderer.text(
       'Put whatever you like here', 
       point.plotX + chart.plotLeft - 10, 
       point.plotY + chart.plotTop - 20 
      ).attr({ 
       zIndex: 5 
      }).add(); 
     }); 

代碼從使用this example