I need to create a custom Exporting button and have it fire a method for exporting the data that backs my chart in Excel format.
I've figured out how to get the button positioned on the chart and formatted the way I want, but for the life of me I cannot figure out how to make the 'onclick' code work.
When I click the button I get the following error:
Uncaught TypeError: undefined is not a function
I found a lot of references to pure Highcharts examples using the embedded Javascript like shown above. I've also tried defining a JSNI function in my GWT Java client code and referencing it in the .SetOption onclick but that doesn't work either.
Does anybody know what I'm doing wrong?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't believe GWT Highcharts has built-in wrapper methods available for custom button event callbacks (not sure if that "exporting.buttons.customButton" is even a documented feature of Highcharts yet?). So, to support this you probably would need to resort to JSNI. You can take a look at the BaseChart.nativeRenderChart() method for an idea of how the Javascript to Java callbacks are wired up for events.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I need to create a custom Exporting button and have it fire a method for exporting the data that backs my chart in Excel format.
I've figured out how to get the button positioned on the chart and formatted the way I want, but for the life of me I cannot figure out how to make the 'onclick' code work.
Here is my code snippet that defines the button:
When I click the button I get the following error:
I found a lot of references to pure Highcharts examples using the embedded Javascript like shown above. I've also tried defining a JSNI function in my GWT Java client code and referencing it in the .SetOption onclick but that doesn't work either.
Does anybody know what I'm doing wrong?
I don't believe GWT Highcharts has built-in wrapper methods available for custom button event callbacks (not sure if that "exporting.buttons.customButton" is even a documented feature of Highcharts yet?). So, to support this you probably would need to resort to JSNI. You can take a look at the BaseChart.nativeRenderChart() method for an idea of how the Javascript to Java callbacks are wired up for events.
Thanks Shawn. Yes, JSNI did the trick, like this.
Javascript In my containing HTML file:
I moved the entire custom button definition into a JavaScriptObject:
And then called .setExporting like this: