[SOLVED] LogarithmicAxis zoom

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Alex4924
Posts: 6
Joined: Wed Nov 23, 2011 10:51 am
antibot: No, of course not.

[SOLVED] LogarithmicAxis zoom

Post by Alex4924 » Wed Nov 30, 2011 5:06 pm

Hello everybody,

I use the LogarithmicAxis in my chart, and I don't want ot display values below zero when i zoom out.

Is it possible?

Thanks
Last edited by Alex4924 on Wed Dec 07, 2011 11:08 am, edited 1 time in total.

maryan
Posts: 7
Joined: Thu Dec 01, 2011 9:53 am
antibot: No, of course not.

Re: LogarithmicAxis zoom

Post by maryan » Thu Dec 01, 2011 11:36 am

I think that you can try to override zoomOutBoth method from ChartPanel.

mkrauskopf
Posts: 31
Joined: Thu May 27, 2010 4:23 pm
antibot: No, of course not.

Re: LogarithmicAxis zoom

Post by mkrauskopf » Tue Dec 06, 2011 10:28 am

Or you might do something like (tweak to your needs):

Code: Select all

    private static LogarithmicAxis newZeroBasedLogAxis() {
        LogarithmicAxis axis = new LogarithmicAxis(null /* maybe title */) {
            @Override
            public Range getRange() {
                Range sRange = super.getRange();
                // ensure lowerBound < upperBound to prevent exception
                return new Range(
                        Math.max(0, sRange.getLowerBound()),
                        Math.max(1e-8, sRange.getUpperBound()));
            }
        };
        axis.setAllowNegativesFlag(true);
        // ... init as you wish ...
        return axis;
    }

    private void aMethod() {
        .....
        XYPlot plot = (XYPlot) chart.getPlot();
        plot.setDomainAxis(newZeroBasedLogAxis());
        plot.setRangeAxis(newZeroBasedLogAxis());
        .....
    }
Cheers,
- m.

Alex4924
Posts: 6
Joined: Wed Nov 23, 2011 10:51 am
antibot: No, of course not.

Re: LogarithmicAxis zoom

Post by Alex4924 » Tue Dec 06, 2011 3:32 pm

Thank a lot,

my problem is almost solved, Do you know how to add tick marks, for example 1000 -> 1KBq?

Alex4924
Posts: 6
Joined: Wed Nov 23, 2011 10:51 am
antibot: No, of course not.

[SOLVED] LogarithmicAxis zoom

Post by Alex4924 » Wed Dec 07, 2011 11:06 am

My probleme is solved, Thank you mkrauskopf!!

maryan
Posts: 7
Joined: Thu Dec 01, 2011 9:53 am
antibot: No, of course not.

Re: LogarithmicAxis zoom

Post by maryan » Wed Dec 07, 2011 2:12 pm

Alex4924 wrote:Thank a lot,

my problem is almost solved, Do you know how to add tick marks, for example 1000 -> 1KBq?
How did you solve this?

Alex4924
Posts: 6
Joined: Wed Nov 23, 2011 10:51 am
antibot: No, of course not.

Re: [SOLVED] LogarithmicAxis zoom

Post by Alex4924 » Wed Dec 07, 2011 3:36 pm

I use the méthods

Code: Select all

protected List refreshTicksHorizontal(Graphics2D g2,Rectangle2D dataArea,RectangleEdge edge)
and

Code: Select all

    protected List refreshTicksVertical(Graphics2D g2,Rectangle2D dataArea,RectangleEdge edge)
in the class LogarithmicAxis

Locked