How to remove Intermediate Intervals in Y aixs of Step Chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
sathu77
Posts: 16
Joined: Mon Dec 13, 2010 7:42 pm
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by sathu77 » Tue Dec 21, 2010 1:42 pm

Hi ,
Any help on the above issue.It will be helpful if we get any sample implementation code.

Thanks,
SAT

barbarius
Posts: 74
Joined: Tue Jul 27, 2010 9:33 am
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by barbarius » Tue Dec 21, 2010 1:56 pm

its a long job..

EDIT: yeah i tried but it looks long if you want to change the whole label processing system

barbarius
Posts: 74
Joined: Tue Jul 27, 2010 9:33 am
antibot: No, of course not.

Re: How to remove Intermediate Intervals in Y aixs of Step Chart

Post by barbarius » Tue Dec 21, 2010 3:08 pm

add this method to org.jfree.text.TextUtilities

Code: Select all

public static void drawLogString(final String text, final Graphics2D g2,
            final float x, final float y, final TextAnchor textAnchor,
            final double angle, final TextAnchor rotationAnchor) {
                
        if ((text == null) || (text.equals(""))) {
            return;
        }
        
        final float[] textAdj = deriveTextBoundsAnchorOffsets(g2, text,
                textAnchor);
        final float[] rotateAdj = deriveRotationAnchorOffsets(g2, text,
                rotationAnchor);
        
        final AffineTransform saved = g2.getTransform();

        // apply the rotation...
        final AffineTransform rotate = AffineTransform.getRotateInstance(
                angle, x + textAdj[0] + rotateAdj[0], y + textAdj[1] + rotateAdj[1]);
        g2.transform(rotate);    
        
        int scoreIndex = text.indexOf('^');
        if(scoreIndex != -1) {
            StringBuilder text1 = new StringBuilder(text.length()-1);
            text1.append( text.substring(0,scoreIndex) ).append( text.substring(scoreIndex+1) );
            AttributedString as = new AttributedString(text1.toString());
            as.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER,
                    scoreIndex, text1.length());
            g2.drawString(as.getIterator(), x + textAdj[0], y + textAdj[1]);
        }
        else g2.drawString(text, x + textAdj[0], y + textAdj[1]);
        
        g2.setTransform(saved);
    }

and in ValueAxis class line 705, replace the method call to

Code: Select all

TextUtilities.drawLogString(...)
you can set a flag system on ValueAxis (a boolean isSuperscored for example) and make an if check for this method. that would look nicer

Locked