The patch allows to set a fixed size for the data area. Based on this size, a preferred size for the plot and for the chart are calculated. These "preferred sizes" are recalculated if required. Based on the preferred chart area size, a retangle can be constructed and used as parameter in the JFreeChart.draw(...) methods to get a chart with a data area of the desired, constant size.
Changes have been made to JFreeChart, Plot, XYPlot and ChartPanel. The ChartPanel has a flag to indicate whether the preferred chart size should be honored. If that is the case, changing the size of the chart panel has no effect on the chart itself.
If the ChartPanel is placed in a JScrollPane, things work as expected, i.e. the scroll pane honors the increasing chart panel size if axes/titles are added. Placing the ChartPanel in the content pane of a JFrame is somewhat "unstable", and the JFrame is not always resized as needed.
The ZIP contains a demo program.
Log in to post a comment.