controlling internal width and height of chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
harshanagesh
Posts: 12
Joined: Fri Jan 06, 2006 1:36 am

controlling internal width and height of chart

Post by harshanagesh » Mon Jun 19, 2006 10:57 am

Hi,

I am wondering what is the API to set the internal height and width of a chart. I am not sure if my terminology is right, but this is what I mean - The complete chart is the actual chart area plus the xaxis and yaxis title and tickmarks. I want to control the the height and width of just the chart area - the region containing the data points. I think this should be possible for any plot, but I am unable to find such an API. any pointers please ? In my case I am trying to plot a timeseries.

Thanks
Harsha

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 » Mon Jun 19, 2006 3:57 pm

JFreeChart does its layout from the outside in (that is, titles, legends and axes first) using any remaining space for the data area. It is not possible to set a fixed size for the data area.
David Gilbert
JFreeChart Project Leader

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

harshanagesh
Posts: 12
Joined: Fri Jan 06, 2006 1:36 am

controlling internal width and height of chart

Post by harshanagesh » Mon Jun 19, 2006 4:43 pm

In such a case if we have multiple charts, one below the other how do we allign the data areas ?
For example, if we are viewing some data for 6 months in two separate graphs it would be ideal to allign their data area to be able to compare and analyze

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 » Mon Jun 19, 2006 5:07 pm

It's difficult to do, given the way JFreeChart dynamically lays out the chart areas. There is a hack you can try...the setFixedDimension() method in the Axis class. If you have two charts stacked on top of one another, you can call setFixedDimension() on the range axis for both charts to make their axes have the same width (which very often results in the data areas having the same size). The difficulty is determining a suitable width so that the axis labels are not clipped, but where there isn't a lot of white space either. The CombinedDomainXYPlot class uses this approach...it sets the fixed dimension to the width of the widest axis (with a fair amount of ugly code to determine this).
David Gilbert
JFreeChart Project Leader

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

Locked