A discussion forum for JFreeChart (a 2D chart library for the Java platform).
-
Kousu
- Posts: 63
- Joined: Wed Mar 07, 2007 10:40 pm
Post
by Kousu » Wed Mar 14, 2007 9:59 pm
new Day(1,2,1870) throws up, because org.jfree.date.{SerialDate,SpreadsheetDate} only supports a range from 1900 onwards. This is problematic for me, because I definitely have data before 1900.
Why does it only support this range? I haven't noticed an explanation in the code.
Work arounds I can think of:
- shifting all my data by a certain offset to make the minimum 1900 and writing custom axis renderers that shift all dates back
- fixing SerialDate and related classes to support a more agreeable range
-
RichardWest
- Posts: 844
- Joined: Fri Oct 13, 2006 9:29 pm
- Location: Sunnyvale, CA
Post
by RichardWest » Wed Mar 14, 2007 10:05 pm
See the Java Date class definition
http://java.sun.com/j2se/1.4.2/docs/api ... /Date.html. All the years are based on 1900. Most of these functions have been deprecated and replaced with Calendar functions. Interesting what a quick Google search reveals.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
-
david.gilbert
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
-
Contact:
Post
by david.gilbert » Wed Mar 14, 2007 10:17 pm
That 1900 limitation arose because in the early days of JFreeChart development, I was trying to match the integer representation of dates used by various spreadsheet programs (Lotus-123, MS Excel etc). I really need to fix that...it's one of the worst pieces of code in JFreeChart. Although I probably shouldn't say that, because someone will just point out something even worse...
-
Kousu
- Posts: 63
- Joined: Wed Mar 07, 2007 10:40 pm
Post
by Kousu » Wed Mar 14, 2007 10:36 pm
Oh good, that means it's not by design. I could fix it up for you if you point out how you would do it.
-
mikadodo
- Posts: 2
- Joined: Mon Oct 08, 2007 2:34 pm
Post
by mikadodo » Mon Oct 08, 2007 3:12 pm
Someone has a solution for it ?
Will i run into major problems if i tweak naively the jcommon sources to get it accept a negative minimum_year value ?
-
mikadodo
- Posts: 2
- Joined: Mon Oct 08, 2007 2:34 pm
Post
by mikadodo » Tue Oct 09, 2007 2:10 pm
One solution is to subclass RegularTimePeriod with a class that directly match the JAVA millisecond system time. It's quite straight forward however it may have an impact with other JFreeChart component.
-
Karthicks
- Posts: 20
- Joined: Wed Mar 26, 2003 1:29 pm
- Location: Chennai , India
Post
by Karthicks » Wed Oct 10, 2007 12:31 pm
To support year from 0 to 9999 we the zoho db team has changed below files in jcommon ,
In jcommon/source/org/jfree/date/SerialDate.java
< public static final int SERIAL_UPPER_BOUND = 2958465;
---
> public static final int SERIAL_UPPER_BOUND = 2958465+693960;
< public static final int MINIMUM_YEAR_SUPPORTED = 1900;
---
> public static final int MINIMUM_YEAR_SUPPORTED = 0;//1900;
===================================================================
In In jcommon/source/org/jfree/date/SpreadsheetDate.java
112c112
< if ((year >= 1900) && (year <= 9999)) {
---
> if ((year >= MINIMUM_YEAR_SUPPORTED) && (year <= MAXIMUM_YEAR_SUPPORTED)) {
Recompile below files. After compiling above jcommon files with the change. Since above jcommon changes involes static final constant.
jfreechart/source/org/jfree/data/time/Day.java
jfreechart/source/org/jfree/data/time/Year.java