How to aviod axis label and legend scaling

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
michael.kuettner
Posts: 7
Joined: Thu Jul 17, 2008 2:52 pm

How to aviod axis label and legend scaling

Post by michael.kuettner » Tue Nov 11, 2014 4:55 pm

For differnent sizes of the charts panel axis label and legend text always scales to different sizes.
At very large/wide screens this looks a little bit strange.

Is it possible to aviod these scaling? Is it possible to set a fixed size of a fixed area for the axis label?

The following two screenshots show the same chart at different window/frame sizes:
Image
Image

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: How to aviod axis label and legend scaling

Post by John Matthews » Fri Nov 14, 2014 6:12 pm

Create a ChartPanel with your chart, and add it to a JPanel having a layout that respects the panel's preferred size, e.g. FlowLayout, the default layout for JPanel. You can adjust the preferred size as shown here.

michael.kuettner
Posts: 7
Joined: Thu Jul 17, 2008 2:52 pm

Re: How to aviod axis label and legend scaling

Post by michael.kuettner » Sun Nov 16, 2014 12:14 pm

I don't want the whole panel to have a fixed size. The ChartPanel should scale into available space if the user resizes the frame. That's ok.
But i would like the text next to axis and the text in the legend to keep a fixed size (e.g. 12pt by default)!

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: How to aviod axis label and legend scaling

Post by John Matthews » Mon Nov 17, 2014 3:38 am

GridLayout works well for that.

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

Re: How to aviod axis label and legend scaling

Post by paradoxoff » Mon Nov 17, 2014 9:55 am

Call ChartPanel.setMinimumDrawWidth/Height with small value and ChartPanel.setMaximumDrawWidth/Height with large values than exceed the screen size of your monitor. Then, the ChartPanel will be scaled without being distorted.

michael.kuettner
Posts: 7
Joined: Thu Jul 17, 2008 2:52 pm

Re: How to aviod axis label and legend scaling

Post by michael.kuettner » Thu Nov 20, 2014 10:10 am

The following lines solved this issue:

Code: Select all

    chartpanel.setMinimumDrawHeight(50);
    chartpanel.setMaximumDrawHeight(5000);

    chartpanel.setMinimumDrawWidth(50);
    chartpanel.setMaximumDrawWidth(5000);
Now the ChartPanel scales without distortion.
Thanks!

Locked