Hi everybody,
I am new in JFreechart and currently I am facing the following problem:
Usually when drawing a gantt chart, all the tasks and subtasks are scaled to fit to the panel so that if there is only one task, it will take the whole panel place.
Is there a possibity to set a fixed width and height for tasks, so that (for example) resizing the window doesn't change the height/width used to draw tasks ? How can I do it ?
Any help will be appreciated.
Thans in advance.
Lionel
Gantt Chart: How to display task with a fixed width/height ?
I was in a similar situation. I needed a fixed bar width on a Gantt chart. I went ahead and extended GanttRenderer with my own GantBarRenderer class. I overrode the calculateBarWidth() method and I was able to accomplish what I needed. I'm sure you could do something similar that would suit your needs.
Good idea
Thanks for your answer Demati. Now I know how to do to set the bar width myself.
The drawed bars are now centered in the display.
Do you know how I can tell the rendere to draw the bars beginning from the top of the screen (without centering them) ? many thanks in advance four your hints.
The drawed bars are now centered in the display.
Do you know how I can tell the rendere to draw the bars beginning from the top of the screen (without centering them) ? many thanks in advance four your hints.
I don't know if I quite follow what you mean by "from the top of the screen", but you can control where on the range axis the bars are drawn, by setting the correct range values on the axis.
For example you could do the following:
This will give you a 30 second window (you can replace the number with something else for a larger or smaller value) view of your schedule, and will draw the first bar at the origin of the chart. Time in this case is the starting value of the dataset. It should help with scaling issues, but might not be exactly what you are looking for.
-George
For example you could do the following:
Code: Select all
CategoryPlot plot = chart.getCategoryPlot();
ValueAxis axis = plot.getRangeAxis();
axis.setRangeWithMargins(time, time+30000.0);
-George
Thanks again for your reply and sorry for my poor english 
I was actually searching for a simple way to set a fixed value for the category rows (category size) so that they are not calculated depending of the available screen area.
The only way I found is to write a CustomCategoryAxis class which and overwrite the calculateCategorySize method.
Have a nice evening

I was actually searching for a simple way to set a fixed value for the category rows (category size) so that they are not calculated depending of the available screen area.
The only way I found is to write a CustomCategoryAxis class which and overwrite the calculateCategorySize method.
Have a nice evening