chart size params

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
june
Posts: 7
Joined: Tue Jul 08, 2003 3:31 pm

chart size params

Post by june » Thu Jul 10, 2003 3:46 pm

I use writeChartAsJPEG(java.io.OutputStream out,
JFreeChart chart,
int width,
int height)
to write the chart onto a output stream.

I wonder what the int width, and height stand for, do they define the size of the image of the chart, and are they in pixels?

thanks

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Jul 10, 2003 4:55 pm

If you follow through the source code, you'll see that the 'height' and 'width' are ultimately used in this method (belonging to the JFreeChart class):

Code: Select all

public BufferedImage createBufferedImage(int width, int height, ChartRenderingInfo info) {

        BufferedImage image = new BufferedImage(width , height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        draw(g2, new Rectangle2D.Double(0, 0, width, height), info);
        g2.dispose();
        return image;

    }
So it controls the width and height of the image.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

june
Posts: 7
Joined: Tue Jul 08, 2003 3:31 pm

Post by june » Fri Jul 11, 2003 9:51 am

Thanks.

But I still don't know whether the height and width are pixels or not.

I use other tools to draw a same chart with same height and width, I found that the chart drawn with JFreeChart is wider than the one drawn with ChartDirector, a chart api compatible with asp.

thank you.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Fri Jul 11, 2003 10:12 am

What values did you use for the width and height, and what is the size of the image (in pixels) generated by JFreeChart?
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

june
Posts: 7
Joined: Tue Jul 08, 2003 3:31 pm

Post by june » Fri Jul 11, 2003 11:43 am

I am convinced that the width and height are pixels.
The reason that I thought it is different from the chart drawn with ChartDirector is that I compared the JFreeChart image with a image constrained inside a html td tag.

But do you know how to set a border around the whole chart image?

Thank you.

Locked