I have created a dataset (of type DefaultCategoryDataSet
) for creating a bar chart (say barChart) with the JFreeChart
api: ChartFactory.createBarChart(...)
. Then I created a ChartPanel
- CP, and added the barChart to it. Finally I added the CP to the JPanel
. This JPanel
is binded to a JTabbedPane
's tab for showing the panel containing my bar chart. Everything runs fine except that the bar chart is not fully fitting into the available panel space. Some parts of the bar chart (left and right) are being cut and not shown. Is there any way of accomodating the entire bar chart. Please note that it's not the data due to which it is not shown entirely (even with fewer data, the problem persists). Also, I am able to display a pie-chart in my tab without any issues.
Asked
Active
Viewed 290 times
0

Andrew Thompson
- 168,117
- 40
- 217
- 433

user1639485
- 808
- 3
- 14
- 26
-
1ok. setting the preferred size (dimension.width) of the chart panel did the trick for me. – user1639485 Sep 01 '12 at 13:13
-
1You can also override the `ChartPanel` method `getPreferredSize()`. You are allowed to [answer your own question](http://meta.stackexchange.com/q/17463/163188). – trashgod Sep 01 '12 at 21:36