getting defaultCategoryDataset graph to resize

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
hugo
Posts: 7
Joined: Wed Jun 23, 2004 12:09 pm

getting defaultCategoryDataset graph to resize

Post by hugo » Thu Sep 30, 2004 9:16 pm

Here is my code

Code: Select all

result = new DefaultCategoryDataset();			
JFreeChart chart = createChart(result); 
barGraphPanel.setLayout(new BorderLayout()); //ChartPanel
barGraphPanel = new ChartPanel(chart);
graphPicture.setLayout(new BorderLayout()); //JPanel
graphPicture.add(barGraphPanel,BorderLayout.CENTER);
[\code]
I want the bar graph to resize with the panel that it is in (itself in a splitpane). Im not surprised that this doesnt work seeing that I set the layout of barGraphPanel before I instantiate  it. I also tried the following without success.
[code]
result = new DefaultCategoryDataset();			
JFreeChart chart = createChart(result); 
ChartPanel barGraphPanel = new ChartPanel();
barGraphPanel.setLayout(new BorderLayout()); //ChartPanel
barGraphPanel.setChart(chart);
graphPicture.setLayout(new BorderLayout()); //JPanel
graphPicture.add(barGraphPanel,BorderLayout.CENTER);
[\code]
any help most appreciated. I bought the Developer Guide recently and havent found it that useful for my problems so far so havent checked it yet. Gonna do that next.

hugo
Posts: 7
Joined: Wed Jun 23, 2004 12:09 pm

Post by hugo » Thu Sep 30, 2004 9:32 pm

ok i was talking crap a minute ago. ill try again. i have a ChartPanel in JPanel in a vertical JSplitPane which is in horizontal JSplitPane. The JPanel is set to BorderLayout and I add the ChartPanel to its CENTER region. When I move the vertical JSplitPane the Graphs height shrinks. When i move the horizontal JSplitPane the width does not change. In fact I get the same behaviour with BoxLayout. here is my code again.

Code: Select all

JFreeChart chart = createChart(result);
barGraphPanel = new ChartPanel(chart);
graphPicture.setLayout(new BorderLayout());			graphPicture.add(barGraphPanel,BorderLayout.CENTER);
PictureStatsPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, graphPicture, statsPanel);
...
this.add(PictureStatsPane);//this is JPanel called 'left'
..
hortizSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,left,right);
Thanks in advance.

Locked