Hi
on a axis, how can I change the tickLabel that are diffents from the real values?
my Axis X is based on date of year that have 3 possibles:
- week (1 -> 52 or 53)
- month (1 -> 12)
- quarter (1 -> 4)
the problem occurs if the rangs are over on 2 years
for ex: the rang is from 01/12/2010 to 05/03/2011 and i want to display with format 'week'
in this cas, the real rang in 'week' is from 48/2010, 49/2010, 50/2010, 51/2010, 52/2010, 01/2011, 02/2011 ... 09/2011
Could you tell me how to display on axis X the values 48, 49, 50, 51, 52, and then 1, 2, .... 9
thanks a lot
BO
rang Axis X & tickLabel
rang Axis X & tickLabel
Last edited by BO on Wed Sep 28, 2011 6:52 am, edited 1 time in total.
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: rang Axis X & displayed value
Code: Select all
((DateAxis)chart.getXYPlot().getDomainAxis()).setDateFormatOverride(new SimpleDateFormat("'Week' w"));
Re: rang Axis X & tickLabel
hi paradoxoff
do you know why the format ww/yyyy of the date '01/01/2010' gave 53/2010 and not '53/2009' ?

other problem
I don't know why I have the same values on DomaineAxis :
very strange

thanks
do you know why the format ww/yyyy of the date '01/01/2010' gave 53/2010 and not '53/2009' ?
other problem
I don't know why I have the same values on DomaineAxis :
very strange

Code: Select all
org.jfree.data.time.RegularTimePeriod periodeTemp = org.jfree.data.time.RegularTimePeriod.createInstance(class org.jfree.data.time.Month, date_i, TimeZone.getDefault());
...
DateAxis dateaxis = (DateAxis)plot.getDomainAxis();
dateaxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy"));
thanks
Last edited by BO on Wed Sep 28, 2011 7:03 am, edited 1 time in total.
Re: rang Axis X & tickLabel
I do it with following code:
Code: Select all
if (periode_id.equals("month")) { // month
dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1, new SimpleDateFormat(pPERIODE_FORMAT1))); // Deprecated. As of version 1.0.13, use DateTickUnitType instead.
dateaxis.setVerticalTickLabels(true);
} else if (periode_id.equals("quarter")) { // // quarter of year
String[] quarters={" 1.", " 2.", " 3.", " 4."};
dateaxis.setDateFormatOverride(new QuarterDateFormat(TimeZone.getDefault(),quarters, true));
dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 3, new SimpleDateFormat(pPERIODE_FORMAT1)));
} else { // week
dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7, new SimpleDateFormat(pPERIODE_FORMAT1)));
dateaxis.setVerticalTickLabels(true);
/*PeriodAxis periodaxis = new PeriodAxis("week");
periodaxis.setMajorTickTimePeriodClass(jfreechartTimeClass);
periodaxis.setMinorTickTimePeriodClass(jfreechartTimeClass);
PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[2];
aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(jfreechartTimeClass, new SimpleDateFormat("w"));
aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Year.class, new SimpleDateFormat("yyyy"));
periodaxis.setLabelInfo(aperiodaxislabelinfo);
plot.setDomainAxis(periodaxis);*/
}
now I would like to show the 1srt unite of time (Quarter, Month, of Week) on the 1srt band and the YEAR on the 2snd one
I saw the PeriodAxisDemo1 using PeriodAxis but in my cas, I have to use DateAxis and not PeriodAxis (the RangeGridlines of 2 charts are differents)
Someone can help me?
thanks a lot
BO
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: rang Axis X & tickLabel
There is not an easy solution in JFreeChart for what you want to do. PeriodAxis was my previous attempt at getting something like this to work in a general way. I wasn't 100% happy with the result (it has a few quirks) but it was useful enough to release.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: rang Axis X & tickLabel
Oh, and that "53/2010" label looks like a bug for sure.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

