background not applied on first request

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Freecharter
Posts: 4
Joined: Thu Mar 13, 2008 3:12 pm

background not applied on first request

Post by Freecharter » Tue Mar 18, 2008 6:04 pm

The background I specify is not applied the first time the chart is rendered It is not a caching issue. When I refresh the page it does get set.

Any idea why?

Below is the code

Code: Select all

        Image image = null;
        try {
            URL imageUrl = new ClassPathResource("some_chart_bg.png").getURL();
            image = Toolkit.getDefaultToolkit().getImage(imageUrl);
        } catch (IOException e) {
           logger.error("could not get image for chart bg", e);
        }

        if(image!=null){
            plot.setBackgroundImage(image);
            plot.setBackgroundAlpha(0.2F);
        }else{
            logger.debug("Image was null");
        }

Locked