2013-04-21 81 views
0

我有一個圖表,其中plotBands調整大小,並且標籤必須更改。但是我無法弄清楚如何在圖表創建後更改標籤。創建後更改plotBand標籤[highcharts]

我曾嘗試:

改變chart.axis [0] .options.plotBands [0] .label.text,標誌着軸作爲isDirty和使用HTML標籤重繪圖表

和通過jQuery改變數值

我必須使用標籤格式化程序函數嗎?或者在API中錯過了什麼?

+0

我能做到這一點通過使用jQuery直接修改tspan.text()。然而,在Highcharts API中這樣做會很好。 – 2013-04-21 23:09:41

回答

0

您可以使用attr()函數,該函數允許更新plotBand標籤等圖形元素。例如:

http://jsfiddle.net/eaFdr/1/

$('#btn').click(function(){ 
     chart.xAxis[0].plotLinesAndBands[0].label.attr({ 
        text:'aaaa' 
       }); 
    }); 
1

我想改變「到/從」的plotbands的值,沒有發現ATTR方法,這工作雖然:

this.chart.yAxis[0].plotLinesAndBands[4].options.from = this.min;