It doesn't work as it should. Seems that there is no any difference between adding image in load event and in any other place when chart is completly rendered. If I don't use scheduleDeferred I get exception, because chart is null.
So, how to solve this problem? Or maybe there is any other way to export chart with custom image?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
See my explanation at https://sourceforge.net/p/gwt-highcharts/discussion/general/thread/d5aaf640/
If by "export chart" you mean "using a Web service to do the export", this means that the image you add is reachable from the server.
Moreover, if, as I believe, the idea is to run Highcharts on the server (on the current settings) to get the SVG (as opposed to send the current SVG to the server), then such custom drawing is lost...
I did a simple experiment: I went to Highcharts demo site; on the displayed chart, I used Firebug to do live edit on a label, changing it to something else. When I exported the chart, I got a rendering of the original one. Also notice that the interactive charts don't have an export button... This confirms that the chart is rendered from the chart parameters on the server side.
Last edit: Philippe Lhoste 2012-09-20
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
By "export chart" I mean using default highcharts exporting. To see the example read the topic which I refer in the first post (link).
I don't render charts on the server, they should be rendered in browser with a custom image (this part works fine), but the problem is that this custom image is not present in the exported image.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"I mean using default highcharts exporting"
Yes, and it is "using a Web service to do the export"...
Now, I found your topic in the Highcharts forum, and they give a solution to allow such custom rendering to be taken in account by Highcharts when exporting. Unfortunately, it requires to do the extra rendering on the load event of the chart, so it cannot be used to stuff added after rendering, I think, like custom drawing around a plot point.
And I don't know how to use this event in GWT Highcharts...
A quick look at the JavaDoc suggests one must create a ChartLoadEventHandler and do the rendering there.
(EDIT 1) Sorry, apparently that's what you try to do from the start... I don't know why it doesn't work since it works in the JsFiddle.
(EDIT 2) I tried the code you show, and indeed, if we use the native chart directly in the load event, GWT complains it is null. If we use, as you did, scheduleDeferred, it works (the image is displayed) but it isn't taken in account by Highcharts (for exporting purpose).
Last edit: Philippe Lhoste 2012-09-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This post is relative to discution in this topic link.
General idea that I need to export chart with custom image that I added.
So, I tried to do that Shawn suggested, but my custom image doesn't exist on exported chart image.
Here is my code:
chart.setLoadEventHandler(new ChartLoadEventHandler() {
});
native JavaScriptObject drawImage(JavaScriptObject chart, String imageUrl) /*-{
}-*/;
It doesn't work as it should. Seems that there is no any difference between adding image in load event and in any other place when chart is completly rendered. If I don't use scheduleDeferred I get exception, because chart is null.
So, how to solve this problem? Or maybe there is any other way to export chart with custom image?
Any ideas?
See my explanation at https://sourceforge.net/p/gwt-highcharts/discussion/general/thread/d5aaf640/
If by "export chart" you mean "using a Web service to do the export", this means that the image you add is reachable from the server.
Moreover, if, as I believe, the idea is to run Highcharts on the server (on the current settings) to get the SVG (as opposed to send the current SVG to the server), then such custom drawing is lost...
I did a simple experiment: I went to Highcharts demo site; on the displayed chart, I used Firebug to do live edit on a label, changing it to something else. When I exported the chart, I got a rendering of the original one. Also notice that the interactive charts don't have an export button... This confirms that the chart is rendered from the chart parameters on the server side.
Last edit: Philippe Lhoste 2012-09-20
By "export chart" I mean using default highcharts exporting. To see the example read the topic which I refer in the first post (link).
I don't render charts on the server, they should be rendered in browser with a custom image (this part works fine), but the problem is that this custom image is not present in the exported image.
"I mean using default highcharts exporting"
Yes, and it is "using a Web service to do the export"...
Now, I found your topic in the Highcharts forum, and they give a solution to allow such custom rendering to be taken in account by Highcharts when exporting. Unfortunately, it requires to do the extra rendering on the load event of the chart, so it cannot be used to stuff added after rendering, I think, like custom drawing around a plot point.
And I don't know how to use this event in GWT Highcharts...
A quick look at the JavaDoc suggests one must create a ChartLoadEventHandler and do the rendering there.
(EDIT 1) Sorry, apparently that's what you try to do from the start... I don't know why it doesn't work since it works in the JsFiddle.
(EDIT 2) I tried the code you show, and indeed, if we use the native chart directly in the load event, GWT complains it is null. If we use, as you did, scheduleDeferred, it works (the image is displayed) but it isn't taken in account by Highcharts (for exporting purpose).
Last edit: Philippe Lhoste 2012-09-24