Charts DateAxis / PeriodAxis

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
RET
Posts: 1
Joined: Thu Jan 13, 2011 8:46 am
antibot: No, of course not.

Charts DateAxis / PeriodAxis

Post by RET » Thu Jan 13, 2011 9:15 am

Hello!

I try to customize my Axis to display several information in 3 rows. So far i have 3 rows but some problems with the last row.
to illustrate, this is the status quo:
Image
img5.imagebanana.com/img/50uv2hs5/chart_is.png

The blue Labels should have the following format:
tickmark right above the label (for the hours)
full hours displayed (01:00, 02:00, ...)

if zoomed in
the tickmarks should get finer
labels should display something like 01:00, 01:15, 01:30, 01:45, 02:00, 02:15, ... (snap every 15 minutes)

my code so far:

Code: Select all

// DateAxis axis = (DateAxis) chart.getXYPlot().getDomainAxis();
PeriodAxis axis = new PeriodAxis(null);
final TickUnits units = new TickUnits();
units.add(new DateTickUnit(DateTickUnitType.MINUTE, 15,new SimpleDateFormat("HH:mm")));
units.add(new DateTickUnit(DateTickUnitType.HOUR, 1, new SimpleDateFormat("EE HH:mm")));
units.add(new DateTickUnit(DateTickUnitType.DAY, 1, new SimpleDateFormat("EE dd.MM.yyyy")));
units.add(new DateTickUnit(DateTickUnitType.MONTH, 1, new SimpleDateFormat("MMMMM yyyy")));
axis.setStandardTickUnits(units);

PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[3];
aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(Hour.class, new SimpleDateFormat("HH:mm"), new RectangleInsets(), new Font("SansSerif", 0, 10), Color.blue, true, new BasicStroke(0.0F), Color.LIGHT_GRAY);
aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("dd.MM.yyyy"), new RectangleInsets(), new Font("SansSerif", 0, 12), Color.BLACK, true, new BasicStroke(1.0F), Color.BLACK);
aperiodaxislabelinfo[2] = new PeriodAxisLabelInfo(Month.class, new SimpleDateFormat("MMMMM"), new RectangleInsets(), new Font("SansSerif", 1, 12), Color.BLACK, true, new BasicStroke(1.0F), Color.BLUE);
axis.setLabelInfo(aperiodaxislabelinfo);
axis.setAutoRangeTimePeriodClass(Day.class);
chart.getXYPlot().setDomainAxis(axis);
how may i achieve this?

Locked