ContentWelcomeProducts Abeona Gaia Hephaistos JavaGantt Features News Documentation Programming domain objects About JavaGantt model Undo / Redo support Localization support Building a treetable Painting a chart Working with the time scale JavaGantt actions License Download Purchase Services Promote your software Contact Us Links |
Working with the time scaleThe Gantt chart time scale is significant for gantt chart span, for the chart header content and also for chart clarity and readability. All classes of the gantt chart header and the time scale are in the package eu.beesoft.gantt.chart:
There is very low probability you need to customize these classes. They are created by JavaGantt in initialization phase. All you need to do is to use them. Zoom policy The zoom policy defines the way the chart is zoomed in / out. There is defined an interface ZoomPolicy and also its default implementation built in ChartComponent. But maybe you will need create your own. The ZoomPolicy requires to implement 4 methods:
They could be implemented in this manner, for example: public class MyZoom implements ZoomPolicy { private TimeUnit[] majorStep; private TimeUnit[] minorStep; private int[] widthStep; public Zoom () { majorStep = new TimeUnit[5]; minorStep = new TimeUnit[5]; widthStep = new int[5]; majorStep[0] = TimeUnit.WEEK; minorStep[0] = TimeUnit.DAY; widthStep[0] = 80; majorStep[1] = TimeUnit.MONTH; minorStep[1] = TimeUnit.DAY; widthStep[1] = 40; majorStep[2] = TimeUnit.MONTH; minorStep[2] = TimeUnit.WEEK; widthStep[2] = 20; majorStep[3] = TimeUnit.YEAR; minorStep[3] = TimeUnit.WEEK; widthStep[3] = 10; majorStep[4] = TimeUnit.YEAR; minorStep[4] = TimeUnit.MONTH; widthStep[4] = 5; } public int getStepCount () { return majorStep.length; } public TimeUnit getMajorStep (int index) { return majorStep[index]; } public TimeUnit getMinorStep (int index) { return minorStep[index]; } public int getTimeSpanWidth (int index) { return widthStep[index]; } } How to customize text for chart header When HeaderModel (re)constructs itself, it calls method GanttModel.getChartHeaderText (Date, TimeUnit, boolean) for each relevant date. So this method in GanttModel is the place to customize chart header texts. What you have to do is to return text for given Date and time granularity (TimeUnit). For example, if TimeUnit is YEAR, you will return "2010" if date is of that year. The third (boolean) argument distinguishes between request for major and minor header, because you may want to display the same value differently in each other header.
|