Label generation bug. (multiple amount of same labels)

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
meehaw
Posts: 10
Joined: Wed Aug 08, 2007 9:16 am

Label generation bug. (multiple amount of same labels)

Post by meehaw » Fri Aug 24, 2007 12:10 pm

Hello everyone.

I'm creating an web application based on jfreechart, jsp, servlets and ajax.

And sometimes i'm receiving such chart with multiplce labels (i removed any label generator- I'm using default one)

Image

For sure You would like to see a piece of code, so i will give some pieces which should be enough to see the problem.

Everything is based in servlets. Servlet is creating an image and writes it to a stream (like in examples delivered by JFreeCHart).

Code: Select all

	public void drawToStream(OutputStream out)
	{
		//freeGauge is PieChart3D object created earlier.
		try
		{
			ChartUtilities.writeChartAsPNG(out , freeGauge, 500, 500);
				
		}
		catch (IOException ioe)
		{
			//some exception handling
		}
	}

When i was using only this method everything was working fine (every 30 second i updated the image and it was displayed correctly).

Then i added an image map creation:

Code: Select all

	public String getAreaMapString()
	{
		plot.setToolTipGenerator( new PieToolTipGenerator()
        {
     	   public String generateToolTip(PieDataset data, Comparable key)
     	   {

     		   return "'Value: "+ data.getValue(key).toString() +"'," +"OPACITY," + 90 + ",TITLE," + "'"+ key.toString() + "'";
     	   }
	   
        });

		ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());

        freeGauge.createBufferedImage(500, 500, info); 
        //MyToolTipTagFragmentGenerator() just override a generateToolTipFragment method.
		String imageMap = ChartUtilities.getImageMap("Map", info ,new MyToolTipTagFragmentGenerator(),new StandardURLTagFragmentGenerator());
		return imageMap;

	}
So now when I draw and image, then i get the image map everything is fine, but when i try to draw image again (after creating a map) i get such bugged image.

So:
1. Creating an image - OK.
2. Creating an image map - OK.
3. Creating an image again - Bug.


Can You give me any clues what might be causing this problem?

Thx in advance!

meehaw
Posts: 10
Joined: Wed Aug 08, 2007 9:16 am

Post by meehaw » Thu Sep 27, 2007 2:28 pm

Well, noone can help me xD


However I've found another method to generate this bug :)


I used servlet which write an image (png) to output stream (same servlet as in developers guide).

I used a bit of javascript in my jsp page:

Code: Select all

objImage = new Image();
objImage.onLoad=imagesLoaded();
objImage .src="HERE LNK TO SERVLET"

In imagesLoaded() function I get the img element and changing its source to "HERE LNK TO SERVLET" which is preloaded by js.

Result is same as in screenshot.

hf,
michal

Locked