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
How can I put scrollbar on ChartPanel & space between ta
-
- Posts: 2
- Joined: Thu Jan 11, 2007 5:47 pm
- Location: Brasil
-
- Posts: 2
- Joined: Thu Jan 11, 2007 5:47 pm
- Location: Brasil
Solution !!!
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
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
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.
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
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?
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 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);
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?