使用塞巴斯蒂安提供的方向,我能夠完全解決這個問題。
爲通過渲染器添加按鈕文檔可以在這裏找到(無信息是在highcharts官方的API不幸):http://forum.highcharts.com/viewtopic.php?f=9&t=15416
這裏是重要的部分:
/**
* Create a button with preset states
* @param {String} text
* @param {Number} x
* @param {Number} y
* @param {Function} callback
* @param {Object} normalState
* @param {Object} hoverState
* @param {Object} pressedState
*/
button: function (text, x, y, callback, normalState, hoverState, pressedState) {}
這裏是我使用的代碼:
hChart是highcharts主對象。
hChart.drillupCustomButton = hChart.renderer.button(
'DRILL BACK UP',
100,
7,
function(){
//run whatever code you want here for when button is clicked
//This next line of code is how you remove the button (I chose to remove the button when the button is clicked)
$(hChart.drillupCustomButton.element).remove();
//You could also remove it via the id like this
$('#drillupCustomButtonID').remove();
},
null,
null,
null
)
.attr({
id: 'drillupCustomButtonID'
})
.add();
你可以通過渲染器添加按鈕和函數http://stackoverflow.com/questions/15472330/highcharts-replace-custom-button-image-on-hover –