NumberAxis does not show axis labels when values too big

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
ge0ffrey
Posts: 20
Joined: Sat Feb 27, 2010 6:44 pm
antibot: No, of course not.

NumberAxis does not show axis labels when values too big

Post by ge0ffrey » Fri Jan 15, 2016 11:54 am

Our Y-Axis labels don't show up when the values become too big:
Image

Here's how we create our plot:

Code: Select all

        NumberAxis yAxis = new NumberAxis("Best score level 1");
        yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale));
        yAxis.setAutoRangeIncludesZero(false);
        XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
Here's a few of the values that we add:

Code: Select all

double d1 = -1244000000000000000L;
double d2 = -1243000000000000000L;
double d3 = -1242900000000000000L;
double d4 = -1242763872527472296L;
Note that all these values are different from each other, even after being converted from a long to a double.

Using JFreeChart 1.0.19. Downstream issue:
https://issues.jboss.org/browse/PLANNER-503

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: NumberAxis does not show axis labels when values too big

Post by david.gilbert » Sun Jan 17, 2016 8:17 pm

Is the axis using the newer NumberTickUnitSource? I thought this one was able to handle larger tick sizes. I will take a look as soon as I have a chance.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

ge0ffrey
Posts: 20
Joined: Sat Feb 27, 2010 6:44 pm
antibot: No, of course not.

Re: NumberAxis does not show axis labels when values too big

Post by ge0ffrey » Mon Jan 18, 2016 4:39 pm

Thanks for taking a look.
My number axis code (see above in my original post), uses a normal JFreeChart NumberAxis which does use NumberTickUnitSource in 1.0.19 (code proof below).

Code: Select all

    
    // My code
    NumberAxis yAxis = new NumberAxis("Best score level 1");

    // JFreeChart code
    public NumberAxis(String label) {
        super(label, NumberAxis.createStandardTickUnits());
        ...
    }
    
    // JFreeChart code
    public static TickUnitSource createStandardTickUnits() {
        return new NumberTickUnitSource();
    }

Might the usage of setAutoRangeIncludesZero(false) have anything to do with it?

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: NumberAxis does not show axis labels when values too big

Post by david.gilbert » Mon Jan 18, 2016 10:27 pm

I committed a change to the NumberAxis class that I think will resolve this issue:

http://sourceforge.net/p/jfreechart/code/3333/

It seems the problem arises because the current tick unit (which defaults to 1.0) is used as the best guess for the initial auto-tick selection, but with an axis range that is extremely large (at least relative to the tick size) the interpolation calculation goes awry. Give it a try and let me know if you see any problems.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

ge0ffrey
Posts: 20
Joined: Sat Feb 27, 2010 6:44 pm
antibot: No, of course not.

Re: NumberAxis does not show axis labels when values too big

Post by ge0ffrey » Tue Jan 19, 2016 9:55 am

Thanks for the quick fix David!

I checked out the source from svn (any plans to move to github? ;)
and build it with ant (any plans to move to maven (or gradle)? ;)
but then I got lost on how to deploy the 1.0.20-SNAPSHOT to my local maven repository...

I 'll check if I can hack-replace the jars in my IntelliJ's classpath: if no jfreechart dependencies (including jfreechart-commons) have changed since 1.0.19, that should work...

PS: I've done a number of ANT to maven migrations in the past for a bunch of open source projects,
if you're interested in migrating jfreechart to maven, ping me on IRC www.freenode.net on channel #optaplanner-dev user ge0ffrey
so we can come up with a directory structure and dependency graph proposal that 's good for maven and that you would be comfortable with.

ge0ffrey
Posts: 20
Joined: Sat Feb 27, 2010 6:44 pm
antibot: No, of course not.

Re: NumberAxis does not show axis labels when values too big

Post by ge0ffrey » Tue Jan 19, 2016 10:08 am

The classpath jar hack-replacing in IntelliJ worked.

I verify that your commit for 1.0.20-pre fixes this issue:

Image

Thanks :)

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: NumberAxis does not show axis labels when values too big

Post by david.gilbert » Tue Jan 19, 2016 6:06 pm

ge0ffrey wrote:Thanks for the quick fix David!
No problem!
ge0ffrey wrote:I checked out the source from svn (any plans to move to github?)
Yes. All my other projects are on GitHub now, I'll move JFreeChart 1.0.x over before long.
ge0ffrey wrote:...and build it with ant (any plans to move to maven (or gradle)?
Yes, I will try to get a working Maven build for the 1.0.20 release. I don't mind continuing with Ant since it works for me, but I'd also like to make Maven work for building the plain jar and also for Netbeans project import. I have something in there that sort of works already, for uploading to the Central Repository...but I need to think about how to support both the Java 1.6 build and the JavaFX (Java 1.8) build together.
ge0ffrey wrote:PS: I've done a number of ANT to maven migrations in the past for a bunch of open source projects,
if you're interested in migrating jfreechart to maven, ping me on IRC http://www.freenode.net on channel #optaplanner-dev user ge0ffrey
so we can come up with a directory structure and dependency graph proposal that 's good for maven and that you would be comfortable with.
OK, thanks for the offer. I'll probably ping you when I get to this task.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

ge0ffrey
Posts: 20
Joined: Sat Feb 27, 2010 6:44 pm
antibot: No, of course not.

Re: NumberAxis does not show axis labels when values too big

Post by ge0ffrey » Tue Jan 19, 2016 8:04 pm

Great to hear :)
I look forward to be able to send a Pull Request to JFreeChart!

Locked