1

I am trying to display 24 LineCharts on a window 4 rows and 6 columns as shown in the picture. The window size is 1368x912 px.

The problem I am facing is that I need to show 24 LineCharts on a smaller window than shown on the upper image, but the smallest size of a LineChart is 200x150 px (at least I can't make it smaller).

Is there any way to overwrite the LineChart class to enable it to make it smaller?

  • 1
    Yes, I've done that before with line charts to make [spark lines](https://en.wikipedia.org/wiki/Sparkline). I don't recall what I did though and no longer have the code. I think it required some code or custom CSS or both to remove axes and change styling. – jewelsea Jun 26 '23 at 06:41
  • 2
    Thank you, you've gave me just enough info to do it. I just had to remove padding from the charts using css. – Jaka Kovše Jun 26 '23 at 11:58
  • 1
    As you have working code at hand, please consider an [answer to your own question](http://meta.stackoverflow.com/q/17463/163188). Also consider [tag:jfreechart-fx] for thumbnails, examined [here](https://stackoverflow.com/q/40441186/230513). – trashgod Jun 26 '23 at 12:32

1 Answers1

2

After a bit of searching, I found the solution to be quite simple.

You need to overwrite the maxSize and minSize properties of the lineChart with the same size:

lineChart.setMaxSize(double, double);
lineChart.setMinSize(double, double);

If the minimum size is bigger than the maximum size, the minimum size will overrule.

You can also adjust padding of a chart using a css file, which can be imported like this:

lineChart.getStylesheet().add("path/to/stylesheet.css");

Reference for fx-css.