How to produce chart picture in memory instead of save it

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
xtsu
Posts: 4
Joined: Sun Aug 12, 2007 4:09 am

How to produce chart picture in memory instead of save it

Post by xtsu » Mon Mar 09, 2009 9:38 pm

Hi, All
I have a question about how to produce chart picture as a java object in memory instead of saving it in harddisk.
Would you give a short example?

Thanks a lot!

reboot
Posts: 46
Joined: Wed Jan 07, 2009 5:35 pm

Re: How to produce chart picture in memory instead of save it

Post by reboot » Mon Mar 09, 2009 11:51 pm

If u look at the Jfrechart API, at the ChartUtilities class. U can use write mothods passing into the write mothod a new OutPutStream() and taking back from it the byte[]. After that u can do what u want....

i suppose

MitchBuell
Posts: 47
Joined: Thu Dec 11, 2008 7:59 pm

Re: How to produce chart picture in memory instead of save it

Post by MitchBuell » Tue Mar 10, 2009 2:23 pm

The JFreeChart object has a few methods for creating a BufferedImage of itself. Here's the simplest method:

Code: Select all

JFreeChart chart = createMyChart();
BufferedImage image = chart.createBufferedImage(int width, int height)

Locked