-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
Does ZK Charts provide any method to get chart's image as file or stream? The scenario is when user clicks the "Export to excel" button, we need to attach this image to excel file automatically.
Thanks.
Hello PeterPYWu,
In the following url there is an example of how to create a BufferedImage from a chart:
http://books.zkoss.org/wiki/SmallTalks/2006/June/IntegratingJFreeCharttoZKFramework,Part_I
Code Sample:
JFreeChart chart = ChartFactory.createPieChart3D("Sample Pie Chart 3D", pieDataset,true,true,true);
PiePlot3D plot = (PiePlot3D) chart.getPlot();
plot.setForegroundAlpha(0.5f);
BufferedImage bi = chart.createBufferedImage(500, 300, BufferedImage.TRANSLUCENT , null);
byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
You could use this object in order to export it to a excel file as shown below:
http://www.mysamplecode.com/2012/06/apache-poi-excel-insert-image.html
Best Regards,
Darksu
Asked: 2014-09-10 12:36:06 +0800
Seen: 19 times
Last updated: Sep 20 '14