2013-11-21 43 views
1

我已經從highcharts 3.0.5升級到3.0.7,並且該更改包含dataLabels overflow:justify屬性,該屬性被設置爲證明dataLabels正確(參見this fiddle舉例)。這隻會將落在圖表外的標籤滑動到欄中,但顏色不會更改,並且看起來不會有改變顏色的選項。有沒有A)強迫標籤出現在酒吧旁邊並重新調整酒吧大小的任何方式,或者B)當overflow: justify開始玩時改變顏色的方法?highcharts dataLabel溢出:對齊問題

立即想到的唯一「修復」是提供一些maxPadding,但是這感覺有點冒險。

回答

2

,而不是您可以使用屬性

overflow: 'none', 
crop: false 

這裏是API reference

我希望這將有助於你

+0

對,當你這樣做時,標籤可以擴展到表格邊界之外。我目前的解決方案是讓圖表對齊,然後爲標籤提供backgroundColor。我可能會在背景上放一個邊框以使其更加清晰可見,但還沒有這樣做。 – ramblingWrecker

+1

最好和最簡單的答案,但屬性翻轉。他們應該是'溢出:'沒有',裁剪:假'。 –

3

我遇到了同樣的事情,並出現一個解決方案上來爲我的場景工作。

在渲染圖表之後,我查看一系列已經右對齊的dataLabels,然後使用jQuery將它們更改爲白色。

// snipped: rendering the chart 


var chart = $('#chartContainer').highcharts(), 
    labels = $('#chartContainer').find(".highcharts-data-labels tspan"), 
    indexesNeedingWhite = []; 

$.each(chart.series[0].data, function (index, data) { 
    if (data.dataLabel.alignOptions.align === "right") { 
     indexesNeedingWhite.push(index); 
    } 
}); 

// find the exact text label within this container 
// and change the fill to white 
$.each(indexesNeedingWhite, function (i, index) { 
    $(labels[index]).css('fill', 'white'); 
});