Empty image Map when using ChartUtilities.saveChartAsPNG

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
philanthrophic
Posts: 9
Joined: Wed Mar 26, 2008 6:20 am

Empty image Map when using ChartUtilities.saveChartAsPNG

Post by philanthrophic » Tue Apr 08, 2008 6:51 am

Hi all,

I have issue here.

I have created a JFreechart object. Now i want to save the chart as .png file and then want to have the corresponding image map from it. Like this:

ChartUtilities.saveChartAsPNG(new File("temp/reports/chart1"+number+".png"), chart, 800,600);
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
ChartUtilities.writeImageMap(new PrintWriter(System.out), "temp/reports/chart1"+number+".png", info, false);

Once i run this program i get the .png in the dirtectory specified but see a empty image map like this
<map id="temp/reports/chart119.png" name="temp/reports/chart119.png">
</map>

What am i doing wrong here??

Although when i use servletUtilities
filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info, session);
ChartUtilities.writeImageMap(pw, filename, info);

I get the desired output.

Can please someone help me with this?

Thank you

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Post by matinh » Tue Apr 08, 2008 8:38 am

What kind of chart are you using?
There was just a report about a bug with image maps and block graphs: http://www.jfree.org/phpBB2/viewtopic.php?t=24269

hth,
- martin

philanthrophic
Posts: 9
Joined: Wed Mar 26, 2008 6:20 am

Post by philanthrophic » Tue Apr 08, 2008 10:12 am

I am using simple stacked Area chart.
I got it working by

ChartRenderingInfo info = new ChartRenderingInfo(
new StandardEntityCollection());
ChartRenderingInfo info1 = new ChartRenderingInfo(
new StandardEntityCollection());
File file1 = new File("ImageMapDemo7.png");
ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
// write an HTML page incorporating the image with an image map
File file2 = new File("ImageMapDemo7.html");
OutputStream out = new BufferedOutputStream(
new FileOutputStream(file2));
System.err.println(ImageMapUtilities.getImageMap("chart", info));


Any other way in whcih i donot have to call so many io methods.

Locked