BUG? Unable to set min and max of date axis

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Neil Aggarwal

BUG? Unable to set min and max of date axis

Post by Neil Aggarwal » Fri May 17, 2002 6:51 pm

Hello:

I am tring to set the range of my time series graph using
the set minimum and maximum values, but it does not
seem to be working.

Here is a graph showing the results of the code below: http://www.jammconsulting.com/burnrated ... rtTest.jsp

Here is the code I used:
// Create a time series data set for the chart
TimeSeriesCollection dataSet = new TimeSeriesCollection();
// Create a time series for the scale weights
BasicTimeSeries series1 = new BasicTimeSeries("Series 1");
dataSet.addSeries(series1);

series1.add(new Day(new Date()),new Integer(190));

// Create the chart
JFreeChart chart = ChartFactory.createTimeSeriesChart("Test Chart","Date","Values",dataSet,true);

// Make sure the y axis has only integer tick units
TickUnits integerTicks = TickUnits.createIntegerTickUnits();
((NumberAxis)chart.getPlot().getAxis(Axis.VERTICAL)).setStandardTickUnits(integerTicks);

// Set the axis range to go between the min wieght and max weight
((NumberAxis)chart.getPlot().getAxis(Axis.VERTICAL)).setAutoRangeMinimumSize(new Integer(5));

// Set the x-axis range to go between yesterday and 5 days from now.
GregorianCalendar minCalendar = new GregorianCalendar();
GregorianCalendar maxCalendar = new GregorianCalendar();
minCalendar.setTime(new Date());
maxCalendar.setTime(new Date());
minCalendar.roll(Calendar.DAY_OF_MONTH,-1);
minCalendar.roll(Calendar.DAY_OF_MONTH,5);
((DateAxis)chart.getPlot().getAxis(Axis.HORIZONTAL)).setMinimumDate(minCalendar.getTime());
((DateAxis)chart.getPlot().getAxis(Axis.HORIZONTAL)).setMaximumDate(maxCalendar.getTime());

The chart is not showing the dates that I set for the x-axis.

I am using jfreechart 0.8.1

Is this a bug?

Thanks,
Neil.

David Gilbert

Re: BUG? Unable to set min and max of date axis

Post by David Gilbert » Sat May 18, 2002 3:43 pm

Should the second roll method call be on maxCalendar?

Regards,

DG.

Neil Aggarwal

Re: BUG? Unable to set min and max of date axis

Post by Neil Aggarwal » Sun May 19, 2002 4:30 pm

David:

ARRGH!

I looked at that code for an hour!

I am sorry for the alarm.

Thanks,
Neil.

David Gilbert

Re: BUG? Unable to set min and max of date axis

Post by David Gilbert » Sun May 19, 2002 7:20 pm

No problem...I'm going to take a closer look at the JFreeChart code and try to make it throw a sensible exception to make it easier to spot this kind of problem.

Regards,

DG.

Locked