chart dimension settings versus pixels

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
losganjas
Posts: 5
Joined: Thu May 06, 2004 2:31 pm

chart dimension settings versus pixels

Post by losganjas » Mon Jun 21, 2004 2:09 pm

hello folks !

difficult to find a general topic description for my problem, which is rather a question...

there are several ways to set the bar width for example, or the chartPanel max draw height/width, or the spacing between categorys etc

lets take for example the chart panel:
chartPanel.setMaximumDrawHeight(int i);
chartPanel.setMaximumDrawWidth(int i);

is there any correlation between the integer passed to this method and the size in pixels ?

The general context of this question is the following:
I use applets to show the graphs in an html page, and below I represent the values in a table(<table> tag etc).
now, it would be nice if the corresponding values for a category in the table are exactly below the corresponding bar in the applet...
I can define the width in pixels for the cells in the table, but how can I integrate this knowledge into a jfreechart, in order to fix the dimension of the chart correctly so that table and chart go "hand in hand" ?

if anyone can give me some hint on this issues...I would greatly appreciate !

MERCI and lets go on charting ! ;-)

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 09, 2004 11:40 am

The chart size is determined by the size of the ChartPanel, which is controlled by the layout manager you are using - so look at your Swing/AWT code to get the ChartPanel to the pixel size you want.

The setMinimumDrawHeight()/setMaximumDrawHeight() and setMinimumDrawWidth()/setMaximumDrawWidth() methods do something different. They're intended for cases where the ChartPanel is either very small or very large, which causes problems for JFreeChart's own layout algorithms.

When the ChartPanel is very small, the charts look better if they are drawn at a larger size first, then scaled down (using a scaling transform in the Graphics2D) to fit the small panel. This scaling kicks in for charts smaller than 300 x 200 (but you can change the threshold using the setMinimumDrawWidth() and setMinimumDrawHeight() methods.

At the other end of the scale, when the ChartPanel is very large, the reverse happens. The chart is drawn at a smaller size (800 x 600 is the default) then scaled up to fit the larger panel. Some people like this effect, some don't - again you can change the threshold using the setMaximumDrawHeight() and setMaximumDrawWidth() methods.
David Gilbert
JFreeChart Project Leader

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

Locked