JFreeChart chart coloring problem

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
nemesi8s
Posts: 5
Joined: Mon Jun 28, 2010 3:16 pm
antibot: No, of course not.

JFreeChart chart coloring problem

Post by nemesi8s » Mon Jun 28, 2010 3:28 pm

Hi guys!

I have a web application, I must export my charts into pdf, that's why i chosed jfreechart.
I create my chart like this:

Code: Select all

public void piePaint(OutputStream out, Object data) throws IOException{
		JFreeChart chart = createPieChart(
				getModel().getPieData());
        if (data instanceof MediaData) {           
            BufferedImage img = chart.createBufferedImage(500, 350);
            ImageIO.write(img,"jpg",out);
        }
    }

private JFreeChart createPieChart(final PieDataset dataset) {
JFreeChart chart  = ChartFactory.createPieChart
                ("chartName", dataset, true, false, false);
            chart.getPlot().setForegroundAlpha(0.9f);
return chart;
}
The datas are set correctly, so i dont copy that code too...
I am showing on-the-fly the chart on html page

Code: Select all

<a4j:mediaOutput element="img" cacheable="false" session="false" createContent="#{statisticsController.piePaint}" value="#{mediaData}" mimeType="image/jpeg"/>
My mediaData class looks like this - i dont think its relevant, because with and without it the problem exists:

Code: Select all

Integer Width = 110;
    Integer Height = 50;
    Color Background = Color.white;
    Color DrawColor = new Color(0,0,0);
    Font font = new Font("Serif", Font.TRUETYPE_FONT, 30);
/** so on with setters and getters... */
And voila, my chart looks like this:
Image

No, your monitor isnt broken, its really red...
So what do you think about this?

Greetings, N

ps. my version: 1.0.12

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: JFreeChart chart coloring problem

Post by paradoxoff » Mon Jun 28, 2010 7:56 pm


nemesi8s
Posts: 5
Joined: Mon Jun 28, 2010 3:16 pm
antibot: No, of course not.

Re: JFreeChart chart coloring problem

Post by nemesi8s » Mon Jun 28, 2010 8:57 pm

Thanks!

However I just resolved the problem. Use ChartUtilities.writeChartAsJPEG for writing to outputStream.

Locked