Reputation: 63
I try to draw some lines (paths) into a Highcharts-Chart. When exporting the chart, the lines should be a little different. Therefore I created a Highcharts-Function, which I call on »load« and »redraw«. I just need to pass one little argument when calling the function, but this doesn´t work. How can I pass the argument?
Here´s the relevant code detail:
Highcharts.linien = function (r) { //generating the lines with my r-argument }
...
chart: {
events: {
load: Highcharts.linien(0)
}
exporting: {
chartOptions: {
chart: {
events: {
load: Highcharts.linien(15)
}
}
}
And here´s a working jsFiddle without using the argument.
Besides: If anyone has a clue, how to destroy my svg-group (linienGruppe) on »redraw«, I would also be very grateful!
Upvotes: 0
Views: 1536
Reputation: 45079
There should be:
chart: {
events: {
load: function(){
Highcharts.linien.call(this, 0);
}
}
}
exporting: {
chartOptions: {
chart: {
events: {
load: function(){
Highcharts.linien.call(this, 15);
}
}
}
}
}
So, using call()
you can pass on this
object to your function.
And regarding destroying group, first store somewhere your group, so later you can destroy that object, like this:
if(this.linienGruppe) {
this.linienGruppe.destroy();
}
this.linienGruppe = linienGruppe;
And working demo: http://jsfiddle.net/t3ywb3gq/4/
Upvotes: 2
Reputation: 13482
Highcharts.linien(0)
& Highcharts.linien(15)
are both function executions/invocations and not handlers. A handler is a function itself. Since you want to pass a parameter, I suggest you create an inline anonymous function with one line that calls your created method with appropriate arguments like below;
chart: {
events: {
load: function(){
Highcharts.linien(0);
}
}
exporting: {
chartOptions: {
chart: {
events: {
load: function(){
Highcharts.linien(15);
}
}
}
}
Upvotes: 1