We're on jfree chart version 10 and I have the below code that I am using to plot data for the given values.
Let's say I have 3 sets of data for x-axis being date and y-axis being the number.
('06/15/2010', 2);
('12/30/2010', 4);
('05/16/2011', 10);
With the current code, it labels the x-axis with dates as the beginning and end of year from the given data. The actual plot for the dates uses those begin/ending year dates as reference but the actual dates don't get displayed. What I really would like the actual dates displayed on x-axis for each plot.
Any pointers will be very appreciated to accomplish. Thanks.
Code: Select all
DateAxis axis = (DateAxis) plot.getDomainAxis();
final TickUnits standardUnits = new TickUnits();
DateFormat dtFormatter = new SimpleDateFormat("MM/dd/yyyy");
standardUnits.add(new DateTickUnit(DateTickUnit.DAY, 1, dtFormatter));
standardUnits.add(new DateTickUnit(DateTickUnit.DAY, 7, dtFormatter));
standardUnits.add(new DateTickUnit(DateTickUnit.MONTH, 1, dtFormatter));
standardUnits.add(new DateTickUnit(DateTickUnit.MONTH, 12, dtFormatter));
standardUnits.add(new DateTickUnit(DateTickUnit.YEAR, 1, dtFormatter));
standardUnits.add(new DateTickUnit(DateTickUnit.YEAR, 365, dtFormatter));
axis.setStandardTickUnits(standardUnits);