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.
BUG? Unable to set min and max of date axis
Re: BUG? Unable to set min and max of date axis
Should the second roll method call be on maxCalendar?
Regards,
DG.
Regards,
DG.
Re: BUG? Unable to set min and max of date axis
David:
ARRGH!
I looked at that code for an hour!
I am sorry for the alarm.
Thanks,
Neil.
ARRGH!
I looked at that code for an hour!
I am sorry for the alarm.
Thanks,
Neil.
Re: BUG? Unable to set min and max of date axis
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.
Regards,
DG.