Changing the chart height

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
jas511
Posts: 6
Joined: Tue Sep 01, 2009 7:02 pm
antibot: No, of course not.

Changing the chart height

Post by jas511 » Tue Sep 01, 2009 7:04 pm

Hi,

I am trying to restrict my chart to have a maximum height and I've tried that using the setMaximumDrawHeight method. That does restrict the height, but because my chart is very wide, the scaling causes the text labels and axes to be gigantic. Basically I only want the plot height to be Y pixels but I'd like the scaling to stay in tact as if the chart was being displayed at its preferred size.

Is that possible?

thanks,
Jeff

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

Re: Changing the chart height

Post by paradoxoff » Tue Sep 01, 2009 9:47 pm

jas511 wrote: I am trying to restrict my chart to have a maximum height and I've tried that using the setMaximumDrawHeight method. That does restrict the height, but because my chart is very wide, the scaling causes the text labels and axes to be gigantic.
Well it does not restrict the chart height in pixel, not will it restrict the size of the ChartPanel. Even if you set a small value for the maximumDrawHeight, you will still be able to bring the ChartPanel to full screen.
Though the chart will be drawn in a Rectangle with a maximum height of maximumDrawHeight, the ChartPanel will scale up the chart to fill the entire space if there is more height available which can lead to large or "gigantic" fonts and symbols.
To avoid the scaling, you should set a large value for the maximumDrawWidth to make sure that the available space is used really drawing a large chart and not for scaling up a small chart.
jas511 wrote: Basically I only want the plot height to be Y pixels but I'd like the scaling to stay in tact as if the chart was being displayed at its preferred size.
A JFreeChart doesn´t have a preferredSize, and you can´t restrict the chart/plot size or width to a limit......
....unless you use the patch discussed here :).
Thanks for the opportunity to mention this patch once more. To me it has been really helpful, and it is good to see that other need definable plot and chart sizes as well w/o scaling.

jas511
Posts: 6
Joined: Tue Sep 01, 2009 7:02 pm
antibot: No, of course not.

Re: Changing the chart height

Post by jas511 » Tue Sep 01, 2009 10:01 pm

Thanks for pointing this post out (and your explanation). I'll be reading up on that patch and seeing if I can use it in my case (thought it looks like I can).
Jeff Storey, Software Developer
http://jeffastorey.blogspot.com

jas511
Posts: 6
Joined: Tue Sep 01, 2009 7:02 pm
antibot: No, of course not.

Re: Changing the chart height

Post by jas511 » Fri Sep 11, 2009 8:13 pm

I was able to handle this problem in a much different way. I put the ChartPanel in another panel, call it chartPanelContainer. I set that to have a preferred height of Y (which is the height i wanted to display the chart at). I added chartPanelContainer to another panel, call it outerContainer. I then used a layout in outerContainer such that chartPanelContainer was always set to its preferred height. I also set the minimum and maximum draw heights of the ChartPanel to Y, and now the chart is fixed with the height I desire.

Jeff
Jeff Storey, Software Developer
http://jeffastorey.blogspot.com

Locked