Custom Axes

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
Turc
Newbie
Newbie
Posts: 34
Joined: Wed Feb 03, 2010 12:00 am

Custom Axes

Post by Turc » Mon Jun 20, 2011 7:48 pm

I have 3 Custom Axes.
Custom Axes 1 Relative Position: 0
Custom Axes 2 Relative Position: 5
Custom Axes 3 Relative Position: 10

When I enable the Custom Axes 3 Grid Line, the Grid Line starts from Position 0, but I want it to start at Position 10 so that it starts where the Custom Axes 3 is located. Same goes for Custom Axes 2 - starts at Position 0, instead of 5.

How do I change the Grid Line starting position?

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Custom Axes

Post by Yeray » Tue Jun 21, 2011 11:47 am

Hello Turc,

I'm afraid the Start and End positions of the axes grids aren't configurable. I've added it to the wish list to be implemented in future releases (TJ71015623).
In the meanwhile, you should draw the grids manually as in the following example:

Code: Select all

    private void initChart() throws InstantiationException, IllegalAccessException {
        commander1.setChart(tChart1.getChart());

        tChart1.getAspect().setView3D(false);
        tChart1.getLegend().setVisible(false);
        tChart1.getPanel().setMarginLeft(5);
        
        com.steema.teechart.styles.Line l = new com.steema.teechart.styles.Line(tChart1.getChart());
        l.fillSampleValues();
            
        com.steema.teechart.axis.Axis a = new com.steema.teechart.axis.Axis();
        tChart1.getAxes().getCustom().add(a);
        l.setCustomVertAxis(a);
        a.setRelativePosition(20);
        a.getGrid().setVisible(false);
        
        tChart1.addChartPaintListener(new ChartPaintListener() {

            @Override
            public void axesPainting(ChartDrawEvent e) {}

            @Override
            public void chartPainted(ChartDrawEvent e) {
                com.steema.teechart.axis.Axis axis = tChart1.getAxes().getCustom().getAxis(0);
                tChart1.getGraphics3D().getPen().setColor(axis.getGrid().getColor());
                
                double tmpIncr = axis.getCalcIncrement();
                double tmpValue = axis.getMaximum() / tmpIncr;
                tmpValue = tmpIncr * (int) (tmpValue);
                double tmp = (axis.getMinimum() - axis.getMinAxisIncrement()) / (1.0 + axis.getMinAxisIncrement());

                while (tmpValue >= tmp) {
                    int ypos = axis.calcPosValue(tmpValue);
                    tChart1.getGraphics3D().line(axis.getPosition(), ypos, tChart1.getAxes().getBottom().iEndPos, ypos);
                    tmpValue -= tmpIncr;
                }
            }

            @Override
            public void chartPainting(ChartDrawEvent e) {}

            @Override
            public void seriesPainting(ChartDrawEvent e) {}

            @Override
            public void seriesPainted(ChartDrawEvent e) {}
        });
    }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply