2

We are trying to display Timeseries chart with dynamic x-axis values. We are using the below code, which contains date values in the first argument.

Can any one suggest the way how to set minimum date to x-axis tick values

for(int i=NUMBER_TWELEVE;i>=NUMBER_ZERO;i--)
 {
      series1.add(new Week(new Date(p1.get(i).getYear(),p1.get(i).getMonth(),p1.get(i).getDate())),actualValues.get(i));

 }
 TimeSeries   series2   = new TimeSeries(key+" Expectation");
 for(int i=NUMBER_TWELEVE;i>=NUMBER_ZERO;i--)
 {
     series2.add(new Week(new Date(p1.get(i).getYear(),p1.get(i).getMonth(),p1.get(i).getDate())),expectedValues.get(i));

 }
 TimeSeriesCollection xyDataset = new TimeSeriesCollection();  
  xyDataset.addSeries(series1);
  xyDataset.addSeries(series2);

We are seeting minimum date using below.

     Date minDate = new Date(p1.get(NUMBER_TWELEVE).getYear(),p1.get(NUMBER_TWELEVE).getMonth(),p1.get(NUMBER_TWELEVE).getDate());

   DateAxis dateaxis = (DateAxis) plot.getDomainAxis();
 dateaxis.setAutoRange(false);
 dateaxis.setAutoTickUnitSelection(false);
 dateaxis.setMinimumDate(minDate);
Srinivas B
  • 1,821
  • 4
  • 17
  • 35
  • 2
    Here is a working code snippet from one of my applications. Hope it may be helpful for you: http://stackoverflow.com/questions/17204745/jfreechart-bar-chart-production/17205022#17205022 – Shailesh Saxena Aug 05 '14 at 10:31

0 Answers0