How to show Bi-Axis (Date and RelativeDateFormat) on Gantt

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
gus315
Posts: 5
Joined: Wed Dec 27, 2006 4:29 am

How to show Bi-Axis (Date and RelativeDateFormat) on Gantt

Post by gus315 » Mon Jul 02, 2007 4:36 am

Hi all,

I tried to show two axis on Gantt Chart. One is date, and the other is date elapse. However, I couldn't get correct date elapse. I only got one negative point. I debugged RelativeDateFormat code, and found that the currentMillis in the format method of RelativeDateFormat was always 0:

Code: Select all

    public StringBuffer format(Date date, StringBuffer toAppendTo,
                               FieldPosition fieldPosition) {
        long currentMillis = date.getTime();
        long elapsed = currentMillis - this.baseMillis;
The following is my code. I really appreciate it if anybody can give me a help. Thank you very much in advance.

Code: Select all

DateAxis dateAxis2 = new DateAxis();
dateAxis2.setVisible(true);
ganttPlot.setRangeAxis(2, dateAxis2);
ganttPlot.setRangeAxisLocation(2, AxisLocation.TOP_OR_LEFT);


Minute minute = new Minute(0, 9, 1, 10, 2001);

DateAxis dateAxis1 = new DateAxis();
dateAxis1.setVisible(true);
//dateAxis1.setFixedAutoRange(1);
//dateAxis1.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7));

RelativeDateFormat rdf = new RelativeDateFormat(minute.getFirstMillisecond());
//relativedateformat.setSecondFormatter(new DecimalFormat("00"));
dateAxis1.setDateFormatOverride(rdf); 

ganttPlot.setRangeAxis(1, dateAxis1);
ganttPlot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Mon Jul 02, 2007 6:17 am

Most likely one of the axes is getting its range automatically from the dataset, while the other has no dataset so takes the default range. There isn't a good mechanism for keeping the ranges for two axes synchronised (although that would be a good feature). You'll have to set the range on the second axis manually.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked