Vertical Lines Do Not Clip

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

Vertical Lines Do Not Clip

Post by Turc » Wed Mar 23, 2011 6:11 pm

Run TeeChartDemo (TeeChart.Features.jar). Go to Tools > Cursor > Moving program.
Scroll the graph either to the left or right. Notice how the Horizontal Cursor tool clips on the Y-axis and at the end of the graph. Whereas the Vertical Cursor Tool doesn't - it is visible left of the Y-axis and after the end of the graph.

This is the same for Annotations, Lines, etc.

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

Re: Vertical Lines Do Not Clip

Post by Yeray » Fri Mar 25, 2011 5:49 pm

Hello,

If you want you could control the tools visibility manually. You could check if the tool is drawn in the Chart Rect at OnScroll event and set its visibility.

Code: Select all

    com.steema.teechart.styles.Bar bar1;
    com.steema.teechart.tools.CursorTool cursor;
    private void initChart() {
        tChart1.getAspect().setView3D(false);

        bar1 = new com.steema.teechart.styles.Bar(tChart1.getChart());
        bar1.fillSampleValues();

        cursor = new com.steema.teechart.tools.CursorTool(tChart1.getChart());        

        tChart1.addChartMotionListener(new ChartMotionListener() {

            @Override
            public void scrolled(ChartEvent e) {
                Rectangle rect = tChart1.getChart().getChartRect();

                if ((tChart1.getAxes().getBottom().calcPosValue(cursor.getXValue()) < rect.x) || (tChart1.getAxes().getBottom().calcPosValue(cursor.getXValue()) > rect.x + rect.width))
                {
                    if ((tChart1.getAxes().getLeft().calcPosValue(cursor.getYValue()) < rect.y) || (tChart1.getAxes().getLeft().calcPosValue(cursor.getYValue()) > rect.y + rect.height))
                    {
                        cursor.setActive(false);
                    }
                    else
                    {
                        cursor.setActive(true);
                        cursor.setStyle(CursorToolStyle.HORIZONTAL);
                    }
                }
                else if ((tChart1.getAxes().getLeft().calcPosValue(cursor.getYValue()) < rect.y) || (tChart1.getAxes().getLeft().calcPosValue(cursor.getYValue()) > rect.y + rect.height))
                {
                    cursor.setActive(true);
                    cursor.setStyle(CursorToolStyle.VERTICAL);
                }
                else
                {
                    cursor.setActive(true);
                    cursor.setStyle(CursorToolStyle.BOTH);
                }
            }

            @Override
            public void zoomed(ChartEvent e) {
            }

            @Override
            public void unzoomed(ChartEvent 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

Turc
Newbie
Newbie
Posts: 34
Joined: Wed Feb 03, 2010 12:00 am

Re: Vertical Lines Do Not Clip

Post by Turc » Fri Mar 25, 2011 6:27 pm

I already do something similar to that, but what I don't like is that the Annotation completely disappears. I would like whatever is left of the annotation to show on the chart.

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

Re: Vertical Lines Do Not Clip

Post by Yeray » Mon Mar 28, 2011 3:06 pm

Hi Turc,

I'm not sure to understand you.
As you can see in the "Tools\Annotation" example in the feature demo, the annotation tools don't scroll automatically and are drawn out of the chart rect. If you want to control the annotations positions or visibility with the scroll action, you could use the event as in the example above.
If you want your series to be drawn out of the chart rect, you can force it with:

Code: Select all

tChart1.setClipPoints(false);
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