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
Changing the chart height
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Changing the chart height
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.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.
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.
A JFreeChart doesn´t have a preferredSize, and you can´t restrict the chart/plot size or width to a limit......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.
....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.
Re: Changing the chart height
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
http://jeffastorey.blogspot.com
Re: Changing the chart height
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
Jeff Storey, Software Developer
http://jeffastorey.blogspot.com
http://jeffastorey.blogspot.com