score:2

First, I would never create a function like S. If you find yourself creating function with arguments like arg1, arg2, arg3, arg4 then something is wrong with your design. Ignoring that for a second and answering your question.


Highcharts allows you to setup a click event handler for many different components on the plot. You set up these handlers in your plotOptions for that specific component. For instance, if you want to handle a click event on a scatter plot point, you set a handler like this:

   plotOptions: {
        series: {
            point: {
                events: {
                    click: function() {
                        // look at the variable this
                    }
                }
            }
        }
    },

Inside the function() the this variable is the item that was clicked on. In the case of a scatter plot point, it is the point object. In this function, you are free to call your s function passing whatever data you want to it queried from the this.

Next, if you are creating the close button as a highcharts context button, you would set a click handler on that component. For that handler the this is the chart object.

Using this approach you can create a click handler for every component you care about. From those handlers, you call you s function.


Related Query