0

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 ?

  • 2
    Among the suggestions [here](https://stackoverflow.com/a/10277372/230513), try `GridLayout`. If this is not a duplicate, please [edit] your question to include a [mre] that shows your revised approach. – trashgod Mar 24 '23 at 14:30
  • Thanks, The use of the full `ChartPanel` constructor by specifying much higher values for `maximumDrawWidth` and `maximumDrawHeight` fixed the rendering issue. – Maël Le Monnier Mar 29 '23 at 13:58
  • I used 2560x1440. I'm using jfreechart library in old version, and the default values was 1024x768. I see the latest version has default values of 2048x1536. – Maël Le Monnier Mar 29 '23 at 14:07

1 Answers1

1

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.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045