How to save charts?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Rajendra

How to save charts?

Post by Rajendra » Mon Jun 10, 2002 6:57 am

Hi,

I have sucessfully plotted the graphs using JFreeChart.

I would like to save the plotted graohs into files of type(GIF,JPEG,etc...anything like that)....

Can anyone give some handles on how to do this?


Thanks inadvance..

With Regards,
Rajendra.

benoit

Re: How to save charts?

Post by benoit » Mon Jun 10, 2002 12:36 pm

use the ChartUtilities classe and the method writeChartAs...

so you could save your chart in JPEG or PNG format.

Rajendra

Re: How to save charts?

Post by Rajendra » Mon Jun 10, 2002 2:33 pm

Thanks Benoit...

Other than JPEG and PNG , cann't i save the chart into formats like GIF,SVG,etc...

With Regards,
Rajendra.

Rajendra

Re: How to save charts?

Post by Rajendra » Tue Jun 11, 2002 9:52 am

I tried Chartutilities class to save the chart.

Have glance at the following piece of code.

ChartUtilities chartutil = new ChartUtilities();
try
{
chartutil.saveChartAsJPEG (graphfile1,chart,450,450);
}
catch(Exception e)
{
System.out.println("exception");
}

It got compiled & ran sucessfully. But the chart was not saved.

What might be the problem?

I have tried with a print statement in the "TRY". It msg was printed,that means it is entering into the TRY stamt....

can any one help me in figuring out what is the problem?


With Ragards,
Rajendra.

josh

Re: How to save charts?

Post by josh » Tue Jun 11, 2002 7:41 pm

since all the ChartUtilities methods are static, maybe try ChartUtilities.saveChartAsJPEG(file, chart, 450,450) ?

Locked