I created a jfrechart as the first pic. After having zoomed it with mouse wheel, It showed as the second pic. How can I resize ChartPanel so that it can show all the zoomed chart?
I put the ChartPanel in a JScrollPane and updated its preferred size in its mouseWheelMoved event as follows. It did not work as I expected. It didn't show the whole chart and the font size of axises were also enlarged to unsuitable size.
public void mouseWheelMoved(MouseWheelEvent e) {
double factor = _chartPanel.getZoomInFactor();
Dimension dim = _chartPanel.getPreferredSize();
dim.width =(int)( dim.width*(1.0+factor)+1);
_chartPanel.setDomainZoomable(false);
_chartPanel.setPreferredSize(dim);;
_chartPanel.revalidate();
_chartPanel.setDomainZoomable(true);
}