4
我想在圖表中使用PeriodAxis來繪製一些時間序列數據。第一個數據點發生在2012-01-08 19:00:00,最終數據點發生在2012-01-09 19:00:00。JFreeChart PeriodAxis:29分鐘分數
繪製圖表時,刻度標籤從19:29開始到19:29結束。我希望他們在19:00開始並相應地結束 - 也就是說,我不想要:29分鐘的分數。我試圖使用setStandardTickUnits()將刻度標籤增量設置爲1小時增量,但這並沒有改變任何東西。我似乎無法找到任何其他方法,這將允許我更改刻度單位。
示例代碼:
PeriodAxis domain = new PeriodAxis(null, new Hour(19, new Day(8, SerialDate.JANUARY, 2012)),
new Hour(19, new Day(9, SerialDate.JANUARY, 2012)));
domain.setAutoRangeTimePeriodClass(Hour.class);
PeriodAxisLabelInfo[] periodLabels = new PeriodAxisLabelInfo[2];
periodLabels[0] = new PeriodAxisLabelInfo(Hour.class, new SimpleDateFormat("HH:mm"));
periodLabels[1] = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("MMM dd, yyyy"));
domain.setLabelInfo(periodLabels);
domain.setLowerMargin(0);
domain.setUpperMargin(0);
TickUnits tu = new TickUnits();
tu.add(new DateTickUnit(DateTickUnit.HOUR, 1));
domain.setAutoTickUnitSelection(true);
domain.setStandardTickUnits(tu);
我需要使用PeriodAxis,所以我會將我的日期格式設置爲「hh:00」。謝謝。 – Tiago