I am using JFreeChart to display a value for each day of a month. Now I want to have my x-axis display the weeks in a month instead of the days. At the moment the values for my graph are double on the y-axis and int on the x axis.
Timestamp ts = a.getTimestamp();
Double val = a.getVal();
series1.add(ts.getDate(), val);
I am using
plot.getDomainAxis().setRange(0, 31);
to set the range for the days to one month and
xax.setTickUnit(new NumberTickUnit(7));
for the x-axis to display the ticks at the right position. Instead of displaying the days (0, 7, 14, 21, 28) i want them to be weeks (0, 1, 2, 3, 4).
Is that even possible, and how would I be able to do that?
You should use a
DateAxis
for your time axis, likeChartFactory.createTimeSeriesChart()
does. Then you can usesetDateFormatOverride()
, like they show here, and theSimpleDateFormat
for "week in month."