How can I put scrollbar on ChartPanel & space between ta

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
ricardo.celso
Posts: 2
Joined: Thu Jan 11, 2007 5:47 pm
Location: Brasil

How can I put scrollbar on ChartPanel & space between ta

Post by ricardo.celso » Thu Jan 11, 2007 6:08 pm

Hi folks,

How can I put scrollbar on ChartPanel and space between tasks?

I'm developing a Gantt Chart, but it has many tasks and the labels overload each other, for example the previous task's label overloads the next one.

I've created my own gantt renderer to put two labels surround the bar, one above and another one bellow.

Does anyone have a solution to this problem ?

Thanks,
Celso

ricardo.celso
Posts: 2
Joined: Thu Jan 11, 2007 5:47 pm
Location: Brasil

Solution !!!

Post by ricardo.celso » Fri Jan 12, 2007 2:55 pm

Hi folks,

I found a solution to those problems.

I added a ChartPanel within a ScrollPane, in the ScrollPane I defined preferred size to display the scroll bar when the chart is out of the limit of the ScrollPane.

And to adjust the size of the Chart and the space between tasks, I put the same values at the constructor of ChartPanel(..., width, height, minDrawWidth, minDrawHeight, maxDrawWidth, maxDrawHeight, ...).

The height value uses a number of tasks multiplied by a constant value(example 80).

I hope my solution has been useful.

Thanks,
Celso

MNusinov
Posts: 15
Joined: Tue Jul 03, 2007 7:41 pm

Post by MNusinov » Mon Jul 09, 2007 10:06 pm

Alright, I'm trying to use this workaround but it doesn't seem to like dynamically adjusting itself. What you have described works upon initial creation but I'm adding new tasks dynamically.

Code: Select all

if(count > 40) {
		chartPanel.setRangeZoomable(true);
		chartPanel.setMinimumSize(new Dimension(chartPanel.getWidth(),count * 15));
		chartPanel.setMaximumSize(new Dimension(chartPanel.getWidth(),count * 15));
		chartPanel.setMaximumDrawHeight(count*15);
		chartPanel.setMinimumDrawHeight(count*15);
}
I've tried variations on setting the above sizes with no luck (the chart just scales itself smaller intsead of resizing).

I've even tried

Code: Select all

	chartPanel = new ChartPanel(chart, 980, count * 15, 980, count * 15, 980, count * 15, true, false, true, true, true, true);
	pnlScroll = new JScrollPane(chartPanel);
in the if statement to manually construct a new Chart every time, but that seems to do the same as the above setting of the height.

I don't understand why if I initially create it larger it will scroll but after that it seems to want to stay at that initial size and just scale itself whenever I try and make it bigger.

Any thoughts?

Locked