开发者

How can I have a jfreechart ChartPanel automatically enlarge itself?

I have a Swing JFrame with a ChartPanel as its only component. When I resize the frame, the chart panel gets stretched out开发者_StackOverflow as if it were an image. For example, if I shrink it vertically, all of the character get compressed.

Is it possible to have the ChartPanel redraw itself on resize events so that it shows more detail on the graph, instead of getting stretched as a static image?


You have to change a few options when constructing your ChartPanel :

 * @param minimumDrawWidth  the minimum drawing width.
 * @param minimumDrawHeight  the minimum drawing height.
 * @param maximumDrawWidth  the maximum drawing width.
 * @param maximumDrawHeight  the maximum drawing height.


I had the same issue. I now realize that ADR gave the solution: you have to set the minimum and maximum drawing width and height, for example:

chartPanel.setMinimumDrawWidth( 0 );
chartPanel.setMinimumDrawHeight( 0 );
chartPanel.setMaximumDrawWidth( 1920 );
chartPanel.setMaximumDrawHeight( 1200 );


ChartPanel has methods to control zoom, as shown in this example. I don't see characters getting compressed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜