PerioAxis LabelInfo Customize Quarter month name

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
castocolina
Posts: 2
Joined: Fri Jan 16, 2009 2:50 pm
Location: Venezuela

PerioAxis LabelInfo Customize Quarter month name

Post by castocolina » Fri Jan 16, 2009 3:54 pm

Hello I have a chart shown quartes periods of data, I want show the month in my data.

This my code:

// Data Set 1
TimeSeries timeseries = new TimeSeries("Price",
org.jfree.data.time.Quarter.class);

// DATA
Calendar cal = GregorianCalendar.getInstance();
cal.set(2002, 2, 01);//month 3 march
Quarter q1 = new Quarter(cal.getTime());
timeseries.add(q1, 400);

Calendar cal2 = GregorianCalendar.getInstance();
cal2.set(2002, 5, 03);//month 6 jun
Quarter q2 = new Quarter(cal2.getTime());
timeseries.add(q2, 450);

XYDataset xydataset = new TimeSeriesCollection(timeseries);

// Create Chart
String s = "Eurodollar Futures Contract (MAR03)";
JFreeChart jfreechart = hartFactory.createTimeSeriesChart(s, "Date",
"Price", xydataset, true, true, false);

XYPlot xyplot = jfreechart.getXYPlot();

xyplot.setDomainZeroBaselineVisible(false);
xyplot.setRangeZeroBaselineVisible(false);

Class<Quarter> infoClass = org.jfree.data.time.Quarter.class;
Class<Year> infoClass2 = org.jfree.data.time.Year.class;

PeriodAxis periodaxis = new PeriodAxis("Date");

PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[2];
aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(infoClass, new SimpleDateFormat("MMMM", new Locale("en", "us")),
new RectangleInsets(2D, 2D, 2D, 2D), new Font("SansSerif", 1,
10), Color.blue, true, new BasicStroke(0.0F),
Color.lightGray);

aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(infoClass2, new SimpleDateFormat("yyyy", new Locale("en", "us")));
periodaxis.setLabelInfo(aperiodaxislabelinfo);

xyplot.setDomainAxis(periodaxis);

NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
numberaxis.setLowerMargin(0.40000000000000002D);
DecimalFormat decimalformat = new DecimalFormat("00.00");
numberaxis.setNumberFormatOverride(decimalformat);

XYBarRenderer xybarrenderer = new XYBarRenderer(0.2);
xyplot.setRenderer(0, xybarrenderer);

try {
ChartUtilities.saveChartAsPNG(new File("PriceVolumeDemo.png"), jfreechart, 300,300);
} catch (Exception e) {
System.err.println(e);
e.printStackTrace();
}

In this case I want to show March and June but is show February and May. I want know if is possible show any moth in my quarter or if is configurable say show the firts, second or third month of the quarters. I want customize moth passed to my DateFormat.

Thanks.

Locked