In highcharts you can get the renderer (http://www.highcharts.com/ref/#renderer) of the chart and then display images or text on it. e.g. http://jsfiddle.net/senyahnoj/NfStH/1/
Is it possible to do it in GWT Highcharts?
Thanks for your help.
Regards
Nabeel Mukhtar
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can grab the native Highcharts JS instance via the GWT Highcharts "Chart.getNativeChart()" instance, and then from there you can use JSNI to operate against the native properties of the object as needed. Note that if you want to utilize the native instance before the chart is rendered you'll need to use deferred scheduling of the logic. Here's a working example:
private Chart chartRendererTest() {
final Chart chart = new Chart()
.setType(Series.Type.SPLINE)
.setChartTitleText("Lawn Tunnels");
Series series = chart.createSeries()
.setName("Moles per Yard")
.setPoints(new Number[]{163, 203, 276, 408, 547, 729, 628});
chart.addSeries(series);
Scheduler.get().scheduleDeferred(new Command() {
public void execute() {
renderText(chart.getNativeChart(), "Hello there", 10, 10);
}
});
return chart;
}
private static native JavaScriptObject renderText(JavaScriptObject chart, String text, int plotX, int plotY) /*-{
return chart.renderer.text(text, plotX, plotY).add();
}-*/;
Let us know if that meets your needs, or if you're looking for something different.
Last edit: Shawn Quinn 2012-07-05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, thanks for this advice, but if I try exporting chart as image I don't see the pictures I added with help of chart.renderer.image()
Is there any possibility to export chart with images you added?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm not quite sure if there's anyway to get Highcharts to add additional content to the SVG routine that is posted to the Batik converter on export, but your best bet would be checking on the main Highcharts forums as someone there will likely know better.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Seems like you can mimic that JS using similar code as noted above in this thread to grab the native renderer and add the image information. Note that GWT Highcharts also supports a ChartLoadEventHandler (which utilizes the Highcharts "load" event) if you need it. In this case, the "scheduleDeferred" approach used above may be easier to use to access the native chart instance. I haven't tried to add custom details the renderer before on my own though, so if you run into trouble - just let us know.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In highcharts you can get the renderer (http://www.highcharts.com/ref/#renderer) of the chart and then display images or text on it. e.g.
http://jsfiddle.net/senyahnoj/NfStH/1/
Is it possible to do it in GWT Highcharts?
Thanks for your help.
Regards
Nabeel Mukhtar
You can grab the native Highcharts JS instance via the GWT Highcharts "Chart.getNativeChart()" instance, and then from there you can use JSNI to operate against the native properties of the object as needed. Note that if you want to utilize the native instance before the chart is rendered you'll need to use deferred scheduling of the logic. Here's a working example:
Let us know if that meets your needs, or if you're looking for something different.
Last edit: Shawn Quinn 2012-07-05
Hello, thanks for this advice, but if I try exporting chart as image I don't see the pictures I added with help of
chart.renderer.image()
Is there any possibility to export chart with images you added?
I'm not quite sure if there's anyway to get Highcharts to add additional content to the SVG routine that is posted to the Batik converter on export, but your best bet would be checking on the main Highcharts forums as someone there will likely know better.
Here is my post on Highcharts forum. There is an answer with code written on JavaScript.
How can I do the same with GWT Highcharts?
Thanks!
Any ideas about how to do this?
Seems like you can mimic that JS using similar code as noted above in this thread to grab the native renderer and add the image information. Note that GWT Highcharts also supports a ChartLoadEventHandler (which utilizes the Highcharts "load" event) if you need it. In this case, the "scheduleDeferred" approach used above may be easier to use to access the native chart instance. I haven't tried to add custom details the renderer before on my own though, so if you run into trouble - just let us know.
Thanks a lot. That's exactly what I needed.