Page 1 of 1

Vertical Lines Do Not Clip

Posted: Wed Mar 23, 2011 6:11 pm
by 15355183
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.

Re: Vertical Lines Do Not Clip

Posted: Fri Mar 25, 2011 5:49 pm
by yeray
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) {
            }
        });
    }

Re: Vertical Lines Do Not Clip

Posted: Fri Mar 25, 2011 6:27 pm
by 15355183
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.

Re: Vertical Lines Do Not Clip

Posted: Mon Mar 28, 2011 3:06 pm
by yeray
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);