2015-01-21 110 views

回答

0

我問了同樣的事情in the Highcharts forum並得到了該解決方案從@帕維爾 - FUS的答覆:

var chartExtraMargin = 30; 

Highcharts.wrap(Highcharts.Axis.prototype, 'setAxisSize', function (p) { 
    p.call(this); 
    if (this.isXAxis) { 
    this.left += chartExtraMargin; 
    this.width -= chartExtraMargin; 

    this.len = Math.max(this.horiz ? this.width : this.height, 0); 
    this.pos = this.horiz ? this.left : this.top; 
    } 
}); 

但是,添加這使得工具提示出現在錯誤的位置。這是固定通過重寫Tooltip.prototype.getAnchor()方法和x座標添加額外保證金:

Highcharts.wrap(Highcharts.Tooltip.prototype, 'getAnchor', function(p, points, mouseEvent) { 
    var anchor = p.call(this, points, mouseEvent); 
    anchor[0] += chartExtraMargin; 
    return anchor; 
}); 
0

您可以設置min值爲-0.49。

http://jsfiddle.net/o4abatfo/2/

+0

請你看看這個:http://jsfiddle.net/o4abatfo/3/和內容:HTTP: //jsfiddle.net/o4abatfo/4/你能告訴我們爲什麼當我們在另一個'xAxis'中使用'minPadding'時,它的工作原理是什麼,如果在同一個'xAxis'中使用,它不會呢? – 2015-01-21 13:02:25

+0

@ SebastianBochan謝謝,但它似乎只適用於某些數據。如果圖表很窄並且y軸上的數字很大,則會發生相同的重疊。 – 2015-01-21 13:35:20

+0

此外,如果您在x軸上使用數字值而不是類別,則此方法根本不起作用。 – 2015-01-21 13:40:16

0

一種可能的解決方案:

保持在外面的標籤,並應用plotBackgroundColor作爲圖表backgroundColor

這意味着圖例也會被封裝在背景顏色中,但是,它又是一個選項。

例子: