Of course support for standard events is one of the strengths of GWT Highcharts. But, unfortunately there currently isn't a way to bridge custom Highcharts events to GWT java methods. The reason the JSNI that you attempted doesn't work is because that is simply treated as a string, and therefore not compiled as JSNI during the GWT compile process. So, I think the only clear way to do what you're attempting here is to modify the BaseChart.java class, and in particular the nativeRenderChart() method to add the new callback for the custom event you're trying to support.
(I suppose it's potentially possible that there may be a way to do this without modifying BaseChart using Highcharts new "Chart.update()" JS method in conjunction with GWT Highcharts "Chart.getNativeChart()" method, and then some JSNI magic. But I'm not quite sure how you could setup a native JS function callback with a GWT JSON object.)
Any GWT gurus out there that can propose a way that we could setup arbitrary function callbacks between Highcharts JS custom events and GWT callback methods, even if it requires some JSNI goo?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
I'm using Moxie GWT Highcharts and I want to use Highcharts plugin "custom events" to get access to click events on x axis labels. http://www.highcharts.com/plugin-registry/single/15/Custom-Events
In their example they're doing:
The equivalent in GWT Highcharts would probably look something like:
I have declared the handleXAxisLabelClick function as advided on http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html#sharing
Is this indented to work? If yes, am I doing something wrong? Can I pass a String declaring a JS function like this to setOption()?
Best regards,
s
Any suggestions?
Of course support for standard events is one of the strengths of GWT Highcharts. But, unfortunately there currently isn't a way to bridge custom Highcharts events to GWT java methods. The reason the JSNI that you attempted doesn't work is because that is simply treated as a string, and therefore not compiled as JSNI during the GWT compile process. So, I think the only clear way to do what you're attempting here is to modify the BaseChart.java class, and in particular the nativeRenderChart() method to add the new callback for the custom event you're trying to support.
(I suppose it's potentially possible that there may be a way to do this without modifying BaseChart using Highcharts new "Chart.update()" JS method in conjunction with GWT Highcharts "Chart.getNativeChart()" method, and then some JSNI magic. But I'm not quite sure how you could setup a native JS function callback with a GWT JSON object.)
Any GWT gurus out there that can propose a way that we could setup arbitrary function callbacks between Highcharts JS custom events and GWT callback methods, even if it requires some JSNI goo?
I got it working like this: