Hi,
Can anybody give me an example to save a created chart as an image file so that I can have it embedded into a pdf file through xslt parsing using FOP?
Would very much appreciate.
Joe Chen
How to save chart as image file?
Re: How to save chart as image file?
If you want to save it as an jpg file. Use the chartutilities class.Here is some sample code:
// create a chart...
JFreeChart chart = ChartFactory.createPieChart("Chart Name" , data, true);
// create and display a frame...
ChartUtilities util = new ChartUtilities();
String fileName = new String ("c://projects//TomcatJBoss//charts//" +"FileName" +".jpg");
try
{
util.saveChartAsJPEG(new File(fileName), chart, 685, 445);
}
catch(IOException e)
{
}
// create a chart...
JFreeChart chart = ChartFactory.createPieChart("Chart Name" , data, true);
// create and display a frame...
ChartUtilities util = new ChartUtilities();
String fileName = new String ("c://projects//TomcatJBoss//charts//" +"FileName" +".jpg");
try
{
util.saveChartAsJPEG(new File(fileName), chart, 685, 445);
}
catch(IOException e)
{
}
Re: How to save chart as image file?
Frank,
Thank you so much! It works just fine for me.
Joe
Thank you so much! It works just fine for me.
Joe