Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
37
rated 0 times [  40] [ 3]  / answers: 1 / hits: 22616  / 10 Years ago, mon, march 10, 2014, 12:00:00

I need to add some custom buttons (with onclick events), without overwrite the exporting buttons value, 'cause I wanna include new buttons without lost the custom buttons previously defined in chart (my chart already has custom buttons defined), all this at runtime, in a Highcharts chart using this object:




$('container').highcharts()




Is this possible?


More From » jquery

 Answers
42

You can add custom buttons using the exporting object:



    exporting: {
buttons: {
customButton: {
text: 'Custom Button',
onclick: function () {
alert('You pressed the button!');
}
},
anotherButton: {
text: 'Another Button',
onclick: function () {
alert('You pressed another button!');
}
}
}
}


http://jsfiddle.net/NxK39/1/



EDIT:
He wanted to add buttons after config



    var chart = $('#container').highcharts();
normalState = new Object();
normalState.stroke_width = null;
normalState.stroke = null;
normalState.fill = null;
normalState.padding = null;
normalState.r = null;

hoverState = new Object();
hoverState = normalState;
hoverState.fill = 'red';

pressedState = new Object();
pressedState = normalState;

var custombutton = chart.renderer.button('button', 74, 10, function(){
alert('New Button Pressed');
},null,hoverState,pressedState).add();


new fiddle: http://jsfiddle.net/NxK39/2/
answer using technique from Highcharts: replace custom button image on hover


[#72064] Saturday, March 8, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
carterf

Total Points: 255
Total Questions: 93
Total Answers: 122

Location: Marshall Islands
Member since Wed, Jun 17, 2020
4 Years ago
;