Maël Le Monnier
Maël Le Monnier

Reputation: 147

How make JFreeChart nicely resizable?

I wonder if it's possible to draw nicely some charts using JFreeChart & ChartPanel. When I increase window size I want the chart to fill-up the new space, using a GridBayLayout. But the text labels are streched also and becomes really ugly.

Here is the default size of a given charts: default jfreechart rendering

And here is what it looks like when I maximize the window: maximized jfreechart rendering ugly

As you can see, the text is badly streched. This is not the behavior of other swing components (like the JLabel of the top-text).

How can I configure my charts/plots to tell the plot to fill-up all new space, but keep legends, axis and any other elements fixed-size ?

Upvotes: 0

Views: 112

Answers (1)

Maël Le Monnier
Maël Le Monnier

Reputation: 147

As suggested here, the use of the full ChartPanel constructor, specifying much higher values for maximumDrawWidth and maximumDrawHeight parameters, fixed the rendering issue.

I used 2560x1440 instead of 1024x768 (since I'm using jfreechart library in old version). In the latest release, default values are now 2048x1536, and should also be sufficient excepted for full-screen graphs displayed on 4K+ screens.

Upvotes: 1

Related Questions